@e4779/pi-fabric 0.131.0-fork.32 → 0.132.6-fork.34

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 (232) hide show
  1. package/README.md +1 -1
  2. package/dist/activity/store.d.ts.map +1 -1
  3. package/dist/actors/feedback.d.ts +5 -0
  4. package/dist/actors/feedback.d.ts.map +1 -0
  5. package/dist/actors/global-registry.d.ts.map +1 -1
  6. package/dist/actors/manager.d.ts.map +1 -1
  7. package/dist/agents/completion-inbox.d.ts +2 -1
  8. package/dist/agents/completion-inbox.d.ts.map +1 -1
  9. package/dist/agents/manager.d.ts.map +1 -1
  10. package/dist/agents/request.d.ts.map +1 -1
  11. package/dist/agents/transports/herdr-core-socket.d.ts +13 -0
  12. package/dist/agents/transports/herdr-core-socket.d.ts.map +1 -0
  13. package/dist/agents/transports/herdr-core-transport.d.ts +10 -0
  14. package/dist/agents/transports/herdr-core-transport.d.ts.map +1 -0
  15. package/dist/agents.js +5 -1
  16. package/dist/agents.js.map +1 -1
  17. package/dist/async-settlement.d.ts +1 -1
  18. package/dist/async-settlement.d.ts.map +1 -1
  19. package/dist/audit/details.d.ts +2 -0
  20. package/dist/audit/details.d.ts.map +1 -1
  21. package/dist/chunks/{chunk-HSEZPCL5.js → chunk-2OC4YJOL.js} +3 -3
  22. package/dist/chunks/{chunk-TXCNZCZP.js → chunk-2QJ4MNS6.js} +2 -2
  23. package/dist/chunks/{chunk-QOEOKW2X.js → chunk-3QH6JAE3.js} +2 -2
  24. package/dist/chunks/{chunk-3XT5WHSG.js → chunk-4Y5KEJP4.js} +3 -3
  25. package/dist/chunks/{chunk-RAA3FAYZ.js → chunk-5PSEJOJB.js} +2 -2
  26. package/dist/chunks/{chunk-XFOSUGLU.js → chunk-66UTGL7T.js} +2 -2
  27. package/dist/chunks/{chunk-WWTGWGH7.js → chunk-6ZPEPRUV.js} +27 -9
  28. package/dist/chunks/chunk-6ZPEPRUV.js.map +7 -0
  29. package/dist/chunks/{chunk-7TB7NXSL.js → chunk-7CIQQOOD.js} +11 -3
  30. package/dist/chunks/{chunk-7TB7NXSL.js.map → chunk-7CIQQOOD.js.map} +2 -2
  31. package/dist/chunks/{chunk-3PKZSIRA.js → chunk-ASOJYFKU.js} +8 -4
  32. package/dist/chunks/chunk-ASOJYFKU.js.map +7 -0
  33. package/dist/chunks/{chunk-PUBHBEYO.js → chunk-B2FIGOPI.js} +2 -2
  34. package/dist/chunks/{chunk-ZFWICFNJ.js → chunk-DGUXJSYA.js} +41 -17
  35. package/dist/chunks/chunk-DGUXJSYA.js.map +7 -0
  36. package/dist/chunks/{chunk-WGMCNCP6.js → chunk-F3D7GTBK.js} +228 -90
  37. package/dist/chunks/chunk-F3D7GTBK.js.map +7 -0
  38. package/dist/chunks/{chunk-X7QETPBC.js → chunk-F6GIK5GO.js} +8 -8
  39. package/dist/chunks/{chunk-LKYLD5SN.js → chunk-FMEOJJ6Y.js} +3 -2
  40. package/dist/chunks/chunk-FMEOJJ6Y.js.map +7 -0
  41. package/dist/chunks/{chunk-4PBW54I2.js → chunk-GGQ43B7T.js} +3 -3
  42. package/dist/chunks/{chunk-MSDL7U6Q.js → chunk-JSHIS7GO.js} +2 -2
  43. package/dist/chunks/{chunk-VNWQIGQL.js → chunk-JWERGULW.js} +421 -254
  44. package/dist/chunks/chunk-JWERGULW.js.map +7 -0
  45. package/dist/chunks/{chunk-HRDMBGMY.js → chunk-K4VRQ7WZ.js} +4 -4
  46. package/dist/chunks/{chunk-5BOTHX47.js → chunk-LP5EVMBB.js} +157 -4
  47. package/dist/chunks/chunk-LP5EVMBB.js.map +7 -0
  48. package/dist/chunks/{chunk-4KX6BIPL.js → chunk-LRSZFYUC.js} +2 -2
  49. package/dist/chunks/chunk-LRSZFYUC.js.map +7 -0
  50. package/dist/chunks/{chunk-56NMRVTV.js → chunk-MGFSQXAJ.js} +23 -23
  51. package/dist/chunks/{chunk-56NMRVTV.js.map → chunk-MGFSQXAJ.js.map} +2 -2
  52. package/dist/chunks/{chunk-RWKQ5SRW.js → chunk-MTAFECXB.js} +2 -2
  53. package/dist/chunks/{chunk-UFMYN5TA.js → chunk-MX53BRAC.js} +2 -2
  54. package/dist/chunks/{chunk-7CIES6X2.js → chunk-NGXAEGD2.js} +12 -2
  55. package/dist/chunks/chunk-NGXAEGD2.js.map +7 -0
  56. package/dist/chunks/{chunk-IOGDTIGN.js → chunk-NSV7WTCT.js} +3 -3
  57. package/dist/chunks/{chunk-IOGDTIGN.js.map → chunk-NSV7WTCT.js.map} +1 -1
  58. package/dist/chunks/{chunk-3VK6UGAN.js → chunk-O5SHIUIL.js} +6 -1
  59. package/dist/chunks/chunk-O5SHIUIL.js.map +7 -0
  60. package/dist/chunks/{chunk-4WKD3YM3.js → chunk-OILZ4PDY.js} +3 -3
  61. package/dist/chunks/{chunk-H57KPL3V.js → chunk-S2JWFXW5.js} +2 -2
  62. package/dist/chunks/{chunk-HFDJWLMS.js → chunk-SOEUGSY4.js} +2 -2
  63. package/dist/chunks/{chunk-YHFWMAQ5.js → chunk-TEMKDJJY.js} +151 -52
  64. package/dist/chunks/chunk-TEMKDJJY.js.map +7 -0
  65. package/dist/chunks/{chunk-KIFOEBYJ.js → chunk-VEXCD3RA.js} +2 -2
  66. package/dist/chunks/{chunk-GS67KDMV.js → chunk-VN7AE3EY.js} +2 -2
  67. package/dist/chunks/{chunk-MPMEK3IQ.js → chunk-WYLBWFAO.js} +2 -2
  68. package/dist/chunks/{chunk-6GWDGTHC.js → chunk-YLO62DWD.js} +4 -4
  69. package/dist/chunks/{chunk-4BYS4ZLY.js → chunk-YN4K3FNB.js} +5 -5
  70. package/dist/chunks/{chunk-OJ4HAALD.js → chunk-YO5UIWDY.js} +3 -3
  71. package/dist/chunks/{chunk-7N7IC3Z2.js → chunk-ZCXW3GR7.js} +2 -2
  72. package/dist/chunks/{chunk-36XQFTEN.js → chunk-ZY375C2U.js} +2 -2
  73. package/dist/commands/fabric-handler.js +2 -2
  74. package/dist/commands/fabric-handler.js.map +1 -1
  75. package/dist/commands/fabric.d.ts.map +1 -1
  76. package/dist/compaction/claim-events.js +8 -8
  77. package/dist/compaction/hook.js +6 -6
  78. package/dist/compaction/owner.js +7 -7
  79. package/dist/compaction/threshold.d.ts.map +1 -1
  80. package/dist/components/configuration.js +3 -3
  81. package/dist/config.d.ts +1 -1
  82. package/dist/config.d.ts.map +1 -1
  83. package/dist/core/action-registry.d.ts +1 -1
  84. package/dist/core/action-registry.d.ts.map +1 -1
  85. package/dist/core/action-registry.js +8 -8
  86. package/dist/core/attached-monitors.d.ts +39 -0
  87. package/dist/core/attached-monitors.d.ts.map +1 -0
  88. package/dist/core/call-presentation.d.ts +14 -0
  89. package/dist/core/call-presentation.d.ts.map +1 -0
  90. package/dist/core/execution-guidelines.d.ts +6 -0
  91. package/dist/core/execution-guidelines.d.ts.map +1 -0
  92. package/dist/core/guidance-delivery.d.ts +19 -0
  93. package/dist/core/guidance-delivery.d.ts.map +1 -0
  94. package/dist/core/observation-actions.d.ts +9 -0
  95. package/dist/core/observation-actions.d.ts.map +1 -0
  96. package/dist/core/prompt-guidance.d.ts +1 -0
  97. package/dist/core/prompt-guidance.d.ts.map +1 -1
  98. package/dist/core/prompt-guidance.js +50 -1
  99. package/dist/core/prompt-guidance.js.map +3 -3
  100. package/dist/core/provider-operations.js +1 -1
  101. package/dist/core/shell-inbox.d.ts +1 -1
  102. package/dist/core/shell-inbox.d.ts.map +1 -1
  103. package/dist/core/shell-jobs.d.ts +17 -1
  104. package/dist/core/shell-jobs.d.ts.map +1 -1
  105. package/dist/core/shell-monitor.d.ts +1 -0
  106. package/dist/core/shell-monitor.d.ts.map +1 -1
  107. package/dist/durable/agent.d.ts.map +1 -1
  108. package/dist/durable/worker-host.js +1 -1
  109. package/dist/durable-extension.d.ts +2 -2
  110. package/dist/durable-extension.d.ts.map +1 -1
  111. package/dist/durable-extension.js +215 -1
  112. package/dist/durable-extension.js.map +3 -3
  113. package/dist/durable-host.js +1 -1
  114. package/dist/durable.d.ts.map +1 -1
  115. package/dist/durable.js +5 -4
  116. package/dist/durable.js.map +2 -2
  117. package/dist/entropy/index.js +9 -9
  118. package/dist/extension-bootstrap.d.ts.map +1 -1
  119. package/dist/extension-bootstrap.js +12 -12
  120. package/dist/extension.d.ts.map +1 -1
  121. package/dist/fabric-exec-tool.d.ts.map +1 -1
  122. package/dist/fabric-runtime-state.d.ts.map +1 -1
  123. package/dist/fabric-runtime-state.js +410 -230
  124. package/dist/fabric-runtime-state.js.map +4 -4
  125. package/dist/feedback.d.ts +5 -0
  126. package/dist/feedback.d.ts.map +1 -0
  127. package/dist/index.js +21 -21
  128. package/dist/jev/client.js +2 -2
  129. package/dist/jev/observation.js +5 -5
  130. package/dist/jev.js +10 -10
  131. package/dist/main-agent.d.ts +2 -1
  132. package/dist/main-agent.d.ts.map +1 -1
  133. package/dist/memory/discovery.js +6 -6
  134. package/dist/memory/file-worker.js +8 -8
  135. package/dist/memory/normalize.js +5 -5
  136. package/dist/memory/search.js +6 -6
  137. package/dist/memory/worker-provider.js +9 -9
  138. package/dist/memory.js +9 -9
  139. package/dist/providers/agents-actions.d.ts.map +1 -1
  140. package/dist/providers/agents-message-router.d.ts.map +1 -1
  141. package/dist/providers/agents-provider.d.ts +2 -0
  142. package/dist/providers/agents-provider.d.ts.map +1 -1
  143. package/dist/providers/jev-provider.js +10 -10
  144. package/dist/providers/memory-provider.js +8 -8
  145. package/dist/providers/tasks-provider.d.ts +3 -1
  146. package/dist/providers/tasks-provider.d.ts.map +1 -1
  147. package/dist/residency/host.js +9 -9
  148. package/dist/residency/pi-entry.js +9 -9
  149. package/dist/runtime/core-override-guest-types.js +2 -2
  150. package/dist/runtime/cpython-runtime.js +1 -1
  151. package/dist/runtime/guest-types.d.ts +1 -1
  152. package/dist/runtime/guest-types.d.ts.map +1 -1
  153. package/dist/runtime/guest-types.js +1 -1
  154. package/dist/runtime/monty-runtime.js +2 -2
  155. package/dist/runtime/node-process-runtime.js +3 -3
  156. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  157. package/dist/runtime/quickjs-runtime.js +2 -2
  158. package/dist/runtime/typescript-kernel.js +5 -5
  159. package/dist/runtime-state-builtins.d.ts +2 -0
  160. package/dist/runtime-state-builtins.d.ts.map +1 -1
  161. package/dist/topology/participant-directory.d.ts.map +1 -1
  162. package/dist/topology/peer-presence.d.ts.map +1 -1
  163. package/dist/topology/provider-participants.d.ts +1 -0
  164. package/dist/topology/provider-participants.d.ts.map +1 -1
  165. package/dist/type-error-guidance.js +1 -1
  166. package/dist/ui/code-preview-shell.d.ts +1 -0
  167. package/dist/ui/code-preview-shell.d.ts.map +1 -1
  168. package/dist/ui/dashboard-model.d.ts.map +1 -1
  169. package/dist/ui/dashboard.js +8 -5
  170. package/dist/ui/dashboard.js.map +2 -2
  171. package/dist/ui/fabric-render.d.ts +1 -0
  172. package/dist/ui/fabric-render.d.ts.map +1 -1
  173. package/dist/ui/settings-values.d.ts +1 -1
  174. package/dist/ui/settings-values.d.ts.map +1 -1
  175. package/dist/ui/settings.js +3 -3
  176. package/dist/ui/settings.js.map +2 -2
  177. package/dist/ui/shell-tasks.d.ts.map +1 -1
  178. package/dist/ui/shell-tasks.js +20 -4
  179. package/dist/ui/shell-tasks.js.map +2 -2
  180. package/dist/ui/widget.d.ts +8 -4
  181. package/dist/ui/widget.d.ts.map +1 -1
  182. package/dist/verified/generated/manifest.json +12 -3
  183. package/dist/verified/generated/prompt-guidance.d.ts +4 -0
  184. package/dist/verified/generated/prompt-guidance.js +17 -0
  185. package/docs/agents.md +26 -6
  186. package/docs/background-tasks.md +98 -14
  187. package/docs/configuration.md +2 -0
  188. package/docs/interface.md +3 -1
  189. package/docs/jev.md +1 -1
  190. package/docs/verified-kernels.md +23 -0
  191. package/package.json +9 -9
  192. package/proofs/index.ts +2 -0
  193. package/proofs/prompt-guidance.ts +38 -0
  194. package/scripts/verified-kernels.ts +1 -1
  195. package/skillsets/python/fabric-council/SKILL.md +25 -14
  196. package/skillsets/typescript/fabric-council/SKILL.md +24 -15
  197. package/skillsets/typescript/fabric-exec/references/agents.md +5 -5
  198. package/dist/chunks/chunk-3PKZSIRA.js.map +0 -7
  199. package/dist/chunks/chunk-3VK6UGAN.js.map +0 -7
  200. package/dist/chunks/chunk-4KX6BIPL.js.map +0 -7
  201. package/dist/chunks/chunk-5BOTHX47.js.map +0 -7
  202. package/dist/chunks/chunk-7CIES6X2.js.map +0 -7
  203. package/dist/chunks/chunk-LKYLD5SN.js.map +0 -7
  204. package/dist/chunks/chunk-VNWQIGQL.js.map +0 -7
  205. package/dist/chunks/chunk-WGMCNCP6.js.map +0 -7
  206. package/dist/chunks/chunk-WWTGWGH7.js.map +0 -7
  207. package/dist/chunks/chunk-YHFWMAQ5.js.map +0 -7
  208. package/dist/chunks/chunk-ZFWICFNJ.js.map +0 -7
  209. /package/dist/chunks/{chunk-HSEZPCL5.js.map → chunk-2OC4YJOL.js.map} +0 -0
  210. /package/dist/chunks/{chunk-TXCNZCZP.js.map → chunk-2QJ4MNS6.js.map} +0 -0
  211. /package/dist/chunks/{chunk-QOEOKW2X.js.map → chunk-3QH6JAE3.js.map} +0 -0
  212. /package/dist/chunks/{chunk-3XT5WHSG.js.map → chunk-4Y5KEJP4.js.map} +0 -0
  213. /package/dist/chunks/{chunk-RAA3FAYZ.js.map → chunk-5PSEJOJB.js.map} +0 -0
  214. /package/dist/chunks/{chunk-XFOSUGLU.js.map → chunk-66UTGL7T.js.map} +0 -0
  215. /package/dist/chunks/{chunk-PUBHBEYO.js.map → chunk-B2FIGOPI.js.map} +0 -0
  216. /package/dist/chunks/{chunk-X7QETPBC.js.map → chunk-F6GIK5GO.js.map} +0 -0
  217. /package/dist/chunks/{chunk-4PBW54I2.js.map → chunk-GGQ43B7T.js.map} +0 -0
  218. /package/dist/chunks/{chunk-MSDL7U6Q.js.map → chunk-JSHIS7GO.js.map} +0 -0
  219. /package/dist/chunks/{chunk-HRDMBGMY.js.map → chunk-K4VRQ7WZ.js.map} +0 -0
  220. /package/dist/chunks/{chunk-RWKQ5SRW.js.map → chunk-MTAFECXB.js.map} +0 -0
  221. /package/dist/chunks/{chunk-UFMYN5TA.js.map → chunk-MX53BRAC.js.map} +0 -0
  222. /package/dist/chunks/{chunk-4WKD3YM3.js.map → chunk-OILZ4PDY.js.map} +0 -0
  223. /package/dist/chunks/{chunk-H57KPL3V.js.map → chunk-S2JWFXW5.js.map} +0 -0
  224. /package/dist/chunks/{chunk-HFDJWLMS.js.map → chunk-SOEUGSY4.js.map} +0 -0
  225. /package/dist/chunks/{chunk-KIFOEBYJ.js.map → chunk-VEXCD3RA.js.map} +0 -0
  226. /package/dist/chunks/{chunk-GS67KDMV.js.map → chunk-VN7AE3EY.js.map} +0 -0
  227. /package/dist/chunks/{chunk-MPMEK3IQ.js.map → chunk-WYLBWFAO.js.map} +0 -0
  228. /package/dist/chunks/{chunk-6GWDGTHC.js.map → chunk-YLO62DWD.js.map} +0 -0
  229. /package/dist/chunks/{chunk-4BYS4ZLY.js.map → chunk-YN4K3FNB.js.map} +0 -0
  230. /package/dist/chunks/{chunk-OJ4HAALD.js.map → chunk-YO5UIWDY.js.map} +0 -0
  231. /package/dist/chunks/{chunk-7N7IC3Z2.js.map → chunk-ZCXW3GR7.js.map} +0 -0
  232. /package/dist/chunks/{chunk-36XQFTEN.js.map → chunk-ZY375C2U.js.map} +0 -0
@@ -1,4 +1,5 @@
1
1
  import {
2
+ arcItem,
2
3
  arcItemStyled,
3
4
  captureFabricAgentPreviews,
4
5
  captureFabricCallHeadlinePreviews,
@@ -15,6 +16,7 @@ import {
15
16
  modelReadHint,
16
17
  nestedCallBody,
17
18
  nestedCallTitle,
19
+ pushArcItem,
18
20
  renderAgentToolPreviewLines,
19
21
  renderBoundedLines,
20
22
  renderCoreToolBody,
@@ -28,7 +30,7 @@ import {
28
30
  safeTerminalText,
29
31
  shellBackgroundShortcut,
30
32
  singleCallProgressLine
31
- } from "./chunk-WWTGWGH7.js";
33
+ } from "./chunk-6ZPEPRUV.js";
32
34
  import {
33
35
  configureHighlighting,
34
36
  highlightCode,
@@ -78,10 +80,11 @@ import {
78
80
  resolveFabricIdentity,
79
81
  setModelSafely,
80
82
  withTrajectoryRearmDirective
81
- } from "./chunk-ZFWICFNJ.js";
83
+ } from "./chunk-DGUXJSYA.js";
82
84
  import {
83
- AgentTranscriptReader
84
- } from "./chunk-YHFWMAQ5.js";
85
+ AgentTranscriptReader,
86
+ isRoutineInternalCall
87
+ } from "./chunk-TEMKDJJY.js";
85
88
  import {
86
89
  countNewlines,
87
90
  editDistance,
@@ -105,14 +108,14 @@ import {
105
108
  loadFabricConfig,
106
109
  loadFabricConfigForScope,
107
110
  resolveForegroundTools
108
- } from "./chunk-4KX6BIPL.js";
111
+ } from "./chunk-LRSZFYUC.js";
109
112
  import {
110
113
  defaultCodePreviewSettings
111
114
  } from "./chunk-OKOHRXGF.js";
112
115
  import {
113
116
  compactAtConfiguredThreshold,
114
117
  fabricExecTitleHintCached
115
- } from "./chunk-3VK6UGAN.js";
118
+ } from "./chunk-O5SHIUIL.js";
116
119
  import {
117
120
  fabricWriteBindings
118
121
  } from "./chunk-SZUXWOO7.js";
@@ -134,11 +137,7 @@ import {
134
137
  ApprovalController,
135
138
  FabricAutoApprovalClassifier,
136
139
  FabricSessionApprovals
137
- } from "./chunk-4PBW54I2.js";
138
- import {
139
- getActiveRepairCompiler,
140
- setActiveCompiledSurface
141
- } from "./chunk-TXCNZCZP.js";
140
+ } from "./chunk-GGQ43B7T.js";
142
141
  import {
143
142
  FABRIC_ACTION_POLICY_REGISTER_EVENT,
144
143
  FABRIC_COMPACTION_OWNER_EVENT,
@@ -176,10 +175,7 @@ import {
176
175
  import {
177
176
  isFabricExecutionTraceV1,
178
177
  readFabricExecutionTraceV1
179
- } from "./chunk-PUBHBEYO.js";
180
- import {
181
- stableJsonHash
182
- } from "./chunk-3YZUQESG.js";
178
+ } from "./chunk-B2FIGOPI.js";
183
179
  import {
184
180
  FABRIC_ACTOR_PI_HOST_EVENTS
185
181
  } from "./chunk-IIPKG52D.js";
@@ -187,6 +183,13 @@ import {
187
183
  FABRIC_THINKING_BOUNDS_ENV,
188
184
  FABRIC_THINKING_ENTRY_TYPE
189
185
  } from "./chunk-V73NIH6B.js";
186
+ import {
187
+ getActiveRepairCompiler,
188
+ setActiveCompiledSurface
189
+ } from "./chunk-2QJ4MNS6.js";
190
+ import {
191
+ stableJsonHash
192
+ } from "./chunk-3YZUQESG.js";
190
193
  import {
191
194
  readChildToolAllowlist
192
195
  } from "./chunk-6OGYPHNQ.js";
@@ -229,6 +232,7 @@ var createFabricPersistedExecutionDetails = (input) => {
229
232
  details.omittedCalls = {
230
233
  count: omitted.count + 1,
231
234
  done: omitted.done + (dropped.success !== void 0 ? 1 : 0),
235
+ ...(omitted.internal ?? 0) + Number(isRoutineInternalCall(dropped)) > 0 ? { internal: (omitted.internal ?? 0) + Number(isRoutineInternalCall(dropped)) } : {},
232
236
  ...(omitted.failed ?? 0) + (dropped.success === false ? 1 : 0) > 0 ? { failed: (omitted.failed ?? 0) + (dropped.success === false ? 1 : 0) } : {}
233
237
  };
234
238
  }
@@ -302,11 +306,12 @@ var readFabricExecutionRenderDetails = (value) => {
302
306
  };
303
307
  var omittedCalls = (value) => {
304
308
  if (!isRecord(value)) return void 0;
305
- const { count, done, failed } = value;
309
+ const { count, done, failed, internal } = value;
306
310
  if (typeof count !== "number" || !Number.isInteger(count) || count <= 0) return void 0;
307
311
  const finished = typeof done === "number" && Number.isInteger(done) ? Math.min(Math.max(0, done), count) : 0;
308
312
  const failures = typeof failed === "number" && Number.isInteger(failed) ? Math.min(Math.max(0, failed), finished) : 0;
309
- return { omittedCalls: { count, done: finished, ...failures > 0 ? { failed: failures } : {} } };
313
+ const plumbing = typeof internal === "number" && Number.isInteger(internal) ? Math.min(Math.max(0, internal), finished - failures) : 0;
314
+ return { omittedCalls: { count, done: finished, ...failures > 0 ? { failed: failures } : {}, ...plumbing > 0 ? { internal: plumbing } : {} } };
310
315
  };
311
316
  var FABRIC_PARTIAL_AUDITS_MAX_BYTES = 128 * 1024;
312
317
  var FABRIC_PARTIAL_UPDATE_MAX_BYTES = 256 * 1024;
@@ -364,10 +369,12 @@ var createFabricPartialExecutionDetails = (input) => {
364
369
  const audits = [...kept.keys()].sort((left, right) => left - right).map((index) => kept.get(index));
365
370
  let omittedDone = 0;
366
371
  let omittedFailed = 0;
372
+ let omittedInternal = 0;
367
373
  for (let index = 0; index < total; index++) {
368
374
  if (!kept.has(index)) {
369
375
  if (input.audits[index].success !== void 0) omittedDone++;
370
376
  if (input.audits[index].success === false) omittedFailed++;
377
+ if (isRoutineInternalCall(input.audits[index])) omittedInternal++;
371
378
  }
372
379
  }
373
380
  const omitted = total - audits.length;
@@ -377,7 +384,7 @@ var createFabricPartialExecutionDetails = (input) => {
377
384
  ...input.deadlineAt !== void 0 ? { deadlineAt: input.deadlineAt } : {},
378
385
  phases: [],
379
386
  audits,
380
- ...omitted > 0 ? { omittedCalls: { count: omitted, done: omittedDone, ...omittedFailed > 0 ? { failed: omittedFailed } : {} } } : {}
387
+ ...omitted > 0 ? { omittedCalls: { count: omitted, done: omittedDone, ...omittedFailed > 0 ? { failed: omittedFailed } : {}, ...omittedInternal > 0 ? { internal: omittedInternal } : {} } } : {}
381
388
  };
382
389
  let bytes = serializedBytes({ content: [{ type: "text", text: progress ?? "" }], details });
383
390
  for (let index = input.phases.length - 1; index >= Math.max(0, input.phases.length - PARTIAL_PHASES); index--) {
@@ -491,6 +498,21 @@ var TimingFooter = class {
491
498
  if (!isTimingOnlyRender(this.state)) this.component.invalidate?.();
492
499
  }
493
500
  };
501
+ var BACKGROUND_SHORTCUT = "(ctrl+b to run in background)";
502
+ var BackgroundShortcutFooter = class {
503
+ constructor(component, theme) {
504
+ this.component = component;
505
+ this.theme = theme;
506
+ }
507
+ render(width) {
508
+ const lines = this.component.render(width);
509
+ if (width < 12 || lines.some((line) => line.includes("ctrl+b"))) return lines;
510
+ return [...continueArcGroup(lines), truncateToWidth(this.theme.fg("muted", `\u2570\u2500 ${BACKGROUND_SHORTCUT}`), width, "")];
511
+ }
512
+ invalidate() {
513
+ this.component.invalidate?.();
514
+ }
515
+ };
494
516
  var renderTimedResult = (context, theme, render, label) => {
495
517
  const state = timingState(context);
496
518
  if (!state) return render(context);
@@ -588,7 +610,11 @@ var withCodePreviewShell = (tool, options = {}) => {
588
610
  const originalRenderCall = tool.renderCall;
589
611
  const originalRenderResult = tool.renderResult;
590
612
  const renderCall = (args, theme, context) => originalRenderCall ? originalRenderCall.call(tool, args, theme, context) : new Text(theme.fg("toolTitle", theme.bold(tool.label || tool.name)), 0, 0);
591
- const renderResult = (result, resultOptions, theme, context) => originalRenderResult ? originalRenderResult.call(tool, result, resultOptions, theme, context) : new Container();
613
+ const renderResult = (result, resultOptions, theme, context) => {
614
+ const component = originalRenderResult ? originalRenderResult.call(tool, result, resultOptions, theme, context) : new Container();
615
+ const background = typeof context.args === "object" && context.args !== null && context.args.background === true;
616
+ return options.backgroundShortcut && context.executionStarted && context.isPartial && !background ? new BackgroundShortcutFooter(component, theme) : component;
617
+ };
592
618
  return {
593
619
  ...tool,
594
620
  renderShell: mode === "on" ? "default" : "self",
@@ -1179,12 +1205,13 @@ function registerFabricCommand(pi, deps) {
1179
1205
  }
1180
1206
  });
1181
1207
  pi.registerCommand("fabric", {
1182
- description: "Open Fabric dashboard, chat or tasks, arm prewalk, reload, or manage agents and actors",
1208
+ description: "Open Fabric dashboard, chat or tasks, background a running workflow, arm prewalk, reload, or manage agents and actors",
1183
1209
  getArgumentCompletions: (argumentPrefix) => {
1184
1210
  const subcommands = [
1185
1211
  "status",
1186
1212
  "dashboard",
1187
1213
  "tasks",
1214
+ "background",
1188
1215
  "chat",
1189
1216
  "focus",
1190
1217
  "settings",
@@ -1314,6 +1341,16 @@ function registerFabricCommand(pi, deps) {
1314
1341
  },
1315
1342
  // The subcommands load at first use, not while registering the command.
1316
1343
  async handler(argumentsText, context) {
1344
+ const [command, ...args] = argumentsText.trim().split(/\s+/);
1345
+ if (command === "background") {
1346
+ if (args.length) {
1347
+ context.ui.notify("Usage: /fabric background", "warning");
1348
+ return;
1349
+ }
1350
+ const count = state.programTasks.detachWaiting();
1351
+ context.ui.notify(count ? `Fabric: ${count === 1 ? "whole workflow moved" : `${count} whole workflows moved`} to the background. Work continues; completion will be reported. /fabric tasks` : "Fabric: no foreground workflow to background", "info");
1352
+ return;
1353
+ }
1317
1354
  const { runFabricCommand } = await import("../commands/fabric-handler.js");
1318
1355
  await runFabricCommand(pi, deps, commandHost, argumentsText, context);
1319
1356
  }
@@ -1744,6 +1781,29 @@ var FabricDirectToolApproval = class {
1744
1781
  }
1745
1782
  };
1746
1783
 
1784
+ // src/core/execution-guidelines.ts
1785
+ var schemaDiscipline = "Form a falsifiable hypothesis covering the reported failure and affected paths. Let contrary evidence invalidate the plan. Verify postconditions before declaring success.";
1786
+ var taskDiscipline = "Be ambitious and persistent: work through uncertainty, try alternatives, and verify the result. Treat new requests as additive, not replacements; keep existing work progressing unless explicitly reprioritized.";
1787
+ var fabricExecutionGuidelines = (kernel = "typescript", pythonRuntime = "monty", managedHost = false) => managedHost ? [
1788
+ "Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence.",
1789
+ schemaDiscipline,
1790
+ taskDiscipline
1791
+ ] : [
1792
+ kernel === "python" ? "Batch independent I/O in one `fabric_exec` Python program with `asyncio.gather`; await dependent steps sequentially. Coalesce independent replacements into one `await pi.edit(path=..., edits=[...])`. Inspect findings before choosing dependent reads or edits. Background long-running work when independent tasks can proceed; collect its result before completion. Return JSON-compatible evidence." : "Batch independent I/O in one `fabric_exec` program (`Promise.all` for parallel, sequential `await` for ordered). Coalesce independent replacements from one file snapshot into one `pi.edit({path, edits:[...]})`; use `all:true` only for intentional repeated exact anchors. Inspect findings before choosing dependent reads or edits. Background long-running work when independent tasks can proceed; collect its result before completion.",
1793
+ kernel === "python" ? "Search before reading with `await pi.grep(pattern=..., path=...)` or `await pi.find(pattern=..., path=...)`, then `await pi.read(path=..., offset=..., limit=...)`. Use Python dict syntax, `True`/`False`/`None`, and bounded searches; unbounded reads cap at 2000 lines or 50KB. Read continuation notices when needed." : "Search before reading: use `pi.grep`/`pi.find` to locate relevant lines, then `pi.read({path, offset, limit})` that range. Escape regex metacharacters, or use `literal:true` for exact punctuated text. Keep fan-out search limits small and widen only on misses. An unbounded `pi.read` returns at most 2000 lines or 50KB and, when truncated, ends with a `Use offset=\u2026` continuation notice; reserve whole-file reads for small files you will use in full.",
1794
+ schemaDiscipline,
1795
+ taskDiscipline,
1796
+ "For edits/writes, pass named payloads through top-level `payloads`; each `\u03C0.key` must exactly match a key there; prefer `pi.edit`/`pi.write`. `pi.bash`: no stdin.",
1797
+ "Use `display.name` and objective `display.description`; Fabric pairs them with verified outcomes in deterministic compaction.",
1798
+ ...kernel === "python" && pythonRuntime === "monty" ? ["Monty requires acyclic JSON host arguments. For underscore-prefixed provider/tool names, use `await tools.call(ref=..., args={...})`, not direct attributes. Use `payloads['key']` for private/non-identifier payload keys."] : []
1799
+ ];
1800
+ var fabricOwnedExecutionGuidelines = () => [.../* @__PURE__ */ new Set([
1801
+ ...fabricExecutionGuidelines(),
1802
+ ...fabricExecutionGuidelines("python", "monty"),
1803
+ ...fabricExecutionGuidelines("python", "cpython"),
1804
+ ...fabricExecutionGuidelines("typescript", "monty", true)
1805
+ ])];
1806
+
1747
1807
  // src/fabric-exec-tool.ts
1748
1808
  import { Container as Container2, Text as Text2 } from "@earendil-works/pi-tui";
1749
1809
  import { Type } from "typebox";
@@ -2063,17 +2123,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
2063
2123
  label: "Fabric",
2064
2124
  description: managedHost ? "Execute type-checked TypeScript in the managed QuickJS runtime. See the managed execution guidance for authorized tool contracts." : python ? monty ? "Execute Python through Fabric's configured Monty sandbox. Monty runs a Python subset with VM resource limits, no native filesystem/network/environment access, and only host-mediated tools. Each invocation starts fresh. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute Python through Fabric\u2019s configured CPython kernel for Pi core tools, MCP, providers, discovery, and extensions. Each call uses a fresh process. Native execution is trusted code; Schema enforce requires OS isolation. This is the exclusive model tool path in full code mode and Schema enforce mode." : "Execute code through Fabric's TypeScript kernel: type-checked TypeScript by default, unmodified JavaScript with executor.codemodeProfile native. Both support nativeTools; native mode places Pi-compatible calls on tools and Fabric discovery on fabric.tools. Compose Pi core tools, MCP, Fabric providers, discovery, and extensions. QuickJS is isolated by default; the optional Node/Bun process is an unsafe trusted-code escape hatch. In full code mode, and always in Schema enforce mode, this is the exclusive model tool path.",
2065
2125
  promptSnippet: managedHost ? `Authorized host tools (${managedHost.providers.join(", ") || "none"}) and deterministic computation` : "Pi core tools, MCP, Fabric providers, discovery, and extensions",
2066
- promptGuidelines: managedHost ? [
2067
- "Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence."
2068
- ] : [
2069
- python ? "Batch independent operations in one `fabric_exec` Python program with `asyncio.gather`; await dependent/conditional steps sequentially. Coalesce independent replacements into one `await pi.edit(path=..., edits=[...])`. Return only the compact final JSON-compatible value." : "Batch independent operations in one `fabric_exec` program (`Promise.all` for parallel, sequential `await` for ordered), not one call per tool; keep dependent/conditional steps sequential. Coalesce non-dependent replacements from one file snapshot into one `pi.edit({path, edits:[...]})`; use `all:true` only for intentional repeated exact anchors. Return only the compact final value; intermediate results stay in the sandbox.",
2070
- python ? "Search before reading with `await pi.grep(pattern=..., path=...)` or `await pi.find(pattern=..., path=...)`, then `await pi.read(path=..., offset=..., limit=...)`. Use Python dict syntax, `True`/`False`/`None`, and bounded searches; unbounded reads cap at 2000 lines or 50KB. Read continuation notices when needed." : "Search before reading: use `pi.grep`/`pi.find` to locate relevant lines, then `pi.read({path, offset, limit})` that range. Escape regex metacharacters, or use `literal:true` for exact punctuated text. Keep fan-out search limits small and widen only on misses. An unbounded `pi.read` returns at most 2000 lines or 50KB and, when truncated, ends with a `Use offset=\u2026` continuation notice; reserve whole-file reads for small files you will use in full.",
2071
- "Keep the acceptance ledger in reasoning or concise progress notes (no tool call): define concrete checks, trace execution before editing, implement end to end, then run targeted tests and direct behavioral probes. Confirm requested public symbols, registrations, and configuration entries. Use the smallest checks that cover the ledger; escalate only for failures or cross-cutting risk. Inspect failures and iterate instead of rerunning unchanged passing checks. A build alone is not completion.",
2072
- python ? "For test/probe nonzero exits, use `await pi.bash(command=..., settle=True)` and inspect the returned dict: `r['ok']`, `r['output']`, and `r.get('exitCode')`. Set shell `timeout` in seconds once for long suites. Return decisions and evidence rather than raw logs." : "Amortize round trips without inflating context: batch only independent, bounded work. Keep search\u2192read and edit\u2192verify sequential when an output determines the next action. Use `settle:true` for tests or probes whose nonzero result is evidence rather than an exceptional stop; for a known long suite, set `pi.bash` `timeout` in seconds once instead of retrying a timed-out call. Filter or summarize noisy command output inside the program and return decisions, failures, and evidence\u2014not raw logs or unused intermediate results.",
2073
- "For edits/writes, pass named payloads through top-level `payloads`; each `\u03C0.key` must exactly match a key there; prefer `pi.edit`/`pi.write`. `pi.bash`: no stdin.",
2074
- "Use `display.name` and objective `display.description`; Fabric pairs them with verified outcomes in deterministic compaction.",
2075
- ...monty ? ["Monty requires acyclic JSON host arguments. For underscore-prefixed provider/tool names, use `await tools.call(ref=..., args={...})`, not direct attributes. Use `payloads['key']` for private/non-identifier payload keys."] : []
2076
- ],
2126
+ promptGuidelines: fabricExecutionGuidelines(toolKernel(state), python ? state.config.executor.pythonRuntime : void 0, Boolean(managedHost)),
2077
2127
  // The model-facing schema is intentionally flat: one large `code` string
2078
2128
  // plus scalar/optional params. Do not add nested arrays-of-objects with
2079
2129
  // escaped content here. SOTA models are post-trained on one dominant
@@ -2120,7 +2170,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
2120
2170
  })
2121
2171
  ),
2122
2172
  background: Type.Optional(Type.Boolean({
2123
- description: "Run the program as a background task and return at once; its result arrives as a background task event. Use for long workflows (many agents) whose result you do not need before continuing."
2173
+ description: "Run this entire program in the background and return its task handle immediately. Use for long workflows, including waits for required shell or agent results: keep dependent awaits inside this program. Main can do independent work or yield for the completion event instead of opening another foreground wait. Backgrounding is not task completion; do not restart the work or claim success while results are pending."
2124
2174
  })),
2125
2175
  timeout_ms: Type.Optional(Type.Integer({ minimum: 1, description: "Hard whole-script deadline in milliseconds; cannot be extended or paused, capped by executor.maxTimeoutMs." })),
2126
2176
  maxOutputTokens: Type.Optional(Type.Integer({ minimum: 1, description: "Per-call output token budget (estimated at four characters per token), capped by executor.maxOutputChars." })),
@@ -2299,6 +2349,13 @@ ${preview}` : ""}${hiddenHint}`,
2299
2349
  audits = restoreFabricWritePreviews(audits, rendererState.fabricWritePreviews);
2300
2350
  }
2301
2351
  }
2352
+ audits = audits.filter((audit) => !isRoutineInternalCall(audit));
2353
+ const internal = details.omittedCalls?.internal ?? 0;
2354
+ if (details.omittedCalls && internal > 0) {
2355
+ const count = details.omittedCalls.count - internal;
2356
+ if (count > 0) details.omittedCalls = { ...details.omittedCalls, count, done: details.omittedCalls.done - internal, internal: 0 };
2357
+ else delete details.omittedCalls;
2358
+ }
2302
2359
  const phases = details.phases;
2303
2360
  const nl = "\n";
2304
2361
  const allRowIndexes = (lines, enabled) => enabled ? new Set(lines.map((_line, index) => index)) : void 0;
@@ -2342,9 +2399,6 @@ ${preview}` : ""}${hiddenHint}`,
2342
2399
  const audit = audits[0];
2343
2400
  const glyph = audit.success === void 0 ? theme.fg("warning", spinner) : audit.success === false ? theme.fg("error", "\u2717") : theme.fg("dim", "\u203A");
2344
2401
  let text2 = `${glyph} ${nestedCallTitle(audit, theme, context?.invalidate, corePreviewContext)}`;
2345
- if (shellBackgroundShortcut(audit)) {
2346
- text2 += nl + theme.fg("dim", "Ctrl+B twice \xB7 background waiting shell");
2347
- }
2348
2402
  const previewLines = renderAgentToolPreviewLines(audit, theme, {
2349
2403
  expanded,
2350
2404
  showTools: showAgentToolPreview,
@@ -2378,6 +2432,7 @@ ${preview}` : ""}${hiddenHint}`,
2378
2432
  if (previewLines.length > 1) text2 += nl + previewLines.slice(1).join(nl);
2379
2433
  }
2380
2434
  const textLines = text2.split(nl);
2435
+ if (shellBackgroundShortcut(audit)) pushArcItem(textLines, arcItem(theme, "(ctrl+b to run in background)"));
2381
2436
  return trackRows(
2382
2437
  renderBoundedLines(
2383
2438
  textLines,
@@ -2840,7 +2895,8 @@ ${recoveryHint}` : ""}`,
2840
2895
  }),
2841
2896
  {
2842
2897
  mode: codePreviewSettings.toolCallBackground,
2843
- toolCallTiming: codePreviewSettings.toolCallTiming
2898
+ toolCallTiming: codePreviewSettings.toolCallTiming,
2899
+ backgroundShortcut: true
2844
2900
  }
2845
2901
  );
2846
2902
  };
@@ -4182,7 +4238,7 @@ var colorStatus = (theme, status, value) => {
4182
4238
  var phaseProgress = (run, phaseId) => {
4183
4239
  const phase = run.phases.find((candidate) => candidate.id === phaseId);
4184
4240
  const statuses = [
4185
- ...run.calls.filter((call) => call.phaseId === phaseId).map((call) => call.status),
4241
+ ...run.calls.filter((call) => !isRoutineInternalCall(call) && call.phaseId === phaseId).map((call) => call.status),
4186
4242
  ...run.items.filter((item) => item.phaseId === phaseId).map((item) => item.status)
4187
4243
  ];
4188
4244
  const completed = statuses.filter((status) => status === "completed").length;
@@ -4223,17 +4279,20 @@ var treeOrder = (agents) => {
4223
4279
  }
4224
4280
  const ordered = [];
4225
4281
  const seen = /* @__PURE__ */ new Set();
4226
- const visit = (agent, depth) => {
4282
+ const visit = (agent, ancestors, last) => {
4227
4283
  if (seen.has(agent.id)) return;
4228
4284
  seen.add(agent.id);
4229
- ordered.push({ agent, depth });
4230
- for (const child of children.get(agent.id) ?? []) visit(child, depth + 1);
4285
+ const depth = ancestors.length;
4286
+ const prefix = depth === 0 ? "" : `${ancestors.slice(1).map((more) => more ? "\u2502 " : " ").join("")}${last ? "\u2514\u2500 " : "\u251C\u2500 "}`;
4287
+ ordered.push({ agent, depth, prefix });
4288
+ const descendants = (children.get(agent.id) ?? []).filter((child) => !seen.has(child.id));
4289
+ descendants.forEach((child, index) => visit(child, [...ancestors, !last], index === descendants.length - 1));
4231
4290
  };
4232
- for (const root of roots) visit(root, 0);
4233
- for (const agent of agents) visit(agent, 0);
4291
+ for (const root of roots) visit(root, [], true);
4292
+ for (const agent of agents) visit(agent, [], true);
4234
4293
  return ordered;
4235
4294
  };
4236
- var agentLine = (theme, agent, now, depth, selected, width) => {
4295
+ var agentLine = (theme, agent, now, prefix, selected, width) => {
4237
4296
  const status = colorStatus(theme, agent.status, circle(selected));
4238
4297
  const live = isActiveStatus(agent.status);
4239
4298
  const activity = live ? agent.milestone ?? agent.currentTool ?? (agent.status === "running" ? "thinking" : agent.status) : agent.error ? `error: ${safeText(agent.error)}` : agent.text ? `result: ${safeText(agent.text)}` : agent.status;
@@ -4244,7 +4303,9 @@ var agentLine = (theme, agent, now, depth, selected, width) => {
4244
4303
  agent.startedAt ? formatDuration((agent.finishedAt ?? now) - agent.startedAt) : void 0
4245
4304
  ].filter((value) => Boolean(value));
4246
4305
  const name = safeText(agent.name);
4247
- const lead = `${" ".repeat(depth)}${status} ${selected ? theme.bold(name) : theme.fg("muted", name)}`;
4306
+ const prefixBudget = Math.max(0, Math.floor(width / 3));
4307
+ const compactPrefix = prefix.length <= prefixBudget ? prefix : prefixBudget >= 4 ? `\u2026${prefix.slice(-(prefixBudget - 1))}` : "";
4308
+ const lead = `${theme.fg("dim", compactPrefix)}${status} ${selected ? theme.bold(name) : theme.fg("muted", name)}`;
4248
4309
  return fitLine(theme, width, lead, { text: safeText(activity).replace(/\s+/g, " ").trim(), gap: " ", color: "muted" }, metrics, []);
4249
4310
  };
4250
4311
  var shouldShowFabricWidget = (snapshot, mode, retention = new FabricWidgetRetention()) => {
@@ -4270,10 +4331,14 @@ var widgetRowLimit = (maxRows, terminalRows) => {
4270
4331
  const paneShare = Math.floor(terminalRows * WIDGET_TERMINAL_ROW_SHARE);
4271
4332
  return Math.max(1, Math.min(configured, paneShare));
4272
4333
  };
4273
- var widgetFocusedRowLimit = (maxRows, terminalRows) => {
4274
- const limit = widgetRowLimit(maxRows, terminalRows);
4275
- if (terminalRows === void 0 || !Number.isFinite(terminalRows) || terminalRows <= 0) return limit;
4276
- return Math.max(limit, Math.floor(terminalRows * WIDGET_TERMINAL_ROW_SHARE));
4334
+ var widgetFocusedRowLimit = (maxRows, terminalRows) => widgetRowLimit(maxRows, terminalRows);
4335
+ var widgetViewport = (contentRows, budget, offset) => {
4336
+ const available = Math.max(0, Math.floor(budget));
4337
+ const maxOffset = available > 0 ? Math.max(0, contentRows - available) : 0;
4338
+ const clampedOffset = Math.max(0, Math.min(maxOffset, Math.floor(offset)));
4339
+ const hasCue = clampedOffset < maxOffset && available > 1;
4340
+ const windowRows = Math.max(0, available - Number(hasCue));
4341
+ return { windowRows, hasCue, maxOffset, offset: clampedOffset };
4277
4342
  };
4278
4343
  var HEADER_ROW = "\0main";
4279
4344
  var FabricWidget = class {
@@ -4295,23 +4360,28 @@ var FabricWidget = class {
4295
4360
  /** Rows above the header in the last render: the spacer, or none on a one-row budget. */
4296
4361
  #spacerRows = 1;
4297
4362
  #renderedInteraction;
4363
+ #scrollOffset = 0;
4364
+ #maxScrollOffset = 0;
4365
+ #followSelection = false;
4298
4366
  /** Select the row on screen, or the first row; used when focus arrives from the keyboard. */
4299
4367
  selectDefault() {
4300
4368
  const rows = this.#selectableRows();
4301
4369
  if (rows.some((row) => row.id === this.#selectedId)) return;
4302
4370
  const viewing = this.interaction?.viewing?.();
4303
4371
  this.#selectedId = rows.find((row) => row.id === viewing)?.id ?? rows[0]?.id;
4372
+ this.#followSelection = true;
4304
4373
  }
4305
4374
  /** Select the top row; ↓ from the editor lands on the row next to it. */
4306
4375
  selectFirst() {
4307
4376
  this.#selectedId = this.#selectableRows()[0]?.id;
4377
+ this.#followSelection = true;
4308
4378
  }
4309
4379
  /** True while at least one row can take focus. */
4310
4380
  hasRows() {
4311
4381
  return this.#selectableRows().length > 0;
4312
4382
  }
4313
4383
  #interactionKey() {
4314
- return `${this.focused}|${this.#selectedId ?? ""}|${this.#hoveredId ?? ""}|${this.interaction?.viewing?.() ?? ""}|${this.interaction?.collapseIdle?.() ?? ""}`;
4384
+ return `${this.focused}|${this.#selectedId ?? ""}|${this.#hoveredId ?? ""}|${this.#scrollOffset}|${this.#followSelection}|${this.interaction?.viewing?.() ?? ""}|${this.interaction?.collapseIdle?.() ?? ""}`;
4315
4385
  }
4316
4386
  handleInput(data) {
4317
4387
  this.#hoveredId = void 0;
@@ -4319,7 +4389,10 @@ var FabricWidget = class {
4319
4389
  const index = Math.max(0, rows.findIndex((row) => row.id === this.#selectedId));
4320
4390
  const select = (next) => {
4321
4391
  const row = rows[Math.max(0, Math.min(rows.length - 1, next))];
4322
- if (row) this.#selectedId = row.id;
4392
+ if (row) {
4393
+ this.#selectedId = row.id;
4394
+ this.#followSelection = true;
4395
+ }
4323
4396
  };
4324
4397
  if (matchesKey(data, "escape") || matchesKey(data, FABRIC_WIDGET_FOCUS_SHORTCUT)) {
4325
4398
  this.interaction?.release();
@@ -4339,6 +4412,15 @@ var FabricWidget = class {
4339
4412
  }
4340
4413
  handleMouse(event) {
4341
4414
  if (!this.interaction) return void 0;
4415
+ if (event.type === "wheel") {
4416
+ if (event.x < 0 || event.x >= (this.#lastWidth ?? 0) || event.y < this.#spacerRows || event.y >= (this.#lastLines?.length ?? 0) || this.#maxScrollOffset === 0 || !Number.isFinite(event.wheelDelta) || !event.wheelDelta) return void 0;
4417
+ const offset = Math.max(0, Math.min(this.#maxScrollOffset, this.#scrollOffset + Math.trunc(event.wheelDelta)));
4418
+ const changed = offset !== this.#scrollOffset;
4419
+ this.#scrollOffset = offset;
4420
+ this.#followSelection = false;
4421
+ this.#hoveredId = void 0;
4422
+ return { handled: true, render: changed };
4423
+ }
4342
4424
  const row = this.#rows.find((candidate) => candidate.line === event.y - this.#spacerRows);
4343
4425
  if (event.type === "move") {
4344
4426
  const header = event.y === this.#spacerRows && (this.#lastLines?.length ?? 0) > this.#spacerRows;
@@ -4364,8 +4446,8 @@ var FabricWidget = class {
4364
4446
  if (budget === 0) return [];
4365
4447
  const { lines, rows } = this.#content(this.snapshot(), Number.MAX_SAFE_INTEGER);
4366
4448
  const body = Math.max(1, budget - (budget >= 2 ? 1 : 0));
4367
- const visible = body >= 3 && lines.length > body ? body - 1 : body;
4368
- return this.focused && body > 1 ? rows : rows.filter((row) => row.line < visible);
4449
+ const viewport = widgetViewport(lines.length - 1, body - 1, this.#scrollOffset);
4450
+ return this.focused && body > 1 ? rows : rows.filter((row) => row.line === 0 || row.line > viewport.offset && row.line <= viewport.offset + viewport.windowRows);
4369
4451
  }
4370
4452
  #rowLimit(width = this.#lastWidth) {
4371
4453
  const limit = this.focused ? widgetFocusedRowLimit(this.maxRows, this.terminalRows?.()) : widgetRowLimit(this.maxRows, this.terminalRows?.());
@@ -4429,30 +4511,30 @@ var FabricWidget = class {
4429
4511
  if (this.#hoveredId !== void 0 && this.#hoveredId !== HEADER_ROW && !rows.some((row) => row.id === this.#hoveredId)) {
4430
4512
  this.#hoveredId = void 0;
4431
4513
  }
4432
- const selectedLine = this.focused && body > 1 ? rows.find((row) => row.id === this.#selectedId)?.line ?? 0 : 0;
4433
- let capacity = body - 1;
4434
- let start = Math.max(1, selectedLine - capacity + 1);
4435
- let below = Math.max(0, lines.length - start - capacity);
4436
- if (below > 0 && body >= 3) {
4437
- capacity--;
4438
- start = Math.max(1, selectedLine - capacity + 1);
4439
- below = Math.max(0, lines.length - start - capacity);
4440
- }
4441
- const above = start - 1;
4442
- const upLabel = above > 0 ? `\u2191 ${above} more` : void 0;
4443
- const downLabel = body < 3 && below > 0 ? `\u2193 ${below} more` : void 0;
4444
- let label = upLabel ?? downLabel;
4445
- if (upLabel && downLabel) {
4446
- const identityWidth = 2 + visibleWidth2(safeText(snapshot.sessionLabel ?? "Fabric"));
4447
- const candidates = [`${upLabel} \xB7 ${downLabel}`, `\u2191 ${above} \xB7 \u2193 ${below}`, upLabel, `\u2191 ${above}`];
4448
- const fits = (candidate, identity) => visibleWidth2(candidate) + 1 + identity <= width;
4449
- label = candidates.find((candidate) => fits(candidate, identityWidth)) ?? candidates.find((candidate) => fits(candidate, Math.min(identityWidth, 8)));
4514
+ let viewport = widgetViewport(lines.length - 1, body - 1, this.#scrollOffset);
4515
+ if (this.focused && this.#followSelection && viewport.windowRows > 0) {
4516
+ const selected = (rows.find((row) => row.id === this.#selectedId)?.line ?? 0) - 1;
4517
+ let offset = viewport.offset;
4518
+ if (selected < offset) offset = Math.max(0, selected);
4519
+ else if (selected >= offset + viewport.windowRows) offset = selected - viewport.windowRows + 1;
4520
+ viewport = widgetViewport(lines.length - 1, body - 1, offset);
4450
4521
  }
4522
+ this.#followSelection = false;
4523
+ this.#scrollOffset = viewport.offset;
4524
+ this.#maxScrollOffset = viewport.maxOffset;
4525
+ const capacity = viewport.windowRows;
4526
+ const start = viewport.offset + 1;
4527
+ const below = Math.max(0, lines.length - start - capacity);
4528
+ const above = viewport.offset;
4529
+ const identityWidth = 2 + visibleWidth2(safeText(snapshot.sessionLabel ?? "Fabric"));
4530
+ const labels = above > 0 ? [`\u2191 ${above} more`, `\u2191 ${above}`] : [];
4531
+ const fits = (label2, identity) => visibleWidth2(label2) + 1 + identity <= width;
4532
+ const label = labels.find((label2) => fits(label2, identityWidth)) ?? labels.find((label2) => fits(label2, Math.min(identityWidth, 8)));
4451
4533
  const headerWidth = label && width >= visibleWidth2(label) + 2 ? width - visibleWidth2(label) - 1 : width;
4452
4534
  const header = headerWidth === width ? lines[0] ?? "" : this.#content(snapshot, width, headerWidth).lines[0] ?? "";
4453
4535
  const boundedHeader = label ? this.#withRightLabel(header, label, width) : truncateToWidth3(header, width);
4454
4536
  const visibleLines = [boundedHeader, ...lines.slice(start, start + capacity).map((line) => truncateToWidth3(line, width))];
4455
- if (below > 0 && body >= 3) visibleLines.push(truncateToWidth3(this.theme.fg("dim", `\u2193 ${below} more`), width));
4537
+ if (viewport.hasCue) visibleLines.push(truncateToWidth3(this.theme.fg("dim", `\u2193 ${below} more`), width));
4456
4538
  this.#rows = rows.filter((row) => row.line === 0 || row.line >= start && row.line < start + capacity).map((row) => ({ ...row, line: row.line === 0 ? 0 : row.line - start + 1 }));
4457
4539
  if (rows.length === 0 && this.interaction?.collapseIdle?.()) return [];
4458
4540
  this.#spacerRows = spacer;
@@ -4481,7 +4563,7 @@ var FabricWidget = class {
4481
4563
  const visibleActors = snapshot.actors.filter((actor) => actor.status !== "stopped");
4482
4564
  const activeActorWorkers = visibleActors.filter((actor) => actor.worker && isActiveStatus(actor.worker.status)).map((actor) => ({ ...actor.worker, name: actor.name, actorId: actor.id }));
4483
4565
  const terminalActorWorkers = visibleActors.filter((actor) => actor.worker && !isActiveStatus(actor.worker.status)).map((actor) => ({ ...actor.worker, name: actor.name, actorId: actor.id }));
4484
- const nestedCalls = run?.calls.filter((call) => call.kind !== "agent" && call.kind !== "actor") ?? [];
4566
+ const nestedCalls = run?.calls.filter((call) => !isRoutineInternalCall(call) && call.kind !== "agent" && call.kind !== "actor") ?? [];
4485
4567
  const shells = snapshot.shells ?? [];
4486
4568
  const liveShells = shells.filter((job) => job.finishedAt === void 0);
4487
4569
  const recentShells = shells.filter((job) => job.finishedAt !== void 0 && isRecentWidgetCompletion(job.finishedAt, snapshot.now));
@@ -4507,7 +4589,13 @@ var FabricWidget = class {
4507
4589
  }
4508
4590
  if (activeAgents.length > 0) parts.push(`${activeAgents.length} running`);
4509
4591
  if (visibleActors.length > 0) parts.push(`${visibleActors.length} actor${visibleActors.length === 1 ? "" : "s"}`);
4510
- if (liveShells.length > 0) parts.push(`${liveShells.length} shell${liveShells.length === 1 ? "" : "s"}`);
4592
+ const backgroundWork = liveShells.filter((job) => !job.observes);
4593
+ const shellCount = backgroundWork.filter((job) => job.tool !== "fabric_exec").length;
4594
+ const workflowCount = backgroundWork.length - shellCount;
4595
+ const observationCount = liveShells.length - backgroundWork.length;
4596
+ if (shellCount) parts.push(`${shellCount} shell${shellCount === 1 ? "" : "s"}`);
4597
+ if (workflowCount) parts.push(`${workflowCount} workflow${workflowCount === 1 ? "" : "s"}`);
4598
+ if (observationCount) parts.push(`${observationCount} observation${observationCount === 1 ? "" : "s"}`);
4511
4599
  const tokens = totalTokens(snapshot, run);
4512
4600
  if (tokens > 0) parts.push(`${formatTokens(tokens)} tok`);
4513
4601
  const cost = totalCost(snapshot, run);
@@ -4529,7 +4617,28 @@ var FabricWidget = class {
4529
4617
  parts,
4530
4618
  this.#hints(hasRows)
4531
4619
  ));
4532
- const pushParticipant = (agent, kind, depth = 0) => {
4620
+ const shownObservations = /* @__PURE__ */ new Set();
4621
+ const pushObservation = (job, prefix) => {
4622
+ shownObservations.add(job.id);
4623
+ rows.push({ id: job.id, kind: "shell", name: safeText(job.description ?? job.command), line: lines.length });
4624
+ const active = job.finishedAt === void 0;
4625
+ const status = job.stopping ? "stopping" : active ? "watching" : job.status === "timed_out" ? "expired" : job.status === "killed" ? "stopped" : "ended";
4626
+ const delivery = job.monitor?.delivery === "wake" ? "wake owner" : "UI only";
4627
+ const remaining = active && job.monitor ? ` \xB7 expires in ${formatDuration(Math.max(0, job.startedAt + job.monitor.timeoutMs - snapshot.now)) || "0s"}` : "";
4628
+ lines.push(fitLine(
4629
+ this.theme,
4630
+ width,
4631
+ `${prefix}${colorStatus(this.theme, job.stopping ? "stopping" : job.status, circle(job.id === marked))} ${this.theme.fg("muted", job.id.slice(0, 8))} ${this.theme.fg("muted", `${status} \xB7 ${delivery}${remaining}`)}`,
4632
+ { text: safeText(job.description ?? `Observe ${job.observes.kind} ${job.observes.id.slice(0, 8)}`), gap: " \xB7 ", color: "dim" },
4633
+ [],
4634
+ []
4635
+ ));
4636
+ };
4637
+ const pushObservations = (kind, id) => {
4638
+ const children = listedShells.filter((job) => job.observes?.kind === kind && job.observes.id === id);
4639
+ children.forEach((job, index) => pushObservation(job, index === children.length - 1 ? " \u2570\u2500 " : " \u251C\u2500 "));
4640
+ };
4641
+ const pushParticipant = (agent, kind, prefix = "") => {
4533
4642
  const id = kind === "actor" ? agent.actorId ?? agent.id : agent.id;
4534
4643
  rows.push({
4535
4644
  id,
@@ -4538,7 +4647,8 @@ var FabricWidget = class {
4538
4647
  ...agent.model ? { model: agent.model } : {},
4539
4648
  line: lines.length
4540
4649
  });
4541
- lines.push(agentLine(this.theme, agent, snapshot.now, depth, id === marked, width));
4650
+ lines.push(agentLine(this.theme, agent, snapshot.now, prefix, id === marked, width));
4651
+ pushObservations("participant", agent.id);
4542
4652
  };
4543
4653
  const liveTrees = [];
4544
4654
  const settledTrees = [];
@@ -4547,10 +4657,10 @@ var FabricWidget = class {
4547
4657
  if (entry.depth === 0) liveRoot = isActiveStatus(entry.agent.status);
4548
4658
  (liveRoot ? liveTrees : settledTrees).push(entry);
4549
4659
  }
4550
- for (const { agent, depth } of liveTrees) pushParticipant(agent, "agent", depth);
4660
+ for (const { agent, prefix } of liveTrees) pushParticipant(agent, "agent", prefix);
4551
4661
  for (const agent of activeActorWorkers) pushParticipant(agent, "actor");
4552
4662
  for (const agent of terminalActorWorkers) pushParticipant(agent, "actor");
4553
- for (const { agent, depth } of settledTrees) pushParticipant(agent, "agent", depth);
4663
+ for (const { agent, prefix } of settledTrees) pushParticipant(agent, "agent", prefix);
4554
4664
  const shellLine = (job, name, detail, id) => {
4555
4665
  const status = job.stopping ? "stopping" : job.status;
4556
4666
  const elapsed2 = formatDuration((job.finishedAt ?? snapshot.now) - job.startedAt) || "0s";
@@ -4564,12 +4674,14 @@ var FabricWidget = class {
4564
4674
  []
4565
4675
  );
4566
4676
  };
4567
- for (const job of listedShells) {
4677
+ for (const job of listedShells.filter((job2) => !job2.observes)) {
4568
4678
  const status = job.stopping ? "stopping" : job.status;
4569
4679
  const label2 = job.monitor && job.finishedAt === void 0 && !job.stopping ? `monitor:${job.monitor.delivery}` : status;
4570
4680
  rows.push({ id: job.id, kind: "shell", name: safeText(job.description ?? job.command), line: lines.length });
4571
4681
  lines.push(shellLine(job, job.id.slice(0, 8), label2, job.id));
4682
+ pushObservations("task", job.id);
4572
4683
  }
4684
+ for (const job of listedShells) if (job.observes && !shownObservations.has(job.id)) pushObservation(job, "");
4573
4685
  return lines;
4574
4686
  }
4575
4687
  #withRightLabel(line, label, width) {
@@ -6445,18 +6557,20 @@ function createFabricExtension(entryUrl) {
6445
6557
  }
6446
6558
  });
6447
6559
  pi.on("agent_settled", async (event, context) => {
6560
+ const interrupted = event.aborted || context.signal?.aborted === true;
6448
6561
  if (state.managedHostOptions) {
6449
- if (state.config.compaction.engine === "fabric") await compactAtConfiguredThreshold(context, state.config);
6562
+ if (!interrupted && state.config.compaction.engine === "fabric") await compactAtConfiguredThreshold(context, state.config);
6450
6563
  if (state.initialized) await state.publishHostLifecycle("pi.agent_settled", event);
6451
6564
  return;
6452
6565
  }
6453
6566
  if (!state.initialized) {
6454
- if (!compactionOwner()) await compactAtConfiguredThreshold(context, state.config);
6567
+ if (!interrupted && !compactionOwner()) await compactAtConfiguredThreshold(context, state.config);
6455
6568
  return;
6456
6569
  }
6457
6570
  const sessionId = context.sessionManager.getSessionId();
6571
+ if (interrupted) state.compact.cancel();
6458
6572
  const settledInPlace = await settleInPlacePrewalk(state.prewalk, pi, context, {
6459
- compactOnReturn: state.config.prewalk.compactOnReturn,
6573
+ compactOnReturn: !interrupted && state.config.prewalk.compactOnReturn,
6460
6574
  compact: state.compact
6461
6575
  });
6462
6576
  if (!settledInPlace && state.prewalk.settleTask(sessionId)) {
@@ -6471,8 +6585,8 @@ function createFabricExtension(entryUrl) {
6471
6585
  } else {
6472
6586
  state.prewalkDrift.drop(sessionId);
6473
6587
  }
6474
- await state.compact.maybeCommit(context);
6475
- if (!compactionOwner()) {
6588
+ if (!interrupted) await state.compact.maybeCommit(context);
6589
+ if (!interrupted && !compactionOwner()) {
6476
6590
  await compactAtConfiguredThreshold(
6477
6591
  context,
6478
6592
  state.config,
@@ -6709,6 +6823,9 @@ function createFabricExtension(entryUrl) {
6709
6823
  defaultFabricExecutionGuidance,
6710
6824
  extensionToolRosterGuidance,
6711
6825
  fabricExecutionKernelGuidance,
6826
+ fabricGuidanceDelivery,
6827
+ relocateFabricGuidelines,
6828
+ stripFabricRuleBullets,
6712
6829
  managedHostExecutionGuidance,
6713
6830
  managedHostKernelGuidance,
6714
6831
  fabricSchemaGuidance
@@ -6717,8 +6834,25 @@ function createFabricExtension(entryUrl) {
6717
6834
  const captureSnapshot = state.bootstrapped ? capturePolicy() : void 0;
6718
6835
  const managedHost = state.managedHostOptions;
6719
6836
  const skillReader = managedHost ? managedHost.skillReader ?? null : void 0;
6720
- const sections = event.systemPromptOptions.forceSystemPrompt === void 0 ? event.systemPromptOptions.sections : void 0;
6721
- const systemPrompt = sections ? "" : restoreSkillsForFullCodePrompt(event.systemPrompt, skills, effectiveFullCodeMode, skillReader);
6837
+ const delivery = fabricGuidanceDelivery(
6838
+ true,
6839
+ event.systemPromptOptions.sections !== void 0,
6840
+ event.systemPromptOptions.forceSystemPrompt !== void 0
6841
+ );
6842
+ const sections = delivery.section ? event.systemPromptOptions.sections : void 0;
6843
+ const ownedExecutionRules = fabricOwnedExecutionGuidelines();
6844
+ const executionRules = relocateFabricGuidelines(
6845
+ event.systemPromptOptions.toolGuidelines,
6846
+ fabricExecutionGuidelines(config.executor.kernel, config.executor.pythonRuntime, Boolean(managedHost)),
6847
+ delivery,
6848
+ ownedExecutionRules
6849
+ );
6850
+ const systemPrompt = sections ? "" : restoreSkillsForFullCodePrompt(
6851
+ stripFabricRuleBullets(event.systemPrompt, ownedExecutionRules),
6852
+ skills,
6853
+ effectiveFullCodeMode,
6854
+ skillReader
6855
+ );
6722
6856
  const prompt = userPromptText(event);
6723
6857
  const skillReferenceGuidance = effectiveFullCodeMode && prompt !== void 0 ? buildSkillReferenceGuidance(prompt, skills, skillReader) : void 0;
6724
6858
  const currentModel = context.model ? `${context.model.provider}/${context.model.id}` : void 0;
@@ -6738,20 +6872,24 @@ function createFabricExtension(entryUrl) {
6738
6872
  const guidance = [
6739
6873
  managedHost ? managedHostKernelGuidance(managedHost) : fabricExecutionKernelGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile),
6740
6874
  resolvedGuidance.slotText,
6875
+ executionRules.text,
6741
6876
  fabricSchemaGuidance(schemaMode),
6742
6877
  overrideGuidance,
6743
6878
  extensionRoster,
6744
6879
  resolvedGuidance.appendText,
6745
6880
  managedHost?.guidance
6746
6881
  ].filter((section) => Boolean(section)).join("\n\n");
6882
+ const catalog = sections ? restoreSkillsForFullCodePrompt(sections.skills ?? "", skills, effectiveFullCodeMode, skillReader).trim() : void 0;
6883
+ const forced = delivery.append ? { systemPrompt: `${systemPrompt}
6884
+
6885
+ ${guidance}` } : {};
6747
6886
  if (sections) {
6748
- const catalog = restoreSkillsForFullCodePrompt("", skills, effectiveFullCodeMode, skillReader).trim();
6749
6887
  if (catalog) sections.skills = catalog;
6750
6888
  sections.fabric = guidance;
6751
6889
  }
6752
- const forced = sections ? {} : { systemPrompt: `${systemPrompt}
6753
-
6754
- ${guidance}` };
6890
+ if (executionRules.remaining !== void 0 && event.systemPromptOptions.toolGuidelines) {
6891
+ event.systemPromptOptions.toolGuidelines.fabric_exec = executionRules.remaining;
6892
+ }
6755
6893
  if (!skillReferenceGuidance) return sections ? void 0 : forced;
6756
6894
  return {
6757
6895
  ...forced,
@@ -6905,4 +7043,4 @@ export {
6905
7043
  FABRIC_MANAGED_HOST_VERSION,
6906
7044
  createFabricExtension
6907
7045
  };
6908
- //# sourceMappingURL=chunk-WGMCNCP6.js.map
7046
+ //# sourceMappingURL=chunk-F3D7GTBK.js.map