@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":"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"}
1
+ {"version":3,"file":"tools.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/tools.ts"],"names":[],"mappings":"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"}
@@ -1,15 +1,10 @@
1
1
  import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
2
- const JsonSchemaProperty = z.object({
3
- type: z.enum(["string", "number", "integer", "boolean", "object", "array"]).optional().describe("Property type"),
4
- description: z.string().optional().describe("Property description"),
5
- enum: z.array(z.union([z.string(), z.number(), z.boolean()])).optional().describe("Enum values"),
6
- default: z.any().optional().describe("Default value")
7
- }).passthrough().describe("JSON Schema property definition");
8
- const ToolInputSchema = z.object({
9
- type: z.literal("object").optional().describe('Schema type, always "object" when present'),
10
- properties: z.record(JsonSchemaProperty).optional().describe("Property definitions"),
11
- required: z.array(z.string()).optional().describe("Required property names")
12
- }).passthrough().describe("JSON Schema for tool input parameters");
2
+ import {
3
+ InternalErrorResponse,
4
+ JsonObjectSchema,
5
+ JsonValueSchema,
6
+ ToolInputSchema
7
+ } from "../schemas/responses.js";
13
8
  const ToolInfoSchema = z.object({
14
9
  id: z.string().describe("Tool identifier"),
15
10
  name: z.string().describe("Tool name"),
@@ -17,7 +12,7 @@ const ToolInfoSchema = z.object({
17
12
  source: z.enum(["local", "mcp"]).describe("Source of the tool (local or mcp)"),
18
13
  serverName: z.string().optional().describe("MCP server name (if source is mcp)"),
19
14
  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)")
15
+ _meta: z.record(z.string(), JsonValueSchema).optional().describe("Optional tool metadata (e.g., MCP Apps UI resource info)")
21
16
  }).strict().describe("Tool information");
22
17
  const AllToolsResponseSchema = z.object({
23
18
  tools: z.array(ToolInfoSchema).describe("Array of all available tools"),
@@ -25,21 +20,22 @@ const AllToolsResponseSchema = z.object({
25
20
  localCount: z.number().describe("Number of local tools"),
26
21
  mcpCount: z.number().describe("Number of MCP tools")
27
22
  }).strict().describe("All available tools from all sources");
23
+ const allToolsRoute = createRoute({
24
+ method: "get",
25
+ path: "/tools",
26
+ summary: "List All Tools",
27
+ description: "Retrieves all available tools from all sources (local and MCP)",
28
+ tags: ["tools"],
29
+ responses: {
30
+ 200: {
31
+ description: "All tools",
32
+ content: { "application/json": { schema: AllToolsResponseSchema } }
33
+ },
34
+ 500: InternalErrorResponse
35
+ }
36
+ });
28
37
  function createToolsRouter(getAgent) {
29
38
  const app = new OpenAPIHono();
30
- const allToolsRoute = createRoute({
31
- method: "get",
32
- path: "/tools",
33
- summary: "List All Tools",
34
- description: "Retrieves all available tools from all sources (local and MCP)",
35
- tags: ["tools"],
36
- responses: {
37
- 200: {
38
- description: "All tools",
39
- content: { "application/json": { schema: AllToolsResponseSchema } }
40
- }
41
- }
42
- });
43
39
  return app.openapi(allToolsRoute, async (ctx) => {
44
40
  const agent = await getAgent(ctx);
45
41
  const allTools = await agent.getAllTools();
@@ -65,14 +61,15 @@ function createToolsRouter(getAgent) {
65
61
  source = "local";
66
62
  localCount++;
67
63
  }
64
+ const metadataResult = JsonObjectSchema.safeParse(toolInfo._meta);
68
65
  toolList.push({
69
66
  id: toolName,
70
67
  name: toolName,
71
68
  description: toolInfo.description || "No description available",
72
69
  source,
73
70
  serverName,
74
- inputSchema: toolInfo.parameters,
75
- _meta: toolInfo._meta
71
+ inputSchema: toolInfo.parameters === void 0 ? void 0 : ToolInputSchema.parse(toolInfo.parameters),
72
+ _meta: metadataResult.success ? metadataResult.data : void 0
76
73
  });
77
74
  }
78
75
  toolList.sort((a, b) => {
@@ -82,12 +79,15 @@ function createToolsRouter(getAgent) {
82
79
  }
83
80
  return a.name.localeCompare(b.name);
84
81
  });
85
- return ctx.json({
86
- tools: toolList,
87
- totalCount: toolList.length,
88
- localCount,
89
- mcpCount
90
- });
82
+ return ctx.json(
83
+ {
84
+ tools: toolList,
85
+ totalCount: toolList.length,
86
+ localCount,
87
+ mcpCount
88
+ },
89
+ 200
90
+ );
91
91
  });
92
92
  }
93
93
  export {
@@ -22,11 +22,13 @@ __export(webhooks_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(webhooks_exports);
24
24
  var import_zod_openapi = require("@hono/zod-openapi");
25
+ var import_core = require("@dexto/core");
26
+ var import_responses = require("../schemas/responses.js");
25
27
  const WebhookResponseSchema = import_zod_openapi.z.object({
26
28
  id: import_zod_openapi.z.string().describe("Unique webhook identifier"),
27
29
  url: import_zod_openapi.z.string().url().describe("Webhook URL"),
28
30
  description: import_zod_openapi.z.string().optional().describe("Webhook description"),
29
- createdAt: import_zod_openapi.z.union([import_zod_openapi.z.date(), import_zod_openapi.z.number()]).describe("Creation timestamp (Date or Unix ms)")
31
+ createdAt: import_zod_openapi.z.string().datetime().describe("Creation timestamp (ISO 8601)")
30
32
  }).strict().describe("Webhook response object");
31
33
  const WebhookTestResultSchema = import_zod_openapi.z.object({
32
34
  success: import_zod_openapi.z.boolean().describe("Whether the webhook test succeeded"),
@@ -39,113 +41,129 @@ const WebhookBodySchema = import_zod_openapi.z.object({
39
41
  secret: import_zod_openapi.z.string().optional().describe("A secret key for HMAC signature verification"),
40
42
  description: import_zod_openapi.z.string().optional().describe("A description of the webhook for reference")
41
43
  }).describe("Request body for registering a webhook");
42
- function createWebhooksRouter(getAgent, webhookSubscriber) {
43
- const app = new import_zod_openapi.OpenAPIHono();
44
- const registerRoute = (0, import_zod_openapi.createRoute)({
45
- method: "post",
46
- path: "/webhooks",
47
- summary: "Register Webhook",
48
- description: "Registers a new webhook endpoint to receive agent events",
49
- tags: ["webhooks"],
50
- request: { body: { content: { "application/json": { schema: WebhookBodySchema } } } },
51
- responses: {
52
- 201: {
53
- description: "Webhook registered",
54
- content: {
55
- "application/json": {
56
- schema: import_zod_openapi.z.object({
57
- webhook: WebhookResponseSchema.describe(
58
- "Registered webhook details"
59
- )
60
- }).strict()
61
- }
44
+ const registerRoute = (0, import_zod_openapi.createRoute)({
45
+ method: "post",
46
+ path: "/webhooks",
47
+ summary: "Register Webhook",
48
+ description: "Registers a new webhook endpoint to receive agent events",
49
+ tags: ["webhooks"],
50
+ request: { body: { content: { "application/json": { schema: WebhookBodySchema } } } },
51
+ responses: {
52
+ 201: {
53
+ description: "Webhook registered",
54
+ content: {
55
+ "application/json": {
56
+ schema: import_zod_openapi.z.object({
57
+ webhook: WebhookResponseSchema.describe("Registered webhook details")
58
+ }).strict()
62
59
  }
63
60
  }
64
- }
65
- });
66
- const listRoute = (0, import_zod_openapi.createRoute)({
67
- method: "get",
68
- path: "/webhooks",
69
- summary: "List Webhooks",
70
- description: "Retrieves a list of all registered webhooks",
71
- tags: ["webhooks"],
72
- responses: {
73
- 200: {
74
- description: "List webhooks",
75
- content: {
76
- "application/json": {
77
- schema: import_zod_openapi.z.object({
78
- webhooks: import_zod_openapi.z.array(WebhookResponseSchema).describe("Array of registered webhooks")
79
- }).strict()
80
- }
61
+ },
62
+ 400: import_responses.BadRequestErrorResponse,
63
+ 500: import_responses.InternalErrorResponse
64
+ }
65
+ });
66
+ const listRoute = (0, import_zod_openapi.createRoute)({
67
+ method: "get",
68
+ path: "/webhooks",
69
+ summary: "List Webhooks",
70
+ description: "Retrieves a list of all registered webhooks",
71
+ tags: ["webhooks"],
72
+ responses: {
73
+ 200: {
74
+ description: "List webhooks",
75
+ content: {
76
+ "application/json": {
77
+ schema: import_zod_openapi.z.object({
78
+ webhooks: import_zod_openapi.z.array(WebhookResponseSchema).describe("Array of registered webhooks")
79
+ }).strict()
81
80
  }
82
81
  }
83
- }
84
- });
85
- const getRoute = (0, import_zod_openapi.createRoute)({
86
- method: "get",
87
- path: "/webhooks/{webhookId}",
88
- summary: "Get Webhook Details",
89
- description: "Fetches details for a specific webhook",
90
- tags: ["webhooks"],
91
- request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
92
- responses: {
93
- 200: {
94
- description: "Webhook",
95
- content: {
96
- "application/json": {
97
- schema: import_zod_openapi.z.object({
98
- webhook: WebhookResponseSchema.describe("Webhook details")
99
- }).strict()
100
- }
82
+ },
83
+ 500: import_responses.InternalErrorResponse
84
+ }
85
+ });
86
+ const getRoute = (0, import_zod_openapi.createRoute)({
87
+ method: "get",
88
+ path: "/webhooks/{webhookId}",
89
+ summary: "Get Webhook Details",
90
+ description: "Fetches details for a specific webhook",
91
+ tags: ["webhooks"],
92
+ request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
93
+ responses: {
94
+ 200: {
95
+ description: "Webhook",
96
+ content: {
97
+ "application/json": {
98
+ schema: import_zod_openapi.z.object({
99
+ webhook: WebhookResponseSchema.describe("Webhook details")
100
+ }).strict()
101
101
  }
102
- },
103
- 404: { description: "Not found" }
102
+ }
103
+ },
104
+ 404: {
105
+ description: "Not found",
106
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
104
107
  }
105
- });
106
- const deleteRoute = (0, import_zod_openapi.createRoute)({
107
- method: "delete",
108
- path: "/webhooks/{webhookId}",
109
- summary: "Delete Webhook",
110
- description: "Permanently removes a webhook endpoint. This action cannot be undone",
111
- tags: ["webhooks"],
112
- request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
113
- responses: {
114
- 200: {
115
- description: "Removed",
116
- content: {
117
- "application/json": {
118
- schema: import_zod_openapi.z.object({
119
- status: import_zod_openapi.z.literal("removed").describe("Operation status indicating successful removal"),
120
- webhookId: import_zod_openapi.z.string().describe("ID of the removed webhook")
121
- }).strict()
122
- }
108
+ }
109
+ });
110
+ const deleteRoute = (0, import_zod_openapi.createRoute)({
111
+ method: "delete",
112
+ path: "/webhooks/{webhookId}",
113
+ summary: "Delete Webhook",
114
+ description: "Permanently removes a webhook endpoint. This action cannot be undone",
115
+ tags: ["webhooks"],
116
+ request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
117
+ responses: {
118
+ 200: {
119
+ description: "Removed",
120
+ content: {
121
+ "application/json": {
122
+ schema: import_zod_openapi.z.object({
123
+ status: import_zod_openapi.z.literal("removed").describe("Operation status indicating successful removal"),
124
+ webhookId: import_zod_openapi.z.string().describe("ID of the removed webhook")
125
+ }).strict()
123
126
  }
124
- },
125
- 404: { description: "Not found" }
127
+ }
128
+ },
129
+ 404: {
130
+ description: "Not found",
131
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
126
132
  }
127
- });
128
- const testRoute = (0, import_zod_openapi.createRoute)({
129
- method: "post",
130
- path: "/webhooks/{webhookId}/test",
131
- summary: "Test Webhook",
132
- description: "Sends a sample event to test webhook connectivity and configuration",
133
- tags: ["webhooks"],
134
- request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
135
- responses: {
136
- 200: {
137
- description: "Test result",
138
- content: {
139
- "application/json": {
140
- schema: import_zod_openapi.z.object({
141
- test: import_zod_openapi.z.literal("completed").describe("Test status indicating completion"),
142
- result: WebhookTestResultSchema.describe("Test execution results")
143
- }).strict()
144
- }
133
+ }
134
+ });
135
+ const testRoute = (0, import_zod_openapi.createRoute)({
136
+ method: "post",
137
+ path: "/webhooks/{webhookId}/test",
138
+ summary: "Test Webhook",
139
+ description: "Sends a sample event to test webhook connectivity and configuration",
140
+ tags: ["webhooks"],
141
+ request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
142
+ responses: {
143
+ 200: {
144
+ description: "Test result",
145
+ content: {
146
+ "application/json": {
147
+ schema: import_zod_openapi.z.object({
148
+ test: import_zod_openapi.z.literal("completed").describe("Test status indicating completion"),
149
+ result: WebhookTestResultSchema.describe("Test execution results")
150
+ }).strict()
145
151
  }
146
- },
147
- 404: { description: "Not found" }
152
+ }
153
+ },
154
+ 404: {
155
+ description: "Not found",
156
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
148
157
  }
158
+ }
159
+ });
160
+ function createWebhooksRouter(getAgent, webhookSubscriber) {
161
+ const app = new import_zod_openapi.OpenAPIHono();
162
+ const serializeWebhook = (webhook) => ({
163
+ id: webhook.id,
164
+ url: webhook.url,
165
+ description: webhook.description,
166
+ createdAt: webhook.createdAt.toISOString()
149
167
  });
150
168
  return app.openapi(registerRoute, async (ctx) => {
151
169
  const agent = await getAgent(ctx);
@@ -162,64 +180,73 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
162
180
  agent.logger.info(`Webhook registered: ${webhookId} -> ${url}`);
163
181
  return ctx.json(
164
182
  {
165
- webhook: {
166
- id: webhook.id,
167
- url: webhook.url,
168
- description: webhook.description,
169
- createdAt: webhook.createdAt
170
- }
183
+ webhook: serializeWebhook(webhook)
171
184
  },
172
185
  201
173
186
  );
174
187
  }).openapi(listRoute, async (ctx) => {
175
- const webhooks = webhookSubscriber.getWebhooks().map((webhook) => ({
176
- id: webhook.id,
177
- url: webhook.url,
178
- description: webhook.description,
179
- createdAt: webhook.createdAt
180
- }));
181
- return ctx.json({ webhooks });
188
+ const webhooks = webhookSubscriber.getWebhooks().map(serializeWebhook);
189
+ return ctx.json({ webhooks }, 200);
182
190
  }).openapi(getRoute, (ctx) => {
183
191
  const { webhookId } = ctx.req.valid("param");
184
192
  const webhook = webhookSubscriber.getWebhook(webhookId);
185
193
  if (!webhook) {
186
- return ctx.json({ error: "Webhook not found" }, 404);
194
+ throw new import_core.DextoRuntimeError(
195
+ "webhook_not_found",
196
+ "webhook",
197
+ import_core.ErrorType.NOT_FOUND,
198
+ "Webhook not found",
199
+ { webhookId }
200
+ );
187
201
  }
188
- return ctx.json({
189
- webhook: {
190
- id: webhook.id,
191
- url: webhook.url,
192
- description: webhook.description,
193
- createdAt: webhook.createdAt
194
- }
195
- });
202
+ return ctx.json(
203
+ {
204
+ webhook: serializeWebhook(webhook)
205
+ },
206
+ 200
207
+ );
196
208
  }).openapi(deleteRoute, async (ctx) => {
197
209
  const agent = await getAgent(ctx);
198
210
  const { webhookId } = ctx.req.valid("param");
199
211
  const removed = webhookSubscriber.removeWebhook(webhookId);
200
212
  if (!removed) {
201
- return ctx.json({ error: "Webhook not found" }, 404);
213
+ throw new import_core.DextoRuntimeError(
214
+ "webhook_not_found",
215
+ "webhook",
216
+ import_core.ErrorType.NOT_FOUND,
217
+ "Webhook not found",
218
+ { webhookId }
219
+ );
202
220
  }
203
221
  agent.logger.info(`Webhook removed: ${webhookId}`);
204
- return ctx.json({ status: "removed", webhookId });
222
+ return ctx.json({ status: "removed", webhookId }, 200);
205
223
  }).openapi(testRoute, async (ctx) => {
206
224
  const agent = await getAgent(ctx);
207
225
  const { webhookId } = ctx.req.valid("param");
208
226
  const webhook = webhookSubscriber.getWebhook(webhookId);
209
227
  if (!webhook) {
210
- return ctx.json({ error: "Webhook not found" }, 404);
228
+ throw new import_core.DextoRuntimeError(
229
+ "webhook_not_found",
230
+ "webhook",
231
+ import_core.ErrorType.NOT_FOUND,
232
+ "Webhook not found",
233
+ { webhookId }
234
+ );
211
235
  }
212
236
  agent.logger.info(`Testing webhook: ${webhookId}`);
213
237
  const result = await webhookSubscriber.testWebhook(webhookId);
214
- return ctx.json({
215
- test: "completed",
216
- result: {
217
- success: result.success,
218
- statusCode: result.statusCode,
219
- responseTime: result.responseTime,
220
- error: result.error
221
- }
222
- });
238
+ return ctx.json(
239
+ {
240
+ test: "completed",
241
+ result: {
242
+ success: result.success,
243
+ statusCode: result.statusCode,
244
+ responseTime: result.responseTime,
245
+ error: result.error
246
+ }
247
+ },
248
+ 200
249
+ );
223
250
  });
224
251
  }
225
252
  // Annotate the CommonJS export names for ESM import in node: