@dexto/server 1.6.20 → 1.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a/jsonrpc/methods.cjs +1 -1
- package/dist/a2a/jsonrpc/methods.d.ts +14 -4
- package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
- package/dist/a2a/jsonrpc/methods.js +1 -1
- package/dist/approval/wire-approval-events.cjs +44 -0
- package/dist/approval/wire-approval-events.d.ts +4 -0
- package/dist/approval/wire-approval-events.d.ts.map +1 -0
- package/dist/approval/wire-approval-events.js +20 -0
- package/dist/events/session-sse-subscriber.cjs +167 -0
- package/dist/events/session-sse-subscriber.d.ts +13 -0
- package/dist/events/session-sse-subscriber.d.ts.map +1 -0
- package/dist/events/session-sse-subscriber.js +143 -0
- package/dist/hono/__tests__/test-fixtures.cjs +8 -0
- package/dist/hono/__tests__/test-fixtures.d.ts +1 -0
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +8 -0
- package/dist/hono/index.cjs +40 -8
- package/dist/hono/index.d.ts +45 -4531
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +43 -9
- package/dist/hono/node/index.cjs +51 -6
- package/dist/hono/node/index.d.ts.map +1 -1
- package/dist/hono/node/index.js +51 -6
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +158 -32
- package/dist/hono/routes/a2a-tasks.d.ts +1 -502
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +162 -32
- package/dist/hono/routes/a2a.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +410 -329
- package/dist/hono/routes/agents.d.ts +16043 -68
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +102 -88
- package/dist/hono/routes/approvals.d.ts +2089 -142
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -89
- package/dist/hono/routes/dexto-auth.cjs +40 -33
- package/dist/hono/routes/dexto-auth.d.ts +401 -2
- package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
- package/dist/hono/routes/dexto-auth.js +40 -33
- package/dist/hono/routes/discovery.cjs +16 -14
- package/dist/hono/routes/discovery.d.ts +586 -1
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +16 -14
- package/dist/hono/routes/greeting.cjs +26 -22
- package/dist/hono/routes/greeting.d.ts +787 -3
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +26 -22
- package/dist/hono/routes/health.d.ts +1 -1
- package/dist/hono/routes/key.cjs +60 -52
- package/dist/hono/routes/key.d.ts +1597 -1
- package/dist/hono/routes/key.d.ts.map +1 -1
- package/dist/hono/routes/key.js +60 -52
- package/dist/hono/routes/llm.cjs +382 -349
- package/dist/hono/routes/llm.d.ts +12148 -98
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +386 -349
- package/dist/hono/routes/mcp.cjs +257 -226
- package/dist/hono/routes/mcp.d.ts +6605 -309
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +263 -225
- package/dist/hono/routes/memory.cjs +102 -89
- package/dist/hono/routes/memory.d.ts +5368 -4
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +108 -90
- package/dist/hono/routes/messages.cjs +189 -191
- package/dist/hono/routes/messages.d.ts +3900 -12
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +192 -191
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2875 -2
- package/dist/hono/routes/models.d.ts.map +1 -1
- package/dist/hono/routes/models.js +108 -64
- package/dist/hono/routes/openrouter.cjs +79 -65
- package/dist/hono/routes/openrouter.d.ts +854 -1
- package/dist/hono/routes/openrouter.d.ts.map +1 -1
- package/dist/hono/routes/openrouter.js +79 -65
- package/dist/hono/routes/prompts.cjs +136 -109
- package/dist/hono/routes/prompts.d.ts +2818 -10
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +138 -109
- package/dist/hono/routes/queue.cjs +133 -120
- package/dist/hono/routes/queue.d.ts +5240 -11
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +136 -120
- package/dist/hono/routes/resources.cjs +65 -46
- package/dist/hono/routes/resources.d.ts +1983 -5
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +72 -47
- package/dist/hono/routes/schedules.cjs +233 -226
- package/dist/hono/routes/schedules.d.ts +4198 -22
- package/dist/hono/routes/schedules.d.ts.map +1 -1
- package/dist/hono/routes/schedules.js +233 -226
- package/dist/hono/routes/search.cjs +34 -30
- package/dist/hono/routes/search.d.ts +3094 -17
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +491 -393
- package/dist/hono/routes/sessions.d.ts +18263 -65
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +497 -395
- package/dist/hono/routes/static.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.cjs +57 -61
- package/dist/hono/routes/system-prompt.d.ts +1228 -2
- package/dist/hono/routes/system-prompt.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.js +58 -62
- package/dist/hono/routes/tools.cjs +29 -34
- package/dist/hono/routes/tools.d.ts +1755 -6
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +115 -123
- package/dist/hono/routes/webhooks.d.ts +2501 -11
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +120 -124
- package/dist/hono/routes/workspaces.cjs +84 -79
- package/dist/hono/routes/workspaces.d.ts +2093 -2
- package/dist/hono/routes/workspaces.d.ts.map +1 -1
- package/dist/hono/routes/workspaces.js +89 -80
- package/dist/hono/schemas/responses.cjs +463 -260
- package/dist/hono/schemas/responses.d.ts +1893 -209
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +203 -14
- package/dist/hono/start-server.cjs +9 -0
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +9 -0
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +7 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,
|
|
1
|
+
{"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/system-prompt.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEtD,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAarE,QAAA,MAAM,mCAAmC;;;;;;;;;;;;;;;EAciB,CAAC;AAuC3D,QAAA,MAAM,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiBzB,CAAC;AAEH,QAAA,MAAM,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8B1B,CAAC;AAEH,wBAAgB,wBAAwB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8E5D;AAED,KAAK,2BAA2B,GAAG,kBAAkB,CAAC,OAAO,qBAAqB,EAAE,EAAE,CAAC,CAAC;AACxF,KAAK,4BAA4B,GAAG,kBAAkB,CAClD,OAAO,sBAAsB,EAC7B;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,mCAAmC,CAAC,CAAA;CAAE,CAChE,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG,2BAA2B,GAAG,4BAA4B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
2
|
import { DextoRuntimeError, ErrorScope, ErrorType } from "@dexto/core";
|
|
3
|
-
import {
|
|
3
|
+
import { BadRequestErrorResponse, InternalErrorResponse } from "../schemas/responses.js";
|
|
4
4
|
const MAX_SYSTEM_PROMPT_CONTRIBUTOR_CONTENT_CHARS = 12e4;
|
|
5
5
|
const DEFAULT_SYSTEM_PROMPT_CONTRIBUTOR_PRIORITY = 45;
|
|
6
6
|
const ContributorInfoSchema = z.object({
|
|
@@ -13,9 +13,6 @@ const UpsertSystemPromptContributorSchema = z.object({
|
|
|
13
13
|
enabled: z.boolean().optional().describe("Set false to remove the contributor instead of adding/updating it"),
|
|
14
14
|
content: z.string().optional().describe("Static contributor content (required when enabled).")
|
|
15
15
|
}).strict().describe("System prompt contributor update payload.");
|
|
16
|
-
const SystemPromptContributorErrorSchema = StandardErrorEnvelopeSchema.describe(
|
|
17
|
-
"System prompt contributor error response."
|
|
18
|
-
);
|
|
19
16
|
function sanitizeContributorId(value) {
|
|
20
17
|
return value.trim().replace(/[^A-Za-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
21
18
|
}
|
|
@@ -25,76 +22,75 @@ function resolveContributorPriority(value) {
|
|
|
25
22
|
}
|
|
26
23
|
return DEFAULT_SYSTEM_PROMPT_CONTRIBUTOR_PRIORITY;
|
|
27
24
|
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
summary: "Upsert System Prompt Contributor",
|
|
53
|
-
description: "Adds or updates a static system prompt contributor. Set enabled=false (or empty content) to remove.",
|
|
54
|
-
tags: ["config"],
|
|
55
|
-
request: {
|
|
56
|
-
body: {
|
|
57
|
-
content: {
|
|
58
|
-
"application/json": {
|
|
59
|
-
schema: UpsertSystemPromptContributorSchema
|
|
60
|
-
}
|
|
25
|
+
const ListContributorsResponseSchema = z.object({
|
|
26
|
+
contributors: z.array(ContributorInfoSchema).describe("Registered system prompt contributors.")
|
|
27
|
+
}).strict().describe("System prompt contributors list response.");
|
|
28
|
+
const UpsertContributorResponseSchema = z.object({
|
|
29
|
+
id: z.string().describe("Contributor identifier"),
|
|
30
|
+
enabled: z.boolean().describe("Whether the contributor remains enabled"),
|
|
31
|
+
priority: z.number().optional().describe("Contributor priority"),
|
|
32
|
+
replaced: z.boolean().optional().describe("Whether an existing contributor was replaced"),
|
|
33
|
+
removed: z.boolean().optional().describe("Whether the contributor was removed"),
|
|
34
|
+
contentLength: z.number().optional().describe("Stored content length in characters"),
|
|
35
|
+
truncated: z.boolean().optional().describe("Whether the submitted content was truncated")
|
|
36
|
+
}).strict().describe("System prompt contributor upsert response.");
|
|
37
|
+
const listContributorsRoute = createRoute({
|
|
38
|
+
method: "get",
|
|
39
|
+
path: "/system-prompt/contributors",
|
|
40
|
+
summary: "List System Prompt Contributors",
|
|
41
|
+
description: "Lists currently registered system prompt contributors.",
|
|
42
|
+
tags: ["config"],
|
|
43
|
+
responses: {
|
|
44
|
+
200: {
|
|
45
|
+
description: "Current contributor list",
|
|
46
|
+
content: {
|
|
47
|
+
"application/json": {
|
|
48
|
+
schema: ListContributorsResponseSchema
|
|
61
49
|
}
|
|
62
50
|
}
|
|
63
51
|
},
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
},
|
|
81
|
-
400: {
|
|
82
|
-
description: "Invalid contributor update request",
|
|
83
|
-
content: {
|
|
84
|
-
"application/json": {
|
|
85
|
-
schema: SystemPromptContributorErrorSchema
|
|
86
|
-
}
|
|
52
|
+
500: InternalErrorResponse
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const upsertContributorRoute = createRoute({
|
|
56
|
+
method: "post",
|
|
57
|
+
path: "/system-prompt/contributors",
|
|
58
|
+
summary: "Upsert System Prompt Contributor",
|
|
59
|
+
description: "Adds or updates a static system prompt contributor. Set enabled=false (or empty content) to remove.",
|
|
60
|
+
tags: ["config"],
|
|
61
|
+
request: {
|
|
62
|
+
body: {
|
|
63
|
+
content: {
|
|
64
|
+
"application/json": {
|
|
65
|
+
schema: UpsertSystemPromptContributorSchema
|
|
87
66
|
}
|
|
88
67
|
}
|
|
89
68
|
}
|
|
90
|
-
}
|
|
69
|
+
},
|
|
70
|
+
responses: {
|
|
71
|
+
200: {
|
|
72
|
+
description: "Contributor upsert result",
|
|
73
|
+
content: {
|
|
74
|
+
"application/json": {
|
|
75
|
+
schema: UpsertContributorResponseSchema
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
},
|
|
79
|
+
400: {
|
|
80
|
+
...BadRequestErrorResponse
|
|
81
|
+
},
|
|
82
|
+
500: InternalErrorResponse
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
function createSystemPromptRouter(getAgent) {
|
|
86
|
+
const app = new OpenAPIHono();
|
|
91
87
|
return app.openapi(listContributorsRoute, async (ctx) => {
|
|
92
88
|
const agent = await getAgent(ctx);
|
|
93
89
|
const contributors = agent.systemPromptManager.getContributors().map((contributor) => ({
|
|
94
90
|
id: contributor.id,
|
|
95
91
|
priority: contributor.priority
|
|
96
92
|
}));
|
|
97
|
-
return ctx.json({ contributors });
|
|
93
|
+
return ctx.json({ contributors }, 200);
|
|
98
94
|
}).openapi(upsertContributorRoute, async (ctx) => {
|
|
99
95
|
const agent = await getAgent(ctx);
|
|
100
96
|
const payload = ctx.req.valid("json");
|
|
@@ -22,25 +22,15 @@ __export(tools_exports, {
|
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(tools_exports);
|
|
24
24
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
|
-
|
|
26
|
-
type: import_zod_openapi.z.enum(["string", "number", "integer", "boolean", "object", "array"]).optional().describe("Property type"),
|
|
27
|
-
description: import_zod_openapi.z.string().optional().describe("Property description"),
|
|
28
|
-
enum: import_zod_openapi.z.array(import_zod_openapi.z.union([import_zod_openapi.z.string(), import_zod_openapi.z.number(), import_zod_openapi.z.boolean()])).optional().describe("Enum values"),
|
|
29
|
-
default: import_zod_openapi.z.any().optional().describe("Default value")
|
|
30
|
-
}).passthrough().describe("JSON Schema property definition");
|
|
31
|
-
const ToolInputSchema = import_zod_openapi.z.object({
|
|
32
|
-
type: import_zod_openapi.z.literal("object").optional().describe('Schema type, always "object" when present'),
|
|
33
|
-
properties: import_zod_openapi.z.record(JsonSchemaProperty).optional().describe("Property definitions"),
|
|
34
|
-
required: import_zod_openapi.z.array(import_zod_openapi.z.string()).optional().describe("Required property names")
|
|
35
|
-
}).passthrough().describe("JSON Schema for tool input parameters");
|
|
25
|
+
var import_responses = require("../schemas/responses.js");
|
|
36
26
|
const ToolInfoSchema = import_zod_openapi.z.object({
|
|
37
27
|
id: import_zod_openapi.z.string().describe("Tool identifier"),
|
|
38
28
|
name: import_zod_openapi.z.string().describe("Tool name"),
|
|
39
29
|
description: import_zod_openapi.z.string().describe("Tool description"),
|
|
40
30
|
source: import_zod_openapi.z.enum(["local", "mcp"]).describe("Source of the tool (local or mcp)"),
|
|
41
31
|
serverName: import_zod_openapi.z.string().optional().describe("MCP server name (if source is mcp)"),
|
|
42
|
-
inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
|
|
43
|
-
_meta: import_zod_openapi.z.record(import_zod_openapi.z.
|
|
32
|
+
inputSchema: import_responses.ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
|
|
33
|
+
_meta: import_zod_openapi.z.record(import_zod_openapi.z.string(), import_responses.JsonValueSchema).optional().describe("Optional tool metadata (e.g., MCP Apps UI resource info)")
|
|
44
34
|
}).strict().describe("Tool information");
|
|
45
35
|
const AllToolsResponseSchema = import_zod_openapi.z.object({
|
|
46
36
|
tools: import_zod_openapi.z.array(ToolInfoSchema).describe("Array of all available tools"),
|
|
@@ -48,21 +38,22 @@ const AllToolsResponseSchema = import_zod_openapi.z.object({
|
|
|
48
38
|
localCount: import_zod_openapi.z.number().describe("Number of local tools"),
|
|
49
39
|
mcpCount: import_zod_openapi.z.number().describe("Number of MCP tools")
|
|
50
40
|
}).strict().describe("All available tools from all sources");
|
|
41
|
+
const allToolsRoute = (0, import_zod_openapi.createRoute)({
|
|
42
|
+
method: "get",
|
|
43
|
+
path: "/tools",
|
|
44
|
+
summary: "List All Tools",
|
|
45
|
+
description: "Retrieves all available tools from all sources (local and MCP)",
|
|
46
|
+
tags: ["tools"],
|
|
47
|
+
responses: {
|
|
48
|
+
200: {
|
|
49
|
+
description: "All tools",
|
|
50
|
+
content: { "application/json": { schema: AllToolsResponseSchema } }
|
|
51
|
+
},
|
|
52
|
+
500: import_responses.InternalErrorResponse
|
|
53
|
+
}
|
|
54
|
+
});
|
|
51
55
|
function createToolsRouter(getAgent) {
|
|
52
56
|
const app = new import_zod_openapi.OpenAPIHono();
|
|
53
|
-
const allToolsRoute = (0, import_zod_openapi.createRoute)({
|
|
54
|
-
method: "get",
|
|
55
|
-
path: "/tools",
|
|
56
|
-
summary: "List All Tools",
|
|
57
|
-
description: "Retrieves all available tools from all sources (local and MCP)",
|
|
58
|
-
tags: ["tools"],
|
|
59
|
-
responses: {
|
|
60
|
-
200: {
|
|
61
|
-
description: "All tools",
|
|
62
|
-
content: { "application/json": { schema: AllToolsResponseSchema } }
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
57
|
return app.openapi(allToolsRoute, async (ctx) => {
|
|
67
58
|
const agent = await getAgent(ctx);
|
|
68
59
|
const allTools = await agent.getAllTools();
|
|
@@ -88,14 +79,15 @@ function createToolsRouter(getAgent) {
|
|
|
88
79
|
source = "local";
|
|
89
80
|
localCount++;
|
|
90
81
|
}
|
|
82
|
+
const metadataResult = import_responses.JsonObjectSchema.safeParse(toolInfo._meta);
|
|
91
83
|
toolList.push({
|
|
92
84
|
id: toolName,
|
|
93
85
|
name: toolName,
|
|
94
86
|
description: toolInfo.description || "No description available",
|
|
95
87
|
source,
|
|
96
88
|
serverName,
|
|
97
|
-
inputSchema: toolInfo.parameters,
|
|
98
|
-
_meta:
|
|
89
|
+
inputSchema: toolInfo.parameters === void 0 ? void 0 : import_responses.ToolInputSchema.parse(toolInfo.parameters),
|
|
90
|
+
_meta: metadataResult.success ? metadataResult.data : void 0
|
|
99
91
|
});
|
|
100
92
|
}
|
|
101
93
|
toolList.sort((a, b) => {
|
|
@@ -105,12 +97,15 @@ function createToolsRouter(getAgent) {
|
|
|
105
97
|
}
|
|
106
98
|
return a.name.localeCompare(b.name);
|
|
107
99
|
});
|
|
108
|
-
return ctx.json(
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
100
|
+
return ctx.json(
|
|
101
|
+
{
|
|
102
|
+
tools: toolList,
|
|
103
|
+
totalCount: toolList.length,
|
|
104
|
+
localCount,
|
|
105
|
+
mcpCount
|
|
106
|
+
},
|
|
107
|
+
200
|
|
108
|
+
);
|
|
114
109
|
});
|
|
115
110
|
}
|
|
116
111
|
// Annotate the CommonJS export names for ESM import in node:
|