@cydm/pie 2.5.2 → 2.6.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.
@@ -1,9 +1,9 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createAskUserCapability
4
- } from "../../../chunks/chunk-LO2V5DZZ.js";
5
- import "../../../chunks/chunk-RTTGO2A6.js";
6
- import "../../../chunks/chunk-UD7KYQ6J.js";
4
+ } from "../../../chunks/chunk-AZ336HKF.js";
5
+ import "../../../chunks/chunk-Y4CYXJR7.js";
6
+ import "../../../chunks/chunk-O2DKMLNX.js";
7
7
  import "../../../chunks/chunk-XXGYUYXI.js";
8
8
  import "../../../chunks/chunk-LZQXQOPJ.js";
9
9
 
@@ -24461,20 +24461,35 @@ function redactSecrets(text, secrets) {
24461
24461
  }
24462
24462
  return sanitized;
24463
24463
  }
24464
- function sanitizeDiagnostic(text, secrets) {
24465
- let sanitized = redactSecrets(text, secrets);
24466
- if (secrets.length > 0 && sanitized.length > 0) {
24467
- for (const secret of secrets) {
24468
- for (let keep = Math.min(secret.length - 1, sanitized.length); keep >= 4; keep--) {
24469
- if (sanitized.startsWith(secret.slice(secret.length - keep))) {
24470
- sanitized = `[redacted]${sanitized.slice(keep)}`;
24471
- break;
24472
- }
24464
+ function redactLeadingSecretSuffix(text, secrets) {
24465
+ if (secrets.length === 0 || text.length === 0) return text;
24466
+ for (const secret of secrets) {
24467
+ for (let keep = Math.min(secret.length - 1, text.length); keep >= 4; keep--) {
24468
+ if (text.startsWith(secret.slice(secret.length - keep))) {
24469
+ return `[redacted]${text.slice(keep)}`;
24470
+ }
24471
+ }
24472
+ }
24473
+ return text;
24474
+ }
24475
+ function redactTrailingSecretPrefix(text, secrets) {
24476
+ if (secrets.length === 0 || text.length === 0) return text;
24477
+ for (const secret of secrets) {
24478
+ for (let keep = Math.min(secret.length - 1, text.length); keep >= 4; keep--) {
24479
+ if (text.endsWith(secret.slice(0, keep))) {
24480
+ return `${text.slice(0, text.length - keep)}[redacted]`;
24473
24481
  }
24474
24482
  }
24475
24483
  }
24484
+ return text;
24485
+ }
24486
+ function redactStderrTail(tail, secrets) {
24487
+ return redactTrailingSecretPrefix(redactLeadingSecretSuffix(redactSecrets(tail, secrets), secrets), secrets);
24488
+ }
24489
+ function sanitizeDiagnostic(text, secrets) {
24490
+ const sanitized = redactLeadingSecretSuffix(redactSecrets(text, secrets), secrets);
24476
24491
  if (sanitized.length > DIAGNOSTIC_TEXT_LIMIT) {
24477
- sanitized = `${sanitized.slice(0, DIAGNOSTIC_TEXT_LIMIT)}\u2026[truncated ${sanitized.length - DIAGNOSTIC_TEXT_LIMIT} chars]`;
24492
+ return `${sanitized.slice(0, DIAGNOSTIC_TEXT_LIMIT)}\u2026[truncated ${sanitized.length - DIAGNOSTIC_TEXT_LIMIT} chars]`;
24478
24493
  }
24479
24494
  return sanitized;
24480
24495
  }
@@ -24543,14 +24558,20 @@ function cacheFingerprint(definition) {
24543
24558
  command: definition.command,
24544
24559
  args: definition.args,
24545
24560
  // Canonicalized (key-sorted) so reordering equivalent env/header keys
24546
- // does not invalidate cached metadata.
24547
- env: Object.fromEntries(Object.entries(definition.env ?? {}).sort(([a], [b]) => a.localeCompare(b))),
24561
+ // does not invalidate cached metadata. Sorting must be locale-stable
24562
+ // (code-unit order, not localeCompare) so the same definition
24563
+ // fingerprints identically on every machine.
24564
+ env: canonicalizeKeys(definition.env),
24548
24565
  serverCwd: definition.cwd,
24549
24566
  url: definition.url,
24550
- headers: Object.fromEntries(Object.entries(definition.headers ?? {}).sort(([a], [b]) => a.localeCompare(b))),
24567
+ headers: canonicalizeKeys(definition.headers),
24551
24568
  inheritEnv: definition.inheritEnv
24552
24569
  })).digest("hex").slice(0, 24);
24553
24570
  }
24571
+ function canonicalizeKeys(record2) {
24572
+ if (!record2) return {};
24573
+ return Object.fromEntries(Object.entries(record2).sort(([a], [b]) => a < b ? -1 : a > b ? 1 : 0));
24574
+ }
24554
24575
  var McpServerManager = class {
24555
24576
  constructor(definitions, cacheDir, log, now = Date.now) {
24556
24577
  this.now = now;
@@ -24757,7 +24778,6 @@ var McpServerManager = class {
24757
24778
  }
24758
24779
  }
24759
24780
  /** Cached descriptors for one server (from the metadata cache file). */
24760
- /** Cached descriptors for one server (from the metadata cache file). */
24761
24781
  cachedToolsFor(server) {
24762
24782
  return this.loadCatalog().filter((tool) => tool.server === sanitizeName(server));
24763
24783
  }
@@ -24887,8 +24907,8 @@ var McpServerManager = class {
24887
24907
  runtime = await this.connect(server, signal);
24888
24908
  } catch (error2) {
24889
24909
  const runtimeState = this.runtimes.get(server);
24890
- const tail = runtimeState?.stderrTail.trim();
24891
24910
  const secrets = definitionSecrets(definition);
24911
+ const tail = redactStderrTail(runtimeState?.stderrTail ?? "", secrets).trim();
24892
24912
  return {
24893
24913
  delivery: "not_sent",
24894
24914
  error: sanitizeDiagnostic(
@@ -25186,6 +25206,7 @@ ${truncate(JSON.stringify(schema ?? {}, null, 2), maxBytes)}` : `unknown MCP too
25186
25206
  }
25187
25207
  const resolved = getManager().resolvePrefixedName(params.tool);
25188
25208
  const server = descriptor?.server ?? resolved?.server ?? "";
25209
+ let dispatchManager;
25189
25210
  if (server) {
25190
25211
  const managerAtGate = getManager();
25191
25212
  const trust = await ensureTrusted(server, managerAtGate);
@@ -25204,6 +25225,7 @@ ${truncate(JSON.stringify(schema ?? {}, null, 2), maxBytes)}` : `unknown MCP too
25204
25225
  isError: true
25205
25226
  };
25206
25227
  }
25228
+ dispatchManager = managerNow;
25207
25229
  }
25208
25230
  let args = {};
25209
25231
  if (typeof params.args === "string") {
@@ -25219,7 +25241,7 @@ ${truncate(JSON.stringify(schema ?? {}, null, 2), maxBytes)}` : `unknown MCP too
25219
25241
  } else if (params.args && typeof params.args === "object" && !Array.isArray(params.args)) {
25220
25242
  args = params.args;
25221
25243
  }
25222
- const outcome = await getManager().callTool(params.tool, args, toolContext.signal);
25244
+ const outcome = await (dispatchManager ?? getManager()).callTool(params.tool, args, toolContext.signal);
25223
25245
  return mapMcpOutcome(outcome, maxBytes);
25224
25246
  }
25225
25247
  };
@@ -7,9 +7,9 @@ import {
7
7
  isPlanModeSafeCommand,
8
8
  markCompletedPlanSteps,
9
9
  restoreExecutionState
10
- } from "../../../chunks/chunk-LO2V5DZZ.js";
11
- import "../../../chunks/chunk-RTTGO2A6.js";
12
- import "../../../chunks/chunk-UD7KYQ6J.js";
10
+ } from "../../../chunks/chunk-AZ336HKF.js";
11
+ import "../../../chunks/chunk-Y4CYXJR7.js";
12
+ import "../../../chunks/chunk-O2DKMLNX.js";
13
13
  import {
14
14
  Type
15
15
  } from "../../../chunks/chunk-XXGYUYXI.js";
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  createCliHostCapabilities
4
- } from "../../../chunks/chunk-M4OJARWJ.js";
4
+ } from "../../../chunks/chunk-G6KCJA6B.js";
5
5
  import {
6
6
  createSharedFileSystemTools,
7
7
  createSubagentCapability
8
- } from "../../../chunks/chunk-LO2V5DZZ.js";
9
- import "../../../chunks/chunk-RTTGO2A6.js";
10
- import "../../../chunks/chunk-UD7KYQ6J.js";
8
+ } from "../../../chunks/chunk-AZ336HKF.js";
9
+ import "../../../chunks/chunk-Y4CYXJR7.js";
10
+ import "../../../chunks/chunk-O2DKMLNX.js";
11
11
  import "../../../chunks/chunk-5353DEEC.js";
12
12
  import "../../../chunks/chunk-XXGYUYXI.js";
13
13
  import "../../../chunks/chunk-LZQXQOPJ.js";
@@ -39,11 +39,14 @@ function subagentExtension(ctx) {
39
39
  debugLog: (module, message, data) => ctx.log(`[subagent:${module}] ${message}${data !== void 0 ? ` ${JSON.stringify(data)}` : ""}`),
40
40
  resolveModelClass: (modelClass) => ctx.resolveModelClass?.(modelClass),
41
41
  resolveModelRef: (modelRef) => ctx.resolveModelRef?.(modelRef),
42
- createRuntimeTools: () => {
42
+ createRuntimeTools: (mode) => {
43
43
  const parentRuntimeTools = ctx.getRuntimeTools();
44
44
  if (Array.isArray(parentRuntimeTools) && parentRuntimeTools.length > 0) {
45
45
  return parentRuntimeTools.filter((tool) => tool?.name !== "spawn_subagents_parallel");
46
46
  }
47
+ if (mode === "edit") {
48
+ throw new Error("Edit delegation requires the parent's executable runtime tools; fallback tools are read-mode only.");
49
+ }
47
50
  const configDir = path.join(os.homedir(), ".pie");
48
51
  const fsOptions = ctx.yoloMode ? { allowlistedDirs: ["/"] } : {
49
52
  accessRoots: [
@@ -8,9 +8,9 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-LO2V5DZZ.js";
12
- import "../../../chunks/chunk-RTTGO2A6.js";
13
- import "../../../chunks/chunk-UD7KYQ6J.js";
11
+ } from "../../../chunks/chunk-AZ336HKF.js";
12
+ import "../../../chunks/chunk-Y4CYXJR7.js";
13
+ import "../../../chunks/chunk-O2DKMLNX.js";
14
14
  import "../../../chunks/chunk-XXGYUYXI.js";
15
15
  import "../../../chunks/chunk-LZQXQOPJ.js";
16
16