Cotal TypeScript packages
    Preparing search index...

    Interface AgentHandle

    An OS handle on one spawned agent — the manager owns this to control the process (the mesh observes its presence separately).

    interface AgentHandle {
        kind: string;
        name: string;
        pid?: number;
        reference?: RuntimeReference;
        attach(): AttachSession;
        exitInfo?(): | { code?: number; diagnostic?: string; signal?: number }
        | undefined;
        interrupt(): void;
        release?(): void;
        startupOutcome?(): StartupOutcome;
        status(): "running" | "exited";
        stop(opts?: { graceful?: boolean }): void;
        waitForExit?(): Promise<void>;
        waitForWorkExit?(): Promise<void>;
        write?(data: string): Promise<number>;
    }
    Index
    kind: string
    name: string
    pid?: number

    OS pid of the spawned child, when the backend owns a real process (pty/host); absent for backends that don't (tmux/cmux attach to an externally-owned process).

    reference?: RuntimeReference

    A local durable reference for a runtime that can later adopt this handle.

    • Open a live attach. Throws on a backend that cannot stream, which is every backend whose runtime declares Runtime.streamsTerminal false: the throw carries that backend's own guidance for watching the agent where it actually runs.

      Returns AttachSession

    • What the runtime OBSERVED when the child ended: the OS exit code, and/or the signal number that killed it. Meaningful only once status reports exited; before that a backend returns undefined.

      OPTIONAL, and absent means UNKNOWN — never "clean": a backend that does not own the child process (tmux/cmux/orca/herdr attach to an externally-owned one) cannot see how it ended, and a caller must say so rather than print a zero it never measured. Defaulting to code: 0 here would fabricate a clean exit on exactly the seats whose death nobody can account for, which is the failure this exists to end.

      diagnostic is the backend's own reason when it stopped the child itself (a startup confirmation that never appeared), otherwise the last line the child printed under a connector's [cotal-<name>] or [cotal-<name>/<part>] prefix, for a backend that reads the child's output; absent when there is neither.

      Returns { code?: number; diagnostic?: string; signal?: number } | undefined

    • Returns void

    • Release this manager's local handle without stopping or deprovisioning the agent. Optional, and absent means the runtime cannot survive manager exit, so callers must fail closed.

      Returns void

    • How the connector's startup watch ended for this child, from the screen read that ended it. Present on every handle spawned by a runtime that declares Runtime.reportsStartupOutcome (an adopted handle may omit it); a launch with no confirm reports pending forever.

      Returns StartupOutcome

    • Returns "running" | "exited"

    • Tear the agent down. graceful (default) signals a clean exit (so the session leaves the mesh on its own) before ensuring the process/tab is gone; otherwise it's a hard, immediate kill.

      Parameters

      • Optionalopts: { graceful?: boolean }

      Returns void

    • Resolve only after the runtime has authoritatively proved the process/window/workspace is gone. Optional during the preservation rollout; a manager maintenance cut must fail closed when absent.

      Returns Promise<void>

    • Prove this launch and all local work it started have ended, including descendants that detached into other sessions or process groups. The runtime must own that work from launch; a parent exit, process-group census, reused PID or environment match is not proof. It may terminate work only through that ownership. Resolve only when no predecessor can create further local work. Reject when ownership or closure is unknown. This does not undo remote effects or promise at-most-once execution.

      Optional; automatic restart refuses when absent. A manager waits for this separately from waitForExit and never starts a replacement on rejection or timeout.

      Returns Promise<void>

    • Type data into the agent as if it came from the keyboard: the one-shot sibling of interrupt (which already writes \x03). A caller that wants to deliver a line of text, not to watch a terminal, uses this instead of standing up an AttachSession for it: a session carries a backlog, a subscriber set and a lifetime, and none of that is wanted for one write.

      OPTIONAL, and absent means REFUSE, never degrade: a backend that does not own the child's input stream (tmux/cmux/orca/herdr attach to an externally-owned process) leaves it off, and the manager answers input is not supported by runtime <kind>. A silent no-op here would be a dropped keystroke, which is worse than an error.

      Resolves only after the runtime has accepted the write, with the number of UTF-8 bytes it accepted. Rejects when the runtime cannot accept it. A caller must derive any delivery receipt from this acknowledgement, never from the buffer it intended to send.

      Parameters

      • data: string

      Returns Promise<number>