omnius 1.0.857 → 1.0.858

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.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
1
  [diffend] Oversized file quarantined before diffing.
2
2
  name: package/dist/index.js
3
- size: 37504153 bytes
4
- sha256: 72456e9f7b61b67a1cbb984d416fca252b250bce4ed4508b5508c427d960c0ab
3
+ size: 37522251 bytes
4
+ sha256: 5b1ad95c2824b29186cceae690cc07628910ebbe8e1a3d2585756a32e7caf6d0
package/dist/library.js CHANGED
@@ -345320,6 +345320,25 @@ function compareKeylessInferenceProviders(a, b) {
345320
345320
  return keylessInferenceStage(a) - keylessInferenceStage(b) || Number(b.nativeToolsHint) - Number(a.nativeToolsHint) || Number(b.structuredOutputHint === true) - Number(a.structuredOutputHint === true) || textOrder(a.id, b.id) || textOrder(a.chatUrl, b.chatUrl);
345321
345321
  }
345322
345322
 
345323
+ // packages/orchestrator/dist/unread-source-carrier.js
345324
+ var proofs2 = /* @__PURE__ */ new WeakMap();
345325
+ function markUnreadSourceCarrier(message, proof) {
345326
+ if (message.requiredSourceEvidence)
345327
+ proofs2.set(message.requiredSourceEvidence, proof);
345328
+ }
345329
+ function isCurrentUnreadSourceCarrier(message) {
345330
+ const evidence = message.requiredSourceEvidence;
345331
+ const proof = evidence && proofs2.get(evidence);
345332
+ return Boolean(proof && message.role === "tool" && message.tool_call_id === proof.callId && message.content === proof.content && evidence?.schema === "omnius.required-source-evidence.v1" && evidence.scope === `unread-web-source:${proof.callId}` && proof.current());
345333
+ }
345334
+ function restoreUnreadSourceCarrierIdentity(before, after) {
345335
+ for (let index = 0; index < before.length; index++) {
345336
+ const source = before[index], target2 = after[index];
345337
+ if (target2 && isCurrentUnreadSourceCarrier(source) && target2.role === source.role && target2.tool_call_id === source.tool_call_id && target2.content === source.content && target2.requiredSourceEvidence?.schema === source.requiredSourceEvidence?.schema && target2.requiredSourceEvidence?.scope === source.requiredSourceEvidence?.scope)
345338
+ target2.requiredSourceEvidence = source.requiredSourceEvidence;
345339
+ }
345340
+ }
345341
+
345323
345342
  // packages/orchestrator/dist/remote-inference-fallback.js
345324
345343
  var completedCapacityRoutes = /* @__PURE__ */ new WeakMap();
345325
345344
  function completedCapacityBinding(request) {
@@ -346420,6 +346439,7 @@ ${line}`).join("");
346420
346439
  responseFormat: prepared.responseFormat,
346421
346440
  response_format: prepared.response_format
346422
346441
  });
346442
+ restoreUnreadSourceCarrierIdentity(prepared.messages, wire.messages);
346423
346443
  const nativeIdle = streamDeadline !== void 0 && (request.nativePlanningStreamIdleTimeoutMs === 9e4 || request.structuredReviewStreamIdleTimeoutMs === 9e4) && this.policy.requestTimeoutMsSource === "default";
346424
346444
  const timeoutMs = nativeIdle ? Math.min(9e4, request.timeoutMs > 0 ? request.timeoutMs : Infinity, Math.max(1, streamDeadline - this.now())) : Math.min(request.timeoutMs, this.policy.requestTimeoutMs);
346425
346445
  const maxTokens = this.remoteOutputTokens(request, route);
@@ -358551,6 +358571,27 @@ var InterruptionLifecycle = class {
358551
358571
  }
358552
358572
  };
358553
358573
 
358574
+ // packages/orchestrator/dist/input-wait-interruption.js
358575
+ var InputWaitInterruption = class extends Error {
358576
+ constructor() {
358577
+ super("The operator paused inference to provide input.");
358578
+ this.name = "InputWaitInterruption";
358579
+ }
358580
+ };
358581
+ async function withInputWaitCancellation(signal, operation) {
358582
+ signal.throwIfAborted();
358583
+ let cancel;
358584
+ const interrupted = new Promise((_, reject) => {
358585
+ cancel = () => reject(signal.reason);
358586
+ signal.addEventListener("abort", cancel, { once: true });
358587
+ });
358588
+ try {
358589
+ return await Promise.race([operation(), interrupted]);
358590
+ } finally {
358591
+ signal.removeEventListener("abort", cancel);
358592
+ }
358593
+ }
358594
+
358554
358595
  // packages/orchestrator/dist/tool-exposure-policy.js
358555
358596
  import { createHash as createHash71 } from "node:crypto";
358556
358597
  var DEFAULT_MAXIMUM_ALWAYS_VISIBLE_TOOLS = 8;
@@ -387226,7 +387267,12 @@ var AgenticRunner = class _AgenticRunner {
387226
387267
  /** Abort releases process-local pressure even if a remote stream ignores cancellation. */
387227
387268
  _activeInferencePressureLease = null;
387228
387269
  _paused = false;
387229
- _pauseResolve = null;
387270
+ _pauseWaiters = /* @__PURE__ */ new Set();
387271
+ _inputWaitModelControllers = /* @__PURE__ */ new Set();
387272
+ _inputWaitPaused = false;
387273
+ _inputWaitSequence = 0;
387274
+ _inputWaitPauseReceipt = null;
387275
+ _inputWaitBoundaryController = new AbortController();
387230
387276
  _interruptionMessages = null;
387231
387277
  _interruptionToolCallLog = null;
387232
387278
  _interruptionExplicitGoal = "";
@@ -392598,11 +392644,16 @@ ${read.content}`;
392598
392644
  * model output never select the ownership class.
392599
392645
  */
392600
392646
  async _dispatchInterruptionOwnedModelRequest(backend, request, ownerId, operation = {}) {
392647
+ const admissionInputWaitGeneration = this._modelRequestGeneration;
392648
+ if (this._paused && this._inputWaitPaused)
392649
+ throw new InputWaitInterruption();
392601
392650
  if (this._interruptionMode !== "off" && this._paused) {
392602
392651
  const shouldContinue = await this.waitIfPaused();
392603
392652
  if (!shouldContinue)
392604
392653
  throw new Error("interruption_stop_admitted");
392605
392654
  }
392655
+ if (admissionInputWaitGeneration !== this._modelRequestGeneration)
392656
+ throw new InputWaitInterruption();
392606
392657
  const ticket = this._interruptionLifecycle?.registerOperation({
392607
392658
  kind: "model",
392608
392659
  effect: "read_only",
@@ -392612,6 +392663,8 @@ ${read.content}`;
392612
392663
  throw new Error("interruption_admission_closed:model");
392613
392664
  }
392614
392665
  const failureOwner = { runId: this.currentArtifactRunId(), taskEpoch: this._taskEpoch };
392666
+ const inputWaitController = new AbortController();
392667
+ this._inputWaitModelControllers.add(inputWaitController);
392615
392668
  let successfulRoute;
392616
392669
  if (operation.requiredForRun)
392617
392670
  this._sourceReadContextCapacity = void 0;
@@ -392628,7 +392681,10 @@ ${read.content}`;
392628
392681
  contextLimitSource: limit2.source,
392629
392682
  allowContentCompaction: false
392630
392683
  });
392631
- if ((preliminary.receipt.decision === "reject" || request.preparedContextCapacity && !this._currentPreparedContextCapacity(request)) && await this._prepareRequestContextCapacity(request, backend.prepareContextCapacity ? backend : this.backend, operation.assertCurrent)) {
392684
+ if ((preliminary.receipt.decision === "reject" || request.preparedContextCapacity && !this._currentPreparedContextCapacity(request)) && await withInputWaitCancellation(inputWaitController.signal, () => this._prepareRequestContextCapacity(request, backend.prepareContextCapacity ? backend : this.backend, () => {
392685
+ inputWaitController.signal.throwIfAborted();
392686
+ operation.assertCurrent?.();
392687
+ }))) {
392632
392688
  limit2 = this._contextAdmissionLimit(request);
392633
392689
  this._refreshCanonicalTransportTrace(request);
392634
392690
  }
@@ -392679,6 +392735,7 @@ ${read.content}`;
392679
392735
  toolOwnerId: this._interruptionOwnerId
392680
392736
  };
392681
392737
  const assertCurrent = () => {
392738
+ inputWaitController.signal.throwIfAborted();
392682
392739
  outbound.assertCurrentAtDispatch?.();
392683
392740
  operation.assertCurrent?.();
392684
392741
  this._abortController.signal.throwIfAborted();
@@ -392714,7 +392771,14 @@ ${read.content}`;
392714
392771
  });
392715
392772
  }
392716
392773
  } : outbound;
392717
- const response = await backend.chatCompletion(dispatchRequest);
392774
+ const ownedRequest = { ...dispatchRequest, signal: AbortSignal.any([
392775
+ inputWaitController.signal,
392776
+ this._abortController.signal,
392777
+ this._turnAbortController.signal,
392778
+ ...dispatchRequest.signal ? [dispatchRequest.signal] : []
392779
+ ]) };
392780
+ const response = await withInputWaitCancellation(inputWaitController.signal, () => backend.chatCompletion(ownedRequest));
392781
+ inputWaitController.signal.throwIfAborted();
392718
392782
  if (ticket && !this._interruptionLifecycle?.canCommit(ticket)) {
392719
392783
  throw new Error("interruption_stale_model_result");
392720
392784
  }
@@ -392722,6 +392786,8 @@ ${read.content}`;
392722
392786
  this._successfulPrimaryInferenceRoutes.set(request, successfulRoute);
392723
392787
  return response;
392724
392788
  } catch (error) {
392789
+ if (inputWaitController.signal.reason instanceof InputWaitInterruption)
392790
+ throw inputWaitController.signal.reason;
392725
392791
  const failure = error;
392726
392792
  if (operation.requiredForRun && !this.aborted && failureOwner.runId === this.currentArtifactRunId() && failureOwner.taskEpoch === this._taskEpoch && failure?.fatal === true && failure.retryable === false && (failure.code === "remote_inference_unavailable" || failure.code === "inference_stream_interrupted" || failure.code === "fallback_approval_required" || failure.code === "fallback_declined")) {
392727
392793
  this._terminalRuntimeFailure = {
@@ -392735,8 +392801,9 @@ ${read.content}`;
392735
392801
  }
392736
392802
  throw error;
392737
392803
  } finally {
392804
+ this._inputWaitModelControllers.delete(inputWaitController);
392738
392805
  if (ticket) {
392739
- this._interruptionLifecycle?.acknowledgeOperation(ticket, this.aborted ? "cancelled" : "completed");
392806
+ this._interruptionLifecycle?.acknowledgeOperation(ticket, this.aborted || inputWaitController.signal.aborted ? "cancelled" : "completed");
392740
392807
  }
392741
392808
  }
392742
392809
  }
@@ -392826,7 +392893,7 @@ ${read.content}`;
392826
392893
  const pending = this._currentUnreadWebSourceCarrier(message), callId = message.tool_call_id;
392827
392894
  if (!pending || !callId || typeof message.content !== "string")
392828
392895
  continue;
392829
- _unreadWebSourceCarrierProofs.set(message, {
392896
+ markUnreadSourceCarrier(message, {
392830
392897
  content: message.content,
392831
392898
  callId,
392832
392899
  current: () => this._currentUnreadWebSourceView(callId) === pending
@@ -393022,6 +393089,7 @@ ${read.content}`;
393022
393089
  const exactRequest = { ...value, messages: value.messages.map((message) => ({ ...message })) };
393023
393090
  this._toolPromotionLastDispatchedTurn = turn;
393024
393091
  const result = await (streaming ? this.streamingRequest(value, turn, textProtocol) : this.backend.chatCompletion(value));
393092
+ value.signal?.throwIfAborted();
393025
393093
  if (!this.aborted && readOwner.scopeId === this._sessionId && readOwner.runId === this.currentArtifactRunId() && readOwner.taskEpoch === this._taskEpoch && readOwner.toolOwnerId === this._interruptionOwnerId && result.choices.some((choice) => Boolean(choice.message.content?.trim() || choice.message.toolCalls?.length))) {
393026
393094
  await this._confirmCorpusReadsInSuccessfulRequest(exactRequest);
393027
393095
  this._confirmUnreadWebSourcesInSuccessfulRequest(exactRequest);
@@ -405949,10 +406017,7 @@ The previous reviewer response failed exact candidate-quote serialization. Host
405949
406017
  if (shellTool && typeof shellTool.killAll === "function") {
405950
406018
  shellTool.killAll();
405951
406019
  }
405952
- if (this._pauseResolve) {
405953
- this._pauseResolve();
405954
- this._pauseResolve = null;
405955
- }
406020
+ this._releasePauseWaiters();
405956
406021
  return transition;
405957
406022
  }
405958
406023
  /** Get the current abort signal for passing to fetch/spawn */
@@ -407651,6 +407716,48 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
407651
407716
  this._paused = true;
407652
407717
  return transition;
407653
407718
  }
407719
+ /** Operator input wait: cancel unfinished inference and retain owned work. */
407720
+ pauseForInput() {
407721
+ const receipt = this.pause();
407722
+ if (receipt?.accepted === false)
407723
+ return receipt;
407724
+ this._inputWaitPauseReceipt = receipt;
407725
+ ++this._inputWaitSequence;
407726
+ if (!this._inputWaitPaused) {
407727
+ this._inputWaitPaused = true;
407728
+ ++this._modelRequestGeneration;
407729
+ this._inputWaitBoundaryController.abort(new InputWaitInterruption());
407730
+ this._pendingStreamAssistantText = null;
407731
+ this._pendingPausedStreamTerminal = null;
407732
+ for (const controller of this._inputWaitModelControllers)
407733
+ controller.abort(new InputWaitInterruption());
407734
+ }
407735
+ return receipt;
407736
+ }
407737
+ /** A typed instruction resumes only after the exact atomic owners settle. */
407738
+ async resumeAfterInput() {
407739
+ const sequence = this._inputWaitSequence;
407740
+ const pauseReceipt = this._inputWaitPauseReceipt;
407741
+ const lifecycle = this._interruptionLifecycle;
407742
+ const runId = this.currentArtifactRunId();
407743
+ while (!this.aborted && sequence === this._inputWaitSequence && lifecycle === this._interruptionLifecycle && runId === this.currentArtifactRunId() && lifecycle?.snapshot().phase === "pausing") {
407744
+ await new Promise((resolve38) => setTimeout(resolve38, 20));
407745
+ }
407746
+ if (sequence !== this._inputWaitSequence || lifecycle !== this._interruptionLifecycle || runId !== this.currentArtifactRunId()) {
407747
+ return pauseReceipt ? {
407748
+ ...pauseReceipt,
407749
+ accepted: false,
407750
+ action: "resume",
407751
+ reason: "Resume superseded by a newer input-wait request."
407752
+ } : null;
407753
+ }
407754
+ return this.resume();
407755
+ }
407756
+ _releasePauseWaiters() {
407757
+ for (const release of this._pauseWaiters)
407758
+ release();
407759
+ this._pauseWaiters.clear();
407760
+ }
407654
407761
  /**
407655
407762
  * Resume a paused task. The run loop continues from where it left off.
407656
407763
  */
@@ -407662,10 +407769,9 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
407662
407769
  if (resumed && !resumed.accepted)
407663
407770
  return resumed;
407664
407771
  this._paused = false;
407665
- if (this._pauseResolve) {
407666
- this._pauseResolve();
407667
- this._pauseResolve = null;
407668
- }
407772
+ this._inputWaitPaused = false;
407773
+ this._inputWaitBoundaryController = new AbortController();
407774
+ this._releasePauseWaiters();
407669
407775
  return resumed;
407670
407776
  }
407671
407777
  /** Whether the runner is currently paused */
@@ -407878,7 +407984,7 @@ Earlier host presentation and its quoted source/history bytes are retained lossl
407878
407984
  } catch {
407879
407985
  }
407880
407986
  await new Promise((resolve38) => {
407881
- this._pauseResolve = resolve38;
407987
+ this._pauseWaiters.add(resolve38);
407882
407988
  });
407883
407989
  return !this.aborted;
407884
407990
  }
@@ -410107,7 +410213,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
410107
410213
  try {
410108
410214
  this.aborted = false;
410109
410215
  this._paused = false;
410110
- this._pauseResolve = null;
410216
+ this._pauseWaiters.clear();
410111
410217
  this._abortController = new AbortController();
410112
410218
  this._turnAbortController = new AbortController();
410113
410219
  this._taskEpoch = 1;
@@ -410405,6 +410511,9 @@ Respond with the assessment and take the selected evidence-backed action.`;
410405
410511
  this._abortController = new AbortController();
410406
410512
  this._turnAbortController = new AbortController();
410407
410513
  this._paused = false;
410514
+ this._inputWaitPaused = false;
410515
+ this._inputWaitBoundaryController = new AbortController();
410516
+ this._inputWaitModelControllers.clear();
410408
410517
  this._interruptionMessages = null;
410409
410518
  this._interruptionToolCallLog = null;
410410
410519
  this._taskProcedureExperience = null;
@@ -410784,7 +410893,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
410784
410893
  } catch {
410785
410894
  }
410786
410895
  this._loadResolutionMemory();
410787
- this._pauseResolve = null;
410896
+ this._pauseWaiters.clear();
410788
410897
  this._prepareSteeringInputsForRun();
410789
410898
  const persistentTaskGoal = cleanForStorage(actualUserGoal || "") || cleanedTask;
410790
410899
  const userGoal = persistentTaskGoal;
@@ -415709,6 +415818,7 @@ Then use file_read on individual FILES inside it.`);
415709
415818
  return boundExecuteSingle;
415710
415819
  };
415711
415820
  for (let turn = 0; turn < turnCap + durableProgressTurnCredits; turn++) {
415821
+ const inputWaitGeneration = this._modelRequestGeneration;
415712
415822
  if (this._completionIncompleteVerification)
415713
415823
  break;
415714
415824
  this._currentTurn = turn;
@@ -417403,9 +417513,21 @@ ${diagnosis}` : diagnosis;
417403
417513
  }
417404
417514
  }
417405
417515
  let response;
417516
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
417517
+ if (!await this.waitIfPaused())
417518
+ break;
417519
+ --turn;
417520
+ continue;
417521
+ }
417406
417522
  try {
417407
417523
  response = await this._dispatchCanonicalRequest(chatRequest, turn);
417408
417524
  } catch (reqErr) {
417525
+ if (reqErr instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
417526
+ if (!await this.waitIfPaused())
417527
+ break;
417528
+ --turn;
417529
+ continue;
417530
+ }
417409
417531
  if (isTerminalInferenceFailure(reqErr)) {
417410
417532
  nonRetryableBackendFailure = true;
417411
417533
  }
@@ -417460,6 +417582,12 @@ ${diagnosis}` : diagnosis;
417460
417582
  try {
417461
417583
  response = await this._dispatchCanonicalRequest(chatRequest, turn);
417462
417584
  } catch (retryErr) {
417585
+ if (retryErr instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
417586
+ if (!await this.waitIfPaused())
417587
+ break;
417588
+ --turn;
417589
+ continue;
417590
+ }
417463
417591
  if (isTerminalInferenceFailure(retryErr)) {
417464
417592
  nonRetryableBackendFailure = true;
417465
417593
  }
@@ -417485,6 +417613,12 @@ ${diagnosis}` : diagnosis;
417485
417613
  try {
417486
417614
  response = await this._dispatchCanonicalRequest(chatRequest, turn);
417487
417615
  } catch (retryErr) {
417616
+ if (retryErr instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
417617
+ if (!await this.waitIfPaused())
417618
+ break;
417619
+ --turn;
417620
+ continue;
417621
+ }
417488
417622
  if (isTerminalInferenceFailure(retryErr)) {
417489
417623
  nonRetryableBackendFailure = true;
417490
417624
  }
@@ -417509,6 +417643,12 @@ ${diagnosis}` : diagnosis;
417509
417643
  nonRetryableBackendFailure = true;
417510
417644
  reqErr = terminalError;
417511
417645
  });
417646
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
417647
+ if (!await this.waitIfPaused())
417648
+ break;
417649
+ --turn;
417650
+ continue;
417651
+ }
417512
417652
  if (!recovered2) {
417513
417653
  if (this.aborted)
417514
417654
  break;
@@ -417542,6 +417682,12 @@ ${diagnosis}` : diagnosis;
417542
417682
  const imgRetry = await this._dispatchCanonicalRequest(chatRequest, turn);
417543
417683
  response = imgRetry;
417544
417684
  } catch (imgRetryErr) {
417685
+ if (imgRetryErr instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
417686
+ if (!await this.waitIfPaused())
417687
+ break;
417688
+ --turn;
417689
+ continue;
417690
+ }
417545
417691
  if (isTerminalInferenceFailure(imgRetryErr)) {
417546
417692
  nonRetryableBackendFailure = true;
417547
417693
  }
@@ -417589,6 +417735,12 @@ ${diagnosis}` : diagnosis;
417589
417735
  response = await this._dispatchCanonicalRequest(chatRequest, turn, true, "json");
417590
417736
  imageRecovered = true;
417591
417737
  } catch (retryErr2) {
417738
+ if (retryErr2 instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
417739
+ if (!await this.waitIfPaused())
417740
+ break;
417741
+ --turn;
417742
+ continue;
417743
+ }
417592
417744
  if (isTerminalInferenceFailure(retryErr2)) {
417593
417745
  nonRetryableBackendFailure = true;
417594
417746
  }
@@ -417632,11 +417784,21 @@ ${transportFailure2}` : transportFailure2;
417632
417784
  response = recovered2 ?? response;
417633
417785
  }
417634
417786
  }
417787
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
417788
+ if (!await this.waitIfPaused())
417789
+ break;
417790
+ --turn;
417791
+ continue;
417792
+ }
417635
417793
  if (this._interruptionMode !== "off" && this._paused) {
417636
417794
  const shouldContinue = await this.waitIfPaused();
417637
417795
  if (!shouldContinue)
417638
417796
  break;
417639
417797
  }
417798
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
417799
+ --turn;
417800
+ continue;
417801
+ }
417640
417802
  this.flushPendingPausedStreamTerminal();
417641
417803
  this.flushPendingStreamAssistantText();
417642
417804
  totalTokens += response.usage?.totalTokens || (response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0) + (response.usage?.completionTokens ?? 0);
@@ -417980,7 +418142,10 @@ ${transportFailure2}` : transportFailure2;
417980
418142
  for (const sr of streamResults) {
417981
418143
  const resolvedStreamTool = this.lookupRegisteredTool(sr.name);
417982
418144
  const admittedFullRead = (resolvedStreamTool?.name ?? sr.name) === "file_read" && sr.result.success && !sr.result.branchEvidence;
417983
- if (!admittedFullRead) {
418145
+ const unread = this._currentUnreadWebSourceView(sr.id);
418146
+ const sourceCall = unread && rawToolCalls.find((call2) => call2.id === sr.id);
418147
+ const admittedWebSource = sr.result.success === true && unread && sourceCall && resolvedStreamTool?.tool === unread.tool && this._buildExactArgsKey(sourceCall.arguments) === unread.argsKey && (sr.result.llmContent ?? sr.result.output) === unread.carrier;
418148
+ if (!admittedFullRead && !admittedWebSource) {
417984
418149
  sr.result = this.applyRegisteredToolResultTriage(sr.result, resolvedStreamTool?.name ?? sr.name, resolvedStreamTool?.tool);
417985
418150
  }
417986
418151
  }
@@ -418710,6 +418875,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
418710
418875
  }
418711
418876
  const restartTurnCap = this.options.maxTurns && this.options.maxTurns > 0 ? this.options.maxTurns : Number.MAX_SAFE_INTEGER;
418712
418877
  for (let turn = 0; turn < restartTurnCap; turn++) {
418878
+ const inputWaitGeneration = this._modelRequestGeneration;
418713
418879
  if (this._completionIncompleteVerification)
418714
418880
  break;
418715
418881
  this._maybeApplyThinkGuard();
@@ -418880,9 +419046,21 @@ ${diagnosis}` : diagnosis;
418880
419046
  break;
418881
419047
  }
418882
419048
  let response;
419049
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
419050
+ if (!await this.waitIfPaused())
419051
+ break;
419052
+ --turn;
419053
+ continue;
419054
+ }
418883
419055
  try {
418884
419056
  response = await this._dispatchCanonicalRequest(chatRequest, turn);
418885
419057
  } catch (reqErr) {
419058
+ if (reqErr instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
419059
+ if (!await this.waitIfPaused())
419060
+ break;
419061
+ --turn;
419062
+ continue;
419063
+ }
418886
419064
  if (isTerminalInferenceFailure(reqErr)) {
418887
419065
  nonRetryableBackendFailure = true;
418888
419066
  }
@@ -418931,6 +419109,12 @@ ${diagnosis}` : diagnosis;
418931
419109
  try {
418932
419110
  response = await this._dispatchCanonicalRequest(chatRequest, turn);
418933
419111
  } catch (retryErr) {
419112
+ if (retryErr instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
419113
+ if (!await this.waitIfPaused())
419114
+ break;
419115
+ --turn;
419116
+ continue;
419117
+ }
418934
419118
  if (isTerminalInferenceFailure(retryErr)) {
418935
419119
  nonRetryableBackendFailure = true;
418936
419120
  }
@@ -418956,6 +419140,12 @@ ${diagnosis}` : diagnosis;
418956
419140
  try {
418957
419141
  response = await this._dispatchCanonicalRequest(chatRequest, turn);
418958
419142
  } catch (retryErr) {
419143
+ if (retryErr instanceof InputWaitInterruption || inputWaitGeneration !== this._modelRequestGeneration) {
419144
+ if (!await this.waitIfPaused())
419145
+ break;
419146
+ --turn;
419147
+ continue;
419148
+ }
418959
419149
  if (isTerminalInferenceFailure(retryErr)) {
418960
419150
  nonRetryableBackendFailure = true;
418961
419151
  }
@@ -418980,6 +419170,12 @@ ${diagnosis}` : diagnosis;
418980
419170
  nonRetryableBackendFailure = true;
418981
419171
  reqErr = terminalError;
418982
419172
  });
419173
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
419174
+ if (!await this.waitIfPaused())
419175
+ break;
419176
+ --turn;
419177
+ continue;
419178
+ }
418983
419179
  if (!recovered2) {
418984
419180
  if (this.aborted)
418985
419181
  break;
@@ -419006,11 +419202,21 @@ ${diagnosis}` : diagnosis;
419006
419202
  response = recovered2;
419007
419203
  }
419008
419204
  }
419205
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
419206
+ if (!await this.waitIfPaused())
419207
+ break;
419208
+ --turn;
419209
+ continue;
419210
+ }
419009
419211
  if (this._interruptionMode !== "off" && this._paused) {
419010
419212
  const shouldContinue = await this.waitIfPaused();
419011
419213
  if (!shouldContinue)
419012
419214
  break;
419013
419215
  }
419216
+ if (inputWaitGeneration !== this._modelRequestGeneration) {
419217
+ --turn;
419218
+ continue;
419219
+ }
419014
419220
  this.flushPendingPausedStreamTerminal();
419015
419221
  this.flushPendingStreamAssistantText();
419016
419222
  totalTokens += response.usage?.totalTokens || (response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0) + (response.usage?.completionTokens ?? 0);
@@ -426277,7 +426483,8 @@ ${description}`
426277
426483
  async waitForTransientRetry(delayMs) {
426278
426484
  const signals = [
426279
426485
  this._abortController.signal,
426280
- this._turnAbortController.signal
426486
+ this._turnAbortController.signal,
426487
+ this._inputWaitBoundaryController.signal
426281
426488
  ];
426282
426489
  if (signals.some((signal) => signal.aborted))
426283
426490
  return;
@@ -426301,7 +426508,8 @@ ${description}`
426301
426508
  });
426302
426509
  }
426303
426510
  async retryOnTransient(initialErr, chatRequest, turn, onTerminalFailure) {
426304
- if (this.aborted || this._pendingSteeringPreemption)
426511
+ const inputWaitGeneration = this._modelRequestGeneration;
426512
+ if (this.aborted || this._pendingSteeringPreemption || this._inputWaitPaused)
426305
426513
  return null;
426306
426514
  if (!this.isTransientError(initialErr))
426307
426515
  return null;
@@ -426328,7 +426536,7 @@ ${description}`
426328
426536
  const backend = this.backend;
426329
426537
  let attempt = 1;
426330
426538
  while (attempt <= (maxRetries === Infinity ? Number.MAX_SAFE_INTEGER : maxRetries)) {
426331
- if (this.aborted || this._pendingSteeringPreemption)
426539
+ if (this.aborted || this._pendingSteeringPreemption || this._inputWaitPaused || inputWaitGeneration !== this._modelRequestGeneration)
426332
426540
  return null;
426333
426541
  if (foregroundCanWait && isStalledBackend(currentErr)) {
426334
426542
  const stall = stallBudget.recordStall();
@@ -426420,7 +426628,7 @@ ${description}`
426420
426628
  });
426421
426629
  }
426422
426630
  await this.waitForTransientRetry(effectiveDelay);
426423
- if (this.aborted || this._pendingSteeringPreemption)
426631
+ if (this.aborted || this._pendingSteeringPreemption || this._inputWaitPaused || inputWaitGeneration !== this._modelRequestGeneration)
426424
426632
  return null;
426425
426633
  try {
426426
426634
  if (!isBrokerQueueDeadline) {
@@ -426514,6 +426722,7 @@ ${description}`
426514
426722
  }
426515
426723
  }
426516
426724
  for await (const chunk of backend.chatCompletionStream(request)) {
426725
+ request.signal?.throwIfAborted();
426517
426726
  if (this.aborted || this._pendingSteeringPreemption)
426518
426727
  break;
426519
426728
  if (chunk.type === "finish" && chunk.responseDiagnostics)
@@ -426671,6 +426880,7 @@ arguments=` : ""}` + (chunk.toolCallArgs ?? "");
426671
426880
  lastFinalizedIdx = idx;
426672
426881
  }
426673
426882
  }
426883
+ request.signal?.throwIfAborted();
426674
426884
  if (toolCallAccumulators.size > 0) {
426675
426885
  for (const [, acc] of toolCallAccumulators) {
426676
426886
  if (acc.name && !["completed", "failed", "yielded", "executing"].includes(this._streamingExecutor.getStates().get(acc.id) ?? "")) {
@@ -426993,7 +427203,6 @@ function computeEffectiveThink(params) {
426993
427203
  return params.defaultThink;
426994
427204
  }
426995
427205
  var _corpusExactCarrierProofs = /* @__PURE__ */ new WeakMap();
426996
- var _unreadWebSourceCarrierProofs = /* @__PURE__ */ new WeakMap();
426997
427206
  function sanitizeHistoryThink(messages2, options = {}) {
426998
427207
  const referencedToolCallIds = /* @__PURE__ */ new Set();
426999
427208
  for (const message of messages2) {
@@ -427002,8 +427211,7 @@ function sanitizeHistoryThink(messages2, options = {}) {
427002
427211
  }
427003
427212
  }
427004
427213
  const stripped = messages2.map((m) => {
427005
- const unread = _unreadWebSourceCarrierProofs.get(m);
427006
- if (unread && m.role === "tool" && m.tool_call_id === unread.callId && m.content === unread.content && m.requiredSourceEvidence?.schema === "omnius.required-source-evidence.v1" && m.requiredSourceEvidence.scope === `unread-web-source:${unread.callId}` && unread.current())
427214
+ if (isCurrentUnreadSourceCarrier(m))
427007
427215
  return m;
427008
427216
  const carrier = _corpusExactCarrierProofs.get(m);
427009
427217
  if (carrier && m.role === "tool" && m.tool_call_id === carrier.callId && m.content === carrier.content && m.requiredSourceEvidence?.schema === "omnius.required-source-evidence.v1" && m.requiredSourceEvidence.scope === `corpus-input:${carrier.callId}` && carrier.current())