import type { ManagedTextFileSnapshot, NativeConfigOperation } from "../types.js"; import type { NativeAsset, WireNativeFilesOptions } from "./native-utils.js"; import type { CodexAgentProfileRecord, CodexProfileDecision } from "./codex-ownership-machine.js"; type CodexMarketplaceStyle = "current" | "legacy"; /** * Writes Codex-native managed files using the current repo/team plugin and * custom-agent contracts. Hooks are intentionally not synthesized: the current * Codex plugin validator rejects unsupported hook fields, and raw hook assets * are not sufficient to construct a valid event-map safely. The apply is * ATOMIC-WITHOUT-ROLLBACK for the collision path: every adoption check * (top-level + legacy plugin roots) runs READ-ONLY before the first managed * write, so a user-owned collision rejects on a clean tree with zero side * effects. Genuine late I/O failures (a write itself throws) then trigger a * COMPLETE, CORRECTLY-SCOPED snapshot-restore so a reported failure never * leaves orphaned marketplace / profile / manifest state, and never deletes a * plugin root a PRIOR apply owned (CodeRabbit Major: the old partial rollback * was both incomplete and over-aggressive). * * Ownership decisions (which profile/marketplace cells are written, preserved, * removed, or restored) are NOT made by inline `if/then` arms here — they are * resolved from the executable CODEX ownership transition table via * `classifyProfileState`/`classifyMarketplaceState` + * `resolveOwnershipDecision` in codex-ownership-machine.ts. This file only * executes the returned decision. */ export declare function writeCodexNativeFiles(options: WireNativeFilesOptions): Promise; /** Reads snapshot bytes, treating an unreachable path (ENOTDIR parent) as absent. */ declare function readSnapshotTextOrNull(filePath: string, read?: (p: string) => Promise): Promise; /** Removes a path, tolerating an unreachable one (ENOTDIR parent, e.g. `.codex` is a file). */ declare function removePathIfReachable(filePath: string, rm?: (p: string) => Promise): Promise; /** Lists existing owned-codex profile filenames below an agents directory. */ declare function listCodexAgentProfileFileNames(agentsDir: string, list?: (p: string) => Promise): Promise; /** Deterministic owned-profile filename for an agent asset id. */ declare function codexAgentProfileFileName(assetId: string): string; /** Prunes directories emptied by a rollback, stopping at the workspace root. */ declare function pruneEmptyApplyParents(workspaceRoot: string, prune?: (p: string) => Promise): Promise; /** Builds the current Codex plugin manifest. */ export declare function buildCodexPluginManifest(): Record; /** Current Codex plugins do not synthesize hook manifests. */ export declare function buildCodexHooksManifest(): null; /** Builds the legacy hook manifest used by legacy Codex plugin layouts. */ export declare function buildLegacyCodexHooksManifest(nativeAssets: readonly NativeAsset[], contentPathByAssetId: Readonly>, hooksManifestPath?: string): Record; /** * Looks up the profile's ownership state from its prior record + live bytes and * resolves the transition-table decision for the given action, narrowed to the * actions that action group can actually produce: * - "apply"/"re-apply"/"re-add" → writer decisions (write / preserve-user-edit) * - "reduce"/"reset" → cleanup decisions (retain / remove / restore / ghost-drop) * This is the ONLY place `codex-native` derives a profile decision — the table * is the source of truth. The actor is derived from the classified state. */ declare function lookupProfileDecision(priorRecord: CodexAgentProfileRecord | undefined, live: string | null, action: "apply" | "re-apply" | "re-add" | "reduce" | "reset"): CodexProfileDecision; /** Merges the managed plugin into the repo/team Codex marketplace. */ export declare function mergeCodexPluginMarketplace(filePath: string): Promise; /** Removes all Codex-native files installed by agent-harness. */ export declare function resetCodexNativeHost(workspaceRoot: string, textFileSnapshots: ManagedTextFileSnapshot[] | undefined): Promise; /** * Test-only surface for the snapshot-restore guard helpers + ownership * classification. The underlying filesystem ops are injectable so each error * arm (ENOENT / ENOTDIR / other) is driven deterministically on every OS — * Windows surfaces these differently in real fs calls (ENOENT under a * file-path), so injection is the only platform-independent way to cover the * ENOTDIR branches (platform-isolation doctrine). */ export declare const codexNativeInternals: { readSnapshotTextOrNull: typeof readSnapshotTextOrNull; removePathIfReachable: typeof removePathIfReachable; listCodexAgentProfileFileNames: typeof listCodexAgentProfileFileNames; pruneEmptyApplyParents: typeof pruneEmptyApplyParents; codexAgentProfileFileName: typeof codexAgentProfileFileName; lookupProfileDecision: typeof lookupProfileDecision; }; export {};