@botconnector/bccli 0.4.0-beta.8 → 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.
Files changed (59) hide show
  1. package/README.en.md +242 -0
  2. package/README.md +95 -3
  3. package/dist/acp-ATIL4JOZ.js +182 -0
  4. package/dist/args-J5ONVGIF.js +13 -0
  5. package/dist/chunk-45SDLMTV.js +341 -0
  6. package/dist/chunk-6M5X2KZE.js +8 -0
  7. package/dist/chunk-7F3IWBPQ.js +191 -0
  8. package/dist/{chunk-CLN4Z5E3.js → chunk-BLOYFIAD.js} +6 -3
  9. package/dist/chunk-BNA74HPN.js +145 -0
  10. package/dist/{chunk-DX7CZTBB.js → chunk-BQ2IGPBR.js} +14 -9
  11. package/dist/chunk-JL5ZCSP2.js +76 -0
  12. package/dist/chunk-KEMYIGCP.js +235 -0
  13. package/dist/{chunk-BFZXRKW5.js → chunk-L7QI6JN2.js} +24 -2
  14. package/dist/chunk-LACUWBWS.js +361 -0
  15. package/dist/chunk-M7CALSP3.js +733 -0
  16. package/dist/{chunk-ELML4KVQ.js → chunk-O7M3TGIW.js} +34 -2
  17. package/dist/chunk-PSO7R5AD.js +10 -0
  18. package/dist/chunk-PUN4HMAG.js +940 -0
  19. package/dist/{chunk-SJH3YLW4.js → chunk-QDQU6VY2.js} +60 -6
  20. package/dist/chunk-QZKLZELZ.js +64 -0
  21. package/dist/{chunk-7S6JXQCH.js → chunk-SPRNLS7K.js} +2 -1
  22. package/dist/chunk-TLPFQIS2.js +231 -0
  23. package/dist/chunk-TVALKHFB.js +2143 -0
  24. package/dist/chunk-UZWJQF67.js +500 -0
  25. package/dist/chunk-XBO5GACQ.js +56 -0
  26. package/dist/cli.js +162 -1383
  27. package/dist/completion-HPPFDAPB.js +125 -0
  28. package/dist/{config-YUNKPCNB.js → config-COPNMMV6.js} +5 -2
  29. package/dist/config-RZ5JONMX.js +30 -0
  30. package/dist/ghBotCli-IBCZIWT5.js +677 -0
  31. package/dist/integrationCli-P75R2VSC.js +685 -0
  32. package/dist/login-SYIQP46J.js +16 -0
  33. package/dist/{mcpCli-DZWQPTOS.js → mcpCli-QUV5SD64.js} +42 -9
  34. package/dist/modelsCli-TRRB5LX4.js +36 -0
  35. package/dist/npmRunner-LU43GM3W.js +46 -0
  36. package/dist/oauthLogin-6FWQABJ7.js +210 -0
  37. package/dist/pluginsCli-GNW4TPVV.js +284 -0
  38. package/dist/prCli-5IMV3VNQ.js +78 -0
  39. package/dist/providerCli-FAOZHOKW.js +15 -0
  40. package/dist/sdk.js +5490 -0
  41. package/dist/serve-6QLBJUYW.js +178 -0
  42. package/dist/serve-JG7RLIUD.js +515 -0
  43. package/dist/session-KBAQ4BZ5.js +12 -0
  44. package/dist/setup-FJAWDWV4.js +24 -0
  45. package/dist/statsCli-CF3R7ATL.js +353 -0
  46. package/dist/transferCli-TK2GSVRK.js +71 -0
  47. package/dist/ui-B3CJ6TGE.js +2365 -0
  48. package/dist/update-K5IQ2MYR.js +145 -0
  49. package/package.json +25 -4
  50. package/dist/args-FLTRM57K.js +0 -12
  51. package/dist/chunk-2MGINW4O.js +0 -114
  52. package/dist/chunk-IM3KMPVZ.js +0 -52
  53. package/dist/chunk-KV27KTOX.js +0 -254
  54. package/dist/chunk-U7GK73CK.js +0 -341
  55. package/dist/chunk-Z7PM3LTC.js +0 -93
  56. package/dist/login-JXFORO3J.js +0 -9
  57. package/dist/providerCli-Q7LRM2NP.js +0 -12
  58. package/dist/session-7UB77CEG.js +0 -9
  59. 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 TWO_WORD = /* @__PURE__ */ new Set(["npm", "npx", "pnpm", "yarn", "bun", "git", "cargo", "go", "docker", "python", "python3", "uv", "make"]);
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 TWO_WORD.has(words[0]) && words[1] ? `${words[0]} ${words[1]}` : words[0];
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";
@@ -0,0 +1,10 @@
1
+ #!/usr/bin/env node
2
+
3
+ // src/tools/types.ts
4
+ function defineTool(tool) {
5
+ return tool;
6
+ }
7
+
8
+ export {
9
+ defineTool
10
+ };