@agentstep/agent-sdk 0.4.13 → 0.4.14
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/auth/middleware.js +6 -6
- package/dist/backends/claude/args.js +6 -6
- package/dist/backends/claude/index.js +8 -8
- package/dist/backends/claude/wrapper-script.js +1 -1
- package/dist/backends/codex/auth.js +6 -6
- package/dist/backends/codex/index.js +11 -11
- package/dist/backends/codex/setup.js +4 -4
- package/dist/backends/codex/wrapper-script.js +1 -1
- package/dist/backends/factory/auth.js +6 -6
- package/dist/backends/factory/index.js +11 -11
- package/dist/backends/factory/setup.js +4 -4
- package/dist/backends/factory/wrapper-script.js +1 -1
- package/dist/backends/gemini/auth.js +6 -6
- package/dist/backends/gemini/index.js +11 -11
- package/dist/backends/gemini/setup.js +4 -4
- package/dist/backends/gemini/wrapper-script.js +1 -1
- package/dist/backends/opencode/auth.js +6 -6
- package/dist/backends/opencode/index.js +11 -11
- package/dist/backends/opencode/setup.js +4 -4
- package/dist/backends/opencode/wrapper-script.js +1 -1
- package/dist/backends/pi/auth.js +6 -6
- package/dist/backends/pi/index.js +11 -11
- package/dist/backends/pi/setup.js +4 -4
- package/dist/backends/pi/wrapper-script.js +1 -1
- package/dist/backends/registry.js +29 -29
- package/dist/{chunk-7YYEE7XR.js → chunk-24NL6GPL.js} +5 -5
- package/dist/{chunk-5GDMWWYD.js → chunk-2BDD6OHG.js} +10 -2
- package/dist/{chunk-XLVCC4IB.js → chunk-374KGHBM.js} +5 -5
- package/dist/{chunk-ME6IR4T6.js → chunk-3W6KEDQE.js} +4 -4
- package/dist/{chunk-4INVRCRD.js → chunk-42O6EBUN.js} +2 -2
- package/dist/{chunk-LP7AQJCU.js → chunk-4MHPOB7A.js} +3 -3
- package/dist/{chunk-DZDWNOEY.js → chunk-5GZEX4HV.js} +1 -1
- package/dist/{chunk-MAW3HLIO.js → chunk-6NZPNYHA.js} +2 -2
- package/dist/{chunk-3KDZP45U.js → chunk-6QQKTF55.js} +11 -8
- package/dist/{chunk-U4F4JSME.js → chunk-7GPKEOAO.js} +3 -3
- package/dist/{chunk-JZ5RFO77.js → chunk-7LQN7NVU.js} +5 -5
- package/dist/{chunk-X3U7IVTN.js → chunk-7OAMTB47.js} +2 -2
- package/dist/{chunk-JFY6EH24.js → chunk-A7MX6RSQ.js} +15 -15
- package/dist/{chunk-IJEZAD5O.js → chunk-ADK2TYO4.js} +2 -2
- package/dist/{chunk-PMEF3X3C.js → chunk-B47IDF63.js} +2 -2
- package/dist/{chunk-RTS2QUZB.js → chunk-B6LPLXPB.js} +8 -8
- package/dist/{chunk-V7OXXKAL.js → chunk-BZ6HFTHU.js} +1 -1
- package/dist/{chunk-I3AP3LEY.js → chunk-CDK25PRU.js} +5 -5
- package/dist/{chunk-TSYQ4XKJ.js → chunk-CSNIN5YZ.js} +2 -2
- package/dist/{chunk-3WJMUX5B.js → chunk-DO4WVWW7.js} +1 -1
- package/dist/{chunk-4FHRWC4H.js → chunk-EDRLRJNT.js} +5 -5
- package/dist/{chunk-AKRE4OEL.js → chunk-EFOIR7R3.js} +5 -3
- package/dist/{chunk-MXRGQRFX.js → chunk-EOFJ2MWJ.js} +4 -4
- package/dist/{chunk-TV2VE2LX.js → chunk-F6M4RLDQ.js} +2 -2
- package/dist/{chunk-NHY4Q6LS.js → chunk-F7DOI3B5.js} +12 -12
- package/dist/{chunk-6BDLNY5J.js → chunk-FVFMYO5W.js} +2 -2
- package/dist/{chunk-KDAZ5TBL.js → chunk-G37JVAOI.js} +5 -5
- package/dist/{chunk-OQWHKEYE.js → chunk-GAFFXICQ.js} +3 -3
- package/dist/{chunk-VVH5DQ2C.js → chunk-GCMYVWZ6.js} +1 -1
- package/dist/{chunk-TQHS4W74.js → chunk-GGYTAWW6.js} +1 -1
- package/dist/{chunk-3NZQBGUJ.js → chunk-GHDY4DVK.js} +13 -13
- package/dist/{chunk-UVCPCX74.js → chunk-GR4QPRB7.js} +5 -5
- package/dist/{chunk-OHYPVKTP.js → chunk-GSODOHNB.js} +4 -4
- package/dist/{chunk-Q4XYK6FF.js → chunk-HE7EOIPA.js} +5 -5
- package/dist/{chunk-KEV4OMRF.js → chunk-HIDFQDFP.js} +9 -9
- package/dist/{chunk-ZA4JVJJE.js → chunk-HOPCVGWL.js} +1 -1
- package/dist/{chunk-3MNDEAPX.js → chunk-HR5YA24J.js} +5 -5
- package/dist/{chunk-MBLMAWSE.js → chunk-I5ZA45YL.js} +7 -7
- package/dist/{chunk-TH54MJMX.js → chunk-IEG5LIX7.js} +1 -1
- package/dist/{chunk-X7W6S3TE.js → chunk-IU457W7Q.js} +5 -5
- package/dist/{chunk-HWTECG57.js → chunk-J4TYHQQG.js} +1 -1
- package/dist/{chunk-Y2SC7HU5.js → chunk-JDBXIJKG.js} +4 -4
- package/dist/{chunk-FDY5BA67.js → chunk-JDELTTHV.js} +1 -1
- package/dist/{chunk-BAH4JSTO.js → chunk-JEI7I3EH.js} +3 -3
- package/dist/{chunk-CKPGSS76.js → chunk-JK5TPJHH.js} +1 -1
- package/dist/{chunk-CX4VNHL6.js → chunk-K2ITIAVJ.js} +73 -31
- package/dist/{chunk-UX6I36QR.js → chunk-LDKZ2SMC.js} +122 -122
- package/dist/{chunk-N5CUDEUJ.js → chunk-LHHBOQUR.js} +2 -2
- package/dist/{chunk-6QDHS2MR.js → chunk-LUQP36Y3.js} +1 -1
- package/dist/{chunk-ETGRQMFJ.js → chunk-M5QX5E5Z.js} +1 -1
- package/dist/{chunk-QKRWCXDU.js → chunk-M674W5NT.js} +1 -1
- package/dist/{chunk-UXZSRUXD.js → chunk-MEEY7BYC.js} +2 -2
- package/dist/{chunk-FXLGGDLM.js → chunk-MFEOQ26S.js} +4 -4
- package/dist/{chunk-RL6XEYOD.js → chunk-MHQXDTJB.js} +1 -1
- package/dist/{chunk-YOFB6CO5.js → chunk-MOLWE2ZY.js} +7 -7
- package/dist/{chunk-6UXT3RG5.js → chunk-MRJMXGCG.js} +4 -4
- package/dist/{chunk-5A6E4F5D.js → chunk-N2RHTKW7.js} +2 -1
- package/dist/{chunk-YM2LYRYY.js → chunk-NCUIEBQY.js} +3 -3
- package/dist/{chunk-7BGILLYC.js → chunk-NIOWKTIF.js} +2 -2
- package/dist/{chunk-OXREXXAQ.js → chunk-NUINUAXO.js} +2 -2
- package/dist/{chunk-XTZ5RQDF.js → chunk-NUO56TF7.js} +4 -4
- package/dist/{chunk-ZIV74JWW.js → chunk-NXRJ7Z4G.js} +2 -2
- package/dist/{chunk-AHHH4PYB.js → chunk-O45IQUWS.js} +3 -3
- package/dist/{chunk-QYFD2OBI.js → chunk-OWTXN2FU.js} +1 -1
- package/dist/{chunk-V4P46OHG.js → chunk-P7P2NWZD.js} +5 -5
- package/dist/{chunk-FB6FOIAY.js → chunk-PCKFMALU.js} +1 -1
- package/dist/{chunk-2FWZ247V.js → chunk-PFLR7INE.js} +2 -2
- package/dist/{chunk-M4RE42AY.js → chunk-PGSOOOB4.js} +3 -3
- package/dist/{chunk-2PKJSOXX.js → chunk-PTGANYUM.js} +1 -1
- package/dist/{chunk-WUNJJNOV.js → chunk-Q3CV35V6.js} +4 -4
- package/dist/{chunk-6A74MTSB.js → chunk-QICG4KW4.js} +3 -3
- package/dist/{chunk-2QGVGXIT.js → chunk-QQDSHL27.js} +4 -4
- package/dist/{chunk-3EGA6TEL.js → chunk-QSYXHYQU.js} +1 -1
- package/dist/{chunk-J4NKW3L5.js → chunk-QYSDP6V5.js} +5 -5
- package/dist/{chunk-LPWEFC55.js → chunk-R5OZHLAD.js} +2 -2
- package/dist/{chunk-CU5GUNFW.js → chunk-R6X47I23.js} +2 -2
- package/dist/{chunk-XLMHG3KR.js → chunk-R7PAZ5OA.js} +38 -35
- package/dist/{chunk-DFE7VZWD.js → chunk-RMEX55EU.js} +4 -4
- package/dist/{chunk-D5XOXR3A.js → chunk-S3SKODVV.js} +4 -4
- package/dist/{chunk-OGONPLTA.js → chunk-SHKBQQ7W.js} +6 -6
- package/dist/{chunk-5ZRGJTR3.js → chunk-SNZ4PDVT.js} +6 -6
- package/dist/{chunk-JMDS2RJJ.js → chunk-SS2EEKNM.js} +1 -1
- package/dist/{chunk-7XFIUYFM.js → chunk-SWIP7JBQ.js} +4 -4
- package/dist/{chunk-XNK2KUTI.js → chunk-SXE7H3VK.js} +2 -2
- package/dist/{chunk-G5RQN53K.js → chunk-TBSWWUJS.js} +1 -1
- package/dist/{chunk-TY7XTT5N.js → chunk-TJA3RHWR.js} +1 -1
- package/dist/{chunk-4BYPJFC5.js → chunk-UF25F3MH.js} +56 -48
- package/dist/{chunk-V364DYC3.js → chunk-UVUSSZ74.js} +1 -1
- package/dist/{chunk-HERWBOQ7.js → chunk-V7WEALLX.js} +5 -5
- package/dist/{chunk-UN3LHCWQ.js → chunk-VIGJQU6V.js} +3 -3
- package/dist/{chunk-7TW4LHPM.js → chunk-X37MWWUA.js} +2 -2
- package/dist/{chunk-W3M3ME6B.js → chunk-XG4UIGDH.js} +5 -5
- package/dist/{chunk-Q5KHBU7P.js → chunk-YEUALILD.js} +3 -3
- package/dist/{chunk-KZGAZPNV.js → chunk-YGAHGTVZ.js} +3 -3
- package/dist/{chunk-6ZJ6X6H7.js → chunk-YIYEPKVQ.js} +1 -1
- package/dist/{chunk-BM34UHSS.js → chunk-YJPQFLY3.js} +4 -4
- package/dist/{chunk-H74BPBKE.js → chunk-YSUPRYX2.js} +5 -5
- package/dist/{chunk-Y5553CX6.js → chunk-ZP5VMV5O.js} +4 -4
- package/dist/config/index.js +5 -5
- package/dist/containers/client.js +6 -6
- package/dist/containers/exec.js +6 -6
- package/dist/containers/lifecycle.js +46 -46
- package/dist/containers/pool.js +3 -3
- package/dist/containers/setup.js +9 -9
- package/dist/db/agents.js +6 -6
- package/dist/db/api_keys.js +5 -5
- package/dist/db/audit.js +3 -3
- package/dist/db/batch.js +10 -10
- package/dist/db/client.js +2 -2
- package/dist/db/credentials.js +3 -3
- package/dist/db/drizzle.js +4 -4
- package/dist/db/environments.js +6 -6
- package/dist/db/events.js +5 -5
- package/dist/db/files.js +5 -5
- package/dist/db/memory.js +5 -5
- package/dist/db/migrations.js +1 -1
- package/dist/db/proxy.js +5 -5
- package/dist/db/schema.js +1 -1
- package/dist/db/session-resources.js +5 -5
- package/dist/db/sessions.js +9 -9
- package/dist/db/sync.js +5 -5
- package/dist/db/tenants.js +3 -3
- package/dist/db/traces.js +5 -5
- package/dist/db/upstream_keys.js +3 -3
- package/dist/db/vaults.js +6 -6
- package/dist/handlers/agents.js +57 -57
- package/dist/handlers/api_keys.js +57 -57
- package/dist/handlers/audit.js +57 -57
- package/dist/handlers/batch.js +57 -57
- package/dist/handlers/credentials.js +57 -57
- package/dist/handlers/environments.js +58 -58
- package/dist/handlers/events.js +61 -61
- package/dist/handlers/files.js +57 -57
- package/dist/handlers/index.js +97 -97
- package/dist/handlers/license.js +56 -56
- package/dist/handlers/memory.js +57 -57
- package/dist/handlers/metrics.js +56 -56
- package/dist/handlers/models.js +57 -57
- package/dist/handlers/openapi.js +3 -3
- package/dist/handlers/providers.js +56 -56
- package/dist/handlers/resources.js +56 -56
- package/dist/handlers/sessions.js +60 -60
- package/dist/handlers/settings.js +56 -56
- package/dist/handlers/skills-write.js +56 -56
- package/dist/handlers/skills.js +57 -57
- package/dist/handlers/stream.js +57 -57
- package/dist/handlers/tenants.js +57 -57
- package/dist/handlers/threads.js +56 -56
- package/dist/handlers/traces.js +57 -57
- package/dist/handlers/ui.js +1 -1
- package/dist/handlers/upstream_keys.js +59 -59
- package/dist/handlers/vaults.js +56 -56
- package/dist/handlers/whoami.js +56 -56
- package/dist/http.js +55 -55
- package/dist/index.js +62 -62
- package/dist/init.js +53 -53
- package/dist/lib/model-registry.js +6 -6
- package/dist/lib/skills-cache.js +6 -6
- package/dist/observability/otlp.js +12 -12
- package/dist/observability/redactor.js +8 -8
- package/dist/openapi/schemas.js +1 -1
- package/dist/openapi/spec.js +2 -2
- package/dist/providers/fly.js +5 -5
- package/dist/providers/modal.js +5 -5
- package/dist/providers/registry.js +1 -1
- package/dist/providers/resolve-secrets.js +7 -7
- package/dist/providers/sprites.js +7 -7
- package/dist/providers/upstream-keys.js +11 -11
- package/dist/providers/vercel.js +5 -5
- package/dist/proxy/forward.js +6 -6
- package/dist/queue/index.js +6 -6
- package/dist/sessions/bus.js +10 -10
- package/dist/sessions/driver.js +46 -46
- package/dist/sessions/grader.js +5 -5
- package/dist/sessions/secrets.js +8 -8
- package/dist/sessions/sweeper.js +43 -43
- package/dist/sessions/threads.js +46 -46
- package/dist/shutdown.js +44 -44
- package/dist/sync/anthropic.js +10 -10
- package/dist/sync/container-file-sync.js +27 -15
- package/dist/sync/file-sync.js +17 -17
- package/package.json +1 -1
|
@@ -16,7 +16,7 @@ import {
|
|
|
16
16
|
} from "./chunk-72BKGVBE.js";
|
|
17
17
|
import {
|
|
18
18
|
loadSessionSecrets
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-7OAMTB47.js";
|
|
20
20
|
import {
|
|
21
21
|
buildErrorPayload,
|
|
22
22
|
classifyError,
|
|
@@ -24,29 +24,29 @@ import {
|
|
|
24
24
|
} from "./chunk-H6TQGV4L.js";
|
|
25
25
|
import {
|
|
26
26
|
isProxied
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-NIOWKTIF.js";
|
|
28
28
|
import {
|
|
29
29
|
acquireForFirstTurn,
|
|
30
30
|
installSkills,
|
|
31
31
|
provisionResources
|
|
32
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-UF25F3MH.js";
|
|
33
33
|
import {
|
|
34
34
|
BLOCKED_ENV_KEYS
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-DO4WVWW7.js";
|
|
36
36
|
import {
|
|
37
37
|
appendEvent,
|
|
38
38
|
appendEventsBatch
|
|
39
|
-
} from "./chunk-
|
|
39
|
+
} from "./chunk-EOFJ2MWJ.js";
|
|
40
40
|
import {
|
|
41
41
|
listEvents,
|
|
42
42
|
markUserEventProcessed
|
|
43
|
-
} from "./chunk-
|
|
43
|
+
} from "./chunk-O45IQUWS.js";
|
|
44
44
|
import {
|
|
45
45
|
getBySession
|
|
46
|
-
} from "./chunk-
|
|
46
|
+
} from "./chunk-EFOIR7R3.js";
|
|
47
47
|
import {
|
|
48
48
|
resolveContainerProvider
|
|
49
|
-
} from "./chunk-
|
|
49
|
+
} from "./chunk-N2RHTKW7.js";
|
|
50
50
|
import {
|
|
51
51
|
bumpSessionStats,
|
|
52
52
|
getOutcomeCriteria,
|
|
@@ -57,16 +57,16 @@ import {
|
|
|
57
57
|
setOutcomeCriteria,
|
|
58
58
|
updateSessionMutable,
|
|
59
59
|
updateSessionStatus
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-I5ZA45YL.js";
|
|
61
61
|
import {
|
|
62
62
|
getEnvironment
|
|
63
|
-
} from "./chunk-
|
|
63
|
+
} from "./chunk-NUO56TF7.js";
|
|
64
64
|
import {
|
|
65
65
|
getAgent
|
|
66
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-JEI7I3EH.js";
|
|
67
67
|
import {
|
|
68
68
|
resolveBackend
|
|
69
|
-
} from "./chunk-
|
|
69
|
+
} from "./chunk-SHKBQQ7W.js";
|
|
70
70
|
import {
|
|
71
71
|
PERMISSION_BRIDGE_PENDING_PATH,
|
|
72
72
|
PERMISSION_BRIDGE_REQUEST_PATH,
|
|
@@ -77,7 +77,7 @@ import {
|
|
|
77
77
|
} from "./chunk-XBHDQK4Z.js";
|
|
78
78
|
import {
|
|
79
79
|
getConfig
|
|
80
|
-
} from "./chunk-
|
|
80
|
+
} from "./chunk-YEUALILD.js";
|
|
81
81
|
import {
|
|
82
82
|
init_clock,
|
|
83
83
|
nowMs
|
|
@@ -181,14 +181,17 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
|
|
|
181
181
|
if (row && row.title == null) {
|
|
182
182
|
const firstText = inputs.find((i) => i.kind === "text");
|
|
183
183
|
if (firstText?.text) {
|
|
184
|
-
|
|
184
|
+
const sanitized = firstText.text.replace(/[\x00-\x1F\x7F\u200B-\u200F\u2028-\u202F\uFEFF]/g, "").replace(/^Image(?=[A-Z])/g, "").replace(/\s+/g, " ").trim();
|
|
185
|
+
if (sanitized) {
|
|
186
|
+
updateSessionMutable(sessionId, { title: sanitized.slice(0, 60) });
|
|
187
|
+
}
|
|
185
188
|
}
|
|
186
189
|
}
|
|
187
190
|
console.log(`[driver] ${sessionId} acquiring container...`);
|
|
188
|
-
let
|
|
191
|
+
let sandboxName;
|
|
189
192
|
try {
|
|
190
|
-
|
|
191
|
-
console.log(`[driver] ${sessionId} container ready: ${
|
|
193
|
+
sandboxName = await acquireForFirstTurn(sessionId);
|
|
194
|
+
console.log(`[driver] ${sessionId} container ready: ${sandboxName}`);
|
|
192
195
|
const latestAgent = getAgent(session.agent.id);
|
|
193
196
|
if (latestAgent && latestAgent.skills && latestAgent.skills.length > 0) {
|
|
194
197
|
const currentSkills = new Map((agent.skills ?? []).map((s) => [s.name, s.content.length]));
|
|
@@ -199,7 +202,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
|
|
|
199
202
|
console.log(`[driver] ${sessionId} injecting ${newSkills.length} new skill(s)...`);
|
|
200
203
|
const envRow = getEnvironment(session.environment_id);
|
|
201
204
|
const sp = await resolveContainerProvider(envRow?.config?.provider);
|
|
202
|
-
await installSkills(
|
|
205
|
+
await installSkills(sandboxName, sp, newSkills, agent.engine);
|
|
203
206
|
console.log(`[driver] ${sessionId} skills injected`);
|
|
204
207
|
}
|
|
205
208
|
}
|
|
@@ -207,7 +210,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
|
|
|
207
210
|
if (freshSession2?.resources && freshSession2.resources.length > 0) {
|
|
208
211
|
const envRow = getEnvironment(session.environment_id);
|
|
209
212
|
const sp = await resolveContainerProvider(envRow?.config?.provider);
|
|
210
|
-
await provisionResources(
|
|
213
|
+
await provisionResources(sandboxName, freshSession2.resources, sp);
|
|
211
214
|
}
|
|
212
215
|
} catch (err) {
|
|
213
216
|
const msg = err instanceof Error ? err.message : String(err);
|
|
@@ -271,7 +274,7 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
|
|
|
271
274
|
let ollamaHostPort;
|
|
272
275
|
if (!turnBuild.env.OLLAMA_HOST) {
|
|
273
276
|
const envRow = getEnvironment(session.environment_id);
|
|
274
|
-
const provName = envRow?.config?.provider ?? "
|
|
277
|
+
const provName = envRow?.config?.provider ?? "docker";
|
|
275
278
|
if (provName === "docker" || provName === "podman") {
|
|
276
279
|
ollamaHostPort = "host.docker.internal:11434";
|
|
277
280
|
} else if (provName === "apple-container" || provName === "apple-firecracker") {
|
|
@@ -328,19 +331,19 @@ ${turnBuild.stdin}`;
|
|
|
328
331
|
});
|
|
329
332
|
if (agent.engine === "claude" && toolResults.length > 0) {
|
|
330
333
|
const { TOOL_BRIDGE_RESPONSE_PATH, TOOL_BRIDGE_PENDING_PATH } = await import("./backends/claude/tool-bridge.js");
|
|
331
|
-
const
|
|
332
|
-
if (
|
|
334
|
+
const sandboxName2 = getSessionRow(sessionId)?.sandbox_name;
|
|
335
|
+
if (sandboxName2) {
|
|
333
336
|
for (const r of toolResults) {
|
|
334
337
|
const responseJson = JSON.stringify({ content: r.content });
|
|
335
338
|
await provider.exec(
|
|
336
|
-
|
|
339
|
+
sandboxName2,
|
|
337
340
|
["bash", "-c", `cat > ${TOOL_BRIDGE_RESPONSE_PATH}`],
|
|
338
341
|
{ stdin: responseJson, secrets }
|
|
339
342
|
).catch((err) => {
|
|
340
343
|
console.warn(`[driver] failed to write tool bridge response:`, err);
|
|
341
344
|
});
|
|
342
345
|
await provider.exec(
|
|
343
|
-
|
|
346
|
+
sandboxName2,
|
|
344
347
|
["rm", "-f", TOOL_BRIDGE_PENDING_PATH],
|
|
345
348
|
{ secrets }
|
|
346
349
|
).catch(() => {
|
|
@@ -357,7 +360,7 @@ ${turnBuild.stdin}`;
|
|
|
357
360
|
});
|
|
358
361
|
let exec;
|
|
359
362
|
try {
|
|
360
|
-
exec = await provider.startExec(
|
|
363
|
+
exec = await provider.startExec(sandboxName, {
|
|
361
364
|
argv,
|
|
362
365
|
stdin,
|
|
363
366
|
signal: controller.signal,
|
|
@@ -379,7 +382,7 @@ ${turnBuild.stdin}`;
|
|
|
379
382
|
let permissionPollTimer = null;
|
|
380
383
|
if (agent.confirmation_mode) {
|
|
381
384
|
permissionPollTimer = setInterval(() => {
|
|
382
|
-
void checkPermissionSentinel(sessionId,
|
|
385
|
+
void checkPermissionSentinel(sessionId, sandboxName, provider).catch(
|
|
383
386
|
(err) => {
|
|
384
387
|
console.warn(`[driver] permission sentinel check failed:`, err);
|
|
385
388
|
}
|
|
@@ -511,12 +514,12 @@ ${turnBuild.stdin}`;
|
|
|
511
514
|
result?.usage
|
|
512
515
|
);
|
|
513
516
|
const sessionRowForSync = getSessionRow(sessionId);
|
|
514
|
-
if (sessionRowForSync?.
|
|
517
|
+
if (sessionRowForSync?.sandbox_name && !isProxied(sessionId)) {
|
|
515
518
|
try {
|
|
516
519
|
const { syncContainerFiles } = await import("./sync/container-file-sync.js");
|
|
517
520
|
const syncResult = await syncContainerFiles({
|
|
518
521
|
sessionId,
|
|
519
|
-
|
|
522
|
+
sandboxName: sessionRowForSync.sandbox_name,
|
|
520
523
|
provider,
|
|
521
524
|
secrets
|
|
522
525
|
});
|
|
@@ -541,7 +544,7 @@ ${turnBuild.stdin}`;
|
|
|
541
544
|
emit("session.status_idle", { stop_reason: formatStopReason("custom_tool_call", customToolEventIds) }, { at: now });
|
|
542
545
|
updateSessionStatus(sessionId, "idle", "custom_tool_call");
|
|
543
546
|
const { TOOL_BRIDGE_RESPONSE_PATH, TOOL_BRIDGE_PENDING_PATH } = await import("./backends/claude/tool-bridge.js");
|
|
544
|
-
const sprName = getSessionRow(sessionId)?.
|
|
547
|
+
const sprName = getSessionRow(sessionId)?.sandbox_name;
|
|
545
548
|
if (sprName) {
|
|
546
549
|
const responseJson = JSON.stringify({ content: [{ type: "text", text: serverToolResult.text }] });
|
|
547
550
|
const envForSession = getEnvironment(session.environment_id);
|
|
@@ -691,11 +694,11 @@ function getPendingConfirmations() {
|
|
|
691
694
|
if (!gd.__caPendingConfirmations) gd.__caPendingConfirmations = /* @__PURE__ */ new Set();
|
|
692
695
|
return gd.__caPendingConfirmations;
|
|
693
696
|
}
|
|
694
|
-
async function checkPermissionSentinel(sessionId,
|
|
697
|
+
async function checkPermissionSentinel(sessionId, sandboxName, provider) {
|
|
695
698
|
if (getPendingConfirmations().has(sessionId)) return;
|
|
696
699
|
try {
|
|
697
700
|
const result = await provider.exec(
|
|
698
|
-
|
|
701
|
+
sandboxName,
|
|
699
702
|
["test", "-f", PERMISSION_BRIDGE_PENDING_PATH]
|
|
700
703
|
);
|
|
701
704
|
if (result.exit_code !== 0) return;
|
|
@@ -705,7 +708,7 @@ async function checkPermissionSentinel(sessionId, spriteName, provider) {
|
|
|
705
708
|
let request;
|
|
706
709
|
try {
|
|
707
710
|
const result = await provider.exec(
|
|
708
|
-
|
|
711
|
+
sandboxName,
|
|
709
712
|
["cat", PERMISSION_BRIDGE_REQUEST_PATH]
|
|
710
713
|
);
|
|
711
714
|
request = JSON.parse(result.stdout);
|
|
@@ -727,8 +730,8 @@ async function checkPermissionSentinel(sessionId, spriteName, provider) {
|
|
|
727
730
|
}
|
|
728
731
|
async function writePermissionResponse(sessionId, result, denyMessage) {
|
|
729
732
|
const row = getSessionRow(sessionId);
|
|
730
|
-
if (!row?.
|
|
731
|
-
console.warn(`[driver] no
|
|
733
|
+
if (!row?.sandbox_name) {
|
|
734
|
+
console.warn(`[driver] no sandbox for session ${sessionId}, cannot write permission response`);
|
|
732
735
|
return;
|
|
733
736
|
}
|
|
734
737
|
const env = getEnvironment(row.environment_id);
|
|
@@ -740,7 +743,7 @@ async function writePermissionResponse(sessionId, result, denyMessage) {
|
|
|
740
743
|
});
|
|
741
744
|
try {
|
|
742
745
|
await provider.exec(
|
|
743
|
-
row.
|
|
746
|
+
row.sandbox_name,
|
|
744
747
|
["bash", "-c", `cat > ${PERMISSION_BRIDGE_RESPONSE_PATH}`],
|
|
745
748
|
{ stdin: response, secrets: permSecrets }
|
|
746
749
|
);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// src/backends/codex/wrapper-script.ts
|
|
2
2
|
var CODEX_WRAPPER_PATH = "/tmp/.codex-wrapper";
|
|
3
|
-
var
|
|
3
|
+
var SANDBOX_WRAPPER_SCRIPT = [
|
|
4
4
|
"#!/bin/bash",
|
|
5
5
|
'while IFS= read -r line; do [ -z "$line" ] && break; export "$line"; done',
|
|
6
6
|
'exec codex "$@"'
|
|
7
7
|
].join("\n");
|
|
8
|
-
async function installCodexWrapper(
|
|
9
|
-
const escaped =
|
|
10
|
-
await provider.exec(
|
|
8
|
+
async function installCodexWrapper(sandboxName, provider) {
|
|
9
|
+
const escaped = SANDBOX_WRAPPER_SCRIPT.replace(/'/g, "'\\''");
|
|
10
|
+
await provider.exec(sandboxName, [
|
|
11
11
|
"bash",
|
|
12
12
|
"-c",
|
|
13
13
|
`printf '%s' '${escaped}' > ${CODEX_WRAPPER_PATH} && chmod +x ${CODEX_WRAPPER_PATH}`
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-I5ZA45YL.js";
|
|
4
4
|
import {
|
|
5
5
|
createEnvironment,
|
|
6
6
|
deleteEnvironment,
|
|
7
7
|
getEnvironment
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-NUO56TF7.js";
|
|
9
9
|
import {
|
|
10
10
|
archiveAgent,
|
|
11
11
|
createAgent,
|
|
12
12
|
getAgent
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-JEI7I3EH.js";
|
|
14
14
|
import {
|
|
15
15
|
getDrizzle,
|
|
16
16
|
init_drizzle
|
|
17
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-SXE7H3VK.js";
|
|
18
18
|
|
|
19
19
|
// src/db/batch.ts
|
|
20
20
|
init_drizzle();
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
piBackend
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GR4QPRB7.js";
|
|
4
4
|
import {
|
|
5
5
|
opencodeBackend
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-HE7EOIPA.js";
|
|
7
7
|
import {
|
|
8
8
|
geminiBackend
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-374KGHBM.js";
|
|
10
10
|
import {
|
|
11
11
|
codexBackend
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-G37JVAOI.js";
|
|
13
13
|
import {
|
|
14
14
|
factoryBackend
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-HR5YA24J.js";
|
|
16
16
|
import {
|
|
17
17
|
claudeBackend
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-A7MX6RSQ.js";
|
|
19
19
|
|
|
20
20
|
// src/backends/registry.ts
|
|
21
21
|
var BACKENDS = {
|
|
@@ -6,31 +6,31 @@ import {
|
|
|
6
6
|
import {
|
|
7
7
|
forwardToAnthropic,
|
|
8
8
|
validateAnthropicProxy
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-YIYEPKVQ.js";
|
|
10
10
|
import {
|
|
11
11
|
jsonOk,
|
|
12
12
|
routeWrap
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-PFLR7INE.js";
|
|
14
14
|
import {
|
|
15
15
|
getProxiedTenantId,
|
|
16
16
|
isProxied,
|
|
17
17
|
markProxied,
|
|
18
18
|
unmarkProxied
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-NIOWKTIF.js";
|
|
20
20
|
import {
|
|
21
21
|
archiveAgent,
|
|
22
22
|
createAgent,
|
|
23
23
|
getAgent,
|
|
24
24
|
listAgents,
|
|
25
25
|
updateAgent
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-JEI7I3EH.js";
|
|
27
27
|
import {
|
|
28
28
|
resolveBackend
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-SHKBQQ7W.js";
|
|
30
30
|
import {
|
|
31
31
|
getDb,
|
|
32
32
|
init_client
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-5GZEX4HV.js";
|
|
34
34
|
import {
|
|
35
35
|
badRequest,
|
|
36
36
|
conflict,
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// src/backends/opencode/wrapper-script.ts
|
|
2
2
|
var OPENCODE_WRAPPER_PATH = "/tmp/.opencode-wrapper";
|
|
3
|
-
var
|
|
3
|
+
var SANDBOX_WRAPPER_SCRIPT = [
|
|
4
4
|
"#!/bin/bash",
|
|
5
5
|
"set -e",
|
|
6
6
|
'while IFS= read -r line; do [ -z "$line" ] && break; export "$line"; done',
|
|
7
7
|
"PROMPT=$(cat)",
|
|
8
8
|
'exec opencode "$@" "$PROMPT"'
|
|
9
9
|
].join("\n");
|
|
10
|
-
async function installOpencodeWrapper(
|
|
11
|
-
const escaped =
|
|
12
|
-
await provider.exec(
|
|
10
|
+
async function installOpencodeWrapper(sandboxName, provider) {
|
|
11
|
+
const escaped = SANDBOX_WRAPPER_SCRIPT.replace(/'/g, "'\\''");
|
|
12
|
+
await provider.exec(sandboxName, [
|
|
13
13
|
"bash",
|
|
14
14
|
"-c",
|
|
15
15
|
`printf '%s' '${escaped}' > ${OPENCODE_WRAPPER_PATH} && chmod +x ${OPENCODE_WRAPPER_PATH}`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
init_schema,
|
|
3
3
|
schema_exports
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LHHBOQUR.js";
|
|
5
5
|
import {
|
|
6
6
|
getDb,
|
|
7
7
|
init_client
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5GZEX4HV.js";
|
|
9
9
|
import {
|
|
10
10
|
__esm
|
|
11
11
|
} from "./chunk-2ESYSVXG.js";
|
|
@@ -1,43 +1,43 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveVaultSecrets
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DO4WVWW7.js";
|
|
4
4
|
import {
|
|
5
5
|
dockerProvider
|
|
6
6
|
} from "./chunk-RMZRSYIJ.js";
|
|
7
7
|
import {
|
|
8
8
|
appendEvent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-EOFJ2MWJ.js";
|
|
10
10
|
import {
|
|
11
|
-
|
|
11
|
+
allSessionSandboxes,
|
|
12
12
|
countInEnv,
|
|
13
13
|
register,
|
|
14
14
|
unregister
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-EFOIR7R3.js";
|
|
16
16
|
import {
|
|
17
17
|
resolveContainerProvider
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-N2RHTKW7.js";
|
|
19
19
|
import {
|
|
20
20
|
getSession,
|
|
21
21
|
getSessionRow,
|
|
22
|
-
|
|
23
|
-
} from "./chunk-
|
|
22
|
+
setSessionSandbox
|
|
23
|
+
} from "./chunk-I5ZA45YL.js";
|
|
24
24
|
import {
|
|
25
25
|
getEnvironment,
|
|
26
26
|
getEnvironmentRow
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-NUO56TF7.js";
|
|
28
28
|
import {
|
|
29
29
|
getAgent
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-JEI7I3EH.js";
|
|
31
31
|
import {
|
|
32
32
|
resolveBackend
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-SHKBQQ7W.js";
|
|
34
34
|
import {
|
|
35
35
|
deleteSprite,
|
|
36
36
|
listSprites
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-IEG5LIX7.js";
|
|
38
38
|
import {
|
|
39
39
|
getConfig
|
|
40
|
-
} from "./chunk-
|
|
40
|
+
} from "./chunk-YEUALILD.js";
|
|
41
41
|
import {
|
|
42
42
|
init_clock,
|
|
43
43
|
nowMs
|
|
@@ -51,8 +51,8 @@ init_clock();
|
|
|
51
51
|
var lcLog = (...args) => {
|
|
52
52
|
if (process.env.DEBUG_LIFECYCLE === "1") console.log(...args);
|
|
53
53
|
};
|
|
54
|
-
var
|
|
55
|
-
async function installSkills(
|
|
54
|
+
var SANDBOX_NAME_PREFIX = "ca-sess-";
|
|
55
|
+
async function installSkills(sandboxName, provider, skills, engine) {
|
|
56
56
|
if (!skills || skills.length === 0) return;
|
|
57
57
|
const SAFE_NAME_RE = /^[a-zA-Z0-9_.-]+$/;
|
|
58
58
|
const safeSkills = skills.filter((s) => {
|
|
@@ -63,33 +63,33 @@ async function installSkills(spriteName, provider, skills, engine) {
|
|
|
63
63
|
return true;
|
|
64
64
|
});
|
|
65
65
|
if (engine === "claude") {
|
|
66
|
-
await provider.exec(
|
|
66
|
+
await provider.exec(sandboxName, ["mkdir", "-p", "/home/agent/.claude/skills"]);
|
|
67
67
|
for (const skill of safeSkills) {
|
|
68
68
|
const dirPath = `/home/agent/.claude/skills/${skill.name}`;
|
|
69
69
|
const filePath = `${dirPath}/SKILL.md`;
|
|
70
|
-
await provider.exec(
|
|
71
|
-
await provider.exec(
|
|
70
|
+
await provider.exec(sandboxName, ["mkdir", "-p", dirPath]);
|
|
71
|
+
await provider.exec(sandboxName, ["sh", "-c", 'cat > "$1"', "sh", filePath], {
|
|
72
72
|
stdin: skill.content
|
|
73
73
|
});
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
await provider.exec(
|
|
76
|
+
await provider.exec(sandboxName, ["mkdir", "-p", "/home/agent/.agents/skills"]);
|
|
77
77
|
for (const skill of safeSkills) {
|
|
78
78
|
const dirPath = `/home/agent/.agents/skills/${skill.name}`;
|
|
79
79
|
const filePath = `${dirPath}/SKILL.md`;
|
|
80
|
-
await provider.exec(
|
|
81
|
-
await provider.exec(
|
|
80
|
+
await provider.exec(sandboxName, ["mkdir", "-p", dirPath]);
|
|
81
|
+
await provider.exec(sandboxName, ["sh", "-c", 'cat > "$1"', "sh", filePath], {
|
|
82
82
|
stdin: skill.content
|
|
83
83
|
});
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
function
|
|
87
|
-
return `${
|
|
86
|
+
function deriveSandboxName(sessionId) {
|
|
87
|
+
return `${SANDBOX_NAME_PREFIX}${sessionId.replace(/^sess_/, "").toLowerCase()}`;
|
|
88
88
|
}
|
|
89
89
|
async function acquireForFirstTurn(sessionId) {
|
|
90
90
|
const row = getSessionRow(sessionId);
|
|
91
91
|
if (!row) throw new ApiError(404, "not_found_error", `session not found: ${sessionId}`);
|
|
92
|
-
if (row.
|
|
92
|
+
if (row.sandbox_name) return row.sandbox_name;
|
|
93
93
|
const env = getEnvironmentRow(row.environment_id);
|
|
94
94
|
if (!env) throw new ApiError(404, "not_found_error", "environment not found");
|
|
95
95
|
if (env.state !== "ready") {
|
|
@@ -99,8 +99,8 @@ async function acquireForFirstTurn(sessionId) {
|
|
|
99
99
|
`environment is not ready (state=${env.state})`
|
|
100
100
|
);
|
|
101
101
|
}
|
|
102
|
-
if (countInEnv(env.id) >= getConfig().
|
|
103
|
-
throw new ApiError(503, "server_busy", "env
|
|
102
|
+
if (countInEnv(env.id) >= getConfig().maxSandboxesPerEnv) {
|
|
103
|
+
throw new ApiError(503, "server_busy", "env sandbox pool exhausted");
|
|
104
104
|
}
|
|
105
105
|
const agent = getAgent(row.agent_id, row.agent_version);
|
|
106
106
|
if (!agent) {
|
|
@@ -125,10 +125,18 @@ async function acquireForFirstTurn(sessionId) {
|
|
|
125
125
|
create: (opts) => provider.create({ ...opts, secrets }),
|
|
126
126
|
delete: (n, s) => provider.delete(n, s ?? secrets)
|
|
127
127
|
} : provider;
|
|
128
|
-
const name =
|
|
128
|
+
const name = deriveSandboxName(sessionId);
|
|
129
129
|
lcLog(`[lifecycle] ${sessionId} creating container via ${sp.name}...`);
|
|
130
|
-
|
|
131
|
-
|
|
130
|
+
try {
|
|
131
|
+
await sp.create({ name });
|
|
132
|
+
lcLog(`[lifecycle] ${sessionId} container created: ${name}`);
|
|
133
|
+
} catch (err) {
|
|
134
|
+
if (String(err).includes("already exists")) {
|
|
135
|
+
lcLog(`[lifecycle] ${sessionId} container ${name} already exists, reusing`);
|
|
136
|
+
} else {
|
|
137
|
+
throw err;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
132
140
|
const needsSlowPrep = backend.name !== "claude";
|
|
133
141
|
if (needsSlowPrep) {
|
|
134
142
|
appendEvent(sessionId, {
|
|
@@ -140,7 +148,7 @@ async function acquireForFirstTurn(sessionId) {
|
|
|
140
148
|
}
|
|
141
149
|
try {
|
|
142
150
|
lcLog(`[lifecycle] ${sessionId} installing ${backend.name} engine on container...`);
|
|
143
|
-
await backend.
|
|
151
|
+
await backend.prepareOnSandbox(name, sp);
|
|
144
152
|
lcLog(`[lifecycle] ${sessionId} engine installed`);
|
|
145
153
|
if (agent.engine === "claude") {
|
|
146
154
|
const customTools = agent.tools.filter(
|
|
@@ -214,17 +222,17 @@ async function acquireForFirstTurn(sessionId) {
|
|
|
214
222
|
}
|
|
215
223
|
}
|
|
216
224
|
register({
|
|
217
|
-
|
|
225
|
+
sandboxName: name,
|
|
218
226
|
envId: env.id,
|
|
219
227
|
sessionId,
|
|
220
228
|
createdAt: nowMs(),
|
|
221
229
|
vaultSecrets: Object.keys(secrets).length > 0 ? secrets : void 0
|
|
222
230
|
});
|
|
223
|
-
|
|
231
|
+
setSessionSandbox(sessionId, name);
|
|
224
232
|
return name;
|
|
225
233
|
}
|
|
226
|
-
async function provisionResources(
|
|
227
|
-
await provider.exec(
|
|
234
|
+
async function provisionResources(sandboxName, resources, provider) {
|
|
235
|
+
await provider.exec(sandboxName, ["mkdir", "-p", "/mnt/session/resources", "/mnt/session/uploads", "/mnt/session/outputs"]);
|
|
228
236
|
const MAX_RESOURCE_BYTES = 50 * 1024 * 1024;
|
|
229
237
|
const SAFE_PATH_RE = /^[a-zA-Z0-9_./\-]+$/;
|
|
230
238
|
function sanitizeMountPath(p) {
|
|
@@ -251,11 +259,11 @@ async function provisionResources(spriteName, resources, provider) {
|
|
|
251
259
|
}
|
|
252
260
|
const dir = mountTarget.substring(0, mountTarget.lastIndexOf("/"));
|
|
253
261
|
if (dir) {
|
|
254
|
-
await provider.exec(
|
|
262
|
+
await provider.exec(sandboxName, ["mkdir", "-p", dir]);
|
|
255
263
|
}
|
|
256
264
|
const writeTo = async (target, content) => {
|
|
257
|
-
await provider.exec(
|
|
258
|
-
await provider.exec(
|
|
265
|
+
await provider.exec(sandboxName, ["sh", "-c", 'cat > "$1"', "sh", target], { stdin: content });
|
|
266
|
+
await provider.exec(sandboxName, ["chmod", "a-w", target]);
|
|
259
267
|
};
|
|
260
268
|
if (r.type === "uri" && r.uri) {
|
|
261
269
|
try {
|
|
@@ -315,9 +323,9 @@ async function provisionResources(spriteName, resources, provider) {
|
|
|
315
323
|
gitArgs.push("--branch", safeBranch);
|
|
316
324
|
}
|
|
317
325
|
gitArgs.push("--", r.repository_url, repoDir);
|
|
318
|
-
const result = await provider.exec(
|
|
326
|
+
const result = await provider.exec(sandboxName, gitArgs, { timeoutMs: 12e4 });
|
|
319
327
|
if (safeCommit && result.exit_code === 0) {
|
|
320
|
-
await provider.exec(
|
|
328
|
+
await provider.exec(sandboxName, ["git", "-C", repoDir, "checkout", safeCommit], { timeoutMs: 3e4 });
|
|
321
329
|
}
|
|
322
330
|
if (result.exit_code !== 0) {
|
|
323
331
|
console.warn(`[lifecycle] git clone failed for ${r.repository_url}: ${result.stderr.slice(0, 200)}`);
|
|
@@ -331,7 +339,7 @@ async function provisionResources(spriteName, resources, provider) {
|
|
|
331
339
|
async function releaseSession(sessionId) {
|
|
332
340
|
const entry = unregister(sessionId);
|
|
333
341
|
const row = getSessionRow(sessionId);
|
|
334
|
-
const name = entry?.
|
|
342
|
+
const name = entry?.sandboxName ?? row?.sandbox_name ?? null;
|
|
335
343
|
if (name) {
|
|
336
344
|
const envObj = row ? getEnvironment(row.environment_id) : null;
|
|
337
345
|
const provider = await resolveContainerProvider(envObj?.config?.provider);
|
|
@@ -339,18 +347,18 @@ async function releaseSession(sessionId) {
|
|
|
339
347
|
console.warn(`releaseSession: failed to delete container ${name}:`, err);
|
|
340
348
|
});
|
|
341
349
|
}
|
|
342
|
-
if (row?.
|
|
350
|
+
if (row?.sandbox_name) setSessionSandbox(sessionId, null);
|
|
343
351
|
}
|
|
344
|
-
async function
|
|
352
|
+
async function reconcileOrphanSandboxes() {
|
|
345
353
|
let deleted = 0;
|
|
346
354
|
let kept = 0;
|
|
347
355
|
const liveNames = new Set(
|
|
348
|
-
|
|
356
|
+
allSessionSandboxes().map((e) => e.sandboxName).filter(Boolean)
|
|
349
357
|
);
|
|
350
358
|
let token;
|
|
351
359
|
for (; ; ) {
|
|
352
360
|
const res = await listSprites({
|
|
353
|
-
prefix:
|
|
361
|
+
prefix: SANDBOX_NAME_PREFIX,
|
|
354
362
|
max_results: 100,
|
|
355
363
|
continuation_token: token
|
|
356
364
|
});
|
|
@@ -369,13 +377,13 @@ async function reconcileOrphans() {
|
|
|
369
377
|
}
|
|
370
378
|
return { deleted, kept };
|
|
371
379
|
}
|
|
372
|
-
async function
|
|
380
|
+
async function reconcileDockerOrphanSandboxes() {
|
|
373
381
|
let deleted = 0;
|
|
374
382
|
let kept = 0;
|
|
375
383
|
const liveNames = new Set(
|
|
376
|
-
|
|
384
|
+
allSessionSandboxes().map((e) => e.sandboxName).filter(Boolean)
|
|
377
385
|
);
|
|
378
|
-
const containers = await dockerProvider.list({ prefix:
|
|
386
|
+
const containers = await dockerProvider.list({ prefix: SANDBOX_NAME_PREFIX });
|
|
379
387
|
for (const c of containers) {
|
|
380
388
|
if (liveNames.has(c.name)) {
|
|
381
389
|
kept++;
|
|
@@ -393,6 +401,6 @@ export {
|
|
|
393
401
|
acquireForFirstTurn,
|
|
394
402
|
provisionResources,
|
|
395
403
|
releaseSession,
|
|
396
|
-
|
|
397
|
-
|
|
404
|
+
reconcileOrphanSandboxes,
|
|
405
|
+
reconcileDockerOrphanSandboxes
|
|
398
406
|
};
|