@botconnector/bccli 0.4.0-beta.22 → 0.4.0-beta.23
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-JM75AWC3.js → chunk-TUSJXGMP.js} +128 -37
- package/dist/{chunk-OQG5NP6C.js → chunk-XUJKRRPO.js} +1 -1
- package/dist/cli.js +32 -22
- package/dist/{login-5AQCNXSR.js → login-KHHIC6QQ.js} +1 -1
- package/dist/{providerCli-FLYQK6DX.js → providerCli-Q3FWHOKL.js} +1 -1
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ import {
|
|
|
19
19
|
// src/provider.ts
|
|
20
20
|
import OpenAI from "openai";
|
|
21
21
|
import { ResponsesWS } from "openai/resources/responses/ws";
|
|
22
|
+
import { toResponseInputItems } from "openai/lib/responses/ResponseInputItems";
|
|
22
23
|
|
|
23
24
|
// src/thinking.ts
|
|
24
25
|
var OPEN = "<think>";
|
|
@@ -207,24 +208,35 @@ function responseInputFromMessages(messages) {
|
|
|
207
208
|
continue;
|
|
208
209
|
}
|
|
209
210
|
if (message.role === "assistant") {
|
|
211
|
+
if (message.responses_output_items?.length) {
|
|
212
|
+
input.push(...toResponseInputItems(message.responses_output_items));
|
|
213
|
+
continue;
|
|
214
|
+
}
|
|
210
215
|
if (message.content) input.push({ role: "assistant", content: message.content });
|
|
211
216
|
for (const call of message.tool_calls ?? []) {
|
|
212
217
|
input.push({
|
|
213
218
|
type: "function_call",
|
|
214
219
|
call_id: call.id,
|
|
215
220
|
name: call.function.name,
|
|
216
|
-
arguments: call.function.arguments || "{}"
|
|
221
|
+
arguments: call.function.arguments || "{}",
|
|
222
|
+
...call.caller ? { caller: call.caller } : {}
|
|
217
223
|
});
|
|
218
224
|
}
|
|
219
225
|
continue;
|
|
220
226
|
}
|
|
221
|
-
input.push({
|
|
227
|
+
input.push({
|
|
228
|
+
type: "function_call_output",
|
|
229
|
+
call_id: message.tool_call_id,
|
|
230
|
+
output: message.content,
|
|
231
|
+
...message.responses_caller ? { caller: message.responses_caller } : {}
|
|
232
|
+
});
|
|
222
233
|
}
|
|
223
234
|
return input;
|
|
224
235
|
}
|
|
225
236
|
var LUNA_TOOL_SEARCH_MIN_MCP_TOOLS = 20;
|
|
226
237
|
var LUNA_TOOL_SEARCH_MIN_MCP_SCHEMA_CHARS = 32e3;
|
|
227
|
-
|
|
238
|
+
var LUNA_PTC_SAFE_FUNCTIONS = /* @__PURE__ */ new Set(["read", "grep", "glob"]);
|
|
239
|
+
function lunaToolPlan(tools, enableProgrammaticToolCalling = false) {
|
|
228
240
|
const native = (tools ?? []).map((tool) => ({
|
|
229
241
|
type: "function",
|
|
230
242
|
name: tool.function.name,
|
|
@@ -235,8 +247,22 @@ function lunaToolPlan(tools) {
|
|
|
235
247
|
const mcpIndexes = native.map((tool, index) => String(tool.name).startsWith("mcp__") ? index : -1).filter((index) => index >= 0);
|
|
236
248
|
const deferredSchemaChars = mcpIndexes.reduce((sum, index) => sum + JSON.stringify(native[index]).length, 0);
|
|
237
249
|
const useToolSearch = mcpIndexes.length >= LUNA_TOOL_SEARCH_MIN_MCP_TOOLS || deferredSchemaChars >= LUNA_TOOL_SEARCH_MIN_MCP_SCHEMA_CHARS;
|
|
250
|
+
if (enableProgrammaticToolCalling) {
|
|
251
|
+
for (let index = 0; index < native.length; index++) {
|
|
252
|
+
if (LUNA_PTC_SAFE_FUNCTIONS.has(String(native[index].name))) {
|
|
253
|
+
native[index] = { ...native[index], allowed_callers: ["direct", "programmatic"] };
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
native.push({ type: "programmatic_tool_calling" });
|
|
257
|
+
}
|
|
238
258
|
if (!useToolSearch) {
|
|
239
|
-
return {
|
|
259
|
+
return {
|
|
260
|
+
tools: native,
|
|
261
|
+
useToolSearch: false,
|
|
262
|
+
useProgrammaticToolCalling: enableProgrammaticToolCalling,
|
|
263
|
+
deferredToolCount: 0,
|
|
264
|
+
deferredSchemaChars
|
|
265
|
+
};
|
|
240
266
|
}
|
|
241
267
|
for (const index of mcpIndexes) native[index] = { ...native[index], defer_loading: true };
|
|
242
268
|
native.push({
|
|
@@ -246,12 +272,13 @@ function lunaToolPlan(tools) {
|
|
|
246
272
|
return {
|
|
247
273
|
tools: native,
|
|
248
274
|
useToolSearch: true,
|
|
275
|
+
useProgrammaticToolCalling: enableProgrammaticToolCalling,
|
|
249
276
|
deferredToolCount: mcpIndexes.length,
|
|
250
277
|
deferredSchemaChars
|
|
251
278
|
};
|
|
252
279
|
}
|
|
253
|
-
function responseTools(tools) {
|
|
254
|
-
return lunaToolPlan(tools).tools;
|
|
280
|
+
function responseTools(tools, enableProgrammaticToolCalling = false) {
|
|
281
|
+
return lunaToolPlan(tools, enableProgrammaticToolCalling).tools;
|
|
255
282
|
}
|
|
256
283
|
function responseReasoning(level) {
|
|
257
284
|
if (level === "auto") return {};
|
|
@@ -260,12 +287,36 @@ function responseReasoning(level) {
|
|
|
260
287
|
function toResponsesUsage(usage) {
|
|
261
288
|
return usage ? { inputTokens: usage.input_tokens ?? 0, outputTokens: usage.output_tokens ?? 0 } : void 0;
|
|
262
289
|
}
|
|
290
|
+
function programCaller(item) {
|
|
291
|
+
const caller = item?.caller;
|
|
292
|
+
return caller?.type === "program" && typeof caller.caller_id === "string" ? { type: "program", caller_id: caller.caller_id } : void 0;
|
|
293
|
+
}
|
|
294
|
+
function responsesFinishReason(items, toolCallCount, incompleteReason) {
|
|
295
|
+
if (incompleteReason) return incompleteReason;
|
|
296
|
+
if (toolCallCount) return "tool_calls";
|
|
297
|
+
const hasMessage = items?.some((item) => item.type === "message") ?? false;
|
|
298
|
+
const hasProgramState = items?.some((item) => item.type === "program" || item.type === "program_output") ?? false;
|
|
299
|
+
return !hasMessage && hasProgramState ? "continue" : "stop";
|
|
300
|
+
}
|
|
301
|
+
function hasPendingProgrammaticReplay(messages) {
|
|
302
|
+
let pending = false;
|
|
303
|
+
for (const message of messages) {
|
|
304
|
+
if (message.role !== "assistant") continue;
|
|
305
|
+
for (const item of message.responses_output_items ?? []) {
|
|
306
|
+
if (item.type === "program") pending = true;
|
|
307
|
+
else if (item.type === "message" && pending) pending = false;
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
return pending;
|
|
311
|
+
}
|
|
263
312
|
async function readResponsesStream(res, onText) {
|
|
264
313
|
let text = "";
|
|
265
314
|
let usage;
|
|
266
315
|
let finishReason;
|
|
267
316
|
let loopAt = -1;
|
|
268
317
|
const calls = /* @__PURE__ */ new Map();
|
|
318
|
+
const outputItems = /* @__PURE__ */ new Map();
|
|
319
|
+
let responsesOutputItems;
|
|
269
320
|
const decoder = new TextDecoder();
|
|
270
321
|
let buffer = "";
|
|
271
322
|
const emitText = (delta) => {
|
|
@@ -298,7 +349,8 @@ async function readResponsesStream(res, onText) {
|
|
|
298
349
|
calls.set(Number(event.output_index ?? calls.size), {
|
|
299
350
|
id: String(event.item.call_id || event.item.id || `call_${calls.size}`),
|
|
300
351
|
name: String(event.item.name || ""),
|
|
301
|
-
arguments: String(event.item.arguments || "")
|
|
352
|
+
arguments: String(event.item.arguments || ""),
|
|
353
|
+
...programCaller(event.item) ? { caller: programCaller(event.item) } : {}
|
|
302
354
|
});
|
|
303
355
|
return;
|
|
304
356
|
}
|
|
@@ -308,24 +360,34 @@ async function readResponsesStream(res, onText) {
|
|
|
308
360
|
if (call) call.arguments += String(event.delta || "");
|
|
309
361
|
return;
|
|
310
362
|
}
|
|
311
|
-
if (event.type === "response.output_item.done" && event.item
|
|
312
|
-
const index = Number(event.output_index ??
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
363
|
+
if (event.type === "response.output_item.done" && event.item) {
|
|
364
|
+
const index = Number(event.output_index ?? outputItems.size);
|
|
365
|
+
outputItems.set(index, event.item);
|
|
366
|
+
if (event.item.type === "function_call") {
|
|
367
|
+
const current = calls.get(index);
|
|
368
|
+
calls.set(index, {
|
|
369
|
+
id: String(event.item.call_id || current?.id || event.item.id || `call_${index}`),
|
|
370
|
+
name: String(event.item.name || current?.name || ""),
|
|
371
|
+
arguments: String(event.item.arguments ?? current?.arguments ?? ""),
|
|
372
|
+
...programCaller(event.item) ?? current?.caller ? { caller: programCaller(event.item) ?? current?.caller } : {}
|
|
373
|
+
});
|
|
374
|
+
}
|
|
319
375
|
return;
|
|
320
376
|
}
|
|
321
377
|
if (event.type === "response.completed") {
|
|
322
378
|
usage = toResponsesUsage(event.response?.usage);
|
|
323
|
-
|
|
379
|
+
responsesOutputItems = event.response?.output ?? [...outputItems.entries()].sort(([a], [b]) => a - b).map(([, item]) => item);
|
|
380
|
+
finishReason = responsesFinishReason(responsesOutputItems, calls.size);
|
|
324
381
|
return;
|
|
325
382
|
}
|
|
326
383
|
if (event.type === "response.incomplete") {
|
|
327
384
|
usage = toResponsesUsage(event.response?.usage);
|
|
328
|
-
|
|
385
|
+
responsesOutputItems = event.response?.output ?? [...outputItems.entries()].sort(([a], [b]) => a - b).map(([, item]) => item);
|
|
386
|
+
finishReason = responsesFinishReason(
|
|
387
|
+
responsesOutputItems,
|
|
388
|
+
calls.size,
|
|
389
|
+
String(event.response?.incomplete_details?.reason || "incomplete")
|
|
390
|
+
);
|
|
329
391
|
}
|
|
330
392
|
};
|
|
331
393
|
for await (const chunk of res.body) {
|
|
@@ -345,7 +407,8 @@ async function readResponsesStream(res, onText) {
|
|
|
345
407
|
text,
|
|
346
408
|
toolCalls: [...calls.entries()].sort(([a], [b]) => a - b).map(([, call]) => call),
|
|
347
409
|
usage,
|
|
348
|
-
finishReason
|
|
410
|
+
finishReason,
|
|
411
|
+
responsesOutputItems
|
|
349
412
|
};
|
|
350
413
|
}
|
|
351
414
|
async function readResponsesJson(res) {
|
|
@@ -362,7 +425,8 @@ async function readResponsesJson(res) {
|
|
|
362
425
|
toolCalls.push({
|
|
363
426
|
id: String(item.call_id || item.id || `call_${toolCalls.length}`),
|
|
364
427
|
name: String(item.name || ""),
|
|
365
|
-
arguments: String(item.arguments || "{}")
|
|
428
|
+
arguments: String(item.arguments || "{}"),
|
|
429
|
+
...programCaller(item) ? { caller: programCaller(item) } : {}
|
|
366
430
|
});
|
|
367
431
|
}
|
|
368
432
|
}
|
|
@@ -370,7 +434,12 @@ async function readResponsesJson(res) {
|
|
|
370
434
|
text,
|
|
371
435
|
toolCalls,
|
|
372
436
|
usage: toResponsesUsage(body.usage),
|
|
373
|
-
|
|
437
|
+
responsesOutputItems: body.output,
|
|
438
|
+
finishReason: responsesFinishReason(
|
|
439
|
+
body.output,
|
|
440
|
+
toolCalls.length,
|
|
441
|
+
body.status === "incomplete" ? String(body.incomplete_details?.reason || "incomplete") : void 0
|
|
442
|
+
)
|
|
374
443
|
};
|
|
375
444
|
}
|
|
376
445
|
function cloneMessages(messages) {
|
|
@@ -387,9 +456,11 @@ function completionAssistantMessage(completion) {
|
|
|
387
456
|
tool_calls: completion.toolCalls.map((call) => ({
|
|
388
457
|
id: call.id,
|
|
389
458
|
type: "function",
|
|
390
|
-
function: { name: call.name, arguments: call.arguments }
|
|
459
|
+
function: { name: call.name, arguments: call.arguments },
|
|
460
|
+
...call.caller ? { caller: call.caller } : {}
|
|
391
461
|
}))
|
|
392
|
-
} : {}
|
|
462
|
+
} : {},
|
|
463
|
+
...completion.responsesOutputItems?.length ? { responses_output_items: completion.responsesOutputItems } : {}
|
|
393
464
|
};
|
|
394
465
|
}
|
|
395
466
|
function responseContinuationInput(messages, continuation) {
|
|
@@ -407,7 +478,12 @@ function responseContinuationInput(messages, continuation) {
|
|
|
407
478
|
return { input: responseInputFromMessages(messages), incremental: false };
|
|
408
479
|
}
|
|
409
480
|
const delta = messages.slice(continuation.requestMessages.length + 1);
|
|
410
|
-
if (!delta.length)
|
|
481
|
+
if (!delta.length) {
|
|
482
|
+
if (continuation.completion.finishReason === "continue") {
|
|
483
|
+
return { input: [], previousResponseId: continuation.responseId, incremental: true };
|
|
484
|
+
}
|
|
485
|
+
return { input: responseInputFromMessages(messages), incremental: false };
|
|
486
|
+
}
|
|
411
487
|
return {
|
|
412
488
|
input: responseInputFromMessages(delta),
|
|
413
489
|
previousResponseId: continuation.responseId,
|
|
@@ -421,6 +497,7 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
421
497
|
let finishReason;
|
|
422
498
|
let loopAt = -1;
|
|
423
499
|
const calls = /* @__PURE__ */ new Map();
|
|
500
|
+
const outputItems = /* @__PURE__ */ new Map();
|
|
424
501
|
const emitText = (delta) => {
|
|
425
502
|
if (!delta) return;
|
|
426
503
|
text += delta;
|
|
@@ -478,7 +555,8 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
478
555
|
calls.set(index, {
|
|
479
556
|
id: String(event.item.call_id || event.item.id || `call_${index}`),
|
|
480
557
|
name: String(event.item.name || ""),
|
|
481
|
-
arguments: String(event.item.arguments || "")
|
|
558
|
+
arguments: String(event.item.arguments || ""),
|
|
559
|
+
...programCaller(event.item) ? { caller: programCaller(event.item) } : {}
|
|
482
560
|
});
|
|
483
561
|
continue;
|
|
484
562
|
}
|
|
@@ -488,14 +566,18 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
488
566
|
if (call) call.arguments += String(event.delta || "");
|
|
489
567
|
continue;
|
|
490
568
|
}
|
|
491
|
-
if (event.type === "response.output_item.done" && event.item
|
|
492
|
-
const index = Number(event.output_index ??
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
569
|
+
if (event.type === "response.output_item.done" && event.item) {
|
|
570
|
+
const index = Number(event.output_index ?? outputItems.size);
|
|
571
|
+
outputItems.set(index, event.item);
|
|
572
|
+
if (event.item.type === "function_call") {
|
|
573
|
+
const current = calls.get(index);
|
|
574
|
+
calls.set(index, {
|
|
575
|
+
id: String(event.item.call_id || current?.id || event.item.id || `call_${index}`),
|
|
576
|
+
name: String(event.item.name || current?.name || ""),
|
|
577
|
+
arguments: String(event.item.arguments ?? current?.arguments ?? ""),
|
|
578
|
+
...programCaller(event.item) ?? current?.caller ? { caller: programCaller(event.item) ?? current?.caller } : {}
|
|
579
|
+
});
|
|
580
|
+
}
|
|
499
581
|
continue;
|
|
500
582
|
}
|
|
501
583
|
if (event.type === "response.failed") {
|
|
@@ -506,14 +588,20 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
506
588
|
if (event.type === "response.completed" || event.type === "response.incomplete") {
|
|
507
589
|
responseId = String(event.response?.id || responseId);
|
|
508
590
|
usage = toResponsesUsage(event.response?.usage);
|
|
509
|
-
|
|
591
|
+
const responsesOutputItems = event.response?.output ?? [...outputItems.entries()].sort(([a], [b]) => a - b).map(([, item]) => item);
|
|
592
|
+
finishReason = responsesFinishReason(
|
|
593
|
+
responsesOutputItems,
|
|
594
|
+
calls.size,
|
|
595
|
+
event.type === "response.incomplete" ? String(event.response?.incomplete_details?.reason || "incomplete") : void 0
|
|
596
|
+
);
|
|
510
597
|
return {
|
|
511
598
|
responseId,
|
|
512
599
|
completion: {
|
|
513
600
|
text,
|
|
514
601
|
toolCalls: [...calls.entries()].sort(([a], [b]) => a - b).map(([, call]) => call),
|
|
515
602
|
usage,
|
|
516
|
-
finishReason
|
|
603
|
+
finishReason,
|
|
604
|
+
responsesOutputItems
|
|
517
605
|
}
|
|
518
606
|
};
|
|
519
607
|
}
|
|
@@ -530,7 +618,8 @@ function createProvider(options) {
|
|
|
530
618
|
providerId,
|
|
531
619
|
fetch: fetchOverride,
|
|
532
620
|
retryDelayMs = 1e3,
|
|
533
|
-
responsesWebSocketFactory
|
|
621
|
+
responsesWebSocketFactory,
|
|
622
|
+
enableProgrammaticToolCalling = false
|
|
534
623
|
} = options;
|
|
535
624
|
const doFetch = fetchOverride ?? fetch;
|
|
536
625
|
const headers = { "content-type": "application/json" };
|
|
@@ -583,7 +672,7 @@ function createProvider(options) {
|
|
|
583
672
|
lunaWsIdleTimer.unref?.();
|
|
584
673
|
};
|
|
585
674
|
async function chatLunaWebSocket(messages, tools, reasoning, signal, onText) {
|
|
586
|
-
const nativeTools = responseTools(tools);
|
|
675
|
+
const nativeTools = responseTools(tools, enableProgrammaticToolCalling);
|
|
587
676
|
const initialPlan = responseContinuationInput(messages, lunaContinuation);
|
|
588
677
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
589
678
|
if (signal?.aborted) throw signal.reason ?? new Error("Request aborted");
|
|
@@ -675,7 +764,7 @@ function createProvider(options) {
|
|
|
675
764
|
}
|
|
676
765
|
}
|
|
677
766
|
if (useNativeResponses) {
|
|
678
|
-
const nativeTools = responseTools(tools);
|
|
767
|
+
const nativeTools = responseTools(tools, enableProgrammaticToolCalling);
|
|
679
768
|
const res2 = await post(
|
|
680
769
|
"/responses",
|
|
681
770
|
{
|
|
@@ -802,6 +891,8 @@ async function runProviderCommand(args, deps) {
|
|
|
802
891
|
}
|
|
803
892
|
|
|
804
893
|
export {
|
|
894
|
+
hasPendingProgrammaticReplay,
|
|
895
|
+
completionAssistantMessage,
|
|
805
896
|
createProvider,
|
|
806
897
|
listAllModels,
|
|
807
898
|
addProviderKey,
|
|
@@ -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-Q3FWHOKL.js");
|
|
39
39
|
const { parseCliArgs } = await import("./args-XQYEBOKB.js");
|
|
40
40
|
return runProviderCommand(parseCliArgs(["provider", "add", providerId]), {
|
|
41
41
|
env: process.env,
|
package/dist/cli.js
CHANGED
|
@@ -18,9 +18,11 @@ import {
|
|
|
18
18
|
} from "./chunk-ELML4KVQ.js";
|
|
19
19
|
import {
|
|
20
20
|
addProviderKey,
|
|
21
|
+
completionAssistantMessage,
|
|
21
22
|
createProvider,
|
|
23
|
+
hasPendingProgrammaticReplay,
|
|
22
24
|
listAllModels
|
|
23
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-TUSJXGMP.js";
|
|
24
26
|
import {
|
|
25
27
|
providerName,
|
|
26
28
|
readGlobalConfigFile
|
|
@@ -28,7 +30,7 @@ import {
|
|
|
28
30
|
import "./chunk-SN3ODJZN.js";
|
|
29
31
|
import {
|
|
30
32
|
runLogin
|
|
31
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-XUJKRRPO.js";
|
|
32
34
|
import {
|
|
33
35
|
Session,
|
|
34
36
|
pruneSessions
|
|
@@ -953,10 +955,10 @@ ${completion.text}` });
|
|
|
953
955
|
this.opts.onTurnStart?.();
|
|
954
956
|
this.webBudget.startTurn();
|
|
955
957
|
try {
|
|
956
|
-
if (this.lastInputTokens > this.contextWindow * 0.8) await this.compact(signal);
|
|
958
|
+
if (this.lastInputTokens > this.contextWindow * 0.8 && !hasPendingProgrammaticReplay(this.messages)) await this.compact(signal);
|
|
957
959
|
this.push({ role: "user", content: text });
|
|
958
960
|
for (let step = 0; step < this.maxSteps; step++) {
|
|
959
|
-
if (step > 0 && this.lastInputTokens > this.contextWindow * 0.8) {
|
|
961
|
+
if (step > 0 && this.lastInputTokens > this.contextWindow * 0.8 && !hasPendingProgrammaticReplay(this.messages)) {
|
|
960
962
|
await this.compact(signal);
|
|
961
963
|
this.push({ role: "user", content: `Continue this task using the summary above: ${text}` });
|
|
962
964
|
}
|
|
@@ -984,17 +986,7 @@ ${completion.text}` });
|
|
|
984
986
|
this.totalUsage.outputTokens += usage.outputTokens;
|
|
985
987
|
this.lastInputTokens = usage.inputTokens;
|
|
986
988
|
this.onEvent({ type: "usage", ...this.totalUsage });
|
|
987
|
-
this.push(
|
|
988
|
-
role: "assistant",
|
|
989
|
-
content: completion.text || null,
|
|
990
|
-
...completion.toolCalls.length ? {
|
|
991
|
-
tool_calls: completion.toolCalls.map((c) => ({
|
|
992
|
-
id: c.id,
|
|
993
|
-
type: "function",
|
|
994
|
-
function: { name: c.name, arguments: c.arguments }
|
|
995
|
-
}))
|
|
996
|
-
} : {}
|
|
997
|
-
});
|
|
989
|
+
this.push(completionAssistantMessage(completion));
|
|
998
990
|
if (completion.finishReason === "repetition") {
|
|
999
991
|
this.onEvent({ type: "textReplace", text: completion.text });
|
|
1000
992
|
this.onEvent({
|
|
@@ -1004,6 +996,7 @@ ${completion.text}` });
|
|
|
1004
996
|
return;
|
|
1005
997
|
}
|
|
1006
998
|
if (!completion.toolCalls.length) {
|
|
999
|
+
if (completion.finishReason === "continue") continue;
|
|
1007
1000
|
this.onEvent({ type: "done" });
|
|
1008
1001
|
return;
|
|
1009
1002
|
}
|
|
@@ -1011,7 +1004,13 @@ ${completion.text}` });
|
|
|
1011
1004
|
let i = 0;
|
|
1012
1005
|
while (i < calls.length) {
|
|
1013
1006
|
if (signal.aborted) {
|
|
1014
|
-
for (const pending of calls.slice(i))
|
|
1007
|
+
for (const pending of calls.slice(i))
|
|
1008
|
+
this.push({
|
|
1009
|
+
role: "tool",
|
|
1010
|
+
tool_call_id: pending.id,
|
|
1011
|
+
content: "Cancelled by the user.",
|
|
1012
|
+
...pending.caller ? { responses_caller: pending.caller } : {}
|
|
1013
|
+
});
|
|
1015
1014
|
this.onEvent({ type: "aborted" });
|
|
1016
1015
|
return;
|
|
1017
1016
|
}
|
|
@@ -1020,7 +1019,12 @@ ${completion.text}` });
|
|
|
1020
1019
|
const batch = calls.slice(i, j);
|
|
1021
1020
|
const results = await Promise.all(batch.map((c) => this.runTool(c, signal)));
|
|
1022
1021
|
batch.forEach((c, k) => {
|
|
1023
|
-
this.push({
|
|
1022
|
+
this.push({
|
|
1023
|
+
role: "tool",
|
|
1024
|
+
tool_call_id: c.id,
|
|
1025
|
+
content: results[k],
|
|
1026
|
+
...c.caller ? { responses_caller: c.caller } : {}
|
|
1027
|
+
});
|
|
1024
1028
|
});
|
|
1025
1029
|
i = j;
|
|
1026
1030
|
}
|
|
@@ -1509,7 +1513,13 @@ function createRuntime(opts) {
|
|
|
1509
1513
|
let reasoning = opts.args.reasoning ?? config.reasoning;
|
|
1510
1514
|
const makeProvider = (ref) => {
|
|
1511
1515
|
const resolved = resolveModel(config, ref, env);
|
|
1512
|
-
return opts.provider ?? createProvider({
|
|
1516
|
+
return opts.provider ?? createProvider({
|
|
1517
|
+
baseURL: resolved.baseURL,
|
|
1518
|
+
apiKey: resolved.apiKey,
|
|
1519
|
+
model: resolved.model,
|
|
1520
|
+
providerId: resolved.providerId,
|
|
1521
|
+
enableProgrammaticToolCalling: env.BCCLI_LUNA_PTC === "1"
|
|
1522
|
+
});
|
|
1513
1523
|
};
|
|
1514
1524
|
const provider = makeProvider(modelRef);
|
|
1515
1525
|
const mode = opts.args.allowAll ? "allowAll" : opts.args.permissionMode ?? config.permissionMode;
|
|
@@ -1645,7 +1655,7 @@ function createRuntime(opts) {
|
|
|
1645
1655
|
}
|
|
1646
1656
|
|
|
1647
1657
|
// src/version.ts
|
|
1648
|
-
var VERSION = true ? "0.4.0-beta.
|
|
1658
|
+
var VERSION = true ? "0.4.0-beta.23" : "0.0.0-dev";
|
|
1649
1659
|
|
|
1650
1660
|
// src/cli.ts
|
|
1651
1661
|
function chooseLanguage(argv) {
|
|
@@ -1671,12 +1681,12 @@ async function main() {
|
|
|
1671
1681
|
if (args.command === "login") return runLogin(args.loginProvider ?? "bc-cloud", cwd);
|
|
1672
1682
|
if (args.command === "mcp") {
|
|
1673
1683
|
const { runMcpCommand } = await import("./mcpCli-J43FHF2H.js");
|
|
1674
|
-
const { readSecret } = await import("./login-
|
|
1684
|
+
const { readSecret } = await import("./login-KHHIC6QQ.js");
|
|
1675
1685
|
return runMcpCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1676
1686
|
}
|
|
1677
1687
|
if (args.command === "provider") {
|
|
1678
|
-
const { runProviderCommand } = await import("./providerCli-
|
|
1679
|
-
const { readSecret } = await import("./login-
|
|
1688
|
+
const { runProviderCommand } = await import("./providerCli-Q3FWHOKL.js");
|
|
1689
|
+
const { readSecret } = await import("./login-KHHIC6QQ.js");
|
|
1680
1690
|
return runProviderCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1681
1691
|
}
|
|
1682
1692
|
if (args.command === "connect" || args.command === "disconnect" || args.command === "integrations") {
|