@cydm/pie 4.3.7 → 4.3.12

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.
@@ -193,17 +193,44 @@ function safeName(name) {
193
193
  }
194
194
  function sanitizeImForward(raw) {
195
195
  if (raw === void 0) return void 0;
196
- if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error("imForward must be an object");
196
+ if (raw === "inherit" || typeof raw === "object" && raw !== null && !Array.isArray(raw) && raw.inherit === true) {
197
+ const userIm = readUserImForwardIdentity();
198
+ if (!userIm) throw new Error("imForward inherit: no user-layer im-forward.json provider settings found to inherit");
199
+ return { enabled: true, ...userIm };
200
+ }
201
+ if (typeof raw !== "object" || raw === null || Array.isArray(raw)) throw new Error('imForward must be an object, "inherit", or {inherit:true}');
197
202
  const source = raw;
198
203
  const out = {};
199
204
  for (const [key, value] of Object.entries(source)) {
205
+ if (key === "inherit") continue;
200
206
  if (!IM_FORWARD_ALLOWED_KEYS.has(key)) {
201
- throw new Error(`imForward field "${key}" is not allowed (executable/path selection is operator-only config). Allowed: ${[...IM_FORWARD_ALLOWED_KEYS].join(", ")}`);
207
+ throw new Error(`imForward field "${key}" is not allowed (executable/path selection is operator-only config). Allowed: inherit, ${[...IM_FORWARD_ALLOWED_KEYS].join(", ")}`);
202
208
  }
203
209
  out[key] = value;
204
210
  }
205
211
  return out;
206
212
  }
213
+ function readUserImForwardIdentity() {
214
+ try {
215
+ const candidates = [path.join(configDirRoot(), "im-forward.json")];
216
+ for (const file of candidates) {
217
+ try {
218
+ const parsed = JSON.parse(fs.readFileSync(file, "utf8"));
219
+ const provider = typeof parsed.provider === "string" ? parsed.provider : "feishu";
220
+ const settings = parsed.providers?.[provider];
221
+ if (!settings) continue;
222
+ const identity = { provider };
223
+ for (const key of ["chatId", "openId", "allowUsers", "larkCliProfile"]) {
224
+ if (settings[key] !== void 0) identity[key] = settings[key];
225
+ }
226
+ return identity;
227
+ } catch {
228
+ }
229
+ }
230
+ } catch {
231
+ }
232
+ return void 0;
233
+ }
207
234
  function cliEntry() {
208
235
  const moduleDir = path.dirname(fileURLToPath(import.meta.url));
209
236
  for (const rel of ["../../../src/cli.ts", "../../../cli.js"]) {
@@ -307,7 +334,7 @@ function pieProc(ctx) {
307
334
  const observed = Math.max(w.lastActiveAt, observeActivity(w));
308
335
  if (observed > w.lastActiveAt) persistActivity(w, observed);
309
336
  }
310
- updateRegistry((snap) => {
337
+ casRegistry((snap) => {
311
338
  const cutoff = Date.now();
312
339
  let changed = false;
313
340
  const keep = [];
@@ -574,6 +601,11 @@ function pieProc(ctx) {
574
601
  }
575
602
  return toolText(`Worker "${name}" (pid ${target.pid}) was signalled but is NOT confirmed dead (state: ${finalState}); its registry entry is retained. Re-run pie_proc kill after it exits, or inspect manually.`, true);
576
603
  };
604
+ const managerOnly = ctx.capabilities?.unattended === true && process.env.PIE_PROC_CURATED_NAME === "manager";
605
+ if (!managerOnly) {
606
+ ctx.log("pie-proc: tool not registered (role-pruned; manager-only)");
607
+ return;
608
+ }
577
609
  ctx.registerTool({
578
610
  name: "pie_proc",
579
611
  label: "Pie worker processes",
@@ -586,7 +618,7 @@ function pieProc(ctx) {
586
618
  task: Type.Optional(Type.String({ description: "oneshot: the task prompt (non-empty, must not start with '-')" })),
587
619
  ttlMs: Type.Optional(Type.Number({ description: "spawn (resident only): idle TTL in ms (0 = never reap)", minimum: 0, maximum: 864e5 })),
588
620
  force: Type.Optional(Type.Boolean({ description: "kill: skip graceful SIGTERM" })),
589
- imForward: Type.Optional(Type.Record(Type.String(), Type.Unknown()), { description: "spawn (resident only): IM identity binding \u2014 identity fields only (enabled/provider/chatId/openId/allowUsers/larkCliProfile)" })
621
+ imForward: Type.Optional(Type.Union([Type.Literal("inherit"), Type.Record(Type.String(), Type.Unknown())], { description: "spawn (resident only): IM identity binding \u2014 'inherit' copies the operator's user-layer IM identity verbatim (recommended: open_ids are per-app, hand copies break silently), or an object of identity fields only (enabled/provider/chatId/openId/allowUsers/larkCliProfile/inherit)" }))
590
622
  }),
591
623
  risk: { riskClass: "process_lifecycle", requiresPermission: true, externalSideEffect: true, readsNetwork: false, writesNetwork: false, concurrencySafe: false },
592
624
  renderHint: { summary: (args) => `${String(args.action)}${args.name ? ` ${String(args.name)}` : ""}` },
@@ -6,7 +6,7 @@ import {
6
6
  createPlanCapability,
7
7
  markCompletedPlanSteps,
8
8
  restoreExecutionState
9
- } from "../../../chunks/chunk-WZLO5V2X.js";
9
+ } from "../../../chunks/chunk-N5B5IGJ6.js";
10
10
  import "../../../chunks/chunk-XMOWWL4B.js";
11
11
  import "../../../chunks/chunk-B4N5LJMD.js";
12
12
  import "../../../chunks/chunk-6JEYRAQM.js";
@@ -191,7 +191,8 @@ ${steps}${warningLines}`;
191
191
  planModeEnabled = false;
192
192
  ctx.setSessionMetadata(SESSION_METADATA_KEY, false);
193
193
  ctx.setPlanMode(false);
194
- const merged = revisionPrefix ? [...revisionPrefix, ...items.map((item, index) => ({ ...item, step: revisionPrefix.length + index + 1 }))] : items;
194
+ const prefix = revisionPrefix;
195
+ const merged = prefix ? [...prefix, ...items.map((item, index) => ({ ...item, step: prefix.length + index + 1 }))] : items;
195
196
  revisionPrefix = null;
196
197
  setExecutingPlan(merged.length > 0);
197
198
  writeExecutionState(createExecutionStateFromPlan(merged));
@@ -325,9 +326,9 @@ Update the plan accordingly and call plan_submit again with the revised steps. D
325
326
  return bare;
326
327
  }).filter(Boolean)
327
328
  }));
328
- if (normalized.every((item) => item.files.length === 0)) return [];
329
+ if (normalized.every((item) => (item.files ?? []).length === 0)) return [];
329
330
  const existsCache = /* @__PURE__ */ new Map();
330
- for (const target of new Set(normalized.flatMap((item) => item.files))) {
331
+ for (const target of new Set(normalized.flatMap((item) => item.files ?? []))) {
331
332
  existsCache.set(target, await pathExists(target));
332
333
  }
333
334
  return checkPlanScope(
@@ -337,7 +338,7 @@ Update the plan accordingly and call plan_submit again with the revised steps. D
337
338
  );
338
339
  }
339
340
  ctx.registerCommand({
340
- path: capability.commands?.[0]?.path ?? ["tools", "plan"],
341
+ path: [...capability.commands?.[0]?.path ?? ["tools", "plan"]],
341
342
  description: "Toggle plan mode (read-only exploration, discussion-first)",
342
343
  handler: async () => {
343
344
  togglePlanMode();
@@ -5,7 +5,7 @@ import {
5
5
  createCliRetryPolicy,
6
6
  formatTransportLifecycle,
7
7
  logTransportLifecycle
8
- } from "../../../chunks/chunk-2SAFRLFJ.js";
8
+ } from "../../../chunks/chunk-I7PBXG5Q.js";
9
9
  import {
10
10
  getConfigDir
11
11
  } from "../../../chunks/chunk-ILUHTKF3.js";
@@ -14,7 +14,7 @@ import {
14
14
  createPolicyEnforcedTools,
15
15
  createSharedFileSystemTools,
16
16
  createSubagentCapability
17
- } from "../../../chunks/chunk-WZLO5V2X.js";
17
+ } from "../../../chunks/chunk-N5B5IGJ6.js";
18
18
  import "../../../chunks/chunk-XMOWWL4B.js";
19
19
  import "../../../chunks/chunk-B4N5LJMD.js";
20
20
  import "../../../chunks/chunk-6JEYRAQM.js";
@@ -381,6 +381,9 @@ function createSubagentSessionStore(sessionsDir, log, deps) {
381
381
 
382
382
  // builtin/extensions/subagent/index.ts
383
383
  import * as path2 from "path";
384
+ function preserveModelResolution(r) {
385
+ return r === void 0 ? void 0 : { ...r, model: r.model };
386
+ }
384
387
  function subagentExtension(ctx) {
385
388
  ctx.log("Subagent extension loaded (transparent parallel mode)");
386
389
  const resolveRuntimePair = () => {
@@ -419,8 +422,14 @@ function subagentExtension(ctx) {
419
422
  ctx.log(formatTransportLifecycle(event));
420
423
  }
421
424
  },
422
- resolveModelClass: (modelClass) => ctx.resolveModelClass?.(modelClass),
423
- resolveModelRef: (modelRef) => ctx.resolveModelRef?.(modelRef),
425
+ resolveModelClass: (modelClass) => {
426
+ const r = ctx.resolveModelClass?.(modelClass);
427
+ return preserveModelResolution(r);
428
+ },
429
+ resolveModelRef: (modelRef) => {
430
+ const r = ctx.resolveModelRef?.(modelRef);
431
+ return preserveModelResolution(r);
432
+ },
424
433
  createRuntimeTools: (mode) => {
425
434
  const parentRuntimeTools = ctx.getRuntimeTools();
426
435
  if (Array.isArray(parentRuntimeTools) && parentRuntimeTools.length > 0) {
@@ -450,5 +459,6 @@ function subagentExtension(ctx) {
450
459
  }
451
460
  }
452
461
  export {
453
- subagentExtension as default
462
+ subagentExtension as default,
463
+ preserveModelResolution
454
464
  };
@@ -8,7 +8,7 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-WZLO5V2X.js";
11
+ } from "../../../chunks/chunk-N5B5IGJ6.js";
12
12
  import "../../../chunks/chunk-XMOWWL4B.js";
13
13
  import "../../../chunks/chunk-B4N5LJMD.js";
14
14
  import "../../../chunks/chunk-6JEYRAQM.js";
@@ -50,7 +50,11 @@ function todoExtension(ctx) {
50
50
  persistExecutionState(ctx, nextState, args.action === "create" ? "create" : args.action === "clear" ? "explicit_clear" : execution.nextTodos.length === 0 ? "completed_clear" : "advance");
51
51
  notifyWidget(ctx, nextState);
52
52
  }
53
- return execution.result;
53
+ return {
54
+ content: execution.result.content.map((block) => ({ type: "text", text: "text" in block ? block.text : "" })),
55
+ details: execution.result.details,
56
+ isError: execution.result.isError
57
+ };
54
58
  }
55
59
  });
56
60
  ctx.on("session:changed", async () => {