@dexto/server 1.4.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.
Files changed (99) hide show
  1. package/dist/hono/__tests__/test-fixtures.cjs +1 -1
  2. package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
  3. package/dist/hono/__tests__/test-fixtures.js +1 -1
  4. package/dist/hono/index.cjs +41 -5
  5. package/dist/hono/index.d.ts +451 -452
  6. package/dist/hono/index.d.ts.map +1 -1
  7. package/dist/hono/index.js +41 -5
  8. package/dist/hono/routes/a2a-jsonrpc.cjs +3 -3
  9. package/dist/hono/routes/a2a-jsonrpc.d.ts +4 -1
  10. package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
  11. package/dist/hono/routes/a2a-jsonrpc.js +3 -3
  12. package/dist/hono/routes/a2a-tasks.cjs +5 -5
  13. package/dist/hono/routes/a2a-tasks.d.ts +13 -10
  14. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
  15. package/dist/hono/routes/a2a-tasks.js +5 -5
  16. package/dist/hono/routes/agents.cjs +25 -35
  17. package/dist/hono/routes/agents.d.ts +6 -407
  18. package/dist/hono/routes/agents.d.ts.map +1 -1
  19. package/dist/hono/routes/agents.js +25 -35
  20. package/dist/hono/routes/approvals.cjs +2 -2
  21. package/dist/hono/routes/approvals.d.ts +4 -1
  22. package/dist/hono/routes/approvals.d.ts.map +1 -1
  23. package/dist/hono/routes/approvals.js +2 -2
  24. package/dist/hono/routes/discovery.cjs +67 -0
  25. package/dist/hono/routes/discovery.d.ts +44 -0
  26. package/dist/hono/routes/discovery.d.ts.map +1 -0
  27. package/dist/hono/routes/discovery.js +43 -0
  28. package/dist/hono/routes/greeting.cjs +2 -2
  29. package/dist/hono/routes/greeting.d.ts +2 -2
  30. package/dist/hono/routes/greeting.d.ts.map +1 -1
  31. package/dist/hono/routes/greeting.js +2 -2
  32. package/dist/hono/routes/health.d.ts +2 -2
  33. package/dist/hono/routes/health.d.ts.map +1 -1
  34. package/dist/hono/routes/key.cjs +110 -0
  35. package/dist/hono/routes/key.d.ts +48 -0
  36. package/dist/hono/routes/key.d.ts.map +1 -0
  37. package/dist/hono/routes/key.js +90 -0
  38. package/dist/hono/routes/llm.cjs +12 -34
  39. package/dist/hono/routes/llm.d.ts +173 -25
  40. package/dist/hono/routes/llm.d.ts.map +1 -1
  41. package/dist/hono/routes/llm.js +12 -35
  42. package/dist/hono/routes/mcp.cjs +8 -8
  43. package/dist/hono/routes/mcp.d.ts +2 -2
  44. package/dist/hono/routes/mcp.d.ts.map +1 -1
  45. package/dist/hono/routes/mcp.js +8 -8
  46. package/dist/hono/routes/memory.cjs +5 -5
  47. package/dist/hono/routes/memory.d.ts +4 -1
  48. package/dist/hono/routes/memory.d.ts.map +1 -1
  49. package/dist/hono/routes/memory.js +5 -5
  50. package/dist/hono/routes/messages.cjs +4 -4
  51. package/dist/hono/routes/messages.d.ts +12 -12
  52. package/dist/hono/routes/messages.d.ts.map +1 -1
  53. package/dist/hono/routes/messages.js +4 -4
  54. package/dist/hono/routes/models.cjs +319 -0
  55. package/dist/hono/routes/models.d.ts +107 -0
  56. package/dist/hono/routes/models.d.ts.map +1 -0
  57. package/dist/hono/routes/models.js +305 -0
  58. package/dist/hono/routes/openrouter.cjs +153 -0
  59. package/dist/hono/routes/openrouter.d.ts +54 -0
  60. package/dist/hono/routes/openrouter.d.ts.map +1 -0
  61. package/dist/hono/routes/openrouter.js +134 -0
  62. package/dist/hono/routes/prompts.cjs +5 -5
  63. package/dist/hono/routes/prompts.d.ts +4 -1
  64. package/dist/hono/routes/prompts.d.ts.map +1 -1
  65. package/dist/hono/routes/prompts.js +5 -5
  66. package/dist/hono/routes/queue.cjs +4 -4
  67. package/dist/hono/routes/queue.d.ts +4 -1
  68. package/dist/hono/routes/queue.d.ts.map +1 -1
  69. package/dist/hono/routes/queue.js +4 -4
  70. package/dist/hono/routes/resources.cjs +3 -3
  71. package/dist/hono/routes/resources.d.ts +2 -2
  72. package/dist/hono/routes/resources.d.ts.map +1 -1
  73. package/dist/hono/routes/resources.js +3 -3
  74. package/dist/hono/routes/search.cjs +2 -2
  75. package/dist/hono/routes/search.d.ts +6 -3
  76. package/dist/hono/routes/search.d.ts.map +1 -1
  77. package/dist/hono/routes/search.js +2 -2
  78. package/dist/hono/routes/sessions.cjs +9 -9
  79. package/dist/hono/routes/sessions.d.ts +3 -3
  80. package/dist/hono/routes/sessions.d.ts.map +1 -1
  81. package/dist/hono/routes/sessions.js +9 -9
  82. package/dist/hono/routes/tools.cjs +126 -0
  83. package/dist/hono/routes/tools.d.ts +42 -0
  84. package/dist/hono/routes/tools.d.ts.map +1 -0
  85. package/dist/hono/routes/tools.js +102 -0
  86. package/dist/hono/routes/webhooks.cjs +4 -4
  87. package/dist/hono/routes/webhooks.d.ts +4 -1
  88. package/dist/hono/routes/webhooks.d.ts.map +1 -1
  89. package/dist/hono/routes/webhooks.js +4 -4
  90. package/dist/hono/schemas/responses.d.ts +41 -41
  91. package/dist/hono/start-server.cjs +102 -0
  92. package/dist/hono/start-server.d.ts +61 -0
  93. package/dist/hono/start-server.d.ts.map +1 -0
  94. package/dist/hono/start-server.js +78 -0
  95. package/dist/index.cjs +2 -0
  96. package/dist/index.d.ts +1 -0
  97. package/dist/index.d.ts.map +1 -1
  98. package/dist/index.js +1 -0
  99. package/package.json +5 -4
@@ -1,6 +1,8 @@
1
1
  import { OpenAPIHono } from '@hono/zod-openapi';
2
2
  import type { DextoAgent } from '@dexto/core';
3
- export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
3
+ import type { Context } from 'hono';
4
+ type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
5
+ export declare function createLlmRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
6
  "/llm/current": {
5
7
  $get: {
6
8
  input: {
@@ -11,7 +13,7 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
11
13
  output: {
12
14
  config: {
13
15
  model: string;
14
- provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
16
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
15
17
  maxIterations?: number | undefined;
16
18
  baseURL?: string | undefined;
17
19
  maxInputTokens?: number | undefined;
@@ -194,6 +196,160 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
194
196
  } | undefined;
195
197
  }[];
196
198
  } | undefined;
199
+ openrouter?: {
200
+ name: string;
201
+ hasApiKey: boolean;
202
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
203
+ primaryEnvVar: string;
204
+ supportsBaseURL: boolean;
205
+ models: {
206
+ name: string;
207
+ maxInputTokens: number;
208
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
209
+ default?: boolean | undefined;
210
+ displayName?: string | undefined;
211
+ pricing?: {
212
+ inputPerM: number;
213
+ outputPerM: number;
214
+ cacheReadPerM?: number | undefined;
215
+ cacheWritePerM?: number | undefined;
216
+ currency?: "USD" | undefined;
217
+ unit?: "per_million_tokens" | undefined;
218
+ } | undefined;
219
+ }[];
220
+ } | undefined;
221
+ litellm?: {
222
+ name: string;
223
+ hasApiKey: boolean;
224
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
225
+ primaryEnvVar: string;
226
+ supportsBaseURL: boolean;
227
+ models: {
228
+ name: string;
229
+ maxInputTokens: number;
230
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
231
+ default?: boolean | undefined;
232
+ displayName?: string | undefined;
233
+ pricing?: {
234
+ inputPerM: number;
235
+ outputPerM: number;
236
+ cacheReadPerM?: number | undefined;
237
+ cacheWritePerM?: number | undefined;
238
+ currency?: "USD" | undefined;
239
+ unit?: "per_million_tokens" | undefined;
240
+ } | undefined;
241
+ }[];
242
+ } | undefined;
243
+ glama?: {
244
+ name: string;
245
+ hasApiKey: boolean;
246
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
247
+ primaryEnvVar: string;
248
+ supportsBaseURL: boolean;
249
+ models: {
250
+ name: string;
251
+ maxInputTokens: number;
252
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
253
+ default?: boolean | undefined;
254
+ displayName?: string | undefined;
255
+ pricing?: {
256
+ inputPerM: number;
257
+ outputPerM: number;
258
+ cacheReadPerM?: number | undefined;
259
+ cacheWritePerM?: number | undefined;
260
+ currency?: "USD" | undefined;
261
+ unit?: "per_million_tokens" | undefined;
262
+ } | undefined;
263
+ }[];
264
+ } | undefined;
265
+ vertex?: {
266
+ name: string;
267
+ hasApiKey: boolean;
268
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
269
+ primaryEnvVar: string;
270
+ supportsBaseURL: boolean;
271
+ models: {
272
+ name: string;
273
+ maxInputTokens: number;
274
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
275
+ default?: boolean | undefined;
276
+ displayName?: string | undefined;
277
+ pricing?: {
278
+ inputPerM: number;
279
+ outputPerM: number;
280
+ cacheReadPerM?: number | undefined;
281
+ cacheWritePerM?: number | undefined;
282
+ currency?: "USD" | undefined;
283
+ unit?: "per_million_tokens" | undefined;
284
+ } | undefined;
285
+ }[];
286
+ } | undefined;
287
+ bedrock?: {
288
+ name: string;
289
+ hasApiKey: boolean;
290
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
291
+ primaryEnvVar: string;
292
+ supportsBaseURL: boolean;
293
+ models: {
294
+ name: string;
295
+ maxInputTokens: number;
296
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
297
+ default?: boolean | undefined;
298
+ displayName?: string | undefined;
299
+ pricing?: {
300
+ inputPerM: number;
301
+ outputPerM: number;
302
+ cacheReadPerM?: number | undefined;
303
+ cacheWritePerM?: number | undefined;
304
+ currency?: "USD" | undefined;
305
+ unit?: "per_million_tokens" | undefined;
306
+ } | undefined;
307
+ }[];
308
+ } | undefined;
309
+ local?: {
310
+ name: string;
311
+ hasApiKey: boolean;
312
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
313
+ primaryEnvVar: string;
314
+ supportsBaseURL: boolean;
315
+ models: {
316
+ name: string;
317
+ maxInputTokens: number;
318
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
319
+ default?: boolean | undefined;
320
+ displayName?: string | undefined;
321
+ pricing?: {
322
+ inputPerM: number;
323
+ outputPerM: number;
324
+ cacheReadPerM?: number | undefined;
325
+ cacheWritePerM?: number | undefined;
326
+ currency?: "USD" | undefined;
327
+ unit?: "per_million_tokens" | undefined;
328
+ } | undefined;
329
+ }[];
330
+ } | undefined;
331
+ ollama?: {
332
+ name: string;
333
+ hasApiKey: boolean;
334
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
335
+ primaryEnvVar: string;
336
+ supportsBaseURL: boolean;
337
+ models: {
338
+ name: string;
339
+ maxInputTokens: number;
340
+ supportedFileTypes: ("image" | "audio" | "pdf")[];
341
+ default?: boolean | undefined;
342
+ displayName?: string | undefined;
343
+ pricing?: {
344
+ inputPerM: number;
345
+ outputPerM: number;
346
+ cacheReadPerM?: number | undefined;
347
+ cacheWritePerM?: number | undefined;
348
+ currency?: "USD" | undefined;
349
+ unit?: "per_million_tokens" | undefined;
350
+ } | undefined;
351
+ }[];
352
+ } | undefined;
197
353
  };
198
354
  } | {
199
355
  models: {
@@ -217,31 +373,13 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
217
373
  status: 200;
218
374
  };
219
375
  };
220
- } & {
221
- "/llm/key": {
222
- $post: {
223
- input: {
224
- json: {
225
- provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
226
- apiKey: string;
227
- };
228
- };
229
- output: {
230
- provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
231
- ok: true;
232
- envVar: string;
233
- };
234
- outputFormat: "json";
235
- status: 200;
236
- };
237
- };
238
376
  } & {
239
377
  "/llm/switch": {
240
378
  $post: {
241
379
  input: {
242
380
  json: {
243
381
  model?: string | undefined;
244
- provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
382
+ provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
245
383
  apiKey?: string | undefined;
246
384
  maxIterations?: number | undefined;
247
385
  baseURL?: string | undefined;
@@ -256,7 +394,7 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
256
394
  output: {
257
395
  config: {
258
396
  model: string;
259
- provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere";
397
+ provider: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
260
398
  maxIterations: number;
261
399
  baseURL?: string | undefined;
262
400
  maxInputTokens?: number | undefined;
@@ -278,7 +416,10 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
278
416
  output: {
279
417
  models: {
280
418
  name: string;
281
- baseURL: string;
419
+ provider: "openai-compatible" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
420
+ apiKey?: string | undefined | undefined;
421
+ baseURL?: string | undefined | undefined;
422
+ filePath?: string | undefined | undefined;
282
423
  displayName?: string | undefined | undefined;
283
424
  maxInputTokens?: number | undefined | undefined;
284
425
  maxOutputTokens?: number | undefined | undefined;
@@ -294,7 +435,10 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
294
435
  input: {
295
436
  json: {
296
437
  name: string;
297
- baseURL: string;
438
+ provider?: "openai-compatible" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
439
+ apiKey?: string | undefined;
440
+ baseURL?: string | undefined;
441
+ filePath?: string | undefined;
298
442
  displayName?: string | undefined;
299
443
  maxInputTokens?: number | undefined;
300
444
  maxOutputTokens?: number | undefined;
@@ -303,7 +447,10 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
303
447
  output: {
304
448
  model: {
305
449
  name: string;
306
- baseURL: string;
450
+ provider: "openai-compatible" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama";
451
+ apiKey?: string | undefined | undefined;
452
+ baseURL?: string | undefined | undefined;
453
+ filePath?: string | undefined | undefined;
307
454
  displayName?: string | undefined | undefined;
308
455
  maxInputTokens?: number | undefined | undefined;
309
456
  maxOutputTokens?: number | undefined | undefined;
@@ -343,4 +490,5 @@ export declare function createLlmRouter(getAgent: () => DextoAgent): OpenAPIHono
343
490
  };
344
491
  };
345
492
  }, "/">;
493
+ export {};
346
494
  //# sourceMappingURL=llm.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAoG9C,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2YzD"}
1
+ {"version":3,"file":"llm.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/llm.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAkB9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAOpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAgErE,wBAAgB,eAAe,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoXnD"}
@@ -9,7 +9,6 @@ import {
9
9
  } from "@dexto/core";
10
10
  import {
11
11
  getProviderKeyStatus,
12
- saveProviderApiKey,
13
12
  loadCustomModels,
14
13
  saveCustomModel,
15
14
  deleteCustomModel,
@@ -36,10 +35,6 @@ const CatalogQuerySchema = z.object({
36
35
  ).describe("Include only default models (true or false)"),
37
36
  mode: z.enum(["grouped", "flat"]).default("grouped").describe("Response format mode (grouped by provider or flat list)")
38
37
  }).describe("Query parameters for filtering and formatting the LLM catalog");
39
- const SaveKeySchema = z.object({
40
- provider: z.enum(LLM_PROVIDERS).describe("LLM provider identifier (e.g., openai, anthropic)"),
41
- apiKey: z.string().min(1, "API key is required").describe("API key for the provider (writeOnly - never returned in responses)").openapi({ writeOnly: true })
42
- }).describe("Request body for saving a provider API key");
43
38
  const SwitchLLMBodySchema = LLMUpdatesSchema.and(
44
39
  z.object({
45
40
  sessionId: z.string().optional().describe("Session identifier for session-specific LLM configuration")
@@ -102,28 +97,6 @@ function createLlmRouter(getAgent) {
102
97
  }
103
98
  }
104
99
  });
105
- const saveKeyRoute = createRoute({
106
- method: "post",
107
- path: "/llm/key",
108
- summary: "Save Provider API Key",
109
- description: "Stores an API key for a provider in .env and makes it available immediately",
110
- tags: ["llm"],
111
- request: { body: { content: { "application/json": { schema: SaveKeySchema } } } },
112
- responses: {
113
- 200: {
114
- description: "API key saved",
115
- content: {
116
- "application/json": {
117
- schema: z.object({
118
- ok: z.literal(true).describe("Operation success indicator"),
119
- provider: z.enum(LLM_PROVIDERS).describe("Provider for which the key was saved"),
120
- envVar: z.string().describe("Environment variable name where key was stored")
121
- }).strict().describe("API key save response")
122
- }
123
- }
124
- }
125
- }
126
- });
127
100
  const switchRoute = createRoute({
128
101
  method: "post",
129
102
  path: "/llm/switch",
@@ -233,8 +206,8 @@ function createLlmRouter(getAgent) {
233
206
  }
234
207
  }
235
208
  });
236
- return app.openapi(currentRoute, (ctx) => {
237
- const agent = getAgent();
209
+ return app.openapi(currentRoute, async (ctx) => {
210
+ const agent = await getAgent(ctx);
238
211
  const { sessionId } = ctx.req.valid("query");
239
212
  const currentConfig = sessionId ? agent.getEffectiveConfig(sessionId).llm : agent.getCurrentLLMConfig();
240
213
  let displayName;
@@ -243,6 +216,13 @@ function createLlmRouter(getAgent) {
243
216
  (m) => m.name.toLowerCase() === String(currentConfig.model).toLowerCase()
244
217
  );
245
218
  displayName = model?.displayName || void 0;
219
+ if (!displayName) {
220
+ const customModels = await loadCustomModels();
221
+ const customModel = customModels.find(
222
+ (cm) => cm.name.toLowerCase() === String(currentConfig.model).toLowerCase()
223
+ );
224
+ displayName = customModel?.displayName || void 0;
225
+ }
246
226
  } catch {
247
227
  }
248
228
  const { apiKey, ...configWithoutKey } = currentConfig;
@@ -326,12 +306,8 @@ function createLlmRouter(getAgent) {
326
306
  return ctx.json({ models: flat });
327
307
  }
328
308
  return ctx.json({ providers: filtered });
329
- }).openapi(saveKeyRoute, async (ctx) => {
330
- const { provider, apiKey } = ctx.req.valid("json");
331
- const meta = await saveProviderApiKey(provider, apiKey, process.cwd());
332
- return ctx.json({ ok: true, provider, envVar: meta.envVar });
333
309
  }).openapi(switchRoute, async (ctx) => {
334
- const agent = getAgent();
310
+ const agent = await getAgent(ctx);
335
311
  const raw = ctx.req.valid("json");
336
312
  const { sessionId, ...llmUpdates } = raw;
337
313
  const config = await agent.switchLLM(llmUpdates, sessionId);
@@ -351,7 +327,8 @@ function createLlmRouter(getAgent) {
351
327
  await saveCustomModel(model);
352
328
  return ctx.json({ ok: true, model });
353
329
  }).openapi(deleteCustomModelRoute, async (ctx) => {
354
- const { name } = ctx.req.valid("param");
330
+ const { name: encodedName } = ctx.req.valid("param");
331
+ const name = decodeURIComponent(encodedName);
355
332
  const deleted = await deleteCustomModel(name);
356
333
  if (!deleted) {
357
334
  throw new DextoRuntimeError(
@@ -228,7 +228,7 @@ function createMcpRouter(getAgent) {
228
228
  }
229
229
  });
230
230
  return app.openapi(addServerRoute, async (ctx) => {
231
- const agent = getAgent();
231
+ const agent = await getAgent(ctx);
232
232
  const { name, config, persistToAgent } = ctx.req.valid("json");
233
233
  await agent.addMcpServer(name, config);
234
234
  const isConnected = config.enabled !== false;
@@ -268,7 +268,7 @@ function createMcpRouter(getAgent) {
268
268
  const status = isConnected ? "connected" : "registered";
269
269
  return ctx.json({ status, name }, 200);
270
270
  }).openapi(listServersRoute, async (ctx) => {
271
- const agent = getAgent();
271
+ const agent = await getAgent(ctx);
272
272
  const clientsMap = agent.getMcpClients();
273
273
  const failedConnections = agent.getMcpFailedConnections();
274
274
  const servers = [];
@@ -280,7 +280,7 @@ function createMcpRouter(getAgent) {
280
280
  }
281
281
  return ctx.json({ servers });
282
282
  }).openapi(toolsRoute, async (ctx) => {
283
- const agent = getAgent();
283
+ const agent = await getAgent(ctx);
284
284
  const { serverId } = ctx.req.valid("param");
285
285
  const client = agent.getMcpClients().get(serverId);
286
286
  if (!client) {
@@ -295,7 +295,7 @@ function createMcpRouter(getAgent) {
295
295
  }));
296
296
  return ctx.json({ tools });
297
297
  }).openapi(deleteServerRoute, async (ctx) => {
298
- const agent = getAgent();
298
+ const agent = await getAgent(ctx);
299
299
  const { serverId } = ctx.req.valid("param");
300
300
  const clientExists = agent.getMcpClients().has(serverId) || agent.getMcpFailedConnections()[serverId];
301
301
  if (!clientExists) {
@@ -304,7 +304,7 @@ function createMcpRouter(getAgent) {
304
304
  await agent.removeMcpServer(serverId);
305
305
  return ctx.json({ status: "disconnected", id: serverId });
306
306
  }).openapi(restartServerRoute, async (ctx) => {
307
- const agent = getAgent();
307
+ const agent = await getAgent(ctx);
308
308
  const { serverId } = ctx.req.valid("param");
309
309
  import_core.logger.info(`Received request to POST /api/mcp/servers/${serverId}/restart`);
310
310
  const clientExists = agent.getMcpClients().has(serverId);
@@ -315,7 +315,7 @@ function createMcpRouter(getAgent) {
315
315
  await agent.restartMcpServer(serverId);
316
316
  return ctx.json({ status: "restarted", id: serverId });
317
317
  }).openapi(execToolRoute, async (ctx) => {
318
- const agent = getAgent();
318
+ const agent = await getAgent(ctx);
319
319
  const { serverId, toolName } = ctx.req.valid("param");
320
320
  const body = ctx.req.valid("json");
321
321
  const client = agent.getMcpClients().get(serverId);
@@ -334,7 +334,7 @@ function createMcpRouter(getAgent) {
334
334
  return ctx.json({ success: false, error: errorMessage }, 200);
335
335
  }
336
336
  }).openapi(listResourcesRoute, async (ctx) => {
337
- const agent = getAgent();
337
+ const agent = await getAgent(ctx);
338
338
  const { serverId } = ctx.req.valid("param");
339
339
  const client = agent.getMcpClients().get(serverId);
340
340
  if (!client) {
@@ -343,7 +343,7 @@ function createMcpRouter(getAgent) {
343
343
  const resources = await agent.listResourcesForServer(serverId);
344
344
  return ctx.json({ success: true, resources });
345
345
  }).openapi(getResourceContentRoute, async (ctx) => {
346
- const agent = getAgent();
346
+ const agent = await getAgent(ctx);
347
347
  const { serverId, resourceId } = ctx.req.valid("param");
348
348
  const client = agent.getMcpClients().get(serverId);
349
349
  if (!client) {
@@ -1,6 +1,6 @@
1
1
  import { OpenAPIHono } from '@hono/zod-openapi';
2
- import type { DextoAgent } from '@dexto/core';
3
- export declare function createMcpRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
2
+ import type { GetAgentFn } from '../index.js';
3
+ export declare function createMcpRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
4
  "/mcp/servers": {
5
5
  $post: {
6
6
  input: {
@@ -1 +1 @@
1
- {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA0I9C,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAkTzD"}
1
+ {"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/mcp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAIhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAuI9C,wBAAgB,eAAe,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAkTnD"}
@@ -205,7 +205,7 @@ function createMcpRouter(getAgent) {
205
205
  }
206
206
  });
207
207
  return app.openapi(addServerRoute, async (ctx) => {
208
- const agent = getAgent();
208
+ const agent = await getAgent(ctx);
209
209
  const { name, config, persistToAgent } = ctx.req.valid("json");
210
210
  await agent.addMcpServer(name, config);
211
211
  const isConnected = config.enabled !== false;
@@ -245,7 +245,7 @@ function createMcpRouter(getAgent) {
245
245
  const status = isConnected ? "connected" : "registered";
246
246
  return ctx.json({ status, name }, 200);
247
247
  }).openapi(listServersRoute, async (ctx) => {
248
- const agent = getAgent();
248
+ const agent = await getAgent(ctx);
249
249
  const clientsMap = agent.getMcpClients();
250
250
  const failedConnections = agent.getMcpFailedConnections();
251
251
  const servers = [];
@@ -257,7 +257,7 @@ function createMcpRouter(getAgent) {
257
257
  }
258
258
  return ctx.json({ servers });
259
259
  }).openapi(toolsRoute, async (ctx) => {
260
- const agent = getAgent();
260
+ const agent = await getAgent(ctx);
261
261
  const { serverId } = ctx.req.valid("param");
262
262
  const client = agent.getMcpClients().get(serverId);
263
263
  if (!client) {
@@ -272,7 +272,7 @@ function createMcpRouter(getAgent) {
272
272
  }));
273
273
  return ctx.json({ tools });
274
274
  }).openapi(deleteServerRoute, async (ctx) => {
275
- const agent = getAgent();
275
+ const agent = await getAgent(ctx);
276
276
  const { serverId } = ctx.req.valid("param");
277
277
  const clientExists = agent.getMcpClients().has(serverId) || agent.getMcpFailedConnections()[serverId];
278
278
  if (!clientExists) {
@@ -281,7 +281,7 @@ function createMcpRouter(getAgent) {
281
281
  await agent.removeMcpServer(serverId);
282
282
  return ctx.json({ status: "disconnected", id: serverId });
283
283
  }).openapi(restartServerRoute, async (ctx) => {
284
- const agent = getAgent();
284
+ const agent = await getAgent(ctx);
285
285
  const { serverId } = ctx.req.valid("param");
286
286
  logger.info(`Received request to POST /api/mcp/servers/${serverId}/restart`);
287
287
  const clientExists = agent.getMcpClients().has(serverId);
@@ -292,7 +292,7 @@ function createMcpRouter(getAgent) {
292
292
  await agent.restartMcpServer(serverId);
293
293
  return ctx.json({ status: "restarted", id: serverId });
294
294
  }).openapi(execToolRoute, async (ctx) => {
295
- const agent = getAgent();
295
+ const agent = await getAgent(ctx);
296
296
  const { serverId, toolName } = ctx.req.valid("param");
297
297
  const body = ctx.req.valid("json");
298
298
  const client = agent.getMcpClients().get(serverId);
@@ -311,7 +311,7 @@ function createMcpRouter(getAgent) {
311
311
  return ctx.json({ success: false, error: errorMessage }, 200);
312
312
  }
313
313
  }).openapi(listResourcesRoute, async (ctx) => {
314
- const agent = getAgent();
314
+ const agent = await getAgent(ctx);
315
315
  const { serverId } = ctx.req.valid("param");
316
316
  const client = agent.getMcpClients().get(serverId);
317
317
  if (!client) {
@@ -320,7 +320,7 @@ function createMcpRouter(getAgent) {
320
320
  const resources = await agent.listResourcesForServer(serverId);
321
321
  return ctx.json({ success: true, resources });
322
322
  }).openapi(getResourceContentRoute, async (ctx) => {
323
- const agent = getAgent();
323
+ const agent = await getAgent(ctx);
324
324
  const { serverId, resourceId } = ctx.req.valid("param");
325
325
  const client = agent.getMcpClients().get(serverId);
326
326
  if (!client) {
@@ -150,7 +150,7 @@ function createMemoryRouter(getAgent) {
150
150
  if (input.metadata !== void 0) {
151
151
  createInput.metadata = input.metadata;
152
152
  }
153
- const agent = getAgent();
153
+ const agent = await getAgent(ctx);
154
154
  const memory = await agent.memoryManager.create(createInput);
155
155
  return ctx.json({ ok: true, memory }, 201);
156
156
  }).openapi(listRoute, async (ctx) => {
@@ -161,12 +161,12 @@ function createMemoryRouter(getAgent) {
161
161
  if (query.pinned !== void 0) options.pinned = query.pinned;
162
162
  if (query.limit !== void 0) options.limit = query.limit;
163
163
  if (query.offset !== void 0) options.offset = query.offset;
164
- const agent = getAgent();
164
+ const agent = await getAgent(ctx);
165
165
  const memories = await agent.memoryManager.list(options);
166
166
  return ctx.json({ ok: true, memories });
167
167
  }).openapi(getRoute, async (ctx) => {
168
168
  const { id } = ctx.req.valid("param");
169
- const agent = getAgent();
169
+ const agent = await getAgent(ctx);
170
170
  const memory = await agent.memoryManager.get(id);
171
171
  return ctx.json({ ok: true, memory });
172
172
  }).openapi(updateRoute, async (ctx) => {
@@ -176,12 +176,12 @@ function createMemoryRouter(getAgent) {
176
176
  if (updatesRaw.content !== void 0) updates.content = updatesRaw.content;
177
177
  if (updatesRaw.metadata !== void 0) updates.metadata = updatesRaw.metadata;
178
178
  if (updatesRaw.tags !== void 0) updates.tags = updatesRaw.tags;
179
- const agent = getAgent();
179
+ const agent = await getAgent(ctx);
180
180
  const memory = await agent.memoryManager.update(id, updates);
181
181
  return ctx.json({ ok: true, memory });
182
182
  }).openapi(deleteRoute, async (ctx) => {
183
183
  const { id } = ctx.req.valid("param");
184
- const agent = getAgent();
184
+ const agent = await getAgent(ctx);
185
185
  await agent.memoryManager.delete(id);
186
186
  return ctx.json({ ok: true, message: "Memory deleted successfully" });
187
187
  });
@@ -1,6 +1,8 @@
1
1
  import { OpenAPIHono, z } from '@hono/zod-openapi';
2
2
  import type { DextoAgent } from '@dexto/core';
3
- export declare function createMemoryRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
3
+ import type { Context } from 'hono';
4
+ type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
5
+ export declare function createMemoryRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
6
  "/memory": {
5
7
  $post: {
6
8
  input: {
@@ -143,4 +145,5 @@ export declare function createMemoryRouter(getAgent: () => DextoAgent): OpenAPIH
143
145
  };
144
146
  };
145
147
  }, "/">;
148
+ export {};
146
149
  //# sourceMappingURL=memory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA6D9C,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwK5D"}
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/memory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AA2DrE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwKtD"}
@@ -127,7 +127,7 @@ function createMemoryRouter(getAgent) {
127
127
  if (input.metadata !== void 0) {
128
128
  createInput.metadata = input.metadata;
129
129
  }
130
- const agent = getAgent();
130
+ const agent = await getAgent(ctx);
131
131
  const memory = await agent.memoryManager.create(createInput);
132
132
  return ctx.json({ ok: true, memory }, 201);
133
133
  }).openapi(listRoute, async (ctx) => {
@@ -138,12 +138,12 @@ function createMemoryRouter(getAgent) {
138
138
  if (query.pinned !== void 0) options.pinned = query.pinned;
139
139
  if (query.limit !== void 0) options.limit = query.limit;
140
140
  if (query.offset !== void 0) options.offset = query.offset;
141
- const agent = getAgent();
141
+ const agent = await getAgent(ctx);
142
142
  const memories = await agent.memoryManager.list(options);
143
143
  return ctx.json({ ok: true, memories });
144
144
  }).openapi(getRoute, async (ctx) => {
145
145
  const { id } = ctx.req.valid("param");
146
- const agent = getAgent();
146
+ const agent = await getAgent(ctx);
147
147
  const memory = await agent.memoryManager.get(id);
148
148
  return ctx.json({ ok: true, memory });
149
149
  }).openapi(updateRoute, async (ctx) => {
@@ -153,12 +153,12 @@ function createMemoryRouter(getAgent) {
153
153
  if (updatesRaw.content !== void 0) updates.content = updatesRaw.content;
154
154
  if (updatesRaw.metadata !== void 0) updates.metadata = updatesRaw.metadata;
155
155
  if (updatesRaw.tags !== void 0) updates.tags = updatesRaw.tags;
156
- const agent = getAgent();
156
+ const agent = await getAgent(ctx);
157
157
  const memory = await agent.memoryManager.update(id, updates);
158
158
  return ctx.json({ ok: true, memory });
159
159
  }).openapi(deleteRoute, async (ctx) => {
160
160
  const { id } = ctx.req.valid("param");
161
- const agent = getAgent();
161
+ const agent = await getAgent(ctx);
162
162
  await agent.memoryManager.delete(id);
163
163
  return ctx.json({ ok: true, message: "Memory deleted successfully" });
164
164
  });
@@ -184,7 +184,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
184
184
  }
185
185
  });
186
186
  return app.openapi(messageRoute, async (ctx) => {
187
- const agent = getAgent();
187
+ const agent = await getAgent(ctx);
188
188
  agent.logger.info("Received message via POST /api/message");
189
189
  const { content, sessionId } = ctx.req.valid("json");
190
190
  agent.logger.info(`Message for session: ${sessionId}`);
@@ -195,7 +195,7 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
195
195
  });
196
196
  return ctx.json({ accepted: true, sessionId }, 202);
197
197
  }).openapi(messageSyncRoute, async (ctx) => {
198
- const agent = getAgent();
198
+ const agent = await getAgent(ctx);
199
199
  agent.logger.info("Received message via POST /api/message-sync");
200
200
  const { content, sessionId } = ctx.req.valid("json");
201
201
  agent.logger.info(`Message for session: ${sessionId}`);
@@ -210,13 +210,13 @@ function createMessagesRouter(getAgent, approvalCoordinator) {
210
210
  provider: llmConfig.provider
211
211
  });
212
212
  }).openapi(resetRoute, async (ctx) => {
213
- const agent = getAgent();
213
+ const agent = await getAgent(ctx);
214
214
  agent.logger.info("Received request via POST /api/reset");
215
215
  const { sessionId } = ctx.req.valid("json");
216
216
  await agent.resetConversation(sessionId);
217
217
  return ctx.json({ status: "reset initiated", sessionId });
218
218
  }).openapi(messageStreamRoute, async (ctx) => {
219
- const agent = getAgent();
219
+ const agent = await getAgent(ctx);
220
220
  const { content, sessionId } = ctx.req.valid("json");
221
221
  const isBusy = await agent.isSessionBusy(sessionId);
222
222
  if (isBusy) {