@botconnector/bccli 0.4.0-beta.9 → 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.
- package/README.en.md +253 -0
- package/README.md +93 -6
- package/dist/abort.d.ts +5 -0
- package/dist/acp-3PHBAI64.js +182 -0
- package/dist/acp.d.ts +27 -0
- package/dist/agent.d.ts +143 -0
- package/dist/agents.d.ts +4 -0
- package/dist/args-W6BNKY7K.js +13 -0
- package/dist/args.d.ts +51 -0
- package/dist/budget.d.ts +23 -0
- package/dist/checkpoints.d.ts +34 -0
- package/dist/{chunk-BFZXRKW5.js → chunk-24JN75FZ.js} +29 -7
- package/dist/chunk-45SDLMTV.js +341 -0
- package/dist/chunk-75BECX4F.js +56 -0
- package/dist/{chunk-SJH3YLW4.js → chunk-BC7UXFE4.js} +69 -6
- package/dist/chunk-BGXNR74O.js +733 -0
- package/dist/chunk-BKGFA2PT.js +8 -0
- package/dist/{chunk-CLN4Z5E3.js → chunk-BLOYFIAD.js} +6 -3
- package/dist/chunk-BXQQCUAC.js +145 -0
- package/dist/chunk-FLQPE4S5.js +373 -0
- package/dist/chunk-GN4W3T6E.js +76 -0
- package/dist/{chunk-7S6JXQCH.js → chunk-JHPGOAXU.js} +2 -1
- package/dist/chunk-MFHCQQEN.js +201 -0
- package/dist/chunk-MHIYLXJC.js +143 -0
- package/dist/chunk-PSO7R5AD.js +10 -0
- package/dist/chunk-PZRKU4UM.js +2143 -0
- package/dist/chunk-QZKLZELZ.js +64 -0
- package/dist/chunk-R5RE46CW.js +231 -0
- package/dist/chunk-UZWJQF67.js +500 -0
- package/dist/{chunk-DX7CZTBB.js → chunk-WI22M2ID.js} +14 -9
- package/dist/chunk-WNACAUDK.js +946 -0
- package/dist/chunk-XV7ZVL4J.js +235 -0
- package/dist/cli.d.ts +1 -0
- package/dist/cli.js +150 -1382
- package/dist/clipboardImage.d.ts +17 -0
- package/dist/commands.d.ts +16 -0
- package/dist/completion-HPPFDAPB.js +125 -0
- package/dist/completion.d.ts +14 -0
- package/dist/{config-YUNKPCNB.js → config-DIDLDONU.js} +5 -2
- package/dist/config-IU76CPK2.js +34 -0
- package/dist/config.d.ts +97 -0
- package/dist/context.d.ts +13 -0
- package/dist/contextWindow.d.ts +3 -0
- package/dist/diff.d.ts +7 -0
- package/dist/exit.d.ts +9 -0
- package/dist/extensions.d.ts +34 -0
- package/dist/ghBotCli-E3VPHNZY.js +677 -0
- package/dist/ghBotCli.d.ts +9 -0
- package/dist/ghBotDispatch.d.ts +68 -0
- package/dist/ghBotRunner.d.ts +82 -0
- package/dist/ghBotServe.d.ts +21 -0
- package/dist/ghBotWebhook.d.ts +45 -0
- package/dist/hooks.d.ts +27 -0
- package/dist/i18n/id.d.ts +1 -0
- package/dist/i18n.d.ts +16 -0
- package/dist/integrationCli-Q2YPDTPG.js +685 -0
- package/dist/integrationCli.d.ts +9 -0
- package/dist/keybinds.d.ts +22 -0
- package/dist/login-FP3BB44A.js +16 -0
- package/dist/login.d.ts +19 -0
- package/dist/lsp.d.ts +47 -0
- package/dist/mcp/catalog.d.ts +14 -0
- package/dist/mcp/config.d.ts +36 -0
- package/dist/mcp/manager.d.ts +34 -0
- package/dist/mcp/oauth.d.ts +82 -0
- package/dist/{mcpCli-DZWQPTOS.js → mcpCli-SNBDUWJN.js} +42 -9
- package/dist/mcpCli.d.ts +3 -0
- package/dist/mcpServer/serve.d.ts +8 -0
- package/dist/mcpServer/server.d.ts +19 -0
- package/dist/models.d.ts +13 -0
- package/dist/modelsCli-CZ2HNGKR.js +36 -0
- package/dist/modelsCli.d.ts +15 -0
- package/dist/npmRunner-LU43GM3W.js +46 -0
- package/dist/npmRunner.d.ts +21 -0
- package/dist/oauthLogin-6FWQABJ7.js +210 -0
- package/dist/oauthLogin.d.ts +47 -0
- package/dist/permissions.d.ts +30 -0
- package/dist/pluginSpec.d.ts +25 -0
- package/dist/plugins.d.ts +45 -0
- package/dist/pluginsCli-LPIUUDWB.js +284 -0
- package/dist/pluginsCli.d.ts +16 -0
- package/dist/prCli-5IMV3VNQ.js +78 -0
- package/dist/prCli.d.ts +33 -0
- package/dist/presets.d.ts +8 -0
- package/dist/print.d.ts +14 -0
- package/dist/provider.d.ts +140 -0
- package/dist/providerCli-NMUFXAAS.js +15 -0
- package/dist/providerCli.d.ts +17 -0
- package/dist/providers.d.ts +6 -0
- package/dist/reasoning.d.ts +12 -0
- package/dist/repomap.d.ts +10 -0
- package/dist/sdk.d.ts +57 -0
- package/dist/sdk.js +5571 -0
- package/dist/serve-KWOECK5W.js +178 -0
- package/dist/serve-X2ZV4S5U.js +521 -0
- package/dist/serve.d.ts +37 -0
- package/dist/serveHeartbeat.d.ts +14 -0
- package/dist/serveProtocol.d.ts +47 -0
- package/dist/session-GKEXDJKZ.js +12 -0
- package/dist/session.d.ts +30 -0
- package/dist/setup-OV3NWQN5.js +24 -0
- package/dist/setup.d.ts +74 -0
- package/dist/slash/copy.d.ts +1 -0
- package/dist/slash/diff.d.ts +1 -0
- package/dist/slash/doctor.d.ts +18 -0
- package/dist/slash/export.d.ts +2 -0
- package/dist/slash/info.d.ts +45 -0
- package/dist/slash/memory.d.ts +10 -0
- package/dist/statsCli-CF3R7ATL.js +353 -0
- package/dist/statsCli.d.ts +62 -0
- package/dist/textToolCalls.d.ts +6 -0
- package/dist/thinking.d.ts +17 -0
- package/dist/tokenBudget.d.ts +22 -0
- package/dist/tools/bash.d.ts +52 -0
- package/dist/tools/diagnostics.d.ts +5 -0
- package/dist/tools/edit.d.ts +7 -0
- package/dist/tools/fetch.d.ts +41 -0
- package/dist/tools/glob.d.ts +5 -0
- package/dist/tools/globSafety.d.ts +7 -0
- package/dist/tools/grep.d.ts +13 -0
- package/dist/tools/ignore.d.ts +2 -0
- package/dist/tools/index.d.ts +12 -0
- package/dist/tools/memory.d.ts +13 -0
- package/dist/tools/paths.d.ts +2 -0
- package/dist/tools/plan.d.ts +10 -0
- package/dist/tools/read.d.ts +16 -0
- package/dist/tools/repomap.d.ts +2 -0
- package/dist/tools/sandbox.d.ts +12 -0
- package/dist/tools/shell.d.ts +18 -0
- package/dist/tools/skill.d.ts +3 -0
- package/dist/tools/task.d.ts +28 -0
- package/dist/tools/todo.d.ts +13 -0
- package/dist/tools/types.d.ts +52 -0
- package/dist/tools/websearch.d.ts +9 -0
- package/dist/tools/write.d.ts +5 -0
- package/dist/transferCli-YUFPI6AH.js +71 -0
- package/dist/transferCli.d.ts +23 -0
- package/dist/ui/App.d.ts +7 -0
- package/dist/ui/DiffView.d.ts +3 -0
- package/dist/ui/EditableText.d.ts +7 -0
- package/dist/ui/LinePrompt.d.ts +6 -0
- package/dist/ui/ListPicker.d.ts +11 -0
- package/dist/ui/Markdown.d.ts +8 -0
- package/dist/ui/McpMenu.d.ts +11 -0
- package/dist/ui/ModelPicker.d.ts +6 -0
- package/dist/ui/PermissionPrompt.d.ts +5 -0
- package/dist/ui/PlanApproval.d.ts +5 -0
- package/dist/ui/PromptInput.d.ts +18 -0
- package/dist/ui/ProviderMenu.d.ts +10 -0
- package/dist/ui/Spinner.d.ts +4 -0
- package/dist/ui/StatusBar.d.ts +9 -0
- package/dist/ui/TodoList.d.ts +4 -0
- package/dist/ui/ToolBlock.d.ts +14 -0
- package/dist/ui/complete.d.ts +1 -0
- package/dist/ui/focusReport.d.ts +1 -0
- package/dist/ui/index.d.ts +7 -0
- package/dist/ui/lineEdit.d.ts +42 -0
- package/dist/ui/replay.d.ts +4 -0
- package/dist/ui/table.d.ts +20 -0
- package/dist/ui/theme.d.ts +5 -0
- package/dist/ui/thinkingMouse.d.ts +33 -0
- package/dist/ui/transcript.d.ts +55 -0
- package/dist/ui/vim.d.ts +26 -0
- package/dist/ui-IVIFNUCC.js +2367 -0
- package/dist/update-TZ2G6KQ3.js +145 -0
- package/dist/update.d.ts +30 -0
- package/dist/verify.d.ts +16 -0
- package/dist/version.d.ts +1 -0
- package/dist/webBudget.d.ts +25 -0
- package/dist/worktree.d.ts +12 -0
- package/package.json +42 -8
- package/dist/args-JPVSGCGY.js +0 -12
- package/dist/chunk-2MGINW4O.js +0 -114
- package/dist/chunk-ELML4KVQ.js +0 -76
- package/dist/chunk-ISGBGFSU.js +0 -52
- package/dist/chunk-KV27KTOX.js +0 -254
- package/dist/chunk-U7GK73CK.js +0 -341
- package/dist/chunk-ZYCYTEKD.js +0 -96
- package/dist/integrationCli-BGT5UZU4.js +0 -223
- package/dist/login-6K32PIXV.js +0 -9
- package/dist/providerCli-Q7LRM2NP.js +0 -12
- package/dist/session-7UB77CEG.js +0 -9
- package/dist/ui-6GTQUJOE.js +0 -1415
package/README.en.md
ADDED
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
# BCCLI
|
|
2
|
+
|
|
3
|
+
[English](README.en.md) · **Bahasa Indonesia**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@botconnector/bccli?activeTab=versions)
|
|
6
|
+
[](https://www.npmjs.com/package/@botconnector/bccli)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://botconnector.id/id/download)
|
|
10
|
+
|
|
11
|
+
An AI coding agent from [BotConnector](https://botconnector.id/) that works in your terminal: it reads code,
|
|
12
|
+
edits files, and runs commands — with your permission.
|
|
13
|
+
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
*Real session recording: BCCLI creates `hello.js` and runs it with `node`.*
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
# one-line install (macOS / Linux / WSL2) — provisions a portable Node if needed, no sudo
|
|
20
|
+
curl -fsSL https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.sh | bash
|
|
21
|
+
|
|
22
|
+
# Windows (PowerShell 5.1+) — needs Node.js 22+ already installed
|
|
23
|
+
irm https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.ps1 | iex
|
|
24
|
+
|
|
25
|
+
# or manual, if you already have Node.js 22+
|
|
26
|
+
npm i -g @botconnector/bccli # latest stable, requires Node.js 22+
|
|
27
|
+
npm i -g @botconnector/bccli@next # …or the next prerelease
|
|
28
|
+
bccli login # store your BotConnector Cloud API key
|
|
29
|
+
cd your-project && bccli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Usage
|
|
33
|
+
|
|
34
|
+
| Command | What it does |
|
|
35
|
+
|---|---|
|
|
36
|
+
| `bccli` | interactive mode |
|
|
37
|
+
| `bccli -p "task"` | one-shot task (scripts/CI) |
|
|
38
|
+
| `bccli -p "task" --output-format json` | final result as a single JSON object; `stream-json` = JSONL events per stage (tool_use/tool_result/message/result) for CI |
|
|
39
|
+
| `bccli -c` / `bccli -r` | continue last session / pick a session |
|
|
40
|
+
| `bccli -m provider/model` | choose a model |
|
|
41
|
+
| `bccli --reasoning <auto\|off\|low\|medium\|high\|max>` | set reasoning level for this invocation |
|
|
42
|
+
| `bccli models` | list models |
|
|
43
|
+
|
|
44
|
+
In-session commands (type `/` for suggestions, ↑↓ to select, Enter to run):
|
|
45
|
+
|
|
46
|
+
| Command | What it does |
|
|
47
|
+
|---|---|
|
|
48
|
+
| `/help` | list commands and shortcuts |
|
|
49
|
+
| `/model` | switch model |
|
|
50
|
+
| `/reasoning` | pick Auto / Off / Low / Medium / High / Max |
|
|
51
|
+
| `/provider` | add/select an AI provider |
|
|
52
|
+
| `/language` | change display language (`en` / `id`) |
|
|
53
|
+
| `/mcp` | install/manage MCP servers |
|
|
54
|
+
| `/new` | new session (old sessions are kept) |
|
|
55
|
+
| `/resume` | continue another session in this folder |
|
|
56
|
+
| `/session` | info about this session |
|
|
57
|
+
| `/status` | version, model, permission mode, MCP, context |
|
|
58
|
+
| `/permissions` | view/revoke permissions |
|
|
59
|
+
| `/pr` | review a pull request (`/pr <n\|url\|branch>`) |
|
|
60
|
+
| `/worktree` | list git worktrees; create one with `bccli -w <name>` |
|
|
61
|
+
| `/undo` | undo the last file-edit turn |
|
|
62
|
+
| `/redo` | re-apply the file edits that /undo just reverted |
|
|
63
|
+
| `/rewind` | step back turns: conversation + file edits (`/rewind 2`) |
|
|
64
|
+
| `/diff` | git diff of the project |
|
|
65
|
+
| `/copy` | copy the last answer |
|
|
66
|
+
| `/export` | save the conversation to markdown |
|
|
67
|
+
| `/memory` | project instructions (/memory <text>, /memory global <text>) |
|
|
68
|
+
| `/init` | create/update AGENTS.md for this project |
|
|
69
|
+
| `/agents` | list subagents |
|
|
70
|
+
| `/tasks` | list background tasks |
|
|
71
|
+
| `/skills` | list skills and custom commands |
|
|
72
|
+
| `/doctor` | check installation health |
|
|
73
|
+
| `/login` | store the active provider's API key |
|
|
74
|
+
| `/logout` | remove the active provider's API key |
|
|
75
|
+
| `/clear` | start a fresh conversation |
|
|
76
|
+
| `/compact` | compact the conversation |
|
|
77
|
+
| `/cost` | token usage for this session |
|
|
78
|
+
| `/exit` | quit |
|
|
79
|
+
|
|
80
|
+
`/undo` only reverts file edit/write tool changes (not bash commands), one turn at a time, up to 20 turns back.
|
|
81
|
+
Shift+Tab cycles permission modes: `default` → `acceptEdits` → `plan` → `allowAll`.
|
|
82
|
+
|
|
83
|
+
Reading a secret file (`.env`, `.ssh`, `.aws`, `id_rsa`, `*.pem`, `*.key`, `secret*`,
|
|
84
|
+
`credential*`) always asks for approval; `allowAll` is the only mode that does not, and the
|
|
85
|
+
approval cannot be granted "for this session".
|
|
86
|
+
|
|
87
|
+
`-p` mode never prompts: permission-requiring tools are refused unless you pass
|
|
88
|
+
`--allow-all` or `--allowed-tools bash,edit,fetch`.
|
|
89
|
+
|
|
90
|
+
## Language
|
|
91
|
+
|
|
92
|
+
BCCLI's UI (help, messages, permission prompts) is **English by default**. Indonesian stays available:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bccli --lang id # one-off
|
|
96
|
+
BCCLI_LANG=id bccli # via environment
|
|
97
|
+
/language id # inside a session; stored in ~/.bccli/config.json ("language")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Priority order: `--lang`, then `BCCLI_LANG`, then `language` in config, then English. The model answers in
|
|
101
|
+
the language you write; tool messages the model reads (tool output, errors) are always English so they
|
|
102
|
+
don't distort the reply language.
|
|
103
|
+
|
|
104
|
+
## Providers
|
|
105
|
+
|
|
106
|
+
`/provider` in a session (or `bccli provider add <id>`) adds a provider with just an API key:
|
|
107
|
+
|
|
108
|
+
| Id | Provider |
|
|
109
|
+
|---|---|
|
|
110
|
+
| `bc-cloud` | BotConnector Cloud (default) |
|
|
111
|
+
| `openrouter` | OpenRouter |
|
|
112
|
+
| `openai` | OpenAI |
|
|
113
|
+
| `gemini` | Google Gemini |
|
|
114
|
+
| `deepseek` | DeepSeek |
|
|
115
|
+
| `groq` | Groq |
|
|
116
|
+
| `ollama-cloud` | Ollama Cloud |
|
|
117
|
+
| `ollama` | local Ollama (no key) |
|
|
118
|
+
| `lmstudio` | local LM Studio (no key) |
|
|
119
|
+
|
|
120
|
+
Any other OpenAI-compatible provider: pick **Custom…** in `/provider`, or
|
|
121
|
+
`bccli provider add corp --url https://corp.example/v1 --name "Corp"`.
|
|
122
|
+
|
|
123
|
+
`/model` lists models from **every** provider that has a key, grouped by provider;
|
|
124
|
+
type to filter. Your choice is saved as the default.
|
|
125
|
+
|
|
126
|
+
Reasoning can be set via `bccli --reasoning <auto|off|low|medium|high|max>` or `/reasoning`.
|
|
127
|
+
**Auto** uses the model/provider default and BCCLI sends no reasoning override. BCCLI never
|
|
128
|
+
silently lowers or raises reasoning effort. Manual levels pass through when the provider/model
|
|
129
|
+
contract supports them; unsupported levels produce a clear error instead of a silent downgrade.
|
|
130
|
+
|
|
131
|
+
`.bccli/config.json` inside a project may only pick a `model` and add new keyless providers —
|
|
132
|
+
the `reasoning` preference is read only from the user config `~/.bccli/config.json`, never from a
|
|
133
|
+
cloned repo — permissions (`permissionMode`, `allow`) and existing providers are configured only
|
|
134
|
+
from `~/.bccli/config.json`, so a cloned repo cannot grant itself full permissions or steal API keys.
|
|
135
|
+
|
|
136
|
+
Every key of `~/.bccli/config.json` with its values and scope: [`docs/config.md`](docs/config.md).
|
|
137
|
+
|
|
138
|
+
## External agent integrations
|
|
139
|
+
|
|
140
|
+
BCCLI can set up BotConnector as a provider for other agents:
|
|
141
|
+
|
|
142
|
+
| Command | What it does |
|
|
143
|
+
|---|---|
|
|
144
|
+
| `bccli integrations` | show integration status |
|
|
145
|
+
| `bccli connect opencode` | connect OpenCode to BotConnector |
|
|
146
|
+
| `bccli connect aider` | connect Aider to BotConnector |
|
|
147
|
+
| `bccli connect cline` | connect Cline CLI to BotConnector |
|
|
148
|
+
| `bccli connect deepseek-harness` / `bccli connect dsh` | connect DeepSeek Harness to BotConnector |
|
|
149
|
+
| `bccli connect codex` | create Codex Responses API profile + BotConnector launcher |
|
|
150
|
+
| `bccli connect claude-code` | create a Claude Code launcher via Anthropic Messages compatibility |
|
|
151
|
+
| `bccli connect cursor` | guided Cursor setup + Base URL override warning |
|
|
152
|
+
| `bccli connect openai-cli` | create an OpenAI CLI launcher for BotConnector |
|
|
153
|
+
| `bccli connect openai-sdk` | create an env profile for the OpenAI Python/Node SDK |
|
|
154
|
+
| `bccli connect openai-compatible` | create a universal OpenAI-compatible env profile |
|
|
155
|
+
| `bccli disconnect <agent>` | restore the config from before the integration |
|
|
156
|
+
|
|
157
|
+
OpenCode uses the global config `~/.config/opencode/opencode.json`. BCCLI fetches the BotConnector
|
|
158
|
+
model catalog on connect, preserves other providers' config, and stores secrets in a separate file
|
|
159
|
+
under `~/.bccli/integrations/`.
|
|
160
|
+
Aider uses `~/.aider.conf.yml` pointing at a separate BCCLI env file; BCCLI refuses to overwrite
|
|
161
|
+
existing Aider OpenAI/env-file settings.
|
|
162
|
+
|
|
163
|
+
Cline uses an `openai-compatible` provider in `~/.cline/data/settings/providers.json`. If that slot
|
|
164
|
+
is taken by another endpoint, BCCLI refuses to overwrite it. Cline itself stores provider API keys
|
|
165
|
+
in that file.
|
|
166
|
+
|
|
167
|
+
DeepSeek Harness uses a custom `botconnector` provider in `$DSH_HOME/settings.yaml` with
|
|
168
|
+
`api: openai-completions` and `apiKeyEnv: BOTCONNECTOR_API_KEY`; the key goes in the BCCLI block of
|
|
169
|
+
`$DSH_HOME/.env`. Other DSH providers are kept. After connecting, run the web profile with
|
|
170
|
+
`dsh web` (same as `dsh --profile web`); bare `dsh` without a profile is rejected by DSH 0.1.x.
|
|
171
|
+
|
|
172
|
+
Codex uses a profile `$CODEX_HOME/botconnector.config.toml` with `wire_api = "responses"` and a BCCLI
|
|
173
|
+
launcher that reads the key from BCCLI storage at runtime. Claude Code gets an isolated launcher with
|
|
174
|
+
`ANTHROPIC_BASE_URL=https://api.botconnector.id` and the `/v1/messages` compatibility endpoint +
|
|
175
|
+
token counting. Codex and Claude Code primary login/config are not overwritten.
|
|
176
|
+
|
|
177
|
+
External agents call BotConnector directly, so model discovery does not use BCCLI-specific identity.
|
|
178
|
+
Access restricted to BCCLI/Web App (for example Luna launch access) is not automatically inherited.
|
|
179
|
+
Before changing external config, BCCLI makes a backup so `disconnect` can restore it.
|
|
180
|
+
|
|
181
|
+
## Internet
|
|
182
|
+
|
|
183
|
+
- `web_search`: web search with no permission prompt. Uses your BotConnector Cloud account when a key
|
|
184
|
+
is present, otherwise goes straight to Keenable (free, no key). Results are titles, URLs, and short
|
|
185
|
+
snippets, so they are token-efficient.
|
|
186
|
+
- `fetch`: open one URL from this machine (permission required per host).
|
|
187
|
+
|
|
188
|
+
## MCP
|
|
189
|
+
|
|
190
|
+
`/mcp` (or `bccli mcp add <name>`) installs servers from the catalog:
|
|
191
|
+
`playwright`, `context7`, `fetch`, `filesystem`, `git`, `github`. Other remote servers:
|
|
192
|
+
`bccli mcp add name --url https://…`. Stored in `~/.bccli/mcp.json` (`mcpServers` format, same as
|
|
193
|
+
Claude Code). All MCP tools always require permission.
|
|
194
|
+
|
|
195
|
+
A `.bccli/mcp.json` inside a repo is not executed until you approve it (asked once per folder).
|
|
196
|
+
|
|
197
|
+
`bccli mcp serve` runs a stdio MCP server with your BotConnector tools
|
|
198
|
+
(`bc_search`, `bc_fetch`, `bc_models`, `bc_chat`) for Claude Code, Cursor, opencode, and other MCP
|
|
199
|
+
hosts. Requires `bccli login` (or `BOTCONNECTOR_API_KEY`):
|
|
200
|
+
|
|
201
|
+
```bash
|
|
202
|
+
claude mcp add botconnector -- npx -y @botconnector/bccli mcp serve
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Subagents
|
|
206
|
+
|
|
207
|
+
The agent can delegate work via the `task` tool:
|
|
208
|
+
- `explore` — read & search only, can run in parallel;
|
|
209
|
+
- `general` — all tools (edits/commands still ask permission);
|
|
210
|
+
- custom — `.bccli/agents/name.md` or `.claude/agents/name.md`:
|
|
211
|
+
|
|
212
|
+
```markdown
|
|
213
|
+
---
|
|
214
|
+
name: reviewer
|
|
215
|
+
description: review code changes
|
|
216
|
+
tools: [read, grep, glob]
|
|
217
|
+
model: openrouter/qwen/qwen3-coder
|
|
218
|
+
---
|
|
219
|
+
You are a code reviewer. Report real bugs only.
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
## Skills & custom commands
|
|
223
|
+
|
|
224
|
+
- Skills: folders containing `SKILL.md` in `~/.bccli/skills/`, `.bccli/skills/`, `~/.claude/skills/`,
|
|
225
|
+
`.claude/skills/` — used automatically when relevant, or via `/skill-name`.
|
|
226
|
+
- Commands: `commands/name.md` in the same folders → `/name arguments` (`$ARGUMENTS` is replaced).
|
|
227
|
+
|
|
228
|
+
## Todos & plan mode
|
|
229
|
+
|
|
230
|
+
Tasks with ≥ 3 steps show a checklist above the input box. In plan mode (Shift+Tab),
|
|
231
|
+
the agent only reads and then proposes a plan; `[a]` approves with automatic edits,
|
|
232
|
+
`[y]` approves asking at each step, `[n]` asks for revisions.
|
|
233
|
+
|
|
234
|
+
Project instructions are read from `AGENTS.md`, `CLAUDE.md`, and `BCCLI.md`.
|
|
235
|
+
|
|
236
|
+
## Development
|
|
237
|
+
|
|
238
|
+
```bash
|
|
239
|
+
npm install
|
|
240
|
+
npm test && npm run typecheck && npm run lint && npm run build
|
|
241
|
+
npm run coverage # coverage gate (also enforced on Linux CI)
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
CI (`ci.yml`) runs the same on Linux, macOS, and Windows, plus the coverage gate on Linux.
|
|
245
|
+
Releases: bump `version` in `package.json`, then push a `v<version>` tag — `release.yml`
|
|
246
|
+
runs tests, a smoke test against BotConnector Cloud, and `npm publish --provenance`.
|
|
247
|
+
|
|
248
|
+
## Learn more
|
|
249
|
+
|
|
250
|
+
- [Download & BCCLI guide](https://botconnector.id/id/download)
|
|
251
|
+
- [BotConnector Developer API](https://botconnector.id/id/developers/api) — OpenAI SDK-compatible endpoint
|
|
252
|
+
- [Switchboard](https://github.com/farijarifriyanto-debug/switchboard) — BotConnector's open source agent harness
|
|
253
|
+
- [Contributing](CONTRIBUTING.md)
|
package/README.md
CHANGED
|
@@ -1,11 +1,31 @@
|
|
|
1
1
|
# BCCLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Bahasa Indonesia** · [English](README.en.md)
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@botconnector/bccli?activeTab=versions)
|
|
6
|
+
[](https://www.npmjs.com/package/@botconnector/bccli)
|
|
7
|
+
[](https://nodejs.org/)
|
|
8
|
+
[](LICENSE)
|
|
9
|
+
[](https://botconnector.id/id/download)
|
|
10
|
+
|
|
11
|
+
Agent AI coding dari [BotConnector](https://botconnector.id/) yang bekerja di terminal: membaca kode, mengedit file,
|
|
4
12
|
dan menjalankan perintah — dengan izin kamu.
|
|
5
13
|
|
|
14
|
+

|
|
15
|
+
|
|
16
|
+
*Rekaman sesi asli: BCCLI membuat file `hello.js` lalu menjalankannya dengan `node`.*
|
|
17
|
+
|
|
6
18
|
```bash
|
|
7
|
-
|
|
8
|
-
|
|
19
|
+
# install satu baris (macOS / Linux / WSL2) — pasang Node portable bila perlu, tanpa sudo
|
|
20
|
+
curl -fsSL https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.sh | bash
|
|
21
|
+
|
|
22
|
+
# Windows (PowerShell 5.1+) — butuh Node.js 22+ terpasang lebih dulu
|
|
23
|
+
irm https://raw.githubusercontent.com/farijarifriyanto-debug/bccli/main/install.ps1 | iex
|
|
24
|
+
|
|
25
|
+
# atau manual, bila Node.js 22+ sudah terpasang
|
|
26
|
+
npm i -g @botconnector/bccli # rilis stabil terbaru, butuh Node.js 22+
|
|
27
|
+
npm i -g @botconnector/bccli@next # …atau pra-rilis berikutnya
|
|
28
|
+
bccli login # simpan API key BotConnector Cloud
|
|
9
29
|
cd project-kamu && bccli
|
|
10
30
|
```
|
|
11
31
|
|
|
@@ -15,6 +35,7 @@ cd project-kamu && bccli
|
|
|
15
35
|
|---|---|
|
|
16
36
|
| `bccli` | mode interaktif |
|
|
17
37
|
| `bccli -p "tugas"` | satu tugas tanpa interaksi (skrip/CI) |
|
|
38
|
+
| `bccli -p "tugas" --output-format json` | hasil akhir sebagai satu objek JSON; `stream-json` = event JSONL per tahap (tool_use/tool_result/message/result) untuk CI |
|
|
18
39
|
| `bccli -c` / `bccli -r` | lanjutkan sesi terakhir / pilih sesi |
|
|
19
40
|
| `bccli -m provider/model` | pilih model |
|
|
20
41
|
| `bccli --reasoning <auto|off|low|medium|high|max>` | pilih level reasoning untuk invocation ini |
|
|
@@ -28,19 +49,25 @@ Perintah di dalam sesi (ketik `/` untuk saran, ↑↓ pilih, Enter jalankan):
|
|
|
28
49
|
| `/model` | ganti model |
|
|
29
50
|
| `/reasoning` | pilih Auto / Off / Low / Medium / High / Max |
|
|
30
51
|
| `/provider` | tambah/pilih provider AI |
|
|
52
|
+
| `/language` | ganti bahasa tampilan (`en` / `id`) |
|
|
31
53
|
| `/mcp` | pasang/kelola server MCP |
|
|
32
54
|
| `/new` | sesi baru (sesi lama tetap tersimpan) |
|
|
33
55
|
| `/resume` | lanjutkan sesi lain di folder ini |
|
|
34
56
|
| `/session` | info sesi ini |
|
|
35
57
|
| `/status` | versi, model, mode izin, MCP, konteks |
|
|
36
58
|
| `/permissions` | lihat/cabut izin |
|
|
59
|
+
| `/pr` | review pull request (`/pr <n\|url\|branch>`) |
|
|
60
|
+
| `/worktree` | daftar git worktree; buat dengan `bccli -w <nama>` |
|
|
37
61
|
| `/undo` | batalkan edit file giliran terakhir |
|
|
62
|
+
| `/redo` | terapkan ulang edit file yang baru dibatalkan `/undo` |
|
|
63
|
+
| `/rewind` | mundur beberapa giliran: percakapan + edit file (`/rewind 2`) |
|
|
38
64
|
| `/diff` | git diff project |
|
|
39
65
|
| `/copy` | salin jawaban terakhir |
|
|
40
66
|
| `/export` | simpan percakapan ke markdown |
|
|
41
67
|
| `/memory` | instruksi project (/memory <teks>, /memory global <teks>) |
|
|
42
68
|
| `/init` | buat/perbarui AGENTS.md untuk project ini |
|
|
43
69
|
| `/agents` | daftar subagent |
|
|
70
|
+
| `/tasks` | daftar tugas latar belakang |
|
|
44
71
|
| `/skills` | daftar skill dan perintah custom |
|
|
45
72
|
| `/doctor` | cek kesehatan instalasi |
|
|
46
73
|
| `/login` | simpan API key provider aktif |
|
|
@@ -53,9 +80,26 @@ Perintah di dalam sesi (ketik `/` untuk saran, ↑↓ pilih, Enter jalankan):
|
|
|
53
80
|
`/undo` hanya membatalkan perubahan lewat alat edit/tulis (bukan perintah bash), per giliran, sampai 20 giliran ke belakang.
|
|
54
81
|
Shift+Tab ganti mode izin: `default` → `acceptEdits` → `plan` → `allowAll`.
|
|
55
82
|
|
|
83
|
+
Membaca file rahasia (`.env`, `.ssh`, `.aws`, `id_rsa`, `*.pem`, `*.key`, `secret*`,
|
|
84
|
+
`credential*`) selalu meminta izin; `allowAll` satu-satunya mode yang tidak bertanya, dan
|
|
85
|
+
izin itu tidak bisa diberikan "untuk sesi ini".
|
|
86
|
+
|
|
56
87
|
Mode `-p` tidak pernah bertanya: alat yang butuh izin ditolak, kecuali memakai
|
|
57
88
|
`--allow-all` atau `--allowed-tools bash,edit,fetch`.
|
|
58
89
|
|
|
90
|
+
## Bahasa
|
|
91
|
+
|
|
92
|
+
Tampilan BCCLI (bantuan, pesan, prompt izin) memakai **bahasa Inggris secara default**. Bahasa Indonesia tetap tersedia:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
bccli --lang id # hanya untuk satu kali jalan
|
|
96
|
+
BCCLI_LANG=id bccli # lewat environment
|
|
97
|
+
/language id # di dalam sesi; disimpan di ~/.bccli/config.json ("language")
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
Urutan prioritas: `--lang`, lalu `BCCLI_LANG`, lalu `language` di config, lalu Inggris. Bahasa jawaban model mengikuti bahasa yang kamu tulis, dan
|
|
101
|
+
pesan alat yang dibaca model (hasil tool, galat) selalu berbahasa Inggris supaya tidak mengganggu bahasa jawabannya.
|
|
102
|
+
|
|
59
103
|
## Provider
|
|
60
104
|
|
|
61
105
|
`/provider` di dalam sesi (atau `bccli provider add <id>`) memasang provider hanya dengan API key:
|
|
@@ -88,6 +132,8 @@ preference `reasoning` hanya dibaca dari config user `~/.bccli/config.json`, buk
|
|
|
88
132
|
izin (`permissionMode`, `allow`) dan provider yang sudah ada hanya diatur dari `~/.bccli/config.json`,
|
|
89
133
|
supaya repo yang kamu clone tidak bisa memberi dirinya izin penuh atau mencuri API key.
|
|
90
134
|
|
|
135
|
+
Daftar lengkap kunci `~/.bccli/config.json` beserta nilai dan cakupannya: [`docs/config.md`](docs/config.md).
|
|
136
|
+
|
|
91
137
|
## Integrasi agent eksternal
|
|
92
138
|
|
|
93
139
|
BCCLI dapat memasang BotConnector sebagai provider untuk agent lain:
|
|
@@ -97,12 +143,37 @@ BCCLI dapat memasang BotConnector sebagai provider untuk agent lain:
|
|
|
97
143
|
| `bccli integrations` | lihat status integrasi |
|
|
98
144
|
| `bccli connect opencode` | hubungkan OpenCode ke BotConnector |
|
|
99
145
|
| `bccli connect aider` | hubungkan Aider ke BotConnector |
|
|
146
|
+
| `bccli connect cline` | hubungkan Cline CLI ke BotConnector |
|
|
147
|
+
| `bccli connect deepseek-harness` / `bccli connect dsh` | hubungkan DeepSeek Harness ke BotConnector |
|
|
148
|
+
| `bccli connect codex` | buat profile Codex Responses API + launcher BotConnector |
|
|
149
|
+
| `bccli connect claude-code` | buat launcher Claude Code via Anthropic Messages compatibility |
|
|
150
|
+
| `bccli connect cursor` | buat guided setup Cursor + warning override Base URL |
|
|
151
|
+
| `bccli connect openai-cli` | buat launcher OpenAI CLI khusus BotConnector |
|
|
152
|
+
| `bccli connect openai-sdk` | buat env profile untuk OpenAI Python/Node SDK |
|
|
153
|
+
| `bccli connect openai-compatible` | buat env profile universal OpenAI-compatible |
|
|
100
154
|
| `bccli disconnect <agent>` | pulihkan config sebelum integrasi |
|
|
101
155
|
|
|
102
156
|
OpenCode memakai config global `~/.config/opencode/opencode.json`. BCCLI mengambil katalog model BotConnector saat connect,
|
|
103
157
|
menjaga config provider lain, dan menyimpan secret di file terpisah di `~/.bccli/integrations/`.
|
|
104
158
|
Aider memakai `~/.aider.conf.yml` yang menunjuk ke env file BCCLI terpisah; BCCLI menolak menimpa setting
|
|
105
|
-
OpenAI/env-file Aider yang sudah ada.
|
|
159
|
+
OpenAI/env-file Aider yang sudah ada.
|
|
160
|
+
|
|
161
|
+
Cline memakai provider `openai-compatible` di `~/.cline/data/settings/providers.json`. Jika slot itu sudah dipakai
|
|
162
|
+
endpoint lain, BCCLI menolak menimpanya. Cline sendiri menyimpan API key provider di file tersebut.
|
|
163
|
+
|
|
164
|
+
DeepSeek Harness memakai custom provider `botconnector` di `$DSH_HOME/settings.yaml` dengan
|
|
165
|
+
`api: openai-completions` dan `apiKeyEnv: BOTCONNECTOR_API_KEY`; key diletakkan pada blok BCCLI di
|
|
166
|
+
`$DSH_HOME/.env`. Provider DSH lain tetap dipertahankan. Setelah connect, jalankan profile web dengan
|
|
167
|
+
`dsh web` (setara dengan `dsh --profile web`); `dsh` tanpa profile memang ditolak oleh DSH 0.1.x.
|
|
168
|
+
|
|
169
|
+
Codex memakai profile `$CODEX_HOME/botconnector.config.toml` dengan `wire_api = "responses"` dan launcher
|
|
170
|
+
BCCLI yang membaca key dari storage BCCLI saat dijalankan. Claude Code memakai launcher terisolasi dengan
|
|
171
|
+
`ANTHROPIC_BASE_URL=https://api.botconnector.id` dan endpoint kompatibilitas `/v1/messages` + token counting.
|
|
172
|
+
Login/config utama Codex dan Claude Code tidak ditimpa.
|
|
173
|
+
|
|
174
|
+
External agent memanggil BotConnector langsung, jadi discovery model tidak memakai identitas khusus BCCLI.
|
|
175
|
+
Akses yang memang dibatasi ke BCCLI/Web App (misalnya Luna launch access) tidak otomatis diwariskan.
|
|
176
|
+
Sebelum mengubah config eksternal, BCCLI membuat backup agar disconnect dapat memulihkannya.
|
|
106
177
|
|
|
107
178
|
## Internet
|
|
108
179
|
|
|
@@ -120,6 +191,14 @@ seperti Claude Code). Semua alat MCP selalu minta izin.
|
|
|
120
191
|
|
|
121
192
|
`.bccli/mcp.json` di dalam repo tidak dijalankan sebelum kamu setujui (ditanya sekali per folder).
|
|
122
193
|
|
|
194
|
+
`bccli mcp serve` menjalankan MCP server stdio dengan tools BotConnector milikmu
|
|
195
|
+
(`bc_search`, `bc_fetch`, `bc_models`, `bc_chat`) untuk dipakai Claude Code, Cursor,
|
|
196
|
+
opencode, dan host MCP lain. Butuh `bccli login` (atau `BOTCONNECTOR_API_KEY`):
|
|
197
|
+
|
|
198
|
+
```bash
|
|
199
|
+
claude mcp add botconnector -- npx -y @botconnector/bccli mcp serve
|
|
200
|
+
```
|
|
201
|
+
|
|
123
202
|
## Subagent
|
|
124
203
|
|
|
125
204
|
Agent bisa mendelegasikan pekerjaan lewat alat `task`:
|
|
@@ -149,15 +228,23 @@ Tugas ≥ 3 langkah menampilkan checklist di atas kotak input. Di mode plan (Shi
|
|
|
149
228
|
agent hanya membaca lalu mengajukan rencana; `[a]` setujui dengan edit otomatis,
|
|
150
229
|
`[y]` setujui dengan tanya tiap langkah, `[n]` minta perbaikan.
|
|
151
230
|
|
|
152
|
-
Instruksi project dibaca dari `AGENTS.md` dan `BCCLI.md`.
|
|
231
|
+
Instruksi project dibaca dari `AGENTS.md`, `CLAUDE.md`, dan `BCCLI.md`.
|
|
153
232
|
|
|
154
233
|
## Pengembangan
|
|
155
234
|
|
|
156
235
|
```bash
|
|
157
236
|
npm install
|
|
158
237
|
npm test && npm run typecheck && npm run lint && npm run build
|
|
238
|
+
npm run coverage # gerbang coverage (juga dijalankan di CI Linux)
|
|
159
239
|
```
|
|
160
240
|
|
|
161
|
-
CI (`ci.yml`) menjalankan hal yang sama di Linux, macOS, dan Windows.
|
|
241
|
+
CI (`ci.yml`) menjalankan hal yang sama di Linux, macOS, dan Windows, plus gerbang coverage di Linux.
|
|
162
242
|
Rilis: naikkan `version` di `package.json`, lalu push tag `v<version>` — `release.yml`
|
|
163
243
|
menjalankan test, smoke test ke BotConnector Cloud, dan `npm publish --provenance`.
|
|
244
|
+
|
|
245
|
+
## Pelajari lebih lanjut
|
|
246
|
+
|
|
247
|
+
- [Unduh & panduan BCCLI](https://botconnector.id/id/download)
|
|
248
|
+
- [Developer API BotConnector](https://botconnector.id/id/developers/api) — endpoint kompatibel OpenAI SDK
|
|
249
|
+
- [Switchboard](https://github.com/farijarifriyanto-debug/switchboard) — harness agent open source dari BotConnector
|
|
250
|
+
- [Berkontribusi](CONTRIBUTING.md)
|
package/dist/abort.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const ABORTED: unique symbol;
|
|
2
|
+
/** Resolves with the promise's value, or with ABORTED as soon as the signal fires. */
|
|
3
|
+
export declare function raceAbort<T>(promise: Promise<T>, signal: AbortSignal): Promise<T | typeof ABORTED>;
|
|
4
|
+
/** Collects an async iterable, giving up (and telling the iterator to stop) as soon as the signal fires. */
|
|
5
|
+
export declare function collectUntilAbort<T>(iterable: AsyncIterable<T>, signal: AbortSignal | undefined, onItem: (item: T) => void): Promise<boolean>;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/acp.ts
|
|
4
|
+
var ACP_PROTOCOL_VERSION = 1;
|
|
5
|
+
var TOOL_KINDS = {
|
|
6
|
+
read: "read",
|
|
7
|
+
repo_map: "read",
|
|
8
|
+
edit: "edit",
|
|
9
|
+
write: "edit",
|
|
10
|
+
grep: "search",
|
|
11
|
+
glob: "search",
|
|
12
|
+
bash: "execute",
|
|
13
|
+
powershell: "execute",
|
|
14
|
+
fetch: "fetch",
|
|
15
|
+
web_search: "fetch"
|
|
16
|
+
};
|
|
17
|
+
var kindOf = (tool) => TOOL_KINDS[tool] ?? "other";
|
|
18
|
+
var titleOf = (tool, target) => (target ? `${tool}: ${target}` : tool).slice(0, 200);
|
|
19
|
+
var MAX_OUTPUT = 4e3;
|
|
20
|
+
var PERMISSION_OPTIONS = [
|
|
21
|
+
{ optionId: "allow", name: "Allow", kind: "allow_once" },
|
|
22
|
+
{ optionId: "allow_session", name: "Allow for this session", kind: "allow_always" },
|
|
23
|
+
{ optionId: "reject", name: "Reject", kind: "reject_once" }
|
|
24
|
+
];
|
|
25
|
+
var ANSWERS = { allow: "yes", allow_session: "session", reject: "no" };
|
|
26
|
+
function runAcp(input, output, opts) {
|
|
27
|
+
const sessions = /* @__PURE__ */ new Map();
|
|
28
|
+
const awaiting = /* @__PURE__ */ new Map();
|
|
29
|
+
let nextSession = 1;
|
|
30
|
+
let nextRequest = 1;
|
|
31
|
+
const write = (msg) => {
|
|
32
|
+
output.write(`${JSON.stringify(msg)}
|
|
33
|
+
`);
|
|
34
|
+
};
|
|
35
|
+
const reply = (id, result) => write({ jsonrpc: "2.0", id, result });
|
|
36
|
+
const replyError = (id, code, message) => write({ jsonrpc: "2.0", id, error: { code, message } });
|
|
37
|
+
const update = (sessionId, body) => write({ jsonrpc: "2.0", method: "session/update", params: { sessionId, update: body } });
|
|
38
|
+
const ioFor = (sid, session) => ({
|
|
39
|
+
toolStart(id, tool, target) {
|
|
40
|
+
session.open.push({ id, tool, target });
|
|
41
|
+
update(sid, { sessionUpdate: "tool_call", toolCallId: id, title: titleOf(tool, target), kind: kindOf(tool), status: "in_progress", rawInput: { target } });
|
|
42
|
+
},
|
|
43
|
+
toolEnd(id, output2, isError) {
|
|
44
|
+
session.open = session.open.filter((c) => c.id !== id);
|
|
45
|
+
const text = output2.length > MAX_OUTPUT ? `${output2.slice(0, MAX_OUTPUT)}
|
|
46
|
+
[truncated]` : output2;
|
|
47
|
+
update(sid, {
|
|
48
|
+
sessionUpdate: "tool_call_update",
|
|
49
|
+
toolCallId: id,
|
|
50
|
+
status: isError ? "failed" : "completed",
|
|
51
|
+
...text ? { content: [{ type: "content", content: { type: "text", text } }] } : {}
|
|
52
|
+
});
|
|
53
|
+
},
|
|
54
|
+
askPermission(req) {
|
|
55
|
+
return new Promise((resolve) => {
|
|
56
|
+
const requestId = nextRequest++;
|
|
57
|
+
const call = [...session.open].reverse().find((c) => c.tool === req.tool && c.target === req.target);
|
|
58
|
+
const settle = (answer) => {
|
|
59
|
+
session.pending.delete(settle);
|
|
60
|
+
awaiting.delete(requestId);
|
|
61
|
+
resolve(answer);
|
|
62
|
+
};
|
|
63
|
+
session.pending.add(settle);
|
|
64
|
+
awaiting.set(requestId, (message) => {
|
|
65
|
+
const outcome = message.result?.outcome;
|
|
66
|
+
settle(outcome?.outcome === "selected" ? ANSWERS[outcome.optionId ?? ""] ?? "no" : "no");
|
|
67
|
+
});
|
|
68
|
+
write({
|
|
69
|
+
jsonrpc: "2.0",
|
|
70
|
+
id: requestId,
|
|
71
|
+
method: "session/request_permission",
|
|
72
|
+
params: {
|
|
73
|
+
sessionId: sid,
|
|
74
|
+
toolCall: { toolCallId: call?.id ?? `permission-${requestId}`, title: titleOf(req.tool, req.target), kind: kindOf(req.tool), status: "pending" },
|
|
75
|
+
options: PERMISSION_OPTIONS
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
});
|
|
81
|
+
const handle = async (msg) => {
|
|
82
|
+
const { id, method, params } = msg ?? {};
|
|
83
|
+
if (method === void 0 && id !== void 0 && (msg.result !== void 0 || msg.error !== void 0)) {
|
|
84
|
+
awaiting.get(id)?.(msg);
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
if (method === "initialize") {
|
|
88
|
+
return reply(id, {
|
|
89
|
+
protocolVersion: ACP_PROTOCOL_VERSION,
|
|
90
|
+
agentCapabilities: {
|
|
91
|
+
loadSession: false,
|
|
92
|
+
promptCapabilities: { image: false, audio: false, embeddedContext: false }
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (method === "session/new") {
|
|
97
|
+
const sessionId = `s${nextSession++}`;
|
|
98
|
+
sessions.set(sessionId, { controller: null, pending: /* @__PURE__ */ new Set(), open: [] });
|
|
99
|
+
return reply(id, { sessionId });
|
|
100
|
+
}
|
|
101
|
+
if (method === "session/cancel") {
|
|
102
|
+
const session = sessions.get(params?.sessionId ?? "");
|
|
103
|
+
session?.controller?.abort();
|
|
104
|
+
for (const settle of [...session?.pending ?? []]) settle("no");
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
if (method === "session/prompt") {
|
|
108
|
+
const sid = params?.sessionId ?? "";
|
|
109
|
+
const session = sessions.get(sid);
|
|
110
|
+
if (!session) return replyError(id, -32602, "Unknown session");
|
|
111
|
+
const text = (params?.prompt ?? []).filter((p) => p?.type === "text").map((p) => String(p.text ?? "")).join("\n");
|
|
112
|
+
const controller = new AbortController();
|
|
113
|
+
session.controller = controller;
|
|
114
|
+
let cancelled = false;
|
|
115
|
+
controller.signal.addEventListener("abort", () => {
|
|
116
|
+
cancelled = true;
|
|
117
|
+
});
|
|
118
|
+
try {
|
|
119
|
+
session.agent ??= opts.newAgent(params?.cwd ?? opts.cwd);
|
|
120
|
+
await session.agent.run(text, (chunk) => update(sid, { sessionUpdate: "agent_message_chunk", content: { type: "text", text: chunk } }), controller.signal, ioFor(sid, session));
|
|
121
|
+
} catch (e) {
|
|
122
|
+
if (cancelled) return reply(id, { stopReason: "cancelled" });
|
|
123
|
+
return replyError(id, -32603, e.message);
|
|
124
|
+
} finally {
|
|
125
|
+
session.controller = null;
|
|
126
|
+
session.open = [];
|
|
127
|
+
}
|
|
128
|
+
return reply(id, { stopReason: cancelled ? "cancelled" : "end_turn" });
|
|
129
|
+
}
|
|
130
|
+
if (id !== void 0) return replyError(id, -32601, "Method not found");
|
|
131
|
+
};
|
|
132
|
+
return new Promise((resolve) => {
|
|
133
|
+
let buf = "";
|
|
134
|
+
const onData = (chunk) => {
|
|
135
|
+
buf += chunk.toString();
|
|
136
|
+
let idx = buf.indexOf("\n");
|
|
137
|
+
while (idx >= 0) {
|
|
138
|
+
const line = buf.slice(0, idx);
|
|
139
|
+
buf = buf.slice(idx + 1);
|
|
140
|
+
idx = buf.indexOf("\n");
|
|
141
|
+
if (!line.trim()) continue;
|
|
142
|
+
let msg;
|
|
143
|
+
try {
|
|
144
|
+
msg = JSON.parse(line);
|
|
145
|
+
} catch {
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
void handle(msg);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
const onEnd = () => {
|
|
152
|
+
input.removeListener("data", onData);
|
|
153
|
+
resolve();
|
|
154
|
+
};
|
|
155
|
+
input.on("data", onData);
|
|
156
|
+
input.on("end", onEnd);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function runtimeAgent(cwd, allowAll = false) {
|
|
160
|
+
let rt;
|
|
161
|
+
return {
|
|
162
|
+
async run(text, onChunk, signal, io) {
|
|
163
|
+
if (!rt) {
|
|
164
|
+
const { parseCliArgs } = await import("./args-W6BNKY7K.js");
|
|
165
|
+
const { createRuntime } = await import("./setup-OV3NWQN5.js");
|
|
166
|
+
rt = createRuntime({ cwd, args: { ...parseCliArgs([]), allowAll } });
|
|
167
|
+
}
|
|
168
|
+
if (io && !allowAll) rt.agent.askPermission = (req) => io.askPermission(req);
|
|
169
|
+
rt.agent.onEvent = (event) => {
|
|
170
|
+
if (event.type === "text") onChunk(event.delta);
|
|
171
|
+
else if (event.type === "toolStart") io?.toolStart(event.id, event.tool, event.target);
|
|
172
|
+
else if (event.type === "toolEnd") io?.toolEnd(event.id, event.output, event.isError);
|
|
173
|
+
};
|
|
174
|
+
await rt.agent.run(text, signal);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
export {
|
|
179
|
+
ACP_PROTOCOL_VERSION,
|
|
180
|
+
runAcp,
|
|
181
|
+
runtimeAgent
|
|
182
|
+
};
|
package/dist/acp.d.ts
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { PermissionAnswer, PermissionAsk } from './agent';
|
|
2
|
+
export declare const ACP_PROTOCOL_VERSION = 1;
|
|
3
|
+
/** What the agent reports to the editor besides text: tool calls, and permission questions the editor answers. */
|
|
4
|
+
export interface AcpIo {
|
|
5
|
+
toolStart(id: string, tool: string, target: string): void;
|
|
6
|
+
toolEnd(id: string, output: string, isError: boolean): void;
|
|
7
|
+
askPermission(req: PermissionAsk): Promise<PermissionAnswer>;
|
|
8
|
+
}
|
|
9
|
+
/** The minimum an ACP client needs: run one prompt, stream text chunks, allow cancellation. */
|
|
10
|
+
export interface AcpAgent {
|
|
11
|
+
run(text: string, onChunk: (text: string) => void, signal: AbortSignal, io?: AcpIo): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Agent Client Protocol over newline-delimited JSON-RPC (the transport editors like Zed use).
|
|
15
|
+
* Implements the subset: initialize, session/new, session/prompt (streaming session/update
|
|
16
|
+
* notifications: text chunks and tool calls), session/request_permission, session/cancel;
|
|
17
|
+
* anything else with an id gets -32601.
|
|
18
|
+
*/
|
|
19
|
+
export declare function runAcp(input: NodeJS.ReadableStream, output: NodeJS.WritableStream, opts: {
|
|
20
|
+
cwd: string;
|
|
21
|
+
newAgent: (cwd: string) => AcpAgent;
|
|
22
|
+
}): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Production agent: one bccli runtime per ACP session. Permission questions go to the editor
|
|
25
|
+
* (session/request_permission); `allowAll` skips them and runs everything unasked.
|
|
26
|
+
*/
|
|
27
|
+
export declare function runtimeAgent(cwd: string, allowAll?: boolean): AcpAgent;
|