@sentry/junior 0.164.0 → 0.166.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-hooks-WTBPNRTC.js → agent-hooks-ZIPK2HUF.js} +9 -9
- package/dist/api/schema/workspace.d.ts +10 -4
- package/dist/api/schema.js +1 -1
- package/dist/api.js +52 -27
- package/dist/app.js +59 -60
- package/dist/{catalog-runtime-CZ2SQINY.js → catalog-runtime-GEZAHBUP.js} +5 -5
- package/dist/chat/pi/transcript.d.ts +10 -10
- package/dist/chat/repository-instructions.d.ts +12 -1
- package/dist/chat/sandbox/sandbox.d.ts +1 -1
- package/dist/chat/sandbox/snapshot/resolve.d.ts +16 -0
- package/dist/chat/sandbox/snapshot/runtime.d.ts +2 -0
- package/dist/chat/services/conversation-memory.d.ts +7 -0
- package/dist/chat/workspaces/store.d.ts +10 -3
- package/dist/chat/workspaces/types.d.ts +8 -1
- package/dist/chat/workspaces/validation.d.ts +0 -1
- package/dist/{chunk-HHW6ZVIZ.js → chunk-22RO7IDD.js} +109 -21
- package/dist/{chunk-FKDY7NTC.js → chunk-2KV4BAAN.js} +12 -12
- package/dist/{chunk-Y2B6AXZQ.js → chunk-2ZKFLHVP.js} +6 -6
- package/dist/{chunk-ZUTAGCPH.js → chunk-3EZ5V7XQ.js} +9 -9
- package/dist/{chunk-3L23VTY7.js → chunk-43KLUCAM.js} +17 -17
- package/dist/{chunk-PU45BSBS.js → chunk-4CMORAHL.js} +9 -5
- package/dist/chunk-4DARCEZH.js +274 -0
- package/dist/{chunk-6ENAACWN.js → chunk-4MDEQNSW.js} +9 -5
- package/dist/{chunk-ZSNABC2E.js → chunk-65SNO3WK.js} +9 -7
- package/dist/{chunk-WJUKESU2.js → chunk-ABNRESX6.js} +1 -1
- package/dist/{chunk-FX4PX3SA.js → chunk-AEKBVJMV.js} +2 -2
- package/dist/{chunk-26JYGL2L.js → chunk-BKP3PVKR.js} +1 -1
- package/dist/{chunk-XAIRI54J.js → chunk-C3USHSIJ.js} +1 -1
- package/dist/{chunk-RYYEHWIL.js → chunk-CDBTQQQ4.js} +1 -1
- package/dist/{chunk-2K25MRZK.js → chunk-DTQAMME2.js} +5 -5
- package/dist/{chunk-BXBZDV3C.js → chunk-EKBVHDZO.js} +1 -1
- package/dist/{chunk-6BXV63YX.js → chunk-FEYQVP64.js} +5 -5
- package/dist/{chunk-H36GJVJV.js → chunk-FFE3BMAT.js} +7 -7
- package/dist/{chunk-LPLVNMVN.js → chunk-JDTCQDRU.js} +3 -3
- package/dist/{chunk-VHSEMJTS.js → chunk-JUFZR2LD.js} +1 -1
- package/dist/{chunk-RBV4JHCP.js → chunk-KQ5YZGDV.js} +1 -1
- package/dist/{chunk-4GTOFUQF.js → chunk-LGSGPWYH.js} +1 -1
- package/dist/{chunk-NLTQRYNP.js → chunk-MDW5YPXW.js} +2 -2
- package/dist/{chunk-5FWQ73UZ.js → chunk-OCOGPNHA.js} +1 -1
- package/dist/{chunk-JW23XD4I.js → chunk-OYN45QUQ.js} +6 -6
- package/dist/{chunk-VV2DN24T.js → chunk-P6UQMGM2.js} +1 -1
- package/dist/{chunk-RJHZNPDH.js → chunk-Q2IPCX7J.js} +45 -282
- package/dist/{chunk-7WKWMMYQ.js → chunk-SLWGX3G5.js} +93 -85
- package/dist/{chunk-CGCNFEAU.js → chunk-U2UCDSDF.js} +4 -4
- package/dist/{chunk-RULIISEI.js → chunk-VNPG55CU.js} +1 -1
- package/dist/{chunk-YHCTPDXS.js → chunk-WX42YNDQ.js} +67 -24
- package/dist/{chunk-5GLGQHO3.js → chunk-YTIKGCPC.js} +2 -1
- package/dist/{chunk-NAGI2XH3.js → chunk-ZKJO4K6M.js} +4 -4
- package/dist/cli/chat.js +30 -29
- package/dist/cli/check.js +6 -6
- package/dist/cli/plugins.js +12 -12
- package/dist/cli/snapshot-create.js +12 -10
- package/dist/cli/upgrade.js +7 -7
- package/dist/db/schema/workspaces.d.ts +68 -17
- package/dist/db/schema.d.ts +68 -17
- package/dist/{db-32KRFS6L.js → db-TGZBS2CP.js} +7 -7
- package/dist/instrumentation.js +4 -4
- package/dist/nitro.js +2 -2
- package/dist/{oauth-callback-server-CGZP2Z6U.js → oauth-callback-server-Z54WUF5H.js} +22 -22
- package/dist/{runner-S5N4Q2XL.js → runner-PVFHKKK6.js} +12 -12
- package/dist/{skills-KYPSHSQR.js → skills-BYRH3QWD.js} +6 -6
- package/dist/spawn-RIPWK7EP.js +37 -0
- package/dist/{validation-SZBE7JNF.js → validation-VZIE4RHA.js} +6 -6
- package/dist/version.js +1 -1
- package/dist/{work-GCZKHEZX.js → work-JTHAOPDQ.js} +17 -17
- package/dist/worker-APEVP56Y.js +24 -0
- package/migrations/0030_drop_workspace_repo_primary.sql +2 -0
- package/migrations/0031_wild_phantom_reporter.sql +4 -0
- package/migrations/meta/0030_snapshot.json +2799 -0
- package/migrations/meta/0031_snapshot.json +2823 -0
- package/migrations/meta/_journal.json +15 -1
- package/package.json +6 -5
- package/dist/spawn-EGOB3CLV.js +0 -37
- package/dist/worker-6MY5Q4A2.js +0 -24
|
@@ -7,12 +7,12 @@ import {
|
|
|
7
7
|
juniorConversations,
|
|
8
8
|
juniorIdentities,
|
|
9
9
|
juniorUsers
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-65SNO3WK.js";
|
|
11
11
|
import {
|
|
12
12
|
TURN_REASONING_LEVELS,
|
|
13
13
|
getChatConfig,
|
|
14
14
|
modelProfileSchema
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-AEKBVJMV.js";
|
|
16
16
|
import {
|
|
17
17
|
juniorDestinations
|
|
18
18
|
} from "./chunk-VFUK3X5B.js";
|
|
@@ -23,7 +23,7 @@ import {
|
|
|
23
23
|
} from "./chunk-V7YE4WCP.js";
|
|
24
24
|
import {
|
|
25
25
|
normalizeIdentityEmail
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JUFZR2LD.js";
|
|
27
27
|
|
|
28
28
|
// src/chat/conversations/sql/store.ts
|
|
29
29
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
@@ -5,19 +5,19 @@ import {
|
|
|
5
5
|
isDmChannel,
|
|
6
6
|
normalizeSlackConversationId,
|
|
7
7
|
withSlackRetries
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-WX42YNDQ.js";
|
|
9
9
|
import {
|
|
10
10
|
parseDestination
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-JDTCQDRU.js";
|
|
12
12
|
import {
|
|
13
13
|
getStateAdapter
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-EKBVHDZO.js";
|
|
15
15
|
import {
|
|
16
16
|
normalizeSlackEmojiName
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-AEKBVJMV.js";
|
|
18
18
|
import {
|
|
19
19
|
pluginCatalogRuntime
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-VNPG55CU.js";
|
|
21
21
|
import {
|
|
22
22
|
parseSlackMessageTs,
|
|
23
23
|
parseSlackUserId
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
isRecord,
|
|
27
27
|
logInfo,
|
|
28
28
|
logWarn
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-JUFZR2LD.js";
|
|
30
30
|
|
|
31
31
|
// src/chat/slack/outbound.ts
|
|
32
32
|
var MAX_SLACK_MESSAGE_TEXT_CHARS = 4e4;
|
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
import {
|
|
2
|
+
create,
|
|
3
|
+
isStale
|
|
4
|
+
} from "./chunk-4DARCEZH.js";
|
|
1
5
|
import {
|
|
2
6
|
SANDBOX_WORKSPACE_ROOT,
|
|
3
7
|
runNonInteractiveCommand,
|
|
@@ -5,18 +9,15 @@ import {
|
|
|
5
9
|
} from "./chunk-BVREIWBD.js";
|
|
6
10
|
import {
|
|
7
11
|
getStateAdapter
|
|
8
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-EKBVHDZO.js";
|
|
9
13
|
import {
|
|
10
14
|
toOptionalTrimmed
|
|
11
|
-
} from "./chunk-
|
|
12
|
-
import {
|
|
13
|
-
pluginCatalogRuntime
|
|
14
|
-
} from "./chunk-RULIISEI.js";
|
|
15
|
+
} from "./chunk-AEKBVJMV.js";
|
|
15
16
|
import {
|
|
16
17
|
setSpanAttributes,
|
|
17
18
|
setSpanStatus,
|
|
18
19
|
withSpan
|
|
19
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-JUFZR2LD.js";
|
|
20
21
|
|
|
21
22
|
// src/chat/sandbox/resources.ts
|
|
22
23
|
var configuredResources;
|
|
@@ -50,266 +51,6 @@ function getSandboxResources() {
|
|
|
50
51
|
return configuredResources ?? resourcesFromEnv();
|
|
51
52
|
}
|
|
52
53
|
|
|
53
|
-
// src/chat/sandbox/snapshot/profile.ts
|
|
54
|
-
import { createHash } from "crypto";
|
|
55
|
-
|
|
56
|
-
// src/chat/sandbox/docker.ts
|
|
57
|
-
var DOCKER_DAEMON_JSON = `{
|
|
58
|
-
"storage-driver": "overlay2",
|
|
59
|
-
"live-restore": false
|
|
60
|
-
}
|
|
61
|
-
`;
|
|
62
|
-
var DOCKER_ENSURE_SCRIPT = `#!/bin/sh
|
|
63
|
-
set -eu
|
|
64
|
-
|
|
65
|
-
if [ "$(id -u)" -ne 0 ]; then
|
|
66
|
-
exec sudo -n "$0" "$@"
|
|
67
|
-
fi
|
|
68
|
-
|
|
69
|
-
SOCK=/var/run/docker.sock
|
|
70
|
-
PIDFILE=/var/run/docker.pid
|
|
71
|
-
LOG=/var/log/junior-dockerd.log
|
|
72
|
-
|
|
73
|
-
is_ready() {
|
|
74
|
-
[ -S "$SOCK" ] && /usr/bin/docker info >/dev/null 2>&1
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
if is_ready; then
|
|
78
|
-
chmod 666 "$SOCK" 2>/dev/null || true
|
|
79
|
-
exit 0
|
|
80
|
-
fi
|
|
81
|
-
|
|
82
|
-
mkdir -p /etc/docker /var/lib/docker /var/run /var/log
|
|
83
|
-
if [ ! -f /etc/docker/daemon.json ]; then
|
|
84
|
-
cat > /etc/docker/daemon.json <<'EOF'
|
|
85
|
-
{
|
|
86
|
-
"storage-driver": "overlay2",
|
|
87
|
-
"live-restore": false
|
|
88
|
-
}
|
|
89
|
-
EOF
|
|
90
|
-
fi
|
|
91
|
-
|
|
92
|
-
if [ -f "$PIDFILE" ]; then
|
|
93
|
-
oldpid="$(cat "$PIDFILE" 2>/dev/null || true)"
|
|
94
|
-
if [ -n "\${oldpid:-}" ] && ! kill -0 "$oldpid" 2>/dev/null; then
|
|
95
|
-
rm -f "$PIDFILE"
|
|
96
|
-
fi
|
|
97
|
-
fi
|
|
98
|
-
|
|
99
|
-
if [ ! -f "$PIDFILE" ] || ! kill -0 "$(cat "$PIDFILE" 2>/dev/null)" 2>/dev/null; then
|
|
100
|
-
# dockerd must outlive this helper; nohup + background is intentional.
|
|
101
|
-
nohup dockerd --host="unix://$SOCK" --pidfile="$PIDFILE" >"$LOG" 2>&1 &
|
|
102
|
-
fi
|
|
103
|
-
|
|
104
|
-
i=0
|
|
105
|
-
while [ "$i" -lt 50 ]; do
|
|
106
|
-
if is_ready; then
|
|
107
|
-
chmod 666 "$SOCK" 2>/dev/null || true
|
|
108
|
-
exit 0
|
|
109
|
-
fi
|
|
110
|
-
i=$((i + 1))
|
|
111
|
-
sleep 0.1
|
|
112
|
-
done
|
|
113
|
-
|
|
114
|
-
echo "junior-ensure-docker: dockerd failed to become ready" >&2
|
|
115
|
-
if [ -f "$LOG" ]; then
|
|
116
|
-
tail -n 50 "$LOG" >&2 || true
|
|
117
|
-
fi
|
|
118
|
-
exit 1
|
|
119
|
-
`;
|
|
120
|
-
var DOCKER_CLI_WRAPPER_SCRIPT = `#!/bin/sh
|
|
121
|
-
set -eu
|
|
122
|
-
if command -v junior-ensure-docker >/dev/null 2>&1; then
|
|
123
|
-
junior-ensure-docker
|
|
124
|
-
fi
|
|
125
|
-
exec /usr/bin/docker "$@"
|
|
126
|
-
`;
|
|
127
|
-
var DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT = `#!/bin/sh
|
|
128
|
-
set -eu
|
|
129
|
-
if command -v junior-ensure-docker >/dev/null 2>&1; then
|
|
130
|
-
junior-ensure-docker
|
|
131
|
-
fi
|
|
132
|
-
exec /usr/local/libexec/junior-docker-compose "$@"
|
|
133
|
-
`;
|
|
134
|
-
async function ensureDockerDaemon(sandbox, signal) {
|
|
135
|
-
await runNonInteractiveCommand(sandbox, {
|
|
136
|
-
cmd: "sh",
|
|
137
|
-
args: [
|
|
138
|
-
"-c",
|
|
139
|
-
"command -v junior-ensure-docker >/dev/null 2>&1 && junior-ensure-docker || true"
|
|
140
|
-
],
|
|
141
|
-
signal
|
|
142
|
-
});
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
// src/chat/sandbox/runtime-dependencies.ts
|
|
146
|
-
var GLOBAL_RUNTIME_DEPENDENCIES = [
|
|
147
|
-
{ type: "system", package: "docker" },
|
|
148
|
-
{ type: "system", package: "spal-release" },
|
|
149
|
-
{ type: "system", package: "ripgrep" }
|
|
150
|
-
];
|
|
151
|
-
function writeFileCommand(path, contents, mode = "0644") {
|
|
152
|
-
const payload = Buffer.from(contents, "utf8").toString("base64");
|
|
153
|
-
return [
|
|
154
|
-
`printf '%s' '${payload}' | base64 -d > ${path}`,
|
|
155
|
-
`chmod ${mode} ${path}`
|
|
156
|
-
].join("\n");
|
|
157
|
-
}
|
|
158
|
-
function writeExecutableCommand(path, contents) {
|
|
159
|
-
return writeFileCommand(path, contents, "0755");
|
|
160
|
-
}
|
|
161
|
-
var GLOBAL_RUNTIME_POSTINSTALL = [
|
|
162
|
-
{
|
|
163
|
-
cmd: "sh",
|
|
164
|
-
args: [
|
|
165
|
-
"-c",
|
|
166
|
-
[
|
|
167
|
-
"set -eu",
|
|
168
|
-
'case "$(uname -m)" in',
|
|
169
|
-
' x86_64) asset="x86_64"; sha256="7af95166a730b87e172d4fc9aefea8725d3c6c7327d59149267b452114ddb7d4" ;;',
|
|
170
|
-
' aarch64) asset="aarch64"; sha256="49082844b87f03cdcd5f5bbef1ba8c9c897b7a2dfb80cea18d61ec8ca6117e0c" ;;',
|
|
171
|
-
' *) echo "unsupported Docker Compose architecture: $(uname -m)" >&2; exit 1 ;;',
|
|
172
|
-
"esac",
|
|
173
|
-
'tmp="$(mktemp)"',
|
|
174
|
-
`trap 'rm -f "$tmp"' EXIT`,
|
|
175
|
-
'curl --fail --location --silent --show-error "https://github.com/docker/compose/releases/download/v2.39.4/docker-compose-linux-${asset}" --output "$tmp"',
|
|
176
|
-
'echo "${sha256} ${tmp}" | sha256sum --check --status',
|
|
177
|
-
// Keep the real Compose binary off PATH; the wrapper below starts dockerd.
|
|
178
|
-
'install -D -m 0755 "$tmp" /usr/local/libexec/junior-docker-compose',
|
|
179
|
-
"mkdir -p /usr/local/lib/docker/cli-plugins /usr/local/libexec /etc/docker /usr/local/bin",
|
|
180
|
-
`mkdir -p ${SANDBOX_WORKSPACE_ROOT}/.junior/bin`,
|
|
181
|
-
writeFileCommand("/etc/docker/daemon.json", DOCKER_DAEMON_JSON),
|
|
182
|
-
writeExecutableCommand(
|
|
183
|
-
"/usr/local/bin/junior-ensure-docker",
|
|
184
|
-
DOCKER_ENSURE_SCRIPT
|
|
185
|
-
),
|
|
186
|
-
// docker compose plugin delegates to the real Compose binary.
|
|
187
|
-
"ln -sfn /usr/local/libexec/junior-docker-compose /usr/local/lib/docker/cli-plugins/docker-compose",
|
|
188
|
-
// PATH wrappers auto-start dockerd for both CLI entrypoints.
|
|
189
|
-
writeExecutableCommand(
|
|
190
|
-
"/usr/local/bin/docker-compose",
|
|
191
|
-
DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT
|
|
192
|
-
),
|
|
193
|
-
writeExecutableCommand(
|
|
194
|
-
`${SANDBOX_WORKSPACE_ROOT}/.junior/bin/docker`,
|
|
195
|
-
DOCKER_CLI_WRAPPER_SCRIPT
|
|
196
|
-
),
|
|
197
|
-
writeExecutableCommand(
|
|
198
|
-
`${SANDBOX_WORKSPACE_ROOT}/.junior/bin/docker-compose`,
|
|
199
|
-
DOCKER_COMPOSE_CLI_WRAPPER_SCRIPT
|
|
200
|
-
),
|
|
201
|
-
// Prefer the wrapper over /usr/bin/docker for non-login shells too.
|
|
202
|
-
writeExecutableCommand(
|
|
203
|
-
"/usr/local/bin/docker",
|
|
204
|
-
DOCKER_CLI_WRAPPER_SCRIPT
|
|
205
|
-
)
|
|
206
|
-
].join("\n")
|
|
207
|
-
],
|
|
208
|
-
sudo: true
|
|
209
|
-
}
|
|
210
|
-
];
|
|
211
|
-
|
|
212
|
-
// src/chat/sandbox/snapshot/profile.ts
|
|
213
|
-
var VERSION = 1;
|
|
214
|
-
var DEFAULT_FLOATING_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
215
|
-
function isExactNpmVersion(version) {
|
|
216
|
-
return /^\d+\.\d+\.\d+(?:[-+][a-z0-9.]+)?$/i.test(version.trim());
|
|
217
|
-
}
|
|
218
|
-
function isFloating(dep) {
|
|
219
|
-
return dep.type === "npm" && !isExactNpmVersion(dep.version);
|
|
220
|
-
}
|
|
221
|
-
function mergeDependencies(dependencies2) {
|
|
222
|
-
const seen = /* @__PURE__ */ new Set();
|
|
223
|
-
const npmVersions = /* @__PURE__ */ new Map();
|
|
224
|
-
const merged = [];
|
|
225
|
-
for (const dependency of dependencies2) {
|
|
226
|
-
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}`;
|
|
227
|
-
if (seen.has(key)) {
|
|
228
|
-
continue;
|
|
229
|
-
}
|
|
230
|
-
seen.add(key);
|
|
231
|
-
if (dependency.type === "npm") {
|
|
232
|
-
const version = npmVersions.get(dependency.package);
|
|
233
|
-
if (version !== void 0 && version !== dependency.version) {
|
|
234
|
-
throw new Error(
|
|
235
|
-
`Conflicting runtime dependency versions for ${dependency.package}: ${version} and ${dependency.version}`
|
|
236
|
-
);
|
|
237
|
-
}
|
|
238
|
-
npmVersions.set(dependency.package, dependency.version);
|
|
239
|
-
}
|
|
240
|
-
merged.push(dependency);
|
|
241
|
-
}
|
|
242
|
-
return merged;
|
|
243
|
-
}
|
|
244
|
-
function floatingMaxAgeMs() {
|
|
245
|
-
const raw = process.env.SANDBOX_SNAPSHOT_FLOATING_MAX_AGE_MS;
|
|
246
|
-
if (!raw?.trim()) {
|
|
247
|
-
return DEFAULT_FLOATING_MAX_AGE_MS;
|
|
248
|
-
}
|
|
249
|
-
const parsed = Number.parseInt(raw, 10);
|
|
250
|
-
return Number.isFinite(parsed) && parsed >= 0 ? parsed : DEFAULT_FLOATING_MAX_AGE_MS;
|
|
251
|
-
}
|
|
252
|
-
function compareCodePoints(left, right) {
|
|
253
|
-
if (left < right) return -1;
|
|
254
|
-
if (left > right) return 1;
|
|
255
|
-
return 0;
|
|
256
|
-
}
|
|
257
|
-
function workspaceRecipe(workspace) {
|
|
258
|
-
const repos = [...workspace.repos].map(({ provider, repo }) => ({
|
|
259
|
-
provider,
|
|
260
|
-
repo
|
|
261
|
-
})).sort((left, right) => {
|
|
262
|
-
const provider = compareCodePoints(left.provider, right.provider);
|
|
263
|
-
if (provider !== 0) return provider;
|
|
264
|
-
return compareCodePoints(left.repo, right.repo);
|
|
265
|
-
});
|
|
266
|
-
return {
|
|
267
|
-
id: workspace.id,
|
|
268
|
-
repos,
|
|
269
|
-
setupScript: workspace.setupScript
|
|
270
|
-
};
|
|
271
|
-
}
|
|
272
|
-
function create(runtime, workspace) {
|
|
273
|
-
const dependencies2 = mergeDependencies([
|
|
274
|
-
...GLOBAL_RUNTIME_DEPENDENCIES,
|
|
275
|
-
...pluginCatalogRuntime.getRuntimeDependencies()
|
|
276
|
-
]);
|
|
277
|
-
const pluginPostinstall = pluginCatalogRuntime.getRuntimePostinstall();
|
|
278
|
-
const postinstall2 = [...GLOBAL_RUNTIME_POSTINSTALL, ...pluginPostinstall];
|
|
279
|
-
if (dependencies2.length === 0 && postinstall2.length === 0 && !workspace) {
|
|
280
|
-
return null;
|
|
281
|
-
}
|
|
282
|
-
const rebuildEpoch = process.env.SANDBOX_SNAPSHOT_REBUILD_EPOCH?.trim() ?? "";
|
|
283
|
-
const floating = dependencies2.some((dependency) => isFloating(dependency)) || pluginPostinstall.length > 0 || Boolean(workspace);
|
|
284
|
-
const hash2 = createHash("sha256").update(
|
|
285
|
-
JSON.stringify({
|
|
286
|
-
version: VERSION,
|
|
287
|
-
runtime,
|
|
288
|
-
rebuildEpoch,
|
|
289
|
-
dependencies: dependencies2,
|
|
290
|
-
postinstall: postinstall2,
|
|
291
|
-
...workspace ? { workspace: workspaceRecipe(workspace) } : {}
|
|
292
|
-
})
|
|
293
|
-
).digest("hex");
|
|
294
|
-
return {
|
|
295
|
-
hash: hash2,
|
|
296
|
-
dependencyCount: dependencies2.length,
|
|
297
|
-
floating,
|
|
298
|
-
dependencies: dependencies2,
|
|
299
|
-
postinstall: postinstall2
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
function hash(runtime, workspace) {
|
|
303
|
-
return create(runtime, workspace)?.hash;
|
|
304
|
-
}
|
|
305
|
-
function isStale(profile, createdAtMs) {
|
|
306
|
-
if (!profile.floating) {
|
|
307
|
-
return false;
|
|
308
|
-
}
|
|
309
|
-
const maxAgeMs = floatingMaxAgeMs();
|
|
310
|
-
return maxAgeMs === 0 || Date.now() - createdAtMs > maxAgeMs;
|
|
311
|
-
}
|
|
312
|
-
|
|
313
54
|
// src/chat/sandbox/snapshot/resolve.ts
|
|
314
55
|
import { Sandbox } from "@vercel/sandbox";
|
|
315
56
|
import { z } from "zod";
|
|
@@ -882,7 +623,7 @@ async function stopSession(session) {
|
|
|
882
623
|
}
|
|
883
624
|
|
|
884
625
|
// src/chat/sandbox/snapshot/resolve.ts
|
|
885
|
-
var SNAPSHOT_CACHE_PREFIX = "junior:sandbox_snapshot_profile";
|
|
626
|
+
var SNAPSHOT_CACHE_PREFIX = "junior:sandbox_snapshot_profile:v2";
|
|
886
627
|
var SNAPSHOT_LOCK_PREFIX = "junior:sandbox_snapshot_lock";
|
|
887
628
|
var SNAPSHOT_CACHE_TTL_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
888
629
|
var SNAPSHOT_BUILD_LOCK_BUFFER_MS = 30 * 1e3;
|
|
@@ -892,7 +633,8 @@ var cachedSnapshotSchema = z.object({
|
|
|
892
633
|
snapshotId: z.string(),
|
|
893
634
|
runtime: z.string(),
|
|
894
635
|
createdAtMs: z.number(),
|
|
895
|
-
dependencyCount: z.number()
|
|
636
|
+
dependencyCount: z.number(),
|
|
637
|
+
buildDurationMs: z.number().int().nonnegative()
|
|
896
638
|
}).strict();
|
|
897
639
|
function profileCacheKey(profileHash) {
|
|
898
640
|
return `${SNAPSHOT_CACHE_PREFIX}:${profileHash}`;
|
|
@@ -937,6 +679,7 @@ async function build(value, runtime, timeoutMs, signal, prepare) {
|
|
|
937
679
|
"app.sandbox.snapshot.dependency_count": value.dependencyCount
|
|
938
680
|
},
|
|
939
681
|
async () => {
|
|
682
|
+
const startedAtMs = Date.now();
|
|
940
683
|
const sandboxCredentials = getVercelSandboxCredentials();
|
|
941
684
|
const resources = getSandboxResources();
|
|
942
685
|
const sandbox = createSandboxSession(
|
|
@@ -952,7 +695,7 @@ async function build(value, runtime, timeoutMs, signal, prepare) {
|
|
|
952
695
|
await dependencies(sandbox, value.dependencies, signal);
|
|
953
696
|
await postinstall(sandbox, value.postinstall, signal);
|
|
954
697
|
await prepare?.(sandbox);
|
|
955
|
-
|
|
698
|
+
const snapshotId = await trace(
|
|
956
699
|
"sandbox.snapshot.capture",
|
|
957
700
|
"sandbox.snapshot.capture",
|
|
958
701
|
{
|
|
@@ -963,6 +706,10 @@ async function build(value, runtime, timeoutMs, signal, prepare) {
|
|
|
963
706
|
return snapshot.snapshotId;
|
|
964
707
|
}
|
|
965
708
|
);
|
|
709
|
+
return {
|
|
710
|
+
snapshotId,
|
|
711
|
+
buildDurationMs: Math.max(0, Date.now() - startedAtMs)
|
|
712
|
+
};
|
|
966
713
|
} finally {
|
|
967
714
|
try {
|
|
968
715
|
await sandbox.stop();
|
|
@@ -1002,7 +749,9 @@ async function withBuildLock(profileHash, timeoutMs, callback, canUseCachedSnaps
|
|
|
1002
749
|
if (cached2?.snapshotId && canUseCachedSnapshot(cached2)) {
|
|
1003
750
|
return {
|
|
1004
751
|
snapshotId: cached2.snapshotId,
|
|
1005
|
-
source: "cache_hit_after_lock_wait"
|
|
752
|
+
source: "cache_hit_after_lock_wait",
|
|
753
|
+
createdAtMs: cached2.createdAtMs,
|
|
754
|
+
buildDurationMs: cached2.buildDurationMs
|
|
1006
755
|
};
|
|
1007
756
|
}
|
|
1008
757
|
lock = await tryAcquireLock();
|
|
@@ -1011,7 +760,9 @@ async function withBuildLock(profileHash, timeoutMs, callback, canUseCachedSnaps
|
|
|
1011
760
|
const result = await callback();
|
|
1012
761
|
return {
|
|
1013
762
|
snapshotId: result.snapshotId,
|
|
1014
|
-
source: result.source === "built" ? "built" : "cache_hit_after_lock_wait"
|
|
763
|
+
source: result.source === "built" ? "built" : "cache_hit_after_lock_wait",
|
|
764
|
+
createdAtMs: result.createdAtMs,
|
|
765
|
+
buildDurationMs: result.buildDurationMs
|
|
1015
766
|
};
|
|
1016
767
|
} finally {
|
|
1017
768
|
await state.releaseLock(lock);
|
|
@@ -1024,7 +775,9 @@ async function withBuildLock(profileHash, timeoutMs, callback, canUseCachedSnaps
|
|
|
1024
775
|
if (cached?.snapshotId && canUseCachedSnapshot(cached)) {
|
|
1025
776
|
return {
|
|
1026
777
|
snapshotId: cached.snapshotId,
|
|
1027
|
-
source: "cache_hit_after_lock_wait"
|
|
778
|
+
source: "cache_hit_after_lock_wait",
|
|
779
|
+
createdAtMs: cached.createdAtMs,
|
|
780
|
+
buildDurationMs: cached.buildDurationMs
|
|
1028
781
|
};
|
|
1029
782
|
}
|
|
1030
783
|
throw new Error("Timed out waiting for snapshot build lock");
|
|
@@ -1079,7 +832,9 @@ async function resolve(params) {
|
|
|
1079
832
|
profileHash: currentProfile.hash,
|
|
1080
833
|
dependencyCount: currentProfile.dependencyCount,
|
|
1081
834
|
cacheHit: true,
|
|
1082
|
-
resolveOutcome: "cache_hit"
|
|
835
|
+
resolveOutcome: "cache_hit",
|
|
836
|
+
createdAtMs: cached.createdAtMs,
|
|
837
|
+
buildDurationMs: cached.buildDurationMs
|
|
1083
838
|
};
|
|
1084
839
|
}
|
|
1085
840
|
const rebuildReason = getRebuildReason({
|
|
@@ -1106,26 +861,35 @@ async function resolve(params) {
|
|
|
1106
861
|
await params.onProgress?.("cache_hit");
|
|
1107
862
|
return {
|
|
1108
863
|
snapshotId: latest.snapshotId,
|
|
1109
|
-
source: "cache_hit"
|
|
864
|
+
source: "cache_hit",
|
|
865
|
+
createdAtMs: latest.createdAtMs,
|
|
866
|
+
buildDurationMs: latest.buildDurationMs
|
|
1110
867
|
};
|
|
1111
868
|
}
|
|
1112
869
|
await params.onProgress?.("building_snapshot");
|
|
1113
|
-
const
|
|
870
|
+
const built = await build(
|
|
1114
871
|
currentProfile,
|
|
1115
872
|
params.runtime,
|
|
1116
873
|
params.timeoutMs,
|
|
1117
874
|
params.signal,
|
|
1118
875
|
params.prepareWorkspace
|
|
1119
876
|
);
|
|
877
|
+
const createdAtMs = Date.now();
|
|
1120
878
|
await setCachedSnapshot({
|
|
1121
879
|
profileHash: currentProfile.hash,
|
|
1122
|
-
snapshotId:
|
|
880
|
+
snapshotId: built.snapshotId,
|
|
1123
881
|
runtime: params.runtime,
|
|
1124
|
-
createdAtMs
|
|
1125
|
-
dependencyCount: currentProfile.dependencyCount
|
|
882
|
+
createdAtMs,
|
|
883
|
+
dependencyCount: currentProfile.dependencyCount,
|
|
884
|
+
buildDurationMs: built.buildDurationMs
|
|
1126
885
|
});
|
|
1127
886
|
await params.onProgress?.("build_complete");
|
|
1128
|
-
return {
|
|
887
|
+
return {
|
|
888
|
+
snapshotId: built.snapshotId,
|
|
889
|
+
source: "built",
|
|
890
|
+
createdAtMs,
|
|
891
|
+
buildDurationMs: built.buildDurationMs
|
|
892
|
+
};
|
|
1129
893
|
},
|
|
1130
894
|
canUseCachedSnapshot,
|
|
1131
895
|
async () => {
|
|
@@ -1142,6 +906,8 @@ async function resolve(params) {
|
|
|
1142
906
|
Boolean(params.forceRebuild),
|
|
1143
907
|
lockResult.source
|
|
1144
908
|
),
|
|
909
|
+
createdAtMs: lockResult.createdAtMs,
|
|
910
|
+
buildDurationMs: lockResult.buildDurationMs,
|
|
1145
911
|
...rebuildReason ? { rebuildReason } : {}
|
|
1146
912
|
};
|
|
1147
913
|
}
|
|
@@ -1161,12 +927,9 @@ export {
|
|
|
1161
927
|
wrapSandboxSetupError,
|
|
1162
928
|
throwSandboxOperationError,
|
|
1163
929
|
getVercelSandboxCredentials,
|
|
1164
|
-
ensureDockerDaemon,
|
|
1165
930
|
getSandboxResourceConfig,
|
|
1166
931
|
setSandboxResourceConfig,
|
|
1167
932
|
getSandboxResources,
|
|
1168
|
-
create,
|
|
1169
|
-
hash,
|
|
1170
933
|
bindSandboxFileSystem,
|
|
1171
934
|
createSandboxSession,
|
|
1172
935
|
stopSession,
|