@proagentstore/cli 0.4.69 → 0.4.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.
Files changed (2) hide show
  1. package/dist/index.js +21 -4
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1204,6 +1204,21 @@ async function waitForLocalRunner(opts, timeoutMs = 15e3) {
1204
1204
  // src/commands/runner/relay.ts
1205
1205
  import { hostname as hostname3 } from "os";
1206
1206
 
1207
+ // src/commands/runner/resources.ts
1208
+ import os from "os";
1209
+ function sampleResources(read = os, now = Date.now()) {
1210
+ const [l1 = 0, l5 = 0, l15 = 0] = read.loadavg();
1211
+ return {
1212
+ loadAvg: [l1, l5, l15],
1213
+ // `availableParallelism` would be better, but `cpus()` is what every supported Node has.
1214
+ cpus: Math.max(1, read.cpus().length),
1215
+ memTotalBytes: read.totalmem(),
1216
+ memFreeBytes: read.freemem(),
1217
+ platform: read.platform(),
1218
+ sampledAt: now
1219
+ };
1220
+ }
1221
+
1207
1222
  // src/commands/runner/self-update.ts
1208
1223
  import { execFile, spawn as spawn3 } from "child_process";
1209
1224
  import { promisify } from "util";
@@ -1517,7 +1532,8 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
1517
1532
  await registerRuntime(openedId, reconnect ? false : force);
1518
1533
  reportRegistration();
1519
1534
  },
1520
- answerControl
1535
+ answerControl,
1536
+ runnerNode
1521
1537
  )
1522
1538
  );
1523
1539
  if (label) writeLine(`Attached agent: ${label}`);
@@ -1543,9 +1559,10 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
1543
1559
  const heartbeat = () => {
1544
1560
  const timer = setTimeout(async () => {
1545
1561
  let failure = null;
1562
+ const resources = sampleResources();
1546
1563
  for (const id of [...attached.keys()]) {
1547
1564
  try {
1548
- await requestPags("POST", `/v1/instances/${apiPathSegment(id)}/runtime/heartbeat`, opts, { runnerNode });
1565
+ await requestPags("POST", `/v1/instances/${apiPathSegment(id)}/runtime/heartbeat`, opts, { runnerNode, resources });
1549
1566
  } catch (e) {
1550
1567
  failure = e instanceof Error ? e.message : String(e);
1551
1568
  }
@@ -1622,7 +1639,7 @@ async function connectViaRelay(instanceIds, localUrl, runnerToken, opts, force =
1622
1639
  tick();
1623
1640
  }
1624
1641
  }
1625
- function openRelaySocket(instanceId, wsBase, mintToken, localUrl, runnerToken, force = false, onConflict, onOpen, onControl) {
1642
+ function openRelaySocket(instanceId, wsBase, mintToken, localUrl, runnerToken, force = false, onConflict, onOpen, onControl, runnerNode = hostname3()) {
1626
1643
  let backoffMs = 1e3;
1627
1644
  let reconnecting = false;
1628
1645
  let closed = false;
@@ -1648,7 +1665,7 @@ function openRelaySocket(instanceId, wsBase, mintToken, localUrl, runnerToken, f
1648
1665
  backoffMs = Math.min(backoffMs * 2, 3e4);
1649
1666
  return;
1650
1667
  }
1651
- const params = new URLSearchParams({ token: relayToken, node: hostname3() });
1668
+ const params = new URLSearchParams({ token: relayToken, node: runnerNode });
1652
1669
  if (force) params.set("force", "1");
1653
1670
  const url = `${wsBase}/v1/relay/${encodeURIComponent(instanceId)}/connect?${params.toString()}`;
1654
1671
  const ws = new WebSocket(url);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@proagentstore/cli",
3
- "version": "0.4.69",
3
+ "version": "0.4.71",
4
4
  "description": "CLI for creating, publishing, and running ProAgentStore agents",
5
5
  "license": "MIT",
6
6
  "type": "module",