/** * relays Command - the standing delegations this machine is holding (#2377) * * commandmate relays [--worktree ] [--instance ] [--json] * commandmate relays cancel * * ## Why a command and not a flag on `ls` * * A relay is the one piece of state in CommandMate that belongs to TWO sessions * at once: session A is owed an answer, session B owes one, and neither * worktree's own listing can show that without inventing a column for the other * side. So the listing is its own thing, and it prints the pair — `from` and * `to`, `→` between them — rather than a status word per row. * * With no `--worktree` it asks the session it is running inside (`whoami`'s * resolution) and prints that session's two sides. That is the shape an agent * uses: "what am I waiting for, and what do I owe?" is a question about the * caller, and making the caller name itself is what #2376 exists to stop. * * ## What this module exports besides the command * * The `--reply-to` plumbing, because `send` and `ask` both take that flag and * both have to turn one string into the two ids the ledger stores. Keeping * {@link resolveRelayEndpoint} here rather than in `send.ts` is what stops the * two commands from resolving `self` two different ways. */ import { Command } from 'commander'; import { ApiClient } from '../utils/api-client'; /** * The codes `POST /api/relays` refuses with. * * Mirrors `RelayRefusalCode` in `lib/relay/relay-policy` plus the route's own * not-found; duplicated rather than imported so the CLI bundle does not pull the * server's database graph in for four strings. */ export declare const RELAY_REFUSAL_CODES: Set; /** One end of a relay, as the API wants it. */ export interface RelayEndpointArg { worktreeId: string; instanceId: string; } /** The text `--reply-to` is documented with, shared by `send` and `ask`. */ export declare const REPLY_TO_OPTION_DESCRIPTION: string; /** The text `--allow-relay-chain` is documented with. */ export declare const ALLOW_RELAY_CHAIN_DESCRIPTION: string; /** * Turn one `--reply-to` value into the two ids the ledger stores. * * Exits 2 rather than throwing: every failure here is a bad option value or a * shell that is not inside a CommandMate session, and both are things the * operator fixes on the command line. * * @param client - API client * @param spec - The raw `--reply-to` value */ export declare function resolveRelayEndpoint(client: ApiClient, spec: string): Promise; /** * The resolved endpoint for a worktree, with or without a named instance. * * Also what `send` / `ask` use for the relay's OTHER end — the session being * asked — because the ledger stores a resolved id at both ends and the send's * own `--instance` may have been omitted (meaning "the primary one", which only * the server can name). * * @param client - API client * @param worktreeId - Worktree ID * @param selector - An instance id or roster alias, or undefined * @param requestedAgent - The `--agent` value, if the caller gave one */ export declare function resolveEndpointForWorktree(client: ApiClient, worktreeId: string, selector: string | undefined, requestedAgent?: string): Promise; /** What {@link registerRelay} needs. */ export interface RegisterRelayInput { /** The session that will receive the reply. */ from: RelayEndpointArg; /** The session being asked. */ to: RelayEndpointArg; allowRelayChain?: boolean; } /** * Open a relay, printing the server's own refusal and exiting 2 on one. * * Exit 2 and not a bespoke code: every refusal is a decision the operator can * change (drop the flag, cancel the other relay, stop forwarding), which is what * `CONFIG_ERROR` means everywhere else in this CLI. * * @returns The relay id */ export declare function registerRelay(client: ApiClient, input: RegisterRelayInput): Promise; /** Withdraw a relay, best effort. Used when the send it accompanied failed. */ export declare function cancelRelayQuietly(client: ApiClient, relayId: string): Promise; export declare function createRelaysCommand(): Command; //# sourceMappingURL=relays.d.ts.map