@sentry/junior 0.203.0 → 0.204.0
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/dist/agent-CMyTD4DD.js +17509 -0
- package/dist/agent-hooks-Bbcp9e33.js +4040 -0
- package/dist/agent-runner-DNb1A49M.js +678 -0
- package/dist/api/schema.d.ts +2728 -2639
- package/dist/api/schema.js +4 -169
- package/dist/api.d.ts +23 -17
- package/dist/api.js +3881 -5326
- package/dist/app-B1TOqBI8.d.ts +246 -0
- package/dist/app.d.ts +4 -520
- package/dist/app.js +9522 -11875
- package/dist/auth-pause-state-DosEalIG.js +168 -0
- package/dist/catalog-runtime-BReos-D4.js +7 -0
- package/dist/checkpoint-CNrPyRJN.js +2450 -0
- package/dist/cli/chat.d.ts +20 -0
- package/dist/cli/chat.js +229 -336
- package/dist/cli/check.d.ts +8 -0
- package/dist/cli/check.js +513 -806
- package/dist/cli/env.d.ts +13 -0
- package/dist/cli/env.js +63 -12
- package/dist/cli/init.d.ts +3 -0
- package/dist/cli/init.js +90 -159
- package/dist/cli/main.d.ts +6 -0
- package/dist/cli/main.js +43 -64
- package/dist/cli/plugins.d.ts +13 -0
- package/dist/cli/plugins.js +148 -227
- package/dist/cli/run.d.ts +16 -0
- package/dist/cli/run.js +52 -8
- package/dist/cli/snapshot-create.d.ts +4 -0
- package/dist/cli/snapshot-create.js +71 -125
- package/dist/cli/upgrade.d.ts +15 -0
- package/dist/cli/upgrade.js +232 -335
- package/dist/config-nGCW1OTG.js +941 -0
- package/dist/context-B45_WqVX.js +298 -0
- package/dist/conversation-privacy-B4voFRSm.js +182 -0
- package/dist/conversation-work-C6y3T5Hx.js +51 -0
- package/dist/credential-sync-kXr1hvO1.js +2660 -0
- package/dist/db-BeyXKJOI.d.ts +5 -0
- package/dist/destinations-BeBiJeEM.js +29 -0
- package/dist/execution-stats-DWfSihcH.js +373 -0
- package/dist/executor-DcMSlI5c.js +721 -0
- package/dist/experimental-CIXf7Uye.js +46 -0
- package/dist/history-ClE4toxe.d.ts +32 -0
- package/dist/history-CqTuSAdI.js +441 -0
- package/dist/instrumentation.d.ts +3 -3
- package/dist/instrumentation.js +130 -176
- package/dist/job-queue-Drn_LXlM.js +63 -0
- package/dist/logging-BzAk1S_s.js +1210 -0
- package/dist/model-profile-CZmVoGdX.js +49 -0
- package/dist/nitro.d.ts +31 -36
- package/dist/nitro.js +275 -456
- package/dist/oauth-callback-server-JiftokvA.js +130 -0
- package/dist/oauth-relay-CdCnu80W.js +62 -0
- package/dist/package-discovery-7a9YqLhE.js +455 -0
- package/dist/pending-auth-CWmSdZVg.js +185 -0
- package/dist/plugin-module-BKGOXca2.js +81 -0
- package/dist/plugins-BI9A1vKA.d.ts +95 -0
- package/dist/plugins-egKWjgue.js +99 -0
- package/dist/private-trace-result-BLvBjy_e.js +16 -0
- package/dist/profile-CrT5nXbw.js +861 -0
- package/dist/registry-DH1xUo2N.js +1419 -0
- package/dist/reporting-schema-DosTN__Q.js +105 -0
- package/dist/resolve-CZHnfxaS.js +546 -0
- package/dist/rolldown-runtime-B4FMCO8f.js +28 -0
- package/dist/runner-CZV2sC46.js +392 -0
- package/dist/sandbox-egress-signals-bHZfmhbd.js +46 -0
- package/dist/schema-Rn8-XEaN.js +1140 -0
- package/dist/sentry-CD3SdJl-.js +26 -0
- package/dist/skills-CIcDQSgM.js +316 -0
- package/dist/spawn-DdkUFRmq.js +29 -0
- package/dist/stats-DTUbAb88.js +2634 -0
- package/dist/store-C5qxF2ac.d.ts +208 -0
- package/dist/task-queue-CJIR4RF7.js +136 -0
- package/dist/task-runner-D-O3A-Cp.js +639 -0
- package/dist/thread-state-CRc9jTJS.js +431 -0
- package/dist/turn-execution-BkinIdJF.js +47 -0
- package/dist/turn-lifecycle-DQV19VTW.js +54 -0
- package/dist/usage-D3EbSO7w.js +296 -0
- package/dist/usage-schema-CKaDkH_j.js +20 -0
- package/dist/validation-C2CR-OX3.js +40 -0
- package/dist/vercel-queue-DIkVcfK4.js +167 -0
- package/dist/vercel.d.ts +6 -6
- package/dist/vercel.js +14 -6
- package/dist/version-CnXZ614E.d.ts +5 -0
- package/dist/version-DxcWdoKa.js +8 -0
- package/dist/version.d.ts +2 -4
- package/dist/version.js +2 -6
- package/dist/web-authorization-RMBxAR_t.js +76 -0
- package/dist/web-input-3EPfpf55.js +494 -0
- package/dist/work-fGofI7Op.js +509 -0
- package/dist/worker-CsOLq-mR.js +625 -0
- package/package.json +8 -8
- package/dist/agent-hooks-GB2VPTNA.js +0 -51
- package/dist/catalog-runtime-UBLIWD3O.js +0 -14
- package/dist/chunk-2LYHWMR4.js +0 -46
- package/dist/chunk-352OWAZH.js +0 -320
- package/dist/chunk-3Y47VMHV.js +0 -6
- package/dist/chunk-3YJSKOWF.js +0 -164
- package/dist/chunk-4KSSKTQ5.js +0 -229
- package/dist/chunk-4UO6FK4G.js +0 -64
- package/dist/chunk-5AHX53NQ.js +0 -717
- package/dist/chunk-5J3E5FWA.js +0 -700
- package/dist/chunk-5PDAG6O3.js +0 -206
- package/dist/chunk-6Y5B5PEX.js +0 -80
- package/dist/chunk-7GWQ5S5R.js +0 -2086
- package/dist/chunk-7H2VZTWN.js +0 -103
- package/dist/chunk-7NL7T6VU.js +0 -406
- package/dist/chunk-A5L27LE4.js +0 -387
- package/dist/chunk-ADIAWL34.js +0 -81
- package/dist/chunk-ASTEMBKJ.js +0 -519
- package/dist/chunk-CEMMLV5L.js +0 -98
- package/dist/chunk-CM5HNV2W.js +0 -131
- package/dist/chunk-CRTRBBRI.js +0 -105
- package/dist/chunk-DA2KGZZI.js +0 -13
- package/dist/chunk-DIB4GX3G.js +0 -8
- package/dist/chunk-DKIJ2RP5.js +0 -68
- package/dist/chunk-DWPN6SCH.js +0 -172
- package/dist/chunk-EDKUFGPL.js +0 -64
- package/dist/chunk-ENY6SKIU.js +0 -1228
- package/dist/chunk-F4MGCZOX.js +0 -2943
- package/dist/chunk-FA6POGLH.js +0 -70
- package/dist/chunk-FSUR7GTG.js +0 -20475
- package/dist/chunk-GKEOHJL5.js +0 -1856
- package/dist/chunk-GMCB6W5Y.js +0 -333
- package/dist/chunk-IE2VPG7O.js +0 -1135
- package/dist/chunk-IZ5B5IHQ.js +0 -3656
- package/dist/chunk-JAL3CH4G.js +0 -27
- package/dist/chunk-KIIEUXD3.js +0 -1764
- package/dist/chunk-KXU4NIL7.js +0 -692
- package/dist/chunk-MTM5IFCY.js +0 -1190
- package/dist/chunk-N7TMSOZH.js +0 -235
- package/dist/chunk-NCEBK6PH.js +0 -36
- package/dist/chunk-NHJU2ZAL.js +0 -56
- package/dist/chunk-P6KTRNVC.js +0 -321
- package/dist/chunk-PDO5BLNM.js +0 -22
- package/dist/chunk-PDRNLLFT.js +0 -3295
- package/dist/chunk-PEQXYSSE.js +0 -45
- package/dist/chunk-PKEX2AQX.js +0 -198
- package/dist/chunk-PSJCGIGO.js +0 -1163
- package/dist/chunk-PZUSUL55.js +0 -506
- package/dist/chunk-R45M4TUS.js +0 -37
- package/dist/chunk-RC745GGZ.js +0 -122
- package/dist/chunk-SP3QKZXJ.js +0 -820
- package/dist/chunk-TXKUKMVO.js +0 -417
- package/dist/chunk-UE4GPWSD.js +0 -931
- package/dist/chunk-UIE3R5XU.js +0 -17
- package/dist/chunk-UXPG6ZIN.js +0 -84
- package/dist/chunk-VFUK3X5B.js +0 -50
- package/dist/chunk-VNMJWREK.js +0 -787
- package/dist/chunk-VZ7CSOX2.js +0 -706
- package/dist/chunk-WCNQJKFT.js +0 -10
- package/dist/chunk-WDZR3QQM.js +0 -135
- package/dist/chunk-WLYVJCHV.js +0 -1433
- package/dist/chunk-WS7NAFTM.js +0 -1520
- package/dist/chunk-X6GDDWQH.js +0 -60
- package/dist/chunk-XPDEYNQI.js +0 -102
- package/dist/chunk-XRW44VGM.js +0 -58
- package/dist/chunk-Y2CM7HXH.js +0 -111
- package/dist/chunk-Y7X25LFY.js +0 -15
- package/dist/conversation-work-VIOQ5ZF3.js +0 -54
- package/dist/db-NGDJV7YH.js +0 -26
- package/dist/discovery-DWVDM7UK.js +0 -44
- package/dist/experimental-P5FZM4CU.js +0 -12
- package/dist/oauth-callback-server-YFY7YEGK.js +0 -243
- package/dist/oauth-relay-5XPVRPYB.js +0 -8
- package/dist/plugins-YTYJMMJF.js +0 -14
- package/dist/runner-ORTNSB2Q.js +0 -522
- package/dist/sandbox-egress-signals-FIL7EGPR.js +0 -73
- package/dist/sentry-MB3NL3IR.js +0 -42
- package/dist/skills-H376WQOH.js +0 -27
- package/dist/spawn-T43WHLOS.js +0 -42
- package/dist/task-runner-LBZWF32V.js +0 -36
- package/dist/validation-REJLRKI6.js +0 -17
- package/dist/work-3KJ3RE76.js +0 -51
- package/dist/worker-QFEBU72E.js +0 -24
package/dist/chunk-5AHX53NQ.js
DELETED
|
@@ -1,717 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
toOptionalTrimmed
|
|
3
|
-
} from "./chunk-ENY6SKIU.js";
|
|
4
|
-
import {
|
|
5
|
-
pluginCatalogRuntime
|
|
6
|
-
} from "./chunk-WCNQJKFT.js";
|
|
7
|
-
import {
|
|
8
|
-
setSpanAttributes,
|
|
9
|
-
setSpanStatus
|
|
10
|
-
} from "./chunk-WS7NAFTM.js";
|
|
11
|
-
|
|
12
|
-
// src/chat/sandbox/paths.ts
|
|
13
|
-
function normalizeWorkspaceRoot(input) {
|
|
14
|
-
const candidate = (input ?? "").trim();
|
|
15
|
-
if (!candidate) {
|
|
16
|
-
return "/vercel/sandbox";
|
|
17
|
-
}
|
|
18
|
-
const normalized = candidate.replace(/\/+$/, "");
|
|
19
|
-
return normalized.startsWith("/") ? normalized : `/${normalized}`;
|
|
20
|
-
}
|
|
21
|
-
var SANDBOX_WORKSPACE_ROOT = normalizeWorkspaceRoot(
|
|
22
|
-
process.env.VERCEL_SANDBOX_WORKSPACE_DIR
|
|
23
|
-
);
|
|
24
|
-
var SANDBOX_REPOS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/repos`;
|
|
25
|
-
var SANDBOX_SKILLS_ROOT = `${SANDBOX_WORKSPACE_ROOT}/skills`;
|
|
26
|
-
var SANDBOX_DATA_ROOT = `${SANDBOX_WORKSPACE_ROOT}/data`;
|
|
27
|
-
function sandboxSkillDir(skillName) {
|
|
28
|
-
return `${SANDBOX_SKILLS_ROOT}/${skillName}`;
|
|
29
|
-
}
|
|
30
|
-
function sandboxSkillFile(skillName) {
|
|
31
|
-
return `${sandboxSkillDir(skillName)}/SKILL.md`;
|
|
32
|
-
}
|
|
33
|
-
function sandboxSkillPathResolution(skillName) {
|
|
34
|
-
const skillDir = sandboxSkillDir(skillName);
|
|
35
|
-
return `Resolve relative paths in this skill against ${skillDir}. For bash commands from this skill, cd to ${skillDir} first or use absolute paths.`;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
// src/chat/sandbox/noninteractive-command.ts
|
|
39
|
-
var NON_INTERACTIVE_ENV = {
|
|
40
|
-
CI: "1",
|
|
41
|
-
TERM: "dumb",
|
|
42
|
-
NO_COLOR: "1",
|
|
43
|
-
PAGER: "cat",
|
|
44
|
-
GIT_PAGER: "cat",
|
|
45
|
-
GH_PROMPT_DISABLED: "1",
|
|
46
|
-
GH_NO_UPDATE_NOTIFIER: "1",
|
|
47
|
-
GH_NO_EXTENSION_UPDATE_NOTIFIER: "1",
|
|
48
|
-
GH_SPINNER_DISABLED: "1",
|
|
49
|
-
GIT_TERMINAL_PROMPT: "0",
|
|
50
|
-
GCM_INTERACTIVE: "never",
|
|
51
|
-
DEBIAN_FRONTEND: "noninteractive",
|
|
52
|
-
// Git credential isolation: prevent git from sending its own auth so the
|
|
53
|
-
// sandbox egress proxy's header transforms are the sole credential source.
|
|
54
|
-
GIT_ASKPASS: "/bin/true",
|
|
55
|
-
GIT_CONFIG_NOSYSTEM: "1",
|
|
56
|
-
GIT_CONFIG_COUNT: "2",
|
|
57
|
-
GIT_CONFIG_KEY_0: "credential.helper",
|
|
58
|
-
GIT_CONFIG_VALUE_0: "",
|
|
59
|
-
GIT_CONFIG_KEY_1: "http.emptyAuth",
|
|
60
|
-
GIT_CONFIG_VALUE_1: "true"
|
|
61
|
-
};
|
|
62
|
-
function shellQuote(value) {
|
|
63
|
-
return `'${value.replace(/'/g, "'\\''")}'`;
|
|
64
|
-
}
|
|
65
|
-
function buildEnvExports(options) {
|
|
66
|
-
const lines = [];
|
|
67
|
-
if (options.pathPrefix) {
|
|
68
|
-
lines.push(`export PATH="${options.pathPrefix}"`);
|
|
69
|
-
}
|
|
70
|
-
for (const [key, value] of Object.entries(NON_INTERACTIVE_ENV)) {
|
|
71
|
-
lines.push(`export ${key}=${shellQuote(value)}`);
|
|
72
|
-
}
|
|
73
|
-
for (const [key, value] of Object.entries(options.env ?? {})) {
|
|
74
|
-
lines.push(`export ${key}=${shellQuote(value)}`);
|
|
75
|
-
}
|
|
76
|
-
return lines;
|
|
77
|
-
}
|
|
78
|
-
function buildCommandScript(input) {
|
|
79
|
-
return [shellQuote(input.cmd), ...(input.args ?? []).map(shellQuote)].join(
|
|
80
|
-
" "
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
function buildNonInteractiveShellScript(script, options = {}) {
|
|
84
|
-
return [...buildEnvExports(options), "exec </dev/null", script].join(" && ");
|
|
85
|
-
}
|
|
86
|
-
function buildNonInteractiveCommand(input) {
|
|
87
|
-
return {
|
|
88
|
-
cmd: "bash",
|
|
89
|
-
args: [
|
|
90
|
-
input.login ? "-lc" : "-c",
|
|
91
|
-
buildNonInteractiveShellScript(buildCommandScript(input), {
|
|
92
|
-
env: input.env,
|
|
93
|
-
pathPrefix: input.pathPrefix
|
|
94
|
-
})
|
|
95
|
-
]
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
async function runNonInteractiveCommand(sandbox, input) {
|
|
99
|
-
const command = {
|
|
100
|
-
...buildNonInteractiveCommand(input),
|
|
101
|
-
...input.cwd ? { cwd: input.cwd } : void 0,
|
|
102
|
-
...input.signal ? { signal: input.signal } : void 0,
|
|
103
|
-
...input.sudo !== void 0 ? { sudo: input.sudo } : void 0,
|
|
104
|
-
...input.timeoutMs !== void 0 ? { timeoutMs: input.timeoutMs } : void 0
|
|
105
|
-
};
|
|
106
|
-
return await sandbox.runCommand(command);
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
// src/chat/sandbox/snapshot/profile.ts
|
|
110
|
-
import { createHash } from "crypto";
|
|
111
|
-
|
|
112
|
-
// src/chat/sandbox/docker.ts
|
|
113
|
-
var DOCKER_DAEMON_JSON = `{
|
|
114
|
-
"storage-driver": "overlay2",
|
|
115
|
-
"live-restore": false
|
|
116
|
-
}
|
|
117
|
-
`;
|
|
118
|
-
var DOCKER_ENSURE_SCRIPT = `#!/bin/sh
|
|
119
|
-
set -eu
|
|
120
|
-
|
|
121
|
-
if [ "$(id -u)" -ne 0 ]; then
|
|
122
|
-
exec sudo -n "$0" "$@"
|
|
123
|
-
fi
|
|
124
|
-
|
|
125
|
-
SOCK=/var/run/docker.sock
|
|
126
|
-
PIDFILE=/var/run/docker.pid
|
|
127
|
-
LOG=/var/log/junior-dockerd.log
|
|
128
|
-
|
|
129
|
-
is_ready() {
|
|
130
|
-
[ -S "$SOCK" ] && /usr/bin/docker info >/dev/null 2>&1
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
if is_ready; then
|
|
134
|
-
chmod 666 "$SOCK" 2>/dev/null || true
|
|
135
|
-
exit 0
|
|
136
|
-
fi
|
|
137
|
-
|
|
138
|
-
mkdir -p /etc/docker /var/lib/docker /var/run /var/log
|
|
139
|
-
if [ ! -f /etc/docker/daemon.json ]; then
|
|
140
|
-
cat > /etc/docker/daemon.json <<'EOF'
|
|
141
|
-
{
|
|
142
|
-
"storage-driver": "overlay2",
|
|
143
|
-
"live-restore": false
|
|
144
|
-
}
|
|
145
|
-
EOF
|
|
146
|
-
fi
|
|
147
|
-
|
|
148
|
-
if [ -f "$PIDFILE" ]; then
|
|
149
|
-
oldpid="$(cat "$PIDFILE" 2>/dev/null || true)"
|
|
150
|
-
if [ -n "\${oldpid:-}" ] && ! kill -0 "$oldpid" 2>/dev/null; then
|
|
151
|
-
rm -f "$PIDFILE"
|
|
152
|
-
fi
|
|
153
|
-
fi
|
|
154
|
-
|
|
155
|
-
if [ ! -f "$PIDFILE" ] || ! kill -0 "$(cat "$PIDFILE" 2>/dev/null)" 2>/dev/null; then
|
|
156
|
-
# dockerd must outlive this helper; nohup + background is intentional.
|
|
157
|
-
nohup dockerd --host="unix://$SOCK" --pidfile="$PIDFILE" >"$LOG" 2>&1 &
|
|
158
|
-
fi
|
|
159
|
-
|
|
160
|
-
i=0
|
|
161
|
-
while [ "$i" -lt 50 ]; do
|
|
162
|
-
if is_ready; then
|
|
163
|
-
chmod 666 "$SOCK" 2>/dev/null || true
|
|
164
|
-
exit 0
|
|
165
|
-
fi
|
|
166
|
-
i=$((i + 1))
|
|
167
|
-
sleep 0.1
|
|
168
|
-
done
|
|
169
|
-
|
|
170
|
-
echo "junior-ensure-docker: dockerd failed to become ready" >&2
|
|
171
|
-
if [ -f "$LOG" ]; then
|
|
172
|
-
tail -n 50 "$LOG" >&2 || true
|
|
173
|
-
fi
|
|
174
|
-
exit 1
|
|
175
|
-
`;
|
|
176
|
-
var DOCKER_CLI_WRAPPER_SCRIPT = `#!/bin/sh
|
|
177
|
-
set -eu
|
|
178
|
-
if command -v junior-ensure-docker >/dev/null 2>&1; then
|
|
179
|
-
junior-ensure-docker
|
|
180
|
-
fi
|
|
181
|
-
exec /usr/bin/docker "$@"
|
|
182
|
-
`;
|
|
183
|
-
var DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT = `#!/bin/sh
|
|
184
|
-
set -eu
|
|
185
|
-
if command -v junior-ensure-docker >/dev/null 2>&1; then
|
|
186
|
-
junior-ensure-docker
|
|
187
|
-
fi
|
|
188
|
-
exec /usr/local/libexec/junior-docker-compose "$@"
|
|
189
|
-
`;
|
|
190
|
-
async function ensureDockerDaemon(sandbox, signal) {
|
|
191
|
-
await runNonInteractiveCommand(sandbox, {
|
|
192
|
-
cmd: "sh",
|
|
193
|
-
args: [
|
|
194
|
-
"-c",
|
|
195
|
-
"command -v junior-ensure-docker >/dev/null 2>&1 && junior-ensure-docker || true"
|
|
196
|
-
],
|
|
197
|
-
signal
|
|
198
|
-
});
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
// src/chat/sandbox/runtime-dependencies.ts
|
|
202
|
-
var GLOBAL_RUNTIME_DEPENDENCIES = [
|
|
203
|
-
{ type: "system", package: "docker" },
|
|
204
|
-
{ type: "system", package: "spal-release" },
|
|
205
|
-
{ type: "system", package: "ripgrep" }
|
|
206
|
-
];
|
|
207
|
-
function writeFileCommand(path, contents, mode = "0644") {
|
|
208
|
-
const payload = Buffer.from(contents, "utf8").toString("base64");
|
|
209
|
-
return [
|
|
210
|
-
`printf '%s' '${payload}' | base64 -d > ${path}`,
|
|
211
|
-
`chmod ${mode} ${path}`
|
|
212
|
-
].join("\n");
|
|
213
|
-
}
|
|
214
|
-
function writeExecutableCommand(path, contents) {
|
|
215
|
-
return writeFileCommand(path, contents, "0755");
|
|
216
|
-
}
|
|
217
|
-
var GLOBAL_RUNTIME_POSTINSTALL = [
|
|
218
|
-
{
|
|
219
|
-
cmd: "sh",
|
|
220
|
-
args: [
|
|
221
|
-
"-c",
|
|
222
|
-
[
|
|
223
|
-
"set -eu",
|
|
224
|
-
'case "$(uname -m)" in',
|
|
225
|
-
' x86_64) asset="x86_64"; sha256="7af95166a730b87e172d4fc9aefea8725d3c6c7327d59149267b452114ddb7d4" ;;',
|
|
226
|
-
' aarch64) asset="aarch64"; sha256="49082844b87f03cdcd5f5bbef1ba8c9c897b7a2dfb80cea18d61ec8ca6117e0c" ;;',
|
|
227
|
-
' *) echo "unsupported Docker Compose architecture: $(uname -m)" >&2; exit 1 ;;',
|
|
228
|
-
"esac",
|
|
229
|
-
'tmp="$(mktemp)"',
|
|
230
|
-
`trap 'rm -f "$tmp"' EXIT`,
|
|
231
|
-
'curl --fail --location --silent --show-error "https://github.com/docker/compose/releases/download/v2.39.4/docker-compose-linux-${asset}" --output "$tmp"',
|
|
232
|
-
'echo "${sha256} ${tmp}" | sha256sum --check --status',
|
|
233
|
-
// Keep the real Compose binary off PATH; the wrapper below starts dockerd.
|
|
234
|
-
'install -D -m 0755 "$tmp" /usr/local/libexec/junior-docker-compose',
|
|
235
|
-
"mkdir -p /usr/local/lib/docker/cli-plugins /usr/local/libexec /etc/docker /usr/local/bin",
|
|
236
|
-
`mkdir -p ${SANDBOX_WORKSPACE_ROOT}/.junior/bin`,
|
|
237
|
-
writeFileCommand("/etc/docker/daemon.json", DOCKER_DAEMON_JSON),
|
|
238
|
-
writeExecutableCommand(
|
|
239
|
-
"/usr/local/bin/junior-ensure-docker",
|
|
240
|
-
DOCKER_ENSURE_SCRIPT
|
|
241
|
-
),
|
|
242
|
-
// docker compose plugin delegates to the real Compose binary.
|
|
243
|
-
"ln -sfn /usr/local/libexec/junior-docker-compose /usr/local/lib/docker/cli-plugins/docker-compose",
|
|
244
|
-
// PATH wrappers auto-start dockerd for both CLI entrypoints.
|
|
245
|
-
writeExecutableCommand(
|
|
246
|
-
"/usr/local/bin/docker-compose",
|
|
247
|
-
DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT
|
|
248
|
-
),
|
|
249
|
-
writeExecutableCommand(
|
|
250
|
-
`${SANDBOX_WORKSPACE_ROOT}/.junior/bin/docker`,
|
|
251
|
-
DOCKER_CLI_WRAPPER_SCRIPT
|
|
252
|
-
),
|
|
253
|
-
writeExecutableCommand(
|
|
254
|
-
`${SANDBOX_WORKSPACE_ROOT}/.junior/bin/docker-compose`,
|
|
255
|
-
DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT
|
|
256
|
-
),
|
|
257
|
-
// Prefer the wrapper over /usr/bin/docker for non-login shells too.
|
|
258
|
-
writeExecutableCommand(
|
|
259
|
-
"/usr/local/bin/docker",
|
|
260
|
-
DOCKER_CLI_WRAPPER_SCRIPT
|
|
261
|
-
)
|
|
262
|
-
].join("\n")
|
|
263
|
-
],
|
|
264
|
-
sudo: true
|
|
265
|
-
}
|
|
266
|
-
];
|
|
267
|
-
|
|
268
|
-
// src/chat/sandbox/snapshot/profile.ts
|
|
269
|
-
var VERSION = 1;
|
|
270
|
-
var DEFAULT_FLOATING_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
271
|
-
function isExactNpmVersion(version) {
|
|
272
|
-
return /^\d+\.\d+\.\d+(?:[-+][a-z0-9.]+)?$/i.test(version.trim());
|
|
273
|
-
}
|
|
274
|
-
function isFloating(dep) {
|
|
275
|
-
return dep.type === "npm" && !isExactNpmVersion(dep.version);
|
|
276
|
-
}
|
|
277
|
-
function mergeDependencies(dependencies) {
|
|
278
|
-
const seen = /* @__PURE__ */ new Set();
|
|
279
|
-
const npmVersions = /* @__PURE__ */ new Map();
|
|
280
|
-
const merged = [];
|
|
281
|
-
for (const dependency of dependencies) {
|
|
282
|
-
const key = dependency.type === "npm" ? `${dependency.type}:${dependency.package}:${dependency.version}` : "package" in dependency ? `${dependency.type}:package:${dependency.package}` : `${dependency.type}:url:${dependency.url}:${dependency.sha256}`;
|
|
283
|
-
if (seen.has(key)) {
|
|
284
|
-
continue;
|
|
285
|
-
}
|
|
286
|
-
seen.add(key);
|
|
287
|
-
if (dependency.type === "npm") {
|
|
288
|
-
const version = npmVersions.get(dependency.package);
|
|
289
|
-
if (version !== void 0 && version !== dependency.version) {
|
|
290
|
-
throw new Error(
|
|
291
|
-
`Conflicting runtime dependency versions for ${dependency.package}: ${version} and ${dependency.version}`
|
|
292
|
-
);
|
|
293
|
-
}
|
|
294
|
-
npmVersions.set(dependency.package, dependency.version);
|
|
295
|
-
}
|
|
296
|
-
merged.push(dependency);
|
|
297
|
-
}
|
|
298
|
-
return merged;
|
|
299
|
-
}
|
|
300
|
-
function floatingMaxAgeMs() {
|
|
301
|
-
const raw = process.env.SANDBOX_SNAPSHOT_FLOATING_MAX_AGE_MS;
|
|
302
|
-
if (!raw?.trim()) {
|
|
303
|
-
return DEFAULT_FLOATING_MAX_AGE_MS;
|
|
304
|
-
}
|
|
305
|
-
const parsed = Number.parseInt(raw, 10);
|
|
306
|
-
return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_FLOATING_MAX_AGE_MS;
|
|
307
|
-
}
|
|
308
|
-
function compareCodePoints(left, right) {
|
|
309
|
-
if (left < right) return -1;
|
|
310
|
-
if (left > right) return 1;
|
|
311
|
-
return 0;
|
|
312
|
-
}
|
|
313
|
-
function workspaceRecipe(workspace) {
|
|
314
|
-
const repos = [...workspace.repos].map(({ provider, repo }) => ({
|
|
315
|
-
provider,
|
|
316
|
-
repo
|
|
317
|
-
})).sort((left, right) => {
|
|
318
|
-
const provider = compareCodePoints(left.provider, right.provider);
|
|
319
|
-
if (provider !== 0) return provider;
|
|
320
|
-
return compareCodePoints(left.repo, right.repo);
|
|
321
|
-
});
|
|
322
|
-
return {
|
|
323
|
-
id: workspace.id,
|
|
324
|
-
repos,
|
|
325
|
-
setupScript: workspace.setupScript
|
|
326
|
-
};
|
|
327
|
-
}
|
|
328
|
-
function create(runtime, workspace) {
|
|
329
|
-
const dependencies = mergeDependencies([
|
|
330
|
-
...GLOBAL_RUNTIME_DEPENDENCIES,
|
|
331
|
-
...pluginCatalogRuntime.getRuntimeDependencies()
|
|
332
|
-
]);
|
|
333
|
-
const pluginPostinstall = pluginCatalogRuntime.getRuntimePostinstall();
|
|
334
|
-
const postinstall = [...GLOBAL_RUNTIME_POSTINSTALL, ...pluginPostinstall];
|
|
335
|
-
if (dependencies.length === 0 && postinstall.length === 0 && !workspace) {
|
|
336
|
-
return null;
|
|
337
|
-
}
|
|
338
|
-
const rebuildEpoch = process.env.SANDBOX_SNAPSHOT_REBUILD_EPOCH?.trim() ?? "";
|
|
339
|
-
const floating = dependencies.some((dependency) => isFloating(dependency)) || pluginPostinstall.length > 0 || Boolean(workspace);
|
|
340
|
-
const hash2 = createHash("sha256").update(
|
|
341
|
-
JSON.stringify({
|
|
342
|
-
version: VERSION,
|
|
343
|
-
runtime,
|
|
344
|
-
rebuildEpoch,
|
|
345
|
-
dependencies,
|
|
346
|
-
postinstall,
|
|
347
|
-
...workspace ? { workspace: workspaceRecipe(workspace) } : void 0
|
|
348
|
-
})
|
|
349
|
-
).digest("hex");
|
|
350
|
-
return {
|
|
351
|
-
hash: hash2,
|
|
352
|
-
dependencyCount: dependencies.length,
|
|
353
|
-
floating,
|
|
354
|
-
dependencies,
|
|
355
|
-
postinstall
|
|
356
|
-
};
|
|
357
|
-
}
|
|
358
|
-
function hash(runtime, workspace) {
|
|
359
|
-
return create(runtime, workspace)?.hash;
|
|
360
|
-
}
|
|
361
|
-
function isStale(profile, createdAtMs) {
|
|
362
|
-
if (!profile.floating) {
|
|
363
|
-
return false;
|
|
364
|
-
}
|
|
365
|
-
const maxAgeMs = floatingMaxAgeMs();
|
|
366
|
-
return maxAgeMs === 0 || Date.now() - createdAtMs > maxAgeMs;
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
// src/chat/sleep.ts
|
|
370
|
-
function sleep(ms, signal) {
|
|
371
|
-
if (!signal) {
|
|
372
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
373
|
-
}
|
|
374
|
-
return new Promise((resolve, reject) => {
|
|
375
|
-
if (signal.aborted) {
|
|
376
|
-
reject(signal.reason);
|
|
377
|
-
return;
|
|
378
|
-
}
|
|
379
|
-
const timeoutId = setTimeout(() => {
|
|
380
|
-
signal.removeEventListener("abort", onAbort);
|
|
381
|
-
resolve();
|
|
382
|
-
}, ms);
|
|
383
|
-
const onAbort = () => {
|
|
384
|
-
clearTimeout(timeoutId);
|
|
385
|
-
reject(signal.reason);
|
|
386
|
-
};
|
|
387
|
-
signal.addEventListener("abort", onAbort, { once: true });
|
|
388
|
-
});
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
// src/chat/sandbox/credentials.ts
|
|
392
|
-
function getVercelSandboxCredentials() {
|
|
393
|
-
const token = toOptionalTrimmed(process.env.VERCEL_TOKEN);
|
|
394
|
-
const teamId = toOptionalTrimmed(process.env.VERCEL_TEAM_ID);
|
|
395
|
-
const projectId = toOptionalTrimmed(process.env.VERCEL_PROJECT_ID);
|
|
396
|
-
if (token && teamId && projectId) {
|
|
397
|
-
return { token, teamId, projectId };
|
|
398
|
-
}
|
|
399
|
-
return void 0;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
// src/chat/sandbox/snapshot/not-ready-error.ts
|
|
403
|
-
var WorkspaceSnapshotNotReadyError = class extends Error {
|
|
404
|
-
workspaceName;
|
|
405
|
-
constructor(workspaceName) {
|
|
406
|
-
super(`Workspace ${workspaceName} snapshot is not ready`);
|
|
407
|
-
this.name = "WorkspaceSnapshotNotReadyError";
|
|
408
|
-
this.workspaceName = workspaceName;
|
|
409
|
-
}
|
|
410
|
-
};
|
|
411
|
-
function getWorkspaceSnapshotNotReadyError(error) {
|
|
412
|
-
const seen = /* @__PURE__ */ new Set();
|
|
413
|
-
let current = error;
|
|
414
|
-
while (current instanceof Error && !seen.has(current)) {
|
|
415
|
-
if (current instanceof WorkspaceSnapshotNotReadyError) return current;
|
|
416
|
-
seen.add(current);
|
|
417
|
-
current = current.cause;
|
|
418
|
-
}
|
|
419
|
-
return void 0;
|
|
420
|
-
}
|
|
421
|
-
function isWorkspaceSnapshotNotReadyError(error) {
|
|
422
|
-
return getWorkspaceSnapshotNotReadyError(error) !== void 0;
|
|
423
|
-
}
|
|
424
|
-
function workspaceSnapshotNotReadyUserMessage(error) {
|
|
425
|
-
return `The ${error.workspaceName} workspace is still preparing its sandbox. Wait for that preparation to finish, then try again.`;
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
// src/chat/sandbox/http-error-details.ts
|
|
429
|
-
var DEFAULT_PREVIEW_LIMIT = 512;
|
|
430
|
-
function toTrimmedString(value, maxChars) {
|
|
431
|
-
if (typeof value !== "string") {
|
|
432
|
-
return void 0;
|
|
433
|
-
}
|
|
434
|
-
const normalized = value.trim();
|
|
435
|
-
if (!normalized) {
|
|
436
|
-
return void 0;
|
|
437
|
-
}
|
|
438
|
-
return normalized.length > maxChars ? `${normalized.slice(0, maxChars)}\u2026` : normalized;
|
|
439
|
-
}
|
|
440
|
-
function extractHttpErrorDetails(error, options = {}) {
|
|
441
|
-
const prefix = options.attributePrefix ?? "app.http_error";
|
|
442
|
-
const previewLimit = options.previewLimit ?? DEFAULT_PREVIEW_LIMIT;
|
|
443
|
-
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
444
|
-
const err = error ?? {};
|
|
445
|
-
const attributes = {
|
|
446
|
-
"error.type": normalizedError.name || "Error",
|
|
447
|
-
"exception.message": toTrimmedString(normalizedError.message, previewLimit) ?? "HTTP error"
|
|
448
|
-
};
|
|
449
|
-
const response = err.response;
|
|
450
|
-
const statusCode = typeof response?.status === "number" ? response.status : void 0;
|
|
451
|
-
const statusText = toTrimmedString(response?.statusText, previewLimit);
|
|
452
|
-
const responseUrl = toTrimmedString(response?.url, previewLimit);
|
|
453
|
-
const responseText = toTrimmedString(err.text, previewLimit);
|
|
454
|
-
const responseJson = toTrimmedString(
|
|
455
|
-
err.json && typeof err.json === "object" ? JSON.stringify(err.json) : void 0,
|
|
456
|
-
previewLimit
|
|
457
|
-
);
|
|
458
|
-
const contentType = toTrimmedString(
|
|
459
|
-
response?.headers?.get?.("content-type"),
|
|
460
|
-
previewLimit
|
|
461
|
-
);
|
|
462
|
-
const requestIdHeader = toTrimmedString(
|
|
463
|
-
response?.headers?.get?.("x-request-id"),
|
|
464
|
-
previewLimit
|
|
465
|
-
);
|
|
466
|
-
const vercelIdHeader = toTrimmedString(
|
|
467
|
-
response?.headers?.get?.("x-vercel-id"),
|
|
468
|
-
previewLimit
|
|
469
|
-
);
|
|
470
|
-
const requestId = requestIdHeader ?? vercelIdHeader;
|
|
471
|
-
if (statusCode !== void 0) {
|
|
472
|
-
attributes["http.response.status_code"] = statusCode;
|
|
473
|
-
}
|
|
474
|
-
if (statusText) {
|
|
475
|
-
attributes[`${prefix}.status_text`] = statusText;
|
|
476
|
-
}
|
|
477
|
-
if (responseUrl) {
|
|
478
|
-
attributes["url.full"] = responseUrl;
|
|
479
|
-
}
|
|
480
|
-
if (contentType) {
|
|
481
|
-
attributes["http.response.header.content-type"] = [contentType];
|
|
482
|
-
}
|
|
483
|
-
if (requestIdHeader) {
|
|
484
|
-
attributes["http.response.header.x-request-id"] = [requestIdHeader];
|
|
485
|
-
}
|
|
486
|
-
if (vercelIdHeader) {
|
|
487
|
-
attributes["http.response.header.x-vercel-id"] = [vercelIdHeader];
|
|
488
|
-
}
|
|
489
|
-
if (responseText) {
|
|
490
|
-
attributes[`${prefix}.response_text_preview`] = responseText;
|
|
491
|
-
attributes[`${prefix}.response_text_length`] = responseText.length;
|
|
492
|
-
}
|
|
493
|
-
if (responseJson) {
|
|
494
|
-
attributes[`${prefix}.response_json_preview`] = responseJson;
|
|
495
|
-
}
|
|
496
|
-
const summaryParts = [];
|
|
497
|
-
if (statusCode !== void 0) {
|
|
498
|
-
summaryParts.push(`status=${statusCode}`);
|
|
499
|
-
}
|
|
500
|
-
if (statusText) {
|
|
501
|
-
summaryParts.push(`statusText=${statusText}`);
|
|
502
|
-
}
|
|
503
|
-
if (responseUrl) {
|
|
504
|
-
summaryParts.push(`url=${responseUrl}`);
|
|
505
|
-
}
|
|
506
|
-
if (requestId) {
|
|
507
|
-
summaryParts.push(`requestId=${requestId}`);
|
|
508
|
-
}
|
|
509
|
-
for (const field of options.extraFields ?? []) {
|
|
510
|
-
const value = toTrimmedString(err[field.sourceKey], previewLimit);
|
|
511
|
-
if (!value) {
|
|
512
|
-
continue;
|
|
513
|
-
}
|
|
514
|
-
attributes[`${prefix}.${field.attributeKey}`] = value;
|
|
515
|
-
summaryParts.push(`${field.summaryKey ?? field.attributeKey}=${value}`);
|
|
516
|
-
}
|
|
517
|
-
if (responseJson) {
|
|
518
|
-
summaryParts.push(`json=${responseJson}`);
|
|
519
|
-
} else if (responseText) {
|
|
520
|
-
summaryParts.push(`text=${responseText}`);
|
|
521
|
-
}
|
|
522
|
-
const searchableText = `${normalizedError.message} ${responseText ?? ""} ${responseJson ?? ""}`.toLowerCase();
|
|
523
|
-
return {
|
|
524
|
-
attributes,
|
|
525
|
-
summary: summaryParts.join(", "),
|
|
526
|
-
searchableText
|
|
527
|
-
};
|
|
528
|
-
}
|
|
529
|
-
|
|
530
|
-
// src/chat/sandbox/errors.ts
|
|
531
|
-
var SANDBOX_ERROR_FIELDS = [
|
|
532
|
-
{
|
|
533
|
-
sourceKey: "sandboxId",
|
|
534
|
-
attributeKey: "sandbox_id",
|
|
535
|
-
summaryKey: "sandboxId"
|
|
536
|
-
}
|
|
537
|
-
];
|
|
538
|
-
function getSandboxErrorDetails(error) {
|
|
539
|
-
return extractHttpErrorDetails(error, {
|
|
540
|
-
attributePrefix: "app.sandbox.api_error",
|
|
541
|
-
extraFields: [...SANDBOX_ERROR_FIELDS]
|
|
542
|
-
});
|
|
543
|
-
}
|
|
544
|
-
function findInErrorChain(error, predicate) {
|
|
545
|
-
const seen = /* @__PURE__ */ new Set();
|
|
546
|
-
let current = error;
|
|
547
|
-
while (current && !seen.has(current)) {
|
|
548
|
-
if (predicate(current)) {
|
|
549
|
-
return true;
|
|
550
|
-
}
|
|
551
|
-
seen.add(current);
|
|
552
|
-
current = typeof current === "object" ? current.cause : void 0;
|
|
553
|
-
}
|
|
554
|
-
return false;
|
|
555
|
-
}
|
|
556
|
-
function isRecord(value) {
|
|
557
|
-
return typeof value === "object" && value !== null;
|
|
558
|
-
}
|
|
559
|
-
function isInvalidSandboxSessionError(error) {
|
|
560
|
-
if (!isRecord(error)) {
|
|
561
|
-
return false;
|
|
562
|
-
}
|
|
563
|
-
if (isRecord(error.json) && error.json.invalidToken === true) {
|
|
564
|
-
return true;
|
|
565
|
-
}
|
|
566
|
-
const response = error.response;
|
|
567
|
-
return isRecord(response) && response.status === 403 && typeof response.url === "string" && response.url.includes("/sandboxes/sessions");
|
|
568
|
-
}
|
|
569
|
-
function getFirstErrorMessage(error) {
|
|
570
|
-
const seen = /* @__PURE__ */ new Set();
|
|
571
|
-
let current = error;
|
|
572
|
-
while (current && !seen.has(current)) {
|
|
573
|
-
if (current instanceof Error) {
|
|
574
|
-
const message = current.message.trim();
|
|
575
|
-
if (message) {
|
|
576
|
-
return message;
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
seen.add(current);
|
|
580
|
-
current = typeof current === "object" ? current.cause : void 0;
|
|
581
|
-
}
|
|
582
|
-
return void 0;
|
|
583
|
-
}
|
|
584
|
-
function isAlreadyExistsError(error) {
|
|
585
|
-
const details = getSandboxErrorDetails(error);
|
|
586
|
-
return details.searchableText.includes("already exists") || details.searchableText.includes("file exists") || details.searchableText.includes("eexist");
|
|
587
|
-
}
|
|
588
|
-
function isSandboxUnavailableError(error) {
|
|
589
|
-
return findInErrorChain(error, (candidate) => {
|
|
590
|
-
if (isInvalidSandboxSessionError(candidate)) {
|
|
591
|
-
return true;
|
|
592
|
-
}
|
|
593
|
-
const details = getSandboxErrorDetails(candidate);
|
|
594
|
-
const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
|
|
595
|
-
return searchable.includes("sandbox_stopped") || searchable.includes("status=410") || searchable.includes("status code 410") || searchable.includes("no longer available") || searchable.includes("stream was closed and is not accepting commands");
|
|
596
|
-
});
|
|
597
|
-
}
|
|
598
|
-
function isSandboxMissingError(error) {
|
|
599
|
-
return findInErrorChain(error, (candidate) => {
|
|
600
|
-
const details = getSandboxErrorDetails(candidate);
|
|
601
|
-
const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
|
|
602
|
-
return searchable.includes("status=404") || searchable.includes("status code 404") || searchable.includes("snapshot_not_found");
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
function isSnapshottingError(error) {
|
|
606
|
-
return findInErrorChain(error, (candidate) => {
|
|
607
|
-
const details = getSandboxErrorDetails(candidate);
|
|
608
|
-
const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
|
|
609
|
-
return searchable.includes("sandbox_snapshotting") || searchable.includes("creating a snapshot") || searchable.includes("stopped shortly");
|
|
610
|
-
});
|
|
611
|
-
}
|
|
612
|
-
function isAbortError(error) {
|
|
613
|
-
return findInErrorChain(error, (candidate) => {
|
|
614
|
-
if (typeof DOMException !== "undefined" && candidate instanceof DOMException) {
|
|
615
|
-
return candidate.name === "AbortError";
|
|
616
|
-
}
|
|
617
|
-
if (!(candidate instanceof Error)) return false;
|
|
618
|
-
if (candidate.name === "AbortError") return true;
|
|
619
|
-
const message = candidate.message.toLowerCase();
|
|
620
|
-
return message.startsWith("executeagentrun timed out after");
|
|
621
|
-
});
|
|
622
|
-
}
|
|
623
|
-
function isSandboxApiTransientError(error) {
|
|
624
|
-
return findInErrorChain(error, (candidate) => {
|
|
625
|
-
const details = getSandboxErrorDetails(candidate);
|
|
626
|
-
const searchable = `${details.searchableText} ${details.summary}`.toLowerCase();
|
|
627
|
-
if (searchable.includes("internal_server_error") || searchable.includes("status=500") || searchable.includes("status code 500") || searchable.includes("status=502") || searchable.includes("status code 502") || searchable.includes("status=503") || searchable.includes("status code 503") || searchable.includes("status=504") || searchable.includes("status code 504")) {
|
|
628
|
-
return true;
|
|
629
|
-
}
|
|
630
|
-
if (!isRecord(candidate)) return false;
|
|
631
|
-
const response = candidate.response;
|
|
632
|
-
return isRecord(response) && typeof response.status === "number" && response.status >= 500 && response.status < 600;
|
|
633
|
-
});
|
|
634
|
-
}
|
|
635
|
-
function isSandboxCommandStreamInterruptedError(error) {
|
|
636
|
-
return findInErrorChain(error, (candidate) => {
|
|
637
|
-
if (!(candidate instanceof Error)) {
|
|
638
|
-
return false;
|
|
639
|
-
}
|
|
640
|
-
return candidate.name === "StreamError" && candidate.message.toLowerCase().includes("stream ended before command finished");
|
|
641
|
-
});
|
|
642
|
-
}
|
|
643
|
-
function wrapSandboxSetupError(error) {
|
|
644
|
-
const notReady = getWorkspaceSnapshotNotReadyError(error);
|
|
645
|
-
if (notReady) {
|
|
646
|
-
return notReady;
|
|
647
|
-
}
|
|
648
|
-
try {
|
|
649
|
-
const details = getSandboxErrorDetails(error);
|
|
650
|
-
if (details.summary) {
|
|
651
|
-
return new Error(`sandbox setup failed (${details.summary})`, {
|
|
652
|
-
cause: error
|
|
653
|
-
});
|
|
654
|
-
}
|
|
655
|
-
} catch {
|
|
656
|
-
}
|
|
657
|
-
let causeMessage;
|
|
658
|
-
try {
|
|
659
|
-
causeMessage = getFirstErrorMessage(error);
|
|
660
|
-
} catch (cause) {
|
|
661
|
-
causeMessage = cause instanceof Error ? cause.message : void 0;
|
|
662
|
-
}
|
|
663
|
-
if (causeMessage && causeMessage.trim() && causeMessage !== "sandbox setup failed") {
|
|
664
|
-
const oneLine = causeMessage.replace(/\s+/g, " ").trim();
|
|
665
|
-
return new Error(`sandbox setup failed (${oneLine})`, { cause: error });
|
|
666
|
-
}
|
|
667
|
-
return new Error("sandbox setup failed", { cause: error });
|
|
668
|
-
}
|
|
669
|
-
function throwSandboxOperationError(action, error, includeMissingPath = false) {
|
|
670
|
-
const details = getSandboxErrorDetails(error);
|
|
671
|
-
setSpanAttributes({
|
|
672
|
-
...details.attributes,
|
|
673
|
-
...includeMissingPath ? {
|
|
674
|
-
"app.sandbox.api_error.missing_path": details.searchableText.includes("no such file") || details.searchableText.includes("enoent")
|
|
675
|
-
} : void 0,
|
|
676
|
-
"app.sandbox.success": false
|
|
677
|
-
});
|
|
678
|
-
setSpanStatus("error");
|
|
679
|
-
throw new Error(
|
|
680
|
-
details.summary ? `${action} failed (${details.summary})` : `${action} failed`,
|
|
681
|
-
{
|
|
682
|
-
cause: error
|
|
683
|
-
}
|
|
684
|
-
);
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
export {
|
|
688
|
-
SANDBOX_WORKSPACE_ROOT,
|
|
689
|
-
SANDBOX_REPOS_ROOT,
|
|
690
|
-
SANDBOX_SKILLS_ROOT,
|
|
691
|
-
SANDBOX_DATA_ROOT,
|
|
692
|
-
sandboxSkillDir,
|
|
693
|
-
sandboxSkillFile,
|
|
694
|
-
sandboxSkillPathResolution,
|
|
695
|
-
sleep,
|
|
696
|
-
buildCommandScript,
|
|
697
|
-
buildNonInteractiveShellScript,
|
|
698
|
-
runNonInteractiveCommand,
|
|
699
|
-
getVercelSandboxCredentials,
|
|
700
|
-
WorkspaceSnapshotNotReadyError,
|
|
701
|
-
getWorkspaceSnapshotNotReadyError,
|
|
702
|
-
isWorkspaceSnapshotNotReadyError,
|
|
703
|
-
workspaceSnapshotNotReadyUserMessage,
|
|
704
|
-
isAlreadyExistsError,
|
|
705
|
-
isSandboxUnavailableError,
|
|
706
|
-
isSandboxMissingError,
|
|
707
|
-
isSnapshottingError,
|
|
708
|
-
isAbortError,
|
|
709
|
-
isSandboxApiTransientError,
|
|
710
|
-
isSandboxCommandStreamInterruptedError,
|
|
711
|
-
wrapSandboxSetupError,
|
|
712
|
-
throwSandboxOperationError,
|
|
713
|
-
ensureDockerDaemon,
|
|
714
|
-
create,
|
|
715
|
-
hash,
|
|
716
|
-
isStale
|
|
717
|
-
};
|