omnius 1.0.892 → 1.0.893
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/assets/rea/LICENSE +21 -0
- package/assets/rea/UPSTREAM.json +43 -0
- package/assets/rea/skills/manifest.json +14 -0
- package/assets/rea/skills/omnius-rea/SKILL.md +61 -0
- package/assets/rea/skills/reverse-engineer-anything/SKILL.md +356 -0
- package/assets/rea/skills/reverse-engineer-anything/references/android-applications.md +36 -0
- package/assets/rea/skills/reverse-engineer-anything/references/connection-and-recovery.md +127 -0
- package/assets/rea/skills/reverse-engineer-anything/references/evidence-workflows.md +71 -0
- package/assets/rea/skills/reverse-engineer-anything/references/javascript-applications.md +218 -0
- package/assets/rea/skills/reverse-engineer-anything/references/native-and-artifacts.md +297 -0
- package/assets/rea/skills/reverse-engineer-anything/references/runtime-observation.md +78 -0
- package/dist/index.js +2 -2
- package/dist/library.js +727 -58
- package/dist/update-worker-runtime.js +463 -27
- package/dist/update-worker.js +3 -1
- package/docs/DISCOVERY.json +30 -0
- package/docs/DISCOVERY.md +1 -0
- package/docs/rea.md +39 -0
- package/npm-shrinkwrap.json +1345 -11
- package/package.json +3 -2
package/dist/library.js
CHANGED
|
@@ -82937,6 +82937,25 @@ function findBundledSkillsRoot(repoRoot) {
|
|
|
82937
82937
|
}
|
|
82938
82938
|
return null;
|
|
82939
82939
|
}
|
|
82940
|
+
function findBundledReaSkills(repoRoot) {
|
|
82941
|
+
const hasSkills = (root) => existsSync17(join20(root, "omnius-rea", "SKILL.md")) && existsSync17(join20(root, "reverse-engineer-anything", "SKILL.md"));
|
|
82942
|
+
const explicit = process.env["OMNIUS_REA_SKILLS_ROOT"];
|
|
82943
|
+
if (explicit)
|
|
82944
|
+
return hasSkills(explicit) ? explicit : null;
|
|
82945
|
+
const candidates = [
|
|
82946
|
+
join20(repoRoot, "packages", "cli", "assets", "rea", "skills"),
|
|
82947
|
+
join20(repoRoot, "assets", "rea", "skills")
|
|
82948
|
+
];
|
|
82949
|
+
let current2 = dirname9(fileURLToPath3(import.meta.url));
|
|
82950
|
+
for (let depth = 0; depth < 10; depth++) {
|
|
82951
|
+
candidates.push(join20(current2, "assets", "rea", "skills"), join20(current2, "packages", "cli", "assets", "rea", "skills"));
|
|
82952
|
+
const parent = dirname9(current2);
|
|
82953
|
+
if (parent === current2)
|
|
82954
|
+
break;
|
|
82955
|
+
current2 = parent;
|
|
82956
|
+
}
|
|
82957
|
+
return candidates.find(hasSkills) ?? null;
|
|
82958
|
+
}
|
|
82940
82959
|
function discoverSkills(repoRoot) {
|
|
82941
82960
|
const skills = /* @__PURE__ */ new Map();
|
|
82942
82961
|
const { frameworksDir, addonsDir, pluginsDir } = getAiwgPaths();
|
|
@@ -82989,6 +83008,9 @@ function discoverSkills(repoRoot) {
|
|
|
82989
83008
|
loadComponent(join20(bundledAddons, addon), `bundled-addon:${addon}`);
|
|
82990
83009
|
}
|
|
82991
83010
|
}
|
|
83011
|
+
const reaSkills = findBundledReaSkills(repoRoot);
|
|
83012
|
+
if (reaSkills)
|
|
83013
|
+
loadSkillsFromDir(reaSkills, "bundled-rea", skills);
|
|
82992
83014
|
const projectAiwg = join20(repoRoot, ".aiwg");
|
|
82993
83015
|
loadSkillsFromDir(join20(projectAiwg, "skills"), "project", skills);
|
|
82994
83016
|
loadCommandsFromDir(join20(projectAiwg, "commands"), "project", skills);
|
|
@@ -352559,6 +352581,141 @@ function findBetterToolSchemaMatches(input) {
|
|
|
352559
352581
|
return [...matches].sort(([left, leftScore], [right, rightScore]) => rightScore - leftScore || left.localeCompare(right)).slice(0, 3).map(([name]) => name);
|
|
352560
352582
|
}
|
|
352561
352583
|
|
|
352584
|
+
// packages/orchestrator/dist/forced-update-requirement-recovery.js
|
|
352585
|
+
function reconcileForcedUpdateReadOnlyOperations(ledger, interruption) {
|
|
352586
|
+
if (!ledger.workPlan || ledger.runId !== interruption.runId || ledger.taskEpoch !== interruption.taskEpoch)
|
|
352587
|
+
return ledger;
|
|
352588
|
+
const retired = new Set(interruption.pendingAcknowledgements.filter((ack) => ack.status === "timed_out" && ack.effect === "read_only" && ack.generation < interruption.owner.generation).map((ack) => ack.id));
|
|
352589
|
+
if (!ledger.workPlan.units.some((unit) => unit.pendingOperationRef && retired.has(unit.pendingOperationRef)))
|
|
352590
|
+
return ledger;
|
|
352591
|
+
const next = structuredClone(ledger);
|
|
352592
|
+
for (const unit of next.workPlan.units)
|
|
352593
|
+
if (unit.pendingOperationRef && retired.has(unit.pendingOperationRef)) {
|
|
352594
|
+
delete unit.pendingOperationRef;
|
|
352595
|
+
if (unit.attemptState === "running")
|
|
352596
|
+
unit.attemptState = "selected";
|
|
352597
|
+
}
|
|
352598
|
+
next.workPlan.revision++;
|
|
352599
|
+
return next;
|
|
352600
|
+
}
|
|
352601
|
+
function applyForcedUpdateRequirementRecovery(recovery, receipt) {
|
|
352602
|
+
return reduceRecovery(recovery, receipt, true, 0);
|
|
352603
|
+
}
|
|
352604
|
+
function projectForcedUpdateRequirementRecoveryPrefix(recovery, receipt) {
|
|
352605
|
+
return reduceRecovery(recovery, receipt, false, 0);
|
|
352606
|
+
}
|
|
352607
|
+
function reduceRecovery(recovery, receipt, complete, depth) {
|
|
352608
|
+
const reject = () => {
|
|
352609
|
+
throw new Error("forced_update_requirement_recovery_receipt_invalid");
|
|
352610
|
+
};
|
|
352611
|
+
if (depth > 32 || !receipt || receipt.schema !== "omnius.forced-update-requirement-recovery-receipt.v1" || ["checkpointSha256", "runId", "sessionId", "taskEpoch", "ownerGeneration"].some((key) => receipt[key] !== recovery[key]) || !Array.isArray(receipt.resolutions))
|
|
352612
|
+
reject();
|
|
352613
|
+
const expected = new Map(recovery.requirementHolds.map((hold2) => [hold2.inputId, hold2.nativeInputSha256]));
|
|
352614
|
+
for (const authority of recovery.requirementAmendments) {
|
|
352615
|
+
if (expected.has(authority.inputId) && expected.get(authority.inputId) !== authority.scope.nativeInputSha256)
|
|
352616
|
+
reject();
|
|
352617
|
+
expected.set(authority.inputId, authority.scope.nativeInputSha256);
|
|
352618
|
+
}
|
|
352619
|
+
let completionLedger = restoreCompletionLedgerSnapshot(recovery.completionLedger);
|
|
352620
|
+
let nativeScope = structuredClone(recovery.nativeScope), expectedOutcome = structuredClone(recovery.expectedOutcome);
|
|
352621
|
+
let recoveredSteering = structuredClone(recovery.steering);
|
|
352622
|
+
const resolvedInputIds = [], replacementInputs = [], responseInputs = [];
|
|
352623
|
+
if (receipt.predecessor) {
|
|
352624
|
+
const prior = receipt.predecessor.recovery;
|
|
352625
|
+
const base = (ledger) => {
|
|
352626
|
+
const { updatedAtIso: _clock, ...facts } = restoreCompletionLedgerSnapshot(ledger);
|
|
352627
|
+
return taskExecutionDigest(facts);
|
|
352628
|
+
};
|
|
352629
|
+
if (!prior || prior.runId !== recovery.runId || prior.sessionId !== recovery.sessionId || prior.taskEpoch !== recovery.taskEpoch || prior.ownerGeneration >= recovery.ownerGeneration || base(prior.completionLedger) !== base(recovery.completionLedger) || taskExecutionDigest(prior.nativeScope) !== taskExecutionDigest(recovery.nativeScope) || taskExecutionDigest(prior.expectedOutcome) !== taskExecutionDigest(recovery.expectedOutcome) || prior.steering.some((input) => !recovery.steering.some((current2) => taskExecutionDigest(current2) === taskExecutionDigest(input))))
|
|
352630
|
+
reject();
|
|
352631
|
+
const projected = reduceRecovery(prior, receipt.predecessor.receipt, true, depth + 1);
|
|
352632
|
+
const priorHashes = new Map([
|
|
352633
|
+
...prior.requirementHolds.map((hold2) => [hold2.inputId, hold2.nativeInputSha256]),
|
|
352634
|
+
...prior.requirementAmendments.map((authority) => [authority.inputId, authority.scope.nativeInputSha256])
|
|
352635
|
+
]);
|
|
352636
|
+
for (const inputId of projected.resolvedInputIds) {
|
|
352637
|
+
if (!expected.has(inputId) || expected.get(inputId) !== priorHashes.get(inputId))
|
|
352638
|
+
reject();
|
|
352639
|
+
expected.delete(inputId);
|
|
352640
|
+
resolvedInputIds.push(inputId);
|
|
352641
|
+
}
|
|
352642
|
+
completionLedger = projected.completionLedger;
|
|
352643
|
+
nativeScope = projected.nativeScope;
|
|
352644
|
+
expectedOutcome = projected.expectedOutcome;
|
|
352645
|
+
recoveredSteering = projected.recoveredSteering;
|
|
352646
|
+
for (const input of recovery.steering)
|
|
352647
|
+
if (!recoveredSteering.some((current2) => current2.inputId === input.inputId))
|
|
352648
|
+
recoveredSteering.push(structuredClone(input));
|
|
352649
|
+
replacementInputs.push(...projected.replacementInputs);
|
|
352650
|
+
responseInputs.push(...projected.responseInputs);
|
|
352651
|
+
}
|
|
352652
|
+
if ((complete ? receipt.resolutions.length !== expected.size : receipt.resolutions.length > expected.size) || new Set(receipt.resolutions.map((result) => result?.inputId)).size !== receipt.resolutions.length)
|
|
352653
|
+
reject();
|
|
352654
|
+
for (const result of receipt.resolutions) {
|
|
352655
|
+
if (!result || !expected.has(result.inputId) || expected.get(result.inputId) !== result.nativeInputSha256)
|
|
352656
|
+
reject();
|
|
352657
|
+
let steering = recoveredSteering.find((input) => input.inputId === result.inputId && input.source === "telegram" && input.taskEpoch === recovery.taskEpoch);
|
|
352658
|
+
if (!steering && result.steering) {
|
|
352659
|
+
const supplied = result.steering;
|
|
352660
|
+
if (supplied.inputId !== result.inputId || supplied.source !== "telegram" || supplied.taskEpoch !== recovery.taskEpoch || !["queued", "acknowledged"].includes(supplied.state) || typeof supplied.content !== "string" || !supplied.content.trim() || !["append", "clarify", "context_only", "constraint", "priority_change", ...result.disposition === "replacement" ? ["replace", "redirect"] : []].includes(supplied.intent) || typeof supplied.receivedAt !== "string" || !Number.isFinite(Date.parse(supplied.receivedAt)))
|
|
352661
|
+
reject();
|
|
352662
|
+
steering = structuredClone(supplied);
|
|
352663
|
+
recoveredSteering.push(steering);
|
|
352664
|
+
}
|
|
352665
|
+
if (!steering)
|
|
352666
|
+
reject();
|
|
352667
|
+
if (result.disposition === "amendment") {
|
|
352668
|
+
if (!result.authority || result.authority.inputId !== result.inputId || result.authority.scope.nativeInputSha256 !== result.nativeInputSha256)
|
|
352669
|
+
reject();
|
|
352670
|
+
const authority = structuredClone(result.authority), plan = completionLedger.workPlan;
|
|
352671
|
+
if (plan) {
|
|
352672
|
+
authority.nextWorkPlan.revision = plan.revision + 1;
|
|
352673
|
+
for (const unit of authority.nextWorkPlan.units) {
|
|
352674
|
+
const prior = plan.units.find((current2) => current2.id === unit.id);
|
|
352675
|
+
if (!prior)
|
|
352676
|
+
continue;
|
|
352677
|
+
unit.outcomeEvidenceIds = [.../* @__PURE__ */ new Set([...unit.outcomeEvidenceIds, ...prior.outcomeEvidenceIds])];
|
|
352678
|
+
if (prior.pendingOperationRef)
|
|
352679
|
+
unit.pendingOperationRef = prior.pendingOperationRef;
|
|
352680
|
+
else
|
|
352681
|
+
delete unit.pendingOperationRef;
|
|
352682
|
+
}
|
|
352683
|
+
}
|
|
352684
|
+
completionLedger = applyNativeTaskRequirementAmendmentV1({
|
|
352685
|
+
ledger: completionLedger,
|
|
352686
|
+
priorExpectedOutcome: expectedOutcome,
|
|
352687
|
+
priorScope: nativeScope,
|
|
352688
|
+
amendment: authority,
|
|
352689
|
+
steering
|
|
352690
|
+
});
|
|
352691
|
+
nativeScope = authority.scope;
|
|
352692
|
+
expectedOutcome = authority.nextExpectedOutcome;
|
|
352693
|
+
} else {
|
|
352694
|
+
const proof = result.review;
|
|
352695
|
+
if (!["unchanged", "context", "no_action", "cancelled", "replacement", "response"].includes(result.disposition) || !proof || !/^[a-f0-9]{64}$/.test(proof.requestSha256) || !/^[a-f0-9]{64}$/.test(proof.resultSha256) || typeof proof.model !== "string" || !proof.model.trim() || typeof proof.providerProtocol !== "string" || !proof.providerProtocol.trim())
|
|
352696
|
+
reject();
|
|
352697
|
+
if (result.disposition === "cancelled")
|
|
352698
|
+
steering.state = "cancelled";
|
|
352699
|
+
else if (result.disposition === "context" || result.disposition === "no_action")
|
|
352700
|
+
steering.state = "consumed";
|
|
352701
|
+
else if (result.disposition === "replacement" || result.disposition === "response") {
|
|
352702
|
+
if (result.disposition === "replacement" && steering.allowTaskReplacement === false || !result.decisionPayload || typeof result.decisionPayload !== "object" || Array.isArray(result.decisionPayload) || taskExecutionDigest(result.decisionPayload) !== result.decisionPayloadSha256)
|
|
352703
|
+
reject();
|
|
352704
|
+
if (result.disposition === "replacement") {
|
|
352705
|
+
steering.state = "cancelled";
|
|
352706
|
+
replacementInputs.push(structuredClone(result));
|
|
352707
|
+
} else {
|
|
352708
|
+
steering.state = "consumed";
|
|
352709
|
+
responseInputs.push(structuredClone(result));
|
|
352710
|
+
}
|
|
352711
|
+
}
|
|
352712
|
+
}
|
|
352713
|
+
expected.delete(result.inputId);
|
|
352714
|
+
resolvedInputIds.push(result.inputId);
|
|
352715
|
+
}
|
|
352716
|
+
return { completionLedger, nativeScope, expectedOutcome, recoveredSteering, resolvedInputIds, replacementInputs, responseInputs };
|
|
352717
|
+
}
|
|
352718
|
+
|
|
352562
352719
|
// packages/orchestrator/dist/adjudication.js
|
|
352563
352720
|
import { z as z18 } from "zod";
|
|
352564
352721
|
var ADJUDICATION_TOOL_NAME = "adjudicate";
|
|
@@ -358353,7 +358510,7 @@ function isSnapshot(value) {
|
|
|
358353
358510
|
const owner = record9["owner"];
|
|
358354
358511
|
const acknowledgements = pending;
|
|
358355
358512
|
const acknowledgementById = new Map(acknowledgements.map((entry) => [entry.id, entry]));
|
|
358356
|
-
if (acknowledgements.some((entry) => entry.generation
|
|
358513
|
+
if (acknowledgements.some((entry) => entry.generation > owner.generation || entry.generation < owner.generation && entry.status === "pending")) {
|
|
358357
358514
|
return false;
|
|
358358
358515
|
}
|
|
358359
358516
|
const phase = record9["phase"];
|
|
@@ -358424,6 +358581,16 @@ var InterruptionLifecycle = class {
|
|
|
358424
358581
|
snapshot() {
|
|
358425
358582
|
return cloneSnapshot(this.state);
|
|
358426
358583
|
}
|
|
358584
|
+
/** A retired instance may retry a failed checkpoint only while its exact
|
|
358585
|
+
* durable owner boundary still exists. Never reopen or rewrite a successor. */
|
|
358586
|
+
isCurrentDurableBoundary() {
|
|
358587
|
+
if (this.durabilityUncertain)
|
|
358588
|
+
return false;
|
|
358589
|
+
if (!this.persistEnabled || !this.statePath)
|
|
358590
|
+
return true;
|
|
358591
|
+
const saved = this.load();
|
|
358592
|
+
return !!saved && saved.runId === this.state.runId && saved.sessionId === this.state.sessionId && saved.taskEpoch === this.state.taskEpoch && saved.sequence === this.state.sequence && saved.phase === this.state.phase && JSON.stringify(saved.owner) === JSON.stringify(this.state.owner);
|
|
358593
|
+
}
|
|
358427
358594
|
/** A post-rename durability failure closes admission until process recovery. */
|
|
358428
358595
|
get requiresDurabilityRecovery() {
|
|
358429
358596
|
return this.durabilityUncertain;
|
|
@@ -358529,6 +358696,32 @@ var InterruptionLifecycle = class {
|
|
|
358529
358696
|
this.transition("paused", this.state.requestedBy, reason, true);
|
|
358530
358697
|
return this.receipt("pause_acknowledged", true, false, previous, reason);
|
|
358531
358698
|
}
|
|
358699
|
+
/** Explicit owner handoff, never an acknowledgement of unfinished work. */
|
|
358700
|
+
forcePauseForUpdate(requestedBy, reason = "explicit update retired unfinished owners") {
|
|
358701
|
+
const previous = this.state.phase;
|
|
358702
|
+
if (!["running", "pausing", "paused"].includes(previous) || !this.ownerMatches(requestedBy))
|
|
358703
|
+
return this.receipt("pause_acknowledged", false, false, previous, "Update handoff rejected for a stale owner or terminal run.");
|
|
358704
|
+
this.assertDurabilityCertain();
|
|
358705
|
+
const before = cloneSnapshot(this.state);
|
|
358706
|
+
try {
|
|
358707
|
+
const at = this.timestamp();
|
|
358708
|
+
for (const acknowledgement of this.state.pendingAcknowledgements) {
|
|
358709
|
+
if (acknowledgement.status !== "pending")
|
|
358710
|
+
continue;
|
|
358711
|
+
acknowledgement.status = "timed_out";
|
|
358712
|
+
acknowledgement.acknowledgedAt = at;
|
|
358713
|
+
if (acknowledgement.effect === "external_effect")
|
|
358714
|
+
this.recordAmbiguity(acknowledgement, at);
|
|
358715
|
+
}
|
|
358716
|
+
this.state.owner = { ...this.state.owner, generation: this.state.owner.generation + 1 };
|
|
358717
|
+
this.transition("paused", this.state.owner, reason, true);
|
|
358718
|
+
} catch (error) {
|
|
358719
|
+
if (!persistenceMayHaveCommitted(error))
|
|
358720
|
+
this.state = before;
|
|
358721
|
+
throw error;
|
|
358722
|
+
}
|
|
358723
|
+
return this.receipt("pause_acknowledged", true, false, previous, reason);
|
|
358724
|
+
}
|
|
358532
358725
|
requestResume(requestedBy, reason = "resume requested") {
|
|
358533
358726
|
const previous = this.state.phase;
|
|
358534
358727
|
if (previous === "running" || previous === "resuming") {
|
|
@@ -388556,6 +388749,15 @@ var AgenticRunner = class _AgenticRunner {
|
|
|
388556
388749
|
_inputWaitSequence = 0;
|
|
388557
388750
|
_inputWaitPauseReceipt = null;
|
|
388558
388751
|
_inputWaitBoundaryController = new AbortController();
|
|
388752
|
+
_updateAbortController = new AbortController();
|
|
388753
|
+
_updateRestartCheckpointForced = false;
|
|
388754
|
+
_updateRestartOwnerRevoked = false;
|
|
388755
|
+
_updateRestartCheckpointSaved = false;
|
|
388756
|
+
_updateCheckpointWriteAuthorized = false;
|
|
388757
|
+
_forcedUpdateRequirementRecoveryHandler;
|
|
388758
|
+
_forcedUpdateRequirementRecoveryApplied;
|
|
388759
|
+
_forcedUpdateRequirementRecoveryPending;
|
|
388760
|
+
_forcedUpdateRequirementTaskReplaced = false;
|
|
388559
388761
|
_interruptionMessages = null;
|
|
388560
388762
|
_interruptionToolCallLog = null;
|
|
388561
388763
|
_interruptionExplicitGoal = "";
|
|
@@ -394838,7 +395040,7 @@ ${read.content}`;
|
|
|
394838
395040
|
const kind = admittedMediaEvidenceRead ? "read_tool" : this.interruptionToolKind(tool, readOnly);
|
|
394839
395041
|
const ticket = this._interruptionLifecycle?.registerOperation({
|
|
394840
395042
|
kind,
|
|
394841
|
-
effect: readOnly ? "read_only" : "external_effect",
|
|
395043
|
+
effect: tool.interruptionEffect ?? (readOnly ? "read_only" : "external_effect"),
|
|
394842
395044
|
ownerId: `tool:${name}`
|
|
394843
395045
|
});
|
|
394844
395046
|
if (this._interruptionLifecycle && !ticket) {
|
|
@@ -394878,10 +395080,18 @@ ${read.content}`;
|
|
|
394878
395080
|
let workflowTicket;
|
|
394879
395081
|
let uiInvocationActive = false;
|
|
394880
395082
|
const desktopScope = this._objectiveRecoveryScope(), desktopController = this._turnAbortController;
|
|
395083
|
+
const cognitionSignal = ticket?.effect === "read_only" && ticket.kind === "background_cognition" ? this._inputWaitBoundaryController.signal : void 0;
|
|
394881
395084
|
try {
|
|
394882
395085
|
const corpusReadAllocation = this._allocateCorpusRead(tool, name, args);
|
|
394883
395086
|
let invocation = tool.acceptsInvocationContext === true ? {
|
|
394884
|
-
signal: this._turnAbortController.signal,
|
|
395087
|
+
signal: AbortSignal.any([this._turnAbortController.signal, this._updateAbortController.signal, ...cognitionSignal ? [cognitionSignal] : []]),
|
|
395088
|
+
assertCurrent: () => {
|
|
395089
|
+
if (cognitionSignal?.aborted)
|
|
395090
|
+
throw new InputWaitInterruption();
|
|
395091
|
+
if (this._updateRestartCheckpointForced || ticket && !this._interruptionLifecycle?.canCommit(ticket))
|
|
395092
|
+
throw new InputWaitInterruption();
|
|
395093
|
+
assertDispatchScope?.();
|
|
395094
|
+
},
|
|
394885
395095
|
...corpusReadAllocation ? { corpusReadAllocation } : {},
|
|
394886
395096
|
...objectiveEffectIntent ? { objectiveEffectIntent } : {},
|
|
394887
395097
|
elevationPolicy: {
|
|
@@ -394900,7 +395110,14 @@ ${read.content}`;
|
|
|
394900
395110
|
if (workflowAdmission && ticket && this._featureWorkflow) {
|
|
394901
395111
|
workflowTicket = this._featureWorkflow.admit(workflowAdmission, ticket, name, args);
|
|
394902
395112
|
invocation = {
|
|
394903
|
-
signal: this._turnAbortController.signal,
|
|
395113
|
+
signal: AbortSignal.any([this._turnAbortController.signal, this._updateAbortController.signal, ...cognitionSignal ? [cognitionSignal] : []]),
|
|
395114
|
+
assertCurrent: () => {
|
|
395115
|
+
if (cognitionSignal?.aborted)
|
|
395116
|
+
throw new InputWaitInterruption();
|
|
395117
|
+
if (this._updateRestartCheckpointForced || ticket && !this._interruptionLifecycle?.canCommit(ticket))
|
|
395118
|
+
throw new InputWaitInterruption();
|
|
395119
|
+
assertDispatchScope?.();
|
|
395120
|
+
},
|
|
394904
395121
|
...objectiveEffectIntent ? { objectiveEffectIntent } : {},
|
|
394905
395122
|
elevationPolicy: {
|
|
394906
395123
|
mode: this.options.surface === "tui" ? "native" : "deny",
|
|
@@ -394970,12 +395187,18 @@ ${read.content}`;
|
|
|
394970
395187
|
};
|
|
394971
395188
|
} finally {
|
|
394972
395189
|
uiInvocationActive = false;
|
|
394973
|
-
if (ticket) {
|
|
394974
|
-
this.
|
|
395190
|
+
if (ticket && !this._updateRestartCheckpointForced) {
|
|
395191
|
+
const unknown = this.aborted || this._updateAbortController.signal.aborted && ticket.effect === "external_effect";
|
|
395192
|
+
this._interruptionLifecycle?.acknowledgeOperation(ticket, unknown ? "unknown" : "completed");
|
|
394975
395193
|
if (!progressOnly)
|
|
394976
|
-
this._transitionTaskWorkOperation(ticket.id,
|
|
395194
|
+
this._transitionTaskWorkOperation(ticket.id, unknown ? "unknown" : "settled");
|
|
394977
395195
|
}
|
|
394978
395196
|
}
|
|
395197
|
+
if (this._updateRestartCheckpointForced) {
|
|
395198
|
+
if (!this.aborted)
|
|
395199
|
+
await new Promise((resolve42) => this._pauseWaiters.add(resolve42));
|
|
395200
|
+
throw new InputWaitInterruption();
|
|
395201
|
+
}
|
|
394979
395202
|
if (pendingObjectiveEffect && !normalizeExternalEffectReceiptV1(result.externalEffectReceipt)) {
|
|
394980
395203
|
result = {
|
|
394981
395204
|
...result,
|
|
@@ -396679,6 +396902,8 @@ Use exact start_char/end_char or start_line/end_line ranges, or query/resume_sou
|
|
|
396679
396902
|
}
|
|
396680
396903
|
}
|
|
396681
396904
|
_saveCompletionLedgerSafe() {
|
|
396905
|
+
if (this._updateRestartCheckpointForced && !this._updateCheckpointWriteAuthorized)
|
|
396906
|
+
return false;
|
|
396682
396907
|
if (!this._completionLedger)
|
|
396683
396908
|
return true;
|
|
396684
396909
|
if (!this.writesUserTaskArtifacts() && !this._completionLedger.objectiveContract)
|
|
@@ -396951,7 +397176,7 @@ ${content}`)].join("\n\n");
|
|
|
396951
397176
|
}
|
|
396952
397177
|
_currentSteeringReplyPending() {
|
|
396953
397178
|
const pending = this._pendingSteeringReply;
|
|
396954
|
-
return pending && pending.runId === this.currentArtifactRunId() && pending.ownerId === this._interruptionOwnerId && pending.input.taskEpoch === this._taskEpoch && !["cancelled", "superseded", "consumed"].includes(pending.input.state) ? pending : null;
|
|
397179
|
+
return pending && pending.runId === this.currentArtifactRunId() && pending.ownerId === this._interruptionOwnerId && pending.input.taskEpoch === this._taskEpoch && !pending.input.humanResponse && !["cancelled", "superseded", "consumed"].includes(pending.input.state) ? pending : null;
|
|
396955
397180
|
}
|
|
396956
397181
|
_adjudicationArgumentRepairIsCurrent(repair) {
|
|
396957
397182
|
const tool = this.lookupRegisteredTool(ADJUDICATION_TOOL_NAME)?.tool;
|
|
@@ -398066,49 +398291,59 @@ ${currentIntent.trim().slice(0, 6e3)}`,
|
|
|
398066
398291
|
const b = this.backend;
|
|
398067
398292
|
return {
|
|
398068
398293
|
chatCompletion: async (req) => {
|
|
398069
|
-
const
|
|
398070
|
-
|
|
398071
|
-
|
|
398072
|
-
|
|
398073
|
-
|
|
398074
|
-
|
|
398075
|
-
|
|
398076
|
-
|
|
398077
|
-
|
|
398078
|
-
|
|
398079
|
-
|
|
398080
|
-
|
|
398081
|
-
|
|
398082
|
-
|
|
398083
|
-
|
|
398084
|
-
|
|
398085
|
-
|
|
398086
|
-
|
|
398087
|
-
|
|
398088
|
-
|
|
398089
|
-
|
|
398090
|
-
|
|
398091
|
-
explicitMaxOutputTokens: explicitAuxiliaryCap
|
|
398092
|
-
});
|
|
398093
|
-
else
|
|
398094
|
-
r.minimumOutputReservation = priorFloor;
|
|
398095
|
-
}
|
|
398096
|
-
if (allocated.maxTokens <= 0)
|
|
398097
|
-
throw Object.assign(new Error("auxiliary_output_capacity_unavailable"), { code: "context_admission_failed" });
|
|
398098
|
-
r.maxTokens = allocated.maxTokens;
|
|
398099
|
-
if (!opts?.suppressContextDump) {
|
|
398100
|
-
recordContextWindowDump({
|
|
398101
|
-
source: "agenticRunner",
|
|
398102
|
-
stage: opts?.dumpStage ?? "aux_inference",
|
|
398103
|
-
agentType: "internal",
|
|
398104
|
-
sessionId: this._sessionId,
|
|
398105
|
-
runId: this._workboardRunId(),
|
|
398106
|
-
model: this._backendModelLabel(this.backend),
|
|
398107
|
-
cwd: this._workingDirectory || process.cwd(),
|
|
398108
|
-
request: r
|
|
398294
|
+
const signal = AbortSignal.any([
|
|
398295
|
+
this._abortController.signal,
|
|
398296
|
+
this._turnAbortController.signal,
|
|
398297
|
+
this._inputWaitBoundaryController.signal,
|
|
398298
|
+
this._updateAbortController.signal,
|
|
398299
|
+
...req.signal ? [req.signal] : []
|
|
398300
|
+
]);
|
|
398301
|
+
return withInputWaitCancellation(signal, async () => {
|
|
398302
|
+
const r = {
|
|
398303
|
+
...req,
|
|
398304
|
+
signal,
|
|
398305
|
+
responseFormat: req.responseFormat ?? { type: "json_object" }
|
|
398306
|
+
};
|
|
398307
|
+
const explicitAuxiliaryCap = this._explicitGenerationMaxTokens || this.options.maxTokens !== 16384 ? this._generationOutputCeiling() : void 0;
|
|
398308
|
+
const desired = auxiliaryOutputBudget({
|
|
398309
|
+
request: r,
|
|
398310
|
+
explicitMaxOutputTokens: explicitAuxiliaryCap
|
|
398311
|
+
}).maxTokens;
|
|
398312
|
+
let allocated = auxiliaryOutputBudget({
|
|
398313
|
+
request: r,
|
|
398314
|
+
contextWindowTokens: this._contextAdmissionLimit(r).limit,
|
|
398315
|
+
explicitMaxOutputTokens: this._explicitGenerationMaxTokens || this.options.maxTokens !== 16384 ? this._generationOutputCeiling() : void 0
|
|
398109
398316
|
});
|
|
398110
|
-
|
|
398111
|
-
|
|
398317
|
+
if (allocated.maxTokens < desired && b.prepareContextCapacity) {
|
|
398318
|
+
const priorFloor = r.minimumOutputReservation;
|
|
398319
|
+
r.maxTokens = desired;
|
|
398320
|
+
r.minimumOutputReservation = Math.min(4096, desired);
|
|
398321
|
+
if (await this._prepareRequestContextCapacity(r, b, opts?.assertCurrent))
|
|
398322
|
+
allocated = auxiliaryOutputBudget({
|
|
398323
|
+
request: r,
|
|
398324
|
+
contextWindowTokens: this._contextAdmissionLimit(r).limit,
|
|
398325
|
+
explicitMaxOutputTokens: explicitAuxiliaryCap
|
|
398326
|
+
});
|
|
398327
|
+
else
|
|
398328
|
+
r.minimumOutputReservation = priorFloor;
|
|
398329
|
+
}
|
|
398330
|
+
if (allocated.maxTokens <= 0)
|
|
398331
|
+
throw Object.assign(new Error("auxiliary_output_capacity_unavailable"), { code: "context_admission_failed" });
|
|
398332
|
+
r.maxTokens = allocated.maxTokens;
|
|
398333
|
+
if (!opts?.suppressContextDump) {
|
|
398334
|
+
recordContextWindowDump({
|
|
398335
|
+
source: "agenticRunner",
|
|
398336
|
+
stage: opts?.dumpStage ?? "aux_inference",
|
|
398337
|
+
agentType: "internal",
|
|
398338
|
+
sessionId: this._sessionId,
|
|
398339
|
+
runId: this._workboardRunId(),
|
|
398340
|
+
model: this._backendModelLabel(this.backend),
|
|
398341
|
+
cwd: this._workingDirectory || process.cwd(),
|
|
398342
|
+
request: r
|
|
398343
|
+
});
|
|
398344
|
+
}
|
|
398345
|
+
return this._dispatchInterruptionOwnedModelRequest(b, r, `model:aux:${opts?.dumpStage ?? "aux_inference"}`, { assertCurrent: opts?.assertCurrent, signal: r.signal });
|
|
398346
|
+
});
|
|
398112
398347
|
}
|
|
398113
398348
|
};
|
|
398114
398349
|
}
|
|
@@ -406701,6 +406936,8 @@ ${notice}`;
|
|
|
406701
406936
|
* active turn, which closes the old bridge-to-runner message-loss race.
|
|
406702
406937
|
*/
|
|
406703
406938
|
injectSteeringInput(input) {
|
|
406939
|
+
if (this._updateRestartCheckpointForced)
|
|
406940
|
+
throw new Error("This runner was retired for update; retain input for the replacement process.");
|
|
406704
406941
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
406705
406942
|
const content = this.scrubUserInput(input.content, "steering-input").trim();
|
|
406706
406943
|
const record9 = {
|
|
@@ -406713,6 +406950,7 @@ ${notice}`;
|
|
|
406713
406950
|
state: "received",
|
|
406714
406951
|
taskEpoch: input.taskEpoch ?? (this._taskEpoch || void 0)
|
|
406715
406952
|
};
|
|
406953
|
+
delete record9.humanResponse;
|
|
406716
406954
|
this.pendingSteeringInputs.push(record9);
|
|
406717
406955
|
this._emitSteeringLifecycle(record9, "received by runner");
|
|
406718
406956
|
if (!content || record9.allowTaskReplacement === false && (record9.intent === "replace" || record9.intent === "redirect")) {
|
|
@@ -406746,6 +406984,73 @@ ${notice}`;
|
|
|
406746
406984
|
projection.controller.abort(new InputWaitInterruption());
|
|
406747
406985
|
return this._steeringReceipt(record9);
|
|
406748
406986
|
}
|
|
406987
|
+
/** A small communication snapshot, independent of atomic tool completion.
|
|
406988
|
+
* The full input remains in the ordinary steering and reconciliation path. */
|
|
406989
|
+
captureSteeringReply(inputId) {
|
|
406990
|
+
const pending = this._currentSteeringReplyPending();
|
|
406991
|
+
if (!pending || pending.input.inputId !== inputId || this.aborted || this._updateAbortController.signal.aborted)
|
|
406992
|
+
return null;
|
|
406993
|
+
const state = this.interruptionState;
|
|
406994
|
+
if (state && ["stopping", "stopped", "failed", "completed"].includes(state.phase))
|
|
406995
|
+
return null;
|
|
406996
|
+
const input = pending.input;
|
|
406997
|
+
const excerpt = (text13, limit2) => {
|
|
406998
|
+
if (Buffer.byteLength(text13, "utf8") <= limit2)
|
|
406999
|
+
return text13;
|
|
407000
|
+
let size = Math.max(1, limit2 - 100), result;
|
|
407001
|
+
do {
|
|
407002
|
+
result = `${text13.slice(0, Math.floor(size * 0.7))}
|
|
407003
|
+
[Excerpt; remaining text is retained for the main task.]
|
|
407004
|
+
${text13.slice(-Math.max(1, Math.floor(size * 0.3)))}`;
|
|
407005
|
+
size = Math.floor(size * 0.7);
|
|
407006
|
+
} while (size > 0 && Buffer.byteLength(result, "utf8") > limit2);
|
|
407007
|
+
return result;
|
|
407008
|
+
};
|
|
407009
|
+
const recent = (this._interruptionMessages ?? []).filter((message) => message.role !== "system" && typeof message.content === "string").slice(-4).map((message) => ({ role: message.role, text: excerpt(partitionTypedModelOutput(message.content).visibleText, 600) }));
|
|
407010
|
+
return {
|
|
407011
|
+
inputId,
|
|
407012
|
+
runId: this.currentArtifactRunId(),
|
|
407013
|
+
taskEpoch: this._taskEpoch,
|
|
407014
|
+
ownerGeneration: state?.owner.generation ?? 0,
|
|
407015
|
+
inputSha256: _createHash("sha256").update(input.content).digest("hex"),
|
|
407016
|
+
turn: this._currentSteeringTurn,
|
|
407017
|
+
contextWindowTokens: Math.min(8192, this.effectiveContextWindow() || 8192),
|
|
407018
|
+
messages: [
|
|
407019
|
+
{ role: "system", content: "Respond directly to the latest user input in one or two concise sentences. This is the ongoing conversation, not a new task. Answer questions using only the supplied observations; distinguish intentions from completed work. For a requested change, state its concrete effect or what you will do next. Keep the existing objective unless the user changes it. Do not call tools, plan, reconcile authority, describe internal processing, or claim actions have run. Do not invent facts missing from this compact snapshot. The full input and task will be reconciled separately after this reply." },
|
|
407020
|
+
{ role: "user", content: JSON.stringify({
|
|
407021
|
+
originalObjective: excerpt(this._taskState.originalGoal || this._taskState.goal || "", 1400),
|
|
407022
|
+
constraints: (this._taskState.steeringConstraints ?? []).slice(-8).map((value) => excerpt(value, 240)),
|
|
407023
|
+
recentObservations: recent,
|
|
407024
|
+
priorAcceptedInputs: this.pendingSteeringInputs.filter((prior) => prior.inputId !== inputId && prior.taskEpoch === this._taskEpoch && !["cancelled", "superseded", "consumed"].includes(prior.state)).slice(-6).map((prior) => ({ inputId: prior.inputId, text: excerpt(prior.content, 480) })),
|
|
407025
|
+
runningOperations: (state?.pendingAcknowledgements ?? []).filter((item) => item.status === "pending").slice(0, 6).map((item) => ({ kind: item.kind, owner: item.ownerId })),
|
|
407026
|
+
latestInput: excerpt(input.content, 8e3),
|
|
407027
|
+
latestInputExcerpted: Buffer.byteLength(input.content, "utf8") > 8e3
|
|
407028
|
+
}) }
|
|
407029
|
+
]
|
|
407030
|
+
};
|
|
407031
|
+
}
|
|
407032
|
+
isSteeringReplyCurrent(packet2) {
|
|
407033
|
+
const pending = this._currentSteeringReplyPending(), state = this.interruptionState;
|
|
407034
|
+
return !this.aborted && !this._updateRestartCheckpointForced && !this._updateAbortController.signal.aborted && !!pending && pending.input.inputId === packet2.inputId && this.currentArtifactRunId() === packet2.runId && this._taskEpoch === packet2.taskEpoch && (state?.owner.generation ?? 0) === packet2.ownerGeneration && (!state || !["stopping", "stopped", "failed", "completed"].includes(state.phase)) && _createHash("sha256").update(pending.input.content).digest("hex") === packet2.inputSha256;
|
|
407035
|
+
}
|
|
407036
|
+
/** Record real visible prose without satisfying the internal scope gate. */
|
|
407037
|
+
recordSteeringReply(packet2, content) {
|
|
407038
|
+
if (!this.isSteeringReplyCurrent(packet2))
|
|
407039
|
+
return false;
|
|
407040
|
+
const visible = partitionTypedModelOutput(content).visibleText.trim();
|
|
407041
|
+
if (!visible)
|
|
407042
|
+
return false;
|
|
407043
|
+
const input = this._pendingSteeringReply.input;
|
|
407044
|
+
input.humanResponse = { content: visible, deliveredAt: (/* @__PURE__ */ new Date()).toISOString(), inputSha256: packet2.inputSha256 };
|
|
407045
|
+
try {
|
|
407046
|
+
this._emitSteeringLifecycle(input, "visible model reply delivered; objective reconciliation remains pending");
|
|
407047
|
+
} catch (error) {
|
|
407048
|
+
delete input.humanResponse;
|
|
407049
|
+
throw error;
|
|
407050
|
+
}
|
|
407051
|
+
this._pendingSteeringReply = null;
|
|
407052
|
+
return true;
|
|
407053
|
+
}
|
|
406749
407054
|
/**
|
|
406750
407055
|
* Request safe-boundary preemption for an already accepted typed input.
|
|
406751
407056
|
* Frontends use this after delivery so cancellation reaches an in-flight
|
|
@@ -407073,7 +407378,7 @@ ${notice}`;
|
|
|
407073
407378
|
hold2.wake();
|
|
407074
407379
|
}
|
|
407075
407380
|
get taskRequirementInterpretationPending() {
|
|
407076
|
-
return this._nativeRequirementInterpretationHolds.size > 0 || this._pendingNativeRequirementAmendments.size > 0;
|
|
407381
|
+
return this._nativeRequirementInterpretationHolds.size > 0 || this._pendingNativeRequirementAmendments.size > 0 || !!(this._forcedUpdateRequirementRecoveryPending?.requirementHolds.length || this._forcedUpdateRequirementRecoveryPending?.requirementAmendments.length);
|
|
407077
407382
|
}
|
|
407078
407383
|
/** Host-only authenticated new human instruction; existing steering gates remain authoritative. */
|
|
407079
407384
|
queueNativeTaskRequirementAmendment(authority) {
|
|
@@ -407611,6 +407916,13 @@ The previous reviewer response failed exact candidate-quote serialization. Host
|
|
|
407611
407916
|
}
|
|
407612
407917
|
/** Abort the current task run through the generation-bound stop lineage. */
|
|
407613
407918
|
abort() {
|
|
407919
|
+
if (this._updateRestartCheckpointForced) {
|
|
407920
|
+
this.aborted = true;
|
|
407921
|
+
this._abortController.abort();
|
|
407922
|
+
this._turnAbortController.abort();
|
|
407923
|
+
this._releasePauseWaiters();
|
|
407924
|
+
return null;
|
|
407925
|
+
}
|
|
407614
407926
|
const transition = this._interruptionLifecycle?.requestStop(this._interruptionLifecycle.snapshot().owner, "runner abort requested") ?? null;
|
|
407615
407927
|
if (transition && !transition.accepted)
|
|
407616
407928
|
return transition;
|
|
@@ -408319,6 +408631,8 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408319
408631
|
}
|
|
408320
408632
|
}
|
|
408321
408633
|
_emitSteeringLifecycle(record9, reason) {
|
|
408634
|
+
if (this._updateRestartCheckpointForced)
|
|
408635
|
+
return;
|
|
408322
408636
|
const receipt = this._steeringReceipt(record9);
|
|
408323
408637
|
const reconciliation = this._activeSteering && [
|
|
408324
408638
|
this._activeSteering.input,
|
|
@@ -408587,6 +408901,16 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408587
408901
|
}
|
|
408588
408902
|
async _drainPendingSteeringMessages(messages2, turn) {
|
|
408589
408903
|
this.drainPendingRuntimeGuidance(turn);
|
|
408904
|
+
const appendReply = (record9) => {
|
|
408905
|
+
const reply = record9.humanResponse;
|
|
408906
|
+
if (!reply || reply.materialized || record9.taskEpoch !== this._taskEpoch || ["cancelled", "superseded"].includes(record9.state) || reply.inputSha256 !== _createHash("sha256").update(record9.content).digest("hex") || !messages2.some((message) => message.role === "user" && message.content === record9.content))
|
|
408907
|
+
return;
|
|
408908
|
+
messages2.push({ role: "assistant", content: reply.content, taskEpoch: this._taskEpoch });
|
|
408909
|
+
reply.materialized = true;
|
|
408910
|
+
};
|
|
408911
|
+
for (const record9 of this.pendingSteeringInputs)
|
|
408912
|
+
if (record9.state !== "queued" && record9.state !== "acknowledged")
|
|
408913
|
+
appendReply(record9);
|
|
408590
408914
|
const pending = this.pendingSteeringInputs.filter((record9) => (record9.state === "queued" || record9.state === "acknowledged") && (!record9.taskEpoch || record9.taskEpoch === this._taskEpoch));
|
|
408591
408915
|
for (const record9 of pending) {
|
|
408592
408916
|
const replacement = this._pendingSteeringPreemption;
|
|
@@ -408599,6 +408923,7 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408599
408923
|
const historyStart = messages2.length;
|
|
408600
408924
|
await this.appendInjectedUserMessage(record9.content, messages2, turn);
|
|
408601
408925
|
this._activateSteering(record9, turn);
|
|
408926
|
+
appendReply(record9);
|
|
408602
408927
|
if (this._immediateSteeringWakeInputId === record9.inputId) {
|
|
408603
408928
|
this._immediateSteeringWakeInputId = null;
|
|
408604
408929
|
}
|
|
@@ -408611,6 +408936,8 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408611
408936
|
if (record9)
|
|
408612
408937
|
this._applyNativeTaskRequirementAmendmentAtBoundary(record9);
|
|
408613
408938
|
}
|
|
408939
|
+
for (const record9 of this.pendingSteeringInputs)
|
|
408940
|
+
appendReply(record9);
|
|
408614
408941
|
while (this.pendingUserMessages.length > 0) {
|
|
408615
408942
|
await this.appendInjectedUserMessage(this.pendingUserMessages.shift(), messages2, turn);
|
|
408616
408943
|
}
|
|
@@ -409077,6 +409404,7 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
409077
409404
|
if (isSteeringScopeResolved(active) && !this._currentSteeringReplyPending())
|
|
409078
409405
|
return null;
|
|
409079
409406
|
const sources = [input, ...active.relatedInputs ?? []];
|
|
409407
|
+
const humanResponse = [...sources].reverse().find((source) => source.humanResponse)?.humanResponse;
|
|
409080
409408
|
const exactSourcesPresent = this.effectiveContextWindow() > 0 && this.effectiveContextWindow() <= 8192 && input.taskEpoch === this._taskEpoch && sources.every((source) => source.taskEpoch === this._taskEpoch && source.state !== "cancelled" && source.state !== "superseded" && sourceMessages?.some((message) => message.role === "user" && message.content === source.content && message.requiredSourceEvidence?.schema === "omnius.required-source-evidence.v1" && message.requiredSourceEvidence.scope === this._steeringAuthorityScope(source)));
|
|
409081
409409
|
const exactSourcePointer = (source) => `Exact admitted instruction is already present in its required user message: input_id=${source.inputId}; sha256=${_createHash("sha256").update(source.content).digest("hex")}.`;
|
|
409082
409410
|
const needsClarification = reconciliation?.status === "needs_clarification";
|
|
@@ -409087,7 +409415,8 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
409087
409415
|
`kind=${input.intent}`,
|
|
409088
409416
|
`admission=${active.gatesOldPlan ? "old_plan_gated" : "context_active"}`,
|
|
409089
409417
|
"This is current user authority, not historical transcript context.",
|
|
409090
|
-
|
|
409418
|
+
humanResponse ? `You have already visibly responded to the latest input: ${humanResponse.content}
|
|
409419
|
+
Do not repeat that response. Reconcile the complete instruction internally before the next action; this conversational reply granted no tool or scope authority.` : "Answer the latest user's question or briefly state the concrete effect of their change first, in ordinary visible prose. Then reconcile the current instruction internally before deeper planning or tools. Do not announce steering, reconciliation, or internal reviews.",
|
|
409091
409420
|
isSteeringScopeResolved(active) && this._currentSteeringReplyPending() ? "The internal scope decision is already stored. Give the actual user-facing answer now; do not repeat the internal reconciliation, call tools, or replace the original objective." : null,
|
|
409092
409421
|
input.intent === "redirect" || input.intent === "replace" ? "The prior task epoch is historical evidence only. Do not continue its plan, todos, recovery cards, or completion contract." : null,
|
|
409093
409422
|
needsClarification ? "You requested clarification. Do not call tools or resume the old plan; ask the user one concise question." : active.requiresReconciliation ? [
|
|
@@ -409371,6 +409700,63 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409371
409700
|
}
|
|
409372
409701
|
return receipt;
|
|
409373
409702
|
}
|
|
409703
|
+
/** Explicit update interrupts inference/owned children without stopping the durable task. */
|
|
409704
|
+
pauseForUpdate() {
|
|
409705
|
+
const receipt = this.pauseForInput();
|
|
409706
|
+
if (receipt?.accepted === false)
|
|
409707
|
+
return receipt;
|
|
409708
|
+
const reason = new InputWaitInterruption();
|
|
409709
|
+
this._updateAbortController.abort(reason);
|
|
409710
|
+
this._turnAbortController.abort(reason);
|
|
409711
|
+
this._trajectoryGroundingRequest?.controller.abort(reason);
|
|
409712
|
+
this._virtualContextRequest?.controller.abort(reason);
|
|
409713
|
+
const names = new Set(this.interruptionState?.pendingAcknowledgements.filter((item) => item.status === "pending" && item.ownerId.startsWith("tool:")).map((item) => item.ownerId.slice(5)) ?? []);
|
|
409714
|
+
for (const name of names) {
|
|
409715
|
+
try {
|
|
409716
|
+
void Promise.resolve(this.lookupRegisteredTool(name)?.tool.cancel?.()).catch(() => void 0);
|
|
409717
|
+
} catch {
|
|
409718
|
+
}
|
|
409719
|
+
}
|
|
409720
|
+
return receipt;
|
|
409721
|
+
}
|
|
409722
|
+
get updateRestartCheckpointForced() {
|
|
409723
|
+
return this._updateRestartCheckpointForced;
|
|
409724
|
+
}
|
|
409725
|
+
/** Native host review capability, installed before this runner accepts work. */
|
|
409726
|
+
setForcedUpdateRequirementRecoveryHandler(handler, onApplied) {
|
|
409727
|
+
if (this._hasStartedTask || this._updateRestartCheckpointForced)
|
|
409728
|
+
throw new Error("Native recovery handler must be bound before task admission");
|
|
409729
|
+
this._forcedUpdateRequirementRecoveryHandler = handler;
|
|
409730
|
+
this._forcedUpdateRequirementRecoveryApplied = onApplied;
|
|
409731
|
+
}
|
|
409732
|
+
/** Called only after the updater's bounded cooperative deadline. One-way. */
|
|
409733
|
+
forceUpdateRestartCheckpoint() {
|
|
409734
|
+
if (this._updateRestartCheckpointSaved)
|
|
409735
|
+
return true;
|
|
409736
|
+
if (!this._interruptionLifecycle || !this._interruptionMessages?.length)
|
|
409737
|
+
return false;
|
|
409738
|
+
if (!this._interruptionLifecycle.isCurrentDurableBoundary())
|
|
409739
|
+
return false;
|
|
409740
|
+
if (!this._updateRestartCheckpointForced) {
|
|
409741
|
+
if (this.pauseForUpdate()?.accepted === false)
|
|
409742
|
+
return false;
|
|
409743
|
+
this._updateRestartCheckpointForced = true;
|
|
409744
|
+
}
|
|
409745
|
+
if (!this._updateRestartOwnerRevoked) {
|
|
409746
|
+
const receipt = this._interruptionLifecycle.forcePauseForUpdate(this._interruptionLifecycle.snapshot().owner);
|
|
409747
|
+
if (!receipt.accepted)
|
|
409748
|
+
return false;
|
|
409749
|
+
this._updateRestartOwnerRevoked = true;
|
|
409750
|
+
this._modelRequestGeneration = receipt.sequence;
|
|
409751
|
+
this._paused = true;
|
|
409752
|
+
}
|
|
409753
|
+
this._updateCheckpointWriteAuthorized = true;
|
|
409754
|
+
try {
|
|
409755
|
+
return this._updateRestartCheckpointSaved = this._prepareUpdateRestartCheckpoint(true);
|
|
409756
|
+
} finally {
|
|
409757
|
+
this._updateCheckpointWriteAuthorized = false;
|
|
409758
|
+
}
|
|
409759
|
+
}
|
|
409374
409760
|
/** A typed instruction resumes only after the exact atomic owners settle. */
|
|
409375
409761
|
async resumeAfterInput() {
|
|
409376
409762
|
const sequence = this._inputWaitSequence;
|
|
@@ -409399,6 +409785,25 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409399
409785
|
* Resume a paused task. The run loop continues from where it left off.
|
|
409400
409786
|
*/
|
|
409401
409787
|
resume() {
|
|
409788
|
+
if (this._updateRestartCheckpointForced) {
|
|
409789
|
+
const state = this.interruptionState;
|
|
409790
|
+
return state ? {
|
|
409791
|
+
accepted: false,
|
|
409792
|
+
idempotent: false,
|
|
409793
|
+
action: "resume",
|
|
409794
|
+
previousPhase: state.phase,
|
|
409795
|
+
phase: state.phase,
|
|
409796
|
+
sequence: state.sequence,
|
|
409797
|
+
sessionId: state.sessionId,
|
|
409798
|
+
runId: state.runId,
|
|
409799
|
+
taskEpoch: state.taskEpoch,
|
|
409800
|
+
ownerGeneration: state.owner.generation,
|
|
409801
|
+
resumable: true,
|
|
409802
|
+
pendingAcknowledgements: state.pendingAcknowledgements.filter((item) => item.status === "pending").length,
|
|
409803
|
+
unresolvedAmbiguousEffects: state.ambiguousEffects.filter((item) => item.state === "unknown_after_interrupt").length,
|
|
409804
|
+
reason: "This instance was retired for update. Restore its durable checkpoint in the replacement process."
|
|
409805
|
+
} : null;
|
|
409806
|
+
}
|
|
409402
409807
|
const transition = this._interruptionLifecycle?.requestResume(this._interruptionLifecycle.snapshot().owner, "resume requested by active owner") ?? null;
|
|
409403
409808
|
if (transition && !transition.accepted)
|
|
409404
409809
|
return transition;
|
|
@@ -409408,6 +409813,11 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409408
409813
|
this._paused = false;
|
|
409409
409814
|
this._inputWaitPaused = false;
|
|
409410
409815
|
this._inputWaitBoundaryController = new AbortController();
|
|
409816
|
+
if (this._updateAbortController.signal.aborted) {
|
|
409817
|
+
this._updateAbortController = new AbortController();
|
|
409818
|
+
this._turnAbortController = new AbortController();
|
|
409819
|
+
this._setBackendTurnAbortSignal(this._turnAbortController.signal);
|
|
409820
|
+
}
|
|
409411
409821
|
this._releasePauseWaiters();
|
|
409412
409822
|
return resumed;
|
|
409413
409823
|
}
|
|
@@ -409540,10 +409950,15 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409540
409950
|
}
|
|
409541
409951
|
/** Persist exact owned work before an update can replace this process. */
|
|
409542
409952
|
prepareUpdateRestartCheckpoint() {
|
|
409543
|
-
if (this.
|
|
409953
|
+
if (this._updateRestartCheckpointForced)
|
|
409954
|
+
return this._updateRestartCheckpointSaved;
|
|
409955
|
+
return this._prepareUpdateRestartCheckpoint(false);
|
|
409956
|
+
}
|
|
409957
|
+
_prepareUpdateRestartCheckpoint(allowUnresolvedEffects) {
|
|
409958
|
+
if (!allowUnresolvedEffects && this.taskRequirementInterpretationPending)
|
|
409544
409959
|
return false;
|
|
409545
409960
|
const state = this._interruptionLifecycle?.snapshot();
|
|
409546
|
-
if (!state || state.phase !== "paused" || !this._interruptionMessages?.length || state.pendingAcknowledgements.some((item) => item.status === "pending") || state.ambiguousEffects.some((item) => item.state === "unknown_after_interrupt"))
|
|
409961
|
+
if (!state || state.phase !== "paused" || !this._interruptionMessages?.length || state.pendingAcknowledgements.some((item) => item.status === "pending") || !allowUnresolvedEffects && state.ambiguousEffects.some((item) => item.state === "unknown_after_interrupt"))
|
|
409547
409962
|
return false;
|
|
409548
409963
|
if (!this._saveCompletionLedgerSafe())
|
|
409549
409964
|
throw new Error("paused_run_checkpoint_ledger_not_durable");
|
|
@@ -409560,7 +409975,7 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409560
409975
|
messages2.push({
|
|
409561
409976
|
role: "tool",
|
|
409562
409977
|
tool_call_id: id5,
|
|
409563
|
-
content: `Host update checkpoint: queued ${name} did not finish before the pause. No success or effect is claimed. Consult the exact durable receipts and decide what remaining work to perform.`
|
|
409978
|
+
content: allowUnresolvedEffects ? `Host forced update checkpoint: unfinished ${name} was retired without a success claim. Its effect may be unknown. Reconcile the durable interruption record before replaying any mutation or external effect.` : `Host update checkpoint: queued ${name} did not finish before the pause. No success or effect is claimed. Consult the exact durable receipts and decide what remaining work to perform.`
|
|
409564
409979
|
});
|
|
409565
409980
|
const checkpoint = {
|
|
409566
409981
|
schema: "omnius.paused-run-checkpoint.v1",
|
|
@@ -409576,7 +409991,33 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409576
409991
|
observedEffects: [...this._expectedOutcomeObservedEffects],
|
|
409577
409992
|
modelRequestGeneration: this._modelRequestGeneration,
|
|
409578
409993
|
toolPromotions: this._checkpointToolPromotions(),
|
|
409579
|
-
runtimeRecovery: this._captureRuntimeRecovery(messages2)
|
|
409994
|
+
runtimeRecovery: this._captureRuntimeRecovery(messages2),
|
|
409995
|
+
...allowUnresolvedEffects ? { forcedInterruption: state } : {},
|
|
409996
|
+
forcedIntake: this._forcedUpdateRequirementRecoveryPending ? {
|
|
409997
|
+
...structuredClone(this._forcedUpdateRequirementRecoveryPending),
|
|
409998
|
+
steering: [...new Map([...this._forcedUpdateRequirementRecoveryPending.steering, ...this.pendingSteeringInputs].map((input) => [input.inputId, structuredClone(input)])).values()],
|
|
409999
|
+
compatibilityMessages: [...this._forcedUpdateRequirementRecoveryPending.compatibilityMessages, ...this.pendingUserMessages],
|
|
410000
|
+
requirementHolds: [...new Map([
|
|
410001
|
+
...this._forcedUpdateRequirementRecoveryPending.requirementHolds,
|
|
410002
|
+
...[...this._nativeRequirementInterpretationHolds].map(([inputId, hold2]) => ({ inputId, runId: hold2.runId, taskEpoch: hold2.taskEpoch, nativeInputSha256: hold2.nativeInputSha256 }))
|
|
410003
|
+
].map((hold2) => [hold2.inputId, hold2])).values()],
|
|
410004
|
+
requirementAmendments: [...new Map([
|
|
410005
|
+
...this._forcedUpdateRequirementRecoveryPending.requirementAmendments,
|
|
410006
|
+
...[...this._pendingNativeRequirementAmendments.values()].map((pending) => structuredClone(pending.authority))
|
|
410007
|
+
].map((authority) => [authority.inputId, authority])).values()]
|
|
410008
|
+
} : {
|
|
410009
|
+
steering: structuredClone(this.pendingSteeringInputs),
|
|
410010
|
+
compatibilityMessages: [...this.pendingUserMessages],
|
|
410011
|
+
requirementHolds: [...this._nativeRequirementInterpretationHolds].map(([inputId, hold2]) => ({
|
|
410012
|
+
inputId,
|
|
410013
|
+
runId: hold2.runId,
|
|
410014
|
+
taskEpoch: hold2.taskEpoch,
|
|
410015
|
+
nativeInputSha256: hold2.nativeInputSha256
|
|
410016
|
+
})),
|
|
410017
|
+
requirementAmendments: [...this._pendingNativeRequirementAmendments.values()].map((pending) => structuredClone(pending.authority)),
|
|
410018
|
+
...this.options.taskNativeScope ? { nativeScope: structuredClone(this.options.taskNativeScope) } : {},
|
|
410019
|
+
...this.options.expectedOutcomeContract ? { expectedOutcome: structuredClone(this.options.expectedOutcomeContract) } : {}
|
|
410020
|
+
}
|
|
409580
410021
|
};
|
|
409581
410022
|
const body = JSON.stringify(checkpoint);
|
|
409582
410023
|
const stored = this._artifactStore().put({
|
|
@@ -409667,13 +410108,192 @@ Earlier host presentation and its quoted source/history bytes are retained lossl
|
|
|
409667
410108
|
throw new Error("paused_run_checkpoint_invalid_identity");
|
|
409668
410109
|
const archived = this._artifactStore().read(selector.reference);
|
|
409669
410110
|
const checkpoint = JSON.parse(archived.content);
|
|
409670
|
-
if (!matches(checkpoint) || checkpoint.modelRequestGeneration !== selector.modelRequestGeneration || typeof checkpoint.goal !== "string" || !Array.isArray(checkpoint.messages) || !checkpoint.messages.every((message) => message && ["system", "user", "assistant", "tool"].includes(message.role)) || !checkpoint.taskState || typeof checkpoint.taskState.goal !== "string" || !Array.isArray(checkpoint.taskState.modifiedFiles) || !checkpoint.taskState.modifiedFiles.every((entry) => Array.isArray(entry) && entry.length === 2 && entry.every((value) => typeof value === "string")) || !Array.isArray(checkpoint.taskState.completedSteps) || !Array.isArray(checkpoint.taskState.pendingSteps) || !Array.isArray(checkpoint.taskState.failedApproaches) || !Number.isSafeInteger(checkpoint.taskState.toolCallCount) || !Array.isArray(checkpoint.toolCallLog) || !Array.isArray(checkpoint.observedEffects) || checkpoint.toolPromotions !== void 0 && !this._validCheckpointToolPromotions(checkpoint.toolPromotions) || checkpoint.runtimeRecovery !== void 0 && !this._validRuntimeRecovery(checkpoint.runtimeRecovery, checkpoint)) {
|
|
410111
|
+
if (!matches(checkpoint) || checkpoint.modelRequestGeneration !== selector.modelRequestGeneration || typeof checkpoint.goal !== "string" || !Array.isArray(checkpoint.messages) || !checkpoint.messages.every((message) => message && ["system", "user", "assistant", "tool"].includes(message.role)) || !checkpoint.taskState || typeof checkpoint.taskState.goal !== "string" || !Array.isArray(checkpoint.taskState.modifiedFiles) || !checkpoint.taskState.modifiedFiles.every((entry) => Array.isArray(entry) && entry.length === 2 && entry.every((value) => typeof value === "string")) || !Array.isArray(checkpoint.taskState.completedSteps) || !Array.isArray(checkpoint.taskState.pendingSteps) || !Array.isArray(checkpoint.taskState.failedApproaches) || !Number.isSafeInteger(checkpoint.taskState.toolCallCount) || !Array.isArray(checkpoint.toolCallLog) || !Array.isArray(checkpoint.observedEffects) || checkpoint.toolPromotions !== void 0 && !this._validCheckpointToolPromotions(checkpoint.toolPromotions) || checkpoint.runtimeRecovery !== void 0 && !this._validRuntimeRecovery(checkpoint.runtimeRecovery, checkpoint) || checkpoint.forcedIntake !== void 0 && !this._validForcedIntake(checkpoint.forcedIntake, checkpoint)) {
|
|
409671
410112
|
throw new Error("paused_run_checkpoint_invalid_snapshot");
|
|
409672
410113
|
}
|
|
409673
410114
|
return checkpoint;
|
|
409674
410115
|
}
|
|
410116
|
+
_validForcedIntake(value, checkpoint) {
|
|
410117
|
+
return !!value && typeof value === "object" && Array.isArray(value.steering) && new Set(value.steering.map((input) => input?.inputId)).size === value.steering.length && value.steering.every((input) => input && typeof input.inputId === "string" && !!input.inputId.trim() && typeof input.content === "string" && typeof input.source === "string" && typeof input.receivedAt === "string" && ["clarify", "append", "context_only", "constraint", "priority_change", "redirect", "replace", "cancel"].includes(input.intent) && ["received", "queued", "acknowledged", "visible_in_request", "reconciliation_required", "reconciled", "first_affected_action", "consumed", "superseded", "cancelled"].includes(input.state) && (input.taskEpoch === void 0 || Number.isSafeInteger(input.taskEpoch) && input.taskEpoch >= 0) && (input.allowTaskReplacement === void 0 || typeof input.allowTaskReplacement === "boolean")) && Array.isArray(value.compatibilityMessages) && value.compatibilityMessages.every((message) => typeof message === "string") && Array.isArray(value.requirementHolds) && value.requirementHolds.every((hold2) => hold2 && typeof hold2.inputId === "string" && hold2.runId === checkpoint.runId && hold2.taskEpoch === checkpoint.taskEpoch && /^[a-f0-9]{64}$/.test(hold2.nativeInputSha256)) && Array.isArray(value.requirementAmendments) && value.requirementAmendments.every((amendment) => amendment && amendment.schema === "omnius.native-requirement-amendment.v1" && typeof amendment.inputId === "string" && amendment.scope?.nativeRunnerRunId === checkpoint.runId && amendment.scope?.taskEpoch === checkpoint.taskEpoch) && (!!checkpoint.forcedInterruption || !value.requirementHolds.length && !value.requirementAmendments.length && !value.reviewedRecovery);
|
|
410118
|
+
}
|
|
410119
|
+
_restoreForcedIntake(checkpoint) {
|
|
410120
|
+
const intake2 = checkpoint.forcedIntake;
|
|
410121
|
+
if (!intake2)
|
|
410122
|
+
return;
|
|
410123
|
+
const activeIds = new Set(this._activeSteering ? [this._activeSteering.input, ...this._activeSteering.relatedInputs ?? []].map((input) => input.inputId) : []);
|
|
410124
|
+
for (const saved of intake2.steering) {
|
|
410125
|
+
const prior = this.pendingSteeringInputs.find((input2) => input2.inputId === saved.inputId);
|
|
410126
|
+
const input = prior ? Object.assign(prior, structuredClone(saved)) : structuredClone(saved);
|
|
410127
|
+
if (!prior)
|
|
410128
|
+
this.pendingSteeringInputs.push(input);
|
|
410129
|
+
if (input.taskEpoch !== void 0 && input.taskEpoch !== this._taskEpoch || ["cancelled", "superseded", "reconciled", "first_affected_action", "consumed"].includes(input.state))
|
|
410130
|
+
continue;
|
|
410131
|
+
if (!activeIds.has(input.inputId))
|
|
410132
|
+
input.state = "queued";
|
|
410133
|
+
if (input.intent === "redirect" || input.intent === "replace" || input.intent === "cancel")
|
|
410134
|
+
this._pendingSteeringPreemption = input;
|
|
410135
|
+
if ((input.source === "tui-work-intake" || input.source === "tui") && input.intent !== "cancel" && !input.humanResponse)
|
|
410136
|
+
this._pendingSteeringReply = { input, runId: this.currentArtifactRunId(), ownerId: this._interruptionOwnerId, visibleRequestTurns: [] };
|
|
410137
|
+
}
|
|
410138
|
+
this.pendingUserMessages.push(...intake2.compatibilityMessages);
|
|
410139
|
+
}
|
|
410140
|
+
async _recoverForcedUpdateRequirements(checkpoint, state) {
|
|
410141
|
+
const intake2 = checkpoint.forcedIntake;
|
|
410142
|
+
if (!intake2 || !intake2.requirementHolds.length && !intake2.requirementAmendments.length)
|
|
410143
|
+
return;
|
|
410144
|
+
if (!checkpoint.completionLedger || !intake2.nativeScope || !intake2.expectedOutcome)
|
|
410145
|
+
throw new Error("forced_update_requirement_recovery_missing_native_authority");
|
|
410146
|
+
this._forcedUpdateRequirementRecoveryPending = structuredClone(intake2);
|
|
410147
|
+
this._completionLedger = restoreCompletionLedgerSnapshot(checkpoint.completionLedger);
|
|
410148
|
+
this._taskObjectiveContract = this._completionLedger.objectiveContract ?? null;
|
|
410149
|
+
const recovery = {
|
|
410150
|
+
schema: "omnius.forced-update-requirement-recovery.v1",
|
|
410151
|
+
checkpointSha256: taskExecutionDigest(checkpoint),
|
|
410152
|
+
runId: state.runId,
|
|
410153
|
+
sessionId: state.sessionId,
|
|
410154
|
+
taskEpoch: state.taskEpoch,
|
|
410155
|
+
ownerGeneration: state.owner.generation,
|
|
410156
|
+
completionLedger: reconcileForcedUpdateReadOnlyOperations(restoreCompletionLedgerSnapshot(checkpoint.completionLedger), state),
|
|
410157
|
+
nativeScope: intake2.nativeScope,
|
|
410158
|
+
expectedOutcome: intake2.expectedOutcome,
|
|
410159
|
+
steering: intake2.steering,
|
|
410160
|
+
requirementHolds: intake2.requirementHolds,
|
|
410161
|
+
requirementAmendments: intake2.requirementAmendments
|
|
410162
|
+
};
|
|
410163
|
+
const lifecycle = this._interruptionLifecycle;
|
|
410164
|
+
const signal = AbortSignal.any([this._turnAbortController.signal, this._updateAbortController.signal, this._abortController.signal]);
|
|
410165
|
+
const assertCurrent = () => {
|
|
410166
|
+
signal.throwIfAborted();
|
|
410167
|
+
if (this._updateRestartCheckpointForced || lifecycle !== this._interruptionLifecycle || !lifecycle?.isCurrentDurableBoundary() || lifecycle.snapshot().phase !== "paused" || lifecycle.snapshot().owner.generation !== recovery.ownerGeneration)
|
|
410168
|
+
throw new InputWaitInterruption();
|
|
410169
|
+
};
|
|
410170
|
+
const file = this._taskScopeBoundaryPath().replace(/\.json$/, ".requirement-recovery.json");
|
|
410171
|
+
let receipt;
|
|
410172
|
+
if (_fsExistsSync(file)) {
|
|
410173
|
+
const stored = JSON.parse(_fsReadFileSync(file, "utf8"));
|
|
410174
|
+
if (stored.checkpointSha256 === recovery.checkpointSha256 && typeof stored.reference === "string")
|
|
410175
|
+
receipt = JSON.parse(this._artifactStore().read(stored.reference).content);
|
|
410176
|
+
}
|
|
410177
|
+
let result;
|
|
410178
|
+
if (receipt)
|
|
410179
|
+
result = applyForcedUpdateRequirementRecovery(recovery, receipt);
|
|
410180
|
+
else {
|
|
410181
|
+
const resolutions = [];
|
|
410182
|
+
const expected = new Map(recovery.requirementHolds.map((hold2) => [hold2.inputId, hold2]));
|
|
410183
|
+
for (const amendment of recovery.requirementAmendments)
|
|
410184
|
+
if (!expected.has(amendment.inputId))
|
|
410185
|
+
expected.set(amendment.inputId, { inputId: amendment.inputId, runId: recovery.runId, taskEpoch: recovery.taskEpoch, nativeInputSha256: amendment.scope.nativeInputSha256 });
|
|
410186
|
+
const prefix = {
|
|
410187
|
+
...this._forcedRequirementRecoveryIdentity(recovery),
|
|
410188
|
+
schema: "omnius.forced-update-requirement-recovery-receipt.v1",
|
|
410189
|
+
resolutions,
|
|
410190
|
+
...intake2.reviewedRecovery ? { predecessor: structuredClone(intake2.reviewedRecovery) } : {}
|
|
410191
|
+
};
|
|
410192
|
+
let current2 = projectForcedUpdateRequirementRecoveryPrefix(recovery, prefix);
|
|
410193
|
+
for (const inputId of current2.resolvedInputIds)
|
|
410194
|
+
expected.delete(inputId);
|
|
410195
|
+
const orderedIds = [.../* @__PURE__ */ new Set([...recovery.steering.map((input) => input.inputId), ...expected.keys()])];
|
|
410196
|
+
for (const inputId of orderedIds) {
|
|
410197
|
+
const hold2 = expected.get(inputId);
|
|
410198
|
+
if (!hold2)
|
|
410199
|
+
continue;
|
|
410200
|
+
assertCurrent();
|
|
410201
|
+
const amendment = recovery.requirementAmendments.find((authority) => authority.inputId === inputId);
|
|
410202
|
+
const one = {
|
|
410203
|
+
...structuredClone(recovery),
|
|
410204
|
+
...structuredClone(current2),
|
|
410205
|
+
steering: structuredClone(current2.recoveredSteering),
|
|
410206
|
+
requirementHolds: [hold2],
|
|
410207
|
+
requirementAmendments: amendment ? [amendment] : []
|
|
410208
|
+
};
|
|
410209
|
+
let reviewed;
|
|
410210
|
+
if (amendment)
|
|
410211
|
+
reviewed = {
|
|
410212
|
+
...this._forcedRequirementRecoveryIdentity(recovery),
|
|
410213
|
+
schema: "omnius.forced-update-requirement-recovery-receipt.v1",
|
|
410214
|
+
resolutions: [{
|
|
410215
|
+
inputId,
|
|
410216
|
+
nativeInputSha256: hold2.nativeInputSha256,
|
|
410217
|
+
disposition: "amendment",
|
|
410218
|
+
authority: amendment
|
|
410219
|
+
}]
|
|
410220
|
+
};
|
|
410221
|
+
else {
|
|
410222
|
+
if (!this._forcedUpdateRequirementRecoveryHandler)
|
|
410223
|
+
throw new Error(`interruption_requirement_review_required:${recovery.runId}`);
|
|
410224
|
+
reviewed = await withInputWaitCancellation(signal, () => this._forcedUpdateRequirementRecoveryHandler(one, { signal, assertCurrent }));
|
|
410225
|
+
}
|
|
410226
|
+
assertCurrent();
|
|
410227
|
+
current2 = applyForcedUpdateRequirementRecovery(one, reviewed);
|
|
410228
|
+
resolutions.push(...reviewed.resolutions);
|
|
410229
|
+
expected.delete(inputId);
|
|
410230
|
+
}
|
|
410231
|
+
if (expected.size)
|
|
410232
|
+
throw new Error("forced_update_requirement_recovery_missing_intake");
|
|
410233
|
+
receipt = prefix;
|
|
410234
|
+
result = applyForcedUpdateRequirementRecovery(recovery, receipt);
|
|
410235
|
+
assertCurrent();
|
|
410236
|
+
const body = JSON.stringify(receipt), stored = this._artifactStore().put({
|
|
410237
|
+
path: `forced-requirement-recovery/${state.runId}/${state.taskEpoch}`,
|
|
410238
|
+
revision: taskExecutionDigest(receipt),
|
|
410239
|
+
content: body,
|
|
410240
|
+
ranges: [{ start: 1, end: 1 }],
|
|
410241
|
+
fidelity: "full"
|
|
410242
|
+
});
|
|
410243
|
+
this._artifactStore().flush(stored.reference);
|
|
410244
|
+
_fsMkdirSync(_pathJoin(file, ".."), { recursive: true });
|
|
410245
|
+
const temporary = `${file}.${crypto.randomUUID()}.tmp`;
|
|
410246
|
+
_fsWriteFileSync(temporary, JSON.stringify({ checkpointSha256: recovery.checkpointSha256, reference: stored.reference }), { encoding: "utf8", mode: 384 });
|
|
410247
|
+
this._syncTaskScopeFile(temporary);
|
|
410248
|
+
assertCurrent();
|
|
410249
|
+
_fsRenameSync(temporary, file);
|
|
410250
|
+
this._syncTaskScopeDirectories(file);
|
|
410251
|
+
}
|
|
410252
|
+
assertCurrent();
|
|
410253
|
+
this._forcedUpdateRequirementRecoveryPending.reviewedRecovery = { recovery: structuredClone(recovery), receipt: structuredClone(receipt) };
|
|
410254
|
+
checkpoint.completionLedger = result.completionLedger;
|
|
410255
|
+
this.options.taskObjectiveContract = result.completionLedger.objectiveContract;
|
|
410256
|
+
this.options.taskNativeScope = structuredClone(result.nativeScope);
|
|
410257
|
+
this.options.expectedOutcomeContract = structuredClone(result.expectedOutcome);
|
|
410258
|
+
intake2.steering = result.recoveredSteering;
|
|
410259
|
+
for (const input of result.recoveredSteering)
|
|
410260
|
+
if (input.state === "consumed" && receipt.resolutions.some((resolution) => resolution.inputId === input.inputId)) {
|
|
410261
|
+
const context = `[REVIEWED USER CONTEXT]
|
|
410262
|
+
input_id=${input.inputId}
|
|
410263
|
+
The native host reviewed this input as context without a new task action. Preserve its quoted source meaning.
|
|
410264
|
+
${JSON.stringify(input.content)}
|
|
410265
|
+
[/REVIEWED USER CONTEXT]`;
|
|
410266
|
+
if (!checkpoint.messages.some((message) => message.role === "system" && message.content === context))
|
|
410267
|
+
checkpoint.messages.push({ role: "system", content: context, taskEpoch: checkpoint.taskEpoch });
|
|
410268
|
+
}
|
|
410269
|
+
intake2.requirementHolds = [];
|
|
410270
|
+
intake2.requirementAmendments = [];
|
|
410271
|
+
if (result.responseInputs.length && !this._forcedUpdateRequirementRecoveryApplied)
|
|
410272
|
+
throw new Error("forced_update_requirement_response_not_delivered");
|
|
410273
|
+
if (this._forcedUpdateRequirementRecoveryApplied) {
|
|
410274
|
+
await withInputWaitCancellation(signal, () => Promise.resolve(this._forcedUpdateRequirementRecoveryApplied(structuredClone(recovery), structuredClone(result), { signal, assertCurrent })));
|
|
410275
|
+
assertCurrent();
|
|
410276
|
+
}
|
|
410277
|
+
if (result.replacementInputs.length) {
|
|
410278
|
+
if (!this._forcedUpdateRequirementRecoveryApplied)
|
|
410279
|
+
throw new Error("forced_update_requirement_replacement_not_staged");
|
|
410280
|
+
this._forcedUpdateRequirementTaskReplaced = true;
|
|
410281
|
+
const stopped = lifecycle.requestStop(lifecycle.snapshot().owner, "native host durably staged an authenticated replacement task after update");
|
|
410282
|
+
if (!stopped.accepted)
|
|
410283
|
+
throw new Error(stopped.reason);
|
|
410284
|
+
if (lifecycle.snapshot().phase === "stopping")
|
|
410285
|
+
lifecycle.acknowledgeStop("old native objective superseded after durable replacement staging");
|
|
410286
|
+
}
|
|
410287
|
+
this._forcedUpdateRequirementRecoveryPending = void 0;
|
|
410288
|
+
}
|
|
410289
|
+
_forcedRequirementRecoveryIdentity(recovery) {
|
|
410290
|
+
const { checkpointSha256, runId, sessionId, taskEpoch, ownerGeneration } = recovery;
|
|
410291
|
+
return { checkpointSha256, runId, sessionId, taskEpoch, ownerGeneration };
|
|
410292
|
+
}
|
|
409675
410293
|
/** Resolve one persisted ambiguous effect before admitting another run. */
|
|
409676
410294
|
resolveInterruptionEffect(operationId, state, evidenceId) {
|
|
410295
|
+
if (this._updateRestartCheckpointForced)
|
|
410296
|
+
return false;
|
|
409677
410297
|
const resolved = this._interruptionLifecycle?.resolveAmbiguousEffect(operationId, state, evidenceId) ?? false;
|
|
409678
410298
|
this._reconcileRetiredLegacyOperations(this.interruptionState);
|
|
409679
410299
|
return resolved;
|
|
@@ -409732,6 +410352,10 @@ Earlier host presentation and its quoted source/history bytes are retained lossl
|
|
|
409732
410352
|
* Returns true if the loop should continue, false if aborted while paused.
|
|
409733
410353
|
*/
|
|
409734
410354
|
async waitIfPaused() {
|
|
410355
|
+
if (this._updateRestartCheckpointForced && this.aborted)
|
|
410356
|
+
throw new InputWaitInterruption();
|
|
410357
|
+
if (this.aborted)
|
|
410358
|
+
return false;
|
|
409735
410359
|
if (!this._paused)
|
|
409736
410360
|
return true;
|
|
409737
410361
|
this._interruptionLifecycle?.acknowledgePauseBoundary();
|
|
@@ -409742,6 +410366,8 @@ Earlier host presentation and its quoted source/history bytes are retained lossl
|
|
|
409742
410366
|
await new Promise((resolve42) => {
|
|
409743
410367
|
this._pauseWaiters.add(resolve42);
|
|
409744
410368
|
});
|
|
410369
|
+
if (this._updateRestartCheckpointForced)
|
|
410370
|
+
throw new InputWaitInterruption();
|
|
409745
410371
|
return !this.aborted;
|
|
409746
410372
|
}
|
|
409747
410373
|
/** Commit a streamed final reply only after its model owner reached a safe boundary. */
|
|
@@ -411786,6 +412412,8 @@ ${rawTask}`;
|
|
|
411786
412412
|
_observabilityActionSequence = 0;
|
|
411787
412413
|
_observabilityPendingActions = /* @__PURE__ */ new Map();
|
|
411788
412414
|
emit(event) {
|
|
412415
|
+
if (this._updateRestartCheckpointForced)
|
|
412416
|
+
return;
|
|
411789
412417
|
if (event.type === "tool_call" && event.toolName !== "task_complete" && !this._isProgressTool(event.toolName ?? "")) {
|
|
411790
412418
|
const candidate = this._latestModelVisibleAssistantText;
|
|
411791
412419
|
this._telegramDeliveryRefinementCandidateKey = this._isTelegramSurface() && candidate?.runId === this.currentArtifactRunId() && candidate.taskEpoch === this._taskEpoch ? [candidate.runId, candidate.taskEpoch, candidate.turn].join(":") : void 0;
|
|
@@ -412229,7 +412857,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
412229
412857
|
try {
|
|
412230
412858
|
if (pending.size)
|
|
412231
412859
|
this.abort();
|
|
412232
|
-
if (admitted && !terminalAccepted)
|
|
412860
|
+
if (admitted && !terminalAccepted && !this._updateRestartCheckpointForced)
|
|
412233
412861
|
lifecycle?.requestStop(lifecycle.snapshot().owner, "host session closed without inferring task completion");
|
|
412234
412862
|
this._saveCompletionLedgerSafe();
|
|
412235
412863
|
} catch (error) {
|
|
@@ -412242,6 +412870,8 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
412242
412870
|
}
|
|
412243
412871
|
/** Run a task through the agentic loop; a host session may not re-enter it. */
|
|
412244
412872
|
async run(task, context, actualUserGoal) {
|
|
412873
|
+
if (this._updateRestartCheckpointForced)
|
|
412874
|
+
throw new Error("This runner was retired for update; restore its durable checkpoint in a replacement process.");
|
|
412245
412875
|
if (this._exclusiveTaskOwner || this._activeDirectToolCalls)
|
|
412246
412876
|
throw new Error("A task or direct call already owns this runner.");
|
|
412247
412877
|
this._exclusiveTaskOwner = "model";
|
|
@@ -412430,6 +413060,36 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
412430
413060
|
this._taskEpoch = recovered.taskEpoch;
|
|
412431
413061
|
this._activeRunId = recovered.runId;
|
|
412432
413062
|
pausedCheckpoint = this._readPausedRunCheckpoint(recovered);
|
|
413063
|
+
if (pausedCheckpoint) {
|
|
413064
|
+
this._paused = true;
|
|
413065
|
+
this._modelRequestGeneration = pausedCheckpoint.modelRequestGeneration ?? 0;
|
|
413066
|
+
this._interruptionMessages = pausedCheckpoint.messages;
|
|
413067
|
+
this._interruptionToolCallLog = pausedCheckpoint.toolCallLog;
|
|
413068
|
+
this._taskState = { ...pausedCheckpoint.taskState, modifiedFiles: new Map(pausedCheckpoint.taskState.modifiedFiles) };
|
|
413069
|
+
try {
|
|
413070
|
+
await this._recoverForcedUpdateRequirements(pausedCheckpoint, recovered);
|
|
413071
|
+
} catch (error) {
|
|
413072
|
+
if (this._paused && this._updateAbortController.signal.aborted) {
|
|
413073
|
+
await this.waitIfPaused();
|
|
413074
|
+
}
|
|
413075
|
+
throw error;
|
|
413076
|
+
}
|
|
413077
|
+
if (this._forcedUpdateRequirementTaskReplaced)
|
|
413078
|
+
return {
|
|
413079
|
+
status: "incomplete",
|
|
413080
|
+
completed: false,
|
|
413081
|
+
turns: 0,
|
|
413082
|
+
toolCalls: 0,
|
|
413083
|
+
totalTokens: 0,
|
|
413084
|
+
promptTokens: 0,
|
|
413085
|
+
completionTokens: 0,
|
|
413086
|
+
estimatedTokens: 0,
|
|
413087
|
+
summary: "",
|
|
413088
|
+
durationMs: 0
|
|
413089
|
+
};
|
|
413090
|
+
if (pausedCheckpoint.forcedInterruption && pausedCheckpoint.completionLedger)
|
|
413091
|
+
pausedCheckpoint.completionLedger = reconcileForcedUpdateReadOnlyOperations(pausedCheckpoint.completionLedger, recovered);
|
|
413092
|
+
}
|
|
412433
413093
|
if (pausedCheckpoint) {
|
|
412434
413094
|
actualUserGoal = pausedCheckpoint.goal;
|
|
412435
413095
|
this._interruptionExplicitGoal = pausedCheckpoint.goal;
|
|
@@ -412449,6 +413109,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
412449
413109
|
const acknowledged = lifecycle.acknowledgeResume("restart recovery checks complete");
|
|
412450
413110
|
if (!acknowledged.accepted)
|
|
412451
413111
|
throw new Error(acknowledged.reason);
|
|
413112
|
+
this._paused = false;
|
|
412452
413113
|
const priorGeneration = pausedCheckpoint?.modelRequestGeneration ?? 0;
|
|
412453
413114
|
if (!Number.isSafeInteger(acknowledged.sequence) || acknowledged.sequence <= priorGeneration) {
|
|
412454
413115
|
throw new Error("paused_run_checkpoint_invalid_request_generation");
|
|
@@ -413204,6 +413865,8 @@ ${dynamicProjectContext}`
|
|
|
413204
413865
|
retainedTaskHistory = this._refreshPausedTelegramNativeContext(retainedTaskHistory, dynamicContextMessages, currentNativeInstruction);
|
|
413205
413866
|
messages2.splice(0, messages2.length, ...currentRuntimePolicy, ...retainedTaskHistory);
|
|
413206
413867
|
}
|
|
413868
|
+
if (pausedCheckpoint)
|
|
413869
|
+
this._restoreForcedIntake(pausedCheckpoint);
|
|
413207
413870
|
this._interruptionMessages = messages2;
|
|
413208
413871
|
const preflightMemoryRecall = await this._buildPreflightTaskMemoryRecall(persistentTaskGoal);
|
|
413209
413872
|
if (preflightMemoryRecall) {
|
|
@@ -420697,6 +421360,8 @@ Your most recent tool calls SUCCEEDED. If the task is complete, call task_comple
|
|
|
420697
421360
|
} catch {
|
|
420698
421361
|
}
|
|
420699
421362
|
}
|
|
421363
|
+
if (this._updateRestartCheckpointForced)
|
|
421364
|
+
throw new InputWaitInterruption();
|
|
420700
421365
|
let prevCycleSubstantiveProgress = substantiveProgressCount;
|
|
420701
421366
|
while (!completed && !this.aborted && !nonRetryableBackendFailure && !this._terminalRuntimeFailure && !this._completionIncompleteVerification && this.options.bruteForce && bruteForceCycle < this.options.bruteForceMaxCycles) {
|
|
420702
421367
|
bruteForceCycle++;
|
|
@@ -421464,6 +422129,8 @@ ${diagnosis}` : diagnosis;
|
|
|
421464
422129
|
} catch {
|
|
421465
422130
|
}
|
|
421466
422131
|
}
|
|
422132
|
+
if (this._updateRestartCheckpointForced)
|
|
422133
|
+
throw new InputWaitInterruption();
|
|
421467
422134
|
const durationMs = Date.now() - start;
|
|
421468
422135
|
const incompleteVerification = this._completionIncompleteVerification;
|
|
421469
422136
|
if (incompleteVerification && !summary) {
|
|
@@ -422775,6 +423442,8 @@ Result: ${summary.slice(0, 330)}`,
|
|
|
422775
423442
|
// -------------------------------------------------------------------------
|
|
422776
423443
|
/** Inject an image into the running conversation (for drag-drop / paste) */
|
|
422777
423444
|
injectImage(base64, mimeType, description) {
|
|
423445
|
+
if (this._updateRestartCheckpointForced)
|
|
423446
|
+
throw new Error("This runner was retired for update; retain input for the replacement process.");
|
|
422778
423447
|
const marker = `[IMAGE_BASE64:${mimeType}:${base64}]`;
|
|
422779
423448
|
this.pendingUserMessages.push(description ? `${description}
|
|
422780
423449
|
${marker}` : marker);
|