eve 0.70.0 → 0.70.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +37 -0
- package/dist/src/channel/adapter.js +1 -1
- package/dist/src/channel/channel-operations.js +1 -1
- package/dist/src/channel/resolve-text.d.ts +8 -0
- package/dist/src/channel/resolve-text.js +2 -1
- package/dist/src/cli/banner.d.ts +2 -2
- package/dist/src/cli/banner.js +1 -1
- package/dist/src/cli/commands/init-agent-workspace.js +1 -1
- package/dist/src/cli/commands/init.js +1 -1
- package/dist/src/cli/dev/tui/prompt-commands.d.ts +7 -7
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/runner.d.ts +4 -3
- package/dist/src/cli/dev/tui/runner.js +2 -2
- package/dist/src/cli/dev/tui/task-activity.d.ts +0 -17
- package/dist/src/cli/dev/tui/task-activity.js +1 -1
- package/dist/src/cli/dev/tui/task-records.d.ts +17 -0
- package/dist/src/cli/dev/tui/task-records.js +1 -0
- package/dist/src/cli/dev/tui/terminal-renderer.js +2 -2
- package/dist/src/cli/dev/tui/test/mock-terminal.d.ts +7 -1
- package/dist/src/cli/dev/tui/test/mock-terminal.js +4 -3
- package/dist/src/cli/dev/tui/theme.d.ts +1 -1
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/tool-presentation.d.ts +15 -2
- package/dist/src/cli/dev/tui/tool-presentation.js +1 -1
- package/dist/src/cli/dev/tui/transcript-parts.d.ts +10 -2
- package/dist/src/cli/dev/tui/transcript-parts.js +2 -2
- package/dist/src/cli/dev/tui/transcript.js +1 -1
- package/dist/src/compiled/.vendor-stamp.json +8 -8
- package/dist/src/compiled/@photon-ai/chat-adapter-imessage/index.js +1 -1
- package/dist/src/compiled/@vercel/sandbox/index.js +1 -1
- package/dist/src/compiled/@workflow/core/index.js +2 -2
- package/dist/src/compiled/@workflow/core/runtime/constants.d.ts +15 -0
- package/dist/src/compiled/@workflow/core/runtime/dynamic-workflow.d.ts +182 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/runtime/helpers.js +1 -1
- package/dist/src/compiled/@workflow/core/runtime/quickjs-assets.generated.d.ts +7 -0
- package/dist/src/compiled/@workflow/core/runtime/quickjs-entrypoint.d.ts +2 -30
- package/dist/src/compiled/@workflow/core/runtime/quickjs-log-view.d.ts +27 -4
- package/dist/src/compiled/@workflow/core/runtime/quickjs-runtime.d.ts +55 -3
- package/dist/src/compiled/@workflow/core/runtime/quickjs-snapshot-codec.d.ts +74 -0
- package/dist/src/compiled/@workflow/core/runtime/start.d.ts +4 -0
- package/dist/src/compiled/@workflow/core/runtime/vm-mode.d.ts +44 -0
- package/dist/src/compiled/@workflow/core/runtime.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/runtime.js +4 -4
- package/dist/src/compiled/@workflow/core/schemas.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/serialization/compression.d.ts +27 -2
- package/dist/src/compiled/@workflow/core/serialization/hardened.d.ts +8 -0
- package/dist/src/compiled/@workflow/core/serialization/types.d.ts +1 -0
- package/dist/src/compiled/@workflow/core/serialization.d.ts +48 -0
- package/dist/src/compiled/@workflow/core/serialization.js +1 -1
- package/dist/src/compiled/@workflow/core/set-error-stack.d.ts +12 -0
- package/dist/src/compiled/@workflow/core/telemetry/semantic-conventions.d.ts +47 -0
- package/dist/src/compiled/@workflow/core/version.d.ts +1 -1
- package/dist/src/compiled/@workflow/core/workflow.js +1 -1
- package/dist/src/compiled/@workflow/world/events.d.ts +10 -0
- package/dist/src/compiled/@workflow/world/index.d.ts +2 -0
- package/dist/src/compiled/@workflow/world/interfaces.d.ts +127 -0
- package/dist/src/compiled/@workflow/world/queue.d.ts +6 -0
- package/dist/src/compiled/@workflow/world/runs.d.ts +9 -2
- package/dist/src/compiled/@workflow/world/snapshots.d.ts +60 -0
- package/dist/src/compiled/@workflow/world-local/index.js +5 -5
- package/dist/src/compiled/@workflow/world-vercel/index.js +19 -17
- package/dist/src/compiled/_chunks/node/undici-B61sz6UT.js +95 -0
- package/dist/src/compiled/_chunks/workflow/{attribute-changes-D721NpZv.js → attribute-changes-VaTKT4K8.js} +3 -3
- package/dist/src/compiled/_chunks/workflow/dist-B7NC1c9-.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{functions-DpZiBxgQ.js → functions-CKkqf9V6.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/helpers-CP9TjeO8.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{logger-D4GJNTk4.js → logger-oqfblE3p.js} +2 -2
- package/dist/src/compiled/_chunks/workflow/resume-hook-yq-NAdBu.js +1 -0
- package/dist/src/compiled/_chunks/workflow/run-DYKeqbob.js +32 -0
- package/dist/src/compiled/_chunks/workflow/serialization-APSKphN5.js +3 -0
- package/dist/src/compiled/_chunks/workflow/signal-exit-iIdjQcCK.js +95 -0
- package/dist/src/compiled/_chunks/workflow/sleep-Ba8SExMt.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{token-BhlnqoHM.js → token-BKeK6DmC.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/token-Cv2GYj9A.js +1 -0
- package/dist/src/compiled/_chunks/workflow/{token-util-DaeRTzDa.js → token-util-CddTZ_ef.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{wait-until-3_1djUuL.js → wait-until-Dc9s3yyP.js} +1 -1
- package/dist/src/compiled/_chunks/workflow/{wrapper-CzrF_dmI.js → wrapper-Dq4OeGmJ.js} +4 -4
- package/dist/src/compiled/{gray-matter → js-yaml}/LICENSE +2 -2
- package/dist/src/compiled/js-yaml/index.d.ts +12 -0
- package/dist/src/compiled/js-yaml/index.js +34 -0
- package/dist/src/compiled/shadcn-registry/index.js +4 -4
- package/dist/src/context/serialize.d.ts +5 -1
- package/dist/src/context/serialize.js +1 -1
- package/dist/src/discover/discover-agent.js +1 -1
- package/dist/src/discover/extension-specifier.d.ts +1 -0
- package/dist/src/discover/extension-specifier.js +1 -1
- package/dist/src/discover/extensions.d.ts +1 -1
- package/dist/src/discover/extensions.js +1 -1
- package/dist/src/discover/project-source.d.ts +5 -0
- package/dist/src/discover/project-source.js +1 -1
- package/dist/src/evals/loaders/yaml.js +1 -1
- package/dist/src/evals/session.d.ts +1 -0
- package/dist/src/evals/session.js +1 -1
- package/dist/src/evals/types.d.ts +6 -0
- package/dist/src/execution/dynamic-workflow/tool.js +1 -1
- package/dist/src/execution/legacy-remote-agent/protocol.d.ts +8 -0
- package/dist/src/execution/legacy-remote-agent/protocol.js +1 -1
- package/dist/src/execution/legacy-session/turn-workflow.js +1 -1
- package/dist/src/execution/proxied-deliver-step.d.ts +11 -0
- package/dist/src/execution/proxied-deliver-step.js +1 -1
- package/dist/src/execution/sandbox/read-file.d.ts +8 -1
- package/dist/src/execution/sandbox/read-file.js +3 -3
- package/dist/src/execution/session/active-turn.d.ts +4 -1
- package/dist/src/execution/session/active-turn.js +1 -1
- package/dist/src/execution/session/checkpoint-migrations.d.ts +23 -0
- package/dist/src/execution/session/checkpoint-migrations.js +1 -0
- package/dist/src/execution/session/entry-input.d.ts +23 -5
- package/dist/src/execution/session/entry.js +1 -1
- package/dist/src/execution/session/finalization.js +1 -1
- package/dist/src/execution/session/handoff-steps.d.ts +24 -5
- package/dist/src/execution/session/handoff-steps.js +1 -1
- package/dist/src/execution/session/handoff.d.ts +40 -16
- package/dist/src/execution/session/handoff.js +1 -1
- package/dist/src/execution/session/pending-turn-state.d.ts +2 -0
- package/dist/src/execution/session/pending-turn-state.js +1 -1
- package/dist/src/execution/session/program.d.ts +16 -3
- package/dist/src/execution/session/program.js +1 -1
- package/dist/src/execution/session/turn-step-result.js +1 -1
- package/dist/src/execution/session/turn-step-types.d.ts +13 -1
- package/dist/src/execution/session/turn-step.js +1 -1
- package/dist/src/execution/session/turn.d.ts +14 -2
- package/dist/src/execution/session/turn.js +1 -1
- package/dist/src/execution/tools/agent-router-workflow.js +1 -1
- package/dist/src/execution/workflow-runtime.d.ts +4 -4
- package/dist/src/execution/workflow-runtime.js +1 -1
- package/dist/src/harness/attachment-staging.d.ts +27 -7
- package/dist/src/harness/attachment-staging.js +1 -1
- package/dist/src/harness/compaction-prompt.js +2 -2
- package/dist/src/harness/input-requests.js +1 -1
- package/dist/src/harness/messages.js +1 -1
- package/dist/src/harness/token-estimate.d.ts +5 -3
- package/dist/src/harness/token-estimate.js +1 -1
- package/dist/src/harness/tool-loop.js +2 -2
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/attachments/media-metadata.d.ts +25 -0
- package/dist/src/internal/attachments/media-metadata.js +1 -0
- package/dist/src/internal/attachments/sandbox-refs.d.ts +12 -7
- package/dist/src/internal/attachments/sandbox-refs.js +1 -1
- package/dist/src/internal/authored-module-loader.js +1 -1
- package/dist/src/internal/bundler/extension-mount-plugin.d.ts +4 -0
- package/dist/src/internal/bundler/extension-mount-plugin.js +1 -1
- package/dist/src/internal/bundler/extension-scope-plugin.js +2 -2
- package/dist/src/internal/helpers/frontmatter.d.ts +24 -0
- package/dist/src/internal/helpers/frontmatter.js +1 -0
- package/dist/src/internal/helpers/markdown.js +1 -3
- package/dist/src/internal/input-text.d.ts +12 -0
- package/dist/src/internal/input-text.js +1 -0
- package/dist/src/internal/nitro/host/create-application-nitro.js +1 -1
- package/dist/src/internal/nitro/host/nitro-bundler-config.js +1 -1
- package/dist/src/internal/node-esm-compat-banner.js +1 -1
- package/dist/src/internal/workflow/vercel-world-defaults.d.ts +1 -1
- package/dist/src/internal/workflow/vercel-world-defaults.js +1 -1
- package/dist/src/public/channels/chat-sdk/input-actions.d.ts +8 -2
- package/dist/src/public/channels/chat-sdk/input-actions.js +4 -1
- package/dist/src/public/channels/github/defaults.js +2 -3
- package/dist/src/public/channels/linear/hitl.js +2 -3
- package/dist/src/public/channels/slack/action-status.d.ts +10 -5
- package/dist/src/public/channels/slack/action-status.js +1 -1
- package/dist/src/public/channels/slack/defaults.js +3 -3
- package/dist/src/public/channels/slack/limits.d.ts +1 -1
- package/dist/src/public/channels/slack/limits.js +1 -1
- package/dist/src/public/channels/slack/slackChannel.d.ts +11 -9
- package/dist/src/public/channels/slack/slackChannel.js +1 -1
- package/dist/src/public/channels/slack/task-card.js +1 -1
- package/dist/src/public/channels/slack/thread-status.d.ts +33 -0
- package/dist/src/public/channels/slack/thread-status.js +1 -0
- package/dist/src/public/channels/twilio/defaults.js +4 -2
- package/dist/src/public/definitions/state.d.ts +2 -0
- package/dist/src/public/definitions/state.js +1 -1
- package/dist/src/runtime/connections/openapi-spec.d.ts +1 -4
- package/dist/src/runtime/connections/openapi-spec.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +1 -1
- package/dist/src/setup/scaffold/create/web-template.d.ts +4 -4
- package/dist/src/setup/scaffold/create/web-template.js +33 -26
- package/dist/src/subagents/callback-route.js +1 -1
- package/dist/src/subagents/hitl-proxy.d.ts +2 -2
- package/dist/src/subagents/hitl-proxy.js +1 -1
- package/dist/src/subagents/parent-notification.d.ts +7 -7
- package/dist/src/subagents/parent-notification.js +1 -1
- package/dist/src/tools/provided/ask-question-workflow.js +1 -1
- package/dist/src/tools/provided/read-file.d.ts +7 -0
- package/dist/src/tools/provided/read-file.js +2 -2
- package/dist/src/tools/provided/sleep-workflow.js +1 -1
- package/docs/agent-config.md +2 -2
- package/docs/channels/chat-sdk.mdx +1 -1
- package/docs/channels/slack.mdx +21 -15
- package/docs/channels/twilio.mdx +1 -1
- package/docs/concepts/built-in-tools.md +1 -1
- package/docs/concepts/default-harness.md +4 -0
- package/docs/concepts/execution-model-and-durability.mdx +9 -1
- package/docs/concepts/sessions-runs-and-streaming.md +3 -3
- package/docs/evals/cases.mdx +1 -0
- package/docs/extensions.md +6 -3
- package/docs/guides/dev-tui.md +5 -3
- package/docs/guides/dynamic-capabilities.md +1 -1
- package/docs/sandbox/index.mdx +11 -0
- package/docs/tools/overview.mdx +4 -2
- package/package.json +8 -8
- package/dist/src/compiled/_chunks/node/undici-h5GH4RBM.js +0 -95
- package/dist/src/compiled/_chunks/workflow/debug-log-CVPstO1D.js +0 -1
- package/dist/src/compiled/_chunks/workflow/dist-BUFGAKRb.js +0 -1
- package/dist/src/compiled/_chunks/workflow/frames-Dr9fHWdo.js +0 -3
- package/dist/src/compiled/_chunks/workflow/helpers-DkKxg_yn.js +0 -1
- package/dist/src/compiled/_chunks/workflow/resume-hook-uTW-jBYz.js +0 -1
- package/dist/src/compiled/_chunks/workflow/run-5DmiMN9b.js +0 -1
- package/dist/src/compiled/_chunks/workflow/serialization-CNIYl1D3.js +0 -3
- package/dist/src/compiled/_chunks/workflow/signal-exit-DZKTacNU.js +0 -95
- package/dist/src/compiled/_chunks/workflow/sleep-DFKgN7UG.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-1wSBbi5N.js +0 -1
- package/dist/src/compiled/_chunks/workflow/token-util-Cm4Ec1Bg.js +0 -1
- package/dist/src/compiled/_chunks/workflow/ws-transport--rYOVIaf.js +0 -1
- package/dist/src/compiled/gray-matter/index.d.ts +0 -62
- package/dist/src/compiled/gray-matter/index.js +0 -48
- package/dist/src/internal/helpers/gray-matter.d.ts +0 -25
- package/dist/src/internal/helpers/gray-matter.js +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as e,o as t,t as n}from"../../_chunks/node/rolldown-runtime-tZXQYakl.js";import{n as r,t as i}from"../../_chunks/node/dist-DsNhwdzf.js";import{n as a,t as o}from"../../_chunks/node/retry-hTJQ4iNT.js";import{t as s}from"../../_chunks/node/undici-h5GH4RBM.js";import{t as c}from"../../_chunks/node/version-C__MqbLM.js";import{n as l,r as u,t as d}from"../../_chunks/node/token-util-DpJNusVS.js";import{Readable as f}from"stream";import p from"zlib";import m,{dirname as h,resolve as g}from"path";import{createWriteStream as _}from"fs";import{z as v}from"#compiled/zod/index.js";import y from"os";import{pipeline as b}from"stream/promises";import{mkdir as x}from"fs/promises";import*as S from"node:constants";import{setTimeout as C}from"node:timers/promises";var w=class e extends Error{constructor(t,n){super(t.statusText),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.response=t,this.message=n?.message??``,this.json=n?.json,this.text=n?.text,this.sandboxName=n?.sandboxName,this.sessionId=n?.sessionId}},T=class e extends Error{constructor(t,n,r){super(n),this.name=`StreamError`,this.code=t,this.sessionId=r,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};const ee=`iad1`;function te(e){return e==null?[]:Array.isArray(e)?e:[e]}var ne=t(n(((e,t)=>{var n=o();function r(e,t){function r(r,i){var a=t||{},o;`randomize`in a||(a.randomize=!0),o=n.operation(a);function s(e){i(e||Error(`Aborted`))}function c(e,t){if(e.bail){s(e);return}o.retry(e)?a.onRetry&&a.onRetry(e,t):i(o.mainError())}function l(t){var n;try{n=e(s,t)}catch(e){c(e,t);return}Promise.resolve(n).then(r).catch(function(e){c(e,t)})}o.attempt(l)}return new Promise(r)}t.exports=r}))(),1);function re(e){return async(t,n={})=>{let r=Object.assign({minTimeout:400,retries:2,factor:2},n.retry);n.onRetry&&(r.onRetry=(e,t)=>{n.onRetry(e,n),n.retry&&n.retry.onRetry&&n.retry.onRetry(e,t)});try{return await(0,ne.default)(async(i,a)=>{try{if(n.signal?.aborted)return i(n.signal.reason||Error(`Request aborted`));let o=await e(t,n);if(o.status===429){let e=Number(o.headers.get(`Retry-After`));if(e>20)return i(new w(o));let t=r.forever||a<=r.retries;throw e>0&&t&&await ie(e*1e3,n.signal),new w(o)}if(o.status>=500&&o.status<600)throw new w(o);return o}catch(e){if(ae(e))return i(e);if(n.signal?.aborted)return i(n.signal.reason||Error(`Request aborted`));throw e}},r)}catch(e){if(e instanceof w)return e.response;throw e}}}async function ie(e,t){if(t?.aborted)throw t.reason||Error(`Request aborted`);await new Promise((n,r)=>{let i=()=>{clearTimeout(a),r(t?.reason||Error(`Request aborted`))},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n(null)},e);t?.addEventListener(`abort`,i,{once:!0})})}function ae(e){return e!=null&&e.name===`AbortError`}const oe=new(s()).Agent({bodyTimeout:0});var se=class{constructor(e){this.fetch=re(e.fetch??globalThis.fetch),this.baseUrl=e.baseUrl,this.debug=e.debug??process.env.DEBUG_FETCH===`true`,this.token=e.token,this.agent=oe}async request(e,t){let n=new URL(`${this.baseUrl}${e}`);if(t?.query)for(let[e,r]of Object.entries(t.query))te(r).forEach(t=>{n.searchParams.append(e,t.toString())});let r=Date.now(),i=await this.fetch(n.toString(),{...t,body:t?.body,method:t?.method||`GET`,headers:this.token?{Authorization:`Bearer ${this.token}`,...t?.headers}:t?.headers,dispatcher:this.agent,signal:t?.signal});if(this.debug){let e=Date.now()-r;if(console.log(`[API] ${n} (${i.status}) ${e}ms`),i.status===429){let e=parseInt(i.headers.get(`Retry-After`)??``,10),t=Math.floor(e/60/60),r=Math.floor(e/60)%60,a=e%60;console.warn(`[API] ${n} Rate Limited, Retry After ${t}h ${r}m ${a}s`)}}return i}};function E(e){return e.match(/\/v2\/sandboxes\/sessions\/([^/?]+)/)?.[1]}function ce(e){return e.match(/\/v2\/sandboxes\/(?!sessions(?:\/|$|\?))(?!snapshots(?:\/|$|\?))([^/?]+)/)?.[1]}const le=v.object({error:v.object({message:v.string()})});function ue(e){let t=le.safeParse(e);return t.success?t.data.error.message:void 0}async function de(e,t){let n=E(t.url),r;n||(r=ce(t.url));let i=await t.text().catch(e=>new w(t,{message:`Can't read response text: ${String(e)}`,sessionId:n,sandboxName:r}));if(typeof i!=`string`)return i;let a;try{a=JSON.parse(i||`{}`)}catch(e){return new w(t,{message:`Can't parse JSON: ${String(e)}`,text:i,sessionId:n,sandboxName:r})}if(!t.ok){let e=ue(a);return new w(t,{message:e?`Status code ${t.status} is not ok: ${e}`:`Status code ${t.status} is not ok`,json:a,text:i,sessionId:n,sandboxName:r})}let o=e.safeParse(a);return o.success?{json:o.data,response:t,text:i}:new w(t,{message:`Response JSON is not valid: ${o.error}`,json:a,text:i,sessionId:n,sandboxName:r})}async function D(e,t){let n=await de(e,t);if(n instanceof w)throw n;return n}const fe=v.object({exact:v.string().optional(),startsWith:v.string().optional(),regex:v.string().optional()}),pe=v.object({key:fe.optional(),value:fe.optional()}),me=v.object({path:fe.optional(),method:v.array(v.string()).optional(),queryString:v.array(pe).optional(),headers:v.array(pe).optional()}),he=v.object({domain:v.string(),headers:v.record(v.string(),v.string()).optional(),headerNames:v.array(v.string()).optional(),match:me.optional()}),ge=v.object({domain:v.string(),forwardURL:v.string(),match:me.optional()}),_e=v.object({headers:v.record(v.string(),v.string()).optional()}),ve=v.object({match:me.optional(),transform:v.array(_e).optional(),forwardURL:v.string().optional()}).refine(({transform:e,forwardURL:t})=>e===void 0||t===void 0,{message:`transform and forwardURL cannot be used together`}).refine(({transform:e,forwardURL:t})=>e!==void 0||t!==void 0,{message:`transform or forwardURL must be provided`}),ye=v.object({allow:v.union([v.array(v.string()),v.record(v.string(),v.array(ve))]).optional(),subnets:v.object({allow:v.array(v.string()).optional(),deny:v.array(v.string()).optional()}).optional()}),be=v.union([v.object({mode:v.literal(`allow-all`)}).passthrough(),v.object({mode:v.literal(`deny-all`)}).passthrough()]),xe=v.object({mode:v.literal(`custom`),allowedDomains:v.array(v.string()).optional(),allowedCIDRs:v.array(v.string()).optional(),deniedCIDRs:v.array(v.string()).optional(),injectionRules:v.array(he).optional(),forwardRules:v.array(ge).optional()}).passthrough(),Se=v.union([be,ye.passthrough()]),Ce=v.union([be,xe]),O=v.object({id:v.string(),memory:v.number(),vcpus:v.number(),region:v.string(),runtime:v.string().optional(),timeout:v.number(),status:v.enum([`pending`,`running`,`stopping`,`stopped`,`failed`,`aborted`,`snapshotting`]),requestedAt:v.number(),startedAt:v.number().optional(),requestedStopAt:v.number().optional(),stoppedAt:v.number().optional(),abortedAt:v.number().optional(),duration:v.number().optional(),sourceSnapshotId:v.string().optional(),snapshottedAt:v.number().optional(),createdAt:v.number(),cwd:v.string(),updatedAt:v.number(),interactivePort:v.number().optional(),networkPolicy:Ce.optional(),activeCpuDurationMs:v.number().optional(),networkTransfer:v.object({ingress:v.number(),egress:v.number()}).optional()}),k=v.object({url:v.string(),subdomain:v.string(),port:v.number()}),A=v.object({id:v.string(),sourceSessionId:v.string(),region:v.string(),regions:v.array(v.string()).optional(),status:v.enum([`created`,`deleted`,`failed`]),sizeBytes:v.number(),expiresAt:v.number().optional(),createdAt:v.number(),updatedAt:v.number(),lastUsedAt:v.number().optional(),creationMethod:v.string().optional(),parentId:v.string().optional()}),j=v.object({count:v.number(),next:v.string().nullable()}),we=v.object({id:v.string(),name:v.string(),args:v.array(v.string()),cwd:v.string(),sessionId:v.string(),exitCode:v.number().nullable(),durationMs:v.number().optional(),startedAt:v.number()}),Te=we.extend({exitCode:v.number()}),M=v.object({session:O.passthrough()}),Ee=M.extend({routes:v.array(k)}),De=v.object({url:v.string(),token:v.string()}),N=v.object({sessions:v.array(O.passthrough()),pagination:j}),Oe=v.object({command:we}),ke=v.object({command:Te}),Ae=v.object({}),je=v.object({data:v.string()}),Me=je.extend({stream:v.literal(`stdout`)}),Ne=je.extend({stream:v.literal(`stderr`)}),Pe=v.object({stream:v.literal(`error`),data:v.object({code:v.string(),message:v.string()})}),Fe=v.discriminatedUnion(`stream`,[Me,Ne,Pe]),Ie=v.object({snapshots:v.array(A),pagination:j}),Le=v.object({snapshot:A,siblings:v.array(A),count:v.string()}),Re=v.object({snapshots:v.array(Le),anchor:Le.optional(),pagination:j}),ze=v.object({snapshot:A,session:O.passthrough()}),Be=v.object({snapshot:A}),Ve=v.object({id:v.string(),name:v.string(),projectId:v.string(),region:v.string(),maxSizeBytes:v.number(),currentSessionId:v.string().optional(),currentSandboxName:v.string().optional(),createdAt:v.number(),updatedAt:v.number()}),He=v.object({drives:v.array(Ve),pagination:j}),Ue=v.object({drive:Ve}),We=v.object({name:v.string(),persistent:v.boolean(),region:v.string().optional(),failoverRegions:v.array(v.string()).optional(),vcpus:v.number().optional(),memory:v.number().optional(),runtime:v.string().optional(),image:v.string().optional(),timeout:v.number().optional(),networkPolicy:Ce.optional(),totalEgressBytes:v.number().optional(),totalIngressBytes:v.number().optional(),totalActiveCpuDurationMs:v.number().optional(),totalDurationMs:v.number().optional(),createdAt:v.number(),updatedAt:v.number(),expiresAt:v.number().optional(),currentSessionId:v.string(),currentSnapshotId:v.string().optional(),status:O.shape.status,statusUpdatedAt:v.number().optional(),cwd:v.string().optional(),tags:v.record(v.string(),v.string()).optional(),mounts:v.record(v.string(),v.object({drive:v.string(),mode:v.enum([`snapshot`,`read-write`,`read-only`]).optional()}).transform(e=>({drive:e.drive,mode:e.mode===`read-only`?`snapshot`:e.mode??`read-write`}))).optional(),snapshotExpiration:v.number().optional(),keepLastSnapshots:v.object({count:v.number(),expiration:v.number().optional(),deleteEvicted:v.boolean().optional()}).optional()}),Ge=v.object({session:O.passthrough(),sandbox:We.optional(),snapshot:A.optional()}),Ke=v.object({sandbox:We,session:O.passthrough(),routes:v.array(k),resumed:v.boolean().optional()}),qe=v.object({sandboxes:v.array(We),pagination:j}),Je=v.object({sandbox:We,routes:v.array(k).optional()});var Ye=n(((t,n)=>{n.exports=e(`events`)})),Xe=n(((e,t)=>{t.exports=class{constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}clear(){this.top=this.btm=0,this.next=null,this.buffer.fill(void 0)}push(e){return this.buffer[this.top]===void 0&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}})),Ze=n(((e,t)=>{let n=Xe();t.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head,this.length=0}clear(){this.head=this.tail,this.head.clear(),this.length=0}push(e){if(this.length++,!this.head.push(e)){let t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){this.length!==0&&this.length--;let e=this.tail.shift();if(e===void 0&&this.tail.next){let e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}peek(){let e=this.tail.peek();return e===void 0&&this.tail.next?this.tail.next.peek():e}isEmpty(){return this.length===0}}})),Qe=n(((e,t)=>{function n(e){return Buffer.isBuffer(e)||e instanceof Uint8Array}function r(e){return Buffer.isEncoding(e)}function i(e,t,n){return Buffer.alloc(e,t,n)}function a(e){return Buffer.allocUnsafe(e)}function o(e){return Buffer.allocUnsafeSlow(e)}function s(e,t){return Buffer.byteLength(e,t)}function c(e,t){return Buffer.compare(e,t)}function l(e,t){return Buffer.concat(e,t)}function u(e,t,n,r,i){return b(e).copy(t,n,r,i)}function d(e,t){return b(e).equals(t)}function f(e,t,n,r,i){return b(e).fill(t,n,r,i)}function p(e,t,n){return Buffer.from(e,t,n)}function m(e,t,n,r){return b(e).includes(t,n,r)}function h(e,t,n,r){return b(e).indexOf(t,n,r)}function g(e,t,n,r){return b(e).lastIndexOf(t,n,r)}function _(e){return b(e).swap16()}function v(e){return b(e).swap32()}function y(e){return b(e).swap64()}function b(e){return Buffer.isBuffer(e)?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)}function x(e,t,n,r){return b(e).toString(t,n,r)}function S(e,t,n){return b(e).toString(`hex`,t,n)}function C(e,t,n,r,i){return b(e).write(t,n,r,i)}function w(e,t){return b(e).readDoubleBE(t)}function T(e,t){return b(e).readDoubleLE(t)}function ee(e,t){return b(e).readFloatBE(t)}function te(e,t){return b(e).readFloatLE(t)}function ne(e,t){return b(e).readInt32BE(t)}function re(e,t){return b(e).readInt32LE(t)}function ie(e,t){return b(e).readUInt32BE(t)}function ae(e,t){return b(e).readUInt32LE(t)}function oe(e,t,n){return b(e).writeDoubleBE(t,n)}function se(e,t,n){return b(e).writeDoubleLE(t,n)}function E(e,t,n){return b(e).writeFloatBE(t,n)}function ce(e,t,n){return b(e).writeFloatLE(t,n)}function le(e,t,n){return b(e).writeInt32BE(t,n)}function ue(e,t,n){return b(e).writeInt32LE(t,n)}function de(e,t,n){return b(e).writeUInt32BE(t,n)}function D(e,t,n){return b(e).writeUInt32LE(t,n)}t.exports={isBuffer:n,isEncoding:r,alloc:i,allocUnsafe:a,allocUnsafeSlow:o,byteLength:s,compare:c,concat:l,copy:u,equals:d,fill:f,from:p,includes:m,indexOf:h,lastIndexOf:g,swap16:_,swap32:v,swap64:y,toBuffer:b,toString:x,toHex:S,write:C,readDoubleBE:w,readDoubleLE:T,readFloatBE:ee,readFloatLE:te,readInt32BE:ne,readInt32LE:re,readUInt32BE:ie,readUInt32LE:ae,writeDoubleBE:oe,writeDoubleLE:se,writeFloatBE:E,writeFloatLE:ce,writeInt32BE:le,writeInt32LE:ue,writeUInt32BE:de,writeUInt32LE:D}})),$e=n(((e,t)=>{let n=Qe();t.exports=class{constructor(e){this.encoding=e}get remaining(){return 0}decode(e){return n.toString(e,this.encoding)}flush(){return``}}})),et=n(((e,t)=>{let n=Qe();t.exports=class{constructor(){this._reset()}get remaining(){return this.bytesSeen}decode(e){if(e.byteLength===0)return``;if(this.bytesNeeded===0&&r(e,0)===0)return this.bytesSeen=i(e),n.toString(e,`utf8`);let t=``,a=0;if(this.bytesNeeded>0){for(;a<e.byteLength;){let n=e[a];if(n<this.lowerBoundary||n>this.upperBoundary){t+=`�`,this._reset();break}if(this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|n&63,this.bytesSeen++,a++,this.bytesSeen===this.bytesNeeded){t+=String.fromCodePoint(this.codePoint),this._reset();break}}if(this.bytesNeeded>0)return t}let o=r(e,a),s=e.byteLength-o;s>a&&(t+=n.toString(e,`utf8`,a,s));for(let n=s;n<e.byteLength;n++){let r=e[n];if(this.bytesNeeded===0){r<=127?(this.bytesSeen=0,t+=String.fromCharCode(r)):r>=194&&r<=223?(this.bytesNeeded=2,this.bytesSeen=1,this.codePoint=r&31):r>=224&&r<=239?(r===224?this.lowerBoundary=160:r===237&&(this.upperBoundary=159),this.bytesNeeded=3,this.bytesSeen=1,this.codePoint=r&15):r>=240&&r<=244?(r===240?this.lowerBoundary=144:r===244&&(this.upperBoundary=143),this.bytesNeeded=4,this.bytesSeen=1,this.codePoint=r&7):(this.bytesSeen=1,t+=`�`);continue}if(r<this.lowerBoundary||r>this.upperBoundary){t+=`�`,n--,this._reset();continue}this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|r&63,this.bytesSeen++,this.bytesSeen===this.bytesNeeded&&(t+=String.fromCodePoint(this.codePoint),this._reset())}return t}flush(){let e=this.bytesNeeded>0?`�`:``;return this._reset(),e}_reset(){this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191}};function r(e,t){let n=e.byteLength;if(n<=t)return 0;let r=Math.max(t,n-4),i=n-1;for(;i>r&&(e[i]&192)==128;)i--;if(i<t)return 0;let a=e[i],o;if(a<=127)return 0;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 0;let s=n-i;return s<o?s:0}function i(e){let t=e.byteLength;if(t===0)return 0;let n=e[t-1];if(n<=127)return 0;if((n&192)!=128)return 1;let r=Math.max(0,t-4),i=t-2;for(;i>=r&&(e[i]&192)==128;)i--;if(i<0)return 1;let a=e[i],o;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 1;if(t-i!==o)return 1;if(o>=3){let t=e[i+1];if(a===224&&t<160||a===237&&t>159||a===240&&t<144||a===244&&t>143)return 1}return 0}})),tt=n(((e,t)=>{let n=$e(),r=et();t.exports=class{constructor(e=`utf8`){switch(this.encoding=i(e),this.encoding){case`utf8`:this.decoder=new r;break;case`utf16le`:case`base64`:throw Error(`Unsupported encoding: `+this.encoding);default:this.decoder=new n(this.encoding)}}get remaining(){return this.decoder.remaining}push(e){return typeof e==`string`?e:this.decoder.decode(e)}write(e){return this.push(e)}end(e){let t=``;return e&&(t=this.push(e)),t+=this.decoder.flush(),t}};function i(e){switch(e=e.toLowerCase(),e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:throw Error(`Unknown encoding: `+e)}}})),nt=n(((e,t)=>{t.exports=class e extends Error{constructor(t,n,r=e){super(t),this.code=n,Error.captureStackTrace&&Error.captureStackTrace(this,r)}static isStreamDestroyed(e){return e&&e.code===`STREAM_DESTROYED`}static isPrematureClose(e){return e&&e.code===`PREMATURE_CLOSE`}static isAborted(e){return e&&e.code===`ABORTED`}static isBadArgument(e){return e&&e.code===`BAD_ARGUMENT`}get name(){return`StreamError`}static STREAM_DESTROYED(){return new e(`Stream was destroyed`,`STREAM_DESTROYED`,e.STREAM_DESTROYED)}static PREMATURE_CLOSE(t=`Premature close`){return new e(t,`PREMATURE_CLOSE`,e.PREMATURE_CLOSE)}static ABORTED(){return new e(`Stream aborted`,`ABORTED`,e.ABORTED)}static BAD_ARGUMENT(t=`Bad argument`){return new e(t,`BAD_ARGUMENT`,e.BAD_ARGUMENT)}}})),rt=n(((e,t)=>{let{EventEmitter:n}=Ye(),r=Ze(),i=tt(),a=nt(),o=typeof queueMicrotask>`u`?e=>global.process.nextTick(e):queueMicrotask,s=536870910,c=1024,l=2048,u=16384,d=32768,f=131072,p=536805375,m=536870143,h=536838143,g=536739839,_=2<<18,v=4<<18,y=8<<18,b=32<<18,x=64<<18,S=128<<18,C=512<<18,w=1024<<18,T=503316479,ee=268435455,te=262160,ne=8404992,re=8405006,ie=33587200,ae=33587215,oe=16527,se=270794767,E=Symbol.asyncIterator||Symbol(`asyncIterator`);var ce=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapWritable:i,byteLength:a,byteLengthWritable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t,this.buffered=0,this.error=null,this.pipeline=null,this.drains=null,this.byteLength=o||a||Ie,this.map=i||n,this.afterWrite=me.bind(this),this.afterUpdateNextTick=_e.bind(this)}get ending(){return!!(this.stream._duplexState&C)}get ended(){return!!(this.stream._duplexState&b)}push(e){return this.stream._duplexState&142606350?!1:(this.map!==null&&(e=this.map(e)),this.buffered+=this.byteLength(e),this.queue.push(e),this.buffered<this.highWaterMark?(this.stream._duplexState|=y,!0):(this.stream._duplexState|=6291456,!1))}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=534773759),e}end(e){typeof e==`function`?this.stream.once(`finish`,e):e!=null&&this.push(e),this.stream._duplexState=(this.stream._duplexState|C)&535822335}autoBatch(e,t){let n=[],r=this.stream;for(n.push(e);(r._duplexState&se)==2359296;)n.push(r._writableState.shift());if(r._duplexState&15)return t(null);r._writev(n,t)}update(){let e=this.stream;e._duplexState|=_;do{for(;(e._duplexState&se)==y;){let t=this.shift();e._duplexState|=67371008,e._write(t,this.afterWrite)}e._duplexState&1310720||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536346623}updateNonPrimary(){let e=this.stream;if((e._duplexState&144965647)==C){e._duplexState|=262144,e._final(fe.bind(this));return}if((e._duplexState&14)==4){e._duplexState&ie||(e._duplexState|=te,e._destroy(pe.bind(this)));return}(e._duplexState&ae)==1&&(e._duplexState=(e._duplexState|te)&s,e._open(ye.bind(this)))}continueUpdate(){return this.stream._duplexState&S?(this.stream._duplexState&=T,!0):!1}updateCallback(){(this.stream._duplexState&35127311)==v?this.update():this.updateNextTick()}updateNextTick(){this.stream._duplexState&S||(this.stream._duplexState|=S,this.stream._duplexState&_||o(this.afterUpdateNextTick))}},le=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapReadable:i,byteLength:a,byteLengthReadable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t===0?1:t,this.buffered=0,this.readAhead=t>0,this.error=null,this.pipeline=null,this.byteLength=o||a||Ie,this.map=i||n,this.pipeTo=null,this.afterRead=he.bind(this),this.afterUpdateNextTick=ge.bind(this)}get ending(){return!!(this.stream._duplexState&c)}get ended(){return!!(this.stream._duplexState&u)}pipe(e,t){if(this.pipeTo!==null)throw a.BAD_ARGUMENT(`Can only pipe to one destination`);if(typeof t!=`function`&&(t=null),this.stream._duplexState|=512,this.pipeTo=e,this.pipeline=new de(this.stream,e,t),t&&this.stream.on(`error`,Le),N(e))e._writableState.pipeline=this.pipeline,t&&e.on(`error`,Le),e.on(`finish`,this.pipeline.finished.bind(this.pipeline));else{let t=this.pipeline.done.bind(this.pipeline,e),n=this.pipeline.done.bind(this.pipeline,e,null);e.on(`error`,t),e.on(`close`,n),e.on(`finish`,this.pipeline.finished.bind(this.pipeline))}e.on(`drain`,D.bind(this)),this.stream.emit(`piping`,e),e.emit(`pipe`,this.stream)}push(e){let t=this.stream;return e===null?(this.highWaterMark=0,t._duplexState=(t._duplexState|c)&536805311,!1):this.map!==null&&(e=this.map(e),e===null)?(t._duplexState&=p,this.buffered<this.highWaterMark):(this.buffered+=this.byteLength(e),this.queue.push(e),t._duplexState=(t._duplexState|128)&p,this.buffered<this.highWaterMark)}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=536862591),e}unshift(e){let t=[this.map===null?e:this.map(e)];for(;this.buffered>0;)t.push(this.shift());for(let e=0;e<t.length-1;e++){let n=t[e];this.buffered+=this.byteLength(n),this.queue.push(n)}this.push(t[t.length-1])}read(){let e=this.stream;if((e._duplexState&oe)==128){let t=this.shift();return this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t),t}return this.readAhead===!1&&(e._duplexState|=f,this.updateNextTick()),null}drain(){let e=this.stream;for(;(e._duplexState&oe)==128&&e._duplexState&768;){let t=this.shift();this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t)}}update(){let e=this.stream;e._duplexState|=32;do{for(this.drain();this.buffered<this.highWaterMark&&(e._duplexState&214047)==f;)e._duplexState|=65552,e._read(this.afterRead),this.drain();(e._duplexState&12431)==4224&&(e._duplexState|=8192,e.emit(`readable`)),e._duplexState&80||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536870879}updateNonPrimary(){let e=this.stream;if((e._duplexState&1167)==c&&(e._duplexState=(e._duplexState|u)&536869887,e.emit(`end`),(e._duplexState&re)==ne&&(e._duplexState|=4),this.pipeTo!==null&&this.pipeTo.end()),(e._duplexState&14)==4){e._duplexState&ie||(e._duplexState|=te,e._destroy(pe.bind(this)));return}(e._duplexState&ae)==1&&(e._duplexState=(e._duplexState|te)&s,e._open(ye.bind(this)))}continueUpdate(){return this.stream._duplexState&d?(this.stream._duplexState&=h,!0):!1}updateCallback(){(this.stream._duplexState&32879)==64?this.update():this.updateNextTick()}updateNextTickIfOpen(){this.stream._duplexState&32769||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}updateNextTick(){this.stream._duplexState&d||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}},ue=class{constructor(e){this.data=null,this.afterTransform=be.bind(e),this.afterFinal=null}},de=class{constructor(e,t,n){this.from=e,this.to=t,this.afterPipe=n,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(e,t){if(t&&(this.error=t),e===this.to&&(this.to=null,this.from!==null)){(!(this.from._duplexState&u)||!this.pipeToFinished)&&this.from.destroy(this.error||a.PREMATURE_CLOSE(`Writable stream closed`));return}if(e===this.from&&(this.from=null,this.to!==null)){e._duplexState&u||this.to.destroy(this.error||a.PREMATURE_CLOSE(`Readable stream closed`));return}this.afterPipe!==null&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null}};function D(){this.stream._duplexState|=512,this.updateCallback()}function fe(e){let t=this.stream;e&&t.destroy(e),t._duplexState&14||(t._duplexState|=b,t.emit(`finish`)),(t._duplexState&re)==ne&&(t._duplexState|=4),t._duplexState&=402391039,t._duplexState&_?this.updateNextTick():this.update()}function pe(e){let t=this.stream;!e&&!a.isStreamDestroyed(this.error)&&(e=this.error),e&&t.emit(`error`,e),t._duplexState|=8,t.emit(`close`);let n=t._readableState,r=t._writableState;if(n!==null&&n.pipeline!==null&&n.pipeline.done(t,e),r!==null){for(;r.drains!==null&&r.drains.length>0;)r.drains.shift().resolve(!1);r.pipeline!==null&&r.pipeline.done(t,e)}}function me(e){let t=this.stream;e&&t.destroy(e),t._duplexState&=469499903,this.drains!==null&&ve(this.drains),(t._duplexState&6553615)==4194304&&(t._duplexState&=532676607,(t._duplexState&x)==x&&t.emit(`drain`)),this.updateCallback()}function he(e){e&&this.stream.destroy(e),this.stream._duplexState&=536870895,this.readAhead===!1&&!(this.stream._duplexState&256)&&(this.stream._duplexState&=g),this.updateCallback()}function ge(){this.stream._duplexState&32||(this.stream._duplexState&=h,this.update())}function _e(){this.stream._duplexState&_||(this.stream._duplexState&=T,this.update())}function ve(e){for(let t=0;t<e.length;t++)--e[t].writes===0&&(e.shift().resolve(!0),t--)}function ye(e){let t=this.stream;e&&t.destroy(e),t._duplexState&4||(t._duplexState&17423||(t._duplexState|=64),t._duplexState&142606351||(t._duplexState|=v),t.emit(`open`)),t._duplexState&=536608751,t._writableState!==null&&t._writableState.updateCallback(),t._readableState!==null&&t._readableState.updateCallback()}function be(e,t){t!=null&&this.push(t),this._writableState.afterWrite(e)}function xe(e){this._readableState!==null&&(e===`data`&&(this._duplexState|=133376,this._readableState.updateNextTick()),e===`readable`&&(this._duplexState|=4096,this._readableState.updateNextTick())),this._writableState!==null&&e===`drain`&&(this._duplexState|=x,this._writableState.updateNextTick())}var Se=class extends n{constructor(e){super(),this._duplexState=0,this._readableState=null,this._writableState=null,e&&(e.open&&(this._open=e.open),e.destroy&&(this._destroy=e.destroy),e.predestroy&&(this._predestroy=e.predestroy),e.signal&&e.signal.addEventListener(`abort`,Re.bind(this))),this.on(`newListener`,xe)}_open(e){e(null)}_destroy(e){e(null)}_predestroy(){}get readable(){return this._readableState!==null||void 0}get writable(){return this._writableState!==null||void 0}get destroyed(){return!!(this._duplexState&8)}get destroying(){return!!(this._duplexState&14)}destroy(e){this._duplexState&14||(e||=a.STREAM_DESTROYED(),this._duplexState=(this._duplexState|4)&535822271,this._readableState!==null&&(this._readableState.highWaterMark=0,this._readableState.error=e),this._writableState!==null&&(this._writableState.highWaterMark=0,this._writableState.error=e),this._duplexState|=2,this._predestroy(),this._duplexState&=536870909,this._readableState!==null&&this._readableState.updateNextTick(),this._writableState!==null&&this._writableState.updateNextTick())}},Ce=class e extends Se{constructor(e){super(e),this._duplexState|=8519681,this._readableState=new le(this,e),e&&(this._readableState.readAhead===!1&&(this._duplexState&=g),e.read&&(this._read=e.read),e.eagerOpen&&this._readableState.updateNextTick(),e.encoding&&this.setEncoding(e.encoding))}static deferred(e,t){let n=new j(t);return e().then(e=>{if(e===null)return n.end();n.destroying||M(e,n,Le)}).catch(e=>n.destroy(e)),n}setEncoding(e){let t=new i(e),n=this._readableState.map||Ee;return this._readableState.map=r,this;function r(e){let r=t.push(e);return r===``&&(e.byteLength!==0||t.remaining>0)?null:n(r)}}_read(e){e(null)}pipe(e,t){return this._readableState.updateNextTick(),this._readableState.pipe(e,t),e}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(e){return this._readableState.updateNextTickIfOpen(),this._readableState.push(e)}unshift(e){return this._readableState.updateNextTickIfOpen(),this._readableState.unshift(e)}resume(){return this._duplexState|=131328,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=this._readableState.readAhead===!1?536739583:536870655,this}static _fromAsyncIterator(t,n){let r,i=new e({...n,read(e){t.next().then(a).then(e.bind(null,null)).catch(e)},predestroy(){r=t.return()},destroy(e){if(!r)return e(null);r.then(e.bind(null,null)).catch(e)}});return i;function a(e){e.done?i.push(null):i.push(e.value)}}static from(t,n){if(Ne(t))return t;if(t[E])return this._fromAsyncIterator(t[E](),n);Array.isArray(t)||(t=t===void 0?[]:[t]);let r=0;return new e({...n,read(e){this.push(r===t.length?null:t[r++]),e(null)}})}static isBackpressured(e){return!!(e._duplexState&17422)||e._readableState.buffered>=e._readableState.highWaterMark}static isPaused(e){return!(e._duplexState&256)}[E](){let e=this,t=null,n=null,r=null;return this.on(`error`,e=>{t=e}),this.on(`readable`,i),this.on(`close`,o),{[E](){return this},next(){return new Promise(function(t,i){n=t,r=i;let a=e.read();a===null?e._duplexState&8&&s(null):s(a)})},return(){return c(null)},throw(e){return c(e)}};function i(){n!==null&&s(e.read())}function o(){n!==null&&s(null)}function s(i){r!==null&&(t?r(t):i===null&&!(e._duplexState&u)?r(a.STREAM_DESTROYED()):n({value:i,done:i===null}),r=n=null)}function c(t){return e.destroy(t),new Promise((n,r)=>{if(e._duplexState&8)return n({value:void 0,done:!0});e.once(`close`,function(){t?r(t):n({value:void 0,done:!0})})})}}},O=class extends Se{constructor(e){super(e),this._duplexState|=16385,this._writableState=new ce(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final),e.eagerOpen&&this._writableState.updateNextTick())}cork(){this._duplexState|=w}uncork(){this._duplexState&=ee,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}static isBackpressured(e){return!!(e._duplexState&146800654)}static drained(e){if(e.destroyed)return Promise.resolve(!1);let t=e._writableState,n=(ze(e)?Math.min(1,t.queue.length):t.queue.length)+(e._duplexState&67108864?1:0);return n===0?Promise.resolve(!0):(t.drains===null&&(t.drains=[]),new Promise(e=>{t.drains.push({writes:n,resolve:e})}))}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},k=class extends Ce{constructor(e){super(e),this._duplexState=1|this._duplexState&f,this._writableState=new ce(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final))}cork(){this._duplexState|=w}uncork(){this._duplexState&=ee,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},A=class extends k{constructor(e){super(e),this._transformState=new ue(this),e&&(e.transform&&(this._transform=e.transform),e.flush&&(this._flush=e.flush))}_write(e,t){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=e:this._transform(e,this._transformState.afterTransform)}_read(e){if(this._transformState.data!==null){let t=this._transformState.data;this._transformState.data=null,e(null),this._transform(t,this._transformState.afterTransform)}else e(null)}destroy(e){super.destroy(e),this._transformState.data!==null&&(this._transformState.data=null,this._transformState.afterTransform())}_transform(e,t){t(null,e)}_flush(e){e(null)}_final(e){this._transformState.afterFinal=e,this._flush(we.bind(this))}},j=class extends A{};function we(e,t){let n=this._transformState.afterFinal;if(e)return n(e);t!=null&&this.push(t),this.push(null),n(null)}function Te(...e){return new Promise((t,n)=>M(...e,e=>{if(e)return n(e);t()}))}function M(e,...t){let n=Array.isArray(e)?[...e,...t]:[e,...t],r=n.length&&typeof n[n.length-1]==`function`?n.pop():null;if(n.length<2)throw a.BAD_ARGUMENT(`Pipeline requires at least 2 streams`);let i=n[0],o=null,s=null;for(let e=1;e<n.length;e++)o=n[e],N(i)?i.pipe(o,l):(c(i,!0,e>1,l),i.pipe(o)),i=o;if(r){let e=!1,t=N(o)||!!(o._writableState&&o._writableState.autoDestroy);o.on(`error`,e=>{s===null&&(s=e)}),o.on(`finish`,()=>{e=!0,t||r(s)}),t&&o.on(`close`,()=>r(s||(e?null:a.PREMATURE_CLOSE())))}return o;function c(e,t,n,r){e.on(`error`,r),e.on(`close`,i);function i(){if(t&&e._readableState&&!e._readableState.ended||n&&e._writableState&&!e._writableState.ended)return r(a.PREMATURE_CLOSE())}}function l(e){if(e&&!s){s=e;for(let t of n)t.destroy(e)}}}function Ee(e){return e}function De(e){return!!e._readableState||!!e._writableState}function N(e){return typeof e._duplexState==`number`&&De(e)}function Oe(e){return!!e._readableState&&e._readableState.ending}function ke(e){return!!e._readableState&&e._readableState.ended}function Ae(e){return!!e._writableState&&e._writableState.ending}function je(e){return!!e._writableState&&e._writableState.ended}function Me(e,t={}){let n=e._readableState&&e._readableState.error||e._writableState&&e._writableState.error;return!t.all&&a.isStreamDestroyed(n)?null:n}function Ne(e){return N(e)&&e.readable}function Pe(e){return(e._duplexState&1)!=1||(e._duplexState&4)==4||!!(e._duplexState&ie)}function Fe(e){return typeof e==`object`&&!!e&&typeof e.byteLength==`number`}function Ie(e){return Fe(e)?e.byteLength:1024}function Le(){}function Re(){this.destroy(a.ABORTED())}function ze(e){return e._writev!==O.prototype._writev&&e._writev!==k.prototype._writev}t.exports={pipeline:M,pipelinePromise:Te,isStream:De,isStreamx:N,isEnding:Oe,isEnded:ke,isFinishing:Ae,isFinished:je,isDisturbed:Pe,getStreamError:Me,Stream:Se,Writable:O,Readable:Ce,Duplex:k,Transform:A,PassThrough:j}})),it=n((e=>{let t=Qe(),n=t.from([117,115,116,97,114,0]),r=t.from([48,48]),i=t.from([117,115,116,97,114,32]),a=t.from([32,0]);e.decodeLongPath=function(e,t){return v(e,0,e.length,t)},e.encodePax=function(e){let n=``;e.name&&(n+=y(` path=`+e.name+`
|
|
1
|
+
import{i as e,o as t,t as n}from"../../_chunks/node/rolldown-runtime-tZXQYakl.js";import{n as r,t as i}from"../../_chunks/node/dist-DsNhwdzf.js";import{n as a,t as o}from"../../_chunks/node/retry-hTJQ4iNT.js";import{t as s}from"../../_chunks/node/undici-B61sz6UT.js";import{t as c}from"../../_chunks/node/version-C__MqbLM.js";import{n as l,r as u,t as d}from"../../_chunks/node/token-util-DpJNusVS.js";import{Readable as f}from"stream";import p from"zlib";import m,{dirname as h,resolve as g}from"path";import{createWriteStream as _}from"fs";import{z as v}from"#compiled/zod/index.js";import y from"os";import{pipeline as b}from"stream/promises";import{mkdir as x}from"fs/promises";import*as S from"node:constants";import{setTimeout as C}from"node:timers/promises";var w=class e extends Error{constructor(t,n){super(t.statusText),Error.captureStackTrace&&Error.captureStackTrace(this,e),this.response=t,this.message=n?.message??``,this.json=n?.json,this.text=n?.text,this.sandboxName=n?.sandboxName,this.sessionId=n?.sessionId}},T=class e extends Error{constructor(t,n,r){super(n),this.name=`StreamError`,this.code=t,this.sessionId=r,Error.captureStackTrace&&Error.captureStackTrace(this,e)}};const ee=`iad1`;function te(e){return e==null?[]:Array.isArray(e)?e:[e]}var ne=t(n(((e,t)=>{var n=o();function r(e,t){function r(r,i){var a=t||{},o;`randomize`in a||(a.randomize=!0),o=n.operation(a);function s(e){i(e||Error(`Aborted`))}function c(e,t){if(e.bail){s(e);return}o.retry(e)?a.onRetry&&a.onRetry(e,t):i(o.mainError())}function l(t){var n;try{n=e(s,t)}catch(e){c(e,t);return}Promise.resolve(n).then(r).catch(function(e){c(e,t)})}o.attempt(l)}return new Promise(r)}t.exports=r}))(),1);function re(e){return async(t,n={})=>{let r=Object.assign({minTimeout:400,retries:2,factor:2},n.retry);n.onRetry&&(r.onRetry=(e,t)=>{n.onRetry(e,n),n.retry&&n.retry.onRetry&&n.retry.onRetry(e,t)});try{return await(0,ne.default)(async(i,a)=>{try{if(n.signal?.aborted)return i(n.signal.reason||Error(`Request aborted`));let o=await e(t,n);if(o.status===429){let e=Number(o.headers.get(`Retry-After`));if(e>20)return i(new w(o));let t=r.forever||a<=r.retries;throw e>0&&t&&await ie(e*1e3,n.signal),new w(o)}if(o.status>=500&&o.status<600)throw new w(o);return o}catch(e){if(ae(e))return i(e);if(n.signal?.aborted)return i(n.signal.reason||Error(`Request aborted`));throw e}},r)}catch(e){if(e instanceof w)return e.response;throw e}}}async function ie(e,t){if(t?.aborted)throw t.reason||Error(`Request aborted`);await new Promise((n,r)=>{let i=()=>{clearTimeout(a),r(t?.reason||Error(`Request aborted`))},a=setTimeout(()=>{t?.removeEventListener(`abort`,i),n(null)},e);t?.addEventListener(`abort`,i,{once:!0})})}function ae(e){return e!=null&&e.name===`AbortError`}const oe=new(s()).Agent({bodyTimeout:0});var se=class{constructor(e){this.fetch=re(e.fetch??globalThis.fetch),this.baseUrl=e.baseUrl,this.debug=e.debug??process.env.DEBUG_FETCH===`true`,this.token=e.token,this.agent=oe}async request(e,t){let n=new URL(`${this.baseUrl}${e}`);if(t?.query)for(let[e,r]of Object.entries(t.query))te(r).forEach(t=>{n.searchParams.append(e,t.toString())});let r=Date.now(),i=await this.fetch(n.toString(),{...t,body:t?.body,method:t?.method||`GET`,headers:this.token?{Authorization:`Bearer ${this.token}`,...t?.headers}:t?.headers,dispatcher:this.agent,signal:t?.signal});if(this.debug){let e=Date.now()-r;if(console.log(`[API] ${n} (${i.status}) ${e}ms`),i.status===429){let e=parseInt(i.headers.get(`Retry-After`)??``,10),t=Math.floor(e/60/60),r=Math.floor(e/60)%60,a=e%60;console.warn(`[API] ${n} Rate Limited, Retry After ${t}h ${r}m ${a}s`)}}return i}};function E(e){return e.match(/\/v2\/sandboxes\/sessions\/([^/?]+)/)?.[1]}function ce(e){return e.match(/\/v2\/sandboxes\/(?!sessions(?:\/|$|\?))(?!snapshots(?:\/|$|\?))([^/?]+)/)?.[1]}const le=v.object({error:v.object({message:v.string()})});function ue(e){let t=le.safeParse(e);return t.success?t.data.error.message:void 0}async function de(e,t){let n=E(t.url),r;n||(r=ce(t.url));let i=await t.text().catch(e=>new w(t,{message:`Can't read response text: ${String(e)}`,sessionId:n,sandboxName:r}));if(typeof i!=`string`)return i;let a;try{a=JSON.parse(i||`{}`)}catch(e){return new w(t,{message:`Can't parse JSON: ${String(e)}`,text:i,sessionId:n,sandboxName:r})}if(!t.ok){let e=ue(a);return new w(t,{message:e?`Status code ${t.status} is not ok: ${e}`:`Status code ${t.status} is not ok`,json:a,text:i,sessionId:n,sandboxName:r})}let o=e.safeParse(a);return o.success?{json:o.data,response:t,text:i}:new w(t,{message:`Response JSON is not valid: ${o.error}`,json:a,text:i,sessionId:n,sandboxName:r})}async function D(e,t){let n=await de(e,t);if(n instanceof w)throw n;return n}const fe=v.object({exact:v.string().optional(),startsWith:v.string().optional(),regex:v.string().optional()}),pe=v.object({key:fe.optional(),value:fe.optional()}),me=v.object({path:fe.optional(),method:v.array(v.string()).optional(),queryString:v.array(pe).optional(),headers:v.array(pe).optional()}),he=v.object({domain:v.string(),headers:v.record(v.string(),v.string()).optional(),headerNames:v.array(v.string()).optional(),match:me.optional()}),ge=v.object({domain:v.string(),forwardURL:v.string(),match:me.optional()}),_e=v.object({headers:v.record(v.string(),v.string()).optional()}),ve=v.object({match:me.optional(),transform:v.array(_e).optional(),forwardURL:v.string().optional()}).refine(({transform:e,forwardURL:t})=>e===void 0||t===void 0,{message:`transform and forwardURL cannot be used together`}).refine(({transform:e,forwardURL:t})=>e!==void 0||t!==void 0,{message:`transform or forwardURL must be provided`}),ye=v.object({allow:v.union([v.array(v.string()),v.record(v.string(),v.array(ve))]).optional(),subnets:v.object({allow:v.array(v.string()).optional(),deny:v.array(v.string()).optional()}).optional()}),be=v.union([v.object({mode:v.literal(`allow-all`)}).passthrough(),v.object({mode:v.literal(`deny-all`)}).passthrough()]),xe=v.object({mode:v.literal(`custom`),allowedDomains:v.array(v.string()).optional(),allowedCIDRs:v.array(v.string()).optional(),deniedCIDRs:v.array(v.string()).optional(),injectionRules:v.array(he).optional(),forwardRules:v.array(ge).optional()}).passthrough(),Se=v.union([be,ye.passthrough()]),Ce=v.union([be,xe]),O=v.object({id:v.string(),memory:v.number(),vcpus:v.number(),region:v.string(),runtime:v.string().optional(),timeout:v.number(),status:v.enum([`pending`,`running`,`stopping`,`stopped`,`failed`,`aborted`,`snapshotting`]),requestedAt:v.number(),startedAt:v.number().optional(),requestedStopAt:v.number().optional(),stoppedAt:v.number().optional(),abortedAt:v.number().optional(),duration:v.number().optional(),sourceSnapshotId:v.string().optional(),snapshottedAt:v.number().optional(),createdAt:v.number(),cwd:v.string(),updatedAt:v.number(),interactivePort:v.number().optional(),networkPolicy:Ce.optional(),activeCpuDurationMs:v.number().optional(),networkTransfer:v.object({ingress:v.number(),egress:v.number()}).optional()}),k=v.object({url:v.string(),subdomain:v.string(),port:v.number()}),A=v.object({id:v.string(),sourceSessionId:v.string(),region:v.string(),regions:v.array(v.string()).optional(),status:v.enum([`created`,`deleted`,`failed`]),sizeBytes:v.number(),expiresAt:v.number().optional(),createdAt:v.number(),updatedAt:v.number(),lastUsedAt:v.number().optional(),creationMethod:v.string().optional(),parentId:v.string().optional()}),j=v.object({count:v.number(),next:v.string().nullable()}),we=v.object({id:v.string(),name:v.string(),args:v.array(v.string()),cwd:v.string(),sessionId:v.string(),exitCode:v.number().nullable(),durationMs:v.number().optional(),startedAt:v.number()}),Te=we.extend({exitCode:v.number()}),M=v.object({session:O.passthrough()}),Ee=M.extend({routes:v.array(k)}),De=v.object({url:v.string(),token:v.string()}),N=v.object({sessions:v.array(O.passthrough()),pagination:j}),Oe=v.object({command:we}),ke=v.object({command:Te}),Ae=v.object({}),je=v.object({data:v.string()}),Me=je.extend({stream:v.literal(`stdout`)}),Ne=je.extend({stream:v.literal(`stderr`)}),Pe=v.object({stream:v.literal(`error`),data:v.object({code:v.string(),message:v.string()})}),Fe=v.discriminatedUnion(`stream`,[Me,Ne,Pe]),Ie=v.object({snapshots:v.array(A),pagination:j}),Le=v.object({snapshot:A,siblings:v.array(A),count:v.string()}),Re=v.object({snapshots:v.array(Le),anchor:Le.optional(),pagination:j}),ze=v.object({snapshot:A,session:O.passthrough()}),Be=v.object({snapshot:A}),Ve=v.object({id:v.string(),name:v.string(),projectId:v.string(),region:v.string(),maxSizeBytes:v.number(),currentSessionId:v.string().optional(),currentSandboxName:v.string().optional(),createdAt:v.number(),updatedAt:v.number()}),He=v.object({drives:v.array(Ve),pagination:j}),Ue=v.object({drive:Ve}),We=v.object({name:v.string(),persistent:v.boolean(),region:v.string().optional(),failoverRegions:v.array(v.string()).optional(),vcpus:v.number().optional(),memory:v.number().optional(),runtime:v.string().optional(),image:v.string().optional(),timeout:v.number().optional(),networkPolicy:Ce.optional(),totalEgressBytes:v.number().optional(),totalIngressBytes:v.number().optional(),totalActiveCpuDurationMs:v.number().optional(),totalDurationMs:v.number().optional(),createdAt:v.number(),updatedAt:v.number(),expiresAt:v.number().optional(),currentSessionId:v.string(),currentSnapshotId:v.string().optional(),status:O.shape.status,statusUpdatedAt:v.number().optional(),cwd:v.string().optional(),tags:v.record(v.string(),v.string()).optional(),mounts:v.record(v.string(),v.object({drive:v.string(),mode:v.enum([`snapshot`,`read-write`,`read-only`]).optional()}).transform(e=>({drive:e.drive,mode:e.mode===`read-only`?`snapshot`:e.mode??`read-write`}))).optional(),snapshotExpiration:v.number().optional(),keepLastSnapshots:v.object({count:v.number(),expiration:v.number().optional(),deleteEvicted:v.boolean().optional()}).optional()}),Ge=v.object({session:O.passthrough(),sandbox:We.optional(),snapshot:A.optional()}),Ke=v.object({sandbox:We,session:O.passthrough(),routes:v.array(k),resumed:v.boolean().optional()}),qe=v.object({sandboxes:v.array(We),pagination:j}),Je=v.object({sandbox:We,routes:v.array(k).optional()});var Ye=n(((t,n)=>{n.exports=e(`events`)})),Xe=n(((e,t)=>{t.exports=class{constructor(e){if(!(e>0)||e-1&e)throw Error(`Max size for a FixedFIFO should be a power of two`);this.buffer=Array(e),this.mask=e-1,this.top=0,this.btm=0,this.next=null}clear(){this.top=this.btm=0,this.next=null,this.buffer.fill(void 0)}push(e){return this.buffer[this.top]===void 0&&(this.buffer[this.top]=e,this.top=this.top+1&this.mask,!0)}shift(){let e=this.buffer[this.btm];if(e!==void 0)return this.buffer[this.btm]=void 0,this.btm=this.btm+1&this.mask,e}peek(){return this.buffer[this.btm]}isEmpty(){return this.buffer[this.btm]===void 0}}})),Ze=n(((e,t)=>{let n=Xe();t.exports=class{constructor(e){this.hwm=e||16,this.head=new n(this.hwm),this.tail=this.head,this.length=0}clear(){this.head=this.tail,this.head.clear(),this.length=0}push(e){if(this.length++,!this.head.push(e)){let t=this.head;this.head=t.next=new n(2*this.head.buffer.length),this.head.push(e)}}shift(){this.length!==0&&this.length--;let e=this.tail.shift();if(e===void 0&&this.tail.next){let e=this.tail.next;return this.tail.next=null,this.tail=e,this.tail.shift()}return e}peek(){let e=this.tail.peek();return e===void 0&&this.tail.next?this.tail.next.peek():e}isEmpty(){return this.length===0}}})),Qe=n(((e,t)=>{function n(e){return Buffer.isBuffer(e)||e instanceof Uint8Array}function r(e){return Buffer.isEncoding(e)}function i(e,t,n){return Buffer.alloc(e,t,n)}function a(e){return Buffer.allocUnsafe(e)}function o(e){return Buffer.allocUnsafeSlow(e)}function s(e,t){return Buffer.byteLength(e,t)}function c(e,t){return Buffer.compare(e,t)}function l(e,t){return Buffer.concat(e,t)}function u(e,t,n,r,i){return b(e).copy(t,n,r,i)}function d(e,t){return b(e).equals(t)}function f(e,t,n,r,i){return b(e).fill(t,n,r,i)}function p(e,t,n){return Buffer.from(e,t,n)}function m(e,t,n,r){return b(e).includes(t,n,r)}function h(e,t,n,r){return b(e).indexOf(t,n,r)}function g(e,t,n,r){return b(e).lastIndexOf(t,n,r)}function _(e){return b(e).swap16()}function v(e){return b(e).swap32()}function y(e){return b(e).swap64()}function b(e){return Buffer.isBuffer(e)?e:Buffer.from(e.buffer,e.byteOffset,e.byteLength)}function x(e,t,n,r){return b(e).toString(t,n,r)}function S(e,t,n){return b(e).toString(`hex`,t,n)}function C(e,t,n,r,i){return b(e).write(t,n,r,i)}function w(e,t){return b(e).readDoubleBE(t)}function T(e,t){return b(e).readDoubleLE(t)}function ee(e,t){return b(e).readFloatBE(t)}function te(e,t){return b(e).readFloatLE(t)}function ne(e,t){return b(e).readInt32BE(t)}function re(e,t){return b(e).readInt32LE(t)}function ie(e,t){return b(e).readUInt32BE(t)}function ae(e,t){return b(e).readUInt32LE(t)}function oe(e,t,n){return b(e).writeDoubleBE(t,n)}function se(e,t,n){return b(e).writeDoubleLE(t,n)}function E(e,t,n){return b(e).writeFloatBE(t,n)}function ce(e,t,n){return b(e).writeFloatLE(t,n)}function le(e,t,n){return b(e).writeInt32BE(t,n)}function ue(e,t,n){return b(e).writeInt32LE(t,n)}function de(e,t,n){return b(e).writeUInt32BE(t,n)}function D(e,t,n){return b(e).writeUInt32LE(t,n)}t.exports={isBuffer:n,isEncoding:r,alloc:i,allocUnsafe:a,allocUnsafeSlow:o,byteLength:s,compare:c,concat:l,copy:u,equals:d,fill:f,from:p,includes:m,indexOf:h,lastIndexOf:g,swap16:_,swap32:v,swap64:y,toBuffer:b,toString:x,toHex:S,write:C,readDoubleBE:w,readDoubleLE:T,readFloatBE:ee,readFloatLE:te,readInt32BE:ne,readInt32LE:re,readUInt32BE:ie,readUInt32LE:ae,writeDoubleBE:oe,writeDoubleLE:se,writeFloatBE:E,writeFloatLE:ce,writeInt32BE:le,writeInt32LE:ue,writeUInt32BE:de,writeUInt32LE:D}})),$e=n(((e,t)=>{let n=Qe();t.exports=class{constructor(e){this.encoding=e}get remaining(){return 0}decode(e){return n.toString(e,this.encoding)}flush(){return``}}})),et=n(((e,t)=>{let n=Qe();t.exports=class{constructor(){this._reset()}get remaining(){return this.bytesSeen}decode(e){if(e.byteLength===0)return``;if(this.bytesNeeded===0&&r(e,0)===0)return this.bytesSeen=i(e),n.toString(e,`utf8`);let t=``,a=0;if(this.bytesNeeded>0){for(;a<e.byteLength;){let n=e[a];if(n<this.lowerBoundary||n>this.upperBoundary){t+=`�`,this._reset();break}if(this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|n&63,this.bytesSeen++,a++,this.bytesSeen===this.bytesNeeded){t+=String.fromCodePoint(this.codePoint),this._reset();break}}if(this.bytesNeeded>0)return t}let o=r(e,a),s=e.byteLength-o;s>a&&(t+=n.toString(e,`utf8`,a,s));for(let n=s;n<e.byteLength;n++){let r=e[n];if(this.bytesNeeded===0){r<=127?(this.bytesSeen=0,t+=String.fromCharCode(r)):r>=194&&r<=223?(this.bytesNeeded=2,this.bytesSeen=1,this.codePoint=r&31):r>=224&&r<=239?(r===224?this.lowerBoundary=160:r===237&&(this.upperBoundary=159),this.bytesNeeded=3,this.bytesSeen=1,this.codePoint=r&15):r>=240&&r<=244?(r===240?this.lowerBoundary=144:r===244&&(this.upperBoundary=143),this.bytesNeeded=4,this.bytesSeen=1,this.codePoint=r&7):(this.bytesSeen=1,t+=`�`);continue}if(r<this.lowerBoundary||r>this.upperBoundary){t+=`�`,n--,this._reset();continue}this.lowerBoundary=128,this.upperBoundary=191,this.codePoint=this.codePoint<<6|r&63,this.bytesSeen++,this.bytesSeen===this.bytesNeeded&&(t+=String.fromCodePoint(this.codePoint),this._reset())}return t}flush(){let e=this.bytesNeeded>0?`�`:``;return this._reset(),e}_reset(){this.codePoint=0,this.bytesNeeded=0,this.bytesSeen=0,this.lowerBoundary=128,this.upperBoundary=191}};function r(e,t){let n=e.byteLength;if(n<=t)return 0;let r=Math.max(t,n-4),i=n-1;for(;i>r&&(e[i]&192)==128;)i--;if(i<t)return 0;let a=e[i],o;if(a<=127)return 0;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 0;let s=n-i;return s<o?s:0}function i(e){let t=e.byteLength;if(t===0)return 0;let n=e[t-1];if(n<=127)return 0;if((n&192)!=128)return 1;let r=Math.max(0,t-4),i=t-2;for(;i>=r&&(e[i]&192)==128;)i--;if(i<0)return 1;let a=e[i],o;if(a>=194&&a<=223)o=2;else if(a>=224&&a<=239)o=3;else if(a>=240&&a<=244)o=4;else return 1;if(t-i!==o)return 1;if(o>=3){let t=e[i+1];if(a===224&&t<160||a===237&&t>159||a===240&&t<144||a===244&&t>143)return 1}return 0}})),tt=n(((e,t)=>{let n=$e(),r=et();t.exports=class{constructor(e=`utf8`){switch(this.encoding=i(e),this.encoding){case`utf8`:this.decoder=new r;break;case`utf16le`:case`base64`:throw Error(`Unsupported encoding: `+this.encoding);default:this.decoder=new n(this.encoding)}}get remaining(){return this.decoder.remaining}push(e){return typeof e==`string`?e:this.decoder.decode(e)}write(e){return this.push(e)}end(e){let t=``;return e&&(t=this.push(e)),t+=this.decoder.flush(),t}};function i(e){switch(e=e.toLowerCase(),e){case`utf8`:case`utf-8`:return`utf8`;case`ucs2`:case`ucs-2`:case`utf16le`:case`utf-16le`:return`utf16le`;case`latin1`:case`binary`:return`latin1`;case`base64`:case`ascii`:case`hex`:return e;default:throw Error(`Unknown encoding: `+e)}}})),nt=n(((e,t)=>{t.exports=class e extends Error{constructor(t,n,r=e){super(t),this.code=n,Error.captureStackTrace&&Error.captureStackTrace(this,r)}static isStreamDestroyed(e){return e&&e.code===`STREAM_DESTROYED`}static isPrematureClose(e){return e&&e.code===`PREMATURE_CLOSE`}static isAborted(e){return e&&e.code===`ABORTED`}static isBadArgument(e){return e&&e.code===`BAD_ARGUMENT`}get name(){return`StreamError`}static STREAM_DESTROYED(){return new e(`Stream was destroyed`,`STREAM_DESTROYED`,e.STREAM_DESTROYED)}static PREMATURE_CLOSE(t=`Premature close`){return new e(t,`PREMATURE_CLOSE`,e.PREMATURE_CLOSE)}static ABORTED(){return new e(`Stream aborted`,`ABORTED`,e.ABORTED)}static BAD_ARGUMENT(t=`Bad argument`){return new e(t,`BAD_ARGUMENT`,e.BAD_ARGUMENT)}}})),rt=n(((e,t)=>{let{EventEmitter:n}=Ye(),r=Ze(),i=tt(),a=nt(),o=typeof queueMicrotask>`u`?e=>global.process.nextTick(e):queueMicrotask,s=536870910,c=1024,l=2048,u=16384,d=32768,f=131072,p=536805375,m=536870143,h=536838143,g=536739839,_=2<<18,v=4<<18,y=8<<18,b=32<<18,x=64<<18,S=128<<18,C=512<<18,w=1024<<18,T=503316479,ee=268435455,te=262160,ne=8404992,re=8405006,ie=33587200,ae=33587215,oe=16527,se=270794767,E=Symbol.asyncIterator||Symbol(`asyncIterator`);var ce=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapWritable:i,byteLength:a,byteLengthWritable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t,this.buffered=0,this.error=null,this.pipeline=null,this.drains=null,this.byteLength=o||a||Ie,this.map=i||n,this.afterWrite=me.bind(this),this.afterUpdateNextTick=_e.bind(this)}get ending(){return!!(this.stream._duplexState&C)}get ended(){return!!(this.stream._duplexState&b)}push(e){return this.stream._duplexState&142606350?!1:(this.map!==null&&(e=this.map(e)),this.buffered+=this.byteLength(e),this.queue.push(e),this.buffered<this.highWaterMark?(this.stream._duplexState|=y,!0):(this.stream._duplexState|=6291456,!1))}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=534773759),e}end(e){typeof e==`function`?this.stream.once(`finish`,e):e!=null&&this.push(e),this.stream._duplexState=(this.stream._duplexState|C)&535822335}autoBatch(e,t){let n=[],r=this.stream;for(n.push(e);(r._duplexState&se)==2359296;)n.push(r._writableState.shift());if(r._duplexState&15)return t(null);r._writev(n,t)}update(){let e=this.stream;e._duplexState|=_;do{for(;(e._duplexState&se)==y;){let t=this.shift();e._duplexState|=67371008,e._write(t,this.afterWrite)}e._duplexState&1310720||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536346623}updateNonPrimary(){let e=this.stream;if((e._duplexState&144965647)==C){e._duplexState|=262144,e._final(fe.bind(this));return}if((e._duplexState&14)==4){e._duplexState&ie||(e._duplexState|=te,e._destroy(pe.bind(this)));return}(e._duplexState&ae)==1&&(e._duplexState=(e._duplexState|te)&s,e._open(ye.bind(this)))}continueUpdate(){return this.stream._duplexState&S?(this.stream._duplexState&=T,!0):!1}updateCallback(){(this.stream._duplexState&35127311)==v?this.update():this.updateNextTick()}updateNextTick(){this.stream._duplexState&S||(this.stream._duplexState|=S,this.stream._duplexState&_||o(this.afterUpdateNextTick))}},le=class{constructor(e,{highWaterMark:t=16384,map:n=null,mapReadable:i,byteLength:a,byteLengthReadable:o}={}){this.stream=e,this.queue=new r,this.highWaterMark=t===0?1:t,this.buffered=0,this.readAhead=t>0,this.error=null,this.pipeline=null,this.byteLength=o||a||Ie,this.map=i||n,this.pipeTo=null,this.afterRead=he.bind(this),this.afterUpdateNextTick=ge.bind(this)}get ending(){return!!(this.stream._duplexState&c)}get ended(){return!!(this.stream._duplexState&u)}pipe(e,t){if(this.pipeTo!==null)throw a.BAD_ARGUMENT(`Can only pipe to one destination`);if(typeof t!=`function`&&(t=null),this.stream._duplexState|=512,this.pipeTo=e,this.pipeline=new de(this.stream,e,t),t&&this.stream.on(`error`,Le),N(e))e._writableState.pipeline=this.pipeline,t&&e.on(`error`,Le),e.on(`finish`,this.pipeline.finished.bind(this.pipeline));else{let t=this.pipeline.done.bind(this.pipeline,e),n=this.pipeline.done.bind(this.pipeline,e,null);e.on(`error`,t),e.on(`close`,n),e.on(`finish`,this.pipeline.finished.bind(this.pipeline))}e.on(`drain`,D.bind(this)),this.stream.emit(`piping`,e),e.emit(`pipe`,this.stream)}push(e){let t=this.stream;return e===null?(this.highWaterMark=0,t._duplexState=(t._duplexState|c)&536805311,!1):this.map!==null&&(e=this.map(e),e===null)?(t._duplexState&=p,this.buffered<this.highWaterMark):(this.buffered+=this.byteLength(e),this.queue.push(e),t._duplexState=(t._duplexState|128)&p,this.buffered<this.highWaterMark)}shift(){let e=this.queue.shift();return this.buffered-=this.byteLength(e),this.buffered===0&&(this.stream._duplexState&=536862591),e}unshift(e){let t=[this.map===null?e:this.map(e)];for(;this.buffered>0;)t.push(this.shift());for(let e=0;e<t.length-1;e++){let n=t[e];this.buffered+=this.byteLength(n),this.queue.push(n)}this.push(t[t.length-1])}read(){let e=this.stream;if((e._duplexState&oe)==128){let t=this.shift();return this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t),t}return this.readAhead===!1&&(e._duplexState|=f,this.updateNextTick()),null}drain(){let e=this.stream;for(;(e._duplexState&oe)==128&&e._duplexState&768;){let t=this.shift();this.pipeTo!==null&&this.pipeTo.write(t)===!1&&(e._duplexState&=m),e._duplexState&l&&e.emit(`data`,t)}}update(){let e=this.stream;e._duplexState|=32;do{for(this.drain();this.buffered<this.highWaterMark&&(e._duplexState&214047)==f;)e._duplexState|=65552,e._read(this.afterRead),this.drain();(e._duplexState&12431)==4224&&(e._duplexState|=8192,e.emit(`readable`)),e._duplexState&80||this.updateNonPrimary()}while(this.continueUpdate()===!0);e._duplexState&=536870879}updateNonPrimary(){let e=this.stream;if((e._duplexState&1167)==c&&(e._duplexState=(e._duplexState|u)&536869887,e.emit(`end`),(e._duplexState&re)==ne&&(e._duplexState|=4),this.pipeTo!==null&&this.pipeTo.end()),(e._duplexState&14)==4){e._duplexState&ie||(e._duplexState|=te,e._destroy(pe.bind(this)));return}(e._duplexState&ae)==1&&(e._duplexState=(e._duplexState|te)&s,e._open(ye.bind(this)))}continueUpdate(){return this.stream._duplexState&d?(this.stream._duplexState&=h,!0):!1}updateCallback(){(this.stream._duplexState&32879)==64?this.update():this.updateNextTick()}updateNextTickIfOpen(){this.stream._duplexState&32769||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}updateNextTick(){this.stream._duplexState&d||(this.stream._duplexState|=d,this.stream._duplexState&32||o(this.afterUpdateNextTick))}},ue=class{constructor(e){this.data=null,this.afterTransform=be.bind(e),this.afterFinal=null}},de=class{constructor(e,t,n){this.from=e,this.to=t,this.afterPipe=n,this.error=null,this.pipeToFinished=!1}finished(){this.pipeToFinished=!0}done(e,t){if(t&&(this.error=t),e===this.to&&(this.to=null,this.from!==null)){(!(this.from._duplexState&u)||!this.pipeToFinished)&&this.from.destroy(this.error||a.PREMATURE_CLOSE(`Writable stream closed`));return}if(e===this.from&&(this.from=null,this.to!==null)){e._duplexState&u||this.to.destroy(this.error||a.PREMATURE_CLOSE(`Readable stream closed`));return}this.afterPipe!==null&&this.afterPipe(this.error),this.to=this.from=this.afterPipe=null}};function D(){this.stream._duplexState|=512,this.updateCallback()}function fe(e){let t=this.stream;e&&t.destroy(e),t._duplexState&14||(t._duplexState|=b,t.emit(`finish`)),(t._duplexState&re)==ne&&(t._duplexState|=4),t._duplexState&=402391039,t._duplexState&_?this.updateNextTick():this.update()}function pe(e){let t=this.stream;!e&&!a.isStreamDestroyed(this.error)&&(e=this.error),e&&t.emit(`error`,e),t._duplexState|=8,t.emit(`close`);let n=t._readableState,r=t._writableState;if(n!==null&&n.pipeline!==null&&n.pipeline.done(t,e),r!==null){for(;r.drains!==null&&r.drains.length>0;)r.drains.shift().resolve(!1);r.pipeline!==null&&r.pipeline.done(t,e)}}function me(e){let t=this.stream;e&&t.destroy(e),t._duplexState&=469499903,this.drains!==null&&ve(this.drains),(t._duplexState&6553615)==4194304&&(t._duplexState&=532676607,(t._duplexState&x)==x&&t.emit(`drain`)),this.updateCallback()}function he(e){e&&this.stream.destroy(e),this.stream._duplexState&=536870895,this.readAhead===!1&&!(this.stream._duplexState&256)&&(this.stream._duplexState&=g),this.updateCallback()}function ge(){this.stream._duplexState&32||(this.stream._duplexState&=h,this.update())}function _e(){this.stream._duplexState&_||(this.stream._duplexState&=T,this.update())}function ve(e){for(let t=0;t<e.length;t++)--e[t].writes===0&&(e.shift().resolve(!0),t--)}function ye(e){let t=this.stream;e&&t.destroy(e),t._duplexState&4||(t._duplexState&17423||(t._duplexState|=64),t._duplexState&142606351||(t._duplexState|=v),t.emit(`open`)),t._duplexState&=536608751,t._writableState!==null&&t._writableState.updateCallback(),t._readableState!==null&&t._readableState.updateCallback()}function be(e,t){t!=null&&this.push(t),this._writableState.afterWrite(e)}function xe(e){this._readableState!==null&&(e===`data`&&(this._duplexState|=133376,this._readableState.updateNextTick()),e===`readable`&&(this._duplexState|=4096,this._readableState.updateNextTick())),this._writableState!==null&&e===`drain`&&(this._duplexState|=x,this._writableState.updateNextTick())}var Se=class extends n{constructor(e){super(),this._duplexState=0,this._readableState=null,this._writableState=null,e&&(e.open&&(this._open=e.open),e.destroy&&(this._destroy=e.destroy),e.predestroy&&(this._predestroy=e.predestroy),e.signal&&e.signal.addEventListener(`abort`,Re.bind(this))),this.on(`newListener`,xe)}_open(e){e(null)}_destroy(e){e(null)}_predestroy(){}get readable(){return this._readableState!==null||void 0}get writable(){return this._writableState!==null||void 0}get destroyed(){return!!(this._duplexState&8)}get destroying(){return!!(this._duplexState&14)}destroy(e){this._duplexState&14||(e||=a.STREAM_DESTROYED(),this._duplexState=(this._duplexState|4)&535822271,this._readableState!==null&&(this._readableState.highWaterMark=0,this._readableState.error=e),this._writableState!==null&&(this._writableState.highWaterMark=0,this._writableState.error=e),this._duplexState|=2,this._predestroy(),this._duplexState&=536870909,this._readableState!==null&&this._readableState.updateNextTick(),this._writableState!==null&&this._writableState.updateNextTick())}},Ce=class e extends Se{constructor(e){super(e),this._duplexState|=8519681,this._readableState=new le(this,e),e&&(this._readableState.readAhead===!1&&(this._duplexState&=g),e.read&&(this._read=e.read),e.eagerOpen&&this._readableState.updateNextTick(),e.encoding&&this.setEncoding(e.encoding))}static deferred(e,t){let n=new j(t);return e().then(e=>{if(e===null)return n.end();n.destroying||M(e,n,Le)}).catch(e=>n.destroy(e)),n}setEncoding(e){let t=new i(e),n=this._readableState.map||Ee;return this._readableState.map=r,this;function r(e){let r=t.push(e);return r===``&&(e.byteLength!==0||t.remaining>0)?null:n(r)}}_read(e){e(null)}pipe(e,t){return this._readableState.updateNextTick(),this._readableState.pipe(e,t),e}read(){return this._readableState.updateNextTick(),this._readableState.read()}push(e){return this._readableState.updateNextTickIfOpen(),this._readableState.push(e)}unshift(e){return this._readableState.updateNextTickIfOpen(),this._readableState.unshift(e)}resume(){return this._duplexState|=131328,this._readableState.updateNextTick(),this}pause(){return this._duplexState&=this._readableState.readAhead===!1?536739583:536870655,this}static _fromAsyncIterator(t,n){let r,i=new e({...n,read(e){t.next().then(a).then(e.bind(null,null)).catch(e)},predestroy(){r=t.return()},destroy(e){if(!r)return e(null);r.then(e.bind(null,null)).catch(e)}});return i;function a(e){e.done?i.push(null):i.push(e.value)}}static from(t,n){if(Ne(t))return t;if(t[E])return this._fromAsyncIterator(t[E](),n);Array.isArray(t)||(t=t===void 0?[]:[t]);let r=0;return new e({...n,read(e){this.push(r===t.length?null:t[r++]),e(null)}})}static isBackpressured(e){return!!(e._duplexState&17422)||e._readableState.buffered>=e._readableState.highWaterMark}static isPaused(e){return!(e._duplexState&256)}[E](){let e=this,t=null,n=null,r=null;return this.on(`error`,e=>{t=e}),this.on(`readable`,i),this.on(`close`,o),{[E](){return this},next(){return new Promise(function(t,i){n=t,r=i;let a=e.read();a===null?e._duplexState&8&&s(null):s(a)})},return(){return c(null)},throw(e){return c(e)}};function i(){n!==null&&s(e.read())}function o(){n!==null&&s(null)}function s(i){r!==null&&(t?r(t):i===null&&!(e._duplexState&u)?r(a.STREAM_DESTROYED()):n({value:i,done:i===null}),r=n=null)}function c(t){return e.destroy(t),new Promise((n,r)=>{if(e._duplexState&8)return n({value:void 0,done:!0});e.once(`close`,function(){t?r(t):n({value:void 0,done:!0})})})}}},O=class extends Se{constructor(e){super(e),this._duplexState|=16385,this._writableState=new ce(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final),e.eagerOpen&&this._writableState.updateNextTick())}cork(){this._duplexState|=w}uncork(){this._duplexState&=ee,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}static isBackpressured(e){return!!(e._duplexState&146800654)}static drained(e){if(e.destroyed)return Promise.resolve(!1);let t=e._writableState,n=(ze(e)?Math.min(1,t.queue.length):t.queue.length)+(e._duplexState&67108864?1:0);return n===0?Promise.resolve(!0):(t.drains===null&&(t.drains=[]),new Promise(e=>{t.drains.push({writes:n,resolve:e})}))}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},k=class extends Ce{constructor(e){super(e),this._duplexState=1|this._duplexState&f,this._writableState=new ce(this,e),e&&(e.writev&&(this._writev=e.writev),e.write&&(this._write=e.write),e.final&&(this._final=e.final))}cork(){this._duplexState|=w}uncork(){this._duplexState&=ee,this._writableState.updateNextTick()}_writev(e,t){t(null)}_write(e,t){this._writableState.autoBatch(e,t)}_final(e){e(null)}write(e){return this._writableState.updateNextTick(),this._writableState.push(e)}end(e){return this._writableState.updateNextTick(),this._writableState.end(e),this}},A=class extends k{constructor(e){super(e),this._transformState=new ue(this),e&&(e.transform&&(this._transform=e.transform),e.flush&&(this._flush=e.flush))}_write(e,t){this._readableState.buffered>=this._readableState.highWaterMark?this._transformState.data=e:this._transform(e,this._transformState.afterTransform)}_read(e){if(this._transformState.data!==null){let t=this._transformState.data;this._transformState.data=null,e(null),this._transform(t,this._transformState.afterTransform)}else e(null)}destroy(e){super.destroy(e),this._transformState.data!==null&&(this._transformState.data=null,this._transformState.afterTransform())}_transform(e,t){t(null,e)}_flush(e){e(null)}_final(e){this._transformState.afterFinal=e,this._flush(we.bind(this))}},j=class extends A{};function we(e,t){let n=this._transformState.afterFinal;if(e)return n(e);t!=null&&this.push(t),this.push(null),n(null)}function Te(...e){return new Promise((t,n)=>M(...e,e=>{if(e)return n(e);t()}))}function M(e,...t){let n=Array.isArray(e)?[...e,...t]:[e,...t],r=n.length&&typeof n[n.length-1]==`function`?n.pop():null;if(n.length<2)throw a.BAD_ARGUMENT(`Pipeline requires at least 2 streams`);let i=n[0],o=null,s=null;for(let e=1;e<n.length;e++)o=n[e],N(i)?i.pipe(o,l):(c(i,!0,e>1,l),i.pipe(o)),i=o;if(r){let e=!1,t=N(o)||!!(o._writableState&&o._writableState.autoDestroy);o.on(`error`,e=>{s===null&&(s=e)}),o.on(`finish`,()=>{e=!0,t||r(s)}),t&&o.on(`close`,()=>r(s||(e?null:a.PREMATURE_CLOSE())))}return o;function c(e,t,n,r){e.on(`error`,r),e.on(`close`,i);function i(){if(t&&e._readableState&&!e._readableState.ended||n&&e._writableState&&!e._writableState.ended)return r(a.PREMATURE_CLOSE())}}function l(e){if(e&&!s){s=e;for(let t of n)t.destroy(e)}}}function Ee(e){return e}function De(e){return!!e._readableState||!!e._writableState}function N(e){return typeof e._duplexState==`number`&&De(e)}function Oe(e){return!!e._readableState&&e._readableState.ending}function ke(e){return!!e._readableState&&e._readableState.ended}function Ae(e){return!!e._writableState&&e._writableState.ending}function je(e){return!!e._writableState&&e._writableState.ended}function Me(e,t={}){let n=e._readableState&&e._readableState.error||e._writableState&&e._writableState.error;return!t.all&&a.isStreamDestroyed(n)?null:n}function Ne(e){return N(e)&&e.readable}function Pe(e){return(e._duplexState&1)!=1||(e._duplexState&4)==4||!!(e._duplexState&ie)}function Fe(e){return typeof e==`object`&&!!e&&typeof e.byteLength==`number`}function Ie(e){return Fe(e)?e.byteLength:1024}function Le(){}function Re(){this.destroy(a.ABORTED())}function ze(e){return e._writev!==O.prototype._writev&&e._writev!==k.prototype._writev}t.exports={pipeline:M,pipelinePromise:Te,isStream:De,isStreamx:N,isEnding:Oe,isEnded:ke,isFinishing:Ae,isFinished:je,isDisturbed:Pe,getStreamError:Me,Stream:Se,Writable:O,Readable:Ce,Duplex:k,Transform:A,PassThrough:j}})),it=n((e=>{let t=Qe(),n=t.from([117,115,116,97,114,0]),r=t.from([48,48]),i=t.from([117,115,116,97,114,32]),a=t.from([32,0]);e.decodeLongPath=function(e,t){return v(e,0,e.length,t)},e.encodePax=function(e){let n=``;e.name&&(n+=y(` path=`+e.name+`
|
|
2
2
|
`)),e.linkname&&(n+=y(` linkpath=`+e.linkname+`
|
|
3
3
|
`));let r=e.pax;if(r)for(let e in r)n+=y(` `+e+`=`+r[e]+`
|
|
4
4
|
`);return t.from(n)},e.decodePax=function(e){let n={};for(;e.length;){let r=0;for(;r<e.length&&e[r]!==32;)r++;let i=parseInt(t.toString(e.subarray(0,r)),10);if(!i)return n;let a=t.toString(e.subarray(r+1,i-1)),o=a.indexOf(`=`);if(o===-1)return n;n[a.slice(0,o)]=a.slice(o+1),e=e.subarray(i)}return n},e.encode=function(e){let i=t.alloc(512),a=e.name,o=``;if(e.typeflag===5&&a[a.length-1]!==`/`&&(a+=`/`),t.byteLength(a)!==a.length)return null;for(;t.byteLength(a)>100;){let e=a.indexOf(`/`);if(e===-1)return null;o+=o?`/`+a.slice(0,e):a.slice(0,e),a=a.slice(e+1)}return t.byteLength(a)>100||t.byteLength(o)>155||e.linkname&&t.byteLength(e.linkname)>100?null:(t.write(i,a),t.write(i,p(e.mode&4095,6),100),t.write(i,p(e.uid,6),108),t.write(i,p(e.gid,6),116),h(e.size,i,124),t.write(i,p(e.mtime.getTime()/1e3|0,11),136),i[156]=48+u(e.type),e.linkname&&t.write(i,e.linkname,157),t.copy(n,i,257),t.copy(r,i,263),e.uname&&t.write(i,e.uname,265),e.gname&&t.write(i,e.gname,297),t.write(i,p(e.devmajor||0,6),329),t.write(i,p(e.devminor||0,6),337),o&&t.write(i,o,345),t.write(i,p(f(i),6),148),i)},e.decode=function(e,t,n){let r=e[156]===0?0:e[156]-48,i=v(e,0,100,t),a=_(e,100,8),c=_(e,108,8),u=_(e,116,8),d=_(e,124,12),p=_(e,136,12),m=l(r),h=e[157]===0?null:v(e,157,100,t),g=v(e,265,32),y=v(e,297,32),b=_(e,329,8),x=_(e,337,8),S=f(e);if(S===256)return null;if(S!==_(e,148,8))throw Error(`Invalid tar header. Maybe the tar is corrupted or it needs to be gunzipped?`);if(o(e))e[345]&&(i=v(e,345,155,t)+`/`+i);else if(!s(e)&&!n)throw Error(`Invalid tar header: unknown format.`);return r===0&&i&&i[i.length-1]===`/`&&(r=5),{name:i,mode:a,uid:c,gid:u,size:d,mtime:new Date(1e3*p),type:m,linkname:h,uname:g,gname:y,devmajor:b,devminor:x,pax:null}};function o(e){return t.equals(n,e.subarray(257,263))}function s(e){return t.equals(i,e.subarray(257,263))&&t.equals(a,e.subarray(263,265))}function c(e,t,n){return typeof e==`number`?(e=~~e,e>=t?t:e>=0||(e+=t,e>=0)?e:0):n}function l(e){switch(e){case 0:return`file`;case 1:return`link`;case 2:return`symlink`;case 3:return`character-device`;case 4:return`block-device`;case 5:return`directory`;case 6:return`fifo`;case 7:return`contiguous-file`;case 72:return`pax-header`;case 55:return`pax-global-header`;case 27:return`gnu-long-link-path`;case 28:case 30:return`gnu-long-path`}return null}function u(e){switch(e){case`file`:return 0;case`link`:return 1;case`symlink`:return 2;case`character-device`:return 3;case`block-device`:return 4;case`directory`:return 5;case`fifo`:return 6;case`contiguous-file`:return 7;case`pax-header`:return 72}return 0}function d(e,t,n,r){for(;n<r;n++)if(e[n]===t)return n;return r}function f(e){let t=256;for(let n=0;n<148;n++)t+=e[n];for(let n=156;n<512;n++)t+=e[n];return t}function p(e,t){return e=e.toString(8),e.length>t?`7777777777777777777`.slice(0,t)+` `:`0000000000000000000`.slice(0,t-e.length)+e+` `}function m(e,t,n){t[n]=128;for(let r=11;r>0;r--)t[n+r]=e&255,e=Math.floor(e/256)}function h(e,n,r){e.toString(8).length>11?m(e,n,r):t.write(n,p(e,11),r)}function g(e){let t;if(e[0]===128)t=!0;else if(e[0]===255)t=!1;else return null;let n=[],r;for(r=e.length-1;r>0;r--){let i=e[r];t?n.push(i):n.push(255-i)}let i=0,a=n.length;for(r=0;r<a;r++)i+=n[r]*256**r;return t?i:-1*i}function _(e,n,r){if(e=e.subarray(n,n+r),n=0,e[n]&128)return g(e);{for(;n<e.length&&e[n]===32;)n++;let r=c(d(e,32,n,e.length),e.length,e.length);for(;n<r&&e[n]===0;)n++;return r===n?0:parseInt(t.toString(e.subarray(n,r)),8)}}function v(e,n,r,i){return t.toString(e.subarray(n,d(e,0,n,n+r)),i)}function y(e){let n=t.byteLength(e),r=Math.floor(Math.log(n)/Math.log(10))+1;return n+r>=10**r&&r++,n+r+e}})),at=n(((e,t)=>{let{Writable:n,Readable:r,getStreamError:i}=rt(),a=Ze(),o=Qe(),s=it(),c=o.alloc(0);var l=class{constructor(){this.buffered=0,this.shifted=0,this.queue=new a,this._offset=0}push(e){this.buffered+=e.byteLength,this.queue.push(e)}shiftFirst(e){return this._buffered===0?null:this._next(e)}shift(e){if(e>this.buffered)return null;if(e===0)return c;let t=this._next(e);if(e===t.byteLength)return t;let n=[t];for(;(e-=t.byteLength)>0;)t=this._next(e),n.push(t);return o.concat(n)}_next(e){let t=this.queue.peek(),n=t.byteLength-this._offset;if(e>=n){let e=this._offset?t.subarray(this._offset,t.byteLength):t;return this.queue.shift(),this._offset=0,this.buffered-=n,this.shifted+=n,e}return this.buffered-=e,this.shifted+=e,t.subarray(this._offset,this._offset+=e)}},u=class extends r{constructor(e,t,n){super(),this.header=t,this.offset=n,this._parent=e}_read(e){this.header.size===0&&this.push(null),this._parent._stream===this&&this._parent._update(),e(null)}_predestroy(){this._parent.destroy(i(this))}_detach(){this._parent._stream===this&&(this._parent._stream=null,this._parent._missing=p(this.header.size),this._parent._update())}_destroy(e){this._detach(),e(null)}},d=class extends n{constructor(e){super(e),e||={},this._buffer=new l,this._offset=0,this._header=null,this._stream=null,this._missing=0,this._longHeader=!1,this._callback=f,this._locked=!1,this._finished=!1,this._pax=null,this._paxGlobal=null,this._gnuLongPath=null,this._gnuLongLinkPath=null,this._filenameEncoding=e.filenameEncoding||`utf-8`,this._allowUnknownFormat=!!e.allowUnknownFormat,this._unlockBound=this._unlock.bind(this)}_unlock(e){if(this._locked=!1,e){this.destroy(e),this._continueWrite(e);return}this._update()}_consumeHeader(){if(this._locked)return!1;this._offset=this._buffer.shifted;try{this._header=s.decode(this._buffer.shift(512),this._filenameEncoding,this._allowUnknownFormat)}catch(e){return this._continueWrite(e),!1}if(!this._header)return!0;switch(this._header.type){case`gnu-long-path`:case`gnu-long-link-path`:case`pax-global-header`:case`pax-header`:return this._longHeader=!0,this._missing=this._header.size,!0}return this._locked=!0,this._applyLongHeaders(),this._header.size===0||this._header.type===`directory`?(this.emit(`entry`,this._header,this._createStream(),this._unlockBound),!0):(this._stream=this._createStream(),this._missing=this._header.size,this.emit(`entry`,this._header,this._stream,this._unlockBound),!0)}_applyLongHeaders(){this._gnuLongPath&&=(this._header.name=this._gnuLongPath,null),this._gnuLongLinkPath&&=(this._header.linkname=this._gnuLongLinkPath,null),this._pax&&=(this._pax.path&&(this._header.name=this._pax.path),this._pax.linkpath&&(this._header.linkname=this._pax.linkpath),this._pax.size&&(this._header.size=parseInt(this._pax.size,10)),this._header.pax=this._pax,null)}_decodeLongHeader(e){switch(this._header.type){case`gnu-long-path`:this._gnuLongPath=s.decodeLongPath(e,this._filenameEncoding);break;case`gnu-long-link-path`:this._gnuLongLinkPath=s.decodeLongPath(e,this._filenameEncoding);break;case`pax-global-header`:this._paxGlobal=s.decodePax(e);break;case`pax-header`:this._pax=this._paxGlobal===null?s.decodePax(e):Object.assign({},this._paxGlobal,s.decodePax(e))}}_consumeLongHeader(){this._longHeader=!1,this._missing=p(this._header.size);let e=this._buffer.shift(this._header.size);try{this._decodeLongHeader(e)}catch(e){return this._continueWrite(e),!1}return!0}_consumeStream(){let e=this._buffer.shiftFirst(this._missing);if(e===null)return!1;this._missing-=e.byteLength;let t=this._stream.push(e);return this._missing===0?(this._stream.push(null),t&&this._stream._detach(),t&&this._locked===!1):t}_createStream(){return new u(this,this._header,this._offset)}_update(){for(;this._buffer.buffered>0&&!this.destroying;){if(this._missing>0){if(this._stream!==null){if(this._consumeStream()===!1)return;continue}if(this._longHeader===!0){if(this._missing>this._buffer.buffered)break;if(this._consumeLongHeader()===!1)return!1;continue}let e=this._buffer.shiftFirst(this._missing);e!==null&&(this._missing-=e.byteLength);continue}if(this._buffer.buffered<512)break;if(this._stream!==null||this._consumeHeader()===!1)return}this._continueWrite(null)}_continueWrite(e){let t=this._callback;this._callback=f,t(e)}_write(e,t){this._callback=t,this._buffer.push(e),this._update()}_final(e){this._finished=this._missing===0&&this._buffer.buffered===0,e(this._finished?null:Error(`Unexpected end of data`))}_predestroy(){this._continueWrite(null)}_destroy(e){this._stream&&this._stream.destroy(i(this)),e(null)}[Symbol.asyncIterator](){let e=null,t=null,n=null,r=null,i=null,a=this;return this.on(`entry`,c),this.on(`error`,t=>{e=t}),this.on(`close`,l),{[Symbol.asyncIterator](){return this},next(){return new Promise(s)},return(){return u(null)},throw(e){return u(e)}};function o(e){if(!i)return;let t=i;i=null,t(e)}function s(i,s){if(e)return s(e);if(r){i({value:r,done:!1}),r=null;return}t=i,n=s,o(null),a._finished&&t&&(t({value:void 0,done:!0}),t=n=null)}function c(e,a,o){i=o,a.on(`error`,f),t?(t({value:a,done:!1}),t=n=null):r=a}function l(){o(e),t&&=(e?n(e):t({value:void 0,done:!0}),n=null)}function u(e){return a.destroy(e),o(e),new Promise((t,n)=>{if(a.destroyed)return t({value:void 0,done:!0});a.once(`close`,function(){e?n(e):t({value:void 0,done:!0})})})}}};t.exports=function(e){return new d(e)};function f(){}function p(e){return e&=511,e&&512-e}})),ot=n(((t,n)=>{let r={S_IFMT:61440,S_IFDIR:16384,S_IFCHR:8192,S_IFBLK:24576,S_IFIFO:4096,S_IFLNK:40960};try{n.exports=e(`fs`).constants||r}catch{n.exports=r}})),st=n(((e,t)=>{let{Readable:n,Writable:r,getStreamError:i}=rt(),a=Qe(),o=ot(),s=it(),c=a.alloc(1024);var l=class extends r{constructor(e,t,n){super({mapWritable:m,eagerOpen:!0}),this.written=0,this.header=t,this._callback=n,this._linkname=null,this._isLinkname=t.type===`symlink`&&!t.linkname,this._isVoid=t.type!==`file`&&t.type!==`contiguous-file`,this._finished=!1,this._pack=e,this._openCallback=null,this._pack._stream===null?this._pack._stream=this:this._pack._pending.push(this)}_open(e){this._openCallback=e,this._pack._stream===this&&this._continueOpen()}_continuePack(e){if(this._callback===null)return;let t=this._callback;this._callback=null,t(e)}_continueOpen(){this._pack._stream===null&&(this._pack._stream=this);let e=this._openCallback;if(this._openCallback=null,e!==null){if(this._pack.destroying)return e(Error(`pack stream destroyed`));if(this._pack._finalized)return e(Error(`pack stream is already finalized`));this._pack._stream=this,this._isLinkname||this._pack._encode(this.header),this._isVoid&&(this._finish(),this._continuePack(null)),e(null)}}_write(e,t){if(this._isLinkname)return this._linkname=this._linkname?a.concat([this._linkname,e]):e,t(null);if(this._isVoid)return e.byteLength>0?t(Error(`No body allowed for this entry`)):t();if(this.written+=e.byteLength,this._pack.push(e))return t();this._pack._drain=t}_finish(){this._finished||(this._finished=!0,this._isLinkname&&(this.header.linkname=this._linkname?a.toString(this._linkname,`utf-8`):``,this._pack._encode(this.header)),p(this._pack,this.header.size),this._pack._done(this))}_final(e){if(this.written!==this.header.size)return e(Error(`Size mismatch`));this._finish(),e(null)}_getError(){return i(this)||Error(`tar entry destroyed`)}_predestroy(){this._pack.destroy(this._getError())}_destroy(e){this._pack._done(this),this._continuePack(this._finished?null:this._getError()),e()}},u=class extends n{constructor(e){super(e),this._drain=f,this._finalized=!1,this._finalizing=!1,this._pending=[],this._stream=null}entry(e,t,n){if(this._finalized||this.destroying)throw Error(`already finalized or destroyed`);typeof t==`function`&&(n=t,t=null),n||=f,(!e.size||e.type===`symlink`)&&(e.size=0),e.type||=d(e.mode),e.mode||=e.type===`directory`?493:420,e.uid||=0,e.gid||=0,e.mtime||=new Date,typeof t==`string`&&(t=a.from(t));let r=new l(this,e,n);return a.isBuffer(t)?(e.size=t.byteLength,r.write(t),r.end(),r):(r._isVoid,r)}finalize(){if(this._stream||this._pending.length>0){this._finalizing=!0;return}this._finalized||(this._finalized=!0,this.push(c),this.push(null))}_done(e){e===this._stream&&(this._stream=null,this._finalizing&&this.finalize(),this._pending.length&&this._pending.shift()._continueOpen())}_encode(e){if(!e.pax){let t=s.encode(e);if(t){this.push(t);return}}this._encodePax(e)}_encodePax(e){let t=s.encodePax({name:e.name,linkname:e.linkname,pax:e.pax}),n={name:`PaxHeader`,mode:e.mode,uid:e.uid,gid:e.gid,size:t.byteLength,mtime:e.mtime,type:`pax-header`,linkname:e.linkname&&`PaxHeader`,uname:e.uname,gname:e.gname,devmajor:e.devmajor,devminor:e.devminor};this.push(s.encode(n)),this.push(t),p(this,t.byteLength),n.size=e.size,n.type=e.type,this.push(s.encode(n))}_doDrain(){let e=this._drain;this._drain=f,e()}_predestroy(){let e=i(this);for(this._stream&&this._stream.destroy(e);this._pending.length;){let t=this._pending.shift();t.destroy(e),t._continueOpen()}this._doDrain()}_read(e){this._doDrain(),e()}};t.exports=function(e){return new u(e)};function d(e){switch(e&o.S_IFMT){case o.S_IFBLK:return`block-device`;case o.S_IFCHR:return`character-device`;case o.S_IFDIR:return`directory`;case o.S_IFIFO:return`fifo`;case o.S_IFLNK:return`symlink`}return`file`}function f(){}function p(e,t){t&=511,t&&e.push(c.subarray(0,512-t))}function m(e){return a.isBuffer(e)?e:a.from(e)}})),ct=t(n((e=>{e.extract=at(),e.pack=st()}))(),1),lt=class{constructor(){let e=p.createGzip();this.pack=ct.pack(),this.readable=this.pack.pipe(e)}async addFile(e){return new Promise((t,n)=>{let r=this.pack.entry(`size`in e?{name:e.name,size:e.size,mode:e.mode}:{name:e.name,size:Buffer.byteLength(e.content),mode:e.mode},e=>{if(e)return n(e);t()});e.content instanceof f?e.content.pipe(r):r.end(e.content)})}async end(){return new Promise((e,t)=>{this.readable.on(`error`,t),this.readable.on(`end`,e),this.pack.finalize()})}};function ut(e){return new Promise((t,n)=>{let r=[];e.on(`error`,e=>n(e)),e.on(`data`,e=>r.push(e)),e.on(`end`,()=>t(Buffer.concat(r)))})}function dt(e){if(!m.posix.isAbsolute(e.cwd))throw Error(`cwd dir must be absolute`);if(!m.posix.isAbsolute(e.extractDir))throw Error(`extractDir must be absolute`);let t=m.posix.isAbsolute(e.filePath)?m.posix.normalize(e.filePath):m.posix.join(e.cwd,e.filePath);return m.posix.relative(e.extractDir,t)}function ft(e){let t=e===`allow-all`||e===`deny-all`?{mode:e}:e;return Se.parse(t),t}function pt(e){if(e.mode===`allow-all`||e.mode===`deny-all`)return e.mode;let t=e.allowedCIDRs||e.deniedCIDRs?{subnets:{...e.allowedCIDRs&&{allow:e.allowedCIDRs},...e.deniedCIDRs&&{deny:e.deniedCIDRs}}}:void 0;if(e.injectionRules&&e.injectionRules.length>0||e.forwardRules&&e.forwardRules.length>0){let n=new Map;for(let t of e.injectionRules??[]){let e=Object.fromEntries((t.headerNames??[]).map(e=>[e,`<redacted>`])),r=n.get(t.domain)??[];r.push({...t.match?{match:t.match}:{},transform:[{headers:e}]}),n.set(t.domain,r)}for(let t of e.forwardRules??[]){let e=n.get(t.domain)??[];e.push({...t.match?{match:t.match}:{},forwardURL:t.forwardURL}),n.set(t.domain,e)}let r={};for(let t of e.allowedDomains??[])r[t]=n.get(t)??[];for(let t of[...e.injectionRules??[],...e.forwardRules??[]])t.domain in r||(r[t.domain]=n.get(t.domain)??[]);return{allow:r,...t}}return{...e.allowedDomains&&{allow:e.allowedDomains},...t}}const P=e=>{let t=Object.entries(e??{}).filter(([e])=>e.startsWith(`__`));return Object.fromEntries(t)};var mt=n(((t,n)=>{var r=e(`stream`).Transform;function i(e){if(!(this instanceof i))throw TypeError(`Cannot call a class as a function`);e||={},r.call(this,{objectMode:!0}),this._memory=``,this._emitInvalidLines=e.emitInvalidLines||!1}i.prototype=Object.create(r.prototype),i.prototype._handleLines=function(e,t){for(var n=0;n<e.length;n++)if(e[n]!==``){var r=null,i=null;try{i=JSON.parse(e[n])}catch(t){t.source=e[n],r=t}if(r){if(this._emitInvalidLines)this.emit(`invalid-line`,r);else return t(r)}else this.push(i)}t(null)},i.prototype._transform=function(e,t,n){var r=(this._memory+e.toString()).split(`
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import"../../_chunks/workflow/dist-
|
|
2
|
-
`)}`)}return await S(t,r.value)}}}async function D(e,
|
|
1
|
+
import"../../_chunks/workflow/dist-B7NC1c9-.js";import{Xn as e,tr as t,zn as n}from"../../_chunks/workflow/logger-oqfblE3p.js";import{d as r,i}from"../../_chunks/workflow/dist-CaNNONeg.js";import{K as a,T as o,at as s,dt as c,ft as l,i as u,it as d,lt as f,ot as p,q as m,rt as h,ut as g,x as _}from"../../_chunks/workflow/serialization-APSKphN5.js";import{a as v,i as y,r as b,t as x}from"../../_chunks/workflow/attribute-changes-VaTKT4K8.js";import{n as S}from"../../_chunks/workflow/resume-hook-yq-NAdBu.js";import{t as C}from"../../_chunks/workflow/sleep-Ba8SExMt.js";function w(e){y(`createHook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-hook`,w)}function T(e){y(`createWebhook()`,`https://workflow-sdk.dev/docs/api-reference/workflow/create-webhook`,T)}function E({schema:e}={}){function t(e){y(`defineHook().create()`,`https://workflow-sdk.dev/docs/api-reference/workflow/define-hook`,t)}return{create:t,async resume(t,n){if(!e?.[`~standard`])return await S(t,n);let r=e[`~standard`].validate(n);if(r instanceof Promise&&(r=await r),r.issues){let e=r.issues.map(e=>{let t=e.path?.map(e=>String(typeof e==`object`&&e?e.key:e)).join(`.`);return t?` at "${t}": ${e.message}`:` ${e.message}`});throw Error(`Hook payload did not match the defined schema:\n${e.join(`
|
|
2
|
+
`)}`)}return await S(t,r.value)}}}async function D(e,n={}){let r=m.getStore(),a=r?.workflowMetadata?.workflowRunId;if(!a)throw new i(`setAttributes() must be called from a 'use workflow' or 'use step' function. Calling it from plain host code is not supported.`);let o={type:`step`,stepId:r.stepMetadata.stepId,attempt:r.stepMetadata.attempt},s=x(e,n,o);if(s.length!==0){if(r.runReadyBarrier)try{await r.runReadyBarrier}catch{}await(await t()).events.create(a,{eventType:`attr_set`,specVersion:8,eventData:{changes:s,writer:o,...n.allowReservedAttributes===!0?{allowReservedAttributes:!0}:{}}})}}function O(){let e=m.getStore();return e||b(`getStepMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-step-metadata`,O),e.stepMetadata}function k(){let e=m.getStore();return e||v(`getWorkflowMetadata()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-workflow-metadata`,k),e.workflowMetadata}function A(t={}){let r=m.getStore();r||v(`getWritable()`,`https://workflow-sdk.dev/docs/api-reference/workflow/get-writable`,A);let{namespace:i}=t,y=r.workflowMetadata.workflowRunId,b=a(y,i);r.writables??=new Map;let x=r.writables,S=x.get(b);if(S)return S.writable;let C=h();C.deferReleaseSettlement=r.streamStates!==void 0;let w=o(_(globalThis,r.ops,y,r.encryptionKey,!0,r.runReadyBarrier),r.encryptionKey),T=new u(y,b,r.runReadyBarrier);r.streamStates??=[],r.streamStates.push(C),r.ops.push(C.promise),d(w.readable,T,C).catch(()=>{});let E=p(w.writable,C);return s(E,C),Object.defineProperty(E,f,{value:b,writable:!1}),Object.defineProperty(E,l,{value:y,writable:!1}),r.workflowDeploymentId&&Object.defineProperty(E,g,{value:r.workflowDeploymentId,writable:!1}),n(r.encryptionKey)&&Object.defineProperty(E,c,{value:e(r.encryptionKey.keyPair.publicKey),writable:!1}),x.set(b,{writable:E,state:C}),E}export{i as FatalError,r as RetryableError,w as createHook,T as createWebhook,E as defineHook,O as getStepMetadata,k as getWorkflowMetadata,A as getWritable,D as setAttributes,C as sleep};
|
|
@@ -232,6 +232,21 @@ export declare function isQuickJSBaselineSnapshotEnabled(): boolean;
|
|
|
232
232
|
* pre-retention behavior.
|
|
233
233
|
*/
|
|
234
234
|
export declare function isVmRetentionEnabled(): boolean;
|
|
235
|
+
/** Environment variable that opts a deployment into dynamic workflows. */
|
|
236
|
+
export declare const DYNAMIC_WORKFLOWS_ENV = "WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS";
|
|
237
|
+
/**
|
|
238
|
+
* Whether this deployment executes dynamic workflows (default OFF).
|
|
239
|
+
*
|
|
240
|
+
* Dynamic source runs with the full privileges of the deployment's functions,
|
|
241
|
+
* so a deployment must opt in before it starts a dynamic run, advertises
|
|
242
|
+
* dynamic support in its health check, or executes stored dynamic code on a
|
|
243
|
+
* delivery. Only `1` or `true` (case-insensitive) enables it; any other value
|
|
244
|
+
* leaves it off.
|
|
245
|
+
*
|
|
246
|
+
* Reads `process.env.WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS` on every call so
|
|
247
|
+
* the deployment's runtime environment decides, not the build.
|
|
248
|
+
*/
|
|
249
|
+
export declare function isDynamicWorkflowsEnabled(): boolean;
|
|
235
250
|
/**
|
|
236
251
|
* Whether inline step ownership is enabled (default ON). When on, the lazy
|
|
237
252
|
* `step_started` that creates an inline step records the owning queue
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dynamic workflow source: starting a run from a workflow function that is
|
|
3
|
+
* not in the deployment's build-time manifest.
|
|
4
|
+
*
|
|
5
|
+
* The normal path compiles workflow functions at build time — the SWC plugin
|
|
6
|
+
* rewrites `"use workflow"` bodies, the builder bundles them, and `start()`
|
|
7
|
+
* names one by the `workflowId` the transform stamped on it. Dynamic source
|
|
8
|
+
* covers orchestration the application assembles after the deployment exists,
|
|
9
|
+
* over a fixed catalog of deployed steps.
|
|
10
|
+
*
|
|
11
|
+
* This module owns the compile half of that: validating the source, deriving
|
|
12
|
+
* a stable workflow id from it, and generating the VM code that registers it.
|
|
13
|
+
* The generated code — not the source — is what gets stored with the run and
|
|
14
|
+
* replayed, so the module is also the format boundary: a run replays byte-for-byte
|
|
15
|
+
* the code it started on, and changing the generator here does not retroactively
|
|
16
|
+
* change what an in-flight run executes.
|
|
17
|
+
*
|
|
18
|
+
* Deliberately not a security sandbox. The workflow VM enforces determinism,
|
|
19
|
+
* not isolation from malicious JavaScript, so dynamic source is trusted
|
|
20
|
+
* application code with the full privileges of the deployment's functions.
|
|
21
|
+
* The `steps` allowlist below is a convenience that keeps ordinary code from
|
|
22
|
+
* reaching a step it was not given; it is not a capability boundary against
|
|
23
|
+
* code that is actively trying to escape one. Deployments opt in with
|
|
24
|
+
* `WORKFLOW_EXPERIMENTAL_DYNAMIC_WORKFLOWS` before they start or execute it.
|
|
25
|
+
*/
|
|
26
|
+
import { WorkflowRuntimeError } from '#compiled/@workflow/errors/index.js';
|
|
27
|
+
import type { StartOptions } from './start.js';
|
|
28
|
+
/**
|
|
29
|
+
* The error `start()` throws when it refuses a dynamic start before anything
|
|
30
|
+
* is written: invalid source or options, the opt-in, the target deployment,
|
|
31
|
+
* the World's capability, or its execution-context limit.
|
|
32
|
+
*
|
|
33
|
+
* Each refusal is deterministic, so retrying the same `start()` fails the same
|
|
34
|
+
* way. `fatal` is what tells the step executor so when `start()` runs inside
|
|
35
|
+
* a step: without it the step spends its retry budget on a refusal, then
|
|
36
|
+
* replaces the message with its retry-exhaustion wrapper. The type and message
|
|
37
|
+
* are otherwise a plain `WorkflowRuntimeError`. See `FatalError.is()`.
|
|
38
|
+
*/
|
|
39
|
+
export declare function dynamicStartRefusal(message: string, options?: ErrorOptions): WorkflowRuntimeError & {
|
|
40
|
+
fatal: true;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* The refusal for an error thrown by a World's `validateRunExecutionContext`;
|
|
44
|
+
* the World contract makes that throw the start's refusal, whatever it threw.
|
|
45
|
+
*
|
|
46
|
+
* A fresh error carrying the World's message, with the original as `cause`,
|
|
47
|
+
* rather than a `fatal` flag set on the World's own object: that object may be
|
|
48
|
+
* frozen, shared across calls, or not an `Error` at all.
|
|
49
|
+
*/
|
|
50
|
+
export declare function dynamicStartRefusalFrom(error: unknown): WorkflowRuntimeError & {
|
|
51
|
+
fatal: true;
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* A step exposed to dynamic source.
|
|
55
|
+
*
|
|
56
|
+
* Either an imported step function, or an explicit `{ stepId }` for a step
|
|
57
|
+
* whose function is not importable from the calling context.
|
|
58
|
+
*
|
|
59
|
+
* The function arm is deliberately typed as "any function" rather than as
|
|
60
|
+
* something carrying `stepId`: the build-time transform stamps `.stepId` on
|
|
61
|
+
* step functions at *runtime*, and nothing adds it to their declared type. A
|
|
62
|
+
* type that demanded it would reject the documented call — `steps: { fetchUser,
|
|
63
|
+
* sendEmail }` with real imports — and only accept the escape hatch. The
|
|
64
|
+
* runtime check in `resolveStepId` is the real gate, and it fails with a
|
|
65
|
+
* message naming the alias when a value turns out to carry no step id.
|
|
66
|
+
*/
|
|
67
|
+
export type DynamicWorkflowStepReference = {
|
|
68
|
+
readonly stepId: string;
|
|
69
|
+
} | ((...args: any[]) => unknown);
|
|
70
|
+
export interface DynamicWorkflowOptions {
|
|
71
|
+
/**
|
|
72
|
+
* Already-registered step functions to expose to the source, keyed by the
|
|
73
|
+
* alias it calls them under (`steps.<alias>(...)`).
|
|
74
|
+
*
|
|
75
|
+
* Each value is either an imported step function — the SDK transform stamps
|
|
76
|
+
* a `.stepId` on it — or an explicit `{ stepId }` reference for a step whose
|
|
77
|
+
* function is not importable from the calling context.
|
|
78
|
+
*
|
|
79
|
+
* There is no way to register a *new* step from dynamic source: only the
|
|
80
|
+
* orchestration is dynamic, and every step it can reach was deployed with
|
|
81
|
+
* the app.
|
|
82
|
+
*/
|
|
83
|
+
steps: Record<string, DynamicWorkflowStepReference>;
|
|
84
|
+
/**
|
|
85
|
+
* Name of the async workflow function in the source. Defaults to
|
|
86
|
+
* `"workflow"`.
|
|
87
|
+
*/
|
|
88
|
+
exportName?: string;
|
|
89
|
+
}
|
|
90
|
+
/** `start()` options for the dynamic-source overload. */
|
|
91
|
+
export type DynamicStartOptions = StartOptions & {
|
|
92
|
+
experimental_dynamic: DynamicWorkflowOptions;
|
|
93
|
+
};
|
|
94
|
+
/**
|
|
95
|
+
* Plaintext metadata recorded on `executionContext.dynamicWorkflow`.
|
|
96
|
+
*
|
|
97
|
+
* Deliberately small and non-sensitive: it has to fit the execution-context
|
|
98
|
+
* budget (2 KB on `world-vercel`) and it is readable without decrypting
|
|
99
|
+
* anything, which is what lets observability show that a run is dynamic —
|
|
100
|
+
* and which steps it was allowed to call — while the code itself stays
|
|
101
|
+
* encrypted behind the run's ref.
|
|
102
|
+
*/
|
|
103
|
+
export interface DynamicWorkflowMetadata {
|
|
104
|
+
version: 1;
|
|
105
|
+
/** SHA-256 over the source and its step bindings. */
|
|
106
|
+
sourceHash: string;
|
|
107
|
+
/** Name of the workflow function inside the source. */
|
|
108
|
+
exportName: string;
|
|
109
|
+
/** Alias → step id map the source was compiled against. */
|
|
110
|
+
steps: Record<string, string>;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Maximum size of the *source* `start()` accepts.
|
|
114
|
+
*
|
|
115
|
+
* This is a product limit rather than a storage one — generated
|
|
116
|
+
* orchestration functions are small, and a caller handing us a megabyte of
|
|
117
|
+
* "workflow" has almost certainly made a mistake worth surfacing at the call
|
|
118
|
+
* site. The storage layer's own cap is far higher; see the Dynamic Workflows
|
|
119
|
+
* docs.
|
|
120
|
+
*/
|
|
121
|
+
export declare const DYNAMIC_WORKFLOW_SOURCE_MAX_BYTES: number;
|
|
122
|
+
/**
|
|
123
|
+
* Largest serialized code payload sent inline on `run_created`.
|
|
124
|
+
*
|
|
125
|
+
* Above this the code is uploaded separately and referenced, because it stops
|
|
126
|
+
* fitting comfortably in the creating write's metadata budget (the
|
|
127
|
+
* `world-vercel` backend caps the inline field at 32 KB). Set below that cap
|
|
128
|
+
* so a compression ratio worse than expected does not push a run over it.
|
|
129
|
+
*
|
|
130
|
+
* Almost every real definition is under this: 24 KB of *compressed,
|
|
131
|
+
* encrypted* bytes is a lot of JavaScript.
|
|
132
|
+
*/
|
|
133
|
+
export declare const DYNAMIC_WORKFLOW_CODE_INLINE_MAX_BYTES: number;
|
|
134
|
+
/**
|
|
135
|
+
* The SDK's limit on `exportName`. The name becomes the last segment of the
|
|
136
|
+
* generated workflow id, which is also the queue topic name, and it counts
|
|
137
|
+
* against the run's execution-context budget. Queues cap topic names too
|
|
138
|
+
* (Vercel's at 256 characters, prefix included), so a long name buys nothing
|
|
139
|
+
* and fails late.
|
|
140
|
+
*/
|
|
141
|
+
export declare const DYNAMIC_WORKFLOW_EXPORT_NAME_MAX_LENGTH = 64;
|
|
142
|
+
export interface CompiledDynamicWorkflow {
|
|
143
|
+
/** Generated workflow id, also the run's `workflowName`. */
|
|
144
|
+
workflowName: string;
|
|
145
|
+
/** Workflow VM code to store with the run and replay from. */
|
|
146
|
+
workflowCode: string;
|
|
147
|
+
/** Plaintext metadata for `executionContext.dynamicWorkflow`. */
|
|
148
|
+
metadata: DynamicWorkflowMetadata;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* The workflow id a dynamic definition registers under.
|
|
152
|
+
*
|
|
153
|
+
* Half the digest. Long enough that a collision is not a practical concern and
|
|
154
|
+
* short enough to keep queue topic names and observability rows readable.
|
|
155
|
+
* Delivery recomputes it from a run's `dynamicWorkflow` marker and refuses a
|
|
156
|
+
* run whose `workflowName` does not match, so a marker cannot turn a static
|
|
157
|
+
* workflow's run into one that executes stored code.
|
|
158
|
+
*/
|
|
159
|
+
export declare function dynamicWorkflowName(metadata: Pick<DynamicWorkflowMetadata, 'sourceHash' | 'exportName'>): string;
|
|
160
|
+
/**
|
|
161
|
+
* Validate dynamic source and generate the workflow VM code for it.
|
|
162
|
+
*
|
|
163
|
+
* The workflow id is derived from the source and its step bindings rather
|
|
164
|
+
* than accepted from the caller. Two consequences, both intentional: the same
|
|
165
|
+
* definition always lands on the same queue topic and groups together in
|
|
166
|
+
* observability, and a caller cannot claim a static workflow's id — or
|
|
167
|
+
* another definition's — for arbitrary code.
|
|
168
|
+
*/
|
|
169
|
+
export declare function compileDynamicWorkflow(source: string, options: DynamicWorkflowOptions): Promise<CompiledDynamicWorkflow>;
|
|
170
|
+
/**
|
|
171
|
+
* Read the dynamic-workflow marker off a run's `executionContext`.
|
|
172
|
+
*
|
|
173
|
+
* The runtime uses this to decide whether a run replays from the deployment's
|
|
174
|
+
* bundle or from its own stored code, so it validates the shape rather than
|
|
175
|
+
* trusting it: `executionContext` is client-supplied and passes through the
|
|
176
|
+
* backend unchecked.
|
|
177
|
+
*
|
|
178
|
+
* Returns undefined for every static run, which is the overwhelming majority
|
|
179
|
+
* — this is on the hot path of each delivery.
|
|
180
|
+
*/
|
|
181
|
+
export declare function readDynamicWorkflowMetadata(executionContext: unknown): DynamicWorkflowMetadata | undefined;
|
|
182
|
+
//# sourceMappingURL=dynamic-workflow.d.ts.map
|
|
@@ -6,6 +6,8 @@ import { type PayloadKey } from '../serialization/encryption.js';
|
|
|
6
6
|
* interpolating it into the queue name string.
|
|
7
7
|
*/
|
|
8
8
|
export declare function getWorkflowQueueName(workflowName: string, namespace?: string): ValidQueueName;
|
|
9
|
+
/** Version of the dynamic-workflow runtime contract advertised by deployments. */
|
|
10
|
+
export declare const DYNAMIC_WORKFLOW_VERSION = 1;
|
|
9
11
|
/**
|
|
10
12
|
* Result of a health check operation.
|
|
11
13
|
*/
|
|
@@ -54,6 +56,11 @@ export interface HealthCheckResult {
|
|
|
54
56
|
* field is missing or malformed.
|
|
55
57
|
*/
|
|
56
58
|
format?: 'json' | 'text';
|
|
59
|
+
/**
|
|
60
|
+
* Version of dynamic-workflow execution supported by the target runtime.
|
|
61
|
+
* Present only when the target has opted in to dynamic workflows.
|
|
62
|
+
*/
|
|
63
|
+
dynamicWorkflowVersion?: number;
|
|
57
64
|
}
|
|
58
65
|
/**
|
|
59
66
|
* Checks if the given message is a health check payload.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,
|
|
1
|
+
import{C as e,D as t,E as n,O as r,S as i,T as a,_ as o,a as s,b as c,c as l,d as u,f as d,g as f,h as p,i as m,k as h,l as g,m as _,n as v,o as y,p as b,r as x,s as S,t as C,u as w,v as T,w as E,x as D,y as O}from"../../../_chunks/workflow/helpers-CP9TjeO8.js";export{C as DYNAMIC_WORKFLOW_VERSION,v as REPLAY_RESOLVE_DATA,x as SLOT_GAP_RECHECK_ATTEMPTS,m as absorbSkippedSlotReport,s as appendEventLog,y as appendUniqueEvents,S as findEventSlotGap,l as getQueueOverhead,g as getWorkflowQueueName,w as handleHealthCheckMessage,u as healthCheck,d as insertEventByEventId,b as isSlotGapCheckEnabled,_ as loadWorkflowRunEvents,p as maxEventSlot,f as memoizeEncryptionKey,o as mergeReportedEvents,T as parseHealthCheckPayload,O as preconditionEventDelta,c as queueMessage,D as queueMessages,i as resolveRunEncryptionKey,e as rootRunIdFrom,E as runDispatchContext,a as settleEventSlotGap,n as slotSnapshotParams,t as stepDispatchIdempotencyKey,r as withHealthCheck,h as withReplayDelta};
|
|
@@ -10,5 +10,12 @@
|
|
|
10
10
|
import type { ExtensionDescriptor } from '../_quickjs-wasi.js';
|
|
11
11
|
declare const quickjsWasm: Uint8Array<ArrayBufferLike>;
|
|
12
12
|
export { quickjsWasm };
|
|
13
|
+
/**
|
|
14
|
+
* The quickjs-wasi package version these embedded binaries came from.
|
|
15
|
+
* Persisted into VM snapshot metadata (engineVersion) and compared on
|
|
16
|
+
* restore — a heap image only restores under the exact WASM build that
|
|
17
|
+
* produced it (the QJSS header does not distinguish builds).
|
|
18
|
+
*/
|
|
19
|
+
export declare const quickjsWasiVersion = "3.4.0";
|
|
13
20
|
export declare const quickjsExtensions: ExtensionDescriptor[];
|
|
14
21
|
//# sourceMappingURL=quickjs-assets.generated.d.ts.map
|
|
@@ -32,36 +32,8 @@ import { type Event, type RunInput, type WorkflowRun } from '#compiled/@workflow
|
|
|
32
32
|
* Exported for unit testing.
|
|
33
33
|
*/
|
|
34
34
|
export declare function isFirstInvocation(preloadedEvents: readonly Event[] | undefined): boolean;
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
*
|
|
38
|
-
* This replaces the `node:vm` replay path (runWorkflow + EventsConsumer)
|
|
39
|
-
* with a QuickJS VM invocation that performs the same full event replay.
|
|
40
|
-
*
|
|
41
|
-
* Log position on writes. This engine follows the same rule as the node:vm
|
|
42
|
-
* replay loop for which writes tell the World where the writer stood (see the
|
|
43
|
-
* "Who names a position" table above `slotSnapshotParams` in `helpers.ts`):
|
|
44
|
-
*
|
|
45
|
-
* - Writes made from this invocation's view of the log (`step_created`,
|
|
46
|
-
* `wait_created`, `hook_created`, `hook_disposed`, `attr_set`, the abort
|
|
47
|
-
* `hook_received`, `wait_completed`, and the `step_created` + `step_failed`
|
|
48
|
-
* pair for an unserializable input) carry `eventCount`, and the page a
|
|
49
|
-
* World hands back is queued for the live VM through {@link QuickJSLogView}.
|
|
50
|
-
* - A single inline step's terminal write asks for the inline delta
|
|
51
|
-
* (`sinceCursor`) through `executeStep`, and so does a lone `hook_created`
|
|
52
|
-
* (see `dispatchPendingOps.deltaCursor`); the delta is queued the same
|
|
53
|
-
* way. The step executor's other writes carry nothing: it holds no log.
|
|
54
|
-
* - Run-terminal writes (`run_completed`, `run_failed`) and the terminal drain
|
|
55
|
-
* of pending ops carry nothing: nothing reads the log afterwards.
|
|
56
|
-
*
|
|
57
|
-
* What differs from the node engine is what "merge into the log" means. The
|
|
58
|
-
* node engine merges a returned page into the array it replays from. This
|
|
59
|
-
* engine holds a live VM that consumes events exactly once, in position
|
|
60
|
-
* order, so a returned page is queued and delivered ahead of the next
|
|
61
|
-
* `events.list`, which then only runs when the queue cannot account for the
|
|
62
|
-
* next position. Both engines fall back to a list for anything a page did
|
|
63
|
-
* not carry.
|
|
64
|
-
*/
|
|
35
|
+
/** Test-only: forget the process-local snapshot latches. */
|
|
36
|
+
export declare function __resetSnapshotLatchesForTests(): void;
|
|
65
37
|
export declare function runWorkflowWithQuickJS(params: {
|
|
66
38
|
workflowCode: string;
|
|
67
39
|
workflowName: string;
|
|
@@ -22,7 +22,9 @@ import { type Event } from '#compiled/@workflow/world/index.js';
|
|
|
22
22
|
* as they arrive and a later replay will read the log in position order;
|
|
23
23
|
* feeding position 13 before 12 exists would let the two disagree.
|
|
24
24
|
* - `cursor`, the read position for `events.list`, advanced by list pages and
|
|
25
|
-
* by a complete inline delta.
|
|
25
|
+
* by a complete inline delta. Alongside it, how many events of the log the
|
|
26
|
+
* cursor covers, when known: VM snapshots persist the pair, and a restore
|
|
27
|
+
* adds only the events listed after the cursor to that count.
|
|
26
28
|
*
|
|
27
29
|
* Only PAGES are queued for delivery, never the created event a write returns
|
|
28
30
|
* on its own. A World reads a report or a delta the way it reads a listing,
|
|
@@ -48,7 +50,24 @@ export declare class QuickJSLogView {
|
|
|
48
50
|
/** Events handed back by a World that the VM has not been given yet. */
|
|
49
51
|
private readonly unfed;
|
|
50
52
|
private cursor;
|
|
51
|
-
|
|
53
|
+
private cursorPosition;
|
|
54
|
+
/**
|
|
55
|
+
* @param cursorPosition How many events of the log `cursor` covers, when
|
|
56
|
+
* the caller knows (see {@link eventsThroughCursor}).
|
|
57
|
+
*/
|
|
58
|
+
constructor(fedEvents: readonly Event[], cursor: string | null, cursorPosition?: number);
|
|
59
|
+
/**
|
|
60
|
+
* How many events of the log the read cursor covers (every event at or
|
|
61
|
+
* before it), or `undefined` once that is no longer known. A VM snapshot
|
|
62
|
+
* saves this with the cursor, and the restore adds the events listed
|
|
63
|
+
* after the cursor, so it must count exactly the events the cursor
|
|
64
|
+
* covers, however they reached the VM.
|
|
65
|
+
*/
|
|
66
|
+
get eventsThroughCursor(): number | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Reset the read position, e.g. after re-reading the whole log.
|
|
69
|
+
*/
|
|
70
|
+
setPosition(cursor: string | null, eventsThroughCursor: number): void;
|
|
52
71
|
/** Read position for the next `events.list`, or `null` for the start. */
|
|
53
72
|
get logCursor(): string | null;
|
|
54
73
|
/** How many events are queued for delivery to the VM. */
|
|
@@ -62,8 +81,12 @@ export declare class QuickJSLogView {
|
|
|
62
81
|
snapshotParams(): {
|
|
63
82
|
eventCount?: number;
|
|
64
83
|
};
|
|
65
|
-
/**
|
|
66
|
-
|
|
84
|
+
/**
|
|
85
|
+
* `events.list` (or an inline delta) was read from the current cursor to
|
|
86
|
+
* `cursor`, returning `eventsRead` events. Without `eventsRead` the
|
|
87
|
+
* position the cursor covers is no longer known.
|
|
88
|
+
*/
|
|
89
|
+
advanceCursor(cursor: string | null, eventsRead?: number): void;
|
|
67
90
|
/**
|
|
68
91
|
* Events delivered to the VM by the caller (the initial load, or an
|
|
69
92
|
* `events.list` page). Removes them from the delivery queue if a write
|