Skip to content

CodexReplay

A CodexAppServer that replays a recorded session with no process.

CodexAgent.layer().pipe(Layer.provide(CodexReplay.layer(jsonlText)))

A recording is what CodexAppServer.layer({ record }) writes: one JSON object per line, {"dir":"out","msg":...} for client->server frames and {"dir":"in","msg":...} for server->client frames. A line {"dir":"exit","exitCode":null,"signal":"SIGKILL"} simulates app-server dying at that point.

Each client request is matched to the next recorded out request with the same method; the recorded in frames after it are then delivered, up to the next recorded out request. Response ids are rewritten to the client’s request ids, and recorded clientUserMessageIds to the client’s.

Since v0.1.0

One line of a recording.

Signature

type Frame =
| { readonly dir: "out" | "in"; readonly msg: P.Message }
| {
readonly dir: "exit"
readonly exitCode: number | null
readonly signal: string | null
}

Source

Since v0.1.0

recording is JSONL text (as written by record) or parsed frames.

Signature

declare const layer: (
recording: string | ReadonlyArray<Frame>,
) => Layer.Layer<CodexAppServer>

Source

Since v0.1.0

Parses JSONL recording text into frames. Throws on a line that isn’t one.

Signature

declare const parseRecording: (jsonl: string) => ReadonlyArray<Frame>

Source

Since v0.1.0