@botconnector/bccli 0.4.0-beta.25 → 0.4.0-beta.27
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-FRB3MUQY.js → chunk-CJEIJ5VW.js} +1 -1
- package/dist/{chunk-Z4CIQZA5.js → chunk-IXAVAK7R.js} +28 -12
- package/dist/cli.js +8 -6
- package/dist/{login-LXPNZMD7.js → login-MOXJVDKB.js} +1 -1
- package/dist/{providerCli-ELUAGUNX.js → providerCli-G5OGC2UN.js} +1 -1
- package/package.json +1 -1
|
@@ -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-G5OGC2UN.js");
|
|
39
39
|
const { parseCliArgs } = await import("./args-XQYEBOKB.js");
|
|
40
40
|
return runProviderCommand(parseCliArgs(["provider", "add", providerId]), {
|
|
41
41
|
env: process.env,
|
|
@@ -238,7 +238,17 @@ var LUNA_TOOL_SEARCH_MIN_MCP_SCHEMA_CHARS = 32e3;
|
|
|
238
238
|
var LUNA_PTC_SAFE_FUNCTIONS = /* @__PURE__ */ new Set(["read", "grep", "glob"]);
|
|
239
239
|
var LUNA_PTC_TOOL_OUTPUT_TRIGGER_CHARS = 8e3;
|
|
240
240
|
var LUNA_PTC_MULTI_WORK_CUE = /\b(both|all|multiple|several|compare|comparison|aggregate|aggregation|total|count|sum|average|filter|join|merge|dedupe|deduplicate|rank|scan|across|every|semua|keduanya|beberapa|bandingkan|perbandingan|agregasi|hitung|jumlah|rata[- ]?rata|gabung|deduplikasi|urutkan|pindai|seluruh)\b|\b(many|banyak)\s+(files?|file|records?|rows?|items?|dokumen|berkas)\b/i;
|
|
241
|
-
|
|
241
|
+
var LUNA_PTC_FORCE_CUE = /\b(count|sum|total|average|aggregate|aggregation|filter|join|merge|dedupe|deduplicate|hitung|jumlah|rata[- ]?rata|agregasi|gabung|deduplikasi)\b/i;
|
|
242
|
+
function shouldForceLunaPtc(messages, enabled) {
|
|
243
|
+
if (!enabled) return false;
|
|
244
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
245
|
+
const message = messages[i];
|
|
246
|
+
if (message.role === "assistant" && message.responses_output_items?.some((item) => item.type === "program")) return true;
|
|
247
|
+
if (message.role === "user") return LUNA_PTC_FORCE_CUE.test(message.content);
|
|
248
|
+
}
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
function shouldEnableLunaPtc(messages, enabled, programmaticToolNames = []) {
|
|
242
252
|
if (!enabled) return false;
|
|
243
253
|
let lastUser = -1;
|
|
244
254
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
@@ -251,13 +261,14 @@ function shouldEnableLunaPtc(messages, enabled) {
|
|
|
251
261
|
const latestUser = lastUser >= 0 ? messages[lastUser] : void 0;
|
|
252
262
|
const prompt = latestUser?.role === "user" ? latestUser.content : "";
|
|
253
263
|
if (LUNA_PTC_MULTI_WORK_CUE.test(prompt)) return true;
|
|
264
|
+
const safeToolNames = /* @__PURE__ */ new Set([...LUNA_PTC_SAFE_FUNCTIONS, ...programmaticToolNames]);
|
|
254
265
|
const safeCalls = /* @__PURE__ */ new Set();
|
|
255
266
|
let safeOutputChars = 0;
|
|
256
267
|
for (const message of turn) {
|
|
257
268
|
if (message.role === "assistant") {
|
|
258
269
|
if (message.responses_output_items?.some((item) => item.type === "program")) return true;
|
|
259
270
|
for (const call of message.tool_calls ?? []) {
|
|
260
|
-
if (
|
|
271
|
+
if (safeToolNames.has(call.function.name)) safeCalls.add(call.id);
|
|
261
272
|
}
|
|
262
273
|
continue;
|
|
263
274
|
}
|
|
@@ -268,7 +279,7 @@ function shouldEnableLunaPtc(messages, enabled) {
|
|
|
268
279
|
}
|
|
269
280
|
return false;
|
|
270
281
|
}
|
|
271
|
-
function lunaToolPlan(tools, enableProgrammaticToolCalling = false) {
|
|
282
|
+
function lunaToolPlan(tools, enableProgrammaticToolCalling = false, programmaticToolNames = [], forceProgrammaticOnly = false) {
|
|
272
283
|
const native = (tools ?? []).map((tool) => ({
|
|
273
284
|
type: "function",
|
|
274
285
|
name: tool.function.name,
|
|
@@ -280,10 +291,11 @@ function lunaToolPlan(tools, enableProgrammaticToolCalling = false) {
|
|
|
280
291
|
const deferredSchemaChars = mcpIndexes.reduce((sum, index) => sum + JSON.stringify(native[index]).length, 0);
|
|
281
292
|
const useToolSearch = mcpIndexes.length >= LUNA_TOOL_SEARCH_MIN_MCP_TOOLS || deferredSchemaChars >= LUNA_TOOL_SEARCH_MIN_MCP_SCHEMA_CHARS;
|
|
282
293
|
let programmaticToolCount = 0;
|
|
294
|
+
const safeToolNames = /* @__PURE__ */ new Set([...LUNA_PTC_SAFE_FUNCTIONS, ...programmaticToolNames]);
|
|
283
295
|
if (enableProgrammaticToolCalling) {
|
|
284
296
|
for (let index = 0; index < native.length; index++) {
|
|
285
|
-
if (
|
|
286
|
-
native[index] = { ...native[index], allowed_callers: ["direct", "programmatic"] };
|
|
297
|
+
if (safeToolNames.has(String(native[index].name))) {
|
|
298
|
+
native[index] = { ...native[index], allowed_callers: forceProgrammaticOnly ? ["programmatic"] : ["direct", "programmatic"] };
|
|
287
299
|
programmaticToolCount++;
|
|
288
300
|
}
|
|
289
301
|
}
|
|
@@ -312,8 +324,8 @@ function lunaToolPlan(tools, enableProgrammaticToolCalling = false) {
|
|
|
312
324
|
deferredSchemaChars
|
|
313
325
|
};
|
|
314
326
|
}
|
|
315
|
-
function responseTools(tools, enableProgrammaticToolCalling = false) {
|
|
316
|
-
return lunaToolPlan(tools, enableProgrammaticToolCalling).tools;
|
|
327
|
+
function responseTools(tools, enableProgrammaticToolCalling = false, programmaticToolNames = [], forceProgrammaticOnly = false) {
|
|
328
|
+
return lunaToolPlan(tools, enableProgrammaticToolCalling, programmaticToolNames, forceProgrammaticOnly).tools;
|
|
317
329
|
}
|
|
318
330
|
function responseReasoning(level) {
|
|
319
331
|
if (level === "auto") return {};
|
|
@@ -706,8 +718,10 @@ function createProvider(options) {
|
|
|
706
718
|
lunaWsIdleTimer = setTimeout(() => resetLunaWebSocket(), 10 * 6e4);
|
|
707
719
|
lunaWsIdleTimer.unref?.();
|
|
708
720
|
};
|
|
709
|
-
async function chatLunaWebSocket(messages, tools, reasoning, signal, onText) {
|
|
710
|
-
const
|
|
721
|
+
async function chatLunaWebSocket(messages, tools, programmaticToolNames, reasoning, signal, onText) {
|
|
722
|
+
const ptcEnabled = shouldEnableLunaPtc(messages, enableProgrammaticToolCalling, programmaticToolNames);
|
|
723
|
+
const forcePtc = shouldForceLunaPtc(messages, ptcEnabled);
|
|
724
|
+
const nativeTools = responseTools(tools, ptcEnabled, programmaticToolNames, forcePtc);
|
|
711
725
|
const initialPlan = responseContinuationInput(messages, lunaContinuation);
|
|
712
726
|
for (let attempt = 0; attempt < 2; attempt++) {
|
|
713
727
|
if (signal?.aborted) throw signal.reason ?? new Error("Request aborted");
|
|
@@ -783,7 +797,7 @@ function createProvider(options) {
|
|
|
783
797
|
throw lastError ?? new ProviderError(t("Request failed"));
|
|
784
798
|
}
|
|
785
799
|
return {
|
|
786
|
-
async chat({ messages, tools, signal, onText, onThinking, reasoning = "auto" }) {
|
|
800
|
+
async chat({ messages, tools, programmaticToolNames = [], signal, onText, onThinking, reasoning = "auto" }) {
|
|
787
801
|
let reasoningOverride;
|
|
788
802
|
try {
|
|
789
803
|
reasoningOverride = reasoningPayload(providerId, reasoning);
|
|
@@ -792,14 +806,16 @@ function createProvider(options) {
|
|
|
792
806
|
}
|
|
793
807
|
if (useResponsesWebSocket) {
|
|
794
808
|
try {
|
|
795
|
-
return await chatLunaWebSocket(messages, tools, reasoning, signal, onText);
|
|
809
|
+
return await chatLunaWebSocket(messages, tools, programmaticToolNames, reasoning, signal, onText);
|
|
796
810
|
} catch (error) {
|
|
797
811
|
const err = error instanceof ProviderError ? error : new ProviderError(error.message);
|
|
798
812
|
if (err.code !== "bc_ws_http_fallback") throw err;
|
|
799
813
|
}
|
|
800
814
|
}
|
|
801
815
|
if (useNativeResponses) {
|
|
802
|
-
const
|
|
816
|
+
const ptcEnabled = shouldEnableLunaPtc(messages, enableProgrammaticToolCalling, programmaticToolNames);
|
|
817
|
+
const forcePtc = shouldForceLunaPtc(messages, ptcEnabled);
|
|
818
|
+
const nativeTools = responseTools(tools, ptcEnabled, programmaticToolNames, forcePtc);
|
|
803
819
|
const res2 = await post(
|
|
804
820
|
"/responses",
|
|
805
821
|
{
|
package/dist/cli.js
CHANGED
|
@@ -22,7 +22,7 @@ import {
|
|
|
22
22
|
createProvider,
|
|
23
23
|
hasPendingProgrammaticReplay,
|
|
24
24
|
listAllModels
|
|
25
|
-
} from "./chunk-
|
|
25
|
+
} from "./chunk-IXAVAK7R.js";
|
|
26
26
|
import {
|
|
27
27
|
providerName,
|
|
28
28
|
readGlobalConfigFile
|
|
@@ -30,7 +30,7 @@ import {
|
|
|
30
30
|
import "./chunk-SN3ODJZN.js";
|
|
31
31
|
import {
|
|
32
32
|
runLogin
|
|
33
|
-
} from "./chunk-
|
|
33
|
+
} from "./chunk-CJEIJ5VW.js";
|
|
34
34
|
import {
|
|
35
35
|
Session,
|
|
36
36
|
pruneSessions
|
|
@@ -966,6 +966,7 @@ ${completion.text}` });
|
|
|
966
966
|
let completion = await this.provider.chat({
|
|
967
967
|
messages: [{ role: "system", content: this.systemPrompt }, ...this.messages],
|
|
968
968
|
tools: this.turnDefinitions,
|
|
969
|
+
programmaticToolNames: this.turnTools.filter((tool) => tool.programmaticSafe).map((tool) => tool.name),
|
|
969
970
|
signal,
|
|
970
971
|
onText: (delta) => this.onEvent({ type: "text", delta }),
|
|
971
972
|
onThinking: (delta) => this.onEvent({ type: "thinking", delta }),
|
|
@@ -1247,6 +1248,7 @@ var McpManager = class {
|
|
|
1247
1248
|
schema: z9.record(z9.string(), z9.unknown()),
|
|
1248
1249
|
jsonSchema: tool.inputSchema,
|
|
1249
1250
|
kind: "mcp",
|
|
1251
|
+
programmaticSafe: tool.annotations?.readOnlyHint === true,
|
|
1250
1252
|
target: (input) => {
|
|
1251
1253
|
const text = JSON.stringify(input);
|
|
1252
1254
|
return text.length > 80 ? `${text.slice(0, 77)}\u2026` : text;
|
|
@@ -1659,7 +1661,7 @@ function createRuntime(opts) {
|
|
|
1659
1661
|
}
|
|
1660
1662
|
|
|
1661
1663
|
// src/version.ts
|
|
1662
|
-
var VERSION = true ? "0.4.0-beta.
|
|
1664
|
+
var VERSION = true ? "0.4.0-beta.27" : "0.0.0-dev";
|
|
1663
1665
|
|
|
1664
1666
|
// src/cli.ts
|
|
1665
1667
|
function chooseLanguage(argv) {
|
|
@@ -1685,12 +1687,12 @@ async function main() {
|
|
|
1685
1687
|
if (args.command === "login") return runLogin(args.loginProvider ?? "bc-cloud", cwd);
|
|
1686
1688
|
if (args.command === "mcp") {
|
|
1687
1689
|
const { runMcpCommand } = await import("./mcpCli-J43FHF2H.js");
|
|
1688
|
-
const { readSecret } = await import("./login-
|
|
1690
|
+
const { readSecret } = await import("./login-MOXJVDKB.js");
|
|
1689
1691
|
return runMcpCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1690
1692
|
}
|
|
1691
1693
|
if (args.command === "provider") {
|
|
1692
|
-
const { runProviderCommand } = await import("./providerCli-
|
|
1693
|
-
const { readSecret } = await import("./login-
|
|
1694
|
+
const { runProviderCommand } = await import("./providerCli-G5OGC2UN.js");
|
|
1695
|
+
const { readSecret } = await import("./login-MOXJVDKB.js");
|
|
1694
1696
|
return runProviderCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
|
|
1695
1697
|
}
|
|
1696
1698
|
if (args.command === "connect" || args.command === "disconnect" || args.command === "integrations") {
|