@dexto/server 1.6.20 → 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.
Files changed (111) hide show
  1. package/dist/a2a/jsonrpc/methods.cjs +1 -1
  2. package/dist/a2a/jsonrpc/methods.d.ts +14 -4
  3. package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
  4. package/dist/a2a/jsonrpc/methods.js +1 -1
  5. package/dist/hono/index.cjs +39 -8
  6. package/dist/hono/index.d.ts +43 -4531
  7. package/dist/hono/index.d.ts.map +1 -1
  8. package/dist/hono/index.js +42 -9
  9. package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
  10. package/dist/hono/routes/a2a-tasks.cjs +158 -32
  11. package/dist/hono/routes/a2a-tasks.d.ts +1 -502
  12. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
  13. package/dist/hono/routes/a2a-tasks.js +162 -32
  14. package/dist/hono/routes/a2a.d.ts.map +1 -1
  15. package/dist/hono/routes/agents.cjs +410 -329
  16. package/dist/hono/routes/agents.d.ts +16043 -68
  17. package/dist/hono/routes/agents.d.ts.map +1 -1
  18. package/dist/hono/routes/agents.js +418 -330
  19. package/dist/hono/routes/approvals.cjs +102 -88
  20. package/dist/hono/routes/approvals.d.ts +2089 -142
  21. package/dist/hono/routes/approvals.d.ts.map +1 -1
  22. package/dist/hono/routes/approvals.js +108 -89
  23. package/dist/hono/routes/dexto-auth.cjs +40 -33
  24. package/dist/hono/routes/dexto-auth.d.ts +401 -2
  25. package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
  26. package/dist/hono/routes/dexto-auth.js +40 -33
  27. package/dist/hono/routes/discovery.cjs +16 -14
  28. package/dist/hono/routes/discovery.d.ts +586 -1
  29. package/dist/hono/routes/discovery.d.ts.map +1 -1
  30. package/dist/hono/routes/discovery.js +16 -14
  31. package/dist/hono/routes/greeting.cjs +26 -22
  32. package/dist/hono/routes/greeting.d.ts +787 -3
  33. package/dist/hono/routes/greeting.d.ts.map +1 -1
  34. package/dist/hono/routes/greeting.js +26 -22
  35. package/dist/hono/routes/health.d.ts +1 -1
  36. package/dist/hono/routes/key.cjs +60 -52
  37. package/dist/hono/routes/key.d.ts +1597 -1
  38. package/dist/hono/routes/key.d.ts.map +1 -1
  39. package/dist/hono/routes/key.js +60 -52
  40. package/dist/hono/routes/llm.cjs +381 -348
  41. package/dist/hono/routes/llm.d.ts +12136 -86
  42. package/dist/hono/routes/llm.d.ts.map +1 -1
  43. package/dist/hono/routes/llm.js +385 -348
  44. package/dist/hono/routes/mcp.cjs +257 -226
  45. package/dist/hono/routes/mcp.d.ts +6605 -309
  46. package/dist/hono/routes/mcp.d.ts.map +1 -1
  47. package/dist/hono/routes/mcp.js +263 -225
  48. package/dist/hono/routes/memory.cjs +102 -89
  49. package/dist/hono/routes/memory.d.ts +5368 -4
  50. package/dist/hono/routes/memory.d.ts.map +1 -1
  51. package/dist/hono/routes/memory.js +108 -90
  52. package/dist/hono/routes/messages.cjs +147 -139
  53. package/dist/hono/routes/messages.d.ts +3900 -11
  54. package/dist/hono/routes/messages.d.ts.map +1 -1
  55. package/dist/hono/routes/messages.js +150 -139
  56. package/dist/hono/routes/models.cjs +106 -64
  57. package/dist/hono/routes/models.d.ts +2874 -1
  58. package/dist/hono/routes/models.d.ts.map +1 -1
  59. package/dist/hono/routes/models.js +108 -64
  60. package/dist/hono/routes/openrouter.cjs +79 -65
  61. package/dist/hono/routes/openrouter.d.ts +854 -1
  62. package/dist/hono/routes/openrouter.d.ts.map +1 -1
  63. package/dist/hono/routes/openrouter.js +79 -65
  64. package/dist/hono/routes/prompts.cjs +136 -109
  65. package/dist/hono/routes/prompts.d.ts +2818 -10
  66. package/dist/hono/routes/prompts.d.ts.map +1 -1
  67. package/dist/hono/routes/prompts.js +138 -109
  68. package/dist/hono/routes/queue.cjs +133 -120
  69. package/dist/hono/routes/queue.d.ts +5144 -9
  70. package/dist/hono/routes/queue.d.ts.map +1 -1
  71. package/dist/hono/routes/queue.js +136 -120
  72. package/dist/hono/routes/resources.cjs +65 -46
  73. package/dist/hono/routes/resources.d.ts +1982 -4
  74. package/dist/hono/routes/resources.d.ts.map +1 -1
  75. package/dist/hono/routes/resources.js +72 -47
  76. package/dist/hono/routes/schedules.cjs +233 -226
  77. package/dist/hono/routes/schedules.d.ts +4198 -22
  78. package/dist/hono/routes/schedules.d.ts.map +1 -1
  79. package/dist/hono/routes/schedules.js +233 -226
  80. package/dist/hono/routes/search.cjs +34 -30
  81. package/dist/hono/routes/search.d.ts +2835 -12
  82. package/dist/hono/routes/search.d.ts.map +1 -1
  83. package/dist/hono/routes/search.js +40 -31
  84. package/dist/hono/routes/sessions.cjs +403 -396
  85. package/dist/hono/routes/sessions.d.ts +16582 -27
  86. package/dist/hono/routes/sessions.d.ts.map +1 -1
  87. package/dist/hono/routes/sessions.js +407 -397
  88. package/dist/hono/routes/static.d.ts.map +1 -1
  89. package/dist/hono/routes/system-prompt.cjs +57 -61
  90. package/dist/hono/routes/system-prompt.d.ts +1228 -2
  91. package/dist/hono/routes/system-prompt.d.ts.map +1 -1
  92. package/dist/hono/routes/system-prompt.js +58 -62
  93. package/dist/hono/routes/tools.cjs +29 -34
  94. package/dist/hono/routes/tools.d.ts +1755 -6
  95. package/dist/hono/routes/tools.d.ts.map +1 -1
  96. package/dist/hono/routes/tools.js +33 -33
  97. package/dist/hono/routes/webhooks.cjs +115 -123
  98. package/dist/hono/routes/webhooks.d.ts +2501 -11
  99. package/dist/hono/routes/webhooks.d.ts.map +1 -1
  100. package/dist/hono/routes/webhooks.js +120 -124
  101. package/dist/hono/routes/workspaces.cjs +84 -79
  102. package/dist/hono/routes/workspaces.d.ts +2093 -2
  103. package/dist/hono/routes/workspaces.d.ts.map +1 -1
  104. package/dist/hono/routes/workspaces.js +89 -80
  105. package/dist/hono/schemas/responses.cjs +406 -259
  106. package/dist/hono/schemas/responses.d.ts +1246 -123
  107. package/dist/hono/schemas/responses.d.ts.map +1 -1
  108. package/dist/hono/schemas/responses.js +144 -10
  109. package/dist/hono/types.d.ts +11 -0
  110. package/dist/hono/types.d.ts.map +1 -1
  111. package/package.json +7 -7
@@ -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;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
+ {"version":3,"file":"messages.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,KAAK,0BAA0B,EAAE,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEjG,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAE3C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AAWlF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAQyC,CAAC;AAEjE,QAAA,MAAM,eAAe;;;;;;EAOqC,CAAC;AAwD3D,QAAA,MAAM,YAAY;;;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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2K5C;AAED,KAAK,kBAAkB,GAAG,QAAQ,CAC9B,MAAM,EACN,UAAU,EACV;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;CAAE,EAC3C,0BAA0B,CAAC,OAAO,YAAY,CAAC,CAClD,CAAC;AAEF,KAAK,sBAAsB,GAAG,QAAQ,CAClC,MAAM,EACN,eAAe,EACf;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;CAAE,EAC3C,0BAA0B,CAAC,OAAO,gBAAgB,CAAC,CACtD,CAAC;AAEF,KAAK,gBAAgB,GAAG,QAAQ,CAC5B,MAAM,EACN,QAAQ,EACR;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,eAAe,CAAC,CAAA;CAAE,EACzC,0BAA0B,CAAC,OAAO,UAAU,CAAC,CAChD,CAAC;AAEF,KAAK,wBAAwB,GAAG,QAAQ,CACpC,MAAM,EACN,iBAAiB,EACjB;IAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,OAAO,iBAAiB,CAAC,CAAA;CAAE,EAC3C,0BAA0B,CAAC,OAAO,kBAAkB,CAAC,CACxD,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC1B,kBAAkB,GAClB,sBAAsB,GACtB,gBAAgB,GAChB,wBAAwB,CAAC"}
@@ -3,6 +3,9 @@ import { streamSSE } from "hono/streaming";
3
3
  import { LLM_PROVIDERS } from "@dexto/core";
4
4
  import {
5
5
  ApiErrorResponseSchema,
6
+ BadRequestErrorResponse,
7
+ InternalErrorResponse,
8
+ NotFoundErrorResponse,
6
9
  PricingStatusSchema,
7
10
  RequestContentSchema,
8
11
  TokenUsageSchema,
@@ -15,158 +18,166 @@ const MessageBodySchema = z.object({
15
18
  const ResetBodySchema = z.object({
16
19
  sessionId: z.string().min(1, "Session ID is required").describe("The ID of the session to reset")
17
20
  }).describe("Request body for resetting a conversation");
18
- function createMessagesRouter(getAgent, approvalCoordinator) {
19
- const app = new OpenAPIHono();
20
- const messageRoute = createRoute({
21
- method: "post",
22
- path: "/message",
23
- summary: "Send Message (async)",
24
- description: "Sends a message and returns immediately. The full response will be sent over SSE",
25
- tags: ["messages"],
26
- request: {
27
- body: {
28
- content: { "application/json": { schema: MessageBodySchema } }
29
- }
30
- },
31
- responses: {
32
- 202: {
33
- description: "Message accepted for async processing; subscribe to SSE for results",
34
- content: {
35
- "application/json": {
36
- schema: z.object({
37
- accepted: z.literal(true).describe("Indicates request was accepted"),
38
- sessionId: z.string().describe("Session ID used for this message")
39
- }).strict()
40
- }
21
+ const MessageAcceptedResponseSchema = z.object({
22
+ accepted: z.literal(true).describe("Indicates request was accepted"),
23
+ sessionId: z.string().describe("Session ID used for this message")
24
+ }).strict().describe("Asynchronous message acceptance response");
25
+ const MessageSyncResponseSchema = z.object({
26
+ response: z.string().describe("Agent response text"),
27
+ sessionId: z.string().describe("Session ID used for this message"),
28
+ tokenUsage: TokenUsageSchema.optional().describe("Token usage statistics"),
29
+ messageId: z.string().uuid().optional().describe("Assistant message ID for this response"),
30
+ usageScopeId: z.string().optional().describe("Optional usage scope identifier for runtime-scoped metering"),
31
+ estimatedCost: z.number().nonnegative().optional().describe("Estimated cost in USD for this response"),
32
+ pricingStatus: PricingStatusSchema.optional().describe(
33
+ "Whether pricing was resolved for this response"
34
+ ),
35
+ reasoning: z.string().optional().describe("Extended thinking content from reasoning models"),
36
+ model: z.string().optional().describe("Model used for this response"),
37
+ provider: z.enum(LLM_PROVIDERS).optional().describe("LLM provider")
38
+ }).strict().describe("Synchronous message response");
39
+ const ResetResponseSchema = z.object({
40
+ status: z.string().describe("Status message indicating reset was initiated"),
41
+ sessionId: z.string().describe("Session ID that was reset")
42
+ }).strict().describe("Session reset response");
43
+ const MessageStreamBusyResponseSchema = z.object({
44
+ busy: z.literal(true).describe("Indicates session is busy"),
45
+ sessionId: z.string().describe("The session ID"),
46
+ queueLength: z.number().describe("Current number of messages in queue"),
47
+ hint: z.string().describe("Instructions for the client")
48
+ }).strict().describe("Busy response for streaming requests");
49
+ const messageRoute = createRoute({
50
+ method: "post",
51
+ path: "/message",
52
+ summary: "Send Message (async)",
53
+ description: "Sends a message and returns immediately. The full response will be sent over SSE",
54
+ tags: ["messages"],
55
+ request: {
56
+ body: {
57
+ content: { "application/json": { schema: MessageBodySchema } }
58
+ }
59
+ },
60
+ responses: {
61
+ 202: {
62
+ description: "Message accepted for async processing; subscribe to SSE for results",
63
+ content: {
64
+ "application/json": {
65
+ schema: MessageAcceptedResponseSchema
41
66
  }
42
- },
43
- 400: {
44
- description: "Validation error",
45
- content: { "application/json": { schema: ApiErrorResponseSchema } }
46
67
  }
47
- }
48
- });
49
- const messageSyncRoute = createRoute({
50
- method: "post",
51
- path: "/message-sync",
52
- summary: "Send Message (sync)",
53
- description: "Sends a message and waits for the full response",
54
- tags: ["messages"],
55
- request: {
56
- body: { content: { "application/json": { schema: MessageBodySchema } } }
57
68
  },
58
- responses: {
59
- 200: {
60
- description: "Synchronous response",
61
- content: {
62
- "application/json": {
63
- schema: z.object({
64
- response: z.string().describe("Agent response text"),
65
- sessionId: z.string().describe("Session ID used for this message"),
66
- tokenUsage: TokenUsageSchema.optional().describe("Token usage statistics"),
67
- messageId: z.string().uuid().optional().describe("Assistant message ID for this response"),
68
- usageScopeId: z.string().optional().describe(
69
- "Optional usage scope identifier for runtime-scoped metering"
70
- ),
71
- estimatedCost: z.number().nonnegative().optional().describe("Estimated cost in USD for this response"),
72
- pricingStatus: PricingStatusSchema.optional().describe(
73
- "Whether pricing was resolved for this response"
74
- ),
75
- reasoning: z.string().optional().describe("Extended thinking content from reasoning models"),
76
- model: z.string().optional().describe("Model used for this response"),
77
- provider: z.enum(LLM_PROVIDERS).optional().describe("LLM provider")
78
- }).strict()
79
- }
69
+ 400: {
70
+ description: "Validation error",
71
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
72
+ },
73
+ 500: InternalErrorResponse
74
+ }
75
+ });
76
+ const messageSyncRoute = createRoute({
77
+ method: "post",
78
+ path: "/message-sync",
79
+ summary: "Send Message (sync)",
80
+ description: "Sends a message and waits for the full response",
81
+ tags: ["messages"],
82
+ request: {
83
+ body: { content: { "application/json": { schema: MessageBodySchema } } }
84
+ },
85
+ responses: {
86
+ 200: {
87
+ description: "Synchronous response",
88
+ content: {
89
+ "application/json": {
90
+ schema: MessageSyncResponseSchema
80
91
  }
81
- },
82
- 400: {
83
- description: "Validation error",
84
- content: { "application/json": { schema: ApiErrorResponseSchema } }
85
92
  }
86
- }
87
- });
88
- const resetRoute = createRoute({
89
- method: "post",
90
- path: "/reset",
91
- summary: "Reset Conversation",
92
- description: "Resets the conversation history for a given session",
93
- tags: ["messages"],
94
- request: {
95
- body: { content: { "application/json": { schema: ResetBodySchema } } }
96
93
  },
97
- responses: {
98
- 200: {
99
- description: "Reset initiated",
100
- content: {
101
- "application/json": {
102
- schema: z.object({
103
- status: z.string().describe("Status message indicating reset was initiated"),
104
- sessionId: z.string().describe("Session ID that was reset")
105
- }).strict()
106
- }
94
+ 400: {
95
+ description: "Validation error",
96
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
97
+ },
98
+ 500: InternalErrorResponse
99
+ }
100
+ });
101
+ const resetRoute = createRoute({
102
+ method: "post",
103
+ path: "/reset",
104
+ summary: "Reset Conversation",
105
+ description: "Resets the conversation history for a given session",
106
+ tags: ["messages"],
107
+ request: {
108
+ body: { content: { "application/json": { schema: ResetBodySchema } } }
109
+ },
110
+ responses: {
111
+ 200: {
112
+ description: "Reset initiated",
113
+ content: {
114
+ "application/json": {
115
+ schema: ResetResponseSchema
107
116
  }
108
117
  }
109
- }
110
- });
111
- const messageStreamRoute = createRoute({
112
- method: "post",
113
- path: "/message-stream",
114
- summary: "Stream message response",
115
- description: "Sends a message and streams the response via Server-Sent Events (SSE). Returns SSE stream directly in response. Events include llm:thinking, llm:chunk, llm:tool-call, llm:tool-result, llm:response, and llm:error. Final llm:response events include token usage, assistant message ID, and pricing metadata when available. If the session is busy processing another message, returns 202 with queue information.",
116
- tags: ["messages"],
117
- request: {
118
- body: {
119
- content: { "application/json": { schema: MessageBodySchema } }
120
- }
121
118
  },
122
- responses: {
123
- 200: {
124
- description: "SSE stream of agent events. Standard SSE format with event type and JSON data.",
125
- headers: {
126
- "Content-Type": {
127
- description: "SSE content type",
128
- schema: { type: "string", example: "text/event-stream" }
129
- },
130
- "Cache-Control": {
131
- description: "Disable caching for stream",
132
- schema: { type: "string", example: "no-cache" }
133
- },
134
- Connection: {
135
- description: "Keep connection alive for streaming",
136
- schema: { type: "string", example: "keep-alive" }
137
- },
138
- "X-Accel-Buffering": {
139
- description: "Disable nginx buffering",
140
- schema: { type: "string", example: "no" }
141
- }
119
+ 400: BadRequestErrorResponse,
120
+ 404: NotFoundErrorResponse,
121
+ 500: InternalErrorResponse
122
+ }
123
+ });
124
+ const messageStreamRoute = createRoute({
125
+ method: "post",
126
+ path: "/message-stream",
127
+ summary: "Stream message response",
128
+ description: "Sends a message and streams the response via Server-Sent Events (SSE). Returns SSE stream directly in response. Events include llm:thinking, llm:chunk, llm:tool-call, llm:tool-result, llm:response, and llm:error. Final llm:response events include token usage, assistant message ID, and pricing metadata when available. If the session is busy processing another message, returns 202 with queue information.",
129
+ tags: ["messages"],
130
+ request: {
131
+ body: {
132
+ content: { "application/json": { schema: MessageBodySchema } }
133
+ }
134
+ },
135
+ responses: {
136
+ 200: {
137
+ description: "SSE stream of agent events. Standard SSE format with event type and JSON data.",
138
+ headers: {
139
+ "Content-Type": {
140
+ description: "SSE content type",
141
+ schema: { type: "string", example: "text/event-stream" }
142
142
  },
143
- content: {
144
- "text/event-stream": {
145
- schema: z.string().describe(
146
- "Server-Sent Events stream. Events: llm:thinking (start), llm:chunk (text fragments), llm:tool-call (tool execution), llm:tool-result (tool output), llm:response (final), llm:error (errors). Final llm:response payloads include token usage, assistant message ID, and pricing metadata when available."
147
- )
148
- }
143
+ "Cache-Control": {
144
+ description: "Disable caching for stream",
145
+ schema: { type: "string", example: "no-cache" }
146
+ },
147
+ Connection: {
148
+ description: "Keep connection alive for streaming",
149
+ schema: { type: "string", example: "keep-alive" }
150
+ },
151
+ "X-Accel-Buffering": {
152
+ description: "Disable nginx buffering",
153
+ schema: { type: "string", example: "no" }
149
154
  }
150
155
  },
151
- 202: {
152
- description: "Session is busy processing another message. Use the queue endpoints to manage pending messages.",
153
- content: {
154
- "application/json": {
155
- schema: z.object({
156
- busy: z.literal(true).describe("Indicates session is busy"),
157
- sessionId: z.string().describe("The session ID"),
158
- queueLength: z.number().describe("Current number of messages in queue"),
159
- hint: z.string().describe("Instructions for the client")
160
- }).strict()
161
- }
156
+ content: {
157
+ "text/event-stream": {
158
+ schema: z.string().describe(
159
+ "Server-Sent Events stream. Events: llm:thinking (start), llm:chunk (text fragments), llm:tool-call (tool execution), llm:tool-result (tool output), llm:response (final), llm:error (errors). Final llm:response payloads include token usage, assistant message ID, and pricing metadata when available."
160
+ )
162
161
  }
163
- },
164
- 400: {
165
- description: "Validation error",
166
- content: { "application/json": { schema: ApiErrorResponseSchema } }
167
162
  }
168
- }
169
- });
163
+ },
164
+ 202: {
165
+ description: "Session is busy processing another message. Use the queue endpoints to manage pending messages.",
166
+ content: {
167
+ "application/json": {
168
+ schema: MessageStreamBusyResponseSchema
169
+ }
170
+ }
171
+ },
172
+ 400: {
173
+ description: "Validation error",
174
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
175
+ },
176
+ 500: InternalErrorResponse
177
+ }
178
+ });
179
+ function createMessagesRouter(getAgent, approvalCoordinator) {
180
+ const app = new OpenAPIHono();
170
181
  return app.openapi(messageRoute, async (ctx) => {
171
182
  const agent = await getAgent(ctx);
172
183
  agent.logger.info("Received message via POST /api/message");
@@ -206,7 +217,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
206
217
  agent.logger.info("Received request via POST /api/reset");
207
218
  const { sessionId } = ctx.req.valid("json");
208
219
  await agent.resetConversation(sessionId);
209
- return ctx.json({ status: "reset initiated", sessionId });
220
+ return ctx.json({ status: "reset initiated", sessionId }, 200);
210
221
  }).openapi(messageStreamRoute, async (ctx) => {
211
222
  const agent = await getAgent(ctx);
212
223
  const { content: rawContent, sessionId } = ctx.req.valid("json");
@@ -25,6 +25,7 @@ var import_zod_openapi = require("@hono/zod-openapi");
25
25
  var import_fs = require("fs");
26
26
  var import_core = require("@dexto/core");
27
27
  var import_agent_management = require("@dexto/agent-management");
28
+ var import_responses = require("../schemas/responses.js");
28
29
  const LocalModelSchema = import_zod_openapi.z.object({
29
30
  id: import_zod_openapi.z.string().describe("Model identifier"),
30
31
  displayName: import_zod_openapi.z.string().describe("Human-readable model name"),
@@ -63,7 +64,8 @@ const listLocalModelsRoute = (0, import_zod_openapi.createRoute)({
63
64
  })
64
65
  }
65
66
  }
66
- }
67
+ },
68
+ 500: import_responses.InternalErrorResponse
67
69
  }
68
70
  });
69
71
  const listOllamaModelsRoute = (0, import_zod_openapi.createRoute)({
@@ -90,7 +92,9 @@ const listOllamaModelsRoute = (0, import_zod_openapi.createRoute)({
90
92
  })
91
93
  }
92
94
  }
93
- }
95
+ },
96
+ 400: import_responses.BadRequestErrorResponse,
97
+ 500: import_responses.InternalErrorResponse
94
98
  }
95
99
  });
96
100
  const validateLocalFileRoute = (0, import_zod_openapi.createRoute)({
@@ -116,7 +120,9 @@ const validateLocalFileRoute = (0, import_zod_openapi.createRoute)({
116
120
  schema: ValidateFileResponseSchema
117
121
  }
118
122
  }
119
- }
123
+ },
124
+ 400: import_responses.BadRequestErrorResponse,
125
+ 500: import_responses.InternalErrorResponse
120
126
  }
121
127
  });
122
128
  const DeleteModelRequestSchema = import_zod_openapi.z.object({
@@ -163,7 +169,9 @@ const deleteLocalModelRoute = (0, import_zod_openapi.createRoute)({
163
169
  schema: DeleteModelResponseSchema
164
170
  }
165
171
  }
166
- }
172
+ },
173
+ 400: import_responses.BadRequestErrorResponse,
174
+ 500: import_responses.InternalErrorResponse
167
175
  }
168
176
  });
169
177
  function createModelsRouter() {
@@ -181,82 +189,112 @@ function createModelsRouter() {
181
189
  source: model.source
182
190
  };
183
191
  });
184
- return ctx.json({ models });
192
+ return ctx.json({ models }, 200);
185
193
  }).openapi(listOllamaModelsRoute, async (ctx) => {
186
194
  const { baseURL } = ctx.req.valid("query");
187
195
  const ollamaURL = baseURL || import_core.DEFAULT_OLLAMA_URL;
188
196
  try {
189
197
  const status = await (0, import_core.checkOllamaStatus)(ollamaURL);
190
198
  if (!status.running) {
191
- return ctx.json({
192
- available: false,
193
- models: [],
194
- error: "Ollama server is not running"
195
- });
199
+ return ctx.json(
200
+ {
201
+ available: false,
202
+ models: [],
203
+ error: "Ollama server is not running"
204
+ },
205
+ 200
206
+ );
196
207
  }
197
208
  const ollamaModels = await (0, import_core.listOllamaModels)(ollamaURL);
198
- return ctx.json({
199
- available: true,
200
- version: status.version,
201
- models: ollamaModels.map((m) => ({
202
- name: m.name,
203
- size: m.size,
204
- digest: m.digest,
205
- modifiedAt: m.modifiedAt
206
- }))
207
- });
209
+ return ctx.json(
210
+ {
211
+ available: true,
212
+ version: status.version,
213
+ models: ollamaModels.map((m) => ({
214
+ name: m.name,
215
+ size: m.size,
216
+ digest: m.digest,
217
+ modifiedAt: m.modifiedAt
218
+ }))
219
+ },
220
+ 200
221
+ );
208
222
  } catch (error) {
209
- return ctx.json({
210
- available: false,
211
- models: [],
212
- error: error instanceof Error ? error.message : "Failed to connect to Ollama server"
213
- });
223
+ return ctx.json(
224
+ {
225
+ available: false,
226
+ models: [],
227
+ error: error instanceof Error ? error.message : "Failed to connect to Ollama server"
228
+ },
229
+ 200
230
+ );
214
231
  }
215
232
  }).openapi(validateLocalFileRoute, async (ctx) => {
216
233
  const { filePath } = ctx.req.valid("json");
217
234
  if (!filePath.startsWith("/")) {
218
- return ctx.json({
219
- valid: false,
220
- error: "File path must be absolute (start with /)"
221
- });
235
+ return ctx.json(
236
+ {
237
+ valid: false,
238
+ error: "File path must be absolute (start with /)"
239
+ },
240
+ 200
241
+ );
222
242
  }
223
243
  if (!filePath.endsWith(".gguf")) {
224
- return ctx.json({
225
- valid: false,
226
- error: "File must have .gguf extension"
227
- });
244
+ return ctx.json(
245
+ {
246
+ valid: false,
247
+ error: "File must have .gguf extension"
248
+ },
249
+ 200
250
+ );
228
251
  }
229
252
  try {
230
253
  const stats = await import_fs.promises.stat(filePath);
231
254
  if (!stats.isFile()) {
232
- return ctx.json({
233
- valid: false,
234
- error: "Path is not a file"
235
- });
255
+ return ctx.json(
256
+ {
257
+ valid: false,
258
+ error: "Path is not a file"
259
+ },
260
+ 200
261
+ );
236
262
  }
237
263
  await import_fs.promises.access(filePath, import_fs.promises.constants.R_OK);
238
- return ctx.json({
239
- valid: true,
240
- sizeBytes: stats.size
241
- });
264
+ return ctx.json(
265
+ {
266
+ valid: true,
267
+ sizeBytes: stats.size
268
+ },
269
+ 200
270
+ );
242
271
  } catch (error) {
243
272
  const nodeError = error;
244
273
  if (nodeError.code === "ENOENT") {
245
- return ctx.json({
246
- valid: false,
247
- error: "File not found"
248
- });
274
+ return ctx.json(
275
+ {
276
+ valid: false,
277
+ error: "File not found"
278
+ },
279
+ 200
280
+ );
249
281
  }
250
282
  if (nodeError.code === "EACCES") {
251
- return ctx.json({
252
- valid: false,
253
- error: "File is not readable (permission denied)"
254
- });
283
+ return ctx.json(
284
+ {
285
+ valid: false,
286
+ error: "File is not readable (permission denied)"
287
+ },
288
+ 200
289
+ );
255
290
  }
256
- return ctx.json({
257
- valid: false,
258
- error: error instanceof Error ? error.message : "Failed to access file"
259
- });
291
+ return ctx.json(
292
+ {
293
+ valid: false,
294
+ error: error instanceof Error ? error.message : "Failed to access file"
295
+ },
296
+ 200
297
+ );
260
298
  }
261
299
  }).openapi(deleteLocalModelRoute, async (ctx) => {
262
300
  const { modelId } = ctx.req.valid("param");
@@ -299,18 +337,22 @@ function createModelsRouter() {
299
337
  }
300
338
  const removed = await (0, import_agent_management.removeInstalledModel)(modelId);
301
339
  if (!removed) {
302
- return ctx.json({
303
- success: false,
304
- modelId,
305
- fileDeleted,
306
- error: "Failed to remove model from state"
307
- });
340
+ throw new import_core.DextoRuntimeError(
341
+ "model_state_remove_failed",
342
+ "model",
343
+ import_core.ErrorType.SYSTEM,
344
+ "Failed to remove model from state",
345
+ { modelId, fileDeleted }
346
+ );
308
347
  }
309
- return ctx.json({
310
- success: true,
311
- modelId,
312
- fileDeleted
313
- });
348
+ return ctx.json(
349
+ {
350
+ success: true,
351
+ modelId,
352
+ fileDeleted
353
+ },
354
+ 200
355
+ );
314
356
  });
315
357
  }
316
358
  // Annotate the CommonJS export names for ESM import in node: