UNPKG

@code-yeongyu/senpi

Version:

Coding agent CLI with read, bash, edit, write tools and session management

36 lines • 2.13 kB
/** * The gates every folder-file write over RPC passes right before it commits (senpi#6485): the project trust as it * stands at that moment, and the permission decision the same edit would get from this machine's own session. * * Trust is read per write, never from session open: the session's live trust (which `set_project_trust` moves), and, * unless a launch flag or the Full access preset decided it, the saved decision another session may have changed since. * The permission decision is the permission system's own dispatch authorizer, asked for a `write` of the absolute path * with the content to write, so rules, presets, "Always" answers and the ask prompt apply exactly as to the write tool. */ import type { AgentSession } from "../../core/agent-session.ts"; export interface ProjectWriteRefusal { readonly ok: false; readonly message: string; readonly errorCode: string; readonly errorData?: Record<string, unknown>; } export interface GuardedWrite { readonly relative: string; readonly absolute: string; readonly content: string; /** The stored version the write replaces (`null`: none); it must still be current when the write commits. */ readonly expectedEtag: string | null; readonly mode: number | undefined; readonly missingFolders: readonly string[]; } export declare function notAllowed(relative: string): ProjectWriteRefusal; export declare function tooLarge(): ProjectWriteRefusal; export declare function conflict(relative: string, currentEtag: string | null): ProjectWriteRefusal; export declare function notTrusted(): ProjectWriteRefusal; export declare function projectTrustedForWrite(session: AgentSession): Promise<boolean>; /** * Commits one checked write: the permission decision, then trust and the expected version again (an ask can take * a while), the permission fence, and the atomic replace. Answers a refusal, or `undefined` once the file is written. */ export declare function commitGuardedWrite(session: AgentSession, write: GuardedWrite): Promise<ProjectWriteRefusal | undefined>; //# sourceMappingURL=project-write-gate.d.ts.map