@pensar/apex 2.6.1 → 2.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/agent-4f87bydg.js +13 -0
- package/build/{agent-ayreaj6z.js → agent-6h49fhz1.js} +5 -5
- package/build/{agent-yby11zaq.js → agent-a5vq5fsm.js} +6 -6
- package/build/{agent-runs-g37vkrjr.js → agent-runs-9nncftzk.js} +16 -16
- package/build/agent-sa0ty54v.js +13 -0
- package/build/{apps-xn6km9yn.js → apps-rh90z2nb.js} +13 -13
- package/build/{auth-d105wc64.js → auth-hshx11mc.js} +13 -13
- package/build/{blackboxAgent-s56sgx9b.js → blackboxAgent-t6zq0ekj.js} +6 -6
- package/build/{blackboxPentest-ps78v3w7.js → blackboxPentest-eskvsmez.js} +11 -11
- package/build/{cli-d37a42dc.js → cli-29179gt8.js} +8 -8
- package/build/{cli-gx71jcke.js → cli-2etfgtj3.js} +1 -1
- package/build/{cli-ngq9dr8n.js → cli-6r1ntbmf.js} +3 -3
- package/build/{cli-709rvekb.js → cli-9eyk8rhx.js} +1 -1
- package/build/{cli-ae8jqxqr.js → cli-c4x5b3q4.js} +2 -2
- package/build/{cli-az3xq70v.js → cli-c9nnxr52.js} +1 -1
- package/build/{cli-1ve18npr.js → cli-dawkcveq.js} +1 -1
- package/build/{cli-3sp6nd8d.js → cli-dqrqgfrp.js} +2 -2
- package/build/{cli-7eea4e2y.js → cli-e0v6hd3d.js} +6 -6
- package/build/{cli-k2nwxta0.js → cli-ewav0q78.js} +2 -2
- package/build/{cli-kb21qhvm.js → cli-fk5e62a6.js} +2 -2
- package/build/{cli-65g6rcat.js → cli-gzgyjs36.js} +1 -1
- package/build/{cli-c05y640n.js → cli-mrk3hg6f.js} +1 -1
- package/build/{cli-dpsw2fe6.js → cli-prw2dfje.js} +353 -185
- package/build/{cli-qgz1q9g5.js → cli-pwhx13h3.js} +105 -36
- package/build/{cli-n2en7j5b.js → cli-q0wmet0t.js} +1 -1
- package/build/{cli-xtc2t6me.js → cli-tf2kp8s4.js} +3 -3
- package/build/{cli-fy6vh2a7.js → cli-vdbnh2ha.js} +1 -1
- package/build/cli.js +37 -37
- package/build/{config-zpqkd5cz.js → config-srw06gyv.js} +1 -1
- package/build/{fastStrike-mcjdvwez.js → fastStrike-gaphkhrs.js} +5 -5
- package/build/{fixes-kytx5dmj.js → fixes-j99tce5t.js} +13 -13
- package/build/{index-wqetp6gq.js → index-3rsrzfje.js} +5 -5
- package/build/{index-fv64eb32.js → index-652yqmn2.js} +2 -2
- package/build/{index-n65z6v7b.js → index-6fxag2h2.js} +6 -6
- package/build/{index-r9yjkfrv.js → index-a9yy0fe3.js} +4 -4
- package/build/{index-dr3tg1w3.js → index-c1tgca1w.js} +1 -1
- package/build/{index-qv4cc65p.js → index-fsv57ssp.js} +13 -13
- package/build/{index-ns4m4s01.js → index-y9h10rfq.js} +4 -4
- package/build/{index-4vqdgb42.js → index-yj0ye642.js} +1236 -1195
- package/build/{index-je6hcsqr.js → index-ynsam8mg.js} +1 -1
- package/build/{issues-eb3q9d3a.js → issues-267ytycy.js} +13 -13
- package/build/{knowledge-fqsvtx0f.js → knowledge-44acmwfw.js} +13 -13
- package/build/lib/{chunk-yrnrbjes.js → chunk-2015fqpw.js} +1 -1
- package/build/lib/{chunk-acgbyf5h.js → chunk-3jr0sp3v.js} +1 -1
- package/build/lib/{chunk-7pwa92rn.js → chunk-45ne0t6e.js} +1 -1
- package/build/lib/{chunk-nhfax4gb.js → chunk-5ma2ns65.js} +1 -1
- package/build/lib/{chunk-z96pbjhd.js → chunk-8zfn4feq.js} +1 -1
- package/build/lib/{chunk-1jvwqnem.js → chunk-93b8vp9x.js} +3 -3
- package/build/lib/{chunk-r4j8ybn9.js → chunk-9kmc9yp6.js} +37 -20
- package/build/lib/{chunk-9yksqgzr.js → chunk-bb2sekn4.js} +11 -11
- package/build/lib/{chunk-e8yy2k73.js → chunk-c3e9aen5.js} +1 -1
- package/build/lib/{chunk-v3dk9j7k.js → chunk-db0bmkrv.js} +11 -11
- package/build/lib/{chunk-1yct6cra.js → chunk-dm8yvkdy.js} +1 -1
- package/build/lib/{chunk-xhdpgpkm.js → chunk-dvn6bg2m.js} +2 -2
- package/build/lib/{chunk-9tt2021m.js → chunk-fwe0fdb5.js} +9 -9
- package/build/lib/{chunk-3c00n0cy.js → chunk-gfzspfyd.js} +3 -3
- package/build/lib/{chunk-ba41jh41.js → chunk-hw0vcs3m.js} +297 -127
- package/build/lib/{chunk-r2dkp4tb.js → chunk-m8w0npxg.js} +1 -1
- package/build/lib/{chunk-z137x08b.js → chunk-mbm9w4ac.js} +5 -5
- package/build/lib/{chunk-4hwzqthr.js → chunk-mjey3y7s.js} +1 -1
- package/build/lib/{chunk-mg03jdmt.js → chunk-mw108bmx.js} +1 -1
- package/build/lib/{chunk-1azdancq.js → chunk-njn4tjsr.js} +1 -1
- package/build/lib/{chunk-bb0ekhkw.js → chunk-p8jd9s8k.js} +8 -8
- package/build/lib/{chunk-2qsq76xq.js → chunk-t6yh604c.js} +62 -10
- package/build/lib/{chunk-1fy8azee.js → chunk-yqengqce.js} +1 -1
- package/build/lib/{chunk-w66ce82a.js → chunk-ysmhn1p6.js} +1 -1
- package/build/lib/core/agents/offSecAgent/index.js +7 -7
- package/build/lib/core/agents/offSecAgent/subagentSpawner.js +5 -5
- package/build/lib/core/agents/offSecAgent/tools/index.js +4 -4
- package/build/lib/core/agents/offSecAgent/tools/listMemories.d.ts +11 -1
- package/build/lib/core/agents/specialized/attackSurface/blackboxAgent.js +9 -9
- package/build/lib/core/agents/specialized/attackSurface/schemas.js +9 -9
- package/build/lib/core/agents/specialized/authenticationAgent/index.js +10 -10
- package/build/lib/core/agents/specialized/codeAgent/agent.js +9 -9
- package/build/lib/core/agents/specialized/findingJudge/agent.js +8 -8
- package/build/lib/core/agents/specialized/findingJudge/index.js +3 -3
- package/build/lib/core/agents/specialized/patching/index.js +10 -10
- package/build/lib/core/agents/specialized/pentest/agent.js +9 -9
- package/build/lib/core/agents/specialized/whiteboxAttackSurface/index.js +9 -9
- package/build/lib/core/ai/ai.d.ts +23 -6
- package/build/lib/core/ai/ai.js +2 -2
- package/build/lib/core/ai/index.js +2 -2
- package/build/lib/core/ai/models/claude-capabilities.d.ts +3 -2
- package/build/lib/core/ai/models/index.d.ts +1 -1
- package/build/lib/core/ai/utils.d.ts +2 -0
- package/build/lib/core/ai/utils.js +4 -2
- package/build/lib/core/api/index.js +19 -19
- package/build/lib/core/api/targetedPentest.js +10 -10
- package/build/lib/core/config/index.js +1 -1
- package/build/lib/core/findings/registry.js +3 -3
- package/build/lib/core/session/index.js +2 -2
- package/build/lib/core/session/persistence.js +3 -3
- package/build/lib/core/workflows/pentest.js +15 -15
- package/build/lib/core/workflows/seams.js +4 -4
- package/build/lib/core/workflows/whiteboxAttackSurface.js +11 -11
- package/build/lib/index.js +22 -22
- package/build/{logs-x62b7hk1.js → logs-wx69vy65.js} +13 -13
- package/build/{native-rollout-evidence-c9yhfqcs.js → native-rollout-evidence-2akrepvz.js} +3 -3
- package/build/{offesecAgent-5whnpeta.js → offesecAgent-zewvmk98.js} +4 -4
- package/build/pentest-n2mjksg2.js +22 -0
- package/build/{pentests-e0f32aqx.js → pentests-xvj8g8h4.js} +13 -13
- package/build/recordedRunClient-a0ye97sw.js +11 -0
- package/build/{targetedPentest-rcbs4nvp.js → targetedPentest-p3cdq712.js} +6 -6
- package/build/{targets-xj9g3q0z.js → targets-1wajqhm7.js} +13 -13
- package/build/threatModel-g9pbtnt1.js +21 -0
- package/build/{uninstall-7s784q4a.js → uninstall-jpm5ppfb.js} +1 -1
- package/build/{upload-4gvhwmvr.js → upload-csny5mns.js} +4 -4
- package/build/{utils-cjrz64pc.js → utils-tzbr4bxg.js} +3 -3
- package/package.json +1 -1
- package/src/core/agents/offSecAgent/offensiveSecurityAgent.test.ts +92 -5
- package/src/core/agents/offSecAgent/offensiveSecurityAgent.ts +49 -28
- package/src/core/agents/offSecAgent/tools/listMemories.test.ts +230 -0
- package/src/core/agents/offSecAgent/tools/listMemories.ts +73 -6
- package/src/core/ai/ai.operator-context.bench.test.ts +1408 -0
- package/src/core/ai/ai.recorded-context.test.ts +74 -0
- package/src/core/ai/ai.test.ts +54 -0
- package/src/core/ai/ai.ts +299 -80
- package/src/core/ai/compactionTelemetry.test.ts +2 -2
- package/src/core/ai/models/anthropic.ts +6 -0
- package/src/core/ai/models/bedrock.ts +18 -0
- package/src/core/ai/models/claude-capabilities.ts +29 -8
- package/src/core/ai/models/index.ts +4 -1
- package/src/core/ai/models/models.test.ts +23 -0
- package/src/core/ai/models/openrouter.ts +6 -0
- package/src/core/ai/providers/anthropic-models.test.ts +60 -1
- package/src/core/ai/providers/bedrock-models.test.ts +81 -0
- package/src/core/ai/providers/gateway-models.test.ts +16 -6
- package/src/core/ai/utils.native-rollout-evidence.test.ts +1 -0
- package/src/core/ai/utils.ts +189 -143
- package/src/core/observability/telemetry.test.ts +2 -3
- package/src/tui/components/chat/loading-indicator.tsx +20 -4
- package/src/tui/components/chat/message-list.tsx +1 -0
- package/src/tui/components/operator-dashboard/run-events.test.ts +3 -1
- package/src/tui/components/shared/__tests__/tool-renderer-lifecycle.tsx +18 -0
- package/src/tui/components/shared/action-label.test.ts +9 -0
- package/src/tui/components/shared/compacting-icon.tsx +18 -0
- package/src/tui/components/shared/index.ts +1 -0
- package/src/tui/components/shared/tool-registry.ts +1 -0
- package/src/tui/components/shared/tool-renderer.tsx +21 -7
- package/build/agent-6w7egcf1.js +0 -13
- package/build/agent-9zx75feh.js +0 -13
- package/build/pentest-e61hc38s.js +0 -22
- package/build/recordedRunClient-dp032c32.js +0 -11
- package/build/threatModel-jkxfa40s.js +0 -21
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
OffensiveSecurityAgent
|
|
3
|
-
} from "./cli-
|
|
4
|
-
import"./cli-
|
|
5
|
-
import"./cli-
|
|
3
|
+
} from "./cli-pwhx13h3.js";
|
|
4
|
+
import"./cli-vdbnh2ha.js";
|
|
5
|
+
import"./cli-mrk3hg6f.js";
|
|
6
6
|
import {
|
|
7
7
|
startAgentExecution
|
|
8
8
|
} from "./cli-g06s7edq.js";
|
|
9
9
|
import"./cli-qba2x69h.js";
|
|
10
|
-
import"./cli-
|
|
10
|
+
import"./cli-prw2dfje.js";
|
|
11
11
|
import"./cli-c2k4xxaw.js";
|
|
12
12
|
|
|
13
13
|
// src/core/api/offesecAgent.ts
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_CONCURRENCY2,
|
|
3
|
+
runPentestSwarm2,
|
|
4
|
+
runPentestWorkflow2
|
|
5
|
+
} from "./cli-29179gt8.js";
|
|
6
|
+
import"./cli-q0wmet0t.js";
|
|
7
|
+
import"./cli-6r1ntbmf.js";
|
|
8
|
+
import"./cli-ewav0q78.js";
|
|
9
|
+
import"./cli-tf2kp8s4.js";
|
|
10
|
+
import"./cli-fk5e62a6.js";
|
|
11
|
+
import"./cli-dawkcveq.js";
|
|
12
|
+
import"./cli-qba2x69h.js";
|
|
13
|
+
import"./cli-pwhx13h3.js";
|
|
14
|
+
import"./cli-prw2dfje.js";
|
|
15
|
+
import"./cli-mrk3hg6f.js";
|
|
16
|
+
import"./cli-c2k4xxaw.js";
|
|
17
|
+
import"./cli-vdbnh2ha.js";
|
|
18
|
+
export {
|
|
19
|
+
DEFAULT_CONCURRENCY2 as DEFAULT_CONCURRENCY,
|
|
20
|
+
runPentestSwarm2 as runPentestSwarm,
|
|
21
|
+
runPentestWorkflow2 as runPentestWorkflow
|
|
22
|
+
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import"./cli-
|
|
3
|
-
import"./cli-
|
|
2
|
+
import"./cli-vdbnh2ha.js";
|
|
3
|
+
import"./cli-mrk3hg6f.js";
|
|
4
4
|
import {
|
|
5
5
|
listScans2,
|
|
6
6
|
getScan2,
|
|
7
7
|
dispatchPentest2
|
|
8
|
-
} from "./cli-
|
|
9
|
-
import"./cli-
|
|
10
|
-
import"./cli-
|
|
11
|
-
import"./cli-
|
|
12
|
-
import"./cli-
|
|
13
|
-
import"./cli-
|
|
14
|
-
import"./cli-
|
|
15
|
-
import"./cli-
|
|
16
|
-
import"./cli-
|
|
8
|
+
} from "./cli-e0v6hd3d.js";
|
|
9
|
+
import"./cli-pwhx13h3.js";
|
|
10
|
+
import"./cli-ewav0q78.js";
|
|
11
|
+
import"./cli-fk5e62a6.js";
|
|
12
|
+
import"./cli-6r1ntbmf.js";
|
|
13
|
+
import"./cli-29179gt8.js";
|
|
14
|
+
import"./cli-dqrqgfrp.js";
|
|
15
|
+
import"./cli-tf2kp8s4.js";
|
|
16
|
+
import"./cli-q0wmet0t.js";
|
|
17
17
|
import"./cli-xcy2vxj2.js";
|
|
18
18
|
import {
|
|
19
19
|
markCommandFailed
|
|
20
20
|
} from "./cli-z82n3qk1.js";
|
|
21
|
-
import"./cli-
|
|
21
|
+
import"./cli-dawkcveq.js";
|
|
22
22
|
import"./cli-qba2x69h.js";
|
|
23
|
-
import"./cli-
|
|
23
|
+
import"./cli-prw2dfje.js";
|
|
24
24
|
import"./cli-c2k4xxaw.js";
|
|
25
25
|
import {
|
|
26
26
|
init_zod
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import {
|
|
2
|
+
openRecordedRunClient2
|
|
3
|
+
} from "./cli-c4x5b3q4.js";
|
|
4
|
+
import"./cli-2etfgtj3.js";
|
|
5
|
+
import"./cli-prw2dfje.js";
|
|
6
|
+
import"./cli-mrk3hg6f.js";
|
|
7
|
+
import"./cli-c2k4xxaw.js";
|
|
8
|
+
import"./cli-vdbnh2ha.js";
|
|
9
|
+
export {
|
|
10
|
+
openRecordedRunClient2 as openRecordedRunClient
|
|
11
|
+
};
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import"./cli-
|
|
2
|
-
import"./cli-
|
|
3
|
-
import"./cli-
|
|
1
|
+
import"./cli-vdbnh2ha.js";
|
|
2
|
+
import"./cli-mrk3hg6f.js";
|
|
3
|
+
import"./cli-pwhx13h3.js";
|
|
4
4
|
import {
|
|
5
5
|
TargetedPentestAgent2
|
|
6
|
-
} from "./cli-
|
|
6
|
+
} from "./cli-tf2kp8s4.js";
|
|
7
7
|
import {
|
|
8
8
|
startAgentExecution
|
|
9
9
|
} from "./cli-g06s7edq.js";
|
|
10
|
-
import"./cli-
|
|
10
|
+
import"./cli-dawkcveq.js";
|
|
11
11
|
import"./cli-qba2x69h.js";
|
|
12
|
-
import"./cli-
|
|
12
|
+
import"./cli-prw2dfje.js";
|
|
13
13
|
import"./cli-c2k4xxaw.js";
|
|
14
14
|
|
|
15
15
|
// src/core/api/targetedPentest.ts
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import"./cli-
|
|
3
|
-
import"./cli-
|
|
2
|
+
import"./cli-vdbnh2ha.js";
|
|
3
|
+
import"./cli-mrk3hg6f.js";
|
|
4
4
|
import {
|
|
5
5
|
listPentestTargets2,
|
|
6
6
|
listTargetLogs2,
|
|
7
7
|
searchTargetLogs2
|
|
8
|
-
} from "./cli-
|
|
9
|
-
import"./cli-
|
|
10
|
-
import"./cli-
|
|
11
|
-
import"./cli-
|
|
12
|
-
import"./cli-
|
|
13
|
-
import"./cli-
|
|
14
|
-
import"./cli-
|
|
15
|
-
import"./cli-
|
|
16
|
-
import"./cli-
|
|
8
|
+
} from "./cli-e0v6hd3d.js";
|
|
9
|
+
import"./cli-pwhx13h3.js";
|
|
10
|
+
import"./cli-ewav0q78.js";
|
|
11
|
+
import"./cli-fk5e62a6.js";
|
|
12
|
+
import"./cli-6r1ntbmf.js";
|
|
13
|
+
import"./cli-29179gt8.js";
|
|
14
|
+
import"./cli-dqrqgfrp.js";
|
|
15
|
+
import"./cli-tf2kp8s4.js";
|
|
16
|
+
import"./cli-q0wmet0t.js";
|
|
17
17
|
import"./cli-xcy2vxj2.js";
|
|
18
18
|
import {
|
|
19
19
|
markCommandFailed
|
|
20
20
|
} from "./cli-z82n3qk1.js";
|
|
21
|
-
import"./cli-
|
|
21
|
+
import"./cli-dawkcveq.js";
|
|
22
22
|
import"./cli-qba2x69h.js";
|
|
23
|
-
import"./cli-
|
|
23
|
+
import"./cli-prw2dfje.js";
|
|
24
24
|
import"./cli-c2k4xxaw.js";
|
|
25
25
|
|
|
26
26
|
// src/cli/targets.ts
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import"./cli-pwhx13h3.js";
|
|
2
|
+
import"./cli-vdbnh2ha.js";
|
|
3
|
+
import"./cli-mrk3hg6f.js";
|
|
4
|
+
import {
|
|
5
|
+
runThreatModelWorkflow2
|
|
6
|
+
} from "./cli-e0v6hd3d.js";
|
|
7
|
+
import"./cli-ewav0q78.js";
|
|
8
|
+
import"./cli-fk5e62a6.js";
|
|
9
|
+
import"./cli-6r1ntbmf.js";
|
|
10
|
+
import"./cli-29179gt8.js";
|
|
11
|
+
import"./cli-dqrqgfrp.js";
|
|
12
|
+
import"./cli-tf2kp8s4.js";
|
|
13
|
+
import"./cli-q0wmet0t.js";
|
|
14
|
+
import"./cli-xcy2vxj2.js";
|
|
15
|
+
import"./cli-dawkcveq.js";
|
|
16
|
+
import"./cli-qba2x69h.js";
|
|
17
|
+
import"./cli-prw2dfje.js";
|
|
18
|
+
import"./cli-c2k4xxaw.js";
|
|
19
|
+
export {
|
|
20
|
+
runThreatModelWorkflow2 as runThreatModelWorkflow
|
|
21
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import"./cli-
|
|
2
|
-
import"./cli-
|
|
1
|
+
import"./cli-vdbnh2ha.js";
|
|
2
|
+
import"./cli-mrk3hg6f.js";
|
|
3
3
|
import {
|
|
4
4
|
resolveConfig,
|
|
5
5
|
createWeaveTracer
|
|
6
|
-
} from "./cli-
|
|
7
|
-
import"./cli-
|
|
6
|
+
} from "./cli-c9nnxr52.js";
|
|
7
|
+
import"./cli-prw2dfje.js";
|
|
8
8
|
import"./cli-c2k4xxaw.js";
|
|
9
9
|
|
|
10
10
|
// src/core/integrations/wandb/upload.ts
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import"./cli-
|
|
2
|
-
import"./cli-
|
|
1
|
+
import"./cli-vdbnh2ha.js";
|
|
2
|
+
import"./cli-mrk3hg6f.js";
|
|
3
3
|
import {
|
|
4
4
|
init_types
|
|
5
5
|
} from "./cli-3gt761d2.js";
|
|
6
6
|
import {
|
|
7
7
|
AVAILABLE_MODELS,
|
|
8
8
|
init_ai
|
|
9
|
-
} from "./cli-
|
|
9
|
+
} from "./cli-prw2dfje.js";
|
|
10
10
|
import"./cli-c2k4xxaw.js";
|
|
11
11
|
|
|
12
12
|
// src/core/providers/utils.ts
|
package/package.json
CHANGED
|
@@ -361,6 +361,86 @@ describe("spawned-agent usage callbacks", () => {
|
|
|
361
361
|
});
|
|
362
362
|
|
|
363
363
|
describe("auxiliary model events", () => {
|
|
364
|
+
it("persists prepared context instead of restoring a fitted-away prefix", async () => {
|
|
365
|
+
streamResponseCalls.length = 0;
|
|
366
|
+
const rootPath = mkdtempSync(join(tmpdir(), "apex-fitted-history-"));
|
|
367
|
+
try {
|
|
368
|
+
const agent = new OffensiveSecurityAgent({
|
|
369
|
+
prompt: "test",
|
|
370
|
+
model: "test-model",
|
|
371
|
+
messages: [{ role: "user", content: "old large prefix" }],
|
|
372
|
+
session: { id: "ses_fitted_history", rootPath },
|
|
373
|
+
activeTools: [],
|
|
374
|
+
sandbox: {},
|
|
375
|
+
} as never);
|
|
376
|
+
void agent.streamResult;
|
|
377
|
+
const call = streamResponseCalls[0] as {
|
|
378
|
+
onContextPrepared: (context: {
|
|
379
|
+
messages: Array<{ role: string; content: unknown }>;
|
|
380
|
+
responseMessageOffset: number;
|
|
381
|
+
}) => void;
|
|
382
|
+
onStepFinish: (event: unknown) => Promise<void>;
|
|
383
|
+
};
|
|
384
|
+
const firstStep = [
|
|
385
|
+
{ role: "assistant", content: "first call" },
|
|
386
|
+
{ role: "tool", content: "full first result" },
|
|
387
|
+
];
|
|
388
|
+
const cachedSystem = {
|
|
389
|
+
role: "system",
|
|
390
|
+
content: "cached effective system prompt",
|
|
391
|
+
providerOptions: {
|
|
392
|
+
anthropic: { cacheControl: { type: "ephemeral" } },
|
|
393
|
+
},
|
|
394
|
+
};
|
|
395
|
+
const historySystem = {
|
|
396
|
+
role: "system",
|
|
397
|
+
content: "caller-supplied history instruction",
|
|
398
|
+
};
|
|
399
|
+
call.onContextPrepared({
|
|
400
|
+
messages: [
|
|
401
|
+
cachedSystem,
|
|
402
|
+
cachedSystem,
|
|
403
|
+
historySystem,
|
|
404
|
+
{ role: "user", content: "fitted prefix" },
|
|
405
|
+
],
|
|
406
|
+
responseMessageOffset: 0,
|
|
407
|
+
});
|
|
408
|
+
await call.onStepFinish({
|
|
409
|
+
response: { id: "step-1", messages: firstStep },
|
|
410
|
+
usage: { inputTokens: 10, outputTokens: 2 },
|
|
411
|
+
});
|
|
412
|
+
|
|
413
|
+
const compacted = [
|
|
414
|
+
historySystem,
|
|
415
|
+
{ role: "user", content: "fitted prefix" },
|
|
416
|
+
{ role: "assistant", content: "first call" },
|
|
417
|
+
{ role: "tool", content: "short first result" },
|
|
418
|
+
];
|
|
419
|
+
call.onContextPrepared({
|
|
420
|
+
messages: [cachedSystem, cachedSystem, ...compacted],
|
|
421
|
+
responseMessageOffset: 2,
|
|
422
|
+
});
|
|
423
|
+
const secondStep = [
|
|
424
|
+
{ role: "assistant", content: "second call" },
|
|
425
|
+
{ role: "tool", content: "second result" },
|
|
426
|
+
];
|
|
427
|
+
await call.onStepFinish({
|
|
428
|
+
response: {
|
|
429
|
+
id: "step-2",
|
|
430
|
+
messages: [...firstStep, ...secondStep],
|
|
431
|
+
},
|
|
432
|
+
usage: { inputTokens: 10, outputTokens: 2 },
|
|
433
|
+
});
|
|
434
|
+
|
|
435
|
+
const writer = (agent as unknown as { writer: AgentMessageWriter })
|
|
436
|
+
.writer;
|
|
437
|
+
expect(writer.latest).toEqual([...compacted, ...secondStep]);
|
|
438
|
+
writer.cancelTimer();
|
|
439
|
+
} finally {
|
|
440
|
+
rmSync(rootPath, { recursive: true, force: true });
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
|
|
364
444
|
it("keeps the last complete message snapshot while forwarding usage", async () => {
|
|
365
445
|
streamResponseCalls.length = 0;
|
|
366
446
|
traceRecordStepCalls.length = 0;
|
|
@@ -2806,6 +2886,11 @@ describe("trace identity and root IO", () => {
|
|
|
2806
2886
|
describe("contextRecorder integration", () => {
|
|
2807
2887
|
const streamTextChunk = { type: "text-delta", id: "t1", delta: "hi" };
|
|
2808
2888
|
const CANONICAL = [
|
|
2889
|
+
{
|
|
2890
|
+
role: "system",
|
|
2891
|
+
content: "cached effective system prompt",
|
|
2892
|
+
providerOptions: { anthropic: { cacheControl: { type: "ephemeral" } } },
|
|
2893
|
+
},
|
|
2809
2894
|
{ role: "user", content: "recorded prompt" },
|
|
2810
2895
|
{ role: "assistant", content: "recorded answer" },
|
|
2811
2896
|
] as never[];
|
|
@@ -2874,14 +2959,13 @@ describe("contextRecorder integration", () => {
|
|
|
2874
2959
|
expect(streamResponseCalls[0]?.inferenceRecorder).toBe(inferenceRecorder);
|
|
2875
2960
|
|
|
2876
2961
|
const stepEvent = {
|
|
2877
|
-
response: { id: "resp_1", messages: CANONICAL.slice(
|
|
2962
|
+
response: { id: "resp_1", messages: CANONICAL.slice(2) },
|
|
2878
2963
|
usage: {},
|
|
2879
2964
|
};
|
|
2880
2965
|
await streamOpts.onStepFinish(stepEvent);
|
|
2881
2966
|
|
|
2882
|
-
//
|
|
2883
|
-
//
|
|
2884
|
-
// projection must not re-prepend a base or duplicate them.
|
|
2967
|
+
// The cached system message is transport-only; it must not enter the
|
|
2968
|
+
// transcript reloaded with a fresh system prompt on the next turn.
|
|
2885
2969
|
const writer = agent["writer" as keyof typeof agent] as unknown as {
|
|
2886
2970
|
waitForPendingWrites: () => Promise<void>;
|
|
2887
2971
|
latest: unknown[] | null;
|
|
@@ -2894,6 +2978,9 @@ describe("contextRecorder integration", () => {
|
|
|
2894
2978
|
await streamOpts.onFinish(finishEvent);
|
|
2895
2979
|
|
|
2896
2980
|
expect(recorder.latest).toHaveBeenCalled();
|
|
2897
|
-
expect(
|
|
2981
|
+
expect(captured).toEqual(CANONICAL.slice(1));
|
|
2982
|
+
expect(
|
|
2983
|
+
JSON.parse(readFileSync(join(rootPath, "messages.json"), "utf8")),
|
|
2984
|
+
).toEqual(CANONICAL.slice(1));
|
|
2898
2985
|
});
|
|
2899
2986
|
});
|
|
@@ -759,16 +759,36 @@ export class OffensiveSecurityAgent<TResult = void> {
|
|
|
759
759
|
}
|
|
760
760
|
this.messagesPath = join(messagesDir, "messages.json");
|
|
761
761
|
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
762
|
+
const preparedContextRef = {
|
|
763
|
+
current: {
|
|
764
|
+
messages: input.messages
|
|
765
|
+
? [...input.messages]
|
|
766
|
+
: [
|
|
767
|
+
{
|
|
768
|
+
role: "user" as const,
|
|
769
|
+
content: [{ type: "text" as const, text: input.prompt }],
|
|
770
|
+
},
|
|
771
|
+
],
|
|
772
|
+
responseMessageOffset: 0,
|
|
773
|
+
},
|
|
774
|
+
};
|
|
775
|
+
const legacyMessages = (responseMessages: ModelMessage[]) => [
|
|
776
|
+
...preparedContextRef.current.messages,
|
|
777
|
+
...responseMessages.slice(
|
|
778
|
+
preparedContextRef.current.responseMessageOffset,
|
|
779
|
+
),
|
|
780
|
+
];
|
|
781
|
+
const persistedMessages = (messages: ModelMessage[]) => {
|
|
782
|
+
// Cache-marked system messages are transport context; the next turn
|
|
783
|
+
// supplies a fresh system prompt and must not replay saved copies.
|
|
784
|
+
let first = 0;
|
|
785
|
+
while (
|
|
786
|
+
messages[first]?.role === "system" &&
|
|
787
|
+
messages[first]?.providerOptions
|
|
788
|
+
) {
|
|
789
|
+
first++;
|
|
790
|
+
}
|
|
791
|
+
return first === 0 ? messages : messages.slice(first);
|
|
772
792
|
};
|
|
773
793
|
|
|
774
794
|
// Agent-local persistence: debounce, latest snapshot, and the
|
|
@@ -861,6 +881,12 @@ export class OffensiveSecurityAgent<TResult = void> {
|
|
|
861
881
|
usageRecorder: input.usageRecorder,
|
|
862
882
|
contextRecorder: input.contextRecorder,
|
|
863
883
|
inferenceRecorder: input.inferenceRecorder,
|
|
884
|
+
onContextPrepared: (context) => {
|
|
885
|
+
preparedContextRef.current = {
|
|
886
|
+
messages: [...context.messages],
|
|
887
|
+
responseMessageOffset: context.responseMessageOffset,
|
|
888
|
+
};
|
|
889
|
+
},
|
|
864
890
|
// Per-subagent so the overflow tool-result dumps land next to this
|
|
865
891
|
// agent's messages.json (`subagents/{id}/tool-results/`) and a host
|
|
866
892
|
// can reclaim them when the subagent finishes, instead of piling up
|
|
@@ -880,16 +906,10 @@ export class OffensiveSecurityAgent<TResult = void> {
|
|
|
880
906
|
return;
|
|
881
907
|
}
|
|
882
908
|
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
// onStepFinish wrapper, before this user callback runs.
|
|
888
|
-
const canonical = input.contextRecorder?.latest() ?? [
|
|
889
|
-
...initialMessagesRef.current,
|
|
890
|
-
...event.response.messages,
|
|
891
|
-
];
|
|
892
|
-
this.writer.setLatest(canonical);
|
|
909
|
+
const canonical =
|
|
910
|
+
input.contextRecorder?.latest() ??
|
|
911
|
+
legacyMessages(event.response.messages);
|
|
912
|
+
this.writer.setLatest(persistedMessages(canonical));
|
|
893
913
|
schedulePersist();
|
|
894
914
|
traceWriter.recordStep(
|
|
895
915
|
event.response.messages as ModelMessage[],
|
|
@@ -905,9 +925,10 @@ export class OffensiveSecurityAgent<TResult = void> {
|
|
|
905
925
|
await input.onStepFinish?.(event);
|
|
906
926
|
},
|
|
907
927
|
onSummarized: () => {
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
928
|
+
preparedContextRef.current = {
|
|
929
|
+
messages: [],
|
|
930
|
+
responseMessageOffset: 0,
|
|
931
|
+
};
|
|
911
932
|
traceWriter.markSummarized();
|
|
912
933
|
},
|
|
913
934
|
onFinish: async (event) => {
|
|
@@ -915,11 +936,11 @@ export class OffensiveSecurityAgent<TResult = void> {
|
|
|
915
936
|
this.writer.cancelTimer();
|
|
916
937
|
// Skip if the interrupted-step finalizer already wrote the abort snapshot.
|
|
917
938
|
if (!this.writer.syntheticsPersisted) {
|
|
918
|
-
const finalMessages =
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
939
|
+
const finalMessages = persistedMessages(
|
|
940
|
+
input.contextRecorder?.latest() ??
|
|
941
|
+
this.writer.latest ??
|
|
942
|
+
legacyMessages(event.response.messages),
|
|
943
|
+
);
|
|
923
944
|
this.writer.setLatest(finalMessages);
|
|
924
945
|
await this.writer.enqueueWrite(finalMessages).catch(() => {});
|
|
925
946
|
}
|