pull/715/head
Travis Fischer 2025-06-10 12:01:46 +07:00
rodzic f18ba2ba8c
commit 9562d92b24
12 zmienionych plików z 257 dodań i 6 usunięć

Wyświetl plik

@ -20,7 +20,11 @@ export default [
}
},
{
files: ['packages/cli/src/**/*.ts', '**/*.test.ts'],
files: [
'packages/cli/src/**/*.ts',
'**/*.test.ts',
'packages/fixtures/valid/**/*.ts'
],
rules: {
'no-console': 'off',
'no-process-env': 'off',

Wyświetl plik

@ -0,0 +1,71 @@
import { defineConfig } from '@agentic/platform'
export default defineConfig({
name: 'test-everything-openapi',
// TODO: deployed url
originUrl: 'TODO',
originAdapter: {
type: 'openapi',
spec: 'TODO/docs'
},
toolConfigs: [
{
name: 'getUser',
enabled: true,
pure: true,
// cacheControl: 'no-cache',
reportUsage: true,
rateLimit: null,
pricingPlanConfigMap: {
free: {
enabled: true,
reportUsage: true
}
}
},
{
name: 'disabledTool',
enabled: false
},
{
name: 'disabledForFreePlanTool',
pricingPlanConfigMap: {
free: {
enabled: false
}
}
},
{
name: 'pureTool',
pure: true
},
{
name: 'unpureToolMarkedPure',
pure: true
},
{
name: 'customCacheControlTool',
cacheControl:
'public, max-age=7200, s-maxage=7200, stale-while-revalidate=3600'
},
{
name: 'noCacheCacheControlTool',
cacheControl: 'no-cache'
},
{
name: 'noStoreCacheControlTool',
cacheControl: 'no-store'
},
{
name: 'customRateLimitTool',
rateLimit: {
interval: '30s',
maxPerInterval: 10
}
},
{
name: 'disabledRateLimitTool',
rateLimit: null
}
]
})

Wyświetl plik

@ -0,0 +1,25 @@
{
"name": "@agentic/platform-fixtures-everything-openapi",
"private": true,
"author": "Travis Fischer <travis@transitivebullsh.it>",
"license": "UNLICENSED",
"repository": {
"type": "git",
"url": "git+https://github.com/transitive-bullshit/agentic-platform.git",
"directory": "packages/fixtures/valid/everything-openapi"
},
"type": "module",
"scripts": {
"start": "tsx src/server.ts",
"test": "run-s test:*",
"test:lint": "eslint .",
"test:typecheck": "tsc --noEmit"
},
"dependencies": {
"@hono/node-server": "catalog:",
"@hono/zod-openapi": "catalog:",
"hono": "catalog:",
"restore-cursor": "catalog:",
"zod": "catalog:"
}
}

Wyświetl plik

@ -0,0 +1,22 @@
import type { ServerType } from '@hono/node-server'
import restoreCursor from 'restore-cursor'
export function initExitHooks({ server }: { server: ServerType }) {
// Gracefully restore the cursor if run from a TTY
restoreCursor()
process.on('SIGINT', () => {
server.close()
process.exit(0)
})
process.on('SIGTERM', () => {
server.close((err) => {
if (err) {
console.error(err)
process.exit(1)
}
process.exit(0)
})
})
}

Wyświetl plik

@ -0,0 +1 @@
export const db = new Map<string, any>()

Wyświetl plik

@ -0,0 +1,48 @@
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
const route = createRoute({
description: 'Gets a user',
tags: ['users'],
operationId: 'getUser',
method: 'get',
path: '/users/{userId}',
request: {
params: z.object({
userId: z.string().openapi({
param: {
description: 'User ID',
name: 'userId',
in: 'path'
}
})
})
},
responses: {
200: {
description: 'A user object',
content: {
'application/json': {
schema: z
.object({
id: z.string(),
name: z.string(),
email: z.string()
})
.openapi('User')
}
}
}
}
})
export function registerGetUser(app: OpenAPIHono) {
return app.openapi(route, async (c) => {
const { userId } = c.req.valid('param')
return c.json({
id: userId,
name: 'John Doe',
email: 'john.doe@example.com'
})
})
}

Wyświetl plik

@ -0,0 +1,26 @@
import { createRoute, type OpenAPIHono, z } from '@hono/zod-openapi'
const route = createRoute({
description: 'Check if the server is healthy',
operationId: 'healthCheck',
method: 'get',
path: '/health',
responses: {
200: {
description: 'OK',
content: {
'application/json': {
schema: z.object({
status: z.string()
})
}
}
}
}
})
export function registerHealthCheck(app: OpenAPIHono) {
return app.openapi(route, async (c) => {
return c.json({ status: 'ok' })
})
}

Wyświetl plik

@ -0,0 +1,29 @@
import { serve } from '@hono/node-server'
import { OpenAPIHono } from '@hono/zod-openapi'
import { logger as honoLogger } from 'hono/logger'
import { initExitHooks } from './exit-hooks'
import { registerGetUser } from './routes/get-user'
import { registerHealthCheck } from './routes/health-check'
export const app = new OpenAPIHono()
app.use(honoLogger())
registerHealthCheck(app)
registerGetUser(app)
app.doc31('/docs', {
openapi: '3.1.0',
info: { title: 'OpenAPI server to test everything', version: '0.1.0' }
})
const port = 3081
export const server = serve({
fetch: app.fetch,
port
})
initExitHooks({ server })
console.log(`Server running on port ${port}`)

Wyświetl plik

@ -0,0 +1,5 @@
{
"extends": "@fisch0920/config/tsconfig-node",
"include": ["*.config.ts", "src"],
"exclude": ["node_modules"]
}

Wyświetl plik

@ -165,7 +165,7 @@ export const toolConfigSchema = z
* }
* }
*/
pricingPlanConfig: z
pricingPlanConfigMap: z
.record(pricingPlanSlugSchema, pricingPlanToolConfigSchema)
.optional()
.describe(

Wyświetl plik

@ -606,6 +606,24 @@ importers:
specifier: 'catalog:'
version: 3.25.51
packages/fixtures/valid/everything-openapi:
dependencies:
'@hono/node-server':
specifier: 'catalog:'
version: 1.14.3(hono@4.7.11)
'@hono/zod-openapi':
specifier: 'catalog:'
version: 0.19.8(hono@4.7.11)(zod@3.25.51)
hono:
specifier: 'catalog:'
version: 4.7.11
restore-cursor:
specifier: 'catalog:'
version: 5.1.0
zod:
specifier: 'catalog:'
version: 3.25.51
packages/hono:
dependencies:
'@agentic/platform-core':

Wyświetl plik

@ -30,8 +30,10 @@
- auth
- custom auth pages for `openauth`
- API gateway
- **do I just ditch the public REST interface and focus on MCP?**
- enforce rate limits
- **enforce rate limits**
- oauth flow
- openapi-kitchen-sink
- mcp-kitchen-sink
- how to handle binary bodies and responses?
- add support for `immutable` in `toolConfigs`
- **Public MCP server interface**
@ -41,8 +43,6 @@
- `_meta` for tool calls
- _still need a way of doing this for initial connection requests_
- mcp auth provider support
- SSE support? (no; post-mvp if at all; only support [streamable http](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) like smithery does, or maybe support both?)
- caching for MCP tool call responses
- binary bodies / responses?
- resources
- prompts
@ -68,6 +68,8 @@
- same for pricing plan line-items
- replace `ms` package
- API gateway
- **do I just ditch the public REST interface and focus on MCP?**
- SSE support? (no; post-mvp if at all; only support [streamable http](https://modelcontextprotocol.io/specification/2025-03-26/basic/transports#streamable-http) like smithery does, or maybe support both?)
- signed requests
- add support for custom headers on responses
- `@agentic/platform-hono`