@dexto/server 1.3.0 → 1.5.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 +3 -3
- package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
- package/dist/hono/__tests__/test-fixtures.js +3 -3
- package/dist/hono/index.cjs +46 -5
- package/dist/hono/index.d.ts +928 -584
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +46 -5
- package/dist/hono/middleware/error.d.ts.map +1 -1
- package/dist/hono/routes/a2a-jsonrpc.cjs +3 -3
- package/dist/hono/routes/a2a-jsonrpc.d.ts +4 -1
- package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
- package/dist/hono/routes/a2a-jsonrpc.js +3 -3
- package/dist/hono/routes/a2a-tasks.cjs +5 -5
- package/dist/hono/routes/a2a-tasks.d.ts +13 -10
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +5 -5
- package/dist/hono/routes/agents.cjs +30 -42
- package/dist/hono/routes/agents.d.ts +7 -401
- package/dist/hono/routes/agents.d.ts.map +1 -1
- package/dist/hono/routes/agents.js +32 -42
- package/dist/hono/routes/approvals.cjs +53 -2
- package/dist/hono/routes/approvals.d.ts +29 -1
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +53 -2
- package/dist/hono/routes/discovery.cjs +67 -0
- package/dist/hono/routes/discovery.d.ts +44 -0
- package/dist/hono/routes/discovery.d.ts.map +1 -0
- package/dist/hono/routes/discovery.js +43 -0
- package/dist/hono/routes/greeting.cjs +2 -2
- package/dist/hono/routes/greeting.d.ts +2 -2
- package/dist/hono/routes/greeting.d.ts.map +1 -1
- package/dist/hono/routes/greeting.js +2 -2
- package/dist/hono/routes/health.d.ts +2 -2
- package/dist/hono/routes/health.d.ts.map +1 -1
- package/dist/hono/routes/key.cjs +110 -0
- package/dist/hono/routes/key.d.ts +48 -0
- package/dist/hono/routes/key.d.ts.map +1 -0
- package/dist/hono/routes/key.js +90 -0
- package/dist/hono/routes/llm.cjs +119 -62
- package/dist/hono/routes/llm.d.ts +242 -42
- package/dist/hono/routes/llm.d.ts.map +1 -1
- package/dist/hono/routes/llm.js +118 -58
- package/dist/hono/routes/mcp.cjs +16 -12
- package/dist/hono/routes/mcp.d.ts +6 -3
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +17 -13
- package/dist/hono/routes/memory.cjs +5 -5
- package/dist/hono/routes/memory.d.ts +5 -2
- package/dist/hono/routes/memory.d.ts.map +1 -1
- package/dist/hono/routes/memory.js +5 -5
- package/dist/hono/routes/messages.cjs +58 -66
- package/dist/hono/routes/messages.d.ts +99 -55
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +59 -67
- package/dist/hono/routes/models.cjs +319 -0
- package/dist/hono/routes/models.d.ts +107 -0
- package/dist/hono/routes/models.d.ts.map +1 -0
- package/dist/hono/routes/models.js +305 -0
- package/dist/hono/routes/openrouter.cjs +153 -0
- package/dist/hono/routes/openrouter.d.ts +54 -0
- package/dist/hono/routes/openrouter.d.ts.map +1 -0
- package/dist/hono/routes/openrouter.js +134 -0
- package/dist/hono/routes/prompts.cjs +5 -5
- package/dist/hono/routes/prompts.d.ts +10 -7
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +5 -5
- package/dist/hono/routes/queue.cjs +202 -0
- package/dist/hono/routes/queue.d.ts +174 -0
- package/dist/hono/routes/queue.d.ts.map +1 -0
- package/dist/hono/routes/queue.js +178 -0
- package/dist/hono/routes/resources.cjs +3 -3
- package/dist/hono/routes/resources.d.ts +3 -3
- package/dist/hono/routes/resources.d.ts.map +1 -1
- package/dist/hono/routes/resources.js +3 -3
- package/dist/hono/routes/search.cjs +2 -2
- package/dist/hono/routes/search.d.ts +39 -10
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +2 -2
- package/dist/hono/routes/sessions.cjs +74 -20
- package/dist/hono/routes/sessions.d.ts +25 -4
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +74 -20
- package/dist/hono/routes/tools.cjs +126 -0
- package/dist/hono/routes/tools.d.ts +42 -0
- package/dist/hono/routes/tools.d.ts.map +1 -0
- package/dist/hono/routes/tools.js +102 -0
- package/dist/hono/routes/webhooks.cjs +4 -4
- package/dist/hono/routes/webhooks.d.ts +4 -1
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +4 -4
- package/dist/hono/schemas/responses.cjs +24 -5
- package/dist/hono/schemas/responses.d.ts +838 -120
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +24 -10
- package/dist/hono/start-server.cjs +102 -0
- package/dist/hono/start-server.d.ts +61 -0
- package/dist/hono/start-server.d.ts.map +1 -0
- package/dist/hono/start-server.js +78 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/package.json +5 -4
|
@@ -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,8 +106,25 @@ function createApprovalsRouter(getAgent, approvalCoordinator) {
|
|
|
72
106
|
}
|
|
73
107
|
}
|
|
74
108
|
});
|
|
75
|
-
return app.openapi(
|
|
76
|
-
const agent = getAgent();
|
|
109
|
+
return app.openapi(getPendingApprovalsRoute, async (ctx) => {
|
|
110
|
+
const agent = await getAgent(ctx);
|
|
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) => {
|
|
127
|
+
const agent = await getAgent(ctx);
|
|
77
128
|
const { approvalId } = ctx.req.valid("param");
|
|
78
129
|
const { status, formData, rememberChoice } = ctx.req.valid("json");
|
|
79
130
|
agent.logger.info(`Received approval decision for ${approvalId}: ${status}`);
|
|
@@ -1,7 +1,34 @@
|
|
|
1
1
|
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
|
+
import type { Context } from 'hono';
|
|
5
|
+
type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
|
|
6
|
+
export declare function createApprovalsRouter(getAgent: GetAgentFn, approvalCoordinator?: ApprovalCoordinator): OpenAPIHono<import("hono").Env, {
|
|
7
|
+
"/approvals": {
|
|
8
|
+
$get: {
|
|
9
|
+
input: {
|
|
10
|
+
query: {
|
|
11
|
+
sessionId: string;
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
output: {
|
|
15
|
+
ok: true;
|
|
16
|
+
approvals: {
|
|
17
|
+
type: string;
|
|
18
|
+
metadata: {
|
|
19
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
20
|
+
};
|
|
21
|
+
timestamp: string;
|
|
22
|
+
approvalId: string;
|
|
23
|
+
sessionId?: string | undefined;
|
|
24
|
+
timeout?: number | undefined;
|
|
25
|
+
}[];
|
|
26
|
+
};
|
|
27
|
+
outputFormat: "json";
|
|
28
|
+
status: 200;
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
} & {
|
|
5
32
|
"/approvals/:approvalId": {
|
|
6
33
|
$post: {
|
|
7
34
|
input: {
|
|
@@ -86,4 +113,5 @@ export declare function createApprovalsRouter(getAgent: () => DextoAgent, approv
|
|
|
86
113
|
};
|
|
87
114
|
};
|
|
88
115
|
}, "/">;
|
|
116
|
+
export {};
|
|
89
117
|
//# sourceMappingURL=approvals.d.ts.map
|
|
@@ -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;AAClF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AA8CrE,wBAAgB,qBAAqB,CACjC,QAAQ,EAAE,UAAU,EACpB,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,8 +83,25 @@ function createApprovalsRouter(getAgent, approvalCoordinator) {
|
|
|
49
83
|
}
|
|
50
84
|
}
|
|
51
85
|
});
|
|
52
|
-
return app.openapi(
|
|
53
|
-
const agent = getAgent();
|
|
86
|
+
return app.openapi(getPendingApprovalsRoute, async (ctx) => {
|
|
87
|
+
const agent = await getAgent(ctx);
|
|
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) => {
|
|
104
|
+
const agent = await getAgent(ctx);
|
|
54
105
|
const { approvalId } = ctx.req.valid("param");
|
|
55
106
|
const { status, formData, rememberChoice } = ctx.req.valid("json");
|
|
56
107
|
agent.logger.info(`Received approval decision for ${approvalId}: ${status}`);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var discovery_exports = {};
|
|
20
|
+
__export(discovery_exports, {
|
|
21
|
+
createDiscoveryRouter: () => createDiscoveryRouter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(discovery_exports);
|
|
24
|
+
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
|
+
var import_core = require("@dexto/core");
|
|
26
|
+
const DiscoveredProviderSchema = import_zod_openapi.z.object({
|
|
27
|
+
type: import_zod_openapi.z.string().describe('Provider type identifier (e.g., "local", "s3", "reactive-overflow")'),
|
|
28
|
+
category: import_zod_openapi.z.enum(["blob", "compaction", "customTools"]).describe("Provider category"),
|
|
29
|
+
metadata: import_zod_openapi.z.object({
|
|
30
|
+
displayName: import_zod_openapi.z.string().optional().describe("Human-readable display name"),
|
|
31
|
+
description: import_zod_openapi.z.string().optional().describe("Provider description")
|
|
32
|
+
}).passthrough().optional().describe("Optional metadata about the provider")
|
|
33
|
+
}).describe("Information about a registered provider");
|
|
34
|
+
const InternalToolSchema = import_zod_openapi.z.object({
|
|
35
|
+
name: import_zod_openapi.z.string().describe('Internal tool name identifier (e.g., "search_history", "ask_user")'),
|
|
36
|
+
description: import_zod_openapi.z.string().describe("Human-readable description of what the tool does")
|
|
37
|
+
}).describe("Information about an internal tool");
|
|
38
|
+
const DiscoveryResponseSchema = import_zod_openapi.z.object({
|
|
39
|
+
blob: import_zod_openapi.z.array(DiscoveredProviderSchema).describe("Blob storage providers"),
|
|
40
|
+
compaction: import_zod_openapi.z.array(DiscoveredProviderSchema).describe("Compaction strategy providers"),
|
|
41
|
+
customTools: import_zod_openapi.z.array(DiscoveredProviderSchema).describe("Custom tool providers"),
|
|
42
|
+
internalTools: import_zod_openapi.z.array(InternalToolSchema).describe("Internal tools available for configuration")
|
|
43
|
+
}).describe("Discovery response with providers grouped by category");
|
|
44
|
+
function createDiscoveryRouter() {
|
|
45
|
+
const app = new import_zod_openapi.OpenAPIHono();
|
|
46
|
+
const discoveryRoute = (0, import_zod_openapi.createRoute)({
|
|
47
|
+
method: "get",
|
|
48
|
+
path: "/discovery",
|
|
49
|
+
summary: "Discover Available Providers and Tools",
|
|
50
|
+
description: "Returns all registered providers (blob storage, compaction, custom tools) and available internal tools. Useful for building UIs that need to display configurable options.",
|
|
51
|
+
tags: ["discovery"],
|
|
52
|
+
responses: {
|
|
53
|
+
200: {
|
|
54
|
+
description: "Available providers grouped by category",
|
|
55
|
+
content: { "application/json": { schema: DiscoveryResponseSchema } }
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
return app.openapi(discoveryRoute, async (ctx) => {
|
|
60
|
+
const providers = (0, import_core.listAllProviders)();
|
|
61
|
+
return ctx.json(providers);
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
65
|
+
0 && (module.exports = {
|
|
66
|
+
createDiscoveryRouter
|
|
67
|
+
});
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
+
export declare function createDiscoveryRouter(): OpenAPIHono<import("hono").Env, {
|
|
3
|
+
"/discovery": {
|
|
4
|
+
$get: {
|
|
5
|
+
input: {};
|
|
6
|
+
output: {
|
|
7
|
+
internalTools: {
|
|
8
|
+
description: string;
|
|
9
|
+
name: string;
|
|
10
|
+
}[];
|
|
11
|
+
customTools: {
|
|
12
|
+
type: string;
|
|
13
|
+
category: "customTools" | "compaction" | "blob";
|
|
14
|
+
metadata?: {
|
|
15
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
16
|
+
description?: string | undefined;
|
|
17
|
+
displayName?: string | undefined;
|
|
18
|
+
} | undefined;
|
|
19
|
+
}[];
|
|
20
|
+
compaction: {
|
|
21
|
+
type: string;
|
|
22
|
+
category: "customTools" | "compaction" | "blob";
|
|
23
|
+
metadata?: {
|
|
24
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
25
|
+
description?: string | undefined;
|
|
26
|
+
displayName?: string | undefined;
|
|
27
|
+
} | undefined;
|
|
28
|
+
}[];
|
|
29
|
+
blob: {
|
|
30
|
+
type: string;
|
|
31
|
+
category: "customTools" | "compaction" | "blob";
|
|
32
|
+
metadata?: {
|
|
33
|
+
[x: string]: import("hono/utils/types").JSONValue;
|
|
34
|
+
description?: string | undefined;
|
|
35
|
+
displayName?: string | undefined;
|
|
36
|
+
} | undefined;
|
|
37
|
+
}[];
|
|
38
|
+
};
|
|
39
|
+
outputFormat: "json";
|
|
40
|
+
status: 200;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
}, "/">;
|
|
44
|
+
//# sourceMappingURL=discovery.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"discovery.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/discovery.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAwChE,wBAAgB,qBAAqB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsBpC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import { listAllProviders } from "@dexto/core";
|
|
3
|
+
const DiscoveredProviderSchema = z.object({
|
|
4
|
+
type: z.string().describe('Provider type identifier (e.g., "local", "s3", "reactive-overflow")'),
|
|
5
|
+
category: z.enum(["blob", "compaction", "customTools"]).describe("Provider category"),
|
|
6
|
+
metadata: z.object({
|
|
7
|
+
displayName: z.string().optional().describe("Human-readable display name"),
|
|
8
|
+
description: z.string().optional().describe("Provider description")
|
|
9
|
+
}).passthrough().optional().describe("Optional metadata about the provider")
|
|
10
|
+
}).describe("Information about a registered provider");
|
|
11
|
+
const InternalToolSchema = z.object({
|
|
12
|
+
name: z.string().describe('Internal tool name identifier (e.g., "search_history", "ask_user")'),
|
|
13
|
+
description: z.string().describe("Human-readable description of what the tool does")
|
|
14
|
+
}).describe("Information about an internal tool");
|
|
15
|
+
const DiscoveryResponseSchema = z.object({
|
|
16
|
+
blob: z.array(DiscoveredProviderSchema).describe("Blob storage providers"),
|
|
17
|
+
compaction: z.array(DiscoveredProviderSchema).describe("Compaction strategy providers"),
|
|
18
|
+
customTools: z.array(DiscoveredProviderSchema).describe("Custom tool providers"),
|
|
19
|
+
internalTools: z.array(InternalToolSchema).describe("Internal tools available for configuration")
|
|
20
|
+
}).describe("Discovery response with providers grouped by category");
|
|
21
|
+
function createDiscoveryRouter() {
|
|
22
|
+
const app = new OpenAPIHono();
|
|
23
|
+
const discoveryRoute = createRoute({
|
|
24
|
+
method: "get",
|
|
25
|
+
path: "/discovery",
|
|
26
|
+
summary: "Discover Available Providers and Tools",
|
|
27
|
+
description: "Returns all registered providers (blob storage, compaction, custom tools) and available internal tools. Useful for building UIs that need to display configurable options.",
|
|
28
|
+
tags: ["discovery"],
|
|
29
|
+
responses: {
|
|
30
|
+
200: {
|
|
31
|
+
description: "Available providers grouped by category",
|
|
32
|
+
content: { "application/json": { schema: DiscoveryResponseSchema } }
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
return app.openapi(discoveryRoute, async (ctx) => {
|
|
37
|
+
const providers = listAllProviders();
|
|
38
|
+
return ctx.json(providers);
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export {
|
|
42
|
+
createDiscoveryRouter
|
|
43
|
+
};
|
|
@@ -47,8 +47,8 @@ function createGreetingRouter(getAgent) {
|
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
});
|
|
50
|
-
return app.openapi(greetingRoute, (ctx) => {
|
|
51
|
-
const agent = getAgent();
|
|
50
|
+
return app.openapi(greetingRoute, async (ctx) => {
|
|
51
|
+
const agent = await getAgent(ctx);
|
|
52
52
|
const { sessionId } = ctx.req.valid("query");
|
|
53
53
|
const cfg = agent.getEffectiveConfig(sessionId);
|
|
54
54
|
return ctx.json({ greeting: cfg.greeting });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import type {
|
|
3
|
-
export declare function createGreetingRouter(getAgent:
|
|
2
|
+
import type { GetAgentFn } from '../index.js';
|
|
3
|
+
export declare function createGreetingRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
|
|
4
4
|
"/greeting": {
|
|
5
5
|
$get: {
|
|
6
6
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"greeting.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/greeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAW9C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,
|
|
1
|
+
{"version":3,"file":"greeting.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/greeting.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAW9C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;QAmCxD"}
|
|
@@ -24,8 +24,8 @@ function createGreetingRouter(getAgent) {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
});
|
|
27
|
-
return app.openapi(greetingRoute, (ctx) => {
|
|
28
|
-
const agent = getAgent();
|
|
27
|
+
return app.openapi(greetingRoute, async (ctx) => {
|
|
28
|
+
const agent = await getAgent(ctx);
|
|
29
29
|
const { sessionId } = ctx.req.valid("query");
|
|
30
30
|
const cfg = agent.getEffectiveConfig(sessionId);
|
|
31
31
|
return ctx.json({ greeting: cfg.greeting });
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import type {
|
|
2
|
+
import type { GetAgentFn } from '../index.js';
|
|
3
3
|
/**
|
|
4
4
|
* NOTE: If we introduce a transport-agnostic handler layer later, the logic in this module can move
|
|
5
5
|
* into that layer. For now we keep the implementation inline for simplicity.
|
|
6
6
|
*/
|
|
7
|
-
export declare function createHealthRouter(_getAgent:
|
|
7
|
+
export declare function createHealthRouter(_getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
|
|
8
8
|
"/": {
|
|
9
9
|
$get: {
|
|
10
10
|
input: {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"health.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/health.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,UAAU;;;;;;;;;QAiBvD"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var key_exports = {};
|
|
20
|
+
__export(key_exports, {
|
|
21
|
+
createKeyRouter: () => createKeyRouter
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(key_exports);
|
|
24
|
+
var import_zod_openapi = require("@hono/zod-openapi");
|
|
25
|
+
var import_core = require("@dexto/core");
|
|
26
|
+
var import_agent_management = require("@dexto/agent-management");
|
|
27
|
+
function maskApiKey(key) {
|
|
28
|
+
if (!key) return "";
|
|
29
|
+
if (key.length < 12) {
|
|
30
|
+
return key.slice(0, 4) + "..." + key.slice(-4);
|
|
31
|
+
}
|
|
32
|
+
return key.slice(0, 7) + "..." + key.slice(-4);
|
|
33
|
+
}
|
|
34
|
+
const GetKeyParamsSchema = import_zod_openapi.z.object({
|
|
35
|
+
provider: import_zod_openapi.z.enum(import_core.LLM_PROVIDERS).describe("LLM provider identifier")
|
|
36
|
+
}).describe("Path parameters for API key operations");
|
|
37
|
+
const SaveKeySchema = import_zod_openapi.z.object({
|
|
38
|
+
provider: import_zod_openapi.z.enum(import_core.LLM_PROVIDERS).describe("LLM provider identifier (e.g., openai, anthropic)"),
|
|
39
|
+
apiKey: import_zod_openapi.z.string().min(1, "API key is required").describe("API key for the provider (writeOnly - never returned in responses)").openapi({ writeOnly: true })
|
|
40
|
+
}).describe("Request body for saving a provider API key");
|
|
41
|
+
function createKeyRouter() {
|
|
42
|
+
const app = new import_zod_openapi.OpenAPIHono();
|
|
43
|
+
const getKeyRoute = (0, import_zod_openapi.createRoute)({
|
|
44
|
+
method: "get",
|
|
45
|
+
path: "/llm/key/{provider}",
|
|
46
|
+
summary: "Get Provider API Key Status",
|
|
47
|
+
description: "Retrieves the API key status for a provider. Returns a masked key value (e.g., sk-proj...xyz4) for UI display purposes.",
|
|
48
|
+
tags: ["llm"],
|
|
49
|
+
request: { params: GetKeyParamsSchema },
|
|
50
|
+
responses: {
|
|
51
|
+
200: {
|
|
52
|
+
description: "API key status and value",
|
|
53
|
+
content: {
|
|
54
|
+
"application/json": {
|
|
55
|
+
schema: import_zod_openapi.z.object({
|
|
56
|
+
provider: import_zod_openapi.z.enum(import_core.LLM_PROVIDERS).describe("Provider identifier"),
|
|
57
|
+
envVar: import_zod_openapi.z.string().describe("Environment variable name"),
|
|
58
|
+
hasKey: import_zod_openapi.z.boolean().describe("Whether API key is configured"),
|
|
59
|
+
keyValue: import_zod_openapi.z.string().optional().describe(
|
|
60
|
+
"Masked API key value if configured (e.g., sk-proj...xyz4)"
|
|
61
|
+
)
|
|
62
|
+
}).strict().describe("API key status response")
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
const saveKeyRoute = (0, import_zod_openapi.createRoute)({
|
|
69
|
+
method: "post",
|
|
70
|
+
path: "/llm/key",
|
|
71
|
+
summary: "Save Provider API Key",
|
|
72
|
+
description: "Stores an API key for a provider in .env and makes it available immediately",
|
|
73
|
+
tags: ["llm"],
|
|
74
|
+
request: { body: { content: { "application/json": { schema: SaveKeySchema } } } },
|
|
75
|
+
responses: {
|
|
76
|
+
200: {
|
|
77
|
+
description: "API key saved",
|
|
78
|
+
content: {
|
|
79
|
+
"application/json": {
|
|
80
|
+
schema: import_zod_openapi.z.object({
|
|
81
|
+
ok: import_zod_openapi.z.literal(true).describe("Operation success indicator"),
|
|
82
|
+
provider: import_zod_openapi.z.enum(import_core.LLM_PROVIDERS).describe("Provider for which the key was saved"),
|
|
83
|
+
envVar: import_zod_openapi.z.string().describe("Environment variable name where key was stored")
|
|
84
|
+
}).strict().describe("API key save response")
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return app.openapi(getKeyRoute, (ctx) => {
|
|
91
|
+
const { provider } = ctx.req.valid("param");
|
|
92
|
+
const keyStatus = (0, import_agent_management.getProviderKeyStatus)(provider);
|
|
93
|
+
const apiKey = (0, import_agent_management.resolveApiKeyForProvider)(provider);
|
|
94
|
+
const maskedKey = apiKey ? maskApiKey(apiKey) : void 0;
|
|
95
|
+
return ctx.json({
|
|
96
|
+
provider,
|
|
97
|
+
envVar: keyStatus.envVar,
|
|
98
|
+
hasKey: keyStatus.hasApiKey,
|
|
99
|
+
...maskedKey && { keyValue: maskedKey }
|
|
100
|
+
});
|
|
101
|
+
}).openapi(saveKeyRoute, async (ctx) => {
|
|
102
|
+
const { provider, apiKey } = ctx.req.valid("json");
|
|
103
|
+
const meta = await (0, import_agent_management.saveProviderApiKey)(provider, apiKey);
|
|
104
|
+
return ctx.json({ ok: true, provider, envVar: meta.envVar });
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
createKeyRouter
|
|
110
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* API Key Management Routes
|
|
3
|
+
*
|
|
4
|
+
* Endpoints for managing LLM provider API keys.
|
|
5
|
+
*
|
|
6
|
+
* TODO: For hosted deployments, these endpoints should integrate with a secure
|
|
7
|
+
* key management service (e.g., AWS Secrets Manager, HashiCorp Vault) rather
|
|
8
|
+
* than storing keys in local .env files.
|
|
9
|
+
*/
|
|
10
|
+
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
11
|
+
export declare function createKeyRouter(): OpenAPIHono<import("hono").Env, {
|
|
12
|
+
"/llm/key/:provider": {
|
|
13
|
+
$get: {
|
|
14
|
+
input: {
|
|
15
|
+
param: {
|
|
16
|
+
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
output: {
|
|
20
|
+
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
|
|
21
|
+
hasKey: boolean;
|
|
22
|
+
envVar: string;
|
|
23
|
+
keyValue?: string | undefined;
|
|
24
|
+
};
|
|
25
|
+
outputFormat: "json";
|
|
26
|
+
status: 200;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
} & {
|
|
30
|
+
"/llm/key": {
|
|
31
|
+
$post: {
|
|
32
|
+
input: {
|
|
33
|
+
json: {
|
|
34
|
+
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
|
|
35
|
+
apiKey: string;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
output: {
|
|
39
|
+
provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
|
|
40
|
+
ok: true;
|
|
41
|
+
envVar: string;
|
|
42
|
+
};
|
|
43
|
+
outputFormat: "json";
|
|
44
|
+
status: 200;
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}, "/">;
|
|
48
|
+
//# sourceMappingURL=key.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"key.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/key.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAuChE,wBAAgB,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAsF9B"}
|