import { type SQL, type SQLWrapper } from "drizzle-orm"; /** Attention is conversational output or an actionable boundary, not activity. * Keep this allow-list shared by rail, tree and consumption queries. */ export declare const MEANINGFUL_SESSION_EVENT_TYPES: readonly ["agent.message.completed", "turn.completed", "turn.failed", "session.requiresAction", "session.humanInput.requested", "tool.auth_needed", "credential.auth_needed", "goal.completed", "goal.paused", "goal.progress", "goal.rewrite.proposed", "rig.setup.failed", "sandbox.operation.failed", "sandbox.box.lost", "workspace.revision.degraded", "machine.op.failed", "machine.link.lost", "session.event.envelope_omitted"]; /** * Events that never count as session activity by themselves: raw stream * deltas, and infrastructure diagnostics such as the idle reaper's * `sandbox.box.terminated` fan-out to every session sharing a drained box. A * statement whose events are all of these advances the durable cursor and * `last_sequence`, but neither `updated_at` (the rail's "last activity" time) * nor `activity_xid` (rail order and incremental discovery). Any other event * in the same statement keeps the ordinary activity projection. Attention * events (`sandbox.box.lost`, `machine.link.lost`, ...) are deliberately * absent: something a person must act on is activity. * * Migration 0904 holds the same literal list in the event cursor trigger; * a change here needs a new migration. */ export declare const SESSION_ACTIVITY_NEUTRAL_EVENT_TYPES: readonly ["agent.message.delta", "agent.reasoning.delta", "sandbox.command.output.delta", "terminal.pty.output.delta", "sandbox.box.created", "sandbox.box.terminated", "sandbox.box.snapshot", "sandbox.env.drift", "session.route.reconciled", "workspace.revision.captured", "machine.op.recovered", "machine.link.restored", "machine.runner.restarted"]; /** * Completed commentary is progress narrating the work, not an answer, so it * never creates attention on its own; the answer or turn outcome that follows * does. A turn that ends waiting for input has no output, but when a human or * API message started it, the `reply` it records is that answer. Exactly the * migration 0774 partial-index predicate, which also counts a task usage limit * stop as an actionable boundary. * * Since migration 1289 an answer that is exactly the no-reply token is not * attention either (`noReplyAnswerExcludedSql`): it is nothing for the person * and no timeline draws it. That exclusion is a filter on top of the 0774 * index predicate, so queries keep using that index. */ export declare function meaningfulSessionEventSql(alias: string): SQL; /** * Exactly the migration 0774 partial-index predicate * (`session_events_meaningful_attention_v3_idx`). Attention queries use * `meaningfulSessionEventSql`, which implies it. */ export declare function meaningfulAttentionIndexPredicateSql(alias: string): SQL; /** * The no-reply token test, as SQL over a text expression: the same * normalization as `isNoReplyText` in `@opengeni/contracts/no-reply` and * migration 1289's `opengeni_private.no_reply_text_v1`. Code-owned literals, * so the predicate needs no runtime routine or parameter. */ export declare function noReplyTextSql(text: SQL): SQL; /** * An agent message, or a turn's output, that is the no-reply token is not an * answer for the person: migration 1289's cursor trigger does not count it as * attention, so a quiet run sets no unread mark. A turn that recorded a * `reply` keeps it. */ export declare function noReplyAnswerExcludedSql(alias: string): SQL; /** * The migration 0527 index predicate (no usage-limit stops). Pre-0774 API * processes still probe with it during a rolling deploy; nothing current * queries it. */ export declare function commentaryExclusiveMeaningfulSessionEventSql(alias: string): SQL; /** * The migration 0503 index predicate. Older API processes still probe with it * during a rolling deploy; nothing current queries it. */ export declare function commentaryInclusiveMeaningfulSessionEventSql(alias: string): SQL; /** A stored audit preview can still need attention, but cannot stand in for * consumption of the original content, even when the reader returned it whole. * This is about what a reader received, so an answer that is the no-reply * token is still content a parent agent can have read. */ export declare function completeMeaningfulSessionEventSql(alias: string): SQL; /** One reverse partial-index probe, independent of the raw-delta tail length. * Derivation also repairs historical bookkeeping-only dots without changing * personal state or rewriting append-only events. */ export declare function meaningfulSessionSequenceSql(workspaceId: SQLWrapper, sessionId: SQLWrapper): SQL; /** The child's newest ordinary turn outcomes, newest first. Only a * result-bearing `turn.completed` here is the child's current answer: an older * answer behind a newer failed, cancelled, superseded, or segment-limited turn * is never reported as the result. A segment-limit completion (`max_turns`, * `budget_exhausted`) is the outcome of the turn that stopped there, and its * empty output means "no answer". Only standalone maintenance is not an * outcome. * * `goalContinuationOnly` marks a turn claimed only to continue the child's * goal: a goal-routed turn to which no other input (a message, a Steer, a * child or command result) was ever delivered. Such a turn follows an answer * rather than producing the task's result, so the caller walks back past it. * Each outcome probe walks the (workspace, session, type, sequence) index * backwards within `limit`, and only the selected rows' payloads are read. * The child's delivered input is scanned once for all selected turns. * * `goalActivatedAt` is the newest `goal.set` or `goal.resumed` event: goal * continuation turns never run across an idle boundary that reported the goal * inactive, so a continuation walk stops there instead of reaching output a * result for an earlier run already reported. */ export declare function childRecentTurnOutcomesSql(workspaceId: SQLWrapper, sessionId: SQLWrapper, limit: number): SQL; /** Bound indexed candidate rows BEFORE testing payload size/completeness. Without * this boundary, a long run of oversized answers can cause an unbounded scan. */ export declare function childLifecycleEvidenceCandidatesSql(workspaceId: SQLWrapper, sessionId: SQLWrapper): SQL;