@dexto/server 1.4.0 → 1.5.0
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/hono/__tests__/test-fixtures.cjs +1 -1
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +1 -1
- package/dist/hono/index.cjs +41 -5
- package/dist/hono/index.d.ts +451 -452
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +41 -5
- package/dist/hono/routes/a2a-jsonrpc.cjs +3 -3
- package/dist/hono/routes/a2a-jsonrpc.d.ts +4 -1
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-jsonrpc.js +3 -3
- package/dist/hono/routes/a2a-tasks.cjs +5 -5
- package/dist/hono/routes/a2a-tasks.d.ts +13 -10
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +5 -5
- package/dist/hono/routes/agents.cjs +25 -35
- package/dist/hono/routes/agents.d.ts +6 -407
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +25 -35
- package/dist/hono/routes/approvals.cjs +2 -2
- package/dist/hono/routes/approvals.d.ts +4 -1
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +2 -2
- package/dist/hono/routes/discovery.cjs +67 -0
- package/dist/hono/routes/discovery.d.ts +44 -0
- package/dist/hono/routes/discovery.d.ts.map +1 -0
- package/dist/hono/routes/discovery.js +43 -0
- package/dist/hono/routes/greeting.cjs +2 -2
- package/dist/hono/routes/greeting.d.ts +2 -2
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +2 -2
- package/dist/hono/routes/health.d.ts +2 -2
- package/dist/hono/routes/health.d.ts.map +1 -1
- package/dist/hono/routes/key.cjs +110 -0
- package/dist/hono/routes/key.d.ts +48 -0
- package/dist/hono/routes/key.d.ts.map +1 -0
- package/dist/hono/routes/key.js +90 -0
- package/dist/hono/routes/llm.cjs +12 -34
- package/dist/hono/routes/llm.d.ts +173 -25
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +12 -35
- package/dist/hono/routes/mcp.cjs +8 -8
- package/dist/hono/routes/mcp.d.ts +2 -2
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +8 -8
- package/dist/hono/routes/memory.cjs +5 -5
- package/dist/hono/routes/memory.d.ts +4 -1
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +5 -5
- package/dist/hono/routes/messages.cjs +4 -4
- package/dist/hono/routes/messages.d.ts +12 -12
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +4 -4
- package/dist/hono/routes/models.cjs +319 -0
- package/dist/hono/routes/models.d.ts +107 -0
- package/dist/hono/routes/models.d.ts.map +1 -0
- package/dist/hono/routes/models.js +305 -0
- package/dist/hono/routes/openrouter.cjs +153 -0
- package/dist/hono/routes/openrouter.d.ts +54 -0
- package/dist/hono/routes/openrouter.d.ts.map +1 -0
- package/dist/hono/routes/openrouter.js +134 -0
- package/dist/hono/routes/prompts.cjs +5 -5
- package/dist/hono/routes/prompts.d.ts +4 -1
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +5 -5
- package/dist/hono/routes/queue.cjs +4 -4
- package/dist/hono/routes/queue.d.ts +4 -1
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +4 -4
- package/dist/hono/routes/resources.cjs +3 -3
- package/dist/hono/routes/resources.d.ts +2 -2
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +3 -3
- package/dist/hono/routes/search.cjs +2 -2
- package/dist/hono/routes/search.d.ts +6 -3
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +2 -2
- package/dist/hono/routes/sessions.cjs +9 -9
- package/dist/hono/routes/sessions.d.ts +3 -3
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +9 -9
- package/dist/hono/routes/tools.cjs +126 -0
- package/dist/hono/routes/tools.d.ts +42 -0
- package/dist/hono/routes/tools.d.ts.map +1 -0
- package/dist/hono/routes/tools.js +102 -0
- package/dist/hono/routes/webhooks.cjs +4 -4
- package/dist/hono/routes/webhooks.d.ts +4 -1
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +4 -4
- package/dist/hono/schemas/responses.d.ts +41 -41
- package/dist/hono/start-server.cjs +102 -0
- package/dist/hono/start-server.d.ts +61 -0
- package/dist/hono/start-server.d.ts.map +1 -0
- package/dist/hono/start-server.js +78 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +5 -4
package/dist/hono/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAgBzD,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAQlF,OAAO,EAGH,KAAK,kBAAkB,EAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAuM5D;AAID,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAGxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/hono/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { OpenAPIHono } from "@hono/zod-openapi";
|
|
2
|
+
import { logger } from "@dexto/core";
|
|
2
3
|
import { createHealthRouter } from "./routes/health.js";
|
|
3
4
|
import { createGreetingRouter } from "./routes/greeting.js";
|
|
4
5
|
import { createMessagesRouter } from "./routes/messages.js";
|
|
@@ -16,6 +17,11 @@ import { createMemoryRouter } from "./routes/memory.js";
|
|
|
16
17
|
import { createAgentsRouter } from "./routes/agents.js";
|
|
17
18
|
import { createApprovalsRouter } from "./routes/approvals.js";
|
|
18
19
|
import { createQueueRouter } from "./routes/queue.js";
|
|
20
|
+
import { createOpenRouterRouter } from "./routes/openrouter.js";
|
|
21
|
+
import { createKeyRouter } from "./routes/key.js";
|
|
22
|
+
import { createToolsRouter } from "./routes/tools.js";
|
|
23
|
+
import { createDiscoveryRouter } from "./routes/discovery.js";
|
|
24
|
+
import { createModelsRouter } from "./routes/models.js";
|
|
19
25
|
import {
|
|
20
26
|
createStaticRouter,
|
|
21
27
|
createSpaFallbackHandler
|
|
@@ -44,8 +50,10 @@ const dummyAgentsContext = {
|
|
|
44
50
|
},
|
|
45
51
|
getActiveAgentId: () => void 0
|
|
46
52
|
};
|
|
53
|
+
const DEFAULT_API_PREFIX = "/api";
|
|
47
54
|
function createDextoApp(options) {
|
|
48
55
|
const {
|
|
56
|
+
apiPrefix,
|
|
49
57
|
getAgent,
|
|
50
58
|
getAgentCard,
|
|
51
59
|
approvalCoordinator,
|
|
@@ -53,15 +61,27 @@ function createDextoApp(options) {
|
|
|
53
61
|
sseSubscriber,
|
|
54
62
|
agentsContext,
|
|
55
63
|
webRoot,
|
|
56
|
-
webUIConfig
|
|
64
|
+
webUIConfig,
|
|
65
|
+
disableAuth = false
|
|
57
66
|
} = options;
|
|
67
|
+
if (disableAuth) {
|
|
68
|
+
logger.warn(
|
|
69
|
+
`\u26A0\uFE0F Authentication disabled (disableAuth=true). createAuthMiddleware() skipped. Ensure external auth is in place.`
|
|
70
|
+
);
|
|
71
|
+
}
|
|
58
72
|
const app = new OpenAPIHono({ strict: false });
|
|
59
73
|
app.use("*", createCorsMiddleware());
|
|
60
|
-
|
|
74
|
+
if (!disableAuth) {
|
|
75
|
+
app.use("*", createAuthMiddleware());
|
|
76
|
+
}
|
|
61
77
|
app.onError((err, ctx) => handleHonoError(ctx, err));
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
const
|
|
78
|
+
const rawPrefix = apiPrefix ?? DEFAULT_API_PREFIX;
|
|
79
|
+
const normalizedPrefix = rawPrefix === "" ? "/" : rawPrefix.replace(/\/+$/, "") || "/";
|
|
80
|
+
const middlewarePattern = normalizedPrefix === "/" ? "/*" : `${normalizedPrefix}/*`;
|
|
81
|
+
app.use(middlewarePattern, prettyJsonMiddleware);
|
|
82
|
+
app.use(middlewarePattern, redactionMiddleware);
|
|
83
|
+
const routePrefix = normalizedPrefix;
|
|
84
|
+
const fullApp = app.route("/health", createHealthRouter(getAgent)).route("/", createA2aRouter(getAgentCard)).route("/", createA2AJsonRpcRouter(getAgent, sseSubscriber)).route("/", createA2ATasksRouter(getAgent, sseSubscriber)).route(routePrefix, createGreetingRouter(getAgent)).route(routePrefix, createMessagesRouter(getAgent, approvalCoordinator)).route(routePrefix, createLlmRouter(getAgent)).route(routePrefix, createSessionsRouter(getAgent)).route(routePrefix, createSearchRouter(getAgent)).route(routePrefix, createMcpRouter(getAgent)).route(routePrefix, createWebhooksRouter(getAgent, webhookSubscriber)).route(routePrefix, createPromptsRouter(getAgent)).route(routePrefix, createResourcesRouter(getAgent)).route(routePrefix, createMemoryRouter(getAgent)).route(routePrefix, createApprovalsRouter(getAgent, approvalCoordinator)).route(routePrefix, createAgentsRouter(getAgent, agentsContext || dummyAgentsContext)).route(routePrefix, createQueueRouter(getAgent)).route(routePrefix, createOpenRouterRouter()).route(routePrefix, createKeyRouter()).route(routePrefix, createToolsRouter(getAgent)).route(routePrefix, createDiscoveryRouter()).route(routePrefix, createModelsRouter());
|
|
65
85
|
fullApp.doc("/openapi.json", {
|
|
66
86
|
openapi: "3.0.0",
|
|
67
87
|
info: {
|
|
@@ -141,6 +161,22 @@ function createDextoApp(options) {
|
|
|
141
161
|
{
|
|
142
162
|
name: "queue",
|
|
143
163
|
description: "Manage message queue for busy sessions"
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
name: "openrouter",
|
|
167
|
+
description: "OpenRouter model validation and cache management"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
name: "discovery",
|
|
171
|
+
description: "Discover available providers and capabilities"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
name: "tools",
|
|
175
|
+
description: "List and inspect available tools from internal, custom, and MCP sources"
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
name: "models",
|
|
179
|
+
description: "List and manage local GGUF models and Ollama models"
|
|
144
180
|
}
|
|
145
181
|
]
|
|
146
182
|
});
|
|
@@ -30,7 +30,7 @@ function createA2AJsonRpcRouter(getAgent, sseSubscriber) {
|
|
|
30
30
|
const app = new import_hono.Hono();
|
|
31
31
|
app.post("/jsonrpc", async (ctx) => {
|
|
32
32
|
try {
|
|
33
|
-
const agent = getAgent();
|
|
33
|
+
const agent = await getAgent(ctx);
|
|
34
34
|
const requestBody = await ctx.req.json();
|
|
35
35
|
const isStreamingRequest = !Array.isArray(requestBody) && requestBody.method === "message/stream";
|
|
36
36
|
if (isStreamingRequest) {
|
|
@@ -91,8 +91,8 @@ function createA2AJsonRpcRouter(getAgent, sseSubscriber) {
|
|
|
91
91
|
});
|
|
92
92
|
}
|
|
93
93
|
});
|
|
94
|
-
app.get("/jsonrpc", (ctx) => {
|
|
95
|
-
const agent = getAgent();
|
|
94
|
+
app.get("/jsonrpc", async (ctx) => {
|
|
95
|
+
const agent = await getAgent(ctx);
|
|
96
96
|
const handlers = new import_methods.A2AMethodHandlers(agent);
|
|
97
97
|
return ctx.json({
|
|
98
98
|
service: "A2A JSON-RPC 2.0",
|
|
@@ -7,6 +7,8 @@
|
|
|
7
7
|
import { Hono } from 'hono';
|
|
8
8
|
import type { DextoAgent } from '@dexto/core';
|
|
9
9
|
import type { A2ASseEventSubscriber } from '../../events/a2a-sse-subscriber.js';
|
|
10
|
+
import type { Context } from 'hono';
|
|
11
|
+
type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
|
|
10
12
|
/**
|
|
11
13
|
* Create A2A JSON-RPC router
|
|
12
14
|
*
|
|
@@ -42,5 +44,6 @@ import type { A2ASseEventSubscriber } from '../../events/a2a-sse-subscriber.js';
|
|
|
42
44
|
* @param sseSubscriber SSE event subscriber for streaming methods
|
|
43
45
|
* @returns Hono router with /jsonrpc endpoint
|
|
44
46
|
*/
|
|
45
|
-
export declare function createA2AJsonRpcRouter(getAgent:
|
|
47
|
+
export declare function createA2AJsonRpcRouter(getAgent: GetAgentFn, sseSubscriber: A2ASseEventSubscriber): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
|
|
48
|
+
export {};
|
|
46
49
|
//# sourceMappingURL=a2a-jsonrpc.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a-jsonrpc.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/a2a-jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"a2a-jsonrpc.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/a2a-jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAI9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,qBAAqB,8EA2HhG"}
|
|
@@ -7,7 +7,7 @@ function createA2AJsonRpcRouter(getAgent, sseSubscriber) {
|
|
|
7
7
|
const app = new Hono();
|
|
8
8
|
app.post("/jsonrpc", async (ctx) => {
|
|
9
9
|
try {
|
|
10
|
-
const agent = getAgent();
|
|
10
|
+
const agent = await getAgent(ctx);
|
|
11
11
|
const requestBody = await ctx.req.json();
|
|
12
12
|
const isStreamingRequest = !Array.isArray(requestBody) && requestBody.method === "message/stream";
|
|
13
13
|
if (isStreamingRequest) {
|
|
@@ -68,8 +68,8 @@ function createA2AJsonRpcRouter(getAgent, sseSubscriber) {
|
|
|
68
68
|
});
|
|
69
69
|
}
|
|
70
70
|
});
|
|
71
|
-
app.get("/jsonrpc", (ctx) => {
|
|
72
|
-
const agent = getAgent();
|
|
71
|
+
app.get("/jsonrpc", async (ctx) => {
|
|
72
|
+
const agent = await getAgent(ctx);
|
|
73
73
|
const handlers = new A2AMethodHandlers(agent);
|
|
74
74
|
return ctx.json({
|
|
75
75
|
service: "A2A JSON-RPC 2.0",
|
|
@@ -254,7 +254,7 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
254
254
|
const validatedBody = parseResult.data;
|
|
255
255
|
import_core.logger.info("REST: message/stream", { hasMessage: !!validatedBody.message });
|
|
256
256
|
const taskId = validatedBody.message.taskId;
|
|
257
|
-
const agent = getAgent();
|
|
257
|
+
const agent = await getAgent(ctx);
|
|
258
258
|
const session = await agent.createSession(taskId);
|
|
259
259
|
const stream = sseSubscriber.createStream(session.id);
|
|
260
260
|
const { text, image, file } = (0, import_message.a2aToInternalMessage)(validatedBody.message);
|
|
@@ -276,18 +276,18 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
276
276
|
}
|
|
277
277
|
});
|
|
278
278
|
return app.openapi(messageSendRoute, async (ctx) => {
|
|
279
|
-
const handlers = new import_methods.A2AMethodHandlers(getAgent());
|
|
279
|
+
const handlers = new import_methods.A2AMethodHandlers(await getAgent(ctx));
|
|
280
280
|
const body = ctx.req.valid("json");
|
|
281
281
|
import_core.logger.info("REST: message/send", { hasMessage: !!body.message });
|
|
282
282
|
const result = await handlers.messageSend(body);
|
|
283
283
|
return ctx.json(result);
|
|
284
284
|
}).openapi(listTasksRoute, async (ctx) => {
|
|
285
|
-
const handlers = new import_methods.A2AMethodHandlers(getAgent());
|
|
285
|
+
const handlers = new import_methods.A2AMethodHandlers(await getAgent(ctx));
|
|
286
286
|
const query = ctx.req.valid("query");
|
|
287
287
|
const result = await handlers.tasksList(query);
|
|
288
288
|
return ctx.json(result);
|
|
289
289
|
}).openapi(getTaskRoute, async (ctx) => {
|
|
290
|
-
const handlers = new import_methods.A2AMethodHandlers(getAgent());
|
|
290
|
+
const handlers = new import_methods.A2AMethodHandlers(await getAgent(ctx));
|
|
291
291
|
const { id } = ctx.req.valid("param");
|
|
292
292
|
try {
|
|
293
293
|
const task = await handlers.tasksGet({ id });
|
|
@@ -297,7 +297,7 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
297
297
|
return ctx.json({ error: "Task not found" }, 404);
|
|
298
298
|
}
|
|
299
299
|
}).openapi(cancelTaskRoute, async (ctx) => {
|
|
300
|
-
const handlers = new import_methods.A2AMethodHandlers(getAgent());
|
|
300
|
+
const handlers = new import_methods.A2AMethodHandlers(await getAgent(ctx));
|
|
301
301
|
const { id } = ctx.req.valid("param");
|
|
302
302
|
import_core.logger.info(`REST: tasks/cancel ${id}`);
|
|
303
303
|
try {
|
|
@@ -13,6 +13,8 @@
|
|
|
13
13
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
14
14
|
import type { DextoAgent } from '@dexto/core';
|
|
15
15
|
import type { A2ASseEventSubscriber } from '../../events/a2a-sse-subscriber.js';
|
|
16
|
+
import type { Context } from 'hono';
|
|
17
|
+
type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
|
|
16
18
|
/**
|
|
17
19
|
* Create A2A REST Task router
|
|
18
20
|
*
|
|
@@ -29,7 +31,7 @@ import type { A2ASseEventSubscriber } from '../../events/a2a-sse-subscriber.js';
|
|
|
29
31
|
* @param sseSubscriber SSE event subscriber for streaming
|
|
30
32
|
* @returns OpenAPIHono router with REST task endpoints
|
|
31
33
|
*/
|
|
32
|
-
export declare function createA2ATasksRouter(getAgent:
|
|
34
|
+
export declare function createA2ATasksRouter(getAgent: GetAgentFn, sseSubscriber: A2ASseEventSubscriber): OpenAPIHono<import("hono").Env, {
|
|
33
35
|
"/v1/message:send": {
|
|
34
36
|
$post: {
|
|
35
37
|
input: {
|
|
@@ -60,8 +62,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
60
62
|
})[];
|
|
61
63
|
messageId: string;
|
|
62
64
|
metadata?: Record<string, any> | undefined;
|
|
63
|
-
contextId?: string | undefined;
|
|
64
65
|
taskId?: string | undefined;
|
|
66
|
+
contextId?: string | undefined;
|
|
65
67
|
extensions?: string[] | undefined;
|
|
66
68
|
referenceTaskIds?: string[] | undefined;
|
|
67
69
|
};
|
|
@@ -116,8 +118,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
116
118
|
metadata?: {
|
|
117
119
|
[x: string]: any;
|
|
118
120
|
} | undefined;
|
|
119
|
-
contextId?: string | undefined;
|
|
120
121
|
taskId?: string | undefined;
|
|
122
|
+
contextId?: string | undefined;
|
|
121
123
|
extensions?: string[] | undefined;
|
|
122
124
|
referenceTaskIds?: string[] | undefined;
|
|
123
125
|
} | undefined;
|
|
@@ -165,8 +167,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
165
167
|
metadata?: {
|
|
166
168
|
[x: string]: any;
|
|
167
169
|
} | undefined;
|
|
168
|
-
contextId?: string | undefined;
|
|
169
170
|
taskId?: string | undefined;
|
|
171
|
+
contextId?: string | undefined;
|
|
170
172
|
extensions?: string[] | undefined;
|
|
171
173
|
referenceTaskIds?: string[] | undefined;
|
|
172
174
|
}[] | undefined;
|
|
@@ -230,8 +232,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
230
232
|
metadata?: {
|
|
231
233
|
[x: string]: any;
|
|
232
234
|
} | undefined;
|
|
233
|
-
contextId?: string | undefined;
|
|
234
235
|
taskId?: string | undefined;
|
|
236
|
+
contextId?: string | undefined;
|
|
235
237
|
extensions?: string[] | undefined;
|
|
236
238
|
referenceTaskIds?: string[] | undefined;
|
|
237
239
|
} | undefined;
|
|
@@ -279,8 +281,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
279
281
|
metadata?: {
|
|
280
282
|
[x: string]: any;
|
|
281
283
|
} | undefined;
|
|
282
|
-
contextId?: string | undefined;
|
|
283
284
|
taskId?: string | undefined;
|
|
285
|
+
contextId?: string | undefined;
|
|
284
286
|
extensions?: string[] | undefined;
|
|
285
287
|
referenceTaskIds?: string[] | undefined;
|
|
286
288
|
}[] | undefined;
|
|
@@ -350,8 +352,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
350
352
|
metadata?: {
|
|
351
353
|
[x: string]: any;
|
|
352
354
|
} | undefined;
|
|
353
|
-
contextId?: string | undefined;
|
|
354
355
|
taskId?: string | undefined;
|
|
356
|
+
contextId?: string | undefined;
|
|
355
357
|
extensions?: string[] | undefined;
|
|
356
358
|
referenceTaskIds?: string[] | undefined;
|
|
357
359
|
} | undefined;
|
|
@@ -399,8 +401,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
399
401
|
metadata?: {
|
|
400
402
|
[x: string]: any;
|
|
401
403
|
} | undefined;
|
|
402
|
-
contextId?: string | undefined;
|
|
403
404
|
taskId?: string | undefined;
|
|
405
|
+
contextId?: string | undefined;
|
|
404
406
|
extensions?: string[] | undefined;
|
|
405
407
|
referenceTaskIds?: string[] | undefined;
|
|
406
408
|
}[] | undefined;
|
|
@@ -466,8 +468,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
466
468
|
metadata?: {
|
|
467
469
|
[x: string]: any;
|
|
468
470
|
} | undefined;
|
|
469
|
-
contextId?: string | undefined;
|
|
470
471
|
taskId?: string | undefined;
|
|
472
|
+
contextId?: string | undefined;
|
|
471
473
|
extensions?: string[] | undefined;
|
|
472
474
|
referenceTaskIds?: string[] | undefined;
|
|
473
475
|
} | undefined;
|
|
@@ -515,8 +517,8 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
515
517
|
metadata?: {
|
|
516
518
|
[x: string]: any;
|
|
517
519
|
} | undefined;
|
|
518
|
-
contextId?: string | undefined;
|
|
519
520
|
taskId?: string | undefined;
|
|
521
|
+
contextId?: string | undefined;
|
|
520
522
|
extensions?: string[] | undefined;
|
|
521
523
|
referenceTaskIds?: string[] | undefined;
|
|
522
524
|
}[] | undefined;
|
|
@@ -527,4 +529,5 @@ export declare function createA2ATasksRouter(getAgent: () => DextoAgent, sseSubs
|
|
|
527
529
|
};
|
|
528
530
|
};
|
|
529
531
|
}, "/">;
|
|
532
|
+
export {};
|
|
530
533
|
//# sourceMappingURL=a2a-tasks.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a-tasks.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/a2a-tasks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"a2a-tasks.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/a2a-tasks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAEhF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AA2KrE;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAuN9F"}
|
|
@@ -231,7 +231,7 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
231
231
|
const validatedBody = parseResult.data;
|
|
232
232
|
logger.info("REST: message/stream", { hasMessage: !!validatedBody.message });
|
|
233
233
|
const taskId = validatedBody.message.taskId;
|
|
234
|
-
const agent = getAgent();
|
|
234
|
+
const agent = await getAgent(ctx);
|
|
235
235
|
const session = await agent.createSession(taskId);
|
|
236
236
|
const stream = sseSubscriber.createStream(session.id);
|
|
237
237
|
const { text, image, file } = a2aToInternalMessage(validatedBody.message);
|
|
@@ -253,18 +253,18 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
253
253
|
}
|
|
254
254
|
});
|
|
255
255
|
return app.openapi(messageSendRoute, async (ctx) => {
|
|
256
|
-
const handlers = new A2AMethodHandlers(getAgent());
|
|
256
|
+
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
257
257
|
const body = ctx.req.valid("json");
|
|
258
258
|
logger.info("REST: message/send", { hasMessage: !!body.message });
|
|
259
259
|
const result = await handlers.messageSend(body);
|
|
260
260
|
return ctx.json(result);
|
|
261
261
|
}).openapi(listTasksRoute, async (ctx) => {
|
|
262
|
-
const handlers = new A2AMethodHandlers(getAgent());
|
|
262
|
+
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
263
263
|
const query = ctx.req.valid("query");
|
|
264
264
|
const result = await handlers.tasksList(query);
|
|
265
265
|
return ctx.json(result);
|
|
266
266
|
}).openapi(getTaskRoute, async (ctx) => {
|
|
267
|
-
const handlers = new A2AMethodHandlers(getAgent());
|
|
267
|
+
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
268
268
|
const { id } = ctx.req.valid("param");
|
|
269
269
|
try {
|
|
270
270
|
const task = await handlers.tasksGet({ id });
|
|
@@ -274,7 +274,7 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
274
274
|
return ctx.json({ error: "Task not found" }, 404);
|
|
275
275
|
}
|
|
276
276
|
}).openapi(cancelTaskRoute, async (ctx) => {
|
|
277
|
-
const handlers = new A2AMethodHandlers(getAgent());
|
|
277
|
+
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
278
278
|
const { id } = ctx.req.valid("param");
|
|
279
279
|
logger.info(`REST: tasks/cancel ${id}`);
|
|
280
280
|
try {
|
|
@@ -40,6 +40,9 @@ var import_path = __toESM(require("path"), 1);
|
|
|
40
40
|
var import_fs = require("fs");
|
|
41
41
|
var import_core2 = require("@dexto/core");
|
|
42
42
|
var import_responses = require("../schemas/responses.js");
|
|
43
|
+
const AgentConfigSchemaForOpenAPI = import_zod_openapi.z.record(import_zod_openapi.z.any()).describe(
|
|
44
|
+
"Complete agent configuration. See AgentConfig type documentation for full schema details."
|
|
45
|
+
);
|
|
43
46
|
const AgentIdentifierSchema = import_zod_openapi.z.object({
|
|
44
47
|
id: import_zod_openapi.z.string().min(1, "Agent id is required").describe('Unique agent identifier (e.g., "database-agent")'),
|
|
45
48
|
path: import_zod_openapi.z.string().optional().describe(
|
|
@@ -59,16 +62,14 @@ const CustomAgentInstallSchema = import_zod_openapi.z.object({
|
|
|
59
62
|
author: import_zod_openapi.z.string().min(1).describe("Agent author or organization name"),
|
|
60
63
|
tags: import_zod_openapi.z.array(import_zod_openapi.z.string()).describe("Tags for categorizing the agent"),
|
|
61
64
|
main: import_zod_openapi.z.string().optional().describe("Main configuration file name within source directory")
|
|
62
|
-
}).strict().describe("Agent metadata including description, author, and tags")
|
|
63
|
-
injectPreferences: import_zod_openapi.z.boolean().default(true).describe("Whether to inject user preferences into agent config")
|
|
65
|
+
}).strict().describe("Agent metadata including description, author, and tags")
|
|
64
66
|
}).strict().describe("Request body for installing a custom agent from file system").transform((value) => {
|
|
65
67
|
const displayName = value.name?.trim() || (0, import_agent_management.deriveDisplayName)(value.id);
|
|
66
68
|
return {
|
|
67
69
|
id: value.id,
|
|
68
70
|
displayName,
|
|
69
71
|
sourcePath: value.sourcePath,
|
|
70
|
-
metadata: value.metadata
|
|
71
|
-
injectPreferences: value.injectPreferences
|
|
72
|
+
metadata: value.metadata
|
|
72
73
|
};
|
|
73
74
|
});
|
|
74
75
|
const CustomAgentCreateSchema = import_zod_openapi.z.object({
|
|
@@ -82,7 +83,7 @@ const CustomAgentCreateSchema = import_zod_openapi.z.object({
|
|
|
82
83
|
author: import_zod_openapi.z.string().optional().describe("Author or organization"),
|
|
83
84
|
tags: import_zod_openapi.z.array(import_zod_openapi.z.string()).default([]).describe("Tags for discovery"),
|
|
84
85
|
// Full agent configuration
|
|
85
|
-
config:
|
|
86
|
+
config: AgentConfigSchemaForOpenAPI.describe("Complete agent configuration")
|
|
86
87
|
}).strict().describe("Request body for creating a new custom agent with full configuration");
|
|
87
88
|
const AgentConfigValidateSchema = import_zod_openapi.z.object({
|
|
88
89
|
yaml: import_zod_openapi.z.string().describe("YAML agent configuration content to validate")
|
|
@@ -426,18 +427,13 @@ function createAgentsRouter(getAgent, context) {
|
|
|
426
427
|
}).openapi(installRoute, async (ctx) => {
|
|
427
428
|
const body = ctx.req.valid("json");
|
|
428
429
|
if ("sourcePath" in body && "metadata" in body) {
|
|
429
|
-
const { id, displayName, sourcePath, metadata
|
|
430
|
-
await import_agent_management.AgentFactory.installCustomAgent(
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
author: metadata.author,
|
|
437
|
-
tags: metadata.tags
|
|
438
|
-
},
|
|
439
|
-
injectPreferences
|
|
440
|
-
);
|
|
430
|
+
const { id, displayName, sourcePath, metadata } = body;
|
|
431
|
+
await import_agent_management.AgentFactory.installCustomAgent(id, sourcePath, {
|
|
432
|
+
name: displayName,
|
|
433
|
+
description: metadata.description,
|
|
434
|
+
author: metadata.author,
|
|
435
|
+
tags: metadata.tags
|
|
436
|
+
});
|
|
441
437
|
return ctx.json(
|
|
442
438
|
{ installed: true, id, name: displayName, type: "custom" },
|
|
443
439
|
201
|
|
@@ -517,18 +513,12 @@ function createAgentsRouter(getAgent, context) {
|
|
|
517
513
|
const tmpFile = import_path.default.join(tmpDir, `${id}-${Date.now()}.yml`);
|
|
518
514
|
await import_fs.promises.writeFile(tmpFile, yamlContent, "utf-8");
|
|
519
515
|
try {
|
|
520
|
-
await import_agent_management.AgentFactory.installCustomAgent(
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
author: author || "Custom",
|
|
527
|
-
tags: tags || []
|
|
528
|
-
},
|
|
529
|
-
false
|
|
530
|
-
// Don't inject preferences
|
|
531
|
-
);
|
|
516
|
+
await import_agent_management.AgentFactory.installCustomAgent(id, tmpFile, {
|
|
517
|
+
name,
|
|
518
|
+
description,
|
|
519
|
+
author: author || "Custom",
|
|
520
|
+
tags: tags || []
|
|
521
|
+
});
|
|
532
522
|
await import_fs.promises.unlink(tmpFile).catch(() => {
|
|
533
523
|
});
|
|
534
524
|
return ctx.json({ created: true, id, name }, 201);
|
|
@@ -537,8 +527,8 @@ function createAgentsRouter(getAgent, context) {
|
|
|
537
527
|
});
|
|
538
528
|
throw installError;
|
|
539
529
|
}
|
|
540
|
-
}).openapi(getPathRoute, (ctx) => {
|
|
541
|
-
const agent = getAgent();
|
|
530
|
+
}).openapi(getPathRoute, async (ctx) => {
|
|
531
|
+
const agent = await getAgent(ctx);
|
|
542
532
|
const agentPath = agent.getAgentFilePath();
|
|
543
533
|
const relativePath = import_path.default.basename(agentPath);
|
|
544
534
|
const ext = import_path.default.extname(agentPath);
|
|
@@ -547,10 +537,10 @@ function createAgentsRouter(getAgent, context) {
|
|
|
547
537
|
path: agentPath,
|
|
548
538
|
relativePath,
|
|
549
539
|
name,
|
|
550
|
-
isDefault: name === "
|
|
540
|
+
isDefault: name === "coding-agent"
|
|
551
541
|
});
|
|
552
542
|
}).openapi(getConfigRoute, async (ctx) => {
|
|
553
|
-
const agent = getAgent();
|
|
543
|
+
const agent = await getAgent(ctx);
|
|
554
544
|
const agentPath = agent.getAgentFilePath();
|
|
555
545
|
const yamlContent = await import_fs.promises.readFile(agentPath, "utf-8");
|
|
556
546
|
const stats = await import_fs.promises.stat(agentPath);
|
|
@@ -626,7 +616,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
626
616
|
warnings
|
|
627
617
|
});
|
|
628
618
|
}).openapi(saveConfigRoute, async (ctx) => {
|
|
629
|
-
const agent = getAgent();
|
|
619
|
+
const agent = await getAgent(ctx);
|
|
630
620
|
const { yaml } = ctx.req.valid("json");
|
|
631
621
|
let parsed;
|
|
632
622
|
try {
|
|
@@ -698,7 +688,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
698
688
|
throw error;
|
|
699
689
|
}
|
|
700
690
|
}).openapi(exportConfigRoute, async (ctx) => {
|
|
701
|
-
const agent = getAgent();
|
|
691
|
+
const agent = await getAgent(ctx);
|
|
702
692
|
const { sessionId } = ctx.req.valid("query");
|
|
703
693
|
const config = agent.getEffectiveConfig(sessionId);
|
|
704
694
|
const maskedConfig = {
|