/** * daemon/launch-cli.ts — `aibroker launch `, a session from a shell. * * Launching already existed over IPC, reachable from a session that has the * tool. That is the wrong shape for the one case that matters most: bringing * work back after the machine restarted. At that moment there is no session to * hold the tool — that is the whole problem — so the capability has to be * reachable from a script and from a bare prompt, which means a CLI verb. * * A directory opens a plain Claude Code session there through the active * transport (a tmux window on Linux, an iTerm tab on macOS); a bare PAI project * name keeps going through `pai_launch`. The transport call runs in this * process, not the daemon: the caller's $TMUX says which tmux session is "here", * and it works while the daemon is down, which is when restoring matters. * * It prints the session id because the caller's next move is almost * always to manage or arm the thing it just created, and that needs the id. */ import type { SessionTransport } from "../transport/index.js"; export interface LiveRow { sessionId: string; paiName?: string | null; name?: string; kind?: string; cwd?: string | null; transport?: string; } export interface LaunchDeps { transport: () => SessionTransport; /** Live rows from the daemon; an unreachable daemon is an empty list, not an error. */ sessions: () => Promise; paiLaunch: (name: string) => Promise<{ itermSessionId?: string; name?: string; }>; isDir: (path: string) => boolean; paiPresent: () => boolean; cwd: string; home: string; out: (line: string) => void; } export type LaunchTarget = { kind: "dir"; dir: string; name: string; } | { kind: "pai"; name: string; }; /** `[--name N] ` in any order. */ export declare function parseLaunchArgs(args: string[]): { target?: string; name?: string; }; /** * Directory or PAI project? A path-like argument (`/x`, `./x`, `~/x`, `a/b`) * is always a directory. A bare word stays a PAI project wherever PAI exists — * on macOS `launch whazaa` must keep meaning the project even when a `whazaa` * directory sits in the working directory — and is a directory otherwise. */ export declare function resolveLaunchTarget(target: string, nameOverride: string | undefined, deps: Pick): LaunchTarget; /** * Attach before spawning. Launching is not the point — HAVING a session for * this project is, and a second pane in the same repository is worse than no * pane at all: two agents claiming the same issues, committing over each * other, neither aware of the other. The recovery case cannot tell in advance * whether the machine restarted or the caller simply asked twice, so the only * safe shape is idempotent. * * Match on paiName, which is the project identity the daemon assigns, rather * than on the terminal's title, which carries spinner glyphs and process * names and would match a bare shell sitting in the same directory. A launched * directory session has no paiName yet, so it is matched by its name or its * directory — but only when it is a live Claude, never a shell. */ export declare function findRunning(rows: LiveRow[], name: string, dir?: string): LiveRow | undefined; /** Returns the process exit code. */ export declare function launch(args: string[], deps: LaunchDeps): Promise; export declare function runLaunch(args: string[]): Promise; //# sourceMappingURL=launch-cli.d.ts.map