Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@
"record:codex-replay": "bun scripts/record-codex-app-server-replay-fixture.ts",
"record:claude-replay": "bun scripts/record-claude-agent-sdk-replay-fixture.ts",
"record:cursor-replay": "node --env-file-if-exists=../../.env --experimental-strip-types scripts/record-cursor-agent-sdk-replay-fixture.ts",
"record:pi-replay": "node scripts/record-pi-rpc-replay-fixture.ts"
"record:pi-replay": "node scripts/record-pi-rpc-replay-fixture.ts",
"record:grok-replay": "node scripts/record-grok-acp-replay-fixture.ts"
},
"dependencies": {
"@anthropic-ai/claude-agent-sdk": "^0.3.276",
Expand Down
21 changes: 18 additions & 3 deletions apps/server/scripts/acp-replay-agent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,17 +35,20 @@ interface JsonRpcMessage {
}

const encodedTranscript = process.env.T3_ACP_REPLAY_TRANSCRIPT;
const transcriptPath = process.env.T3_ACP_REPLAY_TRANSCRIPT_PATH;
const statusPath = process.env.T3_ACP_REPLAY_STATUS_PATH;
const replayWorkspace = process.env.T3_ACP_REPLAY_WORKSPACE ?? process.cwd();

if (encodedTranscript === undefined || statusPath === undefined) {
if ((encodedTranscript === undefined && transcriptPath === undefined) || statusPath === undefined) {
process.stderr.write("ACP replay requires transcript and status environment variables.\n");
process.exit(2);
}

const replayStatusPath = statusPath;
const transcript = JSON.parse(
Buffer.from(encodedTranscript, "base64").toString("utf8"),
transcriptPath === undefined
? Buffer.from(encodedTranscript ?? "", "base64").toString("utf8")
: NodeFS.readFileSync(transcriptPath, "utf8"),
) as ReplayTranscript;
let cursor = 0;
let stopped = false;
Expand Down Expand Up @@ -170,7 +173,19 @@ function logicalIncoming(message: JsonRpcMessage): LogicalFrame | undefined {
};
}

function emitInbound(frame: LogicalFrame): void {
// Recorded agent frames name workspace paths (tool inputs, fs requests) as
// <workspace>; point them at this replay's workspace like expectations do.
function materializeInbound(value: unknown): unknown {
if (typeof value === "string") return expandExpectedString(value);
if (Array.isArray(value)) return value.map(materializeInbound);
if (typeof value !== "object" || value === null) return value;
return Object.fromEntries(
Object.entries(value).map(([key, entry]) => [key, materializeInbound(entry)]),
);
}

function emitInbound(recorded: LogicalFrame): void {
const frame = materializeInbound(recorded) as LogicalFrame;
switch (frame.kind) {
case "notification":
send({
Expand Down
Loading
Loading