@dexto/server 1.6.19 → 1.6.21

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 (111) hide show
  1. package/dist/a2a/jsonrpc/methods.cjs +1 -1
  2. package/dist/a2a/jsonrpc/methods.d.ts +14 -4
  3. package/dist/a2a/jsonrpc/methods.d.ts.map +1 -1
  4. package/dist/a2a/jsonrpc/methods.js +1 -1
  5. package/dist/hono/index.cjs +39 -8
  6. package/dist/hono/index.d.ts +43 -4503
  7. package/dist/hono/index.d.ts.map +1 -1
  8. package/dist/hono/index.js +42 -9
  9. package/dist/hono/routes/a2a-jsonrpc.d.ts.map +1 -1
  10. package/dist/hono/routes/a2a-tasks.cjs +173 -34
  11. package/dist/hono/routes/a2a-tasks.d.ts +1 -498
  12. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
  13. package/dist/hono/routes/a2a-tasks.js +177 -34
  14. package/dist/hono/routes/a2a.d.ts.map +1 -1
  15. package/dist/hono/routes/agents.cjs +410 -329
  16. package/dist/hono/routes/agents.d.ts +16048 -73
  17. package/dist/hono/routes/agents.d.ts.map +1 -1
  18. package/dist/hono/routes/agents.js +418 -330
  19. package/dist/hono/routes/approvals.cjs +103 -78
  20. package/dist/hono/routes/approvals.d.ts +2090 -112
  21. package/dist/hono/routes/approvals.d.ts.map +1 -1
  22. package/dist/hono/routes/approvals.js +108 -78
  23. package/dist/hono/routes/dexto-auth.cjs +40 -33
  24. package/dist/hono/routes/dexto-auth.d.ts +401 -2
  25. package/dist/hono/routes/dexto-auth.d.ts.map +1 -1
  26. package/dist/hono/routes/dexto-auth.js +40 -33
  27. package/dist/hono/routes/discovery.cjs +16 -14
  28. package/dist/hono/routes/discovery.d.ts +586 -1
  29. package/dist/hono/routes/discovery.d.ts.map +1 -1
  30. package/dist/hono/routes/discovery.js +16 -14
  31. package/dist/hono/routes/greeting.cjs +26 -22
  32. package/dist/hono/routes/greeting.d.ts +787 -3
  33. package/dist/hono/routes/greeting.d.ts.map +1 -1
  34. package/dist/hono/routes/greeting.js +26 -22
  35. package/dist/hono/routes/health.d.ts +1 -1
  36. package/dist/hono/routes/key.cjs +60 -52
  37. package/dist/hono/routes/key.d.ts +1597 -1
  38. package/dist/hono/routes/key.d.ts.map +1 -1
  39. package/dist/hono/routes/key.js +60 -52
  40. package/dist/hono/routes/llm.cjs +381 -348
  41. package/dist/hono/routes/llm.d.ts +12137 -87
  42. package/dist/hono/routes/llm.d.ts.map +1 -1
  43. package/dist/hono/routes/llm.js +385 -348
  44. package/dist/hono/routes/mcp.cjs +273 -212
  45. package/dist/hono/routes/mcp.d.ts +6605 -316
  46. package/dist/hono/routes/mcp.d.ts.map +1 -1
  47. package/dist/hono/routes/mcp.js +287 -213
  48. package/dist/hono/routes/memory.cjs +102 -89
  49. package/dist/hono/routes/memory.d.ts +5368 -4
  50. package/dist/hono/routes/memory.d.ts.map +1 -1
  51. package/dist/hono/routes/memory.js +108 -90
  52. package/dist/hono/routes/messages.cjs +171 -164
  53. package/dist/hono/routes/messages.d.ts +3899 -10
  54. package/dist/hono/routes/messages.d.ts.map +1 -1
  55. package/dist/hono/routes/messages.js +181 -165
  56. package/dist/hono/routes/models.cjs +106 -64
  57. package/dist/hono/routes/models.d.ts +2874 -1
  58. package/dist/hono/routes/models.d.ts.map +1 -1
  59. package/dist/hono/routes/models.js +108 -64
  60. package/dist/hono/routes/openrouter.cjs +79 -65
  61. package/dist/hono/routes/openrouter.d.ts +854 -1
  62. package/dist/hono/routes/openrouter.d.ts.map +1 -1
  63. package/dist/hono/routes/openrouter.js +79 -65
  64. package/dist/hono/routes/prompts.cjs +137 -104
  65. package/dist/hono/routes/prompts.d.ts +2820 -12
  66. package/dist/hono/routes/prompts.d.ts.map +1 -1
  67. package/dist/hono/routes/prompts.js +144 -105
  68. package/dist/hono/routes/queue.cjs +158 -132
  69. package/dist/hono/routes/queue.d.ts +5148 -13
  70. package/dist/hono/routes/queue.d.ts.map +1 -1
  71. package/dist/hono/routes/queue.js +168 -133
  72. package/dist/hono/routes/resources.cjs +65 -46
  73. package/dist/hono/routes/resources.d.ts +1983 -5
  74. package/dist/hono/routes/resources.d.ts.map +1 -1
  75. package/dist/hono/routes/resources.js +72 -47
  76. package/dist/hono/routes/schedules.cjs +233 -226
  77. package/dist/hono/routes/schedules.d.ts +4202 -26
  78. package/dist/hono/routes/schedules.d.ts.map +1 -1
  79. package/dist/hono/routes/schedules.js +233 -226
  80. package/dist/hono/routes/search.cjs +34 -30
  81. package/dist/hono/routes/search.d.ts +2837 -14
  82. package/dist/hono/routes/search.d.ts.map +1 -1
  83. package/dist/hono/routes/search.js +40 -31
  84. package/dist/hono/routes/sessions.cjs +404 -392
  85. package/dist/hono/routes/sessions.d.ts +16585 -30
  86. package/dist/hono/routes/sessions.d.ts.map +1 -1
  87. package/dist/hono/routes/sessions.js +408 -393
  88. package/dist/hono/routes/static.d.ts.map +1 -1
  89. package/dist/hono/routes/system-prompt.cjs +57 -61
  90. package/dist/hono/routes/system-prompt.d.ts +1228 -2
  91. package/dist/hono/routes/system-prompt.d.ts.map +1 -1
  92. package/dist/hono/routes/system-prompt.js +58 -62
  93. package/dist/hono/routes/tools.cjs +29 -34
  94. package/dist/hono/routes/tools.d.ts +1756 -7
  95. package/dist/hono/routes/tools.d.ts.map +1 -1
  96. package/dist/hono/routes/tools.js +33 -33
  97. package/dist/hono/routes/webhooks.cjs +159 -132
  98. package/dist/hono/routes/webhooks.d.ts +2504 -14
  99. package/dist/hono/routes/webhooks.d.ts.map +1 -1
  100. package/dist/hono/routes/webhooks.js +163 -132
  101. package/dist/hono/routes/workspaces.cjs +84 -79
  102. package/dist/hono/routes/workspaces.d.ts +2093 -2
  103. package/dist/hono/routes/workspaces.d.ts.map +1 -1
  104. package/dist/hono/routes/workspaces.js +89 -80
  105. package/dist/hono/schemas/responses.cjs +492 -235
  106. package/dist/hono/schemas/responses.d.ts +1461 -146
  107. package/dist/hono/schemas/responses.d.ts.map +1 -1
  108. package/dist/hono/schemas/responses.js +247 -9
  109. package/dist/hono/types.d.ts +11 -0
  110. package/dist/hono/types.d.ts.map +1 -1
  111. package/package.json +7 -7
@@ -1 +1 @@
1
- {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AACpC,KAAK,UAAU,GAAG,CAAC,GAAG,EAAE,OAAO,KAAK,UAAU,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;AAkCrE,wBAAgB,oBAAoB,CAChC,QAAQ,EAAE,UAAU,EACpB,iBAAiB,EAAE,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA0N5C"}
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAe,CAAC,EAAE,MAAM,mBAAmB,CAAC;AAEhE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAO5E,OAAO,KAAK,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAuBlE,QAAA,MAAM,iBAAiB;;;;;;;;;;;;EASgC,CAAC;AAExD,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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KAAK,eAAe,GAAG,kBAAkB,CAAC,OAAO,SAAS,EAAE,mBAAmB,CAAC,CAAC;AAEjF,MAAM,MAAM,oBAAoB,GAC1B,mBAAmB,GACnB,eAAe,GACf,cAAc,GACd,iBAAiB,GACjB,eAAe,CAAC"}
@@ -1,9 +1,15 @@
1
1
  import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2
+ import { DextoRuntimeError, ErrorType } from "@dexto/core";
3
+ import {
4
+ ApiErrorResponseSchema,
5
+ BadRequestErrorResponse,
6
+ InternalErrorResponse
7
+ } from "../schemas/responses.js";
2
8
  const WebhookResponseSchema = z.object({
3
9
  id: z.string().describe("Unique webhook identifier"),
4
10
  url: z.string().url().describe("Webhook URL"),
5
11
  description: z.string().optional().describe("Webhook description"),
6
- createdAt: z.union([z.date(), z.number()]).describe("Creation timestamp (Date or Unix ms)")
12
+ createdAt: z.string().datetime().describe("Creation timestamp (ISO 8601)")
7
13
  }).strict().describe("Webhook response object");
8
14
  const WebhookTestResultSchema = z.object({
9
15
  success: z.boolean().describe("Whether the webhook test succeeded"),
@@ -16,113 +22,129 @@ const WebhookBodySchema = z.object({
16
22
  secret: z.string().optional().describe("A secret key for HMAC signature verification"),
17
23
  description: z.string().optional().describe("A description of the webhook for reference")
18
24
  }).describe("Request body for registering a webhook");
19
- function createWebhooksRouter(getAgent, webhookSubscriber) {
20
- const app = new OpenAPIHono();
21
- const registerRoute = createRoute({
22
- method: "post",
23
- path: "/webhooks",
24
- summary: "Register Webhook",
25
- description: "Registers a new webhook endpoint to receive agent events",
26
- tags: ["webhooks"],
27
- request: { body: { content: { "application/json": { schema: WebhookBodySchema } } } },
28
- responses: {
29
- 201: {
30
- description: "Webhook registered",
31
- content: {
32
- "application/json": {
33
- schema: z.object({
34
- webhook: WebhookResponseSchema.describe(
35
- "Registered webhook details"
36
- )
37
- }).strict()
38
- }
25
+ const registerRoute = createRoute({
26
+ method: "post",
27
+ path: "/webhooks",
28
+ summary: "Register Webhook",
29
+ description: "Registers a new webhook endpoint to receive agent events",
30
+ tags: ["webhooks"],
31
+ request: { body: { content: { "application/json": { schema: WebhookBodySchema } } } },
32
+ responses: {
33
+ 201: {
34
+ description: "Webhook registered",
35
+ content: {
36
+ "application/json": {
37
+ schema: z.object({
38
+ webhook: WebhookResponseSchema.describe("Registered webhook details")
39
+ }).strict()
39
40
  }
40
41
  }
41
- }
42
- });
43
- const listRoute = createRoute({
44
- method: "get",
45
- path: "/webhooks",
46
- summary: "List Webhooks",
47
- description: "Retrieves a list of all registered webhooks",
48
- tags: ["webhooks"],
49
- responses: {
50
- 200: {
51
- description: "List webhooks",
52
- content: {
53
- "application/json": {
54
- schema: z.object({
55
- webhooks: z.array(WebhookResponseSchema).describe("Array of registered webhooks")
56
- }).strict()
57
- }
42
+ },
43
+ 400: BadRequestErrorResponse,
44
+ 500: InternalErrorResponse
45
+ }
46
+ });
47
+ const listRoute = createRoute({
48
+ method: "get",
49
+ path: "/webhooks",
50
+ summary: "List Webhooks",
51
+ description: "Retrieves a list of all registered webhooks",
52
+ tags: ["webhooks"],
53
+ responses: {
54
+ 200: {
55
+ description: "List webhooks",
56
+ content: {
57
+ "application/json": {
58
+ schema: z.object({
59
+ webhooks: z.array(WebhookResponseSchema).describe("Array of registered webhooks")
60
+ }).strict()
58
61
  }
59
62
  }
60
- }
61
- });
62
- const getRoute = createRoute({
63
- method: "get",
64
- path: "/webhooks/{webhookId}",
65
- summary: "Get Webhook Details",
66
- description: "Fetches details for a specific webhook",
67
- tags: ["webhooks"],
68
- request: { params: z.object({ webhookId: z.string().describe("The webhook identifier") }) },
69
- responses: {
70
- 200: {
71
- description: "Webhook",
72
- content: {
73
- "application/json": {
74
- schema: z.object({
75
- webhook: WebhookResponseSchema.describe("Webhook details")
76
- }).strict()
77
- }
63
+ },
64
+ 500: InternalErrorResponse
65
+ }
66
+ });
67
+ const getRoute = createRoute({
68
+ method: "get",
69
+ path: "/webhooks/{webhookId}",
70
+ summary: "Get Webhook Details",
71
+ description: "Fetches details for a specific webhook",
72
+ tags: ["webhooks"],
73
+ request: { params: z.object({ webhookId: z.string().describe("The webhook identifier") }) },
74
+ responses: {
75
+ 200: {
76
+ description: "Webhook",
77
+ content: {
78
+ "application/json": {
79
+ schema: z.object({
80
+ webhook: WebhookResponseSchema.describe("Webhook details")
81
+ }).strict()
78
82
  }
79
- },
80
- 404: { description: "Not found" }
83
+ }
84
+ },
85
+ 404: {
86
+ description: "Not found",
87
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
81
88
  }
82
- });
83
- const deleteRoute = createRoute({
84
- method: "delete",
85
- path: "/webhooks/{webhookId}",
86
- summary: "Delete Webhook",
87
- description: "Permanently removes a webhook endpoint. This action cannot be undone",
88
- tags: ["webhooks"],
89
- request: { params: z.object({ webhookId: z.string().describe("The webhook identifier") }) },
90
- responses: {
91
- 200: {
92
- description: "Removed",
93
- content: {
94
- "application/json": {
95
- schema: z.object({
96
- status: z.literal("removed").describe("Operation status indicating successful removal"),
97
- webhookId: z.string().describe("ID of the removed webhook")
98
- }).strict()
99
- }
89
+ }
90
+ });
91
+ const deleteRoute = createRoute({
92
+ method: "delete",
93
+ path: "/webhooks/{webhookId}",
94
+ summary: "Delete Webhook",
95
+ description: "Permanently removes a webhook endpoint. This action cannot be undone",
96
+ tags: ["webhooks"],
97
+ request: { params: z.object({ webhookId: z.string().describe("The webhook identifier") }) },
98
+ responses: {
99
+ 200: {
100
+ description: "Removed",
101
+ content: {
102
+ "application/json": {
103
+ schema: z.object({
104
+ status: z.literal("removed").describe("Operation status indicating successful removal"),
105
+ webhookId: z.string().describe("ID of the removed webhook")
106
+ }).strict()
100
107
  }
101
- },
102
- 404: { description: "Not found" }
108
+ }
109
+ },
110
+ 404: {
111
+ description: "Not found",
112
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
103
113
  }
104
- });
105
- const testRoute = createRoute({
106
- method: "post",
107
- path: "/webhooks/{webhookId}/test",
108
- summary: "Test Webhook",
109
- description: "Sends a sample event to test webhook connectivity and configuration",
110
- tags: ["webhooks"],
111
- request: { params: z.object({ webhookId: z.string().describe("The webhook identifier") }) },
112
- responses: {
113
- 200: {
114
- description: "Test result",
115
- content: {
116
- "application/json": {
117
- schema: z.object({
118
- test: z.literal("completed").describe("Test status indicating completion"),
119
- result: WebhookTestResultSchema.describe("Test execution results")
120
- }).strict()
121
- }
114
+ }
115
+ });
116
+ const testRoute = createRoute({
117
+ method: "post",
118
+ path: "/webhooks/{webhookId}/test",
119
+ summary: "Test Webhook",
120
+ description: "Sends a sample event to test webhook connectivity and configuration",
121
+ tags: ["webhooks"],
122
+ request: { params: z.object({ webhookId: z.string().describe("The webhook identifier") }) },
123
+ responses: {
124
+ 200: {
125
+ description: "Test result",
126
+ content: {
127
+ "application/json": {
128
+ schema: z.object({
129
+ test: z.literal("completed").describe("Test status indicating completion"),
130
+ result: WebhookTestResultSchema.describe("Test execution results")
131
+ }).strict()
122
132
  }
123
- },
124
- 404: { description: "Not found" }
133
+ }
134
+ },
135
+ 404: {
136
+ description: "Not found",
137
+ content: { "application/json": { schema: ApiErrorResponseSchema } }
125
138
  }
139
+ }
140
+ });
141
+ function createWebhooksRouter(getAgent, webhookSubscriber) {
142
+ const app = new OpenAPIHono();
143
+ const serializeWebhook = (webhook) => ({
144
+ id: webhook.id,
145
+ url: webhook.url,
146
+ description: webhook.description,
147
+ createdAt: webhook.createdAt.toISOString()
126
148
  });
127
149
  return app.openapi(registerRoute, async (ctx) => {
128
150
  const agent = await getAgent(ctx);
@@ -139,64 +161,73 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
139
161
  agent.logger.info(`Webhook registered: ${webhookId} -> ${url}`);
140
162
  return ctx.json(
141
163
  {
142
- webhook: {
143
- id: webhook.id,
144
- url: webhook.url,
145
- description: webhook.description,
146
- createdAt: webhook.createdAt
147
- }
164
+ webhook: serializeWebhook(webhook)
148
165
  },
149
166
  201
150
167
  );
151
168
  }).openapi(listRoute, async (ctx) => {
152
- const webhooks = webhookSubscriber.getWebhooks().map((webhook) => ({
153
- id: webhook.id,
154
- url: webhook.url,
155
- description: webhook.description,
156
- createdAt: webhook.createdAt
157
- }));
158
- return ctx.json({ webhooks });
169
+ const webhooks = webhookSubscriber.getWebhooks().map(serializeWebhook);
170
+ return ctx.json({ webhooks }, 200);
159
171
  }).openapi(getRoute, (ctx) => {
160
172
  const { webhookId } = ctx.req.valid("param");
161
173
  const webhook = webhookSubscriber.getWebhook(webhookId);
162
174
  if (!webhook) {
163
- return ctx.json({ error: "Webhook not found" }, 404);
175
+ throw new DextoRuntimeError(
176
+ "webhook_not_found",
177
+ "webhook",
178
+ ErrorType.NOT_FOUND,
179
+ "Webhook not found",
180
+ { webhookId }
181
+ );
164
182
  }
165
- return ctx.json({
166
- webhook: {
167
- id: webhook.id,
168
- url: webhook.url,
169
- description: webhook.description,
170
- createdAt: webhook.createdAt
171
- }
172
- });
183
+ return ctx.json(
184
+ {
185
+ webhook: serializeWebhook(webhook)
186
+ },
187
+ 200
188
+ );
173
189
  }).openapi(deleteRoute, async (ctx) => {
174
190
  const agent = await getAgent(ctx);
175
191
  const { webhookId } = ctx.req.valid("param");
176
192
  const removed = webhookSubscriber.removeWebhook(webhookId);
177
193
  if (!removed) {
178
- return ctx.json({ error: "Webhook not found" }, 404);
194
+ throw new DextoRuntimeError(
195
+ "webhook_not_found",
196
+ "webhook",
197
+ ErrorType.NOT_FOUND,
198
+ "Webhook not found",
199
+ { webhookId }
200
+ );
179
201
  }
180
202
  agent.logger.info(`Webhook removed: ${webhookId}`);
181
- return ctx.json({ status: "removed", webhookId });
203
+ return ctx.json({ status: "removed", webhookId }, 200);
182
204
  }).openapi(testRoute, async (ctx) => {
183
205
  const agent = await getAgent(ctx);
184
206
  const { webhookId } = ctx.req.valid("param");
185
207
  const webhook = webhookSubscriber.getWebhook(webhookId);
186
208
  if (!webhook) {
187
- return ctx.json({ error: "Webhook not found" }, 404);
209
+ throw new DextoRuntimeError(
210
+ "webhook_not_found",
211
+ "webhook",
212
+ ErrorType.NOT_FOUND,
213
+ "Webhook not found",
214
+ { webhookId }
215
+ );
188
216
  }
189
217
  agent.logger.info(`Testing webhook: ${webhookId}`);
190
218
  const result = await webhookSubscriber.testWebhook(webhookId);
191
- return ctx.json({
192
- test: "completed",
193
- result: {
194
- success: result.success,
195
- statusCode: result.statusCode,
196
- responseTime: result.responseTime,
197
- error: result.error
198
- }
199
- });
219
+ return ctx.json(
220
+ {
221
+ test: "completed",
222
+ result: {
223
+ success: result.success,
224
+ statusCode: result.statusCode,
225
+ responseTime: result.responseTime,
226
+ error: result.error
227
+ }
228
+ },
229
+ 200
230
+ );
200
231
  });
201
232
  }
202
233
  export {
@@ -27,107 +27,112 @@ const SetWorkspaceSchema = import_zod_openapi.z.object({
27
27
  path: import_zod_openapi.z.string().min(1).describe("Absolute workspace root path"),
28
28
  name: import_zod_openapi.z.string().optional().describe("Optional workspace display name")
29
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
- }
30
+ const listRoute = (0, import_zod_openapi.createRoute)({
31
+ method: "get",
32
+ path: "/workspaces",
33
+ summary: "List Workspaces",
34
+ description: "Retrieves all known workspaces",
35
+ tags: ["workspaces"],
36
+ responses: {
37
+ 200: {
38
+ description: "List of workspaces",
39
+ content: {
40
+ "application/json": {
41
+ schema: import_zod_openapi.z.object({
42
+ workspaces: import_zod_openapi.z.array(import_responses.WorkspaceSchema).describe("Workspace list")
43
+ }).strict()
47
44
  }
48
45
  }
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
- }
46
+ },
47
+ 500: import_responses.InternalErrorResponse
48
+ }
49
+ });
50
+ const getActiveRoute = (0, import_zod_openapi.createRoute)({
51
+ method: "get",
52
+ path: "/workspaces/active",
53
+ summary: "Get Active Workspace",
54
+ description: "Returns the active workspace, if any",
55
+ tags: ["workspaces"],
56
+ responses: {
57
+ 200: {
58
+ description: "Active workspace",
59
+ content: {
60
+ "application/json": {
61
+ schema: import_zod_openapi.z.object({
62
+ workspace: import_responses.WorkspaceSchema.nullable().describe(
63
+ "Active workspace or null if none is set"
64
+ )
65
+ }).strict()
68
66
  }
69
67
  }
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
- }
68
+ },
69
+ 500: import_responses.InternalErrorResponse
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()
88
87
  }
89
88
  }
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
- }
89
+ },
90
+ 400: import_responses.BadRequestErrorResponse,
91
+ 500: import_responses.InternalErrorResponse
92
+ }
93
+ });
94
+ const clearActiveRoute = (0, import_zod_openapi.createRoute)({
95
+ method: "delete",
96
+ path: "/workspaces/active",
97
+ summary: "Clear Active Workspace",
98
+ description: "Clears the active workspace for this runtime",
99
+ tags: ["workspaces"],
100
+ responses: {
101
+ 200: {
102
+ description: "Active workspace cleared",
103
+ content: {
104
+ "application/json": {
105
+ schema: import_zod_openapi.z.object({
106
+ workspace: import_responses.WorkspaceSchema.nullable().describe(
107
+ "Active workspace or null if none is set"
108
+ )
109
+ }).strict()
109
110
  }
110
111
  }
111
- }
112
- });
112
+ },
113
+ 500: import_responses.InternalErrorResponse
114
+ }
115
+ });
116
+ function createWorkspacesRouter(getAgent) {
117
+ const app = new import_zod_openapi.OpenAPIHono();
113
118
  return app.openapi(listRoute, async (ctx) => {
114
119
  const agent = await getAgent(ctx);
115
120
  const workspaces = await agent.listWorkspaces();
116
- return ctx.json({ workspaces });
121
+ return ctx.json({ workspaces }, 200);
117
122
  }).openapi(getActiveRoute, async (ctx) => {
118
123
  const agent = await getAgent(ctx);
119
124
  const workspace = await agent.getWorkspace();
120
- return ctx.json({ workspace: workspace ?? null });
125
+ return ctx.json({ workspace: workspace ?? null }, 200);
121
126
  }).openapi(setActiveRoute, async (ctx) => {
122
127
  const agent = await getAgent(ctx);
123
128
  const input = ctx.req.valid("json");
124
129
  const workspaceInput = input.name === void 0 ? { path: input.path } : { path: input.path, name: input.name };
125
130
  const workspace = await agent.setWorkspace(workspaceInput);
126
- return ctx.json({ workspace });
131
+ return ctx.json({ workspace }, 200);
127
132
  }).openapi(clearActiveRoute, async (ctx) => {
128
133
  const agent = await getAgent(ctx);
129
134
  await agent.clearWorkspace();
130
- return ctx.json({ workspace: null });
135
+ return ctx.json({ workspace: null }, 200);
131
136
  });
132
137
  }
133
138
  // Annotate the CommonJS export names for ESM import in node: