Something went wrong. Try again.
fork of prime agent with changes i want but are not upstreamable probqbly (and some fixes)
Something went wrong. Try again.
988 B · 25 lines
TypeScript
at main
1234567891011121314151617181920212223242526import { type LogEntry, setLogSink, stringifyLogEntry } from "@earendil-works/pi-ai";import { appendRotatingLog, getAgentLogPath } from "../config.js";
const AGENT_LOG_MAX_BYTES = 20 * 1024 * 1024;
let context: Record<string, unknown> = {};
/** Merge late-bound fields (e.g. mode, sessionId) into every subsequent log entry. */export function setLogContext(fields: Record<string, unknown>): void { Object.assign(context, fields);}
export function writeFileLogEntry(entry: LogEntry): void { appendRotatingLog(getAgentLogPath(), stringifyLogEntry({ ...entry, ...context }), AGENT_LOG_MAX_BYTES);}
/** * Route all structured logging (coding-agent and pi-ai) to the shared JSONL * log at ~/.prime/agent/logs/agent.jsonl. One master file, filterable by the * pid/context fields; writes are best-effort and size-bounded. */export function installFileLogSink(fields?: Record<string, unknown>): void { context = { pid: process.pid, ...fields }; setLogSink(writeFileLogEntry);}