omnius 1.0.458 → 1.0.459
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 +125 -14
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -572346,6 +572346,20 @@ var init_streaming_executor = __esm({
|
|
|
572346
572346
|
setExecutor(fn) {
|
|
572347
572347
|
this.executeFn = fn;
|
|
572348
572348
|
}
|
|
572349
|
+
/** Rename a queued streaming tool entry when the provider reveals its real id late. */
|
|
572350
|
+
rename(oldId, newId) {
|
|
572351
|
+
if (!oldId || !newId || oldId === newId)
|
|
572352
|
+
return;
|
|
572353
|
+
const entry = this.tools.get(oldId);
|
|
572354
|
+
if (!entry || this.tools.has(newId))
|
|
572355
|
+
return;
|
|
572356
|
+
this.tools.delete(oldId);
|
|
572357
|
+
entry.id = newId;
|
|
572358
|
+
this.tools.set(newId, entry);
|
|
572359
|
+
const idx = this.insertionOrder.indexOf(oldId);
|
|
572360
|
+
if (idx >= 0)
|
|
572361
|
+
this.insertionOrder[idx] = newId;
|
|
572362
|
+
}
|
|
572349
572363
|
/** Update the parsed-input concurrency classifier. */
|
|
572350
572364
|
setConcurrencyResolver(fn) {
|
|
572351
572365
|
this.config.concurrencyResolver = fn;
|
|
@@ -572583,7 +572597,7 @@ var init_streaming_executor = __esm({
|
|
|
572583
572597
|
entry.state = "executing";
|
|
572584
572598
|
entry.startedAt = Date.now();
|
|
572585
572599
|
const exec7 = this.executeFn;
|
|
572586
|
-
entry.promise = exec7(entry.name, entry.args).then((result) => {
|
|
572600
|
+
entry.promise = exec7(entry.id, entry.name, entry.args).then((result) => {
|
|
572587
572601
|
entry.state = "completed";
|
|
572588
572602
|
entry.result = result;
|
|
572589
572603
|
entry.completedAt = Date.now();
|
|
@@ -574740,8 +574754,87 @@ function diagnoseContextDump(record) {
|
|
|
574740
574754
|
if (record.metrics.estimatedTokens > 1e5) {
|
|
574741
574755
|
diagnoses.add("large-context-window");
|
|
574742
574756
|
}
|
|
574757
|
+
if (hasToolResultBindingMismatch(record)) {
|
|
574758
|
+
diagnoses.add("tool-result-binding-mismatch");
|
|
574759
|
+
}
|
|
574743
574760
|
return [...diagnoses].sort();
|
|
574744
574761
|
}
|
|
574762
|
+
function hasToolResultBindingMismatch(record) {
|
|
574763
|
+
const messages2 = Array.isArray(record.request?.["messages"]) ? record.request["messages"] : [];
|
|
574764
|
+
if (messages2.length === 0)
|
|
574765
|
+
return false;
|
|
574766
|
+
const callsById = /* @__PURE__ */ new Map();
|
|
574767
|
+
for (const message2 of messages2) {
|
|
574768
|
+
if (message2["role"] !== "assistant")
|
|
574769
|
+
continue;
|
|
574770
|
+
const calls = Array.isArray(message2["tool_calls"]) ? message2["tool_calls"] : [];
|
|
574771
|
+
for (const call of calls) {
|
|
574772
|
+
const id2 = typeof call["id"] === "string" ? call["id"] : "";
|
|
574773
|
+
const fn = call["function"] && typeof call["function"] === "object" ? call["function"] : {};
|
|
574774
|
+
const name10 = typeof fn["name"] === "string" ? fn["name"] : "";
|
|
574775
|
+
const argsRaw = typeof fn["arguments"] === "string" ? fn["arguments"] : "{}";
|
|
574776
|
+
let args = {};
|
|
574777
|
+
try {
|
|
574778
|
+
args = JSON.parse(argsRaw);
|
|
574779
|
+
} catch {
|
|
574780
|
+
args = {};
|
|
574781
|
+
}
|
|
574782
|
+
if (id2)
|
|
574783
|
+
callsById.set(id2, { name: name10, args });
|
|
574784
|
+
}
|
|
574785
|
+
}
|
|
574786
|
+
for (const message2 of messages2) {
|
|
574787
|
+
if (message2["role"] !== "tool")
|
|
574788
|
+
continue;
|
|
574789
|
+
const id2 = typeof message2["tool_call_id"] === "string" ? message2["tool_call_id"] : "";
|
|
574790
|
+
const call = id2 ? callsById.get(id2) : void 0;
|
|
574791
|
+
if (!call)
|
|
574792
|
+
continue;
|
|
574793
|
+
const requested = extractToolTarget(call.args);
|
|
574794
|
+
if (!requested)
|
|
574795
|
+
continue;
|
|
574796
|
+
const content = typeof message2["content"] === "string" ? message2["content"] : "";
|
|
574797
|
+
const reported = extractReportedToolTarget(content);
|
|
574798
|
+
if (!reported)
|
|
574799
|
+
continue;
|
|
574800
|
+
if (!targetsCompatible(requested, reported))
|
|
574801
|
+
return true;
|
|
574802
|
+
}
|
|
574803
|
+
return false;
|
|
574804
|
+
}
|
|
574805
|
+
function extractToolTarget(args) {
|
|
574806
|
+
const value2 = args["path"] ?? args["file"] ?? args["file_path"] ?? args["filepath"] ?? args["directory"] ?? args["cwd"];
|
|
574807
|
+
return typeof value2 === "string" ? value2.trim() : "";
|
|
574808
|
+
}
|
|
574809
|
+
function extractReportedToolTarget(content) {
|
|
574810
|
+
const patterns = [
|
|
574811
|
+
/^target=([^\n\r]+)/m,
|
|
574812
|
+
/^path=([^\n\r]+)/m,
|
|
574813
|
+
/\bfile\s+([^\s]+)\s+already contains/i,
|
|
574814
|
+
/\bEdited\s+([^\s]+)\s+at line/i,
|
|
574815
|
+
/\bat\s+([^\s]+)\s+\(sha256\b/i,
|
|
574816
|
+
/\bRefusing to (?:edit|overwrite existing file)\s+([^\s]+)/i
|
|
574817
|
+
];
|
|
574818
|
+
for (const pattern of patterns) {
|
|
574819
|
+
const match = content.match(pattern);
|
|
574820
|
+
const raw = match?.[1]?.trim();
|
|
574821
|
+
if (raw)
|
|
574822
|
+
return raw.replace(/[),.;:]+$/, "");
|
|
574823
|
+
}
|
|
574824
|
+
return "";
|
|
574825
|
+
}
|
|
574826
|
+
function targetsCompatible(requested, reported) {
|
|
574827
|
+
const left = normalizeTargetForCompare(requested);
|
|
574828
|
+
const right = normalizeTargetForCompare(reported);
|
|
574829
|
+
if (!left || !right)
|
|
574830
|
+
return true;
|
|
574831
|
+
if (left === right)
|
|
574832
|
+
return true;
|
|
574833
|
+
return left.endsWith(`/${right}`) || right.endsWith(`/${left}`);
|
|
574834
|
+
}
|
|
574835
|
+
function normalizeTargetForCompare(value2) {
|
|
574836
|
+
return value2.trim().replace(/^["']|["']$/g, "").replace(/\\/g, "/").replace(/\/+/g, "/").replace(/\/$/, "");
|
|
574837
|
+
}
|
|
574745
574838
|
function summarizeToolEvent(toolName, success, diagnoses, command) {
|
|
574746
574839
|
const status = success ? "success" : "failure";
|
|
574747
574840
|
const parts = [`${toolName} ${status}`];
|
|
@@ -574853,6 +574946,7 @@ function writeContract(contractPath) {
|
|
|
574853
574946
|
"- `focus-supervisor-cached-evidence`: the focus supervisor short-circuited a call successfully by reusing current cached evidence.",
|
|
574854
574947
|
"- `background-task-id-missing`: task status lookup could not find the spawned task id.",
|
|
574855
574948
|
"- `raw-discovery-dominates-context`: context-window metrics show low signal/noise around raw discovery output.",
|
|
574949
|
+
"- `tool-result-binding-mismatch`: the outbound model transcript contains a tool result whose reported target does not match the assistant tool call it is attached to.",
|
|
574856
574950
|
""
|
|
574857
574951
|
].join("\n");
|
|
574858
574952
|
writeFileSync49(contractPath, body, "utf-8");
|
|
@@ -578130,27 +578224,39 @@ function sanitizeHistoryThink(messages2) {
|
|
|
578130
578224
|
const sanitized = [];
|
|
578131
578225
|
for (let i2 = 0; i2 < stripped.length; i2++) {
|
|
578132
578226
|
const current = stripped[i2];
|
|
578133
|
-
|
|
578134
|
-
if (isOrphanDuplicateAssistantToolAnchor(current, next, referencedToolCallIds)) {
|
|
578227
|
+
if (isOrphanDuplicateAssistantToolAnchor(stripped, i2, referencedToolCallIds)) {
|
|
578135
578228
|
continue;
|
|
578136
578229
|
}
|
|
578137
578230
|
sanitized.push(current);
|
|
578138
578231
|
}
|
|
578139
578232
|
return sanitized;
|
|
578140
578233
|
}
|
|
578141
|
-
function isOrphanDuplicateAssistantToolAnchor(
|
|
578142
|
-
|
|
578234
|
+
function isOrphanDuplicateAssistantToolAnchor(messages2, index, referencedToolCallIds) {
|
|
578235
|
+
const current = messages2[index];
|
|
578236
|
+
if (!current)
|
|
578143
578237
|
return false;
|
|
578144
|
-
if (current.role !== "assistant"
|
|
578238
|
+
if (current.role !== "assistant")
|
|
578145
578239
|
return false;
|
|
578146
|
-
if (!Array.isArray(current.tool_calls) ||
|
|
578240
|
+
if (!Array.isArray(current.tool_calls) || current.tool_calls.length === 0) {
|
|
578147
578241
|
return false;
|
|
578148
578242
|
}
|
|
578149
|
-
if (current.
|
|
578243
|
+
if (assistantVisibleText(current).length > 0)
|
|
578150
578244
|
return false;
|
|
578245
|
+
let next;
|
|
578246
|
+
for (let i2 = index + 1; i2 < Math.min(messages2.length, index + 8); i2++) {
|
|
578247
|
+
const candidate = messages2[i2];
|
|
578248
|
+
if (candidate.role === "system")
|
|
578249
|
+
continue;
|
|
578250
|
+
if (candidate.role !== "assistant")
|
|
578251
|
+
return false;
|
|
578252
|
+
next = candidate;
|
|
578253
|
+
break;
|
|
578151
578254
|
}
|
|
578152
|
-
if (
|
|
578255
|
+
if (!next)
|
|
578256
|
+
return false;
|
|
578257
|
+
if (!Array.isArray(next.tool_calls) || next.tool_calls.length === 0) {
|
|
578153
578258
|
return false;
|
|
578259
|
+
}
|
|
578154
578260
|
if (toolCallsFingerprint(current.tool_calls) !== toolCallsFingerprint(next.tool_calls)) {
|
|
578155
578261
|
return false;
|
|
578156
578262
|
}
|
|
@@ -590807,10 +590913,12 @@ Then use file_read on individual FILES inside it.`);
|
|
|
590807
590913
|
const rawToolCalls = msg.toolCalls;
|
|
590808
590914
|
if (this.options.streamEnabled && this._streamingExecutor.hasTools) {
|
|
590809
590915
|
const streamFpInFlight = /* @__PURE__ */ new Map();
|
|
590810
|
-
this._streamingExecutor.setExecutor(async (name10, args) => {
|
|
590811
|
-
|
|
590916
|
+
this._streamingExecutor.setExecutor(async (id2, name10, args) => {
|
|
590917
|
+
const argsFingerprint = this._buildToolFingerprint(name10, args);
|
|
590918
|
+
const exactArgMatches = rawToolCalls.filter((tc) => tc.name === name10 && this._buildToolFingerprint(tc.name, tc.arguments ?? {}) === argsFingerprint);
|
|
590919
|
+
let matchTc = rawToolCalls.find((tc) => tc.id === id2) ?? (exactArgMatches.length === 1 ? exactArgMatches[0] : void 0);
|
|
590812
590920
|
if (!matchTc) {
|
|
590813
|
-
const synthId = globalThis.crypto?.randomUUID?.() || `call_${Date.now()}`;
|
|
590921
|
+
const synthId = id2 || globalThis.crypto?.randomUUID?.() || `call_${Date.now()}`;
|
|
590814
590922
|
matchTc = { id: synthId, name: name10, arguments: args };
|
|
590815
590923
|
messages2.push({
|
|
590816
590924
|
role: "assistant",
|
|
@@ -597200,14 +597308,17 @@ ${description}`
|
|
|
597200
597308
|
}
|
|
597201
597309
|
}
|
|
597202
597310
|
const acc = toolCallAccumulators.get(idx);
|
|
597311
|
+
if (chunk.toolCallId && chunk.toolCallId !== acc.id) {
|
|
597312
|
+
const previousId = acc.id;
|
|
597313
|
+
acc.id = chunk.toolCallId;
|
|
597314
|
+
this._streamingExecutor.rename(previousId, acc.id);
|
|
597315
|
+
}
|
|
597203
597316
|
if (chunk.toolCallName) {
|
|
597204
597317
|
acc.name = chunk.toolCallName;
|
|
597205
597318
|
if (!this._streamingExecutor.getStates().has(acc.id) && acc.name) {
|
|
597206
597319
|
this._streamingExecutor.queue(acc.id, acc.name);
|
|
597207
597320
|
}
|
|
597208
597321
|
}
|
|
597209
|
-
if (chunk.toolCallId)
|
|
597210
|
-
acc.id = chunk.toolCallId;
|
|
597211
597322
|
if (chunk.toolCallArgs) {
|
|
597212
597323
|
acc.args += chunk.toolCallArgs;
|
|
597213
597324
|
}
|
package/npm-shrinkwrap.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "omnius",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.459",
|
|
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.459",
|
|
10
10
|
"bundleDependencies": [
|
|
11
11
|
"image-to-ascii"
|
|
12
12
|
],
|
package/package.json
CHANGED