@promptbook/utils
Version:
Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action
63 lines (62 loc) • 2.25 kB
TypeScript
/**
* One string-keyed payload of a coding-harness tool invocation.
*
* @private internal type of agent-message runtime logs
*/
type RuntimeLogToolInput = Record<string, unknown>;
/**
* One content block of a Claude Code `stream-json` assistant event.
*
* @private internal type of agent-message runtime logs
*/
export type AgentMessageRuntimeLogContentBlock = {
readonly type?: string;
readonly text?: string;
readonly name?: string;
readonly input?: RuntimeLogToolInput;
};
/**
* One file path touched by a Codex `file_change` item.
*
* @private internal type of agent-message runtime logs
*/
export type AgentMessageRuntimeLogFileChange = {
readonly path?: string;
};
/**
* Minimal shape of one coding-harness runtime log event.
*
* The runtime log mixes two harness formats — Claude Code `stream-json` (`type`/`message`) and
* Codex JSONL (`type`/`item`) — so both are described by one permissive structure and every
* consumer reads only the fields it understands.
*
* @private internal type of agent-message runtime logs
*/
export type AgentMessageRuntimeLogEvent = {
readonly type?: string;
readonly message?: {
readonly content?: ReadonlyArray<AgentMessageRuntimeLogContentBlock>;
};
readonly item?: {
readonly type?: string;
readonly command?: string;
readonly exit_code?: number | null;
readonly changes?: ReadonlyArray<AgentMessageRuntimeLogFileChange>;
readonly server?: string;
readonly tool?: string;
readonly query?: string;
};
};
/**
* Parses every structured event out of one coding-harness runtime log.
*
* The local agent runner streams the answering harness output into a live runtime log file, one
* JSON event per line, optionally prefixed by shell noise. Lines without a usable JSON object are
* skipped so a partially written or interleaved log never breaks its consumers.
*
* @param logText - Raw runtime log content.
* @returns Structured events in the order they were streamed.
* @private internal utility of the agent-message runtime
*/
export declare function parseAgentMessageRuntimeLogEvents(logText: string | null | undefined): ReadonlyArray<AgentMessageRuntimeLogEvent>;
export {};