/** * Autonomy telemetry sink + status/diagnostic snapshots. * * Extracted verbatim from agent-session.ts (god-file decomposition). Owns the latest gate outcome * and the bounded gate-outcome history, and is the single sink for G3 autonomy-telemetry custom * entries. The two snapshot builders READ broadly across live session state (router decision, cost, * goal, lanes, and the research/delegation/learning/goal getters) through narrow deps accessors * rather than the whole AgentSession — they never mutate anything but the owned gate-outcome fields. */ import type { SessionManager } from "@caupulican/pi-agent-core/node"; import type { EvidenceBundle, GateOutcome, LearningDecision, WorkerClaim } from "./autonomy/contracts.ts"; import type { AutonomyDiagnosticSnapshot, AutonomyStatusSnapshot, GateOutcomeHistoryEntry } from "./autonomy/status.ts"; import { type AutonomyTelemetryEvent } from "./autonomy/telemetry-events.ts"; import { type SessionCostSummary } from "./cost/cost-summary.ts"; import type { GoalState } from "./goals/goal-state.ts"; import type { LearningAuditRecord } from "./learning/learning-audit.ts"; import { type ModelRouterDecisionStatus } from "./model-router/status.ts"; export interface AutonomyTelemetryDeps { /** Session log: `appendCustomEntry` is the telemetry sink; `getEntries` feeds diagnostic aggregation. */ getSessionManager(): Pick; /** Latest model-router decision, for the snapshot's `latestRoute` — owned by the router, not this sink. */ getLastModelRouterDecision(): ModelRouterDecisionStatus | undefined; /** Reason the last research lane was skipped, if any — surfaced in the diagnostic's research family. */ getLastResearchLaneSkipReason(): string | undefined; /** Single source of truth for CURRENT/TODAY/SUBAGENTS display costs. */ getCostSummary(): SessionCostSummary; /** Current goal state, if a goal is active. */ getGoalStateSnapshot(): GoalState | undefined; /** Live count of active lanes from the lane tracker — never inferred from historical snapshots. */ getActiveLaneCount(): number; /** Research evidence bundles across the complete session tree, including sibling branches. */ getSessionEvidenceBundleHistory(): EvidenceBundle[]; /** Worker-delegation claims across the complete session tree, including sibling branches. */ getSessionWorkerClaimHistory(): WorkerClaim[]; /** Learning decisions across the complete session tree, including sibling branches. */ getSessionLearningDecisionHistory(): LearningDecision[]; /** Learning audit records recorded this session. */ getLearningAuditRecords(): LearningAuditRecord[]; } export declare class AutonomyTelemetry { private _lastAutonomyGateOutcome?; /** G8: bounded (cap {@link GATE_OUTCOME_HISTORY_LIMIT}) history of gate outcomes; tail is latest. */ private readonly _gateOutcomeHistory; private readonly deps; constructor(deps: AutonomyTelemetryDeps); /** * G3: bounded autonomy-telemetry sink. Passes the whole event through {@link redactTelemetryValue} * (the taxonomy's redaction contract) before storing it, so a secret that leaked into a payload * field never lands in the session log. Observe-only: a failure here can never surface into the * turn it is measuring, so the whole body is swallowed. Payloads MUST stay small (ids, codes, * numbers) — never prompt/summary text; callers own that discipline. */ emitTelemetry(event: AutonomyTelemetryEvent): void; /** * G8: single sink for a gate outcome. Keeps the latest-outcome getter behavior identical (the * full {@link GateOutcome} still lands in `_lastAutonomyGateOutcome`), and additionally appends a * bounded codes-only entry to {@link _gateOutcomeHistory} (oldest evicted at * {@link GATE_OUTCOME_HISTORY_LIMIT}) and emits the `gate_outcome` telemetry event. The history * tail therefore always mirrors the latest outcome. Only called with an active envelope. */ recordGateOutcome(outcome: GateOutcome): void; /** G8: copies of the bounded gate-outcome history, oldest first, latest last. */ getGateOutcomeHistory(): GateOutcomeHistoryEntry[]; getStatusSnapshot(): AutonomyStatusSnapshot; /** * Aggregate an effectiveness/autonomy dashboard: what Pi has actually been doing (recent * route choices, latest gate outcome, cost, and any research/delegation/learning/goal * activity). Read-only — combines existing session-log getters, never mutates state or * recomputes a route/gate decision. */ getDiagnosticSnapshot(options?: { maxEntriesPerFamily?: number; }): AutonomyDiagnosticSnapshot; } //# sourceMappingURL=autonomy-telemetry.d.ts.map