eve 0.75.0 → 0.75.1

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 (86) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/src/cli/commands/deploy.js +1 -1
  3. package/dist/src/cli/commands/link.d.ts +2 -1
  4. package/dist/src/cli/commands/link.js +1 -1
  5. package/dist/src/cli/commands/registry.js +1 -1
  6. package/dist/src/cli/commands/vercel-non-interactive.d.ts +6 -4
  7. package/dist/src/cli/commands/vercel-non-interactive.js +1 -1
  8. package/dist/src/compiled/.vendor-stamp.json +8 -8
  9. package/dist/src/compiled/@eve/catalog/index.js +1 -1
  10. package/dist/src/compiled/@workflow/core/global.d.ts +10 -0
  11. package/dist/src/compiled/@workflow/core/index.js +1 -1
  12. package/dist/src/compiled/@workflow/core/private.d.ts +11 -0
  13. package/dist/src/compiled/@workflow/core/private.js +1 -1
  14. package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +36 -8
  15. package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
  16. package/dist/src/compiled/@workflow/core/runtime/lifecycle-hooks.d.ts +10 -6
  17. package/dist/src/compiled/@workflow/core/runtime/out-of-band-observation.d.ts +159 -0
  18. package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +28 -4
  19. package/dist/src/compiled/@workflow/core/runtime.js +4 -4
  20. package/dist/src/compiled/@workflow/core/serialization.js +1 -1
  21. package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
  22. package/dist/src/compiled/@workflow/core/workflow.js +1 -1
  23. package/dist/src/compiled/@workflow/world-local/index.js +5 -5
  24. package/dist/src/compiled/@workflow/world-vercel/index.js +4 -4
  25. package/dist/src/compiled/_chunks/workflow/{attribute-changes-CSqvJx6j.js → attribute-changes-BW-kbMMn.js} +1 -1
  26. package/dist/src/compiled/_chunks/workflow/dist-CyBgVS7g.js +1 -0
  27. package/dist/src/compiled/_chunks/workflow/{helpers-BXCuoPUb.js → helpers-DlLD3ov_.js} +1 -1
  28. package/dist/src/compiled/_chunks/workflow/private-tQUuwBoQ.js +1 -0
  29. package/dist/src/compiled/_chunks/workflow/{resume-hook-CvENCrxc.js → resume-hook-DMsV_b4n.js} +1 -1
  30. package/dist/src/compiled/_chunks/workflow/{run-8pLWuR2U.js → run-DzdAqdb1.js} +1 -1
  31. package/dist/src/compiled/_chunks/workflow/{serialization-vDozzDhh.js → serialization-DPdYS_w2.js} +2 -2
  32. package/dist/src/compiled/_chunks/workflow/sleep-BY6leHh8.js +1 -0
  33. package/dist/src/compiled/_chunks/workflow/{token-BKeK6DmC.js → token-D5ugC3PI.js} +1 -1
  34. package/dist/src/compiled/_chunks/workflow/{token-util-CddTZ_ef.js → token-util-Bla5Z0G9.js} +1 -1
  35. package/dist/src/compiled/_chunks/workflow/undici-D-ILjOKD.js +95 -0
  36. package/dist/src/compiled/_chunks/workflow/{wait-until-A344L2AG.js → wait-until-xbRRDuUf.js} +1 -1
  37. package/dist/src/eve-channel/request.js +1 -1
  38. package/dist/src/execution/dynamic-workflow/tool.js +1 -1
  39. package/dist/src/execution/ndjson-stream.d.ts +6 -6
  40. package/dist/src/execution/ndjson-stream.js +3 -3
  41. package/dist/src/execution/tools/agent-router-workflow.js +1 -1
  42. package/dist/src/harness/compaction/engine.d.ts +8 -19
  43. package/dist/src/harness/compaction/engine.js +1 -1
  44. package/dist/src/harness/compaction/step.d.ts +7 -1
  45. package/dist/src/harness/compaction/step.js +1 -1
  46. package/dist/src/harness/emission.js +1 -1
  47. package/dist/src/harness/model-call/call.d.ts +2 -3
  48. package/dist/src/harness/model-call/call.js +1 -1
  49. package/dist/src/harness/model-call/model.d.ts +4 -5
  50. package/dist/src/harness/model-call/model.js +1 -1
  51. package/dist/src/harness/model-call/request.d.ts +1 -2
  52. package/dist/src/harness/model-call/request.js +1 -1
  53. package/dist/src/harness/model-call/retry.d.ts +1 -1
  54. package/dist/src/harness/model-call/retry.js +1 -1
  55. package/dist/src/harness/model-call/tools.d.ts +3 -4
  56. package/dist/src/harness/model-call/tools.js +1 -1
  57. package/dist/src/harness/model-call/usage.js +1 -1
  58. package/dist/src/harness/model-profile.d.ts +23 -0
  59. package/dist/src/harness/model-profile.js +1 -0
  60. package/dist/src/harness/prompt-cache.d.ts +5 -53
  61. package/dist/src/harness/prompt-cache.js +1 -1
  62. package/dist/src/harness/provider-safety.d.ts +3 -5
  63. package/dist/src/harness/provider-safety.js +1 -1
  64. package/dist/src/harness/provider-tools.d.ts +5 -13
  65. package/dist/src/harness/provider-tools.js +1 -1
  66. package/dist/src/harness/step-hooks.d.ts +2 -3
  67. package/dist/src/harness/step-hooks.js +1 -1
  68. package/dist/src/harness/tools.d.ts +2 -3
  69. package/dist/src/harness/tools.js +1 -1
  70. package/dist/src/harness/turn-tag-state.d.ts +12 -0
  71. package/dist/src/harness/turn-tag-state.js +1 -1
  72. package/dist/src/internal/application/package.js +1 -1
  73. package/dist/src/internal/gateway.d.ts +0 -13
  74. package/dist/src/internal/gateway.js +1 -1
  75. package/dist/src/setup/scaffold/create/project.js +1 -1
  76. package/dist/src/setup/scaffold/create/web-template.d.ts +3 -2
  77. package/dist/src/setup/scaffold/create/web-template.js +383 -411
  78. package/dist/src/setup/vercel-project.d.ts +1 -1
  79. package/dist/src/setup/vercel-project.js +0 -0
  80. package/dist/src/tools/provided/ask-question-workflow.js +1 -1
  81. package/dist/src/tools/provided/sleep-workflow.js +1 -1
  82. package/package.json +6 -6
  83. package/dist/src/compiled/_chunks/workflow/dist-DmXynLVH.js +0 -1
  84. package/dist/src/compiled/_chunks/workflow/private-Dlf90Zvn.js +0 -1
  85. package/dist/src/compiled/_chunks/workflow/signal-exit-iIdjQcCK.js +0 -95
  86. package/dist/src/compiled/_chunks/workflow/sleep-BMqbraZM.js +0 -1
@@ -20,7 +20,7 @@ interface PickTeamOptions extends VercelProjectOperationOptions {
20
20
  selectMessage?: (currentTeam: string) => string;
21
21
  }
22
22
  export interface LinkProjectOperationOptions extends CreatedProjectFrameworkOptions {
23
- /** Configure 100% trace sampling when creating a Vercel project. */
23
+ /** Configure 100% trace sampling when creating a Vercel project. Defaults to true. */
24
24
  traceSampling?: boolean;
25
25
  }
26
26
  export declare function unresolvedProject(): ProjectResolution;
Binary file
@@ -1 +1 @@
1
- async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.75.0//executeAskQuestionTool`;export{executeAskQuestionTool,toAskQuestionOutput,toAskQuestionRequest};
1
+ async function executeAskQuestionTool(e,t){"use workflow";return toAskQuestionOutput(await t.ask(toAskQuestionRequest(e)))}function toAskQuestionRequest(e){let t=e.options?.map(e=>({description:e.description,id:e.label,label:e.label}));return{allowFreeform:!0,display:t===void 0?`text`:`select`,prompt:e.question,...t!==void 0&&{options:t}}}function toAskQuestionOutput(e){switch(e.status){case`answered`:return{answer:e.optionId??e.text??``,status:`answered`};case`cancelled`:return{interrupted:!0};case`unavailable`:return{status:`unavailable`}}}executeAskQuestionTool.workflowId=`workflow//eve@0.75.1//executeAskQuestionTool`;export{executeAskQuestionTool,toAskQuestionOutput,toAskQuestionRequest};
@@ -1 +1 @@
1
- import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.75.0//executeSleepTool`;export{executeSleepTool};
1
+ import{sleep}from"#compiled/@workflow/core/index.js";async function executeSleepTool(e,t){"use workflow";let n=new Promise(e=>t.abortSignal.addEventListener(`abort`,()=>e(`interrupted`),{once:!0})),r=sleep(Math.ceil(e.seconds*1e3)).then(()=>`elapsed`);return await Promise.race([r,n])===`elapsed`?{waitedSeconds:e.seconds}:{interrupted:!0}}executeSleepTool.workflowId=`workflow//eve@0.75.1//executeSleepTool`;export{executeSleepTool};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eve",
3
- "version": "0.75.0",
3
+ "version": "0.75.1",
4
4
  "private": false,
5
5
  "description": "Filesystem-first framework for durable backend AI agents that run anywhere.",
6
6
  "keywords": [
@@ -580,12 +580,12 @@
580
580
  "@vercel/sandbox": "3.3.0",
581
581
  "@vercel/schedules": "0.0.0-alpha.11",
582
582
  "@vercel/sdk": "1.28.8",
583
- "@workflow/core": "5.1.0",
584
- "@workflow/errors": "5.0.2",
583
+ "@workflow/core": "5.2.0",
584
+ "@workflow/errors": "5.0.3",
585
585
  "@workflow/serde": "5.0.0",
586
- "@workflow/world": "5.0.2",
587
- "@workflow/world-local": "5.0.2",
588
- "@workflow/world-vercel": "5.1.0",
586
+ "@workflow/world": "5.0.3",
587
+ "@workflow/world-local": "5.1.0",
588
+ "@workflow/world-vercel": "5.2.0",
589
589
  "ai": "^7.0.128",
590
590
  "chat": "4.41.0",
591
591
  "chokidar": "5.0.0",
@@ -1 +0,0 @@
1
- import{r as e}from"./rolldown-runtime-B_knIduE.js";import*as t from"#compiled/zod/index.js";import{z as n}from"#compiled/zod/index.js";import r from"node:crypto";function i(e,t,n){let r=Symbol.for(`${e}/v${t}`),i=globalThis,a=i[r];if(a!==void 0)return a;let o=n();return i[r]=o,o}const a=Symbol.for(`@workflow/world//warnedEnvValues/v1`),o=globalThis,s=o[a]??=new Set;function c(e,t){s.has(e)||(s.add(e),console.warn(`[workflow] ${t}`))}function l(e,t,n={}){let r=process.env[e];if(r===void 0||r===``)return t;let{min:i=0,max:a,integer:o=!1}=n,s=Number(r);return!Number.isFinite(s)||o&&!Number.isInteger(s)?(c(`${e}=${r}`,`Ignoring ${e}: not a ${o?`finite integer`:`finite number`}; using default ${t}`),t):s<i?(c(`${e}=${r}`,`${e} below minimum ${i}; clamped`),i):a!==void 0&&s>a?(c(`${e}=${r}`,`${e} above maximum ${a}; clamped`),a):s}function u(e,t,n=process.env){let r=n[e];if(r===void 0||r===``)return t;let i=r.toLowerCase();return i===`0`||i===`false`?!1:i===`1`||i===`true`||(c(`${e}=${r}`,`Ignoring ${e}: expected 0/1/true/false; using default ${t}`),t)}const d=25e3;function ee(){let e=l(`WORKFLOW_MAX_EVENTS`,d,{integer:!0});return e>0?e:d}const f=`0123456789ABCDEFGHJKMNPQRSTVWXYZ`;var p;(function(e){e.Base32IncorrectEncoding=`B32_ENC_INVALID`,e.DecodeTimeInvalidCharacter=`DEC_TIME_CHAR`,e.DecodeTimeValueMalformed=`DEC_TIME_MALFORMED`,e.EncodeTimeNegative=`ENC_TIME_NEG`,e.EncodeTimeSizeExceeded=`ENC_TIME_SIZE_EXCEED`,e.EncodeTimeValueMalformed=`ENC_TIME_MALFORMED`,e.PRNGDetectFailure=`PRNG_DETECT`,e.ULIDInvalid=`ULID_INVALID`,e.Unexpected=`UNEXPECTED`,e.UUIDInvalid=`UUID_INVALID`})(p||={});var m=class extends Error{constructor(e,t){super(`${t} (${e})`),this.name=`ULIDError`,this.code=e}};function te(e){let t=Math.floor(e()*32)%32;return f.charAt(t)}function h(e,t,n){return t>e.length-1?e:e.substr(0,t)+n+e.substr(t+1)}function ne(e){let t,n=e.length,r,i,a=e;for(;!t&&n-->=0;){if(r=a[n],i=f.indexOf(r),i===-1)throw new m(p.Base32IncorrectEncoding,`Incorrectly encoded string`);if(i===31){a=h(a,n,f[0]);continue}t=h(a,n,f[i+1])}if(typeof t==`string`)return t;throw new m(p.Base32IncorrectEncoding,`Failed incrementing string`)}function re(e){if(e.length!==26)throw new m(p.DecodeTimeValueMalformed,`Malformed ULID`);let t=e.substr(0,10).toUpperCase().split(``).reverse().reduce((e,t,n)=>{let r=f.indexOf(t);if(r===-1)throw new m(p.DecodeTimeInvalidCharacter,`Time decode error: Invalid character: ${t}`);return e+=r*32**n},0);if(t>0xffffffffffff)throw new m(p.DecodeTimeValueMalformed,`Malformed ULID: timestamp too large: ${t}`);return t}function ie(e){let t=ae(),n=t&&(t.crypto||t.msCrypto)||(r===void 0?null:r);if(typeof n?.getRandomValues==`function`)return()=>{let e=new Uint8Array(1);return n.getRandomValues(e),e[0]/256};if(typeof n?.randomBytes==`function`)return()=>n.randomBytes(1).readUInt8()/256;if(r?.randomBytes)return()=>r.randomBytes(1).readUInt8()/256;throw new m(p.PRNGDetectFailure,`Failed to find a reliable PRNG`)}function ae(){return se()?self:typeof window<`u`?window:typeof global<`u`?global:typeof globalThis<`u`?globalThis:null}function oe(e,t){let n=``;for(;e>0;e--)n=te(t)+n;return n}function g(e,t=10){if(isNaN(e))throw new m(p.EncodeTimeValueMalformed,`Time must be a number: ${e}`);if(e>0xffffffffffff)throw new m(p.EncodeTimeSizeExceeded,`Cannot encode a time larger than 281474976710655: ${e}`);if(e<0)throw new m(p.EncodeTimeNegative,`Time must be positive: ${e}`);if(Number.isInteger(e)===!1)throw new m(p.EncodeTimeValueMalformed,`Time must be an integer: ${e}`);let n,r=``;for(let i=t;i>0;i--)n=e%32,r=f.charAt(n)+r,e=(e-n)/32;return r}function se(){return typeof WorkerGlobalScope<`u`&&self instanceof WorkerGlobalScope}function ce(e){let t=e||ie(),n=0,r;return function(e){let i=!e||isNaN(e)?Date.now():e;if(i<=n){let e=r=ne(r);return g(n,10)+e}n=i;let a=r=oe(16,t);return g(i,10)+a}}function le(e,t){let n=t||ie();return g(!e||isNaN(e)?Date.now():e,10)+oe(16,n)}const ue=`$rootRunId`,de=`$parentRunId`,_=`$retention`,v=`default`,fe=/^(?:0|[1-9]\d*)$/;function pe(e){let t=e?.[_];return t===void 0?{mode:`default`,wellFormed:!1,unsupported:!1}:fe.test(t)?t===`0`?{mode:`none`,raw:t,wellFormed:!0,unsupported:!1}:{mode:`default`,raw:t,wellFormed:!0,unsupported:!0}:{mode:`default`,raw:t,wellFormed:!1,unsupported:t!==v}}const y=8192,b=new TextEncoder;var x=class extends Error{constructor(e){super(e),this.name=`AttributeValidationError`}};function me(e){let t=b.encode(JSON.stringify(e)).length;if(t>8192)throw new x(`Attribute eventData exceeds limit ${y} UTF-8 JSON bytes (received ${t} bytes). Split the changes into smaller setAttributes() calls.`)}function he(e,t){if(typeof e!=`string`)throw new x(`Attribute key must be a string, got ${typeof e}`);if(e.length===0)throw new x(`Attribute key must not be empty`);if(e.length>256)throw new x(`Attribute key length ${e.length} exceeds limit 256: ${JSON.stringify(e.slice(0,32))}…`);if(!t&&e.startsWith(`$`))throw new x(`Attribute key ${JSON.stringify(e)} starts with reserved prefix "\$" — that namespace is reserved for framework/library code. Set { allowReservedAttributes: true } only if your caller is framework-level.`)}function ge(e){if(e!==null&&typeof e!=`string`)throw new x(`Attribute value must be a string or null, got ${typeof e}`);if(e===null)return;let t=b.encode(e).length;if(t>256)throw new x(`Attribute value byte length ${t} exceeds limit 256`)}function _e(e,t,n){return t===null?n?.has(e)?-1:0:+(n===void 0||!n.has(e))}function S(e,t={}){let n=new Set,r=t.existingKeys===void 0?void 0:t.existingKeys instanceof Set?t.existingKeys:new Set(t.existingKeys),i=r?.size??0;for(let{key:t,value:a}of e){if(n.has(t))throw new x(`Attribute key ${JSON.stringify(t)} appears more than once in the same batch`);n.add(t),i+=_e(t,a,r)}if(i>64)throw new x(`Run attribute count would exceed limit 64 (post-merge ${i})`)}function ve(e,t={}){for(let{key:n,value:r}of e)he(n,t.allowReservedAttributes===!0),ge(r);S(e,t)}function ye(e,t){let n={...e??{}};for(let{key:e,value:r}of t)r===null?delete n[e]:n[e]=r;return n}const be=new TextEncoder,C=t.compile(t.string().min(1,{error:`Attribute key must not be empty`}).max(256,{error:`Attribute key exceeds limit 256`})),w=t.compile(t.string().refine(e=>be.encode(e).length<=256,{error:`Attribute value exceeds limit 256 UTF-8 bytes`}).nullable()),xe=t.compile(t.object({key:C,value:w})),Se=t.compile(t.array(xe).superRefine((e,t)=>{try{S(e)}catch(n){if(!(n instanceof x))throw n;t.addIssue({code:`custom`,message:n.message,input:e})}}));function T(e,t){return Object.hasOwn(e,t)?e[t]:void 0}function Ce(e){return e.eventType===`noop`}const we={attr_set:`attr_set`,step_created:`step_created`,step_started:`step_started`,step_retrying:`step_retrying`,step_completed:`step_terminal`,step_failed:`step_terminal`,wait_created:`wait_created`,wait_completed:`wait_completed`,hook_created:`hook_created`,hook_disposed:`hook_disposed`,run_started:`run_started`};function Te(e){return T(we,e)}function Ee(e){let t=Te(e.eventType);if(t!==void 0)return t===`run_started`?{eventClass:t,entity:``}:e.correlationId?{eventClass:t,entity:e.correlationId}:void 0}const De={run_created:[`input`],run_started:[`input`],run_completed:[`output`],run_failed:[`error`],step_created:[`input`],step_started:[`input`],step_completed:[`result`],step_failed:[`error`],step_retrying:[`error`],hook_created:[`metadata`],hook_received:[`payload`]},Oe=[];function E(e){return T(De,e)??Oe}function ke(e){return E(e)[0]}const Ae=n.compile(n.instanceof(Uint8Array)),je=n.compile(n.any()),D=n.compile(n.union([Ae,je])),O=n.compile(n.enum([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`,`attr_set`,`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`,`hook_created`,`hook_received`,`hook_disposed`,`hook_conflict`,`wait_created`,`wait_completed`,`noop`]));n.compile(O.extract([`run_created`,`run_started`,`run_completed`,`run_failed`,`run_cancelled`])).options;const Me=n.compile(O.extract([`run_completed`,`run_failed`,`run_cancelled`])).options;function Ne(e){return Me.includes(e)}const Pe=n.compile(O.extract([`step_created`,`step_completed`,`step_failed`,`step_retrying`,`step_started`])).options;function Fe(e){return Pe.includes(e)}n.compile(O.extract([`step_completed`,`step_failed`])).options;const Ie=n.compile(O.extract([`hook_created`,`hook_received`,`hook_disposed`])).options;function Le(e){return Ie.includes(e)}const Re=n.compile(O.extract([`hook_disposed`,`hook_received`])).options;function ze(e){return Re.includes(e)}n.compile(O.extract([`wait_created`,`wait_completed`])).options;const Be=n.compile(O.extract([`step_created`,`hook_created`,`wait_created`])).options;function Ve(e){return Be.includes(e)}function He(e,t){if(t!==`none`||!(`eventData`in e))return e;let n=e.eventData;if(!n||typeof n!=`object`){let{eventData:t,...n}=e;return n}let r=E(e.eventType);if(r.length===0)return e;let i={...n};for(let e of r)delete i[e];let{eventData:a,...o}=e;return{...o,...Object.keys(i).length>0?{eventData:i}:{}}}const k=n.compile(n.object({eventType:O,correlationId:n.string().optional(),specVersion:n.number().optional()})),A={ttfs:n.number().optional(),stso:n.number().optional(),stepCount:n.number().int().positive().optional(),eventCount:n.number().int().positive().optional(),rsfs:n.number().optional(),finalSchedulingReplay:n.number().optional(),optimizations:n.array(n.string()).optional()},j=n.compile(k.extend({eventType:n.literal(`step_completed`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),workflowName:n.string().optional(),result:D,...A})})),M=n.compile(k.extend({eventType:n.literal(`step_failed`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),error:D,...A})})),N=n.compile(k.extend({eventType:n.literal(`step_retrying`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),error:D,retryAfter:n.coerce.date().optional()})})),P=n.compile(k.extend({eventType:n.literal(`step_started`),correlationId:n.string(),eventData:n.object({stepName:n.string().optional(),attempt:n.number().optional(),workflowName:n.string().optional(),input:D.optional(),ownerMessageId:n.string().optional()}).optional()})),F=n.compile(k.extend({eventType:n.literal(`step_created`),correlationId:n.string(),eventData:n.object({stepName:n.string(),workflowName:n.string().optional(),input:D})})),I=n.compile(k.extend({eventType:n.literal(`hook_created`),correlationId:n.string(),eventData:n.object({token:n.string(),tokenRetentionUntil:n.coerce.date().optional(),metadata:D.optional(),isWebhook:n.boolean().optional(),isSystem:n.boolean().optional(),force:n.boolean().optional(),forceClaimedFrom:n.object({runId:n.string(),hookId:n.string(),workflowName:n.string().optional(),deploymentId:n.string().optional(),runSpecVersion:n.number().optional()}).optional()})})),L=n.compile(k.extend({eventType:n.literal(`hook_received`),correlationId:n.string(),eventData:n.object({token:n.string().optional(),payload:D})})),Ue=n.compile(k.extend({eventType:n.literal(`hook_disposed`),correlationId:n.string(),eventData:n.object({token:n.string().optional(),forceClaimedBy:n.object({runId:n.string(),hookId:n.string()}).optional()}).optional()})),We=n.compile(k.extend({eventType:n.literal(`hook_conflict`),correlationId:n.string(),eventData:n.object({token:n.string(),conflictingRunId:n.string().optional(),forceRefusedReason:n.literal(`victim-spec-version`).optional()})})),Ge=n.compile(k.extend({eventType:n.literal(`noop`),eventData:n.object({sealed:n.boolean().optional()}).passthrough().optional()})),R=n.compile(k.extend({eventType:n.literal(`wait_created`),correlationId:n.string(),eventData:n.object({resumeAt:n.coerce.date()})})),z=n.compile(k.extend({eventType:n.literal(`wait_completed`),correlationId:n.string(),eventData:n.object({resumeAt:n.coerce.date().optional()}).optional()})),Ke=n.compile(n.discriminatedUnion(`type`,[n.object({type:n.literal(`workflow`)}),n.object({type:n.literal(`step`),stepId:n.string(),attempt:n.number()})])),B=n.compile(k.extend({eventType:n.literal(`attr_set`),correlationId:n.string().optional(),eventData:n.object({changes:Se,writer:Ke,allowReservedAttributes:n.literal(!0).optional()})})),V=n.compile(k.extend({eventType:n.literal(`run_created`),eventData:n.object({deploymentId:n.string(),workflowName:n.string(),input:D,executionContext:n.record(n.string(),n.any()).optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),dynamicWorkflowCode:D.optional(),dynamicWorkflowCodeRef:n.string().optional(),encryptionPublicKey:n.string().optional()}).refine(e=>e.dynamicWorkflowCode===void 0||e.dynamicWorkflowCodeRef===void 0,{path:[`dynamicWorkflowCodeRef`],message:`dynamicWorkflowCode and dynamicWorkflowCodeRef are mutually exclusive`})})),H=n.compile(k.extend({eventType:n.literal(`run_started`),eventData:n.object({input:D.optional(),deploymentId:n.string().optional(),workflowName:n.string().optional(),executionContext:n.record(n.string(),n.any()).optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),encryptionPublicKey:n.string().optional(),dynamicWorkflowCode:D.optional(),dynamicWorkflowCodeRef:n.string().optional()}).refine(e=>e.dynamicWorkflowCode===void 0||e.dynamicWorkflowCodeRef===void 0,{path:[`dynamicWorkflowCodeRef`],message:`dynamicWorkflowCode and dynamicWorkflowCodeRef are mutually exclusive`}).optional()})),U=n.compile(k.extend({eventType:n.literal(`run_completed`),eventData:n.object({output:D.optional()})})),W=n.compile(k.extend({eventType:n.literal(`run_failed`),eventData:n.object({error:D,errorCode:n.string().optional()})})),qe=n.compile(k.extend({eventType:n.literal(`run_cancelled`),eventData:n.object({cancelReason:n.string().max(512).optional()}).optional()}));n.compile(n.discriminatedUnion(`eventType`,[V,H,U,W,qe,B,F,j,M,N,P,I,L,Ue,R,z]));const Je=n.compile(n.discriminatedUnion(`eventType`,[V,H,U,W,qe,B,F,j,M,N,P,I,L,Ue,We,R,z,Ge])),Ye=n.compile(Je.and(n.object({runId:n.string(),eventId:n.string(),createdAt:n.coerce.date(),occurredAt:n.coerce.date().optional(),specVersion:n.number().optional(),resumeId:n.string().optional()})));function Xe(e){return Ve(e.eventType)?!0:e.eventType===`step_started`&&typeof e.eventData?.stepName==`string`&&e.eventData.input!==void 0}const G=n.compile(n.enum([`pending`,`running`,`completed`,`failed`,`cancelled`])),Ze=n.compile(G.extract([`completed`,`failed`,`cancelled`])).options;function Qe(e){return Ze.includes(e)}const K=n.compile(n.object({runId:n.string(),status:G,deploymentId:n.string(),workflowName:n.string(),specVersion:n.number().optional(),executionContext:n.record(n.string(),n.any()).optional(),input:D.optional(),output:D.optional(),dynamicWorkflowCode:D.optional(),error:D.optional(),errorCode:n.string().optional(),attributes:n.record(n.string(),n.string()).default({}),encryptionPublicKey:n.string().optional(),expiredAt:n.coerce.date().optional(),startedAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date()})),$e=n.compile(n.discriminatedUnion(`status`,[K.extend({status:n.enum([`pending`,`running`]),output:n.undefined().optional(),error:n.undefined().optional(),completedAt:n.undefined().optional()}),K.extend({status:n.literal(`cancelled`),output:n.undefined().optional(),error:n.undefined().optional(),completedAt:n.coerce.date()}),K.extend({status:n.literal(`completed`),output:D.optional(),error:n.undefined().optional(),completedAt:n.coerce.date()}),K.extend({status:n.literal(`failed`),output:n.undefined().optional(),error:D.optional(),completedAt:n.coerce.date()})])),et=n.compile(n.object({runIds:n.array(n.string()).min(1).max(500).refine(e=>new Set(e).size===e.length,{message:`runIds must not contain duplicates`}),cancelReason:n.string().max(512).optional()})),tt=n.compile(n.discriminatedUnion(`outcome`,[n.object({runId:n.string(),outcome:n.literal(`cancelled`)}),n.object({runId:n.string(),outcome:n.literal(`already_cancelled`)}),n.object({runId:n.string(),outcome:n.literal(`not_cancellable`),status:n.string()}),n.object({runId:n.string(),outcome:n.literal(`not_found`)}),n.object({runId:n.string(),outcome:n.literal(`failed`),code:n.string(),retryable:n.boolean()})])),nt=n.compile(n.object({summary:n.object({requested:n.number(),cancelled:n.number(),alreadyCancelled:n.number(),notCancellable:n.number(),notFound:n.number(),failed:n.number()}),results:n.array(tt)})),q=n.compile(n.enum([`pending`,`running`,`completed`,`failed`,`cancelled`])),rt=n.compile(n.object({runId:n.string(),stepId:n.string(),stepName:n.string(),status:q,input:D.optional(),output:D.optional(),error:D.optional(),attempt:n.number(),startedAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date(),retryAfter:n.coerce.date().optional(),specVersion:n.number().optional()})),it=n.compile(q.extract([`completed`,`failed`,`cancelled`])).options;function at(e){return it.includes(e)}const ot=n.compile(n.enum([`waiting`,`completed`])),st=n.compile(n.object({waitId:n.string(),runId:n.string(),status:ot,resumeAt:n.coerce.date().optional(),completedAt:n.coerce.date().optional(),createdAt:n.coerce.date(),updatedAt:n.coerce.date(),specVersion:n.number().optional()})),ct=/^\d{4}-\d{2}-\d{2}[ T]\d{2}:\d{2}:\d{2}(?:\.\d+)?$/,J=n.compile(n.preprocess(e=>typeof e==`string`&&ct.test(e)?`${e.replace(` `,`T`)}Z`:e,n.coerce.date())),Y=n.compile(J.nullable().optional()),X=n.compile(n.string().nullable().optional()),Z=n.compile(n.boolean().nullable().optional()),lt=n.compile(n.object({runId:n.string(),status:G,deploymentId:n.string(),workflowName:n.string(),specVersion:n.coerce.number().optional(),attributes:n.record(n.string(),n.string()).default({}),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z})),ut=n.compile(n.object({runId:n.string(),stepId:n.string(),stepName:X,status:q,attempt:n.number().optional(),createdAt:J,updatedAt:J,startedAt:Y,completedAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,workflowEncryptionEnabled:Z,computeInstanceId:X})),dt=n.compile(n.object({runId:n.string(),eventId:n.string(),eventType:O,correlationId:X,entityId:X,stepName:X,workflowName:n.string(),deploymentId:n.string(),specVersion:n.coerce.number().optional(),runCreatedAt:J,createdAt:J,region:X,vercelId:X,requestId:X,computeInstanceId:X,resumeAt:Y,retryAfter:Y,errorCode:X,workflowCoreVersion:X,isWebhook:Z,isSystem:Z,workflowEncryptionEnabled:Z})),ft=n.compile(n.object({runId:n.string(),hookId:n.string(),status:n.enum([`created`,`received`,`disposed`,`conflict`]),createdAt:J,updatedAt:J,receivedAt:Y,disposedAt:Y,isWebhook:Z,isSystem:Z,workflowCoreVersion:X,workflowEncryptionEnabled:Z})),pt=n.compile(n.object({runId:n.string(),waitId:n.string(),status:ot,resumeAt:Y,createdAt:J,updatedAt:J,completedAt:Y,workflowCoreVersion:X,workflowEncryptionEnabled:Z})),mt=n.compile(n.object({key:n.string(),runCount:n.coerce.number(),firstSeenAt:J,lastSeenAt:J})),ht=1e3,gt=n.compile(n.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_$/,`Must match __wkf_workflow_ or __{namespace}_wkf_workflow_`)),_t=n.compile(n.string().regex(/^__(?:[a-z][a-z0-9]*_)?wkf_workflow_.+$/,`Must be a valid queue name with a recognized prefix`)),vt=n.compile(n.string().regex(/^[a-z][a-z0-9]*$/,`Must be lowercase alphanumeric, starting with a letter`));function yt(e){return e??process.env.WORKFLOW_QUEUE_NAMESPACE??void 0}function bt(e,t){if(e!==`workflow`)throw Error(`Unsupported queue kind: ${e}`);return t===void 0?`__wkf_workflow_`:(vt.parse(t),`__${t}_wkf_workflow_`)}function xt(e){let t=e.match(/^(__(?:[a-z][a-z0-9]*_)?wkf_workflow_)(.+)$/);if(!t)throw Error(`Invalid queue name: ${e}`);return{prefix:gt.parse(t[1]),id:t[2]}}const St=n.compile(n.string().brand().describe(`A stored queue message ID`)),Ct=n.compile(n.record(n.string(),n.string())),wt=n.compile(n.object({input:n.unknown(),deploymentId:n.string(),workflowName:n.string(),specVersion:n.number(),executionContext:n.record(n.string(),n.any()).optional(),dynamicWorkflowCode:D.optional(),dynamicWorkflowCodeRef:n.string().optional(),attributes:n.record(n.string(),n.string()).optional(),allowReservedAttributes:n.literal(!0).optional(),environment:n.string().optional()}).refine(e=>e.dynamicWorkflowCode===void 0||e.dynamicWorkflowCodeRef===void 0,{path:[`dynamicWorkflowCodeRef`],message:`dynamicWorkflowCode and dynamicWorkflowCodeRef are mutually exclusive`})),Tt=n.compile(n.object({input:n.custom(e=>e instanceof Uint8Array,{message:`stepInput.input must be a Uint8Array`})})),Et=n.compile(n.object({deploymentId:n.string(),specVersion:n.number(),startedAt:n.number().optional(),rootRunId:n.string().optional()})),Dt=n.compile(n.object({resumeId:n.string(),hookId:n.string(),token:n.string(),payload:n.unknown(),payloadDigest:n.string(),deploymentId:n.string().optional()})),Ot=n.compile(n.object({resumeRequestedAtMs:n.number(),queuePublishRequestedAtMs:n.number(),strategy:n.string().optional(),consumerStartedAtMs:n.number().optional(),replayStartedAtMs:n.number().optional(),nextStepEncounteredAtMs:n.number().optional(),setupSource:n.string().optional()})),kt=n.compile(n.object({runId:n.string(),invoke:n.literal(!0).optional(),requestId:n.string().optional(),input:n.unknown().optional(),traceCarrier:Ct.optional(),requestedAt:n.coerce.date().optional(),replayDivergence:n.object({eventId:n.string(),count:n.number().int().positive(),eventIds:n.array(n.string()).optional().catch(void 0)}).optional(),preconditionReinvocations:n.number().int().positive().optional(),serverErrorRetryCount:n.number().int().optional(),deploymentMismatchRetryCount:n.number().int().nonnegative().optional(),waitContinuation:n.object({correlationId:n.string(),attempt:n.number().int().nonnegative()}).optional().catch(void 0),stepId:n.string().optional(),stepName:n.string().optional(),runInput:wt.optional(),hookInput:Dt.optional(),stepInput:Tt.optional(),runContext:Et.optional(),hookResumeTiming:Ot.optional().catch(void 0)})),At=n.compile(n.object({__healthCheck:n.literal(!0),correlationId:n.string(),runId:n.string().optional()})),jt=n.compile(n.union([At,kt])),Mt=n.compile(n.object({deploymentId:n.string(),workflowName:n.string(),runSpecVersion:n.number().optional(),workflowCoreVersion:n.string().optional(),nodeVersion:n.string().optional(),traceCarrier:Ct.optional(),encryptionPublicKey:n.string().optional(),hookResumeInputVersion:n.number().optional()})),Nt=n.compile(n.object({hookResumeDedupVersion:n.number()})),Pt=n.compile(n.object({runId:n.string(),hookId:n.string(),workflowName:n.string().optional(),deploymentId:n.string().optional(),runSpecVersion:n.number().optional()})),Ft=n.compile(n.object({runId:n.string(),hookId:n.string(),token:n.string(),ownerId:n.string(),projectId:n.string(),environment:n.string(),metadata:D.optional(),createdAt:n.coerce.date(),specVersion:n.number().optional(),isWebhook:n.boolean().optional(),isSystem:n.boolean().optional(),tokenRetentionUntil:n.coerce.date().optional(),resumeContext:Mt.optional(),resumeCapabilities:Nt.optional(),claimedFrom:Pt.optional()})),It=`WORKFLOW_NODE_HTTP`;function Lt(e=process.env){return u(It,!1,e)}async function Rt(e,t,n,r){let i=bt(`workflow`,yt(r)),a=0,o,s=!0;for(;s;){let r=await e.list({status:[`pending`,`running`],resolveData:`none`,pagination:{cursor:o}});for(let e of r.data)try{await t(`${i}${e.workflowName}`,{runId:e.runId}),a++}catch(t){console.warn(`[${n}] Failed to re-enqueue run ${e.runId}: ${t}`)}s=r.hasMore,o=r.cursor??void 0}a>0&&zt()&&console.debug(`[${n}] Re-enqueued ${a} active run(s) on startup`)}function zt(){let e=typeof process<`u`?process.env.DEBUG:void 0;return typeof e==`string`?e.includes(`workflow:`)||e===`*`:!1}const Bt=n.lazy(()=>n.union([n.string(),n.number(),n.boolean(),n.null(),n.array(Bt),n.record(n.string(),Bt)])),Vt=n.compile(n.object({currentLookbackDays:n.number(),maxLookbackDays:n.number(),currentWindowStart:n.coerce.date(),maxWindowStart:n.coerce.date(),upgradeAvailable:n.boolean()})),Ht=e=>n.compile(n.object({data:n.array(e),cursor:n.string().nullable(),hasMore:n.boolean(),pageInfo:Vt.optional()}));function Ut(e){return e===`skip-step-inputs`?`all`:e}const Wt=n.compile(n.object({message:n.string(),stack:n.string().optional(),code:n.string().optional()})),Gt=`evnt_`;function Q(e){if(e.length!==26)return!1;for(let t=0;t<10;t++)if(e[t]!==`0`)return!1;for(let t=10;t<26;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return!0}function Kt(e){let t=e.indexOf(`_`);return t===-1?e:e.slice(t+1)}function qt(e){return Q(Kt(e))}function Jt(e){if(!Number.isSafeInteger(e)||e<1)throw RangeError(`Invalid event slot: ${e}`);return`${Gt}${String(e).padStart(26,`0`)}`}function Yt(e){let t=Kt(e);if(!Q(t))return null;let n=Number(t);return Number.isSafeInteger(n)&&n>=1?n:null}function Xt(e){let t=Yt(e);if(t===null)throw Error(`Event id is not slot-numbered: ${e}. This World allocates event positions the runtime cannot read.`);return t}const Zt=n.object({eventsCursor:n.string().nullable(),createdAt:n.coerce.date(),eventCount:n.number().int().nonnegative().optional(),rngDraws:n.number().int().nonnegative().optional(),serdeRootPtr:n.number().int().optional(),lastUlid:n.string().optional(),engineVersion:n.string().optional(),clockMs:n.number().optional(),formatVersion:n.number().int().optional()}),$=[87,83,78,80];function Qt(e,t){let n=new TextEncoder().encode(JSON.stringify(e)),r=new Uint8Array(9+n.length+t.length);return r.set($,0),r[4]=1,new DataView(r.buffer).setUint32(5,n.length,!0),r.set(n,9),r.set(t,9+n.length),r}function $t(e){if(e.length<9)return null;for(let t=0;t<$.length;t++)if(e[t]!==$[t])return null;if(e[4]!==1)return null;let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(5,!0);if(9+t>e.length)return null;try{let n=new TextDecoder().decode(e.subarray(9,9+t));return{metadata:Zt.passthrough().parse(JSON.parse(n)),data:e.subarray(9+t)}}catch{return null}}function en(e=process.env){return u(`WORKFLOW_SEALED_LOG`,!0,e)?8:6}function tn(e){return e==null||e<=1}function nn(e){return e!=null&&e>8}const rn=n.compile(n.string().ulid()),an=n.compile(n.templateLiteral([`wrun_`,n.ulid()])),on=864e5,sn=3e5;function cn(e){if(Q(e))return null;let t=rn.safeParse(e);return t.success?new Date(re(t.data)):null}function ln(e,t,n=on,r=sn){let i=cn(e.startsWith(t)?e.slice(t.length):e);if(!i)return`Invalid runId: "${e}" is not a valid ULID`;let a=new Date().getTime()-i.getTime();return a>0&&a<=n||a<=0&&-a<=r?null:`Invalid runId timestamp: embedded timestamp is ${Math.round(Math.abs(a)/1e3)}s in the ${a>0?`past`:`future`} (threshold: ${Math.round((a>0?n:r)/1e3)}s)`}var un=e({ANALYTICS_EVENTS_GET_MANY_LIMIT:()=>100,ANALYTICS_MAX_ATTRIBUTE_FILTERS:()=>8,ANALYTICS_PAGE_LIMIT:()=>100,ANALYTICS_RUN_SCOPED_PAGE_LIMIT:()=>ht,ATTRIBUTE_EVENT_DATA_MAX_BYTES:()=>y,ATTRIBUTE_KEY_MAX_LENGTH:()=>256,ATTRIBUTE_MAX_PER_RUN:()=>64,ATTRIBUTE_VALUE_MAX_BYTES:()=>256,BULK_CANCEL_MAX_RUN_IDS:()=>500,DEFAULT_TIMESTAMP_THRESHOLD_FUTURE_MS:()=>sn,DEFAULT_TIMESTAMP_THRESHOLD_MS:()=>DEFAULT_TIMESTAMP_THRESHOLD_MS,DEFAULT_TIMESTAMP_THRESHOLD_PAST_MS:()=>on,EVENT_ID_BODY_LENGTH:()=>26,EVENT_ID_PREFIX:()=>Gt,FIRST_EVENT_SLOT:()=>1,HOOK_RESUME_DEDUP_VERSION:()=>1,HOOK_RESUME_INPUT_VERSION:()=>1,HookSchema:()=>Ft,NODE_HTTP_DEFAULT:()=>!1,NODE_HTTP_ENV_VAR:()=>It,RESERVED_ATTRIBUTE_KEY_PREFIX:()=>`$`,RETENTION_DEFAULT:()=>v,RETENTION_ZERO:()=>`0`,RUN_ENTITY_KEY:()=>``,SEALED_LOG_ENV_VAR:()=>`WORKFLOW_SEALED_LOG`,SNAPSHOT_FORMAT_VERSION:()=>3,SPEC_VERSION_CURRENT:()=>8,SPEC_VERSION_LEGACY:()=>1,SPEC_VERSION_MAX_SUPPORTED:()=>8,SPEC_VERSION_SUPPORTS_ATTRIBUTES:()=>4,SPEC_VERSION_SUPPORTS_CBOR_QUEUE_TRANSPORT:()=>3,SPEC_VERSION_SUPPORTS_COMPRESSION:()=>5,SPEC_VERSION_SUPPORTS_EVENT_SOURCING:()=>2,SPEC_VERSION_SUPPORTS_HOOK_FORCE_CLAIM:()=>8,SPEC_VERSION_SUPPORTS_SEALED_LOG:()=>7,SPEC_VERSION_SUPPORTS_SLOT_IDENTITY:()=>6});export{ke as $,dt as A,K as B,_t as C,yt as D,xt as E,st as F,Xe as G,Qe as H,rt as I,Fe as J,ze as K,at as L,lt as M,ut as N,ht as O,pt as P,Ee as Q,et as R,jt as S,bt as T,Ye as U,$e as V,O as W,He as X,Ne as Y,D as Z,Rt as _,i as _t,tn as a,de as at,At as b,$t as c,ye as ct,qt as d,me as dt,E as et,Xt as f,re as ft,Ut as g,ee as gt,Wt as h,l as ht,an as i,x as it,ft as j,mt as k,Qt as l,pe as lt,Ht as m,le as mt,cn as n,C as nt,en as o,_ as ot,Jt as p,ce as pt,Le as q,ln as r,w as rt,nn as s,ue as st,un as t,Ce as tt,Yt as u,ve as ut,Lt as v,kt as w,St as x,Ft as y,nt as z};
@@ -1 +0,0 @@
1
- import{A as e,F as t}from"./dist-T5NnW-0k.js";function n(){let e,t;return{promise:new Promise((n,r)=>{e=n,t=r}),resolve:e,reject:t}}function r(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}var i=class e extends Error{items;steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(e,n){let r=[...e.values()],i=0,a=0,o=0,s=0,c=0,l=0;for(let e of r)e.type===`step`?i++:e.type===`hook`?e.disposed?c++:e.abortRequested?l++:a++:e.type===`wait`?o++:e.type===`attribute`&&s++;let u=[];i>0&&u.push(`${i} ${t(`step`,`steps`,i)}`),a>0&&u.push(`${a} ${t(`hook`,`hooks`,a)}`),o>0&&u.push(`${o} ${t(`wait`,`waits`,o)}`),s>0&&u.push(`${s} ${t(`attribute write`,`attribute writes`,s)}`),c>0&&u.push(`${c} hook ${t(`disposal`,`disposals`,c)}`);let d=i+a+o+s+c,f=t(`has`,`have`,d),p=+(i>0)+ +(a>0)+ +(o>0)+ +(s>0)+ +(c>0),m;m=p>1?`processed`:i>0?`run`:a>0||o>0?`created`:s>0?`written`:c>0?`processed`:`received`;let h=u.length>0?`${u.join(` and `)} ${f} not been ${m} yet`:`0 steps have not been run yet`;super(h),this.name=`WorkflowSuspension`,this.items=r,this.steps=r,this.globalThis=n,this.stepCount=i,this.hookCount=a,this.waitCount=o,this.attributeCount=s,this.hookDisposedCount=c,this.abortCount=l}static is(t){return t instanceof e}};function a(){throw new e(`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.`)}const o=Symbol.for(`@workflow/core//registeredSteps`),s=globalThis,c=s[o]??=new Map,l=new Set([`__builtin_response_array_buffer`,`__builtin_response_json`,`__builtin_response_text`]);function u(e){let t=e.split(`//`);if(t.length!==3||t[0]!==`step`)return[];let n=t[1],r=t[2],i=new Set,a=e=>{e!==n&&i.add(e)};if(n.startsWith(`./workflows/`)){let e=n.slice(2);a(`./example/${e}`),a(`./src/${e}`)}else if(n.startsWith(`./example/workflows/`)){let e=n.slice(10);a(`./${e}`),a(`./src/${e}`)}else if(n.startsWith(`./src/workflows/`)){let e=n.slice(6);a(`./${e}`),a(`./example/${e}`)}return Array.from(i,e=>`step//${e}//${r}`)}function d(e){if(l.has(e)){for(let[t,n]of c.entries())if(t.endsWith(`//${e}`))return n}}function f(e,t){c.set(e,t),t.stepId=e}function p(e){let t=c.get(e);if(t)return t;for(let t of u(e)){let e=c.get(t);if(e)return e}let n=d(e);if(n)return n}const m={hook:[`hook`,`wait`,`step`],wait:[`hook`,`step`],step:[`wait`,`hook`,`step`]};function h(e,t,n,r){return n>=t||!m[e].includes(r.kind)?!1:!(e===`step`&&!r.armed)}function g(e,t,n,r){let i=r.get(t);if(i!==void 0)return i;let a=_(e,t,n,r);return r.set(t,a),a}function _(e,t,n,r){if(!n.armed)return!1;for(let[i,a]of e)if(h(n.kind,t,i,a)&&!g(e,i,a,r))return!1;return!0}function v(){return process.env.WORKFLOW_LOG_ORDER_DRAWS!==`0`}function y(e){return e===0&&typeof setImmediate==`function`?new Promise(e=>setImmediate(e)):new Promise(t=>setTimeout(t,e))}async function b(e,t){for(;;){let n=e.mintCount??0,r=e.pendingDeliveries;if(await y(await e.promiseQueue.then(()=>!1,()=>!0)?50:0),(e.mintCount??0)!==n||r!==0||e.pendingDeliveries!==0)continue;let i=!1;for(let[n,r]of e.pendingDeliveryBarriers??[])if(n<t&&r.armed){i=!0;break}if(!i)return}}async function x(e,t,n){if(t===void 0||!e.pendingDeliveryBarriers)return;let r=e.pendingDeliveryBarriers,i=[];for(let[e,a]of r)h(n,t,e,a)&&i.push(a.released);if(i.length>0&&await Promise.all(i),v()){await b(e,t);return}i.length>0&&await new Promise(e=>setTimeout(e,0))}function S(t,r,i,a){let o=!1,s=()=>!o&&(o=!0,t.advanceClock?.(a.deliveredAt),!0),c=t.pendingDeliveryBarriers;if(!c||r===void 0)return{markDelivered:()=>{s()},arm:()=>{}};let l=a=>{if(c.has(r))throw new e(`Delivery barrier already registered at event index ${r}`);let{promise:o,resolve:s}=n(),l={kind:i,released:o,armed:a,retired:!1,retire:()=>{l.retired||(l.retired=!0,c.get(r)===l&&c.delete(r),s())}};return c.set(r,l),w(t),l},u=l(a.armed??!0);return{markDelivered:()=>{s()&&u.retire()},arm:()=>{if(!o){if(u.retired){u=l(!0);return}if(c.get(r)!==u)throw new e(`Delivery barrier lost ownership of event index ${r}`);u.armed=!0}}}}const C=new WeakSet;function w(e){let t=e.pendingDeliveryBarriers;if(!t||C.has(e))return;C.add(e);let n=()=>{setTimeout(i,0)},r=()=>{setTimeout(i,50)},i=()=>{if(t.size===0){C.delete(e);return}if(!T(e)){e.promiseQueue.then(n,r);return}for(;t.size>0&&T(e);){let e,n;for(let[r,i]of t)(e===void 0||r<e)&&(e=r,n=i);n?.retire()}setTimeout(i,0)};setTimeout(i,0)}function T(e){return e.pendingDeliveries===0&&!E(e)}function E(e){let t=e.pendingDeliveryBarriers;if(!t||t.size===0)return!1;let n=new Map;for(let[e,r]of t)if(g(t,e,r,n))return!0;return!1}function D(e){return e.pendingDeliveries===0&&(!e.pendingDeliveryBarriers||e.pendingDeliveryBarriers.size===0)}function O(e,t){let n=()=>{D(e)?t():e.promiseQueue.then(()=>{setTimeout(n,0)})};setTimeout(n,0)}function k(e){let t=e.suspensionGeneration;O(e,()=>{t===e.suspensionGeneration&&e.onWorkflowError(new i(e.invocationsQueue,e.globalThis))})}export{S as a,k as c,r as d,n as f,D as i,a as l,p as n,f as o,E as r,O as s,x as t,i as u};