@dexto/server 1.6.20 → 1.6.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/a2a/jsonrpc/methods.cjs +1 -1
- package/dist/a2a/jsonrpc/methods.d.ts +14 -4
- package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
- package/dist/a2a/jsonrpc/methods.js +1 -1
- package/dist/approval/wire-approval-events.cjs +44 -0
- package/dist/approval/wire-approval-events.d.ts +4 -0
- package/dist/approval/wire-approval-events.d.ts.map +1 -0
- package/dist/approval/wire-approval-events.js +20 -0
- package/dist/events/session-sse-subscriber.cjs +167 -0
- package/dist/events/session-sse-subscriber.d.ts +13 -0
- package/dist/events/session-sse-subscriber.d.ts.map +1 -0
- package/dist/events/session-sse-subscriber.js +143 -0
- package/dist/hono/__tests__/test-fixtures.cjs +8 -0
- package/dist/hono/__tests__/test-fixtures.d.ts +1 -0
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +8 -0
- package/dist/hono/index.cjs +40 -8
- package/dist/hono/index.d.ts +45 -4531
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +43 -9
- package/dist/hono/node/index.cjs +51 -6
- package/dist/hono/node/index.d.ts.map +1 -1
- package/dist/hono/node/index.js +51 -6
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +158 -32
- package/dist/hono/routes/a2a-tasks.d.ts +1 -502
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +162 -32
- package/dist/hono/routes/a2a.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +410 -329
- package/dist/hono/routes/agents.d.ts +16043 -68
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +418 -330
- package/dist/hono/routes/approvals.cjs +102 -88
- package/dist/hono/routes/approvals.d.ts +2089 -142
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +108 -89
- package/dist/hono/routes/dexto-auth.cjs +40 -33
- package/dist/hono/routes/dexto-auth.d.ts +401 -2
- package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
- package/dist/hono/routes/dexto-auth.js +40 -33
- package/dist/hono/routes/discovery.cjs +16 -14
- package/dist/hono/routes/discovery.d.ts +586 -1
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +16 -14
- package/dist/hono/routes/greeting.cjs +26 -22
- package/dist/hono/routes/greeting.d.ts +787 -3
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +26 -22
- package/dist/hono/routes/health.d.ts +1 -1
- package/dist/hono/routes/key.cjs +60 -52
- package/dist/hono/routes/key.d.ts +1597 -1
- package/dist/hono/routes/key.d.ts.map +1 -1
- package/dist/hono/routes/key.js +60 -52
- package/dist/hono/routes/llm.cjs +382 -349
- package/dist/hono/routes/llm.d.ts +12148 -98
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +386 -349
- package/dist/hono/routes/mcp.cjs +257 -226
- package/dist/hono/routes/mcp.d.ts +6605 -309
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +263 -225
- package/dist/hono/routes/memory.cjs +102 -89
- package/dist/hono/routes/memory.d.ts +5368 -4
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +108 -90
- package/dist/hono/routes/messages.cjs +189 -191
- package/dist/hono/routes/messages.d.ts +3900 -12
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +192 -191
- package/dist/hono/routes/models.cjs +106 -64
- package/dist/hono/routes/models.d.ts +2875 -2
- package/dist/hono/routes/models.d.ts.map +1 -1
- package/dist/hono/routes/models.js +108 -64
- package/dist/hono/routes/openrouter.cjs +79 -65
- package/dist/hono/routes/openrouter.d.ts +854 -1
- package/dist/hono/routes/openrouter.d.ts.map +1 -1
- package/dist/hono/routes/openrouter.js +79 -65
- package/dist/hono/routes/prompts.cjs +136 -109
- package/dist/hono/routes/prompts.d.ts +2818 -10
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +138 -109
- package/dist/hono/routes/queue.cjs +133 -120
- package/dist/hono/routes/queue.d.ts +5240 -11
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +136 -120
- package/dist/hono/routes/resources.cjs +65 -46
- package/dist/hono/routes/resources.d.ts +1983 -5
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +72 -47
- package/dist/hono/routes/schedules.cjs +233 -226
- package/dist/hono/routes/schedules.d.ts +4198 -22
- package/dist/hono/routes/schedules.d.ts.map +1 -1
- package/dist/hono/routes/schedules.js +233 -226
- package/dist/hono/routes/search.cjs +34 -30
- package/dist/hono/routes/search.d.ts +3094 -17
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +40 -31
- package/dist/hono/routes/sessions.cjs +491 -393
- package/dist/hono/routes/sessions.d.ts +18263 -65
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +497 -395
- package/dist/hono/routes/static.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.cjs +57 -61
- package/dist/hono/routes/system-prompt.d.ts +1228 -2
- package/dist/hono/routes/system-prompt.d.ts.map +1 -1
- package/dist/hono/routes/system-prompt.js +58 -62
- package/dist/hono/routes/tools.cjs +29 -34
- package/dist/hono/routes/tools.d.ts +1755 -6
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +33 -33
- package/dist/hono/routes/webhooks.cjs +115 -123
- package/dist/hono/routes/webhooks.d.ts +2501 -11
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +120 -124
- package/dist/hono/routes/workspaces.cjs +84 -79
- package/dist/hono/routes/workspaces.d.ts +2093 -2
- package/dist/hono/routes/workspaces.d.ts.map +1 -1
- package/dist/hono/routes/workspaces.js +89 -80
- package/dist/hono/schemas/responses.cjs +463 -260
- package/dist/hono/schemas/responses.d.ts +1893 -209
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +203 -14
- package/dist/hono/start-server.cjs +9 -0
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +9 -0
- package/dist/hono/types.d.ts +11 -0
- package/dist/hono/types.d.ts.map +1 -1
- package/dist/index.cjs +5 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/package.json +7 -7
|
@@ -68,423 +68,456 @@ function mapSessionMetadata(sessionId, metadata, defaults) {
|
|
|
68
68
|
parentSessionId: metadata?.parentSessionId ?? defaults?.parentSessionId ?? null
|
|
69
69
|
};
|
|
70
70
|
}
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
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
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
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
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
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
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
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
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
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
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
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
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
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
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
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
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
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
|
-
|
|
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
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
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
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
323
|
+
},
|
|
324
|
+
400: import_responses.BadRequestErrorResponse,
|
|
325
|
+
404: import_responses.NotFoundErrorResponse,
|
|
326
|
+
409: import_responses.ConflictErrorResponse,
|
|
327
|
+
500: import_responses.InternalErrorResponse
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
const eventsRoute = (0, import_zod_openapi.createRoute)({
|
|
331
|
+
method: "get",
|
|
332
|
+
path: "/sessions/{sessionId}/events",
|
|
333
|
+
summary: "Attach Session Event Stream",
|
|
334
|
+
description: "Attaches to the live SSE event stream for an already-running session without starting a new run. Use this to reattach after a page reload or connection interruption.",
|
|
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: "SSE stream of live session events",
|
|
342
|
+
headers: {
|
|
343
|
+
"Content-Type": {
|
|
344
|
+
description: "SSE content type",
|
|
345
|
+
schema: { type: "string", example: "text/event-stream" }
|
|
346
|
+
},
|
|
347
|
+
"Cache-Control": {
|
|
348
|
+
description: "Disable caching for stream",
|
|
349
|
+
schema: { type: "string", example: "no-cache" }
|
|
350
|
+
},
|
|
351
|
+
Connection: {
|
|
352
|
+
description: "Keep connection alive for streaming",
|
|
353
|
+
schema: { type: "string", example: "keep-alive" }
|
|
336
354
|
},
|
|
337
|
-
|
|
355
|
+
"X-Accel-Buffering": {
|
|
356
|
+
description: "Disable nginx buffering",
|
|
357
|
+
schema: { type: "string", example: "no" }
|
|
358
|
+
}
|
|
359
|
+
},
|
|
360
|
+
content: {
|
|
361
|
+
"text/event-stream": {
|
|
362
|
+
schema: import_zod_openapi.z.string().describe(
|
|
363
|
+
"Server-Sent Events stream for an active session. Events use the same payloads as /message-stream."
|
|
364
|
+
)
|
|
365
|
+
}
|
|
338
366
|
}
|
|
339
367
|
},
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
368
|
+
400: import_responses.BadRequestErrorResponse,
|
|
369
|
+
404: import_responses.NotFoundErrorResponse,
|
|
370
|
+
409: import_responses.ConflictErrorResponse,
|
|
371
|
+
500: import_responses.InternalErrorResponse
|
|
372
|
+
}
|
|
373
|
+
});
|
|
374
|
+
const loadRoute = (0, import_zod_openapi.createRoute)({
|
|
375
|
+
method: "get",
|
|
376
|
+
path: "/sessions/{sessionId}/load",
|
|
377
|
+
summary: "Load Session",
|
|
378
|
+
description: "Validates and retrieves session information including processing status. The client should track the active session.",
|
|
379
|
+
tags: ["sessions"],
|
|
380
|
+
request: {
|
|
381
|
+
params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
|
|
382
|
+
},
|
|
383
|
+
responses: {
|
|
384
|
+
200: {
|
|
385
|
+
description: "Session information retrieved successfully",
|
|
386
|
+
content: {
|
|
387
|
+
"application/json": {
|
|
388
|
+
schema: import_zod_openapi.z.object({
|
|
389
|
+
session: import_responses.SessionMetadataSchema.extend({
|
|
390
|
+
isBusy: import_zod_openapi.z.boolean().describe(
|
|
391
|
+
"Whether the session is currently processing a message"
|
|
392
|
+
),
|
|
393
|
+
usageSummary: import_responses.UsageSummarySchema.describe(
|
|
394
|
+
"Exact usage summary derived from assistant message history"
|
|
395
|
+
),
|
|
396
|
+
activeUsageScopeId: import_zod_openapi.z.string().nullable().describe(
|
|
397
|
+
"Current runtime usage scope identifier, if configured"
|
|
398
|
+
),
|
|
399
|
+
activeUsageScope: import_responses.ScopedUsageSummarySchema.nullable().describe(
|
|
400
|
+
"Usage summary for the current runtime scope, if configured"
|
|
351
401
|
)
|
|
352
|
-
}).
|
|
353
|
-
}
|
|
402
|
+
}).describe("Session metadata with processing status")
|
|
403
|
+
}).strict()
|
|
354
404
|
}
|
|
355
405
|
}
|
|
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
406
|
},
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
}
|
|
407
|
+
404: {
|
|
408
|
+
...import_responses.NotFoundErrorResponse
|
|
409
|
+
},
|
|
410
|
+
400: import_responses.BadRequestErrorResponse,
|
|
411
|
+
500: import_responses.InternalErrorResponse
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
const clearContextRoute = (0, import_zod_openapi.createRoute)({
|
|
415
|
+
method: "post",
|
|
416
|
+
path: "/sessions/{sessionId}/clear-context",
|
|
417
|
+
summary: "Clear Session Context",
|
|
418
|
+
description: "Clears the model context window for a session while preserving conversation history for review.",
|
|
419
|
+
tags: ["sessions"],
|
|
420
|
+
request: {
|
|
421
|
+
params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
|
|
422
|
+
},
|
|
423
|
+
responses: {
|
|
424
|
+
200: {
|
|
425
|
+
description: "Session context cleared successfully",
|
|
426
|
+
content: {
|
|
427
|
+
"application/json": {
|
|
428
|
+
schema: import_zod_openapi.z.object({
|
|
429
|
+
status: import_zod_openapi.z.literal("context cleared").describe("Context clear status"),
|
|
430
|
+
sessionId: import_zod_openapi.z.string().describe("Session ID")
|
|
431
|
+
}).strict()
|
|
399
432
|
}
|
|
400
433
|
}
|
|
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
434
|
},
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
435
|
+
400: import_responses.BadRequestErrorResponse,
|
|
436
|
+
404: import_responses.NotFoundErrorResponse,
|
|
437
|
+
500: import_responses.InternalErrorResponse
|
|
438
|
+
}
|
|
439
|
+
});
|
|
440
|
+
const patchRoute = (0, import_zod_openapi.createRoute)({
|
|
441
|
+
method: "patch",
|
|
442
|
+
path: "/sessions/{sessionId}",
|
|
443
|
+
summary: "Update Session Title",
|
|
444
|
+
description: "Updates the title of an existing session",
|
|
445
|
+
tags: ["sessions"],
|
|
446
|
+
request: {
|
|
447
|
+
params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") }),
|
|
448
|
+
body: {
|
|
449
|
+
content: {
|
|
450
|
+
"application/json": {
|
|
451
|
+
schema: import_zod_openapi.z.object({
|
|
452
|
+
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)")
|
|
453
|
+
})
|
|
422
454
|
}
|
|
423
455
|
}
|
|
424
456
|
}
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
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
|
-
}
|
|
457
|
+
},
|
|
458
|
+
responses: {
|
|
459
|
+
200: {
|
|
460
|
+
description: "Session updated successfully",
|
|
461
|
+
content: {
|
|
462
|
+
"application/json": {
|
|
463
|
+
schema: import_zod_openapi.z.object({
|
|
464
|
+
session: import_responses.SessionMetadataSchema.describe("Updated session metadata")
|
|
465
|
+
}).strict()
|
|
441
466
|
}
|
|
442
467
|
}
|
|
443
468
|
},
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
469
|
+
400: import_responses.BadRequestErrorResponse,
|
|
470
|
+
404: import_responses.NotFoundErrorResponse,
|
|
471
|
+
500: import_responses.InternalErrorResponse
|
|
472
|
+
}
|
|
473
|
+
});
|
|
474
|
+
const generateTitleRoute = (0, import_zod_openapi.createRoute)({
|
|
475
|
+
method: "post",
|
|
476
|
+
path: "/sessions/{sessionId}/generate-title",
|
|
477
|
+
summary: "Generate Session Title",
|
|
478
|
+
description: "Generates a descriptive title for the session using the first user message. Returns existing title if already set.",
|
|
479
|
+
tags: ["sessions"],
|
|
480
|
+
request: {
|
|
481
|
+
params: import_zod_openapi.z.object({ sessionId: import_zod_openapi.z.string().describe("Session identifier") })
|
|
482
|
+
},
|
|
483
|
+
responses: {
|
|
484
|
+
200: {
|
|
485
|
+
description: "Title generated successfully",
|
|
486
|
+
content: {
|
|
487
|
+
"application/json": {
|
|
488
|
+
schema: import_zod_openapi.z.object({
|
|
489
|
+
title: import_zod_openapi.z.string().nullable().describe("Generated title, or null if generation failed"),
|
|
490
|
+
sessionId: import_zod_openapi.z.string().describe("Session ID")
|
|
491
|
+
}).strict()
|
|
453
492
|
}
|
|
454
493
|
}
|
|
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
494
|
},
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
495
|
+
404: {
|
|
496
|
+
...import_responses.NotFoundErrorResponse
|
|
497
|
+
},
|
|
498
|
+
400: import_responses.BadRequestErrorResponse,
|
|
499
|
+
500: import_responses.InternalErrorResponse
|
|
500
|
+
}
|
|
501
|
+
});
|
|
502
|
+
function createSessionsRouter(getAgent, sessionSseSubscriber) {
|
|
503
|
+
const app = new import_zod_openapi.OpenAPIHono({
|
|
504
|
+
defaultHook: (result, ctx) => {
|
|
505
|
+
if (!result.success) {
|
|
506
|
+
const issues = (0, import_core.zodToIssues)(result.error);
|
|
507
|
+
return (0, import_error.handleHonoError)(
|
|
508
|
+
ctx,
|
|
509
|
+
new import_core.DextoRuntimeError(
|
|
510
|
+
"validation_failed",
|
|
511
|
+
"validation",
|
|
512
|
+
import_core.ErrorType.USER,
|
|
513
|
+
issues[0]?.message ?? "Validation failed",
|
|
514
|
+
{ issues }
|
|
515
|
+
)
|
|
516
|
+
);
|
|
485
517
|
}
|
|
486
518
|
}
|
|
487
519
|
});
|
|
520
|
+
app.onError((err, ctx) => (0, import_error.handleHonoError)(ctx, err));
|
|
488
521
|
return app.openapi(listRoute, async (ctx) => {
|
|
489
522
|
const agent = await getAgent(ctx);
|
|
490
523
|
const sessionIds = await agent.listSessions();
|
|
@@ -498,7 +531,7 @@ function createSessionsRouter(getAgent) {
|
|
|
498
531
|
}
|
|
499
532
|
})
|
|
500
533
|
);
|
|
501
|
-
return ctx.json({ sessions });
|
|
534
|
+
return ctx.json({ sessions }, 200);
|
|
502
535
|
}).openapi(createRouteDef, async (ctx) => {
|
|
503
536
|
const agent = await getAgent(ctx);
|
|
504
537
|
const { sessionId } = ctx.req.valid("json");
|
|
@@ -529,12 +562,15 @@ function createSessionsRouter(getAgent) {
|
|
|
529
562
|
const { sessionId } = ctx.req.param();
|
|
530
563
|
const metadata = await agent.getSessionMetadata(sessionId);
|
|
531
564
|
const history = await agent.getSessionHistory(sessionId);
|
|
532
|
-
return ctx.json(
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
565
|
+
return ctx.json(
|
|
566
|
+
{
|
|
567
|
+
session: {
|
|
568
|
+
...mapSessionMetadata(sessionId, metadata),
|
|
569
|
+
history: history.length
|
|
570
|
+
}
|
|
571
|
+
},
|
|
572
|
+
200
|
|
573
|
+
);
|
|
538
574
|
}).openapi(historyRoute, async (ctx) => {
|
|
539
575
|
const agent = await getAgent(ctx);
|
|
540
576
|
const { sessionId } = ctx.req.param();
|
|
@@ -542,10 +578,26 @@ function createSessionsRouter(getAgent) {
|
|
|
542
578
|
agent.getSessionHistory(sessionId),
|
|
543
579
|
agent.isSessionBusy(sessionId)
|
|
544
580
|
]);
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
581
|
+
const apiHistory = history.map((message) => (0, import_responses.toApiInternalMessage)(message));
|
|
582
|
+
for (const [index, message] of apiHistory.entries()) {
|
|
583
|
+
const parsed = import_responses.InternalMessageSchema.safeParse(message);
|
|
584
|
+
if (!parsed.success) {
|
|
585
|
+
throw new import_core.DextoRuntimeError(
|
|
586
|
+
"session_history_serialization_failed",
|
|
587
|
+
import_core.ErrorScope.SESSION,
|
|
588
|
+
import_core.ErrorType.SYSTEM,
|
|
589
|
+
"Failed to serialize session history",
|
|
590
|
+
{ sessionId, index, issues: (0, import_core.zodToIssues)(parsed.error) }
|
|
591
|
+
);
|
|
592
|
+
}
|
|
593
|
+
}
|
|
594
|
+
return ctx.json(
|
|
595
|
+
{
|
|
596
|
+
history: apiHistory,
|
|
597
|
+
isBusy
|
|
598
|
+
},
|
|
599
|
+
200
|
|
600
|
+
);
|
|
549
601
|
}).openapi(listSessionPromptContributorsRoute, async (ctx) => {
|
|
550
602
|
const agent = await getAgent(ctx);
|
|
551
603
|
const { sessionId } = ctx.req.valid("param");
|
|
@@ -625,7 +677,7 @@ function createSessionsRouter(getAgent) {
|
|
|
625
677
|
const agent = await getAgent(ctx);
|
|
626
678
|
const { sessionId } = ctx.req.param();
|
|
627
679
|
await agent.deleteSession(sessionId);
|
|
628
|
-
return ctx.json({ status: "deleted", sessionId });
|
|
680
|
+
return ctx.json({ status: "deleted", sessionId }, 200);
|
|
629
681
|
}).openapi(cancelRoute, async (ctx) => {
|
|
630
682
|
const agent = await getAgent(ctx);
|
|
631
683
|
const { sessionId } = ctx.req.valid("param");
|
|
@@ -649,18 +701,61 @@ function createSessionsRouter(getAgent) {
|
|
|
649
701
|
if (!cancelled) {
|
|
650
702
|
agent.logger.debug(`No in-flight run to cancel for session: ${sessionId}`);
|
|
651
703
|
}
|
|
652
|
-
return ctx.json(
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
704
|
+
return ctx.json(
|
|
705
|
+
{
|
|
706
|
+
cancelled,
|
|
707
|
+
sessionId,
|
|
708
|
+
queueCleared: clearQueue,
|
|
709
|
+
clearedCount
|
|
710
|
+
},
|
|
711
|
+
200
|
|
712
|
+
);
|
|
713
|
+
}).openapi(eventsRoute, async (ctx) => {
|
|
714
|
+
const agent = await getAgent(ctx);
|
|
715
|
+
const { sessionId } = ctx.req.valid("param");
|
|
716
|
+
const sessionIds = await agent.listSessions();
|
|
717
|
+
if (!sessionIds.includes(sessionId)) {
|
|
718
|
+
throw new import_core.DextoRuntimeError(
|
|
719
|
+
"session_not_found",
|
|
720
|
+
import_core.ErrorScope.SESSION,
|
|
721
|
+
import_core.ErrorType.NOT_FOUND,
|
|
722
|
+
`Session not found: ${sessionId}`,
|
|
723
|
+
{ sessionId }
|
|
724
|
+
);
|
|
725
|
+
}
|
|
726
|
+
const isBusy = await agent.isSessionBusy(sessionId);
|
|
727
|
+
if (!isBusy) {
|
|
728
|
+
throw new import_core.DextoRuntimeError(
|
|
729
|
+
"session_not_busy",
|
|
730
|
+
import_core.ErrorScope.SESSION,
|
|
731
|
+
import_core.ErrorType.CONFLICT,
|
|
732
|
+
`Session is not running: ${sessionId}`,
|
|
733
|
+
{ sessionId }
|
|
734
|
+
);
|
|
735
|
+
}
|
|
736
|
+
const eventStream = sessionSseSubscriber.createStream(
|
|
737
|
+
sessionId
|
|
738
|
+
);
|
|
739
|
+
return new Response(eventStream, {
|
|
740
|
+
headers: {
|
|
741
|
+
"Content-Type": "text/event-stream",
|
|
742
|
+
"Cache-Control": "no-cache",
|
|
743
|
+
Connection: "keep-alive",
|
|
744
|
+
"X-Accel-Buffering": "no"
|
|
745
|
+
}
|
|
657
746
|
});
|
|
658
747
|
}).openapi(loadRoute, async (ctx) => {
|
|
659
748
|
const agent = await getAgent(ctx);
|
|
660
749
|
const { sessionId } = ctx.req.valid("param");
|
|
661
750
|
const sessionIds = await agent.listSessions();
|
|
662
751
|
if (!sessionIds.includes(sessionId)) {
|
|
663
|
-
|
|
752
|
+
throw new import_core.DextoRuntimeError(
|
|
753
|
+
"session_not_found",
|
|
754
|
+
import_core.ErrorScope.SESSION,
|
|
755
|
+
import_core.ErrorType.NOT_FOUND,
|
|
756
|
+
`Session not found: ${sessionId}`,
|
|
757
|
+
{ sessionId }
|
|
758
|
+
);
|
|
664
759
|
}
|
|
665
760
|
const metadata = await agent.getSessionMetadata(sessionId);
|
|
666
761
|
const isBusy = await agent.isSessionBusy(sessionId);
|
|
@@ -686,16 +781,19 @@ function createSessionsRouter(getAgent) {
|
|
|
686
781
|
const agent = await getAgent(ctx);
|
|
687
782
|
const { sessionId } = ctx.req.valid("param");
|
|
688
783
|
await agent.clearContext(sessionId);
|
|
689
|
-
return ctx.json({ status: "context cleared", sessionId });
|
|
784
|
+
return ctx.json({ status: "context cleared", sessionId }, 200);
|
|
690
785
|
}).openapi(patchRoute, async (ctx) => {
|
|
691
786
|
const agent = await getAgent(ctx);
|
|
692
787
|
const { sessionId } = ctx.req.valid("param");
|
|
693
788
|
const { title } = ctx.req.valid("json");
|
|
694
789
|
await agent.setSessionTitle(sessionId, title);
|
|
695
790
|
const metadata = await agent.getSessionMetadata(sessionId);
|
|
696
|
-
return ctx.json(
|
|
697
|
-
|
|
698
|
-
|
|
791
|
+
return ctx.json(
|
|
792
|
+
{
|
|
793
|
+
session: mapSessionMetadata(sessionId, metadata, { title })
|
|
794
|
+
},
|
|
795
|
+
200
|
|
796
|
+
);
|
|
699
797
|
}).openapi(generateTitleRoute, async (ctx) => {
|
|
700
798
|
const agent = await getAgent(ctx);
|
|
701
799
|
const { sessionId } = ctx.req.valid("param");
|