@dexto/server 1.6.19 → 1.6.20

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.
Files changed (45) hide show
  1. package/dist/hono/index.d.ts +161 -133
  2. package/dist/hono/index.d.ts.map +1 -1
  3. package/dist/hono/routes/a2a-tasks.cjs +17 -4
  4. package/dist/hono/routes/a2a-tasks.d.ts +39 -35
  5. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
  6. package/dist/hono/routes/a2a-tasks.js +17 -4
  7. package/dist/hono/routes/agents.d.ts +8 -8
  8. package/dist/hono/routes/approvals.cjs +19 -8
  9. package/dist/hono/routes/approvals.d.ts +39 -8
  10. package/dist/hono/routes/approvals.d.ts.map +1 -1
  11. package/dist/hono/routes/approvals.js +19 -8
  12. package/dist/hono/routes/llm.d.ts +1 -1
  13. package/dist/hono/routes/mcp.cjs +56 -26
  14. package/dist/hono/routes/mcp.d.ts +22 -29
  15. package/dist/hono/routes/mcp.d.ts.map +1 -1
  16. package/dist/hono/routes/mcp.js +64 -28
  17. package/dist/hono/routes/messages.cjs +34 -35
  18. package/dist/hono/routes/messages.d.ts +12 -12
  19. package/dist/hono/routes/messages.d.ts.map +1 -1
  20. package/dist/hono/routes/messages.js +41 -36
  21. package/dist/hono/routes/prompts.cjs +10 -4
  22. package/dist/hono/routes/prompts.d.ts +4 -4
  23. package/dist/hono/routes/prompts.d.ts.map +1 -1
  24. package/dist/hono/routes/prompts.js +15 -5
  25. package/dist/hono/routes/queue.cjs +42 -29
  26. package/dist/hono/routes/queue.d.ts +9 -9
  27. package/dist/hono/routes/queue.d.ts.map +1 -1
  28. package/dist/hono/routes/queue.js +49 -30
  29. package/dist/hono/routes/resources.d.ts +1 -1
  30. package/dist/hono/routes/schedules.d.ts +4 -4
  31. package/dist/hono/routes/search.d.ts +4 -4
  32. package/dist/hono/routes/sessions.cjs +7 -2
  33. package/dist/hono/routes/sessions.d.ts +12 -12
  34. package/dist/hono/routes/sessions.d.ts.map +1 -1
  35. package/dist/hono/routes/sessions.js +7 -2
  36. package/dist/hono/routes/tools.d.ts +1 -1
  37. package/dist/hono/routes/webhooks.cjs +59 -24
  38. package/dist/hono/routes/webhooks.d.ts +7 -7
  39. package/dist/hono/routes/webhooks.d.ts.map +1 -1
  40. package/dist/hono/routes/webhooks.js +59 -24
  41. package/dist/hono/schemas/responses.cjs +112 -2
  42. package/dist/hono/schemas/responses.d.ts +246 -54
  43. package/dist/hono/schemas/responses.d.ts.map +1 -1
  44. package/dist/hono/schemas/responses.js +105 -1
  45. package/package.json +7 -7
@@ -25,24 +25,8 @@ var import_zod_openapi = require("@hono/zod-openapi");
25
25
  var import_streaming = require("hono/streaming");
26
26
  var import_core = require("@dexto/core");
27
27
  var import_responses = require("../schemas/responses.js");
28
- const TextPartSchema = import_zod_openapi.z.object({
29
- type: import_zod_openapi.z.literal("text").describe("Content type identifier"),
30
- text: import_zod_openapi.z.string().describe("Text content")
31
- }).describe("Text content part");
32
- const ImagePartSchema = import_zod_openapi.z.object({
33
- type: import_zod_openapi.z.literal("image").describe("Content type identifier"),
34
- image: import_zod_openapi.z.string().describe("Base64-encoded image data or URL"),
35
- mimeType: import_zod_openapi.z.string().optional().describe("MIME type (e.g., image/png)")
36
- }).describe("Image content part");
37
- const FilePartSchema = import_zod_openapi.z.object({
38
- type: import_zod_openapi.z.literal("file").describe("Content type identifier"),
39
- data: import_zod_openapi.z.string().describe("Base64-encoded file data or URL"),
40
- mimeType: import_zod_openapi.z.string().describe("MIME type (e.g., application/pdf)"),
41
- filename: import_zod_openapi.z.string().optional().describe("Optional filename")
42
- }).describe("File content part");
43
- const ContentPartSchema = import_zod_openapi.z.discriminatedUnion("type", [TextPartSchema, ImagePartSchema, FilePartSchema]).describe("Content part - text, image, or file");
44
28
  const MessageBodySchema = import_zod_openapi.z.object({
45
- content: import_zod_openapi.z.union([import_zod_openapi.z.string(), import_zod_openapi.z.array(ContentPartSchema)]).describe("Message content - string for text, or ContentPart[] for multimodal"),
29
+ content: import_responses.RequestContentSchema,
46
30
  sessionId: import_zod_openapi.z.string().min(1, "Session ID is required").describe("The session to use for this message")
47
31
  }).describe("Request body for sending a message to the agent");
48
32
  const ResetBodySchema = import_zod_openapi.z.object({
@@ -73,7 +57,10 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
73
57
  }
74
58
  }
75
59
  },
76
- 400: { description: "Validation error" }
60
+ 400: {
61
+ description: "Validation error",
62
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
63
+ }
77
64
  }
78
65
  });
79
66
  const messageSyncRoute = (0, import_zod_openapi.createRoute)({
@@ -109,7 +96,10 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
109
96
  }
110
97
  }
111
98
  },
112
- 400: { description: "Validation error" }
99
+ 400: {
100
+ description: "Validation error",
101
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
102
+ }
113
103
  }
114
104
  });
115
105
  const resetRoute = (0, import_zod_openapi.createRoute)({
@@ -188,13 +178,17 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
188
178
  }
189
179
  }
190
180
  },
191
- 400: { description: "Validation error" }
181
+ 400: {
182
+ description: "Validation error",
183
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
184
+ }
192
185
  }
193
186
  });
194
187
  return app.openapi(messageRoute, async (ctx) => {
195
188
  const agent = await getAgent(ctx);
196
189
  agent.logger.info("Received message via POST /api/message");
197
- const { content, sessionId } = ctx.req.valid("json");
190
+ const { content: rawContent, sessionId } = ctx.req.valid("json");
191
+ const content = (0, import_responses.toContentInput)(rawContent);
198
192
  agent.logger.info(`Message for session: ${sessionId}`);
199
193
  agent.generate(content, sessionId).catch((error) => {
200
194
  agent.logger.error(
@@ -205,21 +199,25 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
205
199
  }).openapi(messageSyncRoute, async (ctx) => {
206
200
  const agent = await getAgent(ctx);
207
201
  agent.logger.info("Received message via POST /api/message-sync");
208
- const { content, sessionId } = ctx.req.valid("json");
202
+ const { content: rawContent, sessionId } = ctx.req.valid("json");
203
+ const content = (0, import_responses.toContentInput)(rawContent);
209
204
  agent.logger.info(`Message for session: ${sessionId}`);
210
205
  const result = await agent.generate(content, sessionId);
211
- return ctx.json({
212
- response: result.content,
213
- sessionId: result.sessionId,
214
- tokenUsage: result.usage,
215
- messageId: result.messageId,
216
- usageScopeId: result.usageScopeId,
217
- estimatedCost: result.estimatedCost,
218
- pricingStatus: result.pricingStatus,
219
- reasoning: result.reasoning,
220
- model: result.model,
221
- provider: result.provider
222
- });
206
+ return ctx.json(
207
+ {
208
+ response: result.content,
209
+ sessionId: result.sessionId,
210
+ tokenUsage: result.usage,
211
+ messageId: result.messageId,
212
+ usageScopeId: result.usageScopeId,
213
+ estimatedCost: result.estimatedCost,
214
+ pricingStatus: result.pricingStatus,
215
+ reasoning: result.reasoning,
216
+ model: result.model,
217
+ provider: result.provider
218
+ },
219
+ 200
220
+ );
223
221
  }).openapi(resetRoute, async (ctx) => {
224
222
  const agent = await getAgent(ctx);
225
223
  agent.logger.info("Received request via POST /api/reset");
@@ -228,7 +226,8 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
228
226
  return ctx.json({ status: "reset initiated", sessionId });
229
227
  }).openapi(messageStreamRoute, async (ctx) => {
230
228
  const agent = await getAgent(ctx);
231
- const { content, sessionId } = ctx.req.valid("json");
229
+ const { content: rawContent, sessionId } = ctx.req.valid("json");
230
+ const content = (0, import_responses.toContentInput)(rawContent);
232
231
  const isBusy = await agent.isSessionBusy(sessionId);
233
232
  if (isBusy) {
234
233
  const queuedMessages = await agent.getQueuedMessages(sessionId);
@@ -22,9 +22,12 @@ export declare function createMessagesRouter(getAgent: GetAgentFn, approvalCoord
22
22
  sessionId: string;
23
23
  };
24
24
  };
25
- output: {};
26
- outputFormat: string;
27
- status: 400;
25
+ output: {
26
+ sessionId: string;
27
+ accepted: true;
28
+ };
29
+ outputFormat: "json";
30
+ status: 202;
28
31
  } | {
29
32
  input: {
30
33
  json: {
@@ -44,12 +47,9 @@ export declare function createMessagesRouter(getAgent: GetAgentFn, approvalCoord
44
47
  sessionId: string;
45
48
  };
46
49
  };
47
- output: {
48
- sessionId: string;
49
- accepted: true;
50
- };
50
+ output: never;
51
51
  outputFormat: "json";
52
- status: 202;
52
+ status: 400;
53
53
  };
54
54
  };
55
55
  } & {
@@ -73,8 +73,8 @@ export declare function createMessagesRouter(getAgent: GetAgentFn, approvalCoord
73
73
  sessionId: string;
74
74
  };
75
75
  };
76
- output: {};
77
- outputFormat: string;
76
+ output: never;
77
+ outputFormat: "json";
78
78
  status: 400;
79
79
  } | {
80
80
  input: {
@@ -177,8 +177,8 @@ export declare function createMessagesRouter(getAgent: GetAgentFn, approvalCoord
177
177
  sessionId: string;
178
178
  };
179
179
  };
180
- output: {};
181
- outputFormat: string;
180
+ output: never;
181
+ outputFormat: "json";
182
182
  status: 400;
183
183
  } | {
184
184
  input: {
@@ -1 +1 @@
1
- {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAIhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAElF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA0D9C,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,UAAU,EACpB,mBAAmB,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA+V5C"}
1
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAGhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAQlF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqB9C,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,UAAU,EACpB,mBAAmB,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA8W5C"}
@@ -1,25 +1,15 @@
1
1
  import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2
2
  import { streamSSE } from "hono/streaming";
3
3
  import { LLM_PROVIDERS } from "@dexto/core";
4
- import { PricingStatusSchema, TokenUsageSchema } from "../schemas/responses.js";
5
- const TextPartSchema = z.object({
6
- type: z.literal("text").describe("Content type identifier"),
7
- text: z.string().describe("Text content")
8
- }).describe("Text content part");
9
- const ImagePartSchema = z.object({
10
- type: z.literal("image").describe("Content type identifier"),
11
- image: z.string().describe("Base64-encoded image data or URL"),
12
- mimeType: z.string().optional().describe("MIME type (e.g., image/png)")
13
- }).describe("Image content part");
14
- const FilePartSchema = z.object({
15
- type: z.literal("file").describe("Content type identifier"),
16
- data: z.string().describe("Base64-encoded file data or URL"),
17
- mimeType: z.string().describe("MIME type (e.g., application/pdf)"),
18
- filename: z.string().optional().describe("Optional filename")
19
- }).describe("File content part");
20
- const ContentPartSchema = z.discriminatedUnion("type", [TextPartSchema, ImagePartSchema, FilePartSchema]).describe("Content part - text, image, or file");
4
+ import {
5
+ ApiErrorResponseSchema,
6
+ PricingStatusSchema,
7
+ RequestContentSchema,
8
+ TokenUsageSchema,
9
+ toContentInput
10
+ } from "../schemas/responses.js";
21
11
  const MessageBodySchema = z.object({
22
- content: z.union([z.string(), z.array(ContentPartSchema)]).describe("Message content - string for text, or ContentPart[] for multimodal"),
12
+ content: RequestContentSchema,
23
13
  sessionId: z.string().min(1, "Session ID is required").describe("The session to use for this message")
24
14
  }).describe("Request body for sending a message to the agent");
25
15
  const ResetBodySchema = z.object({
@@ -50,7 +40,10 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
50
40
  }
51
41
  }
52
42
  },
53
- 400: { description: "Validation error" }
43
+ 400: {
44
+ description: "Validation error",
45
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
46
+ }
54
47
  }
55
48
  });
56
49
  const messageSyncRoute = createRoute({
@@ -86,7 +79,10 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
86
79
  }
87
80
  }
88
81
  },
89
- 400: { description: "Validation error" }
82
+ 400: {
83
+ description: "Validation error",
84
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
85
+ }
90
86
  }
91
87
  });
92
88
  const resetRoute = createRoute({
@@ -165,13 +161,17 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
165
161
  }
166
162
  }
167
163
  },
168
- 400: { description: "Validation error" }
164
+ 400: {
165
+ description: "Validation error",
166
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
167
+ }
169
168
  }
170
169
  });
171
170
  return app.openapi(messageRoute, async (ctx) => {
172
171
  const agent = await getAgent(ctx);
173
172
  agent.logger.info("Received message via POST /api/message");
174
- const { content, sessionId } = ctx.req.valid("json");
173
+ const { content: rawContent, sessionId } = ctx.req.valid("json");
174
+ const content = toContentInput(rawContent);
175
175
  agent.logger.info(`Message for session: ${sessionId}`);
176
176
  agent.generate(content, sessionId).catch((error) => {
177
177
  agent.logger.error(
@@ -182,21 +182,25 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
182
182
  }).openapi(messageSyncRoute, async (ctx) => {
183
183
  const agent = await getAgent(ctx);
184
184
  agent.logger.info("Received message via POST /api/message-sync");
185
- const { content, sessionId } = ctx.req.valid("json");
185
+ const { content: rawContent, sessionId } = ctx.req.valid("json");
186
+ const content = toContentInput(rawContent);
186
187
  agent.logger.info(`Message for session: ${sessionId}`);
187
188
  const result = await agent.generate(content, sessionId);
188
- return ctx.json({
189
- response: result.content,
190
- sessionId: result.sessionId,
191
- tokenUsage: result.usage,
192
- messageId: result.messageId,
193
- usageScopeId: result.usageScopeId,
194
- estimatedCost: result.estimatedCost,
195
- pricingStatus: result.pricingStatus,
196
- reasoning: result.reasoning,
197
- model: result.model,
198
- provider: result.provider
199
- });
189
+ return ctx.json(
190
+ {
191
+ response: result.content,
192
+ sessionId: result.sessionId,
193
+ tokenUsage: result.usage,
194
+ messageId: result.messageId,
195
+ usageScopeId: result.usageScopeId,
196
+ estimatedCost: result.estimatedCost,
197
+ pricingStatus: result.pricingStatus,
198
+ reasoning: result.reasoning,
199
+ model: result.model,
200
+ provider: result.provider
201
+ },
202
+ 200
203
+ );
200
204
  }).openapi(resetRoute, async (ctx) => {
201
205
  const agent = await getAgent(ctx);
202
206
  agent.logger.info("Received request via POST /api/reset");
@@ -205,7 +209,8 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
205
209
  return ctx.json({ status: "reset initiated", sessionId });
206
210
  }).openapi(messageStreamRoute, async (ctx) => {
207
211
  const agent = await getAgent(ctx);
208
- const { content, sessionId } = ctx.req.valid("json");
212
+ const { content: rawContent, sessionId } = ctx.req.valid("json");
213
+ const content = toContentInput(rawContent);
209
214
  const isBusy = await agent.isSessionBusy(sessionId);
210
215
  if (isBusy) {
211
216
  const queuedMessages = await agent.getQueuedMessages(sessionId);
@@ -133,7 +133,10 @@ function createPromptsRouter(getAgent) {
133
133
  }
134
134
  }
135
135
  },
136
- 404: { description: "Prompt not found" }
136
+ 404: {
137
+ description: "Prompt not found",
138
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
139
+ }
137
140
  }
138
141
  });
139
142
  const resolvePromptRoute = (0, import_zod_openapi.createRoute)({
@@ -158,7 +161,10 @@ function createPromptsRouter(getAgent) {
158
161
  }
159
162
  }
160
163
  },
161
- 404: { description: "Prompt not found" }
164
+ 404: {
165
+ description: "Prompt not found",
166
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
167
+ }
162
168
  }
163
169
  });
164
170
  return app.openapi(listRoute, async (ctx) => {
@@ -200,7 +206,7 @@ function createPromptsRouter(getAgent) {
200
206
  const { name } = ctx.req.valid("param");
201
207
  const definition = await agent.getPromptDefinition(name);
202
208
  if (!definition) throw import_core.PromptError.notFound(name);
203
- return ctx.json({ definition });
209
+ return ctx.json({ definition }, 200);
204
210
  }).openapi(resolvePromptRoute, async (ctx) => {
205
211
  const agent = await getAgent(ctx);
206
212
  const { name } = ctx.req.valid("param");
@@ -219,7 +225,7 @@ function createPromptsRouter(getAgent) {
219
225
  if (context !== void 0) options.context = context;
220
226
  if (parsedArgs !== void 0) options.args = parsedArgs;
221
227
  const result = await agent.resolvePrompt(name, options);
222
- return ctx.json({ text: result.text, resources: result.resources });
228
+ return ctx.json({ text: result.text, resources: result.resources }, 200);
223
229
  });
224
230
  }
225
231
  // Annotate the CommonJS export names for ESM import in node:
@@ -88,8 +88,8 @@ export declare function createPromptsRouter(getAgent: GetAgentFn): OpenAPIHono<i
88
88
  name: string;
89
89
  };
90
90
  };
91
- output: {};
92
- outputFormat: string;
91
+ output: never;
92
+ outputFormat: "json";
93
93
  status: 404;
94
94
  } | {
95
95
  input: {
@@ -126,8 +126,8 @@ export declare function createPromptsRouter(getAgent: GetAgentFn): OpenAPIHono<i
126
126
  args?: string | undefined;
127
127
  };
128
128
  };
129
- output: {};
130
- outputFormat: string;
129
+ output: never;
130
+ outputFormat: "json";
131
131
  status: 404;
132
132
  } | {
133
133
  input: {
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAmErE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6NvD"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAO9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAmErE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAmOvD"}
@@ -1,6 +1,10 @@
1
1
  import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2
2
  import { PromptError } from "@dexto/core";
3
- import { PromptInfoSchema, PromptDefinitionSchema } from "../schemas/responses.js";
3
+ import {
4
+ ApiErrorResponseSchema,
5
+ PromptDefinitionSchema,
6
+ PromptInfoSchema
7
+ } from "../schemas/responses.js";
4
8
  const CustomPromptRequestSchema = z.object({
5
9
  name: z.string().min(1, "Prompt name is required").describe("Unique name for the custom prompt"),
6
10
  title: z.string().optional().describe("Display title for the prompt"),
@@ -110,7 +114,10 @@ function createPromptsRouter(getAgent) {
110
114
  }
111
115
  }
112
116
  },
113
- 404: { description: "Prompt not found" }
117
+ 404: {
118
+ description: "Prompt not found",
119
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
120
+ }
114
121
  }
115
122
  });
116
123
  const resolvePromptRoute = createRoute({
@@ -135,7 +142,10 @@ function createPromptsRouter(getAgent) {
135
142
  }
136
143
  }
137
144
  },
138
- 404: { description: "Prompt not found" }
145
+ 404: {
146
+ description: "Prompt not found",
147
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
148
+ }
139
149
  }
140
150
  });
141
151
  return app.openapi(listRoute, async (ctx) => {
@@ -177,7 +187,7 @@ function createPromptsRouter(getAgent) {
177
187
  const { name } = ctx.req.valid("param");
178
188
  const definition = await agent.getPromptDefinition(name);
179
189
  if (!definition) throw PromptError.notFound(name);
180
- return ctx.json({ definition });
190
+ return ctx.json({ definition }, 200);
181
191
  }).openapi(resolvePromptRoute, async (ctx) => {
182
192
  const agent = await getAgent(ctx);
183
193
  const { name } = ctx.req.valid("param");
@@ -196,7 +206,7 @@ function createPromptsRouter(getAgent) {
196
206
  if (context !== void 0) options.context = context;
197
207
  if (parsedArgs !== void 0) options.args = parsedArgs;
198
208
  const result = await agent.resolvePrompt(name, options);
199
- return ctx.json({ text: result.text, resources: result.resources });
209
+ return ctx.json({ text: result.text, resources: result.resources }, 200);
200
210
  });
201
211
  }
202
212
  export {
@@ -22,6 +22,7 @@ __export(queue_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(queue_exports);
24
24
  var import_zod_openapi = require("@hono/zod-openapi");
25
+ var import_core = require("@dexto/core");
25
26
  var import_responses = require("../schemas/responses.js");
26
27
  const QueuedMessageSchema = import_zod_openapi.z.object({
27
28
  id: import_zod_openapi.z.string().describe("Unique identifier for the queued message"),
@@ -30,24 +31,8 @@ const QueuedMessageSchema = import_zod_openapi.z.object({
30
31
  metadata: import_zod_openapi.z.record(import_zod_openapi.z.unknown()).optional().describe("Optional metadata"),
31
32
  kind: import_zod_openapi.z.enum(["default", "background"]).optional().describe("Optional queued message kind")
32
33
  }).strict().describe("A message waiting in the queue");
33
- const TextPartSchema = import_zod_openapi.z.object({
34
- type: import_zod_openapi.z.literal("text").describe("Content type identifier"),
35
- text: import_zod_openapi.z.string().describe("Text content")
36
- }).describe("Text content part");
37
- const ImagePartSchema = import_zod_openapi.z.object({
38
- type: import_zod_openapi.z.literal("image").describe("Content type identifier"),
39
- image: import_zod_openapi.z.string().describe("Base64-encoded image data or URL"),
40
- mimeType: import_zod_openapi.z.string().optional().describe("MIME type (e.g., image/png)")
41
- }).describe("Image content part");
42
- const FilePartSchema = import_zod_openapi.z.object({
43
- type: import_zod_openapi.z.literal("file").describe("Content type identifier"),
44
- data: import_zod_openapi.z.string().describe("Base64-encoded file data or URL"),
45
- mimeType: import_zod_openapi.z.string().describe("MIME type (e.g., application/pdf)"),
46
- filename: import_zod_openapi.z.string().optional().describe("Optional filename")
47
- }).describe("File content part");
48
- const QueueContentPartSchema = import_zod_openapi.z.discriminatedUnion("type", [TextPartSchema, ImagePartSchema, FilePartSchema]).describe("Content part - text, image, or file");
49
34
  const QueueMessageBodySchema = import_zod_openapi.z.object({
50
- content: import_zod_openapi.z.union([import_zod_openapi.z.string(), import_zod_openapi.z.array(QueueContentPartSchema)]).describe("Message content - string for text, or ContentPart[] for multimodal"),
35
+ content: import_responses.RequestContentSchema,
51
36
  kind: import_zod_openapi.z.enum(["default", "background"]).optional().describe("Optional queued message kind")
52
37
  }).describe("Request body for queueing a message");
53
38
  function createQueueRouter(getAgent) {
@@ -75,7 +60,10 @@ function createQueueRouter(getAgent) {
75
60
  }
76
61
  }
77
62
  },
78
- 404: { description: "Session not found" }
63
+ 404: {
64
+ description: "Session not found",
65
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
66
+ }
79
67
  }
80
68
  });
81
69
  const queueMessageRoute = (0, import_zod_openapi.createRoute)({
@@ -105,7 +93,10 @@ function createQueueRouter(getAgent) {
105
93
  }
106
94
  }
107
95
  },
108
- 404: { description: "Session not found" }
96
+ 404: {
97
+ description: "Session not found",
98
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
99
+ }
109
100
  }
110
101
  });
111
102
  const removeQueuedMessageRoute = (0, import_zod_openapi.createRoute)({
@@ -132,7 +123,10 @@ function createQueueRouter(getAgent) {
132
123
  }
133
124
  }
134
125
  },
135
- 404: { description: "Session or message not found" }
126
+ 404: {
127
+ description: "Session or message not found",
128
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
129
+ }
136
130
  }
137
131
  });
138
132
  const clearQueueRoute = (0, import_zod_openapi.createRoute)({
@@ -158,22 +152,35 @@ function createQueueRouter(getAgent) {
158
152
  }
159
153
  }
160
154
  },
161
- 404: { description: "Session not found" }
155
+ 404: {
156
+ description: "Session not found",
157
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
158
+ }
162
159
  }
163
160
  });
164
161
  return app.openapi(getQueueRoute, async (ctx) => {
165
162
  const agent = await getAgent(ctx);
166
163
  const { sessionId } = ctx.req.valid("param");
167
164
  const messages = await agent.getQueuedMessages(sessionId);
168
- return ctx.json({
169
- messages,
170
- count: messages.length
171
- });
165
+ const responseMessages = messages.map((message) => ({
166
+ id: message.id,
167
+ content: message.content.map(import_responses.toApiContentPart),
168
+ queuedAt: message.queuedAt,
169
+ ...message.metadata !== void 0 ? { metadata: message.metadata } : {},
170
+ ...message.kind !== void 0 ? { kind: message.kind } : {}
171
+ }));
172
+ return ctx.json(
173
+ {
174
+ messages: responseMessages,
175
+ count: responseMessages.length
176
+ },
177
+ 200
178
+ );
172
179
  }).openapi(queueMessageRoute, async (ctx) => {
173
180
  const agent = await getAgent(ctx);
174
181
  const { sessionId } = ctx.req.valid("param");
175
182
  const { content: rawContent } = ctx.req.valid("json");
176
- const content = typeof rawContent === "string" ? [{ type: "text", text: rawContent }] : rawContent;
183
+ const content = (0, import_responses.toContentInput)(rawContent);
177
184
  const { kind } = ctx.req.valid("json");
178
185
  const result = await agent.queueMessage(sessionId, {
179
186
  content,
@@ -192,14 +199,20 @@ function createQueueRouter(getAgent) {
192
199
  const { sessionId, messageId } = ctx.req.valid("param");
193
200
  const removed = await agent.removeQueuedMessage(sessionId, messageId);
194
201
  if (!removed) {
195
- return ctx.json({ error: "Message not found in queue" }, 404);
202
+ throw new import_core.DextoRuntimeError(
203
+ "queued_message_not_found",
204
+ "queue",
205
+ import_core.ErrorType.NOT_FOUND,
206
+ "Message not found in queue",
207
+ { sessionId, messageId }
208
+ );
196
209
  }
197
- return ctx.json({ removed: true, id: messageId });
210
+ return ctx.json({ removed: true, id: messageId }, 200);
198
211
  }).openapi(clearQueueRoute, async (ctx) => {
199
212
  const agent = await getAgent(ctx);
200
213
  const { sessionId } = ctx.req.valid("param");
201
214
  const count = await agent.clearMessageQueue(sessionId);
202
- return ctx.json({ cleared: true, count });
215
+ return ctx.json({ cleared: true, count }, 200);
203
216
  });
204
217
  }
205
218
  // Annotate the CommonJS export names for ESM import in node:
@@ -1,5 +1,5 @@
1
1
  import { OpenAPIHono } from '@hono/zod-openapi';
2
- import type { DextoAgent } from '@dexto/core';
2
+ import { type DextoAgent } from '@dexto/core';
3
3
  import type { Context } from 'hono';
4
4
  type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
5
5
  export declare function createQueueRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
@@ -10,8 +10,8 @@ export declare function createQueueRouter(getAgent: GetAgentFn): OpenAPIHono<imp
10
10
  sessionId: string;
11
11
  };
12
12
  };
13
- output: {};
14
- outputFormat: string;
13
+ output: never;
14
+ outputFormat: "json";
15
15
  status: 404;
16
16
  } | {
17
17
  input: {
@@ -85,8 +85,8 @@ export declare function createQueueRouter(getAgent: GetAgentFn): OpenAPIHono<imp
85
85
  kind?: "default" | "background" | undefined;
86
86
  };
87
87
  };
88
- output: {};
89
- outputFormat: string;
88
+ output: never;
89
+ outputFormat: "json";
90
90
  status: 404;
91
91
  } | {
92
92
  input: {
@@ -129,8 +129,8 @@ export declare function createQueueRouter(getAgent: GetAgentFn): OpenAPIHono<imp
129
129
  messageId: string;
130
130
  };
131
131
  };
132
- output: {};
133
- outputFormat: string;
132
+ output: never;
133
+ outputFormat: "json";
134
134
  status: 404;
135
135
  } | {
136
136
  input: {
@@ -155,8 +155,8 @@ export declare function createQueueRouter(getAgent: GetAgentFn): OpenAPIHono<imp
155
155
  sessionId: string;
156
156
  };
157
157
  };
158
- output: {};
159
- outputFormat: string;
158
+ output: never;
159
+ outputFormat: "json";
160
160
  status: 404;
161
161
  } | {
162
162
  input: {
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAuDrE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwLrD"}
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAgC,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAQ5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAsBrE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6MrD"}