@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
|
@@ -2,11 +2,19 @@ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
|
2
2
|
import { A2AMethodHandlers } from "../../a2a/jsonrpc/methods.js";
|
|
3
3
|
import { logger } from "@dexto/core";
|
|
4
4
|
import { a2aToInternalMessage } from "../../a2a/adapters/message.js";
|
|
5
|
+
import {
|
|
6
|
+
BadRequestErrorResponse,
|
|
7
|
+
InternalErrorResponse,
|
|
8
|
+
JsonObjectSchema
|
|
9
|
+
} from "../schemas/responses.js";
|
|
10
|
+
function mountA2ATasksSubrouter(app, router) {
|
|
11
|
+
app.route("/", router);
|
|
12
|
+
}
|
|
5
13
|
const PartSchema = z.discriminatedUnion("kind", [
|
|
6
14
|
z.object({
|
|
7
15
|
kind: z.literal("text").describe("Part type discriminator"),
|
|
8
16
|
text: z.string().describe("Text content"),
|
|
9
|
-
metadata:
|
|
17
|
+
metadata: JsonObjectSchema.optional().describe("Extension metadata")
|
|
10
18
|
}),
|
|
11
19
|
z.object({
|
|
12
20
|
kind: z.literal("file").describe("Part type discriminator"),
|
|
@@ -22,12 +30,12 @@ const PartSchema = z.discriminatedUnion("kind", [
|
|
|
22
30
|
mimeType: z.string().optional().describe("MIME type")
|
|
23
31
|
})
|
|
24
32
|
]).describe("File data (bytes or URI)"),
|
|
25
|
-
metadata:
|
|
33
|
+
metadata: JsonObjectSchema.optional().describe("Extension metadata")
|
|
26
34
|
}),
|
|
27
35
|
z.object({
|
|
28
36
|
kind: z.literal("data").describe("Part type discriminator"),
|
|
29
|
-
data:
|
|
30
|
-
metadata:
|
|
37
|
+
data: JsonObjectSchema.describe("Structured JSON data"),
|
|
38
|
+
metadata: JsonObjectSchema.optional().describe("Extension metadata")
|
|
31
39
|
})
|
|
32
40
|
]).describe("Message part (text, file, or data)");
|
|
33
41
|
const MessageSchema = z.object({
|
|
@@ -36,7 +44,7 @@ const MessageSchema = z.object({
|
|
|
36
44
|
messageId: z.string().describe("Unique message identifier"),
|
|
37
45
|
taskId: z.string().optional().describe("Associated task ID"),
|
|
38
46
|
contextId: z.string().optional().describe("Context identifier"),
|
|
39
|
-
metadata:
|
|
47
|
+
metadata: JsonObjectSchema.optional().describe("Extension metadata"),
|
|
40
48
|
extensions: z.array(z.string()).optional().describe("Extension identifiers"),
|
|
41
49
|
referenceTaskIds: z.array(z.string()).optional().describe("Referenced task IDs"),
|
|
42
50
|
kind: z.literal("message").describe("Object type discriminator")
|
|
@@ -56,18 +64,114 @@ const TaskStatusSchema = z.object({
|
|
|
56
64
|
message: MessageSchema.optional().describe("Status message"),
|
|
57
65
|
timestamp: z.string().optional().describe("ISO 8601 timestamp")
|
|
58
66
|
}).describe("Task status");
|
|
67
|
+
const ArtifactSchema = z.object({
|
|
68
|
+
artifactId: z.string().describe("Unique artifact ID"),
|
|
69
|
+
name: z.string().optional().describe("Artifact name"),
|
|
70
|
+
description: z.string().optional().describe("Artifact description"),
|
|
71
|
+
parts: z.array(PartSchema).describe("Artifact content parts"),
|
|
72
|
+
metadata: JsonObjectSchema.optional().describe("Extension metadata"),
|
|
73
|
+
extensions: z.array(z.string()).optional().describe("Extension identifiers")
|
|
74
|
+
}).describe("A2A protocol artifact");
|
|
59
75
|
const TaskSchema = z.object({
|
|
60
76
|
id: z.string().describe("Unique task identifier"),
|
|
61
77
|
contextId: z.string().describe("Context identifier across related tasks"),
|
|
62
78
|
status: TaskStatusSchema.describe("Current task status"),
|
|
63
79
|
history: z.array(MessageSchema).optional().describe("Conversation history"),
|
|
64
|
-
artifacts: z.array(
|
|
65
|
-
metadata:
|
|
80
|
+
artifacts: z.array(ArtifactSchema).optional().describe("Task artifacts"),
|
|
81
|
+
metadata: JsonObjectSchema.optional().describe("Extension metadata"),
|
|
66
82
|
kind: z.literal("task").describe("Object type discriminator")
|
|
67
83
|
}).describe("A2A Protocol task");
|
|
84
|
+
const TasksListResponseSchema = z.object({
|
|
85
|
+
tasks: z.array(TaskSchema).describe("Array of tasks"),
|
|
86
|
+
totalSize: z.number().describe("Total number of tasks"),
|
|
87
|
+
pageSize: z.number().describe("Number of tasks in this page"),
|
|
88
|
+
nextPageToken: z.string().describe("Token for next page")
|
|
89
|
+
}).describe("Response body for tasks/list");
|
|
68
90
|
const TaskErrorResponseSchema = z.object({
|
|
69
91
|
error: z.string().describe("Task error message")
|
|
70
92
|
}).strict().describe("A2A task error response");
|
|
93
|
+
function toA2APart(part) {
|
|
94
|
+
switch (part.kind) {
|
|
95
|
+
case "text":
|
|
96
|
+
return {
|
|
97
|
+
kind: "text",
|
|
98
|
+
text: part.text,
|
|
99
|
+
...part.metadata !== void 0 ? { metadata: part.metadata } : {}
|
|
100
|
+
};
|
|
101
|
+
case "file": {
|
|
102
|
+
const file = "bytes" in part.file ? {
|
|
103
|
+
bytes: part.file.bytes,
|
|
104
|
+
...part.file.name !== void 0 ? { name: part.file.name } : {},
|
|
105
|
+
...part.file.mimeType !== void 0 ? { mimeType: part.file.mimeType } : {}
|
|
106
|
+
} : {
|
|
107
|
+
uri: part.file.uri,
|
|
108
|
+
...part.file.name !== void 0 ? { name: part.file.name } : {},
|
|
109
|
+
...part.file.mimeType !== void 0 ? { mimeType: part.file.mimeType } : {}
|
|
110
|
+
};
|
|
111
|
+
return {
|
|
112
|
+
kind: "file",
|
|
113
|
+
file,
|
|
114
|
+
...part.metadata !== void 0 ? { metadata: part.metadata } : {}
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
case "data":
|
|
118
|
+
return {
|
|
119
|
+
kind: "data",
|
|
120
|
+
data: part.data,
|
|
121
|
+
...part.metadata !== void 0 ? { metadata: part.metadata } : {}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function toA2AMessage(message) {
|
|
126
|
+
return {
|
|
127
|
+
role: message.role,
|
|
128
|
+
parts: message.parts.map(toA2APart),
|
|
129
|
+
messageId: message.messageId,
|
|
130
|
+
kind: "message",
|
|
131
|
+
...message.taskId !== void 0 ? { taskId: message.taskId } : {},
|
|
132
|
+
...message.contextId !== void 0 ? { contextId: message.contextId } : {},
|
|
133
|
+
...message.metadata !== void 0 ? { metadata: message.metadata } : {},
|
|
134
|
+
...message.extensions !== void 0 ? { extensions: message.extensions } : {},
|
|
135
|
+
...message.referenceTaskIds !== void 0 ? { referenceTaskIds: message.referenceTaskIds } : {}
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
function toMessageSendParams(body) {
|
|
139
|
+
const pushNotificationConfig = body.configuration?.pushNotificationConfig ? {
|
|
140
|
+
url: body.configuration.pushNotificationConfig.url,
|
|
141
|
+
...body.configuration.pushNotificationConfig.headers !== void 0 ? { headers: body.configuration.pushNotificationConfig.headers } : {}
|
|
142
|
+
} : void 0;
|
|
143
|
+
const configuration = body.configuration ? {
|
|
144
|
+
...body.configuration.acceptedOutputModes !== void 0 ? { acceptedOutputModes: body.configuration.acceptedOutputModes } : {},
|
|
145
|
+
...body.configuration.historyLength !== void 0 ? { historyLength: body.configuration.historyLength } : {},
|
|
146
|
+
...pushNotificationConfig !== void 0 ? { pushNotificationConfig } : {},
|
|
147
|
+
...body.configuration.blocking !== void 0 ? { blocking: body.configuration.blocking } : {}
|
|
148
|
+
} : void 0;
|
|
149
|
+
return {
|
|
150
|
+
message: toA2AMessage(body.message),
|
|
151
|
+
...configuration !== void 0 ? { configuration } : {},
|
|
152
|
+
...body.metadata !== void 0 ? { metadata: body.metadata } : {}
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
function toListTasksParams(query) {
|
|
156
|
+
return {
|
|
157
|
+
...query.contextId !== void 0 ? { contextId: query.contextId } : {},
|
|
158
|
+
...query.status !== void 0 ? { status: query.status } : {},
|
|
159
|
+
...query.pageSize !== void 0 ? { pageSize: query.pageSize } : {},
|
|
160
|
+
...query.pageToken !== void 0 ? { pageToken: query.pageToken } : {},
|
|
161
|
+
...query.historyLength !== void 0 ? { historyLength: query.historyLength } : {},
|
|
162
|
+
...query.lastUpdatedAfter !== void 0 ? { lastUpdatedAfter: query.lastUpdatedAfter } : {},
|
|
163
|
+
...query.includeArtifacts !== void 0 ? { includeArtifacts: query.includeArtifacts } : {}
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
function readCancelTaskParam(value) {
|
|
167
|
+
if (Object.prototype.hasOwnProperty.call(value, "id")) {
|
|
168
|
+
return void 0;
|
|
169
|
+
}
|
|
170
|
+
const raw = Object.entries(value).find(
|
|
171
|
+
([key, candidate]) => key === "id:cancel" && typeof candidate === "string"
|
|
172
|
+
)?.[1];
|
|
173
|
+
return typeof raw === "string" ? raw : void 0;
|
|
174
|
+
}
|
|
71
175
|
const MessageSendRequestSchema = z.object({
|
|
72
176
|
message: MessageSchema.describe("Message to send to the agent"),
|
|
73
177
|
configuration: z.object({
|
|
@@ -79,7 +183,7 @@ const MessageSendRequestSchema = z.object({
|
|
|
79
183
|
}).optional().describe("Push notification configuration"),
|
|
80
184
|
blocking: z.boolean().optional().describe("Wait for task completion")
|
|
81
185
|
}).optional().describe("Optional configuration"),
|
|
82
|
-
metadata:
|
|
186
|
+
metadata: JsonObjectSchema.optional().describe("Optional metadata")
|
|
83
187
|
}).describe("Request body for message/send");
|
|
84
188
|
const TaskListQuerySchema = z.object({
|
|
85
189
|
contextId: z.string().optional().describe("Filter by context ID"),
|
|
@@ -140,7 +244,9 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
140
244
|
schema: TaskSchema
|
|
141
245
|
}
|
|
142
246
|
}
|
|
143
|
-
}
|
|
247
|
+
},
|
|
248
|
+
400: BadRequestErrorResponse,
|
|
249
|
+
500: InternalErrorResponse
|
|
144
250
|
}
|
|
145
251
|
});
|
|
146
252
|
const listTasksRoute = createRoute({
|
|
@@ -157,15 +263,12 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
157
263
|
description: "Task list",
|
|
158
264
|
content: {
|
|
159
265
|
"application/json": {
|
|
160
|
-
schema:
|
|
161
|
-
tasks: z.array(TaskSchema).describe("Array of tasks"),
|
|
162
|
-
totalSize: z.number().describe("Total number of tasks"),
|
|
163
|
-
pageSize: z.number().describe("Number of tasks in this page"),
|
|
164
|
-
nextPageToken: z.string().describe("Token for next page")
|
|
165
|
-
}).describe("Response body for tasks/list")
|
|
266
|
+
schema: TasksListResponseSchema
|
|
166
267
|
}
|
|
167
268
|
}
|
|
168
|
-
}
|
|
269
|
+
},
|
|
270
|
+
400: BadRequestErrorResponse,
|
|
271
|
+
500: InternalErrorResponse
|
|
169
272
|
}
|
|
170
273
|
});
|
|
171
274
|
const getTaskRoute = createRoute({
|
|
@@ -205,9 +308,22 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
205
308
|
description: "Cancel a running task (A2A tasks/cancel)",
|
|
206
309
|
tags: ["a2a"],
|
|
207
310
|
request: {
|
|
208
|
-
params: z.
|
|
209
|
-
|
|
210
|
-
|
|
311
|
+
params: z.preprocess(
|
|
312
|
+
(value) => {
|
|
313
|
+
if (value && typeof value === "object" && !Array.isArray(value)) {
|
|
314
|
+
const raw = readCancelTaskParam(value);
|
|
315
|
+
if (raw !== void 0) {
|
|
316
|
+
return {
|
|
317
|
+
id: raw.endsWith(":cancel") ? raw.slice(0, -":cancel".length) : raw
|
|
318
|
+
};
|
|
319
|
+
}
|
|
320
|
+
}
|
|
321
|
+
return value;
|
|
322
|
+
},
|
|
323
|
+
z.object({
|
|
324
|
+
id: z.string().describe("Task ID")
|
|
325
|
+
})
|
|
326
|
+
)
|
|
211
327
|
},
|
|
212
328
|
responses: {
|
|
213
329
|
200: {
|
|
@@ -247,7 +363,7 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
247
363
|
const agent = await getAgent(ctx);
|
|
248
364
|
const session = await agent.createSession(taskId);
|
|
249
365
|
const stream = sseSubscriber.createStream(session.id);
|
|
250
|
-
const { text, image, file } = a2aToInternalMessage(validatedBody.message);
|
|
366
|
+
const { text, image, file } = a2aToInternalMessage(toA2AMessage(validatedBody.message));
|
|
251
367
|
agent.run(text, image, file, session.id).catch((error) => {
|
|
252
368
|
logger.error(`Error in streaming task ${session.id}: ${error}`);
|
|
253
369
|
});
|
|
@@ -265,39 +381,53 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
265
381
|
return ctx.json({ error: "Failed to initiate streaming" }, 500);
|
|
266
382
|
}
|
|
267
383
|
});
|
|
268
|
-
|
|
384
|
+
const messageSendRouter = new OpenAPIHono().openapi(messageSendRoute, async (ctx) => {
|
|
269
385
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
270
386
|
const body = ctx.req.valid("json");
|
|
271
387
|
logger.info("REST: message/send", { hasMessage: !!body.message });
|
|
272
|
-
const result = await handlers.messageSend(body);
|
|
273
|
-
|
|
274
|
-
|
|
388
|
+
const result = await handlers.messageSend(toMessageSendParams(body));
|
|
389
|
+
const response = result;
|
|
390
|
+
return ctx.json(response, 200);
|
|
391
|
+
});
|
|
392
|
+
const listTasksRouter = new OpenAPIHono().openapi(listTasksRoute, async (ctx) => {
|
|
275
393
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
276
394
|
const query = ctx.req.valid("query");
|
|
277
|
-
const result = await handlers.tasksList(query);
|
|
278
|
-
|
|
279
|
-
|
|
395
|
+
const result = await handlers.tasksList(toListTasksParams(query));
|
|
396
|
+
const response = result;
|
|
397
|
+
return ctx.json(response, 200);
|
|
398
|
+
});
|
|
399
|
+
const getTaskRouter = new OpenAPIHono().openapi(getTaskRoute, async (ctx) => {
|
|
280
400
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
281
401
|
const { id } = ctx.req.valid("param");
|
|
282
402
|
try {
|
|
283
403
|
const task = await handlers.tasksGet({ id });
|
|
284
|
-
|
|
404
|
+
const response = task;
|
|
405
|
+
return ctx.json(response, 200);
|
|
285
406
|
} catch (error) {
|
|
286
407
|
logger.warn(`Task ${id} not found: ${error}`);
|
|
287
|
-
|
|
408
|
+
const response = { error: "Task not found" };
|
|
409
|
+
return ctx.json(response, 404);
|
|
288
410
|
}
|
|
289
|
-
})
|
|
411
|
+
});
|
|
412
|
+
const cancelTaskRouter = new OpenAPIHono().openapi(cancelTaskRoute, async (ctx) => {
|
|
290
413
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
291
414
|
const { id } = ctx.req.valid("param");
|
|
292
415
|
logger.info(`REST: tasks/cancel ${id}`);
|
|
293
416
|
try {
|
|
294
417
|
const task = await handlers.tasksCancel({ id });
|
|
295
|
-
|
|
418
|
+
const response = task;
|
|
419
|
+
return ctx.json(response, 200);
|
|
296
420
|
} catch (error) {
|
|
297
421
|
logger.error(`Failed to cancel task ${id}: ${error}`);
|
|
298
|
-
|
|
422
|
+
const response = { error: "Task not found" };
|
|
423
|
+
return ctx.json(response, 404);
|
|
299
424
|
}
|
|
300
425
|
});
|
|
426
|
+
mountA2ATasksSubrouter(app, messageSendRouter);
|
|
427
|
+
mountA2ATasksSubrouter(app, listTasksRouter);
|
|
428
|
+
mountA2ATasksSubrouter(app, getTaskRouter);
|
|
429
|
+
mountA2ATasksSubrouter(app, cancelTaskRouter);
|
|
430
|
+
return app;
|
|
301
431
|
}
|
|
302
432
|
export {
|
|
303
433
|
createA2ATasksRouter
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"a2a.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/a2a.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,SAAS,
|
|
1
|
+
{"version":3,"file":"a2a.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/a2a.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C,wBAAgB,eAAe,CAAC,YAAY,EAAE,MAAM,SAAS,8EAQ5D"}
|