@botconnector/bccli 0.4.0-beta.9 → 0.4.0
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.en.md +242 -0
- package/README.md +80 -4
- package/dist/acp-ATIL4JOZ.js +182 -0
- package/dist/args-J5ONVGIF.js +13 -0
- package/dist/chunk-45SDLMTV.js +341 -0
- package/dist/chunk-6M5X2KZE.js +8 -0
- package/dist/chunk-7F3IWBPQ.js +191 -0
- package/dist/{chunk-CLN4Z5E3.js → chunk-BLOYFIAD.js} +6 -3
- package/dist/chunk-BNA74HPN.js +145 -0
- package/dist/{chunk-DX7CZTBB.js → chunk-BQ2IGPBR.js} +14 -9
- package/dist/chunk-JL5ZCSP2.js +76 -0
- package/dist/chunk-KEMYIGCP.js +235 -0
- package/dist/{chunk-BFZXRKW5.js → chunk-L7QI6JN2.js} +24 -2
- package/dist/chunk-LACUWBWS.js +361 -0
- package/dist/chunk-M7CALSP3.js +733 -0
- package/dist/{chunk-ELML4KVQ.js → chunk-O7M3TGIW.js} +34 -2
- package/dist/chunk-PSO7R5AD.js +10 -0
- package/dist/chunk-PUN4HMAG.js +940 -0
- package/dist/{chunk-SJH3YLW4.js → chunk-QDQU6VY2.js} +60 -6
- package/dist/chunk-QZKLZELZ.js +64 -0
- package/dist/{chunk-7S6JXQCH.js → chunk-SPRNLS7K.js} +2 -1
- package/dist/chunk-TLPFQIS2.js +231 -0
- package/dist/chunk-TVALKHFB.js +2143 -0
- package/dist/chunk-UZWJQF67.js +500 -0
- package/dist/chunk-XBO5GACQ.js +56 -0
- package/dist/cli.js +151 -1382
- package/dist/completion-HPPFDAPB.js +125 -0
- package/dist/{config-YUNKPCNB.js → config-COPNMMV6.js} +5 -2
- package/dist/config-RZ5JONMX.js +30 -0
- package/dist/ghBotCli-IBCZIWT5.js +677 -0
- package/dist/integrationCli-P75R2VSC.js +685 -0
- package/dist/login-SYIQP46J.js +16 -0
- package/dist/{mcpCli-DZWQPTOS.js → mcpCli-QUV5SD64.js} +42 -9
- package/dist/modelsCli-TRRB5LX4.js +36 -0
- package/dist/npmRunner-LU43GM3W.js +46 -0
- package/dist/oauthLogin-6FWQABJ7.js +210 -0
- package/dist/pluginsCli-GNW4TPVV.js +284 -0
- package/dist/prCli-5IMV3VNQ.js +78 -0
- package/dist/providerCli-FAOZHOKW.js +15 -0
- package/dist/sdk.js +5490 -0
- package/dist/serve-6QLBJUYW.js +178 -0
- package/dist/serve-JG7RLIUD.js +515 -0
- package/dist/session-KBAQ4BZ5.js +12 -0
- package/dist/setup-FJAWDWV4.js +24 -0
- package/dist/statsCli-CF3R7ATL.js +353 -0
- package/dist/transferCli-TK2GSVRK.js +71 -0
- package/dist/ui-B3CJ6TGE.js +2365 -0
- package/dist/update-K5IQ2MYR.js +145 -0
- package/package.json +25 -4
- package/dist/args-JPVSGCGY.js +0 -12
- package/dist/chunk-2MGINW4O.js +0 -114
- package/dist/chunk-ISGBGFSU.js +0 -52
- package/dist/chunk-KV27KTOX.js +0 -254
- package/dist/chunk-U7GK73CK.js +0 -341
- package/dist/chunk-ZYCYTEKD.js +0 -96
- package/dist/integrationCli-BGT5UZU4.js +0 -223
- package/dist/login-6K32PIXV.js +0 -9
- package/dist/providerCli-Q7LRM2NP.js +0 -12
- package/dist/session-7UB77CEG.js +0 -9
- package/dist/ui-6GTQUJOE.js +0 -1415
|
@@ -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,8 @@ 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 (requiresSensitiveToolApproval(req) && (req.kind === "read" || process.env.BC_TOOL_POLICY_ENFORCE === "true"))
|
|
60
|
+
return void 0;
|
|
33
61
|
if (req.kind === "edit") return this.editInProject(req.target) ? ["edit(project)"] : void 0;
|
|
34
62
|
if (req.kind === "fetch") {
|
|
35
63
|
try {
|
|
@@ -42,12 +70,16 @@ var Permissions = class {
|
|
|
42
70
|
if (/`|\$\(|[<>]|^\s*[({]/.test(req.target)) return void 0;
|
|
43
71
|
const segments = req.target.split(/&&|\|\||[;&|\n]/).map((s) => s.trim()).filter(Boolean);
|
|
44
72
|
if (!segments.length) return void 0;
|
|
73
|
+
if (segments.some(isAlwaysAsk)) return void 0;
|
|
45
74
|
return [...new Set(segments.map((s) => `bash(${commandKey(s)})`))];
|
|
46
75
|
}
|
|
47
76
|
if (req.kind === "mcp") return [`mcp(${req.tool})`];
|
|
48
77
|
return [];
|
|
49
78
|
}
|
|
50
79
|
check(req) {
|
|
80
|
+
if (this.mode === "plan" && req.kind !== "read") return "deny";
|
|
81
|
+
if (req.kind === "read" && this.mode !== "allowAll" && requiresSensitiveToolApproval(req)) return "ask";
|
|
82
|
+
if (process.env.BC_TOOL_POLICY_ENFORCE === "true" && requiresSensitiveToolApproval(req)) return "ask";
|
|
51
83
|
if (req.kind === "read") return "allow";
|
|
52
84
|
if (this.mode === "allowAll") return "allow";
|
|
53
85
|
if (this.mode === "plan") return "deny";
|