stitchkit 0.128.0 → 0.130.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/CHANGELOG.md +83 -0
- package/dist/agent-executor/acp/v1-connect.d.ts +87 -19
- package/dist/agent-executor/acp/v1-connect.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-driver.d.ts +4 -2
- package/dist/agent-executor/acp/v1-driver.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-handlers.d.ts +56 -0
- package/dist/agent-executor/acp/v1-handlers.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-map.d.ts +13 -2
- package/dist/agent-executor/acp/v1-map.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-permission.d.ts +44 -0
- package/dist/agent-executor/acp/v1-permission.d.ts.map +1 -0
- package/dist/agent-executor/acp/v1-protocol.d.ts +63 -10
- package/dist/agent-executor/acp/v1-protocol.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-session.d.ts +34 -7
- package/dist/agent-executor/acp/v1-session.d.ts.map +1 -1
- package/dist/agent-executor/acp/v1-turn.d.ts +51 -13
- package/dist/agent-executor/acp/v1-turn.d.ts.map +1 -1
- package/dist/agent-executor/claude/classify.d.ts +10 -0
- package/dist/agent-executor/claude/classify.d.ts.map +1 -1
- package/dist/agent-executor/claude/cli-driver.d.ts +4 -1
- package/dist/agent-executor/claude/cli-driver.d.ts.map +1 -1
- package/dist/agent-executor/claude/events.d.ts +146 -0
- package/dist/agent-executor/claude/events.d.ts.map +1 -0
- package/dist/agent-executor/claude/limits.d.ts +7 -1
- package/dist/agent-executor/claude/limits.d.ts.map +1 -1
- package/dist/agent-executor/claude/protocol.d.ts +49 -9
- package/dist/agent-executor/claude/protocol.d.ts.map +1 -1
- package/dist/agent-executor/claude/session.d.ts +2 -0
- package/dist/agent-executor/claude/session.d.ts.map +1 -1
- package/dist/agent-executor/claude/transcript.d.ts +2 -2
- package/dist/agent-executor/claude/transcript.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/controls.d.ts +28 -0
- package/dist/agent-executor/claude-sdk/controls.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/driver.d.ts +208 -4
- package/dist/agent-executor/claude-sdk/driver.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/probe.d.ts +29 -0
- package/dist/agent-executor/claude-sdk/probe.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/query-loop.d.ts +94 -0
- package/dist/agent-executor/claude-sdk/query-loop.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts +29 -0
- package/dist/agent-executor/claude-sdk/query-options.d.ts.map +1 -0
- package/dist/agent-executor/claude-sdk/session.d.ts +5 -5
- package/dist/agent-executor/claude-sdk/session.d.ts.map +1 -1
- package/dist/agent-executor/claude-sdk/turn-usage.d.ts +81 -0
- package/dist/agent-executor/claude-sdk/turn-usage.d.ts.map +1 -0
- package/dist/agent-executor/codex/classify.d.ts +4 -0
- package/dist/agent-executor/codex/classify.d.ts.map +1 -1
- package/dist/agent-executor/codex/connect.d.ts +46 -0
- package/dist/agent-executor/codex/connect.d.ts.map +1 -0
- package/dist/agent-executor/codex/control-client.d.ts +168 -0
- package/dist/agent-executor/codex/control-client.d.ts.map +1 -0
- package/dist/agent-executor/codex/driver.d.ts +71 -10
- package/dist/agent-executor/codex/driver.d.ts.map +1 -1
- package/dist/agent-executor/codex/handlers.d.ts +47 -0
- package/dist/agent-executor/codex/handlers.d.ts.map +1 -0
- package/dist/agent-executor/codex/limits.d.ts +11 -2
- package/dist/agent-executor/codex/limits.d.ts.map +1 -1
- package/dist/agent-executor/codex/protocol.d.ts +173 -4
- package/dist/agent-executor/codex/protocol.d.ts.map +1 -1
- package/dist/agent-executor/codex/request-answers.d.ts +101 -0
- package/dist/agent-executor/codex/request-answers.d.ts.map +1 -0
- package/dist/agent-executor/codex/session-controls.d.ts +195 -0
- package/dist/agent-executor/codex/session-controls.d.ts.map +1 -0
- package/dist/agent-executor/codex/session.d.ts +55 -37
- package/dist/agent-executor/codex/session.d.ts.map +1 -1
- package/dist/agent-executor/codex/shared-server.d.ts +29 -0
- package/dist/agent-executor/codex/shared-server.d.ts.map +1 -0
- package/dist/agent-executor/codex/shared-thread.d.ts +46 -0
- package/dist/agent-executor/codex/shared-thread.d.ts.map +1 -0
- package/dist/agent-executor/codex/thread-controls.d.ts +128 -0
- package/dist/agent-executor/codex/thread-controls.d.ts.map +1 -0
- package/dist/agent-executor/codex/turn-input.d.ts +30 -0
- package/dist/agent-executor/codex/turn-input.d.ts.map +1 -0
- package/dist/agent-executor/codex/unix-socket-target.d.ts +26 -0
- package/dist/agent-executor/codex/unix-socket-target.d.ts.map +1 -0
- package/dist/agent-executor/codex/unix-socket.d.ts +26 -0
- package/dist/agent-executor/codex/unix-socket.d.ts.map +1 -0
- package/dist/agent-executor/codex/ws-frame.d.ts +15 -0
- package/dist/agent-executor/codex/ws-frame.d.ts.map +1 -0
- package/dist/agent-executor/contract.d.ts +79 -0
- package/dist/agent-executor/contract.d.ts.map +1 -1
- package/dist/agent-executor/engine-process.d.ts +9 -0
- package/dist/agent-executor/engine-process.d.ts.map +1 -1
- package/dist/agent-executor/engine.d.ts +6 -2
- package/dist/agent-executor/engine.d.ts.map +1 -1
- package/dist/agent-executor/executor-contract.d.ts +54 -0
- package/dist/agent-executor/executor-contract.d.ts.map +1 -1
- package/dist/agent-executor/handoff-schemas.d.ts +407 -0
- package/dist/agent-executor/handoff-schemas.d.ts.map +1 -0
- package/dist/agent-executor/handoff.d.ts +12 -0
- package/dist/agent-executor/handoff.d.ts.map +1 -0
- package/dist/agent-executor/hello.d.ts +80 -0
- package/dist/agent-executor/hello.d.ts.map +1 -1
- package/dist/agent-executor/image-input.d.ts +22 -0
- package/dist/agent-executor/image-input.d.ts.map +1 -1
- package/dist/agent-executor/projection.d.ts +2 -2
- package/dist/agent-executor/projection.d.ts.map +1 -1
- package/dist/agent-executor/session-primitives.d.ts +10 -1
- package/dist/agent-executor/session-primitives.d.ts.map +1 -1
- package/dist/agent-executor/testing/conformance.d.ts.map +1 -1
- package/dist/agent-executor/testing/replay-driver.d.ts +41 -0
- package/dist/agent-executor/testing/replay-driver.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-gate.d.ts +11 -0
- package/dist/agent-executor/testing/replay-gate.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-runner.d.ts +27 -0
- package/dist/agent-executor/testing/replay-runner.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-scenarios.d.ts +21 -0
- package/dist/agent-executor/testing/replay-scenarios.d.ts.map +1 -0
- package/dist/agent-executor/testing/replay-transcript.d.ts +296 -0
- package/dist/agent-executor/testing/replay-transcript.d.ts.map +1 -0
- package/dist/agent-executor/vocabulary.d.ts +135 -0
- package/dist/agent-executor/vocabulary.d.ts.map +1 -1
- package/dist/agent-runtime/branch-observations.d.ts +5 -5
- package/dist/agent-runtime/deferred-tool-selection.d.ts.map +1 -1
- package/dist/agent-runtime/sql-rows.d.ts +10 -10
- package/dist/agent-runtime/terminal-commit.d.ts +10 -10
- package/dist/entrypoints/agent-executor/acp.d.ts +4 -1
- package/dist/entrypoints/agent-executor/acp.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/acp.js +852 -219
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts +5 -1
- package/dist/entrypoints/agent-executor/claude-sdk.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/claude-sdk.js +1075 -136
- package/dist/entrypoints/agent-executor/claude.js +48 -23
- package/dist/entrypoints/agent-executor/codex.d.ts +11 -0
- package/dist/entrypoints/agent-executor/codex.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/codex.js +3067 -388
- package/dist/entrypoints/agent-executor/testing.d.ts +4 -0
- package/dist/entrypoints/agent-executor/testing.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor/testing.js +1002 -2
- package/dist/entrypoints/agent-executor.d.ts +4 -2
- package/dist/entrypoints/agent-executor.d.ts.map +1 -1
- package/dist/entrypoints/agent-executor.js +416 -28
- package/dist/entrypoints/agent-runtime/browser.js +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +3 -3
- package/dist/entrypoints/agent-runtime/harness.js +8 -8
- package/dist/entrypoints/agent-runtime/openrouter.js +2 -2
- package/dist/entrypoints/agent-runtime/postgres.js +6 -6
- package/dist/entrypoints/agent-runtime/realtime.js +4 -4
- package/dist/entrypoints/agent-runtime/sandbox.js +5 -5
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +6 -6
- package/dist/entrypoints/agent-runtime/sqlite/node.js +6 -6
- package/dist/entrypoints/agent-runtime/testing.js +5 -5
- package/dist/entrypoints/agent-runtime.js +21 -40
- package/dist/entrypoints/application/directory-inbox.js +2 -2
- package/dist/entrypoints/application/opentelemetry.js +2 -2
- package/dist/entrypoints/application.js +2 -2
- package/dist/entrypoints/cli/publish.js +3 -3
- package/dist/entrypoints/cli.js +8 -8
- package/dist/entrypoints/contract.js +2 -2
- package/dist/entrypoints/files/packaging.js +2 -2
- package/dist/entrypoints/files.js +7 -7
- package/dist/entrypoints/handler.js +4 -4
- package/dist/entrypoints/http.js +5 -5
- package/dist/entrypoints/index.js +7 -7
- package/dist/entrypoints/node.js +5 -5
- package/dist/entrypoints/observability.js +4 -4
- package/dist/entrypoints/primitives.js +2 -2
- package/dist/entrypoints/process.js +5 -5
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +2 -2
- package/dist/entrypoints/server.js +6 -6
- package/dist/entrypoints/service-host/macos.js +5 -5
- package/dist/entrypoints/service-host.js +7 -7
- package/dist/entrypoints/spend.js +1 -1
- package/dist/entrypoints/sync/postgres.js +1 -1
- package/dist/entrypoints/sync.js +2 -2
- package/dist/entrypoints/telegram.js +2 -2
- package/dist/entrypoints/testing.js +5 -5
- package/dist/entrypoints/tools/agent.js +5 -5
- package/dist/entrypoints/tools/connections.js +2 -2
- package/dist/entrypoints/tools/invoker.js +4 -4
- package/dist/entrypoints/tools/mcp.d.ts +1 -0
- package/dist/entrypoints/tools/mcp.d.ts.map +1 -1
- package/dist/entrypoints/tools/mcp.js +5 -5
- package/dist/entrypoints/tools/toolkit.js +8 -8
- package/dist/entrypoints/tools.js +12 -12
- package/dist/entrypoints/tracking/contract.js +1 -1
- package/dist/entrypoints/xlsx.js +1 -1
- package/dist/{index-prf6ayhf.js → index-13wmzpa6.js} +1 -1
- package/dist/{index-n7f89hjw.js → index-17qgm6xe.js} +3 -3
- package/dist/{index-wv8dqy7q.js → index-205456mf.js} +1 -1
- package/dist/{index-pwskmywy.js → index-21cfxc4z.js} +1 -1
- package/dist/{index-13dnv6d0.js → index-2s8sy57y.js} +37 -104
- package/dist/{index-d4svrknj.js → index-39c2hj6h.js} +2 -2
- package/dist/{index-sfzfd2m2.js → index-39rmc00v.js} +1 -1
- package/dist/{index-ky3ardqn.js → index-3fym4j8n.js} +1 -1
- package/dist/{index-c5gp2gh6.js → index-5tdc0q43.js} +1 -1
- package/dist/{index-3ypvpkwr.js → index-669374qc.js} +1 -1
- package/dist/{index-5jyjb4s0.js → index-80acsm27.js} +1 -1
- package/dist/{index-xmr47znh.js → index-827bgv33.js} +1 -1
- package/dist/{index-v1mxss62.js → index-93n6jwy0.js} +3 -3
- package/dist/{index-d54npte7.js → index-9kpxz49v.js} +2 -2
- package/dist/{index-xv9jb84s.js → index-9sfhje6y.js} +3 -3
- package/dist/{index-9y0afd5f.js → index-apf5g7y9.js} +1 -1
- package/dist/{index-bh4pmtr9.js → index-dbp6xemn.js} +78 -8
- package/dist/{index-g3e57qj6.js → index-dcsxj68j.js} +2 -2
- package/dist/{index-waa6t4zx.js → index-dnzxxf8a.js} +1 -1
- package/dist/{index-gf92hc87.js → index-fgahdc7s.js} +2 -2
- package/dist/{index-kzavdze2.js → index-gr0kxymw.js} +5 -1
- package/dist/{index-e06z0tkb.js → index-gya4hwh3.js} +2 -2
- package/dist/{index-gzny6zsw.js → index-hab790s6.js} +5 -5
- package/dist/{index-bz3gn6cs.js → index-j0ef04jw.js} +2 -2
- package/dist/{index-rhb33thr.js → index-jcge9tx3.js} +1 -1
- package/dist/{index-4qvyhn23.js → index-jrn3prgm.js} +1 -1
- package/dist/index-kne9g2c5.js +30 -0
- package/dist/{index-pn5b11ce.js → index-mkfhpk11.js} +1 -1
- package/dist/{index-1qwrczr1.js → index-mttkdm5a.js} +1 -1
- package/dist/{index-rxnyygke.js → index-n3bm7zqq.js} +1 -1
- package/dist/{index-6wp4dn9d.js → index-p06z7g7w.js} +3 -3
- package/dist/{index-kt6dh1n6.js → index-p16q492v.js} +1 -1
- package/dist/index-p1qmpq0p.js +1300 -0
- package/dist/{index-t7wa7k12.js → index-pp97q86a.js} +1 -1
- package/dist/{index-39n02e0q.js → index-psye60qn.js} +1 -1
- package/dist/{index-5ptwb6ka.js → index-pzhqydxb.js} +1 -1
- package/dist/{index-7kfcb576.js → index-qa2jjb65.js} +1 -1
- package/dist/{index-rzeezh79.js → index-qhjmmsm2.js} +2 -2
- package/dist/{index-7grgs8cx.js → index-qpzyahe3.js} +2 -2
- package/dist/{index-jfecdk1e.js → index-r97ppg0g.js} +2 -2
- package/dist/{index-bmaz3jzy.js → index-rjs94dny.js} +1 -1
- package/dist/{index-5v5vg85s.js → index-rxh3qy4x.js} +32 -5
- package/dist/{index-en8e5zsj.js → index-ryxb427v.js} +1 -1
- package/dist/{index-y065r8g5.js → index-sd4e5x5j.js} +7 -7
- package/dist/{index-g56ht6qf.js → index-t3qcac2a.js} +1 -1
- package/dist/{index-m18xm96h.js → index-v759mzed.js} +156 -6
- package/dist/{index-4j8efqr3.js → index-x2fb37t0.js} +2 -2
- package/dist/{index-cbhxhma2.js → index-x5ayy5bn.js} +1 -0
- package/dist/index-y0a4gt1s.js +142 -0
- package/dist/{index-wavv538x.js → index-ybdq8kk2.js} +3 -3
- package/dist/{index-4gk6k3zc.js → index-ycr4pk0z.js} +1 -1
- package/dist/{index-0tyt97nk.js → index-yrr3n391.js} +1 -1
- package/dist/{index-v37b2cd6.js → index-z20pdxeb.js} +2 -2
- package/dist/{index-8x22nprv.js → index-z9d74jmb.js} +3 -3
- package/dist/{index-3tnwtz38.js → index-zhshhxew.js} +1 -1
- package/dist/{index-hj1zq7mh.js → index-znd1b57f.js} +3 -3
- package/dist/internal/positive-integer.d.ts +2 -0
- package/dist/internal/positive-integer.d.ts.map +1 -1
- package/dist/internal/unix-socket.d.ts +7 -0
- package/dist/internal/unix-socket.d.ts.map +1 -1
- package/dist/tools/internal/rank-tools.d.ts +10 -0
- package/dist/tools/internal/rank-tools.d.ts.map +1 -0
- package/dist/tools/mcp/handler.d.ts +7 -3
- package/dist/tools/mcp/handler.d.ts.map +1 -1
- package/dist/tools/mcp/lazy-discovery.d.ts +47 -0
- package/dist/tools/mcp/lazy-discovery.d.ts.map +1 -0
- package/dist/tools/mcp/mount.d.ts +7 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +2 -2
- package/dist/tools/mcp/register.d.ts.map +1 -1
- package/llms/agent-executor-acp.txt +7 -8
- package/llms/agent-executor-claude-sdk.txt +15 -10
- package/llms/agent-executor-claude.txt +1 -1
- package/llms/agent-executor-codex.txt +13 -3
- package/llms/agent-executor-testing.txt +5 -1
- package/llms/agent-executor.txt +9 -8
- package/llms/stitchkit.txt +74 -74
- package/llms/tools-mcp.txt +3 -2
- package/llms/tools.txt +24 -0
- package/llms/{upgrading-0.128.0.txt → upgrading-0.128.0-0.130.0.txt} +58 -3
- package/llms/upgrading.txt +1 -1
- package/llms-full.txt +206 -107
- package/llms.txt +10 -10
- package/package.json +1 -1
- package/dist/index-0gqs8ght.js +0 -558
|
@@ -2,10 +2,43 @@ import"../../index-snef22zr.js";
|
|
|
2
2
|
import {
|
|
3
3
|
createLocalStepDurability2
|
|
4
4
|
} from "../../index-kynwa08q.js";
|
|
5
|
+
import"../../index-2rf33y2h.js";
|
|
6
|
+
import {
|
|
7
|
+
ExecutorThreadDispositionSchema2,
|
|
8
|
+
ExecutorStartupPhaseSchema2,
|
|
9
|
+
ExecutorErrorKindSchema2,
|
|
10
|
+
InteractionReplySchema2,
|
|
11
|
+
ExecutorEngineSchema2,
|
|
12
|
+
ExecutorDriverCapabilitiesSchema2,
|
|
13
|
+
PlanWindowSchema2,
|
|
14
|
+
engineProfile
|
|
15
|
+
} from "../../index-dbp6xemn.js";
|
|
16
|
+
import"../../index-09f7w2qq.js";
|
|
17
|
+
import"../../index-v59pxmf1.js";
|
|
18
|
+
import"../../index-qa2jjb65.js";
|
|
19
|
+
import"../../index-6kec3b14.js";
|
|
20
|
+
import {
|
|
21
|
+
createTurnDeltaChannel,
|
|
22
|
+
offerTurnDelta,
|
|
23
|
+
sessionAbort,
|
|
24
|
+
emitStartupPhase,
|
|
25
|
+
holdEngineRequest,
|
|
26
|
+
answerEngineRequest,
|
|
27
|
+
drainEngineRequests,
|
|
28
|
+
endEngineTurn,
|
|
29
|
+
loseEngineTurn
|
|
30
|
+
} from "../../index-2s8sy57y.js";
|
|
31
|
+
import"../../index-pzhqydxb.js";
|
|
5
32
|
import {
|
|
6
33
|
dispatchTurn2,
|
|
7
34
|
projectExecutorDeltas2
|
|
8
|
-
} from "../../index-
|
|
35
|
+
} from "../../index-x5ayy5bn.js";
|
|
36
|
+
import {
|
|
37
|
+
mergeRateLimitEvent2
|
|
38
|
+
} from "../../index-jrn3prgm.js";
|
|
39
|
+
import {
|
|
40
|
+
assertPositiveSafeInteger
|
|
41
|
+
} from "../../index-gr0kxymw.js";
|
|
9
42
|
|
|
10
43
|
// src/agent-executor/testing/conformance.ts
|
|
11
44
|
import { randomUUID } from "node:crypto";
|
|
@@ -80,6 +113,7 @@ function start(session, clientId = randomUUID()) {
|
|
|
80
113
|
async function runAgentEngineConformance(config) {
|
|
81
114
|
const turn = conformanceTurn(config);
|
|
82
115
|
for (const check of [
|
|
116
|
+
checkCapabilities,
|
|
83
117
|
checkText,
|
|
84
118
|
checkApproval,
|
|
85
119
|
checkFailures,
|
|
@@ -92,6 +126,28 @@ async function runAgentEngineConformance(config) {
|
|
|
92
126
|
await check(turn, config.scenarios);
|
|
93
127
|
}
|
|
94
128
|
}
|
|
129
|
+
var checkCapabilities = async (turn, scenarios) => {
|
|
130
|
+
await turn("capabilities", scenarios.text("cap-check"), async (_session, harness) => {
|
|
131
|
+
const { driver } = harness;
|
|
132
|
+
if (driver.capabilities === undefined)
|
|
133
|
+
return;
|
|
134
|
+
const parsed = ExecutorDriverCapabilitiesSchema2.safeParse(driver.capabilities);
|
|
135
|
+
if (!parsed.success) {
|
|
136
|
+
fail("capabilities", `driver.capabilities failed schema validation: ${parsed.error.message}`);
|
|
137
|
+
}
|
|
138
|
+
if (driver.reconcile === "client-id" && driver.findInput === undefined) {
|
|
139
|
+
fail("capabilities", "a client-id driver must provide findInput");
|
|
140
|
+
}
|
|
141
|
+
if (driver.engine === "acp") {
|
|
142
|
+
if (parsed.data.runtimePolicyEnforcement !== "client-boundary") {
|
|
143
|
+
fail("capabilities", "ACP driver must declare runtimePolicyEnforcement: client-boundary");
|
|
144
|
+
}
|
|
145
|
+
if ("approvalEnforcement" in driver && driver.approvalEnforcement !== "agent-initiated") {
|
|
146
|
+
fail("capabilities", "ACP driver approvalEnforcement must remain agent-initiated");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
};
|
|
95
151
|
var checkText = async (turn, scenarios) => {
|
|
96
152
|
await turn("text", scenarios.text("hello back"), async (session, harness) => {
|
|
97
153
|
const clientId = randomUUID();
|
|
@@ -367,9 +423,953 @@ async function runFakeClaudeEngine(input) {
|
|
|
367
423
|
input.exit(0);
|
|
368
424
|
}
|
|
369
425
|
}
|
|
426
|
+
// src/agent-executor/testing/replay-driver.ts
|
|
427
|
+
import { randomUUID as randomUUID2 } from "node:crypto";
|
|
428
|
+
|
|
429
|
+
// src/agent-executor/testing/replay-runner.ts
|
|
430
|
+
var DENY_ENDED = { kind: "deny", message: "The turn ended" };
|
|
431
|
+
var DENY_FAILED = {
|
|
432
|
+
kind: "deny",
|
|
433
|
+
message: "The replay engine failed"
|
|
434
|
+
};
|
|
435
|
+
function emitSimpleStep(step, turn, stepIndex, source) {
|
|
436
|
+
const raw = { source, type: `replay/${step.block}` };
|
|
437
|
+
const itemId = step.itemId ?? `${step.block}:${stepIndex}`;
|
|
438
|
+
switch (step.block) {
|
|
439
|
+
case "text":
|
|
440
|
+
offerTurnDelta(turn.channel, {
|
|
441
|
+
type: "text",
|
|
442
|
+
text: step.text,
|
|
443
|
+
turnId: turn.turnId,
|
|
444
|
+
itemId,
|
|
445
|
+
raw
|
|
446
|
+
});
|
|
447
|
+
return false;
|
|
448
|
+
case "reasoning":
|
|
449
|
+
offerTurnDelta(turn.channel, {
|
|
450
|
+
type: "reasoning",
|
|
451
|
+
text: step.text,
|
|
452
|
+
turnId: turn.turnId,
|
|
453
|
+
itemId,
|
|
454
|
+
raw
|
|
455
|
+
});
|
|
456
|
+
return false;
|
|
457
|
+
case "tool-call":
|
|
458
|
+
offerTurnDelta(turn.channel, {
|
|
459
|
+
type: "tool-call",
|
|
460
|
+
callId: step.callId,
|
|
461
|
+
toolName: step.toolName,
|
|
462
|
+
input: step.input,
|
|
463
|
+
turnId: turn.turnId,
|
|
464
|
+
itemId,
|
|
465
|
+
raw
|
|
466
|
+
});
|
|
467
|
+
return false;
|
|
468
|
+
case "tool-result":
|
|
469
|
+
offerTurnDelta(turn.channel, {
|
|
470
|
+
type: "tool-result",
|
|
471
|
+
callId: step.callId,
|
|
472
|
+
toolName: step.toolName,
|
|
473
|
+
outcome: step.outcome,
|
|
474
|
+
...step.output !== undefined && { output: step.output },
|
|
475
|
+
turnId: turn.turnId,
|
|
476
|
+
itemId,
|
|
477
|
+
raw
|
|
478
|
+
});
|
|
479
|
+
return false;
|
|
480
|
+
case "status":
|
|
481
|
+
offerTurnDelta(turn.channel, {
|
|
482
|
+
type: "status",
|
|
483
|
+
phase: step.phase,
|
|
484
|
+
turnId: turn.turnId,
|
|
485
|
+
itemId,
|
|
486
|
+
raw
|
|
487
|
+
});
|
|
488
|
+
return false;
|
|
489
|
+
case "window":
|
|
490
|
+
offerTurnDelta(turn.channel, {
|
|
491
|
+
type: "window",
|
|
492
|
+
reset: step.reset,
|
|
493
|
+
turnId: turn.turnId,
|
|
494
|
+
itemId,
|
|
495
|
+
raw
|
|
496
|
+
});
|
|
497
|
+
return false;
|
|
498
|
+
case "error":
|
|
499
|
+
offerTurnDelta(turn.channel, {
|
|
500
|
+
type: "error",
|
|
501
|
+
kind: step.errorKind,
|
|
502
|
+
message: step.message,
|
|
503
|
+
turnId: turn.turnId,
|
|
504
|
+
itemId,
|
|
505
|
+
raw
|
|
506
|
+
});
|
|
507
|
+
return false;
|
|
508
|
+
case "turn-end": {
|
|
509
|
+
const outcome = turn.state.interruptRequested ? "interrupted" : step.outcome;
|
|
510
|
+
endEngineTurn(turn, () => DENY_ENDED, [
|
|
511
|
+
{
|
|
512
|
+
type: "turn-end",
|
|
513
|
+
outcome,
|
|
514
|
+
...step.threadDisposition !== undefined && {
|
|
515
|
+
threadDisposition: step.threadDisposition
|
|
516
|
+
},
|
|
517
|
+
turnId: turn.turnId,
|
|
518
|
+
itemId,
|
|
519
|
+
raw
|
|
520
|
+
}
|
|
521
|
+
]);
|
|
522
|
+
return true;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
async function flushQueuedDeltasBeforeFailure(turn, signal) {
|
|
527
|
+
for (let tick = 0;tick < 8; tick += 1) {
|
|
528
|
+
if (signal.aborted || turn.channel.getSnapshot().queuedItems === 0)
|
|
529
|
+
return;
|
|
530
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
async function runReplayTurnScript(context) {
|
|
534
|
+
const { script, turn, engine, signal } = context;
|
|
535
|
+
let ended = false;
|
|
536
|
+
try {
|
|
537
|
+
await Promise.resolve();
|
|
538
|
+
for (let index = 0;index < script.steps.length; index += 1) {
|
|
539
|
+
const step = script.steps[index];
|
|
540
|
+
if (step === undefined)
|
|
541
|
+
continue;
|
|
542
|
+
if (signal.aborted)
|
|
543
|
+
throw new Error("Replay session aborted");
|
|
544
|
+
if (step.kind === "emit") {
|
|
545
|
+
ended = emitSimpleStep(step, turn, index, engine);
|
|
546
|
+
if (ended)
|
|
547
|
+
break;
|
|
548
|
+
continue;
|
|
549
|
+
}
|
|
550
|
+
if (step.kind === "gate") {
|
|
551
|
+
await context.gate?.beforeEmit(step.label, signal);
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
if (step.kind === "waitInterrupt") {
|
|
555
|
+
if (!turn.state.interruptRequested) {
|
|
556
|
+
await new Promise((resolve) => {
|
|
557
|
+
const onAbort = () => resolve();
|
|
558
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
559
|
+
turn.interruptWaiters.push(() => {
|
|
560
|
+
signal.removeEventListener("abort", onAbort);
|
|
561
|
+
resolve();
|
|
562
|
+
});
|
|
563
|
+
});
|
|
564
|
+
}
|
|
565
|
+
continue;
|
|
566
|
+
}
|
|
567
|
+
if (step.kind === "request") {
|
|
568
|
+
const replyPromise = new Promise((resolve) => {
|
|
569
|
+
holdEngineRequest(turn, {
|
|
570
|
+
interactionId: step.interactionId,
|
|
571
|
+
detail: { interactionId: step.interactionId },
|
|
572
|
+
answeredBy: { source: engine, type: "replay/request" },
|
|
573
|
+
delta: () => ({
|
|
574
|
+
type: "request",
|
|
575
|
+
turnId: turn.turnId,
|
|
576
|
+
itemId: step.itemId ?? `request:${step.interactionId}`,
|
|
577
|
+
raw: { source: engine, type: "replay/request" },
|
|
578
|
+
interactionId: step.interactionId,
|
|
579
|
+
kind: step.requestKind,
|
|
580
|
+
...step.callId !== undefined && { callId: step.callId },
|
|
581
|
+
...step.toolName !== undefined && { toolName: step.toolName },
|
|
582
|
+
...step.input !== undefined && { input: step.input },
|
|
583
|
+
...step.prompt !== undefined && { prompt: step.prompt }
|
|
584
|
+
}),
|
|
585
|
+
refusal: { kind: "deny", message: "The turn was interrupted" },
|
|
586
|
+
resolve: (reply) => {
|
|
587
|
+
context.answeredIds.add(step.interactionId);
|
|
588
|
+
resolve(reply);
|
|
589
|
+
}
|
|
590
|
+
});
|
|
591
|
+
});
|
|
592
|
+
turn.replyPromises.set(step.interactionId, replyPromise);
|
|
593
|
+
continue;
|
|
594
|
+
}
|
|
595
|
+
if (step.kind === "expectReply") {
|
|
596
|
+
const pendingReply = turn.replyPromises.get(step.interactionId);
|
|
597
|
+
if (pendingReply === undefined) {
|
|
598
|
+
throw new Error(`Replay expectReply(${step.interactionId}) has no matching preceding request`);
|
|
599
|
+
}
|
|
600
|
+
const reply = await pendingReply;
|
|
601
|
+
if (signal.aborted)
|
|
602
|
+
throw new Error("Replay session aborted");
|
|
603
|
+
if (!turn.state.interruptRequested && step.replyKind !== undefined && reply.kind !== step.replyKind) {
|
|
604
|
+
throw new Error(`Replay expectReply(${step.interactionId}) expected ${step.replyKind}, got ${reply.kind}`);
|
|
605
|
+
}
|
|
606
|
+
if (!turn.state.interruptRequested && step.scope !== undefined && (reply.kind !== "approve" || reply.scope !== step.scope)) {
|
|
607
|
+
throw new Error(`Replay expectReply(${step.interactionId}) expected scope ${step.scope}`);
|
|
608
|
+
}
|
|
609
|
+
continue;
|
|
610
|
+
}
|
|
611
|
+
if (step.kind === "usage") {
|
|
612
|
+
offerTurnDelta(turn.channel, {
|
|
613
|
+
type: "usage",
|
|
614
|
+
turnId: turn.turnId,
|
|
615
|
+
itemId: step.itemId ?? `usage:${index}`,
|
|
616
|
+
raw: { source: engine, type: "replay/usage" },
|
|
617
|
+
...step.inputTokens !== undefined && { inputTokens: step.inputTokens },
|
|
618
|
+
...step.outputTokens !== undefined && { outputTokens: step.outputTokens },
|
|
619
|
+
...step.cachedInputTokens !== undefined && {
|
|
620
|
+
cachedInputTokens: step.cachedInputTokens
|
|
621
|
+
},
|
|
622
|
+
...step.cacheCreationInputTokens !== undefined && {
|
|
623
|
+
cacheCreationInputTokens: step.cacheCreationInputTokens
|
|
624
|
+
},
|
|
625
|
+
...step.thinkingTokens !== undefined && { thinkingTokens: step.thinkingTokens },
|
|
626
|
+
...step.totalTokens !== undefined && { totalTokens: step.totalTokens },
|
|
627
|
+
...step.costUsd !== undefined && { costUsd: step.costUsd }
|
|
628
|
+
});
|
|
629
|
+
continue;
|
|
630
|
+
}
|
|
631
|
+
if (step.kind === "contextUsage") {
|
|
632
|
+
offerTurnDelta(turn.channel, {
|
|
633
|
+
type: "context-usage",
|
|
634
|
+
turnId: turn.turnId,
|
|
635
|
+
itemId: step.itemId ?? `context-usage:${index}`,
|
|
636
|
+
raw: { source: engine, type: "replay/context-usage" },
|
|
637
|
+
usedTokens: step.usedTokens,
|
|
638
|
+
windowTokens: step.windowTokens
|
|
639
|
+
});
|
|
640
|
+
continue;
|
|
641
|
+
}
|
|
642
|
+
if (step.kind === "rateLimit") {
|
|
643
|
+
context.limits.set(context.profileId, mergeRateLimitEvent2({
|
|
644
|
+
previous: context.limits.get(context.profileId),
|
|
645
|
+
windows: step.windows,
|
|
646
|
+
now: new Date
|
|
647
|
+
}));
|
|
648
|
+
continue;
|
|
649
|
+
}
|
|
650
|
+
if (step.kind === "unknownRecord") {
|
|
651
|
+
offerTurnDelta(turn.channel, {
|
|
652
|
+
type: "error",
|
|
653
|
+
turnId: turn.turnId,
|
|
654
|
+
itemId: `unhandled:${index}`,
|
|
655
|
+
raw: { source: engine, type: step.recordType ?? "replay/unknown" },
|
|
656
|
+
kind: "unhandled",
|
|
657
|
+
message: step.message ?? "Unknown replay record"
|
|
658
|
+
});
|
|
659
|
+
continue;
|
|
660
|
+
}
|
|
661
|
+
await flushQueuedDeltasBeforeFailure(turn, signal);
|
|
662
|
+
if (step.kind === "invalidLine") {
|
|
663
|
+
throw new Error(`Invalid replay line: ${step.rawLine ?? "<malformed>"}`);
|
|
664
|
+
}
|
|
665
|
+
if (step.kind === "eofWithoutResult") {
|
|
666
|
+
throw new Error("Replay engine reached EOF without a turn-end result");
|
|
667
|
+
}
|
|
668
|
+
throw new Error(step.message ?? "Replay engine crashed");
|
|
669
|
+
}
|
|
670
|
+
if (!ended) {
|
|
671
|
+
await flushQueuedDeltasBeforeFailure(turn, signal);
|
|
672
|
+
throw new Error("Replay transcript ended without emitting turn-end");
|
|
673
|
+
}
|
|
674
|
+
context.onTurnCompleted();
|
|
675
|
+
} catch (error) {
|
|
676
|
+
const failed = error instanceof Error ? error : new Error(String(error));
|
|
677
|
+
loseEngineTurn(turn, () => DENY_FAILED, failed);
|
|
678
|
+
} finally {
|
|
679
|
+
context.clearActiveTurn();
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
// src/agent-executor/testing/replay-transcript.ts
|
|
684
|
+
import { z as z3 } from "zod";
|
|
685
|
+
var DEFAULT_REPLAY_MAX_BYTES = 4 * 1024 * 1024;
|
|
686
|
+
var DEFAULT_REPLAY_MAX_STEPS = 4096;
|
|
687
|
+
var NonEmpty = z3.string().min(1).max(256);
|
|
688
|
+
var LabelSchema = z3.string().trim().min(1).max(128);
|
|
689
|
+
var NonNegativeInt = z3.int().nonnegative();
|
|
690
|
+
var EmitTextStepSchema = z3.strictObject({
|
|
691
|
+
kind: z3.literal("emit"),
|
|
692
|
+
block: z3.enum(["text", "reasoning"]),
|
|
693
|
+
text: z3.string(),
|
|
694
|
+
itemId: NonEmpty.optional()
|
|
695
|
+
});
|
|
696
|
+
var EmitToolCallStepSchema = z3.strictObject({
|
|
697
|
+
kind: z3.literal("emit"),
|
|
698
|
+
block: z3.literal("tool-call"),
|
|
699
|
+
callId: NonEmpty,
|
|
700
|
+
toolName: NonEmpty,
|
|
701
|
+
input: z3.json(),
|
|
702
|
+
itemId: NonEmpty.optional()
|
|
703
|
+
});
|
|
704
|
+
var EmitToolResultStepSchema = z3.strictObject({
|
|
705
|
+
kind: z3.literal("emit"),
|
|
706
|
+
block: z3.literal("tool-result"),
|
|
707
|
+
callId: NonEmpty,
|
|
708
|
+
toolName: NonEmpty,
|
|
709
|
+
outcome: z3.enum(["success", "error", "interrupted"]),
|
|
710
|
+
output: z3.json().optional(),
|
|
711
|
+
itemId: NonEmpty.optional()
|
|
712
|
+
});
|
|
713
|
+
var EmitStatusStepSchema = z3.strictObject({
|
|
714
|
+
kind: z3.literal("emit"),
|
|
715
|
+
block: z3.literal("status"),
|
|
716
|
+
phase: ExecutorStartupPhaseSchema2,
|
|
717
|
+
itemId: NonEmpty.optional()
|
|
718
|
+
});
|
|
719
|
+
var EmitWindowStepSchema = z3.strictObject({
|
|
720
|
+
kind: z3.literal("emit"),
|
|
721
|
+
block: z3.literal("window"),
|
|
722
|
+
reset: z3.enum(["initial", "gap", "generation", "context"]),
|
|
723
|
+
itemId: NonEmpty.optional()
|
|
724
|
+
});
|
|
725
|
+
var EmitErrorStepSchema = z3.strictObject({
|
|
726
|
+
kind: z3.literal("emit"),
|
|
727
|
+
block: z3.literal("error"),
|
|
728
|
+
errorKind: ExecutorErrorKindSchema2,
|
|
729
|
+
message: z3.string().min(1).max(4096),
|
|
730
|
+
itemId: NonEmpty.optional()
|
|
731
|
+
});
|
|
732
|
+
var EmitTurnEndStepSchema = z3.strictObject({
|
|
733
|
+
kind: z3.literal("emit"),
|
|
734
|
+
block: z3.literal("turn-end"),
|
|
735
|
+
outcome: z3.enum(["completed", "interrupted", "failed"]),
|
|
736
|
+
threadDisposition: ExecutorThreadDispositionSchema2.optional(),
|
|
737
|
+
itemId: NonEmpty.optional()
|
|
738
|
+
});
|
|
739
|
+
var RequestStepSchema = z3.strictObject({
|
|
740
|
+
kind: z3.literal("request"),
|
|
741
|
+
interactionId: NonEmpty,
|
|
742
|
+
requestKind: z3.enum(["approval", "input"]),
|
|
743
|
+
callId: NonEmpty.optional(),
|
|
744
|
+
toolName: NonEmpty.optional(),
|
|
745
|
+
input: z3.json().optional(),
|
|
746
|
+
prompt: z3.string().optional(),
|
|
747
|
+
itemId: NonEmpty.optional()
|
|
748
|
+
});
|
|
749
|
+
var ExpectReplyStepSchema = z3.strictObject({
|
|
750
|
+
kind: z3.literal("expectReply"),
|
|
751
|
+
interactionId: NonEmpty,
|
|
752
|
+
replyKind: z3.enum(["approve", "deny", "input"]).optional(),
|
|
753
|
+
scope: z3.enum(["once", "session"]).optional(),
|
|
754
|
+
required: z3.boolean().optional()
|
|
755
|
+
});
|
|
756
|
+
var GateStepSchema = z3.strictObject({
|
|
757
|
+
kind: z3.literal("gate"),
|
|
758
|
+
label: LabelSchema
|
|
759
|
+
});
|
|
760
|
+
var WaitInterruptStepSchema = z3.strictObject({
|
|
761
|
+
kind: z3.literal("waitInterrupt")
|
|
762
|
+
});
|
|
763
|
+
var UsageStepSchema = z3.strictObject({
|
|
764
|
+
kind: z3.literal("usage"),
|
|
765
|
+
inputTokens: NonNegativeInt.optional(),
|
|
766
|
+
outputTokens: NonNegativeInt.optional(),
|
|
767
|
+
cachedInputTokens: NonNegativeInt.optional(),
|
|
768
|
+
cacheCreationInputTokens: NonNegativeInt.optional(),
|
|
769
|
+
thinkingTokens: NonNegativeInt.optional(),
|
|
770
|
+
totalTokens: NonNegativeInt.optional(),
|
|
771
|
+
costUsd: z3.number().nonnegative().optional(),
|
|
772
|
+
itemId: NonEmpty.optional()
|
|
773
|
+
});
|
|
774
|
+
var ContextUsageStepSchema = z3.strictObject({
|
|
775
|
+
kind: z3.literal("contextUsage"),
|
|
776
|
+
usedTokens: NonNegativeInt,
|
|
777
|
+
windowTokens: NonNegativeInt,
|
|
778
|
+
itemId: NonEmpty.optional()
|
|
779
|
+
});
|
|
780
|
+
var RateLimitStepSchema = z3.strictObject({
|
|
781
|
+
kind: z3.literal("rateLimit"),
|
|
782
|
+
windows: z3.array(PlanWindowSchema2).max(32)
|
|
783
|
+
});
|
|
784
|
+
var UnknownRecordStepSchema = z3.strictObject({
|
|
785
|
+
kind: z3.literal("unknownRecord"),
|
|
786
|
+
recordType: NonEmpty.optional(),
|
|
787
|
+
message: z3.string().min(1).max(4096).optional()
|
|
788
|
+
});
|
|
789
|
+
var InvalidLineStepSchema = z3.strictObject({
|
|
790
|
+
kind: z3.literal("invalidLine"),
|
|
791
|
+
rawLine: z3.string().optional()
|
|
792
|
+
});
|
|
793
|
+
var EofWithoutResultStepSchema = z3.strictObject({
|
|
794
|
+
kind: z3.literal("eofWithoutResult")
|
|
795
|
+
});
|
|
796
|
+
var CrashStepSchema = z3.strictObject({
|
|
797
|
+
kind: z3.literal("crash"),
|
|
798
|
+
message: z3.string().min(1).max(4096).optional()
|
|
799
|
+
});
|
|
800
|
+
var ExecutorReplayStepSchema = z3.union([
|
|
801
|
+
EmitTextStepSchema,
|
|
802
|
+
EmitToolCallStepSchema,
|
|
803
|
+
EmitToolResultStepSchema,
|
|
804
|
+
EmitStatusStepSchema,
|
|
805
|
+
EmitWindowStepSchema,
|
|
806
|
+
EmitErrorStepSchema,
|
|
807
|
+
EmitTurnEndStepSchema,
|
|
808
|
+
RequestStepSchema,
|
|
809
|
+
ExpectReplyStepSchema,
|
|
810
|
+
GateStepSchema,
|
|
811
|
+
WaitInterruptStepSchema,
|
|
812
|
+
UsageStepSchema,
|
|
813
|
+
ContextUsageStepSchema,
|
|
814
|
+
RateLimitStepSchema,
|
|
815
|
+
UnknownRecordStepSchema,
|
|
816
|
+
InvalidLineStepSchema,
|
|
817
|
+
EofWithoutResultStepSchema,
|
|
818
|
+
CrashStepSchema
|
|
819
|
+
]);
|
|
820
|
+
var ExecutorReplayTranscriptSchema = z3.strictObject({
|
|
821
|
+
steps: z3.array(ExecutorReplayStepSchema).max(DEFAULT_REPLAY_MAX_STEPS)
|
|
822
|
+
});
|
|
823
|
+
var UTF8_ENCODER = new TextEncoder;
|
|
824
|
+
function substituteWorkspace(value, workspace) {
|
|
825
|
+
if (typeof value === "string") {
|
|
826
|
+
return value.includes("<workspace>") ? value.replaceAll("<workspace>", workspace) : value;
|
|
827
|
+
}
|
|
828
|
+
if (Array.isArray(value)) {
|
|
829
|
+
return value.map((item) => substituteWorkspace(item, workspace));
|
|
830
|
+
}
|
|
831
|
+
if (typeof value === "object" && value !== null) {
|
|
832
|
+
const out = {};
|
|
833
|
+
for (const [key, entry] of Object.entries(value)) {
|
|
834
|
+
out[key] = substituteWorkspace(entry, workspace);
|
|
835
|
+
}
|
|
836
|
+
return out;
|
|
837
|
+
}
|
|
838
|
+
return value;
|
|
839
|
+
}
|
|
840
|
+
function parseReplayTranscript(ndjson, options = {}) {
|
|
841
|
+
const maxBytes = options.maxBytes ?? DEFAULT_REPLAY_MAX_BYTES;
|
|
842
|
+
const maxSteps = options.maxSteps ?? DEFAULT_REPLAY_MAX_STEPS;
|
|
843
|
+
assertPositiveSafeInteger("maxBytes", maxBytes);
|
|
844
|
+
assertPositiveSafeInteger("maxSteps", maxSteps);
|
|
845
|
+
if (maxBytes > DEFAULT_REPLAY_MAX_BYTES) {
|
|
846
|
+
throw new RangeError(`Replay transcript maxBytes (${maxBytes}) exceeds hard ceiling (${DEFAULT_REPLAY_MAX_BYTES})`);
|
|
847
|
+
}
|
|
848
|
+
if (maxSteps > DEFAULT_REPLAY_MAX_STEPS) {
|
|
849
|
+
throw new RangeError(`Replay transcript maxSteps (${maxSteps}) exceeds hard ceiling (${DEFAULT_REPLAY_MAX_STEPS})`);
|
|
850
|
+
}
|
|
851
|
+
const actualBytes = UTF8_ENCODER.encode(ndjson).byteLength;
|
|
852
|
+
if (actualBytes > maxBytes) {
|
|
853
|
+
throw new RangeError(`Replay transcript size (${actualBytes} bytes) exceeds limit (${maxBytes} bytes)`);
|
|
854
|
+
}
|
|
855
|
+
const steps = [];
|
|
856
|
+
const lines = ndjson.split(/\r?\n/);
|
|
857
|
+
for (let index = 0;index < lines.length; index += 1) {
|
|
858
|
+
const line = lines[index]?.trim() ?? "";
|
|
859
|
+
if (line.length === 0)
|
|
860
|
+
continue;
|
|
861
|
+
if (steps.length >= maxSteps) {
|
|
862
|
+
throw new RangeError(`Replay transcript exceeds step limit (${maxSteps})`);
|
|
863
|
+
}
|
|
864
|
+
let decoded;
|
|
865
|
+
try {
|
|
866
|
+
decoded = JSON.parse(line);
|
|
867
|
+
} catch (error) {
|
|
868
|
+
throw new SyntaxError(`Invalid JSON in replay transcript on line ${index + 1}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
|
|
869
|
+
}
|
|
870
|
+
const hydrated = options.workspace !== undefined ? substituteWorkspace(decoded, options.workspace) : decoded;
|
|
871
|
+
steps.push(ExecutorReplayStepSchema.parse(hydrated));
|
|
872
|
+
}
|
|
873
|
+
return { steps };
|
|
874
|
+
}
|
|
875
|
+
function formatReplayTranscript(steps) {
|
|
876
|
+
return steps.map((step) => JSON.stringify(ExecutorReplayStepSchema.parse(step))).join(`
|
|
877
|
+
`);
|
|
878
|
+
}
|
|
879
|
+
|
|
880
|
+
// src/agent-executor/testing/replay-driver.ts
|
|
881
|
+
var DENY_INTERRUPTED = {
|
|
882
|
+
kind: "deny",
|
|
883
|
+
message: "The turn was interrupted"
|
|
884
|
+
};
|
|
885
|
+
var DENY_CLOSED = {
|
|
886
|
+
kind: "deny",
|
|
887
|
+
message: "The replay session closed"
|
|
888
|
+
};
|
|
889
|
+
function defaultReplayCapabilities(engine, overrides) {
|
|
890
|
+
const base = {
|
|
891
|
+
runtimePolicyEnforcement: engine === "acp" ? "client-boundary" : "native",
|
|
892
|
+
sessionApproval: true,
|
|
893
|
+
interruptOnDeny: true,
|
|
894
|
+
updatedToolInput: engine === "claude-cli" || engine === "claude-sdk",
|
|
895
|
+
structuredInput: true,
|
|
896
|
+
steer: false,
|
|
897
|
+
fork: false,
|
|
898
|
+
revert: false,
|
|
899
|
+
compact: false,
|
|
900
|
+
injectItems: false,
|
|
901
|
+
backgroundWorkOutlivesTurn: false,
|
|
902
|
+
multiThreadPerProcess: false,
|
|
903
|
+
images: false,
|
|
904
|
+
planLimits: "passive"
|
|
905
|
+
};
|
|
906
|
+
return ExecutorDriverCapabilitiesSchema2.parse({ ...base, ...overrides });
|
|
907
|
+
}
|
|
908
|
+
function normalizeTurns(rawTurns, workspace) {
|
|
909
|
+
return rawTurns.map((entry) => typeof entry === "string" ? parseReplayTranscript(entry, workspace !== undefined ? { workspace } : {}) : ExecutorReplayTranscriptSchema.parse(entry));
|
|
910
|
+
}
|
|
911
|
+
function createReplayExecutorDriver(config) {
|
|
912
|
+
const engine = ExecutorEngineSchema2.parse(config.engine ?? "acp");
|
|
913
|
+
const reconcile = config.reconcile ?? "none";
|
|
914
|
+
if (reconcile !== "client-id" && reconcile !== "none") {
|
|
915
|
+
throw new TypeError(`Unsupported replay reconcile mode: ${String(reconcile)}`);
|
|
916
|
+
}
|
|
917
|
+
const capabilities = defaultReplayCapabilities(engine, config.capabilities);
|
|
918
|
+
const transcripts = normalizeTurns(config.turns, config.workspace);
|
|
919
|
+
const version = config.version ?? "replay-1.0.0";
|
|
920
|
+
const limits = new Map;
|
|
921
|
+
const recordedInputs = new Map;
|
|
922
|
+
const answeredIds = new Set;
|
|
923
|
+
const hostAnsweredIds = new Set;
|
|
924
|
+
let nextTurnIndex = 0;
|
|
925
|
+
let completedTurns = 0;
|
|
926
|
+
const assertComplete = () => {
|
|
927
|
+
if (completedTurns < transcripts.length) {
|
|
928
|
+
throw new Error(`Replay driver incomplete: completed ${completedTurns} of ${transcripts.length} scripted turn(s)`);
|
|
929
|
+
}
|
|
930
|
+
const missingRequired = [];
|
|
931
|
+
for (const transcript of transcripts) {
|
|
932
|
+
for (const step of transcript.steps) {
|
|
933
|
+
if (step.kind === "expectReply" && step.required !== false && !hostAnsweredIds.has(step.interactionId)) {
|
|
934
|
+
missingRequired.push(`expectReply:${step.interactionId}`);
|
|
935
|
+
}
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
if (missingRequired.length > 0) {
|
|
939
|
+
throw new Error(`Replay driver incomplete: unconsumed required step(s): ${missingRequired.join(", ")}`);
|
|
940
|
+
}
|
|
941
|
+
};
|
|
942
|
+
return {
|
|
943
|
+
engine,
|
|
944
|
+
reconcile,
|
|
945
|
+
capabilities,
|
|
946
|
+
...engine === "acp" ? { approvalEnforcement: "agent-initiated" } : {},
|
|
947
|
+
async info() {
|
|
948
|
+
return {
|
|
949
|
+
engine,
|
|
950
|
+
version,
|
|
951
|
+
reconcile,
|
|
952
|
+
models: config.models !== undefined ? { answer: "listed", ids: [...config.models] } : { answer: "not-asked" },
|
|
953
|
+
capabilities
|
|
954
|
+
};
|
|
955
|
+
},
|
|
956
|
+
async status(rawProfile) {
|
|
957
|
+
const profile = engineProfile(engine, rawProfile);
|
|
958
|
+
const known = limits.get(profile.profileId);
|
|
959
|
+
return {
|
|
960
|
+
login: { state: "signed-in" },
|
|
961
|
+
effectiveCredential: "subscription",
|
|
962
|
+
...known !== undefined && { planLimits: known }
|
|
963
|
+
};
|
|
964
|
+
},
|
|
965
|
+
...reconcile === "client-id" ? {
|
|
966
|
+
async findInput(input) {
|
|
967
|
+
return recordedInputs.get(input.nativeThreadId)?.has(input.clientId) ?? false;
|
|
968
|
+
}
|
|
969
|
+
} : {},
|
|
970
|
+
inputsFor: (nativeThreadId) => recordedInputs.get(nativeThreadId)?.size ?? 0,
|
|
971
|
+
wasAnswered: (interactionId) => answeredIds.has(interactionId),
|
|
972
|
+
assertComplete,
|
|
973
|
+
async open(openInput) {
|
|
974
|
+
const profile = engineProfile(engine, openInput.profile);
|
|
975
|
+
const linked = sessionAbort(openInput.signal);
|
|
976
|
+
emitStartupPhase(openInput.onStartupPhase, "initializing");
|
|
977
|
+
const nativeThreadId = openInput.nativeThreadId ?? `replay-thread-${randomUUID2()}`;
|
|
978
|
+
let closed = false;
|
|
979
|
+
let activeTurn;
|
|
980
|
+
let activeTurnPromise;
|
|
981
|
+
return {
|
|
982
|
+
nativeThreadId,
|
|
983
|
+
async startTurn(turnInput) {
|
|
984
|
+
if (closed)
|
|
985
|
+
throw new Error("The replay session is closed");
|
|
986
|
+
if (activeTurn !== undefined) {
|
|
987
|
+
throw new Error("A turn is already running in this replay session");
|
|
988
|
+
}
|
|
989
|
+
const script = transcripts[nextTurnIndex];
|
|
990
|
+
if (script === undefined) {
|
|
991
|
+
throw new Error(`No replay transcript available for turn index ${nextTurnIndex}`);
|
|
992
|
+
}
|
|
993
|
+
nextTurnIndex += 1;
|
|
994
|
+
let seen = recordedInputs.get(nativeThreadId);
|
|
995
|
+
if (seen === undefined) {
|
|
996
|
+
seen = new Set;
|
|
997
|
+
recordedInputs.set(nativeThreadId, seen);
|
|
998
|
+
}
|
|
999
|
+
seen.add(turnInput.clientId);
|
|
1000
|
+
const turn = {
|
|
1001
|
+
turnId: turnInput.turnId,
|
|
1002
|
+
state: { turnId: turnInput.turnId, interruptRequested: false },
|
|
1003
|
+
channel: createTurnDeltaChannel(),
|
|
1004
|
+
pending: new Map,
|
|
1005
|
+
interruptWaiters: [],
|
|
1006
|
+
replyPromises: new Map
|
|
1007
|
+
};
|
|
1008
|
+
activeTurn = turn;
|
|
1009
|
+
const runPromise = runReplayTurnScript({
|
|
1010
|
+
script,
|
|
1011
|
+
turn,
|
|
1012
|
+
engine,
|
|
1013
|
+
profileId: profile.profileId,
|
|
1014
|
+
limits,
|
|
1015
|
+
answeredIds,
|
|
1016
|
+
hostAnsweredIds,
|
|
1017
|
+
...config.gate !== undefined && { gate: config.gate },
|
|
1018
|
+
signal: linked.signal,
|
|
1019
|
+
onTurnCompleted: () => {
|
|
1020
|
+
completedTurns += 1;
|
|
1021
|
+
},
|
|
1022
|
+
clearActiveTurn: () => {
|
|
1023
|
+
if (activeTurn === turn)
|
|
1024
|
+
activeTurn = undefined;
|
|
1025
|
+
if (activeTurnPromise === runPromise)
|
|
1026
|
+
activeTurnPromise = undefined;
|
|
1027
|
+
}
|
|
1028
|
+
});
|
|
1029
|
+
activeTurnPromise = runPromise;
|
|
1030
|
+
return {
|
|
1031
|
+
deltas: turn.channel,
|
|
1032
|
+
async interrupt() {
|
|
1033
|
+
turn.state.interruptRequested = true;
|
|
1034
|
+
drainEngineRequests(turn, () => DENY_INTERRUPTED);
|
|
1035
|
+
for (const wake of turn.interruptWaiters.splice(0))
|
|
1036
|
+
wake();
|
|
1037
|
+
},
|
|
1038
|
+
async respond(interactionId, rawReply) {
|
|
1039
|
+
if (!turn.pending.has(interactionId)) {
|
|
1040
|
+
throw new TypeError(`Unknown interaction ${interactionId} for this turn`);
|
|
1041
|
+
}
|
|
1042
|
+
const parsed = InteractionReplySchema2.shape.reply.safeParse(rawReply);
|
|
1043
|
+
if (!parsed.success) {
|
|
1044
|
+
throw new TypeError(`Invalid interaction reply: ${parsed.error.message}`);
|
|
1045
|
+
}
|
|
1046
|
+
hostAnsweredIds.add(interactionId);
|
|
1047
|
+
answerEngineRequest(turn, interactionId, parsed.data);
|
|
1048
|
+
}
|
|
1049
|
+
};
|
|
1050
|
+
},
|
|
1051
|
+
async close() {
|
|
1052
|
+
closed = true;
|
|
1053
|
+
const running = activeTurn;
|
|
1054
|
+
const pendingRun = activeTurnPromise;
|
|
1055
|
+
activeTurn = undefined;
|
|
1056
|
+
loseEngineTurn(running, () => DENY_CLOSED, new Error("The replay session closed"));
|
|
1057
|
+
linked.abort();
|
|
1058
|
+
linked.release();
|
|
1059
|
+
if (pendingRun !== undefined)
|
|
1060
|
+
await pendingRun;
|
|
1061
|
+
if (config.assertCompleteOnClose)
|
|
1062
|
+
assertComplete();
|
|
1063
|
+
}
|
|
1064
|
+
};
|
|
1065
|
+
}
|
|
1066
|
+
};
|
|
1067
|
+
}
|
|
1068
|
+
// src/agent-executor/testing/replay-gate.ts
|
|
1069
|
+
function createReplayGate(labels) {
|
|
1070
|
+
const slots = new Map;
|
|
1071
|
+
for (const rawLabel of labels) {
|
|
1072
|
+
const label = rawLabel.trim();
|
|
1073
|
+
if (label.length === 0) {
|
|
1074
|
+
throw new TypeError("Replay gate label must be a non-empty string");
|
|
1075
|
+
}
|
|
1076
|
+
if (slots.has(label)) {
|
|
1077
|
+
throw new TypeError(`Duplicate replay gate label "${label}"`);
|
|
1078
|
+
}
|
|
1079
|
+
let resolve = () => {
|
|
1080
|
+
return;
|
|
1081
|
+
};
|
|
1082
|
+
const promise = new Promise((done) => {
|
|
1083
|
+
resolve = done;
|
|
1084
|
+
});
|
|
1085
|
+
let resolveReached = () => {
|
|
1086
|
+
return;
|
|
1087
|
+
};
|
|
1088
|
+
const reachedPromise = new Promise((done) => {
|
|
1089
|
+
resolveReached = done;
|
|
1090
|
+
});
|
|
1091
|
+
slots.set(label, {
|
|
1092
|
+
reached: false,
|
|
1093
|
+
released: false,
|
|
1094
|
+
reachedPromise,
|
|
1095
|
+
resolveReached,
|
|
1096
|
+
promise,
|
|
1097
|
+
resolve
|
|
1098
|
+
});
|
|
1099
|
+
}
|
|
1100
|
+
return {
|
|
1101
|
+
beforeEmit(label, signal) {
|
|
1102
|
+
const slot = slots.get(label);
|
|
1103
|
+
if (slot === undefined)
|
|
1104
|
+
return Promise.resolve();
|
|
1105
|
+
slot.reached = true;
|
|
1106
|
+
slot.resolveReached();
|
|
1107
|
+
if (signal === undefined)
|
|
1108
|
+
return slot.promise;
|
|
1109
|
+
if (signal.aborted)
|
|
1110
|
+
return Promise.resolve();
|
|
1111
|
+
return new Promise((done) => {
|
|
1112
|
+
const onAbort = () => done();
|
|
1113
|
+
signal.addEventListener("abort", onAbort, { once: true });
|
|
1114
|
+
slot.promise.then(() => {
|
|
1115
|
+
signal.removeEventListener("abort", onAbort);
|
|
1116
|
+
done();
|
|
1117
|
+
});
|
|
1118
|
+
});
|
|
1119
|
+
},
|
|
1120
|
+
waitForReached(label) {
|
|
1121
|
+
const slot = slots.get(label);
|
|
1122
|
+
return slot === undefined ? Promise.resolve(false) : slot.reachedPromise.then(() => true);
|
|
1123
|
+
},
|
|
1124
|
+
hasReached: (label) => slots.get(label)?.reached ?? false,
|
|
1125
|
+
release(label) {
|
|
1126
|
+
const slot = slots.get(label);
|
|
1127
|
+
if (slot === undefined || slot.released)
|
|
1128
|
+
return false;
|
|
1129
|
+
slot.released = true;
|
|
1130
|
+
slot.resolve();
|
|
1131
|
+
return true;
|
|
1132
|
+
},
|
|
1133
|
+
releaseAll() {
|
|
1134
|
+
for (const slot of slots.values()) {
|
|
1135
|
+
if (slot.released)
|
|
1136
|
+
continue;
|
|
1137
|
+
slot.released = true;
|
|
1138
|
+
slot.resolve();
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
// src/agent-executor/testing/replay-scenarios.ts
|
|
1144
|
+
var REPLAY_SCENARIOS = {
|
|
1145
|
+
"text-stream": formatReplayTranscript([
|
|
1146
|
+
{ kind: "emit", block: "status", phase: "initializing" },
|
|
1147
|
+
{ kind: "emit", block: "text", text: "Hello ", itemId: "msg-1" },
|
|
1148
|
+
{ kind: "emit", block: "text", text: "from replay.", itemId: "msg-1" },
|
|
1149
|
+
{ kind: "usage", inputTokens: 12, outputTokens: 4, totalTokens: 16 },
|
|
1150
|
+
{ kind: "emit", block: "turn-end", outcome: "completed", threadDisposition: "reusable" }
|
|
1151
|
+
]),
|
|
1152
|
+
approval: formatReplayTranscript([
|
|
1153
|
+
{
|
|
1154
|
+
kind: "emit",
|
|
1155
|
+
block: "tool-call",
|
|
1156
|
+
callId: "call-1",
|
|
1157
|
+
toolName: "run_shell",
|
|
1158
|
+
input: { command: "ls <workspace>" },
|
|
1159
|
+
itemId: "tc-1"
|
|
1160
|
+
},
|
|
1161
|
+
{
|
|
1162
|
+
kind: "request",
|
|
1163
|
+
interactionId: "req-1",
|
|
1164
|
+
requestKind: "approval",
|
|
1165
|
+
callId: "call-1",
|
|
1166
|
+
toolName: "run_shell",
|
|
1167
|
+
input: { command: "ls <workspace>" }
|
|
1168
|
+
},
|
|
1169
|
+
{ kind: "expectReply", interactionId: "req-1", replyKind: "approve", required: true },
|
|
1170
|
+
{
|
|
1171
|
+
kind: "emit",
|
|
1172
|
+
block: "tool-result",
|
|
1173
|
+
callId: "call-1",
|
|
1174
|
+
toolName: "run_shell",
|
|
1175
|
+
outcome: "success",
|
|
1176
|
+
output: "README.md",
|
|
1177
|
+
itemId: "tr-1"
|
|
1178
|
+
},
|
|
1179
|
+
{ kind: "emit", block: "text", text: "Listed workspace files.", itemId: "msg-1" },
|
|
1180
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1181
|
+
]),
|
|
1182
|
+
"user-input": formatReplayTranscript([
|
|
1183
|
+
{
|
|
1184
|
+
kind: "request",
|
|
1185
|
+
interactionId: "q-1",
|
|
1186
|
+
requestKind: "input",
|
|
1187
|
+
prompt: "Choose deployment environment",
|
|
1188
|
+
input: { options: ["staging", "production"] }
|
|
1189
|
+
},
|
|
1190
|
+
{ kind: "expectReply", interactionId: "q-1", replyKind: "input", required: true },
|
|
1191
|
+
{ kind: "emit", block: "text", text: "Selection applied.", itemId: "msg-1" },
|
|
1192
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1193
|
+
]),
|
|
1194
|
+
"tool-calls": formatReplayTranscript([
|
|
1195
|
+
{ kind: "emit", block: "reasoning", text: "Inspecting workspace file.", itemId: "r-1" },
|
|
1196
|
+
{
|
|
1197
|
+
kind: "emit",
|
|
1198
|
+
block: "tool-call",
|
|
1199
|
+
callId: "c-read",
|
|
1200
|
+
toolName: "read_file",
|
|
1201
|
+
input: { path: "<workspace>/package.json" },
|
|
1202
|
+
itemId: "tc-1"
|
|
1203
|
+
},
|
|
1204
|
+
{
|
|
1205
|
+
kind: "emit",
|
|
1206
|
+
block: "tool-result",
|
|
1207
|
+
callId: "c-read",
|
|
1208
|
+
toolName: "read_file",
|
|
1209
|
+
outcome: "success",
|
|
1210
|
+
output: '{"name":"demo"}',
|
|
1211
|
+
itemId: "tr-1"
|
|
1212
|
+
},
|
|
1213
|
+
{ kind: "contextUsage", usedTokens: 1200, windowTokens: 200000 },
|
|
1214
|
+
{ kind: "emit", block: "text", text: "Package name is demo.", itemId: "msg-1" },
|
|
1215
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1216
|
+
]),
|
|
1217
|
+
"rate-limit": formatReplayTranscript([
|
|
1218
|
+
{
|
|
1219
|
+
kind: "rateLimit",
|
|
1220
|
+
windows: [{ name: "five_hour", usedPercent: 100, windowDurationMins: 300 }]
|
|
1221
|
+
},
|
|
1222
|
+
{
|
|
1223
|
+
kind: "emit",
|
|
1224
|
+
block: "error",
|
|
1225
|
+
errorKind: "rateLimited",
|
|
1226
|
+
message: "Rate limit window exhausted"
|
|
1227
|
+
},
|
|
1228
|
+
{ kind: "emit", block: "turn-end", outcome: "failed" }
|
|
1229
|
+
]),
|
|
1230
|
+
"multi-turn": [
|
|
1231
|
+
formatReplayTranscript([
|
|
1232
|
+
{ kind: "emit", block: "text", text: "First turn done.", itemId: "m-1" },
|
|
1233
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1234
|
+
]),
|
|
1235
|
+
formatReplayTranscript([
|
|
1236
|
+
{ kind: "emit", block: "text", text: "Second turn done.", itemId: "m-2" },
|
|
1237
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1238
|
+
])
|
|
1239
|
+
],
|
|
1240
|
+
"crash-mid-turn": formatReplayTranscript([
|
|
1241
|
+
{ kind: "emit", block: "text", text: "Partial output before crash", itemId: "m-1" },
|
|
1242
|
+
{ kind: "crash", message: "Simulated engine crash mid-turn" }
|
|
1243
|
+
])
|
|
1244
|
+
};
|
|
1245
|
+
function packReplayScenario(steps) {
|
|
1246
|
+
return {
|
|
1247
|
+
steps: steps.map((step) => ({ do: "emit", record: step })),
|
|
1248
|
+
keepTranscript: true
|
|
1249
|
+
};
|
|
1250
|
+
}
|
|
1251
|
+
function unpackReplayScenario(scenario) {
|
|
1252
|
+
const steps = [];
|
|
1253
|
+
for (const step of scenario.steps) {
|
|
1254
|
+
if (step.do === "emit") {
|
|
1255
|
+
steps.push(ExecutorReplayTranscriptSchema.shape.steps.element.parse(step.record));
|
|
1256
|
+
}
|
|
1257
|
+
}
|
|
1258
|
+
return { steps };
|
|
1259
|
+
}
|
|
1260
|
+
function replayDialectScenarios() {
|
|
1261
|
+
return {
|
|
1262
|
+
text: (value) => packReplayScenario([
|
|
1263
|
+
{ kind: "emit", block: "text", text: value, itemId: "msg-1" },
|
|
1264
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1265
|
+
]),
|
|
1266
|
+
approval: () => packReplayScenario([
|
|
1267
|
+
{
|
|
1268
|
+
kind: "emit",
|
|
1269
|
+
block: "tool-call",
|
|
1270
|
+
callId: "c1",
|
|
1271
|
+
toolName: "bash",
|
|
1272
|
+
input: { command: "echo ok" },
|
|
1273
|
+
itemId: "tc-1"
|
|
1274
|
+
},
|
|
1275
|
+
{
|
|
1276
|
+
kind: "request",
|
|
1277
|
+
interactionId: "req-1",
|
|
1278
|
+
requestKind: "approval",
|
|
1279
|
+
callId: "c1",
|
|
1280
|
+
toolName: "bash",
|
|
1281
|
+
input: { command: "echo ok" }
|
|
1282
|
+
},
|
|
1283
|
+
{ kind: "expectReply", interactionId: "req-1", replyKind: "approve" },
|
|
1284
|
+
{
|
|
1285
|
+
kind: "emit",
|
|
1286
|
+
block: "tool-result",
|
|
1287
|
+
callId: "c1",
|
|
1288
|
+
toolName: "bash",
|
|
1289
|
+
outcome: "success",
|
|
1290
|
+
output: "ok",
|
|
1291
|
+
itemId: "tr-1"
|
|
1292
|
+
},
|
|
1293
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1294
|
+
]),
|
|
1295
|
+
failure: (status) => packReplayScenario([
|
|
1296
|
+
{
|
|
1297
|
+
kind: "emit",
|
|
1298
|
+
block: "error",
|
|
1299
|
+
errorKind: status === 401 ? "authRequired" : "rateLimited",
|
|
1300
|
+
message: `HTTP ${status}`
|
|
1301
|
+
},
|
|
1302
|
+
{ kind: "emit", block: "turn-end", outcome: "failed" }
|
|
1303
|
+
]),
|
|
1304
|
+
interruptible: () => packReplayScenario([
|
|
1305
|
+
{ kind: "emit", block: "text", text: "working", itemId: "m1" },
|
|
1306
|
+
{ kind: "waitInterrupt" },
|
|
1307
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1308
|
+
]),
|
|
1309
|
+
interruptDuringApproval: () => packReplayScenario([
|
|
1310
|
+
{
|
|
1311
|
+
kind: "request",
|
|
1312
|
+
interactionId: "req-int",
|
|
1313
|
+
requestKind: "approval",
|
|
1314
|
+
callId: "c-int",
|
|
1315
|
+
toolName: "bash"
|
|
1316
|
+
},
|
|
1317
|
+
{ kind: "waitInterrupt" },
|
|
1318
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1319
|
+
]),
|
|
1320
|
+
requestAfterInterrupt: () => packReplayScenario([
|
|
1321
|
+
{ kind: "emit", block: "text", text: "before", itemId: "m1" },
|
|
1322
|
+
{ kind: "waitInterrupt" },
|
|
1323
|
+
{
|
|
1324
|
+
kind: "request",
|
|
1325
|
+
interactionId: "req-late",
|
|
1326
|
+
requestKind: "approval",
|
|
1327
|
+
callId: "c-late",
|
|
1328
|
+
toolName: "bash"
|
|
1329
|
+
},
|
|
1330
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1331
|
+
]),
|
|
1332
|
+
requestAtTurnEnd: () => packReplayScenario([
|
|
1333
|
+
{
|
|
1334
|
+
kind: "request",
|
|
1335
|
+
interactionId: "req-end",
|
|
1336
|
+
requestKind: "approval",
|
|
1337
|
+
callId: "c-end",
|
|
1338
|
+
toolName: "bash"
|
|
1339
|
+
},
|
|
1340
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1341
|
+
]),
|
|
1342
|
+
requestThenCrash: () => packReplayScenario([
|
|
1343
|
+
{
|
|
1344
|
+
kind: "request",
|
|
1345
|
+
interactionId: "req-crash",
|
|
1346
|
+
requestKind: "approval",
|
|
1347
|
+
callId: "c-crash",
|
|
1348
|
+
toolName: "bash"
|
|
1349
|
+
},
|
|
1350
|
+
{ kind: "crash", message: "engine lost while request pending" }
|
|
1351
|
+
]),
|
|
1352
|
+
eofWithoutResult: () => packReplayScenario([{ kind: "eofWithoutResult" }]),
|
|
1353
|
+
invalidLine: () => packReplayScenario([{ kind: "invalidLine", rawLine: "{broken" }]),
|
|
1354
|
+
unknownRecord: () => packReplayScenario([
|
|
1355
|
+
{ kind: "unknownRecord", recordType: "future_event", message: "Unknown record" },
|
|
1356
|
+
{ kind: "emit", block: "turn-end", outcome: "completed" }
|
|
1357
|
+
]),
|
|
1358
|
+
crash: () => packReplayScenario([{ kind: "crash", message: "boom" }])
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
370
1361
|
export {
|
|
1362
|
+
ExecutorReplayStepSchema,
|
|
1363
|
+
ExecutorReplayTranscriptSchema,
|
|
371
1364
|
FakeEngineScenarioSchema,
|
|
372
1365
|
FakeEngineStepSchema,
|
|
1366
|
+
REPLAY_SCENARIOS,
|
|
1367
|
+
createReplayExecutorDriver,
|
|
1368
|
+
createReplayGate,
|
|
1369
|
+
formatReplayTranscript,
|
|
1370
|
+
parseReplayTranscript,
|
|
1371
|
+
replayDialectScenarios,
|
|
373
1372
|
runAgentEngineConformance,
|
|
374
|
-
runFakeClaudeEngine
|
|
1373
|
+
runFakeClaudeEngine,
|
|
1374
|
+
unpackReplayScenario
|
|
375
1375
|
};
|