@roam-agent/roam-computer-use 0.5.1 → 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/package.json +2 -1
- package/scripts/lib/roam-bridge.mjs +98 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@roam-agent/roam-computer-use",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.2",
|
|
4
4
|
"description": "Pi extension that lets AI agents observe and control macOS, Windows, and Linux apps.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"keywords": [
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
"src",
|
|
32
32
|
"scripts/build-native.mjs",
|
|
33
33
|
"scripts/setup-helper.mjs",
|
|
34
|
+
"scripts/lib",
|
|
34
35
|
"native/macos/activity_glow.swift",
|
|
35
36
|
"native/macos/bridge.swift",
|
|
36
37
|
"native/windows/bridge-rs/Cargo.lock",
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fork-owned set of macOS helper binaries shipped from `roam/bridge/`.
|
|
3
|
+
*
|
|
4
|
+
* Upstream tracks its own builds under `prebuilt/macos/<arch>/bridge`, which is
|
|
5
|
+
* replaced wholesale whenever upstream ships a release. The fork keeps a second,
|
|
6
|
+
* rename-consistent set under `roam/bridge/` so an upstream sync cannot silently
|
|
7
|
+
* reinstate upstream artifacts, and so installs resolve a helper the fork owns.
|
|
8
|
+
*
|
|
9
|
+
* `roam/bridge/manifest.json` records the protocol version and a SHA-256 per
|
|
10
|
+
* artifact; `npm run test:bridge-set` fails if an artifact drifts from its
|
|
11
|
+
* manifest, from its architecture, or from the protocol the extension requires.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
import { createHash } from "node:crypto";
|
|
15
|
+
import fs from "node:fs/promises";
|
|
16
|
+
import path from "node:path";
|
|
17
|
+
import { fileURLToPath } from "node:url";
|
|
18
|
+
|
|
19
|
+
import { ROAM_BRIDGE_PLATFORM, ROAM_PACKAGE_NAME } from "../../roam/identity.mjs";
|
|
20
|
+
|
|
21
|
+
export const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "../..");
|
|
22
|
+
export const ROAM_BRIDGE_DIR = path.join(rootDir, "roam", "bridge");
|
|
23
|
+
export const ROAM_BRIDGE_MANIFEST = path.join(ROAM_BRIDGE_DIR, "manifest.json");
|
|
24
|
+
|
|
25
|
+
export const PLATFORM = ROAM_BRIDGE_PLATFORM;
|
|
26
|
+
export const ARCHES = ["arm64", "x64"];
|
|
27
|
+
|
|
28
|
+
/** Where the fork ships a helper binary for `arch`. */
|
|
29
|
+
export function roamBridgePathForArch(arch) {
|
|
30
|
+
return path.join(ROAM_BRIDGE_DIR, PLATFORM, arch, "bridge");
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Where upstream ships a helper binary for `arch`. */
|
|
34
|
+
export function upstreamBridgePathForArch(arch) {
|
|
35
|
+
return path.join(rootDir, "prebuilt", PLATFORM, arch, "bridge");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Protocol version the extension requires, read from the overlay that owns the
|
|
40
|
+
* repair policy. The overlay is TypeScript, so this parses rather than imports.
|
|
41
|
+
*/
|
|
42
|
+
export async function helperProtocolVersion() {
|
|
43
|
+
const source = await fs.readFile(path.join(rootDir, "roam", "repair.ts"), "utf8");
|
|
44
|
+
const match = /export const ROAM_HELPER_PROTOCOL_VERSION\s*=\s*(\d+)\s*;/.exec(source);
|
|
45
|
+
if (!match) throw new Error("roam/repair.ts does not declare ROAM_HELPER_PROTOCOL_VERSION");
|
|
46
|
+
return Number(match[1]);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export async function sha256File(file) {
|
|
50
|
+
const hash = createHash("sha256");
|
|
51
|
+
hash.update(await fs.readFile(file));
|
|
52
|
+
return hash.digest("hex");
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Copy each architecture's fresh build from `prebuilt/` into `roam/bridge/` and
|
|
57
|
+
* rewrite the manifest. Returns the manifest that was written.
|
|
58
|
+
*/
|
|
59
|
+
export async function refreshRoamBridgeSet({ arches = ARCHES, source = "prebuilt" } = {}) {
|
|
60
|
+
const protocolVersion = await helperProtocolVersion();
|
|
61
|
+
let previous = [];
|
|
62
|
+
try {
|
|
63
|
+
previous = (await readRoamBridgeManifest()).artifacts ?? [];
|
|
64
|
+
} catch {
|
|
65
|
+
previous = [];
|
|
66
|
+
}
|
|
67
|
+
const artifacts = previous.filter((artifact) => !arches.includes(artifact.arch));
|
|
68
|
+
|
|
69
|
+
for (const arch of arches) {
|
|
70
|
+
const from = source === "prebuilt" ? upstreamBridgePathForArch(arch) : source[arch];
|
|
71
|
+
const to = roamBridgePathForArch(arch);
|
|
72
|
+
await fs.mkdir(path.dirname(to), { recursive: true });
|
|
73
|
+
await fs.copyFile(from, to);
|
|
74
|
+
await fs.chmod(to, 0o755);
|
|
75
|
+
const bytes = (await fs.stat(to)).size;
|
|
76
|
+
artifacts.push({
|
|
77
|
+
path: `${PLATFORM}/${arch}/bridge`,
|
|
78
|
+
arch,
|
|
79
|
+
bytes,
|
|
80
|
+
sha256: await sha256File(to),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
artifacts.sort((a, b) => ARCHES.indexOf(a.arch) - ARCHES.indexOf(b.arch));
|
|
85
|
+
const manifest = {
|
|
86
|
+
generatedBy: "scripts/refresh-roam-bridge.mjs",
|
|
87
|
+
packageName: ROAM_PACKAGE_NAME,
|
|
88
|
+
source: "native/macos/bridge.swift",
|
|
89
|
+
protocolVersion,
|
|
90
|
+
artifacts,
|
|
91
|
+
};
|
|
92
|
+
await fs.writeFile(ROAM_BRIDGE_MANIFEST, `${JSON.stringify(manifest, null, "\t")}\n`);
|
|
93
|
+
return manifest;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export async function readRoamBridgeManifest() {
|
|
97
|
+
return JSON.parse(await fs.readFile(ROAM_BRIDGE_MANIFEST, "utf8"));
|
|
98
|
+
}
|