create-snipara 2.2.14 → 2.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/index.js CHANGED
@@ -14,7 +14,7 @@ import { homedir as homedir2 } from "os";
14
14
  // package.json
15
15
  var package_default = {
16
16
  name: "create-snipara",
17
- version: "2.2.14",
17
+ version: "2.2.16",
18
18
  description: "Onboard Snipara Cloud or self-hosted MCP with an automatic project-grounded proof of value",
19
19
  main: "dist/index.js",
20
20
  type: "module",
@@ -219,9 +219,9 @@ function parseManagedToolchainManifest(value) {
219
219
 
220
220
  // src/managed-versions.json
221
221
  var managed_versions_default = {
222
- companion: "6.0.0",
222
+ companion: "7.0.0",
223
223
  orchestrator: "2.1.0",
224
- sandbox: "3.2.0"
224
+ sandbox: "3.3.0"
225
225
  };
226
226
 
227
227
  // src/managed-toolchain.ts
@@ -230,13 +230,16 @@ function assertManagedRuntimeVersions(nodeVersion, pythonVersion) {
230
230
  const node = /^v?(\d+)\.\d+\.\d+(?:[-+].*)?$/.exec(nodeVersion);
231
231
  const python = /^Python (\d+)\.(\d+)\.\d+(?:[a-z0-9.+-]*)?$/i.exec(pythonVersion.trim());
232
232
  if (!node || Number(node[1]) < 18 || !python || Number(python[1]) !== 3 || Number(python[2]) < 10)
233
- throw new Error("Local work requires existing Node.js 18+ and Python 3.10+. Update your system runtimes and retry; no operating-system runtime was installed");
233
+ throw new Error(
234
+ "Local work requires existing Node.js 18+ and Python 3.10+. Update your system runtimes and retry; no operating-system runtime was installed"
235
+ );
234
236
  }
235
237
  var ManagedInstallerCleanupError = class extends Error {
236
238
  };
237
239
  var sha = (bytes2) => createHash5("sha256").update(bytes2).digest("hex");
238
240
  var uid = () => {
239
- if (!process.getuid || process.platform === "win32") throw new Error("Managed local work requires macOS or Linux");
241
+ if (!process.getuid || process.platform === "win32")
242
+ throw new Error("Managed local work requires macOS or Linux");
240
243
  return process.getuid();
241
244
  };
242
245
  function exists(file) {
@@ -268,7 +271,10 @@ function location(options) {
268
271
  }
269
272
  function bytes(file, limit = 65536) {
270
273
  owned(file, false);
271
- const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK);
274
+ const fd = fs.openSync(
275
+ file,
276
+ fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK
277
+ );
272
278
  try {
273
279
  const info = fs.fstatSync(fd);
274
280
  if (!info.isFile() || info.uid !== uid() || info.size > limit || info.mode & 18)
@@ -286,7 +292,8 @@ function writePrivate(file, value) {
286
292
  function protectedCommand(root, command) {
287
293
  const real = fs.realpathSync(command);
288
294
  if (!real.startsWith(root + path.sep)) throw new Error("Managed command escapes its bundle");
289
- for (let current = path.dirname(real); current !== root; current = path.dirname(current)) owned(current, true);
295
+ for (let current = path.dirname(real); current !== root; current = path.dirname(current))
296
+ owned(current, true);
290
297
  const info = owned(real, false);
291
298
  if (!(info.mode & 73)) throw new Error("Managed command is not executable");
292
299
  return real;
@@ -304,7 +311,8 @@ function readManagedManifest(file, options = {}) {
304
311
  throw new Error("Managed manifest is outside the private installation");
305
312
  const root = path.dirname(target);
306
313
  owned(root, true, true);
307
- if (fs.realpathSync(root) !== root) throw new Error("Managed bundle cannot use linked directories");
314
+ if (fs.realpathSync(root) !== root)
315
+ throw new Error("Managed bundle cannot use linked directories");
308
316
  owned(target, false, true);
309
317
  const manifest = parseManagedToolchainManifest(JSON.parse(bytes(target).toString("utf8")));
310
318
  if (manifest.root !== root || manifest.bundleId !== path.basename(root) || !manifest.capabilities.includes("validation") || !manifest.capabilities.includes("coordination"))
@@ -340,7 +348,11 @@ function verifyRetainedCompanionBootstrap(command, active, options = {}) {
340
348
  function managedToolchainStatus(options = {}) {
341
349
  const active = path.join(location(options), "active.json");
342
350
  if (!exists(active)) return { status: "absent", manifest: null, manifestPath: null };
343
- return { status: "ready", manifest: readManagedManifest(active, options), manifestPath: fs.realpathSync(active) };
351
+ return {
352
+ status: "ready",
353
+ manifest: readManagedManifest(active, options),
354
+ manifestPath: fs.realpathSync(active)
355
+ };
344
356
  }
345
357
  function program(name) {
346
358
  for (const directory of (process.env.PATH ?? "").split(path.delimiter)) {
@@ -356,7 +368,13 @@ function program(name) {
356
368
  }
357
369
  function cleanEnvironment(root) {
358
370
  return {
359
- PATH: [path.dirname(process.execPath), "/usr/local/bin", "/opt/homebrew/bin", "/usr/bin", "/bin"].join(path.delimiter),
371
+ PATH: [
372
+ path.dirname(process.execPath),
373
+ "/usr/local/bin",
374
+ "/opt/homebrew/bin",
375
+ "/usr/bin",
376
+ "/bin"
377
+ ].join(path.delimiter),
360
378
  HOME: path.join(root, "home"),
361
379
  TMPDIR: path.join(root, "tmp"),
362
380
  LANG: "C.UTF-8",
@@ -366,8 +384,10 @@ function cleanEnvironment(root) {
366
384
  PIP_DISABLE_PIP_VERSION_CHECK: "1",
367
385
  PIP_NO_INPUT: "1",
368
386
  PIP_CONFIG_FILE: "/dev/null",
369
- NPM_CONFIG_USERCONFIG: "/dev/null",
370
- NPM_CONFIG_GLOBALCONFIG: "/dev/null",
387
+ // Two distinct absent files inside the private bundle: npm reads an absent config as empty,
388
+ // and refuses to start when the user and global configs are the same path (as two /dev/null were).
389
+ NPM_CONFIG_USERCONFIG: path.join(root, "home", ".npmrc"),
390
+ NPM_CONFIG_GLOBALCONFIG: path.join(root, "home", ".npmrc-global"),
371
391
  NPM_CONFIG_IGNORE_SCRIPTS: "true",
372
392
  NPM_CONFIG_AUDIT: "false",
373
393
  NPM_CONFIG_FUND: "false",
@@ -408,11 +428,18 @@ var runManagedInstaller = async (input) => new Promise((resolve2, reject) => {
408
428
  if (!stopped) {
409
429
  stopped = true;
410
430
  cleanup();
411
- reject(new ManagedInstallerCleanupError("Managed installer cleanup could not be observed within its deadline; installation lock retained"));
431
+ reject(
432
+ new ManagedInstallerCleanupError(
433
+ "Managed installer cleanup could not be observed within its deadline; installation lock retained"
434
+ )
435
+ );
412
436
  }
413
437
  }, 2e3);
414
438
  };
415
- const timer = setTimeout(() => stop("Managed preparation exceeded its bounded deadline"), input.timeoutMs);
439
+ const timer = setTimeout(
440
+ () => stop("Managed preparation exceeded its bounded deadline"),
441
+ input.timeoutMs
442
+ );
416
443
  process.on("SIGINT", interrupted);
417
444
  process.on("SIGTERM", interrupted);
418
445
  process.on("exit", exiting);
@@ -437,7 +464,10 @@ var runManagedInstaller = async (input) => new Promise((resolve2, reject) => {
437
464
  if (stopped) return;
438
465
  stopped = true;
439
466
  if (stopReason) reject(new Error(stopReason));
440
- else if (code !== 0) reject(new Error("Managed preparation step failed; the previous active bundle was preserved"));
467
+ else if (code !== 0)
468
+ reject(
469
+ new Error("Managed preparation step failed; the previous active bundle was preserved")
470
+ );
441
471
  else resolve2({ stdout: output });
442
472
  });
443
473
  });
@@ -445,7 +475,8 @@ function switchPointer(base, name, target) {
445
475
  const current = path.join(base, name);
446
476
  if (exists(current)) {
447
477
  const stat = fs.lstatSync(current);
448
- if (!stat.isSymbolicLink() || stat.uid !== uid()) throw new Error("Managed active pointer must be an owned symlink");
478
+ if (!stat.isSymbolicLink() || stat.uid !== uid())
479
+ throw new Error("Managed active pointer must be an owned symlink");
449
480
  }
450
481
  const temporary = path.join(base, `.pointer-${randomUUID2()}`);
451
482
  fs.symlinkSync(target, temporary);
@@ -482,19 +513,25 @@ async function prepareManagedToolchain(options = {}) {
482
513
  let recovery = null;
483
514
  const preserveInvalidSelection = () => {
484
515
  const pointer = fs.lstatSync(active);
485
- if (!pointer.isSymbolicLink() || pointer.uid !== uid()) throw new Error("Repair refuses a foreign or non-symlink active pointer");
516
+ if (!pointer.isSymbolicLink() || pointer.uid !== uid())
517
+ throw new Error("Repair refuses a foreign or non-symlink active pointer");
486
518
  const target = path.resolve(base, fs.readlinkSync(active));
487
519
  if (path.basename(target) !== "toolchain.json" || path.dirname(path.dirname(target)) !== base)
488
520
  throw new Error("Repair refuses an active pointer outside the owned installation");
489
521
  const root2 = path.dirname(target);
490
522
  owned(root2, true, true);
491
- if (fs.realpathSync(root2) !== root2) throw new Error("Repair refuses a linked bundle directory");
523
+ if (fs.realpathSync(root2) !== root2)
524
+ throw new Error("Repair refuses a linked bundle directory");
492
525
  let previousHash = null;
493
526
  if (exists(target)) {
494
527
  owned(target, false, true);
495
528
  previousHash = sha(bytes(target));
496
529
  }
497
- return { priorManifestPath: target, priorManifestSha256: previousHash, priorSelection: "invalid_owned_bundle" };
530
+ return {
531
+ priorManifestPath: target,
532
+ priorManifestSha256: previousHash,
533
+ priorSelection: "invalid_owned_bundle"
534
+ };
498
535
  };
499
536
  if (exists(active)) {
500
537
  try {
@@ -510,13 +547,24 @@ async function prepareManagedToolchain(options = {}) {
510
547
  for (const [name, component] of Object.entries(manifest.components)) {
511
548
  const command = name === "companion" ? process.execPath : component.command;
512
549
  const args = name === "companion" ? [component.command, "--version"] : ["--version"];
513
- const observed = await runner({ command, args, cwd: manifest.root, env: cleanEnvironment(manifest.root), timeoutMs: 15e3 });
514
- if (!new RegExp(`^(?:snipara-${name}[ ,]+)?${component.version.replaceAll(".", "\\.")}$`, "i").test(observed.stdout.trim()))
550
+ const observed = await runner({
551
+ command,
552
+ args,
553
+ cwd: manifest.root,
554
+ env: cleanEnvironment(manifest.root),
555
+ timeoutMs: 15e3
556
+ });
557
+ if (!new RegExp(
558
+ `^(?:snipara-${name}[ ,]+)?${component.version.replaceAll(".", "\\.")}$`,
559
+ "i"
560
+ ).test(observed.stdout.trim()))
515
561
  throw new Error("Managed component version handshake did not match the pinned bundle");
516
562
  }
517
563
  }
518
564
  const selectedPrior = prior;
519
- if (selectedPrior && Object.entries(MANAGED_VERSIONS).every(([name, version]) => selectedPrior.components[name].version === version)) {
565
+ if (selectedPrior && Object.entries(MANAGED_VERSIONS).every(
566
+ ([name, version]) => selectedPrior.components[name].version === version
567
+ )) {
520
568
  try {
521
569
  await handshake(selectedPrior);
522
570
  readManagedManifest(active, options);
@@ -530,27 +578,64 @@ async function prepareManagedToolchain(options = {}) {
530
578
  const bundleId = `bundle-${MANAGED_VERSIONS.companion}-${MANAGED_VERSIONS.orchestrator}-${MANAGED_VERSIONS.sandbox}-${randomUUID2()}`;
531
579
  const root = path.join(base, bundleId);
532
580
  fs.mkdirSync(root, { mode: 448 });
533
- for (const directory of ["home", "tmp"]) fs.mkdirSync(path.join(root, directory), { mode: 448 });
581
+ for (const directory of ["home", "tmp"])
582
+ fs.mkdirSync(path.join(root, directory), { mode: 448 });
534
583
  const env = cleanEnvironment(root);
535
584
  const run = (command, args, timeoutMs = 3e5) => runner({ command, args, cwd: root, env, timeoutMs });
536
585
  try {
537
- if (recovery) writePrivate(path.join(root, "recovery.json"), { schemaVersion: "snipara.toolchain_recovery.v1", ...recovery, originalBundlePreserved: true });
586
+ if (recovery)
587
+ writePrivate(path.join(root, "recovery.json"), {
588
+ schemaVersion: "snipara.toolchain_recovery.v1",
589
+ ...recovery,
590
+ originalBundlePreserved: true
591
+ });
538
592
  const python = options.python ?? program("python3"), npm = options.npm ?? program("npm");
539
- if (![python, npm].every((value) => path.isAbsolute(value))) throw new Error("Managed package managers need absolute executable paths");
593
+ if (![python, npm].every((value) => path.isAbsolute(value)))
594
+ throw new Error("Managed package managers need absolute executable paths");
540
595
  const runtime = await run(python, ["--version"], 1e4);
541
596
  assertManagedRuntimeVersions(process.versions.node, runtime.stdout);
542
597
  const venv = path.join(root, "python"), prefix = path.join(root, "node");
543
598
  await run(python, ["-I", "-m", "venv", venv], 6e4);
544
- await run(path.join(venv, "bin/python"), ["-I", "-m", "pip", "install", "--no-input", "--disable-pip-version-check", "snipara-sandbox[validation,mcp]==" + MANAGED_VERSIONS.sandbox, "snipara-orchestrator==" + MANAGED_VERSIONS.orchestrator]);
545
- await run(npm, ["install", "--prefix", prefix, "--ignore-scripts", "--no-audit", "--no-fund", "--save-exact", "snipara-companion@" + MANAGED_VERSIONS.companion]);
599
+ await run(path.join(venv, "bin/python"), [
600
+ "-I",
601
+ "-m",
602
+ "pip",
603
+ "install",
604
+ "--no-input",
605
+ "--disable-pip-version-check",
606
+ "snipara-sandbox[validation,mcp]==" + MANAGED_VERSIONS.sandbox,
607
+ "snipara-orchestrator==" + MANAGED_VERSIONS.orchestrator
608
+ ]);
609
+ await run(npm, [
610
+ "install",
611
+ "--prefix",
612
+ prefix,
613
+ "--ignore-scripts",
614
+ "--no-audit",
615
+ "--no-fund",
616
+ "--save-exact",
617
+ "snipara-companion@" + MANAGED_VERSIONS.companion
618
+ ]);
546
619
  const manifest = {
547
620
  schemaVersion: "snipara.toolchain.v1",
548
621
  bundleId,
549
622
  root,
550
623
  components: {
551
- companion: { version: MANAGED_VERSIONS.companion, command: fs.realpathSync(path.join(prefix, "node_modules/.bin/snipara-companion")), sha256: "" },
552
- orchestrator: { version: MANAGED_VERSIONS.orchestrator, command: path.join(venv, "bin/snipara-orchestrator"), sha256: "" },
553
- sandbox: { version: MANAGED_VERSIONS.sandbox, command: path.join(venv, "bin/snipara-sandbox"), sha256: "" }
624
+ companion: {
625
+ version: MANAGED_VERSIONS.companion,
626
+ command: fs.realpathSync(path.join(prefix, "node_modules/.bin/snipara-companion")),
627
+ sha256: ""
628
+ },
629
+ orchestrator: {
630
+ version: MANAGED_VERSIONS.orchestrator,
631
+ command: path.join(venv, "bin/snipara-orchestrator"),
632
+ sha256: ""
633
+ },
634
+ sandbox: {
635
+ version: MANAGED_VERSIONS.sandbox,
636
+ command: path.join(venv, "bin/snipara-sandbox"),
637
+ sha256: ""
638
+ }
554
639
  },
555
640
  contracts: { taskReference: 1, validation: 1 },
556
641
  capabilities: ["validation", "coordination"]
@@ -563,12 +648,24 @@ async function prepareManagedToolchain(options = {}) {
563
648
  writePrivate(manifestFile, parseManagedToolchainManifest(manifest));
564
649
  await handshake(manifest);
565
650
  readManagedManifest(manifestFile, options);
566
- writePrivate(path.join(root, "prepared.json"), { schemaVersion: "snipara.toolchain_preparation.v1", status: "prepared", manifestSha256: sha(bytes(manifestFile)), observedAt: (/* @__PURE__ */ new Date()).toISOString(), activationObserved: false });
651
+ writePrivate(path.join(root, "prepared.json"), {
652
+ schemaVersion: "snipara.toolchain_preparation.v1",
653
+ status: "prepared",
654
+ manifestSha256: sha(bytes(manifestFile)),
655
+ observedAt: (/* @__PURE__ */ new Date()).toISOString(),
656
+ activationObserved: false
657
+ });
567
658
  if (prior) switchPointer(base, "previous.json", path.join(prior.root, "toolchain.json"));
568
659
  switchPointer(base, "active.json", manifestFile);
569
660
  return manifest;
570
661
  } catch (error) {
571
- writePrivate(path.join(root, "failed.json"), { schemaVersion: "snipara.toolchain_preparation.v1", status: "failed", observedAt: (/* @__PURE__ */ new Date()).toISOString(), reason: "preparation_or_identity_check_failed", priorActivePreserved: true });
662
+ writePrivate(path.join(root, "failed.json"), {
663
+ schemaVersion: "snipara.toolchain_preparation.v1",
664
+ status: "failed",
665
+ observedAt: (/* @__PURE__ */ new Date()).toISOString(),
666
+ reason: "preparation_or_identity_check_failed",
667
+ priorActivePreserved: true
668
+ });
572
669
  throw error;
573
670
  }
574
671
  });
@@ -126,9 +126,9 @@ function parseManagedToolchainManifest(value) {
126
126
 
127
127
  // src/managed-versions.json
128
128
  var managed_versions_default = {
129
- companion: "6.0.0",
129
+ companion: "7.0.0",
130
130
  orchestrator: "2.1.0",
131
- sandbox: "3.2.0"
131
+ sandbox: "3.3.0"
132
132
  };
133
133
 
134
134
  // src/managed-toolchain.ts
@@ -137,13 +137,16 @@ function assertManagedRuntimeVersions(nodeVersion, pythonVersion) {
137
137
  const node = /^v?(\d+)\.\d+\.\d+(?:[-+].*)?$/.exec(nodeVersion);
138
138
  const python = /^Python (\d+)\.(\d+)\.\d+(?:[a-z0-9.+-]*)?$/i.exec(pythonVersion.trim());
139
139
  if (!node || Number(node[1]) < 18 || !python || Number(python[1]) !== 3 || Number(python[2]) < 10)
140
- throw new Error("Local work requires existing Node.js 18+ and Python 3.10+. Update your system runtimes and retry; no operating-system runtime was installed");
140
+ throw new Error(
141
+ "Local work requires existing Node.js 18+ and Python 3.10+. Update your system runtimes and retry; no operating-system runtime was installed"
142
+ );
141
143
  }
142
144
  var ManagedInstallerCleanupError = class extends Error {
143
145
  };
144
146
  var sha = (bytes2) => createHash5("sha256").update(bytes2).digest("hex");
145
147
  var uid = () => {
146
- if (!process.getuid || process.platform === "win32") throw new Error("Managed local work requires macOS or Linux");
148
+ if (!process.getuid || process.platform === "win32")
149
+ throw new Error("Managed local work requires macOS or Linux");
147
150
  return process.getuid();
148
151
  };
149
152
  function exists(file) {
@@ -175,7 +178,10 @@ function location(options) {
175
178
  }
176
179
  function bytes(file, limit = 65536) {
177
180
  owned(file, false);
178
- const fd = fs.openSync(file, fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK);
181
+ const fd = fs.openSync(
182
+ file,
183
+ fs.constants.O_RDONLY | fs.constants.O_NOFOLLOW | fs.constants.O_NONBLOCK
184
+ );
179
185
  try {
180
186
  const info = fs.fstatSync(fd);
181
187
  if (!info.isFile() || info.uid !== uid() || info.size > limit || info.mode & 18)
@@ -193,7 +199,8 @@ function writePrivate(file, value) {
193
199
  function protectedCommand(root, command) {
194
200
  const real = fs.realpathSync(command);
195
201
  if (!real.startsWith(root + path.sep)) throw new Error("Managed command escapes its bundle");
196
- for (let current = path.dirname(real); current !== root; current = path.dirname(current)) owned(current, true);
202
+ for (let current = path.dirname(real); current !== root; current = path.dirname(current))
203
+ owned(current, true);
197
204
  const info = owned(real, false);
198
205
  if (!(info.mode & 73)) throw new Error("Managed command is not executable");
199
206
  return real;
@@ -211,7 +218,8 @@ function readManagedManifest(file, options = {}) {
211
218
  throw new Error("Managed manifest is outside the private installation");
212
219
  const root = path.dirname(target);
213
220
  owned(root, true, true);
214
- if (fs.realpathSync(root) !== root) throw new Error("Managed bundle cannot use linked directories");
221
+ if (fs.realpathSync(root) !== root)
222
+ throw new Error("Managed bundle cannot use linked directories");
215
223
  owned(target, false, true);
216
224
  const manifest = parseManagedToolchainManifest(JSON.parse(bytes(target).toString("utf8")));
217
225
  if (manifest.root !== root || manifest.bundleId !== path.basename(root) || !manifest.capabilities.includes("validation") || !manifest.capabilities.includes("coordination"))
@@ -247,7 +255,11 @@ function verifyRetainedCompanionBootstrap(command, active, options = {}) {
247
255
  function managedToolchainStatus(options = {}) {
248
256
  const active = path.join(location(options), "active.json");
249
257
  if (!exists(active)) return { status: "absent", manifest: null, manifestPath: null };
250
- return { status: "ready", manifest: readManagedManifest(active, options), manifestPath: fs.realpathSync(active) };
258
+ return {
259
+ status: "ready",
260
+ manifest: readManagedManifest(active, options),
261
+ manifestPath: fs.realpathSync(active)
262
+ };
251
263
  }
252
264
  function program(name) {
253
265
  for (const directory of (process.env.PATH ?? "").split(path.delimiter)) {
@@ -263,7 +275,13 @@ function program(name) {
263
275
  }
264
276
  function cleanEnvironment(root) {
265
277
  return {
266
- PATH: [path.dirname(process.execPath), "/usr/local/bin", "/opt/homebrew/bin", "/usr/bin", "/bin"].join(path.delimiter),
278
+ PATH: [
279
+ path.dirname(process.execPath),
280
+ "/usr/local/bin",
281
+ "/opt/homebrew/bin",
282
+ "/usr/bin",
283
+ "/bin"
284
+ ].join(path.delimiter),
267
285
  HOME: path.join(root, "home"),
268
286
  TMPDIR: path.join(root, "tmp"),
269
287
  LANG: "C.UTF-8",
@@ -273,8 +291,10 @@ function cleanEnvironment(root) {
273
291
  PIP_DISABLE_PIP_VERSION_CHECK: "1",
274
292
  PIP_NO_INPUT: "1",
275
293
  PIP_CONFIG_FILE: "/dev/null",
276
- NPM_CONFIG_USERCONFIG: "/dev/null",
277
- NPM_CONFIG_GLOBALCONFIG: "/dev/null",
294
+ // Two distinct absent files inside the private bundle: npm reads an absent config as empty,
295
+ // and refuses to start when the user and global configs are the same path (as two /dev/null were).
296
+ NPM_CONFIG_USERCONFIG: path.join(root, "home", ".npmrc"),
297
+ NPM_CONFIG_GLOBALCONFIG: path.join(root, "home", ".npmrc-global"),
278
298
  NPM_CONFIG_IGNORE_SCRIPTS: "true",
279
299
  NPM_CONFIG_AUDIT: "false",
280
300
  NPM_CONFIG_FUND: "false",
@@ -315,11 +335,18 @@ var runManagedInstaller = async (input) => new Promise((resolve, reject) => {
315
335
  if (!stopped) {
316
336
  stopped = true;
317
337
  cleanup();
318
- reject(new ManagedInstallerCleanupError("Managed installer cleanup could not be observed within its deadline; installation lock retained"));
338
+ reject(
339
+ new ManagedInstallerCleanupError(
340
+ "Managed installer cleanup could not be observed within its deadline; installation lock retained"
341
+ )
342
+ );
319
343
  }
320
344
  }, 2e3);
321
345
  };
322
- const timer = setTimeout(() => stop("Managed preparation exceeded its bounded deadline"), input.timeoutMs);
346
+ const timer = setTimeout(
347
+ () => stop("Managed preparation exceeded its bounded deadline"),
348
+ input.timeoutMs
349
+ );
323
350
  process.on("SIGINT", interrupted);
324
351
  process.on("SIGTERM", interrupted);
325
352
  process.on("exit", exiting);
@@ -344,7 +371,10 @@ var runManagedInstaller = async (input) => new Promise((resolve, reject) => {
344
371
  if (stopped) return;
345
372
  stopped = true;
346
373
  if (stopReason) reject(new Error(stopReason));
347
- else if (code !== 0) reject(new Error("Managed preparation step failed; the previous active bundle was preserved"));
374
+ else if (code !== 0)
375
+ reject(
376
+ new Error("Managed preparation step failed; the previous active bundle was preserved")
377
+ );
348
378
  else resolve({ stdout: output });
349
379
  });
350
380
  });
@@ -352,7 +382,8 @@ function switchPointer(base, name, target) {
352
382
  const current = path.join(base, name);
353
383
  if (exists(current)) {
354
384
  const stat = fs.lstatSync(current);
355
- if (!stat.isSymbolicLink() || stat.uid !== uid()) throw new Error("Managed active pointer must be an owned symlink");
385
+ if (!stat.isSymbolicLink() || stat.uid !== uid())
386
+ throw new Error("Managed active pointer must be an owned symlink");
356
387
  }
357
388
  const temporary = path.join(base, `.pointer-${randomUUID2()}`);
358
389
  fs.symlinkSync(target, temporary);
@@ -389,19 +420,25 @@ async function prepareManagedToolchain(options = {}) {
389
420
  let recovery = null;
390
421
  const preserveInvalidSelection = () => {
391
422
  const pointer = fs.lstatSync(active);
392
- if (!pointer.isSymbolicLink() || pointer.uid !== uid()) throw new Error("Repair refuses a foreign or non-symlink active pointer");
423
+ if (!pointer.isSymbolicLink() || pointer.uid !== uid())
424
+ throw new Error("Repair refuses a foreign or non-symlink active pointer");
393
425
  const target = path.resolve(base, fs.readlinkSync(active));
394
426
  if (path.basename(target) !== "toolchain.json" || path.dirname(path.dirname(target)) !== base)
395
427
  throw new Error("Repair refuses an active pointer outside the owned installation");
396
428
  const root2 = path.dirname(target);
397
429
  owned(root2, true, true);
398
- if (fs.realpathSync(root2) !== root2) throw new Error("Repair refuses a linked bundle directory");
430
+ if (fs.realpathSync(root2) !== root2)
431
+ throw new Error("Repair refuses a linked bundle directory");
399
432
  let previousHash = null;
400
433
  if (exists(target)) {
401
434
  owned(target, false, true);
402
435
  previousHash = sha(bytes(target));
403
436
  }
404
- return { priorManifestPath: target, priorManifestSha256: previousHash, priorSelection: "invalid_owned_bundle" };
437
+ return {
438
+ priorManifestPath: target,
439
+ priorManifestSha256: previousHash,
440
+ priorSelection: "invalid_owned_bundle"
441
+ };
405
442
  };
406
443
  if (exists(active)) {
407
444
  try {
@@ -417,13 +454,24 @@ async function prepareManagedToolchain(options = {}) {
417
454
  for (const [name, component] of Object.entries(manifest.components)) {
418
455
  const command = name === "companion" ? process.execPath : component.command;
419
456
  const args = name === "companion" ? [component.command, "--version"] : ["--version"];
420
- const observed = await runner({ command, args, cwd: manifest.root, env: cleanEnvironment(manifest.root), timeoutMs: 15e3 });
421
- if (!new RegExp(`^(?:snipara-${name}[ ,]+)?${component.version.replaceAll(".", "\\.")}$`, "i").test(observed.stdout.trim()))
457
+ const observed = await runner({
458
+ command,
459
+ args,
460
+ cwd: manifest.root,
461
+ env: cleanEnvironment(manifest.root),
462
+ timeoutMs: 15e3
463
+ });
464
+ if (!new RegExp(
465
+ `^(?:snipara-${name}[ ,]+)?${component.version.replaceAll(".", "\\.")}$`,
466
+ "i"
467
+ ).test(observed.stdout.trim()))
422
468
  throw new Error("Managed component version handshake did not match the pinned bundle");
423
469
  }
424
470
  }
425
471
  const selectedPrior = prior;
426
- if (selectedPrior && Object.entries(MANAGED_VERSIONS).every(([name, version]) => selectedPrior.components[name].version === version)) {
472
+ if (selectedPrior && Object.entries(MANAGED_VERSIONS).every(
473
+ ([name, version]) => selectedPrior.components[name].version === version
474
+ )) {
427
475
  try {
428
476
  await handshake(selectedPrior);
429
477
  readManagedManifest(active, options);
@@ -437,27 +485,64 @@ async function prepareManagedToolchain(options = {}) {
437
485
  const bundleId = `bundle-${MANAGED_VERSIONS.companion}-${MANAGED_VERSIONS.orchestrator}-${MANAGED_VERSIONS.sandbox}-${randomUUID2()}`;
438
486
  const root = path.join(base, bundleId);
439
487
  fs.mkdirSync(root, { mode: 448 });
440
- for (const directory of ["home", "tmp"]) fs.mkdirSync(path.join(root, directory), { mode: 448 });
488
+ for (const directory of ["home", "tmp"])
489
+ fs.mkdirSync(path.join(root, directory), { mode: 448 });
441
490
  const env = cleanEnvironment(root);
442
491
  const run = (command, args, timeoutMs = 3e5) => runner({ command, args, cwd: root, env, timeoutMs });
443
492
  try {
444
- if (recovery) writePrivate(path.join(root, "recovery.json"), { schemaVersion: "snipara.toolchain_recovery.v1", ...recovery, originalBundlePreserved: true });
493
+ if (recovery)
494
+ writePrivate(path.join(root, "recovery.json"), {
495
+ schemaVersion: "snipara.toolchain_recovery.v1",
496
+ ...recovery,
497
+ originalBundlePreserved: true
498
+ });
445
499
  const python = options.python ?? program("python3"), npm = options.npm ?? program("npm");
446
- if (![python, npm].every((value) => path.isAbsolute(value))) throw new Error("Managed package managers need absolute executable paths");
500
+ if (![python, npm].every((value) => path.isAbsolute(value)))
501
+ throw new Error("Managed package managers need absolute executable paths");
447
502
  const runtime = await run(python, ["--version"], 1e4);
448
503
  assertManagedRuntimeVersions(process.versions.node, runtime.stdout);
449
504
  const venv = path.join(root, "python"), prefix = path.join(root, "node");
450
505
  await run(python, ["-I", "-m", "venv", venv], 6e4);
451
- await run(path.join(venv, "bin/python"), ["-I", "-m", "pip", "install", "--no-input", "--disable-pip-version-check", "snipara-sandbox[validation,mcp]==" + MANAGED_VERSIONS.sandbox, "snipara-orchestrator==" + MANAGED_VERSIONS.orchestrator]);
452
- await run(npm, ["install", "--prefix", prefix, "--ignore-scripts", "--no-audit", "--no-fund", "--save-exact", "snipara-companion@" + MANAGED_VERSIONS.companion]);
506
+ await run(path.join(venv, "bin/python"), [
507
+ "-I",
508
+ "-m",
509
+ "pip",
510
+ "install",
511
+ "--no-input",
512
+ "--disable-pip-version-check",
513
+ "snipara-sandbox[validation,mcp]==" + MANAGED_VERSIONS.sandbox,
514
+ "snipara-orchestrator==" + MANAGED_VERSIONS.orchestrator
515
+ ]);
516
+ await run(npm, [
517
+ "install",
518
+ "--prefix",
519
+ prefix,
520
+ "--ignore-scripts",
521
+ "--no-audit",
522
+ "--no-fund",
523
+ "--save-exact",
524
+ "snipara-companion@" + MANAGED_VERSIONS.companion
525
+ ]);
453
526
  const manifest = {
454
527
  schemaVersion: "snipara.toolchain.v1",
455
528
  bundleId,
456
529
  root,
457
530
  components: {
458
- companion: { version: MANAGED_VERSIONS.companion, command: fs.realpathSync(path.join(prefix, "node_modules/.bin/snipara-companion")), sha256: "" },
459
- orchestrator: { version: MANAGED_VERSIONS.orchestrator, command: path.join(venv, "bin/snipara-orchestrator"), sha256: "" },
460
- sandbox: { version: MANAGED_VERSIONS.sandbox, command: path.join(venv, "bin/snipara-sandbox"), sha256: "" }
531
+ companion: {
532
+ version: MANAGED_VERSIONS.companion,
533
+ command: fs.realpathSync(path.join(prefix, "node_modules/.bin/snipara-companion")),
534
+ sha256: ""
535
+ },
536
+ orchestrator: {
537
+ version: MANAGED_VERSIONS.orchestrator,
538
+ command: path.join(venv, "bin/snipara-orchestrator"),
539
+ sha256: ""
540
+ },
541
+ sandbox: {
542
+ version: MANAGED_VERSIONS.sandbox,
543
+ command: path.join(venv, "bin/snipara-sandbox"),
544
+ sha256: ""
545
+ }
461
546
  },
462
547
  contracts: { taskReference: 1, validation: 1 },
463
548
  capabilities: ["validation", "coordination"]
@@ -470,12 +555,24 @@ async function prepareManagedToolchain(options = {}) {
470
555
  writePrivate(manifestFile, parseManagedToolchainManifest(manifest));
471
556
  await handshake(manifest);
472
557
  readManagedManifest(manifestFile, options);
473
- writePrivate(path.join(root, "prepared.json"), { schemaVersion: "snipara.toolchain_preparation.v1", status: "prepared", manifestSha256: sha(bytes(manifestFile)), observedAt: (/* @__PURE__ */ new Date()).toISOString(), activationObserved: false });
558
+ writePrivate(path.join(root, "prepared.json"), {
559
+ schemaVersion: "snipara.toolchain_preparation.v1",
560
+ status: "prepared",
561
+ manifestSha256: sha(bytes(manifestFile)),
562
+ observedAt: (/* @__PURE__ */ new Date()).toISOString(),
563
+ activationObserved: false
564
+ });
474
565
  if (prior) switchPointer(base, "previous.json", path.join(prior.root, "toolchain.json"));
475
566
  switchPointer(base, "active.json", manifestFile);
476
567
  return manifest;
477
568
  } catch (error) {
478
- writePrivate(path.join(root, "failed.json"), { schemaVersion: "snipara.toolchain_preparation.v1", status: "failed", observedAt: (/* @__PURE__ */ new Date()).toISOString(), reason: "preparation_or_identity_check_failed", priorActivePreserved: true });
569
+ writePrivate(path.join(root, "failed.json"), {
570
+ schemaVersion: "snipara.toolchain_preparation.v1",
571
+ status: "failed",
572
+ observedAt: (/* @__PURE__ */ new Date()).toISOString(),
573
+ reason: "preparation_or_identity_check_failed",
574
+ priorActivePreserved: true
575
+ });
479
576
  throw error;
480
577
  }
481
578
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-snipara",
3
- "version": "2.2.14",
3
+ "version": "2.2.16",
4
4
  "description": "Onboard Snipara Cloud or self-hosted MCP with an automatic project-grounded proof of value",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",