@dexto/server 1.6.19 → 1.6.20
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.
- package/dist/hono/index.d.ts +161 -133
- package/dist/hono/index.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.cjs +17 -4
- package/dist/hono/routes/a2a-tasks.d.ts +39 -35
- package/dist/hono/routes/a2a-tasks.d.ts.map +1 -1
- package/dist/hono/routes/a2a-tasks.js +17 -4
- package/dist/hono/routes/agents.d.ts +8 -8
- package/dist/hono/routes/approvals.cjs +19 -8
- package/dist/hono/routes/approvals.d.ts +39 -8
- package/dist/hono/routes/approvals.d.ts.map +1 -1
- package/dist/hono/routes/approvals.js +19 -8
- package/dist/hono/routes/llm.d.ts +1 -1
- package/dist/hono/routes/mcp.cjs +56 -26
- package/dist/hono/routes/mcp.d.ts +22 -29
- package/dist/hono/routes/mcp.d.ts.map +1 -1
- package/dist/hono/routes/mcp.js +64 -28
- package/dist/hono/routes/messages.cjs +34 -35
- package/dist/hono/routes/messages.d.ts +12 -12
- package/dist/hono/routes/messages.d.ts.map +1 -1
- package/dist/hono/routes/messages.js +41 -36
- package/dist/hono/routes/prompts.cjs +10 -4
- package/dist/hono/routes/prompts.d.ts +4 -4
- package/dist/hono/routes/prompts.d.ts.map +1 -1
- package/dist/hono/routes/prompts.js +15 -5
- package/dist/hono/routes/queue.cjs +42 -29
- package/dist/hono/routes/queue.d.ts +9 -9
- package/dist/hono/routes/queue.d.ts.map +1 -1
- package/dist/hono/routes/queue.js +49 -30
- package/dist/hono/routes/resources.d.ts +1 -1
- package/dist/hono/routes/schedules.d.ts +4 -4
- package/dist/hono/routes/search.d.ts +4 -4
- package/dist/hono/routes/sessions.cjs +7 -2
- package/dist/hono/routes/sessions.d.ts +12 -12
- package/dist/hono/routes/sessions.d.ts.map +1 -1
- package/dist/hono/routes/sessions.js +7 -2
- package/dist/hono/routes/tools.d.ts +1 -1
- package/dist/hono/routes/webhooks.cjs +59 -24
- package/dist/hono/routes/webhooks.d.ts +7 -7
- package/dist/hono/routes/webhooks.d.ts.map +1 -1
- package/dist/hono/routes/webhooks.js +59 -24
- package/dist/hono/schemas/responses.cjs +112 -2
- package/dist/hono/schemas/responses.d.ts +246 -54
- package/dist/hono/schemas/responses.d.ts.map +1 -1
- package/dist/hono/schemas/responses.js +105 -1
- package/package.json +7 -7
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
-
import {
|
|
2
|
+
import { DextoRuntimeError, ErrorType } from "@dexto/core";
|
|
3
|
+
import {
|
|
4
|
+
ApiErrorResponseSchema,
|
|
5
|
+
ContentPartSchema,
|
|
6
|
+
RequestContentSchema,
|
|
7
|
+
toApiContentPart,
|
|
8
|
+
toContentInput
|
|
9
|
+
} from "../schemas/responses.js";
|
|
3
10
|
const QueuedMessageSchema = z.object({
|
|
4
11
|
id: z.string().describe("Unique identifier for the queued message"),
|
|
5
12
|
content: z.array(ContentPartSchema).describe("Message content parts"),
|
|
@@ -7,24 +14,8 @@ const QueuedMessageSchema = z.object({
|
|
|
7
14
|
metadata: z.record(z.unknown()).optional().describe("Optional metadata"),
|
|
8
15
|
kind: z.enum(["default", "background"]).optional().describe("Optional queued message kind")
|
|
9
16
|
}).strict().describe("A message waiting in the queue");
|
|
10
|
-
const TextPartSchema = z.object({
|
|
11
|
-
type: z.literal("text").describe("Content type identifier"),
|
|
12
|
-
text: z.string().describe("Text content")
|
|
13
|
-
}).describe("Text content part");
|
|
14
|
-
const ImagePartSchema = z.object({
|
|
15
|
-
type: z.literal("image").describe("Content type identifier"),
|
|
16
|
-
image: z.string().describe("Base64-encoded image data or URL"),
|
|
17
|
-
mimeType: z.string().optional().describe("MIME type (e.g., image/png)")
|
|
18
|
-
}).describe("Image content part");
|
|
19
|
-
const FilePartSchema = z.object({
|
|
20
|
-
type: z.literal("file").describe("Content type identifier"),
|
|
21
|
-
data: z.string().describe("Base64-encoded file data or URL"),
|
|
22
|
-
mimeType: z.string().describe("MIME type (e.g., application/pdf)"),
|
|
23
|
-
filename: z.string().optional().describe("Optional filename")
|
|
24
|
-
}).describe("File content part");
|
|
25
|
-
const QueueContentPartSchema = z.discriminatedUnion("type", [TextPartSchema, ImagePartSchema, FilePartSchema]).describe("Content part - text, image, or file");
|
|
26
17
|
const QueueMessageBodySchema = z.object({
|
|
27
|
-
content:
|
|
18
|
+
content: RequestContentSchema,
|
|
28
19
|
kind: z.enum(["default", "background"]).optional().describe("Optional queued message kind")
|
|
29
20
|
}).describe("Request body for queueing a message");
|
|
30
21
|
function createQueueRouter(getAgent) {
|
|
@@ -52,7 +43,10 @@ function createQueueRouter(getAgent) {
|
|
|
52
43
|
}
|
|
53
44
|
}
|
|
54
45
|
},
|
|
55
|
-
404: {
|
|
46
|
+
404: {
|
|
47
|
+
description: "Session not found",
|
|
48
|
+
content: { "application/json": { schema: ApiErrorResponseSchema } }
|
|
49
|
+
}
|
|
56
50
|
}
|
|
57
51
|
});
|
|
58
52
|
const queueMessageRoute = createRoute({
|
|
@@ -82,7 +76,10 @@ function createQueueRouter(getAgent) {
|
|
|
82
76
|
}
|
|
83
77
|
}
|
|
84
78
|
},
|
|
85
|
-
404: {
|
|
79
|
+
404: {
|
|
80
|
+
description: "Session not found",
|
|
81
|
+
content: { "application/json": { schema: ApiErrorResponseSchema } }
|
|
82
|
+
}
|
|
86
83
|
}
|
|
87
84
|
});
|
|
88
85
|
const removeQueuedMessageRoute = createRoute({
|
|
@@ -109,7 +106,10 @@ function createQueueRouter(getAgent) {
|
|
|
109
106
|
}
|
|
110
107
|
}
|
|
111
108
|
},
|
|
112
|
-
404: {
|
|
109
|
+
404: {
|
|
110
|
+
description: "Session or message not found",
|
|
111
|
+
content: { "application/json": { schema: ApiErrorResponseSchema } }
|
|
112
|
+
}
|
|
113
113
|
}
|
|
114
114
|
});
|
|
115
115
|
const clearQueueRoute = createRoute({
|
|
@@ -135,22 +135,35 @@ function createQueueRouter(getAgent) {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
},
|
|
138
|
-
404: {
|
|
138
|
+
404: {
|
|
139
|
+
description: "Session not found",
|
|
140
|
+
content: { "application/json": { schema: ApiErrorResponseSchema } }
|
|
141
|
+
}
|
|
139
142
|
}
|
|
140
143
|
});
|
|
141
144
|
return app.openapi(getQueueRoute, async (ctx) => {
|
|
142
145
|
const agent = await getAgent(ctx);
|
|
143
146
|
const { sessionId } = ctx.req.valid("param");
|
|
144
147
|
const messages = await agent.getQueuedMessages(sessionId);
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
148
|
+
const responseMessages = messages.map((message) => ({
|
|
149
|
+
id: message.id,
|
|
150
|
+
content: message.content.map(toApiContentPart),
|
|
151
|
+
queuedAt: message.queuedAt,
|
|
152
|
+
...message.metadata !== void 0 ? { metadata: message.metadata } : {},
|
|
153
|
+
...message.kind !== void 0 ? { kind: message.kind } : {}
|
|
154
|
+
}));
|
|
155
|
+
return ctx.json(
|
|
156
|
+
{
|
|
157
|
+
messages: responseMessages,
|
|
158
|
+
count: responseMessages.length
|
|
159
|
+
},
|
|
160
|
+
200
|
|
161
|
+
);
|
|
149
162
|
}).openapi(queueMessageRoute, async (ctx) => {
|
|
150
163
|
const agent = await getAgent(ctx);
|
|
151
164
|
const { sessionId } = ctx.req.valid("param");
|
|
152
165
|
const { content: rawContent } = ctx.req.valid("json");
|
|
153
|
-
const content =
|
|
166
|
+
const content = toContentInput(rawContent);
|
|
154
167
|
const { kind } = ctx.req.valid("json");
|
|
155
168
|
const result = await agent.queueMessage(sessionId, {
|
|
156
169
|
content,
|
|
@@ -169,14 +182,20 @@ function createQueueRouter(getAgent) {
|
|
|
169
182
|
const { sessionId, messageId } = ctx.req.valid("param");
|
|
170
183
|
const removed = await agent.removeQueuedMessage(sessionId, messageId);
|
|
171
184
|
if (!removed) {
|
|
172
|
-
|
|
185
|
+
throw new DextoRuntimeError(
|
|
186
|
+
"queued_message_not_found",
|
|
187
|
+
"queue",
|
|
188
|
+
ErrorType.NOT_FOUND,
|
|
189
|
+
"Message not found in queue",
|
|
190
|
+
{ sessionId, messageId }
|
|
191
|
+
);
|
|
173
192
|
}
|
|
174
|
-
return ctx.json({ removed: true, id: messageId });
|
|
193
|
+
return ctx.json({ removed: true, id: messageId }, 200);
|
|
175
194
|
}).openapi(clearQueueRoute, async (ctx) => {
|
|
176
195
|
const agent = await getAgent(ctx);
|
|
177
196
|
const { sessionId } = ctx.req.valid("param");
|
|
178
197
|
const count = await agent.clearMessageQueue(sessionId);
|
|
179
|
-
return ctx.json({ cleared: true, count });
|
|
198
|
+
return ctx.json({ cleared: true, count }, 200);
|
|
180
199
|
});
|
|
181
200
|
}
|
|
182
201
|
export {
|
|
@@ -9,11 +9,11 @@ export declare function createResourcesRouter(getAgent: GetAgentFn): OpenAPIHono
|
|
|
9
9
|
uri: string;
|
|
10
10
|
source: "mcp" | "internal";
|
|
11
11
|
description?: string | undefined;
|
|
12
|
+
name?: string | undefined;
|
|
12
13
|
mimeType?: string | undefined;
|
|
13
14
|
metadata?: {
|
|
14
15
|
[x: string]: import("hono/utils/types").JSONValue;
|
|
15
16
|
} | undefined;
|
|
16
|
-
name?: string | undefined;
|
|
17
17
|
serverName?: string | undefined;
|
|
18
18
|
size?: number | undefined;
|
|
19
19
|
lastModified?: string | undefined;
|
|
@@ -6,8 +6,8 @@ export declare function createSchedulesRouter(getAgent: GetAgentFn): OpenAPIHono
|
|
|
6
6
|
input: {};
|
|
7
7
|
output: {
|
|
8
8
|
schedules: {
|
|
9
|
-
id: string;
|
|
10
9
|
name: string;
|
|
10
|
+
id: string;
|
|
11
11
|
createdAt: number;
|
|
12
12
|
cronExpression: string;
|
|
13
13
|
timezone: string;
|
|
@@ -115,8 +115,8 @@ export declare function createSchedulesRouter(getAgent: GetAgentFn): OpenAPIHono
|
|
|
115
115
|
};
|
|
116
116
|
output: {
|
|
117
117
|
schedule: {
|
|
118
|
-
id: string;
|
|
119
118
|
name: string;
|
|
119
|
+
id: string;
|
|
120
120
|
createdAt: number;
|
|
121
121
|
cronExpression: string;
|
|
122
122
|
timezone: string;
|
|
@@ -279,8 +279,8 @@ export declare function createSchedulesRouter(getAgent: GetAgentFn): OpenAPIHono
|
|
|
279
279
|
};
|
|
280
280
|
output: {
|
|
281
281
|
schedule: {
|
|
282
|
-
id: string;
|
|
283
282
|
name: string;
|
|
283
|
+
id: string;
|
|
284
284
|
createdAt: number;
|
|
285
285
|
cronExpression: string;
|
|
286
286
|
timezone: string;
|
|
@@ -458,9 +458,9 @@ export declare function createSchedulesRouter(getAgent: GetAgentFn): OpenAPIHono
|
|
|
458
458
|
id: string;
|
|
459
459
|
scheduleId: string;
|
|
460
460
|
triggeredAt: number;
|
|
461
|
+
error?: string | undefined;
|
|
461
462
|
completedAt?: number | undefined;
|
|
462
463
|
duration?: number | undefined;
|
|
463
|
-
error?: string | undefined;
|
|
464
464
|
result?: string | undefined;
|
|
465
465
|
} | undefined;
|
|
466
466
|
};
|
|
@@ -46,8 +46,8 @@ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<im
|
|
|
46
46
|
})[] | null;
|
|
47
47
|
role: "system" | "user" | "assistant" | "tool";
|
|
48
48
|
usageScopeId?: string | undefined;
|
|
49
|
-
id?: string | undefined;
|
|
50
49
|
name?: string | undefined;
|
|
50
|
+
id?: string | undefined;
|
|
51
51
|
timestamp?: number | undefined;
|
|
52
52
|
reasoning?: string | undefined;
|
|
53
53
|
tokenUsage?: {
|
|
@@ -74,8 +74,8 @@ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<im
|
|
|
74
74
|
success?: boolean | undefined;
|
|
75
75
|
};
|
|
76
76
|
sessionId: string;
|
|
77
|
-
matchedText: string;
|
|
78
77
|
context: string;
|
|
78
|
+
matchedText: string;
|
|
79
79
|
messageIndex: number;
|
|
80
80
|
}[];
|
|
81
81
|
total: number;
|
|
@@ -133,8 +133,8 @@ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<im
|
|
|
133
133
|
})[] | null;
|
|
134
134
|
role: "system" | "user" | "assistant" | "tool";
|
|
135
135
|
usageScopeId?: string | undefined;
|
|
136
|
-
id?: string | undefined;
|
|
137
136
|
name?: string | undefined;
|
|
137
|
+
id?: string | undefined;
|
|
138
138
|
timestamp?: number | undefined;
|
|
139
139
|
reasoning?: string | undefined;
|
|
140
140
|
tokenUsage?: {
|
|
@@ -161,8 +161,8 @@ export declare function createSearchRouter(getAgent: GetAgentFn): OpenAPIHono<im
|
|
|
161
161
|
success?: boolean | undefined;
|
|
162
162
|
};
|
|
163
163
|
sessionId: string;
|
|
164
|
-
matchedText: string;
|
|
165
164
|
context: string;
|
|
165
|
+
matchedText: string;
|
|
166
166
|
messageIndex: number;
|
|
167
167
|
};
|
|
168
168
|
}[];
|
|
@@ -476,7 +476,12 @@ function createSessionsRouter(getAgent) {
|
|
|
476
476
|
}
|
|
477
477
|
},
|
|
478
478
|
404: {
|
|
479
|
-
description: "Session not found
|
|
479
|
+
description: "Session not found",
|
|
480
|
+
content: {
|
|
481
|
+
"application/json": {
|
|
482
|
+
schema: import_responses.StandardErrorEnvelopeSchema
|
|
483
|
+
}
|
|
484
|
+
}
|
|
480
485
|
}
|
|
481
486
|
}
|
|
482
487
|
});
|
|
@@ -695,7 +700,7 @@ function createSessionsRouter(getAgent) {
|
|
|
695
700
|
const agent = await getAgent(ctx);
|
|
696
701
|
const { sessionId } = ctx.req.valid("param");
|
|
697
702
|
const title = await agent.generateSessionTitle(sessionId);
|
|
698
|
-
return ctx.json({ title, sessionId });
|
|
703
|
+
return ctx.json({ title, sessionId }, 200);
|
|
699
704
|
});
|
|
700
705
|
}
|
|
701
706
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -101,6 +101,15 @@ export declare function createSessionsRouter(getAgent: GetAgentFn): OpenAPIHono<
|
|
|
101
101
|
} & {
|
|
102
102
|
"/sessions/:sessionId/fork": {
|
|
103
103
|
$post: {
|
|
104
|
+
input: {
|
|
105
|
+
param: {
|
|
106
|
+
sessionId: string;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
output: never;
|
|
110
|
+
outputFormat: "json";
|
|
111
|
+
status: 400;
|
|
112
|
+
} | {
|
|
104
113
|
input: {
|
|
105
114
|
param: {
|
|
106
115
|
sessionId: string;
|
|
@@ -147,15 +156,6 @@ export declare function createSessionsRouter(getAgent: GetAgentFn): OpenAPIHono<
|
|
|
147
156
|
};
|
|
148
157
|
outputFormat: "json";
|
|
149
158
|
status: 201;
|
|
150
|
-
} | {
|
|
151
|
-
input: {
|
|
152
|
-
param: {
|
|
153
|
-
sessionId: string;
|
|
154
|
-
};
|
|
155
|
-
};
|
|
156
|
-
output: never;
|
|
157
|
-
outputFormat: "json";
|
|
158
|
-
status: 400;
|
|
159
159
|
} | {
|
|
160
160
|
input: {
|
|
161
161
|
param: {
|
|
@@ -257,8 +257,8 @@ export declare function createSessionsRouter(getAgent: GetAgentFn): OpenAPIHono<
|
|
|
257
257
|
})[] | null;
|
|
258
258
|
role: "system" | "user" | "assistant" | "tool";
|
|
259
259
|
usageScopeId?: string | undefined;
|
|
260
|
-
id?: string | undefined;
|
|
261
260
|
name?: string | undefined;
|
|
261
|
+
id?: string | undefined;
|
|
262
262
|
timestamp?: number | undefined;
|
|
263
263
|
reasoning?: string | undefined;
|
|
264
264
|
tokenUsage?: {
|
|
@@ -611,8 +611,8 @@ export declare function createSessionsRouter(getAgent: GetAgentFn): OpenAPIHono<
|
|
|
611
611
|
sessionId: string;
|
|
612
612
|
};
|
|
613
613
|
};
|
|
614
|
-
output:
|
|
615
|
-
outputFormat:
|
|
614
|
+
output: never;
|
|
615
|
+
outputFormat: "json";
|
|
616
616
|
status: 404;
|
|
617
617
|
} | {
|
|
618
618
|
input: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAehE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwF9C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../../src/hono/routes/sessions.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAkB,MAAM,mBAAmB,CAAC;AAehE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAwF9C,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,UAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QAywBxD"}
|
|
@@ -464,7 +464,12 @@ function createSessionsRouter(getAgent) {
|
|
|
464
464
|
}
|
|
465
465
|
},
|
|
466
466
|
404: {
|
|
467
|
-
description: "Session not found
|
|
467
|
+
description: "Session not found",
|
|
468
|
+
content: {
|
|
469
|
+
"application/json": {
|
|
470
|
+
schema: StandardErrorEnvelopeSchema
|
|
471
|
+
}
|
|
472
|
+
}
|
|
468
473
|
}
|
|
469
474
|
}
|
|
470
475
|
});
|
|
@@ -683,7 +688,7 @@ function createSessionsRouter(getAgent) {
|
|
|
683
688
|
const agent = await getAgent(ctx);
|
|
684
689
|
const { sessionId } = ctx.req.valid("param");
|
|
685
690
|
const title = await agent.generateSessionTitle(sessionId);
|
|
686
|
-
return ctx.json({ title, sessionId });
|
|
691
|
+
return ctx.json({ title, sessionId }, 200);
|
|
687
692
|
});
|
|
688
693
|
}
|
|
689
694
|
export {
|
|
@@ -22,6 +22,8 @@ __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"),
|
|
@@ -100,7 +102,10 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
100
102
|
}
|
|
101
103
|
}
|
|
102
104
|
},
|
|
103
|
-
404: {
|
|
105
|
+
404: {
|
|
106
|
+
description: "Not found",
|
|
107
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
108
|
+
}
|
|
104
109
|
}
|
|
105
110
|
});
|
|
106
111
|
const deleteRoute = (0, import_zod_openapi.createRoute)({
|
|
@@ -122,7 +127,10 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
122
127
|
}
|
|
123
128
|
}
|
|
124
129
|
},
|
|
125
|
-
404: {
|
|
130
|
+
404: {
|
|
131
|
+
description: "Not found",
|
|
132
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
133
|
+
}
|
|
126
134
|
}
|
|
127
135
|
});
|
|
128
136
|
const testRoute = (0, import_zod_openapi.createRoute)({
|
|
@@ -144,7 +152,10 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
144
152
|
}
|
|
145
153
|
}
|
|
146
154
|
},
|
|
147
|
-
404: {
|
|
155
|
+
404: {
|
|
156
|
+
description: "Not found",
|
|
157
|
+
content: { "application/json": { schema: import_responses.ApiErrorResponseSchema } }
|
|
158
|
+
}
|
|
148
159
|
}
|
|
149
160
|
});
|
|
150
161
|
return app.openapi(registerRoute, async (ctx) => {
|
|
@@ -183,43 +194,67 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
183
194
|
const { webhookId } = ctx.req.valid("param");
|
|
184
195
|
const webhook = webhookSubscriber.getWebhook(webhookId);
|
|
185
196
|
if (!webhook) {
|
|
186
|
-
|
|
197
|
+
throw new import_core.DextoRuntimeError(
|
|
198
|
+
"webhook_not_found",
|
|
199
|
+
"webhook",
|
|
200
|
+
import_core.ErrorType.NOT_FOUND,
|
|
201
|
+
"Webhook not found",
|
|
202
|
+
{ webhookId }
|
|
203
|
+
);
|
|
187
204
|
}
|
|
188
|
-
return ctx.json(
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
205
|
+
return ctx.json(
|
|
206
|
+
{
|
|
207
|
+
webhook: {
|
|
208
|
+
id: webhook.id,
|
|
209
|
+
url: webhook.url,
|
|
210
|
+
description: webhook.description,
|
|
211
|
+
createdAt: webhook.createdAt
|
|
212
|
+
}
|
|
213
|
+
},
|
|
214
|
+
200
|
|
215
|
+
);
|
|
196
216
|
}).openapi(deleteRoute, async (ctx) => {
|
|
197
217
|
const agent = await getAgent(ctx);
|
|
198
218
|
const { webhookId } = ctx.req.valid("param");
|
|
199
219
|
const removed = webhookSubscriber.removeWebhook(webhookId);
|
|
200
220
|
if (!removed) {
|
|
201
|
-
|
|
221
|
+
throw new import_core.DextoRuntimeError(
|
|
222
|
+
"webhook_not_found",
|
|
223
|
+
"webhook",
|
|
224
|
+
import_core.ErrorType.NOT_FOUND,
|
|
225
|
+
"Webhook not found",
|
|
226
|
+
{ webhookId }
|
|
227
|
+
);
|
|
202
228
|
}
|
|
203
229
|
agent.logger.info(`Webhook removed: ${webhookId}`);
|
|
204
|
-
return ctx.json({ status: "removed", webhookId });
|
|
230
|
+
return ctx.json({ status: "removed", webhookId }, 200);
|
|
205
231
|
}).openapi(testRoute, async (ctx) => {
|
|
206
232
|
const agent = await getAgent(ctx);
|
|
207
233
|
const { webhookId } = ctx.req.valid("param");
|
|
208
234
|
const webhook = webhookSubscriber.getWebhook(webhookId);
|
|
209
235
|
if (!webhook) {
|
|
210
|
-
|
|
236
|
+
throw new import_core.DextoRuntimeError(
|
|
237
|
+
"webhook_not_found",
|
|
238
|
+
"webhook",
|
|
239
|
+
import_core.ErrorType.NOT_FOUND,
|
|
240
|
+
"Webhook not found",
|
|
241
|
+
{ webhookId }
|
|
242
|
+
);
|
|
211
243
|
}
|
|
212
244
|
agent.logger.info(`Testing webhook: ${webhookId}`);
|
|
213
245
|
const result = await webhookSubscriber.testWebhook(webhookId);
|
|
214
|
-
return ctx.json(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
246
|
+
return ctx.json(
|
|
247
|
+
{
|
|
248
|
+
test: "completed",
|
|
249
|
+
result: {
|
|
250
|
+
success: result.success,
|
|
251
|
+
statusCode: result.statusCode,
|
|
252
|
+
responseTime: result.responseTime,
|
|
253
|
+
error: result.error
|
|
254
|
+
}
|
|
255
|
+
},
|
|
256
|
+
200
|
|
257
|
+
);
|
|
223
258
|
});
|
|
224
259
|
}
|
|
225
260
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
2
|
-
import type
|
|
2
|
+
import { type DextoAgent } from '@dexto/core';
|
|
3
3
|
import { WebhookEventSubscriber } from '../../events/webhook-subscriber.js';
|
|
4
4
|
import type { Context } from 'hono';
|
|
5
5
|
type GetAgentFn = (ctx: Context) => DextoAgent | Promise<DextoAgent>;
|
|
@@ -49,8 +49,8 @@ export declare function createWebhooksRouter(getAgent: GetAgentFn, webhookSubscr
|
|
|
49
49
|
webhookId: string;
|
|
50
50
|
};
|
|
51
51
|
};
|
|
52
|
-
output:
|
|
53
|
-
outputFormat:
|
|
52
|
+
output: never;
|
|
53
|
+
outputFormat: "json";
|
|
54
54
|
status: 404;
|
|
55
55
|
} | {
|
|
56
56
|
input: {
|
|
@@ -78,8 +78,8 @@ export declare function createWebhooksRouter(getAgent: GetAgentFn, webhookSubscr
|
|
|
78
78
|
webhookId: string;
|
|
79
79
|
};
|
|
80
80
|
};
|
|
81
|
-
output:
|
|
82
|
-
outputFormat:
|
|
81
|
+
output: never;
|
|
82
|
+
outputFormat: "json";
|
|
83
83
|
status: 404;
|
|
84
84
|
} | {
|
|
85
85
|
input: {
|
|
@@ -103,8 +103,8 @@ export declare function createWebhooksRouter(getAgent: GetAgentFn, webhookSubscr
|
|
|
103
103
|
webhookId: string;
|
|
104
104
|
};
|
|
105
105
|
};
|
|
106
|
-
output:
|
|
107
|
-
outputFormat:
|
|
106
|
+
output: never;
|
|
107
|
+
outputFormat: "json";
|
|
108
108
|
status: 404;
|
|
109
109
|
} | {
|
|
110
110
|
input: {
|
|
@@ -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,
|
|
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,EAAgC,KAAK,UAAU,EAAE,MAAM,aAAa,CAAC;AAC5E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAG5E,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;QA2P5C"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { OpenAPIHono, createRoute, z } from "@hono/zod-openapi";
|
|
2
|
+
import { DextoRuntimeError, ErrorType } from "@dexto/core";
|
|
3
|
+
import { ApiErrorResponseSchema } from "../schemas/responses.js";
|
|
2
4
|
const WebhookResponseSchema = z.object({
|
|
3
5
|
id: z.string().describe("Unique webhook identifier"),
|
|
4
6
|
url: z.string().url().describe("Webhook URL"),
|
|
@@ -77,7 +79,10 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
77
79
|
}
|
|
78
80
|
}
|
|
79
81
|
},
|
|
80
|
-
404: {
|
|
82
|
+
404: {
|
|
83
|
+
description: "Not found",
|
|
84
|
+
content: { "application/json": { schema: ApiErrorResponseSchema } }
|
|
85
|
+
}
|
|
81
86
|
}
|
|
82
87
|
});
|
|
83
88
|
const deleteRoute = createRoute({
|
|
@@ -99,7 +104,10 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
99
104
|
}
|
|
100
105
|
}
|
|
101
106
|
},
|
|
102
|
-
404: {
|
|
107
|
+
404: {
|
|
108
|
+
description: "Not found",
|
|
109
|
+
content: { "application/json": { schema: ApiErrorResponseSchema } }
|
|
110
|
+
}
|
|
103
111
|
}
|
|
104
112
|
});
|
|
105
113
|
const testRoute = createRoute({
|
|
@@ -121,7 +129,10 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
121
129
|
}
|
|
122
130
|
}
|
|
123
131
|
},
|
|
124
|
-
404: {
|
|
132
|
+
404: {
|
|
133
|
+
description: "Not found",
|
|
134
|
+
content: { "application/json": { schema: ApiErrorResponseSchema } }
|
|
135
|
+
}
|
|
125
136
|
}
|
|
126
137
|
});
|
|
127
138
|
return app.openapi(registerRoute, async (ctx) => {
|
|
@@ -160,43 +171,67 @@ function createWebhooksRouter(getAgent, webhookSubscriber) {
|
|
|
160
171
|
const { webhookId } = ctx.req.valid("param");
|
|
161
172
|
const webhook = webhookSubscriber.getWebhook(webhookId);
|
|
162
173
|
if (!webhook) {
|
|
163
|
-
|
|
174
|
+
throw new DextoRuntimeError(
|
|
175
|
+
"webhook_not_found",
|
|
176
|
+
"webhook",
|
|
177
|
+
ErrorType.NOT_FOUND,
|
|
178
|
+
"Webhook not found",
|
|
179
|
+
{ webhookId }
|
|
180
|
+
);
|
|
164
181
|
}
|
|
165
|
-
return ctx.json(
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
182
|
+
return ctx.json(
|
|
183
|
+
{
|
|
184
|
+
webhook: {
|
|
185
|
+
id: webhook.id,
|
|
186
|
+
url: webhook.url,
|
|
187
|
+
description: webhook.description,
|
|
188
|
+
createdAt: webhook.createdAt
|
|
189
|
+
}
|
|
190
|
+
},
|
|
191
|
+
200
|
|
192
|
+
);
|
|
173
193
|
}).openapi(deleteRoute, async (ctx) => {
|
|
174
194
|
const agent = await getAgent(ctx);
|
|
175
195
|
const { webhookId } = ctx.req.valid("param");
|
|
176
196
|
const removed = webhookSubscriber.removeWebhook(webhookId);
|
|
177
197
|
if (!removed) {
|
|
178
|
-
|
|
198
|
+
throw new DextoRuntimeError(
|
|
199
|
+
"webhook_not_found",
|
|
200
|
+
"webhook",
|
|
201
|
+
ErrorType.NOT_FOUND,
|
|
202
|
+
"Webhook not found",
|
|
203
|
+
{ webhookId }
|
|
204
|
+
);
|
|
179
205
|
}
|
|
180
206
|
agent.logger.info(`Webhook removed: ${webhookId}`);
|
|
181
|
-
return ctx.json({ status: "removed", webhookId });
|
|
207
|
+
return ctx.json({ status: "removed", webhookId }, 200);
|
|
182
208
|
}).openapi(testRoute, async (ctx) => {
|
|
183
209
|
const agent = await getAgent(ctx);
|
|
184
210
|
const { webhookId } = ctx.req.valid("param");
|
|
185
211
|
const webhook = webhookSubscriber.getWebhook(webhookId);
|
|
186
212
|
if (!webhook) {
|
|
187
|
-
|
|
213
|
+
throw new DextoRuntimeError(
|
|
214
|
+
"webhook_not_found",
|
|
215
|
+
"webhook",
|
|
216
|
+
ErrorType.NOT_FOUND,
|
|
217
|
+
"Webhook not found",
|
|
218
|
+
{ webhookId }
|
|
219
|
+
);
|
|
188
220
|
}
|
|
189
221
|
agent.logger.info(`Testing webhook: ${webhookId}`);
|
|
190
222
|
const result = await webhookSubscriber.testWebhook(webhookId);
|
|
191
|
-
return ctx.json(
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
223
|
+
return ctx.json(
|
|
224
|
+
{
|
|
225
|
+
test: "completed",
|
|
226
|
+
result: {
|
|
227
|
+
success: result.success,
|
|
228
|
+
statusCode: result.statusCode,
|
|
229
|
+
responseTime: result.responseTime,
|
|
230
|
+
error: result.error
|
|
231
|
+
}
|
|
232
|
+
},
|
|
233
|
+
200
|
|
234
|
+
);
|
|
200
235
|
});
|
|
201
236
|
}
|
|
202
237
|
export {
|