/** * SituationReporter - the OUTPUT leg of the trigger loop (M2), superseding TriggerReporter (M1.5). * * Accumulates a BOUNDED window of drained events (per-channel counts + last-K excerpts), plus * fire/author activity and the memory those fires recalled (agent-authored memoryQuery drove the * recall - trigger-fire.ts:33-34). On a report cadence the AGENT composes an owner situation * report from the AGGREGATE (agent-first: the agent judges content and may reply NOTHING to * suppress); the system only windows/schedules/sends. * * Two framings share one accumulator + send machinery: * - 'digest': the short periodic update (the M1.5 fire digest, now window-aware). * - 'full' : the fuller scheduled report covering the whole window since the last full report. * * No activity -> no agent call, no send (no spam). Send failure propagates loudly (no-fallback) * and keeps the buffer so the next cadence retries. English default; the agent is told to answer * in the owner's language if inferable. NO personal strings in this source. */ import type { OperatorChannelEvent, OutputSink } from './operator-interfaces.js'; import type { AskAgent } from './trigger-author.js'; import type { BackendType } from '../agent/model-runner.js'; import { type ArtifactProvenance, type ReportCarryTarget } from './report-carry.js'; /** * Machine frame tag prepended to the FULL report prompt so the report-run wiring can tell a full * report from a digest for tool-use auditing (report-run.ts). The bracketed tag keeps framing * source-neutral while remaining machine-readable. */ export declare const OPERATOR_FULL_REPORT_TAG = "[operator_full_report]"; export interface FireActivity { triggerId: string; kind: string; channelId: string; recalled: { topic: string; content: string; }[]; } export type ReportMode = 'digest' | 'full'; export interface PreparedSituationReport { mode: ReportMode; text: string; citedTriggerIds: string[]; createdAtIso: string; deliveryId?: string; provenance?: ArtifactProvenance; target?: ReportCarryTarget; payloadIdentity?: string; occurrence?: { kind: 'digest' | 'scheduled_full' | 'on_demand_full'; hourKey?: string; firedAtIso?: string; }; } export interface DeliveredFullReport { mode: 'full'; deliveryId: string; citedTriggerIds: string[]; createdAtIso: string; deliveredAtIso: string; text: string; provenance: ArtifactProvenance; target?: ReportCarryTarget; payloadIdentity?: string; occurrence?: PreparedSituationReport['occurrence']; } export interface SituationReporterSnapshot { version: 1; channels: Array<{ channelId: string; count: number; excerpts: string[]; }>; windowTotal: number; fires: Array<{ triggerId: string; kind: string; channelId: string; count: number; topics: string[]; }>; authored: number; recalled: Array<{ topic: string; content: string; }>; eventKeys?: string[]; } export interface SituationReporterOptions { /** Model provider controls only the tool-call syntax; report workflow/content stays shared. */ backend?: BackendType; /** * M2.3: tool-call instructions injected into the FULL report framing so the agent * ACTIVELY gathers current context (channels, tasks, memory) before writing - the * lesson from the reference owner console: report prompts instruct the agent to call tools * instead of relying on a low-quality deterministic report builder. The lines * are injected from the runtime wiring (which knows the daemon's toolset); this * module stays generic. Digest mode never uses them (frequent + must stay light). * * A zero-arg provider is resolved at fire time (buildPrompt runs per report), * so runtime wiring can inject freshly anchored gather lines (e.g. a delta * `since=`) without rebuilding the reporter. */ selfGatherLines?: string[] | (() => string[]); /** * Dual-output mechanism: lines instructing the FULL report run to also * publish the operator board slots (report_publish) before writing the text * report. Injected from runtime wiring (board-slot-instructions.ts); digest mode * never publishes the board. */ boardPublishLines?: string[]; /** * G2 success signal: called with the trigger ids the agent says it actually * drew on for the sent report (parsed from the stripped USED_TRIGGERS * trailer, validated against this window's fires). The wiring records * 'succeeded' outcomes so evolution finally gets a positive signal instead * of being elimination-only. Uncited fires stay NEUTRAL - not failures. */ recordTriggerUse?: (triggerIds: string[]) => void; /** Reads the provenance of the run that just composed a FULL report. */ fullReportProvenance?: () => ArtifactProvenance; /** Called only after a FULL report has definitely been delivered. */ persistLastFullReport?: (report: DeliveredFullReport) => void; } export declare class SituationReporter { private windowByChannel; private windowTotal; private fireAgg; private authored; private recalled; private eventKeys; private opts; constructor(opts?: SituationReporterOptions); /** Fold a batch of drained events into the bounded per-channel window. */ recordWindow(events: OperatorChannelEvent[]): void; hasRecordedEvent(event: OperatorChannelEvent): boolean; private eventKey; private legacyEventKey; /** Fold one fire into the aggregate; merge the memory it recalled (agent-query-driven). */ recordFire(activity: FireActivity): void; recordAuthored(count: number): void; /** Any window events, fires, or authored triggers accumulated since the last reset. */ hasActivity(): boolean; snapshot(): SituationReporterSnapshot; restore(snapshot: SituationReporterSnapshot): void; /** * Agent composes the report from the aggregate; sink delivers it. Returns true if a report was * sent, false if there was nothing to say or the agent suppressed it (NOTHING). */ prepareReport(askAgent: AskAgent, mode: ReportMode, deliveryId?: string): Promise; deliverPrepared(prepared: PreparedSituationReport, output: Pick): Promise; /** * TG-06: called by the report delivery boundary (ReportDeliveryPort) exactly * once per DELIVERED report. Credits the cited triggers and resets the * accumulation window. Retry/rejection/cancellation outcomes must NOT call * this - an undelivered report keeps its window and earns no credit. */ markDeliveredOutcome(citedTriggerIds: readonly string[]): void; report(askAgent: AskAgent, output: Pick, mode: ReportMode): Promise; private reset; /** Public for testability. Aggregate window + fire activity + recalled memory -> agent prompt. */ buildPrompt(mode: ReportMode): string; } //# sourceMappingURL=situation-report.d.ts.map