Add Orca terminal surface backend
Subagents run in unfocused Orca terminal tabs in the current worktree, selected automatically between Herdr, Orca (ORCA_TERMINAL_HANDLE), and tmux. - Tabs are created against ORCA_WORKTREE_ID since pi's cwd may live outside any Orca worktree, and start in pi's cwd via the startup command - createSurface blocks on two-phase readiness (startup marker, then a verified probe echo) because input typed during shell init is swallowed by the initial shell's exec or flushed during bash startup - terminal read reports ok with status exited for closed terminals, so reads throw on non-running status to match herdr/tmux semantics - Integration harness gains Orca focus support via terminal switch and visual-layout active-pane lookup
This commit is contained in:
@@ -1,17 +1,19 @@
|
||||
/**
|
||||
* Backend-neutral terminal surface facade.
|
||||
*
|
||||
* Herdr is selected when Pi is running in a Herdr-managed pane. tmux remains
|
||||
* the fallback when Pi is running inside tmux. Selection is automatic so a
|
||||
* process uses one backend consistently for its whole lifetime.
|
||||
* Herdr is selected when Pi is running in a Herdr-managed pane, Orca when Pi
|
||||
* is running in an Orca-managed terminal. tmux remains the fallback when Pi is
|
||||
* running inside tmux. Selection is automatic so a process uses one backend
|
||||
* consistently for its whole lifetime.
|
||||
*/
|
||||
import { existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
|
||||
import { tmpdir } from "node:os";
|
||||
import { dirname, join } from "node:path";
|
||||
import * as herdr from "./herdr.ts";
|
||||
import * as orca from "./orca.ts";
|
||||
import * as tmux from "./tmux.ts";
|
||||
|
||||
export type MuxBackend = "herdr" | "tmux";
|
||||
export type MuxBackend = "herdr" | "orca" | "tmux";
|
||||
type Direction = "left" | "right" | "up" | "down";
|
||||
|
||||
type SurfaceBackend = {
|
||||
@@ -25,20 +27,27 @@ type SurfaceBackend = {
|
||||
|
||||
export function selectMuxBackend(availability: {
|
||||
herdr: boolean;
|
||||
orca: boolean;
|
||||
tmux: boolean;
|
||||
}): MuxBackend | null {
|
||||
if (availability.herdr) return "herdr";
|
||||
if (availability.orca) return "orca";
|
||||
if (availability.tmux) return "tmux";
|
||||
return null;
|
||||
}
|
||||
|
||||
export function getMuxBackend(): MuxBackend | null {
|
||||
return selectMuxBackend({ herdr: herdr.isAvailable(), tmux: tmux.isAvailable() });
|
||||
return selectMuxBackend({
|
||||
herdr: herdr.isAvailable(),
|
||||
orca: orca.isAvailable(),
|
||||
tmux: tmux.isAvailable(),
|
||||
});
|
||||
}
|
||||
|
||||
function getBackend(): SurfaceBackend {
|
||||
const backend = getMuxBackend();
|
||||
if (backend === "herdr") return herdr;
|
||||
if (backend === "orca") return orca;
|
||||
if (backend === "tmux") return tmux;
|
||||
throw new Error(`No supported terminal multiplexer is available. ${muxSetupHint()}`);
|
||||
}
|
||||
@@ -49,8 +58,9 @@ export function isMuxAvailable(): boolean {
|
||||
|
||||
export function muxSetupHint(): string {
|
||||
if (process.env.HERDR_ENV === "1") return herdr.setupHint();
|
||||
if (process.env.ORCA_TERMINAL_HANDLE) return orca.setupHint();
|
||||
if (process.env.TMUX) return tmux.setupHint();
|
||||
return "Start pi inside Herdr or tmux.";
|
||||
return "Start pi inside Herdr, Orca, or tmux.";
|
||||
}
|
||||
|
||||
export function createSurface(name: string): string {
|
||||
|
||||
Reference in New Issue
Block a user