/** * Hivemind tmux-copilot — co-pilot affordance for the tmux visual orchestration layer. * * Phase 43 design notes (D-43-02, REQ-04, REQ-05, REQ-06): * - 4 actions: send-keys, list-panes, compute-grid, respawn * - Discriminated union Zod schema; each branch has its own payload shape * - Permission-gated: orchestrator-tier agents may invoke any action (T-43-05) * The OpenCode SDK `tool()` helper does NOT support a `requiresPermission` * field — the gate is enforced at execute() runtime via context.agent. * REQUIRES_PERMISSIONS is exported as a module const so future * harness-level enforcement layers can consume it. * - Graceful unavailable: when the in-tree integration is not wired, * returns {available: false, reason: "tmux-not-wired"} instead of * throwing. This is the T-43-09 mitigation (DoS) — no exception escapes. * - All adapter calls wrapped in try/catch so tmux/in-tree failures * produce structured error results rather than uncaught exceptions. * * Phase 51 migration: the consumer now uses `getSessionManagerAdapter` * (from `../features/tmux/types.js`) instead of the deleted * `getForkSessionManager` (from `../features/tmux/fork-bridge.js`). * The bridge pattern (module-level mutable state populated by the * integration factory at plugin-init time) is preserved. * * Phase 58.8 (P58 gap-fix S2, REQ-58-08): a second tier of callers * (`USER_SESSION` — agent name `user` / `__user__`) is permitted past * the gate, but only for a restricted action subset (D-58-22 LOCKED): * take-over, release, peek. All other actions remain orchestrator-only. * This closes the S2 symptom where a human operator had no * orchestrator-context affordance to inspect or intervene on a * delegate pane. */ import { tool } from "@opencode-ai/plugin/tool"; import { z } from "zod"; import { type PaneState, type SplitCommand } from "../features/tmux/types.js"; export type TmuxCopilotResult = { available: false; reason: "tmux-not-wired" | "tmux-not-installed" | "tmux-timeout"; } | { available: false; reason: "tmux-error"; error: { message: string; }; } | { sent: true; paneId: string; } | { sent: false; paneId: string; error: { message: string; }; } | { panes: PaneState[]; } | { commands: SplitCommand[]; } | { respawned: true; paneId: string; } | { respawned: false; error: { reason: string; }; } | { paneId: string; deliveredAt: string; byteLength: number; } | { suppressed: true; reason: "manualOverride" | "session-not-found"; paneId: string; textPreview: string; evaluatedAt: string; } | { sessionId: string; paneId: string; takenBy: string; takenAt: string; } | { sessionId: string; releasedAt: string; } | { paneId: string; content: string; capturedAt: string; byteLength: number; } | { sessionId: string; paneId: string; content: string; capturedAt: string; byteLength: number; } | { error: { kind: "invalid-input"; issues: z.ZodIssue[]; }; } | { error: { kind: "permission-denied"; agent: string; }; }; export declare const tmuxCopilotTool: ReturnType; /** * P58 PLAN-07 (Gap 3 fix): BATS-friendly test seam that injects a mock * `SessionManagerAdapter` (alias "TmuxMultiplexer") so the tool can run * without a real tmux session. Delegates to the existing * `setSessionManagerAdapter()` at `src/features/tmux/types.ts` * (already wired by the P51 migration per tmux-copilot.ts:18-22). * * BATS tests should: * 1. Construct a mock with a `sendKeys` method that captures calls * 2. Call `__setTmuxMultiplexerForTesting(mock)` before invoking the tool * 3. Invoke the tool action * 4. Assert the mock captured the expected call * 5. Restore via `__setTmuxMultiplexerForTesting(null)` in teardown * * The seam is intentionally NOT prefixed with `_` (which is the convention * for "private" in some codebases) because the leading double-underscore * `__` is the project's TEST-ONLY marker (per the * `__getDelegationsForTesting` pattern at `src/coordination/delegation/manager.ts`). * * NOT for production code. Production wiring still goes through * `src/features/tmux/integration.ts` which calls * `setSessionManagerAdapter()` directly. */ export declare function __setTmuxMultiplexerForTesting(mux: unknown): void; //# sourceMappingURL=tmux-copilot.d.ts.map