@deepagents/experimental 6.1.0 → 7.0.0
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/README.md +151 -10
- package/dist/coding-agent-reminders/types.d.ts.map +1 -1
- package/dist/index.js +3084 -1206
- package/dist/index.js.map +4 -4
- package/dist/providers/claude/index.d.ts +4 -0
- package/dist/providers/claude/index.d.ts.map +1 -0
- package/dist/providers/claude/index.js +196 -0
- package/dist/providers/claude/index.js.map +7 -0
- package/dist/providers/claude/local-credentials.d.ts +3 -0
- package/dist/providers/claude/local-credentials.d.ts.map +1 -0
- package/dist/providers/codex/generate-via-stream.d.ts +8 -0
- package/dist/providers/codex/generate-via-stream.d.ts.map +1 -0
- package/dist/providers/codex/index.d.ts +4 -0
- package/dist/providers/codex/index.d.ts.map +1 -0
- package/dist/providers/codex/index.js +358 -0
- package/dist/providers/codex/index.js.map +7 -0
- package/dist/providers/codex/local-credentials.d.ts +4 -0
- package/dist/providers/codex/local-credentials.d.ts.map +1 -0
- package/dist/providers/language-model-provider.d.ts +5 -0
- package/dist/providers/language-model-provider.d.ts.map +1 -0
- package/dist/zukhruf/agent.d.ts +17 -2
- package/dist/zukhruf/agent.d.ts.map +1 -1
- package/dist/zukhruf/collaboration/agent-tool-context.d.ts +2 -2
- package/dist/zukhruf/collaboration/agent-tool-context.d.ts.map +1 -1
- package/dist/zukhruf/collaboration/collaboration-tools.d.ts +1807 -3
- package/dist/zukhruf/collaboration/collaboration-tools.d.ts.map +1 -1
- package/dist/zukhruf/collaboration/spawn-agent.d.ts.map +1 -1
- package/dist/zukhruf/collaboration/wait-agent.d.ts.map +1 -1
- package/dist/zukhruf/control-plane/agent-control-plane.d.ts +6 -7
- package/dist/zukhruf/control-plane/agent-control-plane.d.ts.map +1 -1
- package/dist/zukhruf/control-plane/agent-declaration-registry.d.ts +1 -0
- package/dist/zukhruf/control-plane/agent-declaration-registry.d.ts.map +1 -1
- package/dist/zukhruf/control-plane/agent-status-projector.d.ts +6 -3
- package/dist/zukhruf/control-plane/agent-status-projector.d.ts.map +1 -1
- package/dist/zukhruf/control-plane/agent-thread.d.ts.map +1 -1
- package/dist/zukhruf/index.d.ts +7 -3
- package/dist/zukhruf/index.d.ts.map +1 -1
- package/dist/zukhruf/index.js +3085 -1207
- package/dist/zukhruf/index.js.map +4 -4
- package/dist/zukhruf/{multi-agent-v2-config.d.ts → multi-agent-config.d.ts} +14 -9
- package/dist/zukhruf/multi-agent-config.d.ts.map +1 -0
- package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts +76 -0
- package/dist/zukhruf/plugins/conversation-scheduling/conversation-scheduler.d.ts.map +1 -0
- package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts +13 -0
- package/dist/zukhruf/plugins/conversation-scheduling/index.d.ts.map +1 -0
- package/dist/zukhruf/plugins/conversation-scheduling/index.js +999 -0
- package/dist/zukhruf/plugins/conversation-scheduling/index.js.map +7 -0
- package/dist/zukhruf/plugins/conversation-scheduling/pg-boss.wake-scheduler.d.ts +19 -0
- package/dist/zukhruf/plugins/conversation-scheduling/pg-boss.wake-scheduler.d.ts.map +1 -0
- package/dist/zukhruf/plugins/conversation-scheduling/tools.d.ts +1305 -0
- package/dist/zukhruf/plugins/conversation-scheduling/tools.d.ts.map +1 -0
- package/dist/zukhruf/plugins/conversation-scheduling/wake-scheduler.d.ts +12 -0
- package/dist/zukhruf/plugins/conversation-scheduling/wake-scheduler.d.ts.map +1 -0
- package/dist/zukhruf/plugins/http/index.d.ts +50 -0
- package/dist/zukhruf/plugins/http/index.d.ts.map +1 -0
- package/dist/zukhruf/plugins/http/index.js +618 -0
- package/dist/zukhruf/plugins/http/index.js.map +7 -0
- package/dist/zukhruf/plugins/http/parse.d.ts +3 -0
- package/dist/zukhruf/plugins/http/parse.d.ts.map +1 -0
- package/dist/zukhruf/plugins/http/validator.d.ts +64 -0
- package/dist/zukhruf/plugins/http/validator.d.ts.map +1 -0
- package/dist/zukhruf/plugins/mcp/index.d.ts +8 -0
- package/dist/zukhruf/plugins/mcp/index.d.ts.map +1 -0
- package/dist/zukhruf/plugins/mcp/index.js +25 -0
- package/dist/zukhruf/plugins/mcp/index.js.map +7 -0
- package/dist/zukhruf/plugins/schedules/http.d.ts +45 -0
- package/dist/zukhruf/plugins/schedules/http.d.ts.map +1 -0
- package/dist/zukhruf/plugins/schedules/http.js +528 -0
- package/dist/zukhruf/plugins/schedules/http.js.map +7 -0
- package/dist/zukhruf/plugins/schedules/index.d.ts +35 -0
- package/dist/zukhruf/plugins/schedules/index.d.ts.map +1 -0
- package/dist/zukhruf/plugins/schedules/index.js +1873 -0
- package/dist/zukhruf/plugins/schedules/index.js.map +7 -0
- package/dist/zukhruf/plugins/schedules/schedule-files.d.ts +6 -0
- package/dist/zukhruf/plugins/schedules/schedule-files.d.ts.map +1 -0
- package/dist/zukhruf/plugins/schedules/scheduled-tasks.d.ts +157 -0
- package/dist/zukhruf/plugins/schedules/scheduled-tasks.d.ts.map +1 -0
- package/dist/zukhruf/plugins/uploads/http.d.ts +27 -0
- package/dist/zukhruf/plugins/uploads/http.d.ts.map +1 -0
- package/dist/zukhruf/plugins/uploads/http.js +426 -0
- package/dist/zukhruf/plugins/uploads/http.js.map +7 -0
- package/dist/zukhruf/plugins/uploads/index.d.ts +73 -0
- package/dist/zukhruf/plugins/uploads/index.d.ts.map +1 -0
- package/dist/zukhruf/plugins/uploads/index.js +247 -0
- package/dist/zukhruf/plugins/uploads/index.js.map +7 -0
- package/dist/zukhruf/queue/pg-boss-notifications.d.ts +10 -0
- package/dist/zukhruf/queue/pg-boss-notifications.d.ts.map +1 -0
- package/dist/zukhruf/queue/pg-boss.turn-queue.d.ts +8 -11
- package/dist/zukhruf/queue/pg-boss.turn-queue.d.ts.map +1 -1
- package/dist/zukhruf/queue/turn-queue.d.ts +43 -38
- package/dist/zukhruf/queue/turn-queue.d.ts.map +1 -1
- package/dist/zukhruf/runtime/agent-runtime.d.ts +163 -43
- package/dist/zukhruf/runtime/agent-runtime.d.ts.map +1 -1
- package/dist/zukhruf/runtime/agent-turn-executor.d.ts +9 -2
- package/dist/zukhruf/runtime/agent-turn-executor.d.ts.map +1 -1
- package/dist/zukhruf/runtime/approval-controller.d.ts +10 -25
- package/dist/zukhruf/runtime/approval-controller.d.ts.map +1 -1
- package/dist/zukhruf/runtime/compaction.d.ts +47 -0
- package/dist/zukhruf/runtime/compaction.d.ts.map +1 -0
- package/dist/zukhruf/runtime/conversation-status/change-source.d.ts +19 -0
- package/dist/zukhruf/runtime/conversation-status/change-source.d.ts.map +1 -0
- package/dist/zukhruf/runtime/conversation-status/child-progress.d.ts +84 -0
- package/dist/zukhruf/runtime/conversation-status/child-progress.d.ts.map +1 -0
- package/dist/zukhruf/runtime/conversation-status/pg-boss-change-source.d.ts +22 -0
- package/dist/zukhruf/runtime/conversation-status/pg-boss-change-source.d.ts.map +1 -0
- package/dist/zukhruf/runtime/conversation-status/projector.d.ts +62 -0
- package/dist/zukhruf/runtime/conversation-status/projector.d.ts.map +1 -0
- package/dist/zukhruf/runtime/conversation-status/status-publishing-turn-queue.d.ts +20 -0
- package/dist/zukhruf/runtime/conversation-status/status-publishing-turn-queue.d.ts.map +1 -0
- package/dist/zukhruf/runtime/plugin/agent-skills.d.ts +22 -0
- package/dist/zukhruf/runtime/plugin/agent-skills.d.ts.map +1 -0
- package/dist/zukhruf/runtime/plugin/plugin-agents.d.ts +14 -0
- package/dist/zukhruf/runtime/plugin/plugin-agents.d.ts.map +1 -0
- package/dist/zukhruf/runtime/plugin/plugin-bindings.d.ts +8 -0
- package/dist/zukhruf/runtime/plugin/plugin-bindings.d.ts.map +1 -0
- package/dist/zukhruf/runtime/plugin/plugin-context-composition.d.ts +7 -0
- package/dist/zukhruf/runtime/plugin/plugin-context-composition.d.ts.map +1 -0
- package/dist/zukhruf/runtime/plugin/plugin-manager.d.ts +38 -0
- package/dist/zukhruf/runtime/plugin/plugin-manager.d.ts.map +1 -0
- package/dist/zukhruf/runtime/plugin/plugin-tool-composition.d.ts +10 -0
- package/dist/zukhruf/runtime/plugin/plugin-tool-composition.d.ts.map +1 -0
- package/dist/zukhruf/tool.d.ts +5 -1
- package/dist/zukhruf/tool.d.ts.map +1 -1
- package/package.json +74 -6
- package/dist/zukhruf/multi-agent-v2-config.d.ts.map +0 -1
- package/dist/zukhruf/runtime/agent-skills.d.ts +0 -9
- package/dist/zukhruf/runtime/agent-skills.d.ts.map +0 -1
- package/dist/zukhruf/runtime/approval-job-id.d.ts +0 -3
- package/dist/zukhruf/runtime/approval-job-id.d.ts.map +0 -1
|
@@ -0,0 +1,528 @@
|
|
|
1
|
+
// packages/experimental/src/zukhruf/plugins/schedules/http.ts
|
|
2
|
+
import { Hono as Hono2 } from "hono";
|
|
3
|
+
import { bodyLimit } from "hono/body-limit";
|
|
4
|
+
import { HTTPException as HTTPException4 } from "hono/http-exception";
|
|
5
|
+
import { validate as validateUuid2 } from "uuid";
|
|
6
|
+
import z4 from "zod";
|
|
7
|
+
|
|
8
|
+
// packages/experimental/src/zukhruf/plugins/http/index.ts
|
|
9
|
+
import {
|
|
10
|
+
createUIMessageStreamResponse,
|
|
11
|
+
safeValidateUIMessages
|
|
12
|
+
} from "ai";
|
|
13
|
+
import { Hono } from "hono";
|
|
14
|
+
import { HTTPException as HTTPException3 } from "hono/http-exception";
|
|
15
|
+
import { basePath } from "hono/route";
|
|
16
|
+
import { streamSSE } from "hono/streaming";
|
|
17
|
+
import { validate as validateUuid } from "uuid";
|
|
18
|
+
import z3 from "zod";
|
|
19
|
+
import { elementsSchema } from "@deepagents/elements";
|
|
20
|
+
|
|
21
|
+
// packages/experimental/src/zukhruf/plugins/http/validator.ts
|
|
22
|
+
import { parse as parseContentType } from "fast-content-type-parse";
|
|
23
|
+
import { createMiddleware } from "hono/factory";
|
|
24
|
+
import { HTTPException as HTTPException2 } from "hono/http-exception";
|
|
25
|
+
import z2 from "zod";
|
|
26
|
+
|
|
27
|
+
// packages/experimental/src/zukhruf/plugins/http/parse.ts
|
|
28
|
+
import { HTTPException } from "hono/http-exception";
|
|
29
|
+
import "zod";
|
|
30
|
+
async function parse(schema, input) {
|
|
31
|
+
const result = await schema.safeParseAsync(input);
|
|
32
|
+
if (!result.success) {
|
|
33
|
+
const errors = result.error.flatten((issue) => ({
|
|
34
|
+
message: issue.message,
|
|
35
|
+
code: issue.code,
|
|
36
|
+
path: issue.path.join(".")
|
|
37
|
+
})).fieldErrors;
|
|
38
|
+
throw new HTTPException(400, {
|
|
39
|
+
message: "Validation failed",
|
|
40
|
+
cause: {
|
|
41
|
+
code: "api/validation-failed",
|
|
42
|
+
detail: "The input data is invalid",
|
|
43
|
+
errors
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
return result.data;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// packages/experimental/src/zukhruf/plugins/http/validator.ts
|
|
51
|
+
function validate(expectedContentTypeOrSelector, selector) {
|
|
52
|
+
const expectedContentType = typeof expectedContentTypeOrSelector === "string" ? expectedContentTypeOrSelector : void 0;
|
|
53
|
+
const _selector = typeof expectedContentTypeOrSelector === "function" ? expectedContentTypeOrSelector : selector;
|
|
54
|
+
void _selector;
|
|
55
|
+
if (!_selector) {
|
|
56
|
+
throw new Error("Selector function is required");
|
|
57
|
+
}
|
|
58
|
+
return createMiddleware(async (c, next) => {
|
|
59
|
+
const ct = c.req.header("content-type");
|
|
60
|
+
if (c.req.method === "GET" && ct) {
|
|
61
|
+
throw new HTTPException2(415, {
|
|
62
|
+
message: "Unsupported Media Type",
|
|
63
|
+
cause: {
|
|
64
|
+
code: "api/unsupported-media-type",
|
|
65
|
+
detail: `GET requests cannot have a content type header`
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
if (expectedContentType) {
|
|
70
|
+
void verifyContentType(ct, expectedContentType);
|
|
71
|
+
}
|
|
72
|
+
const contentType = ct ? parseContentType(ct) : null;
|
|
73
|
+
let body = null;
|
|
74
|
+
switch (contentType?.type) {
|
|
75
|
+
case "application/json":
|
|
76
|
+
body = await parseJson(c);
|
|
77
|
+
break;
|
|
78
|
+
case "application/x-www-form-urlencoded":
|
|
79
|
+
case "multipart/form-data":
|
|
80
|
+
body = await c.req.parseBody();
|
|
81
|
+
break;
|
|
82
|
+
default:
|
|
83
|
+
body = {};
|
|
84
|
+
}
|
|
85
|
+
const payload = {
|
|
86
|
+
body,
|
|
87
|
+
query: parseQueryParams(c.req.query()),
|
|
88
|
+
queries: parseQueriesParams(c.req.queries()),
|
|
89
|
+
params: c.req.param(),
|
|
90
|
+
headers: c.req.header()
|
|
91
|
+
};
|
|
92
|
+
const config = _selector(payload);
|
|
93
|
+
const schema = z2.object(
|
|
94
|
+
Object.entries(config).reduce(
|
|
95
|
+
(acc, [key, value]) => {
|
|
96
|
+
acc[key] = value.against;
|
|
97
|
+
return acc;
|
|
98
|
+
},
|
|
99
|
+
{}
|
|
100
|
+
)
|
|
101
|
+
);
|
|
102
|
+
const input = Object.entries(config).reduce(
|
|
103
|
+
(acc, [key, value]) => {
|
|
104
|
+
acc[key] = value.select;
|
|
105
|
+
return acc;
|
|
106
|
+
},
|
|
107
|
+
{}
|
|
108
|
+
);
|
|
109
|
+
const parsed = await parse(schema, input);
|
|
110
|
+
c.set("input", parsed);
|
|
111
|
+
await next();
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
function verifyContentType(actual, expected) {
|
|
115
|
+
if (!actual) {
|
|
116
|
+
throw new HTTPException2(415, {
|
|
117
|
+
message: "Unsupported Media Type",
|
|
118
|
+
cause: {
|
|
119
|
+
code: "api/unsupported-media-type",
|
|
120
|
+
detail: "Missing content type header"
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
const { type: incomingContentType } = parseContentType(actual);
|
|
125
|
+
if (incomingContentType !== expected) {
|
|
126
|
+
throw new HTTPException2(415, {
|
|
127
|
+
message: "Unsupported Media Type",
|
|
128
|
+
cause: {
|
|
129
|
+
code: "api/unsupported-media-type",
|
|
130
|
+
detail: `Expected content type: ${expected}, but got: ${incomingContentType}`
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
async function parseJson(context) {
|
|
136
|
+
try {
|
|
137
|
+
return await context.req.json();
|
|
138
|
+
} catch (error) {
|
|
139
|
+
throw new HTTPException2(400, {
|
|
140
|
+
message: "The request body is not valid JSON",
|
|
141
|
+
cause: {
|
|
142
|
+
code: "api/invalid-json",
|
|
143
|
+
detail: error instanceof Error ? error.message : String(error)
|
|
144
|
+
}
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function parseQueryParams(queryParams) {
|
|
149
|
+
return Object.fromEntries(
|
|
150
|
+
Object.entries(queryParams).map(([key, value]) => [
|
|
151
|
+
key,
|
|
152
|
+
value === "null" ? null : value
|
|
153
|
+
])
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
function parseQueriesParams(queriesParams) {
|
|
157
|
+
return Object.fromEntries(
|
|
158
|
+
Object.entries(queriesParams).map(([key, values]) => [
|
|
159
|
+
key,
|
|
160
|
+
values.map((value) => value === "null" ? null : value)
|
|
161
|
+
])
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
// packages/experimental/src/zukhruf/plugins/http/index.ts
|
|
166
|
+
function projectHttp(definition, project) {
|
|
167
|
+
return {
|
|
168
|
+
project(runtime) {
|
|
169
|
+
return project(runtime.plugin(definition), runtime);
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
var sessionIdSchema = z3.string().refine(validateUuid);
|
|
174
|
+
var jsonSchema = z3.custom(
|
|
175
|
+
(value) => typeof value === "object" && value !== null && !Array.isArray(value)
|
|
176
|
+
);
|
|
177
|
+
var clientToolsSchema = z3.record(
|
|
178
|
+
z3.string().min(1),
|
|
179
|
+
z3.strictObject({
|
|
180
|
+
inputSchema: jsonSchema,
|
|
181
|
+
description: z3.string().min(1)
|
|
182
|
+
})
|
|
183
|
+
).optional();
|
|
184
|
+
var turnBodySchema = z3.strictObject({
|
|
185
|
+
sessionId: sessionIdSchema,
|
|
186
|
+
message: z3.unknown(),
|
|
187
|
+
trigger: z3.enum(["submit-message", "regenerate-message"]),
|
|
188
|
+
tools: clientToolsSchema,
|
|
189
|
+
elements: elementsSchema
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// packages/experimental/src/zukhruf/plugins/schedules/http.ts
|
|
193
|
+
var SCHEDULES_PATH = "/schedules";
|
|
194
|
+
var TASKS_PATH = `${SCHEDULES_PATH}/tasks`;
|
|
195
|
+
var TASK_PATH = `${TASKS_PATH}/:taskId`;
|
|
196
|
+
var TASK_RUNS_PATH = `${TASK_PATH}/runs`;
|
|
197
|
+
var RUNS_PATH = `${SCHEDULES_PATH}/runs`;
|
|
198
|
+
var INBOX_PATH = `${RUNS_PATH}/inbox`;
|
|
199
|
+
var RUN_PATH = `${RUNS_PATH}/:runId`;
|
|
200
|
+
var MAX_BODY_BYTES = 10 * 1024;
|
|
201
|
+
var MAX_NAME_LENGTH = 200;
|
|
202
|
+
var MAX_PROMPT_LENGTH = 8e3;
|
|
203
|
+
var MAX_RECURRENCE_LENGTH = 1e3;
|
|
204
|
+
var MAX_TIMEZONE_LENGTH = 100;
|
|
205
|
+
var MAX_CHAT_ID_LENGTH = 200;
|
|
206
|
+
var MAX_IDEMPOTENCY_KEY_LENGTH = 200;
|
|
207
|
+
var NO_STORE = { "cache-control": "no-store" };
|
|
208
|
+
var scheduleIdSchema = z4.string().refine(validateUuid2);
|
|
209
|
+
var idempotencyKeySchema = z4.string().trim().min(1).max(MAX_IDEMPOTENCY_KEY_LENGTH);
|
|
210
|
+
var targetSchema = z4.discriminatedUnion("kind", [
|
|
211
|
+
z4.strictObject({ kind: z4.literal("new-conversation") }),
|
|
212
|
+
z4.strictObject({
|
|
213
|
+
kind: z4.literal("existing-conversation"),
|
|
214
|
+
chatId: z4.string().trim().min(1).max(MAX_CHAT_ID_LENGTH)
|
|
215
|
+
})
|
|
216
|
+
]);
|
|
217
|
+
var definitionSchema = {
|
|
218
|
+
name: z4.string().trim().min(1).max(MAX_NAME_LENGTH),
|
|
219
|
+
prompt: z4.string().trim().min(1).max(MAX_PROMPT_LENGTH),
|
|
220
|
+
recurrence: z4.string().trim().min(1).max(MAX_RECURRENCE_LENGTH),
|
|
221
|
+
timezone: z4.string().trim().min(1).max(MAX_TIMEZONE_LENGTH),
|
|
222
|
+
target: targetSchema
|
|
223
|
+
};
|
|
224
|
+
var createBodySchema = z4.strictObject(definitionSchema);
|
|
225
|
+
var updateBodySchema = z4.strictObject({
|
|
226
|
+
name: definitionSchema.name.optional(),
|
|
227
|
+
prompt: definitionSchema.prompt.optional(),
|
|
228
|
+
recurrence: definitionSchema.recurrence.optional(),
|
|
229
|
+
timezone: definitionSchema.timezone.optional(),
|
|
230
|
+
target: targetSchema.optional()
|
|
231
|
+
}).refine((body) => Object.values(body).some((value) => value !== void 0), {
|
|
232
|
+
message: "At least one field must be provided"
|
|
233
|
+
});
|
|
234
|
+
var limitBody = bodyLimit({
|
|
235
|
+
maxSize: MAX_BODY_BYTES,
|
|
236
|
+
onError: () => {
|
|
237
|
+
throw new HTTPException4(413, {
|
|
238
|
+
message: "Request body is too large",
|
|
239
|
+
cause: {
|
|
240
|
+
code: "api/payload-too-large",
|
|
241
|
+
detail: `Request body exceeds ${MAX_BODY_BYTES} bytes`
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
});
|
|
246
|
+
function schedulesHttp(definition) {
|
|
247
|
+
return projectHttp(definition, (plugin) => ({
|
|
248
|
+
capabilities: { schedules: { path: SCHEDULES_PATH } },
|
|
249
|
+
authenticatedRoutes: scheduleRoutes(plugin),
|
|
250
|
+
events: (userId, signal) => plugin.subscribeChanges(userId, signal)
|
|
251
|
+
}));
|
|
252
|
+
}
|
|
253
|
+
function scheduleRoutes(schedules) {
|
|
254
|
+
const app = new Hono2();
|
|
255
|
+
app.get(
|
|
256
|
+
TASKS_PATH,
|
|
257
|
+
async (context) => context.json(
|
|
258
|
+
(await domain(schedules.list(context.get("userId")))).map(toTaskView),
|
|
259
|
+
200,
|
|
260
|
+
NO_STORE
|
|
261
|
+
)
|
|
262
|
+
);
|
|
263
|
+
app.post(
|
|
264
|
+
TASKS_PATH,
|
|
265
|
+
limitBody,
|
|
266
|
+
validate("application/json", (payload) => ({
|
|
267
|
+
body: { select: payload.body, against: createBodySchema },
|
|
268
|
+
idempotencyKey: {
|
|
269
|
+
select: payload.headers["idempotency-key"],
|
|
270
|
+
against: idempotencyKeySchema
|
|
271
|
+
}
|
|
272
|
+
})),
|
|
273
|
+
async (context) => {
|
|
274
|
+
const { body, idempotencyKey } = context.var.input;
|
|
275
|
+
const task = await domain(
|
|
276
|
+
schedules.create(context.get("userId"), {
|
|
277
|
+
idempotencyKey,
|
|
278
|
+
name: body.name,
|
|
279
|
+
prompt: body.prompt,
|
|
280
|
+
recurrence: body.recurrence,
|
|
281
|
+
timezone: body.timezone,
|
|
282
|
+
executionConfig: toExecutionConfig(body.target)
|
|
283
|
+
})
|
|
284
|
+
);
|
|
285
|
+
return context.json(toTaskView(task), 200, NO_STORE);
|
|
286
|
+
}
|
|
287
|
+
);
|
|
288
|
+
app.all(TASKS_PATH, (context) => methodNotAllowed(context, "GET, POST"));
|
|
289
|
+
app.get(
|
|
290
|
+
TASK_RUNS_PATH,
|
|
291
|
+
taskIdInput,
|
|
292
|
+
async (context) => context.json(
|
|
293
|
+
(await domain(
|
|
294
|
+
schedules.listRuns(context.get("userId"), context.var.input.taskId)
|
|
295
|
+
)).map(toRunView),
|
|
296
|
+
200,
|
|
297
|
+
NO_STORE
|
|
298
|
+
)
|
|
299
|
+
);
|
|
300
|
+
app.all(TASK_RUNS_PATH, (context) => methodNotAllowed(context, "GET"));
|
|
301
|
+
for (const [action, operation] of [
|
|
302
|
+
["pause", schedules.pause],
|
|
303
|
+
["resume", schedules.resume],
|
|
304
|
+
["archive", schedules.archive]
|
|
305
|
+
]) {
|
|
306
|
+
const path = `${TASK_PATH}/${action}`;
|
|
307
|
+
app.post(
|
|
308
|
+
path,
|
|
309
|
+
taskIdInput,
|
|
310
|
+
async (context) => context.json(
|
|
311
|
+
toTaskView(
|
|
312
|
+
await domain(
|
|
313
|
+
operation.call(
|
|
314
|
+
schedules,
|
|
315
|
+
context.get("userId"),
|
|
316
|
+
context.var.input.taskId
|
|
317
|
+
)
|
|
318
|
+
)
|
|
319
|
+
),
|
|
320
|
+
200,
|
|
321
|
+
NO_STORE
|
|
322
|
+
)
|
|
323
|
+
);
|
|
324
|
+
app.all(path, (context) => methodNotAllowed(context, "POST"));
|
|
325
|
+
}
|
|
326
|
+
app.post(
|
|
327
|
+
`${TASK_PATH}/run`,
|
|
328
|
+
validate((payload) => ({
|
|
329
|
+
taskId: { select: payload.params.taskId, against: scheduleIdSchema },
|
|
330
|
+
idempotencyKey: {
|
|
331
|
+
select: payload.headers["idempotency-key"],
|
|
332
|
+
against: idempotencyKeySchema
|
|
333
|
+
}
|
|
334
|
+
})),
|
|
335
|
+
async (context) => {
|
|
336
|
+
const { idempotencyKey, taskId } = context.var.input;
|
|
337
|
+
const run = await domain(
|
|
338
|
+
schedules.runNow(context.get("userId"), taskId, idempotencyKey)
|
|
339
|
+
);
|
|
340
|
+
return context.json(toRunView(run), 202, NO_STORE);
|
|
341
|
+
}
|
|
342
|
+
);
|
|
343
|
+
app.all(`${TASK_PATH}/run`, (context) => methodNotAllowed(context, "POST"));
|
|
344
|
+
app.get(
|
|
345
|
+
TASK_PATH,
|
|
346
|
+
taskIdInput,
|
|
347
|
+
async (context) => context.json(
|
|
348
|
+
toTaskView(
|
|
349
|
+
await domain(
|
|
350
|
+
schedules.get(context.get("userId"), context.var.input.taskId)
|
|
351
|
+
)
|
|
352
|
+
),
|
|
353
|
+
200,
|
|
354
|
+
NO_STORE
|
|
355
|
+
)
|
|
356
|
+
);
|
|
357
|
+
app.patch(
|
|
358
|
+
TASK_PATH,
|
|
359
|
+
limitBody,
|
|
360
|
+
validate("application/json", (payload) => ({
|
|
361
|
+
body: { select: payload.body, against: updateBodySchema },
|
|
362
|
+
taskId: { select: payload.params.taskId, against: scheduleIdSchema }
|
|
363
|
+
})),
|
|
364
|
+
async (context) => {
|
|
365
|
+
const { body, taskId } = context.var.input;
|
|
366
|
+
const task = await domain(
|
|
367
|
+
schedules.update(context.get("userId"), taskId, {
|
|
368
|
+
name: body.name,
|
|
369
|
+
prompt: body.prompt,
|
|
370
|
+
recurrence: body.recurrence,
|
|
371
|
+
timezone: body.timezone,
|
|
372
|
+
executionConfig: body.target && toExecutionConfig(body.target)
|
|
373
|
+
})
|
|
374
|
+
);
|
|
375
|
+
return context.json(toTaskView(task), 200, NO_STORE);
|
|
376
|
+
}
|
|
377
|
+
);
|
|
378
|
+
app.delete(TASK_PATH, taskIdInput, async (context) => {
|
|
379
|
+
await domain(
|
|
380
|
+
schedules.purge(context.get("userId"), context.var.input.taskId)
|
|
381
|
+
);
|
|
382
|
+
return context.body(null, 204, NO_STORE);
|
|
383
|
+
});
|
|
384
|
+
app.all(
|
|
385
|
+
TASK_PATH,
|
|
386
|
+
(context) => methodNotAllowed(context, "GET, PATCH, DELETE")
|
|
387
|
+
);
|
|
388
|
+
app.get(
|
|
389
|
+
INBOX_PATH,
|
|
390
|
+
async (context) => context.json(
|
|
391
|
+
(await domain(schedules.listPendingReview(context.get("userId")))).map(
|
|
392
|
+
toRunView
|
|
393
|
+
),
|
|
394
|
+
200,
|
|
395
|
+
NO_STORE
|
|
396
|
+
)
|
|
397
|
+
);
|
|
398
|
+
app.all(INBOX_PATH, (context) => methodNotAllowed(context, "GET"));
|
|
399
|
+
for (const [action, operation] of [
|
|
400
|
+
["cancel", schedules.cancelRun],
|
|
401
|
+
["review", schedules.markReviewed]
|
|
402
|
+
]) {
|
|
403
|
+
const path = `${RUN_PATH}/${action}`;
|
|
404
|
+
app.post(
|
|
405
|
+
path,
|
|
406
|
+
runIdInput,
|
|
407
|
+
async (context) => context.json(
|
|
408
|
+
toRunView(
|
|
409
|
+
await domain(
|
|
410
|
+
operation.call(
|
|
411
|
+
schedules,
|
|
412
|
+
context.get("userId"),
|
|
413
|
+
context.var.input.runId
|
|
414
|
+
)
|
|
415
|
+
)
|
|
416
|
+
),
|
|
417
|
+
200,
|
|
418
|
+
NO_STORE
|
|
419
|
+
)
|
|
420
|
+
);
|
|
421
|
+
app.all(path, (context) => methodNotAllowed(context, "POST"));
|
|
422
|
+
}
|
|
423
|
+
app.get(
|
|
424
|
+
RUN_PATH,
|
|
425
|
+
runIdInput,
|
|
426
|
+
async (context) => context.json(
|
|
427
|
+
toRunView(
|
|
428
|
+
await domain(
|
|
429
|
+
schedules.getRun(context.get("userId"), context.var.input.runId)
|
|
430
|
+
)
|
|
431
|
+
),
|
|
432
|
+
200,
|
|
433
|
+
NO_STORE
|
|
434
|
+
)
|
|
435
|
+
);
|
|
436
|
+
app.all(RUN_PATH, (context) => methodNotAllowed(context, "GET"));
|
|
437
|
+
return app;
|
|
438
|
+
}
|
|
439
|
+
var taskIdInput = validate((payload) => ({
|
|
440
|
+
taskId: { select: payload.params.taskId, against: scheduleIdSchema }
|
|
441
|
+
}));
|
|
442
|
+
var runIdInput = validate((payload) => ({
|
|
443
|
+
runId: { select: payload.params.runId, against: scheduleIdSchema }
|
|
444
|
+
}));
|
|
445
|
+
function toExecutionConfig(target) {
|
|
446
|
+
return target.kind === "new-conversation" ? {} : { target };
|
|
447
|
+
}
|
|
448
|
+
function toTaskView(task) {
|
|
449
|
+
return {
|
|
450
|
+
id: task.id,
|
|
451
|
+
name: task.name,
|
|
452
|
+
prompt: task.prompt,
|
|
453
|
+
recurrence: task.recurrence,
|
|
454
|
+
timezone: task.timezone,
|
|
455
|
+
target: viewTarget(task.executionConfig),
|
|
456
|
+
status: task.status,
|
|
457
|
+
nextRunAt: task.nextRunAt,
|
|
458
|
+
createdAt: task.createdAt,
|
|
459
|
+
updatedAt: task.updatedAt,
|
|
460
|
+
archivedAt: task.archivedAt
|
|
461
|
+
};
|
|
462
|
+
}
|
|
463
|
+
function toRunView(run) {
|
|
464
|
+
const target = viewTarget(run.executionConfig);
|
|
465
|
+
return {
|
|
466
|
+
id: run.id,
|
|
467
|
+
taskId: run.taskId,
|
|
468
|
+
trigger: run.trigger,
|
|
469
|
+
occurrenceAt: run.occurrenceAt,
|
|
470
|
+
prompt: run.prompt,
|
|
471
|
+
target,
|
|
472
|
+
status: run.status,
|
|
473
|
+
reviewStatus: run.reviewStatus,
|
|
474
|
+
conversation: run.externalExecutionId ? {
|
|
475
|
+
chatId: target.kind === "existing-conversation" ? target.chatId : run.id,
|
|
476
|
+
turnId: run.externalExecutionId
|
|
477
|
+
} : null,
|
|
478
|
+
startedAt: run.startedAt,
|
|
479
|
+
finishedAt: run.finishedAt,
|
|
480
|
+
error: run.error,
|
|
481
|
+
createdAt: run.createdAt,
|
|
482
|
+
updatedAt: run.updatedAt
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
function viewTarget(config) {
|
|
486
|
+
return config.target ?? { kind: "new-conversation" };
|
|
487
|
+
}
|
|
488
|
+
function domain(result) {
|
|
489
|
+
return result.catch(rethrowAsHttp);
|
|
490
|
+
}
|
|
491
|
+
function asScheduledTasksError(error) {
|
|
492
|
+
return error instanceof Error && error.name === "ScheduledTasksError" ? error : void 0;
|
|
493
|
+
}
|
|
494
|
+
function rethrowAsHttp(cause) {
|
|
495
|
+
const error = asScheduledTasksError(cause);
|
|
496
|
+
if (!error) throw cause;
|
|
497
|
+
if (error.code === "not-found") {
|
|
498
|
+
throw new HTTPException4(404, {
|
|
499
|
+
message: "Scheduled resource not found",
|
|
500
|
+
cause: {
|
|
501
|
+
code: "schedules/not-found",
|
|
502
|
+
detail: "The requested scheduled resource does not exist"
|
|
503
|
+
}
|
|
504
|
+
});
|
|
505
|
+
}
|
|
506
|
+
throw new HTTPException4(error.code === "invalid-input" ? 400 : 409, {
|
|
507
|
+
message: error.message,
|
|
508
|
+
cause: {
|
|
509
|
+
code: `schedules/${error.code}`,
|
|
510
|
+
detail: error.message,
|
|
511
|
+
resource: error.resource
|
|
512
|
+
}
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
function methodNotAllowed(context, allow) {
|
|
516
|
+
context.header("Allow", allow);
|
|
517
|
+
throw new HTTPException4(405, {
|
|
518
|
+
message: "Method not allowed",
|
|
519
|
+
cause: {
|
|
520
|
+
code: "api/method-not-allowed",
|
|
521
|
+
detail: `This endpoint only accepts ${allow} requests`
|
|
522
|
+
}
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
export {
|
|
526
|
+
schedulesHttp
|
|
527
|
+
};
|
|
528
|
+
//# sourceMappingURL=http.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/zukhruf/plugins/schedules/http.ts", "../../../../src/zukhruf/plugins/http/index.ts", "../../../../src/zukhruf/plugins/http/validator.ts", "../../../../src/zukhruf/plugins/http/parse.ts"],
|
|
4
|
+
"sourcesContent": ["import { Hono } from 'hono';\nimport { bodyLimit } from 'hono/body-limit';\nimport { HTTPException } from 'hono/http-exception';\nimport { validate as validateUuid } from 'uuid';\nimport z from 'zod';\n\nimport type { AgentPluginDefinition } from '../../runtime/agent-runtime.ts';\nimport {\n type HttpEnv,\n type HttpProjection,\n projectHttp,\n} from '../http/index.ts';\nimport { validate } from '../http/validator.ts';\nimport type {\n ScheduleExecutionConfig,\n ScheduleTarget,\n Schedules,\n} from './index.ts';\nimport type {\n ScheduledRun,\n ScheduledRunReviewStatus,\n ScheduledRunStatus,\n ScheduledTask,\n ScheduledTaskStatus,\n ScheduledTasksError,\n} from './scheduled-tasks.ts';\n\nconst SCHEDULES_PATH = '/schedules';\nconst TASKS_PATH = `${SCHEDULES_PATH}/tasks`;\nconst TASK_PATH = `${TASKS_PATH}/:taskId`;\nconst TASK_RUNS_PATH = `${TASK_PATH}/runs`;\nconst RUNS_PATH = `${SCHEDULES_PATH}/runs`;\nconst INBOX_PATH = `${RUNS_PATH}/inbox`;\nconst RUN_PATH = `${RUNS_PATH}/:runId`;\n\nconst MAX_BODY_BYTES = 10 * 1024;\nconst MAX_NAME_LENGTH = 200;\nconst MAX_PROMPT_LENGTH = 8_000;\nconst MAX_RECURRENCE_LENGTH = 1_000;\nconst MAX_TIMEZONE_LENGTH = 100;\nconst MAX_CHAT_ID_LENGTH = 200;\nconst MAX_IDEMPOTENCY_KEY_LENGTH = 200;\nconst NO_STORE = { 'cache-control': 'no-store' } as const;\n\n/** Browser-safe Scheduled Task projection. Owner and scheduler bookkeeping stay server-side. */\nexport interface ScheduledTaskView {\n id: string;\n name: string;\n prompt: string;\n recurrence: string;\n timezone: string;\n target: ScheduleTarget;\n status: ScheduledTaskStatus;\n nextRunAt: number | null;\n createdAt: number;\n updatedAt: number;\n archivedAt: number | null;\n}\n\n/** Browser-safe Scheduled Run projection with its exact conversation reference. */\nexport interface ScheduledRunView {\n id: string;\n taskId: string;\n trigger: 'scheduled' | 'manual';\n occurrenceAt: number;\n prompt: string;\n target: ScheduleTarget;\n status: ScheduledRunStatus;\n reviewStatus: ScheduledRunReviewStatus | null;\n conversation: { chatId: string; turnId: string } | null;\n startedAt: number | null;\n finishedAt: number | null;\n error: string | null;\n createdAt: number;\n updatedAt: number;\n}\n\nconst scheduleIdSchema = z.string().refine(validateUuid);\nconst idempotencyKeySchema = z\n .string()\n .trim()\n .min(1)\n .max(MAX_IDEMPOTENCY_KEY_LENGTH);\nconst targetSchema = z.discriminatedUnion('kind', [\n z.strictObject({ kind: z.literal('new-conversation') }),\n z.strictObject({\n kind: z.literal('existing-conversation'),\n chatId: z.string().trim().min(1).max(MAX_CHAT_ID_LENGTH),\n }),\n]);\nconst definitionSchema = {\n name: z.string().trim().min(1).max(MAX_NAME_LENGTH),\n prompt: z.string().trim().min(1).max(MAX_PROMPT_LENGTH),\n recurrence: z.string().trim().min(1).max(MAX_RECURRENCE_LENGTH),\n timezone: z.string().trim().min(1).max(MAX_TIMEZONE_LENGTH),\n target: targetSchema,\n};\nconst createBodySchema = z.strictObject(definitionSchema);\nconst updateBodySchema = z\n .strictObject({\n name: definitionSchema.name.optional(),\n prompt: definitionSchema.prompt.optional(),\n recurrence: definitionSchema.recurrence.optional(),\n timezone: definitionSchema.timezone.optional(),\n target: targetSchema.optional(),\n })\n .refine((body) => Object.values(body).some((value) => value !== undefined), {\n message: 'At least one field must be provided',\n });\n\nconst limitBody = bodyLimit({\n maxSize: MAX_BODY_BYTES,\n onError: () => {\n throw new HTTPException(413, {\n message: 'Request body is too large',\n cause: {\n code: 'api/payload-too-large',\n detail: `Request body exceeds ${MAX_BODY_BYTES} bytes`,\n },\n });\n },\n});\n\n/**\n * Optional Scheduled Tasks capability bound to one `schedules()` definition.\n * Compose with `http(runtime, schedulesHttp(scheduled))`; omitting it removes\n * the capability from discovery so DevTool hides Scheduled navigation.\n */\nexport function schedulesHttp(\n definition: AgentPluginDefinition<Schedules>,\n): HttpProjection {\n return projectHttp(definition, (plugin) => ({\n capabilities: { schedules: { path: SCHEDULES_PATH } },\n authenticatedRoutes: scheduleRoutes(plugin),\n events: (userId, signal) => plugin.subscribeChanges(userId, signal),\n }));\n}\n\nfunction scheduleRoutes(schedules: Schedules) {\n const app = new Hono<HttpEnv>();\n\n app.get(TASKS_PATH, async (context) =>\n context.json(\n (await domain(schedules.list(context.get('userId')))).map(toTaskView),\n 200,\n NO_STORE,\n ),\n );\n app.post(\n TASKS_PATH,\n limitBody,\n validate('application/json', (payload) => ({\n body: { select: payload.body, against: createBodySchema },\n idempotencyKey: {\n select: payload.headers['idempotency-key'],\n against: idempotencyKeySchema,\n },\n })),\n async (context) => {\n const { body, idempotencyKey } = context.var.input;\n const task = await domain(\n schedules.create(context.get('userId'), {\n idempotencyKey,\n name: body.name,\n prompt: body.prompt,\n recurrence: body.recurrence,\n timezone: body.timezone,\n executionConfig: toExecutionConfig(body.target),\n }),\n );\n return context.json(toTaskView(task), 200, NO_STORE);\n },\n );\n app.all(TASKS_PATH, (context) => methodNotAllowed(context, 'GET, POST'));\n\n app.get(TASK_RUNS_PATH, taskIdInput, async (context) =>\n context.json(\n (\n await domain(\n schedules.listRuns(context.get('userId'), context.var.input.taskId),\n )\n ).map(toRunView),\n 200,\n NO_STORE,\n ),\n );\n app.all(TASK_RUNS_PATH, (context) => methodNotAllowed(context, 'GET'));\n\n for (const [action, operation] of [\n ['pause', schedules.pause],\n ['resume', schedules.resume],\n ['archive', schedules.archive],\n ] as const) {\n const path = `${TASK_PATH}/${action}`;\n app.post(path, taskIdInput, async (context) =>\n context.json(\n toTaskView(\n await domain(\n operation.call(\n schedules,\n context.get('userId'),\n context.var.input.taskId,\n ),\n ),\n ),\n 200,\n NO_STORE,\n ),\n );\n app.all(path, (context) => methodNotAllowed(context, 'POST'));\n }\n\n app.post(\n `${TASK_PATH}/run`,\n validate((payload) => ({\n taskId: { select: payload.params.taskId, against: scheduleIdSchema },\n idempotencyKey: {\n select: payload.headers['idempotency-key'],\n against: idempotencyKeySchema,\n },\n })),\n async (context) => {\n const { idempotencyKey, taskId } = context.var.input;\n const run = await domain(\n schedules.runNow(context.get('userId'), taskId, idempotencyKey),\n );\n return context.json(toRunView(run), 202, NO_STORE);\n },\n );\n app.all(`${TASK_PATH}/run`, (context) => methodNotAllowed(context, 'POST'));\n\n app.get(TASK_PATH, taskIdInput, async (context) =>\n context.json(\n toTaskView(\n await domain(\n schedules.get(context.get('userId'), context.var.input.taskId),\n ),\n ),\n 200,\n NO_STORE,\n ),\n );\n app.patch(\n TASK_PATH,\n limitBody,\n validate('application/json', (payload) => ({\n body: { select: payload.body, against: updateBodySchema },\n taskId: { select: payload.params.taskId, against: scheduleIdSchema },\n })),\n async (context) => {\n const { body, taskId } = context.var.input;\n const task = await domain(\n schedules.update(context.get('userId'), taskId, {\n name: body.name,\n prompt: body.prompt,\n recurrence: body.recurrence,\n timezone: body.timezone,\n executionConfig: body.target && toExecutionConfig(body.target),\n }),\n );\n return context.json(toTaskView(task), 200, NO_STORE);\n },\n );\n app.delete(TASK_PATH, taskIdInput, async (context) => {\n await domain(\n schedules.purge(context.get('userId'), context.var.input.taskId),\n );\n return context.body(null, 204, NO_STORE);\n });\n app.all(TASK_PATH, (context) =>\n methodNotAllowed(context, 'GET, PATCH, DELETE'),\n );\n\n app.get(INBOX_PATH, async (context) =>\n context.json(\n (await domain(schedules.listPendingReview(context.get('userId')))).map(\n toRunView,\n ),\n 200,\n NO_STORE,\n ),\n );\n app.all(INBOX_PATH, (context) => methodNotAllowed(context, 'GET'));\n\n for (const [action, operation] of [\n ['cancel', schedules.cancelRun],\n ['review', schedules.markReviewed],\n ] as const) {\n const path = `${RUN_PATH}/${action}`;\n app.post(path, runIdInput, async (context) =>\n context.json(\n toRunView(\n await domain(\n operation.call(\n schedules,\n context.get('userId'),\n context.var.input.runId,\n ),\n ),\n ),\n 200,\n NO_STORE,\n ),\n );\n app.all(path, (context) => methodNotAllowed(context, 'POST'));\n }\n\n app.get(RUN_PATH, runIdInput, async (context) =>\n context.json(\n toRunView(\n await domain(\n schedules.getRun(context.get('userId'), context.var.input.runId),\n ),\n ),\n 200,\n NO_STORE,\n ),\n );\n app.all(RUN_PATH, (context) => methodNotAllowed(context, 'GET'));\n\n return app;\n}\n\nconst taskIdInput = validate((payload) => ({\n taskId: { select: payload.params.taskId, against: scheduleIdSchema },\n}));\n\nconst runIdInput = validate((payload) => ({\n runId: { select: payload.params.runId, against: scheduleIdSchema },\n}));\n\nfunction toExecutionConfig(target: ScheduleTarget): ScheduleExecutionConfig {\n return target.kind === 'new-conversation' ? {} : { target };\n}\n\nfunction toTaskView(\n task: ScheduledTask<ScheduleExecutionConfig>,\n): ScheduledTaskView {\n return {\n id: task.id,\n name: task.name,\n prompt: task.prompt,\n recurrence: task.recurrence,\n timezone: task.timezone,\n target: viewTarget(task.executionConfig),\n status: task.status,\n nextRunAt: task.nextRunAt,\n createdAt: task.createdAt,\n updatedAt: task.updatedAt,\n archivedAt: task.archivedAt,\n };\n}\n\nfunction toRunView(\n run: ScheduledRun<ScheduleExecutionConfig>,\n): ScheduledRunView {\n const target = viewTarget(run.executionConfig);\n return {\n id: run.id,\n taskId: run.taskId,\n trigger: run.trigger,\n occurrenceAt: run.occurrenceAt,\n prompt: run.prompt,\n target,\n status: run.status,\n reviewStatus: run.reviewStatus,\n conversation: run.externalExecutionId\n ? {\n chatId:\n target.kind === 'existing-conversation' ? target.chatId : run.id,\n turnId: run.externalExecutionId,\n }\n : null,\n startedAt: run.startedAt,\n finishedAt: run.finishedAt,\n error: run.error,\n createdAt: run.createdAt,\n updatedAt: run.updatedAt,\n };\n}\n\nfunction viewTarget(config: ScheduleExecutionConfig): ScheduleTarget {\n return config.target ?? { kind: 'new-conversation' };\n}\n\n/** Hono resolves handler errors at the innermost dispatch frame, so every\n * domain call converts its own rejection instead of relying on middleware. */\nfunction domain<T>(result: Promise<T>): Promise<T> {\n return result.catch(rethrowAsHttp);\n}\n\n/**\n * `name` rather than `instanceof`: this subpath is its own build entry point, so\n * a value import of the domain would bundle a second copy of the class and every\n * `instanceof` check against it would fail.\n */\nfunction asScheduledTasksError(\n error: unknown,\n): ScheduledTasksError | undefined {\n return error instanceof Error && error.name === 'ScheduledTasksError'\n ? (error as ScheduledTasksError)\n : undefined;\n}\n\nfunction rethrowAsHttp(cause: unknown): never {\n const error = asScheduledTasksError(cause);\n if (!error) throw cause;\n if (error.code === 'not-found') {\n throw new HTTPException(404, {\n message: 'Scheduled resource not found',\n cause: {\n code: 'schedules/not-found',\n detail: 'The requested scheduled resource does not exist',\n },\n });\n }\n throw new HTTPException(error.code === 'invalid-input' ? 400 : 409, {\n message: error.message,\n cause: {\n code: `schedules/${error.code}`,\n detail: error.message,\n resource: error.resource,\n },\n });\n}\n\nfunction methodNotAllowed(\n context: { header(name: string, value: string): void },\n allow: string,\n): never {\n context.header('Allow', allow);\n throw new HTTPException(405, {\n message: 'Method not allowed',\n cause: {\n code: 'api/method-not-allowed',\n detail: `This endpoint only accepts ${allow} requests`,\n },\n });\n}\n", "import {\n type JSONSchema7,\n type UIMessage,\n createUIMessageStreamResponse,\n safeValidateUIMessages,\n} from 'ai';\nimport { type Context, Hono } from 'hono';\nimport { HTTPException } from 'hono/http-exception';\nimport { basePath } from 'hono/route';\nimport { streamSSE } from 'hono/streaming';\nimport { validate as validateUuid } from 'uuid';\nimport z from 'zod';\n\nimport { elementsSchema } from '@deepagents/elements';\n\nimport type { ConversationId } from '../../mailbox/types.ts';\nimport type {\n AgentHost,\n AgentObservation,\n AgentPluginDefinition,\n AgentPluginInstance,\n} from '../../runtime/agent-runtime.ts';\nimport { validate } from './validator.ts';\n\nexport type HttpEnv = { Variables: { userId: string } };\n\nexport type OwnerEvent =\n | { readonly type: 'ready' }\n | {\n readonly type: 'change';\n readonly resource: string;\n readonly id: string;\n readonly [key: string]: unknown;\n };\n\ntype OwnerEventNotification =\n Exclude<OwnerEvent, { type: 'ready' }> | { readonly type: 'reset' };\n\nexport type OwnerEventSource = (\n userId: string,\n signal: AbortSignal,\n) => Promise<AsyncIterable<OwnerEventNotification>>;\n\n/** A discoverable feature: its route under the mount plus any detail the client needs to use it. */\nexport interface HttpCapability {\n readonly path: string;\n readonly [detail: string]: unknown;\n}\n\nexport interface HttpContribution {\n readonly capabilities: Readonly<Record<string, HttpCapability>>;\n readonly publicRoutes?: Hono<HttpEnv>;\n readonly authenticatedRoutes?: Hono<HttpEnv>;\n readonly events?: OwnerEventSource;\n}\n\nexport interface HttpProjection {\n project(runtime: HttpRuntime): HttpContribution;\n}\n\nexport function projectHttp<Instance extends object>(\n definition: AgentPluginDefinition<Instance>,\n project: (\n plugin: AgentPluginInstance & Instance,\n runtime: HttpRuntime,\n ) => HttpContribution,\n): HttpProjection {\n return {\n project(runtime) {\n return project(runtime.plugin(definition), runtime);\n },\n };\n}\n\nconst SESSION_ROUTE_PATH = '/session/:sessionId';\nconst SESSION_CANCEL_ROUTE_PATH = '/session/:sessionId/cancel';\nconst SESSION_STREAM_ROUTE_PATH = '/session/:sessionId/stream';\nconst EVENTS_ROUTE_PATH = '/events';\nconst SESSION_TURN_ROUTE_PATH = '/session/:sessionId/turn/:turnId';\nconst SESSION_TURN_CANCEL_ROUTE_PATH =\n '/session/:sessionId/turn/:turnId/cancel';\nconst HISTORY_ROUTE_PATH = '/history';\nconst INFO_ROUTE_PATH = '/info';\nconst HEALTH_ROUTE_PATH = '/health';\nexport const ZUKHRUF_SESSION_ID_HEADER = 'x-zukhruf-session-id';\nexport const ZUKHRUF_TURN_ID_HEADER = 'x-zukhruf-turn-id';\n\n/** Where the host mounted this API, without a trailing slash; empty at `/`. */\nexport function mountPath(context: Context): string {\n return basePath(context).replace(/\\/$/, '');\n}\n\nconst NO_STORE = { 'cache-control': 'no-store' } as const;\nconst sessionIdSchema = z.string().refine(validateUuid);\nconst jsonSchema = z.custom<JSONSchema7>(\n (value) =>\n typeof value === 'object' && value !== null && !Array.isArray(value),\n);\nconst clientToolsSchema = z\n .record(\n z.string().min(1),\n z.strictObject({\n inputSchema: jsonSchema,\n description: z.string().min(1),\n }),\n )\n .optional();\nconst turnBodySchema = z.strictObject({\n sessionId: sessionIdSchema,\n message: z.unknown(),\n trigger: z.enum(['submit-message', 'regenerate-message']),\n tools: clientToolsSchema,\n elements: elementsSchema,\n});\n\nexport interface HttpRuntime extends Pick<\n AgentHost,\n | 'createSession'\n | 'enqueue'\n | 'info'\n | 'listHistory'\n | 'plugin'\n | 'sessionExists'\n | 'subscribeConversationStatus'\n> {\n observe(conversation: ConversationId): Pick<\n AgentObservation,\n 'cancel' | 'resume' | 'status'\n > & {\n engine: Pick<AgentObservation['engine'], 'getMessages'>;\n };\n}\n\n/** Mount at the host-selected path with `app.route(path, http(runtime))`. */\nexport function http(\n runtime: HttpRuntime,\n ...projections: readonly HttpProjection[]\n) {\n const contributions = projections.map((projection) =>\n projection.project(runtime),\n );\n const capabilities: Record<string, HttpCapability> = {\n history: { path: HISTORY_ROUTE_PATH },\n chat: { path: '/session' },\n events: { path: EVENTS_ROUTE_PATH },\n };\n for (const { capabilities: contributed } of contributions) {\n for (const [name, capability] of Object.entries(contributed)) {\n if (!name.trim() || name !== name.trim()) {\n throw new Error(\n `http: capability name \"${name}\" must be non-empty without surrounding whitespace`,\n );\n }\n if (!capability.path.startsWith('/')) {\n throw new Error(`http: capability \"${name}\" must use an absolute path`);\n }\n if (Object.hasOwn(capabilities, name)) {\n throw new Error(`http: duplicate capability \"${name}\"`);\n }\n capabilities[name] = capability;\n }\n }\n const app = new Hono<HttpEnv>();\n app.onError((error, context) => {\n if (error instanceof HTTPException) {\n return context.json(\n { cause: error.cause, error: error.message },\n error.status,\n NO_STORE,\n );\n }\n throw error;\n });\n\n app.on(['GET', 'HEAD'], HEALTH_ROUTE_PATH, (context) =>\n context.req.method === 'HEAD'\n ? context.body(null, 200, NO_STORE)\n : context.json({ ok: true }, 200, NO_STORE),\n );\n app.all(HEALTH_ROUTE_PATH, (context) =>\n methodNotAllowed(context, 'GET, HEAD'),\n );\n\n for (const { publicRoutes } of contributions) {\n if (publicRoutes) app.route('/', publicRoutes);\n }\n\n app.use('*', async (context, next) => {\n if (!context.get('userId')?.trim()) {\n throw new HTTPException(401, {\n message: 'Authentication required',\n cause: {\n code: 'api/unauthenticated',\n detail: 'Authentication required to access Zukhruf',\n },\n });\n }\n await next();\n });\n\n app.get(INFO_ROUTE_PATH, (context) => {\n const mount = mountPath(context);\n return context.json(\n {\n ...runtime.info,\n capabilities: Object.fromEntries(\n Object.entries(capabilities).map(([name, { path, ...detail }]) => [\n name,\n { href: `${mount}${path}`, ...detail },\n ]),\n ),\n },\n 200,\n NO_STORE,\n );\n });\n app.all(INFO_ROUTE_PATH, (context) => methodNotAllowed(context, 'GET'));\n\n app.get(HISTORY_ROUTE_PATH, async (context) =>\n context.json(\n await runtime.listHistory(context.get('userId')),\n 200,\n NO_STORE,\n ),\n );\n app.all(HISTORY_ROUTE_PATH, (context) => methodNotAllowed(context, 'GET'));\n\n app.get(\n SESSION_ROUTE_PATH,\n validate((payload) => ({\n sessionId: {\n select: payload.params.sessionId,\n against: sessionIdSchema,\n },\n })),\n async (context) => {\n const { sessionId } = context.var.input;\n const conversation = {\n chatId: sessionId,\n userId: context.get('userId'),\n };\n await requireSession(runtime, conversation);\n return context.json(\n {\n sessionId,\n messages: await runtime.observe(conversation).engine.getMessages(),\n },\n 200,\n NO_STORE,\n );\n },\n );\n app.post(\n SESSION_ROUTE_PATH,\n validate('application/json', (payload) => ({\n body: {\n select: payload.body,\n against: turnBodySchema,\n },\n sessionId: {\n select: payload.params.sessionId,\n against: sessionIdSchema,\n },\n })),\n async (context) => {\n const { body, sessionId } = context.var.input;\n if (body.sessionId !== sessionId) {\n throw invalidSessionId('Route and body session IDs must match');\n }\n const conversation = {\n chatId: sessionId,\n userId: context.get('userId'),\n };\n const request = await validateTurnRequest(body);\n if (!(await runtime.sessionExists(conversation))) {\n if (request.message.role !== 'user') {\n throw invalidMessage('A new session must start with a user message');\n }\n if (request.trigger !== 'submit-message') {\n throw invalidMessage('A new session cannot regenerate a response');\n }\n await runtime.createSession(conversation);\n }\n const turn = await runtime.enqueue(conversation, request);\n\n return accepted(context, sessionId, turn.id);\n },\n );\n app.all(SESSION_ROUTE_PATH, (context) =>\n methodNotAllowed(context, 'GET, POST'),\n );\n\n app.get(\n SESSION_TURN_ROUTE_PATH,\n validate((payload) => ({\n sessionId: {\n select: payload.params.sessionId,\n against: sessionIdSchema,\n },\n turnId: {\n select: payload.params.turnId,\n against: sessionIdSchema,\n },\n })),\n async (context) => {\n const { sessionId, turnId } = context.var.input;\n const conversation = {\n chatId: sessionId,\n userId: context.get('userId'),\n };\n await requireSession(runtime, conversation);\n const status = await runtime.observe(conversation).status(turnId);\n if (!status) {\n throw new HTTPException(404, {\n message: 'Session turn not found',\n cause: {\n code: 'zukhruf/session-turn-not-found',\n detail: `Turn ${turnId} does not exist in session ${sessionId}`,\n },\n });\n }\n return context.json({ sessionId, turnId, ...status }, 200, NO_STORE);\n },\n );\n app.all(SESSION_TURN_ROUTE_PATH, (context) =>\n methodNotAllowed(context, 'GET'),\n );\n\n app.post(\n SESSION_TURN_CANCEL_ROUTE_PATH,\n validate((payload) => ({\n sessionId: {\n select: payload.params.sessionId,\n against: sessionIdSchema,\n },\n turnId: {\n select: payload.params.turnId,\n against: sessionIdSchema,\n },\n })),\n async (context) => {\n const { sessionId, turnId } = context.var.input;\n const conversation = {\n chatId: sessionId,\n userId: context.get('userId'),\n };\n await requireSession(runtime, conversation);\n await runtime.observe(conversation).cancel(turnId);\n return context.body(null, 204, NO_STORE);\n },\n );\n app.all(SESSION_TURN_CANCEL_ROUTE_PATH, (context) =>\n methodNotAllowed(context, 'POST'),\n );\n\n app.post(\n SESSION_CANCEL_ROUTE_PATH,\n validate((payload) => ({\n sessionId: {\n select: payload.params.sessionId,\n against: sessionIdSchema,\n },\n })),\n async (context) => {\n const { sessionId } = context.var.input;\n const conversation = {\n chatId: sessionId,\n userId: context.get('userId'),\n };\n await requireSession(runtime, conversation);\n await runtime.observe(conversation).cancel();\n return context.body(null, 204, NO_STORE);\n },\n );\n app.all(SESSION_CANCEL_ROUTE_PATH, (context) =>\n methodNotAllowed(context, 'POST'),\n );\n\n const eventSources: OwnerEventSource[] = [\n async (userId, signal) => {\n const events = await runtime.subscribeConversationStatus(signal);\n return {\n async *[Symbol.asyncIterator]() {\n for await (const event of events) {\n if (event.type === 'reset') {\n yield event;\n } else if (event.conversation.userId === userId) {\n yield {\n type: 'change',\n resource: 'conversation',\n id: event.conversation.chatId,\n status: event.status,\n ...(event.child ? { child: event.child } : {}),\n } satisfies OwnerEvent;\n }\n }\n },\n };\n },\n ...contributions.flatMap(({ events }) => (events ? [events] : [])),\n ];\n\n app.get(EVENTS_ROUTE_PATH, (context) => {\n const userId = context.get('userId');\n const abort = new AbortController();\n const requestSignal = context.req.raw.signal;\n const abortRequest = () => abort.abort();\n requestSignal.addEventListener('abort', abortRequest, { once: true });\n context.header('cache-control', 'no-store');\n return streamSSE(context, async (stream) => {\n stream.onAbort(abortRequest);\n let lastWrite: Promise<unknown> = Promise.resolve();\n const write = (event: OwnerEvent) => {\n const next = lastWrite.then(() =>\n stream.writeSSE({ data: JSON.stringify(event) }),\n );\n lastWrite = next.catch(() => {});\n return next;\n };\n const heartbeat = setInterval(() => {\n const next = lastWrite.then(async () => {\n await stream.write(': heartbeat\\n\\n');\n });\n lastWrite = next.catch(() => {});\n }, 15_000);\n try {\n const subscriptions = await Promise.all(\n eventSources.map((subscribe) => subscribe(userId, abort.signal)),\n );\n await write({ type: 'ready' });\n await Promise.all(\n subscriptions.map(async (events) => {\n for await (const event of events) {\n await write(event.type === 'reset' ? { type: 'ready' } : event);\n }\n }),\n );\n } catch (error) {\n if (!(error instanceof Error && error.name === 'AbortError')) {\n throw error;\n }\n } finally {\n clearInterval(heartbeat);\n abort.abort();\n requestSignal.removeEventListener('abort', abortRequest);\n }\n });\n });\n app.all(EVENTS_ROUTE_PATH, (context) => methodNotAllowed(context, 'GET'));\n\n app.get(\n SESSION_STREAM_ROUTE_PATH,\n validate((payload) => ({\n sessionId: {\n select: payload.params.sessionId,\n against: sessionIdSchema,\n },\n })),\n async (context) => {\n const { sessionId } = context.var.input;\n const conversation = {\n chatId: sessionId,\n userId: context.get('userId'),\n };\n await requireSession(runtime, conversation);\n const stream = await runtime.observe(conversation).resume();\n if (!stream) {\n throw new HTTPException(404, {\n message: 'Session stream not found',\n cause: {\n code: 'zukhruf/session-stream-not-found',\n detail: `No durable stream exists for session ${sessionId}`,\n },\n });\n }\n\n return createUIMessageStreamResponse({\n headers: NO_STORE,\n stream,\n });\n },\n );\n app.all(SESSION_STREAM_ROUTE_PATH, (context) =>\n methodNotAllowed(context, 'GET'),\n );\n\n for (const { authenticatedRoutes } of contributions) {\n if (authenticatedRoutes) app.route('/', authenticatedRoutes);\n }\n\n return app;\n}\n\nfunction accepted<Env extends HttpEnv>(\n context: Context<Env>,\n sessionId: string,\n turnId: string,\n) {\n return context.json({ ok: true, sessionId, turnId }, 202, {\n ...NO_STORE,\n [ZUKHRUF_SESSION_ID_HEADER]: sessionId,\n [ZUKHRUF_TURN_ID_HEADER]: turnId,\n });\n}\n\nasync function validateTurnMessage(\n value: unknown,\n): Promise<Parameters<HttpRuntime['enqueue']>[1]['message']> {\n const result = await safeValidateUIMessages({ messages: [value] });\n if (!result.success) throw invalidMessage(result.error.message);\n const message = result.data[0];\n if (!isTurnMessage(message))\n throw invalidMessage('System messages are not accepted');\n return message;\n}\n\nasync function validateTurnRequest(\n body: z.infer<typeof turnBodySchema>,\n): Promise<Parameters<HttpRuntime['enqueue']>[1]> {\n const message = await validateTurnMessage(body.message);\n const tools = body.tools === undefined ? {} : { tools: body.tools };\n const elements =\n body.elements === undefined ? {} : { elements: body.elements };\n if (message.role === 'assistant') {\n if (body.trigger === 'regenerate-message') {\n throw invalidMessage(\n 'Regeneration requires the user message preceding the assistant response',\n );\n }\n return { message, trigger: 'submit-message', ...tools, ...elements };\n }\n return { message, trigger: body.trigger, ...tools, ...elements };\n}\n\nfunction isTurnMessage(\n message: UIMessage,\n): message is Parameters<HttpRuntime['enqueue']>[1]['message'] {\n return message.role === 'user' || message.role === 'assistant';\n}\n\nfunction invalidMessage(detail: string): HTTPException {\n return new HTTPException(400, {\n message: 'Invalid message',\n cause: { code: 'api/validation-failed', detail },\n });\n}\n\nfunction invalidSessionId(detail: string): HTTPException {\n return new HTTPException(400, {\n message: 'Invalid session ID',\n cause: { code: 'api/validation-failed', detail },\n });\n}\n\nasync function requireSession(\n runtime: HttpRuntime,\n conversation: ConversationId,\n): Promise<void> {\n if (await runtime.sessionExists(conversation)) return;\n throw new HTTPException(404, {\n message: 'Session not found',\n cause: {\n code: 'zukhruf/session-not-found',\n detail: `Session ${conversation.chatId} does not exist`,\n },\n });\n}\n\nfunction methodNotAllowed(context: Context<HttpEnv>, allow: string): never {\n context.header('Allow', allow);\n throw new HTTPException(405, {\n message: 'Method not allowed',\n cause: {\n code: 'api/method-not-allowed',\n detail: `This endpoint only accepts ${allow} requests`,\n },\n });\n}\n", "import { parse as parseContentType } from 'fast-content-type-parse';\nimport type { Context, MiddlewareHandler, ValidationTargets } from 'hono';\nimport { createMiddleware } from 'hono/factory';\nimport { HTTPException } from 'hono/http-exception';\nimport z from 'zod';\n\nimport { parse } from './parse.ts';\n\ntype ContentType =\n | 'application/json'\n | 'application/x-www-form-urlencoded'\n | 'multipart/form-data'\n | 'text/plain';\n\ntype ValidatorConfig = Record<\n string,\n { select: unknown; against: z.ZodTypeAny }\n>;\n\ntype ExtractInput<T extends ValidatorConfig> = {\n [K in keyof T]: z.infer<T[K]['against']>;\n};\n\ntype HasUndefined<T> = undefined extends T ? true : false;\n\ntype InferTarget<\n T extends ValidatorConfig,\n S,\n Target extends keyof ValidationTargets,\n> = {\n [K in keyof T as T[K]['select'] extends S ? K : never]: HasUndefined<\n z.infer<T[K]['against']>\n > extends true\n ? z.infer<T[K]['against']> | undefined\n : z.infer<T[K]['against']> extends ValidationTargets[Target]\n ? z.infer<T[K]['against']>\n : z.infer<T[K]['against']>;\n};\n\ntype InferIn<T extends ValidatorConfig> = (keyof InferTarget<\n T,\n QuerySelect | QueriesSelect,\n 'query'\n> extends never\n ? never\n : { query: InferTarget<T, QuerySelect | QueriesSelect, 'query'> }) &\n (keyof InferTarget<T, BodySelect, 'json'> extends never\n ? never\n : { json: InferTarget<T, BodySelect, 'json'> }) &\n (keyof InferTarget<T, ParamsSelect, 'param'> extends never\n ? never\n : { param: InferTarget<T, ParamsSelect, 'param'> }) &\n (keyof InferTarget<T, HeadersSelect, 'header'> extends never\n ? never\n : { header: InferTarget<T, HeadersSelect, 'header'> }) &\n (keyof InferTarget<T, CookieSelect, 'cookie'> extends never\n ? never\n : { cookie: InferTarget<T, CookieSelect, 'cookie'> });\n\n// Marker classes\nclass BodySelect {\n #private = 0;\n}\nclass QuerySelect {\n #private = 0;\n}\nclass QueriesSelect {\n #private = 0;\n}\nclass ParamsSelect {\n #private = 0;\n}\nclass HeadersSelect {\n #private = 0;\n}\nclass CookieSelect {\n #private = 0;\n}\n\ntype SelectorFn<T> = (payload: {\n body: Record<string, BodySelect>;\n query: Record<string, QuerySelect>;\n queries: Record<string, QueriesSelect>;\n params: Record<string, ParamsSelect>;\n headers: Record<string, HeadersSelect>;\n}) => T;\ntype ValidateMiddleware<T extends ValidatorConfig> = MiddlewareHandler<\n {\n Variables: {\n input: ExtractInput<T>;\n };\n },\n string,\n { in: InferIn<T> }\n>;\n\nexport function validate<T extends ValidatorConfig>(\n selector: SelectorFn<T>,\n): ValidateMiddleware<T>;\nexport function validate<T extends ValidatorConfig>(\n expectedContentTypeOrSelector: ContentType,\n selector: SelectorFn<T>,\n): ValidateMiddleware<T>;\nexport function validate<T extends ValidatorConfig>(\n expectedContentTypeOrSelector: ContentType | SelectorFn<T>,\n selector?: SelectorFn<T>,\n): ValidateMiddleware<T> {\n const expectedContentType =\n typeof expectedContentTypeOrSelector === 'string'\n ? expectedContentTypeOrSelector\n : undefined;\n const _selector =\n typeof expectedContentTypeOrSelector === 'function'\n ? expectedContentTypeOrSelector\n : selector;\n void _selector;\n if (!_selector) {\n throw new Error('Selector function is required');\n }\n\n return createMiddleware(async (c, next) => {\n const ct = c.req.header('content-type');\n if (c.req.method === 'GET' && ct) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: `GET requests cannot have a content type header`,\n },\n });\n }\n if (expectedContentType) {\n void verifyContentType(ct, expectedContentType);\n }\n\n const contentType = ct ? parseContentType(ct) : null;\n let body: unknown = null;\n\n switch (contentType?.type) {\n case 'application/json':\n body = await parseJson(c);\n break;\n case 'application/x-www-form-urlencoded':\n case 'multipart/form-data':\n body = await c.req.parseBody();\n break;\n default:\n body = {};\n }\n\n const payload = {\n body,\n query: parseQueryParams(c.req.query()),\n queries: parseQueriesParams(c.req.queries()),\n params: c.req.param(),\n headers: c.req.header(),\n };\n\n const config = _selector(payload as never);\n const schema = z.object(\n Object.entries(config).reduce<Record<string, z.ZodTypeAny>>(\n (acc, [key, value]) => {\n acc[key] = value.against;\n return acc;\n },\n {},\n ),\n );\n\n const input = Object.entries(config).reduce<Record<string, unknown>>(\n (acc, [key, value]) => {\n acc[key] = value.select;\n return acc;\n },\n {},\n );\n\n const parsed = await parse(schema, input);\n c.set('input', parsed as ExtractInput<T>);\n await next();\n });\n}\n\nexport const openapi = validate;\n\nexport const consume = (contentType: ContentType) => {\n return createMiddleware(async (context, next) => {\n verifyContentType(context.req.header('content-type'), contentType);\n await next();\n });\n};\n\nexport function verifyContentType(\n actual: string | undefined,\n expected: ContentType,\n): asserts actual is ContentType {\n if (!actual) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: 'Missing content type header',\n },\n });\n }\n const { type: incomingContentType } = parseContentType(actual);\n if (incomingContentType !== expected) {\n throw new HTTPException(415, {\n message: 'Unsupported Media Type',\n cause: {\n code: 'api/unsupported-media-type',\n detail: `Expected content type: ${expected}, but got: ${incomingContentType}`,\n },\n });\n }\n}\n\nasync function parseJson(context: Context) {\n try {\n return await context.req.json();\n } catch (error) {\n throw new HTTPException(400, {\n message: 'The request body is not valid JSON',\n cause: {\n code: 'api/invalid-json',\n detail: error instanceof Error ? error.message : String(error),\n },\n });\n }\n}\n\nfunction parseQueryParams(\n queryParams: Record<string, string | undefined>,\n): Record<string, string | null | undefined> {\n return Object.fromEntries(\n Object.entries(queryParams).map(([key, value]) => [\n key,\n value === 'null' ? null : value,\n ]),\n );\n}\n\nfunction parseQueriesParams(\n queriesParams: Record<string, string[]>,\n): Record<string, (string | null)[]> {\n return Object.fromEntries(\n Object.entries(queriesParams).map(([key, values]) => [\n key,\n values.map((value) => (value === 'null' ? null : value)),\n ]),\n );\n}\n", "import { HTTPException } from 'hono/http-exception';\nimport z from 'zod';\n\ninterface ValidationIssue {\n message: string;\n code: string;\n path: string;\n}\n\nexport async function parse<T extends z.ZodRawShape>(\n schema: z.ZodObject<T>,\n input: unknown,\n) {\n const result = await schema.safeParseAsync(input);\n if (!result.success) {\n const errors: z.inferFlattenedErrors<\n z.ZodObject<T>,\n ValidationIssue\n >['fieldErrors'] = result.error.flatten((issue) => ({\n message: issue.message,\n code: issue.code,\n path: issue.path.join('.'),\n })).fieldErrors;\n\n throw new HTTPException(400, {\n message: 'Validation failed',\n cause: {\n code: 'api/validation-failed',\n detail: 'The input data is invalid',\n errors,\n },\n });\n }\n return result.data;\n}\n"],
|
|
5
|
+
"mappings": ";AAAA,SAAS,QAAAA,aAAY;AACrB,SAAS,iBAAiB;AAC1B,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,YAAYC,qBAAoB;AACzC,OAAOC,QAAO;;;ACJd;AAAA,EAGE;AAAA,EACA;AAAA,OACK;AACP,SAAuB,YAAY;AACnC,SAAS,iBAAAC,sBAAqB;AAC9B,SAAS,gBAAgB;AACzB,SAAS,iBAAiB;AAC1B,SAAS,YAAY,oBAAoB;AACzC,OAAOC,QAAO;AAEd,SAAS,sBAAsB;;;ACb/B,SAAS,SAAS,wBAAwB;AAE1C,SAAS,wBAAwB;AACjC,SAAS,iBAAAC,sBAAqB;AAC9B,OAAOC,QAAO;;;ACJd,SAAS,qBAAqB;AAC9B,OAAc;AAQd,eAAsB,MACpB,QACA,OACA;AACA,QAAM,SAAS,MAAM,OAAO,eAAe,KAAK;AAChD,MAAI,CAAC,OAAO,SAAS;AACnB,UAAM,SAGa,OAAO,MAAM,QAAQ,CAAC,WAAW;AAAA,MAClD,SAAS,MAAM;AAAA,MACf,MAAM,MAAM;AAAA,MACZ,MAAM,MAAM,KAAK,KAAK,GAAG;AAAA,IAC3B,EAAE,EAAE;AAEJ,UAAM,IAAI,cAAc,KAAK;AAAA,MAC3B,SAAS;AAAA,MACT,OAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,QACR;AAAA,MACF;AAAA,IACF,CAAC;A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AAI;AAAA,IACf,YAAY,IAAI;AAAA,IAChB,OAAO,IAAI;AAAA,IACX,WAAW,IAAI;AAAA,IACf,WAAW,IAAI;AAAA,EACjB;AACF;AAEA,SAAS,WAAW,QAAiD;AACnE,SAAO,OAAO,UAAU,EAAE,MAAM,mBAAmB;AACrD;AAIA,SAAS,OAAU,QAAgC;AACjD,SAAO,OAAO,MAAM,aAAa;AACnC;AAOA,SAAS,sBACP,OACiC;AACjC,SAAO,iBAAiB,SAAS,MAAM,SAAS,wBAC3C,QACD;AACN;AAEA,SAAS,cAAc,OAAuB;AAC5C,QAAM,QAAQ,sBAAsB,KAAK;AACzC,MAAI,CAAC,MAAO,OAAM;AAClB,MAAI,MAAM,SAAS,aAAa;AAC9B,UAAM,IAAID,eAAc,KAAK;AAAA,MAC3B,SAAS;AAAA,MACT,OAAO;AAAA,QACL,MAAM;AAAA,QACN,QAAQ;AAAA,MACV;AAAA,IACF,CAAC;AAAA,EACH;AACA,QAAM,IAAIA,eAAc,MAAM,SAAS,kBAAkB,MAAM,KAAK;AAAA,IAClE,SAAS,MAAM;AAAA,IACf,OAAO;AAAA,MACL,MAAM,aAAa,MAAM,IAAI;AAAA,MAC7B,QAAQ,MAAM;AAAA,MACd,UAAU,MAAM;AAAA,IAClB;AAAA,EACF,CAAC;AACH;AAEA,SAAS,iBACP,SACA,OACO;AACP,UAAQ,OAAO,SAAS,KAAK;AAC7B,QAAM,IAAIA,eAAc,KAAK;AAAA,IAC3B,SAAS;AAAA,IACT,OAAO;AAAA,MACL,MAAM;AAAA,MACN,QAAQ,8BAA8B,KAAK;AAAA,IAC7C;AAAA,EACF,CAAC;AACH;",
|
|
6
|
+
"names": ["Hono", "HTTPException", "validateUuid", "z", "HTTPException", "z", "HTTPException", "z", "HTTPException", "z", "HTTPException", "z", "z", "validateUuid", "HTTPException", "Hono"]
|
|
7
|
+
}
|