@bgicli/bgicli 2.8.1 → 2.8.3
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/bgi.js +101 -5
- package/dist/bio.js +101 -5
- package/dist/mbp.js +101 -5
- package/package.json +1 -1
package/dist/bgi.js
CHANGED
|
@@ -15271,6 +15271,96 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15271
15271
|
let finishReason = null;
|
|
15272
15272
|
let inputTokens = 0;
|
|
15273
15273
|
let outputTokens = 0;
|
|
15274
|
+
const THINK_OPEN = "<think>";
|
|
15275
|
+
const THINK_CLOSE = "</think>";
|
|
15276
|
+
const SPIN_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
15277
|
+
let pendingBuf = "";
|
|
15278
|
+
let inThink = false;
|
|
15279
|
+
let thinkBuf = "";
|
|
15280
|
+
let thinkStartMs = 0;
|
|
15281
|
+
let spinInterval = null;
|
|
15282
|
+
let spinIdx = 0;
|
|
15283
|
+
let normalWritten = false;
|
|
15284
|
+
const writeNormal = (s2) => {
|
|
15285
|
+
if (!s2) return;
|
|
15286
|
+
process.stdout.write(s2);
|
|
15287
|
+
text += s2;
|
|
15288
|
+
normalWritten = true;
|
|
15289
|
+
};
|
|
15290
|
+
const startThinkBlock = () => {
|
|
15291
|
+
inThink = true;
|
|
15292
|
+
thinkBuf = "";
|
|
15293
|
+
thinkStartMs = Date.now();
|
|
15294
|
+
if (!normalWritten) process.stdout.write("\n");
|
|
15295
|
+
process.stdout.write(source_default.dim(" \u280B \u601D\u8003\u4E2D..."));
|
|
15296
|
+
spinIdx = 0;
|
|
15297
|
+
spinInterval = setInterval(() => {
|
|
15298
|
+
spinIdx = (spinIdx + 1) % SPIN_FRAMES.length;
|
|
15299
|
+
process.stdout.write(`\r${source_default.dim(` ${SPIN_FRAMES[spinIdx]} \u601D\u8003\u4E2D...`)}`);
|
|
15300
|
+
}, 80);
|
|
15301
|
+
};
|
|
15302
|
+
const endThinkBlock = () => {
|
|
15303
|
+
if (spinInterval) {
|
|
15304
|
+
clearInterval(spinInterval);
|
|
15305
|
+
spinInterval = null;
|
|
15306
|
+
}
|
|
15307
|
+
process.stdout.write("\r\x1B[K");
|
|
15308
|
+
const elapsed = ((Date.now() - thinkStartMs) / 1e3).toFixed(1);
|
|
15309
|
+
const trimmed = thinkBuf.trim();
|
|
15310
|
+
if (trimmed) {
|
|
15311
|
+
const W2 = 44;
|
|
15312
|
+
const suffix = ` \u2713 ${elapsed}s`;
|
|
15313
|
+
process.stdout.write(source_default.dim(` \u256D${"\u2500".repeat(W2)}
|
|
15314
|
+
`));
|
|
15315
|
+
for (const line of trimmed.split("\n")) {
|
|
15316
|
+
const chunks = line.match(/.{1,78}/g) ?? [""];
|
|
15317
|
+
for (const c2 of chunks) process.stdout.write(source_default.dim(` \u2502 ${c2}
|
|
15318
|
+
`));
|
|
15319
|
+
}
|
|
15320
|
+
process.stdout.write(source_default.dim(` \u2570${"\u2500".repeat(Math.max(0, W2 - suffix.length))}${suffix}
|
|
15321
|
+
|
|
15322
|
+
`));
|
|
15323
|
+
}
|
|
15324
|
+
inThink = false;
|
|
15325
|
+
thinkBuf = "";
|
|
15326
|
+
};
|
|
15327
|
+
const partialTagLen = (s2, tag) => {
|
|
15328
|
+
const max = Math.min(s2.length, tag.length - 1);
|
|
15329
|
+
for (let i2 = max; i2 > 0; i2--) {
|
|
15330
|
+
if (tag.startsWith(s2.slice(-i2))) return i2;
|
|
15331
|
+
}
|
|
15332
|
+
return 0;
|
|
15333
|
+
};
|
|
15334
|
+
const processChunk = (chunk) => {
|
|
15335
|
+
pendingBuf += chunk;
|
|
15336
|
+
let guard = 0;
|
|
15337
|
+
while (pendingBuf.length > 0 && guard++ < 2e4) {
|
|
15338
|
+
if (!inThink) {
|
|
15339
|
+
const openIdx = pendingBuf.indexOf(THINK_OPEN);
|
|
15340
|
+
if (openIdx === -1) {
|
|
15341
|
+
const hold = partialTagLen(pendingBuf, THINK_OPEN);
|
|
15342
|
+
writeNormal(pendingBuf.slice(0, pendingBuf.length - hold));
|
|
15343
|
+
pendingBuf = hold > 0 ? pendingBuf.slice(-hold) : "";
|
|
15344
|
+
break;
|
|
15345
|
+
}
|
|
15346
|
+
writeNormal(pendingBuf.slice(0, openIdx));
|
|
15347
|
+
pendingBuf = pendingBuf.slice(openIdx + THINK_OPEN.length);
|
|
15348
|
+
startThinkBlock();
|
|
15349
|
+
} else {
|
|
15350
|
+
const closeIdx = pendingBuf.indexOf(THINK_CLOSE);
|
|
15351
|
+
if (closeIdx === -1) {
|
|
15352
|
+
const hold = partialTagLen(pendingBuf, THINK_CLOSE);
|
|
15353
|
+
thinkBuf += pendingBuf.slice(0, pendingBuf.length - hold);
|
|
15354
|
+
pendingBuf = hold > 0 ? pendingBuf.slice(-hold) : "";
|
|
15355
|
+
break;
|
|
15356
|
+
}
|
|
15357
|
+
thinkBuf += pendingBuf.slice(0, closeIdx);
|
|
15358
|
+
pendingBuf = pendingBuf.slice(closeIdx + THINK_CLOSE.length);
|
|
15359
|
+
endThinkBlock();
|
|
15360
|
+
if (!normalWritten) process.stdout.write(source_default.green(`${BRAND} \u203A `));
|
|
15361
|
+
}
|
|
15362
|
+
}
|
|
15363
|
+
};
|
|
15274
15364
|
process.stdout.write(source_default.green(`${BRAND} \u203A `));
|
|
15275
15365
|
for await (const chunk of stream) {
|
|
15276
15366
|
if (chunk.usage) {
|
|
@@ -15282,8 +15372,7 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15282
15372
|
const delta = choice.delta;
|
|
15283
15373
|
finishReason = choice.finish_reason ?? finishReason;
|
|
15284
15374
|
if (delta.content) {
|
|
15285
|
-
|
|
15286
|
-
text += delta.content;
|
|
15375
|
+
processChunk(delta.content);
|
|
15287
15376
|
}
|
|
15288
15377
|
if (delta.tool_calls) {
|
|
15289
15378
|
for (const tc of delta.tool_calls) {
|
|
@@ -15303,6 +15392,12 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15303
15392
|
}
|
|
15304
15393
|
}
|
|
15305
15394
|
}
|
|
15395
|
+
if (pendingBuf) writeNormal(pendingBuf);
|
|
15396
|
+
if (inThink) endThinkBlock();
|
|
15397
|
+
if (spinInterval) {
|
|
15398
|
+
clearInterval(spinInterval);
|
|
15399
|
+
spinInterval = null;
|
|
15400
|
+
}
|
|
15306
15401
|
if (text) process.stdout.write("\n");
|
|
15307
15402
|
return {
|
|
15308
15403
|
text,
|
|
@@ -17817,7 +17912,7 @@ function clearCheckpoints(sessionId) {
|
|
|
17817
17912
|
|
|
17818
17913
|
// src/index.ts
|
|
17819
17914
|
var import_fs7 = require("fs");
|
|
17820
|
-
var VERSION2 = "2.8.
|
|
17915
|
+
var VERSION2 = "2.8.3";
|
|
17821
17916
|
var BRAND2 = "bgi".toLowerCase();
|
|
17822
17917
|
var SKILLHUB_HUBS = {
|
|
17823
17918
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
@@ -19630,7 +19725,8 @@ ${summary}` },
|
|
|
19630
19725
|
printHelp();
|
|
19631
19726
|
break;
|
|
19632
19727
|
default:
|
|
19633
|
-
console.log(source_default.
|
|
19728
|
+
console.log(source_default.dim(` \u63D0\u793A: \u672A\u627E\u5230\u547D\u4EE4 /${cmd}\uFF0C\u5C06\u4F5C\u4E3A\u6D88\u606F\u53D1\u9001\u7ED9 AI\u3002\u8F93\u5165 /help \u67E5\u770B\u5168\u90E8\u547D\u4EE4`));
|
|
19729
|
+
return { sendToAI: true };
|
|
19634
19730
|
}
|
|
19635
19731
|
return {};
|
|
19636
19732
|
}
|
|
@@ -19963,7 +20059,7 @@ async function main() {
|
|
|
19963
20059
|
}
|
|
19964
20060
|
if (result.injectHistory) history = result.injectHistory;
|
|
19965
20061
|
if (result.thinkMode !== void 0) thinkMode = result.thinkMode;
|
|
19966
|
-
continue;
|
|
20062
|
+
if (!result.sendToAI) continue;
|
|
19967
20063
|
}
|
|
19968
20064
|
if (trimmed.startsWith("!")) {
|
|
19969
20065
|
const cmd = trimmed.slice(1).trim();
|
package/dist/bio.js
CHANGED
|
@@ -15271,6 +15271,96 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15271
15271
|
let finishReason = null;
|
|
15272
15272
|
let inputTokens = 0;
|
|
15273
15273
|
let outputTokens = 0;
|
|
15274
|
+
const THINK_OPEN = "<think>";
|
|
15275
|
+
const THINK_CLOSE = "</think>";
|
|
15276
|
+
const SPIN_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
15277
|
+
let pendingBuf = "";
|
|
15278
|
+
let inThink = false;
|
|
15279
|
+
let thinkBuf = "";
|
|
15280
|
+
let thinkStartMs = 0;
|
|
15281
|
+
let spinInterval = null;
|
|
15282
|
+
let spinIdx = 0;
|
|
15283
|
+
let normalWritten = false;
|
|
15284
|
+
const writeNormal = (s2) => {
|
|
15285
|
+
if (!s2) return;
|
|
15286
|
+
process.stdout.write(s2);
|
|
15287
|
+
text += s2;
|
|
15288
|
+
normalWritten = true;
|
|
15289
|
+
};
|
|
15290
|
+
const startThinkBlock = () => {
|
|
15291
|
+
inThink = true;
|
|
15292
|
+
thinkBuf = "";
|
|
15293
|
+
thinkStartMs = Date.now();
|
|
15294
|
+
if (!normalWritten) process.stdout.write("\n");
|
|
15295
|
+
process.stdout.write(source_default.dim(" \u280B \u601D\u8003\u4E2D..."));
|
|
15296
|
+
spinIdx = 0;
|
|
15297
|
+
spinInterval = setInterval(() => {
|
|
15298
|
+
spinIdx = (spinIdx + 1) % SPIN_FRAMES.length;
|
|
15299
|
+
process.stdout.write(`\r${source_default.dim(` ${SPIN_FRAMES[spinIdx]} \u601D\u8003\u4E2D...`)}`);
|
|
15300
|
+
}, 80);
|
|
15301
|
+
};
|
|
15302
|
+
const endThinkBlock = () => {
|
|
15303
|
+
if (spinInterval) {
|
|
15304
|
+
clearInterval(spinInterval);
|
|
15305
|
+
spinInterval = null;
|
|
15306
|
+
}
|
|
15307
|
+
process.stdout.write("\r\x1B[K");
|
|
15308
|
+
const elapsed = ((Date.now() - thinkStartMs) / 1e3).toFixed(1);
|
|
15309
|
+
const trimmed = thinkBuf.trim();
|
|
15310
|
+
if (trimmed) {
|
|
15311
|
+
const W2 = 44;
|
|
15312
|
+
const suffix = ` \u2713 ${elapsed}s`;
|
|
15313
|
+
process.stdout.write(source_default.dim(` \u256D${"\u2500".repeat(W2)}
|
|
15314
|
+
`));
|
|
15315
|
+
for (const line of trimmed.split("\n")) {
|
|
15316
|
+
const chunks = line.match(/.{1,78}/g) ?? [""];
|
|
15317
|
+
for (const c2 of chunks) process.stdout.write(source_default.dim(` \u2502 ${c2}
|
|
15318
|
+
`));
|
|
15319
|
+
}
|
|
15320
|
+
process.stdout.write(source_default.dim(` \u2570${"\u2500".repeat(Math.max(0, W2 - suffix.length))}${suffix}
|
|
15321
|
+
|
|
15322
|
+
`));
|
|
15323
|
+
}
|
|
15324
|
+
inThink = false;
|
|
15325
|
+
thinkBuf = "";
|
|
15326
|
+
};
|
|
15327
|
+
const partialTagLen = (s2, tag) => {
|
|
15328
|
+
const max = Math.min(s2.length, tag.length - 1);
|
|
15329
|
+
for (let i2 = max; i2 > 0; i2--) {
|
|
15330
|
+
if (tag.startsWith(s2.slice(-i2))) return i2;
|
|
15331
|
+
}
|
|
15332
|
+
return 0;
|
|
15333
|
+
};
|
|
15334
|
+
const processChunk = (chunk) => {
|
|
15335
|
+
pendingBuf += chunk;
|
|
15336
|
+
let guard = 0;
|
|
15337
|
+
while (pendingBuf.length > 0 && guard++ < 2e4) {
|
|
15338
|
+
if (!inThink) {
|
|
15339
|
+
const openIdx = pendingBuf.indexOf(THINK_OPEN);
|
|
15340
|
+
if (openIdx === -1) {
|
|
15341
|
+
const hold = partialTagLen(pendingBuf, THINK_OPEN);
|
|
15342
|
+
writeNormal(pendingBuf.slice(0, pendingBuf.length - hold));
|
|
15343
|
+
pendingBuf = hold > 0 ? pendingBuf.slice(-hold) : "";
|
|
15344
|
+
break;
|
|
15345
|
+
}
|
|
15346
|
+
writeNormal(pendingBuf.slice(0, openIdx));
|
|
15347
|
+
pendingBuf = pendingBuf.slice(openIdx + THINK_OPEN.length);
|
|
15348
|
+
startThinkBlock();
|
|
15349
|
+
} else {
|
|
15350
|
+
const closeIdx = pendingBuf.indexOf(THINK_CLOSE);
|
|
15351
|
+
if (closeIdx === -1) {
|
|
15352
|
+
const hold = partialTagLen(pendingBuf, THINK_CLOSE);
|
|
15353
|
+
thinkBuf += pendingBuf.slice(0, pendingBuf.length - hold);
|
|
15354
|
+
pendingBuf = hold > 0 ? pendingBuf.slice(-hold) : "";
|
|
15355
|
+
break;
|
|
15356
|
+
}
|
|
15357
|
+
thinkBuf += pendingBuf.slice(0, closeIdx);
|
|
15358
|
+
pendingBuf = pendingBuf.slice(closeIdx + THINK_CLOSE.length);
|
|
15359
|
+
endThinkBlock();
|
|
15360
|
+
if (!normalWritten) process.stdout.write(source_default.green(`${BRAND} \u203A `));
|
|
15361
|
+
}
|
|
15362
|
+
}
|
|
15363
|
+
};
|
|
15274
15364
|
process.stdout.write(source_default.green(`${BRAND} \u203A `));
|
|
15275
15365
|
for await (const chunk of stream) {
|
|
15276
15366
|
if (chunk.usage) {
|
|
@@ -15282,8 +15372,7 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15282
15372
|
const delta = choice.delta;
|
|
15283
15373
|
finishReason = choice.finish_reason ?? finishReason;
|
|
15284
15374
|
if (delta.content) {
|
|
15285
|
-
|
|
15286
|
-
text += delta.content;
|
|
15375
|
+
processChunk(delta.content);
|
|
15287
15376
|
}
|
|
15288
15377
|
if (delta.tool_calls) {
|
|
15289
15378
|
for (const tc of delta.tool_calls) {
|
|
@@ -15303,6 +15392,12 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15303
15392
|
}
|
|
15304
15393
|
}
|
|
15305
15394
|
}
|
|
15395
|
+
if (pendingBuf) writeNormal(pendingBuf);
|
|
15396
|
+
if (inThink) endThinkBlock();
|
|
15397
|
+
if (spinInterval) {
|
|
15398
|
+
clearInterval(spinInterval);
|
|
15399
|
+
spinInterval = null;
|
|
15400
|
+
}
|
|
15306
15401
|
if (text) process.stdout.write("\n");
|
|
15307
15402
|
return {
|
|
15308
15403
|
text,
|
|
@@ -17817,7 +17912,7 @@ function clearCheckpoints(sessionId) {
|
|
|
17817
17912
|
|
|
17818
17913
|
// src/index.ts
|
|
17819
17914
|
var import_fs7 = require("fs");
|
|
17820
|
-
var VERSION2 = "2.8.
|
|
17915
|
+
var VERSION2 = "2.8.3";
|
|
17821
17916
|
var BRAND2 = "bio".toLowerCase();
|
|
17822
17917
|
var SKILLHUB_HUBS = {
|
|
17823
17918
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
@@ -19630,7 +19725,8 @@ ${summary}` },
|
|
|
19630
19725
|
printHelp();
|
|
19631
19726
|
break;
|
|
19632
19727
|
default:
|
|
19633
|
-
console.log(source_default.
|
|
19728
|
+
console.log(source_default.dim(` \u63D0\u793A: \u672A\u627E\u5230\u547D\u4EE4 /${cmd}\uFF0C\u5C06\u4F5C\u4E3A\u6D88\u606F\u53D1\u9001\u7ED9 AI\u3002\u8F93\u5165 /help \u67E5\u770B\u5168\u90E8\u547D\u4EE4`));
|
|
19729
|
+
return { sendToAI: true };
|
|
19634
19730
|
}
|
|
19635
19731
|
return {};
|
|
19636
19732
|
}
|
|
@@ -19963,7 +20059,7 @@ async function main() {
|
|
|
19963
20059
|
}
|
|
19964
20060
|
if (result.injectHistory) history = result.injectHistory;
|
|
19965
20061
|
if (result.thinkMode !== void 0) thinkMode = result.thinkMode;
|
|
19966
|
-
continue;
|
|
20062
|
+
if (!result.sendToAI) continue;
|
|
19967
20063
|
}
|
|
19968
20064
|
if (trimmed.startsWith("!")) {
|
|
19969
20065
|
const cmd = trimmed.slice(1).trim();
|
package/dist/mbp.js
CHANGED
|
@@ -15271,6 +15271,96 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15271
15271
|
let finishReason = null;
|
|
15272
15272
|
let inputTokens = 0;
|
|
15273
15273
|
let outputTokens = 0;
|
|
15274
|
+
const THINK_OPEN = "<think>";
|
|
15275
|
+
const THINK_CLOSE = "</think>";
|
|
15276
|
+
const SPIN_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
|
|
15277
|
+
let pendingBuf = "";
|
|
15278
|
+
let inThink = false;
|
|
15279
|
+
let thinkBuf = "";
|
|
15280
|
+
let thinkStartMs = 0;
|
|
15281
|
+
let spinInterval = null;
|
|
15282
|
+
let spinIdx = 0;
|
|
15283
|
+
let normalWritten = false;
|
|
15284
|
+
const writeNormal = (s2) => {
|
|
15285
|
+
if (!s2) return;
|
|
15286
|
+
process.stdout.write(s2);
|
|
15287
|
+
text += s2;
|
|
15288
|
+
normalWritten = true;
|
|
15289
|
+
};
|
|
15290
|
+
const startThinkBlock = () => {
|
|
15291
|
+
inThink = true;
|
|
15292
|
+
thinkBuf = "";
|
|
15293
|
+
thinkStartMs = Date.now();
|
|
15294
|
+
if (!normalWritten) process.stdout.write("\n");
|
|
15295
|
+
process.stdout.write(source_default.dim(" \u280B \u601D\u8003\u4E2D..."));
|
|
15296
|
+
spinIdx = 0;
|
|
15297
|
+
spinInterval = setInterval(() => {
|
|
15298
|
+
spinIdx = (spinIdx + 1) % SPIN_FRAMES.length;
|
|
15299
|
+
process.stdout.write(`\r${source_default.dim(` ${SPIN_FRAMES[spinIdx]} \u601D\u8003\u4E2D...`)}`);
|
|
15300
|
+
}, 80);
|
|
15301
|
+
};
|
|
15302
|
+
const endThinkBlock = () => {
|
|
15303
|
+
if (spinInterval) {
|
|
15304
|
+
clearInterval(spinInterval);
|
|
15305
|
+
spinInterval = null;
|
|
15306
|
+
}
|
|
15307
|
+
process.stdout.write("\r\x1B[K");
|
|
15308
|
+
const elapsed = ((Date.now() - thinkStartMs) / 1e3).toFixed(1);
|
|
15309
|
+
const trimmed = thinkBuf.trim();
|
|
15310
|
+
if (trimmed) {
|
|
15311
|
+
const W2 = 44;
|
|
15312
|
+
const suffix = ` \u2713 ${elapsed}s`;
|
|
15313
|
+
process.stdout.write(source_default.dim(` \u256D${"\u2500".repeat(W2)}
|
|
15314
|
+
`));
|
|
15315
|
+
for (const line of trimmed.split("\n")) {
|
|
15316
|
+
const chunks = line.match(/.{1,78}/g) ?? [""];
|
|
15317
|
+
for (const c2 of chunks) process.stdout.write(source_default.dim(` \u2502 ${c2}
|
|
15318
|
+
`));
|
|
15319
|
+
}
|
|
15320
|
+
process.stdout.write(source_default.dim(` \u2570${"\u2500".repeat(Math.max(0, W2 - suffix.length))}${suffix}
|
|
15321
|
+
|
|
15322
|
+
`));
|
|
15323
|
+
}
|
|
15324
|
+
inThink = false;
|
|
15325
|
+
thinkBuf = "";
|
|
15326
|
+
};
|
|
15327
|
+
const partialTagLen = (s2, tag) => {
|
|
15328
|
+
const max = Math.min(s2.length, tag.length - 1);
|
|
15329
|
+
for (let i2 = max; i2 > 0; i2--) {
|
|
15330
|
+
if (tag.startsWith(s2.slice(-i2))) return i2;
|
|
15331
|
+
}
|
|
15332
|
+
return 0;
|
|
15333
|
+
};
|
|
15334
|
+
const processChunk = (chunk) => {
|
|
15335
|
+
pendingBuf += chunk;
|
|
15336
|
+
let guard = 0;
|
|
15337
|
+
while (pendingBuf.length > 0 && guard++ < 2e4) {
|
|
15338
|
+
if (!inThink) {
|
|
15339
|
+
const openIdx = pendingBuf.indexOf(THINK_OPEN);
|
|
15340
|
+
if (openIdx === -1) {
|
|
15341
|
+
const hold = partialTagLen(pendingBuf, THINK_OPEN);
|
|
15342
|
+
writeNormal(pendingBuf.slice(0, pendingBuf.length - hold));
|
|
15343
|
+
pendingBuf = hold > 0 ? pendingBuf.slice(-hold) : "";
|
|
15344
|
+
break;
|
|
15345
|
+
}
|
|
15346
|
+
writeNormal(pendingBuf.slice(0, openIdx));
|
|
15347
|
+
pendingBuf = pendingBuf.slice(openIdx + THINK_OPEN.length);
|
|
15348
|
+
startThinkBlock();
|
|
15349
|
+
} else {
|
|
15350
|
+
const closeIdx = pendingBuf.indexOf(THINK_CLOSE);
|
|
15351
|
+
if (closeIdx === -1) {
|
|
15352
|
+
const hold = partialTagLen(pendingBuf, THINK_CLOSE);
|
|
15353
|
+
thinkBuf += pendingBuf.slice(0, pendingBuf.length - hold);
|
|
15354
|
+
pendingBuf = hold > 0 ? pendingBuf.slice(-hold) : "";
|
|
15355
|
+
break;
|
|
15356
|
+
}
|
|
15357
|
+
thinkBuf += pendingBuf.slice(0, closeIdx);
|
|
15358
|
+
pendingBuf = pendingBuf.slice(closeIdx + THINK_CLOSE.length);
|
|
15359
|
+
endThinkBlock();
|
|
15360
|
+
if (!normalWritten) process.stdout.write(source_default.green(`${BRAND} \u203A `));
|
|
15361
|
+
}
|
|
15362
|
+
}
|
|
15363
|
+
};
|
|
15274
15364
|
process.stdout.write(source_default.green(`${BRAND} \u203A `));
|
|
15275
15365
|
for await (const chunk of stream) {
|
|
15276
15366
|
if (chunk.usage) {
|
|
@@ -15282,8 +15372,7 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15282
15372
|
const delta = choice.delta;
|
|
15283
15373
|
finishReason = choice.finish_reason ?? finishReason;
|
|
15284
15374
|
if (delta.content) {
|
|
15285
|
-
|
|
15286
|
-
text += delta.content;
|
|
15375
|
+
processChunk(delta.content);
|
|
15287
15376
|
}
|
|
15288
15377
|
if (delta.tool_calls) {
|
|
15289
15378
|
for (const tc of delta.tool_calls) {
|
|
@@ -15303,6 +15392,12 @@ async function streamOnce(client, messages, model, signal) {
|
|
|
15303
15392
|
}
|
|
15304
15393
|
}
|
|
15305
15394
|
}
|
|
15395
|
+
if (pendingBuf) writeNormal(pendingBuf);
|
|
15396
|
+
if (inThink) endThinkBlock();
|
|
15397
|
+
if (spinInterval) {
|
|
15398
|
+
clearInterval(spinInterval);
|
|
15399
|
+
spinInterval = null;
|
|
15400
|
+
}
|
|
15306
15401
|
if (text) process.stdout.write("\n");
|
|
15307
15402
|
return {
|
|
15308
15403
|
text,
|
|
@@ -17817,7 +17912,7 @@ function clearCheckpoints(sessionId) {
|
|
|
17817
17912
|
|
|
17818
17913
|
// src/index.ts
|
|
17819
17914
|
var import_fs7 = require("fs");
|
|
17820
|
-
var VERSION2 = "2.8.
|
|
17915
|
+
var VERSION2 = "2.8.3";
|
|
17821
17916
|
var BRAND2 = "mbp".toLowerCase();
|
|
17822
17917
|
var SKILLHUB_HUBS = {
|
|
17823
17918
|
bgi: { label: "BGI\u5185\u7F51", apiBase: "https://clawhub.ai", backend: "clawhub" },
|
|
@@ -19630,7 +19725,8 @@ ${summary}` },
|
|
|
19630
19725
|
printHelp();
|
|
19631
19726
|
break;
|
|
19632
19727
|
default:
|
|
19633
|
-
console.log(source_default.
|
|
19728
|
+
console.log(source_default.dim(` \u63D0\u793A: \u672A\u627E\u5230\u547D\u4EE4 /${cmd}\uFF0C\u5C06\u4F5C\u4E3A\u6D88\u606F\u53D1\u9001\u7ED9 AI\u3002\u8F93\u5165 /help \u67E5\u770B\u5168\u90E8\u547D\u4EE4`));
|
|
19729
|
+
return { sendToAI: true };
|
|
19634
19730
|
}
|
|
19635
19731
|
return {};
|
|
19636
19732
|
}
|
|
@@ -19963,7 +20059,7 @@ async function main() {
|
|
|
19963
20059
|
}
|
|
19964
20060
|
if (result.injectHistory) history = result.injectHistory;
|
|
19965
20061
|
if (result.thinkMode !== void 0) thinkMode = result.thinkMode;
|
|
19966
|
-
continue;
|
|
20062
|
+
if (!result.sendToAI) continue;
|
|
19967
20063
|
}
|
|
19968
20064
|
if (trimmed.startsWith("!")) {
|
|
19969
20065
|
const cmd = trimmed.slice(1).trim();
|