@botconnector/bccli 0.4.0 → 0.4.2

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 (173) hide show
  1. package/README.en.md +13 -2
  2. package/README.md +13 -2
  3. package/dist/abort.d.ts +5 -0
  4. package/dist/{acp-ATIL4JOZ.js → acp-UYC6APR5.js} +30 -6
  5. package/dist/acp.d.ts +28 -0
  6. package/dist/agent.d.ts +147 -0
  7. package/dist/agents.d.ts +4 -0
  8. package/dist/args-NRTZWWEV.js +13 -0
  9. package/dist/args.d.ts +53 -0
  10. package/dist/budget.d.ts +23 -0
  11. package/dist/checkpoints.d.ts +35 -0
  12. package/dist/{chunk-6M5X2KZE.js → chunk-266SY3MC.js} +1 -1
  13. package/dist/{chunk-7F3IWBPQ.js → chunk-3I5BW3ZT.js} +20 -9
  14. package/dist/{chunk-UZWJQF67.js → chunk-3WHI4LN3.js} +2 -1
  15. package/dist/{chunk-PUN4HMAG.js → chunk-5YJ3ZQVR.js} +73 -10
  16. package/dist/{chunk-L7QI6JN2.js → chunk-6M55UPES.js} +7 -7
  17. package/dist/{chunk-KEMYIGCP.js → chunk-6UO5GX55.js} +26 -12
  18. package/dist/{chunk-TLPFQIS2.js → chunk-C64KM37J.js} +36 -6
  19. package/dist/{chunk-JL5ZCSP2.js → chunk-H7XJDKJY.js} +4 -4
  20. package/dist/{chunk-SPRNLS7K.js → chunk-HQW4BROS.js} +4 -5
  21. package/dist/{chunk-XBO5GACQ.js → chunk-IYR5PYA3.js} +4 -4
  22. package/dist/{chunk-45SDLMTV.js → chunk-JXM6REER.js} +1 -1
  23. package/dist/{chunk-BLOYFIAD.js → chunk-KPTML72Q.js} +1 -1
  24. package/dist/{chunk-BQ2IGPBR.js → chunk-NQOGVP3I.js} +2 -2
  25. package/dist/{chunk-QZKLZELZ.js → chunk-OK2USAXX.js} +28 -4
  26. package/dist/{chunk-TVALKHFB.js → chunk-R72OV7RF.js} +421 -108
  27. package/dist/{chunk-LACUWBWS.js → chunk-RX4UQX43.js} +25 -10
  28. package/dist/{chunk-QDQU6VY2.js → chunk-SVD4LHJC.js} +73 -3
  29. package/dist/{chunk-BNA74HPN.js → chunk-TIMSYZIR.js} +7 -7
  30. package/dist/{chunk-O7M3TGIW.js → chunk-WFZKJY3R.js} +43 -4
  31. package/dist/{chunk-M7CALSP3.js → chunk-ZEPTUKNW.js} +120 -32
  32. package/dist/cli.d.ts +1 -0
  33. package/dist/cli.js +61 -45
  34. package/dist/clipboardImage.d.ts +17 -0
  35. package/dist/commands.d.ts +16 -0
  36. package/dist/{completion-HPPFDAPB.js → completion-D2BSBTQO.js} +1 -1
  37. package/dist/completion.d.ts +14 -0
  38. package/dist/{config-COPNMMV6.js → config-ENDRMOTP.js} +3 -3
  39. package/dist/{config-RZ5JONMX.js → config-LAINORU5.js} +8 -4
  40. package/dist/config.d.ts +99 -0
  41. package/dist/context.d.ts +13 -0
  42. package/dist/contextWindow.d.ts +3 -0
  43. package/dist/diff.d.ts +7 -0
  44. package/dist/exit.d.ts +9 -0
  45. package/dist/extensions.d.ts +34 -0
  46. package/dist/{ghBotCli-IBCZIWT5.js → ghBotCli-TSLRORJJ.js} +21 -20
  47. package/dist/ghBotCli.d.ts +9 -0
  48. package/dist/ghBotDispatch.d.ts +68 -0
  49. package/dist/ghBotRunner.d.ts +82 -0
  50. package/dist/ghBotServe.d.ts +21 -0
  51. package/dist/ghBotWebhook.d.ts +45 -0
  52. package/dist/hooks.d.ts +27 -0
  53. package/dist/i18n/id.d.ts +1 -0
  54. package/dist/i18n.d.ts +16 -0
  55. package/dist/{integrationCli-P75R2VSC.js → integrationCli-HXCSEWH2.js} +2 -2
  56. package/dist/integrationCli.d.ts +9 -0
  57. package/dist/keybinds.d.ts +22 -0
  58. package/dist/{login-SYIQP46J.js → login-RYESFZG6.js} +4 -4
  59. package/dist/login.d.ts +19 -0
  60. package/dist/lsp.d.ts +50 -0
  61. package/dist/mcp/catalog.d.ts +14 -0
  62. package/dist/mcp/config.d.ts +36 -0
  63. package/dist/mcp/manager.d.ts +52 -0
  64. package/dist/mcp/oauth.d.ts +82 -0
  65. package/dist/{mcpCli-QUV5SD64.js → mcpCli-SETTCL3K.js} +6 -6
  66. package/dist/mcpCli.d.ts +3 -0
  67. package/dist/mcpServer/serve.d.ts +8 -0
  68. package/dist/mcpServer/server.d.ts +19 -0
  69. package/dist/models.d.ts +13 -0
  70. package/dist/{modelsCli-TRRB5LX4.js → modelsCli-OP7CDZC7.js} +6 -6
  71. package/dist/modelsCli.d.ts +15 -0
  72. package/dist/npmRunner.d.ts +21 -0
  73. package/dist/{oauthLogin-6FWQABJ7.js → oauthLogin-XWY7OHCG.js} +1 -1
  74. package/dist/oauthLogin.d.ts +47 -0
  75. package/dist/permissions.d.ts +30 -0
  76. package/dist/pluginSpec.d.ts +25 -0
  77. package/dist/plugins.d.ts +45 -0
  78. package/dist/{pluginsCli-GNW4TPVV.js → pluginsCli-ZQNKWZHJ.js} +2 -2
  79. package/dist/pluginsCli.d.ts +16 -0
  80. package/dist/{prCli-5IMV3VNQ.js → prCli-6PUWTMTP.js} +20 -4
  81. package/dist/prCli.d.ts +46 -0
  82. package/dist/presets.d.ts +8 -0
  83. package/dist/print.d.ts +16 -0
  84. package/dist/provider.d.ts +145 -0
  85. package/dist/providerCli-5OZI2GQQ.js +15 -0
  86. package/dist/providerCli.d.ts +17 -0
  87. package/dist/providers.d.ts +6 -0
  88. package/dist/reasoning.d.ts +12 -0
  89. package/dist/repomap.d.ts +10 -0
  90. package/dist/sdk.d.ts +61 -0
  91. package/dist/sdk.js +829 -191
  92. package/dist/{serve-JG7RLIUD.js → serve-4J7HA4JO.js} +24 -18
  93. package/dist/{serve-6QLBJUYW.js → serve-K5AH4MGO.js} +3 -3
  94. package/dist/serve.d.ts +37 -0
  95. package/dist/serveHeartbeat.d.ts +14 -0
  96. package/dist/serveProtocol.d.ts +47 -0
  97. package/dist/session-YQXCCKXI.js +12 -0
  98. package/dist/session.d.ts +33 -0
  99. package/dist/setup-S4AJT6XE.js +24 -0
  100. package/dist/setup.d.ts +74 -0
  101. package/dist/slash/copy.d.ts +1 -0
  102. package/dist/slash/diff.d.ts +1 -0
  103. package/dist/slash/doctor.d.ts +18 -0
  104. package/dist/slash/export.d.ts +2 -0
  105. package/dist/slash/info.d.ts +46 -0
  106. package/dist/slash/memory.d.ts +10 -0
  107. package/dist/{statsCli-CF3R7ATL.js → statsCli-XR6BEZQQ.js} +2 -2
  108. package/dist/statsCli.d.ts +62 -0
  109. package/dist/textToolCalls.d.ts +6 -0
  110. package/dist/thinking.d.ts +17 -0
  111. package/dist/tokenBudget.d.ts +22 -0
  112. package/dist/tools/bash.d.ts +52 -0
  113. package/dist/tools/diagnostics.d.ts +5 -0
  114. package/dist/tools/edit.d.ts +12 -0
  115. package/dist/tools/fetch.d.ts +41 -0
  116. package/dist/tools/glob.d.ts +5 -0
  117. package/dist/tools/globSafety.d.ts +7 -0
  118. package/dist/tools/grep.d.ts +25 -0
  119. package/dist/tools/ignore.d.ts +2 -0
  120. package/dist/tools/index.d.ts +12 -0
  121. package/dist/tools/memory.d.ts +13 -0
  122. package/dist/tools/paths.d.ts +4 -0
  123. package/dist/tools/plan.d.ts +10 -0
  124. package/dist/tools/read.d.ts +16 -0
  125. package/dist/tools/repomap.d.ts +2 -0
  126. package/dist/tools/sandbox.d.ts +12 -0
  127. package/dist/tools/shell.d.ts +18 -0
  128. package/dist/tools/skill.d.ts +3 -0
  129. package/dist/tools/task.d.ts +28 -0
  130. package/dist/tools/todo.d.ts +13 -0
  131. package/dist/tools/types.d.ts +52 -0
  132. package/dist/tools/websearch.d.ts +9 -0
  133. package/dist/tools/write.d.ts +5 -0
  134. package/dist/{transferCli-TK2GSVRK.js → transferCli-R2KEIWQR.js} +8 -6
  135. package/dist/transferCli.d.ts +23 -0
  136. package/dist/ui/App.d.ts +7 -0
  137. package/dist/ui/DiffView.d.ts +3 -0
  138. package/dist/ui/EditableText.d.ts +7 -0
  139. package/dist/ui/LinePrompt.d.ts +6 -0
  140. package/dist/ui/ListPicker.d.ts +11 -0
  141. package/dist/ui/Markdown.d.ts +8 -0
  142. package/dist/ui/McpMenu.d.ts +11 -0
  143. package/dist/ui/ModelPicker.d.ts +6 -0
  144. package/dist/ui/PermissionPrompt.d.ts +5 -0
  145. package/dist/ui/PlanApproval.d.ts +5 -0
  146. package/dist/ui/PromptInput.d.ts +18 -0
  147. package/dist/ui/ProviderMenu.d.ts +10 -0
  148. package/dist/ui/Spinner.d.ts +4 -0
  149. package/dist/ui/StatusBar.d.ts +9 -0
  150. package/dist/ui/TodoList.d.ts +4 -0
  151. package/dist/ui/ToolBlock.d.ts +14 -0
  152. package/dist/ui/complete.d.ts +6 -0
  153. package/dist/ui/focusReport.d.ts +1 -0
  154. package/dist/ui/index.d.ts +7 -0
  155. package/dist/ui/lineEdit.d.ts +42 -0
  156. package/dist/ui/replay.d.ts +4 -0
  157. package/dist/ui/table.d.ts +20 -0
  158. package/dist/ui/theme.d.ts +5 -0
  159. package/dist/ui/thinkingMouse.d.ts +33 -0
  160. package/dist/ui/transcript.d.ts +55 -0
  161. package/dist/ui/vim.d.ts +26 -0
  162. package/dist/{ui-B3CJ6TGE.js → ui-36ZEK65V.js} +179 -54
  163. package/dist/{update-K5IQ2MYR.js → update-FSS7X5WV.js} +2 -2
  164. package/dist/update.d.ts +30 -0
  165. package/dist/verify.d.ts +16 -0
  166. package/dist/version.d.ts +1 -0
  167. package/dist/webBudget.d.ts +25 -0
  168. package/dist/worktree.d.ts +12 -0
  169. package/package.json +26 -13
  170. package/dist/args-J5ONVGIF.js +0 -13
  171. package/dist/providerCli-FAOZHOKW.js +0 -15
  172. package/dist/session-KBAQ4BZ5.js +0 -12
  173. package/dist/setup-FJAWDWV4.js +0 -24
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  createRuntime
4
- } from "./chunk-TVALKHFB.js";
5
- import "./chunk-QZKLZELZ.js";
6
- import "./chunk-M7CALSP3.js";
7
- import "./chunk-45SDLMTV.js";
4
+ } from "./chunk-R72OV7RF.js";
5
+ import "./chunk-OK2USAXX.js";
6
+ import "./chunk-ZEPTUKNW.js";
7
+ import "./chunk-JXM6REER.js";
8
8
  import "./chunk-PSO7R5AD.js";
9
9
  import {
10
10
  VERSION
11
- } from "./chunk-6M5X2KZE.js";
11
+ } from "./chunk-266SY3MC.js";
12
12
  import {
13
13
  LOOPBACK_BIND,
14
14
  MAX_FRAME_BYTES,
@@ -17,25 +17,25 @@ import {
17
17
  parseClientFrame,
18
18
  randomToken,
19
19
  trustFence
20
- } from "./chunk-KEMYIGCP.js";
21
- import "./chunk-O7M3TGIW.js";
22
- import "./chunk-JL5ZCSP2.js";
20
+ } from "./chunk-6UO5GX55.js";
21
+ import "./chunk-WFZKJY3R.js";
22
+ import "./chunk-H7XJDKJY.js";
23
23
  import {
24
24
  listAllModels
25
- } from "./chunk-XBO5GACQ.js";
26
- import "./chunk-SPRNLS7K.js";
27
- import "./chunk-7F3IWBPQ.js";
25
+ } from "./chunk-IYR5PYA3.js";
26
+ import "./chunk-HQW4BROS.js";
27
+ import "./chunk-3I5BW3ZT.js";
28
28
  import {
29
29
  Session
30
- } from "./chunk-QDQU6VY2.js";
31
- import "./chunk-PUN4HMAG.js";
32
- import "./chunk-BLOYFIAD.js";
33
- import "./chunk-L7QI6JN2.js";
30
+ } from "./chunk-SVD4LHJC.js";
31
+ import "./chunk-5YJ3ZQVR.js";
32
+ import "./chunk-KPTML72Q.js";
33
+ import "./chunk-6M55UPES.js";
34
34
  import {
35
35
  bccliHome,
36
36
  loadConfig
37
- } from "./chunk-LACUWBWS.js";
38
- import "./chunk-UZWJQF67.js";
37
+ } from "./chunk-RX4UQX43.js";
38
+ import "./chunk-3WHI4LN3.js";
39
39
 
40
40
  // src/serve.ts
41
41
  import { randomBytes } from "crypto";
@@ -101,6 +101,11 @@ function readBody(req) {
101
101
  function sendFrame(ws, frame) {
102
102
  if (ws.readyState === WebSocket.OPEN) ws.send(JSON.stringify(frame));
103
103
  }
104
+ function serveBanner(handle, opts = {}) {
105
+ const supplied = opts.token !== void 0 || (opts.env ?? process.env).BCCLI_SERVE_TOKEN !== void 0;
106
+ return `bccli serve ${handle.url}${supplied ? "" : ` \u2014 Authorization: Bearer ${handle.token}`}
107
+ `;
108
+ }
104
109
  async function startServe(opts = {}) {
105
110
  const env = opts.env ?? process.env;
106
111
  const cwd = opts.cwd ?? process.cwd();
@@ -454,7 +459,7 @@ Connection: close\r
454
459
  function attachSession(id, forCwd) {
455
460
  const found = findSessionFile(id, forCwd);
456
461
  if (!found) return void 0;
457
- const rt = buildRuntime(found.cwd, "ask");
462
+ const rt = buildRuntime(found.cwd, "ask", found.session.lastModel());
458
463
  rt.resume(found.session);
459
464
  return registerSession(rt, found.cwd, "ask", id);
460
465
  }
@@ -511,5 +516,6 @@ Connection: close\r
511
516
  };
512
517
  }
513
518
  export {
519
+ serveBanner,
514
520
  startServe
515
521
  };
@@ -3,15 +3,15 @@ import {
3
3
  createFetchTool,
4
4
  createWebSearchTool,
5
5
  isPrivateHost
6
- } from "./chunk-45SDLMTV.js";
6
+ } from "./chunk-JXM6REER.js";
7
7
  import "./chunk-PSO7R5AD.js";
8
8
  import {
9
9
  loadConfig,
10
10
  readCredentials
11
- } from "./chunk-LACUWBWS.js";
11
+ } from "./chunk-RX4UQX43.js";
12
12
  import {
13
13
  t
14
- } from "./chunk-UZWJQF67.js";
14
+ } from "./chunk-3WHI4LN3.js";
15
15
 
16
16
  // src/mcpServer/serve.ts
17
17
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
@@ -0,0 +1,37 @@
1
+ import type { Provider } from './provider';
2
+ export interface ServeOptions {
3
+ port?: number;
4
+ host?: string;
5
+ token?: string;
6
+ cwd?: string;
7
+ env?: NodeJS.ProcessEnv;
8
+ provider?: Provider;
9
+ fetch?: typeof fetch;
10
+ heartbeatMs?: number;
11
+ err?: (s: string) => void;
12
+ }
13
+ export interface ServeHandle {
14
+ port: number;
15
+ token: string;
16
+ url: string;
17
+ close(): Promise<void>;
18
+ }
19
+ export type PermissionMode = 'ask' | 'bypassPermissions';
20
+ /**
21
+ * One-line terminal banner for `bccli serve`. A token the user supplied (`--token` or
22
+ * `BCCLI_SERVE_TOKEN`) is left out so it cannot leak into logs; a token BCCLI generated
23
+ * itself must be printed or nobody could connect.
24
+ */
25
+ export declare function serveBanner(handle: {
26
+ url: string;
27
+ token: string;
28
+ }, opts?: {
29
+ token?: string;
30
+ env?: NodeJS.ProcessEnv;
31
+ }): string;
32
+ /**
33
+ * Starts the loopback session server (HTTP unary + WS mux at /v1/mux). Refuses
34
+ * non-loopback bind addresses; every request passes the DSH-style trust fence
35
+ * (403) and, except /health, the bearer-token check (401).
36
+ */
37
+ export declare function startServe(opts?: ServeOptions): Promise<ServeHandle>;
@@ -0,0 +1,14 @@
1
+ export interface Heartbeat {
2
+ /** Sends the first ping and schedules the check loop. Idempotent until stop(). */
3
+ start(): void;
4
+ /** Marks the last ping as answered (ws 'pong' event). */
5
+ pong(): void;
6
+ /** Clears the timer; no further pings or terminations. */
7
+ stop(): void;
8
+ }
9
+ /**
10
+ * ws heartbeat with deadline: every interval a ping goes out; a ping left
11
+ * unanswered by the next tick terminates the socket (connection, not stream).
12
+ * Modeled on the DSH gateway's `websocketHeartbeatIntervalMs` behavior.
13
+ */
14
+ export declare function createHeartbeat(intervalMs: number, ping: () => void, terminate: () => void): Heartbeat;
@@ -0,0 +1,47 @@
1
+ /** Wire frames of the /v1/mux WebSocket (subset of the DSH stream protocol). */
2
+ export type ClientFrame = {
3
+ type: 'open';
4
+ streamId: string;
5
+ target: string;
6
+ } | {
7
+ type: 'cancel';
8
+ streamId: string;
9
+ };
10
+ export type ServerFrame = {
11
+ type: 'item';
12
+ streamId: string;
13
+ value: unknown;
14
+ } | {
15
+ type: 'end';
16
+ streamId: string;
17
+ } | {
18
+ type: 'error';
19
+ streamId: string;
20
+ message: string;
21
+ };
22
+ /** Uplink frame size limit; oversized frames error their stream without closing the socket. */
23
+ export declare const MAX_FRAME_BYTES = 262144;
24
+ /**
25
+ * Parses one uplink mux frame. Malformed JSON, unknown types, an empty streamId,
26
+ * or an `open` without a target produce `{ error }` instead of throwing.
27
+ */
28
+ export declare function parseClientFrame(raw: string): ClientFrame | {
29
+ error: string;
30
+ };
31
+ /** Addresses `bccli serve` is allowed to bind (loopback only; 0.0.0.0 is refused). */
32
+ export declare const LOOPBACK_BIND: Set<string>;
33
+ /**
34
+ * DSH-style trust fence: loopback Host with a port matching the listener, a
35
+ * same-machine Origin when attached, and no cross-site sec-fetch-site. Returns
36
+ * null when trusted, else the 403 reason. Never establishes identity — the
37
+ * bearer token does.
38
+ */
39
+ export declare function trustFence(headers: {
40
+ host?: string;
41
+ origin?: string;
42
+ 'sec-fetch-site'?: string;
43
+ }, port: number): string | null;
44
+ /** Timing-safe `Authorization: Bearer <token>` check. */
45
+ export declare function bearerOk(header: string | undefined, token: string): boolean;
46
+ /** Fresh 32-byte hex serve token. */
47
+ export declare function randomToken(): string;
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ Session,
4
+ pruneSessions
5
+ } from "./chunk-SVD4LHJC.js";
6
+ import "./chunk-5YJ3ZQVR.js";
7
+ import "./chunk-KPTML72Q.js";
8
+ import "./chunk-3WHI4LN3.js";
9
+ export {
10
+ Session,
11
+ pruneSessions
12
+ };
@@ -0,0 +1,33 @@
1
+ import { type ChatMessage, type Usage } from './provider';
2
+ export declare class Session {
3
+ readonly file: string;
4
+ constructor(file: string);
5
+ get id(): string;
6
+ static create(home: string, cwd: string, now?: Date): Session;
7
+ static list(home: string, cwd: string): {
8
+ session: Session;
9
+ mtime: Date;
10
+ preview: string;
11
+ }[];
12
+ static latest(home: string, cwd: string): Session | undefined;
13
+ private write;
14
+ append(message: ChatMessage): void;
15
+ appendUsage(usage: Usage & {
16
+ model?: string;
17
+ }): void;
18
+ reset(): void;
19
+ private records;
20
+ /** What the model continues from: everything after the last reset (after a compaction that is the summary and the recent turns). */
21
+ load(): ChatMessage[];
22
+ /** Model of the most recent turn that recorded usage — serve attach continues a session with its own model. */
23
+ lastModel(): string | undefined;
24
+ /** Accumulated token usage since the last non-compaction reset. */
25
+ totalUsage(): Usage;
26
+ /**
27
+ * What the user sees on resume: the whole conversation. Compaction only shrinks what the model is sent, so
28
+ * its reset does not hide the older turns here. A real reset (/clear, rewind) still starts over, the
29
+ * synthetic summary pair is never shown, and the recent turns a compaction re-writes are not shown twice.
30
+ */
31
+ loadHistory(): ChatMessage[];
32
+ }
33
+ export declare function pruneSessions(home: string, now?: number, maxAgeDays?: number): number;
@@ -0,0 +1,24 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ createRuntime,
4
+ lunaPtcAutoEnabled
5
+ } from "./chunk-R72OV7RF.js";
6
+ import "./chunk-OK2USAXX.js";
7
+ import "./chunk-ZEPTUKNW.js";
8
+ import "./chunk-JXM6REER.js";
9
+ import "./chunk-PSO7R5AD.js";
10
+ import "./chunk-WFZKJY3R.js";
11
+ import "./chunk-H7XJDKJY.js";
12
+ import "./chunk-IYR5PYA3.js";
13
+ import "./chunk-HQW4BROS.js";
14
+ import "./chunk-3I5BW3ZT.js";
15
+ import "./chunk-SVD4LHJC.js";
16
+ import "./chunk-5YJ3ZQVR.js";
17
+ import "./chunk-KPTML72Q.js";
18
+ import "./chunk-6M55UPES.js";
19
+ import "./chunk-RX4UQX43.js";
20
+ import "./chunk-3WHI4LN3.js";
21
+ export {
22
+ createRuntime,
23
+ lunaPtcAutoEnabled
24
+ };
@@ -0,0 +1,74 @@
1
+ import { Agent } from './agent';
2
+ import { CheckpointStore } from './checkpoints';
3
+ import type { McpServerSpec } from './mcp/config';
4
+ import { McpManager } from './mcp/manager';
5
+ import type { CliArgs } from './args';
6
+ import { type Config } from './config';
7
+ import { type AgentDef, type CommandDef, type SkillDef } from './extensions';
8
+ import { type ModelGroup } from './models';
9
+ import { type ChatMessage, type Provider } from './provider';
10
+ import type { ReasoningLevel } from './reasoning';
11
+ import { addProviderKey } from './providerCli';
12
+ import { Session } from './session';
13
+ import { type Interaction } from './tools/plan';
14
+ import { TodoStore } from './tools/todo';
15
+ import { type PluginPayload } from './plugins';
16
+ import type { HookEvent } from './hooks';
17
+ export interface Runtime {
18
+ cwd: string;
19
+ home: string;
20
+ config: Config;
21
+ modelRef: string;
22
+ reasoning: ReasoningLevel;
23
+ agent: Agent;
24
+ session: Session;
25
+ setModel(ref: string): void;
26
+ setReasoning(level: ReasoningLevel): void;
27
+ env: NodeJS.ProcessEnv;
28
+ skills: SkillDef[];
29
+ commands: CommandDef[];
30
+ agentDefs: AgentDef[];
31
+ todos: TodoStore;
32
+ interaction: Interaction;
33
+ mcp: McpManager;
34
+ startMcp(specs: McpServerSpec[]): Promise<void>;
35
+ reloadConfig(): void;
36
+ providerLabel(): string;
37
+ listModels: (only?: string) => Promise<ModelGroup[]>;
38
+ addProviderKey(id: string, key: string): ReturnType<typeof addProviderKey>;
39
+ /** Continue an earlier session: load its history and append new messages to its file. */
40
+ resume(session: Session): void;
41
+ /** Starts a fresh session file; the previous one stays on disk for /resume. */
42
+ newSession(): void;
43
+ /** Re-reads AGENTS.md/BCCLI.md into the system prompt (after /memory). */
44
+ rebuildSystemPrompt(): void;
45
+ /** Fires a plugin observer event (SessionStart/Stop are emitted here; tool events come from the agent). */
46
+ emitPlugins(event: HookEvent, payload?: PluginPayload): Promise<void>;
47
+ checkpoints: CheckpointStore;
48
+ /**
49
+ * Steps back n conversation turns: truncates the history (and the session log) to before
50
+ * them and restores the file snapshots they took. Returns undefined when nothing is left.
51
+ */
52
+ rewindTurns(n: number): Promise<RewindResult | undefined>;
53
+ startedAt: Date;
54
+ }
55
+ export interface RewindResult {
56
+ turns: number;
57
+ restored: string[];
58
+ deleted: string[];
59
+ skipped: string[];
60
+ failed: string[];
61
+ }
62
+ /** PTC is automatic for Luna. This env var is only an emergency/internal kill switch. */
63
+ export declare function lunaPtcAutoEnabled(env: NodeJS.ProcessEnv): boolean;
64
+ export declare function createRuntime(opts: {
65
+ cwd: string;
66
+ args: CliArgs;
67
+ env?: NodeJS.ProcessEnv;
68
+ provider?: Provider;
69
+ history?: ChatMessage[];
70
+ fetch?: typeof fetch;
71
+ userHome?: string;
72
+ /** Override langkah agent (mis. githubBot.stepLimit) — menang atas config.maxSteps. */
73
+ maxSteps?: number | null;
74
+ }): Runtime;
@@ -0,0 +1 @@
1
+ export declare function osc52(text: string, inTmux: boolean): string;
@@ -0,0 +1 @@
1
+ export declare function gitDiff(cwd: string, maxLines?: number, bin?: string): Promise<string>;
@@ -0,0 +1,18 @@
1
+ export interface DoctorDeps {
2
+ which: (cmd: string) => boolean | Promise<boolean>;
3
+ nodeVersion: string;
4
+ listModels: () => Promise<unknown[]>;
5
+ }
6
+ export declare function doctorText(input: {
7
+ providers: {
8
+ id: string;
9
+ name: string;
10
+ ready: boolean;
11
+ }[];
12
+ mcp: {
13
+ name: string;
14
+ status: string;
15
+ error?: string;
16
+ }[];
17
+ activeProvider: string;
18
+ }, deps: DoctorDeps): Promise<string>;
@@ -0,0 +1,2 @@
1
+ import { type ChatMessage } from '../provider';
2
+ export declare function exportMarkdown(messages: ChatMessage[], title: string): string;
@@ -0,0 +1,46 @@
1
+ export interface StatusInput {
2
+ version: string;
3
+ modelRef: string;
4
+ providerLabel: string;
5
+ mode: string;
6
+ cwd: string;
7
+ mcp: {
8
+ name: string;
9
+ status: string;
10
+ error?: string;
11
+ tools: number;
12
+ }[];
13
+ usage: {
14
+ inputTokens: number;
15
+ outputTokens: number;
16
+ cachedInputTokens?: number;
17
+ cacheWriteTokens?: number;
18
+ };
19
+ lastInputTokens: number;
20
+ contextWindow?: number;
21
+ }
22
+ export declare function statusText(s: StatusInput): string;
23
+ export declare function agentsText(defs: {
24
+ name: string;
25
+ description: string;
26
+ tools?: string[];
27
+ model?: string;
28
+ }[]): string;
29
+ export declare function skillsText(skills: {
30
+ name: string;
31
+ description: string;
32
+ dir: string;
33
+ }[], commands: {
34
+ name: string;
35
+ description?: string;
36
+ }[]): string;
37
+ export declare function sessionText(s: {
38
+ file: string;
39
+ started: Date;
40
+ messages: number;
41
+ usage: {
42
+ inputTokens: number;
43
+ outputTokens: number;
44
+ };
45
+ modelRef: string;
46
+ }): string;
@@ -0,0 +1,10 @@
1
+ export declare function instructionFiles(cwd: string, home: string): {
2
+ path: string;
3
+ lines: number;
4
+ }[];
5
+ export declare function appendMemory(file: string, text: string): void;
6
+ /** `/memory [global] <teks>` → target file and text; text is empty when nothing follows. */
7
+ export declare function parseMemoryArgs(args: string): {
8
+ global: boolean;
9
+ text: string;
10
+ };
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  estimateTokens
4
- } from "./chunk-QZKLZELZ.js";
4
+ } from "./chunk-OK2USAXX.js";
5
5
  import {
6
6
  t
7
- } from "./chunk-UZWJQF67.js";
7
+ } from "./chunk-3WHI4LN3.js";
8
8
 
9
9
  // src/statsCli.ts
10
10
  import { existsSync, readdirSync, readFileSync, statSync } from "fs";
@@ -0,0 +1,62 @@
1
+ export interface StatsRow {
2
+ project: string;
3
+ sessions: number;
4
+ messages: number;
5
+ /** Estimated tokens (messages without recorded usage only). */
6
+ inputTokens: number;
7
+ outputTokens: number;
8
+ /** Tokens from persisted `t:usage` records. */
9
+ usageInputTokens: number;
10
+ usageOutputTokens: number;
11
+ cachedInputTokens: number;
12
+ cacheWriteTokens: number;
13
+ toolCalls: Record<string, number>;
14
+ /** Total tokens per session (recorded basis when present, estimate otherwise). */
15
+ sessionTotals: number[];
16
+ /** Per-model token totals from `t:usage` records that carry a model ref. */
17
+ modelUsage: Record<string, ModelTotals>;
18
+ }
19
+ export interface ModelTotals {
20
+ turns: number;
21
+ inputTokens: number;
22
+ outputTokens: number;
23
+ cachedInputTokens: number;
24
+ cacheWriteTokens: number;
25
+ }
26
+ export interface AggregateOptions {
27
+ days: number;
28
+ now?: number;
29
+ }
30
+ /**
31
+ * Walk home/sessions/<project>/*.jsonl, keep files with mtime within `days`,
32
+ * and aggregate per project. Token basis switches per session: sessions with
33
+ * recorded usage records use them (incl. cache counters); older sessions fall
34
+ * back to ~4 chars/token estimates from message content.
35
+ */
36
+ export declare function aggregateSessions(home: string, opts: AggregateOptions): StatsRow[];
37
+ /** Compact token formatting like the opencode stats boxes: 291.6K / 41.0M / 627.4M. */
38
+ export declare function fmtCompact(n: number): string;
39
+ export interface StatsCliArgs {
40
+ subArgs: string[];
41
+ home: string;
42
+ cwd?: string;
43
+ now?: number;
44
+ /** Already-parsed `--days` from parseCliArgs (subArgs never contains it). */
45
+ days?: number;
46
+ /** Already-parsed `--tools` top-N cap. */
47
+ tools?: number;
48
+ /** Already-parsed `--models` ("all" or a number as string). */
49
+ models?: string;
50
+ /** Already-parsed `--project` filter (empty string = current project). */
51
+ project?: string;
52
+ }
53
+ export interface StatsDeps {
54
+ out(line: string): void;
55
+ err?(line: string): void;
56
+ }
57
+ /**
58
+ * `bccli stats [--days N] [--tools N] [--models [N|all]] [--project slug]` —
59
+ * token usage and tool-call stats from local session files, rendered as
60
+ * opencode-style overview/tokens/model/tool boxes.
61
+ */
62
+ export declare function runStatsCommand(args: StatsCliArgs, deps: StatsDeps): number;
@@ -0,0 +1,6 @@
1
+ import type { ToolCall } from './provider';
2
+ import type { ToolDefinition } from './tools/index';
3
+ export declare function recoverTextToolCalls(text: string, tools: ToolDefinition[]): {
4
+ text: string;
5
+ toolCalls: ToolCall[];
6
+ } | null;
@@ -0,0 +1,17 @@
1
+ export declare class ThinkSplitter {
2
+ private inside;
3
+ private held;
4
+ push(delta: string): {
5
+ text: string;
6
+ thinking: string;
7
+ };
8
+ /** Whatever was held back as a possible tag start is plain text after all. */
9
+ flush(): {
10
+ text: string;
11
+ thinking: string;
12
+ };
13
+ }
14
+ export declare function splitThinking(text: string): {
15
+ text: string;
16
+ thinking: string;
17
+ };
@@ -0,0 +1,22 @@
1
+ import type { ChatMessage } from './provider';
2
+ /** ~4 chars per token, the same conservative estimate the usage fallback uses. */
3
+ export declare const estimateTokens: (text: string) => number;
4
+ export declare function estimateMessages(messages: ChatMessage[]): number;
5
+ /**
6
+ * Drops whole oldest turns (everything up to the next user message) until the history fits the
7
+ * budget. Cutting only at turn boundaries keeps assistant tool_calls paired with their tool
8
+ * replies, so the trimmed history is always valid for a provider request.
9
+ */
10
+ export declare function trimToFit(messages: ChatMessage[], maxTokens: number): ChatMessage[];
11
+ /**
12
+ * Splits history into [old, keep]: the newest whole turns that fit `keepTokens` (at least the
13
+ * last user turn) stay verbatim; everything older goes to `old` for summarization. Cutting at
14
+ * user boundaries keeps tool_calls paired with their replies.
15
+ */
16
+ export declare function splitKeepRecent(messages: ChatMessage[], keepTokens: number): [ChatMessage[], ChatMessage[]];
17
+ export declare const isToolStub: (content: string) => boolean;
18
+ /**
19
+ * Replaces old tool results with a one-line stub once they add up past PRUNE_MIN_TOKENS, so the
20
+ * prompt prefix (and its cache) changes rarely. The newest KEEP_TOKENS worth stay intact.
21
+ */
22
+ export declare function pruneOldToolOutputs(messages: ChatMessage[]): boolean;
@@ -0,0 +1,52 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { z } from 'zod';
3
+ import { type ShellDeps, type ShellSpec } from './shell';
4
+ type Spawn = typeof spawn;
5
+ /** Kill a command and everything it started. Never throws (e.g. taskkill missing on Windows). */
6
+ export declare function killProcessTree(pid: number, platform?: NodeJS.Platform, spawnFn?: Spawn): void;
7
+ export declare function killAllCommands(): void;
8
+ /** Human-readable list for the /tasks slash command. */
9
+ export declare function renderBackgroundTasks(): string;
10
+ /** Test/exit helper: stop every background task and forget them. */
11
+ export declare function resetBackgroundTasks(): void;
12
+ export interface CommandResult {
13
+ output: string;
14
+ exitCode: number | null;
15
+ timedOut: boolean;
16
+ aborted: boolean;
17
+ }
18
+ export declare function needsNetwork(command: string): boolean;
19
+ /** Proxy env pointing at a dead local port: tools that honour proxy vars fail fast offline. */
20
+ export declare function offlineEnv(env?: NodeJS.ProcessEnv): NodeJS.ProcessEnv;
21
+ export declare function runCommand(command: string | string[], opts: {
22
+ cwd: string;
23
+ timeoutMs: number;
24
+ signal: AbortSignal;
25
+ env?: NodeJS.ProcessEnv;
26
+ shell?: ShellSpec;
27
+ }): Promise<CommandResult>;
28
+ export interface BashToolOptions {
29
+ /** "offline" blocks known network commands and points proxy env at a dead local port. */
30
+ networkPolicy?: 'allow' | 'offline';
31
+ /** Run every command inside the OS sandbox (sandbox-exec on macOS, bwrap on Linux). */
32
+ sandbox?: boolean;
33
+ /** Test hook: pretend to be another platform. */
34
+ platform?: NodeJS.Platform;
35
+ /** Test hook: fake environment / file lookup used to pick the Windows shell. */
36
+ shellDeps?: Partial<ShellDeps>;
37
+ }
38
+ export declare function createBashTool(options?: BashToolOptions): import("./types").Tool<z.ZodObject<{
39
+ command: z.ZodOptional<z.ZodString>;
40
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
41
+ background: z.ZodOptional<z.ZodBoolean>;
42
+ task_id: z.ZodOptional<z.ZodNumber>;
43
+ kill: z.ZodOptional<z.ZodBoolean>;
44
+ }, z.core.$strip>>;
45
+ export declare const bashTool: import("./types").Tool<z.ZodObject<{
46
+ command: z.ZodOptional<z.ZodString>;
47
+ timeout_ms: z.ZodOptional<z.ZodNumber>;
48
+ background: z.ZodOptional<z.ZodBoolean>;
49
+ task_id: z.ZodOptional<z.ZodNumber>;
50
+ kill: z.ZodOptional<z.ZodBoolean>;
51
+ }, z.core.$strip>>;
52
+ export {};
@@ -0,0 +1,5 @@
1
+ import { z } from 'zod';
2
+ import { type LspServer } from '../lsp';
3
+ export declare function createDiagnosticsTool(servers: LspServer[]): import("./types").Tool<z.ZodObject<{
4
+ path: z.ZodString;
5
+ }, z.core.$strip>>;
@@ -0,0 +1,12 @@
1
+ import { z } from 'zod';
2
+ export declare const editTool: import("./types").Tool<z.ZodObject<{
3
+ path: z.ZodString;
4
+ old_string: z.ZodOptional<z.ZodString>;
5
+ new_string: z.ZodOptional<z.ZodString>;
6
+ replace_all: z.ZodOptional<z.ZodBoolean>;
7
+ edits: z.ZodOptional<z.ZodArray<z.ZodObject<{
8
+ old_string: z.ZodString;
9
+ new_string: z.ZodString;
10
+ replace_all: z.ZodOptional<z.ZodBoolean>;
11
+ }, z.core.$strip>>>;
12
+ }, z.core.$strip>>;