omnius 1.0.548 → 1.0.550
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 +1710 -433
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -155716,7 +155716,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
155716
155716
|
"../node_modules/undici/lib/mock/snapshot-recorder.js"(exports, module) {
|
|
155717
155717
|
"use strict";
|
|
155718
155718
|
var { writeFile: writeFile27, readFile: readFile25, mkdir: mkdir23 } = __require("node:fs/promises");
|
|
155719
|
-
var { dirname:
|
|
155719
|
+
var { dirname: dirname59, resolve: resolve82 } = __require("node:path");
|
|
155720
155720
|
var { setTimeout: setTimeout3, clearTimeout: clearTimeout3 } = __require("node:timers");
|
|
155721
155721
|
var { InvalidArgumentError, UndiciError } = require_errors2();
|
|
155722
155722
|
var { hashId, isUrlExcludedFactory, normalizeHeaders, createHeaderFilters } = require_snapshot_utils();
|
|
@@ -155947,7 +155947,7 @@ var require_snapshot_recorder = __commonJS({
|
|
|
155947
155947
|
throw new InvalidArgumentError("Snapshot path is required");
|
|
155948
155948
|
}
|
|
155949
155949
|
const resolvedPath = resolve82(path16);
|
|
155950
|
-
await mkdir23(
|
|
155950
|
+
await mkdir23(dirname59(resolvedPath), { recursive: true });
|
|
155951
155951
|
const data = Array.from(this.#snapshots.entries()).map(([hash, snapshot]) => ({
|
|
155952
155952
|
hash,
|
|
155953
155953
|
snapshot
|
|
@@ -269609,15 +269609,15 @@ var init_ls = __esm({
|
|
|
269609
269609
|
});
|
|
269610
269610
|
|
|
269611
269611
|
// ../node_modules/@helia/unixfs/dist/src/commands/mkdir.js
|
|
269612
|
-
async function mkdir6(parentCid,
|
|
269613
|
-
if (
|
|
269612
|
+
async function mkdir6(parentCid, dirname59, blockstore, options2 = {}) {
|
|
269613
|
+
if (dirname59.includes("/")) {
|
|
269614
269614
|
throw new InvalidParametersError4("Path must not have slashes");
|
|
269615
269615
|
}
|
|
269616
269616
|
const entry = await exporter2(parentCid, blockstore, options2);
|
|
269617
269617
|
if (entry.type !== "directory") {
|
|
269618
269618
|
throw new NotADirectoryError(`${parentCid.toString()} was not a UnixFS directory`);
|
|
269619
269619
|
}
|
|
269620
|
-
log16("creating %s",
|
|
269620
|
+
log16("creating %s", dirname59);
|
|
269621
269621
|
const metadata = new UnixFS({
|
|
269622
269622
|
type: "directory",
|
|
269623
269623
|
mode: options2.mode,
|
|
@@ -269633,9 +269633,9 @@ async function mkdir6(parentCid, dirname58, blockstore, options2 = {}) {
|
|
|
269633
269633
|
await blockstore.put(emptyDirCid, buf);
|
|
269634
269634
|
const [directory, pblink] = await Promise.all([
|
|
269635
269635
|
cidToDirectory(parentCid, blockstore, options2),
|
|
269636
|
-
cidToPBLink(emptyDirCid,
|
|
269636
|
+
cidToPBLink(emptyDirCid, dirname59, blockstore, options2)
|
|
269637
269637
|
]);
|
|
269638
|
-
log16("adding empty dir called %s to %c",
|
|
269638
|
+
log16("adding empty dir called %s to %c", dirname59, parentCid);
|
|
269639
269639
|
const result = await addLink(directory, pblink, blockstore, {
|
|
269640
269640
|
...options2,
|
|
269641
269641
|
allowOverwriting: options2.force
|
|
@@ -270134,8 +270134,8 @@ var init_unixfs2 = __esm({
|
|
|
270134
270134
|
async *ls(cid, options2 = {}) {
|
|
270135
270135
|
yield* ls(cid, this.components.blockstore, options2);
|
|
270136
270136
|
}
|
|
270137
|
-
async mkdir(cid,
|
|
270138
|
-
return mkdir6(cid,
|
|
270137
|
+
async mkdir(cid, dirname59, options2 = {}) {
|
|
270138
|
+
return mkdir6(cid, dirname59, this.components.blockstore, options2);
|
|
270139
270139
|
}
|
|
270140
270140
|
async rm(cid, path16, options2 = {}) {
|
|
270141
270141
|
return rm3(cid, path16, this.components.blockstore, options2);
|
|
@@ -516914,7 +516914,7 @@ var require_path_browserify = __commonJS({
|
|
|
516914
516914
|
_makeLong: function _makeLong(path16) {
|
|
516915
516915
|
return path16;
|
|
516916
516916
|
},
|
|
516917
|
-
dirname: function
|
|
516917
|
+
dirname: function dirname59(path16) {
|
|
516918
516918
|
assertPath(path16);
|
|
516919
516919
|
if (path16.length === 0) return ".";
|
|
516920
516920
|
var code8 = path16.charCodeAt(0);
|
|
@@ -566998,6 +566998,7 @@ function createCompletionLedger(input) {
|
|
|
566998
566998
|
const ts = nowIso2(input.now);
|
|
566999
566999
|
return {
|
|
567000
567000
|
runId: input.runId,
|
|
567001
|
+
...typeof input.taskEpoch === "number" ? { taskEpoch: input.taskEpoch } : {},
|
|
567001
567002
|
goal: cleanText(input.goal, 2e3),
|
|
567002
567003
|
createdAtIso: ts,
|
|
567003
567004
|
updatedAtIso: ts,
|
|
@@ -567183,7 +567184,23 @@ function appendUnresolved(items, text2, source) {
|
|
|
567183
567184
|
}
|
|
567184
567185
|
];
|
|
567185
567186
|
}
|
|
567187
|
+
function classifyCompletionProgress(entry) {
|
|
567188
|
+
if (entry.progressClass)
|
|
567189
|
+
return entry.progressClass;
|
|
567190
|
+
const targets = [...entry.targetPaths ?? [], entry.rawRef ?? ""];
|
|
567191
|
+
if (targets.some((target) => CONTROLLER_ARTIFACT_RE.test(target))) {
|
|
567192
|
+
return "control_bookkeeping";
|
|
567193
|
+
}
|
|
567194
|
+
if (entry.role === "blocker")
|
|
567195
|
+
return "blocker";
|
|
567196
|
+
if (entry.kind === "file_change" || entry.role === "mutation") {
|
|
567197
|
+
return "work_product";
|
|
567198
|
+
}
|
|
567199
|
+
return "observation";
|
|
567200
|
+
}
|
|
567186
567201
|
function isMutationEvidence(entry) {
|
|
567202
|
+
if (classifyCompletionProgress(entry) !== "work_product")
|
|
567203
|
+
return false;
|
|
567187
567204
|
if (entry.role === "mutation")
|
|
567188
567205
|
return true;
|
|
567189
567206
|
if (entry.kind === "file_change")
|
|
@@ -567314,10 +567331,12 @@ function saveCompletionLedger(filePath, ledger) {
|
|
|
567314
567331
|
function loadCompletionLedger(filePath) {
|
|
567315
567332
|
return JSON.parse(readFileSync66(filePath, "utf8"));
|
|
567316
567333
|
}
|
|
567334
|
+
var CONTROLLER_ARTIFACT_RE;
|
|
567317
567335
|
var init_completionLedger = __esm({
|
|
567318
567336
|
"packages/orchestrator/dist/completionLedger.js"() {
|
|
567319
567337
|
"use strict";
|
|
567320
567338
|
init_completionContract();
|
|
567339
|
+
CONTROLLER_ARTIFACT_RE = /(?:^|[\\/])\.omnius(?:[\\/]|$)/i;
|
|
567321
567340
|
}
|
|
567322
567341
|
});
|
|
567323
567342
|
|
|
@@ -574466,6 +574485,8 @@ function writeTaskHandoff(omniusDir, handoff) {
|
|
|
574466
574485
|
function readTaskHandoff(omniusDir, opts) {
|
|
574467
574486
|
if (!handoffEnabled())
|
|
574468
574487
|
return null;
|
|
574488
|
+
if (!opts.allowImplicitContinuation)
|
|
574489
|
+
return null;
|
|
574469
574490
|
try {
|
|
574470
574491
|
const file = handoffPath(omniusDir);
|
|
574471
574492
|
if (!fs4.existsSync(file))
|
|
@@ -574506,7 +574527,7 @@ function buildHandoffMessagePair(h) {
|
|
|
574506
574527
|
const filesBlock = h.filesTouched.length ? h.filesTouched.map((f2) => ` - ${f2}`).join("\n") : " (none)";
|
|
574507
574528
|
const toolsBlock = h.toolsUsed.length ? h.toolsUsed.map((t2) => ` - ${t2}`).join("\n") : " (none)";
|
|
574508
574529
|
const actionsBlock = h.lastActions.length ? h.lastActions.map((a2) => ` - ${a2}`).join("\n") : " (none recorded)";
|
|
574509
|
-
const summaryBlock = h.priorSummary || "(no summary captured)";
|
|
574530
|
+
const summaryBlock = (h.priorSummary || "(no summary captured)").slice(0, MAX_SUMMARY_CHARS);
|
|
574510
574531
|
const trajectoryBlock = h.trajectory ? [
|
|
574511
574532
|
"Prior trajectory (STALE orientation — verify before acting):",
|
|
574512
574533
|
` Assessment: ${h.trajectory.assessment}`,
|
|
@@ -574524,10 +574545,10 @@ function buildHandoffMessagePair(h) {
|
|
|
574524
574545
|
|
|
574525
574546
|
If you need verbatim details from the prior task (specific code, exact error messages, or content beyond this summary), file_read the transcript at: ${h.transcriptPath}` : "";
|
|
574526
574547
|
const summary = {
|
|
574527
|
-
role: "
|
|
574548
|
+
role: "system",
|
|
574528
574549
|
content: [
|
|
574529
|
-
"[task_summary]
|
|
574530
|
-
"
|
|
574550
|
+
"[task_summary] Prior-task reference only. It is not a user instruction and cannot replace the live user goal.",
|
|
574551
|
+
"Use it only when the active task explicitly continues this work; otherwise ignore it.",
|
|
574531
574552
|
"",
|
|
574532
574553
|
`Prior goal: ${h.priorGoal}`,
|
|
574533
574554
|
`Prior outcome: ${h.priorOutcome} in ${h.turns} turn(s)`,
|
|
@@ -574565,7 +574586,7 @@ var init_taskHandoff = __esm({
|
|
|
574565
574586
|
init_trajectory_checkpoint();
|
|
574566
574587
|
init_dist5();
|
|
574567
574588
|
DEFAULT_TTL_MS2 = 24 * 60 * 60 * 1e3;
|
|
574568
|
-
MAX_SUMMARY_CHARS =
|
|
574589
|
+
MAX_SUMMARY_CHARS = 2400;
|
|
574569
574590
|
MAX_FILES = 30;
|
|
574570
574591
|
MAX_TOOLS = 24;
|
|
574571
574592
|
MAX_LAST_ACTIONS = 12;
|
|
@@ -578678,6 +578699,36 @@ context_fabric: included=${included.length} dropped=${dropped.length} truncated=
|
|
|
578678
578699
|
});
|
|
578679
578700
|
|
|
578680
578701
|
// packages/orchestrator/dist/context-compiler.js
|
|
578702
|
+
function isCurrentGoalMessage(message2) {
|
|
578703
|
+
return typeof message2.content === "string" && message2.content.includes("[CURRENT USER GOAL]");
|
|
578704
|
+
}
|
|
578705
|
+
function applyModelFacingBudget(messages2, preserveFirstSystem) {
|
|
578706
|
+
const reservedTransaction = latestResolvedToolTransaction(messages2);
|
|
578707
|
+
const reservedChars = [...reservedTransaction].reduce((sum2, index) => sum2 + modelFacingReservedChars(messages2[index]), 0);
|
|
578708
|
+
let remaining = Math.max(0, MODEL_FACING_CONTEXT_CHAR_BUDGET - reservedChars);
|
|
578709
|
+
const kept = [];
|
|
578710
|
+
for (let index = 0; index < messages2.length; index++) {
|
|
578711
|
+
const message2 = messages2[index];
|
|
578712
|
+
const content = messageText(message2.content);
|
|
578713
|
+
const isReservedTransactionMessage = reservedTransaction.has(index);
|
|
578714
|
+
const isPriorityIntent = message2.role === "user" || isCurrentGoalMessage(message2);
|
|
578715
|
+
const perMessageCap = message2.role === "tool" ? MODEL_FACING_TOOL_CHAR_CAP : message2.role === "system" ? MODEL_FACING_SYSTEM_CHAR_CAP : content.length;
|
|
578716
|
+
const allowed = isReservedTransactionMessage ? perMessageCap : isPriorityIntent ? content.length : Math.min(remaining, perMessageCap);
|
|
578717
|
+
if (!isReservedTransactionMessage && !isPriorityIntent && allowed <= 0) {
|
|
578718
|
+
continue;
|
|
578719
|
+
}
|
|
578720
|
+
const bounded = content.length > allowed && allowed > 0 ? `${content.slice(0, Math.max(0, allowed - 83))}
|
|
578721
|
+
[truncated_by_context_budget: retained higher-priority current intent/evidence]` : content;
|
|
578722
|
+
if (!isReservedTransactionMessage && !isPriorityIntent && !bounded) {
|
|
578723
|
+
continue;
|
|
578724
|
+
}
|
|
578725
|
+
kept.push(typeof message2.content === "string" ? { ...message2, content: bounded } : message2);
|
|
578726
|
+
if (!isReservedTransactionMessage && !isPriorityIntent) {
|
|
578727
|
+
remaining = Math.max(0, remaining - bounded.length);
|
|
578728
|
+
}
|
|
578729
|
+
}
|
|
578730
|
+
return kept;
|
|
578731
|
+
}
|
|
578681
578732
|
function collapseWhitespace(text2) {
|
|
578682
578733
|
return text2.replace(/\r\n/g, "\n").split("\n").map((line) => line.trimEnd()).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
578683
578734
|
}
|
|
@@ -578710,6 +578761,79 @@ function messageText(content) {
|
|
|
578710
578761
|
return "";
|
|
578711
578762
|
}).filter(Boolean).join("\n");
|
|
578712
578763
|
}
|
|
578764
|
+
function toolCallIds(message2) {
|
|
578765
|
+
const calls = message2["tool_calls"];
|
|
578766
|
+
if (!Array.isArray(calls))
|
|
578767
|
+
return [];
|
|
578768
|
+
return calls.flatMap((call) => {
|
|
578769
|
+
if (!call || typeof call !== "object")
|
|
578770
|
+
return [];
|
|
578771
|
+
const id2 = call["id"];
|
|
578772
|
+
return typeof id2 === "string" && id2 ? [id2] : [];
|
|
578773
|
+
});
|
|
578774
|
+
}
|
|
578775
|
+
function hasToolCallsMetadata(message2) {
|
|
578776
|
+
return Array.isArray(message2["tool_calls"]);
|
|
578777
|
+
}
|
|
578778
|
+
function linkedToolCallId(message2) {
|
|
578779
|
+
const id2 = message2["tool_call_id"];
|
|
578780
|
+
return typeof id2 === "string" && id2 ? id2 : null;
|
|
578781
|
+
}
|
|
578782
|
+
function latestResolvedToolTransaction(messages2) {
|
|
578783
|
+
const resultIndexesById = /* @__PURE__ */ new Map();
|
|
578784
|
+
for (let index = 0; index < messages2.length; index++) {
|
|
578785
|
+
const message2 = messages2[index];
|
|
578786
|
+
if (message2.role !== "tool")
|
|
578787
|
+
continue;
|
|
578788
|
+
const id2 = linkedToolCallId(message2);
|
|
578789
|
+
if (!id2)
|
|
578790
|
+
continue;
|
|
578791
|
+
const indexes = resultIndexesById.get(id2) ?? [];
|
|
578792
|
+
indexes.push(index);
|
|
578793
|
+
resultIndexesById.set(id2, indexes);
|
|
578794
|
+
}
|
|
578795
|
+
for (let index = messages2.length - 1; index >= 0; index--) {
|
|
578796
|
+
const message2 = messages2[index];
|
|
578797
|
+
if (message2.role !== "assistant")
|
|
578798
|
+
continue;
|
|
578799
|
+
const callIds = toolCallIds(message2);
|
|
578800
|
+
if (callIds.length === 0 || !callIds.every((id2) => resultIndexesById.has(id2))) {
|
|
578801
|
+
continue;
|
|
578802
|
+
}
|
|
578803
|
+
const transaction = /* @__PURE__ */ new Set([index]);
|
|
578804
|
+
for (const id2 of callIds) {
|
|
578805
|
+
for (const resultIndex of resultIndexesById.get(id2) ?? []) {
|
|
578806
|
+
transaction.add(resultIndex);
|
|
578807
|
+
}
|
|
578808
|
+
}
|
|
578809
|
+
return transaction;
|
|
578810
|
+
}
|
|
578811
|
+
return /* @__PURE__ */ new Set();
|
|
578812
|
+
}
|
|
578813
|
+
function modelFacingReservedChars(message2) {
|
|
578814
|
+
const content = messageText(message2.content);
|
|
578815
|
+
const cap = message2.role === "tool" ? MODEL_FACING_TOOL_CHAR_CAP : message2.role === "system" ? MODEL_FACING_SYSTEM_CHAR_CAP : content.length;
|
|
578816
|
+
return Math.min(content.length, cap);
|
|
578817
|
+
}
|
|
578818
|
+
function retireLinkedAssistantReadIntents(messages2) {
|
|
578819
|
+
const resolvedToolCallIds = new Set(messages2.filter((message2) => message2.role === "tool").map(linkedToolCallId).filter((id2) => id2 !== null));
|
|
578820
|
+
return messages2.map((message2, index) => {
|
|
578821
|
+
const callIds = toolCallIds(message2);
|
|
578822
|
+
let nextNonSystemMessage;
|
|
578823
|
+
for (let candidateIndex = index + 1; candidateIndex < messages2.length; candidateIndex++) {
|
|
578824
|
+
const candidate = messages2[candidateIndex];
|
|
578825
|
+
if (candidate.role === "system")
|
|
578826
|
+
continue;
|
|
578827
|
+
nextNonSystemMessage = candidate;
|
|
578828
|
+
break;
|
|
578829
|
+
}
|
|
578830
|
+
const hasLegacyAdjacentToolResult = message2.role === "assistant" && !hasToolCallsMetadata(message2) && nextNonSystemMessage?.role === "tool" && linkedToolCallId(nextNonSystemMessage) === null;
|
|
578831
|
+
if (message2.role !== "assistant" || typeof message2.content !== "string" || !(callIds.some((id2) => resolvedToolCallIds.has(id2)) || hasLegacyAdjacentToolResult) || !/\b(?:i|we)\s+(?:need|will|should|have)\s+to\s+(?:read|inspect|open)\b/i.test(message2.content)) {
|
|
578832
|
+
return message2;
|
|
578833
|
+
}
|
|
578834
|
+
return { ...message2, content: ASSISTANT_READ_INTENT_RETIRED_MARKER };
|
|
578835
|
+
});
|
|
578836
|
+
}
|
|
578713
578837
|
function runtimeControlSemanticKey(content) {
|
|
578714
578838
|
const normalized = content.replace(/\s+/g, " ").trim().toLowerCase();
|
|
578715
578839
|
if (!normalized)
|
|
@@ -578859,7 +578983,7 @@ function prepareModelFacingApiMessages(input) {
|
|
|
578859
578983
|
const insertAt = preserveFirstSystem && deduped[0]?.role === "system" ? 1 : 0;
|
|
578860
578984
|
deduped.splice(insertAt, 0, goalMessage);
|
|
578861
578985
|
}
|
|
578862
|
-
return deduped;
|
|
578986
|
+
return retireLinkedAssistantReadIntents(applyModelFacingBudget(deduped, preserveFirstSystem));
|
|
578863
578987
|
}
|
|
578864
578988
|
function deriveCurrentGoal(input) {
|
|
578865
578989
|
const explicit = sanitizeModelVisibleContextText(input.explicitGoal ?? "");
|
|
@@ -578927,15 +579051,22 @@ function compileContextFrameV2(input) {
|
|
|
578927
579051
|
warnings: [...new Set(warnings)],
|
|
578928
579052
|
admittedSignals: frame.included.length,
|
|
578929
579053
|
rejectedSignals: normalized.rejected.length,
|
|
578930
|
-
hadConcreteGoal: goal.concrete
|
|
579054
|
+
hadConcreteGoal: goal.concrete,
|
|
579055
|
+
admittedChars: frame.included.reduce((total, signal) => total + signal.content.length, 0),
|
|
579056
|
+
droppedChars: normalized.rejected.reduce((total, signal) => total + signal.content.length, 0),
|
|
579057
|
+
droppedSources: normalized.rejected.map((signal) => signal.source)
|
|
578931
579058
|
}
|
|
578932
579059
|
};
|
|
578933
579060
|
}
|
|
578934
|
-
var RESTORE_NOISE_LINE_RE, RUNTIME_GUIDANCE_RE, ACTIVE_CONTEXT_RE;
|
|
579061
|
+
var MODEL_FACING_CONTEXT_CHAR_BUDGET, MODEL_FACING_TOOL_CHAR_CAP, MODEL_FACING_SYSTEM_CHAR_CAP, ASSISTANT_READ_INTENT_RETIRED_MARKER, RESTORE_NOISE_LINE_RE, RUNTIME_GUIDANCE_RE, ACTIVE_CONTEXT_RE;
|
|
578935
579062
|
var init_context_compiler = __esm({
|
|
578936
579063
|
"packages/orchestrator/dist/context-compiler.js"() {
|
|
578937
579064
|
"use strict";
|
|
578938
579065
|
init_context_fabric();
|
|
579066
|
+
MODEL_FACING_CONTEXT_CHAR_BUDGET = 48e3;
|
|
579067
|
+
MODEL_FACING_TOOL_CHAR_CAP = 6e3;
|
|
579068
|
+
MODEL_FACING_SYSTEM_CHAR_CAP = 8e3;
|
|
579069
|
+
ASSISTANT_READ_INTENT_RETIRED_MARKER = "[assistant read intent retired: the linked tool result is already available; decide from that evidence instead of restating a read plan]";
|
|
578939
579070
|
RESTORE_NOISE_LINE_RE = /^\s*(?:🔊|E Task timeout reached|E Incomplete:|⚠ Task incomplete|Tokens:\s*[\d,]+|▹\s*continue\b|·\s*(?:Starting fresh|Context (?:auto-)?restored|Nexus P2P network connected|REST API:|Voice feedback enabled|Memory maintenance:)|.*\bSHELL TRANSCRIPT\b.*|.*speaker emoji.*).*$/i;
|
|
578940
579071
|
RUNTIME_GUIDANCE_RE = /\[RUNTIME_GUIDANCE_INTAKE v\d+\][\s\S]*?<<<RUNTIME_GUIDANCE>>>\s*([\s\S]*?)\s*<<<END_RUNTIME_GUIDANCE>>>[\s\S]*?\[\/RUNTIME_GUIDANCE_INTAKE\]/g;
|
|
578941
579072
|
ACTIVE_CONTEXT_RE = /\[ACTIVE CONTEXT FRAME\][\s\S]*?(?=\n\[ACTIVE CONTEXT FRAME\]|$)/g;
|
|
@@ -580067,8 +580198,8 @@ var init_adversaryStream = __esm({
|
|
|
580067
580198
|
return;
|
|
580068
580199
|
try {
|
|
580069
580200
|
const { writeFileSync: writeFileSync97, mkdirSync: mkdirSync114, existsSync: existsSync177 } = __require("node:fs");
|
|
580070
|
-
const { dirname:
|
|
580071
|
-
const dir =
|
|
580201
|
+
const { dirname: dirname59 } = __require("node:path");
|
|
580202
|
+
const dir = dirname59(this.persistPath);
|
|
580072
580203
|
if (!existsSync177(dir))
|
|
580073
580204
|
mkdirSync114(dir, { recursive: true });
|
|
580074
580205
|
writeFileSync97(this.persistPath, JSON.stringify({ ledger: this.ledger }, null, 2));
|
|
@@ -587788,8 +587919,6 @@ function flattenErrorText(err) {
|
|
|
587788
587919
|
function computeEffectiveThink(params) {
|
|
587789
587920
|
if (process.env["OMNIUS_FORCE_NO_THINK"] === "1")
|
|
587790
587921
|
return false;
|
|
587791
|
-
if (process.env["OMNIUS_ENABLE_THINKING"] !== "1")
|
|
587792
|
-
return false;
|
|
587793
587922
|
if (params.suppressed)
|
|
587794
587923
|
return false;
|
|
587795
587924
|
if (params.hasTools)
|
|
@@ -587826,6 +587955,9 @@ function sanitizeHistoryThink(messages2) {
|
|
|
587826
587955
|
const collapsed = collapseDegenerateAssistantRepetition(content);
|
|
587827
587956
|
content = collapsed ?? content;
|
|
587828
587957
|
}
|
|
587958
|
+
if (m2.role === "assistant" && Array.isArray(m2.tool_calls) && m2.tool_calls.some((call) => referencedToolCallIds.has(call.id)) && /\b(?:i|we)\s+(?:need|will|should|have)\s+to\s+(?:read|inspect|open)\b/i.test(content)) {
|
|
587959
|
+
content = "[assistant read intent retired: the linked tool result is already available; decide from that evidence instead of restating a read plan]";
|
|
587960
|
+
}
|
|
587829
587961
|
return { ...m2, content };
|
|
587830
587962
|
});
|
|
587831
587963
|
const sanitized = [];
|
|
@@ -588178,6 +588310,18 @@ var init_agenticRunner = __esm({
|
|
|
588178
588310
|
_onTypedEvent;
|
|
588179
588311
|
handlers = [];
|
|
588180
588312
|
pendingUserMessages = [];
|
|
588313
|
+
/** Typed source of truth for user steering; pendingUserMessages remains a compatibility queue. */
|
|
588314
|
+
pendingSteeringInputs = [];
|
|
588315
|
+
_steeringSequence = 0;
|
|
588316
|
+
_taskEpoch = 0;
|
|
588317
|
+
_activeRunId = "";
|
|
588318
|
+
/** Session storage is retained for compatibility; superseded task leaves are hidden from active guards. */
|
|
588319
|
+
_supersededTodoIds = /* @__PURE__ */ new Set();
|
|
588320
|
+
/** Cross-task restoration is opt-in only for an explicit continuation/append. */
|
|
588321
|
+
_allowImplicitContinuation = false;
|
|
588322
|
+
/** Abort scope for only the in-flight model/tool turn. Never use for permanent stop. */
|
|
588323
|
+
_turnAbortController = new AbortController();
|
|
588324
|
+
_pendingSteeringPreemption = null;
|
|
588181
588325
|
pendingRuntimeGuidanceMessages = [];
|
|
588182
588326
|
aborted = false;
|
|
588183
588327
|
_abortController = new AbortController();
|
|
@@ -588678,6 +588822,9 @@ var init_agenticRunner = __esm({
|
|
|
588678
588822
|
_branchEvidenceCache = /* @__PURE__ */ new Map();
|
|
588679
588823
|
/** Latest curated node per canonical path for safe post-compaction recovery. */
|
|
588680
588824
|
_branchEvidenceByPath = /* @__PURE__ */ new Map();
|
|
588825
|
+
/** Exact read fingerprints resolved from canonical evidence, not a fresh tool call. */
|
|
588826
|
+
_resolvedReadEvidence = /* @__PURE__ */ new Map();
|
|
588827
|
+
_deterministicNarrowReadFallbacks = /* @__PURE__ */ new Set();
|
|
588681
588828
|
// OBS-1: durable "current observed state" for non-file_read tool outputs
|
|
588682
588829
|
// (shell/web_fetch/list_directory/…). EvidenceLedger's counterpart for the
|
|
588683
588830
|
// observation channels that were previously invisible after compaction —
|
|
@@ -588786,7 +588933,7 @@ var init_agenticRunner = __esm({
|
|
|
588786
588933
|
return this._workboard;
|
|
588787
588934
|
}
|
|
588788
588935
|
const dir = this._workboardDir();
|
|
588789
|
-
const runId = this.
|
|
588936
|
+
const runId = this.currentArtifactRunId();
|
|
588790
588937
|
const existing = loadWorkboardSnapshot(dir, runId);
|
|
588791
588938
|
if (existing) {
|
|
588792
588939
|
this._workboard = this._seedWorkboardCardsIfNeeded(existing, goal);
|
|
@@ -588897,7 +589044,7 @@ var init_agenticRunner = __esm({
|
|
|
588897
589044
|
if (!diagnosis.createRecoveryCard && count < 2)
|
|
588898
589045
|
return;
|
|
588899
589046
|
const dir = this._workboardDir();
|
|
588900
|
-
const runId = this.
|
|
589047
|
+
const runId = this.currentArtifactRunId();
|
|
588901
589048
|
const actor = this.options.subAgent ? "sub-agent" : "agent";
|
|
588902
589049
|
const cardInput = this._failureRecoveryCardInput(diagnosis);
|
|
588903
589050
|
try {
|
|
@@ -589009,7 +589156,7 @@ var init_agenticRunner = __esm({
|
|
|
589009
589156
|
return;
|
|
589010
589157
|
const cards = activeLeaves.map((todo) => this._todoWorkboardCardInput(todo, this._todoPath(todo, index)));
|
|
589011
589158
|
const dir = this._workboardDir();
|
|
589012
|
-
const runId = this.
|
|
589159
|
+
const runId = this.currentArtifactRunId();
|
|
589013
589160
|
const actor = this.options.subAgent ? "sub-agent" : "agent";
|
|
589014
589161
|
try {
|
|
589015
589162
|
let board = readActiveWorkboardSnapshot(dir, runId) ?? this._workboard ?? null;
|
|
@@ -589230,7 +589377,7 @@ ${parts.join("\n")}
|
|
|
589230
589377
|
}
|
|
589231
589378
|
_currentWorkboardSnapshotForFrame() {
|
|
589232
589379
|
const dir = this._workboardDir();
|
|
589233
|
-
const fromDisk = readActiveWorkboardSnapshot(dir, this.
|
|
589380
|
+
const fromDisk = readActiveWorkboardSnapshot(dir, this.currentArtifactRunId());
|
|
589234
589381
|
const goal = this._taskState.originalGoal || this._taskState.goal || "";
|
|
589235
589382
|
const initialCards = this._initialWorkboardCardsForGoal(goal);
|
|
589236
589383
|
if (fromDisk) {
|
|
@@ -589359,8 +589506,9 @@ ${parts.join("\n")}
|
|
|
589359
589506
|
case "creative_pivot_or_research":
|
|
589360
589507
|
return "a FUNDAMENTALLY different approach: web_search the exact error/blocker to find how it is solved, or pivot to a method you have NOT tried — not a variant of what failed, and NOT task_complete";
|
|
589361
589508
|
case "report_blocked":
|
|
589509
|
+
return 'call task_complete with status="blocked", a concise external blocker, and the next prerequisite; do not create a bookkeeping artifact as the recovery action';
|
|
589362
589510
|
case "report_incomplete":
|
|
589363
|
-
return "a fundamentally different approach or web_search the blocker
|
|
589511
|
+
return 'call task_complete with status="incomplete" or status="blocked" only when the evidence shows no remaining substantive action; otherwise take a fundamentally different approach or web_search the blocker';
|
|
589364
589512
|
default:
|
|
589365
589513
|
return "choose the narrowest tool that advances the current card";
|
|
589366
589514
|
}
|
|
@@ -589525,7 +589673,7 @@ ${parts.join("\n")}
|
|
|
589525
589673
|
const discovery = cards.get("discover-current-state");
|
|
589526
589674
|
if (discovery && discovery.status !== "verified" && discovery.evidence.length > 0) {
|
|
589527
589675
|
const completed = completeWorkboardCard(dir, {
|
|
589528
|
-
runId: this.
|
|
589676
|
+
runId: this.currentArtifactRunId(),
|
|
589529
589677
|
cardId: discovery.id,
|
|
589530
589678
|
actor,
|
|
589531
589679
|
outcome: "completed",
|
|
@@ -589536,7 +589684,7 @@ ${parts.join("\n")}
|
|
|
589536
589684
|
const completedDiscovery = cards.get("discover-current-state");
|
|
589537
589685
|
if (completedDiscovery?.status === "completed") {
|
|
589538
589686
|
const verified = completeWorkboardCard(dir, {
|
|
589539
|
-
runId: this.
|
|
589687
|
+
runId: this.currentArtifactRunId(),
|
|
589540
589688
|
cardId: completedDiscovery.id,
|
|
589541
589689
|
actor,
|
|
589542
589690
|
outcome: "verified",
|
|
@@ -589549,7 +589697,7 @@ ${parts.join("\n")}
|
|
|
589549
589697
|
const implementation2 = cards.get("implement-repair");
|
|
589550
589698
|
if (implementation2 && (implementation2.status === "open" || implementation2.status === "needs_changes")) {
|
|
589551
589699
|
current = updateWorkboardCard(dir, {
|
|
589552
|
-
runId: this.
|
|
589700
|
+
runId: this.currentArtifactRunId(),
|
|
589553
589701
|
cardId: implementation2.id,
|
|
589554
589702
|
actor,
|
|
589555
589703
|
updates: { status: "in_progress", lane: "worker" },
|
|
@@ -589563,7 +589711,7 @@ ${parts.join("\n")}
|
|
|
589563
589711
|
const integration = cards.get("integrate-and-run");
|
|
589564
589712
|
if (integration && this._workboardHasEditEvidence(implementation2) && (integration.status === "open" || integration.status === "needs_changes")) {
|
|
589565
589713
|
current = updateWorkboardCard(dir, {
|
|
589566
|
-
runId: this.
|
|
589714
|
+
runId: this.currentArtifactRunId(),
|
|
589567
589715
|
cardId: integration.id,
|
|
589568
589716
|
actor,
|
|
589569
589717
|
updates: { status: "in_progress", lane: "verification" },
|
|
@@ -589618,7 +589766,7 @@ ${parts.join("\n")}
|
|
|
589618
589766
|
return;
|
|
589619
589767
|
}
|
|
589620
589768
|
attachWorkboardEvidence(dir, {
|
|
589621
|
-
runId: this.
|
|
589769
|
+
runId: this.currentArtifactRunId(),
|
|
589622
589770
|
cardId: targetCard.id,
|
|
589623
589771
|
actor,
|
|
589624
589772
|
evidence
|
|
@@ -589633,7 +589781,7 @@ ${parts.join("\n")}
|
|
|
589633
589781
|
return;
|
|
589634
589782
|
try {
|
|
589635
589783
|
const dir = this._workboardDir();
|
|
589636
|
-
const refreshed = readActiveWorkboardSnapshot(dir, this.
|
|
589784
|
+
const refreshed = readActiveWorkboardSnapshot(dir, this.currentArtifactRunId());
|
|
589637
589785
|
if (refreshed)
|
|
589638
589786
|
this._workboard = refreshed;
|
|
589639
589787
|
} catch {
|
|
@@ -589824,7 +589972,7 @@ ${parts.join("\n")}
|
|
|
589824
589972
|
stage: stage2,
|
|
589825
589973
|
agentType,
|
|
589826
589974
|
sessionId: this._sessionId,
|
|
589827
|
-
runId: this.
|
|
589975
|
+
runId: this.currentArtifactRunId(),
|
|
589828
589976
|
turn,
|
|
589829
589977
|
attempt,
|
|
589830
589978
|
model: this._backendModelLabel(this.backend),
|
|
@@ -589849,7 +589997,7 @@ ${parts.join("\n")}
|
|
|
589849
589997
|
recordDebugContextWindowDump({
|
|
589850
589998
|
cwd: this.authoritativeWorkingDirectory(),
|
|
589851
589999
|
stateDir: this.omniusStateDir(),
|
|
589852
|
-
runId: this.
|
|
590000
|
+
runId: this.currentArtifactRunId(),
|
|
589853
590001
|
sessionId: this._sessionId,
|
|
589854
590002
|
record
|
|
589855
590003
|
});
|
|
@@ -590072,7 +590220,7 @@ ${parts.join("\n")}
|
|
|
590072
590220
|
try {
|
|
590073
590221
|
const dir = _pathJoin(this.omniusStateDir(), "completion-contracts");
|
|
590074
590222
|
_fsMkdirSync(dir, { recursive: true });
|
|
590075
|
-
_fsWriteFileSync(_pathJoin(dir, `${this.
|
|
590223
|
+
_fsWriteFileSync(_pathJoin(dir, `${this.currentArtifactRunId()}.json`), JSON.stringify({
|
|
590076
590224
|
sessionId: this._sessionId,
|
|
590077
590225
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
590078
590226
|
contract
|
|
@@ -590621,7 +590769,7 @@ Your hypotheses MUST address this specific error, not generic causes.
|
|
|
590621
590769
|
stage: opts?.dumpStage ?? "aux_inference",
|
|
590622
590770
|
agentType: "internal",
|
|
590623
590771
|
sessionId: this._sessionId,
|
|
590624
|
-
runId: this.
|
|
590772
|
+
runId: this.currentArtifactRunId(),
|
|
590625
590773
|
model: this._backendModelLabel(this.backend),
|
|
590626
590774
|
cwd: this._workingDirectory || process.cwd(),
|
|
590627
590775
|
request: r2
|
|
@@ -591135,7 +591283,8 @@ Pick the SMALLEST concrete deliverable from the spec — typically the project e
|
|
|
591135
591283
|
readSessionTodos() {
|
|
591136
591284
|
try {
|
|
591137
591285
|
const sid = this._sessionId || process.env["OMNIUS_SESSION_ID"] || "default";
|
|
591138
|
-
|
|
591286
|
+
const todos = readTodos(sid);
|
|
591287
|
+
return this._supersededTodoIds.size === 0 ? todos : todos.filter((todo) => !this._supersededTodoIds.has(todo.id));
|
|
591139
591288
|
} catch {
|
|
591140
591289
|
return null;
|
|
591141
591290
|
}
|
|
@@ -591667,13 +591816,13 @@ ${extras.join("\n")}`;
|
|
|
591667
591816
|
if (!existing) {
|
|
591668
591817
|
this._workboard = addWorkboardCard(dir, {
|
|
591669
591818
|
...compileFixCardToWorkboardInput(card),
|
|
591670
|
-
runId: this.
|
|
591819
|
+
runId: this.currentArtifactRunId(),
|
|
591671
591820
|
actor,
|
|
591672
591821
|
decisionReason: "compile_error_card_created"
|
|
591673
591822
|
});
|
|
591674
591823
|
} else if (card.status === "assigned" && existing.status === "open") {
|
|
591675
591824
|
this._workboard = updateWorkboardCard(dir, {
|
|
591676
|
-
runId: this.
|
|
591825
|
+
runId: this.currentArtifactRunId(),
|
|
591677
591826
|
cardId: card.id,
|
|
591678
591827
|
actor,
|
|
591679
591828
|
updates: {
|
|
@@ -591694,7 +591843,7 @@ ${extras.join("\n")}`;
|
|
|
591694
591843
|
"patch touched only owned files"
|
|
591695
591844
|
];
|
|
591696
591845
|
this._workboard = attachWorkboardEvidence(dir, {
|
|
591697
|
-
runId: this.
|
|
591846
|
+
runId: this.currentArtifactRunId(),
|
|
591698
591847
|
cardId: card.id,
|
|
591699
591848
|
actor,
|
|
591700
591849
|
evidence: {
|
|
@@ -591716,7 +591865,7 @@ ${extras.join("\n")}`;
|
|
|
591716
591865
|
const wbCard = active?.cards.find((item) => item.id === card.id);
|
|
591717
591866
|
if (wbCard && wbCard.status !== "completed" && wbCard.status !== "verified") {
|
|
591718
591867
|
this._workboard = completeWorkboardCard(dir, {
|
|
591719
|
-
runId: this.
|
|
591868
|
+
runId: this.currentArtifactRunId(),
|
|
591720
591869
|
cardId: card.id,
|
|
591721
591870
|
actor,
|
|
591722
591871
|
outcome: "completed",
|
|
@@ -591728,7 +591877,7 @@ ${extras.join("\n")}`;
|
|
|
591728
591877
|
const latestCard = latest?.cards.find((item) => item.id === card.id);
|
|
591729
591878
|
if (latestCard?.status === "completed") {
|
|
591730
591879
|
this._workboard = completeWorkboardCard(dir, {
|
|
591731
|
-
runId: this.
|
|
591880
|
+
runId: this.currentArtifactRunId(),
|
|
591732
591881
|
cardId: card.id,
|
|
591733
591882
|
actor,
|
|
591734
591883
|
outcome: "verified",
|
|
@@ -591749,7 +591898,7 @@ ${extras.join("\n")}`;
|
|
|
591749
591898
|
if (!existing || existing.status !== "open")
|
|
591750
591899
|
return;
|
|
591751
591900
|
this._workboard = updateWorkboardCard(dir, {
|
|
591752
|
-
runId: this.
|
|
591901
|
+
runId: this.currentArtifactRunId(),
|
|
591753
591902
|
cardId: card.id,
|
|
591754
591903
|
actor: this.options.subAgent ? "sub-agent" : "agent",
|
|
591755
591904
|
updates: {
|
|
@@ -591773,6 +591922,11 @@ ${extras.join("\n")}`;
|
|
|
591773
591922
|
state.verifierDirtySinceTurn = turn;
|
|
591774
591923
|
state.lastVerifierPassedTurn = null;
|
|
591775
591924
|
state.lastMutationTurn = turn;
|
|
591925
|
+
this._focusSupervisor?.markCompletionBlocked({
|
|
591926
|
+
turn,
|
|
591927
|
+
reason: "A source mutation invalidated the declared verifier; verifier evidence now owns the active focus.",
|
|
591928
|
+
requiredNextAction: "run_verification"
|
|
591929
|
+
});
|
|
591776
591930
|
for (const card of state.cards) {
|
|
591777
591931
|
if (card.status === "assigned" && (normalized.length === 0 || normalized.some((pathValue) => card.ownedFiles.some((ownedPath) => this._pathsOverlapForVerifier(pathValue, ownedPath))))) {
|
|
591778
591932
|
card.status = "patched";
|
|
@@ -591825,8 +591979,9 @@ ${extras.join("\n")}`;
|
|
|
591825
591979
|
state.preflightBlockStreak = 0;
|
|
591826
591980
|
return null;
|
|
591827
591981
|
}
|
|
591828
|
-
if (!shellLikelyMutatesFilesystem)
|
|
591982
|
+
if (!shellLikelyMutatesFilesystem) {
|
|
591829
591983
|
return null;
|
|
591984
|
+
}
|
|
591830
591985
|
const extraction = extractShellMutationPaths(command, {
|
|
591831
591986
|
workingDir: this.authoritativeWorkingDirectory()
|
|
591832
591987
|
});
|
|
@@ -591837,7 +591992,7 @@ ${extras.join("\n")}`;
|
|
|
591837
591992
|
} else if (!this._isProjectEditTool(toolName)) {
|
|
591838
591993
|
return null;
|
|
591839
591994
|
}
|
|
591840
|
-
const yieldAfter =
|
|
591995
|
+
const yieldAfter = Number.MAX_SAFE_INTEGER;
|
|
591841
591996
|
const streak = (state.preflightBlockStreak ?? 0) + 1;
|
|
591842
591997
|
if (streak > yieldAfter) {
|
|
591843
591998
|
state.preflightBlockStreak = 0;
|
|
@@ -591869,7 +592024,7 @@ ${extras.join("\n")}`;
|
|
|
591869
592024
|
`lastMutationTurn: ${state.lastMutationTurn}`,
|
|
591870
592025
|
`lastVerifierRunTurn: ${state.lastVerifierRunTurn}`,
|
|
591871
592026
|
`blockedTool: ${toolName}`,
|
|
591872
|
-
`consecutiveBlocks: ${streak}
|
|
592027
|
+
`consecutiveBlocks: ${streak} (verifier focus is retained until a live verifier settles)`
|
|
591873
592028
|
].join("\n");
|
|
591874
592029
|
this.emit({
|
|
591875
592030
|
type: "status",
|
|
@@ -592330,6 +592485,9 @@ ${result.output ?? ""}`;
|
|
|
592330
592485
|
return /^\s*(BLOCKED|INCOMPLETE|NEEDS[_ -]?INPUT)\b\s*:?/i.test(summary);
|
|
592331
592486
|
}
|
|
592332
592487
|
_shouldBypassTodoCompletionGuardForTaskComplete(args) {
|
|
592488
|
+
if (completionStatusFromTaskCompleteArgs(args) === "blocked") {
|
|
592489
|
+
return this._hasEvidenceBackedBlockedCompletion(args);
|
|
592490
|
+
}
|
|
592333
592491
|
if (!this._taskCompleteArgsReportDegraded(args))
|
|
592334
592492
|
return false;
|
|
592335
592493
|
if (this._completionIncompleteVerification)
|
|
@@ -592387,6 +592545,32 @@ ${result.output ?? ""}`;
|
|
|
592387
592545
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
592388
592546
|
});
|
|
592389
592547
|
}
|
|
592548
|
+
/**
|
|
592549
|
+
* Admit a BLOCKED terminal state only when every unresolved leaf is blocked
|
|
592550
|
+
* by observed external evidence. Controller-authored notes, todo churn, and
|
|
592551
|
+
* recovery artifacts are deliberately not evidence: otherwise the recovery
|
|
592552
|
+
* loop can manufacture its own next blocker.
|
|
592553
|
+
*/
|
|
592554
|
+
_hasEvidenceBackedBlockedCompletion(args) {
|
|
592555
|
+
if (completionStatusFromTaskCompleteArgs(args) !== "blocked")
|
|
592556
|
+
return false;
|
|
592557
|
+
const summary = extractTaskCompleteSummary(args).trim();
|
|
592558
|
+
if (!summary)
|
|
592559
|
+
return false;
|
|
592560
|
+
const leaves = openTodoLeaves(this._normalizeTodosForPrompt(this.readSessionTodos() ?? [])).filter((todo) => todo.status !== "completed");
|
|
592561
|
+
if (leaves.length === 0)
|
|
592562
|
+
return false;
|
|
592563
|
+
const controllerArtifact = /(?:status artifact|blocker note|recovery (?:note|report|artifact)|todo_(?:write|read)|workboard|completion ledger|session diary)/i;
|
|
592564
|
+
const externalBlocker = /(?:enoent|not found|missing|permission|access denied|credential|network|remote|upstream|service unavailable|waiting for|user input|third[- ]party)/i;
|
|
592565
|
+
const hasObservedExternalFailure = this._recentFailures.some((failure) => externalBlocker.test(`${failure.error || ""}
|
|
592566
|
+
${failure.output || ""}`));
|
|
592567
|
+
if (!hasObservedExternalFailure)
|
|
592568
|
+
return false;
|
|
592569
|
+
return leaves.every((todo) => {
|
|
592570
|
+
const blocker = typeof todo.blocker === "string" ? todo.blocker.trim() : "";
|
|
592571
|
+
return todo.status === "blocked" && blocker.length > 0 && externalBlocker.test(blocker) && !controllerArtifact.test(blocker);
|
|
592572
|
+
});
|
|
592573
|
+
}
|
|
592390
592574
|
buildTodoCompletionGuard(openItems) {
|
|
592391
592575
|
const list = openItems.slice(0, 20).map((t2, i2) => `${i2 + 1}. [${t2.status}] ${t2.content}`).join("\n");
|
|
592392
592576
|
const full = this.readSessionTodos() || [];
|
|
@@ -596594,8 +596778,48 @@ ${notice}`;
|
|
|
596594
596778
|
}
|
|
596595
596779
|
/** Inject a user message into the running conversation (mid-task steering) */
|
|
596596
596780
|
injectUserMessage(content) {
|
|
596597
|
-
this.
|
|
596781
|
+
this.injectSteeringInput({
|
|
596782
|
+
inputId: `legacy-steering-${Date.now()}-${++this._steeringSequence}`,
|
|
596783
|
+
content,
|
|
596784
|
+
source: "legacy-injectUserMessage",
|
|
596785
|
+
receivedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
596786
|
+
intent: "append",
|
|
596787
|
+
state: "received",
|
|
596788
|
+
taskEpoch: this._taskEpoch || void 0
|
|
596789
|
+
});
|
|
596790
|
+
}
|
|
596791
|
+
/**
|
|
596792
|
+
* Queue a typed user instruction and return an acknowledgement receipt.
|
|
596793
|
+
* The receipt is emitted and ledgered before a redirect can cancel the
|
|
596794
|
+
* active turn, which closes the old bridge-to-runner message-loss race.
|
|
596795
|
+
*/
|
|
596796
|
+
injectSteeringInput(input) {
|
|
596797
|
+
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
596798
|
+
const content = this.scrubUserInput(input.content, "steering-input").trim();
|
|
596799
|
+
const record = {
|
|
596800
|
+
...input,
|
|
596801
|
+
inputId: input.inputId.trim() || `steering-${Date.now()}-${++this._steeringSequence}`,
|
|
596802
|
+
content,
|
|
596803
|
+
source: input.source || "unknown",
|
|
596804
|
+
receivedAt: input.receivedAt || now2,
|
|
596805
|
+
state: "received",
|
|
596806
|
+
taskEpoch: input.taskEpoch ?? (this._taskEpoch || void 0)
|
|
596807
|
+
};
|
|
596808
|
+
this.pendingSteeringInputs.push(record);
|
|
596809
|
+
this._emitSteeringLifecycle(record, "received by runner");
|
|
596810
|
+
if (!content) {
|
|
596811
|
+
record.state = "cancelled";
|
|
596812
|
+
this._emitSteeringLifecycle(record, "empty steering input rejected");
|
|
596813
|
+
return this._steeringReceipt(record);
|
|
596814
|
+
}
|
|
596815
|
+
this.pendingUserMessages.push(content);
|
|
596816
|
+
record.state = "queued";
|
|
596817
|
+
this._emitSteeringLifecycle(record, "queued for next safe turn boundary");
|
|
596818
|
+
if (record.intent === "redirect" || record.intent === "replace" || record.intent === "cancel") {
|
|
596819
|
+
this._requestSteeringPreemption(record);
|
|
596820
|
+
}
|
|
596598
596821
|
this._trajectoryDirtyCauses.add("user_steering");
|
|
596822
|
+
return this._steeringReceipt(record);
|
|
596599
596823
|
}
|
|
596600
596824
|
/** Inject bounded runtime guidance without treating it as user steering. */
|
|
596601
596825
|
injectRuntimeGuidance(content) {
|
|
@@ -596621,12 +596845,22 @@ ${notice}`;
|
|
|
596621
596845
|
retractLastPendingMessage() {
|
|
596622
596846
|
if (this.pendingUserMessages.length === 0)
|
|
596623
596847
|
return null;
|
|
596624
|
-
|
|
596848
|
+
const content = this.pendingUserMessages.pop();
|
|
596849
|
+
const record = [...this.pendingSteeringInputs].reverse().find((candidate) => candidate.content === content && (candidate.state === "queued" || candidate.state === "acknowledged"));
|
|
596850
|
+
if (record) {
|
|
596851
|
+
record.state = "cancelled";
|
|
596852
|
+
if (this._pendingSteeringPreemption?.inputId === record.inputId) {
|
|
596853
|
+
this._pendingSteeringPreemption = null;
|
|
596854
|
+
}
|
|
596855
|
+
this._emitSteeringLifecycle(record, "retracted before consumption");
|
|
596856
|
+
}
|
|
596857
|
+
return content;
|
|
596625
596858
|
}
|
|
596626
596859
|
/** Abort the current task run — cancels in-flight requests and kills child processes */
|
|
596627
596860
|
abort() {
|
|
596628
596861
|
this.aborted = true;
|
|
596629
596862
|
this._abortController.abort();
|
|
596863
|
+
this._turnAbortController.abort();
|
|
596630
596864
|
const shellTool = this.tools.get("shell");
|
|
596631
596865
|
if (shellTool && typeof shellTool.killAll === "function") {
|
|
596632
596866
|
shellTool.killAll();
|
|
@@ -596638,7 +596872,245 @@ ${notice}`;
|
|
|
596638
596872
|
}
|
|
596639
596873
|
/** Get the current abort signal for passing to fetch/spawn */
|
|
596640
596874
|
get abortSignal() {
|
|
596641
|
-
return this.
|
|
596875
|
+
return this._turnAbortController.signal;
|
|
596876
|
+
}
|
|
596877
|
+
/** Current run identity and epoch, exposed for frontends that persist intake. */
|
|
596878
|
+
get taskEpoch() {
|
|
596879
|
+
return this._taskEpoch;
|
|
596880
|
+
}
|
|
596881
|
+
get activeRunId() {
|
|
596882
|
+
return this._activeRunId;
|
|
596883
|
+
}
|
|
596884
|
+
/** Immutable run key for artifacts; sessionId remains correlation metadata. */
|
|
596885
|
+
currentArtifactRunId() {
|
|
596886
|
+
return this._activeRunId || this._sessionId;
|
|
596887
|
+
}
|
|
596888
|
+
_steeringReceipt(record) {
|
|
596889
|
+
return {
|
|
596890
|
+
inputId: record.inputId,
|
|
596891
|
+
intent: record.intent,
|
|
596892
|
+
state: record.state,
|
|
596893
|
+
taskEpoch: record.taskEpoch,
|
|
596894
|
+
runId: this._activeRunId || void 0,
|
|
596895
|
+
acceptedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
596896
|
+
};
|
|
596897
|
+
}
|
|
596898
|
+
/**
|
|
596899
|
+
* Retire a satisfied read-plan from the exact outbound request. Tool-call
|
|
596900
|
+
* metadata and tool-result links are retained untouched for provider
|
|
596901
|
+
* protocol correctness; only stale assistant-visible planning prose changes.
|
|
596902
|
+
*/
|
|
596903
|
+
_retireLinkedAssistantReadIntents(messages2) {
|
|
596904
|
+
const resolvedToolCallIds = new Set(messages2.filter((message2) => message2.role === "tool" && message2.tool_call_id).map((message2) => message2.tool_call_id));
|
|
596905
|
+
for (const message2 of messages2) {
|
|
596906
|
+
if (message2.role !== "assistant" || typeof message2.content !== "string" || !Array.isArray(message2.tool_calls) || !message2.tool_calls.some((call) => resolvedToolCallIds.has(call.id)) || !/\b(?:i|we)\s+(?:need|will|should|have)\s+to\s+(?:read|inspect|open)\b/i.test(message2.content)) {
|
|
596907
|
+
continue;
|
|
596908
|
+
}
|
|
596909
|
+
message2.content = "[assistant read intent retired: the linked tool result is present below; decide from that evidence rather than planning the same read]";
|
|
596910
|
+
}
|
|
596911
|
+
}
|
|
596912
|
+
_emitSteeringLifecycle(record, reason) {
|
|
596913
|
+
const receipt = this._steeringReceipt(record);
|
|
596914
|
+
this.emit({
|
|
596915
|
+
type: "status",
|
|
596916
|
+
content: `Steering ${record.inputId} ${record.state}: ${reason}`,
|
|
596917
|
+
steering: receipt,
|
|
596918
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
596919
|
+
});
|
|
596920
|
+
appendSteeringLedgerEntry(this._workingDirectory || process.cwd(), {
|
|
596921
|
+
type: "lifecycle",
|
|
596922
|
+
packetId: record.inputId,
|
|
596923
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
596924
|
+
intake: { ...record },
|
|
596925
|
+
summary: reason
|
|
596926
|
+
});
|
|
596927
|
+
}
|
|
596928
|
+
_setBackendTurnAbortSignal(signal) {
|
|
596929
|
+
if (typeof this.backend.setAbortSignal === "function") {
|
|
596930
|
+
this.backend.setAbortSignal(signal);
|
|
596931
|
+
}
|
|
596932
|
+
}
|
|
596933
|
+
_requestSteeringPreemption(record) {
|
|
596934
|
+
this._pendingSteeringPreemption = record;
|
|
596935
|
+
record.state = "acknowledged";
|
|
596936
|
+
this._emitSteeringLifecycle(record, "preemption acknowledged");
|
|
596937
|
+
this._turnAbortController.abort(new Error(`steering ${record.intent}: ${record.inputId}`));
|
|
596938
|
+
const shellTool = this.tools.get("shell");
|
|
596939
|
+
if (shellTool && typeof shellTool.killAll === "function") {
|
|
596940
|
+
shellTool.killAll();
|
|
596941
|
+
}
|
|
596942
|
+
this._turnAbortController = new AbortController();
|
|
596943
|
+
this._setBackendTurnAbortSignal(this._turnAbortController.signal);
|
|
596944
|
+
}
|
|
596945
|
+
_prepareSteeringInputsForRun() {
|
|
596946
|
+
const initialInputs = this.pendingSteeringInputs.filter((record) => record.state === "queued" || record.state === "acknowledged");
|
|
596947
|
+
this._allowImplicitContinuation = initialInputs.some((record) => record.intent === "append" || record.intent === "clarify") && !initialInputs.some((record) => record.intent === "redirect" || record.intent === "replace" || record.intent === "cancel");
|
|
596948
|
+
for (const record of this.pendingSteeringInputs) {
|
|
596949
|
+
if (record.state !== "queued" && record.state !== "acknowledged")
|
|
596950
|
+
continue;
|
|
596951
|
+
if (record.taskEpoch && record.taskEpoch !== this._taskEpoch) {
|
|
596952
|
+
record.state = "superseded";
|
|
596953
|
+
this._emitSteeringLifecycle(record, "superseded by a later task run");
|
|
596954
|
+
const index = this.pendingUserMessages.lastIndexOf(record.content);
|
|
596955
|
+
if (index >= 0)
|
|
596956
|
+
this.pendingUserMessages.splice(index, 1);
|
|
596957
|
+
continue;
|
|
596958
|
+
}
|
|
596959
|
+
record.taskEpoch = this._taskEpoch;
|
|
596960
|
+
this._emitSteeringLifecycle(record, "bound to active task epoch");
|
|
596961
|
+
}
|
|
596962
|
+
}
|
|
596963
|
+
/** Archive prior task-epoch state before its session-backed records are hidden. */
|
|
596964
|
+
_archiveSupersededTaskState(taskEpoch, steering) {
|
|
596965
|
+
const todos = this.readSessionTodos() ?? [];
|
|
596966
|
+
const archive = {
|
|
596967
|
+
runId: this._activeRunId || this._sessionId,
|
|
596968
|
+
sessionId: this._sessionId,
|
|
596969
|
+
taskEpoch,
|
|
596970
|
+
supersededAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
596971
|
+
steering: {
|
|
596972
|
+
inputId: steering.inputId,
|
|
596973
|
+
intent: steering.intent,
|
|
596974
|
+
content: steering.content
|
|
596975
|
+
},
|
|
596976
|
+
todos,
|
|
596977
|
+
workboard: this._workboard,
|
|
596978
|
+
completionLedger: this._completionLedger
|
|
596979
|
+
};
|
|
596980
|
+
try {
|
|
596981
|
+
const dir = _pathJoin(this.omniusStateDir(), "task-epoch-archives");
|
|
596982
|
+
_fsMkdirSync(dir, { recursive: true });
|
|
596983
|
+
_fsWriteFileSync(_pathJoin(dir, `${this._activeRunId || this._sessionId}-epoch-${taskEpoch}.json`), JSON.stringify(archive, null, 2), "utf8");
|
|
596984
|
+
} catch {
|
|
596985
|
+
}
|
|
596986
|
+
for (const todo of todos)
|
|
596987
|
+
this._supersededTodoIds.add(todo.id);
|
|
596988
|
+
this._workboard = null;
|
|
596989
|
+
}
|
|
596990
|
+
_steeringRecordForContent(content) {
|
|
596991
|
+
return this.pendingSteeringInputs.find((record) => record.content === content && (record.state === "queued" || record.state === "acknowledged") && record.taskEpoch === this._taskEpoch);
|
|
596992
|
+
}
|
|
596993
|
+
_canonicalReadEvidencePayload(canonicalPath, contentHash2) {
|
|
596994
|
+
const branch = this._branchEvidenceByPath.get(canonicalPath);
|
|
596995
|
+
if (branch && branch.contentHash === contentHash2)
|
|
596996
|
+
return branch.output;
|
|
596997
|
+
return null;
|
|
596998
|
+
}
|
|
596999
|
+
_rehydrateResolvedReadEvidence(input) {
|
|
597000
|
+
const previous = this._resolvedReadEvidence.get(input.fingerprint);
|
|
597001
|
+
const handle2 = previous?.handle ?? `evidence:${input.canonicalPath}:${input.contentHash.slice(0, 16)}`;
|
|
597002
|
+
this._resolvedReadEvidence.set(input.fingerprint, {
|
|
597003
|
+
state: "resolved_from_cache",
|
|
597004
|
+
handle: handle2,
|
|
597005
|
+
path: input.canonicalPath,
|
|
597006
|
+
contentHash: input.contentHash,
|
|
597007
|
+
resolvedTurn: input.turn,
|
|
597008
|
+
consumed: false
|
|
597009
|
+
});
|
|
597010
|
+
return [
|
|
597011
|
+
"[REHYDRATED_FILE_EVIDENCE]",
|
|
597012
|
+
`handle=${handle2}`,
|
|
597013
|
+
"fingerprint_state=resolved_from_cache",
|
|
597014
|
+
`path=${input.canonicalPath}`,
|
|
597015
|
+
`sha256=${input.contentHash}`,
|
|
597016
|
+
"Facts below are canonical current-run evidence. Consume these facts in the next decision; do not repeat the identical read.",
|
|
597017
|
+
"[CANONICAL_FACTS]",
|
|
597018
|
+
input.payload.slice(0, 7e3),
|
|
597019
|
+
"[/CANONICAL_FACTS]"
|
|
597020
|
+
].join("\n");
|
|
597021
|
+
}
|
|
597022
|
+
_rejectRepeatedResolvedRead(tc, messages2) {
|
|
597023
|
+
if (tc.name !== "file_read") {
|
|
597024
|
+
for (const state2 of this._resolvedReadEvidence.values()) {
|
|
597025
|
+
state2.consumed = true;
|
|
597026
|
+
}
|
|
597027
|
+
return null;
|
|
597028
|
+
}
|
|
597029
|
+
const fingerprint = this._buildToolFingerprint(tc.name, tc.arguments);
|
|
597030
|
+
const state = this._resolvedReadEvidence.get(fingerprint);
|
|
597031
|
+
if (!state)
|
|
597032
|
+
return null;
|
|
597033
|
+
const latestAssistant = [...messages2].reverse().find((message2) => message2.role === "assistant" && typeof message2.content === "string");
|
|
597034
|
+
if (latestAssistant && typeof latestAssistant.content === "string" && latestAssistant.content.includes(state.handle)) {
|
|
597035
|
+
state.consumed = true;
|
|
597036
|
+
}
|
|
597037
|
+
return [
|
|
597038
|
+
"[REPEATED_READ_REJECTED]",
|
|
597039
|
+
`handle=${state.handle}`,
|
|
597040
|
+
`fingerprint_state=${state.state}`,
|
|
597041
|
+
state.consumed ? "The evidence handle was acknowledged, but an identical read cannot add facts. Change file/range/query scope or take the evidence-backed next action." : "Consume the rehydrated evidence handle in your next decision before requesting another read. Change file/range/query scope if a different fact is required."
|
|
597042
|
+
].join("\n");
|
|
597043
|
+
}
|
|
597044
|
+
async _drainPendingSteeringMessages(messages2, turn) {
|
|
597045
|
+
this.drainPendingRuntimeGuidance(turn);
|
|
597046
|
+
while (this.pendingUserMessages.length > 0) {
|
|
597047
|
+
const userMsg = this.pendingUserMessages.shift();
|
|
597048
|
+
const record = this._steeringRecordForContent(userMsg);
|
|
597049
|
+
const replacement = this._pendingSteeringPreemption;
|
|
597050
|
+
if (replacement?.intent === "replace" && record && record.inputId !== replacement.inputId) {
|
|
597051
|
+
record.state = "superseded";
|
|
597052
|
+
this._emitSteeringLifecycle(record, `superseded before consumption by replacement ${replacement.inputId}`);
|
|
597053
|
+
continue;
|
|
597054
|
+
}
|
|
597055
|
+
await this.appendInjectedUserMessage(userMsg, messages2, turn);
|
|
597056
|
+
if (record) {
|
|
597057
|
+
record.state = "consumed";
|
|
597058
|
+
this._emitSteeringLifecycle(record, `consumed at turn ${turn}`);
|
|
597059
|
+
}
|
|
597060
|
+
}
|
|
597061
|
+
}
|
|
597062
|
+
/** Apply a preemption only at a safe boundary after its user content is visible. */
|
|
597063
|
+
_applyPendingSteeringPreemption(messages2, turn) {
|
|
597064
|
+
const record = this._pendingSteeringPreemption;
|
|
597065
|
+
if (!record)
|
|
597066
|
+
return false;
|
|
597067
|
+
this._pendingSteeringPreemption = null;
|
|
597068
|
+
if (record.intent === "cancel") {
|
|
597069
|
+
record.state = "cancelled";
|
|
597070
|
+
this._emitSteeringLifecycle(record, `cancelled active task at turn ${turn}`);
|
|
597071
|
+
this.abort();
|
|
597072
|
+
return true;
|
|
597073
|
+
}
|
|
597074
|
+
const previousEpoch = this._taskEpoch;
|
|
597075
|
+
this._archiveSupersededTaskState(previousEpoch, record);
|
|
597076
|
+
this._allowImplicitContinuation = false;
|
|
597077
|
+
this._taskEpoch += 1;
|
|
597078
|
+
record.taskEpoch = this._taskEpoch;
|
|
597079
|
+
if (record.intent === "replace") {
|
|
597080
|
+
for (const candidate of this.pendingSteeringInputs) {
|
|
597081
|
+
if (candidate.inputId !== record.inputId && candidate.taskEpoch === previousEpoch && (candidate.state === "queued" || candidate.state === "acknowledged")) {
|
|
597082
|
+
candidate.state = "superseded";
|
|
597083
|
+
this._emitSteeringLifecycle(candidate, `superseded by replacement ${record.inputId}`);
|
|
597084
|
+
}
|
|
597085
|
+
}
|
|
597086
|
+
}
|
|
597087
|
+
this._completionContract = null;
|
|
597088
|
+
this._completionLedger = this.writesUserTaskArtifacts() ? createCompletionLedger({
|
|
597089
|
+
runId: this.currentArtifactRunId(),
|
|
597090
|
+
goal: record.content
|
|
597091
|
+
}) : null;
|
|
597092
|
+
if (this._completionLedger) {
|
|
597093
|
+
this._completionLedger.taskEpoch = this._taskEpoch;
|
|
597094
|
+
}
|
|
597095
|
+
this._completionHoldState.count = 0;
|
|
597096
|
+
this._completionHoldState.total = 0;
|
|
597097
|
+
this._completionHoldState.lastKey = "";
|
|
597098
|
+
this._completionIncompleteVerification = null;
|
|
597099
|
+
this._taskState.goal = record.content;
|
|
597100
|
+
this._taskState.originalGoal = record.content;
|
|
597101
|
+
messages2.push({
|
|
597102
|
+
role: "system",
|
|
597103
|
+
content: [
|
|
597104
|
+
"[ACTIVE USER STEERING - HIGHEST USER PRIORITY]",
|
|
597105
|
+
`inputId=${record.inputId} taskEpoch=${this._taskEpoch} intent=${record.intent}`,
|
|
597106
|
+
"The prior task epoch is historical evidence only. Do not continue its plan, todos, recovery cards, or completion contract.",
|
|
597107
|
+
"Replan from this active user instruction before any further tool call:",
|
|
597108
|
+
record.content
|
|
597109
|
+
].join("\n")
|
|
597110
|
+
});
|
|
597111
|
+
record.state = "consumed";
|
|
597112
|
+
this._emitSteeringLifecycle(record, `applied at turn ${turn}; epoch ${previousEpoch} -> ${this._taskEpoch}`);
|
|
597113
|
+
return true;
|
|
596642
597114
|
}
|
|
596643
597115
|
/**
|
|
596644
597116
|
* Pause the current task gracefully. The run loop will suspend at the next
|
|
@@ -596899,28 +597371,32 @@ ${notice}`;
|
|
|
596899
597371
|
const cacheKey = `${canonicalPath}|${fullHash}|${offset ?? 0}:${limit ?? "EOF"}|${contractFingerprint}`;
|
|
596900
597372
|
const cached = this._branchEvidenceCache.get(cacheKey);
|
|
596901
597373
|
if (cached) {
|
|
596902
|
-
const
|
|
596903
|
-
|
|
596904
|
-
|
|
596905
|
-
|
|
596906
|
-
|
|
597374
|
+
const fingerprint = this._buildToolFingerprint(input.toolName, input.args);
|
|
597375
|
+
const rehydrated = this._rehydrateResolvedReadEvidence({
|
|
597376
|
+
fingerprint,
|
|
597377
|
+
canonicalPath,
|
|
597378
|
+
contentHash: fullHash,
|
|
597379
|
+
payload: cached.output,
|
|
597380
|
+
turn: input.turn
|
|
597381
|
+
});
|
|
596907
597382
|
this.emit({
|
|
596908
597383
|
type: "status",
|
|
596909
597384
|
toolName: input.toolName,
|
|
596910
|
-
content: `Branch-extract cache
|
|
597385
|
+
content: `Branch-extract cache rehydrated: ${rawPath} sha256=${fullHash.slice(0, 12)} contract=${contractFingerprint} fingerprint_state=resolved_from_cache`,
|
|
596911
597386
|
turn: input.turn,
|
|
596912
597387
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
596913
597388
|
});
|
|
596914
597389
|
return {
|
|
596915
597390
|
success: true,
|
|
596916
|
-
output:
|
|
596917
|
-
llmContent:
|
|
597391
|
+
output: rehydrated,
|
|
597392
|
+
llmContent: rehydrated,
|
|
596918
597393
|
beforeHash: fullHash,
|
|
596919
597394
|
runtimeAuthored: true,
|
|
596920
597395
|
noop: true,
|
|
596921
597396
|
completionEvidenceMetrics: {
|
|
596922
597397
|
branchSourceBytes: cached.sourceBytes,
|
|
596923
|
-
branchCacheHit: true
|
|
597398
|
+
branchCacheHit: true,
|
|
597399
|
+
fingerprintState: "resolved_from_cache"
|
|
596924
597400
|
}
|
|
596925
597401
|
};
|
|
596926
597402
|
}
|
|
@@ -597439,7 +597915,7 @@ ${inventory}`
|
|
|
597439
597915
|
});
|
|
597440
597916
|
this._onTypedEvent?.({
|
|
597441
597917
|
type: "trajectory_checkpoint",
|
|
597442
|
-
runId: this.
|
|
597918
|
+
runId: this.currentArtifactRunId(),
|
|
597443
597919
|
revision: checkpoint.revision,
|
|
597444
597920
|
assessment: checkpoint.assessment,
|
|
597445
597921
|
nextAction: checkpoint.nextAction,
|
|
@@ -597450,7 +597926,7 @@ ${inventory}`
|
|
|
597450
597926
|
recordDebugTrajectoryCheckpoint({
|
|
597451
597927
|
cwd: this.authoritativeWorkingDirectory(),
|
|
597452
597928
|
stateDir: this.omniusStateDir(),
|
|
597453
|
-
runId: this.
|
|
597929
|
+
runId: this.currentArtifactRunId(),
|
|
597454
597930
|
sessionId: this._sessionId,
|
|
597455
597931
|
checkpoint
|
|
597456
597932
|
});
|
|
@@ -597691,6 +598167,9 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
597691
598167
|
async run(task, context2, actualUserGoal) {
|
|
597692
598168
|
this.aborted = false;
|
|
597693
598169
|
this._abortController = new AbortController();
|
|
598170
|
+
this._turnAbortController = new AbortController();
|
|
598171
|
+
this._taskEpoch += 1;
|
|
598172
|
+
this._activeRunId = `${this._sessionId || "run"}-${Date.now()}-${this._taskEpoch}`;
|
|
597694
598173
|
this._fileWritesThisRun = 0;
|
|
597695
598174
|
this._backwardPassCyclesUsed = 0;
|
|
597696
598175
|
this._completionVerifyRejections = 0;
|
|
@@ -597716,7 +598195,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
597716
598195
|
this._resetVisualEvidenceState();
|
|
597717
598196
|
this._verifyFailuresBaseline = new Set(this._verifyFailures);
|
|
597718
598197
|
if (typeof this.backend.setAbortSignal === "function") {
|
|
597719
|
-
this.backend.setAbortSignal(this.
|
|
598198
|
+
this.backend.setAbortSignal(this._turnAbortController.signal);
|
|
597720
598199
|
}
|
|
597721
598200
|
const cleanedTask = cleanForStorage(task) || task.slice(0, 500);
|
|
597722
598201
|
const start2 = Date.now();
|
|
@@ -597847,7 +598326,7 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
597847
598326
|
}
|
|
597848
598327
|
this._loadResolutionMemory();
|
|
597849
598328
|
this._pauseResolve = null;
|
|
597850
|
-
this.
|
|
598329
|
+
this._prepareSteeringInputsForRun();
|
|
597851
598330
|
const persistentTaskGoal = cleanForStorage(actualUserGoal || "") || cleanedTask;
|
|
597852
598331
|
const userGoal = persistentTaskGoal.slice(0, 500);
|
|
597853
598332
|
this._taskRelevantErrorPatterns = process.env["OMNIUS_DISABLE_FAILURE_HANDOFF"] === "1" ? /* @__PURE__ */ new Map() : await this._selectTaskRelevantErrorPatterns(persistentTaskGoal, 10);
|
|
@@ -597952,9 +598431,10 @@ Respond with the assessment and take the selected evidence-backed action.`;
|
|
|
597952
598431
|
if (this.writesUserTaskArtifacts()) {
|
|
597953
598432
|
this._initializeCompletionContract(task, context2, actualUserGoal);
|
|
597954
598433
|
this._completionLedger = createCompletionLedger({
|
|
597955
|
-
runId: this._sessionId,
|
|
598434
|
+
runId: this._activeRunId || this._sessionId,
|
|
597956
598435
|
goal: userGoal
|
|
597957
598436
|
});
|
|
598437
|
+
this._completionLedger.taskEpoch = this._taskEpoch;
|
|
597958
598438
|
} else {
|
|
597959
598439
|
this._completionContract = null;
|
|
597960
598440
|
this._completionLedger = null;
|
|
@@ -598260,9 +598740,9 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598260
598740
|
if (process.env["OMNIUS_FRESH_SESSION"] === "1")
|
|
598261
598741
|
throw "skip-handoff-fresh";
|
|
598262
598742
|
const omniusDir = this._workingDirectory ? _pathJoin(this._workingDirectory, ".omnius") : _pathJoin(process.cwd(), ".omnius");
|
|
598263
|
-
const chainPairs = loadMessagePairsFromLog(omniusDir, {
|
|
598743
|
+
const chainPairs = this._allowImplicitContinuation ? loadMessagePairsFromLog(omniusDir, {
|
|
598264
598744
|
currentTask: persistentTaskGoal
|
|
598265
|
-
});
|
|
598745
|
+
}) : [];
|
|
598266
598746
|
if (chainPairs.length > 0) {
|
|
598267
598747
|
messages2.splice(1, 0, ...chainPairs);
|
|
598268
598748
|
this.emit({
|
|
@@ -598273,7 +598753,8 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598273
598753
|
} else {
|
|
598274
598754
|
const prior = readTaskHandoff(omniusDir, {
|
|
598275
598755
|
currentSessionId: this._sessionId,
|
|
598276
|
-
currentTask: persistentTaskGoal
|
|
598756
|
+
currentTask: persistentTaskGoal,
|
|
598757
|
+
allowImplicitContinuation: this._allowImplicitContinuation
|
|
598277
598758
|
});
|
|
598278
598759
|
if (prior) {
|
|
598279
598760
|
const handoffPair = buildHandoffMessagePair(prior);
|
|
@@ -598388,7 +598869,7 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598388
598869
|
}),
|
|
598389
598870
|
persistPath,
|
|
598390
598871
|
sessionId: this._sessionId,
|
|
598391
|
-
runId: this.
|
|
598872
|
+
runId: this.currentArtifactRunId(),
|
|
598392
598873
|
cwd: this._workingDirectory || process.cwd(),
|
|
598393
598874
|
model: this._backendModelLabel(this.backend),
|
|
598394
598875
|
onCritique: (critique2, sourceTurn) => {
|
|
@@ -598634,6 +599115,19 @@ TASK: ${scrubbedTask}` : scrubbedTask;
|
|
|
598634
599115
|
return completionHoldEscapeMax * 2;
|
|
598635
599116
|
})();
|
|
598636
599117
|
const holdTaskCompleteGates = (args, turn) => {
|
|
599118
|
+
if (this._hasEvidenceBackedBlockedCompletion(args)) {
|
|
599119
|
+
this._completionHoldState.count = 0;
|
|
599120
|
+
this._completionHoldState.lastKey = "";
|
|
599121
|
+
this._completionHoldState.total = 0;
|
|
599122
|
+
lastCompletionGateCode = "";
|
|
599123
|
+
this.emit({
|
|
599124
|
+
type: "status",
|
|
599125
|
+
content: "task_complete admitted as evidence-backed blocked state",
|
|
599126
|
+
turn,
|
|
599127
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
599128
|
+
});
|
|
599129
|
+
return false;
|
|
599130
|
+
}
|
|
598637
599131
|
if (this._completionHoldState.total >= completionHoldHardMax) {
|
|
598638
599132
|
const incompleteSummary = [
|
|
598639
599133
|
`INCOMPLETE_VERIFICATION: completion was requested after ${this._completionHoldState.total} gate hold(s), but required evidence is still missing.`,
|
|
@@ -598853,6 +599347,8 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
598853
599347
|
}
|
|
598854
599348
|
}
|
|
598855
599349
|
for (let turn = 0; turn < turnCap; turn++) {
|
|
599350
|
+
this._turnAbortController = new AbortController();
|
|
599351
|
+
this._setBackendTurnAbortSignal(this._turnAbortController.signal);
|
|
598856
599352
|
clearTurnState(this._appState);
|
|
598857
599353
|
this._maybeApplyThinkGuard();
|
|
598858
599354
|
if (this._paused) {
|
|
@@ -598865,7 +599361,7 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
598865
599361
|
});
|
|
598866
599362
|
this._onTypedEvent?.({
|
|
598867
599363
|
type: "run_failed",
|
|
598868
|
-
runId: this.
|
|
599364
|
+
runId: this.currentArtifactRunId(),
|
|
598869
599365
|
error: "Task aborted by user",
|
|
598870
599366
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
598871
599367
|
});
|
|
@@ -598880,7 +599376,7 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
598880
599376
|
});
|
|
598881
599377
|
this._onTypedEvent?.({
|
|
598882
599378
|
type: "run_failed",
|
|
598883
|
-
runId: this.
|
|
599379
|
+
runId: this.currentArtifactRunId(),
|
|
598884
599380
|
error: "Task aborted by user",
|
|
598885
599381
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
598886
599382
|
});
|
|
@@ -598954,7 +599450,7 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
598954
599450
|
});
|
|
598955
599451
|
this._onTypedEvent?.({
|
|
598956
599452
|
type: "completion_requested",
|
|
598957
|
-
runId: this.
|
|
599453
|
+
runId: this.currentArtifactRunId(),
|
|
598958
599454
|
summary: summary.slice(0, 500),
|
|
598959
599455
|
sourcePath: "direct",
|
|
598960
599456
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -600019,10 +600515,11 @@ ${_staleSamples.join("\n")}` : ``,
|
|
|
600019
600515
|
});
|
|
600020
600516
|
}
|
|
600021
600517
|
}
|
|
600022
|
-
this.
|
|
600023
|
-
|
|
600024
|
-
|
|
600025
|
-
|
|
600518
|
+
await this._drainPendingSteeringMessages(messages2, turn);
|
|
600519
|
+
if (this._applyPendingSteeringPreemption(messages2, turn)) {
|
|
600520
|
+
if (this.aborted)
|
|
600521
|
+
break;
|
|
600522
|
+
continue;
|
|
600026
600523
|
}
|
|
600027
600524
|
if (!this.options.disableTodoPlanningNudges) {
|
|
600028
600525
|
const maybeReminder = this.getTodoReminderContent(turn);
|
|
@@ -600252,7 +600749,7 @@ If you're stuck, try a completely different approach. Do NOT repeat what failed
|
|
|
600252
600749
|
toolEvents: this._toolEvents,
|
|
600253
600750
|
memoryHints: [],
|
|
600254
600751
|
runState: {
|
|
600255
|
-
runId: this.
|
|
600752
|
+
runId: this.currentArtifactRunId(),
|
|
600256
600753
|
tokenBudget: _limits.compactionThreshold,
|
|
600257
600754
|
completionContract: this._completionContract ? formatCompletionContract(this._completionContract) : void 0
|
|
600258
600755
|
}
|
|
@@ -600397,7 +600894,7 @@ ${memoryLines.join("\n")}`
|
|
|
600397
600894
|
toolEvents: this._toolEvents,
|
|
600398
600895
|
memoryHints: [],
|
|
600399
600896
|
runState: {
|
|
600400
|
-
runId: this.
|
|
600897
|
+
runId: this.currentArtifactRunId(),
|
|
600401
600898
|
tokenBudget: _limits.compactionThreshold,
|
|
600402
600899
|
completionContract: this._completionContract ? formatCompletionContract(this._completionContract) : void 0
|
|
600403
600900
|
}
|
|
@@ -600425,6 +600922,11 @@ ${memoryLines.join("\n")}`
|
|
|
600425
600922
|
const echoBoostedTemp = this._echoTempBoostTurns > 0 ? Math.max(this.options.temperature ?? 0, 0.7) : this.options.temperature;
|
|
600426
600923
|
if (this._echoTempBoostTurns > 0)
|
|
600427
600924
|
this._echoTempBoostTurns--;
|
|
600925
|
+
const actionGroundTruth = this._buildRecentActionGroundTruth(turn);
|
|
600926
|
+
if (actionGroundTruth) {
|
|
600927
|
+
requestMessages.push({ role: "system", content: actionGroundTruth });
|
|
600928
|
+
}
|
|
600929
|
+
this._retireLinkedAssistantReadIntents(requestMessages);
|
|
600428
600930
|
const chatRequest = {
|
|
600429
600931
|
messages: requestMessages,
|
|
600430
600932
|
tools: toolDefs,
|
|
@@ -600508,6 +601010,15 @@ ${memoryLines.join("\n")}`
|
|
|
600508
601010
|
try {
|
|
600509
601011
|
response = this.options.streamEnabled && this.hasStreamingSupport() ? await this.streamingRequest(chatRequest, turn) : await this.backend.chatCompletion(chatRequest);
|
|
600510
601012
|
} catch (reqErr) {
|
|
601013
|
+
if (this._pendingSteeringPreemption) {
|
|
601014
|
+
this.emit({
|
|
601015
|
+
type: "status",
|
|
601016
|
+
content: "Model request interrupted by pending user steering; skipping recovery.",
|
|
601017
|
+
turn,
|
|
601018
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
601019
|
+
});
|
|
601020
|
+
continue;
|
|
601021
|
+
}
|
|
600511
601022
|
if (reqErr instanceof Error && reqErr.fatal) {
|
|
600512
601023
|
this.emit({
|
|
600513
601024
|
type: "error",
|
|
@@ -600516,7 +601027,7 @@ ${memoryLines.join("\n")}`
|
|
|
600516
601027
|
});
|
|
600517
601028
|
this._onTypedEvent?.({
|
|
600518
601029
|
type: "run_failed",
|
|
600519
|
-
runId: this.
|
|
601030
|
+
runId: this.currentArtifactRunId(),
|
|
600520
601031
|
error: reqErr.message,
|
|
600521
601032
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
600522
601033
|
});
|
|
@@ -600535,7 +601046,7 @@ ${memoryLines.join("\n")}`
|
|
|
600535
601046
|
});
|
|
600536
601047
|
this._onTypedEvent?.({
|
|
600537
601048
|
type: "run_failed",
|
|
600538
|
-
runId: this.
|
|
601049
|
+
runId: this.currentArtifactRunId(),
|
|
600539
601050
|
error: retryMsg,
|
|
600540
601051
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
600541
601052
|
});
|
|
@@ -600559,7 +601070,7 @@ ${memoryLines.join("\n")}`
|
|
|
600559
601070
|
});
|
|
600560
601071
|
this._onTypedEvent?.({
|
|
600561
601072
|
type: "run_failed",
|
|
600562
|
-
runId: this.
|
|
601073
|
+
runId: this.currentArtifactRunId(),
|
|
600563
601074
|
error: `Model not found: ${errMsg}`,
|
|
600564
601075
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
600565
601076
|
});
|
|
@@ -600634,7 +601145,7 @@ ${memoryLines.join("\n")}`
|
|
|
600634
601145
|
summary = String(parsed.args?.summary ?? content);
|
|
600635
601146
|
this._onTypedEvent?.({
|
|
600636
601147
|
type: "completion_requested",
|
|
600637
|
-
runId: this.
|
|
601148
|
+
runId: this.currentArtifactRunId(),
|
|
600638
601149
|
summary: summary.slice(0, 500),
|
|
600639
601150
|
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
600640
601151
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -600657,7 +601168,7 @@ ${memoryLines.join("\n")}`
|
|
|
600657
601168
|
});
|
|
600658
601169
|
this._onTypedEvent?.({
|
|
600659
601170
|
type: "run_failed",
|
|
600660
|
-
runId: this.
|
|
601171
|
+
runId: this.currentArtifactRunId(),
|
|
600661
601172
|
error: msg2,
|
|
600662
601173
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
600663
601174
|
});
|
|
@@ -600672,7 +601183,7 @@ ${memoryLines.join("\n")}`
|
|
|
600672
601183
|
});
|
|
600673
601184
|
this._onTypedEvent?.({
|
|
600674
601185
|
type: "run_failed",
|
|
600675
|
-
runId: this.
|
|
601186
|
+
runId: this.currentArtifactRunId(),
|
|
600676
601187
|
error: `Backend unavailable: ${errMsg}`,
|
|
600677
601188
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
600678
601189
|
});
|
|
@@ -600682,10 +601193,10 @@ ${memoryLines.join("\n")}`
|
|
|
600682
601193
|
response = recovered ?? response;
|
|
600683
601194
|
}
|
|
600684
601195
|
}
|
|
600685
|
-
totalTokens += response.usage?.totalTokens ?? 0;
|
|
600686
|
-
promptTokens += response.usage?.promptTokens ?? 0;
|
|
601196
|
+
totalTokens += response.usage?.totalTokens || (response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0) + (response.usage?.completionTokens ?? 0);
|
|
601197
|
+
promptTokens += response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0;
|
|
600687
601198
|
completionTokens += response.usage?.completionTokens ?? 0;
|
|
600688
|
-
const turnPromptTokens = response.usage?.promptTokens ?? 0;
|
|
601199
|
+
const turnPromptTokens = response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0;
|
|
600689
601200
|
const turnCompletionTokens = response.usage?.completionTokens ?? 0;
|
|
600690
601201
|
if (turnPromptTokens || turnCompletionTokens) {
|
|
600691
601202
|
recordTokenUsage(this._appState, turnPromptTokens, turnCompletionTokens, 0, false);
|
|
@@ -600903,8 +601414,19 @@ ${memoryLines.join("\n")}`
|
|
|
600903
601414
|
reservations: /* @__PURE__ */ new Map()
|
|
600904
601415
|
};
|
|
600905
601416
|
executeSingle = async (tc) => {
|
|
600906
|
-
if (this.aborted)
|
|
601417
|
+
if (this.aborted || this._pendingSteeringPreemption)
|
|
600907
601418
|
return null;
|
|
601419
|
+
const resolvedReadBlock = this._rejectRepeatedResolvedRead(tc, messages2);
|
|
601420
|
+
if (resolvedReadBlock) {
|
|
601421
|
+
this.emit({
|
|
601422
|
+
type: "status",
|
|
601423
|
+
toolName: tc.name,
|
|
601424
|
+
content: "Repeated planned file_read rejected until evidence scope changes.",
|
|
601425
|
+
turn,
|
|
601426
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
601427
|
+
});
|
|
601428
|
+
return { tc, output: resolvedReadBlock, success: true };
|
|
601429
|
+
}
|
|
600908
601430
|
const cohortKey = this.buildArgCohortKey(tc.name, tc.arguments);
|
|
600909
601431
|
const cohort = this._argCohorts.get(cohortKey);
|
|
600910
601432
|
if (cohort && cohort.failure >= 3 && cohort.success === 0) {
|
|
@@ -601920,30 +602442,70 @@ ${cachedResult}`,
|
|
|
601920
602442
|
const currentRead = this._fileReadDiskIdentity(tc.arguments);
|
|
601921
602443
|
if (currentRead && currentRead.contentHash === priorRead.contentHash) {
|
|
601922
602444
|
exactFileReadObservations.set(exactReadKey, currentRead);
|
|
601923
|
-
const
|
|
601924
|
-
|
|
601925
|
-
|
|
601926
|
-
|
|
601927
|
-
|
|
601928
|
-
|
|
601929
|
-
|
|
601930
|
-
|
|
601931
|
-
|
|
601932
|
-
|
|
601933
|
-
|
|
601934
|
-
|
|
601935
|
-
|
|
601936
|
-
|
|
601937
|
-
|
|
602445
|
+
const canonicalPayload = this._canonicalReadEvidencePayload(currentRead.canonicalPath, currentRead.contentHash);
|
|
602446
|
+
if (canonicalPayload) {
|
|
602447
|
+
const rehydrated = this._rehydrateResolvedReadEvidence({
|
|
602448
|
+
fingerprint: exactReadKey,
|
|
602449
|
+
canonicalPath: currentRead.canonicalPath,
|
|
602450
|
+
contentHash: currentRead.contentHash,
|
|
602451
|
+
payload: canonicalPayload,
|
|
602452
|
+
turn
|
|
602453
|
+
});
|
|
602454
|
+
branchPreempted = {
|
|
602455
|
+
success: true,
|
|
602456
|
+
output: rehydrated,
|
|
602457
|
+
llmContent: rehydrated,
|
|
602458
|
+
beforeHash: currentRead.contentHash,
|
|
602459
|
+
runtimeAuthored: true,
|
|
602460
|
+
noop: true,
|
|
602461
|
+
completionEvidenceMetrics: {
|
|
602462
|
+
duplicateReadResolvedFromCache: true,
|
|
602463
|
+
duplicateReadSourceBytes: currentRead.byteCount,
|
|
602464
|
+
fingerprintState: "resolved_from_cache"
|
|
602465
|
+
}
|
|
602466
|
+
};
|
|
602467
|
+
this.emit({
|
|
602468
|
+
type: "status",
|
|
602469
|
+
toolName: normalizedDispatchName,
|
|
602470
|
+
content: `Exact unchanged file_read rehydrated: ${currentRead.path} sha256=${currentRead.contentHash.slice(0, 12)} fingerprint_state=resolved_from_cache`,
|
|
602471
|
+
turn,
|
|
602472
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
602473
|
+
});
|
|
602474
|
+
} else {
|
|
602475
|
+
if (this._deterministicNarrowReadFallbacks.has(exactReadKey)) {
|
|
602476
|
+
const fallbackBlocked = [
|
|
602477
|
+
"[REPEATED_NARROW_READ_REJECTED]",
|
|
602478
|
+
`path=${currentRead.path}`,
|
|
602479
|
+
"No canonical payload was produced by the allowed narrow reread. Change scope with a new range or symbol query; do not repeat identical arguments."
|
|
602480
|
+
].join("\n");
|
|
602481
|
+
branchPreempted = {
|
|
602482
|
+
success: true,
|
|
602483
|
+
output: fallbackBlocked,
|
|
602484
|
+
llmContent: fallbackBlocked,
|
|
602485
|
+
beforeHash: currentRead.contentHash,
|
|
602486
|
+
runtimeAuthored: true,
|
|
602487
|
+
noop: true
|
|
602488
|
+
};
|
|
602489
|
+
} else {
|
|
602490
|
+
this._deterministicNarrowReadFallbacks.add(exactReadKey);
|
|
602491
|
+
const previousOffset = tc.arguments["offset"];
|
|
602492
|
+
const previousLimit = tc.arguments["limit"];
|
|
602493
|
+
Object.assign(finalArgs, {
|
|
602494
|
+
offset: typeof previousOffset === "number" && Number.isFinite(previousOffset) ? Math.max(1, Math.floor(previousOffset)) : 1,
|
|
602495
|
+
limit: typeof previousLimit === "number" && Number.isFinite(previousLimit) ? Math.max(1, Math.min(160, Math.floor(previousLimit))) : 160
|
|
602496
|
+
});
|
|
602497
|
+
tc.arguments = finalArgs;
|
|
602498
|
+
this._deterministicNarrowReadFallbacks.add(this._buildToolFingerprint("file_read", tc.arguments));
|
|
602499
|
+
exactFileReadObservations.delete(exactReadKey);
|
|
602500
|
+
this.emit({
|
|
602501
|
+
type: "status",
|
|
602502
|
+
toolName: normalizedDispatchName,
|
|
602503
|
+
content: `Exact read cache lacked canonical payload; allowing one deterministic narrow reread: ${currentRead.path} offset=${tc.arguments["offset"]} limit=${tc.arguments["limit"]}`,
|
|
602504
|
+
turn,
|
|
602505
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
602506
|
+
});
|
|
601938
602507
|
}
|
|
601939
|
-
}
|
|
601940
|
-
this.emit({
|
|
601941
|
-
type: "status",
|
|
601942
|
-
toolName: normalizedDispatchName,
|
|
601943
|
-
content: `Exact unchanged file_read blocked before dispatch: ${currentRead.path} sha256=${currentRead.contentHash.slice(0, 12)}`,
|
|
601944
|
-
turn,
|
|
601945
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
601946
|
-
});
|
|
602508
|
+
}
|
|
601947
602509
|
} else {
|
|
601948
602510
|
exactFileReadObservations.delete(exactReadKey);
|
|
601949
602511
|
}
|
|
@@ -602119,6 +602681,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
602119
602681
|
args: tc.arguments,
|
|
602120
602682
|
result
|
|
602121
602683
|
});
|
|
602684
|
+
this._reconcileCreationGroundTruth(resolvedTool?.name ?? tc.name, tc.arguments, result, turn);
|
|
602122
602685
|
if (observedStateMutation) {
|
|
602123
602686
|
this._markAdversaryObservedStateMutation();
|
|
602124
602687
|
}
|
|
@@ -602209,7 +602772,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
602209
602772
|
writeCount: prev?.writeCount
|
|
602210
602773
|
});
|
|
602211
602774
|
}
|
|
602212
|
-
if (p2 && result.success && result.output) {
|
|
602775
|
+
if (p2 && result.success && result.output && !(result.runtimeAuthored === true && result.noop === true)) {
|
|
602213
602776
|
const rOffset = typeof tc.arguments?.["offset"] === "number" ? tc.arguments["offset"] : void 0;
|
|
602214
602777
|
const rLimit = typeof tc.arguments?.["limit"] === "number" ? tc.arguments["limit"] : void 0;
|
|
602215
602778
|
const start3 = rOffset === void 0 && rLimit === void 0 ? 0 : Math.max(1, rOffset ?? 1);
|
|
@@ -603537,7 +604100,7 @@ ${delegateDir}` : delegateDir;
|
|
|
603537
604100
|
recordDebugToolEvent({
|
|
603538
604101
|
cwd: this.authoritativeWorkingDirectory(),
|
|
603539
604102
|
stateDir: this.omniusStateDir(),
|
|
603540
|
-
runId: this.
|
|
604103
|
+
runId: this.currentArtifactRunId(),
|
|
603541
604104
|
sessionId: this._sessionId,
|
|
603542
604105
|
turn,
|
|
603543
604106
|
toolCallId: tc.id,
|
|
@@ -603791,7 +604354,7 @@ Then use file_read on individual FILES inside it.`);
|
|
|
603791
604354
|
});
|
|
603792
604355
|
this._onTypedEvent?.({
|
|
603793
604356
|
type: "tool_call_finished",
|
|
603794
|
-
runId: this.
|
|
604357
|
+
runId: this.currentArtifactRunId(),
|
|
603795
604358
|
toolName: tc.name,
|
|
603796
604359
|
callId: tc.id,
|
|
603797
604360
|
success: result.success === true,
|
|
@@ -603903,7 +604466,7 @@ ${sr.result.output}`;
|
|
|
603903
604466
|
summary = extractTaskCompleteSummary(taskCompleteArgs);
|
|
603904
604467
|
this._onTypedEvent?.({
|
|
603905
604468
|
type: "completion_requested",
|
|
603906
|
-
runId: this.
|
|
604469
|
+
runId: this.currentArtifactRunId(),
|
|
603907
604470
|
summary: (summary ?? "").slice(0, 500),
|
|
603908
604471
|
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
603909
604472
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -603926,7 +604489,7 @@ ${sr.result.output}`;
|
|
|
603926
604489
|
if (!completed && !this._completionIncompleteVerification) {
|
|
603927
604490
|
const unhandled = rawToolCalls.filter((tc) => !handledIds.has(tc.id));
|
|
603928
604491
|
for (const tc of unhandled) {
|
|
603929
|
-
if (this.aborted)
|
|
604492
|
+
if (this.aborted || this._pendingSteeringPreemption)
|
|
603930
604493
|
break;
|
|
603931
604494
|
const r2 = await executeSingle(tc);
|
|
603932
604495
|
if (r2) {
|
|
@@ -603978,7 +604541,7 @@ ${sr.result.output}`;
|
|
|
603978
604541
|
summary = extractTaskCompleteSummary(taskCompleteArgs);
|
|
603979
604542
|
this._onTypedEvent?.({
|
|
603980
604543
|
type: "completion_requested",
|
|
603981
|
-
runId: this.
|
|
604544
|
+
runId: this.currentArtifactRunId(),
|
|
603982
604545
|
summary: (summary ?? "").slice(0, 500),
|
|
603983
604546
|
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
603984
604547
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -604008,7 +604571,7 @@ ${sr.result.output}`;
|
|
|
604008
604571
|
}));
|
|
604009
604572
|
const batches = partitionToolCalls(batchToolCalls);
|
|
604010
604573
|
for (const batch2 of batches) {
|
|
604011
|
-
if (this.aborted)
|
|
604574
|
+
if (this.aborted || this._pendingSteeringPreemption)
|
|
604012
604575
|
break;
|
|
604013
604576
|
const batchFingerprintFirstId = /* @__PURE__ */ new Map();
|
|
604014
604577
|
const batchInFlight = /* @__PURE__ */ new Map();
|
|
@@ -604092,7 +604655,7 @@ ${sr.result.output}`;
|
|
|
604092
604655
|
summary = extractTaskCompleteSummary(taskCompleteArgs);
|
|
604093
604656
|
this._onTypedEvent?.({
|
|
604094
604657
|
type: "completion_requested",
|
|
604095
|
-
runId: this.
|
|
604658
|
+
runId: this.currentArtifactRunId(),
|
|
604096
604659
|
summary: (summary ?? "").slice(0, 500),
|
|
604097
604660
|
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
604098
604661
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -604321,7 +604884,7 @@ Only call task_complete when the task is actually complete and the evidence is f
|
|
|
604321
604884
|
summary = content;
|
|
604322
604885
|
this._onTypedEvent?.({
|
|
604323
604886
|
type: "completion_requested",
|
|
604324
|
-
runId: this.
|
|
604887
|
+
runId: this.currentArtifactRunId(),
|
|
604325
604888
|
summary: content.slice(0, 500),
|
|
604326
604889
|
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
604327
604890
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -604570,7 +605133,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604570
605133
|
toolEvents: this._toolEvents,
|
|
604571
605134
|
memoryHints: [],
|
|
604572
605135
|
runState: {
|
|
604573
|
-
runId: this.
|
|
605136
|
+
runId: this.currentArtifactRunId(),
|
|
604574
605137
|
tokenBudget: _limits.compactionThreshold,
|
|
604575
605138
|
completionContract: this._completionContract ? formatCompletionContract(this._completionContract) : void 0
|
|
604576
605139
|
}
|
|
@@ -604594,7 +605157,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604594
605157
|
});
|
|
604595
605158
|
this._onTypedEvent?.({
|
|
604596
605159
|
type: "run_failed",
|
|
604597
|
-
runId: this.
|
|
605160
|
+
runId: this.currentArtifactRunId(),
|
|
604598
605161
|
error: "Task aborted by user",
|
|
604599
605162
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
604600
605163
|
});
|
|
@@ -604609,7 +605172,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604609
605172
|
});
|
|
604610
605173
|
this._onTypedEvent?.({
|
|
604611
605174
|
type: "run_failed",
|
|
604612
|
-
runId: this.
|
|
605175
|
+
runId: this.currentArtifactRunId(),
|
|
604613
605176
|
error: "Task aborted by user",
|
|
604614
605177
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
604615
605178
|
});
|
|
@@ -604666,6 +605229,13 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604666
605229
|
const bfEchoBoostedTemp = this._echoTempBoostTurns > 0 ? Math.max(this.options.temperature ?? 0, 0.7) : this.options.temperature;
|
|
604667
605230
|
if (this._echoTempBoostTurns > 0)
|
|
604668
605231
|
this._echoTempBoostTurns--;
|
|
605232
|
+
const bruteForceGroundTruth = this._buildRecentActionGroundTruth(turn);
|
|
605233
|
+
if (bruteForceGroundTruth) {
|
|
605234
|
+
modelFacingMessages.push({
|
|
605235
|
+
role: "system",
|
|
605236
|
+
content: bruteForceGroundTruth
|
|
605237
|
+
});
|
|
605238
|
+
}
|
|
604669
605239
|
const chatRequest = {
|
|
604670
605240
|
messages: modelFacingMessages,
|
|
604671
605241
|
tools: toolDefs,
|
|
@@ -604687,7 +605257,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604687
605257
|
});
|
|
604688
605258
|
this._onTypedEvent?.({
|
|
604689
605259
|
type: "run_failed",
|
|
604690
|
-
runId: this.
|
|
605260
|
+
runId: this.currentArtifactRunId(),
|
|
604691
605261
|
error: "Task aborted by user",
|
|
604692
605262
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
604693
605263
|
});
|
|
@@ -604706,7 +605276,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604706
605276
|
});
|
|
604707
605277
|
this._onTypedEvent?.({
|
|
604708
605278
|
type: "run_failed",
|
|
604709
|
-
runId: this.
|
|
605279
|
+
runId: this.currentArtifactRunId(),
|
|
604710
605280
|
error: bfRetryMsg,
|
|
604711
605281
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
604712
605282
|
});
|
|
@@ -604729,7 +605299,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604729
605299
|
});
|
|
604730
605300
|
this._onTypedEvent?.({
|
|
604731
605301
|
type: "run_failed",
|
|
604732
|
-
runId: this.
|
|
605302
|
+
runId: this.currentArtifactRunId(),
|
|
604733
605303
|
error: errMsg2,
|
|
604734
605304
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
604735
605305
|
});
|
|
@@ -604738,10 +605308,10 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604738
605308
|
response = recovered;
|
|
604739
605309
|
}
|
|
604740
605310
|
}
|
|
604741
|
-
totalTokens += response.usage?.totalTokens ?? 0;
|
|
604742
|
-
promptTokens += response.usage?.promptTokens ?? 0;
|
|
605311
|
+
totalTokens += response.usage?.totalTokens || (response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0) + (response.usage?.completionTokens ?? 0);
|
|
605312
|
+
promptTokens += response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0;
|
|
604743
605313
|
completionTokens += response.usage?.completionTokens ?? 0;
|
|
604744
|
-
const bfTurnPrompt = response.usage?.promptTokens ?? 0;
|
|
605314
|
+
const bfTurnPrompt = response.usage?.promptEvalCount ?? response.usage?.promptTokens ?? 0;
|
|
604745
605315
|
const bfTurnCompletion = response.usage?.completionTokens ?? 0;
|
|
604746
605316
|
if (bfTurnPrompt || bfTurnCompletion) {
|
|
604747
605317
|
recordTokenUsage(this._appState, bfTurnPrompt, bfTurnCompletion, 0, false);
|
|
@@ -604871,7 +605441,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604871
605441
|
summary = extractTaskCompleteSummary(taskCompleteArgs);
|
|
604872
605442
|
this._onTypedEvent?.({
|
|
604873
605443
|
type: "completion_requested",
|
|
604874
|
-
runId: this.
|
|
605444
|
+
runId: this.currentArtifactRunId(),
|
|
604875
605445
|
summary: (summary ?? "").slice(0, 500),
|
|
604876
605446
|
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
604877
605447
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -604929,7 +605499,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
604929
605499
|
summary = content;
|
|
604930
605500
|
this._onTypedEvent?.({
|
|
604931
605501
|
type: "completion_requested",
|
|
604932
|
-
runId: this.
|
|
605502
|
+
runId: this.currentArtifactRunId(),
|
|
604933
605503
|
summary: content.slice(0, 500),
|
|
604934
605504
|
sourcePath: this.options.streamEnabled ? "stream" : "batch",
|
|
604935
605505
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -605024,7 +605594,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
605024
605594
|
});
|
|
605025
605595
|
this._onTypedEvent?.({
|
|
605026
605596
|
type: "completion_requested",
|
|
605027
|
-
runId: this.
|
|
605597
|
+
runId: this.currentArtifactRunId(),
|
|
605028
605598
|
summary: summary.slice(0, 500),
|
|
605029
605599
|
sourcePath: "direct",
|
|
605030
605600
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -605081,7 +605651,7 @@ ${caveat}` : caveat;
|
|
|
605081
605651
|
});
|
|
605082
605652
|
this._onTypedEvent?.({
|
|
605083
605653
|
type: "run_finished",
|
|
605084
|
-
runId: this.
|
|
605654
|
+
runId: this.currentArtifactRunId(),
|
|
605085
605655
|
status: runStatus,
|
|
605086
605656
|
success: completed,
|
|
605087
605657
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
@@ -605769,7 +606339,8 @@ ${caveat}` : caveat;
|
|
|
605769
606339
|
const trajDir = path16.join(this.omniusStateDir(), "trajectories");
|
|
605770
606340
|
fs14.mkdirSync(trajDir, { recursive: true });
|
|
605771
606341
|
const trajectory = {
|
|
605772
|
-
id: this.
|
|
606342
|
+
id: this.currentArtifactRunId(),
|
|
606343
|
+
sessionId: this._sessionId,
|
|
605773
606344
|
// CLEAN task — this file is the prerequisite for ALL future RL/RFT
|
|
605774
606345
|
// training. Storing the scaffolded version would teach future models
|
|
605775
606346
|
// to reproduce signpost text as part of their task understanding.
|
|
@@ -606002,7 +606573,7 @@ ${marker}` : marker);
|
|
|
606002
606573
|
].filter(Boolean).join("\n"));
|
|
606003
606574
|
}
|
|
606004
606575
|
shouldBypassDiscoveryCompaction(output) {
|
|
606005
|
-
return output.includes("[IMAGE_BASE64:") || output.includes("[BRANCH-EXTRACT]") || output.includes("[REPEAT GATE - cached evidence not re-sent]") || output.includes("[CACHED READ — content unchanged") || output.includes("[REHYDRATED FROM CACHE") || output.includes("[Tool output truncated") || output.includes(TRIAGE_ENVELOPE_MARKER);
|
|
606576
|
+
return output.includes("[IMAGE_BASE64:") || output.includes("[BRANCH-EXTRACT]") || output.includes("[REPEAT GATE - cached evidence not re-sent]") || output.includes("[REPEATED_READ_REJECTED]") || output.includes("[REPEATED_NARROW_READ_REJECTED]") || output.includes("[CACHED READ — content unchanged") || output.includes("[REHYDRATED FROM CACHE") || output.includes("[Tool output truncated") || output.includes(TRIAGE_ENVELOPE_MARKER);
|
|
606006
606577
|
}
|
|
606007
606578
|
countTextLines(text2) {
|
|
606008
606579
|
if (!text2)
|
|
@@ -608578,6 +609149,8 @@ ${trimmedNew}`;
|
|
|
608578
609149
|
* adversary buffer, this is populated directly after tool execution and does
|
|
608579
609150
|
* not depend on raw tool messages surviving compaction. */
|
|
608580
609151
|
_recentToolOutcomes = [];
|
|
609152
|
+
/** Recent successful user-work mutations suppress generic "create again" nudges. */
|
|
609153
|
+
_groundTruthSuccessPaths = /* @__PURE__ */ new Map();
|
|
608581
609154
|
/** Monotonic counter for observed local state changes.
|
|
608582
609155
|
* Redundant-action classification is only valid within the same state
|
|
608583
609156
|
* version; a repeated verifier after an edit is fresh evidence. */
|
|
@@ -608704,10 +609277,85 @@ ${trimmedNew}`;
|
|
|
608704
609277
|
succeeded: input.result.success === true,
|
|
608705
609278
|
...outcomeEvidence
|
|
608706
609279
|
});
|
|
609280
|
+
if (input.result.success === true && this._isRealProjectMutation(input.toolName, input.result)) {
|
|
609281
|
+
for (const rawPath of this._extractToolTargetPaths(input.toolName, input.args ?? {}, input.result)) {
|
|
609282
|
+
const path16 = this._normalizeEvidencePath(rawPath);
|
|
609283
|
+
if (!path16 || path16.startsWith(".omnius/"))
|
|
609284
|
+
continue;
|
|
609285
|
+
this._groundTruthSuccessPaths.set(path16, { turn: input.turn });
|
|
609286
|
+
}
|
|
609287
|
+
this._reg61CooldownUntilTurn = Math.max(this._reg61CooldownUntilTurn, input.turn + 5);
|
|
609288
|
+
}
|
|
608707
609289
|
while (this._recentToolOutcomes.length > 40) {
|
|
608708
609290
|
this._recentToolOutcomes.shift();
|
|
608709
609291
|
}
|
|
608710
609292
|
}
|
|
609293
|
+
/** Late, bounded execution facts. Never use model prose or controller files. */
|
|
609294
|
+
_buildRecentActionGroundTruth(turn) {
|
|
609295
|
+
const activePaths = [...this._taskState.modifiedFiles.entries()].map(([rawPath, rawAction]) => ({
|
|
609296
|
+
path: this._normalizeEvidencePath(rawPath),
|
|
609297
|
+
rawAction
|
|
609298
|
+
})).filter((entry) => entry.path && !entry.path.startsWith(".omnius/")).slice(-8);
|
|
609299
|
+
if (activePaths.length === 0)
|
|
609300
|
+
return null;
|
|
609301
|
+
const verifier = this._worldFacts.lastTest;
|
|
609302
|
+
const verifierState = verifier?.summary ? `outcome=${verifier.passed ? "passed" : "failed"} turn=${verifier.turn ?? "?"}` : "outcome=not_recorded";
|
|
609303
|
+
const verifierRequired = this._compileFixLoop?.active === true && this._compileFixLoop.verifierDirtySinceTurn !== null;
|
|
609304
|
+
const lines = [
|
|
609305
|
+
"[RECENT ACTION GROUND TRUTH]",
|
|
609306
|
+
`turn=${turn} stateVersion=${this._adversaryStateVersion}`,
|
|
609307
|
+
`verifier=${verifierState}`
|
|
609308
|
+
];
|
|
609309
|
+
for (const entry of activePaths) {
|
|
609310
|
+
const action = /creat/i.test(entry.rawAction) ? "created" : /delet/i.test(entry.rawAction) ? "deleted" : "modified";
|
|
609311
|
+
const evidence = this._evidenceLedger.get(entry.path);
|
|
609312
|
+
const fact = this._worldFacts.files.get(entry.path);
|
|
609313
|
+
const outcome = [...this._recentToolOutcomes].reverse().find((item) => item.path && this._normalizeEvidencePath(item.path) === entry.path);
|
|
609314
|
+
const resultState = outcome ? outcome.succeeded ? "tool_result=success" : "tool_result=failure" : "tool_result=not_recorded";
|
|
609315
|
+
const hash = evidence?.contentHash ?? "unknown";
|
|
609316
|
+
const bytes = fact && typeof fact.size === "number" ? String(fact.size) : "unknown";
|
|
609317
|
+
const nextAction = verifierRequired ? "run_declared_verifier" : outcome?.succeeded ? "verify_or_complete_distinct_leaf" : "inspect_external_blocker_or_change_scope";
|
|
609318
|
+
const doNot = action === "created" ? "do_not_create_again" : action === "modified" ? "do_not_full_rewrite_without_fresh_read" : "do_not_recreate_without_authoritative_target";
|
|
609319
|
+
lines.push(`${action} path=${entry.path} hash=${hash} bytes=${bytes} ${resultState} stateVersion=${outcome?.stateVersion ?? this._adversaryStateVersion} turn=${outcome?.turn ?? turn} next_valid_action=${nextAction} ${doNot}`);
|
|
609320
|
+
}
|
|
609321
|
+
lines.push("Use these facts over stale assistant plans, broad summaries, or controller artifacts.");
|
|
609322
|
+
return lines.join("\n").slice(0, 5200);
|
|
609323
|
+
}
|
|
609324
|
+
/** Mark a workboard target complete when a confirmed creation satisfies it. */
|
|
609325
|
+
_reconcileCreationGroundTruth(toolName, args, result, turn) {
|
|
609326
|
+
if (result.success !== true || !this._isRealProjectMutation(toolName, result)) {
|
|
609327
|
+
return;
|
|
609328
|
+
}
|
|
609329
|
+
const created = this._extractToolTargetPaths(toolName, args, result).map((path16) => this._normalizeEvidencePath(path16)).filter((path16) => path16 && !path16.startsWith(".omnius/") && /creat/i.test(this._taskState.modifiedFiles.get(path16) ?? ""));
|
|
609330
|
+
if (created.length === 0)
|
|
609331
|
+
return;
|
|
609332
|
+
const board = this._workboard ?? this.getOrCreateWorkboard();
|
|
609333
|
+
if (board) {
|
|
609334
|
+
const card = this._workboardTodoCardForPaths(board, created);
|
|
609335
|
+
if (card && (card.status === "open" || card.status === "in_progress" || card.status === "needs_changes")) {
|
|
609336
|
+
try {
|
|
609337
|
+
const completed = completeWorkboardCard(this._workboardDir(), {
|
|
609338
|
+
runId: this.currentArtifactRunId(),
|
|
609339
|
+
cardId: card.id,
|
|
609340
|
+
actor: this.options.subAgent ? "sub-agent" : "agent",
|
|
609341
|
+
outcome: "completed",
|
|
609342
|
+
reason: `Creation ground truth satisfied mapped target(s): ${created.join(", ")} at turn ${turn}.`
|
|
609343
|
+
});
|
|
609344
|
+
this._workboard = completed.snapshot;
|
|
609345
|
+
} catch {
|
|
609346
|
+
}
|
|
609347
|
+
}
|
|
609348
|
+
}
|
|
609349
|
+
for (const todo of this.readSessionTodos() ?? []) {
|
|
609350
|
+
const artifacts = Array.isArray(todo.declaredArtifacts) ? todo.declaredArtifacts.filter((path16) => typeof path16 === "string").map((path16) => this._normalizeEvidencePath(path16)) : [];
|
|
609351
|
+
if (todo.status !== "completed" && artifacts.length > 0 && artifacts.every((path16) => created.includes(path16))) {
|
|
609352
|
+
const marker = `created target evidence: ${todo.content}`;
|
|
609353
|
+
if (!this._taskState.completedSteps.includes(marker)) {
|
|
609354
|
+
this._taskState.completedSteps.push(marker);
|
|
609355
|
+
}
|
|
609356
|
+
}
|
|
609357
|
+
}
|
|
609358
|
+
}
|
|
608711
609359
|
_recentToolActionsForWorldState() {
|
|
608712
609360
|
if (this._recentToolOutcomes.length > 0)
|
|
608713
609361
|
return this._recentToolOutcomes;
|
|
@@ -610462,7 +611110,7 @@ ${result}`
|
|
|
610462
611110
|
stage: "vision_image_recovery",
|
|
610463
611111
|
agentType: "internal",
|
|
610464
611112
|
sessionId: this._sessionId,
|
|
610465
|
-
runId: this._sessionId,
|
|
611113
|
+
runId: this._activeRunId || this._sessionId,
|
|
610466
611114
|
turn,
|
|
610467
611115
|
attempt: 0,
|
|
610468
611116
|
model,
|
|
@@ -610490,7 +611138,7 @@ ${result}`
|
|
|
610490
611138
|
stage: "vision_image_recovery",
|
|
610491
611139
|
agentType: "internal",
|
|
610492
611140
|
sessionId: this._sessionId,
|
|
610493
|
-
runId: this._sessionId,
|
|
611141
|
+
runId: this._activeRunId || this._sessionId,
|
|
610494
611142
|
turn,
|
|
610495
611143
|
attempt: 1,
|
|
610496
611144
|
model,
|
|
@@ -610570,7 +611218,7 @@ ${description}`
|
|
|
610570
611218
|
* Returns the response on success, or null if recovery did not apply.
|
|
610571
611219
|
*/
|
|
610572
611220
|
async retryOnTransient(initialErr, chatRequest, turn) {
|
|
610573
|
-
if (this.aborted)
|
|
611221
|
+
if (this.aborted || this._pendingSteeringPreemption)
|
|
610574
611222
|
return null;
|
|
610575
611223
|
if (!this.isTransientError(initialErr))
|
|
610576
611224
|
return null;
|
|
@@ -610584,7 +611232,7 @@ ${description}`
|
|
|
610584
611232
|
const backend = this.backend;
|
|
610585
611233
|
let attempt = 1;
|
|
610586
611234
|
while (attempt <= (maxRetries === Infinity ? Number.MAX_SAFE_INTEGER : maxRetries)) {
|
|
610587
|
-
if (this.aborted)
|
|
611235
|
+
if (this.aborted || this._pendingSteeringPreemption)
|
|
610588
611236
|
return null;
|
|
610589
611237
|
if (this.isPaymentRequiredError(initialErr) && typeof backend.rotateKey === "function") {
|
|
610590
611238
|
const rotated = backend.rotateKey();
|
|
@@ -610651,7 +611299,7 @@ ${description}`
|
|
|
610651
611299
|
});
|
|
610652
611300
|
}
|
|
610653
611301
|
await new Promise((r2) => setTimeout(r2, effectiveDelay));
|
|
610654
|
-
if (this.aborted)
|
|
611302
|
+
if (this.aborted || this._pendingSteeringPreemption)
|
|
610655
611303
|
return null;
|
|
610656
611304
|
try {
|
|
610657
611305
|
this._recordContextWindowDump("agent_turn_transient_retry", chatRequest, turn, attempt);
|
|
@@ -610719,7 +611367,7 @@ ${description}`
|
|
|
610719
611367
|
}
|
|
610720
611368
|
}
|
|
610721
611369
|
for await (const chunk of backend.chatCompletionStream(request)) {
|
|
610722
|
-
if (this.aborted)
|
|
611370
|
+
if (this.aborted || this._pendingSteeringPreemption)
|
|
610723
611371
|
break;
|
|
610724
611372
|
if (chunk.type === "usage" && chunk.usage) {
|
|
610725
611373
|
streamUsage = chunk.usage;
|
|
@@ -611932,8 +612580,6 @@ var init_nexusBackend = __esm({
|
|
|
611932
612580
|
effectiveThink(request) {
|
|
611933
612581
|
if (process.env["OMNIUS_FORCE_NO_THINK"] === "1")
|
|
611934
612582
|
return false;
|
|
611935
|
-
if (process.env["OMNIUS_ENABLE_THINKING"] !== "1")
|
|
611936
|
-
return false;
|
|
611937
612583
|
if (Array.isArray(request.tools) && request.tools.length > 0)
|
|
611938
612584
|
return false;
|
|
611939
612585
|
if (request.think === true)
|
|
@@ -633315,11 +633961,149 @@ async function queryOpenAIContextSize(baseUrl2, modelName, apiKey) {
|
|
|
633315
633961
|
return null;
|
|
633316
633962
|
}
|
|
633317
633963
|
}
|
|
633318
|
-
|
|
633319
|
-
|
|
633964
|
+
function llamaCppRootUrl(baseUrl2) {
|
|
633965
|
+
return normalizeBaseUrl(baseUrl2).replace(/\/v1$/i, "");
|
|
633966
|
+
}
|
|
633967
|
+
function asRecord(value2) {
|
|
633968
|
+
return value2 !== null && typeof value2 === "object" && !Array.isArray(value2) ? value2 : null;
|
|
633969
|
+
}
|
|
633970
|
+
function positiveInteger(value2) {
|
|
633971
|
+
const parsed = typeof value2 === "number" ? value2 : typeof value2 === "string" && /^\d+$/.test(value2.trim()) ? Number(value2) : NaN;
|
|
633972
|
+
return Number.isFinite(parsed) && parsed > 0 ? Math.floor(parsed) : void 0;
|
|
633973
|
+
}
|
|
633974
|
+
function firstPositive(record, keys) {
|
|
633975
|
+
for (const key of keys) {
|
|
633976
|
+
const value2 = positiveInteger(record[key]);
|
|
633977
|
+
if (value2 !== void 0) return value2;
|
|
633978
|
+
}
|
|
633979
|
+
return void 0;
|
|
633980
|
+
}
|
|
633981
|
+
function contextCapacityFromRecord(record) {
|
|
633982
|
+
return firstPositive(record, [
|
|
633983
|
+
"n_ctx",
|
|
633984
|
+
"n_ctx_train",
|
|
633985
|
+
"context_length",
|
|
633986
|
+
"context_window",
|
|
633987
|
+
"max_model_len",
|
|
633988
|
+
"max_context_length"
|
|
633989
|
+
]);
|
|
633990
|
+
}
|
|
633991
|
+
function telemetryHeaders(apiKey) {
|
|
633992
|
+
return apiKey ? { Authorization: `Bearer ${apiKey}` } : void 0;
|
|
633993
|
+
}
|
|
633994
|
+
async function fetchTelemetryJson(url, apiKey) {
|
|
633995
|
+
try {
|
|
633996
|
+
const response = await fetch(url, {
|
|
633997
|
+
headers: telemetryHeaders(apiKey),
|
|
633998
|
+
signal: AbortSignal.timeout(LLAMA_CPP_TELEMETRY_TIMEOUT_MS)
|
|
633999
|
+
});
|
|
634000
|
+
return response.ok ? await response.json() : null;
|
|
634001
|
+
} catch {
|
|
634002
|
+
return null;
|
|
634003
|
+
}
|
|
634004
|
+
}
|
|
634005
|
+
function llamaCppSlotsFromJson(raw, endpoint, model) {
|
|
634006
|
+
const root = asRecord(raw);
|
|
634007
|
+
const slots = Array.isArray(raw) ? raw : Array.isArray(root?.["slots"]) ? root["slots"] : null;
|
|
634008
|
+
if (!slots) return null;
|
|
634009
|
+
const active = slots.map(asRecord).filter((slot) => {
|
|
634010
|
+
if (!slot) return false;
|
|
634011
|
+
return slot["is_processing"] === true || firstPositive(slot, ["n_prompt_tokens", "n_past", "n_decoded", "n_tokens"]) !== void 0;
|
|
634012
|
+
});
|
|
634013
|
+
if (active.length === 0) {
|
|
634014
|
+
return { endpoint, model, activeSlotCount: 0, isLlamaCpp: true };
|
|
634015
|
+
}
|
|
634016
|
+
const measured = active.map((slot) => {
|
|
634017
|
+
const promptTokens = firstPositive(slot, ["n_prompt_tokens", "prompt_tokens"]);
|
|
634018
|
+
const decodedTokens = firstPositive(slot, ["n_decoded", "n_generated", "n_output_tokens"]);
|
|
634019
|
+
const observed = promptTokens !== void 0 ? promptTokens + (decodedTokens ?? 0) : firstPositive(slot, ["n_past", "n_tokens"]) ?? decodedTokens;
|
|
634020
|
+
return {
|
|
634021
|
+
capacityTokens: firstPositive(slot, ["n_ctx", "context_length"]),
|
|
634022
|
+
promptTokens,
|
|
634023
|
+
decodedTokens,
|
|
634024
|
+
outputReservationTokens: firstPositive(slot, ["n_predict", "n_predict_max", "n_output_reservation"]),
|
|
634025
|
+
estimatedContextTokens: observed
|
|
634026
|
+
};
|
|
634027
|
+
});
|
|
634028
|
+
const selected = measured.reduce(
|
|
634029
|
+
(best, candidate) => (candidate.estimatedContextTokens ?? 0) > (best.estimatedContextTokens ?? 0) ? candidate : best
|
|
634030
|
+
);
|
|
634031
|
+
return {
|
|
634032
|
+
endpoint,
|
|
634033
|
+
model,
|
|
634034
|
+
...selected,
|
|
634035
|
+
capacitySource: selected.capacityTokens ? "llama_cpp_slots" : void 0,
|
|
634036
|
+
activeSlotCount: active.length,
|
|
634037
|
+
isLlamaCpp: true
|
|
634038
|
+
};
|
|
634039
|
+
}
|
|
634040
|
+
async function queryLlamaCppSlotTelemetry(baseUrl2, modelName, apiKey) {
|
|
634041
|
+
const endpoint = llamaCppRootUrl(baseUrl2);
|
|
634042
|
+
const slots = await fetchTelemetryJson(`${endpoint}/slots`, apiKey);
|
|
634043
|
+
return llamaCppSlotsFromJson(slots, endpoint, modelName);
|
|
634044
|
+
}
|
|
634045
|
+
function llamaCppModelCapacity(raw, modelName) {
|
|
634046
|
+
const root = asRecord(raw);
|
|
634047
|
+
if (!root) return void 0;
|
|
634048
|
+
const records = Array.isArray(root["data"]) ? root["data"].map(asRecord).filter((entry) => entry !== null) : [];
|
|
634049
|
+
const target = records.find(
|
|
634050
|
+
(entry) => [entry["id"], entry["name"], entry["model"]].some(
|
|
634051
|
+
(value2) => typeof value2 === "string" && value2 === modelName
|
|
634052
|
+
)
|
|
634053
|
+
);
|
|
634054
|
+
return (target && contextCapacityFromRecord(target)) ?? contextCapacityFromRecord(root);
|
|
634055
|
+
}
|
|
634056
|
+
async function queryLlamaCppContextTelemetry(baseUrl2, modelName, apiKey) {
|
|
634057
|
+
const endpoint = llamaCppRootUrl(baseUrl2);
|
|
634058
|
+
const [propsRaw, modelsRaw, slotsRaw] = await Promise.all([
|
|
634059
|
+
fetchTelemetryJson(`${endpoint}/props`, apiKey),
|
|
634060
|
+
fetchTelemetryJson(`${endpoint}/v1/models`, apiKey),
|
|
634061
|
+
fetchTelemetryJson(`${endpoint}/slots`, apiKey)
|
|
634062
|
+
]);
|
|
634063
|
+
const props = asRecord(propsRaw);
|
|
634064
|
+
const slots = llamaCppSlotsFromJson(slotsRaw, endpoint, modelName);
|
|
634065
|
+
const propsCapacity = props ? contextCapacityFromRecord(props) : void 0;
|
|
634066
|
+
const modelsCapacity = llamaCppModelCapacity(modelsRaw, modelName);
|
|
634067
|
+
const isLlamaCpp = props !== null || slots !== null;
|
|
634068
|
+
if (!isLlamaCpp) return null;
|
|
634069
|
+
const capacityTokens = propsCapacity ?? modelsCapacity ?? slots?.capacityTokens;
|
|
634070
|
+
const capacitySource = propsCapacity ? "llama_cpp_props" : modelsCapacity ? "llama_cpp_models" : slots?.capacityTokens ? "llama_cpp_slots" : void 0;
|
|
634071
|
+
return {
|
|
634072
|
+
endpoint,
|
|
634073
|
+
model: modelName,
|
|
634074
|
+
...slots,
|
|
634075
|
+
capacityTokens,
|
|
634076
|
+
capacitySource,
|
|
634077
|
+
isLlamaCpp: true
|
|
634078
|
+
};
|
|
634079
|
+
}
|
|
634080
|
+
async function queryContextTelemetry(baseUrl2, modelName, apiKey) {
|
|
634081
|
+
const endpoint = normalizeBaseUrl(baseUrl2);
|
|
634082
|
+
if (baseUrl2.startsWith("peer://")) {
|
|
634083
|
+
return {
|
|
634084
|
+
endpoint,
|
|
634085
|
+
model: modelName,
|
|
634086
|
+
capacityTokens: 32768,
|
|
634087
|
+
capacitySource: "peer_default"
|
|
634088
|
+
};
|
|
634089
|
+
}
|
|
633320
634090
|
const ollamaSize = await queryModelContextSize(baseUrl2, modelName);
|
|
633321
|
-
if (ollamaSize)
|
|
633322
|
-
|
|
634091
|
+
if (ollamaSize) {
|
|
634092
|
+
return { endpoint, model: modelName, capacityTokens: ollamaSize, capacitySource: "ollama_show" };
|
|
634093
|
+
}
|
|
634094
|
+
const llama = await queryLlamaCppContextTelemetry(baseUrl2, modelName, apiKey);
|
|
634095
|
+
const openAiSize = await queryOpenAIContextSize(baseUrl2, modelName, apiKey);
|
|
634096
|
+
if (openAiSize) {
|
|
634097
|
+
return {
|
|
634098
|
+
...llama ?? { endpoint, model: modelName },
|
|
634099
|
+
capacityTokens: openAiSize,
|
|
634100
|
+
capacitySource: llama?.capacitySource ?? "openai_models"
|
|
634101
|
+
};
|
|
634102
|
+
}
|
|
634103
|
+
return llama ?? { endpoint, model: modelName };
|
|
634104
|
+
}
|
|
634105
|
+
async function queryContextSize(baseUrl2, modelName, apiKey) {
|
|
634106
|
+
return (await queryContextTelemetry(baseUrl2, modelName, apiKey)).capacityTokens ?? null;
|
|
633323
634107
|
}
|
|
633324
634108
|
async function queryModelCapabilities(baseUrl2, modelName) {
|
|
633325
634109
|
const caps = { vision: false, toolUse: false, thinking: false };
|
|
@@ -633412,7 +634196,7 @@ function formatRelativeTime(iso2) {
|
|
|
633412
634196
|
const months = Math.floor(days / 30);
|
|
633413
634197
|
return `${months}mo ago`;
|
|
633414
634198
|
}
|
|
633415
|
-
var IMAGE_GEN_PATTERNS;
|
|
634199
|
+
var IMAGE_GEN_PATTERNS, LLAMA_CPP_TELEMETRY_TIMEOUT_MS;
|
|
633416
634200
|
var init_model_picker = __esm({
|
|
633417
634201
|
"packages/cli/src/tui/model-picker.ts"() {
|
|
633418
634202
|
init_dist6();
|
|
@@ -633426,6 +634210,7 @@ var init_model_picker = __esm({
|
|
|
633426
634210
|
/midjourney/i,
|
|
633427
634211
|
/imagen/i
|
|
633428
634212
|
];
|
|
634213
|
+
LLAMA_CPP_TELEMETRY_TIMEOUT_MS = 2500;
|
|
633429
634214
|
}
|
|
633430
634215
|
});
|
|
633431
634216
|
|
|
@@ -633689,6 +634474,237 @@ var init_tool_collapse_store = __esm({
|
|
|
633689
634474
|
}
|
|
633690
634475
|
});
|
|
633691
634476
|
|
|
634477
|
+
// packages/cli/src/utils/internal-output.ts
|
|
634478
|
+
function compactForDisplay(text2, max = 170) {
|
|
634479
|
+
const clean5 = text2.replace(/\s+/g, " ").trim();
|
|
634480
|
+
return clean5.length <= max ? clean5 : `${clean5.slice(0, Math.max(0, max - 1)).trimEnd()}…`;
|
|
634481
|
+
}
|
|
634482
|
+
function parseAssignmentMap(line) {
|
|
634483
|
+
const out = {};
|
|
634484
|
+
const assignmentRe = /(\w+)=([^\s]+)/g;
|
|
634485
|
+
let m2;
|
|
634486
|
+
while ((m2 = assignmentRe.exec(line)) !== null) {
|
|
634487
|
+
out[m2[1].toLowerCase()] = m2[2];
|
|
634488
|
+
}
|
|
634489
|
+
return out;
|
|
634490
|
+
}
|
|
634491
|
+
function extractFirstMatch(lines, pattern) {
|
|
634492
|
+
for (const line of lines) {
|
|
634493
|
+
const match = line.match(pattern);
|
|
634494
|
+
if (match?.[1]) return match[1].trim();
|
|
634495
|
+
}
|
|
634496
|
+
return "";
|
|
634497
|
+
}
|
|
634498
|
+
function formatBranchExtractSummary(output) {
|
|
634499
|
+
const lines = output.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
634500
|
+
if (lines.length === 0) return null;
|
|
634501
|
+
const first2 = lines[0].toLowerCase();
|
|
634502
|
+
const isBranchExtract = first2.startsWith("[branch-extract") || first2.startsWith("[branch-duplicate-blocked]");
|
|
634503
|
+
if (!isBranchExtract) return null;
|
|
634504
|
+
const routingLine = lines.find((line) => line.toLowerCase().startsWith("routing=")) || "";
|
|
634505
|
+
const assignment = parseAssignmentMap(routingLine);
|
|
634506
|
+
const route = assignment.routing ?? "mandatory";
|
|
634507
|
+
const reasons = assignment.reasons?.split(",").map((r2) => r2.trim()).filter(Boolean).join(", ") || "context protection";
|
|
634508
|
+
const projected = assignment.projected_read_tokens || assignment.projectedreadtokens || assignment.projected;
|
|
634509
|
+
const fractionLimit = assignment.fraction_limit_tokens || assignment.fractionlimittokens || assignment.fraction_limit || "";
|
|
634510
|
+
const available = assignment.available_headroom_tokens || assignment.available_headroom;
|
|
634511
|
+
const path16 = extractFirstMatch(
|
|
634512
|
+
lines,
|
|
634513
|
+
/(?:^|\s)path=(\S+)/
|
|
634514
|
+
) || extractFirstMatch(lines, /\[branch-extract[^\]]*?\]\s*path=([^\s]+)/) || "unknown path";
|
|
634515
|
+
const discoveryStart = lines.findIndex(
|
|
634516
|
+
(line) => /^\[discovery contract\]/i.test(line)
|
|
634517
|
+
);
|
|
634518
|
+
const curatedStart = lines.findIndex(
|
|
634519
|
+
(line) => /^\[curated segments\]/i.test(line)
|
|
634520
|
+
);
|
|
634521
|
+
let goalAnchor = "";
|
|
634522
|
+
let request = "";
|
|
634523
|
+
const required = [];
|
|
634524
|
+
let inRequired = false;
|
|
634525
|
+
let stopCondition = "";
|
|
634526
|
+
if (discoveryStart >= 0) {
|
|
634527
|
+
for (let i2 = discoveryStart + 1; i2 < lines.length; i2 += 1) {
|
|
634528
|
+
const line = lines[i2];
|
|
634529
|
+
if (/^\[curated segments\]/i.test(line)) break;
|
|
634530
|
+
if (/^Goal anchor:/i.test(line)) {
|
|
634531
|
+
goalAnchor = line.replace(/^Goal anchor:\s*/i, "");
|
|
634532
|
+
inRequired = false;
|
|
634533
|
+
continue;
|
|
634534
|
+
}
|
|
634535
|
+
if (/^Request:/i.test(line)) {
|
|
634536
|
+
request = line.replace(/^Request:\s*/i, "");
|
|
634537
|
+
inRequired = false;
|
|
634538
|
+
continue;
|
|
634539
|
+
}
|
|
634540
|
+
if (/^Stop conditions?:/i.test(line)) {
|
|
634541
|
+
stopCondition = line.replace(/^Stop conditions?:\s*/i, "");
|
|
634542
|
+
inRequired = false;
|
|
634543
|
+
continue;
|
|
634544
|
+
}
|
|
634545
|
+
if (/^Required discoveries:/i.test(line)) {
|
|
634546
|
+
inRequired = true;
|
|
634547
|
+
continue;
|
|
634548
|
+
}
|
|
634549
|
+
if (inRequired && line.startsWith("- ")) {
|
|
634550
|
+
required.push(line.replace(/^- /, "").slice(0, 170));
|
|
634551
|
+
}
|
|
634552
|
+
}
|
|
634553
|
+
}
|
|
634554
|
+
let curatedSummary = "";
|
|
634555
|
+
let unresolved = "";
|
|
634556
|
+
let satisfied = "";
|
|
634557
|
+
let provenance = "";
|
|
634558
|
+
if (curatedStart >= 0) {
|
|
634559
|
+
for (let i2 = curatedStart + 1; i2 < lines.length; i2 += 1) {
|
|
634560
|
+
const line = lines[i2];
|
|
634561
|
+
if (/^satisfied=/i.test(line) || /^unresolved=/i.test(line) || /^provenance=/i.test(line)) {
|
|
634562
|
+
if (line.startsWith("satisfied=")) {
|
|
634563
|
+
satisfied = line.replace(/^satisfied=/i, "");
|
|
634564
|
+
} else if (line.startsWith("unresolved=")) {
|
|
634565
|
+
unresolved = line.replace(/^unresolved=/i, "");
|
|
634566
|
+
} else if (line.startsWith("provenance=")) {
|
|
634567
|
+
provenance = line.replace(/^provenance=/i, "");
|
|
634568
|
+
}
|
|
634569
|
+
continue;
|
|
634570
|
+
}
|
|
634571
|
+
if (/^Contract:/i.test(line)) {
|
|
634572
|
+
continue;
|
|
634573
|
+
}
|
|
634574
|
+
if (curatedSummary.length < 240) {
|
|
634575
|
+
curatedSummary = curatedSummary ? `${curatedSummary} ${compactForDisplay(line, 120)}` : compactForDisplay(line, 120);
|
|
634576
|
+
}
|
|
634577
|
+
}
|
|
634578
|
+
}
|
|
634579
|
+
const isDuplicate = /^\[branch-duplicate-blocked\]/i.test(lines[0]);
|
|
634580
|
+
const header = isDuplicate ? "Branch-extract duplicate reuse" : "Branch-extract preempted";
|
|
634581
|
+
const whatHappened = isDuplicate ? "a cache-safe duplicate was detected" : "read was auto-summarized before injecting into context";
|
|
634582
|
+
const out = [
|
|
634583
|
+
`↳ ${header}`,
|
|
634584
|
+
` ├ what happened: ${whatHappened}`,
|
|
634585
|
+
` ├ why: ${compactForDisplay(reasons, 140)}`,
|
|
634586
|
+
` ├ path: ${compactForDisplay(path16, 140)}`,
|
|
634587
|
+
` ├ decision scope: ${route}`
|
|
634588
|
+
];
|
|
634589
|
+
if (projected) {
|
|
634590
|
+
const projectedText = fractionLimit ? `${projected} projected → ${fractionLimit} limit` : `${projected} projected`;
|
|
634591
|
+
const availText = available ? `; available headroom ${available}` : "";
|
|
634592
|
+
out.push(` ├ budget: ${projectedText}${availText}`);
|
|
634593
|
+
}
|
|
634594
|
+
if (goalAnchor) out.push(` ├ goal anchor: ${compactForDisplay(goalAnchor, 120)}`);
|
|
634595
|
+
if (request) out.push(` ├ request: ${compactForDisplay(request, 150)}`);
|
|
634596
|
+
if (required.length > 0) {
|
|
634597
|
+
out.push(` ├ required: ${compactForDisplay(required.slice(0, 3).join(", "), 180)}`);
|
|
634598
|
+
}
|
|
634599
|
+
if (stopCondition) {
|
|
634600
|
+
out.push(` ├ stop: ${compactForDisplay(stopCondition, 140)}`);
|
|
634601
|
+
}
|
|
634602
|
+
if (curatedSummary) {
|
|
634603
|
+
out.push(` ├ curated segment: ${compactForDisplay(curatedSummary, 180)}`);
|
|
634604
|
+
}
|
|
634605
|
+
if (satisfied || unresolved) {
|
|
634606
|
+
out.push(
|
|
634607
|
+
` ├ state: satisfied=${compactForDisplay(satisfied || "none", 90)}; unresolved=${compactForDisplay(unresolved || "none", 90)}`
|
|
634608
|
+
);
|
|
634609
|
+
}
|
|
634610
|
+
if (provenance) {
|
|
634611
|
+
out.push(` ├ provenance: ${compactForDisplay(provenance, 120)}`);
|
|
634612
|
+
}
|
|
634613
|
+
if (out.length > 1) {
|
|
634614
|
+
const last2 = out.length - 1;
|
|
634615
|
+
out[last2] = out[last2]?.replace(/^ ├ /, " └ ") ?? out[last2];
|
|
634616
|
+
}
|
|
634617
|
+
return out.length > 0 ? out : null;
|
|
634618
|
+
}
|
|
634619
|
+
function formatEchoGuardSummary(output) {
|
|
634620
|
+
const lower = output.toLowerCase();
|
|
634621
|
+
const match = output.match(/echo-1:\s*text-only echo\s*#?(\d+)/i);
|
|
634622
|
+
const echoCount = match?.[1] ? `#${match[1]}` : "";
|
|
634623
|
+
const similarityMatch = output.match(/(\d+)% similar/);
|
|
634624
|
+
const similarity3 = similarityMatch?.[1] ? ` (${similarityMatch[1]}% similar to earlier response)` : "";
|
|
634625
|
+
const collapsed = output.match(/collapsed\s+(\d+)\s+duplicate/);
|
|
634626
|
+
const duplicates = collapsed?.[1] ? `${collapsed[1]} duplicate(s) collapsed` : "";
|
|
634627
|
+
return [
|
|
634628
|
+
`↳ ECHO-1 mode-collapse guard${echoCount ? ` ${echoCount}` : ""}${similarity3}`,
|
|
634629
|
+
" ├ what happened: repeated text-only plan was intercepted",
|
|
634630
|
+
" ├ why: duplicate plan text was detected from the model loop",
|
|
634631
|
+
` ├ action: pattern-breaker${duplicates ? ` (${duplicates})` : ""}`,
|
|
634632
|
+
" └ next action: resume with tool-backed evidence"
|
|
634633
|
+
];
|
|
634634
|
+
}
|
|
634635
|
+
function formatSupersededPlanSummary() {
|
|
634636
|
+
return [
|
|
634637
|
+
"↳ Mode-collapse guard",
|
|
634638
|
+
" ├ what happened: near-duplicate assistant plan was suppressed",
|
|
634639
|
+
" ├ why: loop prevention to stop re-entering the same plan text",
|
|
634640
|
+
" └ next action: tool call or concrete evidence request before restating the plan"
|
|
634641
|
+
];
|
|
634642
|
+
}
|
|
634643
|
+
function summarizeInternalControlOutput(output) {
|
|
634644
|
+
if (!output) return null;
|
|
634645
|
+
const firstLine = output.split(/\r?\n/)[0]?.trim().toLowerCase() ?? "";
|
|
634646
|
+
const lower = output.toLowerCase();
|
|
634647
|
+
if (firstLine.includes("[branch-extract") || firstLine.includes("[branch-duplicate-blocked]") || lower.includes("branch-extract preempted")) {
|
|
634648
|
+
return formatBranchExtractSummary(output);
|
|
634649
|
+
}
|
|
634650
|
+
if (firstLine.includes("[echo break") || firstLine.includes("[echo-break") || lower.includes("echo-1:")) {
|
|
634651
|
+
return formatEchoGuardSummary(output);
|
|
634652
|
+
}
|
|
634653
|
+
if (lower.includes("[superseded near-duplicate plan removed")) {
|
|
634654
|
+
return formatSupersededPlanSummary();
|
|
634655
|
+
}
|
|
634656
|
+
return null;
|
|
634657
|
+
}
|
|
634658
|
+
function isRunnerEventLine(line) {
|
|
634659
|
+
const raw = line.trim();
|
|
634660
|
+
if (!raw.startsWith("{") || !raw.endsWith("}")) return false;
|
|
634661
|
+
try {
|
|
634662
|
+
const parsed = JSON.parse(raw);
|
|
634663
|
+
return typeof parsed?.type === "string";
|
|
634664
|
+
} catch {
|
|
634665
|
+
return false;
|
|
634666
|
+
}
|
|
634667
|
+
}
|
|
634668
|
+
function isStatusEchoLine(line) {
|
|
634669
|
+
if (/^i\s+/.test(line)) return true;
|
|
634670
|
+
if (/^E\s+/.test(line)) return true;
|
|
634671
|
+
if (/^⚠\s*(Task incomplete|Task complete)/.test(line)) return true;
|
|
634672
|
+
if (/^▹\s/.test(line)) return true;
|
|
634673
|
+
if (/^User:\s/.test(line)) return true;
|
|
634674
|
+
if (/^Assistant:\s/.test(line)) return true;
|
|
634675
|
+
if (/^Previous conversation:/.test(line)) return true;
|
|
634676
|
+
if (/^omnius \(/.test(line)) return true;
|
|
634677
|
+
return false;
|
|
634678
|
+
}
|
|
634679
|
+
function stripAnsi2(text2) {
|
|
634680
|
+
return text2.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "").replace(/\x1B\].*?\x07/g, "").replace(/\x1B\[[\?]?[0-9;]*[hl]/g, "");
|
|
634681
|
+
}
|
|
634682
|
+
function sanitizeAgentOutputForUser(raw) {
|
|
634683
|
+
if (typeof raw !== "string") return "";
|
|
634684
|
+
const cleaned = stripAnsi2(raw);
|
|
634685
|
+
const summary = summarizeInternalControlOutput(cleaned.trim());
|
|
634686
|
+
if (summary) return summary.join("\n");
|
|
634687
|
+
const out = [];
|
|
634688
|
+
const lines = cleaned.split("\n");
|
|
634689
|
+
for (const rawLine of lines) {
|
|
634690
|
+
const line = rawLine.trim();
|
|
634691
|
+
if (!line) continue;
|
|
634692
|
+
if (isRunnerEventLine(line)) continue;
|
|
634693
|
+
const lineSummary = summarizeInternalControlOutput(line);
|
|
634694
|
+
if (lineSummary) {
|
|
634695
|
+
out.push(...lineSummary);
|
|
634696
|
+
continue;
|
|
634697
|
+
}
|
|
634698
|
+
if (isStatusEchoLine(line)) continue;
|
|
634699
|
+
out.push(line);
|
|
634700
|
+
}
|
|
634701
|
+
return out.join("\n").trim();
|
|
634702
|
+
}
|
|
634703
|
+
var init_internal_output = __esm({
|
|
634704
|
+
"packages/cli/src/utils/internal-output.ts"() {
|
|
634705
|
+
}
|
|
634706
|
+
});
|
|
634707
|
+
|
|
633692
634708
|
// packages/cli/src/tui/render.ts
|
|
633693
634709
|
var render_exports = {};
|
|
633694
634710
|
__export(render_exports, {
|
|
@@ -634399,186 +635415,6 @@ function sanitizeToolBoxContent(text2) {
|
|
|
634399
635415
|
}
|
|
634400
635416
|
return out;
|
|
634401
635417
|
}
|
|
634402
|
-
function compactForDisplay(text2, max = 170) {
|
|
634403
|
-
const clean5 = text2.replace(/\s+/g, " ").trim();
|
|
634404
|
-
return clean5.length <= max ? clean5 : `${clean5.slice(0, Math.max(0, max - 1)).trimEnd()}…`;
|
|
634405
|
-
}
|
|
634406
|
-
function parseAssignmentMap(line) {
|
|
634407
|
-
const out = {};
|
|
634408
|
-
const assignmentRe = /(\w+)=([^\s]+)/g;
|
|
634409
|
-
let m2;
|
|
634410
|
-
while ((m2 = assignmentRe.exec(line)) !== null) {
|
|
634411
|
-
out[m2[1].toLowerCase()] = m2[2];
|
|
634412
|
-
}
|
|
634413
|
-
return out;
|
|
634414
|
-
}
|
|
634415
|
-
function extractFirstMatch(lines, pattern) {
|
|
634416
|
-
for (const line of lines) {
|
|
634417
|
-
const match = line.match(pattern);
|
|
634418
|
-
if (match?.[1]) return match[1].trim();
|
|
634419
|
-
}
|
|
634420
|
-
return "";
|
|
634421
|
-
}
|
|
634422
|
-
function formatBranchExtractSummary(output) {
|
|
634423
|
-
const lines = output.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
634424
|
-
if (lines.length === 0) return null;
|
|
634425
|
-
const first2 = lines[0].toLowerCase();
|
|
634426
|
-
const isBranchExtract = first2.startsWith("[branch-extract") || first2.startsWith("[branch-duplicate-blocked]");
|
|
634427
|
-
if (!isBranchExtract) return null;
|
|
634428
|
-
const routingLine = lines.find((line) => line.toLowerCase().startsWith("routing=")) || "";
|
|
634429
|
-
const assignment = parseAssignmentMap(routingLine);
|
|
634430
|
-
const route = assignment.routing ?? "mandatory";
|
|
634431
|
-
const reasons = assignment.reasons?.split(",").map((r2) => r2.trim()).filter(Boolean).join(", ") || "context protection";
|
|
634432
|
-
const projected = assignment.projected_read_tokens || assignment.projectedreadtokens || assignment.projected;
|
|
634433
|
-
const fractionLimit = assignment.fraction_limit_tokens || assignment.fractionlimittokens || assignment.fraction_limit || "";
|
|
634434
|
-
const available = assignment.available_headroom_tokens || assignment.available_headroom;
|
|
634435
|
-
const path16 = extractFirstMatch(
|
|
634436
|
-
lines,
|
|
634437
|
-
/(?:^|\s)path=(\S+)/
|
|
634438
|
-
) || extractFirstMatch(lines, /\[branch-extract[^\]]*?\]\s*path=([^\s]+)/) || "unknown path";
|
|
634439
|
-
const discoveryStart = lines.findIndex(
|
|
634440
|
-
(line) => /^\[discovery contract\]/i.test(line)
|
|
634441
|
-
);
|
|
634442
|
-
const curatedStart = lines.findIndex(
|
|
634443
|
-
(line) => /^\[curated segments\]/i.test(line)
|
|
634444
|
-
);
|
|
634445
|
-
let goalAnchor = "";
|
|
634446
|
-
let request = "";
|
|
634447
|
-
const required = [];
|
|
634448
|
-
let inRequired = false;
|
|
634449
|
-
let stopCondition = "";
|
|
634450
|
-
if (discoveryStart >= 0) {
|
|
634451
|
-
for (let i2 = discoveryStart + 1; i2 < lines.length; i2 += 1) {
|
|
634452
|
-
const line = lines[i2];
|
|
634453
|
-
if (/^\[curated segments\]/i.test(line)) break;
|
|
634454
|
-
if (/^Goal anchor:/i.test(line)) {
|
|
634455
|
-
goalAnchor = line.replace(/^Goal anchor:\s*/i, "");
|
|
634456
|
-
continue;
|
|
634457
|
-
}
|
|
634458
|
-
if (/^Request:/i.test(line)) {
|
|
634459
|
-
request = line.replace(/^Request:\s*/i, "");
|
|
634460
|
-
inRequired = false;
|
|
634461
|
-
continue;
|
|
634462
|
-
}
|
|
634463
|
-
if (/^Stop conditions?:/i.test(line)) {
|
|
634464
|
-
stopCondition = line.replace(/^Stop conditions?:\s*/i, "");
|
|
634465
|
-
inRequired = false;
|
|
634466
|
-
continue;
|
|
634467
|
-
}
|
|
634468
|
-
if (/^Required discoveries:/i.test(line)) {
|
|
634469
|
-
inRequired = true;
|
|
634470
|
-
continue;
|
|
634471
|
-
}
|
|
634472
|
-
if (inRequired && line.startsWith("- ")) {
|
|
634473
|
-
required.push(line.replace(/^- /, "").slice(0, 170));
|
|
634474
|
-
}
|
|
634475
|
-
}
|
|
634476
|
-
}
|
|
634477
|
-
let curatedSummary = "";
|
|
634478
|
-
let unresolved = "";
|
|
634479
|
-
let satisfied = "";
|
|
634480
|
-
let provenance = "";
|
|
634481
|
-
if (curatedStart >= 0) {
|
|
634482
|
-
for (let i2 = curatedStart + 1; i2 < lines.length; i2 += 1) {
|
|
634483
|
-
const line = lines[i2];
|
|
634484
|
-
if (/^satisfied=/i.test(line) || /^unresolved=/i.test(line) || /^provenance=/i.test(line)) {
|
|
634485
|
-
if (line.startsWith("satisfied=")) {
|
|
634486
|
-
satisfied = line.replace(/^satisfied=/i, "");
|
|
634487
|
-
} else if (line.startsWith("unresolved=")) {
|
|
634488
|
-
unresolved = line.replace(/^unresolved=/i, "");
|
|
634489
|
-
} else if (line.startsWith("provenance=")) {
|
|
634490
|
-
provenance = line.replace(/^provenance=/i, "");
|
|
634491
|
-
}
|
|
634492
|
-
continue;
|
|
634493
|
-
}
|
|
634494
|
-
if (/^Contract:/i.test(line)) {
|
|
634495
|
-
continue;
|
|
634496
|
-
}
|
|
634497
|
-
if (curatedSummary.length < 240) {
|
|
634498
|
-
curatedSummary = curatedSummary ? `${curatedSummary} ${compactForDisplay(line, 120)}` : compactForDisplay(line, 120);
|
|
634499
|
-
}
|
|
634500
|
-
}
|
|
634501
|
-
}
|
|
634502
|
-
const isDuplicate = /^\[branch-duplicate-blocked\]/i.test(lines[0]);
|
|
634503
|
-
const header = isDuplicate ? "Branch-extract duplicate reuse" : "Branch-extract preempted";
|
|
634504
|
-
const whatHappened = isDuplicate ? "a cache-safe duplicate was detected" : "read was auto-summarized before injecting into context";
|
|
634505
|
-
const out = [
|
|
634506
|
-
`↳ ${header}`,
|
|
634507
|
-
` ├ what happened: ${whatHappened}`,
|
|
634508
|
-
` ├ why: ${compactForDisplay(reasons, 140)}`,
|
|
634509
|
-
` ├ path: ${compactForDisplay(path16, 140)}`,
|
|
634510
|
-
` ├ decision scope: ${route}`
|
|
634511
|
-
];
|
|
634512
|
-
if (projected) {
|
|
634513
|
-
const projectedText = fractionLimit ? `${projected} projected → ${fractionLimit} limit` : `${projected} projected`;
|
|
634514
|
-
const availText = available ? `; available headroom ${available}` : "";
|
|
634515
|
-
out.push(` ├ budget: ${projectedText}${availText}`);
|
|
634516
|
-
}
|
|
634517
|
-
if (goalAnchor) out.push(` ├ goal anchor: ${compactForDisplay(goalAnchor, 120)}`);
|
|
634518
|
-
if (request) out.push(` ├ request: ${compactForDisplay(request, 150)}`);
|
|
634519
|
-
if (required.length > 0) {
|
|
634520
|
-
out.push(` ├ required: ${compactForDisplay(required.slice(0, 3).join(", "), 180)}`);
|
|
634521
|
-
}
|
|
634522
|
-
if (stopCondition) {
|
|
634523
|
-
out.push(` ├ stop: ${compactForDisplay(stopCondition, 140)}`);
|
|
634524
|
-
}
|
|
634525
|
-
if (curatedSummary) {
|
|
634526
|
-
out.push(` ├ curated segment: ${compactForDisplay(curatedSummary, 180)}`);
|
|
634527
|
-
}
|
|
634528
|
-
if (satisfied || unresolved) {
|
|
634529
|
-
out.push(
|
|
634530
|
-
` ├ state: satisfied=${compactForDisplay(satisfied || "none", 90)}; unresolved=${compactForDisplay(unresolved || "none", 90)}`
|
|
634531
|
-
);
|
|
634532
|
-
}
|
|
634533
|
-
if (provenance) {
|
|
634534
|
-
out.push(` ├ provenance: ${compactForDisplay(provenance, 120)}`);
|
|
634535
|
-
}
|
|
634536
|
-
if (out.length > 1) {
|
|
634537
|
-
const last2 = out.length - 1;
|
|
634538
|
-
out[last2] = out[last2]?.replace(/^ ├ /, " └ ") ?? out[last2];
|
|
634539
|
-
}
|
|
634540
|
-
return out.length > 0 ? out : null;
|
|
634541
|
-
}
|
|
634542
|
-
function formatSupersededPlanSummary() {
|
|
634543
|
-
return [
|
|
634544
|
-
"↳ Mode-collapse guard",
|
|
634545
|
-
" ├ what happened: near-duplicate assistant plan was suppressed",
|
|
634546
|
-
" ├ why: loop prevention to stop re-entering the same plan text",
|
|
634547
|
-
" └ next action: tool call or concrete evidence request before restating the plan"
|
|
634548
|
-
];
|
|
634549
|
-
}
|
|
634550
|
-
function formatEchoGuardSummary(output) {
|
|
634551
|
-
const lower = output.toLowerCase();
|
|
634552
|
-
const match = output.match(/echo-1:\s*text-only echo\s*#?(\d+)/i);
|
|
634553
|
-
const echoCount = match?.[1] ? `#${match[1]}` : "";
|
|
634554
|
-
const similarityMatch = output.match(/(\d+)% similar/);
|
|
634555
|
-
const similarity3 = similarityMatch?.[1] ? ` (${similarityMatch[1]}% similar to earlier response)` : "";
|
|
634556
|
-
const collapsed = output.match(/collapsed\s+(\d+)\s+duplicate/);
|
|
634557
|
-
const duplicates = collapsed?.[1] ? `${collapsed[1]} duplicate(s) collapsed` : "";
|
|
634558
|
-
const out = [
|
|
634559
|
-
`↳ ECHO-1 mode-collapse guard${echoCount ? ` ${echoCount}` : ""}${similarity3}`,
|
|
634560
|
-
" ├ what happened: repeated text-only plan was intercepted",
|
|
634561
|
-
" ├ why: duplicate plan text was detected from the model loop",
|
|
634562
|
-
` ├ action: pattern-breaker${duplicates ? ` (${duplicates})` : ""}`,
|
|
634563
|
-
" └ next action: resume with tool-backed evidence"
|
|
634564
|
-
];
|
|
634565
|
-
return out;
|
|
634566
|
-
}
|
|
634567
|
-
function summarizeInternalControlOutput(output) {
|
|
634568
|
-
if (!output) return null;
|
|
634569
|
-
const firstLine = output.split(/\r?\n/)[0]?.trim().toLowerCase() ?? "";
|
|
634570
|
-
const lower = output.toLowerCase();
|
|
634571
|
-
if (firstLine.includes("[branch-extract") || firstLine.includes("[branch-duplicate-blocked]") || lower.includes("branch-extract preempted")) {
|
|
634572
|
-
return formatBranchExtractSummary(output);
|
|
634573
|
-
}
|
|
634574
|
-
if (firstLine.includes("[echo break") || firstLine.includes("[echo-break") || lower.includes("echo-1:")) {
|
|
634575
|
-
return formatEchoGuardSummary(output);
|
|
634576
|
-
}
|
|
634577
|
-
if (lower.includes("[superseded near-duplicate plan removed")) {
|
|
634578
|
-
return formatSupersededPlanSummary();
|
|
634579
|
-
}
|
|
634580
|
-
return null;
|
|
634581
|
-
}
|
|
634582
635418
|
function stripTrustTierWrapperForTui(text2, maxWrapperChars = 400) {
|
|
634583
635419
|
const trustWrapper = new RegExp(
|
|
634584
635420
|
`^\\[trust_tier:[^\\]\\n]{0,${Math.max(0, maxWrapperChars)}}\\][ \\t]*(?:\\n)?`,
|
|
@@ -635832,6 +636668,7 @@ var init_render = __esm({
|
|
|
635832
636668
|
init_model_picker();
|
|
635833
636669
|
init_secret_redactor();
|
|
635834
636670
|
init_tool_collapse_store();
|
|
636671
|
+
init_internal_output();
|
|
635835
636672
|
c3 = {
|
|
635836
636673
|
bold: (t2) => ansi2("1", t2),
|
|
635837
636674
|
dim: (t2) => stdoutIsTTY() ? `${dimFg()}${t2}\x1B[0m` : t2,
|
|
@@ -645111,11 +645948,11 @@ function truncate4(s2, max) {
|
|
|
645111
645948
|
if (s2.length <= max) return s2.padEnd(max, " ");
|
|
645112
645949
|
return s2.slice(0, Math.max(0, max - 1)) + "…";
|
|
645113
645950
|
}
|
|
645114
|
-
function
|
|
645951
|
+
function stripAnsi3(s2) {
|
|
645115
645952
|
return s2.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "").replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B[()][A-Z0-9]/g, "").replace(/\x1B\[?\??[0-9;]*[a-zA-Z]/g, "").replace(/\x1B/g, "");
|
|
645116
645953
|
}
|
|
645117
645954
|
function visualLen(s2) {
|
|
645118
|
-
return
|
|
645955
|
+
return stripAnsi3(s2).length;
|
|
645119
645956
|
}
|
|
645120
645957
|
function buildTodoProgressBar(todos, maxWidth) {
|
|
645121
645958
|
if (maxWidth <= 0 || todos.length === 0) return "";
|
|
@@ -647853,6 +648690,7 @@ var init_status_bar = __esm({
|
|
|
647853
648690
|
lastCompletionTokens: 0,
|
|
647854
648691
|
contextWindowSize: 0
|
|
647855
648692
|
};
|
|
648693
|
+
_contextCapacity = { status: "unknown" };
|
|
647856
648694
|
// ── Metrics tracking for Telegram stats ──
|
|
647857
648695
|
_backend = "ollama";
|
|
647858
648696
|
_inferenceCount = 0;
|
|
@@ -649097,7 +649935,17 @@ var init_status_bar = __esm({
|
|
|
649097
649935
|
}
|
|
649098
649936
|
/** Context window size to display. Can be updated if model changes. */
|
|
649099
649937
|
setContextWindowSize(size) {
|
|
649100
|
-
this.
|
|
649938
|
+
this.setContextCapacity(
|
|
649939
|
+
Number.isFinite(size) && size > 0 ? { status: "known", totalTokens: Math.floor(size), source: "runtime" } : { status: "unknown", source: "unavailable" }
|
|
649940
|
+
);
|
|
649941
|
+
}
|
|
649942
|
+
/** Update capacity provenance without turning missing server metadata into zero percent. */
|
|
649943
|
+
setContextCapacity(state) {
|
|
649944
|
+
const totalTokens = state.status === "known" && (state.totalTokens ?? 0) > 0 ? Math.floor(state.totalTokens) : 0;
|
|
649945
|
+
this._contextCapacity = totalTokens > 0 ? { ...state, status: "known", totalTokens } : { ...state, status: "unknown", totalTokens: void 0 };
|
|
649946
|
+
this.metrics.contextWindowSize = totalTokens;
|
|
649947
|
+
this.pushSpinnerContextMetrics();
|
|
649948
|
+
if (this.active) this.renderFooterPreserveCursor();
|
|
649101
649949
|
}
|
|
649102
649950
|
/** Set the current package version for display in the metrics row */
|
|
649103
649951
|
setVersion(version5) {
|
|
@@ -649578,6 +650426,8 @@ var init_status_bar = __esm({
|
|
|
649578
650426
|
this.metrics.totalTokens = update2.totalTokens;
|
|
649579
650427
|
if (update2.estimatedContextTokens !== void 0)
|
|
649580
650428
|
this.metrics.estimatedContextTokens = update2.estimatedContextTokens;
|
|
650429
|
+
if (update2.contextOutputReservationTokens !== void 0)
|
|
650430
|
+
this.metrics.contextOutputReservationTokens = update2.contextOutputReservationTokens;
|
|
649581
650431
|
if (update2.lastPromptTokens !== void 0)
|
|
649582
650432
|
this.metrics.lastPromptTokens = update2.lastPromptTokens;
|
|
649583
650433
|
if (update2.lastCompletionTokens !== void 0)
|
|
@@ -651717,7 +652567,7 @@ ${CONTENT_BG_SEQ}`);
|
|
|
651717
652567
|
this.effectiveContextTotal(m2.contextWindowSize)
|
|
651718
652568
|
);
|
|
651719
652569
|
let ctxStr = "";
|
|
651720
|
-
if (ctxTotal > 0) {
|
|
652570
|
+
if (this._contextCapacity.status === "known" && ctxTotal > 0) {
|
|
651721
652571
|
const pct2 = Math.max(
|
|
651722
652572
|
0,
|
|
651723
652573
|
Math.min(100, Math.round((1 - ctxUsed / ctxTotal) * 100))
|
|
@@ -651729,6 +652579,10 @@ ${CONTENT_BG_SEQ}`);
|
|
|
651729
652579
|
const bar = `\x1B[38;5;${barColor}m${"█".repeat(filled)}\x1B[0m\x1B[38;5;240m${"░".repeat(empty2)}\x1B[0m`;
|
|
651730
652580
|
const pctColor = pct2 > 50 ? 120 : pct2 > 20 ? 222 : 210;
|
|
651731
652581
|
ctxStr = `${bar} \x1B[38;5;${pctColor}m${pct2}%\x1B[0m`;
|
|
652582
|
+
} else {
|
|
652583
|
+
const usage = ctxUsed >= 1024 ? `${(ctxUsed / 1024).toFixed(ctxUsed >= 1e4 ? 0 : 1)}K` : String(Math.max(0, Math.round(ctxUsed)));
|
|
652584
|
+
const reservation = m2.contextOutputReservationTokens && m2.contextOutputReservationTokens > 0 ? ` +${m2.contextOutputReservationTokens >= 1024 ? `${Math.round(m2.contextOutputReservationTokens / 1024)}K` : m2.contextOutputReservationTokens} rsv` : "";
|
|
652585
|
+
ctxStr = `\x1B[38;5;245mCTX ? | ~${usage}${reservation}\x1B[0m`;
|
|
651732
652586
|
}
|
|
651733
652587
|
const arrow = `\x1B[38;5;240m▶\x1B[0m`;
|
|
651734
652588
|
let rightSide;
|
|
@@ -653031,7 +653885,7 @@ function ansi3(code8, text2) {
|
|
|
653031
653885
|
function fg2563(code8, text2) {
|
|
653032
653886
|
return isTTY3 ? `\x1B[38;5;${code8}m${text2}\x1B[0m` : text2;
|
|
653033
653887
|
}
|
|
653034
|
-
function
|
|
653888
|
+
function stripAnsi4(s2) {
|
|
653035
653889
|
return s2.replace(/\x1B\[[0-9;]*m/g, "");
|
|
653036
653890
|
}
|
|
653037
653891
|
function stripTerminalControl(s2) {
|
|
@@ -653047,15 +653901,15 @@ function renderNonInteractiveSelect(opts, currentTitle, skipSet) {
|
|
|
653047
653901
|
const surface = nonInteractiveSelectSurface.getStore();
|
|
653048
653902
|
const maxItems = Math.max(1, surface?.maxItems ?? 30);
|
|
653049
653903
|
const lines = [];
|
|
653050
|
-
if (currentTitle) lines.push(stripTerminalControl(
|
|
653904
|
+
if (currentTitle) lines.push(stripTerminalControl(stripAnsi4(currentTitle)));
|
|
653051
653905
|
if (lines.length) lines.push("");
|
|
653052
653906
|
let idx = 1;
|
|
653053
653907
|
let shown = 0;
|
|
653054
653908
|
let omitted = 0;
|
|
653055
653909
|
for (const item of opts.items) {
|
|
653056
653910
|
const isSkip = skipSet.has(item.key);
|
|
653057
|
-
const labelPlain = stripTerminalControl(
|
|
653058
|
-
const detailPlain = item.detail ? stripTerminalControl(
|
|
653911
|
+
const labelPlain = stripTerminalControl(stripAnsi4(item.label)).trim();
|
|
653912
|
+
const detailPlain = item.detail ? stripTerminalControl(stripAnsi4(item.detail)).trim() : "";
|
|
653059
653913
|
if (isSkip) {
|
|
653060
653914
|
if (labelPlain) lines.push(labelPlain);
|
|
653061
653915
|
continue;
|
|
@@ -653072,7 +653926,7 @@ function renderNonInteractiveSelect(opts, currentTitle, skipSet) {
|
|
|
653072
653926
|
idx++;
|
|
653073
653927
|
}
|
|
653074
653928
|
if (omitted > 0) lines.push(` ... ${omitted} more`);
|
|
653075
|
-
if (opts.customKeyHint) lines.push("", stripTerminalControl(
|
|
653929
|
+
if (opts.customKeyHint) lines.push("", stripTerminalControl(stripAnsi4(opts.customKeyHint)));
|
|
653076
653930
|
lines.push("", surface?.hint ?? "(non-interactive: menu shown as text; open the TUI for selection)");
|
|
653077
653931
|
process.stdout.write(lines.join("\n").trimEnd() + "\n");
|
|
653078
653932
|
}
|
|
@@ -653087,8 +653941,8 @@ function matchRow(item, focused, isActive) {
|
|
|
653087
653941
|
return defaultRenderRow(item, focused, isActive);
|
|
653088
653942
|
}
|
|
653089
653943
|
const marker = selectColors.matchLight("○");
|
|
653090
|
-
const label = selectColors.matchLight(
|
|
653091
|
-
const detail = item.detail ? ` ${selectColors.dim(
|
|
653944
|
+
const label = selectColors.matchLight(stripAnsi4(item.label));
|
|
653945
|
+
const detail = item.detail ? ` ${selectColors.dim(stripAnsi4(item.detail))}` : "";
|
|
653092
653946
|
return ` ${marker} ${label}${detail}`;
|
|
653093
653947
|
}
|
|
653094
653948
|
function tuiSelect(opts) {
|
|
@@ -653117,8 +653971,8 @@ function tuiSelect(opts) {
|
|
|
653117
653971
|
matchSet = /* @__PURE__ */ new Set();
|
|
653118
653972
|
for (let i2 = 0; i2 < items.length; i2++) {
|
|
653119
653973
|
if (isSkippable(i2)) continue;
|
|
653120
|
-
const plain =
|
|
653121
|
-
const detailPlain = items[i2].detail ?
|
|
653974
|
+
const plain = stripAnsi4(items[i2].label).toLowerCase();
|
|
653975
|
+
const detailPlain = items[i2].detail ? stripAnsi4(items[i2].detail).toLowerCase() : "";
|
|
653122
653976
|
if (plain.includes(lower) || detailPlain.includes(lower)) {
|
|
653123
653977
|
matchSet.add(i2);
|
|
653124
653978
|
}
|
|
@@ -653243,7 +654097,7 @@ function tuiSelect(opts) {
|
|
|
653243
654097
|
if (deleteConfirmIdx === idx) {
|
|
653244
654098
|
const yesLabel = deleteConfirmSel ? selectColors.bold(selectColors.green("[Yes]")) : selectColors.dim("[Yes]");
|
|
653245
654099
|
const noLabel = !deleteConfirmSel ? selectColors.bold(selectColors.blue("[No]")) : selectColors.dim("[No]");
|
|
653246
|
-
lines.push(` ${ansi3("31", "✕")} ${ansi3("31",
|
|
654100
|
+
lines.push(` ${ansi3("31", "✕")} ${ansi3("31", stripAnsi4(item.label))} Delete? ${yesLabel} ${noLabel}`);
|
|
653247
654101
|
} else if (filter2) {
|
|
653248
654102
|
lines.push(matchRow(item, focused, isActive));
|
|
653249
654103
|
} else {
|
|
@@ -659229,11 +660083,11 @@ import { extname as extname18, resolve as resolve66 } from "node:path";
|
|
|
659229
660083
|
function ansi4(code8, text2) {
|
|
659230
660084
|
return isTTY4 ? `\x1B[${code8}m${text2}\x1B[0m` : text2;
|
|
659231
660085
|
}
|
|
659232
|
-
function
|
|
660086
|
+
function stripAnsi5(s2) {
|
|
659233
660087
|
return s2.replace(/\x1B\[[0-9;]*m/g, "");
|
|
659234
660088
|
}
|
|
659235
660089
|
function fitToWidth(text2, width) {
|
|
659236
|
-
const visible =
|
|
660090
|
+
const visible = stripAnsi5(text2);
|
|
659237
660091
|
if (visible.length >= width) {
|
|
659238
660092
|
let visCount = 0;
|
|
659239
660093
|
let i2 = 0;
|
|
@@ -670459,12 +671313,12 @@ async function ensureVoiceDeps(ctx3) {
|
|
|
670459
671313
|
}
|
|
670460
671314
|
}
|
|
670461
671315
|
if (typeof mod3.getVenvPython === "function") {
|
|
670462
|
-
const { dirname:
|
|
671316
|
+
const { dirname: dirname59 } = await import("node:path");
|
|
670463
671317
|
const { existsSync: existsSync177 } = await import("node:fs");
|
|
670464
671318
|
const venvPy = mod3.getVenvPython();
|
|
670465
671319
|
if (existsSync177(venvPy)) {
|
|
670466
671320
|
process.env.TRANSCRIBE_PYTHON = venvPy;
|
|
670467
|
-
const venvBin =
|
|
671321
|
+
const venvBin = dirname59(venvPy);
|
|
670468
671322
|
const sep8 = process.platform === "win32" ? ";" : ":";
|
|
670469
671323
|
const cur = process.env.PATH || "";
|
|
670470
671324
|
if (!cur.split(sep8).includes(venvBin)) {
|
|
@@ -673925,10 +674779,6 @@ Clone a new voice: /voice clone <wav-file> [name]`);
|
|
|
673925
674779
|
renderWarning(
|
|
673926
674780
|
"OMNIUS_FORCE_NO_THINK=1 forces off regardless of /think setting"
|
|
673927
674781
|
);
|
|
673928
|
-
else if (cur && process.env["OMNIUS_ENABLE_THINKING"] !== "1")
|
|
673929
|
-
renderWarning(
|
|
673930
|
-
"OMNIUS_ENABLE_THINKING is not set; /think is saved but backend requests remain direct-answer mode."
|
|
673931
|
-
);
|
|
673932
674782
|
return "handled";
|
|
673933
674783
|
}
|
|
673934
674784
|
if (token === "auto") {
|
|
@@ -673967,11 +674817,6 @@ Clone a new voice: /voice clone <wav-file> [name]`);
|
|
|
673967
674817
|
renderInfo(
|
|
673968
674818
|
"Note: max_tokens will auto-raise to ≥4096 per request to prevent <think> truncation."
|
|
673969
674819
|
);
|
|
673970
|
-
if (process.env["OMNIUS_ENABLE_THINKING"] !== "1") {
|
|
673971
|
-
renderWarning(
|
|
673972
|
-
"Thinking is hard-disabled by default. Set OMNIUS_ENABLE_THINKING=1 before launch for /think on or /think auto to affect backend requests."
|
|
673973
|
-
);
|
|
673974
|
-
}
|
|
673975
674820
|
}
|
|
673976
674821
|
return "handled";
|
|
673977
674822
|
}
|
|
@@ -683873,14 +684718,14 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
683873
684718
|
if (models.length > 0) {
|
|
683874
684719
|
try {
|
|
683875
684720
|
const { writeFileSync: writeFileSync97, mkdirSync: mkdirSync114 } = await import("node:fs");
|
|
683876
|
-
const { join: join190, dirname:
|
|
684721
|
+
const { join: join190, dirname: dirname59 } = await import("node:path");
|
|
683877
684722
|
const cachePath2 = join190(
|
|
683878
684723
|
ctx3.repoRoot || process.cwd(),
|
|
683879
684724
|
".omnius",
|
|
683880
684725
|
"nexus",
|
|
683881
684726
|
"peer-models-cache.json"
|
|
683882
684727
|
);
|
|
683883
|
-
mkdirSync114(
|
|
684728
|
+
mkdirSync114(dirname59(cachePath2), { recursive: true });
|
|
683884
684729
|
writeFileSync97(
|
|
683885
684730
|
cachePath2,
|
|
683886
684731
|
JSON.stringify(
|
|
@@ -683956,14 +684801,14 @@ async function handlePeerEndpoint(peerId, authKey, ctx3, local, advertisedModels
|
|
|
683956
684801
|
);
|
|
683957
684802
|
try {
|
|
683958
684803
|
const { writeFileSync: writeFileSync97, mkdirSync: mkdirSync114 } = await import("node:fs");
|
|
683959
|
-
const { join: join190, dirname:
|
|
684804
|
+
const { join: join190, dirname: dirname59 } = await import("node:path");
|
|
683960
684805
|
const cachePath2 = join190(
|
|
683961
684806
|
ctx3.repoRoot || process.cwd(),
|
|
683962
684807
|
".omnius",
|
|
683963
684808
|
"nexus",
|
|
683964
684809
|
"peer-models-cache.json"
|
|
683965
684810
|
);
|
|
683966
|
-
mkdirSync114(
|
|
684811
|
+
mkdirSync114(dirname59(cachePath2), { recursive: true });
|
|
683967
684812
|
writeFileSync97(
|
|
683968
684813
|
cachePath2,
|
|
683969
684814
|
JSON.stringify(
|
|
@@ -684979,10 +685824,10 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
684979
685824
|
try {
|
|
684980
685825
|
const { createRequire: createRequire11 } = await import("node:module");
|
|
684981
685826
|
const { fileURLToPath: fileURLToPath26 } = await import("node:url");
|
|
684982
|
-
const { dirname:
|
|
685827
|
+
const { dirname: dirname59, join: join190 } = await import("node:path");
|
|
684983
685828
|
const { existsSync: existsSync177 } = await import("node:fs");
|
|
684984
685829
|
const req3 = createRequire11(import.meta.url);
|
|
684985
|
-
const thisDir =
|
|
685830
|
+
const thisDir = dirname59(fileURLToPath26(import.meta.url));
|
|
684986
685831
|
const candidates = [
|
|
684987
685832
|
join190(thisDir, "..", "package.json"),
|
|
684988
685833
|
join190(thisDir, "..", "..", "package.json"),
|
|
@@ -687168,11 +688013,11 @@ function normalizeRoot(root) {
|
|
|
687168
688013
|
return root;
|
|
687169
688014
|
}
|
|
687170
688015
|
}
|
|
687171
|
-
function
|
|
688016
|
+
function stripAnsi6(text2) {
|
|
687172
688017
|
return String(text2 || "").replace(/\u001b\[[0-9;]*[a-zA-Z]/g, "");
|
|
687173
688018
|
}
|
|
687174
688019
|
function cleanSessionDisplayLine(line) {
|
|
687175
|
-
return
|
|
688020
|
+
return stripAnsi6(line).replace(/^[>❯▹∙•*+\-\s]+/, "").replace(/^(?:User|Assistant|You|Open Agent|Omnius)\s*:\s*/i, "").replace(/\s+/g, " ").trim();
|
|
687176
688021
|
}
|
|
687177
688022
|
function isNoisySessionDisplayLine(line) {
|
|
687178
688023
|
const clean5 = cleanSessionDisplayLine(line || "");
|
|
@@ -687180,12 +688025,12 @@ function isNoisySessionDisplayLine(line) {
|
|
|
687180
688025
|
return /^(?:Previous session found|REST API:|Nexus P2P network connected|No context to restore|Starting fresh|Use \/endpoint|Knowledge graph:|Zettelkasten:|Episodes captured:|Current OMNIUS_HOST:|Loaded TUI session|General session$|Chat tui:sess|\[Imported TUI session transcript\]|Title:|Description:|Project root:|i\s+)/i.test(clean5);
|
|
687181
688026
|
}
|
|
687182
688027
|
function bestSessionDisplayLine(text2) {
|
|
687183
|
-
const lines =
|
|
688028
|
+
const lines = stripAnsi6(text2).split(/\r?\n/);
|
|
687184
688029
|
for (const line of lines) {
|
|
687185
688030
|
const clean5 = cleanSessionDisplayLine(line);
|
|
687186
688031
|
if (!isNoisySessionDisplayLine(clean5)) return clean5;
|
|
687187
688032
|
}
|
|
687188
|
-
const fallback =
|
|
688033
|
+
const fallback = stripAnsi6(text2).replace(/\s+/g, " ").trim();
|
|
687189
688034
|
return isNoisySessionDisplayLine(fallback) ? "" : fallback;
|
|
687190
688035
|
}
|
|
687191
688036
|
function makeTitle(text2) {
|
|
@@ -687386,7 +688231,7 @@ function getSession2(sessionId, model, cwd4) {
|
|
|
687386
688231
|
function importTranscriptSession(opts) {
|
|
687387
688232
|
const projectRoot = normalizeRoot(opts.projectRoot) ?? process.cwd();
|
|
687388
688233
|
const id2 = opts.id;
|
|
687389
|
-
const transcript = opts.transcriptLines.map(
|
|
688234
|
+
const transcript = opts.transcriptLines.map(stripAnsi6).join("\n").trim();
|
|
687390
688235
|
const metadataSource = [opts.title, opts.description, transcript].filter(Boolean).join("\n");
|
|
687391
688236
|
const title = makeTitle(metadataSource || id2);
|
|
687392
688237
|
const preview = makePreview([opts.description, transcript].filter(Boolean).join("\n") || title);
|
|
@@ -700641,6 +701486,7 @@ import {
|
|
|
700641
701486
|
} from "node:fs";
|
|
700642
701487
|
import {
|
|
700643
701488
|
join as join170,
|
|
701489
|
+
dirname as dirname53,
|
|
700644
701490
|
resolve as resolve73,
|
|
700645
701491
|
basename as basename42,
|
|
700646
701492
|
relative as relative21,
|
|
@@ -700648,7 +701494,11 @@ import {
|
|
|
700648
701494
|
extname as extname21
|
|
700649
701495
|
} from "node:path";
|
|
700650
701496
|
import { homedir as homedir56 } from "node:os";
|
|
700651
|
-
import {
|
|
701497
|
+
import {
|
|
701498
|
+
appendFile as appendFileAsync,
|
|
701499
|
+
mkdir as mkdirAsync,
|
|
701500
|
+
writeFile as writeFileAsync
|
|
701501
|
+
} from "node:fs/promises";
|
|
700652
701502
|
import { createHash as createHash49, randomBytes as randomBytes28, randomInt } from "node:crypto";
|
|
700653
701503
|
function formatModelBytes(bytes) {
|
|
700654
701504
|
if (!Number.isFinite(bytes) || bytes <= 0) return "0 B";
|
|
@@ -703681,6 +704531,12 @@ Telegram link integrity contract:
|
|
|
703681
704531
|
subAgents = /* @__PURE__ */ new Map();
|
|
703682
704532
|
/** Debounced live-context packets for messages arriving during a runner. */
|
|
703683
704533
|
telegramSubAgentContextBuffers = /* @__PURE__ */ new Map();
|
|
704534
|
+
/** Append-only, durable ingress ledger for every agent-routed Telegram task input. */
|
|
704535
|
+
telegramIntakeRecords = /* @__PURE__ */ new Map();
|
|
704536
|
+
telegramIntakeMessages = /* @__PURE__ */ new Map();
|
|
704537
|
+
telegramIntakeWriteTail = Promise.resolve();
|
|
704538
|
+
/** Intent epochs isolate redirected/replaced work inside a long-lived chat session. */
|
|
704539
|
+
telegramTaskEpochs = /* @__PURE__ */ new Map();
|
|
703684
704540
|
/** Active direct chat completions, counted with Telegram activity in the TUI */
|
|
703685
704541
|
activeChatViews = /* @__PURE__ */ new Set();
|
|
703686
704542
|
/** Active direct chat completions by Telegram session key for admission. */
|
|
@@ -704582,7 +705438,7 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
704582
705438
|
}
|
|
704583
705439
|
this.refreshActiveTelegramInteractionCount();
|
|
704584
705440
|
}
|
|
704585
|
-
buildTelegramQueuedSessionWork(sessionKey, msg, toolContext, now2) {
|
|
705441
|
+
buildTelegramQueuedSessionWork(sessionKey, msg, toolContext, now2, intakeRecord) {
|
|
704586
705442
|
const existing = this.telegramQueuedSessionWork.get(sessionKey);
|
|
704587
705443
|
const messages2 = [...existing?.messages ?? [], msg].slice(
|
|
704588
705444
|
-TELEGRAM_SUB_AGENT_BURST_CONTEXT_LIMIT
|
|
@@ -704591,6 +705447,7 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
704591
705447
|
sessionKey,
|
|
704592
705448
|
msg,
|
|
704593
705449
|
messages: messages2,
|
|
705450
|
+
intakeRecords: [...existing?.intakeRecords ?? [], intakeRecord],
|
|
704594
705451
|
toolContext,
|
|
704595
705452
|
enqueuedAtMs: existing?.enqueuedAtMs ?? now2,
|
|
704596
705453
|
lastSpokenAtMs: now2,
|
|
@@ -704616,14 +705473,15 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
704616
705473
|
shouldAwaitTelegramQueuedWorkForTests() {
|
|
704617
705474
|
return process.env["OMNIUS_TG_AWAIT_QUEUED_WORK"] === "1" || process.env["VITEST"] === "true";
|
|
704618
705475
|
}
|
|
704619
|
-
scheduleTelegramSessionWork(msg, toolContext) {
|
|
705476
|
+
scheduleTelegramSessionWork(msg, toolContext, intakeRecord) {
|
|
704620
705477
|
const sessionKey = this.sessionKeyForMessage(msg);
|
|
704621
705478
|
const now2 = Date.now();
|
|
704622
705479
|
const existing = this.subAgents.get(sessionKey);
|
|
704623
705480
|
if (existing && !existing.aborted) {
|
|
704624
705481
|
return this.enqueueTelegramMessageForExistingSubAgent(
|
|
704625
705482
|
msg,
|
|
704626
|
-
existing
|
|
705483
|
+
existing,
|
|
705484
|
+
intakeRecord
|
|
704627
705485
|
).catch((err) => {
|
|
704628
705486
|
this.tuiWrite(
|
|
704629
705487
|
() => renderWarning(
|
|
@@ -704637,9 +705495,15 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
704637
705495
|
sessionKey,
|
|
704638
705496
|
msg,
|
|
704639
705497
|
toolContext,
|
|
704640
|
-
now2
|
|
705498
|
+
now2,
|
|
705499
|
+
intakeRecord
|
|
704641
705500
|
);
|
|
704642
705501
|
this.telegramQueuedSessionWork.set(sessionKey, queued);
|
|
705502
|
+
void this.transitionTelegramIntake(
|
|
705503
|
+
intakeRecord,
|
|
705504
|
+
"deferred",
|
|
705505
|
+
"queued behind Telegram session admission"
|
|
705506
|
+
);
|
|
704643
705507
|
this.refreshActiveTelegramInteractionCount();
|
|
704644
705508
|
this.dispatchQueuedTelegramSessionWorkSoon(
|
|
704645
705509
|
Math.max(0, queued.dispatchAfterMs - now2)
|
|
@@ -704850,14 +705714,14 @@ ${message2}`)
|
|
|
704850
705714
|
`live context injected (${buffer2.messages.length} message${buffer2.messages.length === 1 ? "" : "s"})`
|
|
704851
705715
|
);
|
|
704852
705716
|
} else {
|
|
704853
|
-
subAgent.
|
|
705717
|
+
subAgent.pendingContextPackets.push(packet);
|
|
704854
705718
|
this.subAgentViewCallbacks?.onWrite(
|
|
704855
705719
|
subAgent.viewId,
|
|
704856
705720
|
`live context staged (${buffer2.messages.length} message${buffer2.messages.length === 1 ? "" : "s"})`
|
|
704857
705721
|
);
|
|
704858
705722
|
}
|
|
704859
705723
|
}
|
|
704860
|
-
async enqueueTelegramMessageForExistingSubAgent(msg, subAgent) {
|
|
705724
|
+
async enqueueTelegramMessageForExistingSubAgent(msg, subAgent, intakeRecord) {
|
|
704861
705725
|
const sessionKey = this.sessionKeyForMessage(msg);
|
|
704862
705726
|
let mediaContext = "";
|
|
704863
705727
|
if (msg.media || msg.replyToMedia) {
|
|
@@ -704876,11 +705740,16 @@ ${message2}`)
|
|
|
704876
705740
|
} else {
|
|
704877
705741
|
this.recordTelegramUserMessage(msg, "steering");
|
|
704878
705742
|
}
|
|
704879
|
-
this.
|
|
704880
|
-
sessionKey,
|
|
705743
|
+
this.injectTelegramSteeringInput(
|
|
704881
705744
|
subAgent,
|
|
704882
|
-
|
|
704883
|
-
|
|
705745
|
+
intakeRecord,
|
|
705746
|
+
context2
|
|
705747
|
+
);
|
|
705748
|
+
void this.transitionTelegramIntake(
|
|
705749
|
+
intakeRecord,
|
|
705750
|
+
"accepted",
|
|
705751
|
+
"accepted by active Telegram runner",
|
|
705752
|
+
{ runId: subAgent.runId }
|
|
704884
705753
|
);
|
|
704885
705754
|
this.tuiWrite(
|
|
704886
705755
|
() => renderTelegramSubAgentEvent(
|
|
@@ -704892,8 +705761,259 @@ ${message2}`)
|
|
|
704892
705761
|
async enqueueTelegramQueuedSessionWorkForExistingSubAgent(work, subAgent) {
|
|
704893
705762
|
const messages2 = work.messages.length > 0 ? work.messages : [work.msg];
|
|
704894
705763
|
for (const msg of messages2) {
|
|
704895
|
-
|
|
705764
|
+
const intakeRecord = work.intakeRecords.find(
|
|
705765
|
+
(record) => record.inputId === this.telegramInputIdForMessage(msg)
|
|
705766
|
+
);
|
|
705767
|
+
if (!intakeRecord) continue;
|
|
705768
|
+
await this.enqueueTelegramMessageForExistingSubAgent(
|
|
705769
|
+
msg,
|
|
705770
|
+
subAgent,
|
|
705771
|
+
intakeRecord
|
|
705772
|
+
);
|
|
705773
|
+
}
|
|
705774
|
+
}
|
|
705775
|
+
telegramInputIdForMessage(msg) {
|
|
705776
|
+
const thread = msg.messageThreadId ?? 0;
|
|
705777
|
+
return `telegram:${this.sessionKeyForMessage(msg)}:${thread}:${msg.messageId ?? "unknown"}`;
|
|
705778
|
+
}
|
|
705779
|
+
telegramTaskEpoch(sessionKey) {
|
|
705780
|
+
const current = this.telegramTaskEpochs.get(sessionKey);
|
|
705781
|
+
if (current !== void 0) return current;
|
|
705782
|
+
this.telegramTaskEpochs.set(sessionKey, 1);
|
|
705783
|
+
return 1;
|
|
705784
|
+
}
|
|
705785
|
+
advanceTelegramTaskEpoch(sessionKey) {
|
|
705786
|
+
const next = this.telegramTaskEpoch(sessionKey) + 1;
|
|
705787
|
+
this.telegramTaskEpochs.set(sessionKey, next);
|
|
705788
|
+
return next;
|
|
705789
|
+
}
|
|
705790
|
+
triageTelegramSteeringInput(msg) {
|
|
705791
|
+
const text2 = msg.text.trim();
|
|
705792
|
+
const lower = text2.toLowerCase();
|
|
705793
|
+
if (/^\/(?:stop|cancel|abort|halt)\b/.test(lower)) {
|
|
705794
|
+
return { intent: "cancel", reason: "explicit stop/cancel command" };
|
|
705795
|
+
}
|
|
705796
|
+
if (/^\/(?:redirect|reroute|pivot)\b/.test(lower)) {
|
|
705797
|
+
return { intent: "redirect", reason: "explicit redirect command" };
|
|
705798
|
+
}
|
|
705799
|
+
if (/^\/(?:replace|new[_-]?task)\b/.test(lower) || /^(?:new task|replace (?:the )?(?:current )?task|forget (?:that|the current task)|instead[,!:]?)/.test(
|
|
705800
|
+
lower
|
|
705801
|
+
)) {
|
|
705802
|
+
return { intent: "replace", reason: "explicit replacement/new-task request" };
|
|
704896
705803
|
}
|
|
705804
|
+
if (/^\/(?:append|add|also)\b/.test(lower) || /^(?:also|add|include|one more thing)\b/.test(lower)) {
|
|
705805
|
+
return { intent: "append", reason: "explicit additive instruction" };
|
|
705806
|
+
}
|
|
705807
|
+
if (/\?$/.test(text2) || /^(?:clarify|correction|to be clear)\b/.test(lower)) {
|
|
705808
|
+
return { intent: "clarify", reason: "plain-text clarification; scope preserved" };
|
|
705809
|
+
}
|
|
705810
|
+
return { intent: "append", reason: "conservative plain-text intake; momentum preserved" };
|
|
705811
|
+
}
|
|
705812
|
+
telegramIntakePath(sessionKey) {
|
|
705813
|
+
const digest3 = createHash49("sha256").update(sessionKey).digest("hex").slice(0, 20);
|
|
705814
|
+
return join170(
|
|
705815
|
+
this.repoRoot ?? process.cwd(),
|
|
705816
|
+
".omnius",
|
|
705817
|
+
"telegram-intake",
|
|
705818
|
+
`${digest3}.jsonl`
|
|
705819
|
+
);
|
|
705820
|
+
}
|
|
705821
|
+
appendTelegramIntakeJournal(sessionKey, entry) {
|
|
705822
|
+
const write2 = async () => {
|
|
705823
|
+
const path16 = this.telegramIntakePath(sessionKey);
|
|
705824
|
+
await mkdirAsync(dirname53(path16), { recursive: true });
|
|
705825
|
+
await appendFileAsync(path16, `${JSON.stringify(entry)}
|
|
705826
|
+
`, "utf8");
|
|
705827
|
+
};
|
|
705828
|
+
this.telegramIntakeWriteTail = this.telegramIntakeWriteTail.catch(() => {
|
|
705829
|
+
}).then(write2);
|
|
705830
|
+
return this.telegramIntakeWriteTail;
|
|
705831
|
+
}
|
|
705832
|
+
async registerTelegramIntake(msg, triage) {
|
|
705833
|
+
const sessionKey = this.sessionKeyForMessage(msg);
|
|
705834
|
+
const inputId = this.telegramInputIdForMessage(msg);
|
|
705835
|
+
const existing = this.telegramIntakeRecords.get(inputId);
|
|
705836
|
+
if (existing) return existing;
|
|
705837
|
+
const now2 = (/* @__PURE__ */ new Date()).toISOString();
|
|
705838
|
+
const record = {
|
|
705839
|
+
inputId,
|
|
705840
|
+
source: "telegram",
|
|
705841
|
+
receivedAt: now2,
|
|
705842
|
+
lifecycle: "received",
|
|
705843
|
+
lifecycleAt: now2,
|
|
705844
|
+
lifecycleReason: "Telegram update accepted before task routing",
|
|
705845
|
+
intent: triage.intent,
|
|
705846
|
+
classificationReason: triage.reason,
|
|
705847
|
+
sessionKey,
|
|
705848
|
+
chatId: String(msg.chatId),
|
|
705849
|
+
messageId: msg.messageId,
|
|
705850
|
+
messageThreadId: msg.messageThreadId,
|
|
705851
|
+
rawText: msg.text,
|
|
705852
|
+
taskEpoch: this.telegramTaskEpoch(sessionKey)
|
|
705853
|
+
};
|
|
705854
|
+
this.telegramIntakeRecords.set(inputId, record);
|
|
705855
|
+
this.telegramIntakeMessages.set(inputId, msg);
|
|
705856
|
+
await this.appendTelegramIntakeJournal(sessionKey, {
|
|
705857
|
+
kind: "intake_received",
|
|
705858
|
+
record
|
|
705859
|
+
});
|
|
705860
|
+
await this.transitionTelegramIntake(record, "classified", triage.reason);
|
|
705861
|
+
return record;
|
|
705862
|
+
}
|
|
705863
|
+
async transitionTelegramIntake(record, lifecycle, reason, links2 = {}) {
|
|
705864
|
+
const at = (/* @__PURE__ */ new Date()).toISOString();
|
|
705865
|
+
Object.assign(record, links2, {
|
|
705866
|
+
lifecycle,
|
|
705867
|
+
lifecycleAt: at,
|
|
705868
|
+
lifecycleReason: reason
|
|
705869
|
+
});
|
|
705870
|
+
await this.appendTelegramIntakeJournal(record.sessionKey, {
|
|
705871
|
+
kind: "intake_lifecycle",
|
|
705872
|
+
inputId: record.inputId,
|
|
705873
|
+
lifecycle,
|
|
705874
|
+
at,
|
|
705875
|
+
reason,
|
|
705876
|
+
taskEpoch: record.taskEpoch,
|
|
705877
|
+
runId: record.runId,
|
|
705878
|
+
runnerTurn: record.runnerTurn
|
|
705879
|
+
});
|
|
705880
|
+
}
|
|
705881
|
+
formatTelegramSteeringCompatibilityMessage(input) {
|
|
705882
|
+
return [
|
|
705883
|
+
"[TELEGRAM_STEERING_INTAKE]",
|
|
705884
|
+
`input_id: ${input.intake.inputId}`,
|
|
705885
|
+
`intent: ${input.intake.intent}`,
|
|
705886
|
+
`task_epoch: ${input.intake.taskEpoch}`,
|
|
705887
|
+
"This is a direct user intake. Reconcile it before the next action; do not treat it as passive transcript context.",
|
|
705888
|
+
input.content,
|
|
705889
|
+
"[/TELEGRAM_STEERING_INTAKE]"
|
|
705890
|
+
].join("\n");
|
|
705891
|
+
}
|
|
705892
|
+
injectTelegramSteeringInput(subAgent, intake, content) {
|
|
705893
|
+
const pending2 = { intake, content };
|
|
705894
|
+
if (!subAgent.runner) {
|
|
705895
|
+
subAgent.pendingIntakeRecords.push(pending2);
|
|
705896
|
+
return;
|
|
705897
|
+
}
|
|
705898
|
+
const runner = subAgent.runner;
|
|
705899
|
+
if (typeof runner.injectSteeringInput === "function") {
|
|
705900
|
+
runner.injectSteeringInput({
|
|
705901
|
+
inputId: intake.inputId,
|
|
705902
|
+
content,
|
|
705903
|
+
source: "telegram",
|
|
705904
|
+
receivedAt: intake.receivedAt,
|
|
705905
|
+
intent: intake.intent,
|
|
705906
|
+
taskEpoch: intake.taskEpoch
|
|
705907
|
+
});
|
|
705908
|
+
return;
|
|
705909
|
+
}
|
|
705910
|
+
runner.injectUserMessage(this.formatTelegramSteeringCompatibilityMessage(pending2));
|
|
705911
|
+
}
|
|
705912
|
+
async preemptTelegramSubAgentForIntake(msg, subAgent, toolContext, intake) {
|
|
705913
|
+
const sessionKey = intake.sessionKey;
|
|
705914
|
+
await this.transitionTelegramIntake(
|
|
705915
|
+
intake,
|
|
705916
|
+
"acknowledged",
|
|
705917
|
+
"trusted Telegram steering receipt sent",
|
|
705918
|
+
{ runId: subAgent.runId }
|
|
705919
|
+
);
|
|
705920
|
+
const receipt = intake.intent === "cancel" ? "Cancellation received. I am stopping the current task." : "Redirection received. I am stopping the current step and replanning from your latest instruction.";
|
|
705921
|
+
await this.replyToTelegramMessage(msg, receipt).catch(() => null);
|
|
705922
|
+
await this.transitionTelegramIntake(
|
|
705923
|
+
intake,
|
|
705924
|
+
"preempt_requested",
|
|
705925
|
+
"trusted admin-DM steering preemption requested",
|
|
705926
|
+
{ runId: subAgent.runId }
|
|
705927
|
+
);
|
|
705928
|
+
subAgent.preempted = true;
|
|
705929
|
+
if (intake.intent !== "cancel") {
|
|
705930
|
+
const epoch = this.advanceTelegramTaskEpoch(sessionKey);
|
|
705931
|
+
const displaced = this.telegramQueuedSessionWork.get(sessionKey);
|
|
705932
|
+
if (displaced) {
|
|
705933
|
+
this.telegramQueuedSessionWork.delete(sessionKey);
|
|
705934
|
+
await Promise.all(
|
|
705935
|
+
displaced.intakeRecords.map(
|
|
705936
|
+
(record) => this.transitionTelegramIntake(
|
|
705937
|
+
record,
|
|
705938
|
+
"superseded",
|
|
705939
|
+
`superseded by trusted ${intake.intent} intake ${intake.inputId}`
|
|
705940
|
+
)
|
|
705941
|
+
)
|
|
705942
|
+
);
|
|
705943
|
+
}
|
|
705944
|
+
intake.taskEpoch = epoch;
|
|
705945
|
+
const queued = this.buildTelegramQueuedSessionWork(
|
|
705946
|
+
sessionKey,
|
|
705947
|
+
msg,
|
|
705948
|
+
toolContext,
|
|
705949
|
+
Date.now(),
|
|
705950
|
+
intake
|
|
705951
|
+
);
|
|
705952
|
+
this.telegramQueuedSessionWork.set(sessionKey, queued);
|
|
705953
|
+
await this.transitionTelegramIntake(
|
|
705954
|
+
intake,
|
|
705955
|
+
"deferred",
|
|
705956
|
+
"waiting for superseded runner cleanup before dispatch",
|
|
705957
|
+
{ taskEpoch: epoch }
|
|
705958
|
+
);
|
|
705959
|
+
}
|
|
705960
|
+
const runner = subAgent.runner;
|
|
705961
|
+
if (typeof runner?.requestSteeringPreemption === "function") {
|
|
705962
|
+
runner.requestSteeringPreemption(intake.inputId);
|
|
705963
|
+
} else {
|
|
705964
|
+
runner?.abort?.();
|
|
705965
|
+
}
|
|
705966
|
+
await this.transitionTelegramIntake(
|
|
705967
|
+
intake,
|
|
705968
|
+
"preempted",
|
|
705969
|
+
"active runner interrupted for trusted steering intake",
|
|
705970
|
+
{ runId: subAgent.runId }
|
|
705971
|
+
);
|
|
705972
|
+
this.dispatchQueuedTelegramSessionWorkSoon();
|
|
705973
|
+
}
|
|
705974
|
+
async requeuePendingTelegramIntakeOnFinalization(subAgent) {
|
|
705975
|
+
const pending2 = subAgent.pendingIntakeRecords.splice(0);
|
|
705976
|
+
if (pending2.length === 0) return;
|
|
705977
|
+
for (const item of pending2) {
|
|
705978
|
+
const msg = this.telegramIntakeMessages.get(item.intake.inputId);
|
|
705979
|
+
if (!msg || subAgent.preempted) {
|
|
705980
|
+
await this.transitionTelegramIntake(
|
|
705981
|
+
item.intake,
|
|
705982
|
+
subAgent.preempted ? "superseded" : "failed",
|
|
705983
|
+
subAgent.preempted ? "runner was superseded before pending intake dispatch" : "original Telegram message unavailable for pending intake requeue"
|
|
705984
|
+
);
|
|
705985
|
+
continue;
|
|
705986
|
+
}
|
|
705987
|
+
const work = this.buildTelegramQueuedSessionWork(
|
|
705988
|
+
item.intake.sessionKey,
|
|
705989
|
+
msg,
|
|
705990
|
+
subAgent.toolContext,
|
|
705991
|
+
Date.now(),
|
|
705992
|
+
item.intake
|
|
705993
|
+
);
|
|
705994
|
+
this.telegramQueuedSessionWork.set(item.intake.sessionKey, work);
|
|
705995
|
+
await this.transitionTelegramIntake(
|
|
705996
|
+
item.intake,
|
|
705997
|
+
"deferred",
|
|
705998
|
+
"runner finalized before pending intake dispatch; requeued atomically"
|
|
705999
|
+
);
|
|
706000
|
+
}
|
|
706001
|
+
this.dispatchQueuedTelegramSessionWorkSoon();
|
|
706002
|
+
}
|
|
706003
|
+
forwardTelegramRunnerIntakeLifecycle(event) {
|
|
706004
|
+
const typed = event;
|
|
706005
|
+
const inputId = typed.inputId ?? typed.steeringInputId;
|
|
706006
|
+
if (!inputId) return;
|
|
706007
|
+
const record = this.telegramIntakeRecords.get(inputId);
|
|
706008
|
+
if (!record) return;
|
|
706009
|
+
const lifecycle = typed.type === "steering_preempt_requested" ? "preempt_requested" : typed.type === "steering_preempted" ? "preempted" : typed.type === "steering_input_consumed" || typed.type === "steering_consumed" ? "consumed" : typed.type === "steering_input_accepted" || typed.type === "steering_received" ? "accepted" : null;
|
|
706010
|
+
if (!lifecycle) return;
|
|
706011
|
+
void this.transitionTelegramIntake(
|
|
706012
|
+
record,
|
|
706013
|
+
lifecycle,
|
|
706014
|
+
`runner lifecycle event: ${typed.type}`,
|
|
706015
|
+
typeof typed.turn === "number" ? { runnerTurn: typed.turn } : {}
|
|
706016
|
+
);
|
|
704897
706017
|
}
|
|
704898
706018
|
async replyWithTelegramHelp(msg, isAdmin) {
|
|
704899
706019
|
const scope = isAdmin ? "admin" : "public";
|
|
@@ -712597,12 +713717,32 @@ Join: ${newUrl}`
|
|
|
712597
713717
|
return;
|
|
712598
713718
|
}
|
|
712599
713719
|
}
|
|
713720
|
+
const intakeTriage = this.triageTelegramSteeringInput(msg);
|
|
713721
|
+
const intakeRecord = await this.registerTelegramIntake(msg, intakeTriage);
|
|
712600
713722
|
const existing = this.subAgents.get(sessionKey);
|
|
712601
713723
|
if (existing && !existing.aborted) {
|
|
712602
|
-
|
|
713724
|
+
const trustedPreemption = isAdminDM && (intakeRecord.intent === "cancel" || intakeRecord.intent === "redirect" || intakeRecord.intent === "replace");
|
|
713725
|
+
if (trustedPreemption) {
|
|
713726
|
+
await this.preemptTelegramSubAgentForIntake(
|
|
713727
|
+
msg,
|
|
713728
|
+
existing,
|
|
713729
|
+
toolContext,
|
|
713730
|
+
intakeRecord
|
|
713731
|
+
);
|
|
713732
|
+
return;
|
|
713733
|
+
}
|
|
713734
|
+
await this.enqueueTelegramMessageForExistingSubAgent(
|
|
713735
|
+
msg,
|
|
713736
|
+
existing,
|
|
713737
|
+
intakeRecord
|
|
713738
|
+
);
|
|
712603
713739
|
return;
|
|
712604
713740
|
}
|
|
712605
|
-
const queuedWork = this.scheduleTelegramSessionWork(
|
|
713741
|
+
const queuedWork = this.scheduleTelegramSessionWork(
|
|
713742
|
+
msg,
|
|
713743
|
+
toolContext,
|
|
713744
|
+
intakeRecord
|
|
713745
|
+
);
|
|
712606
713746
|
if (this.shouldAwaitTelegramQueuedWorkForTests()) await queuedWork;
|
|
712607
713747
|
}
|
|
712608
713748
|
async processTelegramMessageWork(work, workGeneration) {
|
|
@@ -712612,6 +713752,15 @@ Join: ${newUrl}`
|
|
|
712612
713752
|
const isAdminDM = toolContext === "telegram-admin-dm";
|
|
712613
713753
|
if (!this.telegramWorkGenerationIsCurrent(sessionKey, workGeneration))
|
|
712614
713754
|
return;
|
|
713755
|
+
await Promise.all(
|
|
713756
|
+
work.intakeRecords.map(
|
|
713757
|
+
(record) => this.transitionTelegramIntake(
|
|
713758
|
+
record,
|
|
713759
|
+
"dispatched",
|
|
713760
|
+
"Telegram session work dispatched to runner admission"
|
|
713761
|
+
)
|
|
713762
|
+
)
|
|
713763
|
+
);
|
|
712615
713764
|
const existing = this.subAgents.get(sessionKey);
|
|
712616
713765
|
if (existing && !existing.aborted) {
|
|
712617
713766
|
await this.enqueueTelegramQueuedSessionWorkForExistingSubAgent(
|
|
@@ -712690,6 +713839,15 @@ Join: ${newUrl}`
|
|
|
712690
713839
|
msg,
|
|
712691
713840
|
`live inference: no reply — ${decision2.reason}`
|
|
712692
713841
|
);
|
|
713842
|
+
await Promise.all(
|
|
713843
|
+
work.intakeRecords.map(
|
|
713844
|
+
(intake) => this.transitionTelegramIntake(
|
|
713845
|
+
intake,
|
|
713846
|
+
"consumed",
|
|
713847
|
+
"Telegram attention router retained intake without visible reply"
|
|
713848
|
+
)
|
|
713849
|
+
)
|
|
713850
|
+
);
|
|
712693
713851
|
return;
|
|
712694
713852
|
}
|
|
712695
713853
|
const decisionContext = this.formatTelegramAttentionDecisionContext(deliveredDecision);
|
|
@@ -712734,6 +713892,15 @@ Join: ${newUrl}`
|
|
|
712734
713892
|
daydreamOpportunities
|
|
712735
713893
|
);
|
|
712736
713894
|
}
|
|
713895
|
+
await Promise.all(
|
|
713896
|
+
work.intakeRecords.map(
|
|
713897
|
+
(intake) => this.transitionTelegramIntake(
|
|
713898
|
+
intake,
|
|
713899
|
+
"consumed",
|
|
713900
|
+
"Telegram quick-chat path completed"
|
|
713901
|
+
)
|
|
713902
|
+
)
|
|
713903
|
+
);
|
|
712737
713904
|
return;
|
|
712738
713905
|
}
|
|
712739
713906
|
const subAgent = {
|
|
@@ -712757,7 +713924,10 @@ Join: ${newUrl}`
|
|
|
712757
713924
|
lastEditMs: 0,
|
|
712758
713925
|
aborted: false,
|
|
712759
713926
|
toolContext,
|
|
712760
|
-
|
|
713927
|
+
pendingIntakeRecords: [],
|
|
713928
|
+
pendingContextPackets: [],
|
|
713929
|
+
runId: `telegram:${randomBytes28(8).toString("hex")}`,
|
|
713930
|
+
taskEpoch: work.intakeRecords[work.intakeRecords.length - 1]?.taskEpoch ?? this.telegramTaskEpoch(sessionKey),
|
|
712761
713931
|
creativeWorkspaceRoot: this.creativeWorkspaceRootForMessage(
|
|
712762
713932
|
msg,
|
|
712763
713933
|
toolContext
|
|
@@ -712768,6 +713938,14 @@ Join: ${newUrl}`
|
|
|
712768
713938
|
surfacedToolCallFingerprints: /* @__PURE__ */ new Set()
|
|
712769
713939
|
};
|
|
712770
713940
|
this.subAgents.set(sessionKey, subAgent);
|
|
713941
|
+
for (const intake of work.intakeRecords) {
|
|
713942
|
+
void this.transitionTelegramIntake(
|
|
713943
|
+
intake,
|
|
713944
|
+
"accepted",
|
|
713945
|
+
"admitted as the primary Telegram task prompt",
|
|
713946
|
+
{ runId: subAgent.runId }
|
|
713947
|
+
);
|
|
713948
|
+
}
|
|
712771
713949
|
this.refreshActiveTelegramInteractionCount();
|
|
712772
713950
|
this.subAgentViewCallbacks?.onRegister(
|
|
712773
713951
|
subAgent.viewId,
|
|
@@ -712818,6 +713996,20 @@ Join: ${newUrl}`
|
|
|
712818
713996
|
mediaContext,
|
|
712819
713997
|
subAgentProfile,
|
|
712820
713998
|
[decisionContext, rapidContext].filter(Boolean).join("\n\n")
|
|
713999
|
+
).catch((err) => {
|
|
714000
|
+
if (subAgent.preempted) return "";
|
|
714001
|
+
throw err;
|
|
714002
|
+
});
|
|
714003
|
+
if (subAgent.preempted) return;
|
|
714004
|
+
await Promise.all(
|
|
714005
|
+
work.intakeRecords.map(
|
|
714006
|
+
(intake) => this.transitionTelegramIntake(
|
|
714007
|
+
intake,
|
|
714008
|
+
"consumed",
|
|
714009
|
+
"primary Telegram task completed its runner lifecycle",
|
|
714010
|
+
{ runId: subAgent.runId }
|
|
714011
|
+
)
|
|
714012
|
+
)
|
|
712821
714013
|
);
|
|
712822
714014
|
if (subAgent.typingInterval) {
|
|
712823
714015
|
clearInterval(subAgent.typingInterval);
|
|
@@ -713009,6 +714201,7 @@ Join: ${newUrl}`
|
|
|
713009
714201
|
}
|
|
713010
714202
|
} finally {
|
|
713011
714203
|
this.stopTelegramPublicProgressMessage(subAgent);
|
|
714204
|
+
await this.requeuePendingTelegramIntakeOnFinalization(subAgent);
|
|
713012
714205
|
this.clearTelegramSubAgentContextBuffer(sessionKey);
|
|
713013
714206
|
this.subAgents.delete(sessionKey);
|
|
713014
714207
|
this.refreshActiveTelegramInteractionCount();
|
|
@@ -713039,7 +714232,10 @@ Join: ${newUrl}`
|
|
|
713039
714232
|
lastEditMs: 0,
|
|
713040
714233
|
aborted: false,
|
|
713041
714234
|
toolContext,
|
|
713042
|
-
|
|
714235
|
+
pendingIntakeRecords: [],
|
|
714236
|
+
pendingContextPackets: [],
|
|
714237
|
+
runId: `telegram:${randomBytes28(8).toString("hex")}`,
|
|
714238
|
+
taskEpoch: this.telegramTaskEpoch(sessionKey),
|
|
713043
714239
|
creativeWorkspaceRoot: this.creativeWorkspaceRootForMessage(
|
|
713044
714240
|
msg,
|
|
713045
714241
|
toolContext
|
|
@@ -713050,6 +714246,17 @@ Join: ${newUrl}`
|
|
|
713050
714246
|
surfacedToolCallFingerprints: /* @__PURE__ */ new Set()
|
|
713051
714247
|
};
|
|
713052
714248
|
this.subAgents.set(sessionKey, subAgent);
|
|
714249
|
+
const primaryIntake = this.telegramIntakeRecords.get(
|
|
714250
|
+
this.telegramInputIdForMessage(msg)
|
|
714251
|
+
);
|
|
714252
|
+
if (primaryIntake) {
|
|
714253
|
+
void this.transitionTelegramIntake(
|
|
714254
|
+
primaryIntake,
|
|
714255
|
+
"accepted",
|
|
714256
|
+
"admitted as the primary Telegram chat prompt",
|
|
714257
|
+
{ runId: subAgent.runId }
|
|
714258
|
+
);
|
|
714259
|
+
}
|
|
713053
714260
|
this.refreshActiveTelegramInteractionCount();
|
|
713054
714261
|
this.subAgentViewCallbacks?.onRegister(
|
|
713055
714262
|
subAgent.viewId,
|
|
@@ -713092,7 +714299,11 @@ Join: ${newUrl}`
|
|
|
713092
714299
|
mediaContext,
|
|
713093
714300
|
"chat",
|
|
713094
714301
|
additionalContext
|
|
713095
|
-
)
|
|
714302
|
+
).catch((err) => {
|
|
714303
|
+
if (subAgent.preempted) return "";
|
|
714304
|
+
throw err;
|
|
714305
|
+
});
|
|
714306
|
+
if (subAgent.preempted) return;
|
|
713096
714307
|
if (subAgent.typingInterval) {
|
|
713097
714308
|
clearInterval(subAgent.typingInterval);
|
|
713098
714309
|
subAgent.typingInterval = null;
|
|
@@ -713216,6 +714427,7 @@ Join: ${newUrl}`
|
|
|
713216
714427
|
);
|
|
713217
714428
|
}
|
|
713218
714429
|
} finally {
|
|
714430
|
+
await this.requeuePendingTelegramIntakeOnFinalization(subAgent);
|
|
713219
714431
|
this.clearTelegramSubAgentContextBuffer(sessionKey);
|
|
713220
714432
|
this.subAgents.delete(sessionKey);
|
|
713221
714433
|
this.refreshActiveTelegramInteractionCount();
|
|
@@ -713682,6 +714894,7 @@ ${conversationStream}`
|
|
|
713682
714894
|
...isAdminDM ? TELEGRAM_ADMIN_EVIDENCE_OPTIONS : TELEGRAM_PUBLIC_FAST_OPTIONS,
|
|
713683
714895
|
// ── WO #03 (Typed Gateway Event Stream): structured event feed ──
|
|
713684
714896
|
onTypedEvent: (event) => {
|
|
714897
|
+
this.forwardTelegramRunnerIntakeLifecycle(event);
|
|
713685
714898
|
if (event.type === "run_finished") {
|
|
713686
714899
|
subAgent.runnerCompleted = event.success;
|
|
713687
714900
|
subAgent.runnerStatus = event.status;
|
|
@@ -713697,17 +714910,33 @@ ${conversationStream}`
|
|
|
713697
714910
|
});
|
|
713698
714911
|
runner.setWorkingDirectory(repoRoot);
|
|
713699
714912
|
subAgent.runner = runner;
|
|
713700
|
-
if (subAgent.
|
|
713701
|
-
for (const queued of subAgent.
|
|
713702
|
-
|
|
714913
|
+
if (subAgent.pendingIntakeRecords.length > 0) {
|
|
714914
|
+
for (const queued of subAgent.pendingIntakeRecords) {
|
|
714915
|
+
this.injectTelegramSteeringInput(
|
|
714916
|
+
subAgent,
|
|
714917
|
+
queued.intake,
|
|
714918
|
+
queued.content
|
|
714919
|
+
);
|
|
714920
|
+
void this.transitionTelegramIntake(
|
|
714921
|
+
queued.intake,
|
|
714922
|
+
"accepted",
|
|
714923
|
+
"initial Telegram intake handed to runner",
|
|
714924
|
+
{ runId: subAgent.runId }
|
|
714925
|
+
);
|
|
713703
714926
|
}
|
|
713704
714927
|
this.tuiWrite(
|
|
713705
714928
|
() => renderTelegramSubAgentEvent(
|
|
713706
714929
|
msg.username,
|
|
713707
|
-
`replayed ${subAgent.
|
|
714930
|
+
`replayed ${subAgent.pendingIntakeRecords.length} typed intake record(s)`
|
|
713708
714931
|
)
|
|
713709
714932
|
);
|
|
713710
|
-
subAgent.
|
|
714933
|
+
subAgent.pendingIntakeRecords.length = 0;
|
|
714934
|
+
}
|
|
714935
|
+
if (subAgent.pendingContextPackets.length > 0) {
|
|
714936
|
+
for (const packet of subAgent.pendingContextPackets) {
|
|
714937
|
+
runner.injectUserMessage(packet);
|
|
714938
|
+
}
|
|
714939
|
+
subAgent.pendingContextPackets.length = 0;
|
|
713711
714940
|
}
|
|
713712
714941
|
const tools = this.buildSubAgentTools(
|
|
713713
714942
|
ctx3,
|
|
@@ -720501,7 +721730,7 @@ var command_passthrough_exports = {};
|
|
|
720501
721730
|
__export(command_passthrough_exports, {
|
|
720502
721731
|
runCommand: () => runCommand
|
|
720503
721732
|
});
|
|
720504
|
-
function
|
|
721733
|
+
function stripAnsi7(s2) {
|
|
720505
721734
|
return s2.replace(/\x1B(?:\[[\d;?]*[a-zA-Z]|\][^\x07\x1B]*[\x07\x1B]?|[@-Z\\-_])/g, "");
|
|
720506
721735
|
}
|
|
720507
721736
|
async function runCommand(input, opts) {
|
|
@@ -720566,7 +721795,7 @@ async function runCommand(input, opts) {
|
|
|
720566
721795
|
command: cmdName,
|
|
720567
721796
|
args: argsStr,
|
|
720568
721797
|
kind,
|
|
720569
|
-
output:
|
|
721798
|
+
output: stripAnsi7(ansi5).trim(),
|
|
720570
721799
|
ansi: ansi5,
|
|
720571
721800
|
durationMs: Date.now() - start2,
|
|
720572
721801
|
error: errMsg
|
|
@@ -721935,7 +723164,7 @@ var init_audit_log = __esm({
|
|
|
721935
723164
|
// packages/cli/src/api/disk-task-output.ts
|
|
721936
723165
|
import { open } from "node:fs/promises";
|
|
721937
723166
|
import { existsSync as existsSync164, mkdirSync as mkdirSync102, statSync as statSync63 } from "node:fs";
|
|
721938
|
-
import { dirname as
|
|
723167
|
+
import { dirname as dirname54 } from "node:path";
|
|
721939
723168
|
import * as fsConstants from "node:constants";
|
|
721940
723169
|
var O_NOFOLLOW2, O_APPEND2, O_CREAT2, O_WRONLY2, OPEN_FLAGS_WRITE, OPEN_MODE, DiskTaskOutput;
|
|
721941
723170
|
var init_disk_task_output = __esm({
|
|
@@ -721953,7 +723182,7 @@ var init_disk_task_output = __esm({
|
|
|
721953
723182
|
fileSize = 0;
|
|
721954
723183
|
constructor(outputPath3) {
|
|
721955
723184
|
this.path = outputPath3;
|
|
721956
|
-
mkdirSync102(
|
|
723185
|
+
mkdirSync102(dirname54(outputPath3), { recursive: true });
|
|
721957
723186
|
}
|
|
721958
723187
|
/** Queue content for async append. Non-blocking. */
|
|
721959
723188
|
append(chunk) {
|
|
@@ -741038,7 +742267,7 @@ var init_chat_followup = __esm({
|
|
|
741038
742267
|
// packages/cli/src/docker.ts
|
|
741039
742268
|
import { execSync as execSync39, spawn as spawn37 } from "node:child_process";
|
|
741040
742269
|
import { existsSync as existsSync172, mkdirSync as mkdirSync108, writeFileSync as writeFileSync91 } from "node:fs";
|
|
741041
|
-
import { join as join181, resolve as resolve76, dirname as
|
|
742270
|
+
import { join as join181, resolve as resolve76, dirname as dirname55 } from "node:path";
|
|
741042
742271
|
import { homedir as homedir62 } from "node:os";
|
|
741043
742272
|
import { fileURLToPath as fileURLToPath22 } from "node:url";
|
|
741044
742273
|
function getDockerDir() {
|
|
@@ -741049,7 +742278,7 @@ function getDockerDir() {
|
|
|
741049
742278
|
} catch {
|
|
741050
742279
|
}
|
|
741051
742280
|
try {
|
|
741052
|
-
const thisDir =
|
|
742281
|
+
const thisDir = dirname55(fileURLToPath22(import.meta.url));
|
|
741053
742282
|
return join181(thisDir, "..", "..", "..", "docker");
|
|
741054
742283
|
} catch {
|
|
741055
742284
|
}
|
|
@@ -741514,7 +742743,7 @@ import * as http5 from "node:http";
|
|
|
741514
742743
|
import * as https3 from "node:https";
|
|
741515
742744
|
import { createRequire as createRequire8 } from "node:module";
|
|
741516
742745
|
import { fileURLToPath as fileURLToPath23 } from "node:url";
|
|
741517
|
-
import { dirname as
|
|
742746
|
+
import { dirname as dirname56, join as join183, resolve as resolve77 } from "node:path";
|
|
741518
742747
|
import { homedir as homedir63 } from "node:os";
|
|
741519
742748
|
import { spawn as spawn38, execSync as execSync40 } from "node:child_process";
|
|
741520
742749
|
import {
|
|
@@ -741544,7 +742773,7 @@ function memoryDbPaths3(baseDir = process.cwd()) {
|
|
|
741544
742773
|
}
|
|
741545
742774
|
function getVersion3() {
|
|
741546
742775
|
try {
|
|
741547
|
-
const thisDir =
|
|
742776
|
+
const thisDir = dirname56(fileURLToPath23(import.meta.url));
|
|
741548
742777
|
const candidates = [
|
|
741549
742778
|
join183(thisDir, "..", "package.json"),
|
|
741550
742779
|
join183(thisDir, "..", "..", "package.json"),
|
|
@@ -742122,23 +743351,7 @@ async function writeMemoryEpisodes(sessionId, userMessage, assistantContent, too
|
|
|
742122
743351
|
}
|
|
742123
743352
|
}
|
|
742124
743353
|
function sanitizeChatContent(raw) {
|
|
742125
|
-
|
|
742126
|
-
const lines = raw.split("\n");
|
|
742127
|
-
const cleaned = [];
|
|
742128
|
-
for (const rawLine of lines) {
|
|
742129
|
-
const line = rawLine.replace(/\x1B\[[0-9;]*[A-Za-z]/g, "").replace(/\x1B\].*?\x07/g, "").trim();
|
|
742130
|
-
if (!line) continue;
|
|
742131
|
-
if (/^i\s+/.test(line)) continue;
|
|
742132
|
-
if (/^E\s+/.test(line)) continue;
|
|
742133
|
-
if (/^⚠\s*(Task incomplete|Task complete)/.test(line)) continue;
|
|
742134
|
-
if (/^▹\s/.test(line)) continue;
|
|
742135
|
-
if (/^User:\s/.test(line)) continue;
|
|
742136
|
-
if (/^Assistant:\s/.test(line)) continue;
|
|
742137
|
-
if (/^Previous conversation:/.test(line)) continue;
|
|
742138
|
-
if (/^omnius \(/.test(line)) continue;
|
|
742139
|
-
cleaned.push(line);
|
|
742140
|
-
}
|
|
742141
|
-
return cleaned.join("\n").trim();
|
|
743354
|
+
return sanitizeAgentOutputForUser(raw);
|
|
742142
743355
|
}
|
|
742143
743356
|
function appendNoThinkDirectivesToMessages(messages2) {
|
|
742144
743357
|
let lastUserIdx = -1;
|
|
@@ -744276,7 +745489,8 @@ async function handleV1ChatCompletions(req3, res, ollamaUrl) {
|
|
|
744276
745489
|
return;
|
|
744277
745490
|
}
|
|
744278
745491
|
const callerProvidedThink = "think" in routedBody;
|
|
744279
|
-
const
|
|
745492
|
+
const requestTools = routedBody["tools"];
|
|
745493
|
+
const thinkingAllowed = process.env["OMNIUS_FORCE_NO_THINK"] !== "1" && !(Array.isArray(requestTools) && requestTools.length > 0);
|
|
744280
745494
|
const finalThink = thinkingAllowed && callerProvidedThink ? routedBody["think"] : false;
|
|
744281
745495
|
const ollamaBody = { ...routedBody };
|
|
744282
745496
|
if (finalThink === false && Array.isArray(ollamaBody["messages"])) {
|
|
@@ -745021,7 +746235,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
745021
746235
|
);
|
|
745022
746236
|
const fs14 = require4("node:fs");
|
|
745023
746237
|
const nodeBin = process.execPath;
|
|
745024
|
-
const nodeDir =
|
|
746238
|
+
const nodeDir = dirname56(nodeBin);
|
|
745025
746239
|
const { execSync: es } = require4("node:child_process");
|
|
745026
746240
|
const isWin2 = process.platform === "win32";
|
|
745027
746241
|
let npmBin = "";
|
|
@@ -745036,7 +746250,7 @@ async function handleV1Update(req3, res, requestId) {
|
|
|
745036
746250
|
const dir = join183(homedir63(), ".omnius");
|
|
745037
746251
|
fs14.mkdirSync(dir, { recursive: true });
|
|
745038
746252
|
const logFd = fs14.openSync(logPath3, "w");
|
|
745039
|
-
const npmPrefix =
|
|
746253
|
+
const npmPrefix = dirname56(nodeDir);
|
|
745040
746254
|
let globalBinDir = "";
|
|
745041
746255
|
try {
|
|
745042
746256
|
if (isWin2) {
|
|
@@ -750985,7 +752199,7 @@ function startApiServer(options2 = {}) {
|
|
|
750985
752199
|
if (process.env["OMNIUS_DAEMON"] === "1" && process.env["OMNIUS_NO_VERSION_GUARD"] !== "1") {
|
|
750986
752200
|
const readDiskVersion = () => {
|
|
750987
752201
|
try {
|
|
750988
|
-
const here =
|
|
752202
|
+
const here = dirname56(fileURLToPath23(import.meta.url));
|
|
750989
752203
|
for (const rel of ["../package.json", "../../package.json", "../../../package.json", "../../../../package.json"]) {
|
|
750990
752204
|
const p2 = join183(here, rel);
|
|
750991
752205
|
if (existsSync173(p2)) {
|
|
@@ -751894,6 +753108,7 @@ var init_serve = __esm({
|
|
|
751894
753108
|
init_access_policy();
|
|
751895
753109
|
init_projects();
|
|
751896
753110
|
init_project_preferences();
|
|
753111
|
+
init_internal_output();
|
|
751897
753112
|
init_voice_runtime();
|
|
751898
753113
|
init_voice();
|
|
751899
753114
|
init_audit_log();
|
|
@@ -752075,7 +753290,7 @@ var init_clipboard_media = __esm({
|
|
|
752075
753290
|
|
|
752076
753291
|
// packages/cli/src/tui/interactive.ts
|
|
752077
753292
|
import { cwd } from "node:process";
|
|
752078
|
-
import { resolve as resolve78, join as join185, dirname as
|
|
753293
|
+
import { resolve as resolve78, join as join185, dirname as dirname57, extname as extname22, relative as relative22, sep as sep7 } from "node:path";
|
|
752079
753294
|
import { createRequire as createRequire9 } from "node:module";
|
|
752080
753295
|
import { fileURLToPath as fileURLToPath24 } from "node:url";
|
|
752081
753296
|
import { createHash as createHash53 } from "node:crypto";
|
|
@@ -752092,7 +753307,7 @@ import { existsSync as existsSync174 } from "node:fs";
|
|
|
752092
753307
|
import {
|
|
752093
753308
|
readFile as readFileAsync2,
|
|
752094
753309
|
writeFile as writeFileAsync2,
|
|
752095
|
-
mkdir as
|
|
753310
|
+
mkdir as mkdirAsync2
|
|
752096
753311
|
} from "node:fs/promises";
|
|
752097
753312
|
import { homedir as homedir64 } from "node:os";
|
|
752098
753313
|
function refreshLocalOllamaModelCache() {
|
|
@@ -752136,7 +753351,7 @@ function formatTimeAgo2(date) {
|
|
|
752136
753351
|
function getVersion4() {
|
|
752137
753352
|
try {
|
|
752138
753353
|
const require5 = createRequire9(import.meta.url);
|
|
752139
|
-
const thisDir =
|
|
753354
|
+
const thisDir = dirname57(fileURLToPath24(import.meta.url));
|
|
752140
753355
|
const candidates = [
|
|
752141
753356
|
join185(thisDir, "..", "package.json"),
|
|
752142
753357
|
join185(thisDir, "..", "..", "package.json"),
|
|
@@ -756044,7 +757259,7 @@ When done, either call task_complete with your answer, or use FINAL_VAR(variable
|
|
|
756044
757259
|
if (existsSync174(ikFile)) {
|
|
756045
757260
|
ikState = JSON.parse(await readFileAsync2(ikFile, "utf8"));
|
|
756046
757261
|
} else {
|
|
756047
|
-
await
|
|
757262
|
+
await mkdirAsync2(ikDir, { recursive: true });
|
|
756048
757263
|
const machineId = Date.now().toString(36) + Math.random().toString(36).slice(2, 8);
|
|
756049
757264
|
ikState = {
|
|
756050
757265
|
self_id: `omnius-${machineId}`,
|
|
@@ -757218,14 +758433,50 @@ ${result.summary}`
|
|
|
757218
758433
|
} : null
|
|
757219
758434
|
});
|
|
757220
758435
|
let resolvedContextWindowSize = 0;
|
|
757221
|
-
|
|
757222
|
-
|
|
757223
|
-
|
|
757224
|
-
|
|
757225
|
-
|
|
757226
|
-
|
|
758436
|
+
const contextTelemetryByScope = /* @__PURE__ */ new Map();
|
|
758437
|
+
const contextScope = (backendUrl2, model) => `${normalizeBaseUrl(backendUrl2).replace(/\/v1$/i, "")}\0${model}`;
|
|
758438
|
+
const currentContextScope = () => contextScope(currentConfig.backendUrl, currentConfig.model);
|
|
758439
|
+
const applyContextTelemetry = (telemetry) => {
|
|
758440
|
+
const scope = contextScope(telemetry.endpoint, telemetry.model);
|
|
758441
|
+
const previous = contextTelemetryByScope.get(scope);
|
|
758442
|
+
const merged = {
|
|
758443
|
+
...previous,
|
|
758444
|
+
...telemetry,
|
|
758445
|
+
capacityTokens: telemetry.capacityTokens ?? previous?.capacityTokens,
|
|
758446
|
+
capacitySource: telemetry.capacityTokens ? telemetry.capacitySource : previous?.capacitySource
|
|
758447
|
+
};
|
|
758448
|
+
contextTelemetryByScope.set(scope, merged);
|
|
758449
|
+
if (scope !== currentContextScope()) return;
|
|
758450
|
+
const capacity = merged.capacityTokens;
|
|
758451
|
+
resolvedContextWindowSize = capacity ?? 0;
|
|
758452
|
+
statusBar.setContextCapacity(capacity ? {
|
|
758453
|
+
status: "known",
|
|
758454
|
+
totalTokens: capacity,
|
|
758455
|
+
source: merged.capacitySource,
|
|
758456
|
+
endpoint: merged.endpoint,
|
|
758457
|
+
model: merged.model
|
|
758458
|
+
} : {
|
|
758459
|
+
status: "unknown",
|
|
758460
|
+
source: "provider_metadata_missing",
|
|
758461
|
+
endpoint: merged.endpoint,
|
|
758462
|
+
model: merged.model
|
|
758463
|
+
});
|
|
758464
|
+
setActiveTaskContextWindowSize(capacity ?? 0);
|
|
758465
|
+
telegramBridge?.setContextWindowSize(capacity ?? 0);
|
|
758466
|
+
if (merged.estimatedContextTokens !== void 0 || merged.outputReservationTokens !== void 0) {
|
|
758467
|
+
statusBar.updateMetrics({
|
|
758468
|
+
...merged.estimatedContextTokens !== void 0 ? { estimatedContextTokens: merged.estimatedContextTokens } : {},
|
|
758469
|
+
...merged.outputReservationTokens !== void 0 ? { contextOutputReservationTokens: merged.outputReservationTokens } : {}
|
|
758470
|
+
});
|
|
757227
758471
|
}
|
|
757228
|
-
}
|
|
758472
|
+
};
|
|
758473
|
+
void queryContextTelemetry(config.backendUrl, config.model, config.apiKey).then(applyContextTelemetry).catch(() => {
|
|
758474
|
+
statusBar.setContextCapacity({
|
|
758475
|
+
status: "unknown",
|
|
758476
|
+
source: "query_failed",
|
|
758477
|
+
endpoint: normalizeBaseUrl(config.backendUrl),
|
|
758478
|
+
model: config.model
|
|
758479
|
+
});
|
|
757229
758480
|
});
|
|
757230
758481
|
let resolvedCaps = {
|
|
757231
758482
|
vision: false,
|
|
@@ -757539,6 +758790,28 @@ Rationale: ${proposal.rationale}${provenanceNote}${dmnDevDiscipline(proposal.cat
|
|
|
757539
758790
|
const runner = activeTask?.runner;
|
|
757540
758791
|
if (runner) runner.setContextWindowSize(size);
|
|
757541
758792
|
};
|
|
758793
|
+
let llamaCppSlotPollInFlight = false;
|
|
758794
|
+
const pollLlamaCppSlots = async () => {
|
|
758795
|
+
if (llamaCppSlotPollInFlight || !activeTask) return;
|
|
758796
|
+
llamaCppSlotPollInFlight = true;
|
|
758797
|
+
const pollScope = currentContextScope();
|
|
758798
|
+
const endpoint = currentConfig.backendUrl;
|
|
758799
|
+
const model = currentConfig.model;
|
|
758800
|
+
const apiKey = currentConfig.apiKey;
|
|
758801
|
+
try {
|
|
758802
|
+
const telemetry = await queryLlamaCppSlotTelemetry(endpoint, model, apiKey);
|
|
758803
|
+
if (telemetry && pollScope === currentContextScope()) {
|
|
758804
|
+
applyContextTelemetry(telemetry);
|
|
758805
|
+
}
|
|
758806
|
+
} catch {
|
|
758807
|
+
} finally {
|
|
758808
|
+
llamaCppSlotPollInFlight = false;
|
|
758809
|
+
}
|
|
758810
|
+
};
|
|
758811
|
+
const llamaCppSlotPollTimer = setInterval(() => {
|
|
758812
|
+
void pollLlamaCppSlots();
|
|
758813
|
+
}, 3e3);
|
|
758814
|
+
llamaCppSlotPollTimer.unref();
|
|
757542
758815
|
const turnQueue = [];
|
|
757543
758816
|
let queueDrainScheduled = false;
|
|
757544
758817
|
let sessionTitle = null;
|
|
@@ -763295,7 +764568,8 @@ async function runJson(task, config, repoPath2) {
|
|
|
763295
764568
|
try {
|
|
763296
764569
|
await runWithTUI(task, config, repoPath2, {
|
|
763297
764570
|
onAssistantText: (text2) => {
|
|
763298
|
-
|
|
764571
|
+
const sanitized = sanitizeAgentOutputForUser(text2);
|
|
764572
|
+
if (sanitized) assistantTexts.push(sanitized);
|
|
763299
764573
|
},
|
|
763300
764574
|
onToolCall: (tool, args) => {
|
|
763301
764575
|
toolCallLog.push({ tool, args });
|
|
@@ -763350,12 +764624,14 @@ async function runJson(task, config, repoPath2) {
|
|
|
763350
764624
|
process.stdout.write = origWrite;
|
|
763351
764625
|
process.stderr.write = origStderr;
|
|
763352
764626
|
const allCaptured = captured.join("");
|
|
763353
|
-
const cleanText2 = allCaptured
|
|
764627
|
+
const cleanText2 = sanitizeAgentOutputForUser(allCaptured);
|
|
763354
764628
|
result.text = cleanText2;
|
|
763355
764629
|
if (assistantTexts.length > 0) {
|
|
763356
|
-
const streamText = assistantTexts[0] || "";
|
|
764630
|
+
const streamText = sanitizeAgentOutputForUser(assistantTexts[0] || "");
|
|
763357
764631
|
const hasSubstantiveStream = streamText.length > 30;
|
|
763358
|
-
result.assistant_text = hasSubstantiveStream ? streamText :
|
|
764632
|
+
result.assistant_text = hasSubstantiveStream ? streamText : sanitizeAgentOutputForUser(
|
|
764633
|
+
assistantTexts[assistantTexts.length - 1] || ""
|
|
764634
|
+
);
|
|
763359
764635
|
}
|
|
763360
764636
|
if (toolCallLog.length > 0) {
|
|
763361
764637
|
result.tool_calls = toolCallLog;
|
|
@@ -763490,6 +764766,7 @@ var init_run = __esm({
|
|
|
763490
764766
|
init_dist8();
|
|
763491
764767
|
init_typed_node_events();
|
|
763492
764768
|
init_secret_redactor();
|
|
764769
|
+
init_internal_output();
|
|
763493
764770
|
}
|
|
763494
764771
|
});
|
|
763495
764772
|
|
|
@@ -764356,7 +765633,7 @@ init_typed_node_events();
|
|
|
764356
765633
|
init_dist5();
|
|
764357
765634
|
import { parseArgs as nodeParseArgs2 } from "node:util";
|
|
764358
765635
|
import { fileURLToPath as fileURLToPath25 } from "node:url";
|
|
764359
|
-
import { dirname as
|
|
765636
|
+
import { dirname as dirname58, join as join189 } from "node:path";
|
|
764360
765637
|
import { createRequire as createRequire10 } from "node:module";
|
|
764361
765638
|
|
|
764362
765639
|
// packages/cli/src/cli.ts
|
|
@@ -764504,7 +765781,7 @@ init_output();
|
|
|
764504
765781
|
function getVersion5() {
|
|
764505
765782
|
try {
|
|
764506
765783
|
const require5 = createRequire10(import.meta.url);
|
|
764507
|
-
const pkgPath = join189(
|
|
765784
|
+
const pkgPath = join189(dirname58(fileURLToPath25(import.meta.url)), "..", "package.json");
|
|
764508
765785
|
const pkg = require5(pkgPath);
|
|
764509
765786
|
return pkg.version;
|
|
764510
765787
|
} catch {
|