/** * What `roles`, `instances` and `send` share about roles (Issue #4116): reading a * role or repository the way a person names it, reading a body, and turning the * role API's refusals into an exit code. * * ## Decisions * * - **A role is named by ID or name, and nothing is reserved.** "No role" and * "follow the defaults" are flags, so a role called `none` is just a role. * An exact match wins; failing that, a match ignoring case and Unicode form. * Two answers at the same step is an error listing them, never a pick. * - **`--repo` is, in this order: an ID, a path, a name.** A value containing a `/` * or starting with `.` is a path; it may be a registered root, or a worktree of * one (which answers for its root). A bare word is never read as a path, so what * the current directory holds cannot change which repository a word means. * - **Unknown, unregistered and ambiguous have their own codes**: `unknown_repository`, * `repository_not_registered` (a real directory with no row) and `ambiguous_repository`. * A root with no row for a tool is not an error: it reads `stored: inherit`. * * Type imports and {@link isAgentRoleCliTool} only from the shared types: the CLI * does not load the server's role layer. */ import { type ApiClient } from './api-client'; import { RoleCliError, roleFailureFromApi, usageError } from './role-failure'; import { type AgentRoleCliTool, type AgentRoleSummary, type RoleAssignmentInput } from '../../types/agent-roles'; export { RoleCliError, roleFailureFromApi, usageError }; export { readRoleBodyOption } from './role-input'; /** * Run a request that changes a role setting (Issue #4116). The routes write, then build * their answer, so a 500 or a lost answer can follow a write that stayed. Only a 4xx is * known to have changed nothing; anything else says that is not known, how to look, and * with `--json` the same as `saved: "unknown"` and `check`. The code and exit code stay * what the failure itself has. * * @param check - The command that shows what the setting is now * @throws A 4xx as its role failure, or as it came when it is none */ export declare function roleWrite(check: string, write: () => Promise): Promise; /** * End a role command on `error`: the sentence on stderr, and with `--json` the same * thing as an object on stdout, whatever the failure was, so a caller parsing stdout * gets an answer either way. A failure no route classified (a 500, no connection) * keeps the sentence and exit code `handleCommandError` gives it. */ export declare function reportRoleFailure(error: unknown, json: boolean | undefined): void; /** * The role `selector` names. The database keeps names unique ignoring ASCII case * only, so Unicode forms and non-ASCII case can still answer twice, and a name can * equal another role's ID. */ export declare function pickRole(roles: readonly T[], selector: string): T; export declare function resolveRole(client: ApiClient, selector: string): Promise; /** The tool a role command names, or the failure for one outside the role feature. */ export declare function assertRoleTool(tool: string): AgentRoleCliTool; /** * `--role` and `--no-role` share one commander value, where the last one given wins. * Asking for both is a contradiction, so the two are watched as they are parsed. * * @returns Whether both were given. Read after parsing. */ export declare function watchRoleFlagConflict(command: { on(event: string, listener: () => void): unknown; }): () => boolean; /** `--role ` / `--no-role` as a setting, or undefined when neither was given. */ export declare function roleAssignmentFromFlag(client: ApiClient, flag: string | false | undefined): Promise; export interface RegisteredRepository { id: string; name: string; path: string; enabled?: boolean; } export declare function listRepositories(client: ApiClient): Promise; /** The registered repository `--repo` names. See the module's decisions for the order. */ export declare function resolveRepository(client: ApiClient, selector: string): Promise; //# sourceMappingURL=agent-roles.d.ts.map