@dexto/server 1.3.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/approval/manual-approval-handler.cjs +23 -15
- package/dist/approval/manual-approval-handler.d.ts.map +1 -1
- package/dist/approval/manual-approval-handler.js +23 -15
- package/dist/events/webhook-subscriber.cjs +1 -1
- package/dist/events/webhook-subscriber.d.ts.map +1 -1
- package/dist/events/webhook-subscriber.js +1 -1
- package/dist/hono/__tests__/test-fixtures.cjs +3 -3
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +3 -3
- package/dist/hono/index.cjs +46 -5
- package/dist/hono/index.d.ts +928 -584
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +46 -5
- package/dist/hono/middleware/error.d.ts.map +1 -1
- 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 +30 -42
- package/dist/hono/routes/agents.d.ts +7 -401
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +32 -42
- package/dist/hono/routes/approvals.cjs +53 -2
- package/dist/hono/routes/approvals.d.ts +29 -1
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +53 -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 +119 -62
- package/dist/hono/routes/llm.d.ts +242 -42
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +118 -58
- package/dist/hono/routes/mcp.cjs +16 -12
- package/dist/hono/routes/mcp.d.ts +6 -3
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +17 -13
- package/dist/hono/routes/memory.cjs +5 -5
- package/dist/hono/routes/memory.d.ts +5 -2
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +5 -5
- package/dist/hono/routes/messages.cjs +58 -66
- package/dist/hono/routes/messages.d.ts +99 -55
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +59 -67
- 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 +10 -7
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +5 -5
- package/dist/hono/routes/queue.cjs +202 -0
- package/dist/hono/routes/queue.d.ts +174 -0
- package/dist/hono/routes/queue.d.ts.map +1 -0
- package/dist/hono/routes/queue.js +178 -0
- package/dist/hono/routes/resources.cjs +3 -3
- package/dist/hono/routes/resources.d.ts +3 -3
- 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 +39 -10
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +2 -2
- package/dist/hono/routes/sessions.cjs +74 -20
- package/dist/hono/routes/sessions.d.ts +25 -4
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +74 -20
- 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.cjs +24 -5
- package/dist/hono/schemas/responses.d.ts +838 -120
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +24 -10
- 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":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,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";
|
|
@@ -15,6 +16,12 @@ import { createResourcesRouter } from "./routes/resources.js";
|
|
|
15
16
|
import { createMemoryRouter } from "./routes/memory.js";
|
|
16
17
|
import { createAgentsRouter } from "./routes/agents.js";
|
|
17
18
|
import { createApprovalsRouter } from "./routes/approvals.js";
|
|
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";
|
|
18
25
|
import {
|
|
19
26
|
createStaticRouter,
|
|
20
27
|
createSpaFallbackHandler
|
|
@@ -43,8 +50,10 @@ const dummyAgentsContext = {
|
|
|
43
50
|
},
|
|
44
51
|
getActiveAgentId: () => void 0
|
|
45
52
|
};
|
|
53
|
+
const DEFAULT_API_PREFIX = "/api";
|
|
46
54
|
function createDextoApp(options) {
|
|
47
55
|
const {
|
|
56
|
+
apiPrefix,
|
|
48
57
|
getAgent,
|
|
49
58
|
getAgentCard,
|
|
50
59
|
approvalCoordinator,
|
|
@@ -52,15 +61,27 @@ function createDextoApp(options) {
|
|
|
52
61
|
sseSubscriber,
|
|
53
62
|
agentsContext,
|
|
54
63
|
webRoot,
|
|
55
|
-
webUIConfig
|
|
64
|
+
webUIConfig,
|
|
65
|
+
disableAuth = false
|
|
56
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
|
+
}
|
|
57
72
|
const app = new OpenAPIHono({ strict: false });
|
|
58
73
|
app.use("*", createCorsMiddleware());
|
|
59
|
-
|
|
74
|
+
if (!disableAuth) {
|
|
75
|
+
app.use("*", createAuthMiddleware());
|
|
76
|
+
}
|
|
60
77
|
app.onError((err, ctx) => handleHonoError(ctx, err));
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
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());
|
|
64
85
|
fullApp.doc("/openapi.json", {
|
|
65
86
|
openapi: "3.0.0",
|
|
66
87
|
info: {
|
|
@@ -136,6 +157,26 @@ function createDextoApp(options) {
|
|
|
136
157
|
{
|
|
137
158
|
name: "agents",
|
|
138
159
|
description: "Install, switch, and manage agent configurations"
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
name: "queue",
|
|
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"
|
|
139
180
|
}
|
|
140
181
|
]
|
|
141
182
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/hono/middleware/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/hono/middleware/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc9F,eAAO,MAAM,oBAAoB,GAAI,MAAM,SAAS,KAAG,MAoBtD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,QAAQ,UAAU,CAAC,OAAO,WAAW,CAAC,KAAG,MAI5E,CAAC;AAEF,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,OAkFrD"}
|
|
@@ -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 {
|
|
@@ -34,13 +34,15 @@ module.exports = __toCommonJS(agents_exports);
|
|
|
34
34
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
35
35
|
var import_core = require("@dexto/core");
|
|
36
36
|
var import_agent_management = require("@dexto/agent-management");
|
|
37
|
-
var import_agent_management2 = require("@dexto/agent-management");
|
|
38
37
|
var import_yaml = require("yaml");
|
|
39
38
|
var import_os = __toESM(require("os"), 1);
|
|
40
39
|
var import_path = __toESM(require("path"), 1);
|
|
41
40
|
var import_fs = require("fs");
|
|
42
41
|
var import_core2 = require("@dexto/core");
|
|
43
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
|
+
);
|
|
44
46
|
const AgentIdentifierSchema = import_zod_openapi.z.object({
|
|
45
47
|
id: import_zod_openapi.z.string().min(1, "Agent id is required").describe('Unique agent identifier (e.g., "database-agent")'),
|
|
46
48
|
path: import_zod_openapi.z.string().optional().describe(
|
|
@@ -60,16 +62,14 @@ const CustomAgentInstallSchema = import_zod_openapi.z.object({
|
|
|
60
62
|
author: import_zod_openapi.z.string().min(1).describe("Agent author or organization name"),
|
|
61
63
|
tags: import_zod_openapi.z.array(import_zod_openapi.z.string()).describe("Tags for categorizing the agent"),
|
|
62
64
|
main: import_zod_openapi.z.string().optional().describe("Main configuration file name within source directory")
|
|
63
|
-
}).strict().describe("Agent metadata including description, author, and tags")
|
|
64
|
-
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")
|
|
65
66
|
}).strict().describe("Request body for installing a custom agent from file system").transform((value) => {
|
|
66
|
-
const displayName = value.name?.trim() || (0,
|
|
67
|
+
const displayName = value.name?.trim() || (0, import_agent_management.deriveDisplayName)(value.id);
|
|
67
68
|
return {
|
|
68
69
|
id: value.id,
|
|
69
70
|
displayName,
|
|
70
71
|
sourcePath: value.sourcePath,
|
|
71
|
-
metadata: value.metadata
|
|
72
|
-
injectPreferences: value.injectPreferences
|
|
72
|
+
metadata: value.metadata
|
|
73
73
|
};
|
|
74
74
|
});
|
|
75
75
|
const CustomAgentCreateSchema = import_zod_openapi.z.object({
|
|
@@ -83,7 +83,7 @@ const CustomAgentCreateSchema = import_zod_openapi.z.object({
|
|
|
83
83
|
author: import_zod_openapi.z.string().optional().describe("Author or organization"),
|
|
84
84
|
tags: import_zod_openapi.z.array(import_zod_openapi.z.string()).default([]).describe("Tags for discovery"),
|
|
85
85
|
// Full agent configuration
|
|
86
|
-
config:
|
|
86
|
+
config: AgentConfigSchemaForOpenAPI.describe("Complete agent configuration")
|
|
87
87
|
}).strict().describe("Request body for creating a new custom agent with full configuration");
|
|
88
88
|
const AgentConfigValidateSchema = import_zod_openapi.z.object({
|
|
89
89
|
yaml: import_zod_openapi.z.string().describe("YAML agent configuration content to validate")
|
|
@@ -411,7 +411,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
411
411
|
}
|
|
412
412
|
});
|
|
413
413
|
return app.openapi(listRoute, async (ctx) => {
|
|
414
|
-
const agents = await
|
|
414
|
+
const agents = await import_agent_management.AgentFactory.listAgents();
|
|
415
415
|
const currentId = getActiveAgentId() ?? null;
|
|
416
416
|
return ctx.json({
|
|
417
417
|
installed: agents.installed,
|
|
@@ -427,26 +427,20 @@ function createAgentsRouter(getAgent, context) {
|
|
|
427
427
|
}).openapi(installRoute, async (ctx) => {
|
|
428
428
|
const body = ctx.req.valid("json");
|
|
429
429
|
if ("sourcePath" in body && "metadata" in body) {
|
|
430
|
-
const { id, displayName, sourcePath, metadata
|
|
431
|
-
await
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
author: metadata.author,
|
|
438
|
-
tags: metadata.tags,
|
|
439
|
-
...metadata.main ? { main: metadata.main } : {}
|
|
440
|
-
},
|
|
441
|
-
injectPreferences
|
|
442
|
-
);
|
|
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
|
+
});
|
|
443
437
|
return ctx.json(
|
|
444
438
|
{ installed: true, id, name: displayName, type: "custom" },
|
|
445
439
|
201
|
|
446
440
|
);
|
|
447
441
|
} else {
|
|
448
442
|
const { id } = body;
|
|
449
|
-
await
|
|
443
|
+
await import_agent_management.AgentFactory.installAgent(id);
|
|
450
444
|
const agentInfo = await resolveAgentInfo(id);
|
|
451
445
|
return ctx.json(
|
|
452
446
|
{
|
|
@@ -463,7 +457,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
463
457
|
return ctx.json({ switched: true, ...result });
|
|
464
458
|
}).openapi(validateNameRoute, async (ctx) => {
|
|
465
459
|
const { id } = ctx.req.valid("json");
|
|
466
|
-
const agents = await
|
|
460
|
+
const agents = await import_agent_management.AgentFactory.listAgents();
|
|
467
461
|
const installedAgent = agents.installed.find((a) => a.id === id);
|
|
468
462
|
if (installedAgent) {
|
|
469
463
|
return ctx.json({
|
|
@@ -483,7 +477,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
483
477
|
return ctx.json({ valid: true });
|
|
484
478
|
}).openapi(uninstallRoute, async (ctx) => {
|
|
485
479
|
const { id, force } = ctx.req.valid("json");
|
|
486
|
-
await
|
|
480
|
+
await import_agent_management.AgentFactory.uninstallAgent(id, force);
|
|
487
481
|
return ctx.json({ uninstalled: true, id });
|
|
488
482
|
}).openapi(customCreateRoute, async (ctx) => {
|
|
489
483
|
const { id, name, description, author, tags, config } = ctx.req.valid("json");
|
|
@@ -519,18 +513,12 @@ function createAgentsRouter(getAgent, context) {
|
|
|
519
513
|
const tmpFile = import_path.default.join(tmpDir, `${id}-${Date.now()}.yml`);
|
|
520
514
|
await import_fs.promises.writeFile(tmpFile, yamlContent, "utf-8");
|
|
521
515
|
try {
|
|
522
|
-
await
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
author: author || "Custom",
|
|
529
|
-
tags: tags || []
|
|
530
|
-
},
|
|
531
|
-
false
|
|
532
|
-
// Don't inject preferences
|
|
533
|
-
);
|
|
516
|
+
await import_agent_management.AgentFactory.installCustomAgent(id, tmpFile, {
|
|
517
|
+
name,
|
|
518
|
+
description,
|
|
519
|
+
author: author || "Custom",
|
|
520
|
+
tags: tags || []
|
|
521
|
+
});
|
|
534
522
|
await import_fs.promises.unlink(tmpFile).catch(() => {
|
|
535
523
|
});
|
|
536
524
|
return ctx.json({ created: true, id, name }, 201);
|
|
@@ -539,8 +527,8 @@ function createAgentsRouter(getAgent, context) {
|
|
|
539
527
|
});
|
|
540
528
|
throw installError;
|
|
541
529
|
}
|
|
542
|
-
}).openapi(getPathRoute, (ctx) => {
|
|
543
|
-
const agent = getAgent();
|
|
530
|
+
}).openapi(getPathRoute, async (ctx) => {
|
|
531
|
+
const agent = await getAgent(ctx);
|
|
544
532
|
const agentPath = agent.getAgentFilePath();
|
|
545
533
|
const relativePath = import_path.default.basename(agentPath);
|
|
546
534
|
const ext = import_path.default.extname(agentPath);
|
|
@@ -549,10 +537,10 @@ function createAgentsRouter(getAgent, context) {
|
|
|
549
537
|
path: agentPath,
|
|
550
538
|
relativePath,
|
|
551
539
|
name,
|
|
552
|
-
isDefault: name === "
|
|
540
|
+
isDefault: name === "coding-agent"
|
|
553
541
|
});
|
|
554
542
|
}).openapi(getConfigRoute, async (ctx) => {
|
|
555
|
-
const agent = getAgent();
|
|
543
|
+
const agent = await getAgent(ctx);
|
|
556
544
|
const agentPath = agent.getAgentFilePath();
|
|
557
545
|
const yamlContent = await import_fs.promises.readFile(agentPath, "utf-8");
|
|
558
546
|
const stats = await import_fs.promises.stat(agentPath);
|
|
@@ -628,7 +616,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
628
616
|
warnings
|
|
629
617
|
});
|
|
630
618
|
}).openapi(saveConfigRoute, async (ctx) => {
|
|
631
|
-
const agent = getAgent();
|
|
619
|
+
const agent = await getAgent(ctx);
|
|
632
620
|
const { yaml } = ctx.req.valid("json");
|
|
633
621
|
let parsed;
|
|
634
622
|
try {
|
|
@@ -700,7 +688,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
700
688
|
throw error;
|
|
701
689
|
}
|
|
702
690
|
}).openapi(exportConfigRoute, async (ctx) => {
|
|
703
|
-
const agent = getAgent();
|
|
691
|
+
const agent = await getAgent(ctx);
|
|
704
692
|
const { sessionId } = ctx.req.valid("query");
|
|
705
693
|
const config = agent.getEffectiveConfig(sessionId);
|
|
706
694
|
const maskedConfig = {
|