@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
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
use linux_bridge::protocol::PROTOCOL_VERSION;
|
|
2
|
+
use linux_bridge::{ErrorCode, ProtocolError, Request, Response};
|
|
3
|
+
use serde_json::json;
|
|
4
|
+
use std::io::Write;
|
|
5
|
+
use std::process::{Command, Stdio};
|
|
6
|
+
|
|
7
|
+
#[test]
|
|
8
|
+
fn protocol_round_trip_matches_other_helpers() {
|
|
9
|
+
let request: Request = serde_json::from_value(json!({
|
|
10
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
11
|
+
"id": "linux-1",
|
|
12
|
+
"cmd": "diagnostics",
|
|
13
|
+
"args": {}
|
|
14
|
+
}))
|
|
15
|
+
.unwrap();
|
|
16
|
+
let response = Response::ok(&request.id, json!({"backend":"at-spi2"}));
|
|
17
|
+
let value = serde_json::to_value(response).unwrap();
|
|
18
|
+
assert_eq!(value["protocolVersion"], 4);
|
|
19
|
+
assert_eq!(value["id"], "linux-1");
|
|
20
|
+
assert_eq!(value["result"]["backend"], "at-spi2");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
#[test]
|
|
24
|
+
fn errors_have_stable_machine_codes() {
|
|
25
|
+
let response = Response::err(
|
|
26
|
+
"linux-2",
|
|
27
|
+
ProtocolError::new("no screenshot", ErrorCode::CaptureFailed),
|
|
28
|
+
);
|
|
29
|
+
let value = serde_json::to_value(response).unwrap();
|
|
30
|
+
assert_eq!(value["ok"], false);
|
|
31
|
+
assert_eq!(value["error"]["code"], "capture_failed");
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
#[test]
|
|
35
|
+
fn diagnostics_response_is_flushed_after_stdin_eof() {
|
|
36
|
+
let mut child = Command::new(env!("CARGO_BIN_EXE_linux-bridge"))
|
|
37
|
+
.stdin(Stdio::piped())
|
|
38
|
+
.stdout(Stdio::piped())
|
|
39
|
+
.stderr(Stdio::piped())
|
|
40
|
+
.spawn()
|
|
41
|
+
.expect("spawn linux helper");
|
|
42
|
+
let request = json!({
|
|
43
|
+
"protocolVersion": PROTOCOL_VERSION,
|
|
44
|
+
"id": "eof-1",
|
|
45
|
+
"cmd": "diagnostics",
|
|
46
|
+
"args": {}
|
|
47
|
+
});
|
|
48
|
+
writeln!(
|
|
49
|
+
child.stdin.as_mut().expect("piped stdin"),
|
|
50
|
+
"{}",
|
|
51
|
+
serde_json::to_string(&request).unwrap()
|
|
52
|
+
)
|
|
53
|
+
.expect("write diagnostics request");
|
|
54
|
+
drop(child.stdin.take());
|
|
55
|
+
|
|
56
|
+
let output = child.wait_with_output().expect("helper exits after EOF");
|
|
57
|
+
let stderr = String::from_utf8_lossy(&output.stderr);
|
|
58
|
+
assert!(output.status.success(), "helper failed: {stderr}");
|
|
59
|
+
assert!(
|
|
60
|
+
!stderr.contains("panicked"),
|
|
61
|
+
"helper panicked during shutdown: {stderr}"
|
|
62
|
+
);
|
|
63
|
+
let lines = String::from_utf8(output.stdout)
|
|
64
|
+
.expect("UTF-8 stdout")
|
|
65
|
+
.lines()
|
|
66
|
+
.map(str::to_owned)
|
|
67
|
+
.collect::<Vec<_>>();
|
|
68
|
+
assert_eq!(lines.len(), 1, "expected one response: {lines:?}");
|
|
69
|
+
let response: serde_json::Value = serde_json::from_str(&lines[0]).expect("valid JSON response");
|
|
70
|
+
assert_eq!(response["id"], "eof-1");
|
|
71
|
+
assert_eq!(response["ok"], true);
|
|
72
|
+
assert_eq!(response["result"]["protocolVersion"], PROTOCOL_VERSION);
|
|
73
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import AppKit
|
|
2
|
+
import QuartzCore
|
|
3
|
+
|
|
4
|
+
private let agentCursorBloomColor = NSColor(
|
|
5
|
+
calibratedRed: 1,
|
|
6
|
+
green: 0x78 / 255,
|
|
7
|
+
blue: 0x18 / 255,
|
|
8
|
+
alpha: 1
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
private final class ActivityGlowView: NSView {
|
|
12
|
+
private let edgeWidth: CGFloat = 30
|
|
13
|
+
private let edges = (0..<4).map { _ in CAGradientLayer() }
|
|
14
|
+
private let border = CALayer()
|
|
15
|
+
|
|
16
|
+
override init(frame frameRect: NSRect) {
|
|
17
|
+
super.init(frame: frameRect)
|
|
18
|
+
wantsLayer = true
|
|
19
|
+
layer?.masksToBounds = true
|
|
20
|
+
|
|
21
|
+
let strong = agentCursorBloomColor.withAlphaComponent(0.72).cgColor
|
|
22
|
+
let soft = agentCursorBloomColor.withAlphaComponent(0.22).cgColor
|
|
23
|
+
let clear = agentCursorBloomColor.withAlphaComponent(0).cgColor
|
|
24
|
+
|
|
25
|
+
for edge in edges {
|
|
26
|
+
edge.colors = [strong, soft, clear]
|
|
27
|
+
edge.locations = [0, 0.35, 1]
|
|
28
|
+
layer?.addSublayer(edge)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
border.borderColor = agentCursorBloomColor.withAlphaComponent(0.9).cgColor
|
|
32
|
+
border.borderWidth = 2
|
|
33
|
+
layer?.addSublayer(border)
|
|
34
|
+
|
|
35
|
+
let pulse = CAKeyframeAnimation(keyPath: "opacity")
|
|
36
|
+
pulse.values = [0.72, 1, 0.72]
|
|
37
|
+
pulse.keyTimes = [0, 0.5, 1]
|
|
38
|
+
pulse.duration = 1.8
|
|
39
|
+
pulse.repeatCount = .infinity
|
|
40
|
+
pulse.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
|
|
41
|
+
layer?.add(pulse, forKey: "computer-use-activity-pulse")
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
required init?(coder: NSCoder) {
|
|
45
|
+
fatalError("init(coder:) has not been implemented")
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override func layout() {
|
|
49
|
+
super.layout()
|
|
50
|
+
|
|
51
|
+
let width = bounds.width
|
|
52
|
+
let height = bounds.height
|
|
53
|
+
|
|
54
|
+
edges[0].frame = CGRect(x: 0, y: height - edgeWidth, width: width, height: edgeWidth)
|
|
55
|
+
edges[0].startPoint = CGPoint(x: 0.5, y: 1)
|
|
56
|
+
edges[0].endPoint = CGPoint(x: 0.5, y: 0)
|
|
57
|
+
|
|
58
|
+
edges[1].frame = CGRect(x: 0, y: 0, width: width, height: edgeWidth)
|
|
59
|
+
edges[1].startPoint = CGPoint(x: 0.5, y: 0)
|
|
60
|
+
edges[1].endPoint = CGPoint(x: 0.5, y: 1)
|
|
61
|
+
|
|
62
|
+
edges[2].frame = CGRect(x: 0, y: 0, width: edgeWidth, height: height)
|
|
63
|
+
edges[2].startPoint = CGPoint(x: 0, y: 0.5)
|
|
64
|
+
edges[2].endPoint = CGPoint(x: 1, y: 0.5)
|
|
65
|
+
|
|
66
|
+
edges[3].frame = CGRect(x: width - edgeWidth, y: 0, width: edgeWidth, height: height)
|
|
67
|
+
edges[3].startPoint = CGPoint(x: 1, y: 0.5)
|
|
68
|
+
edges[3].endPoint = CGPoint(x: 0, y: 0.5)
|
|
69
|
+
|
|
70
|
+
border.frame = bounds
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
final class ActivityGlowController: NSObject {
|
|
75
|
+
private let stateLock = NSLock()
|
|
76
|
+
private var activeClients = Set<UUID>()
|
|
77
|
+
private var windows: [NSWindow] = []
|
|
78
|
+
private var visible = false
|
|
79
|
+
|
|
80
|
+
override init() {
|
|
81
|
+
super.init()
|
|
82
|
+
NotificationCenter.default.addObserver(
|
|
83
|
+
self,
|
|
84
|
+
selector: #selector(screensChanged),
|
|
85
|
+
name: NSApplication.didChangeScreenParametersNotification,
|
|
86
|
+
object: nil
|
|
87
|
+
)
|
|
88
|
+
rebuildWindows()
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
deinit {
|
|
92
|
+
NotificationCenter.default.removeObserver(self)
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
func setActive(_ active: Bool, for clientID: UUID) {
|
|
96
|
+
stateLock.lock()
|
|
97
|
+
if active {
|
|
98
|
+
activeClients.insert(clientID)
|
|
99
|
+
} else {
|
|
100
|
+
activeClients.remove(clientID)
|
|
101
|
+
}
|
|
102
|
+
stateLock.unlock()
|
|
103
|
+
DispatchQueue.main.async { [weak self] in
|
|
104
|
+
self?.syncVisibility()
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
func disconnect(_ clientID: UUID) {
|
|
109
|
+
setActive(false, for: clientID)
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
var isActive: Bool {
|
|
113
|
+
stateLock.lock()
|
|
114
|
+
defer { stateLock.unlock() }
|
|
115
|
+
return !activeClients.isEmpty
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
@objc private func screensChanged() {
|
|
119
|
+
rebuildWindows()
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
private func rebuildWindows() {
|
|
123
|
+
windows.forEach { $0.close() }
|
|
124
|
+
windows = NSScreen.screens.map(makeWindow)
|
|
125
|
+
if visible {
|
|
126
|
+
windows.forEach { $0.orderFrontRegardless() }
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
private func makeWindow(for screen: NSScreen) -> NSWindow {
|
|
131
|
+
let window = NSWindow(
|
|
132
|
+
contentRect: screen.frame,
|
|
133
|
+
styleMask: .borderless,
|
|
134
|
+
backing: .buffered,
|
|
135
|
+
defer: false,
|
|
136
|
+
screen: screen
|
|
137
|
+
)
|
|
138
|
+
window.setFrame(screen.frame, display: true)
|
|
139
|
+
window.backgroundColor = .clear
|
|
140
|
+
window.isOpaque = false
|
|
141
|
+
window.hasShadow = false
|
|
142
|
+
window.ignoresMouseEvents = true
|
|
143
|
+
window.isReleasedWhenClosed = false
|
|
144
|
+
window.sharingType = .readOnly
|
|
145
|
+
window.setAccessibilityElement(false)
|
|
146
|
+
window.level = .screenSaver
|
|
147
|
+
window.collectionBehavior = [
|
|
148
|
+
.canJoinAllSpaces,
|
|
149
|
+
.stationary,
|
|
150
|
+
.fullScreenAuxiliary,
|
|
151
|
+
.ignoresCycle,
|
|
152
|
+
]
|
|
153
|
+
let glowView = ActivityGlowView(frame: NSRect(origin: .zero, size: screen.frame.size))
|
|
154
|
+
glowView.setAccessibilityElement(false)
|
|
155
|
+
window.contentView = glowView
|
|
156
|
+
return window
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
private func syncVisibility() {
|
|
160
|
+
let shouldShow = isActive
|
|
161
|
+
guard visible != shouldShow else { return }
|
|
162
|
+
visible = shouldShow
|
|
163
|
+
if shouldShow {
|
|
164
|
+
windows.forEach { $0.orderFrontRegardless() }
|
|
165
|
+
} else {
|
|
166
|
+
windows.forEach { $0.orderOut(nil) }
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
}
|