/** * Hivemind tmux feature — shared types. * * The TypeScript types previously scattered across `fork-bridge.ts` and * re-imported from there by the `tmux-copilot` tool now live here as the * authoritative in-tree contract. All three new class modules * (`tmux-multiplexer.ts`, `session-manager.ts`, `grid-planner.ts`) import * from this file, and the `tmux-copilot` tool imports from here directly. * * Migration history: * - P51-2026-06-02: Replaces fork-bridge.ts as the canonical type home. * `ForkSessionManager`/`ForkSessionManagerAdapter` are renamed to * `SessionManagerAdapter` (and an `EnrichedSessionEvent` alias is added) * because the adapter is no longer a "fork" adapter — it is the real * in-tree SessionManager + TmuxMultiplexer bundle. * * ORIGIN: opencode-tmux/src/grid-planner.ts:23-33 (PaneTreeNode / * SplitDirection / SplitCommand) — PaneTreeNode, SplitDirection, * SplitCommand carried forward as structural types (fork-bridge.ts:34-50). * No code change vs. fork: the public surface of the planner is purely * data shapes that serialize through the IPC boundary, so the in-tree * definitions MUST be byte-identical to the fork for round-trip * compatibility with any persisted snapshots. * * ORIGIN: opencode-tmux/src/tmux.ts:13-20 (PaneState) — Mirrored from fork; * the field set is the on-the-wire contract for the `tmux list-panes` * format string #{pane_id}\t#{pane_title}\t#{pane_active}\t#{pane_width}x#{pane_height}. */ import type { EnrichedSessionEvent } from "./observers.js"; /** * A node in a logical pane tree. Recursive — a node has an optional * `children` array of the same shape. * * ORIGIN: opencode-tmux/src/grid-planner.ts:23-26 */ export interface PaneTreeNode { id: string; children?: PaneTreeNode[]; } /** * Direction of a tmux `split-window` command. * - "h" → horizontal split (top/bottom layout, used for depth-1 children) * - "v" → vertical split (left/right layout, used for depth-2+ children) * * ORIGIN: opencode-tmux/src/grid-planner.ts:28 */ export type SplitDirection = "h" | "v"; /** * One `split-window` instruction emitted by the planner. `parentPaneId` * is the tmux pane id that must exist BEFORE the split is executed * (parents must be created in DFS preorder before their children). * * ORIGIN: opencode-tmux/src/grid-planner.ts:30-33 */ export interface SplitCommand { parentPaneId: string; direction: SplitDirection; } /** * Parsed pane state from one line of `tmux list-panes` output. The * `isMain` flag is computed client-side from a `mainPaneId` argument — * tmux itself does not flag the main pane. * * ORIGIN: opencode-tmux/src/tmux.ts:13-20 */ export interface PaneState { paneId: string; title: string; isActive: boolean; width: number; height: number; isMain: boolean; } /** * Public consumer-facing surface of the planner. The only method the * `tmux-copilot` tool needs is `computeSplitSequence`. The `requestLayout` * (debounced) and `cancel` (debounce-clear) methods are part of the * in-tree class implementation but are intentionally NOT exposed on the * public adapter contract — they are not called from outside the planner * itself. * * ORIGIN: opencode-tmux/src/grid-planner.ts:35-113 (full class surface); * this is the public narrow view. */ export interface PaneGridPlanner { computeSplitSequence: (root: PaneTreeNode) => SplitCommand[]; } /** * Internal full surface of the planner. Exported for documentation and * for any future in-tree replacement class that needs to implement the * wider interface. Not returned by the adapter contract — see * {@link PaneGridPlanner} for the public consumer view. */ export interface PaneGridPlannerInternal extends PaneGridPlanner { requestLayout: (root: PaneTreeNode, onComputed: (commands: SplitCommand[]) => void) => void; cancel: () => void; } /** * Aliased re-export of the enriched session.created event. Consumers * (e.g. `tmux-copilot` tool, the Hivemind event observer) import * `EnrichedSessionEvent` from this module instead of reaching into * `./observers.js` directly — keeps all tmux-feature types under one * namespace. */ export type { EnrichedSessionEvent }; /** * Adapter shape returned by `createTmuxIntegrationIfSupported` in the * rewritten `integration.ts`. Bundles the public method surface of the * in-tree `SessionManager` + `TmuxMultiplexer` + a planner factory, so * the `tmux-copilot` tool has a single injection point. * * Replaces the previous `ForkSessionManagerAdapter` from * `fork-bridge.ts:115-119`. The method set is identical (sendKeys, * listPanes, createPaneGridPlanner, respawnIfKnown, onSessionCreated, * getMainPaneId) — only the type name changes, because the source is * no longer a fork package; it is the real in-tree implementation. * * The signatures here are the authoritative contract — they MUST match * the in-tree class methods exactly: * - `SessionManager.onSessionCreated` / `respawnIfKnown` (session-manager.ts) * - `TmuxMultiplexer.getMainPaneId` / `sendKeys` / `listPanes` (tmux-multiplexer.ts) * - `new PaneGridPlanner(debounceMs?)` constructor * * P58.8 (S1, REQ-58-07) extension: `getLatestCapture` and `startPolling` * are added to the adapter so the `tmux-copilot peek` action (S2, user * tier) and any other future tool can read the most recent capture-pane * content without re-running the tmux CLI. */ export interface SessionManagerAdapter { onSessionCreated: (event: EnrichedSessionEvent) => Promise; respawnIfKnown: (sessionId: string) => Promise<{ paneId: string; } | null>; /** P58.8 S1: read the most recent capture-pane record for a pane id. */ getLatestCapture?: (paneId: string) => { content: string; capturedAt: number; byteLength: number; } | null; /** P58.8 S1: ensure the 5s capture-pane polling loop is running. */ startPolling?: (intervalMs?: number) => void; getMainPaneId: () => Promise; sendKeys: (paneId: string, text: string, literal?: boolean) => Promise; listPanes: (mainPaneId?: string) => Promise; createPaneGridPlanner: (debounceMs?: number) => PaneGridPlanner; onPaneCaptured: (event: import("./observers.js").PaneCapturedEvent) => void; } /** * Publish a `SessionManagerAdapter` so the `tmux-copilot` tool can * consume it. Called by `createTmuxIntegrationIfSupported` after the * multiplexer + session manager are constructed. * * @param adapter the adapter to publish, or `null` to clear */ export declare function setSessionManagerAdapter(adapter: SessionManagerAdapter | null): void; /** * Get the currently-published `SessionManagerAdapter`, or `null` if the * integration factory has not yet run (or the integration is not * available in this environment). Used by `tmux-copilot.ts:execute` * to dispatch actions. */ export declare function getSessionManagerAdapter(): SessionManagerAdapter | null; /** * Register a mapping from a session ID to a tmux pane ID. * Called by the tmux integration when a child session is spawned in a pane. */ export declare function registerSessionToPaneId(sessionId: string, paneId: string): void; export declare function resolveSessionToPaneId(sessionId: string): string | undefined; export type SendPromptMode = { noReply: true; } | { noReply: false; }; export declare function setSendPrompt(fn: ((sessionId: string, text: string, mode?: SendPromptMode) => Promise) | null): void; export declare function getSendPrompt(): ((sessionId: string, text: string, mode?: SendPromptMode) => Promise) | null; export type SessionMessage = { role: "user" | "assistant" | "system" | "tool"; content: string; toolName?: string; toolArgs?: Record; timestamp?: number; /** When role is "tool" or "assistant" with tool parts, the tool's raw result */ toolResult?: unknown; /** When role is "tool", the call ID */ toolCallId?: string; /** true if this is a thought/reasoning-only message (no tool/text output) */ isThought?: boolean; /** true if this message has text content (vs. only tool calls or only thought) */ hasText?: boolean; }; export type SessionMessagesFetcher = (sessionId: string, limit?: number) => Promise; export declare function setGetSessionMessages(fn: SessionMessagesFetcher | null): void; export declare function getSessionMessagesFetcher(): SessionMessagesFetcher | null; /** * Remove a session→paneId mapping when the session ends or the pane is closed. */ export declare function clearSessionToPaneId(sessionId: string): void; /** * Get the total number of registered session→paneId mappings (for diagnostics). */ export declare function getSessionPaneRegistrySize(): number; /** * P59 R4: return a snapshot of the session→paneId registry for callers that * need to do reverse lookups (e.g. peek needs paneId→sessionId). */ export declare function getSessionPaneRegistryEntries(): Array<[string, string]>; //# sourceMappingURL=types.d.ts.map