agentroam 0.2.0-preview.7 → 0.2.0-preview.70
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/README.md +61 -15
- package/bin/agentroam.mjs +10 -1
- package/bin/cli-progress.d.mts +9 -0
- package/bin/cli-progress.mjs +65 -0
- package/bin/desktop-download.mjs +69 -0
- package/bin/node-preflight.mjs +171 -0
- package/bin/node-runtime-policy.json +4 -0
- package/bin/runtime-policy.d.mts +5 -0
- package/bin/runtime-policy.mjs +37 -0
- package/dist/abort.js +25 -0
- package/dist/args.js +102 -3
- package/dist/cli.js +229 -33
- package/dist/cloudflared/bundled-asset.js +3 -2
- package/dist/cloudflared/manifest.js +2 -2
- package/dist/codex-desktop-command.js +70 -0
- package/dist/codex-desktop-force-stop.js +46 -0
- package/dist/codex-desktop-idle-guard.js +15 -0
- package/dist/codex-desktop-preflight.js +63 -0
- package/dist/codex-desktop-probe.js +152 -0
- package/dist/codex-desktop-setup.js +154 -0
- package/dist/codex-desktop-status.js +85 -0
- package/dist/codex-desktop-windows.js +122 -0
- package/dist/codex-runtime-manager.js +368 -0
- package/dist/codex-sharing.js +153 -0
- package/dist/codex-windows-backend-host.js +59 -0
- package/dist/codex-windows-backend.js +120 -0
- package/dist/desktop-authorization-prompt.js +84 -0
- package/dist/desktop-authorization.js +161 -0
- package/dist/device-pairing.js +170 -0
- package/dist/error-log.js +113 -0
- package/dist/instance-takeover.js +143 -0
- package/dist/local-desktop-url.js +8 -0
- package/dist/local-service-request.js +69 -0
- package/dist/native-runtime.js +68 -0
- package/dist/network.js +32 -3
- package/dist/node-runtime-manager.js +251 -0
- package/dist/opencode-runtime-manager.js +239 -0
- package/dist/platform-packages.js +16 -5
- package/dist/platform.js +6 -4
- package/dist/power/sleep-inhibitor.js +161 -0
- package/dist/runtime-manager.js +129 -19
- package/dist/service/launcher-cleanup.js +79 -0
- package/dist/service/macos-launch-agent.js +288 -0
- package/dist/service/runtime-state.js +43 -0
- package/dist/service/service-command.js +219 -0
- package/dist/service/service-controller.js +27 -0
- package/dist/service/service-files.js +78 -0
- package/dist/service/windows-service-host.js +59 -0
- package/dist/service/windows-task-service.js +289 -0
- package/dist/startup-lock.js +81 -0
- package/dist/tunnel/cloudflare-provider.js +4 -1
- package/dist/tunnel/public-readiness.js +76 -50
- package/dist/tunnel/relay-orchestrator.js +29 -9
- package/dist/unlock-service.js +105 -0
- package/dist/update/update-channel.js +38 -0
- package/dist/update/update-command.js +96 -0
- package/dist/update/update-install.js +34 -0
- package/dist/update/update-state.js +43 -0
- package/dist/update/update-worker.js +80 -0
- package/install/README.md +55 -0
- package/install/codex-shared-watchdog.sh +16 -0
- package/install/install-agentroam.ps1 +358 -0
- package/install/install-agentroam.sh +457 -0
- package/install/install-manifest.json +15 -0
- package/install/start-codex-desktop-shared.sh +152 -0
- package/package.json +13 -10
- package/dist/args.test.js +0 -27
- package/dist/cloudflared/bundled-asset.test.js +0 -76
- package/dist/cloudflared/installer.test.js +0 -95
- package/dist/native-runtime.test.js +0 -19
- package/dist/network.test.js +0 -20
- package/dist/pairing.js +0 -2
- package/dist/platform-packages.test.js +0 -75
- package/dist/platform.test.js +0 -3
- package/dist/port.test.js +0 -3
- package/dist/process-supervisor.test.js +0 -42
- package/dist/tunnel/cloudflare-provider.test.js +0 -33
- package/dist/tunnel/pinggy-provider.test.js +0 -40
- package/dist/tunnel/proxy-settings.test.js +0 -111
- package/dist/tunnel/public-readiness.test.js +0 -104
- package/dist/tunnel/relay-orchestrator.test.js +0 -72
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agentroam",
|
|
3
|
-
"version": "0.2.0-preview.
|
|
3
|
+
"version": "0.2.0-preview.70",
|
|
4
4
|
"description": "Zero-install mobile remote terminal and file console",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -8,33 +8,36 @@
|
|
|
8
8
|
"agent-tui": "./bin/agent-tui.mjs"
|
|
9
9
|
},
|
|
10
10
|
"engines": {
|
|
11
|
-
"node": ">=22
|
|
11
|
+
"node": ">=22.22.0"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"bin",
|
|
15
15
|
"dist",
|
|
16
|
+
"install",
|
|
16
17
|
"README.md"
|
|
17
18
|
],
|
|
18
19
|
"scripts": {
|
|
19
|
-
"build": "tsc -p tsconfig.json",
|
|
20
|
+
"build": "tsc -p tsconfig.build.json",
|
|
20
21
|
"test": "vitest run --root ../.. packages/cli/src",
|
|
21
22
|
"prepack": "npm run build"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
25
|
"qrcode-terminal": "^0.12.0",
|
|
25
|
-
"undici": "^6.25.0"
|
|
26
|
+
"undici": "^6.25.0",
|
|
27
|
+
"ws": "^8.21.3"
|
|
26
28
|
},
|
|
27
29
|
"optionalDependencies": {
|
|
28
|
-
"agentroam-runtime-darwin-arm64": "0.2.0-preview.
|
|
29
|
-
"agentroam-runtime-win32-x64": "0.2.0-preview.
|
|
30
|
-
"agentroam-cloudflared-darwin-arm64": "0.2.0-preview.
|
|
31
|
-
"agentroam-cloudflared-win32-x64": "0.2.0-preview.
|
|
32
|
-
"agentroam-tui-darwin-arm64": "0.2.0-preview.
|
|
33
|
-
"@caoqu/agentroam-tui-win32-x64": "0.2.0-preview.
|
|
30
|
+
"agentroam-runtime-darwin-arm64": "0.2.0-preview.70",
|
|
31
|
+
"agentroam-runtime-win32-x64": "0.2.0-preview.70",
|
|
32
|
+
"agentroam-cloudflared-darwin-arm64": "0.2.0-preview.58",
|
|
33
|
+
"agentroam-cloudflared-win32-x64": "0.2.0-preview.58",
|
|
34
|
+
"agentroam-tui-darwin-arm64": "0.2.0-preview.70",
|
|
35
|
+
"@caoqu/agentroam-tui-win32-x64": "0.2.0-preview.70"
|
|
34
36
|
},
|
|
35
37
|
"devDependencies": {
|
|
36
38
|
"@types/node": "^22.0.0",
|
|
37
39
|
"@types/qrcode-terminal": "^0.12.2",
|
|
40
|
+
"@types/ws": "^8.18.1",
|
|
38
41
|
"typescript": "^5.6.0",
|
|
39
42
|
"vitest": "^2.1.0"
|
|
40
43
|
},
|
package/dist/args.test.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { parseArgs } from "./args.js";
|
|
3
|
-
describe("parseArgs", () => {
|
|
4
|
-
it("uses auto relay and the current directory by default", () => {
|
|
5
|
-
const value = parseArgs([]);
|
|
6
|
-
expect(value.command).toBe("start");
|
|
7
|
-
expect(value.roots).toEqual([process.cwd()]);
|
|
8
|
-
expect(value.relay).toBe("auto");
|
|
9
|
-
});
|
|
10
|
-
it("parses every supported relay", () => {
|
|
11
|
-
expect(parseArgs(["--relay", "cloudflare"]).relay).toBe("cloudflare");
|
|
12
|
-
expect(parseArgs(["--relay", "pinggy"]).relay).toBe("pinggy");
|
|
13
|
-
expect(parseArgs(["--relay", "custom", "--tunnel-command", "relay {port}"]).relay).toBe("custom");
|
|
14
|
-
});
|
|
15
|
-
it("parses repeatable roots and custom relay options", () => {
|
|
16
|
-
const value = parseArgs([
|
|
17
|
-
"start", "--root", ".", "--root", "..", "--relay", "custom", "--tunnel-command", "relay {port}", "--no-qr",
|
|
18
|
-
]);
|
|
19
|
-
expect(value.roots).toHaveLength(2);
|
|
20
|
-
expect(value.tunnelCommand).toContain("{port}");
|
|
21
|
-
expect(value.qr).toBe(false);
|
|
22
|
-
});
|
|
23
|
-
it("rejects invalid ports and relay names", () => {
|
|
24
|
-
expect(() => parseArgs(["--port", "70000"])).toThrow();
|
|
25
|
-
expect(() => parseArgs(["--relay", "unknown"])).toThrow("relay must be auto");
|
|
26
|
-
});
|
|
27
|
-
});
|
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { resolveBundledCloudflared } from "./bundled-asset.js";
|
|
6
|
-
describe("resolveBundledCloudflared", () => {
|
|
7
|
-
it("resolves a valid platform package manifest and archive", async () => {
|
|
8
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-bundled-resolver-"));
|
|
9
|
-
const manifestPath = resolve(root, "manifest.json");
|
|
10
|
-
const archivePath = resolve(root, "cloudflared.tgz");
|
|
11
|
-
await writeFile(archivePath, "archive");
|
|
12
|
-
await writeFile(manifestPath, JSON.stringify({
|
|
13
|
-
packageVersion: "0.2.0-preview.7",
|
|
14
|
-
upstreamVersion: "2026.8.2",
|
|
15
|
-
target: "darwin-arm64",
|
|
16
|
-
assetFormat: "tgz",
|
|
17
|
-
fileName: "cloudflared",
|
|
18
|
-
size: 7,
|
|
19
|
-
sha256: "a".repeat(64),
|
|
20
|
-
}));
|
|
21
|
-
const asset = await resolveBundledCloudflared("darwin-arm64", fakeRequire(manifestPath, archivePath));
|
|
22
|
-
expect(asset).toEqual({
|
|
23
|
-
assetPath: archivePath,
|
|
24
|
-
assetFormat: "tgz",
|
|
25
|
-
version: "2026.8.2",
|
|
26
|
-
fileName: "cloudflared",
|
|
27
|
-
size: 7,
|
|
28
|
-
sha256: "a".repeat(64),
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
it("rejects a mismatched platform package version", async () => {
|
|
32
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-bundled-version-"));
|
|
33
|
-
const manifestPath = resolve(root, "manifest.json");
|
|
34
|
-
const archivePath = resolve(root, "cloudflared.tgz");
|
|
35
|
-
await writeFile(archivePath, "archive");
|
|
36
|
-
await writeFile(manifestPath, JSON.stringify({
|
|
37
|
-
packageVersion: "0.2.0-preview.2",
|
|
38
|
-
upstreamVersion: "2026.8.2",
|
|
39
|
-
target: "darwin-arm64",
|
|
40
|
-
assetFormat: "tgz",
|
|
41
|
-
fileName: "cloudflared",
|
|
42
|
-
size: 7,
|
|
43
|
-
sha256: "a".repeat(64),
|
|
44
|
-
}));
|
|
45
|
-
await expect(resolveBundledCloudflared("darwin-arm64", fakeRequire(manifestPath, archivePath)))
|
|
46
|
-
.rejects.toThrow("invalid cloudflared platform manifest");
|
|
47
|
-
});
|
|
48
|
-
it("resolves a Windows executable asset", async () => {
|
|
49
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-bundled-windows-"));
|
|
50
|
-
const manifestPath = resolve(root, "manifest.json");
|
|
51
|
-
const assetPath = resolve(root, "cloudflared.exe");
|
|
52
|
-
await writeFile(assetPath, "binary");
|
|
53
|
-
await writeFile(manifestPath, JSON.stringify({
|
|
54
|
-
packageVersion: "0.2.0-preview.7",
|
|
55
|
-
upstreamVersion: "2026.8.2",
|
|
56
|
-
target: "windows-amd64",
|
|
57
|
-
assetFormat: "executable",
|
|
58
|
-
fileName: "cloudflared.exe",
|
|
59
|
-
size: 6,
|
|
60
|
-
sha256: "b".repeat(64),
|
|
61
|
-
}));
|
|
62
|
-
await expect(resolveBundledCloudflared("windows-amd64", fakeRequire(manifestPath, assetPath))).resolves.toEqual({
|
|
63
|
-
assetPath,
|
|
64
|
-
assetFormat: "executable",
|
|
65
|
-
version: "2026.8.2",
|
|
66
|
-
fileName: "cloudflared.exe",
|
|
67
|
-
size: 6,
|
|
68
|
-
sha256: "b".repeat(64),
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
function fakeRequire(manifestPath, archivePath) {
|
|
73
|
-
return {
|
|
74
|
-
resolve: (id) => id.endsWith("/manifest.json") ? manifestPath : archivePath,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import { execFileSync } from "node:child_process";
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
import { constants } from "node:fs";
|
|
4
|
-
import { access, chmod, mkdtemp, mkdir, readFile, stat, writeFile } from "node:fs/promises";
|
|
5
|
-
import { tmpdir } from "node:os";
|
|
6
|
-
import { resolve } from "node:path";
|
|
7
|
-
import { describe, expect, it, vi } from "vitest";
|
|
8
|
-
import { ensureCloudflared, findSystemCloudflared } from "./installer.js";
|
|
9
|
-
describe("ensureCloudflared", () => {
|
|
10
|
-
it("extracts a verified bundled archive and repairs executable permissions", async () => {
|
|
11
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-cloudflared-bundle-"));
|
|
12
|
-
const asset = await createArchive(root, "#!/bin/sh\necho bundled\n");
|
|
13
|
-
const executable = await ensureCloudflared("darwin-arm64", resolve(root, "data"), {
|
|
14
|
-
resolveBundled: async () => asset,
|
|
15
|
-
findSystem: async () => null,
|
|
16
|
-
});
|
|
17
|
-
expect(await readFile(executable, "utf8")).toContain("bundled");
|
|
18
|
-
await access(executable, constants.X_OK);
|
|
19
|
-
expect(await readFile(`${executable}.source.sha256`, "utf8")).toBe(`${asset.sha256}\n`);
|
|
20
|
-
});
|
|
21
|
-
it("reuses the verified cache", async () => {
|
|
22
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-cloudflared-cache-"));
|
|
23
|
-
const asset = await createArchive(root, "#!/bin/sh\n");
|
|
24
|
-
const resolver = vi.fn(async () => asset);
|
|
25
|
-
const options = { resolveBundled: resolver, findSystem: async () => null };
|
|
26
|
-
const first = await ensureCloudflared("darwin-arm64", resolve(root, "data"), options);
|
|
27
|
-
const second = await ensureCloudflared("darwin-arm64", resolve(root, "data"), options);
|
|
28
|
-
expect(second).toBe(first);
|
|
29
|
-
expect(resolver).toHaveBeenCalledTimes(2);
|
|
30
|
-
});
|
|
31
|
-
it("copies a verified Windows executable without tar", async () => {
|
|
32
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-cloudflared-windows-"));
|
|
33
|
-
const assetPath = resolve(root, "source.exe");
|
|
34
|
-
const bytes = Buffer.from("MZ-test-windows-binary");
|
|
35
|
-
await writeFile(assetPath, bytes);
|
|
36
|
-
const asset = {
|
|
37
|
-
assetPath,
|
|
38
|
-
assetFormat: "executable",
|
|
39
|
-
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
40
|
-
size: bytes.length,
|
|
41
|
-
fileName: "cloudflared.exe",
|
|
42
|
-
version: "test",
|
|
43
|
-
};
|
|
44
|
-
const executable = await ensureCloudflared("windows-amd64", resolve(root, "data"), {
|
|
45
|
-
resolveBundled: async () => asset,
|
|
46
|
-
findSystem: async () => null,
|
|
47
|
-
});
|
|
48
|
-
expect(executable).toBe(resolve(root, "data/bin/cloudflared.exe"));
|
|
49
|
-
expect(await readFile(executable)).toEqual(bytes);
|
|
50
|
-
});
|
|
51
|
-
it("falls back to PATH when the bundled checksum is invalid", async () => {
|
|
52
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-cloudflared-fallback-"));
|
|
53
|
-
const asset = await createArchive(root, "#!/bin/sh\n");
|
|
54
|
-
const system = resolve(root, "system-cloudflared");
|
|
55
|
-
await writeFile(system, "#!/bin/sh\n", { mode: 0o755 });
|
|
56
|
-
const result = await ensureCloudflared("darwin-arm64", resolve(root, "data"), {
|
|
57
|
-
resolveBundled: async () => ({ ...asset, sha256: "0".repeat(64) }),
|
|
58
|
-
findSystem: async () => system,
|
|
59
|
-
});
|
|
60
|
-
expect(result).toBe(system);
|
|
61
|
-
});
|
|
62
|
-
it("reports package and PATH failures without downloading", async () => {
|
|
63
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-cloudflared-missing-"));
|
|
64
|
-
await expect(ensureCloudflared("darwin-arm64", resolve(root, "data"), {
|
|
65
|
-
resolveBundled: async () => null,
|
|
66
|
-
findSystem: async () => null,
|
|
67
|
-
})).rejects.toThrow("platform package missing for darwin-arm64; no executable on PATH");
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe("findSystemCloudflared", () => {
|
|
71
|
-
it("reuses an executable cloudflared already installed on PATH", async () => {
|
|
72
|
-
const directory = await mkdtemp(resolve(tmpdir(), "agentroam-cloudflared-path-"));
|
|
73
|
-
const executable = resolve(directory, "cloudflared");
|
|
74
|
-
await writeFile(executable, "#!/bin/sh\n", { mode: 0o644 });
|
|
75
|
-
expect(await findSystemCloudflared(directory, "darwin")).toBeNull();
|
|
76
|
-
await chmod(executable, 0o755);
|
|
77
|
-
expect(await findSystemCloudflared(directory, "darwin")).toBe(executable);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
async function createArchive(root, content) {
|
|
81
|
-
const source = resolve(root, "source");
|
|
82
|
-
await mkdir(source, { recursive: true });
|
|
83
|
-
await writeFile(resolve(source, "cloudflared"), content, { mode: 0o644 });
|
|
84
|
-
const archivePath = resolve(root, "cloudflared.tgz");
|
|
85
|
-
execFileSync("tar", ["-czf", archivePath, "-C", source, "cloudflared"]);
|
|
86
|
-
const bytes = await readFile(archivePath);
|
|
87
|
-
return {
|
|
88
|
-
assetPath: archivePath,
|
|
89
|
-
assetFormat: "tgz",
|
|
90
|
-
sha256: createHash("sha256").update(bytes).digest("hex"),
|
|
91
|
-
size: (await stat(archivePath)).size,
|
|
92
|
-
fileName: "cloudflared",
|
|
93
|
-
version: "test",
|
|
94
|
-
};
|
|
95
|
-
}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { mkdtemp, mkdir, stat, writeFile } from "node:fs/promises";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { resolve } from "node:path";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { repairNativeRuntimePermissions } from "./native-runtime.js";
|
|
6
|
-
describe("repairNativeRuntimePermissions", () => {
|
|
7
|
-
it("restores the node-pty helper execute bits stripped by npm pack", async () => {
|
|
8
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-native-"));
|
|
9
|
-
const helper = resolve(root, "node_modules/node-pty/prebuilds/darwin-arm64/spawn-helper");
|
|
10
|
-
await mkdir(resolve(helper, ".."), { recursive: true });
|
|
11
|
-
await writeFile(helper, "helper", { mode: 0o644 });
|
|
12
|
-
await repairNativeRuntimePermissions(root, "darwin", "arm64");
|
|
13
|
-
expect((await stat(helper)).mode & 0o111).toBe(0o111);
|
|
14
|
-
});
|
|
15
|
-
it("fails before gateway startup when the helper is missing", async () => {
|
|
16
|
-
const root = await mkdtemp(resolve(tmpdir(), "agentroam-native-missing-"));
|
|
17
|
-
await expect(repairNativeRuntimePermissions(root, "darwin", "arm64")).rejects.toThrow("spawn-helper missing");
|
|
18
|
-
});
|
|
19
|
-
});
|
package/dist/network.test.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { findLanUrl } from "./network.js";
|
|
3
|
-
describe("findLanUrl", () => {
|
|
4
|
-
it("prefers an RFC1918 address over VPN and public interfaces", () => {
|
|
5
|
-
expect(findLanUrl(52032, {
|
|
6
|
-
utun7: [{ address: "100.121.10.115", netmask: "255.255.255.255", family: "IPv4", mac: "", internal: false, cidr: null }],
|
|
7
|
-
en0: [{ address: "10.22.34.143", netmask: "255.255.252.0", family: "IPv4", mac: "", internal: false, cidr: null }],
|
|
8
|
-
})).toBe("http://10.22.34.143:52032");
|
|
9
|
-
});
|
|
10
|
-
it("falls back to the first external IPv4 address", () => {
|
|
11
|
-
expect(findLanUrl(4100, {
|
|
12
|
-
utun7: [{ address: "100.121.10.115", netmask: "255.255.255.255", family: "IPv4", mac: "", internal: false, cidr: null }],
|
|
13
|
-
})).toBe("http://100.121.10.115:4100");
|
|
14
|
-
});
|
|
15
|
-
it("returns null when only loopback is available", () => {
|
|
16
|
-
expect(findLanUrl(4100, {
|
|
17
|
-
lo0: [{ address: "127.0.0.1", netmask: "255.0.0.0", family: "IPv4", mac: "", internal: true, cidr: null }],
|
|
18
|
-
})).toBeNull();
|
|
19
|
-
});
|
|
20
|
-
});
|
package/dist/pairing.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
2
|
-
export function createPairingSecret(now = Date.now()) { const token = randomBytes(32).toString("base64url"); return { token, hashHex: createHash("sha256").update(token).digest("hex"), expiresAt: new Date(now + 5 * 60 * 1000).toISOString() }; }
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { mkdtempSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
|
-
import { tmpdir } from "node:os";
|
|
3
|
-
import { dirname, resolve } from "node:path";
|
|
4
|
-
import { describe, expect, it } from "vitest";
|
|
5
|
-
import { AGENTROAM_VERSION, requirePlatformPackages, resolvePlatformRuntime, resolvePlatformTui, } from "./platform-packages.js";
|
|
6
|
-
describe("platform packages", () => {
|
|
7
|
-
it("maps macOS arm64 and Windows x64 package names", () => {
|
|
8
|
-
expect(requirePlatformPackages("darwin-arm64")).toEqual({
|
|
9
|
-
runtime: "agentroam-runtime-darwin-arm64",
|
|
10
|
-
cloudflared: "agentroam-cloudflared-darwin-arm64",
|
|
11
|
-
tui: "agentroam-tui-darwin-arm64",
|
|
12
|
-
});
|
|
13
|
-
expect(requirePlatformPackages("windows-amd64")).toEqual({
|
|
14
|
-
runtime: "agentroam-runtime-win32-x64",
|
|
15
|
-
cloudflared: "agentroam-cloudflared-win32-x64",
|
|
16
|
-
tui: "@caoqu/agentroam-tui-win32-x64",
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
it("rejects targets without a published package set", () => {
|
|
20
|
-
expect(() => requirePlatformPackages("darwin-amd64")).toThrow("unavailable for darwin-amd64");
|
|
21
|
-
});
|
|
22
|
-
it("resolves a matching runtime manifest", () => {
|
|
23
|
-
const root = mkdtempSync(resolve(tmpdir(), "agentroam-runtime-resolver-"));
|
|
24
|
-
const manifestPath = resolve(root, "manifest.json");
|
|
25
|
-
const runtimePackageJson = resolve(root, "runtime/package.json");
|
|
26
|
-
mkdirSync(dirname(runtimePackageJson), { recursive: true });
|
|
27
|
-
writeFileSync(runtimePackageJson, "{}");
|
|
28
|
-
writeFileSync(manifestPath, JSON.stringify({
|
|
29
|
-
packageVersion: AGENTROAM_VERSION,
|
|
30
|
-
target: "windows-amd64",
|
|
31
|
-
nodeMajor: 22,
|
|
32
|
-
nodeModuleAbi: 127,
|
|
33
|
-
nativeFiles: { "node_modules/example.node": "a".repeat(64) },
|
|
34
|
-
}));
|
|
35
|
-
const resolved = resolvePlatformRuntime("windows-amd64", fakeRequire({
|
|
36
|
-
"/manifest.json": manifestPath,
|
|
37
|
-
"/runtime": runtimePackageJson,
|
|
38
|
-
}));
|
|
39
|
-
expect(resolved.runtimeRoot).toBe(dirname(runtimePackageJson));
|
|
40
|
-
expect(resolved.manifest.target).toBe("windows-amd64");
|
|
41
|
-
});
|
|
42
|
-
it("rejects mismatched runtime versions and targets", () => {
|
|
43
|
-
const root = mkdtempSync(resolve(tmpdir(), "agentroam-runtime-invalid-"));
|
|
44
|
-
const manifestPath = resolve(root, "manifest.json");
|
|
45
|
-
const runtimePackageJson = resolve(root, "runtime/package.json");
|
|
46
|
-
mkdirSync(dirname(runtimePackageJson), { recursive: true });
|
|
47
|
-
writeFileSync(runtimePackageJson, "{}");
|
|
48
|
-
writeFileSync(manifestPath, JSON.stringify({
|
|
49
|
-
packageVersion: "0.0.0",
|
|
50
|
-
target: "darwin-arm64",
|
|
51
|
-
nodeMajor: 22,
|
|
52
|
-
nodeModuleAbi: 127,
|
|
53
|
-
nativeFiles: {},
|
|
54
|
-
}));
|
|
55
|
-
expect(() => resolvePlatformRuntime("windows-amd64", fakeRequire({
|
|
56
|
-
"/manifest.json": manifestPath,
|
|
57
|
-
"/runtime": runtimePackageJson,
|
|
58
|
-
}))).toThrow("invalid AgentRoam runtime manifest");
|
|
59
|
-
});
|
|
60
|
-
it("resolves the target TUI entry", () => {
|
|
61
|
-
const entry = resolvePlatformTui("windows-amd64", fakeRequire({ "/entry": "C:\\agentroam\\agent-tui.js" }));
|
|
62
|
-
expect(entry).toBe("C:\\agentroam\\agent-tui.js");
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
function fakeRequire(suffixes) {
|
|
66
|
-
return {
|
|
67
|
-
resolve(id) {
|
|
68
|
-
for (const [suffix, value] of Object.entries(suffixes)) {
|
|
69
|
-
if (id.endsWith(suffix))
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
throw Object.assign(new Error(`missing ${id}`), { code: "MODULE_NOT_FOUND" });
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
}
|
package/dist/platform.test.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { detectPlatform } from "./platform.js";
|
|
3
|
-
describe("detectPlatform", () => { it("maps supported targets", () => { expect(detectPlatform("darwin", "arm64", "22.1.0")).toBe("darwin-arm64"); expect(detectPlatform("win32", "x64", "22.1.0")).toBe("windows-amd64"); }); it("rejects unsupported versions", () => expect(() => detectPlatform("darwin", "arm64", "23.0.0")).toThrow("Node.js 22")); });
|
package/dist/port.test.js
DELETED
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
import { describe, expect, it, vi } from "vitest";
|
|
3
|
-
import { ProcessSupervisor } from "./process-supervisor.js";
|
|
4
|
-
function fakeChild(pid = 42) {
|
|
5
|
-
const child = new EventEmitter();
|
|
6
|
-
Object.assign(child, { pid, exitCode: null, kill: vi.fn(() => true) });
|
|
7
|
-
return child;
|
|
8
|
-
}
|
|
9
|
-
describe("ProcessSupervisor", () => {
|
|
10
|
-
it("falls back to child.kill when taskkill cannot start", async () => {
|
|
11
|
-
const child = fakeChild();
|
|
12
|
-
const spawnProcess = vi.fn(() => {
|
|
13
|
-
const killer = new EventEmitter();
|
|
14
|
-
queueMicrotask(() => killer.emit("error", new Error("ENOENT")));
|
|
15
|
-
return killer;
|
|
16
|
-
});
|
|
17
|
-
const supervisor = new ProcessSupervisor("win32", spawnProcess);
|
|
18
|
-
const stopping = supervisor.stop(child, 20);
|
|
19
|
-
queueMicrotask(() => {
|
|
20
|
-
Object.assign(child, { exitCode: 0 });
|
|
21
|
-
child.emit("exit", 0, null);
|
|
22
|
-
});
|
|
23
|
-
await stopping;
|
|
24
|
-
expect(spawnProcess).toHaveBeenCalledWith("taskkill", ["/PID", "42", "/T", "/F"], { stdio: "ignore" });
|
|
25
|
-
expect(child.kill).toHaveBeenCalledWith("SIGTERM");
|
|
26
|
-
});
|
|
27
|
-
it("uses taskkill for a running Windows process tree", async () => {
|
|
28
|
-
const child = fakeChild();
|
|
29
|
-
const spawnProcess = vi.fn(() => {
|
|
30
|
-
const killer = new EventEmitter();
|
|
31
|
-
queueMicrotask(() => {
|
|
32
|
-
killer.emit("exit", 0, null);
|
|
33
|
-
Object.assign(child, { exitCode: 0 });
|
|
34
|
-
child.emit("exit", 0, null);
|
|
35
|
-
});
|
|
36
|
-
return killer;
|
|
37
|
-
});
|
|
38
|
-
const supervisor = new ProcessSupervisor("win32", spawnProcess);
|
|
39
|
-
await supervisor.stop(child, 20);
|
|
40
|
-
expect(child.kill).not.toHaveBeenCalled();
|
|
41
|
-
});
|
|
42
|
-
});
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
import { PassThrough } from "node:stream";
|
|
3
|
-
import { describe, expect, it, vi } from "vitest";
|
|
4
|
-
import { waitForConnectedUrl } from "./cloudflare-provider.js";
|
|
5
|
-
describe("waitForConnectedUrl", () => {
|
|
6
|
-
it("waits for both the public URL and a registered tunnel connection", async () => {
|
|
7
|
-
const { child, stderr } = fakeChild();
|
|
8
|
-
let resolved = false;
|
|
9
|
-
const ready = waitForConnectedUrl(child, vi.fn(), 100).then((url) => {
|
|
10
|
-
resolved = true;
|
|
11
|
-
return url;
|
|
12
|
-
});
|
|
13
|
-
stderr.write("https://ready.trycloudflare.com\n");
|
|
14
|
-
await new Promise((resolvePromise) => setImmediate(resolvePromise));
|
|
15
|
-
expect(resolved).toBe(false);
|
|
16
|
-
stderr.write("INF Registered tunnel ");
|
|
17
|
-
stderr.write("connection connIndex=0 protocol=quic\n");
|
|
18
|
-
await expect(ready).resolves.toBe("https://ready.trycloudflare.com");
|
|
19
|
-
});
|
|
20
|
-
it("supports registration output arriving before the URL", async () => {
|
|
21
|
-
const { child, stdout, stderr } = fakeChild();
|
|
22
|
-
const ready = waitForConnectedUrl(child, vi.fn(), 100);
|
|
23
|
-
stdout.write("INF Registered tunnel connection connIndex=0 protocol=http2\n");
|
|
24
|
-
stderr.write("Visit https://later.trycloudflare.com when ready\n");
|
|
25
|
-
await expect(ready).resolves.toBe("https://later.trycloudflare.com");
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
function fakeChild() {
|
|
29
|
-
const stdout = new PassThrough();
|
|
30
|
-
const stderr = new PassThrough();
|
|
31
|
-
const child = Object.assign(new EventEmitter(), { stdout, stderr });
|
|
32
|
-
return { child, stdout, stderr };
|
|
33
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { EventEmitter } from "node:events";
|
|
2
|
-
import { PassThrough } from "node:stream";
|
|
3
|
-
import { describe, expect, it, vi } from "vitest";
|
|
4
|
-
import { PinggyTunnelProvider, parsePinggyUrl } from "./pinggy-provider.js";
|
|
5
|
-
describe("parsePinggyUrl", () => {
|
|
6
|
-
it("accepts only Pinggy free HTTPS URLs", () => {
|
|
7
|
-
expect(parsePinggyUrl("open https://abc-123.run.pinggy-free.link now")).toBe("https://abc-123.run.pinggy-free.link");
|
|
8
|
-
expect(parsePinggyUrl("https://example.com")).toBeNull();
|
|
9
|
-
expect(parsePinggyUrl("http://abc.run.pinggy-free.link")).toBeNull();
|
|
10
|
-
});
|
|
11
|
-
});
|
|
12
|
-
describe("PinggyTunnelProvider", () => {
|
|
13
|
-
it("starts SSH on port 443 with persistent host-key checking", async () => {
|
|
14
|
-
const child = fakeChild();
|
|
15
|
-
const spawnImpl = vi.fn((_command, _args) => child);
|
|
16
|
-
const provider = new PinggyTunnelProvider(43210, "/tmp/agentroam-test", spawnImpl);
|
|
17
|
-
const started = provider.start({ localUrl: "http://127.0.0.1:43210", signal: new AbortController().signal, log: vi.fn() });
|
|
18
|
-
queueMicrotask(() => child.stderr.write("https://sample.run.pinggy-free.link\n"));
|
|
19
|
-
const handle = await started;
|
|
20
|
-
expect(handle.publicUrl).toBe("https://sample.run.pinggy-free.link");
|
|
21
|
-
const args = spawnImpl.mock.calls[0][1];
|
|
22
|
-
expect(args).toContain("443");
|
|
23
|
-
expect(args).toContain("StrictHostKeyChecking=accept-new");
|
|
24
|
-
expect(args).toContain("0:localhost:43210");
|
|
25
|
-
expect(args.some((value) => value.startsWith("UserKnownHostsFile="))).toBe(true);
|
|
26
|
-
});
|
|
27
|
-
});
|
|
28
|
-
function fakeChild() {
|
|
29
|
-
const child = new EventEmitter();
|
|
30
|
-
child.stdout = new PassThrough();
|
|
31
|
-
child.stderr = new PassThrough();
|
|
32
|
-
Object.defineProperty(child, "exitCode", { value: null, writable: true });
|
|
33
|
-
Object.defineProperty(child, "pid", { value: undefined, writable: true });
|
|
34
|
-
child.kill = vi.fn(() => {
|
|
35
|
-
child.exitCode = 0;
|
|
36
|
-
child.emit("exit", 0, null);
|
|
37
|
-
return true;
|
|
38
|
-
});
|
|
39
|
-
return child;
|
|
40
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { parseMacSystemProxy, resolveProxyForUrl } from "./proxy-settings.js";
|
|
3
|
-
const target = new URL("https://api.example.test/status");
|
|
4
|
-
describe("resolveProxyForUrl", () => {
|
|
5
|
-
it("prefers the lowercase HTTPS proxy and normalizes an omitted scheme", async () => {
|
|
6
|
-
await expect(resolveProxyForUrl(target, {
|
|
7
|
-
env: {
|
|
8
|
-
https_proxy: "127.0.0.1:7897",
|
|
9
|
-
HTTPS_PROXY: "http://uppercase.test:8080",
|
|
10
|
-
HTTP_PROXY: "http://http.test:8080",
|
|
11
|
-
},
|
|
12
|
-
platform: "linux",
|
|
13
|
-
})).resolves.toBe("http://127.0.0.1:7897/");
|
|
14
|
-
});
|
|
15
|
-
it("uses HTTP_PROXY as the HTTPS fallback and ALL_PROXY for HTTP", async () => {
|
|
16
|
-
await expect(resolveProxyForUrl(target, { env: { HTTP_PROXY: "http://http.test:8080" }, platform: "linux" })).resolves.toBe("http://http.test:8080/");
|
|
17
|
-
await expect(resolveProxyForUrl(new URL("http://example.test"), {
|
|
18
|
-
env: { ALL_PROXY: "https://all.test:8443" },
|
|
19
|
-
platform: "linux",
|
|
20
|
-
})).resolves.toBe("https://all.test:8443/");
|
|
21
|
-
});
|
|
22
|
-
it.each([
|
|
23
|
-
["*", "https://api.example.test/status"],
|
|
24
|
-
["api.example.test", "https://api.example.test/status"],
|
|
25
|
-
[".example.test", "https://api.example.test/status"],
|
|
26
|
-
["example.test", "https://api.example.test/status"],
|
|
27
|
-
["api.example.test:443", "https://api.example.test/status"],
|
|
28
|
-
["api.example.test:8443", "https://api.example.test:8443/status"],
|
|
29
|
-
])("bypasses the proxy for NO_PROXY=%s", async (noProxy, url) => {
|
|
30
|
-
await expect(resolveProxyForUrl(new URL(url), {
|
|
31
|
-
env: { HTTPS_PROXY: "http://proxy.test:8080", NO_PROXY: noProxy },
|
|
32
|
-
platform: "darwin",
|
|
33
|
-
readMacSystemProxy: vi.fn(async () => macProxyOutput()),
|
|
34
|
-
})).resolves.toBeNull();
|
|
35
|
-
});
|
|
36
|
-
it("does not bypass a suffix lookalike or a rule with a different port", async () => {
|
|
37
|
-
await expect(resolveProxyForUrl(target, {
|
|
38
|
-
env: { HTTPS_PROXY: "http://proxy.test:8080", no_proxy: "notexample.test,api.example.test:8443" },
|
|
39
|
-
platform: "linux",
|
|
40
|
-
})).resolves.toBe("http://proxy.test:8080/");
|
|
41
|
-
});
|
|
42
|
-
it("falls back to uppercase NO_PROXY when the lowercase value is empty", async () => {
|
|
43
|
-
await expect(resolveProxyForUrl(target, {
|
|
44
|
-
env: { HTTPS_PROXY: "http://proxy.test:8080", no_proxy: "", NO_PROXY: "example.test" },
|
|
45
|
-
platform: "linux",
|
|
46
|
-
})).resolves.toBeNull();
|
|
47
|
-
});
|
|
48
|
-
it("falls back to the enabled macOS HTTPS proxy", async () => {
|
|
49
|
-
await expect(resolveProxyForUrl(target, {
|
|
50
|
-
env: {},
|
|
51
|
-
platform: "darwin",
|
|
52
|
-
readMacSystemProxy: async () => macProxyOutput(),
|
|
53
|
-
})).resolves.toBe("http://127.0.0.1:7897/");
|
|
54
|
-
});
|
|
55
|
-
it("uses the macOS HTTP proxy when HTTPS proxying is disabled", async () => {
|
|
56
|
-
await expect(resolveProxyForUrl(target, {
|
|
57
|
-
env: {},
|
|
58
|
-
platform: "darwin",
|
|
59
|
-
readMacSystemProxy: async () => macProxyOutput({ httpsEnabled: false }),
|
|
60
|
-
})).resolves.toBe("http://127.0.0.1:7898/");
|
|
61
|
-
});
|
|
62
|
-
it("returns direct mode for command failures and non-macOS platforms", async () => {
|
|
63
|
-
await expect(resolveProxyForUrl(target, {
|
|
64
|
-
env: {},
|
|
65
|
-
platform: "darwin",
|
|
66
|
-
readMacSystemProxy: async () => {
|
|
67
|
-
throw new Error("scutil failed");
|
|
68
|
-
},
|
|
69
|
-
})).resolves.toBeNull();
|
|
70
|
-
const reader = vi.fn(async () => macProxyOutput());
|
|
71
|
-
await expect(resolveProxyForUrl(target, { env: {}, platform: "linux", readMacSystemProxy: reader })).resolves.toBeNull();
|
|
72
|
-
expect(reader).not.toHaveBeenCalled();
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
describe("parseMacSystemProxy", () => {
|
|
76
|
-
it("parses enabled HTTP and HTTPS settings", () => {
|
|
77
|
-
expect(parseMacSystemProxy(macProxyOutput())).toEqual({
|
|
78
|
-
httpProxy: "http://127.0.0.1:7898/",
|
|
79
|
-
httpsProxy: "http://127.0.0.1:7897/",
|
|
80
|
-
});
|
|
81
|
-
});
|
|
82
|
-
it("ignores disabled and malformed settings", () => {
|
|
83
|
-
expect(parseMacSystemProxy(`
|
|
84
|
-
HTTPEnable : 0
|
|
85
|
-
HTTPProxy : 127.0.0.1
|
|
86
|
-
HTTPPort : 7898
|
|
87
|
-
HTTPSEnable : 1
|
|
88
|
-
HTTPSProxy : 127.0.0.1
|
|
89
|
-
HTTPSPort : not-a-port
|
|
90
|
-
`)).toEqual({ httpProxy: null, httpsProxy: null });
|
|
91
|
-
expect(parseMacSystemProxy("HTTPSEnable : 1\nHTTPSProxy : 127.0.0.1\nHTTPSPort : 70000")).toEqual({
|
|
92
|
-
httpProxy: null,
|
|
93
|
-
httpsProxy: null,
|
|
94
|
-
});
|
|
95
|
-
expect(parseMacSystemProxy("HTTPSEnable : 1\nHTTPSProxy : proxy.test/path\nHTTPSPort : 7897")).toEqual({
|
|
96
|
-
httpProxy: null,
|
|
97
|
-
httpsProxy: null,
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
});
|
|
101
|
-
function macProxyOutput({ httpsEnabled = true } = {}) {
|
|
102
|
-
return `
|
|
103
|
-
<dictionary> {
|
|
104
|
-
HTTPEnable : 1
|
|
105
|
-
HTTPPort : 7898
|
|
106
|
-
HTTPProxy : 127.0.0.1
|
|
107
|
-
HTTPSEnable : ${httpsEnabled ? "1" : "0"}
|
|
108
|
-
HTTPSPort : 7897
|
|
109
|
-
HTTPSProxy : 127.0.0.1
|
|
110
|
-
}`;
|
|
111
|
-
}
|