@botconnector/bccli 0.4.17 → 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 (186) 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-HWHF25KU.js +0 -221
  18. package/dist/acp.d.ts +0 -44
  19. package/dist/agent.d.ts +0 -158
  20. package/dist/agents.d.ts +0 -4
  21. package/dist/args-XA77XUMD.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-2IP5F3EK.js +0 -56
  26. package/dist/chunk-5CVHTYBQ.js +0 -270
  27. package/dist/chunk-6LO6YRDY.js +0 -216
  28. package/dist/chunk-6PJRWKVI.js +0 -50
  29. package/dist/chunk-7OTFZK4B.js +0 -159
  30. package/dist/chunk-7U7CMKKI.js +0 -861
  31. package/dist/chunk-A3NBWIEQ.js +0 -2706
  32. package/dist/chunk-FY543EQW.js +0 -50
  33. package/dist/chunk-IDZLHEVL.js +0 -524
  34. package/dist/chunk-IF5RNXBI.js +0 -341
  35. package/dist/chunk-M5T4AM4I.js +0 -256
  36. package/dist/chunk-NGFWBVHD.js +0 -71
  37. package/dist/chunk-OCEQ2TRJ.js +0 -1075
  38. package/dist/chunk-OK2USAXX.js +0 -88
  39. package/dist/chunk-PSO7R5AD.js +0 -10
  40. package/dist/chunk-RLSQAZBT.js +0 -78
  41. package/dist/chunk-VPFCIUC6.js +0 -91
  42. package/dist/chunk-XP5MTJN2.js +0 -8
  43. package/dist/chunk-YGBTNDPK.js +0 -202
  44. package/dist/chunk-YYTFJUO2.js +0 -148
  45. package/dist/chunk-ZXWRLN7E.js +0 -378
  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-IRVEVW6H.js +0 -125
  51. package/dist/completion.d.ts +0 -14
  52. package/dist/config-OVWCUVY7.js +0 -25
  53. package/dist/config-S3CZUIBB.js +0 -34
  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-FYKJDJOD.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-GY73S2K7.js +0 -876
  70. package/dist/integrationCli.d.ts +0 -9
  71. package/dist/keybinds.d.ts +0 -22
  72. package/dist/login-KSN63EM4.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-VWSCCDWT.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-4Q6KFWV2.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-JWXQZTMZ.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-7XWDLJEL.js +0 -288
  94. package/dist/pluginsCli.d.ts +0 -16
  95. package/dist/prCli-FH7N26D4.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-YMG4G56R.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 -6532
  107. package/dist/serve-HSFF6MGB.js +0 -178
  108. package/dist/serve-HUQNVOSP.js +0 -532
  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-YM36TGU7.js +0 -12
  113. package/dist/session.d.ts +0 -33
  114. package/dist/setup-3YB6EKYX.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-I4TSDU3X.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-3B4LMOYI.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 -14
  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 -29
  171. package/dist/ui/markdownLayout.d.ts +0 -23
  172. package/dist/ui/replay.d.ts +0 -4
  173. package/dist/ui/stdinFilter.d.ts +0 -18
  174. package/dist/ui/table.d.ts +0 -20
  175. package/dist/ui/theme.d.ts +0 -5
  176. package/dist/ui/thinkingMouse.d.ts +0 -38
  177. package/dist/ui/transcript.d.ts +0 -55
  178. package/dist/ui/tty.d.ts +0 -11
  179. package/dist/ui/vim.d.ts +0 -26
  180. package/dist/ui-TAZMRXRI.js +0 -3044
  181. package/dist/update-5V425FIK.js +0 -145
  182. package/dist/update.d.ts +0 -30
  183. package/dist/verify.d.ts +0 -16
  184. package/dist/version.d.ts +0 -1
  185. package/dist/webBudget.d.ts +0 -25
  186. package/dist/worktree.d.ts +0 -12
@@ -1,178 +0,0 @@
1
- #!/usr/bin/env node
2
- import {
3
- createFetchTool,
4
- createWebSearchTool,
5
- isPrivateHost
6
- } from "./chunk-IF5RNXBI.js";
7
- import "./chunk-PSO7R5AD.js";
8
- import {
9
- loadConfig,
10
- readCredentials
11
- } from "./chunk-ZXWRLN7E.js";
12
- import {
13
- t
14
- } from "./chunk-IDZLHEVL.js";
15
-
16
- // src/mcpServer/serve.ts
17
- import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
18
-
19
- // src/mcpServer/server.ts
20
- import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
21
- import { z } from "zod";
22
- var CATALOG_URL = "https://botconnector.id/data/cloud-models.json";
23
- var PRICING_URL = "https://botconnector.id/data/payg-pricing.json";
24
- var CACHE_TTL_MS = 60 * 6e4;
25
- var ctxLabel = (context) => {
26
- if (!context || !Number.isFinite(context)) return "?";
27
- return context >= 1e3 ? `${Math.round(context / 1e3)}k` : String(context);
28
- };
29
- var usd = (v) => typeof v === "number" ? `$${v}` : "?";
30
- function createMcpServer(deps) {
31
- const server = new McpServer({ name: "botconnector", version: "0.1.0" });
32
- const fetchFn = deps.fetchFn ?? fetch;
33
- const now = deps.now ?? Date.now;
34
- let cache;
35
- const searchTool = createWebSearchTool({
36
- botconnector: () => deps.apiKey ? { baseURL: deps.baseUrl, apiKey: deps.apiKey } : void 0,
37
- keenableURL: deps.keenableURL
38
- });
39
- const pageTool = createFetchTool(deps.fetchTool);
40
- const toolCtx = () => ({
41
- cwd: ".",
42
- signal: AbortSignal.timeout(3e4),
43
- readFiles: /* @__PURE__ */ new Set()
44
- });
45
- server.registerTool(
46
- "bc_models",
47
- {
48
- description: "List BotConnector cloud models with context window and pay-as-you-go price (USD per 1M tokens).",
49
- inputSchema: {},
50
- annotations: { readOnlyHint: true }
51
- },
52
- async () => {
53
- if (cache && now() - cache.at < CACHE_TTL_MS) {
54
- return { content: [{ type: "text", text: cache.text }] };
55
- }
56
- const [catalogRes, pricingRes] = await Promise.all([fetchFn(CATALOG_URL), fetchFn(PRICING_URL)]);
57
- if (!catalogRes.ok) throw new Error(`catalog HTTP ${catalogRes.status}`);
58
- const catalog = await catalogRes.json();
59
- const pricing = pricingRes.ok ? await pricingRes.json() : { tokenRates: [] };
60
- const rates = new Map((pricing.tokenRates ?? []).map((r) => [r.id, r]));
61
- const lines = (catalog.models ?? []).map((m) => {
62
- const tier = rates.get(m.id)?.tiers?.[0];
63
- const price = tier ? `in ${usd(tier.inputPerMTokensUsd)}/M out ${usd(tier.outputPerMTokensUsd)}/M` : "price n/a";
64
- const access = m.access ? ` \xB7 ${m.access}` : "";
65
- return `${m.id} \xB7 ctx ${ctxLabel(m.context)} \xB7 ${price}${access}`;
66
- });
67
- const text = lines.length ? lines.join("\n") : "No models in the catalog.";
68
- cache = { at: now(), text };
69
- return { content: [{ type: "text", text }] };
70
- }
71
- );
72
- server.registerTool(
73
- "bc_search",
74
- {
75
- description: "Search the web and return ranked results (title, url, snippet). Use it to discover pages, then bc_fetch to read one.",
76
- inputSchema: {
77
- query: z.string().min(1).max(500).describe("Search query"),
78
- max_results: z.number().int().min(1).max(8).optional().describe("Number of results (default 6)")
79
- },
80
- annotations: { readOnlyHint: true }
81
- },
82
- async ({ query, max_results }) => {
83
- const r = await searchTool.run({ query, max_results }, toolCtx());
84
- return { content: [{ type: "text", text: r.output }], ...r.isError ? { isError: true } : {} };
85
- }
86
- );
87
- server.registerTool(
88
- "bc_fetch",
89
- {
90
- description: "Fetch a URL and return its text content (HTML tags stripped).",
91
- inputSchema: { url: z.string().min(1).describe("Absolute http(s) URL") },
92
- annotations: { readOnlyHint: true }
93
- },
94
- async ({ url }) => {
95
- if (!/^https?:\/\//i.test(url)) {
96
- return { content: [{ type: "text", text: "URL must start with http:// or https://" }], isError: true };
97
- }
98
- let host;
99
- try {
100
- host = new URL(url).hostname;
101
- } catch {
102
- return { content: [{ type: "text", text: "Invalid URL." }], isError: true };
103
- }
104
- if (isPrivateHost(host)) {
105
- return {
106
- content: [{ type: "text", text: `Blocked: ${host} is a private host. bc_fetch only fetches public URLs.` }],
107
- isError: true
108
- };
109
- }
110
- const r = await pageTool.run({ url }, toolCtx());
111
- return { content: [{ type: "text", text: r.output }], ...r.isError ? { isError: true } : {} };
112
- }
113
- );
114
- server.registerTool(
115
- "bc_chat",
116
- {
117
- description: "Send a prompt to a BotConnector model and get the reply. Returns the answer plus token usage. The model pays from the same API key.",
118
- inputSchema: {
119
- prompt: z.string().min(1).max(1e5).describe("The user message"),
120
- model: z.string().optional().describe("Model id (default: the configured model)"),
121
- max_tokens: z.number().int().min(1).max(4096).optional().describe("Reply budget (default 1024, max 4096)")
122
- },
123
- annotations: { readOnlyHint: false, destructiveHint: false }
124
- },
125
- async ({ prompt, model, max_tokens }) => {
126
- const res = await fetchFn(`${deps.baseUrl}/chat/completions`, {
127
- method: "POST",
128
- headers: { "content-type": "application/json", authorization: `Bearer ${deps.apiKey}` },
129
- body: JSON.stringify({
130
- model: model ?? deps.defaultModel,
131
- messages: [{ role: "user", content: prompt }],
132
- max_tokens: max_tokens ?? 1024,
133
- stream: false
134
- }),
135
- signal: AbortSignal.timeout(3e4)
136
- });
137
- const body = await res.json().catch(() => ({}));
138
- if (!res.ok) {
139
- const message = body.error?.message ?? `HTTP ${res.status}`;
140
- return { content: [{ type: "text", text: `bc_chat failed: ${message}` }], isError: true };
141
- }
142
- const reply = body.choices?.[0]?.message?.content ?? "";
143
- const usage = body.usage ? `
144
-
145
- [usage: ${body.usage.prompt_tokens ?? 0} in / ${body.usage.completion_tokens ?? 0} out]` : "";
146
- return { content: [{ type: "text", text: reply + usage }] };
147
- }
148
- );
149
- return server;
150
- }
151
-
152
- // src/mcpServer/serve.ts
153
- var DEFAULT_BASE = "https://api.botconnector.id/v1";
154
- var FALLBACK_MODEL = "glm-5.3-flash";
155
- async function runMcpServe(args, deps) {
156
- const apiKey = readCredentials(deps.env)["bc-cloud"] || deps.env.BOTCONNECTOR_API_KEY;
157
- if (!apiKey) {
158
- deps.err(t("No BotConnector API key yet. Run bccli login bc-cloud first."));
159
- return 1;
160
- }
161
- const config = loadConfig(deps.cwd, deps.env);
162
- const providerBase = config.providers["bc-cloud"]?.baseURL ?? DEFAULT_BASE;
163
- const baseUrl = (args.baseUrl ?? providerBase).replace(/\/+$/, "");
164
- const defaultModel = config.model.startsWith("bc-cloud/") ? config.model.slice("bc-cloud/".length) : FALLBACK_MODEL;
165
- const server = createMcpServer({ baseUrl, apiKey, defaultModel, fetchFn: deps.fetch });
166
- await server.connect(deps.transport ?? new StdioServerTransport());
167
- deps.err(`mcp serve: 4 tools, base=${baseUrl}`);
168
- if (deps.transport) return 0;
169
- await new Promise((resolve) => {
170
- const stdin = process.stdin;
171
- stdin.on("end", () => resolve());
172
- stdin.on("close", () => resolve());
173
- });
174
- return 0;
175
- }
176
- export {
177
- runMcpServe
178
- };