@tangle-network/sdk-cli-runner 0.3.17 → 0.3.18

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.d.mts CHANGED
@@ -434,6 +434,8 @@ type RawCaptureAttempt = {
434
434
  declare function withRawCaptureAttempt<T>(attempt: RawCaptureAttempt, run: () => Promise<T>): Promise<T>;
435
435
  /** The sidecar owns this directory; the CLI's writable HOME cannot contain its evidence. */
436
436
  declare function resolveRawCapturePath(runtimeHome: string): string;
437
+ /** Prepare root-owned executor state without opening or enabling an evidence spool. */
438
+ declare function ensureRawCaptureDirectory(runtimeHome: string): string;
437
439
  /**
438
440
  * Opt one runtime HOME in to full capture, inside the shared byte budget, when
439
441
  * the platform default is off. The Sidecar calls this for a session created with retention
@@ -648,5 +650,5 @@ declare function mergeSpawnEnv(base: NodeJS.ProcessEnv, overrides: Record<string
648
650
  */
649
651
  declare function createStreamParser<T>(config: StreamParserConfig<T>): StreamParser<T>;
650
652
  //#endregion
651
- export { BridgeClosedError, type CliExecOptions, type CliExecResult, type CliExitResult, type CliLaunch, type CliLaunchSpec, type CliLauncher, type CliProcess, type CliSpawnConfig, type CliStdinValue, HELD_SPARE_IDLE_MS, type HeldSpare, type HeldSpareLetFinish, type HeldSpareRegistry, InvalidAttachmentError, JsonRpcError, RAW_CAPTURE_ROOT, RAW_CAPTURE_TOTAL_CAP_BYTES, type RawCaptureProcess, type RpcBridge, type RpcBridgeConfig, type RpcCloseReason, type RpcNotificationHandler, type RpcRequestHandler, type RpcRequestOptions, RpcRequestTimeoutError, type StreamParserConfig, allowRetainedRawCapture, argAfter, configurePrivilegeDrop, createDeferredParser, createHeldSpareRegistry, createStreamParser, execCli, launchCliProcess, launchDifferences, mergeSpawnEnv, openRawCapture, privilegeDropCommand, privilegeDropIdentity, readProcessIdentity, removeRawCapture, resolveRawCapturePath, restoreTurnPriority, shellQuote, spawnCliProcess, spawnRpcBridge, summarizeRawCapture, trimRawCapture, trustedToolPath, withRawCaptureAttempt, yieldUntilAdopted };
653
+ export { BridgeClosedError, type CliExecOptions, type CliExecResult, type CliExitResult, type CliLaunch, type CliLaunchSpec, type CliLauncher, type CliProcess, type CliSpawnConfig, type CliStdinValue, HELD_SPARE_IDLE_MS, type HeldSpare, type HeldSpareLetFinish, type HeldSpareRegistry, InvalidAttachmentError, JsonRpcError, RAW_CAPTURE_ROOT, RAW_CAPTURE_TOTAL_CAP_BYTES, type RawCaptureProcess, type RpcBridge, type RpcBridgeConfig, type RpcCloseReason, type RpcNotificationHandler, type RpcRequestHandler, type RpcRequestOptions, RpcRequestTimeoutError, type StreamParserConfig, allowRetainedRawCapture, argAfter, configurePrivilegeDrop, createDeferredParser, createHeldSpareRegistry, createStreamParser, ensureRawCaptureDirectory, execCli, launchCliProcess, launchDifferences, mergeSpawnEnv, openRawCapture, privilegeDropCommand, privilegeDropIdentity, readProcessIdentity, removeRawCapture, resolveRawCapturePath, restoreTurnPriority, shellQuote, spawnCliProcess, spawnRpcBridge, summarizeRawCapture, trimRawCapture, trustedToolPath, withRawCaptureAttempt, yieldUntilAdopted };
652
654
  //# sourceMappingURL=index.d.mts.map
package/dist/index.mjs CHANGED
@@ -252,7 +252,7 @@ function resolveRawCapturePath(runtimeHome) {
252
252
  if (!isAbsolute(runtimeHome)) throw new Error("runtimeHome must be absolute for raw capture");
253
253
  return join(RAW_ROOT, createHash("sha256").update(resolve(runtimeHome)).digest("hex"), "process-io.frames");
254
254
  }
255
- function assertProtectedCaptureDirectory(directory) {
255
+ function assertProtectedCaptureDirectory(directory, create = false) {
256
256
  if (process.getuid?.() !== 0) throw new Error("sidecar raw capture requires root ownership");
257
257
  for (const part of [
258
258
  "/root",
@@ -260,10 +260,20 @@ function assertProtectedCaptureDirectory(directory) {
260
260
  RAW_ROOT,
261
261
  directory
262
262
  ]) {
263
+ if (create && part !== "/root") mkdirSync(part, {
264
+ recursive: true,
265
+ mode: 448
266
+ });
263
267
  const entry = lstatSync(part);
264
268
  if (!entry.isDirectory() || entry.isSymbolicLink() || entry.uid !== 0 || (entry.mode & 63) !== 0 || realpathSync(part) !== part) throw new Error(`raw capture parent is not protected: ${part}`);
265
269
  }
266
270
  }
271
+ /** Prepare root-owned executor state without opening or enabling an evidence spool. */
272
+ function ensureRawCaptureDirectory(runtimeHome) {
273
+ const directory = dirname(resolveRawCapturePath(runtimeHome));
274
+ assertProtectedCaptureDirectory(directory, true);
275
+ return directory;
276
+ }
267
277
  /**
268
278
  * Opt one runtime HOME in to full capture, inside the shared byte budget, when
269
279
  * the platform default is off. The Sidecar calls this for a session created with retention
@@ -488,7 +498,8 @@ function openRawCapture(file, options) {
488
498
  };
489
499
  if (mode === "none") return disabled;
490
500
  try {
491
- mkdirSync(directory, {
501
+ if (protectedPath) assertProtectedCaptureDirectory(directory, true);
502
+ else mkdirSync(directory, {
492
503
  recursive: true,
493
504
  mode: 448
494
505
  });
@@ -496,7 +507,6 @@ function openRawCapture(file, options) {
496
507
  if (protectedPath && captureCapacityError(error)) return disabled;
497
508
  throw error;
498
509
  }
499
- if (protectedPath) assertProtectedCaptureDirectory(directory);
500
510
  const parent = lstatSync(directory);
501
511
  if (!parent.isDirectory() || parent.isSymbolicLink() || (parent.mode & 63) !== 0) throw new Error("raw capture directory must be a private real directory");
502
512
  const path = resolve(file);
@@ -2597,6 +2607,6 @@ function shellQuote(value) {
2597
2607
  return `'${value.replace(/'/g, `'"'"'`)}'`;
2598
2608
  }
2599
2609
  //#endregion
2600
- export { BridgeClosedError, HELD_SPARE_IDLE_MS, InvalidAttachmentError, JsonRpcError, RAW_CAPTURE_ROOT, RAW_CAPTURE_TOTAL_CAP_BYTES, RpcRequestTimeoutError, allowRetainedRawCapture, argAfter, configurePrivilegeDrop, createDeferredParser, createHeldSpareRegistry, createStreamParser, execCli, launchCliProcess, launchDifferences, mergeSpawnEnv, openRawCapture, privilegeDropCommand, privilegeDropIdentity, readProcessIdentity, removeRawCapture, resolveRawCapturePath, restoreTurnPriority, shellQuote, spawnCliProcess, spawnRpcBridge, summarizeRawCapture, trimRawCapture, trustedToolPath, withRawCaptureAttempt, yieldUntilAdopted };
2610
+ export { BridgeClosedError, HELD_SPARE_IDLE_MS, InvalidAttachmentError, JsonRpcError, RAW_CAPTURE_ROOT, RAW_CAPTURE_TOTAL_CAP_BYTES, RpcRequestTimeoutError, allowRetainedRawCapture, argAfter, configurePrivilegeDrop, createDeferredParser, createHeldSpareRegistry, createStreamParser, ensureRawCaptureDirectory, execCli, launchCliProcess, launchDifferences, mergeSpawnEnv, openRawCapture, privilegeDropCommand, privilegeDropIdentity, readProcessIdentity, removeRawCapture, resolveRawCapturePath, restoreTurnPriority, shellQuote, spawnCliProcess, spawnRpcBridge, summarizeRawCapture, trimRawCapture, trustedToolPath, withRawCaptureAttempt, yieldUntilAdopted };
2601
2611
 
2602
2612
  //# sourceMappingURL=index.mjs.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tangle-network/sdk-cli-runner",
3
- "version": "0.3.17",
3
+ "version": "0.3.18",
4
4
  "description": "Generic CLI process spawning with stdin/stdout streaming and JSONL parsing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.mjs",
@@ -26,8 +26,8 @@
26
26
  "registry": "https://registry.npmjs.org"
27
27
  },
28
28
  "tangleRelease": {
29
- "sourceSha": "e71746bf3cf7d504d76e0e24659e55501b42a175",
30
- "mergedAt": "2026-11-22T22:31:59-08:00"
29
+ "sourceSha": "57453ab6787f82ae4359215373fc5dd0070d8aa9",
30
+ "mergedAt": "2026-11-24T01:40:28-08:00"
31
31
  },
32
32
  "scripts": {
33
33
  "build": "tsdown",