agentroam 0.2.0-preview.7 → 0.2.0-preview.71
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 +244 -44
- 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 +130 -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 +31 -9
- package/dist/tunnel/tunnel-controller.js +144 -0
- 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
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { waitForPublicReadiness } from "./public-readiness.js";
|
|
3
|
-
describe("waitForPublicReadiness", () => {
|
|
4
|
-
it("retries a transient 530 and accepts the expected auth status", async () => {
|
|
5
|
-
const fetchImpl = vi
|
|
6
|
-
.fn()
|
|
7
|
-
.mockResolvedValueOnce(new Response("unavailable", { status: 530 }))
|
|
8
|
-
.mockResolvedValueOnce(Response.json({ authenticated: false, needsSetup: true }, { status: 200 }));
|
|
9
|
-
await waitForPublicReadiness("https://example.test", {
|
|
10
|
-
fetchImpl,
|
|
11
|
-
intervalMs: 1,
|
|
12
|
-
timeoutMs: 100,
|
|
13
|
-
});
|
|
14
|
-
expect(fetchImpl).toHaveBeenCalledTimes(2);
|
|
15
|
-
});
|
|
16
|
-
it("rejects an invalid HTTP 200 payload", async () => {
|
|
17
|
-
const fetchImpl = vi.fn().mockResolvedValue(Response.json({ ok: true }));
|
|
18
|
-
await expect(waitForPublicReadiness("https://example.test", { fetchImpl, intervalMs: 1, timeoutMs: 5 })).rejects.toThrow("invalid auth status JSON");
|
|
19
|
-
});
|
|
20
|
-
it("includes the last HTTP status in timeout diagnostics", async () => {
|
|
21
|
-
const fetchImpl = vi.fn().mockResolvedValue(new Response("bad gateway", { status: 502 }));
|
|
22
|
-
await expect(waitForPublicReadiness("https://example.test", { fetchImpl, intervalMs: 1, timeoutMs: 5 })).rejects.toThrow("HTTP 502");
|
|
23
|
-
});
|
|
24
|
-
it("reuses one proxy handle across retries and closes it after success", async () => {
|
|
25
|
-
const close = vi.fn(async () => { });
|
|
26
|
-
const proxiedFetch = vi
|
|
27
|
-
.fn()
|
|
28
|
-
.mockResolvedValueOnce(new Response("unavailable", { status: 530 }))
|
|
29
|
-
.mockResolvedValueOnce(Response.json({ authenticated: false, needsSetup: true }, { status: 200 }));
|
|
30
|
-
const proxyFetchFactory = vi.fn(() => ({ fetch: proxiedFetch, close }));
|
|
31
|
-
await waitForPublicReadiness("https://example.test", {
|
|
32
|
-
intervalMs: 1,
|
|
33
|
-
timeoutMs: 100,
|
|
34
|
-
proxyResolver: async () => "http://127.0.0.1:7897/",
|
|
35
|
-
proxyFetchFactory,
|
|
36
|
-
});
|
|
37
|
-
expect(proxyFetchFactory).toHaveBeenCalledOnce();
|
|
38
|
-
expect(proxiedFetch).toHaveBeenCalledTimes(2);
|
|
39
|
-
expect(close).toHaveBeenCalledOnce();
|
|
40
|
-
});
|
|
41
|
-
it.each([
|
|
42
|
-
{
|
|
43
|
-
name: "a fatal response",
|
|
44
|
-
fetchImpl: vi.fn().mockResolvedValue(new Response("forbidden", { status: 403 })),
|
|
45
|
-
timeoutMs: 100,
|
|
46
|
-
expected: "HTTP 403",
|
|
47
|
-
},
|
|
48
|
-
{
|
|
49
|
-
name: "a timeout",
|
|
50
|
-
fetchImpl: vi.fn().mockResolvedValue(new Response("unavailable", { status: 530 })),
|
|
51
|
-
timeoutMs: 2,
|
|
52
|
-
expected: "HTTP 530",
|
|
53
|
-
},
|
|
54
|
-
])("closes the proxy handle after $name", async ({ fetchImpl, timeoutMs, expected }) => {
|
|
55
|
-
const close = vi.fn(async () => { });
|
|
56
|
-
await expect(waitForPublicReadiness("https://example.test", {
|
|
57
|
-
intervalMs: 1,
|
|
58
|
-
timeoutMs,
|
|
59
|
-
proxyResolver: async () => "http://127.0.0.1:7897/",
|
|
60
|
-
proxyFetchFactory: () => ({ fetch: fetchImpl, close }),
|
|
61
|
-
})).rejects.toThrow(expected);
|
|
62
|
-
expect(close).toHaveBeenCalledOnce();
|
|
63
|
-
});
|
|
64
|
-
it("closes the proxy handle when readiness is aborted", async () => {
|
|
65
|
-
const controller = new AbortController();
|
|
66
|
-
const close = vi.fn(async () => { });
|
|
67
|
-
const proxiedFetch = vi.fn().mockImplementation(async () => {
|
|
68
|
-
controller.abort();
|
|
69
|
-
throw new Error("request aborted");
|
|
70
|
-
});
|
|
71
|
-
await expect(waitForPublicReadiness("https://example.test", {
|
|
72
|
-
signal: controller.signal,
|
|
73
|
-
proxyResolver: async () => "http://127.0.0.1:7897/",
|
|
74
|
-
proxyFetchFactory: () => ({ fetch: proxiedFetch, close }),
|
|
75
|
-
})).rejects.toThrow("public tunnel readiness aborted");
|
|
76
|
-
expect(close).toHaveBeenCalledOnce();
|
|
77
|
-
});
|
|
78
|
-
it("does not create a proxy handle in direct mode", async () => {
|
|
79
|
-
const proxyFetchFactory = vi.fn();
|
|
80
|
-
const directFetch = vi.spyOn(globalThis, "fetch").mockResolvedValueOnce(Response.json({ authenticated: false, needsSetup: true }));
|
|
81
|
-
try {
|
|
82
|
-
await waitForPublicReadiness("https://example.test", {
|
|
83
|
-
proxyResolver: async () => null,
|
|
84
|
-
proxyFetchFactory,
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
finally {
|
|
88
|
-
directFetch.mockRestore();
|
|
89
|
-
}
|
|
90
|
-
expect(proxyFetchFactory).not.toHaveBeenCalled();
|
|
91
|
-
});
|
|
92
|
-
it("skips proxy discovery when a fetch implementation is injected", async () => {
|
|
93
|
-
const proxyResolver = vi.fn(async () => "http://127.0.0.1:7897/");
|
|
94
|
-
const proxyFetchFactory = vi.fn();
|
|
95
|
-
const fetchImpl = vi.fn().mockResolvedValue(Response.json({ authenticated: false, needsSetup: true }));
|
|
96
|
-
await waitForPublicReadiness("https://example.test", {
|
|
97
|
-
fetchImpl,
|
|
98
|
-
proxyResolver,
|
|
99
|
-
proxyFetchFactory,
|
|
100
|
-
});
|
|
101
|
-
expect(proxyResolver).not.toHaveBeenCalled();
|
|
102
|
-
expect(proxyFetchFactory).not.toHaveBeenCalled();
|
|
103
|
-
});
|
|
104
|
-
});
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it, vi } from "vitest";
|
|
2
|
-
import { selectRelay } from "./relay-orchestrator.js";
|
|
3
|
-
describe("selectRelay", () => {
|
|
4
|
-
it("selects Cloudflare when it becomes ready", async () => {
|
|
5
|
-
const cloudflare = fakeProvider("https://ready.trycloudflare.com");
|
|
6
|
-
const result = await selectRelay(options("auto", { cloudflare }));
|
|
7
|
-
expect(result.provider).toBe("cloudflare");
|
|
8
|
-
expect(result.publicUrl).toContain("trycloudflare.com");
|
|
9
|
-
});
|
|
10
|
-
it("closes failed Cloudflare and selects Pinggy", async () => {
|
|
11
|
-
const cloudflare = fakeProvider("https://bad.trycloudflare.com");
|
|
12
|
-
const pinggy = fakeProvider("https://good.run.pinggy-free.link");
|
|
13
|
-
const readiness = vi.fn(async (url) => {
|
|
14
|
-
if (url.includes("bad"))
|
|
15
|
-
throw new Error("HTTP 530");
|
|
16
|
-
});
|
|
17
|
-
const result = await selectRelay(options("auto", { cloudflare, pinggy }, readiness));
|
|
18
|
-
expect(cloudflare.handle.close).toHaveBeenCalledOnce();
|
|
19
|
-
expect(result.provider).toBe("pinggy");
|
|
20
|
-
expect(result.failures).toEqual([{ provider: "cloudflare", message: "HTTP 530" }]);
|
|
21
|
-
});
|
|
22
|
-
it("falls back to LAN when both public providers fail", async () => {
|
|
23
|
-
const cloudflare = fakeProvider("https://bad.trycloudflare.com");
|
|
24
|
-
const pinggy = fakeProvider("https://bad.run.pinggy-free.link");
|
|
25
|
-
const result = await selectRelay(options("auto", { cloudflare, pinggy }, async () => { throw new Error("blocked"); }));
|
|
26
|
-
expect(result.provider).toBe("lan");
|
|
27
|
-
expect(result.publicUrl).toBe("http://10.0.0.2:43210");
|
|
28
|
-
expect(result.failures).toHaveLength(2);
|
|
29
|
-
});
|
|
30
|
-
it("bypasses every public provider in local-only mode", async () => {
|
|
31
|
-
const cloudflare = fakeProvider("https://unused.trycloudflare.com");
|
|
32
|
-
const result = await selectRelay({ ...options("auto", { cloudflare }), cli: cli("auto", true) });
|
|
33
|
-
expect(result.provider).toBe("lan");
|
|
34
|
-
expect(cloudflare.provider.start).not.toHaveBeenCalled();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
function options(relay, providers, readiness = async () => { }) {
|
|
38
|
-
return {
|
|
39
|
-
cli: cli(relay),
|
|
40
|
-
target: "darwin-arm64",
|
|
41
|
-
localUrl: "http://127.0.0.1:43210",
|
|
42
|
-
lanUrl: "http://10.0.0.2:43210",
|
|
43
|
-
port: 43210,
|
|
44
|
-
signal: new AbortController().signal,
|
|
45
|
-
log: vi.fn(),
|
|
46
|
-
readiness: readiness,
|
|
47
|
-
providerFactories: Object.fromEntries(Object.entries(providers).map(([name, value]) => [name, async () => value.provider])),
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
function cli(relay, localOnly = false) {
|
|
51
|
-
return {
|
|
52
|
-
command: "start",
|
|
53
|
-
roots: [process.cwd()],
|
|
54
|
-
port: null,
|
|
55
|
-
relay,
|
|
56
|
-
tunnelCommand: relay === "custom" ? "relay {port}" : null,
|
|
57
|
-
localOnly,
|
|
58
|
-
qr: false,
|
|
59
|
-
dataDir: "/tmp/agentroam-test",
|
|
60
|
-
};
|
|
61
|
-
}
|
|
62
|
-
function fakeProvider(publicUrl) {
|
|
63
|
-
const handle = {
|
|
64
|
-
publicUrl,
|
|
65
|
-
close: vi.fn(async () => { }),
|
|
66
|
-
exited: new Promise(() => { }),
|
|
67
|
-
};
|
|
68
|
-
const provider = {
|
|
69
|
-
start: vi.fn(async () => handle),
|
|
70
|
-
};
|
|
71
|
-
return { provider, handle };
|
|
72
|
-
}
|