@botconnector/bccli 0.4.0-beta.40 → 0.4.0-beta.42
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/dist/{acp-5A7EXLCG.js → acp-PP7ZONVQ.js} +2 -2
- package/dist/{args-4SMOHFN5.js → args-3DGIMRTG.js} +4 -4
- package/dist/{chunk-ISCT3PN3.js → chunk-3P5N6UPF.js} +2 -2
- package/dist/{chunk-3HCOAJEQ.js → chunk-7F3IWBPQ.js} +1 -0
- package/dist/{chunk-JROUQ5YS.js → chunk-A2XKKKKU.js} +4 -4
- package/dist/{chunk-AS7VV7D3.js → chunk-ADS5FDWL.js} +12 -6
- package/dist/{chunk-M7LLJQ7M.js → chunk-AGIZBZ64.js} +64 -24
- package/dist/{chunk-NI5JZUZ3.js → chunk-AWNQDAOY.js} +1 -1
- package/dist/{chunk-ZMU7MXCH.js → chunk-DRK3XTVZ.js} +78 -19
- package/dist/{chunk-WH7XLDGZ.js → chunk-HQB227LD.js} +23 -21
- package/dist/{chunk-VM7HYAJS.js → chunk-HVGXCPDG.js} +1 -1
- package/dist/{chunk-SESBH44L.js → chunk-I422TPGX.js} +1 -1
- package/dist/chunk-I4THUZRD.js +145 -0
- package/dist/{chunk-LN32JIZR.js → chunk-LYFN6AEV.js} +4 -4
- package/dist/{chunk-GGNXHJL6.js → chunk-LYQHLA43.js} +2 -2
- package/dist/{chunk-AVB6M4JE.js → chunk-NFJPKNHL.js} +2 -2
- package/dist/{chunk-RV74TCEP.js → chunk-O74EQFYI.js} +3 -3
- package/dist/{chunk-PDVS4UWM.js → chunk-Q2ZBR4OU.js} +1 -1
- package/dist/{chunk-HE33XAPZ.js → chunk-QZM66F3A.js} +1 -1
- package/dist/{chunk-M23QBX3V.js → chunk-VBEX5YHF.js} +58 -2
- package/dist/cli.js +57 -37
- package/dist/{config-C4KLLDC6.js → config-LFT2FNSE.js} +3 -3
- package/dist/config-UKEKWMCG.js +30 -0
- package/dist/ghBotCli-DWQXAIKE.js +676 -0
- package/dist/{integrationCli-HR7CDUSI.js → integrationCli-RSJCJ3NW.js} +2 -2
- package/dist/login-L3SUO4H4.js +16 -0
- package/dist/{mcpCli-5QTXH7XJ.js → mcpCli-RSLEDQQ7.js} +6 -6
- package/dist/{modelsCli-DKTT3UZD.js → modelsCli-IKZLORLH.js} +6 -6
- package/dist/npmRunner-LU43GM3W.js +46 -0
- package/dist/oauthLogin-XHEMYL6L.js +210 -0
- package/dist/pluginsCli-MRS547WG.js +284 -0
- package/dist/providerCli-7GRUL3BS.js +15 -0
- package/dist/sdk.js +174 -51
- package/dist/{serve-I2VQUTHR.js → serve-A4E67R5E.js} +3 -3
- package/dist/{serve-JNQUP7CZ.js → serve-GFNJ5PSL.js} +18 -18
- package/dist/session-VKVBMGCC.js +12 -0
- package/dist/setup-XWX64X5Q.js +23 -0
- package/dist/{ui-GVIMUZNS.js → ui-STI6HSOR.js} +13 -13
- package/dist/{update-SZUG3YSB.js → update-KMWE2P2I.js} +2 -2
- package/package.json +1 -1
- package/dist/chunk-DSFHN5CH.js +0 -52
- package/dist/login-T5S6SPZA.js +0 -9
- package/dist/providerCli-DDH4ZZUY.js +0 -15
- package/dist/session-H2YL5RSB.js +0 -12
- package/dist/setup-I7UY7X7C.js +0 -23
|
@@ -97,8 +97,8 @@ function runAcp(input, output, opts) {
|
|
|
97
97
|
function runtimeAgent(cwd) {
|
|
98
98
|
return {
|
|
99
99
|
async run(text, onChunk, signal) {
|
|
100
|
-
const { parseCliArgs } = await import("./args-
|
|
101
|
-
const { createRuntime } = await import("./setup-
|
|
100
|
+
const { parseCliArgs } = await import("./args-3DGIMRTG.js");
|
|
101
|
+
const { createRuntime } = await import("./setup-XWX64X5Q.js");
|
|
102
102
|
const rt = createRuntime({ cwd, args: { ...parseCliArgs([]), allowAll: true } });
|
|
103
103
|
rt.agent.onEvent = (event) => {
|
|
104
104
|
if (event.type === "text") onChunk(event.delta);
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
import {
|
|
3
3
|
helpText,
|
|
4
4
|
parseCliArgs
|
|
5
|
-
} from "./chunk-
|
|
5
|
+
} from "./chunk-ADS5FDWL.js";
|
|
6
6
|
import "./chunk-GAFJEQTJ.js";
|
|
7
|
-
import "./chunk-
|
|
8
|
-
import "./chunk-
|
|
9
|
-
import "./chunk-
|
|
7
|
+
import "./chunk-AWNQDAOY.js";
|
|
8
|
+
import "./chunk-AGIZBZ64.js";
|
|
9
|
+
import "./chunk-VBEX5YHF.js";
|
|
10
10
|
export {
|
|
11
11
|
helpText,
|
|
12
12
|
parseCliArgs
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
listAllModels
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-LYFN6AEV.js";
|
|
5
5
|
import {
|
|
6
6
|
hasKey,
|
|
7
7
|
providerName,
|
|
8
8
|
removeGlobalProvider,
|
|
9
9
|
writeGlobalConfig
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-I422TPGX.js";
|
|
11
11
|
import {
|
|
12
12
|
PRESETS,
|
|
13
13
|
loadConfig,
|
|
14
14
|
saveCredential
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-AGIZBZ64.js";
|
|
16
16
|
import {
|
|
17
17
|
t
|
|
18
|
-
} from "./chunk-
|
|
18
|
+
} from "./chunk-VBEX5YHF.js";
|
|
19
19
|
|
|
20
20
|
// src/providerCli.ts
|
|
21
21
|
async function addProviderKey(providerId, key, deps) {
|
|
@@ -5,14 +5,14 @@ import {
|
|
|
5
5
|
import {
|
|
6
6
|
REASONING_LEVELS,
|
|
7
7
|
isReasoningLevel
|
|
8
|
-
} from "./chunk-
|
|
8
|
+
} from "./chunk-AWNQDAOY.js";
|
|
9
9
|
import {
|
|
10
10
|
ConfigError
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-AGIZBZ64.js";
|
|
12
12
|
import {
|
|
13
13
|
parseLang,
|
|
14
14
|
t
|
|
15
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-VBEX5YHF.js";
|
|
16
16
|
|
|
17
17
|
// src/args.ts
|
|
18
18
|
import { parseArgs } from "util";
|
|
@@ -77,11 +77,13 @@ var HELP = `BCCLI \u2014 BotConnector's AI coding agent for the terminal
|
|
|
77
77
|
Usage:
|
|
78
78
|
bccli [task] interactive mode (optionally start with a task)
|
|
79
79
|
bccli -p "task" run one task without interaction (scripts/CI)
|
|
80
|
-
bccli login [provider]
|
|
80
|
+
bccli login [provider] OAuth login (or --key paste API key, --logout remove)
|
|
81
81
|
bccli models [provider] list models (default: the active provider)
|
|
82
82
|
bccli update install the newest bccli from npm
|
|
83
83
|
bccli acp run as an ACP agent for editors (Zed, ...)
|
|
84
84
|
bccli serve [--port N] serve sessions over HTTP+WS for IDEs/bots
|
|
85
|
+
bccli plugins list, install, remove, or update plugins
|
|
86
|
+
bccli gh-bot [serve] GitHub comment bot (off-by-default; needs config)
|
|
85
87
|
bccli provider list|add <id>|remove <id> manage providers (custom: --url <url> [--name N] [--key-env ENV])
|
|
86
88
|
bccli mcp list|add <name>|remove <name>|auth <name>|logout <name>|serve [--base-url <url>] manage MCP servers, or serve this account's tools over stdio
|
|
87
89
|
bccli integrations show the status of external agent integrations
|
|
@@ -124,6 +126,8 @@ function parseCliArgs(argv) {
|
|
|
124
126
|
name: { type: "string" },
|
|
125
127
|
"key-env": { type: "string" },
|
|
126
128
|
value: { type: "string", multiple: true },
|
|
129
|
+
key: { type: "boolean" },
|
|
130
|
+
logout: { type: "boolean" },
|
|
127
131
|
port: { type: "string" },
|
|
128
132
|
host: { type: "string" },
|
|
129
133
|
token: { type: "string" },
|
|
@@ -144,7 +148,7 @@ function parseCliArgs(argv) {
|
|
|
144
148
|
throw new ConfigError(t("--output-format must be one of: {formats}", { formats: "text, json, stream-json" }));
|
|
145
149
|
}
|
|
146
150
|
const [first, ...rest] = positionals;
|
|
147
|
-
const SUBCOMMANDS = ["login", "models", "update", "acp", "serve", "provider", "mcp", "connect", "disconnect", "integrations"];
|
|
151
|
+
const SUBCOMMANDS = ["login", "models", "update", "acp", "serve", "plugins", "gh-bot", "provider", "mcp", "connect", "disconnect", "integrations"];
|
|
148
152
|
const command = SUBCOMMANDS.includes(first) ? first : "run";
|
|
149
153
|
const words = command === "run" ? positionals : rest;
|
|
150
154
|
const port = values.port !== void 0 ? Number(values.port) : void 0;
|
|
@@ -171,7 +175,9 @@ function parseCliArgs(argv) {
|
|
|
171
175
|
help: !!values.help,
|
|
172
176
|
version: !!values.version,
|
|
173
177
|
loginProvider: command === "login" ? rest[0] ?? "bc-cloud" : void 0,
|
|
174
|
-
|
|
178
|
+
key: !!values.key,
|
|
179
|
+
logout: !!values.logout,
|
|
180
|
+
subArgs: ["models", "plugins", "gh-bot", "provider", "mcp", "connect", "disconnect", "integrations"].includes(command) ? rest : [],
|
|
175
181
|
url: values.url,
|
|
176
182
|
name: values.name,
|
|
177
183
|
keyEnv: values["key-env"],
|
|
@@ -1,7 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import {
|
|
3
3
|
t
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-VBEX5YHF.js";
|
|
5
|
+
|
|
6
|
+
// src/config.ts
|
|
7
|
+
import { chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, writeFileSync } from "fs";
|
|
8
|
+
import { homedir } from "os";
|
|
9
|
+
import { dirname, join } from "path";
|
|
5
10
|
|
|
6
11
|
// src/presets.ts
|
|
7
12
|
var PRESETS = [
|
|
@@ -16,29 +21,6 @@ var PRESETS = [
|
|
|
16
21
|
{ id: "lmstudio", name: "LM Studio lokal", baseURL: "http://127.0.0.1:1234/v1", local: true }
|
|
17
22
|
];
|
|
18
23
|
|
|
19
|
-
// src/ui/theme.ts
|
|
20
|
-
var THEMES = ["default", "blue", "amber", "magenta", "mono"];
|
|
21
|
-
var REMAP = {
|
|
22
|
-
blue: { green: "blue" },
|
|
23
|
-
amber: { green: "yellow" },
|
|
24
|
-
magenta: { green: "magenta" }
|
|
25
|
-
};
|
|
26
|
-
var theme = "default";
|
|
27
|
-
function setTheme(name) {
|
|
28
|
-
theme = name;
|
|
29
|
-
}
|
|
30
|
-
function color(name) {
|
|
31
|
-
if (process.env.NO_COLOR) return void 0;
|
|
32
|
-
if (theme === "mono") return void 0;
|
|
33
|
-
return REMAP[theme]?.[name] ?? name;
|
|
34
|
-
}
|
|
35
|
-
var ACCENT = "green";
|
|
36
|
-
|
|
37
|
-
// src/config.ts
|
|
38
|
-
import { chmodSync, existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
39
|
-
import { homedir } from "os";
|
|
40
|
-
import { join } from "path";
|
|
41
|
-
|
|
42
24
|
// src/keybinds.ts
|
|
43
25
|
var KEYBIND_ACTIONS = ["thinking", "toolOutput", "pasteImage"];
|
|
44
26
|
var DEFAULT_KEYBINDS = {
|
|
@@ -62,6 +44,24 @@ function matchKeybind(kb, input, key) {
|
|
|
62
44
|
return kb.ctrl === !!key.ctrl && kb.meta === !!key.meta && input.toLowerCase() === kb.key;
|
|
63
45
|
}
|
|
64
46
|
|
|
47
|
+
// src/ui/theme.ts
|
|
48
|
+
var THEMES = ["default", "blue", "amber", "magenta", "mono"];
|
|
49
|
+
var REMAP = {
|
|
50
|
+
blue: { green: "blue" },
|
|
51
|
+
amber: { green: "yellow" },
|
|
52
|
+
magenta: { green: "magenta" }
|
|
53
|
+
};
|
|
54
|
+
var theme = "default";
|
|
55
|
+
function setTheme(name) {
|
|
56
|
+
theme = name;
|
|
57
|
+
}
|
|
58
|
+
function color(name) {
|
|
59
|
+
if (process.env.NO_COLOR) return void 0;
|
|
60
|
+
if (theme === "mono") return void 0;
|
|
61
|
+
return REMAP[theme]?.[name] ?? name;
|
|
62
|
+
}
|
|
63
|
+
var ACCENT = "green";
|
|
64
|
+
|
|
65
65
|
// src/config.ts
|
|
66
66
|
var ConfigError = class extends Error {
|
|
67
67
|
};
|
|
@@ -251,6 +251,42 @@ function loadConfig(cwd, env = process.env) {
|
|
|
251
251
|
allow: [...global.allow ?? []]
|
|
252
252
|
};
|
|
253
253
|
}
|
|
254
|
+
function globalConfigPath(env = process.env) {
|
|
255
|
+
return join(bccliHome(env), "config.json");
|
|
256
|
+
}
|
|
257
|
+
function readGlobalPlugins(env = process.env) {
|
|
258
|
+
const raw = readJsonConfig(globalConfigPath(env));
|
|
259
|
+
const value = raw.plugins;
|
|
260
|
+
if (value === void 0) return [];
|
|
261
|
+
if (!Array.isArray(value) || value.some((entry) => typeof entry !== "string")) {
|
|
262
|
+
throw new ConfigError(t("plugins must be an array of strings."));
|
|
263
|
+
}
|
|
264
|
+
return value;
|
|
265
|
+
}
|
|
266
|
+
function writeFileAtomic(path, data) {
|
|
267
|
+
const tmp = `${path}.tmp-${process.pid}-${Date.now()}`;
|
|
268
|
+
try {
|
|
269
|
+
writeFileSync(tmp, data);
|
|
270
|
+
renameSync(tmp, path);
|
|
271
|
+
} catch (error) {
|
|
272
|
+
try {
|
|
273
|
+
rmSync(tmp, { force: true });
|
|
274
|
+
} catch {
|
|
275
|
+
}
|
|
276
|
+
throw error;
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
function updateGlobalConfig(env, mutate) {
|
|
280
|
+
const path = globalConfigPath(env);
|
|
281
|
+
let cfg = {};
|
|
282
|
+
if (existsSync(path)) {
|
|
283
|
+
cfg = JSON.parse(readFileSync(path, "utf8"));
|
|
284
|
+
}
|
|
285
|
+
mutate(cfg);
|
|
286
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
287
|
+
writeFileAtomic(path, `${JSON.stringify(cfg, null, 2)}
|
|
288
|
+
`);
|
|
289
|
+
}
|
|
254
290
|
function readCredentials(env = process.env) {
|
|
255
291
|
const path = join(bccliHome(env), "credentials");
|
|
256
292
|
if (!existsSync(path)) return {};
|
|
@@ -300,9 +336,13 @@ export {
|
|
|
300
336
|
color,
|
|
301
337
|
ACCENT,
|
|
302
338
|
ConfigError,
|
|
339
|
+
DEFAULT_MAX_STEPS,
|
|
303
340
|
bccliHome,
|
|
304
341
|
readJsonConfig,
|
|
305
342
|
loadConfig,
|
|
343
|
+
globalConfigPath,
|
|
344
|
+
readGlobalPlugins,
|
|
345
|
+
updateGlobalConfig,
|
|
306
346
|
readCredentials,
|
|
307
347
|
saveCredential,
|
|
308
348
|
resolveModel,
|
|
@@ -4,10 +4,11 @@ import {
|
|
|
4
4
|
} from "./chunk-PSO7R5AD.js";
|
|
5
5
|
import {
|
|
6
6
|
t
|
|
7
|
-
} from "./chunk-
|
|
7
|
+
} from "./chunk-VBEX5YHF.js";
|
|
8
8
|
|
|
9
9
|
// src/tools/bash.ts
|
|
10
10
|
import { spawn } from "child_process";
|
|
11
|
+
import { existsSync as existsSync2 } from "fs";
|
|
11
12
|
import { z } from "zod";
|
|
12
13
|
|
|
13
14
|
// src/tools/sandbox.ts
|
|
@@ -57,6 +58,40 @@ function sandboxArgv(command, opts) {
|
|
|
57
58
|
return void 0;
|
|
58
59
|
}
|
|
59
60
|
|
|
61
|
+
// src/tools/shell.ts
|
|
62
|
+
import { existsSync } from "fs";
|
|
63
|
+
import { win32 } from "path";
|
|
64
|
+
var PS_PRELUDE = "[Console]::OutputEncoding=[Text.Encoding]::UTF8; $OutputEncoding=[Text.Encoding]::UTF8; ";
|
|
65
|
+
var PS_EPILOGUE = "\nif ($LASTEXITCODE -ne $null) { exit $LASTEXITCODE } elseif (-not $?) { exit 1 }";
|
|
66
|
+
function gitBashCandidates(env) {
|
|
67
|
+
const roots = [env.ProgramW6432, env.ProgramFiles, env["ProgramFiles(x86)"], env.LOCALAPPDATA && win32.join(env.LOCALAPPDATA, "Programs")];
|
|
68
|
+
const fromRoots = roots.filter((root) => !!root).map((root) => win32.join(root, "Git", "bin", "bash.exe"));
|
|
69
|
+
const fromPath = (env.PATH ?? env.Path ?? "").split(";").filter(Boolean).map((dir) => win32.join(dir, "..", "bin", "bash.exe"));
|
|
70
|
+
return [...fromRoots, ...fromPath];
|
|
71
|
+
}
|
|
72
|
+
function resolveShell(deps) {
|
|
73
|
+
if (deps.platform !== "win32") return void 0;
|
|
74
|
+
const bash = gitBashCandidates(deps.env).find((candidate) => deps.exists(candidate));
|
|
75
|
+
if (bash) return { name: "bash", file: bash, args: (command) => ["-c", command] };
|
|
76
|
+
return {
|
|
77
|
+
name: "powershell",
|
|
78
|
+
file: "powershell.exe",
|
|
79
|
+
args: (command) => [
|
|
80
|
+
"-NoProfile",
|
|
81
|
+
"-NonInteractive",
|
|
82
|
+
"-ExecutionPolicy",
|
|
83
|
+
"Bypass",
|
|
84
|
+
"-EncodedCommand",
|
|
85
|
+
Buffer.from(PS_PRELUDE + command + PS_EPILOGUE, "utf16le").toString("base64")
|
|
86
|
+
]
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
var cachedDefault = null;
|
|
90
|
+
function defaultShell() {
|
|
91
|
+
if (cachedDefault === null) cachedDefault = resolveShell({ platform: process.platform, env: process.env, exists: existsSync });
|
|
92
|
+
return cachedDefault;
|
|
93
|
+
}
|
|
94
|
+
|
|
60
95
|
// src/tools/bash.ts
|
|
61
96
|
var HALF = 15e3;
|
|
62
97
|
function killProcessTree(pid, platform = process.platform, spawnFn = spawn) {
|
|
@@ -87,8 +122,8 @@ function killAllCommands() {
|
|
|
87
122
|
}
|
|
88
123
|
var backgrounds = /* @__PURE__ */ new Map();
|
|
89
124
|
var nextBackgroundId = 1;
|
|
90
|
-
function startBackground(command, cwd, env) {
|
|
91
|
-
const child = spawnChild(command, cwd, env);
|
|
125
|
+
function startBackground(command, cwd, env, shell) {
|
|
126
|
+
const child = spawnChild(command, cwd, env, shell);
|
|
92
127
|
const task = {
|
|
93
128
|
id: nextBackgroundId++,
|
|
94
129
|
command: Array.isArray(command) ? command.join(" ") : command,
|
|
@@ -138,8 +173,8 @@ function startBackground(command, cwd, env) {
|
|
|
138
173
|
return task;
|
|
139
174
|
}
|
|
140
175
|
function backgroundStatus(task) {
|
|
141
|
-
if (task.status === "running") return `[running ${Math.round((Date.now() - task.startedAt) / 1e3)}s]`;
|
|
142
176
|
if (task.killed) return "[killed]";
|
|
177
|
+
if (task.status === "running") return `[running ${Math.round((Date.now() - task.startedAt) / 1e3)}s]`;
|
|
143
178
|
return `[exit code ${task.exitCode}]`;
|
|
144
179
|
}
|
|
145
180
|
function backgroundOutput(task) {
|
|
@@ -159,8 +194,14 @@ function renderBackgroundTasks() {
|
|
|
159
194
|
return `Background tasks:
|
|
160
195
|
${lines.join("\n")}`;
|
|
161
196
|
}
|
|
162
|
-
function spawnChild(command, cwd, env) {
|
|
163
|
-
|
|
197
|
+
function spawnChild(command, cwd, env, shell) {
|
|
198
|
+
if (Array.isArray(command)) {
|
|
199
|
+
return spawn(command[0], command.slice(1), { cwd, detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe"], env });
|
|
200
|
+
}
|
|
201
|
+
if (shell) {
|
|
202
|
+
return spawn(shell.file, shell.args(command), { cwd, shell: false, detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe"], env });
|
|
203
|
+
}
|
|
204
|
+
return spawn(command, { cwd, shell: true, detached: process.platform !== "win32", stdio: ["ignore", "pipe", "pipe"], env });
|
|
164
205
|
}
|
|
165
206
|
var NETWORK_PATTERNS = [
|
|
166
207
|
/\b(curl|wget|ftp|scp|sftp|rsync|lynx|telnet)\b/i,
|
|
@@ -196,7 +237,7 @@ function offlineEnv(env = process.env) {
|
|
|
196
237
|
}
|
|
197
238
|
function runCommand(command, opts) {
|
|
198
239
|
return new Promise((resolve) => {
|
|
199
|
-
const child = spawnChild(command, opts.cwd, opts.env);
|
|
240
|
+
const child = spawnChild(command, opts.cwd, opts.env, opts.shell ?? defaultShell());
|
|
200
241
|
if (!exitHookInstalled) {
|
|
201
242
|
process.on("exit", killAllCommands);
|
|
202
243
|
exitHookInstalled = true;
|
|
@@ -264,13 +305,20 @@ var BASH_SCHEMA = z.object({
|
|
|
264
305
|
task_id: z.number().int().optional().describe("Poll a background task started with background: true (omit command)"),
|
|
265
306
|
kill: z.boolean().optional().describe("With task_id: stop the background task")
|
|
266
307
|
});
|
|
308
|
+
var SHELL_NOTE = {
|
|
309
|
+
bash: "Shell: Git Bash. Unix tools such as tail, grep, ls, sed and head are available.",
|
|
310
|
+
powershell: "Shell: Windows PowerShell 5.1. Unix tools such as tail, grep, ls, sed and head are NOT installed; use PowerShell equivalents (Select-Object -Last 40, Select-String, Get-ChildItem, Get-Content)."
|
|
311
|
+
};
|
|
267
312
|
function createBashTool(options = {}) {
|
|
268
313
|
const offline = options.networkPolicy === "offline";
|
|
269
314
|
const sandbox = options.sandbox === true;
|
|
270
315
|
const platform = options.platform ?? process.platform;
|
|
316
|
+
const shell = resolveShell({ platform, env: process.env, exists: existsSync2, ...options.shellDeps });
|
|
271
317
|
const childEnv = offline ? offlineEnv() : void 0;
|
|
318
|
+
const shellNote = shell ? `
|
|
319
|
+
${SHELL_NOTE[shell.name]}` : "";
|
|
272
320
|
const description = `${offline ? `${BASH_DESCRIPTION}
|
|
273
|
-
Network access is off (networkPolicy "offline"): internet commands such as curl, wget, git fetch/push/clone, package installs (npm, pip, ...), gh, and docker pull are blocked.` : BASH_DESCRIPTION}${sandbox ? "\nCommands run inside an OS sandbox: file writes are limited to the working directory and temp areas." : ""}`;
|
|
321
|
+
Network access is off (networkPolicy "offline"): internet commands such as curl, wget, git fetch/push/clone, package installs (npm, pip, ...), gh, and docker pull are blocked.` : BASH_DESCRIPTION}${sandbox ? "\nCommands run inside an OS sandbox: file writes are limited to the working directory and temp areas." : ""}${shellNote}`;
|
|
274
322
|
return defineTool({
|
|
275
323
|
name: "bash",
|
|
276
324
|
description,
|
|
@@ -310,7 +358,7 @@ Network access is off (networkPolicy "offline"): internet commands such as curl,
|
|
|
310
358
|
}
|
|
311
359
|
if (input.background) {
|
|
312
360
|
if (!input.command) return { output: 'The "command" argument is required to start a background task.', isError: true };
|
|
313
|
-
const task = startBackground(exec, ctx.cwd, childEnv);
|
|
361
|
+
const task = startBackground(exec, ctx.cwd, childEnv, shell);
|
|
314
362
|
return {
|
|
315
363
|
output: `Background task #${task.id} started: ${input.command}
|
|
316
364
|
Poll it with {task_id: ${task.id}}; stop it with {task_id: ${task.id}, kill: true}.`
|
|
@@ -323,7 +371,8 @@ Poll it with {task_id: ${task.id}}; stop it with {task_id: ${task.id}, kill: tru
|
|
|
323
371
|
cwd: ctx.cwd,
|
|
324
372
|
timeoutMs: input.timeout_ms ?? 12e4,
|
|
325
373
|
signal: ctx.signal,
|
|
326
|
-
env: childEnv
|
|
374
|
+
env: childEnv,
|
|
375
|
+
shell
|
|
327
376
|
});
|
|
328
377
|
const status = r.timedOut ? `[stopped: timeout after ${Math.round((input.timeout_ms ?? 12e4) / 1e3)} seconds]` : r.aborted ? "[cancelled by the user]" : `[exit code ${r.exitCode}]`;
|
|
329
378
|
return { output: `${r.output.trimEnd()}
|
|
@@ -353,12 +402,12 @@ var BUILTIN_AGENTS = [
|
|
|
353
402
|
];
|
|
354
403
|
|
|
355
404
|
// src/context.ts
|
|
356
|
-
import { existsSync, readFileSync } from "fs";
|
|
405
|
+
import { existsSync as existsSync3, readFileSync } from "fs";
|
|
357
406
|
import { dirname, join } from "path";
|
|
358
407
|
var FILES = ["AGENTS.md", "BCCLI.md"];
|
|
359
408
|
function readIf(path) {
|
|
360
409
|
try {
|
|
361
|
-
return
|
|
410
|
+
return existsSync3(path) ? readFileSync(path, "utf8").trim() : void 0;
|
|
362
411
|
} catch {
|
|
363
412
|
return void 0;
|
|
364
413
|
}
|
|
@@ -382,7 +431,7 @@ ${text}`);
|
|
|
382
431
|
}
|
|
383
432
|
function isGitRepo(cwd) {
|
|
384
433
|
for (let dir = cwd; ; dir = dirname(dir)) {
|
|
385
|
-
if (
|
|
434
|
+
if (existsSync3(join(dir, ".git"))) return true;
|
|
386
435
|
if (dirname(dir) === dir) return false;
|
|
387
436
|
}
|
|
388
437
|
}
|
|
@@ -426,7 +475,7 @@ ${instructions}` : ""}`;
|
|
|
426
475
|
}
|
|
427
476
|
|
|
428
477
|
// src/extensions.ts
|
|
429
|
-
import { existsSync as
|
|
478
|
+
import { existsSync as existsSync4, readdirSync, readFileSync as readFileSync2, statSync } from "fs";
|
|
430
479
|
import { basename, join as join2 } from "path";
|
|
431
480
|
function parseFrontmatter(text) {
|
|
432
481
|
const match = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?/.exec(text);
|
|
@@ -461,7 +510,7 @@ function loadSkills(r) {
|
|
|
461
510
|
for (const dir of dirs(r, "skills")) {
|
|
462
511
|
for (const entry of list(dir)) {
|
|
463
512
|
const file = join2(dir, entry, "SKILL.md");
|
|
464
|
-
if (!
|
|
513
|
+
if (!existsSync4(file)) continue;
|
|
465
514
|
const { data } = parseFrontmatter(readFileSync2(file, "utf8"));
|
|
466
515
|
const name = str(data.name) || entry;
|
|
467
516
|
byName.set(name, { name, description: str(data.description) ?? "", dir: join2(dir, entry), file });
|
|
@@ -536,8 +585,18 @@ function runOne(command, event, payload, opts) {
|
|
|
536
585
|
resolve(result);
|
|
537
586
|
};
|
|
538
587
|
let child;
|
|
588
|
+
const shell = defaultShell();
|
|
539
589
|
try {
|
|
540
|
-
|
|
590
|
+
if (shell) {
|
|
591
|
+
child = spawn2(shell.file, shell.args(command), {
|
|
592
|
+
shell: false,
|
|
593
|
+
env,
|
|
594
|
+
cwd: opts.cwd ?? process.cwd(),
|
|
595
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
596
|
+
});
|
|
597
|
+
} else {
|
|
598
|
+
child = spawn2(command, { shell: true, env, cwd: opts.cwd ?? process.cwd(), stdio: ["ignore", "pipe", "pipe"] });
|
|
599
|
+
}
|
|
541
600
|
} catch (error) {
|
|
542
601
|
resolve({ failure: error.message });
|
|
543
602
|
return;
|
|
@@ -590,12 +649,12 @@ async function runHooks(hooks, event, payload = {}, opts = {}) {
|
|
|
590
649
|
}
|
|
591
650
|
|
|
592
651
|
// src/slash/memory.ts
|
|
593
|
-
import { appendFileSync, existsSync as
|
|
652
|
+
import { appendFileSync, existsSync as existsSync5, readFileSync as readFileSync3 } from "fs";
|
|
594
653
|
function instructionFiles(cwd, home) {
|
|
595
|
-
return instructionPaths(cwd, home).filter((path) =>
|
|
654
|
+
return instructionPaths(cwd, home).filter((path) => existsSync5(path)).map((path) => ({ path, lines: readFileSync3(path, "utf8").split("\n").filter(Boolean).length }));
|
|
596
655
|
}
|
|
597
656
|
function appendMemory(file, text) {
|
|
598
|
-
const prefix =
|
|
657
|
+
const prefix = existsSync5(file) && !readFileSync3(file, "utf8").endsWith("\n") ? "\n" : "";
|
|
599
658
|
appendFileSync(file, `${prefix}- ${text.trim()}
|
|
600
659
|
`);
|
|
601
660
|
}
|
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
FileOAuthProvider,
|
|
4
|
-
hasStoredTokens
|
|
5
|
-
} from "./chunk-3HCOAJEQ.js";
|
|
6
2
|
import {
|
|
7
3
|
BUILTIN_AGENTS,
|
|
8
4
|
appendMemory,
|
|
@@ -17,47 +13,51 @@ import {
|
|
|
17
13
|
parseFrontmatter,
|
|
18
14
|
runHooks,
|
|
19
15
|
validateGlobPattern
|
|
20
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-DRK3XTVZ.js";
|
|
17
|
+
import {
|
|
18
|
+
createWebSearchTool,
|
|
19
|
+
fetchTool
|
|
20
|
+
} from "./chunk-QZM66F3A.js";
|
|
21
|
+
import {
|
|
22
|
+
defineTool
|
|
23
|
+
} from "./chunk-PSO7R5AD.js";
|
|
21
24
|
import {
|
|
22
25
|
Permissions
|
|
23
26
|
} from "./chunk-GAFJEQTJ.js";
|
|
24
27
|
import {
|
|
25
28
|
addProviderKey
|
|
26
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-A2XKKKKU.js";
|
|
27
30
|
import {
|
|
28
31
|
listAllModels
|
|
29
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-LYFN6AEV.js";
|
|
30
33
|
import {
|
|
31
34
|
providerName
|
|
32
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-I422TPGX.js";
|
|
36
|
+
import {
|
|
37
|
+
FileOAuthProvider,
|
|
38
|
+
hasStoredTokens
|
|
39
|
+
} from "./chunk-7F3IWBPQ.js";
|
|
33
40
|
import {
|
|
34
41
|
Session
|
|
35
|
-
} from "./chunk-
|
|
42
|
+
} from "./chunk-HVGXCPDG.js";
|
|
36
43
|
import {
|
|
37
44
|
completionAssistantMessage,
|
|
38
45
|
createProvider,
|
|
39
46
|
hasPendingProgrammaticReplay,
|
|
40
47
|
imageUserMessage
|
|
41
|
-
} from "./chunk-
|
|
48
|
+
} from "./chunk-LYQHLA43.js";
|
|
42
49
|
import {
|
|
43
50
|
expandEnvVars
|
|
44
|
-
} from "./chunk-
|
|
45
|
-
import {
|
|
46
|
-
createWebSearchTool,
|
|
47
|
-
fetchTool
|
|
48
|
-
} from "./chunk-HE33XAPZ.js";
|
|
49
|
-
import {
|
|
50
|
-
defineTool
|
|
51
|
-
} from "./chunk-PSO7R5AD.js";
|
|
51
|
+
} from "./chunk-NFJPKNHL.js";
|
|
52
52
|
import {
|
|
53
53
|
ConfigError,
|
|
54
54
|
bccliHome,
|
|
55
55
|
loadConfig,
|
|
56
56
|
resolveModel
|
|
57
|
-
} from "./chunk-
|
|
57
|
+
} from "./chunk-AGIZBZ64.js";
|
|
58
58
|
import {
|
|
59
59
|
t
|
|
60
|
-
} from "./chunk-
|
|
60
|
+
} from "./chunk-VBEX5YHF.js";
|
|
61
61
|
|
|
62
62
|
// src/textToolCalls.ts
|
|
63
63
|
var PAIR = /(?:<arg_key>\s*|`)?([A-Za-z_]\w*)(?:\s*<\/arg_key>)?`?\s*(?:=\s*`|<arg_value>)([\s\S]*?)<\/arg_value>/g;
|
|
@@ -1909,6 +1909,8 @@ function createRuntime(opts) {
|
|
|
1909
1909
|
apiKey: resolved.apiKey,
|
|
1910
1910
|
model: resolved.model,
|
|
1911
1911
|
providerId: resolved.providerId,
|
|
1912
|
+
fetch: opts.fetch,
|
|
1913
|
+
// diteruskan penuh (spec gh-bot §6.6 — juga memperbaiki sdk fetch-injection)
|
|
1912
1914
|
enableProgrammaticToolCalling: lunaPtcAutoEnabled(env)
|
|
1913
1915
|
});
|
|
1914
1916
|
};
|
|
@@ -1993,7 +1995,7 @@ function createRuntime(opts) {
|
|
|
1993
1995
|
cwd: opts.cwd,
|
|
1994
1996
|
history,
|
|
1995
1997
|
reasoning,
|
|
1996
|
-
maxSteps: config.maxSteps,
|
|
1998
|
+
maxSteps: opts.maxSteps ?? config.maxSteps,
|
|
1997
1999
|
hooks: config.hooks,
|
|
1998
2000
|
pluginEmit,
|
|
1999
2001
|
env,
|