eve 0.22.0 → 0.22.2
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 +20 -0
- package/dist/src/channel/types.d.ts +18 -1
- package/dist/src/cli/commands/init-repl.d.ts +6 -5
- package/dist/src/compiled/.vendor-stamp.json +6 -4
- package/dist/src/compiled/@workflow/core/create-hook.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/events-consumer.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +14 -0
- package/dist/src/compiled/@workflow/core/runtime/get-world-lazy.d.ts +3 -12
- package/dist/src/compiled/@workflow/core/runtime/wait-continuation.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/world-compatibility.d.ts +5 -0
- package/dist/src/compiled/@workflow/core/runtime/world-init.d.ts +16 -41
- package/dist/src/compiled/@workflow/core/runtime/world-target.d.ts +11 -0
- package/dist/src/compiled/@workflow/core/runtime/world.d.ts +21 -9
- package/dist/src/compiled/@workflow/core/runtime.d.ts +2 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -141
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/world-init-stub.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.js +1 -1
- package/dist/src/compiled/@workflow/world/analytics.d.ts +182 -0
- package/dist/src/compiled/@workflow/world/env-config.d.ts +39 -0
- package/dist/src/compiled/@workflow/world/events.d.ts +25 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +6 -3
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +14 -7
- package/dist/src/compiled/@workflow/world/runs.d.ts +9 -1
- package/dist/src/compiled/@workflow/world/shared.d.ts +15 -0
- package/dist/src/compiled/@workflow/world/steps.d.ts +8 -0
- package/dist/src/compiled/@workflow/world-local/LICENSE.md +201 -0
- package/dist/src/compiled/@workflow/world-local/index.js +4 -0
- package/dist/src/compiled/@workflow/world-vercel/LICENSE.md +201 -0
- package/dist/src/compiled/@workflow/world-vercel/index.js +42 -0
- package/dist/src/compiled/_chunks/workflow/attribute-changes-BnKD8Y3m.js +20 -0
- package/dist/src/compiled/_chunks/workflow/{dist-FLIfyJ4Y.js → dist-CttsoN4D.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/dist-DJU_7R9s.js +40 -0
- package/dist/src/compiled/_chunks/workflow/dist-DpDDcpTl.js +3 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-DjPY9VGg.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-BSANnUPR.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-phozDCW8.js +1 -0
- package/dist/src/compiled/_chunks/workflow/token-CaY0nA5J.js +1 -0
- package/dist/src/compiled/_chunks/workflow/token-D4VIwGlD.js +1 -0
- package/dist/src/compiled/_chunks/workflow/undici-fb54XL8i.js +95 -0
- package/dist/src/execution/reconcile-session-continuation-token.d.ts +4 -0
- package/dist/src/execution/reconcile-session-continuation-token.js +1 -0
- package/dist/src/execution/sandbox/bindings/vercel-credentials.js +1 -1
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/subagent-adapter.js +1 -1
- package/dist/src/execution/subagent-event-proxy-step.d.ts +23 -0
- package/dist/src/execution/subagent-event-proxy-step.js +1 -0
- package/dist/src/execution/turn-workflow.js +1 -1
- package/dist/src/execution/workflow-steps.d.ts +1 -22
- package/dist/src/execution/workflow-steps.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/model-call-error.d.ts +5 -0
- package/dist/src/harness/model-call-error.js +1 -1
- package/dist/src/harness/prompt-cache.d.ts +18 -9
- package/dist/src/harness/prompt-cache.js +1 -1
- package/dist/src/harness/tool-loop.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.d.ts +4 -0
- package/dist/src/internal/application/compiled-artifacts.js +5 -4
- package/dist/src/internal/application/package.d.ts +9 -5
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/routes/health.d.ts +3 -3
- package/dist/src/internal/workflow/runtime.js +1 -1
- package/dist/src/internal/workflow/validate-world.d.ts +16 -0
- package/dist/src/internal/workflow/validate-world.js +1 -0
- package/dist/src/internal/workflow/world-compatibility.d.ts +1 -12
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/index.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/parse-name.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/pluralize.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/promise.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/time.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/workflow-routes.js +1 -0
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/world-target.js +1 -0
- package/dist/src/node_modules/.pnpm/ms@2.1.3/node_modules/ms/index.js +1 -0
- package/dist/src/public/channels/slack/action-status.d.ts +19 -0
- package/dist/src/public/channels/slack/action-status.js +1 -0
- package/dist/src/public/channels/slack/defaults.js +2 -2
- package/dist/src/public/channels/slack/hitl.d.ts +3 -2
- package/dist/src/public/channels/slack/hitl.js +3 -3
- package/dist/src/public/channels/slack/index.d.ts +2 -1
- package/dist/src/public/channels/slack/index.js +1 -1
- package/dist/src/public/channels/slack/interactions.js +1 -1
- package/dist/src/public/channels/slack/limits.d.ts +18 -0
- package/dist/src/public/channels/slack/limits.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +1 -1
- package/dist/src/public/next/index.d.ts +9 -9
- package/dist/src/public/next/index.js +1 -1
- package/dist/src/public/next/vercel-output-config.js +1 -1
- package/dist/src/runtime/sandbox/keys.d.ts +4 -0
- package/dist/src/runtime/sandbox/keys.js +1 -1
- package/dist/src/runtime/sandbox/template-plan.d.ts +0 -2
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/shared/vercel-project.d.ts +25 -0
- package/dist/src/shared/vercel-project.js +1 -0
- package/docs/agent-config.md +1 -1
- package/docs/channels/github.mdx +35 -2
- package/docs/channels/linear.mdx +35 -5
- package/docs/channels/slack.mdx +30 -3
- package/docs/concepts/execution-model-and-durability.md +1 -1
- package/docs/connections/overview.mdx +2 -0
- package/docs/guides/deployment.md +1 -1
- package/docs/guides/frontend/nextjs.mdx +7 -7
- package/docs/sandbox.mdx +3 -1
- package/docs/subagents.mdx +3 -1
- package/package.json +7 -5
- package/dist/src/compiled/_chunks/workflow/attribute-changes-zAifvEhb.js +0 -59
- package/dist/src/compiled/_chunks/workflow/dist-Dxrjttr2.js +0 -3
- package/dist/src/compiled/_chunks/workflow/resume-hook-C15uJ2ik.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-BJUPZ0Ni.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-C8B-TYir.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-Bm-WLAUB.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-J7YP0s9a.js +0 -1
- package/dist/src/internal/workflow/configure-world.d.ts +0 -18
- package/dist/src/internal/workflow/configure-world.js +0 -1
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import{o as e}from"./dist-CttsoN4D.js";const t={USER_ERROR:`USER_ERROR`,RUNTIME_ERROR:`RUNTIME_ERROR`,CORRUPTED_EVENT_LOG:`CORRUPTED_EVENT_LOG`,REPLAY_DIVERGENCE:`REPLAY_DIVERGENCE`,MAX_DELIVERIES_EXCEEDED:`MAX_DELIVERIES_EXCEEDED`,REPLAY_TIMEOUT:`REPLAY_TIMEOUT`,WORLD_CONTRACT_ERROR:`WORLD_CONTRACT_ERROR`};function n(e){return typeof e==`object`&&!!e&&`name`in e&&`message`in e}function r(e,t){if(t.length===0)return e;let n=[e];return t.forEach((e,r)=>{let i=r===t.length-1,a=i?`╰▶ `:`├▶ `,o=i?` `:`│ `;`${e.label}: ${e.value}`.split(`
|
|
2
|
+
`).forEach((e,t)=>n.push(`${t===0?a:o}${e}`))}),n.join(`
|
|
3
|
+
`)}function i(e,t){let n=[];return e&&n.push({label:`hint`,value:e}),t&&n.push({label:`docs`,value:`https://workflow-sdk.dev/err/${t}`}),n}const a={NODE_JS_MODULE_IN_WORKFLOW:`node-js-module-in-workflow`,START_INVALID_WORKFLOW_FUNCTION:`start-invalid-workflow-function`,SERIALIZATION_FAILED:`serialization-failed`,WEBHOOK_INVALID_RESPOND_WITH_VALUE:`webhook-invalid-respond-with-value`,WEBHOOK_RESPONSE_NOT_SENT:`webhook-response-not-sent`,FETCH_IN_WORKFLOW_FUNCTION:`fetch-in-workflow`,TIMEOUT_FUNCTIONS_IN_WORKFLOW:`timeout-in-workflow`,HOOK_CONFLICT:`hook-conflict`,CORRUPTED_EVENT_LOG:`corrupted-event-log`,REPLAY_DIVERGENCE:`replay-divergence`,STEP_NOT_REGISTERED:`step-not-registered`,WORKFLOW_NOT_REGISTERED:`workflow-not-registered`,RUNTIME_DECRYPTION_FAILED:`runtime-decryption-failed`};var o=class extends Error{cause;constructor(e,t){let n=r(e,i(void 0,t?.slug));super(n,{cause:t?.cause}),t?.cause!==void 0&&(this.cause=t.cause),t?.cause instanceof Error&&(this.stack=`${this.stack}\nCaused by: ${t.cause.stack}`)}static is(e){return n(e)&&e.name===`WorkflowError`}},s=class extends o{status;code;url;retryAfter;constructor(e,t){super(e,{cause:t?.cause}),this.name=`WorkflowWorldError`,this.status=t?.status,this.code=t?.code,this.url=t?.url,this.retryAfter=t?.retryAfter}static is(e){return n(e)&&e.name===`WorkflowWorldError`}},c=class extends o{runId;errorCode;constructor(e,t,n={}){let r=t instanceof Error?t.message:typeof t==`string`?t:t&&typeof t==`object`&&`message`in t?String(t.message):`Unknown error`;super(`Workflow run "${e}" failed: ${r}`,{cause:t}),this.name=`WorkflowRunFailedError`,this.runId=e,n.errorCode!==void 0&&(this.errorCode=n.errorCode)}static is(e){return n(e)&&e.name===`WorkflowRunFailedError`}},l=class extends o{runId;status;constructor(e,t){super(`Workflow run "${e}" has not completed`,{}),this.name=`WorkflowRunNotCompletedError`,this.runId=e,this.status=t}static is(e){return n(e)&&e.name===`WorkflowRunNotCompletedError`}},u=class extends o{constructor(e,t){super(e,{...t}),this.name=`WorkflowRuntimeError`}static is(e){return n(e)&&e.name===`WorkflowRuntimeError`}},d=class extends u{constructor(e,t){super(e,{...t,slug:a.CORRUPTED_EVENT_LOG}),this.name=`CorruptedEventLogError`}static is(e){return n(e)&&e.name===`CorruptedEventLogError`}},f=class extends u{eventId;constructor(e,t){super(e,{...t,slug:a.REPLAY_DIVERGENCE}),this.name=`ReplayDivergenceError`,this.eventId=t.eventId}static is(e){return n(e)&&e.name===`ReplayDivergenceError`&&typeof e.eventId==`string`}},p=class extends u{constructor(e,t){super(e,{cause:t?.cause,slug:a.RUNTIME_DECRYPTION_FAILED}),this.name=`RuntimeDecryptionError`,t?.context!==void 0&&(this.context=t.context)}static is(e){return n(e)&&e.name===`RuntimeDecryptionError`}},m=class extends o{hint;constructor(e,t){let n=r(e,i(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`WorkflowBuildError`,this.hint=t?.hint}static is(e){return n(e)&&e.name===`WorkflowBuildError`}},h=class extends o{hint;fatal=!0;constructor(e,t){let n=r(e,i(t?.hint,void 0));super(n,{cause:t?.cause}),this.name=`SerializationError`,this.hint=t?.hint}static is(e){return n(e)&&e.name===`SerializationError`}},g=class extends u{stepName;constructor(e){super(`Step "${e}" is not registered in the current deployment. This usually indicates a build or bundling issue that caused the step to not be included in the deployment.`,{slug:a.STEP_NOT_REGISTERED}),this.name=`StepNotRegisteredError`,this.stepName=e}static is(e){return n(e)&&e.name===`StepNotRegisteredError`}},_=class extends u{workflowName;constructor(e){super(`Workflow "${e}" is not registered in the current deployment. This usually means a run was started against a deployment that does not have this workflow, or there was a build/bundling issue.`,{slug:a.WORKFLOW_NOT_REGISTERED}),this.name=`WorkflowNotRegisteredError`,this.workflowName=e}static is(e){return n(e)&&e.name===`WorkflowNotRegisteredError`}},v=class extends o{runId;constructor(e){super(`Workflow run "${e}" not found`,{}),this.name=`WorkflowRunNotFoundError`,this.runId=e}static is(e){return n(e)&&e.name===`WorkflowRunNotFoundError`}},y=class extends o{token;conflictingRunId;constructor(e,t){super(`Hook token "${e}" is already in use by another workflow${t?` (run "${t}")`:``}`,{slug:a.HOOK_CONFLICT}),this.name=`HookConflictError`,this.token=e,t!==void 0&&(this.conflictingRunId=t)}static is(e){return n(e)&&e.name===`HookConflictError`}},b=class extends o{token;constructor(e){super(`Hook not found`,{}),this.name=`HookNotFoundError`,this.token=e}static is(e){return n(e)&&e.name===`HookNotFoundError`}},x=class extends s{constructor(e){super(e),this.name=`EntityConflictError`}static is(e){return n(e)&&e.name===`EntityConflictError`}},S=class extends s{constructor(e){super(e),this.name=`RunExpiredError`}static is(e){return n(e)&&e.name===`RunExpiredError`}},C=class extends s{constructor(e,t){super(e,{retryAfter:t?.retryAfter}),this.name=`TooEarlyError`}static is(e){return n(e)&&e.name===`TooEarlyError`}},w=class extends s{retryAfter;constructor(e,t){super(e),this.name=`ThrottleError`,this.retryAfter=t?.retryAfter}static is(e){return n(e)&&e.name===`ThrottleError`}},T=class extends o{runId;constructor(e){super(`Workflow run "${e}" cancelled`,{}),this.name=`WorkflowRunCancelledError`,this.runId=e}static is(e){return n(e)&&e.name===`WorkflowRunCancelledError`}},E=class extends o{runSpecVersion;worldSpecVersion;constructor(e,t){super(`Run requires spec version ${e}, but world supports version ${t}. Please upgrade 'workflow' package.`),this.name=`RunNotSupportedError`,this.runSpecVersion=e,this.worldSpecVersion=t}static is(e){return n(e)&&e.name===`RunNotSupportedError`}},D=class extends Error{fatal=!0;constructor(e){super(e),this.name=`FatalError`}static is(e){return n(e)?e.name===`FatalError`?!0:e.fatal===!0:!1}},O=class extends Error{retryAfter;constructor(t,n={}){super(t),this.name=`RetryableError`,n.retryAfter===void 0?this.retryAfter=new Date(Date.now()+1e3):this.retryAfter=e(n.retryAfter)}static is(e){return n(e)&&e.name===`RetryableError`}};const k="Your current vercel account does not have access to this resource. Use `vercel login` or `vercel switch` to ensure you are linked to the right account.",A=Symbol.for(`@workflow/errors//FatalError`),j=Symbol.for(`@workflow/errors//RetryableError`),M=Symbol.for(`@workflow/errors//HookConflictError`),N=Symbol.for(`@workflow/errors//RuntimeDecryptionError`);typeof globalThis<`u`&&(Object.hasOwn(globalThis,A)||Object.defineProperty(globalThis,A,{value:D,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,j)||Object.defineProperty(globalThis,j,{value:O,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,M)||Object.defineProperty(globalThis,M,{value:y,writable:!1,enumerable:!1,configurable:!1}),Object.hasOwn(globalThis,N)||Object.defineProperty(globalThis,N,{value:p,writable:!1,enumerable:!1,configurable:!1}));export{v as C,t as E,l as S,s as T,m as _,y as a,T as b,O as c,p as d,h as f,k as g,C as h,D as i,S as l,w as m,a as n,b as o,g as p,x as r,f as s,d as t,E as u,o as v,u as w,c as x,_ as y};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./chunk-BHKSVoKr.js";import{n as t,o as n,w as r}from"./dist-DpDDcpTl.js";import{B as i,Cn as a,D as o,Gt as s,J as c,Lt as l,X as u,a as d,at as f,b as p,it as m,m as h,n as g,r as _,rt as v,tn as y,un as b,vn as x}from"./attribute-changes-BnKD8Y3m.js";import{o as S}from"./dist-DJU_7R9s.js";var C=e({getHookByToken:()=>T,resumeHook:()=>E,resumeWebhook:()=>D});async function w(e){let t=await x(),n=await t.hooks.getByToken(e),r=await t.runs.get(n.runId),i=await t.getEncryptionKeyForRun?.(r),s=i?await a(i):void 0;return n.metadata!==void 0&&(n.metadata=await o(n.metadata,n.runId,s)),{hook:n,run:r,encryptionKey:s}}async function T(e){let{hook:t}=await w(e);return t}async function E(e,t,n){return await _(()=>u(`hook.resume`,async r=>{let o=await x();try{let u,_,v;if(typeof e==`string`){let t=await w(e);u=t.hook,_=t.run,v=n??t.encryptionKey}else if(u=e,_=await o.runs.get(u.runId),n)v=n;else{let e=await o.getEncryptionKeyForRun?.(_);v=e?await a(e):void 0}r?.setAttributes({...f(u.token),...m(u.hookId),...s(u.runId)});let b=_.executionContext?.workflowCoreVersion,x=h(typeof b==`string`?b:void 0);x.supportedFormats.has(y.ENCRYPTED)||(v=void 0);let C=(_.specVersion??0)>=5&&x.supportedFormats.has(y.GZIP),T=[],E=S(u.specVersion),D=await p(t,u.runId,v,T,globalThis,E,x.framedByteStreams,C);g(Promise.all(T),e=>{e!==void 0&&i.warn(`Background flush of hook payload ops failed`,{workflowRunId:u.runId,hookId:u.hookId,error:e instanceof Error?e.message:String(e)})}),await o.events.create(u.runId,{eventType:`hook_received`,specVersion:5,correlationId:u.hookId,eventData:{...E?{}:{token:u.token},payload:D}},{v1Compat:E}),r?.setAttributes({...l(_.workflowName)});let O=await c(_.executionContext?.traceCarrier);return O&&r?.addLink?.(O),await o.queue(d(_.workflowName),{runId:u.runId,traceCarrier:_.executionContext?.traceCarrier??void 0},{deploymentId:_.deploymentId,specVersion:_.specVersion??1}),u}catch(t){throw r?.setAttributes({...f(typeof e==`string`?e:e.token),...v(!1)}),t}}))}async function D(e,i){let{hook:a,encryptionKey:o}=await w(e);if(a.isWebhook===!1)throw new n(e);let s,c;if(a.metadata&&typeof a.metadata==`object`&&`respondWith`in a.metadata)if(a.metadata.respondWith===`manual`){let{readable:e,writable:t}=new TransformStream;c=e,i[b]=t}else if(a.metadata.respondWith instanceof Response)s=a.metadata.respondWith;else throw new r(`Invalid \`respondWith\` value: ${a.metadata.respondWith}`,{slug:t.WEBHOOK_INVALID_RESPOND_WITH_VALUE});else s=new Response(null,{status:202});if(await E(a,i,o),c){let e=c.getReader(),t=await e.read();t.value&&(s=t.value),e.cancel()}if(!s)throw new r(`Workflow run did not send a response`,{slug:t.WEBHOOK_RESPONSE_NOT_SENT});return s}export{C as i,E as n,D as r,T as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{h as e}from"./dist-CttsoN4D.js";import{C as t,E as n,S as r,T as i,b as a,d as o,m as s,p as c,r as l,s as u,t as d,w as f,x as p,y as m}from"./dist-DpDDcpTl.js";import{$ as h,A as g,B as _,Cn as v,E as y,Gt as b,Kt as x,Lt as S,R as C,Rt as w,X as T,Y as E,_n as D,a as O,gn as k,j as A,jt as j,m as M,n as ee,p as te,r as N,s as P,t as F,tn as I,vn as L,w as R,x as z,yn as B}from"./attribute-changes-BnKD8Y3m.js";import{a as V,o as H}from"./dist-DJU_7R9s.js";const U=new Set([`PARSE_ERROR`,`SCHEMA_VALIDATION`,n.WORLD_CONTRACT_ERROR]),W=new Set([`TRANSPORT`,`TIMEOUT`]),G=[f.is,c.is,m.is,o.is];function K(e){if(!i.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 q(e){return s.is(e)?!0:i.is(e)?e.status!==void 0&&e.status>=500?!0:e.code!==void 0&&W.has(e.code):!1}function J(e){if(u.is(e))return n.REPLAY_DIVERGENCE;if(d.is(e))return n.CORRUPTED_EVENT_LOG;if(K(e)||q(e))return n.WORLD_CONTRACT_ERROR;for(let t of G)if(t(e))return n.RUNTIME_ERROR;return n.USER_ERROR}const Y=V();let X=!1;async function Z(t,n,r){"use step";return await N(()=>{let i=t?.workflowId;if(!i)throw new f(`'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 T(`workflow.start ${e(i)}`,async e=>{e?.setAttributes({...S(i),...w(`start`)});let t=[],a=r??{};Array.isArray(n)?t=n:typeof n==`object`&&(a=n),e?.setAttributes({...j(t.length)});let o=a.world??await L();B(o);let s=await o.getDeploymentId(),c=a.deploymentId??s;c===`latest`&&(o.resolveLatestDeploymentId?c=await o.resolveLatestDeploymentId():(X||(X=!0,_.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:s})),c=s));let u,d;if(c===s)u=!0,d=!0;else if(typeof o.streams?.get!=`function`)u=!1,d=!1;else{let e=M((await P(o,`workflow`,{deploymentId:c,timeout:2e3}).catch(()=>void 0))?.workflowCoreVersion);u=e.framedByteStreams,d=e.supportedFormats.has(I.GZIP)}let p=[],m=`wrun_${Y()}`,g=await E(),y=a.specVersion??o.specVersion,C=H(y),T=a.allowReservedAttributes===!0,D;if(a.attributes&&Object.keys(a.attributes).length>0){if(y<4)throw new f(`Initial workflow attributes require a World that supports spec version 4 or later.`);for(let[e,t]of Object.entries(a.attributes))if(typeof t!=`string`)throw new f(`Initial workflow attribute ${JSON.stringify(e)} must be a string value.`);let e=F(a.attributes,{allowReservedAttributes:T});D=Object.fromEntries(e.map(({key:e,value:t})=>[e,t]))}let k=D?{attributes:D,...T?{allowReservedAttributes:!0}:{}}:{},A=await o.getEncryptionKeyForRun?.(m,{...a,deploymentId:c}),N=A?await v(A):void 0,R=await z(t,m,N,p,globalThis,C,u,d&&y>=5),V={traceCarrier:g,workflowCoreVersion:te,features:{encryption:!!N}},[U,W]=await Promise.allSettled([o.events.create(m,{eventType:`run_created`,specVersion:y,eventData:{deploymentId:c,workflowName:i,input:R,executionContext:V,...k}},{v1Compat:C}),o.queue(O(i),{runId:m,traceCarrier:g,...y>=3?{runInput:{input:R,deploymentId:c,workflowName:i,specVersion:y,executionContext:V,...k}}:{}},{deploymentId:c,specVersion:y})]);if(W.status===`rejected`)throw W.reason;let G=!1;if(U.status===`rejected`){let e=U.reason;if(!l.is(e))if(q(e))G=!0,_.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:m,error:e.message});else throw e}else{let e=U.value;if(!e.run)throw new f(`Missing 'run' in server response for 'run_created' event`);if(!C&&e.run.runId!==m)throw new f(`Server returned different runId than requested: expected ${m}, got ${e.run.runId}`)}return ee(Promise.all(p),e=>{_.warn(`Background flush of workflow argument streams failed`,{workflowRunId:m,error:e instanceof Error?e.message:String(e)})}),e?.setAttributes({...b(m),...h(c),...U.status===`fulfilled`&&U.value.run?x(U.value.run.status):{}}),new $(m,{resilientStart:G})})})}const ne=e=>Array.isArray(e)?e:[e];async function re(e,t,n={}){try{let r=await e.runs.get(t,{resolveData:`all`}),i=await e.getEncryptionKeyForRun?.(r),a=i?await v(i):void 0,o=ne(await g(r.input,t,a,globalThis)),s=n.specVersion??r.specVersion??1,c=n.deploymentId??r.deploymentId;return(await Z({workflowId:r.workflowName},o,{deploymentId:c,world:e,specVersion:s})).runId}catch(e){throw Error(`Failed to recreate run from ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ie(e,t){try{let n=(await e.runs.get(t,{resolveData:`none`})).specVersion??1,r=H(n),i={eventType:`run_cancelled`,specVersion:n};await e.events.create(t,i,{v1Compat:r})}catch(e){throw Error(`Failed to cancel run ${t}: ${e instanceof Error?e.message:String(e)}`,{cause:e})}}async function ae(e,t){try{let n=await e.runs.get(t,{resolveData:`none`});await e.queue(O(n.workflowName),{runId:t},{deploymentId:n.deploymentId,specVersion:n.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=H(r.specVersion),a=[],o=null;do{let n=await e.events.list({runId:t,pagination:{limit:1e3,...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)),u=s.filter(e=>!c.has(e.correlationId));if(n?.correlationIds&&n.correlationIds.length>0){let e=new Set(n.correlationIds);u=u.filter(t=>t.correlationId&&e.has(t.correlationId))}let d=[],f=0;for(let n of u){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}),f++}catch(e){l.is(e)?f++:d.push(e instanceof Error?e:Error(String(e)))}}if(f>0&&await e.queue(O(r.workflowName),{runId:t},{deploymentId:r.deploymentId,specVersion:r.specVersion??1}),d.length>0)throw AggregateError(d,`Failed to complete ${d.length}/${u.length} pending wait(s) for run ${t}`);return{stoppedCount:f}}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 oe(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 se(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})}}var $=class e{static[D](e){return{runId:e.runId,resilientStart:e.#r}}static[k](t){return new e(t.runId,{resilientStart:t.resilientStart})}runId;#e;get#t(){return this.#e||=L(),this.#e}#n=null;#r=!1;constructor(e,t){this.runId=e,this.#r=t?.resilientStart??!1}#i(){return this.#n||=(async()=>{let e=await this.#t,t=await e.runs.get(this.runId),n=await e.getEncryptionKeyForRun?.(t);return n?await v(n):void 0})(),this.#n}#a(){return()=>this.#i()}async wakeUp(e){"use step";return Q(await this.#t,this.runId,e)}async cancel(){"use step";await(await this.#t).events.create(this.runId,{eventType:`run_cancelled`,specVersion:5})}get exists(){"use step";return this.#t.then(e=>e.runs.get(this.runId,{resolveData:`none`}).then(()=>!0).catch(e=>{if(t.is(e))return!1;throw e}))}get status(){"use step";return this.#t.then(e=>e.runs.get(this.runId).then(e=>e.status))}get returnValue(){"use step";return this.#o()}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=C(this.runId,i),o=this.#a(),s=R(n,t,this.runId,o).ReadableStream({name:a,startIndex:r}),c=this.#t,l=this.runId;return Object.assign(s,{getTailIndex:async()=>(await(await c).streams.getInfo(l,a)).tailIndex})}async#o(){let e=await this.#t,n=0,i=this.#r?3:0,o=[1e3,3e3,6e3];for(;;)try{let t=await e.runs.get(this.runId);if(t.status===`completed`){let e=await this.#i();return await A(t.output,this.runId,e)}if(t.status===`cancelled`)throw new a(this.runId);if(t.status===`failed`){let e=await this.#i(),n;try{n=await y(t.error,this.runId,e)}catch{n=Error(`Failed to hydrate workflow run error`)}throw new p(this.runId,n,{errorCode:t.errorCode})}throw new r(this.runId,t.status)}catch(e){if(r.is(e)){await new Promise(e=>setTimeout(e,1e3));continue}if(t.is(e)&&n<i){let e=o[n];n++,await new Promise(t=>setTimeout(t,e));continue}throw e}}};function ce(e){return new $(e)}export{oe as a,Q as c,q as d,K as f,se as i,Z as l,ce as n,re as o,ie as r,ae as s,$ as t,J as u};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{En as e,mn as t}from"./attribute-changes-BnKD8Y3m.js";async function n(r){let i=globalThis[t];return i||e(`sleep()`,`https://workflow-sdk.dev/docs/api-reference/workflow/sleep`,n),i(r)}export{n as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./chunk-BHKSVoKr.js";import{i as t,r as n}from"../../@workflow/world-vercel/index.js";var r=e(((e,r)=>{var i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of o(t))!s.call(e,c)&&c!==n&&i(e,c,{get:()=>t[c],enumerable:!(r=a(t,c))||r.enumerable});return e},u=e=>l(i({},`__esModule`,{value:!0}),e),d={};c(d,{refreshToken:()=>m}),r.exports=u(d);var f=t(),p=n();async function m(e){let t=e?.project,n=e?.team;if(!t&&!n){let e=(0,p.findProjectInfo)();t=e.projectId,n=e.teamId}else if(!t||!n){let e=(0,p.findProjectInfo)();t??=e.projectId,n??=e.teamId}if(!t)throw new f.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let r=(0,p.loadToken)(t);if(!r||(0,p.isExpired)((0,p.getTokenPayload)(r.token),e?.expirationBufferMs)){let i=await(0,p.getVercelToken)({expirationBufferMs:e?.expirationBufferMs});if(r=await(0,p.getVercelOidcToken)(i,t,n),!r)throw new f.VercelOidcTokenError(`Failed to refresh OIDC token`);(0,p.saveToken)(r,t)}process.env.VERCEL_OIDC_TOKEN=r.token}0&&(r.exports={refreshToken:m})}));export default r();export{};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{t as e}from"./chunk-BHKSVoKr.js";import{n as t,t as n}from"../../@workflow/world-vercel/index.js";var r=e(((e,r)=>{var i=Object.defineProperty,a=Object.getOwnPropertyDescriptor,o=Object.getOwnPropertyNames,s=Object.prototype.hasOwnProperty,c=(e,t)=>{for(var n in t)i(e,n,{get:t[n],enumerable:!0})},l=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(let c of o(t))!s.call(e,c)&&c!==n&&i(e,c,{get:()=>t[c],enumerable:!(r=a(t,c))||r.enumerable});return e},u=e=>l(i({},`__esModule`,{value:!0}),e),d={};c(d,{refreshToken:()=>m}),r.exports=u(d);var f=t(),p=n();async function m(e){let t=e?.project,n=e?.team;if(!t&&!n){let e=(0,p.findProjectInfo)();t=e.projectId,n=e.teamId}else if(!t||!n){let e=(0,p.findProjectInfo)();t??=e.projectId,n??=e.teamId}if(!t)throw new f.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");let r=(0,p.loadToken)(t);if(!r||(0,p.isExpired)((0,p.getTokenPayload)(r.token),e?.expirationBufferMs)){let i=await(0,p.getVercelToken)({expirationBufferMs:e?.expirationBufferMs});if(r=await(0,p.getVercelOidcToken)(i,t,n),!r)throw new f.VercelOidcTokenError(`Failed to refresh OIDC token`);(0,p.saveToken)(r,t)}process.env.VERCEL_OIDC_TOKEN=r.token}0&&(r.exports={refreshToken:m})}));export default r();export{};
|