@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
|
@@ -41,7 +41,7 @@ var import_path = __toESM(require("path"), 1);
|
|
|
41
41
|
var import_fs = require("fs");
|
|
42
42
|
var import_core2 = require("@dexto/core");
|
|
43
43
|
var import_responses = require("../schemas/responses.js");
|
|
44
|
-
const AgentConfigSchemaForOpenAPI = import_zod_openapi.z.record(import_zod_openapi.z.
|
|
44
|
+
const AgentConfigSchemaForOpenAPI = import_zod_openapi.z.record(import_zod_openapi.z.string(), import_responses.JsonValueSchema).describe(
|
|
45
45
|
"Complete agent configuration. See AgentConfig type documentation for full schema details."
|
|
46
46
|
);
|
|
47
47
|
const AgentIdentifierSchema = import_zod_openapi.z.object({
|
|
@@ -142,296 +142,341 @@ const SaveConfigResponseSchema = import_zod_openapi.z.object({
|
|
|
142
142
|
changesApplied: import_zod_openapi.z.array(import_zod_openapi.z.string()).describe("List of changes that were applied"),
|
|
143
143
|
message: import_zod_openapi.z.string().describe("Success message")
|
|
144
144
|
}).strict().describe("Configuration save result");
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
const installRoute = (0, import_zod_openapi.createRoute)({
|
|
182
|
-
method: "post",
|
|
183
|
-
path: "/agents/install",
|
|
184
|
-
summary: "Install Agent",
|
|
185
|
-
description: "Installs an agent from the registry or from a custom source",
|
|
186
|
-
tags: ["agents"],
|
|
187
|
-
request: {
|
|
188
|
-
body: {
|
|
189
|
-
content: {
|
|
190
|
-
"application/json": {
|
|
191
|
-
schema: import_zod_openapi.z.union([CustomAgentInstallSchema, AgentIdentifierSchema])
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
|
145
|
+
const CreateCustomAgentResponseSchema = import_zod_openapi.z.object({
|
|
146
|
+
created: import_zod_openapi.z.literal(true).describe("Creation success indicator"),
|
|
147
|
+
id: import_zod_openapi.z.string().describe("Agent identifier"),
|
|
148
|
+
name: import_zod_openapi.z.string().describe("Agent name")
|
|
149
|
+
}).strict().describe("Custom agent creation response");
|
|
150
|
+
const ValidateConfigErrorSchema = import_zod_openapi.z.object({
|
|
151
|
+
line: import_zod_openapi.z.number().int().optional().describe("Line number"),
|
|
152
|
+
column: import_zod_openapi.z.number().int().optional().describe("Column number"),
|
|
153
|
+
path: import_zod_openapi.z.string().optional().describe("Configuration path"),
|
|
154
|
+
message: import_zod_openapi.z.string().describe("Error message"),
|
|
155
|
+
code: import_zod_openapi.z.string().describe("Error code")
|
|
156
|
+
}).passthrough().describe("Configuration validation error");
|
|
157
|
+
const ValidateConfigWarningSchema = import_zod_openapi.z.object({
|
|
158
|
+
path: import_zod_openapi.z.string().describe("Configuration path"),
|
|
159
|
+
message: import_zod_openapi.z.string().describe("Warning message"),
|
|
160
|
+
code: import_zod_openapi.z.string().describe("Warning code")
|
|
161
|
+
}).strict().describe("Configuration validation warning");
|
|
162
|
+
const ValidateConfigResponseSchema = import_zod_openapi.z.object({
|
|
163
|
+
valid: import_zod_openapi.z.boolean().describe("Whether configuration is valid"),
|
|
164
|
+
errors: import_zod_openapi.z.array(ValidateConfigErrorSchema).describe("Validation errors"),
|
|
165
|
+
warnings: import_zod_openapi.z.array(ValidateConfigWarningSchema).describe("Configuration warnings")
|
|
166
|
+
}).strict().describe("Configuration validation result");
|
|
167
|
+
const ExportConfigQuerySchema = import_zod_openapi.z.object({
|
|
168
|
+
sessionId: import_zod_openapi.z.string().optional().describe("Session identifier to export session-specific configuration")
|
|
169
|
+
}).describe("Export configuration query");
|
|
170
|
+
const InstallAgentRequestSchema = import_zod_openapi.z.union([CustomAgentInstallSchema, AgentIdentifierSchema]).describe("Agent installation request");
|
|
171
|
+
const listRoute = (0, import_zod_openapi.createRoute)({
|
|
172
|
+
method: "get",
|
|
173
|
+
path: "/agents",
|
|
174
|
+
summary: "List Agents",
|
|
175
|
+
description: "Retrieves all agents (installed, available, and current active agent)",
|
|
176
|
+
tags: ["agents"],
|
|
177
|
+
responses: {
|
|
178
|
+
200: {
|
|
179
|
+
description: "List all agents",
|
|
180
|
+
content: { "application/json": { schema: ListAgentsResponseSchema } }
|
|
195
181
|
},
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
body: {
|
|
211
|
-
content: {
|
|
212
|
-
"application/json": {
|
|
213
|
-
schema: AgentIdentifierSchema
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
}
|
|
182
|
+
400: import_responses.BadRequestErrorResponse,
|
|
183
|
+
500: import_responses.InternalErrorResponse
|
|
184
|
+
}
|
|
185
|
+
});
|
|
186
|
+
const currentRoute = (0, import_zod_openapi.createRoute)({
|
|
187
|
+
method: "get",
|
|
188
|
+
path: "/agents/current",
|
|
189
|
+
summary: "Get Current Agent",
|
|
190
|
+
description: "Retrieves the currently active agent",
|
|
191
|
+
tags: ["agents"],
|
|
192
|
+
responses: {
|
|
193
|
+
200: {
|
|
194
|
+
description: "Current agent",
|
|
195
|
+
content: { "application/json": { schema: AgentInfoNullableSchema } }
|
|
217
196
|
},
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
197
|
+
400: import_responses.BadRequestErrorResponse,
|
|
198
|
+
500: import_responses.InternalErrorResponse
|
|
199
|
+
}
|
|
200
|
+
});
|
|
201
|
+
const installRoute = (0, import_zod_openapi.createRoute)({
|
|
202
|
+
method: "post",
|
|
203
|
+
path: "/agents/install",
|
|
204
|
+
summary: "Install Agent",
|
|
205
|
+
description: "Installs an agent from the registry or from a custom source",
|
|
206
|
+
tags: ["agents"],
|
|
207
|
+
request: {
|
|
208
|
+
body: {
|
|
209
|
+
content: {
|
|
210
|
+
"application/json": {
|
|
211
|
+
schema: InstallAgentRequestSchema
|
|
212
|
+
}
|
|
222
213
|
}
|
|
223
214
|
}
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
215
|
+
},
|
|
216
|
+
responses: {
|
|
217
|
+
201: {
|
|
218
|
+
description: "Agent installed",
|
|
219
|
+
content: { "application/json": { schema: InstallAgentResponseSchema } }
|
|
220
|
+
},
|
|
221
|
+
400: import_responses.BadRequestErrorResponse,
|
|
222
|
+
404: import_responses.NotFoundErrorResponse,
|
|
223
|
+
409: import_responses.ConflictErrorResponse,
|
|
224
|
+
500: import_responses.InternalErrorResponse
|
|
225
|
+
}
|
|
226
|
+
});
|
|
227
|
+
const switchRoute = (0, import_zod_openapi.createRoute)({
|
|
228
|
+
method: "post",
|
|
229
|
+
path: "/agents/switch",
|
|
230
|
+
summary: "Switch Agent",
|
|
231
|
+
description: "Switches to a different agent by ID or file path",
|
|
232
|
+
tags: ["agents"],
|
|
233
|
+
request: {
|
|
234
|
+
body: {
|
|
235
|
+
content: {
|
|
236
|
+
"application/json": {
|
|
237
|
+
schema: AgentIdentifierSchema
|
|
237
238
|
}
|
|
238
239
|
}
|
|
240
|
+
}
|
|
241
|
+
},
|
|
242
|
+
responses: {
|
|
243
|
+
200: {
|
|
244
|
+
description: "Agent switched",
|
|
245
|
+
content: { "application/json": { schema: SwitchAgentResponseSchema } }
|
|
239
246
|
},
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
247
|
+
400: import_responses.BadRequestErrorResponse,
|
|
248
|
+
404: import_responses.NotFoundErrorResponse,
|
|
249
|
+
409: import_responses.ConflictErrorResponse,
|
|
250
|
+
500: import_responses.InternalErrorResponse
|
|
251
|
+
}
|
|
252
|
+
});
|
|
253
|
+
const validateNameRoute = (0, import_zod_openapi.createRoute)({
|
|
254
|
+
method: "post",
|
|
255
|
+
path: "/agents/validate-name",
|
|
256
|
+
summary: "Validate Agent Name",
|
|
257
|
+
description: "Checks if an agent ID conflicts with existing agents",
|
|
258
|
+
tags: ["agents"],
|
|
259
|
+
request: {
|
|
260
|
+
body: {
|
|
261
|
+
content: {
|
|
262
|
+
"application/json": {
|
|
263
|
+
schema: AgentIdentifierSchema
|
|
264
|
+
}
|
|
244
265
|
}
|
|
245
266
|
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
267
|
+
},
|
|
268
|
+
responses: {
|
|
269
|
+
200: {
|
|
270
|
+
description: "Name validation result",
|
|
271
|
+
content: { "application/json": { schema: ValidateNameResponseSchema } }
|
|
272
|
+
},
|
|
273
|
+
400: import_responses.BadRequestErrorResponse,
|
|
274
|
+
404: import_responses.NotFoundErrorResponse,
|
|
275
|
+
409: import_responses.ConflictErrorResponse,
|
|
276
|
+
500: import_responses.InternalErrorResponse
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
const uninstallRoute = (0, import_zod_openapi.createRoute)({
|
|
280
|
+
method: "post",
|
|
281
|
+
path: "/agents/uninstall",
|
|
282
|
+
summary: "Uninstall Agent",
|
|
283
|
+
description: "Removes an agent from the system. Custom agents are removed from registry; builtin agents can be reinstalled",
|
|
284
|
+
tags: ["agents"],
|
|
285
|
+
request: {
|
|
286
|
+
body: {
|
|
287
|
+
content: {
|
|
288
|
+
"application/json": {
|
|
289
|
+
schema: UninstallAgentSchema
|
|
259
290
|
}
|
|
260
291
|
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
responses: {
|
|
295
|
+
200: {
|
|
296
|
+
description: "Agent uninstalled",
|
|
297
|
+
content: { "application/json": { schema: UninstallAgentResponseSchema } }
|
|
261
298
|
},
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
299
|
+
400: import_responses.BadRequestErrorResponse,
|
|
300
|
+
404: import_responses.NotFoundErrorResponse,
|
|
301
|
+
409: import_responses.ConflictErrorResponse,
|
|
302
|
+
500: import_responses.InternalErrorResponse
|
|
303
|
+
}
|
|
304
|
+
});
|
|
305
|
+
const customCreateRoute = (0, import_zod_openapi.createRoute)({
|
|
306
|
+
method: "post",
|
|
307
|
+
path: "/agents/custom/create",
|
|
308
|
+
summary: "Create Custom Agent",
|
|
309
|
+
description: "Creates a new custom agent from scratch via the UI/API",
|
|
310
|
+
tags: ["agents"],
|
|
311
|
+
request: {
|
|
312
|
+
body: {
|
|
313
|
+
content: {
|
|
314
|
+
"application/json": {
|
|
315
|
+
schema: CustomAgentCreateSchema
|
|
316
|
+
}
|
|
266
317
|
}
|
|
267
318
|
}
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
request: {
|
|
276
|
-
body: {
|
|
277
|
-
content: {
|
|
278
|
-
"application/json": {
|
|
279
|
-
schema: CustomAgentCreateSchema
|
|
280
|
-
}
|
|
319
|
+
},
|
|
320
|
+
responses: {
|
|
321
|
+
201: {
|
|
322
|
+
description: "Custom agent created",
|
|
323
|
+
content: {
|
|
324
|
+
"application/json": {
|
|
325
|
+
schema: CreateCustomAgentResponseSchema
|
|
281
326
|
}
|
|
282
327
|
}
|
|
283
328
|
},
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
329
|
+
400: import_responses.BadRequestErrorResponse,
|
|
330
|
+
404: import_responses.NotFoundErrorResponse,
|
|
331
|
+
409: import_responses.ConflictErrorResponse,
|
|
332
|
+
500: import_responses.InternalErrorResponse
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
const getPathRoute = (0, import_zod_openapi.createRoute)({
|
|
336
|
+
method: "get",
|
|
337
|
+
path: "/agent/path",
|
|
338
|
+
summary: "Get Agent File Path",
|
|
339
|
+
description: "Retrieves the file path of the currently active agent configuration",
|
|
340
|
+
tags: ["agent"],
|
|
341
|
+
responses: {
|
|
342
|
+
200: {
|
|
343
|
+
description: "Agent file path",
|
|
344
|
+
content: {
|
|
345
|
+
"application/json": {
|
|
346
|
+
schema: AgentPathResponseSchema
|
|
295
347
|
}
|
|
296
348
|
}
|
|
297
|
-
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
349
|
+
},
|
|
350
|
+
400: import_responses.BadRequestErrorResponse,
|
|
351
|
+
404: import_responses.NotFoundErrorResponse,
|
|
352
|
+
409: import_responses.ConflictErrorResponse,
|
|
353
|
+
500: import_responses.InternalErrorResponse
|
|
354
|
+
}
|
|
355
|
+
});
|
|
356
|
+
const getConfigRoute = (0, import_zod_openapi.createRoute)({
|
|
357
|
+
method: "get",
|
|
358
|
+
path: "/agent/config",
|
|
359
|
+
summary: "Get Agent Configuration",
|
|
360
|
+
description: "Retrieves the raw YAML configuration of the currently active agent",
|
|
361
|
+
tags: ["agent"],
|
|
362
|
+
responses: {
|
|
363
|
+
200: {
|
|
364
|
+
description: "Agent configuration",
|
|
365
|
+
content: {
|
|
366
|
+
"application/json": {
|
|
367
|
+
schema: AgentConfigResponseSchema
|
|
312
368
|
}
|
|
313
369
|
}
|
|
314
|
-
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
370
|
+
},
|
|
371
|
+
400: import_responses.BadRequestErrorResponse,
|
|
372
|
+
404: import_responses.NotFoundErrorResponse,
|
|
373
|
+
409: import_responses.ConflictErrorResponse,
|
|
374
|
+
500: import_responses.InternalErrorResponse
|
|
375
|
+
}
|
|
376
|
+
});
|
|
377
|
+
const validateConfigRoute = (0, import_zod_openapi.createRoute)({
|
|
378
|
+
method: "post",
|
|
379
|
+
path: "/agent/validate",
|
|
380
|
+
summary: "Validate Agent Configuration",
|
|
381
|
+
description: "Validates YAML agent configuration without saving it",
|
|
382
|
+
tags: ["agent"],
|
|
383
|
+
request: {
|
|
384
|
+
body: {
|
|
385
|
+
content: {
|
|
386
|
+
"application/json": {
|
|
387
|
+
schema: AgentConfigValidateSchema
|
|
329
388
|
}
|
|
330
389
|
}
|
|
331
390
|
}
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
request: {
|
|
340
|
-
body: {
|
|
341
|
-
content: {
|
|
342
|
-
"application/json": {
|
|
343
|
-
schema: AgentConfigValidateSchema
|
|
344
|
-
}
|
|
391
|
+
},
|
|
392
|
+
responses: {
|
|
393
|
+
200: {
|
|
394
|
+
description: "Validation result",
|
|
395
|
+
content: {
|
|
396
|
+
"application/json": {
|
|
397
|
+
schema: ValidateConfigResponseSchema
|
|
345
398
|
}
|
|
346
399
|
}
|
|
347
400
|
},
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
import_zod_openapi.z.object({
|
|
366
|
-
path: import_zod_openapi.z.string().describe("Configuration path"),
|
|
367
|
-
message: import_zod_openapi.z.string().describe("Warning message"),
|
|
368
|
-
code: import_zod_openapi.z.string().describe("Warning code")
|
|
369
|
-
}).strict()
|
|
370
|
-
).describe("Configuration warnings")
|
|
371
|
-
}).strict()
|
|
372
|
-
}
|
|
401
|
+
400: import_responses.BadRequestErrorResponse,
|
|
402
|
+
404: import_responses.NotFoundErrorResponse,
|
|
403
|
+
409: import_responses.ConflictErrorResponse,
|
|
404
|
+
500: import_responses.InternalErrorResponse
|
|
405
|
+
}
|
|
406
|
+
});
|
|
407
|
+
const saveConfigRoute = (0, import_zod_openapi.createRoute)({
|
|
408
|
+
method: "post",
|
|
409
|
+
path: "/agent/config",
|
|
410
|
+
summary: "Save Agent Configuration",
|
|
411
|
+
description: "Saves and applies YAML agent configuration. Creates backup before saving",
|
|
412
|
+
tags: ["agent"],
|
|
413
|
+
request: {
|
|
414
|
+
body: {
|
|
415
|
+
content: {
|
|
416
|
+
"application/json": {
|
|
417
|
+
schema: AgentConfigSaveSchema
|
|
373
418
|
}
|
|
374
419
|
}
|
|
375
420
|
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
request: {
|
|
384
|
-
body: {
|
|
385
|
-
content: {
|
|
386
|
-
"application/json": {
|
|
387
|
-
schema: AgentConfigSaveSchema
|
|
388
|
-
}
|
|
421
|
+
},
|
|
422
|
+
responses: {
|
|
423
|
+
200: {
|
|
424
|
+
description: "Configuration saved",
|
|
425
|
+
content: {
|
|
426
|
+
"application/json": {
|
|
427
|
+
schema: SaveConfigResponseSchema
|
|
389
428
|
}
|
|
390
429
|
}
|
|
391
430
|
},
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
431
|
+
400: import_responses.BadRequestErrorResponse,
|
|
432
|
+
404: import_responses.NotFoundErrorResponse,
|
|
433
|
+
409: import_responses.ConflictErrorResponse,
|
|
434
|
+
500: import_responses.InternalErrorResponse
|
|
435
|
+
}
|
|
436
|
+
});
|
|
437
|
+
const exportConfigRoute = (0, import_zod_openapi.createRoute)({
|
|
438
|
+
method: "get",
|
|
439
|
+
path: "/agent/config/export",
|
|
440
|
+
summary: "Export Agent Configuration",
|
|
441
|
+
description: "Exports the effective agent configuration with sensitive values redacted",
|
|
442
|
+
tags: ["agent"],
|
|
443
|
+
request: {
|
|
444
|
+
query: ExportConfigQuerySchema
|
|
445
|
+
},
|
|
446
|
+
responses: {
|
|
447
|
+
200: {
|
|
448
|
+
description: "Exported configuration",
|
|
449
|
+
content: { "application/x-yaml": { schema: import_zod_openapi.z.string() } }
|
|
401
450
|
}
|
|
402
|
-
}
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
sessionId: import_zod_openapi.z.string().optional().describe("Session identifier to export session-specific configuration")
|
|
412
|
-
})
|
|
413
|
-
},
|
|
414
|
-
responses: {
|
|
415
|
-
200: {
|
|
416
|
-
description: "Exported configuration",
|
|
417
|
-
content: { "application/x-yaml": { schema: import_zod_openapi.z.string() } }
|
|
418
|
-
}
|
|
451
|
+
}
|
|
452
|
+
});
|
|
453
|
+
function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
454
|
+
const app = new import_zod_openapi.OpenAPIHono();
|
|
455
|
+
const { switchAgentById, switchAgentByPath, resolveAgentInfo, getActiveAgentId } = context;
|
|
456
|
+
const resolveAgentConfigPath = async (ctx) => {
|
|
457
|
+
const configPath = await getAgentConfigPath(ctx);
|
|
458
|
+
if (!configPath) {
|
|
459
|
+
throw import_core.AgentError.noConfigPath();
|
|
419
460
|
}
|
|
420
|
-
|
|
461
|
+
return configPath;
|
|
462
|
+
};
|
|
421
463
|
return app.openapi(listRoute, async (ctx) => {
|
|
422
464
|
const agents = await import_agent_management.AgentFactory.listAgents();
|
|
423
465
|
const currentId = getActiveAgentId() ?? null;
|
|
424
|
-
return ctx.json(
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
466
|
+
return ctx.json(
|
|
467
|
+
{
|
|
468
|
+
installed: agents.installed,
|
|
469
|
+
available: agents.available,
|
|
470
|
+
current: currentId ? await resolveAgentInfo(currentId) : { id: null, name: null }
|
|
471
|
+
},
|
|
472
|
+
200
|
|
473
|
+
);
|
|
429
474
|
}).openapi(currentRoute, async (ctx) => {
|
|
430
475
|
const currentId = getActiveAgentId() ?? null;
|
|
431
476
|
if (!currentId) {
|
|
432
|
-
return ctx.json({ id: null, name: null });
|
|
477
|
+
return ctx.json({ id: null, name: null }, 200);
|
|
433
478
|
}
|
|
434
|
-
return ctx.json(await resolveAgentInfo(currentId));
|
|
479
|
+
return ctx.json(await resolveAgentInfo(currentId), 200);
|
|
435
480
|
}).openapi(installRoute, async (ctx) => {
|
|
436
481
|
const body = ctx.req.valid("json");
|
|
437
482
|
if ("sourcePath" in body && "metadata" in body) {
|
|
@@ -462,53 +507,68 @@ function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
|
462
507
|
}).openapi(switchRoute, async (ctx) => {
|
|
463
508
|
const { id, path: filePath } = ctx.req.valid("json");
|
|
464
509
|
const result = filePath ? await switchAgentByPath(filePath) : await switchAgentById(id);
|
|
465
|
-
return ctx.json({ switched: true, ...result });
|
|
510
|
+
return ctx.json({ switched: true, ...result }, 200);
|
|
466
511
|
}).openapi(validateNameRoute, async (ctx) => {
|
|
467
512
|
const { id } = ctx.req.valid("json");
|
|
468
513
|
const agents = await import_agent_management.AgentFactory.listAgents();
|
|
469
514
|
const installedAgent = agents.installed.find((a) => a.id === id);
|
|
470
515
|
if (installedAgent) {
|
|
471
|
-
return ctx.json(
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
516
|
+
return ctx.json(
|
|
517
|
+
{
|
|
518
|
+
valid: false,
|
|
519
|
+
conflict: installedAgent.type,
|
|
520
|
+
message: `Agent id '${id}' already exists (${installedAgent.type})`
|
|
521
|
+
},
|
|
522
|
+
200
|
|
523
|
+
);
|
|
476
524
|
}
|
|
477
525
|
const availableAgent = agents.available.find((a) => a.id === id);
|
|
478
526
|
if (availableAgent) {
|
|
479
|
-
return ctx.json(
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
527
|
+
return ctx.json(
|
|
528
|
+
{
|
|
529
|
+
valid: false,
|
|
530
|
+
conflict: availableAgent.type,
|
|
531
|
+
message: `Agent id '${id}' conflicts with ${availableAgent.type} agent`
|
|
532
|
+
},
|
|
533
|
+
200
|
|
534
|
+
);
|
|
484
535
|
}
|
|
485
|
-
return ctx.json({ valid: true });
|
|
536
|
+
return ctx.json({ valid: true }, 200);
|
|
486
537
|
}).openapi(uninstallRoute, async (ctx) => {
|
|
487
538
|
const { id, force } = ctx.req.valid("json");
|
|
488
539
|
await import_agent_management.AgentFactory.uninstallAgent(id, force);
|
|
489
|
-
return ctx.json({ uninstalled: true, id });
|
|
540
|
+
return ctx.json({ uninstalled: true, id }, 200);
|
|
490
541
|
}).openapi(customCreateRoute, async (ctx) => {
|
|
491
542
|
const { id, name, description, author, tags, config } = ctx.req.valid("json");
|
|
492
|
-
const
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
543
|
+
const configResult = import_agent_config.AgentConfigSchema.safeParse(config);
|
|
544
|
+
if (!configResult.success) {
|
|
545
|
+
throw new import_core2.DextoValidationError((0, import_core.zodToIssues)(configResult.error));
|
|
546
|
+
}
|
|
547
|
+
const validatedConfig = configResult.data;
|
|
548
|
+
const provider = validatedConfig.llm.provider;
|
|
549
|
+
let agentConfig = validatedConfig;
|
|
550
|
+
if (validatedConfig.llm.apiKey && !validatedConfig.llm.apiKey.startsWith("$")) {
|
|
551
|
+
const meta = await (0, import_agent_management.saveProviderApiKey)(
|
|
552
|
+
provider,
|
|
553
|
+
validatedConfig.llm.apiKey,
|
|
554
|
+
process.cwd()
|
|
555
|
+
);
|
|
496
556
|
const apiKeyRef = `$${meta.envVar}`;
|
|
497
557
|
import_core.logger.info(
|
|
498
558
|
`Stored API key securely for ${provider}, using env var: ${meta.envVar}`
|
|
499
559
|
);
|
|
500
560
|
agentConfig = {
|
|
501
|
-
...
|
|
561
|
+
...validatedConfig,
|
|
502
562
|
llm: {
|
|
503
|
-
...
|
|
563
|
+
...validatedConfig.llm,
|
|
504
564
|
apiKey: apiKeyRef
|
|
505
565
|
}
|
|
506
566
|
};
|
|
507
|
-
} else if (!
|
|
567
|
+
} else if (!validatedConfig.llm.apiKey) {
|
|
508
568
|
agentConfig = {
|
|
509
|
-
...
|
|
569
|
+
...validatedConfig,
|
|
510
570
|
llm: {
|
|
511
|
-
...
|
|
571
|
+
...validatedConfig.llm,
|
|
512
572
|
apiKey: `$${(0, import_agent_management.getPrimaryApiKeyEnvVar)(provider)}`
|
|
513
573
|
}
|
|
514
574
|
};
|
|
@@ -540,26 +600,32 @@ function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
|
540
600
|
const relativePath = import_path.default.basename(agentPath);
|
|
541
601
|
const ext = import_path.default.extname(agentPath);
|
|
542
602
|
const name = import_path.default.basename(agentPath, ext);
|
|
543
|
-
return ctx.json(
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
603
|
+
return ctx.json(
|
|
604
|
+
{
|
|
605
|
+
path: agentPath,
|
|
606
|
+
relativePath,
|
|
607
|
+
name,
|
|
608
|
+
isDefault: name === "coding-agent"
|
|
609
|
+
},
|
|
610
|
+
200
|
|
611
|
+
);
|
|
549
612
|
}).openapi(getConfigRoute, async (ctx) => {
|
|
550
613
|
const agentPath = await resolveAgentConfigPath(ctx);
|
|
551
614
|
const yamlContent = await import_fs.promises.readFile(agentPath, "utf-8");
|
|
552
615
|
const stats = await import_fs.promises.stat(agentPath);
|
|
553
|
-
return ctx.json(
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
616
|
+
return ctx.json(
|
|
617
|
+
{
|
|
618
|
+
yaml: yamlContent,
|
|
619
|
+
path: agentPath,
|
|
620
|
+
relativePath: import_path.default.basename(agentPath),
|
|
621
|
+
lastModified: stats.mtime,
|
|
622
|
+
warnings: [
|
|
623
|
+
"Environment variables ($VAR) will be resolved at runtime",
|
|
624
|
+
"API keys should use environment variables"
|
|
625
|
+
]
|
|
626
|
+
},
|
|
627
|
+
200
|
|
628
|
+
);
|
|
563
629
|
}).openapi(validateConfigRoute, async (ctx) => {
|
|
564
630
|
const { yaml } = ctx.req.valid("json");
|
|
565
631
|
let parsed;
|
|
@@ -568,32 +634,38 @@ function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
|
568
634
|
} catch (parseError) {
|
|
569
635
|
const message = parseError instanceof Error ? parseError.message : String(parseError);
|
|
570
636
|
const linePos = typeof parseError === "object" && parseError !== null && "linePos" in parseError ? parseError.linePos : void 0;
|
|
571
|
-
return ctx.json(
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
637
|
+
return ctx.json(
|
|
638
|
+
{
|
|
639
|
+
valid: false,
|
|
640
|
+
errors: [
|
|
641
|
+
{
|
|
642
|
+
line: linePos?.[0]?.line ?? 1,
|
|
643
|
+
column: linePos?.[0]?.col ?? 1,
|
|
644
|
+
message,
|
|
645
|
+
code: "YAML_PARSE_ERROR"
|
|
646
|
+
}
|
|
647
|
+
],
|
|
648
|
+
warnings: []
|
|
649
|
+
},
|
|
650
|
+
200
|
|
651
|
+
);
|
|
583
652
|
}
|
|
584
653
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
585
|
-
return ctx.json(
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
654
|
+
return ctx.json(
|
|
655
|
+
{
|
|
656
|
+
valid: false,
|
|
657
|
+
errors: [
|
|
658
|
+
{
|
|
659
|
+
line: 1,
|
|
660
|
+
column: 1,
|
|
661
|
+
message: "Configuration must be a valid YAML object",
|
|
662
|
+
code: "INVALID_CONFIG_TYPE"
|
|
663
|
+
}
|
|
664
|
+
],
|
|
665
|
+
warnings: []
|
|
666
|
+
},
|
|
667
|
+
200
|
|
668
|
+
);
|
|
597
669
|
}
|
|
598
670
|
const enriched = (0, import_agent_management.enrichAgentConfig)(parsed, void 0);
|
|
599
671
|
const result = import_agent_config.AgentConfigSchema.safeParse(enriched);
|
|
@@ -604,11 +676,14 @@ function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
|
604
676
|
message: issue.message,
|
|
605
677
|
code: "SCHEMA_VALIDATION_ERROR"
|
|
606
678
|
}));
|
|
607
|
-
return ctx.json(
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
679
|
+
return ctx.json(
|
|
680
|
+
{
|
|
681
|
+
valid: false,
|
|
682
|
+
errors,
|
|
683
|
+
warnings: []
|
|
684
|
+
},
|
|
685
|
+
200
|
|
686
|
+
);
|
|
612
687
|
}
|
|
613
688
|
const warnings = [];
|
|
614
689
|
if (parsed.llm?.apiKey && !parsed.llm.apiKey.startsWith("$")) {
|
|
@@ -618,11 +693,14 @@ function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
|
618
693
|
code: "SECURITY_WARNING"
|
|
619
694
|
});
|
|
620
695
|
}
|
|
621
|
-
return ctx.json(
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
696
|
+
return ctx.json(
|
|
697
|
+
{
|
|
698
|
+
valid: true,
|
|
699
|
+
errors: [],
|
|
700
|
+
warnings
|
|
701
|
+
},
|
|
702
|
+
200
|
|
703
|
+
);
|
|
626
704
|
}).openapi(saveConfigRoute, async (ctx) => {
|
|
627
705
|
const { yaml } = ctx.req.valid("json");
|
|
628
706
|
let parsed;
|
|
@@ -673,14 +751,17 @@ function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
|
673
751
|
await import_fs.promises.unlink(backupPath).catch(() => {
|
|
674
752
|
});
|
|
675
753
|
import_core.logger.info(`Agent configuration saved and applied: ${agentPath}`);
|
|
676
|
-
return ctx.json(
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
754
|
+
return ctx.json(
|
|
755
|
+
{
|
|
756
|
+
ok: true,
|
|
757
|
+
path: agentPath,
|
|
758
|
+
reloaded: true,
|
|
759
|
+
restarted: true,
|
|
760
|
+
changesApplied: ["restart"],
|
|
761
|
+
message: "Configuration saved and applied successfully (agent restarted)"
|
|
762
|
+
},
|
|
763
|
+
200
|
|
764
|
+
);
|
|
684
765
|
} catch (error) {
|
|
685
766
|
await import_fs.promises.copyFile(backupPath, agentPath).catch(() => {
|
|
686
767
|
});
|