@botconnector/bccli 0.4.0-beta.8 → 0.4.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/README.en.md +242 -0
- package/README.md +95 -3
- package/dist/acp-ATIL4JOZ.js +182 -0
- package/dist/args-J5ONVGIF.js +13 -0
- package/dist/chunk-45SDLMTV.js +341 -0
- package/dist/chunk-6M5X2KZE.js +8 -0
- package/dist/chunk-7F3IWBPQ.js +191 -0
- package/dist/{chunk-CLN4Z5E3.js → chunk-BLOYFIAD.js} +6 -3
- package/dist/chunk-BNA74HPN.js +145 -0
- package/dist/{chunk-DX7CZTBB.js → chunk-BQ2IGPBR.js} +14 -9
- package/dist/chunk-JL5ZCSP2.js +76 -0
- package/dist/chunk-KEMYIGCP.js +235 -0
- package/dist/{chunk-BFZXRKW5.js → chunk-L7QI6JN2.js} +24 -2
- package/dist/chunk-LACUWBWS.js +361 -0
- package/dist/chunk-M7CALSP3.js +733 -0
- package/dist/{chunk-ELML4KVQ.js → chunk-O7M3TGIW.js} +34 -2
- package/dist/chunk-PSO7R5AD.js +10 -0
- package/dist/chunk-PUN4HMAG.js +940 -0
- package/dist/{chunk-SJH3YLW4.js → chunk-QDQU6VY2.js} +60 -6
- package/dist/chunk-QZKLZELZ.js +64 -0
- package/dist/{chunk-7S6JXQCH.js → chunk-SPRNLS7K.js} +2 -1
- package/dist/chunk-TLPFQIS2.js +231 -0
- package/dist/chunk-TVALKHFB.js +2143 -0
- package/dist/chunk-UZWJQF67.js +500 -0
- package/dist/chunk-XBO5GACQ.js +56 -0
- package/dist/cli.js +162 -1383
- package/dist/completion-HPPFDAPB.js +125 -0
- package/dist/{config-YUNKPCNB.js → config-COPNMMV6.js} +5 -2
- package/dist/config-RZ5JONMX.js +30 -0
- package/dist/ghBotCli-IBCZIWT5.js +677 -0
- package/dist/integrationCli-P75R2VSC.js +685 -0
- package/dist/login-SYIQP46J.js +16 -0
- package/dist/{mcpCli-DZWQPTOS.js → mcpCli-QUV5SD64.js} +42 -9
- package/dist/modelsCli-TRRB5LX4.js +36 -0
- package/dist/npmRunner-LU43GM3W.js +46 -0
- package/dist/oauthLogin-6FWQABJ7.js +210 -0
- package/dist/pluginsCli-GNW4TPVV.js +284 -0
- package/dist/prCli-5IMV3VNQ.js +78 -0
- package/dist/providerCli-FAOZHOKW.js +15 -0
- package/dist/sdk.js +5490 -0
- package/dist/serve-6QLBJUYW.js +178 -0
- package/dist/serve-JG7RLIUD.js +515 -0
- package/dist/session-KBAQ4BZ5.js +12 -0
- package/dist/setup-FJAWDWV4.js +24 -0
- package/dist/statsCli-CF3R7ATL.js +353 -0
- package/dist/transferCli-TK2GSVRK.js +71 -0
- package/dist/ui-B3CJ6TGE.js +2365 -0
- package/dist/update-K5IQ2MYR.js +145 -0
- package/package.json +25 -4
- package/dist/args-FLTRM57K.js +0 -12
- package/dist/chunk-2MGINW4O.js +0 -114
- package/dist/chunk-IM3KMPVZ.js +0 -52
- package/dist/chunk-KV27KTOX.js +0 -254
- package/dist/chunk-U7GK73CK.js +0 -341
- package/dist/chunk-Z7PM3LTC.js +0 -93
- package/dist/login-JXFORO3J.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/dist/chunk-U7GK73CK.js
DELETED
|
@@ -1,341 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
hasKey,
|
|
4
|
-
providerName,
|
|
5
|
-
removeGlobalProvider,
|
|
6
|
-
writeGlobalConfig
|
|
7
|
-
} from "./chunk-7S6JXQCH.js";
|
|
8
|
-
import {
|
|
9
|
-
reasoningPayload
|
|
10
|
-
} from "./chunk-CLN4Z5E3.js";
|
|
11
|
-
import {
|
|
12
|
-
PRESETS,
|
|
13
|
-
loadConfig,
|
|
14
|
-
readCredentials,
|
|
15
|
-
saveCredential
|
|
16
|
-
} from "./chunk-2MGINW4O.js";
|
|
17
|
-
|
|
18
|
-
// src/thinking.ts
|
|
19
|
-
var OPEN = "<think>";
|
|
20
|
-
var CLOSE = "</think>";
|
|
21
|
-
function partialTag(text, tag) {
|
|
22
|
-
for (let n = Math.min(tag.length - 1, text.length); n > 0; n--) if (tag.startsWith(text.slice(-n))) return n;
|
|
23
|
-
return 0;
|
|
24
|
-
}
|
|
25
|
-
var ThinkSplitter = class {
|
|
26
|
-
inside = false;
|
|
27
|
-
held = "";
|
|
28
|
-
push(delta) {
|
|
29
|
-
let rest = this.held + delta;
|
|
30
|
-
this.held = "";
|
|
31
|
-
let text = "";
|
|
32
|
-
let thinking = "";
|
|
33
|
-
while (rest) {
|
|
34
|
-
const tag = this.inside ? CLOSE : OPEN;
|
|
35
|
-
const at = rest.indexOf(tag);
|
|
36
|
-
if (at >= 0) {
|
|
37
|
-
if (this.inside) thinking += rest.slice(0, at);
|
|
38
|
-
else text += rest.slice(0, at);
|
|
39
|
-
rest = rest.slice(at + tag.length);
|
|
40
|
-
this.inside = !this.inside;
|
|
41
|
-
continue;
|
|
42
|
-
}
|
|
43
|
-
const keep = partialTag(rest, tag);
|
|
44
|
-
const out = rest.slice(0, rest.length - keep);
|
|
45
|
-
if (this.inside) thinking += out;
|
|
46
|
-
else text += out;
|
|
47
|
-
this.held = rest.slice(rest.length - keep);
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
return { text, thinking };
|
|
51
|
-
}
|
|
52
|
-
/** Whatever was held back as a possible tag start is plain text after all. */
|
|
53
|
-
flush() {
|
|
54
|
-
const held = this.held;
|
|
55
|
-
this.held = "";
|
|
56
|
-
return this.inside ? { text: "", thinking: held } : { text: held, thinking: "" };
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
function splitThinking(text) {
|
|
60
|
-
const s = new ThinkSplitter();
|
|
61
|
-
const a = s.push(text);
|
|
62
|
-
const b = s.flush();
|
|
63
|
-
return { text: a.text + b.text, thinking: a.thinking + b.thinking };
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// src/provider.ts
|
|
67
|
-
var ProviderError = class extends Error {
|
|
68
|
-
constructor(message, status) {
|
|
69
|
-
super(message);
|
|
70
|
-
this.status = status;
|
|
71
|
-
}
|
|
72
|
-
status;
|
|
73
|
-
};
|
|
74
|
-
var retryable = (status) => status === 429 || status >= 500;
|
|
75
|
-
function detectRepetition(text) {
|
|
76
|
-
const tail = text.slice(-600);
|
|
77
|
-
for (let len = 1; len <= 12; len++) {
|
|
78
|
-
const unit = tail.slice(-len);
|
|
79
|
-
if (unit.length < len || !unit.trim()) continue;
|
|
80
|
-
let i = tail.length;
|
|
81
|
-
let count = 0;
|
|
82
|
-
while (i >= len && tail.slice(i - len, i) === unit) {
|
|
83
|
-
count++;
|
|
84
|
-
i -= len;
|
|
85
|
-
}
|
|
86
|
-
if (count >= 20 && count * len >= 300) return text.length - count * len;
|
|
87
|
-
}
|
|
88
|
-
return -1;
|
|
89
|
-
}
|
|
90
|
-
function sleep(ms, signal) {
|
|
91
|
-
return new Promise((resolve, reject) => {
|
|
92
|
-
const timer = setTimeout(resolve, ms);
|
|
93
|
-
signal?.addEventListener(
|
|
94
|
-
"abort",
|
|
95
|
-
() => {
|
|
96
|
-
clearTimeout(timer);
|
|
97
|
-
reject(signal.reason);
|
|
98
|
-
},
|
|
99
|
-
{ once: true }
|
|
100
|
-
);
|
|
101
|
-
});
|
|
102
|
-
}
|
|
103
|
-
function errorMessage(body) {
|
|
104
|
-
try {
|
|
105
|
-
const parsed = JSON.parse(body);
|
|
106
|
-
return parsed?.error?.message ?? parsed?.message ?? body.slice(0, 300);
|
|
107
|
-
} catch {
|
|
108
|
-
return body.slice(0, 300);
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
var toUsage = (u) => u ? { inputTokens: u.prompt_tokens ?? 0, outputTokens: u.completion_tokens ?? 0 } : void 0;
|
|
112
|
-
async function readStream(res, onText, onThinking) {
|
|
113
|
-
let text = "";
|
|
114
|
-
let thinking = "";
|
|
115
|
-
const splitter = new ThinkSplitter();
|
|
116
|
-
const emit = (part) => {
|
|
117
|
-
if (part.thinking) {
|
|
118
|
-
thinking += part.thinking;
|
|
119
|
-
onThinking?.(part.thinking);
|
|
120
|
-
}
|
|
121
|
-
if (part.text) {
|
|
122
|
-
text += part.text;
|
|
123
|
-
onText?.(part.text);
|
|
124
|
-
if (loopAt < 0) loopAt = detectRepetition(text);
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
let usage;
|
|
128
|
-
let finishReason;
|
|
129
|
-
const calls = [];
|
|
130
|
-
const byIndex = /* @__PURE__ */ new Map();
|
|
131
|
-
let current;
|
|
132
|
-
const decoder = new TextDecoder();
|
|
133
|
-
let buffer = "";
|
|
134
|
-
let loopAt = -1;
|
|
135
|
-
const handle = (line) => {
|
|
136
|
-
if (!line.startsWith("data:")) return;
|
|
137
|
-
const data = line.slice(5).trim();
|
|
138
|
-
if (!data || data === "[DONE]") return;
|
|
139
|
-
let event;
|
|
140
|
-
try {
|
|
141
|
-
event = JSON.parse(data);
|
|
142
|
-
} catch {
|
|
143
|
-
return;
|
|
144
|
-
}
|
|
145
|
-
if (event.error) throw new ProviderError(`Error dari provider: ${event.error.message ?? JSON.stringify(event.error)}`);
|
|
146
|
-
if (event.usage) usage = toUsage(event.usage);
|
|
147
|
-
const choice = event.choices?.[0];
|
|
148
|
-
if (!choice) return;
|
|
149
|
-
if (choice.finish_reason) finishReason = choice.finish_reason;
|
|
150
|
-
const delta = choice.delta ?? {};
|
|
151
|
-
const reasoning = delta.reasoning_content || delta.reasoning;
|
|
152
|
-
if (reasoning) emit({ text: "", thinking: reasoning });
|
|
153
|
-
if (delta.content) emit(splitter.push(delta.content));
|
|
154
|
-
for (const tc of delta.tool_calls ?? []) {
|
|
155
|
-
let target = tc.index !== void 0 ? byIndex.get(tc.index) : current;
|
|
156
|
-
if (!target || tc.index === void 0 && tc.id && target.id && target.id !== tc.id) {
|
|
157
|
-
target = { id: "", name: "", arguments: "" };
|
|
158
|
-
calls.push(target);
|
|
159
|
-
if (tc.index !== void 0) byIndex.set(tc.index, target);
|
|
160
|
-
}
|
|
161
|
-
current = target;
|
|
162
|
-
if (tc.id) target.id = tc.id;
|
|
163
|
-
if (tc.function?.name && !target.name) target.name = tc.function.name;
|
|
164
|
-
if (tc.function?.arguments) target.arguments += tc.function.arguments;
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
for await (const chunk of res.body) {
|
|
168
|
-
buffer += decoder.decode(chunk, { stream: true });
|
|
169
|
-
let newline = buffer.indexOf("\n");
|
|
170
|
-
while (newline >= 0 && loopAt < 0) {
|
|
171
|
-
handle(buffer.slice(0, newline).trim());
|
|
172
|
-
buffer = buffer.slice(newline + 1);
|
|
173
|
-
newline = buffer.indexOf("\n");
|
|
174
|
-
}
|
|
175
|
-
if (loopAt >= 0) return { text: text.slice(0, loopAt), toolCalls: [], thinking: thinking || void 0, usage, finishReason: "repetition" };
|
|
176
|
-
}
|
|
177
|
-
handle(buffer.trim());
|
|
178
|
-
emit(splitter.flush());
|
|
179
|
-
const toolCalls = calls.map((call, index) => ({ ...call, id: call.id || `call_${index}` }));
|
|
180
|
-
return { text, toolCalls, thinking: thinking || void 0, usage, finishReason };
|
|
181
|
-
}
|
|
182
|
-
async function readJson(res) {
|
|
183
|
-
const body = await res.json();
|
|
184
|
-
const choice = body.choices?.[0];
|
|
185
|
-
const toolCalls = (choice?.message?.tool_calls ?? []).map((tc, i) => ({
|
|
186
|
-
id: tc.id || `call_${i}`,
|
|
187
|
-
name: tc.function?.name ?? "",
|
|
188
|
-
arguments: tc.function?.arguments ?? ""
|
|
189
|
-
}));
|
|
190
|
-
const split = splitThinking(choice?.message?.content ?? "");
|
|
191
|
-
const thinking = (choice?.message?.reasoning_content || choice?.message?.reasoning || "") + split.thinking;
|
|
192
|
-
return { text: split.text, toolCalls, thinking: thinking || void 0, usage: toUsage(body.usage), finishReason: choice?.finish_reason };
|
|
193
|
-
}
|
|
194
|
-
function createProvider({ baseURL, apiKey, model, providerId, fetch: doFetch = fetch, retryDelayMs = 1e3 }) {
|
|
195
|
-
const headers = { "content-type": "application/json" };
|
|
196
|
-
if (apiKey) headers.authorization = `Bearer ${apiKey}`;
|
|
197
|
-
if (/^https:\/\/api\.botconnector\.id\/v1\/?$/.test(baseURL) && apiKey?.startsWith("bc_live_")) {
|
|
198
|
-
headers["x-botconnector-client"] = "bccli";
|
|
199
|
-
headers["x-botconnector-client-version"] = "0.4.0";
|
|
200
|
-
}
|
|
201
|
-
async function post(path, body, signal) {
|
|
202
|
-
let lastError;
|
|
203
|
-
for (let attempt = 0; attempt < 4; attempt++) {
|
|
204
|
-
if (attempt > 0) await sleep(retryDelayMs * 2 ** (attempt - 1), signal);
|
|
205
|
-
let res;
|
|
206
|
-
try {
|
|
207
|
-
res = await doFetch(`${baseURL}${path}`, { method: "POST", headers, body: JSON.stringify(body), signal });
|
|
208
|
-
} catch (error) {
|
|
209
|
-
if (signal?.aborted) throw error;
|
|
210
|
-
lastError = new ProviderError(`Tidak bisa terhubung ke ${baseURL}: ${error.message}`);
|
|
211
|
-
continue;
|
|
212
|
-
}
|
|
213
|
-
if (res.ok) return res;
|
|
214
|
-
const text = await res.text().catch(() => "");
|
|
215
|
-
lastError = new ProviderError(`${res.status} dari ${baseURL}: ${errorMessage(text)}`, res.status);
|
|
216
|
-
if (!retryable(res.status)) throw lastError;
|
|
217
|
-
}
|
|
218
|
-
throw lastError ?? new ProviderError("Permintaan gagal");
|
|
219
|
-
}
|
|
220
|
-
return {
|
|
221
|
-
async chat({ messages, tools, signal, onText, onThinking, reasoning = "auto" }) {
|
|
222
|
-
let reasoningOverride;
|
|
223
|
-
try {
|
|
224
|
-
reasoningOverride = reasoningPayload(providerId, reasoning);
|
|
225
|
-
} catch (error) {
|
|
226
|
-
throw new ProviderError(error.message);
|
|
227
|
-
}
|
|
228
|
-
const res = await post(
|
|
229
|
-
"/chat/completions",
|
|
230
|
-
{ model, messages, stream: true, stream_options: { include_usage: true }, ...tools?.length ? { tools } : {}, ...reasoningOverride },
|
|
231
|
-
signal
|
|
232
|
-
);
|
|
233
|
-
if ((res.headers.get("content-type") ?? "").includes("application/json")) return readJson(res);
|
|
234
|
-
if (!res.body) throw new ProviderError("Respons provider kosong");
|
|
235
|
-
return readStream(res, onText, onThinking);
|
|
236
|
-
},
|
|
237
|
-
async listModels() {
|
|
238
|
-
const res = await doFetch(`${baseURL}/models`, { headers });
|
|
239
|
-
if (!res.ok) throw new ProviderError(`${res.status} saat mengambil daftar model`, res.status);
|
|
240
|
-
const body = await res.json();
|
|
241
|
-
return (body.data ?? []).map((m) => m.id).sort();
|
|
242
|
-
}
|
|
243
|
-
};
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
// src/models.ts
|
|
247
|
-
function order(ids) {
|
|
248
|
-
const presetIds = PRESETS.map((p) => p.id);
|
|
249
|
-
const presets = presetIds.filter((id) => ids.includes(id));
|
|
250
|
-
const custom = ids.filter((id) => !presetIds.includes(id)).sort();
|
|
251
|
-
return [...presets, ...custom];
|
|
252
|
-
}
|
|
253
|
-
async function listAllModels(config, env = process.env, opts = {}) {
|
|
254
|
-
const timeoutMs = opts.timeoutMs ?? 5e3;
|
|
255
|
-
const baseFetch = opts.fetch ?? fetch;
|
|
256
|
-
const untrusted = new Set(config.projectProviders ?? []);
|
|
257
|
-
const ids = order(Object.keys(config.providers)).filter((id) => opts.only ? id === opts.only : !untrusted.has(id) && hasKey(config, id, env));
|
|
258
|
-
const results = await Promise.all(
|
|
259
|
-
ids.map(async (id) => {
|
|
260
|
-
const provider = config.providers[id];
|
|
261
|
-
const apiKey = (opts.keyOverride && id === opts.only ? opts.keyOverride : void 0) || (provider.apiKeyEnv ? env[provider.apiKeyEnv] : void 0) || readCredentials(env)[id] || void 0;
|
|
262
|
-
const local = !provider.apiKeyEnv;
|
|
263
|
-
const timedFetch = ((input, init) => baseFetch(input, { ...init, signal: AbortSignal.timeout(timeoutMs) }));
|
|
264
|
-
const list = createProvider({ baseURL: provider.baseURL.replace(/\/+$/, ""), apiKey, model: "", fetch: timedFetch }).listModels();
|
|
265
|
-
let timer;
|
|
266
|
-
const timeout = new Promise((_, reject) => {
|
|
267
|
-
timer = setTimeout(() => reject(new Error("timeout")), timeoutMs);
|
|
268
|
-
});
|
|
269
|
-
try {
|
|
270
|
-
const models = await Promise.race([list, timeout]);
|
|
271
|
-
return { providerId: id, providerName: providerName(config, id), models };
|
|
272
|
-
} catch {
|
|
273
|
-
if (local && !opts.only) return void 0;
|
|
274
|
-
return { providerId: id, providerName: providerName(config, id), models: [], error: "tidak bisa dihubungi" };
|
|
275
|
-
} finally {
|
|
276
|
-
clearTimeout(timer);
|
|
277
|
-
}
|
|
278
|
-
})
|
|
279
|
-
);
|
|
280
|
-
return results.filter((g) => !!g);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
// src/providerCli.ts
|
|
284
|
-
async function addProviderKey(providerId, key, deps) {
|
|
285
|
-
const config = loadConfig(deps.cwd, deps.env);
|
|
286
|
-
const [group] = await listAllModels(config, deps.env, { only: providerId, fetch: deps.fetch, keyOverride: key || void 0 });
|
|
287
|
-
if (!group || group.error) return { ok: false, error: `API key ditolak atau ${providerName(config, providerId)} tidak bisa dihubungi.` };
|
|
288
|
-
if (key) saveCredential(providerId, key, deps.env);
|
|
289
|
-
return { ok: true, models: group.models.length };
|
|
290
|
-
}
|
|
291
|
-
async function runProviderCommand(args, deps) {
|
|
292
|
-
const [action = "list", id] = args.subArgs;
|
|
293
|
-
const config = loadConfig(deps.cwd, deps.env);
|
|
294
|
-
if (action === "list") {
|
|
295
|
-
for (const pid of Object.keys(config.providers)) {
|
|
296
|
-
const mark = hasKey(config, pid, deps.env) ? "\u2713" : "\u25CB";
|
|
297
|
-
deps.out(`${mark} ${pid.padEnd(14)} ${providerName(config, pid).padEnd(20)} ${config.providers[pid].baseURL}`);
|
|
298
|
-
}
|
|
299
|
-
return 0;
|
|
300
|
-
}
|
|
301
|
-
if (!id) {
|
|
302
|
-
deps.err(`Pemakaian: bccli provider ${action} <id>`);
|
|
303
|
-
return 1;
|
|
304
|
-
}
|
|
305
|
-
if (action === "remove") {
|
|
306
|
-
removeGlobalProvider(id, deps.env);
|
|
307
|
-
deps.out(`${id} dihapus.`);
|
|
308
|
-
return 0;
|
|
309
|
-
}
|
|
310
|
-
if (action !== "add") {
|
|
311
|
-
deps.err(`Aksi tidak dikenal: ${action}. Pakai list, add, atau remove.`);
|
|
312
|
-
return 1;
|
|
313
|
-
}
|
|
314
|
-
const preset = PRESETS.find((p) => p.id === id);
|
|
315
|
-
if (!preset && !config.providers[id]) {
|
|
316
|
-
if (!args.url) {
|
|
317
|
-
deps.err(`${id} bukan preset. Untuk provider custom tambahkan --url <base URL OpenAI-compatible>.`);
|
|
318
|
-
return 1;
|
|
319
|
-
}
|
|
320
|
-
writeGlobalConfig(
|
|
321
|
-
{ providers: { [id]: { baseURL: args.url, ...args.name ? { name: args.name } : {}, ...args.keyEnv ? { apiKeyEnv: args.keyEnv } : {} } } },
|
|
322
|
-
deps.env
|
|
323
|
-
);
|
|
324
|
-
}
|
|
325
|
-
const needsKey = !!loadConfig(deps.cwd, deps.env).providers[id].apiKeyEnv || !preset;
|
|
326
|
-
const key = needsKey ? await deps.readSecret(`API key untuk ${id} (kosongkan bila tidak perlu): `) : "";
|
|
327
|
-
const result = await addProviderKey(id, key, deps);
|
|
328
|
-
if (!result.ok) {
|
|
329
|
-
deps.err(result.error);
|
|
330
|
-
return 1;
|
|
331
|
-
}
|
|
332
|
-
deps.out(`${id} siap. ${result.models} model tersedia.`);
|
|
333
|
-
return 0;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
export {
|
|
337
|
-
createProvider,
|
|
338
|
-
listAllModels,
|
|
339
|
-
addProviderKey,
|
|
340
|
-
runProviderCommand
|
|
341
|
-
};
|
package/dist/chunk-Z7PM3LTC.js
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
3
|
-
MODE_ORDER
|
|
4
|
-
} from "./chunk-ELML4KVQ.js";
|
|
5
|
-
import {
|
|
6
|
-
REASONING_LEVELS,
|
|
7
|
-
isReasoningLevel
|
|
8
|
-
} from "./chunk-CLN4Z5E3.js";
|
|
9
|
-
import {
|
|
10
|
-
ConfigError
|
|
11
|
-
} from "./chunk-2MGINW4O.js";
|
|
12
|
-
|
|
13
|
-
// src/args.ts
|
|
14
|
-
import { parseArgs } from "util";
|
|
15
|
-
var HELP_TEXT = `BCCLI \u2014 agent AI BotConnector di terminal
|
|
16
|
-
|
|
17
|
-
Pemakaian:
|
|
18
|
-
bccli [tugas] mode interaktif (opsional langsung dengan tugas)
|
|
19
|
-
bccli -p "tugas" jalankan satu tugas tanpa interaksi (skrip/CI)
|
|
20
|
-
bccli login [provider] simpan API key (default: bc-cloud)
|
|
21
|
-
bccli models daftar model dari provider aktif
|
|
22
|
-
bccli provider list|add <id>|remove <id> kelola provider (custom: --url <url> [--name N] [--key-env ENV])
|
|
23
|
-
bccli mcp list|add <nama>|remove <nama> kelola server MCP (katalog, atau --url <url>)
|
|
24
|
-
|
|
25
|
-
Opsi:
|
|
26
|
-
-m, --model <provider/model> pilih model, contoh bc-cloud/glm-5.3-flash
|
|
27
|
-
--reasoning <level> auto | off | low | medium | high | max
|
|
28
|
-
-c, --continue lanjutkan sesi terakhir di folder ini
|
|
29
|
-
-r, --resume pilih sesi untuk dilanjutkan
|
|
30
|
-
--allow-all jalankan semua alat tanpa minta izin
|
|
31
|
-
--allowed-tools <a,b> alat yang boleh tanpa izin: bash, edit, fetch
|
|
32
|
-
--permission-mode <mode> default | acceptEdits | plan | allowAll
|
|
33
|
-
-v, --version versi
|
|
34
|
-
-h, --help bantuan ini`;
|
|
35
|
-
function parseCliArgs(argv) {
|
|
36
|
-
const { values, positionals } = parseArgs({
|
|
37
|
-
args: argv,
|
|
38
|
-
allowPositionals: true,
|
|
39
|
-
options: {
|
|
40
|
-
print: { type: "boolean", short: "p" },
|
|
41
|
-
model: { type: "string", short: "m" },
|
|
42
|
-
reasoning: { type: "string" },
|
|
43
|
-
continue: { type: "boolean", short: "c" },
|
|
44
|
-
resume: { type: "boolean", short: "r" },
|
|
45
|
-
"allow-all": { type: "boolean" },
|
|
46
|
-
"allowed-tools": { type: "string" },
|
|
47
|
-
"permission-mode": { type: "string" },
|
|
48
|
-
help: { type: "boolean", short: "h" },
|
|
49
|
-
version: { type: "boolean", short: "v" },
|
|
50
|
-
url: { type: "string" },
|
|
51
|
-
name: { type: "string" },
|
|
52
|
-
"key-env": { type: "string" },
|
|
53
|
-
value: { type: "string", multiple: true }
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
const reasoning = values.reasoning;
|
|
57
|
-
if (reasoning && !isReasoningLevel(reasoning)) {
|
|
58
|
-
throw new ConfigError(`--reasoning harus salah satu dari: ${REASONING_LEVELS.join(", ")}`);
|
|
59
|
-
}
|
|
60
|
-
const mode = values["permission-mode"];
|
|
61
|
-
if (mode && !MODE_ORDER.includes(mode)) {
|
|
62
|
-
throw new ConfigError(`--permission-mode harus salah satu dari: ${MODE_ORDER.join(", ")}`);
|
|
63
|
-
}
|
|
64
|
-
const [first, ...rest] = positionals;
|
|
65
|
-
const SUBCOMMANDS = ["login", "models", "provider", "mcp"];
|
|
66
|
-
const command = SUBCOMMANDS.includes(first) ? first : "run";
|
|
67
|
-
const words = command === "run" ? positionals : rest;
|
|
68
|
-
return {
|
|
69
|
-
command,
|
|
70
|
-
prompt: command === "run" && words.length ? words.join(" ") : void 0,
|
|
71
|
-
print: !!values.print,
|
|
72
|
-
model: values.model,
|
|
73
|
-
reasoning,
|
|
74
|
-
continue: !!values.continue,
|
|
75
|
-
resume: !!values.resume,
|
|
76
|
-
allowAll: !!values["allow-all"],
|
|
77
|
-
allowedTools: (values["allowed-tools"] ?? "").split(",").map((s) => s.trim()).filter(Boolean),
|
|
78
|
-
permissionMode: mode,
|
|
79
|
-
help: !!values.help,
|
|
80
|
-
version: !!values.version,
|
|
81
|
-
loginProvider: command === "login" ? rest[0] ?? "bc-cloud" : void 0,
|
|
82
|
-
subArgs: command === "provider" || command === "mcp" ? rest : [],
|
|
83
|
-
url: values.url,
|
|
84
|
-
name: values.name,
|
|
85
|
-
keyEnv: values["key-env"],
|
|
86
|
-
values: values.value ?? []
|
|
87
|
-
};
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
export {
|
|
91
|
-
HELP_TEXT,
|
|
92
|
-
parseCliArgs
|
|
93
|
-
};
|
package/dist/login-JXFORO3J.js
DELETED