@cydm/pie 4.14.0 → 4.15.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.
Files changed (33) hide show
  1. package/README.md +5 -5
  2. package/dist/builtin/extensions/ask-user/index.js +4 -4
  3. package/dist/builtin/extensions/cron/index.js +70 -17
  4. package/dist/builtin/extensions/im-forward/index.js +889 -205
  5. package/dist/builtin/extensions/memory/index.js +6 -6
  6. package/dist/builtin/extensions/memory/package.json +1 -2
  7. package/dist/builtin/extensions/pie-proc/README.md +12 -3
  8. package/dist/builtin/extensions/pie-proc/index.js +88 -45
  9. package/dist/builtin/extensions/plan-mode/index.js +4 -4
  10. package/dist/builtin/extensions/subagent/index.js +5 -5
  11. package/dist/builtin/extensions/todo/index.js +4 -4
  12. package/dist/chunks/{chunk-FD3KBPDR.js → chunk-6AYPNTCO.js} +8 -8
  13. package/dist/chunks/{chunk-JJH77AUU.js → chunk-J6EZ335F.js} +8 -7
  14. package/dist/chunks/{chunk-EZZTMDWZ.js → chunk-JE53PC46.js} +1064 -161
  15. package/dist/chunks/{chunk-BOQIGMGQ.js → chunk-LIA52LJU.js} +3 -3
  16. package/dist/chunks/{chunk-26KRUYZH.js → chunk-MTH6QSYD.js} +1 -1
  17. package/dist/chunks/{chunk-UYDS75SI.js → chunk-NAMH667S.js} +11 -15
  18. package/dist/chunks/{chunk-IK2FR2YF.js → chunk-VWDCKHCC.js} +1 -1
  19. package/dist/chunks/{chunk-MCR4JYI6.js → chunk-YKV45EMY.js} +313 -149
  20. package/dist/chunks/{chunk-JKO42HZW.js → chunk-ZBIR5YS7.js} +1 -1
  21. package/dist/chunks/{chunk-KGWKRO7Z.js → chunk-ZH6EAKVM.js} +2 -2
  22. package/dist/chunks/{host-image-fallback-LPHB5CTL.js → host-image-fallback-GX2KXZXQ.js} +1 -1
  23. package/dist/chunks/{memory-git-ZJN6SPIU.js → memory-git-BJMYZHIE.js} +5 -5
  24. package/dist/chunks/{model-registry-GLBIUOJR.js → model-registry-T6EMM66I.js} +2 -2
  25. package/dist/chunks/{read-file-understanding-DFJPTTSB.js → read-file-understanding-ZRE5KDG3.js} +5 -5
  26. package/dist/chunks/{src-KZ7YID3I.js → src-DLAIQCKP.js} +3 -3
  27. package/dist/chunks/{src-ALHMJZ5R.js → src-FWL3LCBK.js} +2 -2
  28. package/dist/chunks/{src-LEXKDSFV.js → src-OP6LFLR6.js} +8 -4
  29. package/dist/chunks/{src-76Q33OY5.js → src-XJKZIY3S.js} +11 -1
  30. package/dist/chunks/{test-stream-OVGDTXOY.js → test-stream-P3CUEGEE.js} +1 -1
  31. package/dist/cli.js +408 -52
  32. package/models.schema.json +4 -0
  33. package/package.json +2 -2
@@ -3,10 +3,10 @@ import {
3
3
  distillWorkerLogPath,
4
4
  readDistillWorkerLog,
5
5
  spawnDistillWorker
6
- } from "../../../chunks/chunk-FD3KBPDR.js";
6
+ } from "../../../chunks/chunk-6AYPNTCO.js";
7
7
  import {
8
8
  commitCuratedMemoryBestEffort
9
- } from "../../../chunks/chunk-IK2FR2YF.js";
9
+ } from "../../../chunks/chunk-VWDCKHCC.js";
10
10
  import {
11
11
  getConfigDir,
12
12
  getSessionsDir,
@@ -27,12 +27,12 @@ import {
27
27
  saveAttestedEntry,
28
28
  searchMemory,
29
29
  todayKey
30
- } from "../../../chunks/chunk-EZZTMDWZ.js";
30
+ } from "../../../chunks/chunk-JE53PC46.js";
31
31
  import {
32
32
  FileSessionStore
33
- } from "../../../chunks/chunk-JJH77AUU.js";
34
- import "../../../chunks/chunk-26KRUYZH.js";
35
- import "../../../chunks/chunk-MCR4JYI6.js";
33
+ } from "../../../chunks/chunk-J6EZ335F.js";
34
+ import "../../../chunks/chunk-MTH6QSYD.js";
35
+ import "../../../chunks/chunk-YKV45EMY.js";
36
36
  import {
37
37
  Type
38
38
  } from "../../../chunks/chunk-XXGYUYXI.js";
@@ -6,8 +6,7 @@
6
6
  "type": "module",
7
7
  "pie": {
8
8
  "name": "memory",
9
- "main": "index.js",
10
- "defaultEnablement": false
9
+ "main": "index.js"
11
10
  },
12
11
  "keywords": [
13
12
  "pie",
@@ -6,8 +6,11 @@ directories, isolated agent dirs, caps, TTL sweeping, and an audit ledger.
6
6
 
7
7
  ## Host gating
8
8
 
9
- Activates on `longLived` (interactive TUI and resident json-events hosts —
10
- the manager). One-shot print hosts never own workers.
9
+ Role-pruned to the resident manager (`capabilities.unattended === true` and
10
+ `PIE_PROC_CURATED_NAME === "manager"`): both the `pie_proc` tool and the 60s
11
+ background `sweepTimer` activate only on the manager. Interactive TUI hosts,
12
+ worker processes, and one-shot print hosts never register the tool or run
13
+ background registry sweeps.
11
14
 
12
15
  ## Tool: `pie_proc`
13
16
 
@@ -85,7 +88,13 @@ fallback on Windows 11+); a probe failure is `unknown`, and unknown is
85
88
  never signalled. A v1 registry (records without generation) fails CLOSED
86
89
  with a migration error. Abandoned pending reservations are reaped only
87
90
  when their reserver process is confirmed dead (same-process aborted spawns
88
- are retried by the sweep). Every spawn/kill/TTL reap goes to the extension
91
+ are retried by the sweep). Idle-activity persistence is bounded to avoid
92
+ unbounded revision churn: `ttl === 0` resident workers never write
93
+ `lastActiveAt` bumps on log mtime changes (`pie_proc list` reads live
94
+ activity on demand), while `ttl > 0` workers throttle `lastActiveAt`
95
+ persists, maintain an in-memory high-water mark per generation, and
96
+ re-verify live activity immediately before authorizing any idle-TTL
97
+ `SIGTERM`. Every spawn/kill/TTL reap goes to the extension
89
98
  log (verbose mode / host transcript).
90
99
 
91
100
  ## Design notes
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  registerWorkerLifecycleBridge,
4
4
  syncInheritedWorkerModels
5
- } from "../../../chunks/chunk-JKO42HZW.js";
5
+ } from "../../../chunks/chunk-ZBIR5YS7.js";
6
6
  import {
7
7
  readProcessCommandLine
8
8
  } from "../../../chunks/chunk-7RJXKN7N.js";
@@ -11,17 +11,18 @@ import {
11
11
  } from "../../../chunks/chunk-Q5PSWX3B.js";
12
12
  import "../../../chunks/chunk-Q4NJEPIZ.js";
13
13
  import {
14
- loadResolvedModelsConfig
15
- } from "../../../chunks/chunk-UYDS75SI.js";
14
+ loadResolvedModelsConfig,
15
+ normalizeModelClassRoutes
16
+ } from "../../../chunks/chunk-NAMH667S.js";
16
17
  import "../../../chunks/chunk-CBDQJMUI.js";
17
18
  import {
18
19
  redactText
19
- } from "../../../chunks/chunk-EZZTMDWZ.js";
20
+ } from "../../../chunks/chunk-JE53PC46.js";
20
21
  import {
21
22
  isCompactSummaryMessage
22
- } from "../../../chunks/chunk-JJH77AUU.js";
23
- import "../../../chunks/chunk-26KRUYZH.js";
24
- import "../../../chunks/chunk-MCR4JYI6.js";
23
+ } from "../../../chunks/chunk-J6EZ335F.js";
24
+ import "../../../chunks/chunk-MTH6QSYD.js";
25
+ import "../../../chunks/chunk-YKV45EMY.js";
25
26
  import {
26
27
  Type
27
28
  } from "../../../chunks/chunk-XXGYUYXI.js";
@@ -674,12 +675,10 @@ import * as fs3 from "node:fs";
674
675
  import * as path3 from "node:path";
675
676
  var SPAWN_THINKING_LEVELS = /* @__PURE__ */ new Set(["off", "minimal", "low", "medium", "high", "xhigh", "max"]);
676
677
  var MODEL_REF_RE = /^[^/\s]+\/\S+$/;
677
- function collectModelRefsFromRaw(raw) {
678
+ function collectModelRefsFromConfig(config) {
678
679
  const refs = /* @__PURE__ */ new Set();
679
- if (!raw || typeof raw !== "object") return refs;
680
- const doc = raw;
681
- if (doc.providers && typeof doc.providers === "object") {
682
- for (const [provider, cfg] of Object.entries(doc.providers)) {
680
+ if (config.profiles) {
681
+ for (const [provider, cfg] of Object.entries(config.profiles)) {
683
682
  if (!Array.isArray(cfg?.models)) continue;
684
683
  for (const m of cfg.models) {
685
684
  if (typeof m?.id === "string" && m.id.trim()) {
@@ -688,15 +687,15 @@ function collectModelRefsFromRaw(raw) {
688
687
  }
689
688
  }
690
689
  }
691
- if (doc.defaults && typeof doc.defaults === "object") {
692
- if (typeof doc.defaults.provider === "string" && typeof doc.defaults.modelId === "string") {
693
- refs.add(`${doc.defaults.provider.trim()}/${doc.defaults.modelId.trim()}`);
694
- }
695
- if (doc.defaults.modelClasses && typeof doc.defaults.modelClasses === "object") {
696
- for (const entry of Object.values(doc.defaults.modelClasses)) {
697
- const list = Array.isArray(entry) ? entry : [entry];
698
- for (const cls of list) {
699
- if (typeof cls?.provider === "string" && typeof cls?.modelId === "string") {
690
+ if (config.defaults) {
691
+ if (typeof config.defaults.provider === "string" && typeof config.defaults.modelId === "string") {
692
+ refs.add(`${config.defaults.provider.trim()}/${config.defaults.modelId.trim()}`);
693
+ }
694
+ if (config.defaults.modelClasses) {
695
+ for (const entry of Object.values(config.defaults.modelClasses)) {
696
+ for (const cls of normalizeModelClassRoutes(entry)) {
697
+ if (!cls || typeof cls !== "object") continue;
698
+ if (typeof cls.provider === "string" && typeof cls.modelId === "string") {
700
699
  refs.add(`${cls.provider.trim()}/${cls.modelId.trim()}`);
701
700
  }
702
701
  }
@@ -705,17 +704,39 @@ function collectModelRefsFromRaw(raw) {
705
704
  }
706
705
  return refs;
707
706
  }
707
+ function collectModelRefsFromMinimalFixture(raw) {
708
+ const refs = /* @__PURE__ */ new Set();
709
+ if (!raw || typeof raw !== "object") return refs;
710
+ const doc = raw;
711
+ for (const group of [doc.profiles, doc.providers]) {
712
+ if (!group || typeof group !== "object") continue;
713
+ for (const [provider, cfg] of Object.entries(group)) {
714
+ if (!Array.isArray(cfg?.models)) continue;
715
+ for (const m of cfg.models) {
716
+ if (typeof m?.id === "string" && m.id.trim()) {
717
+ refs.add(`${provider.trim()}/${m.id.trim()}`);
718
+ }
719
+ }
720
+ }
721
+ }
722
+ if (doc.defaults && typeof doc.defaults === "object") {
723
+ for (const ref of collectModelRefsFromConfig({ defaults: doc.defaults })) {
724
+ refs.add(ref);
725
+ }
726
+ }
727
+ return refs;
728
+ }
708
729
  function readKnownModelRefs(modelsPath) {
709
730
  if (!fs3.existsSync(modelsPath)) return void 0;
710
731
  try {
711
732
  const resolved = loadResolvedModelsConfig(modelsPath);
712
- const refs = collectModelRefsFromRaw(resolved.config);
733
+ const refs = collectModelRefsFromConfig(resolved.config);
713
734
  if (refs.size > 0) return refs;
714
735
  } catch {
715
736
  }
716
737
  try {
717
738
  const raw = JSON.parse(fs3.readFileSync(modelsPath, "utf8"));
718
- const refs = collectModelRefsFromRaw(raw);
739
+ const refs = collectModelRefsFromMinimalFixture(raw);
719
740
  return refs.size > 0 ? refs : void 0;
720
741
  } catch {
721
742
  return void 0;
@@ -779,12 +800,21 @@ function readModelsJsonDefault(modelsPath) {
779
800
  const known = readKnownModelRefs(modelsPath);
780
801
  if (!known || known.size === 0) return void 0;
781
802
  try {
782
- const raw = JSON.parse(fs3.readFileSync(modelsPath, "utf8"));
783
- if (typeof raw.defaults?.provider === "string" && typeof raw.defaults?.modelId === "string") {
784
- const ref = `${raw.defaults.provider.trim()}/${raw.defaults.modelId.trim()}`;
803
+ const resolved = loadResolvedModelsConfig(modelsPath);
804
+ const { provider, modelId } = resolved.config.defaults ?? {};
805
+ if (typeof provider === "string" && typeof modelId === "string") {
806
+ const ref = `${provider.trim()}/${modelId.trim()}`;
785
807
  if (MODEL_REF_RE.test(ref)) return ref;
786
808
  }
787
809
  } catch {
810
+ try {
811
+ const raw = JSON.parse(fs3.readFileSync(modelsPath, "utf8"));
812
+ if (typeof raw.defaults?.provider === "string" && typeof raw.defaults?.modelId === "string") {
813
+ const ref = `${raw.defaults.provider.trim()}/${raw.defaults.modelId.trim()}`;
814
+ if (MODEL_REF_RE.test(ref)) return ref;
815
+ }
816
+ } catch {
817
+ }
788
818
  }
789
819
  return [...known][0];
790
820
  }
@@ -1365,15 +1395,13 @@ function pieProc(ctx) {
1365
1395
  }
1366
1396
  return logTime;
1367
1397
  };
1368
- const persistActivity = (record, at) => {
1369
- try {
1370
- updateRegistry((snap) => ({
1371
- next: snap.workers.map((w) => w.generation === record.generation && at > w.lastActiveAt ? { ...w, lastActiveAt: at } : w),
1372
- result: void 0
1373
- }));
1374
- } catch {
1375
- }
1398
+ const inMemoryActivity = /* @__PURE__ */ new Map();
1399
+ const recordObservedActivity = (record) => {
1400
+ const fresh = Math.max(record.lastActiveAt, inMemoryActivity.get(record.generation) ?? 0, observeActivity(record));
1401
+ inMemoryActivity.set(record.generation, fresh);
1402
+ return fresh;
1376
1403
  };
1404
+ const activityPersistThresholdMs = (ttlMs) => Math.min(6e4, Math.floor(ttlMs / 4));
1377
1405
  const releaseReservation = (generation) => {
1378
1406
  try {
1379
1407
  updateRegistry((snap) => ({
@@ -1435,10 +1463,11 @@ function pieProc(ctx) {
1435
1463
  }
1436
1464
  }
1437
1465
  for (const w of readRegistryUncached().workers) {
1438
- const observed = Math.max(w.lastActiveAt, observeActivity(w));
1439
- if (observed > w.lastActiveAt) persistActivity(w, observed);
1466
+ recordObservedActivity(w);
1440
1467
  }
1468
+ const liveGenerations = /* @__PURE__ */ new Set();
1441
1469
  casRegistry((snap) => {
1470
+ liveGenerations.clear();
1442
1471
  const cutoff = Date.now();
1443
1472
  let changed = false;
1444
1473
  const keep = [];
@@ -1491,10 +1520,21 @@ function pieProc(ctx) {
1491
1520
  continue;
1492
1521
  }
1493
1522
  const ttl = w.kind === "resident" ? w.ttlMs ?? currentConfig().defaultTtlMs : 0;
1494
- if (ttl > 0 && liveness === "alive" && cutoff - Math.max(w.lastActiveAt, observeActivity(w)) > ttl) {
1495
- signalWorkerProcessGroup(w.pid, "SIGTERM");
1496
- ctx.log(`pie-proc: idle TTL signaled worker ${w.name} (idle > ${Math.round(ttl / 1e3)}s, identity verified)`);
1497
- keep.push({ ...w, ttlMs: 0, orphanSignaledAt: cutoff });
1523
+ let observed = Math.max(w.lastActiveAt, inMemoryActivity.get(w.generation) ?? 0);
1524
+ if (ttl > 0 && liveness === "alive" && cutoff - observed > ttl) {
1525
+ observed = recordObservedActivity(w);
1526
+ if (Date.now() - observed > ttl) {
1527
+ signalWorkerProcessGroup(w.pid, "SIGTERM");
1528
+ ctx.log(`pie-proc: idle TTL signaled worker ${w.name} (idle > ${Math.round(ttl / 1e3)}s, identity verified)`);
1529
+ keep.push({ ...w, lastActiveAt: observed, ttlMs: 0, orphanSignaledAt: cutoff });
1530
+ liveGenerations.add(w.generation);
1531
+ changed = true;
1532
+ continue;
1533
+ }
1534
+ }
1535
+ liveGenerations.add(w.generation);
1536
+ if (ttl > 0 && liveness === "alive" && observed > w.lastActiveAt && observed - w.lastActiveAt >= activityPersistThresholdMs(ttl)) {
1537
+ keep.push({ ...w, lastActiveAt: observed });
1498
1538
  changed = true;
1499
1539
  continue;
1500
1540
  }
@@ -1503,15 +1543,13 @@ function pieProc(ctx) {
1503
1543
  if (!changed) return { abort: { value: void 0 } };
1504
1544
  return { next: keep, result: void 0 };
1505
1545
  });
1546
+ for (const gen of [...inMemoryActivity.keys()]) {
1547
+ if (!liveGenerations.has(gen)) inMemoryActivity.delete(gen);
1548
+ }
1506
1549
  } catch (error) {
1507
1550
  ctx.log(`pie-proc: sweep skipped: ${error instanceof Error ? error.message : String(error)}`);
1508
1551
  }
1509
1552
  };
1510
- const sweepTimer = setInterval(sweep, 6e4);
1511
- sweepTimer.unref?.();
1512
- ctx.registerCleanup?.(() => {
1513
- clearInterval(sweepTimer);
1514
- });
1515
1553
  const spawnWorker = async (params) => {
1516
1554
  if (!safeName(params.name)) throw new Error(`invalid worker name "${params.name}" (use [a-z0-9-_], max 48)`);
1517
1555
  if (params.kind === "oneshot" && (typeof params.task !== "string" || !params.task.trim())) throw new Error("oneshot spawn requires a non-empty task");
@@ -1815,6 +1853,11 @@ function pieProc(ctx) {
1815
1853
  ctx.log("pie-proc: tool not registered (role-pruned; manager-only)");
1816
1854
  return;
1817
1855
  }
1856
+ const sweepTimer = setInterval(sweep, 6e4);
1857
+ sweepTimer.unref?.();
1858
+ ctx.registerCleanup?.(() => {
1859
+ clearInterval(sweepTimer);
1860
+ });
1818
1861
  const unregisterPanelBridge = registerPieProcPanelBridge({
1819
1862
  pieProcDir,
1820
1863
  operatorSessionsDir: resolveOperatorSessionsDir,
@@ -6,10 +6,10 @@ import {
6
6
  createPlanCapability,
7
7
  markCompletedPlanSteps,
8
8
  restoreExecutionState
9
- } from "../../../chunks/chunk-EZZTMDWZ.js";
10
- import "../../../chunks/chunk-JJH77AUU.js";
11
- import "../../../chunks/chunk-26KRUYZH.js";
12
- import "../../../chunks/chunk-MCR4JYI6.js";
9
+ } from "../../../chunks/chunk-JE53PC46.js";
10
+ import "../../../chunks/chunk-J6EZ335F.js";
11
+ import "../../../chunks/chunk-MTH6QSYD.js";
12
+ import "../../../chunks/chunk-YKV45EMY.js";
13
13
  import {
14
14
  Type
15
15
  } from "../../../chunks/chunk-XXGYUYXI.js";
@@ -5,7 +5,7 @@ import {
5
5
  createCliRetryPolicy,
6
6
  formatTransportLifecycle,
7
7
  logTransportLifecycle
8
- } from "../../../chunks/chunk-BOQIGMGQ.js";
8
+ } from "../../../chunks/chunk-LIA52LJU.js";
9
9
  import {
10
10
  getConfigDir
11
11
  } from "../../../chunks/chunk-CBDQJMUI.js";
@@ -14,10 +14,10 @@ import {
14
14
  createPolicyEnforcedTools,
15
15
  createSharedFileSystemTools,
16
16
  createSubagentCapability
17
- } from "../../../chunks/chunk-EZZTMDWZ.js";
18
- import "../../../chunks/chunk-JJH77AUU.js";
19
- import "../../../chunks/chunk-26KRUYZH.js";
20
- import "../../../chunks/chunk-MCR4JYI6.js";
17
+ } from "../../../chunks/chunk-JE53PC46.js";
18
+ import "../../../chunks/chunk-J6EZ335F.js";
19
+ import "../../../chunks/chunk-MTH6QSYD.js";
20
+ import "../../../chunks/chunk-YKV45EMY.js";
21
21
  import "../../../chunks/chunk-XXGYUYXI.js";
22
22
  import "../../../chunks/chunk-LZQXQOPJ.js";
23
23
 
@@ -8,10 +8,10 @@ import {
8
8
  executeManageTodoList,
9
9
  executionStateToTodos,
10
10
  restoreExecutionState
11
- } from "../../../chunks/chunk-EZZTMDWZ.js";
12
- import "../../../chunks/chunk-JJH77AUU.js";
13
- import "../../../chunks/chunk-26KRUYZH.js";
14
- import "../../../chunks/chunk-MCR4JYI6.js";
11
+ } from "../../../chunks/chunk-JE53PC46.js";
12
+ import "../../../chunks/chunk-J6EZ335F.js";
13
+ import "../../../chunks/chunk-MTH6QSYD.js";
14
+ import "../../../chunks/chunk-YKV45EMY.js";
15
15
  import "../../../chunks/chunk-XXGYUYXI.js";
16
16
  import "../../../chunks/chunk-LZQXQOPJ.js";
17
17
 
@@ -4,7 +4,7 @@ import {
4
4
  } from "./chunk-CBDQJMUI.js";
5
5
  import {
6
6
  createMemoryLockBackend
7
- } from "./chunk-EZZTMDWZ.js";
7
+ } from "./chunk-JE53PC46.js";
8
8
 
9
9
  // src/commands/memory-distill.ts
10
10
  import * as fs from "node:fs";
@@ -194,7 +194,7 @@ function createWikiModelCall(registry, modelClass, explicitModelSpec, timeoutMs
194
194
  };
195
195
  return async (prompt, options) => {
196
196
  const targets = resolveTargets();
197
- const complete = hooks?.completeFn ?? (await import("./src-76Q33OY5.js")).completeSimple;
197
+ const complete = hooks?.completeFn ?? (await import("./src-XJKZIY3S.js")).completeSimple;
198
198
  const runCandidate = async (model, apiKey) => {
199
199
  const invokeOnce = async () => {
200
200
  const controller = new AbortController();
@@ -225,7 +225,7 @@ function createWikiModelCall(registry, modelClass, explicitModelSpec, timeoutMs
225
225
  if (message.stopReason && message.stopReason !== "stop") {
226
226
  const detail = typeof message.errorMessage === "string" && message.errorMessage.trim() ? `: ${message.errorMessage.trim()}` : "";
227
227
  const err = new Error(`wiki model call (${model.provider}/${model.id}) ended with stopReason=${message.stopReason}${detail}`);
228
- if (message.retryable === false || message.stopReason === "length") {
228
+ if (message.retryable === false || message.remoteFailure?.quotaExhausted === true || message.stopReason === "length") {
229
229
  err.noImmediateReplay = true;
230
230
  }
231
231
  throw err;
@@ -356,12 +356,12 @@ async function runDistillWorkerMain(memoryRoot, date, noExit = false, sessionsDi
356
356
  let result;
357
357
  let wikiForError;
358
358
  try {
359
- const { ModelRegistry } = await import("./model-registry-GLBIUOJR.js");
359
+ const { ModelRegistry } = await import("./model-registry-T6EMM66I.js");
360
360
  const { AuthStorage } = await import("./auth-storage-IJEJ2TGE.js");
361
361
  const { getSessionsDir } = await import("./config-4EOI5NOU.js");
362
- const { FileSessionStore } = await import("./src-KZ7YID3I.js");
363
- const { WikiStore, runWikiBootstrap, runWikiDreamBatches, runWikiGc } = await import("./src-LEXKDSFV.js");
364
- const { commitCuratedMemoryBestEffort } = await import("./memory-git-ZJN6SPIU.js");
362
+ const { FileSessionStore } = await import("./src-DLAIQCKP.js");
363
+ const { WikiStore, runWikiBootstrap, runWikiDreamBatches, runWikiGc } = await import("./src-OP6LFLR6.js");
364
+ const { commitCuratedMemoryBestEffort } = await import("./memory-git-BJMYZHIE.js");
365
365
  const wiki = new WikiStore(memoryRoot);
366
366
  wikiForError = wiki;
367
367
  const inboxOnly = date === "__inbox__";
@@ -456,7 +456,7 @@ async function runDistillAuto(memoryRoot, days = 7, runner, sessionsDir) {
456
456
  } catch {
457
457
  }
458
458
  };
459
- const { WikiStore, countWikiInbox, todayKey } = await import("./src-LEXKDSFV.js");
459
+ const { WikiStore, countWikiInbox, todayKey } = await import("./src-OP6LFLR6.js");
460
460
  const wiki = new WikiStore(memoryRoot);
461
461
  const today = todayKey(Date.now());
462
462
  const dates = [];
@@ -2,7 +2,7 @@ import { createRequire as __createRequire } from "node:module"; const require =
2
2
  import {
3
3
  createAgentOperationError,
4
4
  getAgentFailureMetadata
5
- } from "./chunk-26KRUYZH.js";
5
+ } from "./chunk-MTH6QSYD.js";
6
6
  import {
7
7
  EMPTY_ASSISTANT_CONTENT_ERROR,
8
8
  FileSystemGateway,
@@ -10,8 +10,9 @@ import {
10
10
  detectPlatform,
11
11
  getFileSystemGateway,
12
12
  getPlatformConfig,
13
+ isQuotaOrBillingFailure,
13
14
  streamSimple
14
- } from "./chunk-MCR4JYI6.js";
15
+ } from "./chunk-YKV45EMY.js";
15
16
  import {
16
17
  Type
17
18
  } from "./chunk-XXGYUYXI.js";
@@ -818,13 +819,12 @@ import { createRequire } from "node:module";
818
819
  import { fileURLToPath } from "node:url";
819
820
 
820
821
  // ../../packages/agent-framework/src/session/remote-failure.ts
821
- var QUOTA_EXHAUSTED_PATTERN = /insufficient[_ ]quota|plan[_ ]quota[_ ](?:exhausted|exceeded|depleted)|fresh plan quota.*required|credit[_ ]protection|credit protection|credits are disabled|exceeded[_ ]current[_ ]quota|exceeded your current quota|billing[_ ]hard[_ ]limit|insufficient[_ ]balance|credit balance is too low|\barrearage\b|余额不足|\b(?:account|monthly|billing|plan) quota (?:has been |is )?(?:exhausted|exceeded|depleted)/i;
822
822
  function isDefaultQuotaExhaustedError(errorMessage) {
823
- return QUOTA_EXHAUSTED_PATTERN.test(errorMessage);
823
+ return isQuotaOrBillingFailure(errorMessage);
824
824
  }
825
825
  function classifyRemoteFailure(remote, message) {
826
826
  if (!remote || !["transient", "other", "context_overflow"].includes(remote.category)) return void 0;
827
- if (remote.category === "other" && isDefaultQuotaExhaustedError(message)) {
827
+ if (remote.quotaExhausted === true || (remote.category === "other" || remote.category === "transient") && isDefaultQuotaExhaustedError(message)) {
828
828
  return {
829
829
  kind: "auth_config",
830
830
  retryable: false,
@@ -1170,8 +1170,8 @@ function isCompactionWsOverflowError(error) {
1170
1170
  function isTransientCompactionFailure(error) {
1171
1171
  const record = error && typeof error === "object" ? error : void 0;
1172
1172
  const text = `${record?.code ?? ""} ${record?.message ?? String(error)}`;
1173
- if (record?.name === "AbortError" || /request was aborted|local abort signal|user abort|user_interrupt|interrupted by user|esc pressed|ctrl\+c|\bcancel(?:led|ed)\b|insufficient[_ ]quota|exceeded[_ ]current[_ ]quota|exceeded your current quota|insufficient[_ ]balance|credit balance is too low|\barrearage\b|余额不足|\b(?:account|monthly|billing) quota (?:has been |is )?exhausted|billing|invalid api key|unauthorized|forbidden/i.test(text)) return false;
1174
1173
  const status = record?.status ?? record?.statusCode;
1174
+ if (record?.name === "AbortError" || /request was aborted|local abort signal|user abort|user_interrupt|interrupted by user|esc pressed|ctrl\+c|\bcancel(?:led|ed)\b|invalid api key|unauthorized|forbidden/i.test(text) || isQuotaOrBillingFailure(error, status) || isQuotaOrBillingFailure(text, status)) return false;
1175
1175
  if (status !== void 0) {
1176
1176
  if (status === 400 && AGY_BRIDGE_TRANSIENT_PATTERN.test(text)) return true;
1177
1177
  return status === 429 || status >= 500 && status <= 599;
@@ -1605,7 +1605,7 @@ function createSimpleSummary(messages) {
1605
1605
  ].filter(Boolean).join("\n");
1606
1606
  }
1607
1607
  async function createCompactionSummary(messages, options = {}) {
1608
- const { model, apiKey, systemPrompt, compactPrompt, signal } = options;
1608
+ const { model, apiKey, systemPrompt, compactPrompt, signal, sessionId } = options;
1609
1609
  const throwIfAborted = () => {
1610
1610
  if (signal?.aborted) {
1611
1611
  throw new Error("Compaction aborted");
@@ -1641,6 +1641,7 @@ Return a text-only successor handoff. Do not call any tools.` }],
1641
1641
  {
1642
1642
  apiKey,
1643
1643
  signal,
1644
+ ...sessionId ? { sessionId } : {},
1644
1645
  ...forceSseFallback ? { transport: "sse" } : {}
1645
1646
  }
1646
1647
  ).result();