@agentstep/agent-sdk 0.5.10 → 0.5.12
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 +8 -8
- package/dist/backends/claude/args.js +6 -6
- package/dist/backends/claude/index.js +12 -12
- package/dist/backends/claude/wrapper-script.js +1 -1
- package/dist/backends/codex/auth.js +6 -6
- package/dist/backends/codex/index.js +14 -14
- package/dist/backends/codex/setup.js +2 -2
- package/dist/backends/codex/wrapper-script.js +1 -1
- package/dist/backends/factory/auth.js +6 -6
- package/dist/backends/factory/index.js +16 -16
- package/dist/backends/factory/setup.js +2 -2
- package/dist/backends/factory/wrapper-script.js +1 -1
- package/dist/backends/gemini/auth.js +6 -6
- package/dist/backends/gemini/index.js +12 -12
- package/dist/backends/gemini/setup.js +2 -2
- package/dist/backends/gemini/wrapper-script.js +1 -1
- package/dist/backends/opencode/auth.js +6 -6
- package/dist/backends/opencode/index.js +14 -14
- package/dist/backends/opencode/setup.js +2 -2
- 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 +2 -2
- package/dist/backends/pi/wrapper-script.js +1 -1
- package/dist/backends/registry.js +36 -36
- package/dist/{chunk-ZEDULYKX.js → chunk-2IISXUVF.js} +1 -1
- package/dist/{chunk-34Q6WMIT.js → chunk-2Z56TPBL.js} +3 -3
- package/dist/{chunk-WCLMAQR4.js → chunk-3DRK36FB.js} +5 -5
- package/dist/{chunk-2PTWIZX6.js → chunk-3NNU7TQ4.js} +8 -8
- package/dist/{chunk-NFGCFN57.js → chunk-3UK3IF27.js} +6 -6
- package/dist/chunk-4ANV3AH3.js +65 -0
- package/dist/{chunk-RNU253MD.js → chunk-4ENK7S24.js} +21 -2
- package/dist/{chunk-IFZ7EXMG.js → chunk-4EVT4MFD.js} +1 -1
- package/dist/{chunk-7POF237O.js → chunk-4MKJB6U2.js} +1 -1
- package/dist/{chunk-WKPUTJGD.js → chunk-5LDBCBOR.js} +1 -1
- package/dist/{chunk-ZIMK4TPI.js → chunk-6PIL2RJD.js} +2 -2
- package/dist/{chunk-6TRWB7CE.js → chunk-6X3G5SAS.js} +41 -18
- package/dist/{chunk-LVSQULRG.js → chunk-7ASUTNKE.js} +2 -2
- package/dist/{chunk-KJENLSJT.js → chunk-7BT6V4CH.js} +20 -18
- package/dist/{chunk-5COWXLGO.js → chunk-7D55V4XP.js} +1 -1
- package/dist/{chunk-KYDOZBD5.js → chunk-7NZ46LIO.js} +29 -28
- package/dist/{chunk-4QBWHZKQ.js → chunk-7SO7O6RV.js} +2 -2
- package/dist/{chunk-4JPJ3ZIV.js → chunk-7Z6LTBYQ.js} +5 -5
- package/dist/{chunk-NVTDXBGV.js → chunk-APKELBCA.js} +1 -1
- package/dist/{chunk-YSUPRYX2.js → chunk-AQHYCRTO.js} +1 -1
- package/dist/{chunk-GUD3MOP7.js → chunk-B3UOTIOI.js} +9 -9
- package/dist/{chunk-2OFGWHZB.js → chunk-B5JUCPYW.js} +1 -1
- package/dist/{chunk-LJSD6G6K.js → chunk-BQ5MWNWN.js} +3 -3
- package/dist/{chunk-SKRIZPPF.js → chunk-BYJRL4IQ.js} +6 -6
- package/dist/{chunk-56KP3SAI.js → chunk-C3ZPWUDE.js} +2 -2
- package/dist/{chunk-LSXVCZN7.js → chunk-CD2FQVQR.js} +1 -1
- package/dist/{chunk-6BOOQV4Q.js → chunk-CFLMIJ2C.js} +3 -3
- package/dist/{chunk-6BRG2NJL.js → chunk-CGGGCKSK.js} +4 -4
- package/dist/{chunk-QYSDP6V5.js → chunk-CMOU2OFW.js} +1 -1
- package/dist/chunk-D2GADI73.js +253 -0
- package/dist/{chunk-75C3KFST.js → chunk-D3TY7PMJ.js} +5 -5
- package/dist/{chunk-RTZNJDEL.js → chunk-DAIEVD4O.js} +4 -4
- package/dist/{chunk-BGNQXT4T.js → chunk-DDF2CRA3.js} +2 -2
- package/dist/{chunk-DQ5VMD3Z.js → chunk-FCKUWBUL.js} +2 -2
- package/dist/{chunk-YFGBTXID.js → chunk-FV2XE3DX.js} +2 -2
- package/dist/{chunk-73BYGQWA.js → chunk-G7Y5YGLE.js} +1 -1
- package/dist/{chunk-PXOL34HI.js → chunk-HE3IEIKM.js} +3 -3
- package/dist/{chunk-WKMRBRJQ.js → chunk-HH23DOBB.js} +1 -1
- package/dist/{chunk-HCORTMQH.js → chunk-HHS6EHSG.js} +4 -4
- package/dist/{chunk-6T4DKZYW.js → chunk-ISXWS5Y4.js} +8 -8
- package/dist/{chunk-QBJOYOVF.js → chunk-J6T3W6RY.js} +15 -0
- package/dist/{chunk-CXDNTVCM.js → chunk-JK2GXKOQ.js} +5 -5
- package/dist/{chunk-A4BGGHRC.js → chunk-JXU6SA6S.js} +42 -1
- package/dist/{chunk-37Y556D5.js → chunk-KHICXOTH.js} +3 -3
- package/dist/chunk-KJ2GJLPQ.js +39 -0
- package/dist/{chunk-BUQATYS7.js → chunk-KNWM237Q.js} +2 -2
- package/dist/{chunk-RNDLMMKI.js → chunk-LOWHDHDD.js} +3 -3
- package/dist/{chunk-6SVZD3UA.js → chunk-M4OF5D4K.js} +4 -4
- package/dist/{chunk-CZPWZ5A5.js → chunk-M7SYXJBT.js} +1 -1
- package/dist/{chunk-IBO36HUU.js → chunk-MQBNN4KH.js} +1 -1
- package/dist/{chunk-32RP2UX6.js → chunk-MTB7SCZ5.js} +5 -5
- package/dist/{chunk-LEVIKSPQ.js → chunk-MTRTBT7L.js} +1 -1
- package/dist/{chunk-TARFRZ44.js → chunk-N5F5OUUZ.js} +3 -3
- package/dist/{chunk-M2LUXIXU.js → chunk-NMZMRH3E.js} +1 -1
- package/dist/{chunk-KGTWD46T.js → chunk-NWIMPG4M.js} +1 -1
- package/dist/chunk-OGA7KDQZ.js +37 -0
- package/dist/chunk-ONEKY3CM.js +146 -0
- package/dist/{chunk-SUFGP47L.js → chunk-ONS32E65.js} +28 -20
- package/dist/{chunk-XG4UIGDH.js → chunk-PAQ2JFVD.js} +1 -1
- package/dist/{chunk-N5C3WQWD.js → chunk-PDUQCDIO.js} +1 -1
- package/dist/{chunk-DSNNEER4.js → chunk-PJTGQVKB.js} +1 -1
- package/dist/{chunk-SAUR463Z.js → chunk-PLSXDJT4.js} +6 -5
- package/dist/{chunk-NL4EKSFA.js → chunk-PPI76YVT.js} +2 -2
- package/dist/{chunk-N33MOUCH.js → chunk-PRWWTLPR.js} +3 -3
- package/dist/{chunk-T75UYYMI.js → chunk-PVFGDKXO.js} +2 -2
- package/dist/{chunk-PIJJXKMK.js → chunk-PXMTLKUJ.js} +3 -3
- package/dist/chunk-PZ5EGY64.js +37 -0
- package/dist/{chunk-6ERUVF2Y.js → chunk-QB7JAMWG.js} +1 -1
- package/dist/{chunk-IY3KO2BC.js → chunk-QS544PN6.js} +4 -4
- package/dist/{chunk-GBGXSRZX.js → chunk-R5LXEIOJ.js} +9 -9
- package/dist/{chunk-OJUDLJOG.js → chunk-REY2YZ5X.js} +3 -3
- package/dist/{chunk-4IEDAORR.js → chunk-RFK4W5PZ.js} +1 -1
- package/dist/{chunk-NOG7ZJJA.js → chunk-RLLVP37Q.js} +1 -1
- package/dist/{chunk-HV7M7UUY.js → chunk-S5NB47IR.js} +6 -6
- package/dist/{chunk-3XGUMXGR.js → chunk-SXR4HQZY.js} +2 -2
- package/dist/{chunk-YN2F26NN.js → chunk-T3CXZ2BE.js} +2 -2
- package/dist/{chunk-MF3J7WTR.js → chunk-TN34IN7S.js} +16 -13
- package/dist/{chunk-XUODI55L.js → chunk-U3QU5AVC.js} +1 -1
- package/dist/{chunk-PNJRIMKJ.js → chunk-UB5WVCY4.js} +3 -3
- package/dist/{chunk-P7P2NWZD.js → chunk-URNG7ZX2.js} +1 -1
- package/dist/{chunk-3TF3YLM2.js → chunk-UROFA6OZ.js} +2 -2
- package/dist/{chunk-T5P54I7S.js → chunk-UTQRPXTL.js} +9 -8
- package/dist/{chunk-Y3EUEPGQ.js → chunk-UWHV7EJG.js} +2 -2
- package/dist/chunk-UY3VT3HQ.js +39 -0
- package/dist/{chunk-5LXMEHQX.js → chunk-VG2TYPZ4.js} +18 -2
- package/dist/{chunk-EZBJEV6F.js → chunk-VTH56ERA.js} +4 -4
- package/dist/{chunk-Z4DZMNDE.js → chunk-W6QYWXOZ.js} +2 -2
- package/dist/{chunk-3WZGFAV4.js → chunk-WKGJQIRC.js} +4 -3
- package/dist/{chunk-EGN4TPN5.js → chunk-WT3SEE34.js} +3 -3
- package/dist/{chunk-CZ4IOIWV.js → chunk-X23OAFFE.js} +4 -4
- package/dist/{chunk-E4FQRMHV.js → chunk-XJYR5HE3.js} +18 -0
- package/dist/{chunk-X3IXLDWQ.js → chunk-XSRIFWHR.js} +2 -2
- package/dist/{chunk-SS5IC3XV.js → chunk-Y6BFKPNB.js} +1 -1
- package/dist/{chunk-EFSLGRY2.js → chunk-YCL5RHEC.js} +2 -2
- package/dist/{chunk-LGVD2IGL.js → chunk-YD67W6DW.js} +9 -9
- package/dist/{chunk-J3XIGC3L.js → chunk-YE47YUGE.js} +6 -6
- package/dist/{chunk-F6DCNXO5.js → chunk-YEJFXJHR.js} +2 -2
- package/dist/{chunk-ZV6Y5VOD.js → chunk-YUVQQCT4.js} +15 -15
- package/dist/{chunk-T64ECODW.js → chunk-YUZFNAG6.js} +21 -0
- package/dist/{chunk-OWG6UV4S.js → chunk-YWAMRRAX.js} +10 -10
- 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 +48 -48
- package/dist/containers/setup.js +10 -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 +5 -3
- package/dist/db/session-resources.js +5 -5
- package/dist/db/sessions.js +8 -8
- package/dist/db/skills.js +5 -5
- package/dist/db/sync.js +5 -5
- package/dist/db/tenants.js +3 -3
- package/dist/db/threads.js +7 -7
- package/dist/db/traces.js +5 -5
- package/dist/db/upstream_keys.js +3 -3
- package/dist/db/vaults.js +6 -6
- package/dist/db/work.js +33 -0
- package/dist/dreaming/review.js +11 -11
- package/dist/handlers/agents.js +64 -64
- package/dist/handlers/api_keys.js +65 -65
- package/dist/handlers/audit.js +65 -65
- package/dist/handlers/batch.js +65 -65
- package/dist/handlers/credentials.js +65 -65
- package/dist/handlers/environments.js +65 -65
- package/dist/handlers/events.js +68 -68
- package/dist/handlers/files.js +65 -65
- package/dist/handlers/index.js +141 -120
- package/dist/handlers/license.js +64 -64
- package/dist/handlers/memory.js +66 -66
- package/dist/handlers/metrics.js +64 -64
- package/dist/handlers/models.js +65 -65
- package/dist/handlers/providers.js +64 -64
- package/dist/handlers/resources.js +64 -64
- package/dist/handlers/sessions.js +68 -68
- package/dist/handlers/settings.js +64 -64
- package/dist/handlers/skills-write.js +67 -65
- package/dist/handlers/skills.js +65 -65
- package/dist/handlers/stream.js +64 -64
- package/dist/handlers/tenants.js +65 -65
- package/dist/handlers/threads.js +65 -65
- package/dist/handlers/traces.js +65 -65
- package/dist/handlers/ui.d.ts +6 -0
- package/dist/handlers/ui.d.ts.map +1 -0
- package/dist/handlers/ui.js +1 -1
- package/dist/handlers/upstream_keys.js +67 -67
- package/dist/handlers/vaults.js +64 -64
- package/dist/handlers/whoami.js +64 -64
- package/dist/handlers/work.js +114 -0
- package/dist/http.js +63 -63
- package/dist/index.js +84 -73
- package/dist/init.js +60 -60
- 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/providers/daytona.js +1 -1
- package/dist/providers/fly.js +7 -6
- package/dist/providers/modal.js +5 -5
- package/dist/providers/registry.js +15 -3
- package/dist/providers/resolve-secrets.js +7 -7
- package/dist/providers/sprites.js +7 -7
- package/dist/providers/upstream-keys.js +12 -12
- 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 +53 -53
- package/dist/sessions/grader.js +5 -5
- package/dist/sessions/secrets.js +8 -8
- package/dist/sessions/sweeper.js +49 -49
- package/dist/sessions/threads.js +54 -54
- package/dist/shutdown.js +50 -50
- package/dist/sync/anthropic.js +10 -10
- package/dist/sync/container-file-sync.js +6 -6
- package/dist/sync/file-sync.js +17 -17
- package/dist/workers/runner.js +85 -0
- package/package.json +1 -1
- package/dist/chunk-3W6KEDQE.js +0 -20
- package/dist/chunk-JDBXIJKG.js +0 -20
- package/dist/chunk-QQDSHL27.js +0 -22
- package/dist/chunk-SWIP7JBQ.js +0 -22
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getAgent
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-WT3SEE34.js";
|
|
4
4
|
import {
|
|
5
5
|
init_ids,
|
|
6
6
|
newId
|
|
@@ -13,10 +13,10 @@ import {
|
|
|
13
13
|
import {
|
|
14
14
|
getDrizzle,
|
|
15
15
|
init_drizzle
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-PVFGDKXO.js";
|
|
17
17
|
import {
|
|
18
18
|
schema_exports
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-4ENK7S24.js";
|
|
20
20
|
|
|
21
21
|
// src/db/threads.ts
|
|
22
22
|
init_drizzle();
|
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
} from "./chunk-23UKWXJH.js";
|
|
5
5
|
import {
|
|
6
6
|
reviewSessions
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PXMTLKUJ.js";
|
|
8
8
|
import {
|
|
9
9
|
archiveMemoryStore,
|
|
10
10
|
createMemoryStore,
|
|
@@ -20,19 +20,19 @@ import {
|
|
|
20
20
|
redactMemoryVersion,
|
|
21
21
|
updateMemory,
|
|
22
22
|
updateMemoryStore
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-T3CXZ2BE.js";
|
|
24
24
|
import {
|
|
25
25
|
jsonOk,
|
|
26
26
|
paginatedOk,
|
|
27
27
|
routeWrap
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FCKUWBUL.js";
|
|
29
29
|
import {
|
|
30
30
|
getConfig
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-WKGJQIRC.js";
|
|
32
32
|
import {
|
|
33
33
|
getDb,
|
|
34
34
|
init_client
|
|
35
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-U3QU5AVC.js";
|
|
36
36
|
import {
|
|
37
37
|
badRequest,
|
|
38
38
|
conflict,
|
|
@@ -1,32 +1,32 @@
|
|
|
1
1
|
import {
|
|
2
2
|
resolveRemoteSessionId
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LOWHDHDD.js";
|
|
4
4
|
import {
|
|
5
5
|
assertResourceTenant
|
|
6
6
|
} from "./chunk-23UKWXJH.js";
|
|
7
7
|
import {
|
|
8
8
|
authenticateAndIntercept
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-BQ5MWNWN.js";
|
|
10
10
|
import {
|
|
11
11
|
forwardToAnthropic
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-5LDBCBOR.js";
|
|
13
13
|
import {
|
|
14
14
|
ensureInitialized
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-7BT6V4CH.js";
|
|
16
16
|
import {
|
|
17
17
|
getProxiedTenantId,
|
|
18
18
|
isProxied
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-YCL5RHEC.js";
|
|
20
20
|
import {
|
|
21
21
|
subscribe
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-X23OAFFE.js";
|
|
23
23
|
import {
|
|
24
24
|
getSession
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-MTB7SCZ5.js";
|
|
26
26
|
import {
|
|
27
27
|
getDb,
|
|
28
28
|
init_client
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-U3QU5AVC.js";
|
|
30
30
|
import {
|
|
31
31
|
notFound,
|
|
32
32
|
toResponse
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createGeminiTranslator
|
|
3
|
+
} from "./chunk-S3JRZFF5.js";
|
|
1
4
|
import {
|
|
2
5
|
buildGeminiArgs
|
|
3
6
|
} from "./chunk-IBYOMAZ3.js";
|
|
4
7
|
import {
|
|
5
8
|
buildGeminiAuthEnv,
|
|
6
9
|
validateGeminiRuntime
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-RLLVP37Q.js";
|
|
8
11
|
import {
|
|
9
12
|
prepareGeminiOnSandbox
|
|
10
|
-
} from "./chunk-
|
|
11
|
-
import {
|
|
12
|
-
createGeminiTranslator
|
|
13
|
-
} from "./chunk-S3JRZFF5.js";
|
|
13
|
+
} from "./chunk-PAQ2JFVD.js";
|
|
14
14
|
import {
|
|
15
15
|
GEMINI_WRAPPER_PATH
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-PZ5EGY64.js";
|
|
17
17
|
import {
|
|
18
18
|
wrapPromptWithSystem
|
|
19
19
|
} from "./chunk-YE2RMJY7.js";
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ackWorkItem,
|
|
3
|
+
completeWorkItem,
|
|
4
|
+
getWorkItemInputs,
|
|
5
|
+
heartbeatWorkItem,
|
|
6
|
+
pollWorkItem
|
|
7
|
+
} from "./chunk-D2GADI73.js";
|
|
8
|
+
import {
|
|
9
|
+
runTurn
|
|
10
|
+
} from "./chunk-7NZ46LIO.js";
|
|
11
|
+
|
|
12
|
+
// src/workers/runner.ts
|
|
13
|
+
async function startWorker(opts) {
|
|
14
|
+
const pollInterval = opts.pollIntervalMs ?? 5e3;
|
|
15
|
+
const workerId = opts.workerId ?? `worker-${process.pid}`;
|
|
16
|
+
let stopping = false;
|
|
17
|
+
process.on("SIGINT", () => {
|
|
18
|
+
stopping = true;
|
|
19
|
+
});
|
|
20
|
+
process.on("SIGTERM", () => {
|
|
21
|
+
stopping = true;
|
|
22
|
+
});
|
|
23
|
+
console.log(`[worker] starting: env=${opts.environmentId} poll=${pollInterval}ms worker=${workerId}`);
|
|
24
|
+
while (!stopping) {
|
|
25
|
+
const item = pollWorkItem(opts.environmentId, workerId);
|
|
26
|
+
if (!item) {
|
|
27
|
+
await new Promise((r) => setTimeout(r, pollInterval));
|
|
28
|
+
continue;
|
|
29
|
+
}
|
|
30
|
+
console.log(`[worker] claimed ${item.id} -> session ${item.data.id}`);
|
|
31
|
+
const acked = ackWorkItem(item.id, workerId);
|
|
32
|
+
if (!acked) {
|
|
33
|
+
console.warn(`[worker] ack failed for ${item.id} \u2014 another worker claimed it`);
|
|
34
|
+
continue;
|
|
35
|
+
}
|
|
36
|
+
const heartbeatTimer = setInterval(() => {
|
|
37
|
+
const result = heartbeatWorkItem(item.id);
|
|
38
|
+
if (result && !result.lease_extended) {
|
|
39
|
+
console.warn(`[worker] heartbeat failed for ${item.id}: state=${result.state}`);
|
|
40
|
+
}
|
|
41
|
+
}, 3e4);
|
|
42
|
+
try {
|
|
43
|
+
const inputsRaw = getWorkItemInputs(item.id);
|
|
44
|
+
const inputs = inputsRaw ? JSON.parse(inputsRaw) : [];
|
|
45
|
+
if (inputs.length > 0) {
|
|
46
|
+
await runTurn(item.data.id, inputs);
|
|
47
|
+
} else {
|
|
48
|
+
console.warn(`[worker] no inputs for ${item.id} \u2014 skipping`);
|
|
49
|
+
}
|
|
50
|
+
completeWorkItem(item.id, "completed");
|
|
51
|
+
console.log(`[worker] completed ${item.id}`);
|
|
52
|
+
} catch (err) {
|
|
53
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
54
|
+
console.error(`[worker] failed ${item.id}: ${msg}`);
|
|
55
|
+
completeWorkItem(item.id, "failed");
|
|
56
|
+
} finally {
|
|
57
|
+
clearInterval(heartbeatTimer);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
console.log("[worker] stopped");
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export {
|
|
64
|
+
startWorker
|
|
65
|
+
};
|
|
@@ -24,10 +24,11 @@ __export(schema_exports, {
|
|
|
24
24
|
skillVersions: () => skillVersions,
|
|
25
25
|
skills: () => skills,
|
|
26
26
|
vaultEntries: () => vaultEntries,
|
|
27
|
-
vaults: () => vaults
|
|
27
|
+
vaults: () => vaults,
|
|
28
|
+
workItems: () => workItems
|
|
28
29
|
});
|
|
29
30
|
import { sqliteTable, text, integer, real, primaryKey } from "drizzle-orm/sqlite-core";
|
|
30
|
-
var settings, proxyResources, apiKeys, agents, agentVersions, environments, sessions, events, sessionThreads, vaults, vaultEntries, memoryStores, memoryVersions, memories, files, sessionResources, skills, skillVersions, anthropicSync;
|
|
31
|
+
var settings, proxyResources, apiKeys, agents, agentVersions, environments, sessions, events, sessionThreads, vaults, vaultEntries, memoryStores, memoryVersions, memories, files, sessionResources, skills, skillVersions, workItems, anthropicSync;
|
|
31
32
|
var init_schema = __esm({
|
|
32
33
|
"src/db/schema.ts"() {
|
|
33
34
|
settings = sqliteTable("settings", {
|
|
@@ -275,6 +276,23 @@ var init_schema = __esm({
|
|
|
275
276
|
files_json: text("files_json").notNull().default("{}"),
|
|
276
277
|
created_at: integer("created_at").notNull()
|
|
277
278
|
});
|
|
279
|
+
workItems = sqliteTable("work_items", {
|
|
280
|
+
id: text("id").primaryKey(),
|
|
281
|
+
environment_id: text("environment_id").notNull(),
|
|
282
|
+
session_id: text("session_id").notNull(),
|
|
283
|
+
state: text("state").notNull().default("queued"),
|
|
284
|
+
worker_id: text("worker_id"),
|
|
285
|
+
inputs_json: text("inputs_json"),
|
|
286
|
+
metadata_json: text("metadata_json").notNull().default("{}"),
|
|
287
|
+
tenant_id: text("tenant_id"),
|
|
288
|
+
created_at: integer("created_at").notNull(),
|
|
289
|
+
acknowledged_at: integer("acknowledged_at"),
|
|
290
|
+
started_at: integer("started_at"),
|
|
291
|
+
latest_heartbeat_at: integer("latest_heartbeat_at"),
|
|
292
|
+
stop_requested_at: integer("stop_requested_at"),
|
|
293
|
+
stopped_at: integer("stopped_at"),
|
|
294
|
+
lease_expires_at: integer("lease_expires_at")
|
|
295
|
+
});
|
|
278
296
|
anthropicSync = sqliteTable("anthropic_sync", {
|
|
279
297
|
local_id: text("local_id").notNull(),
|
|
280
298
|
resource_type: text("resource_type").notNull(),
|
|
@@ -306,6 +324,7 @@ export {
|
|
|
306
324
|
sessionResources,
|
|
307
325
|
skills,
|
|
308
326
|
skillVersions,
|
|
327
|
+
workItems,
|
|
309
328
|
anthropicSync,
|
|
310
329
|
schema_exports,
|
|
311
330
|
init_schema
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchError,
|
|
3
3
|
executeBatch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VTH56ERA.js";
|
|
5
5
|
import {
|
|
6
6
|
jsonOk,
|
|
7
7
|
routeWrap
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-FCKUWBUL.js";
|
|
9
9
|
import {
|
|
10
10
|
badRequest
|
|
11
11
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -2,10 +2,10 @@ import {
|
|
|
2
2
|
reportUpstreamFailure,
|
|
3
3
|
reportUpstreamSuccess,
|
|
4
4
|
resolveAnthropicKey
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-HHS6EHSG.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveRemoteSessionId
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-LOWHDHDD.js";
|
|
9
9
|
import {
|
|
10
10
|
assertResourceTenant
|
|
11
11
|
} from "./chunk-23UKWXJH.js";
|
|
@@ -20,46 +20,50 @@ import {
|
|
|
20
20
|
listMemoryStores,
|
|
21
21
|
searchMemories,
|
|
22
22
|
updateMemory
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-T3CXZ2BE.js";
|
|
24
24
|
import {
|
|
25
25
|
jsonOk,
|
|
26
26
|
paginatedOk,
|
|
27
27
|
routeWrap
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-FCKUWBUL.js";
|
|
29
29
|
import {
|
|
30
30
|
forwardToAnthropic
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-5LDBCBOR.js";
|
|
32
32
|
import {
|
|
33
33
|
enqueueTurn
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-MTRTBT7L.js";
|
|
35
35
|
import {
|
|
36
36
|
runTurn,
|
|
37
37
|
writePermissionResponse
|
|
38
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-7NZ46LIO.js";
|
|
39
39
|
import {
|
|
40
40
|
getProxiedTenantId,
|
|
41
41
|
isProxied
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-YCL5RHEC.js";
|
|
43
43
|
import {
|
|
44
44
|
getActor
|
|
45
45
|
} from "./chunk-LAWTTG2E.js";
|
|
46
46
|
import {
|
|
47
47
|
appendEvent
|
|
48
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-X23OAFFE.js";
|
|
49
49
|
import {
|
|
50
50
|
bumpSessionStats,
|
|
51
51
|
getSession,
|
|
52
52
|
getSessionRow,
|
|
53
53
|
setOutcomeCriteria,
|
|
54
54
|
updateSessionMutable
|
|
55
|
-
} from "./chunk-
|
|
55
|
+
} from "./chunk-MTB7SCZ5.js";
|
|
56
56
|
import {
|
|
57
57
|
listEvents,
|
|
58
58
|
rowToManagedEvent
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-PRWWTLPR.js";
|
|
60
|
+
import {
|
|
61
|
+
getEnvironment,
|
|
62
|
+
getEnvironmentRow
|
|
63
|
+
} from "./chunk-CFLMIJ2C.js";
|
|
60
64
|
import {
|
|
61
65
|
getAgent
|
|
62
|
-
} from "./chunk-
|
|
66
|
+
} from "./chunk-WT3SEE34.js";
|
|
63
67
|
import {
|
|
64
68
|
init_clock,
|
|
65
69
|
nowMs
|
|
@@ -67,7 +71,7 @@ import {
|
|
|
67
71
|
import {
|
|
68
72
|
getDb,
|
|
69
73
|
init_client
|
|
70
|
-
} from "./chunk-
|
|
74
|
+
} from "./chunk-U3QU5AVC.js";
|
|
71
75
|
import {
|
|
72
76
|
badRequest,
|
|
73
77
|
notFound
|
|
@@ -655,11 +659,30 @@ function handlePostEvents(request, sessionId) {
|
|
|
655
659
|
if (appended.pendingForTurn.length > 0) {
|
|
656
660
|
const row = getSessionRow(sessionId);
|
|
657
661
|
if (row) {
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
}
|
|
662
|
-
|
|
662
|
+
const env = getEnvironment(row.environment_id);
|
|
663
|
+
if (env?.config?.type === "self_hosted") {
|
|
664
|
+
const { createWorkItem } = await import("./db/work.js");
|
|
665
|
+
const { updateSessionStatus } = await import("./db/sessions.js");
|
|
666
|
+
const inputsJson = JSON.stringify(appended.pendingForTurn);
|
|
667
|
+
const envRow = getEnvironmentRow(row.environment_id);
|
|
668
|
+
createWorkItem(row.environment_id, sessionId, {
|
|
669
|
+
inputsJson,
|
|
670
|
+
tenantId: envRow?.tenant_id ?? void 0
|
|
671
|
+
});
|
|
672
|
+
updateSessionStatus(sessionId, "running");
|
|
673
|
+
appendEvent(sessionId, {
|
|
674
|
+
type: "session.status_running",
|
|
675
|
+
payload: {},
|
|
676
|
+
origin: "server",
|
|
677
|
+
processedAt: nowMs()
|
|
678
|
+
});
|
|
679
|
+
} else {
|
|
680
|
+
void enqueueTurn(row.environment_id, () => runTurn(sessionId, appended.pendingForTurn)).catch(
|
|
681
|
+
(err) => {
|
|
682
|
+
console.error(`[events] enqueueTurn failed:`, err);
|
|
683
|
+
}
|
|
684
|
+
);
|
|
685
|
+
}
|
|
663
686
|
}
|
|
664
687
|
}
|
|
665
688
|
return jsonOk({ data: appended.rows.map(rowToManagedEvent) });
|
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-23UKWXJH.js";
|
|
5
5
|
import {
|
|
6
6
|
listAudit
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-PDUQCDIO.js";
|
|
8
8
|
import {
|
|
9
9
|
paginatedOk,
|
|
10
10
|
routeWrap
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-FCKUWBUL.js";
|
|
12
12
|
import {
|
|
13
13
|
badRequest
|
|
14
14
|
} from "./chunk-EZYKRG4W.js";
|
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import {
|
|
2
2
|
enqueueTurn
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-MTRTBT7L.js";
|
|
4
4
|
import {
|
|
5
5
|
runTurn
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7NZ46LIO.js";
|
|
7
7
|
import {
|
|
8
8
|
installOtlpExporter
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7Z6LTBYQ.js";
|
|
10
10
|
import {
|
|
11
11
|
redactAppendInput
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-FV2XE3DX.js";
|
|
13
13
|
import {
|
|
14
14
|
createApiKey,
|
|
15
15
|
listApiKeys
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-W6QYWXOZ.js";
|
|
17
17
|
import {
|
|
18
18
|
initSentry
|
|
19
19
|
} from "./chunk-3MQ2FWXS.js";
|
|
20
20
|
import {
|
|
21
21
|
installShutdownHandlers
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-XSRIFWHR.js";
|
|
23
23
|
import {
|
|
24
24
|
runSweep
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-UTQRPXTL.js";
|
|
26
26
|
import {
|
|
27
27
|
fillWarmPools,
|
|
28
28
|
reconcileDockerOrphanSandboxes,
|
|
29
29
|
reconcileOrphanSandboxes
|
|
30
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-TN34IN7S.js";
|
|
31
31
|
import {
|
|
32
32
|
appendEvent,
|
|
33
33
|
installPayloadRedactor
|
|
34
|
-
} from "./chunk-
|
|
34
|
+
} from "./chunk-X23OAFFE.js";
|
|
35
35
|
import {
|
|
36
36
|
setSessionSandbox
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-MTB7SCZ5.js";
|
|
38
38
|
import {
|
|
39
39
|
readEnvValue,
|
|
40
40
|
upsertEnvLine
|
|
41
41
|
} from "./chunk-YPXI7Q2M.js";
|
|
42
42
|
import {
|
|
43
43
|
getLastUnprocessedUserMessage
|
|
44
|
-
} from "./chunk-
|
|
44
|
+
} from "./chunk-PRWWTLPR.js";
|
|
45
45
|
import {
|
|
46
46
|
getBySession,
|
|
47
47
|
register
|
|
48
48
|
} from "./chunk-EFOIR7R3.js";
|
|
49
49
|
import {
|
|
50
|
-
|
|
51
|
-
} from "./chunk-
|
|
50
|
+
tryResolveProvider
|
|
51
|
+
} from "./chunk-JXU6SA6S.js";
|
|
52
52
|
import {
|
|
53
53
|
getEnvironment
|
|
54
|
-
} from "./chunk-
|
|
54
|
+
} from "./chunk-CFLMIJ2C.js";
|
|
55
55
|
import {
|
|
56
56
|
getConfig
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-WKGJQIRC.js";
|
|
58
58
|
import {
|
|
59
59
|
init_clock,
|
|
60
60
|
nowMs
|
|
@@ -62,7 +62,7 @@ import {
|
|
|
62
62
|
import {
|
|
63
63
|
getDb,
|
|
64
64
|
init_client
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-U3QU5AVC.js";
|
|
66
66
|
import {
|
|
67
67
|
getRuntime
|
|
68
68
|
} from "./chunk-UYTSKFGK.js";
|
|
@@ -184,7 +184,8 @@ async function recoverStaleSessions() {
|
|
|
184
184
|
if (lastMsg) {
|
|
185
185
|
if (row.sandbox_name) {
|
|
186
186
|
const envObj = getEnvironment(row.environment_id);
|
|
187
|
-
const provider = await
|
|
187
|
+
const provider = await tryResolveProvider({ envConfigProvider: envObj?.config?.provider });
|
|
188
|
+
if (!provider) continue;
|
|
188
189
|
try {
|
|
189
190
|
const containers = await provider.list({ prefix: row.sandbox_name });
|
|
190
191
|
const alive = containers.some((c) => c.name === row.sandbox_name);
|
|
@@ -267,7 +268,8 @@ async function rebuildContainerPool() {
|
|
|
267
268
|
if (getBySession(row.id)) continue;
|
|
268
269
|
try {
|
|
269
270
|
const envObj = getEnvironment(row.environment_id);
|
|
270
|
-
const provider = await
|
|
271
|
+
const provider = await tryResolveProvider({ envConfigProvider: envObj?.config?.provider });
|
|
272
|
+
if (!provider) continue;
|
|
271
273
|
const containers = await provider.list({ prefix: row.sandbox_name });
|
|
272
274
|
const alive = containers.some((c) => c.name === row.sandbox_name);
|
|
273
275
|
if (alive) {
|