@roam-agent/roam-computer-use 0.0.0-stage → 0.5.1
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/LICENSE +21 -0
- package/README.md +80 -2
- package/assets/reference/img.jpg +0 -0
- package/docs/README.md +45 -0
- package/docs/content/docs/explanation/action-pipeline.mdx +36 -0
- package/docs/content/docs/explanation/architecture.mdx +161 -0
- package/docs/content/docs/explanation/index.mdx +19 -0
- package/docs/content/docs/explanation/meta.json +5 -0
- package/docs/content/docs/explanation/observation-pipeline.mdx +37 -0
- package/docs/content/docs/explanation/platform-boundary.mdx +37 -0
- package/docs/content/docs/explanation/state-and-scheduling.mdx +35 -0
- package/docs/content/docs/how-to-guides/develop-and-validate.mdx +112 -0
- package/docs/content/docs/how-to-guides/index.mdx +12 -0
- package/docs/content/docs/how-to-guides/linux.mdx +68 -0
- package/docs/content/docs/how-to-guides/meta.json +1 -0
- package/docs/content/docs/how-to-guides/troubleshooting.mdx +126 -0
- package/docs/content/docs/index.mdx +67 -0
- package/docs/content/docs/meta.json +5 -0
- package/docs/content/docs/reference/agent/contract.mdx +162 -0
- package/docs/content/docs/reference/agent/index.mdx +8 -0
- package/docs/content/docs/reference/agent/meta.json +8 -0
- package/docs/content/docs/reference/agent/tools.mdx +221 -0
- package/docs/content/docs/reference/codebase.mdx +139 -0
- package/docs/content/docs/reference/configuration.mdx +113 -0
- package/docs/content/docs/reference/index.mdx +28 -0
- package/docs/content/docs/reference/meta.json +10 -0
- package/docs/content/docs/reference/platforms/index.mdx +18 -0
- package/docs/content/docs/reference/platforms/macos/accessibility.mdx +61 -0
- package/docs/content/docs/reference/platforms/macos/actions.mdx +63 -0
- package/docs/content/docs/reference/platforms/macos/capture.mdx +58 -0
- package/docs/content/docs/reference/platforms/macos/implementation.mdx +98 -0
- package/docs/content/docs/reference/platforms/macos/index.mdx +16 -0
- package/docs/content/docs/reference/platforms/macos/meta.json +10 -0
- package/docs/content/docs/reference/platforms/macos/root-targeting.mdx +47 -0
- package/docs/content/docs/reference/platforms/meta.json +8 -0
- package/docs/content/docs/reference/platforms/windows.mdx +75 -0
- package/docs/content/docs/tutorials/getting-started.mdx +46 -0
- package/docs/content/docs/tutorials/index.mdx +10 -0
- package/docs/content/docs/tutorials/meta.json +1 -0
- package/extensions/computer-use.ts +235 -0
- package/native/linux/bridge-rs/Cargo.lock +1204 -0
- package/native/linux/bridge-rs/Cargo.toml +21 -0
- package/native/linux/bridge-rs/src/atspi.rs +670 -0
- package/native/linux/bridge-rs/src/error.rs +65 -0
- package/native/linux/bridge-rs/src/lib.rs +11 -0
- package/native/linux/bridge-rs/src/main.rs +1110 -0
- package/native/linux/bridge-rs/src/protocol.rs +49 -0
- package/native/linux/bridge-rs/src/state.rs +293 -0
- package/native/linux/bridge-rs/src/wayland.rs +89 -0
- package/native/linux/bridge-rs/src/x11.rs +909 -0
- package/native/linux/bridge-rs/tests/protocol_tests.rs +73 -0
- package/native/macos/activity_glow.swift +169 -0
- package/native/macos/bridge.swift +3968 -0
- package/native/windows/bridge-rs/Cargo.lock +396 -0
- package/native/windows/bridge-rs/Cargo.toml +30 -0
- package/native/windows/bridge-rs/src/capture.rs +561 -0
- package/native/windows/bridge-rs/src/error.rs +81 -0
- package/native/windows/bridge-rs/src/input.rs +501 -0
- package/native/windows/bridge-rs/src/lib.rs +85 -0
- package/native/windows/bridge-rs/src/main.rs +1683 -0
- package/native/windows/bridge-rs/src/protocol.rs +53 -0
- package/native/windows/bridge-rs/src/refs.rs +237 -0
- package/native/windows/bridge-rs/src/state.rs +55 -0
- package/native/windows/bridge-rs/src/uia.rs +1252 -0
- package/native/windows/bridge-rs/src/window.rs +718 -0
- package/native/windows/bridge-rs/tests/protocol_tests.rs +252 -0
- package/native/windows/bridge-rs/tests/refs_tests.rs +86 -0
- package/native/windows/bridge-rs/tests/state_tests.rs +33 -0
- package/package.json +104 -5
- package/prebuilt/macos/arm64/bridge +0 -0
- package/prebuilt/macos/x64/bridge +0 -0
- package/roam/README.md +52 -0
- package/roam/bridge/macos/arm64/bridge +0 -0
- package/roam/bridge/macos/x64/bridge +0 -0
- package/roam/bridge/manifest.json +20 -0
- package/roam/helper-path.d.mts +9 -0
- package/roam/helper-path.mjs +36 -0
- package/roam/identity.d.mts +16 -0
- package/roam/identity.mjs +64 -0
- package/roam/index.ts +51 -0
- package/roam/redirect.ts +51 -0
- package/roam/repair.ts +120 -0
- package/scripts/build-native.mjs +286 -0
- package/scripts/setup-helper.mjs +635 -0
- package/src/actions.ts +130 -0
- package/src/bridge.ts +2594 -0
- package/src/cdp.ts +658 -0
- package/src/config.ts +226 -0
- package/src/contract.ts +107 -0
- package/src/extension/index.ts +9 -0
- package/src/find-params.ts +21 -0
- package/src/note.ts +195 -0
- package/src/outline.ts +702 -0
- package/src/output.ts +134 -0
- package/src/permissions.ts +111 -0
- package/src/platform/architecture.ts +23 -0
- package/src/platform/coerce.ts +16 -0
- package/src/platform/index.ts +61 -0
- package/src/platform/linux/backend.ts +186 -0
- package/src/platform/linux/helper.ts +238 -0
- package/src/platform/macos/backend.ts +147 -0
- package/src/platform/macos/browser.ts +110 -0
- package/src/platform/macos/helper.ts +369 -0
- package/src/platform/macos/permissions.ts +146 -0
- package/src/platform/types.ts +229 -0
- package/src/platform/windows/backend.ts +142 -0
- package/src/platform/windows/helper.ts +140 -0
- package/src/root-selection.ts +25 -0
- package/src/runtime.ts +129 -0
- package/src/state.ts +146 -0
- package/src/view.ts +147 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Zane Chee
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,81 @@
|
|
|
1
|
-
#
|
|
1
|
+
# roam-computer-use
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
<p align="center">
|
|
4
|
+
<img src="./assets/logo/logo3.png" width="50%" alt="roam-computer-use">
|
|
5
|
+
</p>
|
|
6
|
+
|
|
7
|
+
`roam-computer-use` lets AI agents use desktop apps on macOS, Windows, and Linux.
|
|
8
|
+
|
|
9
|
+
The macOS helper requires macOS 14 or newer; the [macOS reference](./docs/content/docs/reference/platforms/macos/implementation.mdx) maps each platform claim to Apple documentation and the implementation.
|
|
10
|
+
|
|
11
|
+
An agent can look at an app window, understand the buttons and text inside it, and perform actions like clicking, typing, scrolling, and waiting for something to change. This is useful when the agent needs to work with a normal desktop app instead of an API, a terminal command, or a file.
|
|
12
|
+
|
|
13
|
+
New to computer use? Start with: [Wait, what exactly is Computer Use?](https://zanechee.dev/what-exactly-is-computer-use/)
|
|
14
|
+
|
|
15
|
+
## What this package does
|
|
16
|
+
|
|
17
|
+
This is a Pi extension. After installation, Pi agents get tools for:
|
|
18
|
+
|
|
19
|
+
- finding open apps and windows
|
|
20
|
+
- observing what is visible in a window
|
|
21
|
+
- searching the visible interface for text, buttons, and controls
|
|
22
|
+
- inspecting parts of the interface in more detail
|
|
23
|
+
- clicking, typing, scrolling, and pressing UI controls
|
|
24
|
+
- waiting for UI changes
|
|
25
|
+
|
|
26
|
+
In short: it gives an agent a controlled way to operate desktop software.
|
|
27
|
+
|
|
28
|
+
## What this package is not
|
|
29
|
+
|
|
30
|
+
`roam-computer-use` is not a replacement for app APIs or MCP servers. If an app has a reliable direct integration, use that first.
|
|
31
|
+
|
|
32
|
+
Computer use is most helpful when the only available interface is the app on screen.
|
|
33
|
+
|
|
34
|
+
## Install
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
pi install npm:@roam-agent/roam-computer-use
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Start Pi and complete the platform setup flow.
|
|
41
|
+
|
|
42
|
+
On macOS, the runtime installs the helper per user at `~/Applications/roam-computer-use.app` and requests Accessibility and Screen Recording. Existing writable system-wide installs remain at `/Applications/roam-computer-use.app`. Enable both grants for that app in System Settings, then choose Recheck. The [macOS reference](./docs/content/docs/reference/platforms/macos/accessibility.mdx#trust-and-permission) documents the exact APIs and avoids relying on version-specific pane labels.
|
|
43
|
+
|
|
44
|
+
On Windows, use an interactive desktop session. Windows support uses the platform accessibility APIs and does not use the macOS helper app.
|
|
45
|
+
|
|
46
|
+
On Linux, run Pi inside the target user's graphical session with a working AT-SPI2 accessibility bus. AT-SPI semantic operations remain background-first. X11 additionally supports EWMH window metadata/focus, window capture, and policy-gated XTEST physical input; strict headless/background policies never use focus or XTEST. Native Wayland remains semantic-only; diagnostics reads portal capability properties without creating a session, and interactive portal use is disabled. See [Linux support](./docs/content/docs/how-to-guides/linux.mdx) for the exact capability matrix and portal status.
|
|
47
|
+
|
|
48
|
+
Use `/computer-use` inside Pi to show the active configuration and where it came from.
|
|
49
|
+
|
|
50
|
+
## Main tools
|
|
51
|
+
|
|
52
|
+
- `find_roots`
|
|
53
|
+
- `observe_ui`
|
|
54
|
+
- `search_ui`
|
|
55
|
+
- `expand_ui`
|
|
56
|
+
- `inspect_ui`
|
|
57
|
+
- `act_ui`
|
|
58
|
+
- `read_text`
|
|
59
|
+
- `wait_for`
|
|
60
|
+
|
|
61
|
+
Follow the [getting-started tutorial](./docs/content/docs/tutorials/getting-started.mdx), then use the generated [agent state and action contract](./docs/content/docs/reference/agent/contract.mdx) for operating behavior or the generated [tool schema reference](./docs/content/docs/reference/agent/tools.mdx) for exact parameters.
|
|
62
|
+
|
|
63
|
+
## Documentation
|
|
64
|
+
|
|
65
|
+
The docs follow [Diátaxis](https://diataxis.fr/) and render through the Next.js/Fumadocs app in [`docs/`](./docs/README.md). Run `npm install --prefix docs` once, then `npm run docs:dev` and open `http://localhost:8080/docs`.
|
|
66
|
+
|
|
67
|
+
- [Tutorials](./docs/content/docs/tutorials/getting-started.mdx)
|
|
68
|
+
- [How-to guides](./docs/content/docs/how-to-guides/troubleshooting.mdx)
|
|
69
|
+
- [Explanation](./docs/content/docs/explanation/architecture.mdx)
|
|
70
|
+
- [Reference](./docs/content/docs/reference/index.mdx)
|
|
71
|
+
- [macOS root targeting](./docs/content/docs/reference/platforms/macos/root-targeting.mdx)
|
|
72
|
+
- [Linux support](./docs/content/docs/how-to-guides/linux.mdx)
|
|
73
|
+
- [Contributing](./CONTRIBUTING.md)
|
|
74
|
+
|
|
75
|
+
## Development status
|
|
76
|
+
|
|
77
|
+
The architecture is centered on immutable, state-scoped observations. Desktop surfaces and CDP pages form one multi-root forest; progressive outline queries remain cached, while live work is ordered per physical resource so independent roots can run in parallel. `act_ui` accepts one or more intent steps, preserves focus across dependent input, verifies delivery, recovers safely, stores one complete successor state, and returns a compact diff when identity confidence allows. Older direct tools such as `screenshot`, `click`, `set_text`, and `computer_actions` are no longer part of the public extension surface.
|
|
78
|
+
|
|
79
|
+
## License
|
|
80
|
+
|
|
81
|
+
MIT
|
|
Binary file
|
package/docs/README.md
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# Documentation website
|
|
2
|
+
|
|
3
|
+
This directory contains the Next.js and Fumadocs application used to render the pi-computer-use documentation website. The content, navigation, generated references, and visual system are maintained specifically for pi-computer-use.
|
|
4
|
+
|
|
5
|
+
## Run locally
|
|
6
|
+
|
|
7
|
+
Install the website dependencies once:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install --prefix docs
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Start the preview from the repository root:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm run docs:dev
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Open http://localhost:8080/docs.
|
|
20
|
+
|
|
21
|
+
Build and validate it with:
|
|
22
|
+
|
|
23
|
+
```bash
|
|
24
|
+
npm run docs:build
|
|
25
|
+
npm run docs:site:check
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Content model
|
|
29
|
+
|
|
30
|
+
Public content lives in `content/docs/` and follows Diátaxis:
|
|
31
|
+
|
|
32
|
+
- `tutorials/` teaches through a guided first success.
|
|
33
|
+
- `how-to-guides/` gives steps for one operational goal.
|
|
34
|
+
- `explanation/` builds understanding of architecture and tradeoffs, organized by runtime concern.
|
|
35
|
+
- `reference/` provides exact interface, configuration, and platform lookup, organized by implementation boundary.
|
|
36
|
+
|
|
37
|
+
Navigation opens only the active branch. Platform reference should expose concrete subsystems rather than hiding them in one page; for example, macOS separates Accessibility and AX, capture and OCR, actions and input delivery, and the complete implementation inventory.
|
|
38
|
+
|
|
39
|
+
Every page below `reference/` is generated. Exact tool schemas come from `../extensions/computer-use.ts`; behavioral reference prose is extracted from marked documentation blocks in the source file that owns the behavior; navigation and the codebase inventory are derived from generator metadata and the repository tree. `../scripts/docs-generators/reference-evidence.json` independently lists required source symbols. Run `npm run docs:generate` after changing code-owned reference documentation, and `npm run docs:check` to detect output or evidence drift.
|
|
40
|
+
|
|
41
|
+
## Visual system
|
|
42
|
+
|
|
43
|
+
The website uses the quiet systems language: near-black olive surfaces, warm off-white text, sparse amber and green signals, square geometry, technical mono labels, condensed display typography, and a restrained 12-column editorial rhythm. Structure and reading order take priority over decoration.
|
|
44
|
+
|
|
45
|
+
Theme implementation lives in `src/app/global.css`. Keep new components responsive, maintain 44px interaction targets, and respect reduced-motion preferences.
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Action execution and evidence'
|
|
3
|
+
description: 'How intent is validated, grounded, delivered, checked, and converted into one immutable successor state.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
An action is not considered successful merely because an input API accepted it. The runtime separates intent, delivery, and evidence so uncertain effects remain explicit.
|
|
7
|
+
|
|
8
|
+
## Ownership by layer
|
|
9
|
+
|
|
10
|
+
[`src/actions.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/actions.ts) validates action shapes, normalizes intent, resolves targets, tracks dependent focus, and decides whether retry is safe. [`src/bridge.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/bridge.ts) validates state ownership, acquires the resource lane, and coordinates the transaction. The selected platform backend grounds coordinates and refs, performs preflight, delivers input, and gathers evidence.
|
|
11
|
+
|
|
12
|
+
```text
|
|
13
|
+
intent → state validation → resource lock → grounding → preflight → delivery → evidence → successor observation
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Dependent transactions
|
|
17
|
+
|
|
18
|
+
One `act_ui` call can contain several ordered steps when no intermediate observation is required. The transaction validates one base state, stays inside one resource lane, and stops at the first failed or invalidated step. Partial results identify the checked boundary, after which the caller must observe again.
|
|
19
|
+
|
|
20
|
+
Focus established by an editable click can carry into a following unscoped typing step. This dependency is transaction-local rather than a mutable global focus assumption.
|
|
21
|
+
|
|
22
|
+
## Delivery versus success
|
|
23
|
+
|
|
24
|
+
Backends report `worked`, `didnt`, or `unknown`. Read-back values, selection changes, focused-window changes, sheets, and root deltas can provide evidence. A posted pointer or keyboard event alone may remain unknown.
|
|
25
|
+
|
|
26
|
+
Optional `expect` conditions add semantic evidence such as text or a role appearing or disappearing. A failed postcondition changes the outcome to `didnt`; event delivery is not upgraded to success.
|
|
27
|
+
|
|
28
|
+
## Retry safety
|
|
29
|
+
|
|
30
|
+
A retry is allowed only when checked evidence shows that the earlier attempt had no effect and the next strategy is policy-compliant. Ambiguous pointer outcomes are not replayed because duplicate delivery could produce a second side effect.
|
|
31
|
+
|
|
32
|
+
Platform mechanisms differ. The macOS backend can use AX operations, background `CGEvent` delivery, or controlled foreground fallback; [Actions and input delivery](../reference/platforms/macos/actions.mdx) documents that strategy. Windows uses UIA and native input while preserving the same outcome contract.
|
|
33
|
+
|
|
34
|
+
## Successor state
|
|
35
|
+
|
|
36
|
+
After execution settles, the backend observes one final root state. The runtime stores that complete immutable successor and renders a compact diff only when identity confidence and change size make the diff trustworthy. Otherwise it returns a folded full view.
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Architecture'
|
|
3
|
+
description: 'How immutable UI state, resource scheduling, observations, and checked actions fit together.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
`pi-computer-use` exposes one state-scoped interface for desktop and browser UI:
|
|
7
|
+
|
|
8
|
+
```text
|
|
9
|
+
find roots → observe one root → search/expand/inspect its state → act from that state
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
The agent still sees a multi-root forest. `find_roots` returns stable root refs (`@rN`) for desktop windows, transient surfaces, and CDP pages. Observing one root produces an immutable element tree whose refs (`@eN`) belong only to that returned `stateId`. Progressive disclosure is unchanged: the first view lists actionable controls, while `search_ui`, `expand_ui`, and `inspect_ui` query the full stored tree.
|
|
13
|
+
|
|
14
|
+
## Runtime model
|
|
15
|
+
|
|
16
|
+
Every live request follows one path:
|
|
17
|
+
|
|
18
|
+
```text
|
|
19
|
+
load saved state → prepare actions → run → observe → save → show changes
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
The implementation keeps that ownership explicit:
|
|
23
|
+
|
|
24
|
+
| Module | Owns |
|
|
25
|
+
|---|---|
|
|
26
|
+
| `state.ts` | Saved UI states, request-local state, restoration, and serialization |
|
|
27
|
+
| `actions.ts` | Validation, normalization, target resolution, dependent focus, and safe retry eligibility |
|
|
28
|
+
| `bridge.ts` | Tool coordination and resource scheduling |
|
|
29
|
+
| `view.ts` | Stable public refs and full-versus-changes rendering |
|
|
30
|
+
| `outline.ts` | Parsing and querying complete UI trees |
|
|
31
|
+
| `platform/*` | OS observation, input mechanics, and native protocol translation |
|
|
32
|
+
|
|
33
|
+
```mermaid
|
|
34
|
+
flowchart TB
|
|
35
|
+
A["Agent tool calls<br/>Pi may issue them concurrently"] --> C["State-scoped contract<br/>root @r / stateId / element @e"]
|
|
36
|
+
C --> Q{"Cached or live?"}
|
|
37
|
+
Q -->|"cached search / expand / inspect"| S["Bounded immutable state store"]
|
|
38
|
+
Q -->|"observe / act / live read"| R["Resource scheduler"]
|
|
39
|
+
R --> D1["desktop-pid:123 lane"]
|
|
40
|
+
R --> D2["desktop-pid:456 lane"]
|
|
41
|
+
R --> B1["cdp:page-A lane"]
|
|
42
|
+
D1 --> P["Platform-neutral backend"]
|
|
43
|
+
D2 --> P
|
|
44
|
+
B1 --> Cdp["Target-keyed CDP connections"]
|
|
45
|
+
P --> M["macOS AX/capture helper"]
|
|
46
|
+
P --> W["Windows UIA/input helper"]
|
|
47
|
+
P --> L["Linux AT-SPI2 helper"]
|
|
48
|
+
M --> O["OS UI resources"]
|
|
49
|
+
W --> O
|
|
50
|
+
L --> O
|
|
51
|
+
Cdp --> O
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
There is no session-wide current UI. Every call hydrates request-local state from `stateId`; unrelated calls cannot overwrite one another. Stored observations are immutable and bounded, so old refs either resolve to their exact observation or fail clearly after eviction.
|
|
55
|
+
|
|
56
|
+
The scheduler serializes live operations only when they address the same physical resource. Different desktop processes and different CDP targets can run concurrently. Cached outline queries bypass it entirely. Every resource has a monotonically increasing epoch. A mutating call must present the epoch captured by its state; if another write won the race, the stale call is rejected before dispatch.
|
|
57
|
+
|
|
58
|
+
Desktop scheduling is conservatively keyed by process rather than window because accessibility focus, menus, and physical input can cross window boundaries inside an app. CDP scheduling is keyed by page target. Global physical input remains mutex-protected in the native helper; semantic AX/UIA work can overlap where the platform permits it.
|
|
59
|
+
|
|
60
|
+
## Observation and progressive disclosure
|
|
61
|
+
|
|
62
|
+
`observe_ui` asks the selected backend for one look. A desktop look combines root identity, accessibility structure, optional image evidence, OCR boxes when required, and capture metadata. A browser look converts the CDP accessibility tree into the same serialized outline shape.
|
|
63
|
+
|
|
64
|
+
The bridge stores the complete observation and returns a compact control list; `detail: "outline"` and `expand_ui` render the folded tree. The state owns its refs:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
@r3 browser page
|
|
68
|
+
state A (epoch 4)
|
|
69
|
+
@e1 document
|
|
70
|
+
@e7 button
|
|
71
|
+
|
|
72
|
+
@r8 desktop window
|
|
73
|
+
state B (epoch 2)
|
|
74
|
+
@e1 application
|
|
75
|
+
@e12 text field
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
`search_ui` and ordinary inspection are pure cached queries. A live escalation such as OCR or a refreshed truncated region is epoch-checked and resource-scheduled. It cannot silently graft data across a concurrent mutation.
|
|
79
|
+
|
|
80
|
+
## Acting and batching
|
|
81
|
+
|
|
82
|
+
`act_ui` runs one dependent action list:
|
|
83
|
+
|
|
84
|
+
```ts
|
|
85
|
+
act_ui({
|
|
86
|
+
stateId,
|
|
87
|
+
actions: [
|
|
88
|
+
{ action: "setText", ref: "@e12", text: "hello" },
|
|
89
|
+
{ action: "press", ref: "@e18" },
|
|
90
|
+
],
|
|
91
|
+
})
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Transactions may include a semantic postcondition:
|
|
95
|
+
|
|
96
|
+
```ts
|
|
97
|
+
act_ui({
|
|
98
|
+
stateId,
|
|
99
|
+
actions: [{ action: "press", ref: "@e9" }],
|
|
100
|
+
expect: { text: "Saved", timeoutMs: 3000 }
|
|
101
|
+
})
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
With a postcondition, the backend waits for the requested text or role to
|
|
105
|
+
appear (or disappear with `gone: true`) before reporting success. It records
|
|
106
|
+
whether the condition was newly verified, already present before delivery, or
|
|
107
|
+
failed. A failed postcondition changes the execution outcome to `didnt`; event
|
|
108
|
+
delivery alone is never treated as semantic success.
|
|
109
|
+
|
|
110
|
+
One action is represented by an array of length one. A multi-action transaction is appropriate only when no intermediate observation is needed. The runtime validates one base state, acquires one resource lane, and sends the steps as one native helper transaction. The helper captures one pre-transaction root baseline, executes and verifies steps in order, and stops on the first failed or invalidated step. Partial results include `stoppedAt`, so callers know the exact checked boundary and must re-observe before continuing. The helper performs one final root-delta settle and the bridge produces one final observation. There is no alternate sequential protocol. This is not a mechanism for parallel actions within one UI resource.
|
|
111
|
+
|
|
112
|
+
The bridge resolves model intent; the backend/helper owns grounding, preflight, delivery, and evidence. Accessibility capabilities choose an initial strategy but are not treated as proof that the intended result occurred. Editable-region clicks establish foreground focus for following unscoped keyboard steps in the same transaction. Raw coordinates are tied to the image-bearing state that produced them. Web-backed editable controls use atomic keyboard events and web-backed buttons use pointer events so application state receives normal input events rather than only a changed AX value. A helper result reports `worked`, `didnt`, or `unknown`, including evidence and shallow root changes where available. The [macOS implementation reference](../reference/platforms/macos/actions.mdx) documents that backend's exact Accessibility, web-control, and synthesized-event paths.
|
|
113
|
+
|
|
114
|
+
With `headless: true`, the background boundary is strict: Pi must never activate or raise an application, change the user's focused window, move the global cursor, post synthesized input, or display the agent cursor or activity glow. On macOS, the helper rejects any action that would need synthesized pointer or keyboard input with `foreground_required`, and the bridge returns that error instead of retrying in the foreground ([macOS actions reference](../reference/platforms/macos/actions.mdx#headless-policy)). With `headless: false` (the default), credible semantic activation may begin in the background, editable clicks preserve the focus they establish for following unscoped keyboard input, and keyboard input with a checked `didnt` result may retry in the foreground because the first attempt proved side-effect-free. Focus-preserving native keyboard requests do not raise or re-focus the outer window between semantic activation and event delivery; canvas editors such as PowerPoint otherwise collapse an inner text editor back to placeholder selection. Ambiguous pointer outcomes are never replayed. On macOS, `cursor_overlay` schedules a visual, noninteractive overlay separately from action delivery for non-headless background pointer actions; foreground HID actions use only the physical cursor, and the overlay is currently main-display-only ([macOS implementation reference](../reference/platforms/macos/actions.mdx#agent-cursor-overlay)). With `activity_glow: true` (default `false`), non-headless macOS sessions hold a persistent helper connection that owns a click-through border on each screen until the agent run ends. The helper combines active connections and removes their state on disconnect.
|
|
115
|
+
|
|
116
|
+
The `headless` configuration option determines whether foreground execution is prohibited. Fallback-capable multi-action calls execute one checked action at a time, retain click-established focus, and stop on a checked `didnt`; strict-headless calls retain native transactional batching.
|
|
117
|
+
|
|
118
|
+
## Successor diffs
|
|
119
|
+
|
|
120
|
+
Complete observations remain immutable and bounded internally. The initial observation renders the compact control list. After a mutation, `view.ts` stabilizes public refs using confident native identities, saves the complete resulting state, and compares it with the base state. Small trustworthy results render `added`, `updated`, and `removed` nodes plus the next `stateId`. Root appearance, closure, and focus changes remain part of the run result.
|
|
121
|
+
|
|
122
|
+
Diff rendering falls back to the compact control list when the root identity changes, too few successor nodes can be matched confidently, or the change budget would make a patch less useful than the full view. Cached queries always operate on the complete stored state, never on a partially applied model-side tree.
|
|
123
|
+
|
|
124
|
+
## Browser support
|
|
125
|
+
|
|
126
|
+
Browser pages are roots, not a second agent-facing context hierarchy. `launch_browser` returns browser-page `@r` refs; `observe_ui` returns their normal outline and `stateId`. `read_text`, `wait_for`, `act_ui`, `navigate_browser`, and `evaluate_browser` derive the CDP target from that state. Internal CDP target identifiers never need to be copied between public tools.
|
|
127
|
+
|
|
128
|
+
## Native transports
|
|
129
|
+
|
|
130
|
+
The macOS socket server and Windows line protocol accept multiple in-flight requests and correlate responses by request id. macOS protects shared AX ref/look stores and the root-event sequence; Windows uses a fixed worker pool and initializes UIA per worker thread. Both platforms keep eight immutable native look records and serialize global synthesized input. Target focus, bounded occlusion preflight, and event delivery share that same critical section; another worker cannot change the foreground between validation and delivery. UIA-only Windows batches do not acquire the global input lock, while any batch that may fall back to pointer or keyboard delivery holds it for the complete transaction. Further event-delivery and occlusion details live in the [macOS implementation reference](../reference/platforms/macos/implementation.mdx) and [Windows bridge reference](../reference/platforms/windows.mdx).
|
|
131
|
+
|
|
132
|
+
The Linux helper is a local JSON-lines child process with correlated concurrent requests. It snapshots roots over AT-SPI2 and attempts semantic `Action`/`EditableText` delivery first. On X11, EWMH enriches root identity/focus, XComposite (with `GetImage` fallback) supplies PNG capture, and non-headless policies may use serialized XTEST physical input. Strict headless/background policy blocks XTEST and focus. Wayland diagnostics only reads portal version and capability properties; no portal session, capture, or input path is implemented. The [Linux support guide](../how-to-guides/linux.mdx) lists the exact capability matrix.
|
|
133
|
+
|
|
134
|
+
Windows UIA extraction is bounded. When the native limit omits descendants, the nearest retained ancestors are marked `truncated`; `expand_ui` performs a scoped look and the helper carries forward the untouched refs into the new immutable look record. Windows root deltas combine an event journal with authoritative before/after snapshots. `SetWinEventHook` accelerates settling and retains short-lived root transitions, while snapshots remain the source of truth for persistent state.
|
|
135
|
+
|
|
136
|
+
## Preventing platform drift
|
|
137
|
+
|
|
138
|
+
Platform parity is defined by invariants, not matching source structure. Every helper reports an `architectureVersion` and the invariant set it implements. Startup fails closed if either helper omits a required invariant. The TypeScript backend interface and conformance check additionally require both platforms to expose the same observation, text ownership, batching, and lifecycle operations.
|
|
139
|
+
|
|
140
|
+
Changes to a native backend should therefore include three layers of evidence:
|
|
141
|
+
|
|
142
|
+
1. shared contract tests for request and response semantics;
|
|
143
|
+
2. target-native compilation and deterministic native unit tests;
|
|
144
|
+
3. the same black-box Cubench properties on an interactive host for that platform.
|
|
145
|
+
|
|
146
|
+
OS-specific mechanisms can differ—Accessibility, Core Graphics, ScreenCaptureKit, Vision, and AppKit on macOS; UIA and Windows capture/input APIs on Windows; AT-SPI2 plus optional X11 EWMH/XComposite/XTEST on Linux—but state ownership, bounds, progressive disclosure, transaction boundaries, and honest outcomes may not. The [macOS implementation reference](../reference/platforms/macos/implementation.mdx) records the current API choices, delivery policies, evidence boundaries, and known limits so this explanation does not duplicate platform claims. The agent-cursor overlay lives inside the existing helper because native action grounding owns the final screen point; keeping it there avoids a second coordinate transform or public cursor tool surface. The helper's socket server runs off the main thread while AppKit owns the main run loop, and the helper excludes its click-through overlay from root discovery. Cursor animation is observational: newer actions may supersede an in-flight path, but rendering never blocks action delivery or verification.
|
|
147
|
+
|
|
148
|
+
## Design constraints
|
|
149
|
+
|
|
150
|
+
- Preserve the multi-root forest and progressive disclosure.
|
|
151
|
+
- Make state ownership explicit; never depend on a mutable session-wide current UI.
|
|
152
|
+
- Reject stale writes before dispatch using resource epochs.
|
|
153
|
+
- Serialize by physical resource, not by tool name or whole session.
|
|
154
|
+
- Prefer platform semantics as the cheapest credible attempt, then trust verified outcomes over advertised capabilities.
|
|
155
|
+
- Preserve focus established by one transaction step for dependent keyboard steps.
|
|
156
|
+
- Store full immutable states and render the smallest trustworthy resulting view.
|
|
157
|
+
- Keep observation compact and expand locally.
|
|
158
|
+
- Let the backend/helper own action grounding and verification.
|
|
159
|
+
- Keep platform mechanisms behind the platform-neutral seam.
|
|
160
|
+
- Treat batching as one-resource transaction amortization, not a separate execution architecture.
|
|
161
|
+
- Fail closed when an action outcome is uncertain; a later call must observe again.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Overview'
|
|
3
|
+
description: 'Understand why pi-computer-use uses immutable state, resource scheduling, progressive disclosure, and checked execution.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Explanation pages build a mental model of the system. They answer why the runtime is structured this way; use [reference](/reference) when you need exact APIs, options, platform mechanisms, or limits.
|
|
7
|
+
|
|
8
|
+
## Start with the system view
|
|
9
|
+
|
|
10
|
+
- [Architecture](./architecture.mdx) — how the complete runtime fits together.
|
|
11
|
+
|
|
12
|
+
## Follow a runtime concern
|
|
13
|
+
|
|
14
|
+
- [State ownership and scheduling](./state-and-scheduling.mdx) — `state.ts`, resource epochs, concurrency, and stale-write rejection.
|
|
15
|
+
- [Observation and progressive disclosure](./observation-pipeline.mdx) — platform observations, `outline.ts`, immutable storage, folded views, and scoped expansion.
|
|
16
|
+
- [Action execution and evidence](./action-pipeline.mdx) — `actions.ts`, bridge coordination, native delivery, checked outcomes, and successor states.
|
|
17
|
+
- [Platform boundary](./platform-boundary.mdx) — how the shared runtime delegates to macOS, Windows, Linux, and browser backends without pretending their APIs are identical.
|
|
18
|
+
|
|
19
|
+
If your question names a concrete operating-system API—such as macOS AX, ScreenCaptureKit, or Windows UIA—go directly to [platform reference](/reference/platforms).
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Observation and progressive disclosure'
|
|
3
|
+
description: 'How platform observations become complete immutable trees, compact outlines, local queries, and image evidence.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
Observation separates what the runtime stores from what it initially shows the agent. The backend collects a complete bounded state, while the first response folds that state into a compact outline.
|
|
7
|
+
|
|
8
|
+
## Pipeline
|
|
9
|
+
|
|
10
|
+
```text
|
|
11
|
+
platform root → semantic tree + optional image → normalized outline → immutable state → folded response
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
The main ownership boundaries are:
|
|
15
|
+
|
|
16
|
+
- [`src/platform/`](https://github.com/injaneity/pi-computer-use/tree/main/src/platform) retrieves platform-specific roots, semantic structure, text, images, and native metadata;
|
|
17
|
+
- [`src/outline.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/outline.ts) parses and queries complete outline trees;
|
|
18
|
+
- [`src/state.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/state.ts) stores the immutable result;
|
|
19
|
+
- [`src/view.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/view.ts) produces stable public refs and compact renderings.
|
|
20
|
+
|
|
21
|
+
## Progressive disclosure
|
|
22
|
+
|
|
23
|
+
`observe_ui` returns enough ancestry and local detail to orient the agent without dumping every descendant. `search_ui`, `expand_ui`, and `inspect_ui` query the complete saved tree, so folding affects presentation rather than data ownership.
|
|
24
|
+
|
|
25
|
+
Most of those queries are pure and cached. A request that needs fresh OCR or recovery of a truncated region becomes a live, epoch-checked observation and produces a new state instead of mutating the old one.
|
|
26
|
+
|
|
27
|
+
## Semantic and visual evidence
|
|
28
|
+
|
|
29
|
+
Desktop observations can combine an accessibility tree with an optional image. Visual OCR boxes supplement sparse semantic trees but do not acquire native action capabilities. Browser observations normalize the CDP accessibility tree into the same agent-facing outline model.
|
|
30
|
+
|
|
31
|
+
On macOS, AX extraction and image capture are separate subsystems; use [Accessibility and AX](../reference/platforms/macos/accessibility.mdx) or [Capture and OCR](../reference/platforms/macos/capture.mdx) for exact behavior. Windows uses UI Automation extraction and its native capture path.
|
|
32
|
+
|
|
33
|
+
## Bounded completeness
|
|
34
|
+
|
|
35
|
+
A platform walk can stop at implementation limits. Rather than implying completeness, the nearest retained ancestor is marked `truncated`. Scoped expansion can then retrieve the missing region into a successor state while preserving unaffected identities where confidence allows.
|
|
36
|
+
|
|
37
|
+
Continue to [State ownership and scheduling](./state-and-scheduling.mdx) for concurrency rules or [Action execution and evidence](./action-pipeline.mdx) for mutation.
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Platform boundary'
|
|
3
|
+
description: 'How the shared runtime delegates observation and input to macOS, Windows, Linux, and browser backends without hiding platform differences.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The agent contract is shared, but operating-system mechanics are not forced into identical source structures. A platform-neutral seam keeps state ownership and outcomes consistent while allowing each backend to use credible native APIs.
|
|
7
|
+
|
|
8
|
+
## Shared contract
|
|
9
|
+
|
|
10
|
+
[`src/platform/types.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/platform/types.ts) defines the backend operations consumed by the runtime. Shared TypeScript code owns public refs, state IDs, resource epochs, action intent, and result rendering. Backends own native root enumeration, observation, coordinate grounding, delivery, and platform evidence.
|
|
11
|
+
|
|
12
|
+
## macOS path
|
|
13
|
+
|
|
14
|
+
[`src/platform/macos/`](https://github.com/injaneity/pi-computer-use/tree/main/src/platform/macos) manages helper lifecycle, permissions, and protocol translation. [`native/macos/bridge.swift`](https://github.com/injaneity/pi-computer-use/blob/main/native/macos/bridge.swift) integrates Accessibility, Core Graphics, ScreenCaptureKit, Vision, AppKit, and synthesized events.
|
|
15
|
+
|
|
16
|
+
The macOS reference is organized by those implementation subsystems:
|
|
17
|
+
|
|
18
|
+
- [Accessibility and AX](../reference/platforms/macos/accessibility.mdx)
|
|
19
|
+
- [Capture and OCR](../reference/platforms/macos/capture.mdx)
|
|
20
|
+
- [Actions and input delivery](../reference/platforms/macos/actions.mdx)
|
|
21
|
+
- [Complete implementation reference](../reference/platforms/macos/implementation.mdx)
|
|
22
|
+
|
|
23
|
+
## Windows path
|
|
24
|
+
|
|
25
|
+
[`src/platform/windows/`](https://github.com/injaneity/pi-computer-use/tree/main/src/platform/windows) translates the shared contract to the Windows native bridge. UI Automation provides semantic extraction and actions, while the helper owns Windows capture, input, event journals, and authoritative snapshots. Exact protocol behavior is in the [Windows bridge reference](../reference/platforms/windows.mdx).
|
|
26
|
+
|
|
27
|
+
## Linux path
|
|
28
|
+
|
|
29
|
+
[`src/platform/linux/`](https://github.com/injaneity/pi-computer-use/tree/main/src/platform/linux) translates the shared contract to the Rust helper in [`native/linux/bridge-rs/`](https://github.com/injaneity/pi-computer-use/tree/main/native/linux/bridge-rs). AT-SPI2 provides semantic extraction and actions on every session; X11 adds EWMH window metadata and focus, XComposite capture, and policy-gated XTEST input, while native Wayland stays semantic-only. The capability matrix is in the [Linux support guide](../how-to-guides/linux.mdx).
|
|
30
|
+
|
|
31
|
+
## Browser path
|
|
32
|
+
|
|
33
|
+
Browser pages are roots in the same multi-root forest. CDP accessibility trees become normal outlines, and page-target identity supplies the resource key. Browser tools derive the internal CDP target from public root or state ownership rather than asking the agent to manage protocol identifiers.
|
|
34
|
+
|
|
35
|
+
## Parity without pretending equivalence
|
|
36
|
+
|
|
37
|
+
Platform parity means preserving shared invariants: immutable states, bounded observations, honest truncation, checked transactions, resource ordering, and explicit uncertainty. It does not mean claiming that AX, UIA, and AT-SPI2 expose identical roles, actions, window identity, or capture behavior.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'State ownership and scheduling'
|
|
3
|
+
description: 'Why observations are immutable, refs are state-owned, and live work is serialized by physical resource.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
The runtime has no session-wide “current UI.” That choice prevents one concurrent tool call from silently changing the meaning of refs used by another call.
|
|
7
|
+
|
|
8
|
+
## State ownership
|
|
9
|
+
|
|
10
|
+
[`src/state.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/state.ts) owns saved observations, request-local hydration, restoration, and bounded storage. An `@e` ref belongs to exactly one `stateId`; it is meaningful only inside that immutable observation. [`src/view.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/view.ts) assigns public refs and renders either a full view or a trustworthy successor diff.
|
|
11
|
+
|
|
12
|
+
This produces a simple rule: cached reading can reuse a state, but mutation must prove that the state still represents the resource epoch from which it was observed.
|
|
13
|
+
|
|
14
|
+
## Resource scheduling
|
|
15
|
+
|
|
16
|
+
[`src/bridge.ts`](https://github.com/injaneity/pi-computer-use/blob/main/src/bridge.ts) coordinates live work by physical resource rather than by tool name or whole session.
|
|
17
|
+
|
|
18
|
+
- desktop work is conservatively keyed by process because focus, menus, and input can cross windows inside one app;
|
|
19
|
+
- browser work is keyed by CDP page target;
|
|
20
|
+
- cached search, expansion, and ordinary inspection do not enter a live resource lane;
|
|
21
|
+
- global synthesized input remains serialized by the native helper.
|
|
22
|
+
|
|
23
|
+
Independent apps and browser pages can therefore progress concurrently, while operations that could interfere with one another remain ordered.
|
|
24
|
+
|
|
25
|
+
## Epoch checks
|
|
26
|
+
|
|
27
|
+
Each resource has a monotonically increasing epoch. A mutating call presents the epoch captured by its base state. If another mutation has already advanced the resource, the stale call is rejected before delivery and the caller must observe again.
|
|
28
|
+
|
|
29
|
+
This is stricter than checking whether a window still exists: the root may remain present while its actionable state has changed.
|
|
30
|
+
|
|
31
|
+
## Why immutable states matter
|
|
32
|
+
|
|
33
|
+
Immutability enables deterministic cached queries, explicit stale-state errors, safe parallelism across unrelated roots, and successor diffs that compare two complete observations. It also keeps recovery honest: the runtime never patches a partially trusted model-side tree and calls it current.
|
|
34
|
+
|
|
35
|
+
Continue to [Observation and progressive disclosure](./observation-pipeline.mdx) for how a complete state is built, or [Action execution and evidence](./action-pipeline.mdx) for how a state becomes a checked successor.
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Develop and validate changes'
|
|
3
|
+
description: 'Repository layout, validation, native helper development, and release signing.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
## Repository layout
|
|
7
|
+
|
|
8
|
+
```text
|
|
9
|
+
extensions/computer-use.ts Public Pi tool registration
|
|
10
|
+
src/bridge.ts TypeScript runtime and tool implementation
|
|
11
|
+
src/actions.ts Action preparation and result reconciliation
|
|
12
|
+
src/runtime.ts Immutable state store and resource scheduler
|
|
13
|
+
src/state.ts Saved UI state ownership and restoration
|
|
14
|
+
src/view.ts Stable refs and resulting-state change views
|
|
15
|
+
src/outline.ts Outline parsing, folding, control lists, search, and ref mapping
|
|
16
|
+
src/note.ts Disposable running-note generation
|
|
17
|
+
native/macos/bridge.swift macOS helper for AX, capture, permissions, and input
|
|
18
|
+
native/macos/activity_glow.swift macOS activity indicator windows and client ownership
|
|
19
|
+
native/windows/ Windows backend/helper code when developing on Windows
|
|
20
|
+
native/linux/bridge-rs/ Linux AT-SPI2 helper (Rust)
|
|
21
|
+
scripts/build-native.mjs macOS helper build script
|
|
22
|
+
scripts/setup-helper.mjs macOS helper install script
|
|
23
|
+
scripts/check-invariants.mjs Architecture invariant checks
|
|
24
|
+
scripts/check-runtime-concurrency.mjs Scheduler/state concurrency checks
|
|
25
|
+
scripts/pi-cubench-agent.mjs Cubench gateway adapter using registered Pi tools
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
The public tool surface lives in `extensions/computer-use.ts`. Keep it small. Internal complexity belongs in `src/bridge.ts`, `src/outline.ts`, `src/note.ts`, and the native helper.
|
|
29
|
+
|
|
30
|
+
## Checks
|
|
31
|
+
|
|
32
|
+
Run all static checks:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
npm test
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
This runs TypeScript, generated documentation checks, tool-schema compatibility checks, architecture invariants, and native helper checks available on the current platform. After changing a tool definition or a source-owned `PI_DOCS_REFERENCE` block, run `npm run docs:generate` and commit the regenerated pages.
|
|
39
|
+
|
|
40
|
+
On macOS, rebuild the native helper after Swift changes:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
npm run build:native
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## Architecture rules
|
|
47
|
+
|
|
48
|
+
The runtime is state-scoped and outline-first:
|
|
49
|
+
|
|
50
|
+
- `observe_ui` returns a compact control list and running note; `detail: "outline"` returns the folded outline.
|
|
51
|
+
- `search_ui`, `expand_ui`, and `inspect_ui` provide progressive disclosure.
|
|
52
|
+
- `act_ui` is the only public desktop action entrypoint.
|
|
53
|
+
- UI observations are immutable records; request-local hydration replaces global current state.
|
|
54
|
+
- Cached queries bypass scheduling; live work is ordered per physical resource.
|
|
55
|
+
- Browser pages and desktop surfaces share the `@r` root forest and `@e` outline contract.
|
|
56
|
+
- The helper owns grounding, preflight, execution, and verification.
|
|
57
|
+
- Removed direct tools such as `screenshot`, `click`, `set_text`, and `computer_actions` should not reappear as public extension tools.
|
|
58
|
+
|
|
59
|
+
Run invariants after architecture changes:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
npm run test:invariants
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Set `PI_CU_LIVE=1` only when you want live helper checks in addition to static checks.
|
|
66
|
+
|
|
67
|
+
## Cubench
|
|
68
|
+
|
|
69
|
+
`scripts/pi-cubench-agent.mjs` drives a headed Cubench Chromium window through the same registered Pi tools used by the extension. Cubench must launch its web driver headed (the current development tree accepts `CUBENCH_HEADLESS=0`):
|
|
70
|
+
|
|
71
|
+
```bash
|
|
72
|
+
CUBENCH_HEADLESS=0 node ../cubench/bin/cubench.mjs suite run \
|
|
73
|
+
--suite ../cubench/suites/core.json \
|
|
74
|
+
--agent "node --experimental-transform-types $PWD/scripts/pi-cubench-agent.mjs" \
|
|
75
|
+
--driver web \
|
|
76
|
+
--trials 3 \
|
|
77
|
+
--label picu
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
The adapter uses Cubench only for the instruction and final oracle; UI observation and action go through `pi-computer-use`. Gateway action/observation counters therefore do not trigger Cubench interference hooks, so stale/reorder cases need a native-driver integration before their interference timing can be treated as benchmark evidence.
|
|
81
|
+
|
|
82
|
+
## Native platform helpers
|
|
83
|
+
|
|
84
|
+
On macOS, the helper installed for permissions is normally:
|
|
85
|
+
|
|
86
|
+
```text
|
|
87
|
+
~/Applications/pi-computer-use.app
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Existing writable system-wide installs remain at `/Applications/pi-computer-use.app`. The macOS helper targets macOS 14 and links ApplicationServices, AppKit, ScreenCaptureKit, Foundation, SwiftUI, Vision, and ImageIO through the Swift sources and build scripts. The [macOS implementation reference](../reference/platforms/macos/implementation.mdx) records the exact platform behavior and Apple API citations; update it whenever the helper changes.
|
|
91
|
+
|
|
92
|
+
Local setup chooses a Developer ID identity when one is available, otherwise its managed local signing identity, and finally ad-hoc signing. The installer refuses to replace an existing helper with an ad-hoc rebuild unless `PI_COMPUTER_USE_ALLOW_ADHOC_UPDATE=1` is set. This is project safety policy, not a guarantee about permission retention ([setup-helper.mjs](https://github.com/injaneity/pi-computer-use/blob/main/scripts/setup-helper.mjs#L427)).
|
|
93
|
+
|
|
94
|
+
On Windows, development uses the Windows platform backend/helper and the active desktop session rather than the macOS app bundle.
|
|
95
|
+
|
|
96
|
+
On Linux, install Rust/Cargo and run `npm run build:linux`, `npm run test:linux`, and `npm run test:linux-scripts`. Live checks must run inside the target user's graphical D-Bus session. The helper installs to `~/.pi/agent/helpers/pi-computer-use/linux-bridge`.
|
|
97
|
+
|
|
98
|
+
For an isolated X11 acceptance run, install Xvfb, xfwm4, the AT-SPI2 runtime, xfce4-appfinder, and xfce4-terminal, then build and install the helper before running the explicitly gated live suite:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
npm run build:linux
|
|
102
|
+
node scripts/setup-helper.mjs --platform linux
|
|
103
|
+
npm run test:linux-live
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
The harness creates its own D-Bus and Xvfb session. It fails rather than silently passing when the live flag, helper, accessibility bridge, or required X11 applications are unavailable.
|
|
107
|
+
|
|
108
|
+
## macOS release signing
|
|
109
|
+
|
|
110
|
+
`.github/workflows/publish-npm.yml` is the release source of truth. It builds a universal helper on `macos-14`, assembles the app with a `14.0` minimum system version, signs it with the configured certificate and hardened runtime, and verifies the signature. When the repository variable `NOTARIZE` is `true`, it submits and staples the app before packaging ([publish-npm.yml](https://github.com/injaneity/pi-computer-use/blob/main/.github/workflows/publish-npm.yml#L39)).
|
|
111
|
+
|
|
112
|
+
The workflow requires `APPLICATION_CERT_BASE64`, `CERT_PASSWORD`, and `SIGN_IDENTITY`. Optional notarization additionally requires `TEAM_ID`, `APPLE_ID`, and `APP_SPECIFIC_PASSWORD`. It stages the helper in a draft GitHub Release, injects the same artifact into the npm package, publishes npm, and publishes the GitHub Release last.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: 'Overview'
|
|
3
|
+
description: 'Task-focused procedures for operating and repairing pi-computer-use.'
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
How-to guides solve a specific operational problem without teaching the whole system.
|
|
7
|
+
|
|
8
|
+
- [Troubleshoot setup and runtime failures](./troubleshooting.mdx) — repair helper installation, permissions, capture, stale state, coordinates, and browser fallback.
|
|
9
|
+
- [Run on Linux](./linux.mdx) — set up the AT-SPI2 helper and check the X11, Wayland, headless, and security boundaries.
|
|
10
|
+
- [Develop and validate changes](./develop-and-validate.mdx) — run checks, preserve invariants, work on native helpers, and prepare signed macOS releases.
|
|
11
|
+
|
|
12
|
+
Use the [macOS implementation reference](/reference/platforms/macos) when a procedure depends on platform API behavior.
|