experimental-ash 0.22.2 → 0.24.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 (172) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/dist/docs/internals/hooks.md +13 -16
  3. package/dist/docs/internals/message-runtime.md +1 -1
  4. package/dist/docs/public/auth-and-route-protection.md +3 -3
  5. package/dist/docs/public/faqs.md +67 -0
  6. package/dist/docs/public/meta.json +1 -0
  7. package/dist/docs/public/schedules.md +11 -0
  8. package/dist/docs/public/session-context.md +46 -89
  9. package/dist/docs/public/skills.md +13 -0
  10. package/dist/docs/public/subagents.md +12 -6
  11. package/dist/docs/public/tools.md +9 -13
  12. package/dist/docs/public/typescript-api.md +4 -4
  13. package/dist/src/channel/types.d.ts +10 -12
  14. package/dist/src/chunks/{client-CKsU8Li3.js → client-nshDsWNF.js} +1 -1
  15. package/dist/src/chunks/{dev-authored-source-watcher-BLzYWh05.js → dev-authored-source-watcher-B4PaZGUr.js} +1 -1
  16. package/dist/src/chunks/host-DsW72Q-w.js +65 -0
  17. package/dist/src/chunks/paths-OknjaYR8.js +89 -0
  18. package/dist/src/chunks/prewarm-B4YblQ5m.js +6 -0
  19. package/dist/src/cli/commands/info.js +1 -1
  20. package/dist/src/cli/dev/repl.js +2 -2
  21. package/dist/src/cli/run.js +1 -1
  22. package/dist/src/client/session.js +8 -0
  23. package/dist/src/client/types.d.ts +12 -1
  24. package/dist/src/compiled/.vendor-stamp.json +3 -3
  25. package/dist/src/compiled/@workflow/core/_ms.d.ts +4 -0
  26. package/dist/src/compiled/@workflow/core/_workflow-serde.d.ts +5 -0
  27. package/dist/src/compiled/@workflow/core/_workflow-utils.d.ts +8 -0
  28. package/dist/src/compiled/@workflow/core/_workflow-world.d.ts +59 -0
  29. package/dist/src/compiled/@workflow/core/capabilities.d.ts +45 -0
  30. package/dist/src/compiled/@workflow/core/capture-stack.d.ts +16 -0
  31. package/dist/src/compiled/@workflow/core/class-serialization.d.ts +31 -0
  32. package/dist/src/compiled/@workflow/core/classify-error.d.ts +20 -0
  33. package/dist/src/compiled/@workflow/core/context-errors.d.ts +27 -0
  34. package/dist/src/compiled/@workflow/core/context-violation-error.d.ts +97 -0
  35. package/dist/src/compiled/@workflow/core/create-hook.d.ts +179 -0
  36. package/dist/src/compiled/@workflow/core/define-hook.d.ts +68 -0
  37. package/dist/src/compiled/@workflow/core/describe-error.d.ts +70 -0
  38. package/dist/src/compiled/@workflow/core/encryption.d.ts +51 -0
  39. package/dist/src/compiled/@workflow/core/events-consumer.d.ts +64 -0
  40. package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +82 -0
  41. package/dist/src/compiled/@workflow/core/global.d.ts +48 -0
  42. package/dist/src/compiled/@workflow/core/index.d.ts +19 -38
  43. package/dist/src/compiled/@workflow/core/index.js +2 -2
  44. package/dist/src/compiled/@workflow/core/log-format.d.ts +25 -0
  45. package/dist/src/compiled/@workflow/core/logger.d.ts +29 -0
  46. package/dist/src/compiled/@workflow/core/package.json +1 -1
  47. package/dist/src/compiled/@workflow/core/private.d.ts +59 -10
  48. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +51 -0
  49. package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +10 -0
  50. package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +32 -0
  51. package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +97 -0
  52. package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +98 -0
  53. package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +77 -0
  54. package/dist/src/compiled/@workflow/core/runtime/run.d.ts +134 -0
  55. package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +50 -0
  56. package/dist/src/compiled/@workflow/core/runtime/start.d.ts +59 -0
  57. package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +40 -0
  58. package/dist/src/compiled/@workflow/core/runtime/step-handler.d.ts +2 -0
  59. package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +42 -0
  60. package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +75 -0
  61. package/dist/src/compiled/@workflow/core/runtime/world.d.ts +32 -0
  62. package/dist/src/compiled/@workflow/core/runtime.d.ts +22 -67
  63. package/dist/src/compiled/@workflow/core/runtime.js +27 -27
  64. package/dist/src/compiled/@workflow/core/schemas.d.ts +15 -0
  65. package/dist/src/compiled/@workflow/core/serialization/client.d.ts +17 -0
  66. package/dist/src/compiled/@workflow/core/serialization/codec-devalue.d.ts +14 -0
  67. package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +90 -0
  68. package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +32 -0
  69. package/dist/src/compiled/@workflow/core/serialization/errors.d.ts +21 -0
  70. package/dist/src/compiled/@workflow/core/serialization/format.d.ts +60 -0
  71. package/dist/src/compiled/@workflow/core/serialization/index.d.ts +18 -0
  72. package/dist/src/compiled/@workflow/core/serialization/reducers/class.d.ts +11 -0
  73. package/dist/src/compiled/@workflow/core/serialization/reducers/common.d.ts +16 -0
  74. package/dist/src/compiled/@workflow/core/serialization/reducers/step-function.d.ts +35 -0
  75. package/dist/src/compiled/@workflow/core/serialization/step.d.ts +17 -0
  76. package/dist/src/compiled/@workflow/core/serialization/types.d.ts +215 -0
  77. package/dist/src/compiled/@workflow/core/serialization/workflow.d.ts +29 -0
  78. package/dist/src/compiled/@workflow/core/serialization-format.d.ts +171 -0
  79. package/dist/src/compiled/@workflow/core/serialization.d.ts +337 -0
  80. package/dist/src/compiled/@workflow/core/sleep.d.ts +33 -0
  81. package/dist/src/compiled/@workflow/core/source-map.d.ts +10 -0
  82. package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +13 -0
  83. package/dist/src/compiled/@workflow/core/step/get-closure-vars.d.ts +9 -0
  84. package/dist/src/compiled/@workflow/core/step/get-step-metadata.d.ts +42 -0
  85. package/dist/src/compiled/@workflow/core/step/get-workflow-metadata.d.ts +7 -0
  86. package/dist/src/compiled/@workflow/core/step/writable-stream.d.ts +22 -0
  87. package/dist/src/compiled/@workflow/core/step.d.ts +4 -0
  88. package/dist/src/compiled/@workflow/core/symbols.d.ts +36 -0
  89. package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +283 -0
  90. package/dist/src/compiled/@workflow/core/telemetry.d.ts +53 -0
  91. package/dist/src/compiled/@workflow/core/types.d.ts +14 -0
  92. package/dist/src/compiled/@workflow/core/util.d.ts +40 -0
  93. package/dist/src/compiled/@workflow/core/version.d.ts +2 -0
  94. package/dist/src/compiled/@workflow/core/vm/index.d.ts +17 -0
  95. package/dist/src/compiled/@workflow/core/vm/uint8array-base64.d.ts +21 -0
  96. package/dist/src/compiled/@workflow/core/vm/uuid.d.ts +10 -0
  97. package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +65 -0
  98. package/dist/src/compiled/@workflow/core/workflow/create-hook.d.ts +7 -0
  99. package/dist/src/compiled/@workflow/core/workflow/define-hook.d.ts +10 -0
  100. package/dist/src/compiled/@workflow/core/workflow/get-workflow-metadata.d.ts +32 -0
  101. package/dist/src/compiled/@workflow/core/workflow/hook.d.ts +4 -0
  102. package/dist/src/compiled/@workflow/core/workflow/index.d.ts +11 -0
  103. package/dist/src/compiled/@workflow/core/workflow/sleep.d.ts +4 -0
  104. package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +15 -0
  105. package/dist/src/compiled/@workflow/core/workflow/writable-stream.d.ts +3 -0
  106. package/dist/src/compiled/@workflow/core/workflow.d.ts +1 -38
  107. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  108. package/dist/src/compiled/@workflow/errors/error-codes.d.ts +5 -1
  109. package/dist/src/compiled/@workflow/errors/index.d.ts +15 -1
  110. package/dist/src/compiled/@workflow/errors/index.js +1 -1
  111. package/dist/src/compiled/@workflow/errors/package.json +1 -1
  112. package/dist/src/compiled/_chunks/workflow/{context-errors-zbKocOyk.js → context-errors-Bbvvp-li.js} +2 -2
  113. package/dist/src/compiled/_chunks/workflow/{dist-0iNBqPYp.js → dist-C7wPwOI9.js} +2 -2
  114. package/dist/src/compiled/_chunks/workflow/{dist-D774SUM4.js → dist-C_oiE-l7.js} +1 -1
  115. package/dist/src/compiled/_chunks/workflow/resume-hook-C3VWUPii.js +12 -0
  116. package/dist/src/compiled/_chunks/workflow/sleep-QTkC1VFe.js +1 -0
  117. package/dist/src/compiled/_chunks/workflow/{symbols-D-4tVV8x.js → symbols-QezhMuLg.js} +1 -1
  118. package/dist/src/evals/cli/eval.js +1 -1
  119. package/dist/src/execution/await-authorization-orchestrator.d.ts +2 -1
  120. package/dist/src/execution/await-authorization-orchestrator.js +4 -0
  121. package/dist/src/execution/connection-auth-steps.d.ts +4 -0
  122. package/dist/src/execution/connection-auth-steps.js +9 -11
  123. package/dist/src/execution/node-step.d.ts +4 -5
  124. package/dist/src/execution/subagent-adapter.d.ts +0 -27
  125. package/dist/src/execution/subagent-adapter.js +2 -66
  126. package/dist/src/execution/subagent-hitl-proxy.d.ts +2 -2
  127. package/dist/src/execution/subagent-hitl-proxy.js +2 -2
  128. package/dist/src/execution/task-mode.d.ts +3 -3
  129. package/dist/src/execution/task-mode.js +3 -3
  130. package/dist/src/execution/turn-workflow.d.ts +41 -0
  131. package/dist/src/execution/turn-workflow.js +96 -0
  132. package/dist/src/execution/workflow-entry.js +77 -87
  133. package/dist/src/execution/workflow-errors.d.ts +14 -0
  134. package/dist/src/execution/workflow-errors.js +54 -0
  135. package/dist/src/execution/workflow-runtime.d.ts +34 -3
  136. package/dist/src/execution/workflow-runtime.js +52 -10
  137. package/dist/src/execution/workflow-steps.d.ts +27 -2
  138. package/dist/src/execution/workflow-steps.js +31 -26
  139. package/dist/src/harness/instrumentation-config.js +14 -7
  140. package/dist/src/harness/messages.d.ts +7 -7
  141. package/dist/src/harness/messages.js +4 -4
  142. package/dist/src/harness/runtime-actions.d.ts +4 -4
  143. package/dist/src/internal/application/package.js +1 -1
  144. package/dist/src/internal/workflow-bundle/workflow-builders.d.ts +1 -1
  145. package/dist/src/internal/workflow-bundle/workflow-builders.js +20 -8
  146. package/dist/src/internal/workflow-bundle/workflow-transformer.d.ts +13 -0
  147. package/dist/src/internal/workflow-bundle/workflow-transformer.js +10 -4
  148. package/dist/src/protocol/message.d.ts +6 -1
  149. package/dist/src/public/channels/ash.js +50 -3
  150. package/dist/src/public/context/index.d.ts +4 -7
  151. package/dist/src/public/context/index.js +4 -5
  152. package/dist/src/public/definitions/state.d.ts +33 -0
  153. package/dist/src/public/definitions/state.js +34 -0
  154. package/dist/src/public/next/index.d.ts +7 -0
  155. package/dist/src/public/next/index.js +2 -0
  156. package/dist/src/public/next/vercel-json.d.ts +1 -0
  157. package/dist/src/public/next/vercel-json.js +1 -0
  158. package/dist/src/react/index.d.ts +1 -1
  159. package/dist/src/react/use-ash-agent.d.ts +8 -0
  160. package/dist/src/react/use-ash-agent.js +26 -4
  161. package/dist/src/services/dev-client.d.ts +4 -1
  162. package/dist/src/services/dev-client.js +1 -0
  163. package/package.json +4 -4
  164. package/dist/src/chunks/host-DREC8e8Z.js +0 -65
  165. package/dist/src/chunks/paths-C6sp4T2U.js +0 -88
  166. package/dist/src/chunks/prewarm-hz8p2jlZ.js +0 -6
  167. package/dist/src/compiled/_chunks/workflow/resume-hook-CL8Ed91K.js +0 -12
  168. package/dist/src/compiled/_chunks/workflow/sleep-Dn3i9nxI.js +0 -1
  169. package/dist/src/execution/continuous-entry.d.ts +0 -59
  170. package/dist/src/execution/continuous-entry.js +0 -487
  171. package/dist/src/execution/continuous-runtime.d.ts +0 -17
  172. package/dist/src/execution/continuous-runtime.js +0 -123
@@ -0,0 +1,12 @@
1
+ import{i as e,n as t,t as n}from"./chunk-DHhdAPOb.js";import{A as r,M as i,N as a,O as o,P as s,S as c,a as l,i as u,j as d,k as f,n as p,o as m,s as h,t as g,u as _}from"./dist-C7wPwOI9.js";import{C as v,S as y,a as b,c as x,d as ee,g as te,i as S,l as ne,n as re,o as C,r as w,s as T,t as E,u as ie,v as D,x as ae}from"./symbols-QezhMuLg.js";import{a as oe,p as se,s as ce}from"./dist-C_oiE-l7.js";import{getStepFunction as le}from"../../@workflow/core/private.js";import{types as ue}from"node:util";import{AsyncLocalStorage as de}from"node:async_hooks";var fe=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{CITY_HEADER_NAME:()=>u,COUNTRY_HEADER_NAME:()=>d,EMOJI_FLAG_UNICODE_STARTING_POSITION:()=>v,IP_HEADER_NAME:()=>f,LATITUDE_HEADER_NAME:()=>p,LONGITUDE_HEADER_NAME:()=>m,POSTAL_CODE_HEADER_NAME:()=>g,REGION_HEADER_NAME:()=>h,REQUEST_ID_HEADER_NAME:()=>_,geolocation:()=>S,ipAddress:()=>ee}),t.exports=c(l);let u=`x-vercel-ip-city`,d=`x-vercel-ip-country`,f=`x-real-ip`,p=`x-vercel-ip-latitude`,m=`x-vercel-ip-longitude`,h=`x-vercel-ip-country-region`,g=`x-vercel-ip-postal-code`,_=`x-vercel-id`,v=127397;function y(e,t){return e.get(t)??void 0}function b(e,t){let n=y(e.headers,t);return n?decodeURIComponent(n):void 0}function x(e){let t=RegExp(`^[A-Z]{2}$`).test(e);if(!(!e||!t))return String.fromCodePoint(...e.split(``).map(e=>v+e.charCodeAt(0)))}function ee(e){return y(`headers`in e?e.headers:e,f)}function te(e){return e?e.split(`:`)[0]:`dev1`}function S(e){return{city:b(e,u),country:y(e.headers,d),flag:x(y(e.headers,d)),countryRegion:y(e.headers,h),region:te(y(e.headers,_)),latitude:y(e.headers,p),longitude:y(e.headers,m),postalCode:y(e.headers,g)}}})),pe=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{getEnv:()=>u}),t.exports=c(l);let u=(e=process.env)=>({VERCEL:d(e,`VERCEL`),CI:d(e,`CI`),VERCEL_ENV:d(e,`VERCEL_ENV`),VERCEL_URL:d(e,`VERCEL_URL`),VERCEL_BRANCH_URL:d(e,`VERCEL_BRANCH_URL`),VERCEL_PROJECT_PRODUCTION_URL:d(e,`VERCEL_PROJECT_PRODUCTION_URL`),VERCEL_REGION:d(e,`VERCEL_REGION`),VERCEL_DEPLOYMENT_ID:d(e,`VERCEL_DEPLOYMENT_ID`),VERCEL_SKEW_PROTECTION_ENABLED:d(e,`VERCEL_SKEW_PROTECTION_ENABLED`),VERCEL_AUTOMATION_BYPASS_SECRET:d(e,`VERCEL_AUTOMATION_BYPASS_SECRET`),VERCEL_GIT_PROVIDER:d(e,`VERCEL_GIT_PROVIDER`),VERCEL_GIT_REPO_SLUG:d(e,`VERCEL_GIT_REPO_SLUG`),VERCEL_GIT_REPO_OWNER:d(e,`VERCEL_GIT_REPO_OWNER`),VERCEL_GIT_REPO_ID:d(e,`VERCEL_GIT_REPO_ID`),VERCEL_GIT_COMMIT_REF:d(e,`VERCEL_GIT_COMMIT_REF`),VERCEL_GIT_COMMIT_SHA:d(e,`VERCEL_GIT_COMMIT_SHA`),VERCEL_GIT_COMMIT_MESSAGE:d(e,`VERCEL_GIT_COMMIT_MESSAGE`),VERCEL_GIT_COMMIT_AUTHOR_LOGIN:d(e,`VERCEL_GIT_COMMIT_AUTHOR_LOGIN`),VERCEL_GIT_COMMIT_AUTHOR_NAME:d(e,`VERCEL_GIT_COMMIT_AUTHOR_NAME`),VERCEL_GIT_PREVIOUS_SHA:d(e,`VERCEL_GIT_PREVIOUS_SHA`),VERCEL_GIT_PULL_REQUEST_ID:d(e,`VERCEL_GIT_PULL_REQUEST_ID`)}),d=(e,t)=>{let n=e[t];return n===``?void 0:n}})),me=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{SYMBOL_FOR_REQ_CONTEXT:()=>u,getContext:()=>d}),t.exports=c(l);let u=Symbol.for(`@vercel/request-context`);function d(){return globalThis[u]?.get?.()??{}}})),he=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{waitUntil:()=>d}),t.exports=c(l);var u=me();let d=e=>{if(typeof e!=`object`||!e||typeof e.then!=`function`)throw TypeError(`waitUntil can only be called with a Promise, got ${typeof e}`);return(0,u.getContext)().waitUntil?.(e)}})),ge=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{next:()=>f,rewrite:()=>d}),t.exports=c(l);function u(e,t){if(e?.request?.headers){if(!(e.request.headers instanceof Headers))throw Error(`request.headers must be an instance of Headers`);let n=[];for(let[r,i]of e.request.headers)t.set(`x-middleware-request-`+r,i),n.push(r);t.set(`x-middleware-override-headers`,n.join(`,`))}}function d(e,t){let n=new Headers(t?.headers??{});return n.set(`x-middleware-rewrite`,String(e)),u(t,n),new Response(null,{...t,headers:n})}function f(e){let t=new Headers(e?.headers??{});return t.set(`x-middleware-next`,`1`),u(e,t),new Response(null,{...e,headers:t})}})),_e=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{InMemoryCache:()=>u}),t.exports=c(l);var u=class{constructor(){this.cache={}}async get(e){let t=this.cache[e];return t?t.ttl&&t.lastModified+t.ttl*1e3<Date.now()?(await this.delete(e),null):JSON.parse(t.value):null}async set(e,t,n){let r=JSON.stringify(t??null);this.cache[e]={value:r,lastModified:Date.now(),ttl:n?.ttl,tags:new Set(n?.tags||[])}}async delete(e){delete this.cache[e]}async expireTag(e){let t=Array.isArray(e)?e:[e];for(let e in this.cache)if(Object.prototype.hasOwnProperty.call(this.cache,e)){let n=this.cache[e];t.some(e=>n.tags.has(e))&&delete this.cache[e]}}}})),ve=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{BuildCache:()=>d}),t.exports=c(l);var u=ye(),d=class{constructor({endpoint:e,headers:t,onError:n,timeout:r=500}){this.get=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{headers:this.headers,method:`GET`,signal:t.signal});if(r.status===404)return clearTimeout(n),null;if(r.status===200){if(r.headers.get(u.HEADERS_VERCEL_CACHE_STATE)!==u.PkgCacheState.Fresh)return r.body?.cancel?.(),clearTimeout(n),null;let e=await r.json();return clearTimeout(n),e}else throw clearTimeout(n),Error(`Failed to get cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e);return null}},this.set=async(e,t,n)=>{let r=new AbortController,i=setTimeout(()=>r.abort(),this.timeout);try{let a={};n?.ttl&&(a[u.HEADERS_VERCEL_REVALIDATE]=n.ttl.toString()),n?.tags&&n.tags.length>0&&(a[u.HEADERS_VERCEL_CACHE_TAGS]=n.tags.join(`,`)),n?.name&&(a[u.HEADERS_VERCEL_CACHE_ITEM_NAME]=n.name);let o=await fetch(`${this.endpoint}${e}`,{method:`POST`,headers:{...this.headers,...a},body:JSON.stringify(t),signal:r.signal});if(clearTimeout(i),o.status!==200)throw Error(`Failed to set cache: ${o.status} ${o.statusText}`)}catch(e){if(clearTimeout(i),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.delete=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{let r=await fetch(`${this.endpoint}${e}`,{method:`DELETE`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to delete cache: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.expireTag=async e=>{let t=new AbortController,n=setTimeout(()=>t.abort(),this.timeout);try{Array.isArray(e)&&(e=e.join(`,`));let r=await fetch(`${this.endpoint}revalidate?tags=${e}`,{method:`POST`,headers:this.headers,signal:t.signal});if(clearTimeout(n),r.status!==200)throw Error(`Failed to revalidate tag: ${r.statusText}`)}catch(e){if(clearTimeout(n),e.name===`AbortError`){let t=Error(`Cache request timed out after ${this.timeout}ms`);t.stack=e.stack,this.onError?.(t)}else this.onError?.(e)}},this.endpoint=e,this.headers=t,this.onError=n,this.timeout=r}}})),ye=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{HEADERS_VERCEL_CACHE_ITEM_NAME:()=>ne,HEADERS_VERCEL_CACHE_STATE:()=>ee,HEADERS_VERCEL_CACHE_TAGS:()=>S,HEADERS_VERCEL_REVALIDATE:()=>te,PkgCacheState:()=>x,getCache:()=>g}),t.exports=c(l);var u=me(),d=_e(),f=ve();let p=e=>{let t=5381;for(let n=0;n<e.length;n++)t=t*33^e.charCodeAt(n);return(t>>>0).toString(16)},m=null,h=null,g=e=>v(()=>{let e;return e=(0,u.getContext)().cache?(0,u.getContext)().cache:b(process.env.SUSPENSE_CACHE_DEBUG===`true`),e},_(e));function _(e){let t=e?.keyHashFunction||p;return n=>{if(!e?.namespace)return t(n);let r=e.namespaceSeparator||`$`;return`${e.namespace}${r}${t(n)}`}}function v(e,t){return{get:n=>e().get(t(n)),set:(n,r,i)=>e().set(t(n),r,i),delete:n=>e().delete(t(n)),expireTag:t=>e().expireTag(t)}}let y=!1;function b(e){if(m||=new d.InMemoryCache,process.env.RUNTIME_CACHE_DISABLE_BUILD_CACHE===`true`)return e&&console.log(`Using InMemoryCache as build cache is disabled`),m;let{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}=process.env;if(e&&console.log(`Runtime cache environment variables:`,{RUNTIME_CACHE_ENDPOINT:t,RUNTIME_CACHE_HEADERS:n}),!t||!n)return y||=(console.warn(`Runtime Cache unavailable in this environment. Falling back to in-memory cache.`),!0),m;if(!h){let e={};try{e=JSON.parse(n)}catch(e){return console.error(`Failed to parse RUNTIME_CACHE_HEADERS:`,e),m}let r=500;if(process.env.RUNTIME_CACHE_TIMEOUT){let e=parseInt(process.env.RUNTIME_CACHE_TIMEOUT,10);!isNaN(e)&&e>0?r=e:console.warn(`Invalid RUNTIME_CACHE_TIMEOUT value: "${process.env.RUNTIME_CACHE_TIMEOUT}". Using default: ${r}ms`)}h=new f.BuildCache({endpoint:t,headers:e,onError:e=>console.error(e),timeout:r})}return h}var x=(e=>(e.Fresh=`fresh`,e.Stale=`stale`,e.Expired=`expired`,e.NotFound=`notFound`,e.Error=`error`,e))(x||{});let ee=`x-vercel-cache-state`,te=`x-vercel-revalidate`,S=`x-vercel-cache-tags`,ne=`x-vercel-cache-item-name`})),be=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{attachDatabasePool:()=>_,experimental_attachDatabasePool:()=>v}),t.exports=c(l);var u=me();let d=!!process.env.DEBUG;function f(e){if(`options`in e&&e.options){if(`idleTimeoutMillis`in e.options)return typeof e.options.idleTimeoutMillis==`number`?e.options.idleTimeoutMillis:1e4;if(`maxIdleTimeMS`in e.options)return typeof e.options.maxIdleTimeMS==`number`?e.options.maxIdleTimeMS:0;if(`status`in e)return 5e3;if(`connect`in e&&`execute`in e)return 3e4}if(`config`in e&&e.config){if(`connectionConfig`in e.config&&e.config.connectionConfig)return e.config.connectionConfig.idleTimeout||6e4;if(`idleTimeout`in e.config)return typeof e.config.idleTimeout==`number`?e.config.idleTimeout:6e4}return`poolTimeout`in e?typeof e.poolTimeout==`number`?e.poolTimeout:6e4:`idleTimeout`in e?typeof e.idleTimeout==`number`?e.idleTimeout:0:1e4}let p=null,m=()=>{},h=Date.now();function g(e){if(!process.env.VERCEL_URL||!process.env.VERCEL_REGION)return;p&&(clearTimeout(p),m());let t=new Promise(e=>{m=e}),n=Math.min(f(e)+100,Math.max(100,899e3-(Date.now()-h)));p=setTimeout(()=>{m?.(),d&&console.log(`Database pool idle timeout reached. Releasing connections.`)},n);let r=(0,u.getContext)();r?.waitUntil?r.waitUntil(t):console.warn(`Pool release event triggered outside of request scope.`)}function _(e){if(p&&(m?.(),clearTimeout(p)),`on`in e&&e.on&&`options`in e&&`idleTimeoutMillis`in e.options){e.on(`release`,()=>{d&&console.log(`Client released from pool`),g(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`connectionConfig`in e.config){e.on(`release`,()=>{d&&console.log(`MySQL client released from pool`),g(e)});return}else if(`on`in e&&e.on&&`config`in e&&e.config&&`idleTimeout`in e.config){e.on(`release`,()=>{d&&console.log(`MySQL2/MariaDB client released from pool`),g(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`maxIdleTimeMS`in e.options){e.on(`connectionCheckedOut`,()=>{d&&console.log(`MongoDB connection checked out`),g(e)});return}if(`on`in e&&e.on&&`options`in e&&e.options&&`socket`in e.options){e.on(`end`,()=>{d&&console.log(`Redis connection ended`),g(e)});return}throw Error(`Unsupported database pool type`)}let v=_})),xe=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{dangerouslyDeleteBySrcImage:()=>m,dangerouslyDeleteByTag:()=>f,invalidateBySrcImage:()=>p,invalidateByTag:()=>d}),t.exports=c(l);var u=me();let d=e=>{let t=(0,u.getContext)().purge;return t?t.invalidateByTag(e):Promise.resolve()},f=(e,t)=>{let n=(0,u.getContext)().purge;return n?n.dangerouslyDeleteByTag(e,t):Promise.resolve()},p=e=>{let t=(0,u.getContext)().purge;return t?t.invalidateBySrcImage(e):Promise.resolve()},m=(e,t)=>{let n=(0,u.getContext)().purge;return n?n.dangerouslyDeleteBySrcImage(e,t):Promise.resolve()}})),Se=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{addCacheTag:()=>d}),t.exports=c(l);var u=me();let d=e=>{let t=(0,u.getContext)().addCacheTag;return t?t(e):Promise.resolve()}})),Ce=n(((e,t)=>{var n=Object.defineProperty,r=Object.getOwnPropertyDescriptor,i=Object.getOwnPropertyNames,a=Object.prototype.hasOwnProperty,o=(e,t)=>{for(var r in t)n(e,r,{get:t[r],enumerable:!0})},s=(e,t,o,s)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of i(t))!a.call(e,c)&&c!==o&&n(e,c,{get:()=>t[c],enumerable:!(s=r(t,c))||s.enumerable});return e},c=e=>s(n({},`__esModule`,{value:!0}),e),l={};o(l,{addCacheTag:()=>_.addCacheTag,attachDatabasePool:()=>h.attachDatabasePool,dangerouslyDeleteBySrcImage:()=>g.dangerouslyDeleteBySrcImage,dangerouslyDeleteByTag:()=>g.dangerouslyDeleteByTag,experimental_attachDatabasePool:()=>h.experimental_attachDatabasePool,geolocation:()=>u.geolocation,getCache:()=>m.getCache,getEnv:()=>d.getEnv,invalidateBySrcImage:()=>g.invalidateBySrcImage,invalidateByTag:()=>g.invalidateByTag,ipAddress:()=>u.ipAddress,next:()=>p.next,rewrite:()=>p.rewrite,waitUntil:()=>f.waitUntil}),t.exports=c(l);var u=fe(),d=pe(),f=he(),p=ge(),m=ye(),h=be(),g=xe(),_=Se()})),we=n(((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=n(((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=n(((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=n(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),Oe=n(((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=n(((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}}})),k=n(((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}}})),ke=n(((e,t)=>{let n=k();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Ae=n(((e,t)=>{let n=k();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),je=n(((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}}})),Me=n(((e,t)=>{let n=k();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`}})),Ne=n(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).major})),Pe=n(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).minor})),Fe=n(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).patch})),Ie=n(((e,t)=>{let n=k();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),A=n(((e,t)=>{let n=O();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Le=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>n(t,e,r)})),Re=n(((e,t)=>{let n=A();t.exports=(e,t)=>n(e,t,!0)})),ze=n(((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)}})),Be=n(((e,t)=>{let n=ze();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Ve=n(((e,t)=>{let n=ze();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),He=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>n(e,t,r)>0})),Ue=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>n(e,t,r)<0})),We=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>n(e,t,r)===0})),Ge=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>n(e,t,r)!==0})),Ke=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>n(e,t,r)>=0})),qe=n(((e,t)=>{let n=A();t.exports=(e,t,r)=>n(e,t,r)<=0})),Je=n(((e,t)=>{let n=We(),r=Ge(),i=He(),a=Ke(),o=Ue(),s=qe();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}`)}}})),Ye=n(((e,t)=>{let n=O(),r=k(),{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];return r(`${s}.${o[3]||`0`}.${o[4]||`0`}${t.includePrerelease&&o[5]?`-${o[5]}`:``}${t.includePrerelease&&o[6]?`+${o[6]}`:``}`,t)}})),Xe=n(((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}}})),j=n(((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,w(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=>C(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(T(this.set[t],e,this.options))return!0;return!1}};let r=new(Xe()),i=De(),a=Ze(),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=ee(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=S(e,t),o(`xrange`,e),e=re(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(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})},ee=(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})},S=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>ne(e,t)).join(` `)),ne=(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})},re=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),C=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),w=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()),T=(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}})),Ze=n(((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===``?!0:new l(t.value,n).test(this.value):t.operator===``?t.value===``?!0: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=Je(),s=Te(),c=O(),l=j()})),Qe=n(((e,t)=>{let n=j();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),$e=n(((e,t)=>{let n=j();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),et=n(((e,t)=>{let n=O(),r=j();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}})),tt=n(((e,t)=>{let n=O(),r=j();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=n(((e,t)=>{let n=O(),r=j(),i=He();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}})),rt=n(((e,t)=>{let n=j();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),it=n(((e,t)=>{let n=O(),r=Ze(),{ANY:i}=r,a=j(),o=Qe(),s=He(),c=Ue(),l=qe(),u=Ke();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}})),at=n(((e,t)=>{let n=it();t.exports=(e,t,r)=>n(e,t,`>`,r)})),ot=n(((e,t)=>{let n=it();t.exports=(e,t,r)=>n(e,t,`<`,r)})),st=n(((e,t)=>{let n=j();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),ct=n(((e,t)=>{let n=Qe(),r=A();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}})),lt=n(((e,t)=>{let n=j(),r=Ze(),{ANY:i}=r,a=Qe(),o=A(),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})),ut=n(((e,t)=>{let n=Ee(),r=we(),i=O(),a=Oe();t.exports={parse:k(),valid:ke(),clean:Ae(),inc:je(),diff:Me(),major:Ne(),minor:Pe(),patch:Fe(),prerelease:Ie(),compare:A(),rcompare:Le(),compareLoose:Re(),compareBuild:ze(),sort:Be(),rsort:Ve(),gt:He(),lt:Ue(),eq:We(),neq:Ge(),gte:Ke(),lte:qe(),cmp:Je(),coerce:Ye(),Comparator:Ze(),Range:j(),satisfies:Qe(),toComparators:$e(),maxSatisfying:et(),minSatisfying:tt(),minVersion:nt(),validRange:rt(),outside:it(),gtr:at(),ltr:ot(),intersects:st(),simplifyRange:ct(),subset:lt(),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}})),M=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};function dt(e){return Object(e)!==e}const ft=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function pt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===ft}function mt(e){return Object.prototype.toString.call(e).slice(8,-1)}function ht(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
2
+ `: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 N(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=ht(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function gt(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const _t=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function vt(e){return _t.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function yt(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}let t=+e;return!(t>=2**32-1||t<0)}function bt(e){let t=Object.keys(e);for(var n=t.length-1;n>=0&&!yt(t[n]);n--);return t.length=n+1,t}function xt(e){let t=new DataView(e),n=``;for(let r=0;r<e.byteLength;r++)n+=String.fromCharCode(t.getUint8(r));return Tt(n)}function St(e){let t=wt(e),n=new ArrayBuffer(t.length),r=new DataView(n);for(let e=0;e<n.byteLength;e++)r.setUint8(e,t.charCodeAt(e));return n}const Ct=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function wt(e){e.length%4==0&&(e=e.replace(/==?$/,``));let t=``,n=0,r=0;for(let i=0;i<e.length;i++)n<<=6,n|=Ct.indexOf(e[i]),r+=6,r===24&&(t+=String.fromCharCode((n&16711680)>>16),t+=String.fromCharCode((n&65280)>>8),t+=String.fromCharCode(n&255),n=r=0);return r===12?(n>>=4,t+=String.fromCharCode(n)):r===18&&(n>>=2,t+=String.fromCharCode((n&65280)>>8),t+=String.fromCharCode(n&255)),t}function Tt(e){let t=``;for(let n=0;n<e.length;n+=3){let r=[void 0,void 0,void 0,void 0];r[0]=e.charCodeAt(n)>>2,r[1]=(e.charCodeAt(n)&3)<<4,e.length>n+1&&(r[1]|=e.charCodeAt(n+1)>>4,r[2]=(e.charCodeAt(n+1)&15)<<2),e.length>n+2&&(r[2]|=e.charCodeAt(n+2)>>6,r[3]=e.charCodeAt(n+2)&63);for(let e=0;e<r.length;e++)r[e]===void 0?t+=`=`:t+=Ct[r[e]]}return t}function Et(e,t){return Dt(JSON.parse(e),t)}function Dt(e,t){if(typeof e==`number`)return a(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let n=e,r=Array(n.length),i=null;function a(e,o=!1){if(e===-1)return;if(e===-3)return NaN;if(e===-4)return 1/0;if(e===-5)return-1/0;if(e===-6)return-0;if(o||typeof e!=`number`)throw Error(`Invalid input`);if(e in r)return r[e];let s=n[e];if(!s||typeof s!=`object`)r[e]=s;else if(Array.isArray(s))if(typeof s[0]==`string`){let o=s[0],c=t&&Object.hasOwn(t,o)?t[o]:void 0;if(c){let t=s[1];if(typeof t!=`number`&&(t=n.push(s[1])-1),i??=new Set,i.has(t))throw Error(`Invalid circular reference`);return i.add(t),r[e]=c(a(t)),i.delete(t),r[e]}switch(o){case`Date`:r[e]=new Date(s[1]);break;case`Set`:let t=new Set;r[e]=t;for(let e=1;e<s.length;e+=1)t.add(a(s[e]));break;case`Map`:let i=new Map;r[e]=i;for(let e=1;e<s.length;e+=2)i.set(a(s[e]),a(s[e+1]));break;case`RegExp`:r[e]=new RegExp(s[1],s[2]);break;case`Object`:r[e]=Object(s[1]);break;case`BigInt`:r[e]=BigInt(s[1]);break;case`null`:let c=Object.create(null);r[e]=c;for(let e=1;e<s.length;e+=2)c[s[e]]=a(s[e+1]);break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{if(n[s[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=globalThis[o],i=new t(a(s[1]));r[e]=s[2]===void 0?i:i.subarray(s[2],s[3]);break}case`ArrayBuffer`:{let t=s[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);r[e]=St(t);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`:{let t=o.slice(9);r[e]=Temporal[t].from(s[1]);break}case`URL`:r[e]=new URL(s[1]);break;case`URLSearchParams`:r[e]=new URLSearchParams(s[1]);break;default:throw Error(`Unknown type ${o}`)}}else if(s[0]===-7){let t=s[1],n=Array(t);r[e]=n;for(let e=2;e<s.length;e+=2){let t=s[e];n[t]=a(s[e+1])}}else{let t=Array(s.length);r[e]=t;for(let e=0;e<s.length;e+=1){let n=s[e];n!==-2&&(t[e]=a(n))}}else{let t={};r[e]=t;for(let e of Object.keys(s)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");let n=s[e];t[e]=a(n)}}return r[e]}return a(0)}function P(e,t){let n=[],r=new Map,i=[];if(t)for(let e of Object.getOwnPropertyNames(t))i.push({key:e,fn:t[e]});let a=[],o=0;function s(t){if(t===void 0)return-1;if(Number.isNaN(t))return-3;if(t===1/0)return-4;if(t===-1/0)return-5;if(t===0&&1/t<0)return-6;if(r.has(t))return r.get(t);let c=o++;r.set(t,c);for(let{key:e,fn:r}of i){let i=r(t);if(i)return n[c]=`["${e}",${s(i)}]`,c}if(typeof t==`function`)throw new M(`Cannot stringify a function`,a,t,e);let l=``;if(dt(t))l=Ot(t);else{let n=mt(t);switch(n){case`Number`:case`String`:case`Boolean`:l=`["Object",${Ot(t)}]`;break;case`BigInt`:l=`["BigInt",${t}]`;break;case`Date`:l=`["Date","${isNaN(t.getDate())?``:t.toISOString()}"]`;break;case`URL`:l=`["URL",${N(t.toString())}]`;break;case`URLSearchParams`:l=`["URLSearchParams",${N(t.toString())}]`;break;case`RegExp`:let{source:r,flags:i}=t;l=i?`["RegExp",${N(r)},"${i}"]`:`["RegExp",${N(r)}]`;break;case`Array`:{let e=!1;l=`[`;for(let n=0;n<t.length;n+=1)if(n>0&&(l+=`,`),Object.hasOwn(t,n))a.push(`[${n}]`),l+=s(t[n]),a.pop();else if(e)l+=-2;else{let n=bt(t),r=n.length,i=String(t.length).length;if((t.length-r)*3>4+i+r*(i+1)){l=`[-7,`+t.length;for(let e=0;e<n.length;e++){let r=n[e];a.push(`[${r}]`),l+=`,`+r+`,`+s(t[r]),a.pop()}break}else e=!0,l+=-2}l+=`]`;break}case`Set`:l=`["Set"`;for(let e of t)l+=`,${s(e)}`;l+=`]`;break;case`Map`:l=`["Map"`;for(let[e,n]of t)a.push(`.get(${dt(e)?Ot(e):`...`})`),l+=`,${s(e)},${s(n)}`,a.pop();l+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:{let e=t;l=`["`+n+`",`+s(e.buffer);let r=t.byteOffset,i=r+t.byteLength;if(r>0||i!==e.buffer.byteLength){let e=/(\d+)/.exec(n)[1]/8;l+=`,${r/e},${i/e}`}l+=`]`;break}case`ArrayBuffer`:l=`["ArrayBuffer","${xt(t)}"]`;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`:l=`["${n}",${N(t.toString())}]`;break;default:if(!pt(t))throw new M(`Cannot stringify arbitrary non-POJOs`,a,t,e);if(gt(t).length>0)throw new M(`Cannot stringify POJOs with symbolic keys`,a,t,e);if(Object.getPrototypeOf(t)===null){l=`["null"`;for(let n of Object.keys(t)){if(n===`__proto__`)throw new M(`Cannot stringify objects with __proto__ keys`,a,t,e);a.push(vt(n)),l+=`,${N(n)},${s(t[n])}`,a.pop()}l+=`]`}else{l=`{`;let n=!1;for(let r of Object.keys(t)){if(r===`__proto__`)throw new M(`Cannot stringify objects with __proto__ keys`,a,t,e);n&&(l+=`,`),n=!0,a.push(vt(r)),l+=`${N(r)}:${s(t[r])}`,a.pop()}l+=`}`}}}return n[c]=l,c}let c=s(e);return c<0?`${c}`:`[${n.join(`,`)}]`}function Ot(e){let t=typeof e;return t===`string`?N(e):e instanceof String?N(e.toString()):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var kt=Ce(),At=e(ut(),1);async function F(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 jt(e,t){let n=globalThis.crypto.getRandomValues(new Uint8Array(12)),r=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:n,tagLength:128},e,t),i=new Uint8Array(12+r.byteLength);return i.set(n,0),i.set(new Uint8Array(r),12),i}async function Mt(e,t){if(t.byteLength<28)throw new c(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`);let n=t.subarray(0,12),r=t.subarray(12),i=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:n,tagLength:128},e,r);return new Uint8Array(i)}function I(){return{...f(),pendingOps:0,doneResolved:!1,streamEnded:!1}}function Nt(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Pt(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function Ft(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}Nt(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.writablePollingInterval=void 0)},10);t.writablePollingInterval=n}function It(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}Pt(e)&&t.pendingOps===0&&(t.doneResolved=!0,t.resolve(),clearInterval(n),t.readablePollingInterval=void 0)},10);t.readablePollingInterval=n}async function L(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.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(a).catch(()=>{}),r.releaseLock(),i.releaseLock()}}const Lt=Symbol.for(`@workflow/world//cache`),Rt=Symbol.for(`@workflow/world//cachePromise`),zt=Symbol.for(`@workflow/world//getWorldFn`);async function R(){let e=globalThis;if(e[Lt])return e[Lt];if(e[Rt])return e[Lt]=await e[Rt],e[Lt];let t=e[zt];if(t)return t();let{getWorld:n}=await import([`./world`,`js`].join(`.`));return n()}const Bt=Symbol.for(`workflow-serialize`),Vt=Symbol.for(`workflow-deserialize`);function Ht(e=globalThis){let t=e,n=t[ee];return n||(n=new Map,t[ee]=n),n}function Ut(e,t){return Ht(t).get(e)}function Wt(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=e.classId;return typeof t==`string`?{classId:t}:!1},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=e.constructor;if(!t||typeof t!=`function`)return!1;let n=t[Bt];if(typeof n!=`function`)return!1;let r=t.classId;if(typeof r!=`string`)throw Error(`Class "${t.name}" with ${String(Bt)} must have a static "classId" property.`);return{classId:r,data:n.call(t,e)}}}}function Gt(e=globalThis){return{Class:t=>{let n=t.classId,r=Ut(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=Ut(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[Vt];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(Vt)} method.`);return a.call(i,r)}}}function Kt(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function z(e){return Kt(e.buffer,e.byteOffset,e.byteLength)}function B(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 qt(e){return JSON.parse(e)}function Jt(e){if(!ue.isNativeError(e))return!1;let t={message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t}function Yt(e,t){return!ue.isNativeError(t)||t.name!==e?!1:Jt(t)}function V(e){return t=>Yt(e,t)||!1}function H(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 Xt(e=globalThis){return{ArrayBuffer:t=>t instanceof e.ArrayBuffer&&Kt(t,0,t.byteLength),BigInt:e=>typeof e==`bigint`&&e.toString(),BigInt64Array:t=>t instanceof e.BigInt64Array&&z(t),BigUint64Array:t=>t instanceof e.BigUint64Array&&z(t),Date:t=>t instanceof e.Date?Number.isNaN(t.getDate())?`.`:t.toISOString():!1,DOMException:e=>{if(typeof e!=`object`||!e||e.constructor?.name!==`DOMException`)return!1;let t=e,n={message:t.message,name:t.name,stack:t.stack};return`cause`in t&&(n.cause=t.cause),n},EvalError:V(`EvalError`),FatalError:V(`FatalError`),HookConflictError:e=>{let t=Yt(`HookConflictError`,e);if(!t)return!1;let n=e,r={...t,token:n.token};return n.conflictingRunId!==void 0&&(r.conflictingRunId=n.conflictingRunId),r},RangeError:V(`RangeError`),ReferenceError:V(`ReferenceError`),RetryableError:e=>{let t=Yt(`RetryableError`,e);if(!t)return!1;let n=e.retryAfter,r;if(n&&typeof n==`object`&&typeof n.getTime==`function`){let e=n.getTime();r=Number.isNaN(e)?Date.now()+1e3:e}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}},SyntaxError:V(`SyntaxError`),TypeError:V(`TypeError`),URIError:V(`URIError`),AggregateError:e=>{let t=Yt(`AggregateError`,e);return t?{...t,errors:e.errors}:!1},Error:e=>{if(!ue.isNativeError(e))return!1;let t={name:e.name,message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t},Float32Array:t=>t instanceof e.Float32Array&&z(t),Float64Array:t=>t instanceof e.Float64Array&&z(t),Headers:t=>t instanceof e.Headers&&Array.from(t),Int8Array:t=>t instanceof e.Int8Array&&z(t),Int16Array:t=>t instanceof e.Int16Array&&z(t),Int32Array:t=>t instanceof e.Int32Array&&z(t),Map:t=>t instanceof e.Map&&Array.from(t),RegExp:t=>t instanceof e.RegExp&&{source:t.source,flags:t.flags},Set:t=>t instanceof e.Set&&Array.from(t),URL:t=>t instanceof e.URL&&t.href,WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=e.workflowId;return typeof t==`string`?{workflowId:t}:!1},URLSearchParams:t=>t instanceof e.URLSearchParams?t.size===0?`.`:String(t):!1,Uint8Array:t=>t instanceof e.Uint8Array&&z(t),Uint8ClampedArray:t=>t instanceof e.Uint8ClampedArray&&z(t),Uint16Array:t=>t instanceof e.Uint16Array&&z(t),Uint32Array:t=>t instanceof e.Uint32Array&&z(t)}}function Zt(e=globalThis){return{ArrayBuffer:t=>B(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(B(t,e)),BigUint64Array:t=>new e.BigUint64Array(B(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:H(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??u)(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`)]??l)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:H(e,`RangeError`),ReferenceError:H(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??h)(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},SyntaxError:H(e,`SyntaxError`),TypeError:H(e,`TypeError`),URIError:H(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(B(t,e)),Float64Array:t=>new e.Float64Array(B(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(B(t,e)),Int16Array:t=>new e.Int16Array(B(t,e)),Int32Array:t=>new e.Int32Array(B(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(B(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(B(t,e)),Uint16Array:t=>new e.Uint16Array(B(t,e)),Uint32Array:t=>new e.Uint32Array(B(t,e))}}function Qt(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=e.stepId;if(typeof t!=`string`)return!1;let n=e.__closureVarsFn,r=n&&typeof n==`function`?n():void 0,i=`__boundThis`in e,a=i?e.__boundThis:void 0,o=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 $t(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 en(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const U={DEVALUE_V1:`devl`,ENCRYPTED:`encr`},tn=new TextEncoder,nn=new TextDecoder;function rn(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Wt(),...Qt(),...Xt(t)};break;case`step`:r={...Wt(),...Xt(t)};break;case`client`:r={...Wt(),...Xt(t)};break}return n?{...r,...n}:r}function an(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Gt(t),...$t(t),...Zt(t)};break;case`step`:r={...Gt(t),...Zt(t)};break;case`client`:r={...Gt(t),...Zt(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}};break}return n?{...r,...n}:r}const W={formatPrefix:U.DEVALUE_V1,serialize(e,t,n){let r=P(e,rn(t,n?.global,n?.extraReducers));return tn.encode(r)},deserialize(e,t,n){let r=an(t,n?.global,n?.extraRevivers);return Et(nn.decode(e),r)},deserializeLegacy(e,t,n){return Dt(e,an(t,n?.global,n?.extraRevivers))}},on=new TextEncoder,sn=new TextDecoder;function G(e,t){if(!(t instanceof Uint8Array))return t;let n=on.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function cn(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=sn.decode(t);return en(n)?n:null}function K(e){if(!(e instanceof Uint8Array))return{format:U.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=sn.decode(t);if(!en(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}async function ln(e,t){if(!t||!(e instanceof Uint8Array))return e;let n=await jt(t,e);return G(U.ENCRYPTED,n)}async function un(e,t){if(!(e instanceof Uint8Array))return e;let n=cn(e);if(n===U.ENCRYPTED&&!t)throw new c(`Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`);if(n!==U.ENCRYPTED)return e;let{payload:r}=K(e);return Mt(t,r)}function dn(e,t,n){let[r,...i]=t.split(`
3
+ `),a=i.join(`
4
+ `),o=fn(r??``,n),s=pn(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
5
+ `)}function fn(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 i=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`hint`,`attempt`,`retryCount`]),a=[],o=q(t,`errorName`),s=q(t,`errorAttribution`);if(o||s){let e=s?s===`sdk`?y(`sdk error`):v(`user error`):``,t=o?te(o):``,n=e&&t?D(` · `):``;a.push(` ${e}${n}${t}`)}let c=q(t,`workflowRunId`),l=q(t,`workflowName`);c?a.push(gn(`run`,c,l,d)):l&&a.push(gn(`run`,null,l,d));let u=q(t,`stepId`),f=q(t,`stepName`);if((u||f)&&a.push(gn(`step`,u,f,r)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?a.push(` ${hn(`retry`)} ${e} ${D(`attempts ·`)} ${n} ${D(`max retries`)}`):e!==void 0&&a.push(` ${hn(`retry`)} ${e} ${D(`attempts`)}`)}let p=q(t,`errorCode`);p&&p!==o&&a.push(` ${hn(`code`)} ${D(p)}`);let m=q(t,`hint`);m&&a.push(` ${ae(m)}`);let h=Object.entries(t).filter(([e,t])=>!i.has(e)&&!n.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of h)a.push(` ${hn(e)} ${_n(t)}`);return a.length?a.join(`
6
+ `):null}function pn(e){if(!e)return null;let t=e.split(`
7
+ `),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&&mn(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(`
8
+ `)}function mn(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 q(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function hn(e){return D(e.padEnd(6))}function gn(e,t,n,r){let o=t||D(`—`),s=n&&(e===`run`?a(n):i(n))?`${D(`·`)} ${r(n)}`:``;return` ${hn(e)} ${o}${s?` `+s:``}`}function _n(e){if(typeof e==`string`)return e.includes(`
9
+ `)?e.split(`
10
+ `).map((e,t)=>t===0?e:` ${e}`).join(`
11
+ `):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var vn=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,a=0,o=0,c=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?o++:e.abortRequested?c++:i++:e.type===`wait`&&a++;let l=[];r>0&&l.push(`${r} ${s(`step`,`steps`,r)}`),i>0&&l.push(`${i} ${s(`hook`,`hooks`,i)}`),a>0&&l.push(`${a} ${s(`wait`,`waits`,a)}`),o>0&&l.push(`${o} hook ${s(`disposal`,`disposals`,o)}`);let u=s(`has`,`have`,r+i+a+o),d=+(r>0)+ +(i>0)+ +(a>0)+ +(o>0),f;f=d>1?`processed`:r>0?`run`:i>0||a>0?`created`:o>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.hookDisposedCount=o,this.abortCount=c}static is(t){return t instanceof e}};function yn(){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 bn=J(`workflow.name`),xn=J(`workflow.operation`),Sn=J(`workflow.run.id`),Cn=J(`workflow.run.status`),wn=J(`workflow.started_at`),Tn=J(`workflow.events.count`),En=J(`workflow.arguments.count`),Dn=J(`workflow.result.type`),On=J(`workflow.trace.propagated`),kn=J(`workflow.error.name`),An=J(`workflow.error.message`),jn=J(`workflow.error.code`),Mn=J(`workflow.steps.created`),Nn=J(`workflow.hooks.created`),Pn=J(`workflow.waits.created`),Fn=J(`step.name`),In=J(`step.id`),Ln=J(`step.attempt`),Rn=J(`step.status`),zn=J(`step.max_retries`),Bn=J(`step.skipped`),Vn=J(`step.skip_reason`),Hn=J(`step.arguments.count`),Un=J(`step.result.type`),Wn=J(`step.error.name`),Gn=J(`step.error.message`),Kn=J(`step.fatal_error`),qn=J(`step.retry.exhausted`),Jn=J(`step.retry.timeout_seconds`),Yn=J(`step.retry.will_retry`),Xn=J(`messaging.system`),Zn=J(`messaging.destination.name`),Qn=J(`messaging.message.id`),$n=J(`messaging.operation.type`),er=J(`workflow.queue.overhead_ms`),tr=J(`deployment.id`),nr=J(`workflow.hook.token`),rr=J(`workflow.hook.id`),ir=J(`workflow.hook.found`),ar=J(`workflow.suspension.state`),or=J(`workflow.suspension.hook_count`),sr=J(`workflow.suspension.step_count`),cr=J(`workflow.suspension.wait_count`),lr=J(`error.type`),ur=J(`workflow.events.pages_loaded`),dr=J(`workflow.queue.deserialize_time_ms`),fr=J(`workflow.queue.execution_time_ms`),pr=J(`workflow.queue.serialize_time_ms`),mr=J(`peer.service`),hr=J(`rpc.system`),gr=J(`rpc.service`),_r=J(`rpc.method`),vr=J(`error.retryable`),yr=J(`error.category`);async function br(){let e=await Y.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function xr(e){let t=await Y.value;if(t)return t.propagation.extract(t.context.active(),e)}async function Sr(e,t){if(!e)return t();let n=await Y.value;if(!n)return t();let r=await xr(e);return r?n.context.with(r,async()=>await t()):t()}const Y=o(async()=>{try{return await import(`./src-ClRYdO4-.js`).then(t=>e(t.t(),1))}catch{return Fr.info(`OpenTelemetry not available, tracing will be disabled`),null}}),Cr=o(async()=>{let e=await Y.value;return e?e.trace.getTracer(`workflow`):null});async function wr(e,...t){let[n,r]=await Promise.all([Cr.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}),Tr(t,r,e),t}finally{e.end()}})}function Tr(e,t,n){!e||!vn.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({...ar(`suspended`),...sr(e.stepCount),...or(e.hookCount),...cr(e.waitCount)}))}async function Er(e){let[t,n]=await Promise.all([xr(e),Y.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function Dr(){return await kr(e=>e.trace.getActiveSpan())}async function Or(e){return kr(t=>t.SpanKind[e])}async function kr(e){let t=await Y.value;if(t)return await e(t)}function Ar(){return kr(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function jr(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 Mr(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 Nr(e){let t=n=>{let r=t=>{let r=`workflow:${e}:${t}`;return(i,a)=>{let o=Object.keys(n).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...n,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(dn(`[workflow-sdk]`,i,c)),Mr(r,process.env.DEBUG)&&(console.debug(`[${r}] ${i}`,c??``),Dr().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:r(`debug`),info:r(`info`),warn:r(`warn`),error:r(`error`),child:e=>t({...n,...e}),forRun:(e,r,i)=>t({...n,workflowRunId:e,...r===void 0?{}:{workflowName:r},...i??{}})}};return t({})}const Pr=Nr(`step`),Fr=Nr(`runtime`),Ir=Nr(`webhook`),Lr=Nr(`events`);Nr(`adapter`);function X(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof M&&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 M&&t.value!==void 0&&Fr.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function Rr(e,t,n){try{let r=W.serialize(e,`client`,n);return ln(G(U.DEVALUE_V1,r),t)}catch(e){let{message:t,hint:n}=X(`client value`,e);throw new _(t,{hint:n,cause:e})}}async function zr(e,t,n){let r=await un(e,t);if(!(r instanceof Uint8Array)){if(W.deserializeLegacy)return W.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=K(r);if(i===U.DEVALUE_V1)return W.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function Br(e,t,n){try{let r=W.serialize(e,`step`,n);return ln(G(U.DEVALUE_V1,r),t)}catch(e){let{message:t,hint:n}=X(`step value`,e);throw new _(t,{hint:n,cause:e})}}async function Vr(e,t,n){let r=await un(e,t);if(!(r instanceof Uint8Array)){if(W.deserializeLegacy)return W.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=K(r);if(i===U.DEVALUE_V1)return W.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function Hr(e,t){if(!(e instanceof Uint8Array)){if(W.deserializeLegacy)return W.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=K(e);if(n===U.DEVALUE_V1)return W.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const Ur=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),Wr=globalThis[Ur]??(globalThis[Ur]=new de);function Gr(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${s(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${s(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${s(`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 Kr(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function qr(e){return`strm_${e}_system_abort`}function Jr(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return qr(e.slice(5))}async function Yr(e){let t=e();return(0,kt.waitUntil)(t.catch(()=>{})),t}var Z;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Z||={});var Xr=class{eventIndex;events=[];callbacks=[];onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,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)}consume=()=>{let e=this.events[this.eventIndex]??null;for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Z.NotConsumed;try{r=n(e)}catch(e){Lr.error(`EventConsumer callback threw an error`,{error:e})}if(r===Z.Consumed||r===Z.Finished){this.eventIndex++,r===Z.Finished&&this.callbacks.splice(t,1),process.nextTick(this.consume);return}}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))},100)})}}},Zr=class{aborted=!1;reason=void 0;[S];[E];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[S]=e,this[E]=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 Qr(e){return class{signal;[S];[E];constructor(){let t=e.generateUlid(),n=qr(t),r=`abrt_${t}`;this[S]=n,this[E]=r,this.signal=new Zr(n,r);let i=`hook_${e.generateUlid()}`;e.invocationsQueue.set(i,{type:`hook`,correlationId:i,token:r,isWebhook:!1,isSystem:!0}),e.eventsConsumer.subscribe(t=>{if(!t||t.correlationId!==i)return Z.NotConsumed;let n=`eventData`in t&&t.eventData&&`token`in t.eventData?t.eventData.token:void 0;if(typeof n==`string`&&n!==this[E])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new g(`Corrupted event log: abort hook event ${t.eventType} for ${i} belongs to token "${n}", but the current abort hook expects "${this[E]}"`))}),Z.Finished;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(i);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Z.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload;return e.promiseQueue=e.promiseQueue.then(async()=>{let t;if(n!==void 0)try{let r=await Pi(n,e.runId,e.encryptionKey,e.globalThis);r&&typeof r==`object`&&`reason`in r&&(t=r.reason)}catch{}this.signal._setAborted(t)}),e.invocationsQueue.delete(i),Z.Finished}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(i),Z.Finished):Z.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[E]){n.abortRequested=!0,n.abortReason=t;break}}}}}function $r(){return{abort(e){let t=new Zr(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new Zr(``,``),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 ei=oe();function ti(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function Q(e){return e instanceof _&&e.cause!==void 0||e instanceof c&&e.cause!==void 0?e.cause:e}function ni(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0};return new TransformStream({async transform(i,a){try{r.resolved||=(r.key=await t,!0);let o=P(i,e),s=n.encode(o),c=G(U.DEVALUE_V1,s);if(r.key){let e=await jt(r.key,c);c=G(U.ENCRYPTED,e)}let l=new Uint8Array(4+c.length);new DataView(l.buffer).setUint32(0,c.length,!1),l.set(c,4),a.enqueue(l)}catch(e){let{message:t,hint:n}=X(`stream chunk`,e);a.error(new _(t,{hint:n,cause:e}))}}})}function ri(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0};function a(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function o(a){for(i.resolved||=(i.key=await t,!0);r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let o=r.slice(4,4+t);r=r.slice(4+t);let{format:s,payload:l}=K(o);if(s===U.ENCRYPTED){if(!i.key){a.error(new c(`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`));return}let e=await Mt(i.key,l);({format:s,payload:l}=K(e))}if(s===U.DEVALUE_V1){let t=n.decode(l);a.enqueue(Et(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){a(t),await o(i);return}}else if(r.length>0){a(t),await o(i);return}let s=n.decode(t).split(`
12
+ `);for(let t of s)t.length>0&&i.enqueue(Et(t,e))},async flush(e){r.length>0&&await o(e)}})}var ii=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new c(`"name" is required, got "${t}"`);super({type:`bytes`,pull:async r=>{let i=this.#e;if(!i){let r=await(await R()).streams.get(e,t,n);i=this.#e=r.getReader()}if(!i){r.error(Error(`Failed to get reader`));return}let a=await i.read();a.done?(this.#e=void 0,r.close()):r.enqueue(a.value)},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}},$=class extends WritableStream{constructor(e,t){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 n=R(),r=[],i=null,a=null,o,s=async()=>{if(i&&=(clearTimeout(i),null),r.length===0)return;let a=r.slice(),s=await n;if(o===void 0&&(o=s.streamFlushIntervalMs??10),typeof s.streams.writeMulti==`function`&&a.length>1)await s.streams.writeMulti(e,t,a);else for(let n of a)await s.streams.write(e,t,n);r=[]},l=[],u=()=>{i||=setTimeout(()=>{i=null;let e=l;l=[],a=s().then(()=>{for(let t of e)t.resolve()},t=>{for(let n of e)n.reject(t)})},o??10)};super({async write(e){a&&=(await a,null),r.push(e),u(),await new Promise((e,t)=>{l.push({resolve:e,reject:t})})},async close(){a&&=(await a,null),await s(),await(await n).streams.close(e,t)},abort(e){i&&=(clearTimeout(i),null),r=[];let t=l;l=[];let n=e??Error(`Stream aborted`);for(let e of t)e.reject(n)}})}};function ai(e=globalThis){return{...Wt(),...Qt(),...Xt(e),Request:t=>{if(!(t instanceof e.Request))return!1;let n={method:t.method,url:t.url,headers:t.headers,body:t.body,duplex:t.duplex},r=t[ie];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[S])&&(n.signal=t.signal),n},Response:t=>t instanceof e.Response?{type:t.type,url:t.url,status:t.status,statusText:t.statusText,headers:t.headers,body:t.body,redirected:t.redirected}:!1}}function oi(e,t,n,r,i,a){let o=t[S],s=t[E];if(!o){let e=(n[C]||ei)();o=qr(e),s=`abrt_${e}`,t[S]=o,t[E]=s,t.signal&&(t.signal[S]=o,t.signal[E]=s)}return ci(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function si(e,t){let n=t[S]??t.signal?.[S],r=t[E]??t.signal?.[E];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 ci(e,t,n,r,i){e.aborted||e[re]||(e[re]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await r,a=await Di({aborted:!0,reason:e.reason},n,i),o=new $(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function li(e=globalThis,t,n,r){return{...ai(e),ReadableStream:i=>{if(!(i instanceof e.ReadableStream))return!1;if(i.locked)throw new _(`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 a=`strm_${(e[C]||ei)()}`,o=ti(i),s=new $(n,a);o===`bytes`?t.push(i.pipeTo(s)):t.push(i.pipeThrough(ni(li(e,t,n,r),r)).pipeTo(s));let c={name:a};return o&&(c.type=o),c},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[T],a=r[x];if(typeof i==`string`&&typeof a==`string`)return{name:i,runId:a};let o=`strm_${(e[C]||ei)()}`,s=new ii(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:oi(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:oi(i,i,e,t,n,r)}}function ui(e=globalThis){return{...ai(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[b];if(n!==void 0)return{bodyInit:n};let r=t[T];if(!r)throw new c("ReadableStream `name` is not set");let i={name:r},a=t[ne];return a&&(i.type=a),i},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[T];if(!n)throw new c("WritableStream `name` is not set");let r={name:n},i=t[x];return typeof i==`string`&&(r.runId=i),r},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[S]??n.signal?.[S],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:si(t.signal,n)},AbortSignal:t=>{let n=t,r=n&&n[S],i=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!r&&!i?!1:si(t,t)}}}function di(e=globalThis,t,n,r){return{...ai(e),ReadableStream:i=>{if(!(i instanceof e.ReadableStream))return!1;if(i.locked)throw new _(`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 a=i[T],o=i[ne];if(!a){a=`strm_${(e[C]||ei)()}`,o=ti(i);let s=new $(n,a);o===`bytes`?t.push(i.pipeTo(s)):t.push(i.pipeThrough(ni(di(e,t,n,r),r)).pipeTo(s))}let s={name:a};return o&&(s.type=o),s},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[T],o=i[x];a||(a=`strm_${(e[C]||ei)()}`,t.push(new ii(n,a).pipeThrough(ri(bi(e,t,n,r),r)).pipeTo(i)));let s={name:a};return typeof o==`string`&&(s.runId=o),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:oi(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:oi(i,i,e,t,n,r)}}function fi(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new ii(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(r.releaseLock(),a.value&&!a.done)try{let n=Wr.getStore(),r=await Oi(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}catch{}})()),i}function pi(e,t,n){let r=e,i=e.signal;r[S]=t.streamName,r[E]=t.hookToken,i[S]=t.streamName,i[E]=t.hookToken,n&&(r[w]=n,i[w]=n)}function mi(e,t){let n=e,r=t;n[S]!==void 0&&(r[S]=n[S]),n[E]!==void 0&&(r[E]=n[E]),n[w]!==void 0&&(r[w]=n[w])}function hi(e,t,n){let r=new AbortController;e.aborted?(pi(r,e),r.abort(e.reason)):e.streamName?pi(r,e,fi(r,n,e.streamName,t)):pi(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=Wr.getStore();n&&(n.ops.push((async()=>{try{let r=await Di({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new $(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken&&n.ops.push((async()=>{try{let{resumeHook:n}=await Promise.resolve().then(()=>ia);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})()))},r}function gi(e,t,n){let r=new AbortController;return e.aborted?(pi(r,e),r.abort(e.reason)):e.streamName?pi(r,e,fi(r,n,e.streamName,t)):pi(r,e),r.signal}function _i(e=globalThis){return{...Gt(e),...Zt(e)}}function vi(e=globalThis,t,n,r){return{..._i(e),StepFunction:()=>{throw new _(`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 _(`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&&mi(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}let a=new ii(n,i.name,i.startIndex);if(i.type===`bytes`){let n=I();t.push(n.promise);let{readable:r,writable:i}=new e.TransformStream;return L(a,i,n).catch(()=>{}),It(r,n),r}else{let i=ri(vi(e,t,n,r),r),o=I();return t.push(o.promise),L(a,i.writable,o).catch(()=>{}),It(i.readable,o),i.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:(async()=>{let e=await(await R()).getEncryptionKeyForRun?.(a);return e?await F(e,[`encrypt`]):void 0})(),s=ni(li(e,t,a,o),o),c=new $(a,i.name),l=I();return t.push(l.promise),L(s.readable,c,l).catch(()=>{}),Ft(s.writable,l),Object.defineProperty(s.writable,T,{value:i.name,writable:!1}),Object.defineProperty(s.writable,x,{value:a,writable:!1}),s.writable},AbortController:e=>hi(e,t,n),AbortSignal:e=>gi(e,t,n)}}function yi(e=globalThis){return{..._i(e),...$t(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[ie]=n,delete t.responseWritable,t.respondWith=()=>{throw new _("`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 _(`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,{[b]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[T]:{value:t.name,writable:!1},[ne]:{value:t.type,writable:!1}}),WritableStream:t=>{let n={[T]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[x]={value:t.runId,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new Zr(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[S]:e.streamName,[E]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new Zr(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function bi(e=globalThis,t,n,r){return{..._i(e),StepFunction:e=>{let t=e.stepId,n=e.closureVars,r=`boundThis`in e,i=r?e.boundThis:void 0,a=Array.isArray(e.boundArgs)?e.boundArgs:[],o=le(t);if(!o)throw new _(`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(!n&&!r&&a.length===0)return o;let s=function(...e){let t=r?i:this,s=a.length>0?[...a,...e]:e;if(n){let e=Wr.getStore();if(!e)throw new c(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return Wr.run(r,()=>o.apply(t,s))}return o.apply(t,s)};return Object.defineProperty(s,`name`,{value:o.name}),Object.defineProperty(s,`stepId`,{value:t,writable:!1,enumerable:!1,configurable:!1}),o.maxRetries!==void 0&&(s.maxRetries=o.maxRetries),s},WorkflowFunction:e=>Object.assign(()=>{throw new _(`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&&mi(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:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}let a=new ii(n,i.name);if(i.type===`bytes`){let n=I();t.push(n.promise);let{readable:r,writable:i}=new e.TransformStream;return L(a,i,n).catch(()=>{}),It(r,n),r}else{let i=ri(bi(e,t,n,r),r),o=I();return t.push(o.promise),L(a,i.writable,o).catch(()=>{}),It(i.readable,o),i.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:(async()=>{let e=await(await R()).getEncryptionKeyForRun?.(a);return e?await F(e,[`encrypt`]):void 0})(),s=ni(di(e,t,a,o),o),c=new $(a,i.name),l=I();return t.push(l.promise),L(s.readable,c,l).catch(()=>{}),Ft(s.writable,l),Object.defineProperty(s.writable,T,{value:i.name,writable:!1}),Object.defineProperty(s.writable,x,{value:a,writable:!1}),s.writable},AbortController:e=>hi(e,t,n),AbortSignal:e=>gi(e,t,n)}}async function xi(e,t){return await ln(e,t)}async function Si(e,t){return un(e,t)}async function Ci(e,t,n,r=[],i=globalThis,a=!1){if(a)return qt(P(e,li(i,r,t,n)));try{return await Rr(e,n,{global:i,extraReducers:Ii(li(i,r,t,n))})}catch(e){let t=Q(e),{message:n,hint:r}=X(`workflow arguments`,t);throw new _(n,{hint:r,cause:t})}}async function wi(e,t,n,r=globalThis,i={}){return Hr(await Si(e,n),{global:r,extraRevivers:{...Li(yi(r)),...i}})}async function Ti(e,t,n,r=globalThis,i=!1){if(i)return qt(P(e,ui(r)));try{return await Br(e,n,{global:r,extraReducers:Ii(ui(r))})}catch(e){let t=Q(e),{message:n,hint:r}=X(`workflow return value`,t);throw new _(n,{hint:r,cause:t})}}async function Ei(e,t,n,r=[],i=globalThis,a={}){return zr(e,n,{global:i,extraRevivers:{...Li(vi(i,r,t,n)),...a}})}async function Di(e,t,n,r=globalThis,i=!1){if(i)return qt(P(e,ui(r)));try{return await Br(e,n,{global:r,extraReducers:Ii(ui(r))})}catch(e){let t=Q(e),{message:n,hint:r}=X(`step arguments`,t);throw new _(n,{hint:r,cause:t})}}async function Oi(e,t,n,r=[],i=globalThis,a={}){return Vr(e,n,{global:i,extraRevivers:{...Li(bi(i,r,t,n)),...a}})}async function ki(e,t,n,r=[],i=globalThis,a=!1){if(a)return qt(P(e,di(i,r,t,n)));try{return await Br(e,n,{global:i,extraReducers:Ii(di(i,r,t,n))})}catch(e){let t=Q(e),{message:n,hint:r}=X(`step return value`,t);throw new _(n,{hint:r,cause:t})}}async function Ai(e,t,n,r=[],i=globalThis){try{let a=P(e,di(i,r,t,n)),o=new TextEncoder().encode(a);return await xi(G(U.DEVALUE_V1,o),n)}catch(e){let t=Q(e),{message:n,hint:r}=X(`step error`,t);throw new _(n,{hint:r,cause:t})}}async function ji(e,t,n,r=globalThis,i={}){let a=await Si(e,n);if(!(a instanceof Uint8Array))return Dt(a,{...yi(r),...i});let{format:o,payload:s}=K(a);if(o===U.DEVALUE_V1)return Et(new TextDecoder().decode(s),{...yi(r),...i});throw Error(`Unsupported serialization format: ${o}`)}async function Mi(e,t,n,r=globalThis){try{let t=P(e,ui(r)),i=new TextEncoder().encode(t);return await xi(G(U.DEVALUE_V1,i),n)}catch(e){let t=Q(e),{message:n,hint:r}=X(`run error`,t);throw new _(n,{hint:r,cause:t})}}async function Ni(e,t,n,r=[],i=globalThis,a={}){let o=await Si(e,n);if(!(o instanceof Uint8Array))return Dt(o,{...vi(i,r,t,n),...a});let{format:s,payload:c}=K(o);if(s===U.DEVALUE_V1)return Et(new TextDecoder().decode(c),{...vi(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${s}`)}async function Pi(e,t,n,r=globalThis,i={}){return Hr(await Si(e,n),{global:r,extraRevivers:{...Li(yi(r)),...i}})}const Fi=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function Ii(e){let t={};for(let n of Fi)n in e&&(t[n]=e[n]);return t}function Li(e){let t={};for(let n of Fi)n in e&&(t[n]=e[n]);return t}const Ri=[{format:U.ENCRYPTED,minVersion:`4.2.0-beta.64`}],zi=new Set([U.DEVALUE_V1]);function Bi(e){if(!e||!At.default.valid(e))return{supportedFormats:zi};let t=new Set(zi);for(let{format:n,minVersion:r}of Ri)At.default.gte(e,r)&&t.add(n);return{supportedFormats:t}}const Vi=`5.0.0-beta.7`,Hi=/^[a-zA-Z0-9_\-./@]+$/;function Ui(e){if(!Hi.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`__wkf_workflow_${e}`}const Wi=oe();function Gi(e){return`__health_check__${e}`}function Ki(e){let t=se.safeParse(e);if(t.success)return t.data}function qi(e){return`wrun_hc_${e}`}async function Ji(e,t,n){let r=await R(),i=Gi(e.correlationId),a=JSON.stringify({healthy:!0,endpoint:t,correlationId:e.correlationId,specVersion:n??3,workflowCoreVersion:Vi,timestamp:Date.now()}),o=qi(e.correlationId);await r.streams.write(o,i,a),await r.streams.close(o,i)}async function Yi(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 Xi(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),s}async function Zi(e,t,n){let r=n?.timeout??3e4,i=Wi(),a=Gi(i),o=t===`workflow`?`__wkf_workflow_health_check`:`__wkf_step_health_check`,s=Date.now();try{for(await e.queue(o,{__healthCheck:!0,correlationId:i},{specVersion:1,deploymentId:n?.deploymentId});Date.now()-s<r;)try{let t=(await e.streams.get(qi(i),a)).getReader(),{chunks:n,timedOut:r}=await Yi(t,500);if(r){try{t.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let o=Xi(n);if(o)return{...o,latencyMs:Date.now()-s};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${r}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}async function Qi(e,t){let n=t!==void 0;return wr(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...Sn(e)});let i=[],a=t??null,o=!0,s=0,c=await R(),l=Date.now();for(;o;){let t=Date.now(),r=await c.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:a??void 0}});i.push(...r.data),o=r.hasMore,a=r.cursor??a,s++,Fr.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:s,pageEvents:r.data.length,totalEvents:i.length,hasMore:o,pageMs:Date.now()-t})}return Fr.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:s,totalMs:Date.now()-l}),r?.setAttributes({...Tn(i.length),...ur(s)}),{events:i,cursor:a}})}const $i={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function ea(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:$i}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??3,workflowCoreVersion:Vi}),{status:200,headers:{"Content-Type":`application/json`,...$i}}):await e(n)}}async function ta(e,...t){let n=t[0];await wr(`queue.publish`,{attributes:{...Xn(`vercel-queue`),...Zn(n),...$n(`publish`),...mr(`vercel-queue`),...hr(`vercel-queue`),...gr(`vqs`),..._r(`publish`)},kind:await Or(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(Qn(r))})}function na(e){if(e.requestedAt)try{return er(Date.now()-e.requestedAt.getTime())}catch{return}}function ra(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await F(n):void 0})(),n)}var ia=t({getHookByToken:()=>oa,resumeHook:()=>sa,resumeWebhook:()=>ca});async function aa(e){let t=await R(),n=await t.hooks.getByToken(e),r=await t.runs.get(n.runId),i=await t.getEncryptionKeyForRun?.(r),a=i?await F(i):void 0;return n.metadata!==void 0&&(n.metadata=await Oi(n.metadata,n.runId,a)),{hook:n,run:r,encryptionKey:a}}async function oa(e){let{hook:t}=await aa(e);return t}async function sa(e,t,n){return await Yr(()=>wr(`hook.resume`,async r=>{let i=await R();try{let a,o,s;if(typeof e==`string`){let t=await aa(e);a=t.hook,o=t.run,s=n??t.encryptionKey}else if(a=e,o=await i.runs.get(a.runId),n)s=n;else{let e=await i.getEncryptionKeyForRun?.(o);s=e?await F(e):void 0}r?.setAttributes({...nr(a.token),...rr(a.hookId),...Sn(a.runId)});let c=o.executionContext?.workflowCoreVersion,{supportedFormats:l}=Bi(typeof c==`string`?c:void 0);l.has(U.ENCRYPTED)||(s=void 0);let u=[],d=ce(a.specVersion),f=await ki(t,a.runId,s,u,globalThis,d);(0,kt.waitUntil)(Promise.all(u).catch(e=>{if(e!==void 0)throw e})),await i.events.create(a.runId,{eventType:`hook_received`,specVersion:3,correlationId:a.hookId,eventData:{...d?{}:{token:a.token},payload:f}},{v1Compat:d}),r?.setAttributes({...bn(o.workflowName)});let p=o.executionContext?.traceCarrier;if(p){let e=await Er(p);e&&r?.addLink?.({context:e})}return await i.queue(Ui(o.workflowName),{runId:a.runId,traceCarrier:o.executionContext?.traceCarrier??void 0},{deploymentId:o.deploymentId,specVersion:o.specVersion??1}),a}catch(t){throw r?.setAttributes({...nr(typeof e==`string`?e:e.token),...ir(!1)}),t}}))}async function ca(e,t){let{hook:n,encryptionKey:r}=await aa(e);if(n.isWebhook===!1)throw new m(e);let i,a;if(n.metadata&&typeof n.metadata==`object`&&`respondWith`in n.metadata)if(n.metadata.respondWith===`manual`){let{readable:e,writable:n}=new TransformStream;a=e,t[ie]=n}else if(n.metadata.respondWith instanceof Response)i=n.metadata.respondWith;else throw new c(`Invalid \`respondWith\` value: ${n.metadata.respondWith}`,{slug:p.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else i=new Response(null,{status:202});if(await sa(n,t,r),a){let e=a.getReader(),t=await e.read();t.value&&(i=t.value),e.cancel()}if(!i)throw new c(`Workflow run did not send a response`,{slug:p.WEBHOOK_RESPONSE_NOT_SENT});return i}export{Qn as $,Ei as A,Cn as At,Fr as B,I as Bt,vi as C,kn as Ct,ji as D,xn as Dt,Oi as E,bn as Et,Gr as F,yn as Ft,wr as G,Ir as H,Ft as Ht,Jr as I,vn as It,tr as J,Sr as K,Kr as L,Vt as Lt,Qr as M,Mn as Mt,Z as N,On as Nt,Pi as O,Dn as Ot,Xr as P,Pn as Pt,Zn as Q,Yr as R,Bt as Rt,li as S,An as St,Ni as T,Nn as Tt,Ar as U,F as Ut,Pr as V,L as Vt,br as W,Ce as Wt,vr as X,yr as Y,lr as Z,Di as _,Vn as _t,na as a,Hn as at,Ci as b,En as bt,Zi as c,Wn as ct,Ki as d,zn as dt,$n as et,ta as f,Fn as ft,Mi as g,Yn as gt,$ as h,Jn as ht,ia as i,pr as it,$r as j,wn as jt,wi as k,Sn as kt,Qi as l,Kn as lt,Vi as m,qn as mt,sa as n,dr as nt,Ui as o,Ln as ot,ea as p,Un as pt,jr as q,ca as r,fr as rt,Ji as s,Gn as st,oa as t,Xn as tt,ra as u,In as ut,Ai as v,Bn as vt,ni as w,Tn as wt,Ti as x,jn as xt,ki as y,Rn as yt,Wr as z,R as zt};
@@ -0,0 +1 @@
1
+ import{r as e}from"./context-errors-Bbvvp-li.js";import{m as t}from"./symbols-QezhMuLg.js";async function n(r){let i=globalThis[t];return i||e(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
@@ -1,4 +1,4 @@
1
1
  const e=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:e.env.NO_COLOR?!1:!!e.stdout?.isTTY:!1})(),t=(t,n)=>r=>e?`\x1b[${t}m${r}\x1b[${n}m`:r,n={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)},r={info:n.blue,help:n.cyan,warn:n.yellow,error:n.red};function i(e){let t=Array.isArray(e)?e.join(`
2
2
  `):e;return r.info(`${n.bold(`hint:`)} ${t}`)}function a(e){return r.info(`${n.bold(`docs:`)} ${e}`)}function o(e){return n.italic(`${n.dim("`")}${e}${n.dim("`")}`)}function s(e){return n.dim(e)}function c(e){return n.bold(e)}function l(e){return n.red(e)}function u(e){return n.magenta(e)}function d(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
3
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
- `)}const f=Symbol.for(`WORKFLOW_USE_STEP`),p=Symbol.for(`WORKFLOW_CREATE_HOOK`),m=Symbol.for(`WORKFLOW_SLEEP`),h=Symbol.for(`WORKFLOW_GET_STREAM_ID`),g=Symbol.for(`WORKFLOW_STABLE_ULID`),_=Symbol.for(`WORKFLOW_STREAM_NAME`),v=Symbol.for(`WORKFLOW_STREAM_TYPE`),y=Symbol.for(`BODY_INIT`),b=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),x=Symbol.for(`workflow-class-registry`),S=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),C=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),w=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),T=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`);export{l as S,s as _,y as a,i as b,v as c,p as d,h as f,o as g,c as h,S as i,b as l,f as m,w as n,g as o,m as p,T as r,_ as s,C as t,x as u,a as v,u as x,d as y};
4
+ `)}const f=Symbol.for(`WORKFLOW_USE_STEP`),p=Symbol.for(`WORKFLOW_CREATE_HOOK`),m=Symbol.for(`WORKFLOW_SLEEP`),h=Symbol.for(`WORKFLOW_GET_STREAM_ID`),g=Symbol.for(`WORKFLOW_STABLE_ULID`),_=Symbol.for(`WORKFLOW_STREAM_NAME`),v=Symbol.for(`WORKFLOW_STREAM_TYPE`),y=Symbol.for(`WORKFLOW_STREAM_SERVER_RUN_ID`),b=Symbol.for(`BODY_INIT`),x=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),S=Symbol.for(`workflow-class-registry`),C=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),w=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),T=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),E=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`);export{l as C,u as S,o as _,b as a,d as b,y as c,S as d,p as f,c as g,f as h,C as i,v as l,m,T as n,g as o,h as p,E as r,_ as s,w as t,x as u,s as v,i as x,a as y};
@@ -1 +1 @@
1
- import{n as e}from"../../chunks/paths-C6sp4T2U.js";import{loadDevelopmentEnvironmentFiles as t}from"../../cli/dev/environment.js";import{a as n,n as r,t as i}from"../../chunks/client-CKsU8Li3.js";import{n as a}from"../../chunks/host-DREC8e8Z.js";import{discoverAndImportSuites as o,discoverSuiteFiles as s,importSuiteFile as c}from"../runner/discover.js";import{executeSuite as l}from"../runner/execute-suite.js";import{ConsoleReporter as u}from"../runner/reporters/console.js";var d=n();function f(e,t){e.command(`eval`).description(`Run eval suites against an Ash agent.`).option(`--suite <id...>`,`Suite IDs to run (repeatable)`).option(`--all`,`Run all discovered suites`).option(`--url <url>`,`Remote agent URL (skip local host startup)`).option(`--timeout <ms>`,`Per-case timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent case executions per suite`).option(`--json`,`Output results as JSON`).option(`--list-suites`,`List discovered suites and exit`).option(`--skip-report`,`Skip suite-defined reporters (e.g. Braintrust)`).action(async e=>{await p(e,t)})}async function p(n,r){let i=e();if(t(i),n.listSuites){await y(i,r);return}let s=n.suite,c=await o(i,s);if(c.length===0){s&&s.length>0?r.error(`No suites found matching: ${s.join(`, `)}`):r.error(`No eval suites found. Create suite files under evals/ with the *.eval.ts extension.`),process.exitCode=1;return}let u,d;n.url?d={kind:`remote`,url:n.url}:(u=await a(i,{host:`127.0.0.1`,port:0}),d={kind:`local`,url:u.url});let f=m(d);try{let e=[];for(let t of c){let r=_(t,n),a=v(r,{json:n.json===!0,skipReport:n.skipReport===!0}),o=await l({suite:r,target:d,reporters:a,appRoot:i,client:f});e.push(o)}n.json&&r.log(JSON.stringify(e,null,2)),e.some(e=>e.errored>0)&&(process.exitCode=1)}finally{u&&await u.close()}process.exit(process.exitCode??0)}function m(e){if(e.kind===`local`)return new i({host:e.url});let t={},n=process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();return n&&(t[r]=n),new i({auth:h(),headers:Object.keys(t).length>0?t:void 0,host:e.url})}function h(){let e=process.env.ASH_EVAL_AUTH_TOKEN?.trim();return e?{bearer:e}:{bearer:g}}async function g(){try{let e=(await(0,d.getVercelOidcToken)()).trim();if(e.length>0)return e}catch{}return process.env.VERCEL_OIDC_TOKEN?.trim()??``}function _(e,t){let n=t.maxConcurrency?Number.parseInt(t.maxConcurrency,10):void 0,r=t.timeout?Number.parseInt(t.timeout,10):void 0;if(n===void 0&&r===void 0)return e;let i={...e};return n!==void 0&&(i.maxConcurrency=n),r!==void 0&&(i.timeoutMs=r),i}function v(e,t){let n=t.json?[]:[new u];return!t.skipReport&&e.reporters&&n.push(...e.reporters),n}async function y(e,t){let n=await s(e);if(n.length===0){t.log(`No eval suites found.`);return}t.log(`Found ${n.length} eval suite file(s):\n`);for(let r of n){let n=await c(e,r);t.log(` ${n.id}${n.description?` - ${n.description}`:``}`)}}export{f as registerEvalCommand,p as runEvalCommand};
1
+ import{n as e}from"../../chunks/paths-OknjaYR8.js";import{loadDevelopmentEnvironmentFiles as t}from"../../cli/dev/environment.js";import{a as n,n as r,t as i}from"../../chunks/client-nshDsWNF.js";import{n as a}from"../../chunks/host-DsW72Q-w.js";import{discoverAndImportSuites as o,discoverSuiteFiles as s,importSuiteFile as c}from"../runner/discover.js";import{executeSuite as l}from"../runner/execute-suite.js";import{ConsoleReporter as u}from"../runner/reporters/console.js";var d=n();function f(e,t){e.command(`eval`).description(`Run eval suites against an Ash agent.`).option(`--suite <id...>`,`Suite IDs to run (repeatable)`).option(`--all`,`Run all discovered suites`).option(`--url <url>`,`Remote agent URL (skip local host startup)`).option(`--timeout <ms>`,`Per-case timeout in milliseconds`).option(`--max-concurrency <n>`,`Max concurrent case executions per suite`).option(`--json`,`Output results as JSON`).option(`--list-suites`,`List discovered suites and exit`).option(`--skip-report`,`Skip suite-defined reporters (e.g. Braintrust)`).action(async e=>{await p(e,t)})}async function p(n,r){let i=e();if(t(i),n.listSuites){await y(i,r);return}let s=n.suite,c=await o(i,s);if(c.length===0){s&&s.length>0?r.error(`No suites found matching: ${s.join(`, `)}`):r.error(`No eval suites found. Create suite files under evals/ with the *.eval.ts extension.`),process.exitCode=1;return}let u,d;n.url?d={kind:`remote`,url:n.url}:(u=await a(i,{host:`127.0.0.1`,port:0}),d={kind:`local`,url:u.url});let f=m(d);try{let e=[];for(let t of c){let r=_(t,n),a=v(r,{json:n.json===!0,skipReport:n.skipReport===!0}),o=await l({suite:r,target:d,reporters:a,appRoot:i,client:f});e.push(o)}n.json&&r.log(JSON.stringify(e,null,2)),e.some(e=>e.errored>0)&&(process.exitCode=1)}finally{u&&await u.close()}process.exit(process.exitCode??0)}function m(e){if(e.kind===`local`)return new i({host:e.url});let t={},n=process.env.VERCEL_AUTOMATION_BYPASS_SECRET?.trim();return n&&(t[r]=n),new i({auth:h(),headers:Object.keys(t).length>0?t:void 0,host:e.url})}function h(){let e=process.env.ASH_EVAL_AUTH_TOKEN?.trim();return e?{bearer:e}:{bearer:g}}async function g(){try{let e=(await(0,d.getVercelOidcToken)()).trim();if(e.length>0)return e}catch{}return process.env.VERCEL_OIDC_TOKEN?.trim()??``}function _(e,t){let n=t.maxConcurrency?Number.parseInt(t.maxConcurrency,10):void 0,r=t.timeout?Number.parseInt(t.timeout,10):void 0;if(n===void 0&&r===void 0)return e;let i={...e};return n!==void 0&&(i.maxConcurrency=n),r!==void 0&&(i.timeoutMs=r),i}function v(e,t){let n=t.json?[]:[new u];return!t.skipReport&&e.reporters&&n.push(...e.reporters),n}async function y(e,t){let n=await s(e);if(n.length===0){t.log(`No eval suites found.`);return}t.log(`Found ${n.length} eval suite file(s):\n`);for(let r of n){let n=await c(e,r);t.log(` ${n.id}${n.description?` - ${n.description}`:``}`)}}export{f as registerEvalCommand,p as runEvalCommand};
@@ -11,7 +11,7 @@ import type { PendingConnectionToolCall } from "#runtime/framework-tools/pending
11
11
  /**
12
12
  * Return value of {@link awaitAuthorizationAndResolve}. The workflow
13
13
  * body replaces its current session + serialized context with these
14
- * so the next {@link durableRunStep} sees the spliced history and
14
+ * so the next turn step sees the spliced history and
15
15
  * cached tokens.
16
16
  */
17
17
  export interface AwaitAuthorizationResolveResult {
@@ -31,6 +31,7 @@ export interface AwaitAuthorizationResolveResult {
31
31
  * spliced tool call rather than an exception in the workflow body.
32
32
  */
33
33
  export declare function awaitAuthorizationAndResolve(input: {
34
+ readonly parentWritable: WritableStream<Uint8Array>;
34
35
  readonly pendingToolCalls: readonly PendingConnectionToolCall[];
35
36
  readonly pendingAuths: readonly PendingConnectionAuthorization[];
36
37
  readonly serializedContext: Record<string, unknown>;
@@ -63,6 +63,7 @@ export async function awaitAuthorizationAndResolve(input) {
63
63
  start: await startAuthorizationForConnectionStep({
64
64
  connectionName,
65
65
  emissionState,
66
+ parentWritable: input.parentWritable,
66
67
  serializedContext: input.serializedContext,
67
68
  webhookUrl,
68
69
  }),
@@ -89,6 +90,7 @@ export async function awaitAuthorizationAndResolve(input) {
89
90
  await emitConnectionAuthorizationPendingStep({
90
91
  connectionNames: successfulStarts.map((s) => s.connectionName),
91
92
  emissionState,
93
+ parentWritable: input.parentWritable,
92
94
  serializedContext: input.serializedContext,
93
95
  });
94
96
  }
@@ -103,6 +105,7 @@ export async function awaitAuthorizationAndResolve(input) {
103
105
  const complete = await completeAuthorizationForConnectionStep({
104
106
  connectionName,
105
107
  emissionState,
108
+ parentWritable: input.parentWritable,
106
109
  principal,
107
110
  request,
108
111
  serializedContext,
@@ -145,6 +148,7 @@ export async function awaitAuthorizationAndResolve(input) {
145
148
  }
146
149
  return resolvePendingToolCallsStep({
147
150
  failedConnections,
151
+ parentWritable: input.parentWritable,
148
152
  pendingCalls: input.pendingToolCalls,
149
153
  principals,
150
154
  resolvedConnectionNames,
@@ -53,6 +53,7 @@ export type StartAuthorizationStepResult = {
53
53
  export declare function startAuthorizationForConnectionStep(input: {
54
54
  readonly connectionName: string;
55
55
  readonly emissionState: HarnessEmissionState;
56
+ readonly parentWritable: WritableStream<Uint8Array>;
56
57
  readonly serializedContext: Record<string, unknown>;
57
58
  readonly webhookUrl: string;
58
59
  }): Promise<StartAuthorizationStepResult>;
@@ -64,6 +65,7 @@ export declare function startAuthorizationForConnectionStep(input: {
64
65
  export declare function emitConnectionAuthorizationPendingStep(input: {
65
66
  readonly connectionNames: readonly string[];
66
67
  readonly emissionState: HarnessEmissionState;
68
+ readonly parentWritable: WritableStream<Uint8Array>;
67
69
  readonly serializedContext: Record<string, unknown>;
68
70
  }): Promise<void>;
69
71
  /**
@@ -104,6 +106,7 @@ export type CompleteAuthorizationStepResult = {
104
106
  export declare function completeAuthorizationForConnectionStep(input: {
105
107
  readonly connectionName: string;
106
108
  readonly emissionState: HarnessEmissionState;
109
+ readonly parentWritable: WritableStream<Uint8Array>;
107
110
  readonly principal: ConnectionPrincipal;
108
111
  readonly request: AuthorizationCallbackRequest;
109
112
  readonly serializedContext: Record<string, unknown>;
@@ -133,6 +136,7 @@ export interface ConnectionAuthorizationFailure {
133
136
  */
134
137
  export declare function resolvePendingToolCallsStep(input: {
135
138
  readonly failedConnections: Readonly<Record<string, ConnectionAuthorizationFailure>>;
139
+ readonly parentWritable: WritableStream<Uint8Array>;
136
140
  readonly pendingCalls: readonly PendingConnectionToolCall[];
137
141
  readonly principals: Readonly<Record<string, ConnectionPrincipal>>;
138
142
  readonly resolvedConnectionNames: readonly string[];
@@ -2,7 +2,6 @@
2
2
  * Durable step boundaries that make up the interactive OAuth
3
3
  * await-authorization-and-splice flow.
4
4
  */
5
- import { getWritable } from "#compiled/@workflow/core/index.js";
6
5
  import { buildAdapterContext } from "#channel/adapter-context.js";
7
6
  import { callAdapterEventHandler } from "#channel/adapter.js";
8
7
  import { contextStorage, toContextAccessor } from "#context/container.js";
@@ -41,7 +40,7 @@ export async function startAuthorizationForConnectionStep(input) {
41
40
  sequence: input.emissionState.sequence,
42
41
  stepIndex: input.emissionState.stepIndex,
43
42
  turnId: input.emissionState.turnId,
44
- }));
43
+ }), input.parentWritable);
45
44
  return { ok: false, reason };
46
45
  }
47
46
  const description = connection.description ?? input.connectionName;
@@ -66,7 +65,7 @@ export async function startAuthorizationForConnectionStep(input) {
66
65
  sequence: input.emissionState.sequence,
67
66
  stepIndex: input.emissionState.stepIndex,
68
67
  turnId: input.emissionState.turnId,
69
- }));
68
+ }), input.parentWritable);
70
69
  return { ok: false, reason };
71
70
  }
72
71
  await emitAuthorizationEvent(ctx, createConnectionAuthorizationRequiredEvent({
@@ -77,7 +76,7 @@ export async function startAuthorizationForConnectionStep(input) {
77
76
  stepIndex: input.emissionState.stepIndex,
78
77
  turnId: input.emissionState.turnId,
79
78
  webhookUrl: input.webhookUrl,
80
- }));
79
+ }), input.parentWritable);
81
80
  // Re-serialize ctx after the emit so any channel-state mutations
82
81
  // the handler made (e.g. tracked Slack message ts) survive the
83
82
  // step boundary into the matching `completeAuthorization` step.
@@ -104,7 +103,7 @@ export async function emitConnectionAuthorizationPendingStep(input) {
104
103
  sequence: input.emissionState.sequence,
105
104
  stepIndex: input.emissionState.stepIndex,
106
105
  turnId: input.emissionState.turnId,
107
- }));
106
+ }), input.parentWritable);
108
107
  }
109
108
  /**
110
109
  * Runs one connection's `completeAuthorization` callback inside a
@@ -129,7 +128,7 @@ export async function completeAuthorizationForConnectionStep(input) {
129
128
  sequence: input.emissionState.sequence,
130
129
  stepIndex: input.emissionState.stepIndex,
131
130
  turnId: input.emissionState.turnId,
132
- }));
131
+ }), input.parentWritable);
133
132
  return { ok: false, outcome: "failed", reason, retryable: false };
134
133
  }
135
134
  try {
@@ -145,7 +144,7 @@ export async function completeAuthorizationForConnectionStep(input) {
145
144
  sequence: input.emissionState.sequence,
146
145
  stepIndex: input.emissionState.stepIndex,
147
146
  turnId: input.emissionState.turnId,
148
- }));
147
+ }), input.parentWritable);
149
148
  return { ok: true, token };
150
149
  }
151
150
  catch (err) {
@@ -166,7 +165,7 @@ export async function completeAuthorizationForConnectionStep(input) {
166
165
  sequence: input.emissionState.sequence,
167
166
  stepIndex: input.emissionState.stepIndex,
168
167
  turnId: input.emissionState.turnId,
169
- }));
168
+ }), input.parentWritable);
170
169
  return { ok: false, outcome: "failed", reason, retryable };
171
170
  }
172
171
  }
@@ -305,7 +304,7 @@ function findConnection(ctx, connectionName) {
305
304
  const connections = node.agent?.connections ?? [];
306
305
  return connections.find((c) => c.connectionName === connectionName);
307
306
  }
308
- async function emitAuthorizationEvent(ctx, event) {
307
+ async function emitAuthorizationEvent(ctx, event, parentWritable) {
309
308
  const adapter = ctx.require(ChannelKey);
310
309
  const adapterCtx = buildAdapterContext(adapter, toContextAccessor(ctx));
311
310
  const finalEvent = await callAdapterEventHandler(adapter, event, adapterCtx);
@@ -318,8 +317,7 @@ async function emitAuthorizationEvent(ctx, event) {
318
317
  // in place a step later). Mirrors the post-emit pin in
319
318
  // `workflow-steps.ts`.
320
319
  ctx.set(ChannelKey, { ...adapter, state: { ...adapterCtx.state } });
321
- const writable = getWritable();
322
- const writer = writable.getWriter();
320
+ const writer = parentWritable.getWriter();
323
321
  try {
324
322
  await writer.write(encodeMessageStreamEvent(timestampHandleMessageStreamEvent(finalEvent)));
325
323
  }
@@ -5,9 +5,9 @@ import type { RuntimeCompiledArtifactsSource } from "#runtime/compiled-artifacts
5
5
  import type { ResolvedRuntimeAgentNode } from "#runtime/graph.js";
6
6
  /**
7
7
  * Factory that creates a {@link Runtime} for the given compiled
8
- * artifacts source and optional node id. Matches the signature
9
- * of both `createContinuousLoopRuntime` and `createWorkflowRuntime`,
10
- * so callers pass the constructor directly — no wrapper needed.
8
+ * artifacts source and optional node id. Matches the signature of
9
+ * `createWorkflowRuntime`, so callers pass the constructor directly —
10
+ * no wrapper needed.
11
11
  */
12
12
  export type CreateRuntime = (config: {
13
13
  readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
@@ -27,8 +27,7 @@ export interface CreateExecutionNodeStepInput {
27
27
  readonly compiledArtifactsSource: RuntimeCompiledArtifactsSource;
28
28
  /**
29
29
  * Runtime constructor used by the subagent tool executor to start
30
- * delegated child runs on the same runtime flavor (continuous or
31
- * workflow) as the parent.
30
+ * delegated child runs on the same workflow runtime as the parent.
32
31
  */
33
32
  readonly createRuntime: CreateRuntime;
34
33
  readonly emit?: HarnessEmitFn;
@@ -1,31 +1,4 @@
1
1
  import type { ChannelAdapter } from "#channel/adapter.js";
2
- import type { SubagentInputRequestHookPayload } from "#channel/types.js";
3
- /**
4
- * Transport used by the continuous runtime to bridge a child subagent's
5
- * `input.requested` event up to its parent.
6
- */
7
- export type ContinuousSubagentInputRequestDispatcher = (payload: SubagentInputRequestHookPayload) => void;
8
- /**
9
- * Registers the parent-side dispatcher for one child subagent run.
10
- * Called by the continuous runtime right before it starts the child.
11
- *
12
- * In production, child tokens are derived from `(parentSessionId,
13
- * callId)` with a UUID session id, so a duplicate registration would
14
- * indicate a bug (overlapping dispatch or missing cleanup after an
15
- * aborted run). A warning is emitted so such bugs are visible in
16
- * operator logs, but the new dispatcher replaces the stale entry so
17
- * process-crash recovery and abort paths do not wedge subsequent
18
- * runs.
19
- */
20
- export declare function registerContinuousSubagentInputRequestDispatcher(input: {
21
- readonly childContinuationToken: string;
22
- readonly dispatcher: ContinuousSubagentInputRequestDispatcher;
23
- }): void;
24
- /**
25
- * Clears the dispatcher entry when the child finishes (success, error,
26
- * or abort). Called from the child completion chain.
27
- */
28
- export declare function unregisterContinuousSubagentInputRequestDispatcher(childContinuationToken: string): void;
29
2
  /**
30
3
  * Durable adapter kind used for delegated subagent child runs.
31
4
  *
@@ -7,60 +7,6 @@ import { resumeHook } from "#compiled/@workflow/core/runtime.js";
7
7
  import { ContinuationTokenKey, SessionIdKey } from "#context/seed-keys.js";
8
8
  import { createErrorId, createLogger } from "#internal/logging.js";
9
9
  const log = createLogger("execution.subagent-adapter");
10
- /**
11
- * Process-local registry keyed by the child subagent's
12
- * `continuationToken`. When a continuous runtime dispatches a child
13
- * subagent, it registers the parent's dispatcher so the adapter's
14
- * `input.requested` handler can locate it without plumbing runtime
15
- * references through context.
16
- *
17
- * The workflow runtime never touches this registry — its fallback path
18
- * below uses `resumeHook` directly.
19
- */
20
- const continuousDispatchers = new Map();
21
- /**
22
- * Registers the parent-side dispatcher for one child subagent run.
23
- * Called by the continuous runtime right before it starts the child.
24
- *
25
- * In production, child tokens are derived from `(parentSessionId,
26
- * callId)` with a UUID session id, so a duplicate registration would
27
- * indicate a bug (overlapping dispatch or missing cleanup after an
28
- * aborted run). A warning is emitted so such bugs are visible in
29
- * operator logs, but the new dispatcher replaces the stale entry so
30
- * process-crash recovery and abort paths do not wedge subsequent
31
- * runs.
32
- */
33
- export function registerContinuousSubagentInputRequestDispatcher(input) {
34
- if (continuousDispatchers.has(input.childContinuationToken)) {
35
- // Use `console.warn` (not the structured logger) because this
36
- // function sits outside any `"use step"` boundary — the logger's
37
- // `formatError` path pulls `node:util` into the workflow bundler
38
- // graph and is rejected. The warning surfaces the condition; the
39
- // set below replaces the stale entry so abort-path recovery is
40
- // not wedged.
41
- console.warn(`[ash:execution.subagent-adapter] continuous subagent input-request dispatcher already registered — replacing stale entry for child continuation token "${input.childContinuationToken}"`);
42
- }
43
- continuousDispatchers.set(input.childContinuationToken, input.dispatcher);
44
- }
45
- /**
46
- * Clears the dispatcher entry when the child finishes (success, error,
47
- * or abort). Called from the child completion chain.
48
- */
49
- export function unregisterContinuousSubagentInputRequestDispatcher(childContinuationToken) {
50
- continuousDispatchers.delete(childContinuationToken);
51
- }
52
- /**
53
- * Looks up the parent-side dispatcher for one child subagent run.
54
- * Returns `undefined` when no continuous runtime has registered one
55
- * for the given child — the adapter's handler treats this as "not in
56
- * a continuous chain" and falls back to the workflow `resumeHook` path.
57
- */
58
- function getContinuousSubagentInputRequestDispatcher(childContinuationToken) {
59
- return continuousDispatchers.get(childContinuationToken);
60
- }
61
- // ---------------------------------------------------------------------------
62
- // Subagent adapter
63
- // ---------------------------------------------------------------------------
64
10
  /**
65
11
  * Durable adapter kind used for delegated subagent child runs.
66
12
  *
@@ -124,22 +70,12 @@ export const SUBAGENT_ADAPTER = {
124
70
  },
125
71
  };
126
72
  /**
127
- * Forwards one child HITL batch up to its parent.
73
+ * Forwards one child HITL batch up to its parent via the durable
74
+ * workflow `resumeHook` path.
128
75
  */
129
76
  async function forwardSubagentInputRequestStep(input) {
130
77
  "use step";
131
- // The continuous runtime registers a process-local dispatcher
132
- // against the child's continuation token before starting the run
133
- // (see `execution/continuous-entry.ts`). If one is present the
134
- // parent runs in an in-memory chain — bridge via that dispatcher.
135
- // Otherwise the chain is durable and we notify the parent via the
136
- // workflow `resumeHook` path.
137
- const dispatcher = getContinuousSubagentInputRequestDispatcher(input.hookPayload.childContinuationToken);
138
78
  try {
139
- if (dispatcher !== undefined) {
140
- dispatcher(input.hookPayload);
141
- return;
142
- }
143
79
  await resumeHook(input.parentContinuationToken, input.hookPayload);
144
80
  }
145
81
  catch (error) {
@@ -3,8 +3,8 @@ import type { HarnessEmitFn, HarnessSession } from "#harness/types.js";
3
3
  import type { RunMode } from "#run-mode.js";
4
4
  import type { InputResponse } from "#runtime/input/types.js";
5
5
  /**
6
- * Runs the parent-side work shared by the workflow and continuous
7
- * runtimes when a `subagent-input-request` arrives.
6
+ * Runs the parent-side work when a `subagent-input-request` arrives at
7
+ * the workflow runtime.
8
8
  *
9
9
  * Conversation mode emits a waiting boundary on the parent stream while
10
10
  * the parent harness remains parked on the child call; the returned proxy
@@ -5,8 +5,8 @@ import { createInputRequestedEvent } from "#protocol/message.js";
5
5
  // Upward proxy emission
6
6
  // ---------------------------------------------------------------------------
7
7
  /**
8
- * Runs the parent-side work shared by the workflow and continuous
9
- * runtimes when a `subagent-input-request` arrives.
8
+ * Runs the parent-side work when a `subagent-input-request` arrives at
9
+ * the workflow runtime.
10
10
  *
11
11
  * Conversation mode emits a waiting boundary on the parent stream while
12
12
  * the parent harness remains parked on the child call; the returned proxy