@botconnector/bccli 0.4.0-beta.9 → 0.4.1

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 (183) hide show
  1. package/README.en.md +253 -0
  2. package/README.md +93 -6
  3. package/dist/abort.d.ts +5 -0
  4. package/dist/acp-3PHBAI64.js +182 -0
  5. package/dist/acp.d.ts +27 -0
  6. package/dist/agent.d.ts +143 -0
  7. package/dist/agents.d.ts +4 -0
  8. package/dist/args-W6BNKY7K.js +13 -0
  9. package/dist/args.d.ts +51 -0
  10. package/dist/budget.d.ts +23 -0
  11. package/dist/checkpoints.d.ts +34 -0
  12. package/dist/{chunk-BFZXRKW5.js → chunk-24JN75FZ.js} +29 -7
  13. package/dist/chunk-45SDLMTV.js +341 -0
  14. package/dist/chunk-75BECX4F.js +56 -0
  15. package/dist/{chunk-SJH3YLW4.js → chunk-BC7UXFE4.js} +69 -6
  16. package/dist/chunk-BGXNR74O.js +733 -0
  17. package/dist/chunk-BKGFA2PT.js +8 -0
  18. package/dist/{chunk-CLN4Z5E3.js → chunk-BLOYFIAD.js} +6 -3
  19. package/dist/chunk-BXQQCUAC.js +145 -0
  20. package/dist/chunk-FLQPE4S5.js +373 -0
  21. package/dist/chunk-GN4W3T6E.js +76 -0
  22. package/dist/{chunk-7S6JXQCH.js → chunk-JHPGOAXU.js} +2 -1
  23. package/dist/chunk-MFHCQQEN.js +201 -0
  24. package/dist/chunk-MHIYLXJC.js +143 -0
  25. package/dist/chunk-PSO7R5AD.js +10 -0
  26. package/dist/chunk-PZRKU4UM.js +2143 -0
  27. package/dist/chunk-QZKLZELZ.js +64 -0
  28. package/dist/chunk-R5RE46CW.js +231 -0
  29. package/dist/chunk-UZWJQF67.js +500 -0
  30. package/dist/{chunk-DX7CZTBB.js → chunk-WI22M2ID.js} +14 -9
  31. package/dist/chunk-WNACAUDK.js +946 -0
  32. package/dist/chunk-XV7ZVL4J.js +235 -0
  33. package/dist/cli.d.ts +1 -0
  34. package/dist/cli.js +150 -1382
  35. package/dist/clipboardImage.d.ts +17 -0
  36. package/dist/commands.d.ts +16 -0
  37. package/dist/completion-HPPFDAPB.js +125 -0
  38. package/dist/completion.d.ts +14 -0
  39. package/dist/{config-YUNKPCNB.js → config-DIDLDONU.js} +5 -2
  40. package/dist/config-IU76CPK2.js +34 -0
  41. package/dist/config.d.ts +97 -0
  42. package/dist/context.d.ts +13 -0
  43. package/dist/contextWindow.d.ts +3 -0
  44. package/dist/diff.d.ts +7 -0
  45. package/dist/exit.d.ts +9 -0
  46. package/dist/extensions.d.ts +34 -0
  47. package/dist/ghBotCli-E3VPHNZY.js +677 -0
  48. package/dist/ghBotCli.d.ts +9 -0
  49. package/dist/ghBotDispatch.d.ts +68 -0
  50. package/dist/ghBotRunner.d.ts +82 -0
  51. package/dist/ghBotServe.d.ts +21 -0
  52. package/dist/ghBotWebhook.d.ts +45 -0
  53. package/dist/hooks.d.ts +27 -0
  54. package/dist/i18n/id.d.ts +1 -0
  55. package/dist/i18n.d.ts +16 -0
  56. package/dist/integrationCli-Q2YPDTPG.js +685 -0
  57. package/dist/integrationCli.d.ts +9 -0
  58. package/dist/keybinds.d.ts +22 -0
  59. package/dist/login-FP3BB44A.js +16 -0
  60. package/dist/login.d.ts +19 -0
  61. package/dist/lsp.d.ts +47 -0
  62. package/dist/mcp/catalog.d.ts +14 -0
  63. package/dist/mcp/config.d.ts +36 -0
  64. package/dist/mcp/manager.d.ts +34 -0
  65. package/dist/mcp/oauth.d.ts +82 -0
  66. package/dist/{mcpCli-DZWQPTOS.js → mcpCli-SNBDUWJN.js} +42 -9
  67. package/dist/mcpCli.d.ts +3 -0
  68. package/dist/mcpServer/serve.d.ts +8 -0
  69. package/dist/mcpServer/server.d.ts +19 -0
  70. package/dist/models.d.ts +13 -0
  71. package/dist/modelsCli-CZ2HNGKR.js +36 -0
  72. package/dist/modelsCli.d.ts +15 -0
  73. package/dist/npmRunner-LU43GM3W.js +46 -0
  74. package/dist/npmRunner.d.ts +21 -0
  75. package/dist/oauthLogin-6FWQABJ7.js +210 -0
  76. package/dist/oauthLogin.d.ts +47 -0
  77. package/dist/permissions.d.ts +30 -0
  78. package/dist/pluginSpec.d.ts +25 -0
  79. package/dist/plugins.d.ts +45 -0
  80. package/dist/pluginsCli-LPIUUDWB.js +284 -0
  81. package/dist/pluginsCli.d.ts +16 -0
  82. package/dist/prCli-5IMV3VNQ.js +78 -0
  83. package/dist/prCli.d.ts +33 -0
  84. package/dist/presets.d.ts +8 -0
  85. package/dist/print.d.ts +14 -0
  86. package/dist/provider.d.ts +140 -0
  87. package/dist/providerCli-NMUFXAAS.js +15 -0
  88. package/dist/providerCli.d.ts +17 -0
  89. package/dist/providers.d.ts +6 -0
  90. package/dist/reasoning.d.ts +12 -0
  91. package/dist/repomap.d.ts +10 -0
  92. package/dist/sdk.d.ts +57 -0
  93. package/dist/sdk.js +5571 -0
  94. package/dist/serve-KWOECK5W.js +178 -0
  95. package/dist/serve-X2ZV4S5U.js +521 -0
  96. package/dist/serve.d.ts +37 -0
  97. package/dist/serveHeartbeat.d.ts +14 -0
  98. package/dist/serveProtocol.d.ts +47 -0
  99. package/dist/session-GKEXDJKZ.js +12 -0
  100. package/dist/session.d.ts +30 -0
  101. package/dist/setup-OV3NWQN5.js +24 -0
  102. package/dist/setup.d.ts +74 -0
  103. package/dist/slash/copy.d.ts +1 -0
  104. package/dist/slash/diff.d.ts +1 -0
  105. package/dist/slash/doctor.d.ts +18 -0
  106. package/dist/slash/export.d.ts +2 -0
  107. package/dist/slash/info.d.ts +45 -0
  108. package/dist/slash/memory.d.ts +10 -0
  109. package/dist/statsCli-CF3R7ATL.js +353 -0
  110. package/dist/statsCli.d.ts +62 -0
  111. package/dist/textToolCalls.d.ts +6 -0
  112. package/dist/thinking.d.ts +17 -0
  113. package/dist/tokenBudget.d.ts +22 -0
  114. package/dist/tools/bash.d.ts +52 -0
  115. package/dist/tools/diagnostics.d.ts +5 -0
  116. package/dist/tools/edit.d.ts +7 -0
  117. package/dist/tools/fetch.d.ts +41 -0
  118. package/dist/tools/glob.d.ts +5 -0
  119. package/dist/tools/globSafety.d.ts +7 -0
  120. package/dist/tools/grep.d.ts +13 -0
  121. package/dist/tools/ignore.d.ts +2 -0
  122. package/dist/tools/index.d.ts +12 -0
  123. package/dist/tools/memory.d.ts +13 -0
  124. package/dist/tools/paths.d.ts +2 -0
  125. package/dist/tools/plan.d.ts +10 -0
  126. package/dist/tools/read.d.ts +16 -0
  127. package/dist/tools/repomap.d.ts +2 -0
  128. package/dist/tools/sandbox.d.ts +12 -0
  129. package/dist/tools/shell.d.ts +18 -0
  130. package/dist/tools/skill.d.ts +3 -0
  131. package/dist/tools/task.d.ts +28 -0
  132. package/dist/tools/todo.d.ts +13 -0
  133. package/dist/tools/types.d.ts +52 -0
  134. package/dist/tools/websearch.d.ts +9 -0
  135. package/dist/tools/write.d.ts +5 -0
  136. package/dist/transferCli-YUFPI6AH.js +71 -0
  137. package/dist/transferCli.d.ts +23 -0
  138. package/dist/ui/App.d.ts +7 -0
  139. package/dist/ui/DiffView.d.ts +3 -0
  140. package/dist/ui/EditableText.d.ts +7 -0
  141. package/dist/ui/LinePrompt.d.ts +6 -0
  142. package/dist/ui/ListPicker.d.ts +11 -0
  143. package/dist/ui/Markdown.d.ts +8 -0
  144. package/dist/ui/McpMenu.d.ts +11 -0
  145. package/dist/ui/ModelPicker.d.ts +6 -0
  146. package/dist/ui/PermissionPrompt.d.ts +5 -0
  147. package/dist/ui/PlanApproval.d.ts +5 -0
  148. package/dist/ui/PromptInput.d.ts +18 -0
  149. package/dist/ui/ProviderMenu.d.ts +10 -0
  150. package/dist/ui/Spinner.d.ts +4 -0
  151. package/dist/ui/StatusBar.d.ts +9 -0
  152. package/dist/ui/TodoList.d.ts +4 -0
  153. package/dist/ui/ToolBlock.d.ts +14 -0
  154. package/dist/ui/complete.d.ts +1 -0
  155. package/dist/ui/focusReport.d.ts +1 -0
  156. package/dist/ui/index.d.ts +7 -0
  157. package/dist/ui/lineEdit.d.ts +42 -0
  158. package/dist/ui/replay.d.ts +4 -0
  159. package/dist/ui/table.d.ts +20 -0
  160. package/dist/ui/theme.d.ts +5 -0
  161. package/dist/ui/thinkingMouse.d.ts +33 -0
  162. package/dist/ui/transcript.d.ts +55 -0
  163. package/dist/ui/vim.d.ts +26 -0
  164. package/dist/ui-IVIFNUCC.js +2367 -0
  165. package/dist/update-TZ2G6KQ3.js +145 -0
  166. package/dist/update.d.ts +30 -0
  167. package/dist/verify.d.ts +16 -0
  168. package/dist/version.d.ts +1 -0
  169. package/dist/webBudget.d.ts +25 -0
  170. package/dist/worktree.d.ts +12 -0
  171. package/package.json +42 -8
  172. package/dist/args-JPVSGCGY.js +0 -12
  173. package/dist/chunk-2MGINW4O.js +0 -114
  174. package/dist/chunk-ELML4KVQ.js +0 -76
  175. package/dist/chunk-ISGBGFSU.js +0 -52
  176. package/dist/chunk-KV27KTOX.js +0 -254
  177. package/dist/chunk-U7GK73CK.js +0 -341
  178. package/dist/chunk-ZYCYTEKD.js +0 -96
  179. package/dist/integrationCli-BGT5UZU4.js +0 -223
  180. package/dist/login-6K32PIXV.js +0 -9
  181. package/dist/providerCli-Q7LRM2NP.js +0 -12
  182. package/dist/session-7UB77CEG.js +0 -9
  183. package/dist/ui-6GTQUJOE.js +0 -1415
@@ -0,0 +1,56 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ hasKey,
4
+ providerName
5
+ } from "./chunk-JHPGOAXU.js";
6
+ import {
7
+ createProvider
8
+ } from "./chunk-WNACAUDK.js";
9
+ import {
10
+ PRESETS,
11
+ readCredentials
12
+ } from "./chunk-FLQPE4S5.js";
13
+ import {
14
+ t
15
+ } from "./chunk-UZWJQF67.js";
16
+
17
+ // src/models.ts
18
+ function order(ids) {
19
+ const presetIds = PRESETS.map((p) => p.id);
20
+ const presets = presetIds.filter((id) => ids.includes(id));
21
+ const custom = ids.filter((id) => !presetIds.includes(id)).sort();
22
+ return [...presets, ...custom];
23
+ }
24
+ async function listAllModels(config, env = process.env, opts = {}) {
25
+ const timeoutMs = opts.timeoutMs ?? 5e3;
26
+ const baseFetch = opts.fetch ?? fetch;
27
+ const untrusted = new Set(config.projectProviders ?? []);
28
+ const ids = order(Object.keys(config.providers)).filter((id) => opts.only ? id === opts.only : !untrusted.has(id) && hasKey(config, id, env));
29
+ const results = await Promise.all(
30
+ ids.map(async (id) => {
31
+ const provider = config.providers[id];
32
+ const apiKey = (opts.keyOverride && id === opts.only ? opts.keyOverride : void 0) || readCredentials(env)[id] || (provider.apiKeyEnv ? env[provider.apiKeyEnv] : void 0) || void 0;
33
+ const local = !provider.apiKeyEnv;
34
+ const timedFetch = ((input, init) => baseFetch(input, { ...init, signal: AbortSignal.timeout(timeoutMs) }));
35
+ const list = createProvider({ baseURL: provider.baseURL.replace(/\/+$/, ""), apiKey, model: "", fetch: timedFetch }).listModels();
36
+ let timer;
37
+ const timeout = new Promise((_, reject) => {
38
+ timer = setTimeout(() => reject(new Error("timeout")), timeoutMs);
39
+ });
40
+ try {
41
+ const models = await Promise.race([list, timeout]);
42
+ return { providerId: id, providerName: providerName(config, id), models };
43
+ } catch {
44
+ if (local && !opts.only) return void 0;
45
+ return { providerId: id, providerName: providerName(config, id), models: [], error: t("could not be reached") };
46
+ } finally {
47
+ clearTimeout(timer);
48
+ }
49
+ })
50
+ );
51
+ return results.filter((g) => !!g);
52
+ }
53
+
54
+ export {
55
+ listAllModels
56
+ };
@@ -1,4 +1,7 @@
1
1
  #!/usr/bin/env node
2
+ import {
3
+ contentText
4
+ } from "./chunk-WNACAUDK.js";
2
5
 
3
6
  // src/session.ts
4
7
  import { randomBytes } from "crypto";
@@ -36,7 +39,7 @@ var Session = class _Session {
36
39
  return readdirSync(dir).filter((f) => f.endsWith(".jsonl")).map((f) => {
37
40
  const session = new _Session(join(dir, f));
38
41
  const first = session.load().find((m) => m.role === "user");
39
- return { session, mtime: statSync(session.file).mtime, preview: first ? String(first.content).slice(0, 80) : "" };
42
+ return { session, mtime: statSync(session.file).mtime, preview: first ? contentText(first.content).slice(0, 80) : "" };
40
43
  }).sort((a, b) => b.mtime.getTime() - a.mtime.getTime() || b.session.file.localeCompare(a.session.file));
41
44
  }
42
45
  static latest(home, cwd) {
@@ -49,26 +52,86 @@ var Session = class _Session {
49
52
  append(message) {
50
53
  this.write({ t: "msg", m: message });
51
54
  }
55
+ appendUsage(usage) {
56
+ this.write({ t: "usage", ...usage });
57
+ }
52
58
  reset() {
53
59
  this.write({ t: "reset" });
54
60
  }
55
- load() {
61
+ records() {
56
62
  if (!existsSync(this.file)) return [];
57
- let messages = [];
63
+ const out = [];
58
64
  for (const line of readFileSync(this.file, "utf8").split("\n")) {
59
65
  if (!line.trim()) continue;
60
- let record;
61
66
  try {
62
- record = JSON.parse(line);
67
+ out.push(JSON.parse(line));
63
68
  } catch {
64
- continue;
65
69
  }
70
+ }
71
+ return out;
72
+ }
73
+ /** What the model continues from: everything after the last reset (after a compaction that is the summary and the recent turns). */
74
+ load() {
75
+ let messages = [];
76
+ for (const record of this.records()) {
66
77
  if (record.t === "reset") messages = [];
67
78
  else if (record.t === "msg") messages.push(record.m);
68
79
  }
69
80
  return repairTail(messages);
70
81
  }
82
+ /** Model of the most recent turn that recorded usage — serve attach continues a session with its own model. */
83
+ lastModel() {
84
+ const records = this.records();
85
+ for (let i = records.length - 1; i >= 0; i--) {
86
+ const record = records[i];
87
+ if (record.t === "usage" && record.model) return record.model;
88
+ }
89
+ return void 0;
90
+ }
91
+ /**
92
+ * What the user sees on resume: the whole conversation. Compaction only shrinks what the model is sent, so
93
+ * its reset does not hide the older turns here. A real reset (/clear, rewind) still starts over, the
94
+ * synthetic summary pair is never shown, and the recent turns a compaction re-writes are not shown twice.
95
+ */
96
+ loadHistory() {
97
+ const segments = [[]];
98
+ for (const record of this.records()) {
99
+ if (record.t === "reset") segments.push([]);
100
+ else if (record.t === "msg") segments[segments.length - 1].push(record.m);
101
+ }
102
+ let shown = segments[0];
103
+ for (const segment of segments.slice(1)) {
104
+ if (!isCompactionSummary(segment[0])) {
105
+ shown = segment;
106
+ continue;
107
+ }
108
+ const kept = segment.slice(2);
109
+ let at = 0;
110
+ while (at <= shown.length && !endsWithPrefixOf(shown, at, kept)) at++;
111
+ shown = [...shown, ...kept.slice(shown.length - at)];
112
+ }
113
+ return repairTail(shown.filter((m) => !isCompactionSummary(m) && !isCompactionAck(m)));
114
+ }
71
115
  };
116
+ var SUMMARY_PREFIX = "Summary of the previous conversation:";
117
+ var SUMMARY_ACK = "OK, I will continue from this summary.";
118
+ function isCompactionSummary(m) {
119
+ return m?.role === "user" && typeof m.content === "string" && m.content.startsWith(SUMMARY_PREFIX);
120
+ }
121
+ function isCompactionAck(m) {
122
+ return m.role === "assistant" && m.content === SUMMARY_ACK;
123
+ }
124
+ function sameMessage(a, b) {
125
+ if (a.role !== b.role) return false;
126
+ if (a.role === "tool" && b.role === "tool") return a.tool_call_id === b.tool_call_id;
127
+ return JSON.stringify(a.content) === JSON.stringify(b.content) && JSON.stringify("tool_calls" in a && a.tool_calls) === JSON.stringify("tool_calls" in b && b.tool_calls);
128
+ }
129
+ function endsWithPrefixOf(shown, at, kept) {
130
+ const n = shown.length - at;
131
+ if (n > kept.length) return false;
132
+ for (let j = 0; j < n; j++) if (!sameMessage(shown[at + j], kept[j])) return false;
133
+ return true;
134
+ }
72
135
  function pruneSessions(home, now = Date.now(), maxAgeDays = 30) {
73
136
  const root = join(home, "sessions");
74
137
  if (!existsSync(root)) return 0;