@botconnector/bccli 0.4.0-beta.22 → 0.4.0-beta.24
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-QXLXJWIL.js} +131 -37
- package/dist/{chunk-OQG5NP6C.js → chunk-ZBOI364S.js} +1 -1
- package/dist/cli.js +36 -22
- package/dist/{login-5AQCNXSR.js → login-YHBC2ITY.js} +1 -1
- package/dist/{providerCli-FLYQK6DX.js → providerCli-XD7MUX46.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,25 @@ 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
|
+
let programmaticToolCount = 0;
|
|
251
|
+
if (enableProgrammaticToolCalling) {
|
|
252
|
+
for (let index = 0; index < native.length; index++) {
|
|
253
|
+
if (LUNA_PTC_SAFE_FUNCTIONS.has(String(native[index].name))) {
|
|
254
|
+
native[index] = { ...native[index], allowed_callers: ["direct", "programmatic"] };
|
|
255
|
+
programmaticToolCount++;
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
if (programmaticToolCount > 0) native.push({ type: "programmatic_tool_calling" });
|
|
259
|
+
}
|
|
260
|
+
const useProgrammaticToolCalling = programmaticToolCount > 0;
|
|
238
261
|
if (!useToolSearch) {
|
|
239
|
-
return {
|
|
262
|
+
return {
|
|
263
|
+
tools: native,
|
|
264
|
+
useToolSearch: false,
|
|
265
|
+
useProgrammaticToolCalling,
|
|
266
|
+
deferredToolCount: 0,
|
|
267
|
+
deferredSchemaChars
|
|
268
|
+
};
|
|
240
269
|
}
|
|
241
270
|
for (const index of mcpIndexes) native[index] = { ...native[index], defer_loading: true };
|
|
242
271
|
native.push({
|
|
@@ -246,12 +275,13 @@ function lunaToolPlan(tools) {
|
|
|
246
275
|
return {
|
|
247
276
|
tools: native,
|
|
248
277
|
useToolSearch: true,
|
|
278
|
+
useProgrammaticToolCalling,
|
|
249
279
|
deferredToolCount: mcpIndexes.length,
|
|
250
280
|
deferredSchemaChars
|
|
251
281
|
};
|
|
252
282
|
}
|
|
253
|
-
function responseTools(tools) {
|
|
254
|
-
return lunaToolPlan(tools).tools;
|
|
283
|
+
function responseTools(tools, enableProgrammaticToolCalling = false) {
|
|
284
|
+
return lunaToolPlan(tools, enableProgrammaticToolCalling).tools;
|
|
255
285
|
}
|
|
256
286
|
function responseReasoning(level) {
|
|
257
287
|
if (level === "auto") return {};
|
|
@@ -260,12 +290,36 @@ function responseReasoning(level) {
|
|
|
260
290
|
function toResponsesUsage(usage) {
|
|
261
291
|
return usage ? { inputTokens: usage.input_tokens ?? 0, outputTokens: usage.output_tokens ?? 0 } : void 0;
|
|
262
292
|
}
|
|
293
|
+
function programCaller(item) {
|
|
294
|
+
const caller = item?.caller;
|
|
295
|
+
return caller?.type === "program" && typeof caller.caller_id === "string" ? { type: "program", caller_id: caller.caller_id } : void 0;
|
|
296
|
+
}
|
|
297
|
+
function responsesFinishReason(items, toolCallCount, incompleteReason) {
|
|
298
|
+
if (incompleteReason) return incompleteReason;
|
|
299
|
+
if (toolCallCount) return "tool_calls";
|
|
300
|
+
const hasMessage = items?.some((item) => item.type === "message") ?? false;
|
|
301
|
+
const hasProgramState = items?.some((item) => item.type === "program" || item.type === "program_output") ?? false;
|
|
302
|
+
return !hasMessage && hasProgramState ? "continue" : "stop";
|
|
303
|
+
}
|
|
304
|
+
function hasPendingProgrammaticReplay(messages) {
|
|
305
|
+
let pending = false;
|
|
306
|
+
for (const message of messages) {
|
|
307
|
+
if (message.role !== "assistant") continue;
|
|
308
|
+
for (const item of message.responses_output_items ?? []) {
|
|
309
|
+
if (item.type === "program") pending = true;
|
|
310
|
+
else if (item.type === "message" && pending) pending = false;
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
return pending;
|
|
314
|
+
}
|
|
263
315
|
async function readResponsesStream(res, onText) {
|
|
264
316
|
let text = "";
|
|
265
317
|
let usage;
|
|
266
318
|
let finishReason;
|
|
267
319
|
let loopAt = -1;
|
|
268
320
|
const calls = /* @__PURE__ */ new Map();
|
|
321
|
+
const outputItems = /* @__PURE__ */ new Map();
|
|
322
|
+
let responsesOutputItems;
|
|
269
323
|
const decoder = new TextDecoder();
|
|
270
324
|
let buffer = "";
|
|
271
325
|
const emitText = (delta) => {
|
|
@@ -298,7 +352,8 @@ async function readResponsesStream(res, onText) {
|
|
|
298
352
|
calls.set(Number(event.output_index ?? calls.size), {
|
|
299
353
|
id: String(event.item.call_id || event.item.id || `call_${calls.size}`),
|
|
300
354
|
name: String(event.item.name || ""),
|
|
301
|
-
arguments: String(event.item.arguments || "")
|
|
355
|
+
arguments: String(event.item.arguments || ""),
|
|
356
|
+
...programCaller(event.item) ? { caller: programCaller(event.item) } : {}
|
|
302
357
|
});
|
|
303
358
|
return;
|
|
304
359
|
}
|
|
@@ -308,24 +363,34 @@ async function readResponsesStream(res, onText) {
|
|
|
308
363
|
if (call) call.arguments += String(event.delta || "");
|
|
309
364
|
return;
|
|
310
365
|
}
|
|
311
|
-
if (event.type === "response.output_item.done" && event.item
|
|
312
|
-
const index = Number(event.output_index ??
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
366
|
+
if (event.type === "response.output_item.done" && event.item) {
|
|
367
|
+
const index = Number(event.output_index ?? outputItems.size);
|
|
368
|
+
outputItems.set(index, event.item);
|
|
369
|
+
if (event.item.type === "function_call") {
|
|
370
|
+
const current = calls.get(index);
|
|
371
|
+
calls.set(index, {
|
|
372
|
+
id: String(event.item.call_id || current?.id || event.item.id || `call_${index}`),
|
|
373
|
+
name: String(event.item.name || current?.name || ""),
|
|
374
|
+
arguments: String(event.item.arguments ?? current?.arguments ?? ""),
|
|
375
|
+
...programCaller(event.item) ?? current?.caller ? { caller: programCaller(event.item) ?? current?.caller } : {}
|
|
376
|
+
});
|
|
377
|
+
}
|
|
319
378
|
return;
|
|
320
379
|
}
|
|
321
380
|
if (event.type === "response.completed") {
|
|
322
381
|
usage = toResponsesUsage(event.response?.usage);
|
|
323
|
-
|
|
382
|
+
responsesOutputItems = event.response?.output ?? [...outputItems.entries()].sort(([a], [b]) => a - b).map(([, item]) => item);
|
|
383
|
+
finishReason = responsesFinishReason(responsesOutputItems, calls.size);
|
|
324
384
|
return;
|
|
325
385
|
}
|
|
326
386
|
if (event.type === "response.incomplete") {
|
|
327
387
|
usage = toResponsesUsage(event.response?.usage);
|
|
328
|
-
|
|
388
|
+
responsesOutputItems = event.response?.output ?? [...outputItems.entries()].sort(([a], [b]) => a - b).map(([, item]) => item);
|
|
389
|
+
finishReason = responsesFinishReason(
|
|
390
|
+
responsesOutputItems,
|
|
391
|
+
calls.size,
|
|
392
|
+
String(event.response?.incomplete_details?.reason || "incomplete")
|
|
393
|
+
);
|
|
329
394
|
}
|
|
330
395
|
};
|
|
331
396
|
for await (const chunk of res.body) {
|
|
@@ -345,7 +410,8 @@ async function readResponsesStream(res, onText) {
|
|
|
345
410
|
text,
|
|
346
411
|
toolCalls: [...calls.entries()].sort(([a], [b]) => a - b).map(([, call]) => call),
|
|
347
412
|
usage,
|
|
348
|
-
finishReason
|
|
413
|
+
finishReason,
|
|
414
|
+
responsesOutputItems
|
|
349
415
|
};
|
|
350
416
|
}
|
|
351
417
|
async function readResponsesJson(res) {
|
|
@@ -362,7 +428,8 @@ async function readResponsesJson(res) {
|
|
|
362
428
|
toolCalls.push({
|
|
363
429
|
id: String(item.call_id || item.id || `call_${toolCalls.length}`),
|
|
364
430
|
name: String(item.name || ""),
|
|
365
|
-
arguments: String(item.arguments || "{}")
|
|
431
|
+
arguments: String(item.arguments || "{}"),
|
|
432
|
+
...programCaller(item) ? { caller: programCaller(item) } : {}
|
|
366
433
|
});
|
|
367
434
|
}
|
|
368
435
|
}
|
|
@@ -370,7 +437,12 @@ async function readResponsesJson(res) {
|
|
|
370
437
|
text,
|
|
371
438
|
toolCalls,
|
|
372
439
|
usage: toResponsesUsage(body.usage),
|
|
373
|
-
|
|
440
|
+
responsesOutputItems: body.output,
|
|
441
|
+
finishReason: responsesFinishReason(
|
|
442
|
+
body.output,
|
|
443
|
+
toolCalls.length,
|
|
444
|
+
body.status === "incomplete" ? String(body.incomplete_details?.reason || "incomplete") : void 0
|
|
445
|
+
)
|
|
374
446
|
};
|
|
375
447
|
}
|
|
376
448
|
function cloneMessages(messages) {
|
|
@@ -387,9 +459,11 @@ function completionAssistantMessage(completion) {
|
|
|
387
459
|
tool_calls: completion.toolCalls.map((call) => ({
|
|
388
460
|
id: call.id,
|
|
389
461
|
type: "function",
|
|
390
|
-
function: { name: call.name, arguments: call.arguments }
|
|
462
|
+
function: { name: call.name, arguments: call.arguments },
|
|
463
|
+
...call.caller ? { caller: call.caller } : {}
|
|
391
464
|
}))
|
|
392
|
-
} : {}
|
|
465
|
+
} : {},
|
|
466
|
+
...completion.responsesOutputItems?.length ? { responses_output_items: completion.responsesOutputItems } : {}
|
|
393
467
|
};
|
|
394
468
|
}
|
|
395
469
|
function responseContinuationInput(messages, continuation) {
|
|
@@ -407,7 +481,12 @@ function responseContinuationInput(messages, continuation) {
|
|
|
407
481
|
return { input: responseInputFromMessages(messages), incremental: false };
|
|
408
482
|
}
|
|
409
483
|
const delta = messages.slice(continuation.requestMessages.length + 1);
|
|
410
|
-
if (!delta.length)
|
|
484
|
+
if (!delta.length) {
|
|
485
|
+
if (continuation.completion.finishReason === "continue") {
|
|
486
|
+
return { input: [], previousResponseId: continuation.responseId, incremental: true };
|
|
487
|
+
}
|
|
488
|
+
return { input: responseInputFromMessages(messages), incremental: false };
|
|
489
|
+
}
|
|
411
490
|
return {
|
|
412
491
|
input: responseInputFromMessages(delta),
|
|
413
492
|
previousResponseId: continuation.responseId,
|
|
@@ -421,6 +500,7 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
421
500
|
let finishReason;
|
|
422
501
|
let loopAt = -1;
|
|
423
502
|
const calls = /* @__PURE__ */ new Map();
|
|
503
|
+
const outputItems = /* @__PURE__ */ new Map();
|
|
424
504
|
const emitText = (delta) => {
|
|
425
505
|
if (!delta) return;
|
|
426
506
|
text += delta;
|
|
@@ -478,7 +558,8 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
478
558
|
calls.set(index, {
|
|
479
559
|
id: String(event.item.call_id || event.item.id || `call_${index}`),
|
|
480
560
|
name: String(event.item.name || ""),
|
|
481
|
-
arguments: String(event.item.arguments || "")
|
|
561
|
+
arguments: String(event.item.arguments || ""),
|
|
562
|
+
...programCaller(event.item) ? { caller: programCaller(event.item) } : {}
|
|
482
563
|
});
|
|
483
564
|
continue;
|
|
484
565
|
}
|
|
@@ -488,14 +569,18 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
488
569
|
if (call) call.arguments += String(event.delta || "");
|
|
489
570
|
continue;
|
|
490
571
|
}
|
|
491
|
-
if (event.type === "response.output_item.done" && event.item
|
|
492
|
-
const index = Number(event.output_index ??
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
572
|
+
if (event.type === "response.output_item.done" && event.item) {
|
|
573
|
+
const index = Number(event.output_index ?? outputItems.size);
|
|
574
|
+
outputItems.set(index, event.item);
|
|
575
|
+
if (event.item.type === "function_call") {
|
|
576
|
+
const current = calls.get(index);
|
|
577
|
+
calls.set(index, {
|
|
578
|
+
id: String(event.item.call_id || current?.id || event.item.id || `call_${index}`),
|
|
579
|
+
name: String(event.item.name || current?.name || ""),
|
|
580
|
+
arguments: String(event.item.arguments ?? current?.arguments ?? ""),
|
|
581
|
+
...programCaller(event.item) ?? current?.caller ? { caller: programCaller(event.item) ?? current?.caller } : {}
|
|
582
|
+
});
|
|
583
|
+
}
|
|
499
584
|
continue;
|
|
500
585
|
}
|
|
501
586
|
if (event.type === "response.failed") {
|
|
@@ -506,14 +591,20 @@ async function readResponsesWebSocketTurn(events, ws, onText, signal) {
|
|
|
506
591
|
if (event.type === "response.completed" || event.type === "response.incomplete") {
|
|
507
592
|
responseId = String(event.response?.id || responseId);
|
|
508
593
|
usage = toResponsesUsage(event.response?.usage);
|
|
509
|
-
|
|
594
|
+
const responsesOutputItems = event.response?.output ?? [...outputItems.entries()].sort(([a], [b]) => a - b).map(([, item]) => item);
|
|
595
|
+
finishReason = responsesFinishReason(
|
|
596
|
+
responsesOutputItems,
|
|
597
|
+
calls.size,
|
|
598
|
+
event.type === "response.incomplete" ? String(event.response?.incomplete_details?.reason || "incomplete") : void 0
|
|
599
|
+
);
|
|
510
600
|
return {
|
|
511
601
|
responseId,
|
|
512
602
|
completion: {
|
|
513
603
|
text,
|
|
514
604
|
toolCalls: [...calls.entries()].sort(([a], [b]) => a - b).map(([, call]) => call),
|
|
515
605
|
usage,
|
|
516
|
-
finishReason
|
|
606
|
+
finishReason,
|
|
607
|
+
responsesOutputItems
|
|
517
608
|
}
|
|
518
609
|
};
|
|
519
610
|
}
|
|
@@ -530,7 +621,8 @@ function createProvider(options) {
|
|
|
530
621
|
providerId,
|
|
531
622
|
fetch: fetchOverride,
|
|
532
623
|
retryDelayMs = 1e3,
|
|
533
|
-
responsesWebSocketFactory
|
|
624
|
+
responsesWebSocketFactory,
|
|
625
|
+
enableProgrammaticToolCalling = false
|
|
534
626
|
} = options;
|
|
535
627
|
const doFetch = fetchOverride ?? fetch;
|
|
536
628
|
const headers = { "content-type": "application/json" };
|
|
@@ -583,7 +675,7 @@ function createProvider(options) {
|
|
|
583
675
|
lunaWsIdleTimer.unref?.();
|
|
584
676
|
};
|
|
585
677
|
async function chatLunaWebSocket(messages, tools, reasoning, signal, onText) {
|
|
586
|
-
const nativeTools = responseTools(tools);
|
|
678
|
+
const nativeTools = responseTools(tools, enableProgrammaticToolCalling);
|
|
587
679
|
const initialPlan = responseContinuationInput(messages, lunaContinuation);
|
|
588
680
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
589
681
|
if (signal?.aborted) throw signal.reason ?? new Error("Request aborted");
|
|
@@ -675,7 +767,7 @@ function createProvider(options) {
|
|
|
675
767
|
}
|
|
676
768
|
}
|
|
677
769
|
if (useNativeResponses) {
|
|
678
|
-
const nativeTools = responseTools(tools);
|
|
770
|
+
const nativeTools = responseTools(tools, enableProgrammaticToolCalling);
|
|
679
771
|
const res2 = await post(
|
|
680
772
|
"/responses",
|
|
681
773
|
{
|
|
@@ -802,6 +894,8 @@ async function runProviderCommand(args, deps) {
|
|
|
802
894
|
}
|
|
803
895
|
|
|
804
896
|
export {
|
|
897
|
+
hasPendingProgrammaticReplay,
|
|
898
|
+
completionAssistantMessage,
|
|
805
899
|
createProvider,
|
|
806
900
|
listAllModels,
|
|
807
901
|
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-XD7MUX46.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-QXLXJWIL.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-ZBOI364S.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
|
}
|
|
@@ -1501,6 +1505,10 @@ function createTodoTool(store) {
|
|
|
1501
1505
|
|
|
1502
1506
|
// src/setup.ts
|
|
1503
1507
|
var TOOL_RULES = { bash: "bash", edit: "edit", write: "edit", fetch: "fetch" };
|
|
1508
|
+
function lunaPtcAutoEnabled(env) {
|
|
1509
|
+
const value = String(env.BCCLI_LUNA_PTC ?? "").trim().toLowerCase();
|
|
1510
|
+
return !["0", "false", "off", "no"].includes(value);
|
|
1511
|
+
}
|
|
1504
1512
|
function createRuntime(opts) {
|
|
1505
1513
|
const env = opts.env ?? process.env;
|
|
1506
1514
|
const home = bccliHome(env);
|
|
@@ -1509,7 +1517,13 @@ function createRuntime(opts) {
|
|
|
1509
1517
|
let reasoning = opts.args.reasoning ?? config.reasoning;
|
|
1510
1518
|
const makeProvider = (ref) => {
|
|
1511
1519
|
const resolved = resolveModel(config, ref, env);
|
|
1512
|
-
return opts.provider ?? createProvider({
|
|
1520
|
+
return opts.provider ?? createProvider({
|
|
1521
|
+
baseURL: resolved.baseURL,
|
|
1522
|
+
apiKey: resolved.apiKey,
|
|
1523
|
+
model: resolved.model,
|
|
1524
|
+
providerId: resolved.providerId,
|
|
1525
|
+
enableProgrammaticToolCalling: lunaPtcAutoEnabled(env)
|
|
1526
|
+
});
|
|
1513
1527
|
};
|
|
1514
1528
|
const provider = makeProvider(modelRef);
|
|
1515
1529
|
const mode = opts.args.allowAll ? "allowAll" : opts.args.permissionMode ?? config.permissionMode;
|
|
@@ -1645,7 +1659,7 @@ function createRuntime(opts) {
|
|
|
1645
1659
|
}
|
|
1646
1660
|
|
|
1647
1661
|
// src/version.ts
|
|
1648
|
-
var VERSION = true ? "0.4.0-beta.
|
|
1662
|
+
var VERSION = true ? "0.4.0-beta.24" : "0.0.0-dev";
|
|
1649
1663
|
|
|
1650
1664
|
// src/cli.ts
|
|
1651
1665
|
function chooseLanguage(argv) {
|
|
@@ -1671,12 +1685,12 @@ async function main() {
|
|
|
1671
1685
|
if (args.command === "login") return runLogin(args.loginProvider ?? "bc-cloud", cwd);
|
|
1672
1686
|
if (args.command === "mcp") {
|
|
1673
1687
|
const { runMcpCommand } = await import("./mcpCli-J43FHF2H.js");
|
|
1674
|
-
const { readSecret } = await import("./login-
|
|
1688
|
+
const { readSecret } = await import("./login-YHBC2ITY.js");
|
|
1675
1689
|
return runMcpCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1676
1690
|
}
|
|
1677
1691
|
if (args.command === "provider") {
|
|
1678
|
-
const { runProviderCommand } = await import("./providerCli-
|
|
1679
|
-
const { readSecret } = await import("./login-
|
|
1692
|
+
const { runProviderCommand } = await import("./providerCli-XD7MUX46.js");
|
|
1693
|
+
const { readSecret } = await import("./login-YHBC2ITY.js");
|
|
1680
1694
|
return runProviderCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1681
1695
|
}
|
|
1682
1696
|
if (args.command === "connect" || args.command === "disconnect" || args.command === "integrations") {
|