@desplega.ai/agent-swarm 1.129.0 → 1.131.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.
Files changed (226) hide show
  1. package/README.md +2 -2
  2. package/dist/{actions-kfv2dawe.js → actions-w53mbns9.js} +11 -11
  3. package/dist/{anthropic-messages-3xgme8my.js → anthropic-messages-rjmd2e7n.js} +5 -5
  4. package/dist/{app-q8vjk6e8.js → app-m9gwqsqv.js} +8 -8
  5. package/dist/{artifact-hg4t1nx7.js → artifact-jysj3wrg.js} +2 -2
  6. package/dist/{assistant-g037r345.js → assistant-bp65m6f3.js} +13 -13
  7. package/dist/{azure-openai-responses-xa4sh9f6.js → azure-openai-responses-c0yjmbfd.js} +8 -5
  8. package/dist/{boot-reembed-18pzsrxa.js → boot-reembed-62p0at2k.js} +6 -6
  9. package/dist/{boot-reembed-wpks2cj8.js → boot-reembed-xmfp6wdh.js} +7 -7
  10. package/dist/{boot-scrub-logs-n7szd57r.js → boot-scrub-logs-rr8q2dms.js} +5 -5
  11. package/dist/{claude-adapter-qz4r0ajt.js → claude-adapter-2y47mrkd.js} +9 -9
  12. package/dist/{cli-mhjnbgb6.js → cli-0rcyq6d9.js} +450 -186
  13. package/dist/{cli-ttkmehy0.js → cli-2q72qz2s.js} +274 -25
  14. package/dist/{cli-gztgc3hz.js → cli-2wadx7p2.js} +2 -2
  15. package/dist/cli-3fj60etf.js +153 -0
  16. package/dist/{cli-7ecgm5v0.js → cli-3kf51j15.js} +1 -1
  17. package/dist/{cli-vgexpfsr.js → cli-57khth04.js} +6 -3
  18. package/dist/{cli-2mbe7vk0.js → cli-5dsbcjjw.js} +1 -1
  19. package/dist/{cli-etr62zy6.js → cli-5kx36evn.js} +2 -2
  20. package/dist/{cli-v2tr6amf.js → cli-5n6e5yfn.js} +30 -8
  21. package/dist/{cli-hx02s9zq.js → cli-5v4rw6yd.js} +2 -2
  22. package/dist/{cli-v37yr6mf.js → cli-5ze9rv97.js} +4 -4
  23. package/dist/{cli-ch7t5v7n.js → cli-6map995v.js} +9 -4
  24. package/dist/{cli-h0457a67.js → cli-70xqj0z3.js} +3 -3
  25. package/dist/{cli-kk4f9r17.js → cli-72q8m8gk.js} +8 -6
  26. package/dist/{cli-7padk69a.js → cli-78xwvkhj.js} +2 -2
  27. package/dist/{cli-dxtxacy7.js → cli-9dr5qzc0.js} +45 -8
  28. package/dist/{cli-17zxdgsq.js → cli-a40rnf71.js} +6 -6
  29. package/dist/{cli-t53vnnxz.js → cli-a4jzdpa3.js} +2514 -1055
  30. package/dist/{cli-w10fkrf1.js → cli-akdvwc9v.js} +354 -115
  31. package/dist/{cli-1qkk5er0.js → cli-bmze986d.js} +1 -1
  32. package/dist/{cli-ga12dc1d.js → cli-bqw0mt1n.js} +3 -3
  33. package/dist/{cli-0sf92efp.js → cli-cdeg08wx.js} +1 -1
  34. package/dist/{cli-a8ynhkyj.js → cli-cvgjwnh1.js} +17 -15
  35. package/dist/{cli-9fxg3v5m.js → cli-d2tfkcga.js} +4 -4
  36. package/dist/{cli-nhcd7x43.js → cli-d3x3x1c9.js} +2 -2
  37. package/dist/{cli-6nh2qxvh.js → cli-darcwax3.js} +1 -1
  38. package/dist/{cli-yjbgmysx.js → cli-e7ckcg4v.js} +12 -12
  39. package/dist/{cli-4n2gcjpd.js → cli-efxfnq6q.js} +4 -3
  40. package/dist/{cli-z9xqqhfk.js → cli-er3a4bb0.js} +1 -1
  41. package/dist/{cli-xg2eezyv.js → cli-f1am9szv.js} +1 -1
  42. package/dist/{cli-xy4cwsm9.js → cli-fywms69x.js} +1 -1
  43. package/dist/{cli-33jj76y8.js → cli-g6b8x1h8.js} +1 -1
  44. package/dist/{cli-epsvdckx.js → cli-gm9cbhbq.js} +20 -10
  45. package/dist/{cli-rkndnn90.js → cli-k9qkf1hw.js} +6 -4
  46. package/dist/{cli-zejvt395.js → cli-kh3ba2zf.js} +1 -1
  47. package/dist/{cli-gb25p1h2.js → cli-nm5gtp1x.js} +2 -2
  48. package/dist/{cli-akxnpx17.js → cli-pm6xbh84.js} +1829 -1629
  49. package/dist/{cli-2k0ztbfp.js → cli-psh3c4va.js} +1 -1
  50. package/dist/{cli-39vgrsep.js → cli-qv61hp37.js} +2 -2
  51. package/dist/{cli-hv2fndhm.js → cli-r6kqqbj0.js} +6 -4
  52. package/dist/{cli-1y1cm570.js → cli-rzbpmxdr.js} +1 -1
  53. package/dist/{cli-mmrk00vp.js → cli-t1xze5qh.js} +1 -1
  54. package/dist/{cli-g252a9ky.js → cli-t55yw3a1.js} +2 -2
  55. package/dist/{cli-7bz8dzqa.js → cli-t76vw5db.js} +1184 -1522
  56. package/dist/{cli-4n4mdv21.js → cli-xpxde7rm.js} +7 -3
  57. package/dist/{cli-fpaa5k2q.js → cli-yw8vghx2.js} +54 -18
  58. package/dist/cli-zsspvvm2.js +490 -0
  59. package/dist/cli.js +27 -25
  60. package/dist/{codex-adapter-7v6t7ff6.js → codex-adapter-d24q75wk.js} +7 -7
  61. package/dist/{codex-hook-amndawyb.js → codex-hook-hq54t9ft.js} +2 -2
  62. package/dist/{codex-session-runner-e7j4khe2.js → codex-session-runner-g50vcsex.js} +7 -7
  63. package/dist/{commands-ex0k5tbf.js → commands-c3nrc5hg.js} +5 -5
  64. package/dist/{db-df7jatfc.js → db-nt7fg3tw.js} +5 -5
  65. package/dist/{google-generative-ai-y42hnw9p.js → google-generative-ai-hysrd8qx.js} +7 -5
  66. package/dist/{google-vertex-4sg66gb6.js → google-vertex-p5arrga0.js} +7 -5
  67. package/dist/{handlers-1j2cfqt2.js → handlers-fkr6swat.js} +13 -13
  68. package/dist/{hook-nx9a0mj3.js → hook-77wpvnjc.js} +7 -7
  69. package/dist/{hook-w6yaf6sy.js → hook-g019yehy.js} +8 -8
  70. package/dist/{http-4tz5h8wg.js → http-jewj0syk.js} +2993 -716
  71. package/dist/{index-0bpkzb09.js → index-070v4eyb.js} +3 -3
  72. package/dist/{index-0s67qv7h.js → index-6gm5he8h.js} +11 -11
  73. package/dist/{index-35gtv6gj.js → index-7n2xpbd4.js} +310 -40
  74. package/dist/{index-ker3gccb.js → index-9znhar3x.js} +4 -4
  75. package/dist/{index-5n2c8yay.js → index-hase6zbe.js} +2 -2
  76. package/dist/{index-kcf3tm9h.js → index-hfvggd0z.js} +12 -12
  77. package/dist/{index-7c0jqna0.js → index-hp1kdbjj.js} +13 -13
  78. package/dist/{keepalive-3j4a9168.js → keepalive-j0fjvqfd.js} +7 -7
  79. package/dist/{lead-6kpevymb.js → lead-1n8x30xe.js} +33 -33
  80. package/dist/{maintenance-m1k82ean.js → maintenance-gvev11sa.js} +7 -7
  81. package/dist/{mistral-conversations-bjkdfb6z.js → mistral-conversations-81fwav0j.js} +6 -6
  82. package/dist/{oauth-refresh-sweep-881k8e4q.js → oauth-refresh-sweep-s9ecsvh0.js} +6 -6
  83. package/dist/{onboard-c0ykffjn.js → onboard-pvm5b38w.js} +2 -2
  84. package/dist/{openai-codex-responses-xetseqvt.js → openai-codex-responses-5g27pd6f.js} +43 -23
  85. package/dist/{openai-completions-5r2g5axa.js → openai-completions-3vkmfz2a.js} +55 -11
  86. package/dist/{openai-responses-ce67hd23.js → openai-responses-dg4t7j7a.js} +8 -5
  87. package/dist/{openrouter-images-pzfp22jb.js → openrouter-images-g3gm8931.js} +1 -1
  88. package/dist/{otel-impl-sqagjerv.js → otel-impl-p6jvgd9c.js} +6 -4
  89. package/dist/{otel-3mp81ppd.js → otel-nqa12wf3.js} +2 -2
  90. package/dist/{pi-mono-adapter-k584k16g.js → pi-mono-adapter-t091s27g.js} +17117 -7517
  91. package/dist/{pricing-refresh-y82whbf9.js → pricing-refresh-k49rcyed.js} +7 -7
  92. package/dist/{rbac-roles-nvkqmzyd.js → rbac-roles-30pspvy7.js} +7 -7
  93. package/dist/{rbac-roles-4ht8gegc.js → rbac-roles-cr80g96t.js} +6 -6
  94. package/dist/{render-v2-wvqdgvvp.js → render-v2-xm457ng1.js} +8 -8
  95. package/dist/{seed-pricing-fy3rxhde.js → seed-pricing-yhpv35fr.js} +6 -6
  96. package/dist/{setup-ak5cnc6f.js → setup-nytnmwwr.js} +2 -2
  97. package/dist/{worker-d8769q8a.js → worker-msytr2cw.js} +33 -33
  98. package/openapi.json +34039 -11036
  99. package/package.json +8 -6
  100. package/src/apps/definition.ts +368 -26
  101. package/src/apps/row-store.ts +66 -10
  102. package/src/apps/schema-migrate.ts +95 -1
  103. package/src/apps/store.ts +13 -4
  104. package/src/apps/sync-run-as.ts +18 -0
  105. package/src/apps/sync.ts +934 -0
  106. package/src/apps/version.ts +16 -2
  107. package/src/assets/key.ts +8 -1
  108. package/src/be/asset-key-audit.ts +3 -1
  109. package/src/be/db-queries/mcp-oauth.ts +297 -24
  110. package/src/be/db.ts +42 -1
  111. package/src/be/migrations/129_asset_keys_apps_scripts.sql +161 -0
  112. package/src/be/scripts/db.ts +5 -2
  113. package/src/be/scripts/typecheck.ts +1 -0
  114. package/src/be/seed-scripts/catalog/app-sync-run.ts +32 -0
  115. package/src/be/seed-scripts/catalog/github-issues-pull.ts +102 -0
  116. package/src/be/seed-scripts/index.ts +18 -0
  117. package/src/be/seed-skills/index.ts +7 -0
  118. package/src/http/active-sessions.ts +26 -18
  119. package/src/http/agents.ts +94 -27
  120. package/src/http/api-keys.ts +91 -17
  121. package/src/http/approval-requests.ts +87 -10
  122. package/src/http/apps.ts +361 -53
  123. package/src/http/assets.ts +165 -31
  124. package/src/http/budgets.ts +7 -5
  125. package/src/http/codex-oauth-keep-warm.ts +21 -3
  126. package/src/http/config.ts +46 -16
  127. package/src/http/context.ts +33 -6
  128. package/src/http/ecosystem.ts +20 -6
  129. package/src/http/events.ts +24 -9
  130. package/src/http/favorites.ts +20 -6
  131. package/src/http/fs.ts +60 -17
  132. package/src/http/heartbeat.ts +18 -4
  133. package/src/http/inbox-state.ts +12 -6
  134. package/src/http/integrations.ts +25 -5
  135. package/src/http/kv.ts +36 -15
  136. package/src/http/mcp-bridge.ts +5 -1
  137. package/src/http/mcp-oauth.ts +332 -17
  138. package/src/http/mcp-servers.ts +56 -18
  139. package/src/http/memory.ts +282 -29
  140. package/src/http/metrics.ts +80 -17
  141. package/src/http/oauth-callback.ts +10 -4
  142. package/src/http/oauth-generic.ts +5 -1
  143. package/src/http/oauth-locks.ts +6 -3
  144. package/src/http/openapi.ts +57 -9
  145. package/src/http/page-proxy.ts +25 -5
  146. package/src/http/pages-public.ts +37 -20
  147. package/src/http/pages.ts +93 -28
  148. package/src/http/poll.ts +89 -5
  149. package/src/http/pricing.ts +9 -6
  150. package/src/http/prompt-templates.ts +85 -21
  151. package/src/http/route-def.ts +67 -4
  152. package/src/http/schedules.ts +63 -14
  153. package/src/http/script-connection-proxy.ts +30 -4
  154. package/src/http/script-connections.ts +393 -43
  155. package/src/http/script-runs.ts +73 -19
  156. package/src/http/scripts.ts +257 -39
  157. package/src/http/session-data.ts +87 -14
  158. package/src/http/sessions.ts +80 -5
  159. package/src/http/skills.ts +115 -35
  160. package/src/http/stats.ts +94 -13
  161. package/src/http/task-templates.ts +6 -4
  162. package/src/http/tasks.ts +230 -61
  163. package/src/http/trackers/jira.ts +90 -30
  164. package/src/http/trackers/linear.ts +46 -12
  165. package/src/http/users.ts +162 -25
  166. package/src/http/utils.ts +12 -2
  167. package/src/http/webhooks.ts +30 -16
  168. package/src/http/workflow-events.ts +18 -5
  169. package/src/http/workflows.ts +128 -39
  170. package/src/http/x.ts +37 -6
  171. package/src/oauth/ensure-mcp-token.ts +16 -1
  172. package/src/oauth/mcp-wrapper.ts +281 -26
  173. package/src/providers/pi-mono-adapter.ts +1 -1
  174. package/src/scripts-runtime/credential-broker/README.md +1 -1
  175. package/src/scripts-runtime/credential-broker/fetch-patch.ts +12 -2
  176. package/src/scripts-runtime/sdk-allowlist.ts +1 -0
  177. package/src/scripts-runtime/stdlib/fetch.ts +6 -0
  178. package/src/scripts-runtime/types/stdlib.d.ts +1 -0
  179. package/src/scripts-runtime/types/swarm-sdk.d.ts +1 -0
  180. package/src/server.ts +2 -0
  181. package/src/tests/apps-rbac.test.ts +110 -0
  182. package/src/tests/apps-spike2.test.ts +4 -1
  183. package/src/tests/apps-sync-engine.test.ts +2540 -0
  184. package/src/tests/apps-sync.test.ts +1627 -0
  185. package/src/tests/asset-key-api.test.ts +48 -2
  186. package/src/tests/asset-key-invariants.test.ts +92 -0
  187. package/src/tests/asset-key-migration.test.ts +174 -8
  188. package/src/tests/asset-key-normalization.test.ts +2 -0
  189. package/src/tests/credential-broker.test.ts +27 -2
  190. package/src/tests/mcp-oauth-dcr-reuse.test.ts +743 -0
  191. package/src/tests/mcp-oauth-ensure-token.test.ts +45 -0
  192. package/src/tests/mcp-oauth-manual-client.test.ts +135 -2
  193. package/src/tests/mcp-oauth-queries.test.ts +153 -0
  194. package/src/tests/mcp-oauth-wrapper.test.ts +432 -0
  195. package/src/tests/memory-http-recall-gating.test.ts +2 -0
  196. package/src/tests/openapi-response-contract.test.ts +138 -0
  197. package/src/tests/rbac-admission-e2e.test.ts +68 -0
  198. package/src/tests/script-connections.test.ts +3 -0
  199. package/src/tests/scripts-runtime-fetch.test.ts +121 -0
  200. package/src/tests/scripts-runtime-secret-egress.test.ts +4 -2
  201. package/src/tests/seed-scripts.test.ts +2 -2
  202. package/src/tests/swarm-tool-result-gate.test.ts +32 -0
  203. package/src/tests/task-working-dir.test.ts +8 -4
  204. package/src/tests/whoami-route.test.ts +127 -0
  205. package/src/tests/workflow-engine-v2.test.ts +80 -7
  206. package/src/tests/workflow-swarm-script.test.ts +104 -0
  207. package/src/tools/app-get.ts +10 -2
  208. package/src/tools/app-rollback.ts +1 -0
  209. package/src/tools/app-sync.ts +112 -0
  210. package/src/tools/script-common.ts +20 -0
  211. package/src/tools/tool-config.ts +2 -1
  212. package/src/tools/utils.ts +11 -0
  213. package/src/tools/workflows/create-workflow.ts +4 -1
  214. package/src/types.ts +1394 -1206
  215. package/src/utils/template.ts +8 -1
  216. package/src/utils/zod-openapi.ts +11 -0
  217. package/src/workflows/engine.ts +27 -4
  218. package/src/workflows/executors/swarm-script.ts +28 -0
  219. package/src/workflows/retry-poller.ts +19 -2
  220. package/templates/skills/apps/content.md +94 -5
  221. package/templates/skills/asset-namespaces/content.md +2 -2
  222. package/templates/skills/scheduled-task-resilience/SKILL.md +102 -0
  223. package/templates/skills/scheduled-task-resilience/config.json +14 -0
  224. package/templates/skills/scheduled-task-resilience/content.md +97 -0
  225. package/dist/cli-7wmybrt5.js +0 -115
  226. package/dist/cli-d91pvmq1.js +0 -14
@@ -9,7 +9,7 @@ import {
9
9
  isEnvFlagEnabled,
10
10
  isSteeringEnabled,
11
11
  registerTemplate
12
- } from "./cli-4n4mdv21.js";
12
+ } from "./cli-xpxde7rm.js";
13
13
  import {
14
14
  MAX_PROFILE_FILE_LENGTH,
15
15
  init_constants
@@ -19,8 +19,9 @@ import {
19
19
  init_credentials
20
20
  } from "./cli-z2zcxes1.js";
21
21
  import {
22
+ exports_zod,
22
23
  init_zod
23
- } from "./cli-d91pvmq1.js";
24
+ } from "./cli-zsspvvm2.js";
24
25
  import {
25
26
  init_secret_scrubber,
26
27
  scrubSecrets
@@ -28,25 +29,15 @@ import {
28
29
  import {
29
30
  init_package,
30
31
  package_default
31
- } from "./cli-kk4f9r17.js";
32
+ } from "./cli-72q8m8gk.js";
32
33
  import {
33
- ZodIssueCode,
34
34
  _enum,
35
- _null,
36
35
  array,
37
36
  boolean,
38
- discriminatedUnion,
39
- exports_iso,
40
- lazy,
41
- literal,
42
- number,
43
37
  object,
44
- record,
45
38
  string,
46
- union,
47
- unknown,
48
- uuid
49
- } from "./cli-2mbe7vk0.js";
39
+ union
40
+ } from "./cli-5dsbcjjw.js";
50
41
  import {
51
42
  __commonJS,
52
43
  __esm,
@@ -167,11 +158,11 @@ function githubContextKey(input) {
167
158
  if (kind !== "issue" && kind !== "pr") {
168
159
  throw new Error(`context-key: github "kind" must be "issue" or "pr" (got ${JSON.stringify(kind)})`);
169
160
  }
170
- const number2 = assertSafePart(input.number, "number");
171
- if (!/^\d+$/.test(number2)) {
172
- throw new Error(`context-key: github "number" must be a positive integer (got ${JSON.stringify(number2)})`);
161
+ const number = assertSafePart(input.number, "number");
162
+ if (!/^\d+$/.test(number)) {
163
+ throw new Error(`context-key: github "number" must be a positive integer (got ${JSON.stringify(number)})`);
173
164
  }
174
- return ["task", "trackers", "github", owner, repo, kind, number2].join(SEPARATOR);
165
+ return ["task", "trackers", "github", owner, repo, kind, number].join(SEPARATOR);
175
166
  }
176
167
  function gitlabContextKey(input) {
177
168
  const projectId = assertSafePart(input.projectId, "projectId");
@@ -259,14 +250,14 @@ function parseContextKey(key) {
259
250
  if (kind !== "issue" && kind !== "pr") {
260
251
  throw new Error(`context-key: malformed github kind "${kind}": ${JSON.stringify(key)}`);
261
252
  }
262
- const number2 = Number.parseInt(numberStr, 10);
263
- if (!Number.isFinite(number2)) {
253
+ const number = Number.parseInt(numberStr, 10);
254
+ if (!Number.isFinite(number)) {
264
255
  throw new Error(`context-key: malformed github number "${numberStr}": ${JSON.stringify(key)}`);
265
256
  }
266
257
  return {
267
258
  family: "trackers",
268
259
  subFamily: "github",
269
- parts: { owner, repo, kind, number: number2 }
260
+ parts: { owner, repo, kind, number }
270
261
  };
271
262
  }
272
263
  if (subFamily === "gitlab") {
@@ -586,6 +577,1437 @@ var init_telemetry = __esm(() => {
586
577
  };
587
578
  });
588
579
 
580
+ // node_modules/@asteasolutions/zod-to-openapi/dist/index.cjs
581
+ function __rest(s, e) {
582
+ var t = {};
583
+ for (var p in s)
584
+ if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
585
+ t[p] = s[p];
586
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
587
+ for (var i = 0, p = Object.getOwnPropertySymbols(s);i < p.length; i++) {
588
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
589
+ t[p[i]] = s[p[i]];
590
+ }
591
+ return t;
592
+ }
593
+ function isZodType(schema, typeNames) {
594
+ const typeNamesArray = Array.isArray(typeNames) ? typeNames : [typeNames];
595
+ return typeNamesArray.some((typeName) => {
596
+ var _a;
597
+ const typeNameMatch = ((_a = schema === null || schema === undefined ? undefined : schema.def) === null || _a === undefined ? undefined : _a.type) === ZodTypeKeys[typeName];
598
+ if (typeName === "ZodDiscriminatedUnion") {
599
+ return typeNameMatch && "discriminator" in schema.def;
600
+ }
601
+ return typeNameMatch;
602
+ });
603
+ }
604
+ function isAnyZodType(schema) {
605
+ return schema && "def" in schema;
606
+ }
607
+ function isNullableSchema(schema) {
608
+ return schema.safeParse(null).success;
609
+ }
610
+ function isOptionalSchema(schema) {
611
+ return schema.safeParse(undefined).success;
612
+ }
613
+
614
+ class $ZodRegistry {
615
+ constructor() {
616
+ this._map = new Map;
617
+ this._idmap = new Map;
618
+ }
619
+ add(schema, ..._meta) {
620
+ const meta = _meta[0];
621
+ this._map.set(schema, meta);
622
+ if (meta && typeof meta === "object" && "id" in meta) {
623
+ if (this._idmap.has(meta.id)) {
624
+ throw new Error(`ID ${meta.id} already exists in the registry`);
625
+ }
626
+ this._idmap.set(meta.id, schema);
627
+ }
628
+ return this;
629
+ }
630
+ clear() {
631
+ this._map = new Map;
632
+ this._idmap = new Map;
633
+ return this;
634
+ }
635
+ remove(schema) {
636
+ const meta = this._map.get(schema);
637
+ if (meta && typeof meta === "object" && "id" in meta) {
638
+ this._idmap.delete(meta.id);
639
+ }
640
+ this._map.delete(schema);
641
+ return this;
642
+ }
643
+ get(schema) {
644
+ const p = schema._zod.parent;
645
+ if (p) {
646
+ const pm = { ...this.get(p) ?? {} };
647
+ delete pm.id;
648
+ return { ...pm, ...this._map.get(schema) };
649
+ }
650
+ return this._map.get(schema);
651
+ }
652
+ has(schema) {
653
+ return this._map.has(schema);
654
+ }
655
+ }
656
+ function registry() {
657
+ return new $ZodRegistry;
658
+ }
659
+ function isEqual(x, y) {
660
+ if (x === null || x === undefined || y === null || y === undefined) {
661
+ return x === y;
662
+ }
663
+ if (x === y || x.valueOf() === y.valueOf()) {
664
+ return true;
665
+ }
666
+ if (Array.isArray(x)) {
667
+ if (!Array.isArray(y)) {
668
+ return false;
669
+ }
670
+ if (x.length !== y.length) {
671
+ return false;
672
+ }
673
+ }
674
+ if (!(x instanceof Object) || !(y instanceof Object)) {
675
+ return false;
676
+ }
677
+ const keysX = Object.keys(x);
678
+ return Object.keys(y).every((keyY) => keysX.indexOf(keyY) !== -1) && keysX.every((key) => isEqual(x[key], y[key]));
679
+ }
680
+
681
+ class ObjectSet {
682
+ constructor() {
683
+ this.buckets = new Map;
684
+ }
685
+ put(value) {
686
+ const hashCode = this.hashCodeOf(value);
687
+ const itemsByCode = this.buckets.get(hashCode);
688
+ if (!itemsByCode) {
689
+ this.buckets.set(hashCode, [value]);
690
+ return;
691
+ }
692
+ const alreadyHasItem = itemsByCode.some((_) => isEqual(_, value));
693
+ if (!alreadyHasItem) {
694
+ itemsByCode.push(value);
695
+ }
696
+ }
697
+ contains(value) {
698
+ const hashCode = this.hashCodeOf(value);
699
+ const itemsByCode = this.buckets.get(hashCode);
700
+ if (!itemsByCode) {
701
+ return false;
702
+ }
703
+ return itemsByCode.some((_) => isEqual(_, value));
704
+ }
705
+ values() {
706
+ return [...this.buckets.values()].flat();
707
+ }
708
+ stats() {
709
+ let totalBuckets = 0;
710
+ let totalValues = 0;
711
+ let collisions = 0;
712
+ for (const bucket of this.buckets.values()) {
713
+ totalBuckets += 1;
714
+ totalValues += bucket.length;
715
+ if (bucket.length > 1) {
716
+ collisions += 1;
717
+ }
718
+ }
719
+ const hashEffectiveness = totalBuckets / totalValues;
720
+ return { totalBuckets, collisions, totalValues, hashEffectiveness };
721
+ }
722
+ hashCodeOf(object2) {
723
+ let hashCode = 0;
724
+ if (Array.isArray(object2)) {
725
+ for (let i = 0;i < object2.length; i++) {
726
+ hashCode ^= this.hashCodeOf(object2[i]) * i;
727
+ }
728
+ return hashCode;
729
+ }
730
+ if (typeof object2 === "string") {
731
+ for (let i = 0;i < object2.length; i++) {
732
+ hashCode ^= object2.charCodeAt(i) * i;
733
+ }
734
+ return hashCode;
735
+ }
736
+ if (typeof object2 === "number") {
737
+ return object2;
738
+ }
739
+ if (typeof object2 === "object") {
740
+ for (const [key, value] of Object.entries(object2)) {
741
+ hashCode ^= this.hashCodeOf(key) + this.hashCodeOf(value !== null && value !== undefined ? value : "");
742
+ }
743
+ }
744
+ return hashCode;
745
+ }
746
+ }
747
+ function isUndefined(value) {
748
+ return value === undefined;
749
+ }
750
+ function mapValues(object2, mapper) {
751
+ const result = {};
752
+ Object.entries(object2).forEach(([key, value]) => {
753
+ result[key] = mapper(value);
754
+ });
755
+ return result;
756
+ }
757
+ function omit(object2, keys) {
758
+ const result = {};
759
+ Object.entries(object2).forEach(([key, value]) => {
760
+ if (!keys.some((keyToOmit) => keyToOmit === key)) {
761
+ result[key] = value;
762
+ }
763
+ });
764
+ return result;
765
+ }
766
+ function omitBy(object2, predicate) {
767
+ const result = {};
768
+ Object.entries(object2).forEach(([key, value]) => {
769
+ if (!predicate(value, key)) {
770
+ result[key] = value;
771
+ }
772
+ });
773
+ return result;
774
+ }
775
+ function compact(arr) {
776
+ return arr.filter((elem) => !isUndefined(elem));
777
+ }
778
+ function uniq(values) {
779
+ const set = new ObjectSet;
780
+ values.forEach((value) => set.put(value));
781
+ return [...set.values()];
782
+ }
783
+ function isString(val) {
784
+ return typeof val === "string";
785
+ }
786
+ function sortObjectByKeys(obj) {
787
+ return Object.fromEntries(Object.entries(obj).sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)));
788
+ }
789
+
790
+ class Metadata {
791
+ static collectMetadata(schema, metadata) {
792
+ const currentMetadata = this.getMetadataFromRegistry(schema);
793
+ const _internal = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata._internal), metadata === null || metadata === undefined ? undefined : metadata._internal);
794
+ const param = Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param), metadata === null || metadata === undefined ? undefined : metadata.param);
795
+ const totalMetadata = Object.assign(Object.assign(Object.assign(Object.assign({}, Object.keys(_internal).length > 0 ? { _internal } : {}), currentMetadata), metadata), Object.keys(param).length > 0 ? { param } : {});
796
+ if (isZodType(schema, [
797
+ "ZodOptional",
798
+ "ZodNullable",
799
+ "ZodDefault",
800
+ "ZodPrefault",
801
+ "ZodReadonly",
802
+ "ZodNonOptional"
803
+ ]) && isAnyZodType(schema._zod.def.innerType)) {
804
+ return this.collectMetadata(schema._zod.def.innerType, totalMetadata);
805
+ }
806
+ if (isZodType(schema, "ZodPipe")) {
807
+ const inSchema = schema._zod.def.in;
808
+ const outSchema = schema._zod.def.out;
809
+ if (isZodType(inSchema, "ZodTransform") && isAnyZodType(outSchema)) {
810
+ return this.collectMetadata(outSchema, totalMetadata);
811
+ }
812
+ if (isAnyZodType(inSchema)) {
813
+ return this.collectMetadata(inSchema, totalMetadata);
814
+ }
815
+ }
816
+ return totalMetadata;
817
+ }
818
+ static getMetadata(zodSchema) {
819
+ return this.collectMetadata(zodSchema);
820
+ }
821
+ static getOpenApiMetadata(zodSchema) {
822
+ const metadata = this.collectMetadata(zodSchema);
823
+ const _a = metadata !== null && metadata !== undefined ? metadata : {}, { _internal } = _a, rest = __rest(_a, ["_internal"]);
824
+ return rest;
825
+ }
826
+ static getInternalMetadata(zodSchema) {
827
+ var _a;
828
+ return (_a = this.collectMetadata(zodSchema)) === null || _a === undefined ? undefined : _a._internal;
829
+ }
830
+ static getParamMetadata(zodSchema) {
831
+ const metadata = this.collectMetadata(zodSchema);
832
+ return Object.assign(Object.assign({}, metadata), {
833
+ param: Object.assign(Object.assign({}, (metadata === null || metadata === undefined ? undefined : metadata.description) ? { description: metadata.description } : {}), metadata === null || metadata === undefined ? undefined : metadata.param)
834
+ });
835
+ }
836
+ static buildSchemaMetadata(metadata) {
837
+ return omitBy(omit(metadata, ["param", "_internal"]), isUndefined);
838
+ }
839
+ static buildParameterMetadata(metadata) {
840
+ return omitBy(metadata, isUndefined);
841
+ }
842
+ static applySchemaMetadata(initialData, metadata) {
843
+ return omitBy(Object.assign(Object.assign({}, initialData), this.buildSchemaMetadata(metadata)), isUndefined);
844
+ }
845
+ static getRefId(zodSchema) {
846
+ var _a;
847
+ return (_a = this.getInternalMetadata(zodSchema)) === null || _a === undefined ? undefined : _a.refId;
848
+ }
849
+ static unwrapChained(schema) {
850
+ return this.unwrapUntil(schema);
851
+ }
852
+ static getDefaultValue(zodSchema) {
853
+ var _a;
854
+ const unwrapped = (_a = this.unwrapUntil(zodSchema, "ZodDefault")) !== null && _a !== undefined ? _a : this.unwrapUntil(zodSchema, "ZodPrefault");
855
+ return unwrapped === null || unwrapped === undefined ? undefined : unwrapped._zod.def.defaultValue;
856
+ }
857
+ static unwrapUntil(schema, typeName) {
858
+ if (typeName && isZodType(schema, typeName)) {
859
+ return schema;
860
+ }
861
+ if (isZodType(schema, [
862
+ "ZodOptional",
863
+ "ZodNullable",
864
+ "ZodDefault",
865
+ "ZodPrefault",
866
+ "ZodReadonly",
867
+ "ZodNonOptional"
868
+ ]) && isAnyZodType(schema._zod.def.innerType)) {
869
+ return this.unwrapUntil(schema._zod.def.innerType, typeName);
870
+ }
871
+ if (isZodType(schema, "ZodPipe")) {
872
+ const inSchema = schema._zod.def.in;
873
+ const outSchema = schema._zod.def.out;
874
+ if (isZodType(inSchema, "ZodTransform") && isAnyZodType(outSchema)) {
875
+ return this.unwrapUntil(outSchema, typeName);
876
+ }
877
+ if (isAnyZodType(inSchema)) {
878
+ return this.unwrapUntil(inSchema, typeName);
879
+ }
880
+ }
881
+ return typeName ? undefined : schema;
882
+ }
883
+ static getMetadataFromInternalRegistry(zodSchema) {
884
+ return zodToOpenAPIRegistry.get(zodSchema);
885
+ }
886
+ static getMetadataFromRegistry(zodSchema) {
887
+ const internal = this.getMetadataFromInternalRegistry(zodSchema);
888
+ const general = zodSchema.meta();
889
+ if (!internal) {
890
+ return general;
891
+ }
892
+ const { _internal } = internal, rest = __rest(internal, ["_internal"]);
893
+ const _a = general !== null && general !== undefined ? general : {}, { id, title } = _a, restGeneral = __rest(_a, ["id", "title"]);
894
+ return Object.assign(Object.assign(Object.assign({ _internal: Object.assign(Object.assign({}, id ? { refId: id } : {}), _internal) }, rest), title ? { description: title } : {}), restGeneral);
895
+ }
896
+ static setMetadataInRegistry(zodSchema, metadata) {
897
+ zodToOpenAPIRegistry.add(zodSchema, metadata);
898
+ }
899
+ }
900
+ function preserveMetadataFromModifier(zodSchema, modifier) {
901
+ const zodModifier = zodSchema[modifier];
902
+ if (typeof zodModifier !== "function") {
903
+ return;
904
+ }
905
+ zodSchema[modifier] = function(...args) {
906
+ const result = zodModifier.apply(this, args);
907
+ const meta = Metadata.getMetadataFromRegistry(this);
908
+ if (meta) {
909
+ Metadata.setMetadataInRegistry(result, meta);
910
+ }
911
+ return result;
912
+ };
913
+ }
914
+ function extendZodWithOpenApi(zod) {
915
+ if (typeof zod.ZodType.prototype.openapi !== "undefined") {
916
+ return;
917
+ }
918
+ zod.ZodType.prototype.openapi = function(...args) {
919
+ const { refId, metadata, options } = getOpenApiConfiguration(...args);
920
+ const _a = metadata !== null && metadata !== undefined ? metadata : {}, { param } = _a, restOfOpenApi = __rest(_a, ["param"]);
921
+ const allMetadata = Metadata.getMetadataFromRegistry(this);
922
+ const _b = allMetadata !== null && allMetadata !== undefined ? allMetadata : {}, { _internal: internalMetadata } = _b, currentMetadata = __rest(_b, ["_internal"]);
923
+ const _internal = Object.assign(Object.assign(Object.assign({}, internalMetadata), options), refId ? { refId } : undefined);
924
+ const resultMetadata = Object.assign(Object.assign(Object.assign({}, currentMetadata), restOfOpenApi), (currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param) || param ? {
925
+ param: Object.assign(Object.assign({}, currentMetadata === null || currentMetadata === undefined ? undefined : currentMetadata.param), param)
926
+ } : undefined);
927
+ const result = new this.constructor(this._def);
928
+ function setMetadata(schema) {
929
+ Metadata.setMetadataInRegistry(schema, Object.assign(Object.assign({}, Object.keys(_internal).length > 0 ? { _internal } : undefined), resultMetadata));
930
+ }
931
+ setMetadata(result);
932
+ if (isZodType(result, "ZodLazy")) {
933
+ setMetadata(this);
934
+ }
935
+ if (isZodType(result, "ZodObject")) {
936
+ const currentMetadata2 = Metadata.getMetadataFromRegistry(result);
937
+ const originalExtend = result.extend;
938
+ result.extend = function(...args2) {
939
+ const extendedResult = originalExtend.apply(result, args2);
940
+ const _a2 = currentMetadata2 !== null && currentMetadata2 !== undefined ? currentMetadata2 : {}, { _internal: _internal2 } = _a2, rest = __rest(_a2, ["_internal"]);
941
+ Metadata.setMetadataInRegistry(extendedResult, {
942
+ _internal: {
943
+ extendedFrom: (_internal2 === null || _internal2 === undefined ? undefined : _internal2.refId) ? { refId: _internal2.refId, schema: result } : _internal2 === null || _internal2 === undefined ? undefined : _internal2.extendedFrom
944
+ }
945
+ });
946
+ return extendedResult.openapi(rest);
947
+ };
948
+ preserveMetadataFromModifier(result, "catchall");
949
+ }
950
+ preserveMetadataFromModifier(result, "optional");
951
+ preserveMetadataFromModifier(result, "nullable");
952
+ preserveMetadataFromModifier(result, "default");
953
+ preserveMetadataFromModifier(result, "transform");
954
+ preserveMetadataFromModifier(result, "refine");
955
+ preserveMetadataFromModifier(result, "length");
956
+ preserveMetadataFromModifier(result, "min");
957
+ preserveMetadataFromModifier(result, "max");
958
+ const originalMeta = result.meta;
959
+ result.meta = function(...args2) {
960
+ const result2 = originalMeta.apply(this, args2);
961
+ if (args2[0]) {
962
+ const meta = Metadata.getMetadataFromInternalRegistry(this);
963
+ if (meta) {
964
+ Metadata.setMetadataInRegistry(result2, Object.assign(Object.assign({}, meta), args2[0]));
965
+ }
966
+ }
967
+ return result2;
968
+ };
969
+ return result;
970
+ };
971
+ }
972
+ function getOpenApiConfiguration(refOrOpenapi, metadataOrOptions, options) {
973
+ if (typeof refOrOpenapi === "string") {
974
+ return {
975
+ refId: refOrOpenapi,
976
+ metadata: metadataOrOptions,
977
+ options
978
+ };
979
+ }
980
+ return {
981
+ refId: undefined,
982
+ metadata: refOrOpenapi,
983
+ options: metadataOrOptions
984
+ };
985
+ }
986
+
987
+ class OpenAPIRegistry {
988
+ constructor(parents) {
989
+ this.parents = parents;
990
+ this._definitions = [];
991
+ }
992
+ get definitions() {
993
+ var _a, _b;
994
+ const parentDefinitions = (_b = (_a = this.parents) === null || _a === undefined ? undefined : _a.flatMap((par) => par._definitions)) !== null && _b !== undefined ? _b : [];
995
+ return [...parentDefinitions, ...this._definitions];
996
+ }
997
+ register(refId, zodSchema) {
998
+ const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);
999
+ this._definitions.push({ type: "schema", schema: schemaWithRefId });
1000
+ return schemaWithRefId;
1001
+ }
1002
+ registerParameter(refId, zodSchema) {
1003
+ var _a, _b, _c;
1004
+ const schemaWithRefId = this.schemaWithRefId(refId, zodSchema);
1005
+ const currentMetadata = (_a = Metadata.getOpenApiMetadata(schemaWithRefId)) !== null && _a !== undefined ? _a : {};
1006
+ 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 }) }));
1007
+ this._definitions.push({
1008
+ type: "parameter",
1009
+ schema: schemaWithMetadata
1010
+ });
1011
+ return schemaWithMetadata;
1012
+ }
1013
+ registerPath(route) {
1014
+ this._definitions.push({
1015
+ type: "route",
1016
+ route
1017
+ });
1018
+ }
1019
+ registerWebhook(webhook) {
1020
+ this._definitions.push({
1021
+ type: "webhook",
1022
+ webhook
1023
+ });
1024
+ }
1025
+ registerComponent(type, name, component) {
1026
+ this._definitions.push({
1027
+ type: "component",
1028
+ componentType: type,
1029
+ name,
1030
+ component
1031
+ });
1032
+ return {
1033
+ name,
1034
+ ref: { $ref: `#/components/${type}/${name}` }
1035
+ };
1036
+ }
1037
+ schemaWithRefId(refId, zodSchema) {
1038
+ return zodSchema.openapi(refId);
1039
+ }
1040
+ }
1041
+
1042
+ class ZodToOpenAPIError {
1043
+ constructor(message) {
1044
+ this.message = message;
1045
+ }
1046
+ }
1047
+ function enhanceMissingParametersError(action, paramsToAdd) {
1048
+ try {
1049
+ return action();
1050
+ } catch (error) {
1051
+ if (error instanceof MissingParameterDataError) {
1052
+ throw new MissingParameterDataError(Object.assign(Object.assign({}, error.data), paramsToAdd));
1053
+ }
1054
+ throw error;
1055
+ }
1056
+ }
1057
+
1058
+ class ArrayTransformer {
1059
+ transform(zodSchema, mapNullableType, mapItems) {
1060
+ var _a, _b, _c, _d;
1061
+ const itemType = zodSchema.def.element;
1062
+ 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;
1063
+ 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;
1064
+ return Object.assign(Object.assign({}, mapNullableType("array")), {
1065
+ items: isAnyZodType(itemType) ? mapItems(itemType) : {},
1066
+ minItems,
1067
+ maxItems
1068
+ });
1069
+ }
1070
+ }
1071
+
1072
+ class BigIntTransformer {
1073
+ transform(mapNullableType) {
1074
+ return Object.assign(Object.assign({}, mapNullableType("string")), { pattern: `^d+$` });
1075
+ }
1076
+ }
1077
+
1078
+ class DiscriminatedUnionTransformer {
1079
+ transform(zodSchema, isNullable, mapNullableOfArray, mapItem, generateSchemaRef) {
1080
+ const options = [...zodSchema.def.options];
1081
+ const optionSchema = options.map(mapItem);
1082
+ if (isNullable) {
1083
+ return {
1084
+ oneOf: mapNullableOfArray(optionSchema, isNullable)
1085
+ };
1086
+ }
1087
+ const discriminator = zodSchema._zod.def.discriminator;
1088
+ if (!discriminator) {
1089
+ console.error("No discriminator found for discriminated union", zodSchema);
1090
+ return {
1091
+ oneOf: optionSchema
1092
+ };
1093
+ }
1094
+ return {
1095
+ oneOf: optionSchema,
1096
+ discriminator: this.mapDiscriminator(options, discriminator, generateSchemaRef)
1097
+ };
1098
+ }
1099
+ mapDiscriminator(zodObjects, discriminator, generateSchemaRef) {
1100
+ if (zodObjects.some((obj) => Metadata.getRefId(obj) === undefined)) {
1101
+ return;
1102
+ }
1103
+ const mapping = {};
1104
+ zodObjects.forEach((obj) => {
1105
+ var _a;
1106
+ const refId = Metadata.getRefId(obj);
1107
+ const value = (_a = obj.def.shape) === null || _a === undefined ? undefined : _a[discriminator];
1108
+ if (isZodType(value, "ZodEnum")) {
1109
+ const keys = Object.values(value._zod.def.entries).filter(isString);
1110
+ keys.forEach((enumValue) => {
1111
+ mapping[enumValue] = generateSchemaRef(refId);
1112
+ });
1113
+ return;
1114
+ }
1115
+ const literalValue = value === null || value === undefined ? undefined : value.def.values[0];
1116
+ if (typeof literalValue !== "string") {
1117
+ throw new Error(`Discriminator ${discriminator} could not be found in one of the values of a discriminated union`);
1118
+ }
1119
+ mapping[literalValue] = generateSchemaRef(refId);
1120
+ });
1121
+ return {
1122
+ propertyName: discriminator,
1123
+ mapping
1124
+ };
1125
+ }
1126
+ }
1127
+ function enumInfo(enumObject) {
1128
+ const keysExceptReverseMappings = Object.keys(enumObject).filter((key) => typeof enumObject[enumObject[key]] !== "number");
1129
+ const values = keysExceptReverseMappings.map((key) => enumObject[key]);
1130
+ const numericCount = values.filter((_) => typeof _ === "number").length;
1131
+ const type = numericCount === 0 ? "string" : numericCount === values.length ? "numeric" : "mixed";
1132
+ return { values, type };
1133
+ }
1134
+
1135
+ class EnumTransformer {
1136
+ transform(zodSchema, isNullable, mapNullableType) {
1137
+ const { type, values } = enumInfo(zodSchema._zod.def.entries);
1138
+ if (type === "mixed") {
1139
+ throw new ZodToOpenAPIError("Enum has mixed string and number values, please specify the OpenAPI type manually");
1140
+ }
1141
+ return Object.assign(Object.assign({}, mapNullableType(type === "numeric" ? "integer" : "string")), { enum: isNullable ? [...values, null] : values });
1142
+ }
1143
+ }
1144
+
1145
+ class IntersectionTransformer {
1146
+ transform(zodSchema, isNullable, mapNullableOfArray, mapItem) {
1147
+ const subtypes = this.flattenIntersectionTypes(zodSchema);
1148
+ const allOfSchema = {
1149
+ allOf: subtypes.map(mapItem)
1150
+ };
1151
+ if (isNullable) {
1152
+ return {
1153
+ anyOf: mapNullableOfArray([allOfSchema], isNullable)
1154
+ };
1155
+ }
1156
+ return allOfSchema;
1157
+ }
1158
+ flattenIntersectionTypes(schema) {
1159
+ if (!isZodType(schema, "ZodIntersection")) {
1160
+ return [schema];
1161
+ }
1162
+ const leftSubTypes = isAnyZodType(schema._zod.def.left) ? this.flattenIntersectionTypes(schema._zod.def.left) : [];
1163
+ const rightSubTypes = isAnyZodType(schema._zod.def.right) ? this.flattenIntersectionTypes(schema._zod.def.right) : [];
1164
+ return [...leftSubTypes, ...rightSubTypes];
1165
+ }
1166
+ }
1167
+
1168
+ class LiteralTransformer {
1169
+ constructor() {
1170
+ this.bigIntTransformer = new BigIntTransformer;
1171
+ }
1172
+ transform(zodSchema, mapNullableType) {
1173
+ const type = typeof zodSchema.def.values[0];
1174
+ if (type === "boolean" || type === "number" || type === "string" || type === "object") {
1175
+ return Object.assign(Object.assign({}, mapNullableType(type)), { enum: [zodSchema.def.values[0]] });
1176
+ }
1177
+ if (type === "bigint") {
1178
+ return this.bigIntTransformer.transform(mapNullableType);
1179
+ }
1180
+ return mapNullableType("null");
1181
+ }
1182
+ }
1183
+
1184
+ class NumberTransformer {
1185
+ transform(zodSchema, mapNullableType, getNumberChecks) {
1186
+ var _a;
1187
+ return Object.assign(Object.assign(Object.assign({}, mapNullableType("number")), mapNullableType(zodSchema.format === "safeint" ? "integer" : "number")), getNumberChecks((_a = zodSchema.def.checks) !== null && _a !== undefined ? _a : []));
1188
+ }
1189
+ }
1190
+
1191
+ class ObjectTransformer {
1192
+ transform(zodSchema, defaultValue, mapNullableType, mapItem) {
1193
+ var _a;
1194
+ const extendedFrom = (_a = Metadata.getInternalMetadata(zodSchema)) === null || _a === undefined ? undefined : _a.extendedFrom;
1195
+ const required = this.requiredKeysOf(zodSchema);
1196
+ const properties = mapValues(zodSchema.def.shape, mapItem);
1197
+ if (!extendedFrom) {
1198
+ return Object.assign(Object.assign(Object.assign(Object.assign({}, mapNullableType("object")), { properties, default: defaultValue }), required.length > 0 ? { required } : {}), this.generateAdditionalProperties(zodSchema, mapItem));
1199
+ }
1200
+ const parent = extendedFrom.schema;
1201
+ mapItem(parent);
1202
+ const keysRequiredByParent = this.requiredKeysOf(parent);
1203
+ const propsOfParent = mapValues(parent === null || parent === undefined ? undefined : parent.def.shape, mapItem);
1204
+ const propertiesToAdd = Object.fromEntries(Object.entries(properties).filter(([key, type]) => {
1205
+ return !objectEquals(propsOfParent[key], type);
1206
+ }));
1207
+ const additionallyRequired = required.filter((prop) => !keysRequiredByParent.includes(prop));
1208
+ 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));
1209
+ return {
1210
+ allOf: [
1211
+ { $ref: `#/components/schemas/${extendedFrom.refId}` },
1212
+ objectData
1213
+ ]
1214
+ };
1215
+ }
1216
+ generateAdditionalProperties(zodSchema, mapItem) {
1217
+ const catchallSchema = zodSchema.def.catchall;
1218
+ if (!catchallSchema) {
1219
+ return {};
1220
+ }
1221
+ if (isZodType(catchallSchema, "ZodNever")) {
1222
+ return { additionalProperties: false };
1223
+ }
1224
+ if (isAnyZodType(catchallSchema)) {
1225
+ return { additionalProperties: mapItem(catchallSchema) };
1226
+ }
1227
+ return {};
1228
+ }
1229
+ requiredKeysOf(objectSchema) {
1230
+ return Object.entries(objectSchema.def.shape).filter(([_key, type]) => !isOptionalSchema(type)).map(([key, _type]) => key);
1231
+ }
1232
+ }
1233
+
1234
+ class RecordTransformer {
1235
+ transform(zodSchema, mapNullableType, mapItem) {
1236
+ const propertiesType = zodSchema.valueType;
1237
+ const keyType = zodSchema.keyType;
1238
+ const propertiesSchema = isAnyZodType(propertiesType) ? mapItem(propertiesType) : {};
1239
+ if (isZodType(keyType, "ZodEnum")) {
1240
+ const keys = Object.values(keyType._zod.def.entries).filter(isString);
1241
+ const properties = keys.reduce((acc, curr) => Object.assign(Object.assign({}, acc), { [curr]: propertiesSchema }), {});
1242
+ return Object.assign(Object.assign({}, mapNullableType("object")), { properties });
1243
+ }
1244
+ return Object.assign(Object.assign({}, mapNullableType("object")), { additionalProperties: propertiesSchema });
1245
+ }
1246
+ }
1247
+ function isZodCheckLengthEquals(check) {
1248
+ return check._zod.def.check === "length_equals";
1249
+ }
1250
+ function isZodCheckRegex(check) {
1251
+ return check._zod.def.check === "string_format" && check._zod.def.format === "regex";
1252
+ }
1253
+
1254
+ class StringTransformer {
1255
+ transform(zodSchema, mapNullableType) {
1256
+ var _a, _b, _c, _d;
1257
+ const regexCheck = (_a = zodSchema.def.checks) === null || _a === undefined ? undefined : _a.find(isZodCheckRegex);
1258
+ const pattern = regexCheck === null || regexCheck === undefined ? undefined : regexCheck._zod.def.pattern.toString().replace(/^\/|\/$/g, "");
1259
+ const check = (_b = zodSchema.def.checks) === null || _b === undefined ? undefined : _b.find(isZodCheckLengthEquals);
1260
+ const length = check === null || check === undefined ? undefined : check._zod.def.length;
1261
+ const maxLength = Number.isFinite(zodSchema.minLength) ? (_c = zodSchema.minLength) !== null && _c !== undefined ? _c : undefined : undefined;
1262
+ const minLength = Number.isFinite(zodSchema.maxLength) ? (_d = zodSchema.maxLength) !== null && _d !== undefined ? _d : undefined : undefined;
1263
+ return Object.assign(Object.assign({}, mapNullableType("string")), {
1264
+ minLength: length !== null && length !== undefined ? length : maxLength,
1265
+ maxLength: length !== null && length !== undefined ? length : minLength,
1266
+ format: this.mapStringFormat(zodSchema),
1267
+ pattern
1268
+ });
1269
+ }
1270
+ mapStringFormat(zodString) {
1271
+ if (zodString.format === "uuid")
1272
+ return "uuid";
1273
+ if (zodString.format === "email")
1274
+ return "email";
1275
+ if (zodString.format === "url")
1276
+ return "uri";
1277
+ if (zodString.format === "date")
1278
+ return "date";
1279
+ if (zodString.format === "datetime")
1280
+ return "date-time";
1281
+ if (zodString.format === "cuid")
1282
+ return "cuid";
1283
+ if (zodString.format === "cuid2")
1284
+ return "cuid2";
1285
+ if (zodString.format === "ulid")
1286
+ return "ulid";
1287
+ if (zodString.format === "ipv4")
1288
+ return "ip";
1289
+ if (zodString.format === "ipv6")
1290
+ return "ip";
1291
+ if (zodString.format === "emoji")
1292
+ return "emoji";
1293
+ return;
1294
+ }
1295
+ }
1296
+
1297
+ class TupleTransformer {
1298
+ constructor(versionSpecifics) {
1299
+ this.versionSpecifics = versionSpecifics;
1300
+ }
1301
+ transform(zodSchema, mapNullableType, mapItem) {
1302
+ const items = zodSchema._zod.def.items;
1303
+ const schemas = items.map((item) => isAnyZodType(item) ? mapItem(item) : {});
1304
+ return Object.assign(Object.assign({}, mapNullableType("array")), this.versionSpecifics.mapTupleItems(schemas));
1305
+ }
1306
+ }
1307
+
1308
+ class UnionTransformer {
1309
+ constructor(options) {
1310
+ this.options = options;
1311
+ }
1312
+ transform(zodSchema, mapNullableOfArray, mapItem) {
1313
+ var _a, _b, _c;
1314
+ const internalMetadata = Metadata.getInternalMetadata(zodSchema);
1315
+ 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";
1316
+ const options = this.flattenUnionTypes(zodSchema);
1317
+ const schemas = options.map((schema) => {
1318
+ const optionToGenerate = this.unwrapNullable(schema);
1319
+ return mapItem(optionToGenerate);
1320
+ });
1321
+ return {
1322
+ [preferredType]: mapNullableOfArray(schemas)
1323
+ };
1324
+ }
1325
+ flattenUnionTypes(schema) {
1326
+ if (!isZodType(schema, "ZodUnion")) {
1327
+ return [schema];
1328
+ }
1329
+ const options = schema.def.options;
1330
+ return options.flatMap((option) => isAnyZodType(option) ? this.flattenUnionTypes(option) : []);
1331
+ }
1332
+ unwrapNullable(schema) {
1333
+ if (isZodType(schema, "ZodNullable")) {
1334
+ const unwrapped = schema.unwrap();
1335
+ if (isAnyZodType(unwrapped)) {
1336
+ return this.unwrapNullable(unwrapped);
1337
+ }
1338
+ }
1339
+ return schema;
1340
+ }
1341
+ }
1342
+
1343
+ class DateTransformer {
1344
+ transform(mapNullableType) {
1345
+ return Object.assign(Object.assign({}, mapNullableType("string")), { format: "date-time" });
1346
+ }
1347
+ }
1348
+
1349
+ class LazyTransformer {
1350
+ transform(zodSchema, mapItem, mapNullableType, mapNullableRef) {
1351
+ const result = mapItem(zodSchema._zod.def.getter());
1352
+ return LazyTransformer.mapRecursive(result, mapNullableType, mapNullableRef);
1353
+ }
1354
+ static mapRecursive(schema, mapNullableType, mapNullableRef) {
1355
+ if ("$ref" in schema) {
1356
+ return mapNullableRef(schema);
1357
+ }
1358
+ if (schema.type) {
1359
+ return Object.assign(Object.assign({}, schema), mapNullableType(schema.type));
1360
+ }
1361
+ return schema;
1362
+ }
1363
+ }
1364
+
1365
+ class TemplateLiteralTransformer {
1366
+ transform(zodSchema, mapNullableType) {
1367
+ const parts = zodSchema.def.parts;
1368
+ const contentPattern = parts.map((part) => this.generatePattern(part)).join("");
1369
+ return Object.assign(Object.assign({}, mapNullableType("string")), { pattern: `^${contentPattern}$` });
1370
+ }
1371
+ generatePattern(part) {
1372
+ if (typeof part === "string" || typeof part === "number" || typeof part === "boolean" || typeof part === "bigint" || part === null || part === undefined) {
1373
+ return this.escapeRegex(String(part));
1374
+ }
1375
+ if (isZodType(part, "ZodLiteral")) {
1376
+ const value = part.def.values[0];
1377
+ return this.escapeRegex(String(value));
1378
+ }
1379
+ if (isZodType(part, "ZodNumber")) {
1380
+ return "[+-]?\\d+(\\.\\d+)?";
1381
+ }
1382
+ if (isZodType(part, "ZodBoolean")) {
1383
+ return "(true|false)";
1384
+ }
1385
+ if (isZodType(part, "ZodEnum")) {
1386
+ const { values } = enumInfo(part.def.entries);
1387
+ return `(${values.map((v) => this.escapeRegex(String(v))).join("|")})`;
1388
+ }
1389
+ return ".*";
1390
+ }
1391
+ escapeRegex(str) {
1392
+ return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
1393
+ }
1394
+ }
1395
+
1396
+ class OpenApiTransformer {
1397
+ constructor(versionSpecifics, options) {
1398
+ this.versionSpecifics = versionSpecifics;
1399
+ this.objectTransformer = new ObjectTransformer;
1400
+ this.stringTransformer = new StringTransformer;
1401
+ this.numberTransformer = new NumberTransformer;
1402
+ this.bigIntTransformer = new BigIntTransformer;
1403
+ this.dateTransformer = new DateTransformer;
1404
+ this.lazyTransformer = new LazyTransformer;
1405
+ this.literalTransformer = new LiteralTransformer;
1406
+ this.templateLiteralTransformer = new TemplateLiteralTransformer;
1407
+ this.enumTransformer = new EnumTransformer;
1408
+ this.arrayTransformer = new ArrayTransformer;
1409
+ this.discriminatedUnionTransformer = new DiscriminatedUnionTransformer;
1410
+ this.intersectionTransformer = new IntersectionTransformer;
1411
+ this.recordTransformer = new RecordTransformer;
1412
+ this.tupleTransformer = new TupleTransformer(versionSpecifics);
1413
+ this.unionTransformer = new UnionTransformer(options);
1414
+ }
1415
+ transform(zodSchema, isNullable, mapItem, generateSchemaRef, defaultValue) {
1416
+ if (isZodType(zodSchema, "ZodNull")) {
1417
+ return this.versionSpecifics.nullType;
1418
+ }
1419
+ if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) {
1420
+ return this.versionSpecifics.mapNullableType(undefined, isNullable);
1421
+ }
1422
+ if (isZodType(zodSchema, "ZodObject")) {
1423
+ return this.objectTransformer.transform(zodSchema, defaultValue, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
1424
+ }
1425
+ const schema = this.transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef);
1426
+ return Object.assign(Object.assign({}, schema), { default: defaultValue });
1427
+ }
1428
+ transformSchemaWithoutDefault(zodSchema, isNullable, mapItem, generateSchemaRef) {
1429
+ if (isZodType(zodSchema, "ZodUnknown") || isZodType(zodSchema, "ZodAny")) {
1430
+ return this.versionSpecifics.mapNullableType(undefined, isNullable);
1431
+ }
1432
+ if (isZodType(zodSchema, "ZodString")) {
1433
+ return this.stringTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
1434
+ }
1435
+ if (isZodType(zodSchema, "ZodNumber")) {
1436
+ return this.numberTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (_) => this.versionSpecifics.getNumberChecks(_));
1437
+ }
1438
+ if (isZodType(zodSchema, "ZodBigInt")) {
1439
+ return this.bigIntTransformer.transform((schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
1440
+ }
1441
+ if (isZodType(zodSchema, "ZodBoolean")) {
1442
+ return this.versionSpecifics.mapNullableType("boolean", isNullable);
1443
+ }
1444
+ if (isZodType(zodSchema, "ZodLazy")) {
1445
+ return this.lazyTransformer.transform(zodSchema, mapItem, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (schema) => this.versionSpecifics.mapNullableOfRef(schema, isNullable));
1446
+ }
1447
+ if (isZodType(zodSchema, "ZodLiteral")) {
1448
+ return this.literalTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
1449
+ }
1450
+ if (isZodType(zodSchema, "ZodTemplateLiteral")) {
1451
+ return this.templateLiteralTransformer.transform(zodSchema, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
1452
+ }
1453
+ if (isZodType(zodSchema, "ZodEnum")) {
1454
+ return this.enumTransformer.transform(zodSchema, isNullable, (schema) => this.versionSpecifics.mapNullableType(schema, isNullable));
1455
+ }
1456
+ if (isZodType(zodSchema, "ZodArray")) {
1457
+ return this.arrayTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
1458
+ }
1459
+ if (isZodType(zodSchema, "ZodTuple")) {
1460
+ return this.tupleTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
1461
+ }
1462
+ if (isZodType(zodSchema, "ZodDiscriminatedUnion")) {
1463
+ return this.discriminatedUnionTransformer.transform(zodSchema, isNullable, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem, generateSchemaRef);
1464
+ }
1465
+ if (isZodType(zodSchema, "ZodUnion")) {
1466
+ return this.unionTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);
1467
+ }
1468
+ if (isZodType(zodSchema, "ZodIntersection")) {
1469
+ return this.intersectionTransformer.transform(zodSchema, isNullable, (_) => this.versionSpecifics.mapNullableOfArray(_, isNullable), mapItem);
1470
+ }
1471
+ if (isZodType(zodSchema, "ZodRecord")) {
1472
+ return this.recordTransformer.transform(zodSchema, (_) => this.versionSpecifics.mapNullableType(_, isNullable), mapItem);
1473
+ }
1474
+ if (isZodType(zodSchema, "ZodDate")) {
1475
+ return this.dateTransformer.transform((_) => this.versionSpecifics.mapNullableType(_, isNullable));
1476
+ }
1477
+ const refId = Metadata.getRefId(zodSchema);
1478
+ throw new UnknownZodTypeError({
1479
+ currentSchema: zodSchema.def,
1480
+ schemaName: refId
1481
+ });
1482
+ }
1483
+ }
1484
+
1485
+ class OpenAPIGenerator {
1486
+ constructor(definitions, versionSpecifics, options) {
1487
+ this.definitions = definitions;
1488
+ this.versionSpecifics = versionSpecifics;
1489
+ this.options = options;
1490
+ this.schemaRefs = {};
1491
+ this.paramRefs = {};
1492
+ this.pathRefs = {};
1493
+ this.rawComponents = [];
1494
+ this.openApiTransformer = new OpenApiTransformer(versionSpecifics, options);
1495
+ this.sortDefinitions();
1496
+ }
1497
+ generateDocumentData() {
1498
+ this.definitions.forEach((definition) => this.generateSingle(definition));
1499
+ return {
1500
+ components: this.buildComponents(),
1501
+ paths: this.pathRefs
1502
+ };
1503
+ }
1504
+ generateComponents() {
1505
+ this.definitions.forEach((definition) => this.generateSingle(definition));
1506
+ return {
1507
+ components: this.buildComponents()
1508
+ };
1509
+ }
1510
+ buildComponents() {
1511
+ var _a, _b, _c, _d;
1512
+ const rawComponents = {};
1513
+ this.rawComponents.forEach(({ componentType, name, component }) => {
1514
+ var _a2;
1515
+ (_a2 = rawComponents[componentType]) !== null && _a2 !== undefined || (rawComponents[componentType] = {});
1516
+ rawComponents[componentType][name] = component;
1517
+ });
1518
+ const allSchemas = Object.assign(Object.assign({}, (_a = rawComponents.schemas) !== null && _a !== undefined ? _a : {}), this.filteredSchemaRefs);
1519
+ const schemas = ((_b = this.options) === null || _b === undefined ? undefined : _b.sortComponents) === "alphabetically" ? sortObjectByKeys(allSchemas) : allSchemas;
1520
+ const allParameters = Object.assign(Object.assign({}, (_c = rawComponents.parameters) !== null && _c !== undefined ? _c : {}), this.paramRefs);
1521
+ const parameters = ((_d = this.options) === null || _d === undefined ? undefined : _d.sortComponents) === "alphabetically" ? sortObjectByKeys(allParameters) : allParameters;
1522
+ return Object.assign(Object.assign({}, rawComponents), { schemas, parameters });
1523
+ }
1524
+ isNotPendingRefEntry(entry) {
1525
+ return entry[1] !== "pending";
1526
+ }
1527
+ get filteredSchemaRefs() {
1528
+ const filtered = Object.entries(this.schemaRefs).filter(this.isNotPendingRefEntry);
1529
+ return Object.fromEntries(filtered);
1530
+ }
1531
+ sortDefinitions() {
1532
+ const generationOrder = [
1533
+ "schema",
1534
+ "parameter",
1535
+ "component",
1536
+ "route"
1537
+ ];
1538
+ this.definitions.sort((left, right) => {
1539
+ if (!("type" in left)) {
1540
+ if (!("type" in right)) {
1541
+ return 0;
1542
+ }
1543
+ return -1;
1544
+ }
1545
+ if (!("type" in right)) {
1546
+ return 1;
1547
+ }
1548
+ const leftIndex = generationOrder.findIndex((type) => type === left.type);
1549
+ const rightIndex = generationOrder.findIndex((type) => type === right.type);
1550
+ return leftIndex - rightIndex;
1551
+ });
1552
+ }
1553
+ generateSingle(definition) {
1554
+ if (!("type" in definition)) {
1555
+ this.generateSchemaWithRef(definition);
1556
+ return;
1557
+ }
1558
+ switch (definition.type) {
1559
+ case "parameter":
1560
+ this.generateParameterDefinition(definition.schema);
1561
+ return;
1562
+ case "schema":
1563
+ this.generateSchemaWithRef(definition.schema);
1564
+ return;
1565
+ case "route":
1566
+ this.generateSingleRoute(definition.route);
1567
+ return;
1568
+ case "component":
1569
+ this.rawComponents.push(definition);
1570
+ return;
1571
+ }
1572
+ }
1573
+ generateParameterDefinition(zodSchema) {
1574
+ const refId = Metadata.getRefId(zodSchema);
1575
+ const result = this.generateParameter(zodSchema);
1576
+ if (refId) {
1577
+ this.paramRefs[refId] = result;
1578
+ }
1579
+ return result;
1580
+ }
1581
+ getParameterRef(schema, external) {
1582
+ const metadata = Metadata.getOpenApiMetadata(schema);
1583
+ const internalMetadata = Metadata.getInternalMetadata(schema);
1584
+ const parameterMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
1585
+ const existingRef = (internalMetadata === null || internalMetadata === undefined ? undefined : internalMetadata.refId) ? this.paramRefs[internalMetadata.refId] : undefined;
1586
+ if (!(internalMetadata === null || internalMetadata === undefined ? undefined : internalMetadata.refId) || !existingRef) {
1587
+ return;
1588
+ }
1589
+ if (parameterMetadata && existingRef.in !== parameterMetadata.in || (external === null || external === undefined ? undefined : external.in) && existingRef.in !== external.in) {
1590
+ throw new ConflictError(`Conflicting location for parameter ${existingRef.name}`, {
1591
+ key: "in",
1592
+ values: compact([
1593
+ existingRef.in,
1594
+ external === null || external === undefined ? undefined : external.in,
1595
+ parameterMetadata === null || parameterMetadata === undefined ? undefined : parameterMetadata.in
1596
+ ])
1597
+ });
1598
+ }
1599
+ if (parameterMetadata && existingRef.name !== parameterMetadata.name || (external === null || external === undefined ? undefined : external.name) && existingRef.name !== (external === null || external === undefined ? undefined : external.name)) {
1600
+ throw new ConflictError(`Conflicting names for parameter`, {
1601
+ key: "name",
1602
+ values: compact([
1603
+ existingRef.name,
1604
+ external === null || external === undefined ? undefined : external.name,
1605
+ parameterMetadata === null || parameterMetadata === undefined ? undefined : parameterMetadata.name
1606
+ ])
1607
+ });
1608
+ }
1609
+ return {
1610
+ $ref: `#/components/parameters/${internalMetadata.refId}`
1611
+ };
1612
+ }
1613
+ generateInlineParameters(zodSchema, location) {
1614
+ const metadata = Metadata.getOpenApiMetadata(zodSchema);
1615
+ const parameterMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
1616
+ const referencedSchema = this.getParameterRef(zodSchema, { in: location });
1617
+ if (referencedSchema) {
1618
+ return [referencedSchema];
1619
+ }
1620
+ if (isZodType(zodSchema, "ZodObject")) {
1621
+ const propTypes = zodSchema.def.shape;
1622
+ const parameters = Object.entries(propTypes).map(([key, schema]) => {
1623
+ var _a;
1624
+ const innerMetadata = Metadata.getOpenApiMetadata(schema);
1625
+ const referencedSchema2 = this.getParameterRef(schema, {
1626
+ in: location,
1627
+ name: key
1628
+ });
1629
+ if (referencedSchema2) {
1630
+ return referencedSchema2;
1631
+ }
1632
+ const innerParameterMetadata = innerMetadata === null || innerMetadata === undefined ? undefined : innerMetadata.param;
1633
+ if ((innerParameterMetadata === null || innerParameterMetadata === undefined ? undefined : innerParameterMetadata.name) && innerParameterMetadata.name !== key) {
1634
+ throw new ConflictError(`Conflicting names for parameter`, {
1635
+ key: "name",
1636
+ values: [key, innerParameterMetadata.name]
1637
+ });
1638
+ }
1639
+ if ((innerParameterMetadata === null || innerParameterMetadata === undefined ? undefined : innerParameterMetadata.in) && innerParameterMetadata.in !== location) {
1640
+ throw new ConflictError(`Conflicting location for parameter ${(_a = innerParameterMetadata.name) !== null && _a !== undefined ? _a : key}`, {
1641
+ key: "in",
1642
+ values: [location, innerParameterMetadata.in]
1643
+ });
1644
+ }
1645
+ return this.generateParameter(schema, { name: key, in: location });
1646
+ });
1647
+ return parameters;
1648
+ }
1649
+ if ((parameterMetadata === null || parameterMetadata === undefined ? undefined : parameterMetadata.in) && parameterMetadata.in !== location) {
1650
+ throw new ConflictError(`Conflicting location for parameter ${parameterMetadata.name}`, {
1651
+ key: "in",
1652
+ values: [location, parameterMetadata.in]
1653
+ });
1654
+ }
1655
+ return [this.generateParameter(zodSchema, { in: location })];
1656
+ }
1657
+ generateSimpleParameter(zodSchema, externalParamMetadata) {
1658
+ const metadata = Metadata.getParamMetadata(zodSchema);
1659
+ const paramMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
1660
+ const mergedParamMetadata = Object.assign(Object.assign({}, paramMetadata), externalParamMetadata);
1661
+ const required = !isOptionalSchema(zodSchema) && !isNullableSchema(zodSchema);
1662
+ const schema = this.generateSchemaWithRef(zodSchema);
1663
+ return Object.assign({
1664
+ schema,
1665
+ required
1666
+ }, Object.keys(mergedParamMetadata).length > 0 ? Metadata.buildParameterMetadata(mergedParamMetadata) : {});
1667
+ }
1668
+ generateParameter(zodSchema, externalParamMetadata) {
1669
+ var _a, _b;
1670
+ const metadata = Metadata.getOpenApiMetadata(zodSchema);
1671
+ const paramMetadata = metadata === null || metadata === undefined ? undefined : metadata.param;
1672
+ const paramName = (_a = externalParamMetadata === null || externalParamMetadata === undefined ? undefined : externalParamMetadata.name) !== null && _a !== undefined ? _a : paramMetadata === null || paramMetadata === undefined ? undefined : paramMetadata.name;
1673
+ const paramLocation = (_b = externalParamMetadata === null || externalParamMetadata === undefined ? undefined : externalParamMetadata.in) !== null && _b !== undefined ? _b : paramMetadata === null || paramMetadata === undefined ? undefined : paramMetadata.in;
1674
+ if (!paramName) {
1675
+ throw new MissingParameterDataError({ missingField: "name" });
1676
+ }
1677
+ if (!paramLocation) {
1678
+ throw new MissingParameterDataError({
1679
+ missingField: "in",
1680
+ paramName
1681
+ });
1682
+ }
1683
+ const baseParameter = this.generateSimpleParameter(zodSchema, externalParamMetadata);
1684
+ return Object.assign(Object.assign({}, baseParameter), { in: paramLocation, name: paramName });
1685
+ }
1686
+ generateSchemaWithMetadata(zodSchema) {
1687
+ const innerSchema = Metadata.unwrapChained(zodSchema);
1688
+ const metadata = Metadata.getOpenApiMetadata(zodSchema);
1689
+ const defaultValue = Metadata.getDefaultValue(zodSchema);
1690
+ const refId = Metadata.getRefId(zodSchema);
1691
+ if (refId && typeof this.schemaRefs[refId] === "object") {
1692
+ return this.schemaRefs[refId];
1693
+ }
1694
+ if (refId && this.schemaRefs[refId] === "pending") {
1695
+ const refSchema = { $ref: this.generateSchemaRef(refId) };
1696
+ return this.versionSpecifics.mapNullableOfRef(refSchema, isNullableSchema(zodSchema));
1697
+ }
1698
+ if (refId && !this.schemaRefs[refId]) {
1699
+ this.schemaRefs[refId] = "pending";
1700
+ }
1701
+ const result = (metadata === null || metadata === undefined ? undefined : metadata.type) ? { type: metadata.type } : this.toOpenAPISchema(innerSchema, isNullableSchema(zodSchema), defaultValue);
1702
+ return metadata ? Metadata.applySchemaMetadata(result, metadata) : omitBy(result, isUndefined);
1703
+ }
1704
+ constructReferencedOpenAPISchema(zodSchema) {
1705
+ const metadata = Metadata.getOpenApiMetadata(zodSchema);
1706
+ const innerSchema = Metadata.unwrapChained(zodSchema);
1707
+ const defaultValue = Metadata.getDefaultValue(zodSchema);
1708
+ const isNullable = isNullableSchema(zodSchema);
1709
+ if (metadata === null || metadata === undefined ? undefined : metadata.type) {
1710
+ return this.versionSpecifics.mapNullableType(metadata.type, isNullable);
1711
+ }
1712
+ const refId = Metadata.getRefId(zodSchema);
1713
+ if (refId && typeof this.schemaRefs[refId] === "object") {
1714
+ return LazyTransformer.mapRecursive(this.schemaRefs[refId], (schema) => this.versionSpecifics.mapNullableType(schema, isNullable), (schema) => this.versionSpecifics.mapNullableOfRef(schema, isNullable));
1715
+ }
1716
+ if (refId && this.schemaRefs[refId] === "pending") {
1717
+ const refSchema = { $ref: this.generateSchemaRef(refId) };
1718
+ return this.versionSpecifics.mapNullableOfRef(refSchema, isNullable);
1719
+ }
1720
+ if (refId && !this.schemaRefs[refId]) {
1721
+ this.schemaRefs[refId] = "pending";
1722
+ }
1723
+ return this.toOpenAPISchema(innerSchema, isNullable, defaultValue);
1724
+ }
1725
+ generateSimpleSchema(zodSchema) {
1726
+ const metadata = Metadata.getOpenApiMetadata(zodSchema);
1727
+ const refId = Metadata.getRefId(zodSchema);
1728
+ if (!refId || !this.schemaRefs[refId]) {
1729
+ return this.generateSchemaWithMetadata(zodSchema);
1730
+ }
1731
+ const schemaRef = this.schemaRefs[refId];
1732
+ const referenceObject = {
1733
+ $ref: this.generateSchemaRef(refId)
1734
+ };
1735
+ if (this.schemaRefs[refId] === "pending") {
1736
+ return this.versionSpecifics.mapNullableOfRef(referenceObject, isNullableSchema(zodSchema));
1737
+ }
1738
+ const newMetadata = omitBy(Metadata.buildSchemaMetadata(metadata !== null && metadata !== undefined ? metadata : {}), (value, key) => value === undefined || objectEquals(value, schemaRef[key]));
1739
+ if (newMetadata.type) {
1740
+ return {
1741
+ allOf: [referenceObject, newMetadata]
1742
+ };
1743
+ }
1744
+ const newSchemaMetadata = omitBy(this.constructReferencedOpenAPISchema(zodSchema), (value, key) => value === undefined || objectEquals(value, schemaRef[key]));
1745
+ const appliedMetadata = Metadata.applySchemaMetadata(newSchemaMetadata, newMetadata);
1746
+ if (Object.keys(appliedMetadata).length > 0) {
1747
+ return {
1748
+ allOf: [referenceObject, appliedMetadata]
1749
+ };
1750
+ }
1751
+ return referenceObject;
1752
+ }
1753
+ generateSchemaWithRef(zodSchema) {
1754
+ const refId = Metadata.getRefId(zodSchema);
1755
+ if (refId && !this.schemaRefs[refId]) {
1756
+ this.schemaRefs[refId] = this.generateSimpleSchema(zodSchema);
1757
+ return { $ref: this.generateSchemaRef(refId) };
1758
+ }
1759
+ return this.generateSimpleSchema(zodSchema);
1760
+ }
1761
+ generateSchemaRef(refId) {
1762
+ return `#/components/schemas/${refId}`;
1763
+ }
1764
+ getRequestBody(requestBody) {
1765
+ if (!requestBody) {
1766
+ return;
1767
+ }
1768
+ const { content } = requestBody, rest = __rest(requestBody, ["content"]);
1769
+ const requestBodyContent = this.getBodyContent(content);
1770
+ return Object.assign(Object.assign({}, rest), { content: requestBodyContent });
1771
+ }
1772
+ getParameters(request) {
1773
+ if (!request) {
1774
+ return [];
1775
+ }
1776
+ const { headers } = request;
1777
+ const query = this.cleanParameter(request.query);
1778
+ const params = this.cleanParameter(request.params);
1779
+ const cookies = this.cleanParameter(request.cookies);
1780
+ const queryParameters = enhanceMissingParametersError(() => query ? this.generateInlineParameters(query, "query") : [], { location: "query" });
1781
+ const pathParameters = enhanceMissingParametersError(() => params ? this.generateInlineParameters(params, "path") : [], { location: "path" });
1782
+ const cookieParameters = enhanceMissingParametersError(() => cookies ? this.generateInlineParameters(cookies, "cookie") : [], { location: "cookie" });
1783
+ const headerParameters = enhanceMissingParametersError(() => {
1784
+ if (Array.isArray(headers)) {
1785
+ return headers.flatMap((header) => this.generateInlineParameters(header, "header"));
1786
+ }
1787
+ const cleanHeaders = this.cleanParameter(headers);
1788
+ return cleanHeaders ? this.generateInlineParameters(cleanHeaders, "header") : [];
1789
+ }, { location: "header" });
1790
+ return [
1791
+ ...pathParameters,
1792
+ ...queryParameters,
1793
+ ...headerParameters,
1794
+ ...cookieParameters
1795
+ ];
1796
+ }
1797
+ cleanParameter(schema) {
1798
+ if (!schema) {
1799
+ return;
1800
+ }
1801
+ if (isZodType(schema, "ZodPipe")) {
1802
+ const inSchema = schema._zod.def.in;
1803
+ const outSchema = schema._zod.def.out;
1804
+ if (isZodType(inSchema, "ZodObject")) {
1805
+ return this.cleanParameter(inSchema);
1806
+ }
1807
+ if (isZodType(outSchema, "ZodObject")) {
1808
+ return this.cleanParameter(outSchema);
1809
+ }
1810
+ return;
1811
+ }
1812
+ return schema;
1813
+ }
1814
+ generatePath(route) {
1815
+ const { method, path, request, responses } = route, pathItemConfig = __rest(route, ["method", "path", "request", "responses"]);
1816
+ const generatedResponses = mapValues(responses, (response) => {
1817
+ return this.getResponse(response);
1818
+ });
1819
+ const parameters = enhanceMissingParametersError(() => this.getParameters(request), { route: `${method} ${path}` });
1820
+ const requestBody = this.getRequestBody(request === null || request === undefined ? undefined : request.body);
1821
+ const routeDoc = {
1822
+ [method]: Object.assign(Object.assign(Object.assign(Object.assign({}, pathItemConfig), parameters.length > 0 ? {
1823
+ parameters: [...pathItemConfig.parameters || [], ...parameters]
1824
+ } : {}), requestBody ? { requestBody } : {}), { responses: generatedResponses })
1825
+ };
1826
+ return routeDoc;
1827
+ }
1828
+ generateSingleRoute(route) {
1829
+ const routeDoc = this.generatePath(route);
1830
+ this.pathRefs[route.path] = Object.assign(Object.assign({}, this.pathRefs[route.path]), routeDoc);
1831
+ return routeDoc;
1832
+ }
1833
+ getResponse(response) {
1834
+ if (this.isReferenceObject(response)) {
1835
+ return response;
1836
+ }
1837
+ const { content, headers } = response, rest = __rest(response, ["content", "headers"]);
1838
+ const responseContent = content ? { content: this.getBodyContent(content) } : {};
1839
+ if (!headers) {
1840
+ return Object.assign(Object.assign({}, rest), responseContent);
1841
+ }
1842
+ const responseHeaders = isZodType(headers, "ZodObject") ? this.getResponseHeaders(headers) : headers;
1843
+ return Object.assign(Object.assign(Object.assign({}, rest), { headers: responseHeaders }), responseContent);
1844
+ }
1845
+ isReferenceObject(schema) {
1846
+ return "$ref" in schema;
1847
+ }
1848
+ getResponseHeaders(headers) {
1849
+ const schemaShape = headers.def.shape;
1850
+ const responseHeaders = mapValues(schemaShape, (_) => this.generateSimpleParameter(_));
1851
+ return responseHeaders;
1852
+ }
1853
+ getBodyContent(content) {
1854
+ return mapValues(content, (config) => {
1855
+ if (!config || !isAnyZodType(config.schema)) {
1856
+ return config;
1857
+ }
1858
+ const { schema: configSchema } = config, rest = __rest(config, ["schema"]);
1859
+ const schema = this.generateSchemaWithRef(configSchema);
1860
+ return Object.assign({ schema }, rest);
1861
+ });
1862
+ }
1863
+ toOpenAPISchema(zodSchema, isNullable, defaultValue) {
1864
+ const result = this.openApiTransformer.transform(zodSchema, isNullable, (_) => this.generateSchemaWithRef(_), (_) => this.generateSchemaRef(_), defaultValue);
1865
+ return result;
1866
+ }
1867
+ }
1868
+
1869
+ class OpenApiGeneratorV31Specifics {
1870
+ get nullType() {
1871
+ return { type: "null" };
1872
+ }
1873
+ mapNullableOfArray(objects, isNullable) {
1874
+ if (isNullable && !objects.some((object2) => objectEquals(object2, this.nullType))) {
1875
+ return [...objects, this.nullType];
1876
+ }
1877
+ return objects;
1878
+ }
1879
+ mapNullableType(type, isNullable) {
1880
+ if (!type) {
1881
+ return {};
1882
+ }
1883
+ if (isNullable) {
1884
+ const typeArray = Array.isArray(type) ? type : [type];
1885
+ const nullableType = uniq([...typeArray, "null"]);
1886
+ return { type: nullableType };
1887
+ }
1888
+ return { type };
1889
+ }
1890
+ mapNullableOfRef(ref, isNullable) {
1891
+ if (isNullable) {
1892
+ return {
1893
+ oneOf: [ref, this.nullType]
1894
+ };
1895
+ }
1896
+ return ref;
1897
+ }
1898
+ mapTupleItems(schemas) {
1899
+ return {
1900
+ prefixItems: schemas
1901
+ };
1902
+ }
1903
+ getNumberChecks(checks) {
1904
+ return Object.assign({}, ...checks.map((check) => {
1905
+ switch (check._zod.def.check) {
1906
+ case "greater_than": {
1907
+ const greaterThanCheck = check;
1908
+ return greaterThanCheck._zod.def.inclusive ? { minimum: Number(greaterThanCheck._zod.def.value) } : { exclusiveMinimum: Number(greaterThanCheck._zod.def.value) };
1909
+ }
1910
+ case "less_than": {
1911
+ const lessThanCheck = check;
1912
+ return lessThanCheck._zod.def.inclusive ? { maximum: Number(lessThanCheck._zod.def.value) } : { exclusiveMaximum: Number(lessThanCheck._zod.def.value) };
1913
+ }
1914
+ default:
1915
+ return {};
1916
+ }
1917
+ }));
1918
+ }
1919
+ }
1920
+ function isWebhookDefinition(definition) {
1921
+ return "type" in definition && definition.type === "webhook";
1922
+ }
1923
+
1924
+ class OpenApiGeneratorV31 {
1925
+ constructor(definitions, options) {
1926
+ this.definitions = definitions;
1927
+ this.webhookRefs = {};
1928
+ const specifics = new OpenApiGeneratorV31Specifics;
1929
+ this.generator = new OpenAPIGenerator(this.definitions, specifics, options);
1930
+ }
1931
+ generateDocument(config) {
1932
+ const baseDocument = this.generator.generateDocumentData();
1933
+ this.definitions.filter(isWebhookDefinition).forEach((definition) => this.generateSingleWebhook(definition.webhook));
1934
+ return Object.assign(Object.assign(Object.assign({}, config), baseDocument), { webhooks: this.webhookRefs });
1935
+ }
1936
+ generateComponents() {
1937
+ return this.generator.generateComponents();
1938
+ }
1939
+ generateSingleWebhook(route) {
1940
+ const routeDoc = this.generator.generatePath(route);
1941
+ this.webhookRefs[route.path] = Object.assign(Object.assign({}, this.webhookRefs[route.path]), routeDoc);
1942
+ return routeDoc;
1943
+ }
1944
+ }
1945
+ var ZodTypeKeys, objectEquals, zodToOpenAPIRegistry, ConflictError, MissingParameterDataError, UnknownZodTypeError, $OpenAPIRegistry, $OpenApiGeneratorV31, $extendZodWithOpenApi;
1946
+ var init_dist = __esm(() => {
1947
+ ZodTypeKeys = {
1948
+ ZodAny: "any",
1949
+ ZodArray: "array",
1950
+ ZodBigInt: "bigint",
1951
+ ZodBoolean: "boolean",
1952
+ ZodDefault: "default",
1953
+ ZodPrefault: "prefault",
1954
+ ZodTransform: "transform",
1955
+ ZodEnum: "enum",
1956
+ ZodIntersection: "intersection",
1957
+ ZodLazy: "lazy",
1958
+ ZodLiteral: "literal",
1959
+ ZodNever: "never",
1960
+ ZodNull: "null",
1961
+ ZodNullable: "nullable",
1962
+ ZodNumber: "number",
1963
+ ZodNonOptional: "nonoptional",
1964
+ ZodObject: "object",
1965
+ ZodOptional: "optional",
1966
+ ZodPipe: "pipe",
1967
+ ZodReadonly: "readonly",
1968
+ ZodRecord: "record",
1969
+ ZodString: "string",
1970
+ ZodTuple: "tuple",
1971
+ ZodType: "type",
1972
+ ZodUnion: "union",
1973
+ ZodDiscriminatedUnion: "union",
1974
+ ZodUnknown: "unknown",
1975
+ ZodVoid: "void",
1976
+ ZodDate: "date",
1977
+ ZodTemplateLiteral: "template_literal"
1978
+ };
1979
+ objectEquals = isEqual;
1980
+ zodToOpenAPIRegistry = registry();
1981
+ ConflictError = class ConflictError extends ZodToOpenAPIError {
1982
+ constructor(message, data) {
1983
+ super(message);
1984
+ this.data = data;
1985
+ }
1986
+ };
1987
+ MissingParameterDataError = class MissingParameterDataError extends ZodToOpenAPIError {
1988
+ constructor(data) {
1989
+ super(`Missing parameter data, please specify \`${data.missingField}\` and other OpenAPI parameter props using the \`param\` field of \`schema.openapi\``);
1990
+ this.data = data;
1991
+ }
1992
+ };
1993
+ UnknownZodTypeError = class UnknownZodTypeError extends ZodToOpenAPIError {
1994
+ constructor(data) {
1995
+ super(`Unknown zod object type, please specify \`type\` and other OpenAPI props using \`schema.openapi\`.`);
1996
+ this.data = data;
1997
+ }
1998
+ };
1999
+ $OpenAPIRegistry = OpenAPIRegistry;
2000
+ $OpenApiGeneratorV31 = OpenApiGeneratorV31;
2001
+ $extendZodWithOpenApi = extendZodWithOpenApi;
2002
+ });
2003
+
2004
+ // src/utils/zod-openapi.ts
2005
+ var init_zod_openapi = __esm(() => {
2006
+ init_dist();
2007
+ init_zod();
2008
+ $extendZodWithOpenApi(exports_zod);
2009
+ });
2010
+
589
2011
  // src/types.ts
590
2012
  function parseModelTier(value) {
591
2013
  if (!value)
@@ -657,10 +2079,10 @@ function isTerminalTaskStatus(status) {
657
2079
  }
658
2080
  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, ProviderNameSchema, SteerModeSchema, SteeringStatusSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, PROVIDER_STEER_CAPABILITIES, FollowUpConfigSchema, RoutingAffinitySchema, AgentTaskSchema, TaskAttachmentKindSchema, attachmentCommonFields, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, IdentityEventTypeSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentCredStatusLiveTestSchema, AgentLatestModelSchema, AgentBedrockStatusSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChangeSourceSchema, VersionableFieldSchema, ContextVersionSchema, ChannelTypeSchema, ChannelSchema, ChannelMessageSchema, ServiceStatusSchema, ServiceSchema, AgentLogEventTypeSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostSourceSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, 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, 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;
659
2081
  var init_types = __esm(() => {
660
- init_zod();
661
2082
  init_key();
662
2083
  init_constants();
663
- AssetKeySchema = string().min(1).max(255).superRefine((value, ctx) => {
2084
+ init_zod_openapi();
2085
+ AssetKeySchema = exports_zod.string().min(1).max(255).superRefine((value, ctx) => {
664
2086
  try {
665
2087
  normalizeAssetKey(value);
666
2088
  } catch (error) {
@@ -670,38 +2092,46 @@ var init_types = __esm(() => {
670
2092
  });
671
2093
  }
672
2094
  }).describe("Non-unique asset directory namespace (for example shared/ or personal/<user-id>/drafts/). Runtime write boundaries normalize and validate the canonical form.");
673
- AssetEntityTypeSchema = _enum(["task", "workflow", "schedule", "page", "file"]);
674
- AssetProviderRefSchema = object({
675
- providerId: string(),
676
- orgId: string().optional(),
677
- driveId: string().optional(),
678
- providerKey: string()
679
- });
680
- AssetKeyMappingSchema = object({
681
- id: string(),
682
- providerId: string(),
683
- providerOrgId: string().optional(),
684
- providerDriveId: string().optional(),
685
- providerKey: string(),
2095
+ AssetEntityTypeSchema = exports_zod.enum([
2096
+ "task",
2097
+ "workflow",
2098
+ "schedule",
2099
+ "page",
2100
+ "app",
2101
+ "script",
2102
+ "file"
2103
+ ]);
2104
+ AssetProviderRefSchema = exports_zod.object({
2105
+ providerId: exports_zod.string(),
2106
+ orgId: exports_zod.string().optional(),
2107
+ driveId: exports_zod.string().optional(),
2108
+ providerKey: exports_zod.string()
2109
+ }).openapi("AssetProviderRef");
2110
+ AssetKeyMappingSchema = exports_zod.object({
2111
+ id: exports_zod.string(),
2112
+ providerId: exports_zod.string(),
2113
+ providerOrgId: exports_zod.string().optional(),
2114
+ providerDriveId: exports_zod.string().optional(),
2115
+ providerKey: exports_zod.string(),
686
2116
  key: AssetKeySchema,
687
- sourceEntityType: _enum(["task-attachment", "external"]).optional(),
688
- sourceEntityId: string().optional(),
689
- createdAt: exports_iso.datetime(),
690
- updatedAt: exports_iso.datetime(),
691
- createdBy: string().optional(),
692
- updatedBy: string().optional()
693
- });
694
- AssetSummarySchema = object({
2117
+ sourceEntityType: exports_zod.enum(["task-attachment", "external"]).optional(),
2118
+ sourceEntityId: exports_zod.string().optional(),
2119
+ createdAt: exports_zod.iso.datetime(),
2120
+ updatedAt: exports_zod.iso.datetime(),
2121
+ createdBy: exports_zod.string().optional(),
2122
+ updatedBy: exports_zod.string().optional()
2123
+ }).openapi("AssetKeyMapping");
2124
+ AssetSummarySchema = exports_zod.object({
695
2125
  entityType: AssetEntityTypeSchema,
696
- id: string(),
2126
+ id: exports_zod.string(),
697
2127
  key: AssetKeySchema,
698
- label: string(),
699
- updatedAt: string(),
2128
+ label: exports_zod.string(),
2129
+ updatedAt: exports_zod.string(),
700
2130
  providerRef: AssetProviderRefSchema.optional()
701
- });
702
- ModelTierSchema = _enum(["smol", "regular", "smart", "ultra"]);
2131
+ }).openapi("AssetSummary");
2132
+ ModelTierSchema = exports_zod.enum(["smol", "regular", "smart", "ultra"]);
703
2133
  MODEL_TIERS = ModelTierSchema.options;
704
- ReasoningEffortSchema = _enum(["off", "low", "medium", "high", "xhigh", "max"]);
2134
+ ReasoningEffortSchema = exports_zod.enum(["off", "low", "medium", "high", "xhigh", "max"]);
705
2135
  LEGACY_MODEL_TO_TIER = {
706
2136
  haiku: "smol",
707
2137
  sonnet: "regular",
@@ -746,7 +2176,7 @@ var init_types = __esm(() => {
746
2176
  ultra: "devin"
747
2177
  }
748
2178
  };
749
- AgentTaskStatusSchema = _enum([
2179
+ AgentTaskStatusSchema = exports_zod.enum([
750
2180
  "backlog",
751
2181
  "unassigned",
752
2182
  "offered",
@@ -760,29 +2190,29 @@ var init_types = __esm(() => {
760
2190
  "superseded"
761
2191
  ]);
762
2192
  TERMINAL_TASK_STATUSES = ["completed", "failed", "cancelled", "superseded"];
763
- InboxMessageStatusSchema = _enum([
2193
+ InboxMessageStatusSchema = exports_zod.enum([
764
2194
  "unread",
765
2195
  "processing",
766
2196
  "read",
767
2197
  "responded",
768
2198
  "delegated"
769
2199
  ]);
770
- InboxMessageSchema = object({
771
- id: uuid(),
772
- agentId: string(),
773
- content: string().min(1),
774
- source: _enum(["slack", "agentmail"]).default("slack"),
2200
+ InboxMessageSchema = exports_zod.object({
2201
+ id: exports_zod.uuid(),
2202
+ agentId: exports_zod.string(),
2203
+ content: exports_zod.string().min(1),
2204
+ source: exports_zod.enum(["slack", "agentmail"]).default("slack"),
775
2205
  status: InboxMessageStatusSchema.default("unread"),
776
- slackChannelId: string().optional(),
777
- slackThreadTs: string().optional(),
778
- slackUserId: string().optional(),
779
- matchedText: string().optional(),
780
- delegatedToTaskId: uuid().optional(),
781
- responseText: string().optional(),
782
- createdAt: exports_iso.datetime(),
783
- lastUpdatedAt: exports_iso.datetime()
784
- });
785
- AgentTaskSourceSchema = _enum([
2206
+ slackChannelId: exports_zod.string().optional(),
2207
+ slackThreadTs: exports_zod.string().optional(),
2208
+ slackUserId: exports_zod.string().optional(),
2209
+ matchedText: exports_zod.string().optional(),
2210
+ delegatedToTaskId: exports_zod.uuid().optional(),
2211
+ responseText: exports_zod.string().optional(),
2212
+ createdAt: exports_zod.iso.datetime(),
2213
+ lastUpdatedAt: exports_zod.iso.datetime()
2214
+ }).openapi("InboxMessage");
2215
+ AgentTaskSourceSchema = exports_zod.enum([
786
2216
  "mcp",
787
2217
  "slack",
788
2218
  "api",
@@ -796,7 +2226,7 @@ var init_types = __esm(() => {
796
2226
  "linear",
797
2227
  "jira"
798
2228
  ]);
799
- ProviderNameSchema = _enum([
2229
+ ProviderNameSchema = exports_zod.enum([
800
2230
  "claude",
801
2231
  "codex",
802
2232
  "pi",
@@ -804,41 +2234,41 @@ var init_types = __esm(() => {
804
2234
  "claude-managed",
805
2235
  "opencode"
806
2236
  ]);
807
- SteerModeSchema = _enum(["steer", "queue"]);
808
- SteeringStatusSchema = _enum([
2237
+ SteerModeSchema = exports_zod.enum(["steer", "queue"]);
2238
+ SteeringStatusSchema = exports_zod.enum([
809
2239
  "pending",
810
2240
  "delivered",
811
2241
  "handled",
812
2242
  "promoted",
813
2243
  "cancelled"
814
2244
  ]);
815
- SteeringSourceSchema = _enum(["ui", "mcp", "script", "slack", "api"]);
816
- SteeringMessageSchema = object({
817
- id: uuid(),
818
- taskId: uuid(),
819
- body: string().min(1),
2245
+ SteeringSourceSchema = exports_zod.enum(["ui", "mcp", "script", "slack", "api"]);
2246
+ SteeringMessageSchema = exports_zod.object({
2247
+ id: exports_zod.uuid(),
2248
+ taskId: exports_zod.uuid(),
2249
+ body: exports_zod.string().min(1),
820
2250
  mode: SteerModeSchema,
821
2251
  status: SteeringStatusSchema,
822
2252
  deliveredMode: SteerModeSchema.optional(),
823
2253
  source: SteeringSourceSchema,
824
- createdByKind: _enum(["user", "agent", "system"]),
825
- createdByUserId: string().optional(),
826
- createdByAgentId: string().optional(),
827
- promotedTaskId: uuid().optional(),
828
- createdAt: exports_iso.datetime(),
829
- deliveredAt: exports_iso.datetime().optional(),
830
- handledAt: exports_iso.datetime().optional(),
831
- handledNote: string().optional()
832
- });
833
- SteerOutcomeSchema = _enum(["steered", "queued", "promoted"]);
834
- OnUnsupportedSchema = _enum(["degrade", "fail"]).default("degrade");
835
- SteerResultSchema = object({
2254
+ createdByKind: exports_zod.enum(["user", "agent", "system"]),
2255
+ createdByUserId: exports_zod.string().optional(),
2256
+ createdByAgentId: exports_zod.string().optional(),
2257
+ promotedTaskId: exports_zod.uuid().optional(),
2258
+ createdAt: exports_zod.iso.datetime(),
2259
+ deliveredAt: exports_zod.iso.datetime().optional(),
2260
+ handledAt: exports_zod.iso.datetime().optional(),
2261
+ handledNote: exports_zod.string().optional()
2262
+ }).openapi("SteeringMessage");
2263
+ SteerOutcomeSchema = exports_zod.enum(["steered", "queued", "promoted"]);
2264
+ OnUnsupportedSchema = exports_zod.enum(["degrade", "fail"]).default("degrade");
2265
+ SteerResultSchema = exports_zod.object({
836
2266
  outcome: SteerOutcomeSchema,
837
- steeringMessageId: uuid().optional(),
838
- promotedTaskId: uuid().optional(),
2267
+ steeringMessageId: exports_zod.uuid().optional(),
2268
+ promotedTaskId: exports_zod.uuid().optional(),
839
2269
  effectiveMode: SteerModeSchema,
840
2270
  degradedFrom: SteerModeSchema.optional()
841
- });
2271
+ }).openapi("SteerResult");
842
2272
  PROVIDER_STEER_CAPABILITIES = {
843
2273
  pi: ["steer", "queue"],
844
2274
  "claude-managed": ["steer", "queue"],
@@ -847,167 +2277,167 @@ var init_types = __esm(() => {
847
2277
  claude: ["queue"],
848
2278
  codex: ["queue"]
849
2279
  };
850
- FollowUpConfigSchema = object({
851
- disabled: boolean().optional(),
852
- onCompleted: string().max(4000).optional(),
853
- onFailed: string().max(4000).optional()
854
- });
855
- RoutingAffinitySchema = object({
856
- sourceAgentId: string().optional(),
857
- role: string().max(100).optional(),
2280
+ FollowUpConfigSchema = exports_zod.object({
2281
+ disabled: exports_zod.boolean().optional(),
2282
+ onCompleted: exports_zod.string().max(4000).optional(),
2283
+ onFailed: exports_zod.string().max(4000).optional()
2284
+ }).openapi("FollowUpConfig");
2285
+ RoutingAffinitySchema = exports_zod.object({
2286
+ sourceAgentId: exports_zod.string().optional(),
2287
+ role: exports_zod.string().max(100).optional(),
858
2288
  harnessProvider: ProviderNameSchema.optional(),
859
- capabilities: array(string()).default([])
860
- });
861
- AgentTaskSchema = object({
862
- id: uuid(),
2289
+ capabilities: exports_zod.array(exports_zod.string()).default([])
2290
+ }).openapi("RoutingAffinity");
2291
+ AgentTaskSchema = exports_zod.object({
2292
+ id: exports_zod.uuid(),
863
2293
  key: AssetKeySchema,
864
- agentId: string().nullable(),
865
- creatorAgentId: string().optional(),
866
- task: string().min(1),
867
- title: string().optional(),
2294
+ agentId: exports_zod.string().nullable(),
2295
+ creatorAgentId: exports_zod.string().optional(),
2296
+ task: exports_zod.string().min(1),
2297
+ title: exports_zod.string().optional(),
868
2298
  status: AgentTaskStatusSchema,
869
2299
  source: AgentTaskSourceSchema.default("mcp"),
870
- taskType: string().max(50).optional(),
871
- tags: array(string()).default([]),
872
- priority: number().int().min(0).max(100).default(50),
873
- dependsOn: array(uuid()).default([]),
874
- offeredTo: string().optional(),
875
- offeredAt: exports_iso.datetime().optional(),
876
- acceptedAt: exports_iso.datetime().optional(),
877
- rejectionReason: string().optional(),
878
- createdAt: exports_iso.datetime().default(() => new Date().toISOString()),
879
- lastUpdatedAt: exports_iso.datetime().default(() => new Date().toISOString()),
880
- finishedAt: exports_iso.datetime().optional(),
881
- notifiedAt: exports_iso.datetime().optional(),
882
- failureReason: string().optional(),
883
- output: string().optional(),
884
- progress: string().optional(),
885
- slackChannelId: string().optional(),
886
- slackThreadTs: string().optional(),
887
- slackTriggerMessageTs: string().optional(),
888
- slackUserId: string().optional(),
889
- slackReplySent: boolean().default(false),
890
- slackProgressMessageTs: string().optional(),
891
- slackTreeRootMessageTs: string().optional(),
892
- vcsProvider: _enum(["github", "gitlab"]).optional(),
893
- vcsRepo: string().optional(),
894
- vcsEventType: string().optional(),
895
- vcsNumber: number().int().optional(),
896
- vcsCommentId: number().int().optional(),
897
- vcsAuthor: string().optional(),
898
- vcsUrl: string().optional(),
899
- vcsInstallationId: number().int().optional(),
900
- vcsNodeId: string().optional(),
901
- agentmailInboxId: string().optional(),
902
- agentmailMessageId: string().optional(),
903
- agentmailThreadId: string().optional(),
904
- mentionMessageId: uuid().optional(),
905
- mentionChannelId: uuid().optional(),
906
- dir: string().min(1).startsWith("/").optional(),
907
- parentTaskId: uuid().optional(),
908
- claudeSessionId: string().optional(),
909
- model: string().optional(),
2300
+ taskType: exports_zod.string().max(50).optional(),
2301
+ tags: exports_zod.array(exports_zod.string()).default([]),
2302
+ priority: exports_zod.number().int().min(0).max(100).default(50),
2303
+ dependsOn: exports_zod.array(exports_zod.string()).default([]),
2304
+ offeredTo: exports_zod.string().optional(),
2305
+ offeredAt: exports_zod.iso.datetime().optional(),
2306
+ acceptedAt: exports_zod.iso.datetime().optional(),
2307
+ rejectionReason: exports_zod.string().optional(),
2308
+ createdAt: exports_zod.iso.datetime(),
2309
+ lastUpdatedAt: exports_zod.iso.datetime(),
2310
+ finishedAt: exports_zod.iso.datetime().optional(),
2311
+ notifiedAt: exports_zod.iso.datetime().optional(),
2312
+ failureReason: exports_zod.string().optional(),
2313
+ output: exports_zod.string().optional(),
2314
+ progress: exports_zod.string().optional(),
2315
+ slackChannelId: exports_zod.string().optional(),
2316
+ slackThreadTs: exports_zod.string().optional(),
2317
+ slackTriggerMessageTs: exports_zod.string().optional(),
2318
+ slackUserId: exports_zod.string().optional(),
2319
+ slackReplySent: exports_zod.boolean().default(false),
2320
+ slackProgressMessageTs: exports_zod.string().optional(),
2321
+ slackTreeRootMessageTs: exports_zod.string().optional(),
2322
+ vcsProvider: exports_zod.enum(["github", "gitlab"]).optional(),
2323
+ vcsRepo: exports_zod.string().optional(),
2324
+ vcsEventType: exports_zod.string().optional(),
2325
+ vcsNumber: exports_zod.number().int().optional(),
2326
+ vcsCommentId: exports_zod.number().int().optional(),
2327
+ vcsAuthor: exports_zod.string().optional(),
2328
+ vcsUrl: exports_zod.string().optional(),
2329
+ vcsInstallationId: exports_zod.number().int().optional(),
2330
+ vcsNodeId: exports_zod.string().optional(),
2331
+ agentmailInboxId: exports_zod.string().optional(),
2332
+ agentmailMessageId: exports_zod.string().optional(),
2333
+ agentmailThreadId: exports_zod.string().optional(),
2334
+ mentionMessageId: exports_zod.string().optional(),
2335
+ mentionChannelId: exports_zod.string().optional(),
2336
+ dir: exports_zod.string().min(1).optional(),
2337
+ parentTaskId: exports_zod.string().optional(),
2338
+ claudeSessionId: exports_zod.string().optional(),
2339
+ model: exports_zod.string().optional(),
910
2340
  modelTier: ModelTierSchema.optional(),
911
2341
  effort: ReasoningEffortSchema.optional(),
912
- scheduleId: uuid().optional(),
913
- workflowRunId: string().uuid().nullable().optional(),
914
- workflowRunStepId: string().uuid().nullable().optional(),
915
- contextKey: string().optional(),
916
- outputSchema: record(string(), unknown()).optional(),
2342
+ scheduleId: exports_zod.string().optional(),
2343
+ workflowRunId: exports_zod.string().uuid().nullable().optional(),
2344
+ workflowRunStepId: exports_zod.string().uuid().nullable().optional(),
2345
+ contextKey: exports_zod.string().optional(),
2346
+ outputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
917
2347
  followUpConfig: FollowUpConfigSchema.optional(),
918
- wasPaused: boolean().default(false),
919
- compactionCount: number().int().min(0).optional(),
920
- peakContextPercent: number().min(0).max(100).optional(),
921
- peakContextTokens: number().int().min(0).optional(),
922
- contextWindowSize: number().int().min(0).optional(),
923
- credentialKeySuffix: string().optional(),
924
- credentialKeyType: string().optional(),
925
- requestedByUserId: string().optional(),
926
- swarmVersion: string().optional(),
2348
+ wasPaused: exports_zod.boolean().default(false),
2349
+ compactionCount: exports_zod.number().int().min(0).optional(),
2350
+ peakContextPercent: exports_zod.number().min(0).max(100).optional(),
2351
+ peakContextTokens: exports_zod.number().int().min(0).optional(),
2352
+ contextWindowSize: exports_zod.number().int().min(0).optional(),
2353
+ credentialKeySuffix: exports_zod.string().optional(),
2354
+ credentialKeyType: exports_zod.string().optional(),
2355
+ requestedByUserId: exports_zod.string().optional(),
2356
+ swarmVersion: exports_zod.string().optional(),
927
2357
  provider: ProviderNameSchema.optional(),
928
- providerMeta: record(string(), unknown()).optional(),
929
- harnessVariant: string().optional(),
930
- harnessVariantMeta: record(string(), unknown()).optional(),
931
- totalCostUsd: number().min(0).optional(),
2358
+ providerMeta: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2359
+ harnessVariant: exports_zod.string().optional(),
2360
+ harnessVariantMeta: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2361
+ totalCostUsd: exports_zod.number().min(0).optional(),
932
2362
  routingAffinity: RoutingAffinitySchema.optional()
933
- });
934
- TaskAttachmentKindSchema = _enum(["agent-fs", "url", "shared-fs", "page"]);
2363
+ }).openapi("AgentTask");
2364
+ TaskAttachmentKindSchema = exports_zod.enum(["agent-fs", "url", "shared-fs", "page"]);
935
2365
  attachmentCommonFields = {
936
- name: string().min(1).describe("Display name for the attachment."),
937
- providerId: string().min(1).optional(),
938
- providerKey: string().min(1).optional(),
939
- capabilities: record(string(), unknown()).optional(),
940
- mimeType: string().optional(),
941
- sizeBytes: number().int().min(0).optional(),
942
- sha256: string().optional(),
943
- intent: string().optional().describe("WHY this attachment exists — the purpose it serves for this task."),
944
- description: string().optional().describe("Optional: what the attachment is."),
945
- isPrimary: boolean().optional()
2366
+ name: exports_zod.string().min(1).describe("Display name for the attachment."),
2367
+ providerId: exports_zod.string().min(1).optional(),
2368
+ providerKey: exports_zod.string().min(1).optional(),
2369
+ capabilities: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2370
+ mimeType: exports_zod.string().optional(),
2371
+ sizeBytes: exports_zod.number().int().min(0).optional(),
2372
+ sha256: exports_zod.string().optional(),
2373
+ intent: exports_zod.string().optional().describe("WHY this attachment exists — the purpose it serves for this task."),
2374
+ description: exports_zod.string().optional().describe("Optional: what the attachment is."),
2375
+ isPrimary: exports_zod.boolean().optional()
946
2376
  };
947
- AttachmentInputSchema = discriminatedUnion("kind", [
948
- object({
949
- kind: literal("agent-fs"),
950
- path: string().min(1).describe("agent-fs path the attachment points at."),
951
- orgId: string().min(1).optional().describe("agent-fs org id — paired with `driveId` lets the renderer build a public live-host URL."),
952
- driveId: string().min(1).optional().describe("agent-fs drive id — paired with `orgId` lets the renderer build a public live-host URL."),
2377
+ AttachmentInputSchema = exports_zod.discriminatedUnion("kind", [
2378
+ exports_zod.object({
2379
+ kind: exports_zod.literal("agent-fs"),
2380
+ path: exports_zod.string().min(1).describe("agent-fs path the attachment points at."),
2381
+ orgId: exports_zod.string().min(1).optional().describe("agent-fs org id — paired with `driveId` lets the renderer build a public live-host URL."),
2382
+ driveId: exports_zod.string().min(1).optional().describe("agent-fs drive id — paired with `orgId` lets the renderer build a public live-host URL."),
953
2383
  ...attachmentCommonFields
954
2384
  }),
955
- object({
956
- kind: literal("url"),
957
- url: string().min(1).describe("External URL the attachment points at."),
2385
+ exports_zod.object({
2386
+ kind: exports_zod.literal("url"),
2387
+ url: exports_zod.string().min(1).describe("External URL the attachment points at."),
958
2388
  ...attachmentCommonFields
959
2389
  }),
960
- object({
961
- kind: literal("shared-fs"),
962
- path: string().min(1).describe("Shared-filesystem path the attachment points at."),
2390
+ exports_zod.object({
2391
+ kind: exports_zod.literal("shared-fs"),
2392
+ path: exports_zod.string().min(1).describe("Shared-filesystem path the attachment points at."),
963
2393
  ...attachmentCommonFields
964
2394
  }),
965
- object({
966
- kind: literal("page"),
967
- pageId: string().min(1).describe("Swarm Page id the attachment points at."),
2395
+ exports_zod.object({
2396
+ kind: exports_zod.literal("page"),
2397
+ pageId: exports_zod.string().min(1).describe("Swarm Page id the attachment points at."),
968
2398
  ...attachmentCommonFields
969
2399
  })
970
2400
  ]);
971
- TaskAttachmentSchema = object({
972
- id: uuid(),
973
- taskId: uuid(),
974
- agentId: string().nullable(),
975
- name: string(),
2401
+ TaskAttachmentSchema = exports_zod.object({
2402
+ id: exports_zod.uuid(),
2403
+ taskId: exports_zod.uuid(),
2404
+ agentId: exports_zod.string().nullable(),
2405
+ name: exports_zod.string(),
976
2406
  kind: TaskAttachmentKindSchema,
977
- url: string().optional(),
978
- path: string().optional(),
979
- pageId: string().optional(),
980
- providerId: string().optional(),
981
- providerKey: string().optional(),
982
- capabilities: record(string(), unknown()).optional(),
983
- orgId: string().optional(),
984
- driveId: string().optional(),
985
- mimeType: string().optional(),
986
- sizeBytes: number().int().min(0).optional(),
987
- sha256: string().optional(),
988
- intent: string().optional(),
989
- description: string().optional(),
990
- isPrimary: boolean().default(false),
991
- createdAt: exports_iso.datetime(),
992
- createdBy: string().optional(),
993
- updatedBy: string().optional()
994
- });
995
- UserSchema = object({
996
- id: string(),
997
- name: string().min(1),
998
- email: string().optional(),
999
- role: string().optional(),
1000
- notes: string().optional(),
1001
- emailAliases: array(string()).default([]),
1002
- preferredChannel: string().default("slack"),
1003
- timezone: string().optional(),
1004
- metadata: record(string(), unknown()).optional(),
1005
- dailyBudgetUsd: number().nullable().optional(),
1006
- status: _enum(["invited", "active", "suspended"]).default("active"),
1007
- createdAt: exports_iso.datetime(),
1008
- lastUpdatedAt: exports_iso.datetime()
1009
- });
1010
- IdentityEventTypeSchema = _enum([
2407
+ url: exports_zod.string().optional(),
2408
+ path: exports_zod.string().optional(),
2409
+ pageId: exports_zod.string().optional(),
2410
+ providerId: exports_zod.string().optional(),
2411
+ providerKey: exports_zod.string().optional(),
2412
+ capabilities: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2413
+ orgId: exports_zod.string().optional(),
2414
+ driveId: exports_zod.string().optional(),
2415
+ mimeType: exports_zod.string().optional(),
2416
+ sizeBytes: exports_zod.number().int().min(0).optional(),
2417
+ sha256: exports_zod.string().optional(),
2418
+ intent: exports_zod.string().optional(),
2419
+ description: exports_zod.string().optional(),
2420
+ isPrimary: exports_zod.boolean().default(false),
2421
+ createdAt: exports_zod.iso.datetime(),
2422
+ createdBy: exports_zod.string().optional(),
2423
+ updatedBy: exports_zod.string().optional()
2424
+ }).openapi("TaskAttachment");
2425
+ UserSchema = exports_zod.object({
2426
+ id: exports_zod.string(),
2427
+ name: exports_zod.string().min(1),
2428
+ email: exports_zod.string().optional(),
2429
+ role: exports_zod.string().optional(),
2430
+ notes: exports_zod.string().optional(),
2431
+ emailAliases: exports_zod.array(exports_zod.string()).default([]),
2432
+ preferredChannel: exports_zod.string().default("slack"),
2433
+ timezone: exports_zod.string().optional(),
2434
+ metadata: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2435
+ dailyBudgetUsd: exports_zod.number().nullable().optional(),
2436
+ status: exports_zod.enum(["invited", "active", "suspended"]).default("active"),
2437
+ createdAt: exports_zod.iso.datetime(),
2438
+ lastUpdatedAt: exports_zod.iso.datetime()
2439
+ }).openapi("User");
2440
+ IdentityEventTypeSchema = exports_zod.enum([
1011
2441
  "auto_merge",
1012
2442
  "manual_merge",
1013
2443
  "identity_added",
@@ -1020,125 +2450,125 @@ var init_types = __esm(() => {
1020
2450
  "status_changed",
1021
2451
  "profile_changed"
1022
2452
  ]);
1023
- InboxItemTypeSchema = _enum([
2453
+ InboxItemTypeSchema = exports_zod.enum([
1024
2454
  "approval",
1025
2455
  "credential_missing",
1026
2456
  "broken_task",
1027
2457
  "to_read",
1028
2458
  "to_start_template"
1029
2459
  ]);
1030
- InboxItemStatusSchema = _enum(["open", "snoozed", "dismissed", "done"]);
1031
- InboxItemStateSchema = object({
1032
- id: string(),
1033
- userId: string(),
2460
+ InboxItemStatusSchema = exports_zod.enum(["open", "snoozed", "dismissed", "done"]);
2461
+ InboxItemStateSchema = exports_zod.object({
2462
+ id: exports_zod.string(),
2463
+ userId: exports_zod.string(),
1034
2464
  itemType: InboxItemTypeSchema,
1035
- itemId: string(),
2465
+ itemId: exports_zod.string(),
1036
2466
  status: InboxItemStatusSchema,
1037
- snoozeUntil: string().optional(),
1038
- dismissedAt: string().optional(),
1039
- doneAt: string().optional(),
1040
- createdAt: string(),
1041
- lastUpdatedAt: string()
1042
- });
1043
- FavoriteItemTypeSchema = _enum(["page", "workflow", "schedule"]);
1044
- UserFavoriteSchema = object({
1045
- id: string(),
1046
- userId: string().optional(),
2467
+ snoozeUntil: exports_zod.string().optional(),
2468
+ dismissedAt: exports_zod.string().optional(),
2469
+ doneAt: exports_zod.string().optional(),
2470
+ createdAt: exports_zod.string(),
2471
+ lastUpdatedAt: exports_zod.string()
2472
+ }).openapi("InboxItemState");
2473
+ FavoriteItemTypeSchema = exports_zod.enum(["page", "workflow", "schedule"]);
2474
+ UserFavoriteSchema = exports_zod.object({
2475
+ id: exports_zod.string(),
2476
+ userId: exports_zod.string().optional(),
1047
2477
  itemType: FavoriteItemTypeSchema,
1048
- itemId: string(),
1049
- createdAt: string(),
1050
- lastUpdatedAt: string(),
1051
- createdBy: string().optional(),
1052
- updatedBy: string().optional()
1053
- });
1054
- TaskTemplateKindSchema = _enum(["task", "workflow", "schedule"]);
1055
- TaskTemplateSchema = object({
1056
- id: string(),
1057
- title: string().min(1),
1058
- description: string(),
1059
- prompt: string(),
2478
+ itemId: exports_zod.string(),
2479
+ createdAt: exports_zod.string(),
2480
+ lastUpdatedAt: exports_zod.string(),
2481
+ createdBy: exports_zod.string().optional(),
2482
+ updatedBy: exports_zod.string().optional()
2483
+ }).openapi("UserFavorite");
2484
+ TaskTemplateKindSchema = exports_zod.enum(["task", "workflow", "schedule"]);
2485
+ TaskTemplateSchema = exports_zod.object({
2486
+ id: exports_zod.string(),
2487
+ title: exports_zod.string().min(1),
2488
+ description: exports_zod.string(),
2489
+ prompt: exports_zod.string(),
1060
2490
  kind: TaskTemplateKindSchema.default("task"),
1061
- payload: record(string(), unknown()).default({}),
1062
- category: string().optional(),
1063
- tags: array(string()).default([]),
1064
- createdAt: string()
1065
- });
1066
- AgentStatusSchema = _enum(["idle", "busy", "offline", "waiting_for_credentials"]);
1067
- AgentAvatarSchema = discriminatedUnion("type", [
1068
- object({
1069
- type: literal("lucide"),
1070
- icon: string().regex(/^[a-z0-9-]+$/).max(64),
1071
- color: string().regex(/^#[0-9a-fA-F]{6}$/).optional()
2491
+ payload: exports_zod.record(exports_zod.string(), exports_zod.unknown()).default({}),
2492
+ category: exports_zod.string().optional(),
2493
+ tags: exports_zod.array(exports_zod.string()).default([]),
2494
+ createdAt: exports_zod.string()
2495
+ }).openapi("TaskTemplate");
2496
+ AgentStatusSchema = exports_zod.enum(["idle", "busy", "offline", "waiting_for_credentials"]);
2497
+ AgentAvatarSchema = exports_zod.discriminatedUnion("type", [
2498
+ exports_zod.object({
2499
+ type: exports_zod.literal("lucide"),
2500
+ icon: exports_zod.string().regex(/^[a-z0-9-]+$/).max(64),
2501
+ color: exports_zod.string().regex(/^#[0-9a-fA-F]{6}$/).optional()
1072
2502
  })
1073
2503
  ]);
1074
- AgentSchema = object({
1075
- id: string(),
1076
- name: string().min(1),
1077
- isLead: boolean().default(false),
2504
+ AgentSchema = exports_zod.object({
2505
+ id: exports_zod.string(),
2506
+ name: exports_zod.string().min(1),
2507
+ isLead: exports_zod.boolean().default(false),
1078
2508
  status: AgentStatusSchema,
1079
- description: string().optional(),
1080
- role: string().max(100).optional(),
1081
- capabilities: array(string()).default([]),
1082
- claudeMd: string().max(MAX_PROFILE_FILE_LENGTH).optional(),
1083
- soulMd: string().max(MAX_PROFILE_FILE_LENGTH).optional(),
1084
- identityMd: string().max(MAX_PROFILE_FILE_LENGTH).optional(),
1085
- setupScript: string().max(MAX_PROFILE_FILE_LENGTH).optional(),
1086
- toolsMd: string().max(MAX_PROFILE_FILE_LENGTH).optional(),
1087
- heartbeatMd: string().max(MAX_PROFILE_FILE_LENGTH).optional(),
1088
- maxTasks: number().int().min(1).max(100).optional(),
1089
- emptyPollCount: number().int().min(0).optional(),
1090
- lastActivityAt: exports_iso.datetime().optional(),
2509
+ description: exports_zod.string().optional(),
2510
+ role: exports_zod.string().max(100).optional(),
2511
+ capabilities: exports_zod.array(exports_zod.string()).default([]),
2512
+ claudeMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
2513
+ soulMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
2514
+ identityMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
2515
+ setupScript: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
2516
+ toolsMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
2517
+ heartbeatMd: exports_zod.string().max(MAX_PROFILE_FILE_LENGTH).optional(),
2518
+ maxTasks: exports_zod.number().int().min(1).max(100).optional(),
2519
+ emptyPollCount: exports_zod.number().int().min(0).optional(),
2520
+ lastActivityAt: exports_zod.iso.datetime().optional(),
1091
2521
  provider: ProviderNameSchema.optional(),
1092
2522
  harnessProvider: ProviderNameSchema.nullable().optional(),
1093
- credentialMissing: array(string()).nullable().optional(),
1094
- credStatus: lazy(() => AgentCredStatusSchema).nullable().optional(),
1095
- avatar: lazy(() => AgentAvatarSchema).nullable().optional(),
1096
- createdAt: exports_iso.datetime().default(() => new Date().toISOString()),
1097
- lastUpdatedAt: exports_iso.datetime().default(() => new Date().toISOString())
1098
- });
1099
- AgentCredStatusLiveTestSchema = object({
1100
- ok: boolean(),
1101
- error: string().nullable().default(null),
1102
- latency_ms: number(),
1103
- testedAt: number()
1104
- });
1105
- AgentLatestModelSchema = object({
1106
- model: string().min(1),
1107
- source: _enum(["task", "agent_config", "adapter_default", "custom"]),
1108
- taskId: string().nullable().default(null),
2523
+ credentialMissing: exports_zod.array(exports_zod.string()).nullable().optional(),
2524
+ credStatus: exports_zod.lazy(() => AgentCredStatusSchema).nullable().optional(),
2525
+ avatar: exports_zod.lazy(() => AgentAvatarSchema).nullable().optional(),
2526
+ createdAt: exports_zod.iso.datetime(),
2527
+ lastUpdatedAt: exports_zod.iso.datetime()
2528
+ }).openapi("Agent");
2529
+ AgentCredStatusLiveTestSchema = exports_zod.object({
2530
+ ok: exports_zod.boolean(),
2531
+ error: exports_zod.string().nullable().default(null),
2532
+ latency_ms: exports_zod.number(),
2533
+ testedAt: exports_zod.number()
2534
+ }).openapi("AgentCredStatusLiveTest");
2535
+ AgentLatestModelSchema = exports_zod.object({
2536
+ model: exports_zod.string().min(1),
2537
+ source: exports_zod.enum(["task", "agent_config", "adapter_default", "custom"]),
2538
+ taskId: exports_zod.string().nullable().default(null),
1109
2539
  harnessProvider: ProviderNameSchema.nullable().default(null),
1110
- reportedAt: number(),
2540
+ reportedAt: exports_zod.number(),
1111
2541
  reasoningEffort: ReasoningEffortSchema.optional()
1112
- });
1113
- AgentBedrockStatusSchema = object({
1114
- region: string(),
1115
- probedAt: number(),
1116
- ready: boolean(),
1117
- models: array(object({ id: string(), name: string() })).default([]),
1118
- error: string().optional()
1119
- });
1120
- AgentCredStatusSchema = object({
1121
- ready: boolean(),
1122
- missing: array(string()).default([]),
1123
- satisfiedBy: _enum(["env", "file", "side-effect-pending", "sdk-delegated"]).nullable().default(null),
1124
- hint: string().nullable().default(null),
2542
+ }).openapi("AgentLatestModel");
2543
+ AgentBedrockStatusSchema = exports_zod.object({
2544
+ region: exports_zod.string(),
2545
+ probedAt: exports_zod.number(),
2546
+ ready: exports_zod.boolean(),
2547
+ models: exports_zod.array(exports_zod.object({ id: exports_zod.string(), name: exports_zod.string() })).default([]),
2548
+ error: exports_zod.string().optional()
2549
+ }).openapi("AgentBedrockStatus");
2550
+ AgentCredStatusSchema = exports_zod.object({
2551
+ ready: exports_zod.boolean(),
2552
+ missing: exports_zod.array(exports_zod.string()).default([]),
2553
+ satisfiedBy: exports_zod.enum(["env", "file", "side-effect-pending", "sdk-delegated"]).nullable().default(null),
2554
+ hint: exports_zod.string().nullable().default(null),
1125
2555
  liveTest: AgentCredStatusLiveTestSchema.nullable().default(null),
1126
2556
  latestModel: AgentLatestModelSchema.nullable().default(null),
1127
- reportedAt: number(),
1128
- reportKind: _enum(["boot", "post_task"]).default("boot"),
2557
+ reportedAt: exports_zod.number(),
2558
+ reportKind: exports_zod.enum(["boot", "post_task"]).default("boot"),
1129
2559
  bedrock: AgentBedrockStatusSchema.nullable().default(null)
1130
- });
2560
+ }).openapi("AgentCredStatus");
1131
2561
  AgentWithTasksSchema = AgentSchema.extend({
1132
- tasks: array(AgentTaskSchema).default([])
2562
+ tasks: exports_zod.array(AgentTaskSchema).default([])
1133
2563
  });
1134
- ChangeSourceSchema = _enum([
2564
+ ChangeSourceSchema = exports_zod.enum([
1135
2565
  "self_edit",
1136
2566
  "lead_coaching",
1137
2567
  "api",
1138
2568
  "system",
1139
2569
  "session_sync"
1140
2570
  ]);
1141
- VersionableFieldSchema = _enum([
2571
+ VersionableFieldSchema = exports_zod.enum([
1142
2572
  "soulMd",
1143
2573
  "identityMd",
1144
2574
  "toolsMd",
@@ -1146,59 +2576,59 @@ var init_types = __esm(() => {
1146
2576
  "setupScript",
1147
2577
  "heartbeatMd"
1148
2578
  ]);
1149
- ContextVersionSchema = object({
1150
- id: uuid(),
1151
- agentId: string(),
2579
+ ContextVersionSchema = exports_zod.object({
2580
+ id: exports_zod.uuid(),
2581
+ agentId: exports_zod.string(),
1152
2582
  field: VersionableFieldSchema,
1153
- content: string(),
1154
- version: number().int().min(1),
2583
+ content: exports_zod.string(),
2584
+ version: exports_zod.number().int().min(1),
1155
2585
  changeSource: ChangeSourceSchema,
1156
- changedByAgentId: string().nullable(),
1157
- changeReason: string().nullable(),
1158
- contentHash: string(),
1159
- previousVersionId: uuid().nullable(),
1160
- createdAt: exports_iso.datetime()
1161
- });
1162
- ChannelTypeSchema = _enum(["public", "dm"]);
1163
- ChannelSchema = object({
1164
- id: uuid(),
1165
- name: string().min(1).max(100),
1166
- description: string().max(500).optional(),
2586
+ changedByAgentId: exports_zod.string().nullable(),
2587
+ changeReason: exports_zod.string().nullable(),
2588
+ contentHash: exports_zod.string(),
2589
+ previousVersionId: exports_zod.uuid().nullable(),
2590
+ createdAt: exports_zod.iso.datetime()
2591
+ }).openapi("ContextVersion");
2592
+ ChannelTypeSchema = exports_zod.enum(["public", "dm"]);
2593
+ ChannelSchema = exports_zod.object({
2594
+ id: exports_zod.uuid(),
2595
+ name: exports_zod.string().min(1).max(100),
2596
+ description: exports_zod.string().max(500).optional(),
1167
2597
  type: ChannelTypeSchema.default("public"),
1168
- createdBy: string().optional(),
1169
- participants: array(string()).default([]),
1170
- createdAt: exports_iso.datetime()
1171
- });
1172
- ChannelMessageSchema = object({
1173
- id: uuid(),
1174
- channelId: uuid(),
1175
- agentId: string().nullable(),
1176
- agentName: string().optional(),
1177
- content: string().min(1).max(4000),
1178
- replyToId: uuid().optional(),
1179
- mentions: array(string()).default([]),
1180
- createdAt: exports_iso.datetime()
1181
- });
1182
- ServiceStatusSchema = _enum(["starting", "healthy", "unhealthy", "stopped"]);
1183
- ServiceSchema = object({
1184
- id: uuid(),
1185
- agentId: string(),
1186
- name: string().min(1).max(50),
1187
- port: number().int().min(1).max(65535).default(3000),
1188
- description: string().optional(),
1189
- url: string().url().optional(),
1190
- healthCheckPath: string().default("/health"),
2598
+ createdBy: exports_zod.string().optional(),
2599
+ participants: exports_zod.array(exports_zod.string()).default([]),
2600
+ createdAt: exports_zod.iso.datetime()
2601
+ }).openapi("Channel");
2602
+ ChannelMessageSchema = exports_zod.object({
2603
+ id: exports_zod.uuid(),
2604
+ channelId: exports_zod.uuid(),
2605
+ agentId: exports_zod.string().nullable(),
2606
+ agentName: exports_zod.string().optional(),
2607
+ content: exports_zod.string().min(1).max(4000),
2608
+ replyToId: exports_zod.uuid().optional(),
2609
+ mentions: exports_zod.array(exports_zod.string()).default([]),
2610
+ createdAt: exports_zod.iso.datetime()
2611
+ }).openapi("ChannelMessage");
2612
+ ServiceStatusSchema = exports_zod.enum(["starting", "healthy", "unhealthy", "stopped"]);
2613
+ ServiceSchema = exports_zod.object({
2614
+ id: exports_zod.uuid(),
2615
+ agentId: exports_zod.string(),
2616
+ name: exports_zod.string().min(1).max(50),
2617
+ port: exports_zod.number().int().min(1).max(65535).default(3000),
2618
+ description: exports_zod.string().optional(),
2619
+ url: exports_zod.string().url().optional(),
2620
+ healthCheckPath: exports_zod.string().default("/health"),
1191
2621
  status: ServiceStatusSchema.default("starting"),
1192
- script: string().min(1),
1193
- cwd: string().optional(),
1194
- interpreter: string().optional(),
1195
- args: array(string()).optional(),
1196
- env: record(string(), string()).optional(),
1197
- metadata: record(string(), unknown()).default({}),
1198
- createdAt: exports_iso.datetime(),
1199
- lastUpdatedAt: exports_iso.datetime()
1200
- });
1201
- AgentLogEventTypeSchema = _enum([
2622
+ script: exports_zod.string().min(1),
2623
+ cwd: exports_zod.string().optional(),
2624
+ interpreter: exports_zod.string().optional(),
2625
+ args: exports_zod.array(exports_zod.string()).optional(),
2626
+ env: exports_zod.record(exports_zod.string(), exports_zod.string()).optional(),
2627
+ metadata: exports_zod.record(exports_zod.string(), exports_zod.unknown()).default({}),
2628
+ createdAt: exports_zod.iso.datetime(),
2629
+ lastUpdatedAt: exports_zod.iso.datetime()
2630
+ }).openapi("Service");
2631
+ AgentLogEventTypeSchema = exports_zod.enum([
1202
2632
  "agent_joined",
1203
2633
  "agent_status_change",
1204
2634
  "agent_left",
@@ -1224,67 +2654,67 @@ var init_types = __esm(() => {
1224
2654
  "pricing.refresh.failed",
1225
2655
  "task_superseded"
1226
2656
  ]);
1227
- ResumeReasonSchema = _enum([
2657
+ ResumeReasonSchema = exports_zod.enum([
1228
2658
  "graceful_shutdown",
1229
2659
  "context_limits",
1230
2660
  "manual_supersede",
1231
2661
  "crash_recovery"
1232
2662
  ]);
1233
- AgentLogSchema = object({
1234
- id: uuid(),
2663
+ AgentLogSchema = exports_zod.object({
2664
+ id: exports_zod.uuid(),
1235
2665
  eventType: AgentLogEventTypeSchema,
1236
- agentId: string().optional(),
1237
- taskId: string().optional(),
1238
- oldValue: string().optional(),
1239
- newValue: string().optional(),
1240
- metadata: string().optional(),
1241
- createdAt: exports_iso.datetime()
1242
- });
1243
- SessionLogSchema = object({
1244
- id: uuid(),
1245
- taskId: uuid().optional(),
1246
- sessionId: string(),
1247
- iteration: number().int().min(1),
1248
- cli: string().default("claude"),
1249
- content: string(),
1250
- lineNumber: number().int().min(0),
1251
- createdAt: exports_iso.datetime()
1252
- });
1253
- SessionCostSourceSchema = _enum(["harness", "pricing-table", "unpriced"]);
1254
- SessionCostModelBreakdownSchema = object({
1255
- model: string(),
1256
- inputTokens: number().int().nonnegative(),
1257
- outputTokens: number().int().nonnegative(),
1258
- cacheReadTokens: number().int().nonnegative(),
1259
- cacheWriteTokens: number().int().nonnegative(),
1260
- webSearchRequests: number().int().nonnegative().nullable().optional(),
1261
- costUsd: number().nullable().optional(),
1262
- harnessCostUsd: number().nullable().optional()
1263
- });
1264
- SessionCostSchema = object({
1265
- id: uuid(),
1266
- sessionId: string(),
1267
- taskId: uuid().optional(),
1268
- agentId: string(),
1269
- totalCostUsd: number().min(0),
1270
- inputTokens: number().int().min(0).default(0),
1271
- outputTokens: number().int().min(0).default(0),
1272
- cacheReadTokens: number().int().min(0).default(0),
1273
- cacheWriteTokens: number().int().min(0).default(0),
1274
- reasoningOutputTokens: number().int().min(0).default(0),
1275
- thinkingTokens: number().int().min(0).default(0),
1276
- durationMs: number().int().min(0),
1277
- numTurns: number().int().min(1).nullable(),
1278
- model: string(),
1279
- isError: boolean().default(false),
2666
+ agentId: exports_zod.string().optional(),
2667
+ taskId: exports_zod.string().optional(),
2668
+ oldValue: exports_zod.string().optional(),
2669
+ newValue: exports_zod.string().optional(),
2670
+ metadata: exports_zod.string().optional(),
2671
+ createdAt: exports_zod.iso.datetime()
2672
+ }).openapi("AgentLog");
2673
+ SessionLogSchema = exports_zod.object({
2674
+ id: exports_zod.uuid(),
2675
+ taskId: exports_zod.uuid().optional(),
2676
+ sessionId: exports_zod.string(),
2677
+ iteration: exports_zod.number().int().min(1),
2678
+ cli: exports_zod.string().default("claude"),
2679
+ content: exports_zod.string(),
2680
+ lineNumber: exports_zod.number().int().min(0),
2681
+ createdAt: exports_zod.iso.datetime()
2682
+ }).openapi("SessionLog");
2683
+ SessionCostSourceSchema = exports_zod.enum(["harness", "pricing-table", "unpriced"]);
2684
+ SessionCostModelBreakdownSchema = exports_zod.object({
2685
+ model: exports_zod.string(),
2686
+ inputTokens: exports_zod.number().int().nonnegative(),
2687
+ outputTokens: exports_zod.number().int().nonnegative(),
2688
+ cacheReadTokens: exports_zod.number().int().nonnegative(),
2689
+ cacheWriteTokens: exports_zod.number().int().nonnegative(),
2690
+ webSearchRequests: exports_zod.number().int().nonnegative().nullable().optional(),
2691
+ costUsd: exports_zod.number().nullable().optional(),
2692
+ harnessCostUsd: exports_zod.number().nullable().optional()
2693
+ }).openapi("SessionCostModelBreakdown");
2694
+ SessionCostSchema = exports_zod.object({
2695
+ id: exports_zod.uuid(),
2696
+ sessionId: exports_zod.string(),
2697
+ taskId: exports_zod.uuid().optional(),
2698
+ agentId: exports_zod.string(),
2699
+ totalCostUsd: exports_zod.number().min(0),
2700
+ inputTokens: exports_zod.number().int().min(0).default(0),
2701
+ outputTokens: exports_zod.number().int().min(0).default(0),
2702
+ cacheReadTokens: exports_zod.number().int().min(0).default(0),
2703
+ cacheWriteTokens: exports_zod.number().int().min(0).default(0),
2704
+ reasoningOutputTokens: exports_zod.number().int().min(0).default(0),
2705
+ thinkingTokens: exports_zod.number().int().min(0).default(0),
2706
+ durationMs: exports_zod.number().int().min(0),
2707
+ numTurns: exports_zod.number().int().min(1).nullable(),
2708
+ model: exports_zod.string(),
2709
+ isError: exports_zod.boolean().default(false),
1280
2710
  costSource: SessionCostSourceSchema.default("harness"),
1281
- harnessCostUsd: number().nullable().optional(),
1282
- cacheWrite5mTokens: number().int().nullable().optional(),
1283
- cacheWrite1hTokens: number().int().nullable().optional(),
1284
- modelBreakdown: array(SessionCostModelBreakdownSchema).nullable().optional(),
1285
- createdAt: exports_iso.datetime()
1286
- });
1287
- EventCategorySchema = _enum([
2711
+ harnessCostUsd: exports_zod.number().nullable().optional(),
2712
+ cacheWrite5mTokens: exports_zod.number().int().nullable().optional(),
2713
+ cacheWrite1hTokens: exports_zod.number().int().nullable().optional(),
2714
+ modelBreakdown: exports_zod.array(SessionCostModelBreakdownSchema).nullable().optional(),
2715
+ createdAt: exports_zod.iso.datetime()
2716
+ }).openapi("SessionCost");
2717
+ EventCategorySchema = exports_zod.enum([
1288
2718
  "tool",
1289
2719
  "skill",
1290
2720
  "session",
@@ -1293,9 +2723,9 @@ var init_types = __esm(() => {
1293
2723
  "workflow",
1294
2724
  "system"
1295
2725
  ]);
1296
- EventStatusSchema = _enum(["ok", "error", "timeout", "skipped"]);
1297
- EventSourceSchema = _enum(["worker", "api", "hook", "scheduler", "cli"]);
1298
- EventNameSchema = _enum([
2726
+ EventStatusSchema = exports_zod.enum(["ok", "error", "timeout", "skipped"]);
2727
+ EventSourceSchema = exports_zod.enum(["worker", "api", "hook", "scheduler", "cli"]);
2728
+ EventNameSchema = exports_zod.enum([
1299
2729
  "tool.start",
1300
2730
  "tool.end",
1301
2731
  "skill.invoke",
@@ -1319,54 +2749,54 @@ var init_types = __esm(() => {
1319
2749
  "script.global_upsert",
1320
2750
  "schedule.deleted"
1321
2751
  ]);
1322
- SwarmEventSchema = object({
1323
- id: uuid(),
2752
+ SwarmEventSchema = exports_zod.object({
2753
+ id: exports_zod.uuid(),
1324
2754
  category: EventCategorySchema,
1325
2755
  event: EventNameSchema,
1326
2756
  status: EventStatusSchema,
1327
2757
  source: EventSourceSchema,
1328
- agentId: string().optional(),
1329
- taskId: string().optional(),
1330
- sessionId: string().optional(),
1331
- parentEventId: string().optional(),
1332
- numericValue: number().optional(),
1333
- durationMs: number().int().optional(),
1334
- data: record(string(), unknown()).optional(),
1335
- createdAt: exports_iso.datetime()
1336
- });
1337
- ScheduledTaskTargetTypeSchema = _enum(["agent-task", "workflow", "script"]);
1338
- ScheduledTaskSchema = object({
1339
- id: uuid(),
2758
+ agentId: exports_zod.string().optional(),
2759
+ taskId: exports_zod.string().optional(),
2760
+ sessionId: exports_zod.string().optional(),
2761
+ parentEventId: exports_zod.string().optional(),
2762
+ numericValue: exports_zod.number().optional(),
2763
+ durationMs: exports_zod.number().int().optional(),
2764
+ data: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2765
+ createdAt: exports_zod.iso.datetime()
2766
+ }).openapi("SwarmEvent");
2767
+ ScheduledTaskTargetTypeSchema = exports_zod.enum(["agent-task", "workflow", "script"]);
2768
+ ScheduledTaskSchema = exports_zod.object({
2769
+ id: exports_zod.uuid(),
1340
2770
  key: AssetKeySchema,
1341
- name: string().min(1).max(100),
1342
- description: string().optional(),
1343
- cronExpression: string().optional(),
1344
- intervalMs: number().int().positive().optional(),
1345
- taskTemplate: string().optional(),
1346
- taskType: string().max(50).optional(),
1347
- tags: array(string()).default([]),
1348
- priority: number().int().min(0).max(100).default(50),
1349
- targetAgentId: string().optional(),
1350
- enabled: boolean().default(true),
1351
- lastRunAt: exports_iso.datetime().optional(),
1352
- nextRunAt: exports_iso.datetime().optional(),
1353
- createdByAgentId: string().optional(),
1354
- timezone: string().default("UTC"),
1355
- consecutiveErrors: number().int().min(0).default(0),
1356
- lastErrorAt: exports_iso.datetime().optional(),
1357
- lastErrorMessage: string().optional(),
1358
- model: string().optional(),
2771
+ name: exports_zod.string().min(1).max(100),
2772
+ description: exports_zod.string().optional(),
2773
+ cronExpression: exports_zod.string().optional(),
2774
+ intervalMs: exports_zod.number().int().positive().optional(),
2775
+ taskTemplate: exports_zod.string().optional(),
2776
+ taskType: exports_zod.string().max(50).optional(),
2777
+ tags: exports_zod.array(exports_zod.string()).default([]),
2778
+ priority: exports_zod.number().int().min(0).max(100).default(50),
2779
+ targetAgentId: exports_zod.string().optional(),
2780
+ enabled: exports_zod.boolean().default(true),
2781
+ lastRunAt: exports_zod.iso.datetime().optional(),
2782
+ nextRunAt: exports_zod.iso.datetime().optional(),
2783
+ createdByAgentId: exports_zod.string().optional(),
2784
+ timezone: exports_zod.string().default("UTC"),
2785
+ consecutiveErrors: exports_zod.number().int().min(0).default(0),
2786
+ lastErrorAt: exports_zod.iso.datetime().optional(),
2787
+ lastErrorMessage: exports_zod.string().optional(),
2788
+ model: exports_zod.string().optional(),
1359
2789
  modelTier: ModelTierSchema.optional(),
1360
- scheduleType: _enum(["recurring", "one_time"]).default("recurring"),
2790
+ scheduleType: exports_zod.enum(["recurring", "one_time"]).default("recurring"),
1361
2791
  targetType: ScheduledTaskTargetTypeSchema.default("agent-task"),
1362
- workflowId: uuid().optional(),
1363
- scriptName: string().optional(),
1364
- scriptArgs: record(string(), unknown()).optional(),
1365
- createdAt: exports_iso.datetime(),
1366
- lastUpdatedAt: exports_iso.datetime(),
1367
- createdBy: string().optional(),
1368
- updatedBy: string().optional(),
1369
- favorite: boolean().optional()
2792
+ workflowId: exports_zod.uuid().optional(),
2793
+ scriptName: exports_zod.string().optional(),
2794
+ scriptArgs: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2795
+ createdAt: exports_zod.iso.datetime(),
2796
+ lastUpdatedAt: exports_zod.iso.datetime(),
2797
+ createdBy: exports_zod.string().optional(),
2798
+ updatedBy: exports_zod.string().optional(),
2799
+ favorite: exports_zod.boolean().optional()
1370
2800
  }).refine((data) => {
1371
2801
  if (data.scheduleType === "one_time")
1372
2802
  return true;
@@ -1387,293 +2817,293 @@ var init_types = __esm(() => {
1387
2817
  }, {
1388
2818
  message: "Target-type specific field is required (taskTemplate, workflowId, or scriptName)"
1389
2819
  });
1390
- SwarmConfigScopeSchema = _enum(["global", "agent", "repo"]);
1391
- SwarmConfigSchema = object({
1392
- id: string().uuid(),
2820
+ SwarmConfigScopeSchema = exports_zod.enum(["global", "agent", "repo"]);
2821
+ SwarmConfigSchema = exports_zod.object({
2822
+ id: exports_zod.string().uuid(),
1393
2823
  scope: SwarmConfigScopeSchema,
1394
- scopeId: string().nullable(),
1395
- key: string().min(1).max(255),
1396
- value: string(),
1397
- isSecret: boolean(),
1398
- envPath: string().nullable(),
1399
- description: string().nullable(),
1400
- createdAt: string(),
1401
- lastUpdatedAt: string(),
1402
- encrypted: boolean()
1403
- });
1404
- RepoGuidelinesSchema = object({
1405
- prChecks: array(string()),
1406
- mergeChecks: array(string()),
1407
- allowMerge: boolean().optional().default(false),
1408
- review: array(string())
1409
- });
1410
- RepoHooksSchema = object({
1411
- enabled: boolean().default(false)
1412
- });
1413
- SwarmRepoSchema = object({
1414
- id: string().uuid(),
1415
- url: string().min(1),
1416
- name: string().min(1).max(100),
1417
- clonePath: string().min(1),
1418
- defaultBranch: string().default("main"),
1419
- autoClone: boolean().default(true),
2824
+ scopeId: exports_zod.string().nullable(),
2825
+ key: exports_zod.string().min(1).max(255),
2826
+ value: exports_zod.string(),
2827
+ isSecret: exports_zod.boolean(),
2828
+ envPath: exports_zod.string().nullable(),
2829
+ description: exports_zod.string().nullable(),
2830
+ createdAt: exports_zod.string(),
2831
+ lastUpdatedAt: exports_zod.string(),
2832
+ encrypted: exports_zod.boolean()
2833
+ }).openapi("SwarmConfig");
2834
+ RepoGuidelinesSchema = exports_zod.object({
2835
+ prChecks: exports_zod.array(exports_zod.string()),
2836
+ mergeChecks: exports_zod.array(exports_zod.string()),
2837
+ allowMerge: exports_zod.boolean().optional().default(false),
2838
+ review: exports_zod.array(exports_zod.string())
2839
+ }).openapi("RepoGuidelines");
2840
+ RepoHooksSchema = exports_zod.object({
2841
+ enabled: exports_zod.boolean().default(false)
2842
+ }).openapi("RepoHooks");
2843
+ SwarmRepoSchema = exports_zod.object({
2844
+ id: exports_zod.string().uuid(),
2845
+ url: exports_zod.string().min(1),
2846
+ name: exports_zod.string().min(1).max(100),
2847
+ clonePath: exports_zod.string().min(1),
2848
+ defaultBranch: exports_zod.string().default("main"),
2849
+ autoClone: exports_zod.boolean().default(true),
1420
2850
  hooks: RepoHooksSchema.optional().default({ enabled: false }),
1421
2851
  guidelines: RepoGuidelinesSchema.nullable().optional(),
1422
- createdAt: string(),
1423
- lastUpdatedAt: string()
1424
- });
1425
- AgentMemoryScopeSchema = _enum(["agent", "swarm"]);
1426
- AgentMemorySourceSchema = _enum([
2852
+ createdAt: exports_zod.string(),
2853
+ lastUpdatedAt: exports_zod.string()
2854
+ }).openapi("SwarmRepo");
2855
+ AgentMemoryScopeSchema = exports_zod.enum(["agent", "swarm"]);
2856
+ AgentMemorySourceSchema = exports_zod.enum([
1427
2857
  "manual",
1428
2858
  "file_index",
1429
2859
  "session_summary",
1430
2860
  "task_completion"
1431
2861
  ]);
1432
- AgentMemorySchema = object({
1433
- id: string().uuid(),
1434
- agentId: string().nullable(),
2862
+ AgentMemorySchema = exports_zod.object({
2863
+ id: exports_zod.string().uuid(),
2864
+ agentId: exports_zod.string().nullable(),
1435
2865
  scope: AgentMemoryScopeSchema,
1436
- key: string().nullable().optional(),
1437
- name: string().min(1).max(500),
1438
- content: string(),
1439
- summary: string().nullable(),
2866
+ key: exports_zod.string().nullable().optional(),
2867
+ name: exports_zod.string().min(1).max(500),
2868
+ content: exports_zod.string(),
2869
+ summary: exports_zod.string().nullable(),
1440
2870
  source: AgentMemorySourceSchema,
1441
- sourceTaskId: string().uuid().nullable(),
1442
- sourcePath: string().nullable(),
1443
- chunkIndex: number().int().min(0).default(0),
1444
- totalChunks: number().int().min(1).default(1),
1445
- tags: array(string()),
1446
- createdAt: string(),
1447
- updatedAt: string().nullable().optional(),
1448
- accessedAt: string(),
1449
- expiresAt: string().nullable().optional(),
1450
- accessCount: number().int().min(0).default(0).optional(),
1451
- embeddingModel: string().nullable().optional(),
1452
- contentHash: string().nullable().optional(),
1453
- version: number().int().min(1).default(1).optional()
1454
- });
1455
- ActiveSessionSchema = object({
1456
- id: uuid(),
1457
- agentId: string(),
1458
- taskId: string().nullable(),
1459
- triggerType: string(),
1460
- inboxMessageId: string().nullable(),
1461
- taskDescription: string().nullable(),
1462
- runnerSessionId: string().nullable(),
1463
- providerSessionId: string().nullable(),
1464
- startedAt: exports_iso.datetime(),
1465
- lastHeartbeatAt: exports_iso.datetime()
1466
- });
1467
- RetryPolicySchema = object({
1468
- maxRetries: number().int().min(0).default(3),
1469
- strategy: _enum(["exponential", "static", "linear"]).default("exponential"),
1470
- baseDelayMs: number().int().min(0).default(1000),
1471
- maxDelayMs: number().int().min(0).default(60000)
1472
- });
1473
- ExecutorMetaSchema = object({
1474
- runId: string().uuid(),
1475
- stepId: string().uuid(),
1476
- nodeId: string(),
1477
- workflowId: string().uuid(),
1478
- dryRun: boolean().default(false),
1479
- requestedByUserId: string().optional(),
1480
- inputCtx: record(string(), unknown()).optional()
1481
- });
1482
- ValidationResultSchema = object({
1483
- pass: boolean(),
1484
- reasoning: string(),
1485
- confidence: number().min(0).max(1)
1486
- });
1487
- StepValidationConfigSchema = object({
1488
- executor: string().default("validate"),
1489
- config: record(string(), unknown()),
1490
- mustPass: boolean().default(false),
2871
+ sourceTaskId: exports_zod.string().uuid().nullable(),
2872
+ sourcePath: exports_zod.string().nullable(),
2873
+ chunkIndex: exports_zod.number().int().min(0).default(0),
2874
+ totalChunks: exports_zod.number().int().min(1).default(1),
2875
+ tags: exports_zod.array(exports_zod.string()),
2876
+ createdAt: exports_zod.string(),
2877
+ updatedAt: exports_zod.string().nullable().optional(),
2878
+ accessedAt: exports_zod.string(),
2879
+ expiresAt: exports_zod.string().nullable().optional(),
2880
+ accessCount: exports_zod.number().int().min(0).default(0).optional(),
2881
+ embeddingModel: exports_zod.string().nullable().optional(),
2882
+ contentHash: exports_zod.string().nullable().optional(),
2883
+ version: exports_zod.number().int().min(1).default(1).optional()
2884
+ }).openapi("AgentMemory");
2885
+ ActiveSessionSchema = exports_zod.object({
2886
+ id: exports_zod.uuid(),
2887
+ agentId: exports_zod.string(),
2888
+ taskId: exports_zod.string().nullable(),
2889
+ triggerType: exports_zod.string(),
2890
+ inboxMessageId: exports_zod.string().nullable(),
2891
+ taskDescription: exports_zod.string().nullable(),
2892
+ runnerSessionId: exports_zod.string().nullable(),
2893
+ providerSessionId: exports_zod.string().nullable(),
2894
+ startedAt: exports_zod.iso.datetime(),
2895
+ lastHeartbeatAt: exports_zod.iso.datetime()
2896
+ }).openapi("ActiveSession");
2897
+ RetryPolicySchema = exports_zod.object({
2898
+ maxRetries: exports_zod.number().int().min(0).default(3),
2899
+ strategy: exports_zod.enum(["exponential", "static", "linear"]).default("exponential"),
2900
+ baseDelayMs: exports_zod.number().int().min(0).default(1000),
2901
+ maxDelayMs: exports_zod.number().int().min(0).default(60000)
2902
+ }).openapi("RetryPolicy");
2903
+ ExecutorMetaSchema = exports_zod.object({
2904
+ runId: exports_zod.string().uuid(),
2905
+ stepId: exports_zod.string().uuid(),
2906
+ nodeId: exports_zod.string(),
2907
+ workflowId: exports_zod.string().uuid(),
2908
+ dryRun: exports_zod.boolean().default(false),
2909
+ requestedByUserId: exports_zod.string().optional(),
2910
+ inputCtx: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional()
2911
+ }).openapi("ExecutorMeta");
2912
+ ValidationResultSchema = exports_zod.object({
2913
+ pass: exports_zod.boolean(),
2914
+ reasoning: exports_zod.string(),
2915
+ confidence: exports_zod.number().min(0).max(1)
2916
+ }).openapi("ValidationResult");
2917
+ StepValidationConfigSchema = exports_zod.object({
2918
+ executor: exports_zod.string().default("validate"),
2919
+ config: exports_zod.record(exports_zod.string(), exports_zod.unknown()),
2920
+ mustPass: exports_zod.boolean().default(false),
1491
2921
  retry: RetryPolicySchema.optional()
1492
- });
1493
- SwarmScriptNodeConfigSchema = object({
1494
- scriptName: string().min(1),
1495
- scope: _enum(["global", "agent"]).optional(),
1496
- pinHash: string().min(1).optional(),
1497
- args: record(string(), unknown()).optional(),
1498
- fsMode: _enum(["none", "workspace-rw"]).optional(),
1499
- timeoutMs: number().int().min(1000).max(300000).optional()
1500
- });
1501
- WorkflowNodeSchema = object({
1502
- id: string().describe("Unique node identifier, used in 'next' and 'inputs' mappings"),
1503
- type: string().describe("Executor type: 'agent-task', 'script', 'swarm-script', 'raw-llm', 'validate', 'property-match'"),
1504
- label: string().optional().describe("Human-readable label for UI display"),
1505
- config: record(string(), unknown()).describe("Executor-specific config. For agent-task: { template, outputSchema?, agentId?, tags?, priority?, dir?, vcsRepo?, model? }. " + "For swarm-script: { scriptName, scope?, pinHash?, args?, fsMode?, timeoutMs? (1000-300000) }. " + "Values support {{interpolation}} from the node's inputs context. " + "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})."),
1506
- next: union([string(), array(string()), record(string(), 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'})"),
2922
+ }).openapi("StepValidationConfig");
2923
+ SwarmScriptNodeConfigSchema = exports_zod.object({
2924
+ scriptName: exports_zod.string().min(1),
2925
+ scope: exports_zod.enum(["global", "agent"]).optional(),
2926
+ pinHash: exports_zod.string().min(1).optional(),
2927
+ args: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
2928
+ fsMode: exports_zod.enum(["none", "workspace-rw"]).optional(),
2929
+ timeoutMs: exports_zod.number().int().min(1000).max(300000).optional()
2930
+ }).openapi("SwarmScriptNodeConfig");
2931
+ WorkflowNodeSchema = exports_zod.object({
2932
+ id: exports_zod.string().describe("Unique node identifier, used in 'next' and 'inputs' mappings"),
2933
+ type: exports_zod.string().describe("Executor type: 'agent-task', 'script', 'swarm-script', 'raw-llm', 'validate', 'property-match'"),
2934
+ label: exports_zod.string().optional().describe("Human-readable label for UI display"),
2935
+ config: exports_zod.record(exports_zod.string(), exports_zod.unknown()).describe("Executor-specific config. For agent-task: { template, outputSchema?, agentId?, tags?, priority?, dir?, vcsRepo?, model? }. " + "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})."),
2936
+ 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'})"),
1507
2937
  validation: StepValidationConfigSchema.optional(),
1508
2938
  retry: RetryPolicySchema.optional(),
1509
- inputs: record(string(), 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 — only 'trigger' and 'input' are. " + 'Example: { "cityData": "generate-city" } → use {{cityData.taskOutput.field}} in config templates. ' + 'For trigger data: { "pr": "trigger.pullRequest" }.'),
1510
- inputSchema: record(string(), unknown()).optional().describe("JSON Schema to validate resolved inputs before execution"),
1511
- outputSchema: record(string(), 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.")
1512
- });
1513
- WorkflowEdgeSchema = object({
1514
- id: string(),
1515
- source: string(),
1516
- sourcePort: string(),
1517
- target: string()
1518
- });
1519
- WorkflowDefinitionSchema = object({
1520
- nodes: array(WorkflowNodeSchema).min(1),
1521
- onNodeFailure: _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.")
1522
- });
2939
+ 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."),
2940
+ inputSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional().describe("JSON Schema to validate resolved inputs before execution"),
2941
+ 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.")
2942
+ }).openapi("WorkflowNode");
2943
+ WorkflowEdgeSchema = exports_zod.object({
2944
+ id: exports_zod.string(),
2945
+ source: exports_zod.string(),
2946
+ sourcePort: exports_zod.string(),
2947
+ target: exports_zod.string()
2948
+ }).openapi("WorkflowEdge");
2949
+ WorkflowDefinitionSchema = exports_zod.object({
2950
+ nodes: exports_zod.array(WorkflowNodeSchema).min(1),
2951
+ 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.")
2952
+ }).openapi("WorkflowDefinition");
1523
2953
  WorkflowNodePatchSchema = WorkflowNodeSchema.partial().omit({ id: true });
1524
- WorkflowPatchSchema = object({
1525
- update: array(object({
1526
- nodeId: string().describe("ID of the node to update"),
2954
+ WorkflowPatchSchema = exports_zod.object({
2955
+ update: exports_zod.array(exports_zod.object({
2956
+ nodeId: exports_zod.string().describe("ID of the node to update"),
1527
2957
  node: WorkflowNodePatchSchema.describe("Partial node data to merge")
1528
2958
  })).optional().describe("Nodes to update (partial merge)"),
1529
- delete: array(string()).optional().describe("Node IDs to delete"),
1530
- create: array(WorkflowNodeSchema).optional().describe("New nodes to add"),
1531
- onNodeFailure: _enum(["fail", "continue"]).optional().describe("Update the definition-level onNodeFailure behavior"),
1532
- triggerSchema: record(string(), 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.")
1533
- });
1534
- WebhookVerificationSchema = discriminatedUnion("format", [
1535
- object({
1536
- format: literal("hmac-sha256"),
1537
- header: string().default("X-Hub-Signature-256").describe("Header containing HMAC-SHA256 over the raw request body. Accepts sha256=<hex> or bare hex.")
2959
+ delete: exports_zod.array(exports_zod.string()).optional().describe("Node IDs to delete"),
2960
+ create: exports_zod.array(WorkflowNodeSchema).optional().describe("New nodes to add"),
2961
+ onNodeFailure: exports_zod.enum(["fail", "continue"]).optional().describe("Update the definition-level onNodeFailure behavior"),
2962
+ 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.")
2963
+ }).openapi("WorkflowPatch");
2964
+ WebhookVerificationSchema = exports_zod.discriminatedUnion("format", [
2965
+ exports_zod.object({
2966
+ format: exports_zod.literal("hmac-sha256"),
2967
+ 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.")
1538
2968
  }),
1539
- object({
1540
- format: literal("timestamped-hmac-sha256"),
1541
- header: string().min(1).describe("Header containing comma-separated timestamp/signature pairs such as t=<timestamp>,v1=<hex>."),
1542
- timestampKey: string().default("t").describe("Timestamp field key in the signature header"),
1543
- signatureKey: string().default("v1").describe("Signature field key in the signature header; multiple entries are allowed"),
1544
- toleranceSeconds: number().int().positive().default(300).describe("Maximum allowed clock skew, in seconds, for replay protection")
2969
+ exports_zod.object({
2970
+ format: exports_zod.literal("timestamped-hmac-sha256"),
2971
+ header: exports_zod.string().min(1).describe("Header containing comma-separated timestamp/signature pairs such as t=<timestamp>,v1=<hex>."),
2972
+ timestampKey: exports_zod.string().default("t").describe("Timestamp field key in the signature header"),
2973
+ signatureKey: exports_zod.string().default("v1").describe("Signature field key in the signature header; multiple entries are allowed"),
2974
+ toleranceSeconds: exports_zod.number().int().positive().default(300).describe("Maximum allowed clock skew, in seconds, for replay protection")
1545
2975
  }),
1546
- object({
1547
- format: literal("token-equality"),
1548
- header: string().min(1).describe("Header containing the shared token to compare")
2976
+ exports_zod.object({
2977
+ format: exports_zod.literal("token-equality"),
2978
+ header: exports_zod.string().min(1).describe("Header containing the shared token to compare")
1549
2979
  })
1550
2980
  ]);
1551
- TriggerConfigSchema = discriminatedUnion("type", [
1552
- object({
1553
- type: literal("webhook"),
1554
- hmacSecret: string().optional(),
1555
- hmacHeader: string().default("X-Hub-Signature-256").describe("Legacy HMAC header for webhook verification. Prefer verification.header for new workflows."),
2981
+ TriggerConfigSchema = exports_zod.discriminatedUnion("type", [
2982
+ exports_zod.object({
2983
+ type: exports_zod.literal("webhook"),
2984
+ hmacSecret: exports_zod.string().optional(),
2985
+ hmacHeader: exports_zod.string().default("X-Hub-Signature-256").describe("Legacy HMAC header for webhook verification. Prefer verification.header for new workflows."),
1556
2986
  verification: WebhookVerificationSchema.optional().describe("Optional webhook verification format. Omit to keep legacy HMAC-SHA256 behavior with fallback header scanning.")
1557
2987
  }),
1558
- object({
1559
- type: literal("schedule"),
1560
- scheduleId: string().uuid()
2988
+ exports_zod.object({
2989
+ type: exports_zod.literal("schedule"),
2990
+ scheduleId: exports_zod.string().uuid()
1561
2991
  })
1562
2992
  ]).superRefine((trigger, ctx) => {
1563
2993
  if (trigger.type === "webhook" && trigger.verification && !trigger.hmacSecret) {
1564
2994
  ctx.addIssue({
1565
- code: ZodIssueCode.custom,
2995
+ code: exports_zod.ZodIssueCode.custom,
1566
2996
  message: "hmacSecret is required when verification is configured",
1567
2997
  path: ["hmacSecret"]
1568
2998
  });
1569
2999
  }
1570
3000
  });
1571
- CooldownConfigSchema = object({
1572
- hours: number().min(0).optional(),
1573
- minutes: number().min(0).optional(),
1574
- seconds: number().min(0).optional()
3001
+ CooldownConfigSchema = exports_zod.object({
3002
+ hours: exports_zod.number().min(0).optional(),
3003
+ minutes: exports_zod.number().min(0).optional(),
3004
+ seconds: exports_zod.number().min(0).optional()
1575
3005
  }).refine((v) => v.hours !== undefined || v.minutes !== undefined || v.seconds !== undefined, {
1576
3006
  message: "At least one of hours, minutes, or seconds is required"
1577
3007
  });
1578
- InputValueSchema = union([
1579
- string().regex(/^\$\{.+\}$/),
1580
- string().regex(/^secret\..+$/),
1581
- string()
3008
+ InputValueSchema = exports_zod.union([
3009
+ exports_zod.string().regex(/^\$\{.+\}$/),
3010
+ exports_zod.string().regex(/^secret\..+$/),
3011
+ exports_zod.string()
1582
3012
  ]);
1583
- WorkflowTemplateSchema = object({
1584
- id: string().uuid(),
1585
- name: string(),
1586
- description: string(),
1587
- category: string(),
1588
- variables: array(object({
1589
- name: string(),
1590
- description: string(),
1591
- type: _enum(["string", "number", "boolean"]),
1592
- default: unknown().optional(),
1593
- required: boolean().default(true)
3013
+ WorkflowTemplateSchema = exports_zod.object({
3014
+ id: exports_zod.string().uuid(),
3015
+ name: exports_zod.string(),
3016
+ description: exports_zod.string(),
3017
+ category: exports_zod.string(),
3018
+ variables: exports_zod.array(exports_zod.object({
3019
+ name: exports_zod.string(),
3020
+ description: exports_zod.string(),
3021
+ type: exports_zod.enum(["string", "number", "boolean"]),
3022
+ default: exports_zod.unknown().optional(),
3023
+ required: exports_zod.boolean().default(true)
1594
3024
  })),
1595
3025
  definition: WorkflowDefinitionSchema
1596
- });
1597
- WorkflowSnapshotSchema = object({
1598
- name: string(),
1599
- description: string().optional(),
3026
+ }).openapi("WorkflowTemplate");
3027
+ WorkflowSnapshotSchema = exports_zod.object({
3028
+ name: exports_zod.string(),
3029
+ description: exports_zod.string().optional(),
1600
3030
  definition: WorkflowDefinitionSchema,
1601
- triggers: array(TriggerConfigSchema),
3031
+ triggers: exports_zod.array(TriggerConfigSchema),
1602
3032
  cooldown: CooldownConfigSchema.optional(),
1603
- input: record(string(), InputValueSchema).optional(),
1604
- triggerSchema: record(string(), unknown()).optional(),
1605
- dir: string().min(1).startsWith("/").optional(),
1606
- vcsRepo: string().min(1).optional(),
1607
- enabled: boolean()
1608
- });
1609
- WorkflowSchema = object({
1610
- id: string().uuid(),
3033
+ input: exports_zod.record(exports_zod.string(), InputValueSchema).optional(),
3034
+ triggerSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
3035
+ dir: exports_zod.string().min(1).startsWith("/").optional(),
3036
+ vcsRepo: exports_zod.string().min(1).optional(),
3037
+ enabled: exports_zod.boolean()
3038
+ }).openapi("WorkflowSnapshot");
3039
+ WorkflowSchema = exports_zod.object({
3040
+ id: exports_zod.string().uuid(),
1611
3041
  key: AssetKeySchema,
1612
- name: string(),
1613
- description: string().optional(),
1614
- enabled: boolean(),
3042
+ name: exports_zod.string(),
3043
+ description: exports_zod.string().optional(),
3044
+ enabled: exports_zod.boolean(),
1615
3045
  definition: WorkflowDefinitionSchema,
1616
- triggers: array(TriggerConfigSchema).default([]),
3046
+ triggers: exports_zod.array(TriggerConfigSchema).default([]),
1617
3047
  cooldown: CooldownConfigSchema.optional(),
1618
- input: record(string(), InputValueSchema).optional(),
1619
- triggerSchema: record(string(), unknown()).optional(),
1620
- dir: string().min(1).startsWith("/").optional(),
1621
- vcsRepo: string().min(1).optional(),
1622
- createdByAgentId: string().optional(),
1623
- createdAt: string(),
1624
- lastUpdatedAt: string(),
1625
- createdBy: string().optional(),
1626
- updatedBy: string().optional(),
1627
- favorite: boolean().optional()
1628
- });
1629
- WorkflowVersionSchema = object({
1630
- id: string().uuid(),
1631
- workflowId: string().uuid(),
1632
- version: number().int().min(1),
3048
+ input: exports_zod.record(exports_zod.string(), InputValueSchema).optional(),
3049
+ triggerSchema: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
3050
+ dir: exports_zod.string().min(1).startsWith("/").optional(),
3051
+ vcsRepo: exports_zod.string().min(1).optional(),
3052
+ createdByAgentId: exports_zod.string().optional(),
3053
+ createdAt: exports_zod.string(),
3054
+ lastUpdatedAt: exports_zod.string(),
3055
+ createdBy: exports_zod.string().optional(),
3056
+ updatedBy: exports_zod.string().optional(),
3057
+ favorite: exports_zod.boolean().optional()
3058
+ }).openapi("Workflow");
3059
+ WorkflowVersionSchema = exports_zod.object({
3060
+ id: exports_zod.string().uuid(),
3061
+ workflowId: exports_zod.string().uuid(),
3062
+ version: exports_zod.number().int().min(1),
1633
3063
  snapshot: WorkflowSnapshotSchema,
1634
- changedByAgentId: string().optional(),
1635
- createdAt: string()
1636
- });
1637
- PageContentTypeSchema = _enum(["text/html", "application/json"]);
1638
- PageAuthModeSchema = _enum(["public", "authed", "password"]);
1639
- PageSnapshotSchema = object({
1640
- title: string(),
1641
- description: string().optional(),
3064
+ changedByAgentId: exports_zod.string().optional(),
3065
+ createdAt: exports_zod.string()
3066
+ }).openapi("WorkflowVersion");
3067
+ PageContentTypeSchema = exports_zod.enum(["text/html", "application/json"]);
3068
+ PageAuthModeSchema = exports_zod.enum(["public", "authed", "password"]);
3069
+ PageSnapshotSchema = exports_zod.object({
3070
+ title: exports_zod.string(),
3071
+ description: exports_zod.string().optional(),
1642
3072
  contentType: PageContentTypeSchema,
1643
3073
  authMode: PageAuthModeSchema,
1644
- passwordHash: string().optional(),
1645
- body: string(),
1646
- needsCredentials: array(string()).optional()
1647
- });
1648
- PageSchema = object({
1649
- id: string(),
3074
+ passwordHash: exports_zod.string().optional(),
3075
+ body: exports_zod.string(),
3076
+ needsCredentials: exports_zod.array(exports_zod.string()).optional()
3077
+ }).openapi("PageSnapshot");
3078
+ PageSchema = exports_zod.object({
3079
+ id: exports_zod.string(),
1650
3080
  key: AssetKeySchema,
1651
- agentId: string(),
1652
- slug: string(),
1653
- title: string(),
1654
- description: string().optional(),
3081
+ agentId: exports_zod.string(),
3082
+ slug: exports_zod.string(),
3083
+ title: exports_zod.string(),
3084
+ description: exports_zod.string().optional(),
1655
3085
  contentType: PageContentTypeSchema,
1656
3086
  authMode: PageAuthModeSchema,
1657
- passwordHash: string().optional(),
1658
- body: string(),
1659
- needsCredentials: array(string()).optional(),
1660
- viewCount: number().int().min(0).default(0),
1661
- createdAt: string(),
1662
- updatedAt: string(),
1663
- favorite: boolean().optional()
1664
- });
1665
- PageVersionSchema = object({
1666
- id: string(),
1667
- pageId: string(),
1668
- version: number().int().min(1),
3087
+ passwordHash: exports_zod.string().optional(),
3088
+ body: exports_zod.string(),
3089
+ needsCredentials: exports_zod.array(exports_zod.string()).optional(),
3090
+ viewCount: exports_zod.number().int().min(0).default(0),
3091
+ createdAt: exports_zod.string(),
3092
+ updatedAt: exports_zod.string(),
3093
+ favorite: exports_zod.boolean().optional()
3094
+ }).openapi("Page");
3095
+ PageVersionSchema = exports_zod.object({
3096
+ id: exports_zod.string(),
3097
+ pageId: exports_zod.string(),
3098
+ version: exports_zod.number().int().min(1),
1669
3099
  snapshot: PageSnapshotSchema,
1670
- changedByAgentId: string().optional(),
1671
- createdAt: string()
1672
- });
1673
- MetricParamSchema = union([string(), number(), boolean(), _null()]);
1674
- MetricVariableTypeSchema = _enum(["text", "number", "select"]);
1675
- MetricFormatSchema = _enum(["number", "integer", "currency", "percent", "duration"]);
1676
- MetricVisualizationSchema = _enum([
3100
+ changedByAgentId: exports_zod.string().optional(),
3101
+ createdAt: exports_zod.string()
3102
+ }).openapi("PageVersion");
3103
+ MetricParamSchema = exports_zod.union([exports_zod.string(), exports_zod.number(), exports_zod.boolean(), exports_zod.null()]);
3104
+ MetricVariableTypeSchema = exports_zod.enum(["text", "number", "select"]);
3105
+ MetricFormatSchema = exports_zod.enum(["number", "integer", "currency", "percent", "duration"]);
3106
+ MetricVisualizationSchema = exports_zod.enum([
1677
3107
  "stat",
1678
3108
  "table",
1679
3109
  "bar",
@@ -1681,82 +3111,82 @@ var init_types = __esm(() => {
1681
3111
  "multi-bar",
1682
3112
  "multi-line"
1683
3113
  ]);
1684
- MetricQuerySchema = object({
1685
- sql: string().min(1).max(1e4),
1686
- params: array(MetricParamSchema).optional(),
1687
- maxRows: number().int().min(1).max(500).optional()
3114
+ MetricQuerySchema = exports_zod.object({
3115
+ sql: exports_zod.string().min(1).max(1e4),
3116
+ params: exports_zod.array(MetricParamSchema).optional(),
3117
+ maxRows: exports_zod.number().int().min(1).max(500).optional()
1688
3118
  });
1689
- MetricVariableSchema = object({
1690
- key: string().min(1).regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
1691
- label: string().min(1).optional(),
3119
+ MetricVariableSchema = exports_zod.object({
3120
+ key: exports_zod.string().min(1).regex(/^[a-zA-Z][a-zA-Z0-9_]*$/),
3121
+ label: exports_zod.string().min(1).optional(),
1692
3122
  type: MetricVariableTypeSchema.default("text"),
1693
3123
  defaultValue: MetricParamSchema.optional(),
1694
- options: array(object({
1695
- label: string().min(1),
3124
+ options: exports_zod.array(exports_zod.object({
3125
+ label: exports_zod.string().min(1),
1696
3126
  value: MetricParamSchema
1697
3127
  })).optional(),
1698
- optionsQuery: object({
1699
- sql: string().min(1).max(1e4),
1700
- valueKey: string().min(1),
1701
- labelKey: string().min(1).optional()
3128
+ optionsQuery: exports_zod.object({
3129
+ sql: exports_zod.string().min(1).max(1e4),
3130
+ valueKey: exports_zod.string().min(1),
3131
+ labelKey: exports_zod.string().min(1).optional()
1702
3132
  }).optional()
1703
- });
1704
- MetricVizConfigSchema = object({
3133
+ }).openapi("MetricVariable");
3134
+ MetricVizConfigSchema = exports_zod.object({
1705
3135
  type: MetricVisualizationSchema,
1706
- x: string().optional(),
1707
- y: string().optional(),
1708
- series: array(string()).optional(),
1709
- label: string().optional(),
1710
- value: string().optional(),
1711
- columns: array(object({
1712
- key: string(),
1713
- label: string().optional(),
3136
+ x: exports_zod.string().optional(),
3137
+ y: exports_zod.string().optional(),
3138
+ series: exports_zod.array(exports_zod.string()).optional(),
3139
+ label: exports_zod.string().optional(),
3140
+ value: exports_zod.string().optional(),
3141
+ columns: exports_zod.array(exports_zod.object({
3142
+ key: exports_zod.string(),
3143
+ label: exports_zod.string().optional(),
1714
3144
  format: MetricFormatSchema.optional()
1715
3145
  })).optional(),
1716
3146
  format: MetricFormatSchema.optional()
1717
- });
1718
- MetricWidgetSchema = object({
1719
- id: string().min(1),
1720
- title: string().min(1),
1721
- description: string().optional(),
3147
+ }).openapi("MetricVizConfig");
3148
+ MetricWidgetSchema = exports_zod.object({
3149
+ id: exports_zod.string().min(1),
3150
+ title: exports_zod.string().min(1),
3151
+ description: exports_zod.string().optional(),
1722
3152
  query: MetricQuerySchema,
1723
3153
  viz: MetricVizConfigSchema,
1724
- colSpan: number().int().min(1).max(4).optional(),
1725
- rowSpan: number().int().min(1).max(4).optional()
1726
- });
1727
- MetricDefinitionSchema = object({
1728
- version: literal(1),
1729
- widgets: array(MetricWidgetSchema).min(1).max(24),
1730
- variables: array(MetricVariableSchema).max(12).optional(),
1731
- layout: object({
1732
- columns: number().int().min(1).max(4).optional()
3154
+ colSpan: exports_zod.number().int().min(1).max(4).optional(),
3155
+ rowSpan: exports_zod.number().int().min(1).max(4).optional()
3156
+ }).openapi("MetricWidget");
3157
+ MetricDefinitionSchema = exports_zod.object({
3158
+ version: exports_zod.literal(1),
3159
+ widgets: exports_zod.array(MetricWidgetSchema).min(1).max(24),
3160
+ variables: exports_zod.array(MetricVariableSchema).max(12).optional(),
3161
+ layout: exports_zod.object({
3162
+ columns: exports_zod.number().int().min(1).max(4).optional()
1733
3163
  }).optional(),
1734
- refreshSeconds: number().int().min(5).max(3600).optional()
1735
- });
1736
- MetricSnapshotSchema = object({
1737
- title: string(),
1738
- description: string().optional(),
3164
+ refreshSeconds: exports_zod.number().int().min(5).max(3600).optional()
3165
+ }).openapi("MetricDefinition");
3166
+ MetricSnapshotSchema = exports_zod.object({
3167
+ title: exports_zod.string(),
3168
+ description: exports_zod.string().optional(),
1739
3169
  definition: MetricDefinitionSchema
1740
- });
1741
- MetricSchema = object({
1742
- id: string(),
1743
- agentId: string(),
1744
- slug: string(),
1745
- title: string(),
1746
- description: string().optional(),
3170
+ }).openapi("MetricSnapshot");
3171
+ MetricSchema = exports_zod.object({
3172
+ id: exports_zod.string(),
3173
+ agentId: exports_zod.string(),
3174
+ slug: exports_zod.string(),
3175
+ title: exports_zod.string(),
3176
+ description: exports_zod.string().optional(),
1747
3177
  definition: MetricDefinitionSchema,
1748
- createdAt: string(),
1749
- updatedAt: string()
1750
- });
1751
- MetricVersionSchema = object({
1752
- id: string(),
1753
- metricId: string(),
1754
- version: number().int().min(1),
3178
+ createdAt: exports_zod.string(),
3179
+ updatedAt: exports_zod.string()
3180
+ }).openapi("Metric");
3181
+ MetricVersionSchema = exports_zod.object({
3182
+ id: exports_zod.string(),
3183
+ metricId: exports_zod.string(),
3184
+ version: exports_zod.number().int().min(1),
1755
3185
  snapshot: MetricSnapshotSchema,
1756
- changedByAgentId: string().optional(),
1757
- createdAt: string()
1758
- });
1759
- WorkflowRunStatusSchema = _enum([
3186
+ changedByAgentId: exports_zod.string().optional(),
3187
+ createdAt: exports_zod.string()
3188
+ }).openapi("MetricVersion");
3189
+ WorkflowRunStatusSchema = exports_zod.enum([
1760
3190
  "running",
1761
3191
  "waiting",
1762
3192
  "completed",
@@ -1764,18 +3194,18 @@ var init_types = __esm(() => {
1764
3194
  "skipped",
1765
3195
  "cancelled"
1766
3196
  ]);
1767
- WorkflowRunSchema = object({
1768
- id: string().uuid(),
1769
- workflowId: string().uuid(),
3197
+ WorkflowRunSchema = exports_zod.object({
3198
+ id: exports_zod.string().uuid(),
3199
+ workflowId: exports_zod.string().uuid(),
1770
3200
  status: WorkflowRunStatusSchema,
1771
- triggerData: unknown().optional(),
1772
- context: record(string(), unknown()).optional(),
1773
- error: string().optional(),
1774
- startedAt: string(),
1775
- lastUpdatedAt: string(),
1776
- finishedAt: string().optional()
1777
- });
1778
- ScriptRunStatusSchema = _enum([
3201
+ triggerData: exports_zod.unknown().optional(),
3202
+ context: exports_zod.record(exports_zod.string(), exports_zod.unknown()).optional(),
3203
+ error: exports_zod.string().optional(),
3204
+ startedAt: exports_zod.string(),
3205
+ lastUpdatedAt: exports_zod.string(),
3206
+ finishedAt: exports_zod.string().optional()
3207
+ }).openapi("WorkflowRun");
3208
+ ScriptRunStatusSchema = exports_zod.enum([
1779
3209
  "running",
1780
3210
  "paused",
1781
3211
  "completed",
@@ -1789,43 +3219,43 @@ var init_types = __esm(() => {
1789
3219
  "cancelled",
1790
3220
  "aborted_limit"
1791
3221
  ];
1792
- ScriptRunKindSchema = _enum(["workflow", "inline"]);
1793
- ScriptRunSchema = object({
1794
- id: string().uuid(),
1795
- agentId: string(),
1796
- scriptName: string().optional(),
1797
- source: string(),
1798
- args: unknown(),
3222
+ ScriptRunKindSchema = exports_zod.enum(["workflow", "inline"]);
3223
+ ScriptRunSchema = exports_zod.object({
3224
+ id: exports_zod.string().uuid(),
3225
+ agentId: exports_zod.string(),
3226
+ scriptName: exports_zod.string().optional(),
3227
+ source: exports_zod.string(),
3228
+ args: exports_zod.unknown(),
1799
3229
  kind: ScriptRunKindSchema,
1800
3230
  status: ScriptRunStatusSchema,
1801
- pid: number().int().optional(),
1802
- startedAt: string(),
1803
- finishedAt: string().optional(),
1804
- output: unknown().optional(),
1805
- error: string().optional(),
1806
- lastHeartbeatAt: string().optional(),
1807
- idempotencyKey: string().optional(),
1808
- requestedByUserId: string().optional()
1809
- });
3231
+ pid: exports_zod.number().int().optional(),
3232
+ startedAt: exports_zod.string(),
3233
+ finishedAt: exports_zod.string().optional(),
3234
+ output: exports_zod.unknown().optional(),
3235
+ error: exports_zod.string().optional(),
3236
+ lastHeartbeatAt: exports_zod.string().optional(),
3237
+ idempotencyKey: exports_zod.string().optional(),
3238
+ requestedByUserId: exports_zod.string().optional()
3239
+ }).openapi("ScriptRun");
1810
3240
  ScriptRunListItemSchema = ScriptRunSchema.omit({
1811
3241
  source: true,
1812
3242
  args: true,
1813
3243
  output: true
1814
3244
  });
1815
- ScriptRunJournalEntrySchema = object({
1816
- id: string().uuid(),
1817
- runId: string().uuid(),
1818
- stepKey: string(),
1819
- stepType: string(),
1820
- config: record(string(), unknown()),
1821
- status: _enum(["completed", "failed"]),
1822
- result: unknown().optional(),
1823
- error: string().optional(),
1824
- startedAt: string(),
1825
- completedAt: string().optional(),
1826
- durationMs: number().optional()
1827
- });
1828
- WorkflowRunStepStatusSchema = _enum([
3245
+ ScriptRunJournalEntrySchema = exports_zod.object({
3246
+ id: exports_zod.string().uuid(),
3247
+ runId: exports_zod.string().uuid(),
3248
+ stepKey: exports_zod.string(),
3249
+ stepType: exports_zod.string(),
3250
+ config: exports_zod.record(exports_zod.string(), exports_zod.unknown()),
3251
+ status: exports_zod.enum(["completed", "failed"]),
3252
+ result: exports_zod.unknown().optional(),
3253
+ error: exports_zod.string().optional(),
3254
+ startedAt: exports_zod.string(),
3255
+ completedAt: exports_zod.string().optional(),
3256
+ durationMs: exports_zod.number().optional()
3257
+ }).openapi("ScriptRunJournalEntry");
3258
+ WorkflowRunStepStatusSchema = exports_zod.enum([
1829
3259
  "pending",
1830
3260
  "running",
1831
3261
  "waiting",
@@ -1834,205 +3264,205 @@ var init_types = __esm(() => {
1834
3264
  "skipped",
1835
3265
  "cancelled"
1836
3266
  ]);
1837
- WorkflowRunStepSchema = object({
1838
- id: string().uuid(),
1839
- runId: string().uuid(),
1840
- nodeId: string(),
1841
- nodeType: string(),
3267
+ WorkflowRunStepSchema = exports_zod.object({
3268
+ id: exports_zod.string().uuid(),
3269
+ runId: exports_zod.string().uuid(),
3270
+ nodeId: exports_zod.string(),
3271
+ nodeType: exports_zod.string(),
1842
3272
  status: WorkflowRunStepStatusSchema,
1843
- input: unknown().optional(),
1844
- output: unknown().optional(),
1845
- error: string().optional(),
1846
- startedAt: string(),
1847
- finishedAt: string().optional(),
1848
- retryCount: number().int().min(0).default(0),
1849
- maxRetries: number().int().min(0).default(3),
1850
- nextRetryAt: string().optional(),
1851
- idempotencyKey: string().optional(),
1852
- diagnostics: string().optional(),
1853
- nextPort: string().optional()
1854
- });
1855
- WaitModeSchema = _enum(["time", "event"]);
1856
- WaitStateStatusSchema = _enum(["pending", "fired", "timeout"]);
1857
- WaitStateRowSchema = object({
1858
- id: string(),
1859
- workflowRunId: string(),
1860
- workflowRunStepId: string(),
3273
+ input: exports_zod.unknown().optional(),
3274
+ output: exports_zod.unknown().optional(),
3275
+ error: exports_zod.string().optional(),
3276
+ startedAt: exports_zod.string(),
3277
+ finishedAt: exports_zod.string().optional(),
3278
+ retryCount: exports_zod.number().int().min(0).default(0),
3279
+ maxRetries: exports_zod.number().int().min(0).default(3),
3280
+ nextRetryAt: exports_zod.string().optional(),
3281
+ idempotencyKey: exports_zod.string().optional(),
3282
+ diagnostics: exports_zod.string().optional(),
3283
+ nextPort: exports_zod.string().optional()
3284
+ }).openapi("WorkflowRunStep");
3285
+ WaitModeSchema = exports_zod.enum(["time", "event"]);
3286
+ WaitStateStatusSchema = exports_zod.enum(["pending", "fired", "timeout"]);
3287
+ WaitStateRowSchema = exports_zod.object({
3288
+ id: exports_zod.string(),
3289
+ workflowRunId: exports_zod.string(),
3290
+ workflowRunStepId: exports_zod.string(),
1861
3291
  mode: WaitModeSchema,
1862
- wakeUpAt: string().nullable(),
1863
- eventName: string().nullable(),
1864
- eventFilter: union([record(string(), unknown()), string()]).nullable(),
1865
- expiresAt: string().nullable(),
3292
+ wakeUpAt: exports_zod.string().nullable(),
3293
+ eventName: exports_zod.string().nullable(),
3294
+ eventFilter: exports_zod.union([exports_zod.record(exports_zod.string(), exports_zod.unknown()), exports_zod.string()]).nullable(),
3295
+ expiresAt: exports_zod.string().nullable(),
1866
3296
  status: WaitStateStatusSchema,
1867
- firedPayload: unknown().nullable(),
1868
- resolvedAt: string().nullable(),
1869
- createdAt: string(),
1870
- updatedAt: string(),
1871
- eventScope: _enum(["run", "global"])
1872
- });
1873
- PromptTemplateScopeSchema = _enum(["global", "agent", "repo"]);
1874
- PromptTemplateStateSchema = _enum([
3297
+ firedPayload: exports_zod.unknown().nullable(),
3298
+ resolvedAt: exports_zod.string().nullable(),
3299
+ createdAt: exports_zod.string(),
3300
+ updatedAt: exports_zod.string(),
3301
+ eventScope: exports_zod.enum(["run", "global"])
3302
+ }).openapi("WaitStateRow");
3303
+ PromptTemplateScopeSchema = exports_zod.enum(["global", "agent", "repo"]);
3304
+ PromptTemplateStateSchema = exports_zod.enum([
1875
3305
  "enabled",
1876
3306
  "default_prompt_fallback",
1877
3307
  "skip_event"
1878
3308
  ]);
1879
- PromptTemplateSchema = object({
1880
- id: string(),
1881
- eventType: string(),
3309
+ PromptTemplateSchema = exports_zod.object({
3310
+ id: exports_zod.string(),
3311
+ eventType: exports_zod.string(),
1882
3312
  scope: PromptTemplateScopeSchema,
1883
- scopeId: string().nullable(),
3313
+ scopeId: exports_zod.string().nullable(),
1884
3314
  state: PromptTemplateStateSchema,
1885
- body: string(),
1886
- isDefault: boolean(),
1887
- version: number(),
1888
- createdBy: string().nullable(),
1889
- createdAt: string(),
1890
- updatedAt: string()
1891
- });
1892
- PromptTemplateHistorySchema = object({
1893
- id: string(),
1894
- templateId: string(),
1895
- version: number(),
1896
- body: string(),
1897
- state: string(),
1898
- changedBy: string().nullable(),
1899
- changedAt: string(),
1900
- changeReason: string().nullable()
1901
- });
1902
- ScriptScopeSchema = _enum(["global", "agent"]);
1903
- ScriptFsModeSchema = _enum(["none", "workspace-rw"]);
1904
- ScriptRecordSchema = object({
1905
- id: string(),
1906
- name: string(),
3315
+ body: exports_zod.string(),
3316
+ isDefault: exports_zod.boolean(),
3317
+ version: exports_zod.number(),
3318
+ createdBy: exports_zod.string().nullable(),
3319
+ createdAt: exports_zod.string(),
3320
+ updatedAt: exports_zod.string()
3321
+ }).openapi("PromptTemplate");
3322
+ PromptTemplateHistorySchema = exports_zod.object({
3323
+ id: exports_zod.string(),
3324
+ templateId: exports_zod.string(),
3325
+ version: exports_zod.number(),
3326
+ body: exports_zod.string(),
3327
+ state: exports_zod.string(),
3328
+ changedBy: exports_zod.string().nullable(),
3329
+ changedAt: exports_zod.string(),
3330
+ changeReason: exports_zod.string().nullable()
3331
+ }).openapi("PromptTemplateHistory");
3332
+ ScriptScopeSchema = exports_zod.enum(["global", "agent"]);
3333
+ ScriptFsModeSchema = exports_zod.enum(["none", "workspace-rw"]);
3334
+ ScriptRecordSchema = exports_zod.object({
3335
+ id: exports_zod.string(),
3336
+ name: exports_zod.string(),
1907
3337
  scope: ScriptScopeSchema,
1908
- scopeId: string().nullable(),
1909
- source: string(),
1910
- description: string(),
1911
- intent: string(),
1912
- signatureJson: string(),
1913
- argsJsonSchema: string().nullable(),
1914
- contentHash: string(),
1915
- version: number(),
1916
- isScratch: boolean(),
1917
- typeChecked: boolean(),
3338
+ scopeId: exports_zod.string().nullable(),
3339
+ source: exports_zod.string(),
3340
+ description: exports_zod.string(),
3341
+ intent: exports_zod.string(),
3342
+ signatureJson: exports_zod.string(),
3343
+ argsJsonSchema: exports_zod.string().nullable(),
3344
+ contentHash: exports_zod.string(),
3345
+ version: exports_zod.number(),
3346
+ isScratch: exports_zod.boolean(),
3347
+ typeChecked: exports_zod.boolean(),
1918
3348
  fsMode: ScriptFsModeSchema,
1919
- createdByAgentId: string().nullable(),
1920
- createdAt: string(),
1921
- updatedAt: string()
1922
- });
1923
- ScriptVersionRecordSchema = object({
1924
- id: string(),
1925
- scriptId: string(),
1926
- version: number(),
1927
- source: string(),
1928
- description: string(),
1929
- intent: string(),
1930
- signatureJson: string(),
1931
- contentHash: string(),
1932
- changedByAgentId: string().nullable(),
1933
- changedAt: string(),
1934
- changeReason: string().nullable()
1935
- });
1936
- ScriptApiAuthModeSchema = _enum(["none", "bearer"]);
1937
- ScriptApiRecordSchema = object({
1938
- id: string(),
1939
- scriptId: string(),
1940
- agentId: string(),
3349
+ createdByAgentId: exports_zod.string().nullable(),
3350
+ createdAt: exports_zod.string(),
3351
+ updatedAt: exports_zod.string()
3352
+ }).openapi("ScriptRecord");
3353
+ ScriptVersionRecordSchema = exports_zod.object({
3354
+ id: exports_zod.string(),
3355
+ scriptId: exports_zod.string(),
3356
+ version: exports_zod.number(),
3357
+ source: exports_zod.string(),
3358
+ description: exports_zod.string(),
3359
+ intent: exports_zod.string(),
3360
+ signatureJson: exports_zod.string(),
3361
+ contentHash: exports_zod.string(),
3362
+ changedByAgentId: exports_zod.string().nullable(),
3363
+ changedAt: exports_zod.string(),
3364
+ changeReason: exports_zod.string().nullable()
3365
+ }).openapi("ScriptVersionRecord");
3366
+ ScriptApiAuthModeSchema = exports_zod.enum(["none", "bearer"]);
3367
+ ScriptApiRecordSchema = exports_zod.object({
3368
+ id: exports_zod.string(),
3369
+ scriptId: exports_zod.string(),
3370
+ agentId: exports_zod.string(),
1941
3371
  authMode: ScriptApiAuthModeSchema,
1942
- enabled: boolean(),
1943
- label: string().nullable(),
1944
- callCount: number(),
1945
- lastUsedAt: string().nullable(),
1946
- createdAt: string()
1947
- });
1948
- SkillTypeSchema = _enum(["remote", "personal"]);
1949
- SkillScopeSchema = _enum(["global", "swarm", "agent"]);
1950
- SkillSchema = object({
1951
- id: string(),
1952
- name: string(),
1953
- description: string(),
1954
- content: string(),
3372
+ enabled: exports_zod.boolean(),
3373
+ label: exports_zod.string().nullable(),
3374
+ callCount: exports_zod.number(),
3375
+ lastUsedAt: exports_zod.string().nullable(),
3376
+ createdAt: exports_zod.string()
3377
+ }).openapi("ScriptApiRecord");
3378
+ SkillTypeSchema = exports_zod.enum(["remote", "personal"]);
3379
+ SkillScopeSchema = exports_zod.enum(["global", "swarm", "agent"]);
3380
+ SkillSchema = exports_zod.object({
3381
+ id: exports_zod.string(),
3382
+ name: exports_zod.string(),
3383
+ description: exports_zod.string(),
3384
+ content: exports_zod.string(),
1955
3385
  type: SkillTypeSchema,
1956
3386
  scope: SkillScopeSchema,
1957
- ownerAgentId: string().nullable(),
1958
- sourceUrl: string().nullable(),
1959
- sourceRepo: string().nullable(),
1960
- sourcePath: string().nullable(),
1961
- sourceBranch: string(),
1962
- sourceHash: string().nullable(),
1963
- isComplex: boolean(),
1964
- allowedTools: string().nullable(),
1965
- model: string().nullable(),
1966
- effort: string().nullable(),
1967
- context: string().nullable(),
1968
- agent: string().nullable(),
1969
- disableModelInvocation: boolean(),
1970
- userInvocable: boolean(),
1971
- version: number(),
1972
- isEnabled: boolean(),
1973
- systemDefault: boolean(),
1974
- createdAt: string(),
1975
- lastUpdatedAt: string(),
1976
- lastFetchedAt: string().nullable()
1977
- });
1978
- AgentSkillSchema = object({
1979
- id: string(),
1980
- agentId: string(),
1981
- skillId: string(),
1982
- isActive: boolean(),
1983
- installedAt: string()
1984
- });
3387
+ ownerAgentId: exports_zod.string().nullable(),
3388
+ sourceUrl: exports_zod.string().nullable(),
3389
+ sourceRepo: exports_zod.string().nullable(),
3390
+ sourcePath: exports_zod.string().nullable(),
3391
+ sourceBranch: exports_zod.string(),
3392
+ sourceHash: exports_zod.string().nullable(),
3393
+ isComplex: exports_zod.boolean(),
3394
+ allowedTools: exports_zod.string().nullable(),
3395
+ model: exports_zod.string().nullable(),
3396
+ effort: exports_zod.string().nullable(),
3397
+ context: exports_zod.string().nullable(),
3398
+ agent: exports_zod.string().nullable(),
3399
+ disableModelInvocation: exports_zod.boolean(),
3400
+ userInvocable: exports_zod.boolean(),
3401
+ version: exports_zod.number(),
3402
+ isEnabled: exports_zod.boolean(),
3403
+ systemDefault: exports_zod.boolean(),
3404
+ createdAt: exports_zod.string(),
3405
+ lastUpdatedAt: exports_zod.string(),
3406
+ lastFetchedAt: exports_zod.string().nullable()
3407
+ }).openapi("Skill");
3408
+ AgentSkillSchema = exports_zod.object({
3409
+ id: exports_zod.string(),
3410
+ agentId: exports_zod.string(),
3411
+ skillId: exports_zod.string(),
3412
+ isActive: exports_zod.boolean(),
3413
+ installedAt: exports_zod.string()
3414
+ }).openapi("AgentSkill");
1985
3415
  SkillWithInstallInfoSchema = SkillSchema.extend({
1986
- isActive: boolean(),
1987
- installedAt: string()
3416
+ isActive: exports_zod.boolean(),
3417
+ installedAt: exports_zod.string()
1988
3418
  });
1989
- SkillFileSchema = object({
1990
- id: string(),
1991
- skillId: string(),
1992
- path: string(),
1993
- content: string(),
1994
- mimeType: string(),
1995
- isBinary: boolean(),
1996
- size: number().nullable(),
1997
- createdAt: string(),
1998
- lastUpdatedAt: string()
1999
- });
2000
- McpServerTransportSchema = _enum(["stdio", "http", "sse"]);
2001
- McpServerScopeSchema = _enum(["global", "swarm", "agent"]);
2002
- McpAuthMethodSchema = _enum(["static", "oauth", "auto"]);
2003
- McpServerSchema = object({
2004
- id: string(),
2005
- name: string(),
2006
- description: string().nullable(),
3419
+ SkillFileSchema = exports_zod.object({
3420
+ id: exports_zod.string(),
3421
+ skillId: exports_zod.string(),
3422
+ path: exports_zod.string(),
3423
+ content: exports_zod.string(),
3424
+ mimeType: exports_zod.string(),
3425
+ isBinary: exports_zod.boolean(),
3426
+ size: exports_zod.number().nullable(),
3427
+ createdAt: exports_zod.string(),
3428
+ lastUpdatedAt: exports_zod.string()
3429
+ }).openapi("SkillFile");
3430
+ McpServerTransportSchema = exports_zod.enum(["stdio", "http", "sse"]);
3431
+ McpServerScopeSchema = exports_zod.enum(["global", "swarm", "agent"]);
3432
+ McpAuthMethodSchema = exports_zod.enum(["static", "oauth", "auto"]);
3433
+ McpServerSchema = exports_zod.object({
3434
+ id: exports_zod.string(),
3435
+ name: exports_zod.string(),
3436
+ description: exports_zod.string().nullable(),
2007
3437
  scope: McpServerScopeSchema,
2008
- ownerAgentId: string().nullable(),
3438
+ ownerAgentId: exports_zod.string().nullable(),
2009
3439
  transport: McpServerTransportSchema,
2010
- command: string().nullable(),
2011
- args: string().nullable(),
2012
- url: string().nullable(),
2013
- headers: string().nullable(),
2014
- envConfigKeys: string().nullable(),
2015
- headerConfigKeys: string().nullable(),
2016
- extraAuthorizeParams: string().nullable(),
3440
+ command: exports_zod.string().nullable(),
3441
+ args: exports_zod.string().nullable(),
3442
+ url: exports_zod.string().nullable(),
3443
+ headers: exports_zod.string().nullable(),
3444
+ envConfigKeys: exports_zod.string().nullable(),
3445
+ headerConfigKeys: exports_zod.string().nullable(),
3446
+ extraAuthorizeParams: exports_zod.string().nullable(),
2017
3447
  authMethod: McpAuthMethodSchema.default("static"),
2018
- isEnabled: boolean(),
2019
- version: number(),
2020
- createdAt: string(),
2021
- lastUpdatedAt: string()
2022
- });
2023
- AgentMcpServerSchema = object({
2024
- id: string(),
2025
- agentId: string(),
2026
- mcpServerId: string(),
2027
- isActive: boolean(),
2028
- installedAt: string()
2029
- });
3448
+ isEnabled: exports_zod.boolean(),
3449
+ version: exports_zod.number(),
3450
+ createdAt: exports_zod.string(),
3451
+ lastUpdatedAt: exports_zod.string()
3452
+ }).openapi("McpServer");
3453
+ AgentMcpServerSchema = exports_zod.object({
3454
+ id: exports_zod.string(),
3455
+ agentId: exports_zod.string(),
3456
+ mcpServerId: exports_zod.string(),
3457
+ isActive: exports_zod.boolean(),
3458
+ installedAt: exports_zod.string()
3459
+ }).openapi("AgentMcpServer");
2030
3460
  McpServerWithInstallInfoSchema = McpServerSchema.extend({
2031
- isActive: boolean(),
2032
- installedAt: string()
3461
+ isActive: exports_zod.boolean(),
3462
+ installedAt: exports_zod.string()
2033
3463
  });
2034
- ContextSnapshotEventTypeSchema = _enum(["progress", "compaction", "completion"]);
2035
- ContextFormulaSchema = _enum([
3464
+ ContextSnapshotEventTypeSchema = exports_zod.enum(["progress", "compaction", "completion"]);
3465
+ ContextFormulaSchema = exports_zod.enum([
2036
3466
  "input-cache-output",
2037
3467
  "input-cache-no-output",
2038
3468
  "input-output-no-cache",
@@ -2041,31 +3471,31 @@ var init_types = __esm(() => {
2041
3471
  "harness-reported",
2042
3472
  "unknown"
2043
3473
  ]);
2044
- ContextSnapshotSchema = object({
2045
- id: uuid(),
2046
- taskId: uuid(),
2047
- agentId: string(),
2048
- sessionId: string(),
2049
- contextUsedTokens: number().int().min(0).optional(),
2050
- contextTotalTokens: number().int().min(0).optional(),
2051
- contextPercent: number().min(0).max(100).optional(),
3474
+ ContextSnapshotSchema = exports_zod.object({
3475
+ id: exports_zod.uuid(),
3476
+ taskId: exports_zod.uuid(),
3477
+ agentId: exports_zod.string(),
3478
+ sessionId: exports_zod.string(),
3479
+ contextUsedTokens: exports_zod.number().int().min(0).optional(),
3480
+ contextTotalTokens: exports_zod.number().int().min(0).optional(),
3481
+ contextPercent: exports_zod.number().min(0).max(100).optional(),
2052
3482
  eventType: ContextSnapshotEventTypeSchema,
2053
- compactTrigger: _enum(["auto", "manual", "auto-inferred"]).optional(),
2054
- preCompactTokens: number().int().min(0).optional(),
2055
- cumulativeInputTokens: number().int().min(0).default(0),
2056
- cumulativeOutputTokens: number().int().min(0).default(0),
3483
+ compactTrigger: exports_zod.enum(["auto", "manual", "auto-inferred"]).optional(),
3484
+ preCompactTokens: exports_zod.number().int().min(0).optional(),
3485
+ cumulativeInputTokens: exports_zod.number().int().min(0).default(0),
3486
+ cumulativeOutputTokens: exports_zod.number().int().min(0).default(0),
2057
3487
  contextFormula: ContextFormulaSchema.optional(),
2058
- createdAt: exports_iso.datetime()
2059
- });
2060
- BudgetScopeSchema = _enum(["global", "agent", "user"]);
2061
- BudgetSchema = object({
3488
+ createdAt: exports_zod.iso.datetime()
3489
+ }).openapi("ContextSnapshot");
3490
+ BudgetScopeSchema = exports_zod.enum(["global", "agent", "user"]);
3491
+ BudgetSchema = exports_zod.object({
2062
3492
  scope: BudgetScopeSchema,
2063
- scopeId: string(),
2064
- dailyBudgetUsd: number().nonnegative(),
2065
- createdAt: number(),
2066
- lastUpdatedAt: number()
2067
- });
2068
- PricingProviderSchema = _enum([
3493
+ scopeId: exports_zod.string(),
3494
+ dailyBudgetUsd: exports_zod.number().nonnegative(),
3495
+ createdAt: exports_zod.number(),
3496
+ lastUpdatedAt: exports_zod.number()
3497
+ }).openapi("Budget");
3498
+ PricingProviderSchema = exports_zod.enum([
2069
3499
  "claude",
2070
3500
  "claude-managed",
2071
3501
  "codex",
@@ -2074,7 +3504,7 @@ var init_types = __esm(() => {
2074
3504
  "devin",
2075
3505
  "gemini"
2076
3506
  ]);
2077
- PricingTokenClassSchema = _enum([
3507
+ PricingTokenClassSchema = exports_zod.enum([
2078
3508
  "input",
2079
3509
  "cached_input",
2080
3510
  "output",
@@ -2084,54 +3514,54 @@ var init_types = __esm(() => {
2084
3514
  "runtime_hour",
2085
3515
  "acu"
2086
3516
  ]);
2087
- PricingRowSchema = object({
3517
+ PricingRowSchema = exports_zod.object({
2088
3518
  provider: PricingProviderSchema,
2089
- model: string(),
3519
+ model: exports_zod.string(),
2090
3520
  tokenClass: PricingTokenClassSchema,
2091
- effectiveFrom: number().nonnegative(),
2092
- pricePerMillionUsd: number().nonnegative(),
2093
- createdAt: number(),
2094
- lastUpdatedAt: number()
2095
- });
2096
- BudgetRefusalCauseSchema = _enum(["agent", "global", "user"]);
2097
- BudgetRefusalNotificationSchema = object({
2098
- taskId: string(),
2099
- date: string(),
2100
- agentId: string(),
3521
+ effectiveFrom: exports_zod.number().nonnegative(),
3522
+ pricePerMillionUsd: exports_zod.number().nonnegative(),
3523
+ createdAt: exports_zod.number(),
3524
+ lastUpdatedAt: exports_zod.number()
3525
+ }).openapi("PricingRow");
3526
+ BudgetRefusalCauseSchema = exports_zod.enum(["agent", "global", "user"]);
3527
+ BudgetRefusalNotificationSchema = exports_zod.object({
3528
+ taskId: exports_zod.string(),
3529
+ date: exports_zod.string(),
3530
+ agentId: exports_zod.string(),
2101
3531
  cause: BudgetRefusalCauseSchema,
2102
- agentSpendUsd: number().nullable().optional(),
2103
- agentBudgetUsd: number().nullable().optional(),
2104
- globalSpendUsd: number().nullable().optional(),
2105
- globalBudgetUsd: number().nullable().optional(),
2106
- userSpendUsd: number().nullable().optional(),
2107
- userBudgetUsd: number().nullable().optional(),
2108
- followUpTaskId: string().nullable().optional(),
2109
- createdAt: number()
2110
- });
2111
- BudgetRefusedTriggerSchema = object({
2112
- type: literal("budget_refused"),
3532
+ agentSpendUsd: exports_zod.number().nullable().optional(),
3533
+ agentBudgetUsd: exports_zod.number().nullable().optional(),
3534
+ globalSpendUsd: exports_zod.number().nullable().optional(),
3535
+ globalBudgetUsd: exports_zod.number().nullable().optional(),
3536
+ userSpendUsd: exports_zod.number().nullable().optional(),
3537
+ userBudgetUsd: exports_zod.number().nullable().optional(),
3538
+ followUpTaskId: exports_zod.string().nullable().optional(),
3539
+ createdAt: exports_zod.number()
3540
+ }).openapi("BudgetRefusalNotification");
3541
+ BudgetRefusedTriggerSchema = exports_zod.object({
3542
+ type: exports_zod.literal("budget_refused"),
2113
3543
  cause: BudgetRefusalCauseSchema,
2114
- agentSpend: number().optional(),
2115
- agentBudget: number().optional(),
2116
- globalSpend: number().optional(),
2117
- globalBudget: number().optional(),
2118
- userSpend: number().optional(),
2119
- userBudget: number().optional(),
2120
- resetAt: string()
2121
- });
2122
- KvValueTypeSchema = _enum(["json", "string", "integer"]);
3544
+ agentSpend: exports_zod.number().optional(),
3545
+ agentBudget: exports_zod.number().optional(),
3546
+ globalSpend: exports_zod.number().optional(),
3547
+ globalBudget: exports_zod.number().optional(),
3548
+ userSpend: exports_zod.number().optional(),
3549
+ userBudget: exports_zod.number().optional(),
3550
+ resetAt: exports_zod.string()
3551
+ }).openapi("BudgetRefusedTrigger");
3552
+ KvValueTypeSchema = exports_zod.enum(["json", "string", "integer"]);
2123
3553
  KV_NAME_REGEX = /^[a-zA-Z0-9._:/%-]{1,512}$/;
2124
- KvNamespaceSchema = string().min(1).max(512).regex(KV_NAME_REGEX, "namespace must match [a-zA-Z0-9._:/%-]{1,512}");
2125
- KvKeySchema = string().min(1).max(512).regex(KV_NAME_REGEX, "key must match [a-zA-Z0-9._:/%-]{1,512}");
2126
- KvEntrySchema = object({
2127
- namespace: string(),
2128
- key: string(),
2129
- value: unknown(),
3554
+ KvNamespaceSchema = exports_zod.string().min(1).max(512).regex(KV_NAME_REGEX, "namespace must match [a-zA-Z0-9._:/%-]{1,512}");
3555
+ KvKeySchema = exports_zod.string().min(1).max(512).regex(KV_NAME_REGEX, "key must match [a-zA-Z0-9._:/%-]{1,512}");
3556
+ KvEntrySchema = exports_zod.object({
3557
+ namespace: exports_zod.string(),
3558
+ key: exports_zod.string(),
3559
+ value: exports_zod.unknown(),
2130
3560
  valueType: KvValueTypeSchema,
2131
- expiresAt: number().int().nullable(),
2132
- createdAt: number().int(),
2133
- updatedAt: number().int()
2134
- });
3561
+ expiresAt: exports_zod.number().int().nullable(),
3562
+ createdAt: exports_zod.number().int(),
3563
+ updatedAt: exports_zod.number().int()
3564
+ }).openapi("KvEntry");
2135
3565
  });
2136
3566
 
2137
3567
  // src/utils/request-auth-context.ts
@@ -2299,6 +3729,8 @@ var init_asset_key_audit = __esm(() => {
2299
3729
  { entityType: "workflow", sql: 'SELECT id, "key" as key FROM workflows' },
2300
3730
  { entityType: "schedule", sql: 'SELECT id, "key" as key FROM scheduled_tasks' },
2301
3731
  { entityType: "page", sql: 'SELECT id, "key" as key FROM pages' },
3732
+ { entityType: "app", sql: 'SELECT id, "key" as key FROM apps' },
3733
+ { entityType: "script", sql: 'SELECT id, "key" as key FROM scripts' },
2302
3734
  { entityType: "file", sql: 'SELECT id, "key" as key FROM asset_key_mappings' }
2303
3735
  ];
2304
3736
  });
@@ -4912,8 +6344,8 @@ function ensureSlackRenderV2Activation() {
4912
6344
  throw new Error("Failed to persist Slack render v2 activation");
4913
6345
  return persisted;
4914
6346
  }
4915
- function isPendingSlackMessage(record2) {
4916
- return record2.ts.startsWith(PENDING_SLACK_MESSAGE_TS_PREFIX);
6347
+ function isPendingSlackMessage(record) {
6348
+ return record.ts.startsWith(PENDING_SLACK_MESSAGE_TS_PREFIX);
4917
6349
  }
4918
6350
  function rowToSlackMessage(row) {
4919
6351
  return {
@@ -6169,6 +7601,18 @@ function assetSummaryQueries(types) {
6169
7601
  NULL AS providerDriveId, NULL AS providerKey
6170
7602
  FROM pages`);
6171
7603
  }
7604
+ if (types.has("app")) {
7605
+ queries.push(`SELECT 'app' AS entityType, id, "key", name AS label,
7606
+ updated_at AS updatedAt, NULL AS providerId, NULL AS providerOrgId,
7607
+ NULL AS providerDriveId, NULL AS providerKey
7608
+ FROM apps`);
7609
+ }
7610
+ if (types.has("script")) {
7611
+ queries.push(`SELECT 'script' AS entityType, id, "key", name AS label,
7612
+ updatedAt, NULL AS providerId, NULL AS providerOrgId,
7613
+ NULL AS providerDriveId, NULL AS providerKey
7614
+ FROM scripts`);
7615
+ }
6172
7616
  if (types.has("file")) {
6173
7617
  queries.push(`SELECT 'file' AS entityType, id, "key", provider_key AS label,
6174
7618
  updated_at AS updatedAt, provider_id AS providerId,
@@ -6180,7 +7624,7 @@ function assetSummaryQueries(types) {
6180
7624
  return queries;
6181
7625
  }
6182
7626
  function listAssetSummaries(filters) {
6183
- const requestedTypes = new Set(filters?.types?.length ? filters.types : ["task", "workflow", "schedule", "page", "file"]);
7627
+ const requestedTypes = new Set(filters?.types?.length ? filters.types : ["task", "workflow", "schedule", "page", "app", "script", "file"]);
6184
7628
  const queries = assetSummaryQueries(requestedTypes);
6185
7629
  if (queries.length === 0)
6186
7630
  return [];
@@ -6218,6 +7662,10 @@ function currentAssetKey(entityType, id) {
6218
7662
  return getDb().prepare('SELECT "key" AS key FROM scheduled_tasks WHERE id = ?').get(id)?.key ?? null;
6219
7663
  case "page":
6220
7664
  return getDb().prepare('SELECT "key" AS key FROM pages WHERE id = ?').get(id)?.key ?? null;
7665
+ case "app":
7666
+ return getDb().prepare('SELECT "key" AS key FROM apps WHERE id = ?').get(id)?.key ?? null;
7667
+ case "script":
7668
+ return getDb().prepare('SELECT "key" AS key FROM scripts WHERE id = ?').get(id)?.key ?? null;
6221
7669
  case "file":
6222
7670
  return getAssetKeyMapping(id)?.key ?? null;
6223
7671
  }
@@ -6289,6 +7737,17 @@ function moveAssetKey(input) {
6289
7737
  input.id
6290
7738
  ]);
6291
7739
  break;
7740
+ case "app":
7741
+ getDb().run('UPDATE apps SET "key" = ?, updated_at = ? WHERE id = ?', [key, now, input.id]);
7742
+ break;
7743
+ case "script":
7744
+ getDb().run('UPDATE scripts SET "key" = ?, updatedAt = ?, updated_by = ? WHERE id = ?', [
7745
+ key,
7746
+ now,
7747
+ input.changedBy ?? null,
7748
+ input.id
7749
+ ]);
7750
+ break;
6292
7751
  case "file":
6293
7752
  getDb().run('UPDATE asset_key_mappings SET "key" = ?, updated_at = ?, updated_by = ? WHERE id = ?', [key, now, input.changedBy ?? null, input.id]);
6294
7753
  break;
@@ -11473,4 +12932,4 @@ var init_db = __esm(() => {
11473
12932
  };
11474
12933
  });
11475
12934
 
11476
- export { normalizeAssetKey, parseAssetKey, canWriteAssetKey, init_key, slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, initTelemetry, telemetry, init_telemetry, AssetKeySchema, AssetEntityTypeSchema, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, SteerModeSchema, SteeringSourceSchema, SteerOutcomeSchema, OnUnsupportedSchema, FollowUpConfigSchema, AttachmentInputSchema, InboxItemTypeSchema, InboxItemStatusSchema, FavoriteItemTypeSchema, TaskTemplateKindSchema, AgentStatusSchema, AgentAvatarSchema, AgentLatestModelSchema, AgentCredStatusSchema, ChannelTypeSchema, ServiceStatusSchema, ResumeReasonSchema, SessionCostModelBreakdownSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, ScheduledTaskTargetTypeSchema, SwarmConfigScopeSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, WorkflowDefinitionSchema, WorkflowNodePatchSchema, WorkflowPatchSchema, TriggerConfigSchema, CooldownConfigSchema, InputValueSchema, PageContentTypeSchema, PageAuthModeSchema, MetricDefinitionSchema, MetricVersionSchema, WorkflowRunStatusSchema, ScriptRunStatusSchema, TERMINAL_SCRIPT_RUN_STATUSES, PromptTemplateScopeSchema, PromptTemplateStateSchema, ScriptScopeSchema, ScriptFsModeSchema, ScriptApiAuthModeSchema, ContextSnapshotEventTypeSchema, ContextFormulaSchema, BudgetScopeSchema, BudgetSchema, PricingProviderSchema, PricingTokenClassSchema, PricingRowSchema, BudgetRefusalCauseSchema, BudgetRefusalNotificationSchema, KvValueTypeSchema, KvNamespaceSchema, KvKeySchema, init_types, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, init_templates, init_templates2 as init_templates1, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, isPendingSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskTitle, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };
12935
+ export { normalizeAssetKey, defaultAssetKey, parseAssetKey, canWriteAssetKey, init_key, slackContextKey, agentmailContextKey, githubContextKey, gitlabContextKey, linearContextKey, buildJiraContextKey, scheduleContextKey, workflowContextKey, agentContextKey, pageContextKey, init_context_key, checkSlackRoutingCoherence, init_slack_routing, initTelemetry, telemetry, init_telemetry, $OpenAPIRegistry, $OpenApiGeneratorV31, init_dist, init_zod_openapi, AssetKeySchema, AssetEntityTypeSchema, AssetKeyMappingSchema, AssetSummarySchema, ModelTierSchema, ReasoningEffortSchema, splitLegacyModelAlias, resolveTaskModelSelection, AgentTaskStatusSchema, isTerminalTaskStatus, AgentTaskSourceSchema, ProviderNameSchema, SteerModeSchema, SteeringSourceSchema, SteeringMessageSchema, SteerOutcomeSchema, OnUnsupportedSchema, SteerResultSchema, FollowUpConfigSchema, AgentTaskSchema, AttachmentInputSchema, TaskAttachmentSchema, UserSchema, InboxItemTypeSchema, InboxItemStatusSchema, InboxItemStateSchema, FavoriteItemTypeSchema, UserFavoriteSchema, TaskTemplateKindSchema, TaskTemplateSchema, AgentStatusSchema, AgentAvatarSchema, AgentSchema, AgentLatestModelSchema, AgentCredStatusSchema, AgentWithTasksSchema, ChannelTypeSchema, ServiceStatusSchema, ServiceSchema, ResumeReasonSchema, AgentLogSchema, SessionLogSchema, SessionCostModelBreakdownSchema, SessionCostSchema, EventCategorySchema, EventStatusSchema, EventSourceSchema, EventNameSchema, SwarmEventSchema, ScheduledTaskTargetTypeSchema, ScheduledTaskSchema, SwarmConfigScopeSchema, SwarmConfigSchema, RepoGuidelinesSchema, RepoHooksSchema, SwarmRepoSchema, AgentMemoryScopeSchema, AgentMemorySourceSchema, AgentMemorySchema, ActiveSessionSchema, 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, 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, setRequestAuth, getRequestAuth, getCurrentRequestAuth, init_request_auth_context, auditAssetKeys, init_asset_key_audit, CredentialBindingSchema, placeholderForConfigKey, CredentialBroker, DEFAULT_CREDENTIAL_BINDINGS, init_credential_broker, encryptSecret, decryptSecret, getEncryptionKey, init_crypto, normalizeDate, normalizeDateRequired, init_date_utils, init_templates, init_templates2 as init_templates1, SteeringRequestError, isSteeringEnabled2 as isSteeringEnabled, getTaskSteeringFields, promotePendingSteeringForTask, markSteeringUndeliverable, requestSteering, init_steering, isReservedConfigKey, reservedKeyError, validateConfigValue, init_swarm_config_guard, onTaskStarted, init_task_lifecycle_events, generateDefaultClaudeMd, generateDefaultSoulMd, generateDefaultIdentityMd, generateDefaultToolsMd, init_defaults, isSqliteVecAvailable, initDb, getDb, closeDb, computeContentHash, createContextVersion, getLatestContextVersion, getContextVersion, getContextVersionHistory, agentQueries, updateAgentCredentialState, createAgent, getAgentById, getAllAgents, getLeadAgent, updateAgentStatus, updateAgentMaxTasks, updateAgentProvider, setAgentHarnessProvider, updateAgentCredStatus, listAgentsWithCredStatusByProvider, getAgentHarnessProviders, updateAgentActivity, MAX_EMPTY_POLLS, incrementEmptyPollCount, resetEmptyPollCount, shouldBlockPolling, deleteAgent, getActiveTaskCount, hasCapacity, getRemainingCapacity, updateAgentStatusFromCapacity, isPoolAffinityEnforcementEnabled, buildRoutingAffinityFromAgent, isAgentEligibleForTask, taskQueries, createTask, getPendingTaskForAgent, assignUnassignedTaskPending, startTask, getTaskById, getSlackRenderV2ActivatedAt, ensureSlackRenderV2Activation, isPendingSlackMessage, recordSlackMessage, reserveSlackMessage, bindSlackMessageTimestamp, updateSlackMessageRecord, markSlackTreeRendered, deleteSlackMessageRecord, getSlackTreeMessage, getSlackTreeMessageByThread, getSlackOutcomeMessage, getSlackTreeMessages, getSlackMessageByChannelTs, getSlackTasksInThread, markTaskSlackReplySent, setSlackMessageTracking, getChildTasks, hasNonTerminalResumeChild, hasNonTerminalRerouteDecisionChild, updateTaskClaudeSessionId, updateTaskTitle, updateTaskVcs, getTasksByAgentId, getAgentCurrentTask, getTasksByStatus, findTaskByVcs, findTaskByGitHub, getAllTasks, getTasksCount, getTaskStats, getCompletedSlackTasks, getRecentlyFinishedWorkerTasks, markTasksNotified, resetTasksNotified, getInProgressSlackTasks, getSlackTasksMissingTree, getInProgressTasksByContextKey, findExistingLinearTrackerContextWork, getLatestTaskByContextKey, getLatestScriptRunStepTaskByContextKey, getAgentWorkingOnThread, getLatestActiveTaskInThread, getLatestLeadTaskInThread, getMostRecentTaskInThread, findCompletedTaskInThread, findRecentCancelledTaskInThread, completeTask, failTask, overwriteTerminalTaskResultText, cancelTask, supersedeTask, backfillSupersedeTaskResumeTaskId, pauseTask, resumeTask, getPausedTasksForAgent, getOrphanedInProgressTasksForAgent, resetOrphanedInProgressTasksForAgent, getRecentlyCancelledTasksForAgent, deleteTask, updateTaskProgress, insertTaskAttachment, getAssetKeyMappingByProvider, upsertAssetKeyMapping, getAssetKeyMapping, listAssetSummaries, moveAssetKey, deleteTaskAttachment, replaceTaskAttachment, getTaskAttachments, createSteeringMessage, getSteeringMessagesForTask, getSteeringMessageById, getPendingSteeringForTask, getPendingSteeringForAgent, markSteeringDelivered, markSteeringHandled, markSteeringPromoted, cancelPendingSteeringForTask, hasPendingSteering, getAgentWithTasks, getAllAgentsWithTasks, logQueries, createLogEntry, getLogsByAgentId, getLogsByTaskId, getLogsByTaskIdChronological, getLogsByEventType, getAllLogs, findRecentSimilarTasks, createTaskExtended, claimTask, releaseTask, acceptTask, rejectTask, moveTaskToBacklog, moveTaskFromBacklog, releaseStaleReviewingTasks, getOfferedTasksForAgent, claimOfferedTask, getUnassignedTasksCount, getUnassignedTaskIds, getUnassignedTaskIdsForAgent, checkDependencies, getDependentTasks, cascadeFailDependents, updateAgentProfile, updateAgentName, createChannel, getMessageById, getChannelById, getChannelByName, getAllChannels, deleteChannel, postMessage, getChannelMessages, updateReadState, getLastReadAt, getUnreadMessages, getMentionsForAgent, getInboxSummary, claimMentions, releaseMentionProcessing, releaseStaleMentionProcessing, createService, getServiceById, getServiceByAgentAndName, getServicesByAgentId, getAllServices, updateServiceStatus, deleteService, upsertService, deleteServicesByAgentId, sessionLogQueries, createSessionLogs, getSessionLogsByTaskId, getSessionLogsBySession, createSessionCost, getSessionCostsByTaskId, getSessionCostsByAgentId, getAllSessionCosts, getSessionCostsFiltered, UNATTRIBUTED_USER_ID, getSessionCostSummary, getDashboardCostSummary, createInboxMessage, getInboxMessageById, getUnreadInboxMessages, claimInboxMessages, markInboxMessageRead, markInboxMessageResponded, markInboxMessageDelegated, releaseStaleProcessingInbox, getConcurrentContext, getScheduledTasks, getScheduledTaskById, getScheduledTaskByName, createScheduledTask, updateScheduledTask, deleteScheduledTask, getDueScheduledTasks, autoEncryptLegacyPlaintextSecrets, maskSecrets, getSwarmConfigs, getInjectableGlobalConfigs, getSwarmConfigById, getSwarmConfigLookupById, upsertSwarmConfig, deleteSwarmConfig, deleteSwarmConfigByKey, getResolvedConfig, getSwarmRepos, getSwarmRepoById, getSwarmRepoByName, getSwarmRepoByUrl, createSwarmRepo, updateSwarmRepo, deleteSwarmRepo, getAgentMailInboxMapping, getAgentMailInboxMappingsByAgent, getAllAgentMailInboxMappings, createAgentMailInboxMapping, deleteAgentMailInboxMapping, findTaskByAgentMailThread, insertActiveSession, deleteActiveSession, deleteActiveSessionById, getActiveSessions, heartbeatActiveSession, cleanupStaleSessions, cleanupAgentSessions, updateActiveSessionProviderSessionId, getActiveSessionForTask, reassociateSessionLogs, getStalledInProgressTasks, getStalePinnedResumes, failPendingResumeIfUnclaimed, getIdleWorkersWithCapacity, getUnassignedPoolTasks, getStaleUnassignedAffinityTasks, getRecentFailedTasks, getRecentCompletedCount, getRecentFailedCount, createWorkflow, getWorkflow, listWorkflows, updateWorkflow, deleteWorkflow, getWorkflowsByScheduleId, createWorkflowRun, getWorkflowRun, updateWorkflowRun, listWorkflowRuns, countWorkflowRuns, listWorkflowRunsPage, createWorkflowRunStep, getWorkflowRunStep, updateWorkflowRunStep, getWorkflowRunStepsByRunId, getStuckWorkflowRuns, getLastSuccessfulRun, getLastRunStart, getRetryableSteps, getCompletedStepNodeIds, getTaskByWorkflowRunStepId, detachTaskFromWorkflowRunStep, getStepByIdempotencyKey, getStepCountForNode, getLatestStepForNode, createWorkflowVersion, getWorkflowVersions, getWorkflowVersion, createAppVersion, getAppVersions, getAppVersion, createPage, getPage, getPageBySlug, getLatestPageBySlug, listPagesByAgent, listAllPages, countAllPages, countPagesByAgent, updatePage, deletePage, incrementPageViewCount, createPageVersion, getPageVersions, getPageVersion, createMetric, getMetric, getMetricBySlug, listMetricsByAgent, listAllMetrics, countAllMetrics, countMetricsByAgent, updateMetric, deleteMetric, createMetricVersion, getMetricVersions, getMetricVersion, getPromptTemplates, getPromptTemplateById, upsertPromptTemplate, deletePromptTemplate, resetPromptTemplateToDefault, getPromptTemplateHistory, resolvePromptTemplate, checkoutPromptTemplate, getAllChannelActivityCursors, getChannelActivityCursor, upsertChannelActivityCursor, createApprovalRequest, getApprovalRequestById, resolveApprovalRequest, updateApprovalRequestNotifications, listApprovalRequests, getStuckApprovalRuns, getApprovalRequestByStepId, getExpiredPendingApprovals, createWaitState, getWaitStateById, getWaitStateByStepId, getDueWaitStates, getPendingEventWaitNames, getPendingWaitsByEvent, resolveWaitState, getStuckWaitRuns, SKILL_FILE_LIMITS, normalizeSkillFilePath, createSkill, updateSkill, listSkillFileManifest, getSkillFiles, getSkillFile, upsertSkillFile, upsertSkillFiles, deleteSkillFile, deleteSkill, getSkillById, getSkillByName, listSkills, searchSkills, installSkill, getSystemDefaultSkills, installSystemDefaultSkillsForAgent, uninstallSkill, getAgentSkills, toggleAgentSkill, createMcpServer, updateMcpServer, deleteMcpServer, getMcpServerById, getMcpServerByName, listMcpServers, installMcpServer, uninstallMcpServer, getAgentMcpServers, createContextSnapshot, getContextSnapshotsByTaskId, getContextSnapshotsBySessionId, getContextSummaryByTaskId, getAvailableKeyIndices, recordKeyUsage, markKeyRateLimited, recordKeyRateLimitWindows, setApiKeyName, clearKeyRateLimit, getKeyStatuses, getKeyCostSummary, getUserById, getAllUsers, createUser, updateUser, deleteUser, listInboxState, upsertInboxState, listFavorites, listUserFavorites, getFavoriteItemIdSet, setFavorite, setUserFavorite, withFavoriteFlags, listTaskTemplates, getRootTaskChain, listRecentSessions, countSessions, getBudget, getBudgets, upsertBudget, deleteBudget, getAllPricingRows, getPricingRows, getActivePricingRow, insertPricingRow, deletePricingRow, getDailySpendForAgent, getDailySpendGlobal, getDailySpendForUser, recordBudgetRefusalNotification, getBudgetRefusalNotification, getRecentBudgetRefusalNotifications, hasBudgetRefusalNotificationToday, setBudgetRefusalFollowUpTaskId, getLiveAgentCounts, getInstanceActivity, getSwarmMetrics, hasFirstCompletedTask, getKv, sweepExpiredKv, sweepExpiredKvPrefix, upsertKv, deleteKv, KvTypeCollisionError, incrKv, listKv, countKv, createScriptRun, recordInlineScriptRun, getScriptRun, getScriptRunByIdempotencyKey, listScriptRuns, countScriptRuns, countActiveScriptRuns, updateScriptRun, getRunningScriptRuns, getScriptRunJournalStep, upsertScriptRunJournalStep, listScriptRunJournalSteps, countScriptRunJournalSteps, countScriptRunJournalAgentTaskSteps, exports_db, init_db };