/** * Who is sending, as this CLI reads it from its own environment (Issue #4437). * * `send`, `ask` and `respond` (the strict one too) put the answer on their request as * `origin`, with a short `originEvidence` for the server's log — every request that may * reach a tool the policy restricts; one naming any other tool is left as it was * ({@link withSendOrigin}, set on `ApiClient.post` by {@link installSendOrigin}). The server asks the * tool policy (`lib/tool-policy/policy`) with it: under a personal-plan declaration, * antigravity takes a send only from a person (the web UI, which names no origin, or * `terminal`). Everything else is refused before a key is typed, with exit 33. * * In this order, the first match wins (design §1.2): * * 1. `CM_RUN_ORIGIN` — `schedule` (CommandMate's unattended runs set it); any other * value is a launcher this CLI does not know: `unknown` * 2. a CommandMate session's identity in the environment (`CM_WORKTREE_ID`, `CM_AGENT_*`, …) — `session` * 3. `$TMUX`, and the session's name is one CommandMate gave (`mcbd-…`, `parseSessionName`) — `session` * 4. `$TMUX`, and the name cannot be read (tmux failed or said nothing) — `unknown` * 5. an AI agent's own marker (`CLAUDECODE`, the only one confirmed so far) — `agent` * 6. stdin is not a terminal (cron, a pipe, most agents' shells) — `unknown` * 7. otherwise, a person typing in a terminal — `terminal` * * Not knowing is `unknown`, which antigravity refuses: a gap in what can be read must * not let an agent's send through. A person's own tmux with a name of their own is not * a CommandMate session and reads on from step 5. * * Only the environment and the tmux session name are read: no file (no credentials, no * `~/.gemini`), no server. There is deliberately no flag to override it — an agent * could pass it. The server cannot verify the claim; this is a guard against * accidental use, not a guarantee of compliance with the Google Antigravity terms. * * @module cli/utils/send-origin */ /** The origins this CLI claims (`legacy`, `relay` and `timer` are never claimed by a request). */ export type CliSendOrigin = 'terminal' | 'session' | 'agent' | 'schedule' | 'unknown'; /** What {@link resolveSendOrigin} decided, and the one fact it decided on. */ export interface ResolvedSendOrigin { origin: CliSendOrigin; /** e.g. `env:CM_AGENT_TOOL`, `tmux:mcbd-…`, `no-tty`. For the server's log only. */ evidence: string; } /** What {@link resolveSendOrigin} reads; each part replaceable in tests. */ export interface SendOriginInputs { env: Readonly>; /** `process.stdin.isTTY`. */ stdinIsTTY: boolean | undefined; /** The tmux session this process runs in, or null. Called only when `$TMUX` is set. */ readTmuxSessionName: () => string | null; } /** The value of {@link RUN_ORIGIN_ENV} that marks a Schedule / daily-summary child. */ export declare const RUN_ORIGIN_SCHEDULE = "schedule"; /** * A CommandMate session's identity variables (whoami's, and the `CM_AGENT_*` * correlation variables of the launch line). Any one of them is a session. */ export declare const SESSION_ENV_VARS: readonly string[]; /** * Markers an AI agent puts on its own child shells. Only `CLAUDECODE` was observed * (2026-11-16); the others' markers are not confirmed, and step 6 (no terminal) still * catches most of them. */ export declare const AGENT_ENV_MARKERS: readonly string[]; /** * The tmux session name, the way `whoami` reads it (`readTmuxSessionName` there). * Restated rather than imported from `commands/whoami`, so this utility does not * reach into a command module. */ export declare function readTmuxSessionNameForOrigin(): string | null; /** Who is sending, from the environment and the tmux session name only. */ export declare function resolveSendOrigin(inputs?: Partial): ResolvedSendOrigin; /** Whether a POST to `path` is one that types into a session. */ export declare function isSendOriginPath(path: string): boolean; /** * Issue #4449: the `origin` / `originEvidence` of a write a send makes before its message * (the task of `--contract`, the instance and role of `--register --role` / `--contract * --role`), which the server judges as it would the send. Empty for a tool the policy * table never restricts, so those bodies stay byte for byte what they were; a tool this * CLI does not know, or none (the server picks the default), carries it. */ export declare function sendOriginFieldsFor(tool: string | undefined, resolve?: () => ResolvedSendOrigin): { origin?: CliSendOrigin; originEvidence?: string; }; /** * The body of a POST to `path` with `origin` / `originEvidence` on it, when `path` is * one of the routes that type into a session, the body names no origin of its own, * and it may reach a tool the policy restricts ({@link namesUnrestrictedTool}); * otherwise `body` itself. Resolved per request (an environment is cheap to read, and * tmux is asked only inside tmux). */ export declare function withSendOrigin(path: string, body: unknown, resolve?: () => ResolvedSendOrigin): unknown; /** * Make every `ApiClient.post` of this process put who is sending on the requests that * type into a session (`send`, `ask` and `respond` call it first; the strict respond's * own client is covered too). Not done by `api-client` itself: reading the origin runs * tmux, which the guards keep out of what `lib/brief` / `lib/handoff` reach. */ export declare function installSendOrigin(): void; //# sourceMappingURL=send-origin.d.ts.map