omnius 1.0.890 → 1.0.892

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/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
 
@@ -338743,7 +338747,7 @@ var init_ollama_pool = __esm({
338743
338747
  continue;
338744
338748
  }
338745
338749
  const PROBE_GRACE_MS = 3e4;
338746
- if (inst.state.inflight === 0 && Date.now() - inst.state.spawnedAtMs > PROBE_GRACE_MS && await this.isPartialVramSpilled(inst)) {
338750
+ if (!cpuOffloadAllowedFromEnv() && inst.state.inflight === 0 && Date.now() - inst.state.spawnedAtMs > PROBE_GRACE_MS && await this.isPartialVramSpilled(inst)) {
338747
338751
  const reapedAtMs = Date.now();
338748
338752
  await inst.terminate();
338749
338753
  this.dropAffinityFor(inst.state.id);
@@ -352353,9 +352357,9 @@ function sourceSpan(content, observation) {
352353
352357
  }
352354
352358
  function projectQualifiedSourceBodies(input) {
352355
352359
  const observations = new Map(input.observations.filter((observation) => issued5.has(observation) && observation.scope === input.scope).map((observation) => [observation.callId, observation]));
352356
- const calls = new Set(input.messages.flatMap((message) => {
352360
+ const calls = new Map(input.messages.flatMap((message) => {
352357
352361
  const value = message;
352358
- return value["role"] === "assistant" && Array.isArray(value["tool_calls"]) ? value["tool_calls"].flatMap((call2) => call2 && typeof call2 === "object" && call2.function?.name === "file_read" && typeof call2.id === "string" ? [call2.id] : []) : [];
352362
+ return value["role"] === "assistant" && Array.isArray(value["tool_calls"]) ? value["tool_calls"].flatMap((call2) => call2 && typeof call2 === "object" && ["file_read", "web_fetch"].includes(call2.function?.name) && typeof call2.id === "string" ? [[call2.id, call2.function.name]] : []) : [];
352359
352363
  }));
352360
352364
  const carriers = [];
352361
352365
  input.messages.forEach((message, index) => {
@@ -352364,7 +352368,7 @@ function projectQualifiedSourceBodies(input) {
352364
352368
  if (value["role"] !== "tool" || typeof value["content"] !== "string" || typeof callId !== "string" || !calls.has(callId))
352365
352369
  return;
352366
352370
  const observation = observations.get(callId);
352367
- if (!observation)
352371
+ if (!observation || calls.get(callId) !== (observation.toolName ?? "file_read"))
352368
352372
  return;
352369
352373
  const span = sourceSpan(value["content"], observation);
352370
352374
  if (!span)
@@ -352383,7 +352387,7 @@ function projectQualifiedSourceBodies(input) {
352383
352387
  if (carrier.protected)
352384
352388
  continue;
352385
352389
  const own = carrier.observation;
352386
- const covering = carriers.filter((candidate) => candidate.observation.path === own.path && candidate.observation.sourceHash === own.sourceHash && candidate.observation.startLine <= own.startLine && candidate.observation.endLine >= own.endLine).sort((a, b) => b.observation.endLine - b.observation.startLine - (a.observation.endLine - a.observation.startLine) || Number(b.protected) - Number(a.protected) || b.index - a.index);
352390
+ const covering = carriers.filter((candidate) => (candidate.observation.toolName ?? "file_read") === (own.toolName ?? "file_read") && candidate.observation.path === own.path && candidate.observation.sourceHash === own.sourceHash && candidate.observation.startLine <= own.startLine && candidate.observation.endLine >= own.endLine).sort((a, b) => b.observation.endLine - b.observation.startLine - (a.observation.endLine - a.observation.startLine) || Number(b.protected) - Number(a.protected) || b.index - a.index);
352387
352391
  const keeper = covering[0];
352388
352392
  if (!keeper || keeper === carrier)
352389
352393
  continue;
@@ -352526,6 +352530,193 @@ var NativeOllamaToolCalls = class {
352526
352530
  }
352527
352531
  };
352528
352532
 
352533
+ // packages/orchestrator/dist/tool-argument-repair.js
352534
+ function shape2(parameters) {
352535
+ const properties = parameters["properties"];
352536
+ return {
352537
+ properties: new Set(properties && typeof properties === "object" && !Array.isArray(properties) ? Object.keys(properties) : []),
352538
+ required: Array.isArray(parameters["required"]) ? parameters["required"].filter((key) => typeof key === "string") : []
352539
+ };
352540
+ }
352541
+ function findBetterToolSchemaMatches(input) {
352542
+ const keys4 = [...new Set(input.providedKeys.filter((key) => !key.startsWith("_")))];
352543
+ if (!keys4.length)
352544
+ return [];
352545
+ const provided = new Set(keys4), requested = shape2(input.requestedParameters);
352546
+ const requestedMissing = requested.required.filter((key) => !provided.has(key)).length;
352547
+ const requestedUnknown = keys4.filter((key) => !requested.properties.has(key)).length;
352548
+ if (!requestedMissing && !requestedUnknown)
352549
+ return [];
352550
+ const matches = /* @__PURE__ */ new Map();
352551
+ for (const candidate of input.candidates) {
352552
+ if (candidate.name === input.requestedToolName)
352553
+ continue;
352554
+ const target2 = shape2(candidate.parameters ?? {});
352555
+ if (!target2.properties.size || target2.required.some((key) => !provided.has(key)) || keys4.some((key) => !target2.properties.has(key)))
352556
+ continue;
352557
+ matches.set(candidate.name, keys4.length * 2 + target2.required.length * 3);
352558
+ }
352559
+ return [...matches].sort(([left, leftScore], [right, rightScore]) => rightScore - leftScore || left.localeCompare(right)).slice(0, 3).map(([name]) => name);
352560
+ }
352561
+
352562
+ // packages/orchestrator/dist/adjudication.js
352563
+ import { z as z18 } from "zod";
352564
+ var ADJUDICATION_TOOL_NAME = "adjudicate";
352565
+ var ADJUDICATION_ID_PATTERN = "^[A-Za-z0-9][A-Za-z0-9._:-]*$";
352566
+ function adjudicationArgumentRepairContract(error, argsHash) {
352567
+ let issues = [];
352568
+ try {
352569
+ const parsed = JSON.parse(error);
352570
+ if (Array.isArray(parsed))
352571
+ issues = parsed.filter((issue3) => issue3 && typeof issue3 === "object");
352572
+ } catch {
352573
+ }
352574
+ const parameters = adjudicationToolParameters();
352575
+ const fields2 = issues.slice(0, 8).map((issue3) => {
352576
+ const parts = Array.isArray(issue3.path) ? issue3.path : [];
352577
+ let schema = parameters;
352578
+ for (const part of parts) {
352579
+ const next = typeof part === "number" ? schema?.items : schema?.properties?.[part];
352580
+ schema = next && typeof next === "object" && !Array.isArray(next) ? next : void 0;
352581
+ }
352582
+ const constraints = schema && Object.fromEntries(Object.entries(schema).filter(([key]) => ["type", "minLength", "maxLength", "pattern", "enum", "minimum", "maximum", "minItems", "maxItems", "required"].includes(key)));
352583
+ return {
352584
+ path: parts.map((part) => typeof part === "number" ? `[${part}]` : part).join(".").replace(/\.\[/g, "[") || "arguments",
352585
+ message: String(issue3.message ?? "invalid value"),
352586
+ ...constraints ? { schema: constraints } : {}
352587
+ };
352588
+ });
352589
+ return {
352590
+ reason_code: "invalid_tool_arguments",
352591
+ tool: ADJUDICATION_TOOL_NAME,
352592
+ retryable: false,
352593
+ ...argsHash ? { args_sha256: argsHash } : {},
352594
+ fields: fields2.length ? fields2 : [{ path: "arguments", message: error.slice(0, 1400) }]
352595
+ };
352596
+ }
352597
+ function formatAdjudicationArgumentRepair(error, argsHash) {
352598
+ const contract = adjudicationArgumentRepairContract(error, argsHash);
352599
+ return [
352600
+ "[ADJUDICATION_ARGUMENT_REPAIR]",
352601
+ JSON.stringify(contract),
352602
+ ...contract.fields.map((field) => `${field.path}: ${field.message}`),
352603
+ "Required keys for adjudicate: question, allowedOutcomes, evidence",
352604
+ `IDs must be 1–96 characters matching ${ADJUDICATION_ID_PATTERN}; no whitespace or sentence-valued IDs.`,
352605
+ 'Format-only example: allowedOutcomes=["option_a","option_b"], context="option_a means the first described outcome; option_b means the second described outcome".',
352606
+ "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.",
352607
+ "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."
352608
+ ].join("\n");
352609
+ }
352610
+ 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.");
352611
+ var AdjudicationEvidenceSchema = z18.object({
352612
+ id: IdSchema,
352613
+ content: z18.string().trim().min(1).max(32e3),
352614
+ source: z18.string().trim().min(1).max(500),
352615
+ kind: z18.enum([
352616
+ "fact",
352617
+ "observation",
352618
+ "artifact",
352619
+ "test_result",
352620
+ "testimony",
352621
+ "constraint",
352622
+ "precedent"
352623
+ ]).default("observation"),
352624
+ observedAt: z18.string().trim().max(80).optional(),
352625
+ sha256: z18.string().trim().regex(/^[a-fA-F0-9]{64}$/).optional(),
352626
+ reliability: z18.number().min(0).max(1).optional()
352627
+ });
352628
+ var AdjudicationArgumentSchema = z18.object({
352629
+ id: IdSchema,
352630
+ position: z18.string().trim().min(1).max(160),
352631
+ claim: z18.string().trim().min(1).max(4e3),
352632
+ citedEvidenceIds: z18.array(IdSchema).min(1).max(64),
352633
+ submittedBy: z18.string().trim().max(160).optional()
352634
+ });
352635
+ var AdjudicationConstituentInputSchema = z18.object({
352636
+ id: IdSchema.optional(),
352637
+ label: z18.string().trim().min(1).max(120),
352638
+ question: z18.string().trim().min(1).max(2e3),
352639
+ instructions: z18.string().trim().max(2e3).optional(),
352640
+ evidenceIds: z18.array(IdSchema).min(1).max(128).optional(),
352641
+ argumentIds: z18.array(IdSchema).max(64).optional(),
352642
+ decisionRuleIds: z18.array(IdSchema).max(32).optional()
352643
+ });
352644
+ var AdjudicationInputSchema = z18.object({
352645
+ caseId: IdSchema.optional(),
352646
+ question: z18.string().trim().min(1).max(4e3).describe("The exact decision question. Ask one decision only."),
352647
+ context: z18.string().trim().max(8e3).optional().describe("Neutral context needed to interpret the record, including each stable outcome ID's prose meaning."),
352648
+ 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."),
352649
+ 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."),
352650
+ decisionRules: z18.array(z18.string().trim().min(1).max(2e3)).max(24).default([]).describe("Rules the judge must apply."),
352651
+ burdenOfProof: z18.enum([
352652
+ "best_supported",
352653
+ "preponderance",
352654
+ "clear_and_convincing",
352655
+ "beyond_reasonable_doubt",
352656
+ "risk_averse"
352657
+ ]).default("best_supported"),
352658
+ evidence: z18.array(AdjudicationEvidenceSchema).min(1).max(128),
352659
+ arguments: z18.array(AdjudicationArgumentSchema).max(64).default([]),
352660
+ constituents: z18.array(AdjudicationConstituentInputSchema).min(2).max(6).optional().describe("Optional independent focus assignments. Omit to let the case framer derive them."),
352661
+ panelSize: z18.number().int().min(2).max(6).default(3),
352662
+ maxConcurrency: z18.number().int().min(1).max(6).default(3),
352663
+ quorum: z18.number().int().min(2).max(6).optional(),
352664
+ 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."),
352665
+ timeoutMs: z18.number().int().min(5e3).max(6e5).default(12e4),
352666
+ maxTokensPerConstituent: z18.number().int().min(512).max(8192).default(2048),
352667
+ maxJudgeTokens: z18.number().int().min(768).max(12288).default(3072)
352668
+ });
352669
+ function adjudicationToolParameters() {
352670
+ const { $schema: _dialect, ...parameters } = z18.toJSONSchema(AdjudicationInputSchema, { target: "draft-7", io: "input" });
352671
+ return parameters;
352672
+ }
352673
+ var PlannerResponseSchema = z18.object({
352674
+ schemaVersion: z18.literal(1),
352675
+ caseId: IdSchema,
352676
+ assignments: z18.array(z18.object({
352677
+ id: IdSchema,
352678
+ label: z18.string().trim().min(1).max(120),
352679
+ question: z18.string().trim().min(1).max(2e3),
352680
+ instructions: z18.string().trim().max(2e3).default(""),
352681
+ evidenceIds: z18.array(IdSchema).min(1).max(128),
352682
+ argumentIds: z18.array(IdSchema).max(64).default([]),
352683
+ decisionRuleIds: z18.array(IdSchema).min(1).max(32)
352684
+ })).min(2).max(6)
352685
+ });
352686
+ var ConstituentResponseSchema = z18.object({
352687
+ schemaVersion: z18.literal(1),
352688
+ caseId: IdSchema,
352689
+ constituentId: IdSchema,
352690
+ assessment: z18.string().trim().min(20).max(8e3),
352691
+ recommendation: IdSchema,
352692
+ confidence: z18.number().min(0).max(1),
352693
+ citedEvidenceIds: z18.array(IdSchema).min(1).max(128),
352694
+ claims: z18.array(z18.object({
352695
+ claim: z18.string().trim().min(1).max(2e3),
352696
+ evidenceIds: z18.array(IdSchema).min(1).max(64)
352697
+ })).min(1).max(24),
352698
+ counterarguments: z18.array(z18.string().trim().min(1).max(2e3)).max(16).default([]),
352699
+ uncertainties: z18.array(z18.string().trim().min(1).max(2e3)).max(16).default([])
352700
+ });
352701
+ var JudgeResponseSchema = z18.object({
352702
+ schemaVersion: z18.literal(1),
352703
+ caseId: IdSchema,
352704
+ verdict: IdSchema,
352705
+ confidence: z18.number().min(0).max(1),
352706
+ rationale: z18.string().trim().min(30).max(12e3),
352707
+ citedEvidenceIds: z18.array(IdSchema).min(1).max(128),
352708
+ consideredConstituentIds: z18.array(IdSchema).min(2).max(6),
352709
+ acceptedFindingIds: z18.array(IdSchema).max(144),
352710
+ rejectedFindingIds: z18.array(IdSchema).max(144),
352711
+ dissent: z18.array(z18.object({
352712
+ constituentId: IdSchema,
352713
+ recommendation: IdSchema,
352714
+ summary: z18.string().trim().min(1).max(2e3)
352715
+ })).max(6).default([]),
352716
+ unresolvedQuestions: z18.array(z18.string().trim().min(1).max(2e3)).max(24).default([]),
352717
+ nextAction: z18.string().trim().min(1).max(4e3)
352718
+ });
352719
+
352529
352720
  // packages/orchestrator/dist/openai-chat-stream-parser.js
352530
352721
  var object10 = (value) => value !== null && typeof value === "object" && !Array.isArray(value);
352531
352722
  var MAX_PACKET_BYTES = 8388608;
@@ -355125,15 +355316,15 @@ var SelfImprovementArchive = class {
355125
355316
  import { createHash as createHash69, randomUUID as randomUUID41 } from "node:crypto";
355126
355317
  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
355318
  import { dirname as dirname23, join as join40 } from "node:path";
355128
- import { z as z19 } from "zod";
355319
+ import { z as z20 } from "zod";
355129
355320
 
355130
355321
  // packages/orchestrator/dist/commandEvidenceReceipt.js
355131
- import { z as z18 } from "zod";
355132
- var token2 = z18.string().refine((value) => value.trim().length > 0 && !value.includes("\0"));
355133
- var timestamp2 = z18.string().datetime({ offset: true });
355134
- var integer3 = z18.number().int().safe();
355135
- var CommandEvidenceReceiptSchema = z18.object({
355136
- schema: z18.literal("omnius.command-evidence-receipt.v1"),
355322
+ import { z as z19 } from "zod";
355323
+ var token2 = z19.string().refine((value) => value.trim().length > 0 && !value.includes("\0"));
355324
+ var timestamp2 = z19.string().datetime({ offset: true });
355325
+ var integer3 = z19.number().int().safe();
355326
+ var CommandEvidenceReceiptSchema = z19.object({
355327
+ schema: z19.literal("omnius.command-evidence-receipt.v1"),
355137
355328
  command: token2,
355138
355329
  canonicalCommand: token2,
355139
355330
  cwd: token2,
@@ -355141,20 +355332,20 @@ var CommandEvidenceReceiptSchema = z18.object({
355141
355332
  primaryCommand: token2.optional(),
355142
355333
  primaryExitCode: integer3.nullable().optional(),
355143
355334
  runnerExitCode: integer3.nullable().optional(),
355144
- primaryExitProvenance: z18.enum(["runner_process", "trailing_exit_reporter"]).optional(),
355145
- pipefail: z18.boolean(),
355146
- timedOut: z18.boolean(),
355335
+ primaryExitProvenance: z19.enum(["runner_process", "trailing_exit_reporter"]).optional(),
355336
+ pipefail: z19.boolean(),
355337
+ timedOut: z19.boolean(),
355147
355338
  startedAtIso: timestamp2,
355148
355339
  finishedAtIso: timestamp2,
355149
- shellRunId: z18.string().uuid().optional(),
355340
+ shellRunId: z19.string().uuid().optional(),
355150
355341
  timeoutMs: integer3.positive().nullable().optional(),
355151
- cancelled: z18.boolean().optional(),
355342
+ cancelled: z19.boolean().optional(),
355152
355343
  signal: token2.nullable().optional(),
355153
- observation: z18.object({ kind: z18.literal("search_no_match") }).strict().optional(),
355344
+ observation: z19.object({ kind: z19.literal("search_no_match") }).strict().optional(),
355154
355345
  outputRef: token2.optional(),
355155
- observedPaths: z18.array(token2).optional(),
355156
- artifactHashes: z18.array(z18.object({ path: token2, sha256: z18.string().regex(/^[a-f0-9]{64}$/) }).strict()).optional(),
355157
- declaredVerification: z18.object({ protocol: z18.literal("OMNIUS_VERIFICATION_RESULT"), outcome: z18.enum(["pass", "fail"]) }).strict().optional()
355346
+ observedPaths: z19.array(token2).optional(),
355347
+ artifactHashes: z19.array(z19.object({ path: token2, sha256: z19.string().regex(/^[a-f0-9]{64}$/) }).strict()).optional(),
355348
+ declaredVerification: z19.object({ protocol: z19.literal("OMNIUS_VERIFICATION_RESULT"), outcome: z19.enum(["pass", "fail"]) }).strict().optional()
355158
355349
  }).strict().refine((value) => Date.parse(value.finishedAtIso) >= Date.parse(value.startedAtIso));
355159
355350
  function parseCommandEvidenceReceipt(value) {
355160
355351
  try {
@@ -355167,21 +355358,21 @@ function parseCommandEvidenceReceipt(value) {
355167
355358
 
355168
355359
  // packages/orchestrator/dist/conversationReportEvidence.js
355169
355360
  var SCHEMA = "omnius.conversation-report-evidence.v2";
355170
- var token3 = z19.string().refine((value) => value.trim().length > 0 && !value.includes("\0"));
355171
- var timestamp3 = z19.string().datetime({ offset: true });
355172
- var integer4 = z19.number().int().safe();
355173
- var identitySchema = z19.object({ sessionId: token3, runId: token3, taskEpoch: integer4.nonnegative() }).strict();
355174
- var reference = z19.string().regex(/^omnius-artifact:\/\/sha256\/[a-f0-9]{64}$/);
355175
- var paths = z19.array(token3);
355176
- var deliveryReceiptSchema = z19.object({
355177
- schema: z19.literal("omnius.completion-delivery-receipt.v1"),
355361
+ var token3 = z20.string().refine((value) => value.trim().length > 0 && !value.includes("\0"));
355362
+ var timestamp3 = z20.string().datetime({ offset: true });
355363
+ var integer4 = z20.number().int().safe();
355364
+ var identitySchema = z20.object({ sessionId: token3, runId: token3, taskEpoch: integer4.nonnegative() }).strict();
355365
+ var reference = z20.string().regex(/^omnius-artifact:\/\/sha256\/[a-f0-9]{64}$/);
355366
+ var paths = z20.array(token3);
355367
+ var deliveryReceiptSchema = z20.object({
355368
+ schema: z20.literal("omnius.completion-delivery-receipt.v1"),
355178
355369
  provider: token3,
355179
355370
  target: token3,
355180
355371
  receiptId: token3,
355181
355372
  deliveredAtIso: timestamp3,
355182
355373
  artifactPaths: paths.optional()
355183
355374
  }).strict();
355184
- var objectiveEvidenceKindSchema = z19.enum([
355375
+ var objectiveEvidenceKindSchema = z20.enum([
355185
355376
  "visible_response",
355186
355377
  "observation",
355187
355378
  "mutation",
@@ -355193,79 +355384,79 @@ var objectiveEvidenceKindSchema = z19.enum([
355193
355384
  "authenticated_session",
355194
355385
  "human_input"
355195
355386
  ]);
355196
- var externalEffectReceiptSchema = z19.object({
355197
- schema: z19.literal("omnius.external-effect-receipt.v1"),
355387
+ var externalEffectReceiptSchema = z20.object({
355388
+ schema: z20.literal("omnius.external-effect-receipt.v1"),
355198
355389
  effectKind: token3,
355199
355390
  semanticTarget: token3,
355200
355391
  idempotencyKey: token3,
355201
- effectState: z19.enum(["pending", "applied", "absent", "unknown"]),
355392
+ effectState: z20.enum(["pending", "applied", "absent", "unknown"]),
355202
355393
  artifactRevision: token3.optional(),
355203
355394
  evidenceId: token3,
355204
- criterionIds: z19.array(token3),
355205
- evidenceKinds: z19.array(objectiveEvidenceKindSchema).optional(),
355206
- destination: z19.object({ url: z19.string().url(), provider: token3 }).strict().optional()
355395
+ criterionIds: z20.array(token3),
355396
+ evidenceKinds: z20.array(objectiveEvidenceKindSchema).optional(),
355397
+ destination: z20.object({ url: z20.string().url(), provider: token3 }).strict().optional()
355207
355398
  }).strict();
355208
- var verificationReceiptSchema = z19.object({
355209
- schema: z19.literal("omnius.verification-receipt.v1"),
355399
+ var verificationReceiptSchema = z20.object({
355400
+ schema: z20.literal("omnius.verification-receipt.v1"),
355210
355401
  evidenceId: token3,
355211
355402
  criterionId: token3,
355212
355403
  artifactEvidenceId: token3,
355213
355404
  artifactRevision: token3.optional(),
355214
355405
  verifierMethod: token3,
355215
- outcome: z19.enum(["passed", "artifact_failed", "verifier_invalid", "downstream_auth_required", "inconclusive"]),
355216
- evidenceIds: z19.array(token3),
355217
- evidenceKinds: z19.array(objectiveEvidenceKindSchema).optional()
355406
+ outcome: z20.enum(["passed", "artifact_failed", "verifier_invalid", "downstream_auth_required", "inconclusive"]),
355407
+ evidenceIds: z20.array(token3),
355408
+ evidenceKinds: z20.array(objectiveEvidenceKindSchema).optional()
355218
355409
  }).strict();
355219
- var externalBlockerSchema = z19.object({
355220
- schema: z19.literal("omnius.objective-external-blocker.v1"),
355221
- criterionIds: z19.array(token3),
355410
+ var externalBlockerSchema = z20.object({
355411
+ schema: z20.literal("omnius.objective-external-blocker.v1"),
355412
+ criterionIds: z20.array(token3),
355222
355413
  evidenceId: token3,
355223
355414
  blockerKind: token3,
355224
- retryable: z19.boolean()
355415
+ retryable: z20.boolean()
355225
355416
  }).strict();
355226
- var evidenceSchema = z19.object({
355417
+ var evidenceSchema = z20.object({
355227
355418
  id: token3,
355228
- kind: z19.literal("tool_result"),
355419
+ kind: z20.literal("tool_result"),
355229
355420
  observedAtIso: timestamp3,
355230
- summary: z19.string(),
355421
+ summary: z20.string(),
355231
355422
  toolName: token3,
355232
- success: z19.boolean().optional(),
355423
+ success: z20.boolean().optional(),
355233
355424
  rawRef: token3.optional(),
355234
355425
  targetPaths: paths.optional(),
355235
- role: z19.enum(["observation", "verification", "mutation", "blocker", "delivery"]).optional(),
355426
+ role: z20.enum(["observation", "verification", "mutation", "blocker", "delivery"]).optional(),
355236
355427
  family: token3.optional(),
355237
- verificationImpact: z19.enum(["invalidates", "neutral"]).optional(),
355238
- metrics: z19.record(z19.string(), z19.unknown()).optional(),
355428
+ verificationImpact: z20.enum(["invalidates", "neutral"]).optional(),
355429
+ metrics: z20.record(z20.string(), z20.unknown()).optional(),
355239
355430
  receipt: CommandEvidenceReceiptSchema.optional(),
355240
355431
  deliveryReceipt: deliveryReceiptSchema.optional(),
355241
- progressClass: z19.enum(["work_product", "control_bookkeeping", "observation", "blocker"]).optional(),
355242
- criterionIds: z19.array(token3).optional(),
355243
- objectiveEvidenceKinds: z19.array(objectiveEvidenceKindSchema).optional(),
355432
+ progressClass: z20.enum(["work_product", "control_bookkeeping", "observation", "blocker"]).optional(),
355433
+ criterionIds: z20.array(token3).optional(),
355434
+ objectiveEvidenceKinds: z20.array(objectiveEvidenceKindSchema).optional(),
355244
355435
  externalEffectReceipt: externalEffectReceiptSchema.optional(),
355245
355436
  verificationReceipt: verificationReceiptSchema.optional(),
355246
355437
  externalBlocker: externalBlockerSchema.optional()
355247
355438
  }).strict();
355248
- var chunkSchema = z19.object({
355249
- schema: z19.literal(SCHEMA),
355439
+ var chunkSchema = z20.object({
355440
+ schema: z20.literal(SCHEMA),
355250
355441
  identity: identitySchema,
355251
355442
  previousReference: reference.nullable(),
355252
355443
  sequence: integer4.positive(),
355253
355444
  startEntry: integer4.nonnegative(),
355254
355445
  entryCount: integer4.nonnegative(),
355255
- entries: z19.array(z19.object({ callId: token3, evidence: evidenceSchema }).strict()),
355446
+ entries: z20.array(z20.object({ callId: token3, evidence: evidenceSchema }).strict()),
355256
355447
  ledgerCreatedAtIso: timestamp3,
355257
355448
  updatedAtIso: timestamp3,
355258
355449
  recoveryGap: token3.max(500).optional()
355259
355450
  }).strict();
355260
- var pointerSchema = z19.object({
355261
- schema: z19.literal(SCHEMA),
355451
+ var pointerSchema = z20.object({
355452
+ schema: z20.literal(SCHEMA),
355262
355453
  identity: identitySchema,
355263
355454
  reference,
355264
355455
  entryCount: integer4.nonnegative(),
355265
355456
  chunkCount: integer4.positive()
355266
355457
  }).strict();
355267
- var pendingSchema = z19.object({
355268
- schema: z19.literal(SCHEMA),
355458
+ var pendingSchema = z20.object({
355459
+ schema: z20.literal(SCHEMA),
355269
355460
  identity: identitySchema,
355270
355461
  previousReference: reference.nullable(),
355271
355462
  previousEntryCount: integer4.nonnegative(),
@@ -355472,7 +355663,7 @@ var ConversationReportEvidence = class {
355472
355663
  this.persistedChunkCount = pointer.chunkCount;
355473
355664
  this.persistedGap = chain[0].recoveryGap;
355474
355665
  } catch (error) {
355475
- const detail = error instanceof z19.ZodError || error instanceof SyntaxError ? "Saved report evidence has invalid fields or contains task authority." : error instanceof Error ? error.message : String(error);
355666
+ 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
355667
  this.recoveryGap = `Earlier conversation evidence could not be restored: ${detail}${pendingGap ? ` ${pendingGap}` : ""}`.slice(0, 500);
355477
355668
  }
355478
355669
  }
@@ -355607,7 +355798,7 @@ init_dist5();
355607
355798
  import { createHash as createHash71 } from "node:crypto";
355608
355799
  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
355800
  import { dirname as dirname24, isAbsolute as isAbsolute13, join as join42, relative as relative9, resolve as resolve27 } from "node:path";
355610
- import { z as z20 } from "zod";
355801
+ import { z as z21 } from "zod";
355611
355802
 
355612
355803
  // packages/orchestrator/dist/contentAddressedArtifactStore.js
355613
355804
  import { createHash as createHash70, randomUUID as randomUUID42 } from "node:crypto";
@@ -356478,10 +356669,10 @@ var equal = (a, b) => canonical6(a) === canonical6(b);
356478
356669
  function fail3(reason) {
356479
356670
  throw new Error(`feature_workflow_${reason}`);
356480
356671
  }
356481
- var token4 = z20.string().trim().min(1).max(1e3);
356482
- var integer5 = z20.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
356483
- var ref7 = z20.string().regex(/^omnius-artifact:\/\/sha256\/[a-f0-9]{64}$/);
356484
- var digest5 = z20.string().regex(/^[a-f0-9]{64}$/);
356672
+ var token4 = z21.string().trim().min(1).max(1e3);
356673
+ var integer5 = z21.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
356674
+ var ref7 = z21.string().regex(/^omnius-artifact:\/\/sha256\/[a-f0-9]{64}$/);
356675
+ var digest5 = z21.string().regex(/^[a-f0-9]{64}$/);
356485
356676
  function featureWorkflowInputArtifactsHash(artifacts) {
356486
356677
  return createHash71("sha256").update(JSON.stringify([...artifacts].sort((a, b) => a.slotId.localeCompare(b.slotId)).map((a) => ({
356487
356678
  slotId: a.slotId,
@@ -356489,13 +356680,13 @@ function featureWorkflowInputArtifactsHash(artifacts) {
356489
356680
  content: a.content
356490
356681
  })))).digest("hex");
356491
356682
  }
356492
- var identitySchema2 = z20.object({
356683
+ var identitySchema2 = z21.object({
356493
356684
  sessionId: token4,
356494
356685
  runId: token4,
356495
356686
  taskEpoch: integer5,
356496
356687
  generation: integer5
356497
356688
  }).strict();
356498
- var bindingSchema = z20.object({
356689
+ var bindingSchema = z21.object({
356499
356690
  parentOperationId: token4,
356500
356691
  parentRunId: token4,
356501
356692
  parentGeneration: integer5,
@@ -356503,22 +356694,22 @@ var bindingSchema = z20.object({
356503
356694
  cardId: token4,
356504
356695
  planReference: ref7,
356505
356696
  cardContract: digest5,
356506
- inputSlots: z20.record(token4, ref7),
356507
- kind: z20.enum(["work", "review", "verification"]),
356508
- readOnly: z20.boolean(),
356509
- ownedFiles: z20.array(token4).max(128),
356697
+ inputSlots: z21.record(token4, ref7),
356698
+ kind: z21.enum(["work", "review", "verification"]),
356699
+ readOnly: z21.boolean(),
356700
+ ownedFiles: z21.array(token4).max(128),
356510
356701
  inputArtifactsHash: digest5
356511
356702
  }).strict();
356512
356703
  var childSchema = bindingSchema.extend({
356513
- schema: z20.literal("omnius.feature-workflow-child-receipt.v1"),
356704
+ schema: z21.literal("omnius.feature-workflow-child-receipt.v1"),
356514
356705
  childId: token4,
356515
356706
  childRunId: token4,
356516
356707
  childTaskEpoch: integer5,
356517
356708
  childInputHash: digest5,
356518
- status: z20.enum(["completed", "failed", "cancelled", "running"]),
356709
+ status: z21.enum(["completed", "failed", "cancelled", "running"]),
356519
356710
  terminalReceiptId: token4.optional()
356520
356711
  }).strict();
356521
- var slotSchema = z20.object({
356712
+ var slotSchema = z21.object({
356522
356713
  reference: ref7,
356523
356714
  cardId: token4,
356524
356715
  cardContract: digest5,
@@ -356527,61 +356718,61 @@ var slotSchema = z20.object({
356527
356718
  mutationSequence: integer5,
356528
356719
  workspaceRevision: digest5
356529
356720
  }).strict();
356530
- var operationSchema = z20.object({
356721
+ var operationSchema = z21.object({
356531
356722
  binding: bindingSchema,
356532
356723
  actorId: token4,
356533
356724
  toolName: token4,
356534
356725
  command: token4.optional(),
356535
- effect: z20.enum(["read_only", "local_mutation", "external_effect"]),
356536
- state: z20.enum(["pending", "interrupted"]),
356726
+ effect: z21.enum(["read_only", "local_mutation", "external_effect"]),
356727
+ state: z21.enum(["pending", "interrupted"]),
356537
356728
  mutationSequence: integer5,
356538
356729
  workspaceRevision: digest5
356539
356730
  }).strict();
356540
- var resultSchema = z20.object({
356731
+ var resultSchema = z21.object({
356541
356732
  binding: bindingSchema,
356542
356733
  actorId: token4,
356543
- success: z20.boolean(),
356734
+ success: z21.boolean(),
356544
356735
  receiptReference: ref7,
356545
- reviewDisposition: z20.enum(["approved", "changes_requested"]).optional(),
356736
+ reviewDisposition: z21.enum(["approved", "changes_requested"]).optional(),
356546
356737
  childReceipt: childSchema.optional(),
356547
- commandReceipt: z20.unknown().optional(),
356738
+ commandReceipt: z21.unknown().optional(),
356548
356739
  childReportReference: ref7.optional(),
356549
- blockers: z20.array(token4).max(96),
356550
- unresolvedQuestions: z20.array(token4).max(32),
356740
+ blockers: z21.array(token4).max(96),
356741
+ unresolvedQuestions: z21.array(token4).max(32),
356551
356742
  mutationSequence: integer5,
356552
356743
  workspaceRevision: digest5
356553
356744
  }).strict();
356554
- var commandReceiptSchema = z20.object({
356555
- schema: z20.literal("omnius.command-evidence-receipt.v1"),
356745
+ var commandReceiptSchema = z21.object({
356746
+ schema: z21.literal("omnius.command-evidence-receipt.v1"),
356556
356747
  command: token4,
356557
356748
  canonicalCommand: token4,
356558
356749
  cwd: token4,
356559
- pipefail: z20.boolean(),
356560
- timedOut: z20.boolean(),
356561
- cancelled: z20.boolean().optional(),
356562
- startedAtIso: z20.string().datetime(),
356563
- finishedAtIso: z20.string().datetime(),
356564
- exitCode: z20.number().int().nullable().optional(),
356565
- primaryExitCode: z20.number().int().nullable().optional()
356750
+ pipefail: z21.boolean(),
356751
+ timedOut: z21.boolean(),
356752
+ cancelled: z21.boolean().optional(),
356753
+ startedAtIso: z21.string().datetime(),
356754
+ finishedAtIso: z21.string().datetime(),
356755
+ exitCode: z21.number().int().nullable().optional(),
356756
+ primaryExitCode: z21.number().int().nullable().optional()
356566
356757
  }).passthrough();
356567
- var checkpointSchema = z20.object({
356568
- schema: z20.literal(SCHEMA2),
356758
+ var checkpointSchema = z21.object({
356759
+ schema: z21.literal(SCHEMA2),
356569
356760
  identity: identitySchema2,
356570
356761
  boardRunId: token4,
356571
356762
  planReference: ref7,
356572
356763
  sequence: integer5,
356573
356764
  mutationSequence: integer5,
356574
- slots: z20.record(token4, slotSchema),
356575
- operations: z20.record(token4, operationSchema),
356576
- results: z20.record(token4, resultSchema),
356577
- recentSettlements: z20.array(z20.object({ operationId: token4, resultHash: digest5 }).strict()).max(256),
356578
- retired: z20.object({
356765
+ slots: z21.record(token4, slotSchema),
356766
+ operations: z21.record(token4, operationSchema),
356767
+ results: z21.record(token4, resultSchema),
356768
+ recentSettlements: z21.array(z21.object({ operationId: token4, resultHash: digest5 }).strict()).max(256),
356769
+ retired: z21.object({
356579
356770
  reason: token4,
356580
- at: z20.string().datetime(),
356771
+ at: z21.string().datetime(),
356581
356772
  toEpoch: integer5.optional()
356582
356773
  }).strict().optional(),
356583
356774
  workingDir: token4,
356584
- adoptions: z20.array(z20.object({
356775
+ adoptions: z21.array(z21.object({
356585
356776
  from: identitySchema2,
356586
356777
  to: identitySchema2,
356587
356778
  sourceCheckpointReference: ref7,
@@ -356858,8 +357049,8 @@ var FeatureWorkflowController = class {
356858
357049
  return this.state;
356859
357050
  }
356860
357051
  assertCurrentSelector() {
356861
- const actual = existsSync32(this.selectorPath) ? z20.object({
356862
- schema: z20.literal(SELECTOR_SCHEMA),
357052
+ const actual = existsSync32(this.selectorPath) ? z21.object({
357053
+ schema: z21.literal(SELECTOR_SCHEMA),
356863
357054
  checkpointReference: ref7
356864
357055
  }).strict().parse(JSON.parse(readFileSync36(this.selectorPath, "utf8"))).checkpointReference : null;
356865
357056
  if (actual !== this.selectorReference) {
@@ -356995,8 +357186,8 @@ var FeatureWorkflowController = class {
356995
357186
  try {
356996
357187
  if (!existsSync32(this.selectorPath)) {
356997
357188
  const matches = this.selectorCandidates().filter((file) => {
356998
- const selector2 = z20.object({
356999
- schema: z20.literal(SELECTOR_SCHEMA),
357189
+ const selector2 = z21.object({
357190
+ schema: z21.literal(SELECTOR_SCHEMA),
357000
357191
  checkpointReference: ref7
357001
357192
  }).strict().parse(JSON.parse(readFileSync36(join42(dirname24(this.selectorPath), file), "utf8")));
357002
357193
  const state2 = checkpointSchema.parse(JSON.parse(this.store.read(selector2.checkpointReference).content));
@@ -357008,8 +357199,8 @@ var FeatureWorkflowController = class {
357008
357199
  fail3("same_run_checkpoint_not_unique");
357009
357200
  this.selectorPath = join42(dirname24(this.selectorPath), matches[0]);
357010
357201
  }
357011
- const selector = z20.object({
357012
- schema: z20.literal(SELECTOR_SCHEMA),
357202
+ const selector = z21.object({
357203
+ schema: z21.literal(SELECTOR_SCHEMA),
357013
357204
  checkpointReference: ref7
357014
357205
  }).strict().parse(JSON.parse(readFileSync36(this.selectorPath, "utf8")));
357015
357206
  const state = checkpointSchema.parse(JSON.parse(this.store.read(selector.checkpointReference).content));
@@ -357063,8 +357254,8 @@ var FeatureWorkflowController = class {
357063
357254
  return [];
357064
357255
  const results = [];
357065
357256
  for (const file of this.selectorCandidates()) {
357066
- const selector = z20.object({
357067
- schema: z20.literal(SELECTOR_SCHEMA),
357257
+ const selector = z21.object({
357258
+ schema: z21.literal(SELECTOR_SCHEMA),
357068
357259
  checkpointReference: ref7
357069
357260
  }).strict().parse(JSON.parse(readFileSync36(join42(directory, file), "utf8")));
357070
357261
  const state = checkpointSchema.parse(JSON.parse(this.store.read(selector.checkpointReference).content));
@@ -357091,8 +357282,8 @@ var FeatureWorkflowController = class {
357091
357282
  fail3("continuation_not_found");
357092
357283
  const matches = [];
357093
357284
  for (const file of this.selectorCandidates()) {
357094
- const selector = z20.object({
357095
- schema: z20.literal(SELECTOR_SCHEMA),
357285
+ const selector = z21.object({
357286
+ schema: z21.literal(SELECTOR_SCHEMA),
357096
357287
  checkpointReference: ref7
357097
357288
  }).strict().parse(JSON.parse(readFileSync36(join42(directory, file), "utf8")));
357098
357289
  const state = checkpointSchema.parse(JSON.parse(this.store.read(selector.checkpointReference).content));
@@ -357145,7 +357336,7 @@ var FeatureWorkflowController = class {
357145
357336
  if (card.phase === "implementation" && !card.ownedFiles.some((path7) => failed.verifier.targetPaths.some((target2) => resolve27(this.options.workingDir, path7) === resolve27(this.options.workingDir, target2))))
357146
357337
  fail3("repair_not_failed_verifier_target");
357147
357338
  }
357148
- const reason = z20.string().trim().min(1).max(4e3).parse(input.reason);
357339
+ const reason = z21.string().trim().min(1).max(4e3).parse(input.reason);
357149
357340
  const affected = /* @__PURE__ */ new Set([card.id]);
357150
357341
  for (const item of compileFeatureWorkflow(plan).cards) {
357151
357342
  const candidate = plan.cards.find((c) => featureWorkflowCardId(plan, c.id) === item.id);
@@ -359177,7 +359368,7 @@ function checkDoomLoop(context) {
359177
359368
  // packages/orchestrator/dist/steeringIntake.js
359178
359369
  import { appendFileSync as appendFileSync4, existsSync as existsSync34, mkdirSync as mkdirSync28, readFileSync as readFileSync39 } from "node:fs";
359179
359370
  import { join as join44 } from "node:path";
359180
- import { z as z21 } from "zod";
359371
+ import { z as z22 } from "zod";
359181
359372
  function classifySteeringIntent(content, requestedIntent) {
359182
359373
  void content;
359183
359374
  return requestedIntent ?? "context_only";
@@ -359189,12 +359380,12 @@ function steeringGatesOldPlan(intent) {
359189
359380
  return intent !== "cancel";
359190
359381
  }
359191
359382
  var LEDGER_FILE = "steering-ledger.jsonl";
359192
- var SteeringInterpretationSchema = z21.object({
359193
- inference: z21.string().trim().min(1),
359194
- runnerInstruction: z21.string().trim().min(1),
359195
- conflicts: z21.array(z21.string().trim().min(1)).optional().default([]),
359196
- alternatives: z21.array(z21.string().trim().min(1)).optional().default([]),
359197
- memoryNote: z21.string().trim().min(1).optional()
359383
+ var SteeringInterpretationSchema = z22.object({
359384
+ inference: z22.string().trim().min(1),
359385
+ runnerInstruction: z22.string().trim().min(1),
359386
+ conflicts: z22.array(z22.string().trim().min(1)).optional().default([]),
359387
+ alternatives: z22.array(z22.string().trim().min(1)).optional().default([]),
359388
+ memoryNote: z22.string().trim().min(1).optional()
359198
359389
  });
359199
359390
  function appendSteeringLedgerEntry(repoRoot, entry) {
359200
359391
  try {
@@ -359207,13 +359398,17 @@ function appendSteeringLedgerEntry(repoRoot, entry) {
359207
359398
  }
359208
359399
 
359209
359400
  // packages/orchestrator/dist/steeringEvidence.js
359210
- import { z as z22 } from "zod";
359401
+ import { z as z23 } from "zod";
359211
359402
 
359212
359403
  // packages/orchestrator/dist/typed-model-output.js
359213
359404
  var STEERING_RECONCILIATION_REGION = "steering_reconciliation";
359214
359405
  var OPEN = "[STEERING_RECONCILIATION";
359215
359406
  var CLOSE = "[/STEERING_RECONCILIATION";
359216
359407
  var RESERVED_INTERNAL_LINE_MARKERS = [
359408
+ "[ADJUDICATION_ARGUMENT_REPAIR]",
359409
+ "[ADJUDICATION_INVALID_REPLAY]",
359410
+ "[HUMAN_RESPONSE_REQUIRED]",
359411
+ "[HUMAN_RESPONSE_TURN_REQUIRED]",
359217
359412
  "[STEERING_RECONCILIATION_REQUIRED]",
359218
359413
  "[STEERING_REPLAN_TURN_REQUIRED]",
359219
359414
  "[STEERING_CLARIFICATION_REQUIRED]",
@@ -359621,38 +359816,38 @@ ${marker}`);
359621
359816
 
359622
359817
  // packages/orchestrator/dist/steeringEvidence.js
359623
359818
  var STEERING_CHECKPOINT_SCHEMA = "omnius.steering-checkpoint.v1";
359624
- var identity = z22.string().min(1).max(500).refine((value) => value === value.trim());
359625
- var epoch = z22.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
359626
- var intake = z22.object({
359819
+ var identity = z23.string().min(1).max(500).refine((value) => value === value.trim());
359820
+ var epoch = z23.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
359821
+ var intake = z23.object({
359627
359822
  inputId: identity,
359628
- content: z22.string().min(1),
359629
- source: z22.string().min(1),
359630
- receivedAt: z22.string().datetime(),
359631
- intent: z22.enum(["clarify", "append", "context_only", "constraint", "priority_change", "redirect", "replace", "cancel"]),
359632
- state: z22.enum(["received", "queued", "acknowledged", "visible_in_request", "reconciliation_required", "reconciled", "first_affected_action", "consumed", "superseded", "cancelled"]),
359633
- allowTaskReplacement: z22.boolean().optional(),
359823
+ content: z23.string().min(1),
359824
+ source: z23.string().min(1),
359825
+ receivedAt: z23.string().datetime(),
359826
+ intent: z23.enum(["clarify", "append", "context_only", "constraint", "priority_change", "redirect", "replace", "cancel"]),
359827
+ state: z23.enum(["received", "queued", "acknowledged", "visible_in_request", "reconciliation_required", "reconciled", "first_affected_action", "consumed", "superseded", "cancelled"]),
359828
+ allowTaskReplacement: z23.boolean().optional(),
359634
359829
  taskEpoch: epoch
359635
359830
  });
359636
- var call = z22.object({
359831
+ var call = z23.object({
359637
359832
  id: identity,
359638
359833
  name: identity,
359639
- arguments: z22.record(z22.string(), z22.unknown()),
359640
- executionArguments: z22.record(z22.string(), z22.unknown()).optional(),
359641
- state: z22.enum(["pending", "running", "completed"]),
359642
- success: z22.boolean().optional()
359834
+ arguments: z23.record(z23.string(), z23.unknown()),
359835
+ executionArguments: z23.record(z23.string(), z23.unknown()).optional(),
359836
+ state: z23.enum(["pending", "running", "completed"]),
359837
+ success: z23.boolean().optional()
359643
359838
  }).refine((value) => value.state === "completed" === (value.success !== void 0));
359644
- var activeSchema = z22.object({
359839
+ var activeSchema = z23.object({
359645
359840
  input: intake,
359646
- relatedInputs: z22.array(intake).max(127).optional(),
359841
+ relatedInputs: z23.array(intake).max(127).optional(),
359647
359842
  historyStartIndex: epoch.optional(),
359648
359843
  appliedTurn: epoch,
359649
- requiresReconciliation: z22.boolean(),
359650
- gatesOldPlan: z22.boolean(),
359651
- visibleRequestTurns: z22.array(epoch),
359652
- reconciliation: z22.unknown().optional(),
359844
+ requiresReconciliation: z23.boolean(),
359845
+ gatesOldPlan: z23.boolean(),
359846
+ visibleRequestTurns: z23.array(epoch),
359847
+ reconciliation: z23.unknown().optional(),
359653
359848
  reconciledTurn: epoch.optional(),
359654
- firstAffectedAction: z22.object({ toolName: identity, turn: epoch }).optional(),
359655
- evidence: z22.object({ phases: z22.number().int().min(1).max(3), calls: z22.array(call).min(1).max(12) }).optional()
359849
+ firstAffectedAction: z23.object({ toolName: identity, turn: epoch }).optional(),
359850
+ evidence: z23.object({ phases: z23.number().int().min(1).max(3), calls: z23.array(call).min(1).max(12) }).optional()
359656
359851
  });
359657
359852
  function isSteeringScopeResolved(active) {
359658
359853
  const decision2 = active.reconciliation;
@@ -359667,7 +359862,7 @@ function renderSteeringReconciliationProtocol(inputId) {
359667
359862
  taskDisposition: "continue"
359668
359863
  });
359669
359864
  return [
359670
- "Before any tool call, respond with exactly one structured reconciliation and no tool calls in that response:",
359865
+ "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
359866
  "[STEERING_RECONCILIATION]",
359672
359867
  template,
359673
359868
  "[/STEERING_RECONCILIATION]",
@@ -359686,14 +359881,14 @@ function steeringEvidenceArgumentsKey(value) {
359686
359881
  return JSON.stringify(value) ?? "undefined";
359687
359882
  }
359688
359883
  function validateSteeringCheckpoint(value, expected) {
359689
- const parsed = z22.object({
359690
- schema: z22.literal(STEERING_CHECKPOINT_SCHEMA),
359884
+ const parsed = z23.object({
359885
+ schema: z23.literal(STEERING_CHECKPOINT_SCHEMA),
359691
359886
  runId: identity,
359692
359887
  sessionId: identity,
359693
359888
  taskEpoch: epoch,
359694
359889
  active: activeSchema,
359695
- goal: z22.string().min(1).max(16e3),
359696
- messages: z22.array(z22.unknown()).min(1).max(1e5)
359890
+ goal: z23.string().min(1).max(16e3),
359891
+ messages: z23.array(z23.unknown()).min(1).max(1e5)
359697
359892
  }).parse(value);
359698
359893
  if (parsed.runId !== expected.runId || parsed.sessionId !== expected.sessionId || parsed.taskEpoch !== expected.taskEpoch)
359699
359894
  throw new Error("steering_checkpoint_identity_mismatch");
@@ -365409,7 +365604,7 @@ function reconcileShellExecutionOutcome(command, result) {
365409
365604
  }
365410
365605
 
365411
365606
  // packages/orchestrator/dist/agenticRunner.js
365412
- import { z as z24 } from "zod";
365607
+ import { z as z25 } from "zod";
365413
365608
  init_ollama_pool();
365414
365609
 
365415
365610
  // packages/orchestrator/dist/personality.js
@@ -366153,7 +366348,7 @@ function buildPhaseSkillGuidance(input) {
366153
366348
  import { createHash as createHash87 } from "node:crypto";
366154
366349
  import { existsSync as existsSync40, readFileSync as readFileSync46 } from "node:fs";
366155
366350
  import { join as join50 } from "node:path";
366156
- import { z as z23 } from "zod";
366351
+ import { z as z24 } from "zod";
366157
366352
  var deliveryRealityStates = [
366158
366353
  "simulation_only",
366159
366354
  "hardware_integrated",
@@ -366169,70 +366364,70 @@ var acceptanceLayers = [
366169
366364
  "hardware_in_loop",
366170
366365
  "documentation"
366171
366366
  ];
366172
- var sourceSchema = z23.object({
366173
- id: z23.string().min(1),
366174
- kind: z23.enum(["local_contract", "official_vendor", "third_party", "generated"]),
366175
- pathOrUrl: z23.string().min(1),
366176
- revision: z23.string().min(1).optional(),
366177
- hash: z23.string().min(8).optional()
366367
+ var sourceSchema = z24.object({
366368
+ id: z24.string().min(1),
366369
+ kind: z24.enum(["local_contract", "official_vendor", "third_party", "generated"]),
366370
+ pathOrUrl: z24.string().min(1),
366371
+ revision: z24.string().min(1).optional(),
366372
+ hash: z24.string().min(8).optional()
366178
366373
  });
366179
- var contractSchema = z23.object({
366180
- id: z23.string().min(1),
366181
- productSeries: z23.string().min(1),
366182
- sourceId: z23.string().min(1),
366183
- declaredCommands: z23.array(z23.string().min(1)).default([]),
366184
- declaredParameters: z23.array(z23.string().min(1)).default([]),
366185
- declaredModelFormats: z23.array(z23.string().min(1)).default([])
366374
+ var contractSchema = z24.object({
366375
+ id: z24.string().min(1),
366376
+ productSeries: z24.string().min(1),
366377
+ sourceId: z24.string().min(1),
366378
+ declaredCommands: z24.array(z24.string().min(1)).default([]),
366379
+ declaredParameters: z24.array(z24.string().min(1)).default([]),
366380
+ declaredModelFormats: z24.array(z24.string().min(1)).default([])
366186
366381
  });
366187
- var acceptanceSchema = z23.object({
366188
- id: z23.string().min(1),
366189
- layer: z23.enum(acceptanceLayers),
366190
- requiredFor: z23.array(z23.enum(deliveryRealityStates)).min(1),
366382
+ var acceptanceSchema = z24.object({
366383
+ id: z24.string().min(1),
366384
+ layer: z24.enum(acceptanceLayers),
366385
+ requiredFor: z24.array(z24.enum(deliveryRealityStates)).min(1),
366191
366386
  /** Canonical commands whose successful receipts prove this layer ran. */
366192
- verificationCommands: z23.array(z23.string().min(1)).min(1),
366193
- safetyInterlock: z23.string().min(1).optional()
366387
+ verificationCommands: z24.array(z24.string().min(1)).min(1),
366388
+ safetyInterlock: z24.string().min(1).optional()
366194
366389
  });
366195
- var inspectionSchema = z23.object({
366196
- id: z23.string().min(1),
366197
- boundary: z23.string().min(1),
366198
- targetPaths: z23.array(z23.string().min(1)).min(1),
366199
- proves: z23.string().min(1)
366390
+ var inspectionSchema = z24.object({
366391
+ id: z24.string().min(1),
366392
+ boundary: z24.string().min(1),
366393
+ targetPaths: z24.array(z24.string().min(1)).min(1),
366394
+ proves: z24.string().min(1)
366200
366395
  });
366201
- var contradictionCheckSchema = z23.object({
366202
- id: z23.string().min(1),
366203
- question: z23.string().min(1),
366204
- inspectionIds: z23.array(z23.string().min(1)).min(1)
366396
+ var contradictionCheckSchema = z24.object({
366397
+ id: z24.string().min(1),
366398
+ question: z24.string().min(1),
366399
+ inspectionIds: z24.array(z24.string().min(1)).min(1)
366205
366400
  });
366206
- var subjectSchema = z23.object({
366207
- productSeries: z23.string().min(1),
366208
- commands: z23.array(z23.string().min(1)).default([]),
366209
- parameters: z23.array(z23.string().min(1)).default([]),
366210
- modelFormats: z23.array(z23.string().min(1)).default([])
366401
+ var subjectSchema = z24.object({
366402
+ productSeries: z24.string().min(1),
366403
+ commands: z24.array(z24.string().min(1)).default([]),
366404
+ parameters: z24.array(z24.string().min(1)).default([]),
366405
+ modelFormats: z24.array(z24.string().min(1)).default([])
366211
366406
  });
366212
- var claimSchema = z23.object({
366213
- id: z23.string().min(1),
366214
- subjects: z23.array(subjectSchema).min(1),
366215
- state: z23.enum(deliveryRealityStates),
366216
- contractId: z23.string().min(1).optional(),
366217
- sourceIds: z23.array(z23.string().min(1)).min(1),
366218
- evidenceIds: z23.array(z23.string().min(1)).default([]),
366219
- requiredAcceptanceIds: z23.array(z23.string().min(1)).default([]),
366407
+ var claimSchema = z24.object({
366408
+ id: z24.string().min(1),
366409
+ subjects: z24.array(subjectSchema).min(1),
366410
+ state: z24.enum(deliveryRealityStates),
366411
+ contractId: z24.string().min(1).optional(),
366412
+ sourceIds: z24.array(z24.string().min(1)).min(1),
366413
+ evidenceIds: z24.array(z24.string().min(1)).default([]),
366414
+ requiredAcceptanceIds: z24.array(z24.string().min(1)).default([]),
366220
366415
  /** Source boundaries that must be freshly read before this claim is true. */
366221
- requiredInspectionIds: z23.array(z23.string().min(1)).default([]),
366416
+ requiredInspectionIds: z24.array(z24.string().min(1)).default([]),
366222
366417
  /** Falsification checks that must be grounded in those source inspections. */
366223
- requiredContradictionCheckIds: z23.array(z23.string().min(1)).default([]),
366224
- blockedReason: z23.string().min(1).optional()
366418
+ requiredContradictionCheckIds: z24.array(z24.string().min(1)).default([]),
366419
+ blockedReason: z24.string().min(1).optional()
366225
366420
  });
366226
- var deliveryCoverageManifestSchema = z23.object({
366421
+ var deliveryCoverageManifestSchema = z24.object({
366227
366422
  // Version 1 remains readable for existing workspaces. Version 2 activates
366228
366423
  // claim-driven source inspection and falsification gates.
366229
- schemaVersion: z23.union([z23.literal(1), z23.literal(2)]),
366230
- sources: z23.array(sourceSchema),
366231
- contracts: z23.array(contractSchema),
366232
- acceptance: z23.array(acceptanceSchema),
366233
- inspections: z23.array(inspectionSchema).default([]),
366234
- contradictionChecks: z23.array(contradictionCheckSchema).default([]),
366235
- claims: z23.array(claimSchema)
366424
+ schemaVersion: z24.union([z24.literal(1), z24.literal(2)]),
366425
+ sources: z24.array(sourceSchema),
366426
+ contracts: z24.array(contractSchema),
366427
+ acceptance: z24.array(acceptanceSchema),
366428
+ inspections: z24.array(inspectionSchema).default([]),
366429
+ contradictionChecks: z24.array(contradictionCheckSchema).default([]),
366430
+ claims: z24.array(claimSchema)
366236
366431
  });
366237
366432
  function canonicalPath(path7) {
366238
366433
  return String(path7 ?? "").trim().replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/");
@@ -374365,7 +374560,11 @@ function normalizeCanonicalHistory(history, options = {}) {
374365
374560
  for (const group of transactions2.values()) {
374366
374561
  const raw = group.filter((entry) => entry.kind === "tool_transaction_raw");
374367
374562
  const receipts = group.filter((entry) => entry.kind === "evidence_receipt");
374368
- const keepRaw = raw.some((entry) => entry.transactionRelevance === "active") || receipts.length === 0 || options.historicalTransactionPolicy === "retain_raw" && completeRawToolTransaction(raw);
374563
+ const largeHistoricalResult = options.historicalToolInlineBytes !== void 0 && raw.some((entry) => {
374564
+ const message = entry.message;
374565
+ return message && message["role"] === "tool" && typeof message["content"] === "string" && Buffer.byteLength(message["content"], "utf8") > options.historicalToolInlineBytes;
374566
+ });
374567
+ const keepRaw = raw.some((entry) => entry.transactionRelevance === "active" || (entry.protection?.length ?? 0) > 0) || receipts.length === 0 || options.historicalTransactionPolicy === "retain_raw" && !largeHistoricalResult && completeRawToolTransaction(raw);
374369
374568
  const receiptWinner = receipts.length > 0 ? [...receipts].sort(compareHistoryNewest)[0] : void 0;
374370
374569
  const rejected = keepRaw ? receipts : [...raw, ...receipts.filter((entry) => entry !== receiptWinner)];
374371
374570
  for (const entry of rejected) {
@@ -374614,7 +374813,8 @@ function buildCanonicalModelRequest(input) {
374614
374813
  if (input.maxRequestBytes !== void 0)
374615
374814
  assertPositiveBudget(input.maxRequestBytes, "maxRequestBytes");
374616
374815
  const historyProjection = normalizeCanonicalHistory(input.history, {
374617
- historicalTransactionPolicy: input.historicalTransactionPolicy
374816
+ historicalTransactionPolicy: input.historicalTransactionPolicy,
374817
+ historicalToolInlineBytes: input.historicalToolInlineBytes
374618
374818
  });
374619
374819
  const frame = projectCanonicalTaskFrame({
374620
374820
  signals: input.signals,
@@ -388291,6 +388491,10 @@ var AgenticRunner = class _AgenticRunner {
388291
388491
  */
388292
388492
  _immediateSteeringWakeInputId = null;
388293
388493
  _steeringSequence = 0;
388494
+ /** Explicit foreground human input is answered before optional advice/actions. */
388495
+ _pendingSteeringReply = null;
388496
+ _steeringReplyTurn = null;
388497
+ _adjudicationArgumentRepair = null;
388294
388498
  _taskEpoch = 0;
388295
388499
  _exclusiveTaskOwner = null;
388296
388500
  _hasStartedTask = false;
@@ -388465,6 +388669,8 @@ var AgenticRunner = class _AgenticRunner {
388465
388669
  _desktopVerificationObservation = null;
388466
388670
  _desktopVerificationPending = null;
388467
388671
  _trajectoryGeneratedGrounding = null;
388672
+ _trajectoryGroundingRequest = null;
388673
+ _virtualContextRequest = null;
388468
388674
  _taskWorkOperationBindings = /* @__PURE__ */ new Map();
388469
388675
  _taskWorkDispatchUnits = /* @__PURE__ */ new Map();
388470
388676
  // -- File State Registry (SWE-agent inspired) --
@@ -389305,6 +389511,18 @@ var AgenticRunner = class _AgenticRunner {
389305
389511
  const freshHash = typeof result.beforeHash === "string" && /^[a-f0-9]{64}$/i.test(result.beforeHash) ? result.beforeHash : null;
389306
389512
  if (!path7 || !freshHash)
389307
389513
  return null;
389514
+ if (toolName !== "file_edit" || typeof args["old_string"] !== "string" || !args["old_string"].length) {
389515
+ return [
389516
+ "[STALE_HASH_RETRY]",
389517
+ "The file revision differs from the edit precondition. Read the current file and reconcile the intended change before retrying.",
389518
+ "Prefer a focused file_edit/file_patch built from the current text. Never reuse an old full-file replacement with only a refreshed hash.",
389519
+ JSON.stringify({
389520
+ failure_family: "stale_hash",
389521
+ guardrail: "reread_and_rebase",
389522
+ next_read: { tool: "file_read", args: { path: path7 } }
389523
+ })
389524
+ ].join("\n");
389525
+ }
389308
389526
  const retry = {
389309
389527
  failure_family: "stale_hash",
389310
389528
  guardrail: "one_assisted_refresh_only",
@@ -391712,6 +391930,7 @@ runtime_module_sha256=${record9.runtimeProvenance.module.sha256 ?? "unknown"}`
391712
391930
  },
391713
391931
  canonicalToolExposureContracts: options?.canonicalToolExposureContracts ?? [],
391714
391932
  canonicalMaxInputTokens: options?.canonicalMaxInputTokens === void 0 ? void 0 : Math.max(1, Math.floor(options.canonicalMaxInputTokens)),
391933
+ historicalToolInlineBytes: options?.historicalToolInlineBytes === void 0 ? 16 * 1024 : Number.isNaN(options.historicalToolInlineBytes) ? 16 * 1024 : Math.max(0, options.historicalToolInlineBytes),
391715
391934
  // A fixed 8k aggregate ceiling could reject a valid set of action tools
391716
391935
  // before inference (for example 9,479 chars of schemas for an 8k cap).
391717
391936
  // Progressive exposure still controls relevance, but selected schemas
@@ -392928,7 +393147,7 @@ ${read.content}`;
392928
393147
  request.maxTokens = Math.min(outputIntent, configuredCeiling);
392929
393148
  }
392930
393149
  const steering = this._activeSteering;
392931
- const maskSteeringTools = Boolean(steering?.input.taskEpoch === this._taskEpoch && steering.gatesOldPlan && steering.requiresReconciliation && !steering.reconciliation && this._requestCarriesCurrentSteering(request, steering));
393150
+ const maskSteeringTools = Boolean(this._currentSteeringReplyPending() || steering?.input.taskEpoch === this._taskEpoch && steering.gatesOldPlan && steering.requiresReconciliation && !steering.reconciliation && this._requestCarriesCurrentSteering(request, steering));
392932
393151
  const contracts = JSON.stringify([...this._canonicalToolExposureContracts]);
392933
393152
  let toolIntent = this._contextAdmissionToolIntents.get(request);
392934
393153
  if (toolIntent && (toolIntent.runId !== this._activeRunId || toolIntent.taskEpoch !== this._taskEpoch || toolIntent.contracts !== contracts || toolIntent.registry.some((entry) => this.tools.get(entry.name) !== entry.tool))) {
@@ -393419,6 +393638,49 @@ ${read.content}`;
393419
393638
  atomicGroup: transactionId2
393420
393639
  });
393421
393640
  }
393641
+ for (let index = 0; index < messages2.length; index++) {
393642
+ const message = messages2[index];
393643
+ const calls = message.role === "assistant" ? message.tool_calls : void 0;
393644
+ const transactionId2 = transactionByIndex.get(index);
393645
+ if (!calls || calls.length < 2 || !transactionId2 || transactionId2 === activeTransactionId || new Set(calls.map((call2) => call2.id)).size !== calls.length)
393646
+ continue;
393647
+ const members = calls.map((call2) => {
393648
+ const receipt = this._canonicalAcceptedReceipts.get(call2.id);
393649
+ const results = messages2.filter((candidate) => candidate.role === "tool" && candidate.tool_call_id === call2.id);
393650
+ return receipt && results.length === 1 ? { transactionId: call2.id, ...receipt } : void 0;
393651
+ });
393652
+ if (members.some((member) => !member))
393653
+ continue;
393654
+ try {
393655
+ const content = JSON.stringify({ schema: "omnius.tool-batch-artifacts.v1", members });
393656
+ const stored = this._artifactStore().put({
393657
+ path: `tool-batch/${this.currentArtifactRunId()}/${transactionId2}`,
393658
+ revision: _createHash("sha256").update(content).digest("hex"),
393659
+ content,
393660
+ fidelity: "full"
393661
+ });
393662
+ this._artifactStore().flush(stored.reference);
393663
+ entries.push({
393664
+ id: `accepted-receipt:${transactionId2}`,
393665
+ kind: "evidence_receipt",
393666
+ ordinal: (transactionSpans.get(transactionId2)?.end ?? index) + 0.25,
393667
+ turn,
393668
+ revision: turn,
393669
+ priority: 700,
393670
+ transactionId: transactionId2,
393671
+ artifactLocator: stored.reference,
393672
+ atomicGroup: transactionId2,
393673
+ message: { role: "system", content: renderCanonicalEvidenceReceipt({
393674
+ transactionId: transactionId2,
393675
+ toolName: "tool_batch",
393676
+ artifactLocator: stored.reference,
393677
+ success: true,
393678
+ summary: `All ${members.length} results retained; artifact is a manifest of individual source artifacts. ` + members.map((member) => member.summary).join(" ")
393679
+ }) }
393680
+ });
393681
+ } catch {
393682
+ }
393683
+ }
393422
393684
  return entries;
393423
393685
  }
393424
393686
  /**
@@ -393464,6 +393726,15 @@ ${read.content}`;
393464
393726
  });
393465
393727
  }
393466
393728
  }
393729
+ const argumentRepair = this._currentAdjudicationArgumentRepair(turn);
393730
+ if (argumentRepair)
393731
+ latest.set("adjudication-argument-repair", {
393732
+ slot: "next_action",
393733
+ source: "runtime.adjudication-argument-repair",
393734
+ priority: 100,
393735
+ protection: ["active_requirement"],
393736
+ content: this._adjudicationArgumentRepairGuidance(argumentRepair)
393737
+ });
393467
393738
  return [...latest.entries()].map(([id5, signal]) => ({
393468
393739
  id: `canonical-late:${id5}`,
393469
393740
  slot: signal.slot,
@@ -393540,6 +393811,7 @@ ${read.content}`;
393540
393811
  measureInputTokens: (candidate) => this._outboundRequestBudget(candidate).totalInputTokens,
393541
393812
  excludeMutableProjections,
393542
393813
  historicalTransactionPolicy,
393814
+ historicalToolInlineBytes: this.options.historicalToolInlineBytes,
393543
393815
  toolProjection
393544
393816
  });
393545
393817
  const original = build(signals);
@@ -393608,6 +393880,9 @@ ${read.content}`;
393608
393880
  if (hasPhysicalContextLimit && retainedBudget.compactionEligible || canonicalInputCeiling !== void 0 && retainedBudget.totalInputTokens > canonicalInputCeiling) {
393609
393881
  projection = materializeOwnedSourceProjections(buildProjection("receipt", canonicalInputCeiling));
393610
393882
  }
393883
+ if (canonicalInputCeiling !== void 0 && projection.trace.maxInputTokens === void 0) {
393884
+ projection = { ...projection, trace: { ...projection.trace, maxInputTokens: canonicalInputCeiling } };
393885
+ }
393611
393886
  if (schemaBytes > this.options.canonicalMaxToolSchemaChars || toolProjection.status !== "ok") {
393612
393887
  throw new Error(toolProjection.missingRequiredToolNames.length > 0 ? `canonical_tool_required_schema_missing:${toolProjection.missingRequiredToolNames.join(",")}` : `canonical_tool_schema_budget_overflow:${schemaBytes}/${this.options.canonicalMaxToolSchemaChars}`);
393613
393888
  }
@@ -393873,13 +394148,55 @@ ${read.content}`;
393873
394148
  });
393874
394149
  }
393875
394150
  } : outbound;
393876
- const ownedRequest = withManagedLocalAdmissionBudget(this.backend, { ...dispatchRequest, signal: AbortSignal.any([
393877
- inputWaitController.signal,
393878
- this._abortController.signal,
393879
- this._turnAbortController.signal,
393880
- ...dispatchRequest.signal ? [dispatchRequest.signal] : []
393881
- ]) }, this.options.requestTimeoutMs);
393882
- const response = await withInputWaitCancellation(inputWaitController.signal, () => backend.chatCompletion(ownedRequest));
394151
+ const selectedBackend = this.backend;
394152
+ const selectedScope = selectedBackend.transportContextScope?.() ?? selectedBackend;
394153
+ const taskBinding = this._sourceReadTaskBinding();
394154
+ const ownedRequest = withManagedLocalAdmissionBudget(this.backend, {
394155
+ ...dispatchRequest,
394156
+ logicalRequestId: dispatchRequest.logicalRequestId ?? crypto.randomUUID(),
394157
+ signal: AbortSignal.any([
394158
+ inputWaitController.signal,
394159
+ this._abortController.signal,
394160
+ this._turnAbortController.signal,
394161
+ ...dispatchRequest.signal ? [dispatchRequest.signal] : []
394162
+ ])
394163
+ }, this.options.requestTimeoutMs);
394164
+ let response;
394165
+ let readinessWaits = 0;
394166
+ for (; ; ) {
394167
+ assertCurrent();
394168
+ ownedRequest.signal.throwIfAborted();
394169
+ if (readinessWaits > 0 && (selectedBackend !== this.backend || selectedScope !== (this.backend.transportContextScope?.() ?? this.backend) || taskBinding !== this._sourceReadTaskBinding()))
394170
+ throw new Error("interruption_stale_model_dispatch");
394171
+ try {
394172
+ response = await withInputWaitCancellation(ownedRequest.signal, () => backend.chatCompletion(ownedRequest));
394173
+ break;
394174
+ } catch (error) {
394175
+ if (!(error instanceof LocalInferenceNotReadyError) || !operation.requiredForRun || (ownedRequest.workloadClass ?? this.options.workloadClass) !== "foreground")
394176
+ throw error;
394177
+ assertCurrent();
394178
+ ownedRequest.signal.throwIfAborted();
394179
+ if (readinessWaits++ === 0)
394180
+ this.emit({
394181
+ type: "status",
394182
+ inferenceWaiting: true,
394183
+ content: "Waiting for the selected local model.",
394184
+ visibility: "telemetry",
394185
+ turn: operation.turn,
394186
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
394187
+ });
394188
+ await this.waitForTransientRetry(Math.min(15e3, 1e3 * 2 ** Math.min(4, readinessWaits - 1)), ownedRequest.signal);
394189
+ }
394190
+ }
394191
+ if (readinessWaits > 0)
394192
+ this.emit({
394193
+ type: "status",
394194
+ inferenceWaiting: false,
394195
+ content: "Selected local model ready; resuming task.",
394196
+ visibility: "telemetry",
394197
+ turn: operation.turn,
394198
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
394199
+ });
393883
394200
  inputWaitController.signal.throwIfAborted();
393884
394201
  if (ticket && !this._interruptionLifecycle?.canCommit(ticket)) {
393885
394202
  throw new Error("interruption_stale_model_result");
@@ -395755,8 +396072,12 @@ ${workflowStatus}` } : {}
395755
396072
  });
395756
396073
  const tool = this.tools.get(input.toolName);
395757
396074
  const sourceEvidence = input.toolName === "file_read" ? qualifySourceReadEvidence({ cwd: this._workingDirectory || process.cwd(), args: input.args, result: input.result }) : void 0;
396075
+ if (sourceEvidence) {
396076
+ const receipt = this._canonicalAcceptedReceipts.get(input.toolCallId);
396077
+ receipt.summary += ` file_edit_precondition=${JSON.stringify({ path: this._normalizeEvidencePath(sourceEvidence.path), expected_hash: sourceEvidence.sourceHash })}`;
396078
+ }
395758
396079
  const identity4 = tool?.getHistoryObservationIdentity?.(input.args, input.result) ?? (sourceEvidence ? JSON.stringify({ tool: "file_read", cwd: this.authoritativeWorkingDirectory(), path: sourceEvidence.path, hash: sourceEvidence.sourceHash, range: sourceEvidence.coverage }) : null);
395759
- const sourceBody = sourceEvidence?.coverage && typeof sourceEvidence.coverage.endLine === "number" ? issueQualifiedSourceBodyObservation({
396080
+ const fileSourceBody = sourceEvidence?.coverage && typeof sourceEvidence.coverage.endLine === "number" ? issueQualifiedSourceBodyObservation({
395760
396081
  scope: this._sourceBodyProjectionScope(),
395761
396082
  callId: input.toolCallId,
395762
396083
  path: this._normalizeEvidencePath(sourceEvidence.path),
@@ -395767,7 +396088,23 @@ ${workflowStatus}` } : {}
395767
396088
  format: sourceEvidence.deliveryFormat,
395768
396089
  body: input.result.llmContent ?? input.result.output
395769
396090
  }) : null;
395770
- if (sourceBody && (input.result.fullReadAdmitted === true || [...this._inlineReadArtifacts.values()].some((artifact2) => artifact2.path === sourceBody.path && artifact2.contentHash === sourceBody.sourceHash && artifact2.sourceRange.startLine === sourceBody.startLine && artifact2.sourceRange.endLine === sourceBody.endLine))) {
396091
+ const admittedWeb = this._admittedWebSourceViews.get(input.result);
396092
+ const web = complete?.schema === "omnius.native-web-source.v1" ? complete : null;
396093
+ const webBody = web && (input.args["format"] === "raw_html" ? web.body : web.htmlEvidence?.article.text ?? web.body);
396094
+ const webSourceBody = web && webBody && admittedWeb?.source === web && admittedWeb.sourceCurrent() && admittedWeb.scopeId === this._sessionId && admittedWeb.runId === this.currentArtifactRunId() && admittedWeb.taskEpoch === this._taskEpoch && admittedWeb.modelContent === input.result.llmContent && admittedWeb.output === input.result.output && input.toolName === "web_fetch" ? issueQualifiedSourceBodyObservation({
396095
+ scope: this._sourceBodyProjectionScope(),
396096
+ callId: input.toolCallId,
396097
+ toolName: "web_fetch",
396098
+ path: JSON.stringify([web.receipt.requestedUrl, input.args["format"] === "raw_html" ? "raw_html" : "semantic"]),
396099
+ sourceHash: web.receipt.responseSha256,
396100
+ startLine: 1,
396101
+ endLine: webBody.split("\n").length,
396102
+ artifactLocator: stored.reference,
396103
+ format: "raw",
396104
+ body: webBody
396105
+ }) : null;
396106
+ const sourceBody = fileSourceBody ?? webSourceBody;
396107
+ if (fileSourceBody && sourceBody && (input.result.fullReadAdmitted === true || [...this._inlineReadArtifacts.values()].some((artifact2) => artifact2.path === sourceBody.path && artifact2.contentHash === sourceBody.sourceHash && artifact2.sourceRange.startLine === sourceBody.startLine && artifact2.sourceRange.endLine === sourceBody.endLine))) {
395771
396108
  this._inlineReadArtifacts.set(input.toolCallId, {
395772
396109
  callId: input.toolCallId,
395773
396110
  path: sourceBody.path,
@@ -395797,6 +396134,12 @@ ${workflowStatus}` } : {}
395797
396134
  ...sourceEvidence ? { sourceRead: { path: sourceEvidence.path, hash: sourceEvidence.sourceHash, ...sourceEvidence.coverage } } : {},
395798
396135
  ...sourceBody ? { sourceBody } : {}
395799
396136
  });
396137
+ } else if (webSourceBody) {
396138
+ this._historyObservations.set(input.toolCallId, {
396139
+ equivalenceKey: _createHash("sha256").update(`${webSourceBody.scope}:${input.toolCallId}`).digest("hex"),
396140
+ observedAt: web.receipt.fetchedAt ?? (/* @__PURE__ */ new Date()).toISOString(),
396141
+ sourceBody: webSourceBody
396142
+ });
395800
396143
  }
395801
396144
  while (this._canonicalAcceptedReceipts.size > 128) {
395802
396145
  const oldest = this._canonicalAcceptedReceipts.keys().next().value;
@@ -396606,6 +396949,52 @@ ${content}`)].join("\n\n");
396606
396949
  _hasUnresolvedCurrentSteeringInputs() {
396607
396950
  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"));
396608
396951
  }
396952
+ _currentSteeringReplyPending() {
396953
+ const pending = this._pendingSteeringReply;
396954
+ return pending && pending.runId === this.currentArtifactRunId() && pending.ownerId === this._interruptionOwnerId && pending.input.taskEpoch === this._taskEpoch && !["cancelled", "superseded", "consumed"].includes(pending.input.state) ? pending : null;
396955
+ }
396956
+ _adjudicationArgumentRepairIsCurrent(repair) {
396957
+ const tool = this.lookupRegisteredTool(ADJUDICATION_TOOL_NAME)?.tool;
396958
+ 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);
396959
+ }
396960
+ _currentAdjudicationArgumentRepair(turn) {
396961
+ const repair = this._adjudicationArgumentRepair;
396962
+ return repair && this._adjudicationArgumentRepairIsCurrent(repair) && (turn === void 0 || repair.settled && turn === repair.turn + 1) ? repair : null;
396963
+ }
396964
+ _adjudicationArgumentRepairGuidance(repair) {
396965
+ 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);
396966
+ }
396967
+ _observePrimarySteeringReply(content, turn, emitMixedReply = false) {
396968
+ const pending = this._currentSteeringReplyPending();
396969
+ const visible = content ? partitionTypedModelOutput(content).visibleText.trim() : "";
396970
+ let fence2;
396971
+ const hasProse = visible.split(/\r?\n/).some((line) => {
396972
+ const boundary2 = /^\s*(`{3,}|~{3,})(.*)$/.exec(line);
396973
+ if (boundary2) {
396974
+ if (!fence2)
396975
+ fence2 = { marker: boundary2[1][0], length: boundary2[1].length };
396976
+ else if (boundary2[1][0] === fence2.marker && boundary2[1].length >= fence2.length && !boundary2[2].trim())
396977
+ fence2 = void 0;
396978
+ return false;
396979
+ }
396980
+ return !fence2 && Boolean(line.trim());
396981
+ });
396982
+ const carried = Boolean(pending?.visibleRequestTurns.includes(turn));
396983
+ const active = this._activeSteering;
396984
+ if (emitMixedReply && hasProse && (carried || active?.input.taskEpoch === this._taskEpoch && active.requiresReconciliation && active.visibleRequestTurns.includes(turn))) {
396985
+ this.emit({ type: "assistant_text", content: visible, turn, timestamp: (/* @__PURE__ */ new Date()).toISOString() });
396986
+ this._assistantTextEmitted = true;
396987
+ }
396988
+ if (carried && hasProse) {
396989
+ this._pendingSteeringReply = null;
396990
+ this._steeringReplyTurn = {
396991
+ runId: this.currentArtifactRunId(),
396992
+ taskEpoch: this._taskEpoch,
396993
+ ownerId: this._interruptionOwnerId,
396994
+ turn
396995
+ };
396996
+ }
396997
+ }
396609
396998
  _objectiveReadBatchAuxiliaryEligible() {
396610
396999
  const continuation = this._objectiveReadBatchContinuation;
396611
397000
  const batch = this.options.objectiveReadBatch;
@@ -396690,10 +397079,12 @@ ${content}`)].join("\n\n");
396690
397079
  const configuredTrigger = this.options.virtualContext?.triggerTokens;
396691
397080
  const triggerTokens = Number.isFinite(configuredTrigger) && (configuredTrigger ?? 0) > 0 ? Math.floor(configuredTrigger) : Number.isFinite(envTrigger) && envTrigger > 0 ? Math.floor(envTrigger) : Math.max(1, Math.floor(physicalInputBudget * 0.6));
396692
397081
  const configuredEvidenceBudget = this.options.virtualContext?.evidenceTokenBudget;
396693
- const evidenceTokenBudget = Math.max(1, Math.min(physicalInputBudget, Number.isFinite(configuredEvidenceBudget) && (configuredEvidenceBudget ?? 0) > 0 ? Math.floor(configuredEvidenceBudget) : adaptiveBudget.exactEvidence));
397082
+ const evidenceTokenBudget = Math.max(1, Math.min(physicalInputBudget, Number.isFinite(configuredEvidenceBudget) && (configuredEvidenceBudget ?? 0) > 0 ? Math.floor(configuredEvidenceBudget) : configuredEvidenceBudget === Number.POSITIVE_INFINITY ? adaptiveBudget.exactEvidence : Math.min(8192, adaptiveBudget.exactEvidence)));
396694
397083
  const configuredPinnedBudget = this.options.virtualContext?.pinnedMemoryTokenBudget;
396695
397084
  const pinnedTokenBudget = Math.max(0, Math.min(physicalInputBudget, Number.isFinite(configuredPinnedBudget) && (configuredPinnedBudget ?? 0) > 0 ? Math.floor(configuredPinnedBudget) : adaptiveBudget.pinnedState));
396696
397085
  const pinnedMessages = this._pinnedStructuredMemoryMessages(pinnedTokenBudget, physicalInputBudget, turn);
397086
+ if (this._currentAdjudicationArgumentRepair(turn) || this._currentSteeringReplyPending() || this._hasUnresolvedCurrentSteeringInputs())
397087
+ return pinnedMessages;
396697
397088
  const residentInputTokens = estimateConservativeRequestInputTokens({
396698
397089
  messages: messages2.map((message) => ({ ...message })),
396699
397090
  tools,
@@ -396802,11 +397193,34 @@ ${content}`)].join("\n\n");
396802
397193
  }))
396803
397194
  ];
396804
397195
  }
397196
+ const projectionRequest = {
397197
+ controller: new AbortController(),
397198
+ runId: this.currentArtifactRunId(),
397199
+ taskEpoch: this._taskEpoch,
397200
+ ownerId: this._interruptionOwnerId,
397201
+ generation: this._modelRequestGeneration
397202
+ };
397203
+ this._virtualContextRequest = projectionRequest;
397204
+ const signal = AbortSignal.any([
397205
+ projectionRequest.controller.signal,
397206
+ this._abortController.signal,
397207
+ this._turnAbortController.signal,
397208
+ this._inputWaitBoundaryController.signal
397209
+ ]);
397210
+ const isCurrent = () => !signal.aborted && this._virtualContextRequest === projectionRequest && projectionRequest.runId === this.currentArtifactRunId() && projectionRequest.taskEpoch === this._taskEpoch && projectionRequest.ownerId === this._interruptionOwnerId && projectionRequest.generation === this._modelRequestGeneration;
397211
+ const assertCurrent = () => {
397212
+ if (!isCurrent())
397213
+ throw new InputWaitInterruption();
397214
+ };
396805
397215
  try {
396806
397216
  const timeoutMs = this.options.requestTimeoutMs === 0 ? 0 : Number.isFinite(this.options.requestTimeoutMs) && (this.options.requestTimeoutMs ?? 0) > 0 ? this.options.requestTimeoutMs : 3e5;
396807
- const projection = await buildLiveVirtualContextProjection({
397217
+ assertCurrent();
397218
+ const projection = await withInputWaitCancellation(signal, () => buildLiveVirtualContextProjection({
396808
397219
  store,
396809
- archiveDocument: (document) => this._archiveVirtualEvidenceDocument(document),
397220
+ archiveDocument: (document) => {
397221
+ assertCurrent();
397222
+ return this._archiveVirtualEvidenceDocument(document);
397223
+ },
396810
397224
  ...this._structuredMemoryStore ? { memoryStore: this._structuredMemoryStore } : {},
396811
397225
  query,
396812
397226
  scopeId: this._sessionId,
@@ -396819,9 +397233,11 @@ ${content}`)].join("\n\n");
396819
397233
  auxiliaryContextWindowTokens: physicalWindow,
396820
397234
  auxiliaryMaxOutputTokens: this._explicitGenerationMaxTokens || this.options.maxTokens !== 16384 ? this._generationOutputCeiling() : void 0,
396821
397235
  maxRetrievalRounds: this.options.virtualContext?.maxRetrievalRounds,
396822
- signal: this._turnAbortController.signal,
397236
+ signal,
396823
397237
  requestTimeoutMs: timeoutMs > 0 ? Math.min(timeoutMs, 3e4) : 3e4,
396824
397238
  onTrace: (event) => {
397239
+ if (!isCurrent())
397240
+ return;
396825
397241
  this._recordLiveVirtualContextTrace(event, turn);
396826
397242
  this.emit({
396827
397243
  type: "status",
@@ -396832,9 +397248,11 @@ ${content}`)].join("\n\n");
396832
397248
  });
396833
397249
  },
396834
397250
  infer: async (request) => {
397251
+ assertCurrent();
396835
397252
  this._emitModelResolutionTelemetry(`virtual_memory_${request.stage}`, turn);
396836
- const response = await this._auxInferenceBackend({
396837
- dumpStage: `virtual_memory_${request.stage}`
397253
+ const response = await withInputWaitCancellation(request.signal, () => this._auxInferenceBackend({
397254
+ dumpStage: `virtual_memory_${request.stage}`,
397255
+ assertCurrent
396838
397256
  }).chatCompletion({
396839
397257
  messages: [
396840
397258
  { role: "system", content: request.system },
@@ -396848,10 +397266,12 @@ ${content}`)].join("\n\n");
396848
397266
  think: false,
396849
397267
  workloadClass: this.options.workloadClass,
396850
397268
  logicalRequestId: this._modelTurnRequestId(turn, `virtual-memory:${request.stage}`)
396851
- });
397269
+ }));
397270
+ assertCurrent();
396852
397271
  return response.choices?.[0]?.message?.content ?? "";
396853
397272
  }
396854
- });
397273
+ }));
397274
+ assertCurrent();
396855
397275
  this._liveVirtualContextAttempt = { semanticKey, turn };
396856
397276
  if (!projection)
396857
397277
  return pinnedMessages;
@@ -396878,6 +397298,8 @@ ${content}`)].join("\n\n");
396878
397298
  }))
396879
397299
  ];
396880
397300
  } catch (error) {
397301
+ if (!isCurrent() || error instanceof InputWaitInterruption)
397302
+ return pinnedMessages;
396881
397303
  if (this._turnAbortController.signal.aborted)
396882
397304
  throw error;
396883
397305
  this._liveVirtualContextAttempt = { semanticKey, turn };
@@ -396889,6 +397311,9 @@ ${content}`)].join("\n\n");
396889
397311
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
396890
397312
  });
396891
397313
  return pinnedMessages;
397314
+ } finally {
397315
+ if (this._virtualContextRequest === projectionRequest)
397316
+ this._virtualContextRequest = null;
396892
397317
  }
396893
397318
  }
396894
397319
  _pinnedStructuredMemoryMessages(defaultTokenBudget, physicalInputBudget, turn) {
@@ -397683,7 +398108,7 @@ ${currentIntent.trim().slice(0, 6e3)}`,
397683
398108
  request: r
397684
398109
  });
397685
398110
  }
397686
- return this._dispatchInterruptionOwnedModelRequest(b, r, `model:aux:${opts?.dumpStage ?? "aux_inference"}`, { assertCurrent: opts?.assertCurrent });
398111
+ return this._dispatchInterruptionOwnedModelRequest(b, r, `model:aux:${opts?.dumpStage ?? "aux_inference"}`, { assertCurrent: opts?.assertCurrent, signal: r.signal });
397687
398112
  }
397688
398113
  };
397689
398114
  }
@@ -400033,12 +400458,12 @@ ${modelVisible}` : modelVisible || result.error || displayOutput || "";
400033
400458
  if (!candidate)
400034
400459
  return { quality: "not_candidate", summary: "not a validation command" };
400035
400460
  if (!commandReliablySatisfiesVerifyCommand(command, command, result.executionReceipt)) {
400036
- const shape2 = describeUntrustedVerificationCommand(command, result.executionReceipt);
400461
+ const shape3 = describeUntrustedVerificationCommand(command, result.executionReceipt);
400037
400462
  return {
400038
400463
  quality: "rejected_untrusted",
400039
- summary: `validation command is not receipt-authoritative: ${shape2}`,
400040
- reason: `Repair the execution shape: ${shape2}.`,
400041
- nextAction: `Run the canonical validation with a receipt-authoritative shape; current issue: ${shape2}.`
400464
+ summary: `validation command is not receipt-authoritative: ${shape3}`,
400465
+ reason: `Repair the execution shape: ${shape3}.`,
400466
+ nextAction: `Run the canonical validation with a receipt-authoritative shape; current issue: ${shape3}.`
400042
400467
  };
400043
400468
  }
400044
400469
  if (result.success !== true) {
@@ -405669,7 +406094,16 @@ ${findingsBody}`;
405669
406094
  }
405670
406095
  return null;
405671
406096
  }
405672
- buildToolArgumentRepairFeedback(toolName, args, tool, validationError) {
406097
+ buildToolArgumentRepairFeedback(toolName, args, tool, validationError, admittedRepair) {
406098
+ if (tool.name === ADJUDICATION_TOOL_NAME) {
406099
+ const argsKey = this._buildExactArgsKey(args);
406100
+ const candidate = admittedRepair ?? this._currentAdjudicationArgumentRepair();
406101
+ const repair = candidate && this._adjudicationArgumentRepairIsCurrent(candidate) && candidate.argsKey === argsKey ? candidate : null;
406102
+ const guidance = repair ? this._adjudicationArgumentRepairGuidance(repair) : formatAdjudicationArgumentRepair(validationError, _createHash("sha256").update(argsKey).digest("hex"));
406103
+ const message = `Invalid arguments for ${toolName}.
406104
+ ${guidance}`;
406105
+ return { error: message, llmContent: message, systemGuidance: guidance };
406106
+ }
405673
406107
  const parameters = tool.parameters ?? {};
405674
406108
  const props = this.schemaProperties(parameters);
405675
406109
  const required = this.schemaRequired(parameters);
@@ -405869,28 +406303,12 @@ ${findingsBody}`;
405869
406303
  return corrected;
405870
406304
  }
405871
406305
  findSiblingToolSchemaMatches(requestedToolName, providedKeys) {
405872
- if (providedKeys.length === 0)
405873
- return [];
405874
- const provided = new Set(providedKeys);
405875
- const matches = [];
405876
- for (const candidate of this.tools.values()) {
405877
- if (candidate.name === requestedToolName)
405878
- continue;
405879
- const props = this.schemaProperties(candidate.parameters ?? {});
405880
- if (props.size === 0)
405881
- continue;
405882
- const required = this.schemaRequired(candidate.parameters ?? {});
405883
- const matched = providedKeys.filter((key) => props.has(key)).length;
405884
- if (matched === 0)
405885
- continue;
405886
- const requiredPresent = required.filter((key) => provided.has(key)).length;
405887
- const requiredSatisfied = required.length === 0 || requiredPresent === required.length;
405888
- const score = matched * 2 + requiredPresent * 3 + (requiredSatisfied ? 3 : 0) - Math.max(0, required.length - requiredPresent);
405889
- if (score >= 5 || matched >= 2 && requiredSatisfied) {
405890
- matches.push({ name: candidate.name, score });
405891
- }
405892
- }
405893
- return matches.sort((a, b) => b.score - a.score).slice(0, 3).map((match2) => match2.name);
406306
+ return findBetterToolSchemaMatches({
406307
+ requestedToolName,
406308
+ requestedParameters: this.lookupRegisteredTool(requestedToolName)?.tool.parameters ?? {},
406309
+ providedKeys,
406310
+ candidates: this.tools.values()
406311
+ });
405894
406312
  }
405895
406313
  unknownToolError(name) {
405896
406314
  const names = Array.from(this.tools.values()).map((tool) => tool.aliases?.length ? `${tool.name} (aliases: ${tool.aliases.join("|")})` : tool.name).sort();
@@ -406302,6 +406720,14 @@ ${notice}`;
406302
406720
  this._emitSteeringLifecycle(record9, !content ? "empty steering input rejected" : "replacement exceeds host intake authority");
406303
406721
  return this._steeringReceipt(record9);
406304
406722
  }
406723
+ if ((record9.source === "tui-work-intake" || record9.source === "tui") && record9.intent !== "cancel") {
406724
+ this._pendingSteeringReply = {
406725
+ input: record9,
406726
+ runId: this.currentArtifactRunId(),
406727
+ ownerId: this._interruptionOwnerId,
406728
+ visibleRequestTurns: []
406729
+ };
406730
+ }
406305
406731
  record9.state = "queued";
406306
406732
  this._emitSteeringLifecycle(record9, "queued for next safe turn boundary");
406307
406733
  if (steeringGatesOldPlan(record9.intent)) {
@@ -406311,6 +406737,13 @@ ${notice}`;
406311
406737
  this._requestSteeringPreemption(record9);
406312
406738
  }
406313
406739
  this._trajectoryDirtyCauses.add("user_steering");
406740
+ const grounding = this._trajectoryGroundingRequest;
406741
+ if (grounding?.runId === this.currentArtifactRunId() && grounding.taskEpoch === this._taskEpoch) {
406742
+ grounding.controller.abort(new InputWaitInterruption());
406743
+ }
406744
+ const projection = this._virtualContextRequest;
406745
+ if (projection?.runId === this.currentArtifactRunId() && projection.taskEpoch === this._taskEpoch && projection.ownerId === this._interruptionOwnerId)
406746
+ projection.controller.abort(new InputWaitInterruption());
406314
406747
  return this._steeringReceipt(record9);
406315
406748
  }
406316
406749
  /**
@@ -407169,6 +407602,11 @@ The previous reviewer response failed exact candidate-quote serialization. Host
407169
407602
  this._pendingSteeringPreemption = null;
407170
407603
  }
407171
407604
  this._emitSteeringLifecycle(record9, "retracted before admission at a safe boundary");
407605
+ if (this._activeSteering) {
407606
+ this._activeSteering.relatedInputs = this._activeSteering.relatedInputs?.filter((input) => input !== record9);
407607
+ if (this._activeSteering.input === record9 && !this._activeSteering.relatedInputs?.length)
407608
+ this._activeSteering = null;
407609
+ }
407172
407610
  return record9.content;
407173
407611
  }
407174
407612
  /** Abort the current task run through the generation-bound stop lineage. */
@@ -408636,7 +409074,7 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
408636
409074
  if (!active)
408637
409075
  return null;
408638
409076
  const { input, reconciliation } = active;
408639
- if (isSteeringScopeResolved(active))
409077
+ if (isSteeringScopeResolved(active) && !this._currentSteeringReplyPending())
408640
409078
  return null;
408641
409079
  const sources = [input, ...active.relatedInputs ?? []];
408642
409080
  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)));
@@ -408649,6 +409087,8 @@ issuer=${predecessor.runId}; evidence=${receipt.id}; raw_ref=${receipt.rawRef ??
408649
409087
  `kind=${input.intent}`,
408650
409088
  `admission=${active.gatesOldPlan ? "old_plan_gated" : "context_active"}`,
408651
409089
  "This is current user authority, not historical transcript context.",
409090
+ "Answer the latest user's question or briefly state the concrete effect of their change first, in ordinary visible prose. Then reconcile the current instruction internally before deeper planning or tools. Do not announce steering, reconciliation, or internal reviews.",
409091
+ 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,
408652
409092
  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,
408653
409093
  needsClarification ? "You requested clarification. Do not call tools or resume the old plan; ask the user one concise question." : active.requiresReconciliation ? [
408654
409094
  renderSteeringReconciliationProtocol(input.inputId),
@@ -408674,9 +409114,13 @@ ${exactSourcesPresent ? exactSourcePointer(related) : related.content}`),
408674
409114
  }
408675
409115
  _markActiveSteeringVisible(turn) {
408676
409116
  const active = this._activeSteering;
408677
- if (!active || isSteeringScopeResolved(active) || active.visibleRequestTurns.includes(turn))
409117
+ const pendingReply = this._currentSteeringReplyPending();
409118
+ if (pendingReply && active && [active.input, ...active.relatedInputs ?? []].includes(pendingReply.input) && !pendingReply.visibleRequestTurns.includes(turn))
409119
+ pendingReply.visibleRequestTurns.push(turn);
409120
+ if (!active || isSteeringScopeResolved(active) || active.visibleRequestTurns.includes(turn) && ![active.input, ...active.relatedInputs ?? []].some((input) => input.state === "queued" || input.state === "acknowledged"))
408678
409121
  return;
408679
- active.visibleRequestTurns.push(turn);
409122
+ if (!active.visibleRequestTurns.includes(turn))
409123
+ active.visibleRequestTurns.push(turn);
408680
409124
  for (const input of [active.input, ...active.relatedInputs ?? []]) {
408681
409125
  input.state = "visible_in_request";
408682
409126
  this._emitSteeringLifecycle(input, `visible in model request at turn ${turn}`);
@@ -408820,6 +409264,11 @@ ${exactSourcesPresent ? exactSourcePointer(related) : related.content}`),
408820
409264
  if (this.taskRequirementInterpretationPending)
408821
409265
  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.";
408822
409266
  const active = this._activeSteering;
409267
+ const replyTurn = this._steeringReplyTurn;
409268
+ if (replyTurn?.runId === this.currentArtifactRunId() && replyTurn.taskEpoch === this._taskEpoch && replyTurn.ownerId === this._interruptionOwnerId && replyTurn.turn === turn)
409269
+ return "[HUMAN_RESPONSE_TURN_REQUIRED] The current response answers the user. Wait for the next model decision before executing tools.";
409270
+ if (this._currentSteeringReplyPending() && (!active || isSteeringScopeResolved(active)))
409271
+ 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.";
408823
409272
  if (!active)
408824
409273
  return null;
408825
409274
  if (active.input.taskEpoch === this._taskEpoch && active.reconciliation && active.reconciliation.status !== "needs_clarification" && active.reconciledTurn === turn) {
@@ -408840,7 +409289,7 @@ The steering reconciliation was emitted this turn. Wait for the next model decis
408840
409289
  return [
408841
409290
  `[STEERING_RECONCILIATION_REQUIRED]
408842
409291
  input_id=${active.input.inputId}`,
408843
- "Do not execute the old-plan tool call. Emit the steering reconciliation first, as text in your very next response, with no tool calls in that response.",
409292
+ "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.",
408844
409293
  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,
408845
409294
  renderSteeringReconciliationProtocol(active.input.inputId)
408846
409295
  ].filter(Boolean).join("\n");
@@ -408878,7 +409327,7 @@ Only the exact pending declared read tickets may execute. Old-plan mutations and
408878
409327
  authoritySlot: "[ACTIVE USER STEERING]",
408879
409328
  priorRefusals
408880
409329
  }),
408881
- "Do not execute or retry old-plan tools. Emit [STEERING_RECONCILIATION] as your next response text with no tool calls; follow the complete protocol and user instruction in [ACTIVE USER STEERING]."
409330
+ "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]."
408882
409331
  ].join("\n");
408883
409332
  }
408884
409333
  _markFirstSteeringAffectedAction(toolName, turn) {
@@ -409471,10 +409920,19 @@ ${input.acceptedGoal}`);
409471
409920
  return brief;
409472
409921
  }
409473
409922
  _sourceReadTaskBinding() {
409923
+ const authority = (input) => ({
409924
+ inputId: input.inputId,
409925
+ content: input.content,
409926
+ intent: input.intent,
409927
+ source: input.source,
409928
+ receivedAt: input.receivedAt,
409929
+ taskEpoch: input.taskEpoch,
409930
+ allowTaskReplacement: input.allowTaskReplacement
409931
+ });
409474
409932
  return JSON.stringify({
409475
409933
  goal: this._taskState.originalGoal || this._taskState.goal,
409476
409934
  contract: this._taskObjectiveContract,
409477
- steering: this._activeSteering?.input
409935
+ steering: this._activeSteering ? [this._activeSteering.input, ...this._activeSteering.relatedInputs ?? []].map(authority) : void 0
409478
409936
  });
409479
409937
  }
409480
409938
  /** A successful remote primary may allocate only its own returned tool calls.
@@ -411127,6 +411585,8 @@ ${rawTask}`;
411127
411585
  if (this.options.trajectoryCheckpoint === "shadow" || this.options.trajectoryGrounding === "off") {
411128
411586
  return null;
411129
411587
  }
411588
+ if (this._hasUnresolvedCurrentSteeringInputs() || this._currentSteeringReplyPending() || this._currentAdjudicationArgumentRepair(turn))
411589
+ return null;
411130
411590
  const { id: _id, revision: _revision, turn: _turn, ...base } = checkpoint;
411131
411591
  const semanticKey = this._loopRecoveryAdvisoryKey();
411132
411592
  const baseFingerprint = `${trajectoryCheckpointFingerprint(base)}:${semanticKey}`;
@@ -411202,12 +411662,29 @@ ${rawTask}`;
411202
411662
  this._trajectoryGroundingAttemptedFingerprint = baseFingerprint;
411203
411663
  this._trajectoryGroundingMaterial = materialFingerprint;
411204
411664
  const review = this._beginRecoveryReview("trajectory");
411665
+ const grounding = { controller: new AbortController(), runId: this.currentArtifactRunId(), taskEpoch: this._taskEpoch };
411666
+ this._trajectoryGroundingRequest = grounding;
411667
+ const signal = AbortSignal.any([
411668
+ grounding.controller.signal,
411669
+ this._abortController.signal,
411670
+ this._turnAbortController.signal,
411671
+ this._inputWaitBoundaryController.signal
411672
+ ]);
411673
+ const owner = this._interruptionOwnerId;
411674
+ const requestGeneration = this._modelRequestGeneration;
411675
+ const assertCurrent = () => {
411676
+ signal.throwIfAborted();
411677
+ if (grounding.runId !== this.currentArtifactRunId() || grounding.taskEpoch !== this._taskEpoch || owner !== this._interruptionOwnerId || requestGeneration !== this._modelRequestGeneration || !this._recoveryReviewIsCurrent(review) || this._hasUnresolvedCurrentSteeringInputs())
411678
+ throw new InputWaitInterruption();
411679
+ };
411205
411680
  try {
411681
+ assertCurrent();
411206
411682
  this._emitModelResolutionTelemetry("trajectory_grounding", turn);
411207
411683
  const backend = this._auxInferenceBackend({
411208
- dumpStage: "trajectory_grounding"
411684
+ dumpStage: "trajectory_grounding",
411685
+ assertCurrent
411209
411686
  });
411210
- const response = await backend.chatCompletion({
411687
+ const response = await withInputWaitCancellation(signal, () => backend.chatCompletion({
411211
411688
  messages: [
411212
411689
  {
411213
411690
  role: "system",
@@ -411226,8 +411703,10 @@ ${rawTask}`;
411226
411703
  timeoutMs: this.options.requestTimeoutMs,
411227
411704
  // The output is an explicit concise assessment, not a hidden-think
411228
411705
  // transcript. Keep Qwen's structured response path reliable.
411229
- think: false
411230
- });
411706
+ think: false,
411707
+ signal
411708
+ }));
411709
+ assertCurrent();
411231
411710
  const generated = parseTrajectoryGeneratedGrounding(response.choices?.[0]?.message?.content ?? "", checkpoint.groundedFacts.map((fact) => fact.evidence));
411232
411711
  if (!this._recoveryReviewIsCurrent(review))
411233
411712
  return null;
@@ -411283,7 +411762,9 @@ ${rawTask}`;
411283
411762
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
411284
411763
  });
411285
411764
  return generated;
411286
- } catch {
411765
+ } catch (error) {
411766
+ if (signal.aborted || error instanceof InputWaitInterruption || !this._recoveryReviewIsCurrent(review))
411767
+ return null;
411287
411768
  this.emit({
411288
411769
  type: "status",
411289
411770
  content: "Trajectory grounding unavailable; retaining deterministic safety orientation",
@@ -411291,6 +411772,9 @@ ${rawTask}`;
411291
411772
  timestamp: (/* @__PURE__ */ new Date()).toISOString()
411292
411773
  });
411293
411774
  return null;
411775
+ } finally {
411776
+ if (this._trajectoryGroundingRequest === grounding)
411777
+ this._trajectoryGroundingRequest = null;
411294
411778
  }
411295
411779
  }
411296
411780
  /**
@@ -413733,12 +414217,16 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
413733
414217
  };
413734
414218
  const preparedToolArguments = /* @__PURE__ */ new WeakMap();
413735
414219
  const originalToolArguments = /* @__PURE__ */ new WeakMap();
414220
+ const preparedAdjudicationRepairs = /* @__PURE__ */ new WeakMap();
413736
414221
  const prepareToolArguments = async (tc, toolTurn) => {
413737
414222
  if (preparedToolArguments.has(tc))
413738
414223
  return preparedToolArguments.get(tc);
413739
414224
  originalToolArguments.set(tc, structuredClone(tc.arguments ?? {}));
414225
+ const preparationScope = { runId: this.currentArtifactRunId(), taskEpoch: this._taskEpoch, ownerId: this._interruptionOwnerId };
414226
+ const preparationIsCurrent = () => preparationScope.runId === this.currentArtifactRunId() && preparationScope.taskEpoch === this._taskEpoch && preparationScope.ownerId === this._interruptionOwnerId;
413740
414227
  const resolved = this.lookupRegisteredTool(tc.name);
413741
414228
  let error = null;
414229
+ let adjudicationArgs;
413742
414230
  if (resolved && !(tc.arguments && "_raw" in tc.arguments)) {
413743
414231
  try {
413744
414232
  const workflow = extractFeatureWorkflowToolBinding(tc.arguments ?? {});
@@ -413752,6 +414240,18 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
413752
414240
  args = this._autoDeriveDelegationMutationScope(resolved.name, args, toolTurn);
413753
414241
  args = await this._enrichDelegationToolArgs(resolved.name, args, messages2, toolTurn);
413754
414242
  }
414243
+ if (resolved.name === ADJUDICATION_TOOL_NAME) {
414244
+ adjudicationArgs = args;
414245
+ tc.arguments = args;
414246
+ const prior = preparationIsCurrent() ? this._currentAdjudicationArgumentRepair() : null;
414247
+ if (prior?.argsKey === this._buildExactArgsKey(args)) {
414248
+ const replay = { ...prior, turn: toolTurn, repeats: prior.repeats + 1, settled: false };
414249
+ preparedAdjudicationRepairs.set(tc, replay);
414250
+ this._adjudicationArgumentRepair = replay;
414251
+ preparedToolArguments.set(tc, prior.error);
414252
+ return prior.error;
414253
+ }
414254
+ }
413755
414255
  if (resolved.tool.inputSchema)
413756
414256
  args = this._parsedToolArgumentRecord(resolved.tool.inputSchema.parse(args));
413757
414257
  else {
@@ -413764,6 +414264,22 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
413764
414264
  this._featureWorkflowBindings.set(args, workflow.cardId);
413765
414265
  } catch (caught) {
413766
414266
  error = caught instanceof Error ? caught.message : String(caught);
414267
+ if (resolved.name === ADJUDICATION_TOOL_NAME && adjudicationArgs && preparationIsCurrent()) {
414268
+ const repair = {
414269
+ ...preparationScope,
414270
+ tool: resolved.tool,
414271
+ schema: resolved.tool.inputSchema,
414272
+ parameters: JSON.stringify(resolved.tool.parameters),
414273
+ argsKey: this._buildExactArgsKey(adjudicationArgs),
414274
+ contract: adjudicationArgumentRepairContract(error, _createHash("sha256").update(this._buildExactArgsKey(adjudicationArgs)).digest("hex")),
414275
+ error,
414276
+ turn: toolTurn,
414277
+ repeats: 0,
414278
+ settled: false
414279
+ };
414280
+ preparedAdjudicationRepairs.set(tc, repair);
414281
+ this._adjudicationArgumentRepair = repair;
414282
+ }
413767
414283
  }
413768
414284
  }
413769
414285
  preparedToolArguments.set(tc, error);
@@ -414749,7 +415265,8 @@ ${cachedResult}`,
414749
415265
  if (resolvedTool && !this._isToolExposedForModelCall(resolvedTool.name) && !this._admitDeferredDirectCall(resolvedTool.name, turn)) {
414750
415266
  result = this._missingCapabilityResult(resolvedTool.name, turn);
414751
415267
  } else if (preparedArgumentError && tool) {
414752
- const repair = this.buildToolArgumentRepairFeedback(tc.name, tc.arguments, tool, preparedArgumentError);
415268
+ const admittedRepair = preparedAdjudicationRepairs.get(tc);
415269
+ const repair = this.buildToolArgumentRepairFeedback(tc.name, tc.arguments, tool, preparedArgumentError, admittedRepair);
414753
415270
  runtimeSystemGuidance = repair.systemGuidance;
414754
415271
  result = {
414755
415272
  success: false,
@@ -414758,6 +415275,21 @@ ${cachedResult}`,
414758
415275
  llmContent: repair.llmContent,
414759
415276
  runtimeAuthored: true
414760
415277
  };
415278
+ const argumentRepair = admittedRepair && this._adjudicationArgumentRepairIsCurrent(admittedRepair) && admittedRepair.argsKey === this._buildExactArgsKey(tc.arguments) ? admittedRepair : null;
415279
+ if (argumentRepair) {
415280
+ argumentRepair.settled = true;
415281
+ this._adjudicationArgumentRepair = argumentRepair;
415282
+ result.data = { kind: "adjudication_argument_repair", contract: argumentRepair.contract };
415283
+ result.failure = { kind: "schema_validation", field: argumentRepair.contract.fields[0]?.path };
415284
+ result.failureDiagnosis = {
415285
+ ...classifyRuntimeFailure({ toolName: resolvedTool.name, failure: result.failure, errorText: repair.error }),
415286
+ retryable: false,
415287
+ createRecoveryCard: false,
415288
+ guidance: repair.systemGuidance
415289
+ };
415290
+ if (argumentRepair.repeats)
415291
+ repeatShortCircuit = result;
415292
+ }
414761
415293
  } else if (repeatShortCircuit) {
414762
415294
  result = repeatShortCircuit;
414763
415295
  } else if (tc.arguments && "_raw" in tc.arguments) {
@@ -416342,6 +416874,8 @@ ${bookkeepingGuidance}` : bookkeepingGuidance;
416342
416874
  }
416343
416875
  if (result.success) {
416344
416876
  delete result.failureDiagnosis;
416877
+ if (result.runtimeAuthored !== true && this._currentAdjudicationArgumentRepair()?.settled)
416878
+ this._adjudicationArgumentRepair = null;
416345
416879
  } else if (!processWasStopped && !completionReviewIsPending && !this._isPdfTerminalFeedback(result)) {
416346
416880
  this._diagnoseToolFailure(tc.name, tc.arguments, result);
416347
416881
  const staleHashRetryGuidance = this._buildStaleHashRetryGuidance(tc.name, tc.arguments, result);
@@ -418708,7 +419242,12 @@ ${memoryLines.join("\n")}`
418708
419242
  }
418709
419243
  const { maxOutputTokens: effectiveMaxTokens } = this.contextLimits();
418710
419244
  this.gcSystemMessages(requestMessages2);
419245
+ const steeringBeforeVirtualContext = new Set(this.pendingSteeringInputs);
418711
419246
  const virtualEvidenceMessages = await this._buildLiveVirtualContextMessages(task, requestMessages2, turn, toolDefs);
419247
+ if (this.pendingSteeringInputs.some((input) => !steeringBeforeVirtualContext.has(input) && !["cancelled", "superseded", "consumed"].includes(input.state))) {
419248
+ --localTurn;
419249
+ continue;
419250
+ }
418712
419251
  if (virtualEvidenceMessages.length > 0) {
418713
419252
  const insertionIndex = requestMessages2[0]?.role === "system" ? 1 : 0;
418714
419253
  requestMessages2.splice(insertionIndex, 0, ...virtualEvidenceMessages);
@@ -419281,6 +419820,7 @@ ${transportFailure2}` : transportFailure2;
419281
419820
  if (!choice)
419282
419821
  break;
419283
419822
  const msg = choice.message;
419823
+ this._observePrimarySteeringReply(response["_rawTypedModelContent"] ?? msg.content, turn, !this.options.streamEnabled && Boolean(msg.toolCalls?.length));
419284
419824
  this._reconcileActiveSteeringFromModel(response["_rawTypedModelContent"] ?? msg.content, turn, messages2);
419285
419825
  if (this._preparedTaskScopeBoundary && this._pendingSteeringPreemption) {
419286
419826
  await this._applySteeringAtSafeBoundary(messages2, turn);
@@ -420315,7 +420855,12 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
420315
420855
  }
420316
420856
  this._insertContextFrame(compactedMsgs, await this._buildTurnContextFrame(turn, compactedMsgs, void 0, bfEnvironmentBlock));
420317
420857
  this.gcSystemMessages(compactedMsgs);
420858
+ const steeringBeforeVirtualContext = new Set(this.pendingSteeringInputs);
420318
420859
  const virtualEvidenceMessages = await this._buildLiveVirtualContextMessages(persistentTaskGoal, compactedMsgs, turn, toolDefs);
420860
+ if (this.pendingSteeringInputs.some((input) => !steeringBeforeVirtualContext.has(input) && !["cancelled", "superseded", "consumed"].includes(input.state))) {
420861
+ --localTurn;
420862
+ continue;
420863
+ }
420319
420864
  const bfRequestMessages = compactedMsgs.map((message) => ({
420320
420865
  ...message
420321
420866
  }));
@@ -420635,6 +421180,7 @@ ${diagnosis}` : diagnosis;
420635
421180
  if (!choice)
420636
421181
  break;
420637
421182
  const msg = choice.message;
421183
+ this._observePrimarySteeringReply(response["_rawTypedModelContent"] ?? msg.content, turn, !this.options.streamEnabled && Boolean(msg.toolCalls?.length));
420638
421184
  this._reconcileActiveSteeringFromModel(response["_rawTypedModelContent"] ?? msg.content, turn, messages2);
420639
421185
  if (this._preparedTaskScopeBoundary && this._pendingSteeringPreemption) {
420640
421186
  await this._applySteeringAtSafeBoundary(messages2, turn);
@@ -422306,7 +422852,12 @@ ${marker}` : marker);
422306
422852
  success: success !== false,
422307
422853
  identicalToPreviousRun: this._observationLedger.identicalRunsFor(fingerprint2) >= 2
422308
422854
  });
422309
- return this.buildToolMessage(this.compactDiscoveryOutputForModel(toolName, args, output, success, toolCallId, provenance2?.fullReadAdmitted), toolCallId, toolName);
422855
+ const compact4 = this.compactDiscoveryOutputForModel(toolName, args, output, success, toolCallId, provenance2?.fullReadAdmitted);
422856
+ const sourceRead = success === true && toolName === "file_read" ? this._historyObservations.get(toolCallId)?.sourceRead : void 0;
422857
+ const precondition = sourceRead ? `[FILE_EDIT_PRECONDITION]
422858
+ ${JSON.stringify({ path: this._normalizeEvidencePath(sourceRead.path), expected_hash: sourceRead.hash })}
422859
+ ` : "";
422860
+ return this.buildToolMessage(precondition + compact4, toolCallId, toolName);
422310
422861
  }
422311
422862
  compactDiscoveryOutputForModel(toolName, args, output, success, toolCallId, fullReadAdmitted) {
422312
422863
  if (success !== true)
@@ -422606,13 +423157,16 @@ ${marker}` : marker);
422606
423157
  return { args: { ...args, expected_hash: fresh.hash }, patchedCount: 1 };
422607
423158
  }
422608
423159
  if (toolName === "file_write" || toolName === "file_patch") {
422609
- if (this._normalizeExpectedHashValue(this._rawExpectedHashValue(args))) {
422610
- return { args, patchedCount: 0 };
422611
- }
423160
+ const supplied = this._normalizeExpectedHashValue(this._rawExpectedHashValue(args));
422612
423161
  const path7 = this.extractPrimaryToolPath(args);
422613
423162
  const fresh = path7 ? this._freshReadHashForEditPath(path7) : null;
422614
423163
  if (!fresh)
422615
423164
  return { args, patchedCount: 0 };
423165
+ if (supplied) {
423166
+ const readArtifact = [...this._historyObservations].some(([id5, observation]) => observation.sourceRead && this._normalizeEvidencePath(observation.sourceRead.path) === fresh.key && observation.sourceRead.hash === fresh.hash && this._canonicalAcceptedReceipts.get(id5)?.artifactLocator === `omnius-artifact://sha256/${supplied}`);
423167
+ if (supplied === fresh.hash || !readArtifact)
423168
+ return { args, patchedCount: 0 };
423169
+ }
422616
423170
  return { args: { ...args, expected_hash: fresh.hash }, patchedCount: 1 };
422617
423171
  }
422618
423172
  if (toolName !== "batch_edit" || !Array.isArray(args["edits"])) {
@@ -427795,11 +428349,12 @@ ${description}`
427795
428349
  * until recovery; other transient backend errors use bounded backoff.
427796
428350
  * Returns the response on success, or null if recovery did not apply.
427797
428351
  */
427798
- async waitForTransientRetry(delayMs) {
428352
+ async waitForTransientRetry(delayMs, operationSignal) {
427799
428353
  const signals = [
427800
428354
  this._abortController.signal,
427801
428355
  this._turnAbortController.signal,
427802
- this._inputWaitBoundaryController.signal
428356
+ this._inputWaitBoundaryController.signal,
428357
+ ...operationSignal ? [operationSignal] : []
427803
428358
  ];
427804
428359
  if (signals.some((signal) => signal.aborted))
427805
428360
  return;
@@ -429015,6 +429570,9 @@ var OllamaAgenticBackend = class _OllamaAgenticBackend {
429015
429570
  if (enabledGpuUuids !== void 0) {
429016
429571
  headers["X-Ollama-Unify-GPU-UUIDs"] = enabledGpuUuids.length > 0 ? enabledGpuUuids.join(",") : "none";
429017
429572
  }
429573
+ if (cpuOffloadAllowedFromEnv()) {
429574
+ headers["X-Ollama-Unify-CPU-Offload"] = "allow";
429575
+ }
429018
429576
  const envOverride = process.env["OMNIUS_OLLAMA_BROKER_ADMISSION_WAIT_MS"];
429019
429577
  const classDefault = workloadClass === "background" ? 500 : workloadClass === "interactive-control" ? 3e4 : void 0;
429020
429578
  const configured = Number.parseInt(String(request?.brokerAdmissionWaitMs ?? envOverride ?? classDefault ?? 0), 10);
@@ -430170,114 +430728,6 @@ init_dist3();
430170
430728
  init_ollama_pool();
430171
430729
  init_ollama_pool_cleanup();
430172
430730
 
430173
- // packages/orchestrator/dist/adjudication.js
430174
- import { z as z25 } from "zod";
430175
- var IdSchema = z25.string().trim().min(1).max(96).regex(/^[A-Za-z0-9][A-Za-z0-9._:-]*$/, "use a stable identifier without whitespace");
430176
- var AdjudicationEvidenceSchema = z25.object({
430177
- id: IdSchema,
430178
- content: z25.string().trim().min(1).max(32e3),
430179
- source: z25.string().trim().min(1).max(500),
430180
- kind: z25.enum([
430181
- "fact",
430182
- "observation",
430183
- "artifact",
430184
- "test_result",
430185
- "testimony",
430186
- "constraint",
430187
- "precedent"
430188
- ]).default("observation"),
430189
- observedAt: z25.string().trim().max(80).optional(),
430190
- sha256: z25.string().trim().regex(/^[a-fA-F0-9]{64}$/).optional(),
430191
- reliability: z25.number().min(0).max(1).optional()
430192
- });
430193
- var AdjudicationArgumentSchema = z25.object({
430194
- id: IdSchema,
430195
- position: z25.string().trim().min(1).max(160),
430196
- claim: z25.string().trim().min(1).max(4e3),
430197
- citedEvidenceIds: z25.array(IdSchema).min(1).max(64),
430198
- submittedBy: z25.string().trim().max(160).optional()
430199
- });
430200
- var AdjudicationConstituentInputSchema = z25.object({
430201
- id: IdSchema.optional(),
430202
- label: z25.string().trim().min(1).max(120),
430203
- question: z25.string().trim().min(1).max(2e3),
430204
- instructions: z25.string().trim().max(2e3).optional(),
430205
- evidenceIds: z25.array(IdSchema).min(1).max(128).optional(),
430206
- argumentIds: z25.array(IdSchema).max(64).optional(),
430207
- decisionRuleIds: z25.array(IdSchema).max(32).optional()
430208
- });
430209
- var AdjudicationInputSchema = z25.object({
430210
- caseId: IdSchema.optional(),
430211
- question: z25.string().trim().min(1).max(4e3),
430212
- context: z25.string().trim().max(8e3).optional(),
430213
- exclusions: z25.array(z25.string().trim().min(1).max(2e3)).max(32).default([]),
430214
- allowedOutcomes: z25.array(IdSchema).min(2).max(12),
430215
- decisionRules: z25.array(z25.string().trim().min(1).max(2e3)).max(24).default([]),
430216
- burdenOfProof: z25.enum([
430217
- "best_supported",
430218
- "preponderance",
430219
- "clear_and_convincing",
430220
- "beyond_reasonable_doubt",
430221
- "risk_averse"
430222
- ]).default("best_supported"),
430223
- evidence: z25.array(AdjudicationEvidenceSchema).min(1).max(128),
430224
- arguments: z25.array(AdjudicationArgumentSchema).max(64).default([]),
430225
- constituents: z25.array(AdjudicationConstituentInputSchema).min(2).max(6).optional(),
430226
- panelSize: z25.number().int().min(2).max(6).default(3),
430227
- maxConcurrency: z25.number().int().min(1).max(6).default(3),
430228
- quorum: z25.number().int().min(2).max(6).optional(),
430229
- constituentExecution: z25.enum(["auto", "full_sub_agent", "direct"]).default("auto"),
430230
- timeoutMs: z25.number().int().min(5e3).max(6e5).default(12e4),
430231
- maxTokensPerConstituent: z25.number().int().min(512).max(8192).default(2048),
430232
- maxJudgeTokens: z25.number().int().min(768).max(12288).default(3072)
430233
- });
430234
- var PlannerResponseSchema = z25.object({
430235
- schemaVersion: z25.literal(1),
430236
- caseId: IdSchema,
430237
- assignments: z25.array(z25.object({
430238
- id: IdSchema,
430239
- label: z25.string().trim().min(1).max(120),
430240
- question: z25.string().trim().min(1).max(2e3),
430241
- instructions: z25.string().trim().max(2e3).default(""),
430242
- evidenceIds: z25.array(IdSchema).min(1).max(128),
430243
- argumentIds: z25.array(IdSchema).max(64).default([]),
430244
- decisionRuleIds: z25.array(IdSchema).min(1).max(32)
430245
- })).min(2).max(6)
430246
- });
430247
- var ConstituentResponseSchema = z25.object({
430248
- schemaVersion: z25.literal(1),
430249
- caseId: IdSchema,
430250
- constituentId: IdSchema,
430251
- assessment: z25.string().trim().min(20).max(8e3),
430252
- recommendation: IdSchema,
430253
- confidence: z25.number().min(0).max(1),
430254
- citedEvidenceIds: z25.array(IdSchema).min(1).max(128),
430255
- claims: z25.array(z25.object({
430256
- claim: z25.string().trim().min(1).max(2e3),
430257
- evidenceIds: z25.array(IdSchema).min(1).max(64)
430258
- })).min(1).max(24),
430259
- counterarguments: z25.array(z25.string().trim().min(1).max(2e3)).max(16).default([]),
430260
- uncertainties: z25.array(z25.string().trim().min(1).max(2e3)).max(16).default([])
430261
- });
430262
- var JudgeResponseSchema = z25.object({
430263
- schemaVersion: z25.literal(1),
430264
- caseId: IdSchema,
430265
- verdict: IdSchema,
430266
- confidence: z25.number().min(0).max(1),
430267
- rationale: z25.string().trim().min(30).max(12e3),
430268
- citedEvidenceIds: z25.array(IdSchema).min(1).max(128),
430269
- consideredConstituentIds: z25.array(IdSchema).min(2).max(6),
430270
- acceptedFindingIds: z25.array(IdSchema).max(144),
430271
- rejectedFindingIds: z25.array(IdSchema).max(144),
430272
- dissent: z25.array(z25.object({
430273
- constituentId: IdSchema,
430274
- recommendation: IdSchema,
430275
- summary: z25.string().trim().min(1).max(2e3)
430276
- })).max(6).default([]),
430277
- unresolvedQuestions: z25.array(z25.string().trim().min(1).max(2e3)).max(24).default([]),
430278
- nextAction: z25.string().trim().min(1).max(4e3)
430279
- });
430280
-
430281
430731
  // packages/orchestrator/dist/agent-types.js
430282
430732
  var READ_ONLY_TOOLS = [
430283
430733
  "file_read",