UNPKG

@code-yeongyu/senpi

Version:

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

66 lines • 3.91 kB
/** * The session workspace's project trust and project-scope settings over RPC (senpi#6176). * * Trust: the choices are exactly the ones `/trust` offers (`getProjectTrustOptions` without the session-only * entries), and choosing one saves exactly what that choice saves in `trust.json`. It is never implied: only an * explicit `set_project_trust` writes, and a launch that named the trust (`--approve`/`--no-approve`) refuses it, because * that flag outranks every saved decision. Then, in the order `resolveProjectTrusted` decides a session's trust, a folder * with nothing trust gates stays trusted, and a `project_trust` handler of the extensions loaded before trust (never a * project extension) decides before any saved choice: a choice it decides against is refused, with nothing saved and * nothing applied. Otherwise the session takes the decision the way a Full access change does * (`applyProjectTrustChange`), in line with the runtime's own trust changes: project settings, skills, prompts, * extensions and MCP servers load or unload at once. * * `no_inherit` is the one choice `set_project_trust` takes that `get_project_trust` never lists, because it is for * clients, not people (a desktop pull-request worktree of another repository): it saves an explicit no-decision entry, * so the folder inherits no decision from above it or from its main checkout and is decided as if nothing were saved. * It never adds trust to the session it is set in: a trust that came only from Full access stays (and leaving Full * access still withdraws it), any other trust goes unless a `project_trust` handler decides the folder is trusted. * * Settings: the project settings file is read as stored (reading runs nothing, so trust does not gate it) and written * one top-level key at a time through `SettingsManager`'s own project write path, which refuses an untrusted project. */ import type { AgentSession } from "../../core/agent-session.ts"; import { type ProjectSettingsFile } from "../../core/settings-manager.ts"; /** Runs a trust change after every trust change the session's runtime already started (Full access syncs). */ export type InTrustChangeOrder = <T>(task: () => Promise<T>) => Promise<T>; export type ProjectTrustChoice = "trust" | "trust_parent" | "do_not_trust" | "no_inherit"; export interface RpcProjectTrustChoice { choice: ProjectTrustChoice; label: string; trusted: boolean; /** The folder the choice saves its decision for. */ path: string; } export interface RpcProjectTrust { cwd: string; /** Whether this session runs with the project trusted now. */ projectTrusted: boolean; /** Whether the folder has anything trust gates; without it the project counts as trusted. */ requiresTrust: boolean; /** The nearest saved decision at or above the folder, as `/trust` shows it. */ saved: { path: string; trusted: boolean; } | null; /** The launch named the trust (`--approve`/`--no-approve`); `set_project_trust` is refused. */ locked: boolean; choices: RpcProjectTrustChoice[]; } export type ProjectCommandResult<T> = { ok: true; data: T; } | { ok: false; message: string; errorCode: string; }; export declare function readProjectTrust(session: AgentSession): Promise<RpcProjectTrust>; export declare function writeProjectTrust(session: AgentSession, choice: unknown, inTrustChangeOrder: InTrustChangeOrder): Promise<ProjectCommandResult<RpcProjectTrust>>; export interface RpcProjectSettings extends ProjectSettingsFile { cwd: string; projectTrusted: boolean; } export declare function readProjectSettings(session: AgentSession): RpcProjectSettings; export declare function writeProjectSetting(session: AgentSession, key: unknown, value: unknown): Promise<ProjectCommandResult<RpcProjectSettings>>; //# sourceMappingURL=project-workspace-commands.d.ts.map