@dexto/server 1.2.6 → 1.3.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/hono/index.cjs +8 -1
- package/dist/hono/index.d.ts +59 -50
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/index.js +11 -1
- package/dist/hono/routes/llm.d.ts +19 -19
- package/dist/hono/routes/messages.cjs +10 -10
- package/dist/hono/routes/messages.d.ts +15 -15
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +10 -10
- package/dist/hono/routes/prompts.cjs +2 -2
- package/dist/hono/routes/prompts.d.ts +1 -1
- package/dist/hono/routes/prompts.js +2 -2
- package/dist/hono/routes/search.cjs +2 -24
- package/dist/hono/routes/search.d.ts +12 -10
- package/dist/hono/routes/search.d.ts.map +1 -1
- package/dist/hono/routes/search.js +3 -25
- package/dist/hono/routes/sessions.d.ts +6 -5
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- 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 +44 -21
- package/dist/hono/schemas/responses.d.ts +1202 -198
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +51 -31
- package/package.json +3 -3
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { Hono } from "hono";
|
|
2
|
+
import { serveStatic } from "@hono/node-server/serve-static";
|
|
3
|
+
import { readFile } from "node:fs/promises";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
function createStaticRouter(webRoot) {
|
|
6
|
+
const app = new Hono();
|
|
7
|
+
app.use("/assets/*", serveStatic({ root: webRoot }));
|
|
8
|
+
app.use("/logos/*", serveStatic({ root: webRoot }));
|
|
9
|
+
app.use("/favicon.ico", serveStatic({ root: webRoot }));
|
|
10
|
+
return app;
|
|
11
|
+
}
|
|
12
|
+
function buildInjectionScript(config) {
|
|
13
|
+
const scripts = [];
|
|
14
|
+
if (config.analytics) {
|
|
15
|
+
const safeJson = JSON.stringify(config.analytics).replace(/</g, "\\u003c");
|
|
16
|
+
scripts.push(`window.__DEXTO_ANALYTICS__ = ${safeJson};`);
|
|
17
|
+
}
|
|
18
|
+
if (scripts.length === 0) return "";
|
|
19
|
+
return `<script>${scripts.join("\n")}</script>`;
|
|
20
|
+
}
|
|
21
|
+
function createSpaFallbackHandler(webRoot, runtimeConfig) {
|
|
22
|
+
const injectionScript = runtimeConfig ? buildInjectionScript(runtimeConfig) : "";
|
|
23
|
+
return async (c) => {
|
|
24
|
+
const path = c.req.path;
|
|
25
|
+
if (/\.[a-zA-Z0-9]+$/.test(path)) {
|
|
26
|
+
return c.json({ error: "Not Found", path }, 404);
|
|
27
|
+
}
|
|
28
|
+
try {
|
|
29
|
+
let html = await readFile(join(webRoot, "index.html"), "utf-8");
|
|
30
|
+
if (injectionScript) {
|
|
31
|
+
html = html.replace("</head>", `${injectionScript}</head>`);
|
|
32
|
+
}
|
|
33
|
+
return c.html(html);
|
|
34
|
+
} catch {
|
|
35
|
+
return c.html(
|
|
36
|
+
`<!DOCTYPE html>
|
|
37
|
+
<html>
|
|
38
|
+
<head><title>Dexto API Server</title></head>
|
|
39
|
+
<body>
|
|
40
|
+
<h1>Dexto API Server</h1>
|
|
41
|
+
<p>WebUI is not available. API endpoints are accessible at <code>/api/*</code></p>
|
|
42
|
+
</body>
|
|
43
|
+
</html>`,
|
|
44
|
+
200
|
|
45
|
+
);
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export {
|
|
50
|
+
createSpaFallbackHandler,
|
|
51
|
+
createStaticRouter
|
|
52
|
+
};
|
|
@@ -21,9 +21,12 @@ __export(responses_exports, {
|
|
|
21
21
|
AgentCardSchema: () => import_core4.AgentCardSchema,
|
|
22
22
|
AgentRegistryEntrySchema: () => AgentRegistryEntrySchema,
|
|
23
23
|
CatalogModelInfoSchema: () => CatalogModelInfoSchema,
|
|
24
|
+
ContentPartSchema: () => ContentPartSchema,
|
|
24
25
|
DeleteResponseSchema: () => DeleteResponseSchema,
|
|
25
26
|
ErrorResponseSchema: () => ErrorResponseSchema,
|
|
27
|
+
FilePartSchema: () => FilePartSchema,
|
|
26
28
|
HttpServerConfigSchema: () => import_core5.HttpServerConfigSchema,
|
|
29
|
+
ImagePartSchema: () => ImagePartSchema,
|
|
27
30
|
InternalMessageSchema: () => InternalMessageSchema,
|
|
28
31
|
InternalResourceConfigSchema: () => import_core7.InternalResourceConfigSchema,
|
|
29
32
|
LLMConfigBaseSchema: () => import_core3.LLMConfigBaseSchema,
|
|
@@ -31,6 +34,7 @@ __export(responses_exports, {
|
|
|
31
34
|
LLMConfigSchema: () => LLMConfigSchema,
|
|
32
35
|
McpServerConfigSchema: () => import_core5.McpServerConfigSchema,
|
|
33
36
|
MemorySchema: () => import_core2.MemorySchema,
|
|
37
|
+
MessageSearchResponseSchema: () => MessageSearchResponseSchema,
|
|
34
38
|
ModelFlatSchema: () => ModelFlatSchema,
|
|
35
39
|
OkResponseSchema: () => OkResponseSchema,
|
|
36
40
|
PromptArgumentSchema: () => PromptArgumentSchema,
|
|
@@ -41,11 +45,14 @@ __export(responses_exports, {
|
|
|
41
45
|
ResourceSchema: () => ResourceSchema,
|
|
42
46
|
SearchResultSchema: () => SearchResultSchema,
|
|
43
47
|
SessionMetadataSchema: () => SessionMetadataSchema,
|
|
48
|
+
SessionSearchResponseSchema: () => SessionSearchResponseSchema,
|
|
44
49
|
SessionSearchResultSchema: () => SessionSearchResultSchema,
|
|
45
50
|
SseServerConfigSchema: () => import_core5.SseServerConfigSchema,
|
|
46
51
|
StatusResponseSchema: () => StatusResponseSchema,
|
|
47
52
|
StdioServerConfigSchema: () => import_core5.StdioServerConfigSchema,
|
|
53
|
+
TextPartSchema: () => TextPartSchema,
|
|
48
54
|
TokenUsageSchema: () => TokenUsageSchema,
|
|
55
|
+
ToolCallSchema: () => ToolCallSchema,
|
|
49
56
|
ToolConfirmationConfigSchema: () => import_core6.ToolConfirmationConfigSchema,
|
|
50
57
|
ToolSchema: () => ToolSchema,
|
|
51
58
|
WebhookSchema: () => WebhookSchema
|
|
@@ -59,35 +66,18 @@ var import_core4 = require("@dexto/core");
|
|
|
59
66
|
var import_core5 = require("@dexto/core");
|
|
60
67
|
var import_core6 = require("@dexto/core");
|
|
61
68
|
var import_core7 = require("@dexto/core");
|
|
62
|
-
const LLMConfigResponseSchema = import_core.LLMConfigBaseSchema.omit({ apiKey: true }).extend({
|
|
63
|
-
hasApiKey: import_zod.z.boolean().optional().describe("Whether an API key is configured")
|
|
64
|
-
}).describe("LLM configuration (apiKey omitted for security)");
|
|
65
|
-
const LLMConfigSchema = import_core.LLMConfigBaseSchema.describe("LLM configuration with API key");
|
|
66
|
-
const BinaryDataSchema = import_zod.z.custom(
|
|
67
|
-
(val) => {
|
|
68
|
-
return typeof val === "string" || val instanceof Buffer || val instanceof Uint8Array || val instanceof URL;
|
|
69
|
-
},
|
|
70
|
-
{ message: "Must be string, Buffer, Uint8Array, or URL" }
|
|
71
|
-
);
|
|
72
|
-
const SessionMetadataSchema = import_zod.z.object({
|
|
73
|
-
id: import_zod.z.string().describe("Unique session identifier"),
|
|
74
|
-
createdAt: import_zod.z.number().int().positive().nullable().describe("Creation timestamp (Unix ms, null if unavailable)"),
|
|
75
|
-
lastActivity: import_zod.z.number().int().positive().nullable().describe("Last activity timestamp (Unix ms, null if unavailable)"),
|
|
76
|
-
messageCount: import_zod.z.number().int().nonnegative().describe("Total number of messages in session"),
|
|
77
|
-
title: import_zod.z.string().optional().nullable().describe("Optional session title")
|
|
78
|
-
}).strict().describe("Session metadata");
|
|
79
69
|
const TextPartSchema = import_zod.z.object({
|
|
80
70
|
type: import_zod.z.literal("text").describe("Part type: text"),
|
|
81
71
|
text: import_zod.z.string().describe("Text content")
|
|
82
72
|
}).strict().describe("Text content part");
|
|
83
73
|
const ImagePartSchema = import_zod.z.object({
|
|
84
74
|
type: import_zod.z.literal("image").describe("Part type: image"),
|
|
85
|
-
image:
|
|
75
|
+
image: import_zod.z.string().describe("Base64-encoded image data"),
|
|
86
76
|
mimeType: import_zod.z.string().optional().describe("MIME type of the image")
|
|
87
77
|
}).strict().describe("Image content part");
|
|
88
78
|
const FilePartSchema = import_zod.z.object({
|
|
89
79
|
type: import_zod.z.literal("file").describe("Part type: file"),
|
|
90
|
-
data:
|
|
80
|
+
data: import_zod.z.string().describe("Base64-encoded file data"),
|
|
91
81
|
mimeType: import_zod.z.string().describe("MIME type of the file"),
|
|
92
82
|
filename: import_zod.z.string().optional().describe("Optional filename")
|
|
93
83
|
}).strict().describe("File content part");
|
|
@@ -107,18 +97,30 @@ const TokenUsageSchema = import_zod.z.object({
|
|
|
107
97
|
totalTokens: import_zod.z.number().int().nonnegative().optional().describe("Total tokens used")
|
|
108
98
|
}).strict().describe("Token usage accounting");
|
|
109
99
|
const InternalMessageSchema = import_zod.z.object({
|
|
100
|
+
id: import_zod.z.string().uuid().optional().describe("Unique message identifier (UUID)"),
|
|
110
101
|
role: import_zod.z.enum(["system", "user", "assistant", "tool"]).describe("Role of the message sender"),
|
|
111
102
|
timestamp: import_zod.z.number().int().positive().optional().describe("Creation timestamp (Unix ms)"),
|
|
112
103
|
content: import_zod.z.union([import_zod.z.string(), import_zod.z.null(), import_zod.z.array(ContentPartSchema)]).describe("Message content (string, null, or array of parts)"),
|
|
113
104
|
reasoning: import_zod.z.string().optional().describe("Optional model reasoning text"),
|
|
114
105
|
tokenUsage: TokenUsageSchema.optional().describe("Optional token usage accounting"),
|
|
115
106
|
model: import_zod.z.string().optional().describe("Model identifier for assistant messages"),
|
|
116
|
-
provider: import_zod.z.
|
|
117
|
-
router: import_zod.z.
|
|
107
|
+
provider: import_zod.z.enum(import_core.LLM_PROVIDERS).optional().describe("Provider identifier for assistant messages"),
|
|
108
|
+
router: import_zod.z.enum(import_core.LLM_ROUTERS).optional().describe("Router metadata for assistant messages"),
|
|
118
109
|
toolCalls: import_zod.z.array(ToolCallSchema).optional().describe("Tool calls made by the assistant"),
|
|
119
110
|
toolCallId: import_zod.z.string().optional().describe("ID of the tool call this message responds to"),
|
|
120
111
|
name: import_zod.z.string().optional().describe("Name of the tool that produced this result")
|
|
121
112
|
}).strict().describe("Internal message representation");
|
|
113
|
+
const LLMConfigResponseSchema = import_core.LLMConfigBaseSchema.omit({ apiKey: true }).extend({
|
|
114
|
+
hasApiKey: import_zod.z.boolean().optional().describe("Whether an API key is configured")
|
|
115
|
+
}).describe("LLM configuration (apiKey omitted for security)");
|
|
116
|
+
const LLMConfigSchema = import_core.LLMConfigBaseSchema.describe("LLM configuration with API key");
|
|
117
|
+
const SessionMetadataSchema = import_zod.z.object({
|
|
118
|
+
id: import_zod.z.string().describe("Unique session identifier"),
|
|
119
|
+
createdAt: import_zod.z.number().int().positive().nullable().describe("Creation timestamp (Unix ms, null if unavailable)"),
|
|
120
|
+
lastActivity: import_zod.z.number().int().positive().nullable().describe("Last activity timestamp (Unix ms, null if unavailable)"),
|
|
121
|
+
messageCount: import_zod.z.number().int().nonnegative().describe("Total number of messages in session"),
|
|
122
|
+
title: import_zod.z.string().optional().nullable().describe("Optional session title")
|
|
123
|
+
}).strict().describe("Session metadata");
|
|
122
124
|
const SearchResultSchema = import_zod.z.object({
|
|
123
125
|
sessionId: import_zod.z.string().describe("Session ID where the message was found"),
|
|
124
126
|
message: InternalMessageSchema.describe("The message that matched the search"),
|
|
@@ -136,6 +138,20 @@ const SessionSearchResultSchema = import_zod.z.object({
|
|
|
136
138
|
messageCount: import_zod.z.number().int().nonnegative().describe("Total messages in session")
|
|
137
139
|
}).strict().describe("Session metadata")
|
|
138
140
|
}).strict().describe("Result of a session search");
|
|
141
|
+
const MessageSearchResponseSchema = import_zod.z.object({
|
|
142
|
+
results: import_zod.z.array(SearchResultSchema).describe("Array of search results"),
|
|
143
|
+
total: import_zod.z.number().int().nonnegative().describe("Total number of results available"),
|
|
144
|
+
hasMore: import_zod.z.boolean().describe("Whether there are more results beyond the current page"),
|
|
145
|
+
query: import_zod.z.string().describe("Query that was searched")
|
|
146
|
+
}).strict().describe("Message search response");
|
|
147
|
+
const SessionSearchResponseSchema = import_zod.z.object({
|
|
148
|
+
results: import_zod.z.array(SessionSearchResultSchema).describe("Array of session search results"),
|
|
149
|
+
total: import_zod.z.number().int().nonnegative().describe("Total number of sessions with matches"),
|
|
150
|
+
hasMore: import_zod.z.boolean().describe(
|
|
151
|
+
"Always false - session search returns all matching sessions without pagination"
|
|
152
|
+
),
|
|
153
|
+
query: import_zod.z.string().describe("Query that was searched")
|
|
154
|
+
}).strict().describe("Session search response");
|
|
139
155
|
const WebhookSchema = import_zod.z.object({
|
|
140
156
|
id: import_zod.z.string().describe("Unique webhook identifier"),
|
|
141
157
|
url: import_zod.z.string().url().describe("Webhook URL to send events to"),
|
|
@@ -245,9 +261,12 @@ const DeleteResponseSchema = import_zod.z.object({
|
|
|
245
261
|
AgentCardSchema,
|
|
246
262
|
AgentRegistryEntrySchema,
|
|
247
263
|
CatalogModelInfoSchema,
|
|
264
|
+
ContentPartSchema,
|
|
248
265
|
DeleteResponseSchema,
|
|
249
266
|
ErrorResponseSchema,
|
|
267
|
+
FilePartSchema,
|
|
250
268
|
HttpServerConfigSchema,
|
|
269
|
+
ImagePartSchema,
|
|
251
270
|
InternalMessageSchema,
|
|
252
271
|
InternalResourceConfigSchema,
|
|
253
272
|
LLMConfigBaseSchema,
|
|
@@ -255,6 +274,7 @@ const DeleteResponseSchema = import_zod.z.object({
|
|
|
255
274
|
LLMConfigSchema,
|
|
256
275
|
McpServerConfigSchema,
|
|
257
276
|
MemorySchema,
|
|
277
|
+
MessageSearchResponseSchema,
|
|
258
278
|
ModelFlatSchema,
|
|
259
279
|
OkResponseSchema,
|
|
260
280
|
PromptArgumentSchema,
|
|
@@ -265,11 +285,14 @@ const DeleteResponseSchema = import_zod.z.object({
|
|
|
265
285
|
ResourceSchema,
|
|
266
286
|
SearchResultSchema,
|
|
267
287
|
SessionMetadataSchema,
|
|
288
|
+
SessionSearchResponseSchema,
|
|
268
289
|
SessionSearchResultSchema,
|
|
269
290
|
SseServerConfigSchema,
|
|
270
291
|
StatusResponseSchema,
|
|
271
292
|
StdioServerConfigSchema,
|
|
293
|
+
TextPartSchema,
|
|
272
294
|
TokenUsageSchema,
|
|
295
|
+
ToolCallSchema,
|
|
273
296
|
ToolConfirmationConfigSchema,
|
|
274
297
|
ToolSchema,
|
|
275
298
|
WebhookSchema
|