@proagentstore/cli 0.3.2 → 0.3.3
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/dist/browser-runner/index.js +11 -0
- package/dist/index.js +18 -4
- package/package.json +44 -44
|
@@ -55,6 +55,17 @@ Endpoints:
|
|
|
55
55
|
process.exit(0);
|
|
56
56
|
}
|
|
57
57
|
const config = configFromArgs();
|
|
58
|
+
// SECURITY: the runner's endpoints spawn CLIs and drive a browser as the user.
|
|
59
|
+
// Without a token, `authorize()` allows every request, so a tokenless runner must
|
|
60
|
+
// never be reachable off the local machine. Refuse to start if bound to a
|
|
61
|
+
// non-loopback address without a token. (`pags up` always generates one; this
|
|
62
|
+
// only guards the low-level binary run manually with --host 0.0.0.0 and no token.)
|
|
63
|
+
const LOOPBACK = new Set(["127.0.0.1", "localhost", "::1", "[::1]"]);
|
|
64
|
+
if (!config.token && !LOOPBACK.has(config.host)) {
|
|
65
|
+
process.stderr.write(`Refusing to start: --host ${config.host} exposes the runner off-machine with no --token. ` +
|
|
66
|
+
`Set --token (or PAGS_RUNNER_TOKEN), or bind to 127.0.0.1.\n`);
|
|
67
|
+
process.exit(1);
|
|
68
|
+
}
|
|
58
69
|
const started = await startRunnerServer(config);
|
|
59
70
|
process.stdout.write(`FAGS browser runtime listening at ${started.url}\n`);
|
|
60
71
|
process.stdout.write(`Data dir: ${config.dataDir}\n`);
|
package/dist/index.js
CHANGED
|
@@ -824,7 +824,8 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
|
|
|
824
824
|
}
|
|
825
825
|
}
|
|
826
826
|
for (const id of instanceIds) {
|
|
827
|
-
|
|
827
|
+
const mintToken = () => requestPags("POST", `/v1/relay/${apiPathSegment(id)}/token`, { ...opts, pagsToken }, {}).then((r) => r.token);
|
|
828
|
+
openRelaySocket(id, apiBase, mintToken, localUrl, runnerToken, force);
|
|
828
829
|
}
|
|
829
830
|
writeLine("Runtime registered with PAGS \u2713");
|
|
830
831
|
writeLine("");
|
|
@@ -844,11 +845,24 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
|
|
|
844
845
|
};
|
|
845
846
|
heartbeat();
|
|
846
847
|
}
|
|
847
|
-
function openRelaySocket(instanceId, wsBase,
|
|
848
|
+
function openRelaySocket(instanceId, wsBase, mintToken, localUrl, runnerToken, force = false) {
|
|
848
849
|
let backoffMs = 1e3;
|
|
849
850
|
let reconnecting = false;
|
|
850
|
-
const connect = () => {
|
|
851
|
-
|
|
851
|
+
const connect = async () => {
|
|
852
|
+
let relayToken;
|
|
853
|
+
try {
|
|
854
|
+
relayToken = await mintToken();
|
|
855
|
+
} catch (e) {
|
|
856
|
+
const msg = e instanceof Error ? e.message : String(e);
|
|
857
|
+
const hint = /401|token|sign/i.test(msg) ? " (run `pags login`)" : "";
|
|
858
|
+
writeLine(`Relay token mint failed: ${instanceId.slice(0, 8)}\u2026${hint} \u2014 retrying in ${Math.round(backoffMs / 1e3)}s`);
|
|
859
|
+
setTimeout(() => {
|
|
860
|
+
connect();
|
|
861
|
+
}, backoffMs);
|
|
862
|
+
backoffMs = Math.min(backoffMs * 2, 3e4);
|
|
863
|
+
return;
|
|
864
|
+
}
|
|
865
|
+
const url = `${wsBase}/v1/relay/${encodeURIComponent(instanceId)}/connect?token=${encodeURIComponent(relayToken)}${force ? "&force=1" : ""}`;
|
|
852
866
|
const ws = new WebSocket(url);
|
|
853
867
|
ws.onopen = () => {
|
|
854
868
|
backoffMs = 1e3;
|
package/package.json
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
2
|
+
"name": "@proagentstore/cli",
|
|
3
|
+
"version": "0.3.3",
|
|
4
|
+
"description": "CLI for creating, publishing, and running ProAgentStore agents",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"bin": {
|
|
8
|
+
"pags": "dist/index.js"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://github.com/ProAgentStore/platform#readme",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/ProAgentStore/platform.git",
|
|
14
|
+
"directory": "packages/cli"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"proagentstore",
|
|
18
|
+
"pags",
|
|
19
|
+
"cli",
|
|
20
|
+
"agents",
|
|
21
|
+
"mcp",
|
|
22
|
+
"browser-runner"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"build": "pnpm --filter @proagentstore/browser-runner build && tsup src/index.ts --format esm --dts && node scripts/copy-browser-runner.mjs",
|
|
29
|
+
"dev": "tsx src/index.ts",
|
|
30
|
+
"typecheck": "tsc --noEmit"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"chalk": "^5.6.2",
|
|
34
|
+
"commander": "^13.0.0",
|
|
35
|
+
"playwright": "^1.60.0"
|
|
36
|
+
},
|
|
37
|
+
"devDependencies": {
|
|
38
|
+
"@types/node": "^22.0.0",
|
|
39
|
+
"tsup": "^8.4.0",
|
|
40
|
+
"tsx": "^4.21.0",
|
|
41
|
+
"typescript": "^5.7.0"
|
|
42
|
+
},
|
|
43
|
+
"files": [
|
|
44
|
+
"dist"
|
|
45
|
+
]
|
|
46
46
|
}
|