@tractorscorch/clank 1.4.6 → 1.4.7
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/CHANGELOG.md +8 -0
- package/README.md +2 -2
- package/dist/index.js +55 -7
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/).
|
|
|
6
6
|
|
|
7
7
|
---
|
|
8
8
|
|
|
9
|
+
## [1.4.7] — 2026-03-22
|
|
10
|
+
|
|
11
|
+
### Fixed
|
|
12
|
+
- **Tool calling crashes gateway** — context compaction could split tool call / tool result message pairs, sending orphaned messages to Ollama which returns 400 errors and corrupts the session permanently; compaction now drops complete pairs together
|
|
13
|
+
- **Orphaned tool result safety net** — Ollama provider now filters out orphaned tool results before sending to the API, preventing 400 errors even if compaction misses a pair
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
9
17
|
## [1.4.6] — 2026-03-22
|
|
10
18
|
|
|
11
19
|
### Fixed
|
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
</p>
|
|
10
10
|
|
|
11
11
|
<p align="center">
|
|
12
|
-
<a href="https://github.com/ItsTrag1c/Clank/releases/latest"><img src="https://img.shields.io/badge/version-1.4.
|
|
12
|
+
<a href="https://github.com/ItsTrag1c/Clank/releases/latest"><img src="https://img.shields.io/badge/version-1.4.7-blue.svg" alt="Version" /></a>
|
|
13
13
|
<a href="https://opensource.org/licenses/MIT"><img src="https://img.shields.io/badge/License-MIT-blue.svg" alt="License" /></a>
|
|
14
14
|
<a href="https://www.npmjs.com/package/@tractorscorch/clank"><img src="https://img.shields.io/npm/v/@tractorscorch/clank.svg" alt="npm" /></a>
|
|
15
15
|
<a href="https://github.com/ItsTrag1c/Clank/stargazers"><img src="https://img.shields.io/github/stars/ItsTrag1c/Clank.svg" alt="Stars" /></a>
|
|
@@ -75,7 +75,7 @@ That's it. Setup auto-detects your local models, configures the gateway, and get
|
|
|
75
75
|
| Platform | Download |
|
|
76
76
|
|----------|----------|
|
|
77
77
|
| **npm** (all platforms) | `npm install -g @tractorscorch/clank` |
|
|
78
|
-
| **macOS** (Apple Silicon) | [Clank_1.4.
|
|
78
|
+
| **macOS** (Apple Silicon) | [Clank_1.4.7_macos](https://github.com/ItsTrag1c/Clank/releases/latest/download/Clank_1.4.7_macos) |
|
|
79
79
|
|
|
80
80
|
## Features
|
|
81
81
|
|
package/dist/index.js
CHANGED
|
@@ -216,6 +216,8 @@ var init_context_engine = __esm({
|
|
|
216
216
|
}
|
|
217
217
|
/**
|
|
218
218
|
* Tier 1 aggressive: drop oldest messages when regular compaction isn't enough.
|
|
219
|
+
* Drops tool call + tool result pairs together to avoid orphaned messages
|
|
220
|
+
* that cause API errors (Ollama/OpenAI require matching pairs).
|
|
219
221
|
*/
|
|
220
222
|
compactTier1Aggressive() {
|
|
221
223
|
const protectedCount = 6;
|
|
@@ -223,7 +225,38 @@ var init_context_engine = __esm({
|
|
|
223
225
|
while (this.estimateTokens() > budget.conversation * 0.7 && this.messages.length > protectedCount + 2) {
|
|
224
226
|
const dropIdx = this.messages.findIndex((m) => m.role !== "system");
|
|
225
227
|
if (dropIdx === -1 || dropIdx >= this.messages.length - protectedCount) break;
|
|
226
|
-
this.messages
|
|
228
|
+
const msg = this.messages[dropIdx];
|
|
229
|
+
if (msg.role === "assistant" && msg.tool_calls && msg.tool_calls.length > 0) {
|
|
230
|
+
const toolCallIds = new Set(msg.tool_calls.map((tc) => tc.id));
|
|
231
|
+
this.messages.splice(dropIdx, 1);
|
|
232
|
+
for (let i = dropIdx; i < this.messages.length; ) {
|
|
233
|
+
if (this.messages[i].role === "tool" && toolCallIds.has(this.messages[i].tool_call_id || "")) {
|
|
234
|
+
this.messages.splice(i, 1);
|
|
235
|
+
} else {
|
|
236
|
+
break;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
} else if (msg.role === "tool" && msg.tool_call_id) {
|
|
240
|
+
const parentIdx = this.messages.findLastIndex(
|
|
241
|
+
(m, idx) => idx < dropIdx && m.role === "assistant" && m.tool_calls?.some((tc) => tc.id === msg.tool_call_id)
|
|
242
|
+
);
|
|
243
|
+
if (parentIdx >= 0) {
|
|
244
|
+
const parent = this.messages[parentIdx];
|
|
245
|
+
const parentToolIds = new Set(parent.tool_calls.map((tc) => tc.id));
|
|
246
|
+
this.messages.splice(parentIdx, 1);
|
|
247
|
+
for (let i = parentIdx; i < this.messages.length; ) {
|
|
248
|
+
if (this.messages[i].role === "tool" && parentToolIds.has(this.messages[i].tool_call_id || "")) {
|
|
249
|
+
this.messages.splice(i, 1);
|
|
250
|
+
} else {
|
|
251
|
+
break;
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
} else {
|
|
255
|
+
this.messages.splice(dropIdx, 1);
|
|
256
|
+
}
|
|
257
|
+
} else {
|
|
258
|
+
this.messages.splice(dropIdx, 1);
|
|
259
|
+
}
|
|
227
260
|
}
|
|
228
261
|
}
|
|
229
262
|
/**
|
|
@@ -238,7 +271,10 @@ var init_context_engine = __esm({
|
|
|
238
271
|
if (!this.provider) return;
|
|
239
272
|
const protectedCount = 6;
|
|
240
273
|
if (this.messages.length <= protectedCount + 2) return;
|
|
241
|
-
|
|
274
|
+
let cutoff = Math.max(2, this.messages.length - protectedCount - 2);
|
|
275
|
+
while (cutoff < this.messages.length && this.messages[cutoff].role === "tool") {
|
|
276
|
+
cutoff++;
|
|
277
|
+
}
|
|
242
278
|
const toSummarize = this.messages.slice(0, cutoff);
|
|
243
279
|
const toKeep = this.messages.slice(cutoff);
|
|
244
280
|
const conversationText = toSummarize.map((m) => {
|
|
@@ -478,11 +514,23 @@ var init_ollama = __esm({
|
|
|
478
514
|
}));
|
|
479
515
|
}
|
|
480
516
|
async *stream(messages, systemPrompt, tools, signal) {
|
|
517
|
+
const toolCallIds = /* @__PURE__ */ new Set();
|
|
518
|
+
for (const msg of messages) {
|
|
519
|
+
if (msg.role === "assistant" && msg.tool_calls) {
|
|
520
|
+
for (const tc of msg.tool_calls) toolCallIds.add(tc.id);
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
const sanitized = messages.filter((msg) => {
|
|
524
|
+
if (msg.role === "tool" && msg.tool_call_id && !toolCallIds.has(msg.tool_call_id)) {
|
|
525
|
+
return false;
|
|
526
|
+
}
|
|
527
|
+
return true;
|
|
528
|
+
});
|
|
481
529
|
const apiMessages = [];
|
|
482
530
|
if (systemPrompt) {
|
|
483
531
|
apiMessages.push({ role: "system", content: systemPrompt });
|
|
484
532
|
}
|
|
485
|
-
for (const msg of
|
|
533
|
+
for (const msg of sanitized) {
|
|
486
534
|
if (msg.role === "tool") {
|
|
487
535
|
apiMessages.push({
|
|
488
536
|
role: "tool",
|
|
@@ -6078,7 +6126,7 @@ var init_server = __esm({
|
|
|
6078
6126
|
res.writeHead(200, { "Content-Type": "application/json" });
|
|
6079
6127
|
res.end(JSON.stringify({
|
|
6080
6128
|
status: "ok",
|
|
6081
|
-
version: "1.4.
|
|
6129
|
+
version: "1.4.7",
|
|
6082
6130
|
uptime: process.uptime(),
|
|
6083
6131
|
clients: this.clients.size,
|
|
6084
6132
|
agents: this.engines.size
|
|
@@ -6190,7 +6238,7 @@ var init_server = __esm({
|
|
|
6190
6238
|
const hello = {
|
|
6191
6239
|
type: "hello",
|
|
6192
6240
|
protocol: PROTOCOL_VERSION,
|
|
6193
|
-
version: "1.4.
|
|
6241
|
+
version: "1.4.7",
|
|
6194
6242
|
agents: this.config.agents.list.map((a) => ({
|
|
6195
6243
|
id: a.id,
|
|
6196
6244
|
name: a.name || a.id,
|
|
@@ -7584,7 +7632,7 @@ async function runTui(opts) {
|
|
|
7584
7632
|
ws.on("open", () => {
|
|
7585
7633
|
ws.send(JSON.stringify({
|
|
7586
7634
|
type: "connect",
|
|
7587
|
-
params: { auth: { token }, mode: "tui", version: "1.4.
|
|
7635
|
+
params: { auth: { token }, mode: "tui", version: "1.4.7" }
|
|
7588
7636
|
}));
|
|
7589
7637
|
});
|
|
7590
7638
|
ws.on("message", (data) => {
|
|
@@ -8013,7 +8061,7 @@ import { fileURLToPath as fileURLToPath5 } from "url";
|
|
|
8013
8061
|
import { dirname as dirname5, join as join19 } from "path";
|
|
8014
8062
|
var __filename3 = fileURLToPath5(import.meta.url);
|
|
8015
8063
|
var __dirname3 = dirname5(__filename3);
|
|
8016
|
-
var version = "1.4.
|
|
8064
|
+
var version = "1.4.7";
|
|
8017
8065
|
try {
|
|
8018
8066
|
const pkg = JSON.parse(readFileSync(join19(__dirname3, "..", "package.json"), "utf-8"));
|
|
8019
8067
|
version = pkg.version;
|