kopia lustrzana https://github.com/transitive-bullshit/chatgpt-api
pull/715/head
rodzic
97198ebe66
commit
195fff1e23
|
@ -0,0 +1,24 @@
|
||||||
|
import { defineConfig, freePricingPlan } from '@agentic/platform-schemas'
|
||||||
|
|
||||||
|
export default defineConfig({
|
||||||
|
// TODO: resolve name / slug conflicts
|
||||||
|
name: 'My Project',
|
||||||
|
originUrl: 'https://httpbin.org',
|
||||||
|
pricingPlans: [
|
||||||
|
freePricingPlan,
|
||||||
|
{
|
||||||
|
name: 'Basic',
|
||||||
|
slug: 'basic',
|
||||||
|
interval: 'month',
|
||||||
|
trialPeriodDays: 7,
|
||||||
|
lineItems: [
|
||||||
|
{
|
||||||
|
slug: 'base',
|
||||||
|
usageType: 'licensed',
|
||||||
|
amount: 490,
|
||||||
|
interval: 'month'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
})
|
|
@ -3,35 +3,21 @@
|
||||||
exports[`loadAgenticConfig > basic-raw-free-json 1`] = `
|
exports[`loadAgenticConfig > basic-raw-free-json 1`] = `
|
||||||
{
|
{
|
||||||
"name": "My Project",
|
"name": "My Project",
|
||||||
"originAdapter": {
|
|
||||||
"location": "external",
|
|
||||||
"type": "raw",
|
|
||||||
},
|
|
||||||
"originUrl": "https://jsonplaceholder.typicode.com",
|
"originUrl": "https://jsonplaceholder.typicode.com",
|
||||||
"pricingPlans": [
|
|
||||||
{
|
|
||||||
"lineItems": [
|
|
||||||
{
|
|
||||||
"amount": 0,
|
|
||||||
"slug": "base",
|
|
||||||
"usageType": "licensed",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
"name": "Free",
|
|
||||||
"slug": "free",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`loadAgenticConfig > basic-raw-free-ts 1`] = `
|
exports[`loadAgenticConfig > basic-raw-free-ts 1`] = `
|
||||||
{
|
{
|
||||||
"name": "My Project",
|
"name": "My Project",
|
||||||
"originAdapter": {
|
|
||||||
"location": "external",
|
|
||||||
"type": "raw",
|
|
||||||
},
|
|
||||||
"originUrl": "https://jsonplaceholder.typicode.com",
|
"originUrl": "https://jsonplaceholder.typicode.com",
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`loadAgenticConfig > pricing-freemium 1`] = `
|
||||||
|
{
|
||||||
|
"name": "My Project",
|
||||||
|
"originUrl": "https://httpbin.org",
|
||||||
"pricingPlans": [
|
"pricingPlans": [
|
||||||
{
|
{
|
||||||
"lineItems": [
|
"lineItems": [
|
||||||
|
@ -44,6 +30,20 @@ exports[`loadAgenticConfig > basic-raw-free-ts 1`] = `
|
||||||
"name": "Free",
|
"name": "Free",
|
||||||
"slug": "free",
|
"slug": "free",
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"interval": "month",
|
||||||
|
"lineItems": [
|
||||||
|
{
|
||||||
|
"amount": 490,
|
||||||
|
"interval": "month",
|
||||||
|
"slug": "base",
|
||||||
|
"usageType": "licensed",
|
||||||
|
},
|
||||||
|
],
|
||||||
|
"name": "Basic",
|
||||||
|
"slug": "basic",
|
||||||
|
"trialPeriodDays": 7,
|
||||||
|
},
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
`;
|
`;
|
||||||
|
|
|
@ -5,7 +5,11 @@ import { describe, expect, test } from 'vitest'
|
||||||
|
|
||||||
import { loadAgenticConfig } from './load-agentic-config'
|
import { loadAgenticConfig } from './load-agentic-config'
|
||||||
|
|
||||||
const fixtures = ['basic-raw-free-ts', 'basic-raw-free-json']
|
const fixtures = [
|
||||||
|
'basic-raw-free-ts',
|
||||||
|
'basic-raw-free-json',
|
||||||
|
'pricing-freemium'
|
||||||
|
]
|
||||||
|
|
||||||
const fixturesDir = path.join(
|
const fixturesDir = path.join(
|
||||||
fileURLToPath(import.meta.url),
|
fileURLToPath(import.meta.url),
|
||||||
|
|
|
@ -13,9 +13,9 @@ async function main() {
|
||||||
$schema: 'https://json-schema.org/draft-07/schema',
|
$schema: 'https://json-schema.org/draft-07/schema',
|
||||||
// TODO
|
// TODO
|
||||||
// $id: 'https://agentic.so/docs/schema.json',
|
// $id: 'https://agentic.so/docs/schema.json',
|
||||||
title: 'Agentic project schema',
|
title: 'Agentic Project Config Schema',
|
||||||
description:
|
description:
|
||||||
"Schema used by 'agentic.json' files to configure Agentic projects."
|
'JSON Schema used by `agentic.config.{ts,js,json}` files to configure Agentic projects.'
|
||||||
}
|
}
|
||||||
|
|
||||||
// eslint-disable-next-line no-console
|
// eslint-disable-next-line no-console
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
"$schema": "https://json-schema.org/draft-07/schema",
|
"$schema": "https://json-schema.org/draft-07/schema",
|
||||||
"title": "Agentic project schema",
|
"title": "Agentic Project Config Schema",
|
||||||
"description": "Schema used by 'agentic.json' files to configure Agentic projects.",
|
"description": "JSON Schema used by `agentic.config.{ts,js,json}` files to configure Agentic projects.",
|
||||||
"additionalProperties": false,
|
"additionalProperties": false,
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
|
|
@ -1,6 +1,10 @@
|
||||||
import { z } from '@hono/zod-openapi'
|
import { z } from '@hono/zod-openapi'
|
||||||
|
|
||||||
import { deploymentOriginAdapterSchema, pricingPlanListSchema } from './schemas'
|
import {
|
||||||
|
deploymentOriginAdapterSchema,
|
||||||
|
type PricingPlan,
|
||||||
|
pricingPlanListSchema
|
||||||
|
} from './schemas'
|
||||||
|
|
||||||
// TODO:
|
// TODO:
|
||||||
// - **service / tool definitions**
|
// - **service / tool definitions**
|
||||||
|
@ -12,6 +16,18 @@ import { deploymentOriginAdapterSchema, pricingPlanListSchema } from './schemas'
|
||||||
// - optional version
|
// - optional version
|
||||||
// - optional agentic version
|
// - optional agentic version
|
||||||
|
|
||||||
|
export const freePricingPlan = {
|
||||||
|
name: 'Free',
|
||||||
|
slug: 'free',
|
||||||
|
lineItems: [
|
||||||
|
{
|
||||||
|
slug: 'base',
|
||||||
|
usageType: 'licensed',
|
||||||
|
amount: 0
|
||||||
|
}
|
||||||
|
]
|
||||||
|
} as const satisfies PricingPlan
|
||||||
|
|
||||||
export const agenticProjectConfigSchema = z.object({
|
export const agenticProjectConfigSchema = z.object({
|
||||||
name: z.string().describe('Name of the project.'),
|
name: z.string().describe('Name of the project.'),
|
||||||
|
|
||||||
|
@ -46,29 +62,20 @@ export const agenticProjectConfigSchema = z.object({
|
||||||
NOTE: Agentic currently only supports \`external\` API servers. If you'd like to host your API or MCP server on Agentic's infrastructure, please reach out to support@agentic.so.`),
|
NOTE: Agentic currently only supports \`external\` API servers. If you'd like to host your API or MCP server on Agentic's infrastructure, please reach out to support@agentic.so.`),
|
||||||
|
|
||||||
// Optional origin API config
|
// Optional origin API config
|
||||||
originAdapter: deploymentOriginAdapterSchema.default({
|
originAdapter: deploymentOriginAdapterSchema
|
||||||
location: 'external',
|
.default({
|
||||||
type: 'raw'
|
location: 'external',
|
||||||
}),
|
type: 'raw'
|
||||||
|
})
|
||||||
|
.optional(),
|
||||||
|
|
||||||
// Optional subscription pricing config
|
// Optional subscription pricing config
|
||||||
pricingPlans: pricingPlanListSchema
|
pricingPlans: pricingPlanListSchema
|
||||||
.describe(
|
.describe(
|
||||||
'List of PricingPlans to enable subscriptions for the project. Defaults to a single free tier.'
|
'List of PricingPlans configuring which Stripe subscriptions should be available for the project. Defaults to a single free plan which is useful for developing and testing.your project.'
|
||||||
)
|
)
|
||||||
.default([
|
.default([freePricingPlan])
|
||||||
{
|
.optional()
|
||||||
name: 'Free',
|
|
||||||
slug: 'free',
|
|
||||||
lineItems: [
|
|
||||||
{
|
|
||||||
slug: 'base',
|
|
||||||
usageType: 'licensed',
|
|
||||||
amount: 0
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
])
|
|
||||||
})
|
})
|
||||||
export type AgenticProjectConfigInput = z.input<
|
export type AgenticProjectConfigInput = z.input<
|
||||||
typeof agenticProjectConfigSchema
|
typeof agenticProjectConfigSchema
|
||||||
|
|
|
@ -80,15 +80,20 @@ const commonPricingPlanLineItemSchema = z.object({
|
||||||
* Slugs act as the primary key for LineItems. They should be lower and
|
* Slugs act as the primary key for LineItems. They should be lower and
|
||||||
* kebab-cased ("base", "requests", "image-transformations").
|
* kebab-cased ("base", "requests", "image-transformations").
|
||||||
*
|
*
|
||||||
* TODO: ensure user-provided custom LineItems don't use reserved 'base'
|
* The `base` slug is reserved for a plan's default `licensed` line-item.
|
||||||
* and 'requests' slugs.
|
*
|
||||||
|
* The `requests` slug is reserved for charging using `metered billing based
|
||||||
|
* on the number of request made during a given billing interval.
|
||||||
|
*
|
||||||
|
* All other PricingPlanLineItem `slugs` are considered custom line-items.
|
||||||
*/
|
*/
|
||||||
slug: z.union([z.string(), z.literal('base'), z.literal('requests')]),
|
slug: z.union([z.string(), z.literal('base'), z.literal('requests')]),
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The frequency at which a subscription is billed.
|
* The frequency at which a subscription is billed.
|
||||||
*
|
*
|
||||||
* Only optional when `PricingPlan.slug` is `free`.
|
* Only optional on free plans (when `PricingPlan.slug` is `free`), since
|
||||||
|
* free plans don't depend on a billing interval.
|
||||||
*/
|
*/
|
||||||
interval: pricingIntervalSchema.optional(),
|
interval: pricingIntervalSchema.optional(),
|
||||||
|
|
||||||
|
@ -106,6 +111,14 @@ export const pricingPlanLineItemSchema = z
|
||||||
commonPricingPlanLineItemSchema.merge(
|
commonPricingPlanLineItemSchema.merge(
|
||||||
z.object({
|
z.object({
|
||||||
usageType: z.literal('licensed'),
|
usageType: z.literal('licensed'),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The fixed amount to charge per billing interval.
|
||||||
|
*
|
||||||
|
* Specified in the smallest currency unit (e.g. cents for USD).
|
||||||
|
*
|
||||||
|
* So 100 = $1.00 USD, 1000 = $10.00 USD, etc.
|
||||||
|
*/
|
||||||
amount: z.number().nonnegative()
|
amount: z.number().nonnegative()
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
|
@ -136,7 +149,16 @@ export const pricingPlanLineItemSchema = z
|
||||||
*/
|
*/
|
||||||
billingScheme: z.union([z.literal('per_unit'), z.literal('tiered')]),
|
billingScheme: z.union([z.literal('per_unit'), z.literal('tiered')]),
|
||||||
|
|
||||||
// Only applicable for `per_unit` billing schemes
|
//
|
||||||
|
/**
|
||||||
|
* The fixed amount to charge per unit of usage.
|
||||||
|
*
|
||||||
|
* Only applicable for `per_unit` billing schemes.
|
||||||
|
*
|
||||||
|
* Specified in the smallest currency unit (e.g. cents for USD).
|
||||||
|
*
|
||||||
|
* So 100 = $1.00 USD, 1000 = $10.00 USD, etc.
|
||||||
|
*/
|
||||||
unitAmount: z.number().nonnegative().optional(),
|
unitAmount: z.number().nonnegative().optional(),
|
||||||
|
|
||||||
// Only applicable for `tiered` billing schemes
|
// Only applicable for `tiered` billing schemes
|
||||||
|
|
Ładowanie…
Reference in New Issue