/** * Registrations we have made in *another tool's* config that point back into * our data dir. * * Two harnesses do this today: Codex and Claude Code both assemble a plugin * marketplace under `//` and hand that **path** to the * harness CLI, which stores it and re-reads it on every run. * * That makes the data dir load-bearing for a foreign tool, and removing it * without deregistering first leaves that tool pointing at a directory which no * longer exists. For Codex the blast radius is the whole `codex plugin` * surface, including plugins that have nothing to do with Ory: * * ``` * $ codex plugin list * Error: failed to load configured marketplace snapshot(s): * - `ory` at ~/.config/ory-agent-plugins/codex/marketplace: marketplace root * does not contain a supported manifest * ``` * * The ordinary `uninstall` path deregisters correctly. The problem is every * path that removes the data dir *without* going through it — `pnpm clean:all` * or a user clearing the directory by hand. Removing our own state should never * leave someone else's tool broken (#206). * * So each plugin records how to undo its registration, and the destructive * paths replay those removals **before** deleting anything. The record is * deliberately a plain command rather than a callback: the code that could run * it may itself be inside the directory about to be deleted. */ export interface ExternalRegistration { /** The harness that made the registration. One record per harness. */ harness: string; /** The foreign tool holding the reference (`codex`, `claude`). */ tool: string; /** Human-readable summary, shown when the removal runs. */ description: string; /** Path inside our data dir that the foreign tool points at. */ root: string; /** Argv that removes the registration from the foreign tool. */ remove: { command: string; args: string[]; }; } /** Every registration currently recorded. */ export declare function loadExternalRegistrations(): ExternalRegistration[]; /** * Record (or refresh) the registration for a harness. Idempotent: re-running an * install replaces the harness's entry rather than appending a duplicate. */ export declare function recordExternalRegistration(entry: ExternalRegistration): void; /** Forget a harness's registration, after it has been deregistered. */ export declare function clearExternalRegistration(harness: string): void; export interface DeregisterResult { registration: ExternalRegistration; ok: boolean; detail?: string; } /** * Replay every recorded removal. Call this **before** deleting the data dir. * * Entirely best-effort: a foreign tool that is no longer installed, or that * fails the removal, must not stop the reset that is in progress. Results are * returned so the caller can report what happened. */ export declare function deregisterExternalRegistrations(): DeregisterResult[]; /** Drop the whole registry (the data dir is about to go anyway). */ export declare function clearAllExternalRegistrations(): void; /** * A registration whose target directory has gone missing — the foreign tool is * pointing at nothing, which is the state that breaks it. * * `status` uses this to say what happened and how to fix it, instead of leaving * the user to decode an error from a tool that never mentions Ory. */ export declare function findDanglingRegistration(harness: string): ExternalRegistration | undefined; /** One-line remediation for a dangling registration, for `status` output. */ export declare function describeDanglingRegistration(registration: ExternalRegistration): string;