codex-computer-use-mcp 0.3.0 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/ARCHITECTURE.md CHANGED
@@ -61,7 +61,7 @@ The relevant construction difference is the macOS responsible-process chain:
61
61
  - unsupported: ad-hoc/no-Team-ID Node parent → signed helper;
62
62
  - supported: Node/Pi → strict-valid OpenAI-signed app-bundled Codex (`2DC432GLL2`) → strict-valid OpenAI-signed helper (`2DC432GLL2`).
63
63
 
64
- Process sampling confirmed the helper children were direct descendants of signed app-server; helper processes may create their own process groups. App-server and helper therefore share one private per-call cwd. Cleanup preserves partial ancestry results, recovers any reparented process by that unique cwd, freezes the owned set to stability, then kills and verifies every process rather than assuming one PGID. Enumeration, freeze, or exit uncertainty fails cleanup closed. The app-server has the expected sandbox/application-group entitlement keys; the helper has OpenAI application/team identifiers, application groups, and keychain-access-group entitlements. Ordinary Node has no Team ID or entitlement set. The service's peer audit token is not exposed through the supported MCP layer. No private socket inspection, identity spoofing, copied signing material, re-signing, injection, or TCC change was attempted. The remaining enforcement boundary is therefore OS peer/responsible-process identity, not a missing public JSON field.
64
+ Process sampling confirmed the helper children were direct descendants of signed app-server; helper processes may create their own process groups. App-server and helper therefore share one private broker-session cwd. One-shot MCP calls close that session after the call; Pi retains it only across the required `get_app_state` and following action. Cleanup preserves partial ancestry results, recovers any reparented process by that unique cwd, freezes the owned set to stability, then kills and verifies every process rather than assuming one PGID. Enumeration, freeze, or exit uncertainty fails cleanup closed. The app-server has the expected sandbox/application-group entitlement keys; the helper has OpenAI application/team identifiers, application groups, and keychain-access-group entitlements. Ordinary Node has no Team ID or entitlement set. The service's peer audit token is not exposed through the supported MCP layer. No private socket inspection, identity spoofing, copied signing material, re-signing, injection, or TCC change was attempted. The remaining enforcement boundary is therefore OS peer/responsible-process identity, not a missing public JSON field.
65
65
 
66
66
  Command, environment, cwd, and config differences were also isolated: both paths invoke the same signed helper with `mcp`; the accepted path gives it a signed parent plus a private fixed cwd/config environment. Matching public MCP fields did not alter the raw error, while the signed-parent path succeeds without model credentials.
67
67
 
@@ -94,7 +94,7 @@ nested prompts or result summaries
94
94
 
95
95
  | Released wrapper restriction | Classification | Direct design |
96
96
  |---|---|---|
97
- | Fixed ChatGPT/Codex/client paths | **official-required** | retained and verified |
97
+ | Reviewed ChatGPT/Codex/client paths | **official-required** | current per-user installed-component contract plus exact legacy plugin layout; canonicalized and verified |
98
98
  | Strict signatures and OpenAI Team ID | **security-essential** | retained |
99
99
  | Signed-parent/responsible-process chain | **official-required** | retained through signed app-server |
100
100
  | Private Sky socket/native-pipe access | **unsupported/private** | prohibited |
@@ -119,7 +119,7 @@ nested prompts or result summaries
119
119
  | Automatic background app launch | **accidental** | removed; the official tool owns app behavior |
120
120
  | Global focus watcher and final sample | **security-essential detection** | retained |
121
121
  | Timeout/cancellation process-tree termination | **security-essential** | retained with strict enumeration, freeze, kill, stdio-close, and exit verification |
122
- | Per-call temporary worker cleanup | **security-essential** | retained with isolated `CODEX_HOME` |
122
+ | Temporary broker-session cleanup | **security-essential** | retained with isolated `CODEX_HOME`; Pi closes after the inspection-action pair, replacement inspection, or session shutdown |
123
123
  | Codex token usage accounting | **compatibility-only** | removed; no model turn exists |
124
124
  | Content-safe private audit | **security-essential** | retained with direct-call fields |
125
125
  | Full-result spill files | **unsafe/accidental** | prohibited; truncation is in-memory only |
@@ -133,11 +133,13 @@ App-server is created with `approvalPolicy: "never"` and `sandbox: "danger-full-
133
133
 
134
134
  The broker still handles any `mcpServer/elicitation/request` that app-server emits. Pi advertises OpenAI-form support and renders emitted form, OpenAI-form, and URL requests. Generic stdio MCP forwards supported standard modes as `elicitation/create`. The response path preserves `accept`, `decline`, `cancel`, structured content, and response metadata; no callback or compatible UI yields `cancel`, never an invented decision.
135
135
 
136
- ## Pi tool disclosure boundary
136
+ ## Pi tool and session boundary
137
137
 
138
- The Pi extension registers all ten official definitions. On `session_start` it preserves active tools owned by Pi and other extensions, keeps `computer_use_list_apps` and `computer_use_get_app_state` active, and removes only the eight Computer Use interaction definitions from the initial active set. After a successful `get_app_state` result, it additively activates those eight definitions without removing any currently active tool.
138
+ The Pi extension registers and activates all ten official definitions on `session_start`, additively preserving active tools owned by Pi and other extensions. Keeping inspection and interaction methods on the same direct surface avoids provider-bound tool discovery creating a second, incompatible client binding.
139
139
 
140
- This is context disclosure, not a wrapper permission gate. The schemas, execution path, and no-permissions policy do not change. Loader and interaction definitions remain registered throughout the session. The interaction definitions omit `promptSnippet` and `promptGuidelines`, allowing Pi 0.80.7's native deferred-loading representation to add schemas at the tool-result position without changing the system-prompt prefix. Providers without native support use Pi's next-request fallback.
140
+ For `get_app_state`, Pi starts one verified zero-turn app-server runtime and signed Computer Use client. The following direct interaction is serialized through that same runtime and thread, preserving the official active-app lease. The retained process tree is closed and verified after the action, before a replacement inspection, or during `session_shutdown`. One-shot MCP calls still start and close a broker session within the call. Exact inventory and schemas are revalidated before every dispatch in either path.
141
+
142
+ This lifecycle changes neither the schemas nor the no-permissions policy. Interaction definitions omit extra `promptSnippet` and `promptGuidelines` metadata and rely on their official descriptions.
141
143
 
142
144
  ## Output boundary
143
145
 
package/CONTRIBUTING.md CHANGED
@@ -23,7 +23,7 @@ Development and live acceptance require macOS and the official ChatGPT Computer
23
23
  - Add a regression test for every protocol, policy, focus, cleanup, or audit fix.
24
24
  - Never log or persist arguments, typed values, screenshots, app-state/result content, elicitation contents, prompts, credentials, or tokens.
25
25
  - Treat focus checks as post-action detection rather than preventive isolation.
26
- - Document fixed ChatGPT bundle paths and upstream schema/API assumptions.
26
+ - Document reviewed ChatGPT component paths, launcher contracts, and upstream schema/API assumptions.
27
27
  - Include strict core/Pi type checks, tests, build, audit, package inspection, and real-app acceptance evidence.
28
28
  - Obtain independent exact-head review for security-boundary changes.
29
29
 
package/MIGRATION.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Migration and rollback
2
2
 
3
- Version 0.2.0 was the breaking direct-tool architecture change from version 0.1.0. Version 0.3.0 keeps that exact ten-tool contract and adds Pi 0.80.7 progressive disclosure. Use the relevant section below.
3
+ Version 0.2.0 was the breaking direct-tool architecture change from version 0.1.0. Version 0.3.0 added Pi progressive disclosure, version 0.3.1 followed ChatGPT's current per-user Computer Use component layout, and version 0.3.2 restores one complete direct Pi surface with shared inspection-action session continuity. Use the relevant section below.
4
4
 
5
5
  ## What changes
6
6
 
@@ -77,6 +77,29 @@ The MCP contract and signed execution path do not change. The native Pi extensio
77
77
 
78
78
  The change is context disclosure, not a permission mode. Codex Full access, emitted elicitation forwarding, schemas, and the no-permissions policy remain unchanged.
79
79
 
80
+ ## Upgrade from version 0.3.0 to 0.3.1
81
+
82
+ ChatGPT 26.721 moved the signed Computer Use app out of the bundled plugin and into `~/.codex/computer-use/`. Version 0.3.1 follows the official launcher contract while retaining the exact former plugin layout as a compatibility candidate.
83
+
84
+ 1. Verify that npm resolves `codex-computer-use-mcp@0.3.1` exactly, then install that exact package.
85
+ 2. Start a fresh Pi process. A running Pi process retains the already-loaded extension code.
86
+ 3. Verify `/computer-use-status` reports `brokerVerified: true`.
87
+ 4. While the Mac is unlocked, run `computer_use_list_apps` and `computer_use_get_app_state` against a benign real app.
88
+
89
+ The resolver does not read `HOME` or `CODEX_HOME` and has no arbitrary path override. Missing, symlinked, invalidly signed, or wrong-Team-ID clients fail closed.
90
+
91
+ ## Upgrade from version 0.3.1 to 0.3.2
92
+
93
+ Version 0.3.2 activates all ten direct Pi tools at session start and retains one verified signed-client session across `get_app_state` and the following action.
94
+
95
+ 1. Verify that npm resolves `codex-computer-use-mcp@0.3.2` exactly, then install that exact package.
96
+ 2. Start a fresh Pi process; do not rely on hot reload for the retained process lifecycle.
97
+ 3. Verify all ten `computer_use_*` tools are active through the direct extension binding.
98
+ 4. With an unlocked Mac and a benign background app, call `computer_use_get_app_state`, then one harmless interaction against the same app.
99
+ 5. Verify the state and action used one app-server runtime/thread, the action did not report an inactive Computer Use session, focus remained preserved, and cleanup completed.
100
+
101
+ The exact schemas, strict signature and OpenAI Team ID checks, canonical client and app resolution, Full access policy, zero-turn attestation, inventory validation, kernel lock, focus telemetry, process-tree cleanup, and content-safe audit remain mandatory.
102
+
80
103
  ## Rollback
81
104
 
82
105
  1. Stop the current Pi process.
@@ -91,4 +114,4 @@ Direct state can be removed only after rollback evidence is captured and no proc
91
114
 
92
115
  ## Generic MCP gateway
93
116
 
94
- If Pi uses `mcp.json`, retain `directTools: false`. Use the exact `0.3.0` package shown in `integrations/pi/mcp.json.example`. During source acceptance, use a distinct temporary server name and source path, then remove it. The direct Pi adapter is the primary live path; do not leave the version 0.1 aggregate server active after the switch.
117
+ If Pi uses `mcp.json`, retain `directTools: false`. Use the exact `0.3.2` package shown in `integrations/pi/mcp.json.example`. During source acceptance, use a distinct temporary server name and source path, then remove it. The direct Pi adapter is the primary live path; do not leave the version 0.1 aggregate server active after the switch.
package/PROOF.md CHANGED
@@ -49,7 +49,9 @@ The public OpenAI source basis and permanent links are in `ARCHITECTURE.md`.
49
49
  Current branch tests cover:
50
50
 
51
51
  - strict TypeScript for core and Pi adapter;
52
- - fixed-path strict signature and Team ID checks;
52
+ - current ChatGPT per-user component resolution plus exact legacy-layout compatibility;
53
+ - missing, symlinked-path, invalid-signature, and wrong-Team-ID resolution failures, including no fallback from a present invalid current client;
54
+ - strict signature and Team ID checks;
53
55
  - exact official ten-tool inventory/schema drift rejection before dispatch;
54
56
  - direct JSONL request sequence with no `turn/start`;
55
57
  - isolated credential-free `CODEX_HOME` even when the parent environment contains a model API key;
@@ -74,8 +76,8 @@ Current branch tests cover:
74
76
  - signed app-server elicitation forwarding, exact user responses, headless cancellation, and cancellation while a UI callback is pending;
75
77
  - standard form/URL forwarding across a real MCP SDK client/server transport;
76
78
  - Pi source registration for every direct capability with no nested planner, permission command, or wrapper-generated approval UI;
77
- - Pi session-start disclosure of only the two inspection definitions while preserving unrelated active tools;
78
- - purely additive activation of all eight interaction definitions after successful `get_app_state`, with no lazy-tool prompt metadata;
79
+ - Pi session-start registration and activation of all ten direct definitions while preserving unrelated active tools;
80
+ - one retained broker/client session across `get_app_state` and the following action, with deterministic active-app lease continuity and verified close;
79
81
  - Pi form, opaque OpenAI-form, URL, decline, and headless-cancel elicitation handling.
80
82
 
81
83
  ## Official Full access approval probe
@@ -117,7 +119,10 @@ Evidence:
117
119
 
118
120
  Earlier exploratory attempts exposed and fixed two acceptance-quality issues rather than being counted as proof: common `CMD+A` needed normalization to the official `Meta_L+a` key form, and TextEdit state restoration had to be reset before a fresh run. The final evidence above is from the corrected direct path.
119
121
 
120
- ## Pi 0.80.7 progressive-disclosure measurement
122
+ ## Historical Pi 0.80.7 progressive-disclosure measurement
123
+
124
+ This measurement describes version 0.3.0 and 0.3.1. Version 0.3.2 intentionally supersedes progressive disclosure because it could leave direct interaction tools absent or make a provider-discovered interaction use a different client from direct `get_app_state`.
125
+
121
126
 
122
127
  A fresh Pi 0.80.7 process loaded only the source Computer Use extension plus a read-only observer. All ten definitions were registered. The initial active Computer Use set was exactly:
123
128
 
@@ -128,7 +133,7 @@ Serializing names, descriptions, schemas, and prompt guidelines measured 6,063 b
128
133
 
129
134
  A second fresh process exercised the exported activation path from inside a tool execution. Pi's tool result recorded the exact eight interaction names in `addedToolNames`; the before/after active sets retained both inspection tools and removed zero tools. The lazily activated definitions had no `promptSnippet` or `promptGuidelines`.
130
135
 
131
- With `openai-codex/gpt-5.6-sol`, the first request reported 5,723 uncached input tokens. The immediately following request after additive activation reported 1,008 uncached input tokens and 5,632 cache-read tokens. This is live provider evidence that the initial prefix remained reusable while Pi inserted the eight definitions at the tool-result load point. The activation probe used the same `activateInteractionTools` function called after a successful production `get_app_state`; automated tests bind that successful-result branch and exact additive set.
136
+ With `openai-codex/gpt-5.6-sol`, the first request reported 5,723 uncached input tokens. The immediately following request after additive activation reported 1,008 uncached input tokens and 5,632 cache-read tokens. This was live provider evidence that the initial prefix remained reusable while Pi inserted the eight definitions at the tool-result load point. Version 0.3.2 removes that activation path in favor of complete direct registration and signed-client session continuity.
132
137
 
133
138
  ## Review and release status
134
139
 
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Codex Computer Use MCP
2
2
 
3
- Version 0.3.0 exposes the official signed macOS Computer Use capabilities as direct typed tools for Pi and MCP clients. The calling agent chooses every tool and argument itself.
3
+ Version 0.3.2 exposes the official signed macOS Computer Use capabilities as direct typed tools for Pi and MCP clients. The calling agent chooses every tool and argument itself.
4
4
 
5
5
  The primary path has:
6
6
 
@@ -12,7 +12,7 @@ The primary path has:
12
12
 
13
13
  It does use OpenAI's signed `codex app-server` as the official host for the bundled Computer Use MCP client. The current official `mcpServer/tool/call` API requires a loaded thread identifier, so the bridge creates an empty, in-memory, zero-turn context (`ephemeral: true`, `turns: []`, `path: null`). It never calls `turn/start` and fails closed if any `turn/*` or `item/*` model activity appears.
14
14
 
15
- > **Independent project.** This is not an OpenAI product and is not endorsed by OpenAI. The app-server API is marked experimental and fixed ChatGPT bundle paths may change.
15
+ > **Independent project.** This is not an OpenAI product and is not endorsed by OpenAI. The app-server API is marked experimental and ChatGPT's reviewed component locations may change.
16
16
 
17
17
  ## Direct tools
18
18
 
@@ -33,9 +33,9 @@ Pi registers namespaced tools to avoid collisions with Pi's built-ins. The MCP s
33
33
 
34
34
  The MCP façade preserves the official signed helper's tool descriptions, input schemas, and annotations exactly. The Pi façade preserves its descriptions and input schemas; Pi's tool API does not expose MCP annotations. In particular, all ten MCP methods have `destructiveHint: false`; the wrapper does not conflate changing UI state with destructive behavior or add argument restrictions absent from the official schemas.
35
35
 
36
- Pi 0.80.7 and newer registers all ten definitions but initially activates only `computer_use_list_apps` and `computer_use_get_app_state`. A successful `get_app_state` call additively activates the eight interaction definitions for the following model request. Other active Pi and extension tools remain active. The lazily activated tools omit `promptSnippet` and `promptGuidelines`, allowing Pi's native deferred-loading path to preserve the stable system-prompt prefix.
36
+ Pi registers and activates all ten definitions together in every fresh session, while preserving active tools owned by Pi and other extensions. This prevents interaction methods from being absent or loaded through an incompatible provider binding.
37
37
 
38
- As the official contract specifies, Pi—not a nested planner—calls `computer_use_get_app_state` once per assistant turn before interacting with an app, then chooses and executes actions itself.
38
+ As the official contract specifies, Pi—not a nested planner—calls `computer_use_get_app_state` once per assistant turn before interacting with an app, then chooses and executes actions itself. The adapter retains one verified app-server runtime and signed Computer Use client for that inspection-action pair, so the action reuses the official active-app session established by `get_app_state`. It closes and verifies the retained process tree after the action, when a new inspection supersedes it, or on Pi session shutdown.
39
39
 
40
40
  ## Authorization policy: durable no-permissions
41
41
 
@@ -67,24 +67,26 @@ See [`ARCHITECTURE.md`](ARCHITECTURE.md) for source links and the full restricti
67
67
 
68
68
  - macOS
69
69
  - Node.js 22 or newer
70
- - Pi 0.80.7 or newer for native progressive tool disclosure
70
+ - Pi 0.80.7 or newer
71
71
  - official ChatGPT macOS app at `/Applications/ChatGPT.app`
72
- - official Computer Use component installed
72
+ - official Computer Use component installed by ChatGPT under `~/.codex/computer-use/`
73
+
74
+ The bridge follows ChatGPT's current launcher contract for `SkyComputerUseClient` under that per-user component directory. It does not honor `HOME`, `CODEX_HOME`, or an arbitrary path override when resolving the production client. The former exact app-in-plugin layout remains a strict compatibility candidate only when the current component is absent. Every selected client must be at a canonical reviewed path, pass strict code-signature verification, and carry OpenAI Team ID `2DC432GLL2`.
73
75
 
74
76
  The direct bridge starts app-server with a new private `CODEX_HOME` containing no account credentials and only one configured MCP server: official Computer Use. It does not inherit the user's Codex MCP servers, plugins, history, memories, API keys, or auth file. It selects a non-websocket dummy model provider bound to unreachable loopback, disables plugin/remote-control features, and never starts a turn; this prevents app-server model prewarm or Responses API traffic.
75
77
 
76
78
  ### Locked-screen limitation
77
79
 
78
- Version 0.3.0 supports direct local calls in an unlocked macOS session. It does not support window or accessibility actions after the Mac locks.
80
+ Version 0.3.2 supports direct local calls in an unlocked macOS session. It does not support window or accessibility actions after the Mac locks.
79
81
 
80
- OpenAI's [locked Computer Use](https://developers.openai.com/codex/app/computer-use#use-computer-use-while-your-mac-is-locked) is limited to active, trusted ChatGPT turns started from a connected device. It does not authorize other apps or local processes to unlock the Mac. This package uses local zero-turn dispatch, so targeted calls can fail with official error `-10005` while the Mac is locked. Support for locked local use remains a follow-up and is not part of version 0.3.0.
82
+ OpenAI's [locked Computer Use](https://developers.openai.com/codex/app/computer-use#use-computer-use-while-your-mac-is-locked) is limited to active, trusted ChatGPT turns started from a connected device. It does not authorize other apps or local processes to unlock the Mac. This package uses local zero-turn dispatch, so targeted calls can fail with official error `-10005` while the Mac is locked. Support for locked local use remains a follow-up and is not part of version 0.3.2.
81
83
 
82
84
  ## Pi integration
83
85
 
84
86
  Install the exact release from npm:
85
87
 
86
88
  ```bash
87
- pi install npm:codex-computer-use-mcp@0.3.0
89
+ pi install npm:codex-computer-use-mcp@0.3.2
88
90
  ```
89
91
 
90
92
  To evaluate a source checkout instead:
@@ -101,7 +103,7 @@ Command:
101
103
  /computer-use-status
102
104
  ```
103
105
 
104
- The native Pi adapter is the primary product path. It registers all ten typed tools directly, starts each session with the two inspection tools active, and additively activates the eight interaction tools after successful app inspection. It exposes no mode-changing command or wrapper-generated approval UI. Official app-access approval elicitations are resolved by Codex Full access before they reach Pi. Any elicitation that app-server does emit is shown through Pi's UI, and only the user's choice is returned to the service.
106
+ The native Pi adapter is the primary product path. It registers and activates all ten typed tools directly, and routes the required `get_app_state` and following action through one retained signed-client session. It exposes no mode-changing command or wrapper-generated approval UI. Official app-access approval elicitations are resolved by Codex Full access before they reach Pi. Any elicitation that app-server does emit is shown through Pi's UI, and only the user's choice is returned to the service.
105
107
 
106
108
  ## MCP server
107
109
 
package/SECURITY.md CHANGED
@@ -18,8 +18,8 @@ This is direct tool dispatch—not model orchestration.
18
18
 
19
19
  ## Security invariants
20
20
 
21
- 1. Only fixed app-bundled Codex and Computer Use client paths are allowed in production.
22
- 2. Both binaries pass strict code-signature verification and OpenAI Team ID `2DC432GLL2` checks before dispatch.
21
+ 1. Only the fixed app-bundled Codex path and reviewed official Computer Use layouts are allowed in production. The current client is resolved from the OS account home under `~/.codex/computer-use/`; `HOME`, `CODEX_HOME`, arbitrary paths, and symlinked layouts are not accepted. The former exact plugin-bundle layout is considered only when the current component is absent.
22
+ 2. Both binaries pass strict code-signature verification and OpenAI Team ID `2DC432GLL2` checks before dispatch. A present current-layout client that fails verification never falls back.
23
23
  3. The helper's exact ten method names and input schemas match the pinned expected inventory before every call; release tests also verify its descriptions and annotations.
24
24
  4. `no-permissions` is the only wrapper policy: all ten methods are exposed and no wrapper permission prompt is opened.
25
25
  5. There is no config file, environment override, command, tool argument, per-call branch, or alternate safe/full route that an agent can select.
@@ -28,11 +28,11 @@ This is direct tool dispatch—not model orchestration.
28
28
  8. Same-app work is excluded across native Pi, generic MCP, and custom state roots with one fixed per-user kernel `lockf` lease namespace.
29
29
  9. Target focus events, periodic samples, watcher health, queued ASN resolution, and final state are checked. This is post-action detection, not a preventive OS sandbox.
30
30
  10. One direct request emits one official `mcpServer/tool/call`; no model turn, subagent, shell, web, plugin, prompt, or reachable model transport is available.
31
- 11. App-server and helper share one private per-call working directory. Cleanup combines strict ancestry enumeration (preserving partial results) with working-directory ownership recovery, freezes processes to a stable set, kills every owned process, awaits stdio closure, and verifies exit. This still finds a helper reparented by an early app-server exit; enumeration/freeze/exit uncertainty is fatal.
31
+ 11. App-server and helper share one private broker-session working directory. One-shot calls close it immediately; Pi retains it only across the required `get_app_state` and following action, then closes it after the action, before replacement inspection, or on session shutdown. Cleanup combines strict ancestry enumeration (preserving partial results) with working-directory ownership recovery, freezes processes to a stable set, kills every owned process, awaits stdio closure, and verifies exit. This still finds a helper reparented by an early app-server exit; enumeration/freeze/exit uncertainty is fatal.
32
32
  12. Protocol JSONL is bounded before an unterminated line can exceed 8 MB in memory.
33
33
  13. Per-call `CODEX_HOME` and work directories are mode-private and recursively removed.
34
34
  14. Only validated text/image result blocks cross to the invoking client. No full-result spill file is written.
35
- 15. Audits contain metadata only, including separate `brokerCleanupVerified` and `appLeaseReleased` evidence; lease-release failure changes the audited outcome before surfacing. Arguments, values, screenshots, app-state text, result content, prompts, approvals, credentials, and tokens are forbidden.
35
+ 15. Audits contain metadata only, including separate `brokerCleanupVerified` and `appLeaseReleased` evidence. A retained Pi inspection truthfully records broker cleanup as pending (`false`); the paired action does not return if final retained-session cleanup fails. Lease-release failure changes the audited outcome before surfacing. Arguments, values, screenshots, app-state text, result content, prompts, approvals, credentials, and tokens are forbidden.
36
36
  16. Policy rejections are audited; audit failure is fatal once a secure state path exists.
37
37
  17. Runtime and development dependency tarballs are exact-pinned with integrity in `npm-shrinkwrap.json`.
38
38
 
@@ -56,6 +56,6 @@ Computer Use returns the official app-state text and screenshots to the invoking
56
56
 
57
57
  ## Supported versions
58
58
 
59
- Only the latest approved release is supported. Version 0.3.0 supports direct local calls in an unlocked macOS session. Targeted local calls while the Mac is locked are not supported.
59
+ Only the latest approved release is supported. Version 0.3.2 supports direct local calls in an unlocked macOS session. Targeted local calls while the Mac is locked are not supported.
60
60
 
61
61
  App-server is experimental and bundle paths or schemas can change. Drift fails closed until reviewed.
@@ -1,7 +1,8 @@
1
1
  import { type DirectMethod, type DirectToolArguments } from "./tools.ts";
2
2
  export declare const CODEX_PATH = "/Applications/ChatGPT.app/Contents/Resources/codex";
3
3
  export declare const COMPUTER_USE_PLUGIN_ROOT = "/Applications/ChatGPT.app/Contents/Resources/plugins/openai-bundled/plugins/computer-use";
4
- export declare const COMPUTER_USE_CLIENT_PATH = "/Applications/ChatGPT.app/Contents/Resources/plugins/openai-bundled/plugins/computer-use/Codex Computer Use.app/Contents/SharedSupport/SkyComputerUseClient.app/Contents/MacOS/SkyComputerUseClient";
4
+ export declare const COMPUTER_USE_CLIENT_PATH: string;
5
+ export declare const LEGACY_COMPUTER_USE_CLIENT_PATH: string;
5
6
  export interface DirectBrokerElicitationRequest extends Record<string, unknown> {
6
7
  mode?: string;
7
8
  message?: string;
@@ -24,7 +25,7 @@ export interface DirectBrokerResult {
24
25
  elicitationRequests: number;
25
26
  modelTurnsStarted: 0;
26
27
  ephemeralThread: true;
27
- brokerCleanupVerified: true;
28
+ brokerCleanupVerified: boolean;
28
29
  }
29
30
  export interface DirectBrokerOptions {
30
31
  timeoutMs?: number;
@@ -63,9 +64,41 @@ export declare class DirectBrokerCallError extends Error {
63
64
  clientBuild?: string;
64
65
  });
65
66
  }
66
- export declare function verifyOfficialDirectBroker(): {
67
+ interface CommandResult {
68
+ status: number | null;
69
+ stdout?: string | Buffer;
70
+ stderr?: string | Buffer;
71
+ }
72
+ type RunSync = (command: string, args: string[]) => CommandResult;
73
+ export interface OfficialComputerUseClient {
74
+ clientPath: string;
75
+ appPath: string;
76
+ layout: "installed-component" | "legacy-plugin-bundle";
77
+ }
78
+ interface ResolveOfficialComputerUseClientOptions {
79
+ /** Test-only OS-account home override. Production never reads HOME or CODEX_HOME. */
80
+ userHome?: string;
81
+ /** Test-only legacy root override. */
82
+ legacyPluginRoot?: string;
83
+ runSync?: RunSync;
84
+ }
85
+ /** Resolve only the two reviewed official layouts, preferring ChatGPT's current installed-component contract. */
86
+ export declare function resolveOfficialComputerUseClient(options?: ResolveOfficialComputerUseClientOptions): OfficialComputerUseClient;
87
+ export declare function verifyOfficialDirectBroker(options?: ResolveOfficialComputerUseClientOptions): {
67
88
  brokerVersion: string;
68
89
  clientBuild: string;
90
+ client: OfficialComputerUseClient;
69
91
  };
70
- export declare function buildDirectAppServerArgs(mcpCwd?: string): string[];
92
+ export declare function buildDirectAppServerArgs(mcpCwd?: string, clientPath?: string): string[];
93
+ export interface OfficialDirectToolSession {
94
+ call(method: DirectMethod, args: DirectToolArguments, options?: Pick<DirectBrokerOptions, "timeoutMs" | "signal" | "onElicitation" | "supportsOpenAiFormElicitation">): Promise<DirectBrokerResult>;
95
+ close(): Promise<void>;
96
+ }
97
+ /**
98
+ * Start one verified app-server runtime and retain its signed Computer Use MCP
99
+ * client across calls. Pi uses this for the required get_app_state -> action
100
+ * sequence; one-shot callers continue to use callOfficialDirectTool below.
101
+ */
102
+ export declare function createOfficialDirectToolSession(options?: DirectBrokerOptions): Promise<OfficialDirectToolSession>;
71
103
  export declare function callOfficialDirectTool(method: DirectMethod, args: DirectToolArguments, options?: DirectBrokerOptions): Promise<DirectBrokerResult>;
104
+ export {};
@@ -1,11 +1,15 @@
1
1
  import { spawn, spawnSync } from "node:child_process";
2
2
  import { chmod, mkdir, mkdtemp, rm, writeFile } from "node:fs/promises";
3
+ import { existsSync, realpathSync } from "node:fs";
3
4
  import os from "node:os";
4
5
  import path from "node:path";
5
6
  import { EXPECTED_OFFICIAL_INPUT_SCHEMAS, OFFICIAL_METHODS, } from "./tools.js";
6
7
  export const CODEX_PATH = "/Applications/ChatGPT.app/Contents/Resources/codex";
7
8
  export const COMPUTER_USE_PLUGIN_ROOT = "/Applications/ChatGPT.app/Contents/Resources/plugins/openai-bundled/plugins/computer-use";
8
- export const COMPUTER_USE_CLIENT_PATH = `${COMPUTER_USE_PLUGIN_ROOT}/Codex Computer Use.app/Contents/SharedSupport/SkyComputerUseClient.app/Contents/MacOS/SkyComputerUseClient`;
9
+ const COMPUTER_USE_APP_RELATIVE_PATH = "computer-use/Codex Computer Use.app";
10
+ const CLIENT_RELATIVE_PATH = "Contents/SharedSupport/SkyComputerUseClient.app/Contents/MacOS/SkyComputerUseClient";
11
+ export const COMPUTER_USE_CLIENT_PATH = path.join(os.userInfo().homedir, ".codex", COMPUTER_USE_APP_RELATIVE_PATH, CLIENT_RELATIVE_PATH);
12
+ export const LEGACY_COMPUTER_USE_CLIENT_PATH = path.join(COMPUTER_USE_PLUGIN_ROOT, "Codex Computer Use.app", CLIENT_RELATIVE_PATH);
9
13
  const OPENAI_TEAM_ID = "2DC432GLL2";
10
14
  const MAX_PROTOCOL_LINE_BYTES = 8 * 1024 * 1024;
11
15
  const MAX_RESULT_BYTES = 25 * 1024 * 1024;
@@ -35,41 +39,70 @@ export class DirectBrokerCallError extends Error {
35
39
  this.clientBuild = evidence.clientBuild ?? "unknown";
36
40
  }
37
41
  }
38
- function verifySignedBinary(binaryPath) {
39
- const verify = spawnSync("/usr/bin/codesign", ["--verify", "--strict", binaryPath], {
40
- encoding: "utf8",
41
- timeout: 10_000,
42
- });
42
+ function productionRunSync(command, args) {
43
+ return spawnSync(command, args, { encoding: "utf8", timeout: 10_000 });
44
+ }
45
+ function verifySignedBinary(binaryPath, runSync) {
46
+ const verify = runSync("/usr/bin/codesign", ["--verify", "--strict", binaryPath]);
43
47
  if (verify.status !== 0)
44
48
  throw new BrokerVerificationError(`Signature verification failed for ${path.basename(binaryPath)}`);
45
- const details = spawnSync("/usr/bin/codesign", ["-dv", "--verbose=2", binaryPath], {
46
- encoding: "utf8",
47
- timeout: 10_000,
48
- });
49
+ const details = runSync("/usr/bin/codesign", ["-dv", "--verbose=2", binaryPath]);
49
50
  const output = `${details.stdout ?? ""}\n${details.stderr ?? ""}`;
50
- if (details.status !== 0 || !output.includes(`TeamIdentifier=${OPENAI_TEAM_ID}`)) {
51
+ if (details.status !== 0 || !new RegExp(`(?:^|\\n)TeamIdentifier=${OPENAI_TEAM_ID}(?:\\n|$)`).test(output)) {
51
52
  throw new BrokerVerificationError(`${path.basename(binaryPath)} is not signed by the expected OpenAI team`);
52
53
  }
53
54
  }
54
- function clientBuild() {
55
- const plist = path.join(COMPUTER_USE_PLUGIN_ROOT, "Codex Computer Use.app", "Contents", "Info.plist");
56
- const result = spawnSync("/usr/bin/plutil", ["-extract", "CFBundleVersion", "raw", plist], {
57
- encoding: "utf8",
58
- timeout: 5000,
59
- });
60
- if (result.status !== 0 || !(result.stdout ?? "").trim()) {
55
+ function checkedCandidate(appPath, clientPath, layout, runSync) {
56
+ if (!existsSync(clientPath))
57
+ return undefined;
58
+ let canonicalApp;
59
+ let canonicalClient;
60
+ try {
61
+ canonicalApp = realpathSync(appPath);
62
+ canonicalClient = realpathSync(clientPath);
63
+ }
64
+ catch {
65
+ throw new BrokerVerificationError("Could not resolve the official Computer Use client path");
66
+ }
67
+ if (canonicalApp !== path.resolve(appPath) || canonicalClient !== path.resolve(clientPath) || !canonicalClient.startsWith(`${canonicalApp}${path.sep}`)) {
68
+ throw new BrokerVerificationError("Official Computer Use client path was not canonical");
69
+ }
70
+ verifySignedBinary(canonicalClient, runSync);
71
+ return { appPath: canonicalApp, clientPath: canonicalClient, layout };
72
+ }
73
+ /** Resolve only the two reviewed official layouts, preferring ChatGPT's current installed-component contract. */
74
+ export function resolveOfficialComputerUseClient(options = {}) {
75
+ const runSync = options.runSync ?? productionRunSync;
76
+ const userHome = options.userHome ?? os.userInfo().homedir;
77
+ const canonicalUserHome = existsSync(userHome) ? realpathSync(userHome) : path.resolve(userHome);
78
+ const currentApp = path.join(canonicalUserHome, ".codex", COMPUTER_USE_APP_RELATIVE_PATH);
79
+ const current = checkedCandidate(currentApp, path.join(currentApp, CLIENT_RELATIVE_PATH), "installed-component", runSync);
80
+ if (current)
81
+ return current;
82
+ const legacyRoot = options.legacyPluginRoot ?? COMPUTER_USE_PLUGIN_ROOT;
83
+ const canonicalLegacyRoot = existsSync(legacyRoot) ? realpathSync(legacyRoot) : path.resolve(legacyRoot);
84
+ const legacyApp = path.join(canonicalLegacyRoot, "Codex Computer Use.app");
85
+ const legacy = checkedCandidate(legacyApp, path.join(legacyApp, CLIENT_RELATIVE_PATH), "legacy-plugin-bundle", runSync);
86
+ if (legacy)
87
+ return legacy;
88
+ throw new BrokerVerificationError("Official Computer Use client was not found in a supported location");
89
+ }
90
+ function clientBuild(appPath, runSync) {
91
+ const result = runSync("/usr/bin/plutil", ["-extract", "CFBundleVersion", "raw", path.join(appPath, "Contents", "Info.plist")]);
92
+ if (result.status !== 0 || !(result.stdout ?? "").toString().trim()) {
61
93
  throw new BrokerVerificationError("Could not verify the official Computer Use client build");
62
94
  }
63
- return (result.stdout ?? "").trim();
95
+ return (result.stdout ?? "").toString().trim();
64
96
  }
65
- export function verifyOfficialDirectBroker() {
66
- verifySignedBinary(CODEX_PATH);
67
- verifySignedBinary(COMPUTER_USE_CLIENT_PATH);
68
- const version = spawnSync(CODEX_PATH, ["--version"], { encoding: "utf8", timeout: 5000 });
69
- if (version.status !== 0 || !/^codex-cli\s+\d+\./.test((version.stdout ?? "").trim())) {
97
+ export function verifyOfficialDirectBroker(options = {}) {
98
+ const runSync = options.runSync ?? productionRunSync;
99
+ verifySignedBinary(CODEX_PATH, runSync);
100
+ const client = resolveOfficialComputerUseClient({ ...options, runSync });
101
+ const version = runSync(CODEX_PATH, ["--version"]);
102
+ if (version.status !== 0 || !/^codex-cli\s+\d+\./.test((version.stdout ?? "").toString().trim())) {
70
103
  throw new BrokerVerificationError("Could not verify the app-bundled Codex app-server version");
71
104
  }
72
- return { brokerVersion: (version.stdout ?? "").trim(), clientBuild: clientBuild() };
105
+ return { brokerVersion: (version.stdout ?? "").toString().trim(), clientBuild: clientBuild(client.appPath, runSync), client };
73
106
  }
74
107
  function buildBrokerEnv(codexHome, tempRoot) {
75
108
  const env = {
@@ -86,8 +119,8 @@ function buildBrokerEnv(codexHome, tempRoot) {
86
119
  }
87
120
  return env;
88
121
  }
89
- export function buildDirectAppServerArgs(mcpCwd = COMPUTER_USE_PLUGIN_ROOT) {
90
- const mcpTable = `{"computer-use" = { command = ${JSON.stringify(COMPUTER_USE_CLIENT_PATH)}, args = ["mcp"], cwd = ${JSON.stringify(mcpCwd)}, enabled = true, startup_timeout_sec = 30, tool_timeout_sec = 120 }}`;
122
+ export function buildDirectAppServerArgs(mcpCwd = COMPUTER_USE_PLUGIN_ROOT, clientPath = COMPUTER_USE_CLIENT_PATH) {
123
+ const mcpTable = `{"computer-use" = { command = ${JSON.stringify(clientPath)}, args = ["mcp"], cwd = ${JSON.stringify(mcpCwd)}, enabled = true, startup_timeout_sec = 30, tool_timeout_sec = 120 }}`;
91
124
  const disabledProvider = '{ name = "Direct dispatch disabled provider", base_url = "http://127.0.0.1:9/v1", wire_api = "responses", request_max_retries = 0, stream_max_retries = 0, supports_websockets = false, requires_openai_auth = false }';
92
125
  return [
93
126
  "-c", 'model_provider="direct_disabled"',
@@ -372,10 +405,14 @@ async function terminateGroup(proc, workDir, processEnumeratorCommand = "/usr/bi
372
405
  if (cleanupError)
373
406
  throw cleanupError;
374
407
  }
375
- export async function callOfficialDirectTool(method, args, options = {}) {
376
- const startedAt = Date.now();
408
+ /**
409
+ * Start one verified app-server runtime and retain its signed Computer Use MCP
410
+ * client across calls. Pi uses this for the required get_app_state -> action
411
+ * sequence; one-shot callers continue to use callOfficialDirectTool below.
412
+ */
413
+ export async function createOfficialDirectToolSession(options = {}) {
377
414
  const verification = options.skipSignatureVerification
378
- ? { brokerVersion: "test-app-server", clientBuild: "test-client" }
415
+ ? { brokerVersion: "test-app-server", clientBuild: "test-client", client: undefined }
379
416
  : verifyOfficialDirectBroker();
380
417
  const tempRoot = await mkdtemp(path.join(os.tmpdir(), "pi-direct-computer-use."));
381
418
  const codexHome = path.join(tempRoot, "codex-home");
@@ -387,17 +424,17 @@ export async function callOfficialDirectTool(method, args, options = {}) {
387
424
  let proc;
388
425
  let processClosed;
389
426
  let termination;
390
- let abortHandler;
391
427
  let fatalError;
392
428
  let stderr = "";
393
429
  let nextId = 1;
394
- let elicitationRequests = 0;
395
430
  let modelTurnsStarted = 0;
396
- let directCalls = 0;
397
431
  let ephemeralThread = false;
398
- let finalResult;
399
- let primaryError;
400
- let cleanupVerified = false;
432
+ let threadId = "";
433
+ let closed = false;
434
+ let closePromise;
435
+ let callActive = false;
436
+ let currentElicitation;
437
+ let currentElicitationCount = 0;
401
438
  const pending = new Map();
402
439
  const rejectAll = (error) => {
403
440
  for (const waiter of pending.values()) {
@@ -425,8 +462,9 @@ export async function callOfficialDirectTool(method, args, options = {}) {
425
462
  return new Promise((resolve, reject) => {
426
463
  const timer = setTimeout(() => {
427
464
  pending.delete(id);
428
- reject(new Error(`Official app-server request timed out: ${methodName}`));
429
- void ensureTerminated().catch(() => undefined);
465
+ const error = new Error(`Official app-server request timed out: ${methodName}`);
466
+ reject(error);
467
+ fail(error);
430
468
  }, timeoutMs);
431
469
  pending.set(id, { resolve, reject, timer });
432
470
  try {
@@ -439,9 +477,35 @@ export async function callOfficialDirectTool(method, args, options = {}) {
439
477
  }
440
478
  });
441
479
  };
480
+ const close = () => {
481
+ closePromise ??= (async () => {
482
+ closed = true;
483
+ rejectAll(new Error("Official app-server closed"));
484
+ let cleanupError;
485
+ try {
486
+ await ensureTerminated();
487
+ if (processClosed) {
488
+ await new Promise((resolve, reject) => {
489
+ const timer = setTimeout(() => reject(new Error("Official app-server stdio did not close")), 1_000);
490
+ processClosed.then(() => { clearTimeout(timer); resolve(); });
491
+ });
492
+ }
493
+ await new Promise((resolve) => setImmediate(resolve));
494
+ await rm(tempRoot, { recursive: true, force: true });
495
+ }
496
+ catch (error) {
497
+ cleanupError = error instanceof Error ? error : new Error(String(error));
498
+ }
499
+ if (cleanupError)
500
+ throw new Error("Official direct Computer Use broker cleanup failed", { cause: cleanupError });
501
+ if (fatalError || modelTurnsStarted !== 0)
502
+ throw fatalError ?? new BrokerVerificationError("Model-turn activity was observed during broker teardown");
503
+ })();
504
+ return closePromise;
505
+ };
442
506
  try {
443
507
  const command = options.appServerCommand ?? CODEX_PATH;
444
- const commandArgs = options.appServerArgs ?? buildDirectAppServerArgs(workDir);
508
+ const commandArgs = options.appServerArgs ?? buildDirectAppServerArgs(workDir, verification.client.clientPath);
445
509
  proc = spawn(command, commandArgs, {
446
510
  cwd: workDir,
447
511
  detached: true,
@@ -452,20 +516,14 @@ export async function callOfficialDirectTool(method, args, options = {}) {
452
516
  processClosed = new Promise((resolve) => proc.once("close", () => resolve()));
453
517
  if (proc.pid)
454
518
  options.onSpawn?.(proc.pid);
455
- proc.stdin.on("error", (error) => {
456
- if (error.code !== "EPIPE")
457
- fail(error);
458
- });
519
+ proc.stdin.on("error", (error) => { if (error.code !== "EPIPE")
520
+ fail(error); });
459
521
  proc.stderr.setEncoding("utf8");
460
- proc.stderr.on("data", (chunk) => {
461
- if (stderr.length < 16_384)
462
- stderr += chunk.slice(0, 16_384 - stderr.length);
463
- });
522
+ proc.stderr.on("data", (chunk) => { if (stderr.length < 16_384)
523
+ stderr += chunk.slice(0, 16_384 - stderr.length); });
464
524
  proc.once("error", (error) => fail(error));
465
- proc.once("close", (code) => {
466
- if (pending.size > 0)
467
- fail(new Error(`Official app-server exited before completing the request (${code ?? "unknown"})`));
468
- });
525
+ proc.once("close", (code) => { if (!closed && pending.size > 0)
526
+ fail(new Error(`Official app-server exited before completing the request (${code ?? "unknown"})`)); });
469
527
  const processProtocolLine = (line) => {
470
528
  let message;
471
529
  try {
@@ -500,15 +558,14 @@ export async function callOfficialDirectTool(method, args, options = {}) {
500
558
  send({ id: message.id, error: { code: -32601, message: "Unsupported server request" } });
501
559
  return;
502
560
  }
503
- elicitationRequests += 1;
561
+ currentElicitationCount += 1;
504
562
  const requestParams = message.params && typeof message.params === "object" && !Array.isArray(message.params)
505
- ? message.params
506
- : {};
563
+ ? message.params : {};
507
564
  void (async () => {
508
565
  let response = { action: "cancel" };
509
- if (options.onElicitation) {
566
+ if (currentElicitation) {
510
567
  try {
511
- const candidate = await options.onElicitation(requestParams);
568
+ const candidate = await currentElicitation(requestParams);
512
569
  if (candidate && ["accept", "decline", "cancel"].includes(candidate.action))
513
570
  response = candidate;
514
571
  }
@@ -516,11 +573,10 @@ export async function callOfficialDirectTool(method, args, options = {}) {
516
573
  response = { action: "cancel" };
517
574
  }
518
575
  }
519
- if (fatalError || !proc?.stdin.writable)
576
+ if (fatalError || closed || !proc?.stdin.writable)
520
577
  return;
521
578
  send({ id: message.id, result: response });
522
579
  })().catch((error) => fail(error instanceof Error ? error : new Error(String(error))));
523
- return;
524
580
  }
525
581
  }
526
582
  catch (error) {
@@ -550,103 +606,130 @@ export async function callOfficialDirectTool(method, args, options = {}) {
550
606
  offset = newline + 1;
551
607
  }
552
608
  });
553
- proc.stdout.on("end", () => {
554
- if (stdoutBuffer.length > 0)
555
- processProtocolLine(stdoutBuffer);
556
- stdoutBuffer = "";
557
- });
558
- if (options.signal) {
559
- abortHandler = () => {
560
- fail(new Error("Direct Computer Use request cancelled"));
561
- };
562
- if (options.signal.aborted)
563
- abortHandler();
564
- else
565
- options.signal.addEventListener("abort", abortHandler, { once: true });
566
- }
567
- if (fatalError)
568
- throw fatalError;
609
+ proc.stdout.on("end", () => { if (stdoutBuffer.length > 0)
610
+ processProtocolLine(stdoutBuffer); stdoutBuffer = ""; });
569
611
  await request("initialize", {
570
- clientInfo: { name: "pi_direct_computer_use", title: "Pi Direct Computer Use", version: "0.3.0" },
571
- capabilities: { mcpServerOpenaiFormElicitation: options.supportsOpenAiFormElicitation === true && options.onElicitation !== undefined },
612
+ clientInfo: { name: "pi_direct_computer_use", title: "Pi Direct Computer Use", version: "0.3.2" },
613
+ capabilities: { mcpServerOpenaiFormElicitation: options.supportsOpenAiFormElicitation === true },
572
614
  }, 15_000);
573
615
  send({ method: "initialized" });
574
- // Codex Full access requires both values: with `never` plus a restricted sandbox,
575
- // core declines the signed service's app approval instead of prompting or accepting it.
576
- const started = (await request("thread/start", { cwd: workDir, approvalPolicy: "never", sandbox: "danger-full-access", ephemeral: true, serviceName: "pi_direct_computer_use" }, 30_000));
616
+ const started = (await request("thread/start", {
617
+ cwd: workDir, approvalPolicy: "never", sandbox: "danger-full-access", ephemeral: true, serviceName: "pi_direct_computer_use",
618
+ }, 30_000));
577
619
  const thread = started?.thread;
578
- const threadId = thread?.id;
579
- if (typeof threadId !== "string"
580
- || thread.ephemeral !== true
581
- || !Object.prototype.hasOwnProperty.call(thread, "path")
582
- || thread.path !== null
583
- || !Array.isArray(thread.turns)
584
- || thread.turns.length !== 0) {
620
+ threadId = thread?.id;
621
+ if (typeof threadId !== "string" || thread.ephemeral !== true || !Object.prototype.hasOwnProperty.call(thread, "path") || thread.path !== null || !Array.isArray(thread.turns) || thread.turns.length !== 0) {
585
622
  throw new BrokerVerificationError("App-server did not attest an empty pathless ephemeral runtime context");
586
623
  }
587
624
  ephemeralThread = true;
588
- const inventory = await request("mcpServerStatus/list", { threadId, detail: "toolsAndAuthOnly" }, 45_000);
589
- validateInventory(inventory);
590
- const raw = await request("mcpServer/tool/call", { threadId, server: "computer-use", tool: method, arguments: args }, options.timeoutMs ?? 120_000);
591
- directCalls = 1;
592
- if (modelTurnsStarted !== 0)
593
- throw new BrokerVerificationError("Model-turn activity was observed during direct dispatch");
594
- const result = validateResult(raw);
595
- finalResult = {
596
- ...result,
597
- brokerVersion: verification.brokerVersion,
598
- clientBuild: verification.clientBuild,
599
- durationMs: Date.now() - startedAt,
600
- elicitationRequests,
601
- modelTurnsStarted: 0,
602
- ephemeralThread: true,
603
- brokerCleanupVerified: true,
604
- };
605
625
  }
606
626
  catch (error) {
607
627
  const base = error instanceof Error ? error : new Error(String(error));
608
- primaryError = /authentication|bearer|token/i.test(`${base.message}\n${stderr}`)
609
- ? new Error("Official direct Computer Use broker reported an authentication failure")
610
- : base;
611
- }
612
- finally {
613
- if (abortHandler && options.signal)
614
- options.signal.removeEventListener("abort", abortHandler);
615
- rejectAll(new Error("Official app-server closed"));
628
+ const primary = /authentication|bearer|token/i.test(`${base.message}\n${stderr}`)
629
+ ? new Error("Official direct Computer Use broker reported an authentication failure") : base;
616
630
  try {
617
- await ensureTerminated();
618
- if (processClosed) {
619
- await new Promise((resolve, reject) => {
620
- const timer = setTimeout(() => reject(new Error("Official app-server stdio did not close")), 1_000);
621
- processClosed.then(() => {
622
- clearTimeout(timer);
623
- resolve();
624
- });
631
+ await close();
632
+ }
633
+ catch (closeError) {
634
+ const closeFailure = closeError instanceof Error ? closeError : new Error(String(closeError));
635
+ if (closeFailure.message === "Official direct Computer Use broker cleanup failed") {
636
+ throw new DirectBrokerCallError(closeFailure.message, false, primary);
637
+ }
638
+ }
639
+ throw new DirectBrokerCallError(primary.message, true, primary, { modelTurnsStarted, ephemeralThread, brokerVersion: verification.brokerVersion, clientBuild: verification.clientBuild });
640
+ }
641
+ return {
642
+ async call(method, args, callOptions = {}) {
643
+ if (closed)
644
+ throw new DirectBrokerCallError("Official direct Computer Use session is closed", true);
645
+ if (callActive)
646
+ throw new DirectBrokerCallError("Official direct Computer Use session does not allow concurrent calls", false);
647
+ callActive = true;
648
+ currentElicitation = callOptions.onElicitation;
649
+ currentElicitationCount = 0;
650
+ const startedAt = Date.now();
651
+ let directCalls = 0;
652
+ let abortHandler;
653
+ try {
654
+ if (callOptions.signal) {
655
+ abortHandler = () => fail(new Error("Direct Computer Use request cancelled"));
656
+ if (callOptions.signal.aborted)
657
+ abortHandler();
658
+ else
659
+ callOptions.signal.addEventListener("abort", abortHandler, { once: true });
660
+ }
661
+ if (fatalError)
662
+ throw fatalError;
663
+ const inventory = await request("mcpServerStatus/list", { threadId, detail: "toolsAndAuthOnly" }, 45_000);
664
+ validateInventory(inventory);
665
+ const raw = await request("mcpServer/tool/call", { threadId, server: "computer-use", tool: method, arguments: args }, callOptions.timeoutMs ?? 120_000);
666
+ directCalls = 1;
667
+ if (modelTurnsStarted !== 0)
668
+ throw new BrokerVerificationError("Model-turn activity was observed during direct dispatch");
669
+ const result = validateResult(raw);
670
+ return {
671
+ ...result,
672
+ brokerVersion: verification.brokerVersion,
673
+ clientBuild: verification.clientBuild,
674
+ durationMs: Date.now() - startedAt,
675
+ elicitationRequests: currentElicitationCount,
676
+ modelTurnsStarted: 0,
677
+ ephemeralThread: true,
678
+ brokerCleanupVerified: false,
679
+ };
680
+ }
681
+ catch (error) {
682
+ const base = error instanceof Error ? error : new Error(String(error));
683
+ const primary = /authentication|bearer|token/i.test(`${base.message}\n${stderr}`)
684
+ ? new Error("Official direct Computer Use broker reported an authentication failure") : base;
685
+ throw new DirectBrokerCallError(primary.message, false, primary, {
686
+ directCalls, modelTurnsStarted, ephemeralThread, elicitationRequests: currentElicitationCount,
687
+ brokerVersion: verification.brokerVersion, clientBuild: verification.clientBuild,
625
688
  });
626
689
  }
627
- await new Promise((resolve) => setImmediate(resolve));
628
- if (fatalError || modelTurnsStarted !== 0) {
629
- primaryError = fatalError ?? new BrokerVerificationError("Model-turn activity was observed during broker teardown");
690
+ finally {
691
+ if (abortHandler && callOptions.signal)
692
+ callOptions.signal.removeEventListener("abort", abortHandler);
693
+ currentElicitation = undefined;
694
+ callActive = false;
630
695
  }
631
- await rm(tempRoot, { recursive: true, force: true });
696
+ },
697
+ close,
698
+ };
699
+ }
700
+ export async function callOfficialDirectTool(method, args, options = {}) {
701
+ let session;
702
+ let result;
703
+ let failure;
704
+ try {
705
+ session = await createOfficialDirectToolSession(options);
706
+ result = await session.call(method, args, options);
707
+ }
708
+ catch (error) {
709
+ failure = error;
710
+ }
711
+ let cleanupVerified = failure instanceof DirectBrokerCallError ? failure.cleanupVerified : false;
712
+ try {
713
+ if (session) {
714
+ await session.close();
632
715
  cleanupVerified = true;
633
716
  }
634
- catch (cleanupError) {
635
- primaryError = new Error("Official direct Computer Use broker cleanup failed", { cause: cleanupError });
717
+ }
718
+ catch (cleanupError) {
719
+ const closeFailure = cleanupError instanceof Error ? cleanupError : new Error(String(cleanupError));
720
+ if (closeFailure.message !== "Official direct Computer Use broker cleanup failed") {
721
+ throw new DirectBrokerCallError(closeFailure.message, true, closeFailure, failure instanceof DirectBrokerCallError ? failure : {});
722
+ }
723
+ throw new DirectBrokerCallError(closeFailure.message, false, closeFailure, failure instanceof DirectBrokerCallError ? failure : {});
724
+ }
725
+ if (failure) {
726
+ if (failure instanceof DirectBrokerCallError) {
727
+ throw new DirectBrokerCallError(failure.message, cleanupVerified, failure, failure);
636
728
  }
729
+ throw failure;
637
730
  }
638
- const failureEvidence = {
639
- directCalls,
640
- modelTurnsStarted,
641
- ephemeralThread,
642
- elicitationRequests,
643
- brokerVersion: verification.brokerVersion,
644
- clientBuild: verification.clientBuild,
645
- };
646
- if (primaryError)
647
- throw new DirectBrokerCallError(primaryError.message, cleanupVerified, primaryError, failureEvidence);
648
- if (!finalResult)
649
- throw new DirectBrokerCallError("Official direct Computer Use ended without a result", cleanupVerified, undefined, failureEvidence);
650
- return finalResult;
731
+ if (!result)
732
+ throw new DirectBrokerCallError("Official direct Computer Use ended without a result", cleanupVerified);
733
+ return { ...result, brokerCleanupVerified: true };
651
734
  }
652
735
  //# sourceMappingURL=direct-broker.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"direct-broker.js","sourceRoot":"","sources":["../src/direct-broker.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAuC,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACxE,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACN,+BAA+B,EAC/B,gBAAgB,GAGhB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,UAAU,GAAG,oDAAoD,CAAC;AAC/E,MAAM,CAAC,MAAM,wBAAwB,GACpC,0FAA0F,CAAC;AAC5F,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAG,wBAAwB,6GAA6G,CAAC;AACjL,MAAM,cAAc,GAAG,YAAY,CAAC;AACpC,MAAM,uBAAuB,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,CAAC;AAChD,MAAM,gBAAgB,GAAG,EAAE,GAAG,IAAI,GAAG,IAAI,CAAC;AAiD1C,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IACjD,YAAY,OAAe;QAC1B,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;IACvC,CAAC;CACD;AAED,MAAM,OAAO,qBAAsB,SAAQ,KAAK;IACtC,eAAe,CAAU;IACzB,WAAW,CAAS;IACpB,iBAAiB,CAAS;IAC1B,eAAe,CAAU;IACzB,mBAAmB,CAAS;IAC5B,aAAa,CAAS;IACtB,WAAW,CAAS;IAC7B,YACC,OAAe,EACf,eAAwB,EACxB,KAAe,EACf,QAAQ,GAOJ,EAAE;QAEN,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,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rorCode, ListToolsRequestSchema, McpError, } f
5
5
  import { executeDirectTool, getDirectStatus } from "./direct-service.js";
6
6
  import { forwardOfficialElicitationToMcpClient } from "./mcp-elicitation.js";
7
7
  import { EXPECTED_OFFICIAL_INPUT_SCHEMAS, isDirectMethod, OFFICIAL_METHODS, OFFICIAL_TOOL_METADATA, } from "./tools.js";
8
- const version = "0.3.0";
8
+ const version = "0.3.2";
9
9
  async function handleCli() {
10
10
  const args = process.argv.slice(2);
11
11
  if (args.length === 0)
@@ -1,6 +1,6 @@
1
1
  # Pi integration
2
2
 
3
- The native Pi adapter is the primary 0.3 path. It registers ten namespaced typed tools so Pi itself chooses each official Computer Use method and argument. Pi 0.80.7 or newer exposes them progressively without changing the ten-tool contract.
3
+ The native Pi adapter is the primary 0.3 path. It registers and activates ten namespaced typed tools together so Pi itself chooses each official Computer Use method and argument.
4
4
 
5
5
  ## Source checkout acceptance
6
6
 
@@ -13,23 +13,20 @@ CODEX_COMPUTER_USE_HOME="$(mktemp -d)" \
13
13
 
14
14
  `-ne` prevents an installed 0.1 adapter from loading at the same time. This source workflow does not install or switch live Pi configuration.
15
15
 
16
- For normal installation, use the exact version 0.3.0 npm package:
16
+ For normal installation, use the exact version 0.3.2 npm package:
17
17
 
18
18
  ```bash
19
- pi install npm:codex-computer-use-mcp@0.3.0
19
+ pi install npm:codex-computer-use-mcp@0.3.2
20
20
  ```
21
21
 
22
22
  Use the source workflow only when you need to test an exact reviewed commit. Follow the rollback procedure in `MIGRATION.md` when replacing version 0.1.
23
23
 
24
24
  ## Registered surface
25
25
 
26
- Initially active:
26
+ All ten tools are registered and active from session start:
27
27
 
28
28
  - `computer_use_list_apps`
29
29
  - `computer_use_get_app_state`
30
-
31
- Registered and activated after a successful `get_app_state` call:
32
-
33
30
  - `computer_use_click`
34
31
  - `computer_use_perform_secondary_action`
35
32
  - `computer_use_set_value`
@@ -43,13 +40,15 @@ Command:
43
40
 
44
41
  - `/computer-use-status`
45
42
 
46
- The session-start narrowing preserves every active tool owned by Pi or another extension. Activation after inspection is purely additive: both inspection tools remain active, and the adapter does not remove or replace any tool in that call. The lazily activated tools rely on their official descriptions and omit `promptSnippet` and `promptGuidelines`, so native deferred schema loading does not rebuild the system prompt. Supported Anthropic and OpenAI models receive the definitions at the inspection result; other models receive Pi's normal active-tool fallback on the next request.
43
+ Session-start activation is purely additive and preserves every active tool owned by Pi or another extension. The interaction definitions rely on their official descriptions and omit extra prompt metadata.
44
+
45
+ A successful `get_app_state` retains its verified app-server runtime, thread, and signed Computer Use client. The following direct interaction uses that same client and official active-app lease, then closes the retained process tree with strict cleanup verification. A new inspection replaces and closes any earlier retained session; Pi `session_shutdown` also closes it.
47
46
 
48
47
  No-permissions is the only policy: all ten tools are registered and available through this lifecycle with no wrapper permission prompts, mode selector, or app/intent/action gate. The signed host runs with Codex Full access (`approvalPolicy: "never"`, `sandbox: "danger-full-access"`), so normal empty-schema Computer Use app approvals are accepted by Codex before they reach Pi. Pi renders any form, OpenAI-form, or URL elicitation app-server does emit. The user's `accept`, `decline`, or `cancel` response is returned unchanged; the adapter never fabricates one.
49
48
 
50
49
  ## Generic MCP gateway
51
50
 
52
- Merge `mcp.json.example` only for the exact 0.3.0 package or after building an exact reviewed source commit. `directTools: false` is intentional; it keeps this powerful generic MCP surface behind Pi's gateway.
51
+ Merge `mcp.json.example` only for the exact 0.3.2 package or after building an exact reviewed source commit. `directTools: false` is intentional; it keeps this powerful generic MCP surface behind Pi's gateway.
53
52
 
54
53
  For a source checkout:
55
54
 
@@ -4,9 +4,11 @@ import { getAgentDir, truncateHead, type ExtensionAPI } from "@earendil-works/pi
4
4
  import { Text } from "@earendil-works/pi-tui";
5
5
  import { Type, type TSchema } from "typebox";
6
6
  import { executeDirectTool, getDirectStatus } from "../../dist/direct-service.js";
7
- import type {
8
- DirectBrokerElicitationRequest,
9
- DirectBrokerElicitationResponse,
7
+ import {
8
+ createOfficialDirectToolSession,
9
+ type DirectBrokerElicitationRequest,
10
+ type DirectBrokerElicitationResponse,
11
+ type OfficialDirectToolSession,
10
12
  } from "../../dist/direct-broker.js";
11
13
  import { OFFICIAL_TOOL_METADATA, type DirectMethod } from "../../dist/tools.js";
12
14
 
@@ -82,15 +84,94 @@ export const INTERACTION_TOOL_NAMES = [
82
84
  "computer_use_type_text",
83
85
  ] as const;
84
86
 
87
+ export const COMPUTER_USE_TOOL_NAMES = [
88
+ ...INSPECTION_TOOL_NAMES,
89
+ ...INTERACTION_TOOL_NAMES,
90
+ ] as const;
91
+
85
92
  export function setInitialComputerUseTools(pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools">): void {
86
- const interactionTools = new Set<string>(INTERACTION_TOOL_NAMES);
87
- const preserved = pi.getActiveTools().filter((name) => !interactionTools.has(name));
88
- pi.setActiveTools([...new Set([...preserved, ...INSPECTION_TOOL_NAMES])]);
93
+ pi.setActiveTools([...new Set([...pi.getActiveTools(), ...COMPUTER_USE_TOOL_NAMES])]);
94
+ }
95
+
96
+ interface SessionExecutorDependencies {
97
+ createSession?: typeof createOfficialDirectToolSession;
98
+ executeTool?: typeof executeDirectTool;
89
99
  }
90
100
 
91
- export function activateInteractionTools(pi: Pick<ExtensionAPI, "getActiveTools" | "setActiveTools">): void {
92
- const active = pi.getActiveTools();
93
- pi.setActiveTools([...new Set([...active, ...INTERACTION_TOOL_NAMES])]);
101
+ /** Keep the signed app-server/client alive across the required state -> action pair. */
102
+ export class PiDirectSessionExecutor {
103
+ private session: OfficialDirectToolSession | undefined;
104
+ private queue: Promise<void> = Promise.resolve();
105
+ private readonly dependencies: SessionExecutorDependencies;
106
+
107
+ constructor(dependencies: SessionExecutorDependencies = {}) {
108
+ this.dependencies = dependencies;
109
+ }
110
+
111
+ private async closeSession(): Promise<void> {
112
+ const session = this.session;
113
+ this.session = undefined;
114
+ await session?.close();
115
+ }
116
+
117
+ async execute(
118
+ method: DirectMethod,
119
+ params: Record<string, unknown>,
120
+ dependencies: Parameters<typeof executeDirectTool>[1],
121
+ ): Promise<Awaited<ReturnType<typeof executeDirectTool>>> {
122
+ const previous = this.queue;
123
+ let release!: () => void;
124
+ this.queue = new Promise<void>((resolve) => { release = resolve; });
125
+ await previous;
126
+ try {
127
+ const executeTool = this.dependencies.executeTool ?? executeDirectTool;
128
+ if (method === "list_apps") return await executeTool({ method, arguments: params }, dependencies);
129
+ if (method === "get_app_state") {
130
+ await this.closeSession();
131
+ const createSession = this.dependencies.createSession ?? createOfficialDirectToolSession;
132
+ try {
133
+ const response = await executeTool(
134
+ { method, arguments: params },
135
+ {
136
+ ...dependencies,
137
+ callTool: async (directMethod, args, options) => {
138
+ this.session = await createSession({ supportsOpenAiFormElicitation: true });
139
+ return this.session.call(directMethod, args, options);
140
+ },
141
+ },
142
+ );
143
+ if (response.isError) await this.closeSession();
144
+ return response;
145
+ } catch (error) {
146
+ await this.closeSession();
147
+ throw error;
148
+ }
149
+ }
150
+ const session = this.session;
151
+ try {
152
+ return await executeTool(
153
+ { method, arguments: params },
154
+ session ? {
155
+ ...dependencies,
156
+ callTool: async (directMethod, args, options) => {
157
+ const result = await session.call(directMethod, args, options);
158
+ await this.closeSession();
159
+ return { ...result, brokerCleanupVerified: true };
160
+ },
161
+ } : dependencies,
162
+ );
163
+ } finally {
164
+ await this.closeSession();
165
+ }
166
+ } finally {
167
+ release();
168
+ }
169
+ }
170
+
171
+ async close(): Promise<void> {
172
+ await this.queue;
173
+ await this.closeSession();
174
+ }
94
175
  }
95
176
 
96
177
  function toPiContent(content: Array<Record<string, unknown>>): Array<{ type: "text"; text: string } | { type: "image"; data: string; mimeType: string }> {
@@ -188,6 +269,7 @@ export async function handleOfficialElicitation(
188
269
 
189
270
  export default function directComputerUse(pi: ExtensionAPI) {
190
271
  const stateRoot = process.env.CODEX_COMPUTER_USE_HOME || path.join(getAgentDir(), "direct-computer-use");
272
+ const sessionExecutor = new PiDirectSessionExecutor();
191
273
 
192
274
  pi.registerCommand("computer-use-status", {
193
275
  description: "Show the direct-call architecture, durable no-permissions policy, signed broker, and private audit path",
@@ -214,8 +296,9 @@ export default function directComputerUse(pi: ExtensionAPI) {
214
296
  ...inspectionPromptMetadata,
215
297
  parameters: ToolParameters[method] as any,
216
298
  async execute(_toolCallId, params, signal, onUpdate, ctx) {
217
- const response = await executeDirectTool(
218
- { method, arguments: params as Record<string, unknown> },
299
+ const response = await sessionExecutor.execute(
300
+ method,
301
+ params as Record<string, unknown>,
219
302
  {
220
303
  stateRoot,
221
304
  signal,
@@ -232,7 +315,6 @@ export default function directComputerUse(pi: ExtensionAPI) {
232
315
  },
233
316
  );
234
317
  if (response.isError) throw new Error(errorText(response.content));
235
- if (method === "get_app_state") activateInteractionTools(pi);
236
318
  return { content: toPiContent(response.content), details: response.details };
237
319
  },
238
320
  renderCall(args, theme) {
@@ -244,4 +326,5 @@ export default function directComputerUse(pi: ExtensionAPI) {
244
326
  }
245
327
 
246
328
  pi.on("session_start", () => setInitialComputerUseTools(pi));
329
+ pi.on("session_shutdown", () => sessionExecutor.close());
247
330
  }
@@ -4,7 +4,7 @@
4
4
  "command": "npx",
5
5
  "args": [
6
6
  "-y",
7
- "codex-computer-use-mcp@0.3.0"
7
+ "codex-computer-use-mcp@0.3.2"
8
8
  ],
9
9
  "lifecycle": "lazy",
10
10
  "requestTimeoutMs": 180000,
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "codex-computer-use-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "codex-computer-use-mcp",
9
- "version": "0.3.0",
9
+ "version": "0.3.2",
10
10
  "license": "MIT",
11
11
  "os": [
12
12
  "darwin"
@@ -3664,9 +3664,9 @@
3664
3664
  "license": "MIT"
3665
3665
  },
3666
3666
  "node_modules/fast-uri": {
3667
- "version": "3.1.3",
3668
- "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.3.tgz",
3669
- "integrity": "sha512-i70LwGWUduXqzicKXWshooq+sWL1K3WUU5rKZNG/0i3a1OSoX3HqhH5WbWwTmqWfor4urUakGPiRQcleRZTwOg==",
3667
+ "version": "3.1.4",
3668
+ "resolved": "https://registry.npmjs.org/fast-uri/-/fast-uri-3.1.4.tgz",
3669
+ "integrity": "sha512-8JnbkQ4juDyvYs4mgFGQqg4yCYtFDtUtmp2QIQq11ZZe5CFQ5wcqm1rqDgAh/QdMySuBnPzMUiJUNZG5N/AiQw==",
3670
3670
  "funding": [
3671
3671
  {
3672
3672
  "type": "github",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "codex-computer-use-mcp",
3
- "version": "0.3.0",
3
+ "version": "0.3.2",
4
4
  "description": "Expose the official macOS Computer Use tools directly to Pi and MCP clients without a nested model.",
5
5
  "author": "Thomas Mustier",
6
6
  "license": "MIT",