eve 0.48.0 → 0.49.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +15 -0
- package/dist/src/channel/channel-address.js +1 -1
- package/dist/src/channel/types.d.ts +10 -0
- package/dist/src/cli/commands/registry-metadata.d.ts +30 -0
- package/dist/src/cli/commands/registry-metadata.js +1 -1
- package/dist/src/cli/commands/registry-package.d.ts +6 -0
- package/dist/src/cli/commands/registry-package.js +1 -1
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.d.ts +30 -0
- package/dist/src/cli/commands/registry-pnpm-build-policy-flow.js +1 -0
- package/dist/src/cli/commands/registry-pnpm-build-policy.d.ts +12 -0
- package/dist/src/cli/commands/registry-pnpm-build-policy.js +6 -0
- package/dist/src/cli/commands/registry-recovery.d.ts +4 -0
- package/dist/src/cli/commands/registry-recovery.js +1 -1
- package/dist/src/cli/commands/registry.d.ts +1 -1
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/tui/setup-commands.js +2 -2
- package/dist/src/compiled/.vendor-stamp.json +7 -7
- package/dist/src/compiled/@workflow/core/attribute-changes.d.ts +2 -4
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +10 -9
- package/dist/src/compiled/@workflow/core/capture-stack.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/class-serialization.d.ts +8 -8
- package/dist/src/compiled/@workflow/core/context-violation-error.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/describe-error.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/encryption.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +49 -14
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/global.d.ts +4 -2
- package/dist/src/compiled/@workflow/core/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/log-format.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/private.d.ts +40 -78
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +13 -17
- package/dist/src/compiled/@workflow/core/runtime/compute-instance.d.ts +4 -3
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +27 -27
- package/dist/src/compiled/@workflow/core/runtime/count-step-started-events.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/runtime/deployment-guard.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/runtime/get-port-lazy.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +30 -49
- package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +21 -10
- package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +31 -15
- package/dist/src/compiled/@workflow/core/runtime/quickjs-serde.d.ts +10 -10
- package/dist/src/compiled/@workflow/core/runtime/replay-budget.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/runtime/replay-recovery-reporter.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +20 -12
- package/dist/src/compiled/@workflow/core/runtime/resume-latency.d.ts +37 -30
- package/dist/src/compiled/@workflow/core/runtime/run-id-time.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/run.d.ts +22 -5
- package/dist/src/compiled/@workflow/core/runtime/runs.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +3 -3
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +14 -14
- package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +42 -25
- package/dist/src/compiled/@workflow/core/runtime/step-ownership.d.ts +6 -6
- package/dist/src/compiled/@workflow/core/runtime/step-single-flight.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime/suspension-handler.d.ts +38 -24
- package/dist/src/compiled/@workflow/core/runtime/unserializable-step.d.ts +34 -0
- package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/wait-continuation.d.ts +31 -9
- package/dist/src/compiled/@workflow/core/runtime/wait-until.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime/world-compatibility.d.ts +20 -9
- package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/sealed-box.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/serialization/codec-devalue-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/codec-devalue.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +12 -11
- package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +7 -7
- package/dist/src/compiled/@workflow/core/serialization/format.d.ts +6 -6
- package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +23 -22
- package/dist/src/compiled/@workflow/core/serialization/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/reducers/class-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/reducers/step-function-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/serialization/workflow-vm.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization-format.d.ts +11 -11
- package/dist/src/compiled/@workflow/core/serialization.d.ts +18 -19
- package/dist/src/compiled/@workflow/core/source-map.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +5 -5
- package/dist/src/compiled/@workflow/core/step/writable-stream.d.ts +3 -3
- package/dist/src/compiled/@workflow/core/symbols.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +71 -20
- package/dist/src/compiled/@workflow/core/telemetry.d.ts +15 -3
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/vm/script-cache.d.ts +9 -11
- package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +18 -18
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +3 -2
- package/dist/src/compiled/@workflow/world/attributes-validation.d.ts +28 -0
- package/dist/src/compiled/@workflow/world/attributes.d.ts +8 -107
- package/dist/src/compiled/@workflow/world/env-config.d.ts +5 -5
- package/dist/src/compiled/@workflow/world/event-metadata.d.ts +132 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +42 -96
- package/dist/src/compiled/@workflow/world/hooks.d.ts +12 -11
- package/dist/src/compiled/@workflow/world/index.d.ts +3 -3
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +94 -39
- package/dist/src/compiled/@workflow/world/queue.d.ts +29 -22
- package/dist/src/compiled/@workflow/world/runs.d.ts +20 -0
- package/dist/src/compiled/@workflow/world/slot-identity.d.ts +3 -3
- package/dist/src/compiled/@workflow/world/spec-version.d.ts +82 -15
- package/dist/src/compiled/@workflow/world/ulid.d.ts +2 -2
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +12 -12
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-DXbpwBdw.js → attribute-changes-BwAadFfB.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/debug-log-CVPstO1D.js +1 -0
- package/dist/src/compiled/_chunks/workflow/dist-CgbVZs5l.js +40 -0
- package/dist/src/compiled/_chunks/workflow/dist-DjojkP5e.js +3 -0
- package/dist/src/compiled/_chunks/workflow/frames-CZ9eHShe.js +3 -0
- package/dist/src/compiled/_chunks/workflow/global-singleton-BNinwFrL.js +1 -0
- package/dist/src/compiled/_chunks/workflow/private-CZFMABEf.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-BToMtPbH.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-DzyAoGh4.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-3_A5uOp-.js +1 -0
- package/dist/src/compiled/_chunks/workflow/undici-DfxNX5og.js +95 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-BtySPYD0.js +15 -0
- package/dist/src/compiled/_chunks/workflow/ws-transport-PnVVxT0R.js +1 -0
- package/dist/src/eve-channel/index.js +1 -1
- package/dist/src/execution/agent-handle-dispatch.js +1 -1
- package/dist/src/execution/continuation-conflict-step.d.ts +10 -0
- package/dist/src/execution/continuation-conflict-step.js +1 -0
- package/dist/src/execution/delegated-parent-notification.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-shared.d.ts +7 -29
- package/dist/src/execution/dispatch-runtime-actions-shared.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-start.d.ts +33 -0
- package/dist/src/execution/dispatch-runtime-actions-start.js +1 -0
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/dispatch-turn-step.js +1 -1
- package/dist/src/execution/dynamic-connections.js +1 -1
- package/dist/src/execution/inline-turn.js +1 -1
- package/dist/src/execution/next-driver-action.d.ts +5 -4
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/runtime-errors.d.ts +0 -12
- package/dist/src/execution/runtime-errors.js +1 -1
- package/dist/src/execution/session-timeout-steps.js +1 -1
- package/dist/src/execution/settle-cancelled-turn-step.js +1 -1
- package/dist/src/execution/stable-workflow-names.d.ts +2 -2
- package/dist/src/execution/subagent-start-local.js +1 -1
- package/dist/src/execution/tasks/parent/dispatch-task-step.js +1 -1
- package/dist/src/execution/tasks/parent/run-parent.js +1 -1
- package/dist/src/execution/tasks/parent/tool-execution.js +1 -1
- package/dist/src/execution/tool-run/start.js +1 -1
- package/dist/src/execution/tools/subagent/local.js +1 -1
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-entry.d.ts +5 -1
- package/dist/src/execution/workflow-entry.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +12 -12
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/workflow/development-world-client.js +1 -1
- package/dist/src/packages/eve-catalog/src/index.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +7 -1
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/setup/flows/registry.js +1 -1
- package/dist/src/setup/scaffold/connections/catalog.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/docs/channels/custom.mdx +4 -0
- package/docs/channels/eve.mdx +12 -8
- package/docs/channels/mcp.mdx +4 -1
- package/docs/guides/instrumentation.md +1 -1
- package/docs/install-integrations.mdx +2 -0
- package/docs/instructions.mdx +1 -1
- package/docs/memory/custom-provider.md +214 -0
- package/docs/memory/file.md +129 -0
- package/docs/memory/meta.json +5 -0
- package/docs/memory/overview.mdx +282 -0
- package/docs/patterns/multi-tenant-memory.md +12 -20
- package/package.json +8 -8
- package/dist/src/compiled/_chunks/workflow/dist-CqvWKNQv.js +0 -3
- package/dist/src/compiled/_chunks/workflow/dist-Dk0aQqFO.js +0 -40
- package/dist/src/compiled/_chunks/workflow/dist-DpYyXbJv.js +0 -1
- package/dist/src/compiled/_chunks/workflow/env-config-L94XftKz.js +0 -1
- package/dist/src/compiled/_chunks/workflow/frames-Dl2Hcma4.js +0 -3
- package/dist/src/compiled/_chunks/workflow/private-CuQ4HTFC.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-E-Nkx8q_.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-cIeex2KF.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-CxFsdxB_.js +0 -1
- package/dist/src/compiled/_chunks/workflow/spec-version-DBUVfF_R.js +0 -1
- package/dist/src/compiled/_chunks/workflow/undici-DznrXKcM.js +0 -95
- package/dist/src/compiled/_chunks/workflow/wait-until-BZHmJCAW.js +0 -15
- package/dist/src/compiled/_chunks/workflow/ws-transport-Ct6yyRWZ.js +0 -1
- package/docs/memory.md +0 -408
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./global-singleton-BNinwFrL.js";import{$n as t,A as n,B as r,C as i,Dr as a,F as o,J as s,N as c,On as l,Pr as u,S as d,Un as ee,Vn as te,Y as f,Z as p,Zn as m,_n as ne,ar as h,c as re,cr as ie,dr as ae,er as oe,ft as g,ht as se,ir as _,kn as ce,lr as le,n as v,o as y,sr as ue,t as de,ur as b,ut as fe,z as x}from"./wait-until-BtySPYD0.js";import{A as S,C,D as w,E as T,O as E,T as D,_ as O,h as k,k as A,l as j,p as M,r as N,s as P,t as F,w as I,x as L}from"./dist-DjojkP5e.js";import{t as pe}from"./attribute-changes-BwAadFfB.js";import{O as R,c as z,i as me,it as B,o as V,rt as H}from"./dist-CgbVZs5l.js";const U=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,S.WORLD_CONTRACT_ERROR]),W=new Set([`TRANSPORT`,`TIMEOUT`]),he=[E.is,k.is,C.is,M.is];function G(e){if(!A.is(e)||e.status!==void 0)return!1;let t=`cause`in e?e.cause:void 0;return e.code!==void 0&&U.has(e.code)||e.message.startsWith(`Failed to parse response body for `)||e.message.startsWith(`Schema validation failed for `)||typeof t==`object`&&!!t&&`name`in t&&t.name===`ZodError`}function K(e){return O.is(e)?!0:A.is(e)?e.status!==void 0&&e.status>=500||e.code!==void 0&&W.has(e.code):!1}function ge(e){if(j.is(e))return S.REPLAY_DIVERGENCE;if(F.is(e))return S.CORRUPTED_EVENT_LOG;if(P.is(e))return S.MAX_EVENTS_EXCEEDED;if(L.is(e))return S.DEPLOYMENT_MISMATCH;if(G(e)||K(e))return S.WORLD_CONTRACT_ERROR;for(let t of he)if(t(e))return S.RUNTIME_ERROR;return S.USER_ERROR}const q=[`node`,`quickjs`];function J(e=process.env){let t=e.WORKFLOW_VM;if(!(t===void 0||t===``)){if(q.includes(t))return t;throw new E(`Invalid WORKFLOW_VM value: "${t}". Expected one of: ${q.join(`, `)}.`)}}function _e(e){let t=e.executionContext?.workflowVm;if(t!==void 0){if(!q.includes(t))throw new E(`Invalid executionContext.workflowVm value: "${t}". Expected one of: ${q.join(`, `)}.`);return t===`quickjs`}return J()===`quickjs`}const ve=V();function ye(){let e=f.getStore(),t=e?.workflowMetadata?.workflowRunId;if(t)return{[B]:e.rootRunId??t,[H]:t}}const Y=e(`@workflow/core//latestNoOpWarning`,1,()=>({warned:!1}));async function X(e,r,o){"use step";return await v(()=>{let s=e?.workflowId;if(!s)throw new E(`'start' received an invalid workflow function. Ensure the Workflow SDK is configured correctly and the function includes a 'use workflow' directive.`,{slug:`start-invalid-workflow-function`});return g(`workflow.start ${u(s)}`,async e=>{e?.setAttributes({...l(s),...ce(`start`)});let c=[],u=o??{};Array.isArray(r)?c=r:typeof r==`object`&&(u=r),e?.setAttributes({...ne(c.length)});let f=u.world??await b();ae(f);let m=await f.getDeploymentId(),h=u.deploymentId??m;h===`latest`&&(f.resolveLatestDeploymentId?h=await f.resolveLatestDeploymentId():(Y.warned||(Y.warned=!0,p.warn(`deploymentId: 'latest' has no effect in this world and was ignored. It is only supported by worlds with atomic deployments, such as Vercel. The run will target the current deployment.`,{currentDeploymentId:m})),h=m));let g=`wrun_${f.createRunId?f.createRunId(u):ve()}`,_,v,x,S;if(h===m)_=!0,v=!0,x=1;else if(typeof f.streams?.get!=`function`)_=!1,v=!1,x=void 0;else{let e=await re(f,{deploymentId:h,runId:g,timeout:2e3,namespace:u.namespace}).catch(()=>void 0);S=e?.encryptionPublicKey;let t=i(e?.workflowCoreVersion);_=t.framedByteStreams,v=t.supportedFormats.has(oe.GZIP),x=e?.hookResumeInputVersion}let C=[],w=await fe(),T=u.specVersion??f.specVersion,D=z(T),O=u.allowReservedAttributes===!0,k;if(u.attributes&&Object.keys(u.attributes).length>0){if(T<4)throw new E(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(u.attributes))if(typeof t!=`string`)throw new E(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=pe(u.attributes,{allowReservedAttributes:O});k=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let A=T>=4?ye():void 0,j=A?{...A,...k}:k,M=j?{attributes:j,...O||A!=null?{allowReservedAttributes:!0}:{}}:{};if(u.replayedFromRunId!==void 0&&!me.safeParse(u.replayedFromRunId).success)throw new E(`replayedFromRunId must be a run ID (wrun_<ulid>); received ${JSON.stringify(String(u.replayedFromRunId).slice(0,64))}.`);let P=ie(S),F,I;if(P)F=t(P),I=S;else{let e=await f.getEncryptionKeyForRun?.(g,{...u,deploymentId:h});F=e?await a(e):void 0,I=e?ue((await le(e)).publicKey):void 0}let L=await n(c,g,F,C,globalThis,D,_,v&&T>=5),R=f.getEnvironment?.(),B=J(),V={traceCarrier:w,workflowCoreVersion:d,features:{encryption:!!F},...x===void 0?{}:{hookResumeInputVersion:x},...B?{workflowVm:B}:{},...u.replayedFromRunId?{replayedFromRunId:u.replayedFromRunId}:{}},[H,U]=await Promise.allSettled([f.events.create(g,{eventType:`run_created`,specVersion:T,eventData:{deploymentId:h,workflowName:s,input:L,executionContext:V,...I?{encryptionPublicKey:I}:{},...M}},{v1Compat:D}),f.queue(y(s,u.namespace),{runId:g,traceCarrier:w,...T>=3?{runInput:{input:L,deploymentId:h,workflowName:s,specVersion:T,executionContext:V,...I?{encryptionPublicKey:I}:{},...R===void 0?{}:{environment:R},...M}}:{}},{deploymentId:h,specVersion:T,...u.region===void 0?{}:{region:u.region}})]);if(U.status===`rejected`)throw U.reason;let W=!1;if(H.status===`rejected`){let e=H.reason;if(!N.is(e))if(K(e))W=!0,p.warn(`Run creation event failed, but the run was accepted via the queue. The run_created event will be re-tried async by the runtime.`,{workflowRunId:g,error:e.message});else throw e}else{let e=H.value;if(!D&&e.run.runId!==g)throw new E(`Server returned different runId than requested: expected ${g}, got ${e.run.runId}`)}return de(Promise.all(C),e=>{p.warn(`Background flush of workflow argument streams failed`,{workflowRunId:g,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...te(g),...se(h),...H.status===`fulfilled`?ee(H.value.run.status):{}}),new $(g,{resilientStart:W})})})}const be=e=>Array.isArray(e)?e:[e];async function xe(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await m(i):void 0,o=be(await x(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await X({workflowId:r.workflowName},o,{deploymentId:c,world:e,specVersion:s,replayedFromRunId:t,namespace:n.namespace})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Z(e,t,n){try{let r=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,i=z(r),a={eventType:`run_cancelled`,specVersion:r,...n?.cancelReason===void 0?{}:{eventData:{cancelReason:n.cancelReason}}};await e.events.create(t,a,{v1Compat:i})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Se(e,t,n){if(t.length===0)throw Error(`cancelRuns requires at least one run ID.`);if(t.length>500)throw Error(`cancelRuns accepts at most 500 run IDs (received ${t.length}).`);if(new Set(t).size!==t.length)throw Error(`cancelRuns requires unique run IDs (duplicates found).`);if(e.runs.cancelMany)return e.runs.cancelMany({runIds:t,...n?.cancelReason===void 0?{}:{cancelReason:n.cancelReason}});let r=Array(t.length),i=0,a=async()=>{for(;;){let a=i++;if(a>=t.length)return;let o=t[a];try{await Z(e,o,n),r[a]={runId:o,outcome:`cancelled`}}catch{r[a]={runId:o,outcome:`failed`,code:`internal_error`,retryable:!0}}}},o=Math.min(20,t.length);await Promise.all(Array.from({length:o},()=>a()));let s={requested:t.length,cancelled:0,alreadyCancelled:0,notCancellable:0,notFound:0,failed:0};for(let e of r)switch(e.outcome){case`cancelled`:s.cancelled++;break;case`already_cancelled`:s.alreadyCancelled++;break;case`not_cancellable`:s.notCancellable++;break;case`not_found`:s.notFound++;break;case`failed`:s.failed++;break}return{summary:s,results:r}}async function Ce(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`});await e.queue(y(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1})}catch(e){throw Error(`Failed to re-enqueue run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Q(e,t,n){try{let r=await e.runs.get(t,{resolveData:`none`}),i=z(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{sortOrder:`asc`,...o?{cursor:o}:{}},resolveData:`none`});a.push(...n.data),o=n.hasMore?n.cursor:null}while(o);let s=a.filter(e=>e.eventType===`wait_created`),c=new Set(a.filter(e=>e.eventType===`wait_completed`).map(e=>e.correlationId)),l=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);l=l.filter(t=>t.correlationId&&e.has(t.correlationId))}let u=[],d=0;for(let n of l){if(!n.correlationId)continue;let a=i?{eventType:`wait_completed`,correlationId:n.correlationId}:{eventType:`wait_completed`,correlationId:n.correlationId,specVersion:r.specVersion,eventData:{resumeAt:n.eventData.resumeAt}};try{await e.events.create(t,a,{v1Compat:i}),d++}catch(e){N.is(e)?d++:u.push(e instanceof Error?e:Error(String(e)))}}if(d>0&&await e.queue(y(r.workflowName,n?.namespace),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),u.length>0)throw AggregateError(u,`Failed to complete ${u.length}/${l.length} pending wait(s) for run ${t}`);return{stoppedCount:d}}catch(e){throw e instanceof AggregateError?e:Error(`Failed to wake up run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function we(e,t,n,r){try{return await e.streams.get(t,n,r?.startIndex)}catch(e){throw Error(`Failed to read stream ${n}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function Te(e,t){try{return await e.streams.list(t)}catch(e){throw Error(`Failed to list streams for run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}const Ee=new Set([`completed`,`failed`]);function De(){return R(`WORKFLOW_RETURN_VALUE_POLL_INTERVAL_MS`,1e3,{integer:!0,min:1})}function Oe(){return R(`WORKFLOW_RETURN_VALUE_WAIT_MS`,5e4,{integer:!0,min:1})}function ke(){return R(`WORKFLOW_RETURN_VALUE_MAX_LONG_POLLS`,10,{integer:!0,min:1})}function Ae(){let e=process.env.WORKFLOW_RETURN_VALUE_LONG_POLL;return e===void 0||e===``||!(e===`0`||e.toLowerCase()===`false`)}var $=class e{static[h](e){return{runId:e.runId,resilientStart:e.#r}}static[_](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=b(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(e){return this.#n||=(async()=>{let t=await this.#t,n=e??await t.runs.get(this.runId),r=await t.getEncryptionKeyForRun?.(n);return r?await m(r):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Q(await this.#t,this.runId,e)}async cancel(e){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:7,...e?.cancelReason===void 0?{}:{eventData:{cancelReason:e.cancelReason}}})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(w.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(e=>e.status))}get returnValue(){"use step";return this.#s()}get workflowName(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.workflowName))}get createdAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.createdAt))}get startedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.startedAt))}get completedAt(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.completedAt))}get readable(){return this.getReadable()}getReadable(e={}){"use step";let{ops:t=[],global:n=globalThis,startIndex:r,namespace:i}=e,a=s(this.runId,i),o=this.#a(),l=c(n,t,this.runId,o).ReadableStream({name:a,startIndex:r}),u=this.#t,d=this.runId;return Object.assign(l,{getTailIndex:async()=>(await(await u).streams.getInfo(d,a)).tailIndex})}async#o(e){if(e.status===`completed`){let t=await this.#i(e);return await r(e.output,this.runId,t)}if(e.status===`cancelled`)throw new I(this.runId);if(e.status===`failed`){let t=await this.#i(e),n;try{n=await o(e.error,this.runId,t)}catch{n=Error(`Failed to hydrate workflow run error`)}throw new D(this.runId,n,{errorCode:e.errorCode})}throw new T(this.runId,e.status)}async#s(){let e=await this.#t,t=0,n=this.#r?3:0,r=[1e3,3e3,6e3],i=Ae()?e.runs.waitForTerminalStatus?.bind(e.runs):void 0,a=0,o=ke();for(;;){let s=Date.now();try{let t=i&&a<o;t&&a++;let n=t?await i(this.runId,{timeoutMs:Oe(),resolveData:`none`}):await e.runs.get(this.runId,{resolveData:`none`});if(n.status===`cancelled`)throw new I(this.runId);if(Ee.has(n.status)){let t=await e.runs.get(this.runId,{resolveData:`all`});return await this.#o(t)}throw new T(this.runId,n.status)}catch(e){if(T.is(e)){let e=De()-(Date.now()-s);e>0&&await new Promise(t=>setTimeout(t,e));continue}if(w.is(e)&&t<n){let e=r[t];t++,await new Promise(t=>setTimeout(t,e));continue}throw e}}}};function je(e){return new $(e)}export{Te as a,Ce as c,_e as d,ge as f,Se as i,Q as l,G as m,je as n,we as o,K as p,Z as r,xe as s,$ as t,X as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Tr as e}from"./wait-until-BtySPYD0.js";import{i as t}from"./attribute-changes-BwAadFfB.js";async function n(r){let i=globalThis[e];return i||t(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
|