@desplega.ai/agent-swarm 1.152.2 → 1.154.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 +2 -2
- package/dist/{acp-adapter-pfeje2v5.js → acp-adapter-eb2aj8xy.js} +4 -4
- package/dist/{actions-0sttc7f5.js → actions-kpnwp1kz.js} +31 -27
- package/dist/{anthropic-messages-2y8nktar.js → anthropic-messages-9vqsbznt.js} +112 -84
- package/dist/{app-p8teva95.js → app-zk1apkf6.js} +10 -7
- package/dist/{assistant-r45jnsrt.js → assistant-kwq4y50q.js} +32 -28
- package/dist/{azure-openai-responses-f38x2avq.js → azure-openai-responses-04qwdwfq.js} +27 -13
- package/dist/{boot-reembed-je26h5y7.js → boot-reembed-22hd3jjn.js} +9 -7
- package/dist/{boot-reembed-1qmybsd4.js → boot-reembed-qe168424.js} +10 -8
- package/dist/{boot-scrub-logs-gte3h1mm.js → boot-scrub-logs-pkdpsrjd.js} +7 -5
- package/dist/{claude-adapter-csc1mzka.js → claude-adapter-3fx90nww.js} +18 -16
- package/dist/{claude-managed-adapter-dsmkcrjy.js → claude-managed-adapter-ea2aga6w.js} +3 -3
- package/dist/{claude-sdk-session-fcd6f078.js → claude-sdk-session-z7fahf1k.js} +18 -16
- package/dist/{cli-r2fpe7cx.js → cli-00w2c66p.js} +61 -55
- package/dist/{cli-wbyk465z.js → cli-09y3tjxz.js} +1 -1
- package/dist/{cli-ht5rs63n.js → cli-0e31nm4n.js} +16 -7
- package/dist/cli-0x5qzvkg.js +4279 -0
- package/dist/{cli-d3p82erb.js → cli-18amys3y.js} +9 -9
- package/dist/{cli-4ahpr4sw.js → cli-1jpjafw4.js} +5 -5
- package/dist/{cli-jbmc0r7r.js → cli-243tzws8.js} +1 -1
- package/dist/{cli-ch38q5z4.js → cli-24k806sc.js} +6789 -2542
- package/dist/cli-3bkz2p7j.js +2828 -0
- package/dist/cli-3er6gcsn.js +1849 -0
- package/dist/cli-4k7jazkq.js +3339 -0
- package/dist/{cli-c4eeb5q2.js → cli-5b6b62tz.js} +1 -1
- package/dist/{cli-qd65dvr6.js → cli-5vs0nh43.js} +65 -44
- package/dist/{cli-z3wkng35.js → cli-6r3cgpk2.js} +224 -156
- package/dist/{cli-pgj4a5fb.js → cli-71cj99hx.js} +4 -3
- package/dist/cli-8sea27q4.js +14075 -0
- package/dist/{cli-jvy9qgjs.js → cli-913yakhv.js} +22 -7
- package/dist/{cli-pf9q3696.js → cli-927erqqt.js} +5 -2
- package/dist/cli-95jnpnqg.js +230 -0
- package/dist/{cli-wpv5rgg2.js → cli-abp3g4ax.js} +15 -2
- package/dist/{cli-ckz5t2hb.js → cli-acy6bfhr.js} +10 -7
- package/dist/{cli-4yc5d8fk.js → cli-avkd6mqv.js} +50 -0
- package/dist/{cli-8wrympd7.js → cli-bzr0ftht.js} +26 -7
- package/dist/{cli-qn042eh7.js → cli-c1v10xb2.js} +194 -1913
- package/dist/cli-cgj4hc12.js +18902 -0
- package/dist/{cli-2nnd56zt.js → cli-e0pg4zeh.js} +3 -2
- package/dist/{cli-r84ctdxn.js → cli-e31ehqwy.js} +2 -2
- package/dist/{cli-gphgnvpf.js → cli-e3229na9.js} +3 -3
- package/dist/{cli-gpqcs935.js → cli-e3cyf59d.js} +2 -2
- package/dist/{cli-s25avqg9.js → cli-e781c6f9.js} +1 -0
- package/dist/{cli-s2qjdd6z.js → cli-eetrvv91.js} +1 -1
- package/dist/{cli-j4nv2wqy.js → cli-fdzg6jhf.js} +10 -4
- package/dist/{cli-fm4ytsdk.js → cli-g2h29qar.js} +2 -2
- package/dist/{cli-zvgj5zg8.js → cli-ge67p080.js} +302 -3497
- package/dist/cli-h38x0qhg.js +6912 -0
- package/dist/{cli-9xvdm3bx.js → cli-h60qfasa.js} +742 -278
- package/dist/{cli-jew3jda5.js → cli-hws0vn86.js} +2 -2
- package/dist/{cli-j8dggbcr.js → cli-k0g1sjzm.js} +23 -31
- package/dist/{cli-xw7vak96.js → cli-kp3qs53m.js} +5 -5
- package/dist/{cli-rgvp6r2x.js → cli-mcnhgnn1.js} +193 -4
- package/dist/{cli-zvkq5csn.js → cli-myaxtgh8.js} +7 -6
- package/dist/{cli-56h18ng2.js → cli-n62atwh9.js} +1 -1
- package/dist/cli-n7h1kqpf.js +29 -0
- package/dist/{cli-fmy65jdn.js → cli-pf1v8xhb.js} +7 -5
- package/dist/{cli-xy1cchaf.js → cli-q85qhckh.js} +238 -11
- package/dist/{cli-3bpzj8me.js → cli-r1d3dzt6.js} +2 -2
- package/dist/{pi-mono-adapter-jcqt71cg.js → cli-rxkqvngf.js} +67343 -101083
- package/dist/{cli-kj76p1ez.js → cli-scwq51gn.js} +13 -7
- package/dist/{cli-b9dd0h3k.js → cli-stwsmd6k.js} +3 -2
- package/dist/{cli-c2mk1kgf.js → cli-v4en75c5.js} +8 -1
- package/dist/{cli-z61ykvam.js → cli-wg04s9kr.js} +4 -3
- package/dist/cli-yn0a417a.js +4069 -0
- package/dist/{cli-zfzznn7c.js → cli-ytxs7mn1.js} +26 -2
- package/dist/{cli-4j8k1m4w.js → cli-zt1227k1.js} +1162 -192
- package/dist/cli.js +28 -35
- package/dist/{codex-adapter-fxmpsabw.js → codex-adapter-ttdm995v.js} +12 -11
- package/dist/{codex-hook-8jexc34x.js → codex-hook-8gx7bcz0.js} +3 -3
- package/dist/{codex-session-runner-rr1e47ea.js → codex-session-runner-3v8nh4c8.js} +12 -11
- package/dist/{commands-0f5rxz51.js → commands-1cxwbhhq.js} +7 -5
- package/dist/{db-r3jxf3wy.js → db-y9zwsr79.js} +25 -5
- package/dist/{dispatcher-06vph6q4.js → dispatcher-9m9zss36.js} +30 -26
- package/dist/dsh-adapter-gsb2qqf9.js +19 -0
- package/dist/{e2b-413b8t4v.js → e2b-93x1k0j5.js} +6 -7
- package/dist/{google-generative-ai-ndjmj5fa.js → google-generative-ai-gwwrnzqn.js} +33 -73
- package/dist/{google-vertex-fr665tqs.js → google-vertex-5wfawpwz.js} +38 -68
- package/dist/{handlers-0hgtc910.js → handlers-36fm1bwn.js} +33 -29
- package/dist/{hook-9kvrv1er.js → hook-pntw4r8h.js} +12 -10
- package/dist/{hook-fbfhkat3.js → hook-vwq8y26p.js} +13 -11
- package/dist/{http-xbyx8k5j.js → http-20jesakk.js} +357 -261
- package/dist/{index-jsw3aynb.js → index-6artrehg.js} +30 -26
- package/dist/{cli-pdz9qde4.js → index-9ch1n761.js} +10 -11
- package/dist/{index-rnyahfn5.js → index-9n5z2492.js} +30 -26
- package/dist/{index-66xz5e9j.js → index-h5gs261z.js} +521 -9
- package/dist/{index-tfsdxyv6.js → index-j5wrf1yw.js} +40 -25
- package/dist/{index-2sp0384z.js → index-kkeftv5h.js} +738 -21
- package/dist/{index-sgk50mbg.js → index-m2xqpz5r.js} +31 -27
- package/dist/{index-gpfn1741.js → index-m9ks8a7t.js} +9 -7
- package/dist/index-w097eg0x.js +5 -0
- package/dist/jiti-loader-b4837mtm.js +34 -0
- package/dist/jiti-static-loader-q2g5ds0y.js +31267 -0
- package/dist/{keepalive-s3xpr7sw.js → keepalive-pwxvxd2c.js} +9 -7
- package/dist/{lead-rq4n5r16.js → lead-m789wqa3.js} +46 -41
- package/dist/{maintenance-f0atj1ab.js → maintenance-bvg6w7e2.js} +10 -8
- package/dist/{mistral-conversations-qhr84ph3.js → mistral-conversations-zx0kn554.js} +24 -18
- package/dist/{node-x1g4v0pq.js → node-5qtycf6a.js} +16 -11
- package/dist/{oauth-refresh-sweep-q0t3bxre.js → oauth-refresh-sweep-6v4bd737.js} +8 -6
- package/dist/{onboard-br5j1kch.js → onboard-snckpcj1.js} +115 -35
- package/dist/{openai-codex-responses-wy6a43wd.js → openai-codex-responses-4vjqzvjp.js} +33 -27
- package/dist/{openai-completions-32rdwmze.js → openai-completions-pxsmym7g.js} +52 -64
- package/dist/{openai-responses-6xwf7bzg.js → openai-responses-tmn0rqp0.js} +23 -24
- package/dist/{opencode-adapter-28axqa09.js → opencode-adapter-qbmv4tpy.js} +6 -6
- package/dist/{otel-impl-vdqge2nt.js → otel-impl-e0ytens5.js} +4 -4
- package/dist/{pi-messages-b1mbr6gp.js → pi-messages-txpjj39q.js} +3 -3
- package/dist/pi-mono-adapter-c4ggemhz.js +1316 -0
- package/dist/{pricing-refresh-hb3691fd.js → pricing-refresh-52g2ywrw.js} +9 -7
- package/dist/{rbac-roles-t78xt39b.js → rbac-roles-5455kfdn.js} +8 -6
- package/dist/{rbac-roles-jh280k9g.js → rbac-roles-hbf0xa52.js} +9 -7
- package/dist/{render-v2-7p8r2ymg.js → render-v2-npm8xdzh.js} +16 -9
- package/dist/{seed-pricing-hf889enh.js → seed-pricing-650wbr1n.js} +8 -6
- package/dist/{setup-w6mb03jv.js → setup-k1mew5rf.js} +4 -5
- package/dist/virtual-modules-2q5b2pk4.js +54 -0
- package/dist/{work-objects-nt8gy1kj.js → work-objects-2ea3kvwg.js} +33 -29
- package/dist/{worker-dwy617t0.js → worker-ec6hvc4m.js} +46 -41
- package/openapi.json +109 -16
- package/package.json +7 -6
- package/plugin/opencode-plugins/lib/memory-raters.ts +7 -0
- package/src/be/automation-preflight.ts +6 -4
- package/src/be/db/agents.ts +75 -2
- package/src/be/db/tasks/read.ts +2 -0
- package/src/be/db/tasks/write.ts +7 -1
- package/src/be/db.ts +140 -18
- package/src/be/extensions/db.ts +35 -4
- package/src/be/memory/raters/llm.ts +2 -6
- package/src/be/memory/raters/noop.ts +2 -3
- package/src/be/memory/raters/registry.ts +4 -10
- package/src/be/migrations/157_defer_provenance_and_marker.sql +27 -0
- package/src/be/models-catalog.ts +2 -0
- package/src/be/modelsdev-cache.json +213 -0
- package/src/be/rbac-audit.ts +2 -0
- package/src/be/seed/agent-fs-provision.ts +23 -0
- package/src/be/seed-pricing.ts +3 -1
- package/src/be/swarm-config-guard.ts +1 -0
- package/src/commands/onboard/compose-generator.ts +16 -1
- package/src/commands/onboard/env-generator.ts +14 -1
- package/src/commands/onboard/manifest.ts +1 -0
- package/src/commands/onboard/steps/integration-slack.tsx +56 -16
- package/src/commands/onboard/steps/review.tsx +5 -0
- package/src/commands/onboard/types.ts +6 -0
- package/src/commands/onboard.tsx +5 -1
- package/src/commands/provider-credentials.ts +14 -2
- package/src/commands/runner.ts +18 -2
- package/src/extensions/identity.ts +15 -7
- package/src/extensions/lifecycle.ts +15 -21
- package/src/hooks/codex-hook.ts +7 -1
- package/src/http/agents.ts +12 -4
- package/src/http/config.ts +1 -1
- package/src/http/core.ts +5 -3
- package/src/http/extensions.ts +108 -34
- package/src/http/poll.ts +7 -0
- package/src/http/schedules.ts +10 -0
- package/src/http/script-runs.ts +35 -26
- package/src/http/status.ts +24 -11
- package/src/http/tasks.ts +6 -1
- package/src/prompts/base-prompt.ts +15 -7
- package/src/prompts/memories.ts +5 -7
- package/src/prompts/session-templates.ts +3 -2
- package/src/prompts/steering-delivery.ts +2 -0
- package/src/providers/claude-managed-models.ts +8 -0
- package/src/providers/codex-adapter.ts +3 -6
- package/src/providers/codex-models.ts +15 -1
- package/src/providers/dsh-adapter.ts +248 -0
- package/src/providers/index.ts +5 -1
- package/src/providers/modelsdev-reasoning.json +50 -0
- package/src/providers/pi-mono-extension.ts +2 -5
- package/src/rbac/legacy-policy.ts +15 -1
- package/src/rbac/types.ts +2 -0
- package/src/server.ts +7 -1
- package/src/slack/ack.ts +43 -8
- package/src/slack/app.ts +32 -10
- package/src/slack/config.ts +29 -0
- package/src/slack/handlers.ts +7 -1
- package/src/slack/render-v2.ts +186 -17
- package/src/slack/responses.ts +1 -3
- package/src/slack/task-output.ts +66 -8
- package/src/slack/thread-buffer.ts +27 -3
- package/src/telemetry.ts +2 -3
- package/src/tests/agent-fs-provision-seeder.test.ts +56 -2
- package/src/tests/agents-harness-provider.test.ts +19 -0
- package/src/tests/agents-list-model-display.test.ts +60 -1
- package/src/tests/base-prompt.test.ts +25 -0
- package/src/tests/claude-managed-adapter.test.ts +6 -0
- package/src/tests/codex-gpt6-release.test.ts +97 -0
- package/src/tests/codex-steering-hook.test.ts +2 -2
- package/src/tests/config-api-only-keys.test.ts +9 -0
- package/src/tests/context-window.test.ts +1 -0
- package/src/tests/db-task-read-contract.test.ts +9 -0
- package/src/tests/db-task-write-contract.test.ts +9 -0
- package/src/tests/defer-task.test.ts +115 -16
- package/src/tests/dsh-adapter.test.ts +276 -0
- package/src/tests/e2e-nightly-report.test.ts +3 -3
- package/src/tests/e2e-redact.test.ts +2 -0
- package/src/tests/env-flag.test.ts +6 -0
- package/src/tests/extension-agent-visibility.test.ts +474 -0
- package/src/tests/extensions-db.test.ts +41 -0
- package/src/tests/extensions-http.test.ts +148 -4
- package/src/tests/extensions-lifecycle.test.ts +21 -1
- package/src/tests/extensions-mcp-tools.test.ts +9 -5
- package/src/tests/fetch-resolved-env.test.ts +43 -0
- package/src/tests/internal-ai/complete-structured.test.ts +32 -9
- package/src/tests/internal-ai/credentials.test.ts +4 -4
- package/src/tests/internal-ai/models.test.ts +20 -0
- package/src/tests/memory-rate-tool.test.ts +7 -10
- package/src/tests/memory-rater-defaults.test.ts +23 -0
- package/src/tests/memory-rater-e2e.test.ts +2 -3
- package/src/tests/migration-046-budgets.test.ts +2 -0
- package/src/tests/model-control.test.ts +2 -2
- package/src/tests/onboard-compose.test.ts +14 -0
- package/src/tests/onboard-env.test.ts +17 -0
- package/src/tests/onboard-manifest.test.ts +12 -0
- package/src/tests/opus-5-5-registry.test.ts +48 -0
- package/src/tests/pricing-refresh.test.ts +1 -1
- package/src/tests/pricing-routes.test.ts +15 -3
- package/src/tests/provider-registration.test.ts +5 -2
- package/src/tests/rbac-admission-e2e.test.ts +54 -0
- package/src/tests/rbac-e2e-helpers.ts +2 -0
- package/src/tests/rbac-engine.test.ts +32 -0
- package/src/tests/rbac-wire-e2e.test.ts +33 -0
- package/src/tests/reasoning-effort.test.ts +8 -0
- package/src/tests/reload-config.test.ts +33 -0
- package/src/tests/script-connections.test.ts +3 -0
- package/src/tests/session-costs-model-key-normalize.test.ts +1 -0
- package/src/tests/slack-config.test.ts +136 -0
- package/src/tests/slack-mode-lifecycle.test.ts +69 -0
- package/src/tests/slack-render-v2.test.ts +446 -16
- package/src/tests/slack-steering.test.ts +69 -1
- package/src/tests/slack-task-output.test.ts +33 -12
- package/src/tests/status.test.ts +22 -2
- package/src/tests/steering-core.test.ts +35 -0
- package/src/tests/steering-delivery.test.ts +39 -0
- package/src/tests/steering-transport.test.ts +2 -2
- package/src/tests/task-tool-preload-mcp.test.ts +3 -1
- package/src/tests/telemetry-init.test.ts +18 -0
- package/src/tests/workflow-live-recovery.test.ts +126 -0
- package/src/tests/workflow-llm.test.ts +3 -3
- package/src/tools/defer-task.ts +64 -26
- package/src/tools/extension-common.ts +4 -0
- package/src/tools/extension-install.ts +1 -1
- package/src/tools/extension-list.ts +4 -3
- package/src/tools/join-swarm.ts +1 -1
- package/src/tools/schedules/create-schedule.ts +11 -1
- package/src/tools/schedules/patch-schedule.ts +5 -0
- package/src/tools/schedules/update-schedule.ts +5 -0
- package/src/tools/send-task.ts +6 -0
- package/src/tools/utils.ts +1 -1
- package/src/types.ts +30 -8
- package/src/utils/context-window.ts +1 -0
- package/src/utils/credentials.ts +8 -0
- package/src/utils/internal-ai/complete-structured.ts +8 -0
- package/src/utils/internal-ai/models.ts +5 -5
- package/src/utils/memory-raters.ts +3 -0
- package/src/workflows/engine.ts +28 -0
- package/src/workflows/recovery.ts +7 -4
- package/templates/schedules/daily-status-report/content.md +25 -12
- package/templates/schedules/daily-workflow-health-audit/content.md +1 -1
- package/templates/skills/swarm-extensions/content.md +9 -5
- package/dist/cli-4wppfkcm.js +0 -16384
- package/dist/cli-55qrx3q8.js +0 -6041
- package/dist/cli-cg4vnyh4.js +0 -305
- package/dist/cli-jyetr64j.js +0 -52
- package/dist/cli-pp9ax9pa.js +0 -520
- package/dist/cli-qa66qaf0.js +0 -6076
- package/dist/cli-qghpvca2.js +0 -590
- package/dist/cli-rembwgt8.js +0 -861
- package/dist/cli-tcvj7j2r.js +0 -1971
- package/dist/cli-vfcth11k.js +0 -36
- package/dist/cli-w1d1bgkk.js +0 -1422
- package/dist/cli-y6x0gqtg.js +0 -5977
- package/dist/es5-tj3tn4jj.js +0 -844
- package/dist/index-1kq5hw2p.js +0 -467
- package/dist/index-1p8wdstt.js +0 -7
- package/dist/index-8fdjzb2f.js +0 -100
- package/dist/index-bxmwzbgw.js +0 -365
- package/dist/index-nzerxd5z.js +0 -7
- package/dist/index-pyymnzat.js +0 -1168
- package/dist/index-qv6atbab.js +0 -619
- package/dist/index-rja32qa7.js +0 -801
- package/dist/index-tzg5srfp.js +0 -211
- package/dist/index-vhncw983.js +0 -90
- package/dist/index-xk036zsk.js +0 -859
- package/dist/index-zyazbzcb.js +0 -6
- package/dist/{claude-managed-setup-48dwg9bv.js → claude-managed-setup-f5pmsyrp.js} +3 -3
|
@@ -0,0 +1,3339 @@
|
|
|
1
|
+
import {
|
|
2
|
+
MAX_PROFILE_FILE_LENGTH,
|
|
3
|
+
init_constants
|
|
4
|
+
} from "./cli-dv6cdjs2.js";
|
|
5
|
+
import {
|
|
6
|
+
exports_zod,
|
|
7
|
+
init_zod
|
|
8
|
+
} from "./cli-sd0mxa3c.js";
|
|
9
|
+
import {
|
|
10
|
+
__esm
|
|
11
|
+
} from "./cli-bc05qbss.js";
|
|
12
|
+
|
|
13
|
+
// src/assets/key.ts
|
|
14
|
+
function normalizeAssetKey(input) {
|
|
15
|
+
if (typeof input !== "string")
|
|
16
|
+
throw new AssetKeyError("Asset key must be a string");
|
|
17
|
+
if (input.includes("\x00"))
|
|
18
|
+
throw new AssetKeyError("Asset key cannot contain NUL bytes");
|
|
19
|
+
if (input.includes("\\"))
|
|
20
|
+
throw new AssetKeyError("Asset key must use forward slashes");
|
|
21
|
+
const normalized = input.trim().normalize("NFKC").toLowerCase();
|
|
22
|
+
if (!normalized)
|
|
23
|
+
throw new AssetKeyError("Asset key cannot be empty");
|
|
24
|
+
if (normalized.startsWith("/"))
|
|
25
|
+
throw new AssetKeyError("Asset key must be relative");
|
|
26
|
+
const withTrailingSlash = normalized.endsWith("/") ? normalized : `${normalized}/`;
|
|
27
|
+
if (withTrailingSlash.length > ASSET_KEY_MAX_LENGTH) {
|
|
28
|
+
throw new AssetKeyError(`Asset key cannot exceed ${ASSET_KEY_MAX_LENGTH} characters`);
|
|
29
|
+
}
|
|
30
|
+
const segments = withTrailingSlash.slice(0, -1).split("/");
|
|
31
|
+
if (segments.some((segment) => segment === "" || segment === "." || segment === "..")) {
|
|
32
|
+
throw new AssetKeyError("Asset key contains an empty or traversal segment");
|
|
33
|
+
}
|
|
34
|
+
const root = segments[0];
|
|
35
|
+
if (root !== "shared" && root !== "personal") {
|
|
36
|
+
throw new AssetKeyError("Asset key root must be shared or personal");
|
|
37
|
+
}
|
|
38
|
+
if (root === "personal" && !segments[1]) {
|
|
39
|
+
throw new AssetKeyError("Personal asset keys require a canonical user ID");
|
|
40
|
+
}
|
|
41
|
+
return withTrailingSlash;
|
|
42
|
+
}
|
|
43
|
+
function defaultAssetKey(resource, id) {
|
|
44
|
+
if (!id.trim())
|
|
45
|
+
throw new AssetKeyError("Asset key resource ID cannot be empty");
|
|
46
|
+
return normalizeAssetKey(`shared/${resource}:${id}/`);
|
|
47
|
+
}
|
|
48
|
+
function parseAssetKey(input) {
|
|
49
|
+
const key = normalizeAssetKey(input);
|
|
50
|
+
const segments = key.slice(0, -1).split("/");
|
|
51
|
+
if (segments[0] === "personal") {
|
|
52
|
+
return {
|
|
53
|
+
root: "personal",
|
|
54
|
+
key,
|
|
55
|
+
segments,
|
|
56
|
+
userId: segments[1],
|
|
57
|
+
relativeSegments: segments.slice(2)
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
root: "shared",
|
|
62
|
+
key,
|
|
63
|
+
segments,
|
|
64
|
+
relativeSegments: segments.slice(1)
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function isCanonicalAssetKey(input) {
|
|
68
|
+
try {
|
|
69
|
+
return normalizeAssetKey(input) === input;
|
|
70
|
+
} catch {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
function canWriteAssetKey(input, trustedUserId) {
|
|
75
|
+
const parsed = parseAssetKey(input);
|
|
76
|
+
return parsed.root === "shared" || !!trustedUserId && parsed.userId === trustedUserId;
|
|
77
|
+
}
|
|
78
|
+
var ASSET_KEY_MAX_LENGTH = 255, AssetKeyError;
|
|
79
|
+
var init_key = __esm(() => {
|
|
80
|
+
AssetKeyError = class AssetKeyError extends Error {
|
|
81
|
+
constructor(message) {
|
|
82
|
+
super(message);
|
|
83
|
+
this.name = "AssetKeyError";
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
// src/extensions/bundle-path.ts
|
|
89
|
+
function isSafeBundlePath(path) {
|
|
90
|
+
return path.length > 0 && path.length <= 256 && !path.startsWith("/") && !path.includes("\\") && !path.includes("\x00") && path.split("/").every((segment) => segment !== "" && segment !== "." && segment !== "..");
|
|
91
|
+
}
|
|
92
|
+
var init_bundle_path = () => {};
|
|
93
|
+
|
|
94
|
+
// node_modules/@asteasolutions/zod-to-openapi/dist/index.cjs
|
|
95
|
+
function __rest(s, e) {
|
|
96
|
+
var t = {};
|
|
97
|
+
for (var p in s)
|
|
98
|
+
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
99
|
+
t[p] = s[p];
|
|
100
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
101
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s);i < p.length; i++) {
|
|
102
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
103
|
+
t[p[i]] = s[p[i]];
|
|
104
|
+
}
|
|
105
|
+
return t;
|
|
106
|
+
}
|
|
107
|
+
function isZodType(schema, typeNames) {
|
|
108
|
+
const typeNamesArray = Array.isArray(typeNames) ? typeNames : [typeNames];
|
|
109
|
+
return typeNamesArray.some((typeName) => {
|
|
110
|
+
var _a;
|
|
111
|
+
const typeNameMatch = ((_a = schema === null || schema === undefined ? undefined : schema.def) === null || _a === undefined ? undefined : _a.type) === ZodTypeKeys[typeName];
|
|
112
|
+
if (typeName === "ZodDiscriminatedUnion") {
|
|
113
|
+
return typeNameMatch && "discriminator" in schema.def;
|
|
114
|
+
}
|
|
115
|
+
return typeNameMatch;
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function isAnyZodType(schema) {
|
|
119
|
+
return schema && "def" in schema;
|
|
120
|
+
}
|
|
121
|
+
function isNullableSchema(schema) {
|
|
122
|
+
return schema.safeParse(null).success;
|
|
123
|
+
}
|
|
124
|
+
function isOptionalSchema(schema) {
|
|
125
|
+
return schema.safeParse(undefined).success;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
class $ZodRegistry {
|
|
129
|
+
constructor() {
|
|
130
|
+
this._map = new Map;
|
|
131
|
+
this._idmap = new Map;
|
|
132
|
+
}
|
|
133
|
+
add(schema, ..._meta) {
|
|
134
|
+
const meta = _meta[0];
|
|
135
|
+
this._map.set(schema, meta);
|
|
136
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
137
|
+
if (this._idmap.has(meta.id)) {
|
|
138
|
+
throw new Error(`ID ${meta.id} already exists in the registry`);
|
|
139
|
+
}
|
|
140
|
+
this._idmap.set(meta.id, schema);
|
|
141
|
+
}
|
|
142
|
+
return this;
|
|
143
|
+
}
|
|
144
|
+
clear() {
|
|
145
|
+
this._map = new Map;
|
|
146
|
+
this._idmap = new Map;
|
|
147
|
+
return this;
|
|
148
|
+
}
|
|
149
|
+
remove(schema) {
|
|
150
|
+
const meta = this._map.get(schema);
|
|
151
|
+
if (meta && typeof meta === "object" && "id" in meta) {
|
|
152
|
+
this._idmap.delete(meta.id);
|
|
153
|
+
}
|
|
154
|
+
this._map.delete(schema);
|
|
155
|
+
return this;
|
|
156
|
+
}
|
|
157
|
+
get(schema) {
|
|
158
|
+
const p = schema._zod.parent;
|
|
159
|
+
if (p) {
|
|
160
|
+
const pm = { ...this.get(p) ?? {} };
|
|
161
|
+
delete pm.id;
|
|
162
|
+
return { ...pm, ...this._map.get(schema) };
|
|
163
|
+
}
|
|
164
|
+
return this._map.get(schema);
|
|
165
|
+
}
|
|
166
|
+
has(schema) {
|
|
167
|
+
return this._map.has(schema);
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
function registry() {
|
|
171
|
+
return new $ZodRegistry;
|
|
172
|
+
}
|
|
173
|
+
function isEqual(x, y) {
|
|
174
|
+
if (x === null || x === undefined || y === null || y === undefined) {
|
|
175
|
+
return x === y;
|
|
176
|
+
}
|
|
177
|
+
if (x === y || x.valueOf() === y.valueOf()) {
|
|
178
|
+
return true;
|
|
179
|
+
}
|
|
180
|
+
if (Array.isArray(x)) {
|
|
181
|
+
if (!Array.isArray(y)) {
|
|
182
|
+
return false;
|
|
183
|
+
}
|
|
184
|
+
if (x.length !== y.length) {
|
|
185
|
+
return false;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
if (!(x instanceof Object) || !(y instanceof Object)) {
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
const keysX = Object.keys(x);
|
|
192
|
+
return Object.keys(y).every((keyY) => keysX.indexOf(keyY) !== -1) && keysX.every((key) => isEqual(x[key], y[key]));
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
class ObjectSet {
|
|
196
|
+
constructor() {
|
|
197
|
+
this.buckets = new Map;
|
|
198
|
+
}
|
|
199
|
+
put(value) {
|
|
200
|
+
const hashCode = this.hashCodeOf(value);
|
|
201
|
+
const itemsByCode = this.buckets.get(hashCode);
|
|
202
|
+
if (!itemsByCode) {
|
|
203
|
+
this.buckets.set(hashCode, [value]);
|
|
204
|
+
return;
|
|
205
|
+
}
|
|
206
|
+
const alreadyHasItem = itemsByCode.some((_) => isEqual(_, value));
|
|
207
|
+
if (!alreadyHasItem) {
|
|
208
|
+
itemsByCode.push(value);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
contains(value) {
|
|
212
|
+
const hashCode = this.hashCodeOf(value);
|
|
213
|
+
const itemsByCode = this.buckets.get(hashCode);
|
|
214
|
+
if (!itemsByCode) {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
return itemsByCode.some((_) => isEqual(_, value));
|
|
218
|
+
}
|
|
219
|
+
values() {
|
|
220
|
+
return [...this.buckets.values()].flat();
|
|
221
|
+
}
|
|
222
|
+
stats() {
|
|
223
|
+
let totalBuckets = 0;
|
|
224
|
+
let totalValues = 0;
|
|
225
|
+
let collisions = 0;
|
|
226
|
+
for (const bucket of this.buckets.values()) {
|
|
227
|
+
totalBuckets += 1;
|
|
228
|
+
totalValues += bucket.length;
|
|
229
|
+
if (bucket.length > 1) {
|
|
230
|
+
collisions += 1;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
const hashEffectiveness = totalBuckets / totalValues;
|
|
234
|
+
return { totalBuckets, collisions, totalValues, hashEffectiveness };
|
|
235
|
+
}
|
|
236
|
+
hashCodeOf(object) {
|
|
237
|
+
let hashCode = 0;
|
|
238
|
+
if (Array.isArray(object)) {
|
|
239
|
+
for (let i = 0;i < object.length; i++) {
|
|
240
|
+
hashCode ^= this.hashCodeOf(object[i]) * i;
|
|
241
|
+
}
|
|
242
|
+
return hashCode;
|
|
243
|
+
}
|
|
244
|
+
if (typeof object === "string") {
|
|
245
|
+
for (let i = 0;i < object.length; i++) {
|
|
246
|
+
hashCode ^= object.charCodeAt(i) * i;
|
|
247
|
+
}
|
|
248
|
+
return hashCode;
|
|
249
|
+
}
|
|
250
|
+
if (typeof object === "number") {
|
|
251
|
+
return object;
|
|
252
|
+
}
|
|
253
|
+
if (typeof object === "object") {
|
|
254
|
+
for (const [key, value] of Object.entries(object)) {
|
|
255
|
+
hashCode ^= this.hashCodeOf(key) + this.hashCodeOf(value !== null && value !== undefined ? value : "");
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
return hashCode;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
function isUndefined(value) {
|
|
262
|
+
return value === undefined;
|
|
263
|
+
}
|
|
264
|
+
function mapValues(object, mapper) {
|
|
265
|
+
const result = {};
|
|
266
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
267
|
+
result[key] = mapper(value);
|
|
268
|
+
});
|
|
269
|
+
return result;
|
|
270
|
+
}
|
|
271
|
+
function omit(object, keys) {
|
|
272
|
+
const result = {};
|
|
273
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
274
|
+
if (!keys.some((keyToOmit) => keyToOmit === key)) {
|
|
275
|
+
result[key] = value;
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
return result;
|
|
279
|
+
}
|
|
280
|
+
function omitBy(object, predicate) {
|
|
281
|
+
const result = {};
|
|
282
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
283
|
+
if (!predicate(value, key)) {
|
|
284
|
+
result[key] = value;
|
|
285
|
+
}
|
|
286
|
+
});
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
function compact(arr) {
|
|
290
|
+
return arr.filter((elem) => !isUndefined(elem));
|
|
291
|
+
}
|
|
292
|
+
function uniq(values) {
|
|
293
|
+
const set = new ObjectSet;
|
|
294
|
+
values.forEach((value) => set.put(value));
|
|
295
|
+
return [...set.values()];
|
|
296
|
+
}
|
|
297
|
+
function isString(val) {
|
|
298
|
+
return typeof val === "string";
|
|
299
|
+
}
|
|
300
|
+
function sortObjectByKeys(obj) {
|
|
301
|
+
return Object.fromEntries(Object.entries(obj).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)));
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
class Metadata {
|
|
305
|
+
static collectMetadata(schema, metadata) {
|
|
306
|
+
const currentMetadata = this.getMetadataFromRegistry(schema);
|
|
307
|
+
const _internal = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata._internal), metadata === null || metadata === undefined ? undefined : metadata._internal);
|
|
308
|
+
const param = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param), metadata === null || metadata === undefined ? undefined : metadata.param);
|
|
309
|
+
const totalMetadata = Object.assign(Object.assign(Object.assign(Object.assign({}, Object.keys(_internal).length > 0 ? { _internal } : {}), currentMetadata), metadata), Object.keys(param).length > 0 ? { param } : {});
|
|
310
|
+
if (isZodType(schema, [
|
|
311
|
+
"ZodOptional",
|
|
312
|
+
"ZodNullable",
|
|
313
|
+
"ZodDefault",
|
|
314
|
+
"ZodPrefault",
|
|
315
|
+
"ZodReadonly",
|
|
316
|
+
"ZodNonOptional"
|
|
317
|
+
]) && isAnyZodType(schema._zod.def.innerType)) {
|
|
318
|
+
return this.collectMetadata(schema._zod.def.innerType, totalMetadata);
|
|
319
|
+
}
|
|
320
|
+
if (isZodType(schema, "ZodPipe")) {
|
|
321
|
+
const inSchema = schema._zod.def.in;
|
|
322
|
+
const outSchema = schema._zod.def.out;
|
|
323
|
+
if (isZodType(inSchema, "ZodTransform") && isAnyZodType(outSchema)) {
|
|
324
|
+
return this.collectMetadata(outSchema, totalMetadata);
|
|
325
|
+
}
|
|
326
|
+
if (isAnyZodType(inSchema)) {
|
|
327
|
+
return this.collectMetadata(inSchema, totalMetadata);
|
|
328
|
+
}
|
|
329
|
+
}
|
|
330
|
+
return totalMetadata;
|
|
331
|
+
}
|
|
332
|
+
static getMetadata(zodSchema) {
|
|
333
|
+
return this.collectMetadata(zodSchema);
|
|
334
|
+
}
|
|
335
|
+
static getOpenApiMetadata(zodSchema) {
|
|
336
|
+
const metadata = this.collectMetadata(zodSchema);
|
|
337
|
+
const _a = metadata !== null && metadata !== undefined ? metadata : {}, { _internal } = _a, rest = __rest(_a, ["_internal"]);
|
|
338
|
+
return rest;
|
|
339
|
+
}
|
|
340
|
+
static getInternalMetadata(zodSchema) {
|
|
341
|
+
var _a;
|
|
342
|
+
return (_a = this.collectMetadata(zodSchema)) === null || _a === undefined ? undefined : _a._internal;
|
|
343
|
+
}
|
|
344
|
+
static getParamMetadata(zodSchema) {
|
|
345
|
+
const metadata = this.collectMetadata(zodSchema);
|
|
346
|
+
return Object.assign(Object.assign({}, metadata), {
|
|
347
|
+
param: Object.assign(Object.assign({}, (metadata === null || metadata === undefined ? undefined : metadata.description) ? { description: metadata.description } : {}), metadata === null || metadata === undefined ? undefined : metadata.param)
|
|
348
|
+
});
|
|
349
|
+
}
|
|
350
|
+
static buildSchemaMetadata(metadata) {
|
|
351
|
+
return omitBy(omit(metadata, ["param", "_internal"]), isUndefined);
|
|
352
|
+
}
|
|
353
|
+
static buildParameterMetadata(metadata) {
|
|
354
|
+
return omitBy(metadata, isUndefined);
|
|
355
|
+
}
|
|
356
|
+
static applySchemaMetadata(initialData, metadata) {
|
|
357
|
+
return omitBy(Object.assign(Object.assign({}, initialData), this.buildSchemaMetadata(metadata)), isUndefined);
|
|
358
|
+
}
|
|
359
|
+
static getRefId(zodSchema) {
|
|
360
|
+
var _a;
|
|
361
|
+
return (_a = this.getInternalMetadata(zodSchema)) === null || _a === undefined ? undefined : _a.refId;
|
|
362
|
+
}
|
|
363
|
+
static unwrapChained(schema) {
|
|
364
|
+
return this.unwrapUntil(schema);
|
|
365
|
+
}
|
|
366
|
+
static getDefaultValue(zodSchema) {
|
|
367
|
+
var _a;
|
|
368
|
+
const unwrapped = (_a = this.unwrapUntil(zodSchema, "ZodDefault")) !== null && _a !== undefined ? _a : this.unwrapUntil(zodSchema, "ZodPrefault");
|
|
369
|
+
return unwrapped === null || unwrapped === undefined ? undefined : unwrapped._zod.def.defaultValue;
|
|
370
|
+
}
|
|
371
|
+
static unwrapUntil(schema, typeName) {
|
|
372
|
+
if (typeName && isZodType(schema, typeName)) {
|
|
373
|
+
return schema;
|
|
374
|
+
}
|
|
375
|
+
if (isZodType(schema, [
|
|
376
|
+
"ZodOptional",
|
|
377
|
+
"ZodNullable",
|
|
378
|
+
"ZodDefault",
|
|
379
|
+
"ZodPrefault",
|
|
380
|
+
"ZodReadonly",
|
|
381
|
+
"ZodNonOptional"
|
|
382
|
+
]) && isAnyZodType(schema._zod.def.innerType)) {
|
|
383
|
+
return this.unwrapUntil(schema._zod.def.innerType, typeName);
|
|
384
|
+
}
|
|
385
|
+
if (isZodType(schema, "ZodPipe")) {
|
|
386
|
+
const inSchema = schema._zod.def.in;
|
|
387
|
+
const outSchema = schema._zod.def.out;
|
|
388
|
+
if (isZodType(inSchema, "ZodTransform") && isAnyZodType(outSchema)) {
|
|
389
|
+
return this.unwrapUntil(outSchema, typeName);
|
|
390
|
+
}
|
|
391
|
+
if (isAnyZodType(inSchema)) {
|
|
392
|
+
return this.unwrapUntil(inSchema, typeName);
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
return typeName ? undefined : schema;
|
|
396
|
+
}
|
|
397
|
+
static getMetadataFromInternalRegistry(zodSchema) {
|
|
398
|
+
return zodToOpenAPIRegistry.get(zodSchema);
|
|
399
|
+
}
|
|
400
|
+
static getMetadataFromRegistry(zodSchema) {
|
|
401
|
+
const internal = this.getMetadataFromInternalRegistry(zodSchema);
|
|
402
|
+
const general = zodSchema.meta();
|
|
403
|
+
if (!internal) {
|
|
404
|
+
return general;
|
|
405
|
+
}
|
|
406
|
+
const { _internal } = internal, rest = __rest(internal, ["_internal"]);
|
|
407
|
+
const _a = general !== null && general !== undefined ? general : {}, { id, title } = _a, restGeneral = __rest(_a, ["id", "title"]);
|
|
408
|
+
return Object.assign(Object.assign(Object.assign({ _internal: Object.assign(Object.assign({}, id ? { refId: id } : {}), _internal) }, rest), title ? { description: title } : {}), restGeneral);
|
|
409
|
+
}
|
|
410
|
+
static setMetadataInRegistry(zodSchema, metadata) {
|
|
411
|
+
zodToOpenAPIRegistry.add(zodSchema, metadata);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
function preserveMetadataFromModifier(zodSchema, modifier) {
|
|
415
|
+
const zodModifier = zodSchema[modifier];
|
|
416
|
+
if (typeof zodModifier !== "function") {
|
|
417
|
+
return;
|
|
418
|
+
}
|
|
419
|
+
zodSchema[modifier] = function(...args) {
|
|
420
|
+
const result = zodModifier.apply(this, args);
|
|
421
|
+
const meta = Metadata.getMetadataFromRegistry(this);
|
|
422
|
+
if (meta) {
|
|
423
|
+
Metadata.setMetadataInRegistry(result, meta);
|
|
424
|
+
}
|
|
425
|
+
return result;
|
|
426
|
+
};
|
|
427
|
+
}
|
|
428
|
+
function extendZodWithOpenApi(zod) {
|
|
429
|
+
if (typeof zod.ZodType.prototype.openapi !== "undefined") {
|
|
430
|
+
return;
|
|
431
|
+
}
|
|
432
|
+
zod.ZodType.prototype.openapi = function(...args) {
|
|
433
|
+
const { refId, metadata, options } = getOpenApiConfiguration(...args);
|
|
434
|
+
const _a = metadata !== null && metadata !== undefined ? metadata : {}, { param } = _a, restOfOpenApi = __rest(_a, ["param"]);
|
|
435
|
+
const allMetadata = Metadata.getMetadataFromRegistry(this);
|
|
436
|
+
const _b = allMetadata !== null && allMetadata !== undefined ? allMetadata : {}, { _internal: internalMetadata } = _b, currentMetadata = __rest(_b, ["_internal"]);
|
|
437
|
+
const _internal = Object.assign(Object.assign(Object.assign({}, internalMetadata), options), refId ? { refId } : undefined);
|
|
438
|
+
const resultMetadata = Object.assign(Object.assign(Object.assign({}, currentMetadata), restOfOpenApi), (currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param) || param ? {
|
|
439
|
+
param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param), param)
|
|
440
|
+
} : undefined);
|
|
441
|
+
const result = new this.constructor(this._def);
|
|
442
|
+
function setMetadata(schema) {
|
|
443
|
+
Metadata.setMetadataInRegistry(schema, Object.assign(Object.assign({}, Object.keys(_internal).length > 0 ? { _internal } : undefined), resultMetadata));
|
|
444
|
+
}
|
|
445
|
+
setMetadata(result);
|
|
446
|
+
if (isZodType(result, "ZodLazy")) {
|
|
447
|
+
setMetadata(this);
|
|
448
|
+
}
|
|
449
|
+
if (isZodType(result, "ZodObject")) {
|
|
450
|
+
const currentMetadata2 = Metadata.getMetadataFromRegistry(result);
|
|
451
|
+
const originalExtend = result.extend;
|
|
452
|
+
result.extend = function(...args2) {
|
|
453
|
+
const extendedResult = originalExtend.apply(result, args2);
|
|
454
|
+
const _a2 = currentMetadata2 !== null && currentMetadata2 !== undefined ? currentMetadata2 : {}, { _internal: _internal2 } = _a2, rest = __rest(_a2, ["_internal"]);
|
|
455
|
+
Metadata.setMetadataInRegistry(extendedResult, {
|
|
456
|
+
_internal: {
|
|
457
|
+
extendedFrom: (_internal2 === null || _internal2 === undefined ? undefined : _internal2.refId) ? { refId: _internal2.refId, schema: result } : _internal2 === null || _internal2 === undefined ? undefined : _internal2.extendedFrom
|
|
458
|
+
}
|
|
459
|
+
});
|
|
460
|
+
return extendedResult.openapi(rest);
|
|
461
|
+
};
|
|
462
|
+
preserveMetadataFromModifier(result, "catchall");
|
|
463
|
+
}
|
|
464
|
+
preserveMetadataFromModifier(result, "optional");
|
|
465
|
+
preserveMetadataFromModifier(result, "nullable");
|
|
466
|
+
preserveMetadataFromModifier(result, "default");
|
|
467
|
+
preserveMetadataFromModifier(result, "transform");
|
|
468
|
+
preserveMetadataFromModifier(result, "refine");
|
|
469
|
+
preserveMetadataFromModifier(result, "length");
|
|
470
|
+
preserveMetadataFromModifier(result, "min");
|
|
471
|
+
preserveMetadataFromModifier(result, "max");
|
|
472
|
+
const originalMeta = result.meta;
|
|
473
|
+
result.meta = function(...args2) {
|
|
474
|
+
const result2 = originalMeta.apply(this, args2);
|
|
475
|
+
if (args2[0]) {
|
|
476
|
+
const meta = Metadata.getMetadataFromInternalRegistry(this);
|
|
477
|
+
if (meta) {
|
|
478
|
+
Metadata.setMetadataInRegistry(result2, Object.assign(Object.assign({}, meta), args2[0]));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
return result2;
|
|
482
|
+
};
|
|
483
|
+
return result;
|
|
484
|
+
};
|
|
485
|
+
}
|
|
486
|
+
function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
|
|
487
|
+
if (typeof refOrOpenapi === "string") {
|
|
488
|
+
return {
|
|
489
|
+
refId: refOrOpenapi,
|
|
490
|
+
metadata: metadataOrOptions,
|
|
491
|
+
options
|
|
492
|
+
};
|
|
493
|
+
}
|
|
494
|
+
return {
|
|
495
|
+
refId: undefined,
|
|
496
|
+
metadata: refOrOpenapi,
|
|
497
|
+
options: metadataOrOptions
|
|
498
|
+
};
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
class OpenAPIRegistry {
|
|
502
|
+
constructor(parents) {
|
|
503
|
+
this.parents = parents;
|
|
504
|
+
this._definitions = [];
|
|
505
|
+
}
|
|
506
|
+
get definitions() {
|
|
507
|
+
var _a, _b;
|
|
508
|
+
const parentDefinitions = (_b = (_a = this.parents) === null || _a === undefined ? undefined : _a.flatMap((par) => par._definitions)) !== null && _b !== undefined ? _b : [];
|
|
509
|
+
return [...parentDefinitions, ...this._definitions];
|
|
510
|
+
}
|
|
511
|
+
register(refId, zodSchema) {
|
|
512
|
+
const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);
|
|
513
|
+
this._definitions.push({ type: "schema", schema: schemaWithRefId });
|
|
514
|
+
return schemaWithRefId;
|
|
515
|
+
}
|
|
516
|
+
registerParameter(refId, zodSchema) {
|
|
517
|
+
var _a, _b, _c;
|
|
518
|
+
const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);
|
|
519
|
+
const currentMetadata = (_a = Metadata.getOpenApiMetadata(schemaWithRefId)) !== null && _a !== undefined ? _a : {};
|
|
520
|
+
const schemaWithMetadata = schemaWithRefId.openapi(Object.assign(Object.assign({}, currentMetadata), { param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param), { name: (_c = (_b = currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param) === null || _b === undefined ? undefined : _b.name) !== null && _c !== undefined ? _c : refId }) }));
|
|
521
|
+
this._definitions.push({
|
|
522
|
+
type: "parameter",
|
|
523
|
+
schema: schemaWithMetadata
|
|
524
|
+
});
|
|
525
|
+
return schemaWithMetadata;
|
|
526
|
+
}
|
|
527
|
+
registerPath(route) {
|
|
528
|
+
this._definitions.push({
|
|
529
|
+
type: "route",
|
|
530
|
+
route
|
|
531
|
+
});
|
|
532
|
+
}
|
|
533
|
+
registerWebhook(webhook) {
|
|
534
|
+
this._definitions.push({
|
|
535
|
+
type: "webhook",
|
|
536
|
+
webhook
|
|
537
|
+
});
|
|
538
|
+
}
|
|
539
|
+
registerComponent(type, name, component) {
|
|
540
|
+
this._definitions.push({
|
|
541
|
+
type: "component",
|
|
542
|
+
componentType: type,
|
|
543
|
+
name,
|
|
544
|
+
component
|
|
545
|
+
});
|
|
546
|
+
return {
|
|
547
|
+
name,
|
|
548
|
+
ref: { $ref: `#/components/${type}/${name}` }
|
|
549
|
+
};
|
|
550
|
+
}
|
|
551
|
+
schemaWithRefId(refId, zodSchema) {
|
|
552
|
+
return zodSchema.openapi(refId);
|
|
553
|
+
}
|
|
554
|
+
}
|
|
555
|
+
|
|
556
|
+
class ZodToOpenAPIError {
|
|
557
|
+
constructor(message) {
|
|
558
|
+
this.message = message;
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
function enhanceMissingParametersError(action, paramsToAdd) {
|
|
562
|
+
try {
|
|
563
|
+
return action();
|
|
564
|
+
} catch (error) {
|
|
565
|
+
if (error instanceof MissingParameterDataError) {
|
|
566
|
+
throw new MissingParameterDataError(Object.assign(Object.assign({}, error.data), paramsToAdd));
|
|
567
|
+
}
|
|
568
|
+
throw error;
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
class ArrayTransformer {
|
|
573
|
+
transform(zodSchema, mapNullableType, mapItems) {
|
|
574
|
+
var _a, _b, _c, _d;
|
|
575
|
+
const itemType = zodSchema.def.element;
|
|
576
|
+
const minItems = (_b = (_a = zodSchema.def.checks) === null || _a === undefined ? undefined : _a.find((check) => check._zod.def.check === "min_length")) === null || _b === undefined ? undefined : _b._zod.def.minimum;
|
|
577
|
+
const maxItems = (_d = (_c = zodSchema.def.checks) === null || _c === undefined ? undefined : _c.find((check) => check._zod.def.check === "max_length")) === null || _d === undefined ? undefined : _d._zod.def.maximum;
|
|
578
|
+
return Object.assign(Object.assign({}, mapNullableType("array")), {
|
|
579
|
+
items: isAnyZodType(itemType) ? mapItems(itemType) : {},
|
|
580
|
+
minItems,
|
|
581
|
+
maxItems
|
|
582
|
+
});
|
|
583
|
+
}
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
class BigIntTransformer {
|
|
587
|
+
transform(mapNullableType) {
|
|
588
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), { pattern: `^d+$` });
|
|
589
|
+
}
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
class DiscriminatedUnionTransformer {
|
|
593
|
+
transform(zodSchema, isNullable, mapNullableOfArray, mapItem, generateSchemaRef) {
|
|
594
|
+
const options = [...zodSchema.def.options];
|
|
595
|
+
const optionSchema = options.map(mapItem);
|
|
596
|
+
if (isNullable) {
|
|
597
|
+
return {
|
|
598
|
+
oneOf: mapNullableOfArray(optionSchema, isNullable)
|
|
599
|
+
};
|
|
600
|
+
}
|
|
601
|
+
const discriminator = zodSchema._zod.def.discriminator;
|
|
602
|
+
if (!discriminator) {
|
|
603
|
+
console.error("No discriminator found for discriminated union", zodSchema);
|
|
604
|
+
return {
|
|
605
|
+
oneOf: optionSchema
|
|
606
|
+
};
|
|
607
|
+
}
|
|
608
|
+
return {
|
|
609
|
+
oneOf: optionSchema,
|
|
610
|
+
discriminator: this.mapDiscriminator(options, discriminator, generateSchemaRef)
|
|
611
|
+
};
|
|
612
|
+
}
|
|
613
|
+
mapDiscriminator(zodObjects, discriminator, generateSchemaRef) {
|
|
614
|
+
if (zodObjects.some((obj) => Metadata.getRefId(obj) === undefined)) {
|
|
615
|
+
return;
|
|
616
|
+
}
|
|
617
|
+
const mapping = {};
|
|
618
|
+
zodObjects.forEach((obj) => {
|
|
619
|
+
var _a;
|
|
620
|
+
const refId = Metadata.getRefId(obj);
|
|
621
|
+
const value = (_a = obj.def.shape) === null || _a === undefined ? undefined : _a[discriminator];
|
|
622
|
+
if (isZodType(value, "ZodEnum")) {
|
|
623
|
+
const keys = Object.values(value._zod.def.entries).filter(isString);
|
|
624
|
+
keys.forEach((enumValue) => {
|
|
625
|
+
mapping[enumValue] = generateSchemaRef(refId);
|
|
626
|
+
});
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const literalValue = value === null || value === undefined ? undefined : value.def.values[0];
|
|
630
|
+
if (typeof literalValue !== "string") {
|
|
631
|
+
throw new Error(`Discriminator ${discriminator} could not be found in one of the values of a discriminated union`);
|
|
632
|
+
}
|
|
633
|
+
mapping[literalValue] = generateSchemaRef(refId);
|
|
634
|
+
});
|
|
635
|
+
return {
|
|
636
|
+
propertyName: discriminator,
|
|
637
|
+
mapping
|
|
638
|
+
};
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
function enumInfo(enumObject) {
|
|
642
|
+
const keysExceptReverseMappings = Object.keys(enumObject).filter((key) => typeof enumObject[enumObject[key]] !== "number");
|
|
643
|
+
const values = keysExceptReverseMappings.map((key) => enumObject[key]);
|
|
644
|
+
const numericCount = values.filter((_) => typeof _ === "number").length;
|
|
645
|
+
const type = numericCount === 0 ? "string" : numericCount === values.length ? "numeric" : "mixed";
|
|
646
|
+
return { values, type };
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
class EnumTransformer {
|
|
650
|
+
transform(zodSchema, isNullable, mapNullableType) {
|
|
651
|
+
const { type, values } = enumInfo(zodSchema._zod.def.entries);
|
|
652
|
+
if (type === "mixed") {
|
|
653
|
+
throw new ZodToOpenAPIError("Enum has mixed string and number values, please specify the OpenAPI type manually");
|
|
654
|
+
}
|
|
655
|
+
return Object.assign(Object.assign({}, mapNullableType(type === "numeric" ? "integer" : "string")), { enum: isNullable ? [...values, null] : values });
|
|
656
|
+
}
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
class IntersectionTransformer {
|
|
660
|
+
transform(zodSchema, isNullable, mapNullableOfArray, mapItem) {
|
|
661
|
+
const subtypes = this.flattenIntersectionTypes(zodSchema);
|
|
662
|
+
const allOfSchema = {
|
|
663
|
+
allOf: subtypes.map(mapItem)
|
|
664
|
+
};
|
|
665
|
+
if (isNullable) {
|
|
666
|
+
return {
|
|
667
|
+
anyOf: mapNullableOfArray([allOfSchema], isNullable)
|
|
668
|
+
};
|
|
669
|
+
}
|
|
670
|
+
return allOfSchema;
|
|
671
|
+
}
|
|
672
|
+
flattenIntersectionTypes(schema) {
|
|
673
|
+
if (!isZodType(schema, "ZodIntersection")) {
|
|
674
|
+
return [schema];
|
|
675
|
+
}
|
|
676
|
+
const leftSubTypes = isAnyZodType(schema._zod.def.left) ? this.flattenIntersectionTypes(schema._zod.def.left) : [];
|
|
677
|
+
const rightSubTypes = isAnyZodType(schema._zod.def.right) ? this.flattenIntersectionTypes(schema._zod.def.right) : [];
|
|
678
|
+
return [...leftSubTypes, ...rightSubTypes];
|
|
679
|
+
}
|
|
680
|
+
}
|
|
681
|
+
|
|
682
|
+
class LiteralTransformer {
|
|
683
|
+
constructor() {
|
|
684
|
+
this.bigIntTransformer = new BigIntTransformer;
|
|
685
|
+
}
|
|
686
|
+
transform(zodSchema, mapNullableType) {
|
|
687
|
+
const type = typeof zodSchema.def.values[0];
|
|
688
|
+
if (type === "boolean" || type === "number" || type === "string" || type === "object") {
|
|
689
|
+
return Object.assign(Object.assign({}, mapNullableType(type)), { enum: [zodSchema.def.values[0]] });
|
|
690
|
+
}
|
|
691
|
+
if (type === "bigint") {
|
|
692
|
+
return this.bigIntTransformer.transform(mapNullableType);
|
|
693
|
+
}
|
|
694
|
+
return mapNullableType("null");
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
class NumberTransformer {
|
|
699
|
+
transform(zodSchema, mapNullableType, getNumberChecks) {
|
|
700
|
+
var _a;
|
|
701
|
+
return Object.assign(Object.assign(Object.assign({}, mapNullableType("number")), mapNullableType(zodSchema.format === "safeint" ? "integer" : "number")), getNumberChecks((_a = zodSchema.def.checks) !== null && _a !== undefined ? _a : []));
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
class ObjectTransformer {
|
|
706
|
+
transform(zodSchema, defaultValue, mapNullableType, mapItem) {
|
|
707
|
+
var _a;
|
|
708
|
+
const extendedFrom = (_a = Metadata.getInternalMetadata(zodSchema)) === null || _a === undefined ? undefined : _a.extendedFrom;
|
|
709
|
+
const required = this.requiredKeysOf(zodSchema);
|
|
710
|
+
const properties = mapValues(zodSchema.def.shape, mapItem);
|
|
711
|
+
if (!extendedFrom) {
|
|
712
|
+
return Object.assign(Object.assign(Object.assign(Object.assign({}, mapNullableType("object")), { properties, default: defaultValue }), required.length > 0 ? { required } : {}), this.generateAdditionalProperties(zodSchema, mapItem));
|
|
713
|
+
}
|
|
714
|
+
const parent = extendedFrom.schema;
|
|
715
|
+
mapItem(parent);
|
|
716
|
+
const keysRequiredByParent = this.requiredKeysOf(parent);
|
|
717
|
+
const propsOfParent = mapValues(parent === null || parent === undefined ? undefined : parent.def.shape, mapItem);
|
|
718
|
+
const propertiesToAdd = Object.fromEntries(Object.entries(properties).filter(([key, type]) => {
|
|
719
|
+
return !objectEquals(propsOfParent[key], type);
|
|
720
|
+
}));
|
|
721
|
+
const additionallyRequired = required.filter((prop) => !keysRequiredByParent.includes(prop));
|
|
722
|
+
const objectData = Object.assign(Object.assign(Object.assign(Object.assign({}, mapNullableType("object")), { default: defaultValue, properties: propertiesToAdd }), additionallyRequired.length > 0 ? { required: additionallyRequired } : {}), this.generateAdditionalProperties(zodSchema, mapItem));
|
|
723
|
+
return {
|
|
724
|
+
allOf: [
|
|
725
|
+
{ $ref: `#/components/schemas/${extendedFrom.refId}` },
|
|
726
|
+
objectData
|
|
727
|
+
]
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
generateAdditionalProperties(zodSchema, mapItem) {
|
|
731
|
+
const catchallSchema = zodSchema.def.catchall;
|
|
732
|
+
if (!catchallSchema) {
|
|
733
|
+
return {};
|
|
734
|
+
}
|
|
735
|
+
if (isZodType(catchallSchema, "ZodNever")) {
|
|
736
|
+
return { additionalProperties: false };
|
|
737
|
+
}
|
|
738
|
+
if (isAnyZodType(catchallSchema)) {
|
|
739
|
+
return { additionalProperties: mapItem(catchallSchema) };
|
|
740
|
+
}
|
|
741
|
+
return {};
|
|
742
|
+
}
|
|
743
|
+
requiredKeysOf(objectSchema) {
|
|
744
|
+
return Object.entries(objectSchema.def.shape).filter(([_key, type]) => !isOptionalSchema(type)).map(([key, _type]) => key);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
|
|
748
|
+
class RecordTransformer {
|
|
749
|
+
transform(zodSchema, mapNullableType, mapItem) {
|
|
750
|
+
const propertiesType = zodSchema.valueType;
|
|
751
|
+
const keyType = zodSchema.keyType;
|
|
752
|
+
const propertiesSchema = isAnyZodType(propertiesType) ? mapItem(propertiesType) : {};
|
|
753
|
+
if (isZodType(keyType, "ZodEnum")) {
|
|
754
|
+
const keys = Object.values(keyType._zod.def.entries).filter(isString);
|
|
755
|
+
const properties = keys.reduce((acc, curr) => Object.assign(Object.assign({}, acc), { [curr]: propertiesSchema }), {});
|
|
756
|
+
return Object.assign(Object.assign({}, mapNullableType("object")), { properties });
|
|
757
|
+
}
|
|
758
|
+
return Object.assign(Object.assign({}, mapNullableType("object")), { additionalProperties: propertiesSchema });
|
|
759
|
+
}
|
|
760
|
+
}
|
|
761
|
+
function isZodCheckLengthEquals(check) {
|
|
762
|
+
return check._zod.def.check === "length_equals";
|
|
763
|
+
}
|
|
764
|
+
function isZodCheckRegex(check) {
|
|
765
|
+
return check._zod.def.check === "string_format" && check._zod.def.format === "regex";
|
|
766
|
+
}
|
|
767
|
+
|
|
768
|
+
class StringTransformer {
|
|
769
|
+
transform(zodSchema, mapNullableType) {
|
|
770
|
+
var _a, _b, _c, _d;
|
|
771
|
+
const regexCheck = (_a = zodSchema.def.checks) === null || _a === undefined ? undefined : _a.find(isZodCheckRegex);
|
|
772
|
+
const pattern = regexCheck === null || regexCheck === undefined ? undefined : regexCheck._zod.def.pattern.toString().replace(/^\/|\/$/g, "");
|
|
773
|
+
const check = (_b = zodSchema.def.checks) === null || _b === undefined ? undefined : _b.find(isZodCheckLengthEquals);
|
|
774
|
+
const length = check === null || check === undefined ? undefined : check._zod.def.length;
|
|
775
|
+
const maxLength = Number.isFinite(zodSchema.minLength) ? (_c = zodSchema.minLength) !== null && _c !== undefined ? _c : undefined : undefined;
|
|
776
|
+
const minLength = Number.isFinite(zodSchema.maxLength) ? (_d = zodSchema.maxLength) !== null && _d !== undefined ? _d : undefined : undefined;
|
|
777
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), {
|
|
778
|
+
minLength: length !== null && length !== undefined ? length : maxLength,
|
|
779
|
+
maxLength: length !== null && length !== undefined ? length : minLength,
|
|
780
|
+
format: this.mapStringFormat(zodSchema),
|
|
781
|
+
pattern
|
|
782
|
+
});
|
|
783
|
+
}
|
|
784
|
+
mapStringFormat(zodString) {
|
|
785
|
+
if (zodString.format === "uuid")
|
|
786
|
+
return "uuid";
|
|
787
|
+
if (zodString.format === "email")
|
|
788
|
+
return "email";
|
|
789
|
+
if (zodString.format === "url")
|
|
790
|
+
return "uri";
|
|
791
|
+
if (zodString.format === "date")
|
|
792
|
+
return "date";
|
|
793
|
+
if (zodString.format === "datetime")
|
|
794
|
+
return "date-time";
|
|
795
|
+
if (zodString.format === "cuid")
|
|
796
|
+
return "cuid";
|
|
797
|
+
if (zodString.format === "cuid2")
|
|
798
|
+
return "cuid2";
|
|
799
|
+
if (zodString.format === "ulid")
|
|
800
|
+
return "ulid";
|
|
801
|
+
if (zodString.format === "ipv4")
|
|
802
|
+
return "ip";
|
|
803
|
+
if (zodString.format === "ipv6")
|
|
804
|
+
return "ip";
|
|
805
|
+
if (zodString.format === "emoji")
|
|
806
|
+
return "emoji";
|
|
807
|
+
return;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
|
|
811
|
+
class TupleTransformer {
|
|
812
|
+
constructor(versionSpecifics) {
|
|
813
|
+
this.versionSpecifics = versionSpecifics;
|
|
814
|
+
}
|
|
815
|
+
transform(zodSchema, mapNullableType, mapItem) {
|
|
816
|
+
const items = zodSchema._zod.def.items;
|
|
817
|
+
const schemas = items.map((item) => isAnyZodType(item) ? mapItem(item) : {});
|
|
818
|
+
return Object.assign(Object.assign({}, mapNullableType("array")), this.versionSpecifics.mapTupleItems(schemas));
|
|
819
|
+
}
|
|
820
|
+
}
|
|
821
|
+
|
|
822
|
+
class UnionTransformer {
|
|
823
|
+
constructor(options) {
|
|
824
|
+
this.options = options;
|
|
825
|
+
}
|
|
826
|
+
transform(zodSchema, mapNullableOfArray, mapItem) {
|
|
827
|
+
var _a, _b, _c;
|
|
828
|
+
const internalMetadata = Metadata.getInternalMetadata(zodSchema);
|
|
829
|
+
const preferredType = (_c = (_a = internalMetadata === null || internalMetadata === undefined ? undefined : internalMetadata.unionPreferredType) !== null && _a !== undefined ? _a : (_b = this.options) === null || _b === undefined ? undefined : _b.unionPreferredType) !== null && _c !== undefined ? _c : "anyOf";
|
|
830
|
+
const options = this.flattenUnionTypes(zodSchema);
|
|
831
|
+
const schemas = options.map((schema) => {
|
|
832
|
+
const optionToGenerate = this.unwrapNullable(schema);
|
|
833
|
+
return mapItem(optionToGenerate);
|
|
834
|
+
});
|
|
835
|
+
return {
|
|
836
|
+
[preferredType]: mapNullableOfArray(schemas)
|
|
837
|
+
};
|
|
838
|
+
}
|
|
839
|
+
flattenUnionTypes(schema) {
|
|
840
|
+
if (!isZodType(schema, "ZodUnion")) {
|
|
841
|
+
return [schema];
|
|
842
|
+
}
|
|
843
|
+
const options = schema.def.options;
|
|
844
|
+
return options.flatMap((option) => isAnyZodType(option) ? this.flattenUnionTypes(option) : []);
|
|
845
|
+
}
|
|
846
|
+
unwrapNullable(schema) {
|
|
847
|
+
if (isZodType(schema, "ZodNullable")) {
|
|
848
|
+
const unwrapped = schema.unwrap();
|
|
849
|
+
if (isAnyZodType(unwrapped)) {
|
|
850
|
+
return this.unwrapNullable(unwrapped);
|
|
851
|
+
}
|
|
852
|
+
}
|
|
853
|
+
return schema;
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
class DateTransformer {
|
|
858
|
+
transform(mapNullableType) {
|
|
859
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), { format: "date-time" });
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
|
|
863
|
+
class LazyTransformer {
|
|
864
|
+
transform(zodSchema, mapItem, mapNullableType, mapNullableRef) {
|
|
865
|
+
const result = mapItem(zodSchema._zod.def.getter());
|
|
866
|
+
return LazyTransformer.mapRecursive(result, mapNullableType, mapNullableRef);
|
|
867
|
+
}
|
|
868
|
+
static mapRecursive(schema, mapNullableType, mapNullableRef) {
|
|
869
|
+
if ("$ref" in schema) {
|
|
870
|
+
return mapNullableRef(schema);
|
|
871
|
+
}
|
|
872
|
+
if (schema.type) {
|
|
873
|
+
return Object.assign(Object.assign({}, schema), mapNullableType(schema.type));
|
|
874
|
+
}
|
|
875
|
+
return schema;
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
|
|
879
|
+
class TemplateLiteralTransformer {
|
|
880
|
+
transform(zodSchema, mapNullableType) {
|
|
881
|
+
const parts = zodSchema.def.parts;
|
|
882
|
+
const contentPattern = parts.map((part) => this.generatePattern(part)).join("");
|
|
883
|
+
return Object.assign(Object.assign({}, mapNullableType("string")), { pattern: `^${contentPattern}$` });
|
|
884
|
+
}
|
|
885
|
+
generatePattern(part) {
|
|
886
|
+
if (typeof part === "string" || typeof part === "number" || typeof part === "boolean" || typeof part === "bigint" || part === null || part === undefined) {
|
|
887
|
+
return this.escapeRegex(String(part));
|
|
888
|
+
}
|
|
889
|
+
if (isZodType(part, "ZodLiteral")) {
|
|
890
|
+
const value = part.def.values[0];
|
|
891
|
+
return this.escapeRegex(String(value));
|
|
892
|
+
}
|
|
893
|
+
if (isZodType(part, "ZodNumber")) {
|
|
894
|
+
return "[+-]?\\d+(\\.\\d+)?";
|
|
895
|
+
}
|
|
896
|
+
if (isZodType(part, "ZodBoolean")) {
|
|
897
|
+
return "(true|false)";
|
|
898
|
+
}
|
|
899
|
+
if (isZodType(part, "ZodEnum")) {
|
|
900
|
+
const { values } = enumInfo(part.def.entries);
|
|
901
|
+
return `(${values.map((v) => this.escapeRegex(String(v))).join("|")})`;
|
|
902
|
+
}
|
|
903
|
+
return ".*";
|
|
904
|
+
}
|
|
905
|
+
escapeRegex(str) {
|
|
906
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
907
|
+
}
|
|
908
|
+
}
|
|
909
|
+
|
|
910
|
+
class OpenApiTransformer {
|
|
911
|
+
constructor(versionSpecifics, options) {
|
|
912
|
+
this.versionSpecifics = versionSpecifics;
|
|
913
|
+
this.objectTransformer = new ObjectTransformer;
|
|
914
|
+
this.stringTransformer = new StringTransformer;
|
|
915
|
+
this.numberTransformer = new NumberTransformer;
|
|
916
|
+
this.bigIntTransformer = new BigIntTransformer;
|
|
917
|
+
this.dateTransformer = new DateTransformer;
|
|
918
|
+
this.lazyTransformer = new LazyTransformer;
|
|
919
|
+
this.literalTransformer = new LiteralTransformer;
|
|
920
|
+
this.templateLiteralTransformer = new TemplateLiteralTransformer;
|
|
921
|
+
this.enumTransformer = new EnumTransformer;
|
|
922
|
+
this.arrayTransformer = new ArrayTransformer;
|
|
923
|
+
this.discriminatedUnionTransformer = new DiscriminatedUnionTransformer;
|
|
924
|
+
this.intersectionTransformer = new IntersectionTransformer;
|
|
925
|
+
this.recordTransformer = new RecordTransformer;
|
|
926
|
+
this.tupleTransformer = new TupleTransformer(versionSpecifics);
|
|
927
|
+
this.unionTransformer = new UnionTransformer(options);
|
|
928
|
+
}
|
|
929
|
+
transform(zodSchema, isNullable, mapItem, generateSchemaRef, defaultValue) {
|
|
930
|
+
if (isZodType(zodSchema, "ZodNull")) {
|
|
931
|
+
return this.versionSpecifics.nullType;
|
|
932
|
+
}
|
|
933
|
+
if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) {
|
|
934
|
+
return this.versionSpecifics.mapNullableType(undefined, isNullable);
|
|
935
|
+
}
|
|
936
|
+
if (isZodType(zodSchema, "ZodObject")) {
|
|
937
|
+
return this.objectTransformer.transform(zodSchema, defaultValue, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
|
|
938
|
+
}
|
|
939
|
+
const schema = this.transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef);
|
|
940
|
+
return Object.assign(Object.assign({}, schema), { default: defaultValue });
|
|
941
|
+
}
|
|
942
|
+
transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef) {
|
|
943
|
+
if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) {
|
|
944
|
+
return this.versionSpecifics.mapNullableType(undefined, isNullable);
|
|
945
|
+
}
|
|
946
|
+
if (isZodType(zodSchema, "ZodString")) {
|
|
947
|
+
return this.stringTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
948
|
+
}
|
|
949
|
+
if (isZodType(zodSchema, "ZodNumber")) {
|
|
950
|
+
return this.numberTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (_) => this.versionSpecifics.getNumberChecks(_));
|
|
951
|
+
}
|
|
952
|
+
if (isZodType(zodSchema, "ZodBigInt")) {
|
|
953
|
+
return this.bigIntTransformer.transform((schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
954
|
+
}
|
|
955
|
+
if (isZodType(zodSchema, "ZodBoolean")) {
|
|
956
|
+
return this.versionSpecifics.mapNullableType("boolean", isNullable);
|
|
957
|
+
}
|
|
958
|
+
if (isZodType(zodSchema, "ZodLazy")) {
|
|
959
|
+
return this.lazyTransformer.transform(zodSchema, mapItem, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (schema) => this.versionSpecifics.mapNullableOfRef(schema, isNullable));
|
|
960
|
+
}
|
|
961
|
+
if (isZodType(zodSchema, "ZodLiteral")) {
|
|
962
|
+
return this.literalTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
963
|
+
}
|
|
964
|
+
if (isZodType(zodSchema, "ZodTemplateLiteral")) {
|
|
965
|
+
return this.templateLiteralTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
966
|
+
}
|
|
967
|
+
if (isZodType(zodSchema, "ZodEnum")) {
|
|
968
|
+
return this.enumTransformer.transform(zodSchema, isNullable, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
|
|
969
|
+
}
|
|
970
|
+
if (isZodType(zodSchema, "ZodArray")) {
|
|
971
|
+
return this.arrayTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
|
|
972
|
+
}
|
|
973
|
+
if (isZodType(zodSchema, "ZodTuple")) {
|
|
974
|
+
return this.tupleTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
|
|
975
|
+
}
|
|
976
|
+
if (isZodType(zodSchema, "ZodDiscriminatedUnion")) {
|
|
977
|
+
return this.discriminatedUnionTransformer.transform(zodSchema, isNullable, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem, generateSchemaRef);
|
|
978
|
+
}
|
|
979
|
+
if (isZodType(zodSchema, "ZodUnion")) {
|
|
980
|
+
return this.unionTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);
|
|
981
|
+
}
|
|
982
|
+
if (isZodType(zodSchema, "ZodIntersection")) {
|
|
983
|
+
return this.intersectionTransformer.transform(zodSchema, isNullable, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);
|
|
984
|
+
}
|
|
985
|
+
if (isZodType(zodSchema, "ZodRecord")) {
|
|
986
|
+
return this.recordTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
|
|
987
|
+
}
|
|
988
|
+
if (isZodType(zodSchema, "ZodDate")) {
|
|
989
|
+
return this.dateTransformer.transform((_) => this.versionSpecifics.mapNullableType(_, isNullable));
|
|
990
|
+
}
|
|
991
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
992
|
+
throw new UnknownZodTypeError({
|
|
993
|
+
currentSchema: zodSchema.def,
|
|
994
|
+
schemaName: refId
|
|
995
|
+
});
|
|
996
|
+
}
|
|
997
|
+
}
|
|
998
|
+
|
|
999
|
+
class OpenAPIGenerator {
|
|
1000
|
+
constructor(definitions, versionSpecifics, options) {
|
|
1001
|
+
this.definitions = definitions;
|
|
1002
|
+
this.versionSpecifics = versionSpecifics;
|
|
1003
|
+
this.options = options;
|
|
1004
|
+
this.schemaRefs = {};
|
|
1005
|
+
this.paramRefs = {};
|
|
1006
|
+
this.pathRefs = {};
|
|
1007
|
+
this.rawComponents = [];
|
|
1008
|
+
this.openApiTransformer = new OpenApiTransformer(versionSpecifics, options);
|
|
1009
|
+
this.sortDefinitions();
|
|
1010
|
+
}
|
|
1011
|
+
generateDocumentData() {
|
|
1012
|
+
this.definitions.forEach((definition) => this.generateSingle(definition));
|
|
1013
|
+
return {
|
|
1014
|
+
components: this.buildComponents(),
|
|
1015
|
+
paths: this.pathRefs
|
|
1016
|
+
};
|
|
1017
|
+
}
|
|
1018
|
+
generateComponents() {
|
|
1019
|
+
this.definitions.forEach((definition) => this.generateSingle(definition));
|
|
1020
|
+
return {
|
|
1021
|
+
components: this.buildComponents()
|
|
1022
|
+
};
|
|
1023
|
+
}
|
|
1024
|
+
buildComponents() {
|
|
1025
|
+
var _a, _b, _c, _d;
|
|
1026
|
+
const rawComponents = {};
|
|
1027
|
+
this.rawComponents.forEach(({ componentType, name, component }) => {
|
|
1028
|
+
var _a2;
|
|
1029
|
+
(_a2 = rawComponents[componentType]) !== null && _a2 !== undefined || (rawComponents[componentType] = {});
|
|
1030
|
+
rawComponents[componentType][name] = component;
|
|
1031
|
+
});
|
|
1032
|
+
const allSchemas = Object.assign(Object.assign({}, (_a = rawComponents.schemas) !== null && _a !== undefined ? _a : {}), this.filteredSchemaRefs);
|
|
1033
|
+
const schemas = ((_b = this.options) === null || _b === undefined ? undefined : _b.sortComponents) === "alphabetically" ? sortObjectByKeys(allSchemas) : allSchemas;
|
|
1034
|
+
const allParameters = Object.assign(Object.assign({}, (_c = rawComponents.parameters) !== null && _c !== undefined ? _c : {}), this.paramRefs);
|
|
1035
|
+
const parameters = ((_d = this.options) === null || _d === undefined ? undefined : _d.sortComponents) === "alphabetically" ? sortObjectByKeys(allParameters) : allParameters;
|
|
1036
|
+
return Object.assign(Object.assign({}, rawComponents), { schemas, parameters });
|
|
1037
|
+
}
|
|
1038
|
+
isNotPendingRefEntry(entry) {
|
|
1039
|
+
return entry[1] !== "pending";
|
|
1040
|
+
}
|
|
1041
|
+
get filteredSchemaRefs() {
|
|
1042
|
+
const filtered = Object.entries(this.schemaRefs).filter(this.isNotPendingRefEntry);
|
|
1043
|
+
return Object.fromEntries(filtered);
|
|
1044
|
+
}
|
|
1045
|
+
sortDefinitions() {
|
|
1046
|
+
const generationOrder = [
|
|
1047
|
+
"schema",
|
|
1048
|
+
"parameter",
|
|
1049
|
+
"component",
|
|
1050
|
+
"route"
|
|
1051
|
+
];
|
|
1052
|
+
this.definitions.sort((left, right) => {
|
|
1053
|
+
if (!("type" in left)) {
|
|
1054
|
+
if (!("type" in right)) {
|
|
1055
|
+
return 0;
|
|
1056
|
+
}
|
|
1057
|
+
return -1;
|
|
1058
|
+
}
|
|
1059
|
+
if (!("type" in right)) {
|
|
1060
|
+
return 1;
|
|
1061
|
+
}
|
|
1062
|
+
const leftIndex = generationOrder.findIndex((type) => type === left.type);
|
|
1063
|
+
const rightIndex = generationOrder.findIndex((type) => type === right.type);
|
|
1064
|
+
return leftIndex - rightIndex;
|
|
1065
|
+
});
|
|
1066
|
+
}
|
|
1067
|
+
generateSingle(definition) {
|
|
1068
|
+
if (!("type" in definition)) {
|
|
1069
|
+
this.generateSchemaWithRef(definition);
|
|
1070
|
+
return;
|
|
1071
|
+
}
|
|
1072
|
+
switch (definition.type) {
|
|
1073
|
+
case "parameter":
|
|
1074
|
+
this.generateParameterDefinition(definition.schema);
|
|
1075
|
+
return;
|
|
1076
|
+
case "schema":
|
|
1077
|
+
this.generateSchemaWithRef(definition.schema);
|
|
1078
|
+
return;
|
|
1079
|
+
case "route":
|
|
1080
|
+
this.generateSingleRoute(definition.route);
|
|
1081
|
+
return;
|
|
1082
|
+
case "component":
|
|
1083
|
+
this.rawComponents.push(definition);
|
|
1084
|
+
return;
|
|
1085
|
+
}
|
|
1086
|
+
}
|
|
1087
|
+
generateParameterDefinition(zodSchema) {
|
|
1088
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
1089
|
+
const result = this.generateParameter(zodSchema);
|
|
1090
|
+
if (refId) {
|
|
1091
|
+
this.paramRefs[refId] = result;
|
|
1092
|
+
}
|
|
1093
|
+
return result;
|
|
1094
|
+
}
|
|
1095
|
+
getParameterRef(schema, external) {
|
|
1096
|
+
const metadata = Metadata.getOpenApiMetadata(schema);
|
|
1097
|
+
const internalMetadata = Metadata.getInternalMetadata(schema);
|
|
1098
|
+
const parameterMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
|
|
1099
|
+
const existingRef = (internalMetadata === null || internalMetadata === undefined ? undefined : internalMetadata.refId) ? this.paramRefs[internalMetadata.refId] : undefined;
|
|
1100
|
+
if (!(internalMetadata === null || internalMetadata === undefined ? undefined : internalMetadata.refId) || !existingRef) {
|
|
1101
|
+
return;
|
|
1102
|
+
}
|
|
1103
|
+
if (parameterMetadata && existingRef.in !== parameterMetadata.in || (external === null || external === undefined ? undefined : external.in) && existingRef.in !== external.in) {
|
|
1104
|
+
throw new ConflictError(`Conflicting location for parameter ${existingRef.name}`, {
|
|
1105
|
+
key: "in",
|
|
1106
|
+
values: compact([
|
|
1107
|
+
existingRef.in,
|
|
1108
|
+
external === null || external === undefined ? undefined : external.in,
|
|
1109
|
+
parameterMetadata === null || parameterMetadata === undefined ? undefined : parameterMetadata.in
|
|
1110
|
+
])
|
|
1111
|
+
});
|
|
1112
|
+
}
|
|
1113
|
+
if (parameterMetadata && existingRef.name !== parameterMetadata.name || (external === null || external === undefined ? undefined : external.name) && existingRef.name !== (external === null || external === undefined ? undefined : external.name)) {
|
|
1114
|
+
throw new ConflictError(`Conflicting names for parameter`, {
|
|
1115
|
+
key: "name",
|
|
1116
|
+
values: compact([
|
|
1117
|
+
existingRef.name,
|
|
1118
|
+
external === null || external === undefined ? undefined : external.name,
|
|
1119
|
+
parameterMetadata === null || parameterMetadata === undefined ? undefined : parameterMetadata.name
|
|
1120
|
+
])
|
|
1121
|
+
});
|
|
1122
|
+
}
|
|
1123
|
+
return {
|
|
1124
|
+
$ref: `#/components/parameters/${internalMetadata.refId}`
|
|
1125
|
+
};
|
|
1126
|
+
}
|
|
1127
|
+
generateInlineParameters(zodSchema, location) {
|
|
1128
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
1129
|
+
const parameterMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
|
|
1130
|
+
const referencedSchema = this.getParameterRef(zodSchema, { in: location });
|
|
1131
|
+
if (referencedSchema) {
|
|
1132
|
+
return [referencedSchema];
|
|
1133
|
+
}
|
|
1134
|
+
if (isZodType(zodSchema, "ZodObject")) {
|
|
1135
|
+
const propTypes = zodSchema.def.shape;
|
|
1136
|
+
const parameters = Object.entries(propTypes).map(([key, schema]) => {
|
|
1137
|
+
var _a;
|
|
1138
|
+
const innerMetadata = Metadata.getOpenApiMetadata(schema);
|
|
1139
|
+
const referencedSchema2 = this.getParameterRef(schema, {
|
|
1140
|
+
in: location,
|
|
1141
|
+
name: key
|
|
1142
|
+
});
|
|
1143
|
+
if (referencedSchema2) {
|
|
1144
|
+
return referencedSchema2;
|
|
1145
|
+
}
|
|
1146
|
+
const innerParameterMetadata = innerMetadata === null || innerMetadata === undefined ? undefined : innerMetadata.param;
|
|
1147
|
+
if ((innerParameterMetadata === null || innerParameterMetadata === undefined ? undefined : innerParameterMetadata.name) && innerParameterMetadata.name !== key) {
|
|
1148
|
+
throw new ConflictError(`Conflicting names for parameter`, {
|
|
1149
|
+
key: "name",
|
|
1150
|
+
values: [key, innerParameterMetadata.name]
|
|
1151
|
+
});
|
|
1152
|
+
}
|
|
1153
|
+
if ((innerParameterMetadata === null || innerParameterMetadata === undefined ? undefined : innerParameterMetadata.in) && innerParameterMetadata.in !== location) {
|
|
1154
|
+
throw new ConflictError(`Conflicting location for parameter ${(_a = innerParameterMetadata.name) !== null && _a !== undefined ? _a : key}`, {
|
|
1155
|
+
key: "in",
|
|
1156
|
+
values: [location, innerParameterMetadata.in]
|
|
1157
|
+
});
|
|
1158
|
+
}
|
|
1159
|
+
return this.generateParameter(schema, { name: key, in: location });
|
|
1160
|
+
});
|
|
1161
|
+
return parameters;
|
|
1162
|
+
}
|
|
1163
|
+
if ((parameterMetadata === null || parameterMetadata === undefined ? undefined : parameterMetadata.in) && parameterMetadata.in !== location) {
|
|
1164
|
+
throw new ConflictError(`Conflicting location for parameter ${parameterMetadata.name}`, {
|
|
1165
|
+
key: "in",
|
|
1166
|
+
values: [location, parameterMetadata.in]
|
|
1167
|
+
});
|
|
1168
|
+
}
|
|
1169
|
+
return [this.generateParameter(zodSchema, { in: location })];
|
|
1170
|
+
}
|
|
1171
|
+
generateSimpleParameter(zodSchema, externalParamMetadata) {
|
|
1172
|
+
const metadata = Metadata.getParamMetadata(zodSchema);
|
|
1173
|
+
const paramMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
|
|
1174
|
+
const mergedParamMetadata = Object.assign(Object.assign({}, paramMetadata), externalParamMetadata);
|
|
1175
|
+
const required = !isOptionalSchema(zodSchema) && !isNullableSchema(zodSchema);
|
|
1176
|
+
const schema = this.generateSchemaWithRef(zodSchema);
|
|
1177
|
+
return Object.assign({
|
|
1178
|
+
schema,
|
|
1179
|
+
required
|
|
1180
|
+
}, Object.keys(mergedParamMetadata).length > 0 ? Metadata.buildParameterMetadata(mergedParamMetadata) : {});
|
|
1181
|
+
}
|
|
1182
|
+
generateParameter(zodSchema, externalParamMetadata) {
|
|
1183
|
+
var _a, _b;
|
|
1184
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
1185
|
+
const paramMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
|
|
1186
|
+
const paramName = (_a = externalParamMetadata === null || externalParamMetadata === undefined ? undefined : externalParamMetadata.name) !== null && _a !== undefined ? _a : paramMetadata === null || paramMetadata === undefined ? undefined : paramMetadata.name;
|
|
1187
|
+
const paramLocation = (_b = externalParamMetadata === null || externalParamMetadata === undefined ? undefined : externalParamMetadata.in) !== null && _b !== undefined ? _b : paramMetadata === null || paramMetadata === undefined ? undefined : paramMetadata.in;
|
|
1188
|
+
if (!paramName) {
|
|
1189
|
+
throw new MissingParameterDataError({ missingField: "name" });
|
|
1190
|
+
}
|
|
1191
|
+
if (!paramLocation) {
|
|
1192
|
+
throw new MissingParameterDataError({
|
|
1193
|
+
missingField: "in",
|
|
1194
|
+
paramName
|
|
1195
|
+
});
|
|
1196
|
+
}
|
|
1197
|
+
const baseParameter = this.generateSimpleParameter(zodSchema, externalParamMetadata);
|
|
1198
|
+
return Object.assign(Object.assign({}, baseParameter), { in: paramLocation, name: paramName });
|
|
1199
|
+
}
|
|
1200
|
+
generateSchemaWithMetadata(zodSchema) {
|
|
1201
|
+
const innerSchema = Metadata.unwrapChained(zodSchema);
|
|
1202
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
1203
|
+
const defaultValue = Metadata.getDefaultValue(zodSchema);
|
|
1204
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
1205
|
+
if (refId && typeof this.schemaRefs[refId] === "object") {
|
|
1206
|
+
return this.schemaRefs[refId];
|
|
1207
|
+
}
|
|
1208
|
+
if (refId && this.schemaRefs[refId] === "pending") {
|
|
1209
|
+
const refSchema = { $ref: this.generateSchemaRef(refId) };
|
|
1210
|
+
return this.versionSpecifics.mapNullableOfRef(refSchema, isNullableSchema(zodSchema));
|
|
1211
|
+
}
|
|
1212
|
+
if (refId && !this.schemaRefs[refId]) {
|
|
1213
|
+
this.schemaRefs[refId] = "pending";
|
|
1214
|
+
}
|
|
1215
|
+
const result = (metadata === null || metadata === undefined ? undefined : metadata.type) ? { type: metadata.type } : this.toOpenAPISchema(innerSchema, isNullableSchema(zodSchema), defaultValue);
|
|
1216
|
+
return metadata ? Metadata.applySchemaMetadata(result, metadata) : omitBy(result, isUndefined);
|
|
1217
|
+
}
|
|
1218
|
+
constructReferencedOpenAPISchema(zodSchema) {
|
|
1219
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
1220
|
+
const innerSchema = Metadata.unwrapChained(zodSchema);
|
|
1221
|
+
const defaultValue = Metadata.getDefaultValue(zodSchema);
|
|
1222
|
+
const isNullable = isNullableSchema(zodSchema);
|
|
1223
|
+
if (metadata === null || metadata === undefined ? undefined : metadata.type) {
|
|
1224
|
+
return this.versionSpecifics.mapNullableType(metadata.type, isNullable);
|
|
1225
|
+
}
|
|
1226
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
1227
|
+
if (refId && typeof this.schemaRefs[refId] === "object") {
|
|
1228
|
+
return LazyTransformer.mapRecursive(this.schemaRefs[refId], (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (schema) => this.versionSpecifics.mapNullableOfRef(schema, isNullable));
|
|
1229
|
+
}
|
|
1230
|
+
if (refId && this.schemaRefs[refId] === "pending") {
|
|
1231
|
+
const refSchema = { $ref: this.generateSchemaRef(refId) };
|
|
1232
|
+
return this.versionSpecifics.mapNullableOfRef(refSchema, isNullable);
|
|
1233
|
+
}
|
|
1234
|
+
if (refId && !this.schemaRefs[refId]) {
|
|
1235
|
+
this.schemaRefs[refId] = "pending";
|
|
1236
|
+
}
|
|
1237
|
+
return this.toOpenAPISchema(innerSchema, isNullable, defaultValue);
|
|
1238
|
+
}
|
|
1239
|
+
generateSimpleSchema(zodSchema) {
|
|
1240
|
+
const metadata = Metadata.getOpenApiMetadata(zodSchema);
|
|
1241
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
1242
|
+
if (!refId || !this.schemaRefs[refId]) {
|
|
1243
|
+
return this.generateSchemaWithMetadata(zodSchema);
|
|
1244
|
+
}
|
|
1245
|
+
const schemaRef = this.schemaRefs[refId];
|
|
1246
|
+
const referenceObject = {
|
|
1247
|
+
$ref: this.generateSchemaRef(refId)
|
|
1248
|
+
};
|
|
1249
|
+
if (this.schemaRefs[refId] === "pending") {
|
|
1250
|
+
return this.versionSpecifics.mapNullableOfRef(referenceObject, isNullableSchema(zodSchema));
|
|
1251
|
+
}
|
|
1252
|
+
const newMetadata = omitBy(Metadata.buildSchemaMetadata(metadata !== null && metadata !== undefined ? metadata : {}), (value, key) => value === undefined || objectEquals(value, schemaRef[key]));
|
|
1253
|
+
if (newMetadata.type) {
|
|
1254
|
+
return {
|
|
1255
|
+
allOf: [referenceObject, newMetadata]
|
|
1256
|
+
};
|
|
1257
|
+
}
|
|
1258
|
+
const newSchemaMetadata = omitBy(this.constructReferencedOpenAPISchema(zodSchema), (value, key) => value === undefined || objectEquals(value, schemaRef[key]));
|
|
1259
|
+
const appliedMetadata = Metadata.applySchemaMetadata(newSchemaMetadata, newMetadata);
|
|
1260
|
+
if (Object.keys(appliedMetadata).length > 0) {
|
|
1261
|
+
return {
|
|
1262
|
+
allOf: [referenceObject, appliedMetadata]
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
return referenceObject;
|
|
1266
|
+
}
|
|
1267
|
+
generateSchemaWithRef(zodSchema) {
|
|
1268
|
+
const refId = Metadata.getRefId(zodSchema);
|
|
1269
|
+
if (refId && !this.schemaRefs[refId]) {
|
|
1270
|
+
this.schemaRefs[refId] = this.generateSimpleSchema(zodSchema);
|
|
1271
|
+
return { $ref: this.generateSchemaRef(refId) };
|
|
1272
|
+
}
|
|
1273
|
+
return this.generateSimpleSchema(zodSchema);
|
|
1274
|
+
}
|
|
1275
|
+
generateSchemaRef(refId) {
|
|
1276
|
+
return `#/components/schemas/${refId}`;
|
|
1277
|
+
}
|
|
1278
|
+
getRequestBody(requestBody) {
|
|
1279
|
+
if (!requestBody) {
|
|
1280
|
+
return;
|
|
1281
|
+
}
|
|
1282
|
+
const { content } = requestBody, rest = __rest(requestBody, ["content"]);
|
|
1283
|
+
const requestBodyContent = this.getBodyContent(content);
|
|
1284
|
+
return Object.assign(Object.assign({}, rest), { content: requestBodyContent });
|
|
1285
|
+
}
|
|
1286
|
+
getParameters(request) {
|
|
1287
|
+
if (!request) {
|
|
1288
|
+
return [];
|
|
1289
|
+
}
|
|
1290
|
+
const { headers } = request;
|
|
1291
|
+
const query = this.cleanParameter(request.query);
|
|
1292
|
+
const params = this.cleanParameter(request.params);
|
|
1293
|
+
const cookies = this.cleanParameter(request.cookies);
|
|
1294
|
+
const queryParameters = enhanceMissingParametersError(() => query ? this.generateInlineParameters(query, "query") : [], { location: "query" });
|
|
1295
|
+
const pathParameters = enhanceMissingParametersError(() => params ? this.generateInlineParameters(params, "path") : [], { location: "path" });
|
|
1296
|
+
const cookieParameters = enhanceMissingParametersError(() => cookies ? this.generateInlineParameters(cookies, "cookie") : [], { location: "cookie" });
|
|
1297
|
+
const headerParameters = enhanceMissingParametersError(() => {
|
|
1298
|
+
if (Array.isArray(headers)) {
|
|
1299
|
+
return headers.flatMap((header) => this.generateInlineParameters(header, "header"));
|
|
1300
|
+
}
|
|
1301
|
+
const cleanHeaders = this.cleanParameter(headers);
|
|
1302
|
+
return cleanHeaders ? this.generateInlineParameters(cleanHeaders, "header") : [];
|
|
1303
|
+
}, { location: "header" });
|
|
1304
|
+
return [
|
|
1305
|
+
...pathParameters,
|
|
1306
|
+
...queryParameters,
|
|
1307
|
+
...headerParameters,
|
|
1308
|
+
...cookieParameters
|
|
1309
|
+
];
|
|
1310
|
+
}
|
|
1311
|
+
cleanParameter(schema) {
|
|
1312
|
+
if (!schema) {
|
|
1313
|
+
return;
|
|
1314
|
+
}
|
|
1315
|
+
if (isZodType(schema, "ZodPipe")) {
|
|
1316
|
+
const inSchema = schema._zod.def.in;
|
|
1317
|
+
const outSchema = schema._zod.def.out;
|
|
1318
|
+
if (isZodType(inSchema, "ZodObject")) {
|
|
1319
|
+
return this.cleanParameter(inSchema);
|
|
1320
|
+
}
|
|
1321
|
+
if (isZodType(outSchema, "ZodObject")) {
|
|
1322
|
+
return this.cleanParameter(outSchema);
|
|
1323
|
+
}
|
|
1324
|
+
return;
|
|
1325
|
+
}
|
|
1326
|
+
return schema;
|
|
1327
|
+
}
|
|
1328
|
+
generatePath(route) {
|
|
1329
|
+
const { method, path, request, responses } = route, pathItemConfig = __rest(route, ["method", "path", "request", "responses"]);
|
|
1330
|
+
const generatedResponses = mapValues(responses, (response) => {
|
|
1331
|
+
return this.getResponse(response);
|
|
1332
|
+
});
|
|
1333
|
+
const parameters = enhanceMissingParametersError(() => this.getParameters(request), { route: `${method} ${path}` });
|
|
1334
|
+
const requestBody = this.getRequestBody(request === null || request === undefined ? undefined : request.body);
|
|
1335
|
+
const routeDoc = {
|
|
1336
|
+
[method]: Object.assign(Object.assign(Object.assign(Object.assign({}, pathItemConfig), parameters.length > 0 ? {
|
|
1337
|
+
parameters: [...pathItemConfig.parameters || [], ...parameters]
|
|
1338
|
+
} : {}), requestBody ? { requestBody } : {}), { responses: generatedResponses })
|
|
1339
|
+
};
|
|
1340
|
+
return routeDoc;
|
|
1341
|
+
}
|
|
1342
|
+
generateSingleRoute(route) {
|
|
1343
|
+
const routeDoc = this.generatePath(route);
|
|
1344
|
+
this.pathRefs[route.path] = Object.assign(Object.assign({}, this.pathRefs[route.path]), routeDoc);
|
|
1345
|
+
return routeDoc;
|
|
1346
|
+
}
|
|
1347
|
+
getResponse(response) {
|
|
1348
|
+
if (this.isReferenceObject(response)) {
|
|
1349
|
+
return response;
|
|
1350
|
+
}
|
|
1351
|
+
const { content, headers } = response, rest = __rest(response, ["content", "headers"]);
|
|
1352
|
+
const responseContent = content ? { content: this.getBodyContent(content) } : {};
|
|
1353
|
+
if (!headers) {
|
|
1354
|
+
return Object.assign(Object.assign({}, rest), responseContent);
|
|
1355
|
+
}
|
|
1356
|
+
const responseHeaders = isZodType(headers, "ZodObject") ? this.getResponseHeaders(headers) : headers;
|
|
1357
|
+
return Object.assign(Object.assign(Object.assign({}, rest), { headers: responseHeaders }), responseContent);
|
|
1358
|
+
}
|
|
1359
|
+
isReferenceObject(schema) {
|
|
1360
|
+
return "$ref" in schema;
|
|
1361
|
+
}
|
|
1362
|
+
getResponseHeaders(headers) {
|
|
1363
|
+
const schemaShape = headers.def.shape;
|
|
1364
|
+
const responseHeaders = mapValues(schemaShape, (_) => this.generateSimpleParameter(_));
|
|
1365
|
+
return responseHeaders;
|
|
1366
|
+
}
|
|
1367
|
+
getBodyContent(content) {
|
|
1368
|
+
return mapValues(content, (config) => {
|
|
1369
|
+
if (!config || !isAnyZodType(config.schema)) {
|
|
1370
|
+
return config;
|
|
1371
|
+
}
|
|
1372
|
+
const { schema: configSchema } = config, rest = __rest(config, ["schema"]);
|
|
1373
|
+
const schema = this.generateSchemaWithRef(configSchema);
|
|
1374
|
+
return Object.assign({ schema }, rest);
|
|
1375
|
+
});
|
|
1376
|
+
}
|
|
1377
|
+
toOpenAPISchema(zodSchema, isNullable, defaultValue) {
|
|
1378
|
+
const result = this.openApiTransformer.transform(zodSchema, isNullable, (_) => this.generateSchemaWithRef(_), (_) => this.generateSchemaRef(_), defaultValue);
|
|
1379
|
+
return result;
|
|
1380
|
+
}
|
|
1381
|
+
}
|
|
1382
|
+
|
|
1383
|
+
class OpenApiGeneratorV31Specifics {
|
|
1384
|
+
get nullType() {
|
|
1385
|
+
return { type: "null" };
|
|
1386
|
+
}
|
|
1387
|
+
mapNullableOfArray(objects, isNullable) {
|
|
1388
|
+
if (isNullable && !objects.some((object) => objectEquals(object, this.nullType))) {
|
|
1389
|
+
return [...objects, this.nullType];
|
|
1390
|
+
}
|
|
1391
|
+
return objects;
|
|
1392
|
+
}
|
|
1393
|
+
mapNullableType(type, isNullable) {
|
|
1394
|
+
if (!type) {
|
|
1395
|
+
return {};
|
|
1396
|
+
}
|
|
1397
|
+
if (isNullable) {
|
|
1398
|
+
const typeArray = Array.isArray(type) ? type : [type];
|
|
1399
|
+
const nullableType = uniq([...typeArray, "null"]);
|
|
1400
|
+
return { type: nullableType };
|
|
1401
|
+
}
|
|
1402
|
+
return { type };
|
|
1403
|
+
}
|
|
1404
|
+
mapNullableOfRef(ref, isNullable) {
|
|
1405
|
+
if (isNullable) {
|
|
1406
|
+
return {
|
|
1407
|
+
oneOf: [ref, this.nullType]
|
|
1408
|
+
};
|
|
1409
|
+
}
|
|
1410
|
+
return ref;
|
|
1411
|
+
}
|
|
1412
|
+
mapTupleItems(schemas) {
|
|
1413
|
+
return {
|
|
1414
|
+
prefixItems: schemas
|
|
1415
|
+
};
|
|
1416
|
+
}
|
|
1417
|
+
getNumberChecks(checks) {
|
|
1418
|
+
return Object.assign({}, ...checks.map((check) => {
|
|
1419
|
+
switch (check._zod.def.check) {
|
|
1420
|
+
case "greater_than": {
|
|
1421
|
+
const greaterThanCheck = check;
|
|
1422
|
+
return greaterThanCheck._zod.def.inclusive ? { minimum: Number(greaterThanCheck._zod.def.value) } : { exclusiveMinimum: Number(greaterThanCheck._zod.def.value) };
|
|
1423
|
+
}
|
|
1424
|
+
case "less_than": {
|
|
1425
|
+
const lessThanCheck = check;
|
|
1426
|
+
return lessThanCheck._zod.def.inclusive ? { maximum: Number(lessThanCheck._zod.def.value) } : { exclusiveMaximum: Number(lessThanCheck._zod.def.value) };
|
|
1427
|
+
}
|
|
1428
|
+
default:
|
|
1429
|
+
return {};
|
|
1430
|
+
}
|
|
1431
|
+
}));
|
|
1432
|
+
}
|
|
1433
|
+
}
|
|
1434
|
+
function isWebhookDefinition(definition) {
|
|
1435
|
+
return "type" in definition && definition.type === "webhook";
|
|
1436
|
+
}
|
|
1437
|
+
|
|
1438
|
+
class OpenApiGeneratorV31 {
|
|
1439
|
+
constructor(definitions, options) {
|
|
1440
|
+
this.definitions = definitions;
|
|
1441
|
+
this.webhookRefs = {};
|
|
1442
|
+
const specifics = new OpenApiGeneratorV31Specifics;
|
|
1443
|
+
this.generator = new OpenAPIGenerator(this.definitions, specifics, options);
|
|
1444
|
+
}
|
|
1445
|
+
generateDocument(config) {
|
|
1446
|
+
const baseDocument = this.generator.generateDocumentData();
|
|
1447
|
+
this.definitions.filter(isWebhookDefinition).forEach((definition) => this.generateSingleWebhook(definition.webhook));
|
|
1448
|
+
return Object.assign(Object.assign(Object.assign({}, config), baseDocument), { webhooks: this.webhookRefs });
|
|
1449
|
+
}
|
|
1450
|
+
generateComponents() {
|
|
1451
|
+
return this.generator.generateComponents();
|
|
1452
|
+
}
|
|
1453
|
+
generateSingleWebhook(route) {
|
|
1454
|
+
const routeDoc = this.generator.generatePath(route);
|
|
1455
|
+
this.webhookRefs[route.path] = Object.assign(Object.assign({}, this.webhookRefs[route.path]), routeDoc);
|
|
1456
|
+
return routeDoc;
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
var ZodTypeKeys, objectEquals, zodToOpenAPIRegistry, ConflictError, MissingParameterDataError, UnknownZodTypeError, $OpenAPIRegistry, $OpenApiGeneratorV31, $extendZodWithOpenApi;
|
|
1460
|
+
var init_dist = __esm(() => {
|
|
1461
|
+
ZodTypeKeys = {
|
|
1462
|
+
ZodAny: "any",
|
|
1463
|
+
ZodArray: "array",
|
|
1464
|
+
ZodBigInt: "bigint",
|
|
1465
|
+
ZodBoolean: "boolean",
|
|
1466
|
+
ZodDefault: "default",
|
|
1467
|
+
ZodPrefault: "prefault",
|
|
1468
|
+
ZodTransform: "transform",
|
|
1469
|
+
ZodEnum: "enum",
|
|
1470
|
+
ZodIntersection: "intersection",
|
|
1471
|
+
ZodLazy: "lazy",
|
|
1472
|
+
ZodLiteral: "literal",
|
|
1473
|
+
ZodNever: "never",
|
|
1474
|
+
ZodNull: "null",
|
|
1475
|
+
ZodNullable: "nullable",
|
|
1476
|
+
ZodNumber: "number",
|
|
1477
|
+
ZodNonOptional: "nonoptional",
|
|
1478
|
+
ZodObject: "object",
|
|
1479
|
+
ZodOptional: "optional",
|
|
1480
|
+
ZodPipe: "pipe",
|
|
1481
|
+
ZodReadonly: "readonly",
|
|
1482
|
+
ZodRecord: "record",
|
|
1483
|
+
ZodString: "string",
|
|
1484
|
+
ZodTuple: "tuple",
|
|
1485
|
+
ZodType: "type",
|
|
1486
|
+
ZodUnion: "union",
|
|
1487
|
+
ZodDiscriminatedUnion: "union",
|
|
1488
|
+
ZodUnknown: "unknown",
|
|
1489
|
+
ZodVoid: "void",
|
|
1490
|
+
ZodDate: "date",
|
|
1491
|
+
ZodTemplateLiteral: "template_literal"
|
|
1492
|
+
};
|
|
1493
|
+
objectEquals = isEqual;
|
|
1494
|
+
zodToOpenAPIRegistry = registry();
|
|
1495
|
+
ConflictError = class ConflictError extends ZodToOpenAPIError {
|
|
1496
|
+
constructor(message, data) {
|
|
1497
|
+
super(message);
|
|
1498
|
+
this.data = data;
|
|
1499
|
+
}
|
|
1500
|
+
};
|
|
1501
|
+
MissingParameterDataError = class MissingParameterDataError extends ZodToOpenAPIError {
|
|
1502
|
+
constructor(data) {
|
|
1503
|
+
super(`Missing parameter data, please specify \`${data.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`schema.openapi\``);
|
|
1504
|
+
this.data = data;
|
|
1505
|
+
}
|
|
1506
|
+
};
|
|
1507
|
+
UnknownZodTypeError = class UnknownZodTypeError extends ZodToOpenAPIError {
|
|
1508
|
+
constructor(data) {
|
|
1509
|
+
super(`Unknown zod object type, please specify \`type\` and other OpenAPI props using \`schema.openapi\`.`);
|
|
1510
|
+
this.data = data;
|
|
1511
|
+
}
|
|
1512
|
+
};
|
|
1513
|
+
$OpenAPIRegistry = OpenAPIRegistry;
|
|
1514
|
+
$OpenApiGeneratorV31 = OpenApiGeneratorV31;
|
|
1515
|
+
$extendZodWithOpenApi = extendZodWithOpenApi;
|
|
1516
|
+
});
|
|
1517
|
+
|
|
1518
|
+
// src/utils/zod-openapi.ts
|
|
1519
|
+
var init_zod_openapi = __esm(() => {
|
|
1520
|
+
init_dist();
|
|
1521
|
+
init_zod();
|
|
1522
|
+
$extendZodWithOpenApi(exports_zod);
|
|
1523
|
+
});
|
|
1524
|
+
|
|
1525
|
+
// src/types.ts
|
|
1526
|
+
function parseModelTier(value) {
|
|
1527
|
+
if (!value)
|
|
1528
|
+
return;
|
|
1529
|
+
const normalized = value.trim().toLowerCase();
|
|
1530
|
+
return ModelTierSchema.safeParse(normalized).success ? normalized : LEGACY_MODEL_TO_TIER[normalized];
|
|
1531
|
+
}
|
|
1532
|
+
function splitLegacyModelAlias(input) {
|
|
1533
|
+
const explicitTier = parseModelTier(input.modelTier);
|
|
1534
|
+
const model = input.model?.trim();
|
|
1535
|
+
if (!model)
|
|
1536
|
+
return { modelTier: explicitTier };
|
|
1537
|
+
const legacyTier = parseModelTier(model);
|
|
1538
|
+
if (legacyTier && !explicitTier) {
|
|
1539
|
+
return { modelTier: legacyTier };
|
|
1540
|
+
}
|
|
1541
|
+
return {
|
|
1542
|
+
model,
|
|
1543
|
+
modelTier: explicitTier
|
|
1544
|
+
};
|
|
1545
|
+
}
|
|
1546
|
+
function parseTierMapJson(value) {
|
|
1547
|
+
if (!value)
|
|
1548
|
+
return {};
|
|
1549
|
+
try {
|
|
1550
|
+
const parsed = JSON.parse(value);
|
|
1551
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
|
|
1552
|
+
return {};
|
|
1553
|
+
const result = {};
|
|
1554
|
+
for (const tier of MODEL_TIERS) {
|
|
1555
|
+
const model = parsed[tier];
|
|
1556
|
+
if (typeof model === "string" && model.trim())
|
|
1557
|
+
result[tier] = model.trim();
|
|
1558
|
+
}
|
|
1559
|
+
return result;
|
|
1560
|
+
} catch {
|
|
1561
|
+
return {};
|
|
1562
|
+
}
|
|
1563
|
+
}
|
|
1564
|
+
function resolveModelTier(opts) {
|
|
1565
|
+
const tier = parseModelTier(opts.tier);
|
|
1566
|
+
if (!tier)
|
|
1567
|
+
return;
|
|
1568
|
+
const env = opts.env ?? {};
|
|
1569
|
+
const jsonOverrides = parseTierMapJson(env.MODEL_TIER_MAP);
|
|
1570
|
+
const envKey = `MODEL_TIER_${tier.toUpperCase()}`;
|
|
1571
|
+
const directOverride = env[envKey]?.trim();
|
|
1572
|
+
if (directOverride)
|
|
1573
|
+
return directOverride;
|
|
1574
|
+
if (jsonOverrides[tier])
|
|
1575
|
+
return jsonOverrides[tier];
|
|
1576
|
+
return DEFAULT_MODEL_TIER_MAP[opts.harnessProvider]?.[tier];
|
|
1577
|
+
}
|
|
1578
|
+
function resolveTaskModelSelection(opts) {
|
|
1579
|
+
const model = opts.model?.trim();
|
|
1580
|
+
if (model)
|
|
1581
|
+
return { model, source: "model" };
|
|
1582
|
+
const tierModel = resolveModelTier({
|
|
1583
|
+
tier: opts.modelTier,
|
|
1584
|
+
harnessProvider: opts.harnessProvider,
|
|
1585
|
+
env: opts.env
|
|
1586
|
+
});
|
|
1587
|
+
if (tierModel)
|
|
1588
|
+
return { model: tierModel, source: "modelTier" };
|
|
1589
|
+
return { source: "none" };
|
|
1590
|
+
}
|
|
1591
|
+
function isTerminalTaskStatus(status) {
|
|
1592
|
+
return TERMINAL_TASK_STATUSES.includes(status);
|
|
1593
|
+
}
|
|
1594
|
+
var AssetKeySchema, AssetEntityTypeSchema, AssetProviderRefSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, MODEL_TIERS, ReasoningEffortSchema, LEGACY_MODEL_TO_TIER, DEFAULT_MODEL_TIER_MAP, AgentTaskStatusSchema, TERMINAL_TASK_STATUSES, InboxMessageStatusSchema, InboxMessageSchema, AgentTaskSourceSchema, RoutingReasonSchema, RoutingSourceSchema, ProviderNameSchema, SteerModeSchema, SteeringStatusSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, CreateTaskOptionsSchema, TaskAttachmentKindSchema, SERVER_GENERATED_ATTACHMENT_CAPABILITY = "_agentSwarmGeneratedBy", attachmentCapabilitiesSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AcpSessionConfigSelectValueSchema, AcpSessionConfigSelectGroupSchema, AcpSessionConfigOptionSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, REPO_GUIDELINES_MAX_ENTRIES = 50, RepoGuidelinesInputSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RuntimeInstanceStatusSchema, RuntimeInstanceSchema, RetryPolicySchema, ExecutorMetaSchema, ValidationResultSchema, StepValidationConfigSchema, SwarmScriptNodeConfigSchema, WorkflowNodeSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, WebhookVerificationSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowTemplateSchema, WorkflowSnapshotSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSnapshotSchema, PageSchema, PageVersionSchema, MetricParamSchema, MetricVariableTypeSchema, MetricFormatSchema, MetricVisualizationSchema, MetricQuerySchema, MetricVariableSchema, MetricVizConfigSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSnapshotSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunKindSchema, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepStatusSchema, WorkflowRunStepSchema, WaitModeSchema, WaitStateStatusSchema, WaitStateRowSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ExtensionNameSchema, SemverSchema, ExtensionManifestSchema, ExtensionStatusSchema, ExtensionSchema, ExtensionFileSchema, ExtensionVersionSchema, ExtensionRunSchema, ExtensionInstallBodySchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillTypeSchema, SkillScopeSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpServerTransportSchema, McpServerScopeSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KV_NAME_REGEX, KvNamespaceSchema, KvKeySchema, KvEntrySchema;
|
|
1595
|
+
var init_types = __esm(() => {
|
|
1596
|
+
init_key();
|
|
1597
|
+
init_bundle_path();
|
|
1598
|
+
init_constants();
|
|
1599
|
+
init_zod_openapi();
|
|
1600
|
+
AssetKeySchema = exports_zod.string().min(1).max(255).superRefine((value, ctx) => {
|
|
1601
|
+
try {
|
|
1602
|
+
normalizeAssetKey(value);
|
|
1603
|
+
} catch (error) {
|
|
1604
|
+
ctx.addIssue({
|
|
1605
|
+
code: "custom",
|
|
1606
|
+
message: error instanceof Error ? error.message : "Invalid asset namespace key"
|
|
1607
|
+
});
|
|
1608
|
+
}
|
|
1609
|
+
}).describe("Non-unique asset directory namespace (for example shared/ or personal/<user-id>/drafts/). Runtime write boundaries normalize and validate the canonical form.");
|
|
1610
|
+
AssetEntityTypeSchema = exports_zod.enum([
|
|
1611
|
+
"task",
|
|
1612
|
+
"workflow",
|
|
1613
|
+
"schedule",
|
|
1614
|
+
"page",
|
|
1615
|
+
"app",
|
|
1616
|
+
"script",
|
|
1617
|
+
"file"
|
|
1618
|
+
]);
|
|
1619
|
+
AssetProviderRefSchema = exports_zod.object({
|
|
1620
|
+
providerId: exports_zod.string(),
|
|
1621
|
+
orgId: exports_zod.string().optional(),
|
|
1622
|
+
driveId: exports_zod.string().optional(),
|
|
1623
|
+
providerKey: exports_zod.string()
|
|
1624
|
+
}).openapi("AssetProviderRef");
|
|
1625
|
+
AssetKeyMappingSchema = exports_zod.object({
|
|
1626
|
+
id: exports_zod.string(),
|
|
1627
|
+
providerId: exports_zod.string(),
|
|
1628
|
+
providerOrgId: exports_zod.string().optional(),
|
|
1629
|
+
providerDriveId: exports_zod.string().optional(),
|
|
1630
|
+
providerKey: exports_zod.string(),
|
|
1631
|
+
key: AssetKeySchema,
|
|
1632
|
+
sourceEntityType: exports_zod.enum(["task-attachment", "external"]).optional(),
|
|
1633
|
+
sourceEntityId: exports_zod.string().optional(),
|
|
1634
|
+
createdAt: exports_zod.iso.datetime(),
|
|
1635
|
+
updatedAt: exports_zod.iso.datetime(),
|
|
1636
|
+
createdBy: exports_zod.string().optional(),
|
|
1637
|
+
updatedBy: exports_zod.string().optional()
|
|
1638
|
+
}).openapi("AssetKeyMapping");
|
|
1639
|
+
AssetSummarySchema = exports_zod.object({
|
|
1640
|
+
entityType: AssetEntityTypeSchema,
|
|
1641
|
+
id: exports_zod.string(),
|
|
1642
|
+
key: AssetKeySchema,
|
|
1643
|
+
label: exports_zod.string(),
|
|
1644
|
+
updatedAt: exports_zod.string(),
|
|
1645
|
+
providerRef: AssetProviderRefSchema.optional()
|
|
1646
|
+
}).openapi("AssetSummary");
|
|
1647
|
+
ModelTierSchema = exports_zod.enum(["smol", "regular", "smart", "ultra"]);
|
|
1648
|
+
MODEL_TIERS = ModelTierSchema.options;
|
|
1649
|
+
ReasoningEffortSchema = exports_zod.enum(["off", "low", "medium", "high", "xhigh", "max"]);
|
|
1650
|
+
LEGACY_MODEL_TO_TIER = {
|
|
1651
|
+
haiku: "smol",
|
|
1652
|
+
sonnet: "regular",
|
|
1653
|
+
opus: "smart",
|
|
1654
|
+
fable: "ultra"
|
|
1655
|
+
};
|
|
1656
|
+
DEFAULT_MODEL_TIER_MAP = {
|
|
1657
|
+
claude: {
|
|
1658
|
+
smol: "haiku",
|
|
1659
|
+
regular: "sonnet",
|
|
1660
|
+
smart: "opus",
|
|
1661
|
+
ultra: "fable"
|
|
1662
|
+
},
|
|
1663
|
+
"claude-managed": {
|
|
1664
|
+
smol: "claude-haiku-4-5",
|
|
1665
|
+
regular: "claude-sonnet-5",
|
|
1666
|
+
smart: "claude-opus-4-8",
|
|
1667
|
+
ultra: "claude-fable-5"
|
|
1668
|
+
},
|
|
1669
|
+
codex: {
|
|
1670
|
+
smol: "gpt-5.6-luna",
|
|
1671
|
+
regular: "gpt-5.6-terra",
|
|
1672
|
+
smart: "gpt-5.6-sol",
|
|
1673
|
+
ultra: "gpt-5.6-sol"
|
|
1674
|
+
},
|
|
1675
|
+
pi: {
|
|
1676
|
+
smol: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
1677
|
+
regular: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
1678
|
+
smart: "openrouter/deepseek/deepseek-v4-pro-0813",
|
|
1679
|
+
ultra: "openrouter/anthropic/claude-opus-5.5"
|
|
1680
|
+
},
|
|
1681
|
+
opencode: {
|
|
1682
|
+
smol: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
1683
|
+
regular: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
1684
|
+
smart: "openrouter/deepseek/deepseek-v4-pro-0813",
|
|
1685
|
+
ultra: "openrouter/anthropic/claude-opus-5.5"
|
|
1686
|
+
},
|
|
1687
|
+
dsh: {
|
|
1688
|
+
smol: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
1689
|
+
regular: "openrouter/deepseek/deepseek-v4.1-flash",
|
|
1690
|
+
smart: "openrouter/deepseek/deepseek-v4-pro-0813",
|
|
1691
|
+
ultra: "openrouter/anthropic/claude-opus-5.5"
|
|
1692
|
+
},
|
|
1693
|
+
devin: {
|
|
1694
|
+
smol: "devin",
|
|
1695
|
+
regular: "devin",
|
|
1696
|
+
smart: "devin",
|
|
1697
|
+
ultra: "devin"
|
|
1698
|
+
},
|
|
1699
|
+
acp: {
|
|
1700
|
+
smol: "",
|
|
1701
|
+
regular: "",
|
|
1702
|
+
smart: "",
|
|
1703
|
+
ultra: ""
|
|
1704
|
+
}
|
|
1705
|
+
};
|
|
1706
|
+
AgentTaskStatusSchema = exports_zod.enum([
|
|
1707
|
+
"draft",
|
|
1708
|
+
"backlog",
|
|
1709
|
+
"unassigned",
|
|
1710
|
+
"offered",
|
|
1711
|
+
"reviewing",
|
|
1712
|
+
"pending",
|
|
1713
|
+
"in_progress",
|
|
1714
|
+
"paused",
|
|
1715
|
+
"completed",
|
|
1716
|
+
"failed",
|
|
1717
|
+
"cancelled",
|
|
1718
|
+
"superseded"
|
|
1719
|
+
]);
|
|
1720
|
+
TERMINAL_TASK_STATUSES = ["completed", "failed", "cancelled", "superseded"];
|
|
1721
|
+
InboxMessageStatusSchema = exports_zod.enum([
|
|
1722
|
+
"unread",
|
|
1723
|
+
"processing",
|
|
1724
|
+
"read",
|
|
1725
|
+
"responded",
|
|
1726
|
+
"delegated"
|
|
1727
|
+
]);
|
|
1728
|
+
InboxMessageSchema = exports_zod.object({
|
|
1729
|
+
id: exports_zod.uuid(),
|
|
1730
|
+
agentId: exports_zod.string(),
|
|
1731
|
+
content: exports_zod.string().min(1),
|
|
1732
|
+
source: exports_zod.enum(["slack", "agentmail"]).default("slack"),
|
|
1733
|
+
status: InboxMessageStatusSchema.default("unread"),
|
|
1734
|
+
slackChannelId: exports_zod.string().optional(),
|
|
1735
|
+
slackThreadTs: exports_zod.string().optional(),
|
|
1736
|
+
slackUserId: exports_zod.string().optional(),
|
|
1737
|
+
matchedText: exports_zod.string().optional(),
|
|
1738
|
+
delegatedToTaskId: exports_zod.uuid().optional(),
|
|
1739
|
+
responseText: exports_zod.string().optional(),
|
|
1740
|
+
createdAt: exports_zod.iso.datetime(),
|
|
1741
|
+
lastUpdatedAt: exports_zod.iso.datetime()
|
|
1742
|
+
}).openapi("InboxMessage");
|
|
1743
|
+
AgentTaskSourceSchema = exports_zod.enum([
|
|
1744
|
+
"mcp",
|
|
1745
|
+
"slack",
|
|
1746
|
+
"api",
|
|
1747
|
+
"ui",
|
|
1748
|
+
"github",
|
|
1749
|
+
"gitlab",
|
|
1750
|
+
"agentmail",
|
|
1751
|
+
"system",
|
|
1752
|
+
"schedule",
|
|
1753
|
+
"workflow",
|
|
1754
|
+
"linear",
|
|
1755
|
+
"jira"
|
|
1756
|
+
]);
|
|
1757
|
+
RoutingReasonSchema = exports_zod.enum([
|
|
1758
|
+
"skill",
|
|
1759
|
+
"continuity",
|
|
1760
|
+
"overflow",
|
|
1761
|
+
"human_pinned",
|
|
1762
|
+
"reroute_fault"
|
|
1763
|
+
]);
|
|
1764
|
+
RoutingSourceSchema = exports_zod.enum(["declared", "engine_default"]);
|
|
1765
|
+
ProviderNameSchema = exports_zod.enum([
|
|
1766
|
+
"claude",
|
|
1767
|
+
"codex",
|
|
1768
|
+
"pi",
|
|
1769
|
+
"devin",
|
|
1770
|
+
"claude-managed",
|
|
1771
|
+
"opencode",
|
|
1772
|
+
"acp",
|
|
1773
|
+
"dsh"
|
|
1774
|
+
]);
|
|
1775
|
+
SteerModeSchema = exports_zod.enum(["steer", "queue"]);
|
|
1776
|
+
SteeringStatusSchema = exports_zod.enum([
|
|
1777
|
+
"pending",
|
|
1778
|
+
"delivered",
|
|
1779
|
+
"handled",
|
|
1780
|
+
"promoted",
|
|
1781
|
+
"cancelled"
|
|
1782
|
+
]);
|
|
1783
|
+
SteeringSourceSchema = exports_zod.enum(["ui", "mcp", "script", "slack", "api"]);
|
|
1784
|
+
SteeringMessageSchema = exports_zod.object({
|
|
1785
|
+
id: exports_zod.uuid(),
|
|
1786
|
+
taskId: exports_zod.uuid(),
|
|
1787
|
+
body: exports_zod.string().min(1),
|
|
1788
|
+
mode: SteerModeSchema,
|
|
1789
|
+
status: SteeringStatusSchema,
|
|
1790
|
+
deliveredMode: SteerModeSchema.optional(),
|
|
1791
|
+
source: SteeringSourceSchema,
|
|
1792
|
+
senderLabel: exports_zod.string().optional(),
|
|
1793
|
+
createdByKind: exports_zod.enum(["user", "agent", "system"]),
|
|
1794
|
+
createdByUserId: exports_zod.string().optional(),
|
|
1795
|
+
createdByAgentId: exports_zod.string().optional(),
|
|
1796
|
+
promotedTaskId: exports_zod.uuid().optional(),
|
|
1797
|
+
createdAt: exports_zod.iso.datetime(),
|
|
1798
|
+
deliveredAt: exports_zod.iso.datetime().optional(),
|
|
1799
|
+
handledAt: exports_zod.iso.datetime().optional(),
|
|
1800
|
+
handledNote: exports_zod.string().optional()
|
|
1801
|
+
}).openapi("SteeringMessage");
|
|
1802
|
+
SteerOutcomeSchema = exports_zod.enum(["steered", "queued", "promoted"]);
|
|
1803
|
+
OnUnsupportedSchema = exports_zod.enum(["degrade", "fail"]).default("degrade");
|
|
1804
|
+
SteerResultSchema = exports_zod.object({
|
|
1805
|
+
outcome: SteerOutcomeSchema,
|
|
1806
|
+
steeringMessageId: exports_zod.uuid().optional(),
|
|
1807
|
+
promotedTaskId: exports_zod.uuid().optional(),
|
|
1808
|
+
effectiveMode: SteerModeSchema,
|
|
1809
|
+
degradedFrom: SteerModeSchema.optional()
|
|
1810
|
+
}).openapi("SteerResult");
|
|
1811
|
+
PROVIDER_STEER_CAPABILITIES = {
|
|
1812
|
+
pi: ["steer", "queue"],
|
|
1813
|
+
"claude-managed": ["steer", "queue"],
|
|
1814
|
+
devin: ["queue"],
|
|
1815
|
+
opencode: ["queue"],
|
|
1816
|
+
claude: ["queue"],
|
|
1817
|
+
codex: ["steer", "queue"],
|
|
1818
|
+
acp: [],
|
|
1819
|
+
dsh: []
|
|
1820
|
+
};
|
|
1821
|
+
FollowUpConfigSchema = exports_zod.object({
|
|
1822
|
+
disabled: exports_zod.boolean().optional(),
|
|
1823
|
+
onCompleted: exports_zod.string().max(4000).optional(),
|
|
1824
|
+
onFailed: exports_zod.string().max(4000).optional()
|
|
1825
|
+
}).openapi("FollowUpConfig");
|
|
1826
|
+
RoutingAffinitySchema = exports_zod.object({
|
|
1827
|
+
sourceAgentId: exports_zod.string().optional(),
|
|
1828
|
+
role: exports_zod.string().max(100).optional(),
|
|
1829
|
+
harnessProvider: ProviderNameSchema.optional(),
|
|
1830
|
+
capabilities: exports_zod.array(exports_zod.string()).default([]),
|
|
1831
|
+
leadOnly: exports_zod.boolean().optional()
|
|
1832
|
+
}).openapi("RoutingAffinity");
|
|
1833
|
+
AgentTaskSchema = exports_zod.object({
|
|
1834
|
+
id: exports_zod.uuid(),
|
|
1835
|
+
key: AssetKeySchema,
|
|
1836
|
+
agentId: exports_zod.string().nullable(),
|
|
1837
|
+
creatorAgentId: exports_zod.string().optional(),
|
|
1838
|
+
task: exports_zod.string().min(1),
|
|
1839
|
+
title: exports_zod.string().optional(),
|
|
1840
|
+
status: AgentTaskStatusSchema,
|
|
1841
|
+
source: AgentTaskSourceSchema.default("mcp"),
|
|
1842
|
+
routingReason: RoutingReasonSchema.optional(),
|
|
1843
|
+
routingSource: RoutingSourceSchema.optional().describe("Origin of the routing reason: declared by the caller or chosen by the engine. Absent for unknown historical provenance or no reason."),
|
|
1844
|
+
routingNote: exports_zod.string().max(200).optional(),
|
|
1845
|
+
taskType: exports_zod.string().max(50).optional(),
|
|
1846
|
+
tags: exports_zod.array(exports_zod.string()).default([]),
|
|
1847
|
+
priority: exports_zod.number().int().min(0).max(100).default(50),
|
|
1848
|
+
dependsOn: exports_zod.array(exports_zod.string()).default([]),
|
|
1849
|
+
offeredTo: exports_zod.string().optional(),
|
|
1850
|
+
offeredAt: exports_zod.iso.datetime().optional(),
|
|
1851
|
+
acceptedAt: exports_zod.iso.datetime().optional(),
|
|
1852
|
+
rejectionReason: exports_zod.string().optional(),
|
|
1853
|
+
createdAt: exports_zod.iso.datetime(),
|
|
1854
|
+
lastUpdatedAt: exports_zod.iso.datetime(),
|
|
1855
|
+
finishedAt: exports_zod.iso.datetime().optional(),
|
|
1856
|
+
notifiedAt: exports_zod.iso.datetime().optional(),
|
|
1857
|
+
failureReason: exports_zod.string().optional(),
|
|
1858
|
+
output: exports_zod.string().optional(),
|
|
1859
|
+
progress: exports_zod.string().optional(),
|
|
1860
|
+
slackChannelId: exports_zod.string().optional(),
|
|
1861
|
+
slackThreadTs: exports_zod.string().optional(),
|
|
1862
|
+
slackTriggerMessageTs: exports_zod.string().optional(),
|
|
1863
|
+
slackUserId: exports_zod.string().optional(),
|
|
1864
|
+
slackReplySent: exports_zod.boolean().default(false),
|
|
1865
|
+
slackProgressMessageTs: exports_zod.string().optional(),
|
|
1866
|
+
slackTreeRootMessageTs: exports_zod.string().optional(),
|
|
1867
|
+
vcsProvider: exports_zod.enum(["github", "gitlab"]).optional(),
|
|
1868
|
+
vcsRepo: exports_zod.string().optional(),
|
|
1869
|
+
vcsEventType: exports_zod.string().optional(),
|
|
1870
|
+
vcsNumber: exports_zod.number().int().optional(),
|
|
1871
|
+
vcsCommentId: exports_zod.number().int().optional(),
|
|
1872
|
+
vcsAuthor: exports_zod.string().optional(),
|
|
1873
|
+
vcsUrl: exports_zod.string().optional(),
|
|
1874
|
+
vcsInstallationId: exports_zod.number().int().optional(),
|
|
1875
|
+
vcsNodeId: exports_zod.string().optional(),
|
|
1876
|
+
agentmailInboxId: exports_zod.string().optional(),
|
|
1877
|
+
agentmailMessageId: exports_zod.string().optional(),
|
|
1878
|
+
agentmailThreadId: exports_zod.string().optional(),
|
|
1879
|
+
mentionMessageId: exports_zod.string().optional(),
|
|
1880
|
+
mentionChannelId: exports_zod.string().optional(),
|
|
1881
|
+
dir: exports_zod.string().min(1).optional(),
|
|
1882
|
+
parentTaskId: exports_zod.string().optional(),
|
|
1883
|
+
claudeSessionId: exports_zod.string().optional(),
|
|
1884
|
+
model: exports_zod.string().optional(),
|
|
1885
|
+
modelTier: ModelTierSchema.optional(),
|
|
1886
|
+
effort: ReasoningEffortSchema.optional(),
|
|
1887
|
+
scheduleId: exports_zod.string().optional(),
|
|
1888
|
+
workflowRunId: exports_zod.string().uuid().nullable().optional(),
|
|
1889
|
+
workflowRunStepId: exports_zod.string().uuid().nullable().optional(),
|
|
1890
|
+
contextKey: exports_zod.string().optional(),
|
|
1891
|
+
outputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
1892
|
+
followUpConfig: FollowUpConfigSchema.optional(),
|
|
1893
|
+
wasPaused: exports_zod.boolean().default(false),
|
|
1894
|
+
deferredAt: exports_zod.iso.datetime().optional(),
|
|
1895
|
+
compactionCount: exports_zod.number().int().min(0).optional(),
|
|
1896
|
+
peakContextPercent: exports_zod.number().min(0).max(100).optional(),
|
|
1897
|
+
peakContextTokens: exports_zod.number().int().min(0).optional(),
|
|
1898
|
+
contextWindowSize: exports_zod.number().int().min(0).optional(),
|
|
1899
|
+
credentialKeySuffix: exports_zod.string().optional(),
|
|
1900
|
+
credentialKeyType: exports_zod.string().optional(),
|
|
1901
|
+
requestedByUserId: exports_zod.string().optional(),
|
|
1902
|
+
swarmVersion: exports_zod.string().optional(),
|
|
1903
|
+
provider: ProviderNameSchema.optional(),
|
|
1904
|
+
providerMeta: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
1905
|
+
harnessVariant: exports_zod.string().optional(),
|
|
1906
|
+
harnessVariantMeta: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
1907
|
+
totalCostUsd: exports_zod.number().min(0).optional(),
|
|
1908
|
+
routingAffinity: RoutingAffinitySchema.optional(),
|
|
1909
|
+
routingAffinityInvalid: exports_zod.boolean().optional()
|
|
1910
|
+
}).openapi("AgentTask");
|
|
1911
|
+
CreateTaskOptionsSchema = exports_zod.object({
|
|
1912
|
+
key: exports_zod.string().min(1).optional(),
|
|
1913
|
+
agentId: exports_zod.string().nullable().optional(),
|
|
1914
|
+
creatorAgentId: exports_zod.string().optional(),
|
|
1915
|
+
source: AgentTaskSourceSchema.optional(),
|
|
1916
|
+
routingReason: RoutingReasonSchema.optional(),
|
|
1917
|
+
routingSource: RoutingSourceSchema.optional(),
|
|
1918
|
+
routingNote: exports_zod.string().max(200).optional(),
|
|
1919
|
+
taskType: exports_zod.string().max(50).optional(),
|
|
1920
|
+
tags: exports_zod.array(exports_zod.string()).optional(),
|
|
1921
|
+
priority: exports_zod.number().int().min(0).max(100).optional(),
|
|
1922
|
+
dependsOn: exports_zod.array(exports_zod.string()).optional(),
|
|
1923
|
+
offeredTo: exports_zod.string().optional(),
|
|
1924
|
+
status: exports_zod.enum(["draft", "backlog", "unassigned"]).optional(),
|
|
1925
|
+
slackChannelId: exports_zod.string().optional(),
|
|
1926
|
+
slackThreadTs: exports_zod.string().optional(),
|
|
1927
|
+
slackTriggerMessageTs: exports_zod.string().optional(),
|
|
1928
|
+
slackUserId: exports_zod.string().optional(),
|
|
1929
|
+
overrideSlackContext: exports_zod.boolean().optional(),
|
|
1930
|
+
vcsProvider: exports_zod.enum(["github", "gitlab"]).optional(),
|
|
1931
|
+
vcsRepo: exports_zod.string().optional(),
|
|
1932
|
+
vcsEventType: exports_zod.string().optional(),
|
|
1933
|
+
vcsNumber: exports_zod.number().int().optional(),
|
|
1934
|
+
vcsCommentId: exports_zod.number().int().optional(),
|
|
1935
|
+
vcsAuthor: exports_zod.string().optional(),
|
|
1936
|
+
vcsUrl: exports_zod.string().optional(),
|
|
1937
|
+
vcsInstallationId: exports_zod.number().int().optional(),
|
|
1938
|
+
vcsNodeId: exports_zod.string().optional(),
|
|
1939
|
+
agentmailInboxId: exports_zod.string().optional(),
|
|
1940
|
+
agentmailMessageId: exports_zod.string().optional(),
|
|
1941
|
+
agentmailThreadId: exports_zod.string().optional(),
|
|
1942
|
+
mentionMessageId: exports_zod.string().optional(),
|
|
1943
|
+
mentionChannelId: exports_zod.string().optional(),
|
|
1944
|
+
dir: exports_zod.string().optional(),
|
|
1945
|
+
parentTaskId: exports_zod.string().optional(),
|
|
1946
|
+
model: exports_zod.string().optional(),
|
|
1947
|
+
modelTier: ModelTierSchema.optional(),
|
|
1948
|
+
effort: ReasoningEffortSchema.optional(),
|
|
1949
|
+
scheduleId: exports_zod.string().optional(),
|
|
1950
|
+
workflowRunId: exports_zod.string().optional(),
|
|
1951
|
+
workflowRunStepId: exports_zod.string().optional(),
|
|
1952
|
+
sourceTaskId: exports_zod.string().optional(),
|
|
1953
|
+
outputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
1954
|
+
inheritParentOutputSchema: exports_zod.boolean().optional(),
|
|
1955
|
+
inheritParentRoutingAffinity: exports_zod.boolean().optional(),
|
|
1956
|
+
followUpConfig: FollowUpConfigSchema.optional(),
|
|
1957
|
+
requestedByUserId: exports_zod.string().optional(),
|
|
1958
|
+
contextKey: exports_zod.string().optional(),
|
|
1959
|
+
bypassTrackerContextDedup: exports_zod.boolean().optional(),
|
|
1960
|
+
routingAffinity: RoutingAffinitySchema.optional()
|
|
1961
|
+
});
|
|
1962
|
+
TaskAttachmentKindSchema = exports_zod.enum(["agent-fs", "url", "shared-fs", "page"]);
|
|
1963
|
+
attachmentCapabilitiesSchema = exports_zod.record(exports_zod.string(), exports_zod.unknown()).refine((capabilities) => !(SERVER_GENERATED_ATTACHMENT_CAPABILITY in capabilities), {
|
|
1964
|
+
message: `${SERVER_GENERATED_ATTACHMENT_CAPABILITY} is reserved for server-generated attachments`
|
|
1965
|
+
});
|
|
1966
|
+
attachmentCommonFields = {
|
|
1967
|
+
name: exports_zod.string().min(1).describe("Display name for the attachment."),
|
|
1968
|
+
providerId: exports_zod.string().min(1).optional(),
|
|
1969
|
+
providerKey: exports_zod.string().min(1).optional(),
|
|
1970
|
+
capabilities: attachmentCapabilitiesSchema.optional(),
|
|
1971
|
+
mimeType: exports_zod.string().optional(),
|
|
1972
|
+
sizeBytes: exports_zod.number().int().min(0).optional(),
|
|
1973
|
+
sha256: exports_zod.string().optional(),
|
|
1974
|
+
intent: exports_zod.string().optional().describe("WHY this attachment exists — the purpose it serves for this task."),
|
|
1975
|
+
description: exports_zod.string().optional().describe("Optional: what the attachment is."),
|
|
1976
|
+
isPrimary: exports_zod.boolean().optional()
|
|
1977
|
+
};
|
|
1978
|
+
AttachmentInputSchema = exports_zod.discriminatedUnion("kind", [
|
|
1979
|
+
exports_zod.object({
|
|
1980
|
+
kind: exports_zod.literal("agent-fs"),
|
|
1981
|
+
path: exports_zod.string().min(1).describe("agent-fs path the attachment points at."),
|
|
1982
|
+
orgId: exports_zod.string().min(1).optional().describe("agent-fs org id — paired with `driveId` lets the renderer build a public live-host URL."),
|
|
1983
|
+
driveId: exports_zod.string().min(1).optional().describe("agent-fs drive id — paired with `orgId` lets the renderer build a public live-host URL."),
|
|
1984
|
+
...attachmentCommonFields
|
|
1985
|
+
}),
|
|
1986
|
+
exports_zod.object({
|
|
1987
|
+
kind: exports_zod.literal("url"),
|
|
1988
|
+
url: exports_zod.string().min(1).describe("External URL the attachment points at."),
|
|
1989
|
+
...attachmentCommonFields
|
|
1990
|
+
}),
|
|
1991
|
+
exports_zod.object({
|
|
1992
|
+
kind: exports_zod.literal("shared-fs"),
|
|
1993
|
+
path: exports_zod.string().min(1).describe("Shared-filesystem path the attachment points at."),
|
|
1994
|
+
...attachmentCommonFields
|
|
1995
|
+
}),
|
|
1996
|
+
exports_zod.object({
|
|
1997
|
+
kind: exports_zod.literal("page"),
|
|
1998
|
+
pageId: exports_zod.string().min(1).describe("Swarm Page id the attachment points at."),
|
|
1999
|
+
...attachmentCommonFields
|
|
2000
|
+
})
|
|
2001
|
+
]);
|
|
2002
|
+
TaskAttachmentSchema = exports_zod.object({
|
|
2003
|
+
id: exports_zod.uuid(),
|
|
2004
|
+
taskId: exports_zod.uuid(),
|
|
2005
|
+
agentId: exports_zod.string().nullable(),
|
|
2006
|
+
name: exports_zod.string(),
|
|
2007
|
+
kind: TaskAttachmentKindSchema,
|
|
2008
|
+
url: exports_zod.string().optional(),
|
|
2009
|
+
path: exports_zod.string().optional(),
|
|
2010
|
+
pageId: exports_zod.string().optional(),
|
|
2011
|
+
providerId: exports_zod.string().optional(),
|
|
2012
|
+
providerKey: exports_zod.string().optional(),
|
|
2013
|
+
capabilities: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2014
|
+
orgId: exports_zod.string().optional(),
|
|
2015
|
+
driveId: exports_zod.string().optional(),
|
|
2016
|
+
mimeType: exports_zod.string().optional(),
|
|
2017
|
+
sizeBytes: exports_zod.number().int().min(0).optional(),
|
|
2018
|
+
sha256: exports_zod.string().optional(),
|
|
2019
|
+
intent: exports_zod.string().optional(),
|
|
2020
|
+
description: exports_zod.string().optional(),
|
|
2021
|
+
isPrimary: exports_zod.boolean().default(false),
|
|
2022
|
+
createdAt: exports_zod.iso.datetime(),
|
|
2023
|
+
createdBy: exports_zod.string().optional(),
|
|
2024
|
+
updatedBy: exports_zod.string().optional()
|
|
2025
|
+
}).openapi("TaskAttachment");
|
|
2026
|
+
UserSchema = exports_zod.object({
|
|
2027
|
+
id: exports_zod.string(),
|
|
2028
|
+
name: exports_zod.string().min(1),
|
|
2029
|
+
email: exports_zod.string().optional(),
|
|
2030
|
+
role: exports_zod.string().optional(),
|
|
2031
|
+
notes: exports_zod.string().optional(),
|
|
2032
|
+
emailAliases: exports_zod.array(exports_zod.string()).default([]),
|
|
2033
|
+
preferredChannel: exports_zod.string().default("slack"),
|
|
2034
|
+
timezone: exports_zod.string().optional(),
|
|
2035
|
+
metadata: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2036
|
+
dailyBudgetUsd: exports_zod.number().nullable().optional(),
|
|
2037
|
+
status: exports_zod.enum(["invited", "active", "suspended"]).default("active"),
|
|
2038
|
+
createdAt: exports_zod.iso.datetime(),
|
|
2039
|
+
lastUpdatedAt: exports_zod.iso.datetime()
|
|
2040
|
+
}).openapi("User");
|
|
2041
|
+
UserCommsPrefsSchema = exports_zod.object({
|
|
2042
|
+
tone: exports_zod.string().optional(),
|
|
2043
|
+
language: exports_zod.string().optional(),
|
|
2044
|
+
verbosity: exports_zod.string().optional()
|
|
2045
|
+
}).openapi("UserCommsPrefs");
|
|
2046
|
+
IdentityEventTypeSchema = exports_zod.enum([
|
|
2047
|
+
"auto_merge",
|
|
2048
|
+
"manual_merge",
|
|
2049
|
+
"identity_added",
|
|
2050
|
+
"identity_removed",
|
|
2051
|
+
"email_added",
|
|
2052
|
+
"email_removed",
|
|
2053
|
+
"token_minted",
|
|
2054
|
+
"token_revoked",
|
|
2055
|
+
"budget_changed",
|
|
2056
|
+
"status_changed",
|
|
2057
|
+
"profile_changed"
|
|
2058
|
+
]);
|
|
2059
|
+
InboxItemTypeSchema = exports_zod.enum([
|
|
2060
|
+
"approval",
|
|
2061
|
+
"credential_missing",
|
|
2062
|
+
"broken_task",
|
|
2063
|
+
"to_read",
|
|
2064
|
+
"to_start_template",
|
|
2065
|
+
"notification"
|
|
2066
|
+
]);
|
|
2067
|
+
InboxItemStatusSchema = exports_zod.enum(["open", "snoozed", "dismissed", "done"]);
|
|
2068
|
+
InboxItemStateSchema = exports_zod.object({
|
|
2069
|
+
id: exports_zod.string(),
|
|
2070
|
+
userId: exports_zod.string(),
|
|
2071
|
+
itemType: InboxItemTypeSchema,
|
|
2072
|
+
itemId: exports_zod.string(),
|
|
2073
|
+
status: InboxItemStatusSchema,
|
|
2074
|
+
snoozeUntil: exports_zod.string().optional(),
|
|
2075
|
+
dismissedAt: exports_zod.string().optional(),
|
|
2076
|
+
doneAt: exports_zod.string().optional(),
|
|
2077
|
+
readAt: exports_zod.string().optional(),
|
|
2078
|
+
createdAt: exports_zod.string(),
|
|
2079
|
+
lastUpdatedAt: exports_zod.string()
|
|
2080
|
+
}).openapi("InboxItemState");
|
|
2081
|
+
FavoriteItemTypeSchema = exports_zod.enum(["page", "workflow", "schedule"]);
|
|
2082
|
+
UserFavoriteSchema = exports_zod.object({
|
|
2083
|
+
id: exports_zod.string(),
|
|
2084
|
+
userId: exports_zod.string().optional(),
|
|
2085
|
+
itemType: FavoriteItemTypeSchema,
|
|
2086
|
+
itemId: exports_zod.string(),
|
|
2087
|
+
createdAt: exports_zod.string(),
|
|
2088
|
+
lastUpdatedAt: exports_zod.string(),
|
|
2089
|
+
createdBy: exports_zod.string().optional(),
|
|
2090
|
+
updatedBy: exports_zod.string().optional()
|
|
2091
|
+
}).openapi("UserFavorite");
|
|
2092
|
+
TaskTemplateKindSchema = exports_zod.enum(["task", "workflow", "schedule"]);
|
|
2093
|
+
TaskTemplateSchema = exports_zod.object({
|
|
2094
|
+
id: exports_zod.string(),
|
|
2095
|
+
title: exports_zod.string().min(1),
|
|
2096
|
+
description: exports_zod.string(),
|
|
2097
|
+
prompt: exports_zod.string(),
|
|
2098
|
+
kind: TaskTemplateKindSchema.default("task"),
|
|
2099
|
+
payload: exports_zod.record(exports_zod.string(), exports_zod.unknown()).default({}),
|
|
2100
|
+
category: exports_zod.string().optional(),
|
|
2101
|
+
tags: exports_zod.array(exports_zod.string()).default([]),
|
|
2102
|
+
createdAt: exports_zod.string()
|
|
2103
|
+
}).openapi("TaskTemplate");
|
|
2104
|
+
AgentStatusSchema = exports_zod.enum(["idle", "busy", "offline", "waiting_for_credentials"]);
|
|
2105
|
+
AgentAvatarSchema = exports_zod.discriminatedUnion("type", [
|
|
2106
|
+
exports_zod.object({
|
|
2107
|
+
type: exports_zod.literal("lucide"),
|
|
2108
|
+
icon: exports_zod.string().regex(/^[a-z0-9-]+$/).max(64),
|
|
2109
|
+
color: exports_zod.string().regex(/^#[0-9a-fA-F]{6}$/).optional()
|
|
2110
|
+
})
|
|
2111
|
+
]);
|
|
2112
|
+
AgentSchema = exports_zod.object({
|
|
2113
|
+
id: exports_zod.string(),
|
|
2114
|
+
name: exports_zod.string().min(1),
|
|
2115
|
+
isLead: exports_zod.boolean().default(false),
|
|
2116
|
+
status: AgentStatusSchema,
|
|
2117
|
+
description: exports_zod.string().optional(),
|
|
2118
|
+
role: exports_zod.string().max(100).optional(),
|
|
2119
|
+
capabilities: exports_zod.array(exports_zod.string()).default([]),
|
|
2120
|
+
claudeMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
|
|
2121
|
+
soulMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
|
|
2122
|
+
identityMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
|
|
2123
|
+
setupScript: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
|
|
2124
|
+
toolsMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
|
|
2125
|
+
heartbeatMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
|
|
2126
|
+
maxTasks: exports_zod.number().int().min(1).max(100).optional(),
|
|
2127
|
+
emptyPollCount: exports_zod.number().int().min(0).optional(),
|
|
2128
|
+
lastActivityAt: exports_zod.iso.datetime().optional(),
|
|
2129
|
+
provider: ProviderNameSchema.optional(),
|
|
2130
|
+
harnessProvider: ProviderNameSchema.nullable().optional(),
|
|
2131
|
+
credentialMissing: exports_zod.array(exports_zod.string()).nullable().optional(),
|
|
2132
|
+
credStatus: exports_zod.lazy(() => AgentCredStatusSchema).nullable().optional(),
|
|
2133
|
+
avatar: exports_zod.lazy(() => AgentAvatarSchema).nullable().optional(),
|
|
2134
|
+
createdAt: exports_zod.iso.datetime(),
|
|
2135
|
+
lastUpdatedAt: exports_zod.iso.datetime()
|
|
2136
|
+
}).openapi("Agent");
|
|
2137
|
+
AgentCredStatusLiveTestSchema = exports_zod.object({
|
|
2138
|
+
ok: exports_zod.boolean(),
|
|
2139
|
+
error: exports_zod.string().nullable().default(null),
|
|
2140
|
+
latency_ms: exports_zod.number(),
|
|
2141
|
+
testedAt: exports_zod.number()
|
|
2142
|
+
}).openapi("AgentCredStatusLiveTest");
|
|
2143
|
+
AgentLatestModelSchema = exports_zod.object({
|
|
2144
|
+
model: exports_zod.string().min(1),
|
|
2145
|
+
source: exports_zod.enum(["task", "agent_config", "adapter_default", "custom"]),
|
|
2146
|
+
taskId: exports_zod.string().nullable().default(null),
|
|
2147
|
+
harnessProvider: ProviderNameSchema.nullable().default(null),
|
|
2148
|
+
reportedAt: exports_zod.number(),
|
|
2149
|
+
reasoningEffort: ReasoningEffortSchema.optional()
|
|
2150
|
+
}).openapi("AgentLatestModel");
|
|
2151
|
+
AgentBedrockStatusSchema = exports_zod.object({
|
|
2152
|
+
region: exports_zod.string(),
|
|
2153
|
+
probedAt: exports_zod.number(),
|
|
2154
|
+
ready: exports_zod.boolean(),
|
|
2155
|
+
models: exports_zod.array(exports_zod.object({ id: exports_zod.string(), name: exports_zod.string() })).default([]),
|
|
2156
|
+
error: exports_zod.string().optional()
|
|
2157
|
+
}).openapi("AgentBedrockStatus");
|
|
2158
|
+
AcpSessionConfigSelectValueSchema = exports_zod.object({
|
|
2159
|
+
value: exports_zod.string(),
|
|
2160
|
+
name: exports_zod.string(),
|
|
2161
|
+
description: exports_zod.string().nullable().optional()
|
|
2162
|
+
});
|
|
2163
|
+
AcpSessionConfigSelectGroupSchema = exports_zod.object({
|
|
2164
|
+
group: exports_zod.string(),
|
|
2165
|
+
name: exports_zod.string(),
|
|
2166
|
+
options: exports_zod.array(AcpSessionConfigSelectValueSchema)
|
|
2167
|
+
});
|
|
2168
|
+
AcpSessionConfigOptionSchema = exports_zod.discriminatedUnion("type", [
|
|
2169
|
+
exports_zod.object({
|
|
2170
|
+
type: exports_zod.literal("select"),
|
|
2171
|
+
id: exports_zod.string(),
|
|
2172
|
+
name: exports_zod.string(),
|
|
2173
|
+
description: exports_zod.string().nullable().optional(),
|
|
2174
|
+
category: exports_zod.string().nullable().optional(),
|
|
2175
|
+
currentValue: exports_zod.string(),
|
|
2176
|
+
options: exports_zod.array(exports_zod.union([AcpSessionConfigSelectValueSchema, AcpSessionConfigSelectGroupSchema]))
|
|
2177
|
+
}),
|
|
2178
|
+
exports_zod.object({
|
|
2179
|
+
type: exports_zod.literal("boolean"),
|
|
2180
|
+
id: exports_zod.string(),
|
|
2181
|
+
name: exports_zod.string(),
|
|
2182
|
+
description: exports_zod.string().nullable().optional(),
|
|
2183
|
+
category: exports_zod.string().nullable().optional(),
|
|
2184
|
+
currentValue: exports_zod.boolean()
|
|
2185
|
+
})
|
|
2186
|
+
]);
|
|
2187
|
+
AgentAcpStatusSchema = exports_zod.object({
|
|
2188
|
+
target: exports_zod.enum(["opencode", "custom"]),
|
|
2189
|
+
configOptions: exports_zod.array(AcpSessionConfigOptionSchema),
|
|
2190
|
+
reportedAt: exports_zod.number()
|
|
2191
|
+
}).openapi("AgentAcpStatus");
|
|
2192
|
+
AgentCredStatusSchema = exports_zod.object({
|
|
2193
|
+
ready: exports_zod.boolean(),
|
|
2194
|
+
missing: exports_zod.array(exports_zod.string()).default([]),
|
|
2195
|
+
satisfiedBy: exports_zod.enum(["env", "file", "side-effect-pending", "sdk-delegated"]).nullable().default(null),
|
|
2196
|
+
hint: exports_zod.string().nullable().default(null),
|
|
2197
|
+
liveTest: AgentCredStatusLiveTestSchema.nullable().default(null),
|
|
2198
|
+
latestModel: AgentLatestModelSchema.nullable().default(null),
|
|
2199
|
+
reportedAt: exports_zod.number(),
|
|
2200
|
+
reportKind: exports_zod.enum(["boot", "post_task"]).default("boot"),
|
|
2201
|
+
bedrock: AgentBedrockStatusSchema.nullable().default(null),
|
|
2202
|
+
acp: AgentAcpStatusSchema.nullable().default(null)
|
|
2203
|
+
}).openapi("AgentCredStatus");
|
|
2204
|
+
AgentWithTasksSchema = AgentSchema.extend({
|
|
2205
|
+
tasks: exports_zod.array(AgentTaskSchema).default([])
|
|
2206
|
+
});
|
|
2207
|
+
ChangeSourceSchema = exports_zod.enum([
|
|
2208
|
+
"self_edit",
|
|
2209
|
+
"lead_coaching",
|
|
2210
|
+
"api",
|
|
2211
|
+
"system",
|
|
2212
|
+
"session_sync"
|
|
2213
|
+
]);
|
|
2214
|
+
VersionableFieldSchema = exports_zod.enum([
|
|
2215
|
+
"soulMd",
|
|
2216
|
+
"identityMd",
|
|
2217
|
+
"toolsMd",
|
|
2218
|
+
"claudeMd",
|
|
2219
|
+
"setupScript",
|
|
2220
|
+
"heartbeatMd"
|
|
2221
|
+
]);
|
|
2222
|
+
ContextVersionSchema = exports_zod.object({
|
|
2223
|
+
id: exports_zod.uuid(),
|
|
2224
|
+
agentId: exports_zod.string(),
|
|
2225
|
+
field: VersionableFieldSchema,
|
|
2226
|
+
content: exports_zod.string(),
|
|
2227
|
+
version: exports_zod.number().int().min(1),
|
|
2228
|
+
changeSource: ChangeSourceSchema,
|
|
2229
|
+
changedByAgentId: exports_zod.string().nullable(),
|
|
2230
|
+
changeReason: exports_zod.string().nullable(),
|
|
2231
|
+
contentHash: exports_zod.string(),
|
|
2232
|
+
previousVersionId: exports_zod.uuid().nullable(),
|
|
2233
|
+
createdAt: exports_zod.iso.datetime()
|
|
2234
|
+
}).openapi("ContextVersion");
|
|
2235
|
+
ChannelTypeSchema = exports_zod.enum(["public", "dm"]);
|
|
2236
|
+
ChannelSchema = exports_zod.object({
|
|
2237
|
+
id: exports_zod.uuid(),
|
|
2238
|
+
name: exports_zod.string().min(1).max(100),
|
|
2239
|
+
description: exports_zod.string().max(500).optional(),
|
|
2240
|
+
type: ChannelTypeSchema.default("public"),
|
|
2241
|
+
createdBy: exports_zod.string().optional(),
|
|
2242
|
+
participants: exports_zod.array(exports_zod.string()).default([]),
|
|
2243
|
+
createdAt: exports_zod.iso.datetime()
|
|
2244
|
+
}).openapi("Channel");
|
|
2245
|
+
ChannelMessageSchema = exports_zod.object({
|
|
2246
|
+
id: exports_zod.uuid(),
|
|
2247
|
+
channelId: exports_zod.uuid(),
|
|
2248
|
+
agentId: exports_zod.string().nullable(),
|
|
2249
|
+
agentName: exports_zod.string().optional(),
|
|
2250
|
+
content: exports_zod.string().min(1).max(4000),
|
|
2251
|
+
replyToId: exports_zod.uuid().optional(),
|
|
2252
|
+
mentions: exports_zod.array(exports_zod.string()).default([]),
|
|
2253
|
+
createdAt: exports_zod.iso.datetime()
|
|
2254
|
+
}).openapi("ChannelMessage");
|
|
2255
|
+
ServiceStatusSchema = exports_zod.enum(["starting", "healthy", "unhealthy", "stopped"]);
|
|
2256
|
+
ServiceSchema = exports_zod.object({
|
|
2257
|
+
id: exports_zod.uuid(),
|
|
2258
|
+
agentId: exports_zod.string(),
|
|
2259
|
+
name: exports_zod.string().min(1).max(50),
|
|
2260
|
+
port: exports_zod.number().int().min(1).max(65535).default(3000),
|
|
2261
|
+
description: exports_zod.string().optional(),
|
|
2262
|
+
url: exports_zod.string().url().optional(),
|
|
2263
|
+
healthCheckPath: exports_zod.string().default("/health"),
|
|
2264
|
+
status: ServiceStatusSchema.default("starting"),
|
|
2265
|
+
script: exports_zod.string().min(1),
|
|
2266
|
+
cwd: exports_zod.string().optional(),
|
|
2267
|
+
interpreter: exports_zod.string().optional(),
|
|
2268
|
+
args: exports_zod.array(exports_zod.string()).optional(),
|
|
2269
|
+
env: exports_zod.record(exports_zod.string(), exports_zod.string()).optional(),
|
|
2270
|
+
metadata: exports_zod.record(exports_zod.string(), exports_zod.unknown()).default({}),
|
|
2271
|
+
createdAt: exports_zod.iso.datetime(),
|
|
2272
|
+
lastUpdatedAt: exports_zod.iso.datetime()
|
|
2273
|
+
}).openapi("Service");
|
|
2274
|
+
AgentLogEventTypeSchema = exports_zod.enum([
|
|
2275
|
+
"agent_joined",
|
|
2276
|
+
"agent_status_change",
|
|
2277
|
+
"agent_left",
|
|
2278
|
+
"task_created",
|
|
2279
|
+
"task_status_change",
|
|
2280
|
+
"task_progress",
|
|
2281
|
+
"task_steering",
|
|
2282
|
+
"task_offered",
|
|
2283
|
+
"task_accepted",
|
|
2284
|
+
"task_rejected",
|
|
2285
|
+
"task_claimed",
|
|
2286
|
+
"task_claim_rejected_affinity",
|
|
2287
|
+
"task_dispatch_rejected_affinity",
|
|
2288
|
+
"task_authorization_rejected",
|
|
2289
|
+
"task_recovery_authorization",
|
|
2290
|
+
"task_released",
|
|
2291
|
+
"channel_message",
|
|
2292
|
+
"service_registered",
|
|
2293
|
+
"service_unregistered",
|
|
2294
|
+
"service_status_change",
|
|
2295
|
+
"budget.upserted",
|
|
2296
|
+
"budget.deleted",
|
|
2297
|
+
"pricing.inserted",
|
|
2298
|
+
"pricing.deleted",
|
|
2299
|
+
"pricing.refresh",
|
|
2300
|
+
"pricing.refresh.failed",
|
|
2301
|
+
"task_superseded",
|
|
2302
|
+
"slack_delivery"
|
|
2303
|
+
]);
|
|
2304
|
+
ResumeReasonSchema = exports_zod.enum([
|
|
2305
|
+
"graceful_shutdown",
|
|
2306
|
+
"context_limits",
|
|
2307
|
+
"manual_supersede",
|
|
2308
|
+
"crash_recovery"
|
|
2309
|
+
]);
|
|
2310
|
+
AgentLogSchema = exports_zod.object({
|
|
2311
|
+
id: exports_zod.uuid(),
|
|
2312
|
+
eventType: AgentLogEventTypeSchema,
|
|
2313
|
+
agentId: exports_zod.string().optional(),
|
|
2314
|
+
taskId: exports_zod.string().optional(),
|
|
2315
|
+
oldValue: exports_zod.string().optional(),
|
|
2316
|
+
newValue: exports_zod.string().optional(),
|
|
2317
|
+
metadata: exports_zod.string().optional(),
|
|
2318
|
+
createdAt: exports_zod.iso.datetime()
|
|
2319
|
+
}).openapi("AgentLog");
|
|
2320
|
+
SessionLogSchema = exports_zod.object({
|
|
2321
|
+
id: exports_zod.uuid(),
|
|
2322
|
+
taskId: exports_zod.uuid().optional(),
|
|
2323
|
+
sessionId: exports_zod.string(),
|
|
2324
|
+
iteration: exports_zod.number().int().min(1),
|
|
2325
|
+
cli: exports_zod.string().default("claude"),
|
|
2326
|
+
content: exports_zod.string(),
|
|
2327
|
+
lineNumber: exports_zod.number().int().min(0),
|
|
2328
|
+
createdAt: exports_zod.iso.datetime()
|
|
2329
|
+
}).openapi("SessionLog");
|
|
2330
|
+
SessionCostSourceSchema = exports_zod.enum(["harness", "pricing-table", "unpriced"]);
|
|
2331
|
+
SessionCostModelBreakdownSchema = exports_zod.object({
|
|
2332
|
+
model: exports_zod.string(),
|
|
2333
|
+
inputTokens: exports_zod.number().int().nonnegative(),
|
|
2334
|
+
outputTokens: exports_zod.number().int().nonnegative(),
|
|
2335
|
+
cacheReadTokens: exports_zod.number().int().nonnegative(),
|
|
2336
|
+
cacheWriteTokens: exports_zod.number().int().nonnegative(),
|
|
2337
|
+
webSearchRequests: exports_zod.number().int().nonnegative().nullable().optional(),
|
|
2338
|
+
costUsd: exports_zod.number().nullable().optional(),
|
|
2339
|
+
harnessCostUsd: exports_zod.number().nullable().optional()
|
|
2340
|
+
}).openapi("SessionCostModelBreakdown");
|
|
2341
|
+
SessionCostSchema = exports_zod.object({
|
|
2342
|
+
id: exports_zod.uuid(),
|
|
2343
|
+
sessionId: exports_zod.string(),
|
|
2344
|
+
taskId: exports_zod.uuid().optional(),
|
|
2345
|
+
agentId: exports_zod.string(),
|
|
2346
|
+
totalCostUsd: exports_zod.number().min(0),
|
|
2347
|
+
inputTokens: exports_zod.number().int().min(0).default(0),
|
|
2348
|
+
outputTokens: exports_zod.number().int().min(0).default(0),
|
|
2349
|
+
cacheReadTokens: exports_zod.number().int().min(0).default(0),
|
|
2350
|
+
cacheWriteTokens: exports_zod.number().int().min(0).default(0),
|
|
2351
|
+
reasoningOutputTokens: exports_zod.number().int().min(0).default(0),
|
|
2352
|
+
thinkingTokens: exports_zod.number().int().min(0).default(0),
|
|
2353
|
+
durationMs: exports_zod.number().int().min(0),
|
|
2354
|
+
numTurns: exports_zod.number().int().min(1).nullable(),
|
|
2355
|
+
model: exports_zod.string(),
|
|
2356
|
+
isError: exports_zod.boolean().default(false),
|
|
2357
|
+
costSource: SessionCostSourceSchema.default("harness"),
|
|
2358
|
+
harnessCostUsd: exports_zod.number().nullable().optional(),
|
|
2359
|
+
cacheWrite5mTokens: exports_zod.number().int().nullable().optional(),
|
|
2360
|
+
cacheWrite1hTokens: exports_zod.number().int().nullable().optional(),
|
|
2361
|
+
modelBreakdown: exports_zod.array(SessionCostModelBreakdownSchema).nullable().optional(),
|
|
2362
|
+
createdAt: exports_zod.iso.datetime()
|
|
2363
|
+
}).openapi("SessionCost");
|
|
2364
|
+
EventCategorySchema = exports_zod.enum([
|
|
2365
|
+
"tool",
|
|
2366
|
+
"skill",
|
|
2367
|
+
"session",
|
|
2368
|
+
"api",
|
|
2369
|
+
"task",
|
|
2370
|
+
"workflow",
|
|
2371
|
+
"system"
|
|
2372
|
+
]);
|
|
2373
|
+
EventStatusSchema = exports_zod.enum(["ok", "error", "timeout", "skipped"]);
|
|
2374
|
+
EventSourceSchema = exports_zod.enum(["worker", "api", "hook", "scheduler", "cli"]);
|
|
2375
|
+
EventNameSchema = exports_zod.enum([
|
|
2376
|
+
"tool.start",
|
|
2377
|
+
"tool.end",
|
|
2378
|
+
"skill.invoke",
|
|
2379
|
+
"skill.complete",
|
|
2380
|
+
"session.start",
|
|
2381
|
+
"session.end",
|
|
2382
|
+
"session.resume",
|
|
2383
|
+
"session.cost",
|
|
2384
|
+
"api.request",
|
|
2385
|
+
"api.error",
|
|
2386
|
+
"task.poll",
|
|
2387
|
+
"task.assign",
|
|
2388
|
+
"task.timeout",
|
|
2389
|
+
"workflow.step.start",
|
|
2390
|
+
"workflow.step.end",
|
|
2391
|
+
"workflow.run.start",
|
|
2392
|
+
"workflow.run.end",
|
|
2393
|
+
"system.boot",
|
|
2394
|
+
"system.migration",
|
|
2395
|
+
"system.error",
|
|
2396
|
+
"system.profile_sync_rejected",
|
|
2397
|
+
"system.profile_sync_reconciled",
|
|
2398
|
+
"system.profile_sync_conflict",
|
|
2399
|
+
"script.global_upsert",
|
|
2400
|
+
"schedule.deleted"
|
|
2401
|
+
]);
|
|
2402
|
+
SwarmEventSchema = exports_zod.object({
|
|
2403
|
+
id: exports_zod.uuid(),
|
|
2404
|
+
category: EventCategorySchema,
|
|
2405
|
+
event: EventNameSchema,
|
|
2406
|
+
status: EventStatusSchema,
|
|
2407
|
+
source: EventSourceSchema,
|
|
2408
|
+
agentId: exports_zod.string().optional(),
|
|
2409
|
+
taskId: exports_zod.string().optional(),
|
|
2410
|
+
sessionId: exports_zod.string().optional(),
|
|
2411
|
+
parentEventId: exports_zod.string().optional(),
|
|
2412
|
+
numericValue: exports_zod.number().optional(),
|
|
2413
|
+
durationMs: exports_zod.number().int().optional(),
|
|
2414
|
+
data: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2415
|
+
createdAt: exports_zod.iso.datetime()
|
|
2416
|
+
}).openapi("SwarmEvent");
|
|
2417
|
+
AutomationIntegrationIdSchema = exports_zod.enum([
|
|
2418
|
+
"slack",
|
|
2419
|
+
"github",
|
|
2420
|
+
"linear",
|
|
2421
|
+
"jira",
|
|
2422
|
+
"gsc",
|
|
2423
|
+
"agentmail",
|
|
2424
|
+
"agentfs"
|
|
2425
|
+
]);
|
|
2426
|
+
ScheduledTaskTargetTypeSchema = exports_zod.enum(["agent-task", "workflow", "script"]);
|
|
2427
|
+
ScheduledTaskSchema = exports_zod.object({
|
|
2428
|
+
id: exports_zod.uuid(),
|
|
2429
|
+
key: AssetKeySchema,
|
|
2430
|
+
name: exports_zod.string().min(1).max(100),
|
|
2431
|
+
description: exports_zod.string().optional(),
|
|
2432
|
+
cronExpression: exports_zod.string().optional(),
|
|
2433
|
+
intervalMs: exports_zod.number().int().positive().optional(),
|
|
2434
|
+
taskTemplate: exports_zod.string().optional(),
|
|
2435
|
+
taskType: exports_zod.string().max(50).optional(),
|
|
2436
|
+
tags: exports_zod.array(exports_zod.string()).default([]),
|
|
2437
|
+
priority: exports_zod.number().int().min(0).max(100).default(50),
|
|
2438
|
+
targetAgentId: exports_zod.string().optional(),
|
|
2439
|
+
enabled: exports_zod.boolean().default(true),
|
|
2440
|
+
lastRunAt: exports_zod.iso.datetime().optional(),
|
|
2441
|
+
nextRunAt: exports_zod.iso.datetime().optional(),
|
|
2442
|
+
createdByAgentId: exports_zod.string().optional(),
|
|
2443
|
+
parentTaskId: exports_zod.string().optional(),
|
|
2444
|
+
requestedDelayMs: exports_zod.number().int().positive().optional(),
|
|
2445
|
+
requestedRunAt: exports_zod.iso.datetime().optional(),
|
|
2446
|
+
timezone: exports_zod.string().default("UTC"),
|
|
2447
|
+
consecutiveErrors: exports_zod.number().int().min(0).default(0),
|
|
2448
|
+
lastErrorAt: exports_zod.iso.datetime().optional(),
|
|
2449
|
+
lastErrorMessage: exports_zod.string().optional(),
|
|
2450
|
+
model: exports_zod.string().optional(),
|
|
2451
|
+
modelTier: ModelTierSchema.optional(),
|
|
2452
|
+
scheduleType: exports_zod.enum(["recurring", "one_time"]).default("recurring"),
|
|
2453
|
+
targetType: ScheduledTaskTargetTypeSchema.default("agent-task"),
|
|
2454
|
+
workflowId: exports_zod.uuid().optional(),
|
|
2455
|
+
scriptName: exports_zod.string().optional(),
|
|
2456
|
+
scriptArgs: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2457
|
+
params: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2458
|
+
requiredParams: exports_zod.array(exports_zod.string()).optional(),
|
|
2459
|
+
requires: exports_zod.array(AutomationIntegrationIdSchema).optional(),
|
|
2460
|
+
createdAt: exports_zod.iso.datetime(),
|
|
2461
|
+
lastUpdatedAt: exports_zod.iso.datetime(),
|
|
2462
|
+
createdBy: exports_zod.string().optional(),
|
|
2463
|
+
updatedBy: exports_zod.string().optional(),
|
|
2464
|
+
favorite: exports_zod.boolean().optional()
|
|
2465
|
+
}).refine((data) => {
|
|
2466
|
+
if (data.scheduleType === "one_time")
|
|
2467
|
+
return true;
|
|
2468
|
+
return data.cronExpression || data.intervalMs;
|
|
2469
|
+
}, {
|
|
2470
|
+
message: "Either cronExpression or intervalMs must be provided for recurring schedules"
|
|
2471
|
+
}).refine((data) => {
|
|
2472
|
+
switch (data.targetType) {
|
|
2473
|
+
case "agent-task":
|
|
2474
|
+
return !!data.taskTemplate;
|
|
2475
|
+
case "workflow":
|
|
2476
|
+
return !!data.workflowId;
|
|
2477
|
+
case "script":
|
|
2478
|
+
return !!data.scriptName;
|
|
2479
|
+
default:
|
|
2480
|
+
return true;
|
|
2481
|
+
}
|
|
2482
|
+
}, {
|
|
2483
|
+
message: "Target-type specific field is required (taskTemplate, workflowId, or scriptName)"
|
|
2484
|
+
});
|
|
2485
|
+
SwarmConfigScopeSchema = exports_zod.enum(["global", "agent", "repo"]);
|
|
2486
|
+
SwarmConfigSchema = exports_zod.object({
|
|
2487
|
+
id: exports_zod.string().uuid(),
|
|
2488
|
+
scope: SwarmConfigScopeSchema,
|
|
2489
|
+
scopeId: exports_zod.string().nullable(),
|
|
2490
|
+
key: exports_zod.string().min(1).max(255),
|
|
2491
|
+
value: exports_zod.string(),
|
|
2492
|
+
isSecret: exports_zod.boolean(),
|
|
2493
|
+
envPath: exports_zod.string().nullable(),
|
|
2494
|
+
description: exports_zod.string().nullable(),
|
|
2495
|
+
createdAt: exports_zod.string(),
|
|
2496
|
+
lastUpdatedAt: exports_zod.string(),
|
|
2497
|
+
encrypted: exports_zod.boolean()
|
|
2498
|
+
}).openapi("SwarmConfig");
|
|
2499
|
+
RepoGuidelinesSchema = exports_zod.object({
|
|
2500
|
+
prChecks: exports_zod.array(exports_zod.string()),
|
|
2501
|
+
mergeChecks: exports_zod.array(exports_zod.string()),
|
|
2502
|
+
allowMerge: exports_zod.boolean().optional().default(false),
|
|
2503
|
+
review: exports_zod.array(exports_zod.string())
|
|
2504
|
+
}).openapi("RepoGuidelines");
|
|
2505
|
+
RepoGuidelinesInputSchema = exports_zod.object({
|
|
2506
|
+
prChecks: exports_zod.array(exports_zod.string()).max(REPO_GUIDELINES_MAX_ENTRIES),
|
|
2507
|
+
mergeChecks: exports_zod.array(exports_zod.string()).max(REPO_GUIDELINES_MAX_ENTRIES),
|
|
2508
|
+
allowMerge: exports_zod.boolean().optional().default(false),
|
|
2509
|
+
review: exports_zod.array(exports_zod.string()).max(REPO_GUIDELINES_MAX_ENTRIES)
|
|
2510
|
+
}).openapi("RepoGuidelinesInput");
|
|
2511
|
+
RepoHooksSchema = exports_zod.object({
|
|
2512
|
+
enabled: exports_zod.boolean().default(false)
|
|
2513
|
+
}).openapi("RepoHooks");
|
|
2514
|
+
SwarmRepoSchema = exports_zod.object({
|
|
2515
|
+
id: exports_zod.string().uuid(),
|
|
2516
|
+
url: exports_zod.string().min(1),
|
|
2517
|
+
name: exports_zod.string().min(1).max(100),
|
|
2518
|
+
clonePath: exports_zod.string().min(1),
|
|
2519
|
+
defaultBranch: exports_zod.string().default("main"),
|
|
2520
|
+
autoClone: exports_zod.boolean().default(true),
|
|
2521
|
+
hooks: RepoHooksSchema.optional().default({ enabled: false }),
|
|
2522
|
+
guidelines: RepoGuidelinesSchema.nullable().optional(),
|
|
2523
|
+
createdAt: exports_zod.string(),
|
|
2524
|
+
lastUpdatedAt: exports_zod.string()
|
|
2525
|
+
}).openapi("SwarmRepo");
|
|
2526
|
+
AgentMemoryScopeSchema = exports_zod.enum(["agent", "swarm"]);
|
|
2527
|
+
AgentMemorySourceSchema = exports_zod.enum([
|
|
2528
|
+
"manual",
|
|
2529
|
+
"file_index",
|
|
2530
|
+
"session_summary",
|
|
2531
|
+
"task_completion"
|
|
2532
|
+
]);
|
|
2533
|
+
AgentMemorySchema = exports_zod.object({
|
|
2534
|
+
id: exports_zod.string().uuid(),
|
|
2535
|
+
agentId: exports_zod.string().nullable(),
|
|
2536
|
+
scope: AgentMemoryScopeSchema,
|
|
2537
|
+
key: exports_zod.string().nullable().optional(),
|
|
2538
|
+
name: exports_zod.string().min(1).max(500),
|
|
2539
|
+
content: exports_zod.string(),
|
|
2540
|
+
summary: exports_zod.string().nullable(),
|
|
2541
|
+
source: AgentMemorySourceSchema,
|
|
2542
|
+
sourceTaskId: exports_zod.string().uuid().nullable(),
|
|
2543
|
+
sourcePath: exports_zod.string().nullable(),
|
|
2544
|
+
chunkIndex: exports_zod.number().int().min(0).default(0),
|
|
2545
|
+
totalChunks: exports_zod.number().int().min(1).default(1),
|
|
2546
|
+
tags: exports_zod.array(exports_zod.string()),
|
|
2547
|
+
createdAt: exports_zod.string(),
|
|
2548
|
+
updatedAt: exports_zod.string().nullable().optional(),
|
|
2549
|
+
accessedAt: exports_zod.string(),
|
|
2550
|
+
expiresAt: exports_zod.string().nullable().optional(),
|
|
2551
|
+
accessCount: exports_zod.number().int().min(0).default(0).optional(),
|
|
2552
|
+
embeddingModel: exports_zod.string().nullable().optional(),
|
|
2553
|
+
contentHash: exports_zod.string().nullable().optional(),
|
|
2554
|
+
version: exports_zod.number().int().min(1).default(1).optional()
|
|
2555
|
+
}).openapi("AgentMemory");
|
|
2556
|
+
ActiveSessionSchema = exports_zod.object({
|
|
2557
|
+
id: exports_zod.uuid(),
|
|
2558
|
+
agentId: exports_zod.string(),
|
|
2559
|
+
taskId: exports_zod.string().nullable(),
|
|
2560
|
+
triggerType: exports_zod.string(),
|
|
2561
|
+
inboxMessageId: exports_zod.string().nullable(),
|
|
2562
|
+
taskDescription: exports_zod.string().nullable(),
|
|
2563
|
+
runnerSessionId: exports_zod.string().nullable(),
|
|
2564
|
+
providerSessionId: exports_zod.string().nullable(),
|
|
2565
|
+
runtimeInstanceId: exports_zod.string().nullable().optional(),
|
|
2566
|
+
startedAt: exports_zod.iso.datetime(),
|
|
2567
|
+
lastHeartbeatAt: exports_zod.iso.datetime()
|
|
2568
|
+
}).openapi("ActiveSession");
|
|
2569
|
+
RuntimeInstanceStatusSchema = exports_zod.enum(["active", "offline"]);
|
|
2570
|
+
RuntimeInstanceSchema = exports_zod.object({
|
|
2571
|
+
id: exports_zod.string(),
|
|
2572
|
+
agentId: exports_zod.string(),
|
|
2573
|
+
status: RuntimeInstanceStatusSchema,
|
|
2574
|
+
reportedSlots: exports_zod.number().int(),
|
|
2575
|
+
credentialReady: exports_zod.boolean().nullable().optional(),
|
|
2576
|
+
metadata: exports_zod.record(exports_zod.string(), exports_zod.unknown()).nullable(),
|
|
2577
|
+
lastSeenAt: exports_zod.iso.datetime(),
|
|
2578
|
+
createdAt: exports_zod.iso.datetime(),
|
|
2579
|
+
updatedAt: exports_zod.iso.datetime()
|
|
2580
|
+
}).openapi("RuntimeInstance");
|
|
2581
|
+
RetryPolicySchema = exports_zod.object({
|
|
2582
|
+
maxRetries: exports_zod.number().int().min(0).default(3),
|
|
2583
|
+
strategy: exports_zod.enum(["exponential", "static", "linear"]).default("exponential"),
|
|
2584
|
+
baseDelayMs: exports_zod.number().int().min(0).default(1000),
|
|
2585
|
+
maxDelayMs: exports_zod.number().int().min(0).default(60000)
|
|
2586
|
+
}).openapi("RetryPolicy");
|
|
2587
|
+
ExecutorMetaSchema = exports_zod.object({
|
|
2588
|
+
runId: exports_zod.string().uuid(),
|
|
2589
|
+
stepId: exports_zod.string().uuid(),
|
|
2590
|
+
nodeId: exports_zod.string(),
|
|
2591
|
+
workflowId: exports_zod.string().uuid(),
|
|
2592
|
+
dryRun: exports_zod.boolean().default(false),
|
|
2593
|
+
requestedByUserId: exports_zod.string().optional(),
|
|
2594
|
+
inputCtx: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional()
|
|
2595
|
+
}).openapi("ExecutorMeta");
|
|
2596
|
+
ValidationResultSchema = exports_zod.object({
|
|
2597
|
+
pass: exports_zod.boolean(),
|
|
2598
|
+
reasoning: exports_zod.string(),
|
|
2599
|
+
confidence: exports_zod.number().min(0).max(1)
|
|
2600
|
+
}).openapi("ValidationResult");
|
|
2601
|
+
StepValidationConfigSchema = exports_zod.object({
|
|
2602
|
+
executor: exports_zod.string().default("validate"),
|
|
2603
|
+
config: exports_zod.record(exports_zod.string(), exports_zod.unknown()),
|
|
2604
|
+
mustPass: exports_zod.boolean().default(false),
|
|
2605
|
+
retry: RetryPolicySchema.optional()
|
|
2606
|
+
}).openapi("StepValidationConfig");
|
|
2607
|
+
SwarmScriptNodeConfigSchema = exports_zod.object({
|
|
2608
|
+
scriptName: exports_zod.string().min(1),
|
|
2609
|
+
scope: exports_zod.enum(["global", "agent"]).optional(),
|
|
2610
|
+
pinHash: exports_zod.string().min(1).optional(),
|
|
2611
|
+
args: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2612
|
+
fsMode: exports_zod.enum(["none", "workspace-rw"]).optional(),
|
|
2613
|
+
timeoutMs: exports_zod.number().int().min(1000).max(300000).optional()
|
|
2614
|
+
}).openapi("SwarmScriptNodeConfig");
|
|
2615
|
+
WorkflowNodeSchema = exports_zod.object({
|
|
2616
|
+
id: exports_zod.string().describe("Unique node identifier, used in 'next' and 'inputs' mappings"),
|
|
2617
|
+
type: exports_zod.string().describe("Executor type: 'agent-task', 'script', 'swarm-script', 'raw-llm', 'validate', 'property-match'"),
|
|
2618
|
+
label: exports_zod.string().optional().describe("Human-readable label for UI display"),
|
|
2619
|
+
config: exports_zod.record(exports_zod.string(), exports_zod.unknown()).describe("Executor-specific config. For agent-task: { template, outputSchema?, agentId?, routingReason?, routingNote?, tags?, priority?, dir?, vcsRepo?, model? }; configured agentId defaults routingReason to human_pinned. " + "For script: { runtime, script, args?, timeout? }. " + "For swarm-script: { scriptName, scope?, pinHash?, args?, fsMode?, timeoutMs? (1000-300000) }. " + "Agent-task templates and ordinary config values support {{interpolation}} from the node's inputs context, including trigger and declared upstream aliases. " + "SECURITY: executable source for script/swarm-script nodes does not interpolate trigger.* or upstream node outputs; only input/workflow/swarm/run values are allowed in inline script source, and named swarm-script source is not workflow-interpolated. " + "Pass dynamic values through config.args instead (inline script receives them as argv; swarm-script receives its args object). " + "NOTE: config.outputSchema on agent-task nodes validates the AGENT's raw JSON output, " + "while node-level outputSchema validates the EXECUTOR's return value ({taskId, taskOutput})."),
|
|
2620
|
+
next: exports_zod.union([exports_zod.string(), exports_zod.array(exports_zod.string()), exports_zod.record(exports_zod.string(), exports_zod.string())]).optional().describe("Next node(s): string for simple chaining, string[] for fan-out to parallel nodes, or record for port-based routing ({pass: 'a', fail: 'b'})"),
|
|
2621
|
+
validation: StepValidationConfigSchema.optional(),
|
|
2622
|
+
retry: RetryPolicySchema.optional(),
|
|
2623
|
+
inputs: exports_zod.record(exports_zod.string(), exports_zod.string()).optional().describe("REQUIRED for cross-node data access. Maps local names to context paths. " + "Without this, upstream step outputs are NOT available for interpolation; built-in trigger/input/workflow/swarm/run context remains available. " + 'Example: { "cityData": "generate-city" } → use {{cityData.taskOutput.field}} in config templates. ' + 'For trigger data: { "pr": "trigger.pullRequest" }. ' + "This mapping works in agent-task templates and ordinary config, but executable script/swarm-script source excludes trigger and upstream-output aliases. " + "Route those dynamic values through config.args (argv for inline scripts) instead."),
|
|
2624
|
+
inputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional().describe("JSON Schema to validate resolved inputs before execution"),
|
|
2625
|
+
outputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional().describe("JSON Schema to validate the executor's output (e.g. {taskId, taskOutput} for agent-task). " + "Different from config.outputSchema which validates the agent's raw output.")
|
|
2626
|
+
}).openapi("WorkflowNode");
|
|
2627
|
+
WorkflowEdgeSchema = exports_zod.object({
|
|
2628
|
+
id: exports_zod.string(),
|
|
2629
|
+
source: exports_zod.string(),
|
|
2630
|
+
sourcePort: exports_zod.string(),
|
|
2631
|
+
target: exports_zod.string()
|
|
2632
|
+
}).openapi("WorkflowEdge");
|
|
2633
|
+
WorkflowDefinitionSchema = exports_zod.object({
|
|
2634
|
+
nodes: exports_zod.array(WorkflowNodeSchema).min(1),
|
|
2635
|
+
onNodeFailure: exports_zod.enum(["fail", "continue"]).default("fail").describe("Behavior when a node's task fails or is cancelled. " + "'fail' (default): mark the entire run as failed. " + "'continue': treat the failed node as completed with error output and proceed — " + "downstream convergence nodes receive '[FAILED: reason]' and can handle partial results.")
|
|
2636
|
+
}).openapi("WorkflowDefinition");
|
|
2637
|
+
WorkflowNodePatchSchema = WorkflowNodeSchema.partial().omit({ id: true });
|
|
2638
|
+
WorkflowPatchSchema = exports_zod.object({
|
|
2639
|
+
update: exports_zod.array(exports_zod.object({
|
|
2640
|
+
nodeId: exports_zod.string().describe("ID of the node to update"),
|
|
2641
|
+
node: WorkflowNodePatchSchema.describe("Partial node data to merge")
|
|
2642
|
+
})).optional().describe("Nodes to update (partial merge)"),
|
|
2643
|
+
delete: exports_zod.array(exports_zod.string()).optional().describe("Node IDs to delete"),
|
|
2644
|
+
create: exports_zod.array(WorkflowNodeSchema).optional().describe("New nodes to add"),
|
|
2645
|
+
onNodeFailure: exports_zod.enum(["fail", "continue"]).optional().describe("Update the definition-level onNodeFailure behavior"),
|
|
2646
|
+
triggerSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional().nullable().describe("Optional JSON-Schema describing the expected trigger payload shape. " + "Pass an object to set/replace; pass null to clear; omit to leave unchanged. " + "Validator subset: type, required, properties, enum, const, items. " + "Other JSON-Schema keywords are silently ignored."),
|
|
2647
|
+
params: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2648
|
+
requiredParams: exports_zod.array(exports_zod.string()).optional(),
|
|
2649
|
+
requires: exports_zod.array(AutomationIntegrationIdSchema).optional()
|
|
2650
|
+
}).openapi("WorkflowPatch");
|
|
2651
|
+
WebhookVerificationSchema = exports_zod.discriminatedUnion("format", [
|
|
2652
|
+
exports_zod.object({
|
|
2653
|
+
format: exports_zod.literal("hmac-sha256"),
|
|
2654
|
+
header: exports_zod.string().default("X-Hub-Signature-256").describe("Header containing HMAC-SHA256 over the raw request body. Accepts sha256=<hex> or bare hex.")
|
|
2655
|
+
}),
|
|
2656
|
+
exports_zod.object({
|
|
2657
|
+
format: exports_zod.literal("timestamped-hmac-sha256"),
|
|
2658
|
+
header: exports_zod.string().min(1).describe("Header containing comma-separated timestamp/signature pairs such as t=<timestamp>,v1=<hex>."),
|
|
2659
|
+
timestampKey: exports_zod.string().default("t").describe("Timestamp field key in the signature header"),
|
|
2660
|
+
signatureKey: exports_zod.string().default("v1").describe("Signature field key in the signature header; multiple entries are allowed"),
|
|
2661
|
+
toleranceSeconds: exports_zod.number().int().positive().default(300).describe("Maximum allowed clock skew, in seconds, for replay protection")
|
|
2662
|
+
}),
|
|
2663
|
+
exports_zod.object({
|
|
2664
|
+
format: exports_zod.literal("token-equality"),
|
|
2665
|
+
header: exports_zod.string().min(1).describe("Header containing the shared token to compare")
|
|
2666
|
+
})
|
|
2667
|
+
]);
|
|
2668
|
+
TriggerConfigSchema = exports_zod.discriminatedUnion("type", [
|
|
2669
|
+
exports_zod.object({
|
|
2670
|
+
type: exports_zod.literal("webhook"),
|
|
2671
|
+
hmacSecret: exports_zod.string().optional(),
|
|
2672
|
+
hmacHeader: exports_zod.string().default("X-Hub-Signature-256").describe("Legacy HMAC header for webhook verification. Prefer verification.header for new workflows."),
|
|
2673
|
+
verification: WebhookVerificationSchema.optional().describe("Optional webhook verification format. Omit to keep legacy HMAC-SHA256 behavior with fallback header scanning.")
|
|
2674
|
+
}),
|
|
2675
|
+
exports_zod.object({
|
|
2676
|
+
type: exports_zod.literal("schedule"),
|
|
2677
|
+
scheduleId: exports_zod.string().uuid()
|
|
2678
|
+
}),
|
|
2679
|
+
exports_zod.object({
|
|
2680
|
+
type: exports_zod.literal("event"),
|
|
2681
|
+
eventName: exports_zod.literal("slack.message")
|
|
2682
|
+
})
|
|
2683
|
+
]).superRefine((trigger, ctx) => {
|
|
2684
|
+
if (trigger.type === "webhook" && trigger.verification && !trigger.hmacSecret) {
|
|
2685
|
+
ctx.addIssue({
|
|
2686
|
+
code: exports_zod.ZodIssueCode.custom,
|
|
2687
|
+
message: "hmacSecret is required when verification is configured",
|
|
2688
|
+
path: ["hmacSecret"]
|
|
2689
|
+
});
|
|
2690
|
+
}
|
|
2691
|
+
});
|
|
2692
|
+
CooldownConfigSchema = exports_zod.object({
|
|
2693
|
+
hours: exports_zod.number().min(0).optional(),
|
|
2694
|
+
minutes: exports_zod.number().min(0).optional(),
|
|
2695
|
+
seconds: exports_zod.number().min(0).optional()
|
|
2696
|
+
}).refine((v) => v.hours !== undefined || v.minutes !== undefined || v.seconds !== undefined, {
|
|
2697
|
+
message: "At least one of hours, minutes, or seconds is required"
|
|
2698
|
+
});
|
|
2699
|
+
InputValueSchema = exports_zod.union([
|
|
2700
|
+
exports_zod.string().regex(/^\$\{.+\}$/),
|
|
2701
|
+
exports_zod.string().regex(/^secret\..+$/),
|
|
2702
|
+
exports_zod.string()
|
|
2703
|
+
]);
|
|
2704
|
+
WorkflowTemplateSchema = exports_zod.object({
|
|
2705
|
+
id: exports_zod.string().uuid(),
|
|
2706
|
+
name: exports_zod.string(),
|
|
2707
|
+
description: exports_zod.string(),
|
|
2708
|
+
category: exports_zod.string(),
|
|
2709
|
+
variables: exports_zod.array(exports_zod.object({
|
|
2710
|
+
name: exports_zod.string(),
|
|
2711
|
+
description: exports_zod.string(),
|
|
2712
|
+
type: exports_zod.enum(["string", "number", "boolean"]),
|
|
2713
|
+
default: exports_zod.unknown().optional(),
|
|
2714
|
+
required: exports_zod.boolean().default(true)
|
|
2715
|
+
})),
|
|
2716
|
+
definition: WorkflowDefinitionSchema
|
|
2717
|
+
}).openapi("WorkflowTemplate");
|
|
2718
|
+
WorkflowSnapshotSchema = exports_zod.object({
|
|
2719
|
+
name: exports_zod.string(),
|
|
2720
|
+
description: exports_zod.string().optional(),
|
|
2721
|
+
definition: WorkflowDefinitionSchema,
|
|
2722
|
+
triggers: exports_zod.array(TriggerConfigSchema),
|
|
2723
|
+
cooldown: CooldownConfigSchema.optional(),
|
|
2724
|
+
input: exports_zod.record(exports_zod.string(), InputValueSchema).optional(),
|
|
2725
|
+
triggerSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2726
|
+
params: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2727
|
+
requiredParams: exports_zod.array(exports_zod.string()).optional(),
|
|
2728
|
+
requires: exports_zod.array(AutomationIntegrationIdSchema).optional(),
|
|
2729
|
+
dir: exports_zod.string().min(1).startsWith("/").optional(),
|
|
2730
|
+
vcsRepo: exports_zod.string().min(1).optional(),
|
|
2731
|
+
enabled: exports_zod.boolean()
|
|
2732
|
+
}).openapi("WorkflowSnapshot");
|
|
2733
|
+
WorkflowSchema = exports_zod.object({
|
|
2734
|
+
id: exports_zod.string().uuid(),
|
|
2735
|
+
key: AssetKeySchema,
|
|
2736
|
+
name: exports_zod.string(),
|
|
2737
|
+
description: exports_zod.string().optional(),
|
|
2738
|
+
enabled: exports_zod.boolean(),
|
|
2739
|
+
definition: WorkflowDefinitionSchema,
|
|
2740
|
+
triggers: exports_zod.array(TriggerConfigSchema).default([]),
|
|
2741
|
+
cooldown: CooldownConfigSchema.optional(),
|
|
2742
|
+
input: exports_zod.record(exports_zod.string(), InputValueSchema).optional(),
|
|
2743
|
+
triggerSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2744
|
+
params: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2745
|
+
requiredParams: exports_zod.array(exports_zod.string()).optional(),
|
|
2746
|
+
requires: exports_zod.array(AutomationIntegrationIdSchema).optional(),
|
|
2747
|
+
dir: exports_zod.string().min(1).startsWith("/").optional(),
|
|
2748
|
+
vcsRepo: exports_zod.string().min(1).optional(),
|
|
2749
|
+
createdByAgentId: exports_zod.string().optional(),
|
|
2750
|
+
createdAt: exports_zod.string(),
|
|
2751
|
+
lastUpdatedAt: exports_zod.string(),
|
|
2752
|
+
createdBy: exports_zod.string().optional(),
|
|
2753
|
+
updatedBy: exports_zod.string().optional(),
|
|
2754
|
+
favorite: exports_zod.boolean().optional()
|
|
2755
|
+
}).openapi("Workflow");
|
|
2756
|
+
WorkflowVersionSchema = exports_zod.object({
|
|
2757
|
+
id: exports_zod.string().uuid(),
|
|
2758
|
+
workflowId: exports_zod.string().uuid(),
|
|
2759
|
+
version: exports_zod.number().int().min(1),
|
|
2760
|
+
snapshot: WorkflowSnapshotSchema,
|
|
2761
|
+
changedByAgentId: exports_zod.string().optional(),
|
|
2762
|
+
createdAt: exports_zod.string()
|
|
2763
|
+
}).openapi("WorkflowVersion");
|
|
2764
|
+
PageContentTypeSchema = exports_zod.enum(["text/html", "application/json", "image/svg+xml"]);
|
|
2765
|
+
PageAuthModeSchema = exports_zod.enum(["public", "authed", "password"]);
|
|
2766
|
+
PageSnapshotSchema = exports_zod.object({
|
|
2767
|
+
title: exports_zod.string(),
|
|
2768
|
+
description: exports_zod.string().optional(),
|
|
2769
|
+
contentType: PageContentTypeSchema,
|
|
2770
|
+
authMode: PageAuthModeSchema,
|
|
2771
|
+
passwordHash: exports_zod.string().optional(),
|
|
2772
|
+
body: exports_zod.string(),
|
|
2773
|
+
needsCredentials: exports_zod.array(exports_zod.string()).optional()
|
|
2774
|
+
}).openapi("PageSnapshot");
|
|
2775
|
+
PageSchema = exports_zod.object({
|
|
2776
|
+
id: exports_zod.string(),
|
|
2777
|
+
key: AssetKeySchema,
|
|
2778
|
+
agentId: exports_zod.string(),
|
|
2779
|
+
slug: exports_zod.string(),
|
|
2780
|
+
title: exports_zod.string(),
|
|
2781
|
+
description: exports_zod.string().optional(),
|
|
2782
|
+
contentType: PageContentTypeSchema,
|
|
2783
|
+
authMode: PageAuthModeSchema,
|
|
2784
|
+
passwordHash: exports_zod.string().optional(),
|
|
2785
|
+
body: exports_zod.string(),
|
|
2786
|
+
needsCredentials: exports_zod.array(exports_zod.string()).optional(),
|
|
2787
|
+
viewCount: exports_zod.number().int().min(0).default(0),
|
|
2788
|
+
createdAt: exports_zod.string(),
|
|
2789
|
+
updatedAt: exports_zod.string(),
|
|
2790
|
+
favorite: exports_zod.boolean().optional()
|
|
2791
|
+
}).openapi("Page");
|
|
2792
|
+
PageVersionSchema = exports_zod.object({
|
|
2793
|
+
id: exports_zod.string(),
|
|
2794
|
+
pageId: exports_zod.string(),
|
|
2795
|
+
version: exports_zod.number().int().min(1),
|
|
2796
|
+
snapshot: PageSnapshotSchema,
|
|
2797
|
+
changedByAgentId: exports_zod.string().optional(),
|
|
2798
|
+
createdAt: exports_zod.string()
|
|
2799
|
+
}).openapi("PageVersion");
|
|
2800
|
+
MetricParamSchema = exports_zod.union([exports_zod.string(), exports_zod.number(), exports_zod.boolean(), exports_zod.null()]);
|
|
2801
|
+
MetricVariableTypeSchema = exports_zod.enum(["text", "number", "select"]);
|
|
2802
|
+
MetricFormatSchema = exports_zod.enum(["number", "integer", "currency", "percent", "duration"]);
|
|
2803
|
+
MetricVisualizationSchema = exports_zod.enum([
|
|
2804
|
+
"stat",
|
|
2805
|
+
"table",
|
|
2806
|
+
"bar",
|
|
2807
|
+
"line",
|
|
2808
|
+
"multi-bar",
|
|
2809
|
+
"multi-line"
|
|
2810
|
+
]);
|
|
2811
|
+
MetricQuerySchema = exports_zod.object({
|
|
2812
|
+
sql: exports_zod.string().min(1).max(1e4),
|
|
2813
|
+
params: exports_zod.array(MetricParamSchema).optional(),
|
|
2814
|
+
maxRows: exports_zod.number().int().min(1).max(500).optional()
|
|
2815
|
+
});
|
|
2816
|
+
MetricVariableSchema = exports_zod.object({
|
|
2817
|
+
key: exports_zod.string().min(1).regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
|
|
2818
|
+
label: exports_zod.string().min(1).optional(),
|
|
2819
|
+
type: MetricVariableTypeSchema.default("text"),
|
|
2820
|
+
defaultValue: MetricParamSchema.optional(),
|
|
2821
|
+
options: exports_zod.array(exports_zod.object({
|
|
2822
|
+
label: exports_zod.string().min(1),
|
|
2823
|
+
value: MetricParamSchema
|
|
2824
|
+
})).optional(),
|
|
2825
|
+
optionsQuery: exports_zod.object({
|
|
2826
|
+
sql: exports_zod.string().min(1).max(1e4),
|
|
2827
|
+
valueKey: exports_zod.string().min(1),
|
|
2828
|
+
labelKey: exports_zod.string().min(1).optional()
|
|
2829
|
+
}).optional()
|
|
2830
|
+
}).openapi("MetricVariable");
|
|
2831
|
+
MetricVizConfigSchema = exports_zod.object({
|
|
2832
|
+
type: MetricVisualizationSchema,
|
|
2833
|
+
x: exports_zod.string().optional(),
|
|
2834
|
+
y: exports_zod.string().optional(),
|
|
2835
|
+
series: exports_zod.array(exports_zod.string()).optional(),
|
|
2836
|
+
label: exports_zod.string().optional(),
|
|
2837
|
+
value: exports_zod.string().optional(),
|
|
2838
|
+
columns: exports_zod.array(exports_zod.object({
|
|
2839
|
+
key: exports_zod.string(),
|
|
2840
|
+
label: exports_zod.string().optional(),
|
|
2841
|
+
format: MetricFormatSchema.optional()
|
|
2842
|
+
})).optional(),
|
|
2843
|
+
format: MetricFormatSchema.optional()
|
|
2844
|
+
}).openapi("MetricVizConfig");
|
|
2845
|
+
MetricWidgetSchema = exports_zod.object({
|
|
2846
|
+
id: exports_zod.string().min(1),
|
|
2847
|
+
title: exports_zod.string().min(1),
|
|
2848
|
+
description: exports_zod.string().optional(),
|
|
2849
|
+
query: MetricQuerySchema,
|
|
2850
|
+
viz: MetricVizConfigSchema,
|
|
2851
|
+
colSpan: exports_zod.number().int().min(1).max(4).optional(),
|
|
2852
|
+
rowSpan: exports_zod.number().int().min(1).max(4).optional()
|
|
2853
|
+
}).openapi("MetricWidget");
|
|
2854
|
+
MetricDefinitionSchema = exports_zod.object({
|
|
2855
|
+
version: exports_zod.literal(1),
|
|
2856
|
+
widgets: exports_zod.array(MetricWidgetSchema).min(1).max(24),
|
|
2857
|
+
variables: exports_zod.array(MetricVariableSchema).max(12).optional(),
|
|
2858
|
+
layout: exports_zod.object({
|
|
2859
|
+
columns: exports_zod.number().int().min(1).max(4).optional()
|
|
2860
|
+
}).optional(),
|
|
2861
|
+
refreshSeconds: exports_zod.number().int().min(5).max(3600).optional()
|
|
2862
|
+
}).openapi("MetricDefinition");
|
|
2863
|
+
MetricSnapshotSchema = exports_zod.object({
|
|
2864
|
+
title: exports_zod.string(),
|
|
2865
|
+
description: exports_zod.string().optional(),
|
|
2866
|
+
definition: MetricDefinitionSchema
|
|
2867
|
+
}).openapi("MetricSnapshot");
|
|
2868
|
+
MetricSchema = exports_zod.object({
|
|
2869
|
+
id: exports_zod.string(),
|
|
2870
|
+
agentId: exports_zod.string(),
|
|
2871
|
+
slug: exports_zod.string(),
|
|
2872
|
+
title: exports_zod.string(),
|
|
2873
|
+
description: exports_zod.string().optional(),
|
|
2874
|
+
definition: MetricDefinitionSchema,
|
|
2875
|
+
createdAt: exports_zod.string(),
|
|
2876
|
+
updatedAt: exports_zod.string()
|
|
2877
|
+
}).openapi("Metric");
|
|
2878
|
+
MetricVersionSchema = exports_zod.object({
|
|
2879
|
+
id: exports_zod.string(),
|
|
2880
|
+
metricId: exports_zod.string(),
|
|
2881
|
+
version: exports_zod.number().int().min(1),
|
|
2882
|
+
snapshot: MetricSnapshotSchema,
|
|
2883
|
+
changedByAgentId: exports_zod.string().optional(),
|
|
2884
|
+
createdAt: exports_zod.string()
|
|
2885
|
+
}).openapi("MetricVersion");
|
|
2886
|
+
WorkflowRunStatusSchema = exports_zod.enum([
|
|
2887
|
+
"running",
|
|
2888
|
+
"waiting",
|
|
2889
|
+
"completed",
|
|
2890
|
+
"failed",
|
|
2891
|
+
"skipped",
|
|
2892
|
+
"cancelled"
|
|
2893
|
+
]);
|
|
2894
|
+
WorkflowRunSchema = exports_zod.object({
|
|
2895
|
+
id: exports_zod.string().uuid(),
|
|
2896
|
+
workflowId: exports_zod.string().uuid(),
|
|
2897
|
+
status: WorkflowRunStatusSchema,
|
|
2898
|
+
triggerData: exports_zod.unknown().optional(),
|
|
2899
|
+
context: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
|
|
2900
|
+
error: exports_zod.string().optional(),
|
|
2901
|
+
createdBy: exports_zod.string().optional(),
|
|
2902
|
+
startedAt: exports_zod.string(),
|
|
2903
|
+
lastUpdatedAt: exports_zod.string(),
|
|
2904
|
+
finishedAt: exports_zod.string().optional()
|
|
2905
|
+
}).openapi("WorkflowRun");
|
|
2906
|
+
ScriptRunStatusSchema = exports_zod.enum([
|
|
2907
|
+
"running",
|
|
2908
|
+
"paused",
|
|
2909
|
+
"completed",
|
|
2910
|
+
"failed",
|
|
2911
|
+
"cancelled",
|
|
2912
|
+
"aborted_limit"
|
|
2913
|
+
]);
|
|
2914
|
+
TERMINAL_SCRIPT_RUN_STATUSES = [
|
|
2915
|
+
"completed",
|
|
2916
|
+
"failed",
|
|
2917
|
+
"cancelled",
|
|
2918
|
+
"aborted_limit"
|
|
2919
|
+
];
|
|
2920
|
+
ScriptRunKindSchema = exports_zod.enum(["workflow", "inline"]);
|
|
2921
|
+
ScriptRunSchema = exports_zod.object({
|
|
2922
|
+
id: exports_zod.string().uuid(),
|
|
2923
|
+
agentId: exports_zod.string(),
|
|
2924
|
+
scriptName: exports_zod.string().optional(),
|
|
2925
|
+
source: exports_zod.string(),
|
|
2926
|
+
args: exports_zod.unknown(),
|
|
2927
|
+
kind: ScriptRunKindSchema,
|
|
2928
|
+
status: ScriptRunStatusSchema,
|
|
2929
|
+
pid: exports_zod.number().int().optional(),
|
|
2930
|
+
startedAt: exports_zod.string(),
|
|
2931
|
+
finishedAt: exports_zod.string().optional(),
|
|
2932
|
+
output: exports_zod.unknown().optional(),
|
|
2933
|
+
error: exports_zod.string().optional(),
|
|
2934
|
+
lastHeartbeatAt: exports_zod.string().optional(),
|
|
2935
|
+
idempotencyKey: exports_zod.string().optional(),
|
|
2936
|
+
requestedByUserId: exports_zod.string().optional()
|
|
2937
|
+
}).openapi("ScriptRun");
|
|
2938
|
+
ScriptRunListItemSchema = ScriptRunSchema.omit({
|
|
2939
|
+
source: true,
|
|
2940
|
+
args: true,
|
|
2941
|
+
output: true
|
|
2942
|
+
});
|
|
2943
|
+
ScriptRunJournalEntrySchema = exports_zod.object({
|
|
2944
|
+
id: exports_zod.string().uuid(),
|
|
2945
|
+
runId: exports_zod.string().uuid(),
|
|
2946
|
+
stepKey: exports_zod.string(),
|
|
2947
|
+
stepType: exports_zod.string(),
|
|
2948
|
+
config: exports_zod.record(exports_zod.string(), exports_zod.unknown()),
|
|
2949
|
+
status: exports_zod.enum(["completed", "failed"]),
|
|
2950
|
+
result: exports_zod.unknown().optional(),
|
|
2951
|
+
error: exports_zod.string().optional(),
|
|
2952
|
+
startedAt: exports_zod.string(),
|
|
2953
|
+
completedAt: exports_zod.string().optional(),
|
|
2954
|
+
durationMs: exports_zod.number().optional()
|
|
2955
|
+
}).openapi("ScriptRunJournalEntry");
|
|
2956
|
+
WorkflowRunStepStatusSchema = exports_zod.enum([
|
|
2957
|
+
"pending",
|
|
2958
|
+
"running",
|
|
2959
|
+
"waiting",
|
|
2960
|
+
"completed",
|
|
2961
|
+
"failed",
|
|
2962
|
+
"skipped",
|
|
2963
|
+
"cancelled"
|
|
2964
|
+
]);
|
|
2965
|
+
WorkflowRunStepSchema = exports_zod.object({
|
|
2966
|
+
id: exports_zod.string().uuid(),
|
|
2967
|
+
runId: exports_zod.string().uuid(),
|
|
2968
|
+
nodeId: exports_zod.string(),
|
|
2969
|
+
nodeType: exports_zod.string(),
|
|
2970
|
+
status: WorkflowRunStepStatusSchema,
|
|
2971
|
+
input: exports_zod.unknown().optional(),
|
|
2972
|
+
output: exports_zod.unknown().optional(),
|
|
2973
|
+
error: exports_zod.string().optional(),
|
|
2974
|
+
startedAt: exports_zod.string(),
|
|
2975
|
+
finishedAt: exports_zod.string().optional(),
|
|
2976
|
+
retryCount: exports_zod.number().int().min(0).default(0),
|
|
2977
|
+
maxRetries: exports_zod.number().int().min(0).default(3),
|
|
2978
|
+
nextRetryAt: exports_zod.string().optional(),
|
|
2979
|
+
idempotencyKey: exports_zod.string().optional(),
|
|
2980
|
+
diagnostics: exports_zod.string().optional(),
|
|
2981
|
+
nextPort: exports_zod.string().optional()
|
|
2982
|
+
}).openapi("WorkflowRunStep");
|
|
2983
|
+
WaitModeSchema = exports_zod.enum(["time", "event"]);
|
|
2984
|
+
WaitStateStatusSchema = exports_zod.enum(["pending", "fired", "timeout"]);
|
|
2985
|
+
WaitStateRowSchema = exports_zod.object({
|
|
2986
|
+
id: exports_zod.string(),
|
|
2987
|
+
workflowRunId: exports_zod.string(),
|
|
2988
|
+
workflowRunStepId: exports_zod.string(),
|
|
2989
|
+
mode: WaitModeSchema,
|
|
2990
|
+
wakeUpAt: exports_zod.string().nullable(),
|
|
2991
|
+
eventName: exports_zod.string().nullable(),
|
|
2992
|
+
eventFilter: exports_zod.union([exports_zod.record(exports_zod.string(), exports_zod.unknown()), exports_zod.string()]).nullable(),
|
|
2993
|
+
expiresAt: exports_zod.string().nullable(),
|
|
2994
|
+
status: WaitStateStatusSchema,
|
|
2995
|
+
firedPayload: exports_zod.unknown().nullable(),
|
|
2996
|
+
resolvedAt: exports_zod.string().nullable(),
|
|
2997
|
+
createdAt: exports_zod.string(),
|
|
2998
|
+
updatedAt: exports_zod.string(),
|
|
2999
|
+
eventScope: exports_zod.enum(["run", "global"])
|
|
3000
|
+
}).openapi("WaitStateRow");
|
|
3001
|
+
PromptTemplateScopeSchema = exports_zod.enum(["global", "agent", "repo"]);
|
|
3002
|
+
PromptTemplateStateSchema = exports_zod.enum([
|
|
3003
|
+
"enabled",
|
|
3004
|
+
"default_prompt_fallback",
|
|
3005
|
+
"skip_event"
|
|
3006
|
+
]);
|
|
3007
|
+
PromptTemplateSchema = exports_zod.object({
|
|
3008
|
+
id: exports_zod.string(),
|
|
3009
|
+
eventType: exports_zod.string(),
|
|
3010
|
+
scope: PromptTemplateScopeSchema,
|
|
3011
|
+
scopeId: exports_zod.string().nullable(),
|
|
3012
|
+
state: PromptTemplateStateSchema,
|
|
3013
|
+
body: exports_zod.string(),
|
|
3014
|
+
isDefault: exports_zod.boolean(),
|
|
3015
|
+
version: exports_zod.number(),
|
|
3016
|
+
createdBy: exports_zod.string().nullable(),
|
|
3017
|
+
createdAt: exports_zod.string(),
|
|
3018
|
+
updatedAt: exports_zod.string()
|
|
3019
|
+
}).openapi("PromptTemplate");
|
|
3020
|
+
PromptTemplateHistorySchema = exports_zod.object({
|
|
3021
|
+
id: exports_zod.string(),
|
|
3022
|
+
templateId: exports_zod.string(),
|
|
3023
|
+
version: exports_zod.number(),
|
|
3024
|
+
body: exports_zod.string(),
|
|
3025
|
+
state: exports_zod.string(),
|
|
3026
|
+
changedBy: exports_zod.string().nullable(),
|
|
3027
|
+
changedAt: exports_zod.string(),
|
|
3028
|
+
changeReason: exports_zod.string().nullable()
|
|
3029
|
+
}).openapi("PromptTemplateHistory");
|
|
3030
|
+
ScriptScopeSchema = exports_zod.enum(["global", "agent"]);
|
|
3031
|
+
ScriptFsModeSchema = exports_zod.enum(["none", "workspace-rw"]);
|
|
3032
|
+
ScriptRecordSchema = exports_zod.object({
|
|
3033
|
+
id: exports_zod.string(),
|
|
3034
|
+
name: exports_zod.string(),
|
|
3035
|
+
scope: ScriptScopeSchema,
|
|
3036
|
+
scopeId: exports_zod.string().nullable(),
|
|
3037
|
+
source: exports_zod.string(),
|
|
3038
|
+
description: exports_zod.string(),
|
|
3039
|
+
intent: exports_zod.string(),
|
|
3040
|
+
signatureJson: exports_zod.string(),
|
|
3041
|
+
argsJsonSchema: exports_zod.string().nullable(),
|
|
3042
|
+
contentHash: exports_zod.string(),
|
|
3043
|
+
version: exports_zod.number(),
|
|
3044
|
+
isScratch: exports_zod.boolean(),
|
|
3045
|
+
typeChecked: exports_zod.boolean(),
|
|
3046
|
+
fsMode: ScriptFsModeSchema,
|
|
3047
|
+
createdByAgentId: exports_zod.string().nullable(),
|
|
3048
|
+
createdAt: exports_zod.string(),
|
|
3049
|
+
updatedAt: exports_zod.string()
|
|
3050
|
+
}).openapi("ScriptRecord");
|
|
3051
|
+
ScriptVersionRecordSchema = exports_zod.object({
|
|
3052
|
+
id: exports_zod.string(),
|
|
3053
|
+
scriptId: exports_zod.string(),
|
|
3054
|
+
version: exports_zod.number(),
|
|
3055
|
+
source: exports_zod.string(),
|
|
3056
|
+
description: exports_zod.string(),
|
|
3057
|
+
intent: exports_zod.string(),
|
|
3058
|
+
signatureJson: exports_zod.string(),
|
|
3059
|
+
contentHash: exports_zod.string(),
|
|
3060
|
+
changedByAgentId: exports_zod.string().nullable(),
|
|
3061
|
+
changedAt: exports_zod.string(),
|
|
3062
|
+
changeReason: exports_zod.string().nullable()
|
|
3063
|
+
}).openapi("ScriptVersionRecord");
|
|
3064
|
+
ExtensionNameSchema = exports_zod.string().min(1).regex(/^[a-z0-9]+(?:-[a-z0-9]+)*$/, "must be a lowercase slug");
|
|
3065
|
+
SemverSchema = exports_zod.string().regex(/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/, "must be a semantic version");
|
|
3066
|
+
ExtensionManifestSchema = exports_zod.object({
|
|
3067
|
+
name: ExtensionNameSchema,
|
|
3068
|
+
description: exports_zod.string(),
|
|
3069
|
+
version: SemverSchema,
|
|
3070
|
+
runtime: exports_zod.enum(["api", "worker"]),
|
|
3071
|
+
assets: exports_zod.object({
|
|
3072
|
+
hooks: exports_zod.string().min(1).refine(isSafeBundlePath, "Must be a relative POSIX file path without empty, dot, or parent segments, at most 256 characters"),
|
|
3073
|
+
skills: exports_zod.array(exports_zod.string()).optional(),
|
|
3074
|
+
workflows: exports_zod.array(exports_zod.string()).optional(),
|
|
3075
|
+
schedules: exports_zod.array(exports_zod.string()).optional()
|
|
3076
|
+
}).strict(),
|
|
3077
|
+
homepage: exports_zod.string().url().optional(),
|
|
3078
|
+
author: exports_zod.string().min(1).optional()
|
|
3079
|
+
}).strict().openapi("ExtensionManifest");
|
|
3080
|
+
ExtensionStatusSchema = exports_zod.enum(["disabled", "enabled", "error", "auto-disabled"]);
|
|
3081
|
+
ExtensionSchema = exports_zod.object({
|
|
3082
|
+
id: exports_zod.string(),
|
|
3083
|
+
name: ExtensionNameSchema,
|
|
3084
|
+
description: exports_zod.string(),
|
|
3085
|
+
runtime: exports_zod.enum(["api", "worker"]),
|
|
3086
|
+
manifestJson: exports_zod.string(),
|
|
3087
|
+
contentHash: exports_zod.string(),
|
|
3088
|
+
version: exports_zod.number().int().min(1),
|
|
3089
|
+
activeVersion: exports_zod.number().int().min(1),
|
|
3090
|
+
enabled: exports_zod.boolean(),
|
|
3091
|
+
priority: exports_zod.number().int(),
|
|
3092
|
+
configJson: exports_zod.string(),
|
|
3093
|
+
status: ExtensionStatusSchema,
|
|
3094
|
+
consecutiveFailures: exports_zod.number().int().min(0),
|
|
3095
|
+
lastError: exports_zod.string().nullable(),
|
|
3096
|
+
agentId: exports_zod.string().nullable(),
|
|
3097
|
+
createdByAgentId: exports_zod.string().nullable(),
|
|
3098
|
+
createdAt: exports_zod.string(),
|
|
3099
|
+
updatedAt: exports_zod.string()
|
|
3100
|
+
}).openapi("Extension");
|
|
3101
|
+
ExtensionFileSchema = exports_zod.object({
|
|
3102
|
+
id: exports_zod.string(),
|
|
3103
|
+
extensionId: exports_zod.string(),
|
|
3104
|
+
path: exports_zod.string(),
|
|
3105
|
+
content: exports_zod.string(),
|
|
3106
|
+
contentHash: exports_zod.string()
|
|
3107
|
+
}).openapi("ExtensionFile");
|
|
3108
|
+
ExtensionVersionSchema = exports_zod.object({
|
|
3109
|
+
id: exports_zod.string(),
|
|
3110
|
+
extensionId: exports_zod.string(),
|
|
3111
|
+
version: exports_zod.number().int().min(1),
|
|
3112
|
+
manifestJson: exports_zod.string(),
|
|
3113
|
+
filesJson: exports_zod.string(),
|
|
3114
|
+
contentHash: exports_zod.string(),
|
|
3115
|
+
changedByAgentId: exports_zod.string().nullable(),
|
|
3116
|
+
changedAt: exports_zod.string(),
|
|
3117
|
+
changeReason: exports_zod.string().nullable()
|
|
3118
|
+
}).openapi("ExtensionVersion");
|
|
3119
|
+
ExtensionRunSchema = exports_zod.object({
|
|
3120
|
+
id: exports_zod.string(),
|
|
3121
|
+
extensionId: exports_zod.string(),
|
|
3122
|
+
version: exports_zod.number().int().min(1),
|
|
3123
|
+
event: exports_zod.string(),
|
|
3124
|
+
action: exports_zod.enum(["continue", "modify", "block", "error", "timeout", "load-error"]),
|
|
3125
|
+
durationMs: exports_zod.number().int().nullable(),
|
|
3126
|
+
message: exports_zod.string().nullable(),
|
|
3127
|
+
agentId: exports_zod.string().nullable(),
|
|
3128
|
+
subject: exports_zod.string().nullable(),
|
|
3129
|
+
createdAt: exports_zod.string()
|
|
3130
|
+
}).openapi("ExtensionRun");
|
|
3131
|
+
ExtensionInstallBodySchema = exports_zod.object({
|
|
3132
|
+
manifest: ExtensionManifestSchema,
|
|
3133
|
+
files: exports_zod.record(exports_zod.string(), exports_zod.string()),
|
|
3134
|
+
priority: exports_zod.number().int().optional(),
|
|
3135
|
+
config: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional()
|
|
3136
|
+
}).strict().openapi("ExtensionInstallBody");
|
|
3137
|
+
ScriptApiAuthModeSchema = exports_zod.enum(["none", "bearer"]);
|
|
3138
|
+
ScriptApiRecordSchema = exports_zod.object({
|
|
3139
|
+
id: exports_zod.string(),
|
|
3140
|
+
scriptId: exports_zod.string(),
|
|
3141
|
+
agentId: exports_zod.string(),
|
|
3142
|
+
authMode: ScriptApiAuthModeSchema,
|
|
3143
|
+
enabled: exports_zod.boolean(),
|
|
3144
|
+
label: exports_zod.string().nullable(),
|
|
3145
|
+
callCount: exports_zod.number(),
|
|
3146
|
+
lastUsedAt: exports_zod.string().nullable(),
|
|
3147
|
+
createdAt: exports_zod.string()
|
|
3148
|
+
}).openapi("ScriptApiRecord");
|
|
3149
|
+
SkillTypeSchema = exports_zod.enum(["remote", "personal"]);
|
|
3150
|
+
SkillScopeSchema = exports_zod.enum(["global", "swarm", "agent"]);
|
|
3151
|
+
SkillSchema = exports_zod.object({
|
|
3152
|
+
id: exports_zod.string(),
|
|
3153
|
+
name: exports_zod.string(),
|
|
3154
|
+
description: exports_zod.string(),
|
|
3155
|
+
content: exports_zod.string(),
|
|
3156
|
+
type: SkillTypeSchema,
|
|
3157
|
+
scope: SkillScopeSchema,
|
|
3158
|
+
ownerAgentId: exports_zod.string().nullable(),
|
|
3159
|
+
sourceUrl: exports_zod.string().nullable(),
|
|
3160
|
+
sourceRepo: exports_zod.string().nullable(),
|
|
3161
|
+
sourcePath: exports_zod.string().nullable(),
|
|
3162
|
+
sourceBranch: exports_zod.string(),
|
|
3163
|
+
sourceHash: exports_zod.string().nullable(),
|
|
3164
|
+
isComplex: exports_zod.boolean(),
|
|
3165
|
+
allowedTools: exports_zod.string().nullable(),
|
|
3166
|
+
model: exports_zod.string().nullable(),
|
|
3167
|
+
effort: exports_zod.string().nullable(),
|
|
3168
|
+
context: exports_zod.string().nullable(),
|
|
3169
|
+
agent: exports_zod.string().nullable(),
|
|
3170
|
+
disableModelInvocation: exports_zod.boolean(),
|
|
3171
|
+
userInvocable: exports_zod.boolean(),
|
|
3172
|
+
version: exports_zod.number(),
|
|
3173
|
+
isEnabled: exports_zod.boolean(),
|
|
3174
|
+
systemDefault: exports_zod.boolean(),
|
|
3175
|
+
createdAt: exports_zod.string(),
|
|
3176
|
+
lastUpdatedAt: exports_zod.string(),
|
|
3177
|
+
lastFetchedAt: exports_zod.string().nullable()
|
|
3178
|
+
}).openapi("Skill");
|
|
3179
|
+
AgentSkillSchema = exports_zod.object({
|
|
3180
|
+
id: exports_zod.string(),
|
|
3181
|
+
agentId: exports_zod.string(),
|
|
3182
|
+
skillId: exports_zod.string(),
|
|
3183
|
+
isActive: exports_zod.boolean(),
|
|
3184
|
+
installedAt: exports_zod.string()
|
|
3185
|
+
}).openapi("AgentSkill");
|
|
3186
|
+
SkillWithInstallInfoSchema = SkillSchema.extend({
|
|
3187
|
+
isActive: exports_zod.boolean(),
|
|
3188
|
+
installedAt: exports_zod.string()
|
|
3189
|
+
});
|
|
3190
|
+
SkillFileSchema = exports_zod.object({
|
|
3191
|
+
id: exports_zod.string(),
|
|
3192
|
+
skillId: exports_zod.string(),
|
|
3193
|
+
path: exports_zod.string(),
|
|
3194
|
+
content: exports_zod.string(),
|
|
3195
|
+
mimeType: exports_zod.string(),
|
|
3196
|
+
isBinary: exports_zod.boolean(),
|
|
3197
|
+
size: exports_zod.number().nullable(),
|
|
3198
|
+
createdAt: exports_zod.string(),
|
|
3199
|
+
lastUpdatedAt: exports_zod.string()
|
|
3200
|
+
}).openapi("SkillFile");
|
|
3201
|
+
McpServerTransportSchema = exports_zod.enum(["stdio", "http", "sse"]);
|
|
3202
|
+
McpServerScopeSchema = exports_zod.enum(["global", "swarm", "agent"]);
|
|
3203
|
+
McpAuthMethodSchema = exports_zod.enum(["static", "oauth", "auto"]);
|
|
3204
|
+
McpServerSchema = exports_zod.object({
|
|
3205
|
+
id: exports_zod.string(),
|
|
3206
|
+
name: exports_zod.string(),
|
|
3207
|
+
description: exports_zod.string().nullable(),
|
|
3208
|
+
scope: McpServerScopeSchema,
|
|
3209
|
+
ownerAgentId: exports_zod.string().nullable(),
|
|
3210
|
+
transport: McpServerTransportSchema,
|
|
3211
|
+
command: exports_zod.string().nullable(),
|
|
3212
|
+
args: exports_zod.string().nullable(),
|
|
3213
|
+
url: exports_zod.string().nullable(),
|
|
3214
|
+
headers: exports_zod.string().nullable(),
|
|
3215
|
+
envConfigKeys: exports_zod.string().nullable(),
|
|
3216
|
+
headerConfigKeys: exports_zod.string().nullable(),
|
|
3217
|
+
extraAuthorizeParams: exports_zod.string().nullable(),
|
|
3218
|
+
authMethod: McpAuthMethodSchema.default("static"),
|
|
3219
|
+
isEnabled: exports_zod.boolean(),
|
|
3220
|
+
version: exports_zod.number(),
|
|
3221
|
+
createdAt: exports_zod.string(),
|
|
3222
|
+
lastUpdatedAt: exports_zod.string()
|
|
3223
|
+
}).openapi("McpServer");
|
|
3224
|
+
AgentMcpServerSchema = exports_zod.object({
|
|
3225
|
+
id: exports_zod.string(),
|
|
3226
|
+
agentId: exports_zod.string(),
|
|
3227
|
+
mcpServerId: exports_zod.string(),
|
|
3228
|
+
isActive: exports_zod.boolean(),
|
|
3229
|
+
installedAt: exports_zod.string()
|
|
3230
|
+
}).openapi("AgentMcpServer");
|
|
3231
|
+
McpServerWithInstallInfoSchema = McpServerSchema.extend({
|
|
3232
|
+
isActive: exports_zod.boolean(),
|
|
3233
|
+
installedAt: exports_zod.string()
|
|
3234
|
+
});
|
|
3235
|
+
ContextSnapshotEventTypeSchema = exports_zod.enum(["progress", "compaction", "completion"]);
|
|
3236
|
+
ContextFormulaSchema = exports_zod.enum([
|
|
3237
|
+
"input-cache-output",
|
|
3238
|
+
"input-cache-no-output",
|
|
3239
|
+
"input-output-no-cache",
|
|
3240
|
+
"peak-proxy",
|
|
3241
|
+
"pi-delegated",
|
|
3242
|
+
"harness-reported",
|
|
3243
|
+
"unknown"
|
|
3244
|
+
]);
|
|
3245
|
+
ContextSnapshotSchema = exports_zod.object({
|
|
3246
|
+
id: exports_zod.uuid(),
|
|
3247
|
+
taskId: exports_zod.uuid(),
|
|
3248
|
+
agentId: exports_zod.string(),
|
|
3249
|
+
sessionId: exports_zod.string(),
|
|
3250
|
+
contextUsedTokens: exports_zod.number().int().min(0).optional(),
|
|
3251
|
+
contextTotalTokens: exports_zod.number().int().min(0).optional(),
|
|
3252
|
+
contextPercent: exports_zod.number().min(0).max(100).optional(),
|
|
3253
|
+
eventType: ContextSnapshotEventTypeSchema,
|
|
3254
|
+
compactTrigger: exports_zod.enum(["auto", "manual", "auto-inferred"]).optional(),
|
|
3255
|
+
preCompactTokens: exports_zod.number().int().min(0).optional(),
|
|
3256
|
+
cumulativeInputTokens: exports_zod.number().int().min(0).default(0),
|
|
3257
|
+
cumulativeOutputTokens: exports_zod.number().int().min(0).default(0),
|
|
3258
|
+
contextFormula: ContextFormulaSchema.optional(),
|
|
3259
|
+
createdAt: exports_zod.iso.datetime()
|
|
3260
|
+
}).openapi("ContextSnapshot");
|
|
3261
|
+
BudgetScopeSchema = exports_zod.enum(["global", "agent", "user"]);
|
|
3262
|
+
BudgetSchema = exports_zod.object({
|
|
3263
|
+
scope: BudgetScopeSchema,
|
|
3264
|
+
scopeId: exports_zod.string(),
|
|
3265
|
+
dailyBudgetUsd: exports_zod.number().nonnegative(),
|
|
3266
|
+
createdAt: exports_zod.number(),
|
|
3267
|
+
lastUpdatedAt: exports_zod.number()
|
|
3268
|
+
}).openapi("Budget");
|
|
3269
|
+
PricingProviderSchema = exports_zod.enum([
|
|
3270
|
+
"claude",
|
|
3271
|
+
"claude-managed",
|
|
3272
|
+
"codex",
|
|
3273
|
+
"pi",
|
|
3274
|
+
"opencode",
|
|
3275
|
+
"devin",
|
|
3276
|
+
"gemini",
|
|
3277
|
+
"acp"
|
|
3278
|
+
]);
|
|
3279
|
+
PricingTokenClassSchema = exports_zod.enum([
|
|
3280
|
+
"input",
|
|
3281
|
+
"cached_input",
|
|
3282
|
+
"output",
|
|
3283
|
+
"cache_write",
|
|
3284
|
+
"cache_write_1h",
|
|
3285
|
+
"web_search",
|
|
3286
|
+
"runtime_hour",
|
|
3287
|
+
"acu"
|
|
3288
|
+
]);
|
|
3289
|
+
PricingRowSchema = exports_zod.object({
|
|
3290
|
+
provider: PricingProviderSchema,
|
|
3291
|
+
model: exports_zod.string(),
|
|
3292
|
+
tokenClass: PricingTokenClassSchema,
|
|
3293
|
+
effectiveFrom: exports_zod.number().nonnegative(),
|
|
3294
|
+
pricePerMillionUsd: exports_zod.number().nonnegative(),
|
|
3295
|
+
createdAt: exports_zod.number(),
|
|
3296
|
+
lastUpdatedAt: exports_zod.number()
|
|
3297
|
+
}).openapi("PricingRow");
|
|
3298
|
+
BudgetRefusalCauseSchema = exports_zod.enum(["agent", "global", "user"]);
|
|
3299
|
+
BudgetRefusalNotificationSchema = exports_zod.object({
|
|
3300
|
+
taskId: exports_zod.string(),
|
|
3301
|
+
date: exports_zod.string(),
|
|
3302
|
+
agentId: exports_zod.string(),
|
|
3303
|
+
cause: BudgetRefusalCauseSchema,
|
|
3304
|
+
agentSpendUsd: exports_zod.number().nullable().optional(),
|
|
3305
|
+
agentBudgetUsd: exports_zod.number().nullable().optional(),
|
|
3306
|
+
globalSpendUsd: exports_zod.number().nullable().optional(),
|
|
3307
|
+
globalBudgetUsd: exports_zod.number().nullable().optional(),
|
|
3308
|
+
userSpendUsd: exports_zod.number().nullable().optional(),
|
|
3309
|
+
userBudgetUsd: exports_zod.number().nullable().optional(),
|
|
3310
|
+
followUpTaskId: exports_zod.string().nullable().optional(),
|
|
3311
|
+
createdAt: exports_zod.number()
|
|
3312
|
+
}).openapi("BudgetRefusalNotification");
|
|
3313
|
+
BudgetRefusedTriggerSchema = exports_zod.object({
|
|
3314
|
+
type: exports_zod.literal("budget_refused"),
|
|
3315
|
+
cause: BudgetRefusalCauseSchema,
|
|
3316
|
+
agentSpend: exports_zod.number().optional(),
|
|
3317
|
+
agentBudget: exports_zod.number().optional(),
|
|
3318
|
+
globalSpend: exports_zod.number().optional(),
|
|
3319
|
+
globalBudget: exports_zod.number().optional(),
|
|
3320
|
+
userSpend: exports_zod.number().optional(),
|
|
3321
|
+
userBudget: exports_zod.number().optional(),
|
|
3322
|
+
resetAt: exports_zod.string()
|
|
3323
|
+
}).openapi("BudgetRefusedTrigger");
|
|
3324
|
+
KvValueTypeSchema = exports_zod.enum(["json", "string", "integer"]);
|
|
3325
|
+
KV_NAME_REGEX = /^[a-zA-Z0-9._:/%-]{1,512}$/;
|
|
3326
|
+
KvNamespaceSchema = exports_zod.string().min(1).max(512).regex(KV_NAME_REGEX, "namespace must match [a-zA-Z0-9._:/%-]{1,512}");
|
|
3327
|
+
KvKeySchema = exports_zod.string().min(1).max(512).regex(KV_NAME_REGEX, "key must match [a-zA-Z0-9._:/%-]{1,512}");
|
|
3328
|
+
KvEntrySchema = exports_zod.object({
|
|
3329
|
+
namespace: exports_zod.string(),
|
|
3330
|
+
key: exports_zod.string(),
|
|
3331
|
+
value: exports_zod.unknown(),
|
|
3332
|
+
valueType: KvValueTypeSchema,
|
|
3333
|
+
expiresAt: exports_zod.number().int().nullable(),
|
|
3334
|
+
createdAt: exports_zod.number().int(),
|
|
3335
|
+
updatedAt: exports_zod.number().int()
|
|
3336
|
+
}).openapi("KvEntry");
|
|
3337
|
+
});
|
|
3338
|
+
|
|
3339
|
+
export { normalizeAssetKey, defaultAssetKey, parseAssetKey, isCanonicalAssetKey, canWriteAssetKey, init_key, isSafeBundlePath, init_bundle_path, $OpenAPIRegistry, $OpenApiGeneratorV31, init_dist, init_zod_openapi, AssetKeySchema, AssetEntityTypeSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, ReasoningEffortSchema, DEFAULT_MODEL_TIER_MAP, parseModelTier, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, RoutingReasonSchema, ProviderNameSchema, SteerModeSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, CreateTaskOptionsSchema, SERVER_GENERATED_ATTACHMENT_CAPABILITY, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, UserCommsPrefsSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentLatestModelSchema, AgentAcpStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, VersionableFieldSchema, ChannelTypeSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, AutomationIntegrationIdSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesInputSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, RuntimeInstanceSchema, WorkflowEdgeSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, WorkflowSchema, WorkflowVersionSchema, PageContentTypeSchema, PageAuthModeSchema, PageSchema, PageVersionSchema, MetricWidgetSchema, MetricDefinitionSchema, MetricSchema, MetricVersionSchema, WorkflowRunStatusSchema, WorkflowRunSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, ScriptRunSchema, ScriptRunListItemSchema, ScriptRunJournalEntrySchema, WorkflowRunStepSchema, PromptTemplateScopeSchema, PromptTemplateStateSchema, PromptTemplateSchema, PromptTemplateHistorySchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptRecordSchema, ScriptVersionRecordSchema, ExtensionManifestSchema, ExtensionSchema, ExtensionVersionSchema, ExtensionRunSchema, ExtensionInstallBodySchema, ScriptApiAuthModeSchema, ScriptApiRecordSchema, SkillSchema, AgentSkillSchema, SkillWithInstallInfoSchema, SkillFileSchema, McpAuthMethodSchema, McpServerSchema, AgentMcpServerSchema, McpServerWithInstallInfoSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, ContextSnapshotSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, BudgetRefusedTriggerSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, KvEntrySchema, init_types };
|