@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
@@ -0,0 +1,21 @@
1
+ import { spawnSync } from 'node:child_process';
2
+ /**
3
+ * Synchronous npm runner. On Windows it NEVER goes through cmd.exe: npm's own
4
+ * npm.cmd is just a shim around `node …\node_modules\npm\bin\npm-cli.js`, so we
5
+ * invoke that script with process.execPath and pass every argument as plain
6
+ * argv. Shell metacharacters in the prefix path (& % ( ) spaces, …) therefore
7
+ * need no quoting at all — nothing is ever joined into a command line.
8
+ */
9
+ export interface NpmRunResult {
10
+ code: number;
11
+ stderr: string;
12
+ stdout?: string;
13
+ }
14
+ export interface RunNpmOptions {
15
+ platform?: NodeJS.Platform;
16
+ spawn?: typeof spawnSync;
17
+ env?: NodeJS.ProcessEnv;
18
+ exists?: (path: string) => boolean;
19
+ execPath?: string;
20
+ }
21
+ export declare function runNpmSync(prefix: string, argv: string[], opts?: RunNpmOptions): NpmRunResult;
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  t
4
- } from "./chunk-UZWJQF67.js";
4
+ } from "./chunk-3WHI4LN3.js";
5
5
 
6
6
  // src/oauthLogin.ts
7
7
  import { createHash, randomBytes } from "crypto";
@@ -0,0 +1,47 @@
1
+ export declare const OPENROUTER_AUTH_URL = "https://openrouter.ai/auth";
2
+ export declare const OPENROUTER_EXCHANGE_URL = "https://openrouter.ai/api/v1/auth/keys";
3
+ export declare const OPENROUTER_DASHBOARD_URL = "https://openrouter.ai/settings/keys";
4
+ export declare const OPENROUTER_ENV_KEY = "OPENROUTER_API_KEY";
5
+ export declare function pkcePair(): {
6
+ verifier: string;
7
+ challenge: string;
8
+ };
9
+ /** Varian tanpa redirect per docs resmi OpenRouter: kode ditampilkan untuk di-copy. */
10
+ export declare function buildAuthUrl(challenge: string): string;
11
+ export declare function redact(text: string, secrets: string[]): string;
12
+ export declare function classifyExchange403(detail: string): 'expired' | 'rejected';
13
+ export type ExchangeResult = {
14
+ ok: true;
15
+ key: string;
16
+ } | {
17
+ ok: false;
18
+ kind: 'timeout' | 'network' | 'cancelled' | 'http403-expired' | 'http403-rejected' | 'http-other' | 'invalid-body';
19
+ status?: number;
20
+ detail: string;
21
+ };
22
+ export declare function exchangeAuthCode(code: string, verifier: string, deps: {
23
+ fetch: typeof fetch;
24
+ timeoutMs?: number;
25
+ signal?: AbortSignal;
26
+ }): Promise<ExchangeResult>;
27
+ /** Balasan readLine saat Ctrl+C pada mode test; di produksi readLine exit 130 langsung. */
28
+ export declare const ABORT: unique symbol;
29
+ export interface OauthLoginDeps {
30
+ out(s: string): void;
31
+ err(s: string): void;
32
+ env: NodeJS.ProcessEnv;
33
+ isTTY: boolean;
34
+ open(url: string): void;
35
+ readLine(prompt: string): Promise<string | typeof ABORT>;
36
+ saveCredential(id: string, key: string): void;
37
+ fetch: typeof fetch;
38
+ timeoutMs?: number;
39
+ }
40
+ export declare function runOauthLogin(deps: OauthLoginDeps): Promise<number>;
41
+ export interface OauthLogoutDeps {
42
+ out(s: string): void;
43
+ err(s: string): void;
44
+ env: NodeJS.ProcessEnv;
45
+ removeCredential(id: string): boolean;
46
+ }
47
+ export declare function runOauthLogout(deps: OauthLogoutDeps): Promise<number>;
@@ -0,0 +1,30 @@
1
+ import type { PermissionMode } from './config';
2
+ import type { PermissionKind } from './tools/types';
3
+ export interface PermissionRequest {
4
+ tool: string;
5
+ kind: PermissionKind;
6
+ target: string;
7
+ }
8
+ export type Decision = 'allow' | 'deny' | 'ask';
9
+ export declare const MODE_ORDER: PermissionMode[];
10
+ export declare function nextMode(mode: PermissionMode): PermissionMode;
11
+ export declare function requiresSensitiveToolApproval(req: PermissionRequest): boolean;
12
+ export declare class Permissions {
13
+ mode: PermissionMode;
14
+ private readonly cwd;
15
+ private readonly rules;
16
+ private readonly configRules;
17
+ constructor(mode: PermissionMode, rules?: string[], cwd?: string);
18
+ /** Edits may only be auto-allowed inside the project and outside .git. */
19
+ private editInProject;
20
+ /** Rules that "[a] allow for this session" would add; undefined when it must always be asked. */
21
+ rulesFor(req: PermissionRequest): string[] | undefined;
22
+ check(req: PermissionRequest): Decision;
23
+ list(): {
24
+ rule: string;
25
+ source: 'config' | 'session';
26
+ }[];
27
+ /** Removes a session grant; rules from config/flags stay until the user edits them. */
28
+ revoke(rule: string): void;
29
+ allowForSession(req: PermissionRequest): void;
30
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Strict npm spec parsing and managed-entry validation for `bccli plugins`.
3
+ * Pure module — no filesystem or process access.
4
+ */
5
+ export interface ParsedSpec {
6
+ /** Package name without the @version/@tag suffix; scope preserved. */
7
+ name: string;
8
+ /** The original (trimmed) spec, safe to hand to npm argv. */
9
+ spec: string;
10
+ }
11
+ /**
12
+ * Parses an npm install spec. Rejects URLs, git+ssh/github:/file: refs, local
13
+ * paths, flag-like arguments (leading '-'), uppercase, spaces/metachars and
14
+ * npm ranges (^, ~). Returns null when anything is off.
15
+ */
16
+ export declare function parseNpmSpec(raw: string): ParsedSpec | null;
17
+ /** Canonical config entry for a managed package (a config STRING, never join()). */
18
+ export declare function managedEntry(name: string): string;
19
+ export declare function isManagedEntry(entry: string): boolean;
20
+ /**
21
+ * Strict validation of a managed entry: canonical prefix + bare npm name suffix.
22
+ * Returns the bare name, or null when the entry is not managed or is malformed
23
+ * (malformed entries must never be handed to npm).
24
+ */
25
+ export declare function managedEntryName(entry: string): string | null;
@@ -0,0 +1,45 @@
1
+ import { z } from 'zod';
2
+ import { type Config } from './config';
3
+ import type { HookEvent } from './hooks';
4
+ import type { Tool, ToolContext, ToolResult } from './tools/types';
5
+ export type PluginPayload = {
6
+ tool?: string;
7
+ input?: unknown;
8
+ output?: string;
9
+ };
10
+ /** What a plugin may do at load time. `config` is the read-only view of the loaded config. */
11
+ export interface PluginContext {
12
+ cwd: string;
13
+ env: NodeJS.ProcessEnv;
14
+ config: Readonly<Config>;
15
+ registerTool(tool: PluginTool): void;
16
+ /** Observe-only in v1: handlers run in order, errors are logged and never break the session. */
17
+ on(event: HookEvent, handler: (payload: PluginPayload) => void | Promise<void>): void;
18
+ log(message: string): void;
19
+ }
20
+ /** A tool as declared by a plugin; schema/kind/target get safe defaults. */
21
+ export interface PluginTool {
22
+ name: string;
23
+ description: string;
24
+ schema?: z.ZodType;
25
+ kind?: Tool['kind'];
26
+ target?: (input: unknown) => string;
27
+ run(input: never, ctx: ToolContext): Promise<ToolResult>;
28
+ }
29
+ export interface LoadedPlugins {
30
+ tools: Tool[];
31
+ emit(event: HookEvent, payload?: PluginPayload): Promise<void>;
32
+ }
33
+ /**
34
+ * Loads the plugins listed in the global config (trusted). Specs may be absolute paths,
35
+ * `./`-relative to the config home, or bare package specifiers. Every failure — missing
36
+ * file, syntax error, bad activation, name collision — throws ConfigError so a broken
37
+ * plugin is visible immediately instead of silently missing.
38
+ */
39
+ export declare function loadPlugins(specs: string[], opts: {
40
+ home: string;
41
+ cwd: string;
42
+ env: NodeJS.ProcessEnv;
43
+ config: Config;
44
+ builtinNames: string[];
45
+ }): LoadedPlugins;
@@ -2,10 +2,10 @@
2
2
  import {
3
3
  bccliHome,
4
4
  globalConfigPath
5
- } from "./chunk-LACUWBWS.js";
5
+ } from "./chunk-RX4UQX43.js";
6
6
  import {
7
7
  t
8
- } from "./chunk-UZWJQF67.js";
8
+ } from "./chunk-3WHI4LN3.js";
9
9
 
10
10
  // src/pluginsCli.ts
11
11
  import { existsSync, mkdirSync, readFileSync, statSync, writeFileSync } from "fs";
@@ -0,0 +1,16 @@
1
+ import type { CliArgs } from './args';
2
+ export interface PluginsDeps {
3
+ out(s: string): void;
4
+ err(s: string): void;
5
+ env: NodeJS.ProcessEnv;
6
+ /** argv = argumen setelah npm (mis. ['install','foo']). Prefix = <home>/plugins. */
7
+ runNpm(prefix: string, argv: string[]): Promise<{
8
+ code: number;
9
+ stderr: string;
10
+ }>;
11
+ readPlugins(): string[];
12
+ savePlugins(entries: string[]): void;
13
+ }
14
+ /** Minimal package.json so `npm install --prefix` behaves deterministically. */
15
+ export declare function ensurePrefixDir(prefix: string): void;
16
+ export declare function runPluginsCommand(args: CliArgs, deps: PluginsDeps): Promise<number>;
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  t
4
- } from "./chunk-UZWJQF67.js";
4
+ } from "./chunk-3WHI4LN3.js";
5
5
 
6
6
  // src/prCli.ts
7
7
  import { spawn } from "child_process";
@@ -21,7 +21,15 @@ function defaultGh(argv) {
21
21
  });
22
22
  }
23
23
  function prTaskArgv(entry, opts) {
24
- return [entry, ...opts.prompt ? ["-p", opts.prompt] : [], ...opts.allowAll ? ["--allow-all"] : []];
24
+ return [
25
+ entry,
26
+ ...opts.prompt ? ["-p", opts.prompt] : [],
27
+ ...opts.model ? ["-m", opts.model] : [],
28
+ ...opts.reasoning ? ["--reasoning", opts.reasoning] : [],
29
+ ...opts.permissionMode ? ["--permission-mode", opts.permissionMode] : [],
30
+ ...opts.allowedTools?.length ? ["--allowed-tools", opts.allowedTools.join(",")] : [],
31
+ ...opts.allowAll ? ["--allow-all"] : []
32
+ ];
25
33
  }
26
34
  async function defaultRunTask(opts) {
27
35
  const entry = process.argv[1];
@@ -38,7 +46,7 @@ async function defaultRunTask(opts) {
38
46
  }
39
47
  async function runPrCommand(args, deps) {
40
48
  const rest = [...args.subArgs];
41
- let repo;
49
+ let repo = args.repo;
42
50
  const words = [];
43
51
  for (let i = 0; i < rest.length; i++) {
44
52
  if (rest[i] === "--repo") {
@@ -70,7 +78,15 @@ async function runPrCommand(args, deps) {
70
78
  const runTask = deps.runTask ?? defaultRunTask;
71
79
  const allowAll = args.allowAll === true;
72
80
  if (allowAll) deps.err?.(t("--allow-all: the PR task runs every tool without asking"));
73
- return runTask({ prompt: task, allowAll, cwd: args.cwd });
81
+ return runTask({
82
+ prompt: task,
83
+ allowAll,
84
+ cwd: args.cwd,
85
+ ...args.model ? { model: args.model } : {},
86
+ ...args.reasoning ? { reasoning: args.reasoning } : {},
87
+ ...args.permissionMode ? { permissionMode: args.permissionMode } : {},
88
+ ...args.allowedTools?.length ? { allowedTools: args.allowedTools } : {}
89
+ });
74
90
  }
75
91
  export {
76
92
  prTaskArgv,
@@ -0,0 +1,46 @@
1
+ export interface PrCliArgs {
2
+ subArgs: string[];
3
+ cwd: string;
4
+ /** Set only when the user asked for `bccli pr … --allow-all`. */
5
+ allowAll?: boolean;
6
+ repo?: string;
7
+ model?: string;
8
+ reasoning?: string;
9
+ permissionMode?: string;
10
+ allowedTools?: string[];
11
+ }
12
+ export interface PrDeps {
13
+ out(line: string): void;
14
+ err?(line: string): void;
15
+ /** gh argv runner (no shell). Defaults to `gh` on PATH. */
16
+ gh?(argv: string[]): Promise<{
17
+ code: number;
18
+ stdout: string;
19
+ stderr: string;
20
+ }>;
21
+ /** Run the agent task after checkout (injectable for tests). */
22
+ runTask?(opts: {
23
+ prompt?: string;
24
+ allowAll: boolean;
25
+ cwd: string;
26
+ model?: string;
27
+ reasoning?: string;
28
+ permissionMode?: string;
29
+ allowedTools?: string[];
30
+ }): Promise<number>;
31
+ }
32
+ /** argv for the child running the PR task; `--allow-all` only when the user asked for it. */
33
+ export declare function prTaskArgv(entry: string, opts: {
34
+ prompt?: string;
35
+ allowAll?: boolean;
36
+ model?: string;
37
+ reasoning?: string;
38
+ permissionMode?: string;
39
+ allowedTools?: string[];
40
+ }): string[];
41
+ /**
42
+ * `bccli pr <number> [--repo owner/name] [task]` — check out a GitHub PR
43
+ * with `gh pr checkout`, then run an optional task on the checked-out branch.
44
+ * Read-only: never pushes, merges, or comments.
45
+ */
46
+ export declare function runPrCommand(args: PrCliArgs, deps: PrDeps): Promise<number>;
@@ -0,0 +1,8 @@
1
+ export interface ProviderPreset {
2
+ id: string;
3
+ name: string;
4
+ baseURL: string;
5
+ apiKeyEnv?: string;
6
+ local?: boolean;
7
+ }
8
+ export declare const PRESETS: ProviderPreset[];
@@ -0,0 +1,16 @@
1
+ import type { Runtime } from './setup';
2
+ interface Writer {
3
+ write(s: string): unknown;
4
+ }
5
+ export declare function toolLabel(tool: string): string;
6
+ export type OutputFormat = 'text' | 'json' | 'stream-json';
7
+ /** Combines an optional piped stdin payload with the `-p` prompt argument. */
8
+ export declare function resolvePrintPrompt(prompt: string | undefined, stdinText: string | undefined): string | undefined;
9
+ export declare function runPrint(rt: Runtime, prompt: string, io?: {
10
+ out: Writer;
11
+ err: Writer;
12
+ }, opts?: {
13
+ allowAll?: boolean;
14
+ outputFormat?: OutputFormat;
15
+ }): Promise<number>;
16
+ export {};
@@ -0,0 +1,145 @@
1
+ import OpenAI from 'openai';
2
+ import { ResponsesWS } from 'openai/resources/responses/ws';
3
+ import type { ResponseOutputItem } from 'openai/resources/responses/responses';
4
+ import { type ReasoningLevel } from './reasoning';
5
+ import type { ToolDefinition } from './tools/index';
6
+ import type { ImageAttachment } from './tools/types';
7
+ export interface ResponsesProgramCaller {
8
+ type: 'program';
9
+ caller_id: string;
10
+ }
11
+ export interface ToolCall {
12
+ id: string;
13
+ name: string;
14
+ arguments: string;
15
+ caller?: ResponsesProgramCaller;
16
+ }
17
+ export type ContentPart = {
18
+ type: 'text';
19
+ text: string;
20
+ } | {
21
+ type: 'image_url';
22
+ image_url: {
23
+ url: string;
24
+ };
25
+ };
26
+ export type ChatMessage = {
27
+ role: 'system';
28
+ content: string;
29
+ } | {
30
+ role: 'user';
31
+ content: string | ContentPart[];
32
+ } | {
33
+ role: 'assistant';
34
+ content: string | null;
35
+ tool_calls?: {
36
+ id: string;
37
+ type: 'function';
38
+ function: {
39
+ name: string;
40
+ arguments: string;
41
+ };
42
+ caller?: ResponsesProgramCaller;
43
+ }[];
44
+ /** Exact OpenAI Responses output items for stateless Luna replay/reconnect. Hidden from normal UI/export. */
45
+ responses_output_items?: ResponseOutputItem[];
46
+ } | {
47
+ role: 'tool';
48
+ tool_call_id: string;
49
+ content: string;
50
+ /** Program caller linkage must be round-tripped for PTC continuation. */
51
+ responses_caller?: ResponsesProgramCaller;
52
+ };
53
+ export interface Usage {
54
+ inputTokens: number;
55
+ outputTokens: number;
56
+ cachedInputTokens?: number;
57
+ cacheWriteTokens?: number;
58
+ }
59
+ export interface Completion {
60
+ text: string;
61
+ toolCalls: ToolCall[];
62
+ /** Exact OpenAI Responses output items, preserved for store:false replay. */
63
+ responsesOutputItems?: ResponseOutputItem[];
64
+ /** The model's reasoning, when it sends any (reasoning_content or <think> blocks); not part of the history. */
65
+ thinking?: string;
66
+ usage?: Usage;
67
+ finishReason?: string;
68
+ }
69
+ export interface ChatRequest {
70
+ messages: ChatMessage[];
71
+ tools?: ToolDefinition[];
72
+ /** Local-only allowlist for read-only PTC-safe tools; never serialized to Chat Completions. */
73
+ programmaticToolNames?: string[];
74
+ signal?: AbortSignal;
75
+ onText?: (delta: string) => void;
76
+ onThinking?: (delta: string) => void;
77
+ reasoning?: ReasoningLevel;
78
+ }
79
+ export interface Provider {
80
+ chat(req: ChatRequest): Promise<Completion>;
81
+ listModels(): Promise<string[]>;
82
+ }
83
+ export declare class ProviderError extends Error {
84
+ readonly status?: number | undefined;
85
+ readonly code?: string | undefined;
86
+ constructor(message: string, status?: number | undefined, code?: string | undefined);
87
+ }
88
+ interface ProviderOptions {
89
+ baseURL: string;
90
+ apiKey?: string;
91
+ model: string;
92
+ providerId?: string;
93
+ fetch?: typeof fetch;
94
+ retryDelayMs?: number;
95
+ responsesWebSocketFactory?: (client: OpenAI) => ResponsesWS;
96
+ /** Experimental Luna-only PTC canary. Kept opt-in until replay/cost canaries pass. */
97
+ enableProgrammaticToolCalling?: boolean;
98
+ }
99
+ /**
100
+ * Small models sometimes get stuck emitting the same few characters forever.
101
+ * Returns where the loop starts when the tail is one short unit (1-12 chars, not just
102
+ * whitespace) repeated at least 20 times over 300+ chars; otherwise -1. Normal markdown
103
+ * rules like 80 "=" stay under the length threshold.
104
+ */
105
+ export declare function detectRepetition(text: string): number;
106
+ /** Plain-text rendering of message content for previews, exports, and the chat UI. */
107
+ export declare function contentText(content: string | ContentPart[]): string;
108
+ /** The user message that carries read images to a vision-capable model. */
109
+ export declare function imageUserMessage(images: ImageAttachment[]): ChatMessage;
110
+ export declare function responseInputFromMessages(messages: ChatMessage[]): Record<string, unknown>[];
111
+ export declare function shouldForceLunaPtc(messages: ChatMessage[], enabled: boolean): boolean;
112
+ /**
113
+ * Cost-aware PTC gate for Luna.
114
+ * Beta.24 proved PTC is excellent for large read-heavy aggregation but expensive for one tiny read.
115
+ * Keep PTC available only when the current turn has multi-source/data-reduction intent, a large
116
+ * read-only intermediate result, or an already-started program that must be continued safely.
117
+ */
118
+ export declare function shouldEnableLunaPtc(messages: ChatMessage[], enabled: boolean, programmaticToolNames?: string[]): boolean;
119
+ export interface LunaToolPlan {
120
+ tools: Record<string, unknown>[];
121
+ useToolSearch: boolean;
122
+ useProgrammaticToolCalling: boolean;
123
+ deferredToolCount: number;
124
+ deferredSchemaChars: number;
125
+ }
126
+ export declare function lunaToolPlan(tools?: ToolDefinition[], enableProgrammaticToolCalling?: boolean, programmaticToolNames?: string[], forceProgrammaticOnly?: boolean): LunaToolPlan;
127
+ export declare function hasPendingProgrammaticReplay(messages: ChatMessage[]): boolean;
128
+ interface LunaWsContinuation {
129
+ responseId: string;
130
+ requestMessages: ChatMessage[];
131
+ completion: Completion;
132
+ }
133
+ export declare function completionAssistantMessage(completion: Completion): ChatMessage;
134
+ export declare function responseContinuationInput(messages: ChatMessage[], continuation?: LunaWsContinuation): {
135
+ input: Record<string, unknown>[];
136
+ previousResponseId?: string;
137
+ incremental: boolean;
138
+ };
139
+ export declare function createProvider(options: ProviderOptions): Provider;
140
+ /**
141
+ * Wraps a primary provider with automatic fallback providers tried in order when the primary
142
+ * fails before emitting any text (e.g. HTTP 429 rate-limit/quota, 5xx, or connection failure).
143
+ */
144
+ export declare function withFallbackProvider(primary: Provider, fallbacks: () => Provider[]): Provider;
145
+ export {};
@@ -0,0 +1,15 @@
1
+ #!/usr/bin/env node
2
+ import {
3
+ addProviderKey,
4
+ runProviderCommand
5
+ } from "./chunk-H7XJDKJY.js";
6
+ import "./chunk-IYR5PYA3.js";
7
+ import "./chunk-HQW4BROS.js";
8
+ import "./chunk-5YJ3ZQVR.js";
9
+ import "./chunk-KPTML72Q.js";
10
+ import "./chunk-RX4UQX43.js";
11
+ import "./chunk-3WHI4LN3.js";
12
+ export {
13
+ addProviderKey,
14
+ runProviderCommand
15
+ };
@@ -0,0 +1,17 @@
1
+ import type { CliArgs } from './args';
2
+ export interface CliDeps {
3
+ env: NodeJS.ProcessEnv;
4
+ cwd: string;
5
+ out: (s: string) => void;
6
+ err: (s: string) => void;
7
+ readSecret: (prompt: string) => Promise<string>;
8
+ fetch?: typeof fetch;
9
+ }
10
+ export declare function addProviderKey(providerId: string, key: string, deps: CliDeps): Promise<{
11
+ ok: true;
12
+ models: number;
13
+ } | {
14
+ ok: false;
15
+ error: string;
16
+ }>;
17
+ export declare function runProviderCommand(args: CliArgs, deps: CliDeps): Promise<number>;
@@ -0,0 +1,6 @@
1
+ import { type Config } from './config';
2
+ export declare function providerName(config: Config, id: string): string;
3
+ export declare function hasKey(config: Config, id: string, env?: NodeJS.ProcessEnv): boolean;
4
+ export declare function readGlobalConfigFile(env?: NodeJS.ProcessEnv): Partial<Config>;
5
+ export declare function writeGlobalConfig(patch: Partial<Config>, env?: NodeJS.ProcessEnv): void;
6
+ export declare function removeGlobalProvider(id: string, env?: NodeJS.ProcessEnv): void;
@@ -0,0 +1,12 @@
1
+ export declare const REASONING_LEVELS: readonly ['auto', 'off', 'low', 'medium', 'high', 'max'];
2
+ export type ReasoningLevel = (typeof REASONING_LEVELS)[number];
3
+ export interface ReasoningCapability {
4
+ levels: readonly ReasoningLevel[];
5
+ parameter: 'reasoning_effort' | 'reasoning';
6
+ }
7
+ export declare function isReasoningLevel(value: string): value is ReasoningLevel;
8
+ export declare function parseReasoningLevel(value: string, label?: string): ReasoningLevel;
9
+ export declare function reasoningCapability(providerId?: string): ReasoningCapability | undefined;
10
+ export declare function supportedReasoningLevels(providerId?: string): readonly ReasoningLevel[];
11
+ export declare function assertReasoningSupported(providerId: string | undefined, level: ReasoningLevel): void;
12
+ export declare function reasoningPayload(providerId: string | undefined, level: ReasoningLevel): Record<string, unknown>;
@@ -0,0 +1,10 @@
1
+ /** Top-level function/class/type names of one file, capped, in source order. */
2
+ export declare function extractSymbols(text: string, ext: string): string[];
3
+ /**
4
+ * Aider-style repo map: every code file (node_modules/.git excluded) with its top-level
5
+ * symbols, shallowest paths first, cut off at a token budget. Synchronous on purpose —
6
+ * it is computed once at boot for the system prompt.
7
+ */
8
+ export declare function buildRepoMapSync(cwd: string, opts?: {
9
+ maxTokens?: number;
10
+ }): string;
package/dist/sdk.d.ts ADDED
@@ -0,0 +1,61 @@
1
+ import type { Provider } from './provider';
2
+ /**
3
+ * Programmatic API: run one bccli task in-process. Permissions are allowAll — the caller
4
+ * is the supervisor. MCP servers are not started; tools are the built-ins + global plugins.
5
+ */
6
+ export interface SdkOptions {
7
+ prompt: string;
8
+ cwd?: string;
9
+ /** provider/model ref, e.g. "bc-cloud/glm-5.3-flash" (default: the config model). */
10
+ model?: string;
11
+ provider?: Provider;
12
+ env?: NodeJS.ProcessEnv;
13
+ fetch?: typeof fetch;
14
+ signal?: AbortSignal;
15
+ }
16
+ export interface SdkToolCall {
17
+ name: string;
18
+ target: string;
19
+ output?: string;
20
+ isError?: boolean;
21
+ }
22
+ export interface SdkResult {
23
+ text: string;
24
+ toolCalls: SdkToolCall[];
25
+ usage: {
26
+ inputTokens: number;
27
+ outputTokens: number;
28
+ };
29
+ stopReason: 'done' | 'stepLimit' | 'aborted' | 'budgetExceeded' | 'error';
30
+ error?: string;
31
+ }
32
+ export type SdkEvent = {
33
+ type: 'text';
34
+ delta: string;
35
+ } | {
36
+ type: 'thinking';
37
+ delta: string;
38
+ } | {
39
+ type: 'toolStart';
40
+ name: string;
41
+ target: string;
42
+ } | {
43
+ type: 'toolEnd';
44
+ name: string;
45
+ target: string;
46
+ output: string;
47
+ isError?: boolean;
48
+ } | {
49
+ type: 'usage';
50
+ inputTokens: number;
51
+ outputTokens: number;
52
+ } | {
53
+ type: 'error';
54
+ message: string;
55
+ } | {
56
+ type: 'result';
57
+ result: SdkResult;
58
+ };
59
+ export declare function streamTask(opts: SdkOptions): AsyncGenerator<SdkEvent>;
60
+ /** One-shot helper: runs the task and returns only the final result. */
61
+ export declare function runTask(opts: SdkOptions): Promise<SdkResult>;