@agentstep/agent-sdk 0.5.0 → 0.5.2
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 +7 -7
- 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 +11 -11
- package/dist/backends/factory/auth.js +6 -6
- package/dist/backends/factory/index.js +13 -13
- package/dist/backends/gemini/auth.js +6 -6
- package/dist/backends/gemini/index.js +11 -11
- package/dist/backends/opencode/auth.js +6 -6
- package/dist/backends/opencode/index.js +15 -15
- package/dist/backends/pi/auth.js +6 -6
- package/dist/backends/pi/index.js +13 -13
- package/dist/backends/registry.js +31 -31
- package/dist/backends/shared/wrap-prompt.js +1 -1
- package/dist/chunk-3LUY2POB.js +50 -0
- package/dist/{chunk-3PA4NXRP.js → chunk-3VPTHB7I.js} +2 -2
- package/dist/{chunk-YMCS6AB7.js → chunk-4236UQNZ.js} +2 -2
- package/dist/{chunk-HMOSAXVZ.js → chunk-4A4F4L4H.js} +2 -2
- package/dist/{chunk-JFOHGHW5.js → chunk-4B5H2MFO.js} +59 -16
- package/dist/{chunk-OZFSKR2W.js → chunk-5525T7PL.js} +4 -4
- package/dist/{chunk-AXBM7HAR.js → chunk-5EFY6UGV.js} +1 -1
- package/dist/chunk-5UTTNXNJ.js +166 -0
- package/dist/{chunk-4RDILRIO.js → chunk-5YGYUGDQ.js} +3 -3
- package/dist/{chunk-HWR2HYQJ.js → chunk-6DPJVMEC.js} +1 -1
- package/dist/{chunk-PNZF7HIU.js → chunk-6KJS42ZL.js} +8 -7
- package/dist/{chunk-LQP6XGFU.js → chunk-6KQFP32G.js} +3 -3
- package/dist/{chunk-DMMNAQUM.js → chunk-6L4AGHAV.js} +2 -2
- package/dist/{chunk-WEC625LQ.js → chunk-6TJBZXD4.js} +1 -1
- package/dist/{chunk-QTXAWC5J.js → chunk-6URMGCAC.js} +2 -2
- package/dist/{chunk-DJZSPWG2.js → chunk-6WUYI3DJ.js} +4 -4
- package/dist/{chunk-H6OT5GUL.js → chunk-7APAOJIZ.js} +3 -3
- package/dist/{chunk-HVLYE4S5.js → chunk-7EDLLXFQ.js} +1 -1
- package/dist/chunk-7IYL2O7H.js +185 -0
- package/dist/{chunk-KGBKIJPF.js → chunk-7JAUY5SG.js} +3 -3
- package/dist/{chunk-NDTIDWBE.js → chunk-7XIAKW75.js} +1 -1
- package/dist/{chunk-TUEBRYPZ.js → chunk-A2W3USEZ.js} +1 -1
- package/dist/chunk-ACPP4KN7.js +164 -0
- package/dist/{chunk-22OUZJAV.js → chunk-AESA3ARX.js} +3 -3
- package/dist/{chunk-Z4LFLXRR.js → chunk-AIAF5ZZA.js} +1 -1
- package/dist/{chunk-GIMDS46L.js → chunk-ANS2TQYT.js} +3 -3
- package/dist/{chunk-T3FQPTOA.js → chunk-BCBDHUFY.js} +2 -2
- package/dist/{chunk-MCWCRZM4.js → chunk-BLTCDZ3O.js} +4 -4
- package/dist/{chunk-VP527YC5.js → chunk-BYIU4WAQ.js} +3 -3
- package/dist/{chunk-L26TVIB6.js → chunk-C52BVTYC.js} +8 -8
- package/dist/{chunk-EWIWVXXP.js → chunk-CA76BJWL.js} +44 -14
- package/dist/{chunk-DKLHYSPW.js → chunk-DZGFZMUE.js} +5 -5
- package/dist/{chunk-R3QHLKJG.js → chunk-E35XHOFL.js} +5 -5
- package/dist/{chunk-PZNAQBHQ.js → chunk-FILGQF2G.js} +2 -2
- package/dist/{chunk-JP7Y3TKK.js → chunk-FSVDF57K.js} +5 -5
- package/dist/{chunk-S7DFMJR5.js → chunk-FWJOTEVY.js} +3 -3
- package/dist/{chunk-XSNJ7NT2.js → chunk-G4DTLYOD.js} +1 -1
- package/dist/{chunk-IEZFRNLC.js → chunk-GBLR2CPP.js} +107 -9
- package/dist/{chunk-7SY65LWY.js → chunk-GEC3NFYO.js} +4 -4
- package/dist/{chunk-GLKWJESP.js → chunk-GZZHVIEG.js} +2 -2
- package/dist/{chunk-NHAYKVXG.js → chunk-IAKR572X.js} +8 -8
- package/dist/{chunk-GFSRNOPI.js → chunk-IBUFLAAJ.js} +7 -7
- package/dist/{chunk-OKT2J4ZB.js → chunk-IZ5TUMCF.js} +23 -7
- package/dist/{chunk-W3JMIUHV.js → chunk-KQTTKYZY.js} +1 -1
- package/dist/{chunk-AJL3T5JS.js → chunk-L2DCOJTQ.js} +3 -3
- package/dist/{chunk-JLUCJMAQ.js → chunk-LA6IFUVR.js} +70 -24
- package/dist/{chunk-AB7MPL3H.js → chunk-LW4OCFIP.js} +9 -7
- package/dist/{chunk-BCIFFAGW.js → chunk-M3752GFZ.js} +15 -5
- package/dist/{chunk-5U5LRAFJ.js → chunk-MTLM36QD.js} +2 -2
- package/dist/{chunk-A6VORSKD.js → chunk-MV42BTU3.js} +1 -1
- package/dist/{chunk-5MERXOLJ.js → chunk-NRX5WHHN.js} +4 -4
- package/dist/{chunk-T3HMVHDG.js → chunk-O2X4XBU7.js} +1 -1
- package/dist/{chunk-2YZOIFVN.js → chunk-P4NU74SP.js} +47 -0
- package/dist/{chunk-TVODT2UR.js → chunk-P4OCCRQW.js} +1 -1
- package/dist/{chunk-YXOCKQZU.js → chunk-P4VJADXA.js} +2 -2
- package/dist/{chunk-6QZ23WRF.js → chunk-P6LESAPO.js} +54 -20
- package/dist/{chunk-HY3T4YJV.js → chunk-PICGSLMG.js} +5 -5
- package/dist/{chunk-64IQEPSD.js → chunk-PQKIXSEP.js} +2 -2
- package/dist/{chunk-GV6GUSCP.js → chunk-Q2JYAAJO.js} +9 -9
- package/dist/{chunk-IU457W7Q.js → chunk-QBJOYOVF.js} +2 -1
- package/dist/{chunk-MAJWADF7.js → chunk-RZOCX57A.js} +2 -2
- package/dist/{chunk-4D345E27.js → chunk-SQZPJFBF.js} +2 -2
- package/dist/{chunk-OSNMIPHV.js → chunk-TE6KCRPP.js} +1 -1
- package/dist/{chunk-Z6VZYRVN.js → chunk-TF36SWHG.js} +2 -2
- package/dist/{chunk-KUWJJD6O.js → chunk-TSR33JMZ.js} +14 -5
- package/dist/{chunk-L3IACZ72.js → chunk-TWH4UH6G.js} +1 -1
- package/dist/{chunk-445EL6J5.js → chunk-UAEVL47I.js} +1 -1
- package/dist/{chunk-X6QIWZ33.js → chunk-UGH5JDXX.js} +3 -3
- package/dist/{chunk-FSQ4HGHX.js → chunk-UJW3I3TX.js} +3 -3
- package/dist/{chunk-I26QP3A3.js → chunk-UQZFFG7U.js} +1 -1
- package/dist/{chunk-ILHIHMO3.js → chunk-VC5DELR4.js} +37 -2
- package/dist/{chunk-NKQVOAWN.js → chunk-VMLXV2H6.js} +1 -1
- package/dist/{chunk-FCUXFLNK.js → chunk-VY6IWBSK.js} +17 -4
- package/dist/{chunk-6CVQDSTS.js → chunk-WDAFSCYQ.js} +1 -1
- package/dist/{chunk-GCQDNUS2.js → chunk-WFRHLTKI.js} +3 -3
- package/dist/{chunk-R6EEBWM3.js → chunk-WRLCJNQF.js} +1 -1
- package/dist/{chunk-KKAJC3Z2.js → chunk-X4ARJS6I.js} +10 -10
- package/dist/{chunk-MQBMXAPU.js → chunk-Y4MI27HU.js} +1 -1
- package/dist/{chunk-PN3AWRMX.js → chunk-YDP3YA5D.js} +17 -17
- package/dist/{chunk-FVBDEOTZ.js → chunk-YE2RMJY7.js} +18 -4
- package/dist/{chunk-IRW7AYTP.js → chunk-YEWYRPN4.js} +42 -4
- package/dist/{chunk-24IDJ7LY.js → chunk-YL6IQUJC.js} +4 -4
- package/dist/{chunk-CLSGNQ7J.js → chunk-Z46R47QX.js} +8 -8
- package/dist/{chunk-STJNO6SL.js → chunk-Z6OPLBPQ.js} +1 -1
- package/dist/{chunk-RYJXSXCV.js → chunk-ZEJOFHR7.js} +5 -5
- package/dist/{chunk-EOJ66GY7.js → chunk-ZFGG62JW.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 +45 -43
- 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 +13 -5
- package/dist/db/migrations.js +1 -1
- package/dist/db/proxy.js +5 -5
- package/dist/db/schema.js +5 -1
- package/dist/db/session-resources.js +5 -5
- package/dist/db/sessions.js +8 -8
- package/dist/db/sync.js +5 -5
- package/dist/db/tenants.js +3 -3
- package/dist/db/threads.js +27 -0
- package/dist/db/traces.js +5 -5
- package/dist/db/upstream_keys.js +3 -3
- package/dist/db/vaults.js +6 -6
- package/dist/dreaming/prompts.js +9 -0
- package/dist/dreaming/review.js +22 -0
- package/dist/handlers/agents.js +59 -59
- package/dist/handlers/api_keys.js +60 -60
- package/dist/handlers/audit.js +60 -60
- package/dist/handlers/batch.js +60 -60
- package/dist/handlers/credentials.js +60 -60
- package/dist/handlers/environments.js +60 -60
- package/dist/handlers/events.js +63 -63
- package/dist/handlers/files.js +60 -60
- package/dist/handlers/index.js +159 -144
- package/dist/handlers/license.js +59 -59
- package/dist/handlers/memory.js +66 -60
- package/dist/handlers/metrics.js +59 -59
- package/dist/handlers/models.js +60 -60
- package/dist/handlers/providers.js +59 -59
- package/dist/handlers/resources.js +59 -59
- package/dist/handlers/sessions.js +63 -62
- package/dist/handlers/settings.js +59 -59
- package/dist/handlers/skills-write.js +59 -59
- package/dist/handlers/skills.js +60 -60
- package/dist/handlers/stream.js +59 -59
- package/dist/handlers/tenants.js +60 -60
- package/dist/handlers/threads.js +70 -61
- package/dist/handlers/traces.js +60 -60
- package/dist/handlers/upstream_keys.js +62 -62
- package/dist/handlers/vaults.js +59 -59
- package/dist/handlers/whoami.js +59 -59
- package/dist/http.js +58 -58
- package/dist/index.js +72 -67
- 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/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 +12 -12
- package/dist/providers/vercel.js +6 -6
- 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 +121 -55
- package/dist/shutdown.js +45 -45
- 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/sync/memory-sync.js +79 -0
- package/package.json +1 -1
- package/dist/chunk-XTKTIFHC.js +0 -48
- package/dist/{chunk-UE6DNLSV.js → chunk-LT5PRO54.js} +0 -0
- package/dist/{dist-EY25RQ2S.js → dist-S64ZABZX.js} +3 -3
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import {
|
|
2
2
|
parseNDJSONLines
|
|
3
3
|
} from "./chunk-PJZ5TQYW.js";
|
|
4
|
+
import {
|
|
5
|
+
incrementRetry,
|
|
6
|
+
resetRetry,
|
|
7
|
+
retryDelay,
|
|
8
|
+
shouldRetry
|
|
9
|
+
} from "./chunk-72BKGVBE.js";
|
|
10
|
+
import {
|
|
11
|
+
loadSessionSecrets
|
|
12
|
+
} from "./chunk-4A4F4L4H.js";
|
|
4
13
|
import {
|
|
5
14
|
childSpan,
|
|
6
15
|
newTrace
|
|
@@ -13,32 +22,23 @@ import {
|
|
|
13
22
|
import {
|
|
14
23
|
injectMcpAuthHeaders
|
|
15
24
|
} from "./chunk-DBFPJSOY.js";
|
|
16
|
-
import {
|
|
17
|
-
incrementRetry,
|
|
18
|
-
resetRetry,
|
|
19
|
-
retryDelay,
|
|
20
|
-
shouldRetry
|
|
21
|
-
} from "./chunk-72BKGVBE.js";
|
|
22
|
-
import {
|
|
23
|
-
loadSessionSecrets
|
|
24
|
-
} from "./chunk-HMOSAXVZ.js";
|
|
25
25
|
import {
|
|
26
26
|
isProxied
|
|
27
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-MTLM36QD.js";
|
|
28
28
|
import {
|
|
29
29
|
acquireForFirstTurn,
|
|
30
30
|
installSkills,
|
|
31
31
|
provisionResources,
|
|
32
32
|
wrapProviderWithSecrets
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-4B5H2MFO.js";
|
|
34
34
|
import {
|
|
35
35
|
BLOCKED_ENV_KEYS,
|
|
36
36
|
resolveVaultSecrets
|
|
37
|
-
} from "./chunk-
|
|
37
|
+
} from "./chunk-O2X4XBU7.js";
|
|
38
38
|
import {
|
|
39
39
|
appendEvent,
|
|
40
40
|
appendEventsBatch
|
|
41
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-NRX5WHHN.js";
|
|
42
42
|
import {
|
|
43
43
|
bumpSessionStats,
|
|
44
44
|
getOutcomeCriteria,
|
|
@@ -49,26 +49,26 @@ import {
|
|
|
49
49
|
setOutcomeCriteria,
|
|
50
50
|
updateSessionMutable,
|
|
51
51
|
updateSessionStatus
|
|
52
|
-
} from "./chunk-
|
|
52
|
+
} from "./chunk-TSR33JMZ.js";
|
|
53
53
|
import {
|
|
54
54
|
listEvents,
|
|
55
55
|
markUserEventProcessed
|
|
56
|
-
} from "./chunk-
|
|
56
|
+
} from "./chunk-7JAUY5SG.js";
|
|
57
57
|
import {
|
|
58
58
|
getBySession
|
|
59
59
|
} from "./chunk-EFOIR7R3.js";
|
|
60
60
|
import {
|
|
61
61
|
resolveContainerProvider
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-LT5PRO54.js";
|
|
63
63
|
import {
|
|
64
64
|
getEnvironment
|
|
65
|
-
} from "./chunk-
|
|
65
|
+
} from "./chunk-7APAOJIZ.js";
|
|
66
66
|
import {
|
|
67
67
|
getAgent
|
|
68
|
-
} from "./chunk-
|
|
68
|
+
} from "./chunk-M3752GFZ.js";
|
|
69
69
|
import {
|
|
70
70
|
resolveBackend
|
|
71
|
-
} from "./chunk-
|
|
71
|
+
} from "./chunk-Q2JYAAJO.js";
|
|
72
72
|
import {
|
|
73
73
|
PERMISSION_BRIDGE_PENDING_PATH,
|
|
74
74
|
PERMISSION_BRIDGE_REQUEST_PATH,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
} from "./chunk-XBHDQK4Z.js";
|
|
85
85
|
import {
|
|
86
86
|
getConfig
|
|
87
|
-
} from "./chunk-
|
|
87
|
+
} from "./chunk-UGH5JDXX.js";
|
|
88
88
|
import {
|
|
89
89
|
init_clock,
|
|
90
90
|
nowMs
|
|
@@ -266,13 +266,36 @@ async function runTurn(sessionId, inputs, _depth = 0, parentTrace) {
|
|
|
266
266
|
content: i.content
|
|
267
267
|
}));
|
|
268
268
|
const agentForTurn = injectMcpAuthHeaders(agent, vaultEntries);
|
|
269
|
+
let mountedMemoryStores;
|
|
270
|
+
try {
|
|
271
|
+
const { listResources: listSessionResources } = await import("./db/session-resources.js");
|
|
272
|
+
const { getMemoryStore } = await import("./db/memory.js");
|
|
273
|
+
const sessionResources = listSessionResources(sessionId);
|
|
274
|
+
const memStoreResources = sessionResources.filter((r) => r.type === "memory_store" && r.memory_store_id);
|
|
275
|
+
if (memStoreResources.length > 0) {
|
|
276
|
+
mountedMemoryStores = [];
|
|
277
|
+
for (const r of memStoreResources) {
|
|
278
|
+
const store = getMemoryStore(r.memory_store_id);
|
|
279
|
+
if (store) {
|
|
280
|
+
mountedMemoryStores.push({
|
|
281
|
+
name: store.name,
|
|
282
|
+
access: r.access ?? "read_write",
|
|
283
|
+
description: store.description,
|
|
284
|
+
instructions: r.instructions
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
} catch {
|
|
290
|
+
}
|
|
269
291
|
let turnBuild;
|
|
270
292
|
try {
|
|
271
293
|
turnBuild = backend.buildTurn({
|
|
272
294
|
agent: agentForTurn,
|
|
273
295
|
backendSessionId: getSessionRow(sessionId)?.claude_session_id ?? null,
|
|
274
296
|
promptText,
|
|
275
|
-
toolResults
|
|
297
|
+
toolResults,
|
|
298
|
+
memoryStores: mountedMemoryStores
|
|
276
299
|
});
|
|
277
300
|
} catch (err) {
|
|
278
301
|
const msg = err instanceof ApiError ? err.message : err instanceof Error ? err.message : String(err);
|
|
@@ -613,6 +636,17 @@ ${turnBuild.stdin}`;
|
|
|
613
636
|
} catch (err) {
|
|
614
637
|
console.warn("[driver] container file sync failed:", err?.stack ?? err);
|
|
615
638
|
}
|
|
639
|
+
try {
|
|
640
|
+
const { syncMemoryStores } = await import("./sync/memory-sync.js");
|
|
641
|
+
await syncMemoryStores({
|
|
642
|
+
sessionId,
|
|
643
|
+
sandboxName: sessionRowForSync.sandbox_name,
|
|
644
|
+
provider,
|
|
645
|
+
secrets
|
|
646
|
+
});
|
|
647
|
+
} catch (err) {
|
|
648
|
+
console.warn("[driver] memory store sync failed:", err?.stack ?? err);
|
|
649
|
+
}
|
|
616
650
|
}
|
|
617
651
|
const now = nowMs();
|
|
618
652
|
const stopReason = result?.stopReason ?? "end_turn";
|
|
@@ -670,11 +704,12 @@ ${turnBuild.stdin}`;
|
|
|
670
704
|
setIdleSince(sessionId, now);
|
|
671
705
|
if (stopReason === "end_turn") {
|
|
672
706
|
const criteria = getOutcomeCriteria(sessionId);
|
|
673
|
-
if (criteria?.rubric) {
|
|
707
|
+
if (criteria?.rubric && criteria?.status === "running") {
|
|
674
708
|
try {
|
|
675
709
|
const { runGraderEvaluation } = await import("./sessions/grader.js");
|
|
676
710
|
const maxIter = criteria.max_iterations ?? 3;
|
|
677
711
|
const iteration = criteria.grader_iteration ?? 0;
|
|
712
|
+
const outcomeId = criteria.outcome_id ?? null;
|
|
678
713
|
const recentEvents = listEvents(sessionId, { limit: 50, order: "desc" });
|
|
679
714
|
let lastAgentText = "";
|
|
680
715
|
for (const evt of recentEvents) {
|
|
@@ -687,7 +722,7 @@ ${turnBuild.stdin}`;
|
|
|
687
722
|
}
|
|
688
723
|
}
|
|
689
724
|
}
|
|
690
|
-
emit("span.outcome_evaluation_start", { iteration });
|
|
725
|
+
emit("span.outcome_evaluation_start", { outcome_id: outcomeId, iteration });
|
|
691
726
|
const evaluation = await runGraderEvaluation(
|
|
692
727
|
criteria.rubric,
|
|
693
728
|
lastAgentText,
|
|
@@ -706,10 +741,21 @@ ${turnBuild.stdin}`;
|
|
|
706
741
|
});
|
|
707
742
|
const finalResult = iteration + 1 >= maxIter && evaluation.result === "needs_revision" ? "max_iterations_reached" : evaluation.result;
|
|
708
743
|
emit("span.outcome_evaluation_end", {
|
|
744
|
+
outcome_id: outcomeId,
|
|
709
745
|
result: finalResult,
|
|
746
|
+
explanation: evaluation.feedback,
|
|
710
747
|
iteration,
|
|
711
|
-
|
|
748
|
+
usage: evaluation.usage
|
|
712
749
|
});
|
|
750
|
+
if (finalResult === "satisfied" || finalResult === "max_iterations_reached" || finalResult === "failed") {
|
|
751
|
+
setOutcomeCriteria(sessionId, {
|
|
752
|
+
...criteria,
|
|
753
|
+
grader_iteration: iteration + 1,
|
|
754
|
+
status: finalResult,
|
|
755
|
+
completed_at: new Date(nowMs()).toISOString(),
|
|
756
|
+
explanation: evaluation.feedback
|
|
757
|
+
});
|
|
758
|
+
}
|
|
713
759
|
if (evaluation.result === "needs_revision" && iteration + 1 < maxIter) {
|
|
714
760
|
await runTurn(sessionId, [{
|
|
715
761
|
kind: "text",
|
|
@@ -6,29 +6,29 @@ import {
|
|
|
6
6
|
reconcileDockerOrphanSandboxes,
|
|
7
7
|
reconcileOrphanSandboxes,
|
|
8
8
|
releaseSession
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-4B5H2MFO.js";
|
|
10
10
|
import {
|
|
11
11
|
appendEvent,
|
|
12
12
|
dropEmitter
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-NRX5WHHN.js";
|
|
14
14
|
import {
|
|
15
15
|
archiveSession,
|
|
16
16
|
getSessionRow,
|
|
17
17
|
listIdleSessions,
|
|
18
18
|
updateSessionStatus
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-TSR33JMZ.js";
|
|
20
20
|
import {
|
|
21
21
|
resolveContainerProvider
|
|
22
|
-
} from "./chunk-
|
|
22
|
+
} from "./chunk-LT5PRO54.js";
|
|
23
23
|
import {
|
|
24
24
|
getEnvironment
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-7APAOJIZ.js";
|
|
26
26
|
import {
|
|
27
27
|
expireWarm
|
|
28
28
|
} from "./chunk-G7KUVNDY.js";
|
|
29
29
|
import {
|
|
30
30
|
getConfig
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-UGH5JDXX.js";
|
|
32
32
|
import {
|
|
33
33
|
init_clock,
|
|
34
34
|
nowMs
|
|
@@ -110,8 +110,10 @@ async function evictIdleSessions() {
|
|
|
110
110
|
if (rt.inFlightRuns.has(sessionId)) return;
|
|
111
111
|
const row = getSessionRow(sessionId);
|
|
112
112
|
if (!row || row.status !== "idle" || row.archived_at != null) return;
|
|
113
|
+
const env = getEnvironment(row.environment_id);
|
|
114
|
+
const maxAge = env?.config?.idle_timeout_ms ?? cfg.sessionMaxAgeMs;
|
|
113
115
|
const base = row.idle_since ?? row.created_at;
|
|
114
|
-
if (base +
|
|
116
|
+
if (base + maxAge >= now) return;
|
|
115
117
|
await releaseSession(sessionId);
|
|
116
118
|
appendEvent(sessionId, {
|
|
117
119
|
type: "session.status_terminated",
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
DEFAULT_TENANT_ID
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-UQZFFG7U.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-FILGQF2G.js";
|
|
17
17
|
import {
|
|
18
18
|
schema_exports
|
|
19
|
-
} from "./chunk-
|
|
19
|
+
} from "./chunk-VC5DELR4.js";
|
|
20
20
|
|
|
21
21
|
// src/db/agents.ts
|
|
22
22
|
init_drizzle();
|
|
@@ -31,6 +31,13 @@ function hydrate(row, ver) {
|
|
|
31
31
|
type: "url",
|
|
32
32
|
...typeof cfg === "string" ? { url: cfg } : cfg
|
|
33
33
|
}));
|
|
34
|
+
const multiagent = ver.multiagent_json ? JSON.parse(ver.multiagent_json) : void 0;
|
|
35
|
+
let threadsEnabled = Boolean(ver.threads_enabled);
|
|
36
|
+
let callableAgents = ver.callable_agents_json ? JSON.parse(ver.callable_agents_json) : [];
|
|
37
|
+
if (multiagent) {
|
|
38
|
+
threadsEnabled = true;
|
|
39
|
+
callableAgents = multiagent.agents.filter((a) => a.type === "agent").map((a) => ({ type: "agent", id: a.id, version: a.version }));
|
|
40
|
+
}
|
|
34
41
|
return {
|
|
35
42
|
type: "agent",
|
|
36
43
|
id: row.id,
|
|
@@ -46,9 +53,10 @@ function hydrate(row, ver) {
|
|
|
46
53
|
webhook_url: ver.webhook_url ?? null,
|
|
47
54
|
webhook_events: ver.webhook_events_json ? JSON.parse(ver.webhook_events_json) : ["session.status_idle", "session.status_running", "session.error"],
|
|
48
55
|
webhook_signing_enabled: ver.webhook_secret != null && ver.webhook_secret.length > 0,
|
|
49
|
-
threads_enabled:
|
|
56
|
+
threads_enabled: threadsEnabled,
|
|
50
57
|
confirmation_mode: Boolean(ver.confirmation_mode),
|
|
51
|
-
callable_agents:
|
|
58
|
+
callable_agents: callableAgents,
|
|
59
|
+
multiagent,
|
|
52
60
|
skills: ver.skills_json ? JSON.parse(ver.skills_json) : [],
|
|
53
61
|
model_config: modelConfig,
|
|
54
62
|
fallback_json: row.fallback_json ?? null,
|
|
@@ -86,6 +94,7 @@ function createAgent(input) {
|
|
|
86
94
|
threads_enabled: input.threads_enabled ? 1 : 0,
|
|
87
95
|
confirmation_mode: input.confirmation_mode ? 1 : 0,
|
|
88
96
|
callable_agents_json: input.callable_agents?.length ? JSON.stringify(input.callable_agents) : null,
|
|
97
|
+
multiagent_json: input.multiagent ? JSON.stringify(input.multiagent) : null,
|
|
89
98
|
skills_json: JSON.stringify(input.skills ?? []),
|
|
90
99
|
model_config_json: JSON.stringify(input.model_config ?? {}),
|
|
91
100
|
created_at: now
|
|
@@ -138,6 +147,7 @@ function updateAgent(id, input) {
|
|
|
138
147
|
threads_enabled: input.threads_enabled !== void 0 ? input.threads_enabled ? 1 : 0 : existing.threads_enabled ? 1 : 0,
|
|
139
148
|
confirmation_mode: input.confirmation_mode !== void 0 ? input.confirmation_mode ? 1 : 0 : existing.confirmation_mode ? 1 : 0,
|
|
140
149
|
callable_agents_json: input.callable_agents !== void 0 ? input.callable_agents.length ? JSON.stringify(input.callable_agents) : null : existing.callable_agents.length ? JSON.stringify(existing.callable_agents) : null,
|
|
150
|
+
multiagent_json: input.multiagent !== void 0 ? input.multiagent ? JSON.stringify(input.multiagent) : null : existing.multiagent ? JSON.stringify(existing.multiagent) : null,
|
|
141
151
|
skills_json: JSON.stringify(input.skills ?? existing.skills),
|
|
142
152
|
model_config_json: JSON.stringify(input.model_config !== void 0 ? input.model_config : existing.model_config),
|
|
143
153
|
created_at: now
|
|
@@ -1,19 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSession
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-TSR33JMZ.js";
|
|
4
4
|
import {
|
|
5
5
|
appendEvent,
|
|
6
6
|
appendEventsBatch,
|
|
7
7
|
listEvents,
|
|
8
8
|
rowToManagedEvent
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-7JAUY5SG.js";
|
|
10
10
|
import {
|
|
11
11
|
getAgent
|
|
12
|
-
} from "./chunk-
|
|
12
|
+
} from "./chunk-M3752GFZ.js";
|
|
13
13
|
import {
|
|
14
14
|
getDb,
|
|
15
15
|
init_client
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-KQTTKYZY.js";
|
|
17
17
|
|
|
18
18
|
// src/sessions/bus.ts
|
|
19
19
|
import { EventEmitter } from "events";
|
|
@@ -445,6 +445,25 @@ function runMigrations(db) {
|
|
|
445
445
|
UNIQUE(vault_id, display_name)
|
|
446
446
|
)
|
|
447
447
|
`);
|
|
448
|
+
db.exec(`
|
|
449
|
+
CREATE TABLE IF NOT EXISTS memory_versions (
|
|
450
|
+
id TEXT PRIMARY KEY,
|
|
451
|
+
store_id TEXT NOT NULL,
|
|
452
|
+
memory_id TEXT NOT NULL,
|
|
453
|
+
operation TEXT NOT NULL,
|
|
454
|
+
path TEXT NOT NULL,
|
|
455
|
+
content TEXT,
|
|
456
|
+
content_sha256 TEXT,
|
|
457
|
+
session_id TEXT,
|
|
458
|
+
created_at INTEGER NOT NULL
|
|
459
|
+
)
|
|
460
|
+
`);
|
|
461
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_memver_store ON memory_versions(store_id, created_at)`);
|
|
462
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_memver_memory ON memory_versions(memory_id, created_at)`);
|
|
463
|
+
const memStoreColsArchive = db.prepare(`PRAGMA table_info(memory_stores)`).all();
|
|
464
|
+
if (!memStoreColsArchive.some((c) => c.name === "archived_at")) {
|
|
465
|
+
db.exec(`ALTER TABLE memory_stores ADD COLUMN archived_at INTEGER`);
|
|
466
|
+
}
|
|
448
467
|
const credCols = db.prepare(`PRAGMA table_info(vault_credentials)`).all();
|
|
449
468
|
if (!credCols.some((c) => c.name === "expires_at")) {
|
|
450
469
|
db.exec(`ALTER TABLE vault_credentials ADD COLUMN expires_at TEXT`);
|
|
@@ -484,6 +503,34 @@ function runMigrations(db) {
|
|
|
484
503
|
db.exec("UPDATE environments SET updated_at = created_at WHERE updated_at IS NULL");
|
|
485
504
|
}
|
|
486
505
|
}
|
|
506
|
+
db.exec(`
|
|
507
|
+
CREATE TABLE IF NOT EXISTS session_threads (
|
|
508
|
+
id TEXT PRIMARY KEY,
|
|
509
|
+
session_id TEXT NOT NULL,
|
|
510
|
+
agent_id TEXT NOT NULL,
|
|
511
|
+
agent_version INTEGER NOT NULL,
|
|
512
|
+
parent_thread_id TEXT,
|
|
513
|
+
status TEXT NOT NULL DEFAULT 'idle',
|
|
514
|
+
stop_reason TEXT,
|
|
515
|
+
usage_input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
516
|
+
usage_output_tokens INTEGER NOT NULL DEFAULT 0,
|
|
517
|
+
usage_cache_read_input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
518
|
+
usage_cache_creation_input_tokens INTEGER NOT NULL DEFAULT 0,
|
|
519
|
+
created_at INTEGER NOT NULL,
|
|
520
|
+
updated_at INTEGER NOT NULL,
|
|
521
|
+
archived_at INTEGER
|
|
522
|
+
)
|
|
523
|
+
`);
|
|
524
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_session_threads_session ON session_threads(session_id)`);
|
|
525
|
+
const eventColsThread = db.prepare(`PRAGMA table_info(events)`).all();
|
|
526
|
+
if (!eventColsThread.some((c) => c.name === "thread_id")) {
|
|
527
|
+
db.exec(`ALTER TABLE events ADD COLUMN thread_id TEXT`);
|
|
528
|
+
}
|
|
529
|
+
db.exec(`CREATE INDEX IF NOT EXISTS idx_events_thread ON events(thread_id) WHERE thread_id IS NOT NULL`);
|
|
530
|
+
const avColsMultiagent = db.prepare(`PRAGMA table_info(agent_versions)`).all();
|
|
531
|
+
if (!avColsMultiagent.some((c) => c.name === "multiagent_json")) {
|
|
532
|
+
db.exec(`ALTER TABLE agent_versions ADD COLUMN multiagent_json TEXT`);
|
|
533
|
+
}
|
|
487
534
|
{
|
|
488
535
|
const cols = db.prepare("PRAGMA table_info(vaults)").all();
|
|
489
536
|
const names = new Set(cols.map((c) => c.name));
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
BatchError,
|
|
3
3
|
executeBatch
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-BLTCDZ3O.js";
|
|
5
5
|
import {
|
|
6
6
|
jsonOk,
|
|
7
7
|
routeWrap
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-6URMGCAC.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-YL6IQUJC.js";
|
|
6
6
|
import {
|
|
7
7
|
resolveRemoteSessionId
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AESA3ARX.js";
|
|
9
9
|
import {
|
|
10
10
|
assertResourceTenant
|
|
11
11
|
} from "./chunk-23UKWXJH.js";
|
|
@@ -20,46 +20,46 @@ import {
|
|
|
20
20
|
listMemoryStores,
|
|
21
21
|
searchMemories,
|
|
22
22
|
updateMemory
|
|
23
|
-
} from "./chunk-
|
|
23
|
+
} from "./chunk-GBLR2CPP.js";
|
|
24
24
|
import {
|
|
25
25
|
jsonOk,
|
|
26
26
|
paginatedOk,
|
|
27
27
|
routeWrap
|
|
28
|
-
} from "./chunk-
|
|
28
|
+
} from "./chunk-6URMGCAC.js";
|
|
29
29
|
import {
|
|
30
30
|
forwardToAnthropic
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-Y4MI27HU.js";
|
|
32
|
+
import {
|
|
33
|
+
enqueueTurn
|
|
34
|
+
} from "./chunk-AIAF5ZZA.js";
|
|
32
35
|
import {
|
|
33
36
|
runTurn,
|
|
34
37
|
writePermissionResponse
|
|
35
|
-
} from "./chunk-
|
|
36
|
-
import {
|
|
37
|
-
enqueueTurn
|
|
38
|
-
} from "./chunk-Z4LFLXRR.js";
|
|
38
|
+
} from "./chunk-LA6IFUVR.js";
|
|
39
39
|
import {
|
|
40
40
|
getProxiedTenantId,
|
|
41
41
|
isProxied
|
|
42
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-MTLM36QD.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-NRX5WHHN.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-TSR33JMZ.js";
|
|
56
56
|
import {
|
|
57
57
|
listEvents,
|
|
58
58
|
rowToManagedEvent
|
|
59
|
-
} from "./chunk-
|
|
59
|
+
} from "./chunk-7JAUY5SG.js";
|
|
60
60
|
import {
|
|
61
61
|
getAgent
|
|
62
|
-
} from "./chunk-
|
|
62
|
+
} from "./chunk-M3752GFZ.js";
|
|
63
63
|
import {
|
|
64
64
|
init_clock,
|
|
65
65
|
nowMs
|
|
@@ -67,7 +67,7 @@ import {
|
|
|
67
67
|
import {
|
|
68
68
|
getDb,
|
|
69
69
|
init_client
|
|
70
|
-
} from "./chunk-
|
|
70
|
+
} from "./chunk-KQTTKYZY.js";
|
|
71
71
|
import {
|
|
72
72
|
badRequest,
|
|
73
73
|
notFound
|
|
@@ -423,7 +423,10 @@ var UserCustomToolResult = z.object({
|
|
|
423
423
|
var UserDefineOutcome = z.object({
|
|
424
424
|
type: z.literal("user.define_outcome"),
|
|
425
425
|
description: z.string().min(1),
|
|
426
|
-
rubric: z.
|
|
426
|
+
rubric: z.union([
|
|
427
|
+
z.string(),
|
|
428
|
+
z.object({ type: z.literal("text"), content: z.string() })
|
|
429
|
+
]).optional(),
|
|
427
430
|
max_iterations: z.number().int().min(1).max(20).optional()
|
|
428
431
|
});
|
|
429
432
|
var UserEvent = z.union([
|
|
@@ -589,16 +592,47 @@ function handlePostEvents(request, sessionId) {
|
|
|
589
592
|
continue;
|
|
590
593
|
}
|
|
591
594
|
if (event.type === "user.define_outcome") {
|
|
592
|
-
const {
|
|
595
|
+
const { newId: genId } = await import("./util/ids.js");
|
|
596
|
+
const outcomeId = genId("outc");
|
|
597
|
+
const rubricText = typeof event.rubric === "string" ? event.rubric : event.rubric?.content ?? "";
|
|
598
|
+
const maxIterations = event.max_iterations ?? 3;
|
|
599
|
+
const processedAt = nowMs();
|
|
600
|
+
const outcomeData = {
|
|
601
|
+
outcome_id: outcomeId,
|
|
602
|
+
description: event.description,
|
|
603
|
+
rubric: rubricText,
|
|
604
|
+
max_iterations: maxIterations,
|
|
605
|
+
grader_iteration: 0,
|
|
606
|
+
status: "running"
|
|
607
|
+
};
|
|
608
|
+
setOutcomeCriteria(sessionId, outcomeData);
|
|
593
609
|
const row = appendEvent(sessionId, {
|
|
594
610
|
type: "user.define_outcome",
|
|
595
|
-
payload:
|
|
611
|
+
payload: {
|
|
612
|
+
outcome_id: outcomeId,
|
|
613
|
+
description: event.description,
|
|
614
|
+
rubric: rubricText,
|
|
615
|
+
max_iterations: maxIterations,
|
|
616
|
+
processed_at: processedAt
|
|
617
|
+
},
|
|
596
618
|
origin: "user",
|
|
597
619
|
idempotencyKey: ik,
|
|
598
|
-
processedAt
|
|
620
|
+
processedAt
|
|
599
621
|
});
|
|
600
622
|
rows.push(row);
|
|
601
|
-
|
|
623
|
+
const descRow = appendEvent(sessionId, {
|
|
624
|
+
type: "user.message",
|
|
625
|
+
payload: { content: [{ type: "text", text: event.description }] },
|
|
626
|
+
origin: "user",
|
|
627
|
+
processedAt: null
|
|
628
|
+
});
|
|
629
|
+
const inp = { kind: "text", eventId: descRow.id, text: event.description };
|
|
630
|
+
const currentStatus = getSessionRow(sessionId)?.status ?? "idle";
|
|
631
|
+
if (currentStatus === "running" || sawInterrupt) {
|
|
632
|
+
pushPendingUserInput({ sessionId, input: inp });
|
|
633
|
+
} else {
|
|
634
|
+
pendingForTurn.push(inp);
|
|
635
|
+
}
|
|
602
636
|
continue;
|
|
603
637
|
}
|
|
604
638
|
}
|
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
} from "./chunk-23UKWXJH.js";
|
|
7
7
|
import {
|
|
8
8
|
recordAudit
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-TWH4UH6G.js";
|
|
10
10
|
import {
|
|
11
11
|
COMMUNITY_LIMITS,
|
|
12
12
|
hasFeature,
|
|
@@ -15,7 +15,7 @@ import {
|
|
|
15
15
|
import {
|
|
16
16
|
jsonOk,
|
|
17
17
|
routeWrap
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6URMGCAC.js";
|
|
19
19
|
import {
|
|
20
20
|
createApiKey,
|
|
21
21
|
getApiKeyById,
|
|
@@ -23,14 +23,14 @@ import {
|
|
|
23
23
|
listApiKeys,
|
|
24
24
|
revokeApiKey,
|
|
25
25
|
updateApiKeyPermissions
|
|
26
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-BCBDHUFY.js";
|
|
27
27
|
import {
|
|
28
28
|
listSessionsByApiKey
|
|
29
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-TSR33JMZ.js";
|
|
30
30
|
import {
|
|
31
31
|
getDb,
|
|
32
32
|
init_client
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-KQTTKYZY.js";
|
|
34
34
|
import {
|
|
35
35
|
badRequest,
|
|
36
36
|
forbidden,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
markStopping
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-LW4OCFIP.js";
|
|
4
4
|
import {
|
|
5
5
|
closeDb,
|
|
6
6
|
init_client,
|
|
7
7
|
syncDb
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-KQTTKYZY.js";
|
|
9
9
|
import {
|
|
10
10
|
getRuntime
|
|
11
11
|
} from "./chunk-UYTSKFGK.js";
|
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
2
|
-
piBackend
|
|
3
|
-
} from "./chunk-NHAYKVXG.js";
|
|
4
1
|
import {
|
|
5
2
|
opencodeBackend
|
|
6
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-X4ARJS6I.js";
|
|
7
4
|
import {
|
|
8
|
-
|
|
9
|
-
} from "./chunk-
|
|
5
|
+
piBackend
|
|
6
|
+
} from "./chunk-IAKR572X.js";
|
|
10
7
|
import {
|
|
11
8
|
geminiBackend
|
|
12
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-DZGFZMUE.js";
|
|
10
|
+
import {
|
|
11
|
+
factoryBackend
|
|
12
|
+
} from "./chunk-C52BVTYC.js";
|
|
13
13
|
import {
|
|
14
14
|
codexBackend
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-E35XHOFL.js";
|
|
16
16
|
import {
|
|
17
17
|
claudeBackend
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-6KJS42ZL.js";
|
|
19
19
|
|
|
20
20
|
// src/backends/registry.ts
|
|
21
21
|
var BACKENDS = {
|