omnius 1.0.575 → 1.0.577
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 +1633 -881
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1257,8 +1257,8 @@ var init_model_broker = __esm({
|
|
|
1257
1257
|
}
|
|
1258
1258
|
/** Restore a set of previously evicted Ollama models, oldest first. */
|
|
1259
1259
|
async restoreOllamaModels(models, options2 = {}) {
|
|
1260
|
-
const
|
|
1261
|
-
for (const model of
|
|
1260
|
+
const unique5 = dedupeLoadedModels(models.filter((m2) => m2.host === "ollama")).sort((a2, b) => a2.lastUsedAt - b.lastUsedAt);
|
|
1261
|
+
for (const model of unique5) {
|
|
1262
1262
|
await this.warmOllamaModel(model.name, options2.keepAlive ?? "30m").catch(() => false);
|
|
1263
1263
|
}
|
|
1264
1264
|
}
|
|
@@ -2050,8 +2050,8 @@ function sha256FileIfExists(path16) {
|
|
|
2050
2050
|
function clipEvidenceText(text2, maxChars = 500) {
|
|
2051
2051
|
if (typeof text2 !== "string")
|
|
2052
2052
|
return void 0;
|
|
2053
|
-
const
|
|
2054
|
-
return
|
|
2053
|
+
const clean7 = text2.replace(/\s+/g, " ").trim();
|
|
2054
|
+
return clean7 ? clean7.slice(0, maxChars) : void 0;
|
|
2055
2055
|
}
|
|
2056
2056
|
function createEvidenceObservation(input) {
|
|
2057
2057
|
const screenshotHash = input.screenshotHash ?? sha256FileIfExists(input.screenshotPath);
|
|
@@ -12592,23 +12592,23 @@ function attachDiagnosticListeners(p2) {
|
|
|
12592
12592
|
payload: `WebSocket opened: ${wsUrl}`,
|
|
12593
12593
|
url: wsUrl
|
|
12594
12594
|
});
|
|
12595
|
-
ws.on("framesent", (
|
|
12595
|
+
ws.on("framesent", (frame2) => {
|
|
12596
12596
|
try {
|
|
12597
12597
|
pushBounded(wsBuffer, {
|
|
12598
12598
|
ts: Date.now(),
|
|
12599
12599
|
kind: "send",
|
|
12600
|
-
payload: String(
|
|
12600
|
+
payload: String(frame2.payload ?? "").slice(0, 500),
|
|
12601
12601
|
url: wsUrl
|
|
12602
12602
|
});
|
|
12603
12603
|
} catch {
|
|
12604
12604
|
}
|
|
12605
12605
|
});
|
|
12606
|
-
ws.on("framereceived", (
|
|
12606
|
+
ws.on("framereceived", (frame2) => {
|
|
12607
12607
|
try {
|
|
12608
12608
|
pushBounded(wsBuffer, {
|
|
12609
12609
|
ts: Date.now(),
|
|
12610
12610
|
kind: "recv",
|
|
12611
|
-
payload: String(
|
|
12611
|
+
payload: String(frame2.payload ?? "").slice(0, 500),
|
|
12612
12612
|
url: wsUrl
|
|
12613
12613
|
});
|
|
12614
12614
|
} catch {
|
|
@@ -12765,14 +12765,14 @@ async function describeFocusedEditable(pageHandle) {
|
|
|
12765
12765
|
const frames = typeof pageHandle.frames === "function" ? pageHandle.frames() : [];
|
|
12766
12766
|
const mainFrame = typeof pageHandle.mainFrame === "function" ? pageHandle.mainFrame() : null;
|
|
12767
12767
|
for (let i2 = 0; i2 < frames.length; i2++) {
|
|
12768
|
-
const
|
|
12769
|
-
if (!
|
|
12768
|
+
const frame2 = frames[i2];
|
|
12769
|
+
if (!frame2 || frame2 === mainFrame)
|
|
12770
12770
|
continue;
|
|
12771
|
-
const active = await describeFocusedEditableInContext(
|
|
12771
|
+
const active = await describeFocusedEditableInContext(frame2, {
|
|
12772
12772
|
kind: "frame",
|
|
12773
12773
|
index: i2,
|
|
12774
|
-
url: typeof
|
|
12775
|
-
name: typeof
|
|
12774
|
+
url: typeof frame2.url === "function" ? frame2.url() : "",
|
|
12775
|
+
name: typeof frame2.name === "function" ? frame2.name() : ""
|
|
12776
12776
|
}).catch(() => null);
|
|
12777
12777
|
if (active?.["isEditable"])
|
|
12778
12778
|
return active;
|
|
@@ -13129,10 +13129,10 @@ async function findBrowserVisualCandidate(pageHandle, target, visualX, visualY,
|
|
|
13129
13129
|
const frames = typeof pageHandle.frames === "function" ? pageHandle.frames() : [];
|
|
13130
13130
|
const mainFrame = typeof pageHandle.mainFrame === "function" ? pageHandle.mainFrame() : null;
|
|
13131
13131
|
for (let i2 = 0; i2 < frames.length; i2++) {
|
|
13132
|
-
const
|
|
13133
|
-
if (!
|
|
13132
|
+
const frame2 = frames[i2];
|
|
13133
|
+
if (!frame2 || frame2 === mainFrame)
|
|
13134
13134
|
continue;
|
|
13135
|
-
const elementHandle = typeof
|
|
13135
|
+
const elementHandle = typeof frame2.frameElement === "function" ? await frame2.frameElement().catch(() => null) : null;
|
|
13136
13136
|
if (!elementHandle)
|
|
13137
13137
|
continue;
|
|
13138
13138
|
let box = await elementHandle.boundingBox().catch(() => null);
|
|
@@ -13143,7 +13143,7 @@ async function findBrowserVisualCandidate(pageHandle, target, visualX, visualY,
|
|
|
13143
13143
|
continue;
|
|
13144
13144
|
const localX = Math.max(0, Math.min(box.width, visualX - box.x));
|
|
13145
13145
|
const localY = Math.max(0, Math.min(box.height, visualY - box.y));
|
|
13146
|
-
let candidate = await findBrowserVisualCandidateInContext(
|
|
13146
|
+
let candidate = await findBrowserVisualCandidateInContext(frame2, target, localX, localY, forceCandidate, includeOffscreen, scrollIntoView).catch(() => null);
|
|
13147
13147
|
if (!candidate)
|
|
13148
13148
|
continue;
|
|
13149
13149
|
if (scrollIntoView && (!candidate["visible"] || !frameVisible)) {
|
|
@@ -13161,8 +13161,8 @@ async function findBrowserVisualCandidate(pageHandle, target, visualX, visualY,
|
|
|
13161
13161
|
candidates.push(offsetBrowserCandidate(candidate, { x: box.x, y: box.y }, viewport, {
|
|
13162
13162
|
kind: "frame",
|
|
13163
13163
|
index: i2,
|
|
13164
|
-
url: typeof
|
|
13165
|
-
name: typeof
|
|
13164
|
+
url: typeof frame2.url === "function" ? frame2.url() : "",
|
|
13165
|
+
name: typeof frame2.name === "function" ? frame2.name() : "",
|
|
13166
13166
|
rect: { x: box.x, y: box.y, width: box.width, height: box.height }
|
|
13167
13167
|
}));
|
|
13168
13168
|
}
|
|
@@ -13441,8 +13441,8 @@ var init_playwright_browser = __esm({
|
|
|
13441
13441
|
}
|
|
13442
13442
|
await page.keyboard.type(text2, { delay: typingDelay });
|
|
13443
13443
|
const label = active && typeof active === "object" ? `<${active.tag || "element"}>${active.id ? `#${active.id}` : ""}` : "focused element";
|
|
13444
|
-
const
|
|
13445
|
-
return ok(`Typed "${text2}" into ${label}${
|
|
13444
|
+
const frame2 = active["frame"];
|
|
13445
|
+
return ok(`Typed "${text2}" into ${label}${frame2?.kind === "frame" ? ` in frame ${frame2.index}` : ""}`, start2);
|
|
13446
13446
|
}
|
|
13447
13447
|
case "press": {
|
|
13448
13448
|
const key = text2 || "Enter";
|
|
@@ -17409,8 +17409,8 @@ var init_unifiedMemoryStore = __esm({
|
|
|
17409
17409
|
return matches.filter((match) => match.score >= (options2.minScore ?? 0)).sort((a2, b) => b.score - a2.score).slice(0, limit).map((match, index) => ({ ...match, rank: index + 1 }));
|
|
17410
17410
|
}
|
|
17411
17411
|
recordAccess(itemIds) {
|
|
17412
|
-
const
|
|
17413
|
-
if (
|
|
17412
|
+
const unique5 = [...new Set(itemIds)].filter(Boolean);
|
|
17413
|
+
if (unique5.length === 0)
|
|
17414
17414
|
return;
|
|
17415
17415
|
const update2 = this.db.prepare(`
|
|
17416
17416
|
UPDATE memory_item
|
|
@@ -17420,7 +17420,7 @@ var init_unifiedMemoryStore = __esm({
|
|
|
17420
17420
|
`);
|
|
17421
17421
|
const now2 = this.nowIso();
|
|
17422
17422
|
const txn = this.db.transaction(() => {
|
|
17423
|
-
for (const id2 of
|
|
17423
|
+
for (const id2 of unique5)
|
|
17424
17424
|
update2.run(now2, id2);
|
|
17425
17425
|
});
|
|
17426
17426
|
txn();
|
|
@@ -19808,25 +19808,25 @@ function personalizedPageRank(graph, seedNodeIds, config) {
|
|
|
19808
19808
|
allNodes.add(n2.id);
|
|
19809
19809
|
}
|
|
19810
19810
|
}
|
|
19811
|
-
for (const
|
|
19812
|
-
scores.set(
|
|
19811
|
+
for (const nodeId2 of allNodes) {
|
|
19812
|
+
scores.set(nodeId2, seedSet.has(nodeId2) ? teleportProb : 0);
|
|
19813
19813
|
}
|
|
19814
19814
|
for (let iter = 0; iter < cfg.maxIterations; iter++) {
|
|
19815
19815
|
const newScores = /* @__PURE__ */ new Map();
|
|
19816
19816
|
let maxDelta = 0;
|
|
19817
|
-
for (const
|
|
19818
|
-
const teleport = seedSet.has(
|
|
19817
|
+
for (const nodeId2 of allNodes) {
|
|
19818
|
+
const teleport = seedSet.has(nodeId2) ? (1 - cfg.damping) * teleportProb : 0;
|
|
19819
19819
|
let walkSum = 0;
|
|
19820
|
-
const inEdges = graph.currentEdges(
|
|
19820
|
+
const inEdges = graph.currentEdges(nodeId2);
|
|
19821
19821
|
for (const edge of inEdges) {
|
|
19822
|
-
const neighborId = edge.srcId ===
|
|
19822
|
+
const neighborId = edge.srcId === nodeId2 ? edge.dstId : edge.srcId;
|
|
19823
19823
|
const neighborScore = scores.get(neighborId) ?? 0;
|
|
19824
19824
|
const neighborOutDegree = graph.currentEdges(neighborId).length || 1;
|
|
19825
19825
|
walkSum += neighborScore / neighborOutDegree;
|
|
19826
19826
|
}
|
|
19827
19827
|
const newScore = teleport + cfg.damping * walkSum;
|
|
19828
|
-
newScores.set(
|
|
19829
|
-
const delta = Math.abs(newScore - (scores.get(
|
|
19828
|
+
newScores.set(nodeId2, newScore);
|
|
19829
|
+
const delta = Math.abs(newScore - (scores.get(nodeId2) ?? 0));
|
|
19830
19830
|
if (delta > maxDelta)
|
|
19831
19831
|
maxDelta = delta;
|
|
19832
19832
|
}
|
|
@@ -19873,13 +19873,13 @@ function retrieveByPPR(query, graph, episodeStore, config) {
|
|
|
19873
19873
|
}
|
|
19874
19874
|
const pprScores = personalizedPageRank(graph, seedNodes, cfg);
|
|
19875
19875
|
const episodeScores = /* @__PURE__ */ new Map();
|
|
19876
|
-
for (const [
|
|
19876
|
+
for (const [nodeId2, score] of pprScores) {
|
|
19877
19877
|
if (score < 1e-3)
|
|
19878
19878
|
continue;
|
|
19879
|
-
const node = graph.getNode(
|
|
19879
|
+
const node = graph.getNode(nodeId2);
|
|
19880
19880
|
if (!node)
|
|
19881
19881
|
continue;
|
|
19882
|
-
const edges = graph.currentEdges(
|
|
19882
|
+
const edges = graph.currentEdges(nodeId2);
|
|
19883
19883
|
for (const edge of edges) {
|
|
19884
19884
|
if (edge.sourceEpisodeId) {
|
|
19885
19885
|
const existing = episodeScores.get(edge.sourceEpisodeId);
|
|
@@ -20604,30 +20604,30 @@ var init_temporalGraph = __esm({
|
|
|
20604
20604
|
}
|
|
20605
20605
|
// ─── Temporal queries ────────────────────────────────────────────────────
|
|
20606
20606
|
/** Get currently valid edges for a node. */
|
|
20607
|
-
currentEdges(
|
|
20607
|
+
currentEdges(nodeId2) {
|
|
20608
20608
|
return this.db.prepare(`
|
|
20609
20609
|
SELECT * FROM kg_edges
|
|
20610
20610
|
WHERE (src_id = ? OR dst_id = ?) AND valid_until IS NULL
|
|
20611
20611
|
ORDER BY valid_from DESC
|
|
20612
|
-
`).all(
|
|
20612
|
+
`).all(nodeId2, nodeId2).map((r2) => this.rowToEdge(r2));
|
|
20613
20613
|
}
|
|
20614
20614
|
/** Get edges valid at a specific time. */
|
|
20615
|
-
edgesAtTime(
|
|
20615
|
+
edgesAtTime(nodeId2, timestamp) {
|
|
20616
20616
|
return this.db.prepare(`
|
|
20617
20617
|
SELECT * FROM kg_edges
|
|
20618
20618
|
WHERE (src_id = ? OR dst_id = ?)
|
|
20619
20619
|
AND valid_from <= ?
|
|
20620
20620
|
AND (valid_until IS NULL OR valid_until > ?)
|
|
20621
20621
|
ORDER BY valid_from DESC
|
|
20622
|
-
`).all(
|
|
20622
|
+
`).all(nodeId2, nodeId2, timestamp, timestamp).map((r2) => this.rowToEdge(r2));
|
|
20623
20623
|
}
|
|
20624
20624
|
/** Get full history of a node (all edges, including superseded). */
|
|
20625
|
-
nodeHistory(
|
|
20625
|
+
nodeHistory(nodeId2) {
|
|
20626
20626
|
return this.db.prepare(`
|
|
20627
20627
|
SELECT * FROM kg_edges
|
|
20628
20628
|
WHERE src_id = ? OR dst_id = ?
|
|
20629
20629
|
ORDER BY valid_from ASC
|
|
20630
|
-
`).all(
|
|
20630
|
+
`).all(nodeId2, nodeId2).map((r2) => this.rowToEdge(r2));
|
|
20631
20631
|
}
|
|
20632
20632
|
/** Get edges that changed between two timestamps. */
|
|
20633
20633
|
changedBetween(start2, end) {
|
|
@@ -20638,7 +20638,7 @@ var init_temporalGraph = __esm({
|
|
|
20638
20638
|
`).all(start2, end).map((r2) => this.rowToEdge(r2));
|
|
20639
20639
|
}
|
|
20640
20640
|
/** Find neighbors of a node (1-hop traversal). */
|
|
20641
|
-
neighbors(
|
|
20641
|
+
neighbors(nodeId2, relation) {
|
|
20642
20642
|
let sql = `
|
|
20643
20643
|
SELECT e.*, n.id as n_id, n.text as n_text, n.node_type as n_type,
|
|
20644
20644
|
n.first_seen as n_first, n.last_seen as n_last, n.mention_count as n_mentions
|
|
@@ -20646,7 +20646,7 @@ var init_temporalGraph = __esm({
|
|
|
20646
20646
|
JOIN kg_nodes n ON (e.dst_id = n.id AND e.src_id = ?) OR (e.src_id = n.id AND e.dst_id = ?)
|
|
20647
20647
|
WHERE e.valid_until IS NULL
|
|
20648
20648
|
`;
|
|
20649
|
-
const params = [
|
|
20649
|
+
const params = [nodeId2, nodeId2];
|
|
20650
20650
|
if (relation) {
|
|
20651
20651
|
sql += " AND e.relation = ?";
|
|
20652
20652
|
params.push(relation);
|
|
@@ -21127,14 +21127,14 @@ function selectInnerGraphCandidates(graph, candidates, options2 = {}) {
|
|
|
21127
21127
|
const episodeId = edge.sourceEpisodeId;
|
|
21128
21128
|
if (!episodeId || !candidateEpisodeIds.includes(episodeId))
|
|
21129
21129
|
continue;
|
|
21130
|
-
for (const
|
|
21131
|
-
const node = graph.getNode(
|
|
21130
|
+
for (const nodeId2 of [edge.srcId, edge.dstId]) {
|
|
21131
|
+
const node = graph.getNode(nodeId2);
|
|
21132
21132
|
if (!node)
|
|
21133
21133
|
continue;
|
|
21134
|
-
const entry = byNode.get(
|
|
21134
|
+
const entry = byNode.get(nodeId2) ?? { node, candidateEpisodeIds: /* @__PURE__ */ new Set(), edges: /* @__PURE__ */ new Map() };
|
|
21135
21135
|
entry.candidateEpisodeIds.add(episodeId);
|
|
21136
21136
|
entry.edges.set(edgeKey(edge), edge);
|
|
21137
|
-
byNode.set(
|
|
21137
|
+
byNode.set(nodeId2, entry);
|
|
21138
21138
|
}
|
|
21139
21139
|
}
|
|
21140
21140
|
const now2 = Date.now();
|
|
@@ -26246,9 +26246,9 @@ function loadEpisodeCandidates(db, limit) {
|
|
|
26246
26246
|
}
|
|
26247
26247
|
}
|
|
26248
26248
|
function deleteEpisodes(db, ids, dryRun) {
|
|
26249
|
-
const
|
|
26250
|
-
if (dryRun ||
|
|
26251
|
-
return
|
|
26249
|
+
const unique5 = [...new Set(ids)].filter(Boolean);
|
|
26250
|
+
if (dryRun || unique5.length === 0)
|
|
26251
|
+
return unique5.length;
|
|
26252
26252
|
let deleted = 0;
|
|
26253
26253
|
const stmt = db.prepare(`DELETE FROM episodes WHERE id = ?`);
|
|
26254
26254
|
const tx = db.transaction((rows) => {
|
|
@@ -26257,7 +26257,7 @@ function deleteEpisodes(db, ids, dryRun) {
|
|
|
26257
26257
|
deleted += Number(result.changes ?? 0);
|
|
26258
26258
|
}
|
|
26259
26259
|
});
|
|
26260
|
-
tx(
|
|
26260
|
+
tx(unique5);
|
|
26261
26261
|
return deleted;
|
|
26262
26262
|
}
|
|
26263
26263
|
function maintainGraph(dbPath, options2, shouldStop) {
|
|
@@ -26358,7 +26358,7 @@ function vectorDuplicateNodePairs(rows, threshold) {
|
|
|
26358
26358
|
}
|
|
26359
26359
|
function mergeGraphNodes(db, pairs, dryRun) {
|
|
26360
26360
|
const seen = /* @__PURE__ */ new Set();
|
|
26361
|
-
const
|
|
26361
|
+
const unique5 = pairs.filter((pair) => {
|
|
26362
26362
|
if (!pair.keepId || !pair.dropId || pair.keepId === pair.dropId)
|
|
26363
26363
|
return false;
|
|
26364
26364
|
if (seen.has(pair.dropId))
|
|
@@ -26366,8 +26366,8 @@ function mergeGraphNodes(db, pairs, dryRun) {
|
|
|
26366
26366
|
seen.add(pair.dropId);
|
|
26367
26367
|
return true;
|
|
26368
26368
|
});
|
|
26369
|
-
if (dryRun ||
|
|
26370
|
-
return
|
|
26369
|
+
if (dryRun || unique5.length === 0)
|
|
26370
|
+
return unique5.length;
|
|
26371
26371
|
let merged = 0;
|
|
26372
26372
|
const tx = db.transaction((rows) => {
|
|
26373
26373
|
const src2 = db.prepare(`UPDATE kg_edges SET src_id = ? WHERE src_id = ?`);
|
|
@@ -26385,7 +26385,7 @@ function mergeGraphNodes(db, pairs, dryRun) {
|
|
|
26385
26385
|
merged += Number(deleted.changes ?? 0);
|
|
26386
26386
|
}
|
|
26387
26387
|
});
|
|
26388
|
-
tx(
|
|
26388
|
+
tx(unique5);
|
|
26389
26389
|
return merged;
|
|
26390
26390
|
}
|
|
26391
26391
|
function dedupeGraphEdges(db, limit, dryRun) {
|
|
@@ -43755,8 +43755,8 @@ function tokenizeSkillQuery(value2) {
|
|
|
43755
43755
|
return out;
|
|
43756
43756
|
}
|
|
43757
43757
|
function compactSkillLine(value2, max = 180) {
|
|
43758
|
-
const
|
|
43759
|
-
return
|
|
43758
|
+
const clean7 = value2.replace(/\s+/g, " ").trim();
|
|
43759
|
+
return clean7.length > max ? `${clean7.slice(0, Math.max(0, max - 3)).trimEnd()}...` : clean7;
|
|
43760
43760
|
}
|
|
43761
43761
|
function skillHaystack(skill) {
|
|
43762
43762
|
return [
|
|
@@ -63402,7 +63402,7 @@ var init_key = __esm({
|
|
|
63402
63402
|
* @param {string | Uint8Array} s
|
|
63403
63403
|
* @param {boolean} [clean]
|
|
63404
63404
|
*/
|
|
63405
|
-
constructor(s2,
|
|
63405
|
+
constructor(s2, clean7) {
|
|
63406
63406
|
if (typeof s2 === "string") {
|
|
63407
63407
|
this._buf = fromString2(s2);
|
|
63408
63408
|
} else if (s2 instanceof Uint8Array) {
|
|
@@ -63410,10 +63410,10 @@ var init_key = __esm({
|
|
|
63410
63410
|
} else {
|
|
63411
63411
|
throw new Error("Invalid key, should be String of Uint8Array");
|
|
63412
63412
|
}
|
|
63413
|
-
if (
|
|
63414
|
-
|
|
63413
|
+
if (clean7 == null) {
|
|
63414
|
+
clean7 = true;
|
|
63415
63415
|
}
|
|
63416
|
-
if (
|
|
63416
|
+
if (clean7) {
|
|
63417
63417
|
this.clean();
|
|
63418
63418
|
}
|
|
63419
63419
|
if (this._buf.byteLength === 0 || this._buf[0] !== pathSep) {
|
|
@@ -88706,8 +88706,8 @@ var init_config4 = __esm({
|
|
|
88706
88706
|
});
|
|
88707
88707
|
|
|
88708
88708
|
// ../node_modules/@chainsafe/libp2p-yamux/dist/src/decode.js
|
|
88709
|
-
function isDataFrame(
|
|
88710
|
-
return
|
|
88709
|
+
function isDataFrame(frame2) {
|
|
88710
|
+
return frame2.header.type === FrameType.Data && frame2.data !== null;
|
|
88711
88711
|
}
|
|
88712
88712
|
function decodeHeader(data) {
|
|
88713
88713
|
if (data[0] !== YAMUX_VERSION) {
|
|
@@ -88742,11 +88742,11 @@ var init_decode5 = __esm({
|
|
|
88742
88742
|
*emitFrames(buf) {
|
|
88743
88743
|
this.buffer.append(buf);
|
|
88744
88744
|
while (true) {
|
|
88745
|
-
const
|
|
88746
|
-
if (
|
|
88745
|
+
const frame2 = this.readFrame();
|
|
88746
|
+
if (frame2 === void 0) {
|
|
88747
88747
|
break;
|
|
88748
88748
|
}
|
|
88749
|
-
yield
|
|
88749
|
+
yield frame2;
|
|
88750
88750
|
}
|
|
88751
88751
|
}
|
|
88752
88752
|
readFrame() {
|
|
@@ -88773,19 +88773,19 @@ var init_decode5 = __esm({
|
|
|
88773
88773
|
|
|
88774
88774
|
// ../node_modules/@chainsafe/libp2p-yamux/dist/src/encode.js
|
|
88775
88775
|
function encodeHeader(header) {
|
|
88776
|
-
const
|
|
88777
|
-
|
|
88778
|
-
|
|
88779
|
-
|
|
88780
|
-
|
|
88781
|
-
|
|
88782
|
-
|
|
88783
|
-
|
|
88784
|
-
|
|
88785
|
-
|
|
88786
|
-
|
|
88787
|
-
|
|
88788
|
-
return
|
|
88776
|
+
const frame2 = new Uint8Array(HEADER_LENGTH);
|
|
88777
|
+
frame2[1] = header.type;
|
|
88778
|
+
frame2[2] = header.flag >>> 8;
|
|
88779
|
+
frame2[3] = header.flag;
|
|
88780
|
+
frame2[4] = header.streamID >>> 24;
|
|
88781
|
+
frame2[5] = header.streamID >>> 16;
|
|
88782
|
+
frame2[6] = header.streamID >>> 8;
|
|
88783
|
+
frame2[7] = header.streamID;
|
|
88784
|
+
frame2[8] = header.length >>> 24;
|
|
88785
|
+
frame2[9] = header.length >>> 16;
|
|
88786
|
+
frame2[10] = header.length >>> 8;
|
|
88787
|
+
frame2[11] = header.length;
|
|
88788
|
+
return frame2;
|
|
88789
88789
|
}
|
|
88790
88790
|
var init_encode5 = __esm({
|
|
88791
88791
|
"../node_modules/@chainsafe/libp2p-yamux/dist/src/encode.js"() {
|
|
@@ -88934,9 +88934,9 @@ var init_stream2 = __esm({
|
|
|
88934
88934
|
/**
|
|
88935
88935
|
* handleWindowUpdate is called when the stream receives a window update frame
|
|
88936
88936
|
*/
|
|
88937
|
-
handleWindowUpdate(
|
|
88938
|
-
this.processFlags(
|
|
88939
|
-
this.sendWindowCapacity +=
|
|
88937
|
+
handleWindowUpdate(frame2) {
|
|
88938
|
+
this.processFlags(frame2.header.flag);
|
|
88939
|
+
this.sendWindowCapacity += frame2.header.length;
|
|
88940
88940
|
this.maxMessageSize = this.sendWindowCapacity - HEADER_LENGTH;
|
|
88941
88941
|
if (this.maxMessageSize < 0) {
|
|
88942
88942
|
this.maxMessageSize = 0;
|
|
@@ -88945,23 +88945,23 @@ var init_stream2 = __esm({
|
|
|
88945
88945
|
return;
|
|
88946
88946
|
}
|
|
88947
88947
|
if (this.writeBuffer.byteLength > 0) {
|
|
88948
|
-
this.log?.trace("window update of %d bytes allows more data to be sent, have %d bytes queued, sending data %s",
|
|
88948
|
+
this.log?.trace("window update of %d bytes allows more data to be sent, have %d bytes queued, sending data %s", frame2.header.length, this.writeBuffer.byteLength, this.sendingData);
|
|
88949
88949
|
this.safeDispatchEvent("drain");
|
|
88950
88950
|
}
|
|
88951
88951
|
}
|
|
88952
88952
|
/**
|
|
88953
88953
|
* handleData is called when the stream receives a data frame
|
|
88954
88954
|
*/
|
|
88955
|
-
handleData(
|
|
88956
|
-
if (!isDataFrame(
|
|
88955
|
+
handleData(frame2) {
|
|
88956
|
+
if (!isDataFrame(frame2)) {
|
|
88957
88957
|
throw new InvalidFrameError("Frame was not data frame");
|
|
88958
88958
|
}
|
|
88959
|
-
this.processFlags(
|
|
88960
|
-
if (this.recvWindowCapacity <
|
|
88959
|
+
this.processFlags(frame2.header.flag);
|
|
88960
|
+
if (this.recvWindowCapacity < frame2.header.length) {
|
|
88961
88961
|
throw new ReceiveWindowExceededError("Receive window exceeded");
|
|
88962
88962
|
}
|
|
88963
|
-
this.recvWindowCapacity -=
|
|
88964
|
-
this.onData(
|
|
88963
|
+
this.recvWindowCapacity -= frame2.header.length;
|
|
88964
|
+
this.onData(frame2.data);
|
|
88965
88965
|
this.sendWindowUpdate();
|
|
88966
88966
|
}
|
|
88967
88967
|
/**
|
|
@@ -89132,8 +89132,8 @@ var init_muxer = __esm({
|
|
|
89132
89132
|
}
|
|
89133
89133
|
}
|
|
89134
89134
|
onData(buf) {
|
|
89135
|
-
for (const
|
|
89136
|
-
this.handleFrame(
|
|
89135
|
+
for (const frame2 of this.decoder.emitFrames(buf)) {
|
|
89136
|
+
this.handleFrame(frame2);
|
|
89137
89137
|
}
|
|
89138
89138
|
}
|
|
89139
89139
|
onCreateStream() {
|
|
@@ -89268,13 +89268,13 @@ var init_muxer = __esm({
|
|
|
89268
89268
|
this.numOutboundStreams--;
|
|
89269
89269
|
}
|
|
89270
89270
|
}
|
|
89271
|
-
handleFrame(
|
|
89272
|
-
const { streamID, type, length: length4 } =
|
|
89273
|
-
this.log.trace("received frame %o", debugFrame(
|
|
89271
|
+
handleFrame(frame2) {
|
|
89272
|
+
const { streamID, type, length: length4 } = frame2.header;
|
|
89273
|
+
this.log.trace("received frame %o", debugFrame(frame2.header));
|
|
89274
89274
|
if (streamID === 0) {
|
|
89275
89275
|
switch (type) {
|
|
89276
89276
|
case FrameType.Ping: {
|
|
89277
|
-
this.handlePing(
|
|
89277
|
+
this.handlePing(frame2.header);
|
|
89278
89278
|
return;
|
|
89279
89279
|
}
|
|
89280
89280
|
case FrameType.GoAway: {
|
|
@@ -89285,10 +89285,10 @@ var init_muxer = __esm({
|
|
|
89285
89285
|
throw new InvalidFrameError("Invalid frame type");
|
|
89286
89286
|
}
|
|
89287
89287
|
} else {
|
|
89288
|
-
switch (
|
|
89288
|
+
switch (frame2.header.type) {
|
|
89289
89289
|
case FrameType.Data:
|
|
89290
89290
|
case FrameType.WindowUpdate: {
|
|
89291
|
-
this.handleStreamMessage(
|
|
89291
|
+
this.handleStreamMessage(frame2);
|
|
89292
89292
|
return;
|
|
89293
89293
|
}
|
|
89294
89294
|
default:
|
|
@@ -89325,8 +89325,8 @@ var init_muxer = __esm({
|
|
|
89325
89325
|
this.abort(new Error("Remote sent GoAway"));
|
|
89326
89326
|
}
|
|
89327
89327
|
}
|
|
89328
|
-
handleStreamMessage(
|
|
89329
|
-
const { streamID, flag, type } =
|
|
89328
|
+
handleStreamMessage(frame2) {
|
|
89329
|
+
const { streamID, flag, type } = frame2.header;
|
|
89330
89330
|
if ((flag & Flag.SYN) === Flag.SYN) {
|
|
89331
89331
|
this.incomingStream(streamID);
|
|
89332
89332
|
}
|
|
@@ -89337,11 +89337,11 @@ var init_muxer = __esm({
|
|
|
89337
89337
|
}
|
|
89338
89338
|
switch (type) {
|
|
89339
89339
|
case FrameType.WindowUpdate: {
|
|
89340
|
-
stream.handleWindowUpdate(
|
|
89340
|
+
stream.handleWindowUpdate(frame2);
|
|
89341
89341
|
return;
|
|
89342
89342
|
}
|
|
89343
89343
|
case FrameType.Data: {
|
|
89344
|
-
stream.handleData(
|
|
89344
|
+
stream.handleData(frame2);
|
|
89345
89345
|
return;
|
|
89346
89346
|
}
|
|
89347
89347
|
default:
|
|
@@ -113682,10 +113682,10 @@ var require_abort = __commonJS({
|
|
|
113682
113682
|
"../node_modules/asynckit/lib/abort.js"(exports, module) {
|
|
113683
113683
|
module.exports = abort;
|
|
113684
113684
|
function abort(state) {
|
|
113685
|
-
Object.keys(state.jobs).forEach(
|
|
113685
|
+
Object.keys(state.jobs).forEach(clean7.bind(state));
|
|
113686
113686
|
state.jobs = {};
|
|
113687
113687
|
}
|
|
113688
|
-
function
|
|
113688
|
+
function clean7(key) {
|
|
113689
113689
|
if (typeof this.jobs[key] == "function") {
|
|
113690
113690
|
this.jobs[key]();
|
|
113691
113691
|
}
|
|
@@ -165547,24 +165547,24 @@ var require_connection = __commonJS({
|
|
|
165547
165547
|
failWebsocketConnection(object);
|
|
165548
165548
|
object.readyState = states2.CLOSING;
|
|
165549
165549
|
} else if (!object.closeState.has(sentCloseFrameState.SENT) && !object.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
165550
|
-
const
|
|
165550
|
+
const frame2 = new WebsocketFrameSend();
|
|
165551
165551
|
if (reason.length !== 0 && code8 === null) {
|
|
165552
165552
|
code8 = 1e3;
|
|
165553
165553
|
}
|
|
165554
165554
|
assert(code8 === null || Number.isInteger(code8));
|
|
165555
165555
|
if (code8 === null && reason.length === 0) {
|
|
165556
|
-
|
|
165556
|
+
frame2.frameData = emptyBuffer;
|
|
165557
165557
|
} else if (code8 !== null && reason === null) {
|
|
165558
|
-
|
|
165559
|
-
|
|
165558
|
+
frame2.frameData = Buffer.allocUnsafe(2);
|
|
165559
|
+
frame2.frameData.writeUInt16BE(code8, 0);
|
|
165560
165560
|
} else if (code8 !== null && reason !== null) {
|
|
165561
|
-
|
|
165562
|
-
|
|
165563
|
-
|
|
165561
|
+
frame2.frameData = Buffer.allocUnsafe(2 + Buffer.byteLength(reason));
|
|
165562
|
+
frame2.frameData.writeUInt16BE(code8, 0);
|
|
165563
|
+
frame2.frameData.write(reason, 2, "utf-8");
|
|
165564
165564
|
} else {
|
|
165565
|
-
|
|
165565
|
+
frame2.frameData = emptyBuffer;
|
|
165566
165566
|
}
|
|
165567
|
-
object.socket.write(
|
|
165567
|
+
object.socket.write(frame2.createFrame(opcodes.CLOSE));
|
|
165568
165568
|
object.closeState.add(sentCloseFrameState.SENT);
|
|
165569
165569
|
object.readyState = states2.CLOSING;
|
|
165570
165570
|
} else {
|
|
@@ -165982,8 +165982,8 @@ var require_receiver = __commonJS({
|
|
|
165982
165982
|
return false;
|
|
165983
165983
|
} else if (opcode === opcodes.PING) {
|
|
165984
165984
|
if (!this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
165985
|
-
const
|
|
165986
|
-
this.#handler.socket.write(
|
|
165985
|
+
const frame2 = new WebsocketFrameSend(body);
|
|
165986
|
+
this.#handler.socket.write(frame2.createFrame(opcodes.PONG));
|
|
165987
165987
|
this.#handler.onPing(body);
|
|
165988
165988
|
}
|
|
165989
165989
|
} else if (opcode === opcodes.PONG) {
|
|
@@ -166482,8 +166482,8 @@ var require_websocket = __commonJS({
|
|
|
166482
166482
|
}
|
|
166483
166483
|
const readyState = ws.#handler.readyState;
|
|
166484
166484
|
if (isEstablished(readyState) && !isClosing(readyState) && !isClosed(readyState)) {
|
|
166485
|
-
const
|
|
166486
|
-
ws.#handler.socket.write(
|
|
166485
|
+
const frame2 = new WebsocketFrameSend(buffer2);
|
|
166486
|
+
ws.#handler.socket.write(frame2.createFrame(opcodes.PING));
|
|
166487
166487
|
}
|
|
166488
166488
|
}
|
|
166489
166489
|
};
|
|
@@ -166812,8 +166812,8 @@ var require_websocketstream = __commonJS({
|
|
|
166812
166812
|
opcode = opcodes.TEXT;
|
|
166813
166813
|
}
|
|
166814
166814
|
if (!this.#handler.closeState.has(sentCloseFrameState.SENT) && !this.#handler.closeState.has(sentCloseFrameState.RECEIVED)) {
|
|
166815
|
-
const
|
|
166816
|
-
this.#handler.socket.write(
|
|
166815
|
+
const frame2 = new WebsocketFrameSend(data);
|
|
166816
|
+
this.#handler.socket.write(frame2.createFrame(opcode), () => {
|
|
166817
166817
|
promise.resolve(void 0);
|
|
166818
166818
|
});
|
|
166819
166819
|
}
|
|
@@ -279771,22 +279771,22 @@ async function runProcess2(command, args, options2) {
|
|
|
279771
279771
|
return;
|
|
279772
279772
|
const parts = raw.split(/[\r\n]+/).filter((part) => part.trim());
|
|
279773
279773
|
for (const part of parts.length > 0 ? parts : [raw]) {
|
|
279774
|
-
const
|
|
279775
|
-
if (!
|
|
279774
|
+
const clean7 = cleanProgressText(part);
|
|
279775
|
+
if (!clean7)
|
|
279776
279776
|
continue;
|
|
279777
279777
|
const now2 = Date.now();
|
|
279778
|
-
const structured = parseStructuredProgress(
|
|
279779
|
-
if (
|
|
279778
|
+
const structured = parseStructuredProgress(clean7);
|
|
279779
|
+
if (clean7 === lastProgress && now2 - lastProgressAt < 750)
|
|
279780
279780
|
continue;
|
|
279781
|
-
lastProgress =
|
|
279781
|
+
lastProgress = clean7;
|
|
279782
279782
|
lastProgressAt = now2;
|
|
279783
279783
|
if (structured) {
|
|
279784
279784
|
options2.onProgress({ ...structured, elapsedMs: now2 - startedAt2 });
|
|
279785
279785
|
} else {
|
|
279786
279786
|
options2.onProgress({
|
|
279787
279787
|
stage: stream === "stderr" ? "download" : "process",
|
|
279788
|
-
message:
|
|
279789
|
-
percent: parsePercent(
|
|
279788
|
+
message: clean7.length > 220 ? clean7.slice(0, 217) + "..." : clean7,
|
|
279789
|
+
percent: parsePercent(clean7),
|
|
279790
279790
|
elapsedMs: now2 - startedAt2
|
|
279791
279791
|
});
|
|
279792
279792
|
}
|
|
@@ -279829,10 +279829,10 @@ async function runProcess2(command, args, options2) {
|
|
|
279829
279829
|
});
|
|
279830
279830
|
}
|
|
279831
279831
|
function trimProcessText(text2, max = 1800) {
|
|
279832
|
-
const
|
|
279833
|
-
if (
|
|
279834
|
-
return
|
|
279835
|
-
return
|
|
279832
|
+
const clean7 = text2.trim();
|
|
279833
|
+
if (clean7.length <= max)
|
|
279834
|
+
return clean7;
|
|
279835
|
+
return clean7.slice(0, max - 20) + "\n... (truncated)";
|
|
279836
279836
|
}
|
|
279837
279837
|
function formatDiffusersFailure(stderrOrStdout) {
|
|
279838
279838
|
const text2 = trimProcessText(stderrOrStdout);
|
|
@@ -282146,13 +282146,13 @@ ${message2}
|
|
|
282146
282146
|
return;
|
|
282147
282147
|
const parts = raw.split(/[\r\n]+/).filter((part) => part.trim());
|
|
282148
282148
|
for (const part of parts.length > 0 ? parts : [raw]) {
|
|
282149
|
-
const
|
|
282150
|
-
if (!
|
|
282149
|
+
const clean7 = cleanProgressText2(part);
|
|
282150
|
+
if (!clean7)
|
|
282151
282151
|
continue;
|
|
282152
|
-
const jsonStart =
|
|
282152
|
+
const jsonStart = clean7.indexOf("{");
|
|
282153
282153
|
if (jsonStart >= 0) {
|
|
282154
282154
|
try {
|
|
282155
|
-
const payload = JSON.parse(
|
|
282155
|
+
const payload = JSON.parse(clean7.slice(jsonStart));
|
|
282156
282156
|
if (payload.omnius_progress && payload.stage && payload.message) {
|
|
282157
282157
|
const rawTotalBytes = typeof payload.totalBytes === "number" ? payload.totalBytes : typeof payload.total_bytes === "number" ? payload.total_bytes : void 0;
|
|
282158
282158
|
const rawDownloadedBytes = typeof payload.downloadedBytes === "number" ? payload.downloadedBytes : typeof payload.downloaded_bytes === "number" ? payload.downloaded_bytes : void 0;
|
|
@@ -282179,10 +282179,10 @@ ${message2}
|
|
|
282179
282179
|
}
|
|
282180
282180
|
}
|
|
282181
282181
|
const now2 = Date.now();
|
|
282182
|
-
if (
|
|
282183
|
-
lastProgress =
|
|
282182
|
+
if (clean7 !== lastProgress || now2 - lastProgressAt > 1500) {
|
|
282183
|
+
lastProgress = clean7;
|
|
282184
282184
|
lastProgressAt = now2;
|
|
282185
|
-
options2.onProgress?.({ stage: "process", message:
|
|
282185
|
+
options2.onProgress?.({ stage: "process", message: clean7.slice(0, 180), elapsedMs: now2 - startedAt2 });
|
|
282186
282186
|
}
|
|
282187
282187
|
}
|
|
282188
282188
|
};
|
|
@@ -282259,10 +282259,10 @@ ${message2}
|
|
|
282259
282259
|
});
|
|
282260
282260
|
}
|
|
282261
282261
|
function trimProcessText2(text2, max = 1800) {
|
|
282262
|
-
const
|
|
282263
|
-
if (
|
|
282264
|
-
return
|
|
282265
|
-
return
|
|
282262
|
+
const clean7 = text2.trim();
|
|
282263
|
+
if (clean7.length <= max)
|
|
282264
|
+
return clean7;
|
|
282265
|
+
return clean7.slice(0, max - 20) + "\n... (truncated)";
|
|
282266
282266
|
}
|
|
282267
282267
|
async function pythonCanImport2(command, code8, repoRoot, env2) {
|
|
282268
282268
|
return (await pythonImportResult(command, code8, repoRoot, env2)).code === 0;
|
|
@@ -282714,10 +282714,10 @@ function summarizeToolResult2(result) {
|
|
|
282714
282714
|
return trimProcessText2(String(result.error || result.output || "unknown error"), 700).replace(/\s+/g, " ").trim();
|
|
282715
282715
|
}
|
|
282716
282716
|
function summarizeFallbackProgressReason(reason, max = 260) {
|
|
282717
|
-
const
|
|
282718
|
-
if (
|
|
282719
|
-
return
|
|
282720
|
-
return
|
|
282717
|
+
const clean7 = reason.replace(/\s+/g, " ").trim();
|
|
282718
|
+
if (clean7.length <= max)
|
|
282719
|
+
return clean7;
|
|
282720
|
+
return clean7.slice(0, max - 3).trimEnd() + "...";
|
|
282721
282721
|
}
|
|
282722
282722
|
function formatAudioAttempt(candidate, reason, index) {
|
|
282723
282723
|
return `${index + 1}. ${candidate.model} [${candidate.backend}] - ${reason}`;
|
|
@@ -286183,22 +286183,22 @@ async function runProcess4(command, args, options2) {
|
|
|
286183
286183
|
return;
|
|
286184
286184
|
const parts = raw.split(/[\r\n]+/).filter((part) => part.trim());
|
|
286185
286185
|
for (const part of parts.length > 0 ? parts : [raw]) {
|
|
286186
|
-
const
|
|
286187
|
-
if (!
|
|
286186
|
+
const clean7 = cleanProgressText3(part);
|
|
286187
|
+
if (!clean7)
|
|
286188
286188
|
continue;
|
|
286189
286189
|
const now2 = Date.now();
|
|
286190
|
-
const structured = parseStructuredProgress2(
|
|
286191
|
-
if (
|
|
286190
|
+
const structured = parseStructuredProgress2(clean7);
|
|
286191
|
+
if (clean7 === lastProgress && now2 - lastProgressAt < 750)
|
|
286192
286192
|
continue;
|
|
286193
|
-
lastProgress =
|
|
286193
|
+
lastProgress = clean7;
|
|
286194
286194
|
lastProgressAt = now2;
|
|
286195
286195
|
if (structured) {
|
|
286196
286196
|
options2.onProgress({ ...structured, elapsedMs: now2 - startedAt2 });
|
|
286197
286197
|
} else {
|
|
286198
286198
|
options2.onProgress({
|
|
286199
286199
|
stage: stream === "stderr" ? "download" : "process",
|
|
286200
|
-
message:
|
|
286201
|
-
percent: parsePercent2(
|
|
286200
|
+
message: clean7.length > 220 ? clean7.slice(0, 217) + "..." : clean7,
|
|
286201
|
+
percent: parsePercent2(clean7),
|
|
286202
286202
|
elapsedMs: now2 - startedAt2
|
|
286203
286203
|
});
|
|
286204
286204
|
}
|
|
@@ -286241,10 +286241,10 @@ async function runProcess4(command, args, options2) {
|
|
|
286241
286241
|
});
|
|
286242
286242
|
}
|
|
286243
286243
|
function trimProcessText3(text2, max = 1800) {
|
|
286244
|
-
const
|
|
286245
|
-
if (
|
|
286246
|
-
return
|
|
286247
|
-
return
|
|
286244
|
+
const clean7 = text2.trim();
|
|
286245
|
+
if (clean7.length <= max)
|
|
286246
|
+
return clean7;
|
|
286247
|
+
return clean7.slice(0, max - 20) + "\n... (truncated)";
|
|
286248
286248
|
}
|
|
286249
286249
|
function formatVideoFailure(stderrOrStdout) {
|
|
286250
286250
|
const text2 = trimProcessText3(stderrOrStdout);
|
|
@@ -291653,8 +291653,8 @@ function clampInteger2(value2, fallback, min, max) {
|
|
|
291653
291653
|
return Math.max(min, Math.min(max, Math.floor(parsed)));
|
|
291654
291654
|
}
|
|
291655
291655
|
function sanitizeSessionId(raw) {
|
|
291656
|
-
const
|
|
291657
|
-
return
|
|
291656
|
+
const clean7 = raw.toLowerCase().replace(/[^a-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
291657
|
+
return clean7.slice(0, 80) || "default";
|
|
291658
291658
|
}
|
|
291659
291659
|
function timestampSlug2() {
|
|
291660
291660
|
return (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
|
|
@@ -304003,31 +304003,31 @@ var require_source_map_support = __commonJS({
|
|
|
304003
304003
|
}
|
|
304004
304004
|
return line;
|
|
304005
304005
|
}
|
|
304006
|
-
function cloneCallSite(
|
|
304006
|
+
function cloneCallSite(frame2) {
|
|
304007
304007
|
var object = {};
|
|
304008
|
-
Object.getOwnPropertyNames(Object.getPrototypeOf(
|
|
304008
|
+
Object.getOwnPropertyNames(Object.getPrototypeOf(frame2)).forEach(function(name10) {
|
|
304009
304009
|
object[name10] = /^(?:is|get)/.test(name10) ? function() {
|
|
304010
|
-
return
|
|
304011
|
-
} :
|
|
304010
|
+
return frame2[name10].call(frame2);
|
|
304011
|
+
} : frame2[name10];
|
|
304012
304012
|
});
|
|
304013
304013
|
object.toString = CallSiteToString;
|
|
304014
304014
|
return object;
|
|
304015
304015
|
}
|
|
304016
|
-
function wrapCallSite(
|
|
304016
|
+
function wrapCallSite(frame2, state) {
|
|
304017
304017
|
if (state === void 0) {
|
|
304018
304018
|
state = { nextPosition: null, curPosition: null };
|
|
304019
304019
|
}
|
|
304020
|
-
if (
|
|
304020
|
+
if (frame2.isNative()) {
|
|
304021
304021
|
state.curPosition = null;
|
|
304022
|
-
return
|
|
304022
|
+
return frame2;
|
|
304023
304023
|
}
|
|
304024
|
-
var source =
|
|
304024
|
+
var source = frame2.getFileName() || frame2.getScriptNameOrSourceURL();
|
|
304025
304025
|
if (source) {
|
|
304026
|
-
var line =
|
|
304027
|
-
var column =
|
|
304026
|
+
var line = frame2.getLineNumber();
|
|
304027
|
+
var column = frame2.getColumnNumber() - 1;
|
|
304028
304028
|
var noHeader = /^v(10\.1[6-9]|10\.[2-9][0-9]|10\.[0-9]{3,}|1[2-9]\d*|[2-9]\d|\d{3,}|11\.11)/;
|
|
304029
304029
|
var headerLength = noHeader.test(globalProcessVersion()) ? 0 : 62;
|
|
304030
|
-
if (line === 1 && column > headerLength && !isInBrowser() && !
|
|
304030
|
+
if (line === 1 && column > headerLength && !isInBrowser() && !frame2.isEval()) {
|
|
304031
304031
|
column -= headerLength;
|
|
304032
304032
|
}
|
|
304033
304033
|
var position = mapSourcePosition({
|
|
@@ -304036,38 +304036,38 @@ var require_source_map_support = __commonJS({
|
|
|
304036
304036
|
column
|
|
304037
304037
|
});
|
|
304038
304038
|
state.curPosition = position;
|
|
304039
|
-
|
|
304040
|
-
var originalFunctionName =
|
|
304041
|
-
|
|
304039
|
+
frame2 = cloneCallSite(frame2);
|
|
304040
|
+
var originalFunctionName = frame2.getFunctionName;
|
|
304041
|
+
frame2.getFunctionName = function() {
|
|
304042
304042
|
if (state.nextPosition == null) {
|
|
304043
304043
|
return originalFunctionName();
|
|
304044
304044
|
}
|
|
304045
304045
|
return state.nextPosition.name || originalFunctionName();
|
|
304046
304046
|
};
|
|
304047
|
-
|
|
304047
|
+
frame2.getFileName = function() {
|
|
304048
304048
|
return position.source;
|
|
304049
304049
|
};
|
|
304050
|
-
|
|
304050
|
+
frame2.getLineNumber = function() {
|
|
304051
304051
|
return position.line;
|
|
304052
304052
|
};
|
|
304053
|
-
|
|
304053
|
+
frame2.getColumnNumber = function() {
|
|
304054
304054
|
return position.column + 1;
|
|
304055
304055
|
};
|
|
304056
|
-
|
|
304056
|
+
frame2.getScriptNameOrSourceURL = function() {
|
|
304057
304057
|
return position.source;
|
|
304058
304058
|
};
|
|
304059
|
-
return
|
|
304059
|
+
return frame2;
|
|
304060
304060
|
}
|
|
304061
|
-
var origin =
|
|
304061
|
+
var origin = frame2.isEval() && frame2.getEvalOrigin();
|
|
304062
304062
|
if (origin) {
|
|
304063
304063
|
origin = mapEvalOrigin(origin);
|
|
304064
|
-
|
|
304065
|
-
|
|
304064
|
+
frame2 = cloneCallSite(frame2);
|
|
304065
|
+
frame2.getEvalOrigin = function() {
|
|
304066
304066
|
return origin;
|
|
304067
304067
|
};
|
|
304068
|
-
return
|
|
304068
|
+
return frame2;
|
|
304069
304069
|
}
|
|
304070
|
-
return
|
|
304070
|
+
return frame2;
|
|
304071
304071
|
}
|
|
304072
304072
|
function prepareStackTrace(error, stack) {
|
|
304073
304073
|
if (emptyCacheBetweenOperations) {
|
|
@@ -354266,13 +354266,13 @@ ${lanes.join("\n")}
|
|
|
354266
354266
|
return node.body ? getModuleInstanceStateCached(node.body, visited) : 1;
|
|
354267
354267
|
}
|
|
354268
354268
|
function getModuleInstanceStateCached(node, visited = /* @__PURE__ */ new Map()) {
|
|
354269
|
-
const
|
|
354270
|
-
if (visited.has(
|
|
354271
|
-
return visited.get(
|
|
354269
|
+
const nodeId2 = getNodeId(node);
|
|
354270
|
+
if (visited.has(nodeId2)) {
|
|
354271
|
+
return visited.get(nodeId2) || 0;
|
|
354272
354272
|
}
|
|
354273
|
-
visited.set(
|
|
354273
|
+
visited.set(nodeId2, void 0);
|
|
354274
354274
|
const result = getModuleInstanceStateWorker(node, visited);
|
|
354275
|
-
visited.set(
|
|
354275
|
+
visited.set(nodeId2, result);
|
|
354276
354276
|
return result;
|
|
354277
354277
|
}
|
|
354278
354278
|
function getModuleInstanceStateWorker(node, visited) {
|
|
@@ -360499,8 +360499,8 @@ ${lanes.join("\n")}
|
|
|
360499
360499
|
return symbolLinks[id2] ?? (symbolLinks[id2] = new SymbolLinks());
|
|
360500
360500
|
}
|
|
360501
360501
|
function getNodeLinks(node) {
|
|
360502
|
-
const
|
|
360503
|
-
return nodeLinks[
|
|
360502
|
+
const nodeId2 = getNodeId(node);
|
|
360503
|
+
return nodeLinks[nodeId2] || (nodeLinks[nodeId2] = new NodeLinks());
|
|
360504
360504
|
}
|
|
360505
360505
|
function getSymbol2(symbols, name10, meaning) {
|
|
360506
360506
|
if (meaning) {
|
|
@@ -403619,9 +403619,9 @@ ${lanes.join("\n")}
|
|
|
403619
403619
|
}
|
|
403620
403620
|
function getNodeCheckFlags(node) {
|
|
403621
403621
|
var _a2;
|
|
403622
|
-
const
|
|
403623
|
-
if (
|
|
403624
|
-
return ((_a2 = nodeLinks[
|
|
403622
|
+
const nodeId2 = node.id || 0;
|
|
403623
|
+
if (nodeId2 < 0 || nodeId2 >= nodeLinks.length) return 0;
|
|
403624
|
+
return ((_a2 = nodeLinks[nodeId2]) == null ? void 0 : _a2.flags) || 0;
|
|
403625
403625
|
}
|
|
403626
403626
|
function hasNodeCheckFlag(node, flag) {
|
|
403627
403627
|
calculateNodeCheckFlagWorker(node, flag);
|
|
@@ -438711,9 +438711,9 @@ ${lanes.join("\n")}
|
|
|
438711
438711
|
}
|
|
438712
438712
|
}
|
|
438713
438713
|
function generateNameCached(node, privateName, flags, prefix, suffix) {
|
|
438714
|
-
const
|
|
438714
|
+
const nodeId2 = getNodeId(node);
|
|
438715
438715
|
const cache8 = privateName ? nodeIdToGeneratedPrivateName : nodeIdToGeneratedName;
|
|
438716
|
-
return cache8[
|
|
438716
|
+
return cache8[nodeId2] || (cache8[nodeId2] = generateNameForNode(node, privateName, flags ?? 0, formatGeneratedNamePart(prefix, generateName), formatGeneratedNamePart(suffix)));
|
|
438717
438717
|
}
|
|
438718
438718
|
function isUniqueName(name10, privateName) {
|
|
438719
438719
|
return isFileLevelUniqueNameInCurrentFile(name10, privateName) && !isReservedName(name10, privateName) && !generatedNames.has(name10);
|
|
@@ -450102,7 +450102,7 @@ ${lanes.join("\n")}
|
|
|
450102
450102
|
startWatching(state, buildOrder);
|
|
450103
450103
|
return isCircularBuildOrder(buildOrder) ? 4 : !buildOrder.some((p2) => state.diagnostics.has(toResolvedConfigFilePath(state, p2))) ? 0 : successfulProjects ? 2 : 1;
|
|
450104
450104
|
}
|
|
450105
|
-
function
|
|
450105
|
+
function clean7(state, project, onlyReferences) {
|
|
450106
450106
|
mark("SolutionBuilder::beforeClean");
|
|
450107
450107
|
const result = cleanWorker(state, project, onlyReferences);
|
|
450108
450108
|
mark("SolutionBuilder::afterClean");
|
|
@@ -450391,7 +450391,7 @@ ${lanes.join("\n")}
|
|
|
450391
450391
|
const state = createSolutionBuilderState(watch, hostOrHostWithWatch, rootNames, options2, baseWatchOptions);
|
|
450392
450392
|
return {
|
|
450393
450393
|
build: (project, cancellationToken, writeFile28, getCustomTransformers) => build(state, project, cancellationToken, writeFile28, getCustomTransformers),
|
|
450394
|
-
clean: (project) =>
|
|
450394
|
+
clean: (project) => clean7(state, project),
|
|
450395
450395
|
buildReferences: (project, cancellationToken, writeFile28, getCustomTransformers) => build(
|
|
450396
450396
|
state,
|
|
450397
450397
|
project,
|
|
@@ -450401,7 +450401,7 @@ ${lanes.join("\n")}
|
|
|
450401
450401
|
/*onlyReferences*/
|
|
450402
450402
|
true
|
|
450403
450403
|
),
|
|
450404
|
-
cleanReferences: (project) =>
|
|
450404
|
+
cleanReferences: (project) => clean7(
|
|
450405
450405
|
state,
|
|
450406
450406
|
project,
|
|
450407
450407
|
/*onlyReferences*/
|
|
@@ -475940,8 +475940,8 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
|
|
|
475940
475940
|
eachDiagnostic(context2, errorCodes28, (diag2) => {
|
|
475941
475941
|
const info = getInfo10(diag2.file, diag2.start, diag2.code, checker, context2.program);
|
|
475942
475942
|
if (info === void 0) return;
|
|
475943
|
-
const
|
|
475944
|
-
if (!addToSeen(seen,
|
|
475943
|
+
const nodeId2 = getNodeId(info.parentDeclaration) + "#" + (info.kind === 3 ? info.identifier || getNodeId(info.token) : info.token.text);
|
|
475944
|
+
if (!addToSeen(seen, nodeId2)) return;
|
|
475945
475945
|
if (fixId56 === fixMissingFunctionDeclaration && (info.kind === 2 || info.kind === 5)) {
|
|
475946
475946
|
addFunctionDeclaration(changes, context2, info);
|
|
475947
475947
|
} else if (fixId56 === fixMissingProperties && info.kind === 3) {
|
|
@@ -504294,11 +504294,11 @@ ${options2.prefix}` : "\n" : options2.prefix
|
|
|
504294
504294
|
return true;
|
|
504295
504295
|
}
|
|
504296
504296
|
const set = /* @__PURE__ */ new Map();
|
|
504297
|
-
let
|
|
504297
|
+
let unique5 = 0;
|
|
504298
504298
|
for (const v of arr1) {
|
|
504299
504299
|
if (set.get(v) !== true) {
|
|
504300
504300
|
set.set(v, true);
|
|
504301
|
-
|
|
504301
|
+
unique5++;
|
|
504302
504302
|
}
|
|
504303
504303
|
}
|
|
504304
504304
|
for (const v of arr2) {
|
|
@@ -504308,10 +504308,10 @@ ${options2.prefix}` : "\n" : options2.prefix
|
|
|
504308
504308
|
}
|
|
504309
504309
|
if (isSet === true) {
|
|
504310
504310
|
set.set(v, false);
|
|
504311
|
-
|
|
504311
|
+
unique5--;
|
|
504312
504312
|
}
|
|
504313
504313
|
}
|
|
504314
|
-
return
|
|
504314
|
+
return unique5 === 0;
|
|
504315
504315
|
}
|
|
504316
504316
|
function typeAcquisitionChanged(opt1, opt2) {
|
|
504317
504317
|
return opt1.enable !== opt2.enable || !setIsEqualTo(opt1.include, opt2.include) || !setIsEqualTo(opt1.exclude, opt2.exclude);
|
|
@@ -554372,12 +554372,12 @@ function normalizeWorkItem(value2) {
|
|
|
554372
554372
|
const title = sanitizeDelegationText(value2.title, 240);
|
|
554373
554373
|
if (!cardId || !title)
|
|
554374
554374
|
return void 0;
|
|
554375
|
-
const
|
|
554375
|
+
const unique5 = (items, limit) => [...new Set((items ?? []).map((item) => sanitizeDelegationText(item, 220)).filter(Boolean))].slice(0, limit);
|
|
554376
554376
|
const epoch = typeof value2.taskEpoch === "number" && Number.isFinite(value2.taskEpoch) ? Math.max(0, Math.floor(value2.taskEpoch)) : void 0;
|
|
554377
|
-
const todoIds =
|
|
554378
|
-
const ownedFiles =
|
|
554379
|
-
const evidenceRequirements =
|
|
554380
|
-
const expectedArtifacts =
|
|
554377
|
+
const todoIds = unique5(value2.todoIds, 8);
|
|
554378
|
+
const ownedFiles = unique5(value2.ownedFiles, 8);
|
|
554379
|
+
const evidenceRequirements = unique5(value2.evidenceRequirements, 6);
|
|
554380
|
+
const expectedArtifacts = unique5(value2.expectedArtifacts, 8);
|
|
554381
554381
|
const verifierCommand = sanitizeDelegationText(value2.verifierCommand, 360);
|
|
554382
554382
|
return {
|
|
554383
554383
|
cardId,
|
|
@@ -557339,8 +557339,8 @@ function quarantineTree(value2, hint, scope = "project", repoRoot = process.cwd(
|
|
|
557339
557339
|
arr.push(m2);
|
|
557340
557340
|
byPath.set(key, arr);
|
|
557341
557341
|
}
|
|
557342
|
-
for (const [
|
|
557343
|
-
const path16 =
|
|
557342
|
+
for (const [pathKey2, group] of byPath) {
|
|
557343
|
+
const path16 = pathKey2 === "" ? [] : pathKey2.split(".");
|
|
557344
557344
|
const leaf = getAtPath(sanitized, path16);
|
|
557345
557345
|
if (typeof leaf !== "string")
|
|
557346
557346
|
continue;
|
|
@@ -558959,13 +558959,13 @@ function deduplicateFrames(frames) {
|
|
|
558959
558959
|
if (frames.length <= 1)
|
|
558960
558960
|
return frames;
|
|
558961
558961
|
const seen = /* @__PURE__ */ new Set();
|
|
558962
|
-
for (const
|
|
558963
|
-
if (
|
|
558964
|
-
|
|
558962
|
+
for (const frame2 of frames) {
|
|
558963
|
+
if (frame2.hash !== "unknown" && seen.has(frame2.hash)) {
|
|
558964
|
+
frame2.isDuplicate = true;
|
|
558965
558965
|
continue;
|
|
558966
558966
|
}
|
|
558967
|
-
if (
|
|
558968
|
-
seen.add(
|
|
558967
|
+
if (frame2.hash !== "unknown")
|
|
558968
|
+
seen.add(frame2.hash);
|
|
558969
558969
|
}
|
|
558970
558970
|
return frames;
|
|
558971
558971
|
}
|
|
@@ -559024,21 +559024,21 @@ var init_video_understand = __esm({
|
|
|
559024
559024
|
this.workingDir = workingDir;
|
|
559025
559025
|
}
|
|
559026
559026
|
async describeFrames(frames, limit) {
|
|
559027
|
-
const capped = frames.filter((
|
|
559027
|
+
const capped = frames.filter((frame2) => !frame2.isDuplicate).slice(0, Math.max(0, limit));
|
|
559028
559028
|
if (capped.length === 0)
|
|
559029
559029
|
return;
|
|
559030
559030
|
const vision = new VisionTool(this.workingDir);
|
|
559031
|
-
for (const
|
|
559031
|
+
for (const frame2 of capped) {
|
|
559032
559032
|
try {
|
|
559033
559033
|
const result = await vision.execute({
|
|
559034
|
-
image:
|
|
559034
|
+
image: frame2.path,
|
|
559035
559035
|
action: "query",
|
|
559036
559036
|
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.",
|
|
559037
559037
|
length: "normal"
|
|
559038
559038
|
});
|
|
559039
559039
|
const output = normalizeFrameDescriptionForVideo(String(result.llmContent || result.output || ""));
|
|
559040
559040
|
if (result.success && output)
|
|
559041
|
-
|
|
559041
|
+
frame2.description = output;
|
|
559042
559042
|
} catch {
|
|
559043
559043
|
}
|
|
559044
559044
|
}
|
|
@@ -559229,11 +559229,11 @@ var init_video_understand = __esm({
|
|
|
559229
559229
|
deduplicateFrames(frames);
|
|
559230
559230
|
const permanentDir = join88(outDir, `frames-${Date.now()}`);
|
|
559231
559231
|
mkdirSync46(permanentDir, { recursive: true });
|
|
559232
|
-
for (const
|
|
559233
|
-
const dest = join88(permanentDir, basename18(
|
|
559232
|
+
for (const frame2 of frames.filter((f2) => !f2.isDuplicate)) {
|
|
559233
|
+
const dest = join88(permanentDir, basename18(frame2.path));
|
|
559234
559234
|
try {
|
|
559235
|
-
writeFileSync38(dest, readFileSync56(
|
|
559236
|
-
|
|
559235
|
+
writeFileSync38(dest, readFileSync56(frame2.path));
|
|
559236
|
+
frame2.path = dest;
|
|
559237
559237
|
} catch {
|
|
559238
559238
|
}
|
|
559239
559239
|
}
|
|
@@ -559244,11 +559244,11 @@ var init_video_understand = __esm({
|
|
|
559244
559244
|
const mid = (seg.start + seg.end) / 2;
|
|
559245
559245
|
let nearestFrame;
|
|
559246
559246
|
let minDist = Infinity;
|
|
559247
|
-
for (const
|
|
559248
|
-
const dist = Math.abs(
|
|
559247
|
+
for (const frame2 of uniqueFrames) {
|
|
559248
|
+
const dist = Math.abs(frame2.timestamp - mid);
|
|
559249
559249
|
if (dist < minDist) {
|
|
559250
559250
|
minDist = dist;
|
|
559251
|
-
nearestFrame =
|
|
559251
|
+
nearestFrame = frame2;
|
|
559252
559252
|
}
|
|
559253
559253
|
}
|
|
559254
559254
|
return {
|
|
@@ -559352,8 +559352,8 @@ Topic: ${(segments.slice(0, 5).map((s2) => s2.text).join(" ") || audioComprehens
|
|
|
559352
559352
|
if (uniqueFrames.length > 0) {
|
|
559353
559353
|
lines.push("");
|
|
559354
559354
|
lines.push(`## Frames (${uniqueFrames.length} unique, ${frames.length - uniqueFrames.length} duplicates removed)`);
|
|
559355
|
-
for (const
|
|
559356
|
-
lines.push(` [${formatTime2(
|
|
559355
|
+
for (const frame2 of uniqueFrames) {
|
|
559356
|
+
lines.push(` [${formatTime2(frame2.timestamp)}] ${basename18(frame2.path)}${frame2.description ? ` — ${frame2.description}` : ""}`);
|
|
559357
559357
|
}
|
|
559358
559358
|
}
|
|
559359
559359
|
try {
|
|
@@ -567765,6 +567765,400 @@ var init_steeringIntake = __esm({
|
|
|
567765
567765
|
}
|
|
567766
567766
|
});
|
|
567767
567767
|
|
|
567768
|
+
// packages/orchestrator/dist/integrationClosure.js
|
|
567769
|
+
function clean3(value2, max = 320) {
|
|
567770
|
+
return String(value2 ?? "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
567771
|
+
}
|
|
567772
|
+
function pathKey(value2) {
|
|
567773
|
+
return clean3(value2, 800).replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/+/g, "/");
|
|
567774
|
+
}
|
|
567775
|
+
function nodeId(kind, value2) {
|
|
567776
|
+
return `${kind}:${value2.replace(/[^a-zA-Z0-9_.:/@-]+/g, "_").slice(0, 180)}`;
|
|
567777
|
+
}
|
|
567778
|
+
function unique2(values, limit) {
|
|
567779
|
+
const out = [];
|
|
567780
|
+
const seen = /* @__PURE__ */ new Set();
|
|
567781
|
+
for (const raw of values) {
|
|
567782
|
+
const value2 = clean3(raw);
|
|
567783
|
+
if (!value2 || seen.has(value2))
|
|
567784
|
+
continue;
|
|
567785
|
+
seen.add(value2);
|
|
567786
|
+
out.push(value2);
|
|
567787
|
+
if (out.length >= limit)
|
|
567788
|
+
break;
|
|
567789
|
+
}
|
|
567790
|
+
return out;
|
|
567791
|
+
}
|
|
567792
|
+
function edgeId(from3, relation, to) {
|
|
567793
|
+
return `${from3}--${relation}-->${to}`;
|
|
567794
|
+
}
|
|
567795
|
+
function claimState(claim) {
|
|
567796
|
+
if (claim.status === "supported")
|
|
567797
|
+
return "supported";
|
|
567798
|
+
if (claim.status === "blocked" || claim.status === "contradicted")
|
|
567799
|
+
return "blocked";
|
|
567800
|
+
return "open";
|
|
567801
|
+
}
|
|
567802
|
+
function evidenceLabel(evidence) {
|
|
567803
|
+
const receipt = evidence.receipt;
|
|
567804
|
+
if (receipt?.canonicalCommand) {
|
|
567805
|
+
return `${receipt.canonicalCommand} (cwd=${receipt.cwd}, exit=${receipt.exitCode})`;
|
|
567806
|
+
}
|
|
567807
|
+
return clean3(evidence.summary, 220) || evidence.toolName || evidence.id;
|
|
567808
|
+
}
|
|
567809
|
+
function evidenceIsFreshVerification(evidence) {
|
|
567810
|
+
const receipt = evidence.receipt;
|
|
567811
|
+
return evidence.success === true && evidence.role === "verification" && Boolean(receipt && receipt.canonicalCommand && receipt.cwd && receipt.exitCode === 0 && receipt.timedOut !== true && receipt.finishedAtIso);
|
|
567812
|
+
}
|
|
567813
|
+
function claimRequiresClosure(claim) {
|
|
567814
|
+
return claim.materiality === "high" || claim.requiresIndependentEvidence || claim.attainedState === "hardware_integrated" || claim.attainedState === "hardware_verified";
|
|
567815
|
+
}
|
|
567816
|
+
function integrationClosureCompletionBlockers(closure) {
|
|
567817
|
+
const claimNodes = closure.nodes.filter((node) => node.kind === "claim");
|
|
567818
|
+
const claimEdges = /* @__PURE__ */ new Map();
|
|
567819
|
+
for (const edge of closure.edges) {
|
|
567820
|
+
const entries2 = claimEdges.get(edge.from) ?? [];
|
|
567821
|
+
entries2.push(edge);
|
|
567822
|
+
claimEdges.set(edge.from, entries2);
|
|
567823
|
+
}
|
|
567824
|
+
const blockers = [];
|
|
567825
|
+
for (const claim of claimNodes) {
|
|
567826
|
+
const metadata = claim.label.match(/^\[(.+?)\]\s/);
|
|
567827
|
+
const material = metadata?.[1] ?? "low";
|
|
567828
|
+
const edges = claimEdges.get(claim.id) ?? [];
|
|
567829
|
+
const needsIndependent = edges.some((edge) => edge.relation === "verified_by" && edge.state === "open");
|
|
567830
|
+
const isHardwareClaim = edges.some((edge) => edge.reason === "hardware-attained claim requires delivery evidence");
|
|
567831
|
+
if (claim.state === "blocked") {
|
|
567832
|
+
blockers.push(`${claim.label}: contradicted or blocked evidence remains.`);
|
|
567833
|
+
} else if (material === "high" && claim.state !== "supported") {
|
|
567834
|
+
blockers.push(`${claim.label}: material claim lacks linked evidence.`);
|
|
567835
|
+
} else if (needsIndependent) {
|
|
567836
|
+
blockers.push(`${claim.label}: independent verification receipt is missing.`);
|
|
567837
|
+
} else if (isHardwareClaim) {
|
|
567838
|
+
blockers.push(`${claim.label}: hardware claim lacks delivery-path evidence.`);
|
|
567839
|
+
}
|
|
567840
|
+
}
|
|
567841
|
+
return unique2(blockers, 8);
|
|
567842
|
+
}
|
|
567843
|
+
function buildIntegrationClosure(input) {
|
|
567844
|
+
const ledger = input.ledger ?? void 0;
|
|
567845
|
+
const discovery = ledger?.claimDiscovery;
|
|
567846
|
+
const goal = clean3(input.goal, 900) || "unspecified";
|
|
567847
|
+
const nodes = [];
|
|
567848
|
+
const edges = [];
|
|
567849
|
+
const nodeIds = /* @__PURE__ */ new Set();
|
|
567850
|
+
const edgeIds = /* @__PURE__ */ new Set();
|
|
567851
|
+
const addNode = (node) => {
|
|
567852
|
+
if (nodeIds.has(node.id))
|
|
567853
|
+
return;
|
|
567854
|
+
nodeIds.add(node.id);
|
|
567855
|
+
nodes.push(node);
|
|
567856
|
+
};
|
|
567857
|
+
const addEdge = (edge) => {
|
|
567858
|
+
if (edgeIds.has(edge.id))
|
|
567859
|
+
return;
|
|
567860
|
+
edgeIds.add(edge.id);
|
|
567861
|
+
edges.push(edge);
|
|
567862
|
+
};
|
|
567863
|
+
const requirementId = "requirement:current-goal";
|
|
567864
|
+
addNode({
|
|
567865
|
+
id: requirementId,
|
|
567866
|
+
kind: "requirement",
|
|
567867
|
+
label: goal,
|
|
567868
|
+
state: "open",
|
|
567869
|
+
provenance: "task"
|
|
567870
|
+
});
|
|
567871
|
+
const pathReasons = /* @__PURE__ */ new Map();
|
|
567872
|
+
const requiredPaths = discovery?.requiredArtifactPaths ?? [];
|
|
567873
|
+
const candidatePaths = discovery?.candidatePaths ?? [];
|
|
567874
|
+
const addPath = (rawPath, reason) => {
|
|
567875
|
+
const path16 = pathKey(rawPath);
|
|
567876
|
+
if (!path16)
|
|
567877
|
+
return null;
|
|
567878
|
+
if (!pathReasons.has(path16) && pathReasons.size >= MAX_PATHS)
|
|
567879
|
+
return null;
|
|
567880
|
+
pathReasons.set(path16, pathReasons.get(path16) || clean3(reason, 180));
|
|
567881
|
+
const id2 = nodeId("path", path16);
|
|
567882
|
+
addNode({
|
|
567883
|
+
id: id2,
|
|
567884
|
+
kind: "workspace_path",
|
|
567885
|
+
label: path16,
|
|
567886
|
+
state: "unknown",
|
|
567887
|
+
provenance: "workspace"
|
|
567888
|
+
});
|
|
567889
|
+
addEdge({
|
|
567890
|
+
id: edgeId(requirementId, "affects", id2),
|
|
567891
|
+
from: requirementId,
|
|
567892
|
+
to: id2,
|
|
567893
|
+
relation: "affects",
|
|
567894
|
+
state: requiredPaths.includes(rawPath) ? "open" : "advisory",
|
|
567895
|
+
provenance: "task",
|
|
567896
|
+
reason: pathReasons.get(path16)
|
|
567897
|
+
});
|
|
567898
|
+
return id2;
|
|
567899
|
+
};
|
|
567900
|
+
for (const path16 of requiredPaths) {
|
|
567901
|
+
addPath(path16, discovery?.pathReasons?.[path16] || "explicit task artifact");
|
|
567902
|
+
}
|
|
567903
|
+
for (const path16 of candidatePaths) {
|
|
567904
|
+
addPath(path16, discovery?.pathReasons?.[path16] || "bounded workspace lead");
|
|
567905
|
+
}
|
|
567906
|
+
for (const path16 of input.modifiedPaths ?? []) {
|
|
567907
|
+
addPath(path16, "modified during this run");
|
|
567908
|
+
}
|
|
567909
|
+
const evidence = (ledger?.evidence ?? []).slice(-MAX_EVIDENCE);
|
|
567910
|
+
for (const item of evidence) {
|
|
567911
|
+
const evidenceId = nodeId("evidence", item.id);
|
|
567912
|
+
addNode({
|
|
567913
|
+
id: evidenceId,
|
|
567914
|
+
kind: "evidence",
|
|
567915
|
+
label: evidenceLabel(item),
|
|
567916
|
+
state: item.success === false ? "blocked" : item.success === true ? "supported" : "unknown",
|
|
567917
|
+
provenance: "tool"
|
|
567918
|
+
});
|
|
567919
|
+
for (const path16 of item.targetPaths ?? []) {
|
|
567920
|
+
const pathId = addPath(path16, "observed by recorded tool evidence");
|
|
567921
|
+
if (!pathId)
|
|
567922
|
+
continue;
|
|
567923
|
+
addEdge({
|
|
567924
|
+
id: edgeId(evidenceId, "evidenced_by", pathId),
|
|
567925
|
+
from: evidenceId,
|
|
567926
|
+
to: pathId,
|
|
567927
|
+
relation: "evidenced_by",
|
|
567928
|
+
state: item.success === true ? "satisfied" : item.success === false ? "blocked" : "open",
|
|
567929
|
+
provenance: "tool",
|
|
567930
|
+
evidenceIds: [item.id]
|
|
567931
|
+
});
|
|
567932
|
+
}
|
|
567933
|
+
}
|
|
567934
|
+
const claims = (ledger?.proposedClaims ?? []).slice(-MAX_CLAIMS);
|
|
567935
|
+
for (const claim of claims) {
|
|
567936
|
+
const claimId = nodeId("claim", claim.id);
|
|
567937
|
+
addNode({
|
|
567938
|
+
id: claimId,
|
|
567939
|
+
kind: "claim",
|
|
567940
|
+
label: `[${claim.materiality}] ${claim.text}`,
|
|
567941
|
+
state: claimState(claim),
|
|
567942
|
+
provenance: "controller"
|
|
567943
|
+
});
|
|
567944
|
+
addEdge({
|
|
567945
|
+
id: edgeId(requirementId, "requires", claimId),
|
|
567946
|
+
from: requirementId,
|
|
567947
|
+
to: claimId,
|
|
567948
|
+
relation: "requires",
|
|
567949
|
+
state: claim.status === "supported" ? "satisfied" : claim.status === "blocked" ? "blocked" : "open",
|
|
567950
|
+
provenance: "controller"
|
|
567951
|
+
});
|
|
567952
|
+
for (const path16 of claim.workspaceSignals ?? []) {
|
|
567953
|
+
const pathId = addPath(path16, "claim workspace signal");
|
|
567954
|
+
if (!pathId)
|
|
567955
|
+
continue;
|
|
567956
|
+
addEdge({
|
|
567957
|
+
id: edgeId(claimId, "implemented_by", pathId),
|
|
567958
|
+
from: claimId,
|
|
567959
|
+
to: pathId,
|
|
567960
|
+
relation: "implemented_by",
|
|
567961
|
+
state: claim.status === "supported" ? "satisfied" : "open",
|
|
567962
|
+
provenance: "workspace"
|
|
567963
|
+
});
|
|
567964
|
+
}
|
|
567965
|
+
const claimEvidence = new Set(claim.evidenceIds ?? []);
|
|
567966
|
+
for (const item of evidence) {
|
|
567967
|
+
if (!claimEvidence.has(item.id))
|
|
567968
|
+
continue;
|
|
567969
|
+
const evidenceId = nodeId("evidence", item.id);
|
|
567970
|
+
addEdge({
|
|
567971
|
+
id: edgeId(claimId, "evidenced_by", evidenceId),
|
|
567972
|
+
from: claimId,
|
|
567973
|
+
to: evidenceId,
|
|
567974
|
+
relation: "evidenced_by",
|
|
567975
|
+
state: item.success === true ? "satisfied" : item.success === false ? "blocked" : "open",
|
|
567976
|
+
provenance: "tool",
|
|
567977
|
+
evidenceIds: [item.id]
|
|
567978
|
+
});
|
|
567979
|
+
}
|
|
567980
|
+
if (claim.requiresIndependentEvidence) {
|
|
567981
|
+
const verification = evidence.filter(evidenceIsFreshVerification);
|
|
567982
|
+
addEdge({
|
|
567983
|
+
id: edgeId(claimId, "verified_by", "acceptance:independent-verification"),
|
|
567984
|
+
from: claimId,
|
|
567985
|
+
to: "acceptance:independent-verification",
|
|
567986
|
+
relation: "verified_by",
|
|
567987
|
+
state: verification.length > 0 && claim.status === "supported" ? "satisfied" : "open",
|
|
567988
|
+
provenance: "controller",
|
|
567989
|
+
reason: claim.requiredCheck,
|
|
567990
|
+
evidenceIds: verification.map((item) => item.id)
|
|
567991
|
+
});
|
|
567992
|
+
addNode({
|
|
567993
|
+
id: "acceptance:independent-verification",
|
|
567994
|
+
kind: "acceptance",
|
|
567995
|
+
label: "independent verification receipt",
|
|
567996
|
+
state: verification.length > 0 ? "supported" : "open",
|
|
567997
|
+
provenance: "controller"
|
|
567998
|
+
});
|
|
567999
|
+
}
|
|
568000
|
+
if (claim.attainedState === "hardware_integrated" || claim.attainedState === "hardware_verified") {
|
|
568001
|
+
const delivery = evidence.filter((item) => item.kind === "delivery" && item.success === true);
|
|
568002
|
+
addNode({
|
|
568003
|
+
id: "acceptance:delivery-path",
|
|
568004
|
+
kind: "acceptance",
|
|
568005
|
+
label: "declared delivery-path evidence",
|
|
568006
|
+
state: delivery.length > 0 ? "supported" : "open",
|
|
568007
|
+
provenance: "controller"
|
|
568008
|
+
});
|
|
568009
|
+
addEdge({
|
|
568010
|
+
id: edgeId(claimId, "verified_by", "acceptance:delivery-path"),
|
|
568011
|
+
from: claimId,
|
|
568012
|
+
to: "acceptance:delivery-path",
|
|
568013
|
+
relation: "verified_by",
|
|
568014
|
+
state: delivery.length > 0 && claim.status === "supported" ? "satisfied" : "open",
|
|
568015
|
+
provenance: "controller",
|
|
568016
|
+
reason: "hardware-attained claim requires delivery evidence",
|
|
568017
|
+
evidenceIds: delivery.map((item) => item.id)
|
|
568018
|
+
});
|
|
568019
|
+
}
|
|
568020
|
+
}
|
|
568021
|
+
for (const contractId of unique2(input.contractIds ?? [], 12)) {
|
|
568022
|
+
const id2 = nodeId("contract", contractId);
|
|
568023
|
+
addNode({
|
|
568024
|
+
id: id2,
|
|
568025
|
+
kind: "contract",
|
|
568026
|
+
label: contractId,
|
|
568027
|
+
state: "unknown",
|
|
568028
|
+
provenance: "contract"
|
|
568029
|
+
});
|
|
568030
|
+
addEdge({
|
|
568031
|
+
id: edgeId(requirementId, "constrained_by", id2),
|
|
568032
|
+
from: requirementId,
|
|
568033
|
+
to: id2,
|
|
568034
|
+
relation: "constrained_by",
|
|
568035
|
+
state: "advisory",
|
|
568036
|
+
provenance: "contract"
|
|
568037
|
+
});
|
|
568038
|
+
}
|
|
568039
|
+
const runtimeBoundaries = [];
|
|
568040
|
+
const graph = input.codeGraph ?? void 0;
|
|
568041
|
+
if (graph) {
|
|
568042
|
+
for (const path16 of [...pathReasons.keys()].slice(0, 4)) {
|
|
568043
|
+
const pathId = nodeId("path", path16);
|
|
568044
|
+
try {
|
|
568045
|
+
for (const imported of unique2(graph.getImports?.(path16) ?? [], 3)) {
|
|
568046
|
+
const targetId = addPath(imported, `runtime dependency of ${path16}`);
|
|
568047
|
+
if (!targetId)
|
|
568048
|
+
continue;
|
|
568049
|
+
const boundary = `${path16} -> ${imported}`;
|
|
568050
|
+
runtimeBoundaries.push(boundary);
|
|
568051
|
+
addEdge({
|
|
568052
|
+
id: edgeId(pathId, "depends_on", targetId),
|
|
568053
|
+
from: pathId,
|
|
568054
|
+
to: targetId,
|
|
568055
|
+
relation: "depends_on",
|
|
568056
|
+
state: "advisory",
|
|
568057
|
+
provenance: "workspace",
|
|
568058
|
+
reason: "indexed import relationship"
|
|
568059
|
+
});
|
|
568060
|
+
}
|
|
568061
|
+
for (const importer3 of unique2(graph.getImportedBy?.(path16) ?? [], 3)) {
|
|
568062
|
+
const sourceId = addPath(importer3, `runtime consumer of ${path16}`);
|
|
568063
|
+
if (!sourceId)
|
|
568064
|
+
continue;
|
|
568065
|
+
const boundary = `${importer3} -> ${path16}`;
|
|
568066
|
+
runtimeBoundaries.push(boundary);
|
|
568067
|
+
addEdge({
|
|
568068
|
+
id: edgeId(sourceId, "depended_on_by", pathId),
|
|
568069
|
+
from: sourceId,
|
|
568070
|
+
to: pathId,
|
|
568071
|
+
relation: "depended_on_by",
|
|
568072
|
+
state: "advisory",
|
|
568073
|
+
provenance: "workspace",
|
|
568074
|
+
reason: "indexed importer relationship"
|
|
568075
|
+
});
|
|
568076
|
+
}
|
|
568077
|
+
} catch {
|
|
568078
|
+
}
|
|
568079
|
+
}
|
|
568080
|
+
}
|
|
568081
|
+
const unresolved = ledger?.unresolved ?? [];
|
|
568082
|
+
const proofGaps = unique2([
|
|
568083
|
+
...(discovery?.openDeltas ?? []).map((delta) => `${delta.path}: ${delta.reason}`),
|
|
568084
|
+
...unresolved.map((item) => item.text),
|
|
568085
|
+
...claims.filter((claim) => claim.status !== "supported").filter(claimRequiresClosure).map((claim) => `${claim.id}: ${claim.requiredCheck}`)
|
|
568086
|
+
], MAX_GAPS);
|
|
568087
|
+
const blockers = unique2([
|
|
568088
|
+
...discovery?.survivingBlockers ?? [],
|
|
568089
|
+
...discovery?.unresolvedQuestions ?? [],
|
|
568090
|
+
...claims.filter((claim) => claim.status === "blocked" || claim.status === "contradicted").map((claim) => `${claim.id}: ${claim.text}`)
|
|
568091
|
+
], MAX_GAPS);
|
|
568092
|
+
for (const blocker of blockers) {
|
|
568093
|
+
const id2 = nodeId("blocker", blocker);
|
|
568094
|
+
addNode({
|
|
568095
|
+
id: id2,
|
|
568096
|
+
kind: "blocker",
|
|
568097
|
+
label: blocker,
|
|
568098
|
+
state: "blocked",
|
|
568099
|
+
provenance: "controller"
|
|
568100
|
+
});
|
|
568101
|
+
addEdge({
|
|
568102
|
+
id: edgeId(requirementId, "blocked_by", id2),
|
|
568103
|
+
from: requirementId,
|
|
568104
|
+
to: id2,
|
|
568105
|
+
relation: "blocked_by",
|
|
568106
|
+
state: "blocked",
|
|
568107
|
+
provenance: "controller"
|
|
568108
|
+
});
|
|
568109
|
+
}
|
|
568110
|
+
const nextEvidence = unique2([
|
|
568111
|
+
...claims.filter((claim) => claim.status !== "supported").filter(claimRequiresClosure).map((claim) => claim.requiredCheck),
|
|
568112
|
+
...(discovery?.openDeltas ?? []).map((delta) => `Inspect ${delta.path} from authoritative source: ${delta.reason}`)
|
|
568113
|
+
], 6);
|
|
568114
|
+
const closure = {
|
|
568115
|
+
schema: INTEGRATION_CLOSURE_SCHEMA,
|
|
568116
|
+
generatedAtIso: input.nowIso ?? (/* @__PURE__ */ new Date()).toISOString(),
|
|
568117
|
+
goal,
|
|
568118
|
+
nodes,
|
|
568119
|
+
edges,
|
|
568120
|
+
frontier: {
|
|
568121
|
+
affectedPaths: unique2(pathReasons.keys(), MAX_PATHS),
|
|
568122
|
+
runtimeBoundaries: unique2(runtimeBoundaries, MAX_BOUNDARIES),
|
|
568123
|
+
openProofGaps: proofGaps,
|
|
568124
|
+
survivingBlockers: blockers,
|
|
568125
|
+
nextEvidence,
|
|
568126
|
+
receiptIds: evidence.filter((item) => item.receipt).map((item) => item.id).slice(-8)
|
|
568127
|
+
},
|
|
568128
|
+
completeness: blockers.length > 0 ? "blocked" : proofGaps.length > 0 ? "incomplete" : "ready"
|
|
568129
|
+
};
|
|
568130
|
+
return closure;
|
|
568131
|
+
}
|
|
568132
|
+
function renderIntegrationClosureFrontier(closure, maxChars = 2400) {
|
|
568133
|
+
const lines = [
|
|
568134
|
+
"[INTEGRATION CLOSURE v1]",
|
|
568135
|
+
`state=${closure.completeness} goal=${clean3(closure.goal, 500)}`,
|
|
568136
|
+
`affected_paths=${closure.frontier.affectedPaths.join(",") || "none"}`,
|
|
568137
|
+
`runtime_boundaries=${closure.frontier.runtimeBoundaries.join(" | ") || "not indexed"}`,
|
|
568138
|
+
`open_proof_gaps=${closure.frontier.openProofGaps.join(" | ") || "none"}`,
|
|
568139
|
+
`surviving_blockers=${closure.frontier.survivingBlockers.join(" | ") || "none"}`,
|
|
568140
|
+
`next_evidence=${closure.frontier.nextEvidence.join(" | ") || "none"}`,
|
|
568141
|
+
`receipt_handles=${closure.frontier.receiptIds.join(",") || "none"}`
|
|
568142
|
+
];
|
|
568143
|
+
const rendered = lines.join("\n");
|
|
568144
|
+
if (rendered.length <= maxChars)
|
|
568145
|
+
return rendered;
|
|
568146
|
+
return `${rendered.slice(0, Math.max(100, maxChars - 34)).trimEnd()}
|
|
568147
|
+
... [closure frontier truncated]`;
|
|
568148
|
+
}
|
|
568149
|
+
var INTEGRATION_CLOSURE_SCHEMA, MAX_PATHS, MAX_CLAIMS, MAX_EVIDENCE, MAX_GAPS, MAX_BOUNDARIES;
|
|
568150
|
+
var init_integrationClosure = __esm({
|
|
568151
|
+
"packages/orchestrator/dist/integrationClosure.js"() {
|
|
568152
|
+
"use strict";
|
|
568153
|
+
INTEGRATION_CLOSURE_SCHEMA = "omnius.integration-closure.v1";
|
|
568154
|
+
MAX_PATHS = 12;
|
|
568155
|
+
MAX_CLAIMS = 32;
|
|
568156
|
+
MAX_EVIDENCE = 40;
|
|
568157
|
+
MAX_GAPS = 10;
|
|
568158
|
+
MAX_BOUNDARIES = 12;
|
|
568159
|
+
}
|
|
568160
|
+
});
|
|
568161
|
+
|
|
567768
568162
|
// packages/orchestrator/dist/completionContract.js
|
|
567769
568163
|
function normalizeText(value2, max = 500) {
|
|
567770
568164
|
const text2 = String(value2 ?? "").trim().replace(/\s+/g, " ");
|
|
@@ -567998,6 +568392,13 @@ function setClaimDiscoveryState(ledger, state) {
|
|
|
567998
568392
|
updatedAtIso: nowIso3()
|
|
567999
568393
|
};
|
|
568000
568394
|
}
|
|
568395
|
+
function setIntegrationClosure(ledger, closure) {
|
|
568396
|
+
return {
|
|
568397
|
+
...ledger,
|
|
568398
|
+
integrationClosure: closure,
|
|
568399
|
+
updatedAtIso: closure.generatedAtIso
|
|
568400
|
+
};
|
|
568401
|
+
}
|
|
568001
568402
|
function claimDiscoveryStateFromSurvey(input) {
|
|
568002
568403
|
const normalizedInventory = input.boundedInventory;
|
|
568003
568404
|
const paths = [...new Set((Array.isArray(input.candidatePaths) ? input.candidatePaths : []).map((value2) => normalizeEvidencePath(value2)).filter(Boolean).slice(0, 16))];
|
|
@@ -568104,14 +568505,14 @@ function extractPathFragments(text2) {
|
|
|
568104
568505
|
return [...new Set(out)].slice(0, 12);
|
|
568105
568506
|
}
|
|
568106
568507
|
function tokenizeClaims(text2) {
|
|
568107
|
-
return String(text2 ?? "").split(/[
|
|
568508
|
+
return String(text2 ?? "").split(/(?:[!?;]+|\.(?=\s|$)|[\n\r]+)/).map((item) => item.trim()).filter((item) => item.length > 6).filter((item) => item.length < 260).slice(0, 30);
|
|
568108
568509
|
}
|
|
568109
568510
|
function estimateClaimMateriality(text2) {
|
|
568110
568511
|
const normalized = text2.toLowerCase();
|
|
568111
|
-
if (/\b(blocker|critical|security|production|release|deploy
|
|
568512
|
+
if (/\b(blocker|critical|security|production|release|deploy\w*|migrat\w*|regression|customer|public)\b/.test(normalized)) {
|
|
568112
568513
|
return "high";
|
|
568113
568514
|
}
|
|
568114
|
-
if (/\b(implement
|
|
568515
|
+
if (/\b(implement\w*|fix\w*|refactor\w*|resolv\w*|wir\w*|integrat\w*|add\w*|remov\w*|chang\w*|updat\w*)\b/.test(normalized)) {
|
|
568115
568516
|
return "medium";
|
|
568116
568517
|
}
|
|
568117
568518
|
return "low";
|
|
@@ -568234,36 +568635,6 @@ function findInventoryMatches(statement, workspaceInventory) {
|
|
|
568234
568635
|
}
|
|
568235
568636
|
return matches.slice(0, 6);
|
|
568236
568637
|
}
|
|
568237
|
-
function claimDiscoveryControllerSignals(stage2) {
|
|
568238
|
-
if (!stage2)
|
|
568239
|
-
return [];
|
|
568240
|
-
const openDeltas = (stage2.openDeltas ?? []).slice(0, 10);
|
|
568241
|
-
const evidenceHandles = stage2.evidenceHandles ?? [];
|
|
568242
|
-
const resolvedEvidenceHandles = stage2.resolvedEvidenceHandles ?? [];
|
|
568243
|
-
const survivingBlockers = stage2.survivingBlockers ?? [];
|
|
568244
|
-
const unresolvedQuestions = stage2.unresolvedQuestions ?? [];
|
|
568245
|
-
const boundedInventory = stage2.boundedInventory;
|
|
568246
|
-
const boundedDirs = boundedInventory?.dirs ?? [];
|
|
568247
|
-
const requiredArtifactPaths = stage2.requiredArtifactPaths ?? stage2.candidatePaths ?? [];
|
|
568248
|
-
const requiredSet = new Set(requiredArtifactPaths);
|
|
568249
|
-
const exploratoryPaths = (stage2.candidatePaths ?? []).filter((path16) => !requiredSet.has(path16));
|
|
568250
|
-
const resolvedCount = Math.min(evidenceHandles.length, new Set(resolvedEvidenceHandles).size);
|
|
568251
|
-
const unresolvedEvidenceCount = Math.max(evidenceHandles.length - resolvedCount, 0);
|
|
568252
|
-
return [
|
|
568253
|
-
"[COMPLETION CLAIM DISCOVERY]",
|
|
568254
|
-
`status=${stage2.status ?? "skipped"} generated_at=${stage2.generatedAtIso ?? ""}`,
|
|
568255
|
-
`requires_evidence=${stage2.requiresEvidence ? "true" : "false"}`,
|
|
568256
|
-
`bounded_inventory=${boundedInventory ? `${boundedInventory.root}|files=${boundedInventory.files.length}|dirs=${boundedDirs.length}|truncated=${Boolean(boundedInventory.truncated)}` : "none"}`,
|
|
568257
|
-
`required_artifact_paths=${requiredArtifactPaths.join(",") || "none"}`,
|
|
568258
|
-
`exploratory_paths=${exploratoryPaths.join(",") || "none"}`,
|
|
568259
|
-
`open_deltas=${openDeltas.map((delta) => `${delta.path} :: ${delta.reason}`.replace(/\s+/g, " ")).join(" | ") || "none"}`,
|
|
568260
|
-
`open_delta_count=${openDeltas.length} unresolved_evidence_count=${unresolvedEvidenceCount}`,
|
|
568261
|
-
`surviving_blockers=${survivingBlockers.join(" | ") || "none"}`,
|
|
568262
|
-
`unresolved_questions=${unresolvedQuestions.join(" | ") || "none"}`,
|
|
568263
|
-
`evidence_handles=${evidenceHandles.join(",") || "none"}`,
|
|
568264
|
-
`resolved_evidence_handles=${resolvedEvidenceHandles.join(",") || "none"}`
|
|
568265
|
-
];
|
|
568266
|
-
}
|
|
568267
568638
|
function createCompletionLedger(input) {
|
|
568268
568639
|
const ts = nowIso3(input.now);
|
|
568269
568640
|
return {
|
|
@@ -568391,24 +568762,114 @@ function recordToolEvidence(ledger, input) {
|
|
|
568391
568762
|
}
|
|
568392
568763
|
function addCompletionClaims(ledger, claims) {
|
|
568393
568764
|
const byId = new Map(ledger.proposedClaims.map((claim) => [claim.id, claim]));
|
|
568394
|
-
|
|
568765
|
+
const byMeaning = new Map(ledger.proposedClaims.map((claim) => [normalizeCompletionKey(claim.text, "claim"), claim.id]));
|
|
568766
|
+
for (const claim of claims) {
|
|
568767
|
+
const meaning = normalizeCompletionKey(claim.text, "claim");
|
|
568768
|
+
if (meaning && byMeaning.has(meaning))
|
|
568769
|
+
continue;
|
|
568395
568770
|
byId.set(claim.id, claim);
|
|
568771
|
+
if (meaning)
|
|
568772
|
+
byMeaning.set(meaning, claim.id);
|
|
568773
|
+
}
|
|
568396
568774
|
return {
|
|
568397
568775
|
...ledger,
|
|
568398
568776
|
proposedClaims: Array.from(byId.values()),
|
|
568399
568777
|
updatedAtIso: nowIso3()
|
|
568400
568778
|
};
|
|
568401
568779
|
}
|
|
568780
|
+
function claimPathSignals(claim) {
|
|
568781
|
+
const sourcePaths = (claim.sourceSignals ?? []).filter((signal) => /[/.]/.test(signal));
|
|
568782
|
+
return cleanTargetPaths([...claim.workspaceSignals, ...sourcePaths]);
|
|
568783
|
+
}
|
|
568784
|
+
function evidencePaths(evidence) {
|
|
568785
|
+
return cleanTargetPaths([
|
|
568786
|
+
...evidence.targetPaths ?? [],
|
|
568787
|
+
...evidence.receipt?.observedPaths ?? [],
|
|
568788
|
+
...evidence.receipt?.artifactHashes?.map((artifact) => artifact.path) ?? []
|
|
568789
|
+
]);
|
|
568790
|
+
}
|
|
568791
|
+
function samePath(left, right) {
|
|
568792
|
+
const a2 = normalizeEvidencePath(left).replace(/^\/+/, "");
|
|
568793
|
+
const b = normalizeEvidencePath(right).replace(/^\/+/, "");
|
|
568794
|
+
return a2 === b || a2.endsWith(`/${b}`) || b.endsWith(`/${a2}`);
|
|
568795
|
+
}
|
|
568796
|
+
function hasClaimPathOverlap(claim, evidence) {
|
|
568797
|
+
const paths = claimPathSignals(claim);
|
|
568798
|
+
if (paths.length === 0)
|
|
568799
|
+
return false;
|
|
568800
|
+
const targets = evidencePaths(evidence);
|
|
568801
|
+
return paths.some((path16) => targets.some((target) => samePath(path16, target)));
|
|
568802
|
+
}
|
|
568803
|
+
function trustedSuccessfulReceipt(evidence) {
|
|
568804
|
+
const receipt = evidence.receipt;
|
|
568805
|
+
return evidence.success === true && Boolean(receipt && receipt.canonicalCommand && receipt.cwd && receipt.exitCode === 0 && receipt.timedOut !== true && receipt.finishedAtIso);
|
|
568806
|
+
}
|
|
568807
|
+
function evidenceMatchesClaimNeed(claim, evidence, need) {
|
|
568808
|
+
if (evidence.success !== true)
|
|
568809
|
+
return false;
|
|
568810
|
+
const pathOverlap = hasClaimPathOverlap(claim, evidence);
|
|
568811
|
+
switch (need.evidenceKind) {
|
|
568812
|
+
case "file_change":
|
|
568813
|
+
return pathOverlap && (evidence.kind === "file_change" || evidence.role === "mutation");
|
|
568814
|
+
case "tool_result":
|
|
568815
|
+
return evidence.kind === "tool_result" && (pathOverlap || evidence.role === "verification" && trustedSuccessfulReceipt(evidence));
|
|
568816
|
+
case "runtime_observation":
|
|
568817
|
+
return pathOverlap && (evidence.role === "observation" || evidence.role === "verification" || evidence.kind === "runtime_observation");
|
|
568818
|
+
case "delivery":
|
|
568819
|
+
return evidence.kind === "delivery" && trustedSuccessfulReceipt(evidence);
|
|
568820
|
+
default:
|
|
568821
|
+
return false;
|
|
568822
|
+
}
|
|
568823
|
+
}
|
|
568824
|
+
function independentVerificationIsFresh(claim, evidence) {
|
|
568825
|
+
const paths = claimPathSignals(claim);
|
|
568826
|
+
let lastMutation = -1;
|
|
568827
|
+
let lastMutationAtMs = Number.NEGATIVE_INFINITY;
|
|
568828
|
+
evidence.forEach((item, index) => {
|
|
568829
|
+
if (item.role !== "mutation" && item.kind !== "file_change")
|
|
568830
|
+
return;
|
|
568831
|
+
if (paths.length === 0 || hasClaimPathOverlap(claim, item)) {
|
|
568832
|
+
lastMutation = index;
|
|
568833
|
+
const observedAtMs = Date.parse(item.observedAtIso);
|
|
568834
|
+
if (Number.isFinite(observedAtMs))
|
|
568835
|
+
lastMutationAtMs = observedAtMs;
|
|
568836
|
+
}
|
|
568837
|
+
});
|
|
568838
|
+
for (let index = evidence.length - 1; index > lastMutation; index--) {
|
|
568839
|
+
const item = evidence[index];
|
|
568840
|
+
if (item.role !== "verification" || !trustedSuccessfulReceipt(item))
|
|
568841
|
+
continue;
|
|
568842
|
+
const finishedAtMs = Date.parse(item.receipt.finishedAtIso);
|
|
568843
|
+
if (Number.isFinite(lastMutationAtMs) && (!Number.isFinite(finishedAtMs) || finishedAtMs < lastMutationAtMs)) {
|
|
568844
|
+
continue;
|
|
568845
|
+
}
|
|
568846
|
+
return item;
|
|
568847
|
+
}
|
|
568848
|
+
return void 0;
|
|
568849
|
+
}
|
|
568402
568850
|
function reconcileClaimsWithEvidence(ledger) {
|
|
568403
568851
|
const evidenceById = new Map(ledger.evidence.map((entry) => [entry.id, entry]));
|
|
568404
568852
|
const claims = ledger.proposedClaims.map((claim) => {
|
|
568405
|
-
const
|
|
568406
|
-
|
|
568407
|
-
|
|
568853
|
+
const explicit = claim.evidenceIds.map((id2) => evidenceById.get(id2)).filter((entry) => Boolean(entry));
|
|
568854
|
+
const automatic = ledger.evidence.filter((entry) => claim.evidenceNeeds.some((need) => evidenceMatchesClaimNeed(claim, entry, need)));
|
|
568855
|
+
const independent = claim.requiresIndependentEvidence ? independentVerificationIsFresh(claim, ledger.evidence) : void 0;
|
|
568856
|
+
const linked = [...new Map([...explicit, ...automatic, ...independent ? [independent] : []].map((entry) => [entry.id, entry])).values()];
|
|
568857
|
+
const evidenceIds = linked.map((entry) => entry.id);
|
|
568408
568858
|
if (linked.some((entry) => entry.success === false)) {
|
|
568409
|
-
return { ...claim, status: "contradicted" };
|
|
568859
|
+
return { ...claim, evidenceIds, status: "contradicted" };
|
|
568410
568860
|
}
|
|
568411
|
-
|
|
568861
|
+
if (linked.length === 0)
|
|
568862
|
+
return { ...claim, evidenceIds, status: "unverified" };
|
|
568863
|
+
const allNeedsMet = claim.evidenceNeeds.every((need) => linked.some((entry) => evidenceMatchesClaimNeed(claim, entry, need)) || // Preserve explicit evidence links authored by a caller. They remain
|
|
568864
|
+
// subject to failure/receipt validation above, but should not be
|
|
568865
|
+
// reclassified only because a legacy emitter lacked role metadata.
|
|
568866
|
+
explicit.some((entry) => entry.success === true));
|
|
568867
|
+
const independentMet = !claim.requiresIndependentEvidence || Boolean(independent);
|
|
568868
|
+
return {
|
|
568869
|
+
...claim,
|
|
568870
|
+
evidenceIds,
|
|
568871
|
+
status: allNeedsMet && independentMet ? "supported" : "unverified"
|
|
568872
|
+
};
|
|
568412
568873
|
});
|
|
568413
568874
|
return {
|
|
568414
568875
|
...ledger,
|
|
@@ -568513,17 +568974,17 @@ function buildCriticPacketFromLedger(ledger) {
|
|
|
568513
568974
|
return lines.join("\n");
|
|
568514
568975
|
}
|
|
568515
568976
|
function appendUnresolved(items, text2, source) {
|
|
568516
|
-
const
|
|
568517
|
-
if (!
|
|
568977
|
+
const clean7 = cleanText(text2, 500);
|
|
568978
|
+
if (!clean7)
|
|
568518
568979
|
return items;
|
|
568519
|
-
if (items.some((item) => item.text ===
|
|
568980
|
+
if (items.some((item) => item.text === clean7 && item.source === source)) {
|
|
568520
568981
|
return items;
|
|
568521
568982
|
}
|
|
568522
568983
|
return [
|
|
568523
568984
|
...items,
|
|
568524
568985
|
{
|
|
568525
568986
|
id: nextId2("unresolved", items.length),
|
|
568526
|
-
text:
|
|
568987
|
+
text: clean7,
|
|
568527
568988
|
source,
|
|
568528
568989
|
recordedAtIso: nowIso3()
|
|
568529
568990
|
}
|
|
@@ -568697,6 +569158,11 @@ function finalizeCompletionLedgerTruth(ledger) {
|
|
|
568697
569158
|
} else if (effectiveLastVerification >= 0 && lastVerificationInvalidatingMutation > effectiveLastVerification) {
|
|
568698
569159
|
unresolved = appendUnresolved(unresolved, "File changes occurred after the last successful verification; final verification is stale.", "verification_freshness");
|
|
568699
569160
|
}
|
|
569161
|
+
if (ledger.integrationClosure) {
|
|
569162
|
+
for (const blocker of integrationClosureCompletionBlockers(ledger.integrationClosure)) {
|
|
569163
|
+
unresolved = appendUnresolved(unresolved, `Integration closure incomplete: ${blocker}`, "integration_closure");
|
|
569164
|
+
}
|
|
569165
|
+
}
|
|
568700
569166
|
const latestCritique = ledger.critiques.at(-1);
|
|
568701
569167
|
const status = ledger.status === "blocked" || ledger.status === "request_changes" ? ledger.status : unresolved.length > 0 ? "incomplete_verification" : latestCritique?.verdict === "approve" ? "approved" : ledger.status === "incomplete_verification" ? "open" : ledger.status;
|
|
568702
569168
|
return {
|
|
@@ -568718,6 +569184,7 @@ var CONTROLLER_ARTIFACT_RE;
|
|
|
568718
569184
|
var init_completionLedger = __esm({
|
|
568719
569185
|
"packages/orchestrator/dist/completionLedger.js"() {
|
|
568720
569186
|
"use strict";
|
|
569187
|
+
init_integrationClosure();
|
|
568721
569188
|
init_completionContract();
|
|
568722
569189
|
CONTROLLER_ARTIFACT_RE = /(?:^|[\\/])\.omnius(?:[\\/]|$)/i;
|
|
568723
569190
|
}
|
|
@@ -569153,7 +569620,7 @@ var init_completionAutoFinalize = __esm({
|
|
|
569153
569620
|
import { mkdirSync as mkdirSync52, readFileSync as readFileSync67, renameSync as renameSync9, unlinkSync as unlinkSync17, writeFileSync as writeFileSync43 } from "node:fs";
|
|
569154
569621
|
import { join as join99 } from "node:path";
|
|
569155
569622
|
import { createHash as createHash28 } from "node:crypto";
|
|
569156
|
-
function
|
|
569623
|
+
function clean4(value2, max) {
|
|
569157
569624
|
return String(value2 ?? "").replace(/\s+/g, " ").trim().slice(0, max);
|
|
569158
569625
|
}
|
|
569159
569626
|
function isValidObservationReceipt(entry) {
|
|
@@ -569221,7 +569688,7 @@ function buildCompletionFinalizationRecord(input) {
|
|
|
569221
569688
|
...typeof input.taskEpoch === "number" ? { taskEpoch: input.taskEpoch } : {},
|
|
569222
569689
|
status: input.status,
|
|
569223
569690
|
...input.ledger ? { ledgerStatus: input.ledger.status } : {},
|
|
569224
|
-
summary:
|
|
569691
|
+
summary: clean4(input.summary, 4e3),
|
|
569225
569692
|
committedAtIso,
|
|
569226
569693
|
evidenceIds: evidence.evidenceIds,
|
|
569227
569694
|
commandReceipts: evidence.commandReceipts,
|
|
@@ -576162,13 +576629,13 @@ function buildTrajectoryCheckpoint(input) {
|
|
|
576162
576629
|
currentStep: currentStep || void 0,
|
|
576163
576630
|
situationAssessment,
|
|
576164
576631
|
groundingSource,
|
|
576165
|
-
groundingEvidenceRefs: canUseGenerated ?
|
|
576632
|
+
groundingEvidenceRefs: canUseGenerated ? unique3(generated.evidenceRefs, MAX_FACTS) : void 0,
|
|
576166
576633
|
completedWork,
|
|
576167
576634
|
groundedFacts: groundedFacts.slice(0, MAX_FACTS),
|
|
576168
|
-
openQuestions:
|
|
576635
|
+
openQuestions: unique3([...openQuestions, ...generatedOpenQuestions], 2),
|
|
576169
576636
|
nextAction: sanitizeTrajectoryText(nextAction, 320),
|
|
576170
576637
|
successEvidence: sanitizeTrajectoryText(successEvidence, 280),
|
|
576171
|
-
doNotRepeat:
|
|
576638
|
+
doNotRepeat: unique3([...doNotRepeat, ...generatedConstraints], MAX_CONSTRAINTS)
|
|
576172
576639
|
};
|
|
576173
576640
|
const fingerprint2 = trajectoryCheckpointFingerprint(checkpointWithoutIdentity);
|
|
576174
576641
|
return {
|
|
@@ -576263,7 +576730,7 @@ function parseTrajectoryGeneratedGrounding(raw, allowedEvidenceRefs) {
|
|
|
576263
576730
|
doNotRepeat: stringArray3(parsed["do_not_repeat"] ?? parsed["doNotRepeat"], MAX_CONSTRAINTS),
|
|
576264
576731
|
// A goal is always an allowed fact; retain it as a conservative fallback
|
|
576265
576732
|
// for models that omit the optional citation field.
|
|
576266
|
-
evidenceRefs: refs.length > 0 ?
|
|
576733
|
+
evidenceRefs: refs.length > 0 ? unique3(refs, MAX_FACTS) : ["goal"]
|
|
576267
576734
|
};
|
|
576268
576735
|
}
|
|
576269
576736
|
function scopeTrajectoryCheckpoint(checkpoint, delegatedScope, exitEvidence) {
|
|
@@ -576360,7 +576827,7 @@ function extractFocusNextAction(value2) {
|
|
|
576360
576827
|
return null;
|
|
576361
576828
|
}
|
|
576362
576829
|
}
|
|
576363
|
-
function
|
|
576830
|
+
function unique3(values, limit) {
|
|
576364
576831
|
return [...new Set(values.map((value2) => sanitizeTrajectoryText(value2)).filter(Boolean))].slice(0, limit);
|
|
576365
576832
|
}
|
|
576366
576833
|
function deterministicSituationAssessment(input) {
|
|
@@ -576396,11 +576863,11 @@ function parseJsonObject5(raw) {
|
|
|
576396
576863
|
function stringArray3(value2, limit) {
|
|
576397
576864
|
if (!Array.isArray(value2))
|
|
576398
576865
|
return [];
|
|
576399
|
-
return
|
|
576866
|
+
return unique3(value2.map((item) => sanitizeTrajectoryText(item, 280)), limit);
|
|
576400
576867
|
}
|
|
576401
576868
|
function truncate2(value2, max) {
|
|
576402
|
-
const
|
|
576403
|
-
return
|
|
576869
|
+
const clean7 = String(value2 ?? "").trim();
|
|
576870
|
+
return clean7.length > max ? `${clean7.slice(0, Math.max(0, max - 1))}…` : clean7;
|
|
576404
576871
|
}
|
|
576405
576872
|
function shortHash2(value2) {
|
|
576406
576873
|
let hash2 = 2166136261;
|
|
@@ -580338,8 +580805,8 @@ function signalIdentityKeys(signal) {
|
|
|
580338
580805
|
signal.id,
|
|
580339
580806
|
...signal.tags ?? []
|
|
580340
580807
|
].flatMap((key) => {
|
|
580341
|
-
const
|
|
580342
|
-
return
|
|
580808
|
+
const clean7 = typeof key === "string" ? key.trim() : "";
|
|
580809
|
+
return clean7 ? [clean7] : [];
|
|
580343
580810
|
});
|
|
580344
580811
|
}
|
|
580345
580812
|
function choosePreferredSignal(a2, b) {
|
|
@@ -581311,19 +581778,19 @@ function compileContextFrameV2(input) {
|
|
|
581311
581778
|
createdTurn: input.turn,
|
|
581312
581779
|
ttlTurns: 1
|
|
581313
581780
|
});
|
|
581314
|
-
const
|
|
581781
|
+
const frame2 = builder.build(goalSignal ? [goalSignal, ...normalized.signals] : normalized.signals, {
|
|
581315
581782
|
turn: input.turn,
|
|
581316
581783
|
...input.frameOptions
|
|
581317
581784
|
});
|
|
581318
|
-
warnings.push(...
|
|
581785
|
+
warnings.push(...frame2.diagnostics.qualityWarnings);
|
|
581319
581786
|
return {
|
|
581320
|
-
...
|
|
581787
|
+
...frame2,
|
|
581321
581788
|
compilerDiagnostics: {
|
|
581322
581789
|
warnings: [...new Set(warnings)],
|
|
581323
|
-
admittedSignals:
|
|
581790
|
+
admittedSignals: frame2.included.length,
|
|
581324
581791
|
rejectedSignals: normalized.rejected.length,
|
|
581325
581792
|
hadConcreteGoal: goal.concrete,
|
|
581326
|
-
admittedChars:
|
|
581793
|
+
admittedChars: frame2.included.reduce((total, signal) => total + signal.content.length, 0),
|
|
581327
581794
|
droppedChars: normalized.rejected.reduce((total, signal) => total + signal.content.length, 0),
|
|
581328
581795
|
droppedSources: normalized.rejected.map((signal) => signal.source)
|
|
581329
581796
|
}
|
|
@@ -586306,9 +586773,9 @@ function extractClaims(text2) {
|
|
|
586306
586773
|
const hasColonAssertion = /^[A-Z][^:]{5,}:\s/.test(trimmed);
|
|
586307
586774
|
const looksFactual = /^(result|output|status|exit|error|build|test)/i.test(trimmed) && /:/.test(trimmed) || /^(successfully|failed|completed|finished|created|deleted|modified|updated)\b/i.test(trimmed);
|
|
586308
586775
|
if (isAssertion || hasColonAssertion || looksFactual) {
|
|
586309
|
-
const
|
|
586310
|
-
if (
|
|
586311
|
-
claims.push(
|
|
586776
|
+
const clean7 = trimmed.replace(/[`*_~#]/g, "").replace(/\s+/g, " ").trim();
|
|
586777
|
+
if (clean7.length >= 15 && clean7.length <= 600) {
|
|
586778
|
+
claims.push(clean7);
|
|
586312
586779
|
}
|
|
586313
586780
|
}
|
|
586314
586781
|
}
|
|
@@ -588163,17 +588630,17 @@ function queryTerms(query) {
|
|
|
588163
588630
|
];
|
|
588164
588631
|
}
|
|
588165
588632
|
function cleanBriefText(value2, max) {
|
|
588166
|
-
const
|
|
588167
|
-
return
|
|
588633
|
+
const clean7 = String(value2 ?? "").replace(/\x1B\[[0-?]*[ -/]*[@-~]/g, "").replace(/[\x00-\x1F\x7F]/g, " ").replace(/\s+/g, " ").trim();
|
|
588634
|
+
return clean7.length > max ? `${clean7.slice(0, Math.max(0, max - 1))}…` : clean7;
|
|
588168
588635
|
}
|
|
588169
588636
|
function firstBriefText(values) {
|
|
588170
588637
|
for (const value2 of values) {
|
|
588171
|
-
const
|
|
588172
|
-
if (!
|
|
588638
|
+
const clean7 = cleanBriefText(value2, 320);
|
|
588639
|
+
if (!clean7)
|
|
588173
588640
|
continue;
|
|
588174
|
-
if (/^take one narrow, evidence-backed action/i.test(
|
|
588641
|
+
if (/^take one narrow, evidence-backed action/i.test(clean7))
|
|
588175
588642
|
continue;
|
|
588176
|
-
return
|
|
588643
|
+
return clean7;
|
|
588177
588644
|
}
|
|
588178
588645
|
return "";
|
|
588179
588646
|
}
|
|
@@ -588186,26 +588653,26 @@ function asActionClause(value2) {
|
|
|
588186
588653
|
return cleanBriefText(value2, 320).replace(/^to\s+/i, "").replace(/[.?!]+$/, "").replace(/^([A-Z])/, (match) => match.toLowerCase());
|
|
588187
588654
|
}
|
|
588188
588655
|
function fileLocalDiscoveryQuestion(value2, path16) {
|
|
588189
|
-
const
|
|
588190
|
-
if (!
|
|
588656
|
+
const clean7 = cleanBriefText(value2, 320);
|
|
588657
|
+
if (!clean7)
|
|
588191
588658
|
return "";
|
|
588192
|
-
if (/^(?:exploring|editing|reading|verifying|current|next(?:_valid)?_action)\s*:/i.test(
|
|
588659
|
+
if (/^(?:exploring|editing|reading|verifying|current|next(?:_valid)?_action)\s*:/i.test(clean7) || /\b(?:controller state|branch-extract|active context frame|file_read block|runtime repair|recovery required)\b/i.test(clean7)) {
|
|
588193
588660
|
return "";
|
|
588194
588661
|
}
|
|
588195
|
-
const referencedPaths =
|
|
588662
|
+
const referencedPaths = clean7.match(/[\w./-]+\.(?:[cm]?[jt]sx?|py|cpp|cxx|h(?:pp)?|md|json|yaml|yml)/g) ?? [];
|
|
588196
588663
|
const targetBase = path16.split("/").pop() ?? path16;
|
|
588197
588664
|
if (referencedPaths.length > 0 && !referencedPaths.some((candidate) => candidate === targetBase || path16.endsWith(candidate))) {
|
|
588198
588665
|
return "";
|
|
588199
588666
|
}
|
|
588200
|
-
return
|
|
588667
|
+
return clean7;
|
|
588201
588668
|
}
|
|
588202
588669
|
function fileLocalFailureForPath(value2, path16) {
|
|
588203
|
-
const
|
|
588204
|
-
if (!
|
|
588670
|
+
const clean7 = fileLocalDiscoveryQuestion(value2, path16);
|
|
588671
|
+
if (!clean7)
|
|
588205
588672
|
return "";
|
|
588206
588673
|
const targetBase = path16.split("/").pop() ?? path16;
|
|
588207
|
-
const mentionsTarget =
|
|
588208
|
-
return mentionsTarget || !/[\w./-]+\.(?:[cm]?[jt]sx?|py|cpp|cxx|h(?:pp)?)/.test(
|
|
588674
|
+
const mentionsTarget = clean7.includes(targetBase) || clean7.includes(path16);
|
|
588675
|
+
return mentionsTarget || !/[\w./-]+\.(?:[cm]?[jt]sx?|py|cpp|cxx|h(?:pp)?)/.test(clean7) ? clean7 : "";
|
|
588209
588676
|
}
|
|
588210
588677
|
function selectWindows(lines, terms2) {
|
|
588211
588678
|
const matched = [];
|
|
@@ -591070,17 +591537,17 @@ function resolveTrajectoryGroundingMode(explicit, subAgent) {
|
|
|
591070
591537
|
}
|
|
591071
591538
|
return subAgent ? "off" : "adaptive";
|
|
591072
591539
|
}
|
|
591073
|
-
function upsertContextFrame(messages2,
|
|
591540
|
+
function upsertContextFrame(messages2, frame2, marker = "[ACTIVE CONTEXT FRAME]") {
|
|
591074
591541
|
for (let i2 = messages2.length - 1; i2 >= 0; i2--) {
|
|
591075
591542
|
const m2 = messages2[i2];
|
|
591076
591543
|
if (m2 && m2.role === "system" && typeof m2.content === "string" && m2.content.startsWith(marker)) {
|
|
591077
591544
|
messages2.splice(i2, 1);
|
|
591078
591545
|
}
|
|
591079
591546
|
}
|
|
591080
|
-
if (!
|
|
591547
|
+
if (!frame2)
|
|
591081
591548
|
return;
|
|
591082
591549
|
const insertAt = Math.max(0, messages2.length - 1);
|
|
591083
|
-
messages2.splice(insertAt, 0, { role: "system", content:
|
|
591550
|
+
messages2.splice(insertAt, 0, { role: "system", content: frame2 });
|
|
591084
591551
|
}
|
|
591085
591552
|
function textFromMessageContent(content) {
|
|
591086
591553
|
if (typeof content === "string")
|
|
@@ -591730,6 +592197,7 @@ var init_agenticRunner = __esm({
|
|
|
591730
592197
|
init_permissionRuleset();
|
|
591731
592198
|
init_steeringIntake();
|
|
591732
592199
|
init_completionLedger();
|
|
592200
|
+
init_integrationClosure();
|
|
591733
592201
|
init_completionAutoFinalize();
|
|
591734
592202
|
init_completionFinalization();
|
|
591735
592203
|
init_verificationCommand();
|
|
@@ -595077,6 +595545,7 @@ ${read3.content}`;
|
|
|
595077
595545
|
if (!this._completionLedger)
|
|
595078
595546
|
return true;
|
|
595079
595547
|
try {
|
|
595548
|
+
this._refreshIntegrationClosure();
|
|
595080
595549
|
const dir = _pathJoin(this.omniusStateDir(), "completion-ledgers");
|
|
595081
595550
|
_fsMkdirSync(dir, { recursive: true });
|
|
595082
595551
|
saveCompletionLedger(
|
|
@@ -595090,6 +595559,49 @@ ${read3.content}`;
|
|
|
595090
595559
|
return false;
|
|
595091
595560
|
}
|
|
595092
595561
|
}
|
|
595562
|
+
/**
|
|
595563
|
+
* Build the durable requirement→claim→path→evidence projection from facts
|
|
595564
|
+
* already owned by the runner. It never scans or indexes on demand: an
|
|
595565
|
+
* unavailable code graph simply contributes no runtime-boundary edges.
|
|
595566
|
+
*/
|
|
595567
|
+
_refreshIntegrationClosure() {
|
|
595568
|
+
const goal = this._taskState.originalGoal || this._taskState.goal || this._completionLedger?.goal || "unspecified";
|
|
595569
|
+
const modifiedPaths = [...this._taskState.modifiedFiles.keys()].map((path16) => this._normalizeEvidencePath(path16)).filter((path16) => path16 && !path16.startsWith(".omnius/"));
|
|
595570
|
+
const closure = buildIntegrationClosure({
|
|
595571
|
+
goal,
|
|
595572
|
+
ledger: this._completionLedger,
|
|
595573
|
+
modifiedPaths,
|
|
595574
|
+
contractIds: this._referenceContractSelections.map((contract) => contract.id),
|
|
595575
|
+
codeGraph: getCodeGraphDBIfReady(this.authoritativeWorkingDirectory())
|
|
595576
|
+
});
|
|
595577
|
+
if (this._completionLedger) {
|
|
595578
|
+
this._completionLedger = setIntegrationClosure(this._completionLedger, closure);
|
|
595579
|
+
}
|
|
595580
|
+
return closure;
|
|
595581
|
+
}
|
|
595582
|
+
/**
|
|
595583
|
+
* Promote concrete final-summary assertions into stable ledger claims before
|
|
595584
|
+
* a completion decision. Repeated identical summaries reuse their original
|
|
595585
|
+
* node, allowing later tool evidence to close the same graph edge instead
|
|
595586
|
+
* of creating a fresh claim on every retry.
|
|
595587
|
+
*/
|
|
595588
|
+
_recordCompletionSummaryClaims(summary) {
|
|
595589
|
+
if (!this._completionLedger)
|
|
595590
|
+
return;
|
|
595591
|
+
const text2 = String(summary ?? "").trim();
|
|
595592
|
+
if (!text2)
|
|
595593
|
+
return;
|
|
595594
|
+
const claims = deriveClaimsFromProposedText({
|
|
595595
|
+
text: text2,
|
|
595596
|
+
source: "task_complete_summary",
|
|
595597
|
+
existing: this._completionLedger.proposedClaims,
|
|
595598
|
+
taskText: this._taskState.originalGoal || this._taskState.goal || this._completionLedger.goal,
|
|
595599
|
+
workspaceInventory: this._completionLedger.claimDiscovery?.boundedInventory
|
|
595600
|
+
});
|
|
595601
|
+
if (claims.length === 0)
|
|
595602
|
+
return;
|
|
595603
|
+
this._completionLedger = reconcileClaimsWithEvidence(addCompletionClaims(this._completionLedger, claims));
|
|
595604
|
+
}
|
|
595093
595605
|
_initializeCompletionContract(task, context2, actualUserGoal) {
|
|
595094
595606
|
const goalText = actualUserGoal || task;
|
|
595095
595607
|
const seedTexts = actualUserGoal ? [goalText] : [goalText, context2 ?? ""];
|
|
@@ -597377,6 +597889,9 @@ ${modelVisible}` : modelVisible || result.error || displayOutput || "";
|
|
|
597377
597889
|
});
|
|
597378
597890
|
}
|
|
597379
597891
|
}
|
|
597892
|
+
if (this._completionLedger) {
|
|
597893
|
+
this._completionLedger = reconcileClaimsWithEvidence(this._completionLedger);
|
|
597894
|
+
}
|
|
597380
597895
|
this._saveCompletionLedgerSafe();
|
|
597381
597896
|
}
|
|
597382
597897
|
/**
|
|
@@ -597450,9 +597965,9 @@ ${modelVisible}` : modelVisible || result.error || displayOutput || "";
|
|
|
597450
597965
|
return updated.claimDiscovery;
|
|
597451
597966
|
}
|
|
597452
597967
|
_completionArtifactHashes(paths) {
|
|
597453
|
-
const
|
|
597968
|
+
const unique5 = [...new Set(paths.map((path16) => this._normalizeEvidencePath(path16)).filter(Boolean))].slice(0, 20);
|
|
597454
597969
|
const out = [];
|
|
597455
|
-
for (const path16 of
|
|
597970
|
+
for (const path16 of unique5) {
|
|
597456
597971
|
try {
|
|
597457
597972
|
const absolute = _pathResolve(this.authoritativeWorkingDirectory(), path16);
|
|
597458
597973
|
if (!_fsExistsSync(absolute))
|
|
@@ -600248,21 +600763,21 @@ ${sections.join("\n")}` : sections.join("\n");
|
|
|
600248
600763
|
sections.push(`Compacted historical entries: ${compactedCount}. They show what was observed earlier, not what is currently on disk. Re-run the narrow read or verifier when freshness matters.`);
|
|
600249
600764
|
}
|
|
600250
600765
|
if (filesRead.length > 0) {
|
|
600251
|
-
const
|
|
600252
|
-
sections.push(`Files already read (${
|
|
600766
|
+
const unique5 = [...new Set(filesRead)].slice(0, 30);
|
|
600767
|
+
sections.push(`Files already read (${unique5.length}): ${unique5.join(", ")}`);
|
|
600253
600768
|
}
|
|
600254
600769
|
if (dirsListed.length > 0) {
|
|
600255
|
-
const
|
|
600256
|
-
sections.push(`Directories already listed (${
|
|
600770
|
+
const unique5 = [...new Set(dirsListed)].slice(0, 15);
|
|
600771
|
+
sections.push(`Directories already listed (${unique5.length}): ${unique5.join(", ")}`);
|
|
600257
600772
|
sections.push(`Do not call list_directory again on these exact directories unless you changed their contents. Use the listed child paths directly with file_read/edit/delegation.`);
|
|
600258
600773
|
}
|
|
600259
600774
|
if (searches.length > 0) {
|
|
600260
|
-
const
|
|
600261
|
-
sections.push(`Searches already run (${
|
|
600775
|
+
const unique5 = [...new Set(searches)].slice(0, 15);
|
|
600776
|
+
sections.push(`Searches already run (${unique5.length}): ${unique5.join(", ")}`);
|
|
600262
600777
|
}
|
|
600263
600778
|
if (shells.length > 0) {
|
|
600264
|
-
const
|
|
600265
|
-
sections.push(`Shell commands already executed (${
|
|
600779
|
+
const unique5 = [...new Set(shells)].slice(0, 15);
|
|
600780
|
+
sections.push(`Shell commands already executed (${unique5.length}): ${unique5.join(", ")}`);
|
|
600266
600781
|
}
|
|
600267
600782
|
if (sections.length <= 1)
|
|
600268
600783
|
return null;
|
|
@@ -600287,8 +600802,8 @@ ${sections.join("\n")}` : sections.join("\n");
|
|
|
600287
600802
|
}
|
|
600288
600803
|
/** Stable marker every ACTIVE CONTEXT FRAME begins with (see context-fabric.ts). */
|
|
600289
600804
|
static CONTEXT_FRAME_MARKER = "[ACTIVE CONTEXT FRAME]";
|
|
600290
|
-
_insertContextFrame(messages2,
|
|
600291
|
-
upsertContextFrame(messages2,
|
|
600805
|
+
_insertContextFrame(messages2, frame2) {
|
|
600806
|
+
upsertContextFrame(messages2, frame2, _AgenticRunner.CONTEXT_FRAME_MARKER);
|
|
600292
600807
|
}
|
|
600293
600808
|
/**
|
|
600294
600809
|
* Retire historic imperative recovery prose before compiling model context.
|
|
@@ -600871,7 +601386,7 @@ ${String(concreteGoal).replace(/\s+/g, " ").trim().slice(0, 1200)}` : null
|
|
|
600871
601386
|
includeDiagnostics: process.env["OMNIUS_CONTEXT_FABRIC_DIAGNOSTICS"] === "1"
|
|
600872
601387
|
};
|
|
600873
601388
|
const compilerEnabled = process.env["OMNIUS_CONTEXT_COMPILER_V2"] !== "0";
|
|
600874
|
-
const
|
|
601389
|
+
const frame2 = compilerEnabled ? compileContextFrameV2({
|
|
600875
601390
|
turn,
|
|
600876
601391
|
currentGoal: concreteGoal,
|
|
600877
601392
|
signals: this._contextLedger.values(),
|
|
@@ -600889,9 +601404,9 @@ ${String(concreteGoal).replace(/\s+/g, " ").trim().slice(0, 1200)}` : null
|
|
|
600889
601404
|
hadConcreteGoal: Boolean(concreteGoal)
|
|
600890
601405
|
}
|
|
600891
601406
|
};
|
|
600892
|
-
this._lastContextFrameDiagnostics =
|
|
600893
|
-
const phaseContractAdmitted =
|
|
600894
|
-
const visibleContractIds = new Set(phaseContractAdmitted ? phaseContracts.contracts.filter((contract) =>
|
|
601407
|
+
this._lastContextFrameDiagnostics = frame2.diagnostics;
|
|
601408
|
+
const phaseContractAdmitted = frame2.included.some((signal) => signal.source === "turn.reference-contracts");
|
|
601409
|
+
const visibleContractIds = new Set(phaseContractAdmitted ? phaseContracts.contracts.filter((contract) => frame2.content?.includes(`id=${contract.id}`)).map((contract) => contract.id) : []);
|
|
600895
601410
|
this._referenceContractPhase = referenceContractPhase;
|
|
600896
601411
|
this._referenceContractSelections = [
|
|
600897
601412
|
...this._stableReferenceContracts,
|
|
@@ -600901,29 +601416,29 @@ ${String(concreteGoal).replace(/\s+/g, " ").trim().slice(0, 1200)}` : null
|
|
|
600901
601416
|
}))
|
|
600902
601417
|
];
|
|
600903
601418
|
this._lastContextSignalTrace = {
|
|
600904
|
-
included:
|
|
600905
|
-
dropped:
|
|
601419
|
+
included: frame2.included.map((signal) => signal.id),
|
|
601420
|
+
dropped: frame2.dropped.map((signal) => signal.id)
|
|
600906
601421
|
};
|
|
600907
|
-
if (
|
|
601422
|
+
if (frame2.compilerDiagnostics.warnings.length > 0 && process.env["OMNIUS_CONTEXT_COMPILER_STATUS"] === "1") {
|
|
600908
601423
|
this.emit({
|
|
600909
601424
|
type: "status",
|
|
600910
|
-
content: `Context compiler warnings: ${
|
|
601425
|
+
content: `Context compiler warnings: ${frame2.compilerDiagnostics.warnings.join(", ")}`,
|
|
600911
601426
|
turn,
|
|
600912
601427
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
600913
601428
|
});
|
|
600914
601429
|
}
|
|
600915
|
-
semantic.snapshot.frameTokens =
|
|
600916
|
-
semantic.snapshot.droppedSignals =
|
|
600917
|
-
semantic.snapshot.truncatedSignals =
|
|
600918
|
-
semantic.snapshot.semanticChunkCount =
|
|
601430
|
+
semantic.snapshot.frameTokens = frame2.diagnostics.estimatedTokens;
|
|
601431
|
+
semantic.snapshot.droppedSignals = frame2.diagnostics.droppedSignals;
|
|
601432
|
+
semantic.snapshot.truncatedSignals = frame2.diagnostics.truncatedSignals;
|
|
601433
|
+
semantic.snapshot.semanticChunkCount = frame2.diagnostics.semanticChunkCount;
|
|
600919
601434
|
await this._maybeRunDynamicContextConsolidation({
|
|
600920
601435
|
turn,
|
|
600921
601436
|
snapshot: semantic.snapshot,
|
|
600922
601437
|
forgettingReport: semantic.forgettingReport,
|
|
600923
|
-
diagnostics:
|
|
601438
|
+
diagnostics: frame2.diagnostics,
|
|
600924
601439
|
semanticSignals: semantic.signals
|
|
600925
601440
|
});
|
|
600926
|
-
return
|
|
601441
|
+
return frame2.content;
|
|
600927
601442
|
}
|
|
600928
601443
|
/**
|
|
600929
601444
|
* Feed the ContextTree one tool call, detect phase transitions, and — on a
|
|
@@ -605158,6 +605673,34 @@ ${dynamicProjectContext}`
|
|
|
605158
605673
|
});
|
|
605159
605674
|
return true;
|
|
605160
605675
|
};
|
|
605676
|
+
const holdIntegrationClosureTaskComplete = (turn) => {
|
|
605677
|
+
if (!this._completionLedger)
|
|
605678
|
+
return false;
|
|
605679
|
+
const closure = this._refreshIntegrationClosure();
|
|
605680
|
+
const blockers = integrationClosureCompletionBlockers(closure);
|
|
605681
|
+
if (blockers.length === 0)
|
|
605682
|
+
return false;
|
|
605683
|
+
const feedback = [
|
|
605684
|
+
"[COMPLETION BLOCKED — integration closure incomplete]",
|
|
605685
|
+
"Material claims need a linked implementation path and fresh matching evidence before a completed terminal state.",
|
|
605686
|
+
"Open closure edges:",
|
|
605687
|
+
...blockers.map((blocker) => ` - ${blocker}`),
|
|
605688
|
+
"",
|
|
605689
|
+
`Smallest next evidence: ${closure.frontier.nextEvidence[0] ?? "inspect the affected boundary and run its declared acceptance check."}`,
|
|
605690
|
+
"If a real external prerequisite prevents the work, record that specific blocker and its prerequisite instead of claiming completion."
|
|
605691
|
+
].join("\n");
|
|
605692
|
+
lastCompletionGateReason = blockers.join("; ").slice(0, 1200);
|
|
605693
|
+
lastCompletionGateFeedback = feedback;
|
|
605694
|
+
lastCompletionGateCode = "integration_closure";
|
|
605695
|
+
messages2.push({ role: "system", content: feedback });
|
|
605696
|
+
this.emit({
|
|
605697
|
+
type: "status",
|
|
605698
|
+
content: `task_complete held by integration closure: ${lastCompletionGateReason.slice(0, 360)}`,
|
|
605699
|
+
turn,
|
|
605700
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
605701
|
+
});
|
|
605702
|
+
return true;
|
|
605703
|
+
};
|
|
605161
605704
|
const completionHoldEscapeMax = (() => {
|
|
605162
605705
|
const raw = Number(process.env["OMNIUS_COMPLETION_HOLD_MAX"]);
|
|
605163
605706
|
return Number.isFinite(raw) && raw >= 1 ? Math.floor(raw) : 3;
|
|
@@ -605169,6 +605712,10 @@ ${dynamicProjectContext}`
|
|
|
605169
605712
|
return completionHoldEscapeMax * 2;
|
|
605170
605713
|
})();
|
|
605171
605714
|
const holdTaskCompleteGates = (args, turn) => {
|
|
605715
|
+
this._recordCompletionSummaryClaims(extractTaskCompleteSummary(args));
|
|
605716
|
+
if (this._completionLedger) {
|
|
605717
|
+
this._completionLedger = reconcileClaimsWithEvidence(this._completionLedger);
|
|
605718
|
+
}
|
|
605172
605719
|
if (this._hasEvidenceBackedBlockedCompletion(args)) {
|
|
605173
605720
|
this._completionHoldState.count = 0;
|
|
605174
605721
|
this._completionHoldState.lastKey = "";
|
|
@@ -605206,7 +605753,7 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
605206
605753
|
lastCompletionGateCode = "";
|
|
605207
605754
|
return true;
|
|
605208
605755
|
}
|
|
605209
|
-
const held = holdDeliveryCoverageTaskComplete(turn) || holdCompileFixLoopTaskComplete(turn) || holdUnresolvedVerificationTaskComplete(turn) || holdNoProgressTaskComplete(args, turn) || holdProvenanceTaskComplete(args, turn) || holdClaimDiscoveryTaskComplete(turn);
|
|
605756
|
+
const held = holdDeliveryCoverageTaskComplete(turn) || holdCompileFixLoopTaskComplete(turn) || holdUnresolvedVerificationTaskComplete(turn) || holdNoProgressTaskComplete(args, turn) || holdProvenanceTaskComplete(args, turn) || holdClaimDiscoveryTaskComplete(turn) || holdIntegrationClosureTaskComplete(turn);
|
|
605210
605757
|
if (!held) {
|
|
605211
605758
|
this._completionHoldState.count = 0;
|
|
605212
605759
|
this._completionHoldState.lastKey = "";
|
|
@@ -605218,7 +605765,7 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
605218
605765
|
this._focusSupervisor?.markCompletionBlocked({
|
|
605219
605766
|
turn,
|
|
605220
605767
|
reason: lastCompletionGateReason || "completion requested before required evidence was present",
|
|
605221
|
-
requiredNextAction: lastCompletionGateCode === "delivery_coverage" ? "read_authoritative_target" : lastCompletionGateCode === "compile_error_fix_loop" ? "run_verification" : lastCompletionGateCode === "todo_verification" ? "run_verification" : "update_todos"
|
|
605768
|
+
requiredNextAction: lastCompletionGateCode === "delivery_coverage" ? "read_authoritative_target" : lastCompletionGateCode === "compile_error_fix_loop" ? "run_verification" : lastCompletionGateCode === "todo_verification" ? "run_verification" : lastCompletionGateCode === "integration_closure" ? "run_verification" : "update_todos"
|
|
605222
605769
|
});
|
|
605223
605770
|
const focusDirective = this._focusSupervisor?.snapshot().directive;
|
|
605224
605771
|
if (focusDirective) {
|
|
@@ -605326,10 +605873,6 @@ ${lastCompletionGateFeedback.trim().slice(0, 4e3)}` : ""
|
|
|
605326
605873
|
this._claimDiscoveryInitialized = true;
|
|
605327
605874
|
const _survey = await this._resolveClaimDiscoverySurvey(task, 0);
|
|
605328
605875
|
this._completionLedger = setClaimDiscoveryState(this._completionLedger, _survey);
|
|
605329
|
-
messages2.push({
|
|
605330
|
-
role: "system",
|
|
605331
|
-
content: "[CLAIM DISCOVERY] Grounding signals (compact):\n" + claimDiscoveryControllerSignals(this._completionLedger.claimDiscovery).join("\n")
|
|
605332
|
-
});
|
|
605333
605876
|
this.emit({
|
|
605334
605877
|
type: "status",
|
|
605335
605878
|
content: `[CLAIM DISCOVERY] initialized from bounded inventory: ${this._completionLedger.claimDiscovery?.candidatePaths.length ?? 0} candidate path(s), status=${this._completionLedger.claimDiscovery?.status ?? "skipped"}`,
|
|
@@ -606321,13 +606864,13 @@ Respond with EXACTLY this structure before your next tool call:
|
|
|
606321
606864
|
callable: _pfvCallable
|
|
606322
606865
|
}).then((_pfvResult) => {
|
|
606323
606866
|
if (!_pfvResult.verdict.parseFallback && _pfvResult.verdict.verdict !== "continue") {
|
|
606324
|
-
const
|
|
606867
|
+
const frame2 = _pfvResult.verdict.recommended_frame;
|
|
606325
606868
|
this._recordRecoveryControllerDelta({
|
|
606326
606869
|
source: "problem_frame",
|
|
606327
606870
|
turn,
|
|
606328
606871
|
diagnosis: `${_pfvResult.verdict.verdict}: ${_pfvResult.verdict.rationale}`,
|
|
606329
|
-
nextAction:
|
|
606330
|
-
verification:
|
|
606872
|
+
nextAction: frame2?.new_subtask || _pfvResult.verdict.blocker_summary || "Re-evaluate the active task frame against current evidence.",
|
|
606873
|
+
verification: frame2?.success_criterion || "Record new evidence for the selected frame."
|
|
606331
606874
|
});
|
|
606332
606875
|
this.emit({
|
|
606333
606876
|
type: "status",
|
|
@@ -611590,6 +612133,8 @@ ${this._completionCaveat}` : this._completionCaveat;
|
|
|
611590
612133
|
}
|
|
611591
612134
|
if (this._completionLedger) {
|
|
611592
612135
|
this._reconcileDeliveryCoverageForCompletion();
|
|
612136
|
+
this._completionLedger = reconcileClaimsWithEvidence(this._completionLedger);
|
|
612137
|
+
this._refreshIntegrationClosure();
|
|
611593
612138
|
this._completionLedger = finalizeCompletionLedgerTruth(this._completionLedger);
|
|
611594
612139
|
this._saveCompletionLedgerSafe();
|
|
611595
612140
|
if (completed && this._completionLedger.status === "incomplete_verification" && this.options.backwardPassReview !== false && !this._completionCaveat) {
|
|
@@ -613034,8 +613579,8 @@ ${marker}` : marker);
|
|
|
613034
613579
|
const path16 = this.extractPrimaryToolPath(args);
|
|
613035
613580
|
if (!path16)
|
|
613036
613581
|
return null;
|
|
613037
|
-
const
|
|
613038
|
-
const active = [...this._staleEditFamilies.values()].filter((entry) => entry.pathKey ===
|
|
613582
|
+
const pathKey2 = this.staleEditPathKey(path16);
|
|
613583
|
+
const active = [...this._staleEditFamilies.values()].filter((entry) => entry.pathKey === pathKey2).sort((a2, b) => b.lastFailureTurn - a2.lastFailureTurn).find((entry) => {
|
|
613039
613584
|
const hasFreshRead = entry.lastReadTurn > entry.lastFailureTurn;
|
|
613040
613585
|
const hasFreshMutation = entry.lastMutationTurn > entry.lastFailureTurn;
|
|
613041
613586
|
return !hasFreshMutation && (entry.count >= 2 || !hasFreshRead);
|
|
@@ -613191,11 +613736,11 @@ ${marker}` : marker);
|
|
|
613191
613736
|
"Next action: file_read the target file or range, then retry the edit with old_string copied exactly from that read and expected_hash set to the read's sha256."
|
|
613192
613737
|
].join("\n");
|
|
613193
613738
|
}
|
|
613194
|
-
staleEditFamilyKey(toolName,
|
|
613739
|
+
staleEditFamilyKey(toolName, pathKey2, errorKind, targetHash) {
|
|
613195
613740
|
return [
|
|
613196
613741
|
`epoch=${this._taskEpoch}`,
|
|
613197
613742
|
toolName,
|
|
613198
|
-
|
|
613743
|
+
pathKey2 || "(unknown)",
|
|
613199
613744
|
errorKind,
|
|
613200
613745
|
targetHash
|
|
613201
613746
|
].join(":");
|
|
@@ -613204,9 +613749,9 @@ ${marker}` : marker);
|
|
|
613204
613749
|
const target = this.staleEditTarget(toolName, args);
|
|
613205
613750
|
if (!target)
|
|
613206
613751
|
return null;
|
|
613207
|
-
const
|
|
613752
|
+
const pathKey2 = this.staleEditPathKey(target.path);
|
|
613208
613753
|
for (const entry of this._staleEditFamilies.values()) {
|
|
613209
|
-
if (entry.tool !== toolName || entry.pathKey !==
|
|
613754
|
+
if (entry.tool !== toolName || entry.pathKey !== pathKey2 || entry.targetHash !== target.targetHash)
|
|
613210
613755
|
continue;
|
|
613211
613756
|
const hasFreshRead = entry.lastReadTurn > entry.lastFailureTurn;
|
|
613212
613757
|
const hasFreshMutation = entry.lastMutationTurn > entry.lastFailureTurn;
|
|
@@ -613230,8 +613775,8 @@ ${marker}` : marker);
|
|
|
613230
613775
|
const path16 = this.extractPrimaryToolPath(args);
|
|
613231
613776
|
if (!path16)
|
|
613232
613777
|
return null;
|
|
613233
|
-
const
|
|
613234
|
-
const active = [...this._staleEditFamilies.values()].filter((entry) => entry.pathKey ===
|
|
613778
|
+
const pathKey2 = this.staleEditPathKey(path16);
|
|
613779
|
+
const active = [...this._staleEditFamilies.values()].filter((entry) => entry.pathKey === pathKey2).sort((a2, b) => b.lastFailureTurn - a2.lastFailureTurn).find((entry) => {
|
|
613235
613780
|
const hasFreshRead = entry.lastReadTurn > entry.lastFailureTurn;
|
|
613236
613781
|
const hasFreshMutation = entry.lastMutationTurn > entry.lastFailureTurn;
|
|
613237
613782
|
return !hasFreshMutation && (entry.count >= 2 || !hasFreshRead);
|
|
@@ -613267,12 +613812,12 @@ ${marker}` : marker);
|
|
|
613267
613812
|
const overwrite = args?.["overwrite"] === true || args?.["overwriteExisting"] === true;
|
|
613268
613813
|
const hasFreshContract = overwrite && this._toolCallUsesFreshFileReadEvidence(toolName, args ?? {});
|
|
613269
613814
|
if (hasFreshContract) {
|
|
613270
|
-
this._blockedFullWriteAttempts.delete(
|
|
613815
|
+
this._blockedFullWriteAttempts.delete(pathKey2);
|
|
613271
613816
|
return null;
|
|
613272
613817
|
}
|
|
613273
|
-
const previous = this._blockedFullWriteAttempts.get(
|
|
613818
|
+
const previous = this._blockedFullWriteAttempts.get(pathKey2);
|
|
613274
613819
|
const count = (previous?.count ?? 0) + 1;
|
|
613275
|
-
this._blockedFullWriteAttempts.set(
|
|
613820
|
+
this._blockedFullWriteAttempts.set(pathKey2, { count, lastTurn: turn });
|
|
613276
613821
|
if (count < 2)
|
|
613277
613822
|
return null;
|
|
613278
613823
|
return [
|
|
@@ -613373,20 +613918,20 @@ ${marker}` : marker);
|
|
|
613373
613918
|
}
|
|
613374
613919
|
noteStaleEditGuardOutcome(toolName, args, result, turn) {
|
|
613375
613920
|
const path16 = this.extractPrimaryToolPath(args);
|
|
613376
|
-
const
|
|
613921
|
+
const pathKey2 = path16 ? this.staleEditPathKey(path16) : "";
|
|
613377
613922
|
const isFreshRead = toolName === "file_read" && path16 && result.success && result.runtimeAuthored !== true;
|
|
613378
613923
|
if (isFreshRead) {
|
|
613379
|
-
this._blockedFullWriteAttempts.delete(
|
|
613924
|
+
this._blockedFullWriteAttempts.delete(pathKey2);
|
|
613380
613925
|
for (const entry of this._staleEditFamilies.values()) {
|
|
613381
|
-
if (entry.pathKey ===
|
|
613926
|
+
if (entry.pathKey === pathKey2)
|
|
613382
613927
|
entry.lastReadTurn = turn;
|
|
613383
613928
|
}
|
|
613384
613929
|
return;
|
|
613385
613930
|
}
|
|
613386
613931
|
if (toolName === "file_write" && path16 && this._isRealProjectMutation(toolName, result)) {
|
|
613387
|
-
this._blockedFullWriteAttempts.delete(
|
|
613932
|
+
this._blockedFullWriteAttempts.delete(pathKey2);
|
|
613388
613933
|
for (const [key2, entry] of this._staleEditFamilies) {
|
|
613389
|
-
if (entry.pathKey ===
|
|
613934
|
+
if (entry.pathKey === pathKey2)
|
|
613390
613935
|
this._staleEditFamilies.delete(key2);
|
|
613391
613936
|
}
|
|
613392
613937
|
return;
|
|
@@ -615564,9 +616109,8 @@ ${trimmedNew}`;
|
|
|
615564
616109
|
`next_claim_inspection=${coverage?.nextInspection?.replace(/\s+/g, " ").slice(0, 420) || "none"}`,
|
|
615565
616110
|
`evidence_handles=${evidenceHandles.join(",") || "none"}`
|
|
615566
616111
|
];
|
|
615567
|
-
|
|
615568
|
-
|
|
615569
|
-
}
|
|
616112
|
+
const integrationClosure = this._refreshIntegrationClosure();
|
|
616113
|
+
lines.push(renderIntegrationClosureFrontier(integrationClosure, 1800));
|
|
615570
616114
|
const tier = this.options.modelTier ?? "large";
|
|
615571
616115
|
const directive = this._focusSupervisor?.snapshot().directive;
|
|
615572
616116
|
if (directive && tier === "small") {
|
|
@@ -626298,6 +626842,7 @@ __export(dist_exports3, {
|
|
|
626298
626842
|
FocusSupervisor: () => FocusSupervisor,
|
|
626299
626843
|
HookManager: () => HookManager,
|
|
626300
626844
|
INFRA_WORKER_SKILL: () => INFRA_WORKER_SKILL,
|
|
626845
|
+
INTEGRATION_CLOSURE_SCHEMA: () => INTEGRATION_CLOSURE_SCHEMA,
|
|
626301
626846
|
ImportanceBudget: () => ImportanceBudget,
|
|
626302
626847
|
InMemoryConvergenceStore: () => InMemoryConvergenceStore,
|
|
626303
626848
|
JsonConvergenceStore: () => JsonConvergenceStore,
|
|
@@ -626353,6 +626898,7 @@ __export(dist_exports3, {
|
|
|
626353
626898
|
buildExplorerBriefs: () => buildExplorerBriefs,
|
|
626354
626899
|
buildExplorerPrompt: () => buildExplorerPrompt,
|
|
626355
626900
|
buildForkPrompt: () => buildForkPrompt,
|
|
626901
|
+
buildIntegrationClosure: () => buildIntegrationClosure,
|
|
626356
626902
|
buildLessonQuery: () => buildLessonQuery,
|
|
626357
626903
|
buildLockedContract: () => buildLockedContract,
|
|
626358
626904
|
buildMetaCritiquePrompt: () => buildMetaCritiquePrompt,
|
|
@@ -626489,6 +627035,7 @@ __export(dist_exports3, {
|
|
|
626489
627035
|
inferCompletionContractFromTexts: () => inferCompletionContractFromTexts,
|
|
626490
627036
|
initPluginRegistry: () => initPluginRegistry,
|
|
626491
627037
|
initializeValidationState: () => initializeValidationState,
|
|
627038
|
+
integrationClosureCompletionBlockers: () => integrationClosureCompletionBlockers,
|
|
626492
627039
|
interpretSteeringIngress: () => interpretSteeringIngress,
|
|
626493
627040
|
invokeHook: () => invokeHook,
|
|
626494
627041
|
invokeHookAsync: () => invokeHookAsync,
|
|
@@ -626577,6 +627124,7 @@ __export(dist_exports3, {
|
|
|
626577
627124
|
renderDeliveryCoverageState: () => renderDeliveryCoverageState,
|
|
626578
627125
|
renderGitProgressActionContract: () => renderGitProgressActionContract,
|
|
626579
627126
|
renderGitProgressContextBlock: () => renderGitProgressContextBlock,
|
|
627127
|
+
renderIntegrationClosureFrontier: () => renderIntegrationClosureFrontier,
|
|
626580
627128
|
renderScopedTrajectoryCheckpoint: () => renderScopedTrajectoryCheckpoint,
|
|
626581
627129
|
renderTrajectoryCheckpoint: () => renderTrajectoryCheckpoint,
|
|
626582
627130
|
renderValidationContract: () => renderValidationContract,
|
|
@@ -626610,6 +627158,7 @@ __export(dist_exports3, {
|
|
|
626610
627158
|
sealMilestone: () => sealMilestone,
|
|
626611
627159
|
sealMilestoneState: () => sealMilestoneState,
|
|
626612
627160
|
selectTopNotes: () => selectTopNotes,
|
|
627161
|
+
setIntegrationClosure: () => setIntegrationClosure,
|
|
626613
627162
|
setOllamaPool: () => setOllamaPool,
|
|
626614
627163
|
shouldBlockCall: () => shouldBlockCall,
|
|
626615
627164
|
shouldForkSkill: () => shouldForkSkill,
|
|
@@ -626685,6 +627234,7 @@ var init_dist8 = __esm({
|
|
|
626685
627234
|
init_debugArtifactLibrary();
|
|
626686
627235
|
init_focusSupervisor();
|
|
626687
627236
|
init_completionLedger();
|
|
627237
|
+
init_integrationClosure();
|
|
626688
627238
|
init_runEvents();
|
|
626689
627239
|
init_costTracker();
|
|
626690
627240
|
init_workEvaluator();
|
|
@@ -626837,8 +627387,8 @@ var init_spinner = __esm({
|
|
|
626837
627387
|
// Private
|
|
626838
627388
|
// --------------------------------------------------------------------------
|
|
626839
627389
|
_render() {
|
|
626840
|
-
const
|
|
626841
|
-
process.stdout.write(`\r\x1B[36m${
|
|
627390
|
+
const frame2 = FRAMES[this._frameIndex] ?? FRAMES[0];
|
|
627391
|
+
process.stdout.write(`\r\x1B[36m${frame2}\x1B[0m ${this._text}`);
|
|
626842
627392
|
}
|
|
626843
627393
|
};
|
|
626844
627394
|
}
|
|
@@ -627528,13 +628078,13 @@ function isLowInformationAsciiPreview(ascii2) {
|
|
|
627528
628078
|
if (!plain) return true;
|
|
627529
628079
|
const visible = plain.replace(/\s/g, "");
|
|
627530
628080
|
if (visible.length < 12) return true;
|
|
627531
|
-
const
|
|
627532
|
-
if (
|
|
628081
|
+
const unique5 = new Set(Array.from(visible));
|
|
628082
|
+
if (unique5.size <= 2 && /[█▓▒░#@]/u.test(visible)) return true;
|
|
627533
628083
|
return false;
|
|
627534
628084
|
}
|
|
627535
628085
|
function previewFailure(message2, width) {
|
|
627536
|
-
const
|
|
627537
|
-
const text2 = `[image-to-ascii preview failed: ${
|
|
628086
|
+
const clean7 = message2.replace(/\s+/g, " ").trim();
|
|
628087
|
+
const text2 = `[image-to-ascii preview failed: ${clean7 || "unknown error"}]`;
|
|
627538
628088
|
return text2.length > width ? `${text2.slice(0, Math.max(0, width - 1))}]` : text2;
|
|
627539
628089
|
}
|
|
627540
628090
|
async function convertWithImageToAscii(imagePath, width, height, timeoutMs) {
|
|
@@ -629085,16 +629635,16 @@ var init_listen = __esm({
|
|
|
629085
629635
|
return this.owners.size;
|
|
629086
629636
|
}
|
|
629087
629637
|
async acquire(owner) {
|
|
629088
|
-
const
|
|
629089
|
-
this.owners.add(
|
|
629638
|
+
const clean7 = owner.trim() || "shared";
|
|
629639
|
+
this.owners.add(clean7);
|
|
629090
629640
|
if (this.active) return `Live ASR already active (${[...this.owners].join(", ")}).`;
|
|
629091
629641
|
const result = await this.start();
|
|
629092
|
-
if (!this.active) this.owners.delete(
|
|
629642
|
+
if (!this.active) this.owners.delete(clean7);
|
|
629093
629643
|
return result;
|
|
629094
629644
|
}
|
|
629095
629645
|
async release(owner) {
|
|
629096
|
-
const
|
|
629097
|
-
this.owners.delete(
|
|
629646
|
+
const clean7 = owner.trim() || "shared";
|
|
629647
|
+
this.owners.delete(clean7);
|
|
629098
629648
|
if (this.owners.size > 0) {
|
|
629099
629649
|
return `Live ASR remains active (${[...this.owners].join(", ")}).`;
|
|
629100
629650
|
}
|
|
@@ -631114,8 +631664,8 @@ async function classifyLiveSpeech(proposal, config) {
|
|
|
631114
631664
|
}
|
|
631115
631665
|
async function classifyLiveAudioIntake(transcript, config) {
|
|
631116
631666
|
const now2 = Date.now();
|
|
631117
|
-
const
|
|
631118
|
-
if (!
|
|
631667
|
+
const clean7 = transcript.trim();
|
|
631668
|
+
if (!clean7) {
|
|
631119
631669
|
return {
|
|
631120
631670
|
intendedForAgent: false,
|
|
631121
631671
|
confidence: 1,
|
|
@@ -631142,7 +631692,7 @@ async function classifyLiveAudioIntake(transcript, config) {
|
|
|
631142
631692
|
"Do not answer the utterance. Do not treat all room speech as addressed to the agent."
|
|
631143
631693
|
].join("\n")
|
|
631144
631694
|
},
|
|
631145
|
-
{ role: "user", content:
|
|
631695
|
+
{ role: "user", content: clean7.slice(0, 1200) }
|
|
631146
631696
|
]
|
|
631147
631697
|
};
|
|
631148
631698
|
try {
|
|
@@ -631167,7 +631717,7 @@ async function classifyLiveAudioIntake(transcript, config) {
|
|
|
631167
631717
|
} catch {
|
|
631168
631718
|
}
|
|
631169
631719
|
}
|
|
631170
|
-
return { ...fallbackLiveAudioIntakeDecision(
|
|
631720
|
+
return { ...fallbackLiveAudioIntakeDecision(clean7), source: "fallback", updatedAt: now2 };
|
|
631171
631721
|
}
|
|
631172
631722
|
function summarizeInference(value2) {
|
|
631173
631723
|
if (!value2) return "objects: pending";
|
|
@@ -632230,8 +632780,8 @@ async function recordAudioSampleWithRecovery(preferred, devices, durationSec, ou
|
|
|
632230
632780
|
const requireSignal = options2.requireSignal !== false;
|
|
632231
632781
|
const ordered = [];
|
|
632232
632782
|
const add3 = (id2) => {
|
|
632233
|
-
const
|
|
632234
|
-
if (
|
|
632783
|
+
const clean7 = String(id2 ?? "").trim();
|
|
632784
|
+
if (clean7 && !ordered.includes(clean7)) ordered.push(clean7);
|
|
632235
632785
|
};
|
|
632236
632786
|
const preferredInput = preferredLiveAudioInputId(devices, preferred);
|
|
632237
632787
|
if (allowFallback) {
|
|
@@ -632586,12 +633136,12 @@ var init_live_sensors = __esm({
|
|
|
632586
633136
|
activeVideoSources() {
|
|
632587
633137
|
const ordered = [];
|
|
632588
633138
|
const add3 = (id2) => {
|
|
632589
|
-
const
|
|
632590
|
-
if (!
|
|
632591
|
-
const device = this.devices.video.find((entry) => entry.id ===
|
|
633139
|
+
const clean7 = String(id2 ?? "").trim();
|
|
633140
|
+
if (!clean7 || ordered.includes(clean7)) return;
|
|
633141
|
+
const device = this.devices.video.find((entry) => entry.id === clean7);
|
|
632592
633142
|
if (device && /metadata\/non-capture/i.test(device.detail ?? "")) return;
|
|
632593
|
-
if (!this.isCameraStreamEnabled(
|
|
632594
|
-
ordered.push(
|
|
633143
|
+
if (!this.isCameraStreamEnabled(clean7)) return;
|
|
633144
|
+
ordered.push(clean7);
|
|
632595
633145
|
};
|
|
632596
633146
|
add3(this.config.selectedCamera);
|
|
632597
633147
|
for (const device of this.devices.video) add3(device.id);
|
|
@@ -633844,22 +634394,22 @@ ${analysis}` : ""
|
|
|
633844
634394
|
let updated = false;
|
|
633845
634395
|
const previewWidth = liveDashboardPreviewWidthForSources(this.activeVideoSources().length);
|
|
633846
634396
|
for (const source of this.activeVideoSources()) {
|
|
633847
|
-
const
|
|
633848
|
-
if (!
|
|
634397
|
+
const frame2 = this.cameraStreamers.latestFrame(source);
|
|
634398
|
+
if (!frame2) continue;
|
|
633849
634399
|
const lastMtime = this.lastStreamFrameMtime.get(source) ?? 0;
|
|
633850
|
-
if (
|
|
633851
|
-
const preview = await buildImageAsciiPreview(
|
|
634400
|
+
if (frame2.mtimeMs <= lastMtime) continue;
|
|
634401
|
+
const preview = await buildImageAsciiPreview(frame2.path, { width: previewWidth });
|
|
633852
634402
|
if (!preview?.ascii && !preview?.plainAscii) continue;
|
|
633853
|
-
this.lastStreamFrameMtime.set(source,
|
|
634403
|
+
this.lastStreamFrameMtime.set(source, frame2.mtimeMs);
|
|
633854
634404
|
const observedAt = Date.now();
|
|
633855
634405
|
const orientation = this.getCameraOrientation(source);
|
|
633856
|
-
const displayPath = relative16(this.repoRoot,
|
|
634406
|
+
const displayPath = relative16(this.repoRoot, frame2.path).startsWith("..") ? frame2.path : relative16(this.repoRoot, frame2.path);
|
|
633857
634407
|
const existing = this.snapshot.cameras?.[source] ?? { updatedAt: observedAt, source };
|
|
633858
634408
|
const camera = {
|
|
633859
634409
|
...existing,
|
|
633860
634410
|
updatedAt: observedAt,
|
|
633861
634411
|
source,
|
|
633862
|
-
framePath:
|
|
634412
|
+
framePath: frame2.path,
|
|
633863
634413
|
displayPath,
|
|
633864
634414
|
ascii: preview.ascii,
|
|
633865
634415
|
plainAscii: preview.plainAscii,
|
|
@@ -633875,7 +634425,7 @@ ${analysis}` : ""
|
|
|
633875
634425
|
this.snapshot.cameras = { ...this.snapshot.cameras ?? {}, [source]: camera };
|
|
633876
634426
|
if (source === this.config.selectedCamera || !this.snapshot.video) this.snapshot.video = camera;
|
|
633877
634427
|
updated = true;
|
|
633878
|
-
void this.runLiveVlm(source,
|
|
634428
|
+
void this.runLiveVlm(source, frame2.path).catch(() => {
|
|
633879
634429
|
});
|
|
633880
634430
|
}
|
|
633881
634431
|
if (updated) {
|
|
@@ -634359,8 +634909,8 @@ ${args.liveContext.trim()}`);
|
|
|
634359
634909
|
return sections.join("\n\n");
|
|
634360
634910
|
}
|
|
634361
634911
|
function singleLine(value2, maxChars) {
|
|
634362
|
-
const
|
|
634363
|
-
return
|
|
634912
|
+
const clean7 = value2.replace(/\s+/g, " ").trim();
|
|
634913
|
+
return clean7.length > maxChars ? `${clean7.slice(0, Math.max(0, maxChars - 1))}...` : clean7;
|
|
634364
634914
|
}
|
|
634365
634915
|
function formatClock(ts) {
|
|
634366
634916
|
try {
|
|
@@ -634430,12 +634980,12 @@ function responseText(resp) {
|
|
|
634430
634980
|
const reasoning = (msg.reasoning_content ?? msg.reasoning ?? "").trim();
|
|
634431
634981
|
return reasoning;
|
|
634432
634982
|
}
|
|
634433
|
-
function acceptableEnhancement(
|
|
634434
|
-
if (!
|
|
634435
|
-
if (
|
|
634436
|
-
if (/<think>/i.test(
|
|
634437
|
-
if (
|
|
634438
|
-
if (
|
|
634983
|
+
function acceptableEnhancement(clean7, seedText) {
|
|
634984
|
+
if (!clean7) return false;
|
|
634985
|
+
if (clean7 === seedText) return false;
|
|
634986
|
+
if (/<think>/i.test(clean7)) return false;
|
|
634987
|
+
if (clean7.length > 12e3) return false;
|
|
634988
|
+
if (clean7.length < Math.min(24, seedText.length / 2)) return false;
|
|
634439
634989
|
return true;
|
|
634440
634990
|
}
|
|
634441
634991
|
async function enhancePromptViaInference(seed, backend, ctx3) {
|
|
@@ -634482,8 +635032,8 @@ ${seedText}`
|
|
|
634482
635032
|
if (!raw) return null;
|
|
634483
635033
|
const enhanced = extractEnhancedPrompt(raw);
|
|
634484
635034
|
if (!enhanced) return null;
|
|
634485
|
-
const
|
|
634486
|
-
return acceptableEnhancement(
|
|
635035
|
+
const clean7 = enhanced.trim();
|
|
635036
|
+
return acceptableEnhancement(clean7, seedText) ? clean7 : null;
|
|
634487
635037
|
} catch {
|
|
634488
635038
|
return null;
|
|
634489
635039
|
}
|
|
@@ -634685,9 +635235,9 @@ function resolveScriptSource(root, htmlFile, src2) {
|
|
|
634685
635235
|
const raw = src2.trim();
|
|
634686
635236
|
if (!raw || /^(?:https?:)?\/\//i.test(raw) || /^(?:data|blob):/i.test(raw)) return null;
|
|
634687
635237
|
const withoutHash = raw.split("#", 1)[0] ?? "";
|
|
634688
|
-
const
|
|
634689
|
-
if (!
|
|
634690
|
-
const abs =
|
|
635238
|
+
const clean7 = withoutHash.split("?", 1)[0] ?? "";
|
|
635239
|
+
if (!clean7 || !SCRIPT_EXTS.has(extname14(clean7).toLowerCase())) return null;
|
|
635240
|
+
const abs = clean7.startsWith("/") ? resolve61(root, `.${clean7}`) : resolve61(dirname38(htmlFile), clean7);
|
|
634691
635241
|
const rel = relative17(root, abs);
|
|
634692
635242
|
if (rel.startsWith("..") || rel === "") return null;
|
|
634693
635243
|
return existsSync121(abs) ? abs : null;
|
|
@@ -640450,10 +641000,10 @@ function uniqueNonEmpty(values) {
|
|
|
640450
641000
|
const seen = /* @__PURE__ */ new Set();
|
|
640451
641001
|
const out = [];
|
|
640452
641002
|
for (const value2 of values) {
|
|
640453
|
-
const
|
|
640454
|
-
if (!
|
|
640455
|
-
seen.add(
|
|
640456
|
-
out.push(
|
|
641003
|
+
const clean7 = compactDisplayText(value2, 220);
|
|
641004
|
+
if (!clean7 || seen.has(clean7)) continue;
|
|
641005
|
+
seen.add(clean7);
|
|
641006
|
+
out.push(clean7);
|
|
640457
641007
|
}
|
|
640458
641008
|
return out;
|
|
640459
641009
|
}
|
|
@@ -641908,8 +642458,8 @@ var init_tool_collapse_store = __esm({
|
|
|
641908
642458
|
|
|
641909
642459
|
// packages/cli/src/utils/internal-output.ts
|
|
641910
642460
|
function compactForDisplay(text2, max = 170) {
|
|
641911
|
-
const
|
|
641912
|
-
return
|
|
642461
|
+
const clean7 = text2.replace(/\s+/g, " ").trim();
|
|
642462
|
+
return clean7.length <= max ? clean7 : `${clean7.slice(0, Math.max(0, max - 1)).trimEnd()}…`;
|
|
641913
642463
|
}
|
|
641914
642464
|
function parseAssignmentMap(line) {
|
|
641915
642465
|
const out = {};
|
|
@@ -642369,9 +642919,9 @@ function renderVoiceText(text2) {
|
|
|
642369
642919
|
if (process.env["OMNIUS_SHOW_SPOKEN_TEXT"] !== "1" && process.env["OMNIUS_RENDER_VOICE_TEXT"] !== "1") {
|
|
642370
642920
|
return;
|
|
642371
642921
|
}
|
|
642372
|
-
const
|
|
642373
|
-
if (!
|
|
642374
|
-
process.stdout.write(` ${c3.dim("voice")} ${c3.italic(c3.dim(
|
|
642922
|
+
const clean7 = text2.replace(/\s+/g, " ").trim();
|
|
642923
|
+
if (!clean7) return;
|
|
642924
|
+
process.stdout.write(` ${c3.dim("voice")} ${c3.italic(c3.dim(clean7))}
|
|
642375
642925
|
`);
|
|
642376
642926
|
}
|
|
642377
642927
|
function renderUserInterrupt(text2) {
|
|
@@ -642862,21 +643412,21 @@ function wrapFooterItems(items, width) {
|
|
|
642862
643412
|
const lines = [];
|
|
642863
643413
|
let current = "";
|
|
642864
643414
|
for (const item of items) {
|
|
642865
|
-
const
|
|
642866
|
-
if (!
|
|
642867
|
-
const candidate = current ? `${current}${sep11}${
|
|
643415
|
+
const clean7 = item.replace(/\s+/g, " ").trim();
|
|
643416
|
+
if (!clean7) continue;
|
|
643417
|
+
const candidate = current ? `${current}${sep11}${clean7}` : clean7;
|
|
642868
643418
|
if (visibleLen(candidate) <= width) {
|
|
642869
643419
|
current = candidate;
|
|
642870
643420
|
continue;
|
|
642871
643421
|
}
|
|
642872
643422
|
if (current) lines.push(current);
|
|
642873
|
-
if (
|
|
643423
|
+
if (clean7.length > width) {
|
|
642874
643424
|
const pipe3 = " ";
|
|
642875
|
-
const chunks = wrapToolTextLine(
|
|
643425
|
+
const chunks = wrapToolTextLine(clean7, width, pipe3);
|
|
642876
643426
|
lines.push(...chunks.slice(0, -1));
|
|
642877
643427
|
current = chunks[chunks.length - 1] ?? "";
|
|
642878
643428
|
} else {
|
|
642879
|
-
current =
|
|
643429
|
+
current = clean7;
|
|
642880
643430
|
}
|
|
642881
643431
|
}
|
|
642882
643432
|
if (current) lines.push(current);
|
|
@@ -645752,9 +646302,9 @@ function updateScopedPersonality(scope, observation) {
|
|
|
645752
646302
|
}
|
|
645753
646303
|
const relationshipHints = observation.relationshipHints ?? [];
|
|
645754
646304
|
for (const hint of relationshipHints) {
|
|
645755
|
-
const
|
|
645756
|
-
if (
|
|
645757
|
-
if (
|
|
646305
|
+
const clean7 = compactLine(hint, 180);
|
|
646306
|
+
if (clean7 && !doc.relationshipModel.includes(clean7)) doc.relationshipModel.push(clean7);
|
|
646307
|
+
if (clean7 && !doc.relationshipEvents.includes(`${now2} ${clean7}`)) doc.relationshipEvents.push(`${now2} ${clean7}`);
|
|
645758
646308
|
}
|
|
645759
646309
|
doc.relationshipModel = doc.relationshipModel.slice(-12);
|
|
645760
646310
|
doc.relationshipEvents = doc.relationshipEvents.slice(-MAX_PROFILE_RELATIONSHIP_EVENTS);
|
|
@@ -645904,9 +646454,9 @@ function compactText(text2, limit) {
|
|
|
645904
646454
|
return `${compact4.slice(0, Math.max(0, limit - 3)).trimEnd()}...`;
|
|
645905
646455
|
}
|
|
645906
646456
|
function blockText(text2, limit) {
|
|
645907
|
-
const
|
|
645908
|
-
if (
|
|
645909
|
-
return `${
|
|
646457
|
+
const clean7 = text2.replace(/\r\n/g, "\n").trim();
|
|
646458
|
+
if (clean7.length <= limit) return clean7;
|
|
646459
|
+
return `${clean7.slice(0, Math.max(0, limit - 20)).trimEnd()}
|
|
645910
646460
|
... [truncated]`;
|
|
645911
646461
|
}
|
|
645912
646462
|
function scopeStateKey(scope, surface) {
|
|
@@ -650909,10 +651459,10 @@ function normalizeList(items, maxItems) {
|
|
|
650909
651459
|
const seen = /* @__PURE__ */ new Set();
|
|
650910
651460
|
const out = [];
|
|
650911
651461
|
for (const item of items) {
|
|
650912
|
-
const
|
|
650913
|
-
if (!
|
|
650914
|
-
seen.add(
|
|
650915
|
-
out.push(
|
|
651462
|
+
const clean7 = normalizeSessionText(item, 300);
|
|
651463
|
+
if (!clean7 || seen.has(clean7)) continue;
|
|
651464
|
+
seen.add(clean7);
|
|
651465
|
+
out.push(clean7);
|
|
650916
651466
|
if (out.length >= maxItems) break;
|
|
650917
651467
|
}
|
|
650918
651468
|
return out.length > 0 ? out : void 0;
|
|
@@ -651592,8 +652142,8 @@ function getLastTaskSummary(repoRoot) {
|
|
|
651592
652142
|
if (!ctx3 || ctx3.entries.length === 0) return null;
|
|
651593
652143
|
const last2 = ctx3.entries[ctx3.entries.length - 1];
|
|
651594
652144
|
const text2 = last2.summary || last2.task;
|
|
651595
|
-
const
|
|
651596
|
-
return
|
|
652145
|
+
const clean7 = text2.replace(/^\[.*?\]\s*/, "").replace(/\s+/g, " ").trim();
|
|
652146
|
+
return clean7.length > 40 ? clean7.slice(0, 37) + "..." : clean7;
|
|
651597
652147
|
}
|
|
651598
652148
|
function updateSessionEntry(repoRoot, sessionId, patch) {
|
|
651599
652149
|
const indexPath = join139(repoRoot, OMNIUS_DIR, SESSIONS_DIR, SESSIONS_INDEX);
|
|
@@ -651658,8 +652208,8 @@ function sanitizeRestoredSessionLines(lines, options2 = {}) {
|
|
|
651658
652208
|
}
|
|
651659
652209
|
function firstMeaningfulSessionHistoryLine(lines) {
|
|
651660
652210
|
for (const line of sanitizeRestoredSessionLines(lines, { maxLines: 12 })) {
|
|
651661
|
-
const
|
|
651662
|
-
if (
|
|
652211
|
+
const clean7 = cleanSessionHistoryDisplayLine(line);
|
|
652212
|
+
if (clean7) return clean7;
|
|
651663
652213
|
}
|
|
651664
652214
|
return "";
|
|
651665
652215
|
}
|
|
@@ -653308,12 +653858,12 @@ function row(value2, width, stage2, phase, truecolor) {
|
|
|
653308
653858
|
return `${left} ${fit3(value2, width)} ${right}`;
|
|
653309
653859
|
}
|
|
653310
653860
|
function fit3(value2, width) {
|
|
653311
|
-
const
|
|
653312
|
-
const chars = Array.from(
|
|
653861
|
+
const clean7 = value2.replace(ANSI_RE3, "").replace(/\s+/g, " ").trim();
|
|
653862
|
+
const chars = Array.from(clean7);
|
|
653313
653863
|
if (chars.length > width) {
|
|
653314
653864
|
return `${chars.slice(0, Math.max(0, width - 1)).join("")}…`;
|
|
653315
653865
|
}
|
|
653316
|
-
return
|
|
653866
|
+
return clean7 + " ".repeat(Math.max(0, width - chars.length));
|
|
653317
653867
|
}
|
|
653318
653868
|
var ANSI_RE3;
|
|
653319
653869
|
var init_trajectory_live_block = __esm({
|
|
@@ -654030,8 +654580,8 @@ var init_braille_spinner = __esm({
|
|
|
654030
654580
|
// █ full block (header solid)
|
|
654031
654581
|
];
|
|
654032
654582
|
WAVE_EXT = [...EXTENDED_DENSITY, ...EXTENDED_DENSITY.slice(1, -1).reverse()];
|
|
654033
|
-
particleHash = (col,
|
|
654034
|
-
const x = col * 13 +
|
|
654583
|
+
particleHash = (col, frame2) => {
|
|
654584
|
+
const x = col * 13 + frame2 * 3 + 37;
|
|
654035
654585
|
return (x * x * 31 + x * 17 + 59) % 97 / 97;
|
|
654036
654586
|
};
|
|
654037
654587
|
MOOD_RAMPS = {
|
|
@@ -654990,14 +655540,14 @@ function loadFailurePatterns(store2) {
|
|
|
654990
655540
|
const unresolved = store2.listUnresolved();
|
|
654991
655541
|
if (unresolved.length === 0) return "";
|
|
654992
655542
|
const seen = /* @__PURE__ */ new Set();
|
|
654993
|
-
const
|
|
655543
|
+
const unique5 = unresolved.filter((f2) => {
|
|
654994
655544
|
if (seen.has(f2.fingerprint)) return false;
|
|
654995
655545
|
seen.add(f2.fingerprint);
|
|
654996
655546
|
return true;
|
|
654997
655547
|
});
|
|
654998
|
-
if (
|
|
655548
|
+
if (unique5.length === 0) return "";
|
|
654999
655549
|
const lines = ["Known failure patterns (avoid repeating these):"];
|
|
655000
|
-
for (const f2 of
|
|
655550
|
+
for (const f2 of unique5.slice(0, 8)) {
|
|
655001
655551
|
const file = f2.filePath ? ` in ${f2.filePath}` : "";
|
|
655002
655552
|
lines.push(`- [${f2.failureType}]${file}: ${f2.errorMessage.slice(0, 150)}`);
|
|
655003
655553
|
}
|
|
@@ -659797,7 +660347,9 @@ ${CONTENT_BG_SEQ}`);
|
|
|
659797
660347
|
}
|
|
659798
660348
|
_reflowContentLineUncached(line, width) {
|
|
659799
660349
|
const visible = stripAnsi(line);
|
|
659800
|
-
|
|
660350
|
+
let visibleColumns = 0;
|
|
660351
|
+
for (const char of visible) visibleColumns += charWidth2(char);
|
|
660352
|
+
if (visibleColumns <= width) return [line];
|
|
659801
660353
|
const continuationIndent = this.hangingIndentForVisibleLine(visible, width);
|
|
659802
660354
|
const ranges = this.visibleWrapRanges(
|
|
659803
660355
|
visible,
|
|
@@ -660533,9 +661085,9 @@ ${CONTENT_BG_SEQ}`);
|
|
|
660533
661085
|
const cup = `\x1B[${row2};${cellStart}H`;
|
|
660534
661086
|
if (this._enhanceState === "busy") {
|
|
660535
661087
|
this._enhanceConfirmZones = null;
|
|
660536
|
-
const
|
|
661088
|
+
const frame2 = ENHANCE_SPIN_FRAMES[this._enhanceSpinFrame % ENHANCE_SPIN_FRAMES.length] ?? "⠋";
|
|
660537
661089
|
const pad = Math.floor((ENHANCE_SEG_INNER - 1) / 2);
|
|
660538
|
-
const cell = " ".repeat(pad) +
|
|
661090
|
+
const cell = " ".repeat(pad) + frame2 + " ".repeat(ENHANCE_SEG_INNER - 1 - pad);
|
|
660539
661091
|
return `${cup}${PANEL_BG_SEQ}\x1B[38;5;${TEXT_DIM}m${cell}${RESET4}${PANEL_BG_SEQ}`;
|
|
660540
661092
|
}
|
|
660541
661093
|
if (this._enhanceState === "confirm") {
|
|
@@ -660653,9 +661205,9 @@ ${CONTENT_BG_SEQ}`);
|
|
|
660653
661205
|
if (this.active && !this._resizing) this.renderFooterAndPositionInput();
|
|
660654
661206
|
return;
|
|
660655
661207
|
}
|
|
660656
|
-
const
|
|
660657
|
-
if (
|
|
660658
|
-
this._inputMutator?.(
|
|
661208
|
+
const clean7 = (expanded ?? "").trim();
|
|
661209
|
+
if (clean7 && clean7 !== seed) {
|
|
661210
|
+
this._inputMutator?.(clean7, clean7.length);
|
|
660659
661211
|
this._enhanceState = "confirm";
|
|
660660
661212
|
} else {
|
|
660661
661213
|
this._enhanceState = "idle";
|
|
@@ -669718,14 +670270,14 @@ async function showNodesByType(options2, nodeType) {
|
|
|
669718
670270
|
renderError(`Failed to load nodes: ${e2}`);
|
|
669719
670271
|
}
|
|
669720
670272
|
}
|
|
669721
|
-
async function showNodeDetail(options2,
|
|
670273
|
+
async function showNodeDetail(options2, nodeId2) {
|
|
669722
670274
|
const { rl, workingDir } = options2;
|
|
669723
670275
|
const dbPath = path15.join(workingDir, ".omnius", "knowledge.db");
|
|
669724
|
-
renderInfo(`Node: ${
|
|
670276
|
+
renderInfo(`Node: ${nodeId2}`);
|
|
669725
670277
|
console.log();
|
|
669726
670278
|
try {
|
|
669727
670279
|
const kg = new TemporalGraph(dbPath);
|
|
669728
|
-
const node = kg.getNode(
|
|
670280
|
+
const node = kg.getNode(nodeId2);
|
|
669729
670281
|
if (!node) {
|
|
669730
670282
|
renderWarning("Node not found");
|
|
669731
670283
|
kg.close();
|
|
@@ -669737,11 +670289,11 @@ async function showNodeDetail(options2, nodeId) {
|
|
|
669737
670289
|
console.log(import_chalk.default.bold("First seen:"), formatTimestamp(node.firstSeen));
|
|
669738
670290
|
console.log(import_chalk.default.bold("Last seen:"), formatTimestamp(node.lastSeen));
|
|
669739
670291
|
console.log();
|
|
669740
|
-
const edges = kg.currentEdges(
|
|
670292
|
+
const edges = kg.currentEdges(nodeId2);
|
|
669741
670293
|
if (edges.length > 0) {
|
|
669742
670294
|
console.log(import_chalk.default.bold("Edges:"));
|
|
669743
670295
|
for (const e2 of edges.slice(0, 10)) {
|
|
669744
|
-
const otherId = e2.srcId ===
|
|
670296
|
+
const otherId = e2.srcId === nodeId2 ? e2.dstId : e2.srcId;
|
|
669745
670297
|
const otherNode = kg.getNode(otherId);
|
|
669746
670298
|
console.log(` ${import_chalk.default.cyan(e2.relation)} → ${otherNode?.text || otherId.slice(0, 8)}`);
|
|
669747
670299
|
}
|
|
@@ -670219,9 +670771,9 @@ function readSample(buffer2, offset, format3, bitsPerSample) {
|
|
|
670219
670771
|
if (bitsPerSample === 32 && offset + 4 <= buffer2.length) return buffer2.readInt32LE(offset) / 2147483648;
|
|
670220
670772
|
return 0;
|
|
670221
670773
|
}
|
|
670222
|
-
function frameAmplitude(buffer2, info,
|
|
670774
|
+
function frameAmplitude(buffer2, info, frame2) {
|
|
670223
670775
|
const bytesPerSample = info.bitsPerSample / 8;
|
|
670224
|
-
const offset = info.dataOffset +
|
|
670776
|
+
const offset = info.dataOffset + frame2 * info.frameSize;
|
|
670225
670777
|
let sum2 = 0;
|
|
670226
670778
|
for (let channel = 0; channel < info.channels; channel++) {
|
|
670227
670779
|
sum2 += readSample(buffer2, offset + channel * bytesPerSample, info.format, info.bitsPerSample);
|
|
@@ -670254,8 +670806,8 @@ function renderAudioWaveform(file, options2 = {}) {
|
|
|
670254
670806
|
const stride = Math.max(1, Math.floor((end - start2) / 96));
|
|
670255
670807
|
let min = 1;
|
|
670256
670808
|
let max = -1;
|
|
670257
|
-
for (let
|
|
670258
|
-
const amp = frameAmplitude(buffer2, info,
|
|
670809
|
+
for (let frame2 = start2; frame2 < end; frame2 += stride) {
|
|
670810
|
+
const amp = frameAmplitude(buffer2, info, frame2);
|
|
670259
670811
|
if (amp < min) min = amp;
|
|
670260
670812
|
if (amp > max) max = amp;
|
|
670261
670813
|
}
|
|
@@ -670638,17 +671190,17 @@ function toggleFocus(state) {
|
|
|
670638
671190
|
toggleFocus(state);
|
|
670639
671191
|
return;
|
|
670640
671192
|
}
|
|
670641
|
-
const
|
|
670642
|
-
if (!
|
|
670643
|
-
fn(Buffer.from(
|
|
671193
|
+
const clean7 = raw.replace(STDIN_MOUSE_FOCUS_RE, "");
|
|
671194
|
+
if (!clean7) return;
|
|
671195
|
+
fn(Buffer.from(clean7));
|
|
670644
671196
|
} else if (typeof args[0] === "string") {
|
|
670645
671197
|
if (args[0] === "") {
|
|
670646
671198
|
toggleFocus(state);
|
|
670647
671199
|
return;
|
|
670648
671200
|
}
|
|
670649
|
-
const
|
|
670650
|
-
if (!
|
|
670651
|
-
fn(
|
|
671201
|
+
const clean7 = args[0].replace(STDIN_MOUSE_FOCUS_RE, "");
|
|
671202
|
+
if (!clean7) return;
|
|
671203
|
+
fn(clean7);
|
|
670652
671204
|
} else {
|
|
670653
671205
|
fn(...args);
|
|
670654
671206
|
}
|
|
@@ -671673,8 +672225,8 @@ var init_mem_metabolize = __esm({
|
|
|
671673
672225
|
|
|
671674
672226
|
// packages/cli/src/tui/commands/kg-prune-inference.ts
|
|
671675
672227
|
function truncate5(text2, max) {
|
|
671676
|
-
const
|
|
671677
|
-
return
|
|
672228
|
+
const clean7 = text2.replace(/\s+/g, " ").trim();
|
|
672229
|
+
return clean7.length > max ? clean7.slice(0, max - 1) + "…" : clean7;
|
|
671678
672230
|
}
|
|
671679
672231
|
async function classifySignalNodes(candidates, cfg) {
|
|
671680
672232
|
const max = Math.max(1, Math.min(cfg.maxCandidates ?? 40, 100));
|
|
@@ -676897,10 +677449,10 @@ except Exception as exc:
|
|
|
676897
677449
|
}));
|
|
676898
677450
|
}
|
|
676899
677451
|
saveSupertonicProfile(name10) {
|
|
676900
|
-
const
|
|
676901
|
-
if (!
|
|
677452
|
+
const clean7 = name10.trim().replace(/[^a-zA-Z0-9_.-]/g, "-");
|
|
677453
|
+
if (!clean7) return;
|
|
676902
677454
|
const store2 = this.loadSupertonicStore();
|
|
676903
|
-
store2.profiles[
|
|
677455
|
+
store2.profiles[clean7] = { ...store2.active };
|
|
676904
677456
|
this.saveSupertonicStore(store2);
|
|
676905
677457
|
}
|
|
676906
677458
|
loadSupertonicProfile(name10) {
|
|
@@ -686197,9 +686749,9 @@ sleep 1
|
|
|
686197
686749
|
buf += decoder.decode(value2, { stream: true });
|
|
686198
686750
|
let idx;
|
|
686199
686751
|
while ((idx = buf.indexOf("\n\n")) >= 0) {
|
|
686200
|
-
const
|
|
686752
|
+
const frame2 = buf.slice(0, idx);
|
|
686201
686753
|
buf = buf.slice(idx + 2);
|
|
686202
|
-
const dataLine =
|
|
686754
|
+
const dataLine = frame2.split("\n").find((l2) => l2.startsWith("data: "));
|
|
686203
686755
|
if (!dataLine) continue;
|
|
686204
686756
|
try {
|
|
686205
686757
|
const ev = JSON.parse(dataLine.slice(6));
|
|
@@ -694289,7 +694841,7 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694289
694841
|
let _installProgress = 0;
|
|
694290
694842
|
let _installTotal = 10;
|
|
694291
694843
|
let _installPhase = "";
|
|
694292
|
-
function renderInstallFrame(version5,
|
|
694844
|
+
function renderInstallFrame(version5, frame2, statusLine) {
|
|
694293
694845
|
const L = layout();
|
|
694294
694846
|
const cols = L.cols;
|
|
694295
694847
|
const {
|
|
@@ -694326,7 +694878,7 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694326
694878
|
buf += `\x1B[${boxTop + boxH - 1};${boxLeft}H${boxFg}╰${"─".repeat(innerW)}╯`;
|
|
694327
694879
|
const label = isDone ? "INSTALLED" : "INSTALLING";
|
|
694328
694880
|
const labelColor = isDone ? 82 : accentColor;
|
|
694329
|
-
const spinner = isDone ? " ✓" : ` ${BRAILLE_SPINNER[
|
|
694881
|
+
const spinner = isDone ? " ✓" : ` ${BRAILLE_SPINNER[frame2 % BRAILLE_SPINNER.length]}`;
|
|
694330
694882
|
const fullLabel = label + spinner;
|
|
694331
694883
|
const labelCol = centerCol - Math.floor(fullLabel.length / 2);
|
|
694332
694884
|
buf += `\x1B[${boxTop + 1};${labelCol}H\x1B[1;38;5;${labelColor}m${label}\x1B[0m\x1B[38;5;${labelColor}m${spinner}\x1B[0m`;
|
|
@@ -694336,7 +694888,7 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694336
694888
|
if (_installProgress === 0 && !isDone) {
|
|
694337
694889
|
let bar = "";
|
|
694338
694890
|
for (let c9 = 0; c9 < barW; c9++) {
|
|
694339
|
-
const wave = Math.sin((c9 -
|
|
694891
|
+
const wave = Math.sin((c9 - frame2 * 0.8) * 0.3);
|
|
694340
694892
|
const idx = Math.max(
|
|
694341
694893
|
0,
|
|
694342
694894
|
Math.min(
|
|
@@ -694354,7 +694906,7 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694354
694906
|
if (c9 < filledCols) {
|
|
694355
694907
|
bar += PROGRESS_BLOCKS[PROGRESS_BLOCKS.length - 1];
|
|
694356
694908
|
} else if (c9 === filledCols) {
|
|
694357
|
-
const edgeIdx = isDone ? PROGRESS_BLOCKS.length - 1 :
|
|
694909
|
+
const edgeIdx = isDone ? PROGRESS_BLOCKS.length - 1 : frame2 % (PROGRESS_BLOCKS.length - 1) + 1;
|
|
694358
694910
|
bar += PROGRESS_BLOCKS[edgeIdx];
|
|
694359
694911
|
} else {
|
|
694360
694912
|
bar += PROGRESS_BLOCKS[0];
|
|
@@ -694374,14 +694926,14 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694374
694926
|
function startInstallOverlay(version5) {
|
|
694375
694927
|
enterOverlay();
|
|
694376
694928
|
lockFooterRedraws();
|
|
694377
|
-
let
|
|
694929
|
+
let frame2 = 0;
|
|
694378
694930
|
let status = "";
|
|
694379
694931
|
let dismissed = false;
|
|
694380
|
-
renderInstallFrame(version5,
|
|
694932
|
+
renderInstallFrame(version5, frame2, status);
|
|
694381
694933
|
const timer = setInterval(() => {
|
|
694382
694934
|
if (dismissed) return;
|
|
694383
|
-
|
|
694384
|
-
renderInstallFrame(version5,
|
|
694935
|
+
frame2++;
|
|
694936
|
+
renderInstallFrame(version5, frame2, status);
|
|
694385
694937
|
}, 80);
|
|
694386
694938
|
return {
|
|
694387
694939
|
setStatus(text2) {
|
|
@@ -694399,11 +694951,11 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694399
694951
|
clearInterval(timer);
|
|
694400
694952
|
status = "__DONE__";
|
|
694401
694953
|
_installProgress = _installTotal;
|
|
694402
|
-
renderInstallFrame(version5,
|
|
694954
|
+
renderInstallFrame(version5, frame2, status);
|
|
694403
694955
|
setTimeout(() => {
|
|
694404
694956
|
if (dismissed) return;
|
|
694405
694957
|
status = finalText;
|
|
694406
|
-
renderInstallFrame(version5,
|
|
694958
|
+
renderInstallFrame(version5, frame2 + 1, finalText);
|
|
694407
694959
|
}, 300);
|
|
694408
694960
|
},
|
|
694409
694961
|
dismiss() {
|
|
@@ -694775,23 +695327,23 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694775
695327
|
return truncateInstallStatus(cleaned, 64);
|
|
694776
695328
|
};
|
|
694777
695329
|
const summarizeInstallOutputLine = (line) => {
|
|
694778
|
-
const
|
|
694779
|
-
if (!
|
|
694780
|
-
if (/^npm notice/i.test(
|
|
694781
|
-
if (/^\d+\s+packages?\s+are looking for funding/i.test(
|
|
694782
|
-
const deprecated =
|
|
695330
|
+
const clean7 = truncateInstallStatus(stripInstallAnsi(line), 100);
|
|
695331
|
+
if (!clean7) return "";
|
|
695332
|
+
if (/^npm notice/i.test(clean7)) return "";
|
|
695333
|
+
if (/^\d+\s+packages?\s+are looking for funding/i.test(clean7)) return "";
|
|
695334
|
+
const deprecated = clean7.match(/^npm warn deprecated\s+(\S+)\s+(.+)/i);
|
|
694783
695335
|
if (deprecated) {
|
|
694784
695336
|
return truncateInstallStatus(
|
|
694785
695337
|
`deprecated ${deprecated[1]}: ${deprecated[2]}`
|
|
694786
695338
|
);
|
|
694787
695339
|
}
|
|
694788
|
-
const warn =
|
|
695340
|
+
const warn = clean7.match(/^npm warn\s+(.+)/i);
|
|
694789
695341
|
if (warn) return truncateInstallStatus(`warn: ${warn[1]}`);
|
|
694790
|
-
const fetch4 =
|
|
695342
|
+
const fetch4 = clean7.match(
|
|
694791
695343
|
/^npm http fetch\s+\S+\s+\d+\s+(.+?)\s+(\d+ms.*)?$/i
|
|
694792
695344
|
);
|
|
694793
695345
|
if (fetch4) return truncateInstallStatus(`fetching ${fetch4[1]}`);
|
|
694794
|
-
const run2 =
|
|
695346
|
+
const run2 = clean7.match(/^npm info run\s+(\S+)\s+(\S+)\s+(.+)$/i);
|
|
694795
695347
|
if (run2) {
|
|
694796
695348
|
const pkg = run2[1];
|
|
694797
695349
|
const script = run2[2];
|
|
@@ -694799,15 +695351,15 @@ async function handleUpdate(subcommand, ctx3) {
|
|
|
694799
695351
|
if (/\{\s*code:\s*0/i.test(detail)) return `finished ${script}: ${pkg}`;
|
|
694800
695352
|
return truncateInstallStatus(`running ${script}: ${pkg}`);
|
|
694801
695353
|
}
|
|
694802
|
-
if (/node-gyp|prebuild-install|cmake|make\b|g\+\+|clang/i.test(
|
|
694803
|
-
return truncateInstallStatus(
|
|
695354
|
+
if (/node-gyp|prebuild-install|cmake|make\b|g\+\+|clang/i.test(clean7)) {
|
|
695355
|
+
return truncateInstallStatus(clean7);
|
|
694804
695356
|
}
|
|
694805
|
-
if (/^(added|removed|changed|updated|up to date|audited)\b/i.test(
|
|
694806
|
-
return
|
|
695357
|
+
if (/^(added|removed|changed|updated|up to date|audited)\b/i.test(clean7)) {
|
|
695358
|
+
return clean7;
|
|
694807
695359
|
}
|
|
694808
|
-
if (/npm ERR!|error|failed/i.test(
|
|
694809
|
-
return truncateInstallStatus(
|
|
694810
|
-
return
|
|
695360
|
+
if (/npm ERR!|error|failed/i.test(clean7))
|
|
695361
|
+
return truncateInstallStatus(clean7);
|
|
695362
|
+
return clean7;
|
|
694811
695363
|
};
|
|
694812
695364
|
let installError = "";
|
|
694813
695365
|
_installProgress = 0;
|
|
@@ -695713,9 +696265,9 @@ async function showExposeDashboard(gateway, rl, ctx3) {
|
|
|
695713
696265
|
const recentEntries = [];
|
|
695714
696266
|
for (let i2 = streamLog.length - 1; i2 >= 0 && recentEntries.length < streamAreaHeight - 1; i2--) {
|
|
695715
696267
|
const entry = streamLog[i2];
|
|
695716
|
-
const
|
|
695717
|
-
if (!
|
|
695718
|
-
const truncated =
|
|
696268
|
+
const clean7 = entry.content.replace(/\n/g, "⏎").replace(/[\x00-\x1F\x7F]/g, "");
|
|
696269
|
+
if (!clean7) continue;
|
|
696270
|
+
const truncated = clean7.length > maxContentW ? clean7.slice(0, maxContentW - 1) + "…" : clean7;
|
|
695719
696271
|
recentEntries.unshift(` \x1B[38;5;245m${truncated}\x1B[0m`);
|
|
695720
696272
|
}
|
|
695721
696273
|
while (recentEntries.length < streamAreaHeight - 1)
|
|
@@ -695725,8 +696277,8 @@ async function showExposeDashboard(gateway, rl, ctx3) {
|
|
|
695725
696277
|
}
|
|
695726
696278
|
const footerLine = ` ${c3.dim("q")} exit ${c3.dim("s")} stop gateway ${c3.dim("c")} copy endpoint ${c3.dim("auto-refresh 1s")}`;
|
|
695727
696279
|
lines.push(footerLine);
|
|
695728
|
-
const
|
|
695729
|
-
overlayWrite(
|
|
696280
|
+
const frame2 = "\x1B[H\x1B[2J" + lines.join("\n") + "\n";
|
|
696281
|
+
overlayWrite(frame2);
|
|
695730
696282
|
}
|
|
695731
696283
|
const onStats = () => scheduleRender();
|
|
695732
696284
|
gateway.on("stats", onStats);
|
|
@@ -696164,14 +696716,14 @@ function clampInt2(value2, fallback, min, max) {
|
|
|
696164
696716
|
return Math.max(min, Math.min(max, Math.floor(n2)));
|
|
696165
696717
|
}
|
|
696166
696718
|
function compactText2(text2, limit) {
|
|
696167
|
-
const
|
|
696168
|
-
if (
|
|
696169
|
-
return `${
|
|
696719
|
+
const clean7 = text2.replace(/\s+/g, " ").trim();
|
|
696720
|
+
if (clean7.length <= limit) return clean7;
|
|
696721
|
+
return `${clean7.slice(0, Math.max(0, limit - 3)).trimEnd()}...`;
|
|
696170
696722
|
}
|
|
696171
696723
|
function blockText2(text2, limit) {
|
|
696172
|
-
const
|
|
696173
|
-
if (
|
|
696174
|
-
return `${
|
|
696724
|
+
const clean7 = text2.replace(/\r\n/g, "\n").trim();
|
|
696725
|
+
if (clean7.length <= limit) return clean7;
|
|
696726
|
+
return `${clean7.slice(0, Math.max(0, limit - 20)).trimEnd()}
|
|
696175
696727
|
... [truncated]`;
|
|
696176
696728
|
}
|
|
696177
696729
|
function firstReadable(candidates) {
|
|
@@ -696327,9 +696879,9 @@ function wordParts(text2) {
|
|
|
696327
696879
|
}
|
|
696328
696880
|
function finalizeRealtimeReply(text2, opts = {}) {
|
|
696329
696881
|
const maxWords = clampInt2(opts.maxReplyWords, DEFAULT_REALTIME_MAX_REPLY_WORDS, 8, 80);
|
|
696330
|
-
let
|
|
696331
|
-
if (!
|
|
696332
|
-
const sentences =
|
|
696882
|
+
let clean7 = stripHiddenThinking(String(text2 ?? "")).replace(/```[\s\S]*?```/g, "").split("\n").map((line) => line.replace(/^\s*(?:[-*]+|\d+[.)])\s+/, "").trim()).filter(Boolean).join(" ").replace(/^(?:assistant|omnius|agent)\s*:\s*/i, "").replace(/`([^`]+)`/g, "$1").replace(/\s+/g, " ").trim();
|
|
696883
|
+
if (!clean7) return "I didn't catch that. Can you say it again?";
|
|
696884
|
+
const sentences = clean7.match(/[^.!?]+[.!?]+(?=\s|$)|[^.!?]+$/g) ?? [clean7];
|
|
696333
696885
|
const selected = [];
|
|
696334
696886
|
let words = 0;
|
|
696335
696887
|
for (const raw of sentences) {
|
|
@@ -696342,13 +696894,13 @@ function finalizeRealtimeReply(text2, opts = {}) {
|
|
|
696342
696894
|
words += count;
|
|
696343
696895
|
if (words >= maxWords) break;
|
|
696344
696896
|
}
|
|
696345
|
-
|
|
696346
|
-
const parts = wordParts(
|
|
696897
|
+
clean7 = (selected.join(" ") || clean7).trim();
|
|
696898
|
+
const parts = wordParts(clean7);
|
|
696347
696899
|
if (parts.length > maxWords) {
|
|
696348
|
-
|
|
696900
|
+
clean7 = parts.slice(0, maxWords).join(" ");
|
|
696349
696901
|
}
|
|
696350
|
-
if (
|
|
696351
|
-
return
|
|
696902
|
+
if (clean7 && !/[.!?]$/.test(clean7)) clean7 += ".";
|
|
696903
|
+
return clean7;
|
|
696352
696904
|
}
|
|
696353
696905
|
var DEFAULT_REALTIME_HISTORY_MESSAGES, DEFAULT_REALTIME_MAX_TOKENS, DEFAULT_REALTIME_MAX_REPLY_WORDS, DEFAULT_SOUL_CHARS, DEFAULT_VOICE_CHARS;
|
|
696354
696906
|
var init_realtime = __esm({
|
|
@@ -696451,27 +697003,27 @@ function cleanSessionDisplayLine(line) {
|
|
|
696451
697003
|
return stripAnsi6(line).replace(/^[>❯▹∙•*+\-\s]+/, "").replace(/^(?:User|Assistant|You|Open Agent|Omnius)\s*:\s*/i, "").replace(/\s+/g, " ").trim();
|
|
696452
697004
|
}
|
|
696453
697005
|
function isNoisySessionDisplayLine(line) {
|
|
696454
|
-
const
|
|
696455
|
-
if (!
|
|
696456
|
-
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(
|
|
697006
|
+
const clean7 = cleanSessionDisplayLine(line || "");
|
|
697007
|
+
if (!clean7) return true;
|
|
697008
|
+
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(clean7);
|
|
696457
697009
|
}
|
|
696458
697010
|
function bestSessionDisplayLine(text2) {
|
|
696459
697011
|
const lines = stripAnsi6(text2).split(/\r?\n/);
|
|
696460
697012
|
for (const line of lines) {
|
|
696461
|
-
const
|
|
696462
|
-
if (!isNoisySessionDisplayLine(
|
|
697013
|
+
const clean7 = cleanSessionDisplayLine(line);
|
|
697014
|
+
if (!isNoisySessionDisplayLine(clean7)) return clean7;
|
|
696463
697015
|
}
|
|
696464
697016
|
const fallback = stripAnsi6(text2).replace(/\s+/g, " ").trim();
|
|
696465
697017
|
return isNoisySessionDisplayLine(fallback) ? "" : fallback;
|
|
696466
697018
|
}
|
|
696467
697019
|
function makeTitle(text2) {
|
|
696468
|
-
const
|
|
696469
|
-
if (!
|
|
696470
|
-
return
|
|
697020
|
+
const clean7 = bestSessionDisplayLine(text2);
|
|
697021
|
+
if (!clean7) return "Chat session";
|
|
697022
|
+
return clean7.length > 72 ? clean7.slice(0, 69) + "..." : clean7;
|
|
696471
697023
|
}
|
|
696472
697024
|
function makePreview(text2) {
|
|
696473
|
-
const
|
|
696474
|
-
return
|
|
697025
|
+
const clean7 = bestSessionDisplayLine(text2);
|
|
697026
|
+
return clean7.length > 160 ? clean7.slice(0, 157) + "..." : clean7;
|
|
696475
697027
|
}
|
|
696476
697028
|
function normalizeLoadedSession(parsed) {
|
|
696477
697029
|
if (!parsed.source) parsed.source = "web";
|
|
@@ -697059,8 +697611,8 @@ function episodeSurface(ep) {
|
|
|
697059
697611
|
return typeof metadata["sourceSurface"] === "string" ? metadata["sourceSurface"] : void 0;
|
|
697060
697612
|
}
|
|
697061
697613
|
function compactContent(value2, max = 220) {
|
|
697062
|
-
const
|
|
697063
|
-
return
|
|
697614
|
+
const clean7 = value2.replace(/\s+/g, " ").trim();
|
|
697615
|
+
return clean7.length > max ? `${clean7.slice(0, max - 1)}...` : clean7;
|
|
697064
697616
|
}
|
|
697065
697617
|
function pendingConsumedIds(store2, scope, sessionId) {
|
|
697066
697618
|
const consumed = /* @__PURE__ */ new Set();
|
|
@@ -697577,8 +698129,8 @@ async function resolveMediaFromArgs(args, opts) {
|
|
|
697577
698129
|
label: basename35(path16)
|
|
697578
698130
|
};
|
|
697579
698131
|
}
|
|
697580
|
-
function edgeDirection(edge,
|
|
697581
|
-
if (edge.srcId ===
|
|
698132
|
+
function edgeDirection(edge, nodeId2, otherText) {
|
|
698133
|
+
if (edge.srcId === nodeId2) return `${edge.relation} -> ${otherText}`;
|
|
697582
698134
|
return `${otherText} -> ${edge.relation}`;
|
|
697583
698135
|
}
|
|
697584
698136
|
function formatIdentityMemoryContext(surface) {
|
|
@@ -698744,15 +699296,15 @@ var init_banner = __esm({
|
|
|
698744
699296
|
/** Render the current frame into the top 3 rows (public for refresh callbacks) */
|
|
698745
699297
|
renderCurrentFrame() {
|
|
698746
699298
|
if (!isTTY7 || !this.currentDesign) return;
|
|
698747
|
-
const
|
|
698748
|
-
if (!
|
|
699299
|
+
const frame2 = this.currentDesign.frames[this.currentFrame];
|
|
699300
|
+
if (!frame2) return;
|
|
698749
699301
|
this.width = termCols();
|
|
698750
699302
|
const defaultBoxSeparators = this.currentDesign.type === "default" ? new Set((this._defaultBoxSeparatorProvider?.() ?? []).filter((col) => col > 1 && col < this.width)) : null;
|
|
698751
699303
|
let buf = "\x1B[?2026h";
|
|
698752
699304
|
const L = layout();
|
|
698753
699305
|
for (let r2 = 0; r2 < this.rows; r2++) {
|
|
698754
699306
|
buf += `\x1B[${L.headerTop + r2};1H${tuiBg() >= 0 ? `\x1B[48;5;${tuiBg()}m` : "\x1B[49m"}\x1B[2K`;
|
|
698755
|
-
const row2 =
|
|
699307
|
+
const row2 = frame2.grid[r2];
|
|
698756
699308
|
if (!row2) continue;
|
|
698757
699309
|
let prevFg = -1, prevBg = -1, prevBold = false;
|
|
698758
699310
|
for (let c9 = 0; c9 < Math.min(this.width, row2.length); c9++) {
|
|
@@ -698908,8 +699460,8 @@ function generateDescriptors(repoRoot) {
|
|
|
698908
699460
|
if (repoName2 && !tags.includes(repoName2)) {
|
|
698909
699461
|
tags.push(repoName2);
|
|
698910
699462
|
}
|
|
698911
|
-
const
|
|
698912
|
-
const phrases =
|
|
699463
|
+
const unique5 = [...new Set(tags.map((t2) => t2.toLowerCase().trim()).filter((t2) => t2.length > 1 && t2.length < 60))];
|
|
699464
|
+
const phrases = unique5.map((text2) => ({
|
|
698913
699465
|
text: text2,
|
|
698914
699466
|
color: weightedColor(profile)
|
|
698915
699467
|
}));
|
|
@@ -698930,7 +699482,7 @@ function generateDescriptors(repoRoot) {
|
|
|
698930
699482
|
];
|
|
698931
699483
|
for (const fb of fallbacks) {
|
|
698932
699484
|
if (phrases.length >= 20) break;
|
|
698933
|
-
if (!
|
|
699485
|
+
if (!unique5.includes(fb)) {
|
|
698934
699486
|
phrases.push({ text: fb, color: weightedColor(profile) });
|
|
698935
699487
|
}
|
|
698936
699488
|
}
|
|
@@ -700075,9 +700627,18 @@ function compactText3(value2, max) {
|
|
|
700075
700627
|
const single = redacted.replace(/\s+/g, " ").trim();
|
|
700076
700628
|
return single.length > max ? `${single.slice(0, Math.max(1, max - 1))}…` : single;
|
|
700077
700629
|
}
|
|
700078
|
-
function
|
|
700630
|
+
function unique4(values) {
|
|
700079
700631
|
return [...new Set(values.filter(Boolean))];
|
|
700080
700632
|
}
|
|
700633
|
+
function frame(label, width, left, right) {
|
|
700634
|
+
const inner = Math.max(1, width - displayWidth2(left) - displayWidth2(right));
|
|
700635
|
+
return `${left}${fillAnsi(`─ ${label} `, inner, "─")}${right}`;
|
|
700636
|
+
}
|
|
700637
|
+
function fillAnsi(line, width, filler) {
|
|
700638
|
+
const clipped = fit4(line, width);
|
|
700639
|
+
const remaining = Math.max(0, width - displayWidth2(stripAnsi(clipped)));
|
|
700640
|
+
return `${clipped}${filler.repeat(remaining)}`;
|
|
700641
|
+
}
|
|
700081
700642
|
function fit4(line, width) {
|
|
700082
700643
|
const visible = stripAnsi(line);
|
|
700083
700644
|
if (displayWidth2(visible) <= width) return line;
|
|
@@ -700105,11 +700666,7 @@ function fit4(line, width) {
|
|
|
700105
700666
|
}
|
|
700106
700667
|
function displayWidth2(value2) {
|
|
700107
700668
|
let width = 0;
|
|
700108
|
-
for (const char of value2)
|
|
700109
|
-
const point = char.codePointAt(0);
|
|
700110
|
-
if (new RegExp("\\p{Mark}", "u").test(char)) continue;
|
|
700111
|
-
width += point >= 4352 && (point <= 4447 || point === 9001 || point === 9002 || point >= 11904 && point <= 42191 || point >= 44032 && point <= 55203 || point >= 63744 && point <= 64255 || point >= 65040 && point <= 65049 || point >= 65072 && point <= 65135 || point >= 65280 && point <= 65376 || point >= 65504 && point <= 65510 || point >= 127744) ? 2 : 1;
|
|
700112
|
-
}
|
|
700669
|
+
for (const char of value2) width += charWidth2(char);
|
|
700113
700670
|
return width;
|
|
700114
700671
|
}
|
|
700115
700672
|
function formatTime4(value2) {
|
|
@@ -700133,6 +700690,12 @@ var init_action_tree = __esm({
|
|
|
700133
700690
|
sequence = 0;
|
|
700134
700691
|
maxTopLevelNodes = 180;
|
|
700135
700692
|
currentWorkingDirectory = "";
|
|
700693
|
+
// Incremental historical load state. While `historicalLoading` is true the
|
|
700694
|
+
// tree is being populated in the background; `render` shows a truthful
|
|
700695
|
+
// progress line instead of pretending the scan is already complete.
|
|
700696
|
+
historicalLoading = false;
|
|
700697
|
+
historicalScanned = 0;
|
|
700698
|
+
historicalTotal = 0;
|
|
700136
700699
|
startRun(run2) {
|
|
700137
700700
|
this.actionNodes.clear();
|
|
700138
700701
|
this.turnNodes.clear();
|
|
@@ -700166,6 +700729,40 @@ var init_action_tree = __esm({
|
|
|
700166
700729
|
this.currentWorkingDirectory = currentWorkingDirectory;
|
|
700167
700730
|
for (const run2 of runs) this.addArchivedRun(run2);
|
|
700168
700731
|
}
|
|
700732
|
+
/**
|
|
700733
|
+
* Begin an incremental, background historical load. The tree shows a truthful
|
|
700734
|
+
* "scanning" line until `endHistoricalLoad()` is called. Callers append runs
|
|
700735
|
+
* with `appendHistoricalRuns()` as batches arrive from a non-blocking scan.
|
|
700736
|
+
*/
|
|
700737
|
+
beginHistoricalLoad(currentWorkingDirectory = "", total = 0) {
|
|
700738
|
+
this.roots = [];
|
|
700739
|
+
this.activeRoot = null;
|
|
700740
|
+
this.actionNodes.clear();
|
|
700741
|
+
this.turnNodes.clear();
|
|
700742
|
+
this.lastRenderedNodeByRow.clear();
|
|
700743
|
+
this.nodeById.clear();
|
|
700744
|
+
this.sequence = 0;
|
|
700745
|
+
this.currentWorkingDirectory = currentWorkingDirectory;
|
|
700746
|
+
this.historicalLoading = true;
|
|
700747
|
+
this.historicalScanned = 0;
|
|
700748
|
+
this.historicalTotal = total;
|
|
700749
|
+
}
|
|
700750
|
+
/** Append a batch of runs discovered by an incremental scan. */
|
|
700751
|
+
appendHistoricalRuns(runs, scanned, total) {
|
|
700752
|
+
for (const run2 of runs) this.addArchivedRun(run2);
|
|
700753
|
+
this.historicalScanned = scanned;
|
|
700754
|
+
this.historicalTotal = total;
|
|
700755
|
+
}
|
|
700756
|
+
/** Mark the incremental load complete. */
|
|
700757
|
+
endHistoricalLoad() {
|
|
700758
|
+
this.historicalLoading = false;
|
|
700759
|
+
this.historicalScanned = 0;
|
|
700760
|
+
this.historicalTotal = 0;
|
|
700761
|
+
}
|
|
700762
|
+
/** True while a background historical scan is still populating the tree. */
|
|
700763
|
+
get isHistoricalLoading() {
|
|
700764
|
+
return this.historicalLoading;
|
|
700765
|
+
}
|
|
700169
700766
|
recordEvent(event, options2 = {}) {
|
|
700170
700767
|
if (!this.activeRoot) {
|
|
700171
700768
|
this.startRun({
|
|
@@ -700250,22 +700847,26 @@ var init_action_tree = __esm({
|
|
|
700250
700847
|
render(width) {
|
|
700251
700848
|
const maxWidth = Math.max(12, width - 4);
|
|
700252
700849
|
this.lastRenderedNodeByRow.clear();
|
|
700850
|
+
if (this.historicalLoading) {
|
|
700851
|
+
const pct2 = this.historicalTotal > 0 ? ` · ${Math.min(100, Math.round(this.historicalScanned / this.historicalTotal * 100))}%` : "";
|
|
700852
|
+
const lines2 = [];
|
|
700853
|
+
lines2.push(ui.accent(frame("action tree", maxWidth, "╭", "╮")));
|
|
700854
|
+
lines2.push(fit4(ui.warn(`scanning .omnius history… ${this.historicalScanned}${this.historicalTotal > 0 ? `/${this.historicalTotal}` : ""} sources${pct2} · ${this.roots.length} run${this.roots.length === 1 ? "" : "s"} so far`), maxWidth));
|
|
700855
|
+
lines2.push(fit4(ui.hint("the tree fills in as the scan reads durable artifacts — it is not yet complete"), maxWidth));
|
|
700856
|
+
lines2.push(ui.accent(frame("Ctrl+Tab or /tree returns to the action stack", maxWidth, "╰", "╯")));
|
|
700857
|
+
return lines2;
|
|
700858
|
+
}
|
|
700253
700859
|
if (this.roots.length === 0) {
|
|
700254
700860
|
return [ui.hint("No retained runs yet. /tree and Ctrl+Tab remain available before a task starts.")];
|
|
700255
700861
|
}
|
|
700256
700862
|
const lines = [];
|
|
700257
|
-
lines.push(
|
|
700258
|
-
fit4(
|
|
700259
|
-
`${ui.accent("╭─ action tree ───────────────────────────────────────────────╮")}`,
|
|
700260
|
-
maxWidth
|
|
700261
|
-
)
|
|
700262
|
-
);
|
|
700863
|
+
lines.push(ui.accent(frame("action tree", maxWidth, "╭", "╮")));
|
|
700263
700864
|
lines.push(fit4(ui.hint(`${this.roots.length} retained run${this.roots.length === 1 ? "" : "s"} · oldest → newest · click a labeled box to expand`), maxWidth));
|
|
700264
700865
|
if (this.currentWorkingDirectory) {
|
|
700265
700866
|
lines.push(fit4(ui.hint(`current working dir: ${this.currentWorkingDirectory}`), maxWidth));
|
|
700266
700867
|
}
|
|
700267
700868
|
this.renderChildren(this.roots, "", lines, maxWidth);
|
|
700268
|
-
lines.push(
|
|
700869
|
+
lines.push(ui.accent(frame("Ctrl+Tab or /tree returns to the action stack", maxWidth, "╰", "╯")));
|
|
700269
700870
|
return lines;
|
|
700270
700871
|
}
|
|
700271
700872
|
/** Returns true when a clicked rendered row toggled an explorable node. */
|
|
@@ -700318,7 +700919,7 @@ var init_action_tree = __esm({
|
|
|
700318
700919
|
const args = redactJson(event.toolArgs);
|
|
700319
700920
|
if (args && args !== "{}") details.push(`args: ${compactText3(args, 220)}`);
|
|
700320
700921
|
for (const path16 of event.targetPaths ?? []) details.push(`target: ${path16}`);
|
|
700321
|
-
return
|
|
700922
|
+
return unique4(details);
|
|
700322
700923
|
}
|
|
700323
700924
|
resultDetails(event, options2) {
|
|
700324
700925
|
const details = this.callDetails(event, options2);
|
|
@@ -700327,32 +700928,36 @@ var init_action_tree = __esm({
|
|
|
700327
700928
|
if (receipt) details.push(...receiptDetails(receipt));
|
|
700328
700929
|
const output = compactText3(event.content || "", 280);
|
|
700329
700930
|
if (output) details.push(`result: ${output}`);
|
|
700330
|
-
return
|
|
700931
|
+
return unique4(details);
|
|
700331
700932
|
}
|
|
700332
700933
|
renderChildren(nodes, prefix, lines, maxWidth) {
|
|
700333
700934
|
for (let i2 = 0; i2 < nodes.length; i2++) {
|
|
700334
700935
|
const node = nodes[i2];
|
|
700335
700936
|
const last2 = i2 === nodes.length - 1;
|
|
700336
700937
|
const branch = last2 ? "└─" : "├─";
|
|
700337
|
-
const
|
|
700938
|
+
const stem = prefix + (last2 ? " " : "│ ");
|
|
700338
700939
|
const expandable = node.children.length > 0 || node.details.length > 0;
|
|
700339
700940
|
const toggle = expandable ? node.expanded ? "▼" : "▶" : "•";
|
|
700340
|
-
const
|
|
700941
|
+
const innerWidth = Math.max(
|
|
700942
|
+
1,
|
|
700943
|
+
maxWidth - displayWidth2(prefix) - displayWidth2(branch) - 2
|
|
700944
|
+
);
|
|
700945
|
+
const title = `${prefix}${branch}╭${fillAnsi(`─ ${toggle} ${node.label} `, innerWidth, "─")}╮`;
|
|
700341
700946
|
const row2 = lines.length;
|
|
700342
|
-
lines.push(
|
|
700947
|
+
lines.push(colorForState(node.state, title));
|
|
700343
700948
|
if (expandable) this.lastRenderedNodeByRow.set(row2, node.id);
|
|
700344
700949
|
if (!node.expanded) continue;
|
|
700345
700950
|
const details = node.details.slice(0, 8);
|
|
700346
700951
|
for (const detail of details) {
|
|
700347
|
-
lines.push(
|
|
700952
|
+
lines.push(`${stem}│${fillAnsi(` ${ui.sub(detail)} `, innerWidth, " ")}│`);
|
|
700348
700953
|
}
|
|
700349
700954
|
if (node.details.length > details.length) {
|
|
700350
|
-
lines.push(
|
|
700955
|
+
lines.push(`${stem}│${fillAnsi(` ${ui.hint(`… ${node.details.length - details.length} more details`)} `, innerWidth, " ")}│`);
|
|
700351
700956
|
}
|
|
700352
700957
|
if (node.children.length > 0) {
|
|
700353
|
-
this.renderChildren(node.children,
|
|
700958
|
+
this.renderChildren(node.children, stem, lines, maxWidth);
|
|
700354
700959
|
}
|
|
700355
|
-
lines.push(
|
|
700960
|
+
lines.push(colorForState(node.state, `${stem}╰${"─".repeat(innerWidth)}╯`));
|
|
700356
700961
|
}
|
|
700357
700962
|
}
|
|
700358
700963
|
addNode(parent, node) {
|
|
@@ -700393,7 +700998,7 @@ var init_action_tree = __esm({
|
|
|
700393
700998
|
state: run2.state,
|
|
700394
700999
|
at,
|
|
700395
701000
|
expanded: false,
|
|
700396
|
-
details:
|
|
701001
|
+
details: unique4([
|
|
700397
701002
|
historicalSourceLabel(run2.source),
|
|
700398
701003
|
`recorded ${formatTime4(at)}`,
|
|
700399
701004
|
run2.summary ? `summary: ${compactText3(run2.summary, 300)}` : "",
|
|
@@ -700443,7 +701048,7 @@ var init_action_tree = __esm({
|
|
|
700443
701048
|
state: event.state,
|
|
700444
701049
|
at,
|
|
700445
701050
|
expanded: false,
|
|
700446
|
-
details:
|
|
701051
|
+
details: unique4([
|
|
700447
701052
|
...(event.details ?? []).map((detail) => compactText3(detail, 300)),
|
|
700448
701053
|
...(event.relatedTo ?? []).map((id2) => `linked action: ${compactText3(id2, 120)}`)
|
|
700449
701054
|
]),
|
|
@@ -700493,164 +701098,8 @@ var init_action_tree = __esm({
|
|
|
700493
701098
|
// packages/cli/src/tui/action-tree-history.ts
|
|
700494
701099
|
import { existsSync as existsSync155, readdirSync as readdirSync53, readFileSync as readFileSync127, statSync as statSync62 } from "node:fs";
|
|
700495
701100
|
import { join as join164 } from "node:path";
|
|
700496
|
-
function
|
|
700497
|
-
|
|
700498
|
-
if (!existsSync155(stateDir)) return [];
|
|
700499
|
-
const builders = /* @__PURE__ */ new Map();
|
|
700500
|
-
const bySessionId = /* @__PURE__ */ new Map();
|
|
700501
|
-
const ensure = (id2) => {
|
|
700502
|
-
const existing = builders.get(id2);
|
|
700503
|
-
if (existing) return existing;
|
|
700504
|
-
const next = {
|
|
700505
|
-
id: id2,
|
|
700506
|
-
task: "Archived run",
|
|
700507
|
-
cwd: repoRoot,
|
|
700508
|
-
startedAt: "",
|
|
700509
|
-
source: "summary",
|
|
700510
|
-
state: "info",
|
|
700511
|
-
toolsUsed: [],
|
|
700512
|
-
filesModified: [],
|
|
700513
|
-
events: [],
|
|
700514
|
-
receipts: []
|
|
700515
|
-
};
|
|
700516
|
-
builders.set(id2, next);
|
|
700517
|
-
return next;
|
|
700518
|
-
};
|
|
700519
|
-
const byRunOrSession = (runId, sessionId) => builders.get(runId) ?? (sessionId ? bySessionId.get(sessionId) : void 0) ?? ensure(runId);
|
|
700520
|
-
const linkSession = (builder, sessionId) => {
|
|
700521
|
-
const id2 = asString2(sessionId);
|
|
700522
|
-
if (id2) bySessionId.set(id2, builder);
|
|
700523
|
-
};
|
|
700524
|
-
for (const file of jsonFiles(join164(stateDir, "completion-finalizations"))) {
|
|
700525
|
-
if (file.endsWith(".prepared.json")) continue;
|
|
700526
|
-
const record = readJson3(join164(stateDir, "completion-finalizations", file));
|
|
700527
|
-
if (!record || record["schema"] !== "omnius.completion-finalization.v1" || record["phase"] !== "committed") continue;
|
|
700528
|
-
const runId = asString2(record["runId"]);
|
|
700529
|
-
if (!runId) continue;
|
|
700530
|
-
const builder = ensure(runId);
|
|
700531
|
-
applySource(builder, "transactional");
|
|
700532
|
-
builder.state = terminalState(asString2(record["status"]));
|
|
700533
|
-
setIf(builder, "summary", asString2(record["summary"]));
|
|
700534
|
-
setIf(builder, "startedAt", asString2(record["committedAtIso"]));
|
|
700535
|
-
for (const receipt of asArray(record["commandReceipts"])) {
|
|
700536
|
-
const parsed = asRecord2(receipt);
|
|
700537
|
-
if (!parsed) continue;
|
|
700538
|
-
const evidenceId = asString2(parsed["evidenceId"]) || `receipt-${builder.receipts.length + 1}`;
|
|
700539
|
-
builder.receipts.push({
|
|
700540
|
-
id: evidenceId,
|
|
700541
|
-
label: `terminal receipt · ${asString2(parsed["toolName"]) || "command"}`,
|
|
700542
|
-
state: receiptState(parsed),
|
|
700543
|
-
at: asString2(parsed["finishedAtIso"]) || builder.startedAt,
|
|
700544
|
-
details: receiptDetails2(parsed)
|
|
700545
|
-
});
|
|
700546
|
-
}
|
|
700547
|
-
}
|
|
700548
|
-
for (const file of jsonFiles(join164(stateDir, "terminal-trajectories"))) {
|
|
700549
|
-
const record = readJson3(join164(stateDir, "terminal-trajectories", file));
|
|
700550
|
-
if (!record || record["schema"] !== "omnius.terminal-trajectory.v1") continue;
|
|
700551
|
-
const runId = asString2(record["runId"]);
|
|
700552
|
-
if (!runId) continue;
|
|
700553
|
-
const builder = ensure(runId);
|
|
700554
|
-
const payload = asRecord2(record["payload"]);
|
|
700555
|
-
if (!payload) continue;
|
|
700556
|
-
setIf(builder, "task", asString2(payload["task"]));
|
|
700557
|
-
setIf(builder, "model", asString2(payload["model"]));
|
|
700558
|
-
setIfNumber(builder, "toolCalls", payload["totalToolCalls"]);
|
|
700559
|
-
addAll2(builder.filesModified, stringArray4(payload["filesModified"]));
|
|
700560
|
-
setIf(builder, "startedAt", asString2(record["committedAtIso"]));
|
|
700561
|
-
if (builder.state === "info") builder.state = terminalState(asString2(record["status"]));
|
|
700562
|
-
}
|
|
700563
|
-
const debugRunsDir = join164(stateDir, "debug-library", "runs");
|
|
700564
|
-
for (const dir of directories(debugRunsDir)) {
|
|
700565
|
-
const runDir = join164(debugRunsDir, dir);
|
|
700566
|
-
const index = readJson3(join164(runDir, "index.json"));
|
|
700567
|
-
if (!index) continue;
|
|
700568
|
-
const runId = asString2(index["runId"]);
|
|
700569
|
-
if (!runId) continue;
|
|
700570
|
-
const builder = byRunOrSession(runId, asString2(index["sessionId"]));
|
|
700571
|
-
linkSession(builder, index["sessionId"]);
|
|
700572
|
-
applySource(builder, "debug");
|
|
700573
|
-
const debugCwd = asString2(index["cwd"]);
|
|
700574
|
-
if (debugCwd) builder.cwd = debugCwd;
|
|
700575
|
-
setIf(builder, "startedAt", asString2(index["createdAt"]) || asString2(index["updatedAt"]));
|
|
700576
|
-
const shouldAddActions = !hasActionEvents(builder);
|
|
700577
|
-
for (const event of readDebugEvents(join164(runDir, "events.jsonl"))) {
|
|
700578
|
-
if (event.kind === "checkpoint") {
|
|
700579
|
-
builder.events.push(event);
|
|
700580
|
-
} else if (shouldAddActions) {
|
|
700581
|
-
builder.events.push(event);
|
|
700582
|
-
}
|
|
700583
|
-
}
|
|
700584
|
-
}
|
|
700585
|
-
for (const file of jsonFiles(join164(stateDir, "provenance"))) {
|
|
700586
|
-
const record = readJson3(join164(stateDir, "provenance", file));
|
|
700587
|
-
if (!record) continue;
|
|
700588
|
-
const sessionId = asString2(record["sessionId"]);
|
|
700589
|
-
if (!sessionId) continue;
|
|
700590
|
-
const builder = bySessionId.get(sessionId) ?? ensure(`provenance:${sessionId}`);
|
|
700591
|
-
linkSession(builder, sessionId);
|
|
700592
|
-
applySource(builder, "provenance");
|
|
700593
|
-
setIf(builder, "task", asString2(record["task"]));
|
|
700594
|
-
setIf(builder, "startedAt", asString2(record["timestamp"]));
|
|
700595
|
-
if (builder.state === "info") builder.state = provenanceState(asString2(record["outcome"]));
|
|
700596
|
-
if (!hasActionEvents(builder)) {
|
|
700597
|
-
for (const action of asArray(record["actions"]).slice(0, MAX_EVENTS_PER_RUN)) {
|
|
700598
|
-
const parsed = asRecord2(action);
|
|
700599
|
-
if (!parsed) continue;
|
|
700600
|
-
const actionId = asString2(parsed["id"]) || `action-${builder.events.length + 1}`;
|
|
700601
|
-
builder.events.push({
|
|
700602
|
-
id: actionId,
|
|
700603
|
-
kind: "action",
|
|
700604
|
-
label: asString2(parsed["tool"]) || "recorded action",
|
|
700605
|
-
state: "info",
|
|
700606
|
-
at: isoFromMs(parsed["timestamp_ms"]),
|
|
700607
|
-
turn: asNumber2(parsed["turn"]),
|
|
700608
|
-
details: [
|
|
700609
|
-
asString2(parsed["args_fingerprint"]) ? `args fingerprint: ${asString2(parsed["args_fingerprint"])}` : ""
|
|
700610
|
-
].filter(Boolean),
|
|
700611
|
-
relatedTo: stringArray4(parsed["caused_by"])
|
|
700612
|
-
});
|
|
700613
|
-
}
|
|
700614
|
-
}
|
|
700615
|
-
}
|
|
700616
|
-
for (const record of readJsonLines(join164(stateDir, "context", "session-context.events.jsonl"))) {
|
|
700617
|
-
applySessionSummary(record, bySessionId, ensure);
|
|
700618
|
-
}
|
|
700619
|
-
for (const file of jsonFiles(join164(stateDir, "history"))) {
|
|
700620
|
-
if (file === "pending-task.json") continue;
|
|
700621
|
-
const record = readJson3(join164(stateDir, "history", file));
|
|
700622
|
-
if (record) applySessionSummary(record, bySessionId, ensure);
|
|
700623
|
-
}
|
|
700624
|
-
return [...builders.values()].filter((builder) => builder.task !== "Archived run" || builder.events.length > 0 || builder.receipts.length > 0).sort((a2, b) => timeValue(a2.startedAt) - timeValue(b.startedAt) || a2.id.localeCompare(b.id)).map((builder) => ({
|
|
700625
|
-
id: builder.id,
|
|
700626
|
-
task: builder.task,
|
|
700627
|
-
cwd: builder.cwd,
|
|
700628
|
-
startedAt: builder.startedAt || void 0,
|
|
700629
|
-
source: builder.source,
|
|
700630
|
-
state: builder.state,
|
|
700631
|
-
...builder.summary ? { summary: builder.summary } : {},
|
|
700632
|
-
...builder.model ? { model: builder.model } : {},
|
|
700633
|
-
...typeof builder.toolCalls === "number" ? { toolCalls: builder.toolCalls } : {},
|
|
700634
|
-
...builder.toolsUsed.length > 0 ? { toolsUsed: builder.toolsUsed } : {},
|
|
700635
|
-
...builder.filesModified.length > 0 ? { filesModified: builder.filesModified } : {},
|
|
700636
|
-
...builder.events.length > 0 ? { events: builder.events } : {},
|
|
700637
|
-
...builder.receipts.length > 0 ? { receipts: builder.receipts } : {}
|
|
700638
|
-
}));
|
|
700639
|
-
}
|
|
700640
|
-
function applySessionSummary(record, bySessionId, ensure) {
|
|
700641
|
-
const sessionId = asString2(record["sessionId"]) || asString2(record["id"]);
|
|
700642
|
-
const savedAt = asString2(record["savedAt"]) || asString2(record["startedAt"]) || asString2(record["completedAt"]);
|
|
700643
|
-
const builder = (sessionId ? bySessionId.get(sessionId) : void 0) ?? ensure(`summary:${sessionId || savedAt || "unknown"}`);
|
|
700644
|
-
if (sessionId) bySessionId.set(sessionId, builder);
|
|
700645
|
-
applySource(builder, "summary");
|
|
700646
|
-
setIf(builder, "task", asString2(record["task"]));
|
|
700647
|
-
setIf(builder, "summary", asString2(record["summary"]));
|
|
700648
|
-
setIf(builder, "model", asString2(record["model"]));
|
|
700649
|
-
setIf(builder, "startedAt", savedAt);
|
|
700650
|
-
setIfNumber(builder, "toolCalls", record["toolCalls"]);
|
|
700651
|
-
addAll2(builder.toolsUsed, stringArray4(record["toolsUsed"]));
|
|
700652
|
-
addAll2(builder.filesModified, stringArray4(record["filesModified"]));
|
|
700653
|
-
if (builder.state === "info") builder.state = record["completed"] === true ? "passed" : "blocked";
|
|
701101
|
+
function createHistoryScanner(repoRoot) {
|
|
701102
|
+
return new HistoryScanner(repoRoot);
|
|
700654
701103
|
}
|
|
700655
701104
|
function readDebugEvents(path16) {
|
|
700656
701105
|
const raw = readBoundedText(path16);
|
|
@@ -700807,11 +701256,280 @@ function timeValue(value2) {
|
|
|
700807
701256
|
const parsed = Date.parse(value2);
|
|
700808
701257
|
return Number.isFinite(parsed) ? parsed : Number.MAX_SAFE_INTEGER;
|
|
700809
701258
|
}
|
|
700810
|
-
|
|
701259
|
+
function macrotask() {
|
|
701260
|
+
return new Promise((resolve84) => setImmediate(resolve84));
|
|
701261
|
+
}
|
|
701262
|
+
var MAX_EVENTS_PER_RUN, MAX_EVENT_LOG_BYTES, HistoryScanner;
|
|
700811
701263
|
var init_action_tree_history = __esm({
|
|
700812
701264
|
"packages/cli/src/tui/action-tree-history.ts"() {
|
|
700813
701265
|
MAX_EVENTS_PER_RUN = 1e3;
|
|
700814
701266
|
MAX_EVENT_LOG_BYTES = 8 * 1024 * 1024;
|
|
701267
|
+
HistoryScanner = class {
|
|
701268
|
+
constructor(repoRoot) {
|
|
701269
|
+
this.repoRoot = repoRoot;
|
|
701270
|
+
}
|
|
701271
|
+
repoRoot;
|
|
701272
|
+
builders = /* @__PURE__ */ new Map();
|
|
701273
|
+
bySessionId = /* @__PURE__ */ new Map();
|
|
701274
|
+
aborted = false;
|
|
701275
|
+
/** Stop a running `scan()` at the next batch boundary. */
|
|
701276
|
+
abort() {
|
|
701277
|
+
this.aborted = true;
|
|
701278
|
+
}
|
|
701279
|
+
/** Synchronous full read (equivalent to `loadActionTreeHistory`). */
|
|
701280
|
+
loadSync() {
|
|
701281
|
+
for (const task of this.enumerate()) this.applyTask(task);
|
|
701282
|
+
return this.finalize();
|
|
701283
|
+
}
|
|
701284
|
+
/**
|
|
701285
|
+
* Incrementally scan history, yielding batches of discovered runs.
|
|
701286
|
+
*
|
|
701287
|
+
* Each yielded batch contains the runs whose source files were consumed in
|
|
701288
|
+
* the most recent batch, so a consumer can append them to a live tree as
|
|
701289
|
+
* they arrive. The final batch (if any) flushes remaining dirty runs.
|
|
701290
|
+
*/
|
|
701291
|
+
async *scan(opts = {}) {
|
|
701292
|
+
const tasks = this.enumerate();
|
|
701293
|
+
const batchSize = Math.max(1, opts.batchSize ?? 64);
|
|
701294
|
+
const total = tasks.length;
|
|
701295
|
+
opts.onProgress?.(this.progress("enumerating", 0, total, false));
|
|
701296
|
+
const dirty2 = /* @__PURE__ */ new Set();
|
|
701297
|
+
for (let i2 = 0; i2 < tasks.length; i2 += batchSize) {
|
|
701298
|
+
if (opts.signal?.aborted || this.aborted) {
|
|
701299
|
+
opts.onProgress?.(this.progress("done", i2, total, true));
|
|
701300
|
+
return;
|
|
701301
|
+
}
|
|
701302
|
+
const slice2 = tasks.slice(i2, i2 + batchSize);
|
|
701303
|
+
for (const task of slice2) {
|
|
701304
|
+
const key = this.applyTask(task);
|
|
701305
|
+
if (key) dirty2.add(key);
|
|
701306
|
+
}
|
|
701307
|
+
const scanned = Math.min(i2 + batchSize, total);
|
|
701308
|
+
opts.onProgress?.(this.progress("scanning", scanned, total, false));
|
|
701309
|
+
const batch2 = this.drainDirty(dirty2);
|
|
701310
|
+
if (batch2.length > 0) yield batch2;
|
|
701311
|
+
await macrotask();
|
|
701312
|
+
}
|
|
701313
|
+
const tail = this.drainDirty(dirty2);
|
|
701314
|
+
if (tail.length > 0) yield tail;
|
|
701315
|
+
opts.onProgress?.(this.progress("done", total, total, false));
|
|
701316
|
+
}
|
|
701317
|
+
progress(phase, filesScanned, filesTotal, aborted) {
|
|
701318
|
+
return {
|
|
701319
|
+
phase,
|
|
701320
|
+
filesScanned,
|
|
701321
|
+
filesTotal,
|
|
701322
|
+
runsDiscovered: this.builders.size,
|
|
701323
|
+
aborted
|
|
701324
|
+
};
|
|
701325
|
+
}
|
|
701326
|
+
drainDirty(dirty2) {
|
|
701327
|
+
if (dirty2.size === 0) return [];
|
|
701328
|
+
const batch2 = [...dirty2].map((key) => this.builders.get(key)).filter((builder) => !!builder && this.isRetained(builder)).map((builder) => this.toRun(builder));
|
|
701329
|
+
dirty2.clear();
|
|
701330
|
+
return batch2;
|
|
701331
|
+
}
|
|
701332
|
+
enumerate() {
|
|
701333
|
+
const stateDir = join164(this.repoRoot, ".omnius");
|
|
701334
|
+
if (!existsSync155(stateDir)) return [];
|
|
701335
|
+
const tasks = [];
|
|
701336
|
+
for (const file of jsonFiles(join164(stateDir, "completion-finalizations"))) {
|
|
701337
|
+
if (file.endsWith(".prepared.json")) continue;
|
|
701338
|
+
tasks.push({ kind: "finalization", path: join164(stateDir, "completion-finalizations", file) });
|
|
701339
|
+
}
|
|
701340
|
+
for (const file of jsonFiles(join164(stateDir, "terminal-trajectories"))) {
|
|
701341
|
+
tasks.push({ kind: "trajectory", path: join164(stateDir, "terminal-trajectories", file) });
|
|
701342
|
+
}
|
|
701343
|
+
for (const dir of directories(join164(stateDir, "debug-library", "runs"))) {
|
|
701344
|
+
tasks.push({ kind: "debugRun", dir: join164(stateDir, "debug-library", "runs", dir) });
|
|
701345
|
+
}
|
|
701346
|
+
for (const file of jsonFiles(join164(stateDir, "provenance"))) {
|
|
701347
|
+
tasks.push({ kind: "provenance", path: join164(stateDir, "provenance", file) });
|
|
701348
|
+
}
|
|
701349
|
+
const contextLines = readJsonLines(join164(stateDir, "context", "session-context.events.jsonl"));
|
|
701350
|
+
for (const record of contextLines) {
|
|
701351
|
+
tasks.push({ kind: "contextLine", line: JSON.stringify(record) });
|
|
701352
|
+
}
|
|
701353
|
+
for (const file of jsonFiles(join164(stateDir, "history"))) {
|
|
701354
|
+
if (file === "pending-task.json") continue;
|
|
701355
|
+
tasks.push({ kind: "history", path: join164(stateDir, "history", file) });
|
|
701356
|
+
}
|
|
701357
|
+
return tasks;
|
|
701358
|
+
}
|
|
701359
|
+
/** Apply one source file. Returns the builder key it touched, if any. */
|
|
701360
|
+
applyTask(task) {
|
|
701361
|
+
switch (task.kind) {
|
|
701362
|
+
case "finalization": {
|
|
701363
|
+
const record = readJson3(task.path);
|
|
701364
|
+
if (!record || record["schema"] !== "omnius.completion-finalization.v1" || record["phase"] !== "committed") return void 0;
|
|
701365
|
+
const runId = asString2(record["runId"]);
|
|
701366
|
+
if (!runId) return void 0;
|
|
701367
|
+
const builder = this.ensure(runId);
|
|
701368
|
+
applySource(builder, "transactional");
|
|
701369
|
+
builder.state = terminalState(asString2(record["status"]));
|
|
701370
|
+
setIf(builder, "summary", asString2(record["summary"]));
|
|
701371
|
+
setIf(builder, "startedAt", asString2(record["committedAtIso"]));
|
|
701372
|
+
for (const receipt of asArray(record["commandReceipts"])) {
|
|
701373
|
+
const parsed = asRecord2(receipt);
|
|
701374
|
+
if (!parsed) continue;
|
|
701375
|
+
const evidenceId = asString2(parsed["evidenceId"]) || `receipt-${builder.receipts.length + 1}`;
|
|
701376
|
+
builder.receipts.push({
|
|
701377
|
+
id: evidenceId,
|
|
701378
|
+
label: `terminal receipt · ${asString2(parsed["toolName"]) || "command"}`,
|
|
701379
|
+
state: receiptState(parsed),
|
|
701380
|
+
at: asString2(parsed["finishedAtIso"]) || builder.startedAt,
|
|
701381
|
+
details: receiptDetails2(parsed)
|
|
701382
|
+
});
|
|
701383
|
+
}
|
|
701384
|
+
return builder.key;
|
|
701385
|
+
}
|
|
701386
|
+
case "trajectory": {
|
|
701387
|
+
const record = readJson3(task.path);
|
|
701388
|
+
if (!record || record["schema"] !== "omnius.terminal-trajectory.v1") return void 0;
|
|
701389
|
+
const runId = asString2(record["runId"]);
|
|
701390
|
+
if (!runId) return void 0;
|
|
701391
|
+
const builder = this.ensure(runId);
|
|
701392
|
+
const payload = asRecord2(record["payload"]);
|
|
701393
|
+
if (!payload) return builder.key;
|
|
701394
|
+
setIf(builder, "task", asString2(payload["task"]));
|
|
701395
|
+
setIf(builder, "model", asString2(payload["model"]));
|
|
701396
|
+
setIfNumber(builder, "toolCalls", payload["totalToolCalls"]);
|
|
701397
|
+
addAll2(builder.filesModified, stringArray4(payload["filesModified"]));
|
|
701398
|
+
setIf(builder, "startedAt", asString2(record["committedAtIso"]));
|
|
701399
|
+
if (builder.state === "info") builder.state = terminalState(asString2(record["status"]));
|
|
701400
|
+
return builder.key;
|
|
701401
|
+
}
|
|
701402
|
+
case "debugRun": {
|
|
701403
|
+
const index = readJson3(join164(task.dir, "index.json"));
|
|
701404
|
+
if (!index) return void 0;
|
|
701405
|
+
const runId = asString2(index["runId"]);
|
|
701406
|
+
if (!runId) return void 0;
|
|
701407
|
+
const builder = this.byRunOrSession(runId, asString2(index["sessionId"]));
|
|
701408
|
+
this.linkSession(builder, index["sessionId"]);
|
|
701409
|
+
applySource(builder, "debug");
|
|
701410
|
+
const debugCwd = asString2(index["cwd"]);
|
|
701411
|
+
if (debugCwd) builder.cwd = debugCwd;
|
|
701412
|
+
setIf(builder, "startedAt", asString2(index["createdAt"]) || asString2(index["updatedAt"]));
|
|
701413
|
+
const shouldAddActions = !hasActionEvents(builder);
|
|
701414
|
+
for (const event of readDebugEvents(join164(task.dir, "events.jsonl"))) {
|
|
701415
|
+
if (event.kind === "checkpoint") {
|
|
701416
|
+
builder.events.push(event);
|
|
701417
|
+
} else if (shouldAddActions) {
|
|
701418
|
+
builder.events.push(event);
|
|
701419
|
+
}
|
|
701420
|
+
}
|
|
701421
|
+
return builder.key;
|
|
701422
|
+
}
|
|
701423
|
+
case "provenance": {
|
|
701424
|
+
const record = readJson3(task.path);
|
|
701425
|
+
if (!record) return void 0;
|
|
701426
|
+
const sessionId = asString2(record["sessionId"]);
|
|
701427
|
+
if (!sessionId) return void 0;
|
|
701428
|
+
const builder = this.bySessionId.get(sessionId) ?? this.ensure(`provenance:${sessionId}`);
|
|
701429
|
+
this.linkSession(builder, sessionId);
|
|
701430
|
+
applySource(builder, "provenance");
|
|
701431
|
+
setIf(builder, "task", asString2(record["task"]));
|
|
701432
|
+
setIf(builder, "startedAt", asString2(record["timestamp"]));
|
|
701433
|
+
if (builder.state === "info") builder.state = provenanceState(asString2(record["outcome"]));
|
|
701434
|
+
if (!hasActionEvents(builder)) {
|
|
701435
|
+
for (const action of asArray(record["actions"]).slice(0, MAX_EVENTS_PER_RUN)) {
|
|
701436
|
+
const parsed = asRecord2(action);
|
|
701437
|
+
if (!parsed) continue;
|
|
701438
|
+
const actionId = asString2(parsed["id"]) || `action-${builder.events.length + 1}`;
|
|
701439
|
+
builder.events.push({
|
|
701440
|
+
id: actionId,
|
|
701441
|
+
kind: "action",
|
|
701442
|
+
label: asString2(parsed["tool"]) || "recorded action",
|
|
701443
|
+
state: "info",
|
|
701444
|
+
at: isoFromMs(parsed["timestamp_ms"]),
|
|
701445
|
+
turn: asNumber2(parsed["turn"]),
|
|
701446
|
+
details: [
|
|
701447
|
+
asString2(parsed["args_fingerprint"]) ? `args fingerprint: ${asString2(parsed["args_fingerprint"])}` : ""
|
|
701448
|
+
].filter(Boolean),
|
|
701449
|
+
relatedTo: stringArray4(parsed["caused_by"])
|
|
701450
|
+
});
|
|
701451
|
+
}
|
|
701452
|
+
}
|
|
701453
|
+
return builder.key;
|
|
701454
|
+
}
|
|
701455
|
+
case "contextLine": {
|
|
701456
|
+
const record = parseJson(task.line);
|
|
701457
|
+
if (!record) return void 0;
|
|
701458
|
+
return this.applySessionSummary(record);
|
|
701459
|
+
}
|
|
701460
|
+
case "history": {
|
|
701461
|
+
const record = readJson3(task.path);
|
|
701462
|
+
if (!record) return void 0;
|
|
701463
|
+
return this.applySessionSummary(record);
|
|
701464
|
+
}
|
|
701465
|
+
}
|
|
701466
|
+
}
|
|
701467
|
+
finalize() {
|
|
701468
|
+
return [...this.builders.values()].filter((builder) => this.isRetained(builder)).sort((a2, b) => timeValue(a2.startedAt) - timeValue(b.startedAt) || a2.id.localeCompare(b.id)).map((builder) => this.toRun(builder));
|
|
701469
|
+
}
|
|
701470
|
+
toRun(builder) {
|
|
701471
|
+
return {
|
|
701472
|
+
id: builder.id,
|
|
701473
|
+
task: builder.task,
|
|
701474
|
+
cwd: builder.cwd,
|
|
701475
|
+
startedAt: builder.startedAt || void 0,
|
|
701476
|
+
source: builder.source,
|
|
701477
|
+
state: builder.state,
|
|
701478
|
+
...builder.summary ? { summary: builder.summary } : {},
|
|
701479
|
+
...builder.model ? { model: builder.model } : {},
|
|
701480
|
+
...typeof builder.toolCalls === "number" ? { toolCalls: builder.toolCalls } : {},
|
|
701481
|
+
...builder.toolsUsed.length > 0 ? { toolsUsed: builder.toolsUsed } : {},
|
|
701482
|
+
...builder.filesModified.length > 0 ? { filesModified: builder.filesModified } : {},
|
|
701483
|
+
...builder.events.length > 0 ? { events: builder.events } : {},
|
|
701484
|
+
...builder.receipts.length > 0 ? { receipts: builder.receipts } : {}
|
|
701485
|
+
};
|
|
701486
|
+
}
|
|
701487
|
+
isRetained(builder) {
|
|
701488
|
+
return builder.task !== "Archived run" || builder.events.length > 0 || builder.receipts.length > 0;
|
|
701489
|
+
}
|
|
701490
|
+
ensure(id2) {
|
|
701491
|
+
const existing = this.builders.get(id2);
|
|
701492
|
+
if (existing) return existing;
|
|
701493
|
+
const next = {
|
|
701494
|
+
key: id2,
|
|
701495
|
+
id: id2,
|
|
701496
|
+
task: "Archived run",
|
|
701497
|
+
cwd: this.repoRoot,
|
|
701498
|
+
startedAt: "",
|
|
701499
|
+
source: "summary",
|
|
701500
|
+
state: "info",
|
|
701501
|
+
toolsUsed: [],
|
|
701502
|
+
filesModified: [],
|
|
701503
|
+
events: [],
|
|
701504
|
+
receipts: []
|
|
701505
|
+
};
|
|
701506
|
+
this.builders.set(id2, next);
|
|
701507
|
+
return next;
|
|
701508
|
+
}
|
|
701509
|
+
byRunOrSession(runId, sessionId) {
|
|
701510
|
+
return this.builders.get(runId) ?? (sessionId ? this.bySessionId.get(sessionId) : void 0) ?? this.ensure(runId);
|
|
701511
|
+
}
|
|
701512
|
+
linkSession(builder, sessionId) {
|
|
701513
|
+
const id2 = asString2(sessionId);
|
|
701514
|
+
if (id2) this.bySessionId.set(id2, builder);
|
|
701515
|
+
}
|
|
701516
|
+
applySessionSummary(record) {
|
|
701517
|
+
const sessionId = asString2(record["sessionId"]) || asString2(record["id"]);
|
|
701518
|
+
const savedAt = asString2(record["savedAt"]) || asString2(record["startedAt"]) || asString2(record["completedAt"]);
|
|
701519
|
+
const builder = (sessionId ? this.bySessionId.get(sessionId) : void 0) ?? this.ensure(`summary:${sessionId || savedAt || "unknown"}`);
|
|
701520
|
+
if (sessionId) this.bySessionId.set(sessionId, builder);
|
|
701521
|
+
applySource(builder, "summary");
|
|
701522
|
+
setIf(builder, "task", asString2(record["task"]));
|
|
701523
|
+
setIf(builder, "summary", asString2(record["summary"]));
|
|
701524
|
+
setIf(builder, "model", asString2(record["model"]));
|
|
701525
|
+
setIf(builder, "startedAt", savedAt);
|
|
701526
|
+
setIfNumber(builder, "toolCalls", record["toolCalls"]);
|
|
701527
|
+
addAll2(builder.toolsUsed, stringArray4(record["toolsUsed"]));
|
|
701528
|
+
addAll2(builder.filesModified, stringArray4(record["filesModified"]));
|
|
701529
|
+
if (builder.state === "info") builder.state = record["completed"] === true ? "passed" : "blocked";
|
|
701530
|
+
return builder.key;
|
|
701531
|
+
}
|
|
701532
|
+
};
|
|
700815
701533
|
}
|
|
700816
701534
|
});
|
|
700817
701535
|
|
|
@@ -705764,13 +706482,13 @@ function buildScopedToolList(scope) {
|
|
|
705764
706482
|
const commandSigs = commands.flatMap((cmd) => cmd.signatures);
|
|
705765
706483
|
const allSigs = [...syntheticSigs, ...commandSigs];
|
|
705766
706484
|
const seen = /* @__PURE__ */ new Set();
|
|
705767
|
-
const
|
|
706485
|
+
const unique5 = allSigs.filter((sig) => {
|
|
705768
706486
|
if (seen.has(sig.signature)) return false;
|
|
705769
706487
|
seen.add(sig.signature);
|
|
705770
706488
|
return true;
|
|
705771
706489
|
});
|
|
705772
706490
|
const entries2 = [];
|
|
705773
|
-
for (const sig of
|
|
706491
|
+
for (const sig of unique5) {
|
|
705774
706492
|
const matchingCmd = commands.find(
|
|
705775
706493
|
(cmd) => cmd.signatures.some((s2) => s2.signature === sig.signature)
|
|
705776
706494
|
);
|
|
@@ -706794,12 +707512,12 @@ function scopedTool(base3, root, mode) {
|
|
|
706794
707512
|
for (const fn of cleanup) fn();
|
|
706795
707513
|
}
|
|
706796
707514
|
}
|
|
706797
|
-
const
|
|
707515
|
+
const pathKey2 = PATH_KEYS.find(
|
|
706798
707516
|
(key) => typeof next[key] === "string" && String(next[key]).trim()
|
|
706799
707517
|
);
|
|
706800
707518
|
let restoredEditPath = null;
|
|
706801
|
-
if (
|
|
706802
|
-
const guarded = guardPath(rootAbs, String(next[
|
|
707519
|
+
if (pathKey2) {
|
|
707520
|
+
const guarded = guardPath(rootAbs, String(next[pathKey2]));
|
|
706803
707521
|
if (!guarded.ok) return denied(guarded.error);
|
|
706804
707522
|
const pathPolicyError = publicCreativeArtifactPolicyError(
|
|
706805
707523
|
guarded.path.abs
|
|
@@ -706828,7 +707546,7 @@ function scopedTool(base3, root, mode) {
|
|
|
706828
707546
|
`Refusing to overwrite a file that is not owned by this chat workspace manifest: ${guarded.path.rel}`
|
|
706829
707547
|
);
|
|
706830
707548
|
}
|
|
706831
|
-
next[
|
|
707549
|
+
next[pathKey2] = guarded.path.rel;
|
|
706832
707550
|
} else if (mode !== "list") {
|
|
706833
707551
|
return denied(
|
|
706834
707552
|
`${base3.name} requires a path inside the public creative workspace.`
|
|
@@ -706836,8 +707554,8 @@ function scopedTool(base3, root, mode) {
|
|
|
706836
707554
|
}
|
|
706837
707555
|
const result = await base3.execute(next);
|
|
706838
707556
|
const recordedPaths = /* @__PURE__ */ new Set();
|
|
706839
|
-
if (result.success && (mode === "create" || mode === "edit") &&
|
|
706840
|
-
const guarded = guardPath(rootAbs, String(args[
|
|
707557
|
+
if (result.success && (mode === "create" || mode === "edit") && pathKey2) {
|
|
707558
|
+
const guarded = guardPath(rootAbs, String(args[pathKey2]));
|
|
706841
707559
|
if (guarded.ok) {
|
|
706842
707560
|
rememberCreated(rootAbs, guarded.path.abs);
|
|
706843
707561
|
recordedPaths.add(resolve74(guarded.path.abs));
|
|
@@ -708037,8 +708755,8 @@ function sessionDir(repoRoot, sessionKey) {
|
|
|
708037
708755
|
return join172(daydreamRoot(repoRoot), safeFilePart(hash2));
|
|
708038
708756
|
}
|
|
708039
708757
|
function compactLine2(value2, max = 220) {
|
|
708040
|
-
const
|
|
708041
|
-
return
|
|
708758
|
+
const clean7 = value2.replace(/\s+/g, " ").trim();
|
|
708759
|
+
return clean7.length > max ? `${clean7.slice(0, Math.max(0, max - 3)).trimEnd()}...` : clean7;
|
|
708042
708760
|
}
|
|
708043
708761
|
function isoFromMs2(value2) {
|
|
708044
708762
|
return value2 ? new Date(value2).toISOString() : void 0;
|
|
@@ -708380,9 +709098,9 @@ function participantForThread(input, thread) {
|
|
|
708380
709098
|
);
|
|
708381
709099
|
}
|
|
708382
709100
|
if (sourceMessage?.speaker) {
|
|
708383
|
-
const
|
|
709101
|
+
const clean7 = sourceMessage.speaker.replace(/^@/, "");
|
|
708384
709102
|
return input.participants.find(
|
|
708385
|
-
(participant) => participant.username ===
|
|
709103
|
+
(participant) => participant.username === clean7 || participant.firstName === sourceMessage.speaker
|
|
708386
709104
|
);
|
|
708387
709105
|
}
|
|
708388
709106
|
return topParticipants(input)[0];
|
|
@@ -708868,11 +709586,11 @@ function telegramReflectionMemoryDbPaths(repoRoot) {
|
|
|
708868
709586
|
function stableHash2(value2, length4 = 16) {
|
|
708869
709587
|
return createHash55("sha1").update(value2).digest("hex").slice(0, length4);
|
|
708870
709588
|
}
|
|
708871
|
-
function
|
|
709589
|
+
function clean5(value2) {
|
|
708872
709590
|
return String(value2 ?? "").replace(/\s+/g, " ").trim();
|
|
708873
709591
|
}
|
|
708874
709592
|
function compact2(value2, max = 420) {
|
|
708875
|
-
const text2 =
|
|
709593
|
+
const text2 = clean5(value2);
|
|
708876
709594
|
return text2.length > max ? `${text2.slice(0, Math.max(0, max - 3)).trimEnd()}...` : text2;
|
|
708877
709595
|
}
|
|
708878
709596
|
function senderLabel(entry) {
|
|
@@ -709261,7 +709979,7 @@ var init_telegram_reflection_corpus = __esm({
|
|
|
709261
709979
|
});
|
|
709262
709980
|
|
|
709263
709981
|
// packages/cli/src/tui/telegram-reflection-extraction.ts
|
|
709264
|
-
function
|
|
709982
|
+
function clean6(value2, max = 2e3) {
|
|
709265
709983
|
const text2 = String(value2 ?? "").replace(/\s+/g, " ").trim();
|
|
709266
709984
|
return text2.length > max ? `${text2.slice(0, Math.max(0, max - 3)).trimEnd()}...` : text2;
|
|
709267
709985
|
}
|
|
@@ -709275,13 +709993,13 @@ function numberArray(value2) {
|
|
|
709275
709993
|
}
|
|
709276
709994
|
function stringArray5(value2) {
|
|
709277
709995
|
if (!Array.isArray(value2)) return [];
|
|
709278
|
-
return [...new Set(value2.map((item) =>
|
|
709996
|
+
return [...new Set(value2.map((item) => clean6(item, 180)).filter(Boolean))];
|
|
709279
709997
|
}
|
|
709280
709998
|
function episodeLine(episode) {
|
|
709281
709999
|
const meta = episode.metadata;
|
|
709282
710000
|
const telegram = meta?.telegram;
|
|
709283
|
-
const speaker =
|
|
709284
|
-
const role =
|
|
710001
|
+
const speaker = clean6(telegram?.speaker || telegram?.username || "unknown", 80);
|
|
710002
|
+
const role = clean6(telegram?.speakerRole || "participant_human", 40);
|
|
709285
710003
|
const messageId = telegram?.messageId == null ? "unknown" : String(telegram.messageId);
|
|
709286
710004
|
const replyTo = telegram?.replyToMessageId == null ? "" : ` reply_to=${telegram.replyToMessageId}`;
|
|
709287
710005
|
return [
|
|
@@ -709290,13 +710008,13 @@ function episodeLine(episode) {
|
|
|
709290
710008
|
`speaker=${speaker}`,
|
|
709291
710009
|
`speaker_role=${role}`,
|
|
709292
710010
|
`modality=${episode.modality}`,
|
|
709293
|
-
`content=${
|
|
710011
|
+
`content=${clean6(episode.content, 700)}`
|
|
709294
710012
|
].join(" | ");
|
|
709295
710013
|
}
|
|
709296
710014
|
function buildTelegramReflectionExtractionPrompt(options2) {
|
|
709297
710015
|
const corpus = options2.corpus;
|
|
709298
|
-
const walkNodes = corpus.graphWalk.visitedNodes.slice(0, 40).map((node) => `node_id=${node.id} type=${node.nodeType} mentions=${node.mentionCount} text=${
|
|
709299
|
-
const walkEdges = corpus.graphWalk.traversedEdges.slice(0, 60).map((edge) => `edge_id=${edge.id} relation=${edge.relation} confidence=${edge.confidence.toFixed(2)} src=${edge.srcId} dst=${edge.dstId} source_episode=${edge.sourceEpisodeId || "none"} fact=${
|
|
710016
|
+
const walkNodes = corpus.graphWalk.visitedNodes.slice(0, 40).map((node) => `node_id=${node.id} type=${node.nodeType} mentions=${node.mentionCount} text=${clean6(node.text, 220)}`).join("\n");
|
|
710017
|
+
const walkEdges = corpus.graphWalk.traversedEdges.slice(0, 60).map((edge) => `edge_id=${edge.id} relation=${edge.relation} confidence=${edge.confidence.toFixed(2)} src=${edge.srcId} dst=${edge.dstId} source_episode=${edge.sourceEpisodeId || "none"} fact=${clean6(edge.fact, 220)}`).join("\n");
|
|
709300
710018
|
const episodes = corpus.selectedEpisodes.slice(0, 36).map(episodeLine).join("\n");
|
|
709301
710019
|
return [
|
|
709302
710020
|
"You are extracting a reusable Telegram reflection artifact from a scoped chat corpus.",
|
|
@@ -709329,7 +710047,7 @@ function buildTelegramReflectionExtractionPrompt(options2) {
|
|
|
709329
710047
|
"",
|
|
709330
710048
|
`Chat: ${options2.chatTitle || options2.chatId} (${options2.chatType})`,
|
|
709331
710049
|
`Session: ${options2.sessionKey}`,
|
|
709332
|
-
`Corpus query: ${
|
|
710050
|
+
`Corpus query: ${clean6(corpus.query, 1e3)}`,
|
|
709333
710051
|
`Corpus stats: ${JSON.stringify(corpus.stats)}`,
|
|
709334
710052
|
`Selected seed: ${corpus.graphWalk.seed ? `${corpus.graphWalk.seed.node.text} degree=${corpus.graphWalk.seed.degree}` : "none"}`,
|
|
709335
710053
|
corpus.fallbacks.length ? `Fallbacks: ${corpus.fallbacks.join("; ")}` : "Fallbacks: none",
|
|
@@ -709363,8 +710081,8 @@ function parseTelegramReflectionExtraction(raw) {
|
|
|
709363
710081
|
const tags = Array.isArray(parsed.tags) ? parsed.tags.map((item) => {
|
|
709364
710082
|
const obj = item;
|
|
709365
710083
|
return {
|
|
709366
|
-
label:
|
|
709367
|
-
kind:
|
|
710084
|
+
label: clean6(obj.label, 80),
|
|
710085
|
+
kind: clean6(obj.kind, 40) || "topic",
|
|
709368
710086
|
confidence: clampConfidence(obj.confidence),
|
|
709369
710087
|
sourceMessageIds: numberArray(obj.source_message_ids ?? obj.sourceMessageIds),
|
|
709370
710088
|
targetEpisodeIds: stringArray5(obj.target_episode_ids ?? obj.targetEpisodeIds),
|
|
@@ -709374,9 +710092,9 @@ function parseTelegramReflectionExtraction(raw) {
|
|
|
709374
710092
|
const summaries = Array.isArray(parsed.summaries) ? parsed.summaries.map((item) => {
|
|
709375
710093
|
const obj = item;
|
|
709376
710094
|
return {
|
|
709377
|
-
title:
|
|
709378
|
-
scope:
|
|
709379
|
-
text:
|
|
710095
|
+
title: clean6(obj.title, 120),
|
|
710096
|
+
scope: clean6(obj.scope, 60) || "message_window",
|
|
710097
|
+
text: clean6(obj.text, 1200),
|
|
709380
710098
|
confidence: clampConfidence(obj.confidence),
|
|
709381
710099
|
sourceMessageIds: numberArray(obj.source_message_ids ?? obj.sourceMessageIds),
|
|
709382
710100
|
targetEpisodeIds: stringArray5(obj.target_episode_ids ?? obj.targetEpisodeIds)
|
|
@@ -709385,8 +710103,8 @@ function parseTelegramReflectionExtraction(raw) {
|
|
|
709385
710103
|
const titles = Array.isArray(parsed.titles) ? parsed.titles.map((item) => {
|
|
709386
710104
|
const obj = item;
|
|
709387
710105
|
return {
|
|
709388
|
-
title:
|
|
709389
|
-
target:
|
|
710106
|
+
title: clean6(obj.title, 120),
|
|
710107
|
+
target: clean6(obj.target, 60) || "artifact",
|
|
709390
710108
|
confidence: clampConfidence(obj.confidence),
|
|
709391
710109
|
sourceMessageIds: numberArray(obj.source_message_ids ?? obj.sourceMessageIds),
|
|
709392
710110
|
targetEpisodeIds: stringArray5(obj.target_episode_ids ?? obj.targetEpisodeIds)
|
|
@@ -709395,8 +710113,8 @@ function parseTelegramReflectionExtraction(raw) {
|
|
|
709395
710113
|
const extractions = Array.isArray(parsed.extractions) ? parsed.extractions.map((item) => {
|
|
709396
710114
|
const obj = item;
|
|
709397
710115
|
return {
|
|
709398
|
-
kind:
|
|
709399
|
-
text:
|
|
710116
|
+
kind: clean6(obj.kind, 60) || "fact",
|
|
710117
|
+
text: clean6(obj.text, 1e3),
|
|
709400
710118
|
confidence: clampConfidence(obj.confidence),
|
|
709401
710119
|
sourceMessageIds: numberArray(obj.source_message_ids ?? obj.sourceMessageIds),
|
|
709402
710120
|
targetEpisodeIds: stringArray5(obj.target_episode_ids ?? obj.targetEpisodeIds),
|
|
@@ -709406,30 +710124,30 @@ function parseTelegramReflectionExtraction(raw) {
|
|
|
709406
710124
|
const links2 = Array.isArray(parsed.links) ? parsed.links.map((item) => {
|
|
709407
710125
|
const obj = item;
|
|
709408
710126
|
return {
|
|
709409
|
-
relation:
|
|
709410
|
-
srcNodeText:
|
|
709411
|
-
dstNodeText:
|
|
710127
|
+
relation: clean6(obj.relation, 60) || "related_to",
|
|
710128
|
+
srcNodeText: clean6(obj.src_node_text ?? obj.srcNodeText, 180),
|
|
710129
|
+
dstNodeText: clean6(obj.dst_node_text ?? obj.dstNodeText, 180),
|
|
709412
710130
|
confidence: clampConfidence(obj.confidence),
|
|
709413
|
-
fact:
|
|
710131
|
+
fact: clean6(obj.fact, 500),
|
|
709414
710132
|
sourceMessageIds: numberArray(obj.source_message_ids ?? obj.sourceMessageIds),
|
|
709415
710133
|
targetEpisodeIds: stringArray5(obj.target_episode_ids ?? obj.targetEpisodeIds)
|
|
709416
710134
|
};
|
|
709417
710135
|
}).filter((item) => item.srcNodeText && item.dstNodeText) : [];
|
|
709418
710136
|
const followups = Array.isArray(parsed.followups) ? parsed.followups.map((item) => {
|
|
709419
710137
|
const obj = item;
|
|
709420
|
-
const target =
|
|
710138
|
+
const target = clean6(obj.target, 40);
|
|
709421
710139
|
const replyTo = Number(obj.reply_to_message_id ?? obj.replyToMessageId);
|
|
709422
710140
|
const normalizedTarget = target === "private_dm" ? "private_dm" : target === "same_group" ? "same_group" : "none";
|
|
709423
710141
|
return {
|
|
709424
710142
|
target: normalizedTarget,
|
|
709425
|
-
text:
|
|
710143
|
+
text: clean6(obj.text, 700),
|
|
709426
710144
|
replyToMessageId: Number.isFinite(replyTo) ? Math.trunc(replyTo) : null,
|
|
709427
|
-
rationale:
|
|
710145
|
+
rationale: clean6(obj.rationale, 400),
|
|
709428
710146
|
confidence: clampConfidence(obj.confidence)
|
|
709429
710147
|
};
|
|
709430
710148
|
}) : [];
|
|
709431
710149
|
return {
|
|
709432
|
-
artifactTitle:
|
|
710150
|
+
artifactTitle: clean6(parsed.artifact_title ?? parsed.artifactTitle, 140) || "Telegram reflection",
|
|
709433
710151
|
tags,
|
|
709434
710152
|
summaries,
|
|
709435
710153
|
titles,
|
|
@@ -709485,7 +710203,7 @@ function allowedRelation(value2) {
|
|
|
709485
710203
|
return relations.includes(value2) ? value2 : "related_to";
|
|
709486
710204
|
}
|
|
709487
710205
|
function nodeText(prefix, value2) {
|
|
709488
|
-
return `${prefix}:${
|
|
710206
|
+
return `${prefix}:${clean6(value2, 180).toLowerCase()}`;
|
|
709489
710207
|
}
|
|
709490
710208
|
function firstSourceEpisode(itemEpisodeIds, fallback) {
|
|
709491
710209
|
return itemEpisodeIds[0] || fallback;
|
|
@@ -709651,8 +710369,8 @@ ${summary.text}`,
|
|
|
709651
710369
|
graphEdges++;
|
|
709652
710370
|
}
|
|
709653
710371
|
for (const link of extraction.links) {
|
|
709654
|
-
const src2 = graph.upsertNode({ text:
|
|
709655
|
-
const dst = graph.upsertNode({ text:
|
|
710372
|
+
const src2 = graph.upsertNode({ text: clean6(link.srcNodeText, 180), nodeType: "concept" });
|
|
710373
|
+
const dst = graph.upsertNode({ text: clean6(link.dstNodeText, 180), nodeType: "concept" });
|
|
709656
710374
|
graphNodes += 2;
|
|
709657
710375
|
graph.addEdge({
|
|
709658
710376
|
srcId: src2,
|
|
@@ -709716,17 +710434,17 @@ function hashTelegramSocialId(parts) {
|
|
|
709716
710434
|
}
|
|
709717
710435
|
function cleanUsername(value2) {
|
|
709718
710436
|
if (typeof value2 !== "string") return void 0;
|
|
709719
|
-
const
|
|
709720
|
-
return
|
|
710437
|
+
const clean7 = value2.trim().replace(/^@/, "");
|
|
710438
|
+
return clean7 ? clean7.slice(0, 80) : void 0;
|
|
709721
710439
|
}
|
|
709722
710440
|
function compactOptional(value2, max) {
|
|
709723
|
-
const
|
|
709724
|
-
return
|
|
710441
|
+
const clean7 = compact3(value2, max);
|
|
710442
|
+
return clean7 || void 0;
|
|
709725
710443
|
}
|
|
709726
710444
|
function compact3(value2, max) {
|
|
709727
710445
|
if (value2 === void 0 || value2 === null) return "";
|
|
709728
|
-
const
|
|
709729
|
-
return
|
|
710446
|
+
const clean7 = String(value2).replace(/\s+/g, " ").trim();
|
|
710447
|
+
return clean7.length > max ? `${clean7.slice(0, Math.max(0, max - 3)).trimEnd()}...` : clean7;
|
|
709730
710448
|
}
|
|
709731
710449
|
function jsonLine(value2, max) {
|
|
709732
710450
|
return JSON.stringify(compact3(value2, max));
|
|
@@ -710805,9 +711523,9 @@ function telegramMediaContextEvidenceTools(mediaContext) {
|
|
|
710805
711523
|
}
|
|
710806
711524
|
function cleanTelegramDecisionNote(value2, maxLength = 260) {
|
|
710807
711525
|
if (typeof value2 !== "string") return void 0;
|
|
710808
|
-
const
|
|
710809
|
-
if (!
|
|
710810
|
-
return
|
|
711526
|
+
const clean7 = stripTelegramHiddenThinking(value2).replace(/\s+/g, " ").trim();
|
|
711527
|
+
if (!clean7) return void 0;
|
|
711528
|
+
return clean7.length > maxLength ? `${clean7.slice(0, Math.max(0, maxLength - 3)).trimEnd()}...` : clean7;
|
|
710811
711529
|
}
|
|
710812
711530
|
function telegramDecisionNote(parsed, keys, nestedKeys = ["internal_notes", "internalNotes", "notes"]) {
|
|
710813
711531
|
for (const key of keys) {
|
|
@@ -710876,14 +711594,14 @@ function parseTelegramReplyPreferenceUpdate(parsed) {
|
|
|
710876
711594
|
}
|
|
710877
711595
|
function uniqueTelegramJsonCandidates(candidates) {
|
|
710878
711596
|
const seen = /* @__PURE__ */ new Set();
|
|
710879
|
-
const
|
|
711597
|
+
const unique5 = [];
|
|
710880
711598
|
for (const candidate of candidates) {
|
|
710881
|
-
const
|
|
710882
|
-
if (!
|
|
710883
|
-
seen.add(
|
|
710884
|
-
|
|
711599
|
+
const clean7 = candidate.trim();
|
|
711600
|
+
if (!clean7 || seen.has(clean7)) continue;
|
|
711601
|
+
seen.add(clean7);
|
|
711602
|
+
unique5.push(clean7);
|
|
710885
711603
|
}
|
|
710886
|
-
return
|
|
711604
|
+
return unique5;
|
|
710887
711605
|
}
|
|
710888
711606
|
function extractBalancedTelegramJsonObjects(text2) {
|
|
710889
711607
|
const objects = [];
|
|
@@ -710974,9 +711692,9 @@ function telegramDecisionOutputHasDanglingJson(text2) {
|
|
|
710974
711692
|
return depth > 0;
|
|
710975
711693
|
}
|
|
710976
711694
|
function telegramRouterRawPreview(text2, maxLength = 320) {
|
|
710977
|
-
const
|
|
710978
|
-
if (!
|
|
710979
|
-
return
|
|
711695
|
+
const clean7 = stripTelegramHiddenThinking(text2).replace(/\s+/g, " ").trim();
|
|
711696
|
+
if (!clean7) return void 0;
|
|
711697
|
+
return clean7.length > maxLength ? `${clean7.slice(0, Math.max(0, maxLength - 3)).trimEnd()}...` : clean7;
|
|
710980
711698
|
}
|
|
710981
711699
|
function telegramDecisionRecoverableFlag(text2) {
|
|
710982
711700
|
for (const jsonText of telegramDecisionJsonCandidates(text2)) {
|
|
@@ -711763,15 +712481,15 @@ function stripTelegramStuckSelfTalk(text2) {
|
|
|
711763
712481
|
return kept.join("\n\n");
|
|
711764
712482
|
}
|
|
711765
712483
|
function cleanTelegramVisibleReply(text2, options2 = {}) {
|
|
711766
|
-
const
|
|
712484
|
+
const clean7 = normalizeTelegramOutboundLinks(
|
|
711767
712485
|
stripTelegramHiddenThinking(text2)
|
|
711768
712486
|
).trim();
|
|
711769
|
-
if (!
|
|
711770
|
-
if (options2.suppressPotentialNoReplyPrefix && isTelegramPotentialNoReplyPrefix(
|
|
712487
|
+
if (!clean7) return "";
|
|
712488
|
+
if (options2.suppressPotentialNoReplyPrefix && isTelegramPotentialNoReplyPrefix(clean7))
|
|
711771
712489
|
return "";
|
|
711772
|
-
if (isTelegramInternalControlText(
|
|
711773
|
-
if (isTelegramInternalStatusText(
|
|
711774
|
-
const filtered = stripTelegramStuckSelfTalk(
|
|
712490
|
+
if (isTelegramInternalControlText(clean7)) return "";
|
|
712491
|
+
if (isTelegramInternalStatusText(clean7)) return "";
|
|
712492
|
+
const filtered = stripTelegramStuckSelfTalk(clean7).trim();
|
|
711775
712493
|
if (!filtered) return "";
|
|
711776
712494
|
return dedupeTelegramVisibleReply(filtered);
|
|
711777
712495
|
}
|
|
@@ -711780,12 +712498,12 @@ function dedupeTelegramVisibleReply(text2) {
|
|
|
711780
712498
|
const seenParagraphs = /* @__PURE__ */ new Set();
|
|
711781
712499
|
const collapsedParagraphs = [];
|
|
711782
712500
|
for (const paragraph of paragraphs) {
|
|
711783
|
-
const
|
|
711784
|
-
if (!
|
|
711785
|
-
const key = compactTelegramVisibleText(
|
|
712501
|
+
const clean7 = paragraph.trim();
|
|
712502
|
+
if (!clean7) continue;
|
|
712503
|
+
const key = compactTelegramVisibleText(clean7).toLowerCase();
|
|
711786
712504
|
if (seenParagraphs.has(key)) continue;
|
|
711787
712505
|
seenParagraphs.add(key);
|
|
711788
|
-
collapsedParagraphs.push(
|
|
712506
|
+
collapsedParagraphs.push(clean7);
|
|
711789
712507
|
}
|
|
711790
712508
|
const paragraphCollapsed = collapsedParagraphs.join("\n\n");
|
|
711791
712509
|
const sentenceLike = paragraphCollapsed.match(/[^.!?]+[.!?]+|[^.!?]+$/g);
|
|
@@ -711876,10 +712594,10 @@ function telegramHistoryTime(entry) {
|
|
|
711876
712594
|
});
|
|
711877
712595
|
}
|
|
711878
712596
|
function formatTelegramIdentitySignals(signals) {
|
|
711879
|
-
const
|
|
712597
|
+
const unique5 = [
|
|
711880
712598
|
...new Set(signals.map((signal) => signal.trim()).filter(Boolean))
|
|
711881
712599
|
];
|
|
711882
|
-
return
|
|
712600
|
+
return unique5.length > 0 ? unique5.join(", ") : "none";
|
|
711883
712601
|
}
|
|
711884
712602
|
function summarizeTelegramMessageAttachments(msg) {
|
|
711885
712603
|
const parts = [];
|
|
@@ -712094,19 +712812,19 @@ function trimTelegramAdminPanelLines(lines, max = 80) {
|
|
|
712094
712812
|
if (lines.length > max) lines.splice(0, lines.length - max);
|
|
712095
712813
|
}
|
|
712096
712814
|
function pushTelegramAdminPanelLine(state, page2, line) {
|
|
712097
|
-
const
|
|
712098
|
-
if (!
|
|
712815
|
+
const clean7 = stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim();
|
|
712816
|
+
if (!clean7) return;
|
|
712099
712817
|
const target = page2 === "tools" ? state.toolLines : page2 === "logs" ? state.logLines : state.mutationLines;
|
|
712100
|
-
if (target[target.length - 1] !==
|
|
712818
|
+
if (target[target.length - 1] !== clean7) target.push(clean7);
|
|
712101
712819
|
trimTelegramAdminPanelLines(target);
|
|
712102
712820
|
state.updatedAt = Date.now();
|
|
712103
712821
|
if (state.activePage !== page2) state.dirtyPages[page2] = true;
|
|
712104
712822
|
}
|
|
712105
712823
|
function pushTelegramAdminPanelMutationLine(state, line) {
|
|
712106
|
-
const
|
|
712107
|
-
if (!
|
|
712108
|
-
if (state.mutationLines[state.mutationLines.length - 1] !==
|
|
712109
|
-
state.mutationLines.push(
|
|
712824
|
+
const clean7 = stripTelegramHiddenThinking(line).replace(/\s+/g, " ").trim();
|
|
712825
|
+
if (!clean7) return;
|
|
712826
|
+
if (state.mutationLines[state.mutationLines.length - 1] !== clean7)
|
|
712827
|
+
state.mutationLines.push(clean7);
|
|
712110
712828
|
trimTelegramAdminPanelLines(state.mutationLines);
|
|
712111
712829
|
state.updatedAt = Date.now();
|
|
712112
712830
|
if (state.activePage !== "logs") state.dirtyPages.logs = true;
|
|
@@ -712367,12 +713085,12 @@ function buildTelegramHelpHTML(scope, maxPublicCommands = 24) {
|
|
|
712367
713085
|
...commands.flatMap((cmd) => cmd.signatures)
|
|
712368
713086
|
];
|
|
712369
713087
|
const seen = /* @__PURE__ */ new Set();
|
|
712370
|
-
const
|
|
713088
|
+
const unique5 = signatures.filter((sig) => {
|
|
712371
713089
|
if (seen.has(sig.signature)) return false;
|
|
712372
713090
|
seen.add(sig.signature);
|
|
712373
713091
|
return true;
|
|
712374
713092
|
});
|
|
712375
|
-
const visible = scope === "public" ?
|
|
713093
|
+
const visible = scope === "public" ? unique5.slice(0, maxPublicCommands) : unique5;
|
|
712376
713094
|
const lines = [
|
|
712377
713095
|
`<b>Commands (${scope === "admin" ? "admin full scope" : "public secure scope"})</b>`,
|
|
712378
713096
|
"",
|
|
@@ -712380,7 +713098,7 @@ function buildTelegramHelpHTML(scope, maxPublicCommands = 24) {
|
|
|
712380
713098
|
(sig) => `<code>${escapeTelegramHTML(sig.signature)}</code> - ${escapeTelegramHTML(sig.description)}`
|
|
712381
713099
|
)
|
|
712382
713100
|
];
|
|
712383
|
-
if (scope === "public" &&
|
|
713101
|
+
if (scope === "public" && unique5.length > visible.length) {
|
|
712384
713102
|
lines.push("");
|
|
712385
713103
|
lines.push(
|
|
712386
713104
|
`Public scope truncated to ${visible.length} safe commands. Authenticate as admin for full command help.`
|
|
@@ -712811,15 +713529,15 @@ function telegramImageMime(media) {
|
|
|
712811
713529
|
return "image/jpeg";
|
|
712812
713530
|
}
|
|
712813
713531
|
function appendMediaContextBlock(description, block) {
|
|
712814
|
-
const
|
|
712815
|
-
if (!
|
|
713532
|
+
const clean7 = block.trim();
|
|
713533
|
+
if (!clean7) return description;
|
|
712816
713534
|
if (description.endsWith("]"))
|
|
712817
713535
|
return `${description.slice(0, -1)}
|
|
712818
713536
|
|
|
712819
|
-
${
|
|
713537
|
+
${clean7}]`;
|
|
712820
713538
|
return `${description}
|
|
712821
713539
|
|
|
712822
|
-
${
|
|
713540
|
+
${clean7}`;
|
|
712823
713541
|
}
|
|
712824
713542
|
function telegramCachedMediaIsImage(entry) {
|
|
712825
713543
|
if (entry.mediaType === "photo") return true;
|
|
@@ -712972,10 +713690,10 @@ function stripTelegramImagePayloadMarkers(value2) {
|
|
|
712972
713690
|
);
|
|
712973
713691
|
}
|
|
712974
713692
|
function truncateTelegramStageOutput(value2, maxChars = 3500) {
|
|
712975
|
-
const
|
|
712976
|
-
if (
|
|
712977
|
-
return `${
|
|
712978
|
-
... (${
|
|
713693
|
+
const clean7 = stripTelegramImagePayloadMarkers(value2).replace(/\n{3,}/g, "\n\n").trim();
|
|
713694
|
+
if (clean7.length <= maxChars) return clean7;
|
|
713695
|
+
return `${clean7.slice(0, maxChars).trimEnd()}
|
|
713696
|
+
... (${clean7.length - maxChars} more chars omitted)`;
|
|
712979
713697
|
}
|
|
712980
713698
|
function telegramTextExtractionSignal(text2) {
|
|
712981
713699
|
const lines = text2.split(/\r?\n/).map((line) => line.trim()).filter(Boolean);
|
|
@@ -716340,14 +717058,14 @@ Model: <code>${escapeTelegramHTML(model.id)}</code>`
|
|
|
716340
717058
|
return reply;
|
|
716341
717059
|
}
|
|
716342
717060
|
quoteTelegramContextBlock(text2, maxLength = 1800) {
|
|
716343
|
-
const
|
|
717061
|
+
const clean7 = normalizeTelegramOutboundLinks(
|
|
716344
717062
|
stripTelegramHiddenThinking(text2)
|
|
716345
717063
|
).trim();
|
|
716346
|
-
const clipped =
|
|
716347
|
-
|
|
717064
|
+
const clipped = clean7.length > maxLength ? truncateTelegramUrlSafe(
|
|
717065
|
+
clean7,
|
|
716348
717066
|
maxLength,
|
|
716349
717067
|
"\n[reply context truncated]"
|
|
716350
|
-
) :
|
|
717068
|
+
) : clean7;
|
|
716351
717069
|
return clipped.split(/\r?\n/).map((line) => `> ${line}`).join("\n");
|
|
716352
717070
|
}
|
|
716353
717071
|
buildTelegramCurrentReplyContext(sessionKey, msg) {
|
|
@@ -718084,14 +718802,14 @@ ${mediaContext}` : ""
|
|
|
718084
718802
|
this.saveTelegramConversationState(sessionKey);
|
|
718085
718803
|
}
|
|
718086
718804
|
recordTelegramAssistantMessage(msg, text2, mode, options2 = {}) {
|
|
718087
|
-
const
|
|
718805
|
+
const clean7 = normalizeTelegramOutboundLinks(
|
|
718088
718806
|
stripTelegramHiddenThinking(text2)
|
|
718089
718807
|
).trim();
|
|
718090
|
-
if (!
|
|
718808
|
+
if (!clean7) return;
|
|
718091
718809
|
const sessionKey = this.sessionKeyForMessage(msg);
|
|
718092
718810
|
const entry = {
|
|
718093
718811
|
role: "assistant",
|
|
718094
|
-
text:
|
|
718812
|
+
text: clean7,
|
|
718095
718813
|
mode,
|
|
718096
718814
|
chatId: msg.chatId,
|
|
718097
718815
|
speaker: this.state.botUsername ? `@${this.state.botUsername}` : "Assistant",
|
|
@@ -718109,7 +718827,7 @@ ${mediaContext}` : ""
|
|
|
718109
718827
|
}
|
|
718110
718828
|
this.persistTelegramAssistantMessage(
|
|
718111
718829
|
msg,
|
|
718112
|
-
|
|
718830
|
+
clean7,
|
|
718113
718831
|
options2.messageId ?? void 0,
|
|
718114
718832
|
options2.replyToMessageId
|
|
718115
718833
|
);
|
|
@@ -718120,11 +718838,11 @@ ${mediaContext}` : ""
|
|
|
718120
718838
|
try {
|
|
718121
718839
|
updateScopedPersonality(this.telegramPersonalityScope(sessionKey, msg), {
|
|
718122
718840
|
speaker: entry.speaker || "Assistant",
|
|
718123
|
-
text:
|
|
718841
|
+
text: clean7,
|
|
718124
718842
|
role: "assistant",
|
|
718125
718843
|
mode,
|
|
718126
718844
|
ts: entry.ts,
|
|
718127
|
-
toneTags: inferTelegramToneTags(
|
|
718845
|
+
toneTags: inferTelegramToneTags(clean7)
|
|
718128
718846
|
});
|
|
718129
718847
|
} catch {
|
|
718130
718848
|
}
|
|
@@ -718471,9 +719189,9 @@ ${mediaContext}` : ""
|
|
|
718471
719189
|
for (const alias of [entry.username, entry.firstName, speaker].filter(
|
|
718472
719190
|
Boolean
|
|
718473
719191
|
)) {
|
|
718474
|
-
const
|
|
718475
|
-
if (
|
|
718476
|
-
userMemory.aliases.push(
|
|
719192
|
+
const clean7 = alias.replace(/^@/, "").trim();
|
|
719193
|
+
if (clean7 && !userMemory.aliases.includes(clean7))
|
|
719194
|
+
userMemory.aliases.push(clean7);
|
|
718477
719195
|
}
|
|
718478
719196
|
userMemory.aliases = userMemory.aliases.slice(0, 20);
|
|
718479
719197
|
userMemory.lastSeenTs = now2;
|
|
@@ -718575,15 +719293,15 @@ ${mediaContext}` : ""
|
|
|
718575
719293
|
return [...facts].slice(0, 8);
|
|
718576
719294
|
}
|
|
718577
719295
|
upsertTelegramAssociativeFact(facts, text2, entry, speaker, weight = 1) {
|
|
718578
|
-
const
|
|
718579
|
-
const key =
|
|
719296
|
+
const clean7 = stripTelegramHiddenThinking(text2 || "").replace(/\s+/g, " ").trim();
|
|
719297
|
+
const key = clean7.toLowerCase();
|
|
718580
719298
|
const now2 = entry.ts ?? Date.now();
|
|
718581
719299
|
let fact = facts.find((item) => item.text.toLowerCase() === key);
|
|
718582
719300
|
if (!fact) {
|
|
718583
719301
|
fact = {
|
|
718584
719302
|
id: createHash57("sha1").update(`${entry.chatId ?? ""}:${key}`).digest("hex").slice(0, 12),
|
|
718585
|
-
text:
|
|
718586
|
-
tags: telegramMemoryTags(
|
|
719303
|
+
text: clean7,
|
|
719304
|
+
tags: telegramMemoryTags(clean7, entry.mediaSummary),
|
|
718587
719305
|
speakers: [],
|
|
718588
719306
|
userIds: [],
|
|
718589
719307
|
usernames: [],
|
|
@@ -718608,7 +719326,7 @@ ${mediaContext}` : ""
|
|
|
718608
719326
|
if (entry.messageId && !fact.messageIds.includes(entry.messageId))
|
|
718609
719327
|
fact.messageIds.push(entry.messageId);
|
|
718610
719328
|
fact.messageIds = fact.messageIds.slice(-80);
|
|
718611
|
-
for (const tag of telegramMemoryTags(
|
|
719329
|
+
for (const tag of telegramMemoryTags(clean7, entry.mediaSummary)) {
|
|
718612
719330
|
if (!fact.tags.includes(tag)) fact.tags.push(tag);
|
|
718613
719331
|
}
|
|
718614
719332
|
fact.tags = fact.tags.slice(0, 16);
|
|
@@ -718631,8 +719349,8 @@ ${mediaContext}` : ""
|
|
|
718631
719349
|
/Telegram link integrity contract/
|
|
718632
719350
|
];
|
|
718633
719351
|
static isSyntheticMemoryText(text2) {
|
|
718634
|
-
const
|
|
718635
|
-
return _TelegramBridge.SYNTHETIC_MEMORY_PATTERNS.some((p2) => p2.test(
|
|
719352
|
+
const clean7 = String(text2 || "").replace(/\s+/g, " ").trim();
|
|
719353
|
+
return _TelegramBridge.SYNTHETIC_MEMORY_PATTERNS.some((p2) => p2.test(clean7));
|
|
718636
719354
|
}
|
|
718637
719355
|
updateTelegramMemoryCards(sessionKey, entry) {
|
|
718638
719356
|
const text2 = stripTelegramHiddenThinking(entry.text || "").replace(/\s+/g, " ").trim();
|
|
@@ -722508,26 +723226,26 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
722508
723226
|
}
|
|
722509
723227
|
buildTelegramContextExplorerPages(msg, subAgent, finalText) {
|
|
722510
723228
|
const prompt = subAgent.promptSnapshot;
|
|
722511
|
-
const
|
|
722512
|
-
if (!prompt && !
|
|
723229
|
+
const frame2 = subAgent.contextFrame;
|
|
723230
|
+
if (!prompt && !frame2) return [];
|
|
722513
723231
|
const pages = [];
|
|
722514
|
-
const sectionLines =
|
|
723232
|
+
const sectionLines = frame2?.sections.map(
|
|
722515
723233
|
(section) => `${section.order + 1}. ${section.label} (${section.tokenEstimate}t, ${section.charCount} chars, ${section.source})`
|
|
722516
723234
|
) ?? [];
|
|
722517
723235
|
const overview = [
|
|
722518
|
-
`Captured: ${
|
|
723236
|
+
`Captured: ${frame2?.capturedAt ?? prompt?.capturedAt ?? (/* @__PURE__ */ new Date()).toISOString()}`,
|
|
722519
723237
|
`Chat: ${msg.chatType}${msg.chatTitle ? ` "${msg.chatTitle}"` : ""}`,
|
|
722520
723238
|
`Sender: @${(prompt?.username ?? msg.username) || "telegram"} (id ${msg.fromUserId})`,
|
|
722521
723239
|
prompt ? `Model: ${prompt.model} (${prompt.modelTier})` : "",
|
|
722522
723240
|
prompt ? `Tool context: ${prompt.toolContext}; profile: ${prompt.profile}` : "",
|
|
722523
723241
|
prompt ? `Session: ${prompt.sessionKey}; runner state: ${prompt.sessionId}` : "",
|
|
722524
|
-
|
|
723242
|
+
frame2 ? `System prompt: ${frame2.sections.length} section(s), ${frame2.assembledCharCount} chars, ~${frame2.totalTokenEstimate} tokens` : "System prompt frame was not captured.",
|
|
722525
723243
|
subAgent.runnerTurns !== void 0 ? `Runner: completed=${String(subAgent.runnerCompleted)} turns=${subAgent.runnerTurns} tool_calls=${subAgent.runnerToolCalls ?? 0}` : "",
|
|
722526
723244
|
"",
|
|
722527
723245
|
"Presented order:",
|
|
722528
723246
|
...sectionLines.length > 0 ? sectionLines : ["No structured system sections captured."],
|
|
722529
|
-
...
|
|
722530
|
-
`user.message (${
|
|
723247
|
+
...frame2?.userMessage ? [
|
|
723248
|
+
`user.message (${frame2.userMessage.tokenEstimate}t, ${frame2.userMessage.charCount} chars, ${frame2.userMessage.source})`
|
|
722531
723249
|
] : ["user.context_argument", "user.task_prompt"],
|
|
722532
723250
|
"",
|
|
722533
723251
|
"Visible reply preview:",
|
|
@@ -722543,8 +723261,8 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
722543
723261
|
`chat_id=${String(msg.chatId)}`
|
|
722544
723262
|
]
|
|
722545
723263
|
});
|
|
722546
|
-
if (
|
|
722547
|
-
for (const section of
|
|
723264
|
+
if (frame2) {
|
|
723265
|
+
for (const section of frame2.sections) {
|
|
722548
723266
|
this.addTelegramContextExplorerPages(
|
|
722549
723267
|
pages,
|
|
722550
723268
|
`${section.order + 1}. system.${section.label}`,
|
|
@@ -722555,21 +723273,21 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
722555
723273
|
`label=${section.label}`,
|
|
722556
723274
|
`tokens~=${section.tokenEstimate}`,
|
|
722557
723275
|
`chars=${section.charCount}`,
|
|
722558
|
-
`kind=${
|
|
723276
|
+
`kind=${frame2.kind}`
|
|
722559
723277
|
]
|
|
722560
723278
|
);
|
|
722561
723279
|
}
|
|
722562
|
-
if (
|
|
723280
|
+
if (frame2.userMessage) {
|
|
722563
723281
|
this.addTelegramContextExplorerPages(
|
|
722564
723282
|
pages,
|
|
722565
723283
|
"user.message",
|
|
722566
|
-
|
|
722567
|
-
|
|
723284
|
+
frame2.userMessage.source,
|
|
723285
|
+
frame2.userMessage.content,
|
|
722568
723286
|
[
|
|
722569
723287
|
"role=user",
|
|
722570
723288
|
"runner_user_content_order=after system sections",
|
|
722571
|
-
`tokens~=${
|
|
722572
|
-
`chars=${
|
|
723289
|
+
`tokens~=${frame2.userMessage.tokenEstimate}`,
|
|
723290
|
+
`chars=${frame2.userMessage.charCount}`
|
|
722573
723291
|
]
|
|
722574
723292
|
);
|
|
722575
723293
|
}
|
|
@@ -722583,7 +723301,7 @@ ${signals || summary || "Canonical runner status reported completed."}`
|
|
|
722583
723301
|
);
|
|
722584
723302
|
}
|
|
722585
723303
|
if (prompt) {
|
|
722586
|
-
if (!
|
|
723304
|
+
if (!frame2?.userMessage) {
|
|
722587
723305
|
this.addTelegramContextExplorerPages(
|
|
722588
723306
|
pages,
|
|
722589
723307
|
"user.context_argument",
|
|
@@ -724085,14 +724803,14 @@ ${conversationStream}`
|
|
|
724085
724803
|
}
|
|
724086
724804
|
retainTelegramVisibleReplyDraft(subAgent, draft, streamToolNames = subAgent.currentStreamToolNames) {
|
|
724087
724805
|
if (subAgent.visibleReplyText) return;
|
|
724088
|
-
const
|
|
724089
|
-
if (!
|
|
724806
|
+
const clean7 = cleanTelegramVisibleReply(draft);
|
|
724807
|
+
if (!clean7) return;
|
|
724090
724808
|
const toolNames = [...streamToolNames];
|
|
724091
724809
|
const hasNonCompletionTool = toolNames.some(
|
|
724092
724810
|
(name10) => name10 !== "task_complete"
|
|
724093
724811
|
);
|
|
724094
724812
|
if (hasNonCompletionTool) return;
|
|
724095
|
-
subAgent.visibleReplyText =
|
|
724813
|
+
subAgent.visibleReplyText = clean7;
|
|
724096
724814
|
}
|
|
724097
724815
|
retainTelegramVisibleReplyFromCompletedStream(subAgent) {
|
|
724098
724816
|
this.retainTelegramVisibleReplyDraft(
|
|
@@ -726850,20 +727568,20 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
726850
727568
|
};
|
|
726851
727569
|
}
|
|
726852
727570
|
async deleteTelegramMessages(chatId, messageIds, currentMsg) {
|
|
726853
|
-
const
|
|
726854
|
-
if (
|
|
727571
|
+
const unique5 = [...new Set(messageIds)].filter((id2) => Number.isFinite(id2));
|
|
727572
|
+
if (unique5.length === 0)
|
|
726855
727573
|
throw new Error(
|
|
726856
727574
|
"deleteTelegramMessages requires at least one message id."
|
|
726857
727575
|
);
|
|
726858
727576
|
await this.assertTelegramBotRightsForAction(
|
|
726859
727577
|
"delete_messages",
|
|
726860
727578
|
chatId,
|
|
726861
|
-
|
|
727579
|
+
unique5,
|
|
726862
727580
|
currentMsg
|
|
726863
727581
|
);
|
|
726864
727582
|
const chunks = [];
|
|
726865
|
-
for (let idx = 0; idx <
|
|
726866
|
-
chunks.push(
|
|
727583
|
+
for (let idx = 0; idx < unique5.length; idx += 100)
|
|
727584
|
+
chunks.push(unique5.slice(idx, idx + 100));
|
|
726867
727585
|
const results = [];
|
|
726868
727586
|
for (const chunk of chunks) {
|
|
726869
727587
|
const result = await this.apiCall("deleteMessages", {
|
|
@@ -726881,9 +727599,9 @@ Scoped workspace: ${scopedRoot}`,
|
|
|
726881
727599
|
telegram_method: "deleteMessages",
|
|
726882
727600
|
ok: true,
|
|
726883
727601
|
chat_id: chatId,
|
|
726884
|
-
message_ids:
|
|
727602
|
+
message_ids: unique5,
|
|
726885
727603
|
batches: results,
|
|
726886
|
-
bot_rights_checked: !this.telegramTargetLooksPrivate(chatId, currentMsg) && !
|
|
727604
|
+
bot_rights_checked: !this.telegramTargetLooksPrivate(chatId, currentMsg) && !unique5.every((id2) => this.isKnownAssistantTelegramMessage(chatId, id2)),
|
|
726887
727605
|
policy_scope: this.telegramToolPolicy.chatOverrides?.[String(chatId)] ? "chat" : "global/default"
|
|
726888
727606
|
};
|
|
726889
727607
|
}
|
|
@@ -729183,13 +729901,13 @@ Content-Type: ${mimeForPath(pathOrFileId, field === "photo" ? "image" : "video")
|
|
|
729183
729901
|
* Telegram accepts @botusername in chat_id for the supported bot-to-bot subset.
|
|
729184
729902
|
*/
|
|
729185
729903
|
async sendMessageToBot(username, text2) {
|
|
729186
|
-
const
|
|
729187
|
-
if (!/^[A-Za-z0-9_]{5,32}$/.test(
|
|
729904
|
+
const clean7 = username.trim().replace(/^@/, "");
|
|
729905
|
+
if (!/^[A-Za-z0-9_]{5,32}$/.test(clean7)) {
|
|
729188
729906
|
throw new Error(
|
|
729189
729907
|
"Expected a Telegram bot username (5-32 chars, letters/numbers/underscore)."
|
|
729190
729908
|
);
|
|
729191
729909
|
}
|
|
729192
|
-
return this.sendMessage(`@${
|
|
729910
|
+
return this.sendMessage(`@${clean7}`, text2);
|
|
729193
729911
|
}
|
|
729194
729912
|
hydrateTelegramCommandMap(commands) {
|
|
729195
729913
|
for (const cmd of commands) {
|
|
@@ -729832,8 +730550,8 @@ function gibberishTokenPenalty(s2) {
|
|
|
729832
730550
|
const tokens = s2.trim().split(/\s+/).filter(Boolean);
|
|
729833
730551
|
if (tokens.length < 2) return 0;
|
|
729834
730552
|
let penalty = 0;
|
|
729835
|
-
const
|
|
729836
|
-
const uniqueRatio =
|
|
730553
|
+
const unique5 = new Set(tokens.map((t2) => t2.toLowerCase()));
|
|
730554
|
+
const uniqueRatio = unique5.size / tokens.length;
|
|
729837
730555
|
if (tokens.length >= 4 && uniqueRatio <= 0.5) {
|
|
729838
730556
|
penalty += Math.min(1, (0.5 - uniqueRatio) * 2 + 0.5);
|
|
729839
730557
|
}
|
|
@@ -732242,24 +732960,24 @@ function stripMappedPrefix(ip) {
|
|
|
732242
732960
|
}
|
|
732243
732961
|
function isLoopbackIP(ip) {
|
|
732244
732962
|
if (!ip) return false;
|
|
732245
|
-
const
|
|
732246
|
-
if (
|
|
732247
|
-
if (/^127\./.test(
|
|
732963
|
+
const clean7 = stripMappedPrefix(ip);
|
|
732964
|
+
if (clean7 === "::1") return true;
|
|
732965
|
+
if (/^127\./.test(clean7)) return true;
|
|
732248
732966
|
return false;
|
|
732249
732967
|
}
|
|
732250
732968
|
function isPrivateIP(ip) {
|
|
732251
732969
|
if (!ip) return false;
|
|
732252
|
-
const
|
|
732253
|
-
if (/^10\./.test(
|
|
732254
|
-
if (/^192\.168\./.test(
|
|
732255
|
-
const m2 = /^172\.(\d{1,3})\./.exec(
|
|
732970
|
+
const clean7 = stripMappedPrefix(ip);
|
|
732971
|
+
if (/^10\./.test(clean7)) return true;
|
|
732972
|
+
if (/^192\.168\./.test(clean7)) return true;
|
|
732973
|
+
const m2 = /^172\.(\d{1,3})\./.exec(clean7);
|
|
732256
732974
|
if (m2) {
|
|
732257
732975
|
const second3 = parseInt(m2[1], 10);
|
|
732258
732976
|
if (second3 >= 16 && second3 <= 31) return true;
|
|
732259
732977
|
}
|
|
732260
|
-
if (/^169\.254\./.test(
|
|
732261
|
-
if (/^f[cd][0-9a-f]{2}:/i.test(
|
|
732262
|
-
if (/^fe[89ab][0-9a-f]:/i.test(
|
|
732978
|
+
if (/^169\.254\./.test(clean7)) return true;
|
|
732979
|
+
if (/^f[cd][0-9a-f]{2}:/i.test(clean7)) return true;
|
|
732980
|
+
if (/^fe[89ab][0-9a-f]:/i.test(clean7)) return true;
|
|
732263
732981
|
return false;
|
|
732264
732982
|
}
|
|
732265
732983
|
function isAllowedIP(ip, mode) {
|
|
@@ -751954,9 +752672,9 @@ async function runEmbeddingTask(modality, episodeId, taskId, opts) {
|
|
|
751954
752672
|
}
|
|
751955
752673
|
} catch {
|
|
751956
752674
|
}
|
|
751957
|
-
const
|
|
752675
|
+
const nodeId2 = graph.upsertNode({ text: ep.toolName || ep.modality, nodeType: modality === "visual" ? "person" : "entity", embedding: emb });
|
|
751958
752676
|
const rel = modality === "visual" ? "appears_in" : "related_to";
|
|
751959
|
-
graph.addEdge({ srcId:
|
|
752677
|
+
graph.addEdge({ srcId: nodeId2, dstId: nodeId2, relation: rel, fact: ep.content.slice(0, 80), modality: ep.modality, sourceEpisodeId: ep.id });
|
|
751960
752678
|
if (modality === "visual") {
|
|
751961
752679
|
try {
|
|
751962
752680
|
const recent = episodeStore.recent(200).filter((e2) => e2.modality === "text" && e2.toolName === "transcribe_file");
|
|
@@ -751992,8 +752710,8 @@ async function runEmbeddingTask(modality, episodeId, taskId, opts) {
|
|
|
751992
752710
|
} catch {
|
|
751993
752711
|
}
|
|
751994
752712
|
if (ok3) {
|
|
751995
|
-
graph.addEdge({ srcId: personId, dstId:
|
|
751996
|
-
graph.addEdge({ srcId: personId, dstId:
|
|
752713
|
+
graph.addEdge({ srcId: personId, dstId: nodeId2, relation: "co_occurred_with", fact: ep.content.slice(0, 80), modality: ep.modality, sourceEpisodeId: ep.id });
|
|
752714
|
+
graph.addEdge({ srcId: personId, dstId: nodeId2, relation: "appears_in", fact: ep.content.slice(0, 80), modality: ep.modality, sourceEpisodeId: ep.id });
|
|
751997
752715
|
}
|
|
751998
752716
|
}
|
|
751999
752717
|
} catch {
|
|
@@ -767356,6 +768074,10 @@ async function startInteractive(config, repoPath2) {
|
|
|
767356
768074
|
} catch {
|
|
767357
768075
|
}
|
|
767358
768076
|
if (_shellToolRef) _shellToolRef.killAll();
|
|
768077
|
+
try {
|
|
768078
|
+
historyAbort.abort();
|
|
768079
|
+
} catch {
|
|
768080
|
+
}
|
|
767359
768081
|
idleMemoryMaintenance?.stop();
|
|
767360
768082
|
killAllFullSubAgents();
|
|
767361
768083
|
taskManager.stopAll();
|
|
@@ -767507,10 +768229,40 @@ async function startInteractive(config, repoPath2) {
|
|
|
767507
768229
|
const statusBar = new StatusBar();
|
|
767508
768230
|
statusBar.setVersion(version5);
|
|
767509
768231
|
const idleActionTree = new ActionTreeStore();
|
|
767510
|
-
|
|
767511
|
-
|
|
767512
|
-
|
|
767513
|
-
|
|
768232
|
+
const historyAbort = new AbortController();
|
|
768233
|
+
const historyScanner = createHistoryScanner(repoRoot);
|
|
768234
|
+
idleActionTree.beginHistoricalLoad(repoRoot);
|
|
768235
|
+
let historyScanned = 0;
|
|
768236
|
+
let historyTotal = 0;
|
|
768237
|
+
void (async () => {
|
|
768238
|
+
try {
|
|
768239
|
+
for await (const batch2 of historyScanner.scan({
|
|
768240
|
+
signal: historyAbort.signal,
|
|
768241
|
+
batchSize: 64,
|
|
768242
|
+
onProgress: (progress) => {
|
|
768243
|
+
historyScanned = progress.filesScanned;
|
|
768244
|
+
historyTotal = progress.filesTotal;
|
|
768245
|
+
if (idleActionTree.isHistoricalLoading) {
|
|
768246
|
+
idleActionTree.appendHistoricalRuns([], historyScanned, historyTotal);
|
|
768247
|
+
if (statusBar.isActive && statusBar.contentPresentation === "tree") {
|
|
768248
|
+
statusBar.refreshActionTree();
|
|
768249
|
+
}
|
|
768250
|
+
}
|
|
768251
|
+
}
|
|
768252
|
+
})) {
|
|
768253
|
+
idleActionTree.appendHistoricalRuns(batch2, historyScanned, historyTotal);
|
|
768254
|
+
if (statusBar.isActive && statusBar.contentPresentation === "tree") {
|
|
768255
|
+
statusBar.refreshActionTree();
|
|
768256
|
+
}
|
|
768257
|
+
}
|
|
768258
|
+
} catch {
|
|
768259
|
+
} finally {
|
|
768260
|
+
idleActionTree.endHistoricalLoad();
|
|
768261
|
+
if (statusBar.isActive && statusBar.contentPresentation === "tree") {
|
|
768262
|
+
statusBar.refreshActionTree();
|
|
768263
|
+
}
|
|
768264
|
+
}
|
|
768265
|
+
})();
|
|
767514
768266
|
statusBar.setActionTreeRenderer(
|
|
767515
768267
|
(width) => idleActionTree.render(width),
|
|
767516
768268
|
(row2) => {
|
|
@@ -770483,12 +771235,12 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
770483
771235
|
return `Skill invoked: ${result.name}`;
|
|
770484
771236
|
}
|
|
770485
771237
|
const raw = captured.join("");
|
|
770486
|
-
const
|
|
771238
|
+
const clean7 = raw.replace(
|
|
770487
771239
|
/\x1B(?:\[[\d;?]*[ -/]*[@-~]|\][^\x07\x1B]*(?:\x07|\x1B\\)?|[@-Z\\-_])/g,
|
|
770488
771240
|
""
|
|
770489
771241
|
).replace(/\x1B/g, "").replace(/[─━│┃┌┐└┘├┤┬┴┼╔╗╚╝╠╣╦╩╬⎿⎾▕▏⏐]/g, "").replace(/\n{3,}/g, "\n\n").trim();
|
|
770490
|
-
if (!
|
|
770491
|
-
return
|
|
771242
|
+
if (!clean7) return null;
|
|
771243
|
+
return clean7.length > 3900 ? clean7.slice(0, 3900) + "\n..." : clean7;
|
|
770492
771244
|
} catch (err) {
|
|
770493
771245
|
process.stdout.write = origWrite;
|
|
770494
771246
|
throw err;
|
|
@@ -774136,8 +774888,8 @@ async function runConsole(task, config, repoPath2) {
|
|
|
774136
774888
|
}
|
|
774137
774889
|
},
|
|
774138
774890
|
onAssistantText: (text2) => {
|
|
774139
|
-
const
|
|
774140
|
-
if (
|
|
774891
|
+
const clean7 = sanitizeAgentOutputForUser(text2).trim();
|
|
774892
|
+
if (clean7) emit2(`💬 ${clean7.replace(/\n/g, "\n ")}`);
|
|
774141
774893
|
},
|
|
774142
774894
|
onRunResult: (result) => {
|
|
774143
774895
|
runnerResult = {
|