@e4779/pi-fabric 0.92.17-fork.3 → 0.92.24-fork.4

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 (144) hide show
  1. package/dist/agents/budget-ledger.d.ts.map +1 -1
  2. package/dist/agents/handoff-continuation.d.ts +4 -0
  3. package/dist/agents/handoff-continuation.d.ts.map +1 -0
  4. package/dist/agents/manager.d.ts.map +1 -1
  5. package/dist/agents.js +3 -3
  6. package/dist/chunks/{chunk-GXNR6NRU.js → chunk-2IAVP4O2.js} +2 -2
  7. package/dist/chunks/{chunk-2UQV52II.js → chunk-3CPWRPCE.js} +6 -6
  8. package/dist/chunks/{chunk-YK5AZ7CZ.js → chunk-3ZX76BVU.js} +3 -3
  9. package/dist/chunks/{chunk-PH7ZJ27F.js → chunk-7OH6DD3S.js} +210 -118
  10. package/dist/chunks/chunk-7OH6DD3S.js.map +7 -0
  11. package/dist/chunks/chunk-EDL4JDW7.js +184 -0
  12. package/dist/chunks/chunk-EDL4JDW7.js.map +7 -0
  13. package/dist/chunks/{chunk-RNOPHITP.js → chunk-H6DDV6E2.js} +180 -24
  14. package/dist/chunks/chunk-H6DDV6E2.js.map +7 -0
  15. package/dist/chunks/{chunk-ARLYAW2A.js → chunk-IR3PIHJM.js} +2 -1
  16. package/dist/chunks/chunk-IR3PIHJM.js.map +7 -0
  17. package/dist/chunks/{chunk-VRZNFNPB.js → chunk-IYQ5MNCW.js} +20 -17
  18. package/dist/chunks/chunk-IYQ5MNCW.js.map +7 -0
  19. package/dist/chunks/{chunk-CPSW2GW4.js → chunk-KFZYTGF5.js} +5 -5
  20. package/dist/chunks/{chunk-U6CTHPZC.js → chunk-MQG5QKGI.js} +2 -2
  21. package/dist/chunks/{chunk-CI56CW53.js → chunk-NPHCGLGH.js} +16 -10
  22. package/dist/chunks/chunk-NPHCGLGH.js.map +7 -0
  23. package/dist/chunks/{chunk-2DMJ7MEI.js → chunk-QX3TUAWO.js} +172 -141
  24. package/dist/chunks/chunk-QX3TUAWO.js.map +7 -0
  25. package/dist/chunks/chunk-RAO6TQFP.js +187 -0
  26. package/dist/chunks/chunk-RAO6TQFP.js.map +7 -0
  27. package/dist/chunks/{chunk-ZZ4LHQYJ.js → chunk-RTXZHKMS.js} +22 -13
  28. package/dist/chunks/chunk-RTXZHKMS.js.map +7 -0
  29. package/dist/chunks/{chunk-656HWVFU.js → chunk-SZUXWOO7.js} +5 -3
  30. package/dist/chunks/chunk-SZUXWOO7.js.map +7 -0
  31. package/dist/chunks/{chunk-UDFDF7IY.js → chunk-VWSXAEX6.js} +143 -54
  32. package/dist/chunks/chunk-VWSXAEX6.js.map +7 -0
  33. package/dist/chunks/{chunk-TPLMVELH.js → chunk-VYXFSUWU.js} +4 -4
  34. package/dist/chunks/{chunk-UTR3I23Z.js → chunk-W63E3WEO.js} +2 -2
  35. package/dist/chunks/{chunk-3MEHEH6B.js → chunk-X3OD47CL.js} +12 -2
  36. package/dist/chunks/chunk-X3OD47CL.js.map +7 -0
  37. package/dist/chunks/{chunk-OP2KTYQB.js → chunk-ZMIJ6AT4.js} +4 -4
  38. package/dist/compaction/hook.js +2 -2
  39. package/dist/config.d.ts.map +1 -1
  40. package/dist/core/action-registry.js +2 -2
  41. package/dist/core/auto-approval-classifier.d.ts.map +1 -1
  42. package/dist/core/shell-jobs.d.ts +7 -1
  43. package/dist/core/shell-jobs.d.ts.map +1 -1
  44. package/dist/entropy/compiler.d.ts +8 -0
  45. package/dist/entropy/compiler.d.ts.map +1 -1
  46. package/dist/entropy/index.js +9 -1
  47. package/dist/entropy/meter.d.ts +10 -0
  48. package/dist/entropy/meter.d.ts.map +1 -1
  49. package/dist/entropy/pool.d.ts +5 -0
  50. package/dist/entropy/pool.d.ts.map +1 -1
  51. package/dist/entropy/sessions.d.ts +12 -1
  52. package/dist/entropy/sessions.d.ts.map +1 -1
  53. package/dist/fabric-runtime-state.js +30 -22
  54. package/dist/fabric-runtime-state.js.map +2 -2
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/index.js +70 -38
  57. package/dist/index.js.map +3 -3
  58. package/dist/jev/browser.js +2 -2
  59. package/dist/jev/config.d.ts +2 -0
  60. package/dist/jev/config.d.ts.map +1 -1
  61. package/dist/jev/model-key.d.ts +6 -0
  62. package/dist/jev/model-key.d.ts.map +1 -0
  63. package/dist/jev/observation.js +2 -2
  64. package/dist/jev.js +7 -7
  65. package/dist/memory/file-worker.d.ts +15 -0
  66. package/dist/memory/file-worker.d.ts.map +1 -0
  67. package/dist/memory/file-worker.js +44 -0
  68. package/dist/memory/file-worker.js.map +7 -0
  69. package/dist/memory/worker-provider.d.ts +24 -0
  70. package/dist/memory/worker-provider.d.ts.map +1 -0
  71. package/dist/memory/worker-provider.js +18 -0
  72. package/dist/memory/worker-provider.js.map +7 -0
  73. package/dist/output-budget.d.ts.map +1 -1
  74. package/dist/prewalk/arm.d.ts.map +1 -1
  75. package/dist/prewalk/handoff.d.ts.map +1 -1
  76. package/dist/providers/jev-provider.js +6 -6
  77. package/dist/residency/host.js +9 -8
  78. package/dist/residency/pi-entry.js +9 -8
  79. package/dist/residency/pi-entry.js.map +1 -1
  80. package/dist/runtime/monty-runtime.js +3 -2
  81. package/dist/runtime/monty-runtime.js.map +1 -1
  82. package/dist/runtime/typescript-kernel.js +6 -6
  83. package/dist/runtime-state-builtins.d.ts.map +1 -1
  84. package/dist/speculation/stream-tap.d.ts.map +1 -1
  85. package/dist/storage/retention.d.ts +3 -1
  86. package/dist/storage/retention.d.ts.map +1 -1
  87. package/dist/storage/scratch.d.ts +33 -0
  88. package/dist/storage/scratch.d.ts.map +1 -0
  89. package/dist/ui/code-preview-shell.d.ts.map +1 -1
  90. package/dist/ui/conversation-chrome.js +2 -2
  91. package/dist/ui/conversation-native-reader.js +4 -2
  92. package/dist/ui/conversation-native-reader.js.map +2 -2
  93. package/dist/ui/conversation.js +3 -3
  94. package/dist/ui/dashboard-presentation.d.ts.map +1 -1
  95. package/dist/ui/dashboard.js +13 -9
  96. package/dist/ui/dashboard.js.map +2 -2
  97. package/dist/ui/fabric-code-parser.d.ts.map +1 -1
  98. package/dist/ui/format.d.ts +1 -0
  99. package/dist/ui/format.d.ts.map +1 -1
  100. package/dist/ui/highlight.d.ts.map +1 -1
  101. package/dist/ui/settings-rpc.d.ts.map +1 -1
  102. package/dist/ui/settings-sections-execution.d.ts.map +1 -1
  103. package/dist/ui/settings-submenus.d.ts +12 -4
  104. package/dist/ui/settings-submenus.d.ts.map +1 -1
  105. package/dist/ui/settings.js +78 -31
  106. package/dist/ui/settings.js.map +2 -2
  107. package/dist/ui/shiki-catalog.d.ts +3 -0
  108. package/dist/ui/shiki-catalog.d.ts.map +1 -0
  109. package/dist/ui/structured.d.ts.map +1 -1
  110. package/dist/ui/tool-call-timing.d.ts.map +1 -1
  111. package/dist/ui/widget.d.ts.map +1 -1
  112. package/dist/worker/model-control.d.ts.map +1 -1
  113. package/dist/worker/model-control.js +0 -1
  114. package/dist/worker/model-control.js.map +2 -2
  115. package/dist/worker.js +3 -9
  116. package/dist/worker.js.map +2 -2
  117. package/docs/agents.md +7 -3
  118. package/docs/configuration.md +19 -7
  119. package/docs/entropy.md +17 -1
  120. package/docs/jev.md +2 -2
  121. package/docs/memory-recall.md +21 -0
  122. package/package.json +5 -2
  123. package/skillsets/python/fabric-exec/references/agents.md +2 -0
  124. package/skillsets/python/fabric-jev/SKILL.md +1 -1
  125. package/skillsets/typescript/fabric-exec/references/agents.md +2 -0
  126. package/skillsets/typescript/fabric-jev/SKILL.md +1 -1
  127. package/dist/chunks/chunk-2DMJ7MEI.js.map +0 -7
  128. package/dist/chunks/chunk-3MEHEH6B.js.map +0 -7
  129. package/dist/chunks/chunk-656HWVFU.js.map +0 -7
  130. package/dist/chunks/chunk-ARLYAW2A.js.map +0 -7
  131. package/dist/chunks/chunk-CI56CW53.js.map +0 -7
  132. package/dist/chunks/chunk-PH7ZJ27F.js.map +0 -7
  133. package/dist/chunks/chunk-RNOPHITP.js.map +0 -7
  134. package/dist/chunks/chunk-UDFDF7IY.js.map +0 -7
  135. package/dist/chunks/chunk-VRZNFNPB.js.map +0 -7
  136. package/dist/chunks/chunk-ZZ4LHQYJ.js.map +0 -7
  137. /package/dist/chunks/{chunk-GXNR6NRU.js.map → chunk-2IAVP4O2.js.map} +0 -0
  138. /package/dist/chunks/{chunk-2UQV52II.js.map → chunk-3CPWRPCE.js.map} +0 -0
  139. /package/dist/chunks/{chunk-YK5AZ7CZ.js.map → chunk-3ZX76BVU.js.map} +0 -0
  140. /package/dist/chunks/{chunk-CPSW2GW4.js.map → chunk-KFZYTGF5.js.map} +0 -0
  141. /package/dist/chunks/{chunk-U6CTHPZC.js.map → chunk-MQG5QKGI.js.map} +0 -0
  142. /package/dist/chunks/{chunk-TPLMVELH.js.map → chunk-VYXFSUWU.js.map} +0 -0
  143. /package/dist/chunks/{chunk-UTR3I23Z.js.map → chunk-W63E3WEO.js.map} +0 -0
  144. /package/dist/chunks/{chunk-OP2KTYQB.js.map → chunk-ZMIJ6AT4.js.map} +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,iCAAiC,CAAC;AA2JzC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,wBAA8B,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,wBAAwB,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAqvBhI;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,YAAY,EAEb,MAAM,iCAAiC,CAAC;AA2JzC,eAAO,MAAM,2BAA2B,IAAI,CAAC;AAC7C,YAAY,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAElE,wBAA8B,QAAQ,CAAC,EAAE,EAAE,YAAY,EAAE,OAAO,GAAE;IAAE,WAAW,CAAC,EAAE,wBAAwB,CAAA;CAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CA8vBhI;AAED,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,eAAe,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,3 @@
1
- import {
2
- repairFabricGuestCode
3
- } from "./chunks/chunk-VXZZJ44D.js";
4
1
  import {
5
2
  arcItemStyled,
6
3
  captureFabricAgentPreviews,
@@ -32,12 +29,12 @@ import {
32
29
  singleCallProgressLine,
33
30
  spinnerFrame,
34
31
  updateSpinner
35
- } from "./chunks/chunk-VRZNFNPB.js";
32
+ } from "./chunks/chunk-IYQ5MNCW.js";
36
33
  import {
37
34
  configureHighlighting,
38
35
  highlightCode,
39
36
  observePiTheme
40
- } from "./chunks/chunk-ZZ4LHQYJ.js";
37
+ } from "./chunks/chunk-RTXZHKMS.js";
41
38
  import {
42
39
  activeStatuses,
43
40
  isActiveStatus,
@@ -48,11 +45,10 @@ import {
48
45
  formatDuration,
49
46
  formatTokens,
50
47
  safeText
51
- } from "./chunks/chunk-ARLYAW2A.js";
48
+ } from "./chunks/chunk-IR3PIHJM.js";
52
49
  import {
53
- GUEST_TYPE_DECLARATIONS,
54
- PI_CORE_COMPATIBILITY_ARGUMENT_TYPE_NAMES
55
- } from "./chunks/chunk-32BNQ75J.js";
50
+ repairFabricGuestCode
51
+ } from "./chunks/chunk-VXZZJ44D.js";
56
52
  import {
57
53
  CapturedToolCatalog,
58
54
  FABRIC_COMPONENT_PROVIDER_NAMES,
@@ -73,24 +69,32 @@ import {
73
69
  restoreBorrowedInPlaceMain,
74
70
  settleInPlacePrewalk,
75
71
  withTrajectoryRearmDirective
76
- } from "./chunks/chunk-2DMJ7MEI.js";
72
+ } from "./chunks/chunk-QX3TUAWO.js";
77
73
  import {
78
74
  AgentTranscriptReader,
79
75
  countNewlines,
80
76
  truncateMiddle
81
77
  } from "./chunks/chunk-J2HV2URQ.js";
82
78
  import "./chunks/chunk-DLXPTBPL.js";
79
+ import {
80
+ GUEST_TYPE_DECLARATIONS,
81
+ PI_CORE_COMPATIBILITY_ARGUMENT_TYPE_NAMES
82
+ } from "./chunks/chunk-32BNQ75J.js";
83
83
  import {
84
84
  NESTED_TOOL_CALL_ID_PREFIX
85
- } from "./chunks/chunk-CPSW2GW4.js";
85
+ } from "./chunks/chunk-KFZYTGF5.js";
86
86
  import "./chunks/chunk-LMAVZN7J.js";
87
87
  import {
88
88
  AUTO_APPLY_PROPOSAL_KINDS,
89
+ BackgroundEntropyCompiler,
90
+ BackgroundSessionSelector,
89
91
  ENTROPY_ENUM_CANDIDATE_ANNOTATION,
90
92
  OBSERVATION_POOL_VERSION,
91
93
  POOL_BAKED_DIGESTS,
92
94
  POOL_TRACKED_SESSIONS,
93
95
  POOL_TRACKED_VALUES,
96
+ SessionEntropyMeter,
97
+ SessionObservationCache,
94
98
  applyProposalsToSurface,
95
99
  compileEntropySurface,
96
100
  compileEntropySurfaceAsync,
@@ -136,7 +140,7 @@ import {
136
140
  sessionWindowEvidence,
137
141
  sessionWindowEvidenceAsync,
138
142
  surfaceFreedomReport
139
- } from "./chunks/chunk-RNOPHITP.js";
143
+ } from "./chunks/chunk-H6DDV6E2.js";
140
144
  import {
141
145
  COMPILED_SURFACE_VERSION,
142
146
  ENTROPY_INVOCATION_STAGES,
@@ -170,13 +174,13 @@ import {
170
174
  ApprovalController,
171
175
  FabricAutoApprovalClassifier,
172
176
  FabricSessionApprovals
173
- } from "./chunks/chunk-CI56CW53.js";
177
+ } from "./chunks/chunk-NPHCGLGH.js";
174
178
  import "./chunks/chunk-XB3RJVT4.js";
179
+ import "./chunks/chunk-7TB7NXSL.js";
175
180
  import {
176
181
  getActiveRepairCompiler,
177
182
  setActiveCompiledSurface
178
183
  } from "./chunks/chunk-PSNXUZMY.js";
179
- import "./chunks/chunk-7TB7NXSL.js";
180
184
  import {
181
185
  FABRIC_COMPONENT_DISCOVER_EVENT,
182
186
  FABRIC_COMPONENT_REGISTER_EVENT,
@@ -195,30 +199,34 @@ import {
195
199
  import {
196
200
  awaitPeerSettle,
197
201
  buildPeerCards
198
- } from "./chunks/chunk-GXNR6NRU.js";
202
+ } from "./chunks/chunk-2IAVP4O2.js";
199
203
  import {
200
204
  resolveAgentDir
201
205
  } from "./chunks/chunk-PXAICAUT.js";
206
+ import "./chunks/chunk-CGPK5WHX.js";
202
207
  import {
203
208
  DEFAULT_FABRIC_CONFIG,
204
209
  effectiveToolCaptureConfig,
205
210
  loadFabricConfig,
206
211
  loadFabricConfigForScope,
207
212
  saveFabricConfig
208
- } from "./chunks/chunk-UDFDF7IY.js";
209
- import "./chunks/chunk-CGPK5WHX.js";
213
+ } from "./chunks/chunk-VWSXAEX6.js";
210
214
  import {
211
215
  defaultCodePreviewSettings
212
216
  } from "./chunks/chunk-OKOHRXGF.js";
217
+ import {
218
+ closeScratch,
219
+ createScratch
220
+ } from "./chunks/chunk-RAO6TQFP.js";
213
221
  import {
214
222
  compactAtConfiguredThreshold,
215
223
  fabricExecTitleHintCached,
216
224
  normalizeRunDisplay,
217
225
  registerCompactionHook
218
- } from "./chunks/chunk-U6CTHPZC.js";
226
+ } from "./chunks/chunk-MQG5QKGI.js";
219
227
  import {
220
228
  fabricWriteBindings
221
- } from "./chunks/chunk-656HWVFU.js";
229
+ } from "./chunks/chunk-SZUXWOO7.js";
222
230
  import "./chunks/chunk-KAD7UWT2.js";
223
231
  import "./chunks/chunk-ZDNGXLEC.js";
224
232
  import {
@@ -226,7 +234,7 @@ import {
226
234
  } from "./chunks/chunk-OTCASLY2.js";
227
235
  import "./chunks/chunk-MGWQOKBV.js";
228
236
  import "./chunks/chunk-3H7SDWZI.js";
229
- import "./chunks/chunk-3MEHEH6B.js";
237
+ import "./chunks/chunk-X3OD47CL.js";
230
238
  import {
231
239
  FABRIC_EXECUTION_TRACE_KIND,
232
240
  FABRIC_EXECUTION_TRACE_MAX_BYTES,
@@ -336,7 +344,9 @@ var updateTiming = (context, enabled, options = {}) => {
336
344
  if (options.formatLabel === false) return void 0;
337
345
  const running = context.isPartial;
338
346
  const endedAt = running ? Date.now() : state.codePreviewTimingEndedAt ?? Date.now();
339
- return `${running ? "Elapsed" : "Took"} ${formatDuration2(endedAt - startedAt)}`;
347
+ const durationMs = endedAt - startedAt;
348
+ if (!Number.isFinite(durationMs) || Math.round(durationMs) <= 0) return void 0;
349
+ return `${running ? "Elapsed" : "Took"} ${formatDuration2(durationMs)}`;
340
350
  };
341
351
  var TimingPreservedComponent = class {
342
352
  constructor(component, state) {
@@ -757,6 +767,9 @@ var armFabricPrewalkSession = async (state, context, pi, input) => {
757
767
  var autoArmFabricPrewalk = async (state, context, pi) => {
758
768
  const { prewalk } = state.config;
759
769
  if (prewalk.enabled === false || !prewalk.alwaysRearm) return void 0;
770
+ if (resolveFabricIdentity(context.sessionManager.getSessionId()).identity.kind !== "main") {
771
+ return void 0;
772
+ }
760
773
  if (state.prewalk.status().state !== "idle") return void 0;
761
774
  if (!state.config.fullCodeMode || state.config.schema.mode === "enforce") {
762
775
  return "Fabric prewalk auto-arm skipped: requires full code mode with Schema enforce mode disabled.";
@@ -2662,16 +2675,21 @@ var PartialResultObserver = class {
2662
2675
  };
2663
2676
 
2664
2677
  // src/output-budget.ts
2665
- import { mkdtemp, writeFile } from "node:fs/promises";
2666
- import { tmpdir } from "node:os";
2678
+ import fs2 from "node:fs/promises";
2667
2679
  import path6 from "node:path";
2668
2680
  var MAX_FAILURE_MODEL_OUTPUT_CHARS = 2e4;
2669
2681
  var modelOutputBudget = (configuredMaxChars, success) => success ? configuredMaxChars : Math.min(configuredMaxChars, MAX_FAILURE_MODEL_OUTPUT_CHARS);
2670
2682
  var writeOutputArtifact = async (content) => {
2671
- const directory = await mkdtemp(path6.join(tmpdir(), "pi-fabric-output-"));
2672
- const artifactPath = path6.join(directory, "output.txt");
2673
- await writeFile(artifactPath, content, { encoding: "utf8", mode: 384 });
2674
- return artifactPath;
2683
+ const directory = createScratch("output");
2684
+ try {
2685
+ const artifactPath = path6.join(directory, "output.txt");
2686
+ await fs2.writeFile(artifactPath, content, { encoding: "utf8", mode: 384, flag: "wx" });
2687
+ closeScratch(directory);
2688
+ return artifactPath;
2689
+ } catch (error) {
2690
+ await fs2.rm(directory, { recursive: true, force: true }).catch(() => void 0);
2691
+ throw error;
2692
+ }
2675
2693
  };
2676
2694
  var boundModelOutput = async (visible, maxChars, fullOutput = visible, writeArtifact = writeOutputArtifact) => {
2677
2695
  if (visible.length <= maxChars && fullOutput.length <= maxChars) {
@@ -3436,7 +3454,7 @@ ${recoveryHint}` : ""}`,
3436
3454
  };
3437
3455
 
3438
3456
  // src/fabric-state.ts
3439
- import fs2 from "node:fs";
3457
+ import fs3 from "node:fs";
3440
3458
  import path7 from "node:path";
3441
3459
 
3442
3460
  // src/managed-host.ts
@@ -3683,7 +3701,7 @@ var FabricState = class {
3683
3701
  ];
3684
3702
  return actorRoots.some((actorRoot) => {
3685
3703
  try {
3686
- const registry = JSON.parse(fs2.readFileSync(path7.join(actorRoot, "actors.json"), "utf8"));
3704
+ const registry = JSON.parse(fs3.readFileSync(path7.join(actorRoot, "actors.json"), "utf8"));
3687
3705
  if (typeof registry !== "object" || registry === null || Array.isArray(registry)) return false;
3688
3706
  const actors = registry.actors;
3689
3707
  return Array.isArray(actors) && actors.some((value) => {
@@ -4543,7 +4561,8 @@ var FabricWidget = class {
4543
4561
  if (tokens > 0) parts.push(`${formatTokens(tokens)} tok`);
4544
4562
  const cost = totalCost(snapshot, run);
4545
4563
  if (cost > 0) parts.push(formatCost(cost));
4546
- if (run) parts.push(formatDuration((run.finishedAt ?? snapshot.now) - run.startedAt));
4564
+ const elapsed = run && formatDuration((run.finishedAt ?? snapshot.now) - run.startedAt);
4565
+ if (elapsed) parts.push(elapsed);
4547
4566
  const glyph = colorStatus(this.theme, headerStatus, statusGlyph(headerStatus));
4548
4567
  const header = `${glyph} ${this.theme.fg("accent", "Fabric")} ${this.theme.fg(
4549
4568
  "muted",
@@ -5563,33 +5582,40 @@ async function piFabric(pi, options = {}) {
5563
5582
  let entropyCompileInFlight;
5564
5583
  let entropyCompilePending;
5565
5584
  let entropyLifecycleEpoch = 0;
5585
+ const createEntropyCaches = () => ({
5586
+ compiler: new BackgroundEntropyCompiler(),
5587
+ observations: new SessionObservationCache(),
5588
+ sessions: new BackgroundSessionSelector(machineSessionFilesAsync)
5589
+ });
5590
+ let entropyCaches = createEntropyCaches();
5566
5591
  const compileEntropyNow = async (context, epoch) => {
5567
5592
  const current = () => epoch === entropyLifecycleEpoch && state.initialized && state.config.entropy.compile;
5568
5593
  if (!current()) return;
5569
5594
  const agentDir = resolveAgentDir();
5570
5595
  const cwd = state.cwd ?? context.cwd;
5571
5596
  const repairs = entropyRepairRows(state.repairs.repairs);
5597
+ const caches = entropyCaches;
5572
5598
  const [files, loaded, poolLoaded, snapshot] = await Promise.all([
5573
- machineSessionFilesAsync(agentDir, cwd),
5599
+ caches.sessions.select(agentDir, cwd, context.sessionManager.getSessionFile?.()),
5574
5600
  loadCompiledSurfaceAsync(agentDir),
5575
5601
  loadObservationPoolAsync(agentDir),
5576
5602
  liveSurfaceSnapshot({ registry: state.registry, extensionContext: context, cwd })
5577
5603
  ]);
5578
5604
  if (!current() || loaded.error) return;
5579
- const evidence = await sessionWindowEvidenceAsync(files);
5605
+ const evidence = await sessionWindowEvidenceAsync(files, { windowsOnly: true });
5580
5606
  if (!current()) return;
5581
- const mergedPool = await mergeObservationWindowAsync(
5607
+ const mergedPool = await caches.observations.merge(
5582
5608
  poolLoaded.file,
5583
5609
  evidence.observationWindows
5584
5610
  );
5585
- if (!poolLoaded.error) await saveObservationPoolAsync(agentDir, mergedPool.file);
5611
+ if (!poolLoaded.error && (mergedPool.mergedSessions > 0 || !poolLoaded.file)) {
5612
+ await saveObservationPoolAsync(agentDir, mergedPool.file);
5613
+ }
5586
5614
  if (!current()) return;
5587
- const outcome = await compileEntropySurfaceAsync({
5588
- traces: evidence.traces,
5615
+ const outcome = await caches.compiler.compile({
5616
+ windows: evidence.traceWindows,
5589
5617
  surface: snapshot,
5590
5618
  repairs,
5591
- valueObservations: poolToValueObservations(mergedPool.file),
5592
- auditCalls: evidence.auditCalls,
5593
5619
  ...loaded.file ? { artifact: loaded.file } : {}
5594
5620
  });
5595
5621
  if (!current()) return;
@@ -5643,6 +5669,7 @@ async function piFabric(pi, options = {}) {
5643
5669
  };
5644
5670
  pi.on("session_start", async (_event, context) => {
5645
5671
  entropyLifecycleEpoch += 1;
5672
+ entropyCaches = createEntropyCaches();
5646
5673
  entropyEvidenceThisTurn = false;
5647
5674
  entropyCompilePending = void 0;
5648
5675
  pendingHandoffs.clear();
@@ -5934,6 +5961,7 @@ ${guidance}`,
5934
5961
  }
5935
5962
  await settleEntropyCompiles();
5936
5963
  entropyLifecycleEpoch += 1;
5964
+ entropyCaches = createEntropyCaches();
5937
5965
  entropyCompilePending = void 0;
5938
5966
  unsubscribeComponentRegistration();
5939
5967
  unsubscribeProviderRegistration();
@@ -5967,6 +5995,8 @@ ${guidance}`,
5967
5995
  }
5968
5996
  export {
5969
5997
  AUTO_APPLY_PROPOSAL_KINDS,
5998
+ BackgroundEntropyCompiler,
5999
+ BackgroundSessionSelector,
5970
6000
  COMPILED_SURFACE_VERSION,
5971
6001
  ENTROPY_ENUM_CANDIDATE_ANNOTATION,
5972
6002
  ENTROPY_INVOCATION_STAGES,
@@ -6002,6 +6032,8 @@ export {
6002
6032
  POOL_BAKED_DIGESTS,
6003
6033
  POOL_TRACKED_SESSIONS,
6004
6034
  POOL_TRACKED_VALUES,
6035
+ SessionEntropyMeter,
6036
+ SessionObservationCache,
6005
6037
  applyCompiledSurface,
6006
6038
  applyNormalFormPlan,
6007
6039
  applyProposalsToSurface,