@botconnector/bccli 0.4.16 → 0.5.0-rc.4

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 (185) hide show
  1. package/LICENSE +203 -21
  2. package/THIRD_PARTY_NOTICES.md +9 -0
  3. package/branding.mjs +347 -0
  4. package/cli.mjs +120 -0
  5. package/core.mjs +260 -0
  6. package/credentials.mjs +52 -0
  7. package/gateway.mjs +2 -0
  8. package/model-command.mjs +61 -0
  9. package/package.json +35 -59
  10. package/provider-cli.mjs +77 -0
  11. package/providers.mjs +166 -0
  12. package/proxy.mjs +242 -0
  13. package/startup-menu.mjs +120 -0
  14. package/README.en.md +0 -253
  15. package/README.md +0 -250
  16. package/dist/abort.d.ts +0 -5
  17. package/dist/acp-JZW3XHE5.js +0 -221
  18. package/dist/acp.d.ts +0 -44
  19. package/dist/agent.d.ts +0 -147
  20. package/dist/agents.d.ts +0 -4
  21. package/dist/args-XVO7TB4C.js +0 -13
  22. package/dist/args.d.ts +0 -59
  23. package/dist/budget.d.ts +0 -26
  24. package/dist/checkpoints.d.ts +0 -35
  25. package/dist/chunk-3CYQYHPK.js +0 -202
  26. package/dist/chunk-6JK4IBGK.js +0 -1075
  27. package/dist/chunk-6SDRWEPN.js +0 -50
  28. package/dist/chunk-7GM6NN5E.js +0 -341
  29. package/dist/chunk-7XD47KN5.js +0 -71
  30. package/dist/chunk-INMSTUB2.js +0 -56
  31. package/dist/chunk-ISOKH5WB.js +0 -256
  32. package/dist/chunk-JUC3ZOCV.js +0 -50
  33. package/dist/chunk-KDVL2NP6.js +0 -861
  34. package/dist/chunk-KEKDRROL.js +0 -216
  35. package/dist/chunk-KJIXA6MP.js +0 -159
  36. package/dist/chunk-OK2USAXX.js +0 -88
  37. package/dist/chunk-PSO7R5AD.js +0 -10
  38. package/dist/chunk-Q42ZGVAQ.js +0 -91
  39. package/dist/chunk-R754XIBJ.js +0 -523
  40. package/dist/chunk-S3QEZDKB.js +0 -270
  41. package/dist/chunk-SWNRA3EW.js +0 -78
  42. package/dist/chunk-TLCL6DC7.js +0 -378
  43. package/dist/chunk-V5D6PJQN.js +0 -8
  44. package/dist/chunk-YYTFJUO2.js +0 -148
  45. package/dist/chunk-ZJRZTMJF.js +0 -2669
  46. package/dist/cli.d.ts +0 -1
  47. package/dist/cli.js +0 -233
  48. package/dist/clipboardImage.d.ts +0 -17
  49. package/dist/commands.d.ts +0 -16
  50. package/dist/completion-Q7VHOPPV.js +0 -125
  51. package/dist/completion.d.ts +0 -14
  52. package/dist/config-T7MKGJVG.js +0 -34
  53. package/dist/config-YYEAEN2C.js +0 -25
  54. package/dist/config.d.ts +0 -99
  55. package/dist/context.d.ts +0 -13
  56. package/dist/contextWindow.d.ts +0 -3
  57. package/dist/diff.d.ts +0 -7
  58. package/dist/exit.d.ts +0 -9
  59. package/dist/extensions.d.ts +0 -34
  60. package/dist/ghBotCli-7VUGI63S.js +0 -680
  61. package/dist/ghBotCli.d.ts +0 -9
  62. package/dist/ghBotDispatch.d.ts +0 -68
  63. package/dist/ghBotRunner.d.ts +0 -82
  64. package/dist/ghBotServe.d.ts +0 -21
  65. package/dist/ghBotWebhook.d.ts +0 -45
  66. package/dist/hooks.d.ts +0 -27
  67. package/dist/i18n/id.d.ts +0 -1
  68. package/dist/i18n.d.ts +0 -16
  69. package/dist/integrationCli-FBRSTF5F.js +0 -876
  70. package/dist/integrationCli.d.ts +0 -9
  71. package/dist/keybinds.d.ts +0 -22
  72. package/dist/login-BSMUGW7L.js +0 -18
  73. package/dist/login.d.ts +0 -21
  74. package/dist/lsp.d.ts +0 -73
  75. package/dist/mcp/catalog.d.ts +0 -14
  76. package/dist/mcp/config.d.ts +0 -36
  77. package/dist/mcp/manager.d.ts +0 -52
  78. package/dist/mcp/oauth.d.ts +0 -82
  79. package/dist/mcpCli-ZT7CRYMP.js +0 -113
  80. package/dist/mcpCli.d.ts +0 -3
  81. package/dist/mcpServer/serve.d.ts +0 -8
  82. package/dist/mcpServer/server.d.ts +0 -19
  83. package/dist/models.d.ts +0 -13
  84. package/dist/modelsCli-2ZRW4CC4.js +0 -36
  85. package/dist/modelsCli.d.ts +0 -15
  86. package/dist/npmRunner-LU43GM3W.js +0 -46
  87. package/dist/npmRunner.d.ts +0 -21
  88. package/dist/oauthLogin-THSM6FE7.js +0 -210
  89. package/dist/oauthLogin.d.ts +0 -47
  90. package/dist/permissions.d.ts +0 -30
  91. package/dist/pluginSpec.d.ts +0 -25
  92. package/dist/plugins.d.ts +0 -45
  93. package/dist/pluginsCli-EKQI4CJW.js +0 -288
  94. package/dist/pluginsCli.d.ts +0 -16
  95. package/dist/prCli-FMQTOBIV.js +0 -94
  96. package/dist/prCli.d.ts +0 -46
  97. package/dist/presets.d.ts +0 -8
  98. package/dist/print.d.ts +0 -17
  99. package/dist/provider.d.ts +0 -145
  100. package/dist/providerCli-3TFEKV4C.js +0 -15
  101. package/dist/providerCli.d.ts +0 -17
  102. package/dist/providers.d.ts +0 -6
  103. package/dist/reasoning.d.ts +0 -12
  104. package/dist/repomap.d.ts +0 -10
  105. package/dist/sdk.d.ts +0 -61
  106. package/dist/sdk.js +0 -6494
  107. package/dist/serve-3BODPEPR.js +0 -532
  108. package/dist/serve-V6YVZTNR.js +0 -178
  109. package/dist/serve.d.ts +0 -37
  110. package/dist/serveHeartbeat.d.ts +0 -14
  111. package/dist/serveProtocol.d.ts +0 -47
  112. package/dist/session-LX4UNPCD.js +0 -12
  113. package/dist/session.d.ts +0 -33
  114. package/dist/setup-MFG3BWEU.js +0 -24
  115. package/dist/setup.d.ts +0 -79
  116. package/dist/slash/copy.d.ts +0 -1
  117. package/dist/slash/diff.d.ts +0 -1
  118. package/dist/slash/doctor.d.ts +0 -18
  119. package/dist/slash/export.d.ts +0 -2
  120. package/dist/slash/info.d.ts +0 -46
  121. package/dist/slash/memory.d.ts +0 -10
  122. package/dist/statsCli-7MIQHLVW.js +0 -353
  123. package/dist/statsCli.d.ts +0 -62
  124. package/dist/textToolCalls.d.ts +0 -6
  125. package/dist/thinking.d.ts +0 -17
  126. package/dist/tokenBudget.d.ts +0 -22
  127. package/dist/tools/bash.d.ts +0 -54
  128. package/dist/tools/diagnostics.d.ts +0 -13
  129. package/dist/tools/edit.d.ts +0 -12
  130. package/dist/tools/fetch.d.ts +0 -41
  131. package/dist/tools/glob.d.ts +0 -5
  132. package/dist/tools/globSafety.d.ts +0 -7
  133. package/dist/tools/grep.d.ts +0 -25
  134. package/dist/tools/ignore.d.ts +0 -2
  135. package/dist/tools/index.d.ts +0 -12
  136. package/dist/tools/memory.d.ts +0 -13
  137. package/dist/tools/paths.d.ts +0 -4
  138. package/dist/tools/plan.d.ts +0 -10
  139. package/dist/tools/read.d.ts +0 -16
  140. package/dist/tools/repomap.d.ts +0 -2
  141. package/dist/tools/sandbox.d.ts +0 -15
  142. package/dist/tools/shell.d.ts +0 -18
  143. package/dist/tools/skill.d.ts +0 -3
  144. package/dist/tools/task.d.ts +0 -28
  145. package/dist/tools/todo.d.ts +0 -13
  146. package/dist/tools/types.d.ts +0 -52
  147. package/dist/tools/websearch.d.ts +0 -9
  148. package/dist/tools/write.d.ts +0 -5
  149. package/dist/transferCli-SRSYQLSJ.js +0 -73
  150. package/dist/transferCli.d.ts +0 -23
  151. package/dist/ui/App.d.ts +0 -7
  152. package/dist/ui/DiffView.d.ts +0 -3
  153. package/dist/ui/EditableText.d.ts +0 -7
  154. package/dist/ui/LinePrompt.d.ts +0 -6
  155. package/dist/ui/ListPicker.d.ts +0 -11
  156. package/dist/ui/Markdown.d.ts +0 -8
  157. package/dist/ui/McpMenu.d.ts +0 -11
  158. package/dist/ui/ModelPicker.d.ts +0 -6
  159. package/dist/ui/PermissionPrompt.d.ts +0 -5
  160. package/dist/ui/PlanApproval.d.ts +0 -5
  161. package/dist/ui/PromptInput.d.ts +0 -20
  162. package/dist/ui/ProviderMenu.d.ts +0 -10
  163. package/dist/ui/Spinner.d.ts +0 -4
  164. package/dist/ui/StatusBar.d.ts +0 -9
  165. package/dist/ui/TodoList.d.ts +0 -4
  166. package/dist/ui/ToolBlock.d.ts +0 -14
  167. package/dist/ui/complete.d.ts +0 -8
  168. package/dist/ui/index.d.ts +0 -7
  169. package/dist/ui/lineEdit.d.ts +0 -42
  170. package/dist/ui/liveCap.d.ts +0 -9
  171. package/dist/ui/replay.d.ts +0 -4
  172. package/dist/ui/stdinFilter.d.ts +0 -18
  173. package/dist/ui/table.d.ts +0 -20
  174. package/dist/ui/theme.d.ts +0 -5
  175. package/dist/ui/thinkingMouse.d.ts +0 -38
  176. package/dist/ui/transcript.d.ts +0 -55
  177. package/dist/ui/tty.d.ts +0 -11
  178. package/dist/ui/vim.d.ts +0 -26
  179. package/dist/ui-LZ4JGF2V.js +0 -2913
  180. package/dist/update-P7MU4ZM7.js +0 -145
  181. package/dist/update.d.ts +0 -30
  182. package/dist/verify.d.ts +0 -16
  183. package/dist/version.d.ts +0 -1
  184. package/dist/webBudget.d.ts +0 -25
  185. package/dist/worktree.d.ts +0 -12
@@ -1,202 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- quarantineCorruptFile,
4
- writeFileAtomic
5
- } from "./chunk-TLCL6DC7.js";
6
-
7
- // src/mcp/oauth.ts
8
- import { spawn } from "child_process";
9
- import { existsSync, mkdirSync, readFileSync } from "fs";
10
- import { createServer } from "http";
11
- import { dirname, join } from "path";
12
- import { auth } from "@modelcontextprotocol/sdk/client/auth.js";
13
- var oauthStorePath = (home) => join(home, "mcp-oauth.json");
14
- function readStore(home) {
15
- const path = oauthStorePath(home);
16
- if (!existsSync(path)) return {};
17
- try {
18
- return JSON.parse(readFileSync(path, "utf8"));
19
- } catch (error) {
20
- quarantineCorruptFile(path, error);
21
- return {};
22
- }
23
- }
24
- function writeStore(home, store) {
25
- const path = oauthStorePath(home);
26
- mkdirSync(dirname(path), { recursive: true });
27
- writeFileAtomic(path, `${JSON.stringify(store, null, 2)}
28
- `, 384);
29
- }
30
- function hasStoredTokens(home, serverUrl) {
31
- return Boolean(readStore(home)[serverUrl]?.tokens);
32
- }
33
- function clearTokens(home, serverUrl) {
34
- const store = readStore(home);
35
- const entry = store[serverUrl];
36
- if (!entry?.tokens && !entry?.client && !entry?.codeVerifier && !entry?.discovery) return false;
37
- delete store[serverUrl];
38
- writeStore(home, store);
39
- return true;
40
- }
41
- function openCommand(url, platform) {
42
- if (url.protocol !== "http:" && url.protocol !== "https:") return void 0;
43
- if (platform === "win32") return { command: "rundll32.exe", args: ["url.dll,FileProtocolHandler", url.href] };
44
- return { command: platform === "darwin" ? "open" : "xdg-open", args: [url.href] };
45
- }
46
- function defaultOpen(url, deps = {}) {
47
- const plan = openCommand(url, deps.platform ?? process.platform);
48
- if (!plan) return;
49
- const child = (deps.spawn ?? spawn)(plan.command, plan.args, { detached: true, stdio: "ignore" });
50
- child.unref();
51
- child.on("error", () => {
52
- });
53
- }
54
- var FileOAuthProvider = class {
55
- opts;
56
- constructor(opts) {
57
- this.opts = opts;
58
- }
59
- /**
60
- * Always defined: MCP SDK treats a missing redirectUrl as a non-interactive
61
- * (client_credentials) flow and would try a token exchange without a code.
62
- */
63
- get redirectUrl() {
64
- return this.opts.redirectUrl ?? "http://127.0.0.1:1/callback";
65
- }
66
- get clientMetadata() {
67
- return {
68
- client_name: "BCCLI",
69
- redirect_uris: [String(this.redirectUrl)],
70
- grant_types: ["authorization_code", "refresh_token"],
71
- response_types: ["code"],
72
- token_endpoint_auth_method: "none"
73
- };
74
- }
75
- entry() {
76
- return readStore(this.opts.home)[this.opts.serverUrl] ?? {};
77
- }
78
- patch(patch) {
79
- const store = readStore(this.opts.home);
80
- const next = { ...store[this.opts.serverUrl], ...patch };
81
- for (const key of Object.keys(next)) {
82
- if (next[key] === void 0) delete next[key];
83
- }
84
- store[this.opts.serverUrl] = next;
85
- if (Object.keys(next).length === 0) delete store[this.opts.serverUrl];
86
- writeStore(this.opts.home, store);
87
- }
88
- clientInformation() {
89
- return this.entry().client;
90
- }
91
- saveClientInformation(clientInformation) {
92
- this.patch({ client: clientInformation });
93
- }
94
- tokens() {
95
- return this.entry().tokens;
96
- }
97
- saveTokens(tokens) {
98
- this.patch({ tokens });
99
- }
100
- saveCodeVerifier(codeVerifier) {
101
- this.patch({ codeVerifier });
102
- }
103
- codeVerifier() {
104
- return this.entry().codeVerifier ?? "";
105
- }
106
- redirectToAuthorization(authorizationUrl) {
107
- return (this.opts.open ?? defaultOpen)(authorizationUrl);
108
- }
109
- saveDiscoveryState(state) {
110
- this.patch({ discovery: state });
111
- }
112
- discoveryState() {
113
- return this.entry().discovery;
114
- }
115
- invalidateCredentials(scope) {
116
- if (scope === "all") {
117
- this.patch({ client: void 0, tokens: void 0, codeVerifier: void 0, discovery: void 0 });
118
- return;
119
- }
120
- if (scope === "client") this.patch({ client: void 0 });
121
- if (scope === "tokens") this.patch({ tokens: void 0 });
122
- if (scope === "verifier") this.patch({ codeVerifier: void 0 });
123
- if (scope === "discovery") this.patch({ discovery: void 0 });
124
- }
125
- };
126
- function parseCallback(input) {
127
- const url = typeof input === "string" ? new URL(input) : input;
128
- const error = url.searchParams.get("error");
129
- if (error) {
130
- const description = url.searchParams.get("error_description");
131
- throw new Error(description ? `OAuth ${error}: ${description}` : `OAuth ${error}`);
132
- }
133
- const code = url.searchParams.get("code");
134
- if (!code) throw new Error("OAuth callback is missing the code parameter.");
135
- const state = url.searchParams.get("state") ?? void 0;
136
- return { code, state };
137
- }
138
- var CALLBACK_TIMEOUT_MS = 18e4;
139
- async function authorizeMcpServer(spec, deps) {
140
- let settle;
141
- const codeReceived = new Promise((resolve, reject) => {
142
- settle = { resolve, reject };
143
- });
144
- codeReceived.catch(() => {
145
- });
146
- const server = createServer((req, res) => {
147
- const url = new URL(req.url ?? "/", "http://127.0.0.1");
148
- if (url.pathname !== "/callback") {
149
- res.writeHead(404);
150
- res.end();
151
- return;
152
- }
153
- try {
154
- const { code } = parseCallback(url);
155
- res.writeHead(200, { "content-type": "text/html; charset=utf-8" });
156
- res.end("<html><body><p>BCCLI is connected. You can close this tab.</p></body></html>");
157
- settle.resolve(code);
158
- } catch (error) {
159
- const escaped = error.message.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
160
- res.writeHead(400, { "content-type": "text/html; charset=utf-8" });
161
- res.end(`<html><body><p>${escaped}</p></body></html>`);
162
- settle.reject(error);
163
- }
164
- });
165
- const port = await new Promise((resolve, reject) => {
166
- server.once("error", reject);
167
- server.listen(0, "127.0.0.1", () => {
168
- const address = server.address();
169
- resolve(typeof address === "object" && address ? address.port : 0);
170
- });
171
- });
172
- try {
173
- const provider = new FileOAuthProvider({
174
- home: deps.home,
175
- serverUrl: spec.config.url,
176
- redirectUrl: `http://127.0.0.1:${port}/callback`,
177
- open: deps.open
178
- });
179
- const serverUrl = new URL(spec.config.url);
180
- const result = await auth(provider, { serverUrl, fetchFn: deps.fetchFn });
181
- if (result === "AUTHORIZED") return;
182
- const timer = setTimeout(() => settle.reject(new Error("Timed out waiting for the OAuth callback.")), CALLBACK_TIMEOUT_MS);
183
- let code;
184
- try {
185
- code = await codeReceived;
186
- } finally {
187
- clearTimeout(timer);
188
- }
189
- const second = await auth(provider, { serverUrl, authorizationCode: code, fetchFn: deps.fetchFn });
190
- if (second !== "AUTHORIZED") throw new Error("OAuth authorization did not complete.");
191
- } finally {
192
- server.close();
193
- }
194
- }
195
-
196
- export {
197
- hasStoredTokens,
198
- clearTokens,
199
- defaultOpen,
200
- FileOAuthProvider,
201
- authorizeMcpServer
202
- };