@dexto/server 1.5.8 → 1.6.1

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 (58) hide show
  1. package/dist/events/a2a-sse-subscriber.d.ts +1 -1
  2. package/dist/hono/__tests__/test-fixtures.cjs +27 -6
  3. package/dist/hono/__tests__/test-fixtures.d.ts +2 -1
  4. package/dist/hono/__tests__/test-fixtures.d.ts.map +1 -1
  5. package/dist/hono/__tests__/test-fixtures.js +31 -6
  6. package/dist/hono/index.cjs +17 -2
  7. package/dist/hono/index.d.ts +874 -58
  8. package/dist/hono/index.d.ts.map +1 -1
  9. package/dist/hono/index.js +17 -2
  10. package/dist/hono/routes/a2a-tasks.d.ts +6 -6
  11. package/dist/hono/routes/agents.cjs +38 -27
  12. package/dist/hono/routes/agents.d.ts +2 -1
  13. package/dist/hono/routes/agents.d.ts.map +1 -1
  14. package/dist/hono/routes/agents.js +37 -31
  15. package/dist/hono/routes/discovery.cjs +99 -22
  16. package/dist/hono/routes/discovery.d.ts +14 -12
  17. package/dist/hono/routes/discovery.d.ts.map +1 -1
  18. package/dist/hono/routes/discovery.js +89 -22
  19. package/dist/hono/routes/llm.d.ts +2 -2
  20. package/dist/hono/routes/mcp.cjs +96 -14
  21. package/dist/hono/routes/mcp.d.ts +139 -4
  22. package/dist/hono/routes/mcp.d.ts.map +1 -1
  23. package/dist/hono/routes/mcp.js +97 -15
  24. package/dist/hono/routes/memory.d.ts +1 -1
  25. package/dist/hono/routes/models.d.ts +1 -1
  26. package/dist/hono/routes/resources.d.ts +1 -1
  27. package/dist/hono/routes/schedules.cjs +456 -0
  28. package/dist/hono/routes/schedules.d.ts +472 -0
  29. package/dist/hono/routes/schedules.d.ts.map +1 -0
  30. package/dist/hono/routes/schedules.js +439 -0
  31. package/dist/hono/routes/search.d.ts +1 -1
  32. package/dist/hono/routes/sessions.cjs +10 -4
  33. package/dist/hono/routes/sessions.d.ts +135 -5
  34. package/dist/hono/routes/sessions.d.ts.map +1 -1
  35. package/dist/hono/routes/sessions.js +10 -4
  36. package/dist/hono/routes/tools.cjs +12 -19
  37. package/dist/hono/routes/tools.d.ts +5 -3
  38. package/dist/hono/routes/tools.d.ts.map +1 -1
  39. package/dist/hono/routes/tools.js +12 -19
  40. package/dist/hono/routes/workspaces.cjs +136 -0
  41. package/dist/hono/routes/workspaces.d.ts +77 -0
  42. package/dist/hono/routes/workspaces.d.ts.map +1 -0
  43. package/dist/hono/routes/workspaces.js +112 -0
  44. package/dist/hono/schemas/responses.cjs +82 -7
  45. package/dist/hono/schemas/responses.d.ts +366 -16
  46. package/dist/hono/schemas/responses.d.ts.map +1 -1
  47. package/dist/hono/schemas/responses.js +75 -6
  48. package/dist/hono/start-server.cjs +3 -3
  49. package/dist/hono/start-server.d.ts +15 -6
  50. package/dist/hono/start-server.d.ts.map +1 -1
  51. package/dist/hono/start-server.js +3 -3
  52. package/dist/index.cjs +9 -0
  53. package/dist/index.d.ts +1 -0
  54. package/dist/index.d.ts.map +1 -1
  55. package/dist/index.js +4 -0
  56. package/dist/mcp/mcp-handler.d.ts +2 -2
  57. package/dist/mcp/mcp-handler.d.ts.map +1 -1
  58. package/package.json +8 -5
@@ -256,7 +256,8 @@ function createSessionsRouter(getAgent) {
256
256
  createdAt: metadata?.createdAt || null,
257
257
  lastActivity: metadata?.lastActivity || null,
258
258
  messageCount: metadata?.messageCount || 0,
259
- title: metadata?.title || null
259
+ title: metadata?.title || null,
260
+ workspaceId: metadata?.workspaceId || null
260
261
  };
261
262
  } catch {
262
263
  return {
@@ -264,7 +265,8 @@ function createSessionsRouter(getAgent) {
264
265
  createdAt: null,
265
266
  lastActivity: null,
266
267
  messageCount: 0,
267
- title: null
268
+ title: null,
269
+ workspaceId: null
268
270
  };
269
271
  }
270
272
  })
@@ -282,7 +284,8 @@ function createSessionsRouter(getAgent) {
282
284
  createdAt: metadata?.createdAt || Date.now(),
283
285
  lastActivity: metadata?.lastActivity || Date.now(),
284
286
  messageCount: metadata?.messageCount || 0,
285
- title: metadata?.title || null
287
+ title: metadata?.title || null,
288
+ workspaceId: metadata?.workspaceId || null
286
289
  }
287
290
  },
288
291
  201
@@ -299,6 +302,7 @@ function createSessionsRouter(getAgent) {
299
302
  lastActivity: metadata?.lastActivity || null,
300
303
  messageCount: metadata?.messageCount || 0,
301
304
  title: metadata?.title || null,
305
+ workspaceId: metadata?.workspaceId || null,
302
306
  history: history.length
303
307
  }
304
308
  });
@@ -364,6 +368,7 @@ function createSessionsRouter(getAgent) {
364
368
  lastActivity: metadata?.lastActivity || null,
365
369
  messageCount: metadata?.messageCount || 0,
366
370
  title: metadata?.title || null,
371
+ workspaceId: metadata?.workspaceId || null,
367
372
  isBusy
368
373
  }
369
374
  },
@@ -381,7 +386,8 @@ function createSessionsRouter(getAgent) {
381
386
  createdAt: metadata?.createdAt || null,
382
387
  lastActivity: metadata?.lastActivity || null,
383
388
  messageCount: metadata?.messageCount || 0,
384
- title: metadata?.title || title
389
+ title: metadata?.title || title,
390
+ workspaceId: metadata?.workspaceId || null
385
391
  }
386
392
  });
387
393
  }).openapi(generateTitleRoute, async (ctx) => {
@@ -37,15 +37,15 @@ const ToolInfoSchema = import_zod_openapi.z.object({
37
37
  id: import_zod_openapi.z.string().describe("Tool identifier"),
38
38
  name: import_zod_openapi.z.string().describe("Tool name"),
39
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)"),
40
+ source: import_zod_openapi.z.enum(["local", "mcp"]).describe("Source of the tool (local or mcp)"),
41
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")
42
+ inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
43
+ _meta: import_zod_openapi.z.record(import_zod_openapi.z.unknown()).optional().describe("Optional tool metadata (e.g., MCP Apps UI resource info)")
43
44
  }).strict().describe("Tool information");
44
45
  const AllToolsResponseSchema = import_zod_openapi.z.object({
45
46
  tools: import_zod_openapi.z.array(ToolInfoSchema).describe("Array of all available tools"),
46
47
  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"),
48
+ localCount: import_zod_openapi.z.number().describe("Number of local tools"),
49
49
  mcpCount: import_zod_openapi.z.number().describe("Number of MCP tools")
50
50
  }).strict().describe("All available tools from all sources");
51
51
  function createToolsRouter(getAgent) {
@@ -54,7 +54,7 @@ function createToolsRouter(getAgent) {
54
54
  method: "get",
55
55
  path: "/tools",
56
56
  summary: "List All Tools",
57
- description: "Retrieves all available tools from all sources (internal, custom, and MCP servers)",
57
+ description: "Retrieves all available tools from all sources (local and MCP)",
58
58
  tags: ["tools"],
59
59
  responses: {
60
60
  200: {
@@ -68,8 +68,7 @@ function createToolsRouter(getAgent) {
68
68
  const allTools = await agent.getAllTools();
69
69
  const mcpToolsWithServerInfo = agent.getAllMcpToolsWithServerInfo();
70
70
  const toolList = [];
71
- let internalCount = 0;
72
- let customCount = 0;
71
+ let localCount = 0;
73
72
  let mcpCount = 0;
74
73
  for (const [toolName, toolInfo] of Object.entries(allTools)) {
75
74
  let source;
@@ -85,15 +84,9 @@ function createToolsRouter(getAgent) {
85
84
  source = "mcp";
86
85
  mcpCount++;
87
86
  }
88
- } else if (toolName.startsWith("internal--")) {
89
- source = "internal";
90
- internalCount++;
91
- } else if (toolName.startsWith("custom--")) {
92
- source = "custom";
93
- customCount++;
94
87
  } else {
95
- source = "internal";
96
- internalCount++;
88
+ source = "local";
89
+ localCount++;
97
90
  }
98
91
  toolList.push({
99
92
  id: toolName,
@@ -101,11 +94,12 @@ function createToolsRouter(getAgent) {
101
94
  description: toolInfo.description || "No description available",
102
95
  source,
103
96
  serverName,
104
- inputSchema: toolInfo.parameters
97
+ inputSchema: toolInfo.parameters,
98
+ _meta: toolInfo._meta
105
99
  });
106
100
  }
107
101
  toolList.sort((a, b) => {
108
- const sourceOrder = { internal: 0, custom: 1, mcp: 2 };
102
+ const sourceOrder = { local: 0, mcp: 1 };
109
103
  if (a.source !== b.source) {
110
104
  return sourceOrder[a.source] - sourceOrder[b.source];
111
105
  }
@@ -114,8 +108,7 @@ function createToolsRouter(getAgent) {
114
108
  return ctx.json({
115
109
  tools: toolList,
116
110
  totalCount: toolList.length,
117
- internalCount,
118
- customCount,
111
+ localCount,
119
112
  mcpCount
120
113
  });
121
114
  });
@@ -11,7 +11,7 @@ export declare function createToolsRouter(getAgent: GetAgentFn): OpenAPIHono<imp
11
11
  description: string;
12
12
  id: string;
13
13
  name: string;
14
- source: "custom" | "mcp" | "internal";
14
+ source: "local" | "mcp";
15
15
  serverName?: string | undefined;
16
16
  inputSchema?: {
17
17
  [x: string]: import("hono/utils/types").JSONValue;
@@ -27,10 +27,12 @@ export declare function createToolsRouter(getAgent: GetAgentFn): OpenAPIHono<imp
27
27
  } | undefined;
28
28
  required?: string[] | undefined;
29
29
  } | undefined;
30
+ _meta?: {
31
+ [x: string]: import("hono/utils/types").JSONValue;
32
+ } | undefined;
30
33
  }[];
31
34
  totalCount: number;
32
- internalCount: number;
33
- customCount: number;
35
+ localCount: number;
34
36
  mcpCount: number;
35
37
  };
36
38
  outputFormat: "json";
@@ -1 +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"}
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;AAsDrE,wBAAgB,iBAAiB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAkFrD"}
@@ -14,15 +14,15 @@ const ToolInfoSchema = z.object({
14
14
  id: z.string().describe("Tool identifier"),
15
15
  name: z.string().describe("Tool name"),
16
16
  description: z.string().describe("Tool description"),
17
- source: z.enum(["internal", "custom", "mcp"]).describe("Source of the tool (internal, custom, or mcp)"),
17
+ source: z.enum(["local", "mcp"]).describe("Source of the tool (local or mcp)"),
18
18
  serverName: z.string().optional().describe("MCP server name (if source is mcp)"),
19
- inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters")
19
+ inputSchema: ToolInputSchema.optional().describe("JSON Schema for tool input parameters"),
20
+ _meta: z.record(z.unknown()).optional().describe("Optional tool metadata (e.g., MCP Apps UI resource info)")
20
21
  }).strict().describe("Tool information");
21
22
  const AllToolsResponseSchema = z.object({
22
23
  tools: z.array(ToolInfoSchema).describe("Array of all available tools"),
23
24
  totalCount: z.number().describe("Total number of tools"),
24
- internalCount: z.number().describe("Number of internal tools"),
25
- customCount: z.number().describe("Number of custom tools"),
25
+ localCount: z.number().describe("Number of local tools"),
26
26
  mcpCount: z.number().describe("Number of MCP tools")
27
27
  }).strict().describe("All available tools from all sources");
28
28
  function createToolsRouter(getAgent) {
@@ -31,7 +31,7 @@ function createToolsRouter(getAgent) {
31
31
  method: "get",
32
32
  path: "/tools",
33
33
  summary: "List All Tools",
34
- description: "Retrieves all available tools from all sources (internal, custom, and MCP servers)",
34
+ description: "Retrieves all available tools from all sources (local and MCP)",
35
35
  tags: ["tools"],
36
36
  responses: {
37
37
  200: {
@@ -45,8 +45,7 @@ function createToolsRouter(getAgent) {
45
45
  const allTools = await agent.getAllTools();
46
46
  const mcpToolsWithServerInfo = agent.getAllMcpToolsWithServerInfo();
47
47
  const toolList = [];
48
- let internalCount = 0;
49
- let customCount = 0;
48
+ let localCount = 0;
50
49
  let mcpCount = 0;
51
50
  for (const [toolName, toolInfo] of Object.entries(allTools)) {
52
51
  let source;
@@ -62,15 +61,9 @@ function createToolsRouter(getAgent) {
62
61
  source = "mcp";
63
62
  mcpCount++;
64
63
  }
65
- } else if (toolName.startsWith("internal--")) {
66
- source = "internal";
67
- internalCount++;
68
- } else if (toolName.startsWith("custom--")) {
69
- source = "custom";
70
- customCount++;
71
64
  } else {
72
- source = "internal";
73
- internalCount++;
65
+ source = "local";
66
+ localCount++;
74
67
  }
75
68
  toolList.push({
76
69
  id: toolName,
@@ -78,11 +71,12 @@ function createToolsRouter(getAgent) {
78
71
  description: toolInfo.description || "No description available",
79
72
  source,
80
73
  serverName,
81
- inputSchema: toolInfo.parameters
74
+ inputSchema: toolInfo.parameters,
75
+ _meta: toolInfo._meta
82
76
  });
83
77
  }
84
78
  toolList.sort((a, b) => {
85
- const sourceOrder = { internal: 0, custom: 1, mcp: 2 };
79
+ const sourceOrder = { local: 0, mcp: 1 };
86
80
  if (a.source !== b.source) {
87
81
  return sourceOrder[a.source] - sourceOrder[b.source];
88
82
  }
@@ -91,8 +85,7 @@ function createToolsRouter(getAgent) {
91
85
  return ctx.json({
92
86
  tools: toolList,
93
87
  totalCount: toolList.length,
94
- internalCount,
95
- customCount,
88
+ localCount,
96
89
  mcpCount
97
90
  });
98
91
  });
@@ -0,0 +1,136 @@
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 workspaces_exports = {};
20
+ __export(workspaces_exports, {
21
+ createWorkspacesRouter: () => createWorkspacesRouter
22
+ });
23
+ module.exports = __toCommonJS(workspaces_exports);
24
+ var import_zod_openapi = require("@hono/zod-openapi");
25
+ var import_responses = require("../schemas/responses.js");
26
+ const SetWorkspaceSchema = import_zod_openapi.z.object({
27
+ path: import_zod_openapi.z.string().min(1).describe("Absolute workspace root path"),
28
+ name: import_zod_openapi.z.string().optional().describe("Optional workspace display name")
29
+ }).strict().describe("Request body for setting the active workspace");
30
+ function createWorkspacesRouter(getAgent) {
31
+ const app = new import_zod_openapi.OpenAPIHono();
32
+ const listRoute = (0, import_zod_openapi.createRoute)({
33
+ method: "get",
34
+ path: "/workspaces",
35
+ summary: "List Workspaces",
36
+ description: "Retrieves all known workspaces",
37
+ tags: ["workspaces"],
38
+ responses: {
39
+ 200: {
40
+ description: "List of workspaces",
41
+ content: {
42
+ "application/json": {
43
+ schema: import_zod_openapi.z.object({
44
+ workspaces: import_zod_openapi.z.array(import_responses.WorkspaceSchema).describe("Workspace list")
45
+ }).strict()
46
+ }
47
+ }
48
+ }
49
+ }
50
+ });
51
+ const getActiveRoute = (0, import_zod_openapi.createRoute)({
52
+ method: "get",
53
+ path: "/workspaces/active",
54
+ summary: "Get Active Workspace",
55
+ description: "Returns the active workspace, if any",
56
+ tags: ["workspaces"],
57
+ responses: {
58
+ 200: {
59
+ description: "Active workspace",
60
+ content: {
61
+ "application/json": {
62
+ schema: import_zod_openapi.z.object({
63
+ workspace: import_responses.WorkspaceSchema.nullable().describe(
64
+ "Active workspace or null if none is set"
65
+ )
66
+ }).strict()
67
+ }
68
+ }
69
+ }
70
+ }
71
+ });
72
+ const setActiveRoute = (0, import_zod_openapi.createRoute)({
73
+ method: "post",
74
+ path: "/workspaces/active",
75
+ summary: "Set Active Workspace",
76
+ description: "Sets the active workspace for this runtime",
77
+ tags: ["workspaces"],
78
+ request: { body: { content: { "application/json": { schema: SetWorkspaceSchema } } } },
79
+ responses: {
80
+ 200: {
81
+ description: "Active workspace updated",
82
+ content: {
83
+ "application/json": {
84
+ schema: import_zod_openapi.z.object({
85
+ workspace: import_responses.WorkspaceSchema.describe("Updated active workspace")
86
+ }).strict()
87
+ }
88
+ }
89
+ }
90
+ }
91
+ });
92
+ const clearActiveRoute = (0, import_zod_openapi.createRoute)({
93
+ method: "delete",
94
+ path: "/workspaces/active",
95
+ summary: "Clear Active Workspace",
96
+ description: "Clears the active workspace for this runtime",
97
+ tags: ["workspaces"],
98
+ responses: {
99
+ 200: {
100
+ description: "Active workspace cleared",
101
+ content: {
102
+ "application/json": {
103
+ schema: import_zod_openapi.z.object({
104
+ workspace: import_responses.WorkspaceSchema.nullable().describe(
105
+ "Active workspace or null if none is set"
106
+ )
107
+ }).strict()
108
+ }
109
+ }
110
+ }
111
+ }
112
+ });
113
+ return app.openapi(listRoute, async (ctx) => {
114
+ const agent = await getAgent(ctx);
115
+ const workspaces = await agent.listWorkspaces();
116
+ return ctx.json({ workspaces });
117
+ }).openapi(getActiveRoute, async (ctx) => {
118
+ const agent = await getAgent(ctx);
119
+ const workspace = await agent.getWorkspace();
120
+ return ctx.json({ workspace: workspace ?? null });
121
+ }).openapi(setActiveRoute, async (ctx) => {
122
+ const agent = await getAgent(ctx);
123
+ const input = ctx.req.valid("json");
124
+ const workspaceInput = input.name === void 0 ? { path: input.path } : { path: input.path, name: input.name };
125
+ const workspace = await agent.setWorkspace(workspaceInput);
126
+ return ctx.json({ workspace });
127
+ }).openapi(clearActiveRoute, async (ctx) => {
128
+ const agent = await getAgent(ctx);
129
+ await agent.clearWorkspace();
130
+ return ctx.json({ workspace: null });
131
+ });
132
+ }
133
+ // Annotate the CommonJS export names for ESM import in node:
134
+ 0 && (module.exports = {
135
+ createWorkspacesRouter
136
+ });
@@ -0,0 +1,77 @@
1
+ import { OpenAPIHono } from '@hono/zod-openapi';
2
+ import type { GetAgentFn } from '../index.js';
3
+ export declare function createWorkspacesRouter(getAgent: GetAgentFn): OpenAPIHono<import("hono").Env, {
4
+ "/workspaces": {
5
+ $get: {
6
+ input: {};
7
+ output: {
8
+ workspaces: {
9
+ path: string;
10
+ id: string;
11
+ createdAt: number;
12
+ lastActiveAt: number;
13
+ name?: string | null | undefined;
14
+ }[];
15
+ };
16
+ outputFormat: "json";
17
+ status: 200;
18
+ };
19
+ };
20
+ } & {
21
+ "/workspaces/active": {
22
+ $get: {
23
+ input: {};
24
+ output: {
25
+ workspace: {
26
+ path: string;
27
+ id: string;
28
+ createdAt: number;
29
+ lastActiveAt: number;
30
+ name?: string | null | undefined;
31
+ } | null;
32
+ };
33
+ outputFormat: "json";
34
+ status: 200;
35
+ };
36
+ };
37
+ } & {
38
+ "/workspaces/active": {
39
+ $post: {
40
+ input: {
41
+ json: {
42
+ path: string;
43
+ name?: string | undefined;
44
+ };
45
+ };
46
+ output: {
47
+ workspace: {
48
+ path: string;
49
+ id: string;
50
+ createdAt: number;
51
+ lastActiveAt: number;
52
+ name?: string | null | undefined;
53
+ };
54
+ };
55
+ outputFormat: "json";
56
+ status: 200;
57
+ };
58
+ };
59
+ } & {
60
+ "/workspaces/active": {
61
+ $delete: {
62
+ input: {};
63
+ output: {
64
+ workspace: {
65
+ path: string;
66
+ id: string;
67
+ createdAt: number;
68
+ lastActiveAt: number;
69
+ name?: string | null | undefined;
70
+ } | null;
71
+ };
72
+ outputFormat: "json";
73
+ status: 200;
74
+ };
75
+ };
76
+ }, "/">;
77
+ //# sourceMappingURL=workspaces.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workspaces.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/workspaces.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAEhE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAU9C,wBAAgB,sBAAsB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0H1D"}
@@ -0,0 +1,112 @@
1
+ import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2
+ import { WorkspaceSchema } from "../schemas/responses.js";
3
+ const SetWorkspaceSchema = z.object({
4
+ path: z.string().min(1).describe("Absolute workspace root path"),
5
+ name: z.string().optional().describe("Optional workspace display name")
6
+ }).strict().describe("Request body for setting the active workspace");
7
+ function createWorkspacesRouter(getAgent) {
8
+ const app = new OpenAPIHono();
9
+ const listRoute = createRoute({
10
+ method: "get",
11
+ path: "/workspaces",
12
+ summary: "List Workspaces",
13
+ description: "Retrieves all known workspaces",
14
+ tags: ["workspaces"],
15
+ responses: {
16
+ 200: {
17
+ description: "List of workspaces",
18
+ content: {
19
+ "application/json": {
20
+ schema: z.object({
21
+ workspaces: z.array(WorkspaceSchema).describe("Workspace list")
22
+ }).strict()
23
+ }
24
+ }
25
+ }
26
+ }
27
+ });
28
+ const getActiveRoute = createRoute({
29
+ method: "get",
30
+ path: "/workspaces/active",
31
+ summary: "Get Active Workspace",
32
+ description: "Returns the active workspace, if any",
33
+ tags: ["workspaces"],
34
+ responses: {
35
+ 200: {
36
+ description: "Active workspace",
37
+ content: {
38
+ "application/json": {
39
+ schema: z.object({
40
+ workspace: WorkspaceSchema.nullable().describe(
41
+ "Active workspace or null if none is set"
42
+ )
43
+ }).strict()
44
+ }
45
+ }
46
+ }
47
+ }
48
+ });
49
+ const setActiveRoute = createRoute({
50
+ method: "post",
51
+ path: "/workspaces/active",
52
+ summary: "Set Active Workspace",
53
+ description: "Sets the active workspace for this runtime",
54
+ tags: ["workspaces"],
55
+ request: { body: { content: { "application/json": { schema: SetWorkspaceSchema } } } },
56
+ responses: {
57
+ 200: {
58
+ description: "Active workspace updated",
59
+ content: {
60
+ "application/json": {
61
+ schema: z.object({
62
+ workspace: WorkspaceSchema.describe("Updated active workspace")
63
+ }).strict()
64
+ }
65
+ }
66
+ }
67
+ }
68
+ });
69
+ const clearActiveRoute = createRoute({
70
+ method: "delete",
71
+ path: "/workspaces/active",
72
+ summary: "Clear Active Workspace",
73
+ description: "Clears the active workspace for this runtime",
74
+ tags: ["workspaces"],
75
+ responses: {
76
+ 200: {
77
+ description: "Active workspace cleared",
78
+ content: {
79
+ "application/json": {
80
+ schema: z.object({
81
+ workspace: WorkspaceSchema.nullable().describe(
82
+ "Active workspace or null if none is set"
83
+ )
84
+ }).strict()
85
+ }
86
+ }
87
+ }
88
+ }
89
+ });
90
+ return app.openapi(listRoute, async (ctx) => {
91
+ const agent = await getAgent(ctx);
92
+ const workspaces = await agent.listWorkspaces();
93
+ return ctx.json({ workspaces });
94
+ }).openapi(getActiveRoute, async (ctx) => {
95
+ const agent = await getAgent(ctx);
96
+ const workspace = await agent.getWorkspace();
97
+ return ctx.json({ workspace: workspace ?? null });
98
+ }).openapi(setActiveRoute, async (ctx) => {
99
+ const agent = await getAgent(ctx);
100
+ const input = ctx.req.valid("json");
101
+ const workspaceInput = input.name === void 0 ? { path: input.path } : { path: input.path, name: input.name };
102
+ const workspace = await agent.setWorkspace(workspaceInput);
103
+ return ctx.json({ workspace });
104
+ }).openapi(clearActiveRoute, async (ctx) => {
105
+ const agent = await getAgent(ctx);
106
+ await agent.clearWorkspace();
107
+ return ctx.json({ workspace: null });
108
+ });
109
+ }
110
+ export {
111
+ createWorkspacesRouter
112
+ };