omnius 1.0.375 → 1.0.376
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 +544 -316
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4806,6 +4806,9 @@ var init_shell = __esm({
|
|
|
4806
4806
|
const lines = [
|
|
4807
4807
|
"[SHELL TRANSCRIPT]",
|
|
4808
4808
|
`command: ${args.command}`,
|
|
4809
|
+
args.cwdBefore ? `cwd_before: ${args.cwdBefore}` : null,
|
|
4810
|
+
args.cwdAfter ? `cwd_after: ${args.cwdAfter}` : null,
|
|
4811
|
+
args.cwdBefore && args.cwdAfter && args.nextCwd && args.cwdAfter !== args.nextCwd ? `cwd_note: cd changes are command-local; next shell call starts at ${args.nextCwd}` : null,
|
|
4809
4812
|
args.timedOut ? "status: timeout" : args.exitCode === 0 ? "status: success" : "status: failure",
|
|
4810
4813
|
args.exitCode === void 0 || args.exitCode === null ? null : `exit_code: ${args.exitCode}`,
|
|
4811
4814
|
args.error ? `error: ${args.error}` : null,
|
|
@@ -4919,6 +4922,8 @@ ${elevatedResult.stderr}` : ""),
|
|
|
4919
4922
|
runCommand(command, timeout2, stdinInput, onOutput) {
|
|
4920
4923
|
const start2 = performance.now();
|
|
4921
4924
|
const isWin2 = process.platform === "win32";
|
|
4925
|
+
const cwdBefore = this.currentCwd;
|
|
4926
|
+
let cwdAfter = cwdBefore;
|
|
4922
4927
|
let pwdDir = mkdtempSync(join6(tmpdir(), "omnius-shell-"));
|
|
4923
4928
|
let pwdFile = join6(pwdDir, `cwd-${randomUUID3()}`);
|
|
4924
4929
|
let wrappedCommand;
|
|
@@ -4987,13 +4992,13 @@ exit $__omnius_exit
|
|
|
4987
4992
|
heartbeatTimer.unref?.();
|
|
4988
4993
|
const captureFinalCwd = () => {
|
|
4989
4994
|
if (!pwdFile)
|
|
4990
|
-
return;
|
|
4995
|
+
return cwdAfter;
|
|
4991
4996
|
try {
|
|
4992
4997
|
const raw = readFileSync7(pwdFile, "utf8").trim();
|
|
4993
|
-
if (raw
|
|
4998
|
+
if (raw) {
|
|
4994
4999
|
try {
|
|
4995
5000
|
if (statSync5(raw).isDirectory()) {
|
|
4996
|
-
|
|
5001
|
+
cwdAfter = raw;
|
|
4997
5002
|
}
|
|
4998
5003
|
} catch {
|
|
4999
5004
|
}
|
|
@@ -5008,6 +5013,7 @@ exit $__omnius_exit
|
|
|
5008
5013
|
}
|
|
5009
5014
|
pwdFile = null;
|
|
5010
5015
|
pwdDir = null;
|
|
5016
|
+
return cwdAfter;
|
|
5011
5017
|
};
|
|
5012
5018
|
const doResolve = (result) => {
|
|
5013
5019
|
if (resolved)
|
|
@@ -5017,7 +5023,6 @@ exit $__omnius_exit
|
|
|
5017
5023
|
clearInterval(heartbeatTimer);
|
|
5018
5024
|
if (exitFlushTimer)
|
|
5019
5025
|
clearTimeout(exitFlushTimer);
|
|
5020
|
-
captureFinalCwd();
|
|
5021
5026
|
releaseProcessLease(leaseId, killed ? "killed" : result.success ? "completed" : "released", killed ? "shell command timed out" : "shell command exited");
|
|
5022
5027
|
resolve73(result);
|
|
5023
5028
|
};
|
|
@@ -5056,6 +5061,7 @@ exit $__omnius_exit
|
|
|
5056
5061
|
exitFlushTimer = setTimeout(() => {
|
|
5057
5062
|
const durationMs = performance.now() - start2;
|
|
5058
5063
|
if (killed) {
|
|
5064
|
+
const finalCwd2 = captureFinalCwd();
|
|
5059
5065
|
const combined = stdout + stderr;
|
|
5060
5066
|
const looksInteractive = /\? .+[›>]|y\/n|yes\/no|\(Y\/n\)|\[y\/N\]/i.test(combined);
|
|
5061
5067
|
const hint = looksInteractive ? " The command appears to be waiting for interactive input. Use non-interactive flags (e.g., --yes, --no-input) or provide input via the stdin parameter." : ` To run longer, retry with a higher timeout parameter (e.g. timeout: ${Math.min(timeout2 * 10, 6e5)} for ${Math.min(timeout2 * 10, 6e5) / 1e3}s). Or use background_run to run in the background and check with task_output later.`;
|
|
@@ -5065,6 +5071,9 @@ exit $__omnius_exit
|
|
|
5065
5071
|
error: `Command timed out after ${timeout2}ms.${hint}`,
|
|
5066
5072
|
llmContent: this.formatShellTranscript({
|
|
5067
5073
|
command,
|
|
5074
|
+
cwdBefore,
|
|
5075
|
+
cwdAfter: finalCwd2,
|
|
5076
|
+
nextCwd: this.currentCwd,
|
|
5068
5077
|
timedOut: true,
|
|
5069
5078
|
stdout,
|
|
5070
5079
|
stderr,
|
|
@@ -5075,6 +5084,7 @@ exit $__omnius_exit
|
|
|
5075
5084
|
return;
|
|
5076
5085
|
}
|
|
5077
5086
|
const success = code8 === 0;
|
|
5087
|
+
const finalCwd = captureFinalCwd();
|
|
5078
5088
|
doResolve({
|
|
5079
5089
|
success,
|
|
5080
5090
|
output: stdout + (stderr && success ? `
|
|
@@ -5083,6 +5093,9 @@ ${stderr}` : ""),
|
|
|
5083
5093
|
error: success ? void 0 : stderr || `Exit code ${code8}`,
|
|
5084
5094
|
llmContent: this.formatShellTranscript({
|
|
5085
5095
|
command,
|
|
5096
|
+
cwdBefore,
|
|
5097
|
+
cwdAfter: finalCwd,
|
|
5098
|
+
nextCwd: this.currentCwd,
|
|
5086
5099
|
exitCode: code8,
|
|
5087
5100
|
stdout,
|
|
5088
5101
|
stderr,
|
|
@@ -5095,6 +5108,7 @@ ${stderr}` : ""),
|
|
|
5095
5108
|
child.on("close", (code8) => {
|
|
5096
5109
|
const durationMs = performance.now() - start2;
|
|
5097
5110
|
if (killed) {
|
|
5111
|
+
const finalCwd2 = captureFinalCwd();
|
|
5098
5112
|
const combined = stdout + stderr;
|
|
5099
5113
|
const looksInteractive = /\? .+[›>]|y\/n|yes\/no|\(Y\/n\)|\[y\/N\]/i.test(combined);
|
|
5100
5114
|
const hint = looksInteractive ? " The command appears to be waiting for interactive input. Use non-interactive flags (e.g., --yes, --no-input) or provide input via the stdin parameter." : ` To run longer, retry with a higher timeout parameter (e.g. timeout: ${Math.min(timeout2 * 10, 6e5)} for ${Math.min(timeout2 * 10, 6e5) / 1e3}s). Or use background_run to run in the background and check with task_output later.`;
|
|
@@ -5104,6 +5118,9 @@ ${stderr}` : ""),
|
|
|
5104
5118
|
error: `Command timed out after ${timeout2}ms.${hint}`,
|
|
5105
5119
|
llmContent: this.formatShellTranscript({
|
|
5106
5120
|
command,
|
|
5121
|
+
cwdBefore,
|
|
5122
|
+
cwdAfter: finalCwd2,
|
|
5123
|
+
nextCwd: this.currentCwd,
|
|
5107
5124
|
timedOut: true,
|
|
5108
5125
|
stdout,
|
|
5109
5126
|
stderr,
|
|
@@ -5114,6 +5131,7 @@ ${stderr}` : ""),
|
|
|
5114
5131
|
return;
|
|
5115
5132
|
}
|
|
5116
5133
|
const success = code8 === 0;
|
|
5134
|
+
const finalCwd = captureFinalCwd();
|
|
5117
5135
|
doResolve({
|
|
5118
5136
|
success,
|
|
5119
5137
|
output: stdout + (stderr && success ? `
|
|
@@ -5122,6 +5140,9 @@ ${stderr}` : ""),
|
|
|
5122
5140
|
error: success ? void 0 : stderr || `Exit code ${code8}`,
|
|
5123
5141
|
llmContent: this.formatShellTranscript({
|
|
5124
5142
|
command,
|
|
5143
|
+
cwdBefore,
|
|
5144
|
+
cwdAfter: finalCwd,
|
|
5145
|
+
nextCwd: this.currentCwd,
|
|
5125
5146
|
exitCode: code8,
|
|
5126
5147
|
stdout,
|
|
5127
5148
|
stderr,
|
|
@@ -5131,12 +5152,16 @@ ${stderr}` : ""),
|
|
|
5131
5152
|
});
|
|
5132
5153
|
});
|
|
5133
5154
|
child.on("error", (err) => {
|
|
5155
|
+
const finalCwd = captureFinalCwd();
|
|
5134
5156
|
doResolve({
|
|
5135
5157
|
success: false,
|
|
5136
5158
|
output: stdout,
|
|
5137
5159
|
error: err.message,
|
|
5138
5160
|
llmContent: this.formatShellTranscript({
|
|
5139
5161
|
command,
|
|
5162
|
+
cwdBefore,
|
|
5163
|
+
cwdAfter: finalCwd,
|
|
5164
|
+
nextCwd: this.currentCwd,
|
|
5140
5165
|
stdout,
|
|
5141
5166
|
stderr,
|
|
5142
5167
|
error: err.message
|
|
@@ -16742,6 +16767,20 @@ function clamp01Local(x) {
|
|
|
16742
16767
|
return 1;
|
|
16743
16768
|
return x;
|
|
16744
16769
|
}
|
|
16770
|
+
function stableJson2(value2) {
|
|
16771
|
+
if (value2 === null || typeof value2 !== "object") {
|
|
16772
|
+
return JSON.stringify(value2);
|
|
16773
|
+
}
|
|
16774
|
+
if (Array.isArray(value2)) {
|
|
16775
|
+
return `[${value2.map((item) => stableJson2(item)).join(",")}]`;
|
|
16776
|
+
}
|
|
16777
|
+
const entries = Object.entries(value2).filter(([, v]) => v !== void 0).sort(([a2], [b]) => a2.localeCompare(b));
|
|
16778
|
+
return `{${entries.map(([k, v]) => `${JSON.stringify(k)}:${stableJson2(v)}`).join(",")}}`;
|
|
16779
|
+
}
|
|
16780
|
+
function episodeIdentityHash(ep) {
|
|
16781
|
+
const identity3 = ep.metadata ? `${ep.content}\0metadata:${stableJson2(ep.metadata)}` : ep.content;
|
|
16782
|
+
return createHash8("sha256").update(identity3).digest("hex").slice(0, 16);
|
|
16783
|
+
}
|
|
16745
16784
|
function sanitizeImportance(raw, fallback = 5) {
|
|
16746
16785
|
if (typeof raw !== "number" || !Number.isFinite(raw))
|
|
16747
16786
|
return fallback;
|
|
@@ -16926,7 +16965,7 @@ var init_episodeStore = __esm({
|
|
|
16926
16965
|
insert(ep) {
|
|
16927
16966
|
const id = randomUUID10();
|
|
16928
16967
|
const now2 = Date.now();
|
|
16929
|
-
const contentHash2 =
|
|
16968
|
+
const contentHash2 = episodeIdentityHash(ep);
|
|
16930
16969
|
const modality = ep.modality ?? "text";
|
|
16931
16970
|
const rawImportance = ep.importance ?? autoImportance(ep.toolName ?? null, modality, ep.content);
|
|
16932
16971
|
const modulated = ep.emotionalState ? modulateImportance(sanitizeImportance(rawImportance), ep.emotionalState) : sanitizeImportance(rawImportance);
|
|
@@ -16935,7 +16974,11 @@ var init_episodeStore = __esm({
|
|
|
16935
16974
|
return "";
|
|
16936
16975
|
}
|
|
16937
16976
|
const decayClass = ep.decayClass ?? autoDecayClass(ep.toolName ?? null, modality, ep.content);
|
|
16938
|
-
const existing = this.db.prepare(
|
|
16977
|
+
const existing = this.db.prepare(`SELECT id FROM episodes
|
|
16978
|
+
WHERE content_hash = ?
|
|
16979
|
+
AND COALESCE(session_id, '') = COALESCE(?, '')
|
|
16980
|
+
AND COALESCE(tool_name, '') = COALESCE(?, '')
|
|
16981
|
+
LIMIT 1`).get(contentHash2, ep.sessionId ?? null, ep.toolName ?? null);
|
|
16939
16982
|
if (existing)
|
|
16940
16983
|
return existing.id;
|
|
16941
16984
|
this.db.prepare(`
|
|
@@ -37611,12 +37654,12 @@ function catalogAdaptersDir() {
|
|
|
37611
37654
|
function nowIso() {
|
|
37612
37655
|
return (/* @__PURE__ */ new Date()).toISOString();
|
|
37613
37656
|
}
|
|
37614
|
-
function
|
|
37657
|
+
function stableJson3(value2) {
|
|
37615
37658
|
if (Array.isArray(value2))
|
|
37616
|
-
return `[${value2.map(
|
|
37659
|
+
return `[${value2.map(stableJson3).join(",")}]`;
|
|
37617
37660
|
if (value2 && typeof value2 === "object") {
|
|
37618
37661
|
const obj = value2;
|
|
37619
|
-
return `{${Object.keys(obj).sort().map((key) => `${JSON.stringify(key)}:${
|
|
37662
|
+
return `{${Object.keys(obj).sort().map((key) => `${JSON.stringify(key)}:${stableJson3(obj[key])}`).join(",")}}`;
|
|
37620
37663
|
}
|
|
37621
37664
|
return JSON.stringify(value2);
|
|
37622
37665
|
}
|
|
@@ -37996,7 +38039,7 @@ function builtInMediaModelSpec(seed) {
|
|
|
37996
38039
|
evidence: seed.evidence
|
|
37997
38040
|
}
|
|
37998
38041
|
};
|
|
37999
|
-
spec.provenance.contentHash = sha256(
|
|
38042
|
+
spec.provenance.contentHash = sha256(stableJson3({ ...spec, provenance: { ...spec.provenance, contentHash: void 0 } }));
|
|
38000
38043
|
return spec;
|
|
38001
38044
|
}
|
|
38002
38045
|
function builtInMediaModelCatalog() {
|
|
@@ -38148,7 +38191,7 @@ function draftMediaModelAdapter(args) {
|
|
|
38148
38191
|
dependencies: ["torch", "transformers", "diffusers", "accelerate", "safetensors"]
|
|
38149
38192
|
};
|
|
38150
38193
|
}
|
|
38151
|
-
spec.provenance.contentHash = sha256(
|
|
38194
|
+
spec.provenance.contentHash = sha256(stableJson3({ ...spec, provenance: { ...spec.provenance, contentHash: void 0 } }));
|
|
38152
38195
|
return spec;
|
|
38153
38196
|
}
|
|
38154
38197
|
function validateMediaModelAdapter(spec) {
|
|
@@ -38312,7 +38355,7 @@ function saveMediaModelAdapter(spec) {
|
|
|
38312
38355
|
contentHash: void 0
|
|
38313
38356
|
}
|
|
38314
38357
|
};
|
|
38315
|
-
updated.provenance.contentHash = sha256(
|
|
38358
|
+
updated.provenance.contentHash = sha256(stableJson3(updated));
|
|
38316
38359
|
const json = `${JSON.stringify(updated, null, 2)}
|
|
38317
38360
|
`;
|
|
38318
38361
|
const path12 = specPathFor(updated.id);
|
|
@@ -41699,7 +41742,39 @@ function bwrapAvailable() {
|
|
|
41699
41742
|
if (_bwrapAvailable !== null)
|
|
41700
41743
|
return _bwrapAvailable;
|
|
41701
41744
|
try {
|
|
41702
|
-
const r2 = spawnSync5("bwrap", [
|
|
41745
|
+
const r2 = spawnSync5("bwrap", [
|
|
41746
|
+
"--unshare-all",
|
|
41747
|
+
"--die-with-parent",
|
|
41748
|
+
"--new-session",
|
|
41749
|
+
"--ro-bind-try",
|
|
41750
|
+
"/usr",
|
|
41751
|
+
"/usr",
|
|
41752
|
+
"--ro-bind-try",
|
|
41753
|
+
"/bin",
|
|
41754
|
+
"/bin",
|
|
41755
|
+
"--ro-bind-try",
|
|
41756
|
+
"/lib",
|
|
41757
|
+
"/lib",
|
|
41758
|
+
"--ro-bind-try",
|
|
41759
|
+
"/lib64",
|
|
41760
|
+
"/lib64",
|
|
41761
|
+
"--proc",
|
|
41762
|
+
"/proc",
|
|
41763
|
+
"--tmpfs",
|
|
41764
|
+
"/tmp",
|
|
41765
|
+
"--chdir",
|
|
41766
|
+
"/tmp",
|
|
41767
|
+
"--clearenv",
|
|
41768
|
+
"--setenv",
|
|
41769
|
+
"PATH",
|
|
41770
|
+
"/usr/bin:/bin",
|
|
41771
|
+
"--",
|
|
41772
|
+
"python3",
|
|
41773
|
+
"-I",
|
|
41774
|
+
"-S",
|
|
41775
|
+
"-c",
|
|
41776
|
+
"print(1)"
|
|
41777
|
+
], { timeout: 4e3 });
|
|
41703
41778
|
_bwrapAvailable = r2.status === 0;
|
|
41704
41779
|
} catch {
|
|
41705
41780
|
_bwrapAvailable = false;
|
|
@@ -289916,7 +289991,8 @@ async function saveStore(workingDir, store2) {
|
|
|
289916
289991
|
await writeFile22(join62(dir, "tasks.json"), JSON.stringify(store2, null, 2), "utf-8");
|
|
289917
289992
|
}
|
|
289918
289993
|
function globalStoreDir() {
|
|
289919
|
-
|
|
289994
|
+
const home = process.env["OMNIUS_HOME"]?.trim() || join62(homedir14(), ".omnius");
|
|
289995
|
+
return join62(home, "scheduled");
|
|
289920
289996
|
}
|
|
289921
289997
|
async function loadGlobalStore() {
|
|
289922
289998
|
try {
|
|
@@ -295009,6 +295085,9 @@ import { existsSync as existsSync56, readFileSync as readFileSync40, writeFileSy
|
|
|
295009
295085
|
import { join as join69 } from "node:path";
|
|
295010
295086
|
import { homedir as homedir16 } from "node:os";
|
|
295011
295087
|
import { randomBytes as randomBytes17 } from "node:crypto";
|
|
295088
|
+
function canonicalTodoContent(content) {
|
|
295089
|
+
return content.trim().replace(/\s+/g, " ").toLowerCase();
|
|
295090
|
+
}
|
|
295012
295091
|
function setTodoEventPublisher(pub) {
|
|
295013
295092
|
_eventPublisher = pub;
|
|
295014
295093
|
}
|
|
@@ -295042,19 +295121,48 @@ function writeTodos(sessionId, incoming) {
|
|
|
295042
295121
|
mkdirSync31(todoDir(), { recursive: true });
|
|
295043
295122
|
const old = readTodos(sessionId);
|
|
295044
295123
|
const oldById = new Map(old.map((t2) => [t2.id, t2]));
|
|
295124
|
+
const oldByContent = /* @__PURE__ */ new Map();
|
|
295125
|
+
for (const todo of old) {
|
|
295126
|
+
const key = canonicalTodoContent(todo.content);
|
|
295127
|
+
const bucket = oldByContent.get(key) ?? [];
|
|
295128
|
+
bucket.push(todo);
|
|
295129
|
+
oldByContent.set(key, bucket);
|
|
295130
|
+
}
|
|
295131
|
+
const usedOldIds = /* @__PURE__ */ new Set();
|
|
295132
|
+
const idAliases = /* @__PURE__ */ new Map();
|
|
295133
|
+
const indexAliases = /* @__PURE__ */ new Map();
|
|
295134
|
+
for (const [index, incomingTodo] of incoming.entries()) {
|
|
295135
|
+
const requestedId = incomingTodo.id;
|
|
295136
|
+
if (requestedId && oldById.has(requestedId)) {
|
|
295137
|
+
usedOldIds.add(requestedId);
|
|
295138
|
+
continue;
|
|
295139
|
+
}
|
|
295140
|
+
const matches = oldByContent.get(canonicalTodoContent(incomingTodo.content)) ?? [];
|
|
295141
|
+
const match = matches.find((todo) => !usedOldIds.has(todo.id));
|
|
295142
|
+
if (!match)
|
|
295143
|
+
continue;
|
|
295144
|
+
usedOldIds.add(match.id);
|
|
295145
|
+
indexAliases.set(index, match.id);
|
|
295146
|
+
if (requestedId && requestedId !== match.id)
|
|
295147
|
+
idAliases.set(requestedId, match.id);
|
|
295148
|
+
}
|
|
295045
295149
|
const now2 = Date.now();
|
|
295046
|
-
const newTodos = incoming.map((t2) => {
|
|
295047
|
-
const
|
|
295150
|
+
const newTodos = incoming.map((t2, index) => {
|
|
295151
|
+
const requestedId = t2.id || `todo-${randomBytes17(4).toString("hex")}`;
|
|
295152
|
+
const id = indexAliases.get(index) ?? idAliases.get(requestedId) ?? requestedId;
|
|
295048
295153
|
const existing = oldById.get(id);
|
|
295154
|
+
const requestedParentId = t2.parentId ? idAliases.get(t2.parentId) ?? t2.parentId : void 0;
|
|
295155
|
+
const requestedStatus = t2.status;
|
|
295156
|
+
const status = existing?.status === "completed" && (requestedStatus === "pending" || requestedStatus === "in_progress") && !t2.blocker ? "completed" : requestedStatus;
|
|
295049
295157
|
const next = {
|
|
295050
295158
|
id,
|
|
295051
295159
|
content: t2.content,
|
|
295052
|
-
status
|
|
295053
|
-
parentId:
|
|
295054
|
-
blocker: t2.blocker ?? (
|
|
295160
|
+
status,
|
|
295161
|
+
parentId: requestedParentId ?? existing?.parentId,
|
|
295162
|
+
blocker: t2.blocker ?? (status === "blocked" ? existing?.blocker : void 0),
|
|
295055
295163
|
createdAt: existing?.createdAt ?? now2,
|
|
295056
295164
|
updatedAt: now2,
|
|
295057
|
-
completedAt:
|
|
295165
|
+
completedAt: status === "completed" ? existing?.completedAt ?? now2 : void 0,
|
|
295058
295166
|
verifyCommand: t2.verifyCommand ?? existing?.verifyCommand,
|
|
295059
295167
|
// REG-37
|
|
295060
295168
|
declaredArtifacts: t2.declaredArtifacts ?? existing?.declaredArtifacts
|
|
@@ -549192,7 +549300,7 @@ var init_agent_tool = __esm({
|
|
|
549192
549300
|
});
|
|
549193
549301
|
return {
|
|
549194
549302
|
success: true,
|
|
549195
|
-
output: `Agent spawned (subprocess, worktree): ${agentId}
|
|
549303
|
+
output: `Agent spawned (background subprocess, worktree): ${agentId}
|
|
549196
549304
|
Type: ${subagentType}
|
|
549197
549305
|
PID: ${spawn35.pid}
|
|
549198
549306
|
Task: ${prompt.slice(0, 100)}
|
|
@@ -552173,6 +552281,22 @@ function deduplicateFrames(frames) {
|
|
|
552173
552281
|
}
|
|
552174
552282
|
return frames;
|
|
552175
552283
|
}
|
|
552284
|
+
function normalizeFrameDescriptionForVideo(raw) {
|
|
552285
|
+
let text2 = raw.replace(/\s+/g, " ").trim();
|
|
552286
|
+
const answerMatch = text2.match(/\bA:\s*([\s\S]*?)(?:\s+Image:|$)/);
|
|
552287
|
+
if (answerMatch?.[1])
|
|
552288
|
+
text2 = answerMatch[1].replace(/\s+/g, " ").trim();
|
|
552289
|
+
if (!text2)
|
|
552290
|
+
return null;
|
|
552291
|
+
if (/\[IMAGE_BASE64:|data:image\/|base64/i.test(text2))
|
|
552292
|
+
return null;
|
|
552293
|
+
if (/^\s*(?:ids?|coords?|points?)\s*=\s*\[[\d\s,.[\]-]+\]\s*$/i.test(text2))
|
|
552294
|
+
return null;
|
|
552295
|
+
const letters = text2.match(/[A-Za-z]/g)?.length ?? 0;
|
|
552296
|
+
if (text2.length < 12 || letters < 4)
|
|
552297
|
+
return null;
|
|
552298
|
+
return text2.slice(0, 700);
|
|
552299
|
+
}
|
|
552176
552300
|
function formatTime2(seconds) {
|
|
552177
552301
|
const m2 = Math.floor(seconds / 60);
|
|
552178
552302
|
const s2 = Math.floor(seconds % 60);
|
|
@@ -552221,9 +552345,9 @@ var init_video_understand = __esm({
|
|
|
552221
552345
|
prompt: "Describe only the visible scene in this video frame. Note subject identity/type, pose, motion cues, contacts with the ground, and visible text if present. Do not mention file metadata, base64, data URIs, or this prompt.",
|
|
552222
552346
|
length: "normal"
|
|
552223
552347
|
});
|
|
552224
|
-
const output = String(result.llmContent || result.output || "")
|
|
552225
|
-
if (result.success && output
|
|
552226
|
-
frame.description = output
|
|
552348
|
+
const output = normalizeFrameDescriptionForVideo(String(result.llmContent || result.output || ""));
|
|
552349
|
+
if (result.success && output)
|
|
552350
|
+
frame.description = output;
|
|
552227
552351
|
} catch {
|
|
552228
552352
|
}
|
|
552229
552353
|
}
|
|
@@ -555078,26 +555202,34 @@ var init_VllmBackend = __esm({
|
|
|
555078
555202
|
const url = `${this.baseUrl}/health`;
|
|
555079
555203
|
const controller = new AbortController();
|
|
555080
555204
|
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
555081
|
-
|
|
555082
|
-
|
|
555083
|
-
|
|
555084
|
-
|
|
555085
|
-
|
|
555086
|
-
|
|
555087
|
-
|
|
555088
|
-
|
|
555089
|
-
|
|
555090
|
-
|
|
555091
|
-
|
|
555092
|
-
|
|
555093
|
-
|
|
555094
|
-
|
|
555095
|
-
|
|
555205
|
+
let healthy = false;
|
|
555206
|
+
try {
|
|
555207
|
+
const maxRetries = Math.max(0, this.maxRetries);
|
|
555208
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
555209
|
+
if (attempt > 0) {
|
|
555210
|
+
const backoff = Math.min(1e3 * Math.pow(2, attempt - 1), 4e3);
|
|
555211
|
+
await new Promise((r2) => setTimeout(r2, backoff));
|
|
555212
|
+
}
|
|
555213
|
+
try {
|
|
555214
|
+
const response = await fetch(url, {
|
|
555215
|
+
method: "GET",
|
|
555216
|
+
signal: controller.signal,
|
|
555217
|
+
headers: this.authHeaders()
|
|
555218
|
+
});
|
|
555219
|
+
if (response.ok) {
|
|
555220
|
+
healthy = true;
|
|
555221
|
+
break;
|
|
555222
|
+
}
|
|
555223
|
+
} catch {
|
|
555096
555224
|
}
|
|
555097
|
-
} catch {
|
|
555098
555225
|
}
|
|
555226
|
+
} finally {
|
|
555227
|
+
clearTimeout(timer);
|
|
555228
|
+
}
|
|
555229
|
+
if (healthy) {
|
|
555230
|
+
this.consecutiveFailures = 0;
|
|
555231
|
+
return true;
|
|
555099
555232
|
}
|
|
555100
|
-
clearTimeout(timer);
|
|
555101
555233
|
this.consecutiveFailures++;
|
|
555102
555234
|
if (this.consecutiveFailures >= 3) {
|
|
555103
555235
|
this.degradedUntil = Date.now() + 3e4;
|
|
@@ -555291,25 +555423,33 @@ var init_OllamaBackend = __esm({
|
|
|
555291
555423
|
const url = `${this.baseUrl}/api/tags`;
|
|
555292
555424
|
const controller = new AbortController();
|
|
555293
555425
|
const timer = setTimeout(() => controller.abort(), 5e3);
|
|
555294
|
-
|
|
555295
|
-
|
|
555296
|
-
|
|
555297
|
-
|
|
555298
|
-
|
|
555299
|
-
|
|
555300
|
-
|
|
555301
|
-
|
|
555302
|
-
|
|
555303
|
-
|
|
555304
|
-
|
|
555305
|
-
|
|
555306
|
-
|
|
555307
|
-
|
|
555426
|
+
let healthy = false;
|
|
555427
|
+
try {
|
|
555428
|
+
const maxRetries = Math.max(0, this.maxRetries);
|
|
555429
|
+
for (let attempt = 0; attempt <= maxRetries; attempt++) {
|
|
555430
|
+
if (attempt > 0) {
|
|
555431
|
+
const backoff = Math.min(1e3 * Math.pow(2, attempt - 1), 4e3);
|
|
555432
|
+
await new Promise((r2) => setTimeout(r2, backoff));
|
|
555433
|
+
}
|
|
555434
|
+
try {
|
|
555435
|
+
const response = await fetch(url, {
|
|
555436
|
+
method: "GET",
|
|
555437
|
+
signal: controller.signal
|
|
555438
|
+
});
|
|
555439
|
+
if (response.ok) {
|
|
555440
|
+
healthy = true;
|
|
555441
|
+
break;
|
|
555442
|
+
}
|
|
555443
|
+
} catch {
|
|
555308
555444
|
}
|
|
555309
|
-
} catch {
|
|
555310
555445
|
}
|
|
555446
|
+
} finally {
|
|
555447
|
+
clearTimeout(timer);
|
|
555448
|
+
}
|
|
555449
|
+
if (healthy) {
|
|
555450
|
+
this.consecutiveFailures = 0;
|
|
555451
|
+
return true;
|
|
555311
555452
|
}
|
|
555312
|
-
clearTimeout(timer);
|
|
555313
555453
|
this.consecutiveFailures++;
|
|
555314
555454
|
if (this.consecutiveFailures >= 3) {
|
|
555315
555455
|
this.degradedUntil = Date.now() + 3e4;
|
|
@@ -559114,7 +559254,7 @@ function recordToolEvidence(ledger, input) {
|
|
|
559114
559254
|
input.name,
|
|
559115
559255
|
input.success === true ? "succeeded" : input.success === false ? "failed" : "observed",
|
|
559116
559256
|
input.argsKey ? `args=${cleanText(input.argsKey, 180)}` : "",
|
|
559117
|
-
input.outputPreview ? `output=${cleanText(input.outputPreview,
|
|
559257
|
+
input.outputPreview ? `output=${cleanText(input.outputPreview, 1200)}` : ""
|
|
559118
559258
|
].filter(Boolean).join(" ");
|
|
559119
559259
|
return recordCompletionEvidence(ledger, {
|
|
559120
559260
|
kind: "tool_result",
|
|
@@ -559623,7 +559763,13 @@ var init_completionAutoFinalize = __esm({
|
|
|
559623
559763
|
|
|
559624
559764
|
// packages/orchestrator/dist/verificationCommand.js
|
|
559625
559765
|
function normalizeShellCommand(command) {
|
|
559626
|
-
|
|
559766
|
+
let normalized = command.replace(/\s+/g, " ").trim();
|
|
559767
|
+
let previous = "";
|
|
559768
|
+
while (previous !== normalized) {
|
|
559769
|
+
previous = normalized;
|
|
559770
|
+
normalized = normalized.replace(/\s+(?:[12]?>&[12]|[12]?>\s*['"]?\/dev\/null['"]?)$/i, "").trim();
|
|
559771
|
+
}
|
|
559772
|
+
return normalized;
|
|
559627
559773
|
}
|
|
559628
559774
|
function splitConjunctiveVerifyCommand(command) {
|
|
559629
559775
|
return normalizeShellCommand(command).split(/\s+&&\s+/).map((part) => part.trim()).filter(Boolean);
|
|
@@ -569421,7 +569567,7 @@ var init_resolution_memory = __esm({
|
|
|
569421
569567
|
/** Load prior fixes (cross-session). */
|
|
569422
569568
|
loadFixes(fixes) {
|
|
569423
569569
|
for (const f2 of fixes) {
|
|
569424
|
-
if (Array.isArray(f2.from) && Array.isArray(f2.to) && f2.from.length > 0) {
|
|
569570
|
+
if (Array.isArray(f2.from) && Array.isArray(f2.to) && f2.from.length > 0 && !isPathSensitiveFix(f2)) {
|
|
569425
569571
|
this.fixes.push(f2);
|
|
569426
569572
|
}
|
|
569427
569573
|
}
|
|
@@ -569470,6 +569616,10 @@ var init_resolution_memory = __esm({
|
|
|
569470
569616
|
const delta = computeDelta(fail3.tokens, workedTokens);
|
|
569471
569617
|
if (!delta)
|
|
569472
569618
|
continue;
|
|
569619
|
+
if (isPathSensitiveFix(delta)) {
|
|
569620
|
+
this.recentFailures.splice(i2, 1);
|
|
569621
|
+
return null;
|
|
569622
|
+
}
|
|
569473
569623
|
const existing = this.fixes.find((f2) => sameFix(f2, delta.from, delta.to, fail3.errorKey));
|
|
569474
569624
|
if (existing) {
|
|
569475
569625
|
existing.count++;
|
|
@@ -569506,6 +569656,8 @@ var init_resolution_memory = __esm({
|
|
|
569506
569656
|
const tokens = new Set(tokenize6(command));
|
|
569507
569657
|
let best = null;
|
|
569508
569658
|
for (const f2 of this.fixes) {
|
|
569659
|
+
if (isPathSensitiveFix(f2))
|
|
569660
|
+
continue;
|
|
569509
569661
|
if (f2.from.every((t2) => tokens.has(t2))) {
|
|
569510
569662
|
if (!best || f2.count > best.count)
|
|
569511
569663
|
best = f2;
|
|
@@ -572051,7 +572203,7 @@ ${parts.join("\n")}
|
|
|
572051
572203
|
/** State root for runner-owned memory/artifacts. Defaults to cwd/.omnius. */
|
|
572052
572204
|
omniusStateDir() {
|
|
572053
572205
|
const configured = (this.options.stateDir || "").trim();
|
|
572054
|
-
return configured ? _pathResolve(configured) : _pathJoin(
|
|
572206
|
+
return configured ? _pathResolve(configured) : _pathJoin(this.authoritativeWorkingDirectory(), ".omnius");
|
|
572055
572207
|
}
|
|
572056
572208
|
writesUserTaskArtifacts() {
|
|
572057
572209
|
return this.options.artifactMode === "user-task" && !this.options.subAgent;
|
|
@@ -572178,7 +572330,7 @@ ${parts.join("\n")}
|
|
|
572178
572330
|
}
|
|
572179
572331
|
} catch {
|
|
572180
572332
|
}
|
|
572181
|
-
if (selected.size === 0) {
|
|
572333
|
+
if (selected.size === 0 && process.env["OMNIUS_FAILURE_PATTERN_INFERENCE"] === "1") {
|
|
572182
572334
|
const relevant = await this._inferRelevantFailurePatternSignatures(taskGoal, candidates, maxPatterns);
|
|
572183
572335
|
for (const signature of relevant) {
|
|
572184
572336
|
const raw = this._errorPatterns.get(signature);
|
|
@@ -573098,7 +573250,7 @@ Pick the SMALLEST concrete deliverable from the spec — typically the project e
|
|
|
573098
573250
|
if (process.env["OMNIUS_DISABLE_REG66"] === "1")
|
|
573099
573251
|
return { detected: false };
|
|
573100
573252
|
const WINDOW = 20;
|
|
573101
|
-
const SHELL_REPEAT_THRESHOLD =
|
|
573253
|
+
const SHELL_REPEAT_THRESHOLD = 3;
|
|
573102
573254
|
const READ_REPEAT_THRESHOLD = 4;
|
|
573103
573255
|
const window2 = toolCallLog.slice(-WINDOW);
|
|
573104
573256
|
if (window2.length < SHELL_REPEAT_THRESHOLD)
|
|
@@ -573225,13 +573377,85 @@ Pick the SMALLEST concrete deliverable from the spec — typically the project e
|
|
|
573225
573377
|
return false;
|
|
573226
573378
|
return true;
|
|
573227
573379
|
}
|
|
573228
|
-
_toolEvidencePreview(result, displayOutput, max = 500) {
|
|
573380
|
+
_toolEvidencePreview(result, displayOutput, max = 500, toolName) {
|
|
573229
573381
|
const modelVisible = result.llmContent ?? result.output ?? displayOutput ?? "";
|
|
573230
573382
|
const failurePrefix = result.success === false && result.error ? `Error: ${result.error}` : "";
|
|
573231
573383
|
const combined = failurePrefix && modelVisible && !String(modelVisible).startsWith(failurePrefix) ? `${failurePrefix}
|
|
573232
573384
|
${modelVisible}` : modelVisible || result.error || displayOutput || "";
|
|
573385
|
+
const structured = this._structuredMediaEvidencePreview(toolName, String(combined));
|
|
573386
|
+
if (structured)
|
|
573387
|
+
return structured.slice(0, Math.max(max, 1200));
|
|
573233
573388
|
return String(combined).slice(0, max);
|
|
573234
573389
|
}
|
|
573390
|
+
_structuredMediaEvidencePreview(toolName, text2) {
|
|
573391
|
+
if (!toolName || !text2)
|
|
573392
|
+
return null;
|
|
573393
|
+
if (toolName !== "audio_analyze" && toolName !== "video_understand") {
|
|
573394
|
+
return null;
|
|
573395
|
+
}
|
|
573396
|
+
const lines = text2.replace(/\r/g, "").split("\n").map((line) => line.trim()).filter(Boolean);
|
|
573397
|
+
if (lines.length === 0)
|
|
573398
|
+
return null;
|
|
573399
|
+
if (toolName === "audio_analyze") {
|
|
573400
|
+
const kept2 = [];
|
|
573401
|
+
const answer = [];
|
|
573402
|
+
let inAnswer = false;
|
|
573403
|
+
for (const line of lines) {
|
|
573404
|
+
if (line.startsWith("# Audio comprehension:") || line.startsWith("duration ") || line.startsWith("roles:") || line.startsWith("quality:") || /^- (?:mean volume|max volume|silence|active audio windows):/i.test(line)) {
|
|
573405
|
+
kept2.push(line);
|
|
573406
|
+
continue;
|
|
573407
|
+
}
|
|
573408
|
+
if (line === "## Grounded Answer") {
|
|
573409
|
+
inAnswer = true;
|
|
573410
|
+
continue;
|
|
573411
|
+
}
|
|
573412
|
+
if (inAnswer && line.startsWith("## ")) {
|
|
573413
|
+
inAnswer = false;
|
|
573414
|
+
} else if (inAnswer && answer.length < 3) {
|
|
573415
|
+
answer.push(line);
|
|
573416
|
+
}
|
|
573417
|
+
}
|
|
573418
|
+
if (answer.length > 0)
|
|
573419
|
+
kept2.push(`grounded_answer=${answer.join(" ")}`);
|
|
573420
|
+
return kept2.length > 0 ? kept2.join(" | ") : null;
|
|
573421
|
+
}
|
|
573422
|
+
const kept = [];
|
|
573423
|
+
let inAudio = false;
|
|
573424
|
+
let audioLines = 0;
|
|
573425
|
+
let frameLines = 0;
|
|
573426
|
+
for (const line of lines) {
|
|
573427
|
+
if (line.startsWith("# Video Analysis") || line.startsWith("Source:") || line.startsWith("Duration:")) {
|
|
573428
|
+
kept.push(line);
|
|
573429
|
+
continue;
|
|
573430
|
+
}
|
|
573431
|
+
if (line === "## Audio Comprehension") {
|
|
573432
|
+
kept.push("Audio Comprehension: present");
|
|
573433
|
+
inAudio = true;
|
|
573434
|
+
audioLines = 0;
|
|
573435
|
+
continue;
|
|
573436
|
+
}
|
|
573437
|
+
if (line.startsWith("## Frames")) {
|
|
573438
|
+
kept.push(line);
|
|
573439
|
+
inAudio = false;
|
|
573440
|
+
frameLines = 0;
|
|
573441
|
+
continue;
|
|
573442
|
+
}
|
|
573443
|
+
if (line.startsWith("## ")) {
|
|
573444
|
+
inAudio = false;
|
|
573445
|
+
continue;
|
|
573446
|
+
}
|
|
573447
|
+
if (inAudio && audioLines < 8 && (line.startsWith("# Audio comprehension:") || line.startsWith("duration ") || line.startsWith("roles:") || line.startsWith("quality:") || /^- (?:mean volume|max volume|silence|active audio windows):/i.test(line))) {
|
|
573448
|
+
kept.push(line);
|
|
573449
|
+
audioLines++;
|
|
573450
|
+
continue;
|
|
573451
|
+
}
|
|
573452
|
+
if (/^\[[0-9:.]+\]\s+/.test(line) && frameLines < 3) {
|
|
573453
|
+
kept.push(line);
|
|
573454
|
+
frameLines++;
|
|
573455
|
+
}
|
|
573456
|
+
}
|
|
573457
|
+
return kept.length > 0 ? kept.join(" | ") : null;
|
|
573458
|
+
}
|
|
573235
573459
|
_recordCompletionToolEvidenceFromResult(input) {
|
|
573236
573460
|
if (!this._completionLedger || input.toolName === "task_complete")
|
|
573237
573461
|
return;
|
|
@@ -573241,7 +573465,7 @@ ${modelVisible}` : modelVisible || result.error || displayOutput || "";
|
|
|
573241
573465
|
this._completionLedger = recordToolEvidence(this._completionLedger, {
|
|
573242
573466
|
name: input.toolName,
|
|
573243
573467
|
success: input.result.success,
|
|
573244
|
-
outputPreview: (input.outputPreview ?? this._toolEvidencePreview(input.result)).toString().slice(0, 500),
|
|
573468
|
+
outputPreview: (input.outputPreview ?? this._toolEvidencePreview(input.result, void 0, 1200, input.toolName)).toString().slice(0, input.toolName === "audio_analyze" || input.toolName === "video_understand" ? 1200 : 500),
|
|
573245
573469
|
argsKey: input.argsKey.slice(0, 300),
|
|
573246
573470
|
targetPaths: attemptedTargetPaths
|
|
573247
573471
|
});
|
|
@@ -573784,6 +574008,18 @@ ${shellLines.join("\n")}` : "Commands run: none"
|
|
|
573784
574008
|
const failCount = toolCallLog.filter((e2) => e2.success === false).length;
|
|
573785
574009
|
evidenceParts.push(`Failed tool calls this run: ${failCount}`);
|
|
573786
574010
|
const evidenceDigest = evidenceParts.join("\n");
|
|
574011
|
+
const hasFileAction = toolCallLog.some((e2) => e2.mutated || e2.name === "file_write" || e2.name === "file_edit" || e2.name === "batch_edit" || e2.name === "file_patch");
|
|
574012
|
+
if (!hasFileAction && failCount === 0) {
|
|
574013
|
+
const summaryNorm = proposedSummary.replace(/\s+/g, " ");
|
|
574014
|
+
const supportedByShellOutput = toolCallLog.filter((e2) => e2.name === "shell" && e2.success === true).some((e2) => {
|
|
574015
|
+
const output = String(e2.outputPreview ?? "").trim().replace(/\s+/g, " ");
|
|
574016
|
+
if (output.length < 8)
|
|
574017
|
+
return false;
|
|
574018
|
+
return summaryNorm.includes(output.slice(0, Math.min(output.length, 120)));
|
|
574019
|
+
});
|
|
574020
|
+
if (supportedByShellOutput)
|
|
574021
|
+
return { proceed: true };
|
|
574022
|
+
}
|
|
573787
574023
|
const degraded = failCount > 0 ? await this._inferExplicitDegradedCompletion({
|
|
573788
574024
|
turn,
|
|
573789
574025
|
originalGoal,
|
|
@@ -580173,7 +580409,10 @@ Corrective action: try a different approach first: read relevant files, adjust a
|
|
|
580173
580409
|
"background_run"
|
|
580174
580410
|
]);
|
|
580175
580411
|
if (this._reg61PerpetualGateActive && !REG61_BYPASS_TOOLS.has(tc.name) && process.env["OMNIUS_DISABLE_REG61_COERCE"] !== "1") {
|
|
580176
|
-
const _dbgLoop = this._detectDebugLoop(
|
|
580412
|
+
const _dbgLoop = this._detectDebugLoop([
|
|
580413
|
+
...toolCallLog,
|
|
580414
|
+
{ name: tc.name, argsKey }
|
|
580415
|
+
]);
|
|
580177
580416
|
const _debugLoopSampleSafe = (_dbgLoop.repeatedSample ?? "").slice(0, 120);
|
|
580178
580417
|
const _localFailureNudge = this._renderLocalFailureNudge(turn);
|
|
580179
580418
|
const reg61SteerMsg = _dbgLoop.detected ? [
|
|
@@ -580463,11 +580702,12 @@ Use the saved fact to continue the promised synthesis or next concrete step, or
|
|
|
580463
580702
|
if (repeatGateEligible && _existingFp !== void 0 && _repeatGateMax > 0) {
|
|
580464
580703
|
if (criticDecision.hitNumber >= _repeatGateMax) {
|
|
580465
580704
|
if (isReadLike) {
|
|
580705
|
+
const cachedResult = this.sanitizeCachedToolResult(tc.name, _existingFp.result);
|
|
580466
580706
|
repeatShortCircuit = {
|
|
580467
580707
|
success: true,
|
|
580468
580708
|
output: `[STOP RE-READING — you have requested this exact read ${criticDecision.hitNumber}× and you ALREADY HAVE its full content, shown again below. Do NOT read it again. Act on it: edit the file, run a verification, or call task_complete. If a previous edit failed with "old_string not found", your old_string did not match the file — copy it EXACTLY (including indentation) from the content below.]
|
|
580469
580709
|
|
|
580470
|
-
` +
|
|
580710
|
+
` + cachedResult
|
|
580471
580711
|
};
|
|
580472
580712
|
} else {
|
|
580473
580713
|
repeatShortCircuit = {
|
|
@@ -580477,9 +580717,10 @@ Use the saved fact to continue the promised synthesis or next concrete step, or
|
|
|
580477
580717
|
};
|
|
580478
580718
|
}
|
|
580479
580719
|
} else {
|
|
580720
|
+
const cachedResult = this.sanitizeCachedToolResult(tc.name, _existingFp.result);
|
|
580480
580721
|
repeatShortCircuit = {
|
|
580481
580722
|
success: true,
|
|
580482
|
-
output:
|
|
580723
|
+
output: cachedResult
|
|
580483
580724
|
};
|
|
580484
580725
|
}
|
|
580485
580726
|
}
|
|
@@ -581458,7 +581699,7 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
581458
581699
|
// source files (the "old_string not found" cascade). Large
|
|
581459
581700
|
// files are handled by branch-extract upstream, so 16KB
|
|
581460
581701
|
// here covers ordinary files without bloating the cache.
|
|
581461
|
-
isReadLike ? (result.output ?? "").slice(0, 16e3) : (result.output ?? "").slice(0, 2e3)
|
|
581702
|
+
isReadLike ? this.sanitizeCachedToolResult(tc.name, result.output ?? "").slice(0, 16e3) : (result.output ?? "").slice(0, 2e3)
|
|
581462
581703
|
),
|
|
581463
581704
|
compacted: false
|
|
581464
581705
|
});
|
|
@@ -581750,12 +581991,12 @@ ${bookkeepingGuidance}` : bookkeepingGuidance;
|
|
|
581750
581991
|
currentLogEntry.success = result.success;
|
|
581751
581992
|
currentLogEntry.mutated = realFileMutation;
|
|
581752
581993
|
currentLogEntry.mutatedFiles = realMutationPaths;
|
|
581753
|
-
currentLogEntry.outputPreview = this._toolEvidencePreview(result, output);
|
|
581994
|
+
currentLogEntry.outputPreview = this._toolEvidencePreview(result, output, 1200, tc.name);
|
|
581754
581995
|
}
|
|
581755
581996
|
this._toolEvents.push({
|
|
581756
581997
|
name: tc.name,
|
|
581757
581998
|
success: result.success,
|
|
581758
|
-
outputPreview: (result
|
|
581999
|
+
outputPreview: this._toolEvidencePreview(result, output, 1200, tc.name),
|
|
581759
582000
|
turn
|
|
581760
582001
|
});
|
|
581761
582002
|
if (this._toolEvents.length > 200)
|
|
@@ -582096,7 +582337,7 @@ Then use file_read on individual FILES inside it.`);
|
|
|
582096
582337
|
argsKey: tc.arguments ? JSON.stringify(tc.arguments) : "",
|
|
582097
582338
|
args: tc.arguments,
|
|
582098
582339
|
result,
|
|
582099
|
-
outputPreview: this._toolEvidencePreview(result, output),
|
|
582340
|
+
outputPreview: this._toolEvidencePreview(result, output, 1200, tc.name),
|
|
582100
582341
|
realFileMutation,
|
|
582101
582342
|
realMutationPaths
|
|
582102
582343
|
});
|
|
@@ -583202,7 +583443,7 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
583202
583443
|
bfLogEntry.success = result.success;
|
|
583203
583444
|
bfLogEntry.mutated = bfRealFileMutation;
|
|
583204
583445
|
bfLogEntry.mutatedFiles = bfRealMutationPaths;
|
|
583205
|
-
bfLogEntry.outputPreview = this._toolEvidencePreview(result, output);
|
|
583446
|
+
bfLogEntry.outputPreview = this._toolEvidencePreview(result, output, 1200, tc.name);
|
|
583206
583447
|
}
|
|
583207
583448
|
this.emit({
|
|
583208
583449
|
type: "tool_result",
|
|
@@ -583218,7 +583459,7 @@ Full content available via: repl_exec(code="data = retrieve('${handleId}')") or
|
|
|
583218
583459
|
argsKey: bfArgsKey,
|
|
583219
583460
|
args: tc.arguments,
|
|
583220
583461
|
result,
|
|
583221
|
-
outputPreview: this._toolEvidencePreview(result, output),
|
|
583462
|
+
outputPreview: this._toolEvidencePreview(result, output, 1200, tc.name),
|
|
583222
583463
|
realFileMutation: bfRealFileMutation,
|
|
583223
583464
|
realMutationPaths: bfRealMutationPaths
|
|
583224
583465
|
});
|
|
@@ -584378,6 +584619,16 @@ ${marker}` : marker);
|
|
|
584378
584619
|
}
|
|
584379
584620
|
return hash.toString(16).padStart(8, "0");
|
|
584380
584621
|
}
|
|
584622
|
+
sanitizeCachedToolResult(toolName, output) {
|
|
584623
|
+
let text2 = output;
|
|
584624
|
+
if (text2.includes("[IMAGE_BASE64:")) {
|
|
584625
|
+
text2 = text2.replace(/\[IMAGE_BASE64:[^\]]+\]/g, "[image binary omitted from repeat cache; use the OCR/image analysis text in this result]");
|
|
584626
|
+
}
|
|
584627
|
+
if (toolName === "image_read" && text2.length > 8e3) {
|
|
584628
|
+
text2 = this.foldOutput(text2, 8e3);
|
|
584629
|
+
}
|
|
584630
|
+
return text2;
|
|
584631
|
+
}
|
|
584381
584632
|
/**
|
|
584382
584633
|
* WO-NORMALIZE: Normalize tool output at source.
|
|
584383
584634
|
* Caps output length, persists large results to .omnius/tool-results/ with preview,
|
|
@@ -601304,6 +601555,10 @@ var init_command_registry = __esm({
|
|
|
601304
601555
|
["/memory episodes", "Show recent episodes view"],
|
|
601305
601556
|
["/memory concepts", "Show concept clusters view"],
|
|
601306
601557
|
["/memory timeline", "Show temporal timeline view"],
|
|
601558
|
+
[
|
|
601559
|
+
"/metabolize [--dry-run] [--verbose] [--min-score <n>]",
|
|
601560
|
+
"Run memory metabolism: score and compact stale episode entries"
|
|
601561
|
+
],
|
|
601307
601562
|
["/verbose", "Toggle verbose mode"],
|
|
601308
601563
|
["/clear", "Clear the screen"],
|
|
601309
601564
|
["/help", "Show this help"],
|
|
@@ -601407,6 +601662,7 @@ var init_command_registry = __esm({
|
|
|
601407
601662
|
skillify: "tools",
|
|
601408
601663
|
memory: "memory",
|
|
601409
601664
|
mem: "memory",
|
|
601665
|
+
metabolize: "memory",
|
|
601410
601666
|
mouse: "ui",
|
|
601411
601667
|
color: "ui",
|
|
601412
601668
|
colors: "ui",
|
|
@@ -601453,6 +601709,7 @@ var init_command_registry = __esm({
|
|
|
601453
601709
|
"task-type": ["tasktype", "tt"],
|
|
601454
601710
|
stats: ["dashboard"],
|
|
601455
601711
|
memory: ["mem"],
|
|
601712
|
+
metabolize: ["metab"],
|
|
601456
601713
|
files: ["workspace"],
|
|
601457
601714
|
skills: ["skill"],
|
|
601458
601715
|
commands: ["cmds"],
|
|
@@ -602166,8 +602423,8 @@ function formatTokenCount(t2) {
|
|
|
602166
602423
|
}
|
|
602167
602424
|
function buildMetricsChip(data) {
|
|
602168
602425
|
const parts = [];
|
|
602169
|
-
parts.push(`${data.turns}
|
|
602170
|
-
parts.push(`${data.toolCalls}
|
|
602426
|
+
parts.push(`${data.turns} ${data.turns === 1 ? "turn" : "turns"}`);
|
|
602427
|
+
parts.push(`${data.toolCalls} ${data.toolCalls === 1 ? "call" : "calls"}`);
|
|
602171
602428
|
if (data.tokens && data.durationMs > 0) {
|
|
602172
602429
|
const total = data.tokens.total > 0 ? data.tokens.total : data.tokens.estimated;
|
|
602173
602430
|
if (total > 0) {
|
|
@@ -604960,7 +605217,7 @@ function renderInfo(message2) {
|
|
|
604960
605217
|
breakTelegramCoalesce();
|
|
604961
605218
|
const redir = _contentWriteHook?.redirect?.();
|
|
604962
605219
|
const dim = dimFg();
|
|
604963
|
-
const icon = `${dim}
|
|
605220
|
+
const icon = `${dim}🛈\x1B[0m`;
|
|
604964
605221
|
const prefix = `${icon} ${dim}`;
|
|
604965
605222
|
const lines = wrapLinesWithPrefix(message2, prefix, getTermWidth());
|
|
604966
605223
|
const text2 = `${lines.map((l2) => l2 + "\x1B[0m").join("\n")}
|
|
@@ -611306,6 +611563,27 @@ function watchForOmniusGitignore(repoRoot) {
|
|
|
611306
611563
|
}
|
|
611307
611564
|
if (watchers.length > 0) gitignoreWatchers.set(key, watchers);
|
|
611308
611565
|
}
|
|
611566
|
+
function scheduleOmniusGitignoreRescans(repoRoot) {
|
|
611567
|
+
const key = resolve54(repoRoot);
|
|
611568
|
+
if (gitignoreRetryTimers.has(key)) return;
|
|
611569
|
+
const timers = [25, 100, 250, 500, 1e3].map((delay3) => {
|
|
611570
|
+
const timer = setTimeout(() => {
|
|
611571
|
+
try {
|
|
611572
|
+
ensureOmniusIgnored(repoRoot);
|
|
611573
|
+
} catch {
|
|
611574
|
+
}
|
|
611575
|
+
const list = gitignoreRetryTimers.get(key);
|
|
611576
|
+
if (list) {
|
|
611577
|
+
const idx = list.indexOf(timer);
|
|
611578
|
+
if (idx >= 0) list.splice(idx, 1);
|
|
611579
|
+
if (list.length === 0) gitignoreRetryTimers.delete(key);
|
|
611580
|
+
}
|
|
611581
|
+
}, delay3);
|
|
611582
|
+
timer.unref?.();
|
|
611583
|
+
return timer;
|
|
611584
|
+
});
|
|
611585
|
+
gitignoreRetryTimers.set(key, timers);
|
|
611586
|
+
}
|
|
611309
611587
|
function stopOmniusGitignoreWatcher(repoRoot) {
|
|
611310
611588
|
const keys = repoRoot ? [resolve54(repoRoot)] : Array.from(gitignoreWatchers.keys());
|
|
611311
611589
|
for (const key of keys) {
|
|
@@ -611317,6 +611595,9 @@ function stopOmniusGitignoreWatcher(repoRoot) {
|
|
|
611317
611595
|
}
|
|
611318
611596
|
}
|
|
611319
611597
|
gitignoreWatchers.delete(key);
|
|
611598
|
+
const timers = gitignoreRetryTimers.get(key) ?? [];
|
|
611599
|
+
for (const timer of timers) clearTimeout(timer);
|
|
611600
|
+
gitignoreRetryTimers.delete(key);
|
|
611320
611601
|
}
|
|
611321
611602
|
}
|
|
611322
611603
|
function migrateLegacyDirectories(repoRoot, omniusPath) {
|
|
@@ -611348,6 +611629,10 @@ function initOmniusDirectory(repoRoot) {
|
|
|
611348
611629
|
watchForOmniusGitignore(repoRoot);
|
|
611349
611630
|
} catch {
|
|
611350
611631
|
}
|
|
611632
|
+
try {
|
|
611633
|
+
scheduleOmniusGitignoreRescans(repoRoot);
|
|
611634
|
+
} catch {
|
|
611635
|
+
}
|
|
611351
611636
|
return omniusPath;
|
|
611352
611637
|
}
|
|
611353
611638
|
function hasOmniusDirectory(repoRoot) {
|
|
@@ -612375,7 +612660,7 @@ function deleteUsageRecord(kind, value2, repoRoot) {
|
|
|
612375
612660
|
remove(join126(repoRoot, OMNIUS_DIR, USAGE_HISTORY_FILE));
|
|
612376
612661
|
}
|
|
612377
612662
|
}
|
|
612378
|
-
var OMNIUS_DIR, LEGACY_DIRS, SUBDIRS, gitignoreWatchers, CONTEXT_FILES, PENDING_TASK_FILE, HANDOFF_FILE, CONTEXT_SAVE_FILE, CONTEXT_LEDGER_FILE, MAX_CONTEXT_ENTRIES, MAX_SESSION_DIARY_ENTRIES, MAX_SESSION_DIARY_DETAILED_ENTRIES, MAX_CONTEXT_LEDGER_LINES, MAX_CONTEXT_LEDGER_BYTES, SAME_TASK_REPLACE_WINDOW_MS, LOCK_TIMEOUT_MS, LOCK_RETRY_MS, LOCK_RETRY_MAX, SESSIONS_DIR, SESSIONS_INDEX, SKIP_DIRS3, HOME_SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
612663
|
+
var OMNIUS_DIR, LEGACY_DIRS, SUBDIRS, gitignoreWatchers, gitignoreRetryTimers, CONTEXT_FILES, PENDING_TASK_FILE, HANDOFF_FILE, CONTEXT_SAVE_FILE, CONTEXT_LEDGER_FILE, MAX_CONTEXT_ENTRIES, MAX_SESSION_DIARY_ENTRIES, MAX_SESSION_DIARY_DETAILED_ENTRIES, MAX_CONTEXT_LEDGER_LINES, MAX_CONTEXT_LEDGER_BYTES, SAME_TASK_REPLACE_WINDOW_MS, LOCK_TIMEOUT_MS, LOCK_RETRY_MS, LOCK_RETRY_MAX, SESSIONS_DIR, SESSIONS_INDEX, SKIP_DIRS3, HOME_SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
612379
612664
|
var init_omnius_directory = __esm({
|
|
612380
612665
|
"packages/cli/src/tui/omnius-directory.ts"() {
|
|
612381
612666
|
"use strict";
|
|
@@ -612384,6 +612669,7 @@ var init_omnius_directory = __esm({
|
|
|
612384
612669
|
LEGACY_DIRS = [".oa", ".open-agents"];
|
|
612385
612670
|
SUBDIRS = ["memory", "index", "context", "history", "notes", "embedded", "provenance", "tools", "dreams"];
|
|
612386
612671
|
gitignoreWatchers = /* @__PURE__ */ new Map();
|
|
612672
|
+
gitignoreRetryTimers = /* @__PURE__ */ new Map();
|
|
612387
612673
|
CONTEXT_FILES = [
|
|
612388
612674
|
"AGENTS.md",
|
|
612389
612675
|
"Omnius.md",
|
|
@@ -614844,7 +615130,7 @@ var init_status_bar = __esm({
|
|
|
614844
615130
|
BOX_FG = tuiBoxFg();
|
|
614845
615131
|
TEXT_PRIMARY = tuiTextPrimary() < 0 ? 252 : tuiTextPrimary();
|
|
614846
615132
|
TEXT_DIM = tuiTextDim();
|
|
614847
|
-
NO_SUB_AGENTS_HEADER_LABEL = " no agents ";
|
|
615133
|
+
NO_SUB_AGENTS_HEADER_LABEL = " no sub-agents ";
|
|
614848
615134
|
HEADER_BUTTON_GLYPH_FG = headerButtonGlyphFg();
|
|
614849
615135
|
HEADER_BUTTON_BG = headerButtonBg();
|
|
614850
615136
|
HEADER_BUTTON_FG = headerButtonFg();
|
|
@@ -615253,11 +615539,11 @@ var init_status_bar = __esm({
|
|
|
615253
615539
|
return "p2p";
|
|
615254
615540
|
if (backendType === "fake") return "fake";
|
|
615255
615541
|
if (!backendUrl2) return "";
|
|
615256
|
-
if (backendType) return backendType;
|
|
615257
615542
|
if (backendUrl2.includes("127.0.0.1") || backendUrl2.includes("localhost") || backendUrl2.includes("0.0.0.0")) {
|
|
615258
615543
|
return "local";
|
|
615259
615544
|
}
|
|
615260
|
-
return "remote";
|
|
615545
|
+
if (/^https?:\/\//i.test(backendUrl2)) return "remote";
|
|
615546
|
+
return backendType || "remote";
|
|
615261
615547
|
}
|
|
615262
615548
|
buildHeaderIdentitySegments() {
|
|
615263
615549
|
const sponsorLabel = (this._sponsorHeader?.message || this._sponsorHeader?.linkText || "").trim();
|
|
@@ -615277,6 +615563,16 @@ var init_status_bar = __esm({
|
|
|
615277
615563
|
last2.width += 2;
|
|
615278
615564
|
}
|
|
615279
615565
|
}
|
|
615566
|
+
const modelSummary2 = this.summarizeHeaderModelName();
|
|
615567
|
+
if (modelSummary2) {
|
|
615568
|
+
const text2 = ` ${modelSummary2} `;
|
|
615569
|
+
parts.push({ text: text2, width: stripAnsi(text2).length });
|
|
615570
|
+
}
|
|
615571
|
+
const transportSummary = this.summarizeHeaderTransport();
|
|
615572
|
+
if (transportSummary) {
|
|
615573
|
+
const text2 = ` ${transportSummary} `;
|
|
615574
|
+
parts.push({ text: text2, width: stripAnsi(text2).length });
|
|
615575
|
+
}
|
|
615280
615576
|
if (this._processing) {
|
|
615281
615577
|
const glyph = _StatusBar.HEADER_SPINNER_FRAMES[this._headerSpinnerFrame] ?? "";
|
|
615282
615578
|
const last2 = parts[parts.length - 1];
|
|
@@ -615592,20 +615888,23 @@ var init_status_bar = __esm({
|
|
|
615592
615888
|
return [];
|
|
615593
615889
|
}
|
|
615594
615890
|
getHeaderChromeLayout(termWidth) {
|
|
615891
|
+
const showPrev = this._headerPanelIndex > 0;
|
|
615892
|
+
const showNext = this._headerPanelIndex < this._headerPanels.length - 1;
|
|
615893
|
+
const contentStartCol = showPrev ? 4 : 2;
|
|
615894
|
+
const rightChrome = showNext ? 1 : 0;
|
|
615595
615895
|
return {
|
|
615596
|
-
showPrev
|
|
615597
|
-
showNext
|
|
615598
|
-
|
|
615599
|
-
|
|
615600
|
-
contentStartCol: 2,
|
|
615601
|
-
innerWidth: Math.max(1, termWidth - 4)
|
|
615896
|
+
showPrev,
|
|
615897
|
+
showNext,
|
|
615898
|
+
contentStartCol,
|
|
615899
|
+
innerWidth: Math.max(1, termWidth - contentStartCol - rightChrome)
|
|
615602
615900
|
};
|
|
615603
615901
|
}
|
|
615604
615902
|
hitTestCurrentHeaderAction(row, col, termWidth) {
|
|
615605
615903
|
const hdrRow = layout().headerContent;
|
|
615606
615904
|
if (row !== hdrRow) return null;
|
|
615607
615905
|
const chrome = this.getHeaderChromeLayout(termWidth);
|
|
615608
|
-
if (chrome.
|
|
615906
|
+
if (chrome.showPrev && col === 2) return "header-prev";
|
|
615907
|
+
if (chrome.showNext && col === termWidth - 1) return "header-next";
|
|
615609
615908
|
const hit = this._headerCommandZones.find(
|
|
615610
615909
|
(zone) => col >= zone.start && col <= zone.end
|
|
615611
615910
|
);
|
|
@@ -615698,9 +615997,14 @@ var init_status_bar = __esm({
|
|
|
615698
615997
|
let buf = "\x1B7";
|
|
615699
615998
|
buf += `\x1B[${hdrRow};1H${PANEL_BG_SEQ}\x1B[2K`;
|
|
615700
615999
|
buf += `${BOX_FG}│${RESET4}${PANEL_BG_SEQ}`;
|
|
616000
|
+
if (chromeLayout.showPrev) {
|
|
616001
|
+
buf += `${HEADER_BUTTON_FG}◀${RESET4}${PANEL_BG_SEQ} `;
|
|
616002
|
+
}
|
|
615701
616003
|
buf += `\x1B[38;5;${TEXT_PRIMARY}m${PANEL_BG_SEQ}`;
|
|
615702
616004
|
buf += content;
|
|
615703
|
-
|
|
616005
|
+
if (chromeLayout.showNext) {
|
|
616006
|
+
buf += `\x1B[${hdrRow};${w - 1}H${HEADER_BUTTON_FG}▶${RESET4}${PANEL_BG_SEQ}`;
|
|
616007
|
+
}
|
|
615704
616008
|
buf += `\x1B[${hdrRow};${w}H${BOX_FG}│${RESET4}${PANEL_BG_SEQ}`;
|
|
615705
616009
|
const scrollPct = this._contentScrollOffset > 0 ? `${Math.round(this._contentScrollOffset / this._contentMaxLines * 100)}%` : "live";
|
|
615706
616010
|
if (this._headerExpanded) {
|
|
@@ -618027,6 +618331,10 @@ ${CONTENT_BG_SEQ}`);
|
|
|
618027
618331
|
const digits = String(n2).split("");
|
|
618028
618332
|
return digits.map((d2) => this.DIGIT_EMOJI[parseInt(d2)] ?? d2).join("");
|
|
618029
618333
|
}
|
|
618334
|
+
static formatInteger(n2) {
|
|
618335
|
+
if (!Number.isFinite(n2) || n2 < 0) return "0";
|
|
618336
|
+
return Math.round(n2).toLocaleString();
|
|
618337
|
+
}
|
|
618030
618338
|
/** Render a digit bar with a given fg color, wrapped in panel bg */
|
|
618031
618339
|
static digitBarAnsi(n2, fgCode) {
|
|
618032
618340
|
const bar = this.digitBar(n2);
|
|
@@ -618073,10 +618381,10 @@ ${CONTENT_BG_SEQ}`);
|
|
|
618073
618381
|
const tpsStr = _StatusBar.formatTokensPerSecond(this._tokensPerSecond);
|
|
618074
618382
|
const tpsExpanded = " " + pastel2(222, "t/s") + " " + c3.bold(tpsStr);
|
|
618075
618383
|
const tpsW = 1 + 3 + 1 + tpsStr.length;
|
|
618076
|
-
const tokExpanded = pastel2(117, "↑") + _StatusBar.
|
|
618077
|
-
const tokCompact = pastel2(117, "↑") + _StatusBar.
|
|
618078
|
-
const tokExpW = 1 + _StatusBar.
|
|
618079
|
-
const tokCompW = 1 + _StatusBar.
|
|
618384
|
+
const tokExpanded = pastel2(117, "↑") + pastel2(117, _StatusBar.formatInteger(tokInRaw)) + " " + pastel2(151, "↓") + pastel2(151, _StatusBar.formatInteger(tokOutVal)) + " " + pastel2(222, "t/s") + " " + c3.bold(tpsStr);
|
|
618385
|
+
const tokCompact = pastel2(117, "↑") + pastel2(117, _StatusBar.formatInteger(tokInRaw)) + " " + pastel2(151, "↓") + pastel2(151, _StatusBar.formatInteger(tokOutVal)) + " " + pastel2(222, "t/s") + " " + c3.bold(tpsStr);
|
|
618386
|
+
const tokExpW = 1 + _StatusBar.formatInteger(tokInRaw).length + 1 + 1 + _StatusBar.formatInteger(tokOutVal).length + tpsW;
|
|
618387
|
+
const tokCompW = 1 + _StatusBar.formatInteger(tokInRaw).length + 1 + 1 + _StatusBar.formatInteger(tokOutVal).length + tpsW;
|
|
618080
618388
|
sections.push({
|
|
618081
618389
|
expanded: tokExpanded,
|
|
618082
618390
|
compact: tokCompact,
|
|
@@ -618264,24 +618572,24 @@ ${CONTENT_BG_SEQ}`);
|
|
|
618264
618572
|
if (rm4.cpuUtil >= 0) {
|
|
618265
618573
|
const cpuColor = rm4.cpuUtil > 80 ? c3.red : rm4.cpuUtil > 50 ? c3.yellow : c3.green;
|
|
618266
618574
|
const cpuCoresInfo = rm4.cpuCores > 0 ? ` (${_StatusBar.digitBar(rm4.cpuCores)}c` + (rm4.cpuModel ? " " + rm4.cpuModel.replace(/\s+/g, " ").slice(0, 30) : "") + ")" : "";
|
|
618267
|
-
hwExpStr += `CPU${cpuColor(_StatusBar.digitBar(rm4.cpuUtil) + "%")}${c3.dim(cpuCoresInfo)}`;
|
|
618268
|
-
hwCompStr += `CPU${cpuColor(_StatusBar.digitBar(rm4.cpuUtil) + "%")}`;
|
|
618269
|
-
hwExpW +=
|
|
618270
|
-
hwCompW +=
|
|
618575
|
+
hwExpStr += `CPU ${cpuColor(_StatusBar.digitBar(rm4.cpuUtil) + "%")}${c3.dim(cpuCoresInfo)}`;
|
|
618576
|
+
hwCompStr += `CPU ${cpuColor(_StatusBar.digitBar(rm4.cpuUtil) + "%")}`;
|
|
618577
|
+
hwExpW += 5 + `${rm4.cpuUtil}%`.length + cpuCoresInfo.length;
|
|
618578
|
+
hwCompW += 5 + `${rm4.cpuUtil}%`.length;
|
|
618271
618579
|
}
|
|
618272
618580
|
if (rm4.memUtil >= 0) {
|
|
618273
618581
|
const memColor = rm4.memUtil > 80 ? c3.red : rm4.memUtil > 50 ? c3.yellow : c3.green;
|
|
618274
618582
|
const memDetail = rm4.memTotalGB > 0 ? ` (${rm4.memUsedGB}/${rm4.memTotalGB}GB)` : "";
|
|
618275
|
-
hwExpStr += ` RAM${memColor(_StatusBar.digitBar(rm4.memUtil) + "%")}${c3.dim(memDetail)}`;
|
|
618276
|
-
hwCompStr += ` RAM${memColor(_StatusBar.digitBar(rm4.memUtil) + "%")}`;
|
|
618583
|
+
hwExpStr += ` RAM ${memColor(_StatusBar.digitBar(rm4.memUtil) + "%")}${c3.dim(memDetail)}`;
|
|
618584
|
+
hwCompStr += ` RAM ${memColor(_StatusBar.digitBar(rm4.memUtil) + "%")}`;
|
|
618277
618585
|
hwExpW += 5 + `${rm4.memUtil}%`.length + memDetail.length;
|
|
618278
618586
|
hwCompW += 5 + `${rm4.memUtil}%`.length;
|
|
618279
618587
|
}
|
|
618280
618588
|
if (rm4.diskUtil >= 0) {
|
|
618281
618589
|
const diskColor = rm4.diskUtil > 90 ? c3.red : rm4.diskUtil > 75 ? c3.yellow : c3.green;
|
|
618282
618590
|
const diskDetail = rm4.diskTotalGB > 0 ? ` (${rm4.diskFreeGB.toFixed(rm4.diskFreeGB < 10 ? 1 : 0)}GB free)` : "";
|
|
618283
|
-
hwExpStr += ` DISK${diskColor(_StatusBar.digitBar(rm4.diskUtil) + "%")}${c3.dim(diskDetail)}`;
|
|
618284
|
-
hwCompStr += ` DISK${diskColor(_StatusBar.digitBar(rm4.diskUtil) + "%")}`;
|
|
618591
|
+
hwExpStr += ` DISK ${diskColor(_StatusBar.digitBar(rm4.diskUtil) + "%")}${c3.dim(diskDetail)}`;
|
|
618592
|
+
hwCompStr += ` DISK ${diskColor(_StatusBar.digitBar(rm4.diskUtil) + "%")}`;
|
|
618285
618593
|
hwExpW += 6 + `${rm4.diskUtil}%`.length + diskDetail.length;
|
|
618286
618594
|
hwCompW += 6 + `${rm4.diskUtil}%`.length;
|
|
618287
618595
|
}
|
|
@@ -640282,6 +640590,22 @@ The session corrections MUST become hard rules in the SKILL.md Rules section.`;
|
|
|
640282
640590
|
await showCohereStatus(ctx3);
|
|
640283
640591
|
return "handled";
|
|
640284
640592
|
}
|
|
640593
|
+
if (arg === "models") {
|
|
640594
|
+
const nexus = new NexusTool(ctx3.repoRoot);
|
|
640595
|
+
const result = await nexus.execute({
|
|
640596
|
+
action: "cohere_list_models",
|
|
640597
|
+
format: "json"
|
|
640598
|
+
});
|
|
640599
|
+
if (result.success) {
|
|
640600
|
+
renderInfo(`COHERE all endpoint models:
|
|
640601
|
+
${result.output}`);
|
|
640602
|
+
} else {
|
|
640603
|
+
renderError(
|
|
640604
|
+
result.error || result.output || "COHERE model listing failed."
|
|
640605
|
+
);
|
|
640606
|
+
}
|
|
640607
|
+
return "handled";
|
|
640608
|
+
}
|
|
640285
640609
|
await showCohereDashboard(ctx3);
|
|
640286
640610
|
return "handled";
|
|
640287
640611
|
}
|
|
@@ -650566,6 +650890,7 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
650566
650890
|
installOverlay.stop("Requesting permissions...");
|
|
650567
650891
|
await new Promise((r2) => setTimeout(r2, 300));
|
|
650568
650892
|
installOverlay.dismiss();
|
|
650893
|
+
renderInfo("Global npm directory requires elevated permissions.");
|
|
650569
650894
|
const sudoReady = await acquireSudoCredentials(
|
|
650570
650895
|
ctx3,
|
|
650571
650896
|
"The global npm directory requires elevated permissions for this update."
|
|
@@ -655593,12 +655918,12 @@ var init_stream_renderer = __esm({
|
|
|
655593
655918
|
this.thinkingBoxOpen = true;
|
|
655594
655919
|
this.thinkingBoxRowCount = 2;
|
|
655595
655920
|
this.writeRaw(thinkingBoxTop(w) + "\n");
|
|
655596
|
-
this.writeRaw(thinkingBoxRow(dimItalic("
|
|
655921
|
+
this.writeRaw(thinkingBoxRow(dimItalic("thinking..."), w) + "\n");
|
|
655597
655922
|
this.lineStarted = false;
|
|
655598
655923
|
}
|
|
655599
655924
|
if (this.thinkingTokenCount % 500 === 0) {
|
|
655600
655925
|
this.updateThinkingBox(
|
|
655601
|
-
`
|
|
655926
|
+
`thinking... (${this.thinkingTokenCount} tokens)`,
|
|
655602
655927
|
w
|
|
655603
655928
|
);
|
|
655604
655929
|
}
|
|
@@ -660661,12 +660986,6 @@ function buildToolDetailText(tool) {
|
|
|
660661
660986
|
lines.push("🔙 <i>Tap Back to return to the tool list.</i>");
|
|
660662
660987
|
return lines.join("\n");
|
|
660663
660988
|
}
|
|
660664
|
-
function renderHelpMenu(scope) {
|
|
660665
|
-
const tools = buildScopedToolList(scope);
|
|
660666
|
-
const text2 = buildToolListText(tools, 0, scope);
|
|
660667
|
-
const inline_keyboard = buildToolListKeyboard(tools, 0, scope);
|
|
660668
|
-
return { text: text2, replyMarkup: { inline_keyboard } };
|
|
660669
|
-
}
|
|
660670
660989
|
function renderHelpMenuPage(scope, page2) {
|
|
660671
660990
|
const tools = buildScopedToolList(scope);
|
|
660672
660991
|
const totalPages = Math.max(1, Math.ceil(tools.length / TOOLS_PER_PAGE));
|
|
@@ -660675,14 +660994,6 @@ function renderHelpMenuPage(scope, page2) {
|
|
|
660675
660994
|
const inline_keyboard = buildToolListKeyboard(tools, page2, scope);
|
|
660676
660995
|
return { text: text2, replyMarkup: { inline_keyboard } };
|
|
660677
660996
|
}
|
|
660678
|
-
function renderHelpMenuPageWithCountdown(scope, page2, countdown) {
|
|
660679
|
-
const tools = buildScopedToolList(scope);
|
|
660680
|
-
const totalPages = Math.max(1, Math.ceil(tools.length / TOOLS_PER_PAGE));
|
|
660681
|
-
page2 = Math.max(0, Math.min(page2, totalPages - 1));
|
|
660682
|
-
const text2 = buildToolListText(tools, page2, scope);
|
|
660683
|
-
const inline_keyboard = buildToolListKeyboard(tools, page2, scope, countdown);
|
|
660684
|
-
return { text: text2, replyMarkup: { inline_keyboard } };
|
|
660685
|
-
}
|
|
660686
660997
|
function renderHelpToolDetail(scope, toolName, returnPage) {
|
|
660687
660998
|
const tools = buildScopedToolList(scope);
|
|
660688
660999
|
const tool = tools.find((t2) => t2.name === toolName);
|
|
@@ -660727,7 +661038,7 @@ function handleHelpCallback(callbackData, currentState) {
|
|
|
660727
661038
|
}
|
|
660728
661039
|
return { render: render2, newState };
|
|
660729
661040
|
}
|
|
660730
|
-
var TOOLS_PER_PAGE, GRID_COLS, CALLBACK_PREFIX, MAX_CALLBACK_DATA,
|
|
661041
|
+
var TOOLS_PER_PAGE, GRID_COLS, CALLBACK_PREFIX, MAX_CALLBACK_DATA, TELEGRAM_PUBLIC_HELP_COMMANDS, HelpMenuStateStore;
|
|
660731
661042
|
var init_telegram_help_menu = __esm({
|
|
660732
661043
|
"packages/cli/src/tui/telegram-help-menu.ts"() {
|
|
660733
661044
|
"use strict";
|
|
@@ -660736,8 +661047,6 @@ var init_telegram_help_menu = __esm({
|
|
|
660736
661047
|
GRID_COLS = 5;
|
|
660737
661048
|
CALLBACK_PREFIX = "help";
|
|
660738
661049
|
MAX_CALLBACK_DATA = 64;
|
|
660739
|
-
INACTIVITY_TIMEOUT_MS = 6e4;
|
|
660740
|
-
COUNTDOWN_SECONDS = 10;
|
|
660741
661050
|
TELEGRAM_PUBLIC_HELP_COMMANDS = /* @__PURE__ */ new Set(["help", "start", "auth", "call"]);
|
|
660742
661051
|
HelpMenuStateStore = class {
|
|
660743
661052
|
states = /* @__PURE__ */ new Map();
|
|
@@ -660763,124 +661072,6 @@ var init_telegram_help_menu = __esm({
|
|
|
660763
661072
|
}
|
|
660764
661073
|
}
|
|
660765
661074
|
};
|
|
660766
|
-
HelpMenuTimerManager = class {
|
|
660767
|
-
inactivityTimers = /* @__PURE__ */ new Map();
|
|
660768
|
-
countdownIntervals = /* @__PURE__ */ new Map();
|
|
660769
|
-
stateStore;
|
|
660770
|
-
callbacks;
|
|
660771
|
-
constructor(stateStore, callbacks) {
|
|
660772
|
-
this.stateStore = stateStore;
|
|
660773
|
-
this.callbacks = callbacks;
|
|
660774
|
-
}
|
|
660775
|
-
key(chatId, messageId) {
|
|
660776
|
-
return `${chatId}:${messageId}`;
|
|
660777
|
-
}
|
|
660778
|
-
/** Start the inactivity timer for a newly created menu */
|
|
660779
|
-
startTimer(state) {
|
|
660780
|
-
this.clearTimer(state.chatId, state.messageId);
|
|
660781
|
-
const k = this.key(state.chatId, state.messageId);
|
|
660782
|
-
const timer = setTimeout(() => {
|
|
660783
|
-
this.inactivityTimers.delete(k);
|
|
660784
|
-
this.startCountdown(state);
|
|
660785
|
-
}, INACTIVITY_TIMEOUT_MS);
|
|
660786
|
-
this.inactivityTimers.set(k, timer);
|
|
660787
|
-
}
|
|
660788
|
-
/** Reset the inactivity timer after user interaction */
|
|
660789
|
-
resetTimer(chatId, messageId) {
|
|
660790
|
-
const state = this.stateStore.get(chatId, messageId);
|
|
660791
|
-
if (!state) return;
|
|
660792
|
-
this.cancelCountdown(chatId, messageId);
|
|
660793
|
-
const updated = { ...state, lastInteractionAt: Date.now(), countdownValue: null };
|
|
660794
|
-
this.stateStore.set(updated);
|
|
660795
|
-
this.startTimer(updated);
|
|
660796
|
-
}
|
|
660797
|
-
/** Clear all timers for a menu (used when menu is closed or deleted) */
|
|
660798
|
-
clearTimer(chatId, messageId) {
|
|
660799
|
-
const k = this.key(chatId, messageId);
|
|
660800
|
-
const timer = this.inactivityTimers.get(k);
|
|
660801
|
-
if (timer) {
|
|
660802
|
-
clearTimeout(timer);
|
|
660803
|
-
this.inactivityTimers.delete(k);
|
|
660804
|
-
}
|
|
660805
|
-
this.cancelCountdown(chatId, messageId);
|
|
660806
|
-
}
|
|
660807
|
-
/** Start the 10-second countdown, updating the close button each second */
|
|
660808
|
-
startCountdown(state) {
|
|
660809
|
-
const k = this.key(state.chatId, state.messageId);
|
|
660810
|
-
let countdown = COUNTDOWN_SECONDS;
|
|
660811
|
-
const updatedState = { ...state, countdownValue: countdown, lastInteractionAt: Date.now() };
|
|
660812
|
-
this.stateStore.set(updatedState);
|
|
660813
|
-
this.updateCountdownButton(updatedState);
|
|
660814
|
-
const interval = setInterval(() => {
|
|
660815
|
-
countdown--;
|
|
660816
|
-
if (countdown <= 0) {
|
|
660817
|
-
clearInterval(interval);
|
|
660818
|
-
this.countdownIntervals.delete(k);
|
|
660819
|
-
this.deleteMenu(state.chatId, state.messageId);
|
|
660820
|
-
} else {
|
|
660821
|
-
const s2 = { ...state, countdownValue: countdown, lastInteractionAt: Date.now() };
|
|
660822
|
-
this.stateStore.set(s2);
|
|
660823
|
-
this.updateCountdownButton(s2);
|
|
660824
|
-
}
|
|
660825
|
-
}, 1e3);
|
|
660826
|
-
this.countdownIntervals.set(k, interval);
|
|
660827
|
-
}
|
|
660828
|
-
cancelCountdown(chatId, messageId) {
|
|
660829
|
-
const k = this.key(chatId, messageId);
|
|
660830
|
-
const interval = this.countdownIntervals.get(k);
|
|
660831
|
-
if (interval) {
|
|
660832
|
-
clearInterval(interval);
|
|
660833
|
-
this.countdownIntervals.delete(k);
|
|
660834
|
-
}
|
|
660835
|
-
}
|
|
660836
|
-
/** Update the close button to show countdown value */
|
|
660837
|
-
async updateCountdownButton(state) {
|
|
660838
|
-
try {
|
|
660839
|
-
let render2;
|
|
660840
|
-
if (state.view === "list") {
|
|
660841
|
-
render2 = renderHelpMenuPageWithCountdown(state.scope, state.page, state.countdownValue);
|
|
660842
|
-
} else {
|
|
660843
|
-
render2 = renderHelpToolDetail(state.scope, state.detailToolName, state.page);
|
|
660844
|
-
}
|
|
660845
|
-
if (!render2) return;
|
|
660846
|
-
await this.callbacks.editMessageText(
|
|
660847
|
-
state.chatId,
|
|
660848
|
-
state.messageId,
|
|
660849
|
-
render2.text,
|
|
660850
|
-
render2.replyMarkup
|
|
660851
|
-
);
|
|
660852
|
-
} catch {
|
|
660853
|
-
}
|
|
660854
|
-
}
|
|
660855
|
-
/** Delete the menu message, the invoking user message, and clean up state */
|
|
660856
|
-
async deleteMenu(chatId, messageId) {
|
|
660857
|
-
const state = this.stateStore.get(chatId, messageId);
|
|
660858
|
-
const invokerMsgId = state?.invokerMessageId;
|
|
660859
|
-
this.clearTimer(chatId, messageId);
|
|
660860
|
-
this.stateStore.delete(chatId, messageId);
|
|
660861
|
-
try {
|
|
660862
|
-
await this.callbacks.deleteMessage(chatId, messageId);
|
|
660863
|
-
} catch {
|
|
660864
|
-
}
|
|
660865
|
-
if (invokerMsgId) {
|
|
660866
|
-
try {
|
|
660867
|
-
await this.callbacks.deleteMessage(chatId, invokerMsgId);
|
|
660868
|
-
} catch {
|
|
660869
|
-
}
|
|
660870
|
-
}
|
|
660871
|
-
}
|
|
660872
|
-
/** Clean up all timers (for shutdown) */
|
|
660873
|
-
destroyAll() {
|
|
660874
|
-
for (const [k, timer] of this.inactivityTimers) {
|
|
660875
|
-
clearTimeout(timer);
|
|
660876
|
-
}
|
|
660877
|
-
this.inactivityTimers.clear();
|
|
660878
|
-
for (const [k, interval] of this.countdownIntervals) {
|
|
660879
|
-
clearInterval(interval);
|
|
660880
|
-
}
|
|
660881
|
-
this.countdownIntervals.clear();
|
|
660882
|
-
}
|
|
660883
|
-
};
|
|
660884
661075
|
}
|
|
660885
661076
|
});
|
|
660886
661077
|
|
|
@@ -661140,7 +661331,7 @@ function handleStatsCallback(data, currentState, snapshot) {
|
|
|
661140
661331
|
return null;
|
|
661141
661332
|
}
|
|
661142
661333
|
}
|
|
661143
|
-
var PAGE_SIZE, StatsMenuStateStore, CB_PREFIX, CATEGORY_LABELS2,
|
|
661334
|
+
var PAGE_SIZE, StatsMenuStateStore, CB_PREFIX, CATEGORY_LABELS2, INACTIVITY_TIMEOUT_MS, COUNTDOWN_SECONDS, StatsMenuTimerManager;
|
|
661144
661335
|
var init_telegram_stats_menu = __esm({
|
|
661145
661336
|
"packages/cli/src/tui/telegram-stats-menu.ts"() {
|
|
661146
661337
|
"use strict";
|
|
@@ -661174,8 +661365,8 @@ var init_telegram_stats_menu = __esm({
|
|
|
661174
661365
|
session: "Session",
|
|
661175
661366
|
system: "System"
|
|
661176
661367
|
};
|
|
661177
|
-
|
|
661178
|
-
|
|
661368
|
+
INACTIVITY_TIMEOUT_MS = 6e4;
|
|
661369
|
+
COUNTDOWN_SECONDS = 10;
|
|
661179
661370
|
StatsMenuTimerManager = class {
|
|
661180
661371
|
constructor(states2, callbacks, getSnapshot) {
|
|
661181
661372
|
this.states = states2;
|
|
@@ -661211,12 +661402,12 @@ var init_telegram_stats_menu = __esm({
|
|
|
661211
661402
|
lastInteractionAt: Date.now()
|
|
661212
661403
|
}
|
|
661213
661404
|
);
|
|
661214
|
-
},
|
|
661405
|
+
}, INACTIVITY_TIMEOUT_MS)
|
|
661215
661406
|
);
|
|
661216
661407
|
}
|
|
661217
661408
|
startCountdown(state) {
|
|
661218
661409
|
const k = this.key(state.chatId, state.messageId);
|
|
661219
|
-
this.countdownValues.set(k,
|
|
661410
|
+
this.countdownValues.set(k, COUNTDOWN_SECONDS);
|
|
661220
661411
|
this.renderCountdown(state).catch(() => {
|
|
661221
661412
|
});
|
|
661222
661413
|
this.countdownTimers.set(
|
|
@@ -668572,6 +668763,7 @@ Telegram link integrity contract:
|
|
|
668572
668763
|
telegramActiveWorkStartedAtMs = /* @__PURE__ */ new Map();
|
|
668573
668764
|
/** Queued Telegram sessions waiting for a global work slot. */
|
|
668574
668765
|
telegramQueuedSessionWork = /* @__PURE__ */ new Map();
|
|
668766
|
+
telegramQueuedSessionCompletions = /* @__PURE__ */ new Map();
|
|
668575
668767
|
telegramDispatchQueuedTimer = null;
|
|
668576
668768
|
telegramDispatchQueuedAtMs = 0;
|
|
668577
668769
|
telegramQueueDiagnosticLastAtMs = 0;
|
|
@@ -669474,22 +669666,41 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
669474
669666
|
messageCount: (existing?.messageCount ?? 0) + 1
|
|
669475
669667
|
};
|
|
669476
669668
|
}
|
|
669669
|
+
getTelegramQueuedSessionCompletion(sessionKey) {
|
|
669670
|
+
const existing = this.telegramQueuedSessionCompletions.get(sessionKey);
|
|
669671
|
+
if (existing) return existing;
|
|
669672
|
+
let resolve73;
|
|
669673
|
+
let reject;
|
|
669674
|
+
const promise = new Promise((res, rej) => {
|
|
669675
|
+
resolve73 = res;
|
|
669676
|
+
reject = rej;
|
|
669677
|
+
});
|
|
669678
|
+
promise.catch(() => {
|
|
669679
|
+
});
|
|
669680
|
+
const completion = { promise, resolve: resolve73, reject };
|
|
669681
|
+
this.telegramQueuedSessionCompletions.set(sessionKey, completion);
|
|
669682
|
+
return completion;
|
|
669683
|
+
}
|
|
669684
|
+
shouldAwaitTelegramQueuedWorkForTests() {
|
|
669685
|
+
return process.env["OMNIUS_TG_AWAIT_QUEUED_WORK"] === "1" || process.env["VITEST"] === "true";
|
|
669686
|
+
}
|
|
669477
669687
|
scheduleTelegramSessionWork(msg, toolContext) {
|
|
669478
669688
|
const sessionKey = this.sessionKeyForMessage(msg);
|
|
669479
669689
|
const now2 = Date.now();
|
|
669480
669690
|
const existing = this.subAgents.get(sessionKey);
|
|
669481
669691
|
if (existing && !existing.aborted) {
|
|
669482
|
-
|
|
669483
|
-
|
|
669484
|
-
|
|
669485
|
-
|
|
669486
|
-
|
|
669487
|
-
|
|
669488
|
-
|
|
669489
|
-
|
|
669490
|
-
|
|
669491
|
-
|
|
669692
|
+
return this.enqueueTelegramMessageForExistingSubAgent(
|
|
669693
|
+
msg,
|
|
669694
|
+
existing
|
|
669695
|
+
).catch((err) => {
|
|
669696
|
+
this.tuiWrite(
|
|
669697
|
+
() => renderWarning(
|
|
669698
|
+
`Telegram context merge error: ${err instanceof Error ? err.message : String(err)}`
|
|
669699
|
+
)
|
|
669700
|
+
);
|
|
669701
|
+
});
|
|
669492
669702
|
}
|
|
669703
|
+
const completion = this.getTelegramQueuedSessionCompletion(sessionKey);
|
|
669493
669704
|
const queued = this.buildTelegramQueuedSessionWork(
|
|
669494
669705
|
sessionKey,
|
|
669495
669706
|
msg,
|
|
@@ -669507,6 +669718,7 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
669507
669718
|
`queued Telegram work for ${msg.chatTitle || msg.chatType}; active ${this.activeTelegramInteractionCount()}/${this.getSubAgentLimit()}, queued ${this.telegramQueuedSessionWork.size}, bundled ${queued.messageCount}`
|
|
669508
669719
|
)
|
|
669509
669720
|
);
|
|
669721
|
+
return completion.promise;
|
|
669510
669722
|
}
|
|
669511
669723
|
startTelegramSessionWork(work) {
|
|
669512
669724
|
if (this.telegramSessionIsLive(work.sessionKey)) {
|
|
@@ -669521,13 +669733,20 @@ No scoped reflection artifact exists yet for this chat. Use <code>/reflect</code
|
|
|
669521
669733
|
this.telegramActiveWorkStartedAtMs.set(work.sessionKey, Date.now());
|
|
669522
669734
|
const generation = this.nextTelegramWorkGeneration(work.sessionKey);
|
|
669523
669735
|
this.refreshActiveTelegramInteractionCount();
|
|
669524
|
-
|
|
669736
|
+
const completion = this.telegramQueuedSessionCompletions.get(
|
|
669737
|
+
work.sessionKey
|
|
669738
|
+
);
|
|
669739
|
+
void this.processTelegramMessageWork(work, generation).then(() => {
|
|
669740
|
+
completion?.resolve();
|
|
669741
|
+
}).catch((err) => {
|
|
669525
669742
|
this.tuiWrite(
|
|
669526
669743
|
() => renderWarning(
|
|
669527
669744
|
`Telegram sub-agent error: ${err instanceof Error ? err.message : String(err)}`
|
|
669528
669745
|
)
|
|
669529
669746
|
);
|
|
669747
|
+
completion?.reject(err);
|
|
669530
669748
|
}).finally(() => {
|
|
669749
|
+
this.telegramQueuedSessionCompletions.delete(work.sessionKey);
|
|
669531
669750
|
if (this.telegramWorkGenerationIsCurrent(work.sessionKey, generation)) {
|
|
669532
669751
|
this.telegramActiveWorkSessions.delete(work.sessionKey);
|
|
669533
669752
|
this.telegramActiveWorkStartedAtMs.delete(work.sessionKey);
|
|
@@ -669738,58 +669957,21 @@ ${message2}`)
|
|
|
669738
669957
|
}
|
|
669739
669958
|
async replyWithTelegramHelp(msg, isAdmin) {
|
|
669740
669959
|
const scope = isAdmin ? "admin" : "public";
|
|
669741
|
-
const
|
|
669960
|
+
const helpText = buildTelegramHelpHTML(scope);
|
|
669742
669961
|
if (msg.guestQueryId) {
|
|
669743
|
-
const chunks = splitTelegramHTMLMessage(
|
|
669744
|
-
buildTelegramHelpHTML(isAdmin ? "admin" : "public")
|
|
669745
|
-
);
|
|
669962
|
+
const chunks = splitTelegramHTMLMessage(helpText);
|
|
669746
669963
|
await this.answerGuestQuery(msg.guestQueryId, chunks[0] ?? "", {
|
|
669747
669964
|
parseMode: "HTML"
|
|
669748
669965
|
});
|
|
669749
669966
|
return;
|
|
669750
669967
|
}
|
|
669751
|
-
const
|
|
669752
|
-
|
|
669753
|
-
|
|
669754
|
-
|
|
669755
|
-
|
|
669756
|
-
|
|
669757
|
-
|
|
669758
|
-
if (sent.ok && sent.result?.message_id) {
|
|
669759
|
-
const state = {
|
|
669760
|
-
chatId: msg.chatId,
|
|
669761
|
-
messageId: sent.result.message_id,
|
|
669762
|
-
invokerMessageId: msg.messageId,
|
|
669763
|
-
scope,
|
|
669764
|
-
page: 0,
|
|
669765
|
-
view: "list",
|
|
669766
|
-
detailToolName: null,
|
|
669767
|
-
fromUserId: msg.fromUserId ?? 0,
|
|
669768
|
-
createdAt: Date.now(),
|
|
669769
|
-
lastInteractionAt: Date.now(),
|
|
669770
|
-
countdownValue: null
|
|
669771
|
-
};
|
|
669772
|
-
this.helpMenuStates.set(state);
|
|
669773
|
-
if (!this.helpMenuTimers) {
|
|
669774
|
-
this.helpMenuTimers = new HelpMenuTimerManager(this.helpMenuStates, {
|
|
669775
|
-
editMessageText: async (chatId, messageId, text2, replyMarkup) => {
|
|
669776
|
-
await this.apiCall("editMessageText", {
|
|
669777
|
-
chat_id: chatId,
|
|
669778
|
-
message_id: messageId,
|
|
669779
|
-
text: text2,
|
|
669780
|
-
parse_mode: "HTML",
|
|
669781
|
-
reply_markup: JSON.stringify(replyMarkup)
|
|
669782
|
-
});
|
|
669783
|
-
},
|
|
669784
|
-
deleteMessage: async (chatId, messageId) => {
|
|
669785
|
-
await this.apiCall("deleteMessage", {
|
|
669786
|
-
chat_id: chatId,
|
|
669787
|
-
message_id: messageId
|
|
669788
|
-
});
|
|
669789
|
-
}
|
|
669790
|
-
});
|
|
669791
|
-
}
|
|
669792
|
-
this.helpMenuTimers.startTimer(state);
|
|
669968
|
+
for (const chunk of splitTelegramHTMLMessage(helpText)) {
|
|
669969
|
+
await this.apiCall("sendMessage", {
|
|
669970
|
+
chat_id: msg.chatId,
|
|
669971
|
+
text: chunk,
|
|
669972
|
+
parse_mode: "HTML",
|
|
669973
|
+
...msg.chatType !== "private" ? { reply_to_message_id: msg.messageId } : {}
|
|
669974
|
+
});
|
|
669793
669975
|
}
|
|
669794
669976
|
}
|
|
669795
669977
|
async replyWithTelegramCommandMenu(msg, isAdmin, kind, commandName) {
|
|
@@ -673854,6 +674036,10 @@ ${lines.join("\n")}`;
|
|
|
673854
674036
|
const factCount = memory?.facts.length ?? 0;
|
|
673855
674037
|
const userMemoryCount = memory ? Object.keys(memory.users).length : 0;
|
|
673856
674038
|
const historyCount = (this.chatHistory.get(sessionKey) ?? []).length;
|
|
674039
|
+
const sqliteHistoryCount = this.telegramSqliteHistoryForSession(
|
|
674040
|
+
sessionKey,
|
|
674041
|
+
5e3
|
|
674042
|
+
).length;
|
|
673857
674043
|
const chatId = msg.chatId;
|
|
673858
674044
|
let topicCount = 0;
|
|
673859
674045
|
if (this.repoRoot && chatId !== void 0) {
|
|
@@ -673868,11 +674054,37 @@ ${lines.join("\n")}`;
|
|
|
673868
674054
|
} catch {
|
|
673869
674055
|
}
|
|
673870
674056
|
}
|
|
673871
|
-
const hasMemory = cardCount + factCount + userMemoryCount + topicCount > 0 || historyCount > 0;
|
|
674057
|
+
const hasMemory = cardCount + factCount + userMemoryCount + topicCount > 0 || historyCount > 0 || sqliteHistoryCount > 0;
|
|
673872
674058
|
if (!hasMemory) return "";
|
|
674059
|
+
const sqliteLines = [];
|
|
674060
|
+
if (sqliteHistoryCount > 0) {
|
|
674061
|
+
const addressableRows = this.telegramMergedHistoryForSession(
|
|
674062
|
+
sessionKey,
|
|
674063
|
+
5e3
|
|
674064
|
+
).length;
|
|
674065
|
+
const anchors = this.telegramHistoryAnchorsForSession(sessionKey, 1);
|
|
674066
|
+
sqliteLines.push(`SQLite mirror rows: ${sqliteHistoryCount}`);
|
|
674067
|
+
sqliteLines.push(
|
|
674068
|
+
`Addressable conversation history rows: ${addressableRows}`
|
|
674069
|
+
);
|
|
674070
|
+
const earliest = anchors.earliest[0];
|
|
674071
|
+
if (earliest?.ts) {
|
|
674072
|
+
sqliteLines.push(
|
|
674073
|
+
`Earliest turn: ${new Date(earliest.ts).toISOString()} ${telegramHistorySpeaker(earliest)}`
|
|
674074
|
+
);
|
|
674075
|
+
}
|
|
674076
|
+
for (const stat8 of this.telegramParticipantActivityStats(sessionKey, {
|
|
674077
|
+
limit: 5
|
|
674078
|
+
})) {
|
|
674079
|
+
sqliteLines.push(
|
|
674080
|
+
`${stat8.speaker}: ${stat8.count} message${stat8.count === 1 ? "" : "s"}`
|
|
674081
|
+
);
|
|
674082
|
+
}
|
|
674083
|
+
}
|
|
673873
674084
|
return [
|
|
673874
674085
|
"### Memory Substrate (this chat)",
|
|
673875
674086
|
`Available: ${cardCount} cards, ${factCount} facts, ${userMemoryCount} per-user memories, ${historyCount} rolling-history msgs, ${topicCount} memory_read topics.`,
|
|
674087
|
+
...sqliteLines,
|
|
673876
674088
|
"Recall via memory_search (semantic similarity / graph traversal / episodes). For exact reads: memory_read(topic, key). The substrate is associative — recall is by cue, not by date."
|
|
673877
674089
|
].join("\n");
|
|
673878
674090
|
}
|
|
@@ -673933,6 +674145,11 @@ ${lines.join("\n")}`;
|
|
|
673933
674145
|
if (socialStateContext) {
|
|
673934
674146
|
sections.push(socialStateContext);
|
|
673935
674147
|
}
|
|
674148
|
+
try {
|
|
674149
|
+
const daydreamContext = this.formatLatestTelegramChannelDaydreamContext(sessionKey);
|
|
674150
|
+
if (daydreamContext) sections.push(daydreamContext);
|
|
674151
|
+
} catch {
|
|
674152
|
+
}
|
|
673936
674153
|
if (participants.length > 0) {
|
|
673937
674154
|
const fullCount = Math.min(12, participants.length);
|
|
673938
674155
|
const tier1Count = Math.max(1, Math.round(fullCount * tier1Ratio));
|
|
@@ -674336,13 +674553,8 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
674336
674553
|
const suppressed = telegramThinkSuppressedRequest(request);
|
|
674337
674554
|
const requestTimeoutMs = Number.isFinite(suppressed.timeoutMs) && (suppressed.timeoutMs ?? 0) > 0 ? suppressed.timeoutMs : void 0;
|
|
674338
674555
|
const jsonStartMs = Date.now();
|
|
674339
|
-
const nativeOllamaRouter = diagnostics?.backendType === "ollama" && typeof backend.nativeOllamaChatCompletion === "function";
|
|
674340
674556
|
try {
|
|
674341
|
-
jsonModeResult =
|
|
674342
|
-
...suppressed,
|
|
674343
|
-
responseFormat: TELEGRAM_INTERACTION_DECISION_RESPONSE_FORMAT,
|
|
674344
|
-
disableEmptyContentRecovery: true
|
|
674345
|
-
}) : await this.telegramObservableInference(
|
|
674557
|
+
jsonModeResult = await this.telegramObservableInference(
|
|
674346
674558
|
backend,
|
|
674347
674559
|
{
|
|
674348
674560
|
...suppressed,
|
|
@@ -674406,7 +674618,7 @@ ${this.quoteTelegramContextBlock(msg.text, 1200)}`,
|
|
|
674406
674618
|
}
|
|
674407
674619
|
const plainStartMs = Date.now();
|
|
674408
674620
|
try {
|
|
674409
|
-
const plainResult =
|
|
674621
|
+
const plainResult = await this.telegramObservableInference(
|
|
674410
674622
|
backend,
|
|
674411
674623
|
suppressed,
|
|
674412
674624
|
inferenceKind,
|
|
@@ -676480,6 +676692,10 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
|
|
|
676480
676692
|
this.telegramDispatchQueuedAtMs = 0;
|
|
676481
676693
|
}
|
|
676482
676694
|
this.telegramQueuedSessionWork.clear();
|
|
676695
|
+
for (const completion of this.telegramQueuedSessionCompletions.values()) {
|
|
676696
|
+
completion.reject(new Error("Telegram bridge stopped before queued work completed"));
|
|
676697
|
+
}
|
|
676698
|
+
this.telegramQueuedSessionCompletions.clear();
|
|
676483
676699
|
this.telegramActiveWorkSessions.clear();
|
|
676484
676700
|
this.telegramActiveWorkGenerations.clear();
|
|
676485
676701
|
this.telegramActiveWorkStartedAtMs.clear();
|
|
@@ -677625,7 +677841,8 @@ Join: ${newUrl}`
|
|
|
677625
677841
|
await this.enqueueTelegramMessageForExistingSubAgent(msg, existing);
|
|
677626
677842
|
return;
|
|
677627
677843
|
}
|
|
677628
|
-
this.scheduleTelegramSessionWork(msg, toolContext);
|
|
677844
|
+
const queuedWork = this.scheduleTelegramSessionWork(msg, toolContext);
|
|
677845
|
+
if (this.shouldAwaitTelegramQueuedWorkForTests()) await queuedWork;
|
|
677629
677846
|
}
|
|
677630
677847
|
async processTelegramMessageWork(work, workGeneration) {
|
|
677631
677848
|
const msg = work.msg;
|
|
@@ -687348,11 +687565,14 @@ var init_routes_media = __esm({
|
|
|
687348
687565
|
async function buildDirectToolRegistry(workingDir) {
|
|
687349
687566
|
const mod3 = await Promise.resolve().then(() => (init_dist5(), dist_exports2)).catch(() => null);
|
|
687350
687567
|
if (!mod3) {
|
|
687351
|
-
return { entries: [], byName: /* @__PURE__ */ new Map(), executionModule: {} };
|
|
687568
|
+
return { entries: [], byName: /* @__PURE__ */ new Map(), callableByName: /* @__PURE__ */ new Map(), executionModule: {} };
|
|
687352
687569
|
}
|
|
687353
687570
|
const buildManifest = mod3.buildToolManifestFromModule;
|
|
687354
687571
|
const baseEntries = buildManifest ? buildManifest(mod3, { cwd: workingDir }) : [];
|
|
687355
|
-
const entries = baseEntries.filter((entry) => typeof entry.name === "string" && typeof entry.className === "string").map((entry) => ({
|
|
687572
|
+
const entries = baseEntries.filter((entry) => typeof entry.name === "string" && typeof entry.className === "string").map((entry) => ({
|
|
687573
|
+
...entry,
|
|
687574
|
+
directCallable: DIRECT_BOOKKEEPING_TOOL_NAMES.has(entry.name)
|
|
687575
|
+
}));
|
|
687356
687576
|
if (!entries.some((entry) => entry.name === TASK_COMPLETE_ENTRY.name)) {
|
|
687357
687577
|
entries.push({
|
|
687358
687578
|
...TASK_COMPLETE_ENTRY,
|
|
@@ -687360,14 +687580,16 @@ async function buildDirectToolRegistry(workingDir) {
|
|
|
687360
687580
|
});
|
|
687361
687581
|
}
|
|
687362
687582
|
entries.sort((a2, b) => a2.name.localeCompare(b.name));
|
|
687583
|
+
const callableEntries = entries.filter((entry) => entry.directCallable);
|
|
687363
687584
|
return {
|
|
687364
687585
|
entries,
|
|
687365
687586
|
byName: new Map(entries.map((entry) => [entry.name, entry])),
|
|
687587
|
+
callableByName: new Map(callableEntries.map((entry) => [entry.name, entry])),
|
|
687366
687588
|
executionModule: mod3
|
|
687367
687589
|
};
|
|
687368
687590
|
}
|
|
687369
687591
|
function instantiateDirectTool(registry4, name10, workingDir) {
|
|
687370
|
-
const entry = registry4.
|
|
687592
|
+
const entry = registry4.callableByName.get(name10);
|
|
687371
687593
|
if (!entry) return null;
|
|
687372
687594
|
if (entry.virtual && entry.name === "task_complete") {
|
|
687373
687595
|
return createTaskCompleteDirectTool();
|
|
@@ -687415,7 +687637,7 @@ function createTaskCompleteDirectTool() {
|
|
|
687415
687637
|
}
|
|
687416
687638
|
};
|
|
687417
687639
|
}
|
|
687418
|
-
var TASK_COMPLETE_ENTRY;
|
|
687640
|
+
var TASK_COMPLETE_ENTRY, DIRECT_BOOKKEEPING_TOOL_NAMES;
|
|
687419
687641
|
var init_direct_tool_registry = __esm({
|
|
687420
687642
|
"packages/cli/src/api/direct-tool-registry.ts"() {
|
|
687421
687643
|
"use strict";
|
|
@@ -687446,6 +687668,11 @@ var init_direct_tool_registry = __esm({
|
|
|
687446
687668
|
directCallable: true,
|
|
687447
687669
|
virtual: true
|
|
687448
687670
|
};
|
|
687671
|
+
DIRECT_BOOKKEEPING_TOOL_NAMES = /* @__PURE__ */ new Set([
|
|
687672
|
+
"todo_write",
|
|
687673
|
+
"todo_read",
|
|
687674
|
+
"working_notes"
|
|
687675
|
+
]);
|
|
687449
687676
|
}
|
|
687450
687677
|
});
|
|
687451
687678
|
|
|
@@ -691741,17 +691968,18 @@ async function handleCallTool(ctx3, name10) {
|
|
|
691741
691968
|
workingDir = pathResolve3(body.working_dir);
|
|
691742
691969
|
}
|
|
691743
691970
|
const registry4 = await buildDirectToolRegistry(workingDir);
|
|
691744
|
-
const entry = registry4.
|
|
691971
|
+
const entry = registry4.callableByName.get(name10);
|
|
691745
691972
|
if (!entry) {
|
|
691746
691973
|
const ext = getExternalTool(workingDir, name10);
|
|
691747
691974
|
if (ext) {
|
|
691748
691975
|
return callExternalTool(ctx3, ext, args, workingDir, origin, scope, body);
|
|
691749
691976
|
}
|
|
691977
|
+
const builtin = registry4.byName.get(name10);
|
|
691750
691978
|
sendProblem(res, problemDetails({
|
|
691751
691979
|
type: P2.notFound,
|
|
691752
691980
|
status: 404,
|
|
691753
|
-
title: `Tool '${name10}' not found`,
|
|
691754
|
-
detail: "This
|
|
691981
|
+
title: builtin ? `Tool '${name10}' is not direct-callable` : `Tool '${name10}' not found`,
|
|
691982
|
+
detail: builtin ? "This built-in tool is discoverable through GET /v1/tools but is not executable through direct REST calls. Use POST /v1/run for agent-bound workflows." : "No direct-callable built-in or registered external tool with that name. Use GET /v1/tools for schemas or POST /v1/run for full agent execution.",
|
|
691755
691983
|
instance: requestId
|
|
691756
691984
|
}));
|
|
691757
691985
|
return true;
|