omnius 1.0.532 โ 1.0.533
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 +626 -78
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -439258,14 +439258,14 @@ ${lanes.join("\n")}
|
|
|
439258
439258
|
}
|
|
439259
439259
|
if (diagnostic.relatedInformation) {
|
|
439260
439260
|
output += host.getNewLine();
|
|
439261
|
-
for (const { file, start: start2, length: length22, messageText } of diagnostic.relatedInformation) {
|
|
439261
|
+
for (const { file, start: start2, length: length22, messageText: messageText2 } of diagnostic.relatedInformation) {
|
|
439262
439262
|
if (file) {
|
|
439263
439263
|
output += host.getNewLine();
|
|
439264
439264
|
output += halfIndent + formatLocation(file, start2, host);
|
|
439265
439265
|
output += formatCodeSpan(file, start2, length22, indent2, "\x1B[96m", host);
|
|
439266
439266
|
}
|
|
439267
439267
|
output += host.getNewLine();
|
|
439268
|
-
output += indent2 + flattenDiagnosticMessageText(
|
|
439268
|
+
output += indent2 + flattenDiagnosticMessageText(messageText2, host.getNewLine());
|
|
439269
439269
|
}
|
|
439270
439270
|
}
|
|
439271
439271
|
output += host.getNewLine();
|
|
@@ -473931,8 +473931,8 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
|
|
|
473931
473931
|
}
|
|
473932
473932
|
}
|
|
473933
473933
|
}
|
|
473934
|
-
function tryGetConstraintFromDiagnosticMessage(
|
|
473935
|
-
const [, constraint] = flattenDiagnosticMessageText(
|
|
473934
|
+
function tryGetConstraintFromDiagnosticMessage(messageText2) {
|
|
473935
|
+
const [, constraint] = flattenDiagnosticMessageText(messageText2, "\n", 0).match(/`extends (.*)`/) || [];
|
|
473936
473936
|
return constraint;
|
|
473937
473937
|
}
|
|
473938
473938
|
function tryGetConstraintType(checker, node) {
|
|
@@ -475979,8 +475979,8 @@ ${newComment.split("\n").map((c9) => ` * ${c9}`).join("\n")}
|
|
|
475979
475979
|
operator === 38 || operator === 36 ? factory.createPrefixUnaryExpression(54, callExpression) : callExpression
|
|
475980
475980
|
);
|
|
475981
475981
|
}
|
|
475982
|
-
function getSuggestion(
|
|
475983
|
-
const [, suggestion] = flattenDiagnosticMessageText(
|
|
475982
|
+
function getSuggestion(messageText2) {
|
|
475983
|
+
const [, suggestion] = flattenDiagnosticMessageText(messageText2, "\n", 0).match(/'(.*)'/) || [];
|
|
475984
475984
|
return suggestion;
|
|
475985
475985
|
}
|
|
475986
475986
|
registerCodeFix({
|
|
@@ -541096,13 +541096,13 @@ Node text: ${this.#forgottenText}`;
|
|
|
541096
541096
|
return file == null ? void 0 : this._context.compilerFactory.getSourceFile(file, { markInProject: false });
|
|
541097
541097
|
}
|
|
541098
541098
|
getMessageText() {
|
|
541099
|
-
const
|
|
541100
|
-
if (typeof
|
|
541101
|
-
return
|
|
541099
|
+
const messageText2 = this._compilerObject.messageText;
|
|
541100
|
+
if (typeof messageText2 === "string")
|
|
541101
|
+
return messageText2;
|
|
541102
541102
|
if (this._context == null)
|
|
541103
|
-
return new DiagnosticMessageChain(
|
|
541103
|
+
return new DiagnosticMessageChain(messageText2);
|
|
541104
541104
|
else
|
|
541105
|
-
return this._context.compilerFactory.getDiagnosticMessageChain(
|
|
541105
|
+
return this._context.compilerFactory.getDiagnosticMessageChain(messageText2);
|
|
541106
541106
|
}
|
|
541107
541107
|
getLineNumber() {
|
|
541108
541108
|
const sourceFile = this.getSourceFile();
|
|
@@ -576749,6 +576749,50 @@ function collectMetadataReports(signals) {
|
|
|
576749
576749
|
forgettingReports: forgettingReports.length > 0 ? forgettingReports : void 0
|
|
576750
576750
|
};
|
|
576751
576751
|
}
|
|
576752
|
+
function signalIdentityKeys(signal) {
|
|
576753
|
+
return [
|
|
576754
|
+
signal.dedupeKey,
|
|
576755
|
+
signal.semanticKey,
|
|
576756
|
+
`${signal.kind}:${signal.id}`,
|
|
576757
|
+
signal.id,
|
|
576758
|
+
...signal.tags ?? []
|
|
576759
|
+
].flatMap((key) => {
|
|
576760
|
+
const clean5 = typeof key === "string" ? key.trim() : "";
|
|
576761
|
+
return clean5 ? [clean5] : [];
|
|
576762
|
+
});
|
|
576763
|
+
}
|
|
576764
|
+
function choosePreferredSignal(a2, b) {
|
|
576765
|
+
const pa = a2.priority ?? 0;
|
|
576766
|
+
const pb = b.priority ?? 0;
|
|
576767
|
+
if (pa !== pb)
|
|
576768
|
+
return pa > pb ? a2 : b;
|
|
576769
|
+
const ta = a2.createdTurn ?? 0;
|
|
576770
|
+
const tb = b.createdTurn ?? 0;
|
|
576771
|
+
if (ta !== tb)
|
|
576772
|
+
return ta > tb ? a2 : b;
|
|
576773
|
+
return a2.sequence > b.sequence ? a2 : b;
|
|
576774
|
+
}
|
|
576775
|
+
function sortSignals(a2, b) {
|
|
576776
|
+
const pa = a2.priority ?? 0;
|
|
576777
|
+
const pb = b.priority ?? 0;
|
|
576778
|
+
if (pa !== pb)
|
|
576779
|
+
return pb - pa;
|
|
576780
|
+
const ta = a2.createdTurn ?? 0;
|
|
576781
|
+
const tb = b.createdTurn ?? 0;
|
|
576782
|
+
if (ta !== tb)
|
|
576783
|
+
return tb - ta;
|
|
576784
|
+
return a2.source.localeCompare(b.source) || a2.id.localeCompare(b.id);
|
|
576785
|
+
}
|
|
576786
|
+
function semanticKeyFor(signal) {
|
|
576787
|
+
const key = signal.semanticKey ?? signal.dedupeKey;
|
|
576788
|
+
return typeof key === "string" && key.trim() ? key.trim() : null;
|
|
576789
|
+
}
|
|
576790
|
+
function isControlSignal(signal) {
|
|
576791
|
+
return signal.kind === "runtime_guidance" || signal.kind === "action_contract" || signal.kind === "recent_failure";
|
|
576792
|
+
}
|
|
576793
|
+
function isEvidenceSignal(signal) {
|
|
576794
|
+
return signal.kind === "goal" || signal.kind === "user_steering" || signal.kind === "task_state" || signal.kind === "known_files" || signal.kind === "tool_cache" || signal.kind === "git_state" || signal.kind === "memory" || signal.kind === "semantic_chunk" || signal.kind === "session_history" || signal.kind === "anchor" || signal.kind === "handoff" || signal.kind === "environment" || signal.kind === "compaction_summary";
|
|
576795
|
+
}
|
|
576752
576796
|
function signalFromBlock(kind, source, content, options2 = {}) {
|
|
576753
576797
|
const normalized = normalizeSignalContent(content ?? "");
|
|
576754
576798
|
if (!normalized)
|
|
@@ -576762,6 +576806,10 @@ function signalFromBlock(kind, source, content, options2 = {}) {
|
|
|
576762
576806
|
createdTurn: options2.createdTurn,
|
|
576763
576807
|
ttlTurns: options2.ttlTurns,
|
|
576764
576808
|
dedupeKey: options2.dedupeKey,
|
|
576809
|
+
semanticKey: options2.semanticKey,
|
|
576810
|
+
conflictGroup: options2.conflictGroup,
|
|
576811
|
+
invalidates: options2.invalidates,
|
|
576812
|
+
modelVisible: options2.modelVisible,
|
|
576765
576813
|
tags: options2.tags,
|
|
576766
576814
|
metadata: options2.metadata
|
|
576767
576815
|
};
|
|
@@ -576830,12 +576878,12 @@ var init_context_fabric = __esm({
|
|
|
576830
576878
|
DEFAULT_KIND_CHAR_BUDGET = {
|
|
576831
576879
|
goal: 900,
|
|
576832
576880
|
user_steering: 1400,
|
|
576833
|
-
runtime_guidance:
|
|
576834
|
-
action_contract:
|
|
576881
|
+
runtime_guidance: 900,
|
|
576882
|
+
action_contract: 1400,
|
|
576835
576883
|
git_state: 1400,
|
|
576836
576884
|
task_state: 1800,
|
|
576837
576885
|
known_files: 2400,
|
|
576838
|
-
recent_failure:
|
|
576886
|
+
recent_failure: 1400,
|
|
576839
576887
|
tool_cache: 2200,
|
|
576840
576888
|
skill_manifest: 900,
|
|
576841
576889
|
memory: 1500,
|
|
@@ -576851,11 +576899,16 @@ var init_context_fabric = __esm({
|
|
|
576851
576899
|
ContextLedger = class {
|
|
576852
576900
|
signals = /* @__PURE__ */ new Map();
|
|
576853
576901
|
sequence = 0;
|
|
576902
|
+
invalidatedSinceLastBuild = 0;
|
|
576854
576903
|
upsert(signal) {
|
|
576855
576904
|
const content = normalizeSignalContent(signal.content);
|
|
576856
576905
|
if (!content)
|
|
576857
576906
|
return;
|
|
576858
|
-
|
|
576907
|
+
if (Array.isArray(signal.invalidates) && signal.invalidates.length > 0) {
|
|
576908
|
+
const invalidates = new Set(signal.invalidates.map((key2) => String(key2 ?? "").trim()).filter(Boolean));
|
|
576909
|
+
this.invalidatedSinceLastBuild += this.removeWhere((existing2) => signalIdentityKeys(existing2).some((key2) => invalidates.has(key2)));
|
|
576910
|
+
}
|
|
576911
|
+
const key = signal.dedupeKey || signal.semanticKey || `${signal.kind}:${signal.id}`;
|
|
576859
576912
|
const incoming = {
|
|
576860
576913
|
...signal,
|
|
576861
576914
|
content,
|
|
@@ -576869,12 +576922,15 @@ var init_context_fabric = __esm({
|
|
|
576869
576922
|
this.signals.set(key, incoming);
|
|
576870
576923
|
return;
|
|
576871
576924
|
}
|
|
576872
|
-
const
|
|
576873
|
-
if (
|
|
576925
|
+
const preferred = choosePreferredSignal(incoming, existing);
|
|
576926
|
+
if (preferred === incoming) {
|
|
576874
576927
|
this.signals.set(key, {
|
|
576875
576928
|
...existing,
|
|
576876
576929
|
...incoming,
|
|
576877
576930
|
tags: [.../* @__PURE__ */ new Set([...existing.tags ?? [], ...incoming.tags ?? []])],
|
|
576931
|
+
invalidates: [
|
|
576932
|
+
.../* @__PURE__ */ new Set([...existing.invalidates ?? [], ...incoming.invalidates ?? []])
|
|
576933
|
+
],
|
|
576878
576934
|
metadata: { ...existing.metadata ?? {}, ...incoming.metadata ?? {} }
|
|
576879
576935
|
});
|
|
576880
576936
|
}
|
|
@@ -576915,12 +576971,64 @@ var init_context_fabric = __esm({
|
|
|
576915
576971
|
size() {
|
|
576916
576972
|
return this.signals.size;
|
|
576917
576973
|
}
|
|
576974
|
+
consumeInvalidatedCount() {
|
|
576975
|
+
const count = this.invalidatedSinceLastBuild;
|
|
576976
|
+
this.invalidatedSinceLastBuild = 0;
|
|
576977
|
+
return count;
|
|
576978
|
+
}
|
|
576918
576979
|
};
|
|
576919
576980
|
ContextFrameBuilder = class {
|
|
576920
576981
|
build(signals, options2 = {}) {
|
|
576921
576982
|
const maxChars = Math.max(1200, options2.maxChars ?? 1e4);
|
|
576922
576983
|
const budgets = { ...DEFAULT_KIND_CHAR_BUDGET, ...options2.kindCharBudget ?? {} };
|
|
576923
|
-
const
|
|
576984
|
+
const normalized = signals.map((signal) => ({ ...signal, content: normalizeSignalContent(signal.content) })).filter((signal) => signal.content.length > 0);
|
|
576985
|
+
const hidden = normalized.filter((signal) => signal.modelVisible === false);
|
|
576986
|
+
const visible = normalized.filter((signal) => signal.modelVisible !== false);
|
|
576987
|
+
const droppedByAdmission = [];
|
|
576988
|
+
let semanticDedupedSignals = 0;
|
|
576989
|
+
let conflictDroppedSignals = 0;
|
|
576990
|
+
const semanticBest = /* @__PURE__ */ new Map();
|
|
576991
|
+
for (const signal of visible) {
|
|
576992
|
+
const key = semanticKeyFor(signal);
|
|
576993
|
+
if (!key)
|
|
576994
|
+
continue;
|
|
576995
|
+
const prior = semanticBest.get(key);
|
|
576996
|
+
if (!prior || sortSignals(signal, prior) < 0) {
|
|
576997
|
+
if (prior) {
|
|
576998
|
+
droppedByAdmission.push(prior);
|
|
576999
|
+
semanticDedupedSignals++;
|
|
577000
|
+
}
|
|
577001
|
+
semanticBest.set(key, signal);
|
|
577002
|
+
} else {
|
|
577003
|
+
droppedByAdmission.push(signal);
|
|
577004
|
+
semanticDedupedSignals++;
|
|
577005
|
+
}
|
|
577006
|
+
}
|
|
577007
|
+
const afterSemantic = visible.filter((signal) => {
|
|
577008
|
+
const key = semanticKeyFor(signal);
|
|
577009
|
+
return !key || semanticBest.get(key) === signal;
|
|
577010
|
+
});
|
|
577011
|
+
const conflictBest = /* @__PURE__ */ new Map();
|
|
577012
|
+
for (const signal of afterSemantic) {
|
|
577013
|
+
const key = typeof signal.conflictGroup === "string" ? signal.conflictGroup.trim() : "";
|
|
577014
|
+
if (!key)
|
|
577015
|
+
continue;
|
|
577016
|
+
const prior = conflictBest.get(key);
|
|
577017
|
+
if (!prior || sortSignals(signal, prior) < 0) {
|
|
577018
|
+
if (prior) {
|
|
577019
|
+
droppedByAdmission.push(prior);
|
|
577020
|
+
conflictDroppedSignals++;
|
|
577021
|
+
}
|
|
577022
|
+
conflictBest.set(key, signal);
|
|
577023
|
+
} else {
|
|
577024
|
+
droppedByAdmission.push(signal);
|
|
577025
|
+
conflictDroppedSignals++;
|
|
577026
|
+
}
|
|
577027
|
+
}
|
|
577028
|
+
const sanitized = afterSemantic.filter((signal) => {
|
|
577029
|
+
const key = typeof signal.conflictGroup === "string" ? signal.conflictGroup.trim() : "";
|
|
577030
|
+
return !key || conflictBest.get(key) === signal;
|
|
577031
|
+
});
|
|
576924
577032
|
const byKind = /* @__PURE__ */ new Map();
|
|
576925
577033
|
for (const signal of sanitized) {
|
|
576926
577034
|
const bucket = byKind.get(signal.kind) ?? [];
|
|
@@ -576937,17 +577045,7 @@ var init_context_fabric = __esm({
|
|
|
576937
577045
|
const bucket = byKind.get(kind);
|
|
576938
577046
|
if (!bucket || bucket.length === 0)
|
|
576939
577047
|
continue;
|
|
576940
|
-
const sorted = [...bucket].sort(
|
|
576941
|
-
const pa = a2.priority ?? 0;
|
|
576942
|
-
const pb = b.priority ?? 0;
|
|
576943
|
-
if (pa !== pb)
|
|
576944
|
-
return pb - pa;
|
|
576945
|
-
const ta = a2.createdTurn ?? 0;
|
|
576946
|
-
const tb = b.createdTurn ?? 0;
|
|
576947
|
-
if (ta !== tb)
|
|
576948
|
-
return tb - ta;
|
|
576949
|
-
return a2.source.localeCompare(b.source) || a2.id.localeCompare(b.id);
|
|
576950
|
-
});
|
|
577048
|
+
const sorted = [...bucket].sort(sortSignals);
|
|
576951
577049
|
const budget = Math.max(200, budgets[kind]);
|
|
576952
577050
|
const body = [];
|
|
576953
577051
|
let chars = 0;
|
|
@@ -576985,21 +577083,40 @@ var init_context_fabric = __esm({
|
|
|
576985
577083
|
"Scope: runtime state for the next action. Treat this as the single merged context intake; do not re-read or re-emit it unless state changes."
|
|
576986
577084
|
].filter(Boolean);
|
|
576987
577085
|
let content = [...header, "", ...sectionLines].join("\n").trim();
|
|
577086
|
+
const controlChars = included.filter(isControlSignal).reduce((sum2, signal) => sum2 + signal.content.length, 0);
|
|
577087
|
+
const evidenceChars = included.filter(isEvidenceSignal).reduce((sum2, signal) => sum2 + signal.content.length, 0);
|
|
577088
|
+
const controlToEvidenceRatio = Number((controlChars / Math.max(1, evidenceChars)).toFixed(3));
|
|
577089
|
+
const qualityWarnings = [];
|
|
577090
|
+
const maxControlRatio = options2.maxControlToEvidenceRatio ?? 0.45;
|
|
577091
|
+
if (controlToEvidenceRatio > maxControlRatio) {
|
|
577092
|
+
qualityWarnings.push(`control_context_ratio_high:${controlToEvidenceRatio}`);
|
|
577093
|
+
}
|
|
577094
|
+
const activeFrameCount = (content.match(/\[ACTIVE CONTEXT FRAME\]/g) ?? []).length;
|
|
577095
|
+
if (activeFrameCount > 1)
|
|
577096
|
+
qualityWarnings.push(`active_frame_count:${activeFrameCount}`);
|
|
576988
577097
|
if (sectionLines.length === 0) {
|
|
576989
577098
|
return {
|
|
576990
577099
|
content: null,
|
|
576991
577100
|
diagnostics: {
|
|
576992
577101
|
includedSignals: 0,
|
|
576993
|
-
droppedSignals: sanitized.length,
|
|
577102
|
+
droppedSignals: sanitized.length + droppedByAdmission.length,
|
|
577103
|
+
hiddenSignals: hidden.length,
|
|
577104
|
+
semanticDedupedSignals,
|
|
577105
|
+
conflictDroppedSignals,
|
|
577106
|
+
invalidatedSignals: options2.invalidatedSignals ?? 0,
|
|
576994
577107
|
truncatedSignals: 0,
|
|
576995
577108
|
estimatedTokens: 0,
|
|
576996
577109
|
totalChars: 0,
|
|
576997
577110
|
semanticChunkCount: 0,
|
|
577111
|
+
controlChars: 0,
|
|
577112
|
+
evidenceChars: 0,
|
|
577113
|
+
controlToEvidenceRatio: 0,
|
|
577114
|
+
qualityWarnings,
|
|
576998
577115
|
...metadataReports,
|
|
576999
577116
|
sections: []
|
|
577000
577117
|
},
|
|
577001
577118
|
included: [],
|
|
577002
|
-
dropped: sanitized
|
|
577119
|
+
dropped: [...sanitized, ...droppedByAdmission, ...hidden]
|
|
577003
577120
|
};
|
|
577004
577121
|
}
|
|
577005
577122
|
if (content.length > maxChars) {
|
|
@@ -577021,22 +577138,243 @@ context_fabric: included=${included.length} dropped=${dropped.length} truncated=
|
|
|
577021
577138
|
content,
|
|
577022
577139
|
diagnostics: {
|
|
577023
577140
|
includedSignals: included.length,
|
|
577024
|
-
droppedSignals: dropped.length,
|
|
577141
|
+
droppedSignals: dropped.length + droppedByAdmission.length,
|
|
577142
|
+
hiddenSignals: hidden.length,
|
|
577143
|
+
semanticDedupedSignals,
|
|
577144
|
+
conflictDroppedSignals,
|
|
577145
|
+
invalidatedSignals: options2.invalidatedSignals ?? 0,
|
|
577025
577146
|
truncatedSignals,
|
|
577026
577147
|
estimatedTokens: estimateTokens2(content),
|
|
577027
577148
|
totalChars: content.length,
|
|
577028
577149
|
semanticChunkCount: included.filter((signal) => signal.kind === "semantic_chunk").length,
|
|
577150
|
+
controlChars,
|
|
577151
|
+
evidenceChars,
|
|
577152
|
+
controlToEvidenceRatio,
|
|
577153
|
+
qualityWarnings,
|
|
577029
577154
|
...metadataReports,
|
|
577030
577155
|
sections: sectionDiagnostics
|
|
577031
577156
|
},
|
|
577032
577157
|
included,
|
|
577033
|
-
dropped
|
|
577158
|
+
dropped: [...dropped, ...droppedByAdmission, ...hidden]
|
|
577034
577159
|
};
|
|
577035
577160
|
}
|
|
577036
577161
|
};
|
|
577037
577162
|
}
|
|
577038
577163
|
});
|
|
577039
577164
|
|
|
577165
|
+
// packages/orchestrator/dist/context-compiler.js
|
|
577166
|
+
function collapseWhitespace(text2) {
|
|
577167
|
+
return text2.replace(/\r\n/g, "\n").split("\n").map((line) => line.trimEnd()).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
577168
|
+
}
|
|
577169
|
+
function sanitizeModelVisibleContextText(text2) {
|
|
577170
|
+
let out = String(text2 ?? "");
|
|
577171
|
+
out = out.replace(RUNTIME_GUIDANCE_RE, (_match, inner) => {
|
|
577172
|
+
return `[runtime_guidance]
|
|
577173
|
+
${String(inner ?? "").trim()}`;
|
|
577174
|
+
});
|
|
577175
|
+
out = out.split("\n").filter((line) => !RESTORE_NOISE_LINE_RE.test(line)).join("\n");
|
|
577176
|
+
const frameMatches = [...out.matchAll(ACTIVE_CONTEXT_RE)];
|
|
577177
|
+
if (frameMatches.length > 1) {
|
|
577178
|
+
const last2 = frameMatches[frameMatches.length - 1]?.[0] ?? "";
|
|
577179
|
+
out = out.replace(ACTIVE_CONTEXT_RE, "").trim();
|
|
577180
|
+
out = `${last2}
|
|
577181
|
+
${out}`.trim();
|
|
577182
|
+
}
|
|
577183
|
+
return collapseWhitespace(out);
|
|
577184
|
+
}
|
|
577185
|
+
function messageText(content) {
|
|
577186
|
+
if (typeof content === "string")
|
|
577187
|
+
return content;
|
|
577188
|
+
if (!Array.isArray(content))
|
|
577189
|
+
return "";
|
|
577190
|
+
return content.map((part) => {
|
|
577191
|
+
if (part && typeof part === "object") {
|
|
577192
|
+
const rec = part;
|
|
577193
|
+
return rec["type"] === "text" && typeof rec["text"] === "string" ? rec["text"] : "";
|
|
577194
|
+
}
|
|
577195
|
+
return "";
|
|
577196
|
+
}).filter(Boolean).join("\n");
|
|
577197
|
+
}
|
|
577198
|
+
function runtimeControlSemanticKey(content) {
|
|
577199
|
+
const normalized = content.replace(/\s+/g, " ").trim().toLowerCase();
|
|
577200
|
+
if (!normalized)
|
|
577201
|
+
return null;
|
|
577202
|
+
if (content.includes("[ACTIVE CONTEXT FRAME]"))
|
|
577203
|
+
return "context.active-frame";
|
|
577204
|
+
if (content.includes("[NEXT ACTION CONTRACT]"))
|
|
577205
|
+
return "context.next-action";
|
|
577206
|
+
if (content.includes("[RUNTIME DIRECTIVE]")) {
|
|
577207
|
+
if (/compile|verifier|verification|build|fix loop/.test(normalized))
|
|
577208
|
+
return "runtime.guidance.verification";
|
|
577209
|
+
if (/action_reason|tool action reason|schema|argument/.test(normalized))
|
|
577210
|
+
return "runtime.guidance.tool-args";
|
|
577211
|
+
if (/doom-loop|loop|repeat|identical|stuck|stale|cached/.test(normalized))
|
|
577212
|
+
return "runtime.guidance.loop-control";
|
|
577213
|
+
if (/todo|workboard|card|task state/.test(normalized))
|
|
577214
|
+
return "runtime.guidance.task-state";
|
|
577215
|
+
if (/scope|owned file|forbidden|mutation/.test(normalized))
|
|
577216
|
+
return "runtime.guidance.mutation-scope";
|
|
577217
|
+
return "runtime.guidance.general";
|
|
577218
|
+
}
|
|
577219
|
+
if (/\[TOOL ACTION REASON CONTRACT\]|action_reason/i.test(content))
|
|
577220
|
+
return "runtime.guidance.tool-args";
|
|
577221
|
+
if (/\[LOCAL ERROR-INFORMED NUDGE\]/.test(content))
|
|
577222
|
+
return "runtime.guidance.local-error";
|
|
577223
|
+
if (/\[STOP โ RETRY LOOP DETECTED\]|\[RECENT TOOL FAILURES/i.test(content))
|
|
577224
|
+
return "runtime.guidance.recent-failures";
|
|
577225
|
+
if (/REG-\d+|FIRST-EDIT|STUCK DETECTOR|LOOP CIRCUIT|doom-loop/i.test(content))
|
|
577226
|
+
return "runtime.guidance.loop-control";
|
|
577227
|
+
if (/\[Associative Memory/i.test(content))
|
|
577228
|
+
return "context.associative-memory";
|
|
577229
|
+
if (/\[TOOL MODE โ PROMPT INJECTION\]/.test(content))
|
|
577230
|
+
return "context.tool-mode-prompt";
|
|
577231
|
+
return null;
|
|
577232
|
+
}
|
|
577233
|
+
function hasConcreteGoalMessage(messages2) {
|
|
577234
|
+
return messages2.some((message2) => {
|
|
577235
|
+
const text2 = messageText(message2.content);
|
|
577236
|
+
return /\[CURRENT USER GOAL\]/.test(text2) && !/No concrete current user goal/i.test(text2);
|
|
577237
|
+
});
|
|
577238
|
+
}
|
|
577239
|
+
function hasUserMessage(messages2) {
|
|
577240
|
+
return messages2.some((message2) => message2.role === "user" && messageText(message2.content).trim().length > 0);
|
|
577241
|
+
}
|
|
577242
|
+
function prepareModelFacingApiMessages(input) {
|
|
577243
|
+
const preserveFirstSystem = input.preserveFirstSystem !== false;
|
|
577244
|
+
const sanitized = [];
|
|
577245
|
+
for (let index = 0; index < input.messages.length; index++) {
|
|
577246
|
+
const message2 = input.messages[index];
|
|
577247
|
+
if (message2.role === "system" && typeof message2.content === "string") {
|
|
577248
|
+
if (preserveFirstSystem && sanitized.length === 0) {
|
|
577249
|
+
sanitized.push({ ...message2 });
|
|
577250
|
+
continue;
|
|
577251
|
+
}
|
|
577252
|
+
const cleaned = sanitizeModelVisibleContextText(message2.content);
|
|
577253
|
+
if (!cleaned)
|
|
577254
|
+
continue;
|
|
577255
|
+
sanitized.push({ ...message2, content: cleaned });
|
|
577256
|
+
continue;
|
|
577257
|
+
}
|
|
577258
|
+
sanitized.push({ ...message2 });
|
|
577259
|
+
}
|
|
577260
|
+
const keep = new Array(sanitized.length).fill(true);
|
|
577261
|
+
const seenSystemKeys = /* @__PURE__ */ new Set();
|
|
577262
|
+
for (let index = sanitized.length - 1; index >= 0; index--) {
|
|
577263
|
+
const message2 = sanitized[index];
|
|
577264
|
+
if (message2.role !== "system" || typeof message2.content !== "string")
|
|
577265
|
+
continue;
|
|
577266
|
+
if (preserveFirstSystem && index === 0)
|
|
577267
|
+
continue;
|
|
577268
|
+
const key = runtimeControlSemanticKey(message2.content);
|
|
577269
|
+
if (!key)
|
|
577270
|
+
continue;
|
|
577271
|
+
if (seenSystemKeys.has(key)) {
|
|
577272
|
+
keep[index] = false;
|
|
577273
|
+
continue;
|
|
577274
|
+
}
|
|
577275
|
+
seenSystemKeys.add(key);
|
|
577276
|
+
}
|
|
577277
|
+
const deduped = sanitized.filter((_message, index) => keep[index]);
|
|
577278
|
+
if (!hasUserMessage(deduped) && !hasConcreteGoalMessage(deduped)) {
|
|
577279
|
+
const goal = deriveCurrentGoal({
|
|
577280
|
+
explicitGoal: input.currentGoal,
|
|
577281
|
+
signals: []
|
|
577282
|
+
});
|
|
577283
|
+
const goalMessage = {
|
|
577284
|
+
role: "system",
|
|
577285
|
+
content: [
|
|
577286
|
+
"[CURRENT USER GOAL]",
|
|
577287
|
+
"source=model-facing-api-view",
|
|
577288
|
+
goal.goal,
|
|
577289
|
+
goal.concrete ? null : "Required next action: recover or ask for the current user goal before mutating project files."
|
|
577290
|
+
].filter(Boolean).join("\n")
|
|
577291
|
+
};
|
|
577292
|
+
const insertAt = preserveFirstSystem && deduped[0]?.role === "system" ? 1 : 0;
|
|
577293
|
+
deduped.splice(insertAt, 0, goalMessage);
|
|
577294
|
+
}
|
|
577295
|
+
return deduped;
|
|
577296
|
+
}
|
|
577297
|
+
function deriveCurrentGoal(input) {
|
|
577298
|
+
const explicit = sanitizeModelVisibleContextText(input.explicitGoal ?? "");
|
|
577299
|
+
if (explicit)
|
|
577300
|
+
return { goal: explicit.slice(0, 1200), concrete: true, source: "runtime_task_state" };
|
|
577301
|
+
const goalSignal = input.signals.filter((signal) => signal.kind === "goal" || signal.kind === "user_steering").sort((a2, b) => (b.createdTurn ?? 0) - (a2.createdTurn ?? 0) || (b.priority ?? 0) - (a2.priority ?? 0))[0];
|
|
577302
|
+
const fromSignal = sanitizeModelVisibleContextText(goalSignal?.content ?? "");
|
|
577303
|
+
if (fromSignal)
|
|
577304
|
+
return { goal: fromSignal.slice(0, 1200), concrete: true, source: goalSignal?.source ?? "context_signal" };
|
|
577305
|
+
return {
|
|
577306
|
+
goal: "No concrete current user goal was present in model-visible context. Recover the latest user request or restored active task before making project mutations.",
|
|
577307
|
+
concrete: false,
|
|
577308
|
+
source: "context_quality_gate"
|
|
577309
|
+
};
|
|
577310
|
+
}
|
|
577311
|
+
function normalizeContextSignalsForModel(signals) {
|
|
577312
|
+
const normalized = [];
|
|
577313
|
+
const rejected = [];
|
|
577314
|
+
for (const signal of signals) {
|
|
577315
|
+
if (signal.modelVisible === false) {
|
|
577316
|
+
normalized.push(signal);
|
|
577317
|
+
continue;
|
|
577318
|
+
}
|
|
577319
|
+
const content = sanitizeModelVisibleContextText(signal.content);
|
|
577320
|
+
if (!content) {
|
|
577321
|
+
rejected.push(signal);
|
|
577322
|
+
continue;
|
|
577323
|
+
}
|
|
577324
|
+
normalized.push({ ...signal, content });
|
|
577325
|
+
}
|
|
577326
|
+
return { signals: normalized, rejected };
|
|
577327
|
+
}
|
|
577328
|
+
function compileContextFrameV2(input) {
|
|
577329
|
+
const builder = input.builder ?? new ContextFrameBuilder();
|
|
577330
|
+
const normalized = normalizeContextSignalsForModel(input.signals);
|
|
577331
|
+
const goal = deriveCurrentGoal({
|
|
577332
|
+
explicitGoal: input.currentGoal,
|
|
577333
|
+
signals: normalized.signals
|
|
577334
|
+
});
|
|
577335
|
+
const warnings = [];
|
|
577336
|
+
if (!goal.concrete)
|
|
577337
|
+
warnings.push("missing_concrete_user_goal");
|
|
577338
|
+
const goalSignal = signalFromBlock("goal", "context-compiler.current-goal", [
|
|
577339
|
+
"[CURRENT USER GOAL]",
|
|
577340
|
+
`source=${goal.source}`,
|
|
577341
|
+
goal.goal,
|
|
577342
|
+
goal.concrete ? null : "Required next action: recover or ask for the current user goal before mutating project files."
|
|
577343
|
+
].filter(Boolean).join("\n"), {
|
|
577344
|
+
id: "current-user-goal",
|
|
577345
|
+
dedupeKey: "context.current_user_goal",
|
|
577346
|
+
semanticKey: "context.current_user_goal",
|
|
577347
|
+
conflictGroup: "context.goal",
|
|
577348
|
+
priority: PRIORITY.GOAL + 20,
|
|
577349
|
+
createdTurn: input.turn,
|
|
577350
|
+
ttlTurns: 1
|
|
577351
|
+
});
|
|
577352
|
+
const frame = builder.build(goalSignal ? [goalSignal, ...normalized.signals] : normalized.signals, {
|
|
577353
|
+
turn: input.turn,
|
|
577354
|
+
...input.frameOptions
|
|
577355
|
+
});
|
|
577356
|
+
warnings.push(...frame.diagnostics.qualityWarnings);
|
|
577357
|
+
return {
|
|
577358
|
+
...frame,
|
|
577359
|
+
compilerDiagnostics: {
|
|
577360
|
+
warnings: [...new Set(warnings)],
|
|
577361
|
+
admittedSignals: frame.included.length,
|
|
577362
|
+
rejectedSignals: normalized.rejected.length,
|
|
577363
|
+
hadConcreteGoal: goal.concrete
|
|
577364
|
+
}
|
|
577365
|
+
};
|
|
577366
|
+
}
|
|
577367
|
+
var RESTORE_NOISE_LINE_RE, RUNTIME_GUIDANCE_RE, ACTIVE_CONTEXT_RE;
|
|
577368
|
+
var init_context_compiler = __esm({
|
|
577369
|
+
"packages/orchestrator/dist/context-compiler.js"() {
|
|
577370
|
+
"use strict";
|
|
577371
|
+
init_context_fabric();
|
|
577372
|
+
RESTORE_NOISE_LINE_RE = /^\s*(?:๐|E Task timeout reached|E Incomplete:|โ Task incomplete|Tokens:\s*[\d,]+|โน\s*continue\b|ยท\s*(?:Starting fresh|Context (?:auto-)?restored|Nexus P2P network connected|REST API:|Voice feedback enabled|Memory maintenance:)|.*\bSHELL TRANSCRIPT\b.*|.*speaker emoji.*).*$/i;
|
|
577373
|
+
RUNTIME_GUIDANCE_RE = /\[RUNTIME_GUIDANCE_INTAKE v\d+\][\s\S]*?<<<RUNTIME_GUIDANCE>>>\s*([\s\S]*?)\s*<<<END_RUNTIME_GUIDANCE>>>[\s\S]*?\[\/RUNTIME_GUIDANCE_INTAKE\]/g;
|
|
577374
|
+
ACTIVE_CONTEXT_RE = /\[ACTIVE CONTEXT FRAME\][\s\S]*?(?=\n\[ACTIVE CONTEXT FRAME\]|$)/g;
|
|
577375
|
+
}
|
|
577376
|
+
});
|
|
577377
|
+
|
|
577040
577378
|
// packages/orchestrator/dist/evidenceLedger.js
|
|
577041
577379
|
import { statSync as statSync38 } from "node:fs";
|
|
577042
577380
|
function buildExtract(content) {
|
|
@@ -577260,6 +577598,7 @@ function recordContextWindowDump(input) {
|
|
|
577260
577598
|
String(input.attempt ?? "")
|
|
577261
577599
|
].join("|");
|
|
577262
577600
|
const id2 = `${timestamp.replace(/[:.]/g, "-")}-${input.agentType}-${shortHash3(stable)}`;
|
|
577601
|
+
const metrics2 = analyzeContextWindowDumpRequest(input.request);
|
|
577263
577602
|
const record = {
|
|
577264
577603
|
schemaVersion: 1,
|
|
577265
577604
|
id: id2,
|
|
@@ -577275,7 +577614,8 @@ function recordContextWindowDump(input) {
|
|
|
577275
577614
|
cwd: cwd4,
|
|
577276
577615
|
...input.note ? { note: input.note } : {},
|
|
577277
577616
|
...input.focusSupervisor ? { focusSupervisor: compactFocusSupervisor(input.focusSupervisor) } : {},
|
|
577278
|
-
metrics:
|
|
577617
|
+
metrics: metrics2,
|
|
577618
|
+
apiView: summarizeApiView(input.request, metrics2),
|
|
577279
577619
|
request: input.request
|
|
577280
577620
|
};
|
|
577281
577621
|
const dir = contextWindowDumpDir(cwd4);
|
|
@@ -577338,12 +577678,17 @@ function analyzeContextWindowDumpRequest(request) {
|
|
|
577338
577678
|
let imageCount = 0;
|
|
577339
577679
|
let activeEvidenceChars = 0;
|
|
577340
577680
|
let activeContextFrameChars = 0;
|
|
577681
|
+
let activeContextFrameCount = 0;
|
|
577341
577682
|
let compactedDiscoveryChars = 0;
|
|
577342
577683
|
let rawDiscoveryToolChars = 0;
|
|
577343
577684
|
let toolResultChars = 0;
|
|
577344
577685
|
let systemChars = 0;
|
|
577345
577686
|
let userChars = 0;
|
|
577687
|
+
let userMessageCount = 0;
|
|
577346
577688
|
let assistantChars = 0;
|
|
577689
|
+
let runtimeControlChars = 0;
|
|
577690
|
+
let modelVisibleNoiseChars = 0;
|
|
577691
|
+
let hasConcreteUserGoal = false;
|
|
577347
577692
|
const allMessageParts = [];
|
|
577348
577693
|
for (const message2 of messages2) {
|
|
577349
577694
|
const rec = message2 && typeof message2 === "object" ? message2 : {};
|
|
@@ -577358,8 +577703,10 @@ function analyzeContextWindowDumpRequest(request) {
|
|
|
577358
577703
|
allMessageParts.push(extracted.textWithoutImages);
|
|
577359
577704
|
if (role === "system")
|
|
577360
577705
|
systemChars += chars;
|
|
577361
|
-
if (role === "user")
|
|
577706
|
+
if (role === "user") {
|
|
577362
577707
|
userChars += chars;
|
|
577708
|
+
userMessageCount++;
|
|
577709
|
+
}
|
|
577363
577710
|
if (role === "assistant")
|
|
577364
577711
|
assistantChars += chars;
|
|
577365
577712
|
if (role === "tool") {
|
|
@@ -577372,6 +577719,17 @@ function analyzeContextWindowDumpRequest(request) {
|
|
|
577372
577719
|
}
|
|
577373
577720
|
if (extracted.textWithoutImages.includes("[ACTIVE CONTEXT FRAME]")) {
|
|
577374
577721
|
activeContextFrameChars += chars;
|
|
577722
|
+
activeContextFrameCount += (extracted.textWithoutImages.match(/\[ACTIVE CONTEXT FRAME\]/g) ?? []).length;
|
|
577723
|
+
}
|
|
577724
|
+
if (/\[CURRENT USER GOAL\]/.test(extracted.textWithoutImages) && !/No concrete current user goal/i.test(extracted.textWithoutImages)) {
|
|
577725
|
+
hasConcreteUserGoal = true;
|
|
577726
|
+
}
|
|
577727
|
+
if (isRuntimeControlText(extracted.textWithoutImages)) {
|
|
577728
|
+
runtimeControlChars += chars;
|
|
577729
|
+
}
|
|
577730
|
+
modelVisibleNoiseChars += estimateModelVisibleNoiseChars(extracted.textWithoutImages);
|
|
577731
|
+
if (role === "user" && extracted.textWithoutImages.trim()) {
|
|
577732
|
+
hasConcreteUserGoal = true;
|
|
577375
577733
|
}
|
|
577376
577734
|
if (extracted.textWithoutImages.includes("[DISCOVERY COMPACTED") || extracted.textWithoutImages.includes("[DISCOVERY BOUNDED")) {
|
|
577377
577735
|
compactedDiscoveryChars += chars;
|
|
@@ -577384,6 +577742,20 @@ function analyzeContextWindowDumpRequest(request) {
|
|
|
577384
577742
|
const lineNoiseChars = lineNoise.noiseChars;
|
|
577385
577743
|
const rawDiscoveryPenalty = rawDiscoveryToolChars * 0.5;
|
|
577386
577744
|
const structuralNoiseCandidateChars = lineNoiseChars + rawDiscoveryPenalty;
|
|
577745
|
+
const controlToEvidenceRatio = Number((runtimeControlChars / Math.max(1, activeEvidenceChars + activeContextFrameChars + userChars)).toFixed(3));
|
|
577746
|
+
const userlessTaskTurn = userMessageCount === 0 && !hasConcreteUserGoal;
|
|
577747
|
+
const qualityWarnings = [];
|
|
577748
|
+
if (activeContextFrameCount > 1) {
|
|
577749
|
+
qualityWarnings.push(`active_context_frame_count:${activeContextFrameCount}`);
|
|
577750
|
+
}
|
|
577751
|
+
if (userlessTaskTurn)
|
|
577752
|
+
qualityWarnings.push("missing_user_message_or_goal");
|
|
577753
|
+
if (controlToEvidenceRatio > 0.45) {
|
|
577754
|
+
qualityWarnings.push(`control_context_ratio_high:${controlToEvidenceRatio}`);
|
|
577755
|
+
}
|
|
577756
|
+
if (modelVisibleNoiseChars > 0) {
|
|
577757
|
+
qualityWarnings.push(`model_visible_restore_noise:${modelVisibleNoiseChars}`);
|
|
577758
|
+
}
|
|
577387
577759
|
const ratio = Number((structuralSignalChars / Math.max(1, structuralNoiseCandidateChars)).toFixed(3));
|
|
577388
577760
|
const snrDb = ratio > 0 ? Number((10 * Math.log10(ratio)).toFixed(2)) : -Infinity;
|
|
577389
577761
|
return {
|
|
@@ -577397,12 +577769,20 @@ function analyzeContextWindowDumpRequest(request) {
|
|
|
577397
577769
|
roleChars,
|
|
577398
577770
|
activeEvidenceChars,
|
|
577399
577771
|
activeContextFrameChars,
|
|
577772
|
+
activeContextFrameCount,
|
|
577400
577773
|
compactedDiscoveryChars,
|
|
577401
577774
|
rawDiscoveryToolChars,
|
|
577402
577775
|
toolResultChars,
|
|
577403
577776
|
systemChars,
|
|
577404
577777
|
userChars,
|
|
577778
|
+
userMessageCount,
|
|
577405
577779
|
assistantChars,
|
|
577780
|
+
runtimeControlChars,
|
|
577781
|
+
controlToEvidenceRatio,
|
|
577782
|
+
hasConcreteUserGoal,
|
|
577783
|
+
userlessTaskTurn,
|
|
577784
|
+
modelVisibleNoiseChars,
|
|
577785
|
+
qualityWarnings,
|
|
577406
577786
|
signalToNoise: {
|
|
577407
577787
|
structuralSignalChars,
|
|
577408
577788
|
structuralNoiseCandidateChars,
|
|
@@ -577412,6 +577792,53 @@ function analyzeContextWindowDumpRequest(request) {
|
|
|
577412
577792
|
}
|
|
577413
577793
|
};
|
|
577414
577794
|
}
|
|
577795
|
+
function summarizeApiView(request, metrics2) {
|
|
577796
|
+
const messages2 = Array.isArray(request["messages"]) ? request["messages"] : [];
|
|
577797
|
+
const previews = [];
|
|
577798
|
+
let currentGoalPreview;
|
|
577799
|
+
for (let index = 0; index < messages2.length && previews.length < 16; index++) {
|
|
577800
|
+
const rec = messages2[index] && typeof messages2[index] === "object" ? messages2[index] : {};
|
|
577801
|
+
const role = typeof rec["role"] === "string" ? rec["role"] : "unknown";
|
|
577802
|
+
const text2 = textAndImagesFromContent(rec["content"]).textWithoutImages;
|
|
577803
|
+
const preview = text2.replace(/\s+/g, " ").trim().slice(0, 180);
|
|
577804
|
+
const goalMatch = text2.match(/\[CURRENT USER GOAL\][\s\S]{0,500}/);
|
|
577805
|
+
if (goalMatch && !currentGoalPreview) {
|
|
577806
|
+
currentGoalPreview = goalMatch[0].replace(/\s+/g, " ").trim().slice(0, 220);
|
|
577807
|
+
}
|
|
577808
|
+
previews.push({
|
|
577809
|
+
index,
|
|
577810
|
+
role,
|
|
577811
|
+
chars: text2.length,
|
|
577812
|
+
preview
|
|
577813
|
+
});
|
|
577814
|
+
}
|
|
577815
|
+
return {
|
|
577816
|
+
kind: "model-facing-api-view",
|
|
577817
|
+
exactRequestStored: true,
|
|
577818
|
+
messageCount: metrics2.messageCount,
|
|
577819
|
+
toolSchemaCount: metrics2.toolSchemaCount,
|
|
577820
|
+
roleCounts: metrics2.roleCounts,
|
|
577821
|
+
estimatedTokens: metrics2.estimatedTokens,
|
|
577822
|
+
activeContextFrameCount: metrics2.activeContextFrameCount,
|
|
577823
|
+
hasConcreteUserGoal: metrics2.hasConcreteUserGoal,
|
|
577824
|
+
userlessTaskTurn: metrics2.userlessTaskTurn,
|
|
577825
|
+
qualityWarnings: metrics2.qualityWarnings,
|
|
577826
|
+
...currentGoalPreview ? { currentGoalPreview } : {},
|
|
577827
|
+
messagePreviews: previews
|
|
577828
|
+
};
|
|
577829
|
+
}
|
|
577830
|
+
function isRuntimeControlText(text2) {
|
|
577831
|
+
return /\[(?:RUNTIME DIRECTIVE|RUNTIME_GUIDANCE_INTAKE|NEXT ACTION CONTRACT|TOOL ACTION REASON CONTRACT)\]|(?:^|\n)\s*REG-\d+\b|focus_required_next_action=|workboard_current_card=/i.test(text2);
|
|
577832
|
+
}
|
|
577833
|
+
function estimateModelVisibleNoiseChars(text2) {
|
|
577834
|
+
let chars = 0;
|
|
577835
|
+
for (const line of text2.split("\n")) {
|
|
577836
|
+
if (/^\s*(?:๐|E Task timeout reached|E Incomplete:|โ Task incomplete|Tokens:\s*[\d,]+|โน\s*continue\b|ยท\s*(?:Starting fresh|Context (?:auto-)?restored|Nexus P2P network connected|REST API:|Voice feedback enabled|Memory maintenance:)|.*\bSHELL TRANSCRIPT\b.*)/i.test(line)) {
|
|
577837
|
+
chars += line.length;
|
|
577838
|
+
}
|
|
577839
|
+
}
|
|
577840
|
+
return chars;
|
|
577841
|
+
}
|
|
577415
577842
|
function textAndImagesFromContent(content) {
|
|
577416
577843
|
if (typeof content === "string") {
|
|
577417
577844
|
const matches = content.match(IMAGE_BASE64_RE);
|
|
@@ -585367,6 +585794,7 @@ var init_agenticRunner = __esm({
|
|
|
585367
585794
|
init_failureHandoff();
|
|
585368
585795
|
init_failure_taxonomy();
|
|
585369
585796
|
init_context_fabric();
|
|
585797
|
+
init_context_compiler();
|
|
585370
585798
|
init_evidenceLedger();
|
|
585371
585799
|
init_adversaryStream();
|
|
585372
585800
|
init_contextWindowDump();
|
|
@@ -586501,9 +586929,34 @@ var init_agenticRunner = __esm({
|
|
|
586501
586929
|
parts.push(`Active: ${activeCards.length}`);
|
|
586502
586930
|
}
|
|
586503
586931
|
if (snapshot.cards.length > 0) {
|
|
586504
|
-
const
|
|
586505
|
-
|
|
586506
|
-
|
|
586932
|
+
const statusCounts = snapshot.cards.reduce((acc, card) => {
|
|
586933
|
+
acc[card.status] = (acc[card.status] ?? 0) + 1;
|
|
586934
|
+
return acc;
|
|
586935
|
+
}, {});
|
|
586936
|
+
parts.push(`Card counts: ${Object.entries(statusCounts).sort(([a2], [b]) => a2.localeCompare(b)).map(([status, count]) => `${status}:${count}`).join(" ")}`);
|
|
586937
|
+
const action = this._deriveWorkboardActionContract(snapshot);
|
|
586938
|
+
const current = action ? snapshot.cards.find((card) => card.id === action.cardId) : activeCards[0] ?? null;
|
|
586939
|
+
if (current) {
|
|
586940
|
+
const currentLines = [
|
|
586941
|
+
`Current card: ${current.id} status=${current.status} lane=${current.lane}`,
|
|
586942
|
+
`title=${current.title.slice(0, 160)}`
|
|
586943
|
+
];
|
|
586944
|
+
if (current.assignee)
|
|
586945
|
+
currentLines.push(`assignee=${current.assignee.slice(0, 120)}`);
|
|
586946
|
+
if (current.ownedFiles && current.ownedFiles.length > 0) {
|
|
586947
|
+
currentLines.push(`owned_files=${current.ownedFiles.slice(0, 6).join(",")}`);
|
|
586948
|
+
}
|
|
586949
|
+
if (current.verifierCommand) {
|
|
586950
|
+
currentLines.push(`verifier=${current.verifierCommand.slice(0, 180)}`);
|
|
586951
|
+
}
|
|
586952
|
+
if (current.diagnosticFingerprint) {
|
|
586953
|
+
currentLines.push(`diagnostic=${current.diagnosticFingerprint.slice(0, 160)}`);
|
|
586954
|
+
}
|
|
586955
|
+
if (current.evidenceRequirements.length > 0) {
|
|
586956
|
+
currentLines.push(`evidence_required=${current.evidenceRequirements.slice(0, 3).map((item) => item.slice(0, 100)).join(" | ")}`);
|
|
586957
|
+
}
|
|
586958
|
+
parts.push(currentLines.join("\n"));
|
|
586959
|
+
}
|
|
586507
586960
|
}
|
|
586508
586961
|
return parts.length > 0 ? `<workboard-status>
|
|
586509
586962
|
${parts.join("\n")}
|
|
@@ -587794,6 +588247,18 @@ Your hypotheses MUST address this specific error, not generic causes.
|
|
|
587794
588247
|
* system prompt. Mutates `messages` in place.
|
|
587795
588248
|
*/
|
|
587796
588249
|
gcSystemMessages(messages2) {
|
|
588250
|
+
for (let i2 = 1; i2 < messages2.length; i2++) {
|
|
588251
|
+
const msg = messages2[i2];
|
|
588252
|
+
if (msg?.role !== "system" || typeof msg.content !== "string")
|
|
588253
|
+
continue;
|
|
588254
|
+
const cleaned = sanitizeModelVisibleContextText(msg.content);
|
|
588255
|
+
if (cleaned) {
|
|
588256
|
+
msg.content = cleaned;
|
|
588257
|
+
} else {
|
|
588258
|
+
messages2.splice(i2, 1);
|
|
588259
|
+
i2--;
|
|
588260
|
+
}
|
|
588261
|
+
}
|
|
587797
588262
|
const ctxTokens = this.effectiveContextWindow();
|
|
587798
588263
|
const systemMaxChars = ctxTokens > 0 ? Math.max(24e3, Math.floor(ctxTokens * 4 * 0.45)) : 0;
|
|
587799
588264
|
const beforeChars = messages2.reduce((sum2, m2) => sum2 + (m2.role === "system" && typeof m2.content === "string" ? m2.content.length : 0), 0);
|
|
@@ -587817,6 +588282,13 @@ Your hypotheses MUST address this specific error, not generic causes.
|
|
|
587817
588282
|
});
|
|
587818
588283
|
}
|
|
587819
588284
|
}
|
|
588285
|
+
_prepareModelFacingMessages(messages2, _turn) {
|
|
588286
|
+
const prepared = prepareModelFacingApiMessages({
|
|
588287
|
+
messages: messages2,
|
|
588288
|
+
currentGoal: this._taskState.originalGoal || this._taskState.goal || this._taskState.currentStep || this._taskState.nextAction || ""
|
|
588289
|
+
});
|
|
588290
|
+
return sanitizeHistoryThink(prepared);
|
|
588291
|
+
}
|
|
587820
588292
|
// โโ Failing-approach detector (the "stop retrying variants" reflex) โโโโโโโ
|
|
587821
588293
|
// Encodes the behavior an effective agent uses and the dropbear 27ร loop
|
|
587822
588294
|
// lacked: when the SAME error recurs ~3ร โ especially while the same target
|
|
@@ -592381,9 +592853,11 @@ ${chunk.content}`, {
|
|
|
592381
592853
|
async _buildTurnContextFrame(turn, messages2, recentToolResults, environmentBlock) {
|
|
592382
592854
|
this._contextLedger.clearSources("turn.");
|
|
592383
592855
|
this._contextLedger.prune(turn);
|
|
592856
|
+
const concreteGoal = this._taskState.originalGoal || this._taskState.goal || this._taskState.currentStep || this._taskState.nextAction || "";
|
|
592384
592857
|
const goalBlock = [
|
|
592385
592858
|
this._renderRuntimeRootBlock(),
|
|
592386
|
-
|
|
592859
|
+
concreteGoal ? `[CURRENT USER GOAL]
|
|
592860
|
+
${String(concreteGoal).replace(/\s+/g, " ").trim().slice(0, 1200)}` : null
|
|
592387
592861
|
].filter(Boolean).join("\n\n");
|
|
592388
592862
|
const workspaceTreeBlock = this._renderWorkspaceTreeBlock(turn);
|
|
592389
592863
|
const filesystemBlock = this._renderFilesystemStateBlock(turn);
|
|
@@ -592422,6 +592896,8 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
592422
592896
|
signalFromBlock("goal", "run.goal", goalBlock, {
|
|
592423
592897
|
id: "active-task",
|
|
592424
592898
|
dedupeKey: "run.goal",
|
|
592899
|
+
semanticKey: "run.goal",
|
|
592900
|
+
conflictGroup: "context.runtime-root",
|
|
592425
592901
|
priority: 100,
|
|
592426
592902
|
createdTurn: turn
|
|
592427
592903
|
}),
|
|
@@ -592449,6 +592925,8 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
592449
592925
|
signalFromBlock("action_contract", "turn.next-action-contract", actionContractBlock, {
|
|
592450
592926
|
id: "next-action-contract",
|
|
592451
592927
|
dedupeKey: "turn.next-action-contract",
|
|
592928
|
+
semanticKey: "context.next-action-contract",
|
|
592929
|
+
conflictGroup: "context.next-action",
|
|
592452
592930
|
priority: PRIORITY.ACTION_CONTRACT,
|
|
592453
592931
|
createdTurn: turn,
|
|
592454
592932
|
ttlTurns: 1
|
|
@@ -592456,6 +592934,7 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
592456
592934
|
signalFromBlock("task_state", "turn.todos", todoBlock, {
|
|
592457
592935
|
id: "todo-state",
|
|
592458
592936
|
dedupeKey: "turn.todos",
|
|
592937
|
+
semanticKey: "context.todos",
|
|
592459
592938
|
priority: 80,
|
|
592460
592939
|
createdTurn: turn,
|
|
592461
592940
|
ttlTurns: 1
|
|
@@ -592470,6 +592949,8 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
592470
592949
|
signalFromBlock("task_state", "turn.focus-supervisor", focusBlock, {
|
|
592471
592950
|
id: "focus-supervisor",
|
|
592472
592951
|
dedupeKey: "turn.focus-supervisor",
|
|
592952
|
+
semanticKey: "context.focus-supervisor",
|
|
592953
|
+
conflictGroup: "context.focus-supervisor",
|
|
592473
592954
|
priority: 98,
|
|
592474
592955
|
createdTurn: turn,
|
|
592475
592956
|
ttlTurns: 1
|
|
@@ -592477,6 +592958,8 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
592477
592958
|
signalFromBlock("recent_failure", "turn.failures", failureBlock, {
|
|
592478
592959
|
id: "recent-failures",
|
|
592479
592960
|
dedupeKey: "turn.failures",
|
|
592961
|
+
semanticKey: "context.recent-failures",
|
|
592962
|
+
conflictGroup: "context.recent-failures",
|
|
592480
592963
|
priority: 95,
|
|
592481
592964
|
createdTurn: turn,
|
|
592482
592965
|
ttlTurns: 1
|
|
@@ -592491,6 +592974,7 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
592491
592974
|
signalFromBlock("tool_cache", "turn.tool-cache", toolCacheBlock, {
|
|
592492
592975
|
id: "tool-cache",
|
|
592493
592976
|
dedupeKey: "turn.tool-cache",
|
|
592977
|
+
semanticKey: "context.tool-cache",
|
|
592494
592978
|
priority: 92,
|
|
592495
592979
|
createdTurn: turn,
|
|
592496
592980
|
ttlTurns: 1
|
|
@@ -592529,15 +593013,49 @@ ${this._lastPprMemoryLines.slice(0, 5).join("\n")}` : null;
|
|
|
592529
593013
|
})
|
|
592530
593014
|
];
|
|
592531
593015
|
this._contextLedger.upsertMany(signals.filter(Boolean));
|
|
592532
|
-
const
|
|
592533
|
-
|
|
593016
|
+
const invalidatedSignals = this._contextLedger.consumeInvalidatedCount();
|
|
593017
|
+
const frameBuildOptions = {
|
|
592534
593018
|
// Raised from 10k to fit the durable read-evidence content (known_files)
|
|
592535
593019
|
// that replaces the re-read loop; the per-kind budget below caps it.
|
|
592536
593020
|
maxChars: 13e3,
|
|
592537
|
-
kindCharBudget: {
|
|
593021
|
+
kindCharBudget: {
|
|
593022
|
+
known_files: 8500,
|
|
593023
|
+
runtime_guidance: 900,
|
|
593024
|
+
recent_failure: 1400,
|
|
593025
|
+
action_contract: 1400
|
|
593026
|
+
},
|
|
593027
|
+
invalidatedSignals,
|
|
593028
|
+
maxControlToEvidenceRatio: 0.45,
|
|
592538
593029
|
includeDiagnostics: process.env["OMNIUS_CONTEXT_FABRIC_DIAGNOSTICS"] === "1"
|
|
592539
|
-
}
|
|
593030
|
+
};
|
|
593031
|
+
const compilerEnabled = process.env["OMNIUS_CONTEXT_COMPILER_V2"] !== "0";
|
|
593032
|
+
const frame = compilerEnabled ? compileContextFrameV2({
|
|
593033
|
+
turn,
|
|
593034
|
+
currentGoal: concreteGoal,
|
|
593035
|
+
signals: this._contextLedger.values(),
|
|
593036
|
+
builder: this._contextFrameBuilder,
|
|
593037
|
+
frameOptions: frameBuildOptions
|
|
593038
|
+
}) : {
|
|
593039
|
+
...this._contextFrameBuilder.build(this._contextLedger.values(), {
|
|
593040
|
+
turn,
|
|
593041
|
+
...frameBuildOptions
|
|
593042
|
+
}),
|
|
593043
|
+
compilerDiagnostics: {
|
|
593044
|
+
warnings: [],
|
|
593045
|
+
admittedSignals: 0,
|
|
593046
|
+
rejectedSignals: 0,
|
|
593047
|
+
hadConcreteGoal: Boolean(concreteGoal)
|
|
593048
|
+
}
|
|
593049
|
+
};
|
|
592540
593050
|
this._lastContextFrameDiagnostics = frame.diagnostics;
|
|
593051
|
+
if (frame.compilerDiagnostics.warnings.length > 0 && process.env["OMNIUS_CONTEXT_COMPILER_STATUS"] === "1") {
|
|
593052
|
+
this.emit({
|
|
593053
|
+
type: "status",
|
|
593054
|
+
content: `Context compiler warnings: ${frame.compilerDiagnostics.warnings.join(", ")}`,
|
|
593055
|
+
turn,
|
|
593056
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
593057
|
+
});
|
|
593058
|
+
}
|
|
592541
593059
|
semantic.snapshot.frameTokens = frame.diagnostics.estimatedTokens;
|
|
592542
593060
|
semantic.snapshot.droppedSignals = frame.diagnostics.droppedSignals;
|
|
592543
593061
|
semantic.snapshot.truncatedSignals = frame.diagnostics.truncatedSignals;
|
|
@@ -596501,7 +597019,7 @@ ${memoryLines.join("\n")}`
|
|
|
596501
597019
|
}
|
|
596502
597020
|
const { maxOutputTokens: effectiveMaxTokens } = this.contextLimits();
|
|
596503
597021
|
this.gcSystemMessages(requestMessages);
|
|
596504
|
-
requestMessages =
|
|
597022
|
+
requestMessages = this._prepareModelFacingMessages(requestMessages, turn);
|
|
596505
597023
|
const chatRequest = {
|
|
596506
597024
|
messages: requestMessages,
|
|
596507
597025
|
tools: toolDefs,
|
|
@@ -596685,10 +597203,10 @@ ${memoryLines.join("\n")}`
|
|
|
596685
597203
|
'When done, output: {"tool": "task_complete", "args": {"summary": "what you did"}}'
|
|
596686
597204
|
].join("\n");
|
|
596687
597205
|
messages2.push({ role: "system", content: toolInjectMsg });
|
|
596688
|
-
chatRequest.messages = [
|
|
597206
|
+
chatRequest.messages = this._prepareModelFacingMessages([
|
|
596689
597207
|
...requestMessages,
|
|
596690
597208
|
{ role: "system", content: toolInjectMsg }
|
|
596691
|
-
];
|
|
597209
|
+
], turn);
|
|
596692
597210
|
chatRequest.tools = [];
|
|
596693
597211
|
try {
|
|
596694
597212
|
this._recordContextWindowDump("agent_turn_prompt_tool_retry", chatRequest, turn, 1);
|
|
@@ -600690,7 +601208,7 @@ ${this.options.maxTurns && this.options.maxTurns > 0 ? `You have ${this.options.
|
|
|
600690
601208
|
}
|
|
600691
601209
|
this._insertContextFrame(compactedMsgs, await this._buildTurnContextFrame(turn, compactedMsgs, void 0, bfEnvironmentBlock));
|
|
600692
601210
|
this.gcSystemMessages(compactedMsgs);
|
|
600693
|
-
const modelFacingMessages =
|
|
601211
|
+
const modelFacingMessages = this._prepareModelFacingMessages(compactedMsgs, turn);
|
|
600694
601212
|
const chatRequest = {
|
|
600695
601213
|
messages: modelFacingMessages,
|
|
600696
601214
|
tools: toolDefs,
|
|
@@ -603738,12 +604256,15 @@ ${tail}`;
|
|
|
603738
604256
|
appendRuntimeGuidance(guidance, turn) {
|
|
603739
604257
|
const packet = this.formatRuntimeGuidance(guidance);
|
|
603740
604258
|
const guidanceHash = _createHash("sha256").update(packet).digest("hex").slice(0, 16);
|
|
604259
|
+
const semanticKey = this.runtimeGuidanceSemanticKey(guidance);
|
|
603741
604260
|
const signal = signalFromBlock("runtime_guidance", "runtime.guidance", packet, {
|
|
603742
604261
|
id: `runtime-guidance-${turn}-${guidanceHash}`,
|
|
603743
604262
|
dedupeKey: `runtime.guidance:${guidanceHash}`,
|
|
604263
|
+
semanticKey,
|
|
604264
|
+
conflictGroup: "context.runtime-guidance",
|
|
603744
604265
|
priority: 94,
|
|
603745
604266
|
createdTurn: turn,
|
|
603746
|
-
ttlTurns:
|
|
604267
|
+
ttlTurns: 3
|
|
603747
604268
|
});
|
|
603748
604269
|
if (signal)
|
|
603749
604270
|
this._contextLedger.upsert(signal);
|
|
@@ -603759,20 +604280,31 @@ ${tail}`;
|
|
|
603759
604280
|
return guidance;
|
|
603760
604281
|
}
|
|
603761
604282
|
return [
|
|
603762
|
-
"[
|
|
603763
|
-
"
|
|
603764
|
-
|
|
603765
|
-
"<<<RUNTIME_GUIDANCE>>>",
|
|
603766
|
-
guidance,
|
|
603767
|
-
"<<<END_RUNTIME_GUIDANCE>>>",
|
|
603768
|
-
"",
|
|
603769
|
-
"Contract:",
|
|
603770
|
-
"- Treat this as diagnostic/control-plane guidance for the next action.",
|
|
603771
|
-
"- Reconcile it with the user goal and fresh tool evidence.",
|
|
603772
|
-
"- Do not quote or summarize this wrapper to the user.",
|
|
603773
|
-
"[/RUNTIME_GUIDANCE_INTAKE]"
|
|
604283
|
+
"[RUNTIME DIRECTIVE]",
|
|
604284
|
+
"source=omnius_runtime",
|
|
604285
|
+
guidance
|
|
603774
604286
|
].join("\n");
|
|
603775
604287
|
}
|
|
604288
|
+
runtimeGuidanceSemanticKey(guidance) {
|
|
604289
|
+
const normalized = guidance.replace(/\s+/g, " ").trim().toLowerCase();
|
|
604290
|
+
if (/compile|verifier|verification|build|fix loop/.test(normalized)) {
|
|
604291
|
+
return "runtime.guidance.verification";
|
|
604292
|
+
}
|
|
604293
|
+
if (/action_reason|tool action reason|schema|argument/.test(normalized)) {
|
|
604294
|
+
return "runtime.guidance.tool-args";
|
|
604295
|
+
}
|
|
604296
|
+
if (/doom-loop|loop|repeat|identical|stuck|stale|cached/.test(normalized)) {
|
|
604297
|
+
return "runtime.guidance.loop-control";
|
|
604298
|
+
}
|
|
604299
|
+
if (/todo|workboard|card|task state/.test(normalized)) {
|
|
604300
|
+
return "runtime.guidance.task-state";
|
|
604301
|
+
}
|
|
604302
|
+
if (/scope|owned file|forbidden|mutation/.test(normalized)) {
|
|
604303
|
+
return "runtime.guidance.mutation-scope";
|
|
604304
|
+
}
|
|
604305
|
+
const digest3 = _createHash("sha256").update(normalized.slice(0, 400)).digest("hex").slice(0, 10);
|
|
604306
|
+
return `runtime.guidance.${digest3}`;
|
|
604307
|
+
}
|
|
603776
604308
|
formatInjectedUserMessage(userMsg) {
|
|
603777
604309
|
if (userMsg.trim().startsWith("[MID_TASK_STEERING_INTAKE")) {
|
|
603778
604310
|
return userMsg;
|
|
@@ -637714,6 +638246,7 @@ __export(omnius_directory_exports, {
|
|
|
637714
638246
|
recordUsage: () => recordUsage,
|
|
637715
638247
|
renderSessionDiary: () => renderSessionDiary,
|
|
637716
638248
|
resolveSettings: () => resolveSettings,
|
|
638249
|
+
sanitizeRestorePromptForModel: () => sanitizeRestorePromptForModel,
|
|
637717
638250
|
sanitizeRestoredSessionLines: () => sanitizeRestoredSessionLines,
|
|
637718
638251
|
saveGlobalSettings: () => saveGlobalSettings,
|
|
637719
638252
|
savePendingTask: () => savePendingTask,
|
|
@@ -638269,9 +638802,16 @@ function releaseLock(lockPath) {
|
|
|
638269
638802
|
} catch {
|
|
638270
638803
|
}
|
|
638271
638804
|
}
|
|
638805
|
+
function stripModelContextNoise(raw) {
|
|
638806
|
+
if (!raw) return "";
|
|
638807
|
+
return String(raw).replace(/\r\n/g, "\n").split("\n").filter((line) => !MODEL_CONTEXT_NOISE_LINE_RE.test(line)).join("\n").replace(/\n{3,}/g, "\n\n").trim();
|
|
638808
|
+
}
|
|
638809
|
+
function sanitizeRestorePromptForModel(raw) {
|
|
638810
|
+
return stripModelContextNoise(raw);
|
|
638811
|
+
}
|
|
638272
638812
|
function normalizeSessionText(raw, maxLen = 500) {
|
|
638273
638813
|
if (!raw) return "";
|
|
638274
|
-
return
|
|
638814
|
+
return stripModelContextNoise(raw).replace(/\s+/g, " ").trim().slice(0, maxLen);
|
|
638275
638815
|
}
|
|
638276
638816
|
function normalizeList(items, maxItems) {
|
|
638277
638817
|
if (!items || items.length === 0) return void 0;
|
|
@@ -638469,7 +639009,7 @@ function saveSessionContext(repoRoot, entry) {
|
|
|
638469
639009
|
}
|
|
638470
639010
|
function cleanPromptForDiary(raw) {
|
|
638471
639011
|
if (!raw) return "";
|
|
638472
|
-
let text2 =
|
|
639012
|
+
let text2 = stripModelContextNoise(raw);
|
|
638473
639013
|
text2 = text2.replace(/^\[Previous sessions exist[^\]]*\]\s*\n*/m, "");
|
|
638474
639014
|
text2 = text2.replace(/^[\s\S]*?\n---\s*\n\s*NEW TASK:\s*/m, "");
|
|
638475
639015
|
text2 = text2.replace(/^NEW TASK:\s*/m, "");
|
|
@@ -638829,6 +639369,7 @@ function buildContextRestoreSnapshot(repoRoot) {
|
|
|
638829
639369
|
const restoredTodos = findRestoredTodoState(restoreSessionIds);
|
|
638830
639370
|
const sourceSessionId = restoredTodos?.sessionId ?? restoreSessionIds[0];
|
|
638831
639371
|
if (handoffPrompt) {
|
|
639372
|
+
const safeHandoffPrompt = stripModelContextNoise(handoffPrompt);
|
|
638832
639373
|
const usefulEntries2 = (ctx3?.entries ?? []).filter((entry) => !isManualSessionEntry(entry));
|
|
638833
639374
|
const baseCtx = ctx3 && ctx3.entries.length > 0 ? `
|
|
638834
639375
|
|
|
@@ -638838,7 +639379,7 @@ Recent tasks: ${(usefulEntries2.length > 0 ? usefulEntries2 : ctx3.entries).slic
|
|
|
638838
639379
|
).join(", ")}
|
|
638839
639380
|
</session-recap>` : "";
|
|
638840
639381
|
const prompt2 = appendRestoreBlocks(
|
|
638841
|
-
|
|
639382
|
+
safeHandoffPrompt + (activeTaskAnchor ? `
|
|
638842
639383
|
|
|
638843
639384
|
${activeTaskAnchor}` : "") + baseCtx,
|
|
638844
639385
|
[restoredTodos?.block, historyAnchor?.block]
|
|
@@ -638878,12 +639419,12 @@ ${activeTaskAnchor}` : "") + baseCtx,
|
|
|
638878
639419
|
const last2 = recent[recent.length - 1] ?? ctx3.entries[ctx3.entries.length - 1];
|
|
638879
639420
|
const lastCompleted = [...usefulEntries].reverse().find((entry) => entry.completed);
|
|
638880
639421
|
const latestCompleted = lastCompleted ? `Latest completed task: ${normalizeSessionText(lastCompleted.assistantResponse || lastCompleted.summary || lastCompleted.task, 180)}` : "";
|
|
638881
|
-
const
|
|
638882
|
-
const assistant = normalizeSessionText(entry.assistantResponse || entry.summary, 320) || "(no assistant reply captured)";
|
|
639422
|
+
const recentTaskState = recent.slice(-8).map((entry) => {
|
|
638883
639423
|
const user = cleanPromptForDiary(entry.task).slice(0, 220);
|
|
638884
|
-
|
|
638885
|
-
|
|
638886
|
-
|
|
639424
|
+
const outcome = normalizeSessionText(entry.assistantResponse || entry.summary, 240);
|
|
639425
|
+
const status = entry.completed ? "done" : "partial";
|
|
639426
|
+
return `- [${status}] user_intent="${user}"${outcome ? ` outcome="${outcome}"` : ""}`;
|
|
639427
|
+
}).join("\n");
|
|
638887
639428
|
const prov = last2.provenance ? `
|
|
638888
639429
|
Provenance: ${last2.provenance} (file_read to expand)` : "";
|
|
638889
639430
|
const kg = `
|
|
@@ -638898,8 +639439,8 @@ ${chronology.join("\n")}
|
|
|
638898
639439
|
` + (latestCompleted ? `
|
|
638899
639440
|
${latestCompleted}
|
|
638900
639441
|
` : "\n") + `
|
|
638901
|
-
|
|
638902
|
-
${
|
|
639442
|
+
Recent structured task state (older to newer; transcript omitted from model context):
|
|
639443
|
+
${recentTaskState}
|
|
638903
639444
|
` + (activeTaskAnchor ? `For continuation prompts, resume the active task anchor above; use chronology only to avoid repeating completed work.${prov}${kg}
|
|
638904
639445
|
` : `Continue from the latest exchange and do not repeat completed work.${prov}${kg}
|
|
638905
639446
|
`) + `</session-recap>`,
|
|
@@ -639310,7 +639851,7 @@ function deleteUsageRecord(kind, value2, repoRoot) {
|
|
|
639310
639851
|
remove(join136(repoRoot, OMNIUS_DIR, USAGE_HISTORY_FILE));
|
|
639311
639852
|
}
|
|
639312
639853
|
}
|
|
639313
|
-
var OMNIUS_DIR, LEGACY_DIRS, SUBDIRS, gitignoreWatchers, gitignoreRetryTimers, CONTEXT_FILES, PENDING_TASK_FILE, HANDOFF_FILE, CONTEXT_SAVE_FILE, CONTEXT_LEDGER_FILE, MAX_CONTEXT_ENTRIES, MAX_SESSION_DIARY_ENTRIES, MAX_SESSION_DIARY_DETAILED_ENTRIES, MAX_CONTEXT_LEDGER_LINES, MAX_CONTEXT_LEDGER_BYTES, SAME_TASK_REPLACE_WINDOW_MS, LOCK_TIMEOUT_MS, LOCK_RETRY_MS, LOCK_RETRY_MAX, DEFAULT_RESTORED_SESSION_HISTORY_MAX_LINES, DEICTIC_CONTINUATION_TERMS, SESSIONS_DIR, SESSIONS_INDEX, TUI_STATE_SUFFIX, AUTHORED_SESSION_LINE, VISUAL_CHROME_LINE, SKIP_DIRS3, HOME_SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
639854
|
+
var OMNIUS_DIR, LEGACY_DIRS, SUBDIRS, gitignoreWatchers, gitignoreRetryTimers, CONTEXT_FILES, PENDING_TASK_FILE, HANDOFF_FILE, CONTEXT_SAVE_FILE, CONTEXT_LEDGER_FILE, MAX_CONTEXT_ENTRIES, MAX_SESSION_DIARY_ENTRIES, MAX_SESSION_DIARY_DETAILED_ENTRIES, MAX_CONTEXT_LEDGER_LINES, MAX_CONTEXT_LEDGER_BYTES, SAME_TASK_REPLACE_WINDOW_MS, LOCK_TIMEOUT_MS, LOCK_RETRY_MS, LOCK_RETRY_MAX, MODEL_CONTEXT_NOISE_LINE_RE, DEFAULT_RESTORED_SESSION_HISTORY_MAX_LINES, DEICTIC_CONTINUATION_TERMS, SESSIONS_DIR, SESSIONS_INDEX, TUI_STATE_SUFFIX, AUTHORED_SESSION_LINE, VISUAL_CHROME_LINE, SKIP_DIRS3, HOME_SKIP_DIRS, USAGE_HISTORY_FILE, MAX_HISTORY_RECORDS;
|
|
639314
639855
|
var init_omnius_directory = __esm({
|
|
639315
639856
|
"packages/cli/src/tui/omnius-directory.ts"() {
|
|
639316
639857
|
init_dist5();
|
|
@@ -639343,6 +639884,7 @@ var init_omnius_directory = __esm({
|
|
|
639343
639884
|
LOCK_TIMEOUT_MS = 5e3;
|
|
639344
639885
|
LOCK_RETRY_MS = 50;
|
|
639345
639886
|
LOCK_RETRY_MAX = 100;
|
|
639887
|
+
MODEL_CONTEXT_NOISE_LINE_RE = /^\s*(?:๐|E Task timeout reached|E Incomplete:|โ Task incomplete|Tokens:\s*[\d,]+|โน\s*continue\b|ยท\s*(?:Starting fresh|Context (?:auto-)?restored|Nexus P2P network connected|REST API:|Voice feedback enabled|Memory maintenance:)|.*\bSHELL TRANSCRIPT\b.*).*$/i;
|
|
639346
639888
|
DEFAULT_RESTORED_SESSION_HISTORY_MAX_LINES = 600;
|
|
639347
639889
|
DEICTIC_CONTINUATION_TERMS = /* @__PURE__ */ new Set([
|
|
639348
639890
|
"again",
|
|
@@ -641822,13 +642364,18 @@ function loadSessionHistory2(repoRoot) {
|
|
|
641822
642364
|
const exchanges = sessionCtx?.entries.slice(-2) ?? [];
|
|
641823
642365
|
if (exchanges.length > 0) {
|
|
641824
642366
|
if (lines.length > 1) lines.push("");
|
|
641825
|
-
lines.push("
|
|
642367
|
+
lines.push("Recent structured task outcomes:");
|
|
641826
642368
|
for (const entry of exchanges) {
|
|
641827
642369
|
const user = cleanForStorage(entry.task) || entry.task;
|
|
641828
642370
|
const assistant = cleanForStorage(entry.assistantResponse || entry.summary) || entry.assistantResponse || entry.summary;
|
|
641829
642371
|
if (!assistant) continue;
|
|
641830
|
-
|
|
641831
|
-
lines.push(
|
|
642372
|
+
const status = entry.completed ? "done" : "partial";
|
|
642373
|
+
lines.push(
|
|
642374
|
+
`- [${status}] intent=${truncateProjectContextText(user, 120, "")}`
|
|
642375
|
+
);
|
|
642376
|
+
lines.push(
|
|
642377
|
+
` outcome=${truncateProjectContextText(assistant, 160, "")}`
|
|
642378
|
+
);
|
|
641832
642379
|
}
|
|
641833
642380
|
}
|
|
641834
642381
|
return lines.length > 1 ? lines.join("\n") : "";
|
|
@@ -701239,7 +701786,7 @@ ${mediaContext}` : ""
|
|
|
701239
701786
|
telegramMemoryIngestPayload(msg, media, localPath, source, extractedContent) {
|
|
701240
701787
|
const isReplyMedia = source === "reply";
|
|
701241
701788
|
const messageId = isReplyMedia ? msg.replyToMessageId : msg.messageId;
|
|
701242
|
-
const
|
|
701789
|
+
const messageText2 = isReplyMedia ? msg.replyContext?.text || msg.replyContext?.caption || msg.replyToText || media.caption : msg.text || media.caption;
|
|
701243
701790
|
const sender = isReplyMedia ? this.telegramMemorySenderFromReply(msg) : this.telegramMemorySenderFromMessage(msg);
|
|
701244
701791
|
const modality = media.type === "audio" || media.type === "voice" ? "audio" : telegramMediaIsImage(media) ? "visual" : "text";
|
|
701245
701792
|
const objectLabels = extractExplicitVisualObjectLabels({
|
|
@@ -701259,7 +701806,7 @@ ${mediaContext}` : ""
|
|
|
701259
701806
|
id: messageId,
|
|
701260
701807
|
threadId: msg.messageThreadId,
|
|
701261
701808
|
timestamp: Date.now(),
|
|
701262
|
-
text:
|
|
701809
|
+
text: messageText2
|
|
701263
701810
|
},
|
|
701264
701811
|
replyTo: !isReplyMedia ? this.telegramMemoryReplyRef(msg) : void 0,
|
|
701265
701812
|
modality,
|
|
@@ -756351,7 +756898,7 @@ Respond concisely and safely. Remember: you are talking to the general public.`;
|
|
|
756351
756898
|
},
|
|
756352
756899
|
setRestoredContext(ctx3) {
|
|
756353
756900
|
if (typeof ctx3 === "string") {
|
|
756354
|
-
restoredSessionContext = ctx3;
|
|
756901
|
+
restoredSessionContext = sanitizeRestorePromptForModel(ctx3);
|
|
756355
756902
|
} else {
|
|
756356
756903
|
applyRestoreSnapshot(ctx3, { replayVisual: false });
|
|
756357
756904
|
}
|
|
@@ -757342,7 +757889,8 @@ ${formatTaskCompletionMeta(previousMetaForIntake)}`
|
|
|
757342
757889
|
let taskInput = fullInput;
|
|
757343
757890
|
let taskSessionId = restoredTaskSessionId;
|
|
757344
757891
|
if (restoredSessionContext) {
|
|
757345
|
-
|
|
757892
|
+
const safeRestoredContext = sanitizeRestorePromptForModel(restoredSessionContext);
|
|
757893
|
+
taskInput = `${safeRestoredContext}
|
|
757346
757894
|
|
|
757347
757895
|
---
|
|
757348
757896
|
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.533",
|
|
4
4
|
"lockfileVersion": 3,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"packages": {
|
|
7
7
|
"": {
|
|
8
8
|
"name": "omnius",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.533",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED