@proagentstore/cli 0.4.60 → 0.4.61
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/index.js +39 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1220,6 +1220,18 @@ function shouldRegisterOnOpen(reconnect, alreadyRegistered) {
|
|
|
1220
1220
|
function pendingRegistrations(attached, registered) {
|
|
1221
1221
|
return [...attached].filter((id) => !registered.has(id));
|
|
1222
1222
|
}
|
|
1223
|
+
function partitionByPin(instances, thisNode, alsoKnownAs = []) {
|
|
1224
|
+
const here = [];
|
|
1225
|
+
const elsewhere = [];
|
|
1226
|
+
for (const inst of instances) (isEligible(inst, thisNode, alsoKnownAs) ? here : elsewhere).push(inst);
|
|
1227
|
+
return { here, elsewhere };
|
|
1228
|
+
}
|
|
1229
|
+
function registrationStatus(attached, registered) {
|
|
1230
|
+
const ids = [...attached];
|
|
1231
|
+
const have = ids.filter((id) => registered.has(id)).length;
|
|
1232
|
+
const total = ids.length;
|
|
1233
|
+
return { agents: `${have}/${total}`, state: have === total ? "ok" : have === 0 ? "fail" : "partial" };
|
|
1234
|
+
}
|
|
1223
1235
|
function instanceLabel(inst) {
|
|
1224
1236
|
const short = `${inst.id.slice(0, 8)}\u2026`;
|
|
1225
1237
|
return inst.name ? `${inst.name} (${short})` : short;
|
|
@@ -1289,14 +1301,13 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
|
|
|
1289
1301
|
return false;
|
|
1290
1302
|
}
|
|
1291
1303
|
};
|
|
1304
|
+
const attached = /* @__PURE__ */ new Map();
|
|
1305
|
+
const blocked = /* @__PURE__ */ new Set();
|
|
1292
1306
|
const reportRegistration = () => {
|
|
1293
|
-
const agents =
|
|
1294
|
-
const state = registered.size === instanceIds.length ? "ok" : registered.size === 0 ? "fail" : "partial";
|
|
1307
|
+
const { agents, state } = registrationStatus(attached.keys(), registered);
|
|
1295
1308
|
writeLine(formatStatusLine({ registration: state, agents, reason: state === "ok" ? void 0 : lastRegisterError }));
|
|
1296
1309
|
};
|
|
1297
1310
|
for (const id of instanceIds) await registerRuntime(id);
|
|
1298
|
-
const attached = /* @__PURE__ */ new Map();
|
|
1299
|
-
const blocked = /* @__PURE__ */ new Set();
|
|
1300
1311
|
const attach = (id, label = `${id.slice(0, 8)}\u2026`) => {
|
|
1301
1312
|
if (attached.has(id)) return;
|
|
1302
1313
|
const mintToken = () => requestPags("POST", `/v1/relay/${apiPathSegment(id)}/token`, { ...opts, pagsToken }, {}).then((r) => r.token);
|
|
@@ -1339,7 +1350,8 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
|
|
|
1339
1350
|
};
|
|
1340
1351
|
for (const id of instanceIds) attach(id, "");
|
|
1341
1352
|
reportRegistration();
|
|
1342
|
-
|
|
1353
|
+
const startup = registrationStatus(attached.keys(), registered);
|
|
1354
|
+
writeLine(startup.state === "ok" ? `Runtime registered with PAGS \u2713 (${startup.agents} agents)` : `Runtime registration incomplete: ${startup.agents} agents \u2014 retried on each relay (re)connect${watchInstances ? " and every 20s while this runs" : ""}.`);
|
|
1343
1355
|
writeLine("");
|
|
1344
1356
|
writeLine("\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550");
|
|
1345
1357
|
writeLine(` \u2705 CONNECTED \u2014 WebSocket relay \xB7 ${hostname3()}`);
|
|
@@ -1717,6 +1729,7 @@ var runnerCommand = createRunnerCommand();
|
|
|
1717
1729
|
// src/commands/up.ts
|
|
1718
1730
|
import { createRequire as createRequire2 } from "module";
|
|
1719
1731
|
import { Command as Command8 } from "commander";
|
|
1732
|
+
import { hostname as hostname5 } from "os";
|
|
1720
1733
|
|
|
1721
1734
|
// src/tui.ts
|
|
1722
1735
|
import chalk from "chalk";
|
|
@@ -1888,6 +1901,7 @@ var upCommand = new Command8("up").description("Start the browser runner for all
|
|
|
1888
1901
|
const data = await res.json();
|
|
1889
1902
|
const active = (data.instances || []).filter((i) => i.status === "active");
|
|
1890
1903
|
let instances = active;
|
|
1904
|
+
let elsewhere = [];
|
|
1891
1905
|
if (opts.instance) {
|
|
1892
1906
|
instances = instances.filter((i) => i.id === opts.instance || i.slug === opts.instance);
|
|
1893
1907
|
} else {
|
|
@@ -1904,16 +1918,31 @@ var upCommand = new Command8("up").description("Start the browser runner for all
|
|
|
1904
1918
|
writeLine(" Subscribe to an agent at https://proagentstore.online");
|
|
1905
1919
|
process.exit(1);
|
|
1906
1920
|
}
|
|
1907
|
-
state.instances = instances.map((i) => ({ id: i.id, name: i.name || i.slug || i.id.slice(0, 8) }));
|
|
1908
|
-
printStep(`Found ${instances.length} instance${instances.length === 1 ? "" : "s"}`, "ok");
|
|
1909
|
-
for (const inst of state.instances) {
|
|
1910
|
-
writeLine(` ${inst.name} (${inst.id.slice(0, 8)}...)`);
|
|
1911
|
-
}
|
|
1912
1921
|
await maybeClaimMachineNames({
|
|
1913
1922
|
token: session.token,
|
|
1914
1923
|
apiBase: API_BASE3,
|
|
1915
1924
|
headless: opts.headless
|
|
1916
1925
|
}).catch(() => void 0);
|
|
1926
|
+
if (!opts.instance) {
|
|
1927
|
+
const split = partitionByPin(instances, hostname5(), loadMachineIdentity(hostname5()).names);
|
|
1928
|
+
instances = split.here;
|
|
1929
|
+
elsewhere = split.elsewhere;
|
|
1930
|
+
}
|
|
1931
|
+
if (instances.length === 0) {
|
|
1932
|
+
printStep(`All ${elsewhere.length} of your runtime agents are pinned to other machines`, "ok");
|
|
1933
|
+
for (const inst of elsewhere) writeLine(` ${inst.name || inst.slug || inst.id.slice(0, 8)} \u2192 ${inst.config?.runnerNode}`);
|
|
1934
|
+
writeLine(' They are served there. To run one from this machine, change its "Runs on" pin in the console, then `pags up` again.');
|
|
1935
|
+
process.exit(0);
|
|
1936
|
+
}
|
|
1937
|
+
state.instances = instances.map((i) => ({ id: i.id, name: i.name || i.slug || i.id.slice(0, 8) }));
|
|
1938
|
+
printStep(`Found ${instances.length} instance${instances.length === 1 ? "" : "s"}`, "ok");
|
|
1939
|
+
for (const inst of state.instances) {
|
|
1940
|
+
writeLine(` ${inst.name} (${inst.id.slice(0, 8)}...)`);
|
|
1941
|
+
}
|
|
1942
|
+
if (elsewhere.length) {
|
|
1943
|
+
printStep(`${elsewhere.length} more pinned to other machines \u2014 served there, not attached here`, "ok");
|
|
1944
|
+
for (const inst of elsewhere) writeLine(` ${inst.name || inst.slug || inst.id.slice(0, 8)} \u2192 ${inst.config?.runnerNode}`);
|
|
1945
|
+
}
|
|
1917
1946
|
state.activeInstance = instances.length === 1 ? instances[0].name || instances[0].slug || instances[0].id.slice(0, 8) : `${instances.length} agents`;
|
|
1918
1947
|
printStep(`Connecting ${state.activeInstance}\u2026`, "wait");
|
|
1919
1948
|
await stopRunnerProcesses();
|