camstack 1.2.14 → 1.2.16

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/cli.js CHANGED
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runDiscover
4
- } from "./chunk-EA6763XQ.js";
5
- import "./chunk-K3NQKI34.js";
4
+ } from "./chunk-O5WJH4RV.js";
5
+ import "./chunk-LMMQX4CK.js";
6
6
 
7
7
  // src/cli.ts
8
8
  import { createRequire } from "module";
@@ -15,7 +15,9 @@ import { parseArgs as parseArgs7 } from "util";
15
15
  import { parseArgs } from "util";
16
16
  function buildServeEnv(opts) {
17
17
  const env = {
18
- CAMSTACK_MODE: "hub"
18
+ // `CAMSTACK_ROLE`, not `CAMSTACK_MODE` — see agent.ts. This one worked
19
+ // only because an empty role DEFAULTS to hub, i.e. by accident.
20
+ CAMSTACK_ROLE: "hub"
19
21
  };
20
22
  if (opts.port) env.PORT = opts.port;
21
23
  if (opts.data) env.CAMSTACK_DATA = opts.data;
@@ -36,7 +38,7 @@ async function runServe(args) {
36
38
  ...typeof values.data === "string" ? { data: values.data } : {}
37
39
  };
38
40
  Object.assign(process.env, buildServeEnv(opts));
39
- await import("@camstack/server/main.js");
41
+ await import("./launcher-QKPDMXLY.js");
40
42
  }
41
43
 
42
44
  // src/commands/agent.ts
@@ -46,7 +48,11 @@ function buildAgentEnv(opts) {
46
48
  const hubPort = opts.port ?? "4443";
47
49
  const agentName = opts.name ?? `${os.hostname()}-${os.arch()}`;
48
50
  return {
49
- CAMSTACK_MODE: "agent",
51
+ // `CAMSTACK_ROLE`, not `CAMSTACK_MODE`. Nothing in server/backend has ever
52
+ // read `CAMSTACK_MODE` — the role switch is `resolveNodeRole`
53
+ // (server/backend/src/node-role.ts), which returns 'hub' for an EMPTY
54
+ // value. So `camstack agent` set a variable no one reads and booted a HUB.
55
+ CAMSTACK_ROLE: "agent",
50
56
  CAMSTACK_HUB_URL: `ws://${opts.hub}:${hubPort}/agent`,
51
57
  CAMSTACK_HUB_TOKEN: opts.token,
52
58
  CAMSTACK_AGENT_NAME: agentName
@@ -77,7 +83,7 @@ async function runAgent(args) {
77
83
  ...typeof values.port === "string" ? { port: values.port } : {}
78
84
  };
79
85
  Object.assign(process.env, buildAgentEnv(opts));
80
- await import("@camstack/server/main.js");
86
+ await import("./launcher-QKPDMXLY.js");
81
87
  }
82
88
 
83
89
  // src/commands/setup.ts
@@ -278,13 +284,13 @@ async function resolveAddonPathInteractive(arg) {
278
284
  }
279
285
  const cwdAbs = path2.resolve(".");
280
286
  if (fs2.existsSync(path2.join(cwdAbs, "package.json"))) {
281
- const { discoverAddonsInCwd: discoverAddonsInCwd2 } = await import("./discover-addons-MHWUAAMX.js");
287
+ const { discoverAddonsInCwd: discoverAddonsInCwd2 } = await import("./discover-addons-3N32LTH7.js");
282
288
  const direct = discoverAddonsInCwd2(cwdAbs, 0);
283
289
  if (direct.length > 0 && direct[0].path === cwdAbs) {
284
290
  return cwdAbs;
285
291
  }
286
292
  }
287
- const { discoverAddonsInCwd } = await import("./discover-addons-MHWUAAMX.js");
293
+ const { discoverAddonsInCwd } = await import("./discover-addons-3N32LTH7.js");
288
294
  const candidates = discoverAddonsInCwd(cwdAbs, 5);
289
295
  if (candidates.length === 0) {
290
296
  throw new Error(
@@ -376,7 +382,7 @@ function packAddon(addonDir) {
376
382
  };
377
383
  }
378
384
  async function fetchOnlineAgents(serverUrl, token) {
379
- const url = `${serverUrl}/trpc/nodes.topology?input=${encodeURIComponent('{"json":null}')}`;
385
+ const url = `${serverUrl}/trpc/nodes.topology?input=${encodeURIComponent('{"json":{}}')}`;
380
386
  const res = await hubRequest(url, {
381
387
  headers: { Authorization: `Bearer ${token}` }
382
388
  });
@@ -386,7 +392,15 @@ async function fetchOnlineAgents(serverUrl, token) {
386
392
  );
387
393
  }
388
394
  const body = await res.json();
389
- const nodes = body.result?.data?.json ?? [];
395
+ if (body.error) {
396
+ throw new Error(`nodes.topology failed: ${body.error.json?.message ?? "unknown error"}`);
397
+ }
398
+ const nodes = body.result?.data?.json;
399
+ if (!Array.isArray(nodes)) {
400
+ throw new Error(
401
+ "nodes.topology returned no node list \u2014 refusing to assume the cluster is empty"
402
+ );
403
+ }
390
404
  return nodes.filter((n) => n.isOnline && !n.isHub);
391
405
  }
392
406
  async function uploadToTarget(args) {
@@ -478,8 +492,8 @@ async function deployAddon(addonPath, opts) {
478
492
  }
479
493
  } catch (err) {
480
494
  const msg = err instanceof Error ? err.message : String(err);
481
- console.error(
482
- `[camstack] --cluster: failed to enumerate agents \u2014 falling back to hub only (${msg})`
495
+ throw new Error(
496
+ `--cluster: cannot enumerate agents, refusing a partial cluster deploy (${msg}). Deploy per node with -n <nodeId> if this is intentional.`
483
497
  );
484
498
  }
485
499
  } else {
@@ -1079,7 +1093,7 @@ function isUnknown(_value) {
1079
1093
  return true;
1080
1094
  }
1081
1095
  async function resolveServerInteractive(presetNamespace) {
1082
- const { discoverNodes, resolveHubFromDiscovered, filterHubNodes, DEFAULT_HUB_HTTPS_PORT } = await import("./discover-UMBUCPOL.js");
1096
+ const { discoverNodes, resolveHubFromDiscovered, filterHubNodes, DEFAULT_HUB_HTTPS_PORT } = await import("./discover-XMMUBDEM.js");
1083
1097
  if (presetNamespace) {
1084
1098
  const spinner4 = clack.spinner();
1085
1099
  spinner4.start(`Discovering hub on LAN (namespace "${presetNamespace}")`);
@@ -5,8 +5,8 @@ import {
5
5
  filterHubNodes,
6
6
  resolveHubFromDiscovered,
7
7
  runDiscover
8
- } from "./chunk-EA6763XQ.js";
9
- import "./chunk-K3NQKI34.js";
8
+ } from "./chunk-O5WJH4RV.js";
9
+ import "./chunk-LMMQX4CK.js";
10
10
  export {
11
11
  DEFAULT_HUB_HTTPS_PORT,
12
12
  discoverNodes,
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import "./chunk-K3NQKI34.js";
2
+ import "./chunk-LMMQX4CK.js";
3
3
 
4
4
  // src/commands/discover-addons.ts
5
5
  import * as fs from "fs";