eve 0.27.11 → 0.27.13
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 +16 -0
- package/dist/src/chunks/{use-eve-agent-CTJrwXM2.js → use-eve-agent-CWYe-vqE.js} +29 -18
- package/dist/src/chunks/{use-eve-agent-DaWxEtnE.js → use-eve-agent-CsSQOKnp.js} +29 -18
- package/dist/src/cli/commands/channels.js +1 -1
- package/dist/src/cli/commands/integration-setup.js +1 -1
- package/dist/src/cli/commands/register-registry-commands.js +1 -1
- package/dist/src/cli/commands/registry-setup-command.d.ts +5 -3
- package/dist/src/cli/commands/registry-setup-command.js +1 -1
- package/dist/src/cli/commands/registry.d.ts +9 -3
- package/dist/src/cli/commands/registry.js +1 -1
- package/dist/src/cli/dev/tui/remote-connection-probe.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/target.d.ts +3 -15
- package/dist/src/cli/dev/tui/tui.js +1 -1
- package/dist/src/cli/invoke/command.d.ts +32 -0
- package/dist/src/cli/invoke/command.js +1 -0
- package/dist/src/cli/invoke/invoke.d.ts +27 -0
- package/dist/src/cli/invoke/invoke.js +1 -0
- package/dist/src/cli/invoke/result.d.ts +313 -0
- package/dist/src/cli/invoke/result.js +1 -0
- package/dist/src/cli/run.d.ts +2 -0
- package/dist/src/cli/run.js +3 -3
- package/dist/src/client/client.js +1 -1
- package/dist/src/client/message-response.js +1 -1
- package/dist/src/client/session-utils.d.ts +21 -15
- package/dist/src/client/session-utils.js +1 -1
- package/dist/src/client/session.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +5 -5
- package/dist/src/compiled/@workflow/core/capabilities.d.ts +6 -0
- package/dist/src/compiled/@workflow/core/encryption.d.ts +15 -2
- package/dist/src/compiled/@workflow/core/flushable-stream.d.ts +26 -0
- package/dist/src/compiled/@workflow/core/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/private.d.ts +76 -33
- package/dist/src/compiled/@workflow/core/private.js +1 -1
- package/dist/src/compiled/@workflow/core/replay-payload-cache.d.ts +3 -2
- package/dist/src/compiled/@workflow/core/runtime/count-step-started-events.d.ts +52 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +41 -12
- package/dist/src/compiled/@workflow/core/runtime/resume-hook.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/runtime/step-executor.d.ts +9 -8
- package/dist/src/compiled/@workflow/core/runtime/world.d.ts +2 -7
- package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +3 -3
- package/dist/src/compiled/@workflow/core/sealed-box.d.ts +167 -0
- package/dist/src/compiled/@workflow/core/serialization/client.d.ts +3 -3
- package/dist/src/compiled/@workflow/core/serialization/codec.d.ts +6 -4
- package/dist/src/compiled/@workflow/core/serialization/encryption.d.ts +118 -17
- package/dist/src/compiled/@workflow/core/serialization/step.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +20 -0
- package/dist/src/compiled/@workflow/core/serialization-format.d.ts +44 -4
- package/dist/src/compiled/@workflow/core/serialization.d.ts +21 -21
- package/dist/src/compiled/@workflow/core/set-attributes.d.ts +2 -7
- package/dist/src/compiled/@workflow/core/step/context-storage.d.ts +2 -2
- package/dist/src/compiled/@workflow/core/symbols.d.ts +23 -10
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +4 -4
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/abort-controller.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow/set-attributes.d.ts +0 -9
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/errors/index.d.ts +1 -1
- package/dist/src/compiled/@workflow/world/events.d.ts +5 -0
- package/dist/src/compiled/@workflow/world/hooks.d.ts +27 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +2 -2
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +8 -6
- package/dist/src/compiled/@workflow/world/queue.d.ts +30 -26
- package/dist/src/compiled/@workflow/world/runs.d.ts +5 -0
- package/dist/src/compiled/@workflow/world/spec-version.d.ts +3 -4
- package/dist/src/compiled/@workflow/world-local/index.js +4 -4
- package/dist/src/compiled/@workflow/world-vercel/index.js +5 -5
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-B6ltn-ph.js → attribute-changes-DeZc2RZz.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/{dist-D7ANgxe0.js → dist-WjtNsOyf.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/private-Cre8uYkA.js +1 -0
- package/dist/src/compiled/_chunks/workflow/resume-hook-ip1hbn1b.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-CWytxfIp.js +1 -0
- package/dist/src/compiled/_chunks/workflow/sleep-BjrUxUcs.js +1 -0
- package/dist/src/compiled/_chunks/workflow/wait-until-De9yESQN.js +15 -0
- package/dist/src/compiled/_chunks/workflow/{workflow-routes-Pd-WKcx_.js → workflow-routes-CwqB063q.js} +1 -1
- package/dist/src/evals/cli/eval-client.js +1 -1
- package/dist/src/evals/session.js +1 -1
- package/dist/src/execution/web-fetch/request.js +1 -1
- package/dist/src/internal/application/compiled-artifacts.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/node-esm-compat-banner.js +1 -1
- package/dist/src/internal/workflow/builtins.d.ts +2 -2
- package/dist/src/internal/workflow/development-world-protocol.js +1 -1
- package/dist/src/internal/workflow-bundle/workflow-core-shim.d.ts +5 -5
- package/dist/src/internal/workflow-bundle/workflow-core-shim.js +1 -1
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/world-target.js +1 -0
- package/dist/src/public/channels/linear/defaults.js +4 -2
- package/dist/src/runtime/attributes/emit.js +1 -1
- package/dist/src/services/dev-client/client-options.d.ts +2 -0
- package/dist/src/services/dev-client/client-options.js +1 -1
- package/dist/src/services/dev-client/target.d.ts +17 -0
- package/dist/src/services/dev-client/target.js +1 -0
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/verified-remote-client.d.ts +5 -1
- package/dist/src/setup/verified-remote-client.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/channels/linear.mdx +4 -0
- package/docs/extensions.md +3 -1
- package/docs/install-integrations.mdx +76 -1
- package/docs/reference/cli.md +28 -1
- package/package.json +8 -8
- package/dist/src/compiled/@workflow/core/runtime/step-handler.d.ts +0 -2
- package/dist/src/compiled/_chunks/workflow/private-DolBHKOQ.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-D2AqAGjq.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-BMRZ6pA-.js +0 -1
- package/dist/src/compiled/_chunks/workflow/sleep-CrgsokmG.js +0 -1
- package/dist/src/compiled/_chunks/workflow/wait-until-B-1TiJji.js +0 -15
- package/dist/src/node_modules/.pnpm/@workflow_utils@5.0.0-beta.6/node_modules/@workflow/utils/dist/world-target.js +0 -1
- /package/dist/src/node_modules/.pnpm/{@workflow_utils@5.0.0-beta.6 → @workflow_utils@5.0.0-beta.7}/node_modules/@workflow/utils/dist/index.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@workflow_utils@5.0.0-beta.6 → @workflow_utils@5.0.0-beta.7}/node_modules/@workflow/utils/dist/parse-name.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@workflow_utils@5.0.0-beta.6 → @workflow_utils@5.0.0-beta.7}/node_modules/@workflow/utils/dist/pluralize.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@workflow_utils@5.0.0-beta.6 → @workflow_utils@5.0.0-beta.7}/node_modules/@workflow/utils/dist/promise.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@workflow_utils@5.0.0-beta.6 → @workflow_utils@5.0.0-beta.7}/node_modules/@workflow/utils/dist/time.js +0 -0
- /package/dist/src/node_modules/.pnpm/{@workflow_utils@5.0.0-beta.6 → @workflow_utils@5.0.0-beta.7}/node_modules/@workflow/utils/dist/workflow-routes.js +0 -0
- /package/dist/src/{cli/dev/tui → services/dev-client}/agent-info-probe.d.ts +0 -0
- /package/dist/src/{cli/dev/tui → services/dev-client}/agent-info-probe.js +0 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import{o as e,t}from"./rolldown-runtime-DaDcL9Zw.js";import{n,o as r,r as i,s as a,t as o}from"./private-Cre8uYkA.js";import"./dist-B-vbuNqP.js";import{D as s,E as c,O as l,a as u,c as d,i as f,l as p,m,p as h,u as g}from"./dist-BeQ_csYA.js";import{d as _,g as v,n as y,o as b,v as x}from"./dist-WjtNsOyf.js";import{t as S}from"./env-config-CYoX3muK.js";import{types as ee}from"node:util";import{AsyncLocalStorage as te}from"node:async_hooks";function ne(e,t){if(typeof t!=`string`)return null;let[n,r,...i]=t.split(`//`);if(n!==e||!r||i.length===0)return null;let a=i.join(`//`),o=a.split(`/`).at(-1)??``,s=``;return s=r.startsWith(`./`)?r.split(`/`).at(-1)??``:(r.split(`@`).slice(0,-1).join(`@`)||r.split(`@`)[0])?.split(`/`).at(-1)??``,[`default`,`__default`].includes(o)&&s&&(o=s),{shortName:o,moduleSpecifier:r,functionName:a}}function re(e){return ne(`workflow`,e)}function C(e){return ne(`step`,e)}function ie(e){return le(C(e),e)}function ae(e){return le(re(e),e)}function oe(e){return re(e)?.shortName??ce(`workflow`,e)??e}function se(e){return C(e)?.shortName??ce(`step`,e)??e}function ce(e,t){if(!t.startsWith(`${e}--`))return null;let n=t.split(`--`).filter(Boolean),r=n.at(-1)?.split(`-`).filter(Boolean).at(-1)??``;if([`default`,`__default`].includes(r)){let t=n.at(-2)?.split(`-`).filter(Boolean).at(-1);t&&t!==e&&(r=t)}return r||null}function le(e,t){return e?`${e.shortName} (${e.moduleSpecifier})`:t}function w(e,t,n){return n===1?e:t}const ue=(()=>{let e=globalThis.process;return e?.env?e.env.FORCE_COLOR&&e.env.FORCE_COLOR!==`0`?!0:!e.env.NO_COLOR&&!!e.stdout?.isTTY:!1})(),T=(e,t)=>n=>ue?`\x1b[${e}m${n}\x1b[${t}m`:n,E={bold:T(1,22),dim:T(2,22),italic:T(3,23),red:T(31,39),blue:T(34,39),cyan:T(36,39),yellow:T(33,39),magenta:T(35,39)},de={info:E.blue,help:E.cyan,warn:E.yellow,error:E.red};function fe(e){let t=Array.isArray(e)?e.join(`
|
|
2
|
+
`):e;return de.info(`${E.bold(`hint:`)} ${t}`)}function pe(e){return de.info(`${E.bold(`docs:`)} ${e}`)}function me(e){return E.italic(`${E.dim("`")}${e}${E.dim("`")}`)}function D(e){return E.dim(e)}function he(e){return E.bold(e)}function ge(e){return E.red(e)}function _e(e){return E.magenta(e)}function ve(e,t){let n=[e];return t.forEach((e,r)=>{let i=e.split(`
|
|
3
|
+
`),a=r===t.length-1,o=a?`╰▶ `:`├▶ `,s=a?` `:`│ `,c=i.map((e,t)=>`${t===0?o:s}${e}`);n.push(...c)}),n.join(`
|
|
4
|
+
`)}var ye=t(((e,t)=>{t.exports={MAX_LENGTH:256,MAX_SAFE_COMPONENT_LENGTH:16,MAX_SAFE_BUILD_LENGTH:250,MAX_SAFE_INTEGER:2**53-1||9007199254740991,RELEASE_TYPES:[`major`,`premajor`,`minor`,`preminor`,`patch`,`prepatch`,`prerelease`],SEMVER_SPEC_VERSION:`2.0.0`,FLAG_INCLUDE_PRERELEASE:1,FLAG_LOOSE:2}})),be=t(((e,t)=>{t.exports=typeof process==`object`&&process.env&&process.env.NODE_DEBUG&&/\bsemver\b/i.test(process.env.NODE_DEBUG)?(...e)=>console.error(`SEMVER`,...e):()=>{}})),xe=t(((e,t)=>{let{MAX_SAFE_COMPONENT_LENGTH:n,MAX_SAFE_BUILD_LENGTH:r,MAX_LENGTH:i}=ye(),a=be();e=t.exports={};let o=e.re=[],s=e.safeRe=[],c=e.src=[],l=e.safeSrc=[],u=e.t={},d=0,f=`[a-zA-Z0-9-]`,p=[[`\\s`,1],[`\\d`,i],[f,r]],m=e=>{for(let[t,n]of p)e=e.split(`${t}*`).join(`${t}{0,${n}}`).split(`${t}+`).join(`${t}{1,${n}}`);return e},h=(e,t,n)=>{let r=m(t),i=d++;a(e,i,t),u[e]=i,c[i]=t,l[i]=r,o[i]=new RegExp(t,n?`g`:void 0),s[i]=new RegExp(r,n?`g`:void 0)};h(`NUMERICIDENTIFIER`,`0|[1-9]\\d*`),h(`NUMERICIDENTIFIERLOOSE`,`\\d+`),h(`NONNUMERICIDENTIFIER`,`\\d*[a-zA-Z-]${f}*`),h(`MAINVERSION`,`(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})\\.(${c[u.NUMERICIDENTIFIER]})`),h(`MAINVERSIONLOOSE`,`(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})\\.(${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASEIDENTIFIER`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIER]})`),h(`PRERELEASEIDENTIFIERLOOSE`,`(?:${c[u.NONNUMERICIDENTIFIER]}|${c[u.NUMERICIDENTIFIERLOOSE]})`),h(`PRERELEASE`,`(?:-(${c[u.PRERELEASEIDENTIFIER]}(?:\\.${c[u.PRERELEASEIDENTIFIER]})*))`),h(`PRERELEASELOOSE`,`(?:-?(${c[u.PRERELEASEIDENTIFIERLOOSE]}(?:\\.${c[u.PRERELEASEIDENTIFIERLOOSE]})*))`),h(`BUILDIDENTIFIER`,`${f}+`),h(`BUILD`,`(?:\\+(${c[u.BUILDIDENTIFIER]}(?:\\.${c[u.BUILDIDENTIFIER]})*))`),h(`FULLPLAIN`,`v?${c[u.MAINVERSION]}${c[u.PRERELEASE]}?${c[u.BUILD]}?`),h(`FULL`,`^${c[u.FULLPLAIN]}$`),h(`LOOSEPLAIN`,`[v=\\s]*${c[u.MAINVERSIONLOOSE]}${c[u.PRERELEASELOOSE]}?${c[u.BUILD]}?`),h(`LOOSE`,`^${c[u.LOOSEPLAIN]}$`),h(`GTLT`,`((?:<|>)?=?)`),h(`XRANGEIDENTIFIERLOOSE`,`${c[u.NUMERICIDENTIFIERLOOSE]}|x|X|\\*`),h(`XRANGEIDENTIFIER`,`${c[u.NUMERICIDENTIFIER]}|x|X|\\*`),h(`XRANGEPLAIN`,`[v=\\s]*(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:\\.(${c[u.XRANGEIDENTIFIER]})(?:${c[u.PRERELEASE]})?${c[u.BUILD]}?)?)?`),h(`XRANGEPLAINLOOSE`,`[v=\\s]*(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:\\.(${c[u.XRANGEIDENTIFIERLOOSE]})(?:${c[u.PRERELEASELOOSE]})?${c[u.BUILD]}?)?)?`),h(`XRANGE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAIN]}$`),h(`XRANGELOOSE`,`^${c[u.GTLT]}\\s*${c[u.XRANGEPLAINLOOSE]}$`),h(`COERCEPLAIN`,`(^|[^\\d])(\\d{1,${n}})(?:\\.(\\d{1,${n}}))?(?:\\.(\\d{1,${n}}))?`),h(`COERCE`,`${c[u.COERCEPLAIN]}(?:$|[^\\d])`),h(`COERCEFULL`,c[u.COERCEPLAIN]+`(?:${c[u.PRERELEASE]})?(?:${c[u.BUILD]})?(?:$|[^\\d])`),h(`COERCERTL`,c[u.COERCE],!0),h(`COERCERTLFULL`,c[u.COERCEFULL],!0),h(`LONETILDE`,`(?:~>?)`),h(`TILDETRIM`,`(\\s*)${c[u.LONETILDE]}\\s+`,!0),e.tildeTrimReplace=`$1~`,h(`TILDE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAIN]}$`),h(`TILDELOOSE`,`^${c[u.LONETILDE]}${c[u.XRANGEPLAINLOOSE]}$`),h(`LONECARET`,`(?:\\^)`),h(`CARETTRIM`,`(\\s*)${c[u.LONECARET]}\\s+`,!0),e.caretTrimReplace=`$1^`,h(`CARET`,`^${c[u.LONECARET]}${c[u.XRANGEPLAIN]}$`),h(`CARETLOOSE`,`^${c[u.LONECARET]}${c[u.XRANGEPLAINLOOSE]}$`),h(`COMPARATORLOOSE`,`^${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]})$|^$`),h(`COMPARATOR`,`^${c[u.GTLT]}\\s*(${c[u.FULLPLAIN]})$|^$`),h(`COMPARATORTRIM`,`(\\s*)${c[u.GTLT]}\\s*(${c[u.LOOSEPLAIN]}|${c[u.XRANGEPLAIN]})`,!0),e.comparatorTrimReplace=`$1$2$3`,h(`HYPHENRANGE`,`^\\s*(${c[u.XRANGEPLAIN]})\\s+-\\s+(${c[u.XRANGEPLAIN]})\\s*$`),h(`HYPHENRANGELOOSE`,`^\\s*(${c[u.XRANGEPLAINLOOSE]})\\s+-\\s+(${c[u.XRANGEPLAINLOOSE]})\\s*$`),h(`STAR`,`(<|>)?=?\\s*\\*`),h(`GTE0`,`^\\s*>=\\s*0\\.0\\.0\\s*$`),h(`GTE0PRE`,`^\\s*>=\\s*0\\.0\\.0-0\\s*$`)})),Se=t(((e,t)=>{let n=Object.freeze({loose:!0}),r=Object.freeze({});t.exports=e=>e?typeof e==`object`?e:n:r})),Ce=t(((e,t)=>{let n=/^[0-9]+$/,r=(e,t)=>{if(typeof e==`number`&&typeof t==`number`)return e===t?0:e<t?-1:1;let r=n.test(e),i=n.test(t);return r&&i&&(e=+e,t=+t),e===t?0:r&&!i?-1:i&&!r?1:e<t?-1:1};t.exports={compareIdentifiers:r,rcompareIdentifiers:(e,t)=>r(t,e)}})),O=t(((e,t)=>{let n=be(),{MAX_LENGTH:r,MAX_SAFE_INTEGER:i}=ye(),{safeRe:a,t:o}=xe(),s=Se(),{compareIdentifiers:c}=Ce();t.exports=class e{constructor(t,c){if(c=s(c),t instanceof e){if(t.loose===!!c.loose&&t.includePrerelease===!!c.includePrerelease)return t;t=t.version}else if(typeof t!=`string`)throw TypeError(`Invalid version. Must be a string. Got type "${typeof t}".`);if(t.length>r)throw TypeError(`version is longer than ${r} characters`);n(`SemVer`,t,c),this.options=c,this.loose=!!c.loose,this.includePrerelease=!!c.includePrerelease;let l=t.trim().match(c.loose?a[o.LOOSE]:a[o.FULL]);if(!l)throw TypeError(`Invalid Version: ${t}`);if(this.raw=t,this.major=+l[1],this.minor=+l[2],this.patch=+l[3],this.major>i||this.major<0)throw TypeError(`Invalid major version`);if(this.minor>i||this.minor<0)throw TypeError(`Invalid minor version`);if(this.patch>i||this.patch<0)throw TypeError(`Invalid patch version`);l[4]?this.prerelease=l[4].split(`.`).map(e=>{if(/^[0-9]+$/.test(e)){let t=+e;if(t>=0&&t<i)return t}return e}):this.prerelease=[],this.build=l[5]?l[5].split(`.`):[],this.format()}format(){return this.version=`${this.major}.${this.minor}.${this.patch}`,this.prerelease.length&&(this.version+=`-${this.prerelease.join(`.`)}`),this.version}toString(){return this.version}compare(t){if(n(`SemVer.compare`,this.version,this.options,t),!(t instanceof e)){if(typeof t==`string`&&t===this.version)return 0;t=new e(t,this.options)}return t.version===this.version?0:this.compareMain(t)||this.comparePre(t)}compareMain(t){return t instanceof e||(t=new e(t,this.options)),this.major<t.major?-1:this.major>t.major?1:this.minor<t.minor?-1:this.minor>t.minor?1:this.patch<t.patch?-1:+(this.patch>t.patch)}comparePre(t){if(t instanceof e||(t=new e(t,this.options)),this.prerelease.length&&!t.prerelease.length)return-1;if(!this.prerelease.length&&t.prerelease.length)return 1;if(!this.prerelease.length&&!t.prerelease.length)return 0;let r=0;do{let e=this.prerelease[r],i=t.prerelease[r];if(n(`prerelease compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}compareBuild(t){t instanceof e||(t=new e(t,this.options));let r=0;do{let e=this.build[r],i=t.build[r];if(n(`build compare`,r,e,i),e===void 0&&i===void 0)return 0;if(i===void 0)return 1;if(e===void 0)return-1;if(e===i)continue;return c(e,i)}while(++r)}inc(e,t,n){if(e.startsWith(`pre`)){if(!t&&n===!1)throw Error(`invalid increment argument: identifier is empty`);if(t){let e=`-${t}`.match(this.options.loose?a[o.PRERELEASELOOSE]:a[o.PRERELEASE]);if(!e||e[1]!==t)throw Error(`invalid identifier: ${t}`)}}switch(e){case`premajor`:this.prerelease.length=0,this.patch=0,this.minor=0,this.major++,this.inc(`pre`,t,n);break;case`preminor`:this.prerelease.length=0,this.patch=0,this.minor++,this.inc(`pre`,t,n);break;case`prepatch`:this.prerelease.length=0,this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`prerelease`:this.prerelease.length===0&&this.inc(`patch`,t,n),this.inc(`pre`,t,n);break;case`release`:if(this.prerelease.length===0)throw Error(`version ${this.raw} is not a prerelease`);this.prerelease.length=0;break;case`major`:(this.minor!==0||this.patch!==0||this.prerelease.length===0)&&this.major++,this.minor=0,this.patch=0,this.prerelease=[];break;case`minor`:(this.patch!==0||this.prerelease.length===0)&&this.minor++,this.patch=0,this.prerelease=[];break;case`patch`:this.prerelease.length===0&&this.patch++,this.prerelease=[];break;case`pre`:{let e=+!!Number(n);if(this.prerelease.length===0)this.prerelease=[e];else{let r=this.prerelease.length;for(;--r>=0;)typeof this.prerelease[r]==`number`&&(this.prerelease[r]++,r=-2);if(r===-1){if(t===this.prerelease.join(`.`)&&n===!1)throw Error(`invalid increment argument: identifier already exists`);this.prerelease.push(e)}}if(t){let r=[t,e];n===!1&&(r=[t]),c(this.prerelease[0],t)===0?isNaN(this.prerelease[1])&&(this.prerelease=r):this.prerelease=r}break}default:throw Error(`invalid increment argument: ${e}`)}return this.raw=this.format(),this.build.length&&(this.raw+=`+${this.build.join(`.`)}`),this}}})),we=t(((e,t)=>{let n=O();t.exports=(e,t,r=!1)=>{if(e instanceof n)return e;try{return new n(e,t)}catch(e){if(!r)return null;throw e}}})),Te=t(((e,t)=>{let n=we();t.exports=(e,t)=>{let r=n(e,t);return r?r.version:null}})),Ee=t(((e,t)=>{let n=we();t.exports=(e,t)=>{let r=n(e.trim().replace(/^[=v]+/,``),t);return r?r.version:null}})),De=t(((e,t)=>{let n=O();t.exports=(e,t,r,i,a)=>{typeof r==`string`&&(a=i,i=r,r=void 0);try{return new n(e instanceof n?e.version:e,r).inc(t,i,a).version}catch{return null}}})),Oe=t(((e,t)=>{let n=we();t.exports=(e,t)=>{let r=n(e,null,!0),i=n(t,null,!0),a=r.compare(i);if(a===0)return null;let o=a>0,s=o?r:i,c=o?i:r,l=!!s.prerelease.length;if(c.prerelease.length&&!l){if(!c.patch&&!c.minor)return`major`;if(c.compareMain(s)===0)return c.minor&&!c.patch?`minor`:`patch`}let u=l?`pre`:``;return r.major===i.major?r.minor===i.minor?r.patch===i.patch?`prerelease`:u+`patch`:u+`minor`:u+`major`}})),ke=t(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).major})),Ae=t(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).minor})),je=t(((e,t)=>{let n=O();t.exports=(e,t)=>new n(e,t).patch})),Me=t(((e,t)=>{let n=we();t.exports=(e,t)=>{let r=n(e,t);return r&&r.prerelease.length?r.prerelease:null}})),k=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>new n(e,r).compare(new n(t,r))})),Ne=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(t,e,r)})),Pe=t(((e,t)=>{let n=k();t.exports=(e,t)=>n(e,t,!0)})),Fe=t(((e,t)=>{let n=O();t.exports=(e,t,r)=>{let i=new n(e,r),a=new n(t,r);return i.compare(a)||i.compareBuild(a)}})),Ie=t(((e,t)=>{let n=Fe();t.exports=(e,t)=>e.sort((e,r)=>n(e,r,t))})),Le=t(((e,t)=>{let n=Fe();t.exports=(e,t)=>e.sort((e,r)=>n(r,e,t))})),Re=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)>0})),ze=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)<0})),Be=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)===0})),Ve=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)!==0})),He=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)>=0})),Ue=t(((e,t)=>{let n=k();t.exports=(e,t,r)=>n(e,t,r)<=0})),We=t(((e,t)=>{let n=Be(),r=Ve(),i=Re(),a=He(),o=ze(),s=Ue();t.exports=(e,t,c,l)=>{switch(t){case`===`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e===c;case`!==`:return typeof e==`object`&&(e=e.version),typeof c==`object`&&(c=c.version),e!==c;case``:case`=`:case`==`:return n(e,c,l);case`!=`:return r(e,c,l);case`>`:return i(e,c,l);case`>=`:return a(e,c,l);case`<`:return o(e,c,l);case`<=`:return s(e,c,l);default:throw TypeError(`Invalid operator: ${t}`)}}})),Ge=t(((e,t)=>{let n=O(),r=we(),{safeRe:i,t:a}=xe();t.exports=(e,t)=>{if(e instanceof n)return e;if(typeof e==`number`&&(e=String(e)),typeof e!=`string`)return null;t||={};let o=null;if(!t.rtl)o=e.match(t.includePrerelease?i[a.COERCEFULL]:i[a.COERCE]);else{let n=t.includePrerelease?i[a.COERCERTLFULL]:i[a.COERCERTL],r;for(;(r=n.exec(e))&&(!o||o.index+o[0].length!==e.length);)(!o||r.index+r[0].length!==o.index+o[0].length)&&(o=r),n.lastIndex=r.index+r[1].length+r[2].length;n.lastIndex=-1}if(o===null)return null;let s=o[2],c=o[3]||`0`,l=o[4]||`0`,u=t.includePrerelease&&o[5]?`-${o[5]}`:``,d=t.includePrerelease&&o[6]?`+${o[6]}`:``;return r(`${s}.${c}.${l}${u}${d}`,t)}})),Ke=t(((e,t)=>{t.exports=class{constructor(){this.max=1e3,this.map=new Map}get(e){let t=this.map.get(e);if(t!==void 0)return this.map.delete(e),this.map.set(e,t),t}delete(e){return this.map.delete(e)}set(e,t){if(!this.delete(e)&&t!==void 0){if(this.map.size>=this.max){let e=this.map.keys().next().value;this.delete(e)}this.map.set(e,t)}return this}}})),A=t(((e,t)=>{let n=/\s+/g;t.exports=class e{constructor(t,r){if(r=i(r),t instanceof e)return t.loose===!!r.loose&&t.includePrerelease===!!r.includePrerelease?t:new e(t.raw,r);if(t instanceof a)return this.raw=t.value,this.set=[[t]],this.formatted=void 0,this;if(this.options=r,this.loose=!!r.loose,this.includePrerelease=!!r.includePrerelease,this.raw=t.trim().replace(n,` `),this.set=this.raw.split(`||`).map(e=>this.parseRange(e.trim())).filter(e=>e.length),!this.set.length)throw TypeError(`Invalid SemVer Range: ${this.raw}`);if(this.set.length>1){let e=this.set[0];if(this.set=this.set.filter(e=>!h(e[0])),this.set.length===0)this.set=[e];else if(this.set.length>1){for(let e of this.set)if(e.length===1&&g(e[0])){this.set=[e];break}}}this.formatted=void 0}get range(){if(this.formatted===void 0){this.formatted=``;for(let e=0;e<this.set.length;e++){e>0&&(this.formatted+=`||`);let t=this.set[e];for(let e=0;e<t.length;e++)e>0&&(this.formatted+=` `),this.formatted+=t[e].toString().trim()}}return this.formatted}format(){return this.range}toString(){return this.range}parseRange(e){let t=((this.options.includePrerelease&&p)|(this.options.loose&&m))+`:`+e,n=r.get(t);if(n)return n;let i=this.options.loose,s=i?c[l.HYPHENRANGELOOSE]:c[l.HYPHENRANGE];e=e.replace(s,ie(this.options.includePrerelease)),o(`hyphen replace`,e),e=e.replace(c[l.COMPARATORTRIM],u),o(`comparator trim`,e),e=e.replace(c[l.TILDETRIM],d),o(`tilde trim`,e),e=e.replace(c[l.CARETTRIM],f),o(`caret trim`,e);let g=e.split(` `).map(e=>v(e,this.options)).join(` `).split(/\s+/).map(e=>C(e,this.options));i&&(g=g.filter(e=>(o(`loose invalid filter`,e,this.options),!!e.match(c[l.COMPARATORLOOSE])))),o(`range list`,g);let _=new Map,y=g.map(e=>new a(e,this.options));for(let e of y){if(h(e))return[e];_.set(e.value,e)}_.size>1&&_.has(``)&&_.delete(``);let b=[..._.values()];return r.set(t,b),b}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Range is required`);return this.set.some(e=>_(e,n)&&t.set.some(t=>_(t,n)&&e.every(e=>t.every(t=>e.intersects(t,n)))))}test(e){if(!e)return!1;if(typeof e==`string`)try{e=new s(e,this.options)}catch{return!1}for(let t=0;t<this.set.length;t++)if(ae(this.set[t],e,this.options))return!0;return!1}};let r=new(Ke()),i=Se(),a=qe(),o=be(),s=O(),{safeRe:c,t:l,comparatorTrimReplace:u,tildeTrimReplace:d,caretTrimReplace:f}=xe(),{FLAG_INCLUDE_PRERELEASE:p,FLAG_LOOSE:m}=ye(),h=e=>e.value===`<0.0.0-0`,g=e=>e.value===``,_=(e,t)=>{let n=!0,r=e.slice(),i=r.pop();for(;n&&r.length;)n=r.every(e=>i.intersects(e,t)),i=r.pop();return n},v=(e,t)=>(e=e.replace(c[l.BUILD],``),o(`comp`,e,t),e=S(e,t),o(`caret`,e),e=b(e,t),o(`tildes`,e),e=te(e,t),o(`xrange`,e),e=re(e,t),o(`stars`,e),e),y=e=>!e||e.toLowerCase()===`x`||e===`*`,b=(e,t)=>e.trim().split(/\s+/).map(e=>x(e,t)).join(` `),x=(e,t)=>{let n=t.loose?c[l.TILDELOOSE]:c[l.TILDE];return e.replace(n,(t,n,r,i,a)=>{o(`tilde`,e,t,n,r,i,a);let s;return y(n)?s=``:y(r)?s=`>=${n}.0.0 <${+n+1}.0.0-0`:y(i)?s=`>=${n}.${r}.0 <${n}.${+r+1}.0-0`:a?(o(`replaceTilde pr`,a),s=`>=${n}.${r}.${i}-${a} <${n}.${+r+1}.0-0`):s=`>=${n}.${r}.${i} <${n}.${+r+1}.0-0`,o(`tilde return`,s),s})},S=(e,t)=>e.trim().split(/\s+/).map(e=>ee(e,t)).join(` `),ee=(e,t)=>{o(`caret`,e,t);let n=t.loose?c[l.CARETLOOSE]:c[l.CARET],r=t.includePrerelease?`-0`:``;return e.replace(n,(t,n,i,a,s)=>{o(`caret`,e,t,n,i,a,s);let c;return y(n)?c=``:y(i)?c=`>=${n}.0.0${r} <${+n+1}.0.0-0`:y(a)?c=n===`0`?`>=${n}.${i}.0${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.0${r} <${+n+1}.0.0-0`:s?(o(`replaceCaret pr`,s),c=n===`0`?i===`0`?`>=${n}.${i}.${a}-${s} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}-${s} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a}-${s} <${+n+1}.0.0-0`):(o(`no pr`),c=n===`0`?i===`0`?`>=${n}.${i}.${a}${r} <${n}.${i}.${+a+1}-0`:`>=${n}.${i}.${a}${r} <${n}.${+i+1}.0-0`:`>=${n}.${i}.${a} <${+n+1}.0.0-0`),o(`caret return`,c),c})},te=(e,t)=>(o(`replaceXRanges`,e,t),e.split(/\s+/).map(e=>ne(e,t)).join(` `)),ne=(e,t)=>{e=e.trim();let n=t.loose?c[l.XRANGELOOSE]:c[l.XRANGE];return e.replace(n,(n,r,i,a,s,c)=>{o(`xRange`,e,n,r,i,a,s,c);let l=y(i),u=l||y(a),d=u||y(s),f=d;return r===`=`&&f&&(r=``),c=t.includePrerelease?`-0`:``,l?n=r===`>`||r===`<`?`<0.0.0-0`:`*`:r&&f?(u&&(a=0),s=0,r===`>`?(r=`>=`,u?(i=+i+1,a=0,s=0):(a=+a+1,s=0)):r===`<=`&&(r=`<`,u?i=+i+1:a=+a+1),r===`<`&&(c=`-0`),n=`${r+i}.${a}.${s}${c}`):u?n=`>=${i}.0.0${c} <${+i+1}.0.0-0`:d&&(n=`>=${i}.${a}.0${c} <${i}.${+a+1}.0-0`),o(`xRange return`,n),n})},re=(e,t)=>(o(`replaceStars`,e,t),e.trim().replace(c[l.STAR],``)),C=(e,t)=>(o(`replaceGTE0`,e,t),e.trim().replace(c[t.includePrerelease?l.GTE0PRE:l.GTE0],``)),ie=e=>(t,n,r,i,a,o,s,c,l,u,d,f)=>(n=y(r)?``:y(i)?`>=${r}.0.0${e?`-0`:``}`:y(a)?`>=${r}.${i}.0${e?`-0`:``}`:o?`>=${n}`:`>=${n}${e?`-0`:``}`,c=y(l)?``:y(u)?`<${+l+1}.0.0-0`:y(d)?`<${l}.${+u+1}.0-0`:f?`<=${l}.${u}.${d}-${f}`:e?`<${l}.${u}.${+d+1}-0`:`<=${c}`,`${n} ${c}`.trim()),ae=(e,t,n)=>{for(let n=0;n<e.length;n++)if(!e[n].test(t))return!1;if(t.prerelease.length&&!n.includePrerelease){for(let n=0;n<e.length;n++)if(o(e[n].semver),e[n].semver!==a.ANY&&e[n].semver.prerelease.length>0){let r=e[n].semver;if(r.major===t.major&&r.minor===t.minor&&r.patch===t.patch)return!0}return!1}return!0}})),qe=t(((e,t)=>{let n=Symbol(`SemVer ANY`);t.exports=class e{static get ANY(){return n}constructor(t,i){if(i=r(i),t instanceof e){if(t.loose===!!i.loose)return t;t=t.value}t=t.trim().split(/\s+/).join(` `),s(`comparator`,t,i),this.options=i,this.loose=!!i.loose,this.parse(t),this.semver===n?this.value=``:this.value=this.operator+this.semver.version,s(`comp`,this)}parse(e){let t=this.options.loose?i[a.COMPARATORLOOSE]:i[a.COMPARATOR],r=e.match(t);if(!r)throw TypeError(`Invalid comparator: ${e}`);this.operator=r[1]===void 0?``:r[1],this.operator===`=`&&(this.operator=``),r[2]?this.semver=new c(r[2],this.options.loose):this.semver=n}toString(){return this.value}test(e){if(s(`Comparator.test`,e,this.options.loose),this.semver===n||e===n)return!0;if(typeof e==`string`)try{e=new c(e,this.options)}catch{return!1}return o(e,this.operator,this.semver,this.options)}intersects(t,n){if(!(t instanceof e))throw TypeError(`a Comparator is required`);return this.operator===``?this.value===``||new l(t.value,n).test(this.value):t.operator===``?t.value===``||new l(this.value,n).test(t.semver):(n=r(n),n.includePrerelease&&(this.value===`<0.0.0-0`||t.value===`<0.0.0-0`)||!n.includePrerelease&&(this.value.startsWith(`<0.0.0`)||t.value.startsWith(`<0.0.0`))?!1:!!(this.operator.startsWith(`>`)&&t.operator.startsWith(`>`)||this.operator.startsWith(`<`)&&t.operator.startsWith(`<`)||this.semver.version===t.semver.version&&this.operator.includes(`=`)&&t.operator.includes(`=`)||o(this.semver,`<`,t.semver,n)&&this.operator.startsWith(`>`)&&t.operator.startsWith(`<`)||o(this.semver,`>`,t.semver,n)&&this.operator.startsWith(`<`)&&t.operator.startsWith(`>`)))}};let r=Se(),{safeRe:i,t:a}=xe(),o=We(),s=be(),c=O(),l=A()})),Je=t(((e,t)=>{let n=A();t.exports=(e,t,r)=>{try{t=new n(t,r)}catch{return!1}return t.test(e)}})),Ye=t(((e,t)=>{let n=A();t.exports=(e,t)=>new n(e,t).set.map(e=>e.map(e=>e.value).join(` `).trim().split(` `))})),Xe=t(((e,t)=>{let n=O(),r=A();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===-1)&&(a=e,o=new n(a,i))}),a}})),Ze=t(((e,t)=>{let n=O(),r=A();t.exports=(e,t,i)=>{let a=null,o=null,s=null;try{s=new r(t,i)}catch{return null}return e.forEach(e=>{s.test(e)&&(!a||o.compare(e)===1)&&(a=e,o=new n(a,i))}),a}})),Qe=t(((e,t)=>{let n=O(),r=A(),i=Re();t.exports=(e,t)=>{e=new r(e,t);let a=new n(`0.0.0`);if(e.test(a)||(a=new n(`0.0.0-0`),e.test(a)))return a;a=null;for(let t=0;t<e.set.length;++t){let r=e.set[t],o=null;r.forEach(e=>{let t=new n(e.semver.version);switch(e.operator){case`>`:t.prerelease.length===0?t.patch++:t.prerelease.push(0),t.raw=t.format();case``:case`>=`:(!o||i(t,o))&&(o=t);break;case`<`:case`<=`:break;default:throw Error(`Unexpected operation: ${e.operator}`)}}),o&&(!a||i(a,o))&&(a=o)}return a&&e.test(a)?a:null}})),$e=t(((e,t)=>{let n=A();t.exports=(e,t)=>{try{return new n(e,t).range||`*`}catch{return null}}})),et=t(((e,t)=>{let n=O(),r=qe(),{ANY:i}=r,a=A(),o=Je(),s=Re(),c=ze(),l=Ue(),u=He();t.exports=(e,t,d,f)=>{e=new n(e,f),t=new a(t,f);let p,m,h,g,_;switch(d){case`>`:p=s,m=l,h=c,g=`>`,_=`>=`;break;case`<`:p=c,m=u,h=s,g=`<`,_=`<=`;break;default:throw TypeError(`Must provide a hilo val of "<" or ">"`)}if(o(e,t,f))return!1;for(let n=0;n<t.set.length;++n){let a=t.set[n],o=null,s=null;if(a.forEach(e=>{e.semver===i&&(e=new r(`>=0.0.0`)),o||=e,s||=e,p(e.semver,o.semver,f)?o=e:h(e.semver,s.semver,f)&&(s=e)}),o.operator===g||o.operator===_||(!s.operator||s.operator===g)&&m(e,s.semver)||s.operator===_&&h(e,s.semver))return!1}return!0}})),tt=t(((e,t)=>{let n=et();t.exports=(e,t,r)=>n(e,t,`>`,r)})),nt=t(((e,t)=>{let n=et();t.exports=(e,t,r)=>n(e,t,`<`,r)})),rt=t(((e,t)=>{let n=A();t.exports=(e,t,r)=>(e=new n(e,r),t=new n(t,r),e.intersects(t,r))})),it=t(((e,t)=>{let n=Je(),r=k();t.exports=(e,t,i)=>{let a=[],o=null,s=null,c=e.sort((e,t)=>r(e,t,i));for(let e of c)n(e,t,i)?(s=e,o||=e):(s&&a.push([o,s]),s=null,o=null);o&&a.push([o,null]);let l=[];for(let[e,t]of a)e===t?l.push(e):!t&&e===c[0]?l.push(`*`):t?e===c[0]?l.push(`<=${t}`):l.push(`${e} - ${t}`):l.push(`>=${e}`);let u=l.join(` || `),d=typeof t.raw==`string`?t.raw:String(t);return u.length<d.length?u:t}})),at=t(((e,t)=>{let n=A(),r=qe(),{ANY:i}=r,a=Je(),o=k(),s=(e,t,r={})=>{if(e===t)return!0;e=new n(e,r),t=new n(t,r);let i=!1;OUTER:for(let n of e.set){for(let e of t.set){let t=u(n,e,r);if(i||=t!==null,t)continue OUTER}if(i)return!1}return!0},c=[new r(`>=0.0.0-0`)],l=[new r(`>=0.0.0`)],u=(e,t,n)=>{if(e===t)return!0;if(e.length===1&&e[0].semver===i){if(t.length===1&&t[0].semver===i)return!0;e=n.includePrerelease?c:l}if(t.length===1&&t[0].semver===i){if(n.includePrerelease)return!0;t=l}let r=new Set,s,u;for(let t of e)t.operator===`>`||t.operator===`>=`?s=d(s,t,n):t.operator===`<`||t.operator===`<=`?u=f(u,t,n):r.add(t.semver);if(r.size>1)return null;let p;if(s&&u&&(p=o(s.semver,u.semver,n),p>0||p===0&&(s.operator!==`>=`||u.operator!==`<=`)))return null;for(let e of r){if(s&&!a(e,String(s),n)||u&&!a(e,String(u),n))return null;for(let r of t)if(!a(e,String(r),n))return!1;return!0}let m,h,g,_,v=u&&!n.includePrerelease&&u.semver.prerelease.length?u.semver:!1,y=s&&!n.includePrerelease&&s.semver.prerelease.length?s.semver:!1;v&&v.prerelease.length===1&&u.operator===`<`&&v.prerelease[0]===0&&(v=!1);for(let e of t){if(_=_||e.operator===`>`||e.operator===`>=`,g=g||e.operator===`<`||e.operator===`<=`,s){if(y&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===y.major&&e.semver.minor===y.minor&&e.semver.patch===y.patch&&(y=!1),e.operator===`>`||e.operator===`>=`){if(m=d(s,e,n),m===e&&m!==s)return!1}else if(s.operator===`>=`&&!a(s.semver,String(e),n))return!1}if(u){if(v&&e.semver.prerelease&&e.semver.prerelease.length&&e.semver.major===v.major&&e.semver.minor===v.minor&&e.semver.patch===v.patch&&(v=!1),e.operator===`<`||e.operator===`<=`){if(h=f(u,e,n),h===e&&h!==u)return!1}else if(u.operator===`<=`&&!a(u.semver,String(e),n))return!1}if(!e.operator&&(u||s)&&p!==0)return!1}return!(s&&g&&!u&&p!==0||u&&_&&!s&&p!==0||y||v)},d=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r>0?e:r<0||t.operator===`>`&&e.operator===`>=`?t:e},f=(e,t,n)=>{if(!e)return t;let r=o(e.semver,t.semver,n);return r<0?e:r>0||t.operator===`<`&&e.operator===`<=`?t:e};t.exports=s})),ot=t(((e,t)=>{let n=xe(),r=ye(),i=O(),a=Ce();t.exports={parse:we(),valid:Te(),clean:Ee(),inc:De(),diff:Oe(),major:ke(),minor:Ae(),patch:je(),prerelease:Me(),compare:k(),rcompare:Ne(),compareLoose:Pe(),compareBuild:Fe(),sort:Ie(),rsort:Le(),gt:Re(),lt:ze(),eq:Be(),neq:Ve(),gte:He(),lte:Ue(),cmp:We(),coerce:Ge(),Comparator:qe(),Range:A(),satisfies:Je(),toComparators:Ye(),maxSatisfying:Xe(),minSatisfying:Ze(),minVersion:Qe(),validRange:$e(),outside:et(),gtr:tt(),ltr:nt(),intersects:rt(),simplifyRange:it(),subset:at(),SemVer:i,re:n.re,src:n.src,tokens:n.t,SEMVER_SPEC_VERSION:r.SEMVER_SPEC_VERSION,RELEASE_TYPES:r.RELEASE_TYPES,compareIdentifiers:a.compareIdentifiers,rcompareIdentifiers:a.rcompareIdentifiers}}));const st=2**32-1,ct=st-1;var j=class extends Error{constructor(e,t,n,r){super(e),this.name=`DevalueError`,this.path=t.join(``),this.value=n,this.root=r}};function lt(e){return e===null||typeof e!=`object`&&typeof e!=`function`}const ut=Object.getOwnPropertyNames(Object.prototype).sort().join(`\0`);function dt(e){let t=Object.getPrototypeOf(e);return t===Object.prototype||t===null||Object.getPrototypeOf(t)===null||Object.getOwnPropertyNames(t).sort().join(`\0`)===ut}function ft(e){return Object.prototype.toString.call(e).slice(8,-1)}function pt(e){switch(e){case`"`:return`\\"`;case`<`:return`\\u003C`;case`\\`:return`\\\\`;case`
|
|
5
|
+
`:return`\\n`;case`\r`:return`\\r`;case` `:return`\\t`;case`\b`:return`\\b`;case`\f`:return`\\f`;case`\u2028`:return`\\u2028`;case`\u2029`:return`\\u2029`;default:return e<` `?`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`:``}}function M(e){let t=``,n=0,r=e.length;for(let i=0;i<r;i+=1){let r=e[i],a=pt(r);a&&(t+=e.slice(n,i)+a,n=i+1)}return`"${n===0?e:t+e.slice(n)}"`}function mt(e){return Object.getOwnPropertySymbols(e).filter(t=>Object.getOwnPropertyDescriptor(e,t).enumerable)}const ht=/^[a-zA-Z_$][a-zA-Z_$0-9]*$/;function gt(e){return ht.test(e)?`.`+e:`[`+JSON.stringify(e)+`]`}function _t(e){return!(!Number.isInteger(e)||e<0||e>ct)}function vt(e){return!(!Number.isInteger(e)||e<0||e>st)}function yt(e){if(e.length===0||e.length>1&&e.charCodeAt(0)===48)return!1;for(let t=0;t<e.length;t++){let n=e.charCodeAt(t);if(n<48||n>57)return!1}return _t(+e)}function bt(e){let t=Object.keys(e);for(var n=t.length-1;n>=0&&!yt(t[n]);n--);return t.length=n+1,t}function xt(e){return new Uint8Array(e).toBase64()}function St(e){return Uint8Array.fromBase64(e).buffer}function Ct(e){return Buffer.from(e).toString(`base64`)}function wt(e){return Uint8Array.from(Buffer.from(e,`base64`)).buffer}function Tt(e){let t=new Uint8Array(e),n=``,r=32768;for(let e=0;e<t.length;e+=r){let i=t.subarray(e,e+r);n+=String.fromCharCode.apply(null,i)}return btoa(n)}function Et(e){let t=atob(e),n=t.length,r=new Uint8Array(n);for(let e=0;e<n;e++)r[e]=t.charCodeAt(e);return r.buffer}const Dt=typeof Uint8Array.fromBase64==`function`,Ot=typeof process==`object`&&process.versions?.node!==void 0,kt=Dt?xt:Ot?Ct:Tt,At=Dt?St:Ot?wt:Et;function jt(e,t){return Mt(JSON.parse(e),t)}function Mt(e,t){if(typeof e==`number`)return a(e,!0);if(!Array.isArray(e)||e.length===0)throw Error(`Invalid input`);let n=e,r=Array(n.length),i=null;function a(e,o=!1){if(e===-1)return;if(e===-3)return NaN;if(e===-4)return 1/0;if(e===-5)return-1/0;if(e===-6)return-0;if(o||typeof e!=`number`)throw Error(`Invalid input`);if(e in r)return r[e];let s=n[e];if(!s||typeof s!=`object`)r[e]=s;else if(Array.isArray(s))if(typeof s[0]==`string`){let o=s[0],c=t&&Object.hasOwn(t,o)?t[o]:void 0;if(c){let t=s[1];if(typeof t!=`number`&&(t=n.push(s[1])-1),i??=new Set,i.has(t))throw Error(`Invalid circular reference`);return i.add(t),r[e]=c(a(t)),i.delete(t),r[e]}switch(o){case`Date`:r[e]=new Date(s[1]);break;case`Set`:let t=new Set;r[e]=t;for(let e=1;e<s.length;e+=1)t.add(a(s[e]));break;case`Map`:let i=new Map;r[e]=i;for(let e=1;e<s.length;e+=2)i.set(a(s[e]),a(s[e+1]));break;case`RegExp`:r[e]=new RegExp(s[1],s[2]);break;case`Object`:{let t=s[1];if(typeof n[t]==`object`&&n[t][0]!==`BigInt`)throw Error(`Invalid input`);r[e]=Object(a(t));break}case`BigInt`:r[e]=BigInt(s[1]);break;case`null`:let c=Object.create(null);r[e]=c;for(let e=1;e<s.length;e+=2){if(s[e]===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");c[s[e]]=a(s[e+1])}break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{if(n[s[1]][0]!==`ArrayBuffer`)throw Error(`Invalid data`);let t=globalThis[o],i=a(s[1]);r[e]=s[2]===void 0?new t(i):new t(i,s[2],s[3]);break}case`ArrayBuffer`:{let t=s[1];if(typeof t!=`string`)throw Error(`Invalid ArrayBuffer encoding`);let n=At(t);r[e]=n;break}case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:{let t=o.slice(9);r[e]=Temporal[t].from(s[1]);break}case`URL`:{let t=new URL(s[1]);r[e]=t;break}case`URLSearchParams`:{let t=new URLSearchParams(s[1]);r[e]=t;break}default:throw Error(`Unknown type ${o}`)}}else if(s[0]===-7){let t=s[1];if(!vt(t))throw Error(`Invalid input`);let n=[];r[e]=n,n[ct]=void 0,delete n[ct];for(let e=2;e<s.length;e+=2){let r=s[e];if(!_t(r)||r>=t)throw Error(`Invalid input`);n[r]=a(s[e+1])}n.length=t}else{let t=Array(s.length);r[e]=t;for(let e=0;e<s.length;e+=1){let n=s[e];n!==-2&&(t[e]=a(n))}}else{let t={};r[e]=t;for(let e of Object.keys(s)){if(e===`__proto__`)throw Error("Cannot parse an object with a `__proto__` property");let n=s[e];t[e]=a(n)}}return r[e]}return a(0)}function N(e,t){let n=Nt(!1,e,t);return typeof n==`string`?n:`[${n.join(`,`)}]`}function Nt(e,t,n){let r=[],i=new Map,a=[];if(n)for(let e of Object.getOwnPropertyNames(n))a.push({key:e,fn:n[e]});let o=[],s=0;function c(n,l){if(n===void 0)return-1;if(Number.isNaN(n))return-3;if(n===1/0)return-4;if(n===-1/0)return-5;if(n===0&&1/n<0)return-6;if(i.has(n))return i.get(n);l??=s++,i.set(n,l);for(let{key:e,fn:t}of a){let i=t(n);if(i)return r[l]=`["${e}",${c(i)}]`,l}if(typeof n==`function`)throw new j(`Cannot stringify a function`,o,n,t);if(typeof n==`symbol`)throw new j(`Cannot stringify a Symbol primitive`,o,n,t);let u=``;if(lt(n))u=Pt(n);else if(typeof n.then==`function`){if(!e)throw new j(`Cannot stringify a Promise or thenable — use stringifyAsync instead`,o,n,t);u=Promise.resolve(n).then(e=>{let t=c(e,l);t<0&&(r[l]=t)})}else{let e=ft(n);switch(e){case`Number`:case`String`:case`Boolean`:case`BigInt`:u=`["Object",${c(n.valueOf())}]`;break;case`Date`:u=`["Date","${isNaN(n.getDate())?``:n.toISOString()}"]`;break;case`URL`:u=`["URL",${M(n.toString())}]`;break;case`URLSearchParams`:u=`["URLSearchParams",${M(n.toString())}]`;break;case`RegExp`:let{source:r,flags:i}=n;u=i?`["RegExp",${M(r)},"${i}"]`:`["RegExp",${M(r)}]`;break;case`Array`:{let e=!1;u=`[`;for(let t=0;t<n.length;t+=1)if(t>0&&(u+=`,`),Object.hasOwn(n,t))o.push(`[${t}]`),u+=c(n[t]),o.pop();else if(e)u+=-2;else{let t=bt(n),r=t.length,i=String(n.length).length;if((n.length-r)*3>4+i+r*(i+1)){u=`[-7,`+n.length;for(let e=0;e<t.length;e++){let r=t[e];o.push(`[${r}]`),u+=`,`+r+`,`+c(n[r]),o.pop()}break}else e=!0,u+=-2}u+=`]`;break}case`Set`:u=`["Set"`;for(let e of n)u+=`,${c(e)}`;u+=`]`;break;case`Map`:u=`["Map"`;for(let[e,t]of n)o.push(`.get(${lt(e)?Pt(e):`...`})`),u+=`,${c(e)},${c(t)}`,o.pop();u+=`]`;break;case`Int8Array`:case`Uint8Array`:case`Uint8ClampedArray`:case`Int16Array`:case`Uint16Array`:case`Float16Array`:case`Int32Array`:case`Uint32Array`:case`Float32Array`:case`Float64Array`:case`BigInt64Array`:case`BigUint64Array`:case`DataView`:{let t=n;u=`["`+e+`",`+c(t.buffer),t.byteLength!==t.buffer.byteLength&&(u+=`,${t.byteOffset},${t.length}`),u+=`]`;break}case`ArrayBuffer`:u=`["ArrayBuffer","${kt(n)}"]`;break;case`Temporal.Duration`:case`Temporal.Instant`:case`Temporal.PlainDate`:case`Temporal.PlainTime`:case`Temporal.PlainDateTime`:case`Temporal.PlainMonthDay`:case`Temporal.PlainYearMonth`:case`Temporal.ZonedDateTime`:u=`["${e}",${M(n.toString())}]`;break;default:if(!dt(n))throw new j(`Cannot stringify arbitrary non-POJOs`,o,n,t);if(mt(n).length>0)throw new j(`Cannot stringify POJOs with symbolic keys`,o,n,t);if(Object.getPrototypeOf(n)===null){u=`["null"`;for(let e of Object.keys(n)){if(e===`__proto__`)throw new j(`Cannot stringify objects with __proto__ keys`,o,n,t);o.push(gt(e)),u+=`,${M(e)},${c(n[e])}`,o.pop()}u+=`]`}else{u=`{`;let e=!1;for(let r of Object.keys(n)){if(r===`__proto__`)throw new j(`Cannot stringify objects with __proto__ keys`,o,n,t);e&&(u+=`,`),e=!0,o.push(gt(r)),u+=`${M(r)}:${c(n[r])}`,o.pop()}u+=`}`}}}return r[l]=u,l}let l=c(t);return l<0?`${l}`:r}function Pt(e){let t=typeof e;return t===`string`?M(e):e===void 0?`-1`:e===0&&1/e<0?`-6`:t===`bigint`?`["BigInt","${e}"]`:String(e)}var Ft=e(ot(),1);async function It(e,t=[`encrypt`,`decrypt`]){if(e.byteLength!==32)throw new c(`Encryption key must be exactly 32 bytes, got ${e.byteLength}`);return globalThis.crypto.subtle.importKey(`raw`,e,`AES-GCM`,!1,t)}async function Lt(e,t,n){let r=globalThis.crypto.getRandomValues(new Uint8Array(12)),i;try{i=await globalThis.crypto.subtle.encrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,t)}catch(e){throw new h(`AES-256-GCM encryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`encrypt`,byteLength:t.byteLength}})}let a=new Uint8Array(12+i.byteLength);return a.set(r,0),a.set(new Uint8Array(i),12),a}async function Rt(e,t,n){if(t.byteLength<28)throw new h(`Encrypted data too short: expected at least 28 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,12),i=t.subarray(12),a;try{a=await globalThis.crypto.subtle.decrypt({name:`AES-GCM`,iv:r,tagLength:128,...n?{additionalData:n}:{}},e,i)}catch(e){throw new h(`AES-256-GCM decryption failed: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return new Uint8Array(a)}const zt=new Uint8Array([48,46,2,1,0,48,5,6,3,43,101,110,4,34,4,32]),Bt=new TextEncoder;function Vt(e){if(e.byteLength!==32)throw new c(`Run key material must be exactly 32 bytes, got ${e.byteLength}`)}function Ht(e,t){if(e.byteLength!==32)throw new c(`${t} must be exactly 32 bytes, got ${e.byteLength}`)}async function Ut(e){Vt(e);let t=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),n=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:Bt.encode(`workflow/encp/x25519/v1`)},t,256),r=new Uint8Array(n);return{scalar:r,publicKey:await Wt(r)}}async function Wt(e){let t=await Gt(e,!0),n=await globalThis.crypto.subtle.exportKey(`jwk`,t);if(!n.x)throw new c(`X25519 JWK export did not include a public key component ("x")`);let r=Xt(n.x);if(r.byteLength!==32)throw new c(`X25519 JWK export produced a ${r.byteLength}-byte public key, expected 32`);return r}async function Gt(e,t){let n=new Uint8Array(zt.length+e.byteLength);return n.set(zt,0),n.set(e,zt.length),globalThis.crypto.subtle.importKey(`pkcs8`,n,{name:`X25519`},t,[`deriveBits`])}function Kt(e){return globalThis.crypto.subtle.importKey(`raw`,e,{name:`X25519`},!0,[])}const qt=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`;function Jt(e){let t=``;for(let n=0;n<e.length;n+=3){let r=e[n],i=n+1<e.length?e[n+1]:0,a=n+2<e.length?e[n+2]:0;t+=qt[r>>2&63],t+=qt[(r&3)<<4|i>>4&15],t+=n+1<e.length?qt[(i&15)<<2|a>>6&3]:`=`,t+=n+2<e.length?qt[a&63]:`=`}return t}function Yt(e){let t=e.length;for(;t>0&&e[t-1]===`=`;)t--;let n=e.slice(0,t);if(n.includes(`=`)||n.length%4==1||t!==e.length&&e.length%4!=0)return;let r=0,i=0,a=[];for(let e=0;e<n.length;e++){let t=qt.indexOf(n[e]);if(t===-1)return;r=r<<6|t,i+=6,i>=8&&(i-=8,a.push(r>>i&255))}if(!(i>0&&r&(1<<i)-1))return new Uint8Array(a)}function Xt(e){let t=0,n=0,r=[];for(let i=0;i<e.length;i++){let a=e[i];if(a===`=`)break;let o=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_`.indexOf(a);if(o===-1)throw new c(`Invalid base64url character "${a}" in X25519 JWK key component`);t=t<<6|o,n+=6,n>=8&&(n-=8,r.push(t>>n&255))}return new Uint8Array(r)}async function Zt(e,t,n,r){let i=Bt.encode(`workflow/encp/aes256gcm/v1`),a=new Uint8Array(i.length+t.length+n.length);a.set(i,0),a.set(t,i.length),a.set(n,i.length+t.length);let o=await globalThis.crypto.subtle.importKey(`raw`,e,`HKDF`,!1,[`deriveBits`]),s=await globalThis.crypto.subtle.deriveBits({name:`HKDF`,hash:`SHA-256`,salt:new Uint8Array(32),info:a},o,256);return globalThis.crypto.subtle.importKey(`raw`,new Uint8Array(s),`AES-GCM`,!1,r)}async function Qt(e){Ht(e,`Recipient public key`);let t;try{t=await Kt(e)}catch(e){throw new c(`Invalid X25519 recipient public key: ${e instanceof Error?e.message:String(e)}`,{cause:e})}let n=await globalThis.crypto.subtle.generateKey({name:`X25519`},!0,[`deriveBits`]),r=new Uint8Array(await globalThis.crypto.subtle.exportKey(`raw`,n.publicKey)),i;try{i=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:t},n.privateKey,256)}catch(e){throw new c(`X25519 key agreement failed: the recipient public key is not a valid curve point (low-order point or corrupted key material)`,{cause:e})}return{ephemeralPublicKey:r,contentKey:await Zt(new Uint8Array(i),r,e,[`encrypt`])}}async function $t(e,t){if(t.byteLength!==32)throw new h(`Sealed payload has a malformed ephemeral public key: expected 32 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let n;try{let[r,i]=await Promise.all([Gt(e.scalar,!1),Kt(t)]);n=await globalThis.crypto.subtle.deriveBits({name:`X25519`,public:i},r,256)}catch(e){throw new h(`X25519 key agreement failed while opening a sealed payload: ${e instanceof Error?e.message:String(e)}`,{cause:e,context:{operation:`decrypt`,byteLength:t.byteLength}})}return Zt(new Uint8Array(n),t,e.publicKey,[`decrypt`])}async function en(e,t,n){let{ephemeralPublicKey:r,contentKey:i}=await Qt(e),a=await Lt(i,t,n),o=new Uint8Array(r.byteLength+a.byteLength);return o.set(r,0),o.set(a,r.byteLength),o}async function tn(e,t,n){if(t.byteLength<60)throw new h(`Sealed payload too short: expected at least 60 bytes, got ${t.byteLength}`,{context:{operation:`decrypt`,byteLength:t.byteLength}});let r=t.subarray(0,32),i=t.subarray(32);return Rt(await $t(e,r),i,n)}function nn(e,t){let n;return{async seal(r){n??=Qt(e);let{ephemeralPublicKey:i,contentKey:a}=await n,o=await Lt(a,r,t),s=new Uint8Array(i.byteLength+o.byteLength);return s.set(i,0),s.set(o,i.byteLength),s}}}function rn(e,t){let n,r;return{async open(i){if(i.byteLength<60)throw new h(`Sealed payload too short: expected at least 60 bytes, got ${i.byteLength}`,{context:{operation:`decrypt`,byteLength:i.byteLength}});let a=i.subarray(0,32),o=i.subarray(32),s=an(a);(s!==n||!r)&&(n=s,r=$t(e,a));let c;try{c=await r}catch(e){throw n=void 0,r=void 0,e}return Rt(c,o,t)}}}function an(e){let t=``;for(let n=0;n<e.length;n++)t+=e[n].toString(16).padStart(2,`0`);return t}function on(e){if(!e)return;let t=Yt(e);if(!(!t||t.byteLength!==32))return t}const sn=Symbol.for(`WORKFLOW_USE_STEP`),cn=Symbol.for(`WORKFLOW_SET_ATTRIBUTES`),ln=Symbol.for(`WORKFLOW_CREATE_HOOK`),un=Symbol.for(`WORKFLOW_SLEEP`),dn=Symbol.for(`WORKFLOW_GET_STREAM_ID`),fn=Symbol.for(`WORKFLOW_STABLE_ULID`),P=Symbol.for(`WORKFLOW_STREAM_NAME`),pn=Symbol.for(`WORKFLOW_STREAM_TYPE`),mn=Symbol.for(`WORKFLOW_STREAM_FRAMING`),F=Symbol.for(`WORKFLOW_STREAM_SERVER_RUN_ID`),hn=Symbol.for(`WORKFLOW_STREAM_SERVER_DEPLOYMENT_ID`),I=Symbol.for(`WORKFLOW_STREAM_SERVER_PUBLIC_KEY`),gn=Symbol.for(`WORKFLOW_STREAM_DRAIN`),_n=Symbol.for(`BODY_INIT`),vn=Symbol.for(`WEBHOOK_RESPONSE_WRITABLE`),yn=Symbol.for(`workflow-class-registry`),L=Symbol.for(`WORKFLOW_ABORT_STREAM_NAME`),R=Symbol.for(`WORKFLOW_ABORT_HOOK_TOKEN`),bn=Symbol.for(`WORKFLOW_ABORT_LISTENER_ATTACHED`),xn=Symbol.for(`WORKFLOW_ABORT_READER_CANCEL`),Sn=()=>S(`WORKFLOW_STREAM_MAX_INFLIGHT_CHUNKS`,1e3,{integer:!0,min:1}),Cn=()=>S(`WORKFLOW_STREAM_MAX_CHUNKS_PER_BATCH`,1e3,{integer:!0,min:1}),wn=()=>S(`WORKFLOW_STREAM_MAX_BYTES_PER_BATCH`,1048576,{integer:!0,min:1}),Tn=()=>S(`WORKFLOW_STREAM_MAX_BUFFERED_BYTES`,8388608,{integer:!0,min:1}),En=()=>S(`WORKFLOW_LOCK_POLL_INTERVAL_MS`,10,{integer:!0,min:1});function Dn(){let e={...a(),pendingOps:0,doneResolved:!1,streamEnded:!1};return e.promise.catch(()=>{}),e}function On(e){if(e.locked)return!1;let t;try{t=e.getWriter()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function kn(e){if(e.locked)return!1;let t;try{t=e.getReader()}catch{return!1}try{t.releaseLock()}catch{return!1}return!0}function An(e){let t=e.drainBarrier;if(!t){e.resolve();return}t().then(()=>e.resolve(),t=>e.reject(t))}function jn(e,t){if(t.writablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.writablePollingInterval=void 0;return}On(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.writablePollingInterval=void 0,An(t))},En());t.writablePollingInterval=n}function Mn(e,t){if(t.readablePollingInterval!==void 0)return;let n=setInterval(()=>{if(t.doneResolved||t.streamEnded){clearInterval(n),t.readablePollingInterval=void 0;return}kn(e)&&t.pendingOps===0&&(t.doneResolved=!0,clearInterval(n),t.readablePollingInterval=void 0,An(t))},En());t.readablePollingInterval=n}function Nn(e,t,n){let r=t[gn];return typeof r==`function`&&(n.drainBarrier=r),Pn(e,t,n)}async function Pn(e,t,n){let r=e.getReader(),i=t.getWriter(),a;try{for(;;){if(n.streamEnded)return;let e=await Promise.race([r.read(),i.closed.then(()=>{throw new c(`Writable stream closed prematurely`)})]);if(n.streamEnded)return;if(e.done){n.streamEnded=!0,await i.close(),n.doneResolved||(n.doneResolved=!0,n.resolve());return}n.pendingOps++;try{await i.write(e.value)}finally{n.pendingOps--}}}catch(e){throw n.streamEnded=!0,a=e,n.drainBarrier&&await n.drainBarrier().catch(()=>{}),n.doneResolved||(n.doneResolved=!0,n.reject(e)),e}finally{r.cancel(a).catch(()=>{}),r.releaseLock(),i.releaseLock()}}function Fn(e){if(e.specVersion!==5)throw new c(`This Workflow runtime requires a World with matching spec version 5, but the configured World declares spec version ${e.specVersion??`none`}. Install a World package version compatible with the current Workflow runtime.`)}const In=Symbol.for(`@workflow/world//cache`),Ln=Symbol.for(`@workflow/world//cachePromise`),Rn=Symbol.for(`@workflow/world//getWorldFn`);async function zn(){let e=globalThis;if(e[In])return Fn(e[In]),e[In];if(e[Ln])return e[In]=await e[Ln],Fn(e[In]),e[In];let t=e[Rn];if(t){let e=await t();return Fn(e),e}throw Error("Workflow world runtime was not initialized. Import from the host workflow entrypoints (`workflow`, `workflow/api`, or `workflow/runtime`) so @workflow/core/runtime/world-init can register getWorld before getWorldLazy() is used.")}const Bn=Symbol.for(`workflow-serialize`),Vn=Symbol.for(`workflow-deserialize`);function Hn(e=globalThis){let t=e,n=t[yn];return n||(n=new Map,t[yn]=n),n}const Un=`class//workflow//Run`;function Wn(e,t,n=globalThis){Hn(n).set(e,t)}function Gn(e,t){return Hn(t).get(e)}function Kn(){return{Class:e=>{if(typeof e!=`function`)return!1;let t=e.classId;return typeof t==`string`&&{classId:t}},Instance:e=>{if(typeof e!=`object`||!e)return!1;let t=e.constructor;if(!t||typeof t!=`function`)return!1;let n=t[Bn];if(typeof n!=`function`)return!1;let r=t.classId;if(typeof r!=`string`)throw Error(`Class "${t.name}" with ${String(Bn)} must have a static "classId" property.`);return{classId:r,data:n.call(t,e)}}}}function qn(e=globalThis){return{Class:t=>{let n=t.classId,r=Gn(n,e);if(!r)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);return r},Instance:t=>{let n=t.classId,r=t.data,i=Gn(n,e);if(!i)throw Error(`Class "${n}" not found. Make sure the class is registered with registerSerializationClass.`);let a=i[Vn];if(typeof a!=`function`)throw Error(`Class "${n}" does not have a static ${String(Vn)} method.`);return a.call(i,r)}}}function Jn(e,t,n){if(n===0)return`.`;let r=new Uint8Array(e,t,n);return Buffer.from(r).toString(`base64`)}function z(e){return Jn(e.buffer,e.byteOffset,e.byteLength)}function B(e,t){let n=e===`.`?``:e,r=Buffer.from(n,`base64`),i=new t.ArrayBuffer(r.length);return new t.Uint8Array(i).set(r),i}function Yn(e){return JSON.parse(e)}function Xn(e){if(!ee.isNativeError(e))return!1;let t={message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t}function Zn(e,t){return!ee.isNativeError(t)||t.name!==e?!1:Xn(t)}function V(e){return t=>Zn(e,t)||!1}function Qn(e,t){return n=>{let r=n,i=`cause`in r?{cause:r.cause}:void 0,a=e[t],o=new a(r.message,i);return r.stack!==void 0&&(o.stack=r.stack),o}}function $n(e=globalThis){return{ArrayBuffer:t=>t instanceof e.ArrayBuffer&&Jn(t,0,t.byteLength),BigInt:e=>typeof e==`bigint`&&e.toString(),BigInt64Array:t=>t instanceof e.BigInt64Array&&z(t),BigUint64Array:t=>t instanceof e.BigUint64Array&&z(t),Date:t=>t instanceof e.Date?Number.isNaN(t.getDate())?`.`:t.toISOString():!1,DOMException:e=>{if(typeof e!=`object`||!e||e.constructor?.name!==`DOMException`)return!1;let t=e,n={message:t.message,name:t.name,stack:t.stack};return`cause`in t&&(n.cause=t.cause),n},EvalError:V(`EvalError`),FatalError:V(`FatalError`),HookConflictError:e=>{let t=Zn(`HookConflictError`,e);if(!t)return!1;let n=e,r={...t,token:n.token};return n.conflictingRunId!==void 0&&(r.conflictingRunId=n.conflictingRunId),r},RangeError:V(`RangeError`),ReferenceError:V(`ReferenceError`),RetryableError:e=>{let t=Zn(`RetryableError`,e);if(!t)return!1;let n=e.retryAfter,r;if(n&&typeof n==`object`&&typeof n.getTime==`function`){let e=n.getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else if(typeof n==`string`||typeof n==`number`){let e=new Date(n).getTime();r=Number.isNaN(e)?Date.now()+1e3:e}else r=Date.now()+1e3;return{...t,retryAfter:r}},RuntimeDecryptionError:e=>{let t=Zn(`RuntimeDecryptionError`,e);if(!t)return!1;let n={...t},r=e.context;return r!==void 0&&(n.context=r),n},SyntaxError:V(`SyntaxError`),TypeError:V(`TypeError`),URIError:V(`URIError`),AggregateError:e=>{let t=Zn(`AggregateError`,e);return t?{...t,errors:e.errors}:!1},Error:e=>{if(!ee.isNativeError(e))return!1;let t={name:e.name,message:e.message,stack:e.stack};return`cause`in e&&(t.cause=e.cause),t},Float32Array:t=>t instanceof e.Float32Array&&z(t),Float64Array:t=>t instanceof e.Float64Array&&z(t),Headers:t=>t instanceof e.Headers&&Array.from(t),Int8Array:t=>t instanceof e.Int8Array&&z(t),Int16Array:t=>t instanceof e.Int16Array&&z(t),Int32Array:t=>t instanceof e.Int32Array&&z(t),Map:t=>t instanceof e.Map&&Array.from(t),RegExp:t=>t instanceof e.RegExp&&{source:t.source,flags:t.flags},Set:t=>t instanceof e.Set&&Array.from(t),URL:t=>t instanceof e.URL&&t.href,WorkflowFunction:e=>{if(typeof e!=`function`)return!1;let t=e.workflowId;return typeof t==`string`&&{workflowId:t}},URLSearchParams:t=>t instanceof e.URLSearchParams?t.size===0?`.`:String(t):!1,Uint8Array:t=>t instanceof e.Uint8Array&&z(t),Uint8ClampedArray:t=>t instanceof e.Uint8ClampedArray&&z(t),Uint16Array:t=>t instanceof e.Uint16Array&&z(t),Uint32Array:t=>t instanceof e.Uint32Array&&z(t)}}function er(e=globalThis){return{ArrayBuffer:t=>B(t,e),BigInt:t=>e.BigInt(t),BigInt64Array:t=>new e.BigInt64Array(B(t,e)),BigUint64Array:t=>new e.BigUint64Array(B(t,e)),Date:t=>new e.Date(t),DOMException:t=>{let n=new e.DOMException(t.message,t.name);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},EvalError:Qn(e,`EvalError`),FatalError:t=>{let n=new(e[Symbol.for(`@workflow/errors//FatalError`)]??f)(t.message);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},HookConflictError:t=>{let n=new(e[Symbol.for(`@workflow/errors//HookConflictError`)]??u)(t.token,t.conflictingRunId);return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RangeError:Qn(e,`RangeError`),ReferenceError:Qn(e,`ReferenceError`),RetryableError:t=>{let n=new(e[Symbol.for(`@workflow/errors//RetryableError`)]??g)(t.message,{retryAfter:new e.Date(t.retryAfter)});return t.stack!==void 0&&(n.stack=t.stack),`cause`in t&&(n.cause=t.cause),n},RuntimeDecryptionError:t=>{let n=e[Symbol.for(`@workflow/errors//RuntimeDecryptionError`)]??h,r={};`cause`in t&&(r.cause=t.cause),t.context!==void 0&&(r.context=t.context);let i=new n(t.message,r);return t.stack!==void 0&&(i.stack=t.stack),i},SyntaxError:Qn(e,`SyntaxError`),TypeError:Qn(e,`TypeError`),URIError:Qn(e,`URIError`),AggregateError:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.AggregateError(t.errors,t.message,n);return t.stack!==void 0&&(r.stack=t.stack),r},Error:t=>{let n=`cause`in t?{cause:t.cause}:void 0,r=new e.Error(t.message,n);return r.name=t.name,t.stack!==void 0&&(r.stack=t.stack),r},Float32Array:t=>new e.Float32Array(B(t,e)),Float64Array:t=>new e.Float64Array(B(t,e)),Headers:t=>new e.Headers(t),Int8Array:t=>new e.Int8Array(B(t,e)),Int16Array:t=>new e.Int16Array(B(t,e)),Int32Array:t=>new e.Int32Array(B(t,e)),Map:t=>new e.Map(t),RegExp:t=>new e.RegExp(t.source,t.flags),Set:t=>new e.Set(t),URL:t=>new e.URL(t),WorkflowFunction:e=>Object.assign(()=>{throw Error(`Workflow functions cannot be called directly. Use start() to invoke them.`)},{workflowId:e.workflowId}),URLSearchParams:t=>new e.URLSearchParams(t===`.`?``:t),Uint8Array:t=>new e.Uint8Array(B(t,e)),Uint8ClampedArray:t=>new e.Uint8ClampedArray(B(t,e)),Uint16Array:t=>new e.Uint16Array(B(t,e)),Uint32Array:t=>new e.Uint32Array(B(t,e))}}function tr(){return{StepFunction:e=>{if(typeof e!=`function`)return!1;let t=e.stepId;if(typeof t!=`string`)return!1;let n=e.__closureVarsFn,r=n&&typeof n==`function`?n():void 0,i=`__boundThis`in e,a=i?e.__boundThis:void 0,o=e.__boundArgs,s={stepId:t};return r!==void 0&&(s.closureVars=r),i&&(s.boundThis=a),Array.isArray(o)&&o.length>0&&(s.boundArgs=o),s}}}function nr(e=globalThis){let t=e[Symbol.for(`WORKFLOW_USE_STEP`)];return{StepFunction:e=>{let n=e.stepId,r=e.closureVars;if(!t)throw Error(`WORKFLOW_USE_STEP not found on global object. Step functions cannot be deserialized outside workflow context.`);let i=r?t(n,()=>r):t(n);if(`boundThis`in e){let t=Array.isArray(e.boundArgs)?e.boundArgs:[];return i.bind(e.boundThis,...t)}return i}}}function rr(e){return e.length===4&&/^[a-z0-9]{4}$/.test(e)}const H={DEVALUE_V1:`devl`,ENCRYPTED:`encr`,SEALED:`encp`,GZIP:`gzip`,ZSTD:`zstd`},ir=new TextEncoder,ar=new TextDecoder;function or(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...Kn(),...tr(),...$n(t)};break;case`step`:r={...Kn(),...$n(t)};break;case`client`:r={...Kn(),...$n(t)};break}return n?{...r,...n}:r}function sr(e,t=globalThis,n){let r;switch(e){case`workflow`:r={...qn(t),...nr(t),...er(t)};break;case`step`:r={...qn(t),...er(t)};break;case`client`:r={...qn(t),...er(t),StepFunction:()=>{throw Error(`Step functions cannot be deserialized in client context.`)}};break}return n?{...r,...n}:r}const U={formatPrefix:H.DEVALUE_V1,serialize(e,t,n){let r=N(e,or(t,n?.global,n?.extraReducers));return ir.encode(r)},deserialize(e,t,n){let r=sr(t,n?.global,n?.extraRevivers);return jt(ar.decode(e),r)},deserializeLegacy(e,t,n){return Mt(e,sr(t,n?.global,n?.extraRevivers))}},cr=new TextEncoder,lr=new TextDecoder;function W(e,t){if(!(t instanceof Uint8Array))return t;let n=cr.encode(e),r=new Uint8Array(4+t.length);return r.set(n,0),r.set(t,4),r}function ur(e){if(!(e instanceof Uint8Array)||e.length<4)return null;let t=e.subarray(0,4),n=lr.decode(t);return rr(n)?n:null}function G(e){if(!(e instanceof Uint8Array))return{format:H.DEVALUE_V1,payload:new TextEncoder().encode(JSON.stringify(e))};if(e.length<4)throw Error(`Data too short to contain format prefix: expected at least 4 bytes, got ${e.length}`);let t=e.subarray(0,4),n=lr.decode(t);if(!rr(n))throw Error(`Invalid format prefix: "${n}". Must be 4 characters of [a-z0-9].`);return{format:n,payload:e.subarray(4)}}function dr(){try{return typeof process<`u`&&process.env?.WORKFLOW_DISABLE_COMPRESSION===`1`}catch{return!1}}function fr(){try{let e=process.env?.WORKFLOW_COMPRESSION_CODEC;return e===`gzip`||e===`zstd`?e:void 0}catch{return}}function pr(){try{return globalThis.process?.getBuiltinModule?.(`node:zlib`)}catch{return}}function mr(){let e=pr();return typeof e?.zstdCompressSync==`function`&&typeof e?.zstdDecompressSync==`function`}function hr(){return typeof CompressionStream==`function`&&typeof DecompressionStream==`function`}async function gr(e,t){let n=t.writable.getWriter(),r=n.write(e).then(()=>n.close());r.catch(()=>{});let i=[],a=0,o=t.readable.getReader();for(;;){let{done:e,value:t}=await o.read();if(e)break;i.push(t),a+=t.length}await r;let s=new Uint8Array(a),c=0;for(let e of i)s.set(e,c),c+=e.length;return s}async function _r(e){return gr(e,new CompressionStream(`gzip`))}async function vr(e){return gr(e,new DecompressionStream(`gzip`))}function yr(e){let t=pr(),n=t?.constants?.ZSTD_c_compressionLevel,r=n===void 0?void 0:{params:{[n]:3}};return new Uint8Array(t.zstdCompressSync(e,r))}function br(e){let t=pr();if(!t?.zstdDecompressSync)throw Error(`Compressed (zstd) workflow data encountered but node:zlib zstd support is not available in this runtime (requires Node.js 22.15+). In the browser, register a zstd decoder via registerZstdDecoder (serialization-format.ts).`);return new Uint8Array(t.zstdDecompressSync(e))}function xr(e,t,n,r){e&&(e.recorded=!0,e.compressed=t!==`none`,e.codec=t,e.uncompressedBytes=n,e.storedBytes=r)}function Sr(){return fr()===`gzip`?hr()?`gzip`:`none`:mr()?`zstd`:hr()?`gzip`:`none`}async function Cr(e,t,n){if(!(e instanceof Uint8Array))return e;if(!t||e.length<1024||dr())return xr(n,`none`,e.length,e.length),e;let r=Sr();if(r===`none`)return xr(n,`none`,e.length,e.length),e;let i=r===`zstd`?yr(e):await _r(e),a=r===`zstd`?H.ZSTD:H.GZIP,o=4+i.length;return o>=e.length*.95?(xr(n,`none`,e.length,e.length),e):(xr(n,r,e.length,o),W(a,i))}async function wr(e,t){if(!(e instanceof Uint8Array))return e;let n=ur(e);if(n===H.ZSTD){let{payload:n}=G(e),r=br(n);return xr(t,`zstd`,r.length,e.length),r}if(n===H.GZIP){if(!hr())throw Error(`Compressed (gzip) workflow data encountered but DecompressionStream is not available in this runtime. Node.js 18+, browsers, and edge runtimes all support it.`);let{payload:n}=G(e),r=await vr(n);return xr(t,`gzip`,r.length,e.length),r}return xr(t,`none`,e.length,e.length),e}const Tr=Symbol.for(`workflow.serialization.sealTarget`),Er=Symbol.for(`workflow.serialization.runKeys`);function Dr(e,t){return{[Tr]:!0,recipientPublicKey:e,aad:t}}function Or(e,t,n){return{[Er]:!0,aes:e,keyPair:t,aad:n}}async function kr(e){let[t,n]=await Promise.all([It(e),Ut(e)]);return Or(t,n)}function Ar(e){return typeof e==`object`&&!!e&&e[Tr]===!0}function jr(e){return typeof e==`object`&&!!e&&e[Er]===!0}function Mr(e){if(e){if(jr(e))return e.aes;if(!Ar(e))return e}}async function Nr(e){return typeof e==`function`?e():e}async function Pr(e,t){if(!t||!(e instanceof Uint8Array))return e;if(Ar(t)){let n=await en(t.recipientPublicKey,e,t.aad);return W(H.SEALED,n)}let n=await Lt(jr(t)?t.aes:t,e);return W(H.ENCRYPTED,n)}async function Fr(e,t){if(!jr(t))throw new h(`Sealed data encountered but no run keypair is available. Opening a sealed payload requires the run's own encryption key material; a symmetric key or a seal-only target cannot decrypt it.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encp`}});let{payload:n}=G(e);try{return await tn(t.keyPair,n,t.aad)}catch(e){throw h.is(e)&&e.context&&(e.context.formatPrefix=H.SEALED),e}}async function Ir(e,t){if(!(e instanceof Uint8Array))return e;let n=ur(e);if(n===H.SEALED)return Fr(e,t);if(n!==H.ENCRYPTED)return e;let r=Mr(t);if(!r)throw new h(`Encrypted data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:e.byteLength,formatPrefix:`encr`}});let{payload:i}=G(e);try{return await Rt(r,i)}catch(e){throw h.is(e)&&e.context&&(e.context.formatPrefix=n),e}}function Lr(e,t,n){let[r,...i]=t.split(`
|
|
6
|
+
`),a=i.join(`
|
|
7
|
+
`),o=Rr(r??``,n),s=zr(a),c=[`${e} ${r??``}`];return o&&c.push(o),s&&c.push(s),c.join(`
|
|
8
|
+
`)}function Rr(e,t){if(!t||Object.keys(t).length===0)return null;let n=new Set;n.add(`errorStack`),typeof t.errorMessage==`string`&&e.includes(t.errorMessage)&&n.add(`errorMessage`);let r=new Set([`workflowRunId`,`workflowName`,`stepId`,`stepName`,`errorAttribution`,`errorCode`,`errorName`,`errorMessage`,`errorStack`,`hint`,`attempt`,`retryCount`]),i=[],a=K(t,`errorName`),o=K(t,`errorAttribution`);if(a||o){let e=o?o===`sdk`?_e(`sdk error`):ge(`user error`):``,t=a?he(a):``,n=e&&t?D(` · `):``;i.push(` ${e}${n}${t}`)}let s=K(t,`workflowRunId`),c=K(t,`workflowName`);s?i.push(Hr(`run`,s,c,ae)):c&&i.push(Hr(`run`,null,c,ae));let l=K(t,`stepId`),u=K(t,`stepName`);if((l||u)&&i.push(Hr(`step`,l,u,ie)),t.attempt!==void 0||t.retryCount!==void 0){let e=t.attempt,n=t.retryCount;e!==void 0&&n!==void 0?i.push(` ${Vr(`retry`)} ${e} ${D(`attempts ·`)} ${n} ${D(`max retries`)}`):e!==void 0&&i.push(` ${Vr(`retry`)} ${e} ${D(`attempts`)}`)}let d=K(t,`errorCode`);d&&d!==a&&i.push(` ${Vr(`code`)} ${D(d)}`);let f=K(t,`hint`);f&&i.push(` ${fe(f)}`);let p=Object.entries(t).filter(([e,t])=>!r.has(e)&&!n.has(e)&&t!=null).sort(([e],[t])=>e.localeCompare(t));for(let[e,t]of p)i.push(` ${Vr(e)} ${Ur(t)}`);return i.length?i.join(`
|
|
9
|
+
`):null}function zr(e){if(!e)return null;let t=e.split(`
|
|
10
|
+
`),n=[],r=0,i=0,a=0,o=()=>{r>0&&(n.push(D(` … ${r} more ${r===1?`frame`:`frames`} in framework internals`)),r=0)};for(let e of t){let t=e.trimStart().startsWith(`at `);if(t&&Br(e)){r++;continue}if(t&&i>=6){a++;continue}o(),n.push(e),t&&i++}return o(),a>0&&n.push(D(` … ${a} more ${a===1?`frame`:`frames`} (run \`pnpm wf inspect run <id>\` for the full stack)`)),n.join(`
|
|
11
|
+
`)}function Br(e){let t=e.trimStart();return t.startsWith(`at `)?!!(t.includes(`node:internal/`)||t.includes(`node_modules/.pnpm/`)||t.includes(`node_modules__pnpm_`)||t.includes(`_next_dist_`)||t.includes(`node_modules/next/`)||t.includes(`node_modules/@opentelemetry/`)||t.includes(`node_modules/vitest/`)||t.includes(`node_modules/@vitest/`)):!1}function K(e,t){let n=e[t];return typeof n==`string`&&n.length>0?n:null}function Vr(e){return D(e.padEnd(6))}function Hr(e,t,n,r){let i=t||D(`—`),a=n&&(e===`run`?re(n):C(n))?`${D(`·`)} ${r(n)}`:``;return` ${Vr(e)} ${i}${a?` `+a:``}`}function Ur(e){if(typeof e==`string`)return e.includes(`
|
|
12
|
+
`)?e.split(`
|
|
13
|
+
`).map((e,t)=>t===0?e:` ${e}`).join(`
|
|
14
|
+
`):e;if(typeof e==`number`||typeof e==`boolean`)return String(e);try{return JSON.stringify(e)}catch{return String(e)}}var Wr=class e extends Error{steps;globalThis;stepCount;hookCount;waitCount;attributeCount;hookDisposedCount;abortCount;constructor(e,t){let n=[...e.values()],r=0,i=0,a=0,o=0,s=0,c=0;for(let e of n)e.type===`step`?r++:e.type===`hook`?e.disposed?s++:e.abortRequested?c++:i++:e.type===`wait`?a++:e.type===`attribute`&&o++;let l=[];r>0&&l.push(`${r} ${w(`step`,`steps`,r)}`),i>0&&l.push(`${i} ${w(`hook`,`hooks`,i)}`),a>0&&l.push(`${a} ${w(`wait`,`waits`,a)}`),o>0&&l.push(`${o} ${w(`attribute write`,`attribute writes`,o)}`),s>0&&l.push(`${s} hook ${w(`disposal`,`disposals`,s)}`);let u=w(`has`,`have`,r+i+a+o+s),d=+(r>0)+ +(i>0)+ +(a>0)+ +(o>0)+ +(s>0),f;f=d>1?`processed`:r>0?`run`:i>0||a>0?`created`:o>0?`written`:s>0?`processed`:`received`;let p=l.length>0?`${l.join(` and `)} ${u} not been ${f} yet`:`0 steps have not been run yet`;super(p),this.name=`WorkflowSuspension`,this.steps=n,this.globalThis=t,this.stepCount=r,this.hookCount=i,this.waitCount=a,this.attributeCount=o,this.hookDisposedCount=s,this.abortCount=c}static is(t){return t instanceof e}};function Gr(){throw new c(`This API is not available inside a workflow function. Workflow functions run in a deterministic VM; move the call to a step function for full Node.js access.`)}function q(...e){return t=>Object.fromEntries(e.map(e=>[e,t]))}const Kr=q(`workflow.name`),qr=q(`workflow.operation`),Jr=q(`workflow.run.id`),Yr=q(`workflow.run.status`),Xr=q(`workflow.started_at`),Zr=q(`workflow.events.count`),Qr=q(`workflow.arguments.count`),$r=q(`workflow.result.type`),ei=q(`workflow.trace.propagated`),ti=q(`workflow.trace.mode`),ni=q(`workflow.turbo`),ri=q(`workflow.error.name`),ii=q(`workflow.error.message`),ai=q(`workflow.error.code`),oi=q(`workflow.steps.created`),si=q(`workflow.hooks.created`),ci=q(`workflow.waits.created`),li=q(`workflow.inline_ownership.owned_recovery_steps`),ui=q(`workflow.inline_ownership.backstop_wakes_armed`),di=q(`workflow.route.type`),fi=q(`workflow.route.handler_cached`),pi=q(`workflow.route.invocation_count`),mi=q(`workflow.route.entrypoint_age_ms`),hi=q(`workflow.route.module_body_init_ms`),gi=q(`step.name`),_i=q(`step.id`),vi=q(`step.attempt`),yi=q(`step.status`),bi=q(`step.max_retries`),xi=q(`step.ttfs_ms`),Si=q(`step.stso_ms`),Ci=q(`step.rsfs_ms`),wi=q(`step.final_scheduling_replay_ms`),Ti=q(`step.latency_optimizations`),Ei=q(`step.skipped`),Di=q(`step.skip_reason`),Oi=q(`step.arguments.count`),ki=q(`step.result.type`),Ai=q(`step.error.name`),ji=q(`step.error.message`),Mi=q(`step.fatal_error`),Ni=q(`step.retry.exhausted`),Pi=q(`step.retry.timeout_seconds`),Fi=q(`step.retry.will_retry`),Ii=q(`messaging.system`),Li=q(`messaging.destination.name`),Ri=q(`messaging.message.id`),zi=q(`messaging.operation.type`),Bi=q(`workflow.queue.overhead_ms`),Vi=q(`deployment.id`),Hi=q(`workflow.hook.token`),Ui=q(`workflow.hook.id`),Wi=q(`workflow.hook.found`),Gi=q(`workflow.suspension.state`),Ki=q(`workflow.suspension.hook_count`),qi=q(`workflow.suspension.step_count`),Ji=q(`workflow.suspension.wait_count`),Yi=q(`http.request.method`),Xi=q(`http.route`),Zi=q(`http.response.status_code`),Qi=q(`error.type`),$i=q(`workflow.events.pages_loaded`),ea=q(`workflow.queue.deserialize_time_ms`),ta=q(`workflow.queue.execution_time_ms`),na=q(`workflow.queue.serialize_time_ms`),ra=q(`workflow.serialization.operation`),ia=q(`workflow.serialization.compressed`),aa=q(`workflow.serialization.codec`),oa=q(`workflow.serialization.uncompressed_bytes`),sa=q(`workflow.serialization.stored_bytes`),ca=q(`workflow.serialization.compression_ratio`),la=q(`peer.service`),ua=q(`rpc.system`),da=q(`rpc.service`),fa=q(`rpc.method`),pa=q(`error.retryable`),ma=q(`error.category`),ha=new Set;function ga(){let e=process.env.WORKFLOW_TRACE_MODE;return e===`continuous`?`continuous`:(e&&e!==`linked`&&!ha.has(e)&&(ha.add(e),Y.warn(`Unrecognized WORKFLOW_TRACE_MODE value "${e}"; expected "linked" or "continuous". Falling back to "linked".`)),`linked`)}function _a(e){return e!==void 0&&Object.keys(e).length>0}function va(e,t){return e===`linked`&&_a(t)?Promise.resolve(t):ba()}async function ya(e,t){if(e!==`linked`)return Na();let n=await Pa(_a(t)?t:void 0);return n?[n]:void 0}async function ba(){let e=await J.value;if(!e)return{};let t={};return e.propagation.inject(e.context.active(),t),t}async function xa(e){let t=await J.value;if(t)return t.propagation.extract(t.context.active(),e)}async function Sa(e,t){if(!e)return t();let n=await J.value;if(!n)return t();let r=await xa(e);return r?n.context.with(r,async()=>await t()):t()}const J=r(async()=>{try{return await import(`./src-Cj3P1ChQ.js`).then(t=>e(t.t(),1))}catch{return Y.info(`OpenTelemetry not available, tracing will be disabled`),null}}),Ca=r(async()=>{let e=await J.value;if(!e)return null;let t=e.trace.getTracer(`workflow`);return Ta(e,t),t});let wa=!1;function Ta(e,t){let n=typeof process<`u`&&typeof process.env.DEBUG==`string`&&(process.env.DEBUG.includes(`workflow:`)||process.env.DEBUG===`*`);if(!(wa||!n)){wa=!0;try{let n=globalThis[Symbol.for(`opentelemetry.js.api.1`)],r=e.trace.getTracerProvider(),i=r.getDelegate?.()??r,a=t.startSpan(`workflow.otel.probe.core`);console.warn(`[workflow:otel-diag] core`,JSON.stringify({globalRegistrationVersion:n?.version??null,providerCtor:r?.constructor?.name??null,delegateCtor:i?.constructor?.name??null,tracerCtor:t?.constructor?.name??null,probeCtor:a?.constructor?.name??null,probeRecording:a.isRecording()})),a.end()}catch(e){console.warn(`[workflow:otel-diag] core failed:`,e instanceof Error?e.message:e)}}}async function Ea(e,...t){let[n,r]=await Promise.all([Ca.value,J.value]),{fn:i,opts:a}=typeof t[0]==`function`?{fn:t[0],opts:{}}:{fn:t[1],opts:t[0]};if(!i)throw Error(`Function to trace must be provided`);return!n||!r?await i():n.startActiveSpan(e,a,async e=>{try{let t=await i(e);return e.setStatus({code:r.SpanStatusCode.OK}),t}catch(t){throw e.setStatus({code:r.SpanStatusCode.ERROR,message:t.message}),Oa(t,r,e),t}finally{e.end()}})}async function Da(e,t,n){let r=await Ca.value;r&&r.startSpan(e,{...n,startTime:t}).end()}function Oa(e,t,n){!e||!Wr.is(e)||(n.setStatus({code:t.SpanStatusCode.OK}),n.setAttributes({...Gi(`suspended`),...qi(e.stepCount),...Ki(e.hookCount),...Ji(e.waitCount)}))}async function ka(e){let[t,n]=await Promise.all([xa(e),J.value]);if(!(!t||!n))return n.trace.getSpanContext(t)}async function Aa(){return await Ma(e=>e.trace.getActiveSpan())}async function ja(e){return Ma(t=>t.SpanKind[e])}async function Ma(e){let t=await J.value;if(t)return await e(t)}function Na(){return Ma(e=>{let t=e.trace.getActiveSpan()?.spanContext();if(t)return[{context:t}]})}async function Pa(e){if(!e)return;let[t,n]=await Promise.all([ka(e),J.value]);if(!(!t||!n)&&n.trace.isSpanContextValid(t))return{context:t}}async function Fa(e,t){let n=await J.value;if(!n)return t();let r=n.propagation.createBaggage({"workflow.run_id":{value:e.workflowRunId},"workflow.name":{value:e.workflowName}}),i=n.propagation.setBaggage(n.context.active(),r);return n.context.with(i,()=>t())}function Ia(e,t){if(!t)return!1;let n=!1;for(let r of t.split(`,`)){let t=r.trim();if(!t)continue;let i=t.startsWith(`-`),a=i?t.slice(1):t;RegExp(`^${a.replace(/[|\\{}()[\]^$+?.]/g,`\\$&`).replace(/\*/g,`.*`)}$`).test(e)&&(n=!i)}return n}function La(e,t={}){let n=r=>{let i=n=>t.debugNamespace??`workflow:${e}:${n}`,a=t=>{let n=i(t);return(i,a)=>{let o=Object.keys(r).length>0,s=a&&Object.keys(a).length>0,c=o||s?{...r,...a??{}}:void 0;(t===`error`||t===`warn`)&&(t===`error`?console.error:console.warn)(Lr(`[workflow-sdk]`,i,c)),Ia(n,process.env.DEBUG)&&(console.debug(`[${n}] ${i}`,c??``),Aa().then(n=>{n?.addEvent(`${t}.${e}`,{message:i,...c})}).catch(()=>{}))}};return{debug:a(`debug`),info:a(`info`),warn:a(`warn`),error:a(`error`),child:e=>n({...r,...e}),forRun:(e,t,i)=>n({...r,workflowRunId:e,...t===void 0?{}:{workflowName:t},...i??{}})}};return n({})}const Ra=La(`step`),Y=La(`runtime`),za=La(`webhook`),Ba=La(`events`);La(`adapter`),La(`build`,{debugNamespace:`workflow:build`});function Va(e){if(h.is(e))throw e}function X(e,t){let n=e.includes(`return value`)?`returning`:`passing`,r=`Failed to serialize ${e}`;t instanceof j&&t.path&&(r+=` at path "${t.path}"`);let i=`Ensure you're ${n} workflow serializable types. Check the serialization docs to see what's serializable: https://workflow-sdk.dev/docs/foundations/serialization`;return t instanceof j&&t.value!==void 0&&Y.error(`Serialization failed`,{context:e,problematicValue:t.value}),{message:r,hint:i}}async function Ha(e,t,n){try{let r=U.serialize(e,`client`,n);return Pr(await Cr(W(H.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){Va(e);let{message:t,hint:n}=X(`client value`,e);throw new m(t,{hint:n,cause:e})}}async function Ua(e,t,n){let r=await wr(await Ir(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(U.deserializeLegacy)return U.deserializeLegacy(r,`client`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=G(r);if(i===H.DEVALUE_V1)return U.deserialize(a,`client`,n);throw Error(`Unsupported serialization format: ${i}`)}async function Wa(e,t,n){try{let r=U.serialize(e,`step`,n);return Pr(await Cr(W(H.DEVALUE_V1,r),n?.compression===!0,n?.compressionStats),t)}catch(e){Va(e);let{message:t,hint:n}=X(`step value`,e);throw new m(t,{hint:n,cause:e})}}async function Ga(e,t,n){let r=await wr(await Ir(e,t),n?.compressionStats);if(!(r instanceof Uint8Array)){if(U.deserializeLegacy)return U.deserializeLegacy(r,`step`,n);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:i,payload:a}=G(r);if(i===H.DEVALUE_V1)return U.deserialize(a,`step`,n);throw Error(`Unsupported serialization format: ${i}`)}function Ka(e,t){if(!(e instanceof Uint8Array)){if(U.deserializeLegacy)return U.deserializeLegacy(e,`workflow`,t);throw Error(`Cannot deserialize non-binary data without legacy support`)}let{format:n,payload:r}=G(e);if(n===H.DEVALUE_V1)return U.deserialize(r,`workflow`,t);throw Error(`Unsupported serialization format: ${n}`)}const qa=Symbol.for(`WORKFLOW_STEP_CONTEXT_STORAGE`),Ja=globalThis[qa]??(globalThis[qa]=new te);function Ya(e,t,n){if(e===0&&t===0&&n===0)return null;let r=[];e>0&&r.push(`${e} ${w(`step`,`steps`,e)}`),t>0&&r.push(`${t} ${w(`hook`,`hooks`,t)}`),n>0&&r.push(`${n} ${w(`timer`,`timers`,n)}`);let i=[];e>0&&i.push(`steps are completed`),t>0&&i.push(`hooks are received`),n>0&&i.push(`timers have elapsed`);let a=i.join(` and `);return`${r.join(` and `)} to be enqueued\n Workflow will suspend and resume when ${a}`}function Xa(e,t){let n=`${e.replace(`wrun_`,`strm_`)}_user`;return t?`${n}_${Buffer.from(t,`utf-8`).toString(`base64url`)}`:n}function Za(e){return`strm_${e}_system_abort`}function Qa(e){if(!e.startsWith(`abrt_`))throw Error(`Invalid abort hook token format: expected "abrt_" prefix, got "${e}"`);return Za(e.slice(5))}const $a=()=>S(`WORKFLOW_DEFERRED_CHECK_DELAY_MS`,100,{integer:!0,min:10});var Z;(function(e){e[e.Consumed=0]=`Consumed`,e[e.NotConsumed=1]=`NotConsumed`,e[e.Finished=2]=`Finished`})(Z||={});var eo=class{eventIndex;events=[];callbacks=[];onConsumedEvent;onUnconsumedEvent;getPromiseQueue;pendingUnconsumedCheck=null;pendingUnconsumedTimeout=null;unconsumedCheckVersion=0;constructor(e,t){this.events=e,this.eventIndex=0,this.onConsumedEvent=t.onConsumedEvent,this.onUnconsumedEvent=t.onUnconsumedEvent,this.getPromiseQueue=t.getPromiseQueue}subscribe(e){this.callbacks.push(e),this.pendingUnconsumedCheck!==null&&(this.unconsumedCheckVersion++,this.pendingUnconsumedCheck=null,this.pendingUnconsumedTimeout!==null&&(clearTimeout(this.pendingUnconsumedTimeout),this.pendingUnconsumedTimeout=null)),process.nextTick(this.consume)}notifyConsumedEvent(e){if(this.onConsumedEvent)try{this.onConsumedEvent(e)}catch(e){Ba.error(`onConsumedEvent callback threw an error`,{error:e})}}consume=()=>{for(;;){let e=this.events[this.eventIndex]??null;if(!this.consumeOne(e)){this.handleUnconsumed(e);return}}};consumeOne(e){for(let t=0;t<this.callbacks.length;t++){let n=this.callbacks[t],r=Z.NotConsumed;try{r=n(e)}catch(e){Ba.error(`EventConsumer callback threw an error`,{error:e})}if(!(r!==Z.Consumed&&r!==Z.Finished))return e!==null&&this.notifyConsumedEvent(e),this.eventIndex++,r===Z.Finished&&this.callbacks.splice(t,1),e!==null}return!1}handleUnconsumed(e){if(e!==null){let t=++this.unconsumedCheckVersion;this.pendingUnconsumedCheck=this.getPromiseQueue().then(()=>new Promise(e=>setTimeout(e,0))).then(()=>this.getPromiseQueue()).then(()=>{this.pendingUnconsumedTimeout=setTimeout(()=>{this.pendingUnconsumedTimeout=null,this.unconsumedCheckVersion===t&&(this.pendingUnconsumedCheck=null,this.onUnconsumedEvent(e))},$a())})}}},to=class{aborted=!1;reason=void 0;[L];[R];#e=[];#t=null;get onabort(){return this.#t}set onabort(e){this.#t=e,e&&this.aborted&&e.call(this)}constructor(e,t){this[L]=e,this[R]=t}_setAborted(e){if(!this.aborted){this.aborted=!0,this.reason=e,this.#t&&this.#t.call(this);for(let e of this.#e)e();this.#e=[]}}addEventListener(e,t){if(e===`abort`){if(this.aborted){t();return}this.#e.push(t)}}removeEventListener(e,t){e===`abort`&&(this.#e=this.#e.filter(e=>e!==t))}throwIfAborted(){if(this.aborted)throw this.reason??new DOMException(`The operation was aborted.`,`AbortError`)}};function no(e){return class{signal;[L];[R];constructor(){let t=e.generateUlid(),n=Za(t),r=`abrt_${t}`;this[L]=n,this[R]=r,this.signal=new to(n,r);let a=`hook_${e.generateUlid()}`;e.invocationsQueue.set(a,{type:`hook`,correlationId:a,token:r,isWebhook:!1,isSystem:!0}),e.eventsConsumer.subscribe(t=>{if(!t||t.correlationId!==a)return Z.NotConsumed;let n=`eventData`in t&&t.eventData&&`token`in t.eventData?t.eventData.token:void 0;if(typeof n==`string`&&n!==this[R])return e.promiseQueue=e.promiseQueue.then(()=>{e.onWorkflowError(new p(`Replay divergence: abort hook event ${t.eventType} for ${a} belongs to token "${n}", but the current abort hook expects "${this[R]}"`,{eventId:t.eventId}))}),Z.Finished;if(t.eventType===`hook_created`){let t=e.invocationsQueue.get(a);return t&&t.type===`hook`&&(t.hasCreatedEvent=!0),Z.Consumed}if(t.eventType===`hook_received`){let n=t.eventData?.payload,r=e.eventsConsumer.eventIndex,s=i(e,r,`hook`),c=o(e,r,`hook`);return e.pendingDeliveries++,e.promiseQueue=e.promiseQueue.then(async()=>{let r;try{if(n!==void 0)try{let i=await e.replayPayloadCache.prepareEventPayload(t.eventId,`payload`,n),a=await ts(n,e.runId,e.encryptionKey,e.globalThis,{},i);a&&typeof a==`object`&&`reason`in a&&(r=a.reason)}catch{}}finally{e.pendingDeliveries--}c.then(()=>{s.markDelivered(),this.signal._setAborted(r)})}),e.invocationsQueue.delete(a),Z.Consumed}return t.eventType===`hook_disposed`?(e.invocationsQueue.delete(a),Z.Finished):Z.NotConsumed})}abort(t){if(!this.signal.aborted){this.signal._setAborted(t);for(let[,n]of e.invocationsQueue)if(n.type===`hook`&&n.token===this[R]){n.abortRequested=!0,n.abortReason=t;break}}}}}function ro(){return{abort(e){let t=new to(``,``);return t._setAborted(e??new DOMException(`The operation was aborted.`,`AbortError`)),t},any(e){let t=new to(``,``),n=Array.from(e);for(let e of n)if(e.aborted)return t._setAborted(e.reason),t;let r=[],i=()=>{for(let{signal:e,listener:t}of r)e.removeEventListener&&e.removeEventListener(`abort`,t);r.length=0};for(let e of n){if(!e.addEventListener)continue;let n=()=>{t.aborted||(t._setAborted(e.reason),i())};r.push({signal:e,listener:n}),e.addEventListener(`abort`,n)}return t},timeout(){throw Error(`AbortSignal.timeout() is not supported in workflow functions. Use sleep() with an AbortController instead. See: /docs/errors/abort-signal-timeout-in-workflow`)}}}const io=b();function ao(e){try{return e.getReader({mode:`byob`}).releaseLock(),`bytes`}catch{}}function oo(e){return Va(e),e instanceof m&&e.cause!==void 0||e instanceof c&&e.cause!==void 0?e.cause:e}async function Q(e,t){if(e.recorded)try{let n=await Aa();if(!n)return;let r=e.uncompressedBytes??0,i=e.storedBytes??0;n.setAttributes({...ra(t),...ia(e.compressed??!1),...aa(e.codec??`none`),...oa(r),...sa(i),...e.compressed&&r>0?ca(1-i/r):{}})}catch{}}function so(e,t){let n=new TextEncoder,r={resolved:!1,key:void 0},i;return new TransformStream({async transform(a,o){try{r.resolved||(r.key=await Nr(t),r.resolved=!0,Ar(r.key)&&(i=nn(r.key.recipientPublicKey,r.key.aad)));let s=N(a,e),c=n.encode(s),l=W(H.DEVALUE_V1,c);i?l=W(H.SEALED,await i.seal(l)):r.key&&(l=await Pr(l,r.key));let u=new Uint8Array(4+l.length);new DataView(u.buffer).setUint32(0,l.length,!1),u.set(l,4),o.enqueue(u)}catch(e){if(h.is(e)){o.error(e);return}let{message:t,hint:n}=X(`stream chunk`,e);o.error(new m(t,{hint:n,cause:e}))}}})}function co(e,t){let n=new TextDecoder,r=new Uint8Array,i={resolved:!1,key:void 0},a;function o(e){let t=new Uint8Array(r.length+e.length);t.set(r,0),t.set(e,r.length),r=t}async function s(o){for(i.resolved||(i.key=await Nr(t),i.resolved=!0,jr(i.key)&&(a=rn(i.key.keyPair,i.key.aad)));r.length>=4;){let t=new DataView(r.buffer,r.byteOffset,r.byteLength).getUint32(0,!1);if(r.length<4+t)break;let s=r.slice(4,4+t);r=r.slice(4+t);let{format:c,payload:l}=G(s);if(c===H.ENCRYPTED||c===H.SEALED){let e=c===H.SEALED;if(!(e?jr(i.key):Mr(i.key)!==void 0)){o.error(new h(e?`Sealed stream data encountered but no run keypair is available. Opening a sealed frame requires the run's own encryption key material.`:`Encrypted stream data encountered but no encryption key is available. Encryption is not configured or no key was provided for this run.`,{context:{operation:`decrypt`,byteLength:l.byteLength,formatPrefix:e?`encp`:`encr`}}));return}let t;try{t=e?await a.open(G(s).payload):await Ir(s,i.key)}catch(e){throw h.is(e)&&e.context&&(e.context.formatPrefix=c),e}({format:c,payload:l}=G(t))}if(c===H.DEVALUE_V1){let t=n.decode(l);o.enqueue(jt(t,e))}}}return new TransformStream({async transform(t,i){if(r.length===0&&t.length>=4){let e=new DataView(t.buffer,t.byteOffset,t.byteLength).getUint32(0,!1);if(e>0&&e<1e8){o(t),await s(i);return}}else if(r.length>0){o(t),await s(i);return}let a=n.decode(t).split(`
|
|
15
|
+
`);for(let t of a)t.length>0&&i.enqueue(jt(t,e))},async flush(e){r.length>0&&await s(e)}})}const lo=1e8;function uo(){return new TransformStream({transform(e,t){if(e.length===0)return;if(e.length>lo){t.error(new c(`Byte-stream chunk of ${e.length} bytes exceeds the maximum framed chunk size (${lo}). Split the data into smaller chunks before writing.`,{slug:`serialization-failed`}));return}let n=new Uint8Array(4+e.length);new DataView(n.buffer).setUint32(0,e.length,!1),n.set(e,4),t.enqueue(n)}})}function fo(){let e=new Uint8Array;function t(t){let n=new Uint8Array(e.length+t.length);n.set(e,0),n.set(t,e.length),e=n}return new TransformStream({transform(n,r){for(n.length>0&&t(n);e.length>=4;){let t=new DataView(e.buffer,e.byteOffset,e.byteLength).getUint32(0,!1);if(t>lo){r.error(new c(`Byte-stream frame length ${t} exceeds maximum (${lo}). This usually means a non-framed byte stream is being read as framed.`,{slug:`serialization-failed`}));return}let n=4+t;if(e.length<n)break;r.enqueue(e.slice(4,n)),e=e.slice(n)}},flush(t){e.length>0&&t.error(new c(`Byte-stream ended with ${e.length} bytes of incomplete frame data. The stream was truncated mid-frame.`,{slug:`serialization-failed`}))}})}function po(e,t,n,r,i){(async()=>{await Da(`workflow.stream.read`,e,{kind:await ja(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read`,"workflow.stream.read.ttfc_ms":Date.now()-e,...typeof i==`number`?{"workflow.stream.read.connect_ms":i}:{},...typeof r==`number`?{"workflow.stream.start_index":r}:{}}})})()}function mo(e,t,n,r,i,a){(async()=>{await Da(`workflow.stream.read.complete`,e,{kind:await ja(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`read_complete`,"workflow.stream.read.total_ms":Date.now()-e,"workflow.stream.read.chunks":r,"workflow.stream.read.bytes":i,...typeof a==`number`?{"workflow.stream.read.reconnects":a}:{}}})})()}var ho=class extends ReadableStream{#e;constructor(e,t,n){if(typeof t!=`string`||t.length===0)throw new c(`"name" is required, got "${t}"`);let r,i=!1,a,o=0,s=0;super({type:`bytes`,pull:async c=>{let l=this.#e;if(!l){r===void 0&&(r=Date.now());let i=await zn(),o=Date.now(),s=await i.streams.get(e,t,n);a=Date.now()-o,l=this.#e=s.getReader()}if(!l){c.error(Error(`Failed to get reader`));return}let u=await l.read();u.done?(this.#e=void 0,r!==void 0&&mo(r,e,t,o,s),c.close()):(!i&&u.value.byteLength>0&&r!==void 0&&(i=!0,po(r,e,t,n,a)),o+=1,s+=u.value.byteLength,c.enqueue(u.value))},cancel:async e=>{this.#e&&=(await this.#e.cancel(e).catch(()=>{}),void 0)}})}};const go=()=>S(`WORKFLOW_FRAMED_STREAM_MAX_RECONNECTS`,50,{integer:!0,min:1}),_o=()=>S(`WORKFLOW_FRAMED_STREAM_MAX_TOTAL_RECONNECTS`,1e3,{integer:!0,min:1});function vo(e,t,n){let r=n===void 0||n>=0,i=n??0,a=0,o=0,s=0,c,l=new Uint8Array,u,d,f=!1,p=0,m=0;async function h(){let o=await zn(),s=r?i+a:n,l=Date.now(),u=await o.streams.get(e,t,s);d===void 0&&(d=Date.now()-l),c=u.getReader()}async function g(){c&&=(await c.cancel().catch(()=>{}),void 0),i+=a,a=0,l=new Uint8Array;let e=go(),n=_o();for(;;){if(o++,s++,o>e)throw Error(`Stream "${t}" exceeded maximum reconnection attempts (${e})`);if(s>n)throw Error(`Stream "${t}" exceeded maximum total reconnection attempts (${n})`);try{await h();return}catch{}}}return new ReadableStream({pull:async i=>{for(u===void 0&&(u=Date.now());;){if(!c)try{await h()}catch(e){i.error(e);return}let _;try{_=await c.read()}catch(e){if(!r){i.error(e);return}try{await g()}catch(e){i.error(e);return}continue}if(_.done||!_.value){c=void 0,u!==void 0&&mo(u,e,t,p,m,s),i.close();return}let v=_.value;if(v.length>0){let e=new Uint8Array(l.length+v.length);e.set(l,0),e.set(v,l.length),l=e}let y=!1;for(;l.length>=4;){let r=4+new DataView(l.buffer,l.byteOffset,l.byteLength).getUint32(0,!1);if(l.length<r)break;i.enqueue(l.slice(0,r)),l=l.slice(r),a++,p++,m+=r,!f&&u!==void 0&&(f=!0,po(u,e,t,n,d)),y=!0}if(y){o=0;return}}},cancel:async()=>{c&&=(await c.cancel().catch(e=>{console.warn(`Error closing ReadableStream reader:`,e)}),void 0)}})}const yo=()=>{let e=S(`WORKFLOW_STREAM_FLUSH_INTERVAL_MS`,NaN,{integer:!0});return Number.isNaN(e)?void 0:e};function bo(e,t,n,r,i,a,o){(async()=>{await Da(`workflow.stream.flush`,e,{kind:await ja(`CLIENT`),attributes:{"workflow.run.id":n,"workflow.stream.name":r,"workflow.stream.operation":`flush`,"workflow.stream.flush.buffer_dwell_ms":t-e,"workflow.stream.flush.chunks":i,"workflow.stream.flush.bytes":a,"workflow.stream.write.chunk_rtt":o}})})()}function xo(e,t,n){(async()=>{await Da(`workflow.stream.close`,e,{kind:await ja(`CLIENT`),attributes:{"workflow.run.id":t,"workflow.stream.name":n,"workflow.stream.operation":`close`,"workflow.stream.close.rpc_ms":Date.now()-e}})})()}var $=class extends WritableStream{constructor(e,t,n){if(typeof e!=`string`)throw new c(`"runId" must be a string, got "${typeof e}"`);if(typeof t!=`string`||t.length===0)throw new c(`"name" is required, got "${t}"`);let r=zn(),i=n,a=async()=>{if(i){try{await i}catch{}i=void 0}},o=[],s=0,l=0,u=0,d=null,f=null,p,m=yo(),h=null,g=Cn(),_=wn(),v=Sn(),y=Tn(),b,x=[],S=[],ee=e=>{let t=[...x,...S];x=[],S=[];for(let n of t)n.reject(e)},te=()=>{let e=0,t=0;for(let n of o){if(e>=g||e>0&&t+n.byteLength>_)break;e++,t+=n.byteLength}let n=o.slice(0,e);return o=o.slice(e),s-=t,{group:n,bytes:t}},ne=async(n,i,o)=>{await a();let s=await r,c=Date.now();if(typeof s.streams.writeMulti==`function`&&n.length>1)await s.streams.writeMulti(e,t,n);else for(let r of n)await s.streams.write(e,t,r);o!==void 0&&bo(o,c,e,t,n.length,i,Date.now()-c)},re=async()=>{for(;o.length>0;){d&&=(clearTimeout(d),null);let e=b,t=Date.now(),{group:n,bytes:r}=te();l=n.length,u=r,b=o.length>0?t:void 0;try{await ne(n,r,e),l=0,u=0}catch(t){throw o=n.concat(o),s+=r,l=0,u=0,b=e!==void 0&&b!==void 0?Math.min(e,b):e??b,t}let i=x;x=[];for(let e of i)e.resolve()}},C=()=>{f||p!==void 0||o.length===0||(f=re().then(()=>{if(f=null,o.length>0){C();return}let e=S;S=[];for(let t of e)t.resolve()},e=>{f=null,p??=e,ee(p)}))},ie=()=>{if(!(d||f)){if(m===void 0){h??=Promise.resolve(r).then(e=>{m=e.streamFlushIntervalMs??0},()=>{m=0}).then(()=>{o.length>0&&ie()});return}if(m<=0){C();return}d=setTimeout(()=>{d=null,C()},m)}},ae=async()=>{for(;;){if(p!==void 0)throw p;if(o.length===0&&!f)return;C(),await new Promise((e,t)=>{S.push({resolve:e,reject:t})})}};super({async write(e){if(p!==void 0)throw p;for(b===void 0&&(b=Date.now()),o.push(e),s+=e.byteLength,o.length>=g||s>=_?C():ie();p===void 0&&(o.length+l>=v||s+u>=y);)C(),await new Promise((e,t)=>{x.push({resolve:e,reject:t})});if(p!==void 0)throw p},async close(){await ae(),await a();let n=await r,i=Date.now();await n.streams.close(e,t),xo(i,e,t)},async abort(e){try{await ae()}catch{}d&&=(clearTimeout(d),null),o=[],s=0,p??=e??Error(`Stream aborted`),ee(p)}}),Object.defineProperty(this,gn,{value:ae,enumerable:!1,writable:!1})}};function So(e=globalThis){return{...Kn(),...tr(),...$n(e),Request:t=>{if(!(t instanceof e.Request))return!1;let n={method:t.method,url:t.url,headers:t.headers,body:t.body,duplex:t.duplex},r=t[vn];return r&&(n.responseWritable=r),t.signal&&(t.signal.aborted||t.signal[L])&&(n.signal=t.signal),n},Response:t=>t instanceof e.Response&&{type:t.type,url:t.url,status:t.status,statusText:t.statusText,headers:t.headers,body:t.body,redirected:t.redirected}}}function Co(e,t,n,r,i,a){let o=t[L],s=t[R];if(!o){let e=(n[fn]||io)();o=Za(e),s=`abrt_${e}`,t[L]=o,t[R]=s,t.signal&&(t.signal[L]=o,t.signal[R]=s)}return To(e,o,i,a,r),{streamName:o,hookToken:s,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function wo(e,t){let n=t[L]??t.signal?.[L],r=t[R]??t.signal?.[R];if(!n)throw Error(`AbortController/AbortSignal stream name is not set`);return{streamName:n,hookToken:r,aborted:e.aborted,reason:e.aborted?e.reason:void 0}}function To(e,t,n,r,i){e.aborted||e[bn]||(e[bn]=!0,e.addEventListener(`abort`,()=>{i.push((async()=>{try{let i=await Nr(r),a=await Jo({aborted:!0,reason:e.reason},n,i),o=new $(n,t).getWriter();await o.write(a),await o.close()}catch{}})())},{once:!0}))}function Eo(e=globalThis,t,n,r,i=!1,a){return{...So(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new m(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=`strm_${(e[fn]||io)()}`,c=ao(o),l=new $(n,s,a);c===`bytes`?i?t.push(o.pipeThrough(uo()).pipeTo(l)):t.push(o.pipeTo(l)):t.push(o.pipeThrough(so(Eo(e,t,n,r,i,a),r)).pipeTo(l));let u={name:s};return c&&(u.type=c),c===`bytes`&&i&&(u.framing=`framed-v1`),u},WritableStream:r=>{if(!(r instanceof e.WritableStream))return!1;let i=r[P],a=r[F];if(typeof i==`string`&&typeof a==`string`){let e={name:i,runId:a},t=r[I];typeof t==`string`&&(e.encryptionPublicKey=t);let n=r[hn];return typeof n==`string`&&(e.deploymentId=n),e}let o=`strm_${(e[fn]||io)()}`,s=new ho(n,o);return t.push(s.pipeTo(r)),{name:o}},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Co(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Co(i,i,e,t,n,r)}}function Do(e=globalThis){return{...So(e),ReadableStream:t=>{if(!(t instanceof e.ReadableStream))return!1;let n=t[_n];if(n!==void 0)return{bodyInit:n};let r=t[P];if(!r)throw new c("ReadableStream `name` is not set");let i={name:r},a=t[pn];a&&(i.type=a);let o=t[mn];return o&&(i.framing=o),i},WritableStream:t=>{if(!(t instanceof e.WritableStream))return!1;let n=t[P];if(!n)throw new c("WritableStream `name` is not set");let r={name:n},i=t[F];typeof i==`string`&&(r.runId=i);let a=t[hn];typeof a==`string`&&(r.deploymentId=a);let o=t[I];return typeof o==`string`&&(r.encryptionPublicKey=o),r},AbortController:t=>{if(!t||!t.signal)return!1;let n=t,r=n[L]??n.signal?.[L],i=e.AbortController&&typeof e.AbortController==`function`&&t instanceof e.AbortController;return!r&&!i?!1:wo(t.signal,n)},AbortSignal:t=>{let n=t?.[L],r=e.AbortSignal&&typeof e.AbortSignal==`function`&&t instanceof e.AbortSignal;return!n&&!r?!1:wo(t,t)}}}function Oo(e=globalThis,t,n,r,i=!1,a){return{...So(e),ReadableStream:o=>{if(!(o instanceof e.ReadableStream))return!1;if(o.locked)throw new m(`ReadableStream is locked and cannot be passed across a workflow boundary.`,{hint:`Pass the stream before calling .getReader() / .pipeThrough() / .pipeTo(), or tee it with .tee() and pass one of the branches.`});let s=o[P],c=o[pn],l=o[mn];if(!s){s=`strm_${(e[fn]||io)()}`,c=ao(o),l=c===`bytes`&&i?`framed-v1`:l;let u=new $(n,s,a);c===`bytes`?l===`framed-v1`?t.push(o.pipeThrough(uo()).pipeTo(u)):t.push(o.pipeTo(u)):t.push(o.pipeThrough(so(Oo(e,t,n,r,i,a),r)).pipeTo(u))}let u={name:s};return c&&(u.type=c),l&&(u.framing=l),u},WritableStream:i=>{if(!(i instanceof e.WritableStream))return!1;let a=i[P],o=i[F];a||(a=`strm_${(e[fn]||io)()}`,t.push(new ho(n,a).pipeThrough(co(zo(e,t,n,r),r)).pipeTo(i)));let s={name:a};typeof o==`string`&&(s.runId=o);let c=i[I];typeof c==`string`&&(s.encryptionPublicKey=c);let l=i[hn];return typeof l==`string`&&(s.deploymentId=l),s},AbortController:i=>!e.AbortController||typeof e.AbortController!=`function`||!(i instanceof e.AbortController)?!1:Co(i.signal,i,e,t,n,r),AbortSignal:i=>!e.AbortSignal||typeof e.AbortSignal!=`function`||!(i instanceof e.AbortSignal)?!1:Co(i,i,e,t,n,r)}}function ko(...e){let t=new WeakSet;function n(e){let t=e[xn];t&&!t.signal.aborted&&t.abort()}function r(e){if(!(typeof e!=`object`||!e)&&!t.has(e)){if(t.add(e),e instanceof AbortController){n(e),n(e.signal);return}if(e instanceof AbortSignal){n(e);return}if(Array.isArray(e)){for(let t of e)r(t);return}if(e instanceof Map){for(let t of e.values())r(t);return}if(e instanceof Set){for(let t of e)r(t);return}if(typeof Request<`u`&&e instanceof Request){r(e.signal);return}for(let t of Object.values(e))r(t)}}for(let t of e)r(t)}function Ao(e,t,n,r){let i=new AbortController;return r.push((async()=>{try{let r=new ho(t,n).getReader(),a=await Promise.race([r.read(),new Promise(e=>{if(i.signal.aborted){e({value:void 0,done:!0});return}i.signal.addEventListener(`abort`,()=>e({value:void 0,done:!0}),{once:!0})})]);if(a.value&&!a.done){try{r.releaseLock()}catch{}try{let n=Ja.getStore(),r=await Yo(a.value,t,n?.encryptionKey);e.abort(r?.reason)}catch{e.abort()}}else r.cancel().catch(()=>{})}catch{}})()),i}function jo(e,t,n){let r=e,i=e.signal;r[L]=t.streamName,r[R]=t.hookToken,i[L]=t.streamName,i[R]=t.hookToken,n&&(r[xn]=n,i[xn]=n)}function Mo(e,t){let n=e,r=t;n[L]!==void 0&&(r[L]=n[L]),n[R]!==void 0&&(r[R]=n[R]),n[xn]!==void 0&&(r[xn]=n[xn])}function No(e,t,n){let r=new AbortController;e.aborted?(jo(r,e),r.abort(e.reason)):e.streamName?jo(r,e,Ao(r,n,e.streamName,t)):jo(r,e);let i=r.abort.bind(r);return r.abort=t=>{if(r.signal.aborted)return;i(t);let n=Ja.getStore();if(n&&(n.ops.push((async()=>{try{let r=await Jo({aborted:!0,reason:t},n.workflowMetadata.workflowRunId,n.encryptionKey),i=new $(n.workflowMetadata.workflowRunId,e.streamName).getWriter();await i.write(r),await i.close()}catch{}})()),e.hookToken)){let r=(async()=>{try{let{resumeHook:n}=await import(`./resume-hook-ip1hbn1b.js`).then(e=>e.i);await n(e.hookToken,{aborted:!0,reason:t})}catch{}})();n.preCompletionOps.push(r)}},r}function Po(e,t,n){let r=new AbortController;return e.aborted?(jo(r,e),r.abort(e.reason)):e.streamName?jo(r,e,Ao(r,n,e.streamName,t)):jo(r,e),r.signal}function Fo(e=globalThis){return{...qn(e),...er(e)}}async function Io(e,t,n){let r=on(n);if(r)return Dr(r);let i=await zn();if(!i.getEncryptionKeyForRun)return;let a=t?await i.getEncryptionKeyForRun(e,{deploymentId:t}):await i.getEncryptionKeyForRun(await i.runs.get(e));return a?await It(a,[`encrypt`]):void 0}function Lo(e=globalThis,t,n,r){return{...Fo(e),StepFunction:()=>{throw new m(`Step functions cannot be deserialized in client context. Step functions should not be returned from workflows.`,{hint:`A step function reference reached the client. Return a serializable value (e.g. the step result) instead of the step itself.`})},WorkflowFunction:e=>Object.assign(()=>{throw new m(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(n.signal=t.signal);let r=new e.Request(t.url,n);return t.signal&&Mo(t.signal,r.signal),r},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:i=>{if(`bodyInit`in i){let t=i.bodyInit;return new e.Response(t).body}if(i.type===`bytes`){let r=new ho(n,i.name,i.startIndex),a=Dn();t.push(a.promise);let{readable:o,writable:s}=i.framing===`framed-v1`?fo():new e.TransformStream;return Nn(r,s,a).catch(()=>{}),Mn(o,a),o}else{let a=vo(n,i.name,i.startIndex),o=co(Lo(e,t,n,r),r),s=Dn();return t.push(s.promise),Nn(a,o.writable,s).catch(()=>{}),Mn(o.readable,s),o.readable}},WritableStream:i=>{let a=typeof i.runId==`string`?i.runId:n,o=a===n?r:Io(a,i.deploymentId,i.encryptionPublicKey),s=so(Eo(e,t,a,o),o),c=new $(a,i.name),l=Dn();return t.push(l.promise),Nn(s.readable,c,l).catch(()=>{}),jn(s.writable,l),Object.defineProperty(s.writable,P,{value:i.name,writable:!1}),Object.defineProperty(s.writable,F,{value:a,writable:!1}),typeof i.deploymentId==`string`&&Object.defineProperty(s.writable,hn,{value:i.deploymentId,writable:!1}),typeof i.encryptionPublicKey==`string`&&Object.defineProperty(s.writable,I,{value:i.encryptionPublicKey,writable:!1}),s.writable},AbortController:e=>No(e,t,n),AbortSignal:e=>Po(e,t,n)}}function Ro(e=globalThis){return{...Fo(e),...nr(e),Request:t=>{Object.setPrototypeOf(t,e.Request.prototype);let n=t.responseWritable;return n&&(t[vn]=n,delete t.responseWritable,t.respondWith=()=>{throw new m("`respondWith()` must be called from within a step function.",{hint:'Move the `respondWith(...)` call inside a `"use step"` function — it cannot be invoked from a workflow context.'})}),t},WorkflowFunction:e=>Object.assign(()=>{throw new m(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Response:t=>(Object.setPrototypeOf(t,e.Response.prototype),t),ReadableStream:t=>`bodyInit`in t?Object.create(e.ReadableStream.prototype,{[_n]:{value:t.bodyInit,writable:!1}}):Object.create(e.ReadableStream.prototype,{[P]:{value:t.name,writable:!1},[pn]:{value:t.type,writable:!1},[mn]:{value:t.framing,writable:!1}}),WritableStream:t=>{let n={[P]:{value:t.name,writable:!1}};return typeof t.runId==`string`&&(n[F]={value:t.runId,writable:!1}),typeof t.deploymentId==`string`&&(n[hn]={value:t.deploymentId,writable:!1}),typeof t.encryptionPublicKey==`string`&&(n[I]={value:t.encryptionPublicKey,writable:!1}),Object.create(e.WritableStream.prototype,n)},AbortController:e=>{let t=new to(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),{[L]:e.streamName,[R]:e.hookToken,signal:t,abort:()=>{}}},AbortSignal:e=>{let t=new to(e.streamName,e.hookToken);return e.aborted&&t._setAborted(e.reason),t}}}function zo(e=globalThis,t,r,i,a){return{...Fo(e),StepFunction:e=>{let t=e.stepId,r=e.closureVars,i=`boundThis`in e,a=i?e.boundThis:void 0,o=Array.isArray(e.boundArgs)?e.boundArgs:[],s=n(t);if(!s)throw new m(`Step function "${t}" not found. Make sure the step function is registered.`,{hint:`Make sure the step file is included in your build (i.e. it is listed in the workflow manifest), and that the SWC plugin is configured for the file.`});if(!r&&!i&&o.length===0)return s;let l=function(...e){let t=i?a:this,n=o.length>0?[...o,...e]:e;if(r){let e=Ja.getStore();if(!e)throw new c(`Cannot call step function with closure variables outside step context`);let i={...e,closureVars:r};return Ja.run(i,()=>s.apply(t,n))}return s.apply(t,n)};return Object.defineProperty(l,"name",{value:s.name}),Object.defineProperty(l,"stepId",{value:t,writable:!1,enumerable:!1,configurable:!1}),s.maxRetries!==void 0&&(l.maxRetries=s.maxRetries),l},WorkflowFunction:e=>Object.assign(()=>{throw new m(`Workflow functions cannot be called directly. Use start() to invoke them.`,{hint:"Wrap the workflow with `start(workflowFn, { ... })` from `workflow` to begin a run instead of invoking it like a normal function."})},{workflowId:e.workflowId}),Request:t=>{let n=t.responseWritable,r={method:t.method,headers:new e.Headers(t.headers),body:t.body,duplex:t.duplex};t.signal&&(r.signal=t.signal);let i=new e.Request(t.url,r);return t.signal&&Mo(t.signal,i.signal),n&&(i.respondWith=async e=>{let t=n.getWriter();await t.write(e),await t.close()}),i},Response:t=>new e.Response(t.body,{status:t.status,statusText:t.statusText,headers:new e.Headers(t.headers)}),ReadableStream:n=>{if(`bodyInit`in n){let t=n.bodyInit;return new e.Response(t).body}let o=new ho(r,n.name);if(n.type===`bytes`){let r=Dn();t.push(r.promise);let{readable:i,writable:a}=n.framing===`framed-v1`?fo():new e.TransformStream;return Nn(o,a,r).catch(()=>{}),Mn(i,r),i}else{let n=co(zo(e,t,r,i,a),i),s=Dn();return t.push(s.promise),Nn(o,n.writable,s).catch(()=>{}),Mn(n.readable,s),n.readable}},WritableStream:n=>{let o=typeof n.runId==`string`?n.runId:r,s=typeof n.deploymentId==`string`?n.deploymentId:o===r?a:void 0,c=o===r?i:Io(o,s,n.encryptionPublicKey),l=so(Oo(e,t,o,c),c),u=new $(o,n.name),d=Dn();return t.push(d.promise),Nn(l.readable,u,d).catch(()=>{}),jn(l.writable,d),Object.defineProperty(l.writable,P,{value:n.name,writable:!1}),Object.defineProperty(l.writable,F,{value:o,writable:!1}),s&&Object.defineProperty(l.writable,hn,{value:s,writable:!1}),typeof n.encryptionPublicKey!=`string`&&o===r&&jr(i)&&Object.defineProperty(l.writable,I,{value:Jt(i.keyPair.publicKey),writable:!1}),typeof n.encryptionPublicKey==`string`&&Object.defineProperty(l.writable,I,{value:n.encryptionPublicKey,writable:!1}),l.writable},AbortController:e=>No(e,t,r),AbortSignal:e=>Po(e,t,r)}}async function Bo(e,t){return await Pr(e,t)}const Vo=async(e,t)=>{let n={},r=await wr(await Ir(e,t),n);return await Q(n,`deserialize`),{data:r}};function Ho(e,t=globalThis,n={}){return Ka(e.data,{global:t,extraRevivers:{...is(Ro(t)),...n}})}function Uo(e,t=globalThis,n={}){let{data:r}=e;if(!(r instanceof Uint8Array))return Mt(r,{...Ro(t),...n});let{format:i,payload:a}=G(r);if(i===H.DEVALUE_V1)return jt(new TextDecoder().decode(a),{...Ro(t),...n});throw Error(`Unsupported serialization format: ${i}`)}async function Wo(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1){if(a)return Yn(N(e,Eo(i,r,t,n,o)));try{let a={},c=await Ha(e,n,{global:i,extraReducers:rs(Eo(i,r,t,n,o)),compression:s,compressionStats:a});return await Q(a,`serialize`),c}catch(e){let t=oo(e),{message:n,hint:r}=X(`workflow arguments`,t);throw new m(n,{hint:r,cause:t})}}async function Go(e,t,n,r=globalThis,i={},a){return Ho(a??await Vo(e,n),r,i)}async function Ko(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Yn(N(e,Do(r)));try{let t={},i=await Wa(e,n,{global:r,extraReducers:rs(Do(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=oo(e),{message:n,hint:r}=X(`workflow return value`,t);throw new m(n,{hint:r,cause:t})}}async function qo(e,t,n,r=[],i=globalThis,a={}){let o={},s=await Ua(e,n,{global:i,extraRevivers:{...is(Lo(i,r,t,n)),...a},compressionStats:o});return await Q(o,`deserialize`),s}async function Jo(e,t,n,r=globalThis,i=!1,a=!1){if(i)return Yn(N(e,Do(r)));try{let t={},i=await Wa(e,n,{global:r,extraReducers:rs(Do(r)),compression:a,compressionStats:t});return await Q(t,`serialize`),i}catch(e){let t=oo(e),{message:n,hint:r}=X(`step arguments`,t);throw new m(n,{hint:r,cause:t})}}async function Yo(e,t,n,r=[],i=globalThis,a={},o){let s={},c=await Ga(e,n,{global:i,extraRevivers:{...is(zo(i,r,t,n,o)),...a},compressionStats:s});return await Q(s,`deserialize`),c}async function Xo(e,t,n,r=[],i=globalThis,a=!1,o=!1,s=!1,c){if(a)return Yn(N(e,Oo(i,r,t,n,o,c)));try{let a={},l=await Wa(e,n,{global:i,extraReducers:rs(Oo(i,r,t,n,o,c)),compression:s,compressionStats:a});return await Q(a,`serialize`),l}catch(e){let t=oo(e),{message:n,hint:r}=X(`step return value`,t);throw new m(n,{hint:r,cause:t})}}async function Zo(e,t,n,r=[],i=globalThis,a=!1){try{let o=N(e,Oo(i,r,t,n)),s=new TextEncoder().encode(o),c=W(H.DEVALUE_V1,s),l={},u=await Bo(await Cr(c,a,l),n);return await Q(l,`serialize`),u}catch(e){let t=oo(e),{message:n,hint:r}=X(`step error`,t);throw new m(n,{hint:r,cause:t})}}async function Qo(e,t,n,r=globalThis,i={},a){return Uo(a??await Vo(e,n),r,i)}async function $o(e,t,n,r=globalThis,i=!1){try{let t=N(e,Do(r)),a=new TextEncoder().encode(t),o=W(H.DEVALUE_V1,a),s={},c=await Bo(await Cr(o,i,s),n);return await Q(s,`serialize`),c}catch(e){let t=oo(e),{message:n,hint:r}=X(`run error`,t);throw new m(n,{hint:r,cause:t})}}async function es(e,t,n,r=[],i=globalThis,a={}){let o={},s=await wr(await Ir(e,n),o);if(await Q(o,`deserialize`),!(s instanceof Uint8Array))return Mt(s,{...Lo(i,r,t,n),...a});let{format:c,payload:l}=G(s);if(c===H.DEVALUE_V1)return jt(new TextDecoder().decode(l),{...Lo(i,r,t,n),...a});throw Error(`Unsupported serialization format: ${c}`)}async function ts(e,t,n,r=globalThis,i={},a){return Ho(a??await Vo(e,n),r,i)}const ns=[`ReadableStream`,`WritableStream`,`Request`,`Response`,`StepFunction`,`AbortController`,`AbortSignal`];function rs(e){let t={};for(let n of ns)n in e&&(t[n]=e[n]);return t}function is(e){let t={};for(let n of ns)n in e&&(t[n]=e[n]);return t}const as=[{format:H.ENCRYPTED,minVersion:`4.2.0-beta.64`},{format:H.GZIP,minVersion:`5.0.0-beta.18`},{format:H.ZSTD,minVersion:`5.0.0-beta.18`},{format:H.SEALED,minVersion:`5.0.0-beta.37`}],os=[{capability:`framedByteStreams`,minVersion:`5.0.0-beta.15`}],ss=new Set([H.DEVALUE_V1]);function cs(e){if(!e||!Ft.default.valid(e))return{supportedFormats:ss,framedByteStreams:!1};let t=new Set(ss);for(let{format:n,minVersion:r}of as)Ft.default.gte(e,r)&&t.add(n);let n={supportedFormats:t,framedByteStreams:!1};for(let{capability:t,minVersion:r}of os)Ft.default.gte(e,r)&&(n[t]=!0);return n}const ls=`5.0.0-beta.37`,us=/^[a-zA-Z0-9_\-./@]+$/;function ds(e,t){if(!us.test(e))throw Error(`Invalid workflow name "${e}": must only contain alphanumeric characters, underscores, hyphens, dots, forward slashes, or at signs`);return`${v(`workflow`,x(t))}${e}`}const fs=b();function ps(e){return`__health_check__${e}`}function ms(e){let t=_.safeParse(e);if(t.success)return t.data}function hs(e){return`wrun_hc_${e}`}async function gs(e,t){let n=await zn(),r=ps(e.correlationId),i;if(e.runId)try{let t=await n.getEncryptionKeyForRun?.(e.runId);t&&(i=Jt((await Ut(t)).publicKey))}catch(t){Y.warn(`Health check could not derive a run public key; the caller will fall back to a key lookup`,{correlationId:e.correlationId,error:t instanceof Error?t.message:String(t)})}let a=JSON.stringify({healthy:!0,correlationId:e.correlationId,specVersion:t??5,workflowCoreVersion:ls,...i?{encryptionPublicKey:i}:{},timestamp:Date.now()}),o=hs(e.correlationId);await n.streams.write(o,r,a),await n.streams.close(o,r)}function _s(e,t){let n;return Promise.race([e,new Promise((e,r)=>{n=setTimeout(()=>r(Error(`Operation timed out after ${t}ms`)),t)})]).finally(()=>clearTimeout(n))}async function vs(e,t){let n=[],r=!1,i=!1;for(;!r&&!i;){let a=e.read(),o=new Promise(e=>setTimeout(()=>{i=!0,e({done:!0,value:void 0})},t)),s=await Promise.race([a,o]);r=s.done,s.value&&n.push(s.value)}return{chunks:n,timedOut:i}}function ys(e){if(e.length===0)return null;let t=e.reduce((e,t)=>e+t.length,0),n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.length;let i=new TextDecoder().decode(n),a;try{a=JSON.parse(i)}catch{return i.length>0?{healthy:!0}:null}if(typeof a!=`object`||!a||!(`healthy`in a)||typeof a.healthy!=`boolean`)return null;let o=a,s={healthy:o.healthy};return typeof o.specVersion==`number`&&(s.specVersion=o.specVersion),typeof o.workflowCoreVersion==`string`&&(s.workflowCoreVersion=o.workflowCoreVersion),typeof o.encryptionPublicKey==`string`&&(s.encryptionPublicKey=o.encryptionPublicKey),s}async function bs(e,t){let n=t?.timeout??3e4,r=e.createRunId?.()??fs(),i=ps(r),a=`${v(`workflow`,x(t?.namespace))}health_check`,o=Date.now();try{for(await e.queue(a,{__healthCheck:!0,correlationId:r,...t?.runId?{runId:t.runId}:{}},{specVersion:1,deploymentId:t?.deploymentId});Date.now()-o<n;)try{let t=n-(Date.now()-o),a=(await _s(e.streams.get(hs(r),i),t)).getReader(),{chunks:s,timedOut:c}=await vs(a,500);if(c){try{a.cancel()}catch{}await new Promise(e=>setTimeout(e,100));continue}let l=ys(s);if(l)return{...l,latencyMs:Date.now()-o};await new Promise(e=>setTimeout(e,100))}catch{await new Promise(e=>setTimeout(e,100))}return{healthy:!1,error:`Health check timed out after ${n}ms`}}catch(e){return{healthy:!1,error:e instanceof Error?e.message:String(e)}}}function xs(e,t){return new s(`Event pagination ${t} for workflow run "${e}".`,{code:l.WORLD_CONTRACT_ERROR})}function Ss(e,t,n){if(t){if(n.has(t))throw xs(e,`did not advance`);n.add(t)}}function Cs(e,t,n){if(t.length===0)return;let r=n??new Set(e.map(e=>e.eventId));for(let n of t)r.has(n.eventId)||(r.add(n.eventId),e.push(n))}function ws(e,t,n,r){if(t){if(n===null)throw xs(e,`returned more pages without a cursor`);if(r.has(n))throw xs(e,`repeated a cursor`)}}function Ts(e,t,n){return t!==null&&!n&&s.is(e)&&e.status===400}async function Es(e,t){let n=t!==void 0;return Ea(n?`workflow.loadNewEvents`:`workflow.loadEvents`,async r=>{r?.setAttributes({...Jr(e)});let i=[],a=new Set,o=new Set,s=t??null,c=!0,l=0,u=!1,d=await zn(),f=Date.now();for(;c;){let t=Date.now(),r=s;Ss(e,r,o);let f;try{f=await d.events.list({runId:e,pagination:{sortOrder:`asc`,cursor:r??void 0}})}catch(t){if(Ts(t,r,u)){Y.warn(`Event cursor was rejected; retrying with a full event reload.`,{workflowRunId:e}),i.length=0,a.clear(),o.clear(),s=null,u=!0;continue}throw t}Cs(i,f.data,a),c=f.hasMore,ws(e,c,f.cursor,o),s=f.cursor??s,l++,Y.debug(`Loaded event page`,{workflowRunId:e,incremental:n,page:l,pageEvents:f.data.length,totalEvents:i.length,hasMore:c,pageMs:Date.now()-t})}return Y.debug(`Event load complete`,{workflowRunId:e,incremental:n,totalEvents:i.length,pagesLoaded:l,totalMs:Date.now()-f}),r?.setAttributes({...Zr(i.length),...$i(l)}),{events:i,cursor:s}})}function Ds(){return process.env.WORKFLOW_PRECONDITION_GUARD!==`0`}function Os(e){let t=e[e.length-1];if(!t)return;let n=t.eventId,r=n.lastIndexOf(`_`),i=y(r===-1?n:n.slice(r+1))?.getTime();if(i===void 0){Y.debug(`Precondition guard: latest event id is not a decodable ULID; sending no snapshot`,{eventId:n});return}return i}function ks(e){return Ds()?Os(e):void 0}async function As(e,t,n){for(let r=0;;r++)try{return await n(ks(t.events))}catch(n){if(!d.is(n)||r>=2)throw n;Y.info(`Event creation rejected as stale; reloading event log and retrying`,{workflowRunId:e,attempt:r+1,maxRetries:2});let i=await Es(e,t.cursor??void 0);Cs(t.events,i.events),t.cursor=i.cursor??t.cursor}}const js={"Access-Control-Allow-Origin":`*`,"Access-Control-Allow-Methods":`POST, OPTIONS, GET, HEAD`,"Access-Control-Allow-Headers":`Content-Type`};function Ms(e,t){return async n=>{let r=new URL(n.url);return r.searchParams.has(`__health`)?n.method===`OPTIONS`?new Response(null,{status:204,headers:js}):new Response(JSON.stringify({healthy:!0,endpoint:r.pathname,specVersion:t??5,workflowCoreVersion:ls}),{status:200,headers:{"Content-Type":`application/json`,...js}}):await e(n)}}async function Ns(e,...t){let n=t[0];await Ea(`queue.publish`,{attributes:{...Ii(`vercel-queue`),...Li(n),...zi(`publish`),...la(`vercel-queue`),...ua(`vercel-queue`),...da(`vqs`),...fa(`publish`)},kind:await ja(`PRODUCER`)},async n=>{let{messageId:r}=await e.queue(...t);r&&n?.setAttributes(Ri(r))})}function Ps(e){if(e.requestedAt)try{return Bi(Date.now()-e.requestedAt.getTime())}catch{return}}function Fs(e,t){let n;return()=>(n||=(async()=>{let n=await e.getEncryptionKeyForRun?.(t);return n?await kr(n):void 0})(),n)}function Is(t){import(`./functions-CiVUVDNB.js`).then(t=>e(t.default,1)).then(({waitUntil:e})=>{e(t)})}function Ls(e,t){Is(e.catch(e=>{if(!(e?.name===`AbortError`||e?.name===`ResponseAborted`))try{t(e)}catch{}}))}async function Rs(e){let t=e();return Is(t.catch(()=>{})),t}export{ba as $,pi as $t,Yo as A,I as An,ki as At,Ya as B,Ut as Bn,Qr as Bt,Xo as C,Dn as Cn,Ai as Ct,Lo as D,fn as Dn,Ti as Dt,Eo as E,_n as En,_i as Et,Vo as F,cn as Fn,Di as Ft,Ra as G,ve as Gn,Zr as Gt,Xa as H,me as Hn,ai as Ht,ro as I,un as In,Ei as It,va as J,se as Jn,qr as Jt,za as K,w as Kn,si as Kt,no as L,sn as Ln,yi as Lt,ts as M,vn as Mn,Pi as Mt,Go as N,ln as Nn,Fi as Nt,so as O,P as On,bi as Ot,qo as P,dn as Pn,Ci as Pt,Pa as Q,fi as Qt,Z as R,Jt as Rn,Si as Rt,Zo as S,Fn as Sn,ji as St,Ko as T,jn as Tn,wi as Tt,Ja as U,D as Un,ii as Ut,Qa as V,It as Vn,ui as Vt,Y as W,pe as Wn,ri as Wt,ga as X,$r as Xt,ja as Y,oe as Yn,li as Yt,_a as Z,mi as Zt,cs as _,Wn as _n,ea as _t,ds as a,oi as an,pa as at,$o as b,Bn as bn,Oi as bt,Ds as c,ni as cn,Ui as ct,ms as d,Wr as dn,Zi as dt,hi as en,Ea as et,Ns as f,kr as fn,Xi as ft,ls as g,Un as gn,Ii as gt,As as h,H as hn,zi as ht,Ps as i,Xr as in,ma as it,Qo as j,F as jn,Ni as jt,es as k,hn as kn,gi as kt,Es as l,ci as ln,Hi as lt,Ms as m,Dr as mn,Ri as mt,Rs as n,Jr as nn,Fa as nt,gs as o,ti as on,Qi as ot,ks as p,jr as pn,Li as pt,ya as q,re as qn,Kr as qt,Cs as r,Yr as rn,Vi as rt,bs as s,ei as sn,Wi as st,Ls as t,di as tn,Sa as tt,Fs as u,Gr as un,Yi as ut,$ as v,Gn as vn,ta as vt,Wo as w,Nn as wn,Mi as wt,Jo as x,zn as xn,vi as xt,ko as y,Vn as yn,na as yt,eo as z,on as zn,xi as zt};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=`/.well-known/workflow/v1`,t=Symbol.for(`@workflow/core/basePath`),n=globalThis;function r(e){n[t]=e??``}function i(){return n[t]??``}function a(e){return new URL(e),`${e.replace(/[?#].*$/,``).replace(/\/+$/,``)}${i()}`}function o(t,n){let r=new URL(t);return r.pathname=`${r.pathname.replace(/\/+$/,``)}${e}/${s(n)}`,r.search=n.type===`health`?`__health`:``,r.hash=``,r.toString()}function s(e){switch(e.type){case`flow`:case`health`:return`flow`;case`
|
|
1
|
+
const e=`/.well-known/workflow/v1`,t=Symbol.for(`@workflow/core/basePath`),n=globalThis;function r(e){n[t]=e??``}function i(){return n[t]??``}function a(e){return new URL(e),`${e.replace(/[?#].*$/,``).replace(/\/+$/,``)}${i()}`}function o(t,n){let r=new URL(t);return r.pathname=`${r.pathname.replace(/\/+$/,``)}${e}/${s(n)}`,r.search=n.type===`health`?`__health`:``,r.hash=``,r.toString()}function s(e){switch(e.type){case`flow`:case`health`:return`flow`;case`manifest`:return`manifest.json`;case`webhook`:return`webhook/${encodeURIComponent(e.token)}`}throw Error(`Unsupported workflow route: ${String(e.type)}`)}function c(){return`${i()}${e}/flow?__health`}export{r as a,o as i,a as n,c as r,e as t};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{
|
|
1
|
+
import{resolveDevelopmentClientOptions}from"#services/dev-client/client-options.js";import{resolveVerifiedRemoteDevelopmentClient}from"#setup/verified-remote-client.js";import{Client}from"#client/client.js";function resolveEvalClientOptions(t){if(t.kind===`local`)return{host:t.url};let n={...resolveDevelopmentClientOptions(t.url),preserveCompletedSessions:!1},r=process.env.EVE_EVAL_AUTH_TOKEN?.trim();return r?{...n,auth:{bearer:r},redirect:`manual`}:n}async function createEvalClient(e,r={}){let i=resolveEvalClientOptions(e);if(e.kind===`local`||i.auth!==void 0||r.workspaceRoot===void 0)return new Client(i);let{options:a}=await resolveVerifiedRemoteDevelopmentClient({serverUrl:e.url,workspaceRoot:r.workspaceRoot,deps:r.deps});return new Client({...i,...a})}export{createEvalClient,resolveEvalClientOptions};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{basename,extname}from"node:path";import{readFile}from"node:fs/promises";import{isCurrentTurnBoundaryEvent,isTurnFailureEvent}from"#protocol/message.js";import{
|
|
1
|
+
import{basename,extname}from"node:path";import{readFile}from"node:fs/promises";import{isCurrentTurnBoundaryEvent,isTurnFailureEvent}from"#protocol/message.js";import{summarizeTurnEvents}from"#client/session-utils.js";import{createTextWithFileContent}from"#client/file-parts.js";import{extractCompletedResult}from"#client/output-schema.js";import{inputRequestMatches,matchesValue,toolCallMatches}from"#evals/match.js";import{AssertionCollector}from"#evals/assertions/collector.js";import{createOutputAssertions,createScopedAssertions}from"#evals/assertions/scoped.js";import{EvalRequirementFailed}from"#evals/control-flow.js";import{deriveRunFacts}from"#evals/runner/derive-run-facts.js";var EveEvalTurnFailedError=class extends Error{event;turn;constructor(e){let t=e.events.find(isTurnFailureEvent),n=t===void 0?`turn ended with status "${e.status}"`:`${t.type}: ${t.data.code} ${t.data.message}`.trim();super(`Eval turn failed: ${n}`),this.name=`EveEvalTurnFailedError`,this.event=t,this.turn=e}},EvalSessionDriver=class{#e;#t;#n;#r=[];#i;#a=[];constructor(e){this.#n=e.collector,this.#e=e.session,this.#t=e.signal,Object.assign(this,createScopedAssertions(this.#n,{timing:`snapshot`,select:()=>this.#c()}),createOutputAssertions(this.#n,{timing:`snapshot`,select:()=>this.#c()}))}get events(){return this.#r}get lastTurn(){return this.#i}get pendingInputRequests(){return this.#a}get sessionId(){return this.#e.state.sessionId??this.#i?.sessionId}get state(){return this.#e.state}async cancel(){return await this.#e.cancel()}requireInputRequest(e={}){this.#a.length===0&&this.#l(`requireInputRequest`,`expected one pending input request, but the last turn did not park`);let t=this.#a.filter(t=>inputRequestMatches(t,e));return(this.#a.length!==1||t.length!==1)&&this.#l(`requireInputRequest`,`expected exactly one pending input request matching ${formatInputRequestFilter(e)}, found ${t.length} match(es) across ${this.#a.length} pending request(s)`),this.#n.recordOutcome({name:`requireInputRequest`,outcome:{score:1}}),t[0]}async respond(...e){if(e.length===0)throw Error(`respond() requires at least one input response.`);return await this.send({inputResponses:e})}async respondAll(e){let t=this.#a;if(t.length===0)throw Error(`respondAll() requires at least one pending input request.`);for(let n of t)assertRequestHasOption(n,e);return await this.respond(...t.map(t=>({optionId:e,requestId:t.requestId})))}async send(e){return await(await this.start(e)).result()}async start(e){let t=await this.#e.send(attachSignal(e,this.#t));return new EvalLiveTurn({events:t,record:e=>this.#s(t.sessionId,e),session:this,sessionId:t.sessionId})}async sendFile(t,r,i){let a=createTextWithFileContent({bytes:await readFile(r),filename:basename(r),mediaType:i??inferMediaType(r),text:t});return await this.send({message:a})}async readTurn(e){let t=this.sessionId;return await this.watchTurn(e,requireSessionId(t)).result()}watchTurn(e,t=requireSessionId(this.sessionId)){return new EvalLiveTurn({events:this.#e.stream({signal:this.#t,startIndex:e?.startIndex}),record:e=>this.#s(t,e),session:this,sessionId:t})}snapshot(e){let t=this.sessionId;return{derived:deriveRunFacts(this.#r,{sessionId:t}),events:[...this.#r],primary:e,sessionId:t,state:this.#e.state}}#o(e){this.#r.push(...e.events),this.#a=e.status===`waiting`?e.inputRequests:[];let t=deriveRunFacts(e.events,{sessionId:e.sessionId}),n=new EvalTurn({collector:this.#n,data:e.data,derived:t,events:e.events,inputRequests:e.inputRequests,message:e.message,sessionId:e.sessionId,status:e.status,toolCalls:t.toolCalls});return this.#i=n,n}#s(e,t){let n=summarizeTurnEvents(t);return this.#o({data:extractCompletedResult(t),events:t,inputRequests:n.inputRequests,message:n.message,sessionId:e,status:n.status})}#c(){let e=this.sessionId;return{derived:deriveRunFacts(this.#r,{sessionId:e}),events:[...this.#r],output:outputOf(this.#i),status:this.#i?.status??`completed`}}#l(e,t){throw this.#n.recordOutcome({name:e,outcome:{score:0,message:t}}),new EvalRequirementFailed}},EvalLiveTurn=class{session;sessionId;#e;#t=[];#n=new Set;#r;constructor(e){this.session=e.session,this.sessionId=e.sessionId,this.#e=this.#i(e.events,e.record),this.#e.catch(()=>{})}get events(){return this.#t}async cancel(){return await this.session.cancel()}async result(){return await this.#e}async waitForEvent(e,t){let matches=n=>n.type===e&&(t?.data===void 0||matchesValue(t.data,`data`in n?n.data:void 0)),n=this.#t.find(matches);if(n!==void 0)return n;if(this.#r!==void 0)throw this.#r;return await new Promise((e,t)=>{let n={matches,reject:t,resolve:t=>e(t)};this.#n.add(n)})}async#i(e,t){try{let n=!1;for await(let t of e)if(this.#t.push(t),this.#a(t),isTurnFailureEvent(t)&&this.#o(Error(`Session ${this.sessionId} failed before the expected event (${t.type}).`)),isCurrentTurnBoundaryEvent(t)){n=!0,this.#o(Error(`Session ${this.sessionId} reached ${t.type} before the expected event.`));break}if(!n)throw Error(`Stream for session "${this.sessionId}" closed before a turn boundary.`);return t(this.#t)}catch(e){let t=e instanceof Error?e:Error(String(e));throw this.#o(t),e}}#a(e){for(let t of this.#n)t.matches(e)&&(this.#n.delete(t),t.resolve(e))}#o(e){if(this.#r===void 0){this.#r=e;for(let t of this.#n)t.reject(e);this.#n.clear()}}},EvalTurn=class{data;events;inputRequests;message;sessionId;status;toolCalls;#e;#t;constructor(e){this.data=e.data,this.events=e.events,this.inputRequests=e.inputRequests,this.message=e.message,this.sessionId=e.sessionId,this.status=e.status,this.toolCalls=e.toolCalls,this.#e=e.collector,this.#t=e.derived,Object.assign(this,createScopedAssertions(e.collector,{timing:`snapshot`,select:()=>this.#n()}),createOutputAssertions(e.collector,{timing:`snapshot`,select:()=>this.#n()}))}expectOk(){if(this.status!==`failed`)return this;throw new EveEvalTurnFailedError(this)}requireToolCall(e,t={}){let n=this.toolCalls.filter(n=>n.name===e&&toolCallMatches(n,t));return n.length!==1&&inputRequirementFailed(this.#e,`requireToolCall`,`expected exactly one matching "${e}" tool call in this turn, found ${n.length}; observed [${this.toolCalls.map(e=>e.name).join(`, `)}]`),this.#e.recordOutcome({name:`requireToolCall`,outcome:{score:1}}),n[0]}#n(){return{derived:this.#t,events:this.events,output:outputOf(this),status:this.status}}},EvalSessionManager=class{#e;#t;#n;#r=[];#i;constructor(e){this.#e=e.client,this.#n=e.collector??new AssertionCollector,this.#t=e.signal}get primary(){return this.#i??=this.#a(),this.#i}newSession(){return this.#a()}async attachSession(e,t){let n=this.#o(e,t);return await n.readTurn(t),n}watchTurn(e,t){return this.#o(e,t).watchTurn(t,e)}snapshots(){return this.#r.map(e=>e.snapshot(e===this.#i))}lastTurnSession(){return this.#i?.lastTurn===void 0?this.#r.find(e=>e.lastTurn!==void 0):this.#i}hasActivity(){return this.#r.length>0}#a(){let e=new EvalSessionDriver({collector:this.#n,session:this.#e.session(),signal:this.#t});return this.#r.push(e),e}#o(e,t){let n=new EvalSessionDriver({collector:this.#n,session:this.#e.session({sessionId:e,streamIndex:t?.startIndex??0}),signal:this.#t});return this.#r.push(n),n}};function attachSignal(e,t){if(t===void 0)return e;if(typeof e==`string`)return{message:e,signal:t};let n=e;return n.signal===void 0?{...n,signal:t}:n}function formatInputRequestFilter(e){return JSON.stringify(e)}function inputRequirementFailed(e,t,n){throw e.recordOutcome({name:t,outcome:{score:0,message:n}}),new EvalRequirementFailed}function outputOf(e){return e===void 0?null:e.data===void 0?e.message??null:e.data}function requireSessionId(e){if(e===void 0)throw Error(`Eval session produced a turn without a session id.`);return e}function assertRequestHasOption(e,t){if(e.options===void 0||e.options.length===0)throw Error(`Input request "${e.requestId}" has no selectable options.`);if(!e.options.some(e=>e.id===t))throw Error(`Input request "${e.requestId}" does not offer option "${t}".`)}function inferMediaType(e){switch(extname(e).toLowerCase()){case`.gif`:return`image/gif`;case`.jpg`:case`.jpeg`:return`image/jpeg`;case`.png`:return`image/png`;case`.webp`:return`image/webp`;default:return`application/octet-stream`}}export{EvalSessionDriver,EvalSessionManager,EveEvalTurnFailedError};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{isLoopbackHostname,isPrivateOrReservedIpAddress}from"#shared/network-address.js";import{lookup}from"node:dns";import{isIP}from"node:net";
|
|
1
|
+
import{isLoopbackHostname,isPrivateOrReservedIpAddress}from"#shared/network-address.js";import{lookup}from"node:dns";import{isIP}from"node:net";const REDIRECT_STATUSES=new Set([301,302,303,307,308]),UNSAFE_DESTINATION_ERROR=`URL must not target localhost, private, link-local, or reserved IP addresses.`;async function requestPublicUrl(e,t){let n=parseHttpsUrl(e),{dispatcher:r,response:a}=await requestOnce(n,t);try{let e=a.headers.get(`location`);if(e!==null&&REDIRECT_STATUSES.has(a.status)){await cancelResponseBody(a);let t=parseHttpsUrl(new URL(e,n).toString());throw Error(`Request redirected to ${t.toString()}. Call web_fetch again with that URL.`)}return await consumeResponse(a,t.maxResponseSize)}finally{await r.close()}}function parseHttpsUrl(e){let t;try{t=new URL(e)}catch{throw Error(`URL must be a valid absolute https:// URL.`)}if(t.protocol!==`https:`)throw Error(`URL must start with https://`);return t}async function requestOnce(e,t){assertPublicHostname(e.hostname);let{Agent:n,Dispatcher1Wrapper:r}=await import(`undici`),i=new r(new n({connect:{lookup:createPublicLookup()}}));try{return{dispatcher:i,response:await fetchWithDispatcher(e,{dispatcher:i,headers:t.headers,redirect:`manual`,signal:t.signal})}}catch(e){throw await i.close(),e}}function fetchWithDispatcher(e,t){return fetch(e,t)}function assertPublicHostname(t){let n=t.replace(/^\[(.*)\]$/u,`$1`);if(isIP(n)!==0){assertPublicAddress(n);return}if(isLoopbackHostname(n))throw Error(UNSAFE_DESTINATION_ERROR)}function assertPublicAddress(e){if(isPrivateOrReservedIpAddress(e))throw Error(UNSAFE_DESTINATION_ERROR)}function createPublicLookup(){return(e,t,r)=>{lookup(e,{all:!0,verbatim:!0},(n,i)=>{if(n!==null){r(n,``,0);return}try{for(let{address:e}of i)assertPublicAddress(e)}catch(e){r(e,``,0);return}let a=t.family===void 0||t.family===0?i:i.filter(({family:e})=>e===t.family);if(a.length===0){let t=Error(`Unable to resolve URL hostname "${e}" in the requested IP family.`);Object.assign(t,{code:`ENOTFOUND`}),r(t,``,0);return}if(t.all===!0){r(null,a);return}let o=a[0];r(null,o.address,o.family)})}}async function consumeResponse(e,t){let n=parseContentLength(e.headers.get(`content-length`));if(n!==void 0&&n>t)throw await cancelResponseBody(e),createResponseTooLargeError();let r=await readBoundedBody(e,t),i=r.byteLength===0?null:Uint8Array.from(r).buffer;return new Response(i,{headers:e.headers,status:e.status,statusText:e.statusText})}function parseContentLength(e){if(e===null)return;let t=Number.parseInt(e,10);return Number.isFinite(t)&&t>=0?t:void 0}async function readBoundedBody(e,t){if(e.body===null)return new Uint8Array;let n=e.body.getReader(),r=[],i=0;try{for(;;){let{done:e,value:a}=await n.read();if(e)break;if(i+=a.byteLength,i>t)throw await n.cancel(),createResponseTooLargeError();r.push(a)}}finally{n.releaseLock()}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.byteLength;return a}async function cancelResponseBody(e){try{await e.body?.cancel()}catch{}}function createResponseTooLargeError(){return Error(`Response too large (exceeds 5 MB limit).`)}export{requestPublicUrl};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{getWorldImport}from"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.
|
|
1
|
+
import{getWorldImport}from"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/world-target.js";import"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/index.js";import{resolvePackageCompiledFilePath,resolvePackageSourceFilePath}from"#internal/application/package.js";import{existsSync}from"node:fs";import{join}from"node:path";import{copyFile,mkdir,writeFile}from"node:fs/promises";import{createCompiledModuleMapSource}from"#compiler/module-map.js";import{stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{buildPackageUserAgent}from"#internal/user-agent.js";import{readMaterializedAuthoredModuleIndex}from"#internal/materialized-authored-modules.js";import{usesParentDevelopmentWorkflowWorld}from"#internal/workflow/development-world-protocol.js";async function writeCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),a=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),s=resolveInstrumentationModule(e.compileResult.manifest.agentRoot);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,await createCompiledArtifactsBootstrapSource({compileResult:e.compileResult,installModulePath:resolvePackageSourceFilePath(`src/runtime/loaders/bundled-artifacts.ts`),moduleMapPath:t,metadata:e.compileResult.metadata})),await writeFile(a,createWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world,defaultWorld:e.defaultWorkflowWorld})),s!==void 0&&await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,instrumentationPath:s,registerConfigPath:resolvePackageSourceFilePath(`src/harness/instrumentation-config.ts`)}));let c={bootstrapPath:t,workflowWorldPluginPath:a};return s!==void 0&&(c.instrumentationPluginPath=r,c.instrumentationSourcePath=s),c}async function writeDevelopmentCompiledArtifactsFiles(e){let t=join(e.outDir,`compiled-artifacts-bootstrap.mjs`),r=join(e.outDir,`compiled-artifacts-instrumentation.mjs`),s=join(e.outDir,`compiled-artifacts-instrumentation-source.mjs`),c=join(e.outDir,`compiled-artifacts-workflow-world.mjs`),l=await readMaterializedAuthoredModuleIndex(e.runtimeAppRoot);if(l===void 0)throw Error(`Development generation at "${e.runtimeAppRoot}" is not materialized.`);await mkdir(e.outDir,{recursive:!0}),await writeFile(t,createDevelopmentCompiledArtifactsBootstrapSource(e.compileResult.manifest.config.name)),await writeFile(c,createDevelopmentWorkflowWorldPluginSource({compiledArtifactsBootstrapPath:t,configuredWorld:e.compileResult.manifest.config.experimental?.workflow?.world}));let u={bootstrapPath:t,workflowWorldPluginPath:c};return l.instrumentation!==void 0&&(await copyFile(join(e.runtimeAppRoot,`.eve`,`compile`,l.instrumentation),s),await writeFile(r,createInstrumentationPluginSource({agentName:e.compileResult.manifest.config.name,instrumentationPath:s,registerConfigPath:resolvePackageSourceFilePath(`src/harness/instrumentation-config.ts`)})),u.instrumentationPluginPath=r,u.instrumentationSourcePath=s),u}function createDevelopmentCompiledArtifactsBootstrapSource(e){return[`// Generated by eve. Do not edit by hand.`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(e)});`,``,`export default function installDevelopmentCompiledArtifactsPlugin() {}`,``].join(`
|
|
2
2
|
`)}const INSTRUMENTATION_EXTENSIONS=[`.ts`,`.mts`,`.js`,`.mjs`];function resolveInstrumentationModule(e){for(let t of INSTRUMENTATION_EXTENSIONS){let n=join(e,`instrumentation${t}`);if(existsSync(n))return n}}function stripCompiledModuleMapExports(e){return e.replace(/^export const moduleMap = /m,`const moduleMap = `).replace(/\nexport default moduleMap;\n?$/,`
|
|
3
3
|
`)}async function createCompiledArtifactsBootstrapSource(e){let t=e.compileResult.manifest.config.name,r=stripCompiledModuleMapExports(createCompiledModuleMapSource({importSpecifierStyle:`absolute`,manifest:e.compileResult.manifest,moduleMapPath:e.moduleMapPath})).trim();return[`// Generated by eve. Do not edit by hand.`,`import { installBundledCompiledArtifacts } from ${stringifyEsmImportSpecifier(e.installModulePath)};`,`import { installEveWorkflowQueueNamespace } from ${stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/queue-namespace.ts`))};`,``,`installEveWorkflowQueueNamespace(${JSON.stringify(t)});`,``,r,``,`const metadata = ${JSON.stringify(e.metadata,null,2)};`,``,`const manifest = ${JSON.stringify(e.compileResult.manifest,null,2)};`,``,`export function installCompiledArtifactsBootstrap() {`,` installBundledCompiledArtifacts({`,` manifest,`,` metadata,`,` moduleMap,`,` });`,`}`,``,`installCompiledArtifactsBootstrap();`,``,`// Default export satisfies the Nitro plugin contract so this file`,`// can be used directly as a Nitro plugin without a separate wrapper.`,`export default function installCompiledArtifactsPlugin() {`,` // Already installed on import above.`,`}`,``].join(`
|
|
4
4
|
`)}function resolveWorkflowWorldWiring(e){if(e===`@workflow/world-local`){let r=stringifyEsmImportSpecifier(resolvePackageSourceFilePath(`src/internal/workflow/local-world-data-directory.ts`));return{moduleImportSpecifier:resolvePackageCompiledFilePath(`src/compiled/${e}/index.js`),extraImportLines:`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.27.
|
|
1
|
+
import{createRequire}from"node:module";import{existsSync,readFileSync,realpathSync}from"node:fs";import{basename,dirname,join}from"node:path";import{fileURLToPath}from"node:url";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";let cachedPackageInfo,cachedPackageLocation;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.27.13`,WORKFLOW_MODULE_ALIASES={"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function tryResolveVerifiedPackageRoot(e){try{let t=realpathSync.native(e);return tryReadInstalledPackageInfo(t,EVE_PACKAGE_NAME)===void 0?void 0:dirname(t)}catch{return}}function findNearestVerifiedPackageRoot(e){let t=e;for(;;){let e=tryResolveVerifiedPackageRoot(join(t,`package.json`));if(e!==void 0)return e;let n=dirname(t);if(n===t)return;t=n}}function tryResolveDirectBuildLocation(e){let t=dirname(e);for(;;){if(basename(t)===`dist`){let e=tryResolveVerifiedPackageRoot(join(dirname(t),`package.json`));if(e!==void 0)return{packageBuildRoot:t,packageRoot:e}}let e=dirname(t);if(e===t)return;t=e}}function isSourceCheckout(e){return existsSync(join(e,`src`,`internal`,`application`,`package.ts`))}function tryCreatePackageLocation(e){if(isSourceCheckout(e))return{packageBuildRoot:null,packageRoot:e};let n=join(e,`dist`);if(existsSync(n))return{packageBuildRoot:n,packageRoot:e}}function resolveSelfPackageJsonPath(t){return createRequire(t).resolve(`${EVE_PACKAGE_NAME}/package.json`)}function resolvePackageLocationFromModulePath(e,t=resolveSelfPackageJsonPath){let n=realpathSync.native(e),i=tryResolveDirectBuildLocation(n);if(i!==void 0)return i;let a=findNearestVerifiedPackageRoot(dirname(n));if(a!==void 0&&isSourceCheckout(a))return{packageBuildRoot:null,packageRoot:a};try{let e=tryResolveVerifiedPackageRoot(t(n)),r=e===void 0?void 0:tryCreatePackageLocation(e);if(r!==void 0)return r}catch{}let o=a===void 0?void 0:tryCreatePackageLocation(a);if(o!==void 0)return o;throw Error(`Failed to resolve the eve package root from "${e}".`)}function resolvePackageLocation(){return cachedPackageLocation??=resolvePackageLocationFromModulePath(resolveCurrentModulePath()),cachedPackageLocation}function resolvePackageBuildRoot(){return resolvePackageLocation().packageBuildRoot}function resolvePackageRoot(){return resolvePackageLocation().packageRoot}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let r=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(r?.name===t)return r}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function readWorkflowVersionFromManifest(e){let t=e;for(let e of[t.devDependencies,t.dependencies,t.peerDependencies]){let t=e?.[`@workflow/core`];if(typeof t==`string`&&t.trim().length>0)return t}}function resolveExpectedWorkflowVersion(){let e=tryResolvePackageRoot();if(e!==void 0)try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(join(e,`package.json`),`utf8`)))}catch{}try{return readWorkflowVersionFromManifest(JSON.parse(readFileSync(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),`utf8`)))}catch{return}}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/api`||e===`workflow/runtime`)return resolvePackageSourceFilePath(`src/internal/workflow/runtime.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveExpectedWorkflowVersion,resolveInstalledPackageInfo,resolvePackageCompiledFilePath,resolvePackageDependencyPath,resolvePackageLocationFromModulePath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const BANNER_LINES=[{importLine:`import { fileURLToPath as __eveFileURLToPath } from "node:url";`,declarationLine:`const __filename = __eveFileURLToPath(import.meta.url);`,bindingPattern:/^(?:const|let|var)\s+__filename(?![\w$])/m},{importLine:`import { dirname as __eveDirname } from "node:path";`,declarationLine:`const __dirname = __eveDirname(__filename);`,bindingPattern:/^(?:const|let|var)\s+__dirname(?![\w$])/m}],REQUIRE_LINE={importLine:`import { createRequire as __eveCreateRequire } from "node:module";`,declarationLine:`const require = __eveCreateRequire(import.meta.url);`,bindingPattern:/^(?:const|let|var)\s+require(?![\w$])/m};function buildNodeEsmCompatBanner(
|
|
1
|
+
const BANNER_LINES=[{importLine:`import { fileURLToPath as __eveFileURLToPath } from "node:url";`,declarationLine:`const __filename = __eveFileURLToPath(import.meta.url);`,bindingPattern:/^(?:const|let|var)\s+__filename(?![\w$])/m},{importLine:`import { dirname as __eveDirname } from "node:path";`,declarationLine:`const __dirname = __eveDirname(__filename);`,bindingPattern:/^(?:const|let|var)\s+__dirname(?![\w$])/m}],FILENAME_BANNER_LINE=BANNER_LINES[0],DIRNAME_BANNER_LINE=BANNER_LINES[1],REQUIRE_LINE={importLine:`import { createRequire as __eveCreateRequire } from "node:module";`,declarationLine:`const require = __eveCreateRequire(import.meta.url);`,bindingPattern:/^(?:const|let|var)\s+require(?![\w$])/m};function buildNodeEsmCompatBanner(i,a={}){let o=[...BANNER_LINES];a.includeRequire===!0&&o.push(REQUIRE_LINE);let s=[],c=[],l=FILENAME_BANNER_LINE.bindingPattern.test(i),u=DIRNAME_BANNER_LINE.bindingPattern.test(i);for(let e of o)e.bindingPattern.test(i)||(s.push(e.importLine),c.push(e===DIRNAME_BANNER_LINE&&l?`const __dirname = __eveDirname(__eveFileURLToPath(import.meta.url));`:e.declarationLine));return l&&!u&&s.unshift(FILENAME_BANNER_LINE.importLine),c.length===0?``:[...s,...c].join(`
|
|
2
2
|
`)}function createNodeEsmCompatBannerPlugin(e={}){return{name:`eve-node-esm-compat-banner`,renderChunk(t,n){let r=buildNodeEsmCompatBanner(t,e);return r===``?null:{code:`${r}\n${t}`,map:createPrependedLineSourceMap({insertedLineCount:r.split(`
|
|
3
3
|
`).length,source:n?.fileName??`eve-node-esm-compat-banner-input`,sourceContent:t})}}}}function createPrependedLineSourceMap({insertedLineCount:e,source:t,sourceContent:n}){let r=n.split(`
|
|
4
4
|
`).length,i=Array.from({length:r},(e,t)=>encodeVlqFields(t===0?[0,0,0,0]:[0,0,1,0]));return{version:3,sources:[t],sourcesContent:[n],names:[],mappings:`${`;`.repeat(e)}${i.join(`;`)}`}}function encodeVlqFields(e){return e.map(e=>encodeVlqInteger(e)).join(``)}function encodeVlqInteger(e){let t=e<0?(-e<<1)+1:e<<1,n=``;do{let e=t&31;t>>>=5,t>0&&(e|=32),n+=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/`[e]}while(t>0);return n}export{buildNodeEsmCompatBanner,createNodeEsmCompatBannerPlugin};
|
|
@@ -8,11 +8,11 @@ export declare function __builtin_response_array_buffer(this: Request | Response
|
|
|
8
8
|
export declare function __builtin_response_json(this: Request | Response): Promise<unknown>;
|
|
9
9
|
export declare function __builtin_response_text(this: Request | Response): Promise<string>;
|
|
10
10
|
/**
|
|
11
|
-
* Step bridge for `
|
|
11
|
+
* Step bridge for `setAttributes`.
|
|
12
12
|
*
|
|
13
13
|
* Mirrors the `__builtin_set_attributes` step from
|
|
14
14
|
* `@workflow/workflow/internal/builtins`. The workflow-body shim's
|
|
15
|
-
* `
|
|
15
|
+
* `setAttributes` (in `internal/workflow-bundle/workflow-core-shim.ts`)
|
|
16
16
|
* dispatches into the workflow runtime with the step id
|
|
17
17
|
* `"__builtin_set_attributes"`; the runtime walks the deployment's step
|
|
18
18
|
* registry to resolve it, so the step has to live inside an
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getWorldImport}from"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.
|
|
1
|
+
import{getWorldImport}from"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/world-target.js";import"../../node_modules/.pnpm/@workflow_utils@5.0.0-beta.7/node_modules/@workflow/utils/dist/index.js";const DEVELOPMENT_WORKFLOW_WORLD_ROUTE=`/eve/v1/dev/internal/workflow-world`;function usesParentDevelopmentWorkflowWorld(e){return getWorldImport({WORKFLOW_TARGET_WORLD:e??`local`})===`@workflow/world-local`}const DEVELOPMENT_WORKFLOW_SECRET_ENV=`EVE_DEV_WORKFLOW_TRANSPORT_SECRET`,DEVELOPMENT_WORKER_APP_ROOT_ENV=`EVE_DEV_WORKER_APP_ROOT`,DEVELOPMENT_WORKFLOW_STREAM_ROUTE=`${DEVELOPMENT_WORKFLOW_WORLD_ROUTE}/stream`,DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER=`x-eve-dev-workflow-transport`,DEVELOPMENT_WORKFLOW_DELIVERY_HEADER=`x-eve-dev-workflow-delivery`,DEVELOPMENT_WORLD_OPERATIONS=[`events.create`,`events.get`,`events.list`,`events.listByCorrelationId`,`hooks.get`,`hooks.getByToken`,`hooks.list`,`getDeploymentId`,`queue`,`resolveLatestDeploymentId`,`runs.experimentalSetAttributes`,`runs.get`,`runs.list`,`steps.get`,`steps.list`,`streams.close`,`streams.getChunks`,`streams.getInfo`,`streams.list`,`streams.write`,`streams.writeMulti`];export{DEVELOPMENT_WORKER_APP_ROOT_ENV,DEVELOPMENT_WORKFLOW_DELIVERY_HEADER,DEVELOPMENT_WORKFLOW_SECRET_ENV,DEVELOPMENT_WORKFLOW_STREAM_ROUTE,DEVELOPMENT_WORKFLOW_TRANSPORT_HEADER,DEVELOPMENT_WORKFLOW_WORLD_ROUTE,DEVELOPMENT_WORLD_OPERATIONS,usesParentDevelopmentWorkflowWorld};
|
|
@@ -48,12 +48,12 @@ export declare function resumeHook(): never;
|
|
|
48
48
|
*/
|
|
49
49
|
export declare function getStepMetadata(): never;
|
|
50
50
|
/**
|
|
51
|
-
* Options accepted by {@link
|
|
51
|
+
* Options accepted by {@link setAttributes}.
|
|
52
52
|
*
|
|
53
|
-
* Mirrors `
|
|
53
|
+
* Mirrors `SetAttributesOptions` from `@workflow/core` so the
|
|
54
54
|
* eve workflow-body bundle does not have to pull the real type in.
|
|
55
55
|
*/
|
|
56
|
-
export interface
|
|
56
|
+
export interface SetAttributesOptions {
|
|
57
57
|
/**
|
|
58
58
|
* Permit attribute keys that start with the reserved `$` prefix. eve
|
|
59
59
|
* framework code passes `true` so it can write the `$eve.*` namespace;
|
|
@@ -62,7 +62,7 @@ export interface ExperimentalSetAttributesOptions {
|
|
|
62
62
|
allowReservedAttributes?: boolean;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
* Workflow-body implementation of `
|
|
65
|
+
* Workflow-body implementation of `setAttributes` for the eve
|
|
66
66
|
* bundle. Mirrors the dispatch path of `@workflow/core`'s workflow-body
|
|
67
67
|
* export (`dist/workflow/set-attributes.js`):
|
|
68
68
|
*
|
|
@@ -80,5 +80,5 @@ export interface ExperimentalSetAttributesOptions {
|
|
|
80
80
|
* validator would require pulling `@workflow/world` into the workflow body
|
|
81
81
|
* bundle.
|
|
82
82
|
*/
|
|
83
|
-
export declare function
|
|
83
|
+
export declare function setAttributes(attrs: Record<string, string | undefined>, options?: SetAttributesOptions): Promise<void>;
|
|
84
84
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const WORKFLOW_CONTEXT_SYMBOL=Symbol.for(`WORKFLOW_CONTEXT`),WORKFLOW_CREATE_HOOK=Symbol.for(`WORKFLOW_CREATE_HOOK`),WORKFLOW_GET_STREAM_ID=Symbol.for(`WORKFLOW_GET_STREAM_ID`),WORKFLOW_USE_STEP=Symbol.for(`WORKFLOW_USE_STEP`),STREAM_NAME_SYMBOL=Symbol.for(`WORKFLOW_STREAM_NAME`),workflowGlobal=globalThis;var RetryableError=class extends Error{},FatalError=class extends Error{};function createHook(e){let n=workflowGlobal[WORKFLOW_CREATE_HOOK];if(n===void 0)throw Error("`createHook()` can only be called inside a workflow function");return n(e)}function getWorkflowMetadata(){let t=workflowGlobal[WORKFLOW_CONTEXT_SYMBOL];if(t===void 0)throw Error("`getWorkflowMetadata()` can only be called inside a workflow or step function");return t}function getWritable(e={}){let t=workflowGlobal[WORKFLOW_GET_STREAM_ID];if(t===void 0)throw Error("`getWritable()` can only be called inside a workflow function");let r=t(e.namespace);return Object.create(globalThis.WritableStream.prototype,{[STREAM_NAME_SYMBOL]:{value:r,writable:!1}})}function createWebhook(e){let t=createHook(e),n=getWorkflowMetadata();return t.url=`${typeof n.url==`string`?n.url:``}/.well-known/workflow/v1/webhook/${encodeURIComponent(t.token)}`,t}function defineHook(){return{create:createHook,resume(){throw Error("`defineHook().resume()` can only be called from external contexts.")}}}function sleep(){throw Error("`sleep()` is not available in eve workflow body bundles")}function resumeHook(){throw Error("`resumeHook()` can only be called from outside a workflow function")}function getStepMetadata(){throw Error("`getStepMetadata()` can only be called inside a step function")}async function
|
|
1
|
+
const WORKFLOW_CONTEXT_SYMBOL=Symbol.for(`WORKFLOW_CONTEXT`),WORKFLOW_CREATE_HOOK=Symbol.for(`WORKFLOW_CREATE_HOOK`),WORKFLOW_GET_STREAM_ID=Symbol.for(`WORKFLOW_GET_STREAM_ID`),WORKFLOW_USE_STEP=Symbol.for(`WORKFLOW_USE_STEP`),STREAM_NAME_SYMBOL=Symbol.for(`WORKFLOW_STREAM_NAME`),workflowGlobal=globalThis;var RetryableError=class extends Error{},FatalError=class extends Error{};function createHook(e){let n=workflowGlobal[WORKFLOW_CREATE_HOOK];if(n===void 0)throw Error("`createHook()` can only be called inside a workflow function");return n(e)}function getWorkflowMetadata(){let t=workflowGlobal[WORKFLOW_CONTEXT_SYMBOL];if(t===void 0)throw Error("`getWorkflowMetadata()` can only be called inside a workflow or step function");return t}function getWritable(e={}){let t=workflowGlobal[WORKFLOW_GET_STREAM_ID];if(t===void 0)throw Error("`getWritable()` can only be called inside a workflow function");let r=t(e.namespace);return Object.create(globalThis.WritableStream.prototype,{[STREAM_NAME_SYMBOL]:{value:r,writable:!1}})}function createWebhook(e){let t=createHook(e),n=getWorkflowMetadata();return t.url=`${typeof n.url==`string`?n.url:``}/.well-known/workflow/v1/webhook/${encodeURIComponent(t.token)}`,t}function defineHook(){return{create:createHook,resume(){throw Error("`defineHook().resume()` can only be called from external contexts.")}}}function sleep(){throw Error("`sleep()` is not available in eve workflow body bundles")}function resumeHook(){throw Error("`resumeHook()` can only be called from outside a workflow function")}function getStepMetadata(){throw Error("`getStepMetadata()` can only be called inside a step function")}async function setAttributes(e,t={}){let n=Object.entries(e);if(n.length===0)return;let i=workflowGlobal[WORKFLOW_USE_STEP];if(i===void 0)throw Error("`setAttributes()` can only be called inside a workflow runtime context");let a=n.map(([e,t])=>({key:e,value:t===void 0?null:t})),o=t.allowReservedAttributes===!0?{allowReservedAttributes:!0}:{};await i(`__builtin_set_attributes`)(a,o)}export{FatalError,RetryableError,createHook,createWebhook,defineHook,getStepMetadata,getWorkflowMetadata,getWritable,resumeHook,setAttributes,sleep};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function normalizeWorkflowTargetWorldImport(e){if(e)return e===`local`?`@workflow/world-local`:e===`vercel`?`@workflow/world-vercel`:e}function isVercelDeploymentEnv(e=process.env){return e.VERCEL_DEPLOYMENT_ID?!0:e.VERCEL===`1`&&e.VERCEL_ENV!==`development`&&e.NODE_ENV!==`development`}function resolveWorkflowTargetWorld(e=process.env){return e.WORKFLOW_TARGET_WORLD||(isVercelDeploymentEnv(e)?`vercel`:`local`)}function getWorldImport(e=process.env){return normalizeWorkflowTargetWorldImport(resolveWorkflowTargetWorld(e))}function isVercelWorldTarget(e){return e===`vercel`||e===`@workflow/world-vercel`}export{getWorldImport,isVercelDeploymentEnv,isVercelWorldTarget,normalizeWorkflowTargetWorldImport,resolveWorkflowTargetWorld};
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
-
import{extractErrorId,formatErrorHint}from"#internal/logging.js";import{createLinearAgentActivity}from"#public/channels/linear/api.js";import{linearInputRequestSignal,renderLinearInputRequests}from"#public/channels/linear/hitl.js";function defaultLinearAuth(e){let t=e.agentActivity?.user??e.agentSession.creator,n=e.agentActivity?.userId??e.agentSession.creatorId??t?.id??`unknown`,r={action:e.action,agent_session_id:e.agentSession.id,organization_id:e.organizationId??e.agentSession.organizationId??``};if(e.delivery.id!==void 0&&(r.delivery_id=e.delivery.id),e.agentSession.issueId!==void 0&&e.agentSession.issueId!==null&&(r.issue_id=e.agentSession.issueId),e.agentSession.issue?.identifier!==void 0&&(r.issue_identifier=e.agentSession.issue.identifier),t!==void 0){let e=linearUserLabel(t);e!==void 0&&(r.user=e)}return{attributes:r,authenticator:`linear-agent-webhook`,issuer:e.organizationId?`linear:${e.organizationId}`:`linear`,principalId:`linear:${n}`,principalType:`user`,subject:n}}function defaultOnAgentSession(e,t){return t.action!==`created`&&t.action!==`prompted`?null:{auth:defaultLinearAuth(t)}}function createDefaultEvents(n={}){return{async"turn.started"(e,t,r){t.state.pendingToolCallMessage=null,await postActivity(t,n,{body:`Working on this.`,type:`thought`},{ephemeral:!0})},async"actions.requested"(e,t,r){let i=t.state.pendingToolCallMessage;if(t.state.pendingToolCallMessage=null,i){await postActivity(t,n,{body:i,type:`thought`},{ephemeral:!0});return}if(e.actions.length!==0){if(e.actions.length>1){await postActivity(t,n,{action:`Running`,parameter:e.actions.map(actionLabel).join(`, `),type:`action`},{ephemeral:!0});return}for(let r of e.actions)await postActivity(t,n,{action:actionLabel(r),parameter:actionParameter(r),type:`action`},{ephemeral:!0})}},async"input.requested"(e,t,a){let o=linearInputRequestSignal(e.requests);await postActivity(t,n,{body:renderLinearInputRequests(e.requests),type:`elicitation`},o)},async"message.completed"(e,t,r){if(e.finishReason===`tool-calls`){t.state.pendingToolCallMessage=e.message?firstNonEmptyLine(e.message)??null:null;return}t.state.pendingToolCallMessage=null,e.message&&await postActivity(t,n,{body:e.message,type:`response`})},async"session.failed"(r,i){let a=formatErrorHint(r),o=extractErrorId(r.details);await postActivity(i,n,{body:[`This session could not recover from an error${a}.`,``,`Start a new Linear agent session to continue.`,...o?[``,`Error id: ${o}`]:[]].join(`
|
|
1
|
+
import{extractErrorId,formatErrorHint}from"#internal/logging.js";import{createLinearAgentActivity}from"#public/channels/linear/api.js";import{linearInputRequestSignal,renderLinearInputRequests}from"#public/channels/linear/hitl.js";function defaultLinearAuth(e){let t=e.agentActivity?.user??e.agentSession.creator,n=e.agentActivity?.userId??e.agentSession.creatorId??t?.id??`unknown`,r={action:e.action,agent_session_id:e.agentSession.id,organization_id:e.organizationId??e.agentSession.organizationId??``};if(e.delivery.id!==void 0&&(r.delivery_id=e.delivery.id),e.agentSession.issueId!==void 0&&e.agentSession.issueId!==null&&(r.issue_id=e.agentSession.issueId),e.agentSession.issue?.identifier!==void 0&&(r.issue_identifier=e.agentSession.issue.identifier),t!==void 0){let e=linearUserLabel(t);e!==void 0&&(r.user=e)}return{attributes:r,authenticator:`linear-agent-webhook`,issuer:e.organizationId?`linear:${e.organizationId}`:`linear`,principalId:`linear:${n}`,principalType:`user`,subject:n}}function defaultOnAgentSession(e,t){return t.action!==`created`&&t.action!==`prompted`?null:{auth:defaultLinearAuth(t)}}function createDefaultEvents(n={}){return{async"turn.started"(e,t,r){t.state.pendingToolCallMessage=null,await postActivity(t,n,{body:`Working on this.`,type:`thought`},{ephemeral:!0})},async"actions.requested"(e,t,r){let i=t.state.pendingToolCallMessage;if(t.state.pendingToolCallMessage=null,i){await postActivity(t,n,{body:i,type:`thought`},{ephemeral:!0});return}if(e.actions.length!==0){if(e.actions.length>1){await postActivity(t,n,{action:`Running`,parameter:e.actions.map(actionLabel).join(`, `),type:`action`},{ephemeral:!0});return}for(let r of e.actions)await postActivity(t,n,{action:actionLabel(r),parameter:actionParameter(r),type:`action`},{ephemeral:!0})}},async"input.requested"(e,t,a){let o=linearInputRequestSignal(e.requests);await postActivity(t,n,{body:renderLinearInputRequests(e.requests),type:`elicitation`},o)},async"authorization.required"(e,t,r){let i=authorizationDisplayName(e.name,e.authorization?.displayName),a=e.authorization?.url,o=linearUserId(r),s;if(a!==void 0){let e={providerName:i,url:a};o!==void 0&&(e.userId=o),s={signal:`auth`,signalMetadata:e}}await postActivity(t,n,{body:authorizationRequiredBody({displayName:i,instructions:e.authorization?.instructions,userCode:e.authorization?.userCode}),type:`elicitation`},s)},async"authorization.completed"(e,t,r){let i=authorizationDisplayName(e.name,e.authorization?.displayName);if(e.outcome===`authorized`){await postActivity(t,n,{body:`Connected to ${i}. Resuming.`,type:`thought`},{ephemeral:!0});return}let a=e.reason===void 0?``:` (${e.reason})`;await postActivity(t,n,{body:`${i} authorization ${formatAuthorizationOutcome(e.outcome)}${a}.`,type:`thought`})},async"message.completed"(e,t,r){if(e.finishReason===`tool-calls`){t.state.pendingToolCallMessage=e.message?firstNonEmptyLine(e.message)??null:null;return}t.state.pendingToolCallMessage=null,e.message&&await postActivity(t,n,{body:e.message,type:`response`})},async"session.failed"(r,i){let a=formatErrorHint(r),o=extractErrorId(r.details);await postActivity(i,n,{body:[`This session could not recover from an error${a}.`,``,`Start a new Linear agent session to continue.`,...o?[``,`Error id: ${o}`]:[]].join(`
|
|
2
2
|
`),type:`error`})},async"turn.failed"(r,i,a){let o=formatErrorHint(r),s=extractErrorId(r.details);await postActivity(i,n,{body:[`I hit an error while handling your request${o}.`,``,`Please try again, rephrase, or reach out if it keeps failing.`,...s?[``,`Error id: ${s}`]:[]].join(`
|
|
3
|
-
`),type:`error`})}}}function postActivity(e,t,r,i={}){return createLinearAgentActivity({api:t.api,credentials:t.credentials,activity:{agentSessionId:requireAgentSessionId(e.state.agentSessionId),content:r,ephemeral:i.ephemeral,signal:i.signal,signalMetadata:i.signalMetadata}})}function requireAgentSessionId(e){if(e===null)throw Error(`linearChannel: cannot post Agent Activity without an Agent Session id.`);return e}function linearUserLabel(e){return e.displayName??e.name??e.email}function
|
|
3
|
+
`),type:`error`})}}}function postActivity(e,t,r,i={}){return createLinearAgentActivity({api:t.api,credentials:t.credentials,activity:{agentSessionId:requireAgentSessionId(e.state.agentSessionId),content:r,ephemeral:i.ephemeral,signal:i.signal,signalMetadata:i.signalMetadata}})}function requireAgentSessionId(e){if(e===null)throw Error(`linearChannel: cannot post Agent Activity without an Agent Session id.`);return e}function linearUserLabel(e){return e.displayName??e.name??e.email}function authorizationDisplayName(e,t){return t===void 0?e.length===0?e:e.charAt(0).toUpperCase()+e.slice(1):t}function authorizationRequiredBody(e){return[`Authorization required for ${e.displayName}.`,e.instructions,e.userCode===void 0?void 0:`Code: ${e.userCode}`].filter(e=>e!==void 0&&e.length>0).join(`
|
|
4
|
+
|
|
5
|
+
`)}function linearUserId(e){let t=e.session.auth.current;return t?.authenticator===`linear-agent-webhook`?t.subject:void 0}function formatAuthorizationOutcome(e){return e===`timed-out`?`timed out`:e}function firstNonEmptyLine(e){for(let t of e.split(/\r?\n/u)){let e=t.trim();if(e.length>0)return e}}function actionLabel(e){return e.kind===`tool-call`&&e.toolName?e.toolName:e.kind}function actionParameter(e){if(e.description)return e.description;if(e.name)return e.name;if(e.input!==void 0)try{return JSON.stringify(e.input)}catch{return``}return``}export{createDefaultEvents,defaultLinearAuth,defaultOnAgentSession};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{EVE_ATTRIBUTE_VALUE_MAX_BYTES,normalizeEveAttributes,truncateForTag}from"#runtime/attributes/normalize.js";import"#internal/workflow/builtins.js";let WARNED_ABOUT_TAG_FAILURE=!1;async function setEveAttributes(e){let t=normalizeEveAttributes(e);if(Object.keys(t).length!==0)try{let{
|
|
1
|
+
import{EVE_ATTRIBUTE_VALUE_MAX_BYTES,normalizeEveAttributes,truncateForTag}from"#runtime/attributes/normalize.js";import"#internal/workflow/builtins.js";let WARNED_ABOUT_TAG_FAILURE=!1;async function setEveAttributes(e){let t=normalizeEveAttributes(e);if(Object.keys(t).length!==0)try{let{setAttributes:e}=await import(`#compiled/@workflow/core/index.js`);await e(t,{allowReservedAttributes:!0})}catch(e){WARNED_ABOUT_TAG_FAILURE||(WARNED_ABOUT_TAG_FAILURE=!0,console.warn(`[eve] setEveAttributes failed; suppressing further warnings this process.`,{keys:Object.keys(t),error:e.message}))}}export{EVE_ATTRIBUTE_VALUE_MAX_BYTES,setEveAttributes,truncateForTag};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { ClientOptions } from "#client/index.js";
|
|
2
2
|
import type { DevelopmentCredentialGate } from "./credential-gate.js";
|
|
3
3
|
type DevelopmentClientHeaders = Readonly<Record<string, string>>;
|
|
4
|
+
/** Returns whether development request headers explicitly own HTTP authorization. */
|
|
5
|
+
export declare function hasDevelopmentAuthorizationHeader(headers: DevelopmentClientHeaders | undefined): headers is DevelopmentClientHeaders;
|
|
4
6
|
/**
|
|
5
7
|
* Builds anonymous {@link ClientOptions} for a development target. Locality is
|
|
6
8
|
* not an authorization decision, so remote URLs receive no ambient Vercel
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";function
|
|
1
|
+
import{VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER}from"#client/types.js";function hasDevelopmentAuthorizationHeader(e){return e!==void 0&&Object.keys(e).some(e=>e.toLowerCase()===`authorization`)}async function resolveRemoteHeaders(t){if(!t.includeTrustedOidcHeader)return{...await t.credentials.resolveBypassHeaders(),...t.headers};let[n,r]=await Promise.all([t.credentials.resolveBypassHeaders(),t.credentials.resolveToken()]),i={...n,...t.headers},a=r.trim();return a.length>0&&(i[VERCEL_TRUSTED_OIDC_IDP_TOKEN_HEADER]=a),i}function resolveDevelopmentClientOptions(e){return{host:e}}function resolveLocalDevelopmentClientOptions(e){let t={host:e.serverUrl,redirect:`manual`};if(hasDevelopmentAuthorizationHeader(e.headers))return{...t,headers:e.headers};let n={...t,auth:{bearer:e.token}};return e.headers===void 0?n:{...n,headers:e.headers}}function resolveRemoteDevelopmentClientOptions(e){let t=new URL(e.serverUrl).origin;if(e.credentials.serverOrigin!==t)throw Error(`Credential gate origin ${e.credentials.serverOrigin} does not match client origin ${t}.`);return hasDevelopmentAuthorizationHeader(e.headers)?{headers:()=>resolveRemoteHeaders({credentials:e.credentials,headers:e.headers,includeTrustedOidcHeader:!0}),host:e.serverUrl,redirect:`manual`}:{auth:{vercelOidc:{token:()=>e.credentials.resolveToken()}},headers:e.headers===void 0?e.credentials.resolveBypassHeaders:()=>resolveRemoteHeaders({credentials:e.credentials,headers:e.headers,includeTrustedOidcHeader:!1}),host:e.serverUrl,redirect:`manual`}}export{hasDevelopmentAuthorizationHeader,resolveDevelopmentClientOptions,resolveLocalDevelopmentClientOptions,resolveRemoteDevelopmentClientOptions};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/** Server target used by development clients. */
|
|
2
|
+
interface DevelopmentTargetBase {
|
|
3
|
+
readonly serverUrl: string;
|
|
4
|
+
/** Local workspace root for app files and the fallback Vercel project link. */
|
|
5
|
+
readonly workspaceRoot: string;
|
|
6
|
+
}
|
|
7
|
+
/** A development client backed by a local `eve dev` server. */
|
|
8
|
+
export interface LocalDevelopmentTarget extends DevelopmentTargetBase {
|
|
9
|
+
readonly kind: "local";
|
|
10
|
+
}
|
|
11
|
+
/** A development client connected to an existing remote server. */
|
|
12
|
+
export interface RemoteDevelopmentTarget extends DevelopmentTargetBase {
|
|
13
|
+
readonly kind: "remote";
|
|
14
|
+
}
|
|
15
|
+
/** Local or remote server backing a development client. */
|
|
16
|
+
export type DevelopmentTarget = LocalDevelopmentTarget | RemoteDevelopmentTarget;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export{};
|