@botconnector/bccli 0.3.0-beta.2 → 0.3.0-beta.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/{chunk-MANM7HY6.js → chunk-5ISYVAXI.js} +19 -1
- package/dist/{chunk-E4BWUMQ2.js → chunk-R37QWDTL.js} +1 -1
- package/dist/cli.js +15 -7
- package/dist/{login-IXJD5O7Z.js → login-WJMGVDRM.js} +1 -1
- package/dist/{providerCli-7QNAYIFT.js → providerCli-SJRCBSRE.js} +1 -1
- package/dist/{ui-HNIC4DQ6.js → ui-HAW5NMFA.js} +5 -0
- package/package.json +1 -1
|
@@ -21,6 +21,21 @@ var ProviderError = class extends Error {
|
|
|
21
21
|
status;
|
|
22
22
|
};
|
|
23
23
|
var retryable = (status) => status === 429 || status >= 500;
|
|
24
|
+
function detectRepetition(text) {
|
|
25
|
+
const tail = text.slice(-600);
|
|
26
|
+
for (let len = 1; len <= 12; len++) {
|
|
27
|
+
const unit = tail.slice(-len);
|
|
28
|
+
if (unit.length < len || !unit.trim()) continue;
|
|
29
|
+
let i = tail.length;
|
|
30
|
+
let count = 0;
|
|
31
|
+
while (i >= len && tail.slice(i - len, i) === unit) {
|
|
32
|
+
count++;
|
|
33
|
+
i -= len;
|
|
34
|
+
}
|
|
35
|
+
if (count >= 20 && count * len >= 300) return text.length - count * len;
|
|
36
|
+
}
|
|
37
|
+
return -1;
|
|
38
|
+
}
|
|
24
39
|
function sleep(ms, signal) {
|
|
25
40
|
return new Promise((resolve, reject) => {
|
|
26
41
|
const timer = setTimeout(resolve, ms);
|
|
@@ -52,6 +67,7 @@ async function readStream(res, onText) {
|
|
|
52
67
|
let current;
|
|
53
68
|
const decoder = new TextDecoder();
|
|
54
69
|
let buffer = "";
|
|
70
|
+
let loopAt = -1;
|
|
55
71
|
const handle = (line) => {
|
|
56
72
|
if (!line.startsWith("data:")) return;
|
|
57
73
|
const data = line.slice(5).trim();
|
|
@@ -71,6 +87,7 @@ async function readStream(res, onText) {
|
|
|
71
87
|
if (delta.content) {
|
|
72
88
|
text += delta.content;
|
|
73
89
|
onText?.(delta.content);
|
|
90
|
+
if (loopAt < 0) loopAt = detectRepetition(text);
|
|
74
91
|
}
|
|
75
92
|
for (const tc of delta.tool_calls ?? []) {
|
|
76
93
|
let target = tc.index !== void 0 ? byIndex.get(tc.index) : current;
|
|
@@ -88,11 +105,12 @@ async function readStream(res, onText) {
|
|
|
88
105
|
for await (const chunk of res.body) {
|
|
89
106
|
buffer += decoder.decode(chunk, { stream: true });
|
|
90
107
|
let newline = buffer.indexOf("\n");
|
|
91
|
-
while (newline >= 0) {
|
|
108
|
+
while (newline >= 0 && loopAt < 0) {
|
|
92
109
|
handle(buffer.slice(0, newline).trim());
|
|
93
110
|
buffer = buffer.slice(newline + 1);
|
|
94
111
|
newline = buffer.indexOf("\n");
|
|
95
112
|
}
|
|
113
|
+
if (loopAt >= 0) return { text: text.slice(0, loopAt), toolCalls: [], usage, finishReason: "repetition" };
|
|
96
114
|
}
|
|
97
115
|
handle(buffer.trim());
|
|
98
116
|
const toolCalls = calls.map((call, index) => ({ ...call, id: call.id || `call_${index}` }));
|
|
@@ -35,7 +35,7 @@ function readSecret(prompt) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
async function runLogin(providerId, cwd) {
|
|
38
|
-
const { runProviderCommand } = await import("./providerCli-
|
|
38
|
+
const { runProviderCommand } = await import("./providerCli-SJRCBSRE.js");
|
|
39
39
|
const { parseCliArgs } = await import("./args-EVIFNGPQ.js");
|
|
40
40
|
return runProviderCommand(parseCliArgs(["provider", "add", providerId]), {
|
|
41
41
|
env: process.env,
|
package/dist/cli.js
CHANGED
|
@@ -7,10 +7,10 @@ import {
|
|
|
7
7
|
addProviderKey,
|
|
8
8
|
createProvider,
|
|
9
9
|
listAllModels
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-5ISYVAXI.js";
|
|
11
11
|
import {
|
|
12
12
|
runLogin
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-R37QWDTL.js";
|
|
14
14
|
import {
|
|
15
15
|
Session,
|
|
16
16
|
pruneSessions
|
|
@@ -624,6 +624,14 @@ ${completion.text}` });
|
|
|
624
624
|
}))
|
|
625
625
|
} : {}
|
|
626
626
|
});
|
|
627
|
+
if (completion.finishReason === "repetition") {
|
|
628
|
+
this.onEvent({ type: "textReplace", text: completion.text });
|
|
629
|
+
this.onEvent({
|
|
630
|
+
type: "error",
|
|
631
|
+
message: "Model terjebak mengulang teks, jawaban dihentikan. Coba ulangi atau ganti model dengan /model."
|
|
632
|
+
});
|
|
633
|
+
return;
|
|
634
|
+
}
|
|
627
635
|
if (!completion.toolCalls.length) {
|
|
628
636
|
this.onEvent({ type: "done" });
|
|
629
637
|
return;
|
|
@@ -1183,7 +1191,7 @@ function createRuntime(opts) {
|
|
|
1183
1191
|
}
|
|
1184
1192
|
|
|
1185
1193
|
// src/version.ts
|
|
1186
|
-
var VERSION = true ? "0.3.0-beta.
|
|
1194
|
+
var VERSION = true ? "0.3.0-beta.3" : "0.0.0-dev";
|
|
1187
1195
|
|
|
1188
1196
|
// src/cli.ts
|
|
1189
1197
|
async function main() {
|
|
@@ -1200,12 +1208,12 @@ async function main() {
|
|
|
1200
1208
|
if (args.command === "login") return runLogin(args.loginProvider ?? "bc-cloud", cwd);
|
|
1201
1209
|
if (args.command === "mcp") {
|
|
1202
1210
|
const { runMcpCommand } = await import("./mcpCli-BV3IGR47.js");
|
|
1203
|
-
const { readSecret } = await import("./login-
|
|
1211
|
+
const { readSecret } = await import("./login-WJMGVDRM.js");
|
|
1204
1212
|
return runMcpCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1205
1213
|
}
|
|
1206
1214
|
if (args.command === "provider") {
|
|
1207
|
-
const { runProviderCommand } = await import("./providerCli-
|
|
1208
|
-
const { readSecret } = await import("./login-
|
|
1215
|
+
const { runProviderCommand } = await import("./providerCli-SJRCBSRE.js");
|
|
1216
|
+
const { readSecret } = await import("./login-WJMGVDRM.js");
|
|
1209
1217
|
return runProviderCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1210
1218
|
}
|
|
1211
1219
|
if (args.command === "models") {
|
|
@@ -1235,7 +1243,7 @@ async function main() {
|
|
|
1235
1243
|
}
|
|
1236
1244
|
}
|
|
1237
1245
|
if (!process.stdin.isTTY) throw new ConfigError('Mode interaktif butuh terminal. Untuk skrip/CI pakai: bccli -p "tugas"');
|
|
1238
|
-
const { startInteractive } = await import("./ui-
|
|
1246
|
+
const { startInteractive } = await import("./ui-HAW5NMFA.js");
|
|
1239
1247
|
return startInteractive(rt, { initialPrompt: args.prompt, resume: args.resume, version: VERSION });
|
|
1240
1248
|
}
|
|
1241
1249
|
main().then(
|
|
@@ -461,6 +461,11 @@ function applyEvent(t, event) {
|
|
|
461
461
|
if (last?.kind === "assistant") return { ...t, live: [...t.live.slice(0, -1), { ...last, text: last.text + event.delta }] };
|
|
462
462
|
return { ...t, live: [...t.live, entry({ kind: "assistant", text: event.delta })] };
|
|
463
463
|
}
|
|
464
|
+
case "textReplace": {
|
|
465
|
+
const last = t.live.at(-1);
|
|
466
|
+
if (last?.kind !== "assistant") return t;
|
|
467
|
+
return { ...t, live: [...t.live.slice(0, -1), { ...last, text: event.text }] };
|
|
468
|
+
}
|
|
464
469
|
case "toolStart": {
|
|
465
470
|
const running = t.live.some((e) => e.kind === "tool" && !e.done);
|
|
466
471
|
const tool = entry({ kind: "tool", callId: event.id, tool: event.tool, target: event.target, done: false });
|