@dexto/server 1.6.19 → 1.6.21
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/hono/index.cjs +39 -8
- package/dist/hono/index.d.ts +43 -4503
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +42 -9
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +173 -34
- package/dist/hono/routes/a2a-tasks.d.ts +1 -498
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +177 -34
- 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 +16048 -73
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +103 -78
- package/dist/hono/routes/approvals.d.ts +2090 -112
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -78
- 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 +381 -348
- package/dist/hono/routes/llm.d.ts +12137 -87
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +385 -348
- package/dist/hono/routes/mcp.cjs +273 -212
- package/dist/hono/routes/mcp.d.ts +6605 -316
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +287 -213
- 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 +171 -164
- package/dist/hono/routes/messages.d.ts +3899 -10
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +181 -165
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2874 -1
- 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 +137 -104
- package/dist/hono/routes/prompts.d.ts +2820 -12
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +144 -105
- package/dist/hono/routes/queue.cjs +158 -132
- package/dist/hono/routes/queue.d.ts +5148 -13
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +168 -133
- 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 +4202 -26
- 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 +2837 -14
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +404 -392
- package/dist/hono/routes/sessions.d.ts +16585 -30
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +408 -393
- 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 +1756 -7
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +159 -132
- package/dist/hono/routes/webhooks.d.ts +2504 -14
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +163 -132
- 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 +492 -235
- package/dist/hono/schemas/responses.d.ts +1461 -146
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +247 -9
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- 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,15 +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");
|
|
90
|
+
const TaskErrorResponseSchema = z.object({
|
|
91
|
+
error: z.string().describe("Task error message")
|
|
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
|
+
}
|
|
68
175
|
const MessageSendRequestSchema = z.object({
|
|
69
176
|
message: MessageSchema.describe("Message to send to the agent"),
|
|
70
177
|
configuration: z.object({
|
|
@@ -76,7 +183,7 @@ const MessageSendRequestSchema = z.object({
|
|
|
76
183
|
}).optional().describe("Push notification configuration"),
|
|
77
184
|
blocking: z.boolean().optional().describe("Wait for task completion")
|
|
78
185
|
}).optional().describe("Optional configuration"),
|
|
79
|
-
metadata:
|
|
186
|
+
metadata: JsonObjectSchema.optional().describe("Optional metadata")
|
|
80
187
|
}).describe("Request body for message/send");
|
|
81
188
|
const TaskListQuerySchema = z.object({
|
|
82
189
|
contextId: z.string().optional().describe("Filter by context ID"),
|
|
@@ -137,7 +244,9 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
137
244
|
schema: TaskSchema
|
|
138
245
|
}
|
|
139
246
|
}
|
|
140
|
-
}
|
|
247
|
+
},
|
|
248
|
+
400: BadRequestErrorResponse,
|
|
249
|
+
500: InternalErrorResponse
|
|
141
250
|
}
|
|
142
251
|
});
|
|
143
252
|
const listTasksRoute = createRoute({
|
|
@@ -154,15 +263,12 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
154
263
|
description: "Task list",
|
|
155
264
|
content: {
|
|
156
265
|
"application/json": {
|
|
157
|
-
schema:
|
|
158
|
-
tasks: z.array(TaskSchema).describe("Array of tasks"),
|
|
159
|
-
totalSize: z.number().describe("Total number of tasks"),
|
|
160
|
-
pageSize: z.number().describe("Number of tasks in this page"),
|
|
161
|
-
nextPageToken: z.string().describe("Token for next page")
|
|
162
|
-
}).describe("Response body for tasks/list")
|
|
266
|
+
schema: TasksListResponseSchema
|
|
163
267
|
}
|
|
164
268
|
}
|
|
165
|
-
}
|
|
269
|
+
},
|
|
270
|
+
400: BadRequestErrorResponse,
|
|
271
|
+
500: InternalErrorResponse
|
|
166
272
|
}
|
|
167
273
|
});
|
|
168
274
|
const getTaskRoute = createRoute({
|
|
@@ -186,7 +292,12 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
186
292
|
}
|
|
187
293
|
},
|
|
188
294
|
404: {
|
|
189
|
-
description: "Task not found"
|
|
295
|
+
description: "Task not found",
|
|
296
|
+
content: {
|
|
297
|
+
"application/json": {
|
|
298
|
+
schema: TaskErrorResponseSchema
|
|
299
|
+
}
|
|
300
|
+
}
|
|
190
301
|
}
|
|
191
302
|
}
|
|
192
303
|
});
|
|
@@ -197,9 +308,22 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
197
308
|
description: "Cancel a running task (A2A tasks/cancel)",
|
|
198
309
|
tags: ["a2a"],
|
|
199
310
|
request: {
|
|
200
|
-
params: z.
|
|
201
|
-
|
|
202
|
-
|
|
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
|
+
)
|
|
203
327
|
},
|
|
204
328
|
responses: {
|
|
205
329
|
200: {
|
|
@@ -211,7 +335,12 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
211
335
|
}
|
|
212
336
|
},
|
|
213
337
|
404: {
|
|
214
|
-
description: "Task not found"
|
|
338
|
+
description: "Task not found",
|
|
339
|
+
content: {
|
|
340
|
+
"application/json": {
|
|
341
|
+
schema: TaskErrorResponseSchema
|
|
342
|
+
}
|
|
343
|
+
}
|
|
215
344
|
}
|
|
216
345
|
}
|
|
217
346
|
});
|
|
@@ -234,7 +363,7 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
234
363
|
const agent = await getAgent(ctx);
|
|
235
364
|
const session = await agent.createSession(taskId);
|
|
236
365
|
const stream = sseSubscriber.createStream(session.id);
|
|
237
|
-
const { text, image, file } = a2aToInternalMessage(validatedBody.message);
|
|
366
|
+
const { text, image, file } = a2aToInternalMessage(toA2AMessage(validatedBody.message));
|
|
238
367
|
agent.run(text, image, file, session.id).catch((error) => {
|
|
239
368
|
logger.error(`Error in streaming task ${session.id}: ${error}`);
|
|
240
369
|
});
|
|
@@ -252,39 +381,53 @@ function createA2ATasksRouter(getAgent, sseSubscriber) {
|
|
|
252
381
|
return ctx.json({ error: "Failed to initiate streaming" }, 500);
|
|
253
382
|
}
|
|
254
383
|
});
|
|
255
|
-
|
|
384
|
+
const messageSendRouter = new OpenAPIHono().openapi(messageSendRoute, async (ctx) => {
|
|
256
385
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
257
386
|
const body = ctx.req.valid("json");
|
|
258
387
|
logger.info("REST: message/send", { hasMessage: !!body.message });
|
|
259
|
-
const result = await handlers.messageSend(body);
|
|
260
|
-
|
|
261
|
-
|
|
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) => {
|
|
262
393
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
263
394
|
const query = ctx.req.valid("query");
|
|
264
|
-
const result = await handlers.tasksList(query);
|
|
265
|
-
|
|
266
|
-
|
|
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) => {
|
|
267
400
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
268
401
|
const { id } = ctx.req.valid("param");
|
|
269
402
|
try {
|
|
270
403
|
const task = await handlers.tasksGet({ id });
|
|
271
|
-
|
|
404
|
+
const response = task;
|
|
405
|
+
return ctx.json(response, 200);
|
|
272
406
|
} catch (error) {
|
|
273
407
|
logger.warn(`Task ${id} not found: ${error}`);
|
|
274
|
-
|
|
408
|
+
const response = { error: "Task not found" };
|
|
409
|
+
return ctx.json(response, 404);
|
|
275
410
|
}
|
|
276
|
-
})
|
|
411
|
+
});
|
|
412
|
+
const cancelTaskRouter = new OpenAPIHono().openapi(cancelTaskRoute, async (ctx) => {
|
|
277
413
|
const handlers = new A2AMethodHandlers(await getAgent(ctx));
|
|
278
414
|
const { id } = ctx.req.valid("param");
|
|
279
415
|
logger.info(`REST: tasks/cancel ${id}`);
|
|
280
416
|
try {
|
|
281
417
|
const task = await handlers.tasksCancel({ id });
|
|
282
|
-
|
|
418
|
+
const response = task;
|
|
419
|
+
return ctx.json(response, 200);
|
|
283
420
|
} catch (error) {
|
|
284
421
|
logger.error(`Failed to cancel task ${id}: ${error}`);
|
|
285
|
-
|
|
422
|
+
const response = { error: "Task not found" };
|
|
423
|
+
return ctx.json(response, 404);
|
|
286
424
|
}
|
|
287
425
|
});
|
|
426
|
+
mountA2ATasksSubrouter(app, messageSendRouter);
|
|
427
|
+
mountA2ATasksSubrouter(app, listTasksRouter);
|
|
428
|
+
mountA2ATasksSubrouter(app, getTaskRouter);
|
|
429
|
+
mountA2ATasksSubrouter(app, cancelTaskRouter);
|
|
430
|
+
return app;
|
|
288
431
|
}
|
|
289
432
|
export {
|
|
290
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"}
|