omnius 1.0.891 → 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 +1379 -411
- package/dist/tui/native/worker.js +46 -22
- package/dist/update-worker-runtime.js +463 -27
- package/dist/update-worker.js +3 -1
- package/docs/DISCOVERY.json +32 -2
- package/docs/DISCOVERY.md +2 -1
- package/docs/rea.md +39 -0
- package/docs/reference/configuration.md +21 -0
- package/docs/reference/slash-commands.md +78 -22
- package/npm-shrinkwrap.json +1345 -11
- package/package.json +3 -2
package/dist/library.js
CHANGED
|
@@ -3505,6 +3505,9 @@ var init_jetson_monitor = __esm({
|
|
|
3505
3505
|
function currentHostEnvironment() {
|
|
3506
3506
|
return globalThis.process?.env ?? {};
|
|
3507
3507
|
}
|
|
3508
|
+
function cpuOffloadAllowedFromEnv(env = currentHostEnvironment()) {
|
|
3509
|
+
return env[OMNIUS_CPU_OFFLOAD_ALLOWED_ENV] === "1";
|
|
3510
|
+
}
|
|
3508
3511
|
function normalizeGpuUuidList(value) {
|
|
3509
3512
|
if (value === void 0)
|
|
3510
3513
|
return void 0;
|
|
@@ -3541,12 +3544,13 @@ function isGpuUuidEnabled(uuid, enabledUuids = enabledGpuUuidsFromEnv()) {
|
|
|
3541
3544
|
return true;
|
|
3542
3545
|
return Boolean(uuid && enabledUuids.includes(uuid));
|
|
3543
3546
|
}
|
|
3544
|
-
var OMNIUS_GPU_ENABLED_UUIDS_ENV, OMNIUS_GPU_PREFERRED_UUID_ENV;
|
|
3547
|
+
var OMNIUS_GPU_ENABLED_UUIDS_ENV, OMNIUS_GPU_PREFERRED_UUID_ENV, OMNIUS_CPU_OFFLOAD_ALLOWED_ENV;
|
|
3545
3548
|
var init_gpu_selection = __esm({
|
|
3546
3549
|
"packages/schemas/dist/gpu-selection.js"() {
|
|
3547
3550
|
"use strict";
|
|
3548
3551
|
OMNIUS_GPU_ENABLED_UUIDS_ENV = "OMNIUS_GPU_ENABLED_UUIDS";
|
|
3549
3552
|
OMNIUS_GPU_PREFERRED_UUID_ENV = "OMNIUS_GPU_PREFERRED_UUID";
|
|
3553
|
+
OMNIUS_CPU_OFFLOAD_ALLOWED_ENV = "OMNIUS_CPU_OFFLOAD_ALLOWED";
|
|
3550
3554
|
}
|
|
3551
3555
|
});
|
|
3552
3556
|
|
|
@@ -82933,6 +82937,25 @@ function findBundledSkillsRoot(repoRoot) {
|
|
|
82933
82937
|
}
|
|
82934
82938
|
return null;
|
|
82935
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
|
+
}
|
|
82936
82959
|
function discoverSkills(repoRoot) {
|
|
82937
82960
|
const skills = /* @__PURE__ */ new Map();
|
|
82938
82961
|
const { frameworksDir, addonsDir, pluginsDir } = getAiwgPaths();
|
|
@@ -82985,6 +83008,9 @@ function discoverSkills(repoRoot) {
|
|
|
82985
83008
|
loadComponent(join20(bundledAddons, addon), `bundled-addon:${addon}`);
|
|
82986
83009
|
}
|
|
82987
83010
|
}
|
|
83011
|
+
const reaSkills = findBundledReaSkills(repoRoot);
|
|
83012
|
+
if (reaSkills)
|
|
83013
|
+
loadSkillsFromDir(reaSkills, "bundled-rea", skills);
|
|
82988
83014
|
const projectAiwg = join20(repoRoot, ".aiwg");
|
|
82989
83015
|
loadSkillsFromDir(join20(projectAiwg, "skills"), "project", skills);
|
|
82990
83016
|
loadCommandsFromDir(join20(projectAiwg, "commands"), "project", skills);
|
|
@@ -338743,7 +338769,7 @@ var init_ollama_pool = __esm({
|
|
|
338743
338769
|
continue;
|
|
338744
338770
|
}
|
|
338745
338771
|
const PROBE_GRACE_MS = 3e4;
|
|
338746
|
-
if (inst.state.inflight === 0 && Date.now() - inst.state.spawnedAtMs > PROBE_GRACE_MS && await this.isPartialVramSpilled(inst)) {
|
|
338772
|
+
if (!cpuOffloadAllowedFromEnv() && inst.state.inflight === 0 && Date.now() - inst.state.spawnedAtMs > PROBE_GRACE_MS && await this.isPartialVramSpilled(inst)) {
|
|
338747
338773
|
const reapedAtMs = Date.now();
|
|
338748
338774
|
await inst.terminate();
|
|
338749
338775
|
this.dropAffinityFor(inst.state.id);
|
|
@@ -352526,6 +352552,328 @@ var NativeOllamaToolCalls = class {
|
|
|
352526
352552
|
}
|
|
352527
352553
|
};
|
|
352528
352554
|
|
|
352555
|
+
// packages/orchestrator/dist/tool-argument-repair.js
|
|
352556
|
+
function shape2(parameters) {
|
|
352557
|
+
const properties = parameters["properties"];
|
|
352558
|
+
return {
|
|
352559
|
+
properties: new Set(properties && typeof properties === "object" && !Array.isArray(properties) ? Object.keys(properties) : []),
|
|
352560
|
+
required: Array.isArray(parameters["required"]) ? parameters["required"].filter((key) => typeof key === "string") : []
|
|
352561
|
+
};
|
|
352562
|
+
}
|
|
352563
|
+
function findBetterToolSchemaMatches(input) {
|
|
352564
|
+
const keys4 = [...new Set(input.providedKeys.filter((key) => !key.startsWith("_")))];
|
|
352565
|
+
if (!keys4.length)
|
|
352566
|
+
return [];
|
|
352567
|
+
const provided = new Set(keys4), requested = shape2(input.requestedParameters);
|
|
352568
|
+
const requestedMissing = requested.required.filter((key) => !provided.has(key)).length;
|
|
352569
|
+
const requestedUnknown = keys4.filter((key) => !requested.properties.has(key)).length;
|
|
352570
|
+
if (!requestedMissing && !requestedUnknown)
|
|
352571
|
+
return [];
|
|
352572
|
+
const matches = /* @__PURE__ */ new Map();
|
|
352573
|
+
for (const candidate of input.candidates) {
|
|
352574
|
+
if (candidate.name === input.requestedToolName)
|
|
352575
|
+
continue;
|
|
352576
|
+
const target2 = shape2(candidate.parameters ?? {});
|
|
352577
|
+
if (!target2.properties.size || target2.required.some((key) => !provided.has(key)) || keys4.some((key) => !target2.properties.has(key)))
|
|
352578
|
+
continue;
|
|
352579
|
+
matches.set(candidate.name, keys4.length * 2 + target2.required.length * 3);
|
|
352580
|
+
}
|
|
352581
|
+
return [...matches].sort(([left, leftScore], [right, rightScore]) => rightScore - leftScore || left.localeCompare(right)).slice(0, 3).map(([name]) => name);
|
|
352582
|
+
}
|
|
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
|
+
|
|
352719
|
+
// packages/orchestrator/dist/adjudication.js
|
|
352720
|
+
import { z as z18 } from "zod";
|
|
352721
|
+
var ADJUDICATION_TOOL_NAME = "adjudicate";
|
|
352722
|
+
var ADJUDICATION_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._:-]*$";
|
|
352723
|
+
function adjudicationArgumentRepairContract(error, argsHash) {
|
|
352724
|
+
let issues = [];
|
|
352725
|
+
try {
|
|
352726
|
+
const parsed = JSON.parse(error);
|
|
352727
|
+
if (Array.isArray(parsed))
|
|
352728
|
+
issues = parsed.filter((issue3) => issue3 && typeof issue3 === "object");
|
|
352729
|
+
} catch {
|
|
352730
|
+
}
|
|
352731
|
+
const parameters = adjudicationToolParameters();
|
|
352732
|
+
const fields2 = issues.slice(0, 8).map((issue3) => {
|
|
352733
|
+
const parts = Array.isArray(issue3.path) ? issue3.path : [];
|
|
352734
|
+
let schema = parameters;
|
|
352735
|
+
for (const part of parts) {
|
|
352736
|
+
const next = typeof part === "number" ? schema?.items : schema?.properties?.[part];
|
|
352737
|
+
schema = next && typeof next === "object" && !Array.isArray(next) ? next : void 0;
|
|
352738
|
+
}
|
|
352739
|
+
const constraints = schema && Object.fromEntries(Object.entries(schema).filter(([key]) => ["type", "minLength", "maxLength", "pattern", "enum", "minimum", "maximum", "minItems", "maxItems", "required"].includes(key)));
|
|
352740
|
+
return {
|
|
352741
|
+
path: parts.map((part) => typeof part === "number" ? `[${part}]` : part).join(".").replace(/\.\[/g, "[") || "arguments",
|
|
352742
|
+
message: String(issue3.message ?? "invalid value"),
|
|
352743
|
+
...constraints ? { schema: constraints } : {}
|
|
352744
|
+
};
|
|
352745
|
+
});
|
|
352746
|
+
return {
|
|
352747
|
+
reason_code: "invalid_tool_arguments",
|
|
352748
|
+
tool: ADJUDICATION_TOOL_NAME,
|
|
352749
|
+
retryable: false,
|
|
352750
|
+
...argsHash ? { args_sha256: argsHash } : {},
|
|
352751
|
+
fields: fields2.length ? fields2 : [{ path: "arguments", message: error.slice(0, 1400) }]
|
|
352752
|
+
};
|
|
352753
|
+
}
|
|
352754
|
+
function formatAdjudicationArgumentRepair(error, argsHash) {
|
|
352755
|
+
const contract = adjudicationArgumentRepairContract(error, argsHash);
|
|
352756
|
+
return [
|
|
352757
|
+
"[ADJUDICATION_ARGUMENT_REPAIR]",
|
|
352758
|
+
JSON.stringify(contract),
|
|
352759
|
+
...contract.fields.map((field) => `${field.path}: ${field.message}`),
|
|
352760
|
+
"Required keys for adjudicate: question, allowedOutcomes, evidence",
|
|
352761
|
+
`IDs must be 1–96 characters matching ${ADJUDICATION_ID_PATTERN}; no whitespace or sentence-valued IDs.`,
|
|
352762
|
+
'Format-only example: allowedOutcomes=["option_a","option_b"], context="option_a means the first described outcome; option_b means the second described outcome".',
|
|
352763
|
+
"Keep the user's actual outcome descriptions in context/evidence. Choose explicit stable IDs yourself; do not drop or silently rewrite evidence, manufacture an outcome, or substitute another tool for a field-format error.",
|
|
352764
|
+
"This exact argument instance cannot be retried unchanged. Correct the named values and retry immediately, or continue other substantive work. No panel ran for this rejected call."
|
|
352765
|
+
].join("\n");
|
|
352766
|
+
}
|
|
352767
|
+
var IdSchema = z18.string().trim().min(1).max(96).regex(new RegExp(ADJUDICATION_ID_PATTERN), "use a stable identifier without whitespace").describe("Stable identifier: 1–96 characters matching ^[A-Za-z0-9][A-Za-z0-9._:-]*$. Put prose descriptions in context/evidence, not IDs.");
|
|
352768
|
+
var AdjudicationEvidenceSchema = z18.object({
|
|
352769
|
+
id: IdSchema,
|
|
352770
|
+
content: z18.string().trim().min(1).max(32e3),
|
|
352771
|
+
source: z18.string().trim().min(1).max(500),
|
|
352772
|
+
kind: z18.enum([
|
|
352773
|
+
"fact",
|
|
352774
|
+
"observation",
|
|
352775
|
+
"artifact",
|
|
352776
|
+
"test_result",
|
|
352777
|
+
"testimony",
|
|
352778
|
+
"constraint",
|
|
352779
|
+
"precedent"
|
|
352780
|
+
]).default("observation"),
|
|
352781
|
+
observedAt: z18.string().trim().max(80).optional(),
|
|
352782
|
+
sha256: z18.string().trim().regex(/^[a-fA-F0-9]{64}$/).optional(),
|
|
352783
|
+
reliability: z18.number().min(0).max(1).optional()
|
|
352784
|
+
});
|
|
352785
|
+
var AdjudicationArgumentSchema = z18.object({
|
|
352786
|
+
id: IdSchema,
|
|
352787
|
+
position: z18.string().trim().min(1).max(160),
|
|
352788
|
+
claim: z18.string().trim().min(1).max(4e3),
|
|
352789
|
+
citedEvidenceIds: z18.array(IdSchema).min(1).max(64),
|
|
352790
|
+
submittedBy: z18.string().trim().max(160).optional()
|
|
352791
|
+
});
|
|
352792
|
+
var AdjudicationConstituentInputSchema = z18.object({
|
|
352793
|
+
id: IdSchema.optional(),
|
|
352794
|
+
label: z18.string().trim().min(1).max(120),
|
|
352795
|
+
question: z18.string().trim().min(1).max(2e3),
|
|
352796
|
+
instructions: z18.string().trim().max(2e3).optional(),
|
|
352797
|
+
evidenceIds: z18.array(IdSchema).min(1).max(128).optional(),
|
|
352798
|
+
argumentIds: z18.array(IdSchema).max(64).optional(),
|
|
352799
|
+
decisionRuleIds: z18.array(IdSchema).max(32).optional()
|
|
352800
|
+
});
|
|
352801
|
+
var AdjudicationInputSchema = z18.object({
|
|
352802
|
+
caseId: IdSchema.optional(),
|
|
352803
|
+
question: z18.string().trim().min(1).max(4e3).describe("The exact decision question. Ask one decision only."),
|
|
352804
|
+
context: z18.string().trim().max(8e3).optional().describe("Neutral context needed to interpret the record, including each stable outcome ID's prose meaning."),
|
|
352805
|
+
exclusions: z18.array(z18.string().trim().min(1).max(2e3)).max(32).default([]).describe("Explicitly excluded material or considerations that the panel must not admit."),
|
|
352806
|
+
allowedOutcomes: z18.array(IdSchema).min(2).max(12).describe("Closed set of stable verdict IDs, for example option_a and option_b; preserve their prose meanings in context. insufficient_evidence is reserved by the tool."),
|
|
352807
|
+
decisionRules: z18.array(z18.string().trim().min(1).max(2e3)).max(24).default([]).describe("Rules the judge must apply."),
|
|
352808
|
+
burdenOfProof: z18.enum([
|
|
352809
|
+
"best_supported",
|
|
352810
|
+
"preponderance",
|
|
352811
|
+
"clear_and_convincing",
|
|
352812
|
+
"beyond_reasonable_doubt",
|
|
352813
|
+
"risk_averse"
|
|
352814
|
+
]).default("best_supported"),
|
|
352815
|
+
evidence: z18.array(AdjudicationEvidenceSchema).min(1).max(128),
|
|
352816
|
+
arguments: z18.array(AdjudicationArgumentSchema).max(64).default([]),
|
|
352817
|
+
constituents: z18.array(AdjudicationConstituentInputSchema).min(2).max(6).optional().describe("Optional independent focus assignments. Omit to let the case framer derive them."),
|
|
352818
|
+
panelSize: z18.number().int().min(2).max(6).default(3),
|
|
352819
|
+
maxConcurrency: z18.number().int().min(1).max(6).default(3),
|
|
352820
|
+
quorum: z18.number().int().min(2).max(6).optional(),
|
|
352821
|
+
constituentExecution: z18.enum(["auto", "full_sub_agent", "direct"]).default("auto").describe("auto uses the dedicated full_sub_agent profile when available, otherwise the direct bounded fallback."),
|
|
352822
|
+
timeoutMs: z18.number().int().min(5e3).max(6e5).default(12e4),
|
|
352823
|
+
maxTokensPerConstituent: z18.number().int().min(512).max(8192).default(2048),
|
|
352824
|
+
maxJudgeTokens: z18.number().int().min(768).max(12288).default(3072)
|
|
352825
|
+
});
|
|
352826
|
+
function adjudicationToolParameters() {
|
|
352827
|
+
const { $schema: _dialect, ...parameters } = z18.toJSONSchema(AdjudicationInputSchema, { target: "draft-7", io: "input" });
|
|
352828
|
+
return parameters;
|
|
352829
|
+
}
|
|
352830
|
+
var PlannerResponseSchema = z18.object({
|
|
352831
|
+
schemaVersion: z18.literal(1),
|
|
352832
|
+
caseId: IdSchema,
|
|
352833
|
+
assignments: z18.array(z18.object({
|
|
352834
|
+
id: IdSchema,
|
|
352835
|
+
label: z18.string().trim().min(1).max(120),
|
|
352836
|
+
question: z18.string().trim().min(1).max(2e3),
|
|
352837
|
+
instructions: z18.string().trim().max(2e3).default(""),
|
|
352838
|
+
evidenceIds: z18.array(IdSchema).min(1).max(128),
|
|
352839
|
+
argumentIds: z18.array(IdSchema).max(64).default([]),
|
|
352840
|
+
decisionRuleIds: z18.array(IdSchema).min(1).max(32)
|
|
352841
|
+
})).min(2).max(6)
|
|
352842
|
+
});
|
|
352843
|
+
var ConstituentResponseSchema = z18.object({
|
|
352844
|
+
schemaVersion: z18.literal(1),
|
|
352845
|
+
caseId: IdSchema,
|
|
352846
|
+
constituentId: IdSchema,
|
|
352847
|
+
assessment: z18.string().trim().min(20).max(8e3),
|
|
352848
|
+
recommendation: IdSchema,
|
|
352849
|
+
confidence: z18.number().min(0).max(1),
|
|
352850
|
+
citedEvidenceIds: z18.array(IdSchema).min(1).max(128),
|
|
352851
|
+
claims: z18.array(z18.object({
|
|
352852
|
+
claim: z18.string().trim().min(1).max(2e3),
|
|
352853
|
+
evidenceIds: z18.array(IdSchema).min(1).max(64)
|
|
352854
|
+
})).min(1).max(24),
|
|
352855
|
+
counterarguments: z18.array(z18.string().trim().min(1).max(2e3)).max(16).default([]),
|
|
352856
|
+
uncertainties: z18.array(z18.string().trim().min(1).max(2e3)).max(16).default([])
|
|
352857
|
+
});
|
|
352858
|
+
var JudgeResponseSchema = z18.object({
|
|
352859
|
+
schemaVersion: z18.literal(1),
|
|
352860
|
+
caseId: IdSchema,
|
|
352861
|
+
verdict: IdSchema,
|
|
352862
|
+
confidence: z18.number().min(0).max(1),
|
|
352863
|
+
rationale: z18.string().trim().min(30).max(12e3),
|
|
352864
|
+
citedEvidenceIds: z18.array(IdSchema).min(1).max(128),
|
|
352865
|
+
consideredConstituentIds: z18.array(IdSchema).min(2).max(6),
|
|
352866
|
+
acceptedFindingIds: z18.array(IdSchema).max(144),
|
|
352867
|
+
rejectedFindingIds: z18.array(IdSchema).max(144),
|
|
352868
|
+
dissent: z18.array(z18.object({
|
|
352869
|
+
constituentId: IdSchema,
|
|
352870
|
+
recommendation: IdSchema,
|
|
352871
|
+
summary: z18.string().trim().min(1).max(2e3)
|
|
352872
|
+
})).max(6).default([]),
|
|
352873
|
+
unresolvedQuestions: z18.array(z18.string().trim().min(1).max(2e3)).max(24).default([]),
|
|
352874
|
+
nextAction: z18.string().trim().min(1).max(4e3)
|
|
352875
|
+
});
|
|
352876
|
+
|
|
352529
352877
|
// packages/orchestrator/dist/openai-chat-stream-parser.js
|
|
352530
352878
|
var object10 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
|
|
352531
352879
|
var MAX_PACKET_BYTES = 8388608;
|
|
@@ -355125,15 +355473,15 @@ var SelfImprovementArchive = class {
|
|
|
355125
355473
|
import { createHash as createHash69, randomUUID as randomUUID41 } from "node:crypto";
|
|
355126
355474
|
import { closeSync as closeSync12, existsSync as existsSync30, fsyncSync as fsyncSync6, mkdirSync as mkdirSync24, openSync as openSync12, readFileSync as readFileSync34, renameSync as renameSync12, unlinkSync as unlinkSync12, writeFileSync as writeFileSync22 } from "node:fs";
|
|
355127
355475
|
import { dirname as dirname23, join as join40 } from "node:path";
|
|
355128
|
-
import { z as
|
|
355476
|
+
import { z as z20 } from "zod";
|
|
355129
355477
|
|
|
355130
355478
|
// packages/orchestrator/dist/commandEvidenceReceipt.js
|
|
355131
|
-
import { z as
|
|
355132
|
-
var token2 =
|
|
355133
|
-
var timestamp2 =
|
|
355134
|
-
var integer3 =
|
|
355135
|
-
var CommandEvidenceReceiptSchema =
|
|
355136
|
-
schema:
|
|
355479
|
+
import { z as z19 } from "zod";
|
|
355480
|
+
var token2 = z19.string().refine((value) => value.trim().length > 0 && !value.includes("\0"));
|
|
355481
|
+
var timestamp2 = z19.string().datetime({ offset: true });
|
|
355482
|
+
var integer3 = z19.number().int().safe();
|
|
355483
|
+
var CommandEvidenceReceiptSchema = z19.object({
|
|
355484
|
+
schema: z19.literal("omnius.command-evidence-receipt.v1"),
|
|
355137
355485
|
command: token2,
|
|
355138
355486
|
canonicalCommand: token2,
|
|
355139
355487
|
cwd: token2,
|
|
@@ -355141,20 +355489,20 @@ var CommandEvidenceReceiptSchema = z18.object({
|
|
|
355141
355489
|
primaryCommand: token2.optional(),
|
|
355142
355490
|
primaryExitCode: integer3.nullable().optional(),
|
|
355143
355491
|
runnerExitCode: integer3.nullable().optional(),
|
|
355144
|
-
primaryExitProvenance:
|
|
355145
|
-
pipefail:
|
|
355146
|
-
timedOut:
|
|
355492
|
+
primaryExitProvenance: z19.enum(["runner_process", "trailing_exit_reporter"]).optional(),
|
|
355493
|
+
pipefail: z19.boolean(),
|
|
355494
|
+
timedOut: z19.boolean(),
|
|
355147
355495
|
startedAtIso: timestamp2,
|
|
355148
355496
|
finishedAtIso: timestamp2,
|
|
355149
|
-
shellRunId:
|
|
355497
|
+
shellRunId: z19.string().uuid().optional(),
|
|
355150
355498
|
timeoutMs: integer3.positive().nullable().optional(),
|
|
355151
|
-
cancelled:
|
|
355499
|
+
cancelled: z19.boolean().optional(),
|
|
355152
355500
|
signal: token2.nullable().optional(),
|
|
355153
|
-
observation:
|
|
355501
|
+
observation: z19.object({ kind: z19.literal("search_no_match") }).strict().optional(),
|
|
355154
355502
|
outputRef: token2.optional(),
|
|
355155
|
-
observedPaths:
|
|
355156
|
-
artifactHashes:
|
|
355157
|
-
declaredVerification:
|
|
355503
|
+
observedPaths: z19.array(token2).optional(),
|
|
355504
|
+
artifactHashes: z19.array(z19.object({ path: token2, sha256: z19.string().regex(/^[a-f0-9]{64}$/) }).strict()).optional(),
|
|
355505
|
+
declaredVerification: z19.object({ protocol: z19.literal("OMNIUS_VERIFICATION_RESULT"), outcome: z19.enum(["pass", "fail"]) }).strict().optional()
|
|
355158
355506
|
}).strict().refine((value) => Date.parse(value.finishedAtIso) >= Date.parse(value.startedAtIso));
|
|
355159
355507
|
function parseCommandEvidenceReceipt(value) {
|
|
355160
355508
|
try {
|
|
@@ -355167,21 +355515,21 @@ function parseCommandEvidenceReceipt(value) {
|
|
|
355167
355515
|
|
|
355168
355516
|
// packages/orchestrator/dist/conversationReportEvidence.js
|
|
355169
355517
|
var SCHEMA = "omnius.conversation-report-evidence.v2";
|
|
355170
|
-
var token3 =
|
|
355171
|
-
var timestamp3 =
|
|
355172
|
-
var integer4 =
|
|
355173
|
-
var identitySchema =
|
|
355174
|
-
var reference =
|
|
355175
|
-
var paths =
|
|
355176
|
-
var deliveryReceiptSchema =
|
|
355177
|
-
schema:
|
|
355518
|
+
var token3 = z20.string().refine((value) => value.trim().length > 0 && !value.includes("\0"));
|
|
355519
|
+
var timestamp3 = z20.string().datetime({ offset: true });
|
|
355520
|
+
var integer4 = z20.number().int().safe();
|
|
355521
|
+
var identitySchema = z20.object({ sessionId: token3, runId: token3, taskEpoch: integer4.nonnegative() }).strict();
|
|
355522
|
+
var reference = z20.string().regex(/^omnius-artifact:\/\/sha256\/[a-f0-9]{64}$/);
|
|
355523
|
+
var paths = z20.array(token3);
|
|
355524
|
+
var deliveryReceiptSchema = z20.object({
|
|
355525
|
+
schema: z20.literal("omnius.completion-delivery-receipt.v1"),
|
|
355178
355526
|
provider: token3,
|
|
355179
355527
|
target: token3,
|
|
355180
355528
|
receiptId: token3,
|
|
355181
355529
|
deliveredAtIso: timestamp3,
|
|
355182
355530
|
artifactPaths: paths.optional()
|
|
355183
355531
|
}).strict();
|
|
355184
|
-
var objectiveEvidenceKindSchema =
|
|
355532
|
+
var objectiveEvidenceKindSchema = z20.enum([
|
|
355185
355533
|
"visible_response",
|
|
355186
355534
|
"observation",
|
|
355187
355535
|
"mutation",
|
|
@@ -355193,79 +355541,79 @@ var objectiveEvidenceKindSchema = z19.enum([
|
|
|
355193
355541
|
"authenticated_session",
|
|
355194
355542
|
"human_input"
|
|
355195
355543
|
]);
|
|
355196
|
-
var externalEffectReceiptSchema =
|
|
355197
|
-
schema:
|
|
355544
|
+
var externalEffectReceiptSchema = z20.object({
|
|
355545
|
+
schema: z20.literal("omnius.external-effect-receipt.v1"),
|
|
355198
355546
|
effectKind: token3,
|
|
355199
355547
|
semanticTarget: token3,
|
|
355200
355548
|
idempotencyKey: token3,
|
|
355201
|
-
effectState:
|
|
355549
|
+
effectState: z20.enum(["pending", "applied", "absent", "unknown"]),
|
|
355202
355550
|
artifactRevision: token3.optional(),
|
|
355203
355551
|
evidenceId: token3,
|
|
355204
|
-
criterionIds:
|
|
355205
|
-
evidenceKinds:
|
|
355206
|
-
destination:
|
|
355552
|
+
criterionIds: z20.array(token3),
|
|
355553
|
+
evidenceKinds: z20.array(objectiveEvidenceKindSchema).optional(),
|
|
355554
|
+
destination: z20.object({ url: z20.string().url(), provider: token3 }).strict().optional()
|
|
355207
355555
|
}).strict();
|
|
355208
|
-
var verificationReceiptSchema =
|
|
355209
|
-
schema:
|
|
355556
|
+
var verificationReceiptSchema = z20.object({
|
|
355557
|
+
schema: z20.literal("omnius.verification-receipt.v1"),
|
|
355210
355558
|
evidenceId: token3,
|
|
355211
355559
|
criterionId: token3,
|
|
355212
355560
|
artifactEvidenceId: token3,
|
|
355213
355561
|
artifactRevision: token3.optional(),
|
|
355214
355562
|
verifierMethod: token3,
|
|
355215
|
-
outcome:
|
|
355216
|
-
evidenceIds:
|
|
355217
|
-
evidenceKinds:
|
|
355563
|
+
outcome: z20.enum(["passed", "artifact_failed", "verifier_invalid", "downstream_auth_required", "inconclusive"]),
|
|
355564
|
+
evidenceIds: z20.array(token3),
|
|
355565
|
+
evidenceKinds: z20.array(objectiveEvidenceKindSchema).optional()
|
|
355218
355566
|
}).strict();
|
|
355219
|
-
var externalBlockerSchema =
|
|
355220
|
-
schema:
|
|
355221
|
-
criterionIds:
|
|
355567
|
+
var externalBlockerSchema = z20.object({
|
|
355568
|
+
schema: z20.literal("omnius.objective-external-blocker.v1"),
|
|
355569
|
+
criterionIds: z20.array(token3),
|
|
355222
355570
|
evidenceId: token3,
|
|
355223
355571
|
blockerKind: token3,
|
|
355224
|
-
retryable:
|
|
355572
|
+
retryable: z20.boolean()
|
|
355225
355573
|
}).strict();
|
|
355226
|
-
var evidenceSchema =
|
|
355574
|
+
var evidenceSchema = z20.object({
|
|
355227
355575
|
id: token3,
|
|
355228
|
-
kind:
|
|
355576
|
+
kind: z20.literal("tool_result"),
|
|
355229
355577
|
observedAtIso: timestamp3,
|
|
355230
|
-
summary:
|
|
355578
|
+
summary: z20.string(),
|
|
355231
355579
|
toolName: token3,
|
|
355232
|
-
success:
|
|
355580
|
+
success: z20.boolean().optional(),
|
|
355233
355581
|
rawRef: token3.optional(),
|
|
355234
355582
|
targetPaths: paths.optional(),
|
|
355235
|
-
role:
|
|
355583
|
+
role: z20.enum(["observation", "verification", "mutation", "blocker", "delivery"]).optional(),
|
|
355236
355584
|
family: token3.optional(),
|
|
355237
|
-
verificationImpact:
|
|
355238
|
-
metrics:
|
|
355585
|
+
verificationImpact: z20.enum(["invalidates", "neutral"]).optional(),
|
|
355586
|
+
metrics: z20.record(z20.string(), z20.unknown()).optional(),
|
|
355239
355587
|
receipt: CommandEvidenceReceiptSchema.optional(),
|
|
355240
355588
|
deliveryReceipt: deliveryReceiptSchema.optional(),
|
|
355241
|
-
progressClass:
|
|
355242
|
-
criterionIds:
|
|
355243
|
-
objectiveEvidenceKinds:
|
|
355589
|
+
progressClass: z20.enum(["work_product", "control_bookkeeping", "observation", "blocker"]).optional(),
|
|
355590
|
+
criterionIds: z20.array(token3).optional(),
|
|
355591
|
+
objectiveEvidenceKinds: z20.array(objectiveEvidenceKindSchema).optional(),
|
|
355244
355592
|
externalEffectReceipt: externalEffectReceiptSchema.optional(),
|
|
355245
355593
|
verificationReceipt: verificationReceiptSchema.optional(),
|
|
355246
355594
|
externalBlocker: externalBlockerSchema.optional()
|
|
355247
355595
|
}).strict();
|
|
355248
|
-
var chunkSchema =
|
|
355249
|
-
schema:
|
|
355596
|
+
var chunkSchema = z20.object({
|
|
355597
|
+
schema: z20.literal(SCHEMA),
|
|
355250
355598
|
identity: identitySchema,
|
|
355251
355599
|
previousReference: reference.nullable(),
|
|
355252
355600
|
sequence: integer4.positive(),
|
|
355253
355601
|
startEntry: integer4.nonnegative(),
|
|
355254
355602
|
entryCount: integer4.nonnegative(),
|
|
355255
|
-
entries:
|
|
355603
|
+
entries: z20.array(z20.object({ callId: token3, evidence: evidenceSchema }).strict()),
|
|
355256
355604
|
ledgerCreatedAtIso: timestamp3,
|
|
355257
355605
|
updatedAtIso: timestamp3,
|
|
355258
355606
|
recoveryGap: token3.max(500).optional()
|
|
355259
355607
|
}).strict();
|
|
355260
|
-
var pointerSchema =
|
|
355261
|
-
schema:
|
|
355608
|
+
var pointerSchema = z20.object({
|
|
355609
|
+
schema: z20.literal(SCHEMA),
|
|
355262
355610
|
identity: identitySchema,
|
|
355263
355611
|
reference,
|
|
355264
355612
|
entryCount: integer4.nonnegative(),
|
|
355265
355613
|
chunkCount: integer4.positive()
|
|
355266
355614
|
}).strict();
|
|
355267
|
-
var pendingSchema =
|
|
355268
|
-
schema:
|
|
355615
|
+
var pendingSchema = z20.object({
|
|
355616
|
+
schema: z20.literal(SCHEMA),
|
|
355269
355617
|
identity: identitySchema,
|
|
355270
355618
|
previousReference: reference.nullable(),
|
|
355271
355619
|
previousEntryCount: integer4.nonnegative(),
|
|
@@ -355472,7 +355820,7 @@ var ConversationReportEvidence = class {
|
|
|
355472
355820
|
this.persistedChunkCount = pointer.chunkCount;
|
|
355473
355821
|
this.persistedGap = chain[0].recoveryGap;
|
|
355474
355822
|
} catch (error) {
|
|
355475
|
-
const detail = error instanceof
|
|
355823
|
+
const detail = error instanceof z20.ZodError || error instanceof SyntaxError ? "Saved report evidence has invalid fields or contains task authority." : error instanceof Error ? error.message : String(error);
|
|
355476
355824
|
this.recoveryGap = `Earlier conversation evidence could not be restored: ${detail}${pendingGap ? ` ${pendingGap}` : ""}`.slice(0, 500);
|
|
355477
355825
|
}
|
|
355478
355826
|
}
|
|
@@ -355607,7 +355955,7 @@ init_dist5();
|
|
|
355607
355955
|
import { createHash as createHash71 } from "node:crypto";
|
|
355608
355956
|
import { closeSync as closeSync14, existsSync as existsSync32, fsyncSync as fsyncSync8, lstatSync as lstatSync4, mkdirSync as mkdirSync26, openSync as openSync14, readFileSync as readFileSync36, readdirSync as readdirSync11, realpathSync as realpathSync10, renameSync as renameSync14, statSync as statSync17, unlinkSync as unlinkSync14, writeFileSync as writeFileSync24 } from "node:fs";
|
|
355609
355957
|
import { dirname as dirname24, isAbsolute as isAbsolute13, join as join42, relative as relative9, resolve as resolve27 } from "node:path";
|
|
355610
|
-
import { z as
|
|
355958
|
+
import { z as z21 } from "zod";
|
|
355611
355959
|
|
|
355612
355960
|
// packages/orchestrator/dist/contentAddressedArtifactStore.js
|
|
355613
355961
|
import { createHash as createHash70, randomUUID as randomUUID42 } from "node:crypto";
|
|
@@ -356478,10 +356826,10 @@ var equal = (a, b) => canonical6(a) === canonical6(b);
|
|
|
356478
356826
|
function fail3(reason) {
|
|
356479
356827
|
throw new Error(`feature_workflow_${reason}`);
|
|
356480
356828
|
}
|
|
356481
|
-
var token4 =
|
|
356482
|
-
var integer5 =
|
|
356483
|
-
var ref7 =
|
|
356484
|
-
var digest5 =
|
|
356829
|
+
var token4 = z21.string().trim().min(1).max(1e3);
|
|
356830
|
+
var integer5 = z21.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
356831
|
+
var ref7 = z21.string().regex(/^omnius-artifact:\/\/sha256\/[a-f0-9]{64}$/);
|
|
356832
|
+
var digest5 = z21.string().regex(/^[a-f0-9]{64}$/);
|
|
356485
356833
|
function featureWorkflowInputArtifactsHash(artifacts) {
|
|
356486
356834
|
return createHash71("sha256").update(JSON.stringify([...artifacts].sort((a, b) => a.slotId.localeCompare(b.slotId)).map((a) => ({
|
|
356487
356835
|
slotId: a.slotId,
|
|
@@ -356489,13 +356837,13 @@ function featureWorkflowInputArtifactsHash(artifacts) {
|
|
|
356489
356837
|
content: a.content
|
|
356490
356838
|
})))).digest("hex");
|
|
356491
356839
|
}
|
|
356492
|
-
var identitySchema2 =
|
|
356840
|
+
var identitySchema2 = z21.object({
|
|
356493
356841
|
sessionId: token4,
|
|
356494
356842
|
runId: token4,
|
|
356495
356843
|
taskEpoch: integer5,
|
|
356496
356844
|
generation: integer5
|
|
356497
356845
|
}).strict();
|
|
356498
|
-
var bindingSchema =
|
|
356846
|
+
var bindingSchema = z21.object({
|
|
356499
356847
|
parentOperationId: token4,
|
|
356500
356848
|
parentRunId: token4,
|
|
356501
356849
|
parentGeneration: integer5,
|
|
@@ -356503,22 +356851,22 @@ var bindingSchema = z20.object({
|
|
|
356503
356851
|
cardId: token4,
|
|
356504
356852
|
planReference: ref7,
|
|
356505
356853
|
cardContract: digest5,
|
|
356506
|
-
inputSlots:
|
|
356507
|
-
kind:
|
|
356508
|
-
readOnly:
|
|
356509
|
-
ownedFiles:
|
|
356854
|
+
inputSlots: z21.record(token4, ref7),
|
|
356855
|
+
kind: z21.enum(["work", "review", "verification"]),
|
|
356856
|
+
readOnly: z21.boolean(),
|
|
356857
|
+
ownedFiles: z21.array(token4).max(128),
|
|
356510
356858
|
inputArtifactsHash: digest5
|
|
356511
356859
|
}).strict();
|
|
356512
356860
|
var childSchema = bindingSchema.extend({
|
|
356513
|
-
schema:
|
|
356861
|
+
schema: z21.literal("omnius.feature-workflow-child-receipt.v1"),
|
|
356514
356862
|
childId: token4,
|
|
356515
356863
|
childRunId: token4,
|
|
356516
356864
|
childTaskEpoch: integer5,
|
|
356517
356865
|
childInputHash: digest5,
|
|
356518
|
-
status:
|
|
356866
|
+
status: z21.enum(["completed", "failed", "cancelled", "running"]),
|
|
356519
356867
|
terminalReceiptId: token4.optional()
|
|
356520
356868
|
}).strict();
|
|
356521
|
-
var slotSchema =
|
|
356869
|
+
var slotSchema = z21.object({
|
|
356522
356870
|
reference: ref7,
|
|
356523
356871
|
cardId: token4,
|
|
356524
356872
|
cardContract: digest5,
|
|
@@ -356527,61 +356875,61 @@ var slotSchema = z20.object({
|
|
|
356527
356875
|
mutationSequence: integer5,
|
|
356528
356876
|
workspaceRevision: digest5
|
|
356529
356877
|
}).strict();
|
|
356530
|
-
var operationSchema =
|
|
356878
|
+
var operationSchema = z21.object({
|
|
356531
356879
|
binding: bindingSchema,
|
|
356532
356880
|
actorId: token4,
|
|
356533
356881
|
toolName: token4,
|
|
356534
356882
|
command: token4.optional(),
|
|
356535
|
-
effect:
|
|
356536
|
-
state:
|
|
356883
|
+
effect: z21.enum(["read_only", "local_mutation", "external_effect"]),
|
|
356884
|
+
state: z21.enum(["pending", "interrupted"]),
|
|
356537
356885
|
mutationSequence: integer5,
|
|
356538
356886
|
workspaceRevision: digest5
|
|
356539
356887
|
}).strict();
|
|
356540
|
-
var resultSchema =
|
|
356888
|
+
var resultSchema = z21.object({
|
|
356541
356889
|
binding: bindingSchema,
|
|
356542
356890
|
actorId: token4,
|
|
356543
|
-
success:
|
|
356891
|
+
success: z21.boolean(),
|
|
356544
356892
|
receiptReference: ref7,
|
|
356545
|
-
reviewDisposition:
|
|
356893
|
+
reviewDisposition: z21.enum(["approved", "changes_requested"]).optional(),
|
|
356546
356894
|
childReceipt: childSchema.optional(),
|
|
356547
|
-
commandReceipt:
|
|
356895
|
+
commandReceipt: z21.unknown().optional(),
|
|
356548
356896
|
childReportReference: ref7.optional(),
|
|
356549
|
-
blockers:
|
|
356550
|
-
unresolvedQuestions:
|
|
356897
|
+
blockers: z21.array(token4).max(96),
|
|
356898
|
+
unresolvedQuestions: z21.array(token4).max(32),
|
|
356551
356899
|
mutationSequence: integer5,
|
|
356552
356900
|
workspaceRevision: digest5
|
|
356553
356901
|
}).strict();
|
|
356554
|
-
var commandReceiptSchema =
|
|
356555
|
-
schema:
|
|
356902
|
+
var commandReceiptSchema = z21.object({
|
|
356903
|
+
schema: z21.literal("omnius.command-evidence-receipt.v1"),
|
|
356556
356904
|
command: token4,
|
|
356557
356905
|
canonicalCommand: token4,
|
|
356558
356906
|
cwd: token4,
|
|
356559
|
-
pipefail:
|
|
356560
|
-
timedOut:
|
|
356561
|
-
cancelled:
|
|
356562
|
-
startedAtIso:
|
|
356563
|
-
finishedAtIso:
|
|
356564
|
-
exitCode:
|
|
356565
|
-
primaryExitCode:
|
|
356907
|
+
pipefail: z21.boolean(),
|
|
356908
|
+
timedOut: z21.boolean(),
|
|
356909
|
+
cancelled: z21.boolean().optional(),
|
|
356910
|
+
startedAtIso: z21.string().datetime(),
|
|
356911
|
+
finishedAtIso: z21.string().datetime(),
|
|
356912
|
+
exitCode: z21.number().int().nullable().optional(),
|
|
356913
|
+
primaryExitCode: z21.number().int().nullable().optional()
|
|
356566
356914
|
}).passthrough();
|
|
356567
|
-
var checkpointSchema =
|
|
356568
|
-
schema:
|
|
356915
|
+
var checkpointSchema = z21.object({
|
|
356916
|
+
schema: z21.literal(SCHEMA2),
|
|
356569
356917
|
identity: identitySchema2,
|
|
356570
356918
|
boardRunId: token4,
|
|
356571
356919
|
planReference: ref7,
|
|
356572
356920
|
sequence: integer5,
|
|
356573
356921
|
mutationSequence: integer5,
|
|
356574
|
-
slots:
|
|
356575
|
-
operations:
|
|
356576
|
-
results:
|
|
356577
|
-
recentSettlements:
|
|
356578
|
-
retired:
|
|
356922
|
+
slots: z21.record(token4, slotSchema),
|
|
356923
|
+
operations: z21.record(token4, operationSchema),
|
|
356924
|
+
results: z21.record(token4, resultSchema),
|
|
356925
|
+
recentSettlements: z21.array(z21.object({ operationId: token4, resultHash: digest5 }).strict()).max(256),
|
|
356926
|
+
retired: z21.object({
|
|
356579
356927
|
reason: token4,
|
|
356580
|
-
at:
|
|
356928
|
+
at: z21.string().datetime(),
|
|
356581
356929
|
toEpoch: integer5.optional()
|
|
356582
356930
|
}).strict().optional(),
|
|
356583
356931
|
workingDir: token4,
|
|
356584
|
-
adoptions:
|
|
356932
|
+
adoptions: z21.array(z21.object({
|
|
356585
356933
|
from: identitySchema2,
|
|
356586
356934
|
to: identitySchema2,
|
|
356587
356935
|
sourceCheckpointReference: ref7,
|
|
@@ -356858,8 +357206,8 @@ var FeatureWorkflowController = class {
|
|
|
356858
357206
|
return this.state;
|
|
356859
357207
|
}
|
|
356860
357208
|
assertCurrentSelector() {
|
|
356861
|
-
const actual = existsSync32(this.selectorPath) ?
|
|
356862
|
-
schema:
|
|
357209
|
+
const actual = existsSync32(this.selectorPath) ? z21.object({
|
|
357210
|
+
schema: z21.literal(SELECTOR_SCHEMA),
|
|
356863
357211
|
checkpointReference: ref7
|
|
356864
357212
|
}).strict().parse(JSON.parse(readFileSync36(this.selectorPath, "utf8"))).checkpointReference : null;
|
|
356865
357213
|
if (actual !== this.selectorReference) {
|
|
@@ -356995,8 +357343,8 @@ var FeatureWorkflowController = class {
|
|
|
356995
357343
|
try {
|
|
356996
357344
|
if (!existsSync32(this.selectorPath)) {
|
|
356997
357345
|
const matches = this.selectorCandidates().filter((file) => {
|
|
356998
|
-
const selector2 =
|
|
356999
|
-
schema:
|
|
357346
|
+
const selector2 = z21.object({
|
|
357347
|
+
schema: z21.literal(SELECTOR_SCHEMA),
|
|
357000
357348
|
checkpointReference: ref7
|
|
357001
357349
|
}).strict().parse(JSON.parse(readFileSync36(join42(dirname24(this.selectorPath), file), "utf8")));
|
|
357002
357350
|
const state2 = checkpointSchema.parse(JSON.parse(this.store.read(selector2.checkpointReference).content));
|
|
@@ -357008,8 +357356,8 @@ var FeatureWorkflowController = class {
|
|
|
357008
357356
|
fail3("same_run_checkpoint_not_unique");
|
|
357009
357357
|
this.selectorPath = join42(dirname24(this.selectorPath), matches[0]);
|
|
357010
357358
|
}
|
|
357011
|
-
const selector =
|
|
357012
|
-
schema:
|
|
357359
|
+
const selector = z21.object({
|
|
357360
|
+
schema: z21.literal(SELECTOR_SCHEMA),
|
|
357013
357361
|
checkpointReference: ref7
|
|
357014
357362
|
}).strict().parse(JSON.parse(readFileSync36(this.selectorPath, "utf8")));
|
|
357015
357363
|
const state = checkpointSchema.parse(JSON.parse(this.store.read(selector.checkpointReference).content));
|
|
@@ -357063,8 +357411,8 @@ var FeatureWorkflowController = class {
|
|
|
357063
357411
|
return [];
|
|
357064
357412
|
const results = [];
|
|
357065
357413
|
for (const file of this.selectorCandidates()) {
|
|
357066
|
-
const selector =
|
|
357067
|
-
schema:
|
|
357414
|
+
const selector = z21.object({
|
|
357415
|
+
schema: z21.literal(SELECTOR_SCHEMA),
|
|
357068
357416
|
checkpointReference: ref7
|
|
357069
357417
|
}).strict().parse(JSON.parse(readFileSync36(join42(directory, file), "utf8")));
|
|
357070
357418
|
const state = checkpointSchema.parse(JSON.parse(this.store.read(selector.checkpointReference).content));
|
|
@@ -357091,8 +357439,8 @@ var FeatureWorkflowController = class {
|
|
|
357091
357439
|
fail3("continuation_not_found");
|
|
357092
357440
|
const matches = [];
|
|
357093
357441
|
for (const file of this.selectorCandidates()) {
|
|
357094
|
-
const selector =
|
|
357095
|
-
schema:
|
|
357442
|
+
const selector = z21.object({
|
|
357443
|
+
schema: z21.literal(SELECTOR_SCHEMA),
|
|
357096
357444
|
checkpointReference: ref7
|
|
357097
357445
|
}).strict().parse(JSON.parse(readFileSync36(join42(directory, file), "utf8")));
|
|
357098
357446
|
const state = checkpointSchema.parse(JSON.parse(this.store.read(selector.checkpointReference).content));
|
|
@@ -357145,7 +357493,7 @@ var FeatureWorkflowController = class {
|
|
|
357145
357493
|
if (card.phase === "implementation" && !card.ownedFiles.some((path7) => failed.verifier.targetPaths.some((target2) => resolve27(this.options.workingDir, path7) === resolve27(this.options.workingDir, target2))))
|
|
357146
357494
|
fail3("repair_not_failed_verifier_target");
|
|
357147
357495
|
}
|
|
357148
|
-
const reason =
|
|
357496
|
+
const reason = z21.string().trim().min(1).max(4e3).parse(input.reason);
|
|
357149
357497
|
const affected = /* @__PURE__ */ new Set([card.id]);
|
|
357150
357498
|
for (const item of compileFeatureWorkflow(plan).cards) {
|
|
357151
357499
|
const candidate = plan.cards.find((c) => featureWorkflowCardId(plan, c.id) === item.id);
|
|
@@ -358162,7 +358510,7 @@ function isSnapshot(value) {
|
|
|
358162
358510
|
const owner = record9["owner"];
|
|
358163
358511
|
const acknowledgements = pending;
|
|
358164
358512
|
const acknowledgementById = new Map(acknowledgements.map((entry) => [entry.id, entry]));
|
|
358165
|
-
if (acknowledgements.some((entry) => entry.generation
|
|
358513
|
+
if (acknowledgements.some((entry) => entry.generation > owner.generation || entry.generation < owner.generation && entry.status === "pending")) {
|
|
358166
358514
|
return false;
|
|
358167
358515
|
}
|
|
358168
358516
|
const phase = record9["phase"];
|
|
@@ -358233,6 +358581,16 @@ var InterruptionLifecycle = class {
|
|
|
358233
358581
|
snapshot() {
|
|
358234
358582
|
return cloneSnapshot(this.state);
|
|
358235
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
|
+
}
|
|
358236
358594
|
/** A post-rename durability failure closes admission until process recovery. */
|
|
358237
358595
|
get requiresDurabilityRecovery() {
|
|
358238
358596
|
return this.durabilityUncertain;
|
|
@@ -358338,6 +358696,32 @@ var InterruptionLifecycle = class {
|
|
|
358338
358696
|
this.transition("paused", this.state.requestedBy, reason, true);
|
|
358339
358697
|
return this.receipt("pause_acknowledged", true, false, previous, reason);
|
|
358340
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
|
+
}
|
|
358341
358725
|
requestResume(requestedBy, reason = "resume requested") {
|
|
358342
358726
|
const previous = this.state.phase;
|
|
358343
358727
|
if (previous === "running" || previous === "resuming") {
|
|
@@ -359177,7 +359561,7 @@ function checkDoomLoop(context) {
|
|
|
359177
359561
|
// packages/orchestrator/dist/steeringIntake.js
|
|
359178
359562
|
import { appendFileSync as appendFileSync4, existsSync as existsSync34, mkdirSync as mkdirSync28, readFileSync as readFileSync39 } from "node:fs";
|
|
359179
359563
|
import { join as join44 } from "node:path";
|
|
359180
|
-
import { z as
|
|
359564
|
+
import { z as z22 } from "zod";
|
|
359181
359565
|
function classifySteeringIntent(content, requestedIntent) {
|
|
359182
359566
|
void content;
|
|
359183
359567
|
return requestedIntent ?? "context_only";
|
|
@@ -359189,12 +359573,12 @@ function steeringGatesOldPlan(intent) {
|
|
|
359189
359573
|
return intent !== "cancel";
|
|
359190
359574
|
}
|
|
359191
359575
|
var LEDGER_FILE = "steering-ledger.jsonl";
|
|
359192
|
-
var SteeringInterpretationSchema =
|
|
359193
|
-
inference:
|
|
359194
|
-
runnerInstruction:
|
|
359195
|
-
conflicts:
|
|
359196
|
-
alternatives:
|
|
359197
|
-
memoryNote:
|
|
359576
|
+
var SteeringInterpretationSchema = z22.object({
|
|
359577
|
+
inference: z22.string().trim().min(1),
|
|
359578
|
+
runnerInstruction: z22.string().trim().min(1),
|
|
359579
|
+
conflicts: z22.array(z22.string().trim().min(1)).optional().default([]),
|
|
359580
|
+
alternatives: z22.array(z22.string().trim().min(1)).optional().default([]),
|
|
359581
|
+
memoryNote: z22.string().trim().min(1).optional()
|
|
359198
359582
|
});
|
|
359199
359583
|
function appendSteeringLedgerEntry(repoRoot, entry) {
|
|
359200
359584
|
try {
|
|
@@ -359207,13 +359591,17 @@ function appendSteeringLedgerEntry(repoRoot, entry) {
|
|
|
359207
359591
|
}
|
|
359208
359592
|
|
|
359209
359593
|
// packages/orchestrator/dist/steeringEvidence.js
|
|
359210
|
-
import { z as
|
|
359594
|
+
import { z as z23 } from "zod";
|
|
359211
359595
|
|
|
359212
359596
|
// packages/orchestrator/dist/typed-model-output.js
|
|
359213
359597
|
var STEERING_RECONCILIATION_REGION = "steering_reconciliation";
|
|
359214
359598
|
var OPEN = "[STEERING_RECONCILIATION";
|
|
359215
359599
|
var CLOSE = "[/STEERING_RECONCILIATION";
|
|
359216
359600
|
var RESERVED_INTERNAL_LINE_MARKERS = [
|
|
359601
|
+
"[ADJUDICATION_ARGUMENT_REPAIR]",
|
|
359602
|
+
"[ADJUDICATION_INVALID_REPLAY]",
|
|
359603
|
+
"[HUMAN_RESPONSE_REQUIRED]",
|
|
359604
|
+
"[HUMAN_RESPONSE_TURN_REQUIRED]",
|
|
359217
359605
|
"[STEERING_RECONCILIATION_REQUIRED]",
|
|
359218
359606
|
"[STEERING_REPLAN_TURN_REQUIRED]",
|
|
359219
359607
|
"[STEERING_CLARIFICATION_REQUIRED]",
|
|
@@ -359621,38 +360009,38 @@ ${marker}`);
|
|
|
359621
360009
|
|
|
359622
360010
|
// packages/orchestrator/dist/steeringEvidence.js
|
|
359623
360011
|
var STEERING_CHECKPOINT_SCHEMA = "omnius.steering-checkpoint.v1";
|
|
359624
|
-
var identity =
|
|
359625
|
-
var epoch =
|
|
359626
|
-
var intake =
|
|
360012
|
+
var identity = z23.string().min(1).max(500).refine((value) => value === value.trim());
|
|
360013
|
+
var epoch = z23.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
|
|
360014
|
+
var intake = z23.object({
|
|
359627
360015
|
inputId: identity,
|
|
359628
|
-
content:
|
|
359629
|
-
source:
|
|
359630
|
-
receivedAt:
|
|
359631
|
-
intent:
|
|
359632
|
-
state:
|
|
359633
|
-
allowTaskReplacement:
|
|
360016
|
+
content: z23.string().min(1),
|
|
360017
|
+
source: z23.string().min(1),
|
|
360018
|
+
receivedAt: z23.string().datetime(),
|
|
360019
|
+
intent: z23.enum(["clarify", "append", "context_only", "constraint", "priority_change", "redirect", "replace", "cancel"]),
|
|
360020
|
+
state: z23.enum(["received", "queued", "acknowledged", "visible_in_request", "reconciliation_required", "reconciled", "first_affected_action", "consumed", "superseded", "cancelled"]),
|
|
360021
|
+
allowTaskReplacement: z23.boolean().optional(),
|
|
359634
360022
|
taskEpoch: epoch
|
|
359635
360023
|
});
|
|
359636
|
-
var call =
|
|
360024
|
+
var call = z23.object({
|
|
359637
360025
|
id: identity,
|
|
359638
360026
|
name: identity,
|
|
359639
|
-
arguments:
|
|
359640
|
-
executionArguments:
|
|
359641
|
-
state:
|
|
359642
|
-
success:
|
|
360027
|
+
arguments: z23.record(z23.string(), z23.unknown()),
|
|
360028
|
+
executionArguments: z23.record(z23.string(), z23.unknown()).optional(),
|
|
360029
|
+
state: z23.enum(["pending", "running", "completed"]),
|
|
360030
|
+
success: z23.boolean().optional()
|
|
359643
360031
|
}).refine((value) => value.state === "completed" === (value.success !== void 0));
|
|
359644
|
-
var activeSchema =
|
|
360032
|
+
var activeSchema = z23.object({
|
|
359645
360033
|
input: intake,
|
|
359646
|
-
relatedInputs:
|
|
360034
|
+
relatedInputs: z23.array(intake).max(127).optional(),
|
|
359647
360035
|
historyStartIndex: epoch.optional(),
|
|
359648
360036
|
appliedTurn: epoch,
|
|
359649
|
-
requiresReconciliation:
|
|
359650
|
-
gatesOldPlan:
|
|
359651
|
-
visibleRequestTurns:
|
|
359652
|
-
reconciliation:
|
|
360037
|
+
requiresReconciliation: z23.boolean(),
|
|
360038
|
+
gatesOldPlan: z23.boolean(),
|
|
360039
|
+
visibleRequestTurns: z23.array(epoch),
|
|
360040
|
+
reconciliation: z23.unknown().optional(),
|
|
359653
360041
|
reconciledTurn: epoch.optional(),
|
|
359654
|
-
firstAffectedAction:
|
|
359655
|
-
evidence:
|
|
360042
|
+
firstAffectedAction: z23.object({ toolName: identity, turn: epoch }).optional(),
|
|
360043
|
+
evidence: z23.object({ phases: z23.number().int().min(1).max(3), calls: z23.array(call).min(1).max(12) }).optional()
|
|
359656
360044
|
});
|
|
359657
360045
|
function isSteeringScopeResolved(active) {
|
|
359658
360046
|
const decision2 = active.reconciliation;
|
|
@@ -359667,7 +360055,7 @@ function renderSteeringReconciliationProtocol(inputId) {
|
|
|
359667
360055
|
taskDisposition: "continue"
|
|
359668
360056
|
});
|
|
359669
360057
|
return [
|
|
359670
|
-
"
|
|
360058
|
+
"First answer the latest user briefly in ordinary visible prose; then include exactly one internal structured reconciliation. Include no tool calls in that response:",
|
|
359671
360059
|
"[STEERING_RECONCILIATION]",
|
|
359672
360060
|
template,
|
|
359673
360061
|
"[/STEERING_RECONCILIATION]",
|
|
@@ -359686,14 +360074,14 @@ function steeringEvidenceArgumentsKey(value) {
|
|
|
359686
360074
|
return JSON.stringify(value) ?? "undefined";
|
|
359687
360075
|
}
|
|
359688
360076
|
function validateSteeringCheckpoint(value, expected) {
|
|
359689
|
-
const parsed =
|
|
359690
|
-
schema:
|
|
360077
|
+
const parsed = z23.object({
|
|
360078
|
+
schema: z23.literal(STEERING_CHECKPOINT_SCHEMA),
|
|
359691
360079
|
runId: identity,
|
|
359692
360080
|
sessionId: identity,
|
|
359693
360081
|
taskEpoch: epoch,
|
|
359694
360082
|
active: activeSchema,
|
|
359695
|
-
goal:
|
|
359696
|
-
messages:
|
|
360083
|
+
goal: z23.string().min(1).max(16e3),
|
|
360084
|
+
messages: z23.array(z23.unknown()).min(1).max(1e5)
|
|
359697
360085
|
}).parse(value);
|
|
359698
360086
|
if (parsed.runId !== expected.runId || parsed.sessionId !== expected.sessionId || parsed.taskEpoch !== expected.taskEpoch)
|
|
359699
360087
|
throw new Error("steering_checkpoint_identity_mismatch");
|
|
@@ -365409,7 +365797,7 @@ function reconcileShellExecutionOutcome(command, result) {
|
|
|
365409
365797
|
}
|
|
365410
365798
|
|
|
365411
365799
|
// packages/orchestrator/dist/agenticRunner.js
|
|
365412
|
-
import { z as
|
|
365800
|
+
import { z as z25 } from "zod";
|
|
365413
365801
|
init_ollama_pool();
|
|
365414
365802
|
|
|
365415
365803
|
// packages/orchestrator/dist/personality.js
|
|
@@ -366153,7 +366541,7 @@ function buildPhaseSkillGuidance(input) {
|
|
|
366153
366541
|
import { createHash as createHash87 } from "node:crypto";
|
|
366154
366542
|
import { existsSync as existsSync40, readFileSync as readFileSync46 } from "node:fs";
|
|
366155
366543
|
import { join as join50 } from "node:path";
|
|
366156
|
-
import { z as
|
|
366544
|
+
import { z as z24 } from "zod";
|
|
366157
366545
|
var deliveryRealityStates = [
|
|
366158
366546
|
"simulation_only",
|
|
366159
366547
|
"hardware_integrated",
|
|
@@ -366169,70 +366557,70 @@ var acceptanceLayers = [
|
|
|
366169
366557
|
"hardware_in_loop",
|
|
366170
366558
|
"documentation"
|
|
366171
366559
|
];
|
|
366172
|
-
var sourceSchema =
|
|
366173
|
-
id:
|
|
366174
|
-
kind:
|
|
366175
|
-
pathOrUrl:
|
|
366176
|
-
revision:
|
|
366177
|
-
hash:
|
|
366560
|
+
var sourceSchema = z24.object({
|
|
366561
|
+
id: z24.string().min(1),
|
|
366562
|
+
kind: z24.enum(["local_contract", "official_vendor", "third_party", "generated"]),
|
|
366563
|
+
pathOrUrl: z24.string().min(1),
|
|
366564
|
+
revision: z24.string().min(1).optional(),
|
|
366565
|
+
hash: z24.string().min(8).optional()
|
|
366178
366566
|
});
|
|
366179
|
-
var contractSchema =
|
|
366180
|
-
id:
|
|
366181
|
-
productSeries:
|
|
366182
|
-
sourceId:
|
|
366183
|
-
declaredCommands:
|
|
366184
|
-
declaredParameters:
|
|
366185
|
-
declaredModelFormats:
|
|
366567
|
+
var contractSchema = z24.object({
|
|
366568
|
+
id: z24.string().min(1),
|
|
366569
|
+
productSeries: z24.string().min(1),
|
|
366570
|
+
sourceId: z24.string().min(1),
|
|
366571
|
+
declaredCommands: z24.array(z24.string().min(1)).default([]),
|
|
366572
|
+
declaredParameters: z24.array(z24.string().min(1)).default([]),
|
|
366573
|
+
declaredModelFormats: z24.array(z24.string().min(1)).default([])
|
|
366186
366574
|
});
|
|
366187
|
-
var acceptanceSchema =
|
|
366188
|
-
id:
|
|
366189
|
-
layer:
|
|
366190
|
-
requiredFor:
|
|
366575
|
+
var acceptanceSchema = z24.object({
|
|
366576
|
+
id: z24.string().min(1),
|
|
366577
|
+
layer: z24.enum(acceptanceLayers),
|
|
366578
|
+
requiredFor: z24.array(z24.enum(deliveryRealityStates)).min(1),
|
|
366191
366579
|
/** Canonical commands whose successful receipts prove this layer ran. */
|
|
366192
|
-
verificationCommands:
|
|
366193
|
-
safetyInterlock:
|
|
366580
|
+
verificationCommands: z24.array(z24.string().min(1)).min(1),
|
|
366581
|
+
safetyInterlock: z24.string().min(1).optional()
|
|
366194
366582
|
});
|
|
366195
|
-
var inspectionSchema =
|
|
366196
|
-
id:
|
|
366197
|
-
boundary:
|
|
366198
|
-
targetPaths:
|
|
366199
|
-
proves:
|
|
366583
|
+
var inspectionSchema = z24.object({
|
|
366584
|
+
id: z24.string().min(1),
|
|
366585
|
+
boundary: z24.string().min(1),
|
|
366586
|
+
targetPaths: z24.array(z24.string().min(1)).min(1),
|
|
366587
|
+
proves: z24.string().min(1)
|
|
366200
366588
|
});
|
|
366201
|
-
var contradictionCheckSchema =
|
|
366202
|
-
id:
|
|
366203
|
-
question:
|
|
366204
|
-
inspectionIds:
|
|
366589
|
+
var contradictionCheckSchema = z24.object({
|
|
366590
|
+
id: z24.string().min(1),
|
|
366591
|
+
question: z24.string().min(1),
|
|
366592
|
+
inspectionIds: z24.array(z24.string().min(1)).min(1)
|
|
366205
366593
|
});
|
|
366206
|
-
var subjectSchema =
|
|
366207
|
-
productSeries:
|
|
366208
|
-
commands:
|
|
366209
|
-
parameters:
|
|
366210
|
-
modelFormats:
|
|
366594
|
+
var subjectSchema = z24.object({
|
|
366595
|
+
productSeries: z24.string().min(1),
|
|
366596
|
+
commands: z24.array(z24.string().min(1)).default([]),
|
|
366597
|
+
parameters: z24.array(z24.string().min(1)).default([]),
|
|
366598
|
+
modelFormats: z24.array(z24.string().min(1)).default([])
|
|
366211
366599
|
});
|
|
366212
|
-
var claimSchema =
|
|
366213
|
-
id:
|
|
366214
|
-
subjects:
|
|
366215
|
-
state:
|
|
366216
|
-
contractId:
|
|
366217
|
-
sourceIds:
|
|
366218
|
-
evidenceIds:
|
|
366219
|
-
requiredAcceptanceIds:
|
|
366600
|
+
var claimSchema = z24.object({
|
|
366601
|
+
id: z24.string().min(1),
|
|
366602
|
+
subjects: z24.array(subjectSchema).min(1),
|
|
366603
|
+
state: z24.enum(deliveryRealityStates),
|
|
366604
|
+
contractId: z24.string().min(1).optional(),
|
|
366605
|
+
sourceIds: z24.array(z24.string().min(1)).min(1),
|
|
366606
|
+
evidenceIds: z24.array(z24.string().min(1)).default([]),
|
|
366607
|
+
requiredAcceptanceIds: z24.array(z24.string().min(1)).default([]),
|
|
366220
366608
|
/** Source boundaries that must be freshly read before this claim is true. */
|
|
366221
|
-
requiredInspectionIds:
|
|
366609
|
+
requiredInspectionIds: z24.array(z24.string().min(1)).default([]),
|
|
366222
366610
|
/** Falsification checks that must be grounded in those source inspections. */
|
|
366223
|
-
requiredContradictionCheckIds:
|
|
366224
|
-
blockedReason:
|
|
366611
|
+
requiredContradictionCheckIds: z24.array(z24.string().min(1)).default([]),
|
|
366612
|
+
blockedReason: z24.string().min(1).optional()
|
|
366225
366613
|
});
|
|
366226
|
-
var deliveryCoverageManifestSchema =
|
|
366614
|
+
var deliveryCoverageManifestSchema = z24.object({
|
|
366227
366615
|
// Version 1 remains readable for existing workspaces. Version 2 activates
|
|
366228
366616
|
// claim-driven source inspection and falsification gates.
|
|
366229
|
-
schemaVersion:
|
|
366230
|
-
sources:
|
|
366231
|
-
contracts:
|
|
366232
|
-
acceptance:
|
|
366233
|
-
inspections:
|
|
366234
|
-
contradictionChecks:
|
|
366235
|
-
claims:
|
|
366617
|
+
schemaVersion: z24.union([z24.literal(1), z24.literal(2)]),
|
|
366618
|
+
sources: z24.array(sourceSchema),
|
|
366619
|
+
contracts: z24.array(contractSchema),
|
|
366620
|
+
acceptance: z24.array(acceptanceSchema),
|
|
366621
|
+
inspections: z24.array(inspectionSchema).default([]),
|
|
366622
|
+
contradictionChecks: z24.array(contradictionCheckSchema).default([]),
|
|
366623
|
+
claims: z24.array(claimSchema)
|
|
366236
366624
|
});
|
|
366237
366625
|
function canonicalPath(path7) {
|
|
366238
366626
|
return String(path7 ?? "").trim().replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/");
|
|
@@ -388296,6 +388684,10 @@ var AgenticRunner = class _AgenticRunner {
|
|
|
388296
388684
|
*/
|
|
388297
388685
|
_immediateSteeringWakeInputId = null;
|
|
388298
388686
|
_steeringSequence = 0;
|
|
388687
|
+
/** Explicit foreground human input is answered before optional advice/actions. */
|
|
388688
|
+
_pendingSteeringReply = null;
|
|
388689
|
+
_steeringReplyTurn = null;
|
|
388690
|
+
_adjudicationArgumentRepair = null;
|
|
388299
388691
|
_taskEpoch = 0;
|
|
388300
388692
|
_exclusiveTaskOwner = null;
|
|
388301
388693
|
_hasStartedTask = false;
|
|
@@ -388357,6 +388749,15 @@ var AgenticRunner = class _AgenticRunner {
|
|
|
388357
388749
|
_inputWaitSequence = 0;
|
|
388358
388750
|
_inputWaitPauseReceipt = null;
|
|
388359
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;
|
|
388360
388761
|
_interruptionMessages = null;
|
|
388361
388762
|
_interruptionToolCallLog = null;
|
|
388362
388763
|
_interruptionExplicitGoal = "";
|
|
@@ -388470,6 +388871,8 @@ var AgenticRunner = class _AgenticRunner {
|
|
|
388470
388871
|
_desktopVerificationObservation = null;
|
|
388471
388872
|
_desktopVerificationPending = null;
|
|
388472
388873
|
_trajectoryGeneratedGrounding = null;
|
|
388874
|
+
_trajectoryGroundingRequest = null;
|
|
388875
|
+
_virtualContextRequest = null;
|
|
388473
388876
|
_taskWorkOperationBindings = /* @__PURE__ */ new Map();
|
|
388474
388877
|
_taskWorkDispatchUnits = /* @__PURE__ */ new Map();
|
|
388475
388878
|
// -- File State Registry (SWE-agent inspired) --
|
|
@@ -392946,7 +393349,7 @@ ${read.content}`;
|
|
|
392946
393349
|
request.maxTokens = Math.min(outputIntent, configuredCeiling);
|
|
392947
393350
|
}
|
|
392948
393351
|
const steering = this._activeSteering;
|
|
392949
|
-
const maskSteeringTools = Boolean(steering?.input.taskEpoch === this._taskEpoch && steering.gatesOldPlan && steering.requiresReconciliation && !steering.reconciliation && this._requestCarriesCurrentSteering(request, steering));
|
|
393352
|
+
const maskSteeringTools = Boolean(this._currentSteeringReplyPending() || steering?.input.taskEpoch === this._taskEpoch && steering.gatesOldPlan && steering.requiresReconciliation && !steering.reconciliation && this._requestCarriesCurrentSteering(request, steering));
|
|
392950
393353
|
const contracts = JSON.stringify([...this._canonicalToolExposureContracts]);
|
|
392951
393354
|
let toolIntent = this._contextAdmissionToolIntents.get(request);
|
|
392952
393355
|
if (toolIntent && (toolIntent.runId !== this._activeRunId || toolIntent.taskEpoch !== this._taskEpoch || toolIntent.contracts !== contracts || toolIntent.registry.some((entry) => this.tools.get(entry.name) !== entry.tool))) {
|
|
@@ -393525,6 +393928,15 @@ ${read.content}`;
|
|
|
393525
393928
|
});
|
|
393526
393929
|
}
|
|
393527
393930
|
}
|
|
393931
|
+
const argumentRepair = this._currentAdjudicationArgumentRepair(turn);
|
|
393932
|
+
if (argumentRepair)
|
|
393933
|
+
latest.set("adjudication-argument-repair", {
|
|
393934
|
+
slot: "next_action",
|
|
393935
|
+
source: "runtime.adjudication-argument-repair",
|
|
393936
|
+
priority: 100,
|
|
393937
|
+
protection: ["active_requirement"],
|
|
393938
|
+
content: this._adjudicationArgumentRepairGuidance(argumentRepair)
|
|
393939
|
+
});
|
|
393528
393940
|
return [...latest.entries()].map(([id5, signal]) => ({
|
|
393529
393941
|
id: `canonical-late:${id5}`,
|
|
393530
393942
|
slot: signal.slot,
|
|
@@ -394628,7 +395040,7 @@ ${read.content}`;
|
|
|
394628
395040
|
const kind = admittedMediaEvidenceRead ? "read_tool" : this.interruptionToolKind(tool, readOnly);
|
|
394629
395041
|
const ticket = this._interruptionLifecycle?.registerOperation({
|
|
394630
395042
|
kind,
|
|
394631
|
-
effect: readOnly ? "read_only" : "external_effect",
|
|
395043
|
+
effect: tool.interruptionEffect ?? (readOnly ? "read_only" : "external_effect"),
|
|
394632
395044
|
ownerId: `tool:${name}`
|
|
394633
395045
|
});
|
|
394634
395046
|
if (this._interruptionLifecycle && !ticket) {
|
|
@@ -394668,10 +395080,18 @@ ${read.content}`;
|
|
|
394668
395080
|
let workflowTicket;
|
|
394669
395081
|
let uiInvocationActive = false;
|
|
394670
395082
|
const desktopScope = this._objectiveRecoveryScope(), desktopController = this._turnAbortController;
|
|
395083
|
+
const cognitionSignal = ticket?.effect === "read_only" && ticket.kind === "background_cognition" ? this._inputWaitBoundaryController.signal : void 0;
|
|
394671
395084
|
try {
|
|
394672
395085
|
const corpusReadAllocation = this._allocateCorpusRead(tool, name, args);
|
|
394673
395086
|
let invocation = tool.acceptsInvocationContext === true ? {
|
|
394674
|
-
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
|
+
},
|
|
394675
395095
|
...corpusReadAllocation ? { corpusReadAllocation } : {},
|
|
394676
395096
|
...objectiveEffectIntent ? { objectiveEffectIntent } : {},
|
|
394677
395097
|
elevationPolicy: {
|
|
@@ -394690,7 +395110,14 @@ ${read.content}`;
|
|
|
394690
395110
|
if (workflowAdmission && ticket && this._featureWorkflow) {
|
|
394691
395111
|
workflowTicket = this._featureWorkflow.admit(workflowAdmission, ticket, name, args);
|
|
394692
395112
|
invocation = {
|
|
394693
|
-
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
|
+
},
|
|
394694
395121
|
...objectiveEffectIntent ? { objectiveEffectIntent } : {},
|
|
394695
395122
|
elevationPolicy: {
|
|
394696
395123
|
mode: this.options.surface === "tui" ? "native" : "deny",
|
|
@@ -394760,12 +395187,18 @@ ${read.content}`;
|
|
|
394760
395187
|
};
|
|
394761
395188
|
} finally {
|
|
394762
395189
|
uiInvocationActive = false;
|
|
394763
|
-
if (ticket) {
|
|
394764
|
-
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");
|
|
394765
395193
|
if (!progressOnly)
|
|
394766
|
-
this._transitionTaskWorkOperation(ticket.id,
|
|
395194
|
+
this._transitionTaskWorkOperation(ticket.id, unknown ? "unknown" : "settled");
|
|
394767
395195
|
}
|
|
394768
395196
|
}
|
|
395197
|
+
if (this._updateRestartCheckpointForced) {
|
|
395198
|
+
if (!this.aborted)
|
|
395199
|
+
await new Promise((resolve42) => this._pauseWaiters.add(resolve42));
|
|
395200
|
+
throw new InputWaitInterruption();
|
|
395201
|
+
}
|
|
394769
395202
|
if (pendingObjectiveEffect && !normalizeExternalEffectReceiptV1(result.externalEffectReceipt)) {
|
|
394770
395203
|
result = {
|
|
394771
395204
|
...result,
|
|
@@ -396469,6 +396902,8 @@ Use exact start_char/end_char or start_line/end_line ranges, or query/resume_sou
|
|
|
396469
396902
|
}
|
|
396470
396903
|
}
|
|
396471
396904
|
_saveCompletionLedgerSafe() {
|
|
396905
|
+
if (this._updateRestartCheckpointForced && !this._updateCheckpointWriteAuthorized)
|
|
396906
|
+
return false;
|
|
396472
396907
|
if (!this._completionLedger)
|
|
396473
396908
|
return true;
|
|
396474
396909
|
if (!this.writesUserTaskArtifacts() && !this._completionLedger.objectiveContract)
|
|
@@ -396739,6 +397174,52 @@ ${content}`)].join("\n\n");
|
|
|
396739
397174
|
_hasUnresolvedCurrentSteeringInputs() {
|
|
396740
397175
|
return this._nativeRequirementInterpretationHolds.size > 0 || this.pendingSteeringInputs.some((input) => (input.taskEpoch === void 0 || input.taskEpoch === this._taskEpoch) && (input.state === "received" || input.state === "queued" || input.state === "acknowledged" || input.state === "visible_in_request" || input.state === "reconciliation_required"));
|
|
396741
397176
|
}
|
|
397177
|
+
_currentSteeringReplyPending() {
|
|
397178
|
+
const pending = this._pendingSteeringReply;
|
|
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;
|
|
397180
|
+
}
|
|
397181
|
+
_adjudicationArgumentRepairIsCurrent(repair) {
|
|
397182
|
+
const tool = this.lookupRegisteredTool(ADJUDICATION_TOOL_NAME)?.tool;
|
|
397183
|
+
return repair.runId === this.currentArtifactRunId() && repair.taskEpoch === this._taskEpoch && repair.ownerId === this._interruptionOwnerId && repair.tool === tool && repair.schema === tool?.inputSchema && repair.parameters === JSON.stringify(tool?.parameters);
|
|
397184
|
+
}
|
|
397185
|
+
_currentAdjudicationArgumentRepair(turn) {
|
|
397186
|
+
const repair = this._adjudicationArgumentRepair;
|
|
397187
|
+
return repair && this._adjudicationArgumentRepairIsCurrent(repair) && (turn === void 0 || repair.settled && turn === repair.turn + 1) ? repair : null;
|
|
397188
|
+
}
|
|
397189
|
+
_adjudicationArgumentRepairGuidance(repair) {
|
|
397190
|
+
return (repair.repeats ? "[ADJUDICATION_INVALID_REPLAY] Identical known-invalid arguments were refused without execution. Correct the named values before retrying.\n" : "") + formatAdjudicationArgumentRepair(repair.error, repair.contract.args_sha256);
|
|
397191
|
+
}
|
|
397192
|
+
_observePrimarySteeringReply(content, turn, emitMixedReply = false) {
|
|
397193
|
+
const pending = this._currentSteeringReplyPending();
|
|
397194
|
+
const visible = content ? partitionTypedModelOutput(content).visibleText.trim() : "";
|
|
397195
|
+
let fence2;
|
|
397196
|
+
const hasProse = visible.split(/\r?\n/).some((line) => {
|
|
397197
|
+
const boundary2 = /^\s*(`{3,}|~{3,})(.*)$/.exec(line);
|
|
397198
|
+
if (boundary2) {
|
|
397199
|
+
if (!fence2)
|
|
397200
|
+
fence2 = { marker: boundary2[1][0], length: boundary2[1].length };
|
|
397201
|
+
else if (boundary2[1][0] === fence2.marker && boundary2[1].length >= fence2.length && !boundary2[2].trim())
|
|
397202
|
+
fence2 = void 0;
|
|
397203
|
+
return false;
|
|
397204
|
+
}
|
|
397205
|
+
return !fence2 && Boolean(line.trim());
|
|
397206
|
+
});
|
|
397207
|
+
const carried = Boolean(pending?.visibleRequestTurns.includes(turn));
|
|
397208
|
+
const active = this._activeSteering;
|
|
397209
|
+
if (emitMixedReply && hasProse && (carried || active?.input.taskEpoch === this._taskEpoch && active.requiresReconciliation && active.visibleRequestTurns.includes(turn))) {
|
|
397210
|
+
this.emit({ type: "assistant_text", content: visible, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
|
|
397211
|
+
this._assistantTextEmitted = true;
|
|
397212
|
+
}
|
|
397213
|
+
if (carried && hasProse) {
|
|
397214
|
+
this._pendingSteeringReply = null;
|
|
397215
|
+
this._steeringReplyTurn = {
|
|
397216
|
+
runId: this.currentArtifactRunId(),
|
|
397217
|
+
taskEpoch: this._taskEpoch,
|
|
397218
|
+
ownerId: this._interruptionOwnerId,
|
|
397219
|
+
turn
|
|
397220
|
+
};
|
|
397221
|
+
}
|
|
397222
|
+
}
|
|
396742
397223
|
_objectiveReadBatchAuxiliaryEligible() {
|
|
396743
397224
|
const continuation = this._objectiveReadBatchContinuation;
|
|
396744
397225
|
const batch = this.options.objectiveReadBatch;
|
|
@@ -396827,6 +397308,8 @@ ${content}`)].join("\n\n");
|
|
|
396827
397308
|
const configuredPinnedBudget = this.options.virtualContext?.pinnedMemoryTokenBudget;
|
|
396828
397309
|
const pinnedTokenBudget = Math.max(0, Math.min(physicalInputBudget, Number.isFinite(configuredPinnedBudget) && (configuredPinnedBudget ?? 0) > 0 ? Math.floor(configuredPinnedBudget) : adaptiveBudget.pinnedState));
|
|
396829
397310
|
const pinnedMessages = this._pinnedStructuredMemoryMessages(pinnedTokenBudget, physicalInputBudget, turn);
|
|
397311
|
+
if (this._currentAdjudicationArgumentRepair(turn) || this._currentSteeringReplyPending() || this._hasUnresolvedCurrentSteeringInputs())
|
|
397312
|
+
return pinnedMessages;
|
|
396830
397313
|
const residentInputTokens = estimateConservativeRequestInputTokens({
|
|
396831
397314
|
messages: messages2.map((message) => ({ ...message })),
|
|
396832
397315
|
tools,
|
|
@@ -396935,11 +397418,34 @@ ${content}`)].join("\n\n");
|
|
|
396935
397418
|
}))
|
|
396936
397419
|
];
|
|
396937
397420
|
}
|
|
397421
|
+
const projectionRequest = {
|
|
397422
|
+
controller: new AbortController(),
|
|
397423
|
+
runId: this.currentArtifactRunId(),
|
|
397424
|
+
taskEpoch: this._taskEpoch,
|
|
397425
|
+
ownerId: this._interruptionOwnerId,
|
|
397426
|
+
generation: this._modelRequestGeneration
|
|
397427
|
+
};
|
|
397428
|
+
this._virtualContextRequest = projectionRequest;
|
|
397429
|
+
const signal = AbortSignal.any([
|
|
397430
|
+
projectionRequest.controller.signal,
|
|
397431
|
+
this._abortController.signal,
|
|
397432
|
+
this._turnAbortController.signal,
|
|
397433
|
+
this._inputWaitBoundaryController.signal
|
|
397434
|
+
]);
|
|
397435
|
+
const isCurrent = () => !signal.aborted && this._virtualContextRequest === projectionRequest && projectionRequest.runId === this.currentArtifactRunId() && projectionRequest.taskEpoch === this._taskEpoch && projectionRequest.ownerId === this._interruptionOwnerId && projectionRequest.generation === this._modelRequestGeneration;
|
|
397436
|
+
const assertCurrent = () => {
|
|
397437
|
+
if (!isCurrent())
|
|
397438
|
+
throw new InputWaitInterruption();
|
|
397439
|
+
};
|
|
396938
397440
|
try {
|
|
396939
397441
|
const timeoutMs = this.options.requestTimeoutMs === 0 ? 0 : Number.isFinite(this.options.requestTimeoutMs) && (this.options.requestTimeoutMs ?? 0) > 0 ? this.options.requestTimeoutMs : 3e5;
|
|
396940
|
-
|
|
397442
|
+
assertCurrent();
|
|
397443
|
+
const projection = await withInputWaitCancellation(signal, () => buildLiveVirtualContextProjection({
|
|
396941
397444
|
store,
|
|
396942
|
-
archiveDocument: (document) =>
|
|
397445
|
+
archiveDocument: (document) => {
|
|
397446
|
+
assertCurrent();
|
|
397447
|
+
return this._archiveVirtualEvidenceDocument(document);
|
|
397448
|
+
},
|
|
396943
397449
|
...this._structuredMemoryStore ? { memoryStore: this._structuredMemoryStore } : {},
|
|
396944
397450
|
query,
|
|
396945
397451
|
scopeId: this._sessionId,
|
|
@@ -396952,9 +397458,11 @@ ${content}`)].join("\n\n");
|
|
|
396952
397458
|
auxiliaryContextWindowTokens: physicalWindow,
|
|
396953
397459
|
auxiliaryMaxOutputTokens: this._explicitGenerationMaxTokens || this.options.maxTokens !== 16384 ? this._generationOutputCeiling() : void 0,
|
|
396954
397460
|
maxRetrievalRounds: this.options.virtualContext?.maxRetrievalRounds,
|
|
396955
|
-
signal
|
|
397461
|
+
signal,
|
|
396956
397462
|
requestTimeoutMs: timeoutMs > 0 ? Math.min(timeoutMs, 3e4) : 3e4,
|
|
396957
397463
|
onTrace: (event) => {
|
|
397464
|
+
if (!isCurrent())
|
|
397465
|
+
return;
|
|
396958
397466
|
this._recordLiveVirtualContextTrace(event, turn);
|
|
396959
397467
|
this.emit({
|
|
396960
397468
|
type: "status",
|
|
@@ -396965,9 +397473,11 @@ ${content}`)].join("\n\n");
|
|
|
396965
397473
|
});
|
|
396966
397474
|
},
|
|
396967
397475
|
infer: async (request) => {
|
|
397476
|
+
assertCurrent();
|
|
396968
397477
|
this._emitModelResolutionTelemetry(`virtual_memory_${request.stage}`, turn);
|
|
396969
|
-
const response = await this._auxInferenceBackend({
|
|
396970
|
-
dumpStage: `virtual_memory_${request.stage}
|
|
397478
|
+
const response = await withInputWaitCancellation(request.signal, () => this._auxInferenceBackend({
|
|
397479
|
+
dumpStage: `virtual_memory_${request.stage}`,
|
|
397480
|
+
assertCurrent
|
|
396971
397481
|
}).chatCompletion({
|
|
396972
397482
|
messages: [
|
|
396973
397483
|
{ role: "system", content: request.system },
|
|
@@ -396981,10 +397491,12 @@ ${content}`)].join("\n\n");
|
|
|
396981
397491
|
think: false,
|
|
396982
397492
|
workloadClass: this.options.workloadClass,
|
|
396983
397493
|
logicalRequestId: this._modelTurnRequestId(turn, `virtual-memory:${request.stage}`)
|
|
396984
|
-
});
|
|
397494
|
+
}));
|
|
397495
|
+
assertCurrent();
|
|
396985
397496
|
return response.choices?.[0]?.message?.content ?? "";
|
|
396986
397497
|
}
|
|
396987
|
-
});
|
|
397498
|
+
}));
|
|
397499
|
+
assertCurrent();
|
|
396988
397500
|
this._liveVirtualContextAttempt = { semanticKey, turn };
|
|
396989
397501
|
if (!projection)
|
|
396990
397502
|
return pinnedMessages;
|
|
@@ -397011,6 +397523,8 @@ ${content}`)].join("\n\n");
|
|
|
397011
397523
|
}))
|
|
397012
397524
|
];
|
|
397013
397525
|
} catch (error) {
|
|
397526
|
+
if (!isCurrent() || error instanceof InputWaitInterruption)
|
|
397527
|
+
return pinnedMessages;
|
|
397014
397528
|
if (this._turnAbortController.signal.aborted)
|
|
397015
397529
|
throw error;
|
|
397016
397530
|
this._liveVirtualContextAttempt = { semanticKey, turn };
|
|
@@ -397022,6 +397536,9 @@ ${content}`)].join("\n\n");
|
|
|
397022
397536
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
397023
397537
|
});
|
|
397024
397538
|
return pinnedMessages;
|
|
397539
|
+
} finally {
|
|
397540
|
+
if (this._virtualContextRequest === projectionRequest)
|
|
397541
|
+
this._virtualContextRequest = null;
|
|
397025
397542
|
}
|
|
397026
397543
|
}
|
|
397027
397544
|
_pinnedStructuredMemoryMessages(defaultTokenBudget, physicalInputBudget, turn) {
|
|
@@ -397774,49 +398291,59 @@ ${currentIntent.trim().slice(0, 6e3)}`,
|
|
|
397774
398291
|
const b = this.backend;
|
|
397775
398292
|
return {
|
|
397776
398293
|
chatCompletion: async (req) => {
|
|
397777
|
-
const
|
|
397778
|
-
|
|
397779
|
-
|
|
397780
|
-
|
|
397781
|
-
|
|
397782
|
-
|
|
397783
|
-
|
|
397784
|
-
|
|
397785
|
-
|
|
397786
|
-
|
|
397787
|
-
|
|
397788
|
-
|
|
397789
|
-
|
|
397790
|
-
|
|
397791
|
-
|
|
397792
|
-
|
|
397793
|
-
|
|
397794
|
-
|
|
397795
|
-
|
|
397796
|
-
|
|
397797
|
-
|
|
397798
|
-
|
|
397799
|
-
explicitMaxOutputTokens: explicitAuxiliaryCap
|
|
397800
|
-
});
|
|
397801
|
-
else
|
|
397802
|
-
r.minimumOutputReservation = priorFloor;
|
|
397803
|
-
}
|
|
397804
|
-
if (allocated.maxTokens <= 0)
|
|
397805
|
-
throw Object.assign(new Error("auxiliary_output_capacity_unavailable"), { code: "context_admission_failed" });
|
|
397806
|
-
r.maxTokens = allocated.maxTokens;
|
|
397807
|
-
if (!opts?.suppressContextDump) {
|
|
397808
|
-
recordContextWindowDump({
|
|
397809
|
-
source: "agenticRunner",
|
|
397810
|
-
stage: opts?.dumpStage ?? "aux_inference",
|
|
397811
|
-
agentType: "internal",
|
|
397812
|
-
sessionId: this._sessionId,
|
|
397813
|
-
runId: this._workboardRunId(),
|
|
397814
|
-
model: this._backendModelLabel(this.backend),
|
|
397815
|
-
cwd: this._workingDirectory || process.cwd(),
|
|
397816
|
-
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
|
|
397817
398316
|
});
|
|
397818
|
-
|
|
397819
|
-
|
|
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
|
+
});
|
|
397820
398347
|
}
|
|
397821
398348
|
};
|
|
397822
398349
|
}
|
|
@@ -400166,12 +400693,12 @@ ${modelVisible}` : modelVisible || result.error || displayOutput || "";
|
|
|
400166
400693
|
if (!candidate)
|
|
400167
400694
|
return { quality: "not_candidate", summary: "not a validation command" };
|
|
400168
400695
|
if (!commandReliablySatisfiesVerifyCommand(command, command, result.executionReceipt)) {
|
|
400169
|
-
const
|
|
400696
|
+
const shape3 = describeUntrustedVerificationCommand(command, result.executionReceipt);
|
|
400170
400697
|
return {
|
|
400171
400698
|
quality: "rejected_untrusted",
|
|
400172
|
-
summary: `validation command is not receipt-authoritative: ${
|
|
400173
|
-
reason: `Repair the execution shape: ${
|
|
400174
|
-
nextAction: `Run the canonical validation with a receipt-authoritative shape; current issue: ${
|
|
400699
|
+
summary: `validation command is not receipt-authoritative: ${shape3}`,
|
|
400700
|
+
reason: `Repair the execution shape: ${shape3}.`,
|
|
400701
|
+
nextAction: `Run the canonical validation with a receipt-authoritative shape; current issue: ${shape3}.`
|
|
400175
400702
|
};
|
|
400176
400703
|
}
|
|
400177
400704
|
if (result.success !== true) {
|
|
@@ -405802,7 +406329,16 @@ ${findingsBody}`;
|
|
|
405802
406329
|
}
|
|
405803
406330
|
return null;
|
|
405804
406331
|
}
|
|
405805
|
-
buildToolArgumentRepairFeedback(toolName, args, tool, validationError) {
|
|
406332
|
+
buildToolArgumentRepairFeedback(toolName, args, tool, validationError, admittedRepair) {
|
|
406333
|
+
if (tool.name === ADJUDICATION_TOOL_NAME) {
|
|
406334
|
+
const argsKey = this._buildExactArgsKey(args);
|
|
406335
|
+
const candidate = admittedRepair ?? this._currentAdjudicationArgumentRepair();
|
|
406336
|
+
const repair = candidate && this._adjudicationArgumentRepairIsCurrent(candidate) && candidate.argsKey === argsKey ? candidate : null;
|
|
406337
|
+
const guidance = repair ? this._adjudicationArgumentRepairGuidance(repair) : formatAdjudicationArgumentRepair(validationError, _createHash("sha256").update(argsKey).digest("hex"));
|
|
406338
|
+
const message = `Invalid arguments for ${toolName}.
|
|
406339
|
+
${guidance}`;
|
|
406340
|
+
return { error: message, llmContent: message, systemGuidance: guidance };
|
|
406341
|
+
}
|
|
405806
406342
|
const parameters = tool.parameters ?? {};
|
|
405807
406343
|
const props = this.schemaProperties(parameters);
|
|
405808
406344
|
const required = this.schemaRequired(parameters);
|
|
@@ -406002,28 +406538,12 @@ ${findingsBody}`;
|
|
|
406002
406538
|
return corrected;
|
|
406003
406539
|
}
|
|
406004
406540
|
findSiblingToolSchemaMatches(requestedToolName, providedKeys) {
|
|
406005
|
-
|
|
406006
|
-
|
|
406007
|
-
|
|
406008
|
-
|
|
406009
|
-
|
|
406010
|
-
|
|
406011
|
-
continue;
|
|
406012
|
-
const props = this.schemaProperties(candidate.parameters ?? {});
|
|
406013
|
-
if (props.size === 0)
|
|
406014
|
-
continue;
|
|
406015
|
-
const required = this.schemaRequired(candidate.parameters ?? {});
|
|
406016
|
-
const matched = providedKeys.filter((key) => props.has(key)).length;
|
|
406017
|
-
if (matched === 0)
|
|
406018
|
-
continue;
|
|
406019
|
-
const requiredPresent = required.filter((key) => provided.has(key)).length;
|
|
406020
|
-
const requiredSatisfied = required.length === 0 || requiredPresent === required.length;
|
|
406021
|
-
const score = matched * 2 + requiredPresent * 3 + (requiredSatisfied ? 3 : 0) - Math.max(0, required.length - requiredPresent);
|
|
406022
|
-
if (score >= 5 || matched >= 2 && requiredSatisfied) {
|
|
406023
|
-
matches.push({ name: candidate.name, score });
|
|
406024
|
-
}
|
|
406025
|
-
}
|
|
406026
|
-
return matches.sort((a, b) => b.score - a.score).slice(0, 3).map((match2) => match2.name);
|
|
406541
|
+
return findBetterToolSchemaMatches({
|
|
406542
|
+
requestedToolName,
|
|
406543
|
+
requestedParameters: this.lookupRegisteredTool(requestedToolName)?.tool.parameters ?? {},
|
|
406544
|
+
providedKeys,
|
|
406545
|
+
candidates: this.tools.values()
|
|
406546
|
+
});
|
|
406027
406547
|
}
|
|
406028
406548
|
unknownToolError(name) {
|
|
406029
406549
|
const names = Array.from(this.tools.values()).map((tool) => tool.aliases?.length ? `${tool.name} (aliases: ${tool.aliases.join("|")})` : tool.name).sort();
|
|
@@ -406416,6 +406936,8 @@ ${notice}`;
|
|
|
406416
406936
|
* active turn, which closes the old bridge-to-runner message-loss race.
|
|
406417
406937
|
*/
|
|
406418
406938
|
injectSteeringInput(input) {
|
|
406939
|
+
if (this._updateRestartCheckpointForced)
|
|
406940
|
+
throw new Error("This runner was retired for update; retain input for the replacement process.");
|
|
406419
406941
|
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
406420
406942
|
const content = this.scrubUserInput(input.content, "steering-input").trim();
|
|
406421
406943
|
const record9 = {
|
|
@@ -406428,6 +406950,7 @@ ${notice}`;
|
|
|
406428
406950
|
state: "received",
|
|
406429
406951
|
taskEpoch: input.taskEpoch ?? (this._taskEpoch || void 0)
|
|
406430
406952
|
};
|
|
406953
|
+
delete record9.humanResponse;
|
|
406431
406954
|
this.pendingSteeringInputs.push(record9);
|
|
406432
406955
|
this._emitSteeringLifecycle(record9, "received by runner");
|
|
406433
406956
|
if (!content || record9.allowTaskReplacement === false && (record9.intent === "replace" || record9.intent === "redirect")) {
|
|
@@ -406435,6 +406958,14 @@ ${notice}`;
|
|
|
406435
406958
|
this._emitSteeringLifecycle(record9, !content ? "empty steering input rejected" : "replacement exceeds host intake authority");
|
|
406436
406959
|
return this._steeringReceipt(record9);
|
|
406437
406960
|
}
|
|
406961
|
+
if ((record9.source === "tui-work-intake" || record9.source === "tui") && record9.intent !== "cancel") {
|
|
406962
|
+
this._pendingSteeringReply = {
|
|
406963
|
+
input: record9,
|
|
406964
|
+
runId: this.currentArtifactRunId(),
|
|
406965
|
+
ownerId: this._interruptionOwnerId,
|
|
406966
|
+
visibleRequestTurns: []
|
|
406967
|
+
};
|
|
406968
|
+
}
|
|
406438
406969
|
record9.state = "queued";
|
|
406439
406970
|
this._emitSteeringLifecycle(record9, "queued for next safe turn boundary");
|
|
406440
406971
|
if (steeringGatesOldPlan(record9.intent)) {
|
|
@@ -406444,8 +406975,82 @@ ${notice}`;
|
|
|
406444
406975
|
this._requestSteeringPreemption(record9);
|
|
406445
406976
|
}
|
|
406446
406977
|
this._trajectoryDirtyCauses.add("user_steering");
|
|
406978
|
+
const grounding = this._trajectoryGroundingRequest;
|
|
406979
|
+
if (grounding?.runId === this.currentArtifactRunId() && grounding.taskEpoch === this._taskEpoch) {
|
|
406980
|
+
grounding.controller.abort(new InputWaitInterruption());
|
|
406981
|
+
}
|
|
406982
|
+
const projection = this._virtualContextRequest;
|
|
406983
|
+
if (projection?.runId === this.currentArtifactRunId() && projection.taskEpoch === this._taskEpoch && projection.ownerId === this._interruptionOwnerId)
|
|
406984
|
+
projection.controller.abort(new InputWaitInterruption());
|
|
406447
406985
|
return this._steeringReceipt(record9);
|
|
406448
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
|
+
}
|
|
406449
407054
|
/**
|
|
406450
407055
|
* Request safe-boundary preemption for an already accepted typed input.
|
|
406451
407056
|
* Frontends use this after delivery so cancellation reaches an in-flight
|
|
@@ -406773,7 +407378,7 @@ ${notice}`;
|
|
|
406773
407378
|
hold2.wake();
|
|
406774
407379
|
}
|
|
406775
407380
|
get taskRequirementInterpretationPending() {
|
|
406776
|
-
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);
|
|
406777
407382
|
}
|
|
406778
407383
|
/** Host-only authenticated new human instruction; existing steering gates remain authoritative. */
|
|
406779
407384
|
queueNativeTaskRequirementAmendment(authority) {
|
|
@@ -407302,10 +407907,22 @@ The previous reviewer response failed exact candidate-quote serialization. Host
|
|
|
407302
407907
|
this._pendingSteeringPreemption = null;
|
|
407303
407908
|
}
|
|
407304
407909
|
this._emitSteeringLifecycle(record9, "retracted before admission at a safe boundary");
|
|
407910
|
+
if (this._activeSteering) {
|
|
407911
|
+
this._activeSteering.relatedInputs = this._activeSteering.relatedInputs?.filter((input) => input !== record9);
|
|
407912
|
+
if (this._activeSteering.input === record9 && !this._activeSteering.relatedInputs?.length)
|
|
407913
|
+
this._activeSteering = null;
|
|
407914
|
+
}
|
|
407305
407915
|
return record9.content;
|
|
407306
407916
|
}
|
|
407307
407917
|
/** Abort the current task run through the generation-bound stop lineage. */
|
|
407308
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
|
+
}
|
|
407309
407926
|
const transition = this._interruptionLifecycle?.requestStop(this._interruptionLifecycle.snapshot().owner, "runner abort requested") ?? null;
|
|
407310
407927
|
if (transition && !transition.accepted)
|
|
407311
407928
|
return transition;
|
|
@@ -408014,6 +408631,8 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408014
408631
|
}
|
|
408015
408632
|
}
|
|
408016
408633
|
_emitSteeringLifecycle(record9, reason) {
|
|
408634
|
+
if (this._updateRestartCheckpointForced)
|
|
408635
|
+
return;
|
|
408017
408636
|
const receipt = this._steeringReceipt(record9);
|
|
408018
408637
|
const reconciliation = this._activeSteering && [
|
|
408019
408638
|
this._activeSteering.input,
|
|
@@ -408282,6 +408901,16 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408282
408901
|
}
|
|
408283
408902
|
async _drainPendingSteeringMessages(messages2, turn) {
|
|
408284
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);
|
|
408285
408914
|
const pending = this.pendingSteeringInputs.filter((record9) => (record9.state === "queued" || record9.state === "acknowledged") && (!record9.taskEpoch || record9.taskEpoch === this._taskEpoch));
|
|
408286
408915
|
for (const record9 of pending) {
|
|
408287
408916
|
const replacement = this._pendingSteeringPreemption;
|
|
@@ -408294,6 +408923,7 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408294
408923
|
const historyStart = messages2.length;
|
|
408295
408924
|
await this.appendInjectedUserMessage(record9.content, messages2, turn);
|
|
408296
408925
|
this._activateSteering(record9, turn);
|
|
408926
|
+
appendReply(record9);
|
|
408297
408927
|
if (this._immediateSteeringWakeInputId === record9.inputId) {
|
|
408298
408928
|
this._immediateSteeringWakeInputId = null;
|
|
408299
408929
|
}
|
|
@@ -408306,6 +408936,8 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408306
408936
|
if (record9)
|
|
408307
408937
|
this._applyNativeTaskRequirementAmendmentAtBoundary(record9);
|
|
408308
408938
|
}
|
|
408939
|
+
for (const record9 of this.pendingSteeringInputs)
|
|
408940
|
+
appendReply(record9);
|
|
408309
408941
|
while (this.pendingUserMessages.length > 0) {
|
|
408310
408942
|
await this.appendInjectedUserMessage(this.pendingUserMessages.shift(), messages2, turn);
|
|
408311
408943
|
}
|
|
@@ -408769,9 +409401,10 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408769
409401
|
if (!active)
|
|
408770
409402
|
return null;
|
|
408771
409403
|
const { input, reconciliation } = active;
|
|
408772
|
-
if (isSteeringScopeResolved(active))
|
|
409404
|
+
if (isSteeringScopeResolved(active) && !this._currentSteeringReplyPending())
|
|
408773
409405
|
return null;
|
|
408774
409406
|
const sources = [input, ...active.relatedInputs ?? []];
|
|
409407
|
+
const humanResponse = [...sources].reverse().find((source) => source.humanResponse)?.humanResponse;
|
|
408775
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)));
|
|
408776
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")}.`;
|
|
408777
409410
|
const needsClarification = reconciliation?.status === "needs_clarification";
|
|
@@ -408782,6 +409415,9 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
|
|
|
408782
409415
|
`kind=${input.intent}`,
|
|
408783
409416
|
`admission=${active.gatesOldPlan ? "old_plan_gated" : "context_active"}`,
|
|
408784
409417
|
"This is current user authority, not historical transcript context.",
|
|
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.",
|
|
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,
|
|
408785
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,
|
|
408786
409422
|
needsClarification ? "You requested clarification. Do not call tools or resume the old plan; ask the user one concise question." : active.requiresReconciliation ? [
|
|
408787
409423
|
renderSteeringReconciliationProtocol(input.inputId),
|
|
@@ -408807,9 +409443,13 @@ ${exactSourcesPresent ? exactSourcePointer(related) : related.content}`),
|
|
|
408807
409443
|
}
|
|
408808
409444
|
_markActiveSteeringVisible(turn) {
|
|
408809
409445
|
const active = this._activeSteering;
|
|
408810
|
-
|
|
409446
|
+
const pendingReply = this._currentSteeringReplyPending();
|
|
409447
|
+
if (pendingReply && active && [active.input, ...active.relatedInputs ?? []].includes(pendingReply.input) && !pendingReply.visibleRequestTurns.includes(turn))
|
|
409448
|
+
pendingReply.visibleRequestTurns.push(turn);
|
|
409449
|
+
if (!active || isSteeringScopeResolved(active) || active.visibleRequestTurns.includes(turn) && ![active.input, ...active.relatedInputs ?? []].some((input) => input.state === "queued" || input.state === "acknowledged"))
|
|
408811
409450
|
return;
|
|
408812
|
-
active.visibleRequestTurns.
|
|
409451
|
+
if (!active.visibleRequestTurns.includes(turn))
|
|
409452
|
+
active.visibleRequestTurns.push(turn);
|
|
408813
409453
|
for (const input of [active.input, ...active.relatedInputs ?? []]) {
|
|
408814
409454
|
input.state = "visible_in_request";
|
|
408815
409455
|
this._emitSteeringLifecycle(input, `visible in model request at turn ${turn}`);
|
|
@@ -408953,6 +409593,11 @@ ${exactSourcesPresent ? exactSourcePointer(related) : related.content}`),
|
|
|
408953
409593
|
if (this.taskRequirementInterpretationPending)
|
|
408954
409594
|
return "native_requirement_interpretation_pending: the host is reviewing the latest authenticated human instruction; no new action or completion is admitted until its canonical requirements are durably resolved.";
|
|
408955
409595
|
const active = this._activeSteering;
|
|
409596
|
+
const replyTurn = this._steeringReplyTurn;
|
|
409597
|
+
if (replyTurn?.runId === this.currentArtifactRunId() && replyTurn.taskEpoch === this._taskEpoch && replyTurn.ownerId === this._interruptionOwnerId && replyTurn.turn === turn)
|
|
409598
|
+
return "[HUMAN_RESPONSE_TURN_REQUIRED] The current response answers the user. Wait for the next model decision before executing tools.";
|
|
409599
|
+
if (this._currentSteeringReplyPending() && (!active || isSteeringScopeResolved(active)))
|
|
409600
|
+
return "[HUMAN_RESPONSE_REQUIRED] Answer the current user's question or change briefly in visible prose before further tools or planning. Its internal scope decision is already stored.";
|
|
408956
409601
|
if (!active)
|
|
408957
409602
|
return null;
|
|
408958
409603
|
if (active.input.taskEpoch === this._taskEpoch && active.reconciliation && active.reconciliation.status !== "needs_clarification" && active.reconciledTurn === turn) {
|
|
@@ -408973,7 +409618,7 @@ The steering reconciliation was emitted this turn. Wait for the next model decis
|
|
|
408973
409618
|
return [
|
|
408974
409619
|
`[STEERING_RECONCILIATION_REQUIRED]
|
|
408975
409620
|
input_id=${active.input.inputId}`,
|
|
408976
|
-
"Do not execute the old-plan tool call.
|
|
409621
|
+
"Do not execute the old-plan tool call. Answer the current user briefly in visible prose first, then emit the internal steering reconciliation, with no tool calls in that response.",
|
|
408977
409622
|
priorRefusals > 0 ? `You have already been refused this exact call ${priorRefusals} time(s). Repeating it will keep being refused. Emit the reconciliation now, or take a different concrete action.` : null,
|
|
408978
409623
|
renderSteeringReconciliationProtocol(active.input.inputId)
|
|
408979
409624
|
].filter(Boolean).join("\n");
|
|
@@ -409011,7 +409656,7 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409011
409656
|
authoritySlot: "[ACTIVE USER STEERING]",
|
|
409012
409657
|
priorRefusals
|
|
409013
409658
|
}),
|
|
409014
|
-
"Do not execute or retry old-plan tools.
|
|
409659
|
+
"Do not execute or retry old-plan tools. Answer the current user briefly in visible prose, then emit [STEERING_RECONCILIATION] with no tool calls; follow the complete protocol and user instruction in [ACTIVE USER STEERING]."
|
|
409015
409660
|
].join("\n");
|
|
409016
409661
|
}
|
|
409017
409662
|
_markFirstSteeringAffectedAction(toolName, turn) {
|
|
@@ -409055,6 +409700,63 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409055
409700
|
}
|
|
409056
409701
|
return receipt;
|
|
409057
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
|
+
}
|
|
409058
409760
|
/** A typed instruction resumes only after the exact atomic owners settle. */
|
|
409059
409761
|
async resumeAfterInput() {
|
|
409060
409762
|
const sequence = this._inputWaitSequence;
|
|
@@ -409083,6 +409785,25 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409083
409785
|
* Resume a paused task. The run loop continues from where it left off.
|
|
409084
409786
|
*/
|
|
409085
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
|
+
}
|
|
409086
409807
|
const transition = this._interruptionLifecycle?.requestResume(this._interruptionLifecycle.snapshot().owner, "resume requested by active owner") ?? null;
|
|
409087
409808
|
if (transition && !transition.accepted)
|
|
409088
409809
|
return transition;
|
|
@@ -409092,6 +409813,11 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409092
409813
|
this._paused = false;
|
|
409093
409814
|
this._inputWaitPaused = false;
|
|
409094
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
|
+
}
|
|
409095
409821
|
this._releasePauseWaiters();
|
|
409096
409822
|
return resumed;
|
|
409097
409823
|
}
|
|
@@ -409224,10 +409950,15 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409224
409950
|
}
|
|
409225
409951
|
/** Persist exact owned work before an update can replace this process. */
|
|
409226
409952
|
prepareUpdateRestartCheckpoint() {
|
|
409227
|
-
if (this.
|
|
409953
|
+
if (this._updateRestartCheckpointForced)
|
|
409954
|
+
return this._updateRestartCheckpointSaved;
|
|
409955
|
+
return this._prepareUpdateRestartCheckpoint(false);
|
|
409956
|
+
}
|
|
409957
|
+
_prepareUpdateRestartCheckpoint(allowUnresolvedEffects) {
|
|
409958
|
+
if (!allowUnresolvedEffects && this.taskRequirementInterpretationPending)
|
|
409228
409959
|
return false;
|
|
409229
409960
|
const state = this._interruptionLifecycle?.snapshot();
|
|
409230
|
-
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"))
|
|
409231
409962
|
return false;
|
|
409232
409963
|
if (!this._saveCompletionLedgerSafe())
|
|
409233
409964
|
throw new Error("paused_run_checkpoint_ledger_not_durable");
|
|
@@ -409244,7 +409975,7 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409244
409975
|
messages2.push({
|
|
409245
409976
|
role: "tool",
|
|
409246
409977
|
tool_call_id: id5,
|
|
409247
|
-
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.`
|
|
409248
409979
|
});
|
|
409249
409980
|
const checkpoint = {
|
|
409250
409981
|
schema: "omnius.paused-run-checkpoint.v1",
|
|
@@ -409260,7 +409991,33 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
|
|
|
409260
409991
|
observedEffects: [...this._expectedOutcomeObservedEffects],
|
|
409261
409992
|
modelRequestGeneration: this._modelRequestGeneration,
|
|
409262
409993
|
toolPromotions: this._checkpointToolPromotions(),
|
|
409263
|
-
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
|
+
}
|
|
409264
410021
|
};
|
|
409265
410022
|
const body = JSON.stringify(checkpoint);
|
|
409266
410023
|
const stored = this._artifactStore().put({
|
|
@@ -409351,13 +410108,192 @@ Earlier host presentation and its quoted source/history bytes are retained lossl
|
|
|
409351
410108
|
throw new Error("paused_run_checkpoint_invalid_identity");
|
|
409352
410109
|
const archived = this._artifactStore().read(selector.reference);
|
|
409353
410110
|
const checkpoint = JSON.parse(archived.content);
|
|
409354
|
-
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)) {
|
|
409355
410112
|
throw new Error("paused_run_checkpoint_invalid_snapshot");
|
|
409356
410113
|
}
|
|
409357
410114
|
return checkpoint;
|
|
409358
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
|
+
}
|
|
409359
410293
|
/** Resolve one persisted ambiguous effect before admitting another run. */
|
|
409360
410294
|
resolveInterruptionEffect(operationId, state, evidenceId) {
|
|
410295
|
+
if (this._updateRestartCheckpointForced)
|
|
410296
|
+
return false;
|
|
409361
410297
|
const resolved = this._interruptionLifecycle?.resolveAmbiguousEffect(operationId, state, evidenceId) ?? false;
|
|
409362
410298
|
this._reconcileRetiredLegacyOperations(this.interruptionState);
|
|
409363
410299
|
return resolved;
|
|
@@ -409416,6 +410352,10 @@ Earlier host presentation and its quoted source/history bytes are retained lossl
|
|
|
409416
410352
|
* Returns true if the loop should continue, false if aborted while paused.
|
|
409417
410353
|
*/
|
|
409418
410354
|
async waitIfPaused() {
|
|
410355
|
+
if (this._updateRestartCheckpointForced && this.aborted)
|
|
410356
|
+
throw new InputWaitInterruption();
|
|
410357
|
+
if (this.aborted)
|
|
410358
|
+
return false;
|
|
409419
410359
|
if (!this._paused)
|
|
409420
410360
|
return true;
|
|
409421
410361
|
this._interruptionLifecycle?.acknowledgePauseBoundary();
|
|
@@ -409426,6 +410366,8 @@ Earlier host presentation and its quoted source/history bytes are retained lossl
|
|
|
409426
410366
|
await new Promise((resolve42) => {
|
|
409427
410367
|
this._pauseWaiters.add(resolve42);
|
|
409428
410368
|
});
|
|
410369
|
+
if (this._updateRestartCheckpointForced)
|
|
410370
|
+
throw new InputWaitInterruption();
|
|
409429
410371
|
return !this.aborted;
|
|
409430
410372
|
}
|
|
409431
410373
|
/** Commit a streamed final reply only after its model owner reached a safe boundary. */
|
|
@@ -411269,6 +412211,8 @@ ${rawTask}`;
|
|
|
411269
412211
|
if (this.options.trajectoryCheckpoint === "shadow" || this.options.trajectoryGrounding === "off") {
|
|
411270
412212
|
return null;
|
|
411271
412213
|
}
|
|
412214
|
+
if (this._hasUnresolvedCurrentSteeringInputs() || this._currentSteeringReplyPending() || this._currentAdjudicationArgumentRepair(turn))
|
|
412215
|
+
return null;
|
|
411272
412216
|
const { id: _id, revision: _revision, turn: _turn, ...base } = checkpoint;
|
|
411273
412217
|
const semanticKey = this._loopRecoveryAdvisoryKey();
|
|
411274
412218
|
const baseFingerprint = `${trajectoryCheckpointFingerprint(base)}:${semanticKey}`;
|
|
@@ -411344,12 +412288,29 @@ ${rawTask}`;
|
|
|
411344
412288
|
this._trajectoryGroundingAttemptedFingerprint = baseFingerprint;
|
|
411345
412289
|
this._trajectoryGroundingMaterial = materialFingerprint;
|
|
411346
412290
|
const review = this._beginRecoveryReview("trajectory");
|
|
412291
|
+
const grounding = { controller: new AbortController(), runId: this.currentArtifactRunId(), taskEpoch: this._taskEpoch };
|
|
412292
|
+
this._trajectoryGroundingRequest = grounding;
|
|
412293
|
+
const signal = AbortSignal.any([
|
|
412294
|
+
grounding.controller.signal,
|
|
412295
|
+
this._abortController.signal,
|
|
412296
|
+
this._turnAbortController.signal,
|
|
412297
|
+
this._inputWaitBoundaryController.signal
|
|
412298
|
+
]);
|
|
412299
|
+
const owner = this._interruptionOwnerId;
|
|
412300
|
+
const requestGeneration = this._modelRequestGeneration;
|
|
412301
|
+
const assertCurrent = () => {
|
|
412302
|
+
signal.throwIfAborted();
|
|
412303
|
+
if (grounding.runId !== this.currentArtifactRunId() || grounding.taskEpoch !== this._taskEpoch || owner !== this._interruptionOwnerId || requestGeneration !== this._modelRequestGeneration || !this._recoveryReviewIsCurrent(review) || this._hasUnresolvedCurrentSteeringInputs())
|
|
412304
|
+
throw new InputWaitInterruption();
|
|
412305
|
+
};
|
|
411347
412306
|
try {
|
|
412307
|
+
assertCurrent();
|
|
411348
412308
|
this._emitModelResolutionTelemetry("trajectory_grounding", turn);
|
|
411349
412309
|
const backend = this._auxInferenceBackend({
|
|
411350
|
-
dumpStage: "trajectory_grounding"
|
|
412310
|
+
dumpStage: "trajectory_grounding",
|
|
412311
|
+
assertCurrent
|
|
411351
412312
|
});
|
|
411352
|
-
const response = await backend.chatCompletion({
|
|
412313
|
+
const response = await withInputWaitCancellation(signal, () => backend.chatCompletion({
|
|
411353
412314
|
messages: [
|
|
411354
412315
|
{
|
|
411355
412316
|
role: "system",
|
|
@@ -411368,8 +412329,10 @@ ${rawTask}`;
|
|
|
411368
412329
|
timeoutMs: this.options.requestTimeoutMs,
|
|
411369
412330
|
// The output is an explicit concise assessment, not a hidden-think
|
|
411370
412331
|
// transcript. Keep Qwen's structured response path reliable.
|
|
411371
|
-
think: false
|
|
411372
|
-
|
|
412332
|
+
think: false,
|
|
412333
|
+
signal
|
|
412334
|
+
}));
|
|
412335
|
+
assertCurrent();
|
|
411373
412336
|
const generated = parseTrajectoryGeneratedGrounding(response.choices?.[0]?.message?.content ?? "", checkpoint.groundedFacts.map((fact) => fact.evidence));
|
|
411374
412337
|
if (!this._recoveryReviewIsCurrent(review))
|
|
411375
412338
|
return null;
|
|
@@ -411425,7 +412388,9 @@ ${rawTask}`;
|
|
|
411425
412388
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
411426
412389
|
});
|
|
411427
412390
|
return generated;
|
|
411428
|
-
} catch {
|
|
412391
|
+
} catch (error) {
|
|
412392
|
+
if (signal.aborted || error instanceof InputWaitInterruption || !this._recoveryReviewIsCurrent(review))
|
|
412393
|
+
return null;
|
|
411429
412394
|
this.emit({
|
|
411430
412395
|
type: "status",
|
|
411431
412396
|
content: "Trajectory grounding unavailable; retaining deterministic safety orientation",
|
|
@@ -411433,6 +412398,9 @@ ${rawTask}`;
|
|
|
411433
412398
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
411434
412399
|
});
|
|
411435
412400
|
return null;
|
|
412401
|
+
} finally {
|
|
412402
|
+
if (this._trajectoryGroundingRequest === grounding)
|
|
412403
|
+
this._trajectoryGroundingRequest = null;
|
|
411436
412404
|
}
|
|
411437
412405
|
}
|
|
411438
412406
|
/**
|
|
@@ -411444,6 +412412,8 @@ ${rawTask}`;
|
|
|
411444
412412
|
_observabilityActionSequence = 0;
|
|
411445
412413
|
_observabilityPendingActions = /* @__PURE__ */ new Map();
|
|
411446
412414
|
emit(event) {
|
|
412415
|
+
if (this._updateRestartCheckpointForced)
|
|
412416
|
+
return;
|
|
411447
412417
|
if (event.type === "tool_call" && event.toolName !== "task_complete" && !this._isProgressTool(event.toolName ?? "")) {
|
|
411448
412418
|
const candidate = this._latestModelVisibleAssistantText;
|
|
411449
412419
|
this._telegramDeliveryRefinementCandidateKey = this._isTelegramSurface() && candidate?.runId === this.currentArtifactRunId() && candidate.taskEpoch === this._taskEpoch ? [candidate.runId, candidate.taskEpoch, candidate.turn].join(":") : void 0;
|
|
@@ -411887,7 +412857,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
411887
412857
|
try {
|
|
411888
412858
|
if (pending.size)
|
|
411889
412859
|
this.abort();
|
|
411890
|
-
if (admitted && !terminalAccepted)
|
|
412860
|
+
if (admitted && !terminalAccepted && !this._updateRestartCheckpointForced)
|
|
411891
412861
|
lifecycle?.requestStop(lifecycle.snapshot().owner, "host session closed without inferring task completion");
|
|
411892
412862
|
this._saveCompletionLedgerSafe();
|
|
411893
412863
|
} catch (error) {
|
|
@@ -411900,6 +412870,8 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
411900
412870
|
}
|
|
411901
412871
|
/** Run a task through the agentic loop; a host session may not re-enter it. */
|
|
411902
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.");
|
|
411903
412875
|
if (this._exclusiveTaskOwner || this._activeDirectToolCalls)
|
|
411904
412876
|
throw new Error("A task or direct call already owns this runner.");
|
|
411905
412877
|
this._exclusiveTaskOwner = "model";
|
|
@@ -412088,6 +413060,36 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
412088
413060
|
this._taskEpoch = recovered.taskEpoch;
|
|
412089
413061
|
this._activeRunId = recovered.runId;
|
|
412090
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
|
+
}
|
|
412091
413093
|
if (pausedCheckpoint) {
|
|
412092
413094
|
actualUserGoal = pausedCheckpoint.goal;
|
|
412093
413095
|
this._interruptionExplicitGoal = pausedCheckpoint.goal;
|
|
@@ -412107,6 +413109,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
412107
413109
|
const acknowledged = lifecycle.acknowledgeResume("restart recovery checks complete");
|
|
412108
413110
|
if (!acknowledged.accepted)
|
|
412109
413111
|
throw new Error(acknowledged.reason);
|
|
413112
|
+
this._paused = false;
|
|
412110
413113
|
const priorGeneration = pausedCheckpoint?.modelRequestGeneration ?? 0;
|
|
412111
413114
|
if (!Number.isSafeInteger(acknowledged.sequence) || acknowledged.sequence <= priorGeneration) {
|
|
412112
413115
|
throw new Error("paused_run_checkpoint_invalid_request_generation");
|
|
@@ -412862,6 +413865,8 @@ ${dynamicProjectContext}`
|
|
|
412862
413865
|
retainedTaskHistory = this._refreshPausedTelegramNativeContext(retainedTaskHistory, dynamicContextMessages, currentNativeInstruction);
|
|
412863
413866
|
messages2.splice(0, messages2.length, ...currentRuntimePolicy, ...retainedTaskHistory);
|
|
412864
413867
|
}
|
|
413868
|
+
if (pausedCheckpoint)
|
|
413869
|
+
this._restoreForcedIntake(pausedCheckpoint);
|
|
412865
413870
|
this._interruptionMessages = messages2;
|
|
412866
413871
|
const preflightMemoryRecall = await this._buildPreflightTaskMemoryRecall(persistentTaskGoal);
|
|
412867
413872
|
if (preflightMemoryRecall) {
|
|
@@ -413875,12 +414880,16 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
413875
414880
|
};
|
|
413876
414881
|
const preparedToolArguments = /* @__PURE__ */ new WeakMap();
|
|
413877
414882
|
const originalToolArguments = /* @__PURE__ */ new WeakMap();
|
|
414883
|
+
const preparedAdjudicationRepairs = /* @__PURE__ */ new WeakMap();
|
|
413878
414884
|
const prepareToolArguments = async (tc, toolTurn) => {
|
|
413879
414885
|
if (preparedToolArguments.has(tc))
|
|
413880
414886
|
return preparedToolArguments.get(tc);
|
|
413881
414887
|
originalToolArguments.set(tc, structuredClone(tc.arguments ?? {}));
|
|
414888
|
+
const preparationScope = { runId: this.currentArtifactRunId(), taskEpoch: this._taskEpoch, ownerId: this._interruptionOwnerId };
|
|
414889
|
+
const preparationIsCurrent = () => preparationScope.runId === this.currentArtifactRunId() && preparationScope.taskEpoch === this._taskEpoch && preparationScope.ownerId === this._interruptionOwnerId;
|
|
413882
414890
|
const resolved = this.lookupRegisteredTool(tc.name);
|
|
413883
414891
|
let error = null;
|
|
414892
|
+
let adjudicationArgs;
|
|
413884
414893
|
if (resolved && !(tc.arguments && "_raw" in tc.arguments)) {
|
|
413885
414894
|
try {
|
|
413886
414895
|
const workflow = extractFeatureWorkflowToolBinding(tc.arguments ?? {});
|
|
@@ -413894,6 +414903,18 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
413894
414903
|
args = this._autoDeriveDelegationMutationScope(resolved.name, args, toolTurn);
|
|
413895
414904
|
args = await this._enrichDelegationToolArgs(resolved.name, args, messages2, toolTurn);
|
|
413896
414905
|
}
|
|
414906
|
+
if (resolved.name === ADJUDICATION_TOOL_NAME) {
|
|
414907
|
+
adjudicationArgs = args;
|
|
414908
|
+
tc.arguments = args;
|
|
414909
|
+
const prior = preparationIsCurrent() ? this._currentAdjudicationArgumentRepair() : null;
|
|
414910
|
+
if (prior?.argsKey === this._buildExactArgsKey(args)) {
|
|
414911
|
+
const replay = { ...prior, turn: toolTurn, repeats: prior.repeats + 1, settled: false };
|
|
414912
|
+
preparedAdjudicationRepairs.set(tc, replay);
|
|
414913
|
+
this._adjudicationArgumentRepair = replay;
|
|
414914
|
+
preparedToolArguments.set(tc, prior.error);
|
|
414915
|
+
return prior.error;
|
|
414916
|
+
}
|
|
414917
|
+
}
|
|
413897
414918
|
if (resolved.tool.inputSchema)
|
|
413898
414919
|
args = this._parsedToolArgumentRecord(resolved.tool.inputSchema.parse(args));
|
|
413899
414920
|
else {
|
|
@@ -413906,6 +414927,22 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
413906
414927
|
this._featureWorkflowBindings.set(args, workflow.cardId);
|
|
413907
414928
|
} catch (caught) {
|
|
413908
414929
|
error = caught instanceof Error ? caught.message : String(caught);
|
|
414930
|
+
if (resolved.name === ADJUDICATION_TOOL_NAME && adjudicationArgs && preparationIsCurrent()) {
|
|
414931
|
+
const repair = {
|
|
414932
|
+
...preparationScope,
|
|
414933
|
+
tool: resolved.tool,
|
|
414934
|
+
schema: resolved.tool.inputSchema,
|
|
414935
|
+
parameters: JSON.stringify(resolved.tool.parameters),
|
|
414936
|
+
argsKey: this._buildExactArgsKey(adjudicationArgs),
|
|
414937
|
+
contract: adjudicationArgumentRepairContract(error, _createHash("sha256").update(this._buildExactArgsKey(adjudicationArgs)).digest("hex")),
|
|
414938
|
+
error,
|
|
414939
|
+
turn: toolTurn,
|
|
414940
|
+
repeats: 0,
|
|
414941
|
+
settled: false
|
|
414942
|
+
};
|
|
414943
|
+
preparedAdjudicationRepairs.set(tc, repair);
|
|
414944
|
+
this._adjudicationArgumentRepair = repair;
|
|
414945
|
+
}
|
|
413909
414946
|
}
|
|
413910
414947
|
}
|
|
413911
414948
|
preparedToolArguments.set(tc, error);
|
|
@@ -414891,7 +415928,8 @@ ${cachedResult}`,
|
|
|
414891
415928
|
if (resolvedTool && !this._isToolExposedForModelCall(resolvedTool.name) && !this._admitDeferredDirectCall(resolvedTool.name, turn)) {
|
|
414892
415929
|
result = this._missingCapabilityResult(resolvedTool.name, turn);
|
|
414893
415930
|
} else if (preparedArgumentError && tool) {
|
|
414894
|
-
const
|
|
415931
|
+
const admittedRepair = preparedAdjudicationRepairs.get(tc);
|
|
415932
|
+
const repair = this.buildToolArgumentRepairFeedback(tc.name, tc.arguments, tool, preparedArgumentError, admittedRepair);
|
|
414895
415933
|
runtimeSystemGuidance = repair.systemGuidance;
|
|
414896
415934
|
result = {
|
|
414897
415935
|
success: false,
|
|
@@ -414900,6 +415938,21 @@ ${cachedResult}`,
|
|
|
414900
415938
|
llmContent: repair.llmContent,
|
|
414901
415939
|
runtimeAuthored: true
|
|
414902
415940
|
};
|
|
415941
|
+
const argumentRepair = admittedRepair && this._adjudicationArgumentRepairIsCurrent(admittedRepair) && admittedRepair.argsKey === this._buildExactArgsKey(tc.arguments) ? admittedRepair : null;
|
|
415942
|
+
if (argumentRepair) {
|
|
415943
|
+
argumentRepair.settled = true;
|
|
415944
|
+
this._adjudicationArgumentRepair = argumentRepair;
|
|
415945
|
+
result.data = { kind: "adjudication_argument_repair", contract: argumentRepair.contract };
|
|
415946
|
+
result.failure = { kind: "schema_validation", field: argumentRepair.contract.fields[0]?.path };
|
|
415947
|
+
result.failureDiagnosis = {
|
|
415948
|
+
...classifyRuntimeFailure({ toolName: resolvedTool.name, failure: result.failure, errorText: repair.error }),
|
|
415949
|
+
retryable: false,
|
|
415950
|
+
createRecoveryCard: false,
|
|
415951
|
+
guidance: repair.systemGuidance
|
|
415952
|
+
};
|
|
415953
|
+
if (argumentRepair.repeats)
|
|
415954
|
+
repeatShortCircuit = result;
|
|
415955
|
+
}
|
|
414903
415956
|
} else if (repeatShortCircuit) {
|
|
414904
415957
|
result = repeatShortCircuit;
|
|
414905
415958
|
} else if (tc.arguments && "_raw" in tc.arguments) {
|
|
@@ -416484,6 +417537,8 @@ ${bookkeepingGuidance}` : bookkeepingGuidance;
|
|
|
416484
417537
|
}
|
|
416485
417538
|
if (result.success) {
|
|
416486
417539
|
delete result.failureDiagnosis;
|
|
417540
|
+
if (result.runtimeAuthored !== true && this._currentAdjudicationArgumentRepair()?.settled)
|
|
417541
|
+
this._adjudicationArgumentRepair = null;
|
|
416487
417542
|
} else if (!processWasStopped && !completionReviewIsPending && !this._isPdfTerminalFeedback(result)) {
|
|
416488
417543
|
this._diagnoseToolFailure(tc.name, tc.arguments, result);
|
|
416489
417544
|
const staleHashRetryGuidance = this._buildStaleHashRetryGuidance(tc.name, tc.arguments, result);
|
|
@@ -418850,7 +419905,12 @@ ${memoryLines.join("\n")}`
|
|
|
418850
419905
|
}
|
|
418851
419906
|
const { maxOutputTokens: effectiveMaxTokens } = this.contextLimits();
|
|
418852
419907
|
this.gcSystemMessages(requestMessages2);
|
|
419908
|
+
const steeringBeforeVirtualContext = new Set(this.pendingSteeringInputs);
|
|
418853
419909
|
const virtualEvidenceMessages = await this._buildLiveVirtualContextMessages(task, requestMessages2, turn, toolDefs);
|
|
419910
|
+
if (this.pendingSteeringInputs.some((input) => !steeringBeforeVirtualContext.has(input) && !["cancelled", "superseded", "consumed"].includes(input.state))) {
|
|
419911
|
+
--localTurn;
|
|
419912
|
+
continue;
|
|
419913
|
+
}
|
|
418854
419914
|
if (virtualEvidenceMessages.length > 0) {
|
|
418855
419915
|
const insertionIndex = requestMessages2[0]?.role === "system" ? 1 : 0;
|
|
418856
419916
|
requestMessages2.splice(insertionIndex, 0, ...virtualEvidenceMessages);
|
|
@@ -419423,6 +420483,7 @@ ${transportFailure2}` : transportFailure2;
|
|
|
419423
420483
|
if (!choice)
|
|
419424
420484
|
break;
|
|
419425
420485
|
const msg = choice.message;
|
|
420486
|
+
this._observePrimarySteeringReply(response["_rawTypedModelContent"] ?? msg.content, turn, !this.options.streamEnabled && Boolean(msg.toolCalls?.length));
|
|
419426
420487
|
this._reconcileActiveSteeringFromModel(response["_rawTypedModelContent"] ?? msg.content, turn, messages2);
|
|
419427
420488
|
if (this._preparedTaskScopeBoundary && this._pendingSteeringPreemption) {
|
|
419428
420489
|
await this._applySteeringAtSafeBoundary(messages2, turn);
|
|
@@ -420299,6 +421360,8 @@ Your most recent tool calls SUCCEEDED. If the task is complete, call task_comple
|
|
|
420299
421360
|
} catch {
|
|
420300
421361
|
}
|
|
420301
421362
|
}
|
|
421363
|
+
if (this._updateRestartCheckpointForced)
|
|
421364
|
+
throw new InputWaitInterruption();
|
|
420302
421365
|
let prevCycleSubstantiveProgress = substantiveProgressCount;
|
|
420303
421366
|
while (!completed && !this.aborted && !nonRetryableBackendFailure && !this._terminalRuntimeFailure && !this._completionIncompleteVerification && this.options.bruteForce && bruteForceCycle < this.options.bruteForceMaxCycles) {
|
|
420304
421367
|
bruteForceCycle++;
|
|
@@ -420457,7 +421520,12 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
420457
421520
|
}
|
|
420458
421521
|
this._insertContextFrame(compactedMsgs, await this._buildTurnContextFrame(turn, compactedMsgs, void 0, bfEnvironmentBlock));
|
|
420459
421522
|
this.gcSystemMessages(compactedMsgs);
|
|
421523
|
+
const steeringBeforeVirtualContext = new Set(this.pendingSteeringInputs);
|
|
420460
421524
|
const virtualEvidenceMessages = await this._buildLiveVirtualContextMessages(persistentTaskGoal, compactedMsgs, turn, toolDefs);
|
|
421525
|
+
if (this.pendingSteeringInputs.some((input) => !steeringBeforeVirtualContext.has(input) && !["cancelled", "superseded", "consumed"].includes(input.state))) {
|
|
421526
|
+
--localTurn;
|
|
421527
|
+
continue;
|
|
421528
|
+
}
|
|
420461
421529
|
const bfRequestMessages = compactedMsgs.map((message) => ({
|
|
420462
421530
|
...message
|
|
420463
421531
|
}));
|
|
@@ -420777,6 +421845,7 @@ ${diagnosis}` : diagnosis;
|
|
|
420777
421845
|
if (!choice)
|
|
420778
421846
|
break;
|
|
420779
421847
|
const msg = choice.message;
|
|
421848
|
+
this._observePrimarySteeringReply(response["_rawTypedModelContent"] ?? msg.content, turn, !this.options.streamEnabled && Boolean(msg.toolCalls?.length));
|
|
420780
421849
|
this._reconcileActiveSteeringFromModel(response["_rawTypedModelContent"] ?? msg.content, turn, messages2);
|
|
420781
421850
|
if (this._preparedTaskScopeBoundary && this._pendingSteeringPreemption) {
|
|
420782
421851
|
await this._applySteeringAtSafeBoundary(messages2, turn);
|
|
@@ -421060,6 +422129,8 @@ ${diagnosis}` : diagnosis;
|
|
|
421060
422129
|
} catch {
|
|
421061
422130
|
}
|
|
421062
422131
|
}
|
|
422132
|
+
if (this._updateRestartCheckpointForced)
|
|
422133
|
+
throw new InputWaitInterruption();
|
|
421063
422134
|
const durationMs = Date.now() - start;
|
|
421064
422135
|
const incompleteVerification = this._completionIncompleteVerification;
|
|
421065
422136
|
if (incompleteVerification && !summary) {
|
|
@@ -422371,6 +423442,8 @@ Result: ${summary.slice(0, 330)}`,
|
|
|
422371
423442
|
// -------------------------------------------------------------------------
|
|
422372
423443
|
/** Inject an image into the running conversation (for drag-drop / paste) */
|
|
422373
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.");
|
|
422374
423447
|
const marker = `[IMAGE_BASE64:${mimeType}:${base64}]`;
|
|
422375
423448
|
this.pendingUserMessages.push(description ? `${description}
|
|
422376
423449
|
${marker}` : marker);
|
|
@@ -429166,6 +430239,9 @@ var OllamaAgenticBackend = class _OllamaAgenticBackend {
|
|
|
429166
430239
|
if (enabledGpuUuids !== void 0) {
|
|
429167
430240
|
headers["X-Ollama-Unify-GPU-UUIDs"] = enabledGpuUuids.length > 0 ? enabledGpuUuids.join(",") : "none";
|
|
429168
430241
|
}
|
|
430242
|
+
if (cpuOffloadAllowedFromEnv()) {
|
|
430243
|
+
headers["X-Ollama-Unify-CPU-Offload"] = "allow";
|
|
430244
|
+
}
|
|
429169
430245
|
const envOverride = process.env["OMNIUS_OLLAMA_BROKER_ADMISSION_WAIT_MS"];
|
|
429170
430246
|
const classDefault = workloadClass === "background" ? 500 : workloadClass === "interactive-control" ? 3e4 : void 0;
|
|
429171
430247
|
const configured = Number.parseInt(String(request?.brokerAdmissionWaitMs ?? envOverride ?? classDefault ?? 0), 10);
|
|
@@ -430321,114 +431397,6 @@ init_dist3();
|
|
|
430321
431397
|
init_ollama_pool();
|
|
430322
431398
|
init_ollama_pool_cleanup();
|
|
430323
431399
|
|
|
430324
|
-
// packages/orchestrator/dist/adjudication.js
|
|
430325
|
-
import { z as z25 } from "zod";
|
|
430326
|
-
var IdSchema = z25.string().trim().min(1).max(96).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/, "use a stable identifier without whitespace");
|
|
430327
|
-
var AdjudicationEvidenceSchema = z25.object({
|
|
430328
|
-
id: IdSchema,
|
|
430329
|
-
content: z25.string().trim().min(1).max(32e3),
|
|
430330
|
-
source: z25.string().trim().min(1).max(500),
|
|
430331
|
-
kind: z25.enum([
|
|
430332
|
-
"fact",
|
|
430333
|
-
"observation",
|
|
430334
|
-
"artifact",
|
|
430335
|
-
"test_result",
|
|
430336
|
-
"testimony",
|
|
430337
|
-
"constraint",
|
|
430338
|
-
"precedent"
|
|
430339
|
-
]).default("observation"),
|
|
430340
|
-
observedAt: z25.string().trim().max(80).optional(),
|
|
430341
|
-
sha256: z25.string().trim().regex(/^[a-fA-F0-9]{64}$/).optional(),
|
|
430342
|
-
reliability: z25.number().min(0).max(1).optional()
|
|
430343
|
-
});
|
|
430344
|
-
var AdjudicationArgumentSchema = z25.object({
|
|
430345
|
-
id: IdSchema,
|
|
430346
|
-
position: z25.string().trim().min(1).max(160),
|
|
430347
|
-
claim: z25.string().trim().min(1).max(4e3),
|
|
430348
|
-
citedEvidenceIds: z25.array(IdSchema).min(1).max(64),
|
|
430349
|
-
submittedBy: z25.string().trim().max(160).optional()
|
|
430350
|
-
});
|
|
430351
|
-
var AdjudicationConstituentInputSchema = z25.object({
|
|
430352
|
-
id: IdSchema.optional(),
|
|
430353
|
-
label: z25.string().trim().min(1).max(120),
|
|
430354
|
-
question: z25.string().trim().min(1).max(2e3),
|
|
430355
|
-
instructions: z25.string().trim().max(2e3).optional(),
|
|
430356
|
-
evidenceIds: z25.array(IdSchema).min(1).max(128).optional(),
|
|
430357
|
-
argumentIds: z25.array(IdSchema).max(64).optional(),
|
|
430358
|
-
decisionRuleIds: z25.array(IdSchema).max(32).optional()
|
|
430359
|
-
});
|
|
430360
|
-
var AdjudicationInputSchema = z25.object({
|
|
430361
|
-
caseId: IdSchema.optional(),
|
|
430362
|
-
question: z25.string().trim().min(1).max(4e3),
|
|
430363
|
-
context: z25.string().trim().max(8e3).optional(),
|
|
430364
|
-
exclusions: z25.array(z25.string().trim().min(1).max(2e3)).max(32).default([]),
|
|
430365
|
-
allowedOutcomes: z25.array(IdSchema).min(2).max(12),
|
|
430366
|
-
decisionRules: z25.array(z25.string().trim().min(1).max(2e3)).max(24).default([]),
|
|
430367
|
-
burdenOfProof: z25.enum([
|
|
430368
|
-
"best_supported",
|
|
430369
|
-
"preponderance",
|
|
430370
|
-
"clear_and_convincing",
|
|
430371
|
-
"beyond_reasonable_doubt",
|
|
430372
|
-
"risk_averse"
|
|
430373
|
-
]).default("best_supported"),
|
|
430374
|
-
evidence: z25.array(AdjudicationEvidenceSchema).min(1).max(128),
|
|
430375
|
-
arguments: z25.array(AdjudicationArgumentSchema).max(64).default([]),
|
|
430376
|
-
constituents: z25.array(AdjudicationConstituentInputSchema).min(2).max(6).optional(),
|
|
430377
|
-
panelSize: z25.number().int().min(2).max(6).default(3),
|
|
430378
|
-
maxConcurrency: z25.number().int().min(1).max(6).default(3),
|
|
430379
|
-
quorum: z25.number().int().min(2).max(6).optional(),
|
|
430380
|
-
constituentExecution: z25.enum(["auto", "full_sub_agent", "direct"]).default("auto"),
|
|
430381
|
-
timeoutMs: z25.number().int().min(5e3).max(6e5).default(12e4),
|
|
430382
|
-
maxTokensPerConstituent: z25.number().int().min(512).max(8192).default(2048),
|
|
430383
|
-
maxJudgeTokens: z25.number().int().min(768).max(12288).default(3072)
|
|
430384
|
-
});
|
|
430385
|
-
var PlannerResponseSchema = z25.object({
|
|
430386
|
-
schemaVersion: z25.literal(1),
|
|
430387
|
-
caseId: IdSchema,
|
|
430388
|
-
assignments: z25.array(z25.object({
|
|
430389
|
-
id: IdSchema,
|
|
430390
|
-
label: z25.string().trim().min(1).max(120),
|
|
430391
|
-
question: z25.string().trim().min(1).max(2e3),
|
|
430392
|
-
instructions: z25.string().trim().max(2e3).default(""),
|
|
430393
|
-
evidenceIds: z25.array(IdSchema).min(1).max(128),
|
|
430394
|
-
argumentIds: z25.array(IdSchema).max(64).default([]),
|
|
430395
|
-
decisionRuleIds: z25.array(IdSchema).min(1).max(32)
|
|
430396
|
-
})).min(2).max(6)
|
|
430397
|
-
});
|
|
430398
|
-
var ConstituentResponseSchema = z25.object({
|
|
430399
|
-
schemaVersion: z25.literal(1),
|
|
430400
|
-
caseId: IdSchema,
|
|
430401
|
-
constituentId: IdSchema,
|
|
430402
|
-
assessment: z25.string().trim().min(20).max(8e3),
|
|
430403
|
-
recommendation: IdSchema,
|
|
430404
|
-
confidence: z25.number().min(0).max(1),
|
|
430405
|
-
citedEvidenceIds: z25.array(IdSchema).min(1).max(128),
|
|
430406
|
-
claims: z25.array(z25.object({
|
|
430407
|
-
claim: z25.string().trim().min(1).max(2e3),
|
|
430408
|
-
evidenceIds: z25.array(IdSchema).min(1).max(64)
|
|
430409
|
-
})).min(1).max(24),
|
|
430410
|
-
counterarguments: z25.array(z25.string().trim().min(1).max(2e3)).max(16).default([]),
|
|
430411
|
-
uncertainties: z25.array(z25.string().trim().min(1).max(2e3)).max(16).default([])
|
|
430412
|
-
});
|
|
430413
|
-
var JudgeResponseSchema = z25.object({
|
|
430414
|
-
schemaVersion: z25.literal(1),
|
|
430415
|
-
caseId: IdSchema,
|
|
430416
|
-
verdict: IdSchema,
|
|
430417
|
-
confidence: z25.number().min(0).max(1),
|
|
430418
|
-
rationale: z25.string().trim().min(30).max(12e3),
|
|
430419
|
-
citedEvidenceIds: z25.array(IdSchema).min(1).max(128),
|
|
430420
|
-
consideredConstituentIds: z25.array(IdSchema).min(2).max(6),
|
|
430421
|
-
acceptedFindingIds: z25.array(IdSchema).max(144),
|
|
430422
|
-
rejectedFindingIds: z25.array(IdSchema).max(144),
|
|
430423
|
-
dissent: z25.array(z25.object({
|
|
430424
|
-
constituentId: IdSchema,
|
|
430425
|
-
recommendation: IdSchema,
|
|
430426
|
-
summary: z25.string().trim().min(1).max(2e3)
|
|
430427
|
-
})).max(6).default([]),
|
|
430428
|
-
unresolvedQuestions: z25.array(z25.string().trim().min(1).max(2e3)).max(24).default([]),
|
|
430429
|
-
nextAction: z25.string().trim().min(1).max(4e3)
|
|
430430
|
-
});
|
|
430431
|
-
|
|
430432
431400
|
// packages/orchestrator/dist/agent-types.js
|
|
430433
431401
|
var READ_ONLY_TOOLS = [
|
|
430434
431402
|
"file_read",
|