aiwg
Version:
Deployment tool and support utility for AI context. Copies agents, skills, commands, rules, and behaviors into the paths each AI platform reads (Claude Code, Codex, Copilot, Cursor, Warp, OpenClaw, and 6 more) so one source of truth works across 10 platfo
70 lines • 2.9 kB
TypeScript
/**
* Codex Per-Profile Runtime-Home Adapter
*
* Codex has no native per-session config flag (unlike `claude --mcp-config`).
* This adapter implements the sysops `codex-role.sh` pattern:
*
* 1. Create ~/.codex/roles-runtime/<profile>/ per profile
* 2. Symlink shared state (history, sessions) into the runtime home
* 3. Write a profile-scoped config.toml (stripped global MCP, only profile servers)
* 4. Launch with HOME=<runtime-home> codex
* 5. Auth flows execute against the runtime home — OAuth tokens are isolated per profile
*
* Reference: roctinam/sysops:scripts/mcp-roles/codex-role.sh
*
* @implements #892
*/
import { type SpawnSyncReturns } from 'child_process';
import type { McpServerDefinition } from '../registry.js';
export interface RuntimeHomeInfo {
profile: string;
path: string;
exists: boolean;
hasConfig: boolean;
hasOrphanedAuth: boolean;
}
export interface SharedStatePolicy {
/** Files/dirs to symlink from the global codex home (shared across profiles) */
shared: string[];
/** Files/dirs that are profile-isolated (not symlinked) */
isolated: string[];
}
declare const DEFAULT_SHARED_STATE: SharedStatePolicy;
/**
* Ensure the runtime home directory exists for a profile.
* Creates the directory and sets up shared-state symlinks.
* Returns the runtime home path.
*/
export declare function ensureRuntimeHome(profile: string, policy?: SharedStatePolicy): Promise<string>;
/**
* Write a profile-scoped config.toml into the runtime home.
* Strips all [mcp_servers.*] blocks from any existing global config.toml
* and writes only the profile's servers.
*/
export declare function writeProfileConfig(profile: string, servers: McpServerDefinition[]): Promise<void>;
/**
* Launch Codex with a profile's runtime home.
* Sets HOME=<runtime-home> so Codex reads its profile-scoped config and
* OAuth tokens are written to the runtime home (isolated from other profiles).
*/
export declare function launchWithProfile(profile: string, extraArgs?: string[]): SpawnSyncReturns<Buffer>;
/**
* Run `codex login` within a profile's runtime home to isolate OAuth tokens.
*/
export declare function loginInProfile(profile: string): Promise<void>;
/**
* List all runtime homes (one per profile that has been set up).
*/
export declare function listRuntimeHomes(): Promise<RuntimeHomeInfo[]>;
/**
* Remove a profile's runtime home (destructive — deletes auth tokens).
* Returns false if the home does not exist.
*/
export declare function removeRuntimeHome(profile: string): Promise<boolean>;
/**
* Detect orphaned runtime homes: runtime homes where the corresponding
* MCP profile no longer exists in the profile registry.
*/
export declare function detectOrphanedRuntimes(knownProfiles: string[]): Promise<RuntimeHomeInfo[]>;
export { DEFAULT_SHARED_STATE };
//# sourceMappingURL=codex-runtime.d.ts.map