import { type RuntimeProcess } from "./process.js"; import { type ProductProfile } from "./profile.js"; import { type CodexHookConfig } from "./codex-hook-state.js"; export type CodexSteerAction = "enable" | "disable" | "status"; export type CodexSteerResult = { status: "ready" | "disabled" | "restart_required" | "unsupported" | "failed"; reason_code?: string; }; export declare function codexHookCommand(node: string, hook: string, directory: string, platform?: NodeJS.Platform, powershell?: () => string): string; /** hooks.jsonの書き換えで位置が動く他のhook。Codexは承認を「ファイル:イベント:まとまり:番号」の鍵で持つ。 */ export type CodexHookMove = { event: string; from: [number, number]; to: [number, number] | null; }; export type CodexHookPlan = { target: string; current: any; next: any; changed: boolean; moves: CodexHookMove[]; owned: { event: string; at: [number, number]; }[]; }; /** 自製品のhookを置換・解除した後のhooks.jsonと、他のhookの位置の動きを計算する(書き込まない)。 */ export declare function planCodexParentHooks(file: string, command: string | null, previousCommand?: string): CodexHookPlan; export declare function writeCodexHookPlan(profile: ProductProfile, plan: CodexHookPlan): boolean; export declare function mergeCodexParentHooks(profile: ProductProfile, file: string, command: string | null, previousCommand?: string): boolean; /** * 自製品のhookを書き換えて他のhookの位置が動く時、その承認(trusted_hash・enabled)を新しい位置へ写してから書き換え、 * 空いた位置の承認を消す。承認を新たに与えたり外したりはしない。位置が動かなければ公式APIを呼ばない。 */ export declare function applyCodexHookPlan(profile: ProductProfile, plan: CodexHookPlan, codexHome: string, executable: string | undefined): Promise; export type CodexSteerRuntime = { platform: string; directory: string; codex_home: string; node: string; hook: string; hookCommand?: (node: string, hook: string, directory: string) => string; findBinary: () => string; processes: () => RuntimeProcess[]; /** 製品が以前使っていた別方式の選択。新規の製品は持たない。binaryは旧方式が起動していたCodex。 */ legacy: () => { enabled: boolean; binary?: string; } | null; disableLegacy: () => Promise; verify: (config: CodexHookConfig, approve: boolean) => Promise; /** 設定を保存する前にhook directoryを整える(WindowsのACL等)。 */ prepareDirectory: (directory: string) => void; /** Windowsでhookを起動するPowerShell 7の絶対path。 */ powershell: () => string; /** processが使うCODEX_HOME。読めなければnull(その時は再起動待ちに数える)。 */ codexHomeOf: (pid: number) => string | null; }; /** * processの環境変数からCODEX_HOME(無ければHOME/.codex)を読む。Linuxの /proc だけで読める。 * macOSとWindowsは他processの環境を読めないのでnull。 */ export declare function processCodexHome(pid: number, platform?: NodeJS.Platform, read?: (file: string) => Buffer): string | null; export declare function verifyCodexHookRegistration(profile: ProductProfile, config: CodexHookConfig, approve: boolean, directory?: string): Promise; /** hookは製品が同梱するCodex hook入口(パッケージのrunCodexResultHookを呼ぶ小さなファイル)の絶対path。 */ export declare function configureCodexSteer(profile: ProductProfile, action: CodexSteerAction | undefined, overrides: Partial & { hook: string; }): Promise;