/** * The subset of opencode's plugin event / message / part wire format we consume. * * ⚠️ VALIDATION SEAM. These shapes are the typed boundary between opencode's * (undocumented, version-sensitive) payloads and the rest of the collector. * They were written against opencode's documented plugin API + SDK message model * (message.updated carries `tokens`/`modelID`/`providerID`; message.part.updated * carries text/reasoning/tool parts). Every field is optional and read * defensively so a schema drift degrades a span rather than throwing into * opencode. Before trusting the output, capture a real session's events * (`opencode` with WEAVE_OPENCODE_DEBUG=1, or dump the `event` payloads) and * reconcile the names here. All the naming risk is contained in THIS file plus * reconstruct.ts — the emit half downstream is provider-agnostic. */ /** An opencode plugin event: `{ type, properties }` on the event bus. */ export interface OcEvent { type: string; properties?: Record; } /** Event type discriminators we react to. */ export declare const EVENT: { readonly MESSAGE_UPDATED: "message.updated"; readonly MESSAGE_PART_UPDATED: "message.part.updated"; readonly MESSAGE_REMOVED: "message.removed"; readonly SESSION_IDLE: "session.idle"; readonly SESSION_UPDATED: "session.updated"; readonly SESSION_ERROR: "session.error"; }; /** opencode token accounting on an assistant message. */ export interface OcTokens { input?: number; output?: number; reasoning?: number; cache?: { read?: number; write?: number; }; } /** A message (user or assistant) as delivered by `message.updated`. */ export interface OcMessage { id: string; sessionID: string; role: 'user' | 'assistant' | string; time?: { created?: number; completed?: number; }; providerID?: string; modelID?: string; cost?: number; tokens?: OcTokens; path?: { cwd?: string; root?: string; }; } /** A tool part's execution state (status, io, timing). */ export interface OcToolState { status?: string; input?: unknown; output?: unknown; error?: string; title?: string; metadata?: Record; time?: { start?: number; end?: number; }; } /** A part delivered by `message.part.updated`. Union discriminated on `type`. */ export interface OcPart { id: string; messageID: string; sessionID: string; type: string; text?: string; callID?: string; tool?: string; state?: OcToolState; time?: { start?: number; end?: number; }; } /** Part `type` discriminators. */ export declare const PART: { readonly TEXT: "text"; readonly REASONING: "reasoning"; readonly TOOL: "tool"; };