@botconnector/bccli 0.4.0-beta.37 → 0.4.0-beta.39
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/README.md +8 -0
- package/dist/acp-4XE2KOIJ.js +114 -0
- package/dist/{args-MNVI2OJI.js → args-BD2PHEKG.js} +4 -4
- package/dist/{chunk-TASYQW7B.js → chunk-AVB6M4JE.js} +2 -2
- package/dist/{chunk-FCQCZCKO.js → chunk-EONFDWBE.js} +2 -2
- package/dist/{chunk-7TABTC32.js → chunk-GGNXHJL6.js} +4 -3
- package/dist/chunk-HE33XAPZ.js +341 -0
- package/dist/{chunk-HPZSXX4W.js → chunk-ISCT3PN3.js} +2 -2
- package/dist/{chunk-BB4CVWHS.js → chunk-JROUQ5YS.js} +6 -45
- package/dist/chunk-LN32JIZR.js +56 -0
- package/dist/{chunk-4RMP4CNT.js → chunk-M23QBX3V.js} +52 -12
- package/dist/chunk-M7LLJQ7M.js +310 -0
- package/dist/{chunk-YURAIW7A.js → chunk-NI5JZUZ3.js} +1 -1
- package/dist/chunk-PDZPPSLU.js +8 -0
- package/dist/chunk-PSO7R5AD.js +10 -0
- package/dist/chunk-QETGQXPL.js +2125 -0
- package/dist/chunk-RV74TCEP.js +231 -0
- package/dist/{chunk-U66JJ6RN.js → chunk-SESBH44L.js} +1 -1
- package/dist/{chunk-3JRBXJVB.js → chunk-VM7HYAJS.js} +1 -1
- package/dist/{chunk-ASTNW3X2.js → chunk-ZG7HCXYA.js} +89 -9
- package/dist/{chunk-HXSREA7S.js → chunk-ZMU7MXCH.js} +184 -295
- package/dist/cli.js +65 -2097
- package/dist/{config-JRO5EOKZ.js → config-C4KLLDC6.js} +3 -3
- package/dist/{integrationCli-ZTZTQD2I.js → integrationCli-HR7CDUSI.js} +2 -2
- package/dist/{login-MHVCON5R.js → login-IWBRUNT4.js} +1 -1
- package/dist/{mcpCli-5ZSAMBJS.js → mcpCli-5QTXH7XJ.js} +9 -5
- package/dist/modelsCli-DKTT3UZD.js +36 -0
- package/dist/providerCli-DDH4ZZUY.js +15 -0
- package/dist/sdk.js +5114 -0
- package/dist/serve-7BP5BVX3.js +514 -0
- package/dist/serve-I2VQUTHR.js +178 -0
- package/dist/session-H2YL5RSB.js +12 -0
- package/dist/setup-FGCFKC7Z.js +23 -0
- package/dist/{ui-YLIKFLGN.js → ui-MLOXPAHT.js} +292 -54
- package/dist/update-73WI27VM.js +109 -0
- package/package.json +5 -2
- package/dist/chunk-H5N4ST6B.js +0 -149
- package/dist/providerCli-Z3TZ5XSZ.js +0 -14
- package/dist/session-IYVTCUBC.js +0 -12
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
VERSION
|
|
4
|
+
} from "./chunk-PDZPPSLU.js";
|
|
5
|
+
import {
|
|
6
|
+
t
|
|
7
|
+
} from "./chunk-M23QBX3V.js";
|
|
8
|
+
|
|
9
|
+
// src/update.ts
|
|
10
|
+
import { spawnSync } from "child_process";
|
|
11
|
+
import { mkdirSync, readFileSync, renameSync, writeFileSync } from "fs";
|
|
12
|
+
import { join } from "path";
|
|
13
|
+
var REGISTRY_URL = "https://registry.npmjs.org/-/package/@botconnector/bccli/dist-tags";
|
|
14
|
+
var CHECK_INTERVAL_MS = 24 * 60 * 60 * 1e3;
|
|
15
|
+
function splitVersion(v) {
|
|
16
|
+
const i = v.indexOf("-");
|
|
17
|
+
const coreStr = i < 0 ? v : v.slice(0, i);
|
|
18
|
+
const preStr = i < 0 ? "" : v.slice(i + 1);
|
|
19
|
+
return {
|
|
20
|
+
core: coreStr.split(".").map((p) => Number.parseInt(p, 10) || 0),
|
|
21
|
+
pre: preStr ? preStr.split(".") : []
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function compareVersions(a, b) {
|
|
25
|
+
const A = splitVersion(a);
|
|
26
|
+
const B = splitVersion(b);
|
|
27
|
+
for (let i = 0; i < Math.max(A.core.length, B.core.length); i++) {
|
|
28
|
+
const x = A.core[i] ?? 0;
|
|
29
|
+
const y = B.core[i] ?? 0;
|
|
30
|
+
if (x !== y) return x < y ? -1 : 1;
|
|
31
|
+
}
|
|
32
|
+
if (!A.pre.length && !B.pre.length) return 0;
|
|
33
|
+
if (!A.pre.length) return 1;
|
|
34
|
+
if (!B.pre.length) return -1;
|
|
35
|
+
for (let i = 0; i < Math.max(A.pre.length, B.pre.length); i++) {
|
|
36
|
+
const x = A.pre[i];
|
|
37
|
+
const y = B.pre[i];
|
|
38
|
+
if (x === void 0) return -1;
|
|
39
|
+
if (y === void 0) return 1;
|
|
40
|
+
const nx = Number.parseInt(x, 10);
|
|
41
|
+
const ny = Number.parseInt(y, 10);
|
|
42
|
+
if (String(nx) === x && String(ny) === y) {
|
|
43
|
+
if (nx !== ny) return nx < ny ? -1 : 1;
|
|
44
|
+
} else if (x !== y) {
|
|
45
|
+
return x < y ? -1 : 1;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return 0;
|
|
49
|
+
}
|
|
50
|
+
function channelFor(version) {
|
|
51
|
+
return version.includes("-") ? "next" : "latest";
|
|
52
|
+
}
|
|
53
|
+
function cachePath(home) {
|
|
54
|
+
return join(home, "update-check.json");
|
|
55
|
+
}
|
|
56
|
+
function readCache(home) {
|
|
57
|
+
try {
|
|
58
|
+
const parsed = JSON.parse(readFileSync(cachePath(home), "utf8"));
|
|
59
|
+
return typeof parsed?.checkedAt === "string" ? parsed : void 0;
|
|
60
|
+
} catch {
|
|
61
|
+
return void 0;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function writeCache(home, cache) {
|
|
65
|
+
mkdirSync(home, { recursive: true });
|
|
66
|
+
const tmp = `${cachePath(home)}.tmp`;
|
|
67
|
+
writeFileSync(tmp, JSON.stringify(cache));
|
|
68
|
+
renameSync(tmp, cachePath(home));
|
|
69
|
+
}
|
|
70
|
+
function dueForCheck(cache, now, intervalMs = CHECK_INTERVAL_MS) {
|
|
71
|
+
if (!cache) return true;
|
|
72
|
+
const at = Date.parse(cache.checkedAt);
|
|
73
|
+
if (!Number.isFinite(at)) return true;
|
|
74
|
+
return now.getTime() - at >= intervalMs;
|
|
75
|
+
}
|
|
76
|
+
function updateNotice(current, latest) {
|
|
77
|
+
if (!latest || compareVersions(current, latest) >= 0) return void 0;
|
|
78
|
+
return t("A new bccli is available: {latest} (you have {current}). Run: bccli update", { latest, current });
|
|
79
|
+
}
|
|
80
|
+
async function checkForUpdate(deps) {
|
|
81
|
+
try {
|
|
82
|
+
const cached = readCache(deps.home);
|
|
83
|
+
if (!dueForCheck(cached, deps.now)) return updateNotice(VERSION, cached?.latest);
|
|
84
|
+
const res = await deps.fetch(REGISTRY_URL, { signal: AbortSignal.timeout(deps.timeoutMs ?? 3e3) });
|
|
85
|
+
if (!res.ok) return updateNotice(VERSION, cached?.latest);
|
|
86
|
+
const tags = await res.json();
|
|
87
|
+
const latest = tags[channelFor(VERSION)] ?? tags.latest;
|
|
88
|
+
writeCache(deps.home, { checkedAt: deps.now.toISOString(), latest });
|
|
89
|
+
return updateNotice(VERSION, latest);
|
|
90
|
+
} catch {
|
|
91
|
+
return void 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
async function runUpdateCommand(deps) {
|
|
95
|
+
const version = deps.env.BCCLI_VERSION_OVERRIDE ?? VERSION;
|
|
96
|
+
const spec = `@botconnector/bccli@${channelFor(version)}`;
|
|
97
|
+
const spawnFn = deps.spawn ?? spawnSync;
|
|
98
|
+
const cmd = process.platform === "win32" ? "npm.cmd" : "npm";
|
|
99
|
+
const r = spawnFn(cmd, ["i", "-g", spec], { stdio: "inherit", env: deps.env });
|
|
100
|
+
return typeof r.status === "number" ? r.status : 1;
|
|
101
|
+
}
|
|
102
|
+
export {
|
|
103
|
+
channelFor,
|
|
104
|
+
checkForUpdate,
|
|
105
|
+
compareVersions,
|
|
106
|
+
dueForCheck,
|
|
107
|
+
runUpdateCommand,
|
|
108
|
+
updateNotice
|
|
109
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@botconnector/bccli",
|
|
3
|
-
"version": "0.4.0-beta.
|
|
3
|
+
"version": "0.4.0-beta.39",
|
|
4
4
|
"description": "BCCLI — BotConnector AI coding agent for the terminal",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -47,7 +47,10 @@
|
|
|
47
47
|
"overrides": {
|
|
48
48
|
"esbuild": "0.28.2"
|
|
49
49
|
},
|
|
50
|
-
"main": "
|
|
50
|
+
"main": "dist/sdk.js",
|
|
51
|
+
"exports": {
|
|
52
|
+
".": "./dist/sdk.js"
|
|
53
|
+
},
|
|
51
54
|
"directories": {
|
|
52
55
|
"doc": "docs",
|
|
53
56
|
"test": "test"
|
package/dist/chunk-H5N4ST6B.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
t
|
|
4
|
-
} from "./chunk-4RMP4CNT.js";
|
|
5
|
-
|
|
6
|
-
// src/presets.ts
|
|
7
|
-
var PRESETS = [
|
|
8
|
-
{ id: "bc-cloud", name: "BotConnector Cloud", baseURL: "https://api.botconnector.id/v1", apiKeyEnv: "BOTCONNECTOR_API_KEY" },
|
|
9
|
-
{ id: "openrouter", name: "OpenRouter", baseURL: "https://openrouter.ai/api/v1", apiKeyEnv: "OPENROUTER_API_KEY" },
|
|
10
|
-
{ id: "openai", name: "OpenAI", baseURL: "https://api.openai.com/v1", apiKeyEnv: "OPENAI_API_KEY" },
|
|
11
|
-
{ id: "gemini", name: "Google Gemini", baseURL: "https://generativelanguage.googleapis.com/v1beta/openai", apiKeyEnv: "GEMINI_API_KEY" },
|
|
12
|
-
{ id: "deepseek", name: "DeepSeek", baseURL: "https://api.deepseek.com/v1", apiKeyEnv: "DEEPSEEK_API_KEY" },
|
|
13
|
-
{ id: "groq", name: "Groq", baseURL: "https://api.groq.com/openai/v1", apiKeyEnv: "GROQ_API_KEY" },
|
|
14
|
-
{ id: "ollama-cloud", name: "Ollama Cloud", baseURL: "https://ollama.com/v1", apiKeyEnv: "OLLAMA_API_KEY" },
|
|
15
|
-
{ id: "ollama", name: "Ollama lokal", baseURL: "http://127.0.0.1:11434/v1", local: true },
|
|
16
|
-
{ id: "lmstudio", name: "LM Studio lokal", baseURL: "http://127.0.0.1:1234/v1", local: true }
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
// src/config.ts
|
|
20
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
21
|
-
import { homedir } from "os";
|
|
22
|
-
import { join } from "path";
|
|
23
|
-
var ConfigError = class extends Error {
|
|
24
|
-
};
|
|
25
|
-
var DEFAULT_MAX_STEPS = 100;
|
|
26
|
-
var DEFAULT_CONFIG = {
|
|
27
|
-
model: "bc-cloud/glm-5.3-flash",
|
|
28
|
-
permissionMode: "default",
|
|
29
|
-
reasoning: "auto",
|
|
30
|
-
vision: true,
|
|
31
|
-
networkPolicy: "allow",
|
|
32
|
-
providers: Object.fromEntries(PRESETS.map((p) => [p.id, { baseURL: p.baseURL, apiKeyEnv: p.apiKeyEnv }])),
|
|
33
|
-
allow: []
|
|
34
|
-
};
|
|
35
|
-
function bccliHome(env = process.env) {
|
|
36
|
-
return env.BCCLI_HOME ?? join(homedir(), ".bccli");
|
|
37
|
-
}
|
|
38
|
-
function readJsonConfig(path) {
|
|
39
|
-
if (!existsSync(path)) return {};
|
|
40
|
-
try {
|
|
41
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
42
|
-
} catch (error) {
|
|
43
|
-
throw new ConfigError(t("Invalid config: {path} ({error})", { path, error: error.message }));
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
function resolvedMaxSteps(global) {
|
|
47
|
-
const value = global.maxSteps;
|
|
48
|
-
if (value === void 0) return DEFAULT_MAX_STEPS;
|
|
49
|
-
if (value === null || value === 0) return null;
|
|
50
|
-
if (typeof value !== "number" || !Number.isFinite(value) || value < 0) {
|
|
51
|
-
throw new ConfigError(t("maxSteps must be a positive number, or 0/null to disable the limit."));
|
|
52
|
-
}
|
|
53
|
-
return Math.max(1, Math.floor(value));
|
|
54
|
-
}
|
|
55
|
-
function resolvedNetworkPolicy(global) {
|
|
56
|
-
const value = global.networkPolicy ?? "allow";
|
|
57
|
-
if (value !== "allow" && value !== "offline") {
|
|
58
|
-
throw new ConfigError(t('networkPolicy must be "allow" or "offline".'));
|
|
59
|
-
}
|
|
60
|
-
return value;
|
|
61
|
-
}
|
|
62
|
-
function resolvedPlugins(global) {
|
|
63
|
-
const value = global.plugins;
|
|
64
|
-
if (value === void 0) return [];
|
|
65
|
-
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
|
|
66
|
-
throw new ConfigError(t("plugins must be an array of strings."));
|
|
67
|
-
}
|
|
68
|
-
return [...value];
|
|
69
|
-
}
|
|
70
|
-
function untrustedProviders(project, known) {
|
|
71
|
-
const out = {};
|
|
72
|
-
for (const [id, provider] of Object.entries(project.providers ?? {})) {
|
|
73
|
-
if (known[id] || typeof provider?.baseURL !== "string") continue;
|
|
74
|
-
out[id] = { baseURL: provider.baseURL };
|
|
75
|
-
}
|
|
76
|
-
return out;
|
|
77
|
-
}
|
|
78
|
-
function loadConfig(cwd, env = process.env) {
|
|
79
|
-
const global = readJsonConfig(join(bccliHome(env), "config.json"));
|
|
80
|
-
const project = readJsonConfig(join(cwd, ".bccli", "config.json"));
|
|
81
|
-
const known = { ...DEFAULT_CONFIG.providers, ...global.providers };
|
|
82
|
-
const fromProject = untrustedProviders(project, known);
|
|
83
|
-
return {
|
|
84
|
-
model: project.model ?? global.model ?? DEFAULT_CONFIG.model,
|
|
85
|
-
permissionMode: global.permissionMode ?? DEFAULT_CONFIG.permissionMode,
|
|
86
|
-
reasoning: global.reasoning ?? DEFAULT_CONFIG.reasoning,
|
|
87
|
-
maxSteps: resolvedMaxSteps(global),
|
|
88
|
-
hooks: global.hooks,
|
|
89
|
-
vision: global.vision ?? DEFAULT_CONFIG.vision,
|
|
90
|
-
networkPolicy: resolvedNetworkPolicy(global),
|
|
91
|
-
plugins: resolvedPlugins(global),
|
|
92
|
-
providers: { ...known, ...fromProject },
|
|
93
|
-
projectProviders: Object.keys(fromProject),
|
|
94
|
-
allow: [...global.allow ?? []]
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
function readCredentials(env = process.env) {
|
|
98
|
-
const path = join(bccliHome(env), "credentials");
|
|
99
|
-
if (!existsSync(path)) return {};
|
|
100
|
-
try {
|
|
101
|
-
return JSON.parse(readFileSync(path, "utf8"));
|
|
102
|
-
} catch {
|
|
103
|
-
return {};
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
function saveCredential(providerId, key, env = process.env) {
|
|
107
|
-
const home = bccliHome(env);
|
|
108
|
-
mkdirSync(home, { recursive: true });
|
|
109
|
-
const path = join(home, "credentials");
|
|
110
|
-
writeFileSync(path, JSON.stringify({ ...readCredentials(env), [providerId]: key }, null, 2), { mode: 384 });
|
|
111
|
-
chmodSync(path, 384);
|
|
112
|
-
}
|
|
113
|
-
function resolveModel(config, modelRef, env = process.env) {
|
|
114
|
-
const slash = modelRef.indexOf("/");
|
|
115
|
-
if (slash <= 0 || slash === modelRef.length - 1) {
|
|
116
|
-
throw new ConfigError(t("Model must be in provider/model format, e.g. bc-cloud/glm-5.3-flash (got: {ref})", { ref: modelRef }));
|
|
117
|
-
}
|
|
118
|
-
const providerId = modelRef.slice(0, slash);
|
|
119
|
-
const provider = config.providers[providerId];
|
|
120
|
-
if (!provider) {
|
|
121
|
-
throw new ConfigError(t('Provider "{id}" is not in the config. Available: {list}', { id: providerId, list: Object.keys(config.providers).join(", ") }));
|
|
122
|
-
}
|
|
123
|
-
const apiKey = (provider.apiKeyEnv ? env[provider.apiKeyEnv] : void 0) || readCredentials(env)[providerId] || void 0;
|
|
124
|
-
if (provider.apiKeyEnv && !apiKey) {
|
|
125
|
-
throw new ConfigError(t("No API key for {id} yet. Run `bccli login` or set the env var {env}.", { id: providerId, env: provider.apiKeyEnv }));
|
|
126
|
-
}
|
|
127
|
-
return { providerId, model: modelRef.slice(slash + 1), baseURL: provider.baseURL.replace(/\/+$/, ""), apiKey };
|
|
128
|
-
}
|
|
129
|
-
function removeCredential(providerId, env = process.env) {
|
|
130
|
-
const creds = readCredentials(env);
|
|
131
|
-
if (!(providerId in creds)) return false;
|
|
132
|
-
delete creds[providerId];
|
|
133
|
-
const path = join(bccliHome(env), "credentials");
|
|
134
|
-
writeFileSync(path, JSON.stringify(creds, null, 2), { mode: 384 });
|
|
135
|
-
chmodSync(path, 384);
|
|
136
|
-
return true;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
export {
|
|
140
|
-
PRESETS,
|
|
141
|
-
ConfigError,
|
|
142
|
-
bccliHome,
|
|
143
|
-
readJsonConfig,
|
|
144
|
-
loadConfig,
|
|
145
|
-
readCredentials,
|
|
146
|
-
saveCredential,
|
|
147
|
-
resolveModel,
|
|
148
|
-
removeCredential
|
|
149
|
-
};
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
addProviderKey,
|
|
4
|
-
runProviderCommand
|
|
5
|
-
} from "./chunk-BB4CVWHS.js";
|
|
6
|
-
import "./chunk-U66JJ6RN.js";
|
|
7
|
-
import "./chunk-7TABTC32.js";
|
|
8
|
-
import "./chunk-YURAIW7A.js";
|
|
9
|
-
import "./chunk-H5N4ST6B.js";
|
|
10
|
-
import "./chunk-4RMP4CNT.js";
|
|
11
|
-
export {
|
|
12
|
-
addProviderKey,
|
|
13
|
-
runProviderCommand
|
|
14
|
-
};
|
package/dist/session-IYVTCUBC.js
DELETED