/** * [WHO]: PermissionStore, PermissionRequest, PermissionAction, PermissionDecision * [FROM]: No external deps * [TO]: Consumed by team-runtime.ts, index.ts * [HERE]: extensions/builtin/team/team-permissions.ts - Phase B B.4 permission model * * Per refactor plan §B.4: "permission must be frozen before mailbox". * * The permission model is the trust boundary between leader and teammate. * Any action that mutates the world or escalates a teammate's mode goes * through a PermissionRequest which the leader must approve via * `/team:approve `. * * Pending requests carry a `resolve` callback so the runtime side can * `await` the leader's decision without polling. */ export type PermissionAction = "mode_change_to_execute" | "write_path" | "bash_command"; export type PermissionStatus = "pending" | "approved" | "denied" | "expired"; export interface PermissionRequest { id: string; teammateId: string; teammateName: string; action: PermissionAction; detail: string; createdAt: number; status: PermissionStatus; } /** * In-memory permission store. Decisions never persist across process restarts: * if the main session dies while a request is pending, the teammate is left * idle and the leader must reissue the action after restart. */ export declare class PermissionStore { private requests; private pathAllowlist; /** * File a new permission request and return a promise that resolves * with the leader's decision (true = approved, false = denied). */ request(teammateId: string, teammateName: string, action: PermissionAction, detail: string): { id: string; decision: Promise; }; /** Approve a pending request. Returns false if id is unknown or already resolved. */ approve(id: string): boolean; /** Deny a pending request. */ deny(id: string): boolean; /** All pending requests, sorted oldest first. */ listPending(): PermissionRequest[]; /** Get a request snapshot without the resolve handle. */ get(id: string): PermissionRequest | undefined; /** * Cancel any pending requests owned by `teammateId`. Used when the * teammate is terminated so the awaiting promise does not leak. */ cancelForTeammate(teammateId: string): void; /** Grant a teammate write permission for a path prefix. */ allowPath(teammateId: string, path: string): void; /** Check whether a teammate currently holds write access to `path`. */ isPathAllowed(teammateId: string, path: string): boolean; /** Drop a teammate's allowlist entirely (called on terminate). */ clearPaths(teammateId: string): void; }