/** * Tool policy (Issue #4436 / #4437): which CLI tools CommandMate may drive, for which * operation, from which origin, under which usage declaration. * * Google Antigravity Additional Terms §6 (https://antigravity.google/terms) and its FAQ * (https://antigravity.google/docs/faq) restrict using Antigravity on a consumer * (personal) plan through third-party software or agents. So for antigravity, unless the * user declares an API-key or enterprise plan, unattended runs and Auto-Yes are refused, * and send / ask / respond / relay are refused unless a person started them (the web UI, * an older CLI, or a terminal). * * Pure: no side effects, no I/O, no DB, no node built-ins and no `process.env` — the * declaration is an argument (see `declaration.ts`). Read from the CLI by a relative path * and from the web UI, so the only import is the `CLIToolType` type. * * @module lib/tool-policy/policy */ import type { CLIToolType } from '../cli-tools/types'; /** Operations the policy decides on. */ export type ToolOperation = 'send' | 'ask' | 'respond' | 'relay' | 'schedule' | 'auto-yes'; /** * Who started the operation. `legacy` = no origin in the request (web UI, older CLI); * `relay` / `timer` are server-internal and never accepted from a request body. */ export type SendOrigin = 'legacy' | 'terminal' | 'session' | 'agent' | 'schedule' | 'unknown' | 'relay' | 'timer'; /** The user's declared Antigravity plan. */ export type UsageDeclaration = 'personal' | 'api-key' | 'enterprise'; /** Environment variable holding the usage declaration. */ export declare const USAGE_DECLARATION_ENV = "CM_ANTIGRAVITY_USAGE"; /** Environment variable marking the origin of a child process (value `schedule`). */ export declare const RUN_ORIGIN_ENV = "CM_RUN_ORIGIN"; /** HTTP / CLI code of a refusal on send, ask, respond, schedule and Auto-Yes. */ export declare const TOOL_POLICY_DENIED = "TOOL_POLICY_DENIED"; /** Code of a refusal on relay creation (follows the `RELAY_*` refusal codes). */ export declare const RELAY_TOOL_POLICY_DENIED = "RELAY_TOOL_POLICY_DENIED"; /** Reason: Antigravity consumer-plan terms (§6 / FAQ). */ export declare const ANTIGRAVITY_CONSUMER_TERMS = "ANTIGRAVITY_CONSUMER_TERMS"; /** Why the policy refused. */ export type ToolPolicyReason = typeof ANTIGRAVITY_CONSUMER_TERMS; /** Google Antigravity Additional Terms. */ export declare const ANTIGRAVITY_TERMS_URL = "https://antigravity.google/terms"; /** Google Antigravity FAQ. */ export declare const ANTIGRAVITY_FAQ_URL = "https://antigravity.google/docs/faq"; /** Date the terms and FAQ wording were checked. */ export declare const ANTIGRAVITY_TERMS_CHECKED_AT = "2026-11-16"; /** One English sentence for the `error` of the API and the CLI. */ export declare const TOOL_POLICY_DENIED_MESSAGE = "Refused by default for antigravity under the Google Antigravity terms \u00A76 (consumer plans). Nothing was typed."; /** * Parse a request's `origin`. Missing → `legacy`; a known body origin → itself; any * other string (including `relay`, `timer`, `legacy`, which a body may not claim) → * `unknown`; a non-string (including `null`) → `invalid` (the caller answers 400). */ export declare function parseSendOrigin(value: unknown): SendOrigin | 'invalid'; /** A restriction on one tool. `null` in the table = no restriction. */ interface ToolRestriction { readonly reason: ToolPolicyReason; readonly links: { readonly terms: string; readonly faq: string; }; /** Declarations that lift the restriction entirely. */ readonly unlockedBy: readonly UsageDeclaration[]; /** Origins still allowed per operation while restricted (empty = refused from any origin). */ readonly allowedOrigins: Readonly>; } /** * The policy as data: change one entry to change the rule. A full `Record` so adding a * tool to `CLI_TOOL_IDS` fails typecheck until it is listed here. */ export declare const TOOL_POLICY_TABLE: Readonly>; /** Input of {@link decideToolPolicy}. */ export interface ToolPolicyInput { tool: CLIToolType; operation: ToolOperation; origin: SendOrigin; declaration: UsageDeclaration; } /** Result of {@link decideToolPolicy}. */ export type ToolPolicyDecision = { allowed: true; } | { allowed: false; code: typeof TOOL_POLICY_DENIED; reason: ToolPolicyReason; tool: CLIToolType; operation: ToolOperation; origin: SendOrigin; declaration: UsageDeclaration; links: { terms: string; faq: string; }; }; /** Decide whether `tool` may be driven for `operation` from `origin` under `declaration`. */ export declare function decideToolPolicy({ tool, operation, origin, declaration }: ToolPolicyInput): ToolPolicyDecision; /** Human-readable message for a refusal (empty string when allowed). Not legal advice. */ export declare function formatToolPolicyDenial(decision: ToolPolicyDecision, locale: 'ja' | 'en'): string; export {}; //# sourceMappingURL=policy.d.ts.map