@stigmer/cli 3.12.9 → 3.13.0

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 (75) hide show
  1. package/commands/up.d.ts.map +1 -1
  2. package/commands/up.js +22 -6
  3. package/commands/up.js.map +1 -1
  4. package/config/resolve.d.ts +5 -2
  5. package/config/resolve.d.ts.map +1 -1
  6. package/config/resolve.js +7 -4
  7. package/config/resolve.js.map +1 -1
  8. package/local/constants.d.ts +8 -3
  9. package/local/constants.d.ts.map +1 -1
  10. package/local/constants.js +8 -3
  11. package/local/constants.js.map +1 -1
  12. package/local/daemon/components.d.ts.map +1 -1
  13. package/local/daemon/components.js +4 -2
  14. package/local/daemon/components.js.map +1 -1
  15. package/local/daemon/env.d.ts +16 -3
  16. package/local/daemon/env.d.ts.map +1 -1
  17. package/local/daemon/env.js +16 -3
  18. package/local/daemon/env.js.map +1 -1
  19. package/local/daemon/launch.d.ts.map +1 -1
  20. package/local/daemon/launch.js +5 -4
  21. package/local/daemon/launch.js.map +1 -1
  22. package/local/daemon/process.d.ts.map +1 -1
  23. package/local/daemon/process.js +8 -5
  24. package/local/daemon/process.js.map +1 -1
  25. package/local/runtime/index.d.ts +2 -2
  26. package/local/runtime/index.d.ts.map +1 -1
  27. package/local/runtime/index.js +4 -2
  28. package/local/runtime/index.js.map +1 -1
  29. package/local/runtime/node.d.ts +8 -0
  30. package/local/runtime/node.d.ts.map +1 -1
  31. package/local/runtime/node.js +74 -23
  32. package/local/runtime/node.js.map +1 -1
  33. package/local/runtime/runner.d.ts +2 -1
  34. package/local/runtime/runner.d.ts.map +1 -1
  35. package/local/runtime/runner.js +4 -31
  36. package/local/runtime/runner.js.map +1 -1
  37. package/local/runtime/runtimes-install.d.ts +13 -0
  38. package/local/runtime/runtimes-install.d.ts.map +1 -0
  39. package/local/runtime/runtimes-install.js +60 -0
  40. package/local/runtime/runtimes-install.js.map +1 -0
  41. package/local/runtime/server.d.ts +26 -30
  42. package/local/runtime/server.d.ts.map +1 -1
  43. package/local/runtime/server.js +106 -108
  44. package/local/runtime/server.js.map +1 -1
  45. package/local/status.d.ts.map +1 -1
  46. package/local/status.js +4 -2
  47. package/local/status.js.map +1 -1
  48. package/local/webconsole/index.d.ts +2 -3
  49. package/local/webconsole/index.d.ts.map +1 -1
  50. package/local/webconsole/index.js +24 -10
  51. package/local/webconsole/index.js.map +1 -1
  52. package/package.json +5 -5
  53. package/src/commands/up.ts +24 -6
  54. package/src/config/resolve.test.ts +1 -1
  55. package/src/config/resolve.ts +7 -4
  56. package/src/local/constants.ts +8 -4
  57. package/src/local/daemon/components.test.ts +9 -1
  58. package/src/local/daemon/components.ts +4 -2
  59. package/src/local/daemon/daemon.integration.test.ts +1 -1
  60. package/src/local/daemon/env.test.ts +15 -4
  61. package/src/local/daemon/env.ts +33 -5
  62. package/src/local/daemon/launch.ts +5 -4
  63. package/src/local/daemon/process.ts +7 -4
  64. package/src/local/runtime/index.ts +6 -5
  65. package/src/local/runtime/node.ts +99 -23
  66. package/src/local/runtime/runner.ts +5 -36
  67. package/src/local/runtime/runtime.test.ts +58 -14
  68. package/src/local/runtime/runtimes-install.test.ts +56 -0
  69. package/src/local/runtime/runtimes-install.ts +72 -0
  70. package/src/local/runtime/server.test.ts +178 -114
  71. package/src/local/runtime/server.ts +149 -129
  72. package/src/local/status.ts +4 -2
  73. package/src/local/webconsole/index.ts +27 -10
  74. package/src/resources/connect/oauth.test.ts +1 -1
  75. package/src/resources/share.test.ts +2 -2
@@ -1,4 +1,5 @@
1
- // Resolution of the Node.js runtime used to launch the runner subprocess.
1
+ // Resolution of the Node.js runtime used to launch the runner and TS-server
2
+ // subprocesses.
2
3
  //
3
4
  // We reuse the very Node that is running the CLI (process.execPath). The CLI is
4
5
  // itself an npm package with `engines: node >= 22.13`, so a suitable Node is
@@ -8,16 +9,26 @@
8
9
  // (`spawn(process.execPath, ...)`). An explicit STIGMER_NODE_BIN override is
9
10
  // honored and capability-checked for advanced/multi-runtime setups.
10
11
  //
11
- // The gate is a CAPABILITY probe, not a version check. The runner's durable
12
- // local checkpointer imports Node's built-in `node:sqlite`, available unflagged
13
- // from 22.13 in the 22.x line and only from 23.4 in the 23.x line — a gap
14
- // (23.0–23.3) that a previous version-table gate here missed, letting those
15
- // Nodes through to crash at runner boot with a raw ERR_UNKNOWN_BUILTIN_MODULE.
16
- // Probing "can this binary provide node:sqlite?" directly cannot drift; the
17
- // version floors survive only in the error message, where staleness is
18
- // harmless. The runner performs the same probe on its own boot (see
19
- // backend/services/runner/src/preflight.ts) — this one exists to fail at
20
- // resolve time with CLI-appropriate guidance instead of a subprocess crash.
12
+ // The gates are CAPABILITY probes, not version checks. Two probes, because the
13
+ // two children need different sqlite capabilities:
14
+ //
15
+ // - The RUNNER's durable local checkpointer imports Node's built-in
16
+ // `node:sqlite`, available unflagged from 22.13 in the 22.x line and only
17
+ // from 23.4 in the 23.x line — a gap (23.0–23.3) that a previous
18
+ // version-table gate here missed, letting those Nodes through to crash at
19
+ // runner boot with a raw ERR_UNKNOWN_BUILTIN_MODULE.
20
+ // - The SERVER additionally needs `node:sqlite` compiled WITH FTS5 (its
21
+ // search index; migration v3 creates an fts5 virtual table at boot). Node
22
+ // 23.4 PROVIDES node:sqlite but its sqlite build LACKS FTS5 — found by
23
+ // D4 #14 and the reason the module-presence probe alone is insufficient
24
+ // for the server. Probing "can this binary create an fts5 table?" directly
25
+ // cannot drift; the version floors survive only in the error messages,
26
+ // where staleness is harmless.
27
+ //
28
+ // The runner performs the module-presence probe on its own boot (see
29
+ // backend/services/runner/src/preflight.ts); the server fails at migration
30
+ // time. Both probes here exist to fail at resolve time with CLI-appropriate
31
+ // guidance instead of a subprocess crash.
21
32
  import { execFileSync } from "node:child_process";
22
33
  import { CliExitError } from "../../errors/cli-exit-error.js";
23
34
  import { ExitCode } from "../../errors/exit-codes.js";
@@ -35,6 +46,14 @@ import { ExitCode } from "../../errors/exit-codes.js";
35
46
  // own runtime: `getBuiltinModule` loads the module, which on 22.x emits an
36
47
  // `ExperimentalWarning` on stderr that must not leak into the CLI's output.
37
48
  const NODE_SQLITE_PROBE = "process.exit(process.getBuiltinModule?.('node:sqlite') === undefined ? 1 : 0)";
49
+ // Exits 0 when the binary's `node:sqlite` can create an FTS5 virtual table,
50
+ // 1 otherwise. Strictly stronger than NODE_SQLITE_PROBE: it exercises the
51
+ // exact operation the server's migration v3 performs, in memory. The
52
+ // try/catch covers both failure shapes — module absent (TypeError on the
53
+ // undefined module) and FTS5 absent (the exec throws "no such module: fts5").
54
+ const NODE_SQLITE_FTS5_PROBE = "try{const{DatabaseSync}=process.getBuiltinModule('node:sqlite');" +
55
+ "new DatabaseSync(':memory:').exec('CREATE VIRTUAL TABLE t USING fts5(x)');" +
56
+ "process.exit(0)}catch{process.exit(1)}";
38
57
  /**
39
58
  * Resolve the Node binary to launch the runner with. Honors STIGMER_NODE_BIN;
40
59
  * otherwise returns the current runtime. Either way the binary is probed for
@@ -43,11 +62,47 @@ const NODE_SQLITE_PROBE = "process.exit(process.getBuiltinModule?.('node:sqlite'
43
62
  * runner-launch paths only (ensureRunner), never on ordinary CLI commands.
44
63
  */
45
64
  export function resolveNode() {
46
- const override = process.env.STIGMER_NODE_BIN;
47
- const bin = override !== undefined && override !== "" ? override : process.execPath;
48
- assertProvidesNodeSqlite(bin);
65
+ const bin = nodeCandidate();
66
+ assertCapability(bin, NODE_SQLITE_PROBE, {
67
+ subject: "the runner",
68
+ capability: "the built-in node:sqlite module",
69
+ floor: "Node >= 22.13 (>= 23.4 in the 23.x line)",
70
+ detail: [
71
+ "The runner's durable checkpointer requires node:sqlite, which is available",
72
+ "unflagged from Node 22.13 (22.x line) and 23.4 (23.x and later) — note that",
73
+ "23.0-23.3 lack it.",
74
+ ],
75
+ });
49
76
  return bin;
50
77
  }
78
+ /**
79
+ * Resolve the Node binary to launch the TS server with. Same
80
+ * STIGMER_NODE_BIN/execPath resolution as {@link resolveNode}, but probes for
81
+ * `node:sqlite` WITH FTS5 — the server's search index needs it and some Node
82
+ * builds (e.g. 23.4) ship node:sqlite without it. Runs on server-launch paths
83
+ * only (ensureServer).
84
+ */
85
+ export function resolveServerNode() {
86
+ const bin = nodeCandidate();
87
+ assertCapability(bin, NODE_SQLITE_FTS5_PROBE, {
88
+ subject: "the stigmer server",
89
+ capability: "the built-in node:sqlite module with FTS5",
90
+ floor: "Node 22.13+ in the 22.x line (23.x builds lack FTS5)",
91
+ detail: [
92
+ "The server's search index requires node:sqlite compiled with FTS5.",
93
+ "The 22.x line from 22.13 is known-good; 23.x builds ship node:sqlite",
94
+ "WITHOUT FTS5 and cannot run the server. Newer majors work if their",
95
+ "sqlite build includes FTS5 — this probe is the authority.",
96
+ ],
97
+ });
98
+ return bin;
99
+ }
100
+ function nodeCandidate() {
101
+ const override = process.env.STIGMER_NODE_BIN;
102
+ return override !== undefined && override !== ""
103
+ ? override
104
+ : process.execPath;
105
+ }
51
106
  /** Best-effort `--version` for error messages only; null when the spawn fails. */
52
107
  function probeNodeVersion(bin) {
53
108
  try {
@@ -61,10 +116,10 @@ function probeNodeVersion(bin) {
61
116
  return null;
62
117
  }
63
118
  }
64
- function assertProvidesNodeSqlite(bin) {
119
+ function assertCapability(bin, probe, copy) {
65
120
  let exitStatus;
66
121
  try {
67
- execFileSync(bin, ["-e", NODE_SQLITE_PROBE], { stdio: "ignore" });
122
+ execFileSync(bin, ["-e", probe], { stdio: "ignore" });
68
123
  return;
69
124
  }
70
125
  catch (err) {
@@ -73,15 +128,11 @@ function assertProvidesNodeSqlite(bin) {
73
128
  exitStatus = err.status ?? null;
74
129
  }
75
130
  if (exitStatus === null) {
76
- throw new CliExitError(`could not run ${bin} to verify the runner's Node requirements`, ExitCode.General, [
77
- `Ensure ${bin} is a working Node >= 22.13 runtime (>= 23.4 in the 23.x line).`,
78
- ]);
131
+ throw new CliExitError(`could not run ${bin} to verify ${copy.subject}'s Node requirements`, ExitCode.General, [`Ensure ${bin} is a working ${copy.floor} runtime.`]);
79
132
  }
80
133
  const version = probeNodeVersion(bin) ?? "unknown version";
81
- throw new CliExitError(`Node at ${bin} (${version}) cannot run the runner: it does not provide the built-in node:sqlite module`, ExitCode.General, [
82
- "The runner's durable checkpointer requires node:sqlite, which is available",
83
- "unflagged from Node 22.13 (22.x line) and 23.4 (23.x and later) — note that",
84
- "23.0-23.3 lack it.",
134
+ throw new CliExitError(`Node at ${bin} (${version}) cannot run ${copy.subject}: it does not provide ${copy.capability}`, ExitCode.General, [
135
+ ...copy.detail,
85
136
  "Upgrade Node, or point STIGMER_NODE_BIN at a suitable runtime.",
86
137
  ]);
87
138
  }
@@ -1 +1 @@
1
- {"version":3,"file":"node.js","sourceRoot":"","sources":["../../../src/local/runtime/node.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,EAAE;AACF,gFAAgF;AAChF,6EAA6E;AAC7E,0EAA0E;AAC1E,iFAAiF;AACjF,yEAAyE;AACzE,6EAA6E;AAC7E,oEAAoE;AACpE,EAAE;AACF,4EAA4E;AAC5E,gFAAgF;AAChF,0EAA0E;AAC1E,4EAA4E;AAC5E,+EAA+E;AAC/E,4EAA4E;AAC5E,uEAAuE;AACvE,oEAAoE;AACpE,yEAAyE;AACzE,4EAA4E;AAE5E,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,gCAAgC,CAAC;AAC9D,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAEtD,+DAA+D;AAC/D,EAAE;AACF,wEAAwE;AACxE,uEAAuE;AACvE,+EAA+E;AAC/E,2EAA2E;AAC3E,4CAA4C;AAC5C,8EAA8E;AAC9E,0EAA0E;AAC1E,8EAA8E;AAC9E,4EAA4E;AAC5E,6EAA6E;AAC7E,8EAA8E;AAC9E,MAAM,iBAAiB,GACrB,+EAA+E,CAAC;AAElF;;;;;;GAMG;AACH,MAAM,UAAU,WAAW;IACzB,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,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B,CACvB,GAAW,EACX,KAAa,EACb,IAAyB;IAEzB,IAAI,UAAyB,CAAC;IAC9B,IAAI,CAAC;QACH,YAAY,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;QACtD,OAAO;IACT,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,oEAAoE;QACpE,qDAAqD;QACrD,UAAU,GAAI,GAAkC,CAAC,MAAM,IAAI,IAAI,CAAC;IAClE,CAAC;IAED,IAAI,UAAU,KAAK,IAAI,EAAE,CAAC;QACxB,MAAM,IAAI,YAAY,CACpB,iBAAiB,GAAG,cAAc,IAAI,CAAC,OAAO,sBAAsB,EACpE,QAAQ,CAAC,OAAO,EAChB,CAAC,UAAU,GAAG,iBAAiB,IAAI,CAAC,KAAK,WAAW,CAAC,CACtD,CAAC;IACJ,CAAC;IAED,MAAM,OAAO,GAAG,gBAAgB,CAAC,GAAG,CAAC,IAAI,iBAAiB,CAAC;IAC3D,MAAM,IAAI,YAAY,CACpB,WAAW,GAAG,KAAK,OAAO,gBAAgB,IAAI,CAAC,OAAO,yBAAyB,IAAI,CAAC,UAAU,EAAE,EAChG,QAAQ,CAAC,OAAO,EAChB;QACE,GAAG,IAAI,CAAC,MAAM;QACd,gEAAgE;KACjE,CACF,CAAC;AACJ,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { type NpmInstall } from "./runtimes-install.js";
1
2
  /** Everything needed to spawn the runner subprocess. */
2
3
  export interface RunnerResolution {
3
4
  /** Node binary to launch with. */
@@ -14,7 +15,7 @@ export interface EnsureRunnerOptions {
14
15
  /** Node resolver (injectable for tests). */
15
16
  node?: () => string;
16
17
  /** npm install implementation (injectable for tests). */
17
- install?: (installDir: string, spec: string) => void;
18
+ install?: NpmInstall;
18
19
  }
19
20
  /**
20
21
  * Ensure a launchable runner, acquiring `@stigmer/runner-slim` on demand if no
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/local/runtime/runner.ts"],"names":[],"mappings":"AAiCA,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,MAAM,CAAC;IACpB,yDAAyD;IACzD,OAAO,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;CACtD;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,gBAAgB,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAM,MAAoB,GAAG,gBAAgB,GAAG,IAAI,CAiBvF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,mBAAwB,GAAG,gBAAgB,CAmC9E"}
1
+ {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../../src/local/runtime/runner.ts"],"names":[],"mappings":"AA6BA,OAAO,EAAmE,KAAK,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAIzH,wDAAwD;AACxD,MAAM,WAAW,gBAAgB;IAC/B,kCAAkC;IAClC,OAAO,EAAE,MAAM,CAAC;IAChB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAC;IAClB,oCAAoC;IACpC,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,mFAAmF;IACnF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,IAAI,CAAC,EAAE,MAAM,MAAM,CAAC;IACpB,yDAAyD;IACzD,OAAO,CAAC,EAAE,UAAU,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,IAAI,GAAE,mBAAwB,GAAG,gBAAgB,CAK7E;AAED;;;;;;GAMG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,MAAM,MAAoB,GAAG,gBAAgB,GAAG,IAAI,CAiBvF;AAED;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,IAAI,GAAE,mBAAwB,GAAG,gBAAgB,CA6B9E"}
@@ -16,8 +16,7 @@
16
16
  // optionalDependencies/os/cpu — ~85 MB instead of the full ~508 MB install. The
17
17
  // launch contract (`node main.js`) is identical to the repo-tree runner, so the
18
18
  // daemon spawns either the same way.
19
- import { execFileSync } from "node:child_process";
20
- import { existsSync, mkdirSync, writeFileSync } from "node:fs";
19
+ import { existsSync } from "node:fs";
21
20
  import { homedir } from "node:os";
22
21
  import { dirname, join } from "node:path";
23
22
  import { fileURLToPath } from "node:url";
@@ -27,6 +26,7 @@ import { log } from "../../logger.js";
27
26
  import { VERSION } from "../../version.js";
28
27
  import { runtimesDir } from "../paths.js";
29
28
  import { resolveNode } from "./node.js";
29
+ import { ensureRuntimesRoot, isAcquirableRelease, npmInstallIntoRuntimes } from "./runtimes-install.js";
30
30
  const SLIM_PACKAGE = "@stigmer/runner-slim";
31
31
  /**
32
32
  * Ensure a launchable runner, acquiring `@stigmer/runner-slim` on demand if no
@@ -85,11 +85,8 @@ export function acquireRunner(opts = {}) {
85
85
  const entryPath = join(installDir, "node_modules", "@stigmer", "runner-slim", "main.js");
86
86
  if (!existsSync(entryPath)) {
87
87
  log.info(`acquiring ${SLIM_PACKAGE}`, { version, dir: installDir });
88
- mkdirSync(installDir, { recursive: true });
89
- // A stable package.json root makes the install deterministic and records the
90
- // pinned dependency rather than letting npm synthesize an ad-hoc root.
91
- writeFileSync(join(installDir, "package.json"), `${JSON.stringify({ name: "stigmer-runtime", private: true, version: "0.0.0" }, null, 2)}\n`);
92
- const install = opts.install ?? installRunnerSlim;
88
+ ensureRuntimesRoot(installDir);
89
+ const install = opts.install ?? npmInstallIntoRuntimes;
93
90
  install(installDir, `${SLIM_PACKAGE}@${version}`);
94
91
  }
95
92
  if (!existsSync(entryPath)) {
@@ -100,24 +97,6 @@ export function acquireRunner(opts = {}) {
100
97
  }
101
98
  return { nodeBin: node(), entryPath, appDir: dirname(entryPath) };
102
99
  }
103
- // Install the slim package (plus its platform-native optional dependency) into an
104
- // isolated prefix. `--omit=dev` drops devDependencies while keeping the optional
105
- // native package npm selects by os/cpu; output is inherited so the user sees the
106
- // one-time download progress.
107
- function installRunnerSlim(installDir, spec) {
108
- try {
109
- execFileSync("npm", ["install", spec, "--prefix", installDir, "--omit=dev", "--no-audit", "--no-fund"], {
110
- stdio: "inherit",
111
- });
112
- }
113
- catch (err) {
114
- throw new CliExitError(`failed to install ${spec}`, ExitCode.General, [
115
- `Command: npm install ${spec} --prefix ${installDir}`,
116
- "Ensure npm is on PATH and the network is reachable.",
117
- String(err),
118
- ]);
119
- }
120
- }
121
100
  function resolveBuiltRunner(appDir, node) {
122
101
  const entryPath = join(appDir, "dist", "main.js");
123
102
  if (!existsSync(entryPath)) {
@@ -129,12 +108,6 @@ function resolveBuiltRunner(appDir, node) {
129
108
  }
130
109
  return { nodeBin: node(), entryPath, appDir };
131
110
  }
132
- // A source build reports "0.0.0-dev" and the dev npm channel stamps "<v>-dev.<stamp>"
133
- // versions; neither publishes a matching @stigmer/runner-slim, so they are not
134
- // acquirable. Release and rc/next versions are.
135
- function isAcquirableRelease(version) {
136
- return !version.includes("-dev");
137
- }
138
111
  function hasPackageJson(dir) {
139
112
  return existsSync(join(dir, "package.json"));
140
113
  }
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot":"","sources":["../../../src/local/runtime/runner.ts"],"names":[],"mappings":"AAAA,8DAA8D;AAC9D,EAAE;AACF,g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,SAAS,CAAC,EAAE,CAAC;AACpE,CAAC;AAED,SAAS,kBAAkB,CAAC,MAAc,EAAE,IAAkB;IAC5D,MAAM,SAAS,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC;IAClD,IAAI,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;QAC3B,MAAM,IAAI,YAAY,CAAC,qBAAqB,SAAS,aAAa,EAAE,QAAQ,CAAC,OAAO,EAAE;YACpF,qFAAqF;YACrF,2EAA2E;YAC3E,kDAAkD;SACnD,CAAC,CAAC;IACL,CAAC;IACD,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC;AAED,SAAS,cAAc,CAAC,GAAW;IACjC,OAAO,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC,CAAC;AAC/C,CAAC;AAED,8EAA8E;AAC9E,SAAS,QAAQ;IACf,IAAI,GAAG,GAAG,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/B,IAAI,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,cAAc,CAAC,CAAC;YAAE,OAAO,GAAG,CAAC;QACvF,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;QAC5B,IAAI,MAAM,KAAK,GAAG;YAAE,MAAM;QAC1B,GAAG,GAAG,MAAM,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,13 @@
1
+ /** The install implementation, injectable for tests. */
2
+ export type NpmInstall = (installDir: string, spec: string) => void;
3
+ /**
4
+ * Ensure the per-version install root exists with a stable package.json.
5
+ * A stable root makes installs deterministic and records the pinned
6
+ * dependencies rather than letting npm synthesize an ad-hoc root; both the
7
+ * runner and the server packages install into this one root, so the file is
8
+ * written once and shared.
9
+ */
10
+ export declare function ensureRuntimesRoot(installDir: string): void;
11
+ export declare function npmInstallIntoRuntimes(installDir: string, spec: string): void;
12
+ export declare function isAcquirableRelease(version: string): boolean;
13
+ //# sourceMappingURL=runtimes-install.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimes-install.d.ts","sourceRoot":"","sources":["../../../src/local/runtime/runtimes-install.ts"],"names":[],"mappings":"AAYA,wDAAwD;AACxD,MAAM,MAAM,UAAU,GAAG,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;AAEpE;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,IAAI,CAS3D;AAMD,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,IAAI,CA2B7E;AAKD,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAE5D"}
@@ -0,0 +1,60 @@
1
+ // Shared npm-install mechanics for on-demand-acquired runtime packages
2
+ // (~/.stigmer/runtimes/<version>/). Extracted when the TS server became the
3
+ // second consumer (D4 #24) — the runner and the server acquire different
4
+ // packages into the SAME per-version install root, so the root bootstrap and
5
+ // the install invocation must not drift between them.
6
+ import { execFileSync } from "node:child_process";
7
+ import { existsSync, mkdirSync, writeFileSync } from "node:fs";
8
+ import { join } from "node:path";
9
+ import { CliExitError } from "../../errors/cli-exit-error.js";
10
+ import { ExitCode } from "../../errors/exit-codes.js";
11
+ /**
12
+ * Ensure the per-version install root exists with a stable package.json.
13
+ * A stable root makes installs deterministic and records the pinned
14
+ * dependencies rather than letting npm synthesize an ad-hoc root; both the
15
+ * runner and the server packages install into this one root, so the file is
16
+ * written once and shared.
17
+ */
18
+ export function ensureRuntimesRoot(installDir) {
19
+ mkdirSync(installDir, { recursive: true });
20
+ const rootManifest = join(installDir, "package.json");
21
+ if (!existsSync(rootManifest)) {
22
+ writeFileSync(rootManifest, `${JSON.stringify({ name: "stigmer-runtime", private: true, version: "0.0.0" }, null, 2)}\n`);
23
+ }
24
+ }
25
+ // Install a package (plus its platform-native optional dependency) into an
26
+ // isolated prefix. `--omit=dev` drops devDependencies while keeping the
27
+ // optional native package npm selects by os/cpu; output is inherited so the
28
+ // user sees the one-time download progress.
29
+ export function npmInstallIntoRuntimes(installDir, spec) {
30
+ try {
31
+ execFileSync("npm", [
32
+ "install",
33
+ spec,
34
+ "--prefix",
35
+ installDir,
36
+ "--omit=dev",
37
+ "--no-audit",
38
+ "--no-fund",
39
+ ], {
40
+ stdio: "inherit",
41
+ });
42
+ }
43
+ catch (err) {
44
+ throw new CliExitError(`failed to install ${spec}`, ExitCode.General, [
45
+ `Command: npm install ${spec} --prefix ${installDir}`,
46
+ "Ensure npm is on PATH and the network is reachable.",
47
+ "If npm reported EBADENGINE, this Node line is outside the package's",
48
+ "supported range. If a previous install was interrupted, remove",
49
+ `${installDir} and retry.`,
50
+ String(err),
51
+ ]);
52
+ }
53
+ }
54
+ // A source build reports "0.0.0-dev" and the dev npm channel stamps
55
+ // "<v>-dev.<stamp>" versions; neither publishes matching runtime packages,
56
+ // so they are not acquirable. Release and rc/next versions are.
57
+ export function isAcquirableRelease(version) {
58
+ return !version.includes("-dev");
59
+ }
60
+ //# sourceMappingURL=runtimes-install.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runtimes-install.js","sourceRoot":"","sources":["../../../src/local/runtime/runtimes-install.ts"],"names":[],"mappings":"AAAA,uEAAuE;AACvE,4EAA4E;AAC5E,yEAAyE;AACzE,6EAA6E;AAC7E,sDAAsD;AAEtD,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;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AC3E,gEAAgE;AAChE,MAAM,UAAU,mBAAmB,CAAC,OAAe;IACjD,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;AACnC,CAAC"}
@@ -1,39 +1,35 @@
1
- /**
2
- * Find an already-present `stigmer-server` binary, or null. Pure: never
3
- * downloads. `home` is injectable for tests.
4
- */
5
- export declare function resolveServerBinary(home?: string): string | null;
1
+ import type { ServerLaunch } from "../daemon/env.js";
2
+ import { type NpmInstall } from "./runtimes-install.js";
6
3
  export interface EnsureServerOptions {
7
4
  home?: string;
8
- /** Release version to download if needed (defaults to the CLI's own version). */
5
+ /** Release version of the slim server to acquire (defaults to the CLI version). */
9
6
  version?: string;
10
- /** Override the fetch implementation (tests). */
11
- fetchImpl?: typeof fetch;
7
+ /** Node resolver (injectable for tests). */
8
+ node?: () => string;
9
+ /** npm install implementation (injectable for tests). */
10
+ install?: NpmInstall;
12
11
  }
13
12
  /**
14
- * Ensure a `stigmer-server` binary is available, returning its path. Reuses an
15
- * existing binary if found; otherwise downloads the pinned release asset into
16
- * ~/.stigmer/bin (checksum-verified). Throws actionable guidance when no binary
17
- * exists and a download is not possible (a source/dev build, or an unsupported
18
- * platform).
13
+ * Resolve what the daemon launches as `stigmer-server`: the explicit
14
+ * STIGMER_SERVER_DIR override, then the repo tree, then acquiring the
15
+ * published slim package. Throws actionable guidance on a missing build, an
16
+ * invalid override, or a non-release CLI build with nothing local.
19
17
  */
20
- export declare function ensureServerBinary(opts?: EnsureServerOptions): Promise<string>;
21
- export interface ServerDownloadTarget {
22
- /** Release version, e.g. "0.5.0" or "0.5.0-rc.1" (with or without a leading "v"). */
23
- version: string;
24
- /** Absolute path to write the extracted `stigmer-server` binary to. */
25
- binPath: string;
26
- /** Node platform (defaults to process.platform). */
27
- platform?: NodeJS.Platform;
28
- /** Node arch (defaults to process.arch). */
29
- arch?: string;
30
- /** Override the fetch implementation (tests). */
31
- fetchImpl?: typeof fetch;
32
- }
18
+ export declare function ensureServer(opts?: EnsureServerOptions): ServerLaunch;
19
+ /**
20
+ * Resolve a repo-tree TS server (dev) or an explicit STIGMER_SERVER_DIR, or
21
+ * null when neither is present (the caller then acquires the slim package).
22
+ * Throws when an override is set but invalid, or when a found server is not
23
+ * built — both are actionable user-facing conditions, not a reason to
24
+ * silently download. `node` is injectable for tests.
25
+ */
26
+ export declare function resolveServerTs(node?: () => string): ServerLaunch | null;
33
27
  /**
34
- * Download, checksum-verify, and install the standalone `stigmer-server` release
35
- * asset. Throws a {@link CliExitError} on an unsupported platform or any
36
- * network/checksum/extraction failure.
28
+ * Acquire the published `@stigmer/server-slim@<version>` into
29
+ * ~/.stigmer/runtimes/<version>/ (idempotent: reuses a prior install; shares
30
+ * the install root with the runner's package) and resolve its `main.js`
31
+ * entry. The version is pinned to the CLI's own version so the server's
32
+ * protos and behavior stay in lockstep with the CLI and the runner.
37
33
  */
38
- export declare function downloadServerBinary(target: ServerDownloadTarget): Promise<void>;
34
+ export declare function acquireServer(opts?: EnsureServerOptions): ServerLaunch;
39
35
  //# sourceMappingURL=server.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.d.ts","sourceRoot":"","sources":["../../../src/local/runtime/server.ts"],"names":[],"mappings":"AAsCA;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,GAAG,IAAI,CAK3E;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,iFAAiF;IACjF,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iDAAiD;IACjD,SAAS,CAAC,EAAE,OAAO,KAAK,CAAC;CAC1B;AAED;;;;;;GAMG;AACH,wBAAsB,kBAAkB,CAAC,IAAI,GAAE,mBAAwB,GAAG,OAAO,CAAC,MAAM,CAAC,CAaxF;AAED,MAAM,WAAW,oBAAoB;IACnC,qFAAqF;IACrF,OAAO,EAAE,MAAM,CAAC;IAChB,uEAAuE;IACvE,OAAO,EAAE,M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