@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.
Files changed (60) hide show
  1. package/dist/approval/manual-approval-handler.cjs +23 -15
  2. package/dist/approval/manual-approval-handler.d.ts.map +1 -1
  3. package/dist/approval/manual-approval-handler.js +23 -15
  4. package/dist/events/webhook-subscriber.cjs +1 -1
  5. package/dist/events/webhook-subscriber.d.ts.map +1 -1
  6. package/dist/events/webhook-subscriber.js +1 -1
  7. package/dist/hono/__tests__/test-fixtures.cjs +2 -2
  8. package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
  9. package/dist/hono/__tests__/test-fixtures.js +2 -2
  10. package/dist/hono/index.cjs +14 -2
  11. package/dist/hono/index.d.ts +486 -132
  12. package/dist/hono/index.d.ts.map +1 -1
  13. package/dist/hono/index.js +17 -2
  14. package/dist/hono/middleware/error.d.ts.map +1 -1
  15. package/dist/hono/routes/agents.cjs +8 -10
  16. package/dist/hono/routes/agents.d.ts +15 -8
  17. package/dist/hono/routes/agents.d.ts.map +1 -1
  18. package/dist/hono/routes/agents.js +10 -10
  19. package/dist/hono/routes/approvals.cjs +52 -1
  20. package/dist/hono/routes/approvals.d.ts +25 -0
  21. package/dist/hono/routes/approvals.d.ts.map +1 -1
  22. package/dist/hono/routes/approvals.js +52 -1
  23. package/dist/hono/routes/llm.cjs +110 -31
  24. package/dist/hono/routes/llm.d.ts +89 -37
  25. package/dist/hono/routes/llm.d.ts.map +1 -1
  26. package/dist/hono/routes/llm.js +108 -25
  27. package/dist/hono/routes/mcp.cjs +8 -4
  28. package/dist/hono/routes/mcp.d.ts +4 -1
  29. package/dist/hono/routes/mcp.d.ts.map +1 -1
  30. package/dist/hono/routes/mcp.js +9 -5
  31. package/dist/hono/routes/memory.d.ts +1 -1
  32. package/dist/hono/routes/messages.cjs +56 -64
  33. package/dist/hono/routes/messages.d.ts +101 -57
  34. package/dist/hono/routes/messages.d.ts.map +1 -1
  35. package/dist/hono/routes/messages.js +57 -65
  36. package/dist/hono/routes/prompts.cjs +2 -2
  37. package/dist/hono/routes/prompts.d.ts +7 -7
  38. package/dist/hono/routes/prompts.js +2 -2
  39. package/dist/hono/routes/queue.cjs +202 -0
  40. package/dist/hono/routes/queue.d.ts +171 -0
  41. package/dist/hono/routes/queue.d.ts.map +1 -0
  42. package/dist/hono/routes/queue.js +178 -0
  43. package/dist/hono/routes/resources.d.ts +1 -1
  44. package/dist/hono/routes/search.cjs +2 -24
  45. package/dist/hono/routes/search.d.ts +43 -15
  46. package/dist/hono/routes/search.d.ts.map +1 -1
  47. package/dist/hono/routes/search.js +3 -25
  48. package/dist/hono/routes/sessions.cjs +65 -11
  49. package/dist/hono/routes/sessions.d.ts +27 -5
  50. package/dist/hono/routes/sessions.d.ts.map +1 -1
  51. package/dist/hono/routes/sessions.js +65 -11
  52. package/dist/hono/routes/static.cjs +77 -0
  53. package/dist/hono/routes/static.d.ts +41 -0
  54. package/dist/hono/routes/static.d.ts.map +1 -0
  55. package/dist/hono/routes/static.js +52 -0
  56. package/dist/hono/schemas/responses.cjs +67 -25
  57. package/dist/hono/schemas/responses.d.ts +2076 -354
  58. package/dist/hono/schemas/responses.d.ts.map +1 -1
  59. package/dist/hono/schemas/responses.js +69 -35
  60. package/package.json +3 -3
@@ -0,0 +1,41 @@
1
+ import { Hono } from 'hono';
2
+ import type { NotFoundHandler } from 'hono';
3
+ /**
4
+ * Runtime configuration injected into WebUI via window globals.
5
+ * This replaces the Next.js SSR injection that was lost in the Vite migration.
6
+ *
7
+ * TODO: This injection only works in production mode where Hono serves index.html.
8
+ * In dev mode (`pnpm dev`), Vite serves index.html directly, bypassing this injection.
9
+ * To support dev mode analytics, add a `/api/config/analytics` endpoint that the
10
+ * WebUI can fetch as a fallback when `window.__DEXTO_ANALYTICS__` is undefined.
11
+ */
12
+ export interface WebUIRuntimeConfig {
13
+ analytics?: {
14
+ distinctId: string;
15
+ posthogKey: string;
16
+ posthogHost: string;
17
+ appVersion: string;
18
+ } | null;
19
+ }
20
+ /**
21
+ * Create a static file router for serving WebUI assets.
22
+ *
23
+ * Serves static files from the specified webRoot directory.
24
+ * Note: SPA fallback is handled separately via createSpaFallbackHandler.
25
+ *
26
+ * @param webRoot - Absolute path to the directory containing WebUI build output
27
+ */
28
+ export declare function createStaticRouter(webRoot: string): Hono<import("hono/types").BlankEnv, import("hono/types").BlankSchema, "/">;
29
+ /**
30
+ * Create a notFound handler for SPA fallback.
31
+ *
32
+ * This handler serves index.html for client-side routes (paths without file extensions).
33
+ * For paths with file extensions (like /openapi.json), it returns a standard 404.
34
+ *
35
+ * This should be registered as app.notFound() to run after all routes fail to match.
36
+ *
37
+ * @param webRoot - Absolute path to the directory containing WebUI build output
38
+ * @param runtimeConfig - Optional runtime configuration to inject into the HTML
39
+ */
40
+ export declare function createSpaFallbackHandler(webRoot: string, runtimeConfig?: WebUIRuntimeConfig): NotFoundHandler;
41
+ //# sourceMappingURL=static.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"static.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/static.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,MAAM,CAAC;AAK5C;;;;;;;;GAQG;AACH,MAAM,WAAW,kBAAkB;IAC/B,SAAS,CAAC,EAAE;QACR,UAAU,EAAE,MAAM,CAAC;QACnB,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC;KACtB,GAAG,IAAI,CAAC;CACZ;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,MAAM,8EAajD;AAmBD;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACpC,OAAO,EAAE,MAAM,EACf,aAAa,CAAC,EAAE,kBAAkB,GACnC,eAAe,CAuCjB"}
@@ -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,13 +45,17 @@ __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,
58
+ UIResourcePartSchema: () => UIResourcePartSchema,
51
59
  WebhookSchema: () => WebhookSchema
52
60
  });
53
61
  module.exports = __toCommonJS(responses_exports);
@@ -59,39 +67,41 @@ var import_core4 = require("@dexto/core");
59
67
  var import_core5 = require("@dexto/core");
60
68
  var import_core6 = require("@dexto/core");
61
69
  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
70
  const TextPartSchema = import_zod.z.object({
80
71
  type: import_zod.z.literal("text").describe("Part type: text"),
81
72
  text: import_zod.z.string().describe("Text content")
82
73
  }).strict().describe("Text content part");
83
74
  const ImagePartSchema = import_zod.z.object({
84
75
  type: import_zod.z.literal("image").describe("Part type: image"),
85
- image: BinaryDataSchema.describe("Image data (string, binary, or URL)"),
76
+ image: import_zod.z.string().describe("Base64-encoded image data"),
86
77
  mimeType: import_zod.z.string().optional().describe("MIME type of the image")
87
78
  }).strict().describe("Image content part");
88
79
  const FilePartSchema = import_zod.z.object({
89
80
  type: import_zod.z.literal("file").describe("Part type: file"),
90
- data: BinaryDataSchema.describe("File data (string, binary, or URL)"),
81
+ data: import_zod.z.string().describe("Base64-encoded file data"),
91
82
  mimeType: import_zod.z.string().describe("MIME type of the file"),
92
83
  filename: import_zod.z.string().optional().describe("Optional filename")
93
84
  }).strict().describe("File content part");
94
- const ContentPartSchema = import_zod.z.discriminatedUnion("type", [TextPartSchema, ImagePartSchema, FilePartSchema]).describe("Message content part (text, image, or file)");
85
+ const UIResourcePartSchema = import_zod.z.object({
86
+ type: import_zod.z.literal("ui-resource").describe("Part type: ui-resource"),
87
+ uri: import_zod.z.string().describe("URI identifying the UI resource (must start with ui://)"),
88
+ mimeType: import_zod.z.string().describe("MIME type: text/html, text/uri-list, or application/vnd.mcp-ui.remote-dom"),
89
+ content: import_zod.z.string().optional().describe("Inline HTML content or URL"),
90
+ blob: import_zod.z.string().optional().describe("Base64-encoded content (alternative to content)"),
91
+ metadata: import_zod.z.object({
92
+ title: import_zod.z.string().optional().describe("Display title for the UI resource"),
93
+ preferredSize: import_zod.z.object({
94
+ width: import_zod.z.number().describe("Preferred width in pixels"),
95
+ height: import_zod.z.number().describe("Preferred height in pixels")
96
+ }).strict().optional().describe("Preferred rendering size")
97
+ }).strict().optional().describe("Optional metadata for the UI resource")
98
+ }).strict().describe("UI Resource content part for MCP-UI interactive components");
99
+ const ContentPartSchema = import_zod.z.discriminatedUnion("type", [
100
+ TextPartSchema,
101
+ ImagePartSchema,
102
+ FilePartSchema,
103
+ UIResourcePartSchema
104
+ ]).describe("Message content part (text, image, file, or UI resource)");
95
105
  const ToolCallSchema = import_zod.z.object({
96
106
  id: import_zod.z.string().describe("Unique identifier for this tool call"),
97
107
  type: import_zod.z.literal("function").describe("Tool call type (currently only function is supported)"),
@@ -107,18 +117,30 @@ const TokenUsageSchema = import_zod.z.object({
107
117
  totalTokens: import_zod.z.number().int().nonnegative().optional().describe("Total tokens used")
108
118
  }).strict().describe("Token usage accounting");
109
119
  const InternalMessageSchema = import_zod.z.object({
120
+ id: import_zod.z.string().uuid().optional().describe("Unique message identifier (UUID)"),
110
121
  role: import_zod.z.enum(["system", "user", "assistant", "tool"]).describe("Role of the message sender"),
111
122
  timestamp: import_zod.z.number().int().positive().optional().describe("Creation timestamp (Unix ms)"),
112
123
  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
124
  reasoning: import_zod.z.string().optional().describe("Optional model reasoning text"),
114
125
  tokenUsage: TokenUsageSchema.optional().describe("Optional token usage accounting"),
115
126
  model: import_zod.z.string().optional().describe("Model identifier for assistant messages"),
116
- provider: import_zod.z.string().optional().describe("Provider identifier for assistant messages"),
117
- router: import_zod.z.string().optional().describe("Router metadata for assistant messages"),
127
+ provider: import_zod.z.enum(import_core.LLM_PROVIDERS).optional().describe("Provider identifier for assistant messages"),
118
128
  toolCalls: import_zod.z.array(ToolCallSchema).optional().describe("Tool calls made by the assistant"),
119
129
  toolCallId: import_zod.z.string().optional().describe("ID of the tool call this message responds to"),
120
- name: import_zod.z.string().optional().describe("Name of the tool that produced this result")
130
+ name: import_zod.z.string().optional().describe("Name of the tool that produced this result"),
131
+ success: import_zod.z.boolean().optional().describe("Whether tool execution succeeded (present for role=tool messages)")
121
132
  }).strict().describe("Internal message representation");
133
+ const LLMConfigResponseSchema = import_core.LLMConfigBaseSchema.omit({ apiKey: true }).extend({
134
+ hasApiKey: import_zod.z.boolean().optional().describe("Whether an API key is configured")
135
+ }).describe("LLM configuration (apiKey omitted for security)");
136
+ const LLMConfigSchema = import_core.LLMConfigBaseSchema.describe("LLM configuration with API key");
137
+ const SessionMetadataSchema = import_zod.z.object({
138
+ id: import_zod.z.string().describe("Unique session identifier"),
139
+ createdAt: import_zod.z.number().int().positive().nullable().describe("Creation timestamp (Unix ms, null if unavailable)"),
140
+ lastActivity: import_zod.z.number().int().positive().nullable().describe("Last activity timestamp (Unix ms, null if unavailable)"),
141
+ messageCount: import_zod.z.number().int().nonnegative().describe("Total number of messages in session"),
142
+ title: import_zod.z.string().optional().nullable().describe("Optional session title")
143
+ }).strict().describe("Session metadata");
122
144
  const SearchResultSchema = import_zod.z.object({
123
145
  sessionId: import_zod.z.string().describe("Session ID where the message was found"),
124
146
  message: InternalMessageSchema.describe("The message that matched the search"),
@@ -136,6 +158,20 @@ const SessionSearchResultSchema = import_zod.z.object({
136
158
  messageCount: import_zod.z.number().int().nonnegative().describe("Total messages in session")
137
159
  }).strict().describe("Session metadata")
138
160
  }).strict().describe("Result of a session search");
161
+ const MessageSearchResponseSchema = import_zod.z.object({
162
+ results: import_zod.z.array(SearchResultSchema).describe("Array of search results"),
163
+ total: import_zod.z.number().int().nonnegative().describe("Total number of results available"),
164
+ hasMore: import_zod.z.boolean().describe("Whether there are more results beyond the current page"),
165
+ query: import_zod.z.string().describe("Query that was searched")
166
+ }).strict().describe("Message search response");
167
+ const SessionSearchResponseSchema = import_zod.z.object({
168
+ results: import_zod.z.array(SessionSearchResultSchema).describe("Array of session search results"),
169
+ total: import_zod.z.number().int().nonnegative().describe("Total number of sessions with matches"),
170
+ hasMore: import_zod.z.boolean().describe(
171
+ "Always false - session search returns all matching sessions without pagination"
172
+ ),
173
+ query: import_zod.z.string().describe("Query that was searched")
174
+ }).strict().describe("Session search response");
139
175
  const WebhookSchema = import_zod.z.object({
140
176
  id: import_zod.z.string().describe("Unique webhook identifier"),
141
177
  url: import_zod.z.string().url().describe("Webhook URL to send events to"),
@@ -147,7 +183,6 @@ const CatalogModelInfoSchema = import_zod.z.object({
147
183
  maxInputTokens: import_zod.z.number().int().positive().describe("Maximum input tokens"),
148
184
  default: import_zod.z.boolean().optional().describe("Whether this is a default model"),
149
185
  supportedFileTypes: import_zod.z.array(import_zod.z.enum(["audio", "pdf", "image"])).describe("File types this model supports"),
150
- supportedRouters: import_zod.z.array(import_zod.z.enum(["vercel", "in-built"])).optional().describe("Routing strategies this model supports"),
151
186
  displayName: import_zod.z.string().optional().describe("Human-readable display name"),
152
187
  pricing: import_zod.z.object({
153
188
  inputPerM: import_zod.z.number().describe("Input cost per million tokens (USD)"),
@@ -162,7 +197,6 @@ const ProviderCatalogSchema = import_zod.z.object({
162
197
  name: import_zod.z.string().describe("Provider display name"),
163
198
  hasApiKey: import_zod.z.boolean().describe("Whether API key is configured"),
164
199
  primaryEnvVar: import_zod.z.string().describe("Primary environment variable for API key"),
165
- supportedRouters: import_zod.z.array(import_zod.z.enum(["vercel", "in-built"])).describe("Routing strategies supported by this provider"),
166
200
  supportsBaseURL: import_zod.z.boolean().describe("Whether custom base URLs are supported"),
167
201
  models: import_zod.z.array(CatalogModelInfoSchema).describe("Models available from this provider"),
168
202
  supportedFileTypes: import_zod.z.array(import_zod.z.enum(["audio", "pdf", "image"])).describe("Provider-level file type support")
@@ -245,9 +279,12 @@ const DeleteResponseSchema = import_zod.z.object({
245
279
  AgentCardSchema,
246
280
  AgentRegistryEntrySchema,
247
281
  CatalogModelInfoSchema,
282
+ ContentPartSchema,
248
283
  DeleteResponseSchema,
249
284
  ErrorResponseSchema,
285
+ FilePartSchema,
250
286
  HttpServerConfigSchema,
287
+ ImagePartSchema,
251
288
  InternalMessageSchema,
252
289
  InternalResourceConfigSchema,
253
290
  LLMConfigBaseSchema,
@@ -255,6 +292,7 @@ const DeleteResponseSchema = import_zod.z.object({
255
292
  LLMConfigSchema,
256
293
  McpServerConfigSchema,
257
294
  MemorySchema,
295
+ MessageSearchResponseSchema,
258
296
  ModelFlatSchema,
259
297
  OkResponseSchema,
260
298
  PromptArgumentSchema,
@@ -265,12 +303,16 @@ const DeleteResponseSchema = import_zod.z.object({
265
303
  ResourceSchema,
266
304
  SearchResultSchema,
267
305
  SessionMetadataSchema,
306
+ SessionSearchResponseSchema,
268
307
  SessionSearchResultSchema,
269
308
  SseServerConfigSchema,
270
309
  StatusResponseSchema,
271
310
  StdioServerConfigSchema,
311
+ TextPartSchema,
272
312
  TokenUsageSchema,
313
+ ToolCallSchema,
273
314
  ToolConfirmationConfigSchema,
274
315
  ToolSchema,
316
+ UIResourcePartSchema,
275
317
  WebhookSchema
276
318
  });