eve 0.22.5 → 0.23.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 +18 -0
- package/dist/src/channel/types.d.ts +1 -1
- package/dist/src/compiled/.vendor-stamp.json +4 -4
- 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/runtime/start.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime/step-latency.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +1 -1
- package/dist/src/compiled/@workflow/core/set-attributes.d.ts +12 -7
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +20 -16
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/recovery.d.ts +3 -2
- package/dist/src/compiled/@workflow/world-local/index.js +2 -2
- package/dist/src/compiled/@workflow/world-vercel/index.js +3 -3
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-ubiPfqvY.js → attribute-changes-Dmf_myUv.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-DnBjuNAZ.js → dist-CQenixFf.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{resume-hook-BkVkWg2r.js → resume-hook-BH01MfRF.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{run-B3N1kN9q.js → run-CL3mguvM.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{sleep-C2Bn-UUg.js → sleep-BkAHCD_s.js} +1 -1
- package/dist/src/compiler/artifacts.d.ts +0 -1
- package/dist/src/compiler/artifacts.js +1 -1
- package/dist/src/compiler/manifest.js +1 -1
- package/dist/src/compiler/normalize-agent-config.js +1 -1
- package/dist/src/execution/create-session-step.js +1 -1
- package/dist/src/execution/dispatch-runtime-actions-step.js +1 -1
- package/dist/src/execution/durable-session-store.d.ts +0 -1
- package/dist/src/execution/node-step.d.ts +1 -1
- package/dist/src/execution/node-step.js +1 -1
- package/dist/src/execution/run-session-limits.d.ts +1 -1
- package/dist/src/execution/sandbox/prewarm.js +1 -1
- package/dist/src/execution/session.d.ts +0 -1
- package/dist/src/execution/session.js +2 -2
- package/dist/src/execution/subagent-tool.js +1 -1
- package/dist/src/harness/advertised-tools.d.ts +1 -1
- package/dist/src/harness/advertised-tools.js +1 -1
- package/dist/src/harness/execute-tool.d.ts +1 -0
- package/dist/src/harness/subagent-depth.d.ts +2 -5
- package/dist/src/harness/subagent-depth.js +1 -1
- package/dist/src/harness/types.d.ts +1 -7
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/application/paths.d.ts +1 -0
- package/dist/src/internal/application/paths.js +1 -1
- package/dist/src/internal/authored-definition/core.js +1 -1
- package/dist/src/internal/nitro/host/prepare-application-host.js +1 -1
- package/dist/src/internal/nitro/host/vercel-build-output-config.d.ts +1 -0
- package/dist/src/internal/nitro/host/vercel-build-output-config.js +1 -1
- package/dist/src/public/channels/chat-sdk/chatSdkChannel.js +1 -1
- package/dist/src/public/channels/index.d.ts +14 -64
- package/dist/src/public/instrumentation/index.d.ts +1 -1
- package/dist/src/public/next/server.js +1 -1
- package/dist/src/runtime/resolve-agent-graph.js +1 -1
- package/dist/src/runtime/resolve-agent.js +1 -1
- package/dist/src/runtime/sessions/compiled-agent-cache.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/create/web-template.d.ts +1 -1
- package/dist/src/setup/scaffold/create/web-template.js +0 -1
- package/dist/src/shared/agent-definition.d.ts +0 -12
- package/docs/agent-config.md +8 -8
- package/docs/channels/custom.mdx +1 -3
- package/docs/concepts/default-harness.md +7 -5
- package/docs/extensions.md +1 -3
- package/docs/guides/dynamic-workflows.md +1 -1
- package/docs/guides/instrumentation.md +1 -1
- package/docs/subagents.mdx +13 -26
- package/package.json +5 -5
- package/dist/src/compiler/channel-instrumentation-types.d.ts +0 -8
- package/dist/src/compiler/channel-instrumentation-types.js +0 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as e,t}from"./chunk-BHKSVoKr.js";import{c as n,d as r,f as i,l as a,p as o,s,u as c}from"./dist-CttsoN4D.js";import{E as l,T as u,a as d,c as f,d as p,f as m,i as h,s as g,w as _}from"./dist-DpDDcpTl.js";import{K as v,W as y,b,d as ee,g as te,o as ne,v as re}from"./dist-
|
|
1
|
+
import{a as e,t}from"./chunk-BHKSVoKr.js";import{c as n,d as r,f as i,l as a,p as o,s,u as c}from"./dist-CttsoN4D.js";import{E as l,T as u,a as d,c as f,d as p,f as m,i as h,s as g,w as _}from"./dist-DpDDcpTl.js";import{K as v,W as y,b,d as ee,g as te,o as ne,v as re}from"./dist-CQenixFf.js";import{getStepFunction as ie}from"../../@workflow/core/private.js";import{types as ae}from"node:util";import{AsyncLocalStorage as oe}from"node:async_hooks";function se(e,t){let n=Error.captureStackTrace;n?.(e,t)}const ce=(()=>{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})(),x=(e,t)=>n=>ce?`\x1b[${e}m${n}\x1b[${t}m`:n,S={bold:x(1,22),dim:x(2,22),italic:x(3,23),red:x(31,39),blue:x(34,39),cyan:x(36,39),yellow:x(33,39),magenta:x(35,39)},le={info:S.blue,help:S.cyan,warn:S.yellow,error:S.red};function ue(e){let t=Array.isArray(e)?e.join(`
|
|
2
2
|
`):e;return le.info(`${S.bold(`hint:`)} ${t}`)}function de(e){return le.info(`${S.bold(`docs:`)} ${e}`)}function fe(e){return S.italic(`${S.dim("`")}${e}${S.dim("`")}`)}function C(e){return S.dim(e)}function pe(e){return S.bold(e)}function me(e){return S.red(e)}function he(e){return S.magenta(e)}function ge(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
4
|
`)}const _e=Symbol.for(`nodejs.util.inspect.custom`);function ve(e){return`code`in e?`\`${e.code}\``:`dim`in e?e.dim:e.text}function ye(e){return`code`in e?fe(e.code):`dim`in e?C(e.dim):e.text}function be(e){return e.type===`docs`?`docs: ${e.url}`:e.segments.map(ve).join(``)}function xe(e){return e.type===`docs`?de(e.url):e.segments.map(ye).join(``)}function Se(e){let t=[e.title.map(ve).join(``)];return e.details.forEach((n,r)=>{let i=r===e.details.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;be(n).split(`
|
|
@@ -17,4 +17,4 @@ import{a as e,t}from"./chunk-BHKSVoKr.js";import{c as n,d as r,f as i,l as a,p a
|
|
|
17
17
|
`)?e.split(`
|
|
18
18
|
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
19
19
|
`):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var vr=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,o=0,s=0,c=0,l=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?c++:e.abortRequested?l++:i++:e.type===`wait`?o++:e.type===`attribute`&&s++;let u=[];r>0&&u.push(`${r} ${a(`step`,`steps`,r)}`),i>0&&u.push(`${i} ${a(`hook`,`hooks`,i)}`),o>0&&u.push(`${o} ${a(`wait`,`waits`,o)}`),s>0&&u.push(`${s} ${a(`attribute write`,`attribute writes`,s)}`),c>0&&u.push(`${c} hook ${a(`disposal`,`disposals`,c)}`);let d=a(`has`,`have`,r+i+o+s+c),f=+(r>0)+ +(i>0)+ +(o>0)+ +(s>0)+ +(c>0),p;p=f>1?`processed`:r>0?`run`:i>0||o>0?`created`:s>0?`written`:c>0?`processed`:`received`;let m=u.length>0?`${u.join(` and `)} ${d} not been ${p} yet`:`0 steps have not been run yet`;super(m),this.name=`WorkflowSuspension`,this.steps=n,this.globalThis=t,this.stepCount=r,this.hookCount=i,this.waitCount=o,this.attributeCount=s,this.hookDisposedCount=c,this.abortCount=l}static is(t){return t instanceof e}};function yr(){throw new _(`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 q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const br=q(`workflow.name`),xr=q(`workflow.operation`),Sr=q(`workflow.run.id`),Cr=q(`workflow.run.status`),wr=q(`workflow.started_at`),Tr=q(`workflow.events.count`),Er=q(`workflow.arguments.count`),Dr=q(`workflow.result.type`),Or=q(`workflow.trace.propagated`),kr=q(`workflow.trace.mode`),Ar=q(`workflow.turbo`),jr=q(`workflow.error.name`),Mr=q(`workflow.error.message`),Nr=q(`workflow.error.code`),Pr=q(`workflow.steps.created`),Fr=q(`workflow.hooks.created`),Ir=q(`workflow.waits.created`),Lr=q(`workflow.inline_ownership.owned_recovery_steps`),Rr=q(`workflow.inline_ownership.backstop_wakes_armed`),zr=q(`workflow.route.type`),Br=q(`workflow.route.handler_cached`),Vr=q(`workflow.route.invocation_count`),Hr=q(`workflow.route.entrypoint_age_ms`),Ur=q(`workflow.route.module_body_init_ms`),Wr=q(`step.name`),Gr=q(`step.id`),Kr=q(`step.attempt`),qr=q(`step.status`),Jr=q(`step.max_retries`),Yr=q(`step.ttfs_ms`),Xr=q(`step.stso_ms`),Zr=q(`step.latency_optimizations`),Qr=q(`step.skipped`),$r=q(`step.skip_reason`),ei=q(`step.arguments.count`),ti=q(`step.result.type`),ni=q(`step.error.name`),ri=q(`step.error.message`),ii=q(`step.fatal_error`),ai=q(`step.retry.exhausted`),oi=q(`step.retry.timeout_seconds`),si=q(`step.retry.will_retry`),ci=q(`messaging.system`),li=q(`messaging.destination.name`),ui=q(`messaging.message.id`),di=q(`messaging.operation.type`),fi=q(`workflow.queue.overhead_ms`),pi=q(`deployment.id`),mi=q(`workflow.hook.token`),hi=q(`workflow.hook.id`),gi=q(`workflow.hook.found`),_i=q(`workflow.suspension.state`),vi=q(`workflow.suspension.hook_count`),yi=q(`workflow.suspension.step_count`),bi=q(`workflow.suspension.wait_count`),xi=q(`http.request.method`),Si=q(`http.route`),Ci=q(`http.response.status_code`),wi=q(`error.type`),Ti=q(`workflow.events.pages_loaded`),Ei=q(`workflow.queue.deserialize_time_ms`),Di=q(`workflow.queue.execution_time_ms`),Oi=q(`workflow.queue.serialize_time_ms`),ki=q(`workflow.serialization.operation`),Ai=q(`workflow.serialization.compressed`),ji=q(`workflow.serialization.codec`),Mi=q(`workflow.serialization.uncompressed_bytes`),Ni=q(`workflow.serialization.stored_bytes`),Pi=q(`workflow.serialization.compression_ratio`),Fi=q(`peer.service`),Ii=q(`rpc.system`),Li=q(`rpc.service`),Ri=q(`rpc.method`),zi=q(`error.retryable`),Bi=q(`error.category`),Vi=new Set;function Hi(){let e=process.env.WORKFLOW_TRACE_MODE;return e===`continuous`?`continuous`:(e&&e!==`linked`&&!Vi.has(e)&&(Vi.add(e),Y.warn(`Unrecognized WORKFLOW_TRACE_MODE value "${e}"; expected "linked" or "continuous". Falling back to "linked".`)),`linked`)}function Ui(e){return e!==void 0&&Object.keys(e).length>0}function Wi(e,t){return e===`linked`&&Ui(t)?Promise.resolve(t):Ki()}async function Gi(e,t){if(e!==`linked`)return ra();let n=await ia(Ui(t)?t:void 0);return n?[n]:void 0}async function Ki(){let e=await J.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function qi(e){let t=await J.value;if(t)return t.propagation.extract(t.context.active(),e)}async function Ji(e,t){if(!e)return t();let n=await J.value;if(!n)return t();let r=await qi(e);return r?n.context.with(r,async()=>await t()):t()}const J=s(async()=>{try{return await import(`./src-CQuMexnO.js`).then(t=>e(t.t(),1))}catch{return Y.info(`OpenTelemetry not available, tracing will be disabled`),null}}),Yi=s(async()=>{let e=await J.value;return e?e.trace.getTracer(`workflow`):null});async function Xi(e,...t){let[n,r]=await Promise.all([Yi.value,J.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}),Qi(t,r,e),t}finally{e.end()}})}async function Zi(e,t,n){let r=await Yi.value;r&&r.startSpan(e,{...n,startTime:t}).end()}function Qi(e,t,n){!e||!vr.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({..._i(`suspended`),...yi(e.stepCount),...vi(e.hookCount),...bi(e.waitCount)}))}async function $i(e){let[t,n]=await Promise.all([qi(e),J.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function ea(){return await na(e=>e.trace.getActiveSpan())}async function ta(e){return na(t=>t.SpanKind[e])}async function na(e){let t=await J.value;if(t)return await e(t)}function ra(){return na(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function ia(e){if(!e)return;let[t,n]=await Promise.all([$i(e),J.value]);if(!(!t||!n)&&n.trace.isSpanContextValid(t))return{context:t}}async function aa(e,t){let n=await J.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 oa(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 sa(e,t={}){let n=r=>{let i=n=>t.debugNamespace??`workflow:${e}:${n}`,a=t=>{let n=i(t);return(i,a)=>{let o=Object.keys(r).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...r,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(dr(`[workflow-sdk]`,i,c)),oa(n,process.env.DEBUG)&&(console.debug(`[${n}] ${i}`,c??``),ea().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:a(`debug`),info:a(`info`),warn:a(`warn`),error:a(`error`),child:e=>n({...r,...e}),forRun:(e,t,i)=>n({...r,workflowRunId:e,...t===void 0?{}:{workflowName:t},...i??{}})}};return n({})}const ca=sa(`step`),Y=sa(`runtime`),la=sa(`webhook`),ua=sa(`events`);sa(`adapter`),sa(`build`,{debugNamespace:`workflow:build`});function da(e){if(p.is(e))throw e}function X(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof D&&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 D&&t.value!==void 0&&Y.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function fa(e,t,n){try{let r=H.serialize(e,`client`,n);return lr(await or(U(V.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){da(e);let{message:t,hint:n}=X(`client value`,e);throw new m(t,{hint:n,cause:e})}}async function pa(e,t,n){let r=await sr(await ur(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function ma(e,t,n){try{let r=H.serialize(e,`step`,n);return lr(await or(U(V.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){da(e);let{message:t,hint:n}=X(`step value`,e);throw new m(t,{hint:n,cause:e})}}async function ha(e,t,n){let r=await sr(await ur(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=W(r);if(i===V.DEVALUE_V1)return H.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function ga(e,t){if(!(e instanceof Uint8Array)){if(H.deserializeLegacy)return H.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=W(e);if(n===V.DEVALUE_V1)return H.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const _a=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),va=globalThis[_a]??(globalThis[_a]=new oe);function ya(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${a(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${a(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${a(`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 o=i.join(` and `);return`${r.join(` and `)} to be enqueued\n Workflow will suspend and resume when ${o}`}function ba(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function xa(e){return`strm_${e}_system_abort`}function Sa(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return xa(e.slice(5))}const Ca=()=>b(`WORKFLOW_DEFERRED_CHECK_DELAY_MS`,100,{integer:!0,min:10});var Z;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Z||={});var wa=class{eventIndex;events=[];callbacks=[];onConsumedEvent;onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,this.onConsumedEvent=t.onConsumedEvent,this.onUnconsumedEvent=t.onUnconsumedEvent,this.getPromiseQueue=t.getPromiseQueue}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}notifyConsumedEvent(e){if(this.onConsumedEvent)try{this.onConsumedEvent(e)}catch(e){ua.error(`onConsumedEvent callback threw an error`,{error:e})}}consume=()=>{for(;;){let e=this.events[this.eventIndex]??null;if(!this.consumeOne(e)){this.handleUnconsumed(e);return}}};consumeOne(e){for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Z.NotConsumed;try{r=n(e)}catch(e){ua.error(`EventConsumer callback threw an error`,{error:e})}if(!(r!==Z.Consumed&&r!==Z.Finished))return e!==null&&this.notifyConsumedEvent(e),this.eventIndex++,r===Z.Finished&&this.callbacks.splice(t,1),e!==null}return!1}handleUnconsumed(e){if(e!==null){let t=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===t&&(this.pendingUnconsumedCheck=null,this.onUnconsumedEvent(e))},Ca())})}}},Ta=class{aborted=!1;reason=void 0;[I];[L];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[I]=e,this[L]=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 Ea(e){return class{signal;[I];[L];constructor(){let t=e.generateUlid(),n=xa(t),r=`abrt_${t}`;this[I]=n,this[L]=r,this.signal=new Ta(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[L])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new g(`Replay divergence: abort hook event ${t.eventType} for ${i} belongs to token "${n}", but the current abort hook expects "${this[L]}"`,{eventId:t.eventId}))}),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.pendingDeliveries++,e.promiseQueue=e.promiseQueue.then(async()=>{let t;try{if(n!==void 0)try{let r=await bo(n,e.runId,e.encryptionKey,e.globalThis);r&&typeof r==`object`&&`reason`in r&&(t=r.reason)}catch{}this.signal._setAborted(t)}finally{e.pendingDeliveries--}}),e.invocationsQueue.delete(i),Z.Consumed}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[L]){n.abortRequested=!0,n.abortReason=t;break}}}}}function Da(){return{abort(e){let t=new Ta(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new Ta(``,``),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 Oa=ne();function ka(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function Aa(e){return da(e),e instanceof m&&e.cause!==void 0||e instanceof _&&e.cause!==void 0?e.cause:e}async function Q(e,t){if(e.recorded)try{let n=await ea();if(!n)return;let r=e.uncompressedBytes??0,i=e.storedBytes??0;n.setAttributes({...ki(t),...Ai(e.compressed??!1),...ji(e.codec??`none`),...Mi(r),...Ni(i),...e.compressed&&r>0?Pi(1-i/r):{}})}catch{}}function ja(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 cr(t),!0);let o=k(i,e),s=n.encode(o),c=U(V.DEVALUE_V1,s);if(r.key){let e=await $t(r.key,c);c=U(V.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){if(p.is(e)){a.error(e);return}let{message:t,hint:n}=X(`stream chunk`,e);a.error(new m(t,{hint:n,cause:e}))}}})}function Ma(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 cr(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:c}=W(o);if(s===V.ENCRYPTED){if(!i.key){a.error(new p(`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:c.byteLength,formatPrefix:`encr`}}));return}let e;try{e=await en(i.key,c)}catch(e){throw p.is(e)&&e.context&&(e.context.formatPrefix=s),e}({format:s,payload:c}=W(e))}if(s===V.DEVALUE_V1){let t=n.decode(c);a.enqueue(qt(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(`
|
|
20
|
-
`);for(let t of s)t.length>0&&i.enqueue(qt(t,e))},async flush(e){r.length>0&&await o(e)}})}const Na=1e8;function Pa(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>Na){t.error(new _(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${Na}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function Fa(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>Na){r.error(new _(`Byte-stream frame length ${t} exceeds maximum (${Na}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new _(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function Ia(e,t,n,r){(async()=>{await Zi(`workflow.stream.read`,e,{kind:await ta(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}var La=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new _(`"name" is required, got "${t}"`);let r,i=!1;super({type:`bytes`,pull:async a=>{let o=this.#e;if(!o){r===void 0&&(r=Date.now());let i=await(await M()).streams.get(e,t,n);o=this.#e=i.getReader()}if(!o){a.error(Error(`Failed to get reader`));return}let s=await o.read();s.done?(this.#e=void 0,a.close()):(!i&&s.value.byteLength>0&&r!==void 0&&(i=!0,Ia(r,e,t,n)),a.enqueue(s.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const Ra=()=>b(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),za=()=>b(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,1e3,{integer:!0,min:1});function Ba(e,t,n){let r=n===void 0||n>=0,i=n??0,a=0,o=0,s=0,c,l=new Uint8Array;async function u(){let o=await M(),s=r?i+a:n;c=(await o.streams.get(e,t,s)).getReader()}async function d(){c&&=(await c.cancel().catch(()=>{}),void 0),i+=a,a=0,l=new Uint8Array;let e=Ra(),n=za();for(;;){if(o++,s++,o>e)throw Error(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(s>n)throw Error(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{await u();return}catch{}}}return new ReadableStream({pull:async e=>{for(;;){if(!c)try{await u()}catch(t){e.error(t);return}let t;try{t=await c.read()}catch(t){if(!r){e.error(t);return}try{await d()}catch(t){e.error(t);return}continue}if(t.done||!t.value){c=void 0,e.close();return}let n=t.value;if(n.length>0){let e=new Uint8Array(l.length+n.length);e.set(l,0),e.set(n,l.length),l=e}let i=!1;for(;l.length>=4;){let t=4+new DataView(l.buffer,l.byteOffset,l.byteLength).getUint32(0,!1);if(l.length<t)break;e.enqueue(l.slice(0,t)),l=l.slice(t),a++,i=!0}if(i){o=0;return}}},cancel:async()=>{c&&=(await c.cancel().catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)}),void 0)}})}const Va=()=>b(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,10,{integer:!0});var $=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new _(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new _(`"name" is required, got "${t}"`);let r=M(),i=n,a=async()=>{if(i){try{await i}catch{}i=void 0}},o=[],s=null,c=null,l,u=async()=>{if(s&&=(clearTimeout(s),null),o.length===0)return;await a();let n=o.slice(),i=await r;if(l===void 0&&(l=i.streamFlushIntervalMs??Va()),typeof i.streams.writeMulti==`function`&&n.length>1)await i.streams.writeMulti(e,t,n);else for(let r of n)await i.streams.write(e,t,r);o=[]},d=[],f=()=>{s||=setTimeout(()=>{s=null;let e=d;d=[],c=u().then(()=>{for(let t of e)t.resolve()},t=>{for(let n of e)n.reject(t)})},l??Va())};super({async write(e){c&&=(await c,null),o.push(e),f(),await new Promise((e,t)=>{d.push({resolve:e,reject:t})})},async close(){c&&=(await c,null),await u(),await a(),await(await r).streams.close(e,t)},abort(e){s&&=(clearTimeout(s),null),o=[];let t=d;d=[];let n=e??Error(`Stream aborted`);for(let e of t)e.reject(n)}})}};function Ha(e=globalThis){return{...An(),...zn(),...Ln(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[Sn];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[I])&&(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 Ua(e,t,n,r,i,a){let o=t[I],s=t[L];if(!o){let e=(n[vn]||Oa)();o=xa(e),s=`abrt_${e}`,t[I]=o,t[L]=s,t.signal&&(t.signal[I]=o,t.signal[L]=s)}return Ga(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function Wa(e,t){let n=t[I]??t.signal?.[I],r=t[L]??t.signal?.[L];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 Ga(e,t,n,r,i){e.aborted||e[wn]||(e[wn]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await cr(r),a=await po({aborted:!0,reason:e.reason},n,i),o=new $(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function Ka(e=globalThis,t,n,r,i=!1,a){return{...Ha(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new m(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=`strm_${(e[vn]||Oa)()}`,c=ka(o),l=new $(n,s,a);c===`bytes`?i?t.push(o.pipeThrough(Pa()).pipeTo(l)):t.push(o.pipeTo(l)):t.push(o.pipeThrough(ja(Ka(e,t,n,r,i,a),r)).pipeTo(l));let u={name:s};return c&&(u.type=c),c===`bytes`&&i&&(u.framing=`framed-v1`),u},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[N],a=r[P];if(typeof i==`string`&&typeof a==`string`){let e={name:i,runId:a},t=r[F];return typeof t==`string`&&(e.deploymentId=t),e}let o=`strm_${(e[vn]||Oa)()}`,s=new La(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ua(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ua(i,i,e,t,n,r)}}function qa(e=globalThis){return{...Ha(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[xn];if(n!==void 0)return{bodyInit:n};let r=t[N];if(!r)throw new _("ReadableStream `name` is not set");let i={name:r},a=t[yn];a&&(i.type=a);let o=t[bn];return o&&(i.framing=o),i},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[N];if(!n)throw new _("WritableStream `name` is not set");let r={name:n},i=t[P];typeof i==`string`&&(r.runId=i);let a=t[F];return typeof a==`string`&&(r.deploymentId=a),r},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[I]??n.signal?.[I],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:Wa(t.signal,n)},AbortSignal:t=>{let n=t?.[I],r=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!n&&!r?!1:Wa(t,t)}}}function Ja(e=globalThis,t,n,r,i=!1,a){return{...Ha(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new m(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=o[N],c=o[yn],l=o[bn];if(!s){s=`strm_${(e[vn]||Oa)()}`,c=ka(o),l=c===`bytes`&&i?`framed-v1`:l;let u=new $(n,s,a);c===`bytes`?l===`framed-v1`?t.push(o.pipeThrough(Pa()).pipeTo(u)):t.push(o.pipeTo(u)):t.push(o.pipeThrough(ja(Ja(e,t,n,r,i,a),r)).pipeTo(u))}let u={name:s};return c&&(u.type=c),l&&(u.framing=l),u},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[N],o=i[P];a||(a=`strm_${(e[vn]||Oa)()}`,t.push(new La(n,a).pipeThrough(Ma(ao(e,t,n,r),r)).pipeTo(i)));let s={name:a};typeof o==`string`&&(s.runId=o);let c=i[F];return typeof c==`string`&&(s.deploymentId=c),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ua(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ua(i,i,e,t,n,r)}}function Ya(...e){let t=new WeakSet;function n(e){let t=e[Tn];t&&!t.signal.aborted&&t.abort()}function r(e){if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function Xa(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new La(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=va.getStore(),r=await mo(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function Za(e,t,n){let r=e,i=e.signal;r[I]=t.streamName,r[L]=t.hookToken,i[I]=t.streamName,i[L]=t.hookToken,n&&(r[Tn]=n,i[Tn]=n)}function Qa(e,t){let n=e,r=t;n[I]!==void 0&&(r[I]=n[I]),n[L]!==void 0&&(r[L]=n[L]),n[Tn]!==void 0&&(r[Tn]=n[Tn])}function $a(e,t,n){let r=new AbortController;e.aborted?(Za(r,e),r.abort(e.reason)):e.streamName?Za(r,e,Xa(r,n,e.streamName,t)):Za(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=va.getStore();if(n&&(n.ops.push((async()=>{try{let r=await po({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)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-BkVkWg2r.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function eo(e,t,n){let r=new AbortController;return e.aborted?(Za(r,e),r.abort(e.reason)):e.streamName?Za(r,e,Xa(r,n,e.streamName,t)):Za(r,e),r.signal}function to(e=globalThis){return{...jn(e),...Rn(e)}}async function no(e,t){let n=await M();if(!n.getEncryptionKeyForRun)return;let r=t?await n.getEncryptionKeyForRun(e,{deploymentId:t}):await n.getEncryptionKeyForRun(await n.runs.get(e));return r?await Qt(r,[`encrypt`]):void 0}function ro(e=globalThis,t,n,r){return{...to(e),StepFunction:()=>{throw new m(`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 m(`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&&Qa(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}if(i.type===`bytes`){let r=new La(n,i.name,i.startIndex),a=A();t.push(a.promise);let{readable:o,writable:s}=i.framing===`framed-v1`?Fa():new e.TransformStream;return j(r,s,a).catch(()=>{}),on(o,a),o}else{let a=Ba(n,i.name,i.startIndex),o=Ma(ro(e,t,n,r),r),s=A();return t.push(s.promise),j(a,o.writable,s).catch(()=>{}),on(o.readable,s),o.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:no(a,i.deploymentId),s=ja(Ka(e,t,a,o),o),c=new $(a,i.name),l=A();return t.push(l.promise),j(s.readable,c,l).catch(()=>{}),an(s.writable,l),Object.defineProperty(s.writable,N,{value:i.name,writable:!1}),Object.defineProperty(s.writable,P,{value:a,writable:!1}),typeof i.deploymentId==`string`&&Object.defineProperty(s.writable,F,{value:i.deploymentId,writable:!1}),s.writable},AbortController:e=>$a(e,t,n),AbortSignal:e=>eo(e,t,n)}}function io(e=globalThis){return{...to(e),...Bn(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[Sn]=n,delete t.responseWritable,t.respondWith=()=>{throw new m("`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 m(`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,{[xn]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[N]:{value:t.name,writable:!1},[yn]:{value:t.type,writable:!1},[bn]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[N]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[P]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[F]={value:t.deploymentId,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new Ta(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[I]:e.streamName,[L]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new Ta(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function ao(e=globalThis,t,n,r,i){return{...to(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=ie(t);if(!o)throw new m(`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=va.getStore();if(!e)throw new _(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return va.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 m(`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&&Qa(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:a=>{if(`bodyInit`in a){let t=a.bodyInit;return new e.Response(t).body}let o=new La(n,a.name);if(a.type===`bytes`){let n=A();t.push(n.promise);let{readable:r,writable:i}=a.framing===`framed-v1`?Fa():new e.TransformStream;return j(o,i,n).catch(()=>{}),on(r,n),r}else{let a=Ma(ao(e,t,n,r,i),r),s=A();return t.push(s.promise),j(o,a.writable,s).catch(()=>{}),on(a.readable,s),a.readable}},WritableStream:a=>{let o=typeof a.runId==`string`?a.runId:n,s=typeof a.deploymentId==`string`?a.deploymentId:o===n?i:void 0,c=o===n?r:no(o,s),l=ja(Ja(e,t,o,c),c),u=new $(o,a.name),d=A();return t.push(d.promise),j(l.readable,u,d).catch(()=>{}),an(l.writable,d),Object.defineProperty(l.writable,N,{value:a.name,writable:!1}),Object.defineProperty(l.writable,P,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,F,{value:s,writable:!1}),l.writable},AbortController:e=>$a(e,t,n),AbortSignal:e=>eo(e,t,n)}}async function oo(e,t){return await lr(e,t)}async function so(e,t){return ur(e,t)}async function co(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1){if(a)return Nn(k(e,Ka(i,r,t,n,o)));try{let a={},c=await fa(e,n,{global:i,extraReducers:So(Ka(i,r,t,n,o)),compression:s,compressionStats:a});return await Q(a,`serialize`),c}catch(e){let t=Aa(e),{message:n,hint:r}=X(`workflow arguments`,t);throw new m(n,{hint:r,cause:t})}}async function lo(e,t,n,r=globalThis,i={}){let a={},o=await sr(await so(e,n),a);return await Q(a,`deserialize`),ga(o,{global:r,extraRevivers:{...Co(io(r)),...i}})}async function uo(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Nn(k(e,qa(r)));try{let t={},i=await ma(e,n,{global:r,extraReducers:So(qa(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=Aa(e),{message:n,hint:r}=X(`workflow return value`,t);throw new m(n,{hint:r,cause:t})}}async function fo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await pa(e,n,{global:i,extraRevivers:{...Co(ro(i,r,t,n)),...a},compressionStats:o});return await Q(o,`deserialize`),s}async function po(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Nn(k(e,qa(r)));try{let t={},i=await ma(e,n,{global:r,extraReducers:So(qa(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=Aa(e),{message:n,hint:r}=X(`step arguments`,t);throw new m(n,{hint:r,cause:t})}}async function mo(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await ha(e,n,{global:i,extraRevivers:{...Co(ao(i,r,t,n,o)),...a},compressionStats:s});return await Q(s,`deserialize`),c}async function ho(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c){if(a)return Nn(k(e,Ja(i,r,t,n,o,c)));try{let a={},l=await ma(e,n,{global:i,extraReducers:So(Ja(i,r,t,n,o,c)),compression:s,compressionStats:a});return await Q(a,`serialize`),l}catch(e){let t=Aa(e),{message:n,hint:r}=X(`step return value`,t);throw new m(n,{hint:r,cause:t})}}async function go(e,t,n,r=[],i=globalThis,a=!1){try{let o=k(e,Ja(i,r,t,n)),s=new TextEncoder().encode(o),c=U(V.DEVALUE_V1,s),l={},u=await oo(await or(c,a,l),n);return await Q(l,`serialize`),u}catch(e){let t=Aa(e),{message:n,hint:r}=X(`step error`,t);throw new m(n,{hint:r,cause:t})}}async function _o(e,t,n,r=globalThis,i={}){let a={},o=await sr(await so(e,n),a);if(await Q(a,`deserialize`),!(o instanceof Uint8Array))return Jt(o,{...io(r),...i});let{format:s,payload:c}=W(o);if(s===V.DEVALUE_V1)return qt(new TextDecoder().decode(c),{...io(r),...i});throw Error(`Unsupported serialization format: ${s}`)}async function vo(e,t,n,r=globalThis,i=!1){try{let t=k(e,qa(r)),a=new TextEncoder().encode(t),o=U(V.DEVALUE_V1,a),s={},c=await oo(await or(o,i,s),n);return await Q(s,`serialize`),c}catch(e){let t=Aa(e),{message:n,hint:r}=X(`run error`,t);throw new m(n,{hint:r,cause:t})}}async function yo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await sr(await so(e,n),o);if(await Q(o,`deserialize`),!(s instanceof Uint8Array))return Jt(s,{...ro(i,r,t,n),...a});let{format:c,payload:l}=W(s);if(c===V.DEVALUE_V1)return qt(new TextDecoder().decode(l),{...ro(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${c}`)}async function bo(e,t,n,r=globalThis,i={}){let a={},o=await sr(await so(e,n),a);return await Q(a,`deserialize`),ga(o,{global:r,extraRevivers:{...Co(io(r)),...i}})}const xo=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function So(e){let t={};for(let n of xo)n in e&&(t[n]=e[n]);return t}function Co(e){let t={};for(let n of xo)n in e&&(t[n]=e[n]);return t}const wo=[{format:V.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:V.GZIP,minVersion:`5.0.0-beta.18`},{format:V.ZSTD,minVersion:`5.0.0-beta.18`}],To=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],Eo=new Set([V.DEVALUE_V1]);function Do(e){if(!e||!Zt.default.valid(e))return{supportedFormats:Eo,framedByteStreams:!1};let t=new Set(Eo);for(let{format:n,minVersion:r}of wo)Zt.default.gte(e,r)&&t.add(n);let n={supportedFormats:t,framedByteStreams:!1};for(let{capability:t,minVersion:r}of To)Zt.default.gte(e,r)&&(n[t]=!0);return n}const Oo=`5.0.0-beta.30`,ko=/^[a-zA-Z0-9_\-./@]+$/;function Ao(e,t){if(!ko.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${te(`workflow`,re(t))}${e}`}const jo=ne();function Mo(e){return`__health_check__${e}`}function No(e){let t=ee.safeParse(e);if(t.success)return t.data}function Po(e){return`wrun_hc_${e}`}async function Fo(e,t,n){let r=await M(),i=Mo(e.correlationId),a=JSON.stringify({healthy:!0,endpoint:t,correlationId:e.correlationId,specVersion:n??5,workflowCoreVersion:Oo,timestamp:Date.now()}),o=Po(e.correlationId);await r.streams.write(o,i,a),await r.streams.close(o,i)}function Io(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function Lo(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 Ro(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),s}async function zo(e,t,n){let r=n?.timeout??3e4,i=jo(),a=Mo(i),o=`${te(t,re(n?.namespace))}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=r-(Date.now()-s),n=(await Io(e.streams.get(Po(i),a),t)).getReader(),{chunks:o,timedOut:c}=await Lo(n,500);if(c){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=Ro(o);if(l)return{...l,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)}}}function Bo(e,t){return new u(`Event pagination ${t} for workflow run "${e}".`,{code:l.WORLD_CONTRACT_ERROR})}function Vo(e,t,n){if(t){if(n.has(t))throw Bo(e,`did not advance`);n.add(t)}}function Ho(e,t,n){for(let r of n)t.has(r.eventId)||(t.add(r.eventId),e.push(r))}function Uo(e,t,n,r){if(t){if(n===null)throw Bo(e,`returned more pages without a cursor`);if(r.has(n))throw Bo(e,`repeated a cursor`)}}function Wo(e,t,n){return t!==null&&!n&&u.is(e)&&e.status===400}async function Go(e,t){let n=t!==void 0;return Xi(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...Sr(e)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await M(),f=Date.now();for(;c;){let t=Date.now(),r=s;Vo(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(Wo(t,r,u)){Y.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,u=!0;continue}throw t}Ho(i,a,f.data),c=f.hasMore,Uo(e,c,f.cursor,o),s=f.cursor??s,l++,Y.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return Y.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...Tr(i.length),...Ti(l)}),{events:i,cursor:s}})}const Ko={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function qo(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:Ko}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??5,workflowCoreVersion:Oo}),{status:200,headers:{"Content-Type":`application/json`,...Ko}}):await e(n)}}async function Jo(e,...t){let n=t[0];await Xi(`queue.publish`,{attributes:{...ci(`vercel-queue`),...li(n),...di(`publish`),...Fi(`vercel-queue`),...Ii(`vercel-queue`),...Li(`vqs`),...Ri(`publish`)},kind:await ta(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(ui(r))})}function Yo(e){if(e.requestedAt)try{return fi(Date.now()-e.requestedAt.getTime())}catch{return}}function Xo(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await Qt(n):void 0})(),n)}function Zo(t){import(`./functions-BCMO8vbf.js`).then(t=>e(t.default,1)).then(({waitUntil:e})=>{e(t)})}function Qo(e,t){Zo(e.catch(e=>{if(!(e?.name===`AbortError`||e?.name===`ResponseAborted`))try{t(e)}catch{}}))}async function $o(e){let t=e();return Zo(t.catch(()=>{})),t}function es(e,t={}){if(typeof e!=`object`||!e||Array.isArray(e))throw new h(`experimental_setAttributes requires a plain object, got ${e===null?`null`:Array.isArray(e)?`array`:typeof e}`);let n=Object.entries(e).map(([e,t])=>({key:e,value:t===void 0?null:t}));if(n.length===0)return n;let r=t.allowReservedAttributes===!0;try{v(n,{allowReservedAttributes:r})}catch(e){throw e instanceof y?new h(e.message):e}return n}export{pi as $,Pr as $t,lo as A,Me as An,Qr as At,Y as B,Fr as Bt,Ka as C,M as Cn,Jr as Ct,mo as D,an as Dn,oi as Dt,yo as E,j as En,ai as Et,wa as F,ke as Fn,Rr as Ft,ta as G,Hr as Gt,la as H,xr as Ht,ya as I,Ee as In,Nr as It,ia as J,Ur as Jt,Hi as K,Br as Kt,Sa as L,Te as Ln,Mr as Lt,Da as M,Ne as Mn,Xr as Mt,Ea as N,Pe as Nn,Yr as Nt,_o as O,Qt as On,si as Ot,Z as P,Oe as Pn,Er as Pt,aa as Q,wr as Qt,ba as R,De as Rn,jr as Rt,uo as S,dn as Sn,Zr as St,ja as T,A as Tn,ti as Tt,Gi as U,Lr as Ut,ca as V,br as Vt,Wi as W,Dr as Wt,Xi as X,Sr as Xt,Ki as Y,zr as Yt,Ji as Z,Cr as Zt,vo as _,_n,Kr as _t,Ao as a,vr as an,mi as at,ho as b,pn as bn,ii as bt,Go as c,On as cn,Si as ct,Jo as d,vn as dn,di as dt,kr as en,Bi as et,qo as f,N as fn,ci as ft,Ya as g,hn as gn,ei as gt,$ as h,Sn as hn,Oi as ht,Yo as i,yr as in,hi as it,fo as j,je as jn,qr as jt,bo as k,Ae as kn,$r as kt,Xo as l,kn as ln,li as lt,Do as m,P as mn,Di as mt,Qo as n,Ar as nn,wi as nt,Fo as o,V as on,xi as ot,Oo as p,F as pn,Ei as pt,Ui as q,Vr as qt,$o as r,Ir as rn,gi as rt,zo as s,Dn as sn,Ci as st,es as t,Or as tn,zi as tt,No as u,xn as un,ui as ut,po as v,mn as vn,ri as vt,ro as w,sn as wn,Wr as wt,co as x,fn as xn,Gr as xt,go as y,gn as yn,ni as yt,va as z,Tr as zt};
|
|
20
|
+
`);for(let t of s)t.length>0&&i.enqueue(qt(t,e))},async flush(e){r.length>0&&await o(e)}})}const Na=1e8;function Pa(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>Na){t.error(new _(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${Na}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function Fa(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>Na){r.error(new _(`Byte-stream frame length ${t} exceeds maximum (${Na}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new _(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function Ia(e,t,n,r){(async()=>{await Zi(`workflow.stream.read`,e,{kind:await ta(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}var La=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new _(`"name" is required, got "${t}"`);let r,i=!1;super({type:`bytes`,pull:async a=>{let o=this.#e;if(!o){r===void 0&&(r=Date.now());let i=await(await M()).streams.get(e,t,n);o=this.#e=i.getReader()}if(!o){a.error(Error(`Failed to get reader`));return}let s=await o.read();s.done?(this.#e=void 0,a.close()):(!i&&s.value.byteLength>0&&r!==void 0&&(i=!0,Ia(r,e,t,n)),a.enqueue(s.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const Ra=()=>b(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),za=()=>b(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,1e3,{integer:!0,min:1});function Ba(e,t,n){let r=n===void 0||n>=0,i=n??0,a=0,o=0,s=0,c,l=new Uint8Array;async function u(){let o=await M(),s=r?i+a:n;c=(await o.streams.get(e,t,s)).getReader()}async function d(){c&&=(await c.cancel().catch(()=>{}),void 0),i+=a,a=0,l=new Uint8Array;let e=Ra(),n=za();for(;;){if(o++,s++,o>e)throw Error(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(s>n)throw Error(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{await u();return}catch{}}}return new ReadableStream({pull:async e=>{for(;;){if(!c)try{await u()}catch(t){e.error(t);return}let t;try{t=await c.read()}catch(t){if(!r){e.error(t);return}try{await d()}catch(t){e.error(t);return}continue}if(t.done||!t.value){c=void 0,e.close();return}let n=t.value;if(n.length>0){let e=new Uint8Array(l.length+n.length);e.set(l,0),e.set(n,l.length),l=e}let i=!1;for(;l.length>=4;){let t=4+new DataView(l.buffer,l.byteOffset,l.byteLength).getUint32(0,!1);if(l.length<t)break;e.enqueue(l.slice(0,t)),l=l.slice(t),a++,i=!0}if(i){o=0;return}}},cancel:async()=>{c&&=(await c.cancel().catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)}),void 0)}})}const Va=()=>b(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,10,{integer:!0});var $=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new _(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new _(`"name" is required, got "${t}"`);let r=M(),i=n,a=async()=>{if(i){try{await i}catch{}i=void 0}},o=[],s=null,c=null,l,u=async()=>{if(s&&=(clearTimeout(s),null),o.length===0)return;await a();let n=o.slice(),i=await r;if(l===void 0&&(l=i.streamFlushIntervalMs??Va()),typeof i.streams.writeMulti==`function`&&n.length>1)await i.streams.writeMulti(e,t,n);else for(let r of n)await i.streams.write(e,t,r);o=[]},d=[],f=()=>{s||=setTimeout(()=>{s=null;let e=d;d=[],c=u().then(()=>{for(let t of e)t.resolve()},t=>{for(let n of e)n.reject(t)})},l??Va())};super({async write(e){c&&=(await c,null),o.push(e),f(),await new Promise((e,t)=>{d.push({resolve:e,reject:t})})},async close(){c&&=(await c,null),await u(),await a(),await(await r).streams.close(e,t)},abort(e){s&&=(clearTimeout(s),null),o=[];let t=d;d=[];let n=e??Error(`Stream aborted`);for(let e of t)e.reject(n)}})}};function Ha(e=globalThis){return{...An(),...zn(),...Ln(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[Sn];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[I])&&(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 Ua(e,t,n,r,i,a){let o=t[I],s=t[L];if(!o){let e=(n[vn]||Oa)();o=xa(e),s=`abrt_${e}`,t[I]=o,t[L]=s,t.signal&&(t.signal[I]=o,t.signal[L]=s)}return Ga(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function Wa(e,t){let n=t[I]??t.signal?.[I],r=t[L]??t.signal?.[L];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 Ga(e,t,n,r,i){e.aborted||e[wn]||(e[wn]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await cr(r),a=await po({aborted:!0,reason:e.reason},n,i),o=new $(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function Ka(e=globalThis,t,n,r,i=!1,a){return{...Ha(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new m(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=`strm_${(e[vn]||Oa)()}`,c=ka(o),l=new $(n,s,a);c===`bytes`?i?t.push(o.pipeThrough(Pa()).pipeTo(l)):t.push(o.pipeTo(l)):t.push(o.pipeThrough(ja(Ka(e,t,n,r,i,a),r)).pipeTo(l));let u={name:s};return c&&(u.type=c),c===`bytes`&&i&&(u.framing=`framed-v1`),u},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[N],a=r[P];if(typeof i==`string`&&typeof a==`string`){let e={name:i,runId:a},t=r[F];return typeof t==`string`&&(e.deploymentId=t),e}let o=`strm_${(e[vn]||Oa)()}`,s=new La(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ua(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ua(i,i,e,t,n,r)}}function qa(e=globalThis){return{...Ha(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[xn];if(n!==void 0)return{bodyInit:n};let r=t[N];if(!r)throw new _("ReadableStream `name` is not set");let i={name:r},a=t[yn];a&&(i.type=a);let o=t[bn];return o&&(i.framing=o),i},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[N];if(!n)throw new _("WritableStream `name` is not set");let r={name:n},i=t[P];typeof i==`string`&&(r.runId=i);let a=t[F];return typeof a==`string`&&(r.deploymentId=a),r},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[I]??n.signal?.[I],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:Wa(t.signal,n)},AbortSignal:t=>{let n=t?.[I],r=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!n&&!r?!1:Wa(t,t)}}}function Ja(e=globalThis,t,n,r,i=!1,a){return{...Ha(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new m(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=o[N],c=o[yn],l=o[bn];if(!s){s=`strm_${(e[vn]||Oa)()}`,c=ka(o),l=c===`bytes`&&i?`framed-v1`:l;let u=new $(n,s,a);c===`bytes`?l===`framed-v1`?t.push(o.pipeThrough(Pa()).pipeTo(u)):t.push(o.pipeTo(u)):t.push(o.pipeThrough(ja(Ja(e,t,n,r,i,a),r)).pipeTo(u))}let u={name:s};return c&&(u.type=c),l&&(u.framing=l),u},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[N],o=i[P];a||(a=`strm_${(e[vn]||Oa)()}`,t.push(new La(n,a).pipeThrough(Ma(ao(e,t,n,r),r)).pipeTo(i)));let s={name:a};typeof o==`string`&&(s.runId=o);let c=i[F];return typeof c==`string`&&(s.deploymentId=c),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Ua(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Ua(i,i,e,t,n,r)}}function Ya(...e){let t=new WeakSet;function n(e){let t=e[Tn];t&&!t.signal.aborted&&t.abort()}function r(e){if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function Xa(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new La(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=va.getStore(),r=await mo(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function Za(e,t,n){let r=e,i=e.signal;r[I]=t.streamName,r[L]=t.hookToken,i[I]=t.streamName,i[L]=t.hookToken,n&&(r[Tn]=n,i[Tn]=n)}function Qa(e,t){let n=e,r=t;n[I]!==void 0&&(r[I]=n[I]),n[L]!==void 0&&(r[L]=n[L]),n[Tn]!==void 0&&(r[Tn]=n[Tn])}function $a(e,t,n){let r=new AbortController;e.aborted?(Za(r,e),r.abort(e.reason)):e.streamName?Za(r,e,Xa(r,n,e.streamName,t)):Za(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=va.getStore();if(n&&(n.ops.push((async()=>{try{let r=await po({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)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-BH01MfRF.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function eo(e,t,n){let r=new AbortController;return e.aborted?(Za(r,e),r.abort(e.reason)):e.streamName?Za(r,e,Xa(r,n,e.streamName,t)):Za(r,e),r.signal}function to(e=globalThis){return{...jn(e),...Rn(e)}}async function no(e,t){let n=await M();if(!n.getEncryptionKeyForRun)return;let r=t?await n.getEncryptionKeyForRun(e,{deploymentId:t}):await n.getEncryptionKeyForRun(await n.runs.get(e));return r?await Qt(r,[`encrypt`]):void 0}function ro(e=globalThis,t,n,r){return{...to(e),StepFunction:()=>{throw new m(`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 m(`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&&Qa(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}if(i.type===`bytes`){let r=new La(n,i.name,i.startIndex),a=A();t.push(a.promise);let{readable:o,writable:s}=i.framing===`framed-v1`?Fa():new e.TransformStream;return j(r,s,a).catch(()=>{}),on(o,a),o}else{let a=Ba(n,i.name,i.startIndex),o=Ma(ro(e,t,n,r),r),s=A();return t.push(s.promise),j(a,o.writable,s).catch(()=>{}),on(o.readable,s),o.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:no(a,i.deploymentId),s=ja(Ka(e,t,a,o),o),c=new $(a,i.name),l=A();return t.push(l.promise),j(s.readable,c,l).catch(()=>{}),an(s.writable,l),Object.defineProperty(s.writable,N,{value:i.name,writable:!1}),Object.defineProperty(s.writable,P,{value:a,writable:!1}),typeof i.deploymentId==`string`&&Object.defineProperty(s.writable,F,{value:i.deploymentId,writable:!1}),s.writable},AbortController:e=>$a(e,t,n),AbortSignal:e=>eo(e,t,n)}}function io(e=globalThis){return{...to(e),...Bn(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[Sn]=n,delete t.responseWritable,t.respondWith=()=>{throw new m("`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 m(`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,{[xn]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[N]:{value:t.name,writable:!1},[yn]:{value:t.type,writable:!1},[bn]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[N]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[P]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[F]={value:t.deploymentId,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new Ta(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[I]:e.streamName,[L]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new Ta(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function ao(e=globalThis,t,n,r,i){return{...to(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=ie(t);if(!o)throw new m(`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=va.getStore();if(!e)throw new _(`Cannot call step function with closure variables outside step context`);let r={...e,closureVars:n};return va.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 m(`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&&Qa(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:a=>{if(`bodyInit`in a){let t=a.bodyInit;return new e.Response(t).body}let o=new La(n,a.name);if(a.type===`bytes`){let n=A();t.push(n.promise);let{readable:r,writable:i}=a.framing===`framed-v1`?Fa():new e.TransformStream;return j(o,i,n).catch(()=>{}),on(r,n),r}else{let a=Ma(ao(e,t,n,r,i),r),s=A();return t.push(s.promise),j(o,a.writable,s).catch(()=>{}),on(a.readable,s),a.readable}},WritableStream:a=>{let o=typeof a.runId==`string`?a.runId:n,s=typeof a.deploymentId==`string`?a.deploymentId:o===n?i:void 0,c=o===n?r:no(o,s),l=ja(Ja(e,t,o,c),c),u=new $(o,a.name),d=A();return t.push(d.promise),j(l.readable,u,d).catch(()=>{}),an(l.writable,d),Object.defineProperty(l.writable,N,{value:a.name,writable:!1}),Object.defineProperty(l.writable,P,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,F,{value:s,writable:!1}),l.writable},AbortController:e=>$a(e,t,n),AbortSignal:e=>eo(e,t,n)}}async function oo(e,t){return await lr(e,t)}async function so(e,t){return ur(e,t)}async function co(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1){if(a)return Nn(k(e,Ka(i,r,t,n,o)));try{let a={},c=await fa(e,n,{global:i,extraReducers:So(Ka(i,r,t,n,o)),compression:s,compressionStats:a});return await Q(a,`serialize`),c}catch(e){let t=Aa(e),{message:n,hint:r}=X(`workflow arguments`,t);throw new m(n,{hint:r,cause:t})}}async function lo(e,t,n,r=globalThis,i={}){let a={},o=await sr(await so(e,n),a);return await Q(a,`deserialize`),ga(o,{global:r,extraRevivers:{...Co(io(r)),...i}})}async function uo(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Nn(k(e,qa(r)));try{let t={},i=await ma(e,n,{global:r,extraReducers:So(qa(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=Aa(e),{message:n,hint:r}=X(`workflow return value`,t);throw new m(n,{hint:r,cause:t})}}async function fo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await pa(e,n,{global:i,extraRevivers:{...Co(ro(i,r,t,n)),...a},compressionStats:o});return await Q(o,`deserialize`),s}async function po(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Nn(k(e,qa(r)));try{let t={},i=await ma(e,n,{global:r,extraReducers:So(qa(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=Aa(e),{message:n,hint:r}=X(`step arguments`,t);throw new m(n,{hint:r,cause:t})}}async function mo(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await ha(e,n,{global:i,extraRevivers:{...Co(ao(i,r,t,n,o)),...a},compressionStats:s});return await Q(s,`deserialize`),c}async function ho(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c){if(a)return Nn(k(e,Ja(i,r,t,n,o,c)));try{let a={},l=await ma(e,n,{global:i,extraReducers:So(Ja(i,r,t,n,o,c)),compression:s,compressionStats:a});return await Q(a,`serialize`),l}catch(e){let t=Aa(e),{message:n,hint:r}=X(`step return value`,t);throw new m(n,{hint:r,cause:t})}}async function go(e,t,n,r=[],i=globalThis,a=!1){try{let o=k(e,Ja(i,r,t,n)),s=new TextEncoder().encode(o),c=U(V.DEVALUE_V1,s),l={},u=await oo(await or(c,a,l),n);return await Q(l,`serialize`),u}catch(e){let t=Aa(e),{message:n,hint:r}=X(`step error`,t);throw new m(n,{hint:r,cause:t})}}async function _o(e,t,n,r=globalThis,i={}){let a={},o=await sr(await so(e,n),a);if(await Q(a,`deserialize`),!(o instanceof Uint8Array))return Jt(o,{...io(r),...i});let{format:s,payload:c}=W(o);if(s===V.DEVALUE_V1)return qt(new TextDecoder().decode(c),{...io(r),...i});throw Error(`Unsupported serialization format: ${s}`)}async function vo(e,t,n,r=globalThis,i=!1){try{let t=k(e,qa(r)),a=new TextEncoder().encode(t),o=U(V.DEVALUE_V1,a),s={},c=await oo(await or(o,i,s),n);return await Q(s,`serialize`),c}catch(e){let t=Aa(e),{message:n,hint:r}=X(`run error`,t);throw new m(n,{hint:r,cause:t})}}async function yo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await sr(await so(e,n),o);if(await Q(o,`deserialize`),!(s instanceof Uint8Array))return Jt(s,{...ro(i,r,t,n),...a});let{format:c,payload:l}=W(s);if(c===V.DEVALUE_V1)return qt(new TextDecoder().decode(l),{...ro(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${c}`)}async function bo(e,t,n,r=globalThis,i={}){let a={},o=await sr(await so(e,n),a);return await Q(a,`deserialize`),ga(o,{global:r,extraRevivers:{...Co(io(r)),...i}})}const xo=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function So(e){let t={};for(let n of xo)n in e&&(t[n]=e[n]);return t}function Co(e){let t={};for(let n of xo)n in e&&(t[n]=e[n]);return t}const wo=[{format:V.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:V.GZIP,minVersion:`5.0.0-beta.18`},{format:V.ZSTD,minVersion:`5.0.0-beta.18`}],To=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],Eo=new Set([V.DEVALUE_V1]);function Do(e){if(!e||!Zt.default.valid(e))return{supportedFormats:Eo,framedByteStreams:!1};let t=new Set(Eo);for(let{format:n,minVersion:r}of wo)Zt.default.gte(e,r)&&t.add(n);let n={supportedFormats:t,framedByteStreams:!1};for(let{capability:t,minVersion:r}of To)Zt.default.gte(e,r)&&(n[t]=!0);return n}const Oo=`5.0.0-beta.31`,ko=/^[a-zA-Z0-9_\-./@]+$/;function Ao(e,t){if(!ko.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${te(`workflow`,re(t))}${e}`}const jo=ne();function Mo(e){return`__health_check__${e}`}function No(e){let t=ee.safeParse(e);if(t.success)return t.data}function Po(e){return`wrun_hc_${e}`}async function Fo(e,t,n){let r=await M(),i=Mo(e.correlationId),a=JSON.stringify({healthy:!0,endpoint:t,correlationId:e.correlationId,specVersion:n??5,workflowCoreVersion:Oo,timestamp:Date.now()}),o=Po(e.correlationId);await r.streams.write(o,i,a),await r.streams.close(o,i)}function Io(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function Lo(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 Ro(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),s}async function zo(e,t,n){let r=n?.timeout??3e4,i=jo(),a=Mo(i),o=`${te(t,re(n?.namespace))}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=r-(Date.now()-s),n=(await Io(e.streams.get(Po(i),a),t)).getReader(),{chunks:o,timedOut:c}=await Lo(n,500);if(c){try{n.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=Ro(o);if(l)return{...l,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)}}}function Bo(e,t){return new u(`Event pagination ${t} for workflow run "${e}".`,{code:l.WORLD_CONTRACT_ERROR})}function Vo(e,t,n){if(t){if(n.has(t))throw Bo(e,`did not advance`);n.add(t)}}function Ho(e,t,n){for(let r of n)t.has(r.eventId)||(t.add(r.eventId),e.push(r))}function Uo(e,t,n,r){if(t){if(n===null)throw Bo(e,`returned more pages without a cursor`);if(r.has(n))throw Bo(e,`repeated a cursor`)}}function Wo(e,t,n){return t!==null&&!n&&u.is(e)&&e.status===400}async function Go(e,t){let n=t!==void 0;return Xi(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...Sr(e)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await M(),f=Date.now();for(;c;){let t=Date.now(),r=s;Vo(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(Wo(t,r,u)){Y.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,u=!0;continue}throw t}Ho(i,a,f.data),c=f.hasMore,Uo(e,c,f.cursor,o),s=f.cursor??s,l++,Y.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return Y.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...Tr(i.length),...Ti(l)}),{events:i,cursor:s}})}const Ko={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function qo(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:Ko}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??5,workflowCoreVersion:Oo}),{status:200,headers:{"Content-Type":`application/json`,...Ko}}):await e(n)}}async function Jo(e,...t){let n=t[0];await Xi(`queue.publish`,{attributes:{...ci(`vercel-queue`),...li(n),...di(`publish`),...Fi(`vercel-queue`),...Ii(`vercel-queue`),...Li(`vqs`),...Ri(`publish`)},kind:await ta(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(ui(r))})}function Yo(e){if(e.requestedAt)try{return fi(Date.now()-e.requestedAt.getTime())}catch{return}}function Xo(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await Qt(n):void 0})(),n)}function Zo(t){import(`./functions-BCMO8vbf.js`).then(t=>e(t.default,1)).then(({waitUntil:e})=>{e(t)})}function Qo(e,t){Zo(e.catch(e=>{if(!(e?.name===`AbortError`||e?.name===`ResponseAborted`))try{t(e)}catch{}}))}async function $o(e){let t=e();return Zo(t.catch(()=>{})),t}function es(e,t={}){if(typeof e!=`object`||!e||Array.isArray(e))throw new h(`setAttributes requires a plain object, got ${e===null?`null`:Array.isArray(e)?`array`:typeof e}`);let n=Object.entries(e).map(([e,t])=>({key:e,value:t===void 0?null:t}));if(n.length===0)return n;let r=t.allowReservedAttributes===!0;try{v(n,{allowReservedAttributes:r})}catch(e){throw e instanceof y?new h(e.message):e}return n}export{pi as $,Pr as $t,lo as A,Me as An,Qr as At,Y as B,Fr as Bt,Ka as C,M as Cn,Jr as Ct,mo as D,an as Dn,oi as Dt,yo as E,j as En,ai as Et,wa as F,ke as Fn,Rr as Ft,ta as G,Hr as Gt,la as H,xr as Ht,ya as I,Ee as In,Nr as It,ia as J,Ur as Jt,Hi as K,Br as Kt,Sa as L,Te as Ln,Mr as Lt,Da as M,Ne as Mn,Xr as Mt,Ea as N,Pe as Nn,Yr as Nt,_o as O,Qt as On,si as Ot,Z as P,Oe as Pn,Er as Pt,aa as Q,wr as Qt,ba as R,De as Rn,jr as Rt,uo as S,dn as Sn,Zr as St,ja as T,A as Tn,ti as Tt,Gi as U,Lr as Ut,ca as V,br as Vt,Wi as W,Dr as Wt,Xi as X,Sr as Xt,Ki as Y,zr as Yt,Ji as Z,Cr as Zt,vo as _,_n,Kr as _t,Ao as a,vr as an,mi as at,ho as b,pn as bn,ii as bt,Go as c,On as cn,Si as ct,Jo as d,vn as dn,di as dt,kr as en,Bi as et,qo as f,N as fn,ci as ft,Ya as g,hn as gn,ei as gt,$ as h,Sn as hn,Oi as ht,Yo as i,yr as in,hi as it,fo as j,je as jn,qr as jt,bo as k,Ae as kn,$r as kt,Xo as l,kn as ln,li as lt,Do as m,P as mn,Di as mt,Qo as n,Ar as nn,wi as nt,Fo as o,V as on,xi as ot,Oo as p,F as pn,Ei as pt,Ui as q,Vr as qt,$o as r,Ir as rn,gi as rt,zo as s,Dn as sn,Ci as st,es as t,Or as tn,zi as tt,No as u,xn as un,ui as ut,po as v,mn as vn,ri as vt,ro as w,sn as wn,Wr as wt,co as x,fn as xn,Gr as xt,go as y,gn as yn,ni as yt,va as z,Tr as zt};
|