@dexto/server 1.2.6 → 1.4.0
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/approval/manual-approval-handler.cjs +23 -15
- package/dist/approval/manual-approval-handler.d.ts.map +1 -1
- package/dist/approval/manual-approval-handler.js +23 -15
- package/dist/events/webhook-subscriber.cjs +1 -1
- package/dist/events/webhook-subscriber.d.ts.map +1 -1
- package/dist/events/webhook-subscriber.js +1 -1
- package/dist/hono/__tests__/test-fixtures.cjs +2 -2
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +2 -2
- package/dist/hono/index.cjs +14 -2
- package/dist/hono/index.d.ts +486 -132
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +17 -2
- package/dist/hono/middleware/error.d.ts.map +1 -1
- package/dist/hono/routes/agents.cjs +8 -10
- package/dist/hono/routes/agents.d.ts +15 -8
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +10 -10
- package/dist/hono/routes/approvals.cjs +52 -1
- package/dist/hono/routes/approvals.d.ts +25 -0
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +52 -1
- package/dist/hono/routes/llm.cjs +110 -31
- package/dist/hono/routes/llm.d.ts +89 -37
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +108 -25
- package/dist/hono/routes/mcp.cjs +8 -4
- package/dist/hono/routes/mcp.d.ts +4 -1
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +9 -5
- package/dist/hono/routes/memory.d.ts +1 -1
- package/dist/hono/routes/messages.cjs +56 -64
- package/dist/hono/routes/messages.d.ts +101 -57
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +57 -65
- package/dist/hono/routes/prompts.cjs +2 -2
- package/dist/hono/routes/prompts.d.ts +7 -7
- package/dist/hono/routes/prompts.js +2 -2
- package/dist/hono/routes/queue.cjs +202 -0
- package/dist/hono/routes/queue.d.ts +171 -0
- package/dist/hono/routes/queue.d.ts.map +1 -0
- package/dist/hono/routes/queue.js +178 -0
- package/dist/hono/routes/resources.d.ts +1 -1
- package/dist/hono/routes/search.cjs +2 -24
- package/dist/hono/routes/search.d.ts +43 -15
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +3 -25
- package/dist/hono/routes/sessions.cjs +65 -11
- package/dist/hono/routes/sessions.d.ts +27 -5
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +65 -11
- package/dist/hono/routes/static.cjs +77 -0
- package/dist/hono/routes/static.d.ts +41 -0
- package/dist/hono/routes/static.d.ts.map +1 -0
- package/dist/hono/routes/static.js +52 -0
- package/dist/hono/schemas/responses.cjs +67 -25
- package/dist/hono/schemas/responses.d.ts +2076 -354
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +69 -35
- package/package.json +3 -3
package/dist/hono/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAezD,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAezD,OAAO,EAAsB,KAAK,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAGlF,OAAO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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;oBAR7n6I;AAID,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAGxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/hono/index.js
CHANGED
|
@@ -15,6 +15,11 @@ import { createResourcesRouter } from "./routes/resources.js";
|
|
|
15
15
|
import { createMemoryRouter } from "./routes/memory.js";
|
|
16
16
|
import { createAgentsRouter } from "./routes/agents.js";
|
|
17
17
|
import { createApprovalsRouter } from "./routes/approvals.js";
|
|
18
|
+
import { createQueueRouter } from "./routes/queue.js";
|
|
19
|
+
import {
|
|
20
|
+
createStaticRouter,
|
|
21
|
+
createSpaFallbackHandler
|
|
22
|
+
} from "./routes/static.js";
|
|
18
23
|
import { handleHonoError } from "./middleware/error.js";
|
|
19
24
|
import { prettyJsonMiddleware, redactionMiddleware } from "./middleware/redaction.js";
|
|
20
25
|
import { createCorsMiddleware } from "./middleware/cors.js";
|
|
@@ -46,7 +51,9 @@ function createDextoApp(options) {
|
|
|
46
51
|
approvalCoordinator,
|
|
47
52
|
webhookSubscriber,
|
|
48
53
|
sseSubscriber,
|
|
49
|
-
agentsContext
|
|
54
|
+
agentsContext,
|
|
55
|
+
webRoot,
|
|
56
|
+
webUIConfig
|
|
50
57
|
} = options;
|
|
51
58
|
const app = new OpenAPIHono({ strict: false });
|
|
52
59
|
app.use("*", createCorsMiddleware());
|
|
@@ -54,7 +61,7 @@ function createDextoApp(options) {
|
|
|
54
61
|
app.onError((err, ctx) => handleHonoError(ctx, err));
|
|
55
62
|
app.use("/api/*", prettyJsonMiddleware);
|
|
56
63
|
app.use("/api/*", redactionMiddleware);
|
|
57
|
-
const fullApp = app.route("/health", createHealthRouter(getAgent)).route("/", createA2aRouter(getAgentCard)).route("/", createA2AJsonRpcRouter(getAgent, sseSubscriber)).route("/", createA2ATasksRouter(getAgent, sseSubscriber)).route("/api", createGreetingRouter(getAgent)).route("/api", createMessagesRouter(getAgent, approvalCoordinator)).route("/api", createLlmRouter(getAgent)).route("/api", createSessionsRouter(getAgent)).route("/api", createSearchRouter(getAgent)).route("/api", createMcpRouter(getAgent)).route("/api", createWebhooksRouter(getAgent, webhookSubscriber)).route("/api", createPromptsRouter(getAgent)).route("/api", createResourcesRouter(getAgent)).route("/api", createMemoryRouter(getAgent)).route("/api", createApprovalsRouter(getAgent, approvalCoordinator)).route("/api", createAgentsRouter(getAgent, agentsContext || dummyAgentsContext));
|
|
64
|
+
const fullApp = app.route("/health", createHealthRouter(getAgent)).route("/", createA2aRouter(getAgentCard)).route("/", createA2AJsonRpcRouter(getAgent, sseSubscriber)).route("/", createA2ATasksRouter(getAgent, sseSubscriber)).route("/api", createGreetingRouter(getAgent)).route("/api", createMessagesRouter(getAgent, approvalCoordinator)).route("/api", createLlmRouter(getAgent)).route("/api", createSessionsRouter(getAgent)).route("/api", createSearchRouter(getAgent)).route("/api", createMcpRouter(getAgent)).route("/api", createWebhooksRouter(getAgent, webhookSubscriber)).route("/api", createPromptsRouter(getAgent)).route("/api", createResourcesRouter(getAgent)).route("/api", createMemoryRouter(getAgent)).route("/api", createApprovalsRouter(getAgent, approvalCoordinator)).route("/api", createAgentsRouter(getAgent, agentsContext || dummyAgentsContext)).route("/api", createQueueRouter(getAgent));
|
|
58
65
|
fullApp.doc("/openapi.json", {
|
|
59
66
|
openapi: "3.0.0",
|
|
60
67
|
info: {
|
|
@@ -130,9 +137,17 @@ function createDextoApp(options) {
|
|
|
130
137
|
{
|
|
131
138
|
name: "agents",
|
|
132
139
|
description: "Install, switch, and manage agent configurations"
|
|
140
|
+
},
|
|
141
|
+
{
|
|
142
|
+
name: "queue",
|
|
143
|
+
description: "Manage message queue for busy sessions"
|
|
133
144
|
}
|
|
134
145
|
]
|
|
135
146
|
});
|
|
147
|
+
if (webRoot) {
|
|
148
|
+
fullApp.route("/", createStaticRouter(webRoot));
|
|
149
|
+
fullApp.notFound(createSpaFallbackHandler(webRoot, webUIConfig));
|
|
150
|
+
}
|
|
136
151
|
Object.assign(fullApp, { webhookSubscriber });
|
|
137
152
|
return fullApp;
|
|
138
153
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/hono/middleware/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/hono/middleware/error.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2C,SAAS,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAc9F,eAAO,MAAM,oBAAoB,GAAI,MAAM,SAAS,KAAG,MAoBtD,CAAC;AAEF,eAAO,MAAM,mBAAmB,GAAI,QAAQ,UAAU,CAAC,OAAO,WAAW,CAAC,KAAG,MAI5E,CAAC;AAEF,wBAAgB,eAAe,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,OAAO,OAkFrD"}
|
|
@@ -34,7 +34,6 @@ module.exports = __toCommonJS(agents_exports);
|
|
|
34
34
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
35
35
|
var import_core = require("@dexto/core");
|
|
36
36
|
var import_agent_management = require("@dexto/agent-management");
|
|
37
|
-
var import_agent_management2 = require("@dexto/agent-management");
|
|
38
37
|
var import_yaml = require("yaml");
|
|
39
38
|
var import_os = __toESM(require("os"), 1);
|
|
40
39
|
var import_path = __toESM(require("path"), 1);
|
|
@@ -63,7 +62,7 @@ const CustomAgentInstallSchema = import_zod_openapi.z.object({
|
|
|
63
62
|
}).strict().describe("Agent metadata including description, author, and tags"),
|
|
64
63
|
injectPreferences: import_zod_openapi.z.boolean().default(true).describe("Whether to inject user preferences into agent config")
|
|
65
64
|
}).strict().describe("Request body for installing a custom agent from file system").transform((value) => {
|
|
66
|
-
const displayName = value.name?.trim() || (0,
|
|
65
|
+
const displayName = value.name?.trim() || (0, import_agent_management.deriveDisplayName)(value.id);
|
|
67
66
|
return {
|
|
68
67
|
id: value.id,
|
|
69
68
|
displayName,
|
|
@@ -411,7 +410,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
411
410
|
}
|
|
412
411
|
});
|
|
413
412
|
return app.openapi(listRoute, async (ctx) => {
|
|
414
|
-
const agents = await
|
|
413
|
+
const agents = await import_agent_management.AgentFactory.listAgents();
|
|
415
414
|
const currentId = getActiveAgentId() ?? null;
|
|
416
415
|
return ctx.json({
|
|
417
416
|
installed: agents.installed,
|
|
@@ -428,15 +427,14 @@ function createAgentsRouter(getAgent, context) {
|
|
|
428
427
|
const body = ctx.req.valid("json");
|
|
429
428
|
if ("sourcePath" in body && "metadata" in body) {
|
|
430
429
|
const { id, displayName, sourcePath, metadata, injectPreferences } = body;
|
|
431
|
-
await
|
|
430
|
+
await import_agent_management.AgentFactory.installCustomAgent(
|
|
432
431
|
id,
|
|
433
432
|
sourcePath,
|
|
434
433
|
{
|
|
435
434
|
name: displayName,
|
|
436
435
|
description: metadata.description,
|
|
437
436
|
author: metadata.author,
|
|
438
|
-
tags: metadata.tags
|
|
439
|
-
...metadata.main ? { main: metadata.main } : {}
|
|
437
|
+
tags: metadata.tags
|
|
440
438
|
},
|
|
441
439
|
injectPreferences
|
|
442
440
|
);
|
|
@@ -446,7 +444,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
446
444
|
);
|
|
447
445
|
} else {
|
|
448
446
|
const { id } = body;
|
|
449
|
-
await
|
|
447
|
+
await import_agent_management.AgentFactory.installAgent(id);
|
|
450
448
|
const agentInfo = await resolveAgentInfo(id);
|
|
451
449
|
return ctx.json(
|
|
452
450
|
{
|
|
@@ -463,7 +461,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
463
461
|
return ctx.json({ switched: true, ...result });
|
|
464
462
|
}).openapi(validateNameRoute, async (ctx) => {
|
|
465
463
|
const { id } = ctx.req.valid("json");
|
|
466
|
-
const agents = await
|
|
464
|
+
const agents = await import_agent_management.AgentFactory.listAgents();
|
|
467
465
|
const installedAgent = agents.installed.find((a) => a.id === id);
|
|
468
466
|
if (installedAgent) {
|
|
469
467
|
return ctx.json({
|
|
@@ -483,7 +481,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
483
481
|
return ctx.json({ valid: true });
|
|
484
482
|
}).openapi(uninstallRoute, async (ctx) => {
|
|
485
483
|
const { id, force } = ctx.req.valid("json");
|
|
486
|
-
await
|
|
484
|
+
await import_agent_management.AgentFactory.uninstallAgent(id, force);
|
|
487
485
|
return ctx.json({ uninstalled: true, id });
|
|
488
486
|
}).openapi(customCreateRoute, async (ctx) => {
|
|
489
487
|
const { id, name, description, author, tags, config } = ctx.req.valid("json");
|
|
@@ -519,7 +517,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
519
517
|
const tmpFile = import_path.default.join(tmpDir, `${id}-${Date.now()}.yml`);
|
|
520
518
|
await import_fs.promises.writeFile(tmpFile, yamlContent, "utf-8");
|
|
521
519
|
try {
|
|
522
|
-
await
|
|
520
|
+
await import_agent_management.AgentFactory.installCustomAgent(
|
|
523
521
|
id,
|
|
524
522
|
tmpFile,
|
|
525
523
|
{
|
|
@@ -66,13 +66,13 @@ export declare function createAgentsRouter(getAgent: () => DextoAgent, context:
|
|
|
66
66
|
id: string;
|
|
67
67
|
path?: string | undefined;
|
|
68
68
|
} | {
|
|
69
|
-
id: string;
|
|
70
69
|
metadata: {
|
|
71
70
|
tags: string[];
|
|
72
71
|
description: string;
|
|
73
72
|
author: string;
|
|
74
73
|
main?: string | undefined;
|
|
75
74
|
};
|
|
75
|
+
id: string;
|
|
76
76
|
sourcePath: string;
|
|
77
77
|
name?: string | undefined;
|
|
78
78
|
injectPreferences?: boolean | undefined;
|
|
@@ -149,10 +149,9 @@ export declare function createAgentsRouter(getAgent: () => DextoAgent, context:
|
|
|
149
149
|
description: string;
|
|
150
150
|
config: {
|
|
151
151
|
llm: {
|
|
152
|
-
apiKey: string;
|
|
153
152
|
model: string;
|
|
154
153
|
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
|
|
155
|
-
|
|
154
|
+
apiKey: string;
|
|
156
155
|
maxIterations?: number | undefined;
|
|
157
156
|
baseURL?: string | undefined;
|
|
158
157
|
maxInputTokens?: number | undefined;
|
|
@@ -188,6 +187,11 @@ export declare function createAgentsRouter(getAgent: () => DextoAgent, context:
|
|
|
188
187
|
enabled?: boolean | undefined;
|
|
189
188
|
})[] | undefined;
|
|
190
189
|
};
|
|
190
|
+
tools?: Record<string, {
|
|
191
|
+
maxOutputChars?: number | undefined;
|
|
192
|
+
maxLines?: number | undefined;
|
|
193
|
+
maxLineLength?: number | undefined;
|
|
194
|
+
}> | undefined;
|
|
191
195
|
storage?: {
|
|
192
196
|
database: {
|
|
193
197
|
type: "in-memory";
|
|
@@ -298,9 +302,13 @@ export declare function createAgentsRouter(getAgent: () => DextoAgent, context:
|
|
|
298
302
|
agentId?: string | undefined;
|
|
299
303
|
agentCard?: {
|
|
300
304
|
description: string;
|
|
301
|
-
url: string;
|
|
302
305
|
name: string;
|
|
306
|
+
url: string;
|
|
303
307
|
version: string;
|
|
308
|
+
provider?: {
|
|
309
|
+
url: string;
|
|
310
|
+
organization: string;
|
|
311
|
+
} | undefined;
|
|
304
312
|
metadata?: z.objectInputType<{
|
|
305
313
|
dexto: z.ZodOptional<z.ZodObject<{
|
|
306
314
|
authentication: z.ZodOptional<z.ZodObject<{
|
|
@@ -381,10 +389,6 @@ export declare function createAgentsRouter(getAgent: () => DextoAgent, context:
|
|
|
381
389
|
pushNotifications?: boolean | undefined;
|
|
382
390
|
stateTransitionHistory?: boolean | undefined;
|
|
383
391
|
} | undefined;
|
|
384
|
-
provider?: {
|
|
385
|
-
url: string;
|
|
386
|
-
organization: string;
|
|
387
|
-
} | undefined;
|
|
388
392
|
protocolVersion?: string | undefined;
|
|
389
393
|
preferredTransport?: "JSONRPC" | "GRPC" | "HTTP+JSON" | undefined;
|
|
390
394
|
defaultInputModes?: string[] | undefined;
|
|
@@ -471,6 +475,7 @@ export declare function createAgentsRouter(getAgent: () => DextoAgent, context:
|
|
|
471
475
|
type: "stdio";
|
|
472
476
|
command: string;
|
|
473
477
|
timeout?: number | undefined;
|
|
478
|
+
enabled?: boolean | undefined;
|
|
474
479
|
args?: string[] | undefined;
|
|
475
480
|
env?: Record<string, string> | undefined;
|
|
476
481
|
connectionMode?: "strict" | "lenient" | undefined;
|
|
@@ -478,12 +483,14 @@ export declare function createAgentsRouter(getAgent: () => DextoAgent, context:
|
|
|
478
483
|
type: "sse";
|
|
479
484
|
url: string;
|
|
480
485
|
timeout?: number | undefined;
|
|
486
|
+
enabled?: boolean | undefined;
|
|
481
487
|
connectionMode?: "strict" | "lenient" | undefined;
|
|
482
488
|
headers?: Record<string, string> | undefined;
|
|
483
489
|
} | {
|
|
484
490
|
type: "http";
|
|
485
491
|
url: string;
|
|
486
492
|
timeout?: number | undefined;
|
|
493
|
+
enabled?: boolean | undefined;
|
|
487
494
|
connectionMode?: "strict" | "lenient" | undefined;
|
|
488
495
|
headers?: Record<string, string> | undefined;
|
|
489
496
|
}> | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAuN9C,MAAM,MAAM,mBAAmB,GAAG;IAC9B,eAAe,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC5E,iBAAiB,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC/E,gBAAgB,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC7E,oBAAoB,EAAE,MAAM,IAAI,CAAC;IACjC,gBAAgB,EAAE,MAAM,MAAM,GAAG,SAAS,CAAC;CAC9C,CAAC;AAEF,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAAU,EAAE,OAAO,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AC;mCAAqC,CAAC;gCAAmC,CAAC;+BAAmC,CAAC;0CAA4D,CAAC;;;;mCAAuG,CAAC;mCAAqC,CAAC;0CAA6C,CAAC;mCAAmD,CAAC;;;;mCAA0G,CAAC;mCAAqC,CAAC;0CAA6C,CAAC;mCAAmD,CAAC;;;;uCAA+S,CAAC;sCAAwC,CAAC;;;mCAAiF,CAAC;gCAAkC,CAAC;+CAAkF,CAAC;wCAAwD,CAAC;2CAA2B,CAAC;0CAA8C,CAAC;;;;;;oCAAkK,CAAC;oCAAsC,CAAC;yCAA2C,CAAC;6CAAgD,CAAC;;;;mCAAoF,CAAC;qCAAwC,CAAC;;;wCAAsF,CAAC;wCAA0C,CAAC;6CAA+C,CAAC;iDAAoD,CAAC;;;;;;kCAA2I,CAAC;;;;;sCAAyI,CAAC;uCAAsD,CAAC;;yCAAqE,CAAC;;;;;6CAA2O,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAD//mH"}
|
|
@@ -9,9 +9,10 @@ import {
|
|
|
9
9
|
getPrimaryApiKeyEnvVar,
|
|
10
10
|
saveProviderApiKey,
|
|
11
11
|
reloadAgentConfigFromFile,
|
|
12
|
-
enrichAgentConfig
|
|
12
|
+
enrichAgentConfig,
|
|
13
|
+
deriveDisplayName,
|
|
14
|
+
AgentFactory
|
|
13
15
|
} from "@dexto/agent-management";
|
|
14
|
-
import { Dexto, deriveDisplayName } from "@dexto/agent-management";
|
|
15
16
|
import { stringify as yamlStringify, parse as yamlParse } from "yaml";
|
|
16
17
|
import os from "os";
|
|
17
18
|
import path from "path";
|
|
@@ -388,7 +389,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
388
389
|
}
|
|
389
390
|
});
|
|
390
391
|
return app.openapi(listRoute, async (ctx) => {
|
|
391
|
-
const agents = await
|
|
392
|
+
const agents = await AgentFactory.listAgents();
|
|
392
393
|
const currentId = getActiveAgentId() ?? null;
|
|
393
394
|
return ctx.json({
|
|
394
395
|
installed: agents.installed,
|
|
@@ -405,15 +406,14 @@ function createAgentsRouter(getAgent, context) {
|
|
|
405
406
|
const body = ctx.req.valid("json");
|
|
406
407
|
if ("sourcePath" in body && "metadata" in body) {
|
|
407
408
|
const { id, displayName, sourcePath, metadata, injectPreferences } = body;
|
|
408
|
-
await
|
|
409
|
+
await AgentFactory.installCustomAgent(
|
|
409
410
|
id,
|
|
410
411
|
sourcePath,
|
|
411
412
|
{
|
|
412
413
|
name: displayName,
|
|
413
414
|
description: metadata.description,
|
|
414
415
|
author: metadata.author,
|
|
415
|
-
tags: metadata.tags
|
|
416
|
-
...metadata.main ? { main: metadata.main } : {}
|
|
416
|
+
tags: metadata.tags
|
|
417
417
|
},
|
|
418
418
|
injectPreferences
|
|
419
419
|
);
|
|
@@ -423,7 +423,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
423
423
|
);
|
|
424
424
|
} else {
|
|
425
425
|
const { id } = body;
|
|
426
|
-
await
|
|
426
|
+
await AgentFactory.installAgent(id);
|
|
427
427
|
const agentInfo = await resolveAgentInfo(id);
|
|
428
428
|
return ctx.json(
|
|
429
429
|
{
|
|
@@ -440,7 +440,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
440
440
|
return ctx.json({ switched: true, ...result });
|
|
441
441
|
}).openapi(validateNameRoute, async (ctx) => {
|
|
442
442
|
const { id } = ctx.req.valid("json");
|
|
443
|
-
const agents = await
|
|
443
|
+
const agents = await AgentFactory.listAgents();
|
|
444
444
|
const installedAgent = agents.installed.find((a) => a.id === id);
|
|
445
445
|
if (installedAgent) {
|
|
446
446
|
return ctx.json({
|
|
@@ -460,7 +460,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
460
460
|
return ctx.json({ valid: true });
|
|
461
461
|
}).openapi(uninstallRoute, async (ctx) => {
|
|
462
462
|
const { id, force } = ctx.req.valid("json");
|
|
463
|
-
await
|
|
463
|
+
await AgentFactory.uninstallAgent(id, force);
|
|
464
464
|
return ctx.json({ uninstalled: true, id });
|
|
465
465
|
}).openapi(customCreateRoute, async (ctx) => {
|
|
466
466
|
const { id, name, description, author, tags, config } = ctx.req.valid("json");
|
|
@@ -496,7 +496,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
496
496
|
const tmpFile = path.join(tmpDir, `${id}-${Date.now()}.yml`);
|
|
497
497
|
await fs.writeFile(tmpFile, yamlContent, "utf-8");
|
|
498
498
|
try {
|
|
499
|
-
await
|
|
499
|
+
await AgentFactory.installCustomAgent(
|
|
500
500
|
id,
|
|
501
501
|
tmpFile,
|
|
502
502
|
{
|
|
@@ -33,8 +33,42 @@ const ApprovalResponseSchema = import_zod_openapi.z.object({
|
|
|
33
33
|
approvalId: import_zod_openapi.z.string().describe("The ID of the processed approval"),
|
|
34
34
|
status: import_zod_openapi.z.enum([import_core.ApprovalStatus.APPROVED, import_core.ApprovalStatus.DENIED]).describe("The final status")
|
|
35
35
|
}).describe("Response after processing approval");
|
|
36
|
+
const PendingApprovalSchema = import_zod_openapi.z.object({
|
|
37
|
+
approvalId: import_zod_openapi.z.string().describe("The unique ID of the approval request"),
|
|
38
|
+
type: import_zod_openapi.z.string().describe("The type of approval (tool_confirmation, elicitation, etc.)"),
|
|
39
|
+
sessionId: import_zod_openapi.z.string().optional().describe("The session ID if applicable"),
|
|
40
|
+
timeout: import_zod_openapi.z.number().optional().describe("Timeout in milliseconds"),
|
|
41
|
+
timestamp: import_zod_openapi.z.string().describe("ISO timestamp when the request was created"),
|
|
42
|
+
metadata: import_zod_openapi.z.record(import_zod_openapi.z.unknown()).describe("Type-specific metadata")
|
|
43
|
+
}).describe("A pending approval request");
|
|
44
|
+
const PendingApprovalsResponseSchema = import_zod_openapi.z.object({
|
|
45
|
+
ok: import_zod_openapi.z.literal(true).describe("Success indicator"),
|
|
46
|
+
approvals: import_zod_openapi.z.array(PendingApprovalSchema).describe("List of pending approval requests")
|
|
47
|
+
}).describe("Response containing pending approval requests");
|
|
36
48
|
function createApprovalsRouter(getAgent, approvalCoordinator) {
|
|
37
49
|
const app = new import_zod_openapi.OpenAPIHono();
|
|
50
|
+
const getPendingApprovalsRoute = (0, import_zod_openapi.createRoute)({
|
|
51
|
+
method: "get",
|
|
52
|
+
path: "/approvals",
|
|
53
|
+
summary: "Get Pending Approvals",
|
|
54
|
+
description: "Fetch all pending approval requests for a session. Use this to restore UI state after page refresh.",
|
|
55
|
+
tags: ["approvals"],
|
|
56
|
+
request: {
|
|
57
|
+
query: import_zod_openapi.z.object({
|
|
58
|
+
sessionId: import_zod_openapi.z.string().describe("The session ID to fetch pending approvals for")
|
|
59
|
+
})
|
|
60
|
+
},
|
|
61
|
+
responses: {
|
|
62
|
+
200: {
|
|
63
|
+
description: "List of pending approval requests",
|
|
64
|
+
content: {
|
|
65
|
+
"application/json": {
|
|
66
|
+
schema: PendingApprovalsResponseSchema
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
});
|
|
38
72
|
const submitApprovalRoute = (0, import_zod_openapi.createRoute)({
|
|
39
73
|
method: "post",
|
|
40
74
|
path: "/approvals/{approvalId}",
|
|
@@ -72,7 +106,24 @@ function createApprovalsRouter(getAgent, approvalCoordinator) {
|
|
|
72
106
|
}
|
|
73
107
|
}
|
|
74
108
|
});
|
|
75
|
-
return app.openapi(
|
|
109
|
+
return app.openapi(getPendingApprovalsRoute, async (ctx) => {
|
|
110
|
+
const agent = getAgent();
|
|
111
|
+
const { sessionId } = ctx.req.valid("query");
|
|
112
|
+
agent.logger.debug(`Fetching pending approvals for session ${sessionId}`);
|
|
113
|
+
const pendingIds = agent.services.approvalManager.getPendingApprovals();
|
|
114
|
+
const approvals = pendingIds.map((approvalId) => ({
|
|
115
|
+
approvalId,
|
|
116
|
+
type: "tool_confirmation",
|
|
117
|
+
// Default type
|
|
118
|
+
sessionId,
|
|
119
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
120
|
+
metadata: {}
|
|
121
|
+
}));
|
|
122
|
+
return ctx.json({
|
|
123
|
+
ok: true,
|
|
124
|
+
approvals
|
|
125
|
+
});
|
|
126
|
+
}).openapi(submitApprovalRoute, async (ctx) => {
|
|
76
127
|
const agent = getAgent();
|
|
77
128
|
const { approvalId } = ctx.req.valid("param");
|
|
78
129
|
const { status, formData, rememberChoice } = ctx.req.valid("json");
|
|
@@ -2,6 +2,31 @@ import { OpenAPIHono } from '@hono/zod-openapi';
|
|
|
2
2
|
import { type DextoAgent, ApprovalStatus } from '@dexto/core';
|
|
3
3
|
import type { ApprovalCoordinator } from '../../approval/approval-coordinator.js';
|
|
4
4
|
export declare function createApprovalsRouter(getAgent: () => DextoAgent, approvalCoordinator?: ApprovalCoordinator): OpenAPIHono<import("hono").Env, {
|
|
5
|
+
"/approvals": {
|
|
6
|
+
$get: {
|
|
7
|
+
input: {
|
|
8
|
+
query: {
|
|
9
|
+
sessionId: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
output: {
|
|
13
|
+
ok: true;
|
|
14
|
+
approvals: {
|
|
15
|
+
type: string;
|
|
16
|
+
metadata: {
|
|
17
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
18
|
+
};
|
|
19
|
+
timestamp: string;
|
|
20
|
+
approvalId: string;
|
|
21
|
+
sessionId?: string | undefined;
|
|
22
|
+
timeout?: number | undefined;
|
|
23
|
+
}[];
|
|
24
|
+
};
|
|
25
|
+
outputFormat: "json";
|
|
26
|
+
status: 200;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
} & {
|
|
5
30
|
"/approvals/:approvalId": {
|
|
6
31
|
$post: {
|
|
7
32
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAgB,cAAc,EAAiB,MAAM,aAAa,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;
|
|
1
|
+
{"version":3,"file":"approvals.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/approvals.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EAAE,KAAK,UAAU,EAAgB,cAAc,EAAiB,MAAM,aAAa,CAAC;AAC3F,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,wCAAwC,CAAC;AA8ClF,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,MAAM,UAAU,EAC1B,mBAAmB,CAAC,EAAE,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAgK5C"}
|
|
@@ -10,8 +10,42 @@ const ApprovalResponseSchema = z.object({
|
|
|
10
10
|
approvalId: z.string().describe("The ID of the processed approval"),
|
|
11
11
|
status: z.enum([ApprovalStatus.APPROVED, ApprovalStatus.DENIED]).describe("The final status")
|
|
12
12
|
}).describe("Response after processing approval");
|
|
13
|
+
const PendingApprovalSchema = z.object({
|
|
14
|
+
approvalId: z.string().describe("The unique ID of the approval request"),
|
|
15
|
+
type: z.string().describe("The type of approval (tool_confirmation, elicitation, etc.)"),
|
|
16
|
+
sessionId: z.string().optional().describe("The session ID if applicable"),
|
|
17
|
+
timeout: z.number().optional().describe("Timeout in milliseconds"),
|
|
18
|
+
timestamp: z.string().describe("ISO timestamp when the request was created"),
|
|
19
|
+
metadata: z.record(z.unknown()).describe("Type-specific metadata")
|
|
20
|
+
}).describe("A pending approval request");
|
|
21
|
+
const PendingApprovalsResponseSchema = z.object({
|
|
22
|
+
ok: z.literal(true).describe("Success indicator"),
|
|
23
|
+
approvals: z.array(PendingApprovalSchema).describe("List of pending approval requests")
|
|
24
|
+
}).describe("Response containing pending approval requests");
|
|
13
25
|
function createApprovalsRouter(getAgent, approvalCoordinator) {
|
|
14
26
|
const app = new OpenAPIHono();
|
|
27
|
+
const getPendingApprovalsRoute = createRoute({
|
|
28
|
+
method: "get",
|
|
29
|
+
path: "/approvals",
|
|
30
|
+
summary: "Get Pending Approvals",
|
|
31
|
+
description: "Fetch all pending approval requests for a session. Use this to restore UI state after page refresh.",
|
|
32
|
+
tags: ["approvals"],
|
|
33
|
+
request: {
|
|
34
|
+
query: z.object({
|
|
35
|
+
sessionId: z.string().describe("The session ID to fetch pending approvals for")
|
|
36
|
+
})
|
|
37
|
+
},
|
|
38
|
+
responses: {
|
|
39
|
+
200: {
|
|
40
|
+
description: "List of pending approval requests",
|
|
41
|
+
content: {
|
|
42
|
+
"application/json": {
|
|
43
|
+
schema: PendingApprovalsResponseSchema
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
});
|
|
15
49
|
const submitApprovalRoute = createRoute({
|
|
16
50
|
method: "post",
|
|
17
51
|
path: "/approvals/{approvalId}",
|
|
@@ -49,7 +83,24 @@ function createApprovalsRouter(getAgent, approvalCoordinator) {
|
|
|
49
83
|
}
|
|
50
84
|
}
|
|
51
85
|
});
|
|
52
|
-
return app.openapi(
|
|
86
|
+
return app.openapi(getPendingApprovalsRoute, async (ctx) => {
|
|
87
|
+
const agent = getAgent();
|
|
88
|
+
const { sessionId } = ctx.req.valid("query");
|
|
89
|
+
agent.logger.debug(`Fetching pending approvals for session ${sessionId}`);
|
|
90
|
+
const pendingIds = agent.services.approvalManager.getPendingApprovals();
|
|
91
|
+
const approvals = pendingIds.map((approvalId) => ({
|
|
92
|
+
approvalId,
|
|
93
|
+
type: "tool_confirmation",
|
|
94
|
+
// Default type
|
|
95
|
+
sessionId,
|
|
96
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
97
|
+
metadata: {}
|
|
98
|
+
}));
|
|
99
|
+
return ctx.json({
|
|
100
|
+
ok: true,
|
|
101
|
+
approvals
|
|
102
|
+
});
|
|
103
|
+
}).openapi(submitApprovalRoute, async (ctx) => {
|
|
53
104
|
const agent = getAgent();
|
|
54
105
|
const { approvalId } = ctx.req.valid("param");
|
|
55
106
|
const { status, formData, rememberChoice } = ctx.req.valid("json");
|