omnius 1.0.272 → 1.0.274
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +706 -627
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -551999,22 +551999,48 @@ var init_VllmBackend = __esm({
|
|
|
551999
551999
|
// -------------------------------------------------------------------------
|
|
552000
552000
|
// LLMBackend — healthCheck
|
|
552001
552001
|
// -------------------------------------------------------------------------
|
|
552002
|
+
/**
|
|
552003
|
+
* Health check with retry + circuit breaker.
|
|
552004
|
+
* Retries up to 3 times with exponential backoff (1s, 2s, 4s).
|
|
552005
|
+
* After 3 consecutive failures, enters "degraded" state for 30s before retrying.
|
|
552006
|
+
*/
|
|
552007
|
+
consecutiveFailures = 0;
|
|
552008
|
+
degradedUntil = 0;
|
|
552002
552009
|
async healthCheck() {
|
|
552010
|
+
if (this.consecutiveFailures >= 3 && Date.now() < this.degradedUntil) {
|
|
552011
|
+
return false;
|
|
552012
|
+
}
|
|
552013
|
+
if (this.consecutiveFailures >= 3 && Date.now() >= this.degradedUntil) {
|
|
552014
|
+
this.consecutiveFailures = 0;
|
|
552015
|
+
}
|
|
552003
552016
|
const url = `${this.baseUrl}/health`;
|
|
552004
552017
|
const controller = new AbortController();
|
|
552005
552018
|
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
552006
|
-
|
|
552007
|
-
|
|
552008
|
-
|
|
552009
|
-
|
|
552010
|
-
|
|
552011
|
-
}
|
|
552012
|
-
|
|
552013
|
-
|
|
552014
|
-
|
|
552015
|
-
|
|
552016
|
-
|
|
552019
|
+
const maxRetries = 3;
|
|
552020
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
552021
|
+
if (attempt > 0) {
|
|
552022
|
+
const backoff = Math.min(1e3 * Math.pow(2, attempt - 1), 4e3);
|
|
552023
|
+
await new Promise((r2) => setTimeout(r2, backoff));
|
|
552024
|
+
}
|
|
552025
|
+
try {
|
|
552026
|
+
const response = await fetch(url, {
|
|
552027
|
+
method: "GET",
|
|
552028
|
+
signal: controller.signal,
|
|
552029
|
+
headers: this.authHeaders()
|
|
552030
|
+
});
|
|
552031
|
+
if (response.ok) {
|
|
552032
|
+
this.consecutiveFailures = 0;
|
|
552033
|
+
return true;
|
|
552034
|
+
}
|
|
552035
|
+
} catch {
|
|
552036
|
+
}
|
|
552017
552037
|
}
|
|
552038
|
+
clearTimeout(timer);
|
|
552039
|
+
this.consecutiveFailures++;
|
|
552040
|
+
if (this.consecutiveFailures >= 3) {
|
|
552041
|
+
this.degradedUntil = Date.now() + 3e4;
|
|
552042
|
+
}
|
|
552043
|
+
return false;
|
|
552018
552044
|
}
|
|
552019
552045
|
// -------------------------------------------------------------------------
|
|
552020
552046
|
// LLMBackend — complete
|
|
@@ -552186,21 +552212,47 @@ var init_OllamaBackend = __esm({
|
|
|
552186
552212
|
// -------------------------------------------------------------------------
|
|
552187
552213
|
// LLMBackend — healthCheck
|
|
552188
552214
|
// -------------------------------------------------------------------------
|
|
552215
|
+
/**
|
|
552216
|
+
* Health check with retry + circuit breaker.
|
|
552217
|
+
* Retries up to 3 times with exponential backoff (1s, 2s, 4s).
|
|
552218
|
+
* After 3 consecutive failures, enters "degraded" state for 30s before retrying.
|
|
552219
|
+
*/
|
|
552220
|
+
consecutiveFailures = 0;
|
|
552221
|
+
degradedUntil = 0;
|
|
552189
552222
|
async healthCheck() {
|
|
552223
|
+
if (this.consecutiveFailures >= 3 && Date.now() < this.degradedUntil) {
|
|
552224
|
+
return false;
|
|
552225
|
+
}
|
|
552226
|
+
if (this.consecutiveFailures >= 3 && Date.now() >= this.degradedUntil) {
|
|
552227
|
+
this.consecutiveFailures = 0;
|
|
552228
|
+
}
|
|
552190
552229
|
const url = `${this.baseUrl}/api/tags`;
|
|
552191
552230
|
const controller = new AbortController();
|
|
552192
552231
|
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
552193
|
-
|
|
552194
|
-
|
|
552195
|
-
|
|
552196
|
-
|
|
552197
|
-
|
|
552198
|
-
|
|
552199
|
-
|
|
552200
|
-
|
|
552201
|
-
|
|
552202
|
-
|
|
552232
|
+
const maxRetries = 3;
|
|
552233
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
552234
|
+
if (attempt > 0) {
|
|
552235
|
+
const backoff = Math.min(1e3 * Math.pow(2, attempt - 1), 4e3);
|
|
552236
|
+
await new Promise((r2) => setTimeout(r2, backoff));
|
|
552237
|
+
}
|
|
552238
|
+
try {
|
|
552239
|
+
const response = await fetch(url, {
|
|
552240
|
+
method: "GET",
|
|
552241
|
+
signal: controller.signal
|
|
552242
|
+
});
|
|
552243
|
+
if (response.ok) {
|
|
552244
|
+
this.consecutiveFailures = 0;
|
|
552245
|
+
return true;
|
|
552246
|
+
}
|
|
552247
|
+
} catch {
|
|
552248
|
+
}
|
|
552203
552249
|
}
|
|
552250
|
+
clearTimeout(timer);
|
|
552251
|
+
this.consecutiveFailures++;
|
|
552252
|
+
if (this.consecutiveFailures >= 3) {
|
|
552253
|
+
this.degradedUntil = Date.now() + 3e4;
|
|
552254
|
+
}
|
|
552255
|
+
return false;
|
|
552204
552256
|
}
|
|
552205
552257
|
// -------------------------------------------------------------------------
|
|
552206
552258
|
// LLMBackend — complete
|
|
@@ -555379,210 +555431,531 @@ var init_permissionRuleset = __esm({
|
|
|
555379
555431
|
}
|
|
555380
555432
|
});
|
|
555381
555433
|
|
|
555382
|
-
// packages/orchestrator/dist/
|
|
555383
|
-
|
|
555384
|
-
|
|
555385
|
-
|
|
555386
|
-
}
|
|
555387
|
-
function
|
|
555388
|
-
const key = String(value2 ?? fallback).trim().toLowerCase().replace(/[^a-z0-9_.:-]+/g, "_").replace(/_{2,}/g, "_").replace(/^[_:.-]+|[_:.-]+$/g, "").slice(0, 96);
|
|
555389
|
-
return key || fallback;
|
|
555390
|
-
}
|
|
555391
|
-
function genericField(key, label, description, acceptanceCriteria) {
|
|
555434
|
+
// packages/orchestrator/dist/steeringIntake.js
|
|
555435
|
+
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
555436
|
+
import { appendFileSync as appendFileSync4, existsSync as existsSync79, mkdirSync as mkdirSync45, readFileSync as readFileSync60 } from "node:fs";
|
|
555437
|
+
import { join as join91 } from "node:path";
|
|
555438
|
+
import { z as z16 } from "zod";
|
|
555439
|
+
function createSteeringIngress(input) {
|
|
555392
555440
|
return {
|
|
555393
|
-
|
|
555394
|
-
|
|
555395
|
-
|
|
555396
|
-
|
|
555397
|
-
|
|
555398
|
-
|
|
555399
|
-
|
|
555441
|
+
id: randomUUID16(),
|
|
555442
|
+
rawText: input.rawText.trim(),
|
|
555443
|
+
sourceSurface: input.sourceSurface,
|
|
555444
|
+
authority: "user",
|
|
555445
|
+
isReplacement: input.isReplacement ?? false,
|
|
555446
|
+
currentTaskGoal: input.currentTaskGoal || "(unknown current task)",
|
|
555447
|
+
recentActivity: input.recentActivity,
|
|
555448
|
+
filesTouched: (input.filesTouched ?? []).filter(Boolean).slice(0, 12),
|
|
555449
|
+
toolCallCount: input.toolCallCount ?? 0,
|
|
555450
|
+
taskId: input.taskId,
|
|
555451
|
+
sessionId: input.sessionId,
|
|
555452
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
555400
555453
|
};
|
|
555401
555454
|
}
|
|
555402
|
-
function
|
|
555403
|
-
const
|
|
555404
|
-
|
|
555405
|
-
|
|
555406
|
-
|
|
555407
|
-
|
|
555408
|
-
|
|
555409
|
-
|
|
555410
|
-
|
|
555411
|
-
|
|
555412
|
-
|
|
555413
|
-
|
|
555414
|
-
|
|
555415
|
-
|
|
555416
|
-
|
|
555417
|
-
|
|
555418
|
-
|
|
555419
|
-
|
|
555420
|
-
|
|
555421
|
-
|
|
555422
|
-
|
|
555423
|
-
|
|
555424
|
-
|
|
555425
|
-
|
|
555426
|
-
|
|
555427
|
-
|
|
555428
|
-
|
|
555429
|
-
|
|
555430
|
-
|
|
555431
|
-
|
|
555432
|
-
|
|
555433
|
-
|
|
555434
|
-
|
|
555435
|
-
|
|
555436
|
-
|
|
555437
|
-
|
|
555438
|
-
|
|
555439
|
-
|
|
555455
|
+
async function interpretSteeringIngress(backend, ingress, timeoutMs = 8e3) {
|
|
555456
|
+
const first2 = await backend.chatCompletion({
|
|
555457
|
+
messages: [
|
|
555458
|
+
{
|
|
555459
|
+
role: "system",
|
|
555460
|
+
content: [
|
|
555461
|
+
"You interpret human feedback for a running coding agent.",
|
|
555462
|
+
"Return strict JSON only.",
|
|
555463
|
+
"Use only the supplied task trajectory and ingress.",
|
|
555464
|
+
"The JSON fields describe task impact and next-action guidance."
|
|
555465
|
+
].join("\n")
|
|
555466
|
+
},
|
|
555467
|
+
{ role: "user", content: buildInterpretationPrompt(ingress) }
|
|
555468
|
+
],
|
|
555469
|
+
tools: [],
|
|
555470
|
+
temperature: 0.2,
|
|
555471
|
+
maxTokens: 512,
|
|
555472
|
+
timeoutMs,
|
|
555473
|
+
think: false,
|
|
555474
|
+
responseFormat: steeringInterpretationResponseFormat()
|
|
555475
|
+
});
|
|
555476
|
+
const raw = first2.choices[0]?.message?.content ?? "";
|
|
555477
|
+
const parsed = parseSteeringInterpretation(raw);
|
|
555478
|
+
if (parsed)
|
|
555479
|
+
return parsed;
|
|
555480
|
+
const repaired = await backend.chatCompletion({
|
|
555481
|
+
messages: [
|
|
555482
|
+
{
|
|
555483
|
+
role: "system",
|
|
555484
|
+
content: "Repair the supplied text into strict JSON matching the requested schema. Return JSON only."
|
|
555485
|
+
},
|
|
555486
|
+
{
|
|
555487
|
+
role: "user",
|
|
555488
|
+
content: [
|
|
555489
|
+
"Schema keys: inference, runnerInstruction, conflicts, alternatives, memoryNote.",
|
|
555490
|
+
"Required keys: inference, runnerInstruction.",
|
|
555491
|
+
"",
|
|
555492
|
+
"Original task state and ingress:",
|
|
555493
|
+
buildInterpretationPrompt(ingress),
|
|
555494
|
+
"",
|
|
555495
|
+
"Malformed model output:",
|
|
555496
|
+
raw
|
|
555497
|
+
].join("\n")
|
|
555440
555498
|
}
|
|
555441
|
-
|
|
555442
|
-
|
|
555443
|
-
|
|
555444
|
-
|
|
555445
|
-
|
|
555446
|
-
|
|
555447
|
-
|
|
555448
|
-
|
|
555449
|
-
|
|
555450
|
-
"The final response distinguishes completed work from verified evidence and unverified or blocked claims."
|
|
555451
|
-
]
|
|
555452
|
-
};
|
|
555499
|
+
],
|
|
555500
|
+
tools: [],
|
|
555501
|
+
temperature: 0,
|
|
555502
|
+
maxTokens: 512,
|
|
555503
|
+
timeoutMs,
|
|
555504
|
+
think: false,
|
|
555505
|
+
responseFormat: steeringInterpretationResponseFormat()
|
|
555506
|
+
});
|
|
555507
|
+
return parseSteeringInterpretation(repaired.choices[0]?.message?.content ?? "");
|
|
555453
555508
|
}
|
|
555454
|
-
function
|
|
555455
|
-
const
|
|
555456
|
-
|
|
555509
|
+
function buildSteeringPacket(ingress, interpretation) {
|
|
555510
|
+
const lines = [
|
|
555511
|
+
STEERING_START,
|
|
555512
|
+
`id: ${ingress.id}`,
|
|
555513
|
+
`sourceSurface: ${ingress.sourceSurface}`,
|
|
555514
|
+
`feedbackKind: external_human`,
|
|
555515
|
+
`authority: ${ingress.authority}`,
|
|
555516
|
+
`replacement: ${ingress.isReplacement ? "true" : "false"}`,
|
|
555517
|
+
`toolCallsSoFar: ${ingress.toolCallCount}`,
|
|
555518
|
+
`timestamp: ${ingress.timestamp}`,
|
|
555519
|
+
"",
|
|
555520
|
+
"Instruction hierarchy:",
|
|
555521
|
+
"- Treat this as user-level steering, below system/developer/tool safety and above older user assumptions when they conflict.",
|
|
555522
|
+
"",
|
|
555523
|
+
"Current task goal:",
|
|
555524
|
+
truncateBlock(ingress.currentTaskGoal || "(unknown current task)", 1200),
|
|
555525
|
+
"",
|
|
555526
|
+
"Recent activity:",
|
|
555527
|
+
truncateBlock(ingress.recentActivity || "(no recent activity recorded)", 1200),
|
|
555528
|
+
"",
|
|
555529
|
+
ingress.filesTouched.length > 0 ? `Files touched so far: ${ingress.filesTouched.join(", ")}` : "Files touched so far: none recorded",
|
|
555530
|
+
"",
|
|
555531
|
+
RAW_START,
|
|
555532
|
+
ingress.rawText,
|
|
555533
|
+
RAW_END,
|
|
555534
|
+
""
|
|
555535
|
+
];
|
|
555536
|
+
if (interpretation) {
|
|
555537
|
+
lines.push("Model-derived steering interpretation:", `inference: ${interpretation.inference}`, `runnerInstruction: ${interpretation.runnerInstruction}`);
|
|
555538
|
+
if (interpretation.conflicts?.length) {
|
|
555539
|
+
lines.push("conflicts:", ...interpretation.conflicts.map((item) => `- ${item}`));
|
|
555540
|
+
}
|
|
555541
|
+
if (interpretation.alternatives?.length) {
|
|
555542
|
+
lines.push("alternative interpretations:", ...interpretation.alternatives.map((item) => `- ${item}`));
|
|
555543
|
+
}
|
|
555544
|
+
if (interpretation.memoryNote) {
|
|
555545
|
+
lines.push(`memoryNote: ${interpretation.memoryNote}`);
|
|
555546
|
+
}
|
|
555547
|
+
lines.push("");
|
|
555548
|
+
} else {
|
|
555549
|
+
lines.push("Model-derived steering interpretation: unavailable", "");
|
|
555550
|
+
}
|
|
555551
|
+
lines.push("Interleave contract:", "- Consume this before the next assistant/tool decision.", "- Do not treat it as passive transcript context.", "- Either act on the steering directly, or explicitly reconcile why it does not alter the current plan.", STEERING_END);
|
|
555552
|
+
return lines.join("\n");
|
|
555457
555553
|
}
|
|
555458
|
-
function
|
|
555459
|
-
|
|
555554
|
+
function extractMidTaskSteeringInput(value2) {
|
|
555555
|
+
const start2 = value2.indexOf(RAW_START);
|
|
555556
|
+
const end = value2.indexOf(RAW_END);
|
|
555557
|
+
if (start2 < 0 || end <= start2)
|
|
555558
|
+
return null;
|
|
555559
|
+
return value2.slice(start2 + RAW_START.length, end).trim();
|
|
555460
555560
|
}
|
|
555461
|
-
function
|
|
555462
|
-
|
|
555561
|
+
function appendSteeringLedgerEntry(repoRoot, entry) {
|
|
555562
|
+
try {
|
|
555563
|
+
const dir = join91(repoRoot, ".omnius", "context");
|
|
555564
|
+
mkdirSync45(dir, { recursive: true });
|
|
555565
|
+
appendFileSync4(join91(dir, LEDGER_FILE), `${JSON.stringify(entry)}
|
|
555566
|
+
`, "utf-8");
|
|
555567
|
+
} catch {
|
|
555568
|
+
}
|
|
555463
555569
|
}
|
|
555464
|
-
function
|
|
555465
|
-
const
|
|
555466
|
-
|
|
555467
|
-
|
|
555468
|
-
|
|
555469
|
-
|
|
555470
|
-
|
|
555471
|
-
|
|
555472
|
-
|
|
555473
|
-
|
|
555474
|
-
}
|
|
555475
|
-
function deriveScenarioSeed(input) {
|
|
555476
|
-
const text2 = [
|
|
555477
|
-
input.taskText,
|
|
555478
|
-
input.contract.goalSummary,
|
|
555479
|
-
input.proposedSummary,
|
|
555480
|
-
input.answerText
|
|
555481
|
-
].map((part) => String(part ?? "").trim()).filter(Boolean).join("\n");
|
|
555482
|
-
const normalized = normalizeCompletionKey(text2.slice(0, 140), "completion_scenario");
|
|
555483
|
-
return normalized || "completion_scenario";
|
|
555570
|
+
function appendSteeringOutcome(repoRoot, packetIds, outcome, summary) {
|
|
555571
|
+
for (const packetId of packetIds) {
|
|
555572
|
+
appendSteeringLedgerEntry(repoRoot, {
|
|
555573
|
+
type: "outcome",
|
|
555574
|
+
packetId,
|
|
555575
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
555576
|
+
outcome,
|
|
555577
|
+
summary: summary.slice(0, 1200)
|
|
555578
|
+
});
|
|
555579
|
+
}
|
|
555484
555580
|
}
|
|
555485
|
-
function
|
|
555486
|
-
const
|
|
555487
|
-
|
|
555488
|
-
|
|
555489
|
-
|
|
555490
|
-
|
|
555491
|
-
|
|
555492
|
-
|
|
555493
|
-
|
|
555494
|
-
|
|
555495
|
-
...(input.recentFailures ?? []).map((item) => `recent failure: ${clip2(item, 260)}`),
|
|
555496
|
-
...(input.planStatus ?? []).filter((item) => item.status || item.reconciled || item.rationale).map((item) => {
|
|
555497
|
-
const state = [item.status, item.reconciled].filter(Boolean).join("/");
|
|
555498
|
-
const suffix = item.rationale ? ` (${clip2(item.rationale, 180)})` : "";
|
|
555499
|
-
return `plan ${state || "observed"}: ${clip2(item.content, 220)}${suffix}`;
|
|
555500
|
-
})
|
|
555501
|
-
];
|
|
555502
|
-
const modifiedFiles = (input.modifiedFiles ?? []).slice(0, 30).map((file) => {
|
|
555503
|
-
const meta = [
|
|
555504
|
-
file.status ? `status=${clip2(file.status, 40)}` : "",
|
|
555505
|
-
typeof file.bytes === "number" ? `bytes=${file.bytes}` : ""
|
|
555506
|
-
].filter(Boolean).join(" ");
|
|
555507
|
-
return `${clip2(file.path, 220)}${meta ? ` (${meta})` : ""}`;
|
|
555581
|
+
function buildRecentSteeringContext(repoRoot, limit = 3) {
|
|
555582
|
+
const entries = readRecentSteeringEntries(repoRoot, limit);
|
|
555583
|
+
if (entries.length === 0)
|
|
555584
|
+
return "";
|
|
555585
|
+
const lines = entries.map((entry, idx) => {
|
|
555586
|
+
const interpretation = entry.interpretation;
|
|
555587
|
+
const inference = interpretation?.inference || "(raw steering only)";
|
|
555588
|
+
const note = interpretation?.memoryNote ? ` Memory note: ${interpretation.memoryNote}` : "";
|
|
555589
|
+
const outcome = entry.outcome ? ` Outcome: ${entry.outcome}.` : "";
|
|
555590
|
+
return `${idx + 1}. ${inference}${note}${outcome}`;
|
|
555508
555591
|
});
|
|
555509
|
-
|
|
555510
|
-
|
|
555511
|
-
|
|
555512
|
-
|
|
555513
|
-
|
|
555514
|
-
|
|
555515
|
-
lines.push(clip2(input.taskText || input.contract.goalSummary, 1200) || "(not provided)");
|
|
555516
|
-
lines.push(``);
|
|
555517
|
-
lines.push(`Proposed completion claim text:`);
|
|
555518
|
-
lines.push(proposedClaimText || "(no proposed completion text yet)");
|
|
555519
|
-
lines.push(``);
|
|
555520
|
-
lines.push(`Observed run evidence:`);
|
|
555521
|
-
lines.push(...listLines(observedEvidence, "- no tool evidence recorded"));
|
|
555522
|
-
lines.push(``);
|
|
555523
|
-
lines.push(`Unresolved or caution signals:`);
|
|
555524
|
-
lines.push(...listLines(unresolvedSignals, "- none recorded"));
|
|
555525
|
-
lines.push(``);
|
|
555526
|
-
lines.push(`Modified artifact digest:`);
|
|
555527
|
-
lines.push(...listLines(modifiedFiles, "- no modified artifacts listed"));
|
|
555528
|
-
lines.push(``);
|
|
555529
|
-
lines.push(`Reviewer decomposition task:`);
|
|
555530
|
-
lines.push(`- Invent a situation-specific completion scenario from the request, proposed claims, and observed run data above.`);
|
|
555531
|
-
lines.push(`- Enumerate the material claims in the proposed completion text, including implied claims about created state, external effects, recipient-visible outcomes, runtime behavior, research facts, or absence of blockers when those claims appear in the text.`);
|
|
555532
|
-
lines.push(`- For each claim, derive what would make it true from the claim's semantics, the user's request, and this run's observations.`);
|
|
555533
|
-
lines.push(`- Map the claim to the observed evidence, contradictions, missing observations, and unresolved loops shown above.`);
|
|
555534
|
-
lines.push(`- If an unsupported claim is material, propose the smallest next observation or correction; if the final wording already marks it unverified or blocked, treat that honesty as part of the evidence review.`);
|
|
555535
|
-
return {
|
|
555536
|
-
scenarioSeed,
|
|
555537
|
-
prompt: lines.join("\n"),
|
|
555538
|
-
proposedClaimText,
|
|
555539
|
-
observedEvidence,
|
|
555540
|
-
unresolvedSignals
|
|
555541
|
-
};
|
|
555592
|
+
return [
|
|
555593
|
+
"<recent-user-steering>",
|
|
555594
|
+
"Recent user steering reflections from this workspace. Use only when relevant to the current task.",
|
|
555595
|
+
...lines,
|
|
555596
|
+
"</recent-user-steering>"
|
|
555597
|
+
].join("\n");
|
|
555542
555598
|
}
|
|
555543
|
-
function
|
|
555544
|
-
|
|
555545
|
-
|
|
555546
|
-
|
|
555547
|
-
|
|
555548
|
-
|
|
555549
|
-
|
|
555550
|
-
|
|
555551
|
-
|
|
555552
|
-
|
|
555553
|
-
|
|
555554
|
-
|
|
555555
|
-
|
|
555556
|
-
|
|
555557
|
-
|
|
555599
|
+
function buildInterpretationPrompt(ingress) {
|
|
555600
|
+
return [
|
|
555601
|
+
"Infer how this human feedback changes, constrains, or clarifies the active task.",
|
|
555602
|
+
"If there are multiple plausible readings, include them in alternatives.",
|
|
555603
|
+
"If the feedback conflicts with prior task assumptions, list the conflict.",
|
|
555604
|
+
"If this should persist beyond the current turn, include memoryNote.",
|
|
555605
|
+
"",
|
|
555606
|
+
"Return JSON:",
|
|
555607
|
+
"{",
|
|
555608
|
+
' "inference": "concise user-facing task-impact inference",',
|
|
555609
|
+
' "runnerInstruction": "specific instruction for the next agent decision",',
|
|
555610
|
+
' "conflicts": ["optional conflict"],',
|
|
555611
|
+
' "alternatives": ["optional alternate reading"],',
|
|
555612
|
+
' "memoryNote": "optional durable lesson"',
|
|
555613
|
+
"}",
|
|
555614
|
+
"",
|
|
555615
|
+
`replacement: ${ingress.isReplacement ? "true" : "false"}`,
|
|
555616
|
+
`toolCallsSoFar: ${ingress.toolCallCount}`,
|
|
555617
|
+
"",
|
|
555618
|
+
"Current task goal:",
|
|
555619
|
+
truncateBlock(ingress.currentTaskGoal || "(unknown current task)", 1200),
|
|
555620
|
+
"",
|
|
555621
|
+
"Recent activity:",
|
|
555622
|
+
truncateBlock(ingress.recentActivity || "(no recent activity recorded)", 1200),
|
|
555623
|
+
"",
|
|
555624
|
+
ingress.filesTouched.length > 0 ? `Files touched so far: ${ingress.filesTouched.join(", ")}` : "Files touched so far: none recorded",
|
|
555625
|
+
"",
|
|
555626
|
+
RAW_START,
|
|
555627
|
+
ingress.rawText,
|
|
555628
|
+
RAW_END
|
|
555629
|
+
].join("\n");
|
|
555630
|
+
}
|
|
555631
|
+
function parseSteeringInterpretation(raw) {
|
|
555632
|
+
const candidate = extractJsonObject(raw);
|
|
555633
|
+
if (!candidate)
|
|
555634
|
+
return null;
|
|
555635
|
+
try {
|
|
555636
|
+
const parsed = SteeringInterpretationSchema.parse(JSON.parse(candidate));
|
|
555637
|
+
return {
|
|
555638
|
+
inference: parsed.inference,
|
|
555639
|
+
runnerInstruction: parsed.runnerInstruction,
|
|
555640
|
+
conflicts: parsed.conflicts,
|
|
555641
|
+
alternatives: parsed.alternatives,
|
|
555642
|
+
memoryNote: parsed.memoryNote
|
|
555643
|
+
};
|
|
555644
|
+
} catch {
|
|
555645
|
+
return null;
|
|
555558
555646
|
}
|
|
555559
|
-
return lines.join("\n");
|
|
555560
555647
|
}
|
|
555561
|
-
|
|
555562
|
-
|
|
555563
|
-
|
|
555648
|
+
function extractJsonObject(raw) {
|
|
555649
|
+
const text2 = raw.trim();
|
|
555650
|
+
if (!text2)
|
|
555651
|
+
return null;
|
|
555652
|
+
try {
|
|
555653
|
+
JSON.parse(text2);
|
|
555654
|
+
return text2;
|
|
555655
|
+
} catch {
|
|
555564
555656
|
}
|
|
555565
|
-
|
|
555566
|
-
|
|
555567
|
-
|
|
555568
|
-
|
|
555569
|
-
|
|
555570
|
-
|
|
555571
|
-
|
|
555657
|
+
let start2 = -1;
|
|
555658
|
+
let depth = 0;
|
|
555659
|
+
let inString = false;
|
|
555660
|
+
let escaped = false;
|
|
555661
|
+
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
555662
|
+
const ch = text2[i2];
|
|
555663
|
+
if (inString) {
|
|
555664
|
+
if (escaped) {
|
|
555665
|
+
escaped = false;
|
|
555666
|
+
} else if (ch === "\\") {
|
|
555667
|
+
escaped = true;
|
|
555668
|
+
} else if (ch === '"') {
|
|
555669
|
+
inString = false;
|
|
555670
|
+
}
|
|
555671
|
+
continue;
|
|
555672
|
+
}
|
|
555673
|
+
if (ch === '"') {
|
|
555674
|
+
inString = true;
|
|
555675
|
+
continue;
|
|
555676
|
+
}
|
|
555677
|
+
if (ch === "{") {
|
|
555678
|
+
if (depth === 0)
|
|
555679
|
+
start2 = i2;
|
|
555680
|
+
depth++;
|
|
555681
|
+
continue;
|
|
555682
|
+
}
|
|
555683
|
+
if (ch === "}") {
|
|
555684
|
+
depth--;
|
|
555685
|
+
if (depth === 0 && start2 >= 0)
|
|
555686
|
+
return text2.slice(start2, i2 + 1);
|
|
555687
|
+
if (depth < 0) {
|
|
555688
|
+
start2 = -1;
|
|
555689
|
+
depth = 0;
|
|
555690
|
+
}
|
|
555691
|
+
}
|
|
555692
|
+
}
|
|
555693
|
+
return null;
|
|
555572
555694
|
}
|
|
555573
|
-
function
|
|
555574
|
-
return
|
|
555695
|
+
function steeringInterpretationResponseFormat() {
|
|
555696
|
+
return { type: "json_object" };
|
|
555575
555697
|
}
|
|
555576
|
-
function
|
|
555577
|
-
|
|
555698
|
+
function readRecentSteeringEntries(repoRoot, limit) {
|
|
555699
|
+
try {
|
|
555700
|
+
const file = join91(repoRoot, ".omnius", "context", LEDGER_FILE);
|
|
555701
|
+
if (!existsSync79(file))
|
|
555702
|
+
return [];
|
|
555703
|
+
const lines = readFileSync60(file, "utf-8").split("\n").filter(Boolean).slice(-100);
|
|
555704
|
+
const parsedEntries = [];
|
|
555705
|
+
for (const line of lines) {
|
|
555706
|
+
try {
|
|
555707
|
+
parsedEntries.push(JSON.parse(line));
|
|
555708
|
+
} catch {
|
|
555709
|
+
}
|
|
555710
|
+
}
|
|
555711
|
+
const latestOutcomes = /* @__PURE__ */ new Map();
|
|
555712
|
+
for (const entry of parsedEntries) {
|
|
555713
|
+
if (entry.type === "outcome")
|
|
555714
|
+
latestOutcomes.set(entry.packetId, entry);
|
|
555715
|
+
}
|
|
555716
|
+
const out = [];
|
|
555717
|
+
for (let i2 = parsedEntries.length - 1; i2 >= 0 && out.length < limit; i2--) {
|
|
555718
|
+
const parsed = parsedEntries[i2];
|
|
555719
|
+
if (parsed.type === "ingress") {
|
|
555720
|
+
const outcome = latestOutcomes.get(parsed.packetId);
|
|
555721
|
+
out.push(outcome ? { ...parsed, outcome: outcome.outcome, summary: outcome.summary } : parsed);
|
|
555722
|
+
}
|
|
555723
|
+
}
|
|
555724
|
+
return out;
|
|
555725
|
+
} catch {
|
|
555726
|
+
return [];
|
|
555727
|
+
}
|
|
555578
555728
|
}
|
|
555579
|
-
function
|
|
555580
|
-
const
|
|
555581
|
-
|
|
555582
|
-
|
|
555583
|
-
|
|
555584
|
-
|
|
555585
|
-
|
|
555729
|
+
function truncateBlock(value2, max) {
|
|
555730
|
+
const trimmed = value2.trim();
|
|
555731
|
+
if (trimmed.length <= max)
|
|
555732
|
+
return trimmed;
|
|
555733
|
+
return `${trimmed.slice(0, max).trimEnd()}
|
|
555734
|
+
...(truncated)`;
|
|
555735
|
+
}
|
|
555736
|
+
var STEERING_START, STEERING_END, RAW_START, RAW_END, LEDGER_FILE, SteeringInterpretationSchema;
|
|
555737
|
+
var init_steeringIntake = __esm({
|
|
555738
|
+
"packages/orchestrator/dist/steeringIntake.js"() {
|
|
555739
|
+
"use strict";
|
|
555740
|
+
STEERING_START = "[MID_TASK_STEERING_INTAKE v2]";
|
|
555741
|
+
STEERING_END = "[/MID_TASK_STEERING_INTAKE]";
|
|
555742
|
+
RAW_START = "<<<USER_ADDED_CONTEXT>>>";
|
|
555743
|
+
RAW_END = "<<<END_USER_ADDED_CONTEXT>>>";
|
|
555744
|
+
LEDGER_FILE = "steering-ledger.jsonl";
|
|
555745
|
+
SteeringInterpretationSchema = z16.object({
|
|
555746
|
+
inference: z16.string().trim().min(1),
|
|
555747
|
+
runnerInstruction: z16.string().trim().min(1),
|
|
555748
|
+
conflicts: z16.array(z16.string().trim().min(1)).optional().default([]),
|
|
555749
|
+
alternatives: z16.array(z16.string().trim().min(1)).optional().default([]),
|
|
555750
|
+
memoryNote: z16.string().trim().min(1).optional()
|
|
555751
|
+
});
|
|
555752
|
+
}
|
|
555753
|
+
});
|
|
555754
|
+
|
|
555755
|
+
// packages/orchestrator/dist/completionContract.js
|
|
555756
|
+
function normalizeText(value2, max = 500) {
|
|
555757
|
+
const text2 = String(value2 ?? "").trim().replace(/\s+/g, " ");
|
|
555758
|
+
return text2 ? text2.slice(0, max) : "";
|
|
555759
|
+
}
|
|
555760
|
+
function normalizeCompletionKey(value2, fallback = "item") {
|
|
555761
|
+
const key = String(value2 ?? fallback).trim().toLowerCase().replace(/[^a-z0-9_.:-]+/g, "_").replace(/_{2,}/g, "_").replace(/^[_:.-]+|[_:.-]+$/g, "").slice(0, 96);
|
|
555762
|
+
return key || fallback;
|
|
555763
|
+
}
|
|
555764
|
+
function genericField(key, label, description, acceptanceCriteria) {
|
|
555765
|
+
return {
|
|
555766
|
+
key: normalizeCompletionKey(key),
|
|
555767
|
+
label,
|
|
555768
|
+
fieldType: "json",
|
|
555769
|
+
elevation: "required",
|
|
555770
|
+
sourceMode: "derived",
|
|
555771
|
+
description,
|
|
555772
|
+
acceptanceCriteria
|
|
555773
|
+
};
|
|
555774
|
+
}
|
|
555775
|
+
function inferCompletionContract(taskText) {
|
|
555776
|
+
const goalSummary = normalizeText(taskText);
|
|
555777
|
+
const fields = [
|
|
555778
|
+
genericField("claims.evidence_map", "Claim evidence map", "A run-local mapping from each final claim to the observed result that supports it.", "Each material claim is either backed by observed evidence from this run or named as unverified/blocked."),
|
|
555779
|
+
genericField("claims.unverified", "Unverified claims", "Claims that could not be proven from the run's observations.", "Unverified claims are not presented as completed work.")
|
|
555780
|
+
];
|
|
555781
|
+
const phases = [
|
|
555782
|
+
{
|
|
555783
|
+
key: "execute",
|
|
555784
|
+
label: "Execute",
|
|
555785
|
+
instructions: "Do the requested work while preserving observations needed to evaluate the result.",
|
|
555786
|
+
requirementIds: [],
|
|
555787
|
+
fields: [],
|
|
555788
|
+
gate: {
|
|
555789
|
+
key: "execution_trace",
|
|
555790
|
+
instructions: "Keep enough concrete run output to distinguish facts from assumptions."
|
|
555791
|
+
}
|
|
555792
|
+
},
|
|
555793
|
+
{
|
|
555794
|
+
key: "verify",
|
|
555795
|
+
label: "Verify",
|
|
555796
|
+
instructions: "Derive the needed evidence from the actual request and final claims, then compare those claims to observed results.",
|
|
555797
|
+
requirementIds: [],
|
|
555798
|
+
fields,
|
|
555799
|
+
gate: {
|
|
555800
|
+
key: "claim_evidence_review",
|
|
555801
|
+
instructions: "Judge whether the actual claim is supported by the actual observations."
|
|
555802
|
+
}
|
|
555803
|
+
},
|
|
555804
|
+
{
|
|
555805
|
+
key: "deliver",
|
|
555806
|
+
label: "Deliver",
|
|
555807
|
+
instructions: "Report completed, verified, unverified, and blocked items without overstating what was observed.",
|
|
555808
|
+
requirementIds: [],
|
|
555809
|
+
fields: [],
|
|
555810
|
+
gate: {
|
|
555811
|
+
key: "result_readback",
|
|
555812
|
+
instructions: "Final wording must not exceed the observed evidence."
|
|
555813
|
+
}
|
|
555814
|
+
}
|
|
555815
|
+
];
|
|
555816
|
+
return {
|
|
555817
|
+
goalSummary,
|
|
555818
|
+
surfaces: [],
|
|
555819
|
+
fields,
|
|
555820
|
+
requirements: [],
|
|
555821
|
+
phases,
|
|
555822
|
+
acceptanceCriteria: [
|
|
555823
|
+
"The final response distinguishes completed work from verified evidence and unverified or blocked claims."
|
|
555824
|
+
]
|
|
555825
|
+
};
|
|
555826
|
+
}
|
|
555827
|
+
function inferCompletionContractFromTexts(texts, fallbackSummary = "") {
|
|
555828
|
+
const combined = texts.map((text2) => String(text2 ?? "").trim()).filter(Boolean).join("\n\n");
|
|
555829
|
+
return inferCompletionContract(combined || fallbackSummary);
|
|
555830
|
+
}
|
|
555831
|
+
function clip2(value2, max = 500) {
|
|
555832
|
+
return normalizeText(value2, max);
|
|
555833
|
+
}
|
|
555834
|
+
function listLines(items, empty2 = "- none observed") {
|
|
555835
|
+
return items.length > 0 ? items.map((item) => `- ${item}`) : [empty2];
|
|
555836
|
+
}
|
|
555837
|
+
function formatEvidenceEntry(entry) {
|
|
555838
|
+
const parts = [
|
|
555839
|
+
entry.success === true ? "ok" : entry.success === false ? "failed" : "unknown",
|
|
555840
|
+
entry.name ? `tool=${clip2(entry.name, 80)}` : "",
|
|
555841
|
+
typeof entry.turn === "number" ? `turn=${entry.turn}` : "",
|
|
555842
|
+
entry.mutated ? "mutated=true" : "",
|
|
555843
|
+
entry.argsKey ? `args=${clip2(entry.argsKey, 180)}` : "",
|
|
555844
|
+
entry.outputPreview ? `observed=${clip2(entry.outputPreview, 260)}` : ""
|
|
555845
|
+
].filter(Boolean);
|
|
555846
|
+
return parts.join(" ");
|
|
555847
|
+
}
|
|
555848
|
+
function deriveScenarioSeed(input) {
|
|
555849
|
+
const text2 = [
|
|
555850
|
+
input.taskText,
|
|
555851
|
+
input.contract.goalSummary,
|
|
555852
|
+
input.proposedSummary,
|
|
555853
|
+
input.answerText
|
|
555854
|
+
].map((part) => String(part ?? "").trim()).filter(Boolean).join("\n");
|
|
555855
|
+
const normalized = normalizeCompletionKey(text2.slice(0, 140), "completion_scenario");
|
|
555856
|
+
return normalized || "completion_scenario";
|
|
555857
|
+
}
|
|
555858
|
+
function buildCompletionScenarioDecomposition(input) {
|
|
555859
|
+
const proposedClaimText = [
|
|
555860
|
+
input.proposedSummary ? `task_complete summary:
|
|
555861
|
+
${String(input.proposedSummary).trim()}` : "",
|
|
555862
|
+
input.answerText ? `assistant visible answer:
|
|
555863
|
+
${String(input.answerText).trim()}` : ""
|
|
555864
|
+
].filter(Boolean).join("\n\n").slice(0, 4e3);
|
|
555865
|
+
const observedEvidence = (input.log ?? []).slice(-40).map(formatEvidenceEntry);
|
|
555866
|
+
const unresolvedSignals = [
|
|
555867
|
+
...(input.openLoops ?? []).map((item) => `open loop: ${clip2(item, 260)}`),
|
|
555868
|
+
...(input.recentFailures ?? []).map((item) => `recent failure: ${clip2(item, 260)}`),
|
|
555869
|
+
...(input.planStatus ?? []).filter((item) => item.status || item.reconciled || item.rationale).map((item) => {
|
|
555870
|
+
const state = [item.status, item.reconciled].filter(Boolean).join("/");
|
|
555871
|
+
const suffix = item.rationale ? ` (${clip2(item.rationale, 180)})` : "";
|
|
555872
|
+
return `plan ${state || "observed"}: ${clip2(item.content, 220)}${suffix}`;
|
|
555873
|
+
})
|
|
555874
|
+
];
|
|
555875
|
+
const modifiedFiles = (input.modifiedFiles ?? []).slice(0, 30).map((file) => {
|
|
555876
|
+
const meta = [
|
|
555877
|
+
file.status ? `status=${clip2(file.status, 40)}` : "",
|
|
555878
|
+
typeof file.bytes === "number" ? `bytes=${file.bytes}` : ""
|
|
555879
|
+
].filter(Boolean).join(" ");
|
|
555880
|
+
return `${clip2(file.path, 220)}${meta ? ` (${meta})` : ""}`;
|
|
555881
|
+
});
|
|
555882
|
+
const scenarioSeed = deriveScenarioSeed(input);
|
|
555883
|
+
const lines = [];
|
|
555884
|
+
lines.push(`[COMPLETION META-DECOMPOSITION]`);
|
|
555885
|
+
lines.push(`Scenario seed: ${scenarioSeed}`);
|
|
555886
|
+
lines.push(``);
|
|
555887
|
+
lines.push(`Original request / goal text:`);
|
|
555888
|
+
lines.push(clip2(input.taskText || input.contract.goalSummary, 1200) || "(not provided)");
|
|
555889
|
+
lines.push(``);
|
|
555890
|
+
lines.push(`Proposed completion claim text:`);
|
|
555891
|
+
lines.push(proposedClaimText || "(no proposed completion text yet)");
|
|
555892
|
+
lines.push(``);
|
|
555893
|
+
lines.push(`Observed run evidence:`);
|
|
555894
|
+
lines.push(...listLines(observedEvidence, "- no tool evidence recorded"));
|
|
555895
|
+
lines.push(``);
|
|
555896
|
+
lines.push(`Unresolved or caution signals:`);
|
|
555897
|
+
lines.push(...listLines(unresolvedSignals, "- none recorded"));
|
|
555898
|
+
lines.push(``);
|
|
555899
|
+
lines.push(`Modified artifact digest:`);
|
|
555900
|
+
lines.push(...listLines(modifiedFiles, "- no modified artifacts listed"));
|
|
555901
|
+
lines.push(``);
|
|
555902
|
+
lines.push(`Reviewer decomposition task:`);
|
|
555903
|
+
lines.push(`- Invent a situation-specific completion scenario from the request, proposed claims, and observed run data above.`);
|
|
555904
|
+
lines.push(`- Enumerate the material claims in the proposed completion text, including implied claims about created state, external effects, recipient-visible outcomes, runtime behavior, research facts, or absence of blockers when those claims appear in the text.`);
|
|
555905
|
+
lines.push(`- For each claim, derive what would make it true from the claim's semantics, the user's request, and this run's observations.`);
|
|
555906
|
+
lines.push(`- Map the claim to the observed evidence, contradictions, missing observations, and unresolved loops shown above.`);
|
|
555907
|
+
lines.push(`- If an unsupported claim is material, propose the smallest next observation or correction; if the final wording already marks it unverified or blocked, treat that honesty as part of the evidence review.`);
|
|
555908
|
+
return {
|
|
555909
|
+
scenarioSeed,
|
|
555910
|
+
prompt: lines.join("\n"),
|
|
555911
|
+
proposedClaimText,
|
|
555912
|
+
observedEvidence,
|
|
555913
|
+
unresolvedSignals
|
|
555914
|
+
};
|
|
555915
|
+
}
|
|
555916
|
+
function formatCompletionContract(contract, scenario) {
|
|
555917
|
+
const lines = [];
|
|
555918
|
+
lines.push(`[COMPLETION CONTRACT]`);
|
|
555919
|
+
lines.push(`Goal: ${contract.goalSummary || "(no goal text)"}`);
|
|
555920
|
+
lines.push(``);
|
|
555921
|
+
lines.push(`Completion review policy:`);
|
|
555922
|
+
lines.push(`- Derive material claims from the current request and proposed final answer.`);
|
|
555923
|
+
lines.push(`- Compare those claims to observed tool results from this run.`);
|
|
555924
|
+
lines.push(`- Treat missing, ambiguous, or failed observations as unverified rather than complete.`);
|
|
555925
|
+
lines.push(`- Use the current request, proposed claims, and recorded observations as the source of truth.`);
|
|
555926
|
+
lines.push(``);
|
|
555927
|
+
lines.push(`Flow: execute -> scenario decomposition -> evidence review -> delivery readback.`);
|
|
555928
|
+
if (scenario) {
|
|
555929
|
+
lines.push(``);
|
|
555930
|
+
lines.push(buildCompletionScenarioDecomposition({ contract, ...scenario }).prompt);
|
|
555931
|
+
}
|
|
555932
|
+
return lines.join("\n");
|
|
555933
|
+
}
|
|
555934
|
+
var init_completionContract = __esm({
|
|
555935
|
+
"packages/orchestrator/dist/completionContract.js"() {
|
|
555936
|
+
"use strict";
|
|
555937
|
+
}
|
|
555938
|
+
});
|
|
555939
|
+
|
|
555940
|
+
// packages/orchestrator/dist/completionLedger.js
|
|
555941
|
+
import { mkdirSync as mkdirSync46, readFileSync as readFileSync61, writeFileSync as writeFileSync38 } from "node:fs";
|
|
555942
|
+
import { dirname as dirname27 } from "node:path";
|
|
555943
|
+
function nowIso2(now2 = /* @__PURE__ */ new Date()) {
|
|
555944
|
+
return now2 instanceof Date ? now2.toISOString() : new Date(now2).toISOString();
|
|
555945
|
+
}
|
|
555946
|
+
function cleanText(value2, max = 600) {
|
|
555947
|
+
return String(value2 ?? "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
555948
|
+
}
|
|
555949
|
+
function nextId2(prefix, count) {
|
|
555950
|
+
return `${prefix}_${String(count + 1).padStart(4, "0")}`;
|
|
555951
|
+
}
|
|
555952
|
+
function createCompletionLedger(input) {
|
|
555953
|
+
const ts = nowIso2(input.now);
|
|
555954
|
+
return {
|
|
555955
|
+
runId: input.runId,
|
|
555956
|
+
goal: cleanText(input.goal, 2e3),
|
|
555957
|
+
createdAtIso: ts,
|
|
555958
|
+
updatedAtIso: ts,
|
|
555586
555959
|
proposedClaims: [],
|
|
555587
555960
|
evidence: [],
|
|
555588
555961
|
critiques: [],
|
|
@@ -555750,12 +556123,12 @@ function buildCriticPacketFromLedger(ledger) {
|
|
|
555750
556123
|
return lines.join("\n");
|
|
555751
556124
|
}
|
|
555752
556125
|
function saveCompletionLedger(filePath, ledger) {
|
|
555753
|
-
|
|
556126
|
+
mkdirSync46(dirname27(filePath), { recursive: true });
|
|
555754
556127
|
writeFileSync38(filePath, `${JSON.stringify(ledger, null, 2)}
|
|
555755
556128
|
`, "utf8");
|
|
555756
556129
|
}
|
|
555757
556130
|
function loadCompletionLedger(filePath) {
|
|
555758
|
-
return JSON.parse(
|
|
556131
|
+
return JSON.parse(readFileSync61(filePath, "utf8"));
|
|
555759
556132
|
}
|
|
555760
556133
|
var init_completionLedger = __esm({
|
|
555761
556134
|
"packages/orchestrator/dist/completionLedger.js"() {
|
|
@@ -556423,9 +556796,9 @@ var init_ollama_pool_cleanup = __esm({
|
|
|
556423
556796
|
|
|
556424
556797
|
// packages/orchestrator/dist/ollama-pool.js
|
|
556425
556798
|
import { spawn as spawn24, exec as exec2 } from "node:child_process";
|
|
556426
|
-
import { existsSync as
|
|
556799
|
+
import { existsSync as existsSync80, readFileSync as readFileSync62, readdirSync as readdirSync24, statfsSync as statfsSync3, statSync as statSync29 } from "node:fs";
|
|
556427
556800
|
import { homedir as homedir30 } from "node:os";
|
|
556428
|
-
import { join as
|
|
556801
|
+
import { join as join92 } from "node:path";
|
|
556429
556802
|
import { createServer as createServer3 } from "node:net";
|
|
556430
556803
|
import { EventEmitter as EventEmitter5 } from "node:events";
|
|
556431
556804
|
function discoverSystemOllamaModelStore() {
|
|
@@ -556438,7 +556811,7 @@ function discoverSystemOllamaModelStore() {
|
|
|
556438
556811
|
const candidates = [
|
|
556439
556812
|
"/usr/share/ollama/.ollama/models",
|
|
556440
556813
|
"/var/lib/ollama/.ollama/models",
|
|
556441
|
-
|
|
556814
|
+
join92(homedir30(), ".ollama", "models")
|
|
556442
556815
|
];
|
|
556443
556816
|
for (const p2 of candidates) {
|
|
556444
556817
|
if (isDirectory(p2))
|
|
@@ -556448,7 +556821,7 @@ function discoverSystemOllamaModelStore() {
|
|
|
556448
556821
|
}
|
|
556449
556822
|
function isDirectory(path12) {
|
|
556450
556823
|
try {
|
|
556451
|
-
return
|
|
556824
|
+
return existsSync80(path12) && statSync29(path12).isDirectory();
|
|
556452
556825
|
} catch {
|
|
556453
556826
|
return false;
|
|
556454
556827
|
}
|
|
@@ -556462,7 +556835,7 @@ function discoverOllamaModelStoreFromProc() {
|
|
|
556462
556835
|
return envStore;
|
|
556463
556836
|
const home = inferHomeFromProcUid(pid);
|
|
556464
556837
|
if (home) {
|
|
556465
|
-
const inferred =
|
|
556838
|
+
const inferred = join92(home, ".ollama", "models");
|
|
556466
556839
|
if (isDirectory(inferred))
|
|
556467
556840
|
return inferred;
|
|
556468
556841
|
}
|
|
@@ -556473,7 +556846,7 @@ function listOllamaPids() {
|
|
|
556473
556846
|
try {
|
|
556474
556847
|
return readdirSync24("/proc", { withFileTypes: true }).filter((d2) => d2.isDirectory() && /^\d+$/.test(d2.name)).map((d2) => d2.name).filter((pid) => {
|
|
556475
556848
|
try {
|
|
556476
|
-
const comm =
|
|
556849
|
+
const comm = readFileSync62(`/proc/${pid}/comm`, "utf8").trim();
|
|
556477
556850
|
return comm === "ollama";
|
|
556478
556851
|
} catch {
|
|
556479
556852
|
return false;
|
|
@@ -556485,7 +556858,7 @@ function listOllamaPids() {
|
|
|
556485
556858
|
}
|
|
556486
556859
|
function readProcEnvValue(pid, key) {
|
|
556487
556860
|
try {
|
|
556488
|
-
const raw =
|
|
556861
|
+
const raw = readFileSync62(`/proc/${pid}/environ`, "utf8");
|
|
556489
556862
|
for (const entry of raw.split("\0")) {
|
|
556490
556863
|
const idx = entry.indexOf("=");
|
|
556491
556864
|
if (idx <= 0)
|
|
@@ -556501,11 +556874,11 @@ function readProcEnvValue(pid, key) {
|
|
|
556501
556874
|
}
|
|
556502
556875
|
function inferHomeFromProcUid(pid) {
|
|
556503
556876
|
try {
|
|
556504
|
-
const status =
|
|
556877
|
+
const status = readFileSync62(`/proc/${pid}/status`, "utf8");
|
|
556505
556878
|
const uid = status.match(/^Uid:\s+(\d+)/m)?.[1];
|
|
556506
556879
|
if (!uid)
|
|
556507
556880
|
return null;
|
|
556508
|
-
const passwd =
|
|
556881
|
+
const passwd = readFileSync62("/etc/passwd", "utf8");
|
|
556509
556882
|
for (const line of passwd.split("\n")) {
|
|
556510
556883
|
const parts = line.split(":");
|
|
556511
556884
|
if (parts.length >= 7 && parts[2] === uid)
|
|
@@ -556531,7 +556904,7 @@ function detectPeerOmniusOllamaPool() {
|
|
|
556531
556904
|
if (e2.name === selfPid || e2.name === selfPpid)
|
|
556532
556905
|
continue;
|
|
556533
556906
|
try {
|
|
556534
|
-
const cmdline =
|
|
556907
|
+
const cmdline = readFileSync62(`/proc/${e2.name}/cmdline`, "utf8");
|
|
556535
556908
|
if (!cmdline.includes("node"))
|
|
556536
556909
|
continue;
|
|
556537
556910
|
if (!/[/\\]omnius[/\\]dist[/\\]index\.js|[/\\]omnius[/\\]/i.test(cmdline))
|
|
@@ -556544,12 +556917,12 @@ function detectPeerOmniusOllamaPool() {
|
|
|
556544
556917
|
return false;
|
|
556545
556918
|
for (const e2 of entries) {
|
|
556546
556919
|
try {
|
|
556547
|
-
const cmd =
|
|
556920
|
+
const cmd = readFileSync62(`/proc/${e2.name}/cmdline`, "utf8");
|
|
556548
556921
|
if (!cmd.includes("ollama"))
|
|
556549
556922
|
continue;
|
|
556550
556923
|
if (!cmd.split("\0").includes("serve"))
|
|
556551
556924
|
continue;
|
|
556552
|
-
const status =
|
|
556925
|
+
const status = readFileSync62(`/proc/${e2.name}/status`, "utf8");
|
|
556553
556926
|
const ppid = status.match(/^PPid:\s+(\d+)/m)?.[1];
|
|
556554
556927
|
if (ppid && peerNodePids.has(ppid))
|
|
556555
556928
|
return true;
|
|
@@ -556680,7 +557053,7 @@ function snapshotDisk(path12) {
|
|
|
556680
557053
|
}
|
|
556681
557054
|
function snapshotNetwork() {
|
|
556682
557055
|
try {
|
|
556683
|
-
const raw =
|
|
557056
|
+
const raw = readFileSync62("/proc/net/dev", "utf8");
|
|
556684
557057
|
let rxBytes = 0;
|
|
556685
557058
|
let txBytes = 0;
|
|
556686
557059
|
for (const line of raw.split("\n")) {
|
|
@@ -558163,7 +558536,7 @@ var init_mast_tagger = __esm({
|
|
|
558163
558536
|
});
|
|
558164
558537
|
|
|
558165
558538
|
// packages/orchestrator/dist/artifact-inspector.js
|
|
558166
|
-
import { existsSync as
|
|
558539
|
+
import { existsSync as existsSync81, statSync as statSync30 } from "node:fs";
|
|
558167
558540
|
import { isAbsolute as isAbsolute5, resolve as resolve47 } from "node:path";
|
|
558168
558541
|
function extractCandidatePaths(content) {
|
|
558169
558542
|
const out = /* @__PURE__ */ new Set();
|
|
@@ -558189,7 +558562,7 @@ function inspectClaimedArtifacts(input) {
|
|
|
558189
558562
|
const stale = [];
|
|
558190
558563
|
for (const p2 of candidates) {
|
|
558191
558564
|
const resolved = resolveAgainstWorkingDir(input.workingDir, p2);
|
|
558192
|
-
if (!
|
|
558565
|
+
if (!existsSync81(resolved)) {
|
|
558193
558566
|
missing.push(p2);
|
|
558194
558567
|
continue;
|
|
558195
558568
|
}
|
|
@@ -558259,8 +558632,8 @@ var init_artifact_inspector = __esm({
|
|
|
558259
558632
|
});
|
|
558260
558633
|
|
|
558261
558634
|
// packages/orchestrator/dist/lesson-bank.js
|
|
558262
|
-
import { existsSync as
|
|
558263
|
-
import { join as
|
|
558635
|
+
import { existsSync as existsSync82, mkdirSync as mkdirSync47, appendFileSync as appendFileSync5, readFileSync as readFileSync63 } from "node:fs";
|
|
558636
|
+
import { join as join93, dirname as dirname28 } from "node:path";
|
|
558264
558637
|
import { createHash as createHash25 } from "node:crypto";
|
|
558265
558638
|
function tokenize4(text2) {
|
|
558266
558639
|
if (!text2)
|
|
@@ -558292,20 +558665,20 @@ function solicit(args) {
|
|
|
558292
558665
|
};
|
|
558293
558666
|
}
|
|
558294
558667
|
function lessonBankPath(workingDir) {
|
|
558295
|
-
const base3 = workingDir ?
|
|
558296
|
-
return
|
|
558668
|
+
const base3 = workingDir ? join93(workingDir, ".omnius", "lessons") : join93(process.env["HOME"] || ".", ".omnius", "lessons");
|
|
558669
|
+
return join93(base3, "lessons.jsonl");
|
|
558297
558670
|
}
|
|
558298
558671
|
function bank(lesson, workingDir) {
|
|
558299
558672
|
const path12 = lessonBankPath(workingDir);
|
|
558300
|
-
|
|
558301
|
-
|
|
558673
|
+
mkdirSync47(dirname28(path12), { recursive: true });
|
|
558674
|
+
appendFileSync5(path12, JSON.stringify(lesson) + "\n", "utf-8");
|
|
558302
558675
|
}
|
|
558303
558676
|
function readAll(workingDir) {
|
|
558304
558677
|
const path12 = lessonBankPath(workingDir);
|
|
558305
|
-
if (!
|
|
558678
|
+
if (!existsSync82(path12))
|
|
558306
558679
|
return [];
|
|
558307
558680
|
try {
|
|
558308
|
-
const raw =
|
|
558681
|
+
const raw = readFileSync63(path12, "utf-8");
|
|
558309
558682
|
const out = [];
|
|
558310
558683
|
for (const line of raw.split(/\r?\n/)) {
|
|
558311
558684
|
const trimmed = line.trim();
|
|
@@ -558362,13 +558735,13 @@ var init_lesson_bank = __esm({
|
|
|
558362
558735
|
});
|
|
558363
558736
|
|
|
558364
558737
|
// packages/orchestrator/dist/intervention-replay.js
|
|
558365
|
-
import { existsSync as
|
|
558366
|
-
import { join as
|
|
558738
|
+
import { existsSync as existsSync83, mkdirSync as mkdirSync48, readFileSync as readFileSync64, writeFileSync as writeFileSync39, readdirSync as readdirSync25 } from "node:fs";
|
|
558739
|
+
import { join as join94, dirname as dirname29 } from "node:path";
|
|
558367
558740
|
function checkpointDir2(workingDir) {
|
|
558368
|
-
return workingDir ?
|
|
558741
|
+
return workingDir ? join94(workingDir, ".omnius", "checkpoints") : join94(process.env["HOME"] || ".", ".omnius", "checkpoints");
|
|
558369
558742
|
}
|
|
558370
558743
|
function checkpointPath(workingDir, turn) {
|
|
558371
|
-
return
|
|
558744
|
+
return join94(checkpointDir2(workingDir), `turn-${String(turn).padStart(4, "0")}.json`);
|
|
558372
558745
|
}
|
|
558373
558746
|
function writeCheckpoint(args) {
|
|
558374
558747
|
try {
|
|
@@ -558380,7 +558753,7 @@ function writeCheckpoint(args) {
|
|
|
558380
558753
|
notes: args.notes
|
|
558381
558754
|
};
|
|
558382
558755
|
const path12 = checkpointPath(args.workingDir, args.turn);
|
|
558383
|
-
|
|
558756
|
+
mkdirSync48(dirname29(path12), { recursive: true });
|
|
558384
558757
|
writeFileSync39(path12, JSON.stringify(snap), "utf-8");
|
|
558385
558758
|
} catch {
|
|
558386
558759
|
}
|
|
@@ -558388,7 +558761,7 @@ function writeCheckpoint(args) {
|
|
|
558388
558761
|
function listCheckpoints(workingDir) {
|
|
558389
558762
|
try {
|
|
558390
558763
|
const dir = checkpointDir2(workingDir);
|
|
558391
|
-
if (!
|
|
558764
|
+
if (!existsSync83(dir))
|
|
558392
558765
|
return [];
|
|
558393
558766
|
return readdirSync25(dir).map((f2) => f2.match(/^turn-(\d+)\.json$/)).filter((m2) => m2 !== null).map((m2) => parseInt(m2[1], 10)).filter((n2) => !Number.isNaN(n2)).sort((a2, b) => a2 - b);
|
|
558394
558767
|
} catch {
|
|
@@ -558404,7 +558777,7 @@ function pruneOldCheckpoints(args) {
|
|
|
558404
558777
|
for (const t2 of toRemove) {
|
|
558405
558778
|
try {
|
|
558406
558779
|
const path12 = checkpointPath(args.workingDir, t2);
|
|
558407
|
-
if (
|
|
558780
|
+
if (existsSync83(path12)) {
|
|
558408
558781
|
const fs11 = __require("node:fs");
|
|
558409
558782
|
fs11.unlinkSync(path12);
|
|
558410
558783
|
removed++;
|
|
@@ -558421,13 +558794,13 @@ var init_intervention_replay = __esm({
|
|
|
558421
558794
|
});
|
|
558422
558795
|
|
|
558423
558796
|
// packages/orchestrator/dist/world-state-disk-scan.js
|
|
558424
|
-
import { existsSync as
|
|
558425
|
-
import { join as
|
|
558797
|
+
import { existsSync as existsSync84, readFileSync as readFileSync65, readdirSync as readdirSync26, statSync as statSync31 } from "node:fs";
|
|
558798
|
+
import { join as join95, relative as relative8, basename as basename20 } from "node:path";
|
|
558426
558799
|
function loadIgnoreFile(path12) {
|
|
558427
|
-
if (!
|
|
558800
|
+
if (!existsSync84(path12))
|
|
558428
558801
|
return [];
|
|
558429
558802
|
try {
|
|
558430
|
-
const lines =
|
|
558803
|
+
const lines = readFileSync65(path12, "utf-8").split(/\r?\n/);
|
|
558431
558804
|
const out = [];
|
|
558432
558805
|
for (const raw of lines) {
|
|
558433
558806
|
const line = raw.trim();
|
|
@@ -558469,7 +558842,7 @@ function scanWorkspace(opts) {
|
|
|
558469
558842
|
if (!noDefaults)
|
|
558470
558843
|
patterns.push(...UNIVERSAL_DEFAULTS);
|
|
558471
558844
|
if (!noGitignore)
|
|
558472
|
-
patterns.push(...loadIgnoreFile(
|
|
558845
|
+
patterns.push(...loadIgnoreFile(join95(root, ".gitignore")));
|
|
558473
558846
|
if (opts.extraIgnore)
|
|
558474
558847
|
patterns.push(...opts.extraIgnore);
|
|
558475
558848
|
const files = [];
|
|
@@ -558500,7 +558873,7 @@ function scanWorkspace(opts) {
|
|
|
558500
558873
|
truncated = true;
|
|
558501
558874
|
break;
|
|
558502
558875
|
}
|
|
558503
|
-
const abs =
|
|
558876
|
+
const abs = join95(dir, entry);
|
|
558504
558877
|
const rel = relative8(root, abs);
|
|
558505
558878
|
const base3 = basename20(abs);
|
|
558506
558879
|
if (shouldIgnore(rel, base3, patterns))
|
|
@@ -558588,8 +558961,8 @@ var init_world_state_disk_scan = __esm({
|
|
|
558588
558961
|
});
|
|
558589
558962
|
|
|
558590
558963
|
// packages/orchestrator/dist/world-state-plan-reconciler.js
|
|
558591
|
-
import { existsSync as
|
|
558592
|
-
import { isAbsolute as isAbsolute6, join as
|
|
558964
|
+
import { existsSync as existsSync85, statSync as statSync32 } from "node:fs";
|
|
558965
|
+
import { isAbsolute as isAbsolute6, join as join96 } from "node:path";
|
|
558593
558966
|
function tokenize5(content) {
|
|
558594
558967
|
const STOP2 = /* @__PURE__ */ new Set([
|
|
558595
558968
|
"the",
|
|
@@ -558671,7 +559044,7 @@ function reconcileTodo(todo, files, opts) {
|
|
|
558671
559044
|
let anyMissing = false;
|
|
558672
559045
|
let anyEmpty = false;
|
|
558673
559046
|
for (const p2 of declared) {
|
|
558674
|
-
const abs = isAbsolute6(p2) ? p2 :
|
|
559047
|
+
const abs = isAbsolute6(p2) ? p2 : join96(opts.workingDir, p2);
|
|
558675
559048
|
let st = null;
|
|
558676
559049
|
try {
|
|
558677
559050
|
st = statSync32(abs);
|
|
@@ -558679,7 +559052,7 @@ function reconcileTodo(todo, files, opts) {
|
|
|
558679
559052
|
st = null;
|
|
558680
559053
|
}
|
|
558681
559054
|
if (!st) {
|
|
558682
|
-
if (!
|
|
559055
|
+
if (!existsSync85(abs)) {
|
|
558683
559056
|
checks.push({ path: p2, ok: false, reason: "missing" });
|
|
558684
559057
|
anyMissing = true;
|
|
558685
559058
|
allOk = false;
|
|
@@ -558777,8 +559150,8 @@ var init_world_state_plan_reconciler = __esm({
|
|
|
558777
559150
|
});
|
|
558778
559151
|
|
|
558779
559152
|
// packages/orchestrator/dist/world-state-drift-detector.js
|
|
558780
|
-
import { existsSync as
|
|
558781
|
-
import { dirname as dirname30, isAbsolute as isAbsolute7, join as
|
|
559153
|
+
import { existsSync as existsSync86, readFileSync as readFileSync66, statSync as statSync33 } from "node:fs";
|
|
559154
|
+
import { dirname as dirname30, isAbsolute as isAbsolute7, join as join97, resolve as pathResolve } from "node:path";
|
|
558782
559155
|
function parseImports(source) {
|
|
558783
559156
|
const out = [];
|
|
558784
559157
|
const lines = source.split(/\r?\n/);
|
|
@@ -558931,11 +559304,11 @@ function loadProjectAliases(workingDir) {
|
|
|
558931
559304
|
const configCandidates = ["tsconfig.json", "jsconfig.json"];
|
|
558932
559305
|
const aliases = {};
|
|
558933
559306
|
for (const name10 of configCandidates) {
|
|
558934
|
-
const path12 =
|
|
558935
|
-
if (!
|
|
559307
|
+
const path12 = join97(workingDir, name10);
|
|
559308
|
+
if (!existsSync86(path12))
|
|
558936
559309
|
continue;
|
|
558937
559310
|
try {
|
|
558938
|
-
const raw =
|
|
559311
|
+
const raw = readFileSync66(path12, "utf-8");
|
|
558939
559312
|
const parsed = JSON.parse(stripJsonComments(raw));
|
|
558940
559313
|
const co = parsed?.compilerOptions;
|
|
558941
559314
|
const paths = co?.paths;
|
|
@@ -558982,11 +559355,11 @@ function resolveImportPath2(importingFile, source, workingDir, aliases) {
|
|
|
558982
559355
|
for (const ext of FILE_EXTENSIONS)
|
|
558983
559356
|
candidates.push(base3 + ext);
|
|
558984
559357
|
for (const ext of FILE_EXTENSIONS)
|
|
558985
|
-
candidates.push(
|
|
559358
|
+
candidates.push(join97(base3, "index" + ext));
|
|
558986
559359
|
candidates.push(base3);
|
|
558987
559360
|
for (const c8 of candidates) {
|
|
558988
559361
|
try {
|
|
558989
|
-
if (
|
|
559362
|
+
if (existsSync86(c8) && statSync33(c8).isFile())
|
|
558990
559363
|
return c8;
|
|
558991
559364
|
} catch {
|
|
558992
559365
|
}
|
|
@@ -559024,7 +559397,7 @@ function detectDrift(files, opts) {
|
|
|
559024
559397
|
const exportsCache = /* @__PURE__ */ new Map();
|
|
559025
559398
|
const readSource = (path12) => {
|
|
559026
559399
|
try {
|
|
559027
|
-
const buf =
|
|
559400
|
+
const buf = readFileSync66(path12);
|
|
559028
559401
|
if (buf.length > maxBytes)
|
|
559029
559402
|
return buf.slice(0, maxBytes).toString("utf-8");
|
|
559030
559403
|
return buf.toString("utf-8");
|
|
@@ -559639,16 +560012,16 @@ var init_backward_pass_critic = __esm({
|
|
|
559639
560012
|
});
|
|
559640
560013
|
|
|
559641
560014
|
// packages/orchestrator/dist/backward-pass-runner.js
|
|
559642
|
-
import { existsSync as
|
|
560015
|
+
import { existsSync as existsSync87, readFileSync as readFileSync67, statSync as statSync34 } from "node:fs";
|
|
559643
560016
|
import { execSync as execSync45 } from "node:child_process";
|
|
559644
|
-
import { isAbsolute as isAbsolute8, join as
|
|
560017
|
+
import { isAbsolute as isAbsolute8, join as join98, relative as relative9 } from "node:path";
|
|
559645
560018
|
function collectDiff(opts) {
|
|
559646
560019
|
const cap = Math.max(1, opts.maxFiles);
|
|
559647
560020
|
if (opts.explicitFiles && opts.explicitFiles.length > 0) {
|
|
559648
560021
|
const files = [];
|
|
559649
560022
|
for (const p2 of opts.explicitFiles.slice(0, cap)) {
|
|
559650
|
-
const abs = isAbsolute8(p2) ? p2 :
|
|
559651
|
-
if (!
|
|
560023
|
+
const abs = isAbsolute8(p2) ? p2 : join98(opts.workingDir, p2);
|
|
560024
|
+
if (!existsSync87(abs))
|
|
559652
560025
|
continue;
|
|
559653
560026
|
let bytes = 0;
|
|
559654
560027
|
try {
|
|
@@ -559659,7 +560032,7 @@ function collectDiff(opts) {
|
|
|
559659
560032
|
}
|
|
559660
560033
|
return { files, strategy: "explicit" };
|
|
559661
560034
|
}
|
|
559662
|
-
if (
|
|
560035
|
+
if (existsSync87(join98(opts.workingDir, ".git"))) {
|
|
559663
560036
|
try {
|
|
559664
560037
|
const out = execSync45("git diff --name-status HEAD 2>/dev/null; git ls-files --others --exclude-standard 2>/dev/null", { cwd: opts.workingDir, encoding: "utf-8", maxBuffer: 4 * 1024 * 1024, stdio: ["ignore", "pipe", "ignore"] });
|
|
559665
560038
|
const files = [];
|
|
@@ -559676,9 +560049,9 @@ function collectDiff(opts) {
|
|
|
559676
560049
|
status = "added";
|
|
559677
560050
|
path12 = line.trim();
|
|
559678
560051
|
}
|
|
559679
|
-
const abs =
|
|
560052
|
+
const abs = join98(opts.workingDir, path12);
|
|
559680
560053
|
let bytes = 0;
|
|
559681
|
-
if (
|
|
560054
|
+
if (existsSync87(abs)) {
|
|
559682
560055
|
try {
|
|
559683
560056
|
bytes = statSync34(abs).size;
|
|
559684
560057
|
} catch {
|
|
@@ -559699,7 +560072,7 @@ function collectDiff(opts) {
|
|
|
559699
560072
|
}
|
|
559700
560073
|
function readPreview(absPath, maxBytes) {
|
|
559701
560074
|
try {
|
|
559702
|
-
const buf =
|
|
560075
|
+
const buf = readFileSync67(absPath);
|
|
559703
560076
|
if (buf.length === 0)
|
|
559704
560077
|
return "";
|
|
559705
560078
|
const sniff = buf.slice(0, Math.min(8192, buf.length));
|
|
@@ -559726,7 +560099,7 @@ async function runBackwardPass(opts) {
|
|
|
559726
560099
|
explicitFiles: opts.explicitFiles
|
|
559727
560100
|
});
|
|
559728
560101
|
const diff = collected.files.map((f2) => {
|
|
559729
|
-
const abs = isAbsolute8(f2.path) ? f2.path :
|
|
560102
|
+
const abs = isAbsolute8(f2.path) ? f2.path : join98(opts.workingDir, f2.path);
|
|
559730
560103
|
const preview = f2.status === "deleted" ? "(file deleted)" : readPreview(abs, maxFilePreviewBytes);
|
|
559731
560104
|
return { ...f2, preview };
|
|
559732
560105
|
});
|
|
@@ -562196,13 +562569,13 @@ var init_hooks2 = __esm({
|
|
|
562196
562569
|
});
|
|
562197
562570
|
|
|
562198
562571
|
// packages/orchestrator/dist/todo-context-chunker.js
|
|
562199
|
-
import { mkdirSync as
|
|
562200
|
-
import { join as
|
|
562572
|
+
import { mkdirSync as mkdirSync51, writeFileSync as writeFileSync42, readFileSync as readFileSync70, existsSync as existsSync90, readdirSync as readdirSync27 } from "node:fs";
|
|
562573
|
+
import { join as join101 } from "node:path";
|
|
562201
562574
|
function chunkDir(workingDir) {
|
|
562202
|
-
return
|
|
562575
|
+
return join101(workingDir, ".omnius", "todo-chunks");
|
|
562203
562576
|
}
|
|
562204
562577
|
function chunkPath(workingDir, todoId) {
|
|
562205
|
-
return
|
|
562578
|
+
return join101(chunkDir(workingDir), `${sanitizeId(todoId)}.json`);
|
|
562206
562579
|
}
|
|
562207
562580
|
function sanitizeId(id) {
|
|
562208
562581
|
return id.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 64);
|
|
@@ -562411,17 +562784,17 @@ async function runTodoChunker(opts) {
|
|
|
562411
562784
|
}
|
|
562412
562785
|
function persistTodoChunk(workingDir, chunk) {
|
|
562413
562786
|
const dir = chunkDir(workingDir);
|
|
562414
|
-
if (!
|
|
562415
|
-
|
|
562787
|
+
if (!existsSync90(dir)) {
|
|
562788
|
+
mkdirSync51(dir, { recursive: true });
|
|
562416
562789
|
}
|
|
562417
562790
|
writeFileSync42(chunkPath(workingDir, chunk.todoId), JSON.stringify(chunk, null, 2), "utf-8");
|
|
562418
562791
|
}
|
|
562419
562792
|
function loadTodoChunk(workingDir, todoId) {
|
|
562420
562793
|
const p2 = chunkPath(workingDir, todoId);
|
|
562421
|
-
if (!
|
|
562794
|
+
if (!existsSync90(p2))
|
|
562422
562795
|
return null;
|
|
562423
562796
|
try {
|
|
562424
|
-
return JSON.parse(
|
|
562797
|
+
return JSON.parse(readFileSync70(p2, "utf-8"));
|
|
562425
562798
|
} catch {
|
|
562426
562799
|
return null;
|
|
562427
562800
|
}
|
|
@@ -563442,10 +563815,26 @@ function signalFromBlock(kind, source, content, options2 = {}) {
|
|
|
563442
563815
|
metadata: options2.metadata
|
|
563443
563816
|
};
|
|
563444
563817
|
}
|
|
563445
|
-
var KIND_ORDER, KIND_LABELS, DEFAULT_KIND_CHAR_BUDGET, URL_RE2, CONTEXT_FABRIC_TRUNCATION_SUFFIX, ContextLedger, ContextFrameBuilder;
|
|
563818
|
+
var PRIORITY, KIND_ORDER, KIND_LABELS, DEFAULT_KIND_CHAR_BUDGET, URL_RE2, CONTEXT_FABRIC_TRUNCATION_SUFFIX, ContextLedger, ContextFrameBuilder;
|
|
563446
563819
|
var init_context_fabric = __esm({
|
|
563447
563820
|
"packages/orchestrator/dist/context-fabric.js"() {
|
|
563448
563821
|
"use strict";
|
|
563822
|
+
PRIORITY = {
|
|
563823
|
+
GOAL: 100,
|
|
563824
|
+
USER_STEERING: 95,
|
|
563825
|
+
TASK_STATE: 80,
|
|
563826
|
+
KNOWN_FILES: 70,
|
|
563827
|
+
RECENT_FAILURE: 65,
|
|
563828
|
+
TOOL_CACHE: 60,
|
|
563829
|
+
SKILL_MANIFEST: 55,
|
|
563830
|
+
MEMORY: 50,
|
|
563831
|
+
SEMANTIC_CHUNK: 45,
|
|
563832
|
+
SESSION_HISTORY: 40,
|
|
563833
|
+
ANCHOR: 35,
|
|
563834
|
+
HANDOFF: 30,
|
|
563835
|
+
ENVIRONMENT: 25,
|
|
563836
|
+
COMPACTION_SUMMARY: 20
|
|
563837
|
+
};
|
|
563449
563838
|
KIND_ORDER = [
|
|
563450
563839
|
"goal",
|
|
563451
563840
|
"user_steering",
|
|
@@ -563625,7 +564014,7 @@ var init_context_fabric = __esm({
|
|
|
563625
564014
|
const label = KIND_LABELS[kind];
|
|
563626
564015
|
sectionLines.push(`## ${label}`);
|
|
563627
564016
|
sectionLines.push(body.join("\n"));
|
|
563628
|
-
sectionDiagnostics.push({ kind, label, signals: used, chars });
|
|
564017
|
+
sectionDiagnostics.push({ kind, label, signals: used, chars, dropped: dropped.length });
|
|
563629
564018
|
}
|
|
563630
564019
|
const header = [
|
|
563631
564020
|
"[ACTIVE CONTEXT FRAME]",
|
|
@@ -563833,21 +564222,21 @@ __export(preflightSnapshot_exports, {
|
|
|
563833
564222
|
formatPreflightStatus: () => formatPreflightStatus,
|
|
563834
564223
|
freeDiskBytes: () => freeDiskBytes
|
|
563835
564224
|
});
|
|
563836
|
-
import { existsSync as
|
|
564225
|
+
import { existsSync as existsSync91, readFileSync as readFileSync71, statSync as statSync35 } from "node:fs";
|
|
563837
564226
|
import { execSync as execSync47 } from "node:child_process";
|
|
563838
564227
|
import { homedir as homedir31, platform as platform3, arch as arch2, totalmem as totalmem3, freemem as freemem3, hostname as hostname3 } from "node:os";
|
|
563839
|
-
import { join as
|
|
564228
|
+
import { join as join102 } from "node:path";
|
|
563840
564229
|
import { createHash as createHash26 } from "node:crypto";
|
|
563841
564230
|
function capturePreflightSnapshot(workingDir) {
|
|
563842
564231
|
const warnings = [];
|
|
563843
564232
|
const configFingerprints = {};
|
|
563844
564233
|
for (const det of CONFIG_DETECTORS) {
|
|
563845
564234
|
const expanded = expandPath(det.path);
|
|
563846
|
-
if (!
|
|
564235
|
+
if (!existsSync91(expanded))
|
|
563847
564236
|
continue;
|
|
563848
564237
|
let raw;
|
|
563849
564238
|
try {
|
|
563850
|
-
raw =
|
|
564239
|
+
raw = readFileSync71(expanded, "utf8");
|
|
563851
564240
|
} catch {
|
|
563852
564241
|
continue;
|
|
563853
564242
|
}
|
|
@@ -563860,12 +564249,12 @@ function capturePreflightSnapshot(workingDir) {
|
|
|
563860
564249
|
for (const det of CONFIG_DETECTORS) {
|
|
563861
564250
|
if (det.path.startsWith("~/")) {
|
|
563862
564251
|
const localName = det.path.replace(/^~\//, "");
|
|
563863
|
-
const projectPath =
|
|
563864
|
-
if (!
|
|
564252
|
+
const projectPath = join102(workingDir, localName);
|
|
564253
|
+
if (!existsSync91(projectPath))
|
|
563865
564254
|
continue;
|
|
563866
564255
|
let raw;
|
|
563867
564256
|
try {
|
|
563868
|
-
raw =
|
|
564257
|
+
raw = readFileSync71(projectPath, "utf8");
|
|
563869
564258
|
} catch {
|
|
563870
564259
|
continue;
|
|
563871
564260
|
}
|
|
@@ -564004,7 +564393,7 @@ function captureToolchainVersions() {
|
|
|
564004
564393
|
}
|
|
564005
564394
|
function expandPath(p2) {
|
|
564006
564395
|
if (p2.startsWith("~/"))
|
|
564007
|
-
return
|
|
564396
|
+
return join102(homedir31(), p2.slice(2));
|
|
564008
564397
|
return p2;
|
|
564009
564398
|
}
|
|
564010
564399
|
function sha2564(s2) {
|
|
@@ -564075,8 +564464,8 @@ __export(postActionVerifier_exports, {
|
|
|
564075
564464
|
classifyShellIntent: () => classifyShellIntent,
|
|
564076
564465
|
verifyShellOutcome: () => verifyShellOutcome
|
|
564077
564466
|
});
|
|
564078
|
-
import { existsSync as
|
|
564079
|
-
import { join as
|
|
564467
|
+
import { existsSync as existsSync92, readFileSync as readFileSync72, readdirSync as readdirSync28, statSync as statSync36 } from "node:fs";
|
|
564468
|
+
import { join as join103 } from "node:path";
|
|
564080
564469
|
function classifyShellIntent(cmd) {
|
|
564081
564470
|
const stripped = cmd.replace(/^cd\s+\S+\s*&&\s*/, "").trim();
|
|
564082
564471
|
const tokens = stripped.split(/\s+/).filter(Boolean);
|
|
@@ -564124,7 +564513,7 @@ function checkMutateMtimeDelta(intent, cwd4, ctx3, _result) {
|
|
|
564124
564513
|
if (intent.klass !== "mutate") {
|
|
564125
564514
|
return { trustworthy: true, intentBucket: bucket, outcomeClass: "unknown" };
|
|
564126
564515
|
}
|
|
564127
|
-
if (!
|
|
564516
|
+
if (!existsSync92(cwd4)) {
|
|
564128
564517
|
return {
|
|
564129
564518
|
trustworthy: false,
|
|
564130
564519
|
syntheticError: `Command claimed success but the working directory ${cwd4} does not exist.`,
|
|
@@ -564163,19 +564552,19 @@ function checkMutateMtimeDelta(intent, cwd4, ctx3, _result) {
|
|
|
564163
564552
|
}
|
|
564164
564553
|
function checkManifestInvariant(cwd4, fallbackBucket) {
|
|
564165
564554
|
for (const pattern of MANIFEST_PATTERNS) {
|
|
564166
|
-
const manifestPath2 =
|
|
564167
|
-
if (!
|
|
564555
|
+
const manifestPath2 = join103(cwd4, pattern.manifest);
|
|
564556
|
+
if (!existsSync92(manifestPath2))
|
|
564168
564557
|
continue;
|
|
564169
564558
|
let declared;
|
|
564170
564559
|
try {
|
|
564171
|
-
declared = pattern.parseDeps(
|
|
564560
|
+
declared = pattern.parseDeps(readFileSync72(manifestPath2, "utf8"));
|
|
564172
564561
|
} catch {
|
|
564173
564562
|
continue;
|
|
564174
564563
|
}
|
|
564175
564564
|
if (declared.length === 0)
|
|
564176
564565
|
continue;
|
|
564177
|
-
const installRootAbs =
|
|
564178
|
-
if (!
|
|
564566
|
+
const installRootAbs = join103(cwd4, pattern.installRoot);
|
|
564567
|
+
if (!existsSync92(installRootAbs)) {
|
|
564179
564568
|
continue;
|
|
564180
564569
|
}
|
|
564181
564570
|
const installed = pattern.listInstalled ? pattern.listInstalled(installRootAbs) : defaultListDirNames(installRootAbs);
|
|
@@ -564276,7 +564665,7 @@ function listNpmInstalled(installRootAbs) {
|
|
|
564276
564665
|
for (const name10 of readdirSync28(installRootAbs)) {
|
|
564277
564666
|
if (name10.startsWith("."))
|
|
564278
564667
|
continue;
|
|
564279
|
-
const sub2 =
|
|
564668
|
+
const sub2 = join103(installRootAbs, name10);
|
|
564280
564669
|
try {
|
|
564281
564670
|
if (!statSync36(sub2).isDirectory())
|
|
564282
564671
|
continue;
|
|
@@ -564293,7 +564682,7 @@ function listNpmInstalled(installRootAbs) {
|
|
|
564293
564682
|
}
|
|
564294
564683
|
continue;
|
|
564295
564684
|
}
|
|
564296
|
-
if (
|
|
564685
|
+
if (existsSync92(join103(sub2, "package.json")))
|
|
564297
564686
|
out.add(name10);
|
|
564298
564687
|
}
|
|
564299
564688
|
} catch {
|
|
@@ -564304,11 +564693,11 @@ function listPipInstalled(installRootAbs) {
|
|
|
564304
564693
|
const out = /* @__PURE__ */ new Set();
|
|
564305
564694
|
const candidates = [];
|
|
564306
564695
|
try {
|
|
564307
|
-
const lib =
|
|
564308
|
-
if (
|
|
564696
|
+
const lib = join103(installRootAbs, "lib");
|
|
564697
|
+
if (existsSync92(lib)) {
|
|
564309
564698
|
for (const py of readdirSync28(lib)) {
|
|
564310
|
-
const sp =
|
|
564311
|
-
if (
|
|
564699
|
+
const sp = join103(lib, py, "site-packages");
|
|
564700
|
+
if (existsSync92(sp))
|
|
564312
564701
|
candidates.push(sp);
|
|
564313
564702
|
}
|
|
564314
564703
|
}
|
|
@@ -564347,7 +564736,7 @@ function mostRecentFileMtimeMs(root, maxDepth) {
|
|
|
564347
564736
|
for (const name10 of entries) {
|
|
564348
564737
|
if (MTIME_EXCLUDES.has(name10))
|
|
564349
564738
|
continue;
|
|
564350
|
-
const full =
|
|
564739
|
+
const full = join103(dir, name10);
|
|
564351
564740
|
let st;
|
|
564352
564741
|
try {
|
|
564353
564742
|
st = statSync36(full);
|
|
@@ -564368,8 +564757,8 @@ function mostRecentFileMtimeMs(root, maxDepth) {
|
|
|
564368
564757
|
function listExistingChildren(cwd4, candidates) {
|
|
564369
564758
|
const out = [];
|
|
564370
564759
|
for (const c8 of candidates) {
|
|
564371
|
-
const p2 =
|
|
564372
|
-
if (
|
|
564760
|
+
const p2 = join103(cwd4, c8);
|
|
564761
|
+
if (existsSync92(p2))
|
|
564373
564762
|
out.push(p2);
|
|
564374
564763
|
}
|
|
564375
564764
|
return out;
|
|
@@ -564886,7 +565275,7 @@ import { createHash as _createHash } from "node:crypto";
|
|
|
564886
565275
|
import { join as _pathJoin, resolve as _pathResolve } from "node:path";
|
|
564887
565276
|
import { tmpdir as _osTmpdir } from "node:os";
|
|
564888
565277
|
import { homedir as _osHomedir } from "node:os";
|
|
564889
|
-
import { z as
|
|
565278
|
+
import { z as z17 } from "zod";
|
|
564890
565279
|
function textFromMessageContent(content) {
|
|
564891
565280
|
if (typeof content === "string")
|
|
564892
565281
|
return content;
|
|
@@ -565366,6 +565755,7 @@ var init_agenticRunner = __esm({
|
|
|
565366
565755
|
"use strict";
|
|
565367
565756
|
init_textSanitize();
|
|
565368
565757
|
init_permissionRuleset();
|
|
565758
|
+
init_steeringIntake();
|
|
565369
565759
|
init_completionLedger();
|
|
565370
565760
|
init_dist6();
|
|
565371
565761
|
init_ollama_pool();
|
|
@@ -569357,6 +569747,16 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
569357
569747
|
priority: 35,
|
|
569358
569748
|
createdTurn: turn,
|
|
569359
569749
|
ttlTurns: 1
|
|
569750
|
+
}),
|
|
569751
|
+
signalFromBlock("user_steering", "turn.recentSteering", buildRecentSteeringContext(this._workingDirectory || process.cwd()), {
|
|
569752
|
+
id: "recentSteering",
|
|
569753
|
+
dedupeKey: "turn.recentSteering",
|
|
569754
|
+
// PRIORITY.USER_STEERING (95) keeps steering above all non-goal
|
|
569755
|
+
// signals so mid-turn user feedback is never buried under budget
|
|
569756
|
+
// pressure. See context-fabric.ts PRIORITY tier map.
|
|
569757
|
+
priority: PRIORITY.USER_STEERING,
|
|
569758
|
+
createdTurn: turn,
|
|
569759
|
+
ttlTurns: 1
|
|
569360
569760
|
})
|
|
569361
569761
|
];
|
|
569362
569762
|
this._contextLedger.upsertMany(signals.filter(Boolean));
|
|
@@ -581221,9 +581621,9 @@ var init_constraint_learner = __esm({
|
|
|
581221
581621
|
});
|
|
581222
581622
|
|
|
581223
581623
|
// packages/orchestrator/dist/nexusBackend.js
|
|
581224
|
-
import { existsSync as
|
|
581624
|
+
import { existsSync as existsSync93, statSync as statSync37, openSync, readSync, closeSync, unlinkSync as unlinkSync17, writeFileSync as writeFileSync43 } from "node:fs";
|
|
581225
581625
|
import { watch as fsWatch } from "node:fs";
|
|
581226
|
-
import { join as
|
|
581626
|
+
import { join as join104 } from "node:path";
|
|
581227
581627
|
import { tmpdir as tmpdir19 } from "node:os";
|
|
581228
581628
|
import { randomBytes as randomBytes20 } from "node:crypto";
|
|
581229
581629
|
var NexusAgenticBackend;
|
|
@@ -581426,7 +581826,7 @@ ${suffix}` } : m2);
|
|
|
581426
581826
|
* Falls back to unary + word-split if streaming setup fails.
|
|
581427
581827
|
*/
|
|
581428
581828
|
async *chatCompletionStream(request) {
|
|
581429
|
-
const streamFile =
|
|
581829
|
+
const streamFile = join104(tmpdir19(), `nexus-stream-${randomBytes20(6).toString("hex")}.jsonl`);
|
|
581430
581830
|
writeFileSync43(streamFile, "", "utf8");
|
|
581431
581831
|
const effectiveThink = this.effectiveThink(request);
|
|
581432
581832
|
const daemonArgs = {
|
|
@@ -581951,327 +582351,6 @@ var init_cascadeBackend = __esm({
|
|
|
581951
582351
|
}
|
|
581952
582352
|
});
|
|
581953
582353
|
|
|
581954
|
-
// packages/orchestrator/dist/steeringIntake.js
|
|
581955
|
-
import { randomUUID as randomUUID16 } from "node:crypto";
|
|
581956
|
-
import { appendFileSync as appendFileSync6, existsSync as existsSync93, mkdirSync as mkdirSync51, readFileSync as readFileSync72 } from "node:fs";
|
|
581957
|
-
import { join as join104 } from "node:path";
|
|
581958
|
-
import { z as z17 } from "zod";
|
|
581959
|
-
function createSteeringIngress(input) {
|
|
581960
|
-
return {
|
|
581961
|
-
id: randomUUID16(),
|
|
581962
|
-
rawText: input.rawText.trim(),
|
|
581963
|
-
sourceSurface: input.sourceSurface,
|
|
581964
|
-
authority: "user",
|
|
581965
|
-
isReplacement: input.isReplacement ?? false,
|
|
581966
|
-
currentTaskGoal: input.currentTaskGoal || "(unknown current task)",
|
|
581967
|
-
recentActivity: input.recentActivity,
|
|
581968
|
-
filesTouched: (input.filesTouched ?? []).filter(Boolean).slice(0, 12),
|
|
581969
|
-
toolCallCount: input.toolCallCount ?? 0,
|
|
581970
|
-
taskId: input.taskId,
|
|
581971
|
-
sessionId: input.sessionId,
|
|
581972
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
581973
|
-
};
|
|
581974
|
-
}
|
|
581975
|
-
async function interpretSteeringIngress(backend, ingress, timeoutMs = 8e3) {
|
|
581976
|
-
const first2 = await backend.chatCompletion({
|
|
581977
|
-
messages: [
|
|
581978
|
-
{
|
|
581979
|
-
role: "system",
|
|
581980
|
-
content: [
|
|
581981
|
-
"You interpret human feedback for a running coding agent.",
|
|
581982
|
-
"Return strict JSON only.",
|
|
581983
|
-
"Use only the supplied task trajectory and ingress.",
|
|
581984
|
-
"The JSON fields describe task impact and next-action guidance."
|
|
581985
|
-
].join("\n")
|
|
581986
|
-
},
|
|
581987
|
-
{ role: "user", content: buildInterpretationPrompt(ingress) }
|
|
581988
|
-
],
|
|
581989
|
-
tools: [],
|
|
581990
|
-
temperature: 0.2,
|
|
581991
|
-
maxTokens: 512,
|
|
581992
|
-
timeoutMs,
|
|
581993
|
-
think: false,
|
|
581994
|
-
responseFormat: steeringInterpretationResponseFormat()
|
|
581995
|
-
});
|
|
581996
|
-
const raw = first2.choices[0]?.message?.content ?? "";
|
|
581997
|
-
const parsed = parseSteeringInterpretation(raw);
|
|
581998
|
-
if (parsed)
|
|
581999
|
-
return parsed;
|
|
582000
|
-
const repaired = await backend.chatCompletion({
|
|
582001
|
-
messages: [
|
|
582002
|
-
{
|
|
582003
|
-
role: "system",
|
|
582004
|
-
content: "Repair the supplied text into strict JSON matching the requested schema. Return JSON only."
|
|
582005
|
-
},
|
|
582006
|
-
{
|
|
582007
|
-
role: "user",
|
|
582008
|
-
content: [
|
|
582009
|
-
"Schema keys: inference, runnerInstruction, conflicts, alternatives, memoryNote.",
|
|
582010
|
-
"Required keys: inference, runnerInstruction.",
|
|
582011
|
-
"",
|
|
582012
|
-
"Original task state and ingress:",
|
|
582013
|
-
buildInterpretationPrompt(ingress),
|
|
582014
|
-
"",
|
|
582015
|
-
"Malformed model output:",
|
|
582016
|
-
raw
|
|
582017
|
-
].join("\n")
|
|
582018
|
-
}
|
|
582019
|
-
],
|
|
582020
|
-
tools: [],
|
|
582021
|
-
temperature: 0,
|
|
582022
|
-
maxTokens: 512,
|
|
582023
|
-
timeoutMs,
|
|
582024
|
-
think: false,
|
|
582025
|
-
responseFormat: steeringInterpretationResponseFormat()
|
|
582026
|
-
});
|
|
582027
|
-
return parseSteeringInterpretation(repaired.choices[0]?.message?.content ?? "");
|
|
582028
|
-
}
|
|
582029
|
-
function buildSteeringPacket(ingress, interpretation) {
|
|
582030
|
-
const lines = [
|
|
582031
|
-
STEERING_START,
|
|
582032
|
-
`id: ${ingress.id}`,
|
|
582033
|
-
`sourceSurface: ${ingress.sourceSurface}`,
|
|
582034
|
-
`feedbackKind: external_human`,
|
|
582035
|
-
`authority: ${ingress.authority}`,
|
|
582036
|
-
`replacement: ${ingress.isReplacement ? "true" : "false"}`,
|
|
582037
|
-
`toolCallsSoFar: ${ingress.toolCallCount}`,
|
|
582038
|
-
`timestamp: ${ingress.timestamp}`,
|
|
582039
|
-
"",
|
|
582040
|
-
"Instruction hierarchy:",
|
|
582041
|
-
"- Treat this as user-level steering, below system/developer/tool safety and above older user assumptions when they conflict.",
|
|
582042
|
-
"",
|
|
582043
|
-
"Current task goal:",
|
|
582044
|
-
truncateBlock(ingress.currentTaskGoal || "(unknown current task)", 1200),
|
|
582045
|
-
"",
|
|
582046
|
-
"Recent activity:",
|
|
582047
|
-
truncateBlock(ingress.recentActivity || "(no recent activity recorded)", 1200),
|
|
582048
|
-
"",
|
|
582049
|
-
ingress.filesTouched.length > 0 ? `Files touched so far: ${ingress.filesTouched.join(", ")}` : "Files touched so far: none recorded",
|
|
582050
|
-
"",
|
|
582051
|
-
RAW_START,
|
|
582052
|
-
ingress.rawText,
|
|
582053
|
-
RAW_END,
|
|
582054
|
-
""
|
|
582055
|
-
];
|
|
582056
|
-
if (interpretation) {
|
|
582057
|
-
lines.push("Model-derived steering interpretation:", `inference: ${interpretation.inference}`, `runnerInstruction: ${interpretation.runnerInstruction}`);
|
|
582058
|
-
if (interpretation.conflicts?.length) {
|
|
582059
|
-
lines.push("conflicts:", ...interpretation.conflicts.map((item) => `- ${item}`));
|
|
582060
|
-
}
|
|
582061
|
-
if (interpretation.alternatives?.length) {
|
|
582062
|
-
lines.push("alternative interpretations:", ...interpretation.alternatives.map((item) => `- ${item}`));
|
|
582063
|
-
}
|
|
582064
|
-
if (interpretation.memoryNote) {
|
|
582065
|
-
lines.push(`memoryNote: ${interpretation.memoryNote}`);
|
|
582066
|
-
}
|
|
582067
|
-
lines.push("");
|
|
582068
|
-
} else {
|
|
582069
|
-
lines.push("Model-derived steering interpretation: unavailable", "");
|
|
582070
|
-
}
|
|
582071
|
-
lines.push("Interleave contract:", "- Consume this before the next assistant/tool decision.", "- Do not treat it as passive transcript context.", "- Either act on the steering directly, or explicitly reconcile why it does not alter the current plan.", STEERING_END);
|
|
582072
|
-
return lines.join("\n");
|
|
582073
|
-
}
|
|
582074
|
-
function extractMidTaskSteeringInput(value2) {
|
|
582075
|
-
const start2 = value2.indexOf(RAW_START);
|
|
582076
|
-
const end = value2.indexOf(RAW_END);
|
|
582077
|
-
if (start2 < 0 || end <= start2)
|
|
582078
|
-
return null;
|
|
582079
|
-
return value2.slice(start2 + RAW_START.length, end).trim();
|
|
582080
|
-
}
|
|
582081
|
-
function appendSteeringLedgerEntry(repoRoot, entry) {
|
|
582082
|
-
try {
|
|
582083
|
-
const dir = join104(repoRoot, ".omnius", "context");
|
|
582084
|
-
mkdirSync51(dir, { recursive: true });
|
|
582085
|
-
appendFileSync6(join104(dir, LEDGER_FILE), `${JSON.stringify(entry)}
|
|
582086
|
-
`, "utf-8");
|
|
582087
|
-
} catch {
|
|
582088
|
-
}
|
|
582089
|
-
}
|
|
582090
|
-
function appendSteeringOutcome(repoRoot, packetIds, outcome, summary) {
|
|
582091
|
-
for (const packetId of packetIds) {
|
|
582092
|
-
appendSteeringLedgerEntry(repoRoot, {
|
|
582093
|
-
type: "outcome",
|
|
582094
|
-
packetId,
|
|
582095
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
582096
|
-
outcome,
|
|
582097
|
-
summary: summary.slice(0, 1200)
|
|
582098
|
-
});
|
|
582099
|
-
}
|
|
582100
|
-
}
|
|
582101
|
-
function buildRecentSteeringContext(repoRoot, limit = 3) {
|
|
582102
|
-
const entries = readRecentSteeringEntries(repoRoot, limit);
|
|
582103
|
-
if (entries.length === 0)
|
|
582104
|
-
return "";
|
|
582105
|
-
const lines = entries.map((entry, idx) => {
|
|
582106
|
-
const interpretation = entry.interpretation;
|
|
582107
|
-
const inference = interpretation?.inference || "(raw steering only)";
|
|
582108
|
-
const note = interpretation?.memoryNote ? ` Memory note: ${interpretation.memoryNote}` : "";
|
|
582109
|
-
const outcome = entry.outcome ? ` Outcome: ${entry.outcome}.` : "";
|
|
582110
|
-
return `${idx + 1}. ${inference}${note}${outcome}`;
|
|
582111
|
-
});
|
|
582112
|
-
return [
|
|
582113
|
-
"<recent-user-steering>",
|
|
582114
|
-
"Recent user steering reflections from this workspace. Use only when relevant to the current task.",
|
|
582115
|
-
...lines,
|
|
582116
|
-
"</recent-user-steering>"
|
|
582117
|
-
].join("\n");
|
|
582118
|
-
}
|
|
582119
|
-
function buildInterpretationPrompt(ingress) {
|
|
582120
|
-
return [
|
|
582121
|
-
"Infer how this human feedback changes, constrains, or clarifies the active task.",
|
|
582122
|
-
"If there are multiple plausible readings, include them in alternatives.",
|
|
582123
|
-
"If the feedback conflicts with prior task assumptions, list the conflict.",
|
|
582124
|
-
"If this should persist beyond the current turn, include memoryNote.",
|
|
582125
|
-
"",
|
|
582126
|
-
"Return JSON:",
|
|
582127
|
-
"{",
|
|
582128
|
-
' "inference": "concise user-facing task-impact inference",',
|
|
582129
|
-
' "runnerInstruction": "specific instruction for the next agent decision",',
|
|
582130
|
-
' "conflicts": ["optional conflict"],',
|
|
582131
|
-
' "alternatives": ["optional alternate reading"],',
|
|
582132
|
-
' "memoryNote": "optional durable lesson"',
|
|
582133
|
-
"}",
|
|
582134
|
-
"",
|
|
582135
|
-
`replacement: ${ingress.isReplacement ? "true" : "false"}`,
|
|
582136
|
-
`toolCallsSoFar: ${ingress.toolCallCount}`,
|
|
582137
|
-
"",
|
|
582138
|
-
"Current task goal:",
|
|
582139
|
-
truncateBlock(ingress.currentTaskGoal || "(unknown current task)", 1200),
|
|
582140
|
-
"",
|
|
582141
|
-
"Recent activity:",
|
|
582142
|
-
truncateBlock(ingress.recentActivity || "(no recent activity recorded)", 1200),
|
|
582143
|
-
"",
|
|
582144
|
-
ingress.filesTouched.length > 0 ? `Files touched so far: ${ingress.filesTouched.join(", ")}` : "Files touched so far: none recorded",
|
|
582145
|
-
"",
|
|
582146
|
-
RAW_START,
|
|
582147
|
-
ingress.rawText,
|
|
582148
|
-
RAW_END
|
|
582149
|
-
].join("\n");
|
|
582150
|
-
}
|
|
582151
|
-
function parseSteeringInterpretation(raw) {
|
|
582152
|
-
const candidate = extractJsonObject(raw);
|
|
582153
|
-
if (!candidate)
|
|
582154
|
-
return null;
|
|
582155
|
-
try {
|
|
582156
|
-
const parsed = SteeringInterpretationSchema.parse(JSON.parse(candidate));
|
|
582157
|
-
return {
|
|
582158
|
-
inference: parsed.inference,
|
|
582159
|
-
runnerInstruction: parsed.runnerInstruction,
|
|
582160
|
-
conflicts: parsed.conflicts,
|
|
582161
|
-
alternatives: parsed.alternatives,
|
|
582162
|
-
memoryNote: parsed.memoryNote
|
|
582163
|
-
};
|
|
582164
|
-
} catch {
|
|
582165
|
-
return null;
|
|
582166
|
-
}
|
|
582167
|
-
}
|
|
582168
|
-
function extractJsonObject(raw) {
|
|
582169
|
-
const text2 = raw.trim();
|
|
582170
|
-
if (!text2)
|
|
582171
|
-
return null;
|
|
582172
|
-
try {
|
|
582173
|
-
JSON.parse(text2);
|
|
582174
|
-
return text2;
|
|
582175
|
-
} catch {
|
|
582176
|
-
}
|
|
582177
|
-
let start2 = -1;
|
|
582178
|
-
let depth = 0;
|
|
582179
|
-
let inString = false;
|
|
582180
|
-
let escaped = false;
|
|
582181
|
-
for (let i2 = 0; i2 < text2.length; i2++) {
|
|
582182
|
-
const ch = text2[i2];
|
|
582183
|
-
if (inString) {
|
|
582184
|
-
if (escaped) {
|
|
582185
|
-
escaped = false;
|
|
582186
|
-
} else if (ch === "\\") {
|
|
582187
|
-
escaped = true;
|
|
582188
|
-
} else if (ch === '"') {
|
|
582189
|
-
inString = false;
|
|
582190
|
-
}
|
|
582191
|
-
continue;
|
|
582192
|
-
}
|
|
582193
|
-
if (ch === '"') {
|
|
582194
|
-
inString = true;
|
|
582195
|
-
continue;
|
|
582196
|
-
}
|
|
582197
|
-
if (ch === "{") {
|
|
582198
|
-
if (depth === 0)
|
|
582199
|
-
start2 = i2;
|
|
582200
|
-
depth++;
|
|
582201
|
-
continue;
|
|
582202
|
-
}
|
|
582203
|
-
if (ch === "}") {
|
|
582204
|
-
depth--;
|
|
582205
|
-
if (depth === 0 && start2 >= 0)
|
|
582206
|
-
return text2.slice(start2, i2 + 1);
|
|
582207
|
-
if (depth < 0) {
|
|
582208
|
-
start2 = -1;
|
|
582209
|
-
depth = 0;
|
|
582210
|
-
}
|
|
582211
|
-
}
|
|
582212
|
-
}
|
|
582213
|
-
return null;
|
|
582214
|
-
}
|
|
582215
|
-
function steeringInterpretationResponseFormat() {
|
|
582216
|
-
return { type: "json_object" };
|
|
582217
|
-
}
|
|
582218
|
-
function readRecentSteeringEntries(repoRoot, limit) {
|
|
582219
|
-
try {
|
|
582220
|
-
const file = join104(repoRoot, ".omnius", "context", LEDGER_FILE);
|
|
582221
|
-
if (!existsSync93(file))
|
|
582222
|
-
return [];
|
|
582223
|
-
const lines = readFileSync72(file, "utf-8").split("\n").filter(Boolean).slice(-100);
|
|
582224
|
-
const parsedEntries = [];
|
|
582225
|
-
for (const line of lines) {
|
|
582226
|
-
try {
|
|
582227
|
-
parsedEntries.push(JSON.parse(line));
|
|
582228
|
-
} catch {
|
|
582229
|
-
}
|
|
582230
|
-
}
|
|
582231
|
-
const latestOutcomes = /* @__PURE__ */ new Map();
|
|
582232
|
-
for (const entry of parsedEntries) {
|
|
582233
|
-
if (entry.type === "outcome")
|
|
582234
|
-
latestOutcomes.set(entry.packetId, entry);
|
|
582235
|
-
}
|
|
582236
|
-
const out = [];
|
|
582237
|
-
for (let i2 = parsedEntries.length - 1; i2 >= 0 && out.length < limit; i2--) {
|
|
582238
|
-
const parsed = parsedEntries[i2];
|
|
582239
|
-
if (parsed.type === "ingress") {
|
|
582240
|
-
const outcome = latestOutcomes.get(parsed.packetId);
|
|
582241
|
-
out.push(outcome ? { ...parsed, outcome: outcome.outcome, summary: outcome.summary } : parsed);
|
|
582242
|
-
}
|
|
582243
|
-
}
|
|
582244
|
-
return out;
|
|
582245
|
-
} catch {
|
|
582246
|
-
return [];
|
|
582247
|
-
}
|
|
582248
|
-
}
|
|
582249
|
-
function truncateBlock(value2, max) {
|
|
582250
|
-
const trimmed = value2.trim();
|
|
582251
|
-
if (trimmed.length <= max)
|
|
582252
|
-
return trimmed;
|
|
582253
|
-
return `${trimmed.slice(0, max).trimEnd()}
|
|
582254
|
-
...(truncated)`;
|
|
582255
|
-
}
|
|
582256
|
-
var STEERING_START, STEERING_END, RAW_START, RAW_END, LEDGER_FILE, SteeringInterpretationSchema;
|
|
582257
|
-
var init_steeringIntake = __esm({
|
|
582258
|
-
"packages/orchestrator/dist/steeringIntake.js"() {
|
|
582259
|
-
"use strict";
|
|
582260
|
-
STEERING_START = "[MID_TASK_STEERING_INTAKE v2]";
|
|
582261
|
-
STEERING_END = "[/MID_TASK_STEERING_INTAKE]";
|
|
582262
|
-
RAW_START = "<<<USER_ADDED_CONTEXT>>>";
|
|
582263
|
-
RAW_END = "<<<END_USER_ADDED_CONTEXT>>>";
|
|
582264
|
-
LEDGER_FILE = "steering-ledger.jsonl";
|
|
582265
|
-
SteeringInterpretationSchema = z17.object({
|
|
582266
|
-
inference: z17.string().trim().min(1),
|
|
582267
|
-
runnerInstruction: z17.string().trim().min(1),
|
|
582268
|
-
conflicts: z17.array(z17.string().trim().min(1)).optional().default([]),
|
|
582269
|
-
alternatives: z17.array(z17.string().trim().min(1)).optional().default([]),
|
|
582270
|
-
memoryNote: z17.string().trim().min(1).optional()
|
|
582271
|
-
});
|
|
582272
|
-
}
|
|
582273
|
-
});
|
|
582274
|
-
|
|
582275
582354
|
// packages/orchestrator/dist/flowstatePrompt.js
|
|
582276
582355
|
var FLOWSTATE_PROMPT;
|
|
582277
582356
|
var init_flowstatePrompt = __esm({
|