@elvatis_com/openclaw-cli-bridge-elvatis 1.8.2 → 1.8.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elvatis_com/openclaw-cli-bridge-elvatis",
3
- "version": "1.8.2",
3
+ "version": "1.8.4",
4
4
  "description": "Bridges gemini, claude, and codex CLI tools as OpenClaw model providers. Reads existing CLI auth without re-login.",
5
5
  "type": "module",
6
6
  "openclaw": {
@@ -22,4 +22,4 @@
22
22
  "dependencies": {
23
23
  "playwright": "^1.58.2"
24
24
  }
25
- }
25
+ }
@@ -562,7 +562,32 @@ async function handleRequest(
562
562
  if (model.startsWith("local-bitnet/")) {
563
563
  const bitnetUrl = opts.getBitNetServerUrl?.() ?? "http://127.0.0.1:8082";
564
564
  const timeoutMs = opts.timeoutMs ?? 120_000;
565
- const requestBody = JSON.stringify(parsed);
565
+ // llama-server (BitNet build) crashes with std::runtime_error on multi-part
566
+ // content arrays (ref: https://github.com/ggerganov/llama.cpp/issues/8367).
567
+ // Flatten all message content to plain strings before forwarding.
568
+ const flattenContent = (content: unknown): string => {
569
+ if (typeof content === "string") return content;
570
+ if (Array.isArray(content)) {
571
+ return content
572
+ .filter((c): c is { type: string; text?: string } => typeof c === "object" && c !== null)
573
+ .map((c) => (c.type === "text" && typeof c.text === "string" ? c.text : ""))
574
+ .join("");
575
+ }
576
+ return String(content ?? "");
577
+ };
578
+ // BitNet has a 4096 token context window. Long sessions blow it up and
579
+ // cause a hard C++ crash (no graceful error). Truncate to system prompt +
580
+ // last 10 messages (~2k tokens max) to stay safely within the limit.
581
+ const BITNET_MAX_MESSAGES = 10;
582
+ const allFlat = parsed.messages.map((m) => ({
583
+ role: m.role,
584
+ content: flattenContent(m.content),
585
+ }));
586
+ const systemMsgs = allFlat.filter((m) => m.role === "system");
587
+ const nonSystemMsgs = allFlat.filter((m) => m.role !== "system");
588
+ const truncated = nonSystemMsgs.slice(-BITNET_MAX_MESSAGES);
589
+ const bitnetMessages = [...systemMsgs, ...truncated];
590
+ const requestBody = JSON.stringify({ ...parsed, messages: bitnetMessages, tools: undefined });
566
591
 
567
592
  try {
568
593
  const targetUrl = new URL("/v1/chat/completions", bitnetUrl);