@cydm/pie 4.4.0 → 4.4.1

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 (40) hide show
  1. package/dist/builtin/extensions/ask-user/index.js +6 -6
  2. package/dist/builtin/extensions/changelog/index.js +1 -1
  3. package/dist/builtin/extensions/cron/index.js +2 -2
  4. package/dist/builtin/extensions/document-attachments/index.js +1 -1
  5. package/dist/builtin/extensions/herdr-agent-state/index.js +1 -1
  6. package/dist/builtin/extensions/im-forward/README.md +4 -3
  7. package/dist/builtin/extensions/im-forward/index.js +23 -4
  8. package/dist/builtin/extensions/init/index.js +1 -1
  9. package/dist/builtin/extensions/mcp-adapter/index.js +2 -2
  10. package/dist/builtin/extensions/memory/index.js +11 -9
  11. package/dist/builtin/extensions/pie-ipc/index.js +2 -2
  12. package/dist/builtin/extensions/pie-proc/index.js +70 -7
  13. package/dist/builtin/extensions/plan-mode/index.js +6 -6
  14. package/dist/builtin/extensions/subagent/index.js +11 -9
  15. package/dist/builtin/extensions/todo/index.js +6 -6
  16. package/dist/builtin/skills/computer-use-axi/computer-use-axi-broker.js +1 -1
  17. package/dist/builtin/skills/computer-use-axi/computer-use-axi-runtime.js +1 -1
  18. package/dist/chunks/{auth-storage-3EGM3VTK.js → auth-storage-RABPRJ6T.js} +3 -3
  19. package/dist/chunks/chunk-7KLWHWZD.js +164 -0
  20. package/dist/chunks/{chunk-I7PBXG5Q.js → chunk-7LTQLJJF.js} +9 -6
  21. package/dist/chunks/{chunk-XXGYUYXI.js → chunk-BPSCGGVF.js} +1 -1
  22. package/dist/chunks/{chunk-VHKMWOG3.js → chunk-EQOI6RZV.js} +5 -3
  23. package/dist/chunks/{chunk-B4N5LJMD.js → chunk-IPLMGAML.js} +1 -1
  24. package/dist/chunks/{chunk-GY47MKCJ.js → chunk-IZDNZW3S.js} +8 -8
  25. package/dist/chunks/{chunk-6DNYGVZP.js → chunk-OV7SLSHR.js} +4 -2
  26. package/dist/chunks/{chunk-6JEYRAQM.js → chunk-R7VO46EK.js} +2 -2
  27. package/dist/chunks/{chunk-LZQXQOPJ.js → chunk-RZGYXAJU.js} +12 -1
  28. package/dist/chunks/{chunk-ILUHTKF3.js → chunk-UCKOXAME.js} +61 -11
  29. package/dist/chunks/{chunk-XMOWWL4B.js → chunk-XO3NM7BB.js} +3 -3
  30. package/dist/chunks/{chunk-N5B5IGJ6.js → chunk-YNTIOWCD.js} +5 -5
  31. package/dist/chunks/{config-74AUVDLT.js → config-HF2PDLN5.js} +8 -4
  32. package/dist/chunks/{manager-cli-4Z6RZ7F4.js → manager-cli-BYCF4RKN.js} +5 -3
  33. package/dist/chunks/{model-registry-NKE3BRSZ.js → model-registry-7FNIUYPF.js} +5 -5
  34. package/dist/chunks/{src-V2M7FLWY.js → src-A5YI46OD.js} +6 -6
  35. package/dist/chunks/{src-4EQ7PBEI.js → src-OA3TP6DS.js} +5 -5
  36. package/dist/chunks/{src-46R5ZFOU.js → src-OVWRBWKU.js} +4 -4
  37. package/dist/chunks/{src-BHIH4VLE.js → src-TF2RAGRU.js} +3 -3
  38. package/dist/chunks/{test-stream-FC6ZRENI.js → test-stream-7YZDGBPO.js} +3 -3
  39. package/dist/cli.js +231 -49
  40. package/package.json +2 -2
@@ -1,12 +1,12 @@
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-N5B5IGJ6.js";
5
- import "../../../chunks/chunk-XMOWWL4B.js";
6
- import "../../../chunks/chunk-B4N5LJMD.js";
7
- import "../../../chunks/chunk-6JEYRAQM.js";
8
- import "../../../chunks/chunk-XXGYUYXI.js";
9
- import "../../../chunks/chunk-LZQXQOPJ.js";
4
+ } from "../../../chunks/chunk-YNTIOWCD.js";
5
+ import "../../../chunks/chunk-XO3NM7BB.js";
6
+ import "../../../chunks/chunk-IPLMGAML.js";
7
+ import "../../../chunks/chunk-R7VO46EK.js";
8
+ import "../../../chunks/chunk-BPSCGGVF.js";
9
+ import "../../../chunks/chunk-RZGYXAJU.js";
10
10
 
11
11
  // builtin/extensions/ask-user/index.ts
12
12
  function askUserExtension(ctx) {
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import "../../../chunks/chunk-LZQXQOPJ.js";
2
+ import "../../../chunks/chunk-RZGYXAJU.js";
3
3
 
4
4
  // builtin/extensions/changelog/index.ts
5
5
  import * as fs from "node:fs";
@@ -1,8 +1,8 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  Type
4
- } from "../../../chunks/chunk-XXGYUYXI.js";
5
- import "../../../chunks/chunk-LZQXQOPJ.js";
4
+ } from "../../../chunks/chunk-BPSCGGVF.js";
5
+ import "../../../chunks/chunk-RZGYXAJU.js";
6
6
 
7
7
  // builtin/extensions/cron/index.ts
8
8
  import * as path4 from "node:path";
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import "../../../chunks/chunk-LZQXQOPJ.js";
2
+ import "../../../chunks/chunk-RZGYXAJU.js";
3
3
 
4
4
  // builtin/extensions/document-attachments/index.ts
5
5
  import * as fs from "node:fs";
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
- import "../../../chunks/chunk-LZQXQOPJ.js";
2
+ import "../../../chunks/chunk-RZGYXAJU.js";
3
3
 
4
4
  // builtin/extensions/herdr-agent-state/index.ts
5
5
  import { spawn } from "node:child_process";
@@ -69,8 +69,9 @@ are read as implicit Feishu settings. Unknown explicit providers never fall back
69
69
  Provider settings merge only within the same provider, with project precedence.
70
70
 
71
71
  The footer shows `[IM…]` while starting, `[IM]` only after the consumer's ready
72
- marker, `[IM!]` on configuration/connection failure, `[IM-DEGRADED:bus]`
73
- when the last recognized bus SDK state is disconnected beyond a ten-minute
72
+ marker, `[IM!]` on configuration/connection failure, `[IM↓]` (logged
73
+ and reported by `/tools/im-forward status` with the specific cause, `bus`
74
+ or `dispatch`) when the last recognized bus SDK state is disconnected beyond a ten-minute
74
75
  reconnect grace, and nothing when off. A five-minute probe reads a bounded
75
76
  log tail using host-local timestamps; unknown/unavailable evidence preserves
76
77
  an existing warning. Only a recognized reconnect clears it. This is passive
@@ -84,7 +85,7 @@ On a machine where a resident holds the consumer slot, non-holder runtimes
84
85
  operate in dispatch mode: they never spawn a consumer and receive events over
85
86
  pie-ipc. For such runtimes the tag answers a delivery question, not a
86
87
  lifecycle one: `[IM]` while dispatch mode is the working configuration (the
87
- holder is alive and sorting), `[IM-DEGRADED:dispatch]` when the holder
88
+ holder is alive and sorting), `[IM↓]` (cause `dispatch`) when the holder
88
89
  heartbeat stays fresh yet nothing has been dispatched here past a ten-minute
89
90
  grace window, and `[IM…]` only while the runtime is genuinely starting or
90
91
  waiting to claim. A dispatched event restores `[IM]` immediately. Losing the
@@ -36,7 +36,7 @@ import {
36
36
  detectImageMime,
37
37
  readImageFormat
38
38
  } from "../../../chunks/chunk-F7EBZTZO.js";
39
- import "../../../chunks/chunk-LZQXQOPJ.js";
39
+ import "../../../chunks/chunk-RZGYXAJU.js";
40
40
 
41
41
  // builtin/extensions/im-forward/runtime.ts
42
42
  import * as crypto from "node:crypto";
@@ -836,10 +836,14 @@ function createRuntime(ctx, cfg, connection, liveEnabled, persistEnabled) {
836
836
  return false;
837
837
  }
838
838
  };
839
+ const degradedTag = (cause) => {
840
+ ctx.log(`im-forward: footer degraded (${cause})`);
841
+ return "[IM\u2193]";
842
+ };
839
843
  function updateFooterTag() {
840
844
  ctx.ui.setStatus?.(
841
845
  STATUS_KEY,
842
- configurationFailed ? "[IM!]" : forwardingEnabled ? consumerLastExit ? "[IM!]" : busStale ? "[IM-DEGRADED:bus]" : consumerReady ? "[IM]" : dispatchMode ? dispatchStale() ? "[IM-DEGRADED:dispatch]" : "[IM]" : "[IM\u2026]" : void 0
846
+ configurationFailed ? "[IM!]" : forwardingEnabled ? consumerLastExit ? "[IM!]" : busStale ? degradedTag("bus") : consumerReady ? "[IM]" : dispatchMode ? dispatchStale() ? degradedTag("dispatch") : "[IM]" : "[IM\u2026]" : void 0
843
847
  );
844
848
  }
845
849
  const DISPATCH_GRACE_MS = 10 * 6e4;
@@ -1219,7 +1223,11 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
1219
1223
  attribution?.replyTo,
1220
1224
  attribution,
1221
1225
  deliver
1222
- ).catch(() => void 0);
1226
+ ).then((delivered) => {
1227
+ if (delivered === true && attribution?.replyTo && connection.react) {
1228
+ providerCall("react", () => connection.react(attribution.replyTo, "CheckMark")).catch(() => void 0);
1229
+ }
1230
+ }).catch(() => void 0);
1223
1231
  });
1224
1232
  ctx.on("turn:failed", (event) => {
1225
1233
  if (!isForwardingEnabled()) return;
@@ -1230,8 +1238,10 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
1230
1238
  const attribution = resolveOutboundAttribution(sessionId);
1231
1239
  const deliverTf = /* @__PURE__ */ new Map();
1232
1240
  if (!outboundRoleAllows(attribution, deliverTf)) return;
1241
+ const recoveryHint = `\u8F93\u5165\u4ECD\u5728\u4F1A\u8BDD\u4E2D\uFF0C\u56DE\u590D\u201C\u91CD\u7B54\u4E0A\u4E00\u6761\u201D\u5373\u53EF\u57FA\u4E8E\u5B83\u91CD\u65B0\u4F5C\u7B54\uFF0C\u65E0\u9700\u91CD\u53D1\u539F\u59CB\u8BF7\u6C42\u3002`;
1233
1242
  void forwardMessage(
1234
- `\u26A0\uFE0F \u4EFB\u52A1\u5931\u8D25\uFF1A${reason}`,
1243
+ `\u26A0\uFE0F \u4EFB\u52A1\u5931\u8D25\uFF1A${reason}\uFF08\u91CD\u8BD5\u5DF2\u7528\u5C3D\uFF09
1244
+ ${recoveryHint}`,
1235
1245
  sessionId,
1236
1246
  sequence,
1237
1247
  attribution?.caption,
@@ -1524,8 +1534,10 @@ ${pending.caption || IM_INPUT_FALLBACK_CAPTION}` : pending.caption).trim();
1524
1534
  anchor
1525
1535
  )
1526
1536
  );
1537
+ return false;
1527
1538
  }
1528
1539
  }
1540
+ return true;
1529
1541
  }
1530
1542
  const sentAnchors = /* @__PURE__ */ new Set();
1531
1543
  function registerRoute(sent, sessionId) {
@@ -3650,6 +3662,13 @@ function connect(binary, profile, targetKind = "chat", settings = { targetId: ""
3650
3662
  async acknowledge(id) {
3651
3663
  await call(["im", "reactions", "create", "--as", "bot", "--params", JSON.stringify({ message_id: id }), "--data", JSON.stringify({ reaction_type: { emoji_type: "THUMBSUP" } })]);
3652
3664
  },
3665
+ // 4.4.1 turn-settled reaction (dogfood ask: "结束☑️就好"). Feishu's
3666
+ // official emoji_type table lists "CheckMark" for ✔ (verified against
3667
+ // the larksuite/cli reactions reference — OnCheck/WHITE_CHECK_MARK do
3668
+ // NOT exist and the API rejects them).
3669
+ async react(id, emoji) {
3670
+ await call(["im", "reactions", "create", "--as", "bot", "--params", JSON.stringify({ message_id: id }), "--data", JSON.stringify({ reaction_type: { emoji_type: emoji } })]);
3671
+ },
3653
3672
  async metadata(id) {
3654
3673
  const data = await call(["im", "+messages-mget", "--as", "bot", "--message-ids", id]);
3655
3674
  const message = Array.isArray(data?.messages) ? data.messages[0] : void 0;
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  resolveCliProjectRoot
4
4
  } from "../../../chunks/chunk-WLFOBECN.js";
5
- import "../../../chunks/chunk-LZQXQOPJ.js";
5
+ import "../../../chunks/chunk-RZGYXAJU.js";
6
6
 
7
7
  // builtin/extensions/init/index.ts
8
8
  import fs from "node:fs";
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  Type
4
- } from "../../../chunks/chunk-XXGYUYXI.js";
4
+ } from "../../../chunks/chunk-BPSCGGVF.js";
5
5
  import {
6
6
  __commonJS,
7
7
  __export,
8
8
  __require,
9
9
  __toESM
10
- } from "../../../chunks/chunk-LZQXQOPJ.js";
10
+ } from "../../../chunks/chunk-RZGYXAJU.js";
11
11
 
12
12
  // ../../node_modules/isexe/windows.js
13
13
  var require_windows = __commonJS({
@@ -3,11 +3,12 @@ import {
3
3
  distillWorkerLogPath,
4
4
  readDistillWorkerLog,
5
5
  spawnDistillWorker
6
- } from "../../../chunks/chunk-GY47MKCJ.js";
6
+ } from "../../../chunks/chunk-IZDNZW3S.js";
7
7
  import {
8
8
  getConfigDir,
9
- getSettingsPath
10
- } from "../../../chunks/chunk-ILUHTKF3.js";
9
+ getSettingsPath,
10
+ init_config
11
+ } from "../../../chunks/chunk-UCKOXAME.js";
11
12
  import {
12
13
  DEFAULT_MEMORY_INJECTION_BUDGET,
13
14
  MemoryStore,
@@ -19,18 +20,19 @@ import {
19
20
  saveAttestedEntry,
20
21
  searchMemory,
21
22
  todayKey
22
- } from "../../../chunks/chunk-N5B5IGJ6.js";
23
- import "../../../chunks/chunk-XMOWWL4B.js";
24
- import "../../../chunks/chunk-B4N5LJMD.js";
25
- import "../../../chunks/chunk-6JEYRAQM.js";
23
+ } from "../../../chunks/chunk-YNTIOWCD.js";
24
+ import "../../../chunks/chunk-XO3NM7BB.js";
25
+ import "../../../chunks/chunk-IPLMGAML.js";
26
+ import "../../../chunks/chunk-R7VO46EK.js";
26
27
  import {
27
28
  Type
28
- } from "../../../chunks/chunk-XXGYUYXI.js";
29
- import "../../../chunks/chunk-LZQXQOPJ.js";
29
+ } from "../../../chunks/chunk-BPSCGGVF.js";
30
+ import "../../../chunks/chunk-RZGYXAJU.js";
30
31
 
31
32
  // builtin/extensions/memory/index.ts
32
33
  import * as fs from "node:fs";
33
34
  import * as path from "node:path";
35
+ init_config();
34
36
  function yesterdayKey() {
35
37
  const probe = /* @__PURE__ */ new Date();
36
38
  probe.setDate(probe.getDate() - 1);
@@ -1,7 +1,7 @@
1
1
  import { createRequire as __createRequire } from "node:module"; const require = __createRequire(import.meta.url);
2
2
  import {
3
3
  Type
4
- } from "../../../chunks/chunk-XXGYUYXI.js";
4
+ } from "../../../chunks/chunk-BPSCGGVF.js";
5
5
  import {
6
6
  DEFAULT_SEND_WAIT_MS,
7
7
  DISPATCH_PREFIX,
@@ -27,7 +27,7 @@ import {
27
27
  wrapInboundText,
28
28
  wrappedMessageMarker
29
29
  } from "../../../chunks/chunk-AKXEZH7K.js";
30
- import "../../../chunks/chunk-LZQXQOPJ.js";
30
+ import "../../../chunks/chunk-RZGYXAJU.js";
31
31
 
32
32
  // builtin/extensions/pie-ipc/index.ts
33
33
  import * as fs3 from "node:fs";
@@ -2,10 +2,14 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  readProcessCommandLine
4
4
  } from "../../../chunks/chunk-X6LBWHK3.js";
5
+ import {
6
+ liveSessionHolder
7
+ } from "../../../chunks/chunk-7KLWHWZD.js";
8
+ import "../../../chunks/chunk-UCKOXAME.js";
5
9
  import {
6
10
  Type
7
- } from "../../../chunks/chunk-XXGYUYXI.js";
8
- import "../../../chunks/chunk-LZQXQOPJ.js";
11
+ } from "../../../chunks/chunk-BPSCGGVF.js";
12
+ import "../../../chunks/chunk-RZGYXAJU.js";
9
13
 
10
14
  // builtin/extensions/pie-proc/index.ts
11
15
  import { spawn } from "node:child_process";
@@ -15,6 +19,20 @@ import * as fs from "node:fs";
15
19
  import * as os from "node:os";
16
20
  import * as path from "node:path";
17
21
  var require_ = createRequire(import.meta.url);
22
+ function resolveOperatorSessionsDir() {
23
+ try {
24
+ const { getSessionsDir } = require_("../../../src/config.js");
25
+ return getSessionsDir();
26
+ } catch {
27
+ const override = process.env.PIE_SESSIONS_DIR;
28
+ if (override !== void 0 && override !== "") {
29
+ if (override === "~") return path.join(os.homedir(), ".pie", "sessions");
30
+ if (override.startsWith("~/")) return path.join(os.homedir(), override.slice(2));
31
+ if (path.isAbsolute(override)) return override;
32
+ }
33
+ return path.join(os.homedir(), ".pie", "sessions");
34
+ }
35
+ }
18
36
  var DEFAULT_CONFIG = { allowCwd: [], maxWorkers: 5, killGraceMs: 15e3, defaultTtlMs: 0 };
19
37
  var IM_FORWARD_ALLOWED_KEYS = /* @__PURE__ */ new Set(["enabled", "provider", "chatId", "openId", "allowUsers", "retryBackoffMs", "larkCliProfile"]);
20
38
  var ONESHOT_TASK_ENV = "PIE_PROC_ONESHOT_TASK";
@@ -160,9 +178,10 @@ function workerLiveness(record) {
160
178
  } catch {
161
179
  return "dead";
162
180
  }
181
+ const marker = record.launchToken ?? record.sessionId;
163
182
  const cmd = readProcessCommandLine(record.pid);
164
183
  if (cmd === void 0) return "unknown";
165
- return cmd.includes(record.sessionId) ? "alive" : "dead";
184
+ return cmd.includes(marker) ? "alive" : "dead";
166
185
  }
167
186
  function canonicalDir(dir) {
168
187
  const resolved = path.resolve(expandTilde(dir));
@@ -397,11 +416,36 @@ function pieProc(ctx) {
397
416
  if (params.kind === "oneshot" && params.task.startsWith("-")) throw new Error(`oneshot task must not start with "-" (got "${params.task.slice(0, 20)}\u2026")`);
398
417
  if (params.kind === "oneshot" && params.imForward) throw new Error("imForward applies to resident workers only");
399
418
  if (params.kind !== "resident" && params.ttlMs !== void 0) throw new Error("ttlMs applies to resident workers only");
419
+ if (params.kind !== "resident" && params.resumeSessionId) throw new Error("resumeSessionId applies to resident workers only");
400
420
  const canonicalCwd = cwdAllowedOrThrow(params.cwd, currentConfig().allowCwd);
401
421
  const entry = cliEntry();
402
422
  if (!entry) throw new Error("cannot resolve a trusted pie entry point (refusing to spawn)");
423
+ let resumeSessionId;
424
+ if (params.resumeSessionId) {
425
+ if (!/^[A-Za-z0-9][A-Za-z0-9-_]{5,63}$/.test(params.resumeSessionId)) throw new Error(`invalid resumeSessionId "${params.resumeSessionId}"`);
426
+ const globalSessionsDir = resolveOperatorSessionsDir();
427
+ const headPath = path.join(globalSessionsDir, params.resumeSessionId, "head.json");
428
+ let recordedCwd;
429
+ try {
430
+ const head = JSON.parse(fs.readFileSync(headPath, "utf8"));
431
+ recordedCwd = head.metadata?.cwd;
432
+ } catch {
433
+ throw new Error(`resumeSessionId "${params.resumeSessionId}" not found in the global session store (${globalSessionsDir})`);
434
+ }
435
+ if (typeof recordedCwd !== "string" || !recordedCwd) throw new Error(`session "${params.resumeSessionId}" has no recorded cwd; resume requires one`);
436
+ let canonicalRecorded = recordedCwd;
437
+ try {
438
+ canonicalRecorded = fs.realpathSync(recordedCwd);
439
+ } catch {
440
+ }
441
+ if (canonicalRecorded !== canonicalCwd) throw new Error(`resume cwd mismatch: session recorded "${recordedCwd}" but spawn cwd is "${params.cwd}" \u2014 resume in the session's own directory`);
442
+ const holder = liveSessionHolder(params.resumeSessionId);
443
+ if (holder) throw new Error(`session "${params.resumeSessionId}" is owned by a live host (pid ${holder.pid} ${holder.holder}); close it or resume another session`);
444
+ resumeSessionId = params.resumeSessionId;
445
+ }
403
446
  const generation = `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 8)}`;
404
- const sessionId = `pie-proc-${params.name}-${generation}`;
447
+ const launchToken = `pie-proc-${params.name}-${generation}`;
448
+ const sessionId = resumeSessionId ?? launchToken;
405
449
  const imForward = sanitizeImForward(params.imForward);
406
450
  casRegistry((snap) => {
407
451
  const current = snap.workers;
@@ -437,6 +481,8 @@ function pieProc(ctx) {
437
481
  const reservation = {
438
482
  name: params.name,
439
483
  sessionId,
484
+ launchToken,
485
+ ...resumeSessionId ? { resumedFrom: resumeSessionId } : {},
440
486
  generation,
441
487
  pid: 0,
442
488
  cwd: "",
@@ -483,7 +529,19 @@ function pieProc(ctx) {
483
529
  }
484
530
  fs.mkdirSync(logDir(), { recursive: true });
485
531
  const logFile = fs.openSync(path.join(logDir(), `${params.name}.jsonl`), "a");
486
- const args = params.kind === "resident" ? [...loaderArgs(), entry, "--json-events", "--idle", "--session-id", sessionId] : [...loaderArgs(), entry, "--session-id", sessionId];
532
+ const args = params.kind === "resident" ? [
533
+ ...loaderArgs(),
534
+ entry,
535
+ "--json-events",
536
+ "--idle",
537
+ "--session-id",
538
+ sessionId,
539
+ // 4.4.1 resume: --resume-required makes a failed load a HARD exit
540
+ // (never silently mint a same-id empty session); --worker-token
541
+ // keeps argv liveness matching on the per-launch token even when
542
+ // --session-id carries a reusable business session id.
543
+ ...resumeSessionId ? ["--resume-required", "--worker-token", launchToken] : []
544
+ ] : [...loaderArgs(), entry, "--session-id", sessionId];
487
545
  const inheritedIpcRoot = path.resolve(expandTilde(process.env.PIE_IPC_CONFIG_DIR ?? configDirRoot()));
488
546
  const { PIE_DEFAULT_PROVIDER: _p, PIE_DEFAULT_MODEL: _m, PIE_MANAGER_BOOTSTRAP: _b, PIE_PROC_CURATED_NAME: _c, ...inheritedEnv } = process.env;
489
547
  const childEnv = {
@@ -493,6 +551,7 @@ function pieProc(ctx) {
493
551
  PIE_IPC_DISPLAY_NAME: params.kind === "resident" ? params.name : process.env.PIE_IPC_DISPLAY_NAME
494
552
  };
495
553
  if (params.kind === "oneshot") childEnv[ONESHOT_TASK_ENV] = params.task ?? "";
554
+ if (resumeSessionId) childEnv.PIE_SESSIONS_DIR = resolveOperatorSessionsDir();
496
555
  try {
497
556
  child = spawn(process.execPath, args, {
498
557
  cwd: canonicalCwd,
@@ -517,6 +576,8 @@ function pieProc(ctx) {
517
576
  const record = {
518
577
  name: params.name,
519
578
  sessionId,
579
+ launchToken,
580
+ ...resumeSessionId ? { resumedFrom: resumeSessionId } : {},
520
581
  generation,
521
582
  pid: child.pid,
522
583
  cwd: canonicalCwd,
@@ -618,7 +679,8 @@ function pieProc(ctx) {
618
679
  task: Type.Optional(Type.String({ description: "oneshot: the task prompt (non-empty, must not start with '-')" })),
619
680
  ttlMs: Type.Optional(Type.Number({ description: "spawn (resident only): idle TTL in ms (0 = never reap)", minimum: 0, maximum: 864e5 })),
620
681
  force: Type.Optional(Type.Boolean({ description: "kill: skip graceful SIGTERM" })),
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)" }))
682
+ 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)" })),
683
+ resumeSessionId: Type.Optional(Type.String({ description: "spawn (resident only): RESUME an existing business session instead of creating a new one. The session must exist in the global store (~/.pie/sessions), its recorded cwd must equal cwd, and no live host may own it. The worker keeps the session's context, IM topic anchors and model; its own config stays isolated. Use when the user wants an old session to CONTINUE its work (e.g. '\u8BA9 TBD \u7684\u90A3\u4E2A\u4F1A\u8BDD\u63A5\u7740\u67E5'), never for fresh tasks." }))
622
684
  }),
623
685
  risk: { riskClass: "process_lifecycle", requiresPermission: true, externalSideEffect: true, readsNetwork: false, writesNetwork: false, concurrencySafe: false },
624
686
  renderHint: { summary: (args) => `${String(args.action)}${args.name ? ` ${String(args.name)}` : ""}` },
@@ -652,7 +714,8 @@ function pieProc(ctx) {
652
714
  kind: args.kind ?? "resident",
653
715
  ttlMs: typeof args.ttlMs === "number" ? args.ttlMs : void 0,
654
716
  task: args.task,
655
- imForward: args.imForward
717
+ imForward: args.imForward,
718
+ resumeSessionId: args.resumeSessionId
656
719
  });
657
720
  }
658
721
  if (action === "kill") {
@@ -6,14 +6,14 @@ import {
6
6
  createPlanCapability,
7
7
  markCompletedPlanSteps,
8
8
  restoreExecutionState
9
- } from "../../../chunks/chunk-N5B5IGJ6.js";
10
- import "../../../chunks/chunk-XMOWWL4B.js";
11
- import "../../../chunks/chunk-B4N5LJMD.js";
12
- import "../../../chunks/chunk-6JEYRAQM.js";
9
+ } from "../../../chunks/chunk-YNTIOWCD.js";
10
+ import "../../../chunks/chunk-XO3NM7BB.js";
11
+ import "../../../chunks/chunk-IPLMGAML.js";
12
+ import "../../../chunks/chunk-R7VO46EK.js";
13
13
  import {
14
14
  Type
15
- } from "../../../chunks/chunk-XXGYUYXI.js";
16
- import "../../../chunks/chunk-LZQXQOPJ.js";
15
+ } from "../../../chunks/chunk-BPSCGGVF.js";
16
+ import "../../../chunks/chunk-RZGYXAJU.js";
17
17
 
18
18
  // builtin/extensions/plan-mode/index.ts
19
19
  import { randomUUID } from "node:crypto";
@@ -5,21 +5,22 @@ import {
5
5
  createCliRetryPolicy,
6
6
  formatTransportLifecycle,
7
7
  logTransportLifecycle
8
- } from "../../../chunks/chunk-I7PBXG5Q.js";
8
+ } from "../../../chunks/chunk-7LTQLJJF.js";
9
9
  import {
10
- getConfigDir
11
- } from "../../../chunks/chunk-ILUHTKF3.js";
10
+ getConfigDir,
11
+ init_config
12
+ } from "../../../chunks/chunk-UCKOXAME.js";
12
13
  import {
13
14
  SUBAGENT_SESSION_RECORD_VERSION,
14
15
  createPolicyEnforcedTools,
15
16
  createSharedFileSystemTools,
16
17
  createSubagentCapability
17
- } from "../../../chunks/chunk-N5B5IGJ6.js";
18
- import "../../../chunks/chunk-XMOWWL4B.js";
19
- import "../../../chunks/chunk-B4N5LJMD.js";
20
- import "../../../chunks/chunk-6JEYRAQM.js";
21
- import "../../../chunks/chunk-XXGYUYXI.js";
22
- import "../../../chunks/chunk-LZQXQOPJ.js";
18
+ } from "../../../chunks/chunk-YNTIOWCD.js";
19
+ import "../../../chunks/chunk-XO3NM7BB.js";
20
+ import "../../../chunks/chunk-IPLMGAML.js";
21
+ import "../../../chunks/chunk-R7VO46EK.js";
22
+ import "../../../chunks/chunk-BPSCGGVF.js";
23
+ import "../../../chunks/chunk-RZGYXAJU.js";
23
24
 
24
25
  // src/files/subagent-session-store.ts
25
26
  import { execFileSync } from "node:child_process";
@@ -380,6 +381,7 @@ function createSubagentSessionStore(sessionsDir, log, deps) {
380
381
  }
381
382
 
382
383
  // builtin/extensions/subagent/index.ts
384
+ init_config();
383
385
  import * as path2 from "path";
384
386
  function preserveModelResolution(r) {
385
387
  return r === void 0 ? void 0 : { ...r, model: r.model };
@@ -8,12 +8,12 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-N5B5IGJ6.js";
12
- import "../../../chunks/chunk-XMOWWL4B.js";
13
- import "../../../chunks/chunk-B4N5LJMD.js";
14
- import "../../../chunks/chunk-6JEYRAQM.js";
15
- import "../../../chunks/chunk-XXGYUYXI.js";
16
- import "../../../chunks/chunk-LZQXQOPJ.js";
11
+ } from "../../../chunks/chunk-YNTIOWCD.js";
12
+ import "../../../chunks/chunk-XO3NM7BB.js";
13
+ import "../../../chunks/chunk-IPLMGAML.js";
14
+ import "../../../chunks/chunk-R7VO46EK.js";
15
+ import "../../../chunks/chunk-BPSCGGVF.js";
16
+ import "../../../chunks/chunk-RZGYXAJU.js";
17
17
 
18
18
  // builtin/extensions/todo/index.ts
19
19
  var EXECUTION_METADATA_KEY = "executionState";
@@ -4366,7 +4366,7 @@ import path from "node:path";
4366
4366
  // src/config.ts
4367
4367
  import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
4368
4368
  import { homedir } from "os";
4369
- import { dirname, join } from "path";
4369
+ import { dirname, isAbsolute, join } from "path";
4370
4370
  import { fileURLToPath } from "url";
4371
4371
  var __filename = fileURLToPath(import.meta.url);
4372
4372
  var __dirname = dirname(__filename);
@@ -41,7 +41,7 @@ import path from "node:path";
41
41
  // src/config.ts
42
42
  import { existsSync, mkdirSync, readFileSync, renameSync } from "fs";
43
43
  import { homedir } from "os";
44
- import { dirname, join } from "path";
44
+ import { dirname, isAbsolute, join } from "path";
45
45
  import { fileURLToPath } from "url";
46
46
  var __filename = fileURLToPath(import.meta.url);
47
47
  var __dirname = dirname(__filename);
@@ -3,9 +3,9 @@ import {
3
3
  AuthStorage,
4
4
  FileAuthStorageBackend,
5
5
  InMemoryAuthStorageBackend
6
- } from "./chunk-6DNYGVZP.js";
7
- import "./chunk-ILUHTKF3.js";
8
- import "./chunk-LZQXQOPJ.js";
6
+ } from "./chunk-OV7SLSHR.js";
7
+ import "./chunk-UCKOXAME.js";
8
+ import "./chunk-RZGYXAJU.js";
9
9
  export {
10
10
  AuthStorage,
11
11
  FileAuthStorageBackend,