openfox 2.0.115 → 2.0.117

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 (95) hide show
  1. package/CHANGELOG.md +46 -0
  2. package/dist/CHANGELOG.md +46 -0
  3. package/dist/{ask-ZYPCJKZD.js → ask-UBIRH3SO.js} +2 -2
  4. package/dist/{auth-YY5PJYSC.js → auth-GTGIGX5X.js} +2 -2
  5. package/dist/{auto-config-T5GR2N6X.js → auto-config-AAUO4PKW.js} +2 -2
  6. package/dist/{backend-LVYHLGQJ.js → backend-67OLCS5O.js} +2 -2
  7. package/dist/{branch.api-XVTYACSH.js → branch.api-UMKSQMSA.js} +2 -2
  8. package/dist/changelog-FZUE6OSG.js +63 -0
  9. package/dist/{chat-handler-5SP265CR.js → chat-handler-URSNELCE.js} +17 -17
  10. package/dist/{chunk-JFK4GKQD.js → chunk-2PQA3DHY.js} +62 -91
  11. package/dist/{chunk-TFF5T3K3.js → chunk-3PEYTWCS.js} +3 -3
  12. package/dist/{chunk-I7FY2LTR.js → chunk-4GHLULHB.js} +18 -2
  13. package/dist/{chunk-TGLVWAFC.js → chunk-6XHDNSA3.js} +5 -5
  14. package/dist/{chunk-3QQAIUZI.js → chunk-7SDJXHJH.js} +175 -30
  15. package/dist/{chunk-4H427UBV.js → chunk-AGXJ5O63.js} +2 -2
  16. package/dist/{chunk-OCBBAEMT.js → chunk-ECCSVMRT.js} +179 -137
  17. package/dist/{chunk-OCSTEGK7.js → chunk-EQ5CGNOT.js} +2 -2
  18. package/dist/{chunk-YX3OQBNX.js → chunk-EQ7DK2TG.js} +9 -5
  19. package/dist/{chunk-OKVHMKE2.js → chunk-EZD7WFBZ.js} +33 -29
  20. package/dist/{chunk-BVVCRIVM.js → chunk-GZTMCTUS.js} +3 -3
  21. package/dist/{chunk-6RGACY4E.js → chunk-HZSKKJHQ.js} +4 -3
  22. package/dist/{chunk-3NPLERPQ.js → chunk-I6MY65LO.js} +9 -8
  23. package/dist/{chunk-VWEATA7R.js → chunk-KLQEL2DZ.js} +7 -1
  24. package/dist/{chunk-JGWHRYWG.js → chunk-MKWS7TQH.js} +2 -2
  25. package/dist/chunk-NPTI5RCQ.js +7 -0
  26. package/dist/{chunk-6KPJLELC.js → chunk-QQVPUZQB.js} +156 -20
  27. package/dist/{chunk-ERNWAKUB.js → chunk-TGVDUK4N.js} +2 -2
  28. package/dist/{chunk-V4IE7HJY.js → chunk-W7VIYHPQ.js} +2 -2
  29. package/dist/{chunk-BWVO5WFK.js → chunk-X3XKYGUN.js} +3 -3
  30. package/dist/{chunk-5WRI5ZAA.js → chunk-YLJ4XMA6.js} +6 -2
  31. package/dist/{chunk-X25Q6RAV.js → chunk-ZKLE2Q3I.js} +1 -1
  32. package/dist/{chunk-37QLXLML.js → chunk-ZS6MW2WM.js} +14 -14
  33. package/dist/cli/dev.js +3 -3
  34. package/dist/cli/index.js +3 -3
  35. package/dist/{client-KE7EDI2D.js → client-KCNTDTIR.js} +4 -4
  36. package/dist/{client-pure-66Z6FWS6.js → client-pure-B5DHEKQJ.js} +2 -2
  37. package/dist/command-defaults/mark-done.command.md +6 -6
  38. package/dist/{compactor-SKVC2VNL.js → compactor-LAXZLPPA.js} +7 -7
  39. package/dist/{config-EAB3V4QK.js → config-TUCHLIWD.js} +2 -2
  40. package/dist/{dynamic-context-QNB4ELLP.js → dynamic-context-NNBVVFBT.js} +3 -3
  41. package/dist/{events-5PLO4QJU.js → events-IVPAMMR5.js} +4 -4
  42. package/dist/{folding-CJWYFUKD.js → folding-RTGU63BW.js} +2 -2
  43. package/dist/{http-client-KLODRQC2.js → http-client-IPUW2MSW.js} +2 -2
  44. package/dist/{inspect-proxy-K6QKEYDT.js → inspect-proxy-WPEDMCG7.js} +2 -2
  45. package/dist/{install-CPOPMCSE.js → install-VA2F6X6Z.js} +2 -2
  46. package/dist/{launch-EOXVWLOP.js → launch-HSSFGQ5A.js} +17 -17
  47. package/dist/{manager-LZ3JQ443.js → manager-EMLSLMMT.js} +2 -2
  48. package/dist/{model-overrides-5UVW3KTE.js → model-overrides-7F2EOA4U.js} +2 -2
  49. package/dist/{oauth-provider-52YILVUJ.js → oauth-provider-DGBC2YM6.js} +2 -2
  50. package/dist/{oauth-store-XCFXV2VM.js → oauth-store-KECHUT54.js} +2 -2
  51. package/dist/{openFolder-HX7X356L.js → openFolder-XCMSU3OI.js} +2 -2
  52. package/dist/{orchestrator-ED3KFPXO.js → orchestrator-FVXUJW3K.js} +16 -16
  53. package/dist/package.json +5 -2
  54. package/dist/{path-security-B6EZC63L.js → path-security-JTCHWYG3.js} +7 -7
  55. package/dist/{paths-F27V3S4I.js → paths-BHR7CZ7I.js} +2 -2
  56. package/dist/{permissions-K6YEA2ZZ.js → permissions-UKR524ZB.js} +2 -2
  57. package/dist/{platform-6RPPBHKH.js → platform-ECDDYMAR.js} +2 -2
  58. package/dist/{processor-226ZOTRI.js → processor-JRVW5QBA.js} +16 -16
  59. package/dist/profiles-GYHXBWPV.js +10 -0
  60. package/dist/{project-creator-VBFE35NI.js → project-creator-PMQ65NKN.js} +2 -2
  61. package/dist/{projects-AXHZOBR2.js → projects-NDPNOV6D.js} +2 -2
  62. package/dist/{protocol-JdxRpPxM.d.ts → protocol-CfUkCYxF.d.ts} +11 -2
  63. package/dist/{protocol-RKSWKNXI.js → protocol-HYA5BYVN.js} +8 -4
  64. package/dist/{provider-DL4ZWQY7.js → provider-Q7J4UFTS.js} +7 -7
  65. package/dist/{provider-manager-6CLRMGDE.js → provider-manager-TMBO4DFG.js} +5 -5
  66. package/dist/{pwa-XPHP3PY2.js → pwa-2GRFSXD7.js} +3 -3
  67. package/dist/{registry-5XI5NDBF.js → registry-5QL3BOWN.js} +2 -2
  68. package/dist/{serve-DARV4NJG.js → serve-CW6PR3M2.js} +22 -22
  69. package/dist/server/index.d.ts +15 -2
  70. package/dist/server/index.js +21 -21
  71. package/dist/{server-LQJ7MBDS.js → server-V46SOIGP.js} +20 -20
  72. package/dist/{service-4JKTGPRG.js → service-M7XJHAK4.js} +6 -6
  73. package/dist/{service-CXWJQFOZ.js → service-WKABQHKL.js} +2 -2
  74. package/dist/{session-overrides-AZKV6BRD.js → session-overrides-CWBKPHMF.js} +4 -4
  75. package/dist/{sessions-752IZIIK.js → sessions-I7ELDIIP.js} +5 -3
  76. package/dist/{settings-2AHDKCD7.js → settings-FGXQHKUH.js} +2 -2
  77. package/dist/shared/index.d.ts +1 -1
  78. package/dist/shared/index.js +2 -2
  79. package/dist/{store-SARB6V2N.js → store-JYPZ2RXB.js} +2 -2
  80. package/dist/{tasks-XJXHU623.js → tasks-X5H5HM4J.js} +6 -6
  81. package/dist/{tool-adapter-FEAHWU5C.js → tool-adapter-FJAFLDZA.js} +2 -2
  82. package/dist/{tools-QYYNFMGU.js → tools-2Q3GRECI.js} +14 -14
  83. package/dist/{update-2REP2WB6.js → update-YP7IRT6M.js} +4 -4
  84. package/dist/{update-server-LOOXIXDW.js → update-server-SVPV6ZJZ.js} +2 -2
  85. package/dist/{url-utils-SAJP7AEX.js → url-utils-C5BM7NF7.js} +2 -2
  86. package/dist/web/assets/index-C58KXxRi.js +324 -0
  87. package/dist/web/assets/{index-BmILAZrT.css → index-DTiVSJJu.css} +1 -1
  88. package/dist/web/index.html +2 -2
  89. package/dist/web/sw.js +1 -1
  90. package/dist/workflow-defaults/default.workflow.json +2 -2
  91. package/dist/{workspace-RMZVTFJD.js → workspace-IQLLHMYR.js} +2 -2
  92. package/package.json +5 -2
  93. package/dist/chunk-5V3BF67X.js +0 -7
  94. package/dist/profiles-5J7F4BML.js +0 -10
  95. package/dist/web/assets/index-M7ToECa4.js +0 -324
@@ -4,7 +4,7 @@ import {
4
4
  import {
5
5
  createServerMessage,
6
6
  isClientMessage
7
- } from "./chunk-X25Q6RAV.js";
7
+ } from "./chunk-ZKLE2Q3I.js";
8
8
 
9
9
  // src/server/session/client-session.ts
10
10
  function toClientSession(session) {
@@ -140,6 +140,12 @@ function createChatDoneMessage(messageId, reason, stats, agentType) {
140
140
  function createChatErrorMessage(error, recoverable) {
141
141
  return createServerMessage("chat.error", { error, recoverable });
142
142
  }
143
+ function createChatMessageRemovedMessage(messageIds) {
144
+ return createServerMessage("chat.message_removed", { messageIds });
145
+ }
146
+ function createChatStepRetryMessage(stepName, attempt, retryInMs) {
147
+ return createServerMessage("chat.step_retry", { stepName, attempt, retryInMs });
148
+ }
143
149
  function createChatPathConfirmationMessage(callId, tool, paths, workdir, reason) {
144
150
  return createServerMessage("chat.path_confirmation", { callId, tool, paths, workdir, reason });
145
151
  }
@@ -316,6 +322,14 @@ function storedEventToServerMessage(event) {
316
322
  const data = event.data;
317
323
  return createChatFormatRetryMessage(data.attempt, data.maxAttempts, data.pattern, data.field, data.matchedContent);
318
324
  }
325
+ case "message.removed": {
326
+ const data = event.data;
327
+ return createChatMessageRemovedMessage(data.messageIds);
328
+ }
329
+ case "workflow.step_retry": {
330
+ const data = event.data;
331
+ return createChatStepRetryMessage(data.stepName, data.attempt, data.retryInMs);
332
+ }
319
333
  case "path.confirmation_pending":
320
334
  case "path.confirmation_responded":
321
335
  return null;
@@ -351,6 +365,8 @@ export {
351
365
  createChatMessageUpdatedMessage,
352
366
  createChatDoneMessage,
353
367
  createChatErrorMessage,
368
+ createChatMessageRemovedMessage,
369
+ createChatStepRetryMessage,
354
370
  createChatPathConfirmationMessage,
355
371
  createChatAskUserMessage,
356
372
  createModeChangedMessage,
@@ -366,4 +382,4 @@ export {
366
382
  createQueueStateMessage,
367
383
  storedEventToServerMessage
368
384
  };
369
- //# sourceMappingURL=chunk-I7FY2LTR.js.map
385
+ //# sourceMappingURL=chunk-4GHLULHB.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  combineEventsWithSnapshot,
3
3
  getEventStore
4
- } from "./chunk-ERNWAKUB.js";
4
+ } from "./chunk-TGVDUK4N.js";
5
5
  import {
6
6
  updateSessionMetadata
7
- } from "./chunk-VWEATA7R.js";
7
+ } from "./chunk-KLQEL2DZ.js";
8
8
  import {
9
9
  createContextStateMessage,
10
10
  createSessionStateMessage
11
- } from "./chunk-I7FY2LTR.js";
11
+ } from "./chunk-4GHLULHB.js";
12
12
  import {
13
13
  getPendingQuestionsForSession
14
14
  } from "./chunk-JURM3RPZ.js";
@@ -153,7 +153,7 @@ async function generateSessionNameForSession(sessionId, userMessage, deps, signa
153
153
  client = deps.getLLMClient();
154
154
  client.setModel(providerConfig.model);
155
155
  } else if (providerConfig) {
156
- const { createLLMClient } = await import("./client-KE7EDI2D.js");
156
+ const { createLLMClient } = await import("./client-KCNTDTIR.js");
157
157
  client = createLLMClient({
158
158
  llm: {
159
159
  baseUrl: providerConfig.baseUrl,
@@ -204,4 +204,4 @@ export {
204
204
  needsNameGeneration,
205
205
  generateSessionNameForSession
206
206
  };
207
- //# sourceMappingURL=chunk-TGLVWAFC.js.map
207
+ //# sourceMappingURL=chunk-6XHDNSA3.js.map
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  runAgentTurn
3
- } from "./chunk-3NPLERPQ.js";
3
+ } from "./chunk-I6MY65LO.js";
4
4
  import {
5
5
  executeSubAgent,
6
6
  getToolRegistryForAgent
7
- } from "./chunk-JFK4GKQD.js";
7
+ } from "./chunk-2PQA3DHY.js";
8
8
  import {
9
9
  TurnMetrics,
10
10
  createMessageStartEvent
11
- } from "./chunk-YX3OQBNX.js";
11
+ } from "./chunk-EQ7DK2TG.js";
12
12
  import {
13
13
  checkAborted,
14
14
  decodeUtf8,
@@ -27,21 +27,24 @@ import {
27
27
  loadProjectWorkflows,
28
28
  loadUserWorkflows,
29
29
  normalizeWorkflowScope
30
- } from "./chunk-6RGACY4E.js";
30
+ } from "./chunk-HZSKKJHQ.js";
31
31
  import {
32
32
  getCurrentContextWindowId,
33
33
  getEventStore
34
- } from "./chunk-ERNWAKUB.js";
34
+ } from "./chunk-TGVDUK4N.js";
35
35
  import {
36
36
  createChatMessageMessage,
37
37
  createSessionRunningMessage
38
- } from "./chunk-I7FY2LTR.js";
38
+ } from "./chunk-4GHLULHB.js";
39
39
  import {
40
40
  findAgentById,
41
41
  getRuntimeConfig,
42
42
  loadAllAgentsDefault,
43
43
  resolveDefaultAgentId
44
44
  } from "./chunk-LNNBLB6G.js";
45
+ import {
46
+ LLMError
47
+ } from "./chunk-LTYL6ZGH.js";
45
48
  import {
46
49
  logger
47
50
  } from "./chunk-K44MW7JJ.js";
@@ -50,11 +53,19 @@ import {
50
53
  } from "./chunk-VUQCQXXJ.js";
51
54
  import {
52
55
  createServerMessage
53
- } from "./chunk-X25Q6RAV.js";
56
+ } from "./chunk-ZKLE2Q3I.js";
54
57
  import {
55
58
  getGlobalConfigDir
56
59
  } from "./chunk-CQGTEGKL.js";
57
60
 
61
+ // src/server/runner/types.ts
62
+ var DEFAULT_LLM_RETRY_POLICY = {
63
+ backoffMs: [1e3, 5e3, 3e4],
64
+ minIntervalMs: 6e4,
65
+ maxDurationMs: 30 * 6e4,
66
+ maxAttempts: 40
67
+ };
68
+
58
69
  // src/server/workflows/types.ts
59
70
  var TERMINAL_DONE = "$done";
60
71
  var TERMINAL_BLOCKED = "$blocked";
@@ -336,6 +347,64 @@ function getCurrentWindowMessageOptions(sessionId) {
336
347
  const contextWindowId = getCurrentContextWindowId(sessionId);
337
348
  return contextWindowId ? { contextWindowId } : void 0;
338
349
  }
350
+ function sleepWithSignal(ms, signal) {
351
+ return new Promise((resolve, reject) => {
352
+ if (signal?.aborted) {
353
+ reject(new Error("Aborted"));
354
+ return;
355
+ }
356
+ const onAbort = () => {
357
+ clearTimeout(timer);
358
+ signal?.removeEventListener("abort", onAbort);
359
+ reject(new Error("Aborted"));
360
+ };
361
+ const timer = setTimeout(() => {
362
+ signal?.removeEventListener("abort", onAbort);
363
+ resolve();
364
+ }, ms);
365
+ signal?.addEventListener("abort", onAbort, { once: true });
366
+ });
367
+ }
368
+ function evaluateLLMRetry(failures, firstFailureAt, now, policy) {
369
+ if (now - firstFailureAt >= policy.maxDurationMs) return { retry: false };
370
+ if (failures >= policy.maxAttempts) return { retry: false };
371
+ const delayMs = failures <= policy.backoffMs.length ? policy.backoffMs[failures - 1] : policy.minIntervalMs;
372
+ return { retry: true, delayMs, attempt: failures + 1 };
373
+ }
374
+ function rollbackFailedAttempt(sessionId, turnStartSeq) {
375
+ const eventStore = getEventStore();
376
+ const fromSeq = Math.max(1, turnStartSeq);
377
+ const events = eventStore.getEvents(sessionId, fromSeq + 1);
378
+ const assistantIds = new Set(
379
+ events.filter((e) => e.type === "message.start" && e.data.role === "assistant").map((e) => e.data.messageId)
380
+ );
381
+ const tombstoneSeqs = events.filter((e) => {
382
+ switch (e.type) {
383
+ case "message.start":
384
+ return e.data.role === "assistant";
385
+ case "message.delta":
386
+ case "message.thinking":
387
+ case "message.done":
388
+ case "chat.done":
389
+ return assistantIds.has(e.data.messageId);
390
+ case "chat.error":
391
+ case "pattern.retry":
392
+ case "tool.preparing":
393
+ case "tool.call":
394
+ case "tool.output":
395
+ case "tool.result":
396
+ return true;
397
+ default:
398
+ return false;
399
+ }
400
+ }).map((e) => e.seq);
401
+ if (tombstoneSeqs.length > 0) {
402
+ eventStore.tombstoneEvents(sessionId, tombstoneSeqs);
403
+ }
404
+ if (assistantIds.size > 0) {
405
+ eventStore.append(sessionId, { type: "message.removed", data: { messageIds: [...assistantIds] } });
406
+ }
407
+ }
339
408
  function buildReason(metadataEntries) {
340
409
  const entries = metadataEntries?.["criteria"] ?? [];
341
410
  const remaining = entries.filter((e) => e.status !== "passed");
@@ -353,6 +422,8 @@ async function executeWorkflow(workflow, options, subGroup) {
353
422
  let currentStepId = isResume ? resumeFromStep : subGroup ? activeSteps[0]?.id ?? workflow.entryStep : workflow.entryStep;
354
423
  let lastStepOutput = options.initialStepOutput ?? {};
355
424
  const firstEntryForStep = /* @__PURE__ */ new Set();
425
+ const stepLLMFailures = /* @__PURE__ */ new Map();
426
+ const stepLLMDeadlines = /* @__PURE__ */ new Map();
356
427
  const messagesBeforeWorkflow = sessionManager.requireSession(sessionId).messages.length;
357
428
  const activeStepIds = new Set(activeSteps.map((s) => s.id));
358
429
  const activeSubGroups = /* @__PURE__ */ new Set();
@@ -497,9 +568,10 @@ async function executeWorkflow(workflow, options, subGroup) {
497
568
  const agentStep = step;
498
569
  const STEP_DONE_PROMPT = "\n\nOnce you're done, call step_done()";
499
570
  const STEP_DONE_NUDGE = "You haven't called step_done(). If you haven't finished the task, continue and when you're finished call step_done()";
571
+ const isResumingCurrentStep = isResume && step.id === resumeFromStep && !resumeConsumed;
572
+ const isLLMFailedRetry = firstEntryForStep.has(step.id) && (stepLLMFailures.get(step.id) ?? 0) > 0;
500
573
  let promptContent;
501
574
  let nudgeContent;
502
- const isResumingCurrentStep = isResume && step.id === resumeFromStep && !resumeConsumed;
503
575
  if (!firstEntryForStep.has(step.id) && agentStep.prompt && !isResumingCurrentStep) {
504
576
  const resolvedPrompt = resolveTemplate(agentStep.prompt, templateCtx);
505
577
  promptContent = resolvedPrompt + STEP_DONE_PROMPT;
@@ -528,7 +600,7 @@ async function executeWorkflow(workflow, options, subGroup) {
528
600
  })
529
601
  );
530
602
  }
531
- } else if (firstEntryForStep.has(step.id) && !isResumingCurrentStep) {
603
+ } else if (firstEntryForStep.has(step.id) && !isResumingCurrentStep && !isLLMFailedRetry) {
532
604
  const parts = [];
533
605
  if (agentStep.nudgePrompt) {
534
606
  const resolvedNudge = resolveTemplate(agentStep.nudgePrompt, templateCtx);
@@ -538,32 +610,105 @@ async function executeWorkflow(workflow, options, subGroup) {
538
610
  nudgeContent = parts.join("\n\n");
539
611
  emitWorkflowMessage(eventStore, sessionId, nudgeContent, currentWindowMessageOptions, onMessage);
540
612
  }
613
+ const turnStartSeq = eventStore.getLatestSeq(sessionId) ?? 0;
614
+ let retryBlocked = null;
615
+ let blockedReason = "";
616
+ const retryPolicy = { ...DEFAULT_LLM_RETRY_POLICY, ...options.llmRetryPolicy };
617
+ const handleLLMFailure = async (errorMessage) => {
618
+ const failures = (stepLLMFailures.get(step.id) ?? 0) + 1;
619
+ stepLLMFailures.set(step.id, failures);
620
+ const firstFailureAt = stepLLMDeadlines.get(step.id) ?? Date.now();
621
+ stepLLMDeadlines.set(step.id, firstFailureAt);
622
+ const decision = evaluateLLMRetry(failures, firstFailureAt, Date.now(), retryPolicy);
623
+ if (decision.retry) {
624
+ rollbackFailedAttempt(sessionId, turnStartSeq);
625
+ firstEntryForStep.add(step.id);
626
+ resumeConsumed = true;
627
+ eventStore.append(sessionId, {
628
+ type: "workflow.step_retry",
629
+ data: { stepName: step.name, attempt: decision.attempt, retryInMs: decision.delayMs }
630
+ });
631
+ retryBlocked = "retry";
632
+ await sleepWithSignal(decision.delayMs, signal);
633
+ return;
634
+ }
635
+ rollbackFailedAttempt(sessionId, turnStartSeq);
636
+ sessionManager.setPhase(sessionId, "blocked");
637
+ if (executionId) {
638
+ sessionManager.blockWorkflow(
639
+ sessionId,
640
+ executionId,
641
+ workflow.metadata.id,
642
+ workflow.metadata.name,
643
+ workflow.metadata.color
644
+ );
645
+ }
646
+ blockedReason = `Step "${step.name}" failed after ${failures} attempts: ${errorMessage}`;
647
+ eventStore.append(sessionId, { type: "chat.error", data: { error: blockedReason, recoverable: false } });
648
+ retryBlocked = "blocked";
649
+ };
541
650
  const turnMetrics = new TurnMetrics();
542
651
  const es = getEventStore();
543
652
  const append = (event) => es.append(sessionId, event);
544
653
  let stepDoneCalled = false;
545
- const agentResult = await runAgentTurn(
546
- {
547
- sessionManager,
548
- sessionId,
549
- llmClient,
550
- ...options.statsIdentity ? { statsIdentity: options.statsIdentity } : {},
551
- ...signal ? { signal } : {},
552
- ...onMessage ? { onMessage } : {}
553
- },
554
- turnMetrics,
555
- agentStep.agentId ?? resolveDefaultAgentId(),
556
- append,
557
- {
558
- ...!firstEntryForStep.has(step.id) && !agentStep.prompt && !isResumingCurrentStep ? { injectKickoff: () => injectGenericKickoff(sessionId) } : {},
559
- onToolExecuted: (toolCall, toolResult) => {
560
- if (toolCall.name === "step_done" && toolResult.success) {
561
- stepDoneCalled = true;
654
+ let agentResult;
655
+ try {
656
+ agentResult = await runAgentTurn(
657
+ {
658
+ sessionManager,
659
+ sessionId,
660
+ llmClient,
661
+ ...options.statsIdentity ? { statsIdentity: options.statsIdentity } : {},
662
+ ...signal ? { signal } : {},
663
+ ...onMessage ? { onMessage } : {},
664
+ suppressRecoverableErrors: true,
665
+ ...isLLMFailedRetry || isResumingCurrentStep ? { skipAgentReminder: true } : {}
666
+ },
667
+ turnMetrics,
668
+ agentStep.agentId ?? resolveDefaultAgentId(),
669
+ append,
670
+ {
671
+ ...!firstEntryForStep.has(step.id) && !agentStep.prompt && !isResumingCurrentStep ? { injectKickoff: () => injectGenericKickoff(sessionId) } : {},
672
+ onToolExecuted: (toolCall, toolResult) => {
673
+ if (toolCall.name === "step_done" && toolResult.success) {
674
+ stepDoneCalled = true;
675
+ }
562
676
  }
563
677
  }
678
+ );
679
+ } catch (error) {
680
+ if (error instanceof Error && error.message === "Aborted") {
681
+ throw error;
564
682
  }
565
- );
683
+ if (!(error instanceof LLMError)) {
684
+ throw error;
685
+ }
686
+ await handleLLMFailure(error.message);
687
+ if (retryBlocked === "retry") {
688
+ iterations -= 1;
689
+ continue;
690
+ }
691
+ return {
692
+ finalAction: { type: "BLOCKED", reason: blockedReason, blockedCriteria: [] },
693
+ iterations,
694
+ totalTime: (performance.now() - startTime) / 1e3
695
+ };
696
+ }
697
+ if (agentResult.failed) {
698
+ await handleLLMFailure(agentResult.failed.error);
699
+ if (retryBlocked === "retry") {
700
+ iterations -= 1;
701
+ continue;
702
+ }
703
+ return {
704
+ finalAction: { type: "BLOCKED", reason: blockedReason, blockedCriteria: [] },
705
+ iterations,
706
+ totalTime: (performance.now() - startTime) / 1e3
707
+ };
708
+ }
566
709
  firstEntryForStep.add(step.id);
710
+ stepLLMFailures.delete(step.id);
711
+ stepLLMDeadlines.delete(step.id);
567
712
  resumeConsumed = true;
568
713
  const agentReturnValue = agentResult.returnValueResult ?? "completed";
569
714
  lastStepOutput = {
@@ -894,9 +1039,9 @@ function launchWorkflowRun(deps, payload) {
894
1039
  ...payload.stepOutput ? { initialStepOutput: payload.stepOutput } : {},
895
1040
  ...payload.userChoice ? { userChoice: payload.userChoice } : {},
896
1041
  ...payload.resumeFrom ? (() => {
897
- const exec = sessionManager.getActiveWorkflowExecution(sessionId);
1042
+ const exec = sessionManager.getLatestWorkflowExecution(sessionId);
898
1043
  if (!exec) return {};
899
- if (exec.status === "waiting") {
1044
+ if (exec.status === "waiting" || exec.status === "blocked") {
900
1045
  const resumed = sessionManager.resumeWorkflow(
901
1046
  sessionId,
902
1047
  exec.id,
@@ -954,4 +1099,4 @@ export {
954
1099
  abortRunnerRun,
955
1100
  launchWorkflowRun
956
1101
  };
957
- //# sourceMappingURL=chunk-3QQAIUZI.js.map
1102
+ //# sourceMappingURL=chunk-7SDJXHJH.js.map
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  __commonJS,
3
3
  __toESM
4
- } from "./chunk-5WRI5ZAA.js";
4
+ } from "./chunk-YLJ4XMA6.js";
5
5
 
6
6
  // node_modules/sisteransi/src/index.js
7
7
  var require_src = __commonJS({
@@ -1295,4 +1295,4 @@ export {
1295
1295
  select,
1296
1296
  text
1297
1297
  };
1298
- //# sourceMappingURL=chunk-4H427UBV.js.map
1298
+ //# sourceMappingURL=chunk-AGXJ5O63.js.map