@botconnector/bccli 0.4.0-beta.43 → 0.4.0-beta.45

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 (48) hide show
  1. package/dist/{acp-U25MNDND.js → acp-QUDKQCTK.js} +2 -2
  2. package/dist/{args-MFTMBNRN.js → args-HXDHQUL2.js} +4 -4
  3. package/dist/{chunk-25DSN3Y3.js → chunk-4BQAIMAM.js} +4 -4
  4. package/dist/{chunk-DUSVS3XK.js → chunk-7BQQYDPU.js} +1 -1
  5. package/dist/{chunk-RMDW3OQ6.js → chunk-ERXWNEVU.js} +2 -2
  6. package/dist/{chunk-VO6MF6JJ.js → chunk-F4XYLKG5.js} +1 -1
  7. package/dist/{chunk-ZGH4B7OU.js → chunk-FNCDUDOB.js} +21 -12
  8. package/dist/{chunk-GIGWZFCY.js → chunk-FNGFR7R6.js} +1 -1
  9. package/dist/{chunk-BQHKN7JI.js → chunk-IA35YV5K.js} +4 -1
  10. package/dist/{chunk-Y3QKYORR.js → chunk-IU7PB6US.js} +6 -6
  11. package/dist/{chunk-NVRNFR4S.js → chunk-JKRSZHDV.js} +1 -1
  12. package/dist/{chunk-QHNWI3OT.js → chunk-JZ5XPSIA.js} +4 -2
  13. package/dist/{chunk-PSRNKKGA.js → chunk-NJ5YDSSP.js} +1 -1
  14. package/dist/{chunk-I7GXIJCY.js → chunk-O33VFLLL.js} +2 -2
  15. package/dist/{chunk-PZC2Q6MJ.js → chunk-Q7DFEWE7.js} +2 -2
  16. package/dist/chunk-QZKLZELZ.js +64 -0
  17. package/dist/{chunk-ZKMSTD6G.js → chunk-RFSNTLOW.js} +1 -1
  18. package/dist/{chunk-TW5HZOTB.js → chunk-VQ4FJ7R2.js} +3 -3
  19. package/dist/{chunk-CYTRCZXI.js → chunk-W2ME7AGN.js} +26 -5
  20. package/dist/{chunk-2ON3WIDP.js → chunk-X5ZJGTWY.js} +4 -4
  21. package/dist/cli.js +60 -41
  22. package/dist/{completion-6K4AXKK2.js → completion-5OLAKCX7.js} +1 -1
  23. package/dist/{config-LCY27K3L.js → config-2PLBQKNC.js} +2 -2
  24. package/dist/{config-Z4HSA435.js → config-LSB274W4.js} +3 -3
  25. package/dist/{ghBotCli-TJMKJU3E.js → ghBotCli-MB7KATUU.js} +14 -14
  26. package/dist/{integrationCli-33KU6GIK.js → integrationCli-L7OLA3DG.js} +2 -2
  27. package/dist/{login-LNF7ZV2S.js → login-4CIXDZZ7.js} +3 -3
  28. package/dist/{mcpCli-TXFS3AOJ.js → mcpCli-SAJTQGI7.js} +5 -5
  29. package/dist/{modelsCli-IZSMIYVB.js → modelsCli-L6VODTVW.js} +6 -6
  30. package/dist/{oauthLogin-QGDYTOW7.js → oauthLogin-6TP475PO.js} +1 -1
  31. package/dist/{pluginsCli-RD4QW3DX.js → pluginsCli-LE2IDSST.js} +2 -2
  32. package/dist/{prCli-NR3ZQMST.js → prCli-PQJDEF7H.js} +3 -4
  33. package/dist/providerCli-SEAZ5OLH.js +15 -0
  34. package/dist/sdk.js +78 -4
  35. package/dist/{serve-YNKE332Z.js → serve-QAVMAYEU.js} +3 -3
  36. package/dist/{serve-F7BYQ7X6.js → serve-ZBCAEE72.js} +15 -15
  37. package/dist/session-3I64N64B.js +12 -0
  38. package/dist/setup-N3PMYREM.js +24 -0
  39. package/dist/statsCli-AJG3IJTX.js +353 -0
  40. package/dist/{transferCli-RQBB6RVY.js → transferCli-HNJMZYLV.js} +4 -4
  41. package/dist/{ui-4ZTUMTYM.js → ui-ORZ5ZNIC.js} +12 -12
  42. package/dist/{update-7SSREI2O.js → update-REYFMT5X.js} +2 -2
  43. package/package.json +1 -1
  44. package/dist/chunk-U6PCNS4B.js +0 -20
  45. package/dist/providerCli-AA3CHCGV.js +0 -15
  46. package/dist/session-KRV2UP5C.js +0 -12
  47. package/dist/setup-L4OPF3XW.js +0 -24
  48. package/dist/statsCli-RPCIMT5R.js +0 -109
package/dist/cli.js CHANGED
@@ -2,47 +2,63 @@
2
2
  import {
3
3
  resolveWorktree,
4
4
  runPrint
5
- } from "./chunk-TW5HZOTB.js";
5
+ } from "./chunk-VQ4FJ7R2.js";
6
6
  import {
7
7
  createRuntime
8
- } from "./chunk-ZGH4B7OU.js";
9
- import "./chunk-U6PCNS4B.js";
10
- import "./chunk-PSRNKKGA.js";
11
- import "./chunk-NVRNFR4S.js";
8
+ } from "./chunk-FNCDUDOB.js";
9
+ import "./chunk-QZKLZELZ.js";
10
+ import "./chunk-NJ5YDSSP.js";
11
+ import "./chunk-JKRSZHDV.js";
12
12
  import "./chunk-PSO7R5AD.js";
13
13
  import {
14
14
  VERSION
15
- } from "./chunk-DUSVS3XK.js";
15
+ } from "./chunk-7BQQYDPU.js";
16
16
  import {
17
17
  helpText,
18
18
  parseCliArgs
19
- } from "./chunk-CYTRCZXI.js";
19
+ } from "./chunk-W2ME7AGN.js";
20
20
  import "./chunk-GAFJEQTJ.js";
21
- import "./chunk-2ON3WIDP.js";
22
- import "./chunk-25DSN3Y3.js";
21
+ import "./chunk-X5ZJGTWY.js";
22
+ import "./chunk-4BQAIMAM.js";
23
23
  import {
24
24
  readGlobalConfigFile
25
- } from "./chunk-VO6MF6JJ.js";
25
+ } from "./chunk-F4XYLKG5.js";
26
26
  import {
27
27
  defaultLoginDeps,
28
28
  runLogin
29
- } from "./chunk-Y3QKYORR.js";
29
+ } from "./chunk-IU7PB6US.js";
30
30
  import "./chunk-7F3IWBPQ.js";
31
31
  import {
32
32
  pruneSessions
33
- } from "./chunk-BQHKN7JI.js";
34
- import "./chunk-RMDW3OQ6.js";
35
- import "./chunk-ZKMSTD6G.js";
36
- import "./chunk-PZC2Q6MJ.js";
33
+ } from "./chunk-IA35YV5K.js";
34
+ import "./chunk-ERXWNEVU.js";
35
+ import "./chunk-RFSNTLOW.js";
36
+ import "./chunk-Q7DFEWE7.js";
37
37
  import {
38
38
  ConfigError,
39
39
  setTheme
40
- } from "./chunk-GIGWZFCY.js";
40
+ } from "./chunk-FNGFR7R6.js";
41
41
  import {
42
42
  resolveLanguage,
43
43
  setLanguage,
44
44
  t
45
- } from "./chunk-QHNWI3OT.js";
45
+ } from "./chunk-JZ5XPSIA.js";
46
+
47
+ // src/exit.ts
48
+ var EXIT_GRACE_MS = 1e3;
49
+ function settleExit(code, deps) {
50
+ const d = {
51
+ setExitCode: (c) => {
52
+ process.exitCode = c;
53
+ },
54
+ exit: (c) => process.exit(c),
55
+ setTimer: (fn, ms) => setTimeout(fn, ms),
56
+ ...deps
57
+ };
58
+ d.setExitCode(code);
59
+ const force = d.setTimer(() => d.exit(code), EXIT_GRACE_MS);
60
+ force.unref();
61
+ }
46
62
 
47
63
  // src/cli.ts
48
64
  function chooseLanguage(argv) {
@@ -68,17 +84,17 @@ async function main() {
68
84
  if (args.worktree) cwd = (await resolveWorktree(cwd, args.worktree)).path;
69
85
  if (args.command === "login") return runLogin(args.loginProvider ?? "bc-cloud", cwd, args, defaultLoginDeps());
70
86
  if (args.command === "mcp") {
71
- const { runMcpCommand } = await import("./mcpCli-TXFS3AOJ.js");
72
- const { readSecret } = await import("./login-LNF7ZV2S.js");
87
+ const { runMcpCommand } = await import("./mcpCli-SAJTQGI7.js");
88
+ const { readSecret } = await import("./login-4CIXDZZ7.js");
73
89
  return runMcpCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
74
90
  }
75
91
  if (args.command === "provider") {
76
- const { runProviderCommand } = await import("./providerCli-AA3CHCGV.js");
77
- const { readSecret } = await import("./login-LNF7ZV2S.js");
92
+ const { runProviderCommand } = await import("./providerCli-SEAZ5OLH.js");
93
+ const { readSecret } = await import("./login-4CIXDZZ7.js");
78
94
  return runProviderCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), readSecret });
79
95
  }
80
96
  if (args.command === "connect" || args.command === "disconnect" || args.command === "integrations") {
81
- const { runIntegrationCommand } = await import("./integrationCli-33KU6GIK.js");
97
+ const { runIntegrationCommand } = await import("./integrationCli-L7OLA3DG.js");
82
98
  return runIntegrationCommand(args, {
83
99
  env: process.env,
84
100
  cwd,
@@ -88,20 +104,20 @@ async function main() {
88
104
  });
89
105
  }
90
106
  if (args.command === "models") {
91
- const { runModelsCommand } = await import("./modelsCli-IZSMIYVB.js");
107
+ const { runModelsCommand } = await import("./modelsCli-L6VODTVW.js");
92
108
  return runModelsCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s), fetch: globalThis.fetch });
93
109
  }
94
110
  if (args.command === "update") {
95
- const { runUpdateCommand } = await import("./update-7SSREI2O.js");
111
+ const { runUpdateCommand } = await import("./update-REYFMT5X.js");
96
112
  return runUpdateCommand({ env: process.env });
97
113
  }
98
114
  if (args.command === "acp") {
99
- const { runtimeAgent, runAcp } = await import("./acp-U25MNDND.js");
115
+ const { runtimeAgent, runAcp } = await import("./acp-QUDKQCTK.js");
100
116
  await runAcp(process.stdin, process.stdout, { cwd, newAgent: (c) => runtimeAgent(c) });
101
117
  return 0;
102
118
  }
103
119
  if (args.command === "serve") {
104
- const { startServe } = await import("./serve-F7BYQ7X6.js");
120
+ const { startServe } = await import("./serve-ZBCAEE72.js");
105
121
  const handle = await startServe({ port: args.port, host: args.host, token: args.token, cwd, env: process.env });
106
122
  process.stderr.write(`bccli serve ${handle.url} \u2014 Authorization: Bearer ${handle.token}
107
123
  `);
@@ -115,8 +131,8 @@ async function main() {
115
131
  return 0;
116
132
  }
117
133
  if (args.command === "plugins") {
118
- const { runPluginsCommand } = await import("./pluginsCli-RD4QW3DX.js");
119
- const { readGlobalPlugins, updateGlobalConfig } = await import("./config-LCY27K3L.js");
134
+ const { runPluginsCommand } = await import("./pluginsCli-LE2IDSST.js");
135
+ const { readGlobalPlugins, updateGlobalConfig } = await import("./config-2PLBQKNC.js");
120
136
  const { runNpmSync } = await import("./npmRunner-LU43GM3W.js");
121
137
  return runPluginsCommand(args, {
122
138
  out: (s) => console.log(s),
@@ -130,27 +146,30 @@ async function main() {
130
146
  });
131
147
  }
132
148
  if (args.command === "gh-bot") {
133
- const { runGhBotCommand } = await import("./ghBotCli-TJMKJU3E.js");
149
+ const { runGhBotCommand } = await import("./ghBotCli-MB7KATUU.js");
134
150
  return runGhBotCommand(args, { env: process.env, cwd, out: (s) => console.log(s), err: (s) => console.error(s) });
135
151
  }
136
152
  if (args.command === "completion") {
137
- const { runCompletionCommand } = await import("./completion-6K4AXKK2.js");
153
+ const { runCompletionCommand } = await import("./completion-5OLAKCX7.js");
138
154
  return runCompletionCommand(args, { out: (s) => console.log(s), err: (s) => console.error(s) });
139
155
  }
140
156
  if (args.command === "stats") {
141
- const { runStatsCommand } = await import("./statsCli-RPCIMT5R.js");
142
- const { bccliHome } = await import("./config-LCY27K3L.js");
143
- return runStatsCommand({ subArgs: args.subArgs, home: bccliHome(process.env) }, { out: (s) => console.log(s), err: (s) => console.error(s) });
157
+ const { runStatsCommand } = await import("./statsCli-AJG3IJTX.js");
158
+ const { bccliHome } = await import("./config-2PLBQKNC.js");
159
+ return runStatsCommand(
160
+ { subArgs: args.subArgs, home: bccliHome(process.env), cwd, days: args.days, tools: args.tools, models: args.models, project: args.project },
161
+ { out: (s) => console.log(s), err: (s) => console.error(s) }
162
+ );
144
163
  }
145
164
  if (args.command === "export" || args.command === "import") {
146
- const { runExportCommand, runImportCommand } = await import("./transferCli-RQBB6RVY.js");
147
- const { bccliHome } = await import("./config-LCY27K3L.js");
165
+ const { runExportCommand, runImportCommand } = await import("./transferCli-HNJMZYLV.js");
166
+ const { bccliHome } = await import("./config-2PLBQKNC.js");
148
167
  const deps = { subArgs: args.subArgs, home: bccliHome(process.env), cwd };
149
168
  const io = { out: (s) => console.log(s), err: (s) => console.error(s) };
150
169
  return args.command === "export" ? runExportCommand(deps, io) : runImportCommand(deps, io);
151
170
  }
152
171
  if (args.command === "pr") {
153
- const { runPrCommand } = await import("./prCli-NR3ZQMST.js");
172
+ const { runPrCommand } = await import("./prCli-PQJDEF7H.js");
154
173
  return runPrCommand({ subArgs: args.subArgs, cwd }, { out: (s) => console.log(s), err: (s) => console.error(s) });
155
174
  }
156
175
  const rt = createRuntime({ cwd, args });
@@ -161,7 +180,7 @@ async function main() {
161
180
  }
162
181
  if (args.print) {
163
182
  if (!args.prompt) throw new ConfigError(t('-p mode needs a task, e.g. bccli -p "explain this repo"'));
164
- const { serversToStart } = await import("./config-Z4HSA435.js");
183
+ const { serversToStart } = await import("./config-LSB274W4.js");
165
184
  const plan = serversToStart(rt.home, cwd);
166
185
  for (const s of plan.needTrust) {
167
186
  console.error(t('Project MCP server "{name}" skipped (not approved yet; run interactive bccli once to approve it).', { name: s.name }));
@@ -176,19 +195,19 @@ async function main() {
176
195
  if (!process.stdin.isTTY) throw new ConfigError(t('Interactive mode needs a terminal. For scripts/CI use: bccli -p "task"'));
177
196
  if (rt.config.updateCheck !== "off" && !process.env.BCCLI_NO_UPDATE_CHECK) {
178
197
  try {
179
- const { checkForUpdate } = await import("./update-7SSREI2O.js");
198
+ const { checkForUpdate } = await import("./update-REYFMT5X.js");
180
199
  const update = await checkForUpdate({ home: rt.home, fetch: globalThis.fetch, now: /* @__PURE__ */ new Date() });
181
200
  if (update) console.error(update);
182
201
  } catch {
183
202
  }
184
203
  }
185
- const { startInteractive } = await import("./ui-4ZTUMTYM.js");
204
+ const { startInteractive } = await import("./ui-ORZ5ZNIC.js");
186
205
  return startInteractive(rt, { initialPrompt: args.prompt, resume: args.resume, version: VERSION });
187
206
  }
188
207
  main().then(
189
- (code) => process.exit(code),
208
+ (code) => settleExit(code),
190
209
  (error) => {
191
210
  console.error(error instanceof ConfigError || error?.code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" ? error.message : error);
192
- process.exit(1);
211
+ settleExit(1);
193
212
  }
194
213
  );
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  t
4
- } from "./chunk-QHNWI3OT.js";
4
+ } from "./chunk-JZ5XPSIA.js";
5
5
 
6
6
  // src/completion.ts
7
7
  var SHELLS = ["bash", "zsh", "fish", "powershell"];
@@ -12,8 +12,8 @@ import {
12
12
  resolveModel,
13
13
  saveCredential,
14
14
  updateGlobalConfig
15
- } from "./chunk-GIGWZFCY.js";
16
- import "./chunk-QHNWI3OT.js";
15
+ } from "./chunk-FNGFR7R6.js";
16
+ import "./chunk-JZ5XPSIA.js";
17
17
  export {
18
18
  ConfigError,
19
19
  DEFAULT_MAX_STEPS,
@@ -9,9 +9,9 @@ import {
9
9
  removeGlobalServer,
10
10
  serversToStart,
11
11
  setProjectTrust
12
- } from "./chunk-PZC2Q6MJ.js";
13
- import "./chunk-GIGWZFCY.js";
14
- import "./chunk-QHNWI3OT.js";
12
+ } from "./chunk-Q7DFEWE7.js";
13
+ import "./chunk-FNGFR7R6.js";
14
+ import "./chunk-JZ5XPSIA.js";
15
15
  export {
16
16
  addGlobalServer,
17
17
  expandEnvVars,
@@ -1,32 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createRuntime
4
- } from "./chunk-ZGH4B7OU.js";
5
- import "./chunk-U6PCNS4B.js";
6
- import "./chunk-PSRNKKGA.js";
7
- import "./chunk-NVRNFR4S.js";
4
+ } from "./chunk-FNCDUDOB.js";
5
+ import "./chunk-QZKLZELZ.js";
6
+ import "./chunk-NJ5YDSSP.js";
7
+ import "./chunk-JKRSZHDV.js";
8
8
  import "./chunk-PSO7R5AD.js";
9
9
  import {
10
10
  LOOPBACK_BIND,
11
11
  parseCliArgs
12
- } from "./chunk-CYTRCZXI.js";
12
+ } from "./chunk-W2ME7AGN.js";
13
13
  import "./chunk-GAFJEQTJ.js";
14
- import "./chunk-2ON3WIDP.js";
15
- import "./chunk-25DSN3Y3.js";
16
- import "./chunk-VO6MF6JJ.js";
14
+ import "./chunk-X5ZJGTWY.js";
15
+ import "./chunk-4BQAIMAM.js";
16
+ import "./chunk-F4XYLKG5.js";
17
17
  import "./chunk-7F3IWBPQ.js";
18
- import "./chunk-BQHKN7JI.js";
19
- import "./chunk-RMDW3OQ6.js";
20
- import "./chunk-ZKMSTD6G.js";
21
- import "./chunk-PZC2Q6MJ.js";
18
+ import "./chunk-IA35YV5K.js";
19
+ import "./chunk-ERXWNEVU.js";
20
+ import "./chunk-RFSNTLOW.js";
21
+ import "./chunk-Q7DFEWE7.js";
22
22
  import {
23
23
  ConfigError,
24
24
  globalConfigPath,
25
25
  readJsonConfig
26
- } from "./chunk-GIGWZFCY.js";
26
+ } from "./chunk-FNGFR7R6.js";
27
27
  import {
28
28
  t
29
- } from "./chunk-QHNWI3OT.js";
29
+ } from "./chunk-JZ5XPSIA.js";
30
30
 
31
31
  // src/ghBotWebhook.ts
32
32
  import { createHmac, timingSafeEqual } from "crypto";
@@ -5,10 +5,10 @@ import {
5
5
  loadConfig,
6
6
  readCredentials,
7
7
  resolveModel
8
- } from "./chunk-GIGWZFCY.js";
8
+ } from "./chunk-FNGFR7R6.js";
9
9
  import {
10
10
  t
11
- } from "./chunk-QHNWI3OT.js";
11
+ } from "./chunk-JZ5XPSIA.js";
12
12
 
13
13
  // src/integrationCli.ts
14
14
  import { chmodSync, copyFileSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync } from "fs";
@@ -4,10 +4,10 @@ import {
4
4
  readLine,
5
5
  readSecret,
6
6
  runLogin
7
- } from "./chunk-Y3QKYORR.js";
7
+ } from "./chunk-IU7PB6US.js";
8
8
  import "./chunk-7F3IWBPQ.js";
9
- import "./chunk-GIGWZFCY.js";
10
- import "./chunk-QHNWI3OT.js";
9
+ import "./chunk-FNGFR7R6.js";
10
+ import "./chunk-JZ5XPSIA.js";
11
11
  export {
12
12
  defaultLoginDeps,
13
13
  readLine,
@@ -2,7 +2,7 @@
2
2
  import {
3
3
  CATALOG,
4
4
  fillTemplate
5
- } from "./chunk-I7GXIJCY.js";
5
+ } from "./chunk-O33VFLLL.js";
6
6
  import {
7
7
  authorizeMcpServer,
8
8
  clearTokens
@@ -12,20 +12,20 @@ import {
12
12
  globalMcpPath,
13
13
  readMcpFile,
14
14
  removeGlobalServer
15
- } from "./chunk-PZC2Q6MJ.js";
15
+ } from "./chunk-Q7DFEWE7.js";
16
16
  import {
17
17
  bccliHome
18
- } from "./chunk-GIGWZFCY.js";
18
+ } from "./chunk-FNGFR7R6.js";
19
19
  import {
20
20
  t
21
- } from "./chunk-QHNWI3OT.js";
21
+ } from "./chunk-JZ5XPSIA.js";
22
22
 
23
23
  // src/mcpCli.ts
24
24
  async function runMcpCommand(args, deps) {
25
25
  const home = bccliHome(deps.env);
26
26
  const [action = "list", name] = args.subArgs;
27
27
  if (action === "serve") {
28
- const { runMcpServe } = await import("./serve-YNKE332Z.js");
28
+ const { runMcpServe } = await import("./serve-QAVMAYEU.js");
29
29
  return runMcpServe(args, deps);
30
30
  }
31
31
  const installed = readMcpFile(globalMcpPath(home));
@@ -1,17 +1,17 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  listAllModels
4
- } from "./chunk-25DSN3Y3.js";
5
- import "./chunk-VO6MF6JJ.js";
6
- import "./chunk-RMDW3OQ6.js";
7
- import "./chunk-ZKMSTD6G.js";
4
+ } from "./chunk-4BQAIMAM.js";
5
+ import "./chunk-F4XYLKG5.js";
6
+ import "./chunk-ERXWNEVU.js";
7
+ import "./chunk-RFSNTLOW.js";
8
8
  import {
9
9
  loadConfig,
10
10
  resolveModel
11
- } from "./chunk-GIGWZFCY.js";
11
+ } from "./chunk-FNGFR7R6.js";
12
12
  import {
13
13
  t
14
- } from "./chunk-QHNWI3OT.js";
14
+ } from "./chunk-JZ5XPSIA.js";
15
15
 
16
16
  // src/modelsCli.ts
17
17
  async function runModelsCommand(args, deps) {
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  t
4
- } from "./chunk-QHNWI3OT.js";
4
+ } from "./chunk-JZ5XPSIA.js";
5
5
 
6
6
  // src/oauthLogin.ts
7
7
  import { createHash, randomBytes } from "crypto";
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  bccliHome,
4
4
  globalConfigPath
5
- } from "./chunk-GIGWZFCY.js";
5
+ } from "./chunk-FNGFR7R6.js";
6
6
  import {
7
7
  t
8
- } from "./chunk-QHNWI3OT.js";
8
+ } from "./chunk-JZ5XPSIA.js";
9
9
 
10
10
  // src/pluginsCli.ts
11
11
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  t
4
- } from "./chunk-QHNWI3OT.js";
4
+ } from "./chunk-JZ5XPSIA.js";
5
5
 
6
6
  // src/prCli.ts
7
7
  import { spawn } from "child_process";
@@ -21,9 +21,9 @@ function defaultGh(argv) {
21
21
  });
22
22
  }
23
23
  async function defaultRunTask(opts) {
24
- const argv = process.execPath ? [new URL("../cli.js", import.meta.url).pathname, ...opts.prompt ? ["-p", opts.prompt] : [], "--allow-all"] : [];
24
+ const entry = process.argv[1];
25
+ if (!entry) return 1;
25
26
  return new Promise((resolve) => {
26
- const entry = new URL("../cli.js", import.meta.url).pathname.replace(/^\/([A-Za-z]:)/, "$1");
27
27
  const child = spawn(process.execPath, [entry, ...opts.prompt ? ["-p", opts.prompt] : [], "--allow-all"], {
28
28
  shell: false,
29
29
  stdio: "inherit",
@@ -31,7 +31,6 @@ async function defaultRunTask(opts) {
31
31
  });
32
32
  child.on("error", () => resolve(1));
33
33
  child.on("close", (code) => resolve(code ?? 1));
34
- void argv;
35
34
  });
36
35
  }
37
36
  async function runPrCommand(args, deps) {
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ addProviderKey,
4
+ runProviderCommand
5
+ } from "./chunk-X5ZJGTWY.js";
6
+ import "./chunk-4BQAIMAM.js";
7
+ import "./chunk-F4XYLKG5.js";
8
+ import "./chunk-ERXWNEVU.js";
9
+ import "./chunk-RFSNTLOW.js";
10
+ import "./chunk-FNGFR7R6.js";
11
+ import "./chunk-JZ5XPSIA.js";
12
+ export {
13
+ addProviderKey,
14
+ runProviderCommand
15
+ };
package/dist/sdk.js CHANGED
@@ -155,7 +155,8 @@ Usage:
155
155
  bccli provider list|add <id>|remove <id> manage providers (custom: --url <url> [--name N] [--key-env ENV])
156
156
  bccli mcp list|add <name>|remove <name>|auth <name>|logout <name>|serve [--base-url <url>] manage MCP servers, or serve this account's tools over stdio
157
157
  bccli completion <shell> print a shell completion script (bash, zsh, fish, powershell)
158
- bccli stats [--days N] show token usage from local sessions (default: last 7 days)
158
+ bccli stats [--days N] [--tools N] [--models [N|all]] [--project slug]
159
+ show token usage from local sessions (default: last 7 days)
159
160
  bccli export [session] [file] copy a session JSONL to a file (default: last session here)
160
161
  bccli import <file> import a session JSONL into the current project
161
162
  bccli pr <number> [--repo owner/name] [task] check out a GitHub PR and run a task on it
@@ -483,11 +484,12 @@ Opsi:
483
484
  "Blocked: {host} resolves to a private address ({addr}). Fetching an internal host through a public DNS name is not allowed.": "Diblokir: {host} mengarah ke alamat privat ({addr}). Mengambil host internal lewat nama DNS publik tidak diizinkan.",
484
485
  "usage: bccli completion <{shells}>": "pakai: bccli completion <{shells}>",
485
486
  "--days must be a positive integer": "--days harus bilangan bulat positif",
487
+ "--tools must be a positive integer": "--tools harus bilangan bulat positif",
488
+ '--models must be a positive integer or "all"': '--models harus bilangan bulat positif atau "all"',
486
489
  "no sessions in the last {days} day(s)": "tidak ada sesi dalam {days} hari terakhir",
487
490
  "sessions (last {days} day(s)):": "sesi ({days} hari terakhir):",
488
491
  "session(s)": "sesi",
489
492
  "message(s)": "pesan",
490
- "recorded": "tercatat",
491
493
  "no session to export in this folder": "tidak ada sesi untuk diekspor di folder ini",
492
494
  "exported {file}": "diekspor ke {file}",
493
495
  "file not found: {file}": "file tidak ditemukan: {file}",
@@ -876,8 +878,11 @@ var LOOPBACK_BIND = /* @__PURE__ */ new Set(["127.0.0.1", "localhost", "::1"]);
876
878
 
877
879
  // src/args.ts
878
880
  function parseCliArgs(argv) {
881
+ const expanded = argv.map(
882
+ (a, i) => a === "--models" && (i + 1 >= argv.length || argv[i + 1].startsWith("-")) ? "--models=all" : a
883
+ );
879
884
  const { values, positionals } = parseArgs({
880
- args: argv,
885
+ args: expanded,
881
886
  allowPositionals: true,
882
887
  options: {
883
888
  print: { type: "boolean", short: "p" },
@@ -904,6 +909,9 @@ function parseCliArgs(argv) {
904
909
  token: { type: "string" },
905
910
  "base-url": { type: "string" },
906
911
  days: { type: "string" },
912
+ tools: { type: "string" },
913
+ models: { type: "string" },
914
+ project: { type: "string" },
907
915
  repo: { type: "string" }
908
916
  }
909
917
  });
@@ -932,6 +940,17 @@ function parseCliArgs(argv) {
932
940
  if (days !== void 0 && (!Number.isInteger(days) || days < 1)) {
933
941
  throw new ConfigError(t("--days must be a positive integer"));
934
942
  }
943
+ const tools = values.tools !== void 0 ? Number(values.tools) : void 0;
944
+ if (tools !== void 0 && (!Number.isInteger(tools) || tools < 1)) {
945
+ throw new ConfigError(t("--tools must be a positive integer"));
946
+ }
947
+ let models;
948
+ if (values.models !== void 0) {
949
+ models = values.models === "" || values.models === "all" ? "all" : values.models;
950
+ if (models !== "all" && (!Number.isInteger(Number(models)) || Number(models) < 1)) {
951
+ throw new ConfigError(t('--models must be a positive integer or "all"'));
952
+ }
953
+ }
935
954
  if (values.host !== void 0 && !LOOPBACK_BIND.has(values.host)) {
936
955
  throw new ConfigError(t("serve only accepts loopback --host (127.0.0.1, localhost, ::1)"));
937
956
  }
@@ -964,6 +983,9 @@ function parseCliArgs(argv) {
964
983
  token: values.token,
965
984
  baseUrl: values["base-url"],
966
985
  days,
986
+ tools,
987
+ models,
988
+ project: values.project,
967
989
  repo: values.repo
968
990
  };
969
991
  }
@@ -3231,6 +3253,48 @@ function trimToFit(messages, maxTokens) {
3231
3253
  }
3232
3254
  return out;
3233
3255
  }
3256
+ function splitKeepRecent(messages, keepTokens) {
3257
+ if (messages.length === 0) return [[], []];
3258
+ let start = messages.length;
3259
+ for (let i = messages.length - 1; i >= 0; i--) {
3260
+ if (i > 0 && messages[i].role !== "user") continue;
3261
+ if (estimateMessages(messages.slice(i)) <= keepTokens) start = i;
3262
+ else break;
3263
+ }
3264
+ if (start === messages.length) {
3265
+ for (let i = messages.length - 1; i >= 0; i--) {
3266
+ if (messages[i].role === "user") {
3267
+ start = i;
3268
+ break;
3269
+ }
3270
+ }
3271
+ }
3272
+ return [messages.slice(0, start), messages.slice(start)];
3273
+ }
3274
+ var TOOL_STUB = "[Old tool result content cleared]";
3275
+ var TOOL_PRUNE_KEEP_TOKENS = 4e4;
3276
+ var TOOL_PRUNE_MIN_TOKENS = 2e4;
3277
+ var isToolStub = (content) => content.startsWith(TOOL_STUB);
3278
+ function pruneOldToolOutputs(messages) {
3279
+ let kept = 0;
3280
+ let oldTokens = 0;
3281
+ const old = [];
3282
+ for (let i = messages.length - 1; i >= 0; i--) {
3283
+ const m = messages[i];
3284
+ if (m.role !== "tool" || isToolStub(m.content)) continue;
3285
+ kept += estimateTokens(m.content);
3286
+ if (kept > TOOL_PRUNE_KEEP_TOKENS) {
3287
+ old.push(i);
3288
+ oldTokens += estimateTokens(m.content);
3289
+ }
3290
+ }
3291
+ if (oldTokens <= TOOL_PRUNE_MIN_TOKENS) return false;
3292
+ for (const i of old) {
3293
+ const m = messages[i];
3294
+ messages[i] = { ...m, content: TOOL_STUB };
3295
+ }
3296
+ return true;
3297
+ }
3234
3298
 
3235
3299
  // src/agent.ts
3236
3300
  var CANCELLED = "Cancelled by the user.";
@@ -3310,7 +3374,10 @@ var Agent2 = class {
3310
3374
  this.opts.onReset?.();
3311
3375
  }
3312
3376
  async compact(signal) {
3313
- const history = trimToFit(this.messages, Math.floor(this.contextWindow * 0.8));
3377
+ pruneOldToolOutputs(this.messages);
3378
+ const keepTokens = Math.min(15e3, Math.floor(this.contextWindow * 0.1));
3379
+ const [older, keep] = splitKeepRecent(this.messages, keepTokens);
3380
+ const history = trimToFit(older, Math.floor(this.contextWindow * 0.8));
3314
3381
  const completion = await this.provider.chat({
3315
3382
  messages: [{ role: "system", content: this.systemPrompt }, ...history, { role: "user", content: COMPACT_PROMPT }],
3316
3383
  // Some gateways reject tool_calls in history when no tools are declared.
@@ -3322,6 +3389,7 @@ var Agent2 = class {
3322
3389
  this.push({ role: "user", content: `Summary of the previous conversation:
3323
3390
  ${completion.text}` });
3324
3391
  this.push({ role: "assistant", content: "OK, I will continue from this summary." });
3392
+ for (const m of keep) this.push(m);
3325
3393
  this.onEvent({ type: "compacted" });
3326
3394
  }
3327
3395
  /**
@@ -3384,6 +3452,7 @@ ${completion.text}` });
3384
3452
  this.totalUsage.cacheWriteTokens = (this.totalUsage.cacheWriteTokens ?? 0) + (usage.cacheWriteTokens ?? 0);
3385
3453
  this.lastInputTokens = usage.inputTokens;
3386
3454
  this.onEvent({ type: "usage", ...this.totalUsage });
3455
+ this.opts.onUsage?.(usage);
3387
3456
  this.push(completionAssistantMessage(completion));
3388
3457
  if (completion.finishReason === "repetition") {
3389
3458
  this.onEvent({ type: "textReplace", text: completion.text });
@@ -3531,6 +3600,7 @@ ${t("This model may not support tool calling. Try another model with /model.")}`
3531
3600
  this.totalUsage.cachedInputTokens = (this.totalUsage.cachedInputTokens ?? 0) + (u.cachedInputTokens ?? 0);
3532
3601
  this.totalUsage.cacheWriteTokens = (this.totalUsage.cacheWriteTokens ?? 0) + (u.cacheWriteTokens ?? 0);
3533
3602
  this.onEvent({ type: "usage", ...this.totalUsage });
3603
+ this.opts.onUsage?.(u);
3534
3604
  }
3535
3605
  };
3536
3606
  emit({ type: "toolStart", id: call.id, tool: tool.name, target });
@@ -4299,6 +4369,9 @@ var Session = class _Session {
4299
4369
  append(message) {
4300
4370
  this.write({ t: "msg", m: message });
4301
4371
  }
4372
+ appendUsage(usage) {
4373
+ this.write({ t: "usage", ...usage });
4374
+ }
4302
4375
  reset() {
4303
4376
  this.write({ t: "reset" });
4304
4377
  }
@@ -5066,6 +5139,7 @@ function createRuntime(opts) {
5066
5139
  budgetModel: modelRef,
5067
5140
  contextWindow: contextWindowFor(modelRef, env),
5068
5141
  onMessage: (m) => session.append(m),
5142
+ onUsage: (u) => session.appendUsage({ ...u, model: modelRef }),
5069
5143
  onReset: () => session.reset(),
5070
5144
  onTurnStart: () => {
5071
5145
  for (let i = turnMarks.length - 1; i >= 0 && turnMarks[i] > agent.messages.length; i--) {
@@ -3,15 +3,15 @@ import {
3
3
  createFetchTool,
4
4
  createWebSearchTool,
5
5
  isPrivateHost
6
- } from "./chunk-NVRNFR4S.js";
6
+ } from "./chunk-JKRSZHDV.js";
7
7
  import "./chunk-PSO7R5AD.js";
8
8
  import {
9
9
  loadConfig,
10
10
  readCredentials
11
- } from "./chunk-GIGWZFCY.js";
11
+ } from "./chunk-FNGFR7R6.js";
12
12
  import {
13
13
  t
14
- } from "./chunk-QHNWI3OT.js";
14
+ } from "./chunk-JZ5XPSIA.js";
15
15
 
16
16
  // src/mcpServer/serve.ts
17
17
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";