eve 0.8.3 → 0.8.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/dist/src/chunks/{use-eve-agent-Dlut2Qzt.js → use-eve-agent-CdETo3qQ.js} +1 -0
- package/dist/src/chunks/{use-eve-agent-BSXZSn-R.js → use-eve-agent-ClyM-_UT.js} +1 -0
- package/dist/src/cli/banner.d.ts +2 -2
- package/dist/src/cli/banner.js +1 -1
- package/dist/src/cli/dev/tui/agent-header.d.ts +1 -1
- package/dist/src/cli/dev/tui/agent-header.js +1 -1
- package/dist/src/cli/dev/tui/log-display-mode.d.ts +13 -0
- package/dist/src/cli/dev/tui/log-display-mode.js +1 -0
- package/dist/src/cli/dev/tui/prompt-commands.js +1 -1
- package/dist/src/cli/dev/tui/runner.js +1 -1
- package/dist/src/cli/dev/tui/status-line.d.ts +13 -4
- package/dist/src/cli/dev/tui/status-line.js +1 -1
- package/dist/src/cli/dev/tui/stream-format.d.ts +1 -2
- package/dist/src/cli/dev/tui/stream-format.js +1 -1
- package/dist/src/cli/dev/tui/terminal-renderer.js +6 -6
- package/dist/src/cli/dev/tui/theme.d.ts +0 -2
- package/dist/src/cli/dev/tui/theme.js +1 -1
- package/dist/src/cli/dev/tui/types.d.ts +8 -11
- package/dist/src/cli/run.js +2 -2
- package/dist/src/execution/sandbox/bindings/docker-base-setup.d.ts +3 -5
- package/dist/src/execution/sandbox/bindings/docker-base-setup.js +1 -1
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.d.ts +2 -3
- package/dist/src/execution/sandbox/bindings/microsandbox-platform.js +3 -160
- package/dist/src/execution/sandbox/development-prewarm.js +1 -1
- package/dist/src/execution/sandbox/ensure.js +1 -1
- package/dist/src/execution/sandbox/prewarm.d.ts +4 -0
- package/dist/src/execution/sandbox/prewarm.js +2 -1
- package/dist/src/execution/sandbox/template-prewarm-lock.js +1 -1
- package/dist/src/harness/emission.js +1 -1
- package/dist/src/harness/runtime-actions.d.ts +10 -0
- package/dist/src/harness/runtime-actions.js +1 -1
- package/dist/src/internal/application/package.js +1 -1
- package/dist/src/internal/nitro/host/configure-nitro-routes.js +2 -2
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.d.ts +1 -0
- package/dist/src/internal/nitro/host/dev-authored-source-watcher.js +1 -1
- package/dist/src/internal/nitro/host/dev-rebuild-registry.d.ts +5 -0
- package/dist/src/internal/nitro/host/dev-rebuild-registry.js +1 -0
- package/dist/src/internal/nitro/routes/dev-runtime-artifacts.d.ts +3 -0
- package/dist/src/internal/nitro/routes/dev-runtime-artifacts.js +1 -1
- package/dist/src/protocol/routes.d.ts +5 -0
- package/dist/src/protocol/routes.js +1 -1
- package/dist/src/public/sandbox/docker-sandbox.d.ts +3 -3
- package/dist/src/public/sandbox/microsandbox-sandbox.d.ts +4 -4
- package/dist/src/services/dev-client/runtime-artifacts.d.ts +3 -0
- package/dist/src/services/dev-client/runtime-artifacts.js +1 -1
- package/dist/src/services/dev-client.js +1 -1
- package/dist/src/setup/scaffold/create/add-to-project.js +1 -1
- package/dist/src/setup/scaffold/create/project.js +2 -2
- package/dist/src/setup/scaffold/update/channels.js +1 -1
- package/dist/src/svelte/index.js +1 -1
- package/dist/src/svelte/use-eve-agent.js +1 -1
- package/dist/src/vue/index.js +1 -1
- package/dist/src/vue/use-eve-agent.js +1 -1
- package/docs/guides/dev-tui.md +4 -4
- package/docs/reference/cli.md +1 -1
- package/docs/sandbox.mdx +2 -2
- package/package.json +2 -1
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* One-time setup applied to containers created from the raw base image
|
|
3
|
-
* (template builds and template-less sessions).
|
|
4
|
-
*
|
|
5
|
-
* `bash`
|
|
6
|
-
* parity with the Vercel backend), installs/verifies Node 24/npm,
|
|
7
|
-
* installs/verifies Python 3, and best-effort installs `ripgrep`.
|
|
3
|
+
* (template builds and template-less sessions). Keeps the framework-owned
|
|
4
|
+
* base layer deliberately tiny: create `/workspace` and verify Bash,
|
|
5
|
+
* because the sandbox `bash` tool and command execution depend on it.
|
|
8
6
|
*/
|
|
9
7
|
export declare function buildDockerBaseSetupScript(): string;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";function buildDockerBaseSetupScript(){return[`set -e`,`mkdir -p ${WORKSPACE_ROOT}`,`
|
|
1
|
+
import{WORKSPACE_ROOT}from"#runtime/workspace/types.js";function buildDockerBaseSetupScript(){return[`set -e`,`mkdir -p ${WORKSPACE_ROOT}`,`command -v bash >/dev/null 2>&1 || { echo "the sandbox image must provide bash" >&2; exit 70; }`].join(`
|
|
2
2
|
`)}export{buildDockerBaseSetupScript};
|
|
@@ -13,9 +13,8 @@ export declare function isMicrosandboxPlatformSupported(): boolean;
|
|
|
13
13
|
export declare function assertMicrosandboxPlatformCandidate(): Promise<void>;
|
|
14
14
|
/**
|
|
15
15
|
* One-time setup applied to sandboxes created from the raw base image:
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* it `/workspace` — mirroring the hosted Vercel Sandbox runtime.
|
|
16
|
+
* verifies Bash, creates the `vercel-sandbox` user, and hands it
|
|
17
|
+
* `/workspace`.
|
|
19
18
|
*/
|
|
20
19
|
export declare function ensureMicrosandboxBaseRuntime(sandbox: MicrosandboxSandbox, options?: {
|
|
21
20
|
readonly log?: (message: string) => void;
|
|
@@ -5,173 +5,16 @@ log_step() {
|
|
|
5
5
|
printf 'eve-base-runtime: %s\\n' "$*" >&2
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if [ "\${#packages[@]}" -eq 0 ]; then
|
|
11
|
-
return
|
|
12
|
-
fi
|
|
13
|
-
|
|
14
|
-
if command -v dnf >/dev/null 2>&1; then
|
|
15
|
-
log_step "dnf install: \${packages[*]}"
|
|
16
|
-
dnf install -y "\${packages[@]}"
|
|
17
|
-
return
|
|
18
|
-
fi
|
|
19
|
-
|
|
20
|
-
if command -v microdnf >/dev/null 2>&1; then
|
|
21
|
-
log_step "microdnf install: \${packages[*]}"
|
|
22
|
-
microdnf install -y "\${packages[@]}"
|
|
23
|
-
return
|
|
24
|
-
fi
|
|
25
|
-
|
|
26
|
-
if command -v apt-get >/dev/null 2>&1; then
|
|
27
|
-
export DEBIAN_FRONTEND=noninteractive
|
|
28
|
-
log_step "apt-get update"
|
|
29
|
-
apt-get update
|
|
30
|
-
log_step "apt-get install: \${packages[*]}"
|
|
31
|
-
apt-get install -y --no-install-recommends "\${packages[@]}"
|
|
32
|
-
return
|
|
33
|
-
fi
|
|
34
|
-
|
|
35
|
-
if command -v apk >/dev/null 2>&1; then
|
|
36
|
-
log_step "apk add: \${packages[*]}"
|
|
37
|
-
apk add --no-cache "\${packages[@]}"
|
|
38
|
-
return
|
|
39
|
-
fi
|
|
40
|
-
|
|
41
|
-
echo "No supported package manager found for installing: \${packages[*]}" >&2
|
|
42
|
-
return 1
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
install_nodejs24() {
|
|
46
|
-
log_step "checking Node.js 24"
|
|
47
|
-
if command -v node >/dev/null 2>&1 && node --version | grep -q '^v24\\.'; then
|
|
48
|
-
log_step "Node.js 24 already installed"
|
|
49
|
-
return
|
|
50
|
-
fi
|
|
51
|
-
|
|
52
|
-
if command -v apt-get >/dev/null 2>&1; then
|
|
53
|
-
export DEBIAN_FRONTEND=noninteractive
|
|
54
|
-
log_step "apt-get update for Node.js prerequisites"
|
|
55
|
-
apt-get update
|
|
56
|
-
log_step "apt-get install: ca-certificates curl gnupg"
|
|
57
|
-
apt-get install -y --no-install-recommends ca-certificates curl gnupg
|
|
58
|
-
log_step "download NodeSource signing key"
|
|
59
|
-
mkdir -p /etc/apt/keyrings
|
|
60
|
-
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
|
|
61
|
-
log_step "configure NodeSource Node.js 24 repository"
|
|
62
|
-
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_24.x nodistro main" > /etc/apt/sources.list.d/nodesource.list
|
|
63
|
-
log_step "apt-get update for Node.js 24"
|
|
64
|
-
apt-get update
|
|
65
|
-
log_step "apt-get install: nodejs"
|
|
66
|
-
apt-get install -y --no-install-recommends nodejs
|
|
67
|
-
return
|
|
68
|
-
fi
|
|
69
|
-
|
|
70
|
-
log_step "install Node.js 24 packages"
|
|
71
|
-
install_packages nodejs24 nodejs24-npm || install_packages nodejs24 || install_packages nodejs npm
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
install_missing_packages() {
|
|
75
|
-
log_step "checking base packages"
|
|
76
|
-
local packages=()
|
|
77
|
-
|
|
78
|
-
if command -v apt-get >/dev/null 2>&1; then
|
|
79
|
-
command -v sudo >/dev/null 2>&1 || packages+=(sudo)
|
|
80
|
-
command -v git >/dev/null 2>&1 || packages+=(git)
|
|
81
|
-
command -v find >/dev/null 2>&1 || packages+=(findutils)
|
|
82
|
-
command -v gzip >/dev/null 2>&1 || packages+=(gzip)
|
|
83
|
-
command -v tar >/dev/null 2>&1 || packages+=(tar)
|
|
84
|
-
command -v unzip >/dev/null 2>&1 || packages+=(unzip)
|
|
85
|
-
command -v which >/dev/null 2>&1 || packages+=(debianutils)
|
|
86
|
-
command -v ps >/dev/null 2>&1 || packages+=(procps)
|
|
87
|
-
command -v openssl >/dev/null 2>&1 || packages+=(openssl)
|
|
88
|
-
command -v zstd >/dev/null 2>&1 || packages+=(zstd)
|
|
89
|
-
command -v useradd >/dev/null 2>&1 || packages+=(passwd)
|
|
90
|
-
[ -e /etc/ssl/certs/ca-certificates.crt ] || packages+=(ca-certificates)
|
|
91
|
-
elif command -v apk >/dev/null 2>&1; then
|
|
92
|
-
command -v sudo >/dev/null 2>&1 || packages+=(sudo)
|
|
93
|
-
command -v git >/dev/null 2>&1 || packages+=(git)
|
|
94
|
-
command -v find >/dev/null 2>&1 || packages+=(findutils)
|
|
95
|
-
command -v gzip >/dev/null 2>&1 || packages+=(gzip)
|
|
96
|
-
command -v tar >/dev/null 2>&1 || packages+=(tar)
|
|
97
|
-
command -v unzip >/dev/null 2>&1 || packages+=(unzip)
|
|
98
|
-
command -v which >/dev/null 2>&1 || packages+=(which)
|
|
99
|
-
command -v ps >/dev/null 2>&1 || packages+=(procps)
|
|
100
|
-
command -v openssl >/dev/null 2>&1 || packages+=(openssl)
|
|
101
|
-
command -v zstd >/dev/null 2>&1 || packages+=(zstd)
|
|
102
|
-
command -v useradd >/dev/null 2>&1 || packages+=(shadow)
|
|
103
|
-
[ -e /etc/ssl/certs/ca-certificates.crt ] || packages+=(ca-certificates)
|
|
104
|
-
else
|
|
105
|
-
command -v sudo >/dev/null 2>&1 || packages+=(sudo)
|
|
106
|
-
command -v git >/dev/null 2>&1 || packages+=(git)
|
|
107
|
-
command -v find >/dev/null 2>&1 || packages+=(findutils)
|
|
108
|
-
command -v gzip >/dev/null 2>&1 || packages+=(gzip)
|
|
109
|
-
command -v tar >/dev/null 2>&1 || packages+=(tar)
|
|
110
|
-
command -v unzip >/dev/null 2>&1 || packages+=(unzip)
|
|
111
|
-
command -v which >/dev/null 2>&1 || packages+=(which)
|
|
112
|
-
command -v ps >/dev/null 2>&1 || packages+=(procps-ng)
|
|
113
|
-
command -v openssl >/dev/null 2>&1 || packages+=(openssl)
|
|
114
|
-
command -v zstd >/dev/null 2>&1 || packages+=(zstd)
|
|
115
|
-
command -v useradd >/dev/null 2>&1 || packages+=(shadow-utils)
|
|
116
|
-
fi
|
|
117
|
-
|
|
118
|
-
install_packages "\${packages[@]}"
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
install_missing_packages
|
|
122
|
-
|
|
123
|
-
install_nodejs24
|
|
124
|
-
|
|
125
|
-
log_step "checking node binary"
|
|
126
|
-
if ! command -v node >/dev/null 2>&1; then
|
|
127
|
-
for candidate in /usr/bin/node-24 /usr/bin/node24 /usr/bin/nodejs24 /usr/bin/nodejs; do
|
|
128
|
-
if [ -x "$candidate" ]; then
|
|
129
|
-
log_step "link node binary: $candidate"
|
|
130
|
-
ln -sf "$candidate" /usr/local/bin/node
|
|
131
|
-
break
|
|
132
|
-
fi
|
|
133
|
-
done
|
|
134
|
-
fi
|
|
135
|
-
|
|
136
|
-
log_step "checking npm binary"
|
|
137
|
-
if ! command -v npm >/dev/null 2>&1; then
|
|
138
|
-
for candidate in /usr/bin/npm-24 /usr/bin/npm24 /usr/bin/npm; do
|
|
139
|
-
if [ -x "$candidate" ]; then
|
|
140
|
-
log_step "link npm binary: $candidate"
|
|
141
|
-
ln -sf "$candidate" /usr/local/bin/npm
|
|
142
|
-
break
|
|
143
|
-
fi
|
|
144
|
-
done
|
|
145
|
-
fi
|
|
146
|
-
|
|
147
|
-
log_step "verifying Node.js and npm"
|
|
148
|
-
command -v node >/dev/null 2>&1
|
|
149
|
-
node --version | grep -q '^v24\\.'
|
|
150
|
-
command -v npm >/dev/null 2>&1
|
|
151
|
-
|
|
152
|
-
log_step "checking pnpm"
|
|
153
|
-
if ! command -v pnpm >/dev/null 2>&1; then
|
|
154
|
-
log_step "npm install -g pnpm"
|
|
155
|
-
npm install -g pnpm
|
|
156
|
-
fi
|
|
157
|
-
|
|
158
|
-
log_step "checking ripgrep"
|
|
159
|
-
if ! command -v rg >/dev/null 2>&1; then
|
|
160
|
-
log_step "install ripgrep"
|
|
161
|
-
install_packages ripgrep || { install_packages spal-release && install_packages ripgrep; }
|
|
162
|
-
fi
|
|
8
|
+
log_step "checking bash"
|
|
9
|
+
command -v bash >/dev/null 2>&1
|
|
163
10
|
|
|
164
11
|
log_step "checking sandbox user"
|
|
165
12
|
if ! id -u ${MICROSANDBOX_USER} >/dev/null 2>&1; then
|
|
13
|
+
command -v useradd >/dev/null 2>&1
|
|
166
14
|
log_step "create sandbox user: ${MICROSANDBOX_USER}"
|
|
167
15
|
useradd -m -s /bin/bash ${MICROSANDBOX_USER}
|
|
168
16
|
fi
|
|
169
17
|
|
|
170
|
-
log_step "configure passwordless sudo for ${MICROSANDBOX_USER}"
|
|
171
|
-
mkdir -p /etc/sudoers.d
|
|
172
|
-
printf '${MICROSANDBOX_USER} ALL=(ALL) NOPASSWD:ALL\\n' > /etc/sudoers.d/${MICROSANDBOX_USER}
|
|
173
|
-
chmod 0440 /etc/sudoers.d/${MICROSANDBOX_USER}
|
|
174
|
-
|
|
175
18
|
log_step "prepare workspace directory: ${WORKSPACE_ROOT}"
|
|
176
19
|
mkdir -p ${WORKSPACE_ROOT}
|
|
177
20
|
chown ${MICROSANDBOX_USER}:${MICROSANDBOX_USER} ${WORKSPACE_ROOT}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{prewarmAppSandboxes}from"./prewarm.js";import{toErrorMessage}from"#shared/errors.js";import{getRuntimeCompiledArtifactsAppRoot,getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";const pendingDevelopmentPrewarms=new Map,retainedDevelopmentPrewarmLogs=new Map;function startDevelopmentSandboxPrewarmInBackground(n){let r=resolvePrewarmKeys(n),o=findPendingPrewarm(r);if(o!==void 0){registerPrewarmAliases(r,o);return}let s={logs:[],promise:Promise.resolve(),subscribers:new Set};for(let e of r)retainedDevelopmentPrewarmLogs.delete(e);
|
|
1
|
+
import{prewarmAppSandboxes}from"./prewarm.js";import{toErrorMessage}from"#shared/errors.js";import{getRuntimeCompiledArtifactsAppRoot,getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";const pendingDevelopmentPrewarms=new Map,retainedDevelopmentPrewarmLogs=new Map,completedDevelopmentPrewarmSignatures=new Map;function startDevelopmentSandboxPrewarmInBackground(n){let r=resolvePrewarmKeys(n),o=findPendingPrewarm(r);if(o!==void 0){registerPrewarmAliases(r,o);return}let s={logs:[],promise:Promise.resolve(),subscribers:new Set};for(let e of r)retainedDevelopmentPrewarmLogs.delete(e);let c=resolvePrewarmSignatureCacheKey(n),l=prewarmAppSandboxes({appRoot:n.appRoot,compiledArtifactsSource:n.compiledArtifactsSource,log:e=>recordPrewarmLog(s,e,n.log),onPrewarmSignature:e=>{completedDevelopmentPrewarmSignatures.set(c,e)},shouldPrewarmSignature:e=>completedDevelopmentPrewarmSignatures.get(c)!==e});s.promise=l,registerPrewarmAliases(r,s),l.catch(e=>{recordPrewarmLog(s,`Eve: failed to initialize sandbox templates in the background: ${toErrorMessage(e)}`,n.log)}).finally(()=>{for(let e of r)pendingDevelopmentPrewarms.get(e)===s&&pendingDevelopmentPrewarms.delete(e),s.subscribers.size===0&&s.logs.length>0&&retainedDevelopmentPrewarmLogs.set(e,[...s.logs])})}function subscribeDevelopmentSandboxPrewarmLogs(e){let t=findPendingPrewarm([e.appRoot]);if(t!==void 0){for(let n of t.logs)e.log(n);return t.subscribers.add(e.log),()=>t.subscribers.delete(e.log)}let n=retainedDevelopmentPrewarmLogs.get(e.appRoot);if(n===void 0)return()=>{};retainedDevelopmentPrewarmLogs.delete(e.appRoot);for(let t of n)e.log(t);return()=>{}}async function waitForDevelopmentSandboxPrewarm(e){let t=findPendingPrewarm(resolvePrewarmKeys(e));if(t===void 0)return;let unsubscribe;if(e.log!==void 0){for(let n of t.logs)e.log(n);let subscriber=t=>e.log?.(t);t.subscribers.add(subscriber),unsubscribe=()=>t.subscribers.delete(subscriber)}try{await withProgressHeartbeat(`waiting for background sandbox template prewarm`,e.log,()=>t.promise)}finally{unsubscribe?.()}}function resolvePrewarmKeys(e){let t=new Set([e.appRoot]),i=getRuntimeCompiledArtifactsAppRoot(e.compiledArtifactsSource);i!==void 0&&t.add(i);let a=getRuntimeCompiledArtifactsSandboxAppRoot(e.compiledArtifactsSource);return a!==void 0&&t.add(a),[...t]}function resolvePrewarmSignatureCacheKey(e){return getRuntimeCompiledArtifactsSandboxAppRoot(e.compiledArtifactsSource)??e.appRoot}function findPendingPrewarm(e){for(let t of e){let e=pendingDevelopmentPrewarms.get(t);if(e!==void 0)return e}}function registerPrewarmAliases(e,t){for(let n of e)pendingDevelopmentPrewarms.set(n,t)}function recordPrewarmLog(e,t,n){e.logs.push(t),e.logs.length>50&&e.logs.splice(0,e.logs.length-50),n?.(t);for(let n of e.subscribers)n(t)}async function withProgressHeartbeat(e,t,n){if(t===void 0)return await n();let r=Date.now(),i=setInterval(()=>{t(`${e} (${Math.round((Date.now()-r)/1e3)}s elapsed)`)},1e4);i.unref?.();try{return await n()}finally{clearInterval(i)}}export{startDevelopmentSandboxPrewarmInBackground,subscribeDevelopmentSandboxPrewarmLogs,waitForDevelopmentSandboxPrewarm};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{waitForDevelopmentSandboxPrewarm}from"#execution/sandbox/development-prewarm.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{isEveDevEnvironment}from"#internal/application/optional-package-install.js";import{markDevelopmentSandboxBackendInitialized}from"#execution/sandbox/development-run.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{createRuntimeSandboxKeys}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{waitForSandboxTemplatePrewarmLock}from"#execution/sandbox/template-prewarm-lock.js";async function ensureSandboxAccess(n){let i=n.state?.initialized??!1,o=n.state?.session??null,s=getRuntimeCompiledArtifactsSandboxAppRoot(n.compiledArtifactsSource)??process.cwd(),c=n.registry.sandbox,l;function getHandle(){return l===void 0&&(l=createHandle().catch(e=>{throw l=void 0,e})),l}async function createHandle(){if(c===null)return null;let a=c.definition,l=a.backend,u=createRuntimeSandboxTemplatePlan({definition:a,workspaceResourceRoot:c.workspaceResourceRoot}),d=await createRuntimeSandboxKeys({backendName:l.name,compiledArtifactsSource:n.compiledArtifactsSource,nodeId:n.nodeId,sessionId:n.sessionId,sourceId:a.sourceId,templatePlan:u});d.templateKey!==null&&(
|
|
1
|
+
import{waitForDevelopmentSandboxPrewarm}from"#execution/sandbox/development-prewarm.js";import{buildCallbackContext}from"#context/build-callback-context.js";import{isEveDevEnvironment}from"#internal/application/optional-package-install.js";import{markDevelopmentSandboxBackendInitialized}from"#execution/sandbox/development-run.js";import{SandboxTemplateNotProvisionedError}from"#public/definitions/sandbox-backend.js";import{getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{createRuntimeSandboxKeys}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{prewarmAppSandboxes}from"#execution/sandbox/prewarm.js";import{waitForSandboxTemplatePrewarmLock}from"#execution/sandbox/template-prewarm-lock.js";async function ensureSandboxAccess(n){let i=n.state?.initialized??!1,o=n.state?.session??null,s=getRuntimeCompiledArtifactsSandboxAppRoot(n.compiledArtifactsSource)??process.cwd(),c=n.registry.sandbox,l;function getHandle(){return l===void 0&&(l=createHandle().catch(e=>{throw l=void 0,e})),l}async function createHandle(){if(c===null)return null;let a=c.definition,l=a.backend,u=createRuntimeSandboxTemplatePlan({definition:a,workspaceResourceRoot:c.workspaceResourceRoot}),d=await createRuntimeSandboxKeys({backendName:l.name,compiledArtifactsSource:n.compiledArtifactsSource,nodeId:n.nodeId,sessionId:n.sessionId,sourceId:a.sourceId,templatePlan:u});d.templateKey!==null&&(await waitForDevelopmentSandboxPrewarm({appRoot:s,compiledArtifactsSource:n.compiledArtifactsSource,log:e=>logDevelopmentSandbox(`Eve: sandbox template "${formatNodeLabel(n.nodeId)}" (${l.name}): ${e}`)}),await waitForSandboxTemplatePrewarmLock({appRoot:s,backendName:l.name,log:e=>logDevelopmentSandbox(`Eve: sandbox template "${formatNodeLabel(n.nodeId)}" (${l.name}): ${e}`),templateKey:d.templateKey}));let f={existingMetadata:o?.backendName===l.name&&o.sessionKey===d.sessionKey?o.metadata:void 0,runtimeContext:{appRoot:s},sessionKey:d.sessionKey,tags:n.tags,templateKey:d.templateKey},p=await withDevelopmentSandboxProgress(`Eve: opening sandbox session "${formatNodeLabel(n.nodeId)}" on backend "${l.name}"...`,`Eve: opening sandbox session "${formatNodeLabel(n.nodeId)}" on backend "${l.name}"`,async()=>await createBackendHandleWithPrewarmRetry({appRoot:s,backend:l,compiledArtifactsSource:n.compiledArtifactsSource,createInput:f}));return markDevelopmentSandboxBackendInitialized(l.name),i||=(await runOnSession(async()=>{await a.onSession?.({ctx:buildCallbackContext(),use:p.useSessionFn})}),!0),p}async function runOnSession(e){if(n.runOnSession!==void 0){await n.runOnSession(e);return}await e()}return{async captureState(){if(l!==void 0){let e=await l;e!==null&&(o=await e.captureState())}return{initialized:i,session:o}},async dispose(){l!==void 0&&await(await l)?.dispose()},async get(){return(await getHandle())?.session??null}}}async function createBackendHandleWithPrewarmRetry(e){try{return await e.backend.create(e.createInput)}catch(t){if(e.createInput.templateKey===null||e.compiledArtifactsSource.kind!==`disk`||!SandboxTemplateNotProvisionedError.is(t))throw t;return await prewarmAppSandboxes({appRoot:e.appRoot,compiledArtifactsSource:e.compiledArtifactsSource,log:e=>logDevelopmentSandbox(e)}),await waitForSandboxTemplatePrewarmLock({appRoot:e.appRoot,backendName:e.backend.name,log:e=>logDevelopmentSandbox(`Eve: ${e}`),templateKey:e.createInput.templateKey}),logDevelopmentSandbox(`Eve: sandbox template is ready; retrying sandbox creation...`),await e.backend.create(e.createInput)}}function logDevelopmentSandbox(e){isEveDevEnvironment()&&console.log(e)}async function withDevelopmentSandboxProgress(e,t,r){if(logDevelopmentSandbox(e),!isEveDevEnvironment())return await r();let i=Date.now(),a=setInterval(()=>{logDevelopmentSandbox(`${t} (${Math.round((Date.now()-i)/1e3)}s elapsed)...`)},5e3);a.unref?.();try{return await r()}finally{clearInterval(a)}}function formatNodeLabel(e){return e===`__root__`?`root`:e}export{ensureSandboxAccess};
|
|
@@ -18,6 +18,8 @@ interface PrewarmSandboxesInput {
|
|
|
18
18
|
readonly graph: ResolvedAgentGraphBundle;
|
|
19
19
|
readonly log?: (message: string) => void;
|
|
20
20
|
readonly dispatch?: SandboxBackendPrewarmDispatch;
|
|
21
|
+
readonly onPrewarmSignature?: (signature: string) => void;
|
|
22
|
+
readonly shouldPrewarmSignature?: (signature: string) => boolean;
|
|
21
23
|
}
|
|
22
24
|
/**
|
|
23
25
|
* Prewarms every backend sandbox template required by one compiled
|
|
@@ -44,6 +46,8 @@ export declare function prewarmAppSandboxes(input: {
|
|
|
44
46
|
}>) => Promise<ResolvedAgentGraphBundle>;
|
|
45
47
|
readonly log?: (message: string) => void;
|
|
46
48
|
readonly dispatch?: SandboxBackendPrewarmDispatch;
|
|
49
|
+
readonly onPrewarmSignature?: (signature: string) => void;
|
|
50
|
+
readonly shouldPrewarmSignature?: (signature: string) => boolean;
|
|
47
51
|
}): Promise<void>;
|
|
48
52
|
/**
|
|
49
53
|
* Loads one built app's bundled compiled artifacts and prewarms the sandbox
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
import{withSandboxTemplatePrewarmLock}from"./template-prewarm-lock.js";import{toErrorMessage}from"#shared/errors.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{createBundledRuntimeCompiledArtifactsSource,getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{loadCompiledModuleMapFromAuthoredSource}from"#internal/authored-module-map-loader.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{loadCompileMetadata}from"#runtime/loaders/compile-metadata.js";import{withBundledCompiledArtifacts}from"#runtime/loaders/bundled-artifacts.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{resolveRuntimeAgentGraph}from"#runtime/resolve-agent-graph.js";import{createRuntimeSandboxTemplateKey}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{materializeWorkspaceDirectory}from"#runtime/workspace/seed-files.js";async function prewarmSandboxes(n){let r=await collectPrewarmTargets(n);if(r.length===0)return;n.
|
|
1
|
+
import{withSandboxTemplatePrewarmLock}from"./template-prewarm-lock.js";import{toErrorMessage}from"#shared/errors.js";import{ROOT_RUNTIME_AGENT_NODE_ID}from"#runtime/graph.js";import{createBundledRuntimeCompiledArtifactsSource,getRuntimeCompiledArtifactsSandboxAppRoot}from"#runtime/compiled-artifacts-source.js";import{loadCompiledModuleMapFromAuthoredSource}from"#internal/authored-module-map-loader.js";import{createAuthoredSourceRuntimeCompiledArtifactsSource}from"#internal/application/runtime-compiled-artifacts-source.js";import{loadCompileMetadata}from"#runtime/loaders/compile-metadata.js";import{withBundledCompiledArtifacts}from"#runtime/loaders/bundled-artifacts.js";import{loadCompiledManifest}from"#runtime/loaders/manifest.js";import{resolveRuntimeCompilerArtifactPaths}from"#runtime/loaders/artifact-paths.js";import{resolveRuntimeAgentGraph}from"#runtime/resolve-agent-graph.js";import{createRuntimeSandboxTemplateKey}from"#runtime/sandbox/keys.js";import{createRuntimeSandboxTemplatePlan}from"#runtime/sandbox/template-plan.js";import{materializeWorkspaceDirectory}from"#runtime/workspace/seed-files.js";async function prewarmSandboxes(n){let r=await collectPrewarmTargets(n);if(r.length===0)return;let i=createPrewarmSignature(r);if(n.shouldPrewarmSignature?.(i)===!1)return;let a=n.dispatch??(async({backend:e,input:t})=>await e.prewarm(t));n.log?.(`Eve: initializing ${formatSandboxTemplateCount(r.length)}...`);let o=(await Promise.all(r.map(async({backend:r,label:i,input:o})=>{let logBackendProgress=e=>{shouldLogSandboxPrewarmProgress(e)&&n.log?.(`Eve: sandbox template "${i}" (${r.name}): ${e}`)},s;try{s=await withSandboxTemplatePrewarmLock({appRoot:o.runtimeContext.appRoot,backendName:r.name,templateKey:o.templateKey},async()=>await a({backend:r,input:{...o,log:n.log===void 0?void 0:logBackendProgress}}))}catch(e){throw n.log?.(`Eve: failed to initialize sandbox template "${i}" on backend "${r.name}": ${toErrorMessage(e)}`),e}return s}))).filter(e=>e.reused).length;n.log?.(`Eve: initialized ${formatSandboxTemplateCount(r.length)} (${o} reused, ${r.length-o} built).`),n.onPrewarmSignature?.(i)}async function prewarmAppSandboxes(e){let t=e.compiledArtifactsSource??createAuthoredSourceRuntimeCompiledArtifactsSource(e.appRoot);if(t.kind!==`disk`)throw Error(`prewarmAppSandboxes requires disk-backed compiled artifacts.`);let n=await(e.loadAgentGraph??loadGraphFromArtifacts)({compiledArtifactsSource:t});await prewarmSandboxes({appRoot:getRuntimeCompiledArtifactsSandboxAppRoot(t)??e.appRoot,compiledArtifactsSource:t,dispatch:e.dispatch,graph:n,log:e.log,onPrewarmSignature:e.onPrewarmSignature,shouldPrewarmSignature:e.shouldPrewarmSignature})}async function prewarmBuiltAppSandboxes(e){let t=createAuthoredSourceRuntimeCompiledArtifactsSource(e.appRoot),[n,i,l]=await Promise.all([loadCompileMetadata({compiledArtifactsSource:t}),loadCompiledManifest({compiledArtifactsSource:t}),loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:t})]);await withBundledCompiledArtifacts({manifest:i,metadata:n??void 0,moduleMap:l,sessionId:`built-app-prewarm`},async()=>{let t=createBundledRuntimeCompiledArtifactsSource(),n=await resolveRuntimeAgentGraph({manifest:i,moduleMap:l});await prewarmSandboxes({appRoot:e.appRoot,compiledArtifactsSource:t,dispatch:e.dispatch,graph:n,log:e.log})})}async function collectPrewarmTargets(e){let t=resolveRuntimeCompilerArtifactPaths(e.appRoot).compileDirectoryPath,n={appRoot:e.appRoot},r=[];return await Promise.all(collectNodeSandboxes(e.graph).map(async({definition:i,nodeId:a,workspaceResourceRoot:o})=>{let s=createRuntimeSandboxTemplatePlan({definition:i,workspaceResourceRoot:o}),c=await createRuntimeSandboxTemplateKey({backendName:i.backend.name,compiledArtifactsSource:e.compiledArtifactsSource,nodeId:a,sourceId:i.sourceId,templatePlan:s});c!==null&&r.push({backend:i.backend,label:formatLabel(a),input:{bootstrap:i.bootstrap,seedFiles:await loadResourceRootSeedFiles({compileDirectoryPath:t,workspaceResourceRoot:o}),runtimeContext:n,templateKey:c},signature:`${i.backend.name}:${a}:${c}`})})),r.sort((e,t)=>e.label.localeCompare(t.label))}async function loadResourceRootSeedFiles(e){return e.workspaceResourceRoot.rootEntries.length===0?[]:(await materializeWorkspaceDirectory(`${e.compileDirectoryPath}/${e.workspaceResourceRoot.logicalPath}`)).map(e=>({content:e.content,path:e.path}))}async function loadGraphFromArtifacts(e){let[t,n]=await Promise.all([loadCompiledManifest({compiledArtifactsSource:e.compiledArtifactsSource}),loadCompiledModuleMapFromAuthoredSource({compiledArtifactsSource:e.compiledArtifactsSource})]);return await resolveRuntimeAgentGraph({manifest:t,moduleMap:n})}function collectNodeSandboxes(e){return[...e.nodesByNodeId.entries()].flatMap(([e,t])=>{let n=t.sandboxRegistry.sandbox;return n===null?[]:[{...n,nodeId:e}]})}function formatLabel(e){return e===ROOT_RUNTIME_AGENT_NODE_ID?`root`:e}function createPrewarmSignature(e){return e.map(e=>e.signature).sort().join(`
|
|
2
|
+
`)}function formatSandboxTemplateCount(e){return`${e} sandbox ${e===1?`template`:`templates`}`}function shouldLogSandboxPrewarmProgress(e){return!e.startsWith(`checking `)&&!e.startsWith(`reusing `)&&e!==`loading microsandbox runtime`&&e!==`microsandbox runtime ready`}export{prewarmAppSandboxes,prewarmBuiltAppSandboxes,prewarmSandboxes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname,join}from"node:path";import{mkdir,rm,stat,writeFile}from"node:fs/promises";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";const LOCK_TIMEOUT_MS=900*1e3;async function waitForSandboxTemplatePrewarmLock(e){await waitForLockRelease(resolveSandboxTemplatePrewarmLockPath(e),e.log)}async function withSandboxTemplatePrewarmLock(e,t){let n=resolveSandboxTemplatePrewarmLockPath(e);await acquireLock(n);try{return await t()}finally{await rm(n,{force:!0,recursive:!0}).catch(()=>{})}}function resolveSandboxTemplatePrewarmLockPath(e){return join(resolveSandboxCacheDirectory(e.appRoot),`template-locks`,e.backendName,`${e.templateKey}.lock`)}async function acquireLock(r){let i=Date.now();for(;;){await mkdir(dirname(r),{recursive:!0});try{await mkdir(r),await writeFile(join(r,`owner.json`),`${JSON.stringify({createdAt:new Date().toISOString(),pid:process.pid})}\n`);return}catch(e){if(!isFileExistsError(e))throw e;await waitForExistingLock(r,i,void 0)}}}async function waitForLockRelease(e,t){let n=Date.now(),r=n;for(;;){try{await stat(e)}catch(e){if(isNotFoundError(e))return;throw e}let a=Date.now();if(t!==void 0&&a>=r){let e=Math.round((a-n)/1e3);t(e===0?`waiting for sandbox template prewarm to finish`:`waiting for sandbox template prewarm to finish (${e}s elapsed)`),r=a+1e4}await waitForExistingLock(e,n,t)}}async function waitForExistingLock(e,t,n){let a=await stat(e).catch(e=>{if(isNotFoundError(e))return null;throw e});if(a!==null){if(Date.now()-a.mtimeMs>18e5){n?.(`removing stale sandbox template prewarm lock`),await rm(e,{force:!0,recursive:!0}).catch(()=>{});return}if(Date.now()-t>LOCK_TIMEOUT_MS)throw Error(`Timed out waiting for sandbox template prewarm lock "${e}" after ${LOCK_TIMEOUT_MS}ms.`);await new Promise(e=>setTimeout(e,250))}}function isFileExistsError(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`EEXIST`}function isNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`}export{waitForSandboxTemplatePrewarmLock,withSandboxTemplatePrewarmLock};
|
|
1
|
+
import{dirname,join}from"node:path";import{mkdir,rm,stat,writeFile}from"node:fs/promises";import{resolveSandboxCacheDirectory}from"#internal/application/paths.js";const LOCK_TIMEOUT_MS=900*1e3;async function waitForSandboxTemplatePrewarmLock(e){await waitForLockRelease(resolveSandboxTemplatePrewarmLockPath(e),e.log)}async function withSandboxTemplatePrewarmLock(e,t){let n=resolveSandboxTemplatePrewarmLockPath(e);await acquireLock(n);try{return await t()}finally{await rm(n,{force:!0,recursive:!0}).catch(()=>{})}}function resolveSandboxTemplatePrewarmLockPath(e){return join(resolveSandboxCacheDirectory(e.appRoot),`template-locks`,e.backendName,`${e.templateKey}.lock`)}async function acquireLock(r){let i=Date.now();for(;;){await mkdir(dirname(r),{recursive:!0});try{await mkdir(r),await writeFile(join(r,`owner.json`),`${JSON.stringify({createdAt:new Date().toISOString(),pid:process.pid})}\n`);return}catch(e){if(!isFileExistsError(e))throw e;await waitForExistingLock(r,i,void 0)}}}async function waitForLockRelease(e,t){let n=Date.now(),r=n+1e4;for(;;){try{await stat(e)}catch(e){if(isNotFoundError(e))return;throw e}let a=Date.now();if(t!==void 0&&a>=r){let e=Math.round((a-n)/1e3);t(e===0?`waiting for sandbox template prewarm to finish`:`waiting for sandbox template prewarm to finish (${e}s elapsed)`),r=a+1e4}await waitForExistingLock(e,n,t)}}async function waitForExistingLock(e,t,n){let a=await stat(e).catch(e=>{if(isNotFoundError(e))return null;throw e});if(a!==null){if(Date.now()-a.mtimeMs>18e5){n?.(`removing stale sandbox template prewarm lock`),await rm(e,{force:!0,recursive:!0}).catch(()=>{});return}if(Date.now()-t>LOCK_TIMEOUT_MS)throw Error(`Timed out waiting for sandbox template prewarm lock "${e}" after ${LOCK_TIMEOUT_MS}ms.`);await new Promise(e=>setTimeout(e,250))}}function isFileExistsError(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`EEXIST`}function isNotFoundError(e){return typeof e==`object`&&!!e&&`code`in e&&e.code===`ENOENT`}export{waitForSandboxTemplatePrewarmLock,withSandboxTemplatePrewarmLock};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{toError}from"#shared/errors.js";import{createActionResultEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{contextStorage}from"#context/container.js";import{isAuthorizationSignal,isPendingAuthorizationToolOutput}from"#harness/authorization.js";import{createRuntimeToolResultFromStepResult}from"#harness/action-result-helpers.js";import{readToolInterrupt}from"#harness/tool-interrupts.js";const HARNESS_EMISSION_STATE_KEY=`eve.harness.emission`,DEFAULT_EMISSION_STATE={sessionStarted:!1,sequence:0,stepIndex:0,turnId:``};function getHarnessEmissionState(e){return e?.[HARNESS_EMISSION_STATE_KEY]??DEFAULT_EMISSION_STATE}function isHarnessBetweenTurns(e){return getHarnessEmissionState(e.state).turnId===``}function setHarnessEmissionState(e,t){return{...e,state:{...e.state,[HARNESS_EMISSION_STATE_KEY]:t}}}async function emitTurnPreamble(e,t,n,r){let
|
|
1
|
+
import{toError}from"#shared/errors.js";import{createActionResultEvent,createActionsRequestedEvent,createMessageAppendedEvent,createMessageCompletedEvent,createMessageReceivedEvent,createReasoningAppendedEvent,createReasoningCompletedEvent,createSessionCompletedEvent,createSessionFailedEvent,createSessionStartedEvent,createSessionWaitingEvent,createStepFailedEvent,createStepStartedEvent,createTurnCompletedEvent,createTurnFailedEvent,createTurnStartedEvent}from"#protocol/message.js";import{contextStorage}from"#context/container.js";import{resolveToolCallInputObject}from"#harness/runtime-actions.js";import{isAuthorizationSignal,isPendingAuthorizationToolOutput}from"#harness/authorization.js";import{createRuntimeToolResultFromStepResult,createRuntimeToolResultFromValue}from"#harness/action-result-helpers.js";import{readToolInterrupt}from"#harness/tool-interrupts.js";const HARNESS_EMISSION_STATE_KEY=`eve.harness.emission`,DEFAULT_EMISSION_STATE={sessionStarted:!1,sequence:0,stepIndex:0,turnId:``};function getHarnessEmissionState(e){return e?.[HARNESS_EMISSION_STATE_KEY]??DEFAULT_EMISSION_STATE}function isHarnessBetweenTurns(e){return getHarnessEmissionState(e.state).turnId===``}function setHarnessEmissionState(e,t){return{...e,state:{...e.state,[HARNESS_EMISSION_STATE_KEY]:t}}}async function emitTurnPreamble(e,t,n,r){let i=`turn_${n.sequence}`;return n.sessionStarted||await e(createSessionStartedEvent({runtime:r})),await e(createTurnStartedEvent({sequence:n.sequence,turnId:i})),t.message!==void 0&&await e(createMessageReceivedEvent({message:t.message,sequence:n.sequence,turnId:i})),{sessionStarted:!0,sequence:n.sequence,stepIndex:0,turnId:i}}async function emitStepStarted(e,t,n){await e(createStepStartedEvent({sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId}),n)}async function emitStepAndTurnFailed(e,t,n){await e(createStepFailedEvent({...n,sequence:t.sequence,stepIndex:t.stepIndex,turnId:t.turnId})),await e(createTurnFailedEvent({...n,sequence:t.sequence,turnId:t.turnId}))}async function emitFailedStep(e,t,n){await emitStepAndTurnFailed(e,t,n),await e(createSessionFailedEvent(n))}async function emitRecoverableFailedTurn(e,t,n){return await emitStepAndTurnFailed(e,t,n),await e(createSessionWaitingEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function advanceStep(e){return{...e,stepIndex:e.stepIndex+1}}async function emitTurnEpilogue(e,t,n){return await e(createTurnCompletedEvent({sequence:t.sequence,turnId:t.turnId})),n===`conversation`?await e(createSessionWaitingEvent()):await e(createSessionCompletedEvent()),{sessionStarted:t.sessionStarted,sequence:t.sequence+1,stepIndex:0,turnId:``}}function normalizeAssistantStepFinishReason(e){switch(e){case`content-filter`:case`error`:case`length`:case`stop`:case`tool-calls`:return e;default:return`other`}}async function emitStreamContent(a,o,s){let c=``,l=``,u=`stop`,d,f=new Set,p=new Set,m=new Set,h=[],g=[],flushCurrentMessage=async()=>{l.length!==0&&(await a(createMessageCompletedEvent({finishReason:`tool-calls`,message:l,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),l=``)},emitProviderToolCall=async e=>{p.has(e.toolCallId)||(p.add(e.toolCallId),await a(createActionsRequestedEvent({actions:[{callId:e.toolCallId,input:resolveToolCallInputObject(e.input,{callId:e.toolCallId,toolName:e.toolName}),kind:`tool-call`,toolName:e.toolName}],sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})))};for await(let n of s)if(d===void 0)switch(n.type){case`reasoning-delta`:c+=n.text,await a(createReasoningAppendedEvent({reasoningDelta:n.text,reasoningSoFar:c,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`text-delta`:c.trim().length>0&&(await a(createReasoningCompletedEvent({reasoning:c,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),c=``),l+=n.text,await a(createMessageAppendedEvent({messageDelta:n.text,messageSoFar:l,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break;case`tool-call`:{let e=n;f.add(e.toolCallId),e.providerExecuted===!0&&await emitProviderToolCall(e);break}case`tool-result`:{let e=n;if(e.providerExecuted===!0){await emitProviderToolCall({input:`input`in e?e.input:void 0,toolCallId:e.toolCallId,toolName:e.toolName}),await a(createActionResultEvent({result:createRuntimeToolResultFromStepResult(e),sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId}));break}if(f.has(n.toolCallId))break;if(await flushCurrentMessage(),isInlineAuthorizationToolResult(e)){m.add(n.toolCallId),h.push(e);break}await a(createActionResultEvent({result:createRuntimeToolResultFromStepResult(e),sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),m.add(n.toolCallId);let r=e.output;g.push({type:`tool-result`,toolCallId:e.toolCallId,toolName:e.toolName,output:typeof r==`string`?{type:`text`,value:r}:{type:`json`,value:r??null}});break}case`tool-error`:{let r=n;r.providerExecuted===!0&&(await emitProviderToolCall(r),await a(createActionResultEvent({result:createRuntimeToolResultFromValue({callId:r.toolCallId,isError:!0,output:toError(r.error),toolName:r.toolName}),sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})));break}case`finish-step`:u=normalizeAssistantStepFinishReason(n.finishReason);break;case`error`:d=toError(n.error);break;default:break}if(d!==void 0)throw d;return c.trim().length>0&&await a(createReasoningCompletedEvent({reasoning:c,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),l.length>0&&await a(createMessageCompletedEvent({finishReason:u,message:l,sequence:o.sequence,stepIndex:o.stepIndex,turnId:o.turnId})),{handledInlineToolResultCallIds:m,inlineAuthorizationResults:h,inlineToolResultParts:g}}function isInlineAuthorizationToolResult(e){if(isPendingAuthorizationToolOutput(e.output))return!0;let t=contextStorage.getStore();if(t===void 0)return!1;let n=readToolInterrupt(t,e.toolCallId);return n!==void 0&&isAuthorizationSignal(n)}export{advanceStep,emitFailedStep,emitRecoverableFailedTurn,emitStepStarted,emitStreamContent,emitTurnEpilogue,emitTurnPreamble,getHarnessEmissionState,isHarnessBetweenTurns,normalizeAssistantStepFinishReason,setHarnessEmissionState};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ModelMessage, ToolSet, TypedToolCall } from "ai";
|
|
2
2
|
import type { RuntimeActionRequest, RuntimeActionResult } from "#runtime/actions/types.js";
|
|
3
|
+
import { type JsonObject } from "#shared/json.js";
|
|
3
4
|
import type { HarnessEmitFn, HarnessSession, HarnessToolMap, SessionStateMap, StepInput } from "#harness/types.js";
|
|
4
5
|
/**
|
|
5
6
|
* Serializable event coordinates for one pending runtime-action batch.
|
|
@@ -103,4 +104,13 @@ export declare function createRuntimeActionRequestFromToolCall(input: {
|
|
|
103
104
|
readonly toolCall: TypedToolCall<ToolSet>;
|
|
104
105
|
readonly tools: HarnessToolMap;
|
|
105
106
|
}): RuntimeActionRequest;
|
|
107
|
+
/**
|
|
108
|
+
* Coerces an AI SDK tool-call `input` into the runtime-action `JsonObject`
|
|
109
|
+
* contract, throwing a `TypeError` (with the original as `cause`) that names
|
|
110
|
+
* the offending tool when the payload is not a JSON object.
|
|
111
|
+
*/
|
|
112
|
+
export declare function resolveToolCallInputObject(value: unknown, context: {
|
|
113
|
+
readonly callId: string;
|
|
114
|
+
readonly toolName: string;
|
|
115
|
+
}): JsonObject;
|
|
106
116
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createActionResultEvent}from"#protocol/message.js";import{parseJsonObject}from"#shared/json.js";import{clearProxyInputRequestsForChild}from"#harness/proxy-input-requests.js";import{getRuntimeActionRequestKey,getRuntimeActionResultKey}from"#runtime/actions/keys.js";const PENDING_RUNTIME_ACTION_BATCH_KEY=`eve.runtime.pendingActionBatch`;function getPendingRuntimeActionBatch(e){let t=e?.[PENDING_RUNTIME_ACTION_BATCH_KEY];if(typeof t!=`object`||!t)return;let n=t;if(!(!Array.isArray(n.actions)||!Array.isArray(n.responseMessages)||typeof n.event!=`object`||n.event===null))return n}function hasPendingRuntimeActionBatch(e){return getPendingRuntimeActionBatch(e)!==void 0}function clearPendingRuntimeActionBatch(e){if(e.state?.[PENDING_RUNTIME_ACTION_BATCH_KEY]===void 0)return e;let t={...e.state};return delete t[PENDING_RUNTIME_ACTION_BATCH_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function setPendingRuntimeActionBatch(e){let t={...e.session.state};return t[PENDING_RUNTIME_ACTION_BATCH_KEY]={actions:[...e.actions],event:e.event,responseMessages:[...e.responseMessages]},{...e.session,state:t}}function recordPendingSubagentChildToken(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t===void 0)return e.session;let n={...e.session.state};return n[PENDING_RUNTIME_ACTION_BATCH_KEY]={...t,childContinuationTokens:{...t.childContinuationTokens,[e.callId]:e.childContinuationToken}},{...e.session,state:n}}async function accumulateRuntimeActionResults(e){let t=e.pendingActionKeys,n=[...e.initialResults??[]];if(t!==void 0&&n.length>0){let e=resolveRuntimeActionResultsForKeys({pendingKeys:t,results:n});if(e!==void 0)return e}for(;;){let r=await e.getNext();if(r===null)return null;if(r.kind===`deliver`){e.bufferedDeliveries.push(r.value);continue}if(n.push(...r.results),t===void 0)continue;let i=resolveRuntimeActionResultsForKeys({pendingKeys:t,results:n});if(i!==void 0)return i}}function resolveReadyRuntimeActionResults(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t!==void 0)return resolveRuntimeActionResultsForBatch({batch:t,results:e.results})}function resolveRuntimeActionResultsForBatch(e){return resolveRuntimeActionResultsForKeys({pendingKeys:e.batch.actions.map(e=>getRuntimeActionRequestKey(e)),results:e.results})}function resolveRuntimeActionResultsForKeys(e){let t=new Set(e.pendingKeys),n=new Map;for(let r of e.results){let e=getRuntimeActionResultKey(r);t.has(e)&&n.set(e,r)}let r=[];for(let t of e.pendingKeys){let e=n.get(t);if(e===void 0)return;r.push(e)}return r}async function resolvePendingRuntimeActions(t){let r=getPendingRuntimeActionBatch(t.session.state);if(r===void 0)return{messages:[...t.session.history],outcome:`continue`,session:t.session};let i=resolveReadyRuntimeActionResults({results:t.stepInput?.runtimeActionResults??[],session:t.session});if(i===void 0)return{messages:[...t.session.history],outcome:`unresolved`,session:t.session};if(t.emit!==void 0)for(let n of i)n.kind===`subagent-result`&&n.isError!==!0&&await t.emit({data:{callId:n.callId,output:typeof n.output==`string`?n.output:JSON.stringify(n.output),subagentName:n.subagentName},type:`subagent.completed`}),await t.emit(createActionResultEvent({result:n,sequence:r.event.sequence,stepIndex:r.event.stepIndex,turnId:r.event.turnId}));let a={...t.session.state};delete a[PENDING_RUNTIME_ACTION_BATCH_KEY];let o={...t.session,state:Object.keys(a).length>0?a:void 0},s=r.childContinuationTokens;if(s!==void 0)for(let e of i){if(e.kind!==`subagent-result`)continue;let t=s[e.callId];t!==void 0&&(o=clearProxyInputRequestsForChild(o,t))}let c=i.map(e=>{switch(e.kind){case`load-skill-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:`load_skill`,type:`tool-result`};case`subagent-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.subagentName,type:`tool-result`};case`tool-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.toolName,type:`tool-result`}}throw Error(`Unsupported runtime action result kind "${String(e)}".`)}),l=[...o.history,...r.responseMessages];return c.length>0&&l.push({content:c,role:`tool`}),{messages:l,outcome:`resolved`,session:o}}function createRuntimeActionRequestFromToolCall(e){let t=e.tools.get(e.toolCall.toolName);return t?.runtimeAction?.kind===`subagent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`subagent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,subagentName:t.runtimeAction.subagentName}:t?.runtimeAction?.kind===`remote-agent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`remote-agent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,remoteAgentName:t.runtimeAction.remoteAgentName??t.name}:{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`tool-call`,toolName:e.toolCall.toolName}}function resolveToolCallInputObject(e,n){if(e==null)return{};try{return parseJsonObject(e)}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`Failed to parse tool-call arguments for "${n.toolName}" (${n.callId}): ${t}`,{cause:e})}}function toToolResultOutput(e){return typeof e.output==`string`?e.isError===!0?{type:`error-text`,value:e.output}:{type:`text`,value:e.output}:e.isError===!0?{type:`error-json`,value:toMutableJsonValue(e.output)}:{type:`json`,value:toMutableJsonValue(e.output)}}function toMutableJsonValue(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return e.map(e=>toMutableJsonValue(e));let t={};for(let[n,r]of Object.entries(e))t[n]=toMutableJsonValue(r);return t}export{accumulateRuntimeActionResults,clearPendingRuntimeActionBatch,createRuntimeActionRequestFromToolCall,getPendingRuntimeActionBatch,hasPendingRuntimeActionBatch,recordPendingSubagentChildToken,resolvePendingRuntimeActions,setPendingRuntimeActionBatch};
|
|
1
|
+
import{createActionResultEvent}from"#protocol/message.js";import{parseJsonObject}from"#shared/json.js";import{clearProxyInputRequestsForChild}from"#harness/proxy-input-requests.js";import{getRuntimeActionRequestKey,getRuntimeActionResultKey}from"#runtime/actions/keys.js";const PENDING_RUNTIME_ACTION_BATCH_KEY=`eve.runtime.pendingActionBatch`;function getPendingRuntimeActionBatch(e){let t=e?.[PENDING_RUNTIME_ACTION_BATCH_KEY];if(typeof t!=`object`||!t)return;let n=t;if(!(!Array.isArray(n.actions)||!Array.isArray(n.responseMessages)||typeof n.event!=`object`||n.event===null))return n}function hasPendingRuntimeActionBatch(e){return getPendingRuntimeActionBatch(e)!==void 0}function clearPendingRuntimeActionBatch(e){if(e.state?.[PENDING_RUNTIME_ACTION_BATCH_KEY]===void 0)return e;let t={...e.state};return delete t[PENDING_RUNTIME_ACTION_BATCH_KEY],{...e,state:Object.keys(t).length>0?t:void 0}}function setPendingRuntimeActionBatch(e){let t={...e.session.state};return t[PENDING_RUNTIME_ACTION_BATCH_KEY]={actions:[...e.actions],event:e.event,responseMessages:[...e.responseMessages]},{...e.session,state:t}}function recordPendingSubagentChildToken(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t===void 0)return e.session;let n={...e.session.state};return n[PENDING_RUNTIME_ACTION_BATCH_KEY]={...t,childContinuationTokens:{...t.childContinuationTokens,[e.callId]:e.childContinuationToken}},{...e.session,state:n}}async function accumulateRuntimeActionResults(e){let t=e.pendingActionKeys,n=[...e.initialResults??[]];if(t!==void 0&&n.length>0){let e=resolveRuntimeActionResultsForKeys({pendingKeys:t,results:n});if(e!==void 0)return e}for(;;){let r=await e.getNext();if(r===null)return null;if(r.kind===`deliver`){e.bufferedDeliveries.push(r.value);continue}if(n.push(...r.results),t===void 0)continue;let i=resolveRuntimeActionResultsForKeys({pendingKeys:t,results:n});if(i!==void 0)return i}}function resolveReadyRuntimeActionResults(e){let t=getPendingRuntimeActionBatch(e.session.state);if(t!==void 0)return resolveRuntimeActionResultsForBatch({batch:t,results:e.results})}function resolveRuntimeActionResultsForBatch(e){return resolveRuntimeActionResultsForKeys({pendingKeys:e.batch.actions.map(e=>getRuntimeActionRequestKey(e)),results:e.results})}function resolveRuntimeActionResultsForKeys(e){let t=new Set(e.pendingKeys),n=new Map;for(let r of e.results){let e=getRuntimeActionResultKey(r);t.has(e)&&n.set(e,r)}let r=[];for(let t of e.pendingKeys){let e=n.get(t);if(e===void 0)return;r.push(e)}return r}async function resolvePendingRuntimeActions(t){let r=getPendingRuntimeActionBatch(t.session.state);if(r===void 0)return{messages:[...t.session.history],outcome:`continue`,session:t.session};let i=resolveReadyRuntimeActionResults({results:t.stepInput?.runtimeActionResults??[],session:t.session});if(i===void 0)return{messages:[...t.session.history],outcome:`unresolved`,session:t.session};if(t.emit!==void 0)for(let n of i)n.kind===`subagent-result`&&n.isError!==!0&&await t.emit({data:{callId:n.callId,output:typeof n.output==`string`?n.output:JSON.stringify(n.output),subagentName:n.subagentName},type:`subagent.completed`}),await t.emit(createActionResultEvent({result:n,sequence:r.event.sequence,stepIndex:r.event.stepIndex,turnId:r.event.turnId}));let a={...t.session.state};delete a[PENDING_RUNTIME_ACTION_BATCH_KEY];let o={...t.session,state:Object.keys(a).length>0?a:void 0},s=r.childContinuationTokens;if(s!==void 0)for(let e of i){if(e.kind!==`subagent-result`)continue;let t=s[e.callId];t!==void 0&&(o=clearProxyInputRequestsForChild(o,t))}let c=i.map(e=>{switch(e.kind){case`load-skill-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:`load_skill`,type:`tool-result`};case`subagent-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.subagentName,type:`tool-result`};case`tool-result`:return{output:toToolResultOutput(e),toolCallId:e.callId,toolName:e.toolName,type:`tool-result`}}throw Error(`Unsupported runtime action result kind "${String(e)}".`)}),l=[...o.history,...r.responseMessages];return c.length>0&&l.push({content:c,role:`tool`}),{messages:l,outcome:`resolved`,session:o}}function createRuntimeActionRequestFromToolCall(e){let t=e.tools.get(e.toolCall.toolName);return t?.runtimeAction?.kind===`subagent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`subagent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,subagentName:t.runtimeAction.subagentName}:t?.runtimeAction?.kind===`remote-agent-call`?{callId:e.toolCall.toolCallId,description:t.description,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`remote-agent-call`,name:t.name,nodeId:t.runtimeAction.nodeId,remoteAgentName:t.runtimeAction.remoteAgentName??t.name}:{callId:e.toolCall.toolCallId,input:resolveToolCallInputObject(e.toolCall.input,{callId:e.toolCall.toolCallId,toolName:e.toolCall.toolName}),kind:`tool-call`,toolName:e.toolCall.toolName}}function resolveToolCallInputObject(e,n){if(e==null)return{};try{return parseJsonObject(e)}catch(e){let t=e instanceof Error?e.message:String(e);throw TypeError(`Failed to parse tool-call arguments for "${n.toolName}" (${n.callId}): ${t}`,{cause:e})}}function toToolResultOutput(e){return typeof e.output==`string`?e.isError===!0?{type:`error-text`,value:e.output}:{type:`text`,value:e.output}:e.isError===!0?{type:`error-json`,value:toMutableJsonValue(e.output)}:{type:`json`,value:toMutableJsonValue(e.output)}}function toMutableJsonValue(e){if(e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`)return e;if(Array.isArray(e))return e.map(e=>toMutableJsonValue(e));let t={};for(let[n,r]of Object.entries(e))t[n]=toMutableJsonValue(r);return t}export{accumulateRuntimeActionResults,clearPendingRuntimeActionBatch,createRuntimeActionRequestFromToolCall,getPendingRuntimeActionBatch,hasPendingRuntimeActionBatch,recordPendingSubagentChildToken,resolvePendingRuntimeActions,resolveToolCallInputObject,setPendingRuntimeActionBatch};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.8.
|
|
1
|
+
import{createRequire}from"node:module";import{basename,dirname,join}from"node:path";import{existsSync,readFileSync,realpathSync}from"node:fs";import{EVE_PACKAGE_NAME}from"#internal/package-name.js";import{fileURLToPath}from"node:url";let cachedPackageInfo;const BUNDLED_FALLBACK_PACKAGE_VERSION=`0.8.5`,WORKFLOW_MODULE_ALIASES={"workflow/api":`src/compiled/@workflow/core/runtime.js`,"workflow/errors":`src/compiled/@workflow/errors/index.js`,"workflow/internal/private":`src/compiled/@workflow/core/private.js`,"workflow/runtime":`src/compiled/@workflow/core/runtime.js`};function resolveFallbackPackageVersion(){return BUNDLED_FALLBACK_PACKAGE_VERSION.startsWith(`__`)?`0.0.0`:BUNDLED_FALLBACK_PACKAGE_VERSION}const FALLBACK_PACKAGE_INFO={name:EVE_PACKAGE_NAME,version:resolveFallbackPackageVersion()};function resolveCurrentModulePath(){return typeof __filename==`string`?__filename:resolveCurrentModulePathFromStack()}function resolveCurrentModulePathFromStack(){let e=Error.prepareStackTrace;try{Error.prepareStackTrace=(e,t)=>t;let e=Error().stack?.[0]?.getFileName();if(typeof e!=`string`||e.length===0)throw Error(`Failed to resolve the current module path from the stack trace.`);return e.startsWith(`file:`)?fileURLToPath(e):e}finally{Error.prepareStackTrace=e}}const require=createRequire(resolveCurrentModulePath());function isBuildOutputPackageRoot(e){return basename(e)===`dist`&&existsSync(join(dirname(e),`package.json`))}function resolvePackageBuildRoot(){let e=dirname(realpathSync(resolveCurrentModulePath()));for(;;){if(isBuildOutputPackageRoot(e))return e;let t=dirname(e);if(t===e)return null;e=t}}function findNearestPackageRoot(e){let t=e;for(;;){if(existsSync(join(t,`package.json`))&&!isBuildOutputPackageRoot(t))return t;let r=dirname(t);if(r===t)throw Error(`Failed to resolve package root from "${e}".`);t=r}}function resolvePackageRoot(){return findNearestPackageRoot(dirname(realpathSync(resolveCurrentModulePath())))}function tryResolvePackageRoot(){try{return resolvePackageRoot()}catch{return}}function rewriteSourceFilePathForBuild(e){return e.replace(/\.[cm]?tsx?$/,`.js`)}function resolvePackageSourceFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),e):join(t,rewriteSourceFilePathForBuild(e))}function resolvePackageSourceDirectoryPath(e){let t=resolvePackageBuildRoot();return join(t===null?resolvePackageRoot():t,e)}function resolvePackageDependencyPath(e){return require.resolve(e)}function resolvePackageCompiledFilePath(e){let t=resolvePackageBuildRoot();return t===null?join(resolvePackageRoot(),`.generated`,`compiled`,e.replace(/^src\/compiled\//,``)):join(t,e)}function normalizeInstalledPackageInfo(e){let t=e;if(!(typeof t.name!=`string`||typeof t.version!=`string`))return{name:t.name,version:t.version}}function tryReadInstalledPackageInfo(e,t){let n=normalizeInstalledPackageInfo(JSON.parse(readFileSync(e,`utf8`)));if(n?.name===t)return n}function resolveInstalledPackageInfo(){if(cachedPackageInfo)return cachedPackageInfo;let e=tryResolvePackageRoot(),t=e===void 0?void 0:tryReadInstalledPackageInfo(join(e,`package.json`),EVE_PACKAGE_NAME);if(t)return cachedPackageInfo=t,cachedPackageInfo;try{let e=tryReadInstalledPackageInfo(require.resolve(`${EVE_PACKAGE_NAME}/package.json`),EVE_PACKAGE_NAME);if(e)return cachedPackageInfo=e,cachedPackageInfo}catch{}return cachedPackageInfo={...FALLBACK_PACKAGE_INFO},cachedPackageInfo}function resolveWorkflowModulePath(e){if(e===`workflow`)return resolvePackageSourceFilePath(`src/internal/workflow/index.ts`);if(e===`workflow/internal/builtins`)return resolvePackageSourceFilePath(`src/internal/workflow/builtins.ts`);let t=WORKFLOW_MODULE_ALIASES[e];return t===void 0?require.resolve(e):resolvePackageCompiledFilePath(t)}export{resolveInstalledPackageInfo,resolvePackageDependencyPath,resolvePackageRoot,resolvePackageSourceDirectoryPath,resolvePackageSourceFilePath,resolveWorkflowModulePath};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{resolvePackageRoot,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,join,relative}from"node:path";import{mkdir,writeFile}from"node:fs/promises";import{normalizeEsmImportSpecifier,stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{EVE_WORKFLOW_QUEUE_PREFIX}from"#internal/workflow/queue-namespace.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{createNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{computeChannelRouteRegistrations,registerChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";function includesApplicationRoutes(e){return e===`all`||e===`app`}function includesWorkflowBundles(e){return includesWorkflowRoute(e)}function includesWorkflowRoute(e){return e===`all`||e===`flow`}function registerHandler(e,t){let n=`#eve-route-handler/${t.method??`ALL`} ${t.route}`,r=stringifyEsmImportSpecifier(t.handlerPath);e.options.handlers.push({handler:n,method:t.method,route:t.route}),e.options.virtual[n]=[`import handler from ${r};`,`export default handler;`].join(`
|
|
1
|
+
import{EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN,EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH}from"#protocol/routes.js";import{resolvePackageRoot,resolvePackageSourceFilePath,resolveWorkflowModulePath}from"#internal/application/package.js";import{dirname,join,relative}from"node:path";import{mkdir,writeFile}from"node:fs/promises";import{normalizeEsmImportSpecifier,stringifyEsmImportSpecifier}from"#internal/application/import-specifier.js";import{EVE_WORKFLOW_QUEUE_PREFIX}from"#internal/workflow/queue-namespace.js";import{WorkflowBundleBuilder}from"#internal/workflow-bundle/builder.js";import{createNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{computeChannelRouteRegistrations,registerChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";function includesApplicationRoutes(e){return e===`all`||e===`app`}function includesWorkflowBundles(e){return includesWorkflowRoute(e)}function includesWorkflowRoute(e){return e===`all`||e===`flow`}function registerHandler(e,t){let n=`#eve-route-handler/${t.method??`ALL`} ${t.route}`,r=stringifyEsmImportSpecifier(t.handlerPath);e.options.handlers.push({handler:n,method:t.method,route:t.route}),e.options.virtual[n]=[`import handler from ${r};`,`export default handler;`].join(`
|
|
2
2
|
`)}function resolveNitroWorkflowBuildDirectory(e){return join(e.options.buildDir,`workflow`)}function createRelativeImportSpecifier(e,t){let n=relative(e,t).replaceAll(`\\`,`/`);return n.startsWith(`.`)?n:`./${n}`}async function addWorkflowFileHandler(e,t){let n=join(resolveNitroWorkflowBuildDirectory(e),`${t.bundleName}-handler.mjs`),r=dirname(n),i=createRelativeImportSpecifier(r,t.bundlePath),a=(t.directHandlers??[]).map(e=>{let t=createRelativeImportSpecifier(r,e.bundlePath);return{importSpecifier:t,isOwnBundle:t===i,queuePrefix:e.queuePrefix}});await mkdir(r,{recursive:!0}),await writeFile(n,buildWorkflowFileHandlerSource({bundlePath:i,directHandlers:a,runtimeImportSpecifier:t.runtimeImportSpecifier})),e.options.handlers.push({handler:n,route:t.route})}function buildWorkflowFileHandlerSource(e){let t=[`// Generated by Eve. Do not edit by hand.`,`import { POST } from ${JSON.stringify(e.bundlePath)};`];if(e.directHandlers.length>0&&e.runtimeImportSpecifier!==void 0){let n=0,r=e.directHandlers.map(e=>{if(e.isOwnBundle)return{...e,binding:`POST`};let t=`__eveWorkflowDirectHandler${n}`;return n+=1,{...e,binding:t}});for(let e of r)e.isOwnBundle||t.push(`import { POST as ${e.binding} } from ${JSON.stringify(e.importSpecifier)};`);t.push(`import { getWorld as __eveGetWorkflowWorld } from ${JSON.stringify(e.runtimeImportSpecifier)};`,``,`try {`,` const __eveWorkflowWorld = await __eveGetWorkflowWorld();`,` if (typeof __eveWorkflowWorld?.registerHandler === "function") {`);for(let e of r)t.push(` __eveWorkflowWorld.registerHandler(${JSON.stringify(e.queuePrefix)}, ${e.binding});`);t.push(` }`,`} catch (err) {`,` console.warn("[eve] Failed to register direct workflow queue handlers:", err);`,`}`)}return t.push(``,`export default async ({ req }) => {`,` return await POST(req);`,`};`,``),t.join(`
|
|
3
3
|
`)}function addFrameworkVirtualHandler(e,t){let n=`#eve-route${t.route}`,r=stringifyEsmImportSpecifier(t.modulePath);e.options.handlers.push({handler:n,method:t.method,route:t.route}),e.options.virtual[n]=[`import { ${t.handlerExport} } from ${r};`,`export default async (event) => ${t.handlerExport}(${t.args}, event.req);`].join(`
|
|
4
|
-
`)}async function configureNitroRoutes(o,s,c){if(includesWorkflowBundles(c.surface)){let e=resolvePackageRoot(),t=new WorkflowBundleBuilder({appRoot:s.appRoot,compiledArtifactsBootstrapPath:s.compiledArtifacts.bootstrapPath,outDir:s.workflowBuildDir,rootDir:e,watch:o.options.dev}),n=Promise.resolve(),buildWorkflowArtifacts=async()=>{await t.build({nitroStepOutfile:includesWorkflowRoute(c.surface)?join(resolveNitroWorkflowBuildDirectory(o),`steps.mjs`):void 0,nitroWorkflowOutfile:o.options.dev&&includesWorkflowRoute(c.surface)?join(resolveNitroWorkflowBuildDirectory(o),`workflows.mjs`):void 0})},syncWorkflowArtifacts=async()=>{let e=n.then(buildWorkflowArtifacts);n=e.catch(()=>{}),await e},r=!0;await syncWorkflowArtifacts(),o.hooks.hook(`build:before`,async()=>{if(r){r=!1;return}await syncWorkflowArtifacts()}),o.options.dev&&o.hooks.hook(`dev:reload`,async()=>{await syncWorkflowArtifacts()})}let l=createNitroArtifactsConfig({appRoot:s.appRoot,dev:o.options.dev});includesApplicationRoutes(c.surface)&&(registerHandler(o,{handlerPath:resolvePackageSourceFilePath(`src/internal/nitro/routes/index.ts`),method:`GET`,route:`/`}),registerHandler(o,{handlerPath:resolvePackageSourceFilePath(`src/internal/nitro/routes/health.ts`),method:`GET`,route:EVE_HEALTH_ROUTE_PATH}),addFrameworkVirtualHandler(o,{args:JSON.stringify({...l,mode:o.options.dev?`development`:`production`}),handlerExport:`handleAgentInfoRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/info.ts`),route:EVE_INFO_ROUTE_PATH}),registerChannelVirtualHandlers(o,{artifactsConfig:l,registrations:computeChannelRouteRegistrations(s)}),o.options.dev&&(addFrameworkVirtualHandler(o,{args:JSON.stringify({appRoot:l.appRoot}),handlerExport:`handleDevRuntimeArtifactsRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}),addFrameworkVirtualHandler(o,{args:JSON.stringify({appRoot:l.appRoot}),handlerExport:`handleDevScheduleDispatchRequest`,method:`POST`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-schedule-dispatch.ts`),route:EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN})));let u=resolveNitroWorkflowBuildDirectory(o),d=includesWorkflowRoute(c.surface)?o.options.dev?join(u,`workflows.mjs`):join(s.workflowBuildDir,`workflows.mjs`):void 0,f=o.options.dev&&d!==void 0?[{bundlePath:d,queuePrefix:EVE_WORKFLOW_QUEUE_PREFIX}]:[],p=f.length>0?normalizeEsmImportSpecifier(resolveWorkflowModulePath(`workflow/runtime`)):void 0;d&&await addWorkflowFileHandler(o,{bundleName:`workflows`,bundlePath:d,directHandlers:f,route:`/.well-known/workflow/v1/flow`,runtimeImportSpecifier:p}),o.routing.sync()}export{configureNitroRoutes};
|
|
4
|
+
`)}async function configureNitroRoutes(o,s,c){if(includesWorkflowBundles(c.surface)){let e=resolvePackageRoot(),t=new WorkflowBundleBuilder({appRoot:s.appRoot,compiledArtifactsBootstrapPath:s.compiledArtifacts.bootstrapPath,outDir:s.workflowBuildDir,rootDir:e,watch:o.options.dev}),n=Promise.resolve(),buildWorkflowArtifacts=async()=>{await t.build({nitroStepOutfile:includesWorkflowRoute(c.surface)?join(resolveNitroWorkflowBuildDirectory(o),`steps.mjs`):void 0,nitroWorkflowOutfile:o.options.dev&&includesWorkflowRoute(c.surface)?join(resolveNitroWorkflowBuildDirectory(o),`workflows.mjs`):void 0})},syncWorkflowArtifacts=async()=>{let e=n.then(buildWorkflowArtifacts);n=e.catch(()=>{}),await e},r=!0;await syncWorkflowArtifacts(),o.hooks.hook(`build:before`,async()=>{if(r){r=!1;return}await syncWorkflowArtifacts()}),o.options.dev&&o.hooks.hook(`dev:reload`,async()=>{await syncWorkflowArtifacts()})}let l=createNitroArtifactsConfig({appRoot:s.appRoot,dev:o.options.dev});includesApplicationRoutes(c.surface)&&(registerHandler(o,{handlerPath:resolvePackageSourceFilePath(`src/internal/nitro/routes/index.ts`),method:`GET`,route:`/`}),registerHandler(o,{handlerPath:resolvePackageSourceFilePath(`src/internal/nitro/routes/health.ts`),method:`GET`,route:EVE_HEALTH_ROUTE_PATH}),addFrameworkVirtualHandler(o,{args:JSON.stringify({...l,mode:o.options.dev?`development`:`production`}),handlerExport:`handleAgentInfoRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/info.ts`),route:EVE_INFO_ROUTE_PATH}),registerChannelVirtualHandlers(o,{artifactsConfig:l,registrations:computeChannelRouteRegistrations(s)}),o.options.dev&&(addFrameworkVirtualHandler(o,{args:JSON.stringify({appRoot:l.appRoot}),handlerExport:`handleDevRuntimeArtifactsRequest`,method:`GET`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}),addFrameworkVirtualHandler(o,{args:JSON.stringify({appRoot:l.appRoot}),handlerExport:`handleDevRuntimeArtifactsRebuildRequest`,method:`POST`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-runtime-artifacts.ts`),route:EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH}),addFrameworkVirtualHandler(o,{args:JSON.stringify({appRoot:l.appRoot}),handlerExport:`handleDevScheduleDispatchRequest`,method:`POST`,modulePath:resolvePackageSourceFilePath(`src/internal/nitro/routes/dev-schedule-dispatch.ts`),route:EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN})));let u=resolveNitroWorkflowBuildDirectory(o),d=includesWorkflowRoute(c.surface)?o.options.dev?join(u,`workflows.mjs`):join(s.workflowBuildDir,`workflows.mjs`):void 0,f=o.options.dev&&d!==void 0?[{bundlePath:d,queuePrefix:EVE_WORKFLOW_QUEUE_PREFIX}]:[],p=f.length>0?normalizeEsmImportSpecifier(resolveWorkflowModulePath(`workflow/runtime`)):void 0;d&&await addWorkflowFileHandler(o,{bundleName:`workflows`,bundlePath:d,directHandlers:f,route:`/.well-known/workflow/v1/flow`,runtimeImportSpecifier:p}),o.routing.sync()}export{configureNitroRoutes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{dirname,join,resolve}from"node:path";import{existsSync}from"node:fs";import{toErrorMessage}from"#shared/errors.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{getDevelopmentEnvironmentFilePaths,loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{clearCompiledRuntimeAgentBundleCache}from"#runtime/sessions/compiled-agent-cache.js";import{
|
|
1
|
+
import{dirname,join,relative,resolve}from"node:path";import{existsSync}from"node:fs";import{toErrorMessage}from"#shared/errors.js";import{startDevelopmentSandboxPrewarmInBackground}from"#execution/sandbox/development-prewarm.js";import{AUTHORED_ARTIFACTS_UPDATED_LOG_LINE,STRUCTURAL_RELOAD_LOG_LINE,formatChangeDetectedLogLine}from"#internal/nitro/host/dev-watcher-log.js";import{getDevelopmentEnvironmentFilePaths,loadDevelopmentEnvironmentFiles}from"#cli/dev/environment.js";import{clearCompiledRuntimeAgentBundleCache}from"#runtime/sessions/compiled-agent-cache.js";import{resolveDevelopmentSourceSnapshotWatchPaths}from"#internal/nitro/dev-runtime-source-snapshot.js";import{resolveTsConfigDependencyPaths}from"#internal/application/tsconfig-dependencies.js";import{prepareApplicationHost}from"#internal/nitro/host/prepare-application-host.js";import{createNitroArtifactsConfig}from"#internal/nitro/host/artifacts-config.js";import{computeChannelRouteRegistrations,syncChannelVirtualHandlers}from"#internal/nitro/host/channel-routes.js";import{watch}from"#compiled/chokidar/index.js";import{resolveNitroCompiledArtifactsSource}from"#internal/nitro/routes/runtime-artifacts.js";import{registerDevelopmentRebuildHandle}from"#internal/nitro/host/dev-rebuild-registry.js";const WATCHED_LOCKFILE_NAMES=[`pnpm-lock.yaml`,`package-lock.json`,`yarn.lock`,`bun.lock`,`bun.lockb`],WATCH_ROOT_MARKER_NAMES=[`.git`,`pnpm-workspace.yaml`],WATCHER_IGNORED_DIRECTORY_NAMES=new Set([`.generated`,`.eve`,`.git`,`.next`,`.output`,`.turbo`,`.vercel`,`.workflow-data`,`build`,`dist`,`node_modules`]);async function startAuthoredSourceWatcher(e){let t=e.preparedHost,n=!1,r=Promise.resolve(),i,o=!1,s=new Map,c=new Set,d=await resolveAuthoredWatchPaths(t),f=createWatchPathMap(d),p=watch(d,{awaitWriteFinish:{pollInterval:50,stabilityThreshold:160},followSymlinks:!1,ignoreInitial:!0,ignored:shouldIgnoreWatcherPath}),m=waitForWatcherReady(p),flush=async()=>{n||(i!==void 0&&(clearTimeout(i),i=void 0),r=r.then(async()=>{if(n)return;let r=[...s.values()];if(r.length===0)return;let i=[...c];s.clear(),c.clear();let o=t,l=hasSandboxRelatedChange(o.compileResult.project.agentRoot,i),u=hasDevelopmentEnvironmentFileChange(o.appRoot,i);console.log(formatChangeDetectedLogLine(o.appRoot,r));try{u&&loadDevelopmentEnvironmentFiles(o.appRoot);let n=await prepareApplicationHost(o.appRoot,{dev:e.nitro.options.dev===!0}),r=createNitroArtifactsConfig({appRoot:n.appRoot,dev:e.nitro.options.dev===!0});l&&startDevelopmentSandboxPrewarmInBackground({appRoot:n.appRoot,compiledArtifactsSource:resolveNitroCompiledArtifactsSource(r),log:e=>console.log(e)});let i=syncChannelVirtualHandlers(e.nitro,{artifactsConfig:r,next:computeChannelRouteRegistrations(n),previous:computeChannelRouteRegistrations(o)});clearCompiledRuntimeAgentBundleCache(),t=n,i||u?(console.log(STRUCTURAL_RELOAD_LOG_LINE),await e.nitro.hooks.callHook(`rollup:reload`)):console.log(AUTHORED_ARTIFACTS_UPDATED_LOG_LINE),f=syncWatcherPaths({nextWatchPaths:await resolveAuthoredWatchPaths(n),previousWatchPathsByKey:f,watcher:p})}catch(e){console.error(`[eve:dev] rebuild failed: ${toErrorMessage(e)}`)}}).catch(e=>{console.error(`[eve:dev] rebuild queue error: ${toErrorMessage(e)}`)}),await r)},h=registerDevelopmentRebuildHandle(t.appRoot,{flush});return p.on(`all`,(e,t)=>{n||!o||(s.set(`${e}:${t}`,{event:e,path:t}),c.add(t),i!==void 0&&clearTimeout(i),i=setTimeout(()=>{i=void 0,flush()},120))}),await m,o=!0,{async close(){n=!0,h(),i!==void 0&&(clearTimeout(i),i=void 0),await p.close(),await r},flush}}async function waitForWatcherReady(e){await new Promise((t,n)=>{e.on(`ready`,()=>{t()}),e.on(`error`,e=>{n(e)})})}async function resolveAuthoredWatchPaths(e){let n=new Set([e.compileResult.project.agentRoot,join(e.appRoot,`package.json`),join(e.appRoot,`jsconfig.json`),join(e.appRoot,`tsconfig.json`),join(e.appRoot,`tsconfig.*.json`)]),r=await resolveTsConfigWatchPaths(e.appRoot),i=await resolveDevelopmentSourceSnapshotWatchPaths(e.appRoot);for(let t of getDevelopmentEnvironmentFilePaths(e.appRoot))n.add(t);for(let e of i)n.add(e);for(let e of r)n.add(e);for(let r of resolveLockfileSearchDirectories(e.appRoot))for(let e of WATCHED_LOCKFILE_NAMES)n.add(join(r,e));return[...n].sort((e,t)=>e.localeCompare(t))}function createWatchPathMap(e){let t=new Map;for(let n of e)t.set(toWatchPathKey(n),n);return t}function syncWatcherPaths(e){let t=createWatchPathMap(e.nextWatchPaths),n=[],r=[];for(let[r,i]of t)e.previousWatchPathsByKey.has(r)||n.push(i);for(let[n,i]of e.previousWatchPathsByKey)t.has(n)||r.push(i);return n.length>0&&e.watcher.add(n),r.length>0&&e.watcher.unwatch(r),t}function toWatchPathKey(e){return e.replaceAll(`\\`,`/`)}function hasDevelopmentEnvironmentFileChange(e,t){let n=new Set(getDevelopmentEnvironmentFilePaths(e).map(e=>toWatchPathKey(resolve(e))));return t.some(e=>n.has(toWatchPathKey(resolve(e))))}function hasSandboxRelatedChange(e,t){return t.some(t=>{let n=toAgentRelativePath(e,t);return n===`sandbox.ts`||n.startsWith(`sandbox/`)||n===`workspace`||n.startsWith(`workspace/`)||n===`skills`||n.startsWith(`skills/`)})}function toAgentRelativePath(e,t){let i=toWatchPathKey(relative(resolve(e),resolve(t)));return i===`..`||i.startsWith(`../`)||i===``?``:i}function resolveLockfileSearchDirectories(t){let n=resolve(t),i=[n],a=n;for(;;){if(hasWatchRootMarker(a))return i;let t=dirname(a);if(t===a)return[n];a=t,i.push(a)}}function hasWatchRootMarker(e){return WATCH_ROOT_MARKER_NAMES.some(n=>existsSync(join(e,n)))}async function resolveTsConfigWatchPaths(e){return await resolveTsConfigDependencyPaths(e)}function shouldIgnoreWatcherPath(e){return e.replaceAll(`\\`,`/`).split(`/`).filter(Boolean).some(e=>WATCHER_IGNORED_DIRECTORY_NAMES.has(e))}export{startAuthoredSourceWatcher};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export interface DevelopmentRebuildHandle {
|
|
2
|
+
flush(): Promise<void>;
|
|
3
|
+
}
|
|
4
|
+
export declare function registerDevelopmentRebuildHandle(appRoot: string, handle: DevelopmentRebuildHandle): () => void;
|
|
5
|
+
export declare function flushDevelopmentRebuild(appRoot: string): Promise<void>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolve}from"node:path";const developmentRebuildHandles=new Map;function registerDevelopmentRebuildHandle(e,t){let n=resolve(e);return developmentRebuildHandles.set(n,t),()=>{developmentRebuildHandles.get(n)===t&&developmentRebuildHandles.delete(n)}}async function flushDevelopmentRebuild(e){await developmentRebuildHandles.get(resolve(e))?.flush()}export{flushDevelopmentRebuild,registerDevelopmentRebuildHandle};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{readDevelopmentRuntimeArtifactsRevision}from"#internal/nitro/dev-runtime-artifacts.js";function handleDevRuntimeArtifactsRequest(
|
|
1
|
+
import{readDevelopmentRuntimeArtifactsRevision}from"#internal/nitro/dev-runtime-artifacts.js";import{flushDevelopmentRebuild}from"#internal/nitro/host/dev-rebuild-registry.js";function handleDevRuntimeArtifactsRequest(t){return Response.json(readDevelopmentRuntimeArtifactsRevision(t.appRoot),{headers:{"cache-control":`no-store`}})}async function handleDevRuntimeArtifactsRebuildRequest(e){return await flushDevelopmentRebuild(e.appRoot),handleDevRuntimeArtifactsRequest(e)}export{handleDevRuntimeArtifactsRebuildRequest,handleDevRuntimeArtifactsRequest};
|
|
@@ -51,6 +51,11 @@ export declare const EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN = "/eve/v1/dev/sche
|
|
|
51
51
|
* snapshot.
|
|
52
52
|
*/
|
|
53
53
|
export declare const EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH = "/eve/v1/dev/runtime-artifacts";
|
|
54
|
+
/**
|
|
55
|
+
* Dev-only route that flushes queued runtime artifact rebuilds before
|
|
56
|
+
* returning the current revision.
|
|
57
|
+
*/
|
|
58
|
+
export declare const EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH = "/eve/v1/dev/runtime-artifacts/rebuild";
|
|
54
59
|
/**
|
|
55
60
|
* Builds the dev-only schedule dispatch URL for one named authored
|
|
56
61
|
* schedule. The path encodes the schedule id so reserved characters in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const EVE_ROUTE_PREFIX=`/eve/v1`,EVE_HEALTH_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/health`,EVE_INFO_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/info`,EVE_CREATE_SESSION_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/session`,EVE_CONTINUE_SESSION_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/session/:sessionId`,EVE_MESSAGE_STREAM_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/session/:sessionId/stream`,EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/dev/schedules/:scheduleId`,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/dev/runtime-artifacts`;function createEveDevDispatchSchedulePath(e){return`${EVE_ROUTE_PREFIX}/dev/schedules/${encodeURIComponent(e)}`}const EVE_CONNECTION_CALLBACK_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`,EVE_CALLBACK_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/callback/:token`;function createEveMessageStreamRoutePath(e){return`${EVE_ROUTE_PREFIX}/session/${encodeURIComponent(e)}/stream`}function createEveContinueSessionRoutePath(e){return`${EVE_ROUTE_PREFIX}/session/${encodeURIComponent(e)}`}function createEveConnectionCallbackRoutePath(e,t){return`${EVE_ROUTE_PREFIX}/connections/${encodeURIComponent(e)}/callback/${encodeURIComponent(t)}`}function createEveCallbackRoutePath(e){return`${EVE_ROUTE_PREFIX}/callback/${encodeURIComponent(e)}`}export{EVE_CALLBACK_ROUTE_PATTERN,EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,EVE_CONTINUE_SESSION_ROUTE_PATTERN,EVE_CREATE_SESSION_ROUTE_PATH,EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH,EVE_MESSAGE_STREAM_ROUTE_PATTERN,EVE_ROUTE_PREFIX,createEveCallbackRoutePath,createEveConnectionCallbackRoutePath,createEveContinueSessionRoutePath,createEveDevDispatchSchedulePath,createEveMessageStreamRoutePath};
|
|
1
|
+
const EVE_ROUTE_PREFIX=`/eve/v1`,EVE_HEALTH_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/health`,EVE_INFO_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/info`,EVE_CREATE_SESSION_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/session`,EVE_CONTINUE_SESSION_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/session/:sessionId`,EVE_MESSAGE_STREAM_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/session/:sessionId/stream`,EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/dev/schedules/:scheduleId`,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH=`${EVE_ROUTE_PREFIX}/dev/runtime-artifacts`,EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH=`${EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}/rebuild`;function createEveDevDispatchSchedulePath(e){return`${EVE_ROUTE_PREFIX}/dev/schedules/${encodeURIComponent(e)}`}const EVE_CONNECTION_CALLBACK_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/connections/:name/callback/:token`,EVE_CALLBACK_ROUTE_PATTERN=`${EVE_ROUTE_PREFIX}/callback/:token`;function createEveMessageStreamRoutePath(e){return`${EVE_ROUTE_PREFIX}/session/${encodeURIComponent(e)}/stream`}function createEveContinueSessionRoutePath(e){return`${EVE_ROUTE_PREFIX}/session/${encodeURIComponent(e)}`}function createEveConnectionCallbackRoutePath(e,t){return`${EVE_ROUTE_PREFIX}/connections/${encodeURIComponent(e)}/callback/${encodeURIComponent(t)}`}function createEveCallbackRoutePath(e){return`${EVE_ROUTE_PREFIX}/callback/${encodeURIComponent(e)}`}export{EVE_CALLBACK_ROUTE_PATTERN,EVE_CONNECTION_CALLBACK_ROUTE_PATTERN,EVE_CONTINUE_SESSION_ROUTE_PATTERN,EVE_CREATE_SESSION_ROUTE_PATH,EVE_DEV_DISPATCH_SCHEDULE_ROUTE_PATTERN,EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,EVE_HEALTH_ROUTE_PATH,EVE_INFO_ROUTE_PATH,EVE_MESSAGE_STREAM_ROUTE_PATTERN,EVE_ROUTE_PREFIX,createEveCallbackRoutePath,createEveConnectionCallbackRoutePath,createEveContinueSessionRoutePath,createEveDevDispatchSchedulePath,createEveMessageStreamRoutePath};
|
|
@@ -23,9 +23,9 @@ export interface DockerSandboxCreateOptions {
|
|
|
23
23
|
/**
|
|
24
24
|
* Base container image for templates and sessions. Defaults to
|
|
25
25
|
* `ubuntu:26.04` — the official Ubuntu 26.04 image. Framework setup
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* creates `/workspace` and verifies Bash. Install any authored runtime
|
|
27
|
+
* tools (Node, Python, ripgrep, etc.) in sandbox bootstrap or provide
|
|
28
|
+
* them through a custom image.
|
|
29
29
|
*/
|
|
30
30
|
readonly image?: string;
|
|
31
31
|
/**
|
|
@@ -11,10 +11,10 @@ import type { SandboxNetworkPolicy } from "#shared/sandbox-network-policy.js";
|
|
|
11
11
|
export interface MicrosandboxCreateOptions {
|
|
12
12
|
/**
|
|
13
13
|
* OCI image used as the base runtime. Eve prepares this image with
|
|
14
|
-
* the framework workspace,
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
14
|
+
* Bash, the framework workspace, and the sandbox user before authored
|
|
15
|
+
* bootstrap code runs. Install authored runtime tools such as Node,
|
|
16
|
+
* Python, or ripgrep in sandbox bootstrap or provide them through a
|
|
17
|
+
* custom Ubuntu image.
|
|
18
18
|
*
|
|
19
19
|
* @default "ubuntu:26.04"
|
|
20
20
|
*/
|
|
@@ -11,3 +11,6 @@
|
|
|
11
11
|
export declare function readDevelopmentRuntimeArtifactsRevision(input: {
|
|
12
12
|
readonly serverUrl: string;
|
|
13
13
|
}): Promise<string | undefined>;
|
|
14
|
+
export declare function rebuildDevelopmentRuntimeArtifacts(input: {
|
|
15
|
+
readonly serverUrl: string;
|
|
16
|
+
}): Promise<string | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveDevelopmentClientHeaders}from"./request-headers.js";import{EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}from"#protocol/routes.js";async function readDevelopmentRuntimeArtifactsRevision(
|
|
1
|
+
import{resolveDevelopmentClientHeaders}from"./request-headers.js";import{EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH}from"#protocol/routes.js";async function readDevelopmentRuntimeArtifactsRevision(t){try{let r=new URL(EVE_DEV_RUNTIME_ARTIFACTS_ROUTE_PATH,t.serverUrl);return await parseDevelopmentRuntimeArtifactsRevision(await fetch(r,{headers:await resolveDevelopmentClientHeaders({serverUrl:t.serverUrl})}))}catch{return}}async function rebuildDevelopmentRuntimeArtifacts(n){try{let r=new URL(EVE_DEV_RUNTIME_ARTIFACTS_REBUILD_ROUTE_PATH,n.serverUrl);return await parseDevelopmentRuntimeArtifactsRevision(await fetch(r,{headers:await resolveDevelopmentClientHeaders({serverUrl:n.serverUrl}),method:`POST`}))}catch{return}}async function parseDevelopmentRuntimeArtifactsRevision(e){if(!e.ok)return;let t=await e.json();return typeof t.revision==`string`&&t.revision.length>0?t.revision:void 0}export{readDevelopmentRuntimeArtifactsRevision,rebuildDevelopmentRuntimeArtifacts};
|