@dexto/server 1.5.7 → 1.6.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/events/a2a-sse-subscriber.d.ts +1 -1
- package/dist/hono/__tests__/test-fixtures.cjs +27 -6
- package/dist/hono/__tests__/test-fixtures.d.ts +2 -1
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +31 -6
- package/dist/hono/index.cjs +17 -2
- package/dist/hono/index.d.ts +897 -76
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +17 -2
- package/dist/hono/routes/a2a-tasks.d.ts +6 -6
- package/dist/hono/routes/agents.cjs +38 -27
- package/dist/hono/routes/agents.d.ts +2 -1
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +37 -31
- package/dist/hono/routes/discovery.cjs +99 -22
- package/dist/hono/routes/discovery.d.ts +14 -12
- package/dist/hono/routes/discovery.d.ts.map +1 -1
- package/dist/hono/routes/discovery.js +89 -22
- package/dist/hono/routes/key.d.ts +4 -4
- package/dist/hono/routes/llm.cjs +21 -7
- package/dist/hono/routes/llm.d.ts +12 -10
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +22 -7
- package/dist/hono/routes/mcp.cjs +96 -14
- package/dist/hono/routes/mcp.d.ts +138 -3
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +97 -15
- package/dist/hono/routes/memory.d.ts +4 -4
- package/dist/hono/routes/messages.d.ts +1 -1
- package/dist/hono/routes/models.d.ts +1 -1
- package/dist/hono/routes/queue.cjs +9 -3
- package/dist/hono/routes/queue.d.ts +3 -0
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +9 -3
- package/dist/hono/routes/resources.d.ts +1 -1
- package/dist/hono/routes/schedules.cjs +455 -0
- package/dist/hono/routes/schedules.d.ts +472 -0
- package/dist/hono/routes/schedules.d.ts.map +1 -0
- package/dist/hono/routes/schedules.js +439 -0
- package/dist/hono/routes/search.d.ts +3 -3
- package/dist/hono/routes/sessions.cjs +10 -4
- package/dist/hono/routes/sessions.d.ts +136 -6
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +10 -4
- package/dist/hono/routes/tools.cjs +12 -19
- package/dist/hono/routes/tools.d.ts +5 -3
- package/dist/hono/routes/tools.d.ts.map +1 -1
- package/dist/hono/routes/tools.js +12 -19
- package/dist/hono/routes/workspaces.cjs +136 -0
- package/dist/hono/routes/workspaces.d.ts +77 -0
- package/dist/hono/routes/workspaces.d.ts.map +1 -0
- package/dist/hono/routes/workspaces.js +112 -0
- package/dist/hono/schemas/responses.cjs +82 -7
- package/dist/hono/schemas/responses.d.ts +403 -53
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +75 -6
- package/dist/hono/start-server.cjs +4 -3
- package/dist/hono/start-server.d.ts +15 -6
- package/dist/hono/start-server.d.ts.map +1 -1
- package/dist/hono/start-server.js +5 -4
- package/dist/index.cjs +9 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/mcp/mcp-handler.d.ts +2 -2
- package/dist/mcp/mcp-handler.d.ts.map +1 -1
- package/package.json +8 -5
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,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hono/index.ts"],"names":[],"mappings":"A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AO,cAAc,CAAC,CAAC;AAGxD,YAAY,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/hono/index.js
CHANGED
|
@@ -14,6 +14,8 @@ import { createWebhooksRouter } from "./routes/webhooks.js";
|
|
|
14
14
|
import { createPromptsRouter } from "./routes/prompts.js";
|
|
15
15
|
import { createResourcesRouter } from "./routes/resources.js";
|
|
16
16
|
import { createMemoryRouter } from "./routes/memory.js";
|
|
17
|
+
import { createWorkspacesRouter } from "./routes/workspaces.js";
|
|
18
|
+
import { createSchedulesRouter } from "./routes/schedules.js";
|
|
17
19
|
import { createAgentsRouter } from "./routes/agents.js";
|
|
18
20
|
import { createApprovalsRouter } from "./routes/approvals.js";
|
|
19
21
|
import { createQueueRouter } from "./routes/queue.js";
|
|
@@ -56,6 +58,7 @@ function createDextoApp(options) {
|
|
|
56
58
|
const {
|
|
57
59
|
apiPrefix,
|
|
58
60
|
getAgent,
|
|
61
|
+
getAgentConfigPath,
|
|
59
62
|
getAgentCard,
|
|
60
63
|
approvalCoordinator,
|
|
61
64
|
webhookSubscriber,
|
|
@@ -82,7 +85,15 @@ function createDextoApp(options) {
|
|
|
82
85
|
app.use(middlewarePattern, prettyJsonMiddleware);
|
|
83
86
|
app.use(middlewarePattern, redactionMiddleware);
|
|
84
87
|
const routePrefix = normalizedPrefix;
|
|
85
|
-
const
|
|
88
|
+
const resolvedGetAgentConfigPath = getAgentConfigPath ?? ((_ctx) => void 0);
|
|
89
|
+
const fullApp = app.route("/health", createHealthRouter(getAgent)).route("/", createA2aRouter(getAgentCard)).route("/", createA2AJsonRpcRouter(getAgent, sseSubscriber)).route("/", createA2ATasksRouter(getAgent, sseSubscriber)).route(routePrefix, createGreetingRouter(getAgent)).route(routePrefix, createMessagesRouter(getAgent, approvalCoordinator)).route(routePrefix, createLlmRouter(getAgent)).route(routePrefix, createSessionsRouter(getAgent)).route(routePrefix, createSearchRouter(getAgent)).route(routePrefix, createMcpRouter(getAgent, resolvedGetAgentConfigPath)).route(routePrefix, createWebhooksRouter(getAgent, webhookSubscriber)).route(routePrefix, createPromptsRouter(getAgent)).route(routePrefix, createResourcesRouter(getAgent)).route(routePrefix, createMemoryRouter(getAgent)).route(routePrefix, createWorkspacesRouter(getAgent)).route(routePrefix, createSchedulesRouter(getAgent)).route(routePrefix, createApprovalsRouter(getAgent, approvalCoordinator)).route(
|
|
90
|
+
routePrefix,
|
|
91
|
+
createAgentsRouter(
|
|
92
|
+
getAgent,
|
|
93
|
+
agentsContext || dummyAgentsContext,
|
|
94
|
+
resolvedGetAgentConfigPath
|
|
95
|
+
)
|
|
96
|
+
).route(routePrefix, createQueueRouter(getAgent)).route(routePrefix, createOpenRouterRouter()).route(routePrefix, createKeyRouter()).route(routePrefix, createToolsRouter(getAgent)).route(routePrefix, createDiscoveryRouter(resolvedGetAgentConfigPath)).route(routePrefix, createModelsRouter()).route(routePrefix, createDextoAuthRouter(getAgent));
|
|
86
97
|
fullApp.doc("/openapi.json", {
|
|
87
98
|
openapi: "3.0.0",
|
|
88
99
|
info: {
|
|
@@ -123,6 +134,10 @@ function createDextoApp(options) {
|
|
|
123
134
|
name: "sessions",
|
|
124
135
|
description: "Create and manage conversation sessions"
|
|
125
136
|
},
|
|
137
|
+
{
|
|
138
|
+
name: "schedules",
|
|
139
|
+
description: "Create and manage automation schedules"
|
|
140
|
+
},
|
|
126
141
|
{
|
|
127
142
|
name: "llm",
|
|
128
143
|
description: "Configure and switch between LLM providers and models"
|
|
@@ -173,7 +188,7 @@ function createDextoApp(options) {
|
|
|
173
188
|
},
|
|
174
189
|
{
|
|
175
190
|
name: "tools",
|
|
176
|
-
description: "List and inspect available tools from
|
|
191
|
+
description: "List and inspect available tools from local and MCP sources"
|
|
177
192
|
},
|
|
178
193
|
{
|
|
179
194
|
name: "models",
|
|
@@ -69,19 +69,19 @@ export declare function createA2ATasksRouter(getAgent: GetAgentFn, sseSubscriber
|
|
|
69
69
|
};
|
|
70
70
|
metadata?: Record<string, any> | undefined;
|
|
71
71
|
configuration?: {
|
|
72
|
-
blocking?: boolean | undefined;
|
|
73
72
|
acceptedOutputModes?: string[] | undefined;
|
|
74
73
|
historyLength?: number | undefined;
|
|
75
74
|
pushNotificationConfig?: {
|
|
76
75
|
url: string;
|
|
77
76
|
headers?: Record<string, string> | undefined;
|
|
78
77
|
} | undefined;
|
|
78
|
+
blocking?: boolean | undefined;
|
|
79
79
|
} | undefined;
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
82
|
output: {
|
|
83
83
|
status: {
|
|
84
|
-
state: "unknown" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "
|
|
84
|
+
state: "unknown" | "failed" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "rejected";
|
|
85
85
|
message?: {
|
|
86
86
|
role: "user" | "agent";
|
|
87
87
|
kind: "message";
|
|
@@ -183,7 +183,7 @@ export declare function createA2ATasksRouter(getAgent: GetAgentFn, sseSubscriber
|
|
|
183
183
|
$get: {
|
|
184
184
|
input: {
|
|
185
185
|
query: {
|
|
186
|
-
status?: "unknown" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "
|
|
186
|
+
status?: "unknown" | "failed" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "rejected" | undefined;
|
|
187
187
|
contextId?: string | undefined;
|
|
188
188
|
pageSize?: string | undefined;
|
|
189
189
|
historyLength?: string | undefined;
|
|
@@ -195,7 +195,7 @@ export declare function createA2ATasksRouter(getAgent: GetAgentFn, sseSubscriber
|
|
|
195
195
|
output: {
|
|
196
196
|
tasks: {
|
|
197
197
|
status: {
|
|
198
|
-
state: "unknown" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "
|
|
198
|
+
state: "unknown" | "failed" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "rejected";
|
|
199
199
|
message?: {
|
|
200
200
|
role: "user" | "agent";
|
|
201
201
|
kind: "message";
|
|
@@ -315,7 +315,7 @@ export declare function createA2ATasksRouter(getAgent: GetAgentFn, sseSubscriber
|
|
|
315
315
|
};
|
|
316
316
|
output: {
|
|
317
317
|
status: {
|
|
318
|
-
state: "unknown" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "
|
|
318
|
+
state: "unknown" | "failed" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "rejected";
|
|
319
319
|
message?: {
|
|
320
320
|
role: "user" | "agent";
|
|
321
321
|
kind: "message";
|
|
@@ -431,7 +431,7 @@ export declare function createA2ATasksRouter(getAgent: GetAgentFn, sseSubscriber
|
|
|
431
431
|
};
|
|
432
432
|
output: {
|
|
433
433
|
status: {
|
|
434
|
-
state: "unknown" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "
|
|
434
|
+
state: "unknown" | "failed" | "auth-required" | "submitted" | "working" | "input-required" | "completed" | "canceled" | "rejected";
|
|
435
435
|
message?: {
|
|
436
436
|
role: "user" | "agent";
|
|
437
437
|
kind: "message";
|
|
@@ -32,6 +32,7 @@ __export(agents_exports, {
|
|
|
32
32
|
});
|
|
33
33
|
module.exports = __toCommonJS(agents_exports);
|
|
34
34
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
35
|
+
var import_agent_config = require("@dexto/agent-config");
|
|
35
36
|
var import_core = require("@dexto/core");
|
|
36
37
|
var import_agent_management = require("@dexto/agent-management");
|
|
37
38
|
var import_yaml = require("yaml");
|
|
@@ -141,9 +142,16 @@ const SaveConfigResponseSchema = import_zod_openapi.z.object({
|
|
|
141
142
|
changesApplied: import_zod_openapi.z.array(import_zod_openapi.z.string()).describe("List of changes that were applied"),
|
|
142
143
|
message: import_zod_openapi.z.string().describe("Success message")
|
|
143
144
|
}).strict().describe("Configuration save result");
|
|
144
|
-
function createAgentsRouter(getAgent, context) {
|
|
145
|
+
function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
145
146
|
const app = new import_zod_openapi.OpenAPIHono();
|
|
146
147
|
const { switchAgentById, switchAgentByPath, resolveAgentInfo, getActiveAgentId } = context;
|
|
148
|
+
const resolveAgentConfigPath = async (ctx) => {
|
|
149
|
+
const configPath = await getAgentConfigPath(ctx);
|
|
150
|
+
if (!configPath) {
|
|
151
|
+
throw import_core.AgentError.noConfigPath();
|
|
152
|
+
}
|
|
153
|
+
return configPath;
|
|
154
|
+
};
|
|
147
155
|
const listRoute = (0, import_zod_openapi.createRoute)({
|
|
148
156
|
method: "get",
|
|
149
157
|
path: "/agents",
|
|
@@ -528,8 +536,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
528
536
|
throw installError;
|
|
529
537
|
}
|
|
530
538
|
}).openapi(getPathRoute, async (ctx) => {
|
|
531
|
-
const
|
|
532
|
-
const agentPath = agent.getAgentFilePath();
|
|
539
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
533
540
|
const relativePath = import_path.default.basename(agentPath);
|
|
534
541
|
const ext = import_path.default.extname(agentPath);
|
|
535
542
|
const name = import_path.default.basename(agentPath, ext);
|
|
@@ -540,8 +547,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
540
547
|
isDefault: name === "coding-agent"
|
|
541
548
|
});
|
|
542
549
|
}).openapi(getConfigRoute, async (ctx) => {
|
|
543
|
-
const
|
|
544
|
-
const agentPath = agent.getAgentFilePath();
|
|
550
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
545
551
|
const yamlContent = await import_fs.promises.readFile(agentPath, "utf-8");
|
|
546
552
|
const stats = await import_fs.promises.stat(agentPath);
|
|
547
553
|
return ctx.json({
|
|
@@ -560,13 +566,15 @@ function createAgentsRouter(getAgent, context) {
|
|
|
560
566
|
try {
|
|
561
567
|
parsed = (0, import_yaml.parse)(yaml);
|
|
562
568
|
} catch (parseError) {
|
|
569
|
+
const message = parseError instanceof Error ? parseError.message : String(parseError);
|
|
570
|
+
const linePos = typeof parseError === "object" && parseError !== null && "linePos" in parseError ? parseError.linePos : void 0;
|
|
563
571
|
return ctx.json({
|
|
564
572
|
valid: false,
|
|
565
573
|
errors: [
|
|
566
574
|
{
|
|
567
|
-
line:
|
|
568
|
-
column:
|
|
569
|
-
message
|
|
575
|
+
line: linePos?.[0]?.line ?? 1,
|
|
576
|
+
column: linePos?.[0]?.col ?? 1,
|
|
577
|
+
message,
|
|
570
578
|
code: "YAML_PARSE_ERROR"
|
|
571
579
|
}
|
|
572
580
|
],
|
|
@@ -588,7 +596,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
588
596
|
});
|
|
589
597
|
}
|
|
590
598
|
const enriched = (0, import_agent_management.enrichAgentConfig)(parsed, void 0);
|
|
591
|
-
const result =
|
|
599
|
+
const result = import_agent_config.AgentConfigSchema.safeParse(enriched);
|
|
592
600
|
if (!result.success) {
|
|
593
601
|
const issues = (0, import_core.zodToIssues)(result.error);
|
|
594
602
|
const errors = issues.map((issue) => ({
|
|
@@ -616,16 +624,16 @@ function createAgentsRouter(getAgent, context) {
|
|
|
616
624
|
warnings
|
|
617
625
|
});
|
|
618
626
|
}).openapi(saveConfigRoute, async (ctx) => {
|
|
619
|
-
const agent = await getAgent(ctx);
|
|
620
627
|
const { yaml } = ctx.req.valid("json");
|
|
621
628
|
let parsed;
|
|
622
629
|
try {
|
|
623
630
|
parsed = (0, import_yaml.parse)(yaml);
|
|
624
631
|
} catch (parseError) {
|
|
632
|
+
const message = parseError instanceof Error ? parseError.message : String(parseError);
|
|
625
633
|
throw new import_core2.DextoValidationError([
|
|
626
634
|
{
|
|
627
635
|
code: import_core2.AgentErrorCode.INVALID_CONFIG,
|
|
628
|
-
message: `Invalid YAML syntax: ${
|
|
636
|
+
message: `Invalid YAML syntax: ${message}`,
|
|
629
637
|
scope: import_core2.ErrorScope.AGENT,
|
|
630
638
|
type: import_core2.ErrorType.USER,
|
|
631
639
|
severity: "error"
|
|
@@ -643,9 +651,9 @@ function createAgentsRouter(getAgent, context) {
|
|
|
643
651
|
}
|
|
644
652
|
]);
|
|
645
653
|
}
|
|
646
|
-
const agentPath =
|
|
654
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
647
655
|
const enriched = (0, import_agent_management.enrichAgentConfig)(parsed, agentPath);
|
|
648
|
-
const validationResult =
|
|
656
|
+
const validationResult = import_agent_config.AgentConfigSchema.safeParse(enriched);
|
|
649
657
|
if (!validationResult.success) {
|
|
650
658
|
throw new import_core2.DextoValidationError(
|
|
651
659
|
validationResult.error.errors.map((err) => ({
|
|
@@ -661,16 +669,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
661
669
|
await import_fs.promises.copyFile(agentPath, backupPath);
|
|
662
670
|
try {
|
|
663
671
|
await import_fs.promises.writeFile(agentPath, yaml, "utf-8");
|
|
664
|
-
|
|
665
|
-
const enrichedConfig = (0, import_agent_management.enrichAgentConfig)(newConfig, agentPath);
|
|
666
|
-
const reloadResult = await agent.reload(enrichedConfig);
|
|
667
|
-
if (reloadResult.restarted) {
|
|
668
|
-
import_core.logger.info(
|
|
669
|
-
`Agent restarted to apply changes: ${reloadResult.changesApplied.join(", ")}`
|
|
670
|
-
);
|
|
671
|
-
} else if (reloadResult.changesApplied.length === 0) {
|
|
672
|
-
import_core.logger.info("Configuration saved (no changes detected)");
|
|
673
|
-
}
|
|
672
|
+
await switchAgentByPath(agentPath);
|
|
674
673
|
await import_fs.promises.unlink(backupPath).catch(() => {
|
|
675
674
|
});
|
|
676
675
|
import_core.logger.info(`Agent configuration saved and applied: ${agentPath}`);
|
|
@@ -678,9 +677,9 @@ function createAgentsRouter(getAgent, context) {
|
|
|
678
677
|
ok: true,
|
|
679
678
|
path: agentPath,
|
|
680
679
|
reloaded: true,
|
|
681
|
-
restarted:
|
|
682
|
-
changesApplied:
|
|
683
|
-
message:
|
|
680
|
+
restarted: true,
|
|
681
|
+
changesApplied: ["restart"],
|
|
682
|
+
message: "Configuration saved and applied successfully (agent restarted)"
|
|
684
683
|
});
|
|
685
684
|
} catch (error) {
|
|
686
685
|
await import_fs.promises.copyFile(backupPath, agentPath).catch(() => {
|
|
@@ -690,7 +689,19 @@ function createAgentsRouter(getAgent, context) {
|
|
|
690
689
|
}).openapi(exportConfigRoute, async (ctx) => {
|
|
691
690
|
const agent = await getAgent(ctx);
|
|
692
691
|
const { sessionId } = ctx.req.valid("query");
|
|
693
|
-
const
|
|
692
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
693
|
+
const fileConfig = await (0, import_agent_management.reloadAgentConfigFromFile)(agentPath);
|
|
694
|
+
const enrichedConfig = (0, import_agent_management.enrichAgentConfig)(fileConfig, agentPath);
|
|
695
|
+
const validatedConfig = import_agent_config.AgentConfigSchema.parse(enrichedConfig);
|
|
696
|
+
const effectiveSettings = agent.getEffectiveConfig(sessionId);
|
|
697
|
+
const config = {
|
|
698
|
+
...validatedConfig,
|
|
699
|
+
...effectiveSettings,
|
|
700
|
+
llm: {
|
|
701
|
+
...validatedConfig.llm,
|
|
702
|
+
...effectiveSettings.llm
|
|
703
|
+
}
|
|
704
|
+
};
|
|
694
705
|
const maskedConfig = {
|
|
695
706
|
...config,
|
|
696
707
|
llm: {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
2
|
import type { DextoAgent } from '@dexto/core';
|
|
3
3
|
import type { Context } from 'hono';
|
|
4
|
+
import type { GetAgentConfigPathFn } from '../index.js';
|
|
4
5
|
type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
|
|
5
6
|
export type AgentsRouterContext = {
|
|
6
7
|
switchAgentById: (agentId: string) => Promise<{
|
|
@@ -18,7 +19,7 @@ export type AgentsRouterContext = {
|
|
|
18
19
|
ensureAgentAvailable: () => void;
|
|
19
20
|
getActiveAgentId: () => string | undefined;
|
|
20
21
|
};
|
|
21
|
-
export declare function createAgentsRouter(getAgent: GetAgentFn, context: AgentsRouterContext): OpenAPIHono<import("hono").Env, {
|
|
22
|
+
export declare function createAgentsRouter(getAgent: GetAgentFn, context: AgentsRouterContext, getAgentConfigPath: GetAgentConfigPathFn): OpenAPIHono<import("hono").Env, {
|
|
22
23
|
"/agents": {
|
|
23
24
|
$get: {
|
|
24
25
|
input: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/agents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,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,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAiB9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACxD,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AA8MrE,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,CAC9B,QAAQ,EAAE,UAAU,EACpB,OAAO,EAAE,mBAAmB,EAC5B,kBAAkB,EAAE,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6tB3C"}
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
safeStringify,
|
|
5
|
-
AgentConfigSchema,
|
|
6
|
-
zodToIssues
|
|
7
|
-
} from "@dexto/core";
|
|
2
|
+
import { AgentConfigSchema } from "@dexto/agent-config";
|
|
3
|
+
import { AgentError, logger, safeStringify, zodToIssues } from "@dexto/core";
|
|
8
4
|
import {
|
|
9
5
|
getPrimaryApiKeyEnvVar,
|
|
10
6
|
saveProviderApiKey,
|
|
@@ -120,9 +116,16 @@ const SaveConfigResponseSchema = z.object({
|
|
|
120
116
|
changesApplied: z.array(z.string()).describe("List of changes that were applied"),
|
|
121
117
|
message: z.string().describe("Success message")
|
|
122
118
|
}).strict().describe("Configuration save result");
|
|
123
|
-
function createAgentsRouter(getAgent, context) {
|
|
119
|
+
function createAgentsRouter(getAgent, context, getAgentConfigPath) {
|
|
124
120
|
const app = new OpenAPIHono();
|
|
125
121
|
const { switchAgentById, switchAgentByPath, resolveAgentInfo, getActiveAgentId } = context;
|
|
122
|
+
const resolveAgentConfigPath = async (ctx) => {
|
|
123
|
+
const configPath = await getAgentConfigPath(ctx);
|
|
124
|
+
if (!configPath) {
|
|
125
|
+
throw AgentError.noConfigPath();
|
|
126
|
+
}
|
|
127
|
+
return configPath;
|
|
128
|
+
};
|
|
126
129
|
const listRoute = createRoute({
|
|
127
130
|
method: "get",
|
|
128
131
|
path: "/agents",
|
|
@@ -507,8 +510,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
507
510
|
throw installError;
|
|
508
511
|
}
|
|
509
512
|
}).openapi(getPathRoute, async (ctx) => {
|
|
510
|
-
const
|
|
511
|
-
const agentPath = agent.getAgentFilePath();
|
|
513
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
512
514
|
const relativePath = path.basename(agentPath);
|
|
513
515
|
const ext = path.extname(agentPath);
|
|
514
516
|
const name = path.basename(agentPath, ext);
|
|
@@ -519,8 +521,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
519
521
|
isDefault: name === "coding-agent"
|
|
520
522
|
});
|
|
521
523
|
}).openapi(getConfigRoute, async (ctx) => {
|
|
522
|
-
const
|
|
523
|
-
const agentPath = agent.getAgentFilePath();
|
|
524
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
524
525
|
const yamlContent = await fs.readFile(agentPath, "utf-8");
|
|
525
526
|
const stats = await fs.stat(agentPath);
|
|
526
527
|
return ctx.json({
|
|
@@ -539,13 +540,15 @@ function createAgentsRouter(getAgent, context) {
|
|
|
539
540
|
try {
|
|
540
541
|
parsed = yamlParse(yaml);
|
|
541
542
|
} catch (parseError) {
|
|
543
|
+
const message = parseError instanceof Error ? parseError.message : String(parseError);
|
|
544
|
+
const linePos = typeof parseError === "object" && parseError !== null && "linePos" in parseError ? parseError.linePos : void 0;
|
|
542
545
|
return ctx.json({
|
|
543
546
|
valid: false,
|
|
544
547
|
errors: [
|
|
545
548
|
{
|
|
546
|
-
line:
|
|
547
|
-
column:
|
|
548
|
-
message
|
|
549
|
+
line: linePos?.[0]?.line ?? 1,
|
|
550
|
+
column: linePos?.[0]?.col ?? 1,
|
|
551
|
+
message,
|
|
549
552
|
code: "YAML_PARSE_ERROR"
|
|
550
553
|
}
|
|
551
554
|
],
|
|
@@ -595,16 +598,16 @@ function createAgentsRouter(getAgent, context) {
|
|
|
595
598
|
warnings
|
|
596
599
|
});
|
|
597
600
|
}).openapi(saveConfigRoute, async (ctx) => {
|
|
598
|
-
const agent = await getAgent(ctx);
|
|
599
601
|
const { yaml } = ctx.req.valid("json");
|
|
600
602
|
let parsed;
|
|
601
603
|
try {
|
|
602
604
|
parsed = yamlParse(yaml);
|
|
603
605
|
} catch (parseError) {
|
|
606
|
+
const message = parseError instanceof Error ? parseError.message : String(parseError);
|
|
604
607
|
throw new DextoValidationError([
|
|
605
608
|
{
|
|
606
609
|
code: AgentErrorCode.INVALID_CONFIG,
|
|
607
|
-
message: `Invalid YAML syntax: ${
|
|
610
|
+
message: `Invalid YAML syntax: ${message}`,
|
|
608
611
|
scope: ErrorScope.AGENT,
|
|
609
612
|
type: ErrorType.USER,
|
|
610
613
|
severity: "error"
|
|
@@ -622,7 +625,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
622
625
|
}
|
|
623
626
|
]);
|
|
624
627
|
}
|
|
625
|
-
const agentPath =
|
|
628
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
626
629
|
const enriched = enrichAgentConfig(parsed, agentPath);
|
|
627
630
|
const validationResult = AgentConfigSchema.safeParse(enriched);
|
|
628
631
|
if (!validationResult.success) {
|
|
@@ -640,16 +643,7 @@ function createAgentsRouter(getAgent, context) {
|
|
|
640
643
|
await fs.copyFile(agentPath, backupPath);
|
|
641
644
|
try {
|
|
642
645
|
await fs.writeFile(agentPath, yaml, "utf-8");
|
|
643
|
-
|
|
644
|
-
const enrichedConfig = enrichAgentConfig(newConfig, agentPath);
|
|
645
|
-
const reloadResult = await agent.reload(enrichedConfig);
|
|
646
|
-
if (reloadResult.restarted) {
|
|
647
|
-
logger.info(
|
|
648
|
-
`Agent restarted to apply changes: ${reloadResult.changesApplied.join(", ")}`
|
|
649
|
-
);
|
|
650
|
-
} else if (reloadResult.changesApplied.length === 0) {
|
|
651
|
-
logger.info("Configuration saved (no changes detected)");
|
|
652
|
-
}
|
|
646
|
+
await switchAgentByPath(agentPath);
|
|
653
647
|
await fs.unlink(backupPath).catch(() => {
|
|
654
648
|
});
|
|
655
649
|
logger.info(`Agent configuration saved and applied: ${agentPath}`);
|
|
@@ -657,9 +651,9 @@ function createAgentsRouter(getAgent, context) {
|
|
|
657
651
|
ok: true,
|
|
658
652
|
path: agentPath,
|
|
659
653
|
reloaded: true,
|
|
660
|
-
restarted:
|
|
661
|
-
changesApplied:
|
|
662
|
-
message:
|
|
654
|
+
restarted: true,
|
|
655
|
+
changesApplied: ["restart"],
|
|
656
|
+
message: "Configuration saved and applied successfully (agent restarted)"
|
|
663
657
|
});
|
|
664
658
|
} catch (error) {
|
|
665
659
|
await fs.copyFile(backupPath, agentPath).catch(() => {
|
|
@@ -669,7 +663,19 @@ function createAgentsRouter(getAgent, context) {
|
|
|
669
663
|
}).openapi(exportConfigRoute, async (ctx) => {
|
|
670
664
|
const agent = await getAgent(ctx);
|
|
671
665
|
const { sessionId } = ctx.req.valid("query");
|
|
672
|
-
const
|
|
666
|
+
const agentPath = await resolveAgentConfigPath(ctx);
|
|
667
|
+
const fileConfig = await reloadAgentConfigFromFile(agentPath);
|
|
668
|
+
const enrichedConfig = enrichAgentConfig(fileConfig, agentPath);
|
|
669
|
+
const validatedConfig = AgentConfigSchema.parse(enrichedConfig);
|
|
670
|
+
const effectiveSettings = agent.getEffectiveConfig(sessionId);
|
|
671
|
+
const config = {
|
|
672
|
+
...validatedConfig,
|
|
673
|
+
...effectiveSettings,
|
|
674
|
+
llm: {
|
|
675
|
+
...validatedConfig.llm,
|
|
676
|
+
...effectiveSettings.llm
|
|
677
|
+
}
|
|
678
|
+
};
|
|
673
679
|
const maskedConfig = {
|
|
674
680
|
...config,
|
|
675
681
|
llm: {
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __export = (target, all) => {
|
|
7
9
|
for (var name in all)
|
|
@@ -15,6 +17,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
17
|
}
|
|
16
18
|
return to;
|
|
17
19
|
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
+
mod
|
|
27
|
+
));
|
|
18
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
29
|
var discovery_exports = {};
|
|
20
30
|
__export(discovery_exports, {
|
|
@@ -22,44 +32,111 @@ __export(discovery_exports, {
|
|
|
22
32
|
});
|
|
23
33
|
module.exports = __toCommonJS(discovery_exports);
|
|
24
34
|
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
35
|
+
var import_agent_config = require("@dexto/agent-config");
|
|
36
|
+
var import_agent_management = require("@dexto/agent-management");
|
|
37
|
+
var import_image_local = __toESM(require("@dexto/image-local"), 1);
|
|
38
|
+
const DiscoveredFactorySchema = import_zod_openapi.z.object({
|
|
39
|
+
type: import_zod_openapi.z.string().describe("Factory type identifier"),
|
|
40
|
+
category: import_zod_openapi.z.enum(["blob", "database", "compaction", "tools"]).describe("Factory category"),
|
|
29
41
|
metadata: import_zod_openapi.z.object({
|
|
30
42
|
displayName: import_zod_openapi.z.string().optional().describe("Human-readable display name"),
|
|
31
|
-
description: import_zod_openapi.z.string().optional().describe("
|
|
32
|
-
}).passthrough().optional().describe("Optional metadata about the
|
|
33
|
-
}).describe("Information about a registered
|
|
34
|
-
const
|
|
35
|
-
name: import_zod_openapi.z.string().describe('
|
|
43
|
+
description: import_zod_openapi.z.string().optional().describe("Factory description")
|
|
44
|
+
}).passthrough().optional().describe("Optional metadata about the factory")
|
|
45
|
+
}).describe("Information about a registered factory");
|
|
46
|
+
const ToolSchema = import_zod_openapi.z.object({
|
|
47
|
+
name: import_zod_openapi.z.string().describe('Built-in tool name identifier (e.g., "search_history", "ask_user")'),
|
|
36
48
|
description: import_zod_openapi.z.string().describe("Human-readable description of what the tool does")
|
|
37
|
-
}).describe("Information about
|
|
49
|
+
}).describe("Information about a built-in tool");
|
|
38
50
|
const DiscoveryResponseSchema = import_zod_openapi.z.object({
|
|
39
|
-
blob: import_zod_openapi.z.array(
|
|
40
|
-
database: import_zod_openapi.z.array(
|
|
41
|
-
compaction: import_zod_openapi.z.array(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}).describe("Discovery response with
|
|
45
|
-
function
|
|
51
|
+
blob: import_zod_openapi.z.array(DiscoveredFactorySchema).describe("Blob storage factories"),
|
|
52
|
+
database: import_zod_openapi.z.array(DiscoveredFactorySchema).describe("Database factories"),
|
|
53
|
+
compaction: import_zod_openapi.z.array(DiscoveredFactorySchema).describe("Compaction strategy factories"),
|
|
54
|
+
toolFactories: import_zod_openapi.z.array(DiscoveredFactorySchema).describe("Tool factories"),
|
|
55
|
+
builtinTools: import_zod_openapi.z.array(ToolSchema).describe("Built-in tools available for configuration")
|
|
56
|
+
}).describe("Discovery response with factories grouped by category");
|
|
57
|
+
function toMetadata(metadata) {
|
|
58
|
+
if (!metadata || typeof metadata !== "object" || Array.isArray(metadata)) {
|
|
59
|
+
return void 0;
|
|
60
|
+
}
|
|
61
|
+
const record = metadata;
|
|
62
|
+
const result = {};
|
|
63
|
+
for (const [key, value] of Object.entries(record)) {
|
|
64
|
+
if (value === void 0) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
67
|
+
if (value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean") {
|
|
68
|
+
result[key] = value;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
72
|
+
}
|
|
73
|
+
async function resolveImage(options) {
|
|
74
|
+
const { ctx, getAgentConfigPath } = options;
|
|
75
|
+
const configPath = await getAgentConfigPath(ctx);
|
|
76
|
+
if (!configPath) {
|
|
77
|
+
return import_image_local.default;
|
|
78
|
+
}
|
|
79
|
+
const rawConfig = await (0, import_agent_management.loadAgentConfig)(configPath);
|
|
80
|
+
const imageName = (typeof rawConfig.image === "string" && rawConfig.image.length > 0 ? rawConfig.image : void 0) ?? process.env.DEXTO_IMAGE ?? "@dexto/image-local";
|
|
81
|
+
if (imageName === "@dexto/image-local") {
|
|
82
|
+
return import_image_local.default;
|
|
83
|
+
}
|
|
84
|
+
try {
|
|
85
|
+
return await (0, import_agent_config.loadImage)(imageName);
|
|
86
|
+
} catch (error) {
|
|
87
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
88
|
+
throw new Error(
|
|
89
|
+
`Failed to load image module '${imageName}'. Ensure it is installed and that the host called setImageImporter(). Original error: ${message}`
|
|
90
|
+
);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
async function listDiscoveryFactories(options) {
|
|
94
|
+
const image = await resolveImage(options);
|
|
95
|
+
const blob = Object.entries(image.storage.blob).map(([type, factory]) => ({
|
|
96
|
+
type,
|
|
97
|
+
category: "blob",
|
|
98
|
+
metadata: toMetadata(factory.metadata)
|
|
99
|
+
}));
|
|
100
|
+
const database = Object.entries(image.storage.database).map(([type, factory]) => ({
|
|
101
|
+
type,
|
|
102
|
+
category: "database",
|
|
103
|
+
metadata: toMetadata(factory.metadata)
|
|
104
|
+
}));
|
|
105
|
+
const compaction = Object.entries(image.compaction).map(([type, factory]) => ({
|
|
106
|
+
type,
|
|
107
|
+
category: "compaction",
|
|
108
|
+
metadata: toMetadata(factory.metadata)
|
|
109
|
+
}));
|
|
110
|
+
const toolFactories = Object.entries(image.tools);
|
|
111
|
+
const builtinFactory = toolFactories.find(([type]) => type === "builtin-tools")?.[1];
|
|
112
|
+
const builtinTools = builtinFactory ? builtinFactory.create(builtinFactory.configSchema.parse({ type: "builtin-tools" })).map((tool) => ({
|
|
113
|
+
name: tool.id,
|
|
114
|
+
description: tool.description
|
|
115
|
+
})) : [];
|
|
116
|
+
const toolFactoriesList = toolFactories.filter(([type]) => type !== "builtin-tools").map(([type, factory]) => ({
|
|
117
|
+
type,
|
|
118
|
+
category: "tools",
|
|
119
|
+
metadata: toMetadata(factory.metadata)
|
|
120
|
+
}));
|
|
121
|
+
return { blob, database, compaction, toolFactories: toolFactoriesList, builtinTools };
|
|
122
|
+
}
|
|
123
|
+
function createDiscoveryRouter(getAgentConfigPath) {
|
|
46
124
|
const app = new import_zod_openapi.OpenAPIHono();
|
|
47
125
|
const discoveryRoute = (0, import_zod_openapi.createRoute)({
|
|
48
126
|
method: "get",
|
|
49
127
|
path: "/discovery",
|
|
50
|
-
summary: "Discover Available
|
|
51
|
-
description: "Returns all
|
|
128
|
+
summary: "Discover Available Factories and Tools",
|
|
129
|
+
description: "Returns all available factories (storage, compaction, tools) for the currently active image.",
|
|
52
130
|
tags: ["discovery"],
|
|
53
131
|
responses: {
|
|
54
132
|
200: {
|
|
55
|
-
description: "Available
|
|
133
|
+
description: "Available factories grouped by category",
|
|
56
134
|
content: { "application/json": { schema: DiscoveryResponseSchema } }
|
|
57
135
|
}
|
|
58
136
|
}
|
|
59
137
|
});
|
|
60
138
|
return app.openapi(discoveryRoute, async (ctx) => {
|
|
61
|
-
|
|
62
|
-
return ctx.json(providers);
|
|
139
|
+
return ctx.json(await listDiscoveryFactories({ ctx, getAgentConfigPath }));
|
|
63
140
|
});
|
|
64
141
|
}
|
|
65
142
|
// Annotate the CommonJS export names for ESM import in node:
|