@botconnector/bccli 0.5.0-rc.4 → 0.5.0
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.
- package/cli.mjs +14 -6
- package/legacy/LICENSE +21 -0
- package/legacy/README.en.md +253 -0
- package/legacy/README.md +250 -0
- package/legacy/dist/abort.d.ts +5 -0
- package/legacy/dist/acp-HWHF25KU.js +221 -0
- package/legacy/dist/acp.d.ts +44 -0
- package/legacy/dist/agent.d.ts +158 -0
- package/legacy/dist/agents.d.ts +4 -0
- package/legacy/dist/args-XA77XUMD.js +13 -0
- package/legacy/dist/args.d.ts +59 -0
- package/legacy/dist/budget.d.ts +26 -0
- package/legacy/dist/checkpoints.d.ts +35 -0
- package/legacy/dist/chunk-2IP5F3EK.js +56 -0
- package/legacy/dist/chunk-5CVHTYBQ.js +270 -0
- package/legacy/dist/chunk-6LO6YRDY.js +216 -0
- package/legacy/dist/chunk-6PJRWKVI.js +50 -0
- package/legacy/dist/chunk-7OTFZK4B.js +159 -0
- package/legacy/dist/chunk-7U7CMKKI.js +861 -0
- package/legacy/dist/chunk-A3NBWIEQ.js +2706 -0
- package/legacy/dist/chunk-FY543EQW.js +50 -0
- package/legacy/dist/chunk-IDZLHEVL.js +524 -0
- package/legacy/dist/chunk-IF5RNXBI.js +341 -0
- package/legacy/dist/chunk-M5T4AM4I.js +256 -0
- package/legacy/dist/chunk-NGFWBVHD.js +71 -0
- package/legacy/dist/chunk-OCEQ2TRJ.js +1075 -0
- package/legacy/dist/chunk-OK2USAXX.js +88 -0
- package/legacy/dist/chunk-PSO7R5AD.js +10 -0
- package/legacy/dist/chunk-RLSQAZBT.js +78 -0
- package/legacy/dist/chunk-VPFCIUC6.js +91 -0
- package/legacy/dist/chunk-XP5MTJN2.js +8 -0
- package/legacy/dist/chunk-YGBTNDPK.js +202 -0
- package/legacy/dist/chunk-YYTFJUO2.js +148 -0
- package/legacy/dist/chunk-ZXWRLN7E.js +378 -0
- package/legacy/dist/cli.d.ts +1 -0
- package/legacy/dist/cli.js +233 -0
- package/legacy/dist/clipboardImage.d.ts +17 -0
- package/legacy/dist/commands.d.ts +16 -0
- package/legacy/dist/completion-IRVEVW6H.js +125 -0
- package/legacy/dist/completion.d.ts +14 -0
- package/legacy/dist/config-OVWCUVY7.js +25 -0
- package/legacy/dist/config-S3CZUIBB.js +34 -0
- package/legacy/dist/config.d.ts +99 -0
- package/legacy/dist/context.d.ts +13 -0
- package/legacy/dist/contextWindow.d.ts +3 -0
- package/legacy/dist/diff.d.ts +7 -0
- package/legacy/dist/exit.d.ts +9 -0
- package/legacy/dist/extensions.d.ts +34 -0
- package/legacy/dist/ghBotCli-FYKJDJOD.js +680 -0
- package/legacy/dist/ghBotCli.d.ts +9 -0
- package/legacy/dist/ghBotDispatch.d.ts +68 -0
- package/legacy/dist/ghBotRunner.d.ts +82 -0
- package/legacy/dist/ghBotServe.d.ts +21 -0
- package/legacy/dist/ghBotWebhook.d.ts +45 -0
- package/legacy/dist/hooks.d.ts +27 -0
- package/legacy/dist/i18n/id.d.ts +1 -0
- package/legacy/dist/i18n.d.ts +16 -0
- package/legacy/dist/integrationCli-GY73S2K7.js +876 -0
- package/legacy/dist/integrationCli.d.ts +9 -0
- package/legacy/dist/keybinds.d.ts +22 -0
- package/legacy/dist/login-KSN63EM4.js +18 -0
- package/legacy/dist/login.d.ts +21 -0
- package/legacy/dist/lsp.d.ts +73 -0
- package/legacy/dist/mcp/catalog.d.ts +14 -0
- package/legacy/dist/mcp/config.d.ts +36 -0
- package/legacy/dist/mcp/manager.d.ts +52 -0
- package/legacy/dist/mcp/oauth.d.ts +82 -0
- package/legacy/dist/mcpCli-VWSCCDWT.js +113 -0
- package/legacy/dist/mcpCli.d.ts +3 -0
- package/legacy/dist/mcpServer/serve.d.ts +8 -0
- package/legacy/dist/mcpServer/server.d.ts +19 -0
- package/legacy/dist/models.d.ts +13 -0
- package/legacy/dist/modelsCli-4Q6KFWV2.js +36 -0
- package/legacy/dist/modelsCli.d.ts +15 -0
- package/legacy/dist/npmRunner-LU43GM3W.js +46 -0
- package/legacy/dist/npmRunner.d.ts +21 -0
- package/legacy/dist/oauthLogin-JWXQZTMZ.js +210 -0
- package/legacy/dist/oauthLogin.d.ts +47 -0
- package/legacy/dist/permissions.d.ts +30 -0
- package/legacy/dist/pluginSpec.d.ts +25 -0
- package/legacy/dist/plugins.d.ts +45 -0
- package/legacy/dist/pluginsCli-7XWDLJEL.js +288 -0
- package/legacy/dist/pluginsCli.d.ts +16 -0
- package/legacy/dist/prCli-FH7N26D4.js +94 -0
- package/legacy/dist/prCli.d.ts +46 -0
- package/legacy/dist/presets.d.ts +8 -0
- package/legacy/dist/print.d.ts +17 -0
- package/legacy/dist/provider.d.ts +145 -0
- package/legacy/dist/providerCli-YMG4G56R.js +15 -0
- package/legacy/dist/providerCli.d.ts +17 -0
- package/legacy/dist/providers.d.ts +6 -0
- package/legacy/dist/reasoning.d.ts +12 -0
- package/legacy/dist/repomap.d.ts +10 -0
- package/legacy/dist/sdk.d.ts +61 -0
- package/legacy/dist/sdk.js +6532 -0
- package/legacy/dist/serve-HSFF6MGB.js +178 -0
- package/legacy/dist/serve-HUQNVOSP.js +532 -0
- package/legacy/dist/serve.d.ts +37 -0
- package/legacy/dist/serveHeartbeat.d.ts +14 -0
- package/legacy/dist/serveProtocol.d.ts +47 -0
- package/legacy/dist/session-YM36TGU7.js +12 -0
- package/legacy/dist/session.d.ts +33 -0
- package/legacy/dist/setup-3YB6EKYX.js +24 -0
- package/legacy/dist/setup.d.ts +79 -0
- package/legacy/dist/slash/copy.d.ts +1 -0
- package/legacy/dist/slash/diff.d.ts +1 -0
- package/legacy/dist/slash/doctor.d.ts +18 -0
- package/legacy/dist/slash/export.d.ts +2 -0
- package/legacy/dist/slash/info.d.ts +46 -0
- package/legacy/dist/slash/memory.d.ts +10 -0
- package/legacy/dist/statsCli-I4TSDU3X.js +353 -0
- package/legacy/dist/statsCli.d.ts +62 -0
- package/legacy/dist/textToolCalls.d.ts +6 -0
- package/legacy/dist/thinking.d.ts +17 -0
- package/legacy/dist/tokenBudget.d.ts +22 -0
- package/legacy/dist/tools/bash.d.ts +54 -0
- package/legacy/dist/tools/diagnostics.d.ts +13 -0
- package/legacy/dist/tools/edit.d.ts +12 -0
- package/legacy/dist/tools/fetch.d.ts +41 -0
- package/legacy/dist/tools/glob.d.ts +5 -0
- package/legacy/dist/tools/globSafety.d.ts +7 -0
- package/legacy/dist/tools/grep.d.ts +25 -0
- package/legacy/dist/tools/ignore.d.ts +2 -0
- package/legacy/dist/tools/index.d.ts +12 -0
- package/legacy/dist/tools/memory.d.ts +13 -0
- package/legacy/dist/tools/paths.d.ts +4 -0
- package/legacy/dist/tools/plan.d.ts +10 -0
- package/legacy/dist/tools/read.d.ts +16 -0
- package/legacy/dist/tools/repomap.d.ts +2 -0
- package/legacy/dist/tools/sandbox.d.ts +15 -0
- package/legacy/dist/tools/shell.d.ts +18 -0
- package/legacy/dist/tools/skill.d.ts +3 -0
- package/legacy/dist/tools/task.d.ts +28 -0
- package/legacy/dist/tools/todo.d.ts +13 -0
- package/legacy/dist/tools/types.d.ts +52 -0
- package/legacy/dist/tools/websearch.d.ts +9 -0
- package/legacy/dist/tools/write.d.ts +5 -0
- package/legacy/dist/transferCli-3B4LMOYI.js +73 -0
- package/legacy/dist/transferCli.d.ts +23 -0
- package/legacy/dist/ui/App.d.ts +7 -0
- package/legacy/dist/ui/DiffView.d.ts +3 -0
- package/legacy/dist/ui/EditableText.d.ts +7 -0
- package/legacy/dist/ui/LinePrompt.d.ts +6 -0
- package/legacy/dist/ui/ListPicker.d.ts +11 -0
- package/legacy/dist/ui/Markdown.d.ts +8 -0
- package/legacy/dist/ui/McpMenu.d.ts +11 -0
- package/legacy/dist/ui/ModelPicker.d.ts +6 -0
- package/legacy/dist/ui/PermissionPrompt.d.ts +5 -0
- package/legacy/dist/ui/PlanApproval.d.ts +5 -0
- package/legacy/dist/ui/PromptInput.d.ts +20 -0
- package/legacy/dist/ui/ProviderMenu.d.ts +10 -0
- package/legacy/dist/ui/Spinner.d.ts +4 -0
- package/legacy/dist/ui/StatusBar.d.ts +14 -0
- package/legacy/dist/ui/TodoList.d.ts +4 -0
- package/legacy/dist/ui/ToolBlock.d.ts +14 -0
- package/legacy/dist/ui/complete.d.ts +8 -0
- package/legacy/dist/ui/index.d.ts +7 -0
- package/legacy/dist/ui/lineEdit.d.ts +42 -0
- package/legacy/dist/ui/liveCap.d.ts +29 -0
- package/legacy/dist/ui/markdownLayout.d.ts +23 -0
- package/legacy/dist/ui/replay.d.ts +4 -0
- package/legacy/dist/ui/stdinFilter.d.ts +18 -0
- package/legacy/dist/ui/table.d.ts +20 -0
- package/legacy/dist/ui/theme.d.ts +5 -0
- package/legacy/dist/ui/thinkingMouse.d.ts +38 -0
- package/legacy/dist/ui/transcript.d.ts +55 -0
- package/legacy/dist/ui/tty.d.ts +11 -0
- package/legacy/dist/ui/vim.d.ts +26 -0
- package/legacy/dist/ui-TAZMRXRI.js +3044 -0
- package/legacy/dist/update-5V425FIK.js +145 -0
- package/legacy/dist/update.d.ts +30 -0
- package/legacy/dist/verify.d.ts +16 -0
- package/legacy/dist/version.d.ts +1 -0
- package/legacy/dist/webBudget.d.ts +25 -0
- package/legacy/dist/worktree.d.ts +12 -0
- package/legacy/package.json +77 -0
- package/legacy-compat.mjs +42 -0
- package/package.json +24 -4
- package/provider-cli.mjs +1 -2
- package/providers.mjs +19 -6
- package/startup-menu.mjs +14 -13
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
t
|
|
4
|
+
} from "./chunk-IDZLHEVL.js";
|
|
5
|
+
|
|
6
|
+
// src/prCli.ts
|
|
7
|
+
import { spawn } from "child_process";
|
|
8
|
+
function defaultGh(argv) {
|
|
9
|
+
return new Promise((resolve) => {
|
|
10
|
+
const child = spawn("gh", argv, { shell: false, stdio: ["ignore", "pipe", "pipe"] });
|
|
11
|
+
let stdout = "";
|
|
12
|
+
let stderr = "";
|
|
13
|
+
child.stdout?.on("data", (d) => {
|
|
14
|
+
stdout += d;
|
|
15
|
+
});
|
|
16
|
+
child.stderr?.on("data", (d) => {
|
|
17
|
+
stderr += d;
|
|
18
|
+
});
|
|
19
|
+
child.on("error", (e) => resolve({ code: 127, stdout, stderr: String(e) }));
|
|
20
|
+
child.on("close", (code) => resolve({ code: code ?? 1, stdout, stderr }));
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
function prTaskArgv(entry, opts) {
|
|
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
|
+
];
|
|
33
|
+
}
|
|
34
|
+
async function defaultRunTask(opts) {
|
|
35
|
+
const entry = process.argv[1];
|
|
36
|
+
if (!entry) return 1;
|
|
37
|
+
return new Promise((resolve) => {
|
|
38
|
+
const child = spawn(process.execPath, prTaskArgv(entry, opts), {
|
|
39
|
+
shell: false,
|
|
40
|
+
stdio: "inherit",
|
|
41
|
+
cwd: opts.cwd
|
|
42
|
+
});
|
|
43
|
+
child.on("error", () => resolve(1));
|
|
44
|
+
child.on("close", (code) => resolve(code ?? 1));
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function runPrCommand(args, deps) {
|
|
48
|
+
const rest = [...args.subArgs];
|
|
49
|
+
let repo = args.repo;
|
|
50
|
+
const words = [];
|
|
51
|
+
for (let i = 0; i < rest.length; i++) {
|
|
52
|
+
if (rest[i] === "--repo") {
|
|
53
|
+
repo = rest[++i];
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
words.push(rest[i]);
|
|
57
|
+
}
|
|
58
|
+
const number = words.shift();
|
|
59
|
+
if (!number || !/^\d+$/.test(number)) {
|
|
60
|
+
deps.err?.(t("usage: bccli pr <number> [--repo owner/name] [task]"));
|
|
61
|
+
return 1;
|
|
62
|
+
}
|
|
63
|
+
const task = words.length ? words.join(" ") : void 0;
|
|
64
|
+
const gh = deps.gh ?? defaultGh;
|
|
65
|
+
const checkoutArgv = ["pr", "checkout", number, ...repo ? ["--repo", repo] : []];
|
|
66
|
+
let res;
|
|
67
|
+
try {
|
|
68
|
+
res = await gh(checkoutArgv);
|
|
69
|
+
} catch (e) {
|
|
70
|
+
deps.err?.(t("gh is not available ({error}); install GitHub CLI first", { error: String(e) }));
|
|
71
|
+
return 1;
|
|
72
|
+
}
|
|
73
|
+
if (res.code !== 0) {
|
|
74
|
+
deps.err?.(t("gh pr checkout {n} failed (exit {code})", { n: number, code: String(res.code) }));
|
|
75
|
+
return 1;
|
|
76
|
+
}
|
|
77
|
+
deps.out(t("checked out PR #{n}", { n: number }));
|
|
78
|
+
const runTask = deps.runTask ?? defaultRunTask;
|
|
79
|
+
const allowAll = args.allowAll === true;
|
|
80
|
+
if (allowAll) deps.err?.(t("--allow-all: the PR task runs every tool without asking"));
|
|
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
|
+
});
|
|
90
|
+
}
|
|
91
|
+
export {
|
|
92
|
+
prTaskArgv,
|
|
93
|
+
runPrCommand
|
|
94
|
+
};
|
|
@@ -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,17 @@
|
|
|
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
|
+
failOnToolError?: boolean;
|
|
16
|
+
}): Promise<number>;
|
|
17
|
+
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-RLSQAZBT.js";
|
|
6
|
+
import "./chunk-2IP5F3EK.js";
|
|
7
|
+
import "./chunk-FY543EQW.js";
|
|
8
|
+
import "./chunk-OCEQ2TRJ.js";
|
|
9
|
+
import "./chunk-NGFWBVHD.js";
|
|
10
|
+
import "./chunk-ZXWRLN7E.js";
|
|
11
|
+
import "./chunk-IDZLHEVL.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;
|
|
@@ -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>;
|