@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
@@ -68,423 +68,412 @@ function mapSessionMetadata(sessionId, metadata, defaults) {
68
68
  parentSessionId: metadata?.parentSessionId ?? defaults?.parentSessionId ?? null
69
69
  };
70
70
  }
71
- function createSessionsRouter(getAgent) {
72
- const app = new import_zod_openapi.OpenAPIHono({
73
- defaultHook: (result, ctx) => {
74
- if (!result.success) {
75
- const issues = (0, import_core.zodToIssues)(result.error);
76
- return (0, import_error.handleHonoError)(
77
- ctx,
78
- new import_core.DextoRuntimeError(
79
- "validation_failed",
80
- "validation",
81
- import_core.ErrorType.USER,
82
- issues[0]?.message ?? "Validation failed",
83
- { issues }
84
- )
85
- );
86
- }
87
- }
88
- });
89
- app.onError((err, ctx) => (0, import_error.handleHonoError)(ctx, err));
90
- const listRoute = (0, import_zod_openapi.createRoute)({
91
- method: "get",
92
- path: "/sessions",
93
- summary: "List Sessions",
94
- description: "Retrieves a list of all active sessions",
95
- tags: ["sessions"],
96
- responses: {
97
- 200: {
98
- description: "List of all active sessions",
99
- content: {
100
- "application/json": {
101
- schema: import_zod_openapi.z.object({
102
- sessions: import_zod_openapi.z.array(import_responses.SessionMetadataSchema).describe("Array of session metadata objects")
103
- }).strict()
104
- }
71
+ const listRoute = (0, import_zod_openapi.createRoute)({
72
+ method: "get",
73
+ path: "/sessions",
74
+ summary: "List Sessions",
75
+ description: "Retrieves a list of all active sessions",
76
+ tags: ["sessions"],
77
+ responses: {
78
+ 200: {
79
+ description: "List of all active sessions",
80
+ content: {
81
+ "application/json": {
82
+ schema: import_zod_openapi.z.object({
83
+ sessions: import_zod_openapi.z.array(import_responses.SessionMetadataSchema).describe("Array of session metadata objects")
84
+ }).strict()
105
85
  }
106
86
  }
107
- }
108
- });
109
- const createRouteDef = (0, import_zod_openapi.createRoute)({
110
- method: "post",
111
- path: "/sessions",
112
- summary: "Create Session",
113
- description: "Creates a new session",
114
- tags: ["sessions"],
115
- request: { body: { content: { "application/json": { schema: CreateSessionSchema } } } },
116
- responses: {
117
- 201: {
118
- description: "Session created successfully",
119
- content: {
120
- "application/json": {
121
- schema: import_zod_openapi.z.object({
122
- session: import_responses.SessionMetadataSchema.describe(
123
- "Newly created session metadata"
124
- )
125
- }).strict()
126
- }
87
+ },
88
+ 400: import_responses.BadRequestErrorResponse,
89
+ 500: import_responses.InternalErrorResponse
90
+ }
91
+ });
92
+ const createRouteDef = (0, import_zod_openapi.createRoute)({
93
+ method: "post",
94
+ path: "/sessions",
95
+ summary: "Create Session",
96
+ description: "Creates a new session",
97
+ tags: ["sessions"],
98
+ request: { body: { content: { "application/json": { schema: CreateSessionSchema } } } },
99
+ responses: {
100
+ 201: {
101
+ description: "Session created successfully",
102
+ content: {
103
+ "application/json": {
104
+ schema: import_zod_openapi.z.object({
105
+ session: import_responses.SessionMetadataSchema.describe(
106
+ "Newly created session metadata"
107
+ )
108
+ }).strict()
127
109
  }
128
110
  }
129
- }
130
- });
131
- const getRoute = (0, import_zod_openapi.createRoute)({
132
- method: "get",
133
- path: "/sessions/{sessionId}",
134
- summary: "Get Session Details",
135
- description: "Fetches details for a specific session",
136
- tags: ["sessions"],
137
- request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
138
- responses: {
139
- 200: {
140
- description: "Session details with metadata",
141
- content: {
142
- "application/json": {
143
- schema: import_zod_openapi.z.object({
144
- session: import_responses.SessionMetadataSchema.extend({
145
- history: import_zod_openapi.z.number().int().nonnegative().describe("Number of messages in history")
146
- }).strict().describe("Session metadata with history count")
147
- }).strict()
148
- }
111
+ },
112
+ 400: import_responses.BadRequestErrorResponse,
113
+ 500: import_responses.InternalErrorResponse
114
+ }
115
+ });
116
+ const getRoute = (0, import_zod_openapi.createRoute)({
117
+ method: "get",
118
+ path: "/sessions/{sessionId}",
119
+ summary: "Get Session Details",
120
+ description: "Fetches details for a specific session",
121
+ tags: ["sessions"],
122
+ request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
123
+ responses: {
124
+ 200: {
125
+ description: "Session details with metadata",
126
+ content: {
127
+ "application/json": {
128
+ schema: import_zod_openapi.z.object({
129
+ session: import_responses.SessionMetadataSchema.extend({
130
+ history: import_zod_openapi.z.number().int().nonnegative().describe("Number of messages in history")
131
+ }).strict().describe("Session metadata with history count")
132
+ }).strict()
149
133
  }
150
134
  }
151
- }
152
- });
153
- const forkRoute = (0, import_zod_openapi.createRoute)({
154
- method: "post",
155
- path: "/sessions/{sessionId}/fork",
156
- summary: "Fork Session",
157
- description: "Creates a new child session by cloning the specified parent session history and metadata lineage.",
158
- tags: ["sessions"],
159
- request: {
160
- params: import_zod_openapi.z.object({
161
- sessionId: import_zod_openapi.z.string().describe("Parent session identifier")
162
- })
163
135
  },
164
- responses: {
165
- 201: {
166
- description: "Forked session created successfully",
167
- content: {
168
- "application/json": {
169
- schema: import_zod_openapi.z.object({
170
- session: import_responses.SessionMetadataSchema.describe(
171
- "Newly created child session metadata"
172
- )
173
- }).strict()
174
- }
175
- }
176
- },
177
- 400: {
178
- description: "Invalid fork request (for example, max session limit reached)",
179
- content: {
180
- "application/json": {
181
- schema: import_responses.StandardErrorEnvelopeSchema
182
- }
183
- }
184
- },
185
- 404: {
186
- description: "Parent session not found",
187
- content: {
188
- "application/json": {
189
- schema: import_responses.StandardErrorEnvelopeSchema
190
- }
136
+ 400: import_responses.BadRequestErrorResponse,
137
+ 404: import_responses.NotFoundErrorResponse,
138
+ 500: import_responses.InternalErrorResponse
139
+ }
140
+ });
141
+ const forkRoute = (0, import_zod_openapi.createRoute)({
142
+ method: "post",
143
+ path: "/sessions/{sessionId}/fork",
144
+ summary: "Fork Session",
145
+ description: "Creates a new child session by cloning the specified parent session history and metadata lineage.",
146
+ tags: ["sessions"],
147
+ request: {
148
+ params: import_zod_openapi.z.object({
149
+ sessionId: import_zod_openapi.z.string().describe("Parent session identifier")
150
+ })
151
+ },
152
+ responses: {
153
+ 201: {
154
+ description: "Forked session created successfully",
155
+ content: {
156
+ "application/json": {
157
+ schema: import_zod_openapi.z.object({
158
+ session: import_responses.SessionMetadataSchema.describe(
159
+ "Newly created child session metadata"
160
+ )
161
+ }).strict()
191
162
  }
192
163
  }
193
- }
194
- });
195
- const historyRoute = (0, import_zod_openapi.createRoute)({
196
- method: "get",
197
- path: "/sessions/{sessionId}/history",
198
- summary: "Get Session History",
199
- description: "Retrieves the conversation history for a session along with processing status",
200
- tags: ["sessions"],
201
- request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
202
- responses: {
203
- 200: {
204
- description: "Session conversation history",
205
- content: {
206
- "application/json": {
207
- schema: import_zod_openapi.z.object({
208
- history: import_zod_openapi.z.array(import_responses.InternalMessageSchema).describe("Array of messages in conversation history"),
209
- isBusy: import_zod_openapi.z.boolean().describe(
210
- "Whether the session is currently processing a message"
211
- )
212
- }).strict()
213
- }
164
+ },
165
+ 400: {
166
+ ...import_responses.BadRequestErrorResponse
167
+ },
168
+ 404: {
169
+ ...import_responses.NotFoundErrorResponse
170
+ },
171
+ 500: import_responses.InternalErrorResponse
172
+ }
173
+ });
174
+ const historyRoute = (0, import_zod_openapi.createRoute)({
175
+ method: "get",
176
+ path: "/sessions/{sessionId}/history",
177
+ summary: "Get Session History",
178
+ description: "Retrieves the conversation history for a session along with processing status",
179
+ tags: ["sessions"],
180
+ request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
181
+ responses: {
182
+ 200: {
183
+ description: "Session conversation history",
184
+ content: {
185
+ "application/json": {
186
+ schema: import_zod_openapi.z.object({
187
+ history: import_zod_openapi.z.array(import_responses.InternalMessageSchema).describe("Array of messages in conversation history"),
188
+ isBusy: import_zod_openapi.z.boolean().describe("Whether the session is currently processing a message")
189
+ }).strict()
214
190
  }
215
191
  }
216
- }
217
- });
218
- const listSessionPromptContributorsRoute = (0, import_zod_openapi.createRoute)({
219
- method: "get",
220
- path: "/sessions/{sessionId}/system-prompt/contributors",
221
- summary: "List Session System Prompt Contributors",
222
- description: "Lists static system prompt contributors that apply only to the specified session.",
223
- tags: ["sessions", "config"],
224
- request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
225
- responses: {
226
- 200: {
227
- description: "Current session contributor list",
228
- content: {
229
- "application/json": {
230
- schema: import_zod_openapi.z.object({
231
- contributors: import_zod_openapi.z.array(SessionPromptContributorInfoSchema).describe("Registered session prompt contributors.")
232
- }).strict()
233
- }
192
+ },
193
+ 400: import_responses.BadRequestErrorResponse,
194
+ 404: import_responses.NotFoundErrorResponse,
195
+ 500: import_responses.InternalErrorResponse
196
+ }
197
+ });
198
+ const listSessionPromptContributorsRoute = (0, import_zod_openapi.createRoute)({
199
+ method: "get",
200
+ path: "/sessions/{sessionId}/system-prompt/contributors",
201
+ summary: "List Session System Prompt Contributors",
202
+ description: "Lists static system prompt contributors that apply only to the specified session.",
203
+ tags: ["sessions", "config"],
204
+ request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
205
+ responses: {
206
+ 200: {
207
+ description: "Current session contributor list",
208
+ content: {
209
+ "application/json": {
210
+ schema: import_zod_openapi.z.object({
211
+ contributors: import_zod_openapi.z.array(SessionPromptContributorInfoSchema).describe("Registered session prompt contributors.")
212
+ }).strict()
234
213
  }
235
- },
236
- 404: {
237
- description: "Session not found",
238
- content: {
239
- "application/json": {
240
- schema: import_responses.StandardErrorEnvelopeSchema
241
- }
214
+ }
215
+ },
216
+ 404: {
217
+ ...import_responses.NotFoundErrorResponse
218
+ },
219
+ 500: import_responses.InternalErrorResponse
220
+ }
221
+ });
222
+ const upsertSessionPromptContributorRoute = (0, import_zod_openapi.createRoute)({
223
+ method: "post",
224
+ path: "/sessions/{sessionId}/system-prompt/contributors",
225
+ summary: "Upsert Session System Prompt Contributor",
226
+ description: "Adds or updates a static system prompt contributor that applies only to the specified session. Set enabled=false to remove it.",
227
+ tags: ["sessions", "config"],
228
+ request: {
229
+ params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
230
+ body: {
231
+ required: true,
232
+ content: {
233
+ "application/json": {
234
+ schema: UpsertSessionPromptContributorSchema
242
235
  }
243
236
  }
244
237
  }
245
- });
246
- const upsertSessionPromptContributorRoute = (0, import_zod_openapi.createRoute)({
247
- method: "post",
248
- path: "/sessions/{sessionId}/system-prompt/contributors",
249
- summary: "Upsert Session System Prompt Contributor",
250
- description: "Adds or updates a static system prompt contributor that applies only to the specified session. Set enabled=false to remove it.",
251
- tags: ["sessions", "config"],
252
- request: {
253
- params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
254
- body: {
255
- required: true,
256
- content: {
257
- "application/json": {
258
- schema: UpsertSessionPromptContributorSchema
259
- }
238
+ },
239
+ responses: {
240
+ 200: {
241
+ description: "Session contributor upsert result",
242
+ content: {
243
+ "application/json": {
244
+ schema: import_zod_openapi.z.object({
245
+ id: import_zod_openapi.z.string().describe("Contributor identifier"),
246
+ enabled: import_zod_openapi.z.boolean().describe("Whether the contributor remains enabled"),
247
+ priority: import_zod_openapi.z.number().optional().describe("Contributor priority"),
248
+ replaced: import_zod_openapi.z.boolean().optional().describe("Whether an existing contributor was replaced"),
249
+ removed: import_zod_openapi.z.boolean().optional().describe("Whether the contributor was removed"),
250
+ contentLength: import_zod_openapi.z.number().optional().describe("Stored content length in characters"),
251
+ truncated: import_zod_openapi.z.boolean().optional().describe("Whether the submitted content was truncated")
252
+ }).strict()
260
253
  }
261
254
  }
262
255
  },
263
- responses: {
264
- 200: {
265
- description: "Session contributor upsert result",
266
- content: {
267
- "application/json": {
268
- schema: import_zod_openapi.z.object({
269
- id: import_zod_openapi.z.string().describe("Contributor identifier"),
270
- enabled: import_zod_openapi.z.boolean().describe("Whether the contributor remains enabled"),
271
- priority: import_zod_openapi.z.number().optional().describe("Contributor priority"),
272
- replaced: import_zod_openapi.z.boolean().optional().describe("Whether an existing contributor was replaced"),
273
- removed: import_zod_openapi.z.boolean().optional().describe("Whether the contributor was removed"),
274
- contentLength: import_zod_openapi.z.number().optional().describe("Stored content length in characters"),
275
- truncated: import_zod_openapi.z.boolean().optional().describe("Whether the submitted content was truncated")
276
- }).strict()
277
- }
256
+ 400: {
257
+ ...import_responses.BadRequestErrorResponse
258
+ },
259
+ 404: {
260
+ ...import_responses.NotFoundErrorResponse
261
+ },
262
+ 500: import_responses.InternalErrorResponse
263
+ }
264
+ });
265
+ const deleteRoute = (0, import_zod_openapi.createRoute)({
266
+ method: "delete",
267
+ path: "/sessions/{sessionId}",
268
+ summary: "Delete Session",
269
+ description: "Permanently deletes a session and all its conversation history. This action cannot be undone",
270
+ tags: ["sessions"],
271
+ request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
272
+ responses: {
273
+ 200: {
274
+ description: "Session deleted successfully",
275
+ content: {
276
+ "application/json": {
277
+ schema: import_zod_openapi.z.object({
278
+ status: import_zod_openapi.z.literal("deleted").describe("Deletion status"),
279
+ sessionId: import_zod_openapi.z.string().describe("ID of the deleted session")
280
+ }).strict()
278
281
  }
279
- },
280
- 400: {
281
- description: "Invalid session contributor request",
282
- content: {
283
- "application/json": {
284
- schema: import_responses.StandardErrorEnvelopeSchema
285
- }
282
+ }
283
+ },
284
+ 400: import_responses.BadRequestErrorResponse,
285
+ 404: import_responses.NotFoundErrorResponse,
286
+ 500: import_responses.InternalErrorResponse
287
+ }
288
+ });
289
+ const cancelRoute = (0, import_zod_openapi.createRoute)({
290
+ method: "post",
291
+ path: "/sessions/{sessionId}/cancel",
292
+ summary: "Cancel Session Run",
293
+ description: "Cancels an in-flight agent run for the specified session. By default (soft cancel), only the current LLM call is cancelled and queued messages continue processing. Set clearQueue=true for hard cancel to also clear any queued messages.",
294
+ tags: ["sessions"],
295
+ request: {
296
+ params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
297
+ body: {
298
+ content: {
299
+ "application/json": {
300
+ schema: import_zod_openapi.z.object({
301
+ clearQueue: import_zod_openapi.z.boolean().optional().default(false).describe(
302
+ "If true (hard cancel), clears queued messages. If false (soft cancel, default), queued messages continue processing."
303
+ )
304
+ }).strict()
286
305
  }
287
306
  },
288
- 404: {
289
- description: "Session not found",
290
- content: {
291
- "application/json": {
292
- schema: import_responses.StandardErrorEnvelopeSchema
293
- }
294
- }
295
- }
307
+ required: false
296
308
  }
297
- });
298
- const deleteRoute = (0, import_zod_openapi.createRoute)({
299
- method: "delete",
300
- path: "/sessions/{sessionId}",
301
- summary: "Delete Session",
302
- description: "Permanently deletes a session and all its conversation history. This action cannot be undone",
303
- tags: ["sessions"],
304
- request: { params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }) },
305
- responses: {
306
- 200: {
307
- description: "Session deleted successfully",
308
- content: {
309
- "application/json": {
310
- schema: import_zod_openapi.z.object({
311
- status: import_zod_openapi.z.literal("deleted").describe("Deletion status"),
312
- sessionId: import_zod_openapi.z.string().describe("ID of the deleted session")
313
- }).strict()
314
- }
309
+ },
310
+ responses: {
311
+ 200: {
312
+ description: "Cancel operation result",
313
+ content: {
314
+ "application/json": {
315
+ schema: import_zod_openapi.z.object({
316
+ cancelled: import_zod_openapi.z.boolean().describe("Whether a run was cancelled"),
317
+ sessionId: import_zod_openapi.z.string().describe("Session ID"),
318
+ queueCleared: import_zod_openapi.z.boolean().describe("Whether queued messages were cleared"),
319
+ clearedCount: import_zod_openapi.z.number().describe("Number of queued messages cleared (0 if soft cancel)")
320
+ }).strict()
315
321
  }
316
322
  }
317
- }
318
- });
319
- const cancelRoute = (0, import_zod_openapi.createRoute)({
320
- method: "post",
321
- path: "/sessions/{sessionId}/cancel",
322
- summary: "Cancel Session Run",
323
- description: "Cancels an in-flight agent run for the specified session. By default (soft cancel), only the current LLM call is cancelled and queued messages continue processing. Set clearQueue=true for hard cancel to also clear any queued messages.",
324
- tags: ["sessions"],
325
- request: {
326
- params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
327
- body: {
328
- content: {
329
- "application/json": {
330
- schema: import_zod_openapi.z.object({
331
- clearQueue: import_zod_openapi.z.boolean().optional().default(false).describe(
332
- "If true (hard cancel), clears queued messages. If false (soft cancel, default), queued messages continue processing."
333
- )
334
- }).strict()
335
- }
336
- },
337
- required: false
338
- }
339
323
  },
340
- responses: {
341
- 200: {
342
- description: "Cancel operation result",
343
- content: {
344
- "application/json": {
345
- schema: import_zod_openapi.z.object({
346
- cancelled: import_zod_openapi.z.boolean().describe("Whether a run was cancelled"),
347
- sessionId: import_zod_openapi.z.string().describe("Session ID"),
348
- queueCleared: import_zod_openapi.z.boolean().describe("Whether queued messages were cleared"),
349
- clearedCount: import_zod_openapi.z.number().describe(
350
- "Number of queued messages cleared (0 if soft cancel)"
324
+ 400: import_responses.BadRequestErrorResponse,
325
+ 404: import_responses.NotFoundErrorResponse,
326
+ 409: import_responses.ConflictErrorResponse,
327
+ 500: import_responses.InternalErrorResponse
328
+ }
329
+ });
330
+ const loadRoute = (0, import_zod_openapi.createRoute)({
331
+ method: "get",
332
+ path: "/sessions/{sessionId}/load",
333
+ summary: "Load Session",
334
+ description: "Validates and retrieves session information including processing status. The client should track the active session.",
335
+ tags: ["sessions"],
336
+ request: {
337
+ params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
338
+ },
339
+ responses: {
340
+ 200: {
341
+ description: "Session information retrieved successfully",
342
+ content: {
343
+ "application/json": {
344
+ schema: import_zod_openapi.z.object({
345
+ session: import_responses.SessionMetadataSchema.extend({
346
+ isBusy: import_zod_openapi.z.boolean().describe(
347
+ "Whether the session is currently processing a message"
348
+ ),
349
+ usageSummary: import_responses.UsageSummarySchema.describe(
350
+ "Exact usage summary derived from assistant message history"
351
+ ),
352
+ activeUsageScopeId: import_zod_openapi.z.string().nullable().describe(
353
+ "Current runtime usage scope identifier, if configured"
354
+ ),
355
+ activeUsageScope: import_responses.ScopedUsageSummarySchema.nullable().describe(
356
+ "Usage summary for the current runtime scope, if configured"
351
357
  )
352
- }).strict()
353
- }
358
+ }).describe("Session metadata with processing status")
359
+ }).strict()
354
360
  }
355
361
  }
356
- }
357
- });
358
- const loadRoute = (0, import_zod_openapi.createRoute)({
359
- method: "get",
360
- path: "/sessions/{sessionId}/load",
361
- summary: "Load Session",
362
- description: "Validates and retrieves session information including processing status. The client should track the active session.",
363
- tags: ["sessions"],
364
- request: {
365
- params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
366
362
  },
367
- responses: {
368
- 200: {
369
- description: "Session information retrieved successfully",
370
- content: {
371
- "application/json": {
372
- schema: import_zod_openapi.z.object({
373
- session: import_responses.SessionMetadataSchema.extend({
374
- isBusy: import_zod_openapi.z.boolean().describe(
375
- "Whether the session is currently processing a message"
376
- ),
377
- usageSummary: import_responses.UsageSummarySchema.describe(
378
- "Exact usage summary derived from assistant message history"
379
- ),
380
- activeUsageScopeId: import_zod_openapi.z.string().nullable().describe(
381
- "Current runtime usage scope identifier, if configured"
382
- ),
383
- activeUsageScope: import_responses.ScopedUsageSummarySchema.nullable().describe(
384
- "Usage summary for the current runtime scope, if configured"
385
- )
386
- }).describe("Session metadata with processing status")
387
- }).strict()
388
- }
389
- }
390
- },
391
- 404: {
392
- description: "Session not found",
393
- content: {
394
- "application/json": {
395
- schema: import_zod_openapi.z.object({
396
- error: import_zod_openapi.z.string().describe("Error message")
397
- }).strict()
398
- }
363
+ 404: {
364
+ ...import_responses.NotFoundErrorResponse
365
+ },
366
+ 400: import_responses.BadRequestErrorResponse,
367
+ 500: import_responses.InternalErrorResponse
368
+ }
369
+ });
370
+ const clearContextRoute = (0, import_zod_openapi.createRoute)({
371
+ method: "post",
372
+ path: "/sessions/{sessionId}/clear-context",
373
+ summary: "Clear Session Context",
374
+ description: "Clears the model context window for a session while preserving conversation history for review.",
375
+ tags: ["sessions"],
376
+ request: {
377
+ params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
378
+ },
379
+ responses: {
380
+ 200: {
381
+ description: "Session context cleared successfully",
382
+ content: {
383
+ "application/json": {
384
+ schema: import_zod_openapi.z.object({
385
+ status: import_zod_openapi.z.literal("context cleared").describe("Context clear status"),
386
+ sessionId: import_zod_openapi.z.string().describe("Session ID")
387
+ }).strict()
399
388
  }
400
389
  }
401
- }
402
- });
403
- const clearContextRoute = (0, import_zod_openapi.createRoute)({
404
- method: "post",
405
- path: "/sessions/{sessionId}/clear-context",
406
- summary: "Clear Session Context",
407
- description: "Clears the model context window for a session while preserving conversation history for review.",
408
- tags: ["sessions"],
409
- request: {
410
- params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
411
390
  },
412
- responses: {
413
- 200: {
414
- description: "Session context cleared successfully",
415
- content: {
416
- "application/json": {
417
- schema: import_zod_openapi.z.object({
418
- status: import_zod_openapi.z.literal("context cleared").describe("Context clear status"),
419
- sessionId: import_zod_openapi.z.string().describe("Session ID")
420
- }).strict()
421
- }
391
+ 400: import_responses.BadRequestErrorResponse,
392
+ 404: import_responses.NotFoundErrorResponse,
393
+ 500: import_responses.InternalErrorResponse
394
+ }
395
+ });
396
+ const patchRoute = (0, import_zod_openapi.createRoute)({
397
+ method: "patch",
398
+ path: "/sessions/{sessionId}",
399
+ summary: "Update Session Title",
400
+ description: "Updates the title of an existing session",
401
+ tags: ["sessions"],
402
+ request: {
403
+ params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
404
+ body: {
405
+ content: {
406
+ "application/json": {
407
+ schema: import_zod_openapi.z.object({
408
+ title: import_zod_openapi.z.string().min(1, "Title is required").max(120, "Title too long").describe("New title for the session (maximum 120 characters)")
409
+ })
422
410
  }
423
411
  }
424
412
  }
425
- });
426
- const patchRoute = (0, import_zod_openapi.createRoute)({
427
- method: "patch",
428
- path: "/sessions/{sessionId}",
429
- summary: "Update Session Title",
430
- description: "Updates the title of an existing session",
431
- tags: ["sessions"],
432
- request: {
433
- params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
434
- body: {
435
- content: {
436
- "application/json": {
437
- schema: import_zod_openapi.z.object({
438
- title: import_zod_openapi.z.string().min(1, "Title is required").max(120, "Title too long").describe("New title for the session (maximum 120 characters)")
439
- })
440
- }
413
+ },
414
+ responses: {
415
+ 200: {
416
+ description: "Session updated successfully",
417
+ content: {
418
+ "application/json": {
419
+ schema: import_zod_openapi.z.object({
420
+ session: import_responses.SessionMetadataSchema.describe("Updated session metadata")
421
+ }).strict()
441
422
  }
442
423
  }
443
424
  },
444
- responses: {
445
- 200: {
446
- description: "Session updated successfully",
447
- content: {
448
- "application/json": {
449
- schema: import_zod_openapi.z.object({
450
- session: import_responses.SessionMetadataSchema.describe("Updated session metadata")
451
- }).strict()
452
- }
425
+ 400: import_responses.BadRequestErrorResponse,
426
+ 404: import_responses.NotFoundErrorResponse,
427
+ 500: import_responses.InternalErrorResponse
428
+ }
429
+ });
430
+ const generateTitleRoute = (0, import_zod_openapi.createRoute)({
431
+ method: "post",
432
+ path: "/sessions/{sessionId}/generate-title",
433
+ summary: "Generate Session Title",
434
+ description: "Generates a descriptive title for the session using the first user message. Returns existing title if already set.",
435
+ tags: ["sessions"],
436
+ request: {
437
+ params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
438
+ },
439
+ responses: {
440
+ 200: {
441
+ description: "Title generated successfully",
442
+ content: {
443
+ "application/json": {
444
+ schema: import_zod_openapi.z.object({
445
+ title: import_zod_openapi.z.string().nullable().describe("Generated title, or null if generation failed"),
446
+ sessionId: import_zod_openapi.z.string().describe("Session ID")
447
+ }).strict()
453
448
  }
454
449
  }
455
- }
456
- });
457
- const generateTitleRoute = (0, import_zod_openapi.createRoute)({
458
- method: "post",
459
- path: "/sessions/{sessionId}/generate-title",
460
- summary: "Generate Session Title",
461
- description: "Generates a descriptive title for the session using the first user message. Returns existing title if already set.",
462
- tags: ["sessions"],
463
- request: {
464
- params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
465
450
  },
466
- responses: {
467
- 200: {
468
- description: "Title generated successfully",
469
- content: {
470
- "application/json": {
471
- schema: import_zod_openapi.z.object({
472
- title: import_zod_openapi.z.string().nullable().describe("Generated title, or null if generation failed"),
473
- sessionId: import_zod_openapi.z.string().describe("Session ID")
474
- }).strict()
475
- }
476
- }
477
- },
478
- 404: {
479
- description: "Session not found",
480
- content: {
481
- "application/json": {
482
- schema: import_responses.StandardErrorEnvelopeSchema
483
- }
484
- }
451
+ 404: {
452
+ ...import_responses.NotFoundErrorResponse
453
+ },
454
+ 400: import_responses.BadRequestErrorResponse,
455
+ 500: import_responses.InternalErrorResponse
456
+ }
457
+ });
458
+ function createSessionsRouter(getAgent) {
459
+ const app = new import_zod_openapi.OpenAPIHono({
460
+ defaultHook: (result, ctx) => {
461
+ if (!result.success) {
462
+ const issues = (0, import_core.zodToIssues)(result.error);
463
+ return (0, import_error.handleHonoError)(
464
+ ctx,
465
+ new import_core.DextoRuntimeError(
466
+ "validation_failed",
467
+ "validation",
468
+ import_core.ErrorType.USER,
469
+ issues[0]?.message ?? "Validation failed",
470
+ { issues }
471
+ )
472
+ );
485
473
  }
486
474
  }
487
475
  });
476
+ app.onError((err, ctx) => (0, import_error.handleHonoError)(ctx, err));
488
477
  return app.openapi(listRoute, async (ctx) => {
489
478
  const agent = await getAgent(ctx);
490
479
  const sessionIds = await agent.listSessions();
@@ -498,7 +487,7 @@ function createSessionsRouter(getAgent) {
498
487
  }
499
488
  })
500
489
  );
501
- return ctx.json({ sessions });
490
+ return ctx.json({ sessions }, 200);
502
491
  }).openapi(createRouteDef, async (ctx) => {
503
492
  const agent = await getAgent(ctx);
504
493
  const { sessionId } = ctx.req.valid("json");
@@ -529,12 +518,15 @@ function createSessionsRouter(getAgent) {
529
518
  const { sessionId } = ctx.req.param();
530
519
  const metadata = await agent.getSessionMetadata(sessionId);
531
520
  const history = await agent.getSessionHistory(sessionId);
532
- return ctx.json({
533
- session: {
534
- ...mapSessionMetadata(sessionId, metadata),
535
- history: history.length
536
- }
537
- });
521
+ return ctx.json(
522
+ {
523
+ session: {
524
+ ...mapSessionMetadata(sessionId, metadata),
525
+ history: history.length
526
+ }
527
+ },
528
+ 200
529
+ );
538
530
  }).openapi(historyRoute, async (ctx) => {
539
531
  const agent = await getAgent(ctx);
540
532
  const { sessionId } = ctx.req.param();
@@ -542,10 +534,13 @@ function createSessionsRouter(getAgent) {
542
534
  agent.getSessionHistory(sessionId),
543
535
  agent.isSessionBusy(sessionId)
544
536
  ]);
545
- return ctx.json({
546
- history,
547
- isBusy
548
- });
537
+ return ctx.json(
538
+ {
539
+ history,
540
+ isBusy
541
+ },
542
+ 200
543
+ );
549
544
  }).openapi(listSessionPromptContributorsRoute, async (ctx) => {
550
545
  const agent = await getAgent(ctx);
551
546
  const { sessionId } = ctx.req.valid("param");
@@ -625,7 +620,7 @@ function createSessionsRouter(getAgent) {
625
620
  const agent = await getAgent(ctx);
626
621
  const { sessionId } = ctx.req.param();
627
622
  await agent.deleteSession(sessionId);
628
- return ctx.json({ status: "deleted", sessionId });
623
+ return ctx.json({ status: "deleted", sessionId }, 200);
629
624
  }).openapi(cancelRoute, async (ctx) => {
630
625
  const agent = await getAgent(ctx);
631
626
  const { sessionId } = ctx.req.valid("param");
@@ -649,18 +644,27 @@ function createSessionsRouter(getAgent) {
649
644
  if (!cancelled) {
650
645
  agent.logger.debug(`No in-flight run to cancel for session: ${sessionId}`);
651
646
  }
652
- return ctx.json({
653
- cancelled,
654
- sessionId,
655
- queueCleared: clearQueue,
656
- clearedCount
657
- });
647
+ return ctx.json(
648
+ {
649
+ cancelled,
650
+ sessionId,
651
+ queueCleared: clearQueue,
652
+ clearedCount
653
+ },
654
+ 200
655
+ );
658
656
  }).openapi(loadRoute, async (ctx) => {
659
657
  const agent = await getAgent(ctx);
660
658
  const { sessionId } = ctx.req.valid("param");
661
659
  const sessionIds = await agent.listSessions();
662
660
  if (!sessionIds.includes(sessionId)) {
663
- return ctx.json({ error: `Session not found: ${sessionId}` }, 404);
661
+ throw new import_core.DextoRuntimeError(
662
+ "session_not_found",
663
+ import_core.ErrorScope.SESSION,
664
+ import_core.ErrorType.NOT_FOUND,
665
+ `Session not found: ${sessionId}`,
666
+ { sessionId }
667
+ );
664
668
  }
665
669
  const metadata = await agent.getSessionMetadata(sessionId);
666
670
  const isBusy = await agent.isSessionBusy(sessionId);
@@ -686,16 +690,19 @@ function createSessionsRouter(getAgent) {
686
690
  const agent = await getAgent(ctx);
687
691
  const { sessionId } = ctx.req.valid("param");
688
692
  await agent.clearContext(sessionId);
689
- return ctx.json({ status: "context cleared", sessionId });
693
+ return ctx.json({ status: "context cleared", sessionId }, 200);
690
694
  }).openapi(patchRoute, async (ctx) => {
691
695
  const agent = await getAgent(ctx);
692
696
  const { sessionId } = ctx.req.valid("param");
693
697
  const { title } = ctx.req.valid("json");
694
698
  await agent.setSessionTitle(sessionId, title);
695
699
  const metadata = await agent.getSessionMetadata(sessionId);
696
- return ctx.json({
697
- session: mapSessionMetadata(sessionId, metadata, { title })
698
- });
700
+ return ctx.json(
701
+ {
702
+ session: mapSessionMetadata(sessionId, metadata, { title })
703
+ },
704
+ 200
705
+ );
699
706
  }).openapi(generateTitleRoute, async (ctx) => {
700
707
  const agent = await getAgent(ctx);
701
708
  const { sessionId } = ctx.req.valid("param");