@e4779/pi-fabric 0.131.4-fork.33 → 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 (180) hide show
  1. package/dist/agents/completion-inbox.d.ts +2 -1
  2. package/dist/agents/completion-inbox.d.ts.map +1 -1
  3. package/dist/agents/manager.d.ts.map +1 -1
  4. package/dist/agents.js +5 -1
  5. package/dist/agents.js.map +1 -1
  6. package/dist/async-settlement.d.ts +1 -1
  7. package/dist/async-settlement.d.ts.map +1 -1
  8. package/dist/chunks/{chunk-HSEZPCL5.js → chunk-2OC4YJOL.js} +3 -3
  9. package/dist/chunks/{chunk-TXCNZCZP.js → chunk-2QJ4MNS6.js} +2 -2
  10. package/dist/chunks/{chunk-QOEOKW2X.js → chunk-3QH6JAE3.js} +2 -2
  11. package/dist/chunks/{chunk-3XT5WHSG.js → chunk-4Y5KEJP4.js} +3 -3
  12. package/dist/chunks/{chunk-RAA3FAYZ.js → chunk-5PSEJOJB.js} +2 -2
  13. package/dist/chunks/{chunk-XFOSUGLU.js → chunk-66UTGL7T.js} +2 -2
  14. package/dist/chunks/{chunk-RKJPBTBB.js → chunk-6ZPEPRUV.js} +6 -4
  15. package/dist/chunks/{chunk-RKJPBTBB.js.map → chunk-6ZPEPRUV.js.map} +2 -2
  16. package/dist/chunks/{chunk-7TB7NXSL.js → chunk-7CIQQOOD.js} +11 -3
  17. package/dist/chunks/{chunk-7TB7NXSL.js.map → chunk-7CIQQOOD.js.map} +2 -2
  18. package/dist/chunks/{chunk-PUBHBEYO.js → chunk-B2FIGOPI.js} +2 -2
  19. package/dist/chunks/{chunk-G2DZJ5LK.js → chunk-F3D7GTBK.js} +148 -47
  20. package/dist/chunks/chunk-F3D7GTBK.js.map +7 -0
  21. package/dist/chunks/{chunk-ZHROHNEE.js → chunk-F6GIK5GO.js} +8 -8
  22. package/dist/chunks/{chunk-LKYLD5SN.js → chunk-FMEOJJ6Y.js} +3 -2
  23. package/dist/chunks/chunk-FMEOJJ6Y.js.map +7 -0
  24. package/dist/chunks/{chunk-4PBW54I2.js → chunk-GGQ43B7T.js} +3 -3
  25. package/dist/chunks/{chunk-MSDL7U6Q.js → chunk-JSHIS7GO.js} +2 -2
  26. package/dist/chunks/{chunk-VGRUWTMG.js → chunk-JWERGULW.js} +7 -3
  27. package/dist/chunks/chunk-JWERGULW.js.map +7 -0
  28. package/dist/chunks/{chunk-HRDMBGMY.js → chunk-K4VRQ7WZ.js} +4 -4
  29. package/dist/chunks/{chunk-LZ2ZXOCU.js → chunk-LP5EVMBB.js} +154 -1
  30. package/dist/chunks/chunk-LP5EVMBB.js.map +7 -0
  31. package/dist/chunks/{chunk-56NMRVTV.js → chunk-MGFSQXAJ.js} +23 -23
  32. package/dist/chunks/{chunk-56NMRVTV.js.map → chunk-MGFSQXAJ.js.map} +2 -2
  33. package/dist/chunks/{chunk-RWKQ5SRW.js → chunk-MTAFECXB.js} +2 -2
  34. package/dist/chunks/{chunk-HRVYXRWZ.js → chunk-NGXAEGD2.js} +11 -1
  35. package/dist/chunks/{chunk-HRVYXRWZ.js.map → chunk-NGXAEGD2.js.map} +2 -2
  36. package/dist/chunks/{chunk-U6Y6TKJL.js → chunk-NSV7WTCT.js} +2 -2
  37. package/dist/chunks/{chunk-3VK6UGAN.js → chunk-O5SHIUIL.js} +6 -1
  38. package/dist/chunks/chunk-O5SHIUIL.js.map +7 -0
  39. package/dist/chunks/{chunk-4WKD3YM3.js → chunk-OILZ4PDY.js} +3 -3
  40. package/dist/chunks/{chunk-H57KPL3V.js → chunk-S2JWFXW5.js} +2 -2
  41. package/dist/chunks/{chunk-HFDJWLMS.js → chunk-SOEUGSY4.js} +2 -2
  42. package/dist/chunks/{chunk-KIFOEBYJ.js → chunk-VEXCD3RA.js} +2 -2
  43. package/dist/chunks/{chunk-GS67KDMV.js → chunk-VN7AE3EY.js} +2 -2
  44. package/dist/chunks/{chunk-MPMEK3IQ.js → chunk-WYLBWFAO.js} +2 -2
  45. package/dist/chunks/{chunk-6GWDGTHC.js → chunk-YLO62DWD.js} +4 -4
  46. package/dist/chunks/{chunk-4BYS4ZLY.js → chunk-YN4K3FNB.js} +5 -5
  47. package/dist/chunks/{chunk-OJ4HAALD.js → chunk-YO5UIWDY.js} +3 -3
  48. package/dist/chunks/{chunk-7N7IC3Z2.js → chunk-ZCXW3GR7.js} +2 -2
  49. package/dist/chunks/{chunk-L6H46CPY.js → chunk-ZY375C2U.js} +2 -2
  50. package/dist/commands/fabric-handler.js +1 -1
  51. package/dist/commands/fabric-handler.js.map +1 -1
  52. package/dist/commands/fabric.d.ts.map +1 -1
  53. package/dist/compaction/claim-events.js +7 -7
  54. package/dist/compaction/hook.js +6 -6
  55. package/dist/compaction/owner.js +7 -7
  56. package/dist/compaction/threshold.d.ts.map +1 -1
  57. package/dist/components/configuration.js +1 -1
  58. package/dist/core/action-registry.d.ts +1 -1
  59. package/dist/core/action-registry.d.ts.map +1 -1
  60. package/dist/core/action-registry.js +8 -8
  61. package/dist/core/attached-monitors.d.ts +39 -0
  62. package/dist/core/attached-monitors.d.ts.map +1 -0
  63. package/dist/core/execution-guidelines.d.ts +6 -0
  64. package/dist/core/execution-guidelines.d.ts.map +1 -0
  65. package/dist/core/guidance-delivery.d.ts +19 -0
  66. package/dist/core/guidance-delivery.d.ts.map +1 -0
  67. package/dist/core/observation-actions.d.ts +9 -0
  68. package/dist/core/observation-actions.d.ts.map +1 -0
  69. package/dist/core/prompt-guidance.d.ts +1 -0
  70. package/dist/core/prompt-guidance.d.ts.map +1 -1
  71. package/dist/core/prompt-guidance.js +50 -1
  72. package/dist/core/prompt-guidance.js.map +3 -3
  73. package/dist/core/provider-operations.js +1 -1
  74. package/dist/core/shell-inbox.d.ts +1 -1
  75. package/dist/core/shell-inbox.d.ts.map +1 -1
  76. package/dist/core/shell-jobs.d.ts +17 -1
  77. package/dist/core/shell-jobs.d.ts.map +1 -1
  78. package/dist/core/shell-monitor.d.ts +1 -0
  79. package/dist/core/shell-monitor.d.ts.map +1 -1
  80. package/dist/durable-extension.d.ts +2 -2
  81. package/dist/durable-extension.d.ts.map +1 -1
  82. package/dist/durable-extension.js +215 -1
  83. package/dist/durable-extension.js.map +3 -3
  84. package/dist/entropy/index.js +9 -9
  85. package/dist/extension-bootstrap.d.ts.map +1 -1
  86. package/dist/extension-bootstrap.js +9 -9
  87. package/dist/extension.d.ts.map +1 -1
  88. package/dist/fabric-exec-tool.d.ts.map +1 -1
  89. package/dist/fabric-runtime-state.d.ts.map +1 -1
  90. package/dist/fabric-runtime-state.js +325 -172
  91. package/dist/fabric-runtime-state.js.map +4 -4
  92. package/dist/index.js +18 -18
  93. package/dist/jev/client.js +2 -2
  94. package/dist/jev/observation.js +5 -5
  95. package/dist/jev.js +10 -10
  96. package/dist/memory/discovery.js +6 -6
  97. package/dist/memory/file-worker.js +8 -8
  98. package/dist/memory/normalize.js +5 -5
  99. package/dist/memory/search.js +6 -6
  100. package/dist/memory/worker-provider.js +9 -9
  101. package/dist/memory.js +9 -9
  102. package/dist/providers/agents-actions.d.ts.map +1 -1
  103. package/dist/providers/agents-message-router.d.ts.map +1 -1
  104. package/dist/providers/agents-provider.d.ts +2 -0
  105. package/dist/providers/agents-provider.d.ts.map +1 -1
  106. package/dist/providers/jev-provider.js +10 -10
  107. package/dist/providers/memory-provider.js +8 -8
  108. package/dist/providers/tasks-provider.d.ts +3 -1
  109. package/dist/providers/tasks-provider.d.ts.map +1 -1
  110. package/dist/residency/host.js +8 -8
  111. package/dist/residency/pi-entry.js +8 -8
  112. package/dist/runtime/core-override-guest-types.js +2 -2
  113. package/dist/runtime/cpython-runtime.js +1 -1
  114. package/dist/runtime/guest-types.d.ts +1 -1
  115. package/dist/runtime/guest-types.d.ts.map +1 -1
  116. package/dist/runtime/guest-types.js +1 -1
  117. package/dist/runtime/monty-runtime.js +1 -1
  118. package/dist/runtime/node-process-runtime.js +3 -3
  119. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  120. package/dist/runtime/quickjs-runtime.js +2 -2
  121. package/dist/runtime/typescript-kernel.js +5 -5
  122. package/dist/runtime-state-builtins.d.ts +2 -0
  123. package/dist/runtime-state-builtins.d.ts.map +1 -1
  124. package/dist/topology/peer-presence.d.ts.map +1 -1
  125. package/dist/topology/provider-participants.d.ts +1 -0
  126. package/dist/topology/provider-participants.d.ts.map +1 -1
  127. package/dist/type-error-guidance.js +1 -1
  128. package/dist/ui/code-preview-shell.d.ts +1 -0
  129. package/dist/ui/code-preview-shell.d.ts.map +1 -1
  130. package/dist/ui/dashboard.js +1 -1
  131. package/dist/ui/fabric-render.d.ts.map +1 -1
  132. package/dist/ui/settings.js +1 -1
  133. package/dist/ui/shell-tasks.d.ts.map +1 -1
  134. package/dist/ui/shell-tasks.js +20 -4
  135. package/dist/ui/shell-tasks.js.map +2 -2
  136. package/dist/ui/widget.d.ts +1 -1
  137. package/dist/ui/widget.d.ts.map +1 -1
  138. package/dist/verified/generated/manifest.json +12 -3
  139. package/dist/verified/generated/prompt-guidance.d.ts +4 -0
  140. package/dist/verified/generated/prompt-guidance.js +17 -0
  141. package/docs/agents.md +17 -0
  142. package/docs/background-tasks.md +74 -2
  143. package/docs/interface.md +1 -1
  144. package/docs/jev.md +1 -1
  145. package/docs/verified-kernels.md +23 -0
  146. package/package.json +1 -1
  147. package/proofs/index.ts +2 -0
  148. package/proofs/prompt-guidance.ts +38 -0
  149. package/scripts/verified-kernels.ts +1 -1
  150. package/skillsets/python/fabric-council/SKILL.md +24 -15
  151. package/skillsets/typescript/fabric-council/SKILL.md +23 -15
  152. package/dist/chunks/chunk-3VK6UGAN.js.map +0 -7
  153. package/dist/chunks/chunk-G2DZJ5LK.js.map +0 -7
  154. package/dist/chunks/chunk-LKYLD5SN.js.map +0 -7
  155. package/dist/chunks/chunk-LZ2ZXOCU.js.map +0 -7
  156. package/dist/chunks/chunk-VGRUWTMG.js.map +0 -7
  157. /package/dist/chunks/{chunk-HSEZPCL5.js.map → chunk-2OC4YJOL.js.map} +0 -0
  158. /package/dist/chunks/{chunk-TXCNZCZP.js.map → chunk-2QJ4MNS6.js.map} +0 -0
  159. /package/dist/chunks/{chunk-QOEOKW2X.js.map → chunk-3QH6JAE3.js.map} +0 -0
  160. /package/dist/chunks/{chunk-3XT5WHSG.js.map → chunk-4Y5KEJP4.js.map} +0 -0
  161. /package/dist/chunks/{chunk-RAA3FAYZ.js.map → chunk-5PSEJOJB.js.map} +0 -0
  162. /package/dist/chunks/{chunk-XFOSUGLU.js.map → chunk-66UTGL7T.js.map} +0 -0
  163. /package/dist/chunks/{chunk-PUBHBEYO.js.map → chunk-B2FIGOPI.js.map} +0 -0
  164. /package/dist/chunks/{chunk-ZHROHNEE.js.map → chunk-F6GIK5GO.js.map} +0 -0
  165. /package/dist/chunks/{chunk-4PBW54I2.js.map → chunk-GGQ43B7T.js.map} +0 -0
  166. /package/dist/chunks/{chunk-MSDL7U6Q.js.map → chunk-JSHIS7GO.js.map} +0 -0
  167. /package/dist/chunks/{chunk-HRDMBGMY.js.map → chunk-K4VRQ7WZ.js.map} +0 -0
  168. /package/dist/chunks/{chunk-RWKQ5SRW.js.map → chunk-MTAFECXB.js.map} +0 -0
  169. /package/dist/chunks/{chunk-U6Y6TKJL.js.map → chunk-NSV7WTCT.js.map} +0 -0
  170. /package/dist/chunks/{chunk-4WKD3YM3.js.map → chunk-OILZ4PDY.js.map} +0 -0
  171. /package/dist/chunks/{chunk-H57KPL3V.js.map → chunk-S2JWFXW5.js.map} +0 -0
  172. /package/dist/chunks/{chunk-HFDJWLMS.js.map → chunk-SOEUGSY4.js.map} +0 -0
  173. /package/dist/chunks/{chunk-KIFOEBYJ.js.map → chunk-VEXCD3RA.js.map} +0 -0
  174. /package/dist/chunks/{chunk-GS67KDMV.js.map → chunk-VN7AE3EY.js.map} +0 -0
  175. /package/dist/chunks/{chunk-MPMEK3IQ.js.map → chunk-WYLBWFAO.js.map} +0 -0
  176. /package/dist/chunks/{chunk-6GWDGTHC.js.map → chunk-YLO62DWD.js.map} +0 -0
  177. /package/dist/chunks/{chunk-4BYS4ZLY.js.map → chunk-YN4K3FNB.js.map} +0 -0
  178. /package/dist/chunks/{chunk-OJ4HAALD.js.map → chunk-YO5UIWDY.js.map} +0 -0
  179. /package/dist/chunks/{chunk-7N7IC3Z2.js.map → chunk-ZCXW3GR7.js.map} +0 -0
  180. /package/dist/chunks/{chunk-L6H46CPY.js.map → chunk-ZY375C2U.js.map} +0 -0
@@ -34,19 +34,27 @@ var runAbortable = (signal, operation) => {
34
34
  return Promise.reject(error);
35
35
  }
36
36
  };
37
- var settleWithin = async (operations, timeoutMs) => {
37
+ var settleWithin = async (operations, timeoutMs, signal) => {
38
38
  const pending = [...operations].map((operation) => Promise.resolve(operation));
39
39
  if (pending.length === 0) return true;
40
+ const settled = Promise.allSettled(pending).then(() => true);
41
+ if (signal?.aborted) return false;
40
42
  let timer;
43
+ let onAbort;
41
44
  try {
42
45
  return await Promise.race([
43
- Promise.allSettled(pending).then(() => true),
46
+ settled,
47
+ ...signal ? [new Promise((resolve) => {
48
+ onAbort = () => resolve(false);
49
+ signal.addEventListener("abort", onAbort, { once: true });
50
+ })] : [],
44
51
  new Promise((resolve) => {
45
52
  timer = setTimeout(() => resolve(false), Math.max(0, timeoutMs));
46
53
  })
47
54
  ]);
48
55
  } finally {
49
56
  if (timer) clearTimeout(timer);
57
+ if (onAbort) signal?.removeEventListener("abort", onAbort);
50
58
  }
51
59
  };
52
60
 
@@ -55,4 +63,4 @@ export {
55
63
  runAbortable,
56
64
  settleWithin
57
65
  };
58
- //# sourceMappingURL=chunk-7TB7NXSL.js.map
66
+ //# sourceMappingURL=chunk-7CIQQOOD.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/async-settlement.ts"],
4
- "sourcesContent": ["const abortError = (signal: AbortSignal): Error => {\n const reason = signal.reason;\n if (reason instanceof Error) return reason;\n return new Error(typeof reason === \"string\" && reason ? reason : \"Operation aborted\");\n};\n\nexport const throwIfAborted = (signal: AbortSignal | undefined): void => {\n if (signal?.aborted) throw abortError(signal);\n};\n\nconst raceWithAbort = <T>(\n operation: PromiseLike<T>,\n signal: AbortSignal | undefined,\n): Promise<T> => {\n if (!signal) return Promise.resolve(operation);\n if (signal.aborted) return Promise.reject(abortError(signal));\n\n return new Promise<T>((resolve, reject) => {\n let settled = false;\n const finish = (callback: () => void): void => {\n if (settled) return;\n settled = true;\n signal.removeEventListener(\"abort\", onAbort);\n callback();\n };\n const onAbort = (): void => finish(() => reject(abortError(signal)));\n signal.addEventListener(\"abort\", onAbort, { once: true });\n Promise.resolve(operation).then(\n (value) => finish(() => resolve(value)),\n (error) => finish(() => reject(error)),\n );\n });\n};\n\nexport const runAbortable = <T>(\n signal: AbortSignal | undefined,\n operation: () => T | PromiseLike<T>,\n): Promise<T> => {\n try {\n throwIfAborted(signal);\n return raceWithAbort(Promise.resolve(operation()), signal);\n } catch (error) {\n return Promise.reject(error);\n }\n};\n\nexport const settleWithin = async (\n operations: Iterable<PromiseLike<unknown>>,\n timeoutMs: number,\n): Promise<boolean> => {\n const pending = [...operations].map((operation) => Promise.resolve(operation));\n if (pending.length === 0) return true;\n\n let timer: NodeJS.Timeout | undefined;\n try {\n return await Promise.race([\n Promise.allSettled(pending).then(() => true),\n new Promise<false>((resolve) => {\n timer = setTimeout(() => resolve(false), Math.max(0, timeoutMs));\n }),\n ]);\n } finally {\n if (timer) clearTimeout(timer);\n }\n};\n"],
5
- "mappings": ";AAAA,IAAM,aAAa,CAAC,WAA+B;AACjD,QAAM,SAAS,OAAO;AACtB,MAAI,kBAAkB,MAAO,QAAO;AACpC,SAAO,IAAI,MAAM,OAAO,WAAW,YAAY,SAAS,SAAS,mBAAmB;AACtF;AAEO,IAAM,iBAAiB,CAAC,WAA0C;AACvE,MAAI,QAAQ,QAAS,OAAM,WAAW,MAAM;AAC9C;AAEA,IAAM,gBAAgB,CACpB,WACA,WACe;AACf,MAAI,CAAC,OAAQ,QAAO,QAAQ,QAAQ,SAAS;AAC7C,MAAI,OAAO,QAAS,QAAO,QAAQ,OAAO,WAAW,MAAM,CAAC;AAE5D,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI,UAAU;AACd,UAAM,SAAS,CAAC,aAA+B;AAC7C,UAAI,QAAS;AACb,gBAAU;AACV,aAAO,oBAAoB,SAAS,OAAO;AAC3C,eAAS;AAAA,IACX;AACA,UAAM,UAAU,MAAY,OAAO,MAAM,OAAO,WAAW,MAAM,CAAC,CAAC;AACnE,WAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AACxD,YAAQ,QAAQ,SAAS,EAAE;AAAA,MACzB,CAAC,UAAU,OAAO,MAAM,QAAQ,KAAK,CAAC;AAAA,MACtC,CAAC,UAAU,OAAO,MAAM,OAAO,KAAK,CAAC;AAAA,IACvC;AAAA,EACF,CAAC;AACH;AAEO,IAAM,eAAe,CAC1B,QACA,cACe;AACf,MAAI;AACF,mBAAe,MAAM;AACrB,WAAO,cAAc,QAAQ,QAAQ,UAAU,CAAC,GAAG,MAAM;AAAA,EAC3D,SAAS,OAAO;AACd,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAEO,IAAM,eAAe,OAC1B,YACA,cACqB;AACrB,QAAM,UAAU,CAAC,GAAG,UAAU,EAAE,IAAI,CAAC,cAAc,QAAQ,QAAQ,SAAS,CAAC;AAC7E,MAAI,QAAQ,WAAW,EAAG,QAAO;AAEjC,MAAI;AACJ,MAAI;AACF,WAAO,MAAM,QAAQ,KAAK;AAAA,MACxB,QAAQ,WAAW,OAAO,EAAE,KAAK,MAAM,IAAI;AAAA,MAC3C,IAAI,QAAe,CAAC,YAAY;AAC9B,gBAAQ,WAAW,MAAM,QAAQ,KAAK,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC;AAAA,MACjE,CAAC;AAAA,IACH,CAAC;AAAA,EACH,UAAE;AACA,QAAI,MAAO,cAAa,KAAK;AAAA,EAC/B;AACF;",
4
+ "sourcesContent": ["const abortError = (signal: AbortSignal): Error => {\n const reason = signal.reason;\n if (reason instanceof Error) return reason;\n return new Error(typeof reason === \"string\" && reason ? reason : \"Operation aborted\");\n};\n\nexport const throwIfAborted = (signal: AbortSignal | undefined): void => {\n if (signal?.aborted) throw abortError(signal);\n};\n\nconst raceWithAbort = <T>(\n operation: PromiseLike<T>,\n signal: AbortSignal | undefined,\n): Promise<T> => {\n if (!signal) return Promise.resolve(operation);\n if (signal.aborted) return Promise.reject(abortError(signal));\n\n return new Promise<T>((resolve, reject) => {\n let settled = false;\n const finish = (callback: () => void): void => {\n if (settled) return;\n settled = true;\n signal.removeEventListener(\"abort\", onAbort);\n callback();\n };\n const onAbort = (): void => finish(() => reject(abortError(signal)));\n signal.addEventListener(\"abort\", onAbort, { once: true });\n Promise.resolve(operation).then(\n (value) => finish(() => resolve(value)),\n (error) => finish(() => reject(error)),\n );\n });\n};\n\nexport const runAbortable = <T>(\n signal: AbortSignal | undefined,\n operation: () => T | PromiseLike<T>,\n): Promise<T> => {\n try {\n throwIfAborted(signal);\n return raceWithAbort(Promise.resolve(operation()), signal);\n } catch (error) {\n return Promise.reject(error);\n }\n};\n\nexport const settleWithin = async (\n operations: Iterable<PromiseLike<unknown>>,\n timeoutMs: number,\n signal?: AbortSignal,\n): Promise<boolean> => {\n const pending = [...operations].map((operation) => Promise.resolve(operation));\n if (pending.length === 0) return true;\n\n // Observe every eventual rejection even if cancellation ends only the wait.\n const settled = Promise.allSettled(pending).then(() => true);\n if (signal?.aborted) return false;\n let timer: NodeJS.Timeout | undefined;\n let onAbort: (() => void) | undefined;\n try {\n return await Promise.race([\n settled,\n ...(signal ? [new Promise<false>((resolve) => {\n onAbort = () => resolve(false);\n signal.addEventListener(\"abort\", onAbort, { once: true });\n })] : []),\n new Promise<false>((resolve) => {\n timer = setTimeout(() => resolve(false), Math.max(0, timeoutMs));\n }),\n ]);\n } finally {\n if (timer) clearTimeout(timer);\n if (onAbort) signal?.removeEventListener(\"abort\", onAbort);\n }\n};\n"],
5
+ "mappings": ";AAAA,IAAM,aAAa,CAAC,WAA+B;AACjD,QAAM,SAAS,OAAO;AACtB,MAAI,kBAAkB,MAAO,QAAO;AACpC,SAAO,IAAI,MAAM,OAAO,WAAW,YAAY,SAAS,SAAS,mBAAmB;AACtF;AAEO,IAAM,iBAAiB,CAAC,WAA0C;AACvE,MAAI,QAAQ,QAAS,OAAM,WAAW,MAAM;AAC9C;AAEA,IAAM,gBAAgB,CACpB,WACA,WACe;AACf,MAAI,CAAC,OAAQ,QAAO,QAAQ,QAAQ,SAAS;AAC7C,MAAI,OAAO,QAAS,QAAO,QAAQ,OAAO,WAAW,MAAM,CAAC;AAE5D,SAAO,IAAI,QAAW,CAAC,SAAS,WAAW;AACzC,QAAI,UAAU;AACd,UAAM,SAAS,CAAC,aAA+B;AAC7C,UAAI,QAAS;AACb,gBAAU;AACV,aAAO,oBAAoB,SAAS,OAAO;AAC3C,eAAS;AAAA,IACX;AACA,UAAM,UAAU,MAAY,OAAO,MAAM,OAAO,WAAW,MAAM,CAAC,CAAC;AACnE,WAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AACxD,YAAQ,QAAQ,SAAS,EAAE;AAAA,MACzB,CAAC,UAAU,OAAO,MAAM,QAAQ,KAAK,CAAC;AAAA,MACtC,CAAC,UAAU,OAAO,MAAM,OAAO,KAAK,CAAC;AAAA,IACvC;AAAA,EACF,CAAC;AACH;AAEO,IAAM,eAAe,CAC1B,QACA,cACe;AACf,MAAI;AACF,mBAAe,MAAM;AACrB,WAAO,cAAc,QAAQ,QAAQ,UAAU,CAAC,GAAG,MAAM;AAAA,EAC3D,SAAS,OAAO;AACd,WAAO,QAAQ,OAAO,KAAK;AAAA,EAC7B;AACF;AAEO,IAAM,eAAe,OAC1B,YACA,WACA,WACqB;AACrB,QAAM,UAAU,CAAC,GAAG,UAAU,EAAE,IAAI,CAAC,cAAc,QAAQ,QAAQ,SAAS,CAAC;AAC7E,MAAI,QAAQ,WAAW,EAAG,QAAO;AAGjC,QAAM,UAAU,QAAQ,WAAW,OAAO,EAAE,KAAK,MAAM,IAAI;AAC3D,MAAI,QAAQ,QAAS,QAAO;AAC5B,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,WAAO,MAAM,QAAQ,KAAK;AAAA,MACxB;AAAA,MACA,GAAI,SAAS,CAAC,IAAI,QAAe,CAAC,YAAY;AAC5C,kBAAU,MAAM,QAAQ,KAAK;AAC7B,eAAO,iBAAiB,SAAS,SAAS,EAAE,MAAM,KAAK,CAAC;AAAA,MAC1D,CAAC,CAAC,IAAI,CAAC;AAAA,MACP,IAAI,QAAe,CAAC,YAAY;AAC9B,gBAAQ,WAAW,MAAM,QAAQ,KAAK,GAAG,KAAK,IAAI,GAAG,SAAS,CAAC;AAAA,MACjE,CAAC;AAAA,IACH,CAAC;AAAA,EACH,UAAE;AACA,QAAI,MAAO,cAAa,KAAK;AAC7B,QAAI,QAAS,SAAQ,oBAAoB,SAAS,OAAO;AAAA,EAC3D;AACF;",
6
6
  "names": []
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  isNormalFormWitness
3
- } from "./chunk-6GWDGTHC.js";
3
+ } from "./chunk-YLO62DWD.js";
4
4
 
5
5
  // src/audit/trace-schema.ts
6
6
  var FABRIC_EXECUTION_TRACE_KIND = "pi-fabric.execution";
@@ -81,4 +81,4 @@ export {
81
81
  isFabricExecutionTraceV1,
82
82
  readFabricExecutionTraceV1
83
83
  };
84
- //# sourceMappingURL=chunk-PUBHBEYO.js.map
84
+ //# sourceMappingURL=chunk-B2FIGOPI.js.map
@@ -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-RKJPBTBB.js";
33
+ } from "./chunk-6ZPEPRUV.js";
32
34
  import {
33
35
  configureHighlighting,
34
36
  highlightCode,
@@ -113,7 +115,7 @@ import {
113
115
  import {
114
116
  compactAtConfiguredThreshold,
115
117
  fabricExecTitleHintCached
116
- } from "./chunk-3VK6UGAN.js";
118
+ } from "./chunk-O5SHIUIL.js";
117
119
  import {
118
120
  fabricWriteBindings
119
121
  } from "./chunk-SZUXWOO7.js";
@@ -135,11 +137,7 @@ import {
135
137
  ApprovalController,
136
138
  FabricAutoApprovalClassifier,
137
139
  FabricSessionApprovals
138
- } from "./chunk-4PBW54I2.js";
139
- import {
140
- getActiveRepairCompiler,
141
- setActiveCompiledSurface
142
- } from "./chunk-TXCNZCZP.js";
140
+ } from "./chunk-GGQ43B7T.js";
143
141
  import {
144
142
  FABRIC_ACTION_POLICY_REGISTER_EVENT,
145
143
  FABRIC_COMPACTION_OWNER_EVENT,
@@ -177,10 +175,7 @@ import {
177
175
  import {
178
176
  isFabricExecutionTraceV1,
179
177
  readFabricExecutionTraceV1
180
- } from "./chunk-PUBHBEYO.js";
181
- import {
182
- stableJsonHash
183
- } from "./chunk-3YZUQESG.js";
178
+ } from "./chunk-B2FIGOPI.js";
184
179
  import {
185
180
  FABRIC_ACTOR_PI_HOST_EVENTS
186
181
  } from "./chunk-IIPKG52D.js";
@@ -188,6 +183,13 @@ import {
188
183
  FABRIC_THINKING_BOUNDS_ENV,
189
184
  FABRIC_THINKING_ENTRY_TYPE
190
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";
191
193
  import {
192
194
  readChildToolAllowlist
193
195
  } from "./chunk-6OGYPHNQ.js";
@@ -496,6 +498,21 @@ var TimingFooter = class {
496
498
  if (!isTimingOnlyRender(this.state)) this.component.invalidate?.();
497
499
  }
498
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
+ };
499
516
  var renderTimedResult = (context, theme, render, label) => {
500
517
  const state = timingState(context);
501
518
  if (!state) return render(context);
@@ -593,7 +610,11 @@ var withCodePreviewShell = (tool, options = {}) => {
593
610
  const originalRenderCall = tool.renderCall;
594
611
  const originalRenderResult = tool.renderResult;
595
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);
596
- 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
+ };
597
618
  return {
598
619
  ...tool,
599
620
  renderShell: mode === "on" ? "default" : "self",
@@ -1184,12 +1205,13 @@ function registerFabricCommand(pi, deps) {
1184
1205
  }
1185
1206
  });
1186
1207
  pi.registerCommand("fabric", {
1187
- 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",
1188
1209
  getArgumentCompletions: (argumentPrefix) => {
1189
1210
  const subcommands = [
1190
1211
  "status",
1191
1212
  "dashboard",
1192
1213
  "tasks",
1214
+ "background",
1193
1215
  "chat",
1194
1216
  "focus",
1195
1217
  "settings",
@@ -1319,6 +1341,16 @@ function registerFabricCommand(pi, deps) {
1319
1341
  },
1320
1342
  // The subcommands load at first use, not while registering the command.
1321
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
+ }
1322
1354
  const { runFabricCommand } = await import("../commands/fabric-handler.js");
1323
1355
  await runFabricCommand(pi, deps, commandHost, argumentsText, context);
1324
1356
  }
@@ -1749,6 +1781,29 @@ var FabricDirectToolApproval = class {
1749
1781
  }
1750
1782
  };
1751
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
+
1752
1807
  // src/fabric-exec-tool.ts
1753
1808
  import { Container as Container2, Text as Text2 } from "@earendil-works/pi-tui";
1754
1809
  import { Type } from "typebox";
@@ -2068,17 +2123,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
2068
2123
  label: "Fabric",
2069
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.",
2070
2125
  promptSnippet: managedHost ? `Authorized host tools (${managedHost.providers.join(", ") || "none"}) and deterministic computation` : "Pi core tools, MCP, Fabric providers, discovery, and extensions",
2071
- promptGuidelines: managedHost ? [
2072
- "Batch independent operations with bounded concurrency, keep dependent calls ordered, inspect results, and return compact evidence."
2073
- ] : [
2074
- 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.",
2075
- 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.",
2076
- "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.",
2077
- 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.",
2078
- "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.",
2079
- "Use `display.name` and objective `display.description`; Fabric pairs them with verified outcomes in deterministic compaction.",
2080
- ...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."] : []
2081
- ],
2126
+ promptGuidelines: fabricExecutionGuidelines(toolKernel(state), python ? state.config.executor.pythonRuntime : void 0, Boolean(managedHost)),
2082
2127
  // The model-facing schema is intentionally flat: one large `code` string
2083
2128
  // plus scalar/optional params. Do not add nested arrays-of-objects with
2084
2129
  // escaped content here. SOTA models are post-trained on one dominant
@@ -2125,7 +2170,7 @@ var createFabricExecTool = (state, codePreviewSettings, pendingHandoffs, decorat
2125
2170
  })
2126
2171
  ),
2127
2172
  background: Type.Optional(Type.Boolean({
2128
- 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."
2129
2174
  })),
2130
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." })),
2131
2176
  maxOutputTokens: Type.Optional(Type.Integer({ minimum: 1, description: "Per-call output token budget (estimated at four characters per token), capped by executor.maxOutputChars." })),
@@ -2354,9 +2399,6 @@ ${preview}` : ""}${hiddenHint}`,
2354
2399
  const audit = audits[0];
2355
2400
  const glyph = audit.success === void 0 ? theme.fg("warning", spinner) : audit.success === false ? theme.fg("error", "\u2717") : theme.fg("dim", "\u203A");
2356
2401
  let text2 = `${glyph} ${nestedCallTitle(audit, theme, context?.invalidate, corePreviewContext)}`;
2357
- if (shellBackgroundShortcut(audit)) {
2358
- text2 += nl + theme.fg("dim", "Ctrl+B twice \xB7 background waiting shell");
2359
- }
2360
2402
  const previewLines = renderAgentToolPreviewLines(audit, theme, {
2361
2403
  expanded,
2362
2404
  showTools: showAgentToolPreview,
@@ -2390,6 +2432,7 @@ ${preview}` : ""}${hiddenHint}`,
2390
2432
  if (previewLines.length > 1) text2 += nl + previewLines.slice(1).join(nl);
2391
2433
  }
2392
2434
  const textLines = text2.split(nl);
2435
+ if (shellBackgroundShortcut(audit)) pushArcItem(textLines, arcItem(theme, "(ctrl+b to run in background)"));
2393
2436
  return trackRows(
2394
2437
  renderBoundedLines(
2395
2438
  textLines,
@@ -2852,7 +2895,8 @@ ${recoveryHint}` : ""}`,
2852
2895
  }),
2853
2896
  {
2854
2897
  mode: codePreviewSettings.toolCallBackground,
2855
- toolCallTiming: codePreviewSettings.toolCallTiming
2898
+ toolCallTiming: codePreviewSettings.toolCallTiming,
2899
+ backgroundShortcut: true
2856
2900
  }
2857
2901
  );
2858
2902
  };
@@ -4290,10 +4334,11 @@ var widgetRowLimit = (maxRows, terminalRows) => {
4290
4334
  var widgetFocusedRowLimit = (maxRows, terminalRows) => widgetRowLimit(maxRows, terminalRows);
4291
4335
  var widgetViewport = (contentRows, budget, offset) => {
4292
4336
  const available = Math.max(0, Math.floor(budget));
4293
- const hasCue = contentRows > available && available > 1;
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;
4294
4340
  const windowRows = Math.max(0, available - Number(hasCue));
4295
- const maxOffset = windowRows > 0 ? Math.max(0, contentRows - windowRows) : 0;
4296
- return { windowRows, hasCue, maxOffset, offset: Math.max(0, Math.min(maxOffset, Math.floor(offset))) };
4341
+ return { windowRows, hasCue, maxOffset, offset: clampedOffset };
4297
4342
  };
4298
4343
  var HEADER_ROW = "\0main";
4299
4344
  var FabricWidget = class {
@@ -4489,7 +4534,7 @@ var FabricWidget = class {
4489
4534
  const header = headerWidth === width ? lines[0] ?? "" : this.#content(snapshot, width, headerWidth).lines[0] ?? "";
4490
4535
  const boundedHeader = label ? this.#withRightLabel(header, label, width) : truncateToWidth3(header, width);
4491
4536
  const visibleLines = [boundedHeader, ...lines.slice(start, start + capacity).map((line) => truncateToWidth3(line, width))];
4492
- if (viewport.hasCue) visibleLines.push(below > 0 ? truncateToWidth3(this.theme.fg("dim", `\u2193 ${below} more`), width) : "");
4537
+ if (viewport.hasCue) visibleLines.push(truncateToWidth3(this.theme.fg("dim", `\u2193 ${below} more`), width));
4493
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 }));
4494
4539
  if (rows.length === 0 && this.interaction?.collapseIdle?.()) return [];
4495
4540
  this.#spacerRows = spacer;
@@ -4544,7 +4589,13 @@ var FabricWidget = class {
4544
4589
  }
4545
4590
  if (activeAgents.length > 0) parts.push(`${activeAgents.length} running`);
4546
4591
  if (visibleActors.length > 0) parts.push(`${visibleActors.length} actor${visibleActors.length === 1 ? "" : "s"}`);
4547
- 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"}`);
4548
4599
  const tokens = totalTokens(snapshot, run);
4549
4600
  if (tokens > 0) parts.push(`${formatTokens(tokens)} tok`);
4550
4601
  const cost = totalCost(snapshot, run);
@@ -4566,6 +4617,27 @@ var FabricWidget = class {
4566
4617
  parts,
4567
4618
  this.#hints(hasRows)
4568
4619
  ));
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
+ };
4569
4641
  const pushParticipant = (agent, kind, prefix = "") => {
4570
4642
  const id = kind === "actor" ? agent.actorId ?? agent.id : agent.id;
4571
4643
  rows.push({
@@ -4576,6 +4648,7 @@ var FabricWidget = class {
4576
4648
  line: lines.length
4577
4649
  });
4578
4650
  lines.push(agentLine(this.theme, agent, snapshot.now, prefix, id === marked, width));
4651
+ pushObservations("participant", agent.id);
4579
4652
  };
4580
4653
  const liveTrees = [];
4581
4654
  const settledTrees = [];
@@ -4601,12 +4674,14 @@ var FabricWidget = class {
4601
4674
  []
4602
4675
  );
4603
4676
  };
4604
- for (const job of listedShells) {
4677
+ for (const job of listedShells.filter((job2) => !job2.observes)) {
4605
4678
  const status = job.stopping ? "stopping" : job.status;
4606
4679
  const label2 = job.monitor && job.finishedAt === void 0 && !job.stopping ? `monitor:${job.monitor.delivery}` : status;
4607
4680
  rows.push({ id: job.id, kind: "shell", name: safeText(job.description ?? job.command), line: lines.length });
4608
4681
  lines.push(shellLine(job, job.id.slice(0, 8), label2, job.id));
4682
+ pushObservations("task", job.id);
4609
4683
  }
4684
+ for (const job of listedShells) if (job.observes && !shownObservations.has(job.id)) pushObservation(job, "");
4610
4685
  return lines;
4611
4686
  }
4612
4687
  #withRightLabel(line, label, width) {
@@ -6482,18 +6557,20 @@ function createFabricExtension(entryUrl) {
6482
6557
  }
6483
6558
  });
6484
6559
  pi.on("agent_settled", async (event, context) => {
6560
+ const interrupted = event.aborted || context.signal?.aborted === true;
6485
6561
  if (state.managedHostOptions) {
6486
- if (state.config.compaction.engine === "fabric") await compactAtConfiguredThreshold(context, state.config);
6562
+ if (!interrupted && state.config.compaction.engine === "fabric") await compactAtConfiguredThreshold(context, state.config);
6487
6563
  if (state.initialized) await state.publishHostLifecycle("pi.agent_settled", event);
6488
6564
  return;
6489
6565
  }
6490
6566
  if (!state.initialized) {
6491
- if (!compactionOwner()) await compactAtConfiguredThreshold(context, state.config);
6567
+ if (!interrupted && !compactionOwner()) await compactAtConfiguredThreshold(context, state.config);
6492
6568
  return;
6493
6569
  }
6494
6570
  const sessionId = context.sessionManager.getSessionId();
6571
+ if (interrupted) state.compact.cancel();
6495
6572
  const settledInPlace = await settleInPlacePrewalk(state.prewalk, pi, context, {
6496
- compactOnReturn: state.config.prewalk.compactOnReturn,
6573
+ compactOnReturn: !interrupted && state.config.prewalk.compactOnReturn,
6497
6574
  compact: state.compact
6498
6575
  });
6499
6576
  if (!settledInPlace && state.prewalk.settleTask(sessionId)) {
@@ -6508,8 +6585,8 @@ function createFabricExtension(entryUrl) {
6508
6585
  } else {
6509
6586
  state.prewalkDrift.drop(sessionId);
6510
6587
  }
6511
- await state.compact.maybeCommit(context);
6512
- if (!compactionOwner()) {
6588
+ if (!interrupted) await state.compact.maybeCommit(context);
6589
+ if (!interrupted && !compactionOwner()) {
6513
6590
  await compactAtConfiguredThreshold(
6514
6591
  context,
6515
6592
  state.config,
@@ -6746,6 +6823,9 @@ function createFabricExtension(entryUrl) {
6746
6823
  defaultFabricExecutionGuidance,
6747
6824
  extensionToolRosterGuidance,
6748
6825
  fabricExecutionKernelGuidance,
6826
+ fabricGuidanceDelivery,
6827
+ relocateFabricGuidelines,
6828
+ stripFabricRuleBullets,
6749
6829
  managedHostExecutionGuidance,
6750
6830
  managedHostKernelGuidance,
6751
6831
  fabricSchemaGuidance
@@ -6754,8 +6834,25 @@ function createFabricExtension(entryUrl) {
6754
6834
  const captureSnapshot = state.bootstrapped ? capturePolicy() : void 0;
6755
6835
  const managedHost = state.managedHostOptions;
6756
6836
  const skillReader = managedHost ? managedHost.skillReader ?? null : void 0;
6757
- const sections = event.systemPromptOptions.forceSystemPrompt === void 0 ? event.systemPromptOptions.sections : void 0;
6758
- 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
+ );
6759
6856
  const prompt = userPromptText(event);
6760
6857
  const skillReferenceGuidance = effectiveFullCodeMode && prompt !== void 0 ? buildSkillReferenceGuidance(prompt, skills, skillReader) : void 0;
6761
6858
  const currentModel = context.model ? `${context.model.provider}/${context.model.id}` : void 0;
@@ -6775,20 +6872,24 @@ function createFabricExtension(entryUrl) {
6775
6872
  const guidance = [
6776
6873
  managedHost ? managedHostKernelGuidance(managedHost) : fabricExecutionKernelGuidance(effectiveFullCodeMode, config.executor.kernel, config.executor.pythonRuntime, config.executor.codemodeProfile),
6777
6874
  resolvedGuidance.slotText,
6875
+ executionRules.text,
6778
6876
  fabricSchemaGuidance(schemaMode),
6779
6877
  overrideGuidance,
6780
6878
  extensionRoster,
6781
6879
  resolvedGuidance.appendText,
6782
6880
  managedHost?.guidance
6783
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}` } : {};
6784
6886
  if (sections) {
6785
- const catalog = restoreSkillsForFullCodePrompt("", skills, effectiveFullCodeMode, skillReader).trim();
6786
6887
  if (catalog) sections.skills = catalog;
6787
6888
  sections.fabric = guidance;
6788
6889
  }
6789
- const forced = sections ? {} : { systemPrompt: `${systemPrompt}
6790
-
6791
- ${guidance}` };
6890
+ if (executionRules.remaining !== void 0 && event.systemPromptOptions.toolGuidelines) {
6891
+ event.systemPromptOptions.toolGuidelines.fabric_exec = executionRules.remaining;
6892
+ }
6792
6893
  if (!skillReferenceGuidance) return sections ? void 0 : forced;
6793
6894
  return {
6794
6895
  ...forced,
@@ -6942,4 +7043,4 @@ export {
6942
7043
  FABRIC_MANAGED_HOST_VERSION,
6943
7044
  createFabricExtension
6944
7045
  };
6945
- //# sourceMappingURL=chunk-G2DZJ5LK.js.map
7046
+ //# sourceMappingURL=chunk-F3D7GTBK.js.map