UNPKG

agentfootprint

Version:

The explainable agent framework — backtrack a wrong answer to the exact context that caused it (evidence, not guesses). Built on footprintjs.

69 lines • 3.13 kB
/** * transcript — the conversation, read back out of the event stream. * * A maintainer opening a bug report reads the conversation first: what was * asked, what the model said, which tools ran, what came back. All of that is * already in the typed events — `agent.turn_start` carries the prompt, * `stream.llm_end` the model's content, `stream.tool_start` / `tool_end` the * call and its result, `agent.turn_end` the final answer — so `conversation.json` * is DERIVED, never a second copy the reporter has to keep in sync. * * ## Derivable, and when it is not * * Turn markers come from the Agent loop. A bare `LLMCall`, a `Sequence` of * them, a pattern — none of those fire `turn_start`, so the walk falls back to * ONE synthetic turn holding the model and tool steps in order, and says so on * the turn (`derived: 'no-turn-markers'`). A recording with no LLM and no tool * events yields no transcript at all, and the manifest carries a note rather * than an empty file that reads like an empty conversation. * * ## What it does NOT do * * It does not summarize, truncate or scrub. Whatever the events carry is what * this writes — including tool arguments and results. Redaction is upstream: * under an agent's `redact` every event was served before it was recorded (a * selected key at any depth is the placeholder), and the manifest lists the * keys that were scrubbed so the reporter can see it happened. The policy * selects by name, never by content — free text under a name it does not * select (a user's sentence, a model's answer) is written as it was. */ /** One model or tool step inside a turn. */ export type TranscriptStep = { readonly kind: 'assistant'; readonly content: string; readonly stopReason?: string; readonly toolCallCount?: number; } | { readonly kind: 'tool'; readonly name: string; readonly toolCallId?: string; readonly args?: unknown; readonly result?: unknown; readonly error?: boolean; /** 9.113.0 — the bracket's own field, copied as the event carries it: * a call a paused batch never dispatched. Its `result` is then the * library's sentence, and it carries no `error`: the call neither * succeeded nor failed. Absent on every other step. */ readonly notDispatched?: unknown; }; /** One turn: what the user asked, what happened, what came back. */ export interface TranscriptTurn { readonly index: number; readonly user?: string; readonly steps: readonly TranscriptStep[]; readonly final?: string; /** Present when there were no turn markers and this turn was inferred. */ readonly derived?: 'no-turn-markers'; } /** One conversation's readable transcript. */ export interface Transcript { readonly turns: readonly TranscriptTurn[]; } /** * Walk one conversation's events into turns. * * @returns the transcript, or `undefined` when nothing conversational * happened — which the manifest reports as a note. */ export declare function deriveTranscript(events: readonly unknown[]): Transcript | undefined; //# sourceMappingURL=transcript.d.ts.map