eve 0.22.1 → 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 +11 -0
- 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/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/index.d.ts +1 -0
- package/dist/src/public/channels/slack/index.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/setup/scaffold/create/project.js +2 -2
- 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 +3 -3
- package/docs/concepts/execution-model-and-durability.md +1 -1
- package/docs/guides/deployment.md +1 -1
- package/docs/guides/frontend/nextjs.mdx +7 -7
- package/docs/subagents.mdx +2 -0
- 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,4 @@
|
|
|
1
|
+
import{a as e,i as t,t as n}from"../../_chunks/workflow/chunk-BHKSVoKr.js";import{i as r,n as i,r as a,t as o}from"../../_chunks/workflow/dist-CttsoN4D.js";import{C as s,T as c,h as l,l as u,o as d,r as f,u as p}from"../../_chunks/workflow/dist-DpDDcpTl.js";import{A as m,D as h,E as g,F as _,L as v,M as y,P as b,R as x,T as ee,V as S,W as C,Y as w,Z as T,a as E,d as D,g as O,k,l as A,n as te,o as ne,p as j,q as M,r as re,s as ie,v as N,z as ae}from"../../_chunks/workflow/dist-DJU_7R9s.js";import{t as P}from"../../_chunks/workflow/undici-fb54XL8i.js";import{createHash as oe}from"node:crypto";import{promisify as se}from"node:util";import{fileURLToPath as ce}from"node:url";import{promises as F}from"node:fs";import I,{access as le,constants as ue,mkdir as de,readFile as L,readdir as fe,readlink as pe,rm as me,unlink as he,writeFile as ge}from"node:fs/promises";import R from"node:path";import{execFile as _e}from"node:child_process";import{setTimeout as ve}from"node:timers/promises";import{EventEmitter as ye}from"node:events";function be(e,t=10){let n=parseInt(e,t);if(!Number.isNaN(n)&&n>=0&&n<=65535)return n}function xe(e,t){let n=[],r=e.trim().split(`
|
|
2
|
+
`);for(let e of r){let r=e.trim().split(/\s+/);if(r.length<5||r[0]?.toUpperCase()!==`TCP`)continue;let[,i,,a,o]=r;if(a?.toUpperCase()!==`LISTENING`||o!==t.toString())continue;let s=i.lastIndexOf(`:`);if(s===-1)continue;let c=be(i.slice(s+1));c!==void 0&&n.push(c)}return n}const Se=se(_e);function Ce(e,t=10){let n=parseInt(e,t);if(!Number.isNaN(n)&&n>=0&&n<=65535)return n}const we=((e,t)=>e.join(t))([``,`proc`],`/`);async function Te(e){let t=[`${we}/net/tcp`,`${we}/net/tcp6`],n=[],r=new Set,i=`${we}/${e}/fd`;try{let e=(await fe(i)).sort((e,t)=>Number.parseInt(e,10)-Number.parseInt(t,10)),t=await Promise.allSettled(e.map(async e=>(await pe(`${i}/${e}`)).match(/^socket:\[(\d+)\]$/)?.[1]??null));for(let e of t)e.status===`fulfilled`&&e.value&&(n.push(e.value),r.add(e.value))}catch{return[]}if(n.length===0)return[];let a=new Map;for(let e of t)try{let t=(await L(e,`utf8`)).split(`
|
|
3
|
+
`).slice(1);for(let e of t){if(!e.trim())continue;let t=e.trim().split(/\s+/);if(t.length<10)continue;let n=t[1],i=t[3],o=t[9];if(!n||i!==`0A`||!o||!r.has(o))continue;let s=n.indexOf(`:`);if(s===-1)continue;let c=n.slice(s+1);if(!c)continue;let l=Ce(c,16);l!==void 0&&a.set(o,l)}}catch{}let o=[];for(let e of n){let t=a.get(e);t!==void 0&&o.push(t)}return o}async function Ee(e){try{let{stdout:t}=await Se(`lsof`,[`-a`,`-i`,`-P`,`-n`,`-p`,e.toString()]),n=[],r=t.split(`
|
|
4
|
+
`);for(let e of r)if(e.includes(`LISTEN`)){let t=e.trim().split(/\s+/)[8];if(t){let e=t.lastIndexOf(`:`);if(e!==-1){let r=Ce(t.slice(e+1));r!==void 0&&n.push(r)}}}return n}catch{return[]}}async function De(e){try{let{stdout:t}=await Se(`cmd`,[`/c`,`netstat -ano -p tcp | findstr LISTENING`]);return xe(t,e)}catch{return[]}}async function Oe(){let{pid:e,platform:t}=process;try{switch(t){case`linux`:return await Te(e);case`darwin`:return await Ee(e);case`win32`:return await De(e);default:return[]}}catch(e){return process.env.NODE_ENV===`development`&&console.debug(`[getAllPorts] Detection failed:`,e),[]}}const ke=`${o}/flow?__health`;async function Ae(e,t={}){let{endpoint:n=ke,timeout:r=500}=t,i=new AbortController,a=setTimeout(()=>i.abort(),r);try{return(await fetch(`http://localhost:${e}${n}`,{method:`HEAD`,signal:i.signal})).status===200}catch{return!1}finally{clearTimeout(a)}}async function je(e){let t=await Oe();if(t.length===0)return;if(t.length===1)return t[0];let n=(await Promise.all(t.map(async t=>({port:t,isWorkflow:await Ae(t,e)})))).find(e=>e.isWorkflow);return n?n.port:(process.env.NODE_ENV===`development`&&console.debug(`[getWorkflowPort] Probing failed, falling back to first port:`,t[0]),t[0])}function Me(e){let t={get value(){let n=e();return Object.defineProperty(t,"value",{value:n}),n}};return t}const Ne=()=>process.env.WORKFLOW_LOCAL_DATA_DIR||`.workflow-data`,Pe=()=>process.env.WORKFLOW_LOCAL_BASE_URL,Fe=Me(()=>({dataDir:Ne(),baseUrl:Pe()}));function Ie(e){return e.baseUrl??process.env.WORKFLOW_LOCAL_BASE_URL??i(`http://localhost`)}async function Le(e){if(e.baseUrl)return e.baseUrl;if(process.env.WORKFLOW_LOCAL_BASE_URL)return process.env.WORKFLOW_LOCAL_BASE_URL;if(typeof e.port==`number`)return i(`http://localhost:${e.port}`);if(process.env.PORT)return i(`http://localhost:${process.env.PORT}`);let t=await je({endpoint:a()});if(t)return i(`http://localhost:${t}`);throw Error(`Unable to resolve base URL for workflow queue.`)}const Re=E(()=>Math.random());function ze(e){let t=typeof e==`string`?e:String(e);return t.length>48?`${t.slice(0,48)}…`:t}var Be=class extends c{constructor(e,t){super(`Unsafe ${e} "${ze(t)}": must not be empty, contain ".", "/", "\\", or null bytes`),this.name=`UnsafeEntityIdError`}static is(e){return e instanceof Error&&e.name===`UnsafeEntityIdError`}};function z(e,t){if(t.length===0||t.startsWith(`.`)||t.includes(`/`)||t.includes(`\\`)||t.includes(`\0`)||t.includes(`.`))throw new Be(e,t)}function B(e,...t){let n=R.resolve(e),r=R.resolve(e,...t);if(r!==n&&!r.startsWith(n+R.sep))throw new Be(`path`,t.join(`/`));return r}const Ve=process.platform===`win32`;async function He(e,t=5){if(!Ve)return e();let n=[`EPERM`,`EBUSY`,`EACCES`];for(let r=0;r<=t;r++)try{return await e()}catch(e){if(!(r<t&&n.includes(e.code)))throw e;let i=10*2**r+Math.random()*10;await new Promise(e=>setTimeout(e,i))}throw Error(`Retry loop exited unexpectedly`)}const Ue=new Set,We=new Set;function Ge(){Ue.clear(),We.clear()}const Ke=/\.[a-zA-Z][a-zA-Z0-9-]*$/;function qe(e){return e.replace(Ke,``)}function Je(e,t){return e.endsWith(`.${t}`)}function Ye(e){return!Ke.test(e)}function V(e,t,n,r){return z(`fileId`,n),r!==void 0&&z(`tag`,r),B(e,t,r?`${n}.${r}.json`:`${n}.json`)}async function H(e,t,n,r,i){if(z(`fileId`,n),i!==void 0&&z(`tag`,i),i){let a=await K(B(e,t,`${n}.${i}.json`),r);if(a!==null)return a}return K(B(e,t,`${n}.json`),r)}async function Xe(e,t){let n=`.${t}.json`;try{return(await F.readdir(e)).filter(e=>e.endsWith(n))}catch(e){if(e.code===`ENOENT`)return[];throw e}}async function Ze(e,t,n){let r=`.${t}${n}`;try{return(await F.readdir(e)).filter(e=>e.endsWith(r))}catch(e){if(e.code===`ENOENT`)return[];throw e}}async function Qe(e){let t=R.resolve(e);if(!We.has(t))try{await F.mkdir(t,{recursive:!0}),We.add(t)}catch{}}async function $e(e,t){await Qe(e);try{return await t()}catch(n){if(n.code!==`ENOENT`)throw n;return We.delete(R.resolve(e)),await Qe(e),t()}}function U(e,t){return t instanceof Uint8Array?{__type:`Uint8Array`,data:Buffer.from(t).toString(`base64`)}:t}function et(e,t){return typeof t==`object`&&t&&t.__type===`Uint8Array`&&typeof t.data==`string`?new Uint8Array(Buffer.from(t.data,`base64`)):t}async function W(e,t,n){return G(e,JSON.stringify(t,U,2),n)}async function G(e,t,n){if(!n?.overwrite){if(Ue.has(e))throw new f(`File ${e} already exists and 'overwrite' is false`);try{throw await F.access(e),Ue.add(e),new f(`File ${e} already exists and 'overwrite' is false`)}catch(e){if(e.code!==`ENOENT`)throw e}}let r=`${e}.tmp.${Re()}`,i=!1;try{await $e(R.dirname(e),async()=>{await F.writeFile(r,t),i=!0,await He(()=>F.rename(r,e))}),Ue.add(e)}catch(e){throw i&&await He(()=>F.unlink(r),3).catch(()=>{}),e}}async function K(e,t){try{let n=await F.readFile(e,`utf-8`);return t.parse(JSON.parse(n,et))}catch(e){if(e.code===`ENOENT`)return null;throw e}}async function tt(e){return await F.readFile(e)}async function nt(e){let t=await F.open(e,`r`);try{let e=Buffer.allocUnsafe(1),{bytesRead:n}=await t.read(e,0,1,0);return n===0?void 0:e[0]}finally{await t.close()}}async function q(e){try{await F.unlink(e)}catch(e){if(e.code!==`ENOENT`)throw e}}async function J(e,t){let n=`${e}.tmp.${Re()}`,r=!1;try{return await $e(R.dirname(e),async()=>{await F.writeFile(n,t,{flag:`wx`}),r=!0;try{return await He(()=>F.link(n,e)),!0}catch(e){if(e.code===`EEXIST`)return!1;throw e}})}finally{r&&await He(()=>F.unlink(n),3).catch(()=>{})}}async function rt(e){return it(e,`.json`)}async function it(e,t){try{return(await F.readdir(e)).filter(e=>e.endsWith(t)).map(e=>e.slice(0,-t.length))}catch(e){if(e.code===`ENOENT`)return[];throw e}}function at(e){if(!e)return null;let t=e.split(`|`);return{timestamp:new Date(t[0]),id:t[1]||null}}function ot(e,t){return t?`${e.toISOString()}|${t}`:e.toISOString()}async function Y(e){let{directory:t,schema:n,cachedItems:r,filePrefix:i,fileIdFilter:a,filter:o,sortOrder:s=`desc`,limit:c=20,cursor:l,getCreatedAt:u,getId:d}=e;i!==void 0&&z(`filePrefix`,i);let f=R.resolve(t),p=await rt(f),m=i?p.filter(e=>e.startsWith(i)):p,h=a?m.filter(a):m,g=at(l),_=h;g&&(_=h.filter(e=>{let t=u(`${e}.json`);if(t){let e=g.timestamp.getTime(),n=t.getTime();return g.id?s===`desc`?n<=e:n>=e:s===`desc`?n<e:n>e}return!0}));let v=[];for(let e of _){let t=R.join(f,`${e}.json`),i=null;try{let e=r?.get(t);i=e===void 0?await K(t,n):structuredClone(e)}catch(t){if(t instanceof T){console.warn(`Skipping item ${e} due to malformed JSON: ${t.message}`);continue}throw t}if(i){if(o&&!o(i))continue;if(g){let e=i.createdAt.getTime(),t=g.timestamp.getTime();if(s===`desc`){if(e>t||e===t&&g.id&&d&&d(i)>=g.id)continue}else if(e<t||e===t&&g.id&&d&&d(i)<=g.id)continue}v.push(i)}}v.sort((e,t)=>{let n=e.createdAt.getTime(),r=t.createdAt.getTime(),i=s===`asc`?n-r:r-n;if(i===0&&d){let n=d(e),r=d(t);return s===`asc`?n.localeCompare(r):r.localeCompare(n)}return i});let y=v.length>c,b=y?v.slice(0,c):v;return{data:b,cursor:b.length>0?ot(b[b.length-1].createdAt,d?.(b[b.length-1])):null,hasMore:y}}let X=null;function st(){return typeof import.meta.url==`string`&&import.meta.url?R.dirname(ce(import.meta.url)):null}async function ct(){if(X)return X;let e=st();if(e)try{let t=await L(R.join(e,`../package.json`),`utf-8`);return X=JSON.parse(t),X}catch{}return X={name:`@workflow/world-local`,version:`5.0.0-beta.24`},X}const lt=`version.txt`;var ut=class extends Error{dataDir;code;constructor(e,t,n){super(e),this.name=`DataDirAccessError`,this.dataDir=t,this.code=n}},dt=class extends Error{oldVersion;newVersion;suggestedVersion;constructor(e,t,n,r){super(e),this.name=`DataDirVersionError`,this.oldVersion=t,this.newVersion=n,this.suggestedVersion=r}};function ft(e){let t=e.match(/^(\d+)\.(\d+)\.(\d+)(?:-(.+))?$/);if(!t)throw Error(`Invalid version string: "${e}"`);return{major:parseInt(t[1],10),minor:parseInt(t[2],10),patch:parseInt(t[3],10),prerelease:t[4],raw:e}}function Z(e){let t=`${e.major}.${e.minor}.${e.patch}`;return e.prerelease?`${t}-${e.prerelease}`:t}function pt(e){let t=e.trim(),n=t.lastIndexOf(`@`);if(n<=0)throw Error(`Invalid version file content: "${e}"`);return{packageName:t.substring(0,n),version:ft(t.substring(n+1))}}function mt(e,t){return`${e}@${Z(t)}`}function ht(e,t){console.log(`[world-local] Upgrading from version ${Z(e)} to ${Z(t)}`)}async function gt(e){let t=R.resolve(e);try{await de(t,{recursive:!0})}catch(e){let n=e;if(n.code!==`EEXIST`)throw new ut(`Failed to create data directory "${t}": ${n.message}`,t,n.code)}try{await le(t,ue.R_OK)}catch(e){let n=e;throw new ut(`Data directory "${t}" is not readable: ${n.message}`,t,n.code)}let n=R.join(t,`.workflow-write-test-${Date.now()}`);try{await ge(n,``),await he(n).catch(e=>{if(e.code!==`ENOENT`)throw e})}catch(e){let n=e;throw new ut(`Data directory "${t}" is not writable: ${n.message}`,t,n.code)}}async function _t(e){let t=R.join(R.resolve(e),lt);try{return pt(await L(t,`utf-8`))}catch(e){if(e.code===`ENOENT`)return null;throw e}}async function vt(e,t){await ge(R.join(R.resolve(e),lt),mt((await ct()).name,t))}function yt(e,t){return t||Z(e)}async function bt(e){await gt(e);let t=await ct(),n=ft(t.version),r=await _t(e);if(r===null){await vt(e,n);return}let{version:i}=r;if(Z(i)!==Z(n))try{ht(i,n),await vt(e,n)}catch(e){let r=yt(i,e instanceof dt?e.suggestedVersion:void 0);throw console.error(`[world-local] Failed to upgrade data directory from version ${Z(i)} to ${Z(n)}:`,e instanceof Error?e.message:e),console.error(`[world-local] Data is not compatible with the current version. Please downgrade to ${t.name}@${r}`),e}}let xt=null;async function St(){return xt||=import(`../../_chunks/workflow/src-CQuMexnO.js`).then(t=>e(t.t(),1)).catch(()=>null),xt}let Ct=null;async function wt(){return Ct||=St().then(e=>e?e.trace.getTracer(`workflow`):null),Ct}async function Tt(e,...t){let[n,r]=await Promise.all([wt(),St()]),{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}),t}finally{e.end()}})}async function Et(e){let t=await St();if(t)return t.SpanKind[e]}function Q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Dt=Q(`peer.service`),Ot=Q(`rpc.system`),kt=Q(`rpc.service`),At=Q(`rpc.method`),jt=Q(`workflow.run.id`),Mt=Q(`step.id`),Nt={peerService:`world-local`,rpcSystem:`local`,rpcService:`world-local`},Pt={"world.runs.get":0,"world.runs.experimentalSetAttributes":0,"world.steps.get":0,"world.events.create":0,"world.events.get":0},Ft=new Set([`world.steps.list`,`world.events.list`,`world.hooks.list`]);function It(e){if(e.length>=2&&typeof e[1]==`object`&&e[1]!==null){let t=e[1];if(typeof t.eventType==`string`)return t.eventType}}function Lt(e,t){return typeof e[t]==`string`?e[t]:void 0}function Rt(e){if(typeof e!=`object`||!e)return;let t=e.runId;return typeof t==`string`?t:void 0}function zt(e){if(typeof e!=`object`||!e)return;let t=e;if(typeof t.runId==`string`)return t.runId;for(let e of[`run`,`step`,`hook`,`wait`]){let n=t[e];if(typeof n==`object`&&n){let e=n.runId;if(typeof e==`string`)return e}}}function Bt(e,t,n){let r=`${e}.${t}`,i={},a=Pt[r],o=a===void 0?Ft.has(r)?Rt(n[0]):void 0:Lt(n,a);if(o&&Object.assign(i,jt(o)),r===`world.steps.get`){let e=Lt(n,1);e&&Object.assign(i,Mt(e))}return i}function Vt(e,t){let n={};for(let r of Object.keys(t))if(typeof t[r]!=`function`)n[r]=t[r];else{let i=t[r],a=String(r);n[r]=async(...t)=>{let n=`${e}.${a}`;if(e===`world.events`&&a===`create`){let r=It(t);r&&(n=`${e}.${a} ${r}`)}return Tt(n,{kind:await Et(`INTERNAL`)},async r=>{r?.setAttributes({...Dt(Nt.peerService),...Ot(Nt.rpcSystem),...kt(Nt.rpcService),...At(n),...Bt(e,a,t)});let o=await i(...t),s=zt(o);return s&&r?.setAttributes(jt(s)),o})}}return n}var Ht=n((e=>{var n=e&&e.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(e,"__esModule",{value:!0}),e.RateLimit=e.Sema=void 0;let r=n(t(`events`));function i(e,t,n,r,i){for(let a=0;a<i;++a)n[a+r]=e[a+t],e[a+t]=void 0}function a(e){return e>>>=0,--e,e|=e>>1,e|=e>>2,e|=e>>4,e|=e>>8,e|=e>>16,e+1}function o(e){return a(Math.min(Math.max(16,e),1073741824))}var s=class{constructor(e){this._capacity=o(e),this._length=0,this._front=0,this.arr=[]}push(e){let t=this._length;this.checkCapacity(t+1);let n=this._front+t&this._capacity-1;return this.arr[n]=e,this._length=t+1,t+1}pop(){let e=this._length;if(e===0)return;let t=this._front+e-1&this._capacity-1,n=this.arr[t];return this.arr[t]=void 0,this._length=e-1,n}shift(){let e=this._length;if(e===0)return;let t=this._front,n=this.arr[t];return this.arr[t]=void 0,this._front=t+1&this._capacity-1,this._length=e-1,n}get length(){return this._length}checkCapacity(e){this._capacity<e&&this.resizeTo(o(this._capacity*1.5+16))}resizeTo(e){let t=this._capacity;this._capacity=e;let n=this._front,r=this._length;if(n+r>t){let e=n+r&t-1;i(this.arr,0,this.arr,t,e)}}},c=class extends r.default{};function l(e){return typeof e==`function`}function u(){return`1`}var d=class{constructor(e,{initFn:t=u,pauseFn:n,resumeFn:r,capacity:i=10}={}){if(l(n)!==l(r))throw Error(`pauseFn and resumeFn must be both set for pausing`);this.nrTokens=e,this.free=new s(e),this.waiting=new s(i),this.releaseEmitter=new c,this.noTokens=t===u,this.pauseFn=n,this.resumeFn=r,this.paused=!1,this.releaseEmitter.on(`release`,e=>{let t=this.waiting.shift();t?t.resolve(e):(this.resumeFn&&this.paused&&(this.paused=!1,this.resumeFn()),this.free.push(e))});for(let n=0;n<e;n++)this.free.push(t())}tryAcquire(){return this.free.pop()}async acquire(){let e=this.tryAcquire();return e===void 0?new Promise((e,t)=>{this.pauseFn&&!this.paused&&(this.paused=!0,this.pauseFn()),this.waiting.push({resolve:e,reject:t})}):e}release(e){this.releaseEmitter.emit(`release`,this.noTokens?`1`:e)}drain(){let e=Array(this.nrTokens);for(let t=0;t<this.nrTokens;t++)e[t]=this.acquire();return Promise.all(e)}nrWaiting(){return this.waiting.length}};e.Sema=d;function f(e,{timeUnit:t=1e3,uniformDistribution:n=!1}={}){let r=new d(n?1:e),i=n?t/e:t;return async function(){await r.acquire(),setTimeout(()=>r.release(),i)}}e.RateLimit=f}))(),Ut=P(),Wt=class{contentType=`application/json`;serialize(e){return Buffer.from(JSON.stringify(e,U))}async deserialize(e){let t=[],n=e.getReader();for(;;){let{done:e,value:r}=await n.read();if(e)break;r&&t.push(r)}let r=Buffer.concat(t).toString();return JSON.parse(r,et)}};const Gt=parseInt(process.env.WORKFLOW_LOCAL_QUEUE_MAX_VISIBILITY??`0`,10)||1/0,Kt=2147483647,qt=parseInt(process.env.WORKFLOW_LOCAL_QUEUE_CONCURRENCY??`0`,10)||1e3,Jt=`Cannot perform ArrayBuffer.prototype.slice on a detached ArrayBuffer`;function Yt(e){let t=e,n=new Set;for(;t&&typeof t==`object`&&!n.has(t);){if(n.add(t),`message`in t&&typeof t.message==`string`&&t.message.includes(Jt))return!0;t=`cause`in t?t.cause:void 0}return!1}function Xt(e){let{kind:t,prefix:n}=O(e);return{pathname:t===`workflow`?`flow`:`step`,prefix:n}}function Zt(e){let t=new Ut.Agent({headersTimeout:0,connections:1e3,keepAliveTimeout:3e4}),n=new Wt,i=E(),a=new Ht.Sema(qt),o=new AbortController,s=o.signal,c=new Map,l=new Map,u=async(o,u,d)=>{let f=[];if(d?.idempotencyKey){let e=c.get(d.idempotencyKey);if(e)return{messageId:e}}let p=n.serialize(u),{pathname:m,prefix:h}=Xt(o),g=D.parse(`msg_${i()}`),_=u,v=_.runId??_.workflowRunId??void 0,y=_.stepId??void 0;if(d?.idempotencyKey){let e=d.idempotencyKey;c.set(e,g),f.push(()=>{c.delete(e)})}return(async()=>{d?.delaySeconds&&d.delaySeconds>0&&await ve(Math.min(d.delaySeconds*1e3,Kt),void 0,{signal:s}),a.tryAcquire()||(console.warn(`[world-local]: concurrency limit (${qt}) reached, waiting for queue to free up`),await a.acquire());let n=0;try{for(let i=0;i<256;i++){let a={...d?.headers,"content-type":`application/json`,"x-vqs-queue-name":o,"x-vqs-message-id":g,"x-vqs-message-attempt":String(n+1)},c=l.get(h),u;try{if(c)u=await c(new Request(r(Ie(e),{type:m}),{method:`POST`,headers:a,body:p}));else{let n=await Le(e);u=await fetch(r(n,{type:m}),{method:`POST`,duplex:`half`,dispatcher:t,headers:a,body:p})}}catch(e){let t=e?.name;if(s.aborted||t===`AbortError`||t===`ResponseAborted`)return;if(Yt(e))throw e;console.error(`[world-local] Queue delivery failed at the transport (loop ${i+1}), retrying`,{queueName:o,messageId:g,...v&&{runId:v},...y&&{stepId:y},error:String(e)}),await ve(5e3,void 0,{signal:s});continue}n++;let f=await u.text();if(u.ok){try{let e=Number(JSON.parse(f).timeoutSeconds);if(Number.isFinite(e)&&e>=0){e>0&&await ve(Math.min(e*1e3,Kt),void 0,{signal:s});continue}}catch{}return}console.error(`[world-local] Queue message failed (attempt ${n}, HTTP ${u.status})`,{queueName:o,messageId:g,...v&&{runId:v},...y&&{stepId:y},handlerError:f}),await ve(5e3,void 0,{signal:s})}console.error(`[world-local] Queue message exhausted safety limit (256 attempts)`,{queueName:o,messageId:g,...v&&{runId:v},...y&&{stepId:y}})}finally{a.release()}})().catch(e=>{e?.name===`AbortError`||e?.name===`ResponseAborted`||(Yt(e)?console.error(`[local world] Queue operation failed: detected "${Jt}". This usually means a Next.js proxy/middleware consumed Workflow's internal request before the executor could read it. Exclude \`/.well-known/workflow/*\` from your matcher. See https://workflow-sdk.dev/docs/getting-started/next#configure-proxy-handler`,{queueName:o,messageId:g,...v&&{runId:v},...y&&{stepId:y},originalError:e}):console.error(`[local world] Queue operation failed:`,e))}).finally(()=>{for(let e of f)e()}),{messageId:g}},d=M({"x-vqs-queue-name":j,"x-vqs-message-id":D,"x-vqs-message-attempt":S()});return{queue:u,createQueueHandler:(e,t)=>async n=>{let r=d.safeParse(Object.fromEntries(n.headers));if(!r.success||!n.body)return Response.json({error:n.body?`Missing required headers`:`Missing request body`},{status:400});let i=r.data[`x-vqs-queue-name`],a=r.data[`x-vqs-message-id`],o=r.data[`x-vqs-message-attempt`];if(!i.startsWith(e))return Response.json({error:`Unhandled queue`},{status:400});let s=await new Wt().deserialize(n.body);try{let e=await t(s,{attempt:o,queueName:i,messageId:a}),n=null;return typeof e?.timeoutSeconds==`number`&&(n=Math.min(e.timeoutSeconds,Gt)),n==null?Response.json({ok:!0}):Response.json({timeoutSeconds:n})}catch(e){return Response.json(String(e),{status:500})}},getDeploymentId:async()=>`dpl_local@${(await ct()).version}`,registerHandler(e,t){l.set(e,t)},async close(){s.aborted||(o.abort(),await t.close())}}}function Qt(e){return oe(`sha256`).update(e).digest(`hex`)}function $t(e,t,n){return B(e,`.locks`,`hooks`,n?`${t}.disposed.${n}`:`${t}.disposed`)}async function en(e,t,n){let r=[$t(e,t)];n&&r.push($t(e,t,n));for(let e of r)try{return await I.access(e),!0}catch{}return!1}function tn(e,t){return R.join(e,`hooks`,`tokens`,`${Qt(t)}.json`)}async function nn(e,t,n,r){let i=tn(e,t),a;try{a=JSON.parse(await I.readFile(i,`utf8`))}catch{return}a.runId!==n||a.hookId!==r||await I.unlink(i).catch(()=>{})}function rn(e,t,n,r){let i=oe(`sha256`).update(`${t}\x00${n}\x00${r}`).digest(`hex`);return R.join(e,`hooks`,`tokens`,`${i}.recovery.json`)}const an=E(()=>Math.random()),$=e=>t=>{let n=qe(t.replace(/\.json$/,``))+`.json`,r=RegExp(`^${e}_`,`g`),i=n.indexOf(`-`);return i===-1?te(n.replace(/\.json$/,``).replace(r,``)):e===`step`?null:te(n.substring(i+1).replace(/\.json$/,``).replace(r,``))};function on(e,t){return t===`none`?{...e,input:void 0,output:void 0}:e}function sn(e,t){return t===`none`?{...e,input:void 0,output:void 0}:e}function cn(e,t){if(t===`none`){let{metadata:t,...n}=e;return n}return e}function ln(e,t){return t?Ye(e)||Je(e,t):Ye(e)}function un(e){if(e.eventType!==`hook_created`)return;let t=e.eventData.token;return typeof t==`string`?t:void 0}function dn(e){let{token:t,metadata:n,isWebhook:r,isSystem:i}=e.eventData;return{runId:e.runId,hookId:e.correlationId,token:t,metadata:n,ownerId:`local-owner`,projectId:`local-project`,environment:`local`,createdAt:e.createdAt,specVersion:e.specVersion,isWebhook:r??!0,isSystem:i??!1}}function fn(e,t){return e.eventType===`hook_created`&&typeof e.correlationId==`string`&&t(e)}function pn(e,t){return e.runId===t.runId?e.eventType===`hook_disposed`&&e.correlationId===t.correlationId||b(e.eventType):!1}async function mn(e){try{return await K(e,y)}catch(e){if(e instanceof SyntaxError||e instanceof T)return null;throw e}}async function hn(e,t,n){let r=await H(e,`runs`,t,k,n);return r?m(r.status):!1}async function gn(e,t,n){let r=R.join(e,`events`),i=[];for(let e of await rt(r)){if(!ln(e,n))continue;let t=await mn(R.join(r,`${e}.json`));t&&i.push(t)}i.sort((e,t)=>{let n=e.createdAt.getTime()-t.createdAt.getTime();return n===0?e.eventId.localeCompare(t.eventId):n});let a=null;for(let e of i){if(fn(e,t)){a=e;continue}a&&pn(e,a)&&(a=null)}return a&&await hn(e,a.runId,n)||a&&await en(e,a.correlationId,n)?null:a}async function _n(e,t,n){let r=dn(t);return await J(R.join(e,`hooks`,`tokens`,`${Qt(r.token)}.json`),JSON.stringify({token:r.token,hookId:r.hookId,runId:r.runId,eventId:t.eventId})),await J(V(e,`hooks`,r.hookId,n),JSON.stringify(r,U,2)),r}async function vn(e,t,n){let r=await gn(e,e=>un(e)===t,n);return r?_n(e,r,n):null}async function yn(e,t,n){let r=await gn(e,e=>e.correlationId===t,n);return r?_n(e,r,n):null}function bn(e,t){async function n(t){let n=R.join(e,`hooks`),r=await rt(n);for(let e of r){let r=await K(R.join(n,`${e}.json`),N);if(r&&r.token===t)return{...r,isWebhook:r.isWebhook??!0}}return null}async function r(n,r){z(`hookId`,n);let i=await H(e,`hooks`,n,N,t);if(!i){let i=await yn(e,n,t);if(!i)throw new d(n);let a=r?.resolveData||`all`;return cn({...i,isWebhook:i.isWebhook??!0},a)}let a=r?.resolveData||`all`;return cn({...i,isWebhook:i.isWebhook??!0},a)}async function i(r){let i=await n(r)??await vn(e,r,t);if(!i)throw new d(r);return i}async function a(t){let n=R.join(e,`hooks`),r=t.resolveData||`all`,i=await Y({directory:n,schema:N,sortOrder:t.pagination?.sortOrder??`asc`,limit:t.pagination?.limit,cursor:t.pagination?.cursor,filePrefix:void 0,filter:e=>!(t.runId&&e.runId!==t.runId),getCreatedAt:()=>null,getId:e=>e.hookId});return{...i,data:i.data.map(e=>cn(e,r))}}return{get:r,getByToken:i,list:a}}async function xn(e,t){let n=R.join(e,`hooks`),r=await rt(n);for(let i of r){let r=R.join(n,`${i}.json`),a=await K(r,N);a&&a.runId===t&&(await nn(e,a.token,a.runId,a.hookId),await q(rn(e,a.token,a.runId,a.hookId)),await q(r))}}async function Sn(e,t,n,r,i){z(`runId`,t);let a=i?.resolveData??`all`;switch(n.eventType){case`run_cancelled`:{let n=new Date,i={runId:r.runId,deploymentId:r.deploymentId,workflowName:r.workflowName,specVersion:r.specVersion,executionContext:r.executionContext,input:r.input,createdAt:r.createdAt,expiredAt:r.expiredAt,startedAt:r.startedAt,status:`cancelled`,output:void 0,error:void 0,completedAt:n,updatedAt:n,attributes:r.attributes};return await W(B(e,`runs`,`${t}.json`),i,{overwrite:!0}),await xn(e,t),{event:void 0,run:on(i,a)}}case`wait_completed`:case`hook_received`:{let r=`evnt_${an()}`,i=new Date,o={...n,runId:t,eventId:r,createdAt:i,specVersion:5};return await W(B(e,`events`,`${`${t}-${r}`}.json`),o),{event:_(o,a)}}default:throw Error(`Event type '${n.eventType}' not supported for legacy runs (specVersion: ${r.specVersion||`undefined`}). Please upgrade 'workflow' package.`)}}const Cn=new Map;function wn(e,t){let n=Cn.get(e),r={},i=(async()=>{n&&await n.catch(()=>void 0);try{return await t()}finally{Cn.get(e)===r.task&&Cn.delete(e)}})();return r.task=i,Cn.set(e,i),i}function Tn(e,t){return{get:(async(n,r)=>{z(`runId`,n);let i=await H(e,`runs`,n,k,t);if(!i)throw new s(n);return on(i,r?.resolveData??`all`)}),list:(async t=>{let n=t?.resolveData??`all`,r=await Y({directory:R.join(e,`runs`),schema:k,fileIdFilter:t?.fileIdFilter,filter:e=>!(t?.workflowName&&e.workflowName!==t.workflowName||t?.status&&e.status!==t.status),sortOrder:t?.pagination?.sortOrder??`desc`,limit:t?.pagination?.limit,cursor:t?.pagination?.cursor,getCreatedAt:$(`wrun`),getId:e=>e.runId});return n===`none`?{...r,data:r.data.map(e=>({...e,input:void 0,output:void 0}))}:r}),experimentalSetAttributes:async(n,r,i)=>(z(`runId`,n),wn(n,async()=>{let a=await H(e,`runs`,n,k,t);if(!a)throw new s(n);try{ae(r,{existingKeys:Object.keys(a.attributes??{}),allowReservedAttributes:i?.allowReservedAttributes})}catch(e){throw e instanceof v,e}let o=x(a.attributes,r),c={...a,attributes:o,updatedAt:new Date};return await W(V(e,`runs`,n,t),c,{overwrite:!0}),{attributes:o}}))}}const En=M({hookId:w().optional(),runId:w(),eventId:w().optional()}),Dn=M({eventId:w()});async function On(e){try{return await K(e,En)}catch(e){if(e instanceof SyntaxError||e instanceof T)return null;throw e}}async function kn(e,t,n){if(t.hookId&&await en(e,t.hookId,n))return!0;let r=await H(e,`runs`,t.runId,k,n);return r?m(r.status):!0}async function An(e){try{return await K(e,Dn)}catch(e){if(e instanceof SyntaxError||e instanceof T)return null;throw e}}async function jn(e,t,n){return(await Y({directory:R.join(e,`events`),schema:y,filePrefix:`${t}-`,filter:e=>e.eventType===`hook_created`&&e.correlationId===n,limit:1,getCreatedAt:$(`evnt`),getId:e=>e.eventId})).data[0]?.eventId??null}async function Mn(e,t,n,r,i){let a=await H(e,`events`,`${t}-${r}`,y,i);if(!a||a.eventType!==`hook_created`||a.correlationId!==n||await H(e,`hooks`,n,N,i))return;let o=a.eventData??{};if(typeof o.token!=`string`)return;let s={runId:t,hookId:n,token:o.token,metadata:o.metadata,ownerId:`local-owner`,projectId:`local-project`,environment:`local`,createdAt:a.createdAt,specVersion:a.specVersion,isWebhook:o.isWebhook??!0,isSystem:o.isSystem??!1};await J(V(e,`hooks`,n,i),JSON.stringify(s,U,2))}async function Nn(e,t,n,r,i){let a=rn(e,t,n,r);return await J(a,JSON.stringify({eventId:i}))?i:(await An(a))?.eventId??null}function Pn(e,t,n){let r=e.get(t),i={},a=(async()=>{r&&await r.catch(()=>void 0);try{return await n()}finally{e.get(t)===i.task&&e.delete(t)}})();return i.task=a,e.set(t,a),a}async function Fn(e,t){let n=R.join(e,`waits`),r=await rt(n);for(let e of r)e.startsWith(`${t}-`)&&await q(R.join(n,`${e}.json`))}async function In(e,t,n,r){return wn(t,async()=>{let i=await K(V(e,`runs`,t,n),k),a={...r,attributes:i?.attributes??r.attributes};return await W(V(e,`runs`,t,n),a,{overwrite:!0}),a})}function Ln(e,t){let n=4*1024*1024,r=new Map,i=new Map,a=new Map,o=0;function v(e){let t=r.get(e);if(!t)return;r.delete(e),o-=i.get(e)??0,i.delete(e);let n=a.get(t.runId);n?.delete(e),n?.size===0&&a.delete(t.runId)}function S(e){for(let t of a.get(e)??[])v(t)}function C(){r.clear(),i.clear(),a.clear(),o=0}function w(e,t,s){if(s>n)return;for(;r.size>0&&(r.size>=1e3||o+s>n);){let e=r.keys().next().value;v(e)}r.set(e,t),i.set(e,s),o+=s;let c=a.get(t.runId)??new Set;c.add(e),a.set(t.runId,c)}function T(e,t,r){if(b(e.eventType)){S(e.runId);return}let i=Buffer.byteLength(r);if(i>n)return;let a=y.safeParse(JSON.parse(r,et));a.success&&w(t,a.data,i)}async function E(n){let r=V(e,`events`,`${n.runId}-${n.eventId}`,t),i=JSON.stringify(n,U,2);await G(r,i),T(n,r,i)}let D=new Map,O=new Map;return{clearCache:C,async create(n,i,a){if(n!=null&&n!==``&&z(`runId`,n),`correlationId`in i&&typeof i.correlationId==`string`&&z(`correlationId`,i.correlationId),(i.eventType===`step_created`||i.eventType===`step_started`||i.eventType===`step_completed`||i.eventType===`step_failed`||i.eventType===`step_retrying`)&&n&&i.correlationId)return Pn(D,t?`${n}-${i.correlationId}.${t}`:`${n}-${i.correlationId}`,()=>o());if((i.eventType===`hook_created`||i.eventType===`hook_received`||i.eventType===`hook_disposed`)&&n&&i.correlationId)return Pn(O,t?`${n}-${i.correlationId}.hook.${t}`:`${n}-${i.correlationId}.hook`,()=>o());return o();async function o(){let o=`evnt_${an()}`,v=new Date,b;if(i.eventType===`run_created`&&(!n||n===``))b=`wrun_${an()}`;else if(n)b=n;else throw Error(`runId is required for non-run_created events`);if(i.eventType===`run_created`&&n&&n!==``){let e=re(b,`wrun_`);if(e)throw new c(e)}let S=i.specVersion??5,C=null;if(i.eventType!==`run_created`&&![`step_completed`,`step_retrying`].includes(i.eventType)&&(C=await H(e,`runs`,b,k,t),i.eventType===`run_started`&&!C&&`eventData`in i&&i.eventData)){let n=i.eventData;if(n.deploymentId&&n.workflowName&&n.input!==void 0){ae(Object.entries(n.attributes??{}).map(([e,t])=>({key:e,value:t})),{allowReservedAttributes:n.allowReservedAttributes===!0});let r={runId:b,deploymentId:n.deploymentId,status:`pending`,workflowName:n.workflowName,specVersion:S,executionContext:n.executionContext,input:n.input,output:void 0,error:void 0,startedAt:void 0,completedAt:void 0,attributes:n.attributes??{},createdAt:v,updatedAt:v};if(await J(V(e,`runs`,b,t),JSON.stringify(r,U))){let e=`evnt_${an()}`;await E({eventType:`run_created`,runId:b,eventId:e,createdAt:v,specVersion:S,eventData:{deploymentId:n.deploymentId,workflowName:n.workflowName,input:n.input,executionContext:n.executionContext,attributes:n.attributes,allowReservedAttributes:n.allowReservedAttributes}}),C=r}else C=await H(e,`runs`,b,k,t)}}if(i.eventType===`run_failed`&&!C||i.eventType===`attr_set`&&!C)throw new s(b);if(C){if(ie(C.specVersion))throw new p(C.specVersion,5);if(ne(C.specVersion))return Sn(e,b,i,C,a)}let w=i.eventType===`step_started`&&`eventData`in i&&!!i.eventData&&typeof i.eventData.stepName==`string`&&i.eventData.input!==void 0;if(C&&m(C.status)){let e=[`run_started`,`run_completed`,`run_failed`];if(i.eventType===`run_cancelled`&&C.status===`cancelled`){let e={...i,runId:b,eventId:o,createdAt:v,specVersion:S};return await E(e),{event:_(e,a?.resolveData??`all`),run:C}}if(i.eventType===`run_started`)throw new u(`Workflow run "${b}" is already in terminal state "${C.status}"`);if(e.includes(i.eventType)||i.eventType===`run_cancelled`)throw new f(`Cannot transition run from terminal state "${C.status}"`);if(i.eventType===`step_created`||i.eventType===`hook_created`||i.eventType===`wait_created`||w)throw new f(`Cannot create new entities on run in terminal state "${C.status}"`);if(i.eventType===`attr_set`)throw new f(`Cannot set attributes on run in terminal state "${C.status}"`)}let D=null;if([`step_started`,`step_completed`,`step_failed`,`step_retrying`].includes(i.eventType)&&i.correlationId){if(D=await H(e,`steps`,`${b}-${i.correlationId}`,g,t),!D&&!w)throw new c(`Step "${i.correlationId}" not found`);if(w&&D)throw new f(`Step "${i.correlationId}" already created`);if(D){if(h(D.status))throw new f(`Cannot modify step in terminal state "${D.status}"`);if(C&&m(C.status)&&D.status!==`running`)throw new u(`Cannot modify non-running step on run in terminal state "${C.status}"`)}}if([`hook_disposed`,`hook_received`].includes(i.eventType)&&i.correlationId&&(i.eventType===`hook_received`&&await en(e,i.correlationId,t)||!await H(e,`hooks`,i.correlationId,N,t)))throw new d(i.correlationId);let O={...i,runId:b,eventId:o,createdAt:v,specVersion:S};if(i.eventType===`run_started`&&`eventData`in O&&delete O.eventData,w&&`eventData`in O&&O.eventData){let{input:e,...t}=O.eventData;O.eventData=t}let A,j,M,P,oe=!1,se;if(i.eventType===`run_created`&&`eventData`in i){let n=i.eventData;if(ae(Object.entries(n.attributes??{}).map(([e,t])=>({key:e,value:t})),{allowReservedAttributes:n.allowReservedAttributes===!0}),A={runId:b,deploymentId:n.deploymentId,status:`pending`,workflowName:n.workflowName,specVersion:S,executionContext:n.executionContext,input:n.input,output:void 0,error:void 0,startedAt:void 0,completedAt:void 0,attributes:n.attributes??{},createdAt:v,updatedAt:v},!await J(V(e,`runs`,b,t),JSON.stringify(A,U,2)))throw new f(`Workflow run "${b}" already exists`)}else if(i.eventType===`run_started`){if(C){if(C.status===`running`)return{run:C};A=await In(e,b,t,{runId:C.runId,deploymentId:C.deploymentId,workflowName:C.workflowName,specVersion:C.specVersion,executionContext:C.executionContext,input:C.input,createdAt:C.createdAt,expiredAt:C.expiredAt,status:`running`,output:void 0,error:void 0,completedAt:void 0,startedAt:C.startedAt??v,updatedAt:v,attributes:C.attributes})}}else if(i.eventType===`run_completed`&&`eventData`in i){let n=i.eventData;C&&(A=await In(e,b,t,{runId:C.runId,deploymentId:C.deploymentId,workflowName:C.workflowName,specVersion:C.specVersion,executionContext:C.executionContext,input:C.input,createdAt:C.createdAt,expiredAt:C.expiredAt,startedAt:C.startedAt,status:`completed`,output:n.output,error:void 0,completedAt:v,updatedAt:v,attributes:C.attributes}),await Promise.all([xn(e,b),Fn(e,b)]))}else if(i.eventType===`run_failed`&&`eventData`in i){let n=i.eventData;C&&(A=await In(e,b,t,{runId:C.runId,deploymentId:C.deploymentId,workflowName:C.workflowName,specVersion:C.specVersion,executionContext:C.executionContext,input:C.input,createdAt:C.createdAt,expiredAt:C.expiredAt,startedAt:C.startedAt,status:`failed`,output:void 0,error:n.error,errorCode:n.errorCode,completedAt:v,updatedAt:v,attributes:C.attributes}),await Promise.all([xn(e,b),Fn(e,b)]))}else if(i.eventType===`run_cancelled`)C&&(A=await In(e,b,t,{runId:C.runId,deploymentId:C.deploymentId,workflowName:C.workflowName,specVersion:C.specVersion,executionContext:C.executionContext,input:C.input,createdAt:C.createdAt,expiredAt:C.expiredAt,startedAt:C.startedAt,status:`cancelled`,output:void 0,error:void 0,completedAt:v,updatedAt:v,attributes:C.attributes}),await Promise.all([xn(e,b),Fn(e,b)]));else if(i.eventType===`attr_set`&&C)A=await wn(b,async()=>{let n=await K(V(e,`runs`,b,t),k);if(!n)throw new s(b);if(ae(i.eventData.changes,{existingKeys:Object.keys(n.attributes),allowReservedAttributes:i.eventData.allowReservedAttributes===!0}),i.correlationId&&i.eventData.writer.type===`workflow`&&!await J(B(e,`.locks`,`attributes`,t?`${b}-${i.correlationId}.created.${t}`:`${b}-${i.correlationId}.created`),``))throw new f(`Attribute event "${i.correlationId}" already exists`);let r={...n,attributes:x(n.attributes,i.eventData.changes),updatedAt:v};return await W(V(e,`runs`,b,t),r,{overwrite:!0}),r});else if(i.eventType===`step_created`&&`eventData`in i){if(!await J(B(e,`.locks`,`steps`,t?`${b}-${i.correlationId}.created.${t}`:`${b}-${i.correlationId}.created`),``))throw new f(`Step "${i.correlationId}" already created`);let n=i.eventData;j={runId:b,stepId:i.correlationId,stepName:n.stepName,status:`pending`,input:n.input,output:void 0,error:void 0,attempt:0,startedAt:void 0,completedAt:void 0,createdAt:v,updatedAt:v,specVersion:S},await W(V(e,`steps`,`${b}-${i.correlationId}`,t),j)}else if(i.eventType===`step_started`){if(!D&&w){let n=i.eventData;if(await J(B(e,`.locks`,`steps`,t?`${b}-${i.correlationId}.created.${t}`:`${b}-${i.correlationId}.created`),``)){let r={runId:b,stepId:i.correlationId,stepName:n.stepName,status:`pending`,input:n.input,output:void 0,error:void 0,attempt:0,startedAt:void 0,completedAt:void 0,createdAt:v,updatedAt:v,specVersion:S};await W(V(e,`steps`,`${b}-${i.correlationId}`,t),r);let a=`evnt_${an()}`,o={eventType:`step_created`,runId:b,eventId:a,createdAt:v,specVersion:S,correlationId:i.correlationId,eventData:{stepName:n.stepName,input:n.input}};await W(V(e,`events`,`${b}-${a}`,t),o),D=r,oe=!0}else throw new f(`Step "${i.correlationId}" already created`)}if(D){if(D.retryAfter&&D.retryAfter.getTime()>Date.now())throw new l(`Cannot start step "${i.correlationId}": retryAfter timestamp has not been reached yet`,{retryAfter:Math.ceil((D.retryAfter.getTime()-Date.now())/1e3)});let n=`${b}-${i.correlationId}`,r=await H(e,`steps`,n,g,t);if(r&&h(r.status))throw new f(`Cannot modify step in terminal state "${r.status}"`);j={...D,status:`running`,startedAt:D.startedAt??v,attempt:D.attempt+1,retryAfter:void 0,updatedAt:v},await W(V(e,`steps`,n,t),j,{overwrite:!0})}}else if(i.eventType===`step_completed`&&`eventData`in i){let n=i.eventData;if(D){let r=`${b}-${i.correlationId}`;if(!await J(B(e,`.locks`,`steps`,t?`${r}.terminal.${t}`:`${r}.terminal`),``))throw new f(`Cannot modify step in terminal state`);j={...D,status:`completed`,output:n.result,completedAt:v,updatedAt:v},await W(V(e,`steps`,r,t),j,{overwrite:!0})}}else if(i.eventType===`step_failed`&&`eventData`in i){let n=i.eventData;if(D){let r=`${b}-${i.correlationId}`;if(!await J(B(e,`.locks`,`steps`,t?`${r}.terminal.${t}`:`${r}.terminal`),``))throw new f(`Cannot modify step in terminal state`);j={...D,status:`failed`,error:n.error,completedAt:v,updatedAt:v},await W(V(e,`steps`,r,t),j,{overwrite:!0})}}else if(i.eventType===`step_retrying`&&`eventData`in i){let n=i.eventData;if(D){let r=`${b}-${i.correlationId}`;j={...D,status:`pending`,error:n.error,retryAfter:n.retryAfter,updatedAt:v},await W(V(e,`steps`,r,t),j,{overwrite:!0})}}else if(i.eventType===`hook_created`&&`eventData`in i){let n=i.eventData,r=tn(e,n.token),s=JSON.stringify({token:n.token,hookId:i.correlationId,runId:b,eventId:o}),c=!1,l=null,u=0,d=0;for(let a=0;a<10&&(await On(r)||await vn(e,n.token,t),c=await J(r,s),!c);a++){if(l=await On(r),!l){d++,d>=3&&await q(r);continue}if(l.runId===b&&l.hookId===i.correlationId||!await kn(e,l,t))break;u++,u<3?await new Promise(e=>setTimeout(e,10)):(await q(r),l.hookId&&(await q(V(e,`hooks`,l.hookId,t)),await q(rn(e,n.token,l.runId,l.hookId)))),l=null}let p=!1;if(!c)if(l?.runId===b&&l.hookId===i.correlationId){let r;if(l.eventId)r=l.eventId;else{let a=await jn(e,b,i.correlationId);if(a!==null)throw await Mn(e,b,i.correlationId,a,t),new f(`Hook "${i.correlationId}" already created`);let s=await Nn(e,n.token,b,i.correlationId,o);if(s===null)throw new f(`Hook "${i.correlationId}" already created`);r=s}o=r;let a=te(o.replace(/^evnt_/,``))??v;O={...i,runId:b,eventId:o,createdAt:a,specVersion:S},p=!0}else{let e={eventType:`hook_conflict`,correlationId:i.correlationId,eventData:{token:n.token,...l?{conflictingRunId:l.runId}:{}},runId:b,eventId:o,createdAt:v,specVersion:S};return await E(e),{event:_(e,a?.resolveData??`all`),run:A,step:j,hook:void 0}}M={runId:b,hookId:i.correlationId,token:n.token,metadata:n.metadata,ownerId:`local-owner`,projectId:`local-project`,environment:`local`,createdAt:O.createdAt,specVersion:S,isWebhook:n.isWebhook??!1,isSystem:n.isSystem??!1},se=p?{overwrite:!0}:void 0}else if(i.eventType===`hook_disposed`){if(!await J($t(e,i.correlationId,t),``))throw new f(`Hook "${i.correlationId}" already disposed`);let n=V(e,`hooks`,i.correlationId,t),r=await H(e,`hooks`,i.correlationId,N,t);r&&(await nn(e,r.token,r.runId,r.hookId),await q(rn(e,r.token,r.runId,r.hookId))),await q(n)}else if(i.eventType===`wait_created`&&`eventData`in i){let n=`${b}-${i.correlationId}`;if(!await J(B(e,`.locks`,`waits`,t?`${n}.created.${t}`:`${n}.created`),``))throw new f(`Wait "${i.correlationId}" already exists`);let r=i.eventData;P={waitId:n,runId:b,status:`waiting`,resumeAt:r.resumeAt,completedAt:void 0,createdAt:v,updatedAt:v,specVersion:S},await W(V(e,`waits`,n,t),P)}else if(i.eventType===`wait_completed`){let n=`${b}-${i.correlationId}`,r=B(e,`.locks`,`waits`,t?`${n}.completed.${t}`:`${n}.completed`);if(!await J(r,``))throw new f(`Wait "${i.correlationId}" already completed`);let a=await H(e,`waits`,n,ee,t);if(!a)throw await I.unlink(r).catch(()=>{}),new c(`Wait "${i.correlationId}" not found`);P={...a,status:`completed`,completedAt:v,updatedAt:v},await W(V(e,`waits`,n,t),P,{overwrite:!0})}if(i.eventType===`hook_received`&&i.correlationId&&await en(e,i.correlationId,t))throw new d(i.correlationId);let ce=V(e,`events`,`${b}-${o}`,t),F=JSON.stringify(O,U,2);if(!await J(ce,F))throw i.eventType===`hook_created`&&i.correlationId&&await Mn(e,b,i.correlationId,o,t),new f(`Event "${o}" already exists for run "${b}"`);T(O,ce,F),M&&i.eventType===`hook_created`&&await W(V(e,`hooks`,M.hookId,t),M,se);let le=a?.resolveData??`all`,ue=_(O,le),de,L,fe;if(i.eventType===`run_started`&&A){let t=await Y({directory:R.join(e,`events`),schema:y,cachedItems:r,filePrefix:`${b}-`,sortOrder:`asc`,limit:1e3,getCreatedAt:$(`evnt`),getId:e=>e.eventId});de=t.data,L=t.cursor,fe=t.hasMore}if((i.eventType===`step_completed`||i.eventType===`step_failed`)&&typeof a?.sinceCursor==`string`){let t=await Y({directory:R.join(e,`events`),schema:y,filePrefix:`${b}-`,sortOrder:`asc`,cursor:a.sinceCursor,getCreatedAt:$(`evnt`),getId:e=>e.eventId});de=le===`none`?t.data.map(e=>_(e,le)):t.data,L=t.cursor,fe=t.hasMore}return{event:ue,run:A,step:j,hook:M,wait:P,events:de,cursor:L,hasMore:fe,...oe?{stepCreated:!0}:{}}}},async get(n,r,i){z(`runId`,n),z(`eventId`,r);let a=await H(e,`events`,`${n}-${r}`,y,t);if(!a)throw Error(`Event ${r} in run ${n} not found`);return _(a,i?.resolveData??`all`)},async list(t){let{runId:n}=t;z(`runId`,n);let i=t.resolveData??`all`,a=await Y({directory:R.join(e,`events`),schema:y,cachedItems:r,filePrefix:`${n}-`,sortOrder:t.pagination?.sortOrder??`asc`,limit:t.pagination?.limit,cursor:t.pagination?.cursor,getCreatedAt:$(`evnt`),getId:e=>e.eventId});return i===`none`?{...a,data:a.data.map(e=>_(e,i))}:a},async listByCorrelationId(t){let n=t.correlationId;z(`correlationId`,n);let i=t.resolveData??`all`,a=await Y({directory:R.join(e,`events`),schema:y,cachedItems:r,filter:e=>e.correlationId===n,sortOrder:t.pagination?.sortOrder??`asc`,limit:t.pagination?.limit,cursor:t.pagination?.cursor,getCreatedAt:$(`evnt`),getId:e=>e.eventId});return i===`none`?{...a,data:a.data.map(e=>_(e,i))}:a}}}function Rn(e,t){return{get:(async(n,r,i)=>{z(`runId`,n),z(`stepId`,r);let a=await H(e,`steps`,`${n}-${r}`,g,t);if(!a)throw Error(`Step ${r} in run ${n} not found`);return sn(a,i?.resolveData??`all`)}),list:(async t=>{z(`runId`,t.runId);let n=t.resolveData??`all`,r=await Y({directory:R.join(e,`steps`),schema:g,filePrefix:`${t.runId}-`,sortOrder:t.pagination?.sortOrder??`desc`,limit:t.pagination?.limit,cursor:t.pagination?.cursor,getCreatedAt:$(`step`),getId:e=>e.stepId});return n===`none`?{...r,data:r.data.map(e=>({...e,input:void 0,output:void 0}))}:r})}}function zn(e,t){let n=Tn(e,t),r=Rn(e,t),i=Ln(e,t),a=bn(e,t);return{runs:Vt(`world.runs`,n),steps:Vt(`world.steps`,r),events:Vt(`world.events`,i),hooks:Vt(`world.hooks`,a),clearCache:()=>i.clearCache()}}const Bn=E(()=>Math.random()),Vn=M({streams:C(w())});function Hn(e){return e===1}function Un(e){let t=Buffer.from([+!!e.eof]);return Buffer.concat([t,e.chunk])}function Wn(e){return Hn(e[0])}function Gn(e){return{eof:Wn(e),chunk:Buffer.from(e.subarray(1))}}async function Kn(e){try{return await I.readdir(e)}catch(e){if(e.code===`ENOENT`)return[];throw e}}function qn(e,t,n,r=n,i=()=>!0){for(let a of t){if(!a.endsWith(n))continue;let t=a.slice(0,-n.length);i(t)&&e.set(t,r)}}function Jn(e,t){return z(`streamName`,t),R.join(e,t)}async function Yn(e,t,n){let r=Jn(e,t),i=await Kn(r),a=new Map;return qn(a,i,`.json`),qn(a,i,`.bin`,`.bin`,n?e=>!e.endsWith(`.${n}`):void 0),n&&qn(a,i,`.${n}.bin`),{files:[...a.keys()].sort(),extMap:a,dir:r}}function Xn(e,t){let n=t?`.${t}`:``,r=new ye,i=new Set;async function a(n,r){z(`runId`,n),z(`streamName`,r);let a=`${n}:${r}`;if(i.has(a))return;let o=V(e,`streams/runs`,n,t),s=(await H(e,`streams/runs`,n,Vn,t))?.streams??[];s.includes(r)||(s.push(r),await W(o,{streams:s},{overwrite:!0})),i.add(a)}function o(e){return typeof e==`string`?Buffer.from(new TextEncoder().encode(e)):e instanceof Buffer?e:Buffer.from(e)}return{streams:{async write(t,i,s){let c=`chnk_${Bn()}`;await a(await t,i);let l=o(s),u=Un({chunk:l,eof:!1});await G(R.join(Jn(R.join(e,`streams`,`chunks`),i),`${c}${n}.bin`),u);let d=Uint8Array.from(l);r.emit(`chunk:${i}`,{streamName:i,chunkData:d,chunkId:c})},async writeMulti(t,i,s){if(s.length===0)return;let c=s.map(()=>`chnk_${Bn()}`);await a(await t,i);let l=s.map(e=>o(e)).map(async(t,r)=>{let a=c[r],o=Un({chunk:t,eof:!1});return await G(R.join(Jn(R.join(e,`streams`,`chunks`),i),`${a}${n}.bin`),o),{chunkId:a,chunkData:Uint8Array.from(t)}});for(let e of l){let{chunkId:t,chunkData:n}=await e;r.emit(`chunk:${i}`,{streamName:i,chunkData:n,chunkId:t})}},async close(t,i){let o=`chnk_${Bn()}`;await a(await t,i),await G(R.join(Jn(R.join(e,`streams`,`chunks`),i),`${o}${n}.bin`),Un({chunk:Buffer.from([]),eof:!0})),r.emit(`close:${i}`,{streamName:i})},async list(n){return z(`runId`,n),(await H(e,`streams/runs`,n,Vn,t))?.streams??[]},async getChunks(n,r,i){let a=i?.limit??100,{files:o,extMap:s,dir:c}=await Yn(R.join(e,`streams`,`chunks`),r,t),l=0;if(i?.cursor)try{l=JSON.parse(Buffer.from(i.cursor,`base64`).toString(`utf-8`)).i}catch{l=0}let u=!1,d=[],f=0;for(let e of o){let t=s.get(e)??`.bin`,n=R.join(c,`${e}${t}`);if(f<l){if(Hn(await nt(n))){u=!0;break}f++;continue}if(d.length>=a){Hn(await nt(n))?u=!0:f++;break}let r=Gn(await tt(n));if(r.eof){u=!0;break}d.push({index:f,data:Uint8Array.from(r.chunk)}),f++}let p=!u&&f>l+d.length,m=l+d.length;return{data:d,cursor:p?Buffer.from(JSON.stringify({i:m})).toString(`base64`):null,hasMore:p,done:u}},async getInfo(n,r){let{files:i,extMap:a,dir:o}=await Yn(R.join(e,`streams`,`chunks`),r,t),s=!1,c=0;for(let e of i){let t=a.get(e)??`.bin`;if(Hn(await nt(R.join(o,`${e}${t}`)))){s=!0;break}c++}return{tailIndex:c-1,done:s}},async get(n,i,a=0){let o=R.join(e,`streams`,`chunks`),s=()=>{},c=null,l=!1;return new ReadableStream({async start(e){let n=new Set,u=[],d=!0,f=!1,p=t=>{if(t.chunkData.byteLength===0){n.add(t.chunkId);return}d?(n.add(t.chunkId),u.push({chunkId:t.chunkId,chunkData:Uint8Array.from(t.chunkData)})):n.has(t.chunkId)||(n.add(t.chunkId),e.enqueue(Uint8Array.from(t.chunkData)))},m=()=>{if(d){f=!0;return}l=!0,s();try{e.close()}catch{}};s=()=>{r.off(`chunk:${i}`,p),r.off(`close:${i}`,m),c&&=(clearInterval(c),null)},r.on(`chunk:${i}`,p),r.on(`close:${i}`,m);let{files:h,extMap:g,dir:_}=await Yn(o,i,t),v=h.length;if(typeof a==`number`&&a<0&&h.length>0){let e=h[h.length-1],t=g.get(e)??`.bin`;Hn(await nt(R.join(_,`${e}${t}`)))&&v--}let y=typeof a==`number`&&a<0?Math.max(0,v+a):a,b=!1;for(let t=y;t<h.length;t++){let r=h[t],i=r;if(n.has(i))continue;let a=g.get(r)??`.bin`,o=Gn(await tt(R.join(_,`${r}${a}`)));if(o?.eof===!0){b=!0;break}n.add(i),o.chunk.byteLength&&e.enqueue(Uint8Array.from(o.chunk))}d=!1,u.sort((e,t)=>e.chunkId.localeCompare(t.chunkId));for(let t of u)e.enqueue(Uint8Array.from(t.chunkData));if(b){l=!0,s();try{e.close()}catch{}return}if(f){l=!0,s();try{e.close()}catch{}return}for(let e=0;e<y&&e<h.length;e++)n.add(h[e]);if(l){s();return}let x=!1;c=setInterval(async()=>{if(!x){x=!0;try{let{files:r,extMap:a}=await Yn(o,i,t);for(let t of r){let r=t;if(n.has(r))continue;n.add(r);let i=a.get(t)??`.bin`,o=Gn(await tt(R.join(_,`${t}${i}`)));if(o?.eof===!0){l=!0,s();try{e.close()}catch{}return}if(l)return;o.chunk.byteLength&&e.enqueue(Uint8Array.from(o.chunk))}}catch(e){e instanceof Error&&`code`in e||console.error(`[world-local] Unexpected polling error:`,e)}finally{x=!1}}},100)},cancel(){l=!0,s()}})}}}}function Zn(e){let t=e?Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0)):{},n={...Fe.value,...t},r=n.tag,i=Zt(n),{clearCache:a,...o}=zn(n.dataDir,r),s=n.recoverActiveRuns??!0;return{specVersion:5,...i,...o,...Vt(`world.streams`,{...Xn(n.dataDir,r),...n.streamFlushIntervalMs!==void 0&&{streamFlushIntervalMs:n.streamFlushIntervalMs}}),async start(){if(await bt(n.dataDir),!s)return;let e=r?e=>Je(e,r):Ye;await A({...o.runs,list:(t=>o.runs.list({...t,fileIdFilter:e}))},i.queue,`world-local`)},async close(){a(),await i.close()},async clear(){if(a(),r){let e=n.dataDir,t=R.join(e,`hooks`),i=await Xe(t,r),{HookSchema:a}=await import(`../../_chunks/workflow/dist-DJU_7R9s.js`).then(e=>e.t);await Promise.all(i.map(async n=>{let r=await K(R.join(t,n),a);r?.token&&(await q(R.join(t,`tokens`,`${Qt(r.token)}.json`)),await q(rn(e,r.token,r.runId,r.hookId)))})),await Promise.all([`runs`,`steps`,`events`,`hooks`,`waits`,`streams/runs`].map(async t=>{let n=R.join(e,t),i=await Xe(n,r);await Promise.all(i.map(e=>q(R.join(n,e))))})),await F.rm(R.join(e,`.locks`),{recursive:!0,force:!0}).catch(()=>{});let o=R.join(e,`streams`,`chunks`),s;try{s=await F.readdir(o,{withFileTypes:!0})}catch{s=[]}await Promise.all(s.filter(e=>e.isDirectory()).map(async e=>{let t=R.join(o,e.name),n=await Ze(t,r,`.bin`);await Promise.all(n.map(e=>F.unlink(R.join(t,e)).catch(()=>{})))})),Ge()}else Ge(),await me(n.dataDir,{recursive:!0,force:!0}),await bt(n.dataDir)}}}function Qn(e){return Zn(e)}export{ut as DataDirAccessError,dt as DataDirVersionError,Qn as createLocalWorld,Zn as createWorld,gt as ensureDataDir,bt as initDataDir,ft as parseVersion};
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
<http://www.apache.org/licenses/>
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2025 Vercel Inc.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|