eve 0.29.4 → 0.30.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 (199) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/src/channel/clear-session.d.ts +4 -0
  3. package/dist/src/channel/clear-session.js +1 -0
  4. package/dist/src/channel/compact-session.d.ts +4 -0
  5. package/dist/src/channel/compact-session.js +1 -0
  6. package/dist/src/channel/routes.d.ts +34 -6
  7. package/dist/src/channel/types.d.ts +61 -9
  8. package/dist/src/chunks/{use-eve-agent-8mofdZcO.js → use-eve-agent-BXMIf5fR.js} +85 -1
  9. package/dist/src/chunks/{use-eve-agent-bKJbH0k4.js → use-eve-agent-k-XHfrJT.js} +85 -1
  10. package/dist/src/cli/dev/tui/message-queue.d.ts +12 -16
  11. package/dist/src/cli/dev/tui/message-queue.js +1 -1
  12. package/dist/src/cli/dev/tui/prompt-commands.d.ts +13 -5
  13. package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
  14. package/dist/src/cli/dev/tui/runner.d.ts +7 -7
  15. package/dist/src/cli/dev/tui/runner.js +1 -1
  16. package/dist/src/cli/dev/tui/setup-panel.js +4 -1
  17. package/dist/src/cli/dev/tui/subagent-pump.d.ts +5 -5
  18. package/dist/src/cli/dev/tui/terminal-renderer.js +12 -12
  19. package/dist/src/client/agent-info-schema.d.ts +2 -2
  20. package/dist/src/client/agent-info-schema.js +1 -1
  21. package/dist/src/client/index.d.ts +1 -1
  22. package/dist/src/client/session.d.ts +15 -1
  23. package/dist/src/client/session.js +1 -1
  24. package/dist/src/client/types.d.ts +20 -0
  25. package/dist/src/compiled/.vendor-stamp.json +6 -6
  26. package/dist/src/compiled/@workflow/core/_devalue.d.ts +8 -0
  27. package/dist/src/compiled/@workflow/core/capabilities.d.ts +5 -0
  28. package/dist/src/compiled/@workflow/core/index.js +2 -2
  29. package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +11 -0
  30. package/dist/src/compiled/@workflow/core/runtime/compute-instance.d.ts +12 -0
  31. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +18 -0
  32. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +103 -31
  33. package/dist/src/compiled/@workflow/core/runtime/replay-recovery-reporter.d.ts +36 -0
  34. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +22 -2
  35. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +17 -13
  36. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +13 -8
  37. package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
  38. package/dist/src/compiled/@workflow/core/runtime.js +3 -3
  39. package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +17 -0
  40. package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +155 -0
  41. package/dist/src/compiled/@workflow/core/serialization/index.d.ts +2 -1
  42. package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +1 -1
  43. package/dist/src/compiled/@workflow/core/serialization.d.ts +13 -9
  44. package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +1 -1
  45. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +41 -0
  46. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  47. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  48. package/dist/src/compiled/@workflow/errors/index.d.ts +16 -8
  49. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  50. package/dist/src/compiled/@workflow/world/analytics.d.ts +2 -0
  51. package/dist/src/compiled/@workflow/world/events.d.ts +87 -0
  52. package/dist/src/compiled/@workflow/world/hooks.d.ts +39 -0
  53. package/dist/src/compiled/@workflow/world/index.d.ts +1 -1
  54. package/dist/src/compiled/@workflow/world/interfaces.d.ts +61 -0
  55. package/dist/src/compiled/@workflow/world/queue.d.ts +40 -0
  56. package/dist/src/compiled/@workflow/world-local/index.js +3 -3
  57. package/dist/src/compiled/@workflow/world-vercel/index.js +14 -14
  58. package/dist/src/compiled/_chunks/workflow/{attribute-changes-1LmTKuTT.js → attribute-changes-DROfGk6l.js} +3 -3
  59. package/dist/src/compiled/_chunks/workflow/{dist-WjtNsOyf.js → dist-D5bR13zs.js} +1 -1
  60. package/dist/src/compiled/_chunks/workflow/{dist-BeQ_csYA.js → dist-dNxTT6nO.js} +2 -2
  61. package/dist/src/compiled/_chunks/workflow/resume-hook-bc-OQVI0.js +1 -0
  62. package/dist/src/compiled/_chunks/workflow/run-DM3ouA3U.js +1 -0
  63. package/dist/src/compiled/_chunks/workflow/sleep-D5iWly6-.js +1 -0
  64. package/dist/src/compiled/_chunks/workflow/wait-until-DoW76jdb.js +15 -0
  65. package/dist/src/compiler/extension-compatibility.d.ts +8 -8
  66. package/dist/src/compiler/extension-compatibility.js +1 -1
  67. package/dist/src/compiler/manifest.d.ts +11 -22
  68. package/dist/src/compiler/manifest.js +1 -1
  69. package/dist/src/compiler/normalize-agent-config.d.ts +3 -1
  70. package/dist/src/compiler/normalize-agent-config.js +1 -1
  71. package/dist/src/compiler/normalize-manifest.js +1 -1
  72. package/dist/src/compiler/normalize-subagent.d.ts +1 -0
  73. package/dist/src/compiler/normalize-subagent.js +1 -1
  74. package/dist/src/compiler/remote-agent-node.d.ts +3 -0
  75. package/dist/src/context/dynamic-subagent-lifecycle.d.ts +22 -0
  76. package/dist/src/context/dynamic-subagent-lifecycle.js +1 -0
  77. package/dist/src/context/dynamic-tool-lifecycle.js +1 -1
  78. package/dist/src/context/keys.d.ts +21 -2
  79. package/dist/src/context/keys.js +1 -1
  80. package/dist/src/context/run-step.js +1 -1
  81. package/dist/src/execution/cancel-descendant-turns-step.js +1 -1
  82. package/dist/src/execution/create-session-step.d.ts +2 -0
  83. package/dist/src/execution/create-session-step.js +1 -1
  84. package/dist/src/execution/delegation-tool.d.ts +3 -0
  85. package/dist/src/execution/delegation-tool.js +1 -0
  86. package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
  87. package/dist/src/execution/dispatch-workflow-runtime-actions-step.js +1 -1
  88. package/dist/src/execution/effective-agent-config.d.ts +12 -0
  89. package/dist/src/execution/effective-agent-config.js +1 -0
  90. package/dist/src/execution/node-step.d.ts +4 -0
  91. package/dist/src/execution/node-step.js +1 -1
  92. package/dist/src/execution/remote-agent-dispatch.d.ts +3 -1
  93. package/dist/src/execution/remote-agent-dispatch.js +1 -1
  94. package/dist/src/execution/runtime-context.d.ts +2 -0
  95. package/dist/src/execution/runtime-context.js +1 -1
  96. package/dist/src/execution/session-callback-request.d.ts +5 -0
  97. package/dist/src/execution/session-callback-request.js +1 -0
  98. package/dist/src/execution/session-delivery-hook.d.ts +1 -0
  99. package/dist/src/execution/session-delivery-hook.js +1 -1
  100. package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
  101. package/dist/src/execution/subagent-event-proxy-step.js +1 -1
  102. package/dist/src/execution/workflow-entry.js +1 -1
  103. package/dist/src/execution/workflow-runtime.d.ts +2 -0
  104. package/dist/src/execution/workflow-runtime.js +1 -1
  105. package/dist/src/execution/workflow-steps.js +1 -1
  106. package/dist/src/harness/agent-handles.d.ts +238 -0
  107. package/dist/src/harness/agent-handles.js +2 -0
  108. package/dist/src/harness/compaction.d.ts +1 -1
  109. package/dist/src/harness/compaction.js +1 -1
  110. package/dist/src/harness/tool-loop.js +2 -2
  111. package/dist/src/harness/types.d.ts +16 -0
  112. package/dist/src/internal/application/package.js +1 -1
  113. package/dist/src/internal/authored-definition/core.js +1 -1
  114. package/dist/src/internal/authored-module-loader.js +1 -1
  115. package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
  116. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response-from-manifest.js +1 -1
  117. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.d.ts +1 -1
  118. package/dist/src/internal/nitro/routes/agent-info/build-agent-info-response.js +1 -1
  119. package/dist/src/internal/nitro/routes/channel-dispatch.js +1 -1
  120. package/dist/src/internal/vercel-agent-summary.d.ts +1 -1
  121. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.d.ts +10 -0
  122. package/dist/src/internal/workflow-bundle/dynamic-capability-transform-plugin.js +1 -0
  123. package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.d.ts +7 -0
  124. package/dist/src/internal/workflow-bundle/dynamic-remote-agent-transform.js +3 -0
  125. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.d.ts +2 -0
  126. package/dist/src/internal/workflow-bundle/dynamic-tool-ast-references.js +1 -1
  127. package/dist/src/internal/workflow-bundle/dynamic-tool-transform.js +2 -2
  128. package/dist/src/protocol/clear-session.d.ts +14 -0
  129. package/dist/src/protocol/clear-session.js +1 -0
  130. package/dist/src/protocol/compact-session.d.ts +14 -0
  131. package/dist/src/protocol/compact-session.js +1 -0
  132. package/dist/src/protocol/message.d.ts +19 -1
  133. package/dist/src/protocol/message.js +1 -1
  134. package/dist/src/protocol/routes.d.ts +10 -0
  135. package/dist/src/protocol/routes.js +1 -1
  136. package/dist/src/public/channels/auth.d.ts +11 -25
  137. package/dist/src/public/channels/auth.js +1 -1
  138. package/dist/src/public/channels/eve.js +1 -1
  139. package/dist/src/public/channels/index.d.ts +1 -1
  140. package/dist/src/public/definitions/agent.d.ts +35 -1
  141. package/dist/src/public/definitions/agent.js +1 -1
  142. package/dist/src/public/definitions/channel.d.ts +5 -2
  143. package/dist/src/public/definitions/channel.js +1 -1
  144. package/dist/src/public/definitions/hook.d.ts +1 -0
  145. package/dist/src/public/definitions/tool.d.ts +4 -1
  146. package/dist/src/public/index.d.ts +1 -2
  147. package/dist/src/public/index.js +1 -1
  148. package/dist/src/runtime/framework-channels/index.js +1 -1
  149. package/dist/src/runtime/framework-tools/connection-search-dynamic.d.ts +2 -18
  150. package/dist/src/runtime/framework-tools/connection-search-dynamic.js +2 -2
  151. package/dist/src/runtime/framework-tools/index.d.ts +7 -2
  152. package/dist/src/runtime/framework-tools/index.js +1 -1
  153. package/dist/src/runtime/resolve-agent-graph.js +1 -1
  154. package/dist/src/runtime/resolve-agent.js +1 -1
  155. package/dist/src/runtime/resolve-dynamic-subagent.d.ts +12 -0
  156. package/dist/src/runtime/resolve-dynamic-subagent.js +1 -0
  157. package/dist/src/runtime/resolve-dynamic-tool.d.ts +15 -0
  158. package/dist/src/runtime/resolve-dynamic-tool.js +1 -1
  159. package/dist/src/runtime/subagents/dynamic-agent-config.d.ts +22 -0
  160. package/dist/src/runtime/subagents/dynamic-agent-config.js +1 -0
  161. package/dist/src/runtime/subagents/dynamic-remote-agent-config.d.ts +13 -0
  162. package/dist/src/runtime/subagents/dynamic-remote-agent-config.js +1 -0
  163. package/dist/src/runtime/subagents/registry.d.ts +10 -2
  164. package/dist/src/runtime/subagents/registry.js +1 -1
  165. package/dist/src/runtime/types.d.ts +11 -2
  166. package/dist/src/setup/flows/registry.js +1 -1
  167. package/dist/src/setup/scaffold/channels-catalog.d.ts +2 -2
  168. package/dist/src/setup/scaffold/channels-catalog.js +1 -1
  169. package/dist/src/setup/scaffold/connections/catalog.d.ts +2 -2
  170. package/dist/src/setup/scaffold/create/project.js +1 -1
  171. package/dist/src/shared/agent-definition.d.ts +7 -0
  172. package/dist/src/shared/agent-turn-outcome.d.ts +47 -0
  173. package/dist/src/shared/agent-turn-outcome.js +1 -0
  174. package/dist/src/shared/dynamic-tool-definition.d.ts +1 -5
  175. package/dist/src/shared/dynamic-tool-definition.js +1 -1
  176. package/dist/src/svelte/index.js +1 -1
  177. package/dist/src/svelte/use-eve-agent.js +1 -1
  178. package/dist/src/vue/index.js +1 -1
  179. package/dist/src/vue/use-eve-agent.js +1 -1
  180. package/docs/channels/custom.mdx +41 -1
  181. package/docs/channels/eve.mdx +27 -2
  182. package/docs/concepts/default-harness.md +4 -0
  183. package/docs/concepts/sessions-runs-and-streaming.md +1 -1
  184. package/docs/guides/auth-and-route-protection.md +13 -13
  185. package/docs/guides/client/streaming.mdx +14 -0
  186. package/docs/guides/dev-tui.md +12 -9
  187. package/docs/guides/dynamic-capabilities.md +74 -6
  188. package/docs/guides/frontend/nextjs.mdx +1 -1
  189. package/docs/guides/frontend/nuxt.mdx +1 -1
  190. package/docs/guides/frontend/sveltekit.mdx +1 -1
  191. package/docs/guides/remote-agents.md +33 -0
  192. package/docs/reference/project-layout.md +1 -1
  193. package/docs/reference/typescript-api.md +48 -48
  194. package/docs/subagents.mdx +32 -2
  195. package/package.json +8 -8
  196. package/dist/src/compiled/_chunks/workflow/resume-hook-D1_5NCZ6.js +0 -1
  197. package/dist/src/compiled/_chunks/workflow/run-C240Ctf4.js +0 -1
  198. package/dist/src/compiled/_chunks/workflow/sleep-De802yfX.js +0 -1
  199. package/dist/src/compiled/_chunks/workflow/wait-until-z48sPUjU.js +0 -15
@@ -0,0 +1,15 @@
1
+ import{o as e,t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r,r as i,s as a,t as o}from"./private-BcwCGTV5.js";import"./dist-B-vbuNqP.js";import{D as s,E as c,O as l,a as u,c as d,g as f,h as p,i as m,l as h,m as g,p as _,s as v,t as y,u as b,x as ee}from"./dist-dNxTT6nO.js";import{_ as x,f as te,n as ne,o as re,y as ie}from"./dist-D5bR13zs.js";import{t as S}from"./env-config-CYoX3muK.js";import{types as C}from"node:util";import{AsyncLocalStorage as ae}from"node:async_hooks";function oe(e,t){if(typeof t!=`string`)return null;let[n,r,...i]=t.split(`//`);if(n!==e||!r||i.length===0)return null;let a=i.join(`//`),o=a.split(`/`).at(-1)??``,s=``;return s=r.startsWith(`./`)?r.split(`/`).at(-1)??``:(r.split(`@`).slice(0,-1).join(`@`)||r.split(`@`)[0])?.split(`/`).at(-1)??``,[`default`,`__default`].includes(o)&&s&&(o=s),{shortName:o,moduleSpecifier:r,functionName:a}}function se(e){return oe(`workflow`,e)}function ce(e){return oe(`step`,e)}function le(e){return me(ce(e),e)}function ue(e){return me(se(e),e)}function de(e){return se(e)?.shortName??pe(`workflow`,e)??e}function fe(e){return ce(e)?.shortName??pe(`step`,e)??e}function pe(e,t){if(!t.startsWith(`${e}--`))return null;let n=t.split(`--`).filter(Boolean),r=n.at(-1)?.split(`-`).filter(Boolean).at(-1)??``;if([`default`,`__default`].includes(r)){let t=n.at(-2)?.split(`-`).filter(Boolean).at(-1);t&&t!==e&&(r=t)}return r||null}function me(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}function w(e,t,n){return n===1?e:t}const he=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:!e.env.NO_COLOR&&!!e.stdout?.isTTY:!1})(),T=(e,t)=>n=>he?`\x1b[${e}m${n}\x1b[${t}m`:n,E={bold:T(1,22),dim:T(2,22),italic:T(3,23),red:T(31,39),blue:T(34,39),cyan:T(36,39),yellow:T(33,39),magenta:T(35,39)},ge={info:E.blue,help:E.cyan,warn:E.yellow,error:E.red};function _e(e){let t=Array.isArray(e)?e.join(`
2
+ `):e;return ge.info(`${E.bold(`hint:`)} ${t}`)}function ve(e){return ge.info(`${E.bold(`docs:`)} ${e}`)}function ye(e){return E.italic(`${E.dim("`")}${e}${E.dim("`")}`)}function D(e){return E.dim(e)}function be(e){return E.bold(e)}function xe(e){return E.red(e)}function Se(e){return E.magenta(e)}function Ce(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
3
+ `),a=r===t.length-1,o=a?`╰▶ `:`├▶ `,s=a?` `:`│ `,c=i.map((e,t)=>`${t===0?o:s}${e}`);n.push(...c)}),n.join(`
4
+ `)}var we=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),Te=t(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),Ee=t(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=we(),a=Te();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),De=t(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),Oe=t(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),O=t(((e,t)=>{let n=Te(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=we(),{safeRe:a,t:o}=Ee(),s=De(),{compareIdentifiers:c}=Oe();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),ke=t(((e,t)=>{let n=O();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),Ae=t(((e,t)=>{let n=ke();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),je=t(((e,t)=>{let n=ke();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),Me=t(((e,t)=>{let n=O();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),Ne=t(((e,t)=>{let n=ke();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),Pe=t(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).major})),Fe=t(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).minor})),Ie=t(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).patch})),Le=t(((e,t)=>{let n=ke();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),k=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Re=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(t,e,r)})),ze=t(((e,t)=>{let n=k();t.exports=(e,t)=>n(e,t,!0)})),Be=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Ve=t(((e,t)=>{let n=Be();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),He=t(((e,t)=>{let n=Be();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Ue=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)>0})),We=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)<0})),Ge=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)===0})),Ke=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)!==0})),qe=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)>=0})),Je=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)<=0})),Ye=t(((e,t)=>{let n=Ge(),r=Ke(),i=Ue(),a=qe(),o=We(),s=Je();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),Xe=t(((e,t)=>{let n=O(),r=ke(),{safeRe:i,t:a}=Ee();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2],c=o[3]||`0`,l=o[4]||`0`,u=t.includePrerelease&&o[5]?`-${o[5]}`:``,d=t.includePrerelease&&o[6]?`+${o[6]}`:``;return r(`${s}.${c}.${l}${u}${d}`,t)}})),Ze=t(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),A=t(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,C(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>S(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(ae(this.set[t],e,this.options))return!0;return!1}};let r=new(Ze()),i=De(),a=Qe(),o=Te(),s=O(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=Ee(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=we(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=x(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=ne(e,t),o(`xrange`,e),e=ie(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>ee(e,t)).join(` `),ee=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},x=(e,t)=>e.trim().split(/\s+/).map(e=>te(e,t)).join(` `),te=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},ne=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>re(e,t)).join(` `)),re=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},ie=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),S=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),C=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),ae=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),Qe=t(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``||new l(t.value,n).test(this.value):t.operator===``?t.value===``||new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=De(),{safeRe:i,t:a}=Ee(),o=Ye(),s=Te(),c=O(),l=A()})),$e=t(((e,t)=>{let n=A();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),et=t(((e,t)=>{let n=A();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),tt=t(((e,t)=>{let n=O(),r=A();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),nt=t(((e,t)=>{let n=O(),r=A();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),rt=t(((e,t)=>{let n=O(),r=A(),i=Ue();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),it=t(((e,t)=>{let n=A();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),at=t(((e,t)=>{let n=O(),r=Qe(),{ANY:i}=r,a=A(),o=$e(),s=Ue(),c=We(),l=Je(),u=qe();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),ot=t(((e,t)=>{let n=at();t.exports=(e,t,r)=>n(e,t,`>`,r)})),st=t(((e,t)=>{let n=at();t.exports=(e,t,r)=>n(e,t,`<`,r)})),ct=t(((e,t)=>{let n=A();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),lt=t(((e,t)=>{let n=$e(),r=k();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),ut=t(((e,t)=>{let n=A(),r=Qe(),{ANY:i}=r,a=$e(),o=k(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),dt=t(((e,t)=>{let n=Ee(),r=we(),i=O(),a=Oe();t.exports={parse:ke(),valid:Ae(),clean:je(),inc:Me(),diff:Ne(),major:Pe(),minor:Fe(),patch:Ie(),prerelease:Le(),compare:k(),rcompare:Re(),compareLoose:ze(),compareBuild:Be(),sort:Ve(),rsort:He(),gt:Ue(),lt:We(),eq:Ge(),neq:Ke(),gte:qe(),lte:Je(),cmp:Ye(),coerce:Xe(),Comparator:Qe(),Range:A(),satisfies:$e(),toComparators:et(),maxSatisfying:tt(),minSatisfying:nt(),minVersion:rt(),validRange:it(),outside:at(),gtr:ot(),ltr:st(),intersects:ct(),simplifyRange:lt(),subset:ut(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));const ft=2**32-1,pt=ft-1;var j=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};const mt=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function ht(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===mt}function gt(e){return Object.prototype.toString.call(e).slice(8,-1)}function _t(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
5
+ `:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;case`\b`:return`\\b`;case`\f`:return`\\f`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:return e<` `?`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}function vt(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=_t(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function yt(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const bt=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function xt(e){return bt.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function St(e){return!(!Number.isInteger(e)||e<0||e>pt)}function Ct(e){return!(!Number.isInteger(e)||e<0||e>ft)}function wt(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return St(+e)}function Tt(e){for(var t=e.length-1;t>=0&&!wt(e[t]);t--);return t+1}function Et(e){let t=Object.keys(e);return t.length=Tt(t),t}function Dt(e){return new Uint8Array(e).toBase64()}function Ot(e){return Uint8Array.fromBase64(e).buffer}function kt(e){return Buffer.from(e).toString(`base64`)}function At(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function jt(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function Mt(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}const Nt=typeof Uint8Array.fromBase64==`function`,Pt=typeof process==`object`&&process.versions?.node!==void 0,Ft=Nt?Dt:Pt?kt:jt,It=Nt?Ot:Pt?At:Mt;function Lt(e,t){if(!t)return e;let n={};for(let r of Object.keys(e))n[r]=t[r]??e[r];return n}const Rt=Object.freeze({kind:`not-plain`}),zt=Object.freeze({kind:`symbol-keys`}),Bt=Object.freeze({identify:e=>e,typeOf:e=>e===null?`null`:typeof e,toPrimitive:e=>e,tagOf:e=>gt(e),isThenable:e=>typeof e.then==`function`,toPromise:e=>Promise.resolve(e),unbox:e=>e.valueOf(),toISOString:e=>isNaN(e.getDate())?``:e.toISOString(),toStringValue:e=>e.toString(),regExpInfo:e=>({source:e.source,flags:e.flags}),valuesOf:e=>e,entriesOf:e=>e,viewInfo:e=>({buffer:e.buffer,byteOffset:e.byteOffset,byteLength:e.byteLength,length:e.length,bufferByteLength:e.buffer.byteLength}),toArrayBuffer:e=>e,lengthOf:e=>e.length,hasOwn:(e,t)=>Object.hasOwn(e,t),indicesOf:e=>Et(e),shapeOf:e=>ht(e)?yt(e).length>0?zt:{kind:Object.getPrototypeOf(e)===null?`null-proto`:`plain`,keys:Object.keys(e)}:Rt,get:(e,t)=>e[t]}),Vt=Object.freeze({fromPrimitive:e=>e,fromISOString:e=>new Date(e),fromStringValue:(e,t)=>e===`URL`?new URL(t):e===`URLSearchParams`?new URLSearchParams(t):Temporal[e.slice(9)].from(t),fromArrayBuffer:e=>e,fromRegExpInfo:(e,t)=>new RegExp(e,t),fromViewInfo:(e,t,n,r)=>{let i=globalThis[e];return n===void 0?new i(t):new i(t,n,r)},box:e=>Object(e),createArray:e=>Array(e),createSparseArray:e=>{let t=[];return t[pt]=void 0,delete t[pt],t.length=e,t},createObject:()=>({}),createNullPrototypeObject:()=>Object.create(null),createSet:()=>new Set,createMap:()=>new Map,set:(e,t,n)=>{e[t]=n},addValue:(e,t)=>{e.add(t)},addEntry:(e,t,n)=>{e.set(t,n)}});function Ht(e,t,n){return Ut(JSON.parse(e),t,n)}function Ut(e,t,n){let r=Lt(Vt,n?.operations);if(typeof e==`number`)return s(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let i=e,a=Array(i.length),o=null;function s(e,n=!1){if(e===-1)return r.fromPrimitive(void 0);if(e===-3)return r.fromPrimitive(NaN);if(e===-4)return r.fromPrimitive(1/0);if(e===-5)return r.fromPrimitive(-1/0);if(e===-6)return r.fromPrimitive(-0);if(n||typeof e!=`number`)throw Error(`Invalid input`);if(e in a)return a[e];let c=i[e];if(!c||typeof c!=`object`)a[e]=r.fromPrimitive(c);else if(Array.isArray(c))if(typeof c[0]==`string`){let n=c[0],l=t&&Object.hasOwn(t,n)?t[n]:void 0;if(l){let t=c[1];if(typeof t!=`number`&&(t=i.push(c[1])-1),Object.hasOwn(a,t))return a[e]=l(a[t]);if(o??=new Set,o.has(t))throw Error(`Invalid circular reference`);return o.add(t),a[e]=l(s(t)),o.delete(t),a[e]}switch(n){case`Date`:a[e]=r.fromISOString(c[1]);break;case`Set`:let t=r.createSet();a[e]=t;for(let e=1;e<c.length;e+=1)r.addValue(t,s(c[e]));break;case`Map`:let o=r.createMap();a[e]=o;for(let e=1;e<c.length;e+=2)r.addEntry(o,s(c[e]),s(c[e+1]));break;case`RegExp`:a[e]=r.fromRegExpInfo(c[1],c[2]);break;case`Object`:{let t=c[1];if(typeof i[t]==`object`&&i[t][0]!==`BigInt`)throw Error(`Invalid input`);a[e]=r.box(s(t));break}case`BigInt`:a[e]=r.fromPrimitive(BigInt(c[1]));break;case`null`:let l=r.createNullPrototypeObject();a[e]=l;for(let e=1;e<c.length;e+=2){if(c[e]===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");r.set(l,c[e],s(c[e+1]))}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{if(i[c[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=s(c[1]);a[e]=r.fromViewInfo(n,t,c[2],c[3]);break}case`ArrayBuffer`:{let t=c[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);a[e]=r.fromArrayBuffer(It(t));break}case`URL`:case`URLSearchParams`:case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:a[e]=r.fromStringValue(n,c[1]);break;default:throw Error(`Unknown type ${n}`)}}else if(c[0]===-7){let t=c[1];if(!Ct(t))throw Error(`Invalid input`);let n=r.createSparseArray(t);a[e]=n;for(let e=2;e<c.length;e+=2){let i=c[e];if(!St(i)||i>=t)throw Error(`Invalid input`);r.set(n,i,s(c[e+1]))}}else{let t=r.createArray(c.length);a[e]=t;for(let e=0;e<c.length;e+=1){let n=c[e];n!==-2&&r.set(t,e,s(n))}}else{let t=r.createObject();a[e]=t;for(let e of Object.keys(c)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");r.set(t,e,s(c[e]))}}return a[e]}return s(0)}function Wt(e,t,n){let r=Gt(!1,e,t,n);return typeof r==`string`?r:`[${r.join(`,`)}]`}function Gt(e,t,n,r){let i=Lt(Bt,r?.operations),a=[],o=new Map,s=[];if(n)for(let e of Object.getOwnPropertyNames(n))s.push({key:e,fn:n[e]});let c=[],l=0;function u(n,r){let d=i.typeOf(n);if(d===`undefined`)return-1;let f;if(d===`number`){if(f=i.toPrimitive(n),Number.isNaN(f))return-3;if(f===1/0)return-4;if(f===-1/0)return-5;if(f===0&&1/f<0)return-6}let p=i.identify(n);if(o.has(p))return o.get(p);r??=l++,o.set(p,r);for(let{key:e,fn:t}of s){let i=t(n);if(i)return a[r]=`["${e}",${u(i)}]`,r}if(d===`function`)throw new j(`Cannot stringify a function`,c,n,t);if(d===`symbol`)throw new j(`Cannot stringify a Symbol primitive`,c,n,t);let m=``;if(d!==`object`)m=Kt(d===`number`?f:i.toPrimitive(n));else if(i.isThenable(n)){if(!e)throw new j(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,c,n,t);m=i.toPromise(n).then(e=>{let t=u(e,r);t<0&&(a[r]=t)})}else{let e=i.tagOf(n);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:m=`["Object",${u(i.unbox(n))}]`;break;case`Date`:m=`["Date","${i.toISOString(n)}"]`;break;case`URL`:m=`["URL",${vt(i.toStringValue(n))}]`;break;case`URLSearchParams`:m=`["URLSearchParams",${vt(i.toStringValue(n))}]`;break;case`RegExp`:let{source:r,flags:a}=i.regExpInfo(n);m=a?`["RegExp",${vt(r)},"${a}"]`:`["RegExp",${vt(r)}]`;break;case`Array`:{let e=!1,t=i.lengthOf(n);m=`[`;for(let r=0;r<t;r+=1)if(r>0&&(m+=`,`),i.hasOwn(n,r))c.push(`[${r}]`),m+=u(i.get(n,r)),c.pop();else if(e)m+=-2;else{let r=i.indicesOf(n),a=r.length,o=String(t).length;if((t-a)*3>4+o+a*(o+1)){m=`[-7,`+t;for(let e=0;e<r.length;e++){let t=r[e];c.push(`[${t}]`),m+=`,`+t+`,`+u(i.get(n,t)),c.pop()}break}else e=!0,m+=-2}m+=`]`;break}case`Set`:m=`["Set"`;for(let e of i.valuesOf(n))m+=`,${u(e)}`;m+=`]`;break;case`Map`:m=`["Map"`;for(let[e,t]of i.entriesOf(n)){let n=i.typeOf(e),r=n!==`object`&&n!==`function`&&n!==`symbol`;c.push(`.get(${r?Kt(i.toPrimitive(e)):`...`})`),m+=`,${u(e)},${u(t)}`,c.pop()}m+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let t=i.viewInfo(n);m=`["`+e+`",`+u(t.buffer),t.byteLength!==t.bufferByteLength&&(m+=`,${t.byteOffset},${t.length}`),m+=`]`;break}case`DataView`:{let t=i.viewInfo(n);m=`["`+e+`",`+u(t.buffer),t.byteLength!==t.bufferByteLength&&(m+=`,${t.byteOffset},${t.byteLength}`),m+=`]`;break}case`ArrayBuffer`:m=`["ArrayBuffer","${Ft(i.toArrayBuffer(n))}"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:m=`["${e}",${vt(i.toStringValue(n))}]`;break;default:{let e=i.shapeOf(n);if(e.kind===`not-plain`)throw new j(`Cannot stringify arbitrary non-POJOs`,c,n,t);if(e.kind===`symbol-keys`)throw new j(`Cannot stringify POJOs with symbolic keys`,c,n,t);if(e.kind===`null-proto`){m=`["null"`;for(let r of e.keys){if(r===`__proto__`)throw new j(`Cannot stringify objects with __proto__ keys`,c,n,t);c.push(xt(r)),m+=`,${vt(r)},${u(i.get(n,r))}`,c.pop()}m+=`]`}else{m=`{`;let r=!1;for(let a of e.keys){if(a===`__proto__`)throw new j(`Cannot stringify objects with __proto__ keys`,c,n,t);r&&(m+=`,`),r=!0,c.push(xt(a)),m+=`${vt(a)}:${u(i.get(n,a))}`,c.pop()}m+=`}`}}}}return a[r]=m,r}let d=u(t);return d<0?`${d}`:a}function Kt(e){let t=typeof e;return t===`string`?vt(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var qt=e(dt(),1);async function Jt(e,t=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new c(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,t)}async function Yt(e,t,n){let r=globalThis.crypto.getRandomValues(new Uint8Array(12)),i;try{i=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,t)}catch(e){throw new _(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let a=new Uint8Array(12+i.byteLength);return a.set(r,0),a.set(new Uint8Array(i),12),a}async function Xt(e,t,n){if(t.byteLength<28)throw new _(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,12),i=t.subarray(12),a;try{a=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,i)}catch(e){throw new _(`AES-256-GCM decryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(a)}const Zt=Symbol.for(`WORKFLOW_USE_STEP`),Qt=Symbol.for(`WORKFLOW_SET_ATTRIBUTES`),$t=Symbol.for(`WORKFLOW_CREATE_HOOK`),en=Symbol.for(`WORKFLOW_SLEEP`),tn=Symbol.for(`WORKFLOW_GET_STREAM_ID`),nn=Symbol.for(`WORKFLOW_STABLE_ULID`),M=Symbol.for(`WORKFLOW_STREAM_NAME`),rn=Symbol.for(`WORKFLOW_STREAM_TYPE`),an=Symbol.for(`WORKFLOW_STREAM_FRAMING`),on=Symbol.for(`WORKFLOW_STREAM_SERVER_RUN_ID`),sn=Symbol.for(`WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID`),N=Symbol.for(`WORKFLOW_STREAM_SERVER_PUBLIC_KEY`),cn=Symbol.for(`WORKFLOW_STREAM_DRAIN`),ln=Symbol.for(`BODY_INIT`),un=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),dn=Symbol.for(`workflow-class-registry`),P=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),F=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),fn=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),pn=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`),mn=()=>S(`WORKFLOW_STREAM_MAX_INFLIGHT_CHUNKS`,1e3,{integer:!0,min:1}),hn=()=>S(`WORKFLOW_STREAM_MAX_CHUNKS_PER_BATCH`,1e3,{integer:!0,min:1}),gn=()=>S(`WORKFLOW_STREAM_MAX_BYTES_PER_BATCH`,1048576,{integer:!0,min:1}),_n=()=>S(`WORKFLOW_STREAM_MAX_BUFFERED_BYTES`,8388608,{integer:!0,min:1}),vn=()=>S(`WORKFLOW_LOCK_POLL_INTERVAL_MS`,10,{integer:!0,min:1});function yn(){let e={...a(),pendingOps:0,doneResolved:!1,streamEnded:!1};return e.promise.catch(()=>{}),e}function bn(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function xn(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Sn(e){let t=e.drainBarrier;if(!t){e.resolve();return}t().then(()=>e.resolve(),t=>e.reject(t))}function Cn(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}bn(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.writablePollingInterval=void 0,Sn(t))},vn());t.writablePollingInterval=n}function wn(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}xn(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.readablePollingInterval=void 0,Sn(t))},vn());t.readablePollingInterval=n}function Tn(e,t,n){let r=t[cn];return typeof r==`function`&&(n.drainBarrier=r),En(e,t,n)}async function En(e,t,n){let r=e.getReader(),i=t.getWriter(),a;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),i.closed.then(()=>{throw new c(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await i.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await i.write(e.value)}finally{n.pendingOps--}}}catch(e){throw n.streamEnded=!0,a=e,n.drainBarrier&&await n.drainBarrier().catch(()=>{}),n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(a).catch(()=>{}),r.releaseLock(),i.releaseLock()}}function Dn(e){if(e.specVersion!==5)throw new c(`This Workflow runtime requires a World with matching spec version 5, but the configured World declares spec version ${e.specVersion??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const On=Symbol.for(`@workflow/world//cache`),kn=Symbol.for(`@workflow/world//cachePromise`),An=Symbol.for(`@workflow/world//getWorldFn`);async function jn(){let e=globalThis;if(e[On])return Dn(e[On]),e[On];if(e[kn])return e[On]=await e[kn],Dn(e[On]),e[On];let t=e[An];if(t){let e=await t();return Dn(e),e}throw Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.")}const Mn=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]),Nn=new TextEncoder;function Pn(e){if(e.byteLength!==32)throw new c(`Run key material must be exactly 32 bytes, got ${e.byteLength}`)}function Fn(e,t){if(e.byteLength!==32)throw new c(`${t} must be exactly 32 bytes, got ${e.byteLength}`)}async function In(e){Pn(e);let t=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),n=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:Nn.encode(`workflow/encp/x25519/v1`)},t,256),r=new Uint8Array(n);return{scalar:r,publicKey:await Ln(r)}}async function Ln(e){let t=await Rn(e,!0),n=await globalThis.crypto.subtle.exportKey(`jwk`,t);if(!n.x)throw new c(`X25519 JWK export did not include a public key component ("x")`);let r=Un(n.x);if(r.byteLength!==32)throw new c(`X25519 JWK export produced a ${r.byteLength}-byte public key, expected 32`);return r}async function Rn(e,t){let n=new Uint8Array(Mn.length+e.byteLength);return n.set(Mn,0),n.set(e,Mn.length),globalThis.crypto.subtle.importKey(`pkcs8`,n,{name:`X25519`},t,[`deriveBits`])}function zn(e){return globalThis.crypto.subtle.importKey(`raw`,e,{name:`X25519`},!0,[])}const Bn=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Vn(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,a=n+2<e.length?e[n+2]:0;t+=Bn[r>>2&63],t+=Bn[(r&3)<<4|i>>4&15],t+=n+1<e.length?Bn[(i&15)<<2|a>>6&3]:`=`,t+=n+2<e.length?Bn[a&63]:`=`}return t}function Hn(e){let t=e.length;for(;t>0&&e[t-1]===`=`;)t--;let n=e.slice(0,t);if(n.includes(`=`)||n.length%4==1||t!==e.length&&e.length%4!=0)return;let r=0,i=0,a=[];for(let e=0;e<n.length;e++){let t=Bn.indexOf(n[e]);if(t===-1)return;r=r<<6|t,i+=6,i>=8&&(i-=8,a.push(r>>i&255))}if(!(i>0&&r&(1<<i)-1))return new Uint8Array(a)}function Un(e){let t=0,n=0,r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a===`=`)break;let o=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(a);if(o===-1)throw new c(`Invalid base64url character "${a}" in X25519 JWK key component`);t=t<<6|o,n+=6,n>=8&&(n-=8,r.push(t>>n&255))}return new Uint8Array(r)}async function Wn(e,t,n,r){let i=Nn.encode(`workflow/encp/aes256gcm/v1`),a=new Uint8Array(i.length+t.length+n.length);a.set(i,0),a.set(t,i.length),a.set(n,i.length+t.length);let o=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),s=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:a},o,256);return globalThis.crypto.subtle.importKey(`raw`,new Uint8Array(s),`AES-GCM`,!1,r)}async function Gn(e){Fn(e,`Recipient public key`);let t;try{t=await zn(e)}catch(e){throw new c(`Invalid X25519 recipient public key: ${e instanceof Error?e.message:String(e)}`,{cause:e})}let n=await globalThis.crypto.subtle.generateKey({name:`X25519`},!0,[`deriveBits`]),r=new Uint8Array(await globalThis.crypto.subtle.exportKey(`raw`,n.publicKey)),i;try{i=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:t},n.privateKey,256)}catch(e){throw new c(`X25519 key agreement failed: the recipient public key is not a valid curve point (low-order point or corrupted key material)`,{cause:e})}return{ephemeralPublicKey:r,contentKey:await Wn(new Uint8Array(i),r,e,[`encrypt`])}}async function Kn(e,t){if(t.byteLength!==32)throw new _(`Sealed payload has a malformed ephemeral public key: expected 32 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let n;try{let[r,i]=await Promise.all([Rn(e.scalar,!1),zn(t)]);n=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:i},r,256)}catch(e){throw new _(`X25519 key agreement failed while opening a sealed payload: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return Wn(new Uint8Array(n),t,e.publicKey,[`decrypt`])}async function qn(e,t,n){let{ephemeralPublicKey:r,contentKey:i}=await Gn(e),a=await Yt(i,t,n),o=new Uint8Array(r.byteLength+a.byteLength);return o.set(r,0),o.set(a,r.byteLength),o}async function Jn(e,t,n){if(t.byteLength<60)throw new _(`Sealed payload too short: expected at least 60 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,32),i=t.subarray(32);return Xt(await Kn(e,r),i,n)}function Yn(e,t){let n;return{async seal(r){n??=Gn(e);let{ephemeralPublicKey:i,contentKey:a}=await n,o=await Yt(a,r,t),s=new Uint8Array(i.byteLength+o.byteLength);return s.set(i,0),s.set(o,i.byteLength),s}}}function Xn(e,t){let n,r;return{async open(i){if(i.byteLength<60)throw new _(`Sealed payload too short: expected at least 60 bytes, got ${i.byteLength}`,{context:{operation:`decrypt`,byteLength:i.byteLength}});let a=i.subarray(0,32),o=i.subarray(32),s=Zn(a);(s!==n||!r)&&(n=s,r=Kn(e,a));let c;try{c=await r}catch(e){throw n=void 0,r=void 0,e}return Xt(c,o,t)}}}function Zn(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}function Qn(e){if(!e)return;let t=Hn(e);if(!(!t||t.byteLength!==32))return t}let $n=null,er=null;function tr(e,t){let n=$n,r=er;$n=e??null,er=e?new WeakSet:null;try{return t()}finally{$n=n,er=r}}const nr=new WeakSet;function rr(e){return nr.add(e),e}function ir(e){return typeof e==`function`&&nr.has(e)}function ar(e,t){if(!$n)return;let n={kind:e};t!==void 0&&(n.detail=t),$n.executions.push(n)}function I(e){!$n||!er||er.has(e)||(er.add(e),ar(`proxy`))}const L=Function.prototype.bind.bind(Function.prototype.call);function R(e,t){let n=Object.getOwnPropertyDescriptor(e,t)?.get;if(!n)throw Error(`Missing intrinsic getter: ${String(t)}`);return L(n)}const or=L(Date.prototype.getDate),sr=L(Date.prototype.getTime),cr=L(Date.prototype.toISOString),lr=R(RegExp.prototype,`source`),ur=R(RegExp.prototype,`flags`),dr=R(ArrayBuffer.prototype,`byteLength`),fr=L(Map.prototype.entries),pr=L(Set.prototype.values),mr=L(Number.prototype.valueOf),hr=L(String.prototype.valueOf),gr=L(Boolean.prototype.valueOf),_r=L(BigInt.prototype.valueOf),vr=Object.getPrototypeOf(Uint8Array.prototype),yr=R(vr,Symbol.toStringTag),br=R(vr,`buffer`),xr=R(vr,`byteOffset`),Sr=R(vr,`byteLength`),Cr=R(vr,`length`),wr=R(DataView.prototype,`buffer`),Tr=R(DataView.prototype,`byteOffset`),Er=R(DataView.prototype,`byteLength`),Dr=R(SharedArrayBuffer.prototype,`byteLength`),Or=L(Headers.prototype[Symbol.iterator]),kr=R(URL.prototype,`href`),Ar=L(URLSearchParams.prototype.toString),{isProxy:z}=C,jr=L(Function.prototype.toString);function Mr(e){if(z(e))return!1;let t=Object.getOwnPropertyDescriptor(e,`name`)?.value;return typeof t==`string`&&t.startsWith(`bound `)?!1:jr(e).endsWith(`{ [native code] }`)||Reflect.getPrototypeOf(e)===Function.prototype}function B(e,t){if(e===null||typeof e!=`object`&&typeof e!=`function`)return;if(z(e))return I(e),e[t];let n=e;for(;n!==null;){if(z(n))return I(n),e[t];let r=Object.getOwnPropertyDescriptor(n,t);if(r)return`value`in r?r.value:r.get?(Mr(r.get)||ar(`getter`,String(t)),r.get.call(e)):void 0;n=Reflect.getPrototypeOf(n)}}function Nr(e,t){if(e===null||typeof e!=`object`&&typeof e!=`function`)return!1;if(z(e))return I(e),t in e;let n=e;for(;n!==null;){if(z(n))return I(n),t in e;if(Object.getOwnPropertyDescriptor(n,t))return!0;n=Reflect.getPrototypeOf(n)}return!1}function V(e,t){if(!t||typeof e!=`object`||!e)return!1;z(e)&&I(e);let n=Reflect.getPrototypeOf(e);for(;n!==null;){if(n===t)return!0;z(n)&&I(n),n=Reflect.getPrototypeOf(n)}return!1}function Pr(e){return z(e)?(I(e),e.href):kr(e)}function Fr(e){return z(e)?(I(e),String(e)):Ar(e)}function Ir(e){return z(e)?(I(e),Array.from(e)):[...Or(e)]}function Lr(e){return[...fr(e)]}function Rr(e){return[...pr(e)]}function zr(e){return C.isDataView(e)?{buffer:wr(e),byteOffset:Tr(e),byteLength:Er(e)}:{buffer:br(e),byteOffset:xr(e),byteLength:Sr(e)}}const Br=new Set([`Int8Array`,`Uint8Array`,`Uint8ClampedArray`,`Int16Array`,`Uint16Array`,`Float16Array`,`Int32Array`,`Uint32Array`,`Float32Array`,`Float64Array`,`BigInt64Array`,`BigUint64Array`]),Vr=new Set([`Date`,`RegExp`,`Map`,`Set`,`Array`,`DataView`,`ArrayBuffer`,`SharedArrayBuffer`,`Number`,`String`,`Boolean`,`BigInt`,`URL`,`URLSearchParams`,...Br]);function Hr(e){if(C.isDate(e))return`Date`;if(C.isRegExp(e))return`RegExp`;if(C.isMap(e))return`Map`;if(C.isSet(e))return`Set`;if(Array.isArray(e))return`Array`;if(C.isTypedArray(e)){let t=yr(e);return t!==void 0&&Br.has(t)?t:void 0}if(C.isDataView(e))return`DataView`;if(C.isArrayBuffer(e))return`ArrayBuffer`;if(C.isSharedArrayBuffer(e))return`SharedArrayBuffer`;if(C.isNumberObject(e))return`Number`;if(C.isStringObject(e))return`String`;if(C.isBooleanObject(e))return`Boolean`;if(C.isBigIntObject(e))return`BigInt`;if(V(e,URL.prototype))return`URL`;if(V(e,URLSearchParams.prototype))return`URLSearchParams`}function Ur(e){let t=B(e,Symbol.toStringTag);return typeof t==`string`?t:void 0}const Wr={tagOf:e=>{if(z(e))return I(e),Bt.tagOf(e);let t=Hr(e);if(t!==void 0)return t;let n=Ur(e);return n===void 0||Vr.has(n)?`Object`:n},isThenable:e=>C.isPromise(e)?!0:typeof B(e,`then`)==`function`,unbox:e=>C.isNumberObject(e)?mr(e):C.isStringObject(e)?hr(e):C.isBooleanObject(e)?gr(e):_r(e),toISOString:e=>Number.isNaN(or(e))?``:cr(e),toStringValue:e=>V(e,URL.prototype)?Pr(e):V(e,URLSearchParams.prototype)?Fr(e):(ar(`method`,`toString (${Ur(e)??`unknown`})`),e.toString()),regExpInfo:e=>({source:lr(e),flags:ur(e)}),valuesOf:e=>Rr(e),entriesOf:e=>Lr(e),viewInfo:e=>{let t=zr(e);return{...t,length:C.isDataView(e)?0:Cr(e),bufferByteLength:C.isSharedArrayBuffer(t.buffer)?Dr(t.buffer):dr(t.buffer)}},shapeOf:e=>(z(e)&&I(e),Bt.shapeOf(e)),get:(e,t)=>B(e,t)},Gr=Symbol.for(`workflow-serialize`),Kr=Symbol.for(`workflow-deserialize`);function qr(e=globalThis){let t=e,n=t[dn];return n||(n=new Map,t[dn]=n),n}const Jr=`class//workflow//Run`;function Yr(e,t,n=globalThis){qr(n).set(e,t)}function Xr(e,t){return qr(t).get(e)}function Zr(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=B(e,`classId`);return typeof t==`string`&&{classId:t}},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=B(e,`constructor`);if(!t||typeof t!=`function`)return!1;let n=B(t,Gr);if(typeof n!=`function`)return!1;let r=B(t,`classId`);if(typeof r!=`string`)throw Error(`Class "${String(B(t,`name`))}" with ${String(Gr)} must have a static "classId" property.`);return ar(`method`,`[WORKFLOW_SERIALIZE] (${r})`),{classId:r,data:n.call(t,e)}}}}function Qr(e=globalThis){return{Class:t=>{let n=t.classId,r=Xr(n,e);if(!r)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);return r},Instance:t=>{let n=t.classId,r=t.data,i=Xr(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[Kr];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(Kr)} method.`);return a.call(i,r)}}}function $r(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function H(e){let t=zr(e);return $r(t.buffer,t.byteOffset,t.byteLength)}function U(e,t){let n=e===`.`?``:e,r=Buffer.from(n,`base64`),i=new t.ArrayBuffer(r.length);return new t.Uint8Array(i).set(r),i}function ei(e){return JSON.parse(e)}function ti(e){if(!C.isNativeError(e))return!1;let t={message:B(e,`message`),stack:B(e,`stack`)};return Nr(e,`cause`)&&(t.cause=B(e,`cause`)),t}function ni(e,t){return!C.isNativeError(t)||B(t,`name`)!==e?!1:ti(t)}function ri(e){return t=>ni(e,t)||!1}function ii(e,t){return n=>{let r=n,i=`cause`in r?{cause:r.cause}:void 0,a=e[t],o=new a(r.message,i);return r.stack!==void 0&&(o.stack=r.stack),o}}function ai(e=globalThis){return{ArrayBuffer:e=>C.isArrayBuffer(e)&&$r(e,0,dr(e)),BigInt:e=>typeof e==`bigint`&&String(e),BigInt64Array:e=>C.isBigInt64Array(e)&&H(e),BigUint64Array:e=>C.isBigUint64Array(e)&&H(e),Date:e=>C.isDate(e)?Number.isNaN(or(e))?`.`:cr(e):!1,DOMException:e=>{if(typeof e!=`object`||!e)return!1;let t=B(e,`constructor`);if(!t||B(t,`name`)!==`DOMException`)return!1;let n={message:B(e,`message`),name:B(e,`name`),stack:B(e,`stack`)};return Nr(e,`cause`)&&(n.cause=B(e,`cause`)),n},EvalError:ri(`EvalError`),FatalError:ri(`FatalError`),HookConflictError:e=>{let t=ni(`HookConflictError`,e);if(!t)return!1;let n={...t,token:B(e,`token`)},r=B(e,`conflictingRunId`);return r!==void 0&&(n.conflictingRunId=r),n},RangeError:ri(`RangeError`),ReferenceError:ri(`ReferenceError`),RetryableError:e=>{let t=ni(`RetryableError`,e);if(!t)return!1;let n=B(e,`retryAfter`),r;if(C.isDate(n)){let e=sr(n);r=Number.isNaN(e)?Date.now()+1e3:e}else if(n&&typeof n==`object`){let e=B(n,`getTime`);if(typeof e==`function`){ar(`method`,`getTime`);let t=e.call(n);r=Number.isNaN(t)?Date.now()+1e3:t}else r=Date.now()+1e3}else if(typeof n==`string`||typeof n==`number`){let e=new Date(n).getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else r=Date.now()+1e3;return{...t,retryAfter:r}},RuntimeDecryptionError:e=>{let t=ni(`RuntimeDecryptionError`,e);if(!t)return!1;let n={...t},r=B(e,`context`);return r!==void 0&&(n.context=r),n},SyntaxError:ri(`SyntaxError`),TypeError:ri(`TypeError`),URIError:ri(`URIError`),AggregateError:e=>{let t=ni(`AggregateError`,e);return t?{...t,errors:B(e,`errors`)}:!1},Error:e=>{if(!C.isNativeError(e))return!1;let t={name:B(e,`name`),message:B(e,`message`),stack:B(e,`stack`)};return Nr(e,`cause`)&&(t.cause=B(e,`cause`)),t},Float32Array:e=>C.isFloat32Array(e)&&H(e),Float64Array:e=>C.isFloat64Array(e)&&H(e),Headers:e=>V(e,Headers.prototype)&&Ir(e),Int8Array:e=>C.isInt8Array(e)&&H(e),Int16Array:e=>C.isInt16Array(e)&&H(e),Int32Array:e=>C.isInt32Array(e)&&H(e),Map:e=>C.isMap(e)&&Lr(e),RegExp:e=>C.isRegExp(e)&&{source:lr(e),flags:ur(e)},Set:e=>C.isSet(e)&&Rr(e),URL:e=>V(e,URL.prototype)&&Pr(e),WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=B(e,`workflowId`);return typeof t==`string`&&{workflowId:t}},URLSearchParams:e=>{if(!V(e,URLSearchParams.prototype))return!1;let t=Fr(e);return t===``?`.`:t},Uint8Array:e=>C.isUint8Array(e)&&H(e),Uint8ClampedArray:e=>C.isUint8ClampedArray(e)&&H(e),Uint16Array:e=>C.isUint16Array(e)&&H(e),Uint32Array:e=>C.isUint32Array(e)&&H(e)}}function oi(e=globalThis){return{ArrayBuffer:t=>U(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(U(t,e)),BigUint64Array:t=>new e.BigUint64Array(U(t,e)),Date:t=>new e.Date(t),DOMException:t=>{let n=new e.DOMException(t.message,t.name);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},EvalError:ii(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??m)(t.message);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},HookConflictError:t=>{let n=new(e[Symbol.for(`@workflow/errors//HookConflictError`)]??u)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:ii(e,`RangeError`),ReferenceError:ii(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??b)(t.message,{retryAfter:new e.Date(t.retryAfter)});return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RuntimeDecryptionError:t=>{let n=e[Symbol.for(`@workflow/errors//RuntimeDecryptionError`)]??_,r={};`cause`in t&&(r.cause=t.cause),t.context!==void 0&&(r.context=t.context);let i=new n(t.message,r);return t.stack!==void 0&&(i.stack=t.stack),i},SyntaxError:ii(e,`SyntaxError`),TypeError:ii(e,`TypeError`),URIError:ii(e,`URIError`),AggregateError:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.AggregateError(t.errors,t.message,n);return t.stack!==void 0&&(r.stack=t.stack),r},Error:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.Error(t.message,n);return r.name=t.name,t.stack!==void 0&&(r.stack=t.stack),r},Float32Array:t=>new e.Float32Array(U(t,e)),Float64Array:t=>new e.Float64Array(U(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(U(t,e)),Int16Array:t=>new e.Int16Array(U(t,e)),Int32Array:t=>new e.Int32Array(U(t,e)),Map:t=>new e.Map(t),RegExp:t=>new e.RegExp(t.source,t.flags),Set:t=>new e.Set(t),URL:t=>new e.URL(t),WorkflowFunction:e=>Object.assign(()=>{throw Error(`Workflow functions cannot be called directly. Use start() to invoke them.`)},{workflowId:e.workflowId}),URLSearchParams:t=>new e.URLSearchParams(t===`.`?``:t),Uint8Array:t=>new e.Uint8Array(U(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(U(t,e)),Uint16Array:t=>new e.Uint16Array(U(t,e)),Uint32Array:t=>new e.Uint32Array(U(t,e))}}function si(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=B(e,`stepId`);if(typeof t!=`string`)return!1;let n=B(e,`__closureVarsFn`),r;typeof n==`function`&&(ir(n)||ar(`method`,`__closureVarsFn`),r=n());let i=Nr(e,`__boundThis`),a=i?B(e,`__boundThis`):void 0,o=B(e,`__boundArgs`),s={stepId:t};return r!==void 0&&(s.closureVars=r),i&&(s.boundThis=a),Array.isArray(o)&&o.length>0&&(s.boundArgs=o),s}}}function ci(e=globalThis){let t=e[Symbol.for(`WORKFLOW_USE_STEP`)];return{StepFunction:e=>{let n=e.stepId,r=e.closureVars;if(!t)throw Error(`WORKFLOW_USE_STEP not found on global object. Step functions cannot be deserialized outside workflow context.`);let i=r?t(n,()=>r):t(n);if(`boundThis`in e){let t=Array.isArray(e.boundArgs)?e.boundArgs:[];return i.bind(e.boundThis,...t)}return i}}}function li(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const W={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,SEALED:`encp`,GZIP:`gzip`,ZSTD:`zstd`},ui=new TextEncoder,di=new TextDecoder;function fi(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Zr(),...si(),...ai(t)};break;case`step`:r={...Zr(),...ai(t)};break;case`client`:r={...Zr(),...ai(t)};break}return n?{...r,...n}:r}function pi(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Qr(t),...ci(t),...oi(t)};break;case`step`:r={...Qr(t),...oi(t)};break;case`client`:r={...Qr(t),...oi(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}};break}return n?{...r,...n}:r}const G={formatPrefix:W.DEVALUE_V1,serialize(e,t,n){let r=fi(t,n?.global,n?.extraReducers),i=tr(n?.guestCodeStats,()=>Wt(e,r,{operations:Wr}));return ui.encode(i)},deserialize(e,t,n){let r=pi(t,n?.global,n?.extraRevivers);return Ht(di.decode(e),r)},deserializeLegacy(e,t,n){return Ut(e,pi(t,n?.global,n?.extraRevivers))}},mi=new TextEncoder,hi=new TextDecoder;function K(e,t){if(!(t instanceof Uint8Array))return t;let n=mi.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function gi(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=hi.decode(t);return li(n)?n:null}function q(e){if(!(e instanceof Uint8Array))return{format:W.DEVALUE_V1,payload:new TextEncoder().encode(JSON.stringify(e))};if(e.length<4)throw Error(`Data too short to contain format prefix: expected at least 4 bytes, got ${e.length}`);let t=e.subarray(0,4),n=hi.decode(t);if(!li(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}function _i(){try{return typeof process<`u`&&process.env?.WORKFLOW_DISABLE_COMPRESSION===`1`}catch{return!1}}function vi(){try{let e=process.env?.WORKFLOW_COMPRESSION_CODEC;return e===`gzip`||e===`zstd`?e:void 0}catch{return}}function yi(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function bi(){let e=yi();return typeof e?.zstdCompressSync==`function`&&typeof e?.zstdDecompressSync==`function`}function xi(){return typeof CompressionStream==`function`&&typeof DecompressionStream==`function`}async function Si(e,t){let n=t.writable.getWriter(),r=n.write(e).then(()=>n.close());r.catch(()=>{});let i=[],a=0,o=t.readable.getReader();for(;;){let{done:e,value:t}=await o.read();if(e)break;i.push(t),a+=t.length}await r;let s=new Uint8Array(a),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function Ci(e){return Si(e,new CompressionStream(`gzip`))}async function wi(e){return Si(e,new DecompressionStream(`gzip`))}function Ti(e){let t=yi(),n=t?.constants?.ZSTD_c_compressionLevel,r=n===void 0?void 0:{params:{[n]:3}};return new Uint8Array(t.zstdCompressSync(e,r))}function Ei(e){let t=yi();if(!t?.zstdDecompressSync)throw Error(`Compressed (zstd) workflow data encountered but node:zlib zstd support is not available in this runtime (requires Node.js 22.15+). In the browser, register a zstd decoder via registerZstdDecoder (serialization-format.ts).`);return new Uint8Array(t.zstdDecompressSync(e))}function Di(e,t,n,r){e&&(e.recorded=!0,e.compressed=t!==`none`,e.codec=t,e.uncompressedBytes=n,e.storedBytes=r)}function Oi(){return vi()===`gzip`?xi()?`gzip`:`none`:bi()?`zstd`:xi()?`gzip`:`none`}async function ki(e,t,n){if(!(e instanceof Uint8Array))return e;if(!t||e.length<1024||_i())return Di(n,`none`,e.length,e.length),e;let r=Oi();if(r===`none`)return Di(n,`none`,e.length,e.length),e;let i=r===`zstd`?Ti(e):await Ci(e),a=r===`zstd`?W.ZSTD:W.GZIP,o=4+i.length;return o>=e.length*.95?(Di(n,`none`,e.length,e.length),e):(Di(n,r,e.length,o),K(a,i))}async function Ai(e,t){if(!(e instanceof Uint8Array))return e;let n=gi(e);if(n===W.ZSTD){let{payload:n}=q(e),r=Ei(n);return Di(t,`zstd`,r.length,e.length),r}if(n===W.GZIP){if(!xi())throw Error(`Compressed (gzip) workflow data encountered but DecompressionStream is not available in this runtime. Node.js 18+, browsers, and edge runtimes all support it.`);let{payload:n}=q(e),r=await wi(n);return Di(t,`gzip`,r.length,e.length),r}return Di(t,`none`,e.length,e.length),e}const ji=Symbol.for(`workflow.serialization.sealTarget`),Mi=Symbol.for(`workflow.serialization.runKeys`);function Ni(e,t){return{[ji]:!0,recipientPublicKey:e,aad:t}}function Pi(e,t,n){return{[Mi]:!0,aes:e,keyPair:t,aad:n}}async function Fi(e){let[t,n]=await Promise.all([Jt(e),In(e)]);return Pi(t,n)}function Ii(e){return typeof e==`object`&&!!e&&e[ji]===!0}function Li(e){return typeof e==`object`&&!!e&&e[Mi]===!0}function Ri(e){if(e){if(Li(e))return e.aes;if(!Ii(e))return e}}async function zi(e){return typeof e==`function`?e():e}async function Bi(e,t){if(!t||!(e instanceof Uint8Array))return e;if(Ii(t)){let n=await qn(t.recipientPublicKey,e,t.aad);return K(W.SEALED,n)}let n=await Yt(Li(t)?t.aes:t,e);return K(W.ENCRYPTED,n)}async function Vi(e,t){if(!Li(t))throw new _(`Sealed data encountered but no run keypair is available. Opening a sealed payload requires the run's own encryption key material; a symmetric key or a seal-only target cannot decrypt it.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encp`}});let{payload:n}=q(e);try{return await Jn(t.keyPair,n,t.aad)}catch(e){throw _.is(e)&&e.context&&(e.context.formatPrefix=W.SEALED),e}}async function Hi(e,t){if(!(e instanceof Uint8Array))return e;let n=gi(e);if(n===W.SEALED)return Vi(e,t);if(n!==W.ENCRYPTED)return e;let r=Ri(t);if(!r)throw new _(`Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encr`}});let{payload:i}=q(e);try{return await Xt(r,i)}catch(e){throw _.is(e)&&e.context&&(e.context.formatPrefix=n),e}}function Ui(e,t,n){let[r,...i]=t.split(`
6
+ `),a=i.join(`
7
+ `),o=Wi(r??``,n),s=Gi(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
8
+ `)}function Wi(e,t){if(!t||Object.keys(t).length===0)return null;let n=new Set;n.add(`errorStack`),typeof t.errorMessage==`string`&&e.includes(t.errorMessage)&&n.add(`errorMessage`);let r=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`hint`,`attempt`,`retryCount`]),i=[],a=qi(t,`errorName`),o=qi(t,`errorAttribution`);if(a||o){let e=o?o===`sdk`?Se(`sdk error`):xe(`user error`):``,t=a?be(a):``,n=e&&t?D(` · `):``;i.push(` ${e}${n}${t}`)}let s=qi(t,`workflowRunId`),c=qi(t,`workflowName`);s?i.push(Yi(`run`,s,c,ue)):c&&i.push(Yi(`run`,null,c,ue));let l=qi(t,`stepId`),u=qi(t,`stepName`);if((l||u)&&i.push(Yi(`step`,l,u,le)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?i.push(` ${Ji(`retry`)} ${e} ${D(`attempts ·`)} ${n} ${D(`max retries`)}`):e!==void 0&&i.push(` ${Ji(`retry`)} ${e} ${D(`attempts`)}`)}let d=qi(t,`errorCode`);d&&d!==a&&i.push(` ${Ji(`code`)} ${D(d)}`);let f=qi(t,`hint`);f&&i.push(` ${_e(f)}`);let p=Object.entries(t).filter(([e,t])=>!r.has(e)&&!n.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of p)i.push(` ${Ji(e)} ${Xi(t)}`);return i.length?i.join(`
9
+ `):null}function Gi(e){if(!e)return null;let t=e.split(`
10
+ `),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(D(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&Ki(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(D(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
11
+ `)}function Ki(e){let t=e.trimStart();return t.startsWith(`at `)?!!(t.includes(`node:internal/`)||t.includes(`node_modules/.pnpm/`)||t.includes(`node_modules__pnpm_`)||t.includes(`_next_dist_`)||t.includes(`node_modules/next/`)||t.includes(`node_modules/@opentelemetry/`)||t.includes(`node_modules/vitest/`)||t.includes(`node_modules/@vitest/`)):!1}function qi(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Ji(e){return D(e.padEnd(6))}function Yi(e,t,n,r){let i=t||D(`—`),a=n&&(e===`run`?se(n):ce(n))?`${D(`·`)} ${r(n)}`:``;return` ${Ji(e)} ${i}${a?` `+a:``}`}function Xi(e){if(typeof e==`string`)return e.includes(`
12
+ `)?e.split(`
13
+ `).map((e,t)=>t===0?e:` ${e}`).join(`
14
+ `):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var Zi=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,a=0,o=0,s=0,c=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?s++:e.abortRequested?c++:i++:e.type===`wait`?a++:e.type===`attribute`&&o++;let l=[];r>0&&l.push(`${r} ${w(`step`,`steps`,r)}`),i>0&&l.push(`${i} ${w(`hook`,`hooks`,i)}`),a>0&&l.push(`${a} ${w(`wait`,`waits`,a)}`),o>0&&l.push(`${o} ${w(`attribute write`,`attribute writes`,o)}`),s>0&&l.push(`${s} hook ${w(`disposal`,`disposals`,s)}`);let u=w(`has`,`have`,r+i+a+o+s),d=+(r>0)+ +(i>0)+ +(a>0)+ +(o>0)+ +(s>0),f;f=d>1?`processed`:r>0?`run`:i>0||a>0?`created`:o>0?`written`:s>0?`processed`:`received`;let p=l.length>0?`${l.join(` and `)} ${u} not been ${f} yet`:`0 steps have not been run yet`;super(p),this.name=`WorkflowSuspension`,this.steps=n,this.globalThis=t,this.stepCount=r,this.hookCount=i,this.waitCount=a,this.attributeCount=o,this.hookDisposedCount=s,this.abortCount=c}static is(t){return t instanceof e}};function Qi(){throw new c(`This API is not available inside a workflow function. Workflow functions run in a deterministic VM; move the call to a step function for full Node.js access.`)}function J(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const $i=J(`workflow.name`),ea=J(`workflow.operation`),ta=J(`workflow.run.id`),na=J(`workflow.run.status`),ra=J(`workflow.started_at`),ia=J(`workflow.events.count`),aa=J(`workflow.arguments.count`),oa=J(`workflow.result.type`),sa=J(`workflow.trace.propagated`),ca=J(`workflow.trace.mode`),la=J(`workflow.turbo`),ua=J(`workflow.error.name`),da=J(`workflow.error.message`),fa=J(`workflow.error.code`),pa=J(`workflow.steps.created`),ma=J(`workflow.hooks.created`),ha=J(`workflow.waits.created`),ga=J(`workflow.inline_ownership.owned_recovery_steps`),_a=J(`workflow.inline_ownership.backstop_wakes_armed`),va=J(`workflow.route.type`),ya=J(`workflow.route.handler_cached`),ba=J(`workflow.route.invocation_count`),xa=J(`workflow.route.entrypoint_age_ms`),Sa=J(`workflow.route.module_body_init_ms`),Ca=J(`faas.instance`),wa=J(`step.name`),Ta=J(`step.id`),Ea=J(`step.attempt`),Da=J(`step.status`),Oa=J(`step.max_retries`),ka=J(`step.ttfs_ms`),Aa=J(`step.stso_ms`),ja=J(`step.rsfs_ms`),Ma=J(`step.final_scheduling_replay_ms`),Na=J(`step.latency_optimizations`),Pa=J(`step.skipped`),Fa=J(`step.skip_reason`),Ia=J(`step.arguments.count`),La=J(`step.result.type`),Ra=J(`step.error.name`),za=J(`step.error.message`),Ba=J(`step.fatal_error`),Va=J(`step.retry.exhausted`),Ha=J(`step.retry.timeout_seconds`),Ua=J(`step.retry.will_retry`),Wa=J(`messaging.system`),Ga=J(`messaging.destination.name`),Ka=J(`messaging.message.id`),qa=J(`messaging.operation.type`),Ja=J(`workflow.queue.overhead_ms`),Ya=J(`deployment.id`),Xa=J(`workflow.hook.token`),Za=J(`workflow.hook.id`),Qa=J(`workflow.hook.found`),$a=J(`workflow.hook.resilient_resume`),eo=J(`workflow.hook.resilient_resume_materialized`),to=J(`workflow.suspension.state`),no=J(`workflow.suspension.hook_count`),ro=J(`workflow.suspension.step_count`),io=J(`workflow.suspension.wait_count`),ao=J(`http.request.method`),oo=J(`http.route`),so=J(`http.response.status_code`),co=J(`error.type`),lo=J(`workflow.events.pages_loaded`),uo=J(`workflow.queue.deserialize_time_ms`),fo=J(`workflow.queue.execution_time_ms`),po=J(`workflow.queue.serialize_time_ms`),mo=J(`workflow.serialization.operation`),ho=J(`workflow.serialization.compressed`),go=J(`workflow.serialization.codec`),_o=J(`workflow.serialization.uncompressed_bytes`),vo=J(`workflow.serialization.stored_bytes`),yo=J(`workflow.serialization.compression_ratio`),bo=J(`workflow.serialization.guest_code_executions`),xo=J(`workflow.serialization.guest_code_details`),So=J(`peer.service`),Co=J(`rpc.system`),wo=J(`rpc.service`),To=J(`rpc.method`),Eo=J(`error.retryable`),Do=J(`error.category`),Oo=new Set;function ko(){let e=process.env.WORKFLOW_TRACE_MODE;return e===`continuous`?`continuous`:(e&&e!==`linked`&&!Oo.has(e)&&(Oo.add(e),X.warn(`Unrecognized WORKFLOW_TRACE_MODE value "${e}"; expected "linked" or "continuous". Falling back to "linked".`)),`linked`)}function Ao(e){return e!==void 0&&Object.keys(e).length>0}function jo(e,t){return e===`linked`&&Ao(t)?Promise.resolve(t):No()}async function Mo(e,t){if(e!==`linked`)return Ko();let n=await qo(Ao(t)?t:void 0);return n?[n]:void 0}async function No(){let e=await Y.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function Po(e){let t=await Y.value;if(t)return t.propagation.extract(t.context.active(),e)}async function Fo(e,t){if(!e)return t();let n=await Y.value;if(!n)return t();let r=await Po(e);return r?n.context.with(r,async()=>await t()):t()}const Y=r(async()=>{try{return await import(`./src-Cj3P1ChQ.js`).then(t=>e(t.t(),1))}catch{return X.info(`OpenTelemetry not available, tracing will be disabled`),null}}),Io=r(async()=>{let e=await Y.value;if(!e)return null;let t=e.trace.getTracer(`workflow`);return Ro(e,t),t});let Lo=!1;function Ro(e,t){let n=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);if(!(Lo||!n)){Lo=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.core`);console.warn(`[workflow:otel-diag] core`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] core failed:`,e instanceof Error?e.message:e)}}}async function zo(e,...t){let[n,r]=await Promise.all([Io.value,Y.value]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),Vo(t,r,e),t}finally{e.end()}})}async function Bo(e,t,n){let r=await Io.value;r&&r.startSpan(e,{...n,startTime:t}).end()}function Vo(e,t,n){!e||!Zi.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({...to(`suspended`),...ro(e.stepCount),...no(e.hookCount),...io(e.waitCount)}))}async function Ho(e){let[t,n]=await Promise.all([Po(e),Y.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function Uo(){return await Go(e=>e.trace.getActiveSpan())}async function Wo(e){return Go(t=>t.SpanKind[e])}async function Go(e){let t=await Y.value;if(t)return await e(t)}function Ko(){return Go(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function qo(e){if(!e)return;let[t,n]=await Promise.all([Ho(e),Y.value]);if(!(!t||!n)&&n.trace.isSpanContextValid(t))return{context:t}}async function Jo(e,t){let n=await Y.value;if(!n)return t();let r=n.propagation.createBaggage({"workflow.run_id":{value:e.workflowRunId},"workflow.name":{value:e.workflowName}}),i=n.propagation.setBaggage(n.context.active(),r);return n.context.with(i,()=>t())}function Yo(e,t){if(!t)return!1;let n=!1;for(let r of t.split(`,`)){let t=r.trim();if(!t)continue;let i=t.startsWith(`-`),a=i?t.slice(1):t;RegExp(`^${a.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`)}$`).test(e)&&(n=!i)}return n}function Xo(e,t={}){let n=r=>{let i=n=>t.debugNamespace??`workflow:${e}:${n}`,a=t=>{let n=i(t);return(i,a)=>{let o=Object.keys(r).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...r,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(Ui(`[workflow-sdk]`,i,c)),Yo(n,process.env.DEBUG)&&(console.debug(`[${n}] ${i}`,c??``),Uo().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:a(`debug`),info:a(`info`),warn:a(`warn`),error:a(`error`),child:e=>n({...r,...e}),forRun:(e,t,i)=>n({...r,workflowRunId:e,...t===void 0?{}:{workflowName:t},...i??{}})}};return n({})}const Zo=Xo(`step`),X=Xo(`runtime`),Qo=Xo(`webhook`),$o=Xo(`events`);Xo(`adapter`),Xo(`build`,{debugNamespace:`workflow:build`});function es(e){if(_.is(e))throw e}function Z(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof j&&t.path&&(r+=` at path "${t.path}"`);let i=`Ensure you're ${n} workflow serializable types. Check the serialization docs to see what's serializable: https://workflow-sdk.dev/docs/foundations/serialization`;return t instanceof j&&t.value!==void 0&&X.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function ts(e,t,n){try{let r=G.serialize(e,`client`,n);return Bi(await ki(K(W.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){es(e);let{message:t,hint:n}=Z(`client value`,e);throw new g(t,{hint:n,cause:e})}}async function ns(e,t,n){let r=await Ai(await Hi(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(G.deserializeLegacy)return G.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=q(r);if(i===W.DEVALUE_V1)return G.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function rs(e,t,n){try{let r=G.serialize(e,`step`,n);return Bi(await ki(K(W.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){es(e);let{message:t,hint:n}=Z(`step value`,e);throw new g(t,{hint:n,cause:e})}}async function is(e,t,n){let r=await Ai(await Hi(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(G.deserializeLegacy)return G.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=q(r);if(i===W.DEVALUE_V1)return G.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function as(e,t){if(!(e instanceof Uint8Array)){if(G.deserializeLegacy)return G.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=q(e);if(n===W.DEVALUE_V1)return G.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const os=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),ss=(()=>{let e=globalThis;return e[os]??=new ae,e[os]})();function cs(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${w(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${w(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${w(`timer`,`timers`,n)}`);let i=[];e>0&&i.push(`steps are completed`),t>0&&i.push(`hooks are received`),n>0&&i.push(`timers have elapsed`);let a=i.join(` and `);return`${r.join(` and `)} to be enqueued\n Workflow will suspend and resume when ${a}`}function ls(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function us(e){return`strm_${e}_system_abort`}function ds(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return us(e.slice(5))}const fs=()=>S(`WORKFLOW_DEFERRED_CHECK_DELAY_MS`,100,{integer:!0,min:10});var Q;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Q||={});var ps=class{eventIndex;events=[];callbacks=[];onConsumedEvent;onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,this.onConsumedEvent=t.onConsumedEvent,this.onUnconsumedEvent=t.onUnconsumedEvent,this.getPromiseQueue=t.getPromiseQueue}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}notifyConsumedEvent(e){if(this.onConsumedEvent)try{this.onConsumedEvent(e)}catch(e){$o.error(`onConsumedEvent callback threw an error`,{error:e})}}consume=()=>{for(;;){let e=this.events[this.eventIndex]??null;if(!this.consumeOne(e)){this.handleUnconsumed(e);return}}};consumeOne(e){for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Q.NotConsumed;try{r=n(e)}catch(e){$o.error(`EventConsumer callback threw an error`,{error:e})}if(!(r!==Q.Consumed&&r!==Q.Finished))return e!==null&&this.notifyConsumedEvent(e),this.eventIndex++,r===Q.Finished&&this.callbacks.splice(t,1),e!==null}return!1}handleUnconsumed(e){if(e!==null){let t=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===t&&(this.pendingUnconsumedCheck=null,this.onUnconsumedEvent(e))},fs())})}}},ms=class{aborted=!1;reason=void 0;[P];[F];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[P]=e,this[F]=t}_setAborted(e){if(!this.aborted){this.aborted=!0,this.reason=e,this.#t&&this.#t.call(this);for(let e of this.#e)e();this.#e=[]}}addEventListener(e,t){if(e===`abort`){if(this.aborted){t();return}this.#e.push(t)}}removeEventListener(e,t){e===`abort`&&(this.#e=this.#e.filter(e=>e!==t))}throwIfAborted(){if(this.aborted)throw this.reason??new DOMException(`The operation was aborted.`,`AbortError`)}};function hs(e){return class{signal;[P];[F];constructor(){let t=e.generateUlid(),n=us(t),r=`abrt_${t}`;this[P]=n,this[F]=r,this.signal=new ms(n,r);let a=`hook_${e.generateUlid()}`;e.invocationsQueue.set(a,{type:`hook`,correlationId:a,token:r,isWebhook:!1,isSystem:!0}),e.eventsConsumer.subscribe(t=>{if(!t||t.correlationId!==a)return Q.NotConsumed;let n=`eventData`in t&&t.eventData&&`token`in t.eventData?t.eventData.token:void 0;if(typeof n==`string`&&n!==this[F])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new h(`Replay divergence: abort hook event ${t.eventType} for ${a} belongs to token "${n}", but the current abort hook expects "${this[F]}"`,{eventId:t.eventId}))}),Q.Finished;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(a);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Q.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload,r=e.eventsConsumer.eventIndex,s=i(e,r,`hook`),c=o(e,r,`hook`);return e.pendingDeliveries++,e.promiseQueue=e.promiseQueue.then(async()=>{let r;try{if(n!==void 0)try{let i=await e.replayPayloadCache.prepareEventPayload(t.eventId,`payload`,n),a=await yc(n,e.runId,e.encryptionKey,e.globalThis,{},i);a&&typeof a==`object`&&`reason`in a&&(r=a.reason)}catch{}}finally{e.pendingDeliveries--}c.then(()=>{s.markDelivered(),this.signal._setAborted(r)})}),e.invocationsQueue.delete(a),Q.Consumed}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(a),Q.Finished):Q.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[F]){n.abortRequested=!0,n.abortReason=t;break}}}}}function gs(){return{abort(e){let t=new ms(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new ms(``,``),n=Array.from(e);for(let e of n)if(e.aborted)return t._setAborted(e.reason),t;let r=[],i=()=>{for(let{signal:e,listener:t}of r)e.removeEventListener&&e.removeEventListener(`abort`,t);r.length=0};for(let e of n){if(!e.addEventListener)continue;let n=()=>{t.aborted||(t._setAborted(e.reason),i())};r.push({signal:e,listener:n}),e.addEventListener(`abort`,n)}return t},timeout(){throw Error(`AbortSignal.timeout() is not supported in workflow functions. Use sleep() with an AbortController instead. See: /docs/errors/abort-signal-timeout-in-workflow`)}}}const _s=re();function vs(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function ys(e){return es(e),e instanceof g&&e.cause!==void 0||e instanceof c&&e.cause!==void 0?e.cause:e}async function $(e,t){if(e.recorded)try{let n=await Uo();if(!n)return;let r=e.uncompressedBytes??0,i=e.storedBytes??0;n.setAttributes({...mo(t),...ho(e.compressed??!1),...go(e.codec??`none`),..._o(r),...vo(i),...e.compressed&&r>0?yo(1-i/r):{}})}catch{}}async function bs(e){if(e.executions.length!==0)try{let t=await Uo();if(!t)return;let n=[...new Set(e.executions.map(e=>e.detail?`${e.kind} (${e.detail})`:e.kind))];t.setAttributes({...bo(e.executions.length),...xo(n)})}catch{}}function xs(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0},i;return new TransformStream({async transform(a,o){try{r.resolved||(r.key=await zi(t),r.resolved=!0,Ii(r.key)&&(i=Yn(r.key.recipientPublicKey,r.key.aad)));let s=Wt(a,e),c=n.encode(s),l=K(W.DEVALUE_V1,c);i?l=K(W.SEALED,await i.seal(l)):r.key&&(l=await Bi(l,r.key));let u=new Uint8Array(4+l.length);new DataView(u.buffer).setUint32(0,l.length,!1),u.set(l,4),o.enqueue(u)}catch(e){if(_.is(e)){o.error(e);return}let{message:t,hint:n}=Z(`stream chunk`,e);o.error(new g(t,{hint:n,cause:e}))}}})}function Ss(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0},a;function o(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function s(o){for(i.resolved||(i.key=await zi(t),i.resolved=!0,Li(i.key)&&(a=Xn(i.key.keyPair,i.key.aad)));r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let s=r.slice(4,4+t);r=r.slice(4+t);let{format:c,payload:l}=q(s);if(c===W.ENCRYPTED||c===W.SEALED){let e=c===W.SEALED;if(!(e?Li(i.key):Ri(i.key)!==void 0)){o.error(new _(e?`Sealed stream data encountered but no run keypair is available. Opening a sealed frame requires the run's own encryption key material.`:`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:l.byteLength,formatPrefix:e?`encp`:`encr`}}));return}let t;try{t=e?await a.open(q(s).payload):await Hi(s,i.key)}catch(e){throw _.is(e)&&e.context&&(e.context.formatPrefix=c),e}({format:c,payload:l}=q(t))}if(c===W.DEVALUE_V1){let t=n.decode(l);o.enqueue(Ht(t,e))}}}return new TransformStream({async transform(t,i){if(r.length===0&&t.length>=4){let e=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!1);if(e>0&&e<1e8){o(t),await s(i);return}}else if(r.length>0){o(t),await s(i);return}let a=n.decode(t).split(`
15
+ `);for(let t of a)t.length>0&&i.enqueue(Ht(t,e))},async flush(e){r.length>0&&await s(e)}})}const Cs=1e8;function ws(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>Cs){t.error(new c(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${Cs}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function Ts(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>Cs){r.error(new c(`Byte-stream frame length ${t} exceeds maximum (${Cs}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new c(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function Es(e,t,n,r,i){(async()=>{await Bo(`workflow.stream.read`,e,{kind:await Wo(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof i==`number`?{"workflow.stream.read.connect_ms":i}:{},...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}function Ds(e,t,n,r,i,a){(async()=>{await Bo(`workflow.stream.read.complete`,e,{kind:await Wo(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read_complete`,"workflow.stream.read.total_ms":Date.now()-e,"workflow.stream.read.chunks":r,"workflow.stream.read.bytes":i,...typeof a==`number`?{"workflow.stream.read.reconnects":a}:{}}})})()}var Os=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new c(`"name" is required, got "${t}"`);let r,i=!1,a,o=0,s=0;super({type:`bytes`,pull:async c=>{let l=this.#e;if(!l){r===void 0&&(r=Date.now());let i=await jn(),o=Date.now(),s=await i.streams.get(e,t,n);a=Date.now()-o,l=this.#e=s.getReader()}if(!l){c.error(Error(`Failed to get reader`));return}let u=await l.read();u.done?(this.#e=void 0,r!==void 0&&Ds(r,e,t,o,s),c.close()):(!i&&u.value.byteLength>0&&r!==void 0&&(i=!0,Es(r,e,t,n,a)),o+=1,s+=u.value.byteLength,c.enqueue(u.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const ks=()=>S(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),As=()=>S(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,1e3,{integer:!0,min:1});function js(e,t,n){let r=n===void 0||n>=0,i=n??0,a=0,o=0,s=0,c,l=new Uint8Array,u,d,f=!1,p=0,m=0;async function h(){let o=await jn(),s=r?i+a:n,l=Date.now(),u=await o.streams.get(e,t,s);d===void 0&&(d=Date.now()-l),c=u.getReader()}async function g(){c&&=(await c.cancel().catch(()=>{}),void 0),i+=a,a=0,l=new Uint8Array;let e=ks(),n=As();for(;;){if(o++,s++,o>e)throw Error(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(s>n)throw Error(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{await h();return}catch{}}}return new ReadableStream({pull:async i=>{for(u===void 0&&(u=Date.now());;){if(!c)try{await h()}catch(e){i.error(e);return}let _;try{_=await c.read()}catch(e){if(!r){i.error(e);return}try{await g()}catch(e){i.error(e);return}continue}if(_.done||!_.value){c=void 0,u!==void 0&&Ds(u,e,t,p,m,s),i.close();return}let v=_.value;if(v.length>0){let e=new Uint8Array(l.length+v.length);e.set(l,0),e.set(v,l.length),l=e}let y=!1;for(;l.length>=4;){let r=4+new DataView(l.buffer,l.byteOffset,l.byteLength).getUint32(0,!1);if(l.length<r)break;i.enqueue(l.slice(0,r)),l=l.slice(r),a++,p++,m+=r,!f&&u!==void 0&&(f=!0,Es(u,e,t,n,d)),y=!0}if(y){o=0;return}}},cancel:async()=>{c&&=(await c.cancel().catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)}),void 0)}})}const Ms=()=>{let e=S(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,NaN,{integer:!0});return Number.isNaN(e)?void 0:e};function Ns(e,t,n,r,i,a,o){(async()=>{await Bo(`workflow.stream.flush`,e,{kind:await Wo(`CLIENT`),attributes:{"workflow.run.id":n,"workflow.stream.name":r,"workflow.stream.operation":`flush`,"workflow.stream.flush.buffer_dwell_ms":t-e,"workflow.stream.flush.chunks":i,"workflow.stream.flush.bytes":a,"workflow.stream.write.chunk_rtt":o}})})()}function Ps(e,t,n){(async()=>{await Bo(`workflow.stream.close`,e,{kind:await Wo(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`close`,"workflow.stream.close.rpc_ms":Date.now()-e}})})()}var Fs=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new c(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new c(`"name" is required, got "${t}"`);let r=jn(),i=n,a=async()=>{if(i){try{await i}catch{}i=void 0}},o=[],s=0,l=0,u=0,d=null,f=null,p,m=Ms(),h=null,g=hn(),_=gn(),v=mn(),y=_n(),b,ee=[],x=[],te=e=>{let t=[...ee,...x];ee=[],x=[];for(let n of t)n.reject(e)},ne=()=>{let e=0,t=0;for(let n of o){if(e>=g||e>0&&t+n.byteLength>_)break;e++,t+=n.byteLength}let n=o.slice(0,e);return o=o.slice(e),s-=t,{group:n,bytes:t}},re=async(n,i,o)=>{await a();let s=await r,c=Date.now();if(typeof s.streams.writeMulti==`function`&&n.length>1)await s.streams.writeMulti(e,t,n);else for(let r of n)await s.streams.write(e,t,r);o!==void 0&&Ns(o,c,e,t,n.length,i,Date.now()-c)},ie=async()=>{for(;o.length>0;){d&&=(clearTimeout(d),null);let e=b,t=Date.now(),{group:n,bytes:r}=ne();l=n.length,u=r,b=o.length>0?t:void 0;try{await re(n,r,e),l=0,u=0}catch(t){throw o=n.concat(o),s+=r,l=0,u=0,b=e!==void 0&&b!==void 0?Math.min(e,b):e??b,t}let i=ee;ee=[];for(let e of i)e.resolve()}},S=()=>{f||p!==void 0||o.length===0||(f=ie().then(()=>{if(f=null,o.length>0){S();return}let e=x;x=[];for(let t of e)t.resolve()},e=>{f=null,p??=e,te(p)}))},C=()=>{if(!(d||f)){if(m===void 0){h??=Promise.resolve(r).then(e=>{m=e.streamFlushIntervalMs??0},()=>{m=0}).then(()=>{o.length>0&&C()});return}if(m<=0){S();return}d=setTimeout(()=>{d=null,S()},m)}},ae=async()=>{for(;;){if(p!==void 0)throw p;if(o.length===0&&!f)return;S(),await new Promise((e,t)=>{x.push({resolve:e,reject:t})})}};super({async write(e){if(p!==void 0)throw p;for(b===void 0&&(b=Date.now()),o.push(e),s+=e.byteLength,o.length>=g||s>=_?S():C();p===void 0&&(o.length+l>=v||s+u>=y);)S(),await new Promise((e,t)=>{ee.push({resolve:e,reject:t})});if(p!==void 0)throw p},async close(){await ae(),await a();let n=await r,i=Date.now();await n.streams.close(e,t),Ps(i,e,t)},async abort(e){try{await ae()}catch{}d&&=(clearTimeout(d),null),o=[],s=0,p??=e??Error(`Stream aborted`),te(p)}}),Object.defineProperty(this,cn,{value:ae,enumerable:!1,writable:!1})}};function Is(e=globalThis){return{...Zr(),...si(),...ai(e),Request:t=>{if(!V(t,Hs(e,`Request`)))return!1;let n={method:B(t,`method`),url:B(t,`url`),headers:B(t,`headers`),body:B(t,`body`),duplex:B(t,`duplex`)},r=B(t,un);r&&(n.responseWritable=r);let i=B(t,`signal`);return i&&(B(i,`aborted`)||B(i,P))&&(n.signal=i),n},Response:t=>V(t,Hs(e,`Response`))?{type:B(t,`type`),url:B(t,`url`),status:B(t,`status`),statusText:B(t,`statusText`),headers:B(t,`headers`),body:B(t,`body`),redirected:B(t,`redirected`)}:!1}}function Ls(e,t,n,r,i,a){let o=t[P],s=t[F];if(!o){let e=(n[nn]||_s)();o=us(e),s=`abrt_${e}`,t[P]=o,t[F]=s,t.signal&&(t.signal[P]=o,t.signal[F]=s)}return zs(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function Rs(e,t){let n=t[P]??t.signal?.[P],r=t[F]??t.signal?.[F];if(!n)throw Error(`AbortController/AbortSignal stream name is not set`);return{streamName:n,hookToken:r,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function zs(e,t,n,r,i){e.aborted||e[fn]||(e[fn]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await zi(r),a=await fc({aborted:!0,reason:e.reason},n,i),o=new Fs(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function Bs(e=globalThis,t,n,r,i=!1,a){return{...Is(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new g(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=`strm_${(e[nn]||_s)()}`,c=vs(o),l=new Fs(n,s,a);c===`bytes`?i?t.push(o.pipeThrough(ws()).pipeTo(l)):t.push(o.pipeTo(l)):t.push(o.pipeThrough(xs(Bs(e,t,n,r,i,a),r)).pipeTo(l));let u={name:s};return c&&(u.type=c),c===`bytes`&&i&&(u.framing=`framed-v1`),u},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[M],a=r[on];if(typeof i==`string`&&typeof a==`string`){let e={name:i,runId:a},t=r[N];typeof t==`string`&&(e.encryptionPublicKey=t);let n=r[sn];return typeof n==`string`&&(e.deploymentId=n),e}let o=`strm_${(e[nn]||_s)()}`,s=new Os(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ls(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ls(i,i,e,t,n,r)}}function Vs(e,t){return Hs(e,`${t}Stream`)}function Hs(e,t){let n=e[t]??globalThis[t]??void 0;return typeof n==`function`?n.prototype:void 0}function Us(e){let t=e.AbortController??globalThis.AbortController;return typeof t==`function`?t.prototype:void 0}function Ws(e){let t=e.AbortSignal??globalThis.AbortSignal;return typeof t==`function`?t.prototype:void 0}function Gs(e=globalThis){return{...Is(e),ReadableStream:t=>{if(!V(t,Vs(e,`Readable`)))return!1;let n=B(t,ln);if(n!==void 0)return{bodyInit:n};let r=B(t,M);if(!r)throw new c("ReadableStream `name` is not set");let i={name:r},a=B(t,rn);a&&(i.type=a);let o=B(t,an);return o&&(i.framing=o),i},WritableStream:t=>{if(!V(t,Vs(e,`Writable`)))return!1;let n=B(t,M);if(!n)throw new c("WritableStream `name` is not set");let r={name:n},i=B(t,on);typeof i==`string`&&(r.runId=i);let a=B(t,sn);typeof a==`string`&&(r.deploymentId=a);let o=B(t,N);return typeof o==`string`&&(r.encryptionPublicKey=o),r},AbortController:t=>{if(typeof t!=`object`||!t)return!1;let n=t,r=B(t,P),i=V(t,Us(e));if(r===void 0&&!i){let e=B(t,`signal`);if(typeof e!=`object`||!e||B(e,P)===void 0)return!1}let a=B(t,`signal`);return a?Rs(a,n):!1},AbortSignal:t=>{if(typeof t!=`object`||!t)return!1;let n=B(t,P)!==void 0,r=V(t,Ws(e));return!n&&!r?!1:Rs(t,t)}}}function Ks(e=globalThis,t,n,r,i=!1,a){return{...Is(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new g(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=o[M],c=o[rn],l=o[an];if(!s){s=`strm_${(e[nn]||_s)()}`,c=vs(o),l=c===`bytes`&&i?`framed-v1`:l;let u=new Fs(n,s,a);c===`bytes`?l===`framed-v1`?t.push(o.pipeThrough(ws()).pipeTo(u)):t.push(o.pipeTo(u)):t.push(o.pipeThrough(xs(Ks(e,t,n,r,i,a),r)).pipeTo(u))}let u={name:s};return c&&(u.type=c),l&&(u.framing=l),u},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[M],o=i[on];a||(a=`strm_${(e[nn]||_s)()}`,t.push(new Os(n,a).pipeThrough(Ss(rc(e,t,n,r),r)).pipeTo(i)));let s={name:a};typeof o==`string`&&(s.runId=o);let c=i[N];typeof c==`string`&&(s.encryptionPublicKey=c);let l=i[sn];return typeof l==`string`&&(s.deploymentId=l),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ls(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ls(i,i,e,t,n,r)}}function qs(...e){let t=new WeakSet;function n(e){let t=e[pn];t&&!t.signal.aborted&&t.abort()}function r(e){if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function Js(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new Os(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=ss.getStore(),r=await pc(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function Ys(e,t,n){let r=e,i=e.signal;r[P]=t.streamName,r[F]=t.hookToken,i[P]=t.streamName,i[F]=t.hookToken,n&&(r[pn]=n,i[pn]=n)}function Xs(e,t){let n=e,r=t;n[P]!==void 0&&(r[P]=n[P]),n[F]!==void 0&&(r[F]=n[F]),n[pn]!==void 0&&(r[pn]=n[pn])}function Zs(e,t,n){let r=new AbortController;e.aborted?(Ys(r,e),r.abort(e.reason)):e.streamName?Ys(r,e,Js(r,n,e.streamName,t)):Ys(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=ss.getStore();if(n&&(n.ops.push((async()=>{try{let r=await fc({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new Fs(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-bc-OQVI0.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function Qs(e,t,n){let r=new AbortController;return e.aborted?(Ys(r,e),r.abort(e.reason)):e.streamName?Ys(r,e,Js(r,n,e.streamName,t)):Ys(r,e),r.signal}function $s(e=globalThis){return{...Qr(e),...oi(e)}}async function ec(e,t,n){let r=Qn(n);if(r)return Ni(r);let i=await jn();if(!i.getEncryptionKeyForRun)return;let a=t?await i.getEncryptionKeyForRun(e,{deploymentId:t}):await i.getEncryptionKeyForRun(await i.runs.get(e));return a?await Jt(a,[`encrypt`]):void 0}function tc(e=globalThis,t,n,r){return{...$s(e),StepFunction:()=>{throw new g(`Step functions cannot be deserialized in client context. Step functions should not be returned from workflows.`,{hint:`A step function reference reached the client. Return a serializable value (e.g. the step result) instead of the step itself.`})},WorkflowFunction:e=>Object.assign(()=>{throw new g(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(n.signal=t.signal);let r=new e.Request(t.url,n);return t.signal&&Xs(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}if(i.type===`bytes`){let r=new Os(n,i.name,i.startIndex),a=yn();t.push(a.promise);let{readable:o,writable:s}=i.framing===`framed-v1`?Ts():new e.TransformStream;return Tn(r,s,a).catch(()=>{}),wn(o,a),o}else{let a=js(n,i.name,i.startIndex),o=Ss(tc(e,t,n,r),r),s=yn();return t.push(s.promise),Tn(a,o.writable,s).catch(()=>{}),wn(o.readable,s),o.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:ec(a,i.deploymentId,i.encryptionPublicKey),s=xs(Bs(e,t,a,o),o),c=new Fs(a,i.name),l=yn();return t.push(l.promise),Tn(s.readable,c,l).catch(()=>{}),Cn(s.writable,l),Object.defineProperty(s.writable,M,{value:i.name,writable:!1}),Object.defineProperty(s.writable,on,{value:a,writable:!1}),typeof i.deploymentId==`string`&&Object.defineProperty(s.writable,sn,{value:i.deploymentId,writable:!1}),typeof i.encryptionPublicKey==`string`&&Object.defineProperty(s.writable,N,{value:i.encryptionPublicKey,writable:!1}),s.writable},AbortController:e=>Zs(e,t,n),AbortSignal:e=>Qs(e,t,n)}}function nc(e=globalThis){return{...$s(e),...ci(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[un]=n,delete t.responseWritable,t.respondWith=()=>{throw new g("`respondWith()` must be called from within a step function.",{hint:'Move the `respondWith(...)` call inside a `"use step"` function — it cannot be invoked from a workflow context.'})}),t},WorkflowFunction:e=>Object.assign(()=>{throw new g(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Response:t=>(Object.setPrototypeOf(t,e.Response.prototype),t),ReadableStream:t=>`bodyInit`in t?Object.create(e.ReadableStream.prototype,{[ln]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[M]:{value:t.name,writable:!1},[rn]:{value:t.type,writable:!1},[an]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[M]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[on]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[sn]={value:t.deploymentId,writable:!1}),typeof t.encryptionPublicKey==`string`&&(n[N]={value:t.encryptionPublicKey,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new ms(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[P]:e.streamName,[F]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new ms(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function rc(e=globalThis,t,r,i,a){return{...$s(e),StepFunction:e=>{let t=e.stepId,r=e.closureVars,i=`boundThis`in e,a=i?e.boundThis:void 0,o=Array.isArray(e.boundArgs)?e.boundArgs:[],s=n(t);if(!s)throw new g(`Step function "${t}" not found. Make sure the step function is registered.`,{hint:`Make sure the step file is included in your build (i.e. it is listed in the workflow manifest), and that the SWC plugin is configured for the file.`});if(!r&&!i&&o.length===0)return s;let l=function(...e){let t=i?a:this,n=o.length>0?[...o,...e]:e;if(r){let e=ss.getStore();if(!e)throw new c(`Cannot call step function with closure variables outside step context`);let i={...e,closureVars:r};return ss.run(i,()=>s.apply(t,n))}return s.apply(t,n)};return Object.defineProperty(l,"name",{value:s.name}),Object.defineProperty(l,"stepId",{value:t,writable:!1,enumerable:!1,configurable:!1}),s.maxRetries!==void 0&&(l.maxRetries=s.maxRetries),l},WorkflowFunction:e=>Object.assign(()=>{throw new g(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n=t.responseWritable,r={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(r.signal=t.signal);let i=new e.Request(t.url,r);return t.signal&&Xs(t.signal,i.signal),n&&(i.respondWith=async e=>{let t=n.getWriter();await t.write(e),await t.close()}),i},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:n=>{if(`bodyInit`in n){let t=n.bodyInit;return new e.Response(t).body}let o=new Os(r,n.name);if(n.type===`bytes`){let r=yn();t.push(r.promise);let{readable:i,writable:a}=n.framing===`framed-v1`?Ts():new e.TransformStream;return Tn(o,a,r).catch(()=>{}),wn(i,r),i}else{let n=Ss(rc(e,t,r,i,a),i),s=yn();return t.push(s.promise),Tn(o,n.writable,s).catch(()=>{}),wn(n.readable,s),n.readable}},WritableStream:n=>{let o=typeof n.runId==`string`?n.runId:r,s=typeof n.deploymentId==`string`?n.deploymentId:o===r?a:void 0,c=o===r?i:ec(o,s,n.encryptionPublicKey),l=xs(Ks(e,t,o,c),c),u=new Fs(o,n.name),d=yn();return t.push(d.promise),Tn(l.readable,u,d).catch(()=>{}),Cn(l.writable,d),Object.defineProperty(l.writable,M,{value:n.name,writable:!1}),Object.defineProperty(l.writable,on,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,sn,{value:s,writable:!1}),typeof n.encryptionPublicKey!=`string`&&o===r&&Li(i)&&Object.defineProperty(l.writable,N,{value:Vn(i.keyPair.publicKey),writable:!1}),typeof n.encryptionPublicKey==`string`&&Object.defineProperty(l.writable,N,{value:n.encryptionPublicKey,writable:!1}),l.writable},AbortController:e=>Zs(e,t,r),AbortSignal:e=>Qs(e,t,r)}}async function ic(e,t){return await Bi(e,t)}const ac=async(e,t)=>{let n={},r=await Ai(await Hi(e,t),n);return await $(n,`deserialize`),{data:r}};function oc(e,t=globalThis,n={}){return as(e.data,{global:t,extraRevivers:{...Sc(nc(t)),...n}})}function sc(e,t=globalThis,n={}){let{data:r}=e;if(!(r instanceof Uint8Array))return Ut(r,{...nc(t),...n});let{format:i,payload:a}=q(r);if(i===W.DEVALUE_V1)return Ht(new TextDecoder().decode(a),{...nc(t),...n});throw Error(`Unsupported serialization format: ${i}`)}async function cc(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1){if(a)return ei(Wt(e,Bs(i,r,t,n,o)));try{let a={},c=await ts(e,n,{global:i,extraReducers:xc(Bs(i,r,t,n,o)),compression:s,compressionStats:a});return await $(a,`serialize`),c}catch(e){let t=ys(e),{message:n,hint:r}=Z(`workflow arguments`,t);throw new g(n,{hint:r,cause:t})}}async function lc(e,t,n,r=globalThis,i={},a){return oc(a??await ac(e,n),r,i)}async function uc(e,t,n,r=globalThis,i=!1,a=!1,o){if(i)return ei(Wt(e,Gs(r)));try{let t={},i=o??{executions:[]},s=await rs(e,n,{global:r,extraReducers:xc(Gs(r)),compression:a,compressionStats:t,guestCodeStats:i});return await $(t,`serialize`),await bs(i),s}catch(e){let t=ys(e),{message:n,hint:r}=Z(`workflow return value`,t);throw new g(n,{hint:r,cause:t})}}async function dc(e,t,n,r=[],i=globalThis,a={}){let o={},s=await ns(e,n,{global:i,extraRevivers:{...Sc(tc(i,r,t,n)),...a},compressionStats:o});return await $(o,`deserialize`),s}async function fc(e,t,n,r=globalThis,i=!1,a=!1,o){if(i)return ei(Wt(e,Gs(r)));try{let t={},i=o??{executions:[]},s=await rs(e,n,{global:r,extraReducers:xc(Gs(r)),compression:a,compressionStats:t,guestCodeStats:i});return await $(t,`serialize`),await bs(i),s}catch(e){let t=ys(e),{message:n,hint:r}=Z(`step arguments`,t);throw new g(n,{hint:r,cause:t})}}async function pc(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await is(e,n,{global:i,extraRevivers:{...Sc(rc(i,r,t,n,o)),...a},compressionStats:s});return await $(s,`deserialize`),c}async function mc(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c){if(a)return ei(Wt(e,Ks(i,r,t,n,o,c)));try{let a={},l=await rs(e,n,{global:i,extraReducers:xc(Ks(i,r,t,n,o,c)),compression:s,compressionStats:a});return await $(a,`serialize`),l}catch(e){let t=ys(e),{message:n,hint:r}=Z(`step return value`,t);throw new g(n,{hint:r,cause:t})}}async function hc(e,t,n,r=[],i=globalThis,a=!1){try{let o=Wt(e,Ks(i,r,t,n)),s=new TextEncoder().encode(o),c=K(W.DEVALUE_V1,s),l={},u=await ic(await ki(c,a,l),n);return await $(l,`serialize`),u}catch(e){let t=ys(e),{message:n,hint:r}=Z(`step error`,t);throw new g(n,{hint:r,cause:t})}}async function gc(e,t,n,r=globalThis,i={},a){return sc(a??await ac(e,n),r,i)}async function _c(e,t,n,r=globalThis,i=!1){try{let t=Wt(e,Gs(r)),a=new TextEncoder().encode(t),o=K(W.DEVALUE_V1,a),s={},c=await ic(await ki(o,i,s),n);return await $(s,`serialize`),c}catch(e){let t=ys(e),{message:n,hint:r}=Z(`run error`,t);throw new g(n,{hint:r,cause:t})}}async function vc(e,t,n,r=[],i=globalThis,a={}){let o={},s=await Ai(await Hi(e,n),o);if(await $(o,`deserialize`),!(s instanceof Uint8Array))return Ut(s,{...tc(i,r,t,n),...a});let{format:c,payload:l}=q(s);if(c===W.DEVALUE_V1)return Ht(new TextDecoder().decode(l),{...tc(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${c}`)}async function yc(e,t,n,r=globalThis,i={},a){return oc(a??await ac(e,n),r,i)}const bc=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function xc(e){let t={};for(let n of bc)n in e&&(t[n]=e[n]);return t}function Sc(e){let t={};for(let n of bc)n in e&&(t[n]=e[n]);return t}const Cc=[{format:W.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:W.GZIP,minVersion:`5.0.0-beta.18`},{format:W.ZSTD,minVersion:`5.0.0-beta.18`},{format:W.SEALED,minVersion:`5.0.0-beta.37`}],wc=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],Tc=new Set([W.DEVALUE_V1]);function Ec(e){if(!e||!qt.default.valid(e))return{supportedFormats:Tc,framedByteStreams:!1};let t=new Set(Tc);for(let{format:n,minVersion:r}of Cc)qt.default.gte(e,r)&&t.add(n);let n={supportedFormats:t,framedByteStreams:!1};for(let{capability:t,minVersion:r}of wc)qt.default.gte(e,r)&&(n[t]=!0);return n}const Dc=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,l.WORLD_CONTRACT_ERROR]),Oc=new Set([`TRANSPORT`,`TIMEOUT`]),kc=[c.is,p.is,ee.is,_.is];function Ac(e){if(!s.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&Dc.has(e.code)||e.message.startsWith(`Failed to parse response body for `)||e.message.startsWith(`Schema validation failed for `)||typeof t==`object`&&!!t&&`name`in t&&t.name===`ZodError`}function jc(e){return f.is(e)?!0:s.is(e)?e.status!==void 0&&e.status>=500||e.code!==void 0&&Oc.has(e.code):!1}function Mc(e){if(h.is(e))return l.REPLAY_DIVERGENCE;if(y.is(e))return l.CORRUPTED_EVENT_LOG;if(v.is(e))return l.MAX_EVENTS_EXCEEDED;if(Ac(e)||jc(e))return l.WORLD_CONTRACT_ERROR;for(let t of kc)if(t(e))return l.RUNTIME_ERROR;return l.USER_ERROR}const Nc=`5.0.0-beta.39`,Pc=/^[a-zA-Z0-9_\-./@]+$/;function Fc(e,t){if(!Pc.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${x(`workflow`,ie(t))}${e}`}const Ic=re();function Lc(e){return`__health_check__${e}`}function Rc(e){let t=te.safeParse(e);if(t.success)return t.data}function zc(e){return`wrun_hc_${e}`}async function Bc(e,t){let n=await jn(),r=Lc(e.correlationId),i;if(e.runId)try{let t=await n.getEncryptionKeyForRun?.(e.runId);t&&(i=Vn((await In(t)).publicKey))}catch(t){X.warn(`Health check could not derive a run public key; the caller will fall back to a key lookup`,{correlationId:e.correlationId,error:t instanceof Error?t.message:String(t)})}let a=JSON.stringify({healthy:!0,correlationId:e.correlationId,specVersion:t??5,workflowCoreVersion:Nc,hookResumeInputVersion:1,...i?{encryptionPublicKey:i}:{},timestamp:Date.now()}),o=zc(e.correlationId);await n.streams.write(o,r,a),await n.streams.close(o,r)}function Vc(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function Hc(e,t){let n=[],r=!1,i=!1;for(;!r&&!i;){let a=e.read(),o=new Promise(e=>setTimeout(()=>{i=!0,e({done:!0,value:void 0})},t)),s=await Promise.race([a,o]);r=s.done,s.value&&n.push(s.value)}return{chunks:n,timedOut:i}}function Uc(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),typeof o.encryptionPublicKey==`string`&&(s.encryptionPublicKey=o.encryptionPublicKey),typeof o.hookResumeInputVersion==`number`&&(s.hookResumeInputVersion=o.hookResumeInputVersion),s}async function Wc(e,t){let n=t?.timeout??3e4,r=e.createRunId?.()??Ic(),i=Lc(r),a=`${x(`workflow`,ie(t?.namespace))}health_check`,o=Date.now();try{for(await e.queue(a,{__healthCheck:!0,correlationId:r,...t?.runId?{runId:t.runId}:{}},{specVersion:1,deploymentId:t?.deploymentId});Date.now()-o<n;)try{let t=n-(Date.now()-o),a=(await Vc(e.streams.get(zc(r),i),t)).getReader(),{chunks:s,timedOut:c}=await Hc(a,500);if(c){try{a.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=Uc(s);if(l)return{...l,latencyMs:Date.now()-o};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${n}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}function Gc(e,t){return new s(`Event pagination ${t} for workflow run "${e}".`,{code:l.WORLD_CONTRACT_ERROR})}function Kc(e,t,n){if(t){if(n.has(t))throw Gc(e,`did not advance`);n.add(t)}}function qc(e,t,n){if(t.length===0)return;let r=n??new Set(e.map(e=>e.eventId));for(let n of t)r.has(n.eventId)||(r.add(n.eventId),e.push(n))}function Jc(e,t){let n=e.length;for(;n>0;){let r=e[n-1];if(r.eventId===t.eventId)return;if(r.eventId<t.eventId)break;n--}e.splice(n,0,t)}function Yc(e,t,n,r){if(t){if(n===null)throw Gc(e,`returned more pages without a cursor`);if(r.has(n))throw Gc(e,`repeated a cursor`)}}function Xc(e,t,n){return t!==null&&!n&&s.is(e)&&e.status===400}async function Zc(e,t){let n=t!==void 0;return zo(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...ta(e)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await jn(),f=Date.now();for(;c;){let t=Date.now(),r=s;Kc(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(Xc(t,r,u)){X.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,u=!0;continue}throw t}qc(i,f.data,a),c=f.hasMore,Yc(e,c,f.cursor,o),s=f.cursor??s,l++,X.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return X.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...ia(i.length),...lo(l)}),{events:i,cursor:s}})}function Qc(){return process.env.WORKFLOW_PRECONDITION_GUARD!==`0`}function $c(e){let t;for(let n of e)(t===void 0||n.eventId>t)&&(t=n.eventId);if(t===void 0)return;let n=t,r=n.lastIndexOf(`_`),i=ne(r===-1?n:n.slice(r+1))?.getTime();if(i===void 0){X.debug(`Precondition guard: latest event id is not a decodable ULID; sending no snapshot`,{eventId:n});return}return i}function el(e,t){if(!Qc())return{};let n=$c(e);return n===void 0?{}:{stateUpdatedAt:n,stateEventCount:e.length,...t?{stateCursor:t}:{}}}function tl(e,t){if(!d.is(e))return null;let n=e.details;if(typeof n!=`object`||!n)return null;let{events:r,cursor:i}=n;if(!Array.isArray(r)||r.length===0)return null;for(let e of r)if(typeof e!=`object`||!e||typeof e.eventId!=`string`||e.runId!==t)return null;return{events:r,cursor:typeof i==`string`?i:null}}const nl={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function rl(e,t){return async n=>{let r=new URL(n.url);return r.searchParams.has(`__health`)?n.method===`OPTIONS`?new Response(null,{status:204,headers:nl}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??5,workflowCoreVersion:Nc}),{status:200,headers:{"Content-Type":`application/json`,...nl}}):await e(n)}}async function il(e,...t){let n=t[0];await zo(`queue.publish`,{attributes:{...Wa(`vercel-queue`),...Ga(n),...qa(`publish`),...So(`vercel-queue`),...Co(`vercel-queue`),...wo(`vqs`),...To(`publish`)},kind:await Wo(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(Ka(r))})}function al(e){if(e.requestedAt)try{return Ja(Date.now()-e.requestedAt.getTime())}catch{return}}function ol(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await Fi(n):void 0})(),n)}function sl(t){import(`./functions-CiVUVDNB.js`).then(t=>e(t.default,1)).then(({waitUntil:e})=>{e(t)})}function cl(e,t){sl(e.catch(e=>{if(!(e?.name===`AbortError`||e?.name===`ResponseAborted`))try{t(e)}catch{}}))}async function ll(e){let t=e();return sl(t.catch(()=>{})),t}export{Wo as $,Ce as $n,ma as $t,Bs as A,Qn as An,Ra as At,gs as B,sn as Bn,Ua as Bt,qs as C,Jr as Cn,Wa as Ct,mc as D,Gr as Dn,Ia as Dt,hc as E,Kr as En,po as Et,gc as F,Tn as Fn,Oa as Ft,ds as G,tn as Gn,Aa as Gt,Q as H,on as Hn,Fa as Ht,yc as I,Cn as In,wa as It,X as J,Zt as Jn,_a as Jt,ls as K,Qt as Kn,ka as Kt,lc as L,ln as Ln,La as Lt,xs as M,jn as Mn,Ma as Mt,vc as N,Dn as Nn,Ta as Nt,cc as O,rr as On,Ea as Ot,pc as P,yn as Pn,Na as Pt,jo as Q,ve as Qn,ia as Qt,dc as R,nn as Rn,Va as Rt,Fs as S,W as Sn,qa as St,fc as T,Xr as Tn,fo as Tt,ps as U,un as Un,Pa as Ut,hs as V,N as Vn,ja as Vt,cs as W,$t as Wn,Da as Wt,Qo as X,ye as Xn,da as Xt,Zo as Y,Jt as Yn,fa as Yt,Mo as Z,D as Zn,ua as Zt,Nc as _,Qi as _n,ao as _t,Fc as a,ya as an,Fo as at,Ac as b,Li as bn,Ga as bt,Jc as c,va as cn,Do as ct,ol as d,ra as dn,Ca as dt,$i as en,w as er,ko as et,Rc as f,pa as fn,Qa as ft,rl as g,ha as gn,Xa as gt,il as h,la as hn,eo as ht,al as i,xa as in,zo as it,tc as j,In as jn,Ba as jt,uc as k,Vn as kn,za as kt,Qc as l,ta as ln,Eo as lt,el as m,sa as mn,$a as mt,ll as n,ga as nn,fe as nr,qo as nt,Bc as o,ba as on,Jo as ot,tl as p,ca as pn,Za as pt,ss as q,en as qn,aa as qt,qc as r,oa as rn,de as rr,No as rt,Wc as s,Sa as sn,Ya as st,cl as t,ea as tn,se as tr,Ao as tt,Zc as u,na as un,co as ut,Mc as v,Zi as vn,so as vt,_c as w,Yr as wn,uo as wt,Ec as x,Ni as xn,Ka as xt,jc as y,Fi as yn,oo as yt,ac as z,M as zn,Ha as zt};
@@ -16,8 +16,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
16
16
  readonly dropped: {};
17
17
  };
18
18
  readonly dynamicTool: {
19
- readonly current: 6;
20
- readonly supported: readonly [1, 2, 3, 4, 5, 6];
19
+ readonly current: 7;
20
+ readonly supported: readonly [1, 2, 3, 4, 5, 6, 7];
21
21
  readonly dropped: {};
22
22
  };
23
23
  readonly connection: {
@@ -26,8 +26,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
26
26
  readonly dropped: {};
27
27
  };
28
28
  readonly hook: {
29
- readonly current: 4;
30
- readonly supported: readonly [1, 2, 3, 4];
29
+ readonly current: 5;
30
+ readonly supported: readonly [1, 2, 3, 4, 5];
31
31
  readonly dropped: {};
32
32
  };
33
33
  readonly skill: {
@@ -36,8 +36,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
36
36
  readonly dropped: {};
37
37
  };
38
38
  readonly dynamicSkill: {
39
- readonly current: 3;
40
- readonly supported: readonly [1, 2, 3];
39
+ readonly current: 4;
40
+ readonly supported: readonly [1, 2, 3, 4];
41
41
  readonly dropped: {};
42
42
  };
43
43
  readonly instructions: {
@@ -46,8 +46,8 @@ declare const EXTENSION_CAPABILITY_CONTRACTS: {
46
46
  readonly dropped: {};
47
47
  };
48
48
  readonly dynamicInstructions: {
49
- readonly current: 3;
50
- readonly supported: readonly [1, 2, 3];
49
+ readonly current: 4;
50
+ readonly supported: readonly [1, 2, 3, 4];
51
51
  readonly dropped: {};
52
52
  };
53
53
  readonly config: {
@@ -1 +1 @@
1
- import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=1,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:3,supported:[1,2,3],dropped:{}},dynamicTool:{current:6,supported:[1,2,3,4,5,6],dropped:{}},connection:{current:2,supported:[1,2],dropped:{}},hook:{current:4,supported:[1,2,3,4],dropped:{}},skill:{current:1,supported:[1],dropped:{}},dynamicSkill:{current:3,supported:[1,2,3],dropped:{}},instructions:{current:1,supported:[1],dropped:{}},dynamicInstructions:{current:3,supported:[1,2,3],dropped:{}},config:{current:1,supported:[1],dropped:{}},state:{current:2,supported:[1,2],dropped:{}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestSchema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict();function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(t){return parseExtensionCompatibilityManifest(await readFile(t,`utf8`),t)}async function writeExtensionCompatibilityManifest(e,n){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(n),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
1
+ import{readFile,writeFile}from"node:fs/promises";import{z}from"#compiled/zod/index.js";import{join}from"node:path";import{formatValidationError}from"#runtime/validation.js";const EXTENSION_COMPATIBILITY_MANIFEST_KIND=`eve-extension`,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION=1,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME=`_manifest.json`,EXTENSION_CAPABILITY_CONTRACTS={extension:{current:1,supported:[1],dropped:{}},tool:{current:3,supported:[1,2,3],dropped:{}},dynamicTool:{current:7,supported:[1,2,3,4,5,6,7],dropped:{}},connection:{current:2,supported:[1,2],dropped:{}},hook:{current:5,supported:[1,2,3,4,5],dropped:{}},skill:{current:1,supported:[1],dropped:{}},dynamicSkill:{current:4,supported:[1,2,3,4],dropped:{}},instructions:{current:1,supported:[1],dropped:{}},dynamicInstructions:{current:4,supported:[1,2,3,4],dropped:{}},config:{current:1,supported:[1],dropped:{}},state:{current:2,supported:[1,2],dropped:{}}},EXTENSION_CAPABILITY_VERSIONS=Object.fromEntries(Object.entries(EXTENSION_CAPABILITY_CONTRACTS).map(([e,t])=>[e,t.current])),EXTENSION_CAPABILITY_SUPPORT=Object.keys(EXTENSION_CAPABILITY_CONTRACTS).reduce((e,t)=>(e[t]=EXTENSION_CAPABILITY_CONTRACTS[t].supported,e),{}),extensionCompatibilityManifestSchema=z.object({kind:z.literal(EXTENSION_COMPATIBILITY_MANIFEST_KIND),formatVersion:z.literal(1),builtWithEve:z.string().min(1),requires:z.record(z.string(),z.number().int().positive())}).strict();function serializeExtensionCompatibilityManifest(e){return`${JSON.stringify(e,null,2)}\n`}function parseExtensionCompatibilityManifest(e,t){let n;try{n=JSON.parse(e)}catch(e){throw Error(`Extension compatibility manifest "${t}" is not valid JSON: ${e instanceof Error?e.message:String(e)}`)}let r=extensionCompatibilityManifestSchema.safeParse(n);if(!r.success)throw Error(`Extension compatibility manifest "${t}" is invalid. ${formatValidationError(r.error)}`);return r.data}async function readExtensionCompatibilityManifest(t){return parseExtensionCompatibilityManifest(await readFile(t,`utf8`),t)}async function writeExtensionCompatibilityManifest(e,n){await writeFile(join(e,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME),serializeExtensionCompatibilityManifest(n),`utf8`)}function findUnsupportedExtensionCapabilities(e,t=EXTENSION_CAPABILITY_SUPPORT){return Object.entries(e.requires).flatMap(([e,n])=>{let r=Object.hasOwn(t,e)?t[e]??[]:[];return r.includes(n)?[]:[{capability:e,requiredVersion:n,supportedVersions:r}]}).sort((e,t)=>e.capability.localeCompare(t.capability))}export{EXTENSION_CAPABILITY_SUPPORT,EXTENSION_CAPABILITY_VERSIONS,EXTENSION_COMPATIBILITY_MANIFEST_FILENAME,EXTENSION_COMPATIBILITY_MANIFEST_FORMAT_VERSION,EXTENSION_COMPATIBILITY_MANIFEST_KIND,findUnsupportedExtensionCapabilities,parseExtensionCompatibilityManifest,readExtensionCompatibilityManifest,serializeExtensionCompatibilityManifest,writeExtensionCompatibilityManifest};
@@ -1,6 +1,6 @@
1
1
  import { z } from "#compiled/zod/index.js";
2
2
  import { type DiscoverDiagnosticsSummary } from "#discover/diagnostics.js";
3
- import { type CompiledRemoteAgentNode } from "#compiler/remote-agent-node.js";
3
+ import { type CompiledDynamicSubagentDefinition, type CompiledRemoteAgentNode } from "#compiler/remote-agent-node.js";
4
4
  import type { ChannelRouteMethod } from "#public/definitions/channel.js";
5
5
  import type { NormalizedChannelCorsOptions } from "#channel/cors.js";
6
6
  import type { InternalInstructionsDefinition } from "#shared/instructions-definition.js";
@@ -20,7 +20,7 @@ export declare const ROOT_COMPILED_AGENT_NODE_ID = "__root__";
20
20
  /**
21
21
  * Current compiled manifest schema version.
22
22
  */
23
- export declare const COMPILED_AGENT_MANIFEST_VERSION = 37;
23
+ export declare const COMPILED_AGENT_MANIFEST_VERSION = 38;
24
24
  /**
25
25
  * Compiled channel entry preserved in the compiled manifest.
26
26
  */
@@ -197,17 +197,18 @@ export interface CompiledHookDefinition extends ModuleSourceRef {
197
197
  * every flattened subagent node.
198
198
  */
199
199
  export type CompiledAgentNodeManifest = z.infer<typeof compiledAgentNodeManifestSchema>;
200
- /**
201
- * Flattened compiled subagent node emitted by the compiler. `name` and
202
- * `description` are copied from `agent.config` for fast registry lookup.
203
- */
204
200
  export type CompiledSubagentNode = Readonly<ModuleSourceRef & Node & {
205
201
  agent: CompiledAgentNodeManifest;
206
- description: string;
207
202
  entryPath: string;
208
203
  name: string;
209
204
  rootPath: string;
210
- }>;
205
+ } & ({
206
+ description: string;
207
+ dynamic?: never;
208
+ } | {
209
+ description?: never;
210
+ dynamic: CompiledDynamicSubagentDefinition;
211
+ })>;
211
212
  export type { CompiledRemoteAgentNode } from "#compiler/remote-agent-node.js";
212
213
  /**
213
214
  * Parent-child edge connecting two compiled agent nodes.
@@ -464,19 +465,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
464
465
  }, z.core.$strict>>;
465
466
  skills: z.ZodReadonly<z.ZodArray<z.ZodType<CompiledSkillDefinition, unknown, z.core.$ZodTypeInternals<CompiledSkillDefinition, unknown>>>>;
466
467
  subagentEdges: z.ZodArray<z.ZodType<CompiledSubagentEdge, unknown, z.core.$ZodTypeInternals<CompiledSubagentEdge, unknown>>>;
467
- subagents: z.ZodArray<z.ZodType<Readonly<ModuleSourceRef & Node & {
468
- agent: CompiledAgentNodeManifest;
469
- description: string;
470
- entryPath: string;
471
- name: string;
472
- rootPath: string;
473
- }>, unknown, z.core.$ZodTypeInternals<Readonly<ModuleSourceRef & Node & {
474
- agent: CompiledAgentNodeManifest;
475
- description: string;
476
- entryPath: string;
477
- name: string;
478
- rootPath: string;
479
- }>, unknown>>>;
468
+ subagents: z.ZodArray<z.ZodType<CompiledSubagentNode, unknown, z.core.$ZodTypeInternals<CompiledSubagentNode, unknown>>>;
480
469
  instructions: z.ZodOptional<z.ZodType<CompiledInstructionsDefinition, unknown, z.core.$ZodTypeInternals<CompiledInstructionsDefinition, unknown>>>;
481
470
  tools: z.ZodArray<z.ZodObject<{
482
471
  description: z.ZodString;
@@ -488,7 +477,7 @@ export declare const compiledAgentManifestSchema: z.ZodObject<{
488
477
  sourceId: z.ZodString;
489
478
  sourceKind: z.ZodLiteral<"module">;
490
479
  }, z.core.$strict>>;
491
- version: z.ZodLiteral<37>;
480
+ version: z.ZodLiteral<38>;
492
481
  workspaceResourceRoot: z.ZodObject<{
493
482
  contentHash: z.ZodOptional<z.ZodString>;
494
483
  logicalPath: z.ZodString;
@@ -1 +1 @@
1
- import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=37,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),compiledDynamicModelDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),sessionTimeoutSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional(),sessionTimeoutMs:sessionTimeoutSchema.optional()}).strict(),compiledWorkflowToolDefinitionSchema=z.object({maxSubagents:z.number().int().positive().optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),dynamicModel:compiledDynamicModelDefinitionSchema.optional(),experimental:z.object({workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledAgentNodeManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),compiledSubagentNodeSchema=z.object({agent:compiledAgentNodeManifestSchema,description:z.string(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledExtensionMountSchema=z.object({namespace:z.string(),packageName:z.string(),packageNamespace:z.string(),sourceRoot:z.string(),mountSourceId:z.string(),mountLogicalPath:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),extensionMounts:z.array(compiledExtensionMountSchema).default([]),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(37),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,dynamicModel:e.config.dynamicModel===void 0?void 0:{...e.config.dynamicModel},experimental:e.config.experimental===void 0?void 0:{workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,sessionTimeoutMs:e.config.limits.sessionTimeoutMs},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowTool:e.workflowTool===void 0?void 0:{maxSubagents:e.workflowTool.maxSubagents},dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,extensionMounts:[...e.extensionMounts??[]],subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:37}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
1
+ import{z}from"#compiled/zod/index.js";import{discoverDiagnosticsSummarySchema}from"#discover/diagnostics.js";import{compiledRemoteAgentNodeSchema}from"#compiler/remote-agent-node.js";import{jsonObjectSchema}from"#shared/json-schemas.js";const COMPILED_AGENT_MANIFEST_KIND=`eve-agent-compiled-manifest`,ROOT_COMPILED_AGENT_NODE_ID=`__root__`,COMPILED_AGENT_MANIFEST_VERSION=38,moduleSourceRefSchema=z.object({exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),compiledDynamicModelDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),sourceKind:z.literal(`module`),logicalPath:z.string(),sourceId:z.string()}).strict(),channelMethodSchema=z.union([z.literal(`GET`),z.literal(`POST`),z.literal(`PUT`),z.literal(`PATCH`),z.literal(`DELETE`),z.literal(`WEBSOCKET`)]),compiledChannelCorsSchema=z.object({origin:z.union([z.literal(`*`),z.literal(`null`),z.array(z.string())]).optional(),methods:z.union([z.literal(`*`),z.array(z.string())]).optional(),allowHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),exposeHeaders:z.union([z.literal(`*`),z.array(z.string())]).optional(),credentials:z.boolean().optional(),maxAge:z.union([z.string(),z.literal(!1)]).optional(),preflight:z.object({statusCode:z.number().int().min(100).max(599).optional()}).strict().optional()}).strict(),compiledChannelDefinitionSchema=z.object({kind:z.literal(`channel`),name:z.string(),logicalPath:z.string(),method:channelMethodSchema,urlPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional(),adapterKind:z.string().optional(),cors:compiledChannelCorsSchema.optional()}).strict(),disabledCompiledChannelEntrySchema=z.object({kind:z.literal(`disabled`),name:z.string(),logicalPath:z.string()}).strict(),compiledChannelEntrySchema=z.union([compiledChannelDefinitionSchema,disabledCompiledChannelEntrySchema]),modelRoutingSchema=z.union([z.object({kind:z.literal(`gateway`),target:z.string(),byok:z.string().optional()}).strict(),z.object({kind:z.literal(`external`),provider:z.string()}).strict()]),compiledRuntimeModelReferenceSchema=z.object({contextWindowTokens:z.number().int().positive().optional(),id:z.string(),source:moduleSourceRefSchema.optional(),providerOptions:z.record(z.string(),jsonObjectSchema).optional(),routing:modelRoutingSchema}).strict(),compiledAgentBuildDefinitionSchema=z.object({externalDependencies:z.array(z.string()).optional()}).strict(),compiledAgentWorkflowWorldDefinitionSchema=z.string(),compiledAgentWorkflowDefinitionSchema=z.object({world:compiledAgentWorkflowWorldDefinitionSchema.optional()}).strict(),compiledAgentCompactionDefinitionSchema=z.object({model:compiledRuntimeModelReferenceSchema.optional(),thresholdPercent:z.number().finite().min(0).max(1).optional()}).strict(),sessionTokenLimitSchema=z.union([z.number().int().positive(),z.literal(!1)]),sessionTimeoutSchema=z.union([z.number().int().positive(),z.literal(!1)]),compiledAgentLimitsDefinitionSchema=z.object({maxInputTokensPerSession:sessionTokenLimitSchema.optional(),maxOutputTokensPerSession:sessionTokenLimitSchema.optional(),sessionTimeoutMs:sessionTimeoutSchema.optional()}).strict(),compiledWorkflowToolDefinitionSchema=z.object({maxSubagents:z.number().int().positive().optional()}).strict(),compiledAgentConfigSchema=z.object({build:compiledAgentBuildDefinitionSchema.optional(),compaction:compiledAgentCompactionDefinitionSchema.optional(),description:z.string().optional(),dynamicModel:compiledDynamicModelDefinitionSchema.optional(),experimental:z.object({subagentPersistentSessions:z.boolean().optional(),workflow:compiledAgentWorkflowDefinitionSchema.optional()}).strict().optional(),model:compiledRuntimeModelReferenceSchema,name:z.string(),outputSchema:jsonObjectSchema.optional(),reasoning:z.enum([`provider-default`,`none`,`minimal`,`low`,`medium`,`high`,`xhigh`]).optional(),source:moduleSourceRefSchema.optional(),limits:compiledAgentLimitsDefinitionSchema.optional()}).strict(),compiledInstructionsSchema=z.object({name:z.string(),logicalPath:z.string(),markdown:z.string(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSkillBaseFields={name:z.string(),description:z.string(),license:z.string().optional(),markdown:z.string(),metadata:z.record(z.string(),z.string()).optional(),sourceId:z.string(),logicalPath:z.string()},compiledSkillSourceSchema=z.discriminatedUnion(`sourceKind`,[z.object({...compiledSkillBaseFields,sourceKind:z.literal(`markdown`)}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`module`),exportName:z.string().optional()}).strict(),z.object({...compiledSkillBaseFields,sourceKind:z.literal(`skill-package`),skillId:z.string(),skillFilePath:z.string(),rootPath:z.string(),assetsPath:z.string().optional(),referencesPath:z.string().optional(),scriptsPath:z.string().optional()}).strict()]),compiledScheduleDefinitionSchema=z.object({cron:z.string(),hasRun:z.boolean(),name:z.string(),logicalPath:z.string(),markdown:z.string().optional(),sourceId:z.string(),sourceKind:z.union([z.literal(`markdown`),z.literal(`module`)])}).strict(),compiledSandboxDefinitionSchema=z.object({backendName:z.string().optional(),description:z.string().optional(),exportName:z.string().optional(),logicalPath:z.string(),revalidationKey:z.string().optional(),sourceHash:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSandboxWorkspaceSchema=z.object({logicalPath:z.string(),rootEntries:z.array(z.string()).readonly(),sourceId:z.string(),sourcePath:z.string()}).strict(),compiledWorkspaceResourceRootSchema=z.object({contentHash:z.string().optional(),logicalPath:z.string(),rootEntries:z.array(z.string()).readonly()}).strict(),compiledConnectionDefinitionSchema=z.object({connectionName:z.string(),description:z.string(),exportName:z.string().optional(),logicalPath:z.string(),protocol:z.enum([`mcp`,`openapi`]).default(`mcp`),sourceId:z.string(),sourceKind:z.literal(`module`),url:z.string(),vercelConnect:z.object({connector:z.string()}).strict().optional()}).strict(),compiledToolDefinitionSchema=z.object({description:z.string(),exportName:z.string().optional(),inputSchema:jsonObjectSchema.nullable(),logicalPath:z.string(),name:z.string(),outputSchema:jsonObjectSchema.optional(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicToolDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicSkillDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),extensionNamespace:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledDynamicInstructionsDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly(),exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledHookDefinitionSchema=z.object({exportName:z.string().optional(),logicalPath:z.string(),slug:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`)}).strict(),compiledSubagentNodeBaseFields={agent:z.object({agentRoot:z.string(),appRoot:z.string(),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),remoteAgents:z.array(compiledRemoteAgentNodeSchema),skills:z.array(compiledSkillSourceSchema).readonly(),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict(),entryPath:z.string(),logicalPath:z.string(),name:z.string(),nodeId:z.string(),rootPath:z.string(),sourceId:z.string(),sourceKind:z.literal(`module`),exportName:z.string().optional()},compiledDynamicSubagentDefinitionSchema=z.object({eventNames:z.array(z.string()).readonly()}).strict(),compiledSubagentNodeSchema=z.union([z.object({...compiledSubagentNodeBaseFields,description:z.string()}).strict(),z.object({...compiledSubagentNodeBaseFields,dynamic:compiledDynamicSubagentDefinitionSchema}).strict()]),compiledSubagentEdgeSchema=z.object({childNodeId:z.string(),parentNodeId:z.string()}).strict(),compiledExtensionMountSchema=z.object({namespace:z.string(),packageName:z.string(),packageNamespace:z.string(),sourceRoot:z.string(),mountSourceId:z.string(),mountLogicalPath:z.string()}).strict(),compiledAgentManifestSchema=z.object({agentRoot:z.string(),appRoot:z.string(),extensionMounts:z.array(compiledExtensionMountSchema).default([]),channels:z.array(compiledChannelEntrySchema),config:compiledAgentConfigSchema,connections:z.array(compiledConnectionDefinitionSchema),diagnosticsSummary:discoverDiagnosticsSummarySchema,disabledFrameworkTools:z.array(z.string()).readonly(),workflowTool:compiledWorkflowToolDefinitionSchema.optional(),dynamicInstructions:z.array(compiledDynamicInstructionsDefinitionSchema).default([]),dynamicSkills:z.array(compiledDynamicSkillDefinitionSchema).default([]),dynamicTools:z.array(compiledDynamicToolDefinitionSchema).default([]),hooks:z.array(compiledHookDefinitionSchema),kind:z.literal(COMPILED_AGENT_MANIFEST_KIND),remoteAgents:z.array(compiledRemoteAgentNodeSchema),sandbox:compiledSandboxDefinitionSchema.nullable(),sandboxWorkspaces:z.array(compiledSandboxWorkspaceSchema),schedules:z.array(compiledScheduleDefinitionSchema),skills:z.array(compiledSkillSourceSchema).readonly(),subagentEdges:z.array(compiledSubagentEdgeSchema),subagents:z.array(compiledSubagentNodeSchema),instructions:compiledInstructionsSchema.optional(),tools:z.array(compiledToolDefinitionSchema),version:z.literal(38),workspaceResourceRoot:compiledWorkspaceResourceRootSchema}).strict();function createCompiledAgentNodeManifest(e){let t={agentRoot:e.agentRoot,appRoot:e.appRoot,channels:[...e.channels??[]],connections:[...e.connections??[]],config:{build:e.config.build===void 0?void 0:{externalDependencies:e.config.build.externalDependencies===void 0?void 0:[...e.config.build.externalDependencies]},compaction:{model:e.config.compaction?.model===void 0?void 0:cloneCompiledRuntimeModelReference(e.config.compaction.model),thresholdPercent:e.config.compaction?.thresholdPercent},description:e.config.description,dynamicModel:e.config.dynamicModel===void 0?void 0:{...e.config.dynamicModel},experimental:e.config.experimental===void 0?void 0:{subagentPersistentSessions:e.config.experimental.subagentPersistentSessions,workflow:e.config.experimental.workflow===void 0?void 0:{world:e.config.experimental.workflow.world}},model:cloneCompiledRuntimeModelReference(e.config.model),name:e.config.name,outputSchema:e.config.outputSchema,reasoning:e.config.reasoning,limits:e.config.limits===void 0?void 0:{maxInputTokensPerSession:e.config.limits.maxInputTokensPerSession,maxOutputTokensPerSession:e.config.limits.maxOutputTokensPerSession,sessionTimeoutMs:e.config.limits.sessionTimeoutMs},source:e.config.source===void 0?void 0:{...e.config.source}},diagnosticsSummary:e.diagnosticsSummary??{errors:0,warnings:0},disabledFrameworkTools:[...e.disabledFrameworkTools??[]],workflowTool:e.workflowTool===void 0?void 0:{maxSubagents:e.workflowTool.maxSubagents},dynamicInstructions:[...e.dynamicInstructions??[]],dynamicSkills:[...e.dynamicSkills??[]],dynamicTools:[...e.dynamicTools??[]],hooks:[...e.hooks??[]],remoteAgents:[...e.remoteAgents??[]],sandbox:e.sandbox??null,sandboxWorkspaces:[...e.sandboxWorkspaces??[]],schedules:[...e.schedules??[]],skills:[...e.skills??[]],tools:[...e.tools??[]],workspaceResourceRoot:e.workspaceResourceRoot??{logicalPath:``,rootEntries:deriveResourceRootEntries({sandboxWorkspaces:e.sandboxWorkspaces,skills:e.skills})}};return e.instructions!==void 0&&(t.instructions=e.instructions),t}function deriveResourceRootEntries(e){let t=new Set;for(let n of e.sandboxWorkspaces??[])for(let e of n.rootEntries)t.add(e);return[...t].sort((e,t)=>e.localeCompare(t))}function createCompiledSubagentNodeId(e,t){return e===`__root__`?t:`${e}::${t}`}function createCompiledAgentManifest(e){return{...createCompiledAgentNodeManifest(e),kind:COMPILED_AGENT_MANIFEST_KIND,extensionMounts:[...e.extensionMounts??[]],subagentEdges:[...e.subagentEdges??[]],subagents:[...e.subagents??[]],version:38}}function cloneCompiledRuntimeModelReference(e){let t={id:e.id,routing:cloneModelRouting(e.routing)};return e.contextWindowTokens!==void 0&&(t.contextWindowTokens=e.contextWindowTokens),e.providerOptions!==void 0&&(t.providerOptions={...e.providerOptions}),e.source!==void 0&&(t.source={...e.source}),t}function cloneModelRouting(e){return e.kind===`external`?{kind:`external`,provider:e.provider}:e.byok===void 0?{kind:`gateway`,target:e.target}:{kind:`gateway`,target:e.target,byok:e.byok}}export{COMPILED_AGENT_MANIFEST_KIND,COMPILED_AGENT_MANIFEST_VERSION,ROOT_COMPILED_AGENT_NODE_ID,compiledAgentManifestSchema,createCompiledAgentManifest,createCompiledAgentNodeManifest,createCompiledSubagentNodeId,deriveResourceRootEntries};
@@ -5,4 +5,6 @@ import { type ManifestCompileContext } from "#compiler/normalize-helpers.js";
5
5
  * Compiles the agent-level configuration (model, compaction, build,
6
6
  * workspace) for one authored agent node.
7
7
  */
8
- export declare function compileAgentConfig(manifest: AgentSourceManifest, context: ManifestCompileContext): Promise<CompiledAgentDefinition>;
8
+ export declare function compileAgentConfig(manifest: AgentSourceManifest, context: ManifestCompileContext, options?: {
9
+ readonly definition?: unknown;
10
+ }): Promise<CompiledAgentDefinition>;
@@ -1 +1 @@
1
- import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t){let n=e.configModule,r=n===void 0?void 0:formatAgentConfigModulePath(e,n),a=normalizeAgentDefinition(n===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:r,kind:`agent config`,source:n}),n===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${n.exportName??`default`}" from "${r}" to match the public eve shape.`),o=isDynamicModelDefinition(a.model)?a.model.fallback:a.model,s=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:a.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:o}),c={},l={compaction:c,model:s,name:e.agentId};if(a.description!==void 0&&(l.description=a.description),isDynamicModelDefinition(a.model)){if(n===void 0)throw Error(`Expected dynamic model definitions to be authored in agent.ts.`);l.dynamicModel={eventNames:Object.keys(a.model.events),exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}}let u=normalizeExperimentalDefinition(a.experimental);return u!==void 0&&(l.experimental=u),a.build!==void 0&&(l.build={externalDependencies:a.build.externalDependencies===void 0?void 0:[...a.build.externalDependencies]}),a.outputSchema!==void 0&&(l.outputSchema=serializeOutputSchema(a.outputSchema)),a.reasoning!==void 0&&(l.reasoning=a.reasoning),a.limits!==void 0&&(l.limits={maxInputTokensPerSession:a.limits.maxInputTokensPerSession,maxOutputTokensPerSession:a.limits.maxOutputTokensPerSession,sessionTimeoutMs:a.limits.sessionTimeoutMs}),n!==void 0&&(l.source={exportName:n.exportName,sourceKind:`module`,logicalPath:n.logicalPath,sourceId:n.sourceId}),a.compaction?.model!==void 0&&(c.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:a.compaction.modelContextWindowTokens,providerOptions:a.modelOptions?.providerOptions,source:n,sourcePath:r,value:a.compaction.model})),a.compaction?.thresholdPercent!==void 0&&(c.thresholdPercent=a.compaction.thresholdPercent),l}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
1
+ import{isAbsolute,join,relative,resolve}from"node:path";import{DEFAULT_AGENT_MODEL_ID}from"#shared/default-agent-model.js";import{toErrorMessage}from"#shared/errors.js";import{serializeOutputSchema}from"#shared/tool-schema.js";import{normalizeLogicalPath}from"#discover/filesystem.js";import{classifyModelRouting}from"#internal/classify-model-routing.js";import{normalizeAgentDefinition}from"#internal/authored-definition/core.js";import{formatLanguageModelGatewayId}from"#internal/runtime-model.js";import{parseJsonObject}from"#shared/json.js";import{isDynamicModelDefinition}from"#shared/agent-definition.js";import{loadModuleBackedDefinition}from"#compiler/normalize-helpers.js";async function compileAgentConfig(e,t,n={}){let r=e.configModule,a=r===void 0?void 0:formatAgentConfigModulePath(e,r),o=normalizeAgentDefinition(Object.hasOwn(n,`definition`)?n.definition:r===void 0?{model:DEFAULT_AGENT_MODEL_ID}:await loadModuleBackedDefinition({agentRoot:e.agentRoot,displayPath:a,kind:`agent config`,source:r}),r===void 0?`Expected the default agent config to match the public eve shape.`:`Expected the agent config export "${r.exportName??`default`}" from "${a}" to match the public eve shape.`),s=isDynamicModelDefinition(o.model)?o.model.fallback:o.model,c=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the primary compaction trigger model`,contextWindowTokens:o.modelContextWindowTokens,providerOptions:o.modelOptions?.providerOptions,source:r,sourcePath:a,value:s}),l={},u={compaction:l,model:c,name:e.agentId};if(o.description!==void 0&&(u.description=o.description),isDynamicModelDefinition(o.model)){if(r===void 0)throw Error(`Expected dynamic model definitions to be authored in agent.ts.`);u.dynamicModel={eventNames:Object.keys(o.model.events),exportName:r.exportName,sourceKind:`module`,logicalPath:r.logicalPath,sourceId:r.sourceId}}let d=normalizeExperimentalDefinition(o.experimental);return d!==void 0&&(u.experimental=d),o.build!==void 0&&(u.build={externalDependencies:o.build.externalDependencies===void 0?void 0:[...o.build.externalDependencies]}),o.outputSchema!==void 0&&(u.outputSchema=serializeOutputSchema(o.outputSchema)),o.reasoning!==void 0&&(u.reasoning=o.reasoning),o.limits!==void 0&&(u.limits={maxInputTokensPerSession:o.limits.maxInputTokensPerSession,maxOutputTokensPerSession:o.limits.maxOutputTokensPerSession,sessionTimeoutMs:o.limits.sessionTimeoutMs}),r!==void 0&&(u.source={exportName:r.exportName,sourceKind:`module`,logicalPath:r.logicalPath,sourceId:r.sourceId}),o.compaction?.model!==void 0&&(l.model=await normalizeAuthoredModelReference({modelCatalog:t.modelCatalog,purpose:`the compaction summary model`,contextWindowTokens:o.compaction.modelContextWindowTokens,providerOptions:o.modelOptions?.providerOptions,source:r,sourcePath:a,value:o.compaction.model})),o.compaction?.thresholdPercent!==void 0&&(l.thresholdPercent=o.compaction.thresholdPercent),u}function normalizeExperimentalDefinition(e){if(e===void 0)return;let t={};return e.subagentPersistentSessions!==void 0&&(t.subagentPersistentSessions=e.subagentPersistentSessions),e.workflow!==void 0&&(t.workflow={world:e.workflow.world}),t}async function normalizeAuthoredModelReference(e){if(typeof e.value==`string`)return await withCompiledRuntimeModelLimits({id:formatLanguageModelGatewayId(e.value),providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(e.value,e.providerOptions)},e);let t=e.source;if(t===void 0)throw Error(`Expected ${e.purpose} to provide a valid AI SDK language model reference.`);let n=e.value,r=n.specificationVersion;if(r!==`v2`&&r!==`v3`&&r!==`v4`||typeof n.provider!=`string`||typeof n.modelId!=`string`||typeof n.doGenerate!=`function`||typeof n.doStream!=`function`)throw Error(`Expected the authored agent config export "${t.exportName??`default`}" from "${e.sourcePath??t.logicalPath}" to provide a valid AI SDK language model.`);let i={id:formatLanguageModelGatewayId(n),source:{exportName:t.exportName,sourceKind:`module`,logicalPath:t.logicalPath,sourceId:t.sourceId},providerOptions:parseProviderOptionsRecord(e.providerOptions),routing:classifyModelRouting(n,e.providerOptions)};if(e.contextWindowTokens===void 0){let t=await e.modelCatalog.getByProviderModelId(n.provider,n.modelId);if(t)return{...i,id:t.slug,contextWindowTokens:t.limits.contextWindowTokens}}return await withCompiledRuntimeModelLimits(i,e)}function formatAgentConfigModulePath(e,r){let i=join(e.agentRoot,r.logicalPath);return normalizeLogicalPath(relative(resolveTopLevelAgentRoot(e),i))}function resolveTopLevelAgentRoot(e){let t=resolve(e.appRoot),n=resolve(t,`agent`);return isPathInsideOrEqual(n,resolve(e.agentRoot))?n:t}function isPathInsideOrEqual(t,r){let i=relative(t,r);return i===``||!i.startsWith(`..`)&&!isAbsolute(i)}async function withCompiledRuntimeModelLimits(e,t){if(t.contextWindowTokens!==void 0)return{...e,contextWindowTokens:t.contextWindowTokens};let n;try{n=await t.modelCatalog.getModelLimits(e.id)}catch(n){throw Error(`Failed to load AI Gateway model metadata for ${t.purpose} "${e.id}". ${toErrorMessage(n)}`)}if(n===null)throw Error(`Cannot compile agent compaction because ${t.purpose} "${e.id}" does not have known AI Gateway context window metadata.`);return{...e,contextWindowTokens:n.contextWindowTokens}}function parseProviderOptionsRecord(e){if(e===void 0)return;let t={};for(let[n,r]of Object.entries(e))t[n]=parseJsonObject(r);return t}export{compileAgentConfig};
@@ -1,3 +1,3 @@
1
- import{compileChannelDefinition}from"#compiler/normalize-channel.js";import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest,createCompiledAgentNodeManifest}from"#compiler/manifest.js";import{compileConnectionDefinition}from"#compiler/normalize-connection.js";import{compileHookEntry}from"#compiler/normalize-hook.js";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{mountRefNamespace,packageStateNamespace}from"#discover/extensions.js";import{createCompiledRuntimeModelCatalogLoader}from"#compiler/model-catalog.js";import{compileAgentConfig}from"#compiler/normalize-agent-config.js";import{compileExtensionContributions}from"#compiler/normalize-extension.js";import{compileSandboxDefinition}from"#compiler/normalize-sandbox.js";import{compileScheduleDefinition}from"#compiler/normalize-schedule.js";import{compileSubagentGraph}from"#compiler/normalize-subagent.js";async function compileAgentManifest(e){let r={modelCatalog:createCompiledRuntimeModelCatalogLoader(e.appRoot)},i=await compileAgentNodeManifest(e,r),a=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest,context:r,externalDependencies:i.config.build?.externalDependencies??[],parentNodeId:ROOT_COMPILED_AGENT_NODE_ID,subagents:e.subagents}),o=e.resolvedExtensions.map(t=>{let n=e.extensions.find(e=>mountRefNamespace(e.logicalPath)===t.namespace);return{namespace:t.namespace,packageName:t.packageName,packageNamespace:packageStateNamespace(t.packageName),sourceRoot:t.sourceRoot,mountSourceId:n?.sourceId??`extensions/${t.namespace}`,mountLogicalPath:n?.logicalPath??`extensions/${t.namespace}`}});return createCompiledAgentManifest({...i,extensionMounts:o,remoteAgents:a.remoteAgents,subagentEdges:a.edges,subagents:a.nodes})}async function compileAgentNodeManifest(t,n,s={}){let c=await compileAgentConfig(t,n);if(s.allowWorkflowConfig===!1&&c.experimental?.workflow!==void 0)throw Error(`Workflow runtime configuration is only supported on the root agent config. Remove "experimental.workflow" from "${t.agentId}".`);let l=mergeExternalDependencies(s.externalDependencies,c.build?.externalDependencies),u=l.length===0?c:{...c,build:{...c.build,externalDependencies:l}},d=await Promise.all(t.tools.map(e=>compileToolEntry(t.agentRoot,e,{externalDependencies:l}))),f=[],p=[],m=[],h;for(let e of d)e.kind===`tool`?f.push(e.definition):e.kind===`dynamic-tool`?p.push(e.definition):e.kind===`workflow-tool`?h={maxSubagents:e.maxSubagents}:m.push(e.name);let g=(await Promise.all(t.channels.map(n=>compileChannelDefinition(t.agentRoot,n,{externalDependencies:l})))).flat(),_=await Promise.all(t.skills.map(e=>compileSkillSource(t.agentRoot,e,{externalDependencies:l}))),v=[],y=[];for(let e of _)e.kind===`skill`?v.push(e.definition):y.push(e.definition);let b=await Promise.all(t.instructions.map(e=>compileInstructionsEntry(t.agentRoot,e,{externalDependencies:l}))),x=[],S=[];for(let e of b)e.kind===`instructions`?x.push(e.definition):S.push(e.definition);let C=await Promise.all(t.connections.map(e=>compileConnectionDefinition(t.agentRoot,e,{externalDependencies:l}))),w=t.hooks.map(e=>compileHookEntry(e)),T=await Promise.all(t.schedules.map(e=>compileScheduleDefinition(t.agentRoot,e,{externalDependencies:l}))),E=new Set(f.map(e=>e.name)),D=new Set(p.map(e=>e.slug)),O=new Set(C.map(e=>e.connectionName)),k=new Set(v.map(e=>e.name)),A=[];for(let e of[...t.resolvedExtensions].sort((e,t)=>e.namespace.localeCompare(t.namespace))){let r=await compileExtensionContributions({mount:e,context:n,consumerAgentRoot:t.agentRoot,externalDependencies:l});for(let e of r.tools)E.has(e.name)||(E.add(e.name),f.push(e));for(let e of r.dynamicTools)D.has(e.slug)||(D.add(e.slug),p.push(e));for(let e of r.connections)O.has(e.connectionName)||(O.add(e.connectionName),C.push(e));for(let e of r.skills)k.has(e.name)||(k.add(e.name),v.push(e));w.push(...r.hooks),y.push(...r.dynamicSkills),S.push(...r.dynamicInstructions),A.push(...r.instructionFragments)}let j=[...x.map(e=>e.markdown),...A],M=j.length===0?void 0:x.length===1&&A.length===0?x[0]:{name:`instructions`,logicalPath:`instructions`,markdown:j.join(`
1
+ import{compileChannelDefinition}from"#compiler/normalize-channel.js";import{ROOT_COMPILED_AGENT_NODE_ID,createCompiledAgentManifest,createCompiledAgentNodeManifest}from"#compiler/manifest.js";import{compileConnectionDefinition}from"#compiler/normalize-connection.js";import{compileHookEntry}from"#compiler/normalize-hook.js";import{compileInstructionsEntry}from"#compiler/normalize-instructions.js";import{compileSkillSource}from"#compiler/normalize-skill.js";import{compileToolEntry}from"#compiler/normalize-tool.js";import{mountRefNamespace,packageStateNamespace}from"#discover/extensions.js";import{createCompiledRuntimeModelCatalogLoader}from"#compiler/model-catalog.js";import{compileAgentConfig}from"#compiler/normalize-agent-config.js";import{compileExtensionContributions}from"#compiler/normalize-extension.js";import{compileSandboxDefinition}from"#compiler/normalize-sandbox.js";import{compileScheduleDefinition}from"#compiler/normalize-schedule.js";import{compileSubagentGraph}from"#compiler/normalize-subagent.js";async function compileAgentManifest(e){let r={modelCatalog:createCompiledRuntimeModelCatalogLoader(e.appRoot)},i=await compileAgentNodeManifest(e,r),a=await compileSubagentGraph({appRoot:e.appRoot,compileAgentNodeManifest,context:r,externalDependencies:i.config.build?.externalDependencies??[],parentNodeId:ROOT_COMPILED_AGENT_NODE_ID,subagents:e.subagents}),o=e.resolvedExtensions.map(t=>{let n=e.extensions.find(e=>mountRefNamespace(e.logicalPath)===t.namespace);return{namespace:t.namespace,packageName:t.packageName,packageNamespace:packageStateNamespace(t.packageName),sourceRoot:t.sourceRoot,mountSourceId:n?.sourceId??`extensions/${t.namespace}`,mountLogicalPath:n?.logicalPath??`extensions/${t.namespace}`}});return createCompiledAgentManifest({...i,extensionMounts:o,remoteAgents:a.remoteAgents,subagentEdges:a.edges,subagents:a.nodes})}async function compileAgentNodeManifest(t,n,s={}){let c=Object.hasOwn(s,`agentConfigDefinition`)?await compileAgentConfig(t,n,{definition:s.agentConfigDefinition}):await compileAgentConfig(t,n);if(s.allowWorkflowConfig===!1&&c.experimental?.workflow!==void 0)throw Error(`Workflow runtime configuration is only supported on the root agent config. Remove "experimental.workflow" from "${t.agentId}".`);let l=mergeExternalDependencies(s.externalDependencies,c.build?.externalDependencies),u=l.length===0?c:{...c,build:{...c.build,externalDependencies:l}},d=await Promise.all(t.tools.map(e=>compileToolEntry(t.agentRoot,e,{externalDependencies:l}))),f=[],p=[],m=[],h;for(let e of d)e.kind===`tool`?f.push(e.definition):e.kind===`dynamic-tool`?p.push(e.definition):e.kind===`workflow-tool`?h={maxSubagents:e.maxSubagents}:m.push(e.name);let g=(await Promise.all(t.channels.map(n=>compileChannelDefinition(t.agentRoot,n,{externalDependencies:l})))).flat(),_=await Promise.all(t.skills.map(e=>compileSkillSource(t.agentRoot,e,{externalDependencies:l}))),v=[],y=[];for(let e of _)e.kind===`skill`?v.push(e.definition):y.push(e.definition);let b=await Promise.all(t.instructions.map(e=>compileInstructionsEntry(t.agentRoot,e,{externalDependencies:l}))),x=[],S=[];for(let e of b)e.kind===`instructions`?x.push(e.definition):S.push(e.definition);let C=await Promise.all(t.connections.map(e=>compileConnectionDefinition(t.agentRoot,e,{externalDependencies:l}))),w=t.hooks.map(e=>compileHookEntry(e)),T=await Promise.all(t.schedules.map(e=>compileScheduleDefinition(t.agentRoot,e,{externalDependencies:l}))),E=new Set(f.map(e=>e.name)),D=new Set(p.map(e=>e.slug)),O=new Set(C.map(e=>e.connectionName)),k=new Set(v.map(e=>e.name)),A=[];for(let e of[...t.resolvedExtensions].sort((e,t)=>e.namespace.localeCompare(t.namespace))){let r=await compileExtensionContributions({mount:e,context:n,consumerAgentRoot:t.agentRoot,externalDependencies:l});for(let e of r.tools)E.has(e.name)||(E.add(e.name),f.push(e));for(let e of r.dynamicTools)D.has(e.slug)||(D.add(e.slug),p.push(e));for(let e of r.connections)O.has(e.connectionName)||(O.add(e.connectionName),C.push(e));for(let e of r.skills)k.has(e.name)||(k.add(e.name),v.push(e));w.push(...r.hooks),y.push(...r.dynamicSkills),S.push(...r.dynamicInstructions),A.push(...r.instructionFragments)}let j=[...x.map(e=>e.markdown),...A],M=j.length===0?void 0:x.length===1&&A.length===0?x[0]:{name:`instructions`,logicalPath:`instructions`,markdown:j.join(`
2
2
 
3
3
  `),sourceId:x[0]?.sourceId??`instructions`,sourceKind:`module`};return createCompiledAgentNodeManifest({agentRoot:t.agentRoot,appRoot:t.appRoot,channels:g,config:u,connections:C,diagnosticsSummary:t.diagnosticsSummary,disabledFrameworkTools:m,workflowTool:h,dynamicSkills:y,dynamicTools:p,hooks:w,sandbox:t.sandbox===null?null:await compileSandboxDefinition(t.agentRoot,t.sandbox,{externalDependencies:l}),sandboxWorkspaces:t.sandboxWorkspaces.map(e=>({logicalPath:e.logicalPath,rootEntries:[...e.rootEntries],sourceId:e.sourceId,sourcePath:e.sourcePath})),schedules:T,dynamicInstructions:S,skills:v,instructions:M,tools:f})}function mergeExternalDependencies(...e){let t=new Set;for(let n of e)for(let e of n??[])t.add(e);return[...t]}export{compileAgentManifest};
@@ -8,6 +8,7 @@ import { type ManifestCompileContext } from "#compiler/normalize-helpers.js";
8
8
  * circular dependency).
9
9
  */
10
10
  export type CompileAgentNodeManifestFn = (manifest: AgentSourceManifest, context: ManifestCompileContext, options?: {
11
+ readonly agentConfigDefinition?: unknown;
11
12
  readonly externalDependencies?: readonly string[];
12
13
  readonly allowWorkflowConfig?: boolean;
13
14
  }) => Promise<CompiledAgentNodeManifest>;