antigravity-codex-subagent
Health Uyari
- License — License: NOASSERTION
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Low visibility — Only 6 GitHub stars
Code Basarisiz
- os.homedir — User home directory access in mcp/codex-client.mjs
- process.env — Environment variable access in mcp/codex-client.mjs
- exec() — Shell command execution in mcp/codex-wire.mjs
- exec() — Shell command execution in mcp/disk-job-store.mjs
- exec() — Shell command execution in mcp/local-path-guard.mjs
- process.env — Environment variable access in mcp/server.mjs
- process.env — Environment variable access in mcp/session-store.mjs
- process.env — Environment variable access in mcp/subprocess-adapter.mjs
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
Persistent Codex subagent MCP plugin for Antigravity over the official @openai/codex app-server v2 protocol
Antigravity Codex Subagent (v0.5.0)
English | 简体中文
Standalone Node.js stdio MCP server & Antigravity MCP App plugin for Antigravity that delegates tasks to an independent OpenAI Codex subagent over the official @openai/codex app-server --stdio JSON-RPC v2 protocol — complete with a built-in Codex Default Settings sidebar panel (Global view) synced bidirectionally with ~/.codex/config.toml.
Supports persistent multi-turn threads (sessionKey / threadId), live telemetry & progress reporting, mid-turn steering (steer), protocol-level sandbox switching (read-only / workspace-write / danger-full-access), multimodal local image inputs, JSON Schema outputSchema, MCP notifications/progress, in-place context compaction (compact), thread branching (fork), crash/restart recovery, and an opt-in warm worker pool.
Prerequisites
- Node.js
>= 20.0.0 - Codex CLI (
@openai/codex) installed globally or locally inside this plugin directory:npm install -g @openai/codex - Codex Authentication: run
codex login(or configureOPENAI_API_KEY/~/.codex/config.toml).
Installation (Antigravity)
- Clone this repository into Antigravity's plugins directory as
codex-subagent:- macOS / Linux:
git clone https://github.com/Kiraliang954321/antigravity-codex-subagent.git ~/.gemini/config/plugins/codex-subagent - Windows (PowerShell):
git clone https://github.com/Kiraliang954321/antigravity-codex-subagent.git "$env:USERPROFILE\.gemini\config\plugins\codex-subagent"
- macOS / Linux:
- (Optional) Customize
mcp_config.jsonif you want to overrideCODEX_MODEL,CODEX_WARM_IDLE_MS,CODEX_WRAPPER_PATH, or forward proxy variables (HTTP_PROXY,HTTPS_PROXY,ALL_PROXY,NO_PROXY). - Reload plugins in Antigravity so the
codex-subagentMCP server and its bundledskills/codex-subagent/SKILL.mdare registered.
Provided MCP Tools
subagent_codex: Delegate a coding, review, or analysis task to an independent Codex subagent via@openai/codex app-server --stdio. Supports:- Ephemeral or persistent multi-turn threads (
sessionKey/threadId) withexcludeTurns: trueresume optimization. - Protocol-level sandbox & permission switching via
sandbox("read-only","workspace-write","danger-full-access") andpermissionMode("never","read-only","approve-for-me","dangerously-bypass-approvals-and-sandbox"), with fail-closedread-onlyenforcement. - Multimodal local image inputs via
images(localImageblocks validated upfront up to 10 images / 20MB each before acquiring a lease). - Structured output constraints via JSON Schema
outputSchema(action: "run"). - Context window usage footer (
[codex-thread threadId=... resumed=... tokens=<used>/<window> (<pct>%)]) with automatic[CONTEXT_WARNING]at>= 80%utilization. - Thread lifecycle operations: in-place compaction (
action: "compact"), thread branching (action: "fork"withtargetSessionKeyand optionallastTurnId), and archiving (action: "close").
- Ephemeral or persistent multi-turn threads (
subagent_codex_wait: Continue waiting for, steer (steer+ optionalimages), or cancel a background Codex job whensubagent_codexreturnsstatus: "running"with ajobIdand livetelemetry(turnId,phase,lastActivityAt, monotonicidleMs,currentActivity,activeCount, 5-itemrecentActivitiesring buffer,plan,diffSummary,tokenUsage). Unclaimed settled job receipts are atomically persisted to an isolated per-store directory (data/jobs/<store>-<hash>/<jobId>.json, 30-minute TTL) so results survive MCP server restarts. Also emits throttled MCPnotifications/progresswhen_meta.progressTokenis supplied.subagent_codex_list_sessions: Inspect persistent Codex threads (sessions, includingusedandcontextWindow) and active or unclaimed background jobs (activeJobs, including live telemetry and disk-persisted unclaimed receipts).subagent_codex_settings: Open the built-in Antigravity MCP App Codex Default Settings panel (ui://codex-subagent/settings.html), also launchable directly from Antigravity's Left Sidebar (Codex Subagent). Powered by two app-only tools (codex_ui_get_settings,codex_ui_update_settings) hidden from the model (visibility: ["app"]) so UI reads and writes never consume model context.
Codex Default Settings Panel
Open Codex Subagent from Antigravity's left sidebar to configure global Codex defaults in one place:
- Bidirectional
~/.codex/config.tomlSync: Reads and updatesmodelandmodel_reasoning_effortdirectly via Codex'sconfig/readandconfig/batchWriteRPCs so changes apply to both subsequentcodex-subagentruns (and evict stale warm workers) and Codex CLI/Desktop itself. - Synced Model & Effort Catalog: Fetches available Codex models (
model/list) and dynamically shows per-modelsupportedReasoningEfforts(clamping unsupported selections automatically when switching models), with a manual custom model ID toggle when needed. - Live Account Quota Bars: Fetches current account rate limits via
account/rateLimits/read, displaying remaining-percentage progress bars with continuous usage-driven color gradients and plan-aware windows (Plus shows 5-hour + weekly limits; Pro tiers omit the 5-hour limit and show weekly only). - Override Awareness: Surfaces active environment overrides (
CODEX_MODEL,CODEX_REASONING_EFFORT) or external Codex config layer overrides, adapts automatically to Antigravity dark/light themes and English/Chinese locales, and allows resetting back to Codex defaults.
Configuration (mcp_config.json env)
| Variable | Default | Description |
|---|---|---|
CODEX_MODEL |
unset (inherits ~/.codex/config.toml) |
Optional default Codex model override (resumed turns preserve their prior session model unless overridden by live settings panel or per-call model). |
CODEX_REASONING_EFFORT |
unset (inherits ~/.codex/config.toml) |
Optional default reasoning effort (none, minimal, low, medium, high, xhigh, max, ultra). |
CODEX_DEFAULT_WAIT_MS |
120000 |
Default synchronous wait window in ms before returning status: "running" (1000..150000). |
CODEX_PERMISSION_MODE |
never |
Default approval/sandbox preset (never, read-only, approve-for-me, dangerously-bypass-approvals-and-sandbox). |
CODEX_SANDBOX |
unset | Optional default sandbox override (read-only, workspace-write, danger-full-access). |
CODEX_WARM_IDLE_MS |
0 in code (180000 in default mcp_config.json) |
Opt-in warm app-server worker idle TTL in ms. When 0, each turn spawns a fresh process. When > 0, consecutive persistent turns with matching (cwd, permissionMode, sandbox, model, config) and unchanged config.toml mtime reuse the initialized worker and evict cleanly on config change, idle timeout, compact/fork, close, or shutdown. |
CODEX_EOF_GRACE_MS |
6000 |
Grace period waiting for clean child exit after closing stdin. |
CODEX_DISPOSE_GRACE_MS |
3000 |
Bounded grace period waiting after subprocess termination. |
CODEX_REQUEST_TIMEOUT_MS |
30000 |
Per-RPC request timeout in ms (inside codex-wire.mjs). |
CODEX_TURN_TIMEOUT_MS |
unset | Optional per-turn timeout in ms. |
CODEX_SESSION_TTL_MS |
604800000 (7 days) |
Idle persistent session expiration TTL. |
CODEX_MAX_SESSIONS |
200 |
Maximum tracked persistent sessions before LRU archiving. |
CODEX_SESSION_STORE_PATH |
<plugin>/data/codex-subagent-sessions.json |
Isolated session registry path (jobs/ sibling directory stores unclaimed settled job receipts). Keep separate from other harnesses sharing the same filename pattern to avoid .lock contention. |
CODEX_WRAPPER_PATH |
auto-resolved | Optional explicit path to @openai/codex/bin/codex.js (auto-resolves from local node_modules, standard global npm directories, or optional DSH profile). |
CODEX_ANCHOR_PATH |
unset | Optional directory anchor searched when resolving @openai/codex. |
CODEX_HOME |
unset | Optional Codex home directory override. |
CODEX_SETTINGS_HTML |
<plugin>/ui/dist/settings.html |
Optional file path override for the MCP App Settings UI HTML (re-read live on resources/read when mtime/size changes). |
HTTP_PROXY / HTTPS_PROXY / ALL_PROXY / NO_PROXY |
unset (inherits environment) | Optional proxy settings forwarded to the spawned codex app-server child. |
Architecture
mcp/server.mjs: MCP stdio JSON-RPC server, MCP App settings resource/entrypoint handlers (ui://), tool schemas, job lifecycle, telemetry aggregation, and warm worker coordination.mcp/codex-wire.mjs:@openai/codex app-server --stdioJSON-RPC v2 framing, activity/delta heartbeats, plan/diff coalescing, config/model RPCs, and turn/thread RPC methods.mcp/codex-client.mjs: Subprocess lifecycle,@openai/codexbinary resolution, bidirectional Codex config/model catalog sync, thread config assertions, rollout JSONL validation, warm worker pool,compact, andfork.mcp/session-store.mjs: Persistent session registry with exclusive.lockfencing, uncertain reconciliation coordination, and atomic fork/lease transactions.mcp/disk-job-store.mjs: Per-store isolated disk job receipts and atomic single-claim recovery across MCP restarts.mcp/local-path-guard.mjs: Path/reparse/UNC/device/network-drive guards and multimodallocalImagevalidation.mcp/subprocess-adapter.mjs: Cross-platform subprocess spawn/drain/tree-termination adapter (taskkill /T /Fon Windows).ui/: Frontend MCP App built with@modelcontextprotocol/ext-appsand bundled viaesbuildinto self-contained single-fileui/dist/settings.html(zero runtime npm dependencies required).
Testing
Run offline unit, protocol, concurrency, and mock-MCP tests (no network or Codex login required):
npm run test:unit
Rebuild the single-file MCP App bundle (ui/dist/settings.html) when developing under ui/src/ (requires devDependencies via npm install):
npm run build:ui
Run the full automated suite (includes live @openai/codex E2E tests — requires an authenticated @openai/codex installation and network access):
npm test
Resilience & Safety
- Registry Isolation: Keeps its own registry at
data/codex-subagent-sessions.json(and unclaimed job receipts underdata/jobs/) with an exclusive.lockfile so concurrent harnesses never collide. - Uncertain Thread Reconciliation: Interrupted threads left in
state: "uncertain"after a crash or restart are probed read-only viathread/read+ rollout JSONL validation (non-blocking background startup sweep with a 15-second budget, plus on-demand recovery inacquire()/acquireFork()), restoring intact threads toready, cleaning archived/missing entries, and preservinguncertainon corrupt rollouts,systemError, or transient timeouts. - Windows Process-Tree Teardown & Local-Path Guard: Subprocess termination executes
taskkill /pid <pid> /T /Fand waits for process-tree exit before allowing archive or worker replacement. Windows drive-type checks usefsutil fsinfo drivetypewith PowerShell[System.IO.DriveInfo]fallback, rejecting UNC, device namespaces (\\?\,\\.\), mapped network drives, and remote reparse points before touching target paths.
Acknowledgements
Portions of the @openai/codex app-server protocol client lifecycle and subprocess drain design were inspired by @deepseek-ai/dsh-subagent-codex (MIT License).
License
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi