@botconnector/bccli 0.4.0 → 0.4.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) 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-3PHBAI64.js} +2 -2
  5. package/dist/acp.d.ts +27 -0
  6. package/dist/agent.d.ts +143 -0
  7. package/dist/agents.d.ts +4 -0
  8. package/dist/{args-J5ONVGIF.js → args-W6BNKY7K.js} +3 -3
  9. package/dist/args.d.ts +51 -0
  10. package/dist/budget.d.ts +23 -0
  11. package/dist/checkpoints.d.ts +34 -0
  12. package/dist/{chunk-L7QI6JN2.js → chunk-24JN75FZ.js} +6 -6
  13. package/dist/{chunk-XBO5GACQ.js → chunk-75BECX4F.js} +3 -3
  14. package/dist/{chunk-QDQU6VY2.js → chunk-BC7UXFE4.js} +10 -1
  15. package/dist/{chunk-M7CALSP3.js → chunk-BGXNR74O.js} +1 -1
  16. package/dist/{chunk-6M5X2KZE.js → chunk-BKGFA2PT.js} +1 -1
  17. package/dist/{chunk-BNA74HPN.js → chunk-BXQQCUAC.js} +4 -4
  18. package/dist/{chunk-LACUWBWS.js → chunk-FLQPE4S5.js} +21 -9
  19. package/dist/{chunk-JL5ZCSP2.js → chunk-GN4W3T6E.js} +3 -3
  20. package/dist/{chunk-SPRNLS7K.js → chunk-JHPGOAXU.js} +1 -1
  21. package/dist/{chunk-7F3IWBPQ.js → chunk-MFHCQQEN.js} +18 -8
  22. package/dist/{chunk-O7M3TGIW.js → chunk-MHIYLXJC.js} +35 -0
  23. package/dist/{chunk-TVALKHFB.js → chunk-PZRKU4UM.js} +10 -10
  24. package/dist/{chunk-TLPFQIS2.js → chunk-R5RE46CW.js} +2 -2
  25. package/dist/{chunk-BQ2IGPBR.js → chunk-WI22M2ID.js} +1 -1
  26. package/dist/{chunk-PUN4HMAG.js → chunk-WNACAUDK.js} +9 -3
  27. package/dist/{chunk-KEMYIGCP.js → chunk-XV7ZVL4J.js} +2 -2
  28. package/dist/cli.d.ts +1 -0
  29. package/dist/cli.js +34 -35
  30. package/dist/clipboardImage.d.ts +17 -0
  31. package/dist/commands.d.ts +16 -0
  32. package/dist/completion.d.ts +14 -0
  33. package/dist/{config-COPNMMV6.js → config-DIDLDONU.js} +2 -2
  34. package/dist/{config-RZ5JONMX.js → config-IU76CPK2.js} +7 -3
  35. package/dist/config.d.ts +97 -0
  36. package/dist/context.d.ts +13 -0
  37. package/dist/contextWindow.d.ts +3 -0
  38. package/dist/diff.d.ts +7 -0
  39. package/dist/exit.d.ts +9 -0
  40. package/dist/extensions.d.ts +34 -0
  41. package/dist/{ghBotCli-IBCZIWT5.js → ghBotCli-E3VPHNZY.js} +12 -12
  42. package/dist/ghBotCli.d.ts +9 -0
  43. package/dist/ghBotDispatch.d.ts +68 -0
  44. package/dist/ghBotRunner.d.ts +82 -0
  45. package/dist/ghBotServe.d.ts +21 -0
  46. package/dist/ghBotWebhook.d.ts +45 -0
  47. package/dist/hooks.d.ts +27 -0
  48. package/dist/i18n/id.d.ts +1 -0
  49. package/dist/i18n.d.ts +16 -0
  50. package/dist/{integrationCli-P75R2VSC.js → integrationCli-Q2YPDTPG.js} +1 -1
  51. package/dist/integrationCli.d.ts +9 -0
  52. package/dist/keybinds.d.ts +22 -0
  53. package/dist/{login-SYIQP46J.js → login-FP3BB44A.js} +3 -3
  54. package/dist/login.d.ts +19 -0
  55. package/dist/lsp.d.ts +47 -0
  56. package/dist/mcp/catalog.d.ts +14 -0
  57. package/dist/mcp/config.d.ts +36 -0
  58. package/dist/mcp/manager.d.ts +34 -0
  59. package/dist/mcp/oauth.d.ts +82 -0
  60. package/dist/{mcpCli-QUV5SD64.js → mcpCli-SNBDUWJN.js} +5 -5
  61. package/dist/mcpCli.d.ts +3 -0
  62. package/dist/mcpServer/serve.d.ts +8 -0
  63. package/dist/mcpServer/server.d.ts +19 -0
  64. package/dist/models.d.ts +13 -0
  65. package/dist/{modelsCli-TRRB5LX4.js → modelsCli-CZ2HNGKR.js} +4 -4
  66. package/dist/modelsCli.d.ts +15 -0
  67. package/dist/npmRunner.d.ts +21 -0
  68. package/dist/oauthLogin.d.ts +47 -0
  69. package/dist/permissions.d.ts +30 -0
  70. package/dist/pluginSpec.d.ts +25 -0
  71. package/dist/plugins.d.ts +45 -0
  72. package/dist/{pluginsCli-GNW4TPVV.js → pluginsCli-LPIUUDWB.js} +1 -1
  73. package/dist/pluginsCli.d.ts +16 -0
  74. package/dist/prCli.d.ts +33 -0
  75. package/dist/presets.d.ts +8 -0
  76. package/dist/print.d.ts +14 -0
  77. package/dist/provider.d.ts +140 -0
  78. package/dist/{providerCli-FAOZHOKW.js → providerCli-NMUFXAAS.js} +5 -5
  79. package/dist/providerCli.d.ts +17 -0
  80. package/dist/providers.d.ts +6 -0
  81. package/dist/reasoning.d.ts +12 -0
  82. package/dist/repomap.d.ts +10 -0
  83. package/dist/sdk.d.ts +57 -0
  84. package/dist/sdk.js +99 -18
  85. package/dist/{serve-6QLBJUYW.js → serve-KWOECK5W.js} +1 -1
  86. package/dist/{serve-JG7RLIUD.js → serve-X2ZV4S5U.js} +20 -14
  87. package/dist/serve.d.ts +37 -0
  88. package/dist/serveHeartbeat.d.ts +14 -0
  89. package/dist/serveProtocol.d.ts +47 -0
  90. package/dist/{session-KBAQ4BZ5.js → session-GKEXDJKZ.js} +2 -2
  91. package/dist/session.d.ts +30 -0
  92. package/dist/setup-OV3NWQN5.js +24 -0
  93. package/dist/setup.d.ts +74 -0
  94. package/dist/slash/copy.d.ts +1 -0
  95. package/dist/slash/diff.d.ts +1 -0
  96. package/dist/slash/doctor.d.ts +18 -0
  97. package/dist/slash/export.d.ts +2 -0
  98. package/dist/slash/info.d.ts +45 -0
  99. package/dist/slash/memory.d.ts +10 -0
  100. package/dist/statsCli.d.ts +62 -0
  101. package/dist/textToolCalls.d.ts +6 -0
  102. package/dist/thinking.d.ts +17 -0
  103. package/dist/tokenBudget.d.ts +22 -0
  104. package/dist/tools/bash.d.ts +52 -0
  105. package/dist/tools/diagnostics.d.ts +5 -0
  106. package/dist/tools/edit.d.ts +7 -0
  107. package/dist/tools/fetch.d.ts +41 -0
  108. package/dist/tools/glob.d.ts +5 -0
  109. package/dist/tools/globSafety.d.ts +7 -0
  110. package/dist/tools/grep.d.ts +13 -0
  111. package/dist/tools/ignore.d.ts +2 -0
  112. package/dist/tools/index.d.ts +12 -0
  113. package/dist/tools/memory.d.ts +13 -0
  114. package/dist/tools/paths.d.ts +2 -0
  115. package/dist/tools/plan.d.ts +10 -0
  116. package/dist/tools/read.d.ts +16 -0
  117. package/dist/tools/repomap.d.ts +2 -0
  118. package/dist/tools/sandbox.d.ts +12 -0
  119. package/dist/tools/shell.d.ts +18 -0
  120. package/dist/tools/skill.d.ts +3 -0
  121. package/dist/tools/task.d.ts +28 -0
  122. package/dist/tools/todo.d.ts +13 -0
  123. package/dist/tools/types.d.ts +52 -0
  124. package/dist/tools/websearch.d.ts +9 -0
  125. package/dist/tools/write.d.ts +5 -0
  126. package/dist/{transferCli-TK2GSVRK.js → transferCli-YUFPI6AH.js} +3 -3
  127. package/dist/transferCli.d.ts +23 -0
  128. package/dist/ui/App.d.ts +7 -0
  129. package/dist/ui/DiffView.d.ts +3 -0
  130. package/dist/ui/EditableText.d.ts +7 -0
  131. package/dist/ui/LinePrompt.d.ts +6 -0
  132. package/dist/ui/ListPicker.d.ts +11 -0
  133. package/dist/ui/Markdown.d.ts +8 -0
  134. package/dist/ui/McpMenu.d.ts +11 -0
  135. package/dist/ui/ModelPicker.d.ts +6 -0
  136. package/dist/ui/PermissionPrompt.d.ts +5 -0
  137. package/dist/ui/PlanApproval.d.ts +5 -0
  138. package/dist/ui/PromptInput.d.ts +18 -0
  139. package/dist/ui/ProviderMenu.d.ts +10 -0
  140. package/dist/ui/Spinner.d.ts +4 -0
  141. package/dist/ui/StatusBar.d.ts +9 -0
  142. package/dist/ui/TodoList.d.ts +4 -0
  143. package/dist/ui/ToolBlock.d.ts +14 -0
  144. package/dist/ui/complete.d.ts +1 -0
  145. package/dist/ui/focusReport.d.ts +1 -0
  146. package/dist/ui/index.d.ts +7 -0
  147. package/dist/ui/lineEdit.d.ts +42 -0
  148. package/dist/ui/replay.d.ts +4 -0
  149. package/dist/ui/table.d.ts +20 -0
  150. package/dist/ui/theme.d.ts +5 -0
  151. package/dist/ui/thinkingMouse.d.ts +33 -0
  152. package/dist/ui/transcript.d.ts +55 -0
  153. package/dist/ui/vim.d.ts +26 -0
  154. package/dist/{ui-B3CJ6TGE.js → ui-IVIFNUCC.js} +13 -11
  155. package/dist/{update-K5IQ2MYR.js → update-TZ2G6KQ3.js} +1 -1
  156. package/dist/update.d.ts +30 -0
  157. package/dist/verify.d.ts +16 -0
  158. package/dist/version.d.ts +1 -0
  159. package/dist/webBudget.d.ts +25 -0
  160. package/dist/worktree.d.ts +12 -0
  161. package/package.json +26 -13
  162. package/dist/setup-FJAWDWV4.js +0 -24
@@ -2,20 +2,20 @@
2
2
  import {
3
3
  CATALOG,
4
4
  fillTemplate
5
- } from "./chunk-BQ2IGPBR.js";
5
+ } from "./chunk-WI22M2ID.js";
6
6
  import {
7
7
  authorizeMcpServer,
8
8
  clearTokens
9
- } from "./chunk-7F3IWBPQ.js";
9
+ } from "./chunk-MFHCQQEN.js";
10
10
  import {
11
11
  addGlobalServer,
12
12
  globalMcpPath,
13
13
  readMcpFile,
14
14
  removeGlobalServer
15
- } from "./chunk-L7QI6JN2.js";
15
+ } from "./chunk-24JN75FZ.js";
16
16
  import {
17
17
  bccliHome
18
- } from "./chunk-LACUWBWS.js";
18
+ } from "./chunk-FLQPE4S5.js";
19
19
  import {
20
20
  t
21
21
  } from "./chunk-UZWJQF67.js";
@@ -25,7 +25,7 @@ async function runMcpCommand(args, deps) {
25
25
  const home = bccliHome(deps.env);
26
26
  const [action = "list", name] = args.subArgs;
27
27
  if (action === "serve") {
28
- const { runMcpServe } = await import("./serve-6QLBJUYW.js");
28
+ const { runMcpServe } = await import("./serve-KWOECK5W.js");
29
29
  return runMcpServe(args, deps);
30
30
  }
31
31
  const installed = readMcpFile(globalMcpPath(home));
@@ -0,0 +1,3 @@
1
+ import type { CliArgs } from './args';
2
+ import type { CliDeps } from './providerCli';
3
+ export declare function runMcpCommand(args: CliArgs, deps: CliDeps): Promise<number>;
@@ -0,0 +1,8 @@
1
+ import type { Transport } from '@modelcontextprotocol/sdk/shared/transport.js';
2
+ import type { CliArgs } from '../args';
3
+ import type { CliDeps } from '../providerCli';
4
+ export interface McpServeDeps extends CliDeps {
5
+ /** Test seam: replaces the stdio transport (pass an InMemoryTransport half). */
6
+ transport?: Transport;
7
+ }
8
+ export declare function runMcpServe(args: CliArgs, deps: McpServeDeps): Promise<number>;
@@ -0,0 +1,19 @@
1
+ import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
+ import { type FetchToolOptions } from '../tools/fetch';
3
+ export interface McpServerDeps {
4
+ /** BotConnector API base, e.g. https://api.botconnector.id/v1 (no trailing slash). */
5
+ baseUrl: string;
6
+ /** Bearer key for paid endpoints (bc_chat); never logged or echoed. */
7
+ apiKey: string;
8
+ /** Default model id for bc_chat (provider prefix already stripped). */
9
+ defaultModel: string;
10
+ /** Injectable for tests; defaults to global fetch. */
11
+ fetchFn?: typeof fetch;
12
+ /** Injectable clock for the catalog cache; defaults to Date.now. */
13
+ now?: () => number;
14
+ /** Keenable endpoint for bc_search fallback; undefined = the public keyless endpoint. */
15
+ keenableURL?: string;
16
+ /** Passed to createFetchTool (DNS lookup / page fetch injection for tests). */
17
+ fetchTool?: FetchToolOptions;
18
+ }
19
+ export declare function createMcpServer(deps: McpServerDeps): McpServer;
@@ -0,0 +1,13 @@
1
+ import { type Config } from './config';
2
+ export interface ModelGroup {
3
+ providerId: string;
4
+ providerName: string;
5
+ models: string[];
6
+ error?: string;
7
+ }
8
+ export declare function listAllModels(config: Config, env?: NodeJS.ProcessEnv, opts?: {
9
+ fetch?: typeof fetch;
10
+ timeoutMs?: number;
11
+ only?: string;
12
+ keyOverride?: string;
13
+ }): Promise<ModelGroup[]>;
@@ -1,14 +1,14 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  listAllModels
4
- } from "./chunk-XBO5GACQ.js";
5
- import "./chunk-SPRNLS7K.js";
6
- import "./chunk-PUN4HMAG.js";
4
+ } from "./chunk-75BECX4F.js";
5
+ import "./chunk-JHPGOAXU.js";
6
+ import "./chunk-WNACAUDK.js";
7
7
  import "./chunk-BLOYFIAD.js";
8
8
  import {
9
9
  loadConfig,
10
10
  resolveModel
11
- } from "./chunk-LACUWBWS.js";
11
+ } from "./chunk-FLQPE4S5.js";
12
12
  import {
13
13
  t
14
14
  } from "./chunk-UZWJQF67.js";
@@ -0,0 +1,15 @@
1
+ import type { CliArgs } from './args';
2
+ export interface ModelsDeps {
3
+ env: NodeJS.ProcessEnv;
4
+ cwd: string;
5
+ out(line: string): void;
6
+ err(line: string): void;
7
+ fetch?: typeof fetch;
8
+ }
9
+ /**
10
+ * `bccli models [provider|provider/model]`.
11
+ * No argument keeps the old behavior: list the models of the active provider.
12
+ * A provider id (or a full model ref, whose provider part is used) lists exactly
13
+ * that provider, even when it is keyless or comes from the project config.
14
+ */
15
+ export declare function runModelsCommand(args: CliArgs, deps: ModelsDeps): Promise<number>;
@@ -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;
@@ -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,7 +2,7 @@
2
2
  import {
3
3
  bccliHome,
4
4
  globalConfigPath
5
- } from "./chunk-LACUWBWS.js";
5
+ } from "./chunk-FLQPE4S5.js";
6
6
  import {
7
7
  t
8
8
  } from "./chunk-UZWJQF67.js";
@@ -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>;
@@ -0,0 +1,33 @@
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
+ }
7
+ export interface PrDeps {
8
+ out(line: string): void;
9
+ err?(line: string): void;
10
+ /** gh argv runner (no shell). Defaults to `gh` on PATH. */
11
+ gh?(argv: string[]): Promise<{
12
+ code: number;
13
+ stdout: string;
14
+ stderr: string;
15
+ }>;
16
+ /** Run the agent task after checkout (injectable for tests). */
17
+ runTask?(opts: {
18
+ prompt?: string;
19
+ allowAll: boolean;
20
+ cwd: string;
21
+ }): Promise<number>;
22
+ }
23
+ /** argv for the child running the PR task; `--allow-all` only when the user asked for it. */
24
+ export declare function prTaskArgv(entry: string, opts: {
25
+ prompt?: string;
26
+ allowAll?: boolean;
27
+ }): string[];
28
+ /**
29
+ * `bccli pr <number> [--repo owner/name] [task]` — check out a GitHub PR
30
+ * with `gh pr checkout`, then run an optional task on the checked-out branch.
31
+ * Read-only: never pushes, merges, or comments.
32
+ */
33
+ 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,14 @@
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
+ export declare function runPrint(rt: Runtime, prompt: string, io?: {
8
+ out: Writer;
9
+ err: Writer;
10
+ }, opts?: {
11
+ allowAll?: boolean;
12
+ outputFormat?: OutputFormat;
13
+ }): Promise<number>;
14
+ export {};
@@ -0,0 +1,140 @@
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
+ export {};
@@ -2,12 +2,12 @@
2
2
  import {
3
3
  addProviderKey,
4
4
  runProviderCommand
5
- } from "./chunk-JL5ZCSP2.js";
6
- import "./chunk-XBO5GACQ.js";
7
- import "./chunk-SPRNLS7K.js";
8
- import "./chunk-PUN4HMAG.js";
5
+ } from "./chunk-GN4W3T6E.js";
6
+ import "./chunk-75BECX4F.js";
7
+ import "./chunk-JHPGOAXU.js";
8
+ import "./chunk-WNACAUDK.js";
9
9
  import "./chunk-BLOYFIAD.js";
10
- import "./chunk-LACUWBWS.js";
10
+ import "./chunk-FLQPE4S5.js";
11
11
  import "./chunk-UZWJQF67.js";
12
12
  export {
13
13
  addProviderKey,
@@ -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,57 @@
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';
30
+ }
31
+ export type SdkEvent = {
32
+ type: 'text';
33
+ delta: string;
34
+ } | {
35
+ type: 'thinking';
36
+ delta: string;
37
+ } | {
38
+ type: 'toolStart';
39
+ name: string;
40
+ target: string;
41
+ } | {
42
+ type: 'toolEnd';
43
+ name: string;
44
+ target: string;
45
+ output: string;
46
+ isError?: boolean;
47
+ } | {
48
+ type: 'usage';
49
+ inputTokens: number;
50
+ outputTokens: number;
51
+ } | {
52
+ type: 'result';
53
+ result: SdkResult;
54
+ };
55
+ export declare function streamTask(opts: SdkOptions): AsyncGenerator<SdkEvent>;
56
+ /** One-shot helper: runs the task and returns only the final result. */
57
+ export declare function runTask(opts: SdkOptions): Promise<SdkResult>;