@roam-agent/roam-computer-use 0.0.0-stage → 0.5.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/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 +105 -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/lib/roam-bridge.mjs +98 -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
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
use serde_json::json;
|
|
2
|
+
|
|
3
|
+
/// The protocol types under test are expected to be exported from the library crate.
|
|
4
|
+
use windows_bridge::{protocol::PROTOCOL_VERSION, ErrorCode, ProtocolError, Request, Response};
|
|
5
|
+
|
|
6
|
+
// ---------------------------------------------------------------------------
|
|
7
|
+
// Request parsing
|
|
8
|
+
// ---------------------------------------------------------------------------
|
|
9
|
+
|
|
10
|
+
#[test]
|
|
11
|
+
fn test_parse_valid_request() {
|
|
12
|
+
let raw = json!({
|
|
13
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
14
|
+
"id": "req-001",
|
|
15
|
+
"cmd": "checkPermissions",
|
|
16
|
+
"args": {}
|
|
17
|
+
});
|
|
18
|
+
let req: Request = serde_json::from_value(raw).expect("valid request");
|
|
19
|
+
assert_eq!(req.protocol_version, PROTOCOL_VERSION);
|
|
20
|
+
assert_eq!(req.id, "req-001");
|
|
21
|
+
assert_eq!(req.cmd, "checkPermissions");
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
#[test]
|
|
25
|
+
fn test_parse_request_with_args() {
|
|
26
|
+
let raw = json!({
|
|
27
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
28
|
+
"id": "req-002",
|
|
29
|
+
"cmd": "listWindows",
|
|
30
|
+
"args": { "pid": 1234 }
|
|
31
|
+
});
|
|
32
|
+
let req: Request = serde_json::from_value(raw).expect("valid request with args");
|
|
33
|
+
assert_eq!(req.protocol_version, PROTOCOL_VERSION);
|
|
34
|
+
assert_eq!(req.id, "req-002");
|
|
35
|
+
assert_eq!(req.cmd, "listWindows");
|
|
36
|
+
assert!(req.args.is_object());
|
|
37
|
+
assert_eq!(req.args["pid"], 1234);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
#[test]
|
|
41
|
+
fn test_parse_request_missing_id() {
|
|
42
|
+
let raw = json!({
|
|
43
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
44
|
+
"cmd": "checkPermissions",
|
|
45
|
+
"args": {}
|
|
46
|
+
});
|
|
47
|
+
let result: Result<Request, _> = serde_json::from_value(raw);
|
|
48
|
+
assert!(result.is_err(), "missing id should be rejected");
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
#[test]
|
|
52
|
+
fn test_parse_request_missing_cmd() {
|
|
53
|
+
let raw = json!({
|
|
54
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
55
|
+
"id": "req-003",
|
|
56
|
+
"args": {}
|
|
57
|
+
});
|
|
58
|
+
let result: Result<Request, _> = serde_json::from_value(raw);
|
|
59
|
+
assert!(result.is_err(), "missing cmd should be rejected");
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
#[test]
|
|
63
|
+
fn test_parse_request_wrong_types() {
|
|
64
|
+
// id must be a string
|
|
65
|
+
let raw = json!({
|
|
66
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
67
|
+
"id": 42,
|
|
68
|
+
"cmd": "test",
|
|
69
|
+
"args": {}
|
|
70
|
+
});
|
|
71
|
+
let result: Result<Request, _> = serde_json::from_value(raw);
|
|
72
|
+
assert!(result.is_err(), "non-string id should be rejected");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Success response serialization
|
|
77
|
+
// ---------------------------------------------------------------------------
|
|
78
|
+
|
|
79
|
+
#[test]
|
|
80
|
+
fn test_serialize_success_response() {
|
|
81
|
+
let resp = Response::ok("req-001", json!({ "ready": true }));
|
|
82
|
+
let json_str = serde_json::to_string(&resp).expect("serialize success");
|
|
83
|
+
let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
|
84
|
+
|
|
85
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
86
|
+
assert_eq!(parsed["id"], "req-001");
|
|
87
|
+
assert_eq!(parsed["ok"], true);
|
|
88
|
+
assert_eq!(parsed["result"]["ready"], true);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
#[test]
|
|
92
|
+
fn test_serialize_success_with_null_result() {
|
|
93
|
+
let resp = Response::ok("req-002", json!(null));
|
|
94
|
+
let json_str = serde_json::to_string(&resp).expect("serialize success null");
|
|
95
|
+
let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
|
96
|
+
|
|
97
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
98
|
+
assert_eq!(parsed["id"], "req-002");
|
|
99
|
+
assert_eq!(parsed["ok"], true);
|
|
100
|
+
assert_eq!(parsed["result"], serde_json::Value::Null);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
// Error response serialization
|
|
105
|
+
// ---------------------------------------------------------------------------
|
|
106
|
+
|
|
107
|
+
#[test]
|
|
108
|
+
fn test_serialize_capability_deferred_error() {
|
|
109
|
+
let err = ProtocolError::new(
|
|
110
|
+
"Window ref-backed actions are deferred in PR #1. \
|
|
111
|
+
This PR supports window discovery, screenshots, state IDs, \
|
|
112
|
+
and read-only UIA element discovery.",
|
|
113
|
+
ErrorCode::CapabilityDeferred,
|
|
114
|
+
);
|
|
115
|
+
let resp = Response::err("req-003", err);
|
|
116
|
+
let json_str = serde_json::to_string(&resp).expect("serialize error");
|
|
117
|
+
let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
|
118
|
+
|
|
119
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
120
|
+
assert_eq!(parsed["id"], "req-003");
|
|
121
|
+
assert_eq!(parsed["ok"], false);
|
|
122
|
+
assert_eq!(parsed["error"]["code"], "capability_deferred");
|
|
123
|
+
assert!(parsed["error"]["message"]
|
|
124
|
+
.as_str()
|
|
125
|
+
.unwrap()
|
|
126
|
+
.contains("deferred"));
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
#[test]
|
|
130
|
+
fn test_serialize_unsupported_command_error() {
|
|
131
|
+
let err = ProtocolError::new("Unknown command 'fooBar'", ErrorCode::UnsupportedCommand);
|
|
132
|
+
let resp = Response::err("req-004", err);
|
|
133
|
+
let json_str = serde_json::to_string(&resp).expect("serialize error");
|
|
134
|
+
let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
|
135
|
+
|
|
136
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
137
|
+
assert_eq!(parsed["id"], "req-004");
|
|
138
|
+
assert_eq!(parsed["ok"], false);
|
|
139
|
+
assert_eq!(parsed["error"]["code"], "unsupported_command");
|
|
140
|
+
assert_eq!(parsed["error"]["message"], "Unknown command 'fooBar'");
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
#[test]
|
|
144
|
+
fn test_serialize_invalid_request_error() {
|
|
145
|
+
let err = ProtocolError::new(
|
|
146
|
+
"Request must be a valid JSON object with protocolVersion, id, and cmd",
|
|
147
|
+
ErrorCode::InvalidRequest,
|
|
148
|
+
);
|
|
149
|
+
let resp = Response::err("req-005", err);
|
|
150
|
+
let json_str = serde_json::to_string(&resp).expect("serialize error");
|
|
151
|
+
let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
|
152
|
+
|
|
153
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
154
|
+
assert_eq!(parsed["id"], "req-005");
|
|
155
|
+
assert_eq!(parsed["ok"], false);
|
|
156
|
+
assert_eq!(parsed["error"]["code"], "invalid_request");
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
#[test]
|
|
160
|
+
fn test_serialize_internal_error() {
|
|
161
|
+
let err = ProtocolError::new("Unexpected internal failure", ErrorCode::InternalError);
|
|
162
|
+
let resp = Response::err("req-006", err);
|
|
163
|
+
let json_str = serde_json::to_string(&resp).expect("serialize error");
|
|
164
|
+
let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
|
165
|
+
|
|
166
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
167
|
+
assert_eq!(parsed["id"], "req-006");
|
|
168
|
+
assert_eq!(parsed["ok"], false);
|
|
169
|
+
assert_eq!(parsed["error"]["code"], "internal_error");
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
#[test]
|
|
173
|
+
fn test_serialize_target_not_found_error() {
|
|
174
|
+
let err = ProtocolError::new("Window with id 42 not found", ErrorCode::TargetNotFound);
|
|
175
|
+
let resp = Response::err("req-007", err);
|
|
176
|
+
let json_str = serde_json::to_string(&resp).expect("serialize error");
|
|
177
|
+
let parsed: serde_json::Value = serde_json::from_str(&json_str).unwrap();
|
|
178
|
+
|
|
179
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
180
|
+
assert_eq!(parsed["id"], "req-007");
|
|
181
|
+
assert_eq!(parsed["ok"], false);
|
|
182
|
+
assert_eq!(parsed["error"]["code"], "target_not_found");
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
// ---------------------------------------------------------------------------
|
|
186
|
+
// ErrorCode Display
|
|
187
|
+
// ---------------------------------------------------------------------------
|
|
188
|
+
|
|
189
|
+
#[test]
|
|
190
|
+
fn test_error_code_display() {
|
|
191
|
+
assert_eq!(
|
|
192
|
+
ErrorCode::CapabilityDeferred.to_string(),
|
|
193
|
+
"capability_deferred"
|
|
194
|
+
);
|
|
195
|
+
assert_eq!(
|
|
196
|
+
ErrorCode::UnsupportedCommand.to_string(),
|
|
197
|
+
"unsupported_command"
|
|
198
|
+
);
|
|
199
|
+
assert_eq!(ErrorCode::InvalidRequest.to_string(), "invalid_request");
|
|
200
|
+
assert_eq!(ErrorCode::TargetNotFound.to_string(), "target_not_found");
|
|
201
|
+
assert_eq!(ErrorCode::InternalError.to_string(), "internal_error");
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// Integration: round-trip request + response
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
#[test]
|
|
209
|
+
fn test_round_trip_request_response() {
|
|
210
|
+
// Simulate: parse a request, produce a success response, serialize it
|
|
211
|
+
let raw = json!({
|
|
212
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
213
|
+
"id": "rt-001",
|
|
214
|
+
"cmd": "checkPermissions",
|
|
215
|
+
"args": {}
|
|
216
|
+
});
|
|
217
|
+
let req: Request = serde_json::from_value(raw).unwrap();
|
|
218
|
+
assert_eq!(req.cmd, "checkPermissions");
|
|
219
|
+
|
|
220
|
+
let resp = Response::ok(req.id.as_str(), json!({ "accessibility": false }));
|
|
221
|
+
let out = serde_json::to_string(&resp).unwrap();
|
|
222
|
+
let parsed: serde_json::Value = serde_json::from_str(&out).unwrap();
|
|
223
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
224
|
+
assert_eq!(parsed["id"], "rt-001");
|
|
225
|
+
assert_eq!(parsed["ok"], true);
|
|
226
|
+
assert_eq!(parsed["result"]["accessibility"], false);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
#[test]
|
|
230
|
+
fn test_round_trip_request_error() {
|
|
231
|
+
// Simulate: parse request, produce an error response, serialize it
|
|
232
|
+
let raw = json!({
|
|
233
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
234
|
+
"id": "rt-002",
|
|
235
|
+
"cmd": "mouseClick",
|
|
236
|
+
"args": {}
|
|
237
|
+
});
|
|
238
|
+
let req: Request = serde_json::from_value(raw).unwrap();
|
|
239
|
+
assert_eq!(req.cmd, "mouseClick");
|
|
240
|
+
|
|
241
|
+
let err = ProtocolError::new(
|
|
242
|
+
"Windows ref-backed actions are deferred in PR #1",
|
|
243
|
+
ErrorCode::CapabilityDeferred,
|
|
244
|
+
);
|
|
245
|
+
let resp = Response::err(req.id.as_str(), err);
|
|
246
|
+
let out = serde_json::to_string(&resp).unwrap();
|
|
247
|
+
let parsed: serde_json::Value = serde_json::from_str(&out).unwrap();
|
|
248
|
+
assert_eq!(parsed["protocolVersion"], PROTOCOL_VERSION);
|
|
249
|
+
assert_eq!(parsed["id"], "rt-002");
|
|
250
|
+
assert_eq!(parsed["ok"], false);
|
|
251
|
+
assert_eq!(parsed["error"]["code"], "capability_deferred");
|
|
252
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
use windows_bridge::refs::{NativeHandle, RefStore};
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// First ref assertions
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
#[test]
|
|
8
|
+
fn test_first_window_ref_is_w1() {
|
|
9
|
+
let mut store = RefStore::new();
|
|
10
|
+
let wref = store.insert_window(NativeHandle::new(0x1234));
|
|
11
|
+
assert_eq!(wref.to_string(), "@w1");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
fn test_first_element_ref_is_e1() {
|
|
16
|
+
let mut store = RefStore::new();
|
|
17
|
+
let eref = store.insert_element(NativeHandle::new(0x5678));
|
|
18
|
+
assert_eq!(eref.to_string(), "@e1");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Refs are state-scoped: independent stores reset counters
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
|
|
25
|
+
#[test]
|
|
26
|
+
fn test_refs_are_state_scoped() {
|
|
27
|
+
let mut store1 = RefStore::new();
|
|
28
|
+
let mut store2 = RefStore::new();
|
|
29
|
+
|
|
30
|
+
let w1 = store1.insert_window(NativeHandle::new(1));
|
|
31
|
+
let e1 = store1.insert_element(NativeHandle::new(2));
|
|
32
|
+
let w2 = store2.insert_window(NativeHandle::new(3));
|
|
33
|
+
let e2 = store2.insert_element(NativeHandle::new(4));
|
|
34
|
+
|
|
35
|
+
assert_eq!(w1.to_string(), "@w1");
|
|
36
|
+
assert_eq!(e1.to_string(), "@e1");
|
|
37
|
+
// Second store starts fresh at 1
|
|
38
|
+
assert_eq!(w2.to_string(), "@w1");
|
|
39
|
+
assert_eq!(e2.to_string(), "@e1");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ---------------------------------------------------------------------------
|
|
43
|
+
// Monotonically increasing refs within the same store
|
|
44
|
+
// ---------------------------------------------------------------------------
|
|
45
|
+
|
|
46
|
+
#[test]
|
|
47
|
+
fn test_window_refs_increment() {
|
|
48
|
+
let mut store = RefStore::new();
|
|
49
|
+
let w1 = store.insert_window(NativeHandle::new(10));
|
|
50
|
+
let w2 = store.insert_window(NativeHandle::new(20));
|
|
51
|
+
let w3 = store.insert_window(NativeHandle::new(30));
|
|
52
|
+
|
|
53
|
+
assert_eq!(w1.to_string(), "@w1");
|
|
54
|
+
assert_eq!(w2.to_string(), "@w2");
|
|
55
|
+
assert_eq!(w3.to_string(), "@w3");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
#[test]
|
|
59
|
+
fn test_element_refs_increment() {
|
|
60
|
+
let mut store = RefStore::new();
|
|
61
|
+
let e1 = store.insert_element(NativeHandle::new(100));
|
|
62
|
+
let e2 = store.insert_element(NativeHandle::new(200));
|
|
63
|
+
|
|
64
|
+
assert_eq!(e1.to_string(), "@e1");
|
|
65
|
+
assert_eq!(e2.to_string(), "@e2");
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ---------------------------------------------------------------------------
|
|
69
|
+
// Retrieve stored native handles by ref
|
|
70
|
+
// ---------------------------------------------------------------------------
|
|
71
|
+
|
|
72
|
+
#[test]
|
|
73
|
+
fn test_retrieve_window_handle() {
|
|
74
|
+
let mut store = RefStore::new();
|
|
75
|
+
let wref = store.insert_window(NativeHandle::new(0xABCD));
|
|
76
|
+
let retrieved = store.get_window(&wref);
|
|
77
|
+
assert_eq!(retrieved, Some(NativeHandle::new(0xABCD)));
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
#[test]
|
|
81
|
+
fn test_retrieve_element_handle() {
|
|
82
|
+
let mut store = RefStore::new();
|
|
83
|
+
let eref = store.insert_element(NativeHandle::new(0xDEAD));
|
|
84
|
+
let retrieved = store.get_element(&eref);
|
|
85
|
+
assert_eq!(retrieved, Some(NativeHandle::new(0xDEAD)));
|
|
86
|
+
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
use windows_bridge::state::StateId;
|
|
2
|
+
|
|
3
|
+
// ---------------------------------------------------------------------------
|
|
4
|
+
// Fresh state IDs
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
|
|
7
|
+
#[test]
|
|
8
|
+
fn test_two_fresh_state_ids_differ() {
|
|
9
|
+
let id1 = StateId::fresh("session");
|
|
10
|
+
let id2 = StateId::fresh("session");
|
|
11
|
+
assert_ne!(id1, id2, "two fresh state IDs must differ");
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
#[test]
|
|
15
|
+
fn test_fresh_state_id_contains_prefix() {
|
|
16
|
+
let id = StateId::fresh("test");
|
|
17
|
+
assert!(
|
|
18
|
+
id.starts_with("test-"),
|
|
19
|
+
"state ID should start with prefix followed by '-'"
|
|
20
|
+
);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[test]
|
|
24
|
+
fn test_fresh_ids_are_unique_across_calls() {
|
|
25
|
+
let mut ids = Vec::new();
|
|
26
|
+
for _ in 0..100 {
|
|
27
|
+
ids.push(StateId::fresh("batch"));
|
|
28
|
+
}
|
|
29
|
+
let mut sorted = ids.clone();
|
|
30
|
+
sorted.sort();
|
|
31
|
+
sorted.dedup();
|
|
32
|
+
assert_eq!(sorted.len(), ids.len(), "all 100 fresh IDs must be unique");
|
|
33
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,106 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
"name": "@roam-agent/roam-computer-use",
|
|
3
|
+
"version": "0.5.2",
|
|
4
|
+
"description": "Pi extension that lets AI agents observe and control macOS, Windows, and Linux apps.",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package",
|
|
8
|
+
"pi-extension",
|
|
9
|
+
"pi",
|
|
10
|
+
"computer-use",
|
|
11
|
+
"macos",
|
|
12
|
+
"desktop-automation",
|
|
13
|
+
"accessibility",
|
|
14
|
+
"linux"
|
|
15
|
+
],
|
|
16
|
+
"license": "MIT",
|
|
17
|
+
"repository": {
|
|
18
|
+
"type": "git",
|
|
19
|
+
"url": "git+https://github.com/roam-agent/roam-computer-use.git"
|
|
20
|
+
},
|
|
21
|
+
"bugs": {
|
|
22
|
+
"url": "https://github.com/roam-agent/roam-computer-use/issues"
|
|
23
|
+
},
|
|
24
|
+
"homepage": "https://github.com/roam-agent/roam-computer-use#readme",
|
|
25
|
+
"engines": {
|
|
26
|
+
"node": ">=20.6.0"
|
|
27
|
+
},
|
|
28
|
+
"files": [
|
|
29
|
+
"extensions",
|
|
30
|
+
"roam",
|
|
31
|
+
"src",
|
|
32
|
+
"scripts/build-native.mjs",
|
|
33
|
+
"scripts/setup-helper.mjs",
|
|
34
|
+
"scripts/lib",
|
|
35
|
+
"native/macos/activity_glow.swift",
|
|
36
|
+
"native/macos/bridge.swift",
|
|
37
|
+
"native/windows/bridge-rs/Cargo.lock",
|
|
38
|
+
"native/windows/bridge-rs/Cargo.toml",
|
|
39
|
+
"native/windows/bridge-rs/src",
|
|
40
|
+
"native/windows/bridge-rs/tests",
|
|
41
|
+
"prebuilt/macos",
|
|
42
|
+
"prebuilt/windows",
|
|
43
|
+
"assets/reference/img.jpg",
|
|
44
|
+
"README.md",
|
|
45
|
+
"LICENSE",
|
|
46
|
+
"native/linux/bridge-rs",
|
|
47
|
+
"prebuilt/linux",
|
|
48
|
+
"docs/content/docs"
|
|
49
|
+
],
|
|
50
|
+
"pi": {
|
|
51
|
+
"extensions": [
|
|
52
|
+
"./extensions"
|
|
53
|
+
],
|
|
54
|
+
"image": "./assets/reference/img.jpg"
|
|
55
|
+
},
|
|
56
|
+
"scripts": {
|
|
57
|
+
"postinstall": "node scripts/setup-helper.mjs --postinstall",
|
|
58
|
+
"docs:generate": "tsx scripts/docs-generators/generate-tool-reference.mjs && node scripts/docs-generators/generate-source-references.mjs",
|
|
59
|
+
"docs:check": "tsx scripts/docs-generators/generate-tool-reference.mjs --check && node scripts/docs-generators/generate-source-references.mjs --check && node scripts/check-docs.mjs",
|
|
60
|
+
"docs:dev": "npm --prefix docs run dev",
|
|
61
|
+
"docs:build": "npm --prefix docs run build",
|
|
62
|
+
"docs:site:check": "npm --prefix docs run typecheck && npm --prefix docs run build",
|
|
63
|
+
"typecheck": "tsc -p tsconfig.json",
|
|
64
|
+
"test:schema": "node scripts/check-tool-schemas.mjs",
|
|
65
|
+
"test:find-params": "tsx scripts/check-find-params.mjs",
|
|
66
|
+
"test:invariants": "node scripts/check-invariants.mjs",
|
|
67
|
+
"test:registration": "tsx scripts/check-extension-registration.mjs",
|
|
68
|
+
"test:identity": "node scripts/check-identity.mjs",
|
|
69
|
+
"test:bridge-set": "node scripts/check-bridge-set.mjs",
|
|
70
|
+
"bridge:refresh": "node scripts/refresh-roam-bridge.mjs",
|
|
71
|
+
"test:fork-scope": "node scripts/check-fork-scope-selftest.mjs",
|
|
72
|
+
"test:lifecycle": "tsx scripts/check-session-lifecycle.mjs",
|
|
73
|
+
"test:runtime": "tsx scripts/check-runtime-concurrency.mjs",
|
|
74
|
+
"test:output": "tsx scripts/check-bounded-output.mjs",
|
|
75
|
+
"test:commits": "node scripts/check-commit-messages.mjs",
|
|
76
|
+
"test:platform": "tsx scripts/check-platform-windows.mjs",
|
|
77
|
+
"test:windows-scripts": "node scripts/check-windows-build-scripts.mjs",
|
|
78
|
+
"test:package-assets": "node scripts/check-package-assets.mjs",
|
|
79
|
+
"test:signing": "node scripts/check-local-signing.mjs",
|
|
80
|
+
"test:macos-path": "node scripts/check-macos-helper-path.mjs",
|
|
81
|
+
"test:macos-target": "tsx scripts/check-macos-observe-target.mjs",
|
|
82
|
+
"test:macos-native": "node scripts/check-macos-native-pure.mjs",
|
|
83
|
+
"test:act-outcomes": "tsx scripts/check-act-outcomes.mjs",
|
|
84
|
+
"test": "npm run typecheck && npm run docs:check && npm run test:schema && npm run test:registration && npm run test:find-params && npm run test:output && npm run test:lifecycle && npm run test:runtime && npm run test:invariants && npm run test:identity && npm run test:bridge-set && npm run test:fork-scope && npm run test:platform && npm run test:linux && npm run test:linux-scripts && npm run test:signing && npm run test:macos-path && npm run test:macos-target && npm run test:macos-native && npm run test:act-outcomes",
|
|
85
|
+
"build:native": "node scripts/build-native.mjs",
|
|
86
|
+
"build:windows": "node scripts/build-native.mjs --platform windows",
|
|
87
|
+
"build:linux": "node scripts/build-native.mjs --platform linux",
|
|
88
|
+
"test:linux": "tsx scripts/check-platform-linux.mjs",
|
|
89
|
+
"test:linux-scripts": "node scripts/check-linux-build-scripts.mjs",
|
|
90
|
+
"test:linux-live": "PI_CU_LIVE=1 tsx scripts/check-linux-live.mjs",
|
|
91
|
+
"prepare": "husky"
|
|
92
|
+
},
|
|
93
|
+
"peerDependencies": {
|
|
94
|
+
"@earendil-works/pi-ai": "*",
|
|
95
|
+
"@earendil-works/pi-coding-agent": "*",
|
|
96
|
+
"@roam-agent/roam-sdk": "^0.2.68",
|
|
97
|
+
"typebox": "*"
|
|
98
|
+
},
|
|
99
|
+
"devDependencies": {
|
|
100
|
+
"@earendil-works/pi-coding-agent": "1.8.0",
|
|
101
|
+
"@types/node": "^26.1.1",
|
|
102
|
+
"husky": "9.1.7",
|
|
103
|
+
"tsx": "^4.23.1",
|
|
104
|
+
"typescript": "^7.0.2"
|
|
105
|
+
}
|
|
106
|
+
}
|
|
Binary file
|
|
Binary file
|
package/roam/README.md
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
# `roam/` — fork overlay
|
|
2
|
+
|
|
3
|
+
Fork-local override layer for this checkout. Same idea as the `.roam/` folder and
|
|
4
|
+
the `plus` packages in the `pi` repo: **upstream `src/` stays upstream-shaped, and
|
|
5
|
+
every deliberate deviation is collected here.**
|
|
6
|
+
|
|
7
|
+
## What belongs here
|
|
8
|
+
|
|
9
|
+
1. **Identity** (`identity.mjs`) — the only place the shipped identity is spelled
|
|
10
|
+
out: app bundle name, bundle id, socket directory, release asset, local
|
|
11
|
+
code-signing common name, npm package name, and repository slugs (plus the
|
|
12
|
+
`UPSTREAM_*` values still resolved by upstream-owned code). Everything else
|
|
13
|
+
imports it; `npm run test:identity` fails when a literal reappears elsewhere.
|
|
14
|
+
Changing identity here is a shipping step: a bundle-id change invalidates
|
|
15
|
+
macOS TCC grants, so reinstall the helper and re-enable Accessibility and
|
|
16
|
+
Screen Recording.
|
|
17
|
+
2. **Fork bridge set** (`bridge/`) — the fork-owned macOS helper binaries:
|
|
18
|
+
`bridge/macos/<arch>/bridge` for `arm64` and `x64`, plus `bridge/manifest.json`
|
|
19
|
+
recording the protocol version and a SHA-256 per artifact. Generated, never
|
|
20
|
+
hand-edited: `node scripts/build-native.mjs` refreshes it after a build and
|
|
21
|
+
`npm run bridge:refresh` re-mirrors `prebuilt/` after an upstream update.
|
|
22
|
+
`scripts/setup-helper.mjs` installs from here first and only falls back to
|
|
23
|
+
`prebuilt/` when the set is absent, so an upstream sync cannot silently
|
|
24
|
+
reinstate upstream artifacts; `npm run test:bridge-set` enforces all of it.
|
|
25
|
+
3. **Redirection wiring** (`redirect.ts`) — which helper app bundle, executable,
|
|
26
|
+
and socket a request is redirected to. Precedence: explicit
|
|
27
|
+
`PI_COMPUTER_USE_HELPER_APP_PATH` > legacy `/Applications` install (when
|
|
28
|
+
writable) > per-user `~/Applications`; socket via `PI_CU_SOCKET_PATH`.
|
|
29
|
+
3. **Defect fixing** (`repair.ts`) — the helper daemon outlives Pi, so a stale
|
|
30
|
+
daemon or a stale installed bundle survives a Pi restart and shows up as a
|
|
31
|
+
protocol/executable mismatch (e.g. `expected protocol 7 ... got protocol 6`).
|
|
32
|
+
Repair order: detect → relaunch resolved bundle → reinstall from `roam/bridge`
|
|
33
|
+
→ relaunch → re-verify. If it still mismatches, fail closed with an actionable
|
|
34
|
+
message instead of pretending the tool works.
|
|
35
|
+
|
|
36
|
+
## What does not belong here
|
|
37
|
+
|
|
38
|
+
- Transport, framing, or scheduling. Those stay in `src/` (`src/platform/*`,
|
|
39
|
+
`src/runtime.ts`).
|
|
40
|
+
- Anything that only works by weakening an invariant in `AGENTS.md`.
|
|
41
|
+
- Silent mutation of `src/` files beyond the thin import the overlay needs.
|
|
42
|
+
|
|
43
|
+
## Maintenance contract
|
|
44
|
+
|
|
45
|
+
`roam/helper-path.mjs` and `roam/identity.mjs` are plain ESM because
|
|
46
|
+
`scripts/setup-helper.mjs`, the docs generators, and the check scripts load them
|
|
47
|
+
with bare `node`; keep a matching `.d.mts` next to each so `redirect.ts` and
|
|
48
|
+
`repair.ts` type-check.
|
|
49
|
+
|
|
50
|
+
Bumping `ROAM_HELPER_PROTOCOL_VERSION` is a **shipping step**, not just an edit:
|
|
51
|
+
regenerate `prebuilt/macos/{arm64,x64}/bridge` (`npm run build:native`), or every
|
|
52
|
+
installed helper will be reported — and now actively repaired — as stale.
|
|
Binary file
|
|
Binary file
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{
|
|
2
|
+
"generatedBy": "scripts/refresh-roam-bridge.mjs",
|
|
3
|
+
"packageName": "@roam-agent/roam-computer-use",
|
|
4
|
+
"source": "native/macos/bridge.swift",
|
|
5
|
+
"protocolVersion": 7,
|
|
6
|
+
"artifacts": [
|
|
7
|
+
{
|
|
8
|
+
"path": "macos/arm64/bridge",
|
|
9
|
+
"arch": "arm64",
|
|
10
|
+
"bytes": 622912,
|
|
11
|
+
"sha256": "377a590ebc159bb3f5a5da247d8c44e6aa581944090490c10325921b40420983"
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"path": "macos/x64/bridge",
|
|
15
|
+
"arch": "x64",
|
|
16
|
+
"bytes": 653664,
|
|
17
|
+
"sha256": "b36ed39fff1154a89be0e5c7cb6e5fda7782e09b11f2f68e74205eeda1bab6de"
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export interface MacosHelperPathOptions {
|
|
2
|
+
env?: NodeJS.ProcessEnv;
|
|
3
|
+
homeDir?: string;
|
|
4
|
+
systemHelperAppPath?: string;
|
|
5
|
+
fileExists?: (filePath: string) => boolean;
|
|
6
|
+
directoryIsWritable?: (directoryPath: string) => boolean;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function resolveMacosHelperAppPath(options?: MacosHelperPathOptions): string;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { accessSync, constants as fsConstants, existsSync } from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
|
|
5
|
+
import { ROAM_APP_BUNDLE_NAME } from "./identity.mjs";
|
|
6
|
+
|
|
7
|
+
const HELPER_APP_NAME = ROAM_APP_BUNDLE_NAME;
|
|
8
|
+
const SYSTEM_HELPER_APP_PATH = path.join("/Applications", HELPER_APP_NAME);
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Resolve one stable helper location for both installation and runtime use.
|
|
12
|
+
* Existing writable system installs stay in place; all other installs are
|
|
13
|
+
* per-user so standard macOS accounts never require administrator access.
|
|
14
|
+
*/
|
|
15
|
+
export function resolveMacosHelperAppPath(options = {}) {
|
|
16
|
+
const env = options.env ?? process.env;
|
|
17
|
+
const explicitPath = env.PI_COMPUTER_USE_HELPER_APP_PATH?.trim();
|
|
18
|
+
if (explicitPath) return path.resolve(explicitPath);
|
|
19
|
+
|
|
20
|
+
const homeDir = options.homeDir ?? os.homedir();
|
|
21
|
+
const systemHelperAppPath = options.systemHelperAppPath ?? SYSTEM_HELPER_APP_PATH;
|
|
22
|
+
const fileExists = options.fileExists ?? existsSync;
|
|
23
|
+
const directoryIsWritable = options.directoryIsWritable ?? ((directoryPath) => {
|
|
24
|
+
try {
|
|
25
|
+
accessSync(directoryPath, fsConstants.W_OK);
|
|
26
|
+
return true;
|
|
27
|
+
} catch {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
if (fileExists(systemHelperAppPath) && directoryIsWritable(path.dirname(systemHelperAppPath))) {
|
|
33
|
+
return systemHelperAppPath;
|
|
34
|
+
}
|
|
35
|
+
return path.join(homeDir, "Applications", HELPER_APP_NAME);
|
|
36
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export declare const ROAM_APP_NAME: string;
|
|
2
|
+
export declare const ROAM_APP_BUNDLE_NAME: string;
|
|
3
|
+
export declare const ROAM_PACKAGE_NAME: string;
|
|
4
|
+
export declare const ROAM_BUNDLE_ID: string;
|
|
5
|
+
export declare const ROAM_SIGNING_ORG: string;
|
|
6
|
+
export declare const ROAM_LOCAL_SIGNING_COMMON_NAME: string;
|
|
7
|
+
export declare const ROAM_RELEASE_ASSET: string;
|
|
8
|
+
export declare const ROAM_SOCKET_DIR_NAME: string;
|
|
9
|
+
export declare const ROAM_BRIDGE_PLATFORM: string;
|
|
10
|
+
export declare const ROAM_SOCKET_FILE_NAME: string;
|
|
11
|
+
export declare const ROAM_LOG_PREFIX: string;
|
|
12
|
+
export declare const ROAM_REPO_SLUG: string;
|
|
13
|
+
export declare const ROAM_REPO_URL: string;
|
|
14
|
+
export declare const UPSTREAM_PACKAGE_NAME: string;
|
|
15
|
+
export declare const UPSTREAM_REPO_SLUG: string;
|
|
16
|
+
export declare const UPSTREAM_REPO_URL: string;
|