@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 createPromptsRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
3
+ import type { Context } from 'hono';
4
+ type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
5
+ export declare function createPromptsRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
6
  "/prompts": {
5
7
  $get: {
6
8
  input: {};
@@ -147,4 +149,5 @@ export declare function createPromptsRouter(getAgent: () => DextoAgent): OpenAPI
147
149
  };
148
150
  };
149
151
  }, "/">;
152
+ export {};
150
153
  //# sourceMappingURL=prompts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAqE9C,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6N7D"}
1
+ {"version":3,"file":"prompts.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/prompts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,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;AAmErE,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA6NvD"}
@@ -139,12 +139,12 @@ function createPromptsRouter(getAgent) {
139
139
  }
140
140
  });
141
141
  return app.openapi(listRoute, async (ctx) => {
142
- const agent = getAgent();
142
+ const agent = await getAgent(ctx);
143
143
  const prompts = await agent.listPrompts();
144
144
  const list = Object.values(prompts);
145
145
  return ctx.json({ prompts: list });
146
146
  }).openapi(createCustomRoute, async (ctx) => {
147
- const agent = getAgent();
147
+ const agent = await getAgent(ctx);
148
148
  const payload = ctx.req.valid("json");
149
149
  const promptArguments = payload.arguments?.map((arg) => ({
150
150
  name: arg.name,
@@ -168,18 +168,18 @@ function createPromptsRouter(getAgent) {
168
168
  const prompt = await agent.createCustomPrompt(createPayload);
169
169
  return ctx.json({ prompt }, 201);
170
170
  }).openapi(deleteCustomRoute, async (ctx) => {
171
- const agent = getAgent();
171
+ const agent = await getAgent(ctx);
172
172
  const { name } = ctx.req.valid("param");
173
173
  await agent.deleteCustomPrompt(name);
174
174
  return ctx.body(null, 204);
175
175
  }).openapi(getPromptRoute, async (ctx) => {
176
- const agent = getAgent();
176
+ const agent = await getAgent(ctx);
177
177
  const { name } = ctx.req.valid("param");
178
178
  const definition = await agent.getPromptDefinition(name);
179
179
  if (!definition) throw PromptError.notFound(name);
180
180
  return ctx.json({ definition });
181
181
  }).openapi(resolvePromptRoute, async (ctx) => {
182
- const agent = getAgent();
182
+ const agent = await getAgent(ctx);
183
183
  const { name } = ctx.req.valid("param");
184
184
  const { context, args: argsString } = ctx.req.valid("query");
185
185
  let parsedArgs;
@@ -160,7 +160,7 @@ function createQueueRouter(getAgent) {
160
160
  }
161
161
  });
162
162
  return app.openapi(getQueueRoute, async (ctx) => {
163
- const agent = getAgent();
163
+ const agent = await getAgent(ctx);
164
164
  const { sessionId } = ctx.req.valid("param");
165
165
  const messages = await agent.getQueuedMessages(sessionId);
166
166
  return ctx.json({
@@ -168,7 +168,7 @@ function createQueueRouter(getAgent) {
168
168
  count: messages.length
169
169
  });
170
170
  }).openapi(queueMessageRoute, async (ctx) => {
171
- const agent = getAgent();
171
+ const agent = await getAgent(ctx);
172
172
  const { sessionId } = ctx.req.valid("param");
173
173
  const { content: rawContent } = ctx.req.valid("json");
174
174
  const content = typeof rawContent === "string" ? [{ type: "text", text: rawContent }] : rawContent;
@@ -182,7 +182,7 @@ function createQueueRouter(getAgent) {
182
182
  201
183
183
  );
184
184
  }).openapi(removeQueuedMessageRoute, async (ctx) => {
185
- const agent = getAgent();
185
+ const agent = await getAgent(ctx);
186
186
  const { sessionId, messageId } = ctx.req.valid("param");
187
187
  const removed = await agent.removeQueuedMessage(sessionId, messageId);
188
188
  if (!removed) {
@@ -190,7 +190,7 @@ function createQueueRouter(getAgent) {
190
190
  }
191
191
  return ctx.json({ removed: true, id: messageId });
192
192
  }).openapi(clearQueueRoute, async (ctx) => {
193
- const agent = getAgent();
193
+ const agent = await getAgent(ctx);
194
194
  const { sessionId } = ctx.req.valid("param");
195
195
  const count = await agent.clearMessageQueue(sessionId);
196
196
  return ctx.json({ cleared: true, count });
@@ -1,6 +1,8 @@
1
1
  import { OpenAPIHono } from '@hono/zod-openapi';
2
2
  import type { DextoAgent } from '@dexto/core';
3
- export declare function createQueueRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
3
+ import type { Context } from 'hono';
4
+ type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
5
+ export declare function createQueueRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
6
  "/queue/:sessionId": {
5
7
  $get: {
6
8
  input: {
@@ -168,4 +170,5 @@ export declare function createQueueRouter(getAgent: () => DextoAgent): OpenAPIHo
168
170
  };
169
171
  };
170
172
  }, "/">;
173
+ export {};
171
174
  //# sourceMappingURL=queue.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAsD3D,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoL3D"}
1
+ {"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAe,MAAM,aAAa,CAAC;AAE3D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAqDrE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAoLrD"}
@@ -137,7 +137,7 @@ function createQueueRouter(getAgent) {
137
137
  }
138
138
  });
139
139
  return app.openapi(getQueueRoute, async (ctx) => {
140
- const agent = getAgent();
140
+ const agent = await getAgent(ctx);
141
141
  const { sessionId } = ctx.req.valid("param");
142
142
  const messages = await agent.getQueuedMessages(sessionId);
143
143
  return ctx.json({
@@ -145,7 +145,7 @@ function createQueueRouter(getAgent) {
145
145
  count: messages.length
146
146
  });
147
147
  }).openapi(queueMessageRoute, async (ctx) => {
148
- const agent = getAgent();
148
+ const agent = await getAgent(ctx);
149
149
  const { sessionId } = ctx.req.valid("param");
150
150
  const { content: rawContent } = ctx.req.valid("json");
151
151
  const content = typeof rawContent === "string" ? [{ type: "text", text: rawContent }] : rawContent;
@@ -159,7 +159,7 @@ function createQueueRouter(getAgent) {
159
159
  201
160
160
  );
161
161
  }).openapi(removeQueuedMessageRoute, async (ctx) => {
162
- const agent = getAgent();
162
+ const agent = await getAgent(ctx);
163
163
  const { sessionId, messageId } = ctx.req.valid("param");
164
164
  const removed = await agent.removeQueuedMessage(sessionId, messageId);
165
165
  if (!removed) {
@@ -167,7 +167,7 @@ function createQueueRouter(getAgent) {
167
167
  }
168
168
  return ctx.json({ removed: true, id: messageId });
169
169
  }).openapi(clearQueueRoute, async (ctx) => {
170
- const agent = getAgent();
170
+ const agent = await getAgent(ctx);
171
171
  const { sessionId } = ctx.req.valid("param");
172
172
  const count = await agent.clearMessageQueue(sessionId);
173
173
  return ctx.json({ cleared: true, count });
@@ -89,16 +89,16 @@ function createResourcesRouter(getAgent) {
89
89
  }
90
90
  });
91
91
  return app.openapi(listRoute, async (ctx) => {
92
- const agent = getAgent();
92
+ const agent = await getAgent(ctx);
93
93
  const resources = await agent.listResources();
94
94
  return ctx.json({ ok: true, resources: Object.values(resources) });
95
95
  }).openapi(getContentRoute, async (ctx) => {
96
- const agent = getAgent();
96
+ const agent = await getAgent(ctx);
97
97
  const { resourceId } = ctx.req.valid("param");
98
98
  const content = await agent.readResource(resourceId);
99
99
  return ctx.json({ ok: true, content });
100
100
  }).openapi(headRoute, async (ctx) => {
101
- const agent = getAgent();
101
+ const agent = await getAgent(ctx);
102
102
  const { resourceId } = ctx.req.valid("param");
103
103
  const exists = await agent.hasResource(resourceId);
104
104
  return ctx.body(null, exists ? 200 : 404);
@@ -1,6 +1,6 @@
1
1
  import { OpenAPIHono } from '@hono/zod-openapi';
2
- import type { DextoAgent } from '@dexto/core';
3
- export declare function createResourcesRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
2
+ import type { GetAgentFn } from '../index.js';
3
+ export declare function createResourcesRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
4
  "/resources": {
5
5
  $get: {
6
6
  input: {};
@@ -1 +1 @@
1
- {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAyD9C,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqE/D"}
1
+ {"version":3,"file":"resources.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/resources.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwD9C,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAqEzD"}
@@ -66,16 +66,16 @@ function createResourcesRouter(getAgent) {
66
66
  }
67
67
  });
68
68
  return app.openapi(listRoute, async (ctx) => {
69
- const agent = getAgent();
69
+ const agent = await getAgent(ctx);
70
70
  const resources = await agent.listResources();
71
71
  return ctx.json({ ok: true, resources: Object.values(resources) });
72
72
  }).openapi(getContentRoute, async (ctx) => {
73
- const agent = getAgent();
73
+ const agent = await getAgent(ctx);
74
74
  const { resourceId } = ctx.req.valid("param");
75
75
  const content = await agent.readResource(resourceId);
76
76
  return ctx.json({ ok: true, content });
77
77
  }).openapi(headRoute, async (ctx) => {
78
- const agent = getAgent();
78
+ const agent = await getAgent(ctx);
79
79
  const { resourceId } = ctx.req.valid("param");
80
80
  const exists = await agent.hasResource(resourceId);
81
81
  return ctx.body(null, exists ? 200 : 404);
@@ -64,7 +64,7 @@ function createSearchRouter(getAgent) {
64
64
  }
65
65
  });
66
66
  return app.openapi(messagesRoute, async (ctx) => {
67
- const agent = getAgent();
67
+ const agent = await getAgent(ctx);
68
68
  const { q, limit, offset, sessionId, role } = ctx.req.valid("query");
69
69
  const options = {
70
70
  limit: limit || 20,
@@ -75,7 +75,7 @@ function createSearchRouter(getAgent) {
75
75
  const searchResults = await agent.searchMessages(q, options);
76
76
  return ctx.json(searchResults);
77
77
  }).openapi(sessionsRoute, async (ctx) => {
78
- const agent = getAgent();
78
+ const agent = await getAgent(ctx);
79
79
  const { q } = ctx.req.valid("query");
80
80
  const searchResults = await agent.searchSessions(q);
81
81
  return ctx.json(searchResults);
@@ -1,6 +1,8 @@
1
1
  import { OpenAPIHono } from '@hono/zod-openapi';
2
2
  import type { DextoAgent } from '@dexto/core';
3
- export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
3
+ import type { Context } from 'hono';
4
+ type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
5
+ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
6
  "/search/messages": {
5
7
  $get: {
6
8
  input: {
@@ -54,7 +56,7 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
54
56
  totalTokens?: number | undefined;
55
57
  } | undefined;
56
58
  model?: string | undefined;
57
- provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
59
+ provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
58
60
  toolCalls?: {
59
61
  function: {
60
62
  name: string;
@@ -136,7 +138,7 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
136
138
  totalTokens?: number | undefined;
137
139
  } | undefined;
138
140
  model?: string | undefined;
139
- provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
141
+ provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
140
142
  toolCalls?: {
141
143
  function: {
142
144
  name: string;
@@ -162,4 +164,5 @@ export declare function createSearchRouter(getAgent: () => DextoAgent): OpenAPIH
162
164
  };
163
165
  };
164
166
  }, "/">;
167
+ export {};
165
168
  //# sourceMappingURL=search.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AA2B9C,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwD5D"}
1
+ {"version":3,"file":"search.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AA0BrE,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAwDtD"}
@@ -41,7 +41,7 @@ function createSearchRouter(getAgent) {
41
41
  }
42
42
  });
43
43
  return app.openapi(messagesRoute, async (ctx) => {
44
- const agent = getAgent();
44
+ const agent = await getAgent(ctx);
45
45
  const { q, limit, offset, sessionId, role } = ctx.req.valid("query");
46
46
  const options = {
47
47
  limit: limit || 20,
@@ -52,7 +52,7 @@ function createSearchRouter(getAgent) {
52
52
  const searchResults = await agent.searchMessages(q, options);
53
53
  return ctx.json(searchResults);
54
54
  }).openapi(sessionsRoute, async (ctx) => {
55
- const agent = getAgent();
55
+ const agent = await getAgent(ctx);
56
56
  const { q } = ctx.req.valid("query");
57
57
  const searchResults = await agent.searchSessions(q);
58
58
  return ctx.json(searchResults);
@@ -268,7 +268,7 @@ function createSessionsRouter(getAgent) {
268
268
  }
269
269
  });
270
270
  return app.openapi(listRoute, async (ctx) => {
271
- const agent = getAgent();
271
+ const agent = await getAgent(ctx);
272
272
  const sessionIds = await agent.listSessions();
273
273
  const sessions = await Promise.all(
274
274
  sessionIds.map(async (id) => {
@@ -294,7 +294,7 @@ function createSessionsRouter(getAgent) {
294
294
  );
295
295
  return ctx.json({ sessions });
296
296
  }).openapi(createRouteDef, async (ctx) => {
297
- const agent = getAgent();
297
+ const agent = await getAgent(ctx);
298
298
  const { sessionId } = ctx.req.valid("json");
299
299
  const session = await agent.createSession(sessionId);
300
300
  const metadata = await agent.getSessionMetadata(session.id);
@@ -311,7 +311,7 @@ function createSessionsRouter(getAgent) {
311
311
  201
312
312
  );
313
313
  }).openapi(getRoute, async (ctx) => {
314
- const agent = getAgent();
314
+ const agent = await getAgent(ctx);
315
315
  const { sessionId } = ctx.req.param();
316
316
  const metadata = await agent.getSessionMetadata(sessionId);
317
317
  const history = await agent.getSessionHistory(sessionId);
@@ -326,7 +326,7 @@ function createSessionsRouter(getAgent) {
326
326
  }
327
327
  });
328
328
  }).openapi(historyRoute, async (ctx) => {
329
- const agent = getAgent();
329
+ const agent = await getAgent(ctx);
330
330
  const { sessionId } = ctx.req.param();
331
331
  const [history, isBusy] = await Promise.all([
332
332
  agent.getSessionHistory(sessionId),
@@ -337,12 +337,12 @@ function createSessionsRouter(getAgent) {
337
337
  isBusy
338
338
  });
339
339
  }).openapi(deleteRoute, async (ctx) => {
340
- const agent = getAgent();
340
+ const agent = await getAgent(ctx);
341
341
  const { sessionId } = ctx.req.param();
342
342
  await agent.deleteSession(sessionId);
343
343
  return ctx.json({ status: "deleted", sessionId });
344
344
  }).openapi(cancelRoute, async (ctx) => {
345
- const agent = getAgent();
345
+ const agent = await getAgent(ctx);
346
346
  const { sessionId } = ctx.req.valid("param");
347
347
  let clearQueue = false;
348
348
  try {
@@ -371,7 +371,7 @@ function createSessionsRouter(getAgent) {
371
371
  clearedCount
372
372
  });
373
373
  }).openapi(loadRoute, async (ctx) => {
374
- const agent = getAgent();
374
+ const agent = await getAgent(ctx);
375
375
  const { sessionId } = ctx.req.valid("param");
376
376
  const sessionIds = await agent.listSessions();
377
377
  if (!sessionIds.includes(sessionId)) {
@@ -393,7 +393,7 @@ function createSessionsRouter(getAgent) {
393
393
  200
394
394
  );
395
395
  }).openapi(patchRoute, async (ctx) => {
396
- const agent = getAgent();
396
+ const agent = await getAgent(ctx);
397
397
  const { sessionId } = ctx.req.valid("param");
398
398
  const { title } = ctx.req.valid("json");
399
399
  await agent.setSessionTitle(sessionId, title);
@@ -408,7 +408,7 @@ function createSessionsRouter(getAgent) {
408
408
  }
409
409
  });
410
410
  }).openapi(generateTitleRoute, async (ctx) => {
411
- const agent = getAgent();
411
+ const agent = await getAgent(ctx);
412
412
  const { sessionId } = ctx.req.valid("param");
413
413
  const title = await agent.generateSessionTitle(sessionId);
414
414
  return ctx.json({ title, sessionId });
@@ -1,6 +1,6 @@
1
1
  import { OpenAPIHono } from '@hono/zod-openapi';
2
- import type { DextoAgent } from '@dexto/core';
3
- export declare function createSessionsRouter(getAgent: () => DextoAgent): OpenAPIHono<import("hono").Env, {
2
+ import type { GetAgentFn } from '../index.js';
3
+ export declare function createSessionsRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
4
  "/sessions": {
5
5
  $get: {
6
6
  input: {};
@@ -108,7 +108,7 @@ export declare function createSessionsRouter(getAgent: () => DextoAgent): OpenAP
108
108
  totalTokens?: number | undefined;
109
109
  } | undefined;
110
110
  model?: string | undefined;
111
- provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | undefined;
111
+ provider?: "openai" | "openai-compatible" | "anthropic" | "google" | "groq" | "xai" | "cohere" | "openrouter" | "litellm" | "glama" | "vertex" | "bedrock" | "local" | "ollama" | undefined;
112
112
  toolCalls?: {
113
113
  function: {
114
114
  name: string;
@@ -1 +1 @@
1
- {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAS9C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,MAAM,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAie9D"}
1
+ {"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQ9C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAiexD"}
@@ -245,7 +245,7 @@ function createSessionsRouter(getAgent) {
245
245
  }
246
246
  });
247
247
  return app.openapi(listRoute, async (ctx) => {
248
- const agent = getAgent();
248
+ const agent = await getAgent(ctx);
249
249
  const sessionIds = await agent.listSessions();
250
250
  const sessions = await Promise.all(
251
251
  sessionIds.map(async (id) => {
@@ -271,7 +271,7 @@ function createSessionsRouter(getAgent) {
271
271
  );
272
272
  return ctx.json({ sessions });
273
273
  }).openapi(createRouteDef, async (ctx) => {
274
- const agent = getAgent();
274
+ const agent = await getAgent(ctx);
275
275
  const { sessionId } = ctx.req.valid("json");
276
276
  const session = await agent.createSession(sessionId);
277
277
  const metadata = await agent.getSessionMetadata(session.id);
@@ -288,7 +288,7 @@ function createSessionsRouter(getAgent) {
288
288
  201
289
289
  );
290
290
  }).openapi(getRoute, async (ctx) => {
291
- const agent = getAgent();
291
+ const agent = await getAgent(ctx);
292
292
  const { sessionId } = ctx.req.param();
293
293
  const metadata = await agent.getSessionMetadata(sessionId);
294
294
  const history = await agent.getSessionHistory(sessionId);
@@ -303,7 +303,7 @@ function createSessionsRouter(getAgent) {
303
303
  }
304
304
  });
305
305
  }).openapi(historyRoute, async (ctx) => {
306
- const agent = getAgent();
306
+ const agent = await getAgent(ctx);
307
307
  const { sessionId } = ctx.req.param();
308
308
  const [history, isBusy] = await Promise.all([
309
309
  agent.getSessionHistory(sessionId),
@@ -314,12 +314,12 @@ function createSessionsRouter(getAgent) {
314
314
  isBusy
315
315
  });
316
316
  }).openapi(deleteRoute, async (ctx) => {
317
- const agent = getAgent();
317
+ const agent = await getAgent(ctx);
318
318
  const { sessionId } = ctx.req.param();
319
319
  await agent.deleteSession(sessionId);
320
320
  return ctx.json({ status: "deleted", sessionId });
321
321
  }).openapi(cancelRoute, async (ctx) => {
322
- const agent = getAgent();
322
+ const agent = await getAgent(ctx);
323
323
  const { sessionId } = ctx.req.valid("param");
324
324
  let clearQueue = false;
325
325
  try {
@@ -348,7 +348,7 @@ function createSessionsRouter(getAgent) {
348
348
  clearedCount
349
349
  });
350
350
  }).openapi(loadRoute, async (ctx) => {
351
- const agent = getAgent();
351
+ const agent = await getAgent(ctx);
352
352
  const { sessionId } = ctx.req.valid("param");
353
353
  const sessionIds = await agent.listSessions();
354
354
  if (!sessionIds.includes(sessionId)) {
@@ -370,7 +370,7 @@ function createSessionsRouter(getAgent) {
370
370
  200
371
371
  );
372
372
  }).openapi(patchRoute, async (ctx) => {
373
- const agent = getAgent();
373
+ const agent = await getAgent(ctx);
374
374
  const { sessionId } = ctx.req.valid("param");
375
375
  const { title } = ctx.req.valid("json");
376
376
  await agent.setSessionTitle(sessionId, title);
@@ -385,7 +385,7 @@ function createSessionsRouter(getAgent) {
385
385
  }
386
386
  });
387
387
  }).openapi(generateTitleRoute, async (ctx) => {
388
- const agent = getAgent();
388
+ const agent = await getAgent(ctx);
389
389
  const { sessionId } = ctx.req.valid("param");
390
390
  const title = await agent.generateSessionTitle(sessionId);
391
391
  return ctx.json({ title, sessionId });
@@ -0,0 +1,126 @@
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 tools_exports = {};
20
+ __export(tools_exports, {
21
+ createToolsRouter: () => createToolsRouter
22
+ });
23
+ module.exports = __toCommonJS(tools_exports);
24
+ var import_zod_openapi = require("@hono/zod-openapi");
25
+ const JsonSchemaProperty = import_zod_openapi.z.object({
26
+ type: import_zod_openapi.z.enum(["string", "number", "integer", "boolean", "object", "array"]).optional().describe("Property type"),
27
+ description: import_zod_openapi.z.string().optional().describe("Property description"),
28
+ enum: import_zod_openapi.z.array(import_zod_openapi.z.union([import_zod_openapi.z.string(), import_zod_openapi.z.number(), import_zod_openapi.z.boolean()])).optional().describe("Enum values"),
29
+ default: import_zod_openapi.z.any().optional().describe("Default value")
30
+ }).passthrough().describe("JSON Schema property definition");
31
+ const ToolInputSchema = import_zod_openapi.z.object({
32
+ type: import_zod_openapi.z.literal("object").optional().describe('Schema type, always "object" when present'),
33
+ properties: import_zod_openapi.z.record(JsonSchemaProperty).optional().describe("Property definitions"),
34
+ required: import_zod_openapi.z.array(import_zod_openapi.z.string()).optional().describe("Required property names")
35
+ }).passthrough().describe("JSON Schema for tool input parameters");
36
+ const ToolInfoSchema = import_zod_openapi.z.object({
37
+ id: import_zod_openapi.z.string().describe("Tool identifier"),
38
+ name: import_zod_openapi.z.string().describe("Tool name"),
39
+ description: import_zod_openapi.z.string().describe("Tool description"),
40
+ source: import_zod_openapi.z.enum(["internal", "custom", "mcp"]).describe("Source of the tool (internal, custom, or mcp)"),
41
+ serverName: import_zod_openapi.z.string().optional().describe("MCP server name (if source is mcp)"),
42
+ inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters")
43
+ }).strict().describe("Tool information");
44
+ const AllToolsResponseSchema = import_zod_openapi.z.object({
45
+ tools: import_zod_openapi.z.array(ToolInfoSchema).describe("Array of all available tools"),
46
+ totalCount: import_zod_openapi.z.number().describe("Total number of tools"),
47
+ internalCount: import_zod_openapi.z.number().describe("Number of internal tools"),
48
+ customCount: import_zod_openapi.z.number().describe("Number of custom tools"),
49
+ mcpCount: import_zod_openapi.z.number().describe("Number of MCP tools")
50
+ }).strict().describe("All available tools from all sources");
51
+ function createToolsRouter(getAgent) {
52
+ const app = new import_zod_openapi.OpenAPIHono();
53
+ const allToolsRoute = (0, import_zod_openapi.createRoute)({
54
+ method: "get",
55
+ path: "/tools",
56
+ summary: "List All Tools",
57
+ description: "Retrieves all available tools from all sources (internal, custom, and MCP servers)",
58
+ tags: ["tools"],
59
+ responses: {
60
+ 200: {
61
+ description: "All tools",
62
+ content: { "application/json": { schema: AllToolsResponseSchema } }
63
+ }
64
+ }
65
+ });
66
+ return app.openapi(allToolsRoute, async (ctx) => {
67
+ const agent = await getAgent(ctx);
68
+ const allTools = await agent.getAllTools();
69
+ const mcpToolsWithServerInfo = agent.getAllMcpToolsWithServerInfo();
70
+ const toolList = [];
71
+ let internalCount = 0;
72
+ let customCount = 0;
73
+ let mcpCount = 0;
74
+ for (const [toolName, toolInfo] of Object.entries(allTools)) {
75
+ let source;
76
+ let serverName;
77
+ if (toolName.startsWith("mcp--")) {
78
+ const mcpToolName = toolName.substring(5);
79
+ const mcpToolInfo = mcpToolsWithServerInfo.get(mcpToolName);
80
+ if (mcpToolInfo) {
81
+ source = "mcp";
82
+ serverName = mcpToolInfo.serverName;
83
+ mcpCount++;
84
+ } else {
85
+ source = "mcp";
86
+ mcpCount++;
87
+ }
88
+ } else if (toolName.startsWith("internal--")) {
89
+ source = "internal";
90
+ internalCount++;
91
+ } else if (toolName.startsWith("custom--")) {
92
+ source = "custom";
93
+ customCount++;
94
+ } else {
95
+ source = "internal";
96
+ internalCount++;
97
+ }
98
+ toolList.push({
99
+ id: toolName,
100
+ name: toolName,
101
+ description: toolInfo.description || "No description available",
102
+ source,
103
+ serverName,
104
+ inputSchema: toolInfo.parameters
105
+ });
106
+ }
107
+ toolList.sort((a, b) => {
108
+ const sourceOrder = { internal: 0, custom: 1, mcp: 2 };
109
+ if (a.source !== b.source) {
110
+ return sourceOrder[a.source] - sourceOrder[b.source];
111
+ }
112
+ return a.name.localeCompare(b.name);
113
+ });
114
+ return ctx.json({
115
+ tools: toolList,
116
+ totalCount: toolList.length,
117
+ internalCount,
118
+ customCount,
119
+ mcpCount
120
+ });
121
+ });
122
+ }
123
+ // Annotate the CommonJS export names for ESM import in node:
124
+ 0 && (module.exports = {
125
+ createToolsRouter
126
+ });
@@ -0,0 +1,42 @@
1
+ import { OpenAPIHono } from '@hono/zod-openapi';
2
+ import type { DextoAgent } from '@dexto/core';
3
+ import type { Context } from 'hono';
4
+ type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
5
+ export declare function createToolsRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
6
+ "/tools": {
7
+ $get: {
8
+ input: {};
9
+ output: {
10
+ tools: {
11
+ description: string;
12
+ id: string;
13
+ name: string;
14
+ source: "custom" | "mcp" | "internal";
15
+ serverName?: string | undefined;
16
+ inputSchema?: {
17
+ [x: string]: import("hono/utils/types").JSONValue;
18
+ type?: "object" | undefined;
19
+ properties?: {
20
+ [x: string]: {
21
+ [x: string]: import("hono/utils/types").JSONValue;
22
+ description?: string | undefined;
23
+ default?: any;
24
+ type?: "string" | "number" | "boolean" | "object" | "integer" | "array" | undefined;
25
+ enum?: (string | number | boolean)[] | undefined;
26
+ };
27
+ } | undefined;
28
+ required?: string[] | undefined;
29
+ } | undefined;
30
+ }[];
31
+ totalCount: number;
32
+ internalCount: number;
33
+ customCount: number;
34
+ mcpCount: number;
35
+ };
36
+ outputFormat: "json";
37
+ status: 200;
38
+ };
39
+ };
40
+ }, "/">;
41
+ export {};
42
+ //# sourceMappingURL=tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAqDrE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0FrD"}