@e4779/pi-fabric 0.105.0-fork.22 → 0.109.2-fork.23

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 (225) hide show
  1. package/README.md +3 -1
  2. package/dist/actors/global-registry.d.ts.map +1 -1
  3. package/dist/agents/manager.d.ts.map +1 -1
  4. package/dist/agents/result.d.ts.map +1 -1
  5. package/dist/agents/result.js +1 -1
  6. package/dist/agents/runner-registry.d.ts +1 -1
  7. package/dist/agents/runner-registry.d.ts.map +1 -1
  8. package/dist/agents.js +5 -5
  9. package/dist/chunks/{chunk-5MNLVHF5.js → chunk-3DUKKQHN.js} +28 -13
  10. package/dist/chunks/chunk-3DUKKQHN.js.map +7 -0
  11. package/dist/chunks/{chunk-GJVPP3NN.js → chunk-3SHUUBZJ.js} +4 -4
  12. package/dist/chunks/chunk-3SHUUBZJ.js.map +7 -0
  13. package/dist/chunks/{chunk-VON4TSO3.js → chunk-CZPQTISQ.js} +27 -2
  14. package/dist/chunks/chunk-CZPQTISQ.js.map +7 -0
  15. package/dist/chunks/{chunk-WLLXKS6I.js → chunk-DU6ZA44F.js} +4 -4
  16. package/dist/chunks/{chunk-QLFDPXK7.js → chunk-DV2JZSCI.js} +153 -27
  17. package/dist/chunks/chunk-DV2JZSCI.js.map +7 -0
  18. package/dist/chunks/{chunk-KQ6R5EWR.js → chunk-FRPNQZV2.js} +24 -22
  19. package/dist/chunks/chunk-FRPNQZV2.js.map +7 -0
  20. package/dist/chunks/{chunk-W7X4XEQU.js → chunk-GC2AUXG6.js} +2 -2
  21. package/dist/chunks/chunk-K6QXUGS5.js +30 -0
  22. package/dist/chunks/chunk-K6QXUGS5.js.map +7 -0
  23. package/dist/chunks/{chunk-VPRJOD4Y.js → chunk-LEDY5G2V.js} +2 -2
  24. package/dist/chunks/{chunk-OVBKQCYL.js → chunk-N2VKKA7O.js} +2 -2
  25. package/dist/chunks/{chunk-N5GUXC6F.js → chunk-P4KH4S4S.js} +2 -1
  26. package/dist/chunks/chunk-P4KH4S4S.js.map +7 -0
  27. package/dist/chunks/{chunk-TFFZVLR2.js → chunk-PF27MQY5.js} +55 -4
  28. package/dist/chunks/chunk-PF27MQY5.js.map +7 -0
  29. package/dist/chunks/{chunk-CGL7QP4A.js → chunk-PK4NIJEV.js} +10 -1
  30. package/dist/chunks/{chunk-CGL7QP4A.js.map → chunk-PK4NIJEV.js.map} +2 -2
  31. package/dist/chunks/{chunk-YRDCJZZW.js → chunk-RUO6L7RM.js} +1 -1
  32. package/dist/chunks/{chunk-YRDCJZZW.js.map → chunk-RUO6L7RM.js.map} +1 -1
  33. package/dist/chunks/{chunk-4RTHQGES.js → chunk-ST36EYHN.js} +4 -4
  34. package/dist/chunks/chunk-ST36EYHN.js.map +7 -0
  35. package/dist/chunks/{chunk-R5F6CHW2.js → chunk-UXEMIWYI.js} +12 -7
  36. package/dist/chunks/chunk-UXEMIWYI.js.map +7 -0
  37. package/dist/chunks/{chunk-SGFH5PYA.js → chunk-V2SKDVQX.js} +10 -9
  38. package/dist/chunks/chunk-V2SKDVQX.js.map +7 -0
  39. package/dist/chunks/{chunk-KYXZJNV6.js → chunk-VTK2FEH7.js} +3 -1
  40. package/dist/chunks/{chunk-KYXZJNV6.js.map → chunk-VTK2FEH7.js.map} +2 -2
  41. package/dist/chunks/{chunk-3QECYQGA.js → chunk-VYQV5JRT.js} +13 -1
  42. package/dist/chunks/chunk-VYQV5JRT.js.map +7 -0
  43. package/dist/chunks/{chunk-3KDUMDPZ.js → chunk-X3CHSIL2.js} +5 -5
  44. package/dist/chunks/{chunk-EXWS4ZS3.js → chunk-YJX27XBO.js} +100 -22
  45. package/dist/chunks/chunk-YJX27XBO.js.map +7 -0
  46. package/dist/components/configuration.js +2 -2
  47. package/dist/config.d.ts +16 -1
  48. package/dist/config.d.ts.map +1 -1
  49. package/dist/core/action-registry.d.ts +1 -1
  50. package/dist/core/action-registry.d.ts.map +1 -1
  51. package/dist/core/action-registry.js +2 -2
  52. package/dist/core/media-sanitize.d.ts.map +1 -1
  53. package/dist/core/native-tool-names.d.ts +9 -0
  54. package/dist/core/native-tool-names.d.ts.map +1 -0
  55. package/dist/core/native-tool-result.d.ts +11 -0
  56. package/dist/core/native-tool-result.d.ts.map +1 -0
  57. package/dist/core/system-guidance.d.ts +3 -3
  58. package/dist/core/system-guidance.d.ts.map +1 -1
  59. package/dist/durable/agent.d.ts +77 -0
  60. package/dist/durable/agent.d.ts.map +1 -0
  61. package/dist/durable/session.d.ts +19 -0
  62. package/dist/durable/session.d.ts.map +1 -0
  63. package/dist/durable/storage.d.ts +7 -0
  64. package/dist/durable/storage.d.ts.map +1 -0
  65. package/dist/durable/worker-host.d.ts +13 -0
  66. package/dist/durable/worker-host.d.ts.map +1 -0
  67. package/dist/durable/worker-host.js +1149 -0
  68. package/dist/durable/worker-host.js.map +7 -0
  69. package/dist/durable/worker-options.d.ts +17 -0
  70. package/dist/durable/worker-options.d.ts.map +1 -0
  71. package/dist/durable/worker.d.ts +3 -0
  72. package/dist/durable/worker.d.ts.map +1 -0
  73. package/dist/durable/worker.js +110 -0
  74. package/dist/durable/worker.js.map +7 -0
  75. package/dist/durable-controls.d.ts +27 -0
  76. package/dist/durable-controls.d.ts.map +1 -0
  77. package/dist/durable-input.d.ts +13 -0
  78. package/dist/durable-input.d.ts.map +1 -0
  79. package/dist/durable.d.ts +6 -0
  80. package/dist/durable.d.ts.map +1 -1
  81. package/dist/durable.js +194 -24
  82. package/dist/durable.js.map +4 -4
  83. package/dist/execution-service.d.ts +4 -0
  84. package/dist/execution-service.d.ts.map +1 -1
  85. package/dist/extension-bootstrap.js +5 -5
  86. package/dist/extension.d.ts.map +1 -1
  87. package/dist/fabric-exec-arguments.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 +604 -284
  91. package/dist/fabric-runtime-state.js.map +4 -4
  92. package/dist/index.js +5 -5
  93. package/dist/jev/observation.js +2 -2
  94. package/dist/jev.js +3 -3
  95. package/dist/mcp.js +1 -1
  96. package/dist/memory/extractive-history.d.ts +29 -0
  97. package/dist/memory/extractive-history.d.ts.map +1 -0
  98. package/dist/memory/extractive-history.js +340 -0
  99. package/dist/memory/extractive-history.js.map +7 -0
  100. package/dist/memory/extractive-index.d.ts +46 -0
  101. package/dist/memory/extractive-index.d.ts.map +1 -0
  102. package/dist/native-codemode.d.ts +34 -0
  103. package/dist/native-codemode.d.ts.map +1 -0
  104. package/dist/native-discovery.d.ts +16 -0
  105. package/dist/native-discovery.d.ts.map +1 -0
  106. package/dist/native-discovery.js +19 -0
  107. package/dist/native-discovery.js.map +7 -0
  108. package/dist/native-image-artifacts.d.ts +4 -0
  109. package/dist/native-image-artifacts.d.ts.map +1 -0
  110. package/dist/native-image-artifacts.js +18 -0
  111. package/dist/native-image-artifacts.js.map +7 -0
  112. package/dist/native-tool-catalog.d.ts +21 -0
  113. package/dist/native-tool-catalog.d.ts.map +1 -0
  114. package/dist/native-tool-catalog.js +71 -0
  115. package/dist/native-tool-catalog.js.map +7 -0
  116. package/dist/protocol.d.ts +2 -0
  117. package/dist/protocol.d.ts.map +1 -1
  118. package/dist/protocol.js +1 -1
  119. package/dist/providers/agents-provider.d.ts.map +1 -1
  120. package/dist/providers/captured-tools-provider.d.ts +1 -1
  121. package/dist/providers/captured-tools-provider.d.ts.map +1 -1
  122. package/dist/providers/jev-provider.js +3 -3
  123. package/dist/providers/mcp-provider.d.ts +1 -1
  124. package/dist/providers/mcp-provider.d.ts.map +1 -1
  125. package/dist/providers/pi-native-mcp.d.ts.map +1 -1
  126. package/dist/providers/pi-tools-provider.d.ts.map +1 -1
  127. package/dist/residency/host.js +7 -7
  128. package/dist/residency/pi-entry.js +7 -7
  129. package/dist/runners.js +1 -1
  130. package/dist/runtime/core-override-guest-types.js +2 -2
  131. package/dist/runtime/dynamic-guest-types.d.ts +2 -0
  132. package/dist/runtime/dynamic-guest-types.d.ts.map +1 -1
  133. package/dist/runtime/dynamic-guest-types.js +5 -3
  134. package/dist/runtime/guest-types.d.ts +1 -1
  135. package/dist/runtime/guest-types.d.ts.map +1 -1
  136. package/dist/runtime/guest-types.js +1 -1
  137. package/dist/runtime/kernel.d.ts +5 -0
  138. package/dist/runtime/kernel.d.ts.map +1 -1
  139. package/dist/runtime/monty-runtime.js +1 -1
  140. package/dist/runtime/native-codemode-guest.d.ts +2 -0
  141. package/dist/runtime/native-codemode-guest.d.ts.map +1 -0
  142. package/dist/runtime/native-codemode-types.d.ts +2 -0
  143. package/dist/runtime/native-codemode-types.d.ts.map +1 -0
  144. package/dist/runtime/node-process-child-source.d.ts.map +1 -1
  145. package/dist/runtime/node-process-runtime.d.ts.map +1 -1
  146. package/dist/runtime/node-process-runtime.js +3 -3
  147. package/dist/runtime/quickjs-runtime.d.ts +1 -1
  148. package/dist/runtime/quickjs-runtime.d.ts.map +1 -1
  149. package/dist/runtime/quickjs-runtime.js +3 -2
  150. package/dist/runtime/type-checker.d.ts +2 -0
  151. package/dist/runtime/type-checker.d.ts.map +1 -1
  152. package/dist/runtime/type-checker.js +5 -3
  153. package/dist/runtime/typescript-kernel.d.ts +1 -1
  154. package/dist/runtime/typescript-kernel.d.ts.map +1 -1
  155. package/dist/runtime/typescript-kernel.js +13 -11
  156. package/dist/runtime/typescript-kernel.js.map +2 -2
  157. package/dist/runtime-state-speculation.d.ts +4 -1
  158. package/dist/runtime-state-speculation.d.ts.map +1 -1
  159. package/dist/speculation/python-scanner.js +1 -1
  160. package/dist/speculation/python-scanner.js.map +2 -2
  161. package/dist/speculation/scanner.d.ts +2 -0
  162. package/dist/speculation/scanner.d.ts.map +1 -1
  163. package/dist/speculation/scanner.js +18 -4
  164. package/dist/speculation/scanner.js.map +2 -2
  165. package/dist/speculation/types.d.ts +1 -0
  166. package/dist/speculation/types.d.ts.map +1 -1
  167. package/dist/type-error-guidance.js +1 -1
  168. package/dist/ui/border-status-editor.d.ts +3 -0
  169. package/dist/ui/border-status-editor.d.ts.map +1 -1
  170. package/dist/ui/controller.d.ts.map +1 -1
  171. package/dist/ui/conversation.d.ts +1 -0
  172. package/dist/ui/conversation.d.ts.map +1 -1
  173. package/dist/ui/conversation.js +28 -5
  174. package/dist/ui/conversation.js.map +2 -2
  175. package/dist/ui/dashboard.d.ts +2 -0
  176. package/dist/ui/dashboard.d.ts.map +1 -1
  177. package/dist/ui/dashboard.js +20 -7
  178. package/dist/ui/dashboard.js.map +2 -2
  179. package/dist/ui/settings-section-context.d.ts +2 -0
  180. package/dist/ui/settings-section-context.d.ts.map +1 -1
  181. package/dist/ui/settings-sections-execution.d.ts.map +1 -1
  182. package/dist/ui/settings-sections-lifecycle.d.ts +1 -0
  183. package/dist/ui/settings-sections-lifecycle.d.ts.map +1 -1
  184. package/dist/ui/settings-sections.d.ts +2 -0
  185. package/dist/ui/settings-sections.d.ts.map +1 -1
  186. package/dist/ui/settings-values.d.ts +4 -1
  187. package/dist/ui/settings-values.d.ts.map +1 -1
  188. package/dist/ui/settings.d.ts.map +1 -1
  189. package/dist/ui/settings.js +61 -2
  190. package/dist/ui/settings.js.map +2 -2
  191. package/dist/worker/model-control.d.ts.map +1 -1
  192. package/dist/worker/model-control.js.map +2 -2
  193. package/dist/worker/options.d.ts.map +1 -1
  194. package/dist/worker/options.js +4 -3
  195. package/dist/worker/options.js.map +2 -2
  196. package/dist/worker/result.js +12 -0
  197. package/dist/worker/result.js.map +2 -2
  198. package/dist/worker.js +95 -8
  199. package/dist/worker.js.map +2 -2
  200. package/docs/agents.md +5 -5
  201. package/docs/codemode-parity.md +97 -0
  202. package/docs/configuration.md +31 -2
  203. package/docs/durable-pi.md +166 -38
  204. package/docs/extractive-history.md +171 -0
  205. package/docs/interface.md +1 -1
  206. package/docs/speculation.md +12 -3
  207. package/package.json +7 -16
  208. package/skillsets/typescript/fabric-exec/SKILL.md +4 -4
  209. package/dist/chunks/chunk-3QECYQGA.js.map +0 -7
  210. package/dist/chunks/chunk-4RTHQGES.js.map +0 -7
  211. package/dist/chunks/chunk-5MNLVHF5.js.map +0 -7
  212. package/dist/chunks/chunk-EXWS4ZS3.js.map +0 -7
  213. package/dist/chunks/chunk-GJVPP3NN.js.map +0 -7
  214. package/dist/chunks/chunk-KQ6R5EWR.js.map +0 -7
  215. package/dist/chunks/chunk-N5GUXC6F.js.map +0 -7
  216. package/dist/chunks/chunk-QLFDPXK7.js.map +0 -7
  217. package/dist/chunks/chunk-R5F6CHW2.js.map +0 -7
  218. package/dist/chunks/chunk-SGFH5PYA.js.map +0 -7
  219. package/dist/chunks/chunk-TFFZVLR2.js.map +0 -7
  220. package/dist/chunks/chunk-VON4TSO3.js.map +0 -7
  221. /package/dist/chunks/{chunk-WLLXKS6I.js.map → chunk-DU6ZA44F.js.map} +0 -0
  222. /package/dist/chunks/{chunk-W7X4XEQU.js.map → chunk-GC2AUXG6.js.map} +0 -0
  223. /package/dist/chunks/{chunk-VPRJOD4Y.js.map → chunk-LEDY5G2V.js.map} +0 -0
  224. /package/dist/chunks/{chunk-OVBKQCYL.js.map → chunk-N2VKKA7O.js.map} +0 -0
  225. /package/dist/chunks/{chunk-3KDUMDPZ.js.map → chunk-X3CHSIL2.js.map} +0 -0
package/dist/worker.js CHANGED
@@ -225,6 +225,7 @@ var main = async () => {
225
225
  writeRunRecord
226
226
  } = loadedRunRecordHelpers;
227
227
  const options = optionHelpers.parseWorkerOptions();
228
+ const isPi = options.runner === "pi" || options.runner === "pi-durable";
228
229
  const sessionExporter = options.sessionExportFile ? new sessionExportHelpers.SessionExporter({
229
230
  file: options.sessionExportFile,
230
231
  sessionId: options.id,
@@ -269,7 +270,7 @@ ${task}
269
270
  if (!options.extensions) piArguments.push("--no-extensions");
270
271
  if (options.fabricExtensionPath) piArguments.push("-e", options.fabricExtensionPath);
271
272
  if (options.writePolicy) {
272
- if (options.runner !== "pi") throw new Error(`Write confinement requires the Pi runner, not ${options.runner}`);
273
+ if (!isPi) throw new Error(`Write confinement requires the Pi runner, not ${options.runner}`);
273
274
  const guard = import.meta.url.endsWith(".ts") ? "./agents/write-guard.ts" : "./agents/write-guard.js";
274
275
  piArguments.push("-e", fileURLToPath(new URL(guard, import.meta.url)));
275
276
  }
@@ -285,6 +286,14 @@ ${task}
285
286
  ${schema}`
286
287
  );
287
288
  }
289
+ if (options.runner === "pi-durable") {
290
+ piArguments.push(
291
+ "--durable-run-id",
292
+ options.id,
293
+ "--durable-directory",
294
+ path.join(path.dirname(options.statusFile), "durable")
295
+ );
296
+ }
288
297
  const claudeCli = options.runner === "claude" ? await loadClaudeCli() : void 0;
289
298
  const vedaCli = options.runner === "veda" ? await loadVedaCli() : void 0;
290
299
  const childArguments = options.runner === "claude" ? claudeCli.buildClaudeArguments({
@@ -308,7 +317,10 @@ ${schema}`
308
317
  // parallel Fabric agents never share Veda session state.
309
318
  session: `fabric-${options.id}`
310
319
  }) : piArguments;
311
- const childBinary = options.runner === "claude" ? options.claudeBinary : options.runner === "veda" ? options.vedaBinary : options.piBinary;
320
+ const childBinary = options.runner === "claude" ? options.claudeBinary : options.runner === "veda" ? options.vedaBinary : options.runner === "pi-durable" ? fileURLToPath(new URL(
321
+ import.meta.url.endsWith(".ts") ? "./durable/worker.ts" : "./durable/worker.js",
322
+ import.meta.url
323
+ )) : options.piBinary;
312
324
  const child = spawnCli(childBinary, childArguments, {
313
325
  cwd: options.cwd,
314
326
  detached: process.platform !== "win32",
@@ -358,15 +370,19 @@ ${schema}`
358
370
  let outputBuffer = "";
359
371
  let vedaOutput = "";
360
372
  let vedaParsed;
361
- const eventProjection = options.runner === "pi" ? new PiEventProjection() : void 0;
373
+ const eventProjection = isPi ? new PiEventProjection() : void 0;
362
374
  const outputDecoder = new StringDecoder("utf8");
363
375
  const stderrDecoder = new StringDecoder("utf8");
364
376
  let terminalStatus;
365
377
  let terminalError;
366
378
  let sawAgentError = false;
367
379
  let retryPending = false;
380
+ let answerProjected = false;
381
+ let recordedResultPending = false;
382
+ let recordedResultTimer;
383
+ const recordedResultId = `fabric-recorded-result:${options.id}`;
368
384
  const update = () => updateRunRecord(options.statusFile, record);
369
- const questionRelay = options.childQuestionTimeoutMs !== void 0 && options.runner === "pi" && options.steerFile ? new (await loadWorkerQuestions()).ChildQuestionRelay(options.childQuestionTimeoutMs, {
385
+ const questionRelay = options.childQuestionTimeoutMs !== void 0 && isPi && options.steerFile ? new (await loadWorkerQuestions()).ChildQuestionRelay(options.childQuestionTimeoutMs, {
370
386
  emit: (question) => emitLifecycle("question", { ...question }),
371
387
  send: (frame) => child.stdin?.write(`${JSON.stringify(frame)}
372
388
  `),
@@ -747,6 +763,58 @@ ${text}
747
763
  processClaudeEvent(event);
748
764
  return;
749
765
  }
766
+ if (event.type === "response" && recordedResultPending && event.id === recordedResultId) {
767
+ recordedResultPending = false;
768
+ clearTimeout(recordedResultTimer);
769
+ const fail = (reason) => failStalledChild(`Durable recorded result retrieval failed: ${reason}`);
770
+ if (event.command !== "get_messages" || event.success !== true) {
771
+ fail(typeof event.error === "string" ? event.error : "invalid or rejected RPC response");
772
+ return;
773
+ }
774
+ const data = event.data;
775
+ const messages = Array.isArray(data?.messages) ? data.messages : [];
776
+ const isMessage = (value) => typeof value === "object" && value !== null && !Array.isArray(value);
777
+ let start = messages.length - 1;
778
+ while (start >= 0 && !(isMessage(messages[start]) && messages[start].role === "user")) start--;
779
+ if (start < 0 || extractText(messages[start]) !== task) {
780
+ fail("recorded history does not end with the submitted prompt");
781
+ return;
782
+ }
783
+ const assistants = messages.slice(start + 1).filter(
784
+ (message) => isMessage(message) && message.role === "assistant"
785
+ );
786
+ const last = assistants.at(-1);
787
+ if (!last) {
788
+ fail("recorded prompt has no assistant result");
789
+ return;
790
+ }
791
+ const restored = { ...record, usage: emptyUsage() };
792
+ for (const message of assistants) {
793
+ applyUsage(restored, message);
794
+ modelControl.observeAssistant(message);
795
+ }
796
+ if (terminalStatus) return;
797
+ for (const key of ["input", "output", "cacheRead", "cacheWrite", "cost"]) {
798
+ record.usage[key] = Math.max(record.usage[key], restored.usage[key]);
799
+ }
800
+ answerProjected = true;
801
+ record.text = latestRunText(extractText(last));
802
+ record.turns = Math.max(record.turns, assistants.length);
803
+ record.toolCalls = Math.max(record.toolCalls, messages.slice(start + 1).filter(
804
+ (message) => isMessage(message) && message.role === "toolResult"
805
+ ).length);
806
+ if (last.stopReason === "error" || last.stopReason === "aborted") {
807
+ sawAgentError = true;
808
+ terminalError = assistantError(last);
809
+ }
810
+ enforceTokenLimit();
811
+ update();
812
+ if (!terminalStatus) {
813
+ pollSteer();
814
+ compactControl.childSettled();
815
+ }
816
+ return;
817
+ }
750
818
  compactControl.observe(event);
751
819
  if (modelControl.observe(event)) return;
752
820
  if (event.type === "message_start" || event.type === "message_update") {
@@ -836,6 +904,9 @@ ${text}
836
904
  const messageRecord = message;
837
905
  if (messageRecord.role !== "assistant") return;
838
906
  const text = extractText(messageRecord);
907
+ if (text || messageRecord.stopReason === "error" || messageRecord.stopReason === "aborted") {
908
+ answerProjected = true;
909
+ }
839
910
  if (text) {
840
911
  record.text = latestRunText(text);
841
912
  process.stdout.write(`
@@ -871,6 +942,17 @@ ${text}
871
942
  if (event.type === "agent_settled") {
872
943
  emitLifecycle("pi.agent_settled");
873
944
  if (!retryPending) {
945
+ if (options.runner === "pi-durable" && !answerProjected && !terminalStatus) {
946
+ if (!recordedResultPending) {
947
+ recordedResultPending = true;
948
+ recordedResultTimer = setTimeout(() => failStalledChild(
949
+ "Durable recorded result retrieval timed out waiting for get_messages"
950
+ ), KILL_GRACE_MS);
951
+ child.stdin?.write(`${JSON.stringify({ type: "get_messages", id: recordedResultId })}
952
+ `);
953
+ }
954
+ return;
955
+ }
874
956
  pollSteer();
875
957
  compactControl.childSettled();
876
958
  }
@@ -917,7 +999,7 @@ ${schema}`
917
999
  let steerRemainder = Buffer.alloc(0);
918
1000
  let skippingOversizedSteerLine = false;
919
1001
  const pollSteer = () => {
920
- if (!options.steerFile || terminalStatus || options.runner === "pi" && !modelControl.ready) return;
1002
+ if (!options.steerFile || terminalStatus || isPi && !modelControl.ready) return;
921
1003
  let descriptor;
922
1004
  try {
923
1005
  descriptor = fs2.openSync(options.steerFile, "r");
@@ -1066,7 +1148,7 @@ ${schema}`
1066
1148
  if (terminalStatus) return;
1067
1149
  terminalStatus = "timed_out";
1068
1150
  terminalError = `Agent timed out after ${options.timeoutMs}ms`;
1069
- if (options.runner === "pi" && !modelControl.ready) {
1151
+ if (isPi && !modelControl.ready) {
1070
1152
  terminalError += "; Pi model admission did not complete; task was not sent";
1071
1153
  }
1072
1154
  killChild();
@@ -1090,6 +1172,11 @@ ${schema}`
1090
1172
  child.once("close", (code) => resolve(code));
1091
1173
  });
1092
1174
  if (steerTimer) clearInterval(steerTimer);
1175
+ clearTimeout(recordedResultTimer);
1176
+ if (recordedResultPending && !terminalStatus) {
1177
+ terminalStatus = "failed";
1178
+ terminalError = "Durable worker exited before recorded result retrieval completed";
1179
+ }
1093
1180
  questionRelay?.close();
1094
1181
  delete record.blockedOn;
1095
1182
  if (claudeCloseTimer) clearTimeout(claudeCloseTimer);
@@ -1097,7 +1184,7 @@ ${schema}`
1097
1184
  if (killTimer) clearTimeout(killTimer);
1098
1185
  if (closeTimer) clearTimeout(closeTimer);
1099
1186
  recoveryWatchdog.dispose();
1100
- if (options.runner === "pi" && !modelControl.ready && !terminalStatus) {
1187
+ if (isPi && !modelControl.ready && !terminalStatus) {
1101
1188
  terminalStatus = "failed";
1102
1189
  terminalError = `Child Pi exited before requested model admission completed; task was not sent${stderr.trim() ? `: ${stderr.trim()}` : ""}`;
1103
1190
  }
@@ -1177,7 +1264,7 @@ ${text}
1177
1264
  }
1178
1265
  record.finishedAt = Date.now();
1179
1266
  record.updatedAt = record.finishedAt;
1180
- const childCompleted = exitCode === 0 && !sawAgentError && (options.runner === "pi" || options.runner === "claude" && claudeResultSeen && claudeSentInputs.length === 0 && claudeSteering.length === 0 && claudeFollowUps.length === 0 || options.runner === "veda" && vedaParsed !== void 0);
1267
+ const childCompleted = exitCode === 0 && !sawAgentError && (isPi || options.runner === "claude" && claudeResultSeen && claudeSentInputs.length === 0 && claudeSteering.length === 0 && claudeFollowUps.length === 0 || options.runner === "veda" && vedaParsed !== void 0);
1181
1268
  record.status = terminalStatus ?? (childCompleted ? "completed" : "failed");
1182
1269
  if (terminalError) record.error = terminalError;
1183
1270
  if (record.status === "failed" && !record.error) {