@botconnector/bccli 0.4.0-beta.4 → 0.4.0-beta.40
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 +80 -1
- package/dist/acp-5A7EXLCG.js +114 -0
- package/dist/args-4SMOHFN5.js +13 -0
- package/dist/chunk-3HCOAJEQ.js +190 -0
- package/dist/chunk-AS7VV7D3.js +195 -0
- package/dist/{chunk-NGLKANMD.js → chunk-AVB6M4JE.js} +24 -2
- package/dist/{chunk-GW36UMHZ.js → chunk-DSFHN5CH.js} +2 -2
- package/dist/{chunk-ELML4KVQ.js → chunk-GAFJEQTJ.js} +32 -2
- package/dist/chunk-GGNXHJL6.js +884 -0
- package/dist/chunk-HE33XAPZ.js +341 -0
- package/dist/{chunk-UESQNU4A.js → chunk-ISCT3PN3.js} +14 -9
- package/dist/chunk-JROUQ5YS.js +76 -0
- package/dist/chunk-LN32JIZR.js +56 -0
- package/dist/chunk-M23QBX3V.js +419 -0
- package/dist/chunk-M7LLJQ7M.js +310 -0
- package/dist/chunk-NI5JZUZ3.js +63 -0
- package/dist/chunk-PDVS4UWM.js +8 -0
- package/dist/chunk-PSO7R5AD.js +10 -0
- package/dist/chunk-RV74TCEP.js +231 -0
- package/dist/{chunk-U7DLMVPZ.js → chunk-SESBH44L.js} +2 -1
- package/dist/{chunk-SJH3YLW4.js → chunk-VM7HYAJS.js} +4 -1
- package/dist/chunk-WH7XLDGZ.js +2125 -0
- package/dist/chunk-ZMU7MXCH.js +674 -0
- package/dist/cli.js +94 -1278
- package/dist/{config-NPSYFAFD.js → config-C4KLLDC6.js} +5 -2
- package/dist/integrationCli-HR7CDUSI.js +685 -0
- package/dist/{login-F4G5QXOU.js → login-T5S6SPZA.js} +1 -1
- package/dist/{mcpCli-Q2H63ISP.js → mcpCli-5QTXH7XJ.js} +42 -9
- package/dist/modelsCli-DKTT3UZD.js +36 -0
- package/dist/providerCli-DDH4ZZUY.js +15 -0
- package/dist/sdk.js +5130 -0
- package/dist/serve-I2VQUTHR.js +178 -0
- package/dist/serve-JNQUP7CZ.js +514 -0
- package/dist/session-H2YL5RSB.js +12 -0
- package/dist/setup-I7UY7X7C.js +23 -0
- package/dist/ui-GVIMUZNS.js +2280 -0
- package/dist/update-SZUG3YSB.js +109 -0
- package/package.json +24 -3
- package/dist/args-FCLPQ7TO.js +0 -11
- package/dist/chunk-C5AFWX7H.js +0 -328
- package/dist/chunk-OSWQPSA4.js +0 -252
- package/dist/chunk-RZUJYAQV.js +0 -112
- package/dist/chunk-UN7QXPCB.js +0 -82
- package/dist/providerCli-MXV6PD6F.js +0 -11
- package/dist/session-7UB77CEG.js +0 -9
- package/dist/ui-7FXPXXGN.js +0 -1333
|
@@ -1,12 +1,33 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
ConfigError
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-M7LLJQ7M.js";
|
|
5
|
+
import {
|
|
6
|
+
t
|
|
7
|
+
} from "./chunk-M23QBX3V.js";
|
|
5
8
|
|
|
6
9
|
// src/mcp/config.ts
|
|
7
10
|
import { createHash } from "crypto";
|
|
8
11
|
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
9
12
|
import { dirname, join, resolve } from "path";
|
|
13
|
+
var ENV_REF = /\$\{([A-Za-z_][A-Za-z0-9_]*)(?::-([^}]*))?\}/g;
|
|
14
|
+
function expandEnvVars(config, env) {
|
|
15
|
+
const expand = (value) => value.replace(ENV_REF, (match, name, fallback) => {
|
|
16
|
+
const resolved = env[name];
|
|
17
|
+
if (resolved !== void 0) return resolved;
|
|
18
|
+
return fallback !== void 0 ? fallback : match;
|
|
19
|
+
});
|
|
20
|
+
const expandMap = (map) => Object.fromEntries(Object.entries(map).map(([k, v]) => [k, expand(v)]));
|
|
21
|
+
if (config.type === "http") {
|
|
22
|
+
return { ...config, url: expand(config.url), ...config.headers ? { headers: expandMap(config.headers) } : {} };
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
...config,
|
|
26
|
+
command: expand(config.command),
|
|
27
|
+
...config.args ? { args: config.args.map(expand) } : {},
|
|
28
|
+
...config.env ? { env: expandMap(config.env) } : {}
|
|
29
|
+
};
|
|
30
|
+
}
|
|
10
31
|
var globalMcpPath = (home) => join(home, "mcp.json");
|
|
11
32
|
var projectMcpPath = (cwd) => join(cwd, ".bccli", "mcp.json");
|
|
12
33
|
var trustPath = (home) => join(home, "trusted-mcp.json");
|
|
@@ -15,7 +36,7 @@ function readJson(path, fallback) {
|
|
|
15
36
|
try {
|
|
16
37
|
return JSON.parse(readFileSync(path, "utf8"));
|
|
17
38
|
} catch (error) {
|
|
18
|
-
throw new ConfigError(
|
|
39
|
+
throw new ConfigError(t("Invalid MCP file: {path} ({error})", { path, error: error.message }));
|
|
19
40
|
}
|
|
20
41
|
}
|
|
21
42
|
function writePrivate(path, data) {
|
|
@@ -58,6 +79,7 @@ function serversToStart(home, cwd) {
|
|
|
58
79
|
}
|
|
59
80
|
|
|
60
81
|
export {
|
|
82
|
+
expandEnvVars,
|
|
61
83
|
globalMcpPath,
|
|
62
84
|
projectMcpPath,
|
|
63
85
|
readMcpFile,
|
|
@@ -35,8 +35,8 @@ function readSecret(prompt) {
|
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
async function runLogin(providerId, cwd) {
|
|
38
|
-
const { runProviderCommand } = await import("./providerCli-
|
|
39
|
-
const { parseCliArgs } = await import("./args-
|
|
38
|
+
const { runProviderCommand } = await import("./providerCli-DDH4ZZUY.js");
|
|
39
|
+
const { parseCliArgs } = await import("./args-4SMOHFN5.js");
|
|
40
40
|
return runProviderCommand(parseCliArgs(["provider", "add", providerId]), {
|
|
41
41
|
env: process.env,
|
|
42
42
|
cwd,
|
|
@@ -6,10 +6,36 @@ var MODE_ORDER = ["default", "acceptEdits", "plan", "allowAll"];
|
|
|
6
6
|
function nextMode(mode) {
|
|
7
7
|
return MODE_ORDER[(MODE_ORDER.indexOf(mode) + 1) % MODE_ORDER.length];
|
|
8
8
|
}
|
|
9
|
-
var
|
|
9
|
+
var ALWAYS_ASK_COMMANDS = /* @__PURE__ */ new Set(["sudo", "sh", "bash", "zsh", "su"]);
|
|
10
|
+
function isAlwaysAsk(segment) {
|
|
11
|
+
const words = segment.trim().split(/\s+/);
|
|
12
|
+
const first = words[0] ?? "";
|
|
13
|
+
if (ALWAYS_ASK_COMMANDS.has(first)) return true;
|
|
14
|
+
const flags = words.slice(1).filter((w) => w.startsWith("-"));
|
|
15
|
+
if (first === "rm" && flags.some((w) => w.includes("r"))) return true;
|
|
16
|
+
if (first === "chmod" && flags.some((w) => w.includes("R"))) return true;
|
|
17
|
+
if (first === "kill" && words.slice(1).includes("-9")) return true;
|
|
18
|
+
if (first === "git" && words[1] === "push") {
|
|
19
|
+
return words.slice(2).some((w) => w === "-f" || w === "--force" || w.startsWith("--force="));
|
|
20
|
+
}
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
10
23
|
function commandKey(segment) {
|
|
11
24
|
const words = segment.trim().split(/\s+/);
|
|
12
|
-
return
|
|
25
|
+
return words[1] ? `${words[0]} ${words[1]}` : words[0];
|
|
26
|
+
}
|
|
27
|
+
function requiresSensitiveToolApproval(req) {
|
|
28
|
+
const target = req.target.trim();
|
|
29
|
+
if (req.kind === "read" || req.kind === "edit") {
|
|
30
|
+
return /(?:^|[/\\])(?:\.env(?:\..*)?|\.ssh|\.aws|\.config\/gcloud|secrets?|credentials?)(?:[/\\]|$)/i.test(target) || /(?:id_rsa|id_ed25519|\.pem|\.p12|\.key)$/i.test(target);
|
|
31
|
+
}
|
|
32
|
+
if (req.kind === "bash") {
|
|
33
|
+
return /\b(?:rm\s+-[a-z]*r[a-z]*f[a-z]*\s|rm\s+-[a-z]*f[a-z]*r[a-z]*\s|mkfs(?:\.|\s)|wipefs\b|shred\s|git\s+push\s+(?:--force|-f)\b|docker\s+(?:system\s+prune|volume\s+rm)|kubectl\s+delete\b|drop\s+(?:database|table)|npm\s+publish\b)/i.test(target) || /\b(?:deploy-service\.sh|aws\s+secretsmanager|cat\s+[^;&|]*\.env\b)/i.test(target);
|
|
34
|
+
}
|
|
35
|
+
if (req.kind === "mcp") {
|
|
36
|
+
return /(?:delete|remove|revoke|transfer|send_email|publish|deploy|execute_command|run_command|read_secret)/i.test(req.tool);
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
13
39
|
}
|
|
14
40
|
var Permissions = class {
|
|
15
41
|
constructor(mode, rules = [], cwd = process.cwd()) {
|
|
@@ -30,6 +56,7 @@ var Permissions = class {
|
|
|
30
56
|
}
|
|
31
57
|
/** Rules that "[a] allow for this session" would add; undefined when it must always be asked. */
|
|
32
58
|
rulesFor(req) {
|
|
59
|
+
if (process.env.BC_TOOL_POLICY_ENFORCE === "true" && requiresSensitiveToolApproval(req)) return void 0;
|
|
33
60
|
if (req.kind === "edit") return this.editInProject(req.target) ? ["edit(project)"] : void 0;
|
|
34
61
|
if (req.kind === "fetch") {
|
|
35
62
|
try {
|
|
@@ -42,12 +69,15 @@ var Permissions = class {
|
|
|
42
69
|
if (/`|\$\(|[<>]|^\s*[({]/.test(req.target)) return void 0;
|
|
43
70
|
const segments = req.target.split(/&&|\|\||[;&|\n]/).map((s) => s.trim()).filter(Boolean);
|
|
44
71
|
if (!segments.length) return void 0;
|
|
72
|
+
if (segments.some(isAlwaysAsk)) return void 0;
|
|
45
73
|
return [...new Set(segments.map((s) => `bash(${commandKey(s)})`))];
|
|
46
74
|
}
|
|
47
75
|
if (req.kind === "mcp") return [`mcp(${req.tool})`];
|
|
48
76
|
return [];
|
|
49
77
|
}
|
|
50
78
|
check(req) {
|
|
79
|
+
if (this.mode === "plan" && req.kind !== "read") return "deny";
|
|
80
|
+
if (process.env.BC_TOOL_POLICY_ENFORCE === "true" && requiresSensitiveToolApproval(req)) return "ask";
|
|
51
81
|
if (req.kind === "read") return "allow";
|
|
52
82
|
if (this.mode === "allowAll") return "allow";
|
|
53
83
|
if (this.mode === "plan") return "deny";
|