@bman654/clodex 2.1.8 → 2.1.9
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/cli.js +22 -11
- package/dist/cli.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -217,7 +217,7 @@ import { join } from "path";
|
|
|
217
217
|
// package.json
|
|
218
218
|
var package_default = {
|
|
219
219
|
name: "@bman654/clodex",
|
|
220
|
-
version: "2.1.
|
|
220
|
+
version: "2.1.9",
|
|
221
221
|
publishConfig: {
|
|
222
222
|
access: "public"
|
|
223
223
|
},
|
|
@@ -4523,20 +4523,28 @@ function continuationMismatchSummary(entry, payload, log12) {
|
|
|
4523
4523
|
const details = continuationMismatchDetails(entry, payload, log12, true);
|
|
4524
4524
|
return `full_items=${details.fullItems} expected_prefix_items=${details.expectedPrefixItems} first_mismatch=${details.firstMismatch} expected=${details.expectedKind} actual=${details.actualKind}`;
|
|
4525
4525
|
}
|
|
4526
|
-
function
|
|
4526
|
+
function canonicalItemStrings(items) {
|
|
4527
|
+
return items.map((item) => canonicalJson(normalizeToolCallJson([item])));
|
|
4528
|
+
}
|
|
4529
|
+
function isStrictPrefix(head, client) {
|
|
4530
|
+
if (client.length <= head.length) return false;
|
|
4531
|
+
for (let index = 0; index < head.length; index += 1) {
|
|
4532
|
+
if (head[index] !== client[index]) return false;
|
|
4533
|
+
}
|
|
4534
|
+
return true;
|
|
4535
|
+
}
|
|
4536
|
+
function continuationMatch(entry, payload, clientItems) {
|
|
4527
4537
|
if (!entry.responseId || !entry.requestInput || !entry.expectedAssistant) return void 0;
|
|
4528
4538
|
const full = inputArray(payload);
|
|
4529
|
-
|
|
4530
|
-
if (
|
|
4531
|
-
return { delta: full.slice(
|
|
4539
|
+
entry.canonicalPrefix ??= canonicalItemStrings([...entry.requestInput, ...entry.expectedAssistant]);
|
|
4540
|
+
if (isStrictPrefix(entry.canonicalPrefix, clientItems)) {
|
|
4541
|
+
return { delta: full.slice(entry.canonicalPrefix.length), mode: "exact" };
|
|
4532
4542
|
}
|
|
4533
4543
|
const echoedAssistant = entry.expectedAssistant.filter((item) => conversationItemKind(item) !== "reasoning");
|
|
4534
4544
|
if (echoedAssistant.length === entry.expectedAssistant.length) return void 0;
|
|
4535
|
-
|
|
4536
|
-
if (
|
|
4537
|
-
|
|
4538
|
-
}
|
|
4539
|
-
return { delta: full.slice(echoablePrefix.length), mode: "omitted_reasoning" };
|
|
4545
|
+
entry.canonicalEchoablePrefix ??= canonicalItemStrings([...entry.requestInput, ...echoedAssistant]);
|
|
4546
|
+
if (!isStrictPrefix(entry.canonicalEchoablePrefix, clientItems)) return void 0;
|
|
4547
|
+
return { delta: full.slice(entry.canonicalEchoablePrefix.length), mode: "omitted_reasoning" };
|
|
4540
4548
|
}
|
|
4541
4549
|
function eventType(event) {
|
|
4542
4550
|
return event && typeof event === "object" && typeof event.type === "string" ? event.type : void 0;
|
|
@@ -5156,6 +5164,8 @@ function handleSocketMessage(entry, data) {
|
|
|
5156
5164
|
entry.responseId = ctx.responseId;
|
|
5157
5165
|
entry.requestInput = inputArray(ctx.originalPayload);
|
|
5158
5166
|
entry.expectedAssistant = expectedAssistantItems(ctx);
|
|
5167
|
+
entry.canonicalPrefix = void 0;
|
|
5168
|
+
entry.canonicalEchoablePrefix = void 0;
|
|
5159
5169
|
entry.promptFieldHashes = ctx.promptFieldHashes;
|
|
5160
5170
|
entry.instructionsSnapshot = ctx.instructionsSnapshot;
|
|
5161
5171
|
entry.lastUsedAt = now;
|
|
@@ -5318,7 +5328,8 @@ function createResponsesWebSocketFetch(wsUrl, log12, options = {}) {
|
|
|
5318
5328
|
const evictions = cleanupExpiredConnections(now);
|
|
5319
5329
|
const candidates = partitionKey ? connectionEntries(partitionKey) : [];
|
|
5320
5330
|
const idleCandidates = candidates.filter((entry) => !entry.inFlight);
|
|
5321
|
-
const
|
|
5331
|
+
const clientItems = idleCandidates.length ? canonicalItemStrings(inputArray(payload)) : [];
|
|
5332
|
+
const matches = idleCandidates.map((entry) => ({ entry, match: continuationMatch(entry, payload, clientItems) })).filter((candidate) => candidate.match !== void 0).sort((left, right) => left.match.delta.length - right.match.delta.length || (left.match.mode === right.match.mode ? 0 : left.match.mode === "exact" ? -1 : 1));
|
|
5322
5333
|
let selected = matches[0]?.entry;
|
|
5323
5334
|
const selectedMatch = matches[0]?.match;
|
|
5324
5335
|
const selectedDelta = selectedMatch?.delta;
|