@dexto/server 1.6.20 → 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 -4531
  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 +158 -32
  11. package/dist/hono/routes/a2a-tasks.d.ts +1 -502
  12. package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
  13. package/dist/hono/routes/a2a-tasks.js +162 -32
  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 +16043 -68
  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 +102 -88
  20. package/dist/hono/routes/approvals.d.ts +2089 -142
  21. package/dist/hono/routes/approvals.d.ts.map +1 -1
  22. package/dist/hono/routes/approvals.js +108 -89
  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 +12136 -86
  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 +257 -226
  45. package/dist/hono/routes/mcp.d.ts +6605 -309
  46. package/dist/hono/routes/mcp.d.ts.map +1 -1
  47. package/dist/hono/routes/mcp.js +263 -225
  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 +147 -139
  53. package/dist/hono/routes/messages.d.ts +3900 -11
  54. package/dist/hono/routes/messages.d.ts.map +1 -1
  55. package/dist/hono/routes/messages.js +150 -139
  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 +136 -109
  65. package/dist/hono/routes/prompts.d.ts +2818 -10
  66. package/dist/hono/routes/prompts.d.ts.map +1 -1
  67. package/dist/hono/routes/prompts.js +138 -109
  68. package/dist/hono/routes/queue.cjs +133 -120
  69. package/dist/hono/routes/queue.d.ts +5144 -9
  70. package/dist/hono/routes/queue.d.ts.map +1 -1
  71. package/dist/hono/routes/queue.js +136 -120
  72. package/dist/hono/routes/resources.cjs +65 -46
  73. package/dist/hono/routes/resources.d.ts +1982 -4
  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 +4198 -22
  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 +2835 -12
  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 +403 -396
  85. package/dist/hono/routes/sessions.d.ts +16582 -27
  86. package/dist/hono/routes/sessions.d.ts.map +1 -1
  87. package/dist/hono/routes/sessions.js +407 -397
  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 +1755 -6
  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 +115 -123
  98. package/dist/hono/routes/webhooks.d.ts +2501 -11
  99. package/dist/hono/routes/webhooks.d.ts.map +1 -1
  100. package/dist/hono/routes/webhooks.js +120 -124
  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 +406 -259
  106. package/dist/hono/schemas/responses.d.ts +1246 -123
  107. package/dist/hono/schemas/responses.d.ts.map +1 -1
  108. package/dist/hono/schemas/responses.js +144 -10
  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 {
@@ -28,7 +28,7 @@ const WebhookResponseSchema = import_zod_openapi.z.object({
28
28
  id: import_zod_openapi.z.string().describe("Unique webhook identifier"),
29
29
  url: import_zod_openapi.z.string().url().describe("Webhook URL"),
30
30
  description: import_zod_openapi.z.string().optional().describe("Webhook description"),
31
- 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)")
32
32
  }).strict().describe("Webhook response object");
33
33
  const WebhookTestResultSchema = import_zod_openapi.z.object({
34
34
  success: import_zod_openapi.z.boolean().describe("Whether the webhook test succeeded"),
@@ -41,122 +41,129 @@ const WebhookBodySchema = import_zod_openapi.z.object({
41
41
  secret: import_zod_openapi.z.string().optional().describe("A secret key for HMAC signature verification"),
42
42
  description: import_zod_openapi.z.string().optional().describe("A description of the webhook for reference")
43
43
  }).describe("Request body for registering a webhook");
44
- function createWebhooksRouter(getAgent, webhookSubscriber) {
45
- const app = new import_zod_openapi.OpenAPIHono();
46
- const registerRoute = (0, import_zod_openapi.createRoute)({
47
- method: "post",
48
- path: "/webhooks",
49
- summary: "Register Webhook",
50
- description: "Registers a new webhook endpoint to receive agent events",
51
- tags: ["webhooks"],
52
- request: { body: { content: { "application/json": { schema: WebhookBodySchema } } } },
53
- responses: {
54
- 201: {
55
- description: "Webhook registered",
56
- content: {
57
- "application/json": {
58
- schema: import_zod_openapi.z.object({
59
- webhook: WebhookResponseSchema.describe(
60
- "Registered webhook details"
61
- )
62
- }).strict()
63
- }
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()
64
59
  }
65
60
  }
66
- }
67
- });
68
- const listRoute = (0, import_zod_openapi.createRoute)({
69
- method: "get",
70
- path: "/webhooks",
71
- summary: "List Webhooks",
72
- description: "Retrieves a list of all registered webhooks",
73
- tags: ["webhooks"],
74
- responses: {
75
- 200: {
76
- description: "List webhooks",
77
- content: {
78
- "application/json": {
79
- schema: import_zod_openapi.z.object({
80
- webhooks: import_zod_openapi.z.array(WebhookResponseSchema).describe("Array of registered webhooks")
81
- }).strict()
82
- }
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()
83
80
  }
84
81
  }
85
- }
86
- });
87
- const getRoute = (0, import_zod_openapi.createRoute)({
88
- method: "get",
89
- path: "/webhooks/{webhookId}",
90
- summary: "Get Webhook Details",
91
- description: "Fetches details for a specific webhook",
92
- tags: ["webhooks"],
93
- request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
94
- responses: {
95
- 200: {
96
- description: "Webhook",
97
- content: {
98
- "application/json": {
99
- schema: import_zod_openapi.z.object({
100
- webhook: WebhookResponseSchema.describe("Webhook details")
101
- }).strict()
102
- }
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()
103
101
  }
104
- },
105
- 404: {
106
- description: "Not found",
107
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
108
102
  }
103
+ },
104
+ 404: {
105
+ description: "Not found",
106
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
109
107
  }
110
- });
111
- const deleteRoute = (0, import_zod_openapi.createRoute)({
112
- method: "delete",
113
- path: "/webhooks/{webhookId}",
114
- summary: "Delete Webhook",
115
- description: "Permanently removes a webhook endpoint. This action cannot be undone",
116
- tags: ["webhooks"],
117
- request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
118
- responses: {
119
- 200: {
120
- description: "Removed",
121
- content: {
122
- "application/json": {
123
- schema: import_zod_openapi.z.object({
124
- status: import_zod_openapi.z.literal("removed").describe("Operation status indicating successful removal"),
125
- webhookId: import_zod_openapi.z.string().describe("ID of the removed webhook")
126
- }).strict()
127
- }
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()
128
126
  }
129
- },
130
- 404: {
131
- description: "Not found",
132
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
133
127
  }
128
+ },
129
+ 404: {
130
+ description: "Not found",
131
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
134
132
  }
135
- });
136
- const testRoute = (0, import_zod_openapi.createRoute)({
137
- method: "post",
138
- path: "/webhooks/{webhookId}/test",
139
- summary: "Test Webhook",
140
- description: "Sends a sample event to test webhook connectivity and configuration",
141
- tags: ["webhooks"],
142
- request: { params: import_zod_openapi.z.object({ webhookId: import_zod_openapi.z.string().describe("The webhook identifier") }) },
143
- responses: {
144
- 200: {
145
- description: "Test result",
146
- content: {
147
- "application/json": {
148
- schema: import_zod_openapi.z.object({
149
- test: import_zod_openapi.z.literal("completed").describe("Test status indicating completion"),
150
- result: WebhookTestResultSchema.describe("Test execution results")
151
- }).strict()
152
- }
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()
153
151
  }
154
- },
155
- 404: {
156
- description: "Not found",
157
- content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
158
152
  }
153
+ },
154
+ 404: {
155
+ description: "Not found",
156
+ content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
159
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()
160
167
  });
161
168
  return app.openapi(registerRoute, async (ctx) => {
162
169
  const agent = await getAgent(ctx);
@@ -173,23 +180,13 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
173
180
  agent.logger.info(`Webhook registered: ${webhookId} -> ${url}`);
174
181
  return ctx.json(
175
182
  {
176
- webhook: {
177
- id: webhook.id,
178
- url: webhook.url,
179
- description: webhook.description,
180
- createdAt: webhook.createdAt
181
- }
183
+ webhook: serializeWebhook(webhook)
182
184
  },
183
185
  201
184
186
  );
185
187
  }).openapi(listRoute, async (ctx) => {
186
- const webhooks = webhookSubscriber.getWebhooks().map((webhook) => ({
187
- id: webhook.id,
188
- url: webhook.url,
189
- description: webhook.description,
190
- createdAt: webhook.createdAt
191
- }));
192
- return ctx.json({ webhooks });
188
+ const webhooks = webhookSubscriber.getWebhooks().map(serializeWebhook);
189
+ return ctx.json({ webhooks }, 200);
193
190
  }).openapi(getRoute, (ctx) => {
194
191
  const { webhookId } = ctx.req.valid("param");
195
192
  const webhook = webhookSubscriber.getWebhook(webhookId);
@@ -204,12 +201,7 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
204
201
  }
205
202
  return ctx.json(
206
203
  {
207
- webhook: {
208
- id: webhook.id,
209
- url: webhook.url,
210
- description: webhook.description,
211
- createdAt: webhook.createdAt
212
- }
204
+ webhook: serializeWebhook(webhook)
213
205
  },
214
206
  200
215
207
  );