Record-count offset arithmetic for the inline (fileless) path, mirroring the
byte-offset semantics of read_new_transcript_lines: returns
(send_offset, next_offset) where send_offset is stamped on the request as
transcript_offset (base for the server’s per-line chunk_index) and
next_offset is persisted to .stream_offset.
Derive the event-level tool-error flag from inline transcript records.
OpenCode tool events carry no tool_use_id, so extract_is_error_from_transcript
can’t run; instead the plugin forwards a toolResult record whose isError
signals the outcome. Returns Some(true|false) for the first toolResult
record found, or None when there is none (non-tool events).
Returns (lines, start_offset, end_offset): start_offset is the seek
position read from offset_path (0 if absent), and end_offset is the
byte offset after the last line read (the old bytes_read).
Fileless agents (OpenCode) have no transcript for tracevault check to
count tool calls from: their records ride inline on each hook event. Append
one slim toolCall record per tool called in records to the session’s
tool_calls.jsonl and record that file as the session’s transcript. Only
the tool name is kept — arguments and outputs (file contents, bash stdout)
would grow the file for nothing. Records with no tool call write nothing.
Store transcript_path in the session’s metadata.json, which is where
tracevault check looks for the transcript it counts tool calls from.
Without it every session reports no tool calls, and a “must call X” policy
can never pass. Other keys in the file are kept. An empty path (Codex
before its first record) writes nothing, and an unchanged path skips the
write. The file is replaced atomically: parallel tool hooks of one session
run concurrently, and check must never read a half-written file.
Choose the transcript source for a stream event. Inline records (from a
plugin-based agent like OpenCode) win over the file-read result whenever the
hook event carries them — INCLUDING an empty vec, so an event with no new
records (e.g. OpenCode stop) preserves the prior record-count offset
instead of resetting it to the file-path’s 0.
Split a hook event whose transcript batch does not fit in one request
(MAX_REQUEST_BYTES) into several requests, so no line is dropped. A
request that fits is returned unchanged as the only part.
A lines-only Transcript request with req’s session, agent and context
fields but none of its event (type, tool payload, event_uuid), which the
server handles as transcript lines only. req’s lines are not copied.
Every field is listed, so a new one has to be decided on here.