@agentstep/agent-sdk 0.4.13 → 0.4.15
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 +11 -6
- package/dist/auth/passthrough.js +9 -0
- 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 +13 -13
- 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 +14 -14
- 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 +13 -13
- 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 +14 -14
- package/dist/backends/pi/setup.js +4 -4
- package/dist/backends/pi/wrapper-script.js +1 -1
- package/dist/backends/registry.js +30 -30
- package/dist/{chunk-5GDMWWYD.js → chunk-2BDD6OHG.js} +10 -2
- package/dist/{chunk-7YYEE7XR.js → chunk-2BZ2XKJU.js} +5 -5
- package/dist/{chunk-OHYPVKTP.js → chunk-3LG7DRJL.js} +4 -4
- package/dist/{chunk-ZA4JVJJE.js → chunk-3PLJHZFD.js} +1 -1
- package/dist/{chunk-ME6IR4T6.js → chunk-3W6KEDQE.js} +4 -4
- package/dist/{chunk-PMEF3X3C.js → chunk-46LBKEBE.js} +2 -2
- package/dist/{chunk-XLMHG3KR.js → chunk-5DHH2PGR.js} +50 -47
- package/dist/{chunk-6QDHS2MR.js → chunk-5GIZLWWF.js} +1 -1
- package/dist/{chunk-DZDWNOEY.js → chunk-5GZEX4HV.js} +1 -1
- package/dist/{chunk-V364DYC3.js → chunk-5XF65N7J.js} +1 -1
- package/dist/{chunk-6UXT3RG5.js → chunk-64ZLFLMN.js} +4 -4
- package/dist/{chunk-JMDS2RJJ.js → chunk-66CJ6LMV.js} +1 -1
- package/dist/{chunk-2FWZ247V.js → chunk-6IWTDQJN.js} +9 -4
- package/dist/{chunk-TQHS4W74.js → chunk-6OL43KT2.js} +1 -1
- package/dist/{chunk-JZ5RFO77.js → chunk-7LQN7NVU.js} +5 -5
- package/dist/{chunk-X3U7IVTN.js → chunk-7OAMTB47.js} +2 -2
- package/dist/{chunk-I3AP3LEY.js → chunk-ACKMNK3C.js} +7 -7
- package/dist/{chunk-IJEZAD5O.js → chunk-ADK2TYO4.js} +2 -2
- package/dist/{chunk-CX4VNHL6.js → chunk-AH7DAJU5.js} +74 -32
- package/dist/{chunk-5ZRGJTR3.js → chunk-AM7F65IC.js} +10 -10
- package/dist/{chunk-MXRGQRFX.js → chunk-BMPB7XJH.js} +6 -6
- package/dist/{chunk-V7OXXKAL.js → chunk-BZ6HFTHU.js} +1 -1
- package/dist/{chunk-TSYQ4XKJ.js → chunk-CDCLICKM.js} +2 -2
- package/dist/{chunk-FXLGGDLM.js → chunk-CE45WWNZ.js} +4 -4
- package/dist/{chunk-QKRWCXDU.js → chunk-CGSUJZ56.js} +1 -1
- package/dist/{chunk-3WJMUX5B.js → chunk-DO4WVWW7.js} +1 -1
- package/dist/{chunk-AKRE4OEL.js → chunk-EFOIR7R3.js} +5 -3
- package/dist/{chunk-M4RE42AY.js → chunk-ENOKSV57.js} +3 -3
- package/dist/{chunk-RTS2QUZB.js → chunk-EO5ZTIP7.js} +20 -11
- package/dist/{chunk-3NZQBGUJ.js → chunk-F2SDCOHG.js} +18 -18
- package/dist/{chunk-FB6FOIAY.js → chunk-FB4OSWM2.js} +1 -1
- package/dist/{chunk-2PKJSOXX.js → chunk-FCULDJQO.js} +1 -1
- package/dist/{chunk-Q4XYK6FF.js → chunk-GJBKDPQD.js} +5 -5
- package/dist/{chunk-7TW4LHPM.js → chunk-HECQRMDR.js} +2 -2
- package/dist/{chunk-XLVCC4IB.js → chunk-HWWCVD2R.js} +7 -7
- package/dist/{chunk-MBLMAWSE.js → chunk-I5ZA45YL.js} +7 -7
- 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-WUNJJNOV.js → chunk-JKUR5MIM.js} +4 -4
- package/dist/{chunk-4BYPJFC5.js → chunk-JOAEFGXZ.js} +62 -54
- package/dist/{chunk-NHY4Q6LS.js → chunk-JOZK6G5O.js} +14 -14
- package/dist/{chunk-5A6E4F5D.js → chunk-JSLEB2ED.js} +2 -1
- package/dist/{chunk-3KDZP45U.js → chunk-K7KLJ2UJ.js} +13 -10
- package/dist/{chunk-LP7AQJCU.js → chunk-KGARPQA4.js} +3 -3
- package/dist/{chunk-6A74MTSB.js → chunk-L6CUSDUF.js} +3 -3
- package/dist/{chunk-N5CUDEUJ.js → chunk-LHHBOQUR.js} +2 -2
- package/dist/{chunk-4FHRWC4H.js → chunk-LJF4GWPJ.js} +5 -5
- package/dist/{chunk-RL6XEYOD.js → chunk-MHQXDTJB.js} +1 -1
- package/dist/{chunk-UX6I36QR.js → chunk-NDQ6CQ7B.js} +122 -122
- package/dist/{chunk-7BGILLYC.js → chunk-NIOWKTIF.js} +2 -2
- package/dist/{chunk-KDAZ5TBL.js → chunk-NK2RCTFI.js} +8 -8
- 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-UXZSRUXD.js → chunk-ORU5GQ4Z.js} +2 -2
- package/dist/{chunk-QYFD2OBI.js → chunk-OWTXN2FU.js} +1 -1
- package/dist/{chunk-V4P46OHG.js → chunk-P7P2NWZD.js} +5 -5
- package/dist/{chunk-MAW3HLIO.js → chunk-PB7LR2AG.js} +2 -2
- package/dist/{chunk-KEV4OMRF.js → chunk-PNYCULIF.js} +9 -9
- package/dist/{chunk-VVH5DQ2C.js → chunk-PWWRWR75.js} +42 -3
- package/dist/{chunk-G5RQN53K.js → chunk-PZWVTEL2.js} +1 -1
- package/dist/{chunk-OGONPLTA.js → chunk-QFUJDBET.js} +6 -6
- package/dist/{chunk-Q5KHBU7P.js → chunk-QH57EOKP.js} +12 -4
- package/dist/{chunk-6ZJ6X6H7.js → chunk-QLWA4MJ5.js} +15 -4
- package/dist/{chunk-2QGVGXIT.js → chunk-QQDSHL27.js} +4 -4
- package/dist/{chunk-J4NKW3L5.js → chunk-QYSDP6V5.js} +5 -5
- package/dist/{chunk-ETGRQMFJ.js → chunk-R45W644X.js} +1 -1
- package/dist/{chunk-LPWEFC55.js → chunk-R5OZHLAD.js} +2 -2
- package/dist/{chunk-DFE7VZWD.js → chunk-RMEX55EU.js} +4 -4
- package/dist/{chunk-TY7XTT5N.js → chunk-RZXRMPF4.js} +1 -1
- package/dist/{chunk-D5XOXR3A.js → chunk-S3SKODVV.js} +4 -4
- package/dist/{chunk-CU5GUNFW.js → chunk-S6AM7WVH.js} +2 -2
- package/dist/{chunk-YOFB6CO5.js → chunk-SDLNBA53.js} +7 -7
- package/dist/{chunk-JFY6EH24.js → chunk-SIKTYKVO.js} +15 -15
- package/dist/{chunk-7XFIUYFM.js → chunk-SWIP7JBQ.js} +4 -4
- package/dist/{chunk-XNK2KUTI.js → chunk-SXE7H3VK.js} +2 -2
- package/dist/{chunk-OQWHKEYE.js → chunk-TFK6TCMC.js} +3 -3
- package/dist/{chunk-TV2VE2LX.js → chunk-TWPTR2C2.js} +2 -2
- package/dist/{chunk-3MNDEAPX.js → chunk-UJDAT42X.js} +8 -8
- package/dist/{chunk-UN3LHCWQ.js → chunk-VIGJQU6V.js} +3 -3
- package/dist/{chunk-4INVRCRD.js → chunk-VO7BDPYU.js} +2 -2
- package/dist/{chunk-UVCPCX74.js → chunk-VS7AMAMU.js} +8 -8
- package/dist/chunk-W6WKXFHN.js +39 -0
- package/dist/{chunk-3EGA6TEL.js → chunk-WPEGSLXX.js} +1 -1
- package/dist/{chunk-YM2LYRYY.js → chunk-WRWTK455.js} +3 -3
- package/dist/{chunk-W3M3ME6B.js → chunk-XG4UIGDH.js} +5 -5
- package/dist/{chunk-TH54MJMX.js → chunk-XPKY3Z54.js} +1 -1
- package/dist/{chunk-BM34UHSS.js → chunk-Y27R572J.js} +6 -5
- package/dist/{chunk-6BDLNY5J.js → chunk-Y4X3QY2S.js} +2 -2
- package/dist/{chunk-U4F4JSME.js → chunk-Y6ZY23HE.js} +3 -3
- package/dist/{chunk-KZGAZPNV.js → chunk-YGAHGTVZ.js} +3 -3
- package/dist/{chunk-H74BPBKE.js → chunk-YSUPRYX2.js} +5 -5
- package/dist/{chunk-HERWBOQ7.js → chunk-ZLUBNJEO.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 +47 -47
- 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 +60 -59
- package/dist/handlers/api_keys.js +61 -59
- package/dist/handlers/audit.js +61 -59
- package/dist/handlers/batch.js +61 -59
- package/dist/handlers/credentials.js +61 -59
- package/dist/handlers/environments.js +61 -60
- package/dist/handlers/events.js +64 -63
- package/dist/handlers/files.js +61 -59
- package/dist/handlers/index.js +125 -124
- package/dist/handlers/license.js +60 -58
- package/dist/handlers/memory.js +61 -59
- package/dist/handlers/metrics.js +60 -58
- package/dist/handlers/models.js +61 -59
- package/dist/handlers/openapi.js +3 -3
- package/dist/handlers/providers.js +60 -58
- package/dist/handlers/resources.js +60 -58
- package/dist/handlers/sessions.js +63 -62
- package/dist/handlers/settings.js +60 -58
- package/dist/handlers/skills-write.js +60 -58
- package/dist/handlers/skills.js +61 -59
- package/dist/handlers/stream.js +60 -59
- package/dist/handlers/tenants.js +61 -59
- package/dist/handlers/threads.js +60 -58
- package/dist/handlers/traces.js +61 -59
- package/dist/handlers/ui.js +1 -1
- package/dist/handlers/upstream_keys.js +63 -61
- package/dist/handlers/vaults.js +60 -58
- package/dist/handlers/whoami.js +60 -58
- package/dist/http.js +59 -57
- package/dist/index.js +81 -78
- package/dist/init.js +55 -55
- 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 +48 -48
- package/dist/sessions/grader.js +5 -5
- package/dist/sessions/secrets.js +8 -8
- package/dist/sessions/sweeper.js +44 -44
- package/dist/sessions/threads.js +52 -52
- package/dist/shutdown.js +45 -45
- package/dist/sync/anthropic.js +10 -10
- package/dist/sync/container-file-sync.js +27 -15
- package/dist/sync/file-sync.js +19 -19
- package/package.json +1 -1
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
buildCodexAuthEnv,
|
|
3
|
+
validateCodexRuntime
|
|
4
|
+
} from "./chunk-5XF65N7J.js";
|
|
5
|
+
import {
|
|
6
|
+
prepareCodexOnSandbox
|
|
7
|
+
} from "./chunk-7LQN7NVU.js";
|
|
4
8
|
import {
|
|
5
9
|
createCodexTranslator
|
|
6
10
|
} from "./chunk-CULYZ3VA.js";
|
|
7
11
|
import {
|
|
8
12
|
CODEX_WRAPPER_PATH
|
|
9
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-RMEX55EU.js";
|
|
10
14
|
import {
|
|
11
15
|
wrapPromptWithSystem
|
|
12
16
|
} from "./chunk-DAT55TX2.js";
|
|
13
17
|
import {
|
|
14
18
|
buildCodexArgs
|
|
15
19
|
} from "./chunk-NQX7WBA4.js";
|
|
16
|
-
import {
|
|
17
|
-
buildCodexAuthEnv,
|
|
18
|
-
validateCodexRuntime
|
|
19
|
-
} from "./chunk-V364DYC3.js";
|
|
20
20
|
import {
|
|
21
21
|
ApiError
|
|
22
22
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -41,7 +41,7 @@ var codexBackend = {
|
|
|
41
41
|
wrapperPath: CODEX_WRAPPER_PATH,
|
|
42
42
|
buildTurn,
|
|
43
43
|
createTranslator: (opts) => createCodexTranslator(opts),
|
|
44
|
-
|
|
44
|
+
prepareOnSandbox: (name, provider) => prepareCodexOnSandbox(name, provider),
|
|
45
45
|
validateRuntime: validateCodexRuntime
|
|
46
46
|
};
|
|
47
47
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_TENANT_ID
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JDELTTHV.js";
|
|
4
4
|
import {
|
|
5
5
|
init_ids,
|
|
6
6
|
newId
|
|
@@ -8,10 +8,10 @@ import {
|
|
|
8
8
|
import {
|
|
9
9
|
getDrizzle,
|
|
10
10
|
init_drizzle
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-SXE7H3VK.js";
|
|
12
12
|
import {
|
|
13
13
|
schema_exports
|
|
14
|
-
} from "./chunk-
|
|
14
|
+
} from "./chunk-LHHBOQUR.js";
|
|
15
15
|
import {
|
|
16
16
|
init_clock,
|
|
17
17
|
nowMs,
|
|
@@ -83,7 +83,7 @@ function updateEnvironmentState(id, state, message) {
|
|
|
83
83
|
}
|
|
84
84
|
function updateEnvironmentCheckpoint(id, checkpointId, templateSprite) {
|
|
85
85
|
const db = getDrizzle();
|
|
86
|
-
db.update(schema_exports.environments).set({ checkpoint_id: checkpointId,
|
|
86
|
+
db.update(schema_exports.environments).set({ checkpoint_id: checkpointId, template_sandbox: templateSprite }).where(eq(schema_exports.environments.id, id)).run();
|
|
87
87
|
}
|
|
88
88
|
function archiveEnvironment(id) {
|
|
89
89
|
const db = getDrizzle();
|
|
@@ -5,10 +5,10 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
getDrizzle,
|
|
7
7
|
init_drizzle
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-SXE7H3VK.js";
|
|
9
9
|
import {
|
|
10
10
|
schema_exports
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-LHHBOQUR.js";
|
|
12
12
|
import {
|
|
13
13
|
init_clock,
|
|
14
14
|
nowMs,
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
import {
|
|
18
18
|
getDb,
|
|
19
19
|
init_client
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-5GZEX4HV.js";
|
|
21
21
|
|
|
22
22
|
// src/db/events.ts
|
|
23
23
|
init_client();
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-23UKWXJH.js";
|
|
5
5
|
import {
|
|
6
6
|
listAudit
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-MHQXDTJB.js";
|
|
8
8
|
import {
|
|
9
9
|
jsonOk,
|
|
10
10
|
routeWrap
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-6IWTDQJN.js";
|
|
12
12
|
import {
|
|
13
13
|
badRequest
|
|
14
14
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -173,7 +173,7 @@ var EnvironmentPackages = z.object({
|
|
|
173
173
|
npm: z.array(z.string()).optional(),
|
|
174
174
|
pip: z.array(z.string()).optional()
|
|
175
175
|
}).openapi({
|
|
176
|
-
description: "Package lists installed into the
|
|
176
|
+
description: "Package lists installed into the sandbox during environment setup. All are optional."
|
|
177
177
|
});
|
|
178
178
|
var EnvironmentNetworking = z.union([
|
|
179
179
|
z.object({ type: z.literal("unrestricted") }),
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
installOpencodeWrapper
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-SWIP7JBQ.js";
|
|
4
4
|
|
|
5
5
|
// src/backends/opencode/setup.ts
|
|
6
6
|
var SENTINEL_NAME = ".claude-agents-opencode-installed";
|
|
7
|
-
async function
|
|
8
|
-
await installOpencodeWrapper(
|
|
7
|
+
async function prepareOpencodeOnSandbox(sandboxName, provider) {
|
|
8
|
+
await installOpencodeWrapper(sandboxName, provider);
|
|
9
9
|
const script = [
|
|
10
10
|
"set -euo pipefail",
|
|
11
11
|
`SENTINEL="$HOME/${SENTINEL_NAME}"`,
|
|
@@ -19,7 +19,7 @@ async function prepareOpencodeOnSprite(spriteName, provider) {
|
|
|
19
19
|
"/usr/local/bin/opencode --version || $PREFIX/bin/opencode --version",
|
|
20
20
|
'touch "$SENTINEL"'
|
|
21
21
|
].join(" && ");
|
|
22
|
-
const result = await provider.exec(
|
|
22
|
+
const result = await provider.exec(sandboxName, ["bash", "-c", script], {
|
|
23
23
|
timeoutMs: 5 * 6e4
|
|
24
24
|
// 5 minutes — cold install typically <30s but leave headroom
|
|
25
25
|
});
|
|
@@ -31,5 +31,5 @@ async function prepareOpencodeOnSprite(spriteName, provider) {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
export {
|
|
34
|
-
|
|
34
|
+
prepareOpencodeOnSandbox
|
|
35
35
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
jsonOk,
|
|
3
3
|
routeWrap
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6IWTDQJN.js";
|
|
5
5
|
import {
|
|
6
6
|
readSetting,
|
|
7
7
|
writeSetting
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-QH57EOKP.js";
|
|
9
9
|
import {
|
|
10
10
|
badRequest
|
|
11
11
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -3,23 +3,23 @@ import {
|
|
|
3
3
|
getActor
|
|
4
4
|
} from "./chunk-LAWTTG2E.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
7
|
-
|
|
6
|
+
reconcileDockerOrphanSandboxes,
|
|
7
|
+
reconcileOrphanSandboxes,
|
|
8
8
|
releaseSession
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-JOAEFGXZ.js";
|
|
10
10
|
import {
|
|
11
11
|
appendEvent,
|
|
12
12
|
dropEmitter
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BMPB7XJH.js";
|
|
14
14
|
import {
|
|
15
15
|
archiveSession,
|
|
16
16
|
getSessionRow,
|
|
17
17
|
listIdleSessions,
|
|
18
18
|
updateSessionStatus
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-I5ZA45YL.js";
|
|
20
20
|
import {
|
|
21
21
|
getConfig
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-QH57EOKP.js";
|
|
23
23
|
import {
|
|
24
24
|
init_clock,
|
|
25
25
|
nowMs
|
|
@@ -51,13 +51,13 @@ async function runSweep() {
|
|
|
51
51
|
const cfg = getConfig();
|
|
52
52
|
if (cfg.spriteToken) {
|
|
53
53
|
try {
|
|
54
|
-
await
|
|
54
|
+
await reconcileOrphanSandboxes();
|
|
55
55
|
} catch (e) {
|
|
56
|
-
console.warn("[sweeper] reconcile
|
|
56
|
+
console.warn("[sweeper] reconcile sandboxes failed:", e);
|
|
57
57
|
}
|
|
58
58
|
}
|
|
59
59
|
try {
|
|
60
|
-
await
|
|
60
|
+
await reconcileDockerOrphanSandboxes();
|
|
61
61
|
} catch (e) {
|
|
62
62
|
if (!(e instanceof Error) || !e.message.includes("ENOENT")) {
|
|
63
63
|
console.warn("[sweeper] reconcile docker failed:", e);
|
|
@@ -1,7 +1,17 @@
|
|
|
1
|
+
import {
|
|
2
|
+
forwardToAnthropic
|
|
3
|
+
} from "./chunk-QLWA4MJ5.js";
|
|
4
|
+
import {
|
|
5
|
+
isAnthropicApiKey,
|
|
6
|
+
isPassthroughAllowedPath
|
|
7
|
+
} from "./chunk-W6WKXFHN.js";
|
|
1
8
|
import {
|
|
2
9
|
findByRawKey,
|
|
3
10
|
hydratePermissions
|
|
4
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-ADK2TYO4.js";
|
|
12
|
+
import {
|
|
13
|
+
getConfig
|
|
14
|
+
} from "./chunk-QH57EOKP.js";
|
|
5
15
|
import {
|
|
6
16
|
unauthorized
|
|
7
17
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -19,6 +29,21 @@ async function authenticate(request) {
|
|
|
19
29
|
const key = extractKey(request);
|
|
20
30
|
if (!key) throw unauthorized();
|
|
21
31
|
const row = findByRawKey(key);
|
|
32
|
+
if (isAnthropicApiKey(key)) {
|
|
33
|
+
if (!getConfig().anthropicPassthroughEnabled) throw unauthorized();
|
|
34
|
+
return {
|
|
35
|
+
keyId: "passthrough",
|
|
36
|
+
name: "anthropic-passthrough",
|
|
37
|
+
permissions: { admin: false, scope: null },
|
|
38
|
+
tenantId: null,
|
|
39
|
+
isGlobalAdmin: false,
|
|
40
|
+
budgetUsd: null,
|
|
41
|
+
rateLimitRpm: null,
|
|
42
|
+
spentUsd: 0,
|
|
43
|
+
mode: "passthrough",
|
|
44
|
+
passthroughKey: key
|
|
45
|
+
};
|
|
46
|
+
}
|
|
22
47
|
if (!row) throw unauthorized();
|
|
23
48
|
const permissions = hydratePermissions(row.permissions_json);
|
|
24
49
|
return {
|
|
@@ -34,11 +59,25 @@ async function authenticate(request) {
|
|
|
34
59
|
isGlobalAdmin: row.tenant_id === null && permissions.admin,
|
|
35
60
|
budgetUsd: row.budget_usd ?? null,
|
|
36
61
|
rateLimitRpm: row.rate_limit_rpm ?? null,
|
|
37
|
-
spentUsd: row.spent_usd ?? 0
|
|
62
|
+
spentUsd: row.spent_usd ?? 0,
|
|
63
|
+
mode: "gateway"
|
|
38
64
|
};
|
|
39
65
|
}
|
|
66
|
+
async function authenticateAndIntercept(request) {
|
|
67
|
+
const auth = await authenticate(request);
|
|
68
|
+
if (auth.mode !== "passthrough") return { kind: "auth", auth };
|
|
69
|
+
const url = new URL(request.url);
|
|
70
|
+
if (!isPassthroughAllowedPath(url.pathname)) {
|
|
71
|
+
throw unauthorized();
|
|
72
|
+
}
|
|
73
|
+
const response = await forwardToAnthropic(request, url.pathname, {
|
|
74
|
+
apiKey: auth.passthroughKey
|
|
75
|
+
});
|
|
76
|
+
return { kind: "response", response };
|
|
77
|
+
}
|
|
40
78
|
|
|
41
79
|
export {
|
|
42
80
|
extractKey,
|
|
43
|
-
authenticate
|
|
81
|
+
authenticate,
|
|
82
|
+
authenticateAndIntercept
|
|
44
83
|
};
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import {
|
|
2
2
|
piBackend
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-VS7AMAMU.js";
|
|
4
4
|
import {
|
|
5
5
|
opencodeBackend
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-GJBKDPQD.js";
|
|
7
7
|
import {
|
|
8
8
|
geminiBackend
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-HWWCVD2R.js";
|
|
10
10
|
import {
|
|
11
11
|
codexBackend
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-NK2RCTFI.js";
|
|
13
13
|
import {
|
|
14
14
|
factoryBackend
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-UJDAT42X.js";
|
|
16
16
|
import {
|
|
17
17
|
claudeBackend
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-SIKTYKVO.js";
|
|
19
19
|
|
|
20
20
|
// src/backends/registry.ts
|
|
21
21
|
var BACKENDS = {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getDrizzle,
|
|
3
3
|
init_drizzle
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-SXE7H3VK.js";
|
|
5
5
|
import {
|
|
6
6
|
schema_exports
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-LHHBOQUR.js";
|
|
8
8
|
import {
|
|
9
9
|
init_clock,
|
|
10
10
|
nowMs
|
|
@@ -44,15 +44,23 @@ function loadConfig() {
|
|
|
44
44
|
agentTimeoutMs: num(process.env.AGENT_TIMEOUT_MS, 6e5),
|
|
45
45
|
spriteTimeoutMs: num(process.env.SPRITE_TIMEOUT_MS, 3e4),
|
|
46
46
|
concurrency: num(process.env.CONCURRENCY, 4),
|
|
47
|
-
|
|
47
|
+
maxSandboxesPerEnv: num(process.env.MAX_SANDBOXES_PER_ENV, 8),
|
|
48
48
|
sessionMaxAgeMs: num(process.env.SESSION_MAX_AGE_MS, 7 * 24 * 3600 * 1e3),
|
|
49
49
|
sweeperIntervalMs: num(process.env.SWEEPER_INTERVAL_MS, 6e4),
|
|
50
50
|
otlpEndpoint: process.env.OTEL_EXPORTER_OTLP_ENDPOINT || process.env.OTLP_ENDPOINT || readSetting("otlp_endpoint") || void 0,
|
|
51
51
|
otlpAuthorization: process.env.OTEL_EXPORTER_OTLP_HEADERS_AUTHORIZATION || process.env.OTLP_AUTHORIZATION || readSetting("otlp_authorization") || void 0,
|
|
52
52
|
redactEnvKeys: (process.env.OBS_REDACT_KEYS || readSetting("obs_redact_keys") || "").split(",").map((s) => s.trim()).filter(Boolean),
|
|
53
|
-
ollamaUrl: process.env.OLLAMA_URL || readSetting("ollama_url") || "http://localhost:11434"
|
|
53
|
+
ollamaUrl: process.env.OLLAMA_URL || readSetting("ollama_url") || "http://localhost:11434",
|
|
54
|
+
anthropicPassthroughEnabled: parseBool(
|
|
55
|
+
process.env.ANTHROPIC_PASSTHROUGH_ENABLED ?? readSetting("anthropic_passthrough_enabled")
|
|
56
|
+
)
|
|
54
57
|
};
|
|
55
58
|
}
|
|
59
|
+
function parseBool(v) {
|
|
60
|
+
if (!v) return false;
|
|
61
|
+
const s = v.toLowerCase();
|
|
62
|
+
return s === "1" || s === "true" || s === "yes";
|
|
63
|
+
}
|
|
56
64
|
function getConfig() {
|
|
57
65
|
const now = nowMs();
|
|
58
66
|
if (g.__caConfigCache && now - g.__caConfigCache.at < CACHE_MS) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getConfig
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QH57EOKP.js";
|
|
4
4
|
import {
|
|
5
5
|
ApiError
|
|
6
6
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -34,16 +34,27 @@ async function forwardToAnthropic(request, path, opts) {
|
|
|
34
34
|
if (idem) headers.set("idempotency-key", idem);
|
|
35
35
|
const accept = request.headers.get("accept");
|
|
36
36
|
if (accept) headers.set("accept", accept);
|
|
37
|
+
const isMultipart = (ct ?? "").toLowerCase().startsWith("multipart/");
|
|
37
38
|
let body;
|
|
38
39
|
if (request.method !== "GET" && request.method !== "HEAD") {
|
|
39
|
-
|
|
40
|
+
if (opts?.body !== void 0) {
|
|
41
|
+
body = opts.body;
|
|
42
|
+
} else if (isMultipart && request.body) {
|
|
43
|
+
body = request.body;
|
|
44
|
+
} else {
|
|
45
|
+
body = await request.text();
|
|
46
|
+
}
|
|
40
47
|
}
|
|
41
|
-
const
|
|
48
|
+
const fetchInit = {
|
|
42
49
|
method: request.method,
|
|
43
50
|
headers,
|
|
44
51
|
body,
|
|
45
52
|
signal: request.signal
|
|
46
|
-
}
|
|
53
|
+
};
|
|
54
|
+
if (body && typeof body !== "string") {
|
|
55
|
+
fetchInit.duplex = "half";
|
|
56
|
+
}
|
|
57
|
+
const res = await fetch(url.toString(), fetchInit);
|
|
47
58
|
const HOP_BY_HOP = /* @__PURE__ */ new Set([
|
|
48
59
|
"connection",
|
|
49
60
|
"keep-alive",
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
// src/backends/factory/wrapper-script.ts
|
|
2
2
|
var FACTORY_WRAPPER_PATH = "/tmp/.factory-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 droid "$@" "$PROMPT"'
|
|
9
9
|
].join("\n");
|
|
10
|
-
async function installFactoryWrapper(
|
|
11
|
-
const escaped =
|
|
12
|
-
await provider.exec(
|
|
10
|
+
async function installFactoryWrapper(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}' > ${FACTORY_WRAPPER_PATH} && chmod +x ${FACTORY_WRAPPER_PATH}`
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
installPiWrapper
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JDBXIJKG.js";
|
|
4
4
|
|
|
5
5
|
// src/backends/pi/setup.ts
|
|
6
6
|
var SENTINEL_NAME = ".claude-agents-pi-installed";
|
|
7
|
-
async function
|
|
8
|
-
await installPiWrapper(
|
|
7
|
+
async function preparePiOnSandbox(sandboxName, provider) {
|
|
8
|
+
await installPiWrapper(sandboxName, provider);
|
|
9
9
|
const script = [
|
|
10
10
|
"set -euo pipefail",
|
|
11
11
|
`SENTINEL="$HOME/${SENTINEL_NAME}"`,
|
|
@@ -16,7 +16,7 @@ async function preparePiOnSprite(spriteName, provider) {
|
|
|
16
16
|
"/usr/local/bin/pi --version || $PREFIX/bin/pi --version",
|
|
17
17
|
'touch "$SENTINEL"'
|
|
18
18
|
].join(" && ");
|
|
19
|
-
const result = await provider.exec(
|
|
19
|
+
const result = await provider.exec(sandboxName, ["bash", "-c", script], {
|
|
20
20
|
timeoutMs: 5 * 6e4
|
|
21
21
|
});
|
|
22
22
|
if (result.exit_code !== 0) {
|
|
@@ -27,5 +27,5 @@ async function preparePiOnSprite(spriteName, provider) {
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
export {
|
|
30
|
-
|
|
30
|
+
preparePiOnSandbox
|
|
31
31
|
};
|
|
@@ -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,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
markStopping
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-PNYCULIF.js";
|
|
4
4
|
import {
|
|
5
5
|
closeDb,
|
|
6
6
|
init_client,
|
|
7
7
|
syncDb
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-5GZEX4HV.js";
|
|
9
9
|
import {
|
|
10
10
|
getRuntime
|
|
11
11
|
} from "./chunk-UYTSKFGK.js";
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveContainerProvider
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-JSLEB2ED.js";
|
|
4
4
|
import {
|
|
5
5
|
getEnvironmentRow,
|
|
6
6
|
updateEnvironmentState
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-NUO56TF7.js";
|
|
8
8
|
import {
|
|
9
9
|
installClaudeWrapper
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-IU457W7Q.js";
|
|
11
11
|
import {
|
|
12
12
|
init_ids,
|
|
13
13
|
newId
|
|
@@ -47,14 +47,14 @@ function buildInstallCommands(packages) {
|
|
|
47
47
|
function shellEscape(s) {
|
|
48
48
|
return `'${s.replace(/'/g, "'\\''")}'`;
|
|
49
49
|
}
|
|
50
|
-
async function prepareSprite(
|
|
50
|
+
async function prepareSprite(sandboxName, packages, provider) {
|
|
51
51
|
const p = provider ?? await resolveContainerProvider();
|
|
52
|
-
await installClaudeWrapper(
|
|
52
|
+
await installClaudeWrapper(sandboxName, p);
|
|
53
53
|
const hash = hashPackages(packages);
|
|
54
54
|
const sentinel = `${SENTINEL_DIR}/.claude-agents-setup-${hash}`;
|
|
55
55
|
const installCmds = buildInstallCommands(packages);
|
|
56
56
|
if (installCmds.length === 0) {
|
|
57
|
-
await p.exec(
|
|
57
|
+
await p.exec(sandboxName, ["bash", "-c", `touch ${sentinel}`]);
|
|
58
58
|
return;
|
|
59
59
|
}
|
|
60
60
|
const script = [
|
|
@@ -63,7 +63,7 @@ async function prepareSprite(spriteName, packages, provider) {
|
|
|
63
63
|
...installCmds,
|
|
64
64
|
`touch ${sentinel}`
|
|
65
65
|
].join(" && ");
|
|
66
|
-
const result = await p.exec(
|
|
66
|
+
const result = await p.exec(sandboxName, ["bash", "-c", script], {
|
|
67
67
|
timeoutMs: 30 * 6e4
|
|
68
68
|
});
|
|
69
69
|
if (result.exit_code !== 0) {
|