import type { StreamDelta } from "../shared/types.js"; /** * Pure protocol helpers for the Antigravity (`agy`) engine — no PTY, no I/O * orchestration, so they're unit-testable in isolation. * * This module serves the interactive PTY adapter. Queued work turns use agy's * stream-JSON print protocol; PTY-native turns still rely on the conversation * transcript written to disk: * ~/.gemini/antigravity-cli/brain//.system_generated/logs/transcript.jsonl * * Each line is a JSON object: { step_index, source, type, status, content }. * - source "USER_EXPLICIT" / type "USER_INPUT" → our prompt * - source "SYSTEM" / type "CONVERSATION_HISTORY" * - source "MODEL" / type "PLANNER_RESPONSE" → assistant turn; * status "DONE" marks turn completion, `content` is the answer. */ /** agy's on-disk state dir (shared with Gemini account dir). */ export declare const ANTIGRAVITY_HOME: string; export declare const ANTIGRAVITY_BRAIN_DIR: string; export declare const ANTIGRAVITY_SETTINGS_PATH: string; export interface StartupBlocker { retryable: boolean; message: string; } /** Identify startup-only TUI responses that reject a submit before a conversation exists. */ export declare function detectStartupBlocker(ptyText: string): StartupBlocker | null; /** Absolute path to a conversation's streaming transcript. */ export declare function transcriptPathFor(convId: string, brainDir?: string): string; /** Absolute path to a conversation's FULL transcript (history + tool calls) — * the closest on-disk proxy for what the model carries as context. */ export declare function fullTranscriptPathFor(convId: string, brainDir?: string): string; /** Estimate context tokens for an agy conversation. agy exposes NO usage data, so * this is an APPROXIMATION: bytes of the full transcript / 4 (the standard rough * chars-per-token ratio). Good enough for a "how full is the window" gauge against * a 1M-token model; not an exact count. Returns 0 if the transcript is unreadable. */ export declare function estimateContextTokens(convId: string, brainDir?: string): number; /** * Per-turn tool-card state threaded through {@link transcriptLineToDeltas}. * * agy opens a tool card two ways: a `tool_calls[]` array on a PLANNER_RESPONSE * row, or (rarely) a standalone tool row with `status:"RUNNING"`. Most often the * only trace of a tool is its terminal `status:"DONE"` row with NO opener at all. * * The web/talk renderers open a card on `tool_use` and merely *mutate the last * card* on `tool_result` — they never create one. So a lone `tool_result` lands * on whatever the previous message was and the tool card is lost. `openCards` * counts the cards opened-but-not-yet-closed so a DONE row can either close an * existing card (no duplicate) or, when none is open, synthesize its own * self-contained `tool_use`+`tool_result` pair (card preserved). */ export interface ToolCardState { openCards: number; } export declare function newToolCardState(): ToolCardState; /** All completed assistant responses (content of MODEL/PLANNER_RESPONSE/DONE rows), in order. */ export declare function extractDoneResponses(transcript: string): string[]; /** * Map one transcript line to StreamDeltas for the parsed (Chat-view) stream. * * Pass a per-turn `state` (see {@link newToolCardState}) so tool cards survive * agy's DONE-only tool rows: planner `tool_calls` and `RUNNING` rows open a card * and bump `openCards`; a DONE/ERROR row closes one if open, else synthesizes its * own `tool_use`+`tool_result` pair. Called statelessly, every DONE/ERROR tool * row is treated as orphaned and synthesizes a full card. */ export declare function transcriptLineToDeltas(line: string, state?: ToolCardState): StreamDelta[]; /** A non-empty planner response with no tool call is agy's strongest turn-final signal. */ export declare function isTerminalAnswerLine(line: string): { terminal: boolean; content?: string; }; /** * Pre-seed agy's workspace trust so a headless PTY spawn in `workspacePath` * doesn't block on the interactive "do you trust this folder?" prompt. * agy stores trust as realpath'd entries in settings.json → trustedWorkspaces. * Idempotent; tolerant of a missing or malformed existing file. */ export declare function ensureWorkspaceTrusted(workspacePath: string, settingsPath?: string): void; /** Snapshot of existing conversation directory names under brain/ (for new-conv detection). */ export declare function listConvDirs(brainDir?: string): Set; //# sourceMappingURL=antigravity-protocol.d.ts.map