bazilion 0.50.0 → 0.52.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/dist/cli.js +316 -90
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +1378 -364
- package/dist/daemon.js.map +1 -1
- package/dist/web/client/assets/AddProviderDialog-BiGLKnu2.js +1 -0
- package/dist/web/client/assets/ConfigPage-DvBzy2MN.js +1 -0
- package/dist/web/client/assets/ConfirmDialog-CiZ5tk9R.js +1 -0
- package/dist/web/client/assets/ConnectionsView-Czkpm2JY.js +1 -0
- package/dist/web/client/assets/Dialog-s_kPtI-W.js +1 -0
- package/dist/web/client/assets/ModelMenu-BfUPoRjV.js +1 -0
- package/dist/web/client/assets/SectionTabs-DENNb6Nw.js +1 -0
- package/dist/web/client/assets/Segmented-Dh77vmpp.js +1 -0
- package/dist/web/client/assets/SkillFindings-Xng11qqx.js +1 -0
- package/dist/web/client/assets/SkillsPicker-hI3YXvib.js +1 -0
- package/dist/web/client/assets/SpawnDialog-CKWFQ6jk.js +1 -0
- package/dist/web/client/assets/Tabs-f6bHvCGn.js +1 -0
- package/dist/web/client/assets/TeamForm-kda1HYZG.js +1 -0
- package/dist/web/client/assets/TeamThread-2rm1JGSk.js +1 -0
- package/dist/web/client/assets/UnsavedChangesGuard-nx6dv2Yw.js +1 -0
- package/dist/web/client/assets/_id-B72mIpcE.js +1 -0
- package/dist/web/client/assets/_id-Bzavnza1.js +1 -0
- package/dist/web/client/assets/access-Yw9jODuk.js +1 -0
- package/dist/web/client/assets/agents-C9xoyL7o.js +1 -0
- package/dist/web/client/assets/agents-TviG16wx.js +1 -0
- package/dist/web/client/assets/api-HC_YzjBy.js +1 -0
- package/dist/web/client/assets/arrow-right-Gm_FDWJ_.js +1 -0
- package/dist/web/client/assets/attention-DmURtlJm.js +1 -0
- package/dist/web/client/assets/check-BjgKoGvU.js +1 -0
- package/dist/web/client/assets/chevron-right-CUZiA2aG.js +1 -0
- package/dist/web/client/assets/config-UZz_mjO5.js +1 -0
- package/dist/web/client/assets/createLucideIcon-C6gOo8sD.js +1 -0
- package/dist/web/client/assets/dist-BWppw70N.js +41 -0
- package/dist/web/client/assets/dist-D2dwY7MR.js +1 -0
- package/dist/web/client/assets/index-Df1oUtAP.js +14 -0
- package/dist/web/client/assets/link-Cbztlp_R.js +1 -0
- package/dist/web/client/assets/login-CPfdaqsV.js +1 -0
- package/dist/web/client/assets/mcp-FlYnNon0.js +1 -0
- package/dist/web/client/assets/model-facts-DoB6QD5y.js +1 -0
- package/dist/web/client/assets/parts-tIDBNsYA.js +1 -0
- package/dist/web/client/assets/plus-CWrKMtvA.js +1 -0
- package/dist/web/client/assets/routes-BZaWCoQj.js +76 -0
- package/dist/web/client/assets/save-f9O-CQia.js +1 -0
- package/dist/web/client/assets/skills-C7yDPC8s.js +1 -0
- package/dist/web/client/assets/style-DDuTFJUu.js +7 -0
- package/dist/web/client/assets/styles-BviXU81u.css +2 -0
- package/dist/web/client/assets/system-CL3Kz36L.js +1 -0
- package/dist/web/client/assets/teams-CQTEF5gV.js +1 -0
- package/dist/web/client/assets/teams-DQ7SqVyF.js +1 -0
- package/dist/web/client/assets/telegram-BLgxtGhZ.js +1 -0
- package/dist/web/client/assets/tools-pOQyGVYo.js +1 -0
- package/dist/web/client/assets/use-resource-C3MBZJop.js +1 -0
- package/dist/web/client/assets/welcome-Hr6JpMef.js +1 -0
- package/dist/web/client/assets/wrench-6BEIqKDn.js +1 -0
- package/dist/web/server/assets/AddProviderDialog-Tn4AskPm.js +613 -0
- package/dist/web/server/assets/{ConfigPage-DSLM5CLw.js → ConfigPage-DqDUujmt.js} +4 -4
- package/dist/web/server/assets/ConfirmDialog-DfaJ--A6.js +52 -0
- package/dist/web/server/assets/{ConnectionsView-DVLNH81Y.js → ConnectionsView-DAG-zNBz.js} +7 -5
- package/dist/web/server/assets/{ConfirmDialog-CvLZgbfY.js → Dialog-aup_yJv5.js} +3 -50
- package/dist/web/server/assets/ModelMenu-DUY9aHkE.js +138 -0
- package/dist/web/server/assets/{Rail-D8LhjS38.js → Rail-BIC_4ptO.js} +8 -66
- package/dist/web/server/assets/{SectionTabs-CNcvxbR8.js → SectionTabs-BGsrf-UQ.js} +5 -4
- package/dist/web/server/assets/Segmented-3ZLdqa5U.js +18 -0
- package/dist/web/server/assets/{SkillFindings-DX8lCMG7.js → SkillFindings-BdATze1A.js} +1 -1
- package/dist/web/server/assets/{SpawnDialog-Brmkl_ll.js → SpawnDialog-D_SMPCG_.js} +11 -8
- package/dist/web/server/assets/{TeamForm-CvQAs2FA.js → TeamForm-ilBaeLI4.js} +1 -1
- package/dist/web/server/assets/{TeamThread-BNJi6gPM.js → TeamThread-DuLlGDcw.js} +4 -19
- package/dist/web/server/assets/{UnsavedChangesGuard-B3Lpl08z.js → UnsavedChangesGuard-DrOvPV14.js} +1 -1
- package/dist/web/server/assets/{_id-CO1PgvyG.js → _id-BsZcsabI.js} +11 -11
- package/dist/web/server/assets/{_id-CA3QO7J5.js → _id-D8Kj0F30.js} +2 -2
- package/dist/web/server/assets/{_id-DIXUiIaB.js → _id-DJnYgisy.js} +2 -2
- package/dist/web/server/assets/{_id-E2N4gZ4O.js → _id-QYifTM9w.js} +3 -3
- package/dist/web/server/assets/{_id-BH1631a8.js → _id-yN0z7VqE.js} +6 -6
- package/dist/web/server/assets/_tanstack-start-manifest_v-D6zrzUC7.js +223 -0
- package/dist/web/server/assets/{tokens-CEdl8puR.js → access-C_pupPks.js} +3 -3
- package/dist/web/server/assets/{tokens-CsqoRt5T.js → access-DKOpcHIJ.js} +10 -10
- package/dist/web/server/assets/{tokens-ByPTGFBQ.js → access-GMGed5O8.js} +5 -5
- package/dist/web/server/assets/{agents-DrkEwIpR.js → agents-B6OR3x99.js} +14 -14
- package/dist/web/server/assets/{agents-CalSKogx.js → agents-B7642eRO.js} +5 -5
- package/dist/web/server/assets/{agents-DPZVni4Q.js → agents-BJ-_oC2e.js} +2 -2
- package/dist/web/server/assets/{agents-CdZvooeQ.js → agents-CjV0w-Zy.js} +2 -2
- package/dist/web/server/assets/{agents-C63VycUw.js → agents-Dy_Q-9lG.js} +3 -3
- package/dist/web/server/assets/{attention-DIyX3VMB.js → attention-CLP4HYBz.js} +3 -3
- package/dist/web/server/assets/{attention-BbE4yc-V.js → attention-DS3O9UmJ.js} +2 -2
- package/dist/web/server/assets/config-DjTGA4iZ.js +17 -0
- package/dist/web/server/assets/config-Q7livfa3.js +1215 -0
- package/dist/web/server/assets/config-X7qWbbpH.js +20 -0
- package/dist/web/server/assets/{Page-KIL1CsME.js → createSsrRpc-GCCF14VW.js} +17 -2
- package/dist/web/server/assets/{mcp-Cf7KzOJ9.js → mcp-BI-FD-JI.js} +5 -5
- package/dist/web/server/assets/{mcp-DE14q5c0.js → mcp-ZARSOxZW.js} +2 -2
- package/dist/web/server/assets/model-facts-mrfrWQne.js +136 -0
- package/dist/web/server/assets/parts-B31PJkhi.js +190 -0
- package/dist/web/server/assets/{router-w2yPgmC1.js → router-Dh2-IvLL.js} +69 -81
- package/dist/web/server/assets/{routes-1FEodTRm.js → routes-BJIJWCIE.js} +3 -3
- package/dist/web/server/assets/{routes-D1NHwz6f.js → routes-C9NawqcV.js} +22 -15
- package/dist/web/server/assets/{routes-B6AO0LjK.js → routes-CDskMy5C.js} +2 -2
- package/dist/web/server/assets/{skills-DC1OTc8n.js → skills-BqLq3ZXq.js} +5 -5
- package/dist/web/server/assets/{skills-CA17GjuZ.js → skills-StN15QhC.js} +2 -2
- package/dist/web/server/assets/system-BtRA2HUs.js +138 -0
- package/dist/web/server/assets/system-Dl-1RhoP.js +12 -0
- package/dist/web/server/assets/system-DtswhLW6.js +18 -0
- package/dist/web/server/assets/{teams-D6Tx-Jyn.js → teams-5PMGvHuM.js} +2 -2
- package/dist/web/server/assets/{teams-OzHTyVi9.js → teams-COaU0wN9.js} +4 -4
- package/dist/web/server/assets/{teams-Cg-QQWpH.js → teams-Ca8W4mvl.js} +5 -5
- package/dist/web/server/assets/{teams-Bm63mbTt.js → teams-CbIPKf99.js} +2 -2
- package/dist/web/server/assets/{telegram-Gy7_9yih.js → telegram-CGol0CKX2.js} +3 -3
- package/dist/web/server/assets/{telegram-xU-vXgef.js → telegram-Cv0D4gyz.js} +5 -5
- package/dist/web/server/assets/{telegram-BJ4l_TA_.js → telegram-Yx8nm6Ei.js} +5 -5
- package/dist/web/server/assets/tools-C-wwWjLI.js +12 -0
- package/dist/web/server/assets/tools-OfD22R-C.js +502 -0
- package/dist/web/server/assets/tools-ioJcPzMW.js +12 -0
- package/dist/web/server/assets/use-resource-DVzK0toP.js +63 -0
- package/dist/web/server/assets/utils-C_uf36nf.js +8 -0
- package/dist/web/server/assets/welcome-CxXMI4HI.js +15 -0
- package/dist/web/server/assets/welcome-FFEbrNT1.js +319 -0
- package/dist/web/server/assets/welcome-jxmpE_Jb.js +26 -0
- package/dist/web/server/assets/{workspace-DeEYMPDX.js → workspace-DaitCM0t.js} +1 -8
- package/dist/web/server/server.js +27 -19
- package/dist/worker.js +277 -153
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
- package/dist/web/client/assets/ConfigPage-_FY--9PB.js +0 -1
- package/dist/web/client/assets/ConfirmDialog-BblXqMVb.js +0 -1
- package/dist/web/client/assets/ConnectionsView-BZHJysCa.js +0 -1
- package/dist/web/client/assets/FieldRow-k05wfDy9.js +0 -1
- package/dist/web/client/assets/ModelSelect-CvOHjUyB.js +0 -1
- package/dist/web/client/assets/SectionTabs-DlfXtepS.js +0 -1
- package/dist/web/client/assets/SkillFindings-CHf5ZGY0.js +0 -1
- package/dist/web/client/assets/SkillsPicker-Cr87y_W-.js +0 -1
- package/dist/web/client/assets/SpawnDialog-C-Ujb4bC.js +0 -1
- package/dist/web/client/assets/Tabs-D0LgBNIk.js +0 -1
- package/dist/web/client/assets/TeamForm-D6EAAF7m.js +0 -1
- package/dist/web/client/assets/TeamThread-DpUOwMoi.js +0 -1
- package/dist/web/client/assets/UnsavedChangesGuard-DTUP7hwu.js +0 -1
- package/dist/web/client/assets/_id-C94dgBDe.js +0 -1
- package/dist/web/client/assets/_id-CxmEfoEp.js +0 -1
- package/dist/web/client/assets/agents-C-bJ5R_0.js +0 -1
- package/dist/web/client/assets/agents-odqBNx-A.js +0 -1
- package/dist/web/client/assets/api-CPzQ_z9m.js +0 -1
- package/dist/web/client/assets/arrow-right-Dyta3p06.js +0 -1
- package/dist/web/client/assets/attention-D0e7o7fh.js +0 -1
- package/dist/web/client/assets/chevron-right-B2YEg9rw.js +0 -1
- package/dist/web/client/assets/config-B7Y5MtpM.js +0 -3
- package/dist/web/client/assets/createLucideIcon-Cgab8gqu.js +0 -1
- package/dist/web/client/assets/index-CNVw44IE.js +0 -54
- package/dist/web/client/assets/jsx-runtime-bzQ4Vb5N.js +0 -1
- package/dist/web/client/assets/link-ClwtaO_E.js +0 -1
- package/dist/web/client/assets/login-Br1F4rQx.js +0 -1
- package/dist/web/client/assets/mcp-B8bIAY6k.js +0 -1
- package/dist/web/client/assets/routes-BZdlkRdC.js +0 -76
- package/dist/web/client/assets/save-ZqeB_I-c.js +0 -1
- package/dist/web/client/assets/services-CPJxDrVG.js +0 -1
- package/dist/web/client/assets/skills-DE_kQQGj.js +0 -1
- package/dist/web/client/assets/style-BWShXY3e.js +0 -7
- package/dist/web/client/assets/styles-Tney8jZq.css +0 -2
- package/dist/web/client/assets/teams-AcuSLc3I.js +0 -1
- package/dist/web/client/assets/teams-tRamPg7O.js +0 -1
- package/dist/web/client/assets/telegram-Ku69-GAv.js +0 -1
- package/dist/web/client/assets/tokens-DuLNZMgi.js +0 -1
- package/dist/web/client/assets/welcome-CrQk6n6I.js +0 -1
- package/dist/web/server/assets/FieldRow-DQBzMtcR.js +0 -173
- package/dist/web/server/assets/ModelSelect-Vwro6OkL.js +0 -43
- package/dist/web/server/assets/_tanstack-start-manifest_v-BVfrV7LQ.js +0 -191
- package/dist/web/server/assets/config-3tPtOmPE.js +0 -12
- package/dist/web/server/assets/config-DJGZiPBJ.js +0 -798
- package/dist/web/server/assets/config-rUqhMjIs.js +0 -25
- package/dist/web/server/assets/createSsrRpc-6LHNEsSK.js +0 -16
- package/dist/web/server/assets/services-BjroGXgC.js +0 -74
- package/dist/web/server/assets/services-Cdk40QHq.js +0 -13
- package/dist/web/server/assets/services-DsHRLL8q.js +0 -12
- package/dist/web/server/assets/welcome-O6Rjd7yO.js +0 -93
package/dist/daemon.js
CHANGED
|
@@ -411,6 +411,7 @@ __export(pool_exports, {
|
|
|
411
411
|
import {
|
|
412
412
|
McpAbortError,
|
|
413
413
|
McpClient,
|
|
414
|
+
McpConnectionClosedError,
|
|
414
415
|
McpSessionExpiredError,
|
|
415
416
|
StdioTransport,
|
|
416
417
|
StreamableHttpTransport,
|
|
@@ -492,7 +493,10 @@ ${stderr.slice(-2e3)}` : ""}`
|
|
|
492
493
|
client.onClose(() => void conn.close());
|
|
493
494
|
client.onError((error) => {
|
|
494
495
|
console.warn(`mcp: server ${server3.name}: ${error.message}`);
|
|
495
|
-
if (error instanceof McpSessionExpiredError)
|
|
496
|
+
if (error instanceof McpSessionExpiredError) {
|
|
497
|
+
conn.sessionLost = error;
|
|
498
|
+
void conn.close();
|
|
499
|
+
}
|
|
496
500
|
});
|
|
497
501
|
client.onNotification("notifications/tools/list_changed", () => {
|
|
498
502
|
conn.toolsStale = true;
|
|
@@ -519,6 +523,9 @@ function connection(server3, connect3, signal) {
|
|
|
519
523
|
ready.then(resolve9, reject2).finally(() => signal.removeEventListener("abort", abort));
|
|
520
524
|
});
|
|
521
525
|
}
|
|
526
|
+
function failureOf(conn, error) {
|
|
527
|
+
return conn.sessionLost && error instanceof McpConnectionClosedError ? conn.sessionLost : error;
|
|
528
|
+
}
|
|
522
529
|
async function listMcpTools(server3, connect3, signal) {
|
|
523
530
|
const conn = await connection(server3, connect3, signal);
|
|
524
531
|
if (conn.tools && !conn.toolsStale) return conn.tools;
|
|
@@ -543,8 +550,9 @@ async function listMcpTools(server3, connect3, signal) {
|
|
|
543
550
|
}
|
|
544
551
|
conn.tools = tools;
|
|
545
552
|
return tools;
|
|
546
|
-
} catch (
|
|
553
|
+
} catch (raw) {
|
|
547
554
|
conn.toolsStale = true;
|
|
555
|
+
const error = failureOf(conn, raw);
|
|
548
556
|
if (error instanceof McpSessionExpiredError) await conn.close();
|
|
549
557
|
throw error;
|
|
550
558
|
} finally {
|
|
@@ -563,7 +571,8 @@ async function callMcpTool(server3, rawName, args, options) {
|
|
|
563
571
|
throw new Error(text4 || `MCP tool ${rawName} reported an error`);
|
|
564
572
|
}
|
|
565
573
|
return parts.length ? parts : [{ type: "text", text: "(no content)" }];
|
|
566
|
-
} catch (
|
|
574
|
+
} catch (raw) {
|
|
575
|
+
const error = failureOf(conn, raw);
|
|
567
576
|
if (error instanceof McpSessionExpiredError) await conn.close();
|
|
568
577
|
throw error;
|
|
569
578
|
} finally {
|
|
@@ -1269,7 +1278,7 @@ ${stderr.trim()}` : message));
|
|
|
1269
1278
|
});
|
|
1270
1279
|
});
|
|
1271
1280
|
const { chromium } = await import("playwright");
|
|
1272
|
-
browser = await chromium.connectOverCDP(endpoint2, { timeout:
|
|
1281
|
+
browser = await chromium.connectOverCDP(endpoint2, { timeout: CONNECT_MS2, isLocal: true });
|
|
1273
1282
|
cdp = await browser.newBrowserCDPSession();
|
|
1274
1283
|
await cdp.send("Browser.setDownloadBehavior", { behavior: "deny" });
|
|
1275
1284
|
const context = browser.contexts()[0];
|
|
@@ -1293,11 +1302,12 @@ ${stderr.trim()}` : message));
|
|
|
1293
1302
|
throw error;
|
|
1294
1303
|
}
|
|
1295
1304
|
}
|
|
1296
|
-
var STARTUP_MS, NO_WEBRTC_SCRIPT, sleep, liveGroups, exitHookInstalled;
|
|
1305
|
+
var STARTUP_MS, CONNECT_MS2, NO_WEBRTC_SCRIPT, sleep, liveGroups, exitHookInstalled;
|
|
1297
1306
|
var init_launch = __esm({
|
|
1298
1307
|
"../daemon/src/lib/browser/launch.ts"() {
|
|
1299
1308
|
"use strict";
|
|
1300
|
-
STARTUP_MS =
|
|
1309
|
+
STARTUP_MS = 6e4;
|
|
1310
|
+
CONNECT_MS2 = 15e3;
|
|
1301
1311
|
NO_WEBRTC_SCRIPT = `for (const name of ['RTCPeerConnection', 'webkitRTCPeerConnection', 'mozRTCPeerConnection']) {
|
|
1302
1312
|
Object.defineProperty(window, name, { configurable: false, get() { return undefined } })
|
|
1303
1313
|
}`;
|
|
@@ -1335,15 +1345,15 @@ ${line}` : line;
|
|
|
1335
1345
|
function clip(text4, max = FIELD_CHARS) {
|
|
1336
1346
|
return text4.length <= max ? text4 : `${text4.slice(0, cutAt(text4, max))}\u2026`;
|
|
1337
1347
|
}
|
|
1338
|
-
function formatSnapshot(
|
|
1339
|
-
const total =
|
|
1348
|
+
function formatSnapshot(snapshot3, n = 1) {
|
|
1349
|
+
const total = snapshot3.pages.length;
|
|
1340
1350
|
const more = n < total ? ` \u2014 read on with browser_snapshot {"page": ${n + 1}}` : "";
|
|
1341
1351
|
return [
|
|
1342
|
-
`- Page URL: ${clip(
|
|
1343
|
-
`- Page title: ${clip(
|
|
1344
|
-
`- Snapshot of ${
|
|
1352
|
+
`- Page URL: ${clip(snapshot3.url)}`,
|
|
1353
|
+
`- Page title: ${clip(snapshot3.title)}`,
|
|
1354
|
+
`- Snapshot of ${snapshot3.tabId}, page ${n} of ${total}${more}`,
|
|
1345
1355
|
"",
|
|
1346
|
-
|
|
1356
|
+
snapshot3.pages[n - 1] ?? ""
|
|
1347
1357
|
].join("\n");
|
|
1348
1358
|
}
|
|
1349
1359
|
function capText(text4) {
|
|
@@ -3415,14 +3425,6 @@ function listAvailableModels(db) {
|
|
|
3415
3425
|
}
|
|
3416
3426
|
return out;
|
|
3417
3427
|
}
|
|
3418
|
-
function groupAvailableModels(db) {
|
|
3419
|
-
const groups = [];
|
|
3420
|
-
for (const provider of listEnabled(db)) {
|
|
3421
|
-
const models = list5(db, provider);
|
|
3422
|
-
if (models.length > 0) groups.push({ provider, models });
|
|
3423
|
-
}
|
|
3424
|
-
return groups;
|
|
3425
|
-
}
|
|
3426
3428
|
function isSetupComplete(db) {
|
|
3427
3429
|
return listAvailableModels(db).length > 0;
|
|
3428
3430
|
}
|
|
@@ -4195,23 +4197,29 @@ function localServer(provider) {
|
|
|
4195
4197
|
endpoint: { env: provider.urlEnv, fallback: provider.url },
|
|
4196
4198
|
local: provider.local,
|
|
4197
4199
|
fields: [
|
|
4198
|
-
{ envVar: provider.urlEnv, kind: "config", label: "
|
|
4199
|
-
{ envVar: provider.keyEnv, kind: "secret", ...provider.keyField }
|
|
4200
|
+
{ envVar: provider.urlEnv, kind: "config", label: "Address", placeholder: provider.url },
|
|
4201
|
+
{ envVar: provider.keyEnv, kind: "secret", advanced: true, ...provider.keyField }
|
|
4200
4202
|
]
|
|
4201
4203
|
};
|
|
4202
4204
|
}
|
|
4203
4205
|
var PROVIDERS = [
|
|
4204
4206
|
{
|
|
4205
4207
|
id: "openai-codex",
|
|
4206
|
-
displayName: "
|
|
4207
|
-
hint: "Use your ChatGPT Plus
|
|
4208
|
+
displayName: "ChatGPT",
|
|
4209
|
+
hint: "Use your ChatGPT Plus, Pro or Team plan. No API key.",
|
|
4208
4210
|
// Credentials come from the OAuth flow (/api/auth/openai), not from fields.
|
|
4209
|
-
fields: []
|
|
4211
|
+
fields: [],
|
|
4212
|
+
popular: true,
|
|
4213
|
+
suggested: ["gpt-6.1-sol", "gpt-6-luna"]
|
|
4214
|
+
},
|
|
4215
|
+
{
|
|
4216
|
+
...apiKey("openai", "OpenAI", "OPENAI_API_KEY", {
|
|
4217
|
+
hint: "GPT models \xB7 platform.openai.com",
|
|
4218
|
+
placeholder: "sk-..."
|
|
4219
|
+
}),
|
|
4220
|
+
popular: true,
|
|
4221
|
+
suggested: ["gpt-6.1-sol", "gpt-6-luna"]
|
|
4210
4222
|
},
|
|
4211
|
-
apiKey("openai", "OpenAI", "OPENAI_API_KEY", {
|
|
4212
|
-
hint: "GPT models \xB7 platform.openai.com",
|
|
4213
|
-
placeholder: "sk-..."
|
|
4214
|
-
}),
|
|
4215
4223
|
{
|
|
4216
4224
|
id: "anthropic",
|
|
4217
4225
|
displayName: "Anthropic",
|
|
@@ -4223,14 +4231,21 @@ var PROVIDERS = [
|
|
|
4223
4231
|
envVar: "ANTHROPIC_OAUTH_TOKEN",
|
|
4224
4232
|
kind: "secret",
|
|
4225
4233
|
label: "OAuth token (alternative to API key)",
|
|
4226
|
-
description: "Takes precedence over ANTHROPIC_API_KEY when set"
|
|
4234
|
+
description: "Takes precedence over ANTHROPIC_API_KEY when set",
|
|
4235
|
+
advanced: true
|
|
4227
4236
|
}
|
|
4228
|
-
]
|
|
4237
|
+
],
|
|
4238
|
+
popular: true,
|
|
4239
|
+
suggested: ["claude-fable-5-2", "claude-haiku-5-5"]
|
|
4240
|
+
},
|
|
4241
|
+
{
|
|
4242
|
+
...apiKey("google", "Google Gemini", "GEMINI_API_KEY", {
|
|
4243
|
+
hint: "Gemini models \xB7 ai.google.dev (free tier available)",
|
|
4244
|
+
placeholder: "AIza..."
|
|
4245
|
+
}),
|
|
4246
|
+
popular: true,
|
|
4247
|
+
suggested: ["gemini-4-argon", "gemini-3.8-flash"]
|
|
4229
4248
|
},
|
|
4230
|
-
apiKey("google", "Google (Gemini)", "GEMINI_API_KEY", {
|
|
4231
|
-
hint: "Gemini models \xB7 ai.google.dev (free tier available)",
|
|
4232
|
-
placeholder: "AIza..."
|
|
4233
|
-
}),
|
|
4234
4249
|
{
|
|
4235
4250
|
id: "google-vertex",
|
|
4236
4251
|
displayName: "Google Vertex AI",
|
|
@@ -4258,7 +4273,8 @@ var PROVIDERS = [
|
|
|
4258
4273
|
envVar: "GOOGLE_VERTEX_CREDENTIALS_JSON",
|
|
4259
4274
|
kind: "secret",
|
|
4260
4275
|
label: "Explicit credentials JSON (learning reviews)",
|
|
4261
|
-
description: "Service-account or ADC JSON given only to the learning-review worker, which cannot read ambient ADC files."
|
|
4276
|
+
description: "Service-account or ADC JSON given only to the learning-review worker, which cannot read ambient ADC files.",
|
|
4277
|
+
advanced: true
|
|
4262
4278
|
}
|
|
4263
4279
|
]
|
|
4264
4280
|
},
|
|
@@ -4414,11 +4430,15 @@ var PROVIDERS = [
|
|
|
4414
4430
|
{ envVar: "CLOUDFLARE_ACCOUNT_ID", kind: "config", label: "Account ID" }
|
|
4415
4431
|
]
|
|
4416
4432
|
},
|
|
4417
|
-
|
|
4418
|
-
|
|
4419
|
-
|
|
4420
|
-
|
|
4421
|
-
|
|
4433
|
+
{
|
|
4434
|
+
...apiKey("openrouter", "OpenRouter", "OPENROUTER_API_KEY", {
|
|
4435
|
+
hint: "Many providers through one key \xB7 openrouter.ai",
|
|
4436
|
+
placeholder: "sk-or-...",
|
|
4437
|
+
modelsUrl: "https://openrouter.ai/api/v1"
|
|
4438
|
+
}),
|
|
4439
|
+
popular: true,
|
|
4440
|
+
suggested: ["~anthropic/claude-sonnet-latest", "~anthropic/claude-haiku-latest"]
|
|
4441
|
+
},
|
|
4422
4442
|
{
|
|
4423
4443
|
id: "vercel-ai-gateway",
|
|
4424
4444
|
displayName: "Vercel AI Gateway",
|
|
@@ -4431,7 +4451,8 @@ var PROVIDERS = [
|
|
|
4431
4451
|
envVar: "AI_GATEWAY_BASE_URL",
|
|
4432
4452
|
kind: "config",
|
|
4433
4453
|
label: "Base URL (optional)",
|
|
4434
|
-
placeholder: "https://ai-gateway.vercel.sh/v1"
|
|
4454
|
+
placeholder: "https://ai-gateway.vercel.sh/v1",
|
|
4455
|
+
advanced: true
|
|
4435
4456
|
}
|
|
4436
4457
|
]
|
|
4437
4458
|
},
|
|
@@ -4517,6 +4538,11 @@ function isProviderConfigured(id, env) {
|
|
|
4517
4538
|
if (provider.configured) return provider.configured(env);
|
|
4518
4539
|
return (provider.keyEnv ?? []).some((name) => Boolean(env[name]));
|
|
4519
4540
|
}
|
|
4541
|
+
function providersUsingField(envVar) {
|
|
4542
|
+
return PROVIDERS.filter(
|
|
4543
|
+
(provider) => provider.fields.some((field) => field.envVar === envVar)
|
|
4544
|
+
).map((provider) => provider.id);
|
|
4545
|
+
}
|
|
4520
4546
|
function providerModelsUrl(id, env) {
|
|
4521
4547
|
const provider = findProvider(id);
|
|
4522
4548
|
if (!provider?.local && !provider?.modelsUrl) return void 0;
|
|
@@ -4524,33 +4550,75 @@ function providerModelsUrl(id, env) {
|
|
|
4524
4550
|
}
|
|
4525
4551
|
|
|
4526
4552
|
// ../daemon/src/core/image-generation-config.ts
|
|
4527
|
-
var
|
|
4528
|
-
|
|
4529
|
-
|
|
4530
|
-
|
|
4531
|
-
|
|
4532
|
-
|
|
4553
|
+
var IMAGE_ROUTES = [
|
|
4554
|
+
{
|
|
4555
|
+
id: "openai-codex:gpt-image-2",
|
|
4556
|
+
model: "GPT Image 2",
|
|
4557
|
+
provider: "openai-codex",
|
|
4558
|
+
label: "GPT Image 2 \xB7 ChatGPT sign-in",
|
|
4559
|
+
billing: "Uses your ChatGPT subscription"
|
|
4560
|
+
},
|
|
4561
|
+
{
|
|
4562
|
+
id: "openai:gpt-image-2",
|
|
4563
|
+
model: "GPT Image 2",
|
|
4564
|
+
provider: "openai",
|
|
4565
|
+
label: "GPT Image 2 \xB7 OpenAI API key",
|
|
4566
|
+
billing: "Billed per image by OpenAI"
|
|
4567
|
+
},
|
|
4568
|
+
{
|
|
4569
|
+
id: "openrouter:google/gemini-3.1-flash-image",
|
|
4570
|
+
model: "Gemini 3.1 Flash Image",
|
|
4571
|
+
provider: "openrouter",
|
|
4572
|
+
label: "Gemini 3.1 Flash Image \xB7 OpenRouter",
|
|
4573
|
+
billing: "Billed by OpenRouter"
|
|
4574
|
+
},
|
|
4575
|
+
{
|
|
4576
|
+
id: "openrouter:openai/gpt-image-2",
|
|
4577
|
+
model: "GPT Image 2",
|
|
4578
|
+
provider: "openrouter",
|
|
4579
|
+
label: "GPT Image 2 \xB7 OpenRouter",
|
|
4580
|
+
billing: "Billed by OpenRouter"
|
|
4581
|
+
}
|
|
4533
4582
|
];
|
|
4583
|
+
var IMAGE_MODEL_CHOICES = ["off", ...IMAGE_ROUTES.map(({ id }) => id)];
|
|
4584
|
+
function isImageModel(provider, model) {
|
|
4585
|
+
return IMAGE_ROUTES.some((route) => route.id === `${provider}:${model}`);
|
|
4586
|
+
}
|
|
4587
|
+
var ROUTE_KEY = { openai: "OPENAI_API_KEY", openrouter: "OPENROUTER_API_KEY" };
|
|
4588
|
+
function imageRouteNeeds(route, env, codexConnected) {
|
|
4589
|
+
if (route.provider === "openai-codex") return codexConnected ? null : "a ChatGPT sign-in";
|
|
4590
|
+
if (env[ROUTE_KEY[route.provider]]?.trim()) return null;
|
|
4591
|
+
return route.provider === "openai" ? "an OpenAI API key" : "an OpenRouter API key";
|
|
4592
|
+
}
|
|
4534
4593
|
function imageRoute(env, codexConnected) {
|
|
4535
4594
|
const model = env.BAZILION_IMAGE_MODEL || "off";
|
|
4536
4595
|
if (model === "off") return { ready: false, reason: "Image generation is off." };
|
|
4537
|
-
|
|
4538
|
-
|
|
4539
|
-
const {
|
|
4540
|
-
const provider =
|
|
4596
|
+
const route = IMAGE_ROUTES.find(({ id }) => id === model);
|
|
4597
|
+
if (!route) return { ready: false, reason: `Unknown image model "${model}".` };
|
|
4598
|
+
const { modelId } = parseModelString(model);
|
|
4599
|
+
const provider = route.provider;
|
|
4541
4600
|
if (provider === "openai-codex")
|
|
4542
4601
|
return codexConnected ? { ready: true, model, provider, modelId } : {
|
|
4543
4602
|
ready: false,
|
|
4544
|
-
reason: `${model} needs a ChatGPT login:
|
|
4603
|
+
reason: `${model} needs a ChatGPT login: sign in under Setup, Models, or run bazilion auth openai login.`
|
|
4545
4604
|
};
|
|
4546
|
-
const key2 = provider
|
|
4605
|
+
const key2 = ROUTE_KEY[provider];
|
|
4547
4606
|
const apiKey2 = env[key2]?.trim();
|
|
4548
4607
|
return apiKey2 ? { ready: true, model, provider, modelId, apiKey: apiKey2 } : { ready: false, reason: `${model} needs ${key2}.` };
|
|
4549
4608
|
}
|
|
4550
4609
|
|
|
4551
4610
|
// ../daemon/src/core/services.ts
|
|
4611
|
+
var yesNo = (fallback) => ({
|
|
4612
|
+
type: "switch",
|
|
4613
|
+
on: "true",
|
|
4614
|
+
off: "false",
|
|
4615
|
+
default: fallback
|
|
4616
|
+
});
|
|
4617
|
+
var BROWSER_ON = { envVar: "BROWSER_ENABLED", is: ["true"] };
|
|
4618
|
+
var OWN_BROWSER = { envVar: "BROWSER_ATTACH", is: ["false"] };
|
|
4619
|
+
var RUNNING_BROWSER = { envVar: "BROWSER_ATTACH", is: ["true"] };
|
|
4552
4620
|
var SERVICES = [
|
|
4553
|
-
// LLM providers: one
|
|
4621
|
+
// LLM providers: one entry per row of the provider table.
|
|
4554
4622
|
...PROVIDERS.map(
|
|
4555
4623
|
({ id, displayName, hint, fields: fields2 }) => ({
|
|
4556
4624
|
id,
|
|
@@ -4560,199 +4628,269 @@ var SERVICES = [
|
|
|
4560
4628
|
fields: fields2
|
|
4561
4629
|
})
|
|
4562
4630
|
),
|
|
4563
|
-
// ---
|
|
4564
|
-
{
|
|
4565
|
-
id: "web-search",
|
|
4566
|
-
displayName: "Web search",
|
|
4567
|
-
category: "service",
|
|
4568
|
-
team: "Web Search",
|
|
4569
|
-
hint: "The web_search tool of every Agent turn. Auto uses Brave when BRAVE_API_KEY is set, else SearXNG when SEARXNG_URL is set, else the search hosted by an Agent on an OpenAI (API key) or ChatGPT model.",
|
|
4570
|
-
fields: [
|
|
4571
|
-
{
|
|
4572
|
-
envVar: "BAZILION_WEB_SEARCH_ROUTE",
|
|
4573
|
-
kind: "config",
|
|
4574
|
-
label: "Search backend",
|
|
4575
|
-
options: ["auto", "brave", "searxng", "native", "off"],
|
|
4576
|
-
description: "auto (default), brave, searxng, native (the Agent\u2019s own OpenAI or ChatGPT model) or off. A chosen backend that is not configured leaves Agents without web_search."
|
|
4577
|
-
}
|
|
4578
|
-
]
|
|
4579
|
-
},
|
|
4631
|
+
// --- Model functions ---
|
|
4580
4632
|
{
|
|
4581
4633
|
id: "image-generation",
|
|
4582
4634
|
displayName: "Image generation",
|
|
4583
|
-
|
|
4584
|
-
|
|
4635
|
+
// Chosen under Images on the Models page; the field is here for `bazilion config`.
|
|
4636
|
+
category: "function",
|
|
4585
4637
|
hint: "The image_generate tool: images are saved to Team Results. At most four image_generate calls per turn.",
|
|
4586
4638
|
fields: [
|
|
4587
4639
|
{
|
|
4588
4640
|
envVar: "BAZILION_IMAGE_MODEL",
|
|
4589
4641
|
kind: "config",
|
|
4590
4642
|
label: "Image model",
|
|
4591
|
-
|
|
4592
|
-
|
|
4593
|
-
|
|
4594
|
-
|
|
4595
|
-
|
|
4596
|
-
|
|
4597
|
-
|
|
4643
|
+
input: {
|
|
4644
|
+
type: "choice",
|
|
4645
|
+
default: "off",
|
|
4646
|
+
options: [
|
|
4647
|
+
{ value: "off", label: "Off" },
|
|
4648
|
+
...IMAGE_ROUTES.map((route) => ({ value: route.id, label: route.label }))
|
|
4649
|
+
]
|
|
4598
4650
|
},
|
|
4599
|
-
description: "Off by default. API-key routes are billed per image; the ChatGPT
|
|
4651
|
+
description: "Off by default. API-key routes are billed per image; the ChatGPT sign-in uses your subscription."
|
|
4600
4652
|
}
|
|
4601
4653
|
]
|
|
4602
4654
|
},
|
|
4655
|
+
// --- Tools: what Agents can do besides thinking ---
|
|
4603
4656
|
{
|
|
4604
|
-
id: "
|
|
4605
|
-
displayName: "
|
|
4606
|
-
category: "
|
|
4607
|
-
|
|
4608
|
-
|
|
4657
|
+
id: "web-search",
|
|
4658
|
+
displayName: "Web search",
|
|
4659
|
+
category: "tool",
|
|
4660
|
+
hint: "Where an Agent\u2019s searches go.",
|
|
4661
|
+
footnote: "Applies to every Agent, in every kind of turn.",
|
|
4609
4662
|
fields: [
|
|
4610
4663
|
{
|
|
4611
|
-
envVar: "
|
|
4612
|
-
kind: "
|
|
4613
|
-
label: "
|
|
4614
|
-
|
|
4615
|
-
|
|
4664
|
+
envVar: "BAZILION_WEB_SEARCH_ROUTE",
|
|
4665
|
+
kind: "config",
|
|
4666
|
+
label: "Search with",
|
|
4667
|
+
input: {
|
|
4668
|
+
type: "choice",
|
|
4669
|
+
default: "auto",
|
|
4670
|
+
options: [
|
|
4671
|
+
{
|
|
4672
|
+
value: "auto",
|
|
4673
|
+
label: "Automatic",
|
|
4674
|
+
hint: "Brave when a key is saved, else SearXNG, else the model\u2019s own search."
|
|
4675
|
+
},
|
|
4676
|
+
{
|
|
4677
|
+
value: "brave",
|
|
4678
|
+
label: "Brave Search",
|
|
4679
|
+
hint: "Needs the key below. Free tier at brave.com/search/api."
|
|
4680
|
+
},
|
|
4681
|
+
{
|
|
4682
|
+
value: "searxng",
|
|
4683
|
+
label: "SearXNG",
|
|
4684
|
+
hint: "Your own instance, at the address below."
|
|
4685
|
+
},
|
|
4686
|
+
{
|
|
4687
|
+
value: "native",
|
|
4688
|
+
label: "The model\u2019s own search",
|
|
4689
|
+
hint: "Only Agents on OpenAI or ChatGPT models can search."
|
|
4690
|
+
},
|
|
4691
|
+
{ value: "off", label: "Off", hint: "Agents cannot search the web." }
|
|
4692
|
+
]
|
|
4693
|
+
}
|
|
4616
4694
|
},
|
|
4695
|
+
{ envVar: "BRAVE_API_KEY", kind: "secret", label: "Brave API key", placeholder: "BSA\u2026" },
|
|
4617
4696
|
{
|
|
4618
|
-
envVar: "
|
|
4697
|
+
envVar: "SEARXNG_URL",
|
|
4619
4698
|
kind: "config",
|
|
4620
|
-
label: "
|
|
4621
|
-
placeholder: "https://
|
|
4699
|
+
label: "SearXNG address",
|
|
4700
|
+
placeholder: "https://searxng.example.com",
|
|
4701
|
+
input: { type: "text", format: "url" }
|
|
4622
4702
|
}
|
|
4623
4703
|
]
|
|
4624
4704
|
},
|
|
4625
4705
|
{
|
|
4626
|
-
id: "
|
|
4627
|
-
displayName: "
|
|
4628
|
-
category: "
|
|
4629
|
-
|
|
4630
|
-
hint: "Web search tool \xB7 free tier at brave.com/search/api/",
|
|
4631
|
-
fields: [{ envVar: "BRAVE_API_KEY", kind: "secret", label: "API key", placeholder: "BSA..." }]
|
|
4632
|
-
},
|
|
4633
|
-
{
|
|
4634
|
-
id: "searxng",
|
|
4635
|
-
displayName: "SearXNG",
|
|
4636
|
-
category: "service",
|
|
4637
|
-
team: "Web Search",
|
|
4638
|
-
hint: "Self-hosted meta-search engine \xB7 searxng.org",
|
|
4706
|
+
id: "web-pages",
|
|
4707
|
+
displayName: "Web pages",
|
|
4708
|
+
category: "tool",
|
|
4709
|
+
hint: "How an Agent reads a page it was given or found. The built-in reader is always on and needs no account.",
|
|
4639
4710
|
fields: [
|
|
4640
4711
|
{
|
|
4641
|
-
envVar: "
|
|
4712
|
+
envVar: "FIRECRAWL_API_KEY",
|
|
4713
|
+
kind: "secret",
|
|
4714
|
+
label: "Firecrawl API key",
|
|
4715
|
+
placeholder: "fc-\u2026",
|
|
4716
|
+
description: "Optional, for pages that need JavaScript: used only when the built-in reader gets too little text. Free tier at firecrawl.dev."
|
|
4717
|
+
},
|
|
4718
|
+
{
|
|
4719
|
+
envVar: "FIRECRAWL_URL",
|
|
4642
4720
|
kind: "config",
|
|
4643
|
-
label: "
|
|
4644
|
-
placeholder: "https://
|
|
4721
|
+
label: "Firecrawl address",
|
|
4722
|
+
placeholder: "https://api.firecrawl.dev",
|
|
4723
|
+
description: "Only for a Firecrawl you host yourself.",
|
|
4724
|
+
input: { type: "text", format: "url" },
|
|
4725
|
+
advanced: true
|
|
4645
4726
|
}
|
|
4646
4727
|
]
|
|
4647
4728
|
},
|
|
4648
4729
|
{
|
|
4649
|
-
id: "
|
|
4650
|
-
displayName: "
|
|
4651
|
-
category: "
|
|
4652
|
-
|
|
4653
|
-
|
|
4730
|
+
id: "browser",
|
|
4731
|
+
displayName: "Browser",
|
|
4732
|
+
category: "tool",
|
|
4733
|
+
hint: "Lets an Agent open pages, click, fill forms and stay logged in.",
|
|
4734
|
+
footnote: "Each Agent\u2019s browser is stopped and reset under Browser in its Agent tab.",
|
|
4654
4735
|
fields: [
|
|
4655
4736
|
{
|
|
4656
|
-
envVar: "
|
|
4737
|
+
envVar: "BROWSER_ENABLED",
|
|
4657
4738
|
kind: "config",
|
|
4658
|
-
label: "
|
|
4659
|
-
|
|
4660
|
-
description: "Use off or dangerous (classified commands require per-call approval). Unattended turns auto-deny; interactive turns may approve once."
|
|
4739
|
+
label: "Agents can use a browser",
|
|
4740
|
+
input: yesNo(true)
|
|
4661
4741
|
},
|
|
4662
4742
|
{
|
|
4663
|
-
envVar: "
|
|
4743
|
+
envVar: "BROWSER_ATTACH",
|
|
4664
4744
|
kind: "config",
|
|
4665
|
-
label: "
|
|
4666
|
-
|
|
4667
|
-
|
|
4668
|
-
|
|
4745
|
+
label: "Which browser",
|
|
4746
|
+
when: [BROWSER_ON],
|
|
4747
|
+
input: {
|
|
4748
|
+
type: "choice",
|
|
4749
|
+
default: "false",
|
|
4750
|
+
options: [
|
|
4751
|
+
{
|
|
4752
|
+
value: "false",
|
|
4753
|
+
label: "A browser of its own for each Agent",
|
|
4754
|
+
hint: "Its logins are kept apart from yours and from other Agents."
|
|
4755
|
+
},
|
|
4756
|
+
{
|
|
4757
|
+
value: "true",
|
|
4758
|
+
label: "My running Chrome",
|
|
4759
|
+
hint: "Agents work in your Chrome or Chromium, with your logins, in tabs of their own. Allow it first at chrome://inspect/#remote-debugging."
|
|
4760
|
+
}
|
|
4761
|
+
]
|
|
4762
|
+
}
|
|
4669
4763
|
},
|
|
4670
4764
|
{
|
|
4671
|
-
envVar: "
|
|
4765
|
+
envVar: "BROWSER_HEADLESS",
|
|
4672
4766
|
kind: "config",
|
|
4673
|
-
label: "
|
|
4674
|
-
|
|
4675
|
-
|
|
4767
|
+
label: "Show the browser window",
|
|
4768
|
+
description: "Off: it works out of sight. Not used with your running Chrome.",
|
|
4769
|
+
// The setting is "headless": the window shows when it is false.
|
|
4770
|
+
input: { type: "switch", on: "false", off: "true", default: false },
|
|
4771
|
+
advanced: true,
|
|
4772
|
+
when: [BROWSER_ON, OWN_BROWSER]
|
|
4676
4773
|
},
|
|
4677
4774
|
{
|
|
4678
|
-
envVar: "
|
|
4775
|
+
envVar: "BROWSER_ALLOW_PRIVATE_NETWORK",
|
|
4679
4776
|
kind: "config",
|
|
4680
|
-
label: "
|
|
4681
|
-
|
|
4682
|
-
|
|
4683
|
-
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
{
|
|
4687
|
-
id: "browser",
|
|
4688
|
-
displayName: "Browser Automation",
|
|
4689
|
-
category: "service",
|
|
4690
|
-
team: "Browser",
|
|
4691
|
-
hint: 'Each Agent gets its own persistent browser profile (cookies, logins), kept across turns and Team moves and excluded from backups. Reset under Browser in the web workspace, or deleting the Agent, removes it. With "Use my running browser" on, Agents work in your own Chrome or Chromium instead.',
|
|
4692
|
-
fields: [
|
|
4777
|
+
label: "Reach addresses on your own network",
|
|
4778
|
+
description: "Off is safer. On is for local development only.",
|
|
4779
|
+
input: yesNo(false),
|
|
4780
|
+
advanced: true,
|
|
4781
|
+
when: [BROWSER_ON]
|
|
4782
|
+
},
|
|
4693
4783
|
{
|
|
4694
|
-
envVar: "
|
|
4784
|
+
envVar: "BROWSER_IDLE_MS",
|
|
4695
4785
|
kind: "config",
|
|
4696
|
-
label: "
|
|
4697
|
-
|
|
4698
|
-
|
|
4786
|
+
label: "Close an idle browser after",
|
|
4787
|
+
input: {
|
|
4788
|
+
type: "number",
|
|
4789
|
+
default: 9e5,
|
|
4790
|
+
min: 6e4,
|
|
4791
|
+
max: 864e5,
|
|
4792
|
+
unit: "minutes",
|
|
4793
|
+
scale: 6e4
|
|
4794
|
+
},
|
|
4795
|
+
advanced: true,
|
|
4796
|
+
when: [BROWSER_ON]
|
|
4699
4797
|
},
|
|
4700
4798
|
{
|
|
4701
|
-
envVar: "
|
|
4799
|
+
envVar: "BROWSER_MAX_SESSIONS",
|
|
4702
4800
|
kind: "config",
|
|
4703
|
-
label: "
|
|
4704
|
-
|
|
4705
|
-
|
|
4801
|
+
label: "Browsers open at the same time",
|
|
4802
|
+
input: { type: "number", default: 4, min: 1, max: 64, unit: "at most" },
|
|
4803
|
+
advanced: true,
|
|
4804
|
+
when: [BROWSER_ON]
|
|
4706
4805
|
},
|
|
4707
4806
|
{
|
|
4708
|
-
envVar: "
|
|
4807
|
+
envVar: "BROWSER_EXECUTABLE_PATH",
|
|
4709
4808
|
kind: "config",
|
|
4710
|
-
label: "
|
|
4711
|
-
placeholder: "
|
|
4712
|
-
description: "
|
|
4809
|
+
label: "Browser program",
|
|
4810
|
+
placeholder: "/usr/bin/brave-browser",
|
|
4811
|
+
description: "A Chromium-family browser to use. Left empty, Bazilion uses the first installed Chrome, Brave, Edge or Chromium, and downloads Chromium once when there is none.",
|
|
4812
|
+
input: { type: "text", format: "path" },
|
|
4813
|
+
advanced: true,
|
|
4814
|
+
when: [BROWSER_ON, OWN_BROWSER]
|
|
4713
4815
|
},
|
|
4714
4816
|
{
|
|
4715
4817
|
envVar: "BROWSER_ATTACH_URL",
|
|
4716
4818
|
kind: "config",
|
|
4717
|
-
label: "
|
|
4819
|
+
label: "Address of the running browser",
|
|
4718
4820
|
placeholder: "http://127.0.0.1:9222",
|
|
4719
|
-
description:
|
|
4720
|
-
|
|
4821
|
+
description: "For a browser started with --remote-debugging-port. Left empty, Bazilion finds the running Chrome or Chromium itself.",
|
|
4822
|
+
input: { type: "text", format: "url" },
|
|
4823
|
+
advanced: true,
|
|
4824
|
+
when: [BROWSER_ON, RUNNING_BROWSER]
|
|
4825
|
+
}
|
|
4826
|
+
]
|
|
4827
|
+
},
|
|
4828
|
+
{
|
|
4829
|
+
id: "commands",
|
|
4830
|
+
displayName: "Commands",
|
|
4831
|
+
category: "tool",
|
|
4832
|
+
hint: "Where an Agent\u2019s shell commands run, and what it must ask first.",
|
|
4833
|
+
footnote: "A Team can name a Docker image of its own in its settings.",
|
|
4834
|
+
fields: [
|
|
4721
4835
|
{
|
|
4722
|
-
envVar: "
|
|
4836
|
+
envVar: "BAZILION_BASH_SANDBOX",
|
|
4723
4837
|
kind: "config",
|
|
4724
|
-
label: "
|
|
4725
|
-
|
|
4726
|
-
|
|
4838
|
+
label: "Commands run",
|
|
4839
|
+
input: {
|
|
4840
|
+
type: "choice",
|
|
4841
|
+
default: "off",
|
|
4842
|
+
options: [
|
|
4843
|
+
{
|
|
4844
|
+
value: "off",
|
|
4845
|
+
label: "On this computer",
|
|
4846
|
+
hint: "No isolation: a command can reach whatever you can."
|
|
4847
|
+
},
|
|
4848
|
+
{
|
|
4849
|
+
value: "docker",
|
|
4850
|
+
label: "In a Docker container",
|
|
4851
|
+
hint: "A fresh container with no network for every command."
|
|
4852
|
+
}
|
|
4853
|
+
]
|
|
4854
|
+
}
|
|
4727
4855
|
},
|
|
4728
4856
|
{
|
|
4729
|
-
envVar: "
|
|
4857
|
+
envVar: "BAZILION_BASH_APPROVAL",
|
|
4730
4858
|
kind: "config",
|
|
4731
|
-
label: "
|
|
4732
|
-
|
|
4733
|
-
|
|
4859
|
+
label: "Ask before dangerous commands",
|
|
4860
|
+
description: "In a chat you allow or deny each one. Schedules, Telegram and inbox turns deny them.",
|
|
4861
|
+
input: { type: "switch", on: "dangerous", off: "off", default: false }
|
|
4734
4862
|
},
|
|
4735
4863
|
{
|
|
4736
|
-
envVar: "
|
|
4864
|
+
envVar: "BAZILION_BASH_SANDBOX_IMAGE",
|
|
4737
4865
|
kind: "config",
|
|
4738
|
-
label: "
|
|
4739
|
-
placeholder: "
|
|
4740
|
-
description: "
|
|
4741
|
-
|
|
4866
|
+
label: "Docker image",
|
|
4867
|
+
placeholder: "debian:bookworm-slim",
|
|
4868
|
+
description: "A local image with /bin/bash. Bazilion never pulls it and never falls back to this computer. A Team can name its own.",
|
|
4869
|
+
input: { type: "text", format: "docker-image" },
|
|
4870
|
+
advanced: true,
|
|
4871
|
+
when: [{ envVar: "BAZILION_BASH_SANDBOX", is: ["docker"] }]
|
|
4872
|
+
}
|
|
4873
|
+
]
|
|
4874
|
+
},
|
|
4875
|
+
{
|
|
4876
|
+
id: "agent-messages",
|
|
4877
|
+
displayName: "Messages between Agents",
|
|
4878
|
+
category: "tool",
|
|
4879
|
+
hint: "Stops Agents from answering each other without end.",
|
|
4880
|
+
fields: [
|
|
4742
4881
|
{
|
|
4743
|
-
envVar: "
|
|
4882
|
+
envVar: "BAZILION_AGENT_LOOP_MAX_HOPS",
|
|
4744
4883
|
kind: "config",
|
|
4745
|
-
label: "
|
|
4746
|
-
|
|
4747
|
-
|
|
4884
|
+
label: "Stop a chain after",
|
|
4885
|
+
description: "The first message between two Agents and this many replies are delivered.",
|
|
4886
|
+
input: { type: "number", default: 8, min: 0, max: 100, unit: "replies" }
|
|
4748
4887
|
}
|
|
4749
4888
|
]
|
|
4750
4889
|
},
|
|
4751
4890
|
// --- External integrations (chat bridges, etc) ---
|
|
4752
|
-
//
|
|
4753
|
-
//
|
|
4754
|
-
//
|
|
4755
|
-
// surfaced through the generic `PUT /api/config/fields/:envVar` endpoint.
|
|
4891
|
+
// Telegram has its own page (`/config/telegram`) with its own flow (preflight, pairing, …).
|
|
4892
|
+
// The fields are here so that the keys are known to the stores and to
|
|
4893
|
+
// `PUT /api/config/fields/:envVar`.
|
|
4756
4894
|
// Daemon-managed internal state keys (watermarks, derived topic ids) live
|
|
4757
4895
|
// in repos/config.ts:INTERNAL_CONFIG_KEYS instead, since the user never
|
|
4758
4896
|
// edits them.
|
|
@@ -4796,7 +4934,9 @@ function servicesByCategory(category) {
|
|
|
4796
4934
|
}
|
|
4797
4935
|
|
|
4798
4936
|
// ../daemon/src/core/repos/config.ts
|
|
4937
|
+
var PROVIDER_CHECKS_KEY = "PROVIDER_CHECKS";
|
|
4799
4938
|
var INTERNAL_CONFIG_KEYS = [
|
|
4939
|
+
PROVIDER_CHECKS_KEY,
|
|
4800
4940
|
// Telegram: polling watermark + derived topic/message ids.
|
|
4801
4941
|
"TELEGRAM_LAST_UPDATE_ID",
|
|
4802
4942
|
"TELEGRAM_SERVICE_TOPIC_ID",
|
|
@@ -5669,7 +5809,8 @@ function readAuthFile(authFile) {
|
|
|
5669
5809
|
};
|
|
5670
5810
|
}
|
|
5671
5811
|
function mergeSecretsIntoEnv(db, password, env = process.env) {
|
|
5672
|
-
|
|
5812
|
+
const { [PROVIDER_CHECKS_KEY]: _checks, ...config } = openConfig(db).getAll();
|
|
5813
|
+
return { ...config, ...openSecrets(db, password).getAll(), ...env };
|
|
5673
5814
|
}
|
|
5674
5815
|
|
|
5675
5816
|
// ../daemon/src/core/skills/import.ts
|
|
@@ -6281,7 +6422,8 @@ function hasDefaultTitle(conversation) {
|
|
|
6281
6422
|
}
|
|
6282
6423
|
function rename(db, agentId, id, title) {
|
|
6283
6424
|
db.raw.run(
|
|
6284
|
-
|
|
6425
|
+
`UPDATE agent_conversations SET title = ?, updated_at = MAX(?, created_at + 1)
|
|
6426
|
+
WHERE agent_id = ? AND id = ?`,
|
|
6285
6427
|
[validTitle(title), Date.now(), agentId, id]
|
|
6286
6428
|
);
|
|
6287
6429
|
const conversation = get16(db, agentId, id);
|
|
@@ -9862,9 +10004,34 @@ function explicitConversationFile(directory, target) {
|
|
|
9862
10004
|
// ../daemon/src/runtime/providers/catalog.ts
|
|
9863
10005
|
import { getBuiltinModels } from "@earendil-works/pi-ai/providers/all";
|
|
9864
10006
|
import { fetch as undiciFetch3 } from "undici";
|
|
9865
|
-
function
|
|
9866
|
-
const models = getBuiltinModels(
|
|
9867
|
-
|
|
10007
|
+
function listCatalogEntries(providerName) {
|
|
10008
|
+
const models = getBuiltinModels(
|
|
10009
|
+
piProviderName(providerName)
|
|
10010
|
+
);
|
|
10011
|
+
return (models ?? []).map((model) => {
|
|
10012
|
+
const input = model.cost?.input ?? 0;
|
|
10013
|
+
const output = model.cost?.output ?? 0;
|
|
10014
|
+
return {
|
|
10015
|
+
id: model.id,
|
|
10016
|
+
// Pi marks the undated alias "(latest)"; the dated copy is told apart by its id.
|
|
10017
|
+
name: (model.name ?? model.id).replace(/ \(latest\)$/, ""),
|
|
10018
|
+
contextWindow: model.contextWindow ?? 0,
|
|
10019
|
+
images: model.input?.includes("image") ?? false,
|
|
10020
|
+
reasoning: model.reasoning ?? false,
|
|
10021
|
+
// Subscription and free endpoints are priced at zero, which says nothing about cost.
|
|
10022
|
+
...input > 0 || output > 0 ? { price: { input, output } } : {}
|
|
10023
|
+
};
|
|
10024
|
+
});
|
|
10025
|
+
}
|
|
10026
|
+
var DATED = /^(.+)-(\d{8}|\d{4}-\d{2}-\d{2})$/;
|
|
10027
|
+
function datedCopies(ids) {
|
|
10028
|
+
const all = new Set(ids);
|
|
10029
|
+
return new Set(
|
|
10030
|
+
ids.filter((id) => {
|
|
10031
|
+
const base = DATED.exec(id)?.[1];
|
|
10032
|
+
return base !== void 0 && all.has(base);
|
|
10033
|
+
})
|
|
10034
|
+
);
|
|
9868
10035
|
}
|
|
9869
10036
|
async function fetchLiveModels(baseUrl, apiKey2, signal) {
|
|
9870
10037
|
try {
|
|
@@ -9875,14 +10042,14 @@ async function fetchLiveModels(baseUrl, apiKey2, signal) {
|
|
|
9875
10042
|
const body = await res.json();
|
|
9876
10043
|
return { models: (body?.data ?? []).flatMap((model) => model.id ? [model.id] : []) };
|
|
9877
10044
|
} catch (err) {
|
|
9878
|
-
|
|
10045
|
+
const cause = err.cause;
|
|
10046
|
+
return { models: [], error: cause?.code ?? cause?.message ?? err.message };
|
|
9879
10047
|
}
|
|
9880
10048
|
}
|
|
9881
|
-
async function
|
|
9882
|
-
const catalog = listCatalogModelsSync(providerName);
|
|
10049
|
+
async function listLiveModels(providerName, env = process.env, signal) {
|
|
9883
10050
|
const url = providerModelsUrl(providerName, env);
|
|
9884
|
-
if (!url) return
|
|
9885
|
-
return
|
|
10051
|
+
if (!url) return void 0;
|
|
10052
|
+
return fetchLiveModels(url, providerApiKey(providerName, env), signal);
|
|
9886
10053
|
}
|
|
9887
10054
|
|
|
9888
10055
|
// ../daemon/src/runtime/worker/spawn.ts
|
|
@@ -10278,12 +10445,12 @@ function assertProviderReady(db, authToken, model) {
|
|
|
10278
10445
|
}
|
|
10279
10446
|
if (!providerState_exports.listEnabled(db).has(providerName)) {
|
|
10280
10447
|
throw new ExecutionUnavailableError(
|
|
10281
|
-
`${providerName}
|
|
10448
|
+
`${providerName} is switched off: connect it under Setup, Models, or run bazilion provider connect ${providerName}`
|
|
10282
10449
|
);
|
|
10283
10450
|
}
|
|
10284
10451
|
if (providerName === "openai-codex" && !hasCredentials(db, authToken)) {
|
|
10285
10452
|
throw new ExecutionUnavailableError(
|
|
10286
|
-
"
|
|
10453
|
+
"ChatGPT is not signed in: sign in under Setup, Models, or run bazilion auth openai login"
|
|
10287
10454
|
);
|
|
10288
10455
|
}
|
|
10289
10456
|
}
|
|
@@ -11739,14 +11906,6 @@ function searchRoute(env, model, codexConnected) {
|
|
|
11739
11906
|
return { backend: null, reason: `Unknown search route "${route}".` };
|
|
11740
11907
|
}
|
|
11741
11908
|
}
|
|
11742
|
-
function searchStatus(env) {
|
|
11743
|
-
const route = env.BAZILION_WEB_SEARCH_ROUTE || "auto";
|
|
11744
|
-
if (route === "off") return "Web search is off.";
|
|
11745
|
-
if (route === "native" || route === "auto" && !env.BRAVE_API_KEY && !env.SEARXNG_URL)
|
|
11746
|
-
return "Hosted search for Agents on OpenAI or ChatGPT models; other Agents have no web_search.";
|
|
11747
|
-
const backend = searchRoute(env, "", false);
|
|
11748
|
-
return backend.backend ? `Web search uses ${backend.backend}.` : backend.reason;
|
|
11749
|
-
}
|
|
11750
11909
|
function text3(value, limit) {
|
|
11751
11910
|
return typeof value === "string" ? value.slice(0, limit) : "";
|
|
11752
11911
|
}
|
|
@@ -13128,6 +13287,740 @@ function webOpenAILoginError(error, signal) {
|
|
|
13128
13287
|
return reason instanceof Error ? reason.message : String(reason);
|
|
13129
13288
|
}
|
|
13130
13289
|
|
|
13290
|
+
// ../daemon/src/core/model-usage.ts
|
|
13291
|
+
function modelUsage(db) {
|
|
13292
|
+
const usage = /* @__PURE__ */ new Map();
|
|
13293
|
+
const entry = (model) => {
|
|
13294
|
+
let found = usage.get(model);
|
|
13295
|
+
if (!found) {
|
|
13296
|
+
found = { agents: 0, templates: [] };
|
|
13297
|
+
usage.set(model, found);
|
|
13298
|
+
}
|
|
13299
|
+
return found;
|
|
13300
|
+
};
|
|
13301
|
+
const defaults = /* @__PURE__ */ new Map();
|
|
13302
|
+
for (const profile of list3(db)) {
|
|
13303
|
+
defaults.set(profile.id, profile.defaultModel);
|
|
13304
|
+
entry(profile.defaultModel).templates.push(profile.name);
|
|
13305
|
+
}
|
|
13306
|
+
for (const agent of list(db)) {
|
|
13307
|
+
const model = agent.modelOverride ?? defaults.get(agent.profileId);
|
|
13308
|
+
if (model) entry(model).agents += 1;
|
|
13309
|
+
}
|
|
13310
|
+
return usage;
|
|
13311
|
+
}
|
|
13312
|
+
|
|
13313
|
+
// ../daemon/src/core/provider-checks.ts
|
|
13314
|
+
function readProviderChecks(db) {
|
|
13315
|
+
const raw = openConfig(db).get(PROVIDER_CHECKS_KEY);
|
|
13316
|
+
if (!raw) return {};
|
|
13317
|
+
try {
|
|
13318
|
+
const parsed = JSON.parse(raw);
|
|
13319
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
13320
|
+
} catch {
|
|
13321
|
+
return {};
|
|
13322
|
+
}
|
|
13323
|
+
}
|
|
13324
|
+
function writeProviderCheck(db, providerId, check) {
|
|
13325
|
+
const checks = readProviderChecks(db);
|
|
13326
|
+
if (check) checks[providerId] = check;
|
|
13327
|
+
else if (providerId in checks) delete checks[providerId];
|
|
13328
|
+
else return;
|
|
13329
|
+
const store = openConfig(db);
|
|
13330
|
+
if (Object.keys(checks).length === 0) store.remove(PROVIDER_CHECKS_KEY);
|
|
13331
|
+
else store.set(PROVIDER_CHECKS_KEY, JSON.stringify(checks));
|
|
13332
|
+
}
|
|
13333
|
+
|
|
13334
|
+
// ../daemon/src/lib/provider-failure.ts
|
|
13335
|
+
var UNREACHABLE = /connection error|econnrefused|enotfound|ehostunreach|enetunreach|etimedout|econnreset|fetch failed|bad port|socket hang up|getaddrinfo|und_err|request aborted|request timed out/;
|
|
13336
|
+
var CREDENTIALS = /invalid.{0,12}api.?key|incorrect api key|invalid x-api-key|invalid_api_key|authentication_error|unauthorized|invalid.{0,12}(access )?token/;
|
|
13337
|
+
var MODEL = /model_not_found|no models loaded|not found, try pulling|not_found_error.{0,40}\bmodel\b|\bmodel\b.{0,80}(not found|does not exist|do not have access|not available|is not supported)|(must be verified|not have access|no access).{0,60}\bmodel\b/;
|
|
13338
|
+
var LIMIT = /insufficient|quota|rate.?limit|billing|\bcredits?\b|overloaded/;
|
|
13339
|
+
function classifyProviderFailure(message, timedOut = false) {
|
|
13340
|
+
const text4 = message.toLowerCase();
|
|
13341
|
+
const status2 = /^(\d{3})\b/.exec(text4)?.[1];
|
|
13342
|
+
if (timedOut || UNREACHABLE.test(text4)) return "unreachable";
|
|
13343
|
+
if (status2 === "401" || CREDENTIALS.test(text4)) return "credentials";
|
|
13344
|
+
if (MODEL.test(text4)) return "model";
|
|
13345
|
+
if (status2 === "402" || status2 === "429" || LIMIT.test(text4)) return "limit";
|
|
13346
|
+
if (status2 === "403") return "credentials";
|
|
13347
|
+
return "other";
|
|
13348
|
+
}
|
|
13349
|
+
function redactDetail(message, secrets) {
|
|
13350
|
+
let detail = message;
|
|
13351
|
+
for (const secret of secrets) {
|
|
13352
|
+
if (secret.length >= 6) detail = detail.split(secret).join("\u2026");
|
|
13353
|
+
}
|
|
13354
|
+
detail = detail.replace(/\s+/g, " ").trim();
|
|
13355
|
+
return detail.length > 400 ? `${detail.slice(0, 400)}\u2026` : detail;
|
|
13356
|
+
}
|
|
13357
|
+
function describeProviderFailure(message, context) {
|
|
13358
|
+
const { provider, modelName, address, timedOut = false } = context;
|
|
13359
|
+
const name = provider.displayName;
|
|
13360
|
+
const local = Boolean(provider.local);
|
|
13361
|
+
const kind = classifyProviderFailure(message, timedOut);
|
|
13362
|
+
const detail = redactDetail(message, context.secrets ?? []);
|
|
13363
|
+
const status2 = /^(\d{3})\b/.exec(message)?.[1];
|
|
13364
|
+
switch (kind) {
|
|
13365
|
+
case "unreachable":
|
|
13366
|
+
if (timedOut)
|
|
13367
|
+
return {
|
|
13368
|
+
kind,
|
|
13369
|
+
title: `${name} did not answer in time`,
|
|
13370
|
+
hint: local ? "A local model can take a while to load. Try again once it is loaded." : "Try again in a moment.",
|
|
13371
|
+
detail
|
|
13372
|
+
};
|
|
13373
|
+
return local ? {
|
|
13374
|
+
kind,
|
|
13375
|
+
title: `Nothing answers at ${address ?? "that address"}`,
|
|
13376
|
+
hint: `Start ${name} and switch its server on, then try again.`,
|
|
13377
|
+
detail
|
|
13378
|
+
} : {
|
|
13379
|
+
kind,
|
|
13380
|
+
title: `${name} could not be reached`,
|
|
13381
|
+
hint: "Check the network of the machine Bazilion runs on, then try again.",
|
|
13382
|
+
detail
|
|
13383
|
+
};
|
|
13384
|
+
case "credentials":
|
|
13385
|
+
if (provider.id === "openai-codex")
|
|
13386
|
+
return { kind, title: "ChatGPT did not accept the sign-in", hint: "Sign in again.", detail };
|
|
13387
|
+
if (local)
|
|
13388
|
+
return {
|
|
13389
|
+
kind,
|
|
13390
|
+
title: `${name} asked for a key it did not get`,
|
|
13391
|
+
hint: "Set the API key the server was started with, under More settings.",
|
|
13392
|
+
detail
|
|
13393
|
+
};
|
|
13394
|
+
return provider.fields.some((field) => field.kind === "secret") ? {
|
|
13395
|
+
kind,
|
|
13396
|
+
title: `${name} did not accept this key`,
|
|
13397
|
+
hint: "Check that the whole key was pasted and that it was not revoked.",
|
|
13398
|
+
detail
|
|
13399
|
+
} : {
|
|
13400
|
+
kind,
|
|
13401
|
+
title: `${name} did not accept the credentials`,
|
|
13402
|
+
hint: provider.hint ?? "Check the credentials in the daemon\u2019s environment.",
|
|
13403
|
+
detail
|
|
13404
|
+
};
|
|
13405
|
+
case "model":
|
|
13406
|
+
return local ? {
|
|
13407
|
+
kind,
|
|
13408
|
+
title: `${name} does not have ${modelName} ready`,
|
|
13409
|
+
hint: `Load it in ${name}, or choose another model.`,
|
|
13410
|
+
detail
|
|
13411
|
+
} : {
|
|
13412
|
+
kind,
|
|
13413
|
+
title: `${name} does not offer ${modelName} to this account`,
|
|
13414
|
+
hint: "Choose another model.",
|
|
13415
|
+
detail
|
|
13416
|
+
};
|
|
13417
|
+
case "limit":
|
|
13418
|
+
return {
|
|
13419
|
+
kind,
|
|
13420
|
+
title: `${name} accepted the key but refused the request`,
|
|
13421
|
+
hint: "A limit was reached or there is no credit left. Check the plan and billing at the provider.",
|
|
13422
|
+
detail
|
|
13423
|
+
};
|
|
13424
|
+
default:
|
|
13425
|
+
return local && status2 === "404" ? {
|
|
13426
|
+
kind,
|
|
13427
|
+
title: `${address ?? "That address"} answered, but not like a model server`,
|
|
13428
|
+
hint: "Check the address. It usually ends in /v1.",
|
|
13429
|
+
detail
|
|
13430
|
+
} : {
|
|
13431
|
+
kind,
|
|
13432
|
+
title: `${name} answered with an error`,
|
|
13433
|
+
hint: "Its own words are in the details.",
|
|
13434
|
+
detail
|
|
13435
|
+
};
|
|
13436
|
+
}
|
|
13437
|
+
}
|
|
13438
|
+
|
|
13439
|
+
// ../daemon/src/lib/setting-fields.ts
|
|
13440
|
+
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
13441
|
+
function readAll(read2) {
|
|
13442
|
+
try {
|
|
13443
|
+
return read2();
|
|
13444
|
+
} catch {
|
|
13445
|
+
return {};
|
|
13446
|
+
}
|
|
13447
|
+
}
|
|
13448
|
+
function readStoredSettings(db, authToken) {
|
|
13449
|
+
return {
|
|
13450
|
+
config: readAll(() => openConfig(db).getAll()),
|
|
13451
|
+
secrets: readAll(() => openSecrets(db, authToken).getAll())
|
|
13452
|
+
};
|
|
13453
|
+
}
|
|
13454
|
+
function mask(value) {
|
|
13455
|
+
if (value.length === 0) return "";
|
|
13456
|
+
return value.length > 8 ? `${value.slice(0, 6)}\u2026` : "***";
|
|
13457
|
+
}
|
|
13458
|
+
var TEXT = { type: "text" };
|
|
13459
|
+
var FALSEY2 = /* @__PURE__ */ new Set(["false", "0", "no", "off"]);
|
|
13460
|
+
var TRUTHY = /* @__PURE__ */ new Set(["true", "1", "yes", "on"]);
|
|
13461
|
+
var DOCKER_IMAGE = /^[A-Za-z0-9][A-Za-z0-9._/:@-]*$/;
|
|
13462
|
+
function isYesNo(values) {
|
|
13463
|
+
return values.length === 2 && values.includes("true") && values.includes("false");
|
|
13464
|
+
}
|
|
13465
|
+
function yesNo2(raw) {
|
|
13466
|
+
return FALSEY2.has(raw.toLowerCase()) ? "false" : "true";
|
|
13467
|
+
}
|
|
13468
|
+
function effectiveValue(input, raw) {
|
|
13469
|
+
const value = raw.trim();
|
|
13470
|
+
switch (input.type) {
|
|
13471
|
+
case "text":
|
|
13472
|
+
return value;
|
|
13473
|
+
case "choice": {
|
|
13474
|
+
const options = input.options.map((option) => option.value);
|
|
13475
|
+
if (value === "") return input.default;
|
|
13476
|
+
if (isYesNo(options)) return yesNo2(value);
|
|
13477
|
+
return options.includes(value) ? value : input.default;
|
|
13478
|
+
}
|
|
13479
|
+
case "switch": {
|
|
13480
|
+
if (value === "") return input.default ? input.on : input.off;
|
|
13481
|
+
if (isYesNo([input.on, input.off])) return yesNo2(value);
|
|
13482
|
+
return value === input.on ? input.on : input.off;
|
|
13483
|
+
}
|
|
13484
|
+
case "number": {
|
|
13485
|
+
const parsed = /^\d+/.test(value) ? Number.parseInt(value, 10) : Number.NaN;
|
|
13486
|
+
const usable = Number.isSafeInteger(parsed) && (parsed > 0 || input.min === 0);
|
|
13487
|
+
return String(usable ? parsed : input.default);
|
|
13488
|
+
}
|
|
13489
|
+
}
|
|
13490
|
+
}
|
|
13491
|
+
function normalizeSetting(field, raw) {
|
|
13492
|
+
const value = raw.trim();
|
|
13493
|
+
if (value === "") return { value: "" };
|
|
13494
|
+
const input = field.input ?? TEXT;
|
|
13495
|
+
const name = field.envVar;
|
|
13496
|
+
switch (input.type) {
|
|
13497
|
+
case "text":
|
|
13498
|
+
if (input.format === "url") {
|
|
13499
|
+
let protocol = "";
|
|
13500
|
+
try {
|
|
13501
|
+
protocol = new URL(value).protocol;
|
|
13502
|
+
} catch {
|
|
13503
|
+
}
|
|
13504
|
+
if (protocol !== "http:" && protocol !== "https:") {
|
|
13505
|
+
return { error: `${name} must be an address that starts with http:// or https://` };
|
|
13506
|
+
}
|
|
13507
|
+
} else if (input.format === "path" && !isAbsolute7(value)) {
|
|
13508
|
+
return { error: `${name} must be a full path, such as /usr/bin/chromium` };
|
|
13509
|
+
} else if (input.format === "docker-image" && !DOCKER_IMAGE.test(value)) {
|
|
13510
|
+
return { error: `${name} is not a Docker image name, such as debian:bookworm-slim` };
|
|
13511
|
+
}
|
|
13512
|
+
return { value };
|
|
13513
|
+
case "choice": {
|
|
13514
|
+
const options = input.options.map((option) => option.value);
|
|
13515
|
+
const lower = value.toLowerCase();
|
|
13516
|
+
if (isYesNo(options) && (TRUTHY.has(lower) || FALSEY2.has(lower))) {
|
|
13517
|
+
return { value: yesNo2(value) };
|
|
13518
|
+
}
|
|
13519
|
+
return options.includes(value) ? { value } : { error: `${name} must be one of: ${options.join(", ")}` };
|
|
13520
|
+
}
|
|
13521
|
+
case "switch": {
|
|
13522
|
+
const lower = value.toLowerCase();
|
|
13523
|
+
if (isYesNo([input.on, input.off])) {
|
|
13524
|
+
return TRUTHY.has(lower) || FALSEY2.has(lower) ? { value: yesNo2(value) } : { error: `${name} must be true or false` };
|
|
13525
|
+
}
|
|
13526
|
+
return value === input.on || value === input.off ? { value } : { error: `${name} must be ${input.on} or ${input.off}` };
|
|
13527
|
+
}
|
|
13528
|
+
case "number": {
|
|
13529
|
+
const parsed = Number(value);
|
|
13530
|
+
if (!/^\d+$/.test(value) || !Number.isSafeInteger(parsed)) {
|
|
13531
|
+
return { error: `${name} must be a whole number` };
|
|
13532
|
+
}
|
|
13533
|
+
if (parsed < input.min || parsed > input.max) {
|
|
13534
|
+
return { error: `${name} must be from ${input.min} to ${input.max}` };
|
|
13535
|
+
}
|
|
13536
|
+
return { value: String(parsed) };
|
|
13537
|
+
}
|
|
13538
|
+
}
|
|
13539
|
+
}
|
|
13540
|
+
function wireInput(input) {
|
|
13541
|
+
switch (input.type) {
|
|
13542
|
+
case "text":
|
|
13543
|
+
return { type: "text" };
|
|
13544
|
+
case "choice":
|
|
13545
|
+
return {
|
|
13546
|
+
type: "choice",
|
|
13547
|
+
default: input.default,
|
|
13548
|
+
options: input.options.map((option) => ({ ...option }))
|
|
13549
|
+
};
|
|
13550
|
+
default:
|
|
13551
|
+
return { ...input };
|
|
13552
|
+
}
|
|
13553
|
+
}
|
|
13554
|
+
function fieldStates(fields2, stored, env = process.env) {
|
|
13555
|
+
return fields2.map((field) => {
|
|
13556
|
+
const value = (field.kind === "config" ? stored.config : stored.secrets)[field.envVar] ?? "";
|
|
13557
|
+
const fromEnvironment = env[field.envVar] ?? "";
|
|
13558
|
+
const input = field.input ?? TEXT;
|
|
13559
|
+
const state2 = {
|
|
13560
|
+
envVar: field.envVar,
|
|
13561
|
+
kind: field.kind,
|
|
13562
|
+
label: field.label,
|
|
13563
|
+
input: wireInput(input),
|
|
13564
|
+
set: value.length > 0,
|
|
13565
|
+
...field.placeholder ? { placeholder: field.placeholder } : {},
|
|
13566
|
+
...field.description ? { description: field.description } : {},
|
|
13567
|
+
...field.advanced ? { advanced: true } : {},
|
|
13568
|
+
...field.when ? { when: field.when.map((rule) => ({ envVar: rule.envVar, is: [...rule.is] })) } : {},
|
|
13569
|
+
...fromEnvironment.length > 0 ? { environment: true } : {}
|
|
13570
|
+
};
|
|
13571
|
+
if (field.kind === "config") {
|
|
13572
|
+
state2.value = value;
|
|
13573
|
+
state2.effective = effectiveValue(input, fromEnvironment || value);
|
|
13574
|
+
if (value.length > 0 && "error" in normalizeSetting(field, value) && effectiveValue(input, value) !== value.trim()) {
|
|
13575
|
+
state2.unusable = true;
|
|
13576
|
+
}
|
|
13577
|
+
} else if (value.length > 0) state2.preview = mask(value);
|
|
13578
|
+
return state2;
|
|
13579
|
+
});
|
|
13580
|
+
}
|
|
13581
|
+
function writeSetting(db, authToken, field, value) {
|
|
13582
|
+
const store = field.kind === "config" ? openConfig(db) : openSecrets(db, authToken);
|
|
13583
|
+
if (value === "") store.remove(field.envVar);
|
|
13584
|
+
else store.set(field.envVar, value);
|
|
13585
|
+
}
|
|
13586
|
+
|
|
13587
|
+
// ../daemon/src/lib/provider-setup.ts
|
|
13588
|
+
var TEST_MESSAGE = "Reply with one word: ready.";
|
|
13589
|
+
var TEST_TIMEOUT_MS = 6e4;
|
|
13590
|
+
var MAX_TEST_ATTEMPTS = 3;
|
|
13591
|
+
var LIST_TIMEOUT_MS = 4e3;
|
|
13592
|
+
var DISCOVERY_TIMEOUT_MS = 1500;
|
|
13593
|
+
var IMAGE_MODEL_AS_CHAT = "This is an image model: choose it under Images, not as a chat model.";
|
|
13594
|
+
function requireProvider(id) {
|
|
13595
|
+
const provider = findProvider(id);
|
|
13596
|
+
if (!provider) throw new DomainError(404, `unknown provider: ${id}`);
|
|
13597
|
+
return provider;
|
|
13598
|
+
}
|
|
13599
|
+
function connectKind(provider) {
|
|
13600
|
+
if (provider.id === "openai-codex") return "signin";
|
|
13601
|
+
return provider.local ? "local" : "fields";
|
|
13602
|
+
}
|
|
13603
|
+
function chatCatalog(providerId) {
|
|
13604
|
+
return listCatalogEntries(providerId).filter((model) => !isImageModel(providerId, model.id));
|
|
13605
|
+
}
|
|
13606
|
+
function effectiveEnv({ db, authToken }, overrides = {}) {
|
|
13607
|
+
const env = { ...mergeSecretsIntoEnv(db, authToken, {}), ...overrides };
|
|
13608
|
+
for (const [name, value] of Object.entries(overrides)) if (value === "") delete env[name];
|
|
13609
|
+
return { ...env, ...process.env };
|
|
13610
|
+
}
|
|
13611
|
+
function snapshot2(ctx) {
|
|
13612
|
+
return {
|
|
13613
|
+
env: effectiveEnv(ctx),
|
|
13614
|
+
stored: readStoredSettings(ctx.db, ctx.authToken),
|
|
13615
|
+
enabled: providerState_exports.listEnabled(ctx.db),
|
|
13616
|
+
checks: readProviderChecks(ctx.db),
|
|
13617
|
+
codex: getStatus(ctx.db, ctx.authToken)
|
|
13618
|
+
};
|
|
13619
|
+
}
|
|
13620
|
+
function hasCredentials2(provider, env, codexConnected) {
|
|
13621
|
+
return provider.id === "openai-codex" ? codexConnected : isProviderConfigured(provider.id, env);
|
|
13622
|
+
}
|
|
13623
|
+
function localAddress(provider, env) {
|
|
13624
|
+
if (!provider.local) return void 0;
|
|
13625
|
+
return providerEndpoint(provider.id, env) ?? provider.endpoint?.fallback;
|
|
13626
|
+
}
|
|
13627
|
+
function entryOf(provider, snap, db) {
|
|
13628
|
+
const connect3 = connectKind(provider);
|
|
13629
|
+
const configured = hasCredentials2(provider, snap.env, snap.codex.connected);
|
|
13630
|
+
const enabled = snap.enabled.has(provider.id);
|
|
13631
|
+
const models = providerModels_exports.list(db, provider.id);
|
|
13632
|
+
const fields2 = fieldStates(provider.fields, snap.stored);
|
|
13633
|
+
const check = snap.checks[provider.id];
|
|
13634
|
+
let state2 = "untested";
|
|
13635
|
+
if (!enabled) state2 = "off";
|
|
13636
|
+
else if (!configured) state2 = "incomplete";
|
|
13637
|
+
else if (check) state2 = check.ok ? "working" : "failing";
|
|
13638
|
+
const address = localAddress(provider, snap.env);
|
|
13639
|
+
return {
|
|
13640
|
+
id: provider.id,
|
|
13641
|
+
displayName: provider.displayName,
|
|
13642
|
+
...provider.hint ? { hint: provider.hint } : {},
|
|
13643
|
+
connect: connect3,
|
|
13644
|
+
group: provider.popular ? "popular" : provider.local ? "local" : "more",
|
|
13645
|
+
fields: fields2,
|
|
13646
|
+
configured,
|
|
13647
|
+
enabled,
|
|
13648
|
+
listed: enabled || models.length > 0 || fields2.some((field) => field.set) || connect3 === "signin" && configured,
|
|
13649
|
+
state: state2,
|
|
13650
|
+
...check ? { check } : {},
|
|
13651
|
+
models,
|
|
13652
|
+
suggested: [...provider.suggested ?? []],
|
|
13653
|
+
catalogSize: chatCatalog(provider.id).length,
|
|
13654
|
+
listsModels: Boolean(provider.local || provider.modelsUrl),
|
|
13655
|
+
...address ? { address } : {},
|
|
13656
|
+
...connect3 === "signin" && snap.codex.accountId ? { account: snap.codex.accountId } : {}
|
|
13657
|
+
};
|
|
13658
|
+
}
|
|
13659
|
+
function providerEntries(ctx) {
|
|
13660
|
+
const snap = snapshot2(ctx);
|
|
13661
|
+
return PROVIDERS.map((provider) => entryOf(provider, snap, ctx.db));
|
|
13662
|
+
}
|
|
13663
|
+
function providerEntry(ctx, id) {
|
|
13664
|
+
return entryOf(requireProvider(id), snapshot2(ctx), ctx.db);
|
|
13665
|
+
}
|
|
13666
|
+
function modelsOverview(ctx) {
|
|
13667
|
+
const snap = snapshot2(ctx);
|
|
13668
|
+
const usage = modelUsage(ctx.db);
|
|
13669
|
+
const chat = [];
|
|
13670
|
+
for (const provider of PROVIDERS) {
|
|
13671
|
+
if (!snap.enabled.has(provider.id)) continue;
|
|
13672
|
+
const entry = entryOf(provider, snap, ctx.db);
|
|
13673
|
+
const facts = new Map(chatCatalog(provider.id).map((model) => [model.id, model]));
|
|
13674
|
+
for (const id of entry.models) {
|
|
13675
|
+
const value = `${provider.id}:${id}`;
|
|
13676
|
+
chat.push({
|
|
13677
|
+
...catalogModel(id, facts.get(id)),
|
|
13678
|
+
selected: true,
|
|
13679
|
+
suggested: entry.suggested.includes(id),
|
|
13680
|
+
value,
|
|
13681
|
+
provider: provider.id,
|
|
13682
|
+
providerName: provider.displayName,
|
|
13683
|
+
providerConnect: entry.connect,
|
|
13684
|
+
providerState: entry.state,
|
|
13685
|
+
usedBy: usage.get(value) ?? { agents: 0, templates: [] }
|
|
13686
|
+
});
|
|
13687
|
+
}
|
|
13688
|
+
}
|
|
13689
|
+
return {
|
|
13690
|
+
chat,
|
|
13691
|
+
images: {
|
|
13692
|
+
selected: snap.env.BAZILION_IMAGE_MODEL || "off",
|
|
13693
|
+
routes: IMAGE_ROUTES.map((route) => {
|
|
13694
|
+
const needs = imageRouteNeeds(route, snap.env, snap.codex.connected);
|
|
13695
|
+
return {
|
|
13696
|
+
id: route.id,
|
|
13697
|
+
model: route.model,
|
|
13698
|
+
provider: route.provider,
|
|
13699
|
+
providerName: findProvider(route.provider)?.displayName ?? route.provider,
|
|
13700
|
+
billing: route.billing,
|
|
13701
|
+
ready: needs === null,
|
|
13702
|
+
...needs ? { needs } : {}
|
|
13703
|
+
};
|
|
13704
|
+
})
|
|
13705
|
+
}
|
|
13706
|
+
};
|
|
13707
|
+
}
|
|
13708
|
+
function catalogModel(id, facts) {
|
|
13709
|
+
if (!facts) return { id };
|
|
13710
|
+
return {
|
|
13711
|
+
id,
|
|
13712
|
+
name: facts.name,
|
|
13713
|
+
...facts.contextWindow > 0 ? { contextWindow: facts.contextWindow } : {},
|
|
13714
|
+
images: facts.images,
|
|
13715
|
+
reasoning: facts.reasoning,
|
|
13716
|
+
...facts.price ? { price: facts.price } : {}
|
|
13717
|
+
};
|
|
13718
|
+
}
|
|
13719
|
+
function providerOverrides(provider, fields2) {
|
|
13720
|
+
if (fields2 === void 0) return {};
|
|
13721
|
+
if (fields2 === null || typeof fields2 !== "object" || Array.isArray(fields2)) {
|
|
13722
|
+
throw new DomainError(400, "fields must be an object of setting names and values");
|
|
13723
|
+
}
|
|
13724
|
+
const overrides = {};
|
|
13725
|
+
for (const [name, value] of Object.entries(fields2)) {
|
|
13726
|
+
if (!provider.fields.some((field) => field.envVar === name)) {
|
|
13727
|
+
throw new DomainError(400, `${name} is not a setting of ${provider.id}`);
|
|
13728
|
+
}
|
|
13729
|
+
if (typeof value !== "string") throw new DomainError(400, `${name} must be a string`);
|
|
13730
|
+
overrides[name] = value.trim();
|
|
13731
|
+
}
|
|
13732
|
+
return overrides;
|
|
13733
|
+
}
|
|
13734
|
+
async function providerCatalog(ctx, id, fields2, signal) {
|
|
13735
|
+
const provider = requireProvider(id);
|
|
13736
|
+
const env = effectiveEnv(ctx, providerOverrides(provider, fields2));
|
|
13737
|
+
const limit = AbortSignal.timeout(LIST_TIMEOUT_MS);
|
|
13738
|
+
const ask = Boolean(provider.local) || providerState_exports.listEnabled(ctx.db).has(id);
|
|
13739
|
+
const live = ask ? await listLiveModels(id, env, signal ? AbortSignal.any([signal, limit]) : limit) : void 0;
|
|
13740
|
+
const listed = (live?.models ?? []).filter((model) => !isImageModel(id, model));
|
|
13741
|
+
const selected = providerModels_exports.list(ctx.db, id);
|
|
13742
|
+
const catalog = provider.local ? [] : chatCatalog(id);
|
|
13743
|
+
const facts = new Map(catalog.map((model) => [model.id, model]));
|
|
13744
|
+
const ids = [.../* @__PURE__ */ new Set([...facts.keys(), ...listed, ...selected])];
|
|
13745
|
+
const dated = datedCopies(ids);
|
|
13746
|
+
const suggested = new Set(provider.suggested ?? []);
|
|
13747
|
+
if (provider.local && selected.length === 0 && listed[0]) suggested.add(listed[0]);
|
|
13748
|
+
return {
|
|
13749
|
+
models: ids.map((model) => ({
|
|
13750
|
+
...catalogModel(model, facts.get(model)),
|
|
13751
|
+
...dated.has(model) ? { dated: true } : {},
|
|
13752
|
+
selected: selected.includes(model),
|
|
13753
|
+
suggested: suggested.has(model)
|
|
13754
|
+
})),
|
|
13755
|
+
...live?.error ? { listError: live.error } : {}
|
|
13756
|
+
};
|
|
13757
|
+
}
|
|
13758
|
+
function setProviderModels(ctx, id, models) {
|
|
13759
|
+
requireProvider(id);
|
|
13760
|
+
if (models.some((model) => isImageModel(id, model.trim()))) {
|
|
13761
|
+
throw new DomainError(400, IMAGE_MODEL_AS_CHAT);
|
|
13762
|
+
}
|
|
13763
|
+
const saved = replaceCuratedModels(ctx.db, id, [...models]);
|
|
13764
|
+
const check = readProviderChecks(ctx.db)[id];
|
|
13765
|
+
if (check && !saved.models.includes(check.model)) writeProviderCheck(ctx.db, id, null);
|
|
13766
|
+
ensureSetupSeeded(ctx.db, ctx.paths);
|
|
13767
|
+
return saved;
|
|
13768
|
+
}
|
|
13769
|
+
async function discoverLocalProviders(ctx) {
|
|
13770
|
+
const env = effectiveEnv(ctx);
|
|
13771
|
+
const servers = await Promise.all(
|
|
13772
|
+
PROVIDERS.filter((provider) => provider.local).map(async (provider) => {
|
|
13773
|
+
const live = await listLiveModels(provider.id, env, AbortSignal.timeout(DISCOVERY_TIMEOUT_MS));
|
|
13774
|
+
return {
|
|
13775
|
+
id: provider.id,
|
|
13776
|
+
displayName: provider.displayName,
|
|
13777
|
+
address: localAddress(provider, env) ?? "",
|
|
13778
|
+
found: Boolean(live) && !live?.error,
|
|
13779
|
+
models: live?.models ?? []
|
|
13780
|
+
};
|
|
13781
|
+
})
|
|
13782
|
+
);
|
|
13783
|
+
return { servers };
|
|
13784
|
+
}
|
|
13785
|
+
function cheapestFirst(providerId, models) {
|
|
13786
|
+
const price = new Map(
|
|
13787
|
+
listCatalogEntries(providerId).map((model) => [
|
|
13788
|
+
model.id,
|
|
13789
|
+
model.price ? model.price.input + model.price.output : Number.POSITIVE_INFINITY
|
|
13790
|
+
])
|
|
13791
|
+
);
|
|
13792
|
+
const cost = (model) => price.get(model) ?? Number.POSITIVE_INFINITY;
|
|
13793
|
+
return models.map((model, index) => ({ model, index })).sort((a, b) => cost(a.model) - cost(b.model) || a.index - b.index).map(({ model }) => model);
|
|
13794
|
+
}
|
|
13795
|
+
function nameOf(providerId, model) {
|
|
13796
|
+
const name = chatCatalog(providerId).find((entry) => entry.id === model)?.name;
|
|
13797
|
+
return name ? { modelName: name } : {};
|
|
13798
|
+
}
|
|
13799
|
+
function hostOf(address) {
|
|
13800
|
+
if (!address) return void 0;
|
|
13801
|
+
try {
|
|
13802
|
+
return new URL(address).host;
|
|
13803
|
+
} catch {
|
|
13804
|
+
return address;
|
|
13805
|
+
}
|
|
13806
|
+
}
|
|
13807
|
+
async function askModel(ctx, provider, model, env, signal) {
|
|
13808
|
+
const limit = AbortSignal.timeout(TEST_TIMEOUT_MS);
|
|
13809
|
+
const started = Date.now();
|
|
13810
|
+
const secrets = provider.fields.filter((field) => field.kind === "secret").flatMap((field) => env[field.envVar] ?? []);
|
|
13811
|
+
try {
|
|
13812
|
+
const apiKey2 = provider.id === "openai-codex" ? await loadAccessToken(ctx.db, ctx.authToken) : void 0;
|
|
13813
|
+
if (apiKey2) secrets.push(apiKey2);
|
|
13814
|
+
await testProviderModel({
|
|
13815
|
+
providerName: provider.id,
|
|
13816
|
+
modelId: model,
|
|
13817
|
+
env,
|
|
13818
|
+
...apiKey2 ? { apiKey: apiKey2 } : {},
|
|
13819
|
+
message: TEST_MESSAGE,
|
|
13820
|
+
signal: signal ? AbortSignal.any([signal, limit]) : limit
|
|
13821
|
+
});
|
|
13822
|
+
return { ok: true, ms: Date.now() - started };
|
|
13823
|
+
} catch (error) {
|
|
13824
|
+
const name = chatCatalog(provider.id).find((entry) => entry.id === model)?.name ?? model;
|
|
13825
|
+
return {
|
|
13826
|
+
ok: false,
|
|
13827
|
+
failure: describeProviderFailure(error.message, {
|
|
13828
|
+
provider,
|
|
13829
|
+
modelName: name,
|
|
13830
|
+
address: hostOf(localAddress(provider, env)),
|
|
13831
|
+
timedOut: limit.aborted,
|
|
13832
|
+
secrets
|
|
13833
|
+
})
|
|
13834
|
+
};
|
|
13835
|
+
}
|
|
13836
|
+
}
|
|
13837
|
+
async function nothingToAsk(provider, env, signal) {
|
|
13838
|
+
const name = provider.displayName;
|
|
13839
|
+
if (!provider.local) {
|
|
13840
|
+
return {
|
|
13841
|
+
kind: "model",
|
|
13842
|
+
title: `No chat model was chosen for ${name}`,
|
|
13843
|
+
hint: "Choose at least one: connecting asks it for a short reply.",
|
|
13844
|
+
detail: ""
|
|
13845
|
+
};
|
|
13846
|
+
}
|
|
13847
|
+
const limit = AbortSignal.timeout(LIST_TIMEOUT_MS);
|
|
13848
|
+
const live = await listLiveModels(
|
|
13849
|
+
provider.id,
|
|
13850
|
+
env,
|
|
13851
|
+
signal ? AbortSignal.any([signal, limit]) : limit
|
|
13852
|
+
);
|
|
13853
|
+
if (live?.error) {
|
|
13854
|
+
const message = /^\d{3}\b/.test(live.error) ? live.error : `Connection error.: ${live.error}`;
|
|
13855
|
+
return describeProviderFailure(message, {
|
|
13856
|
+
provider,
|
|
13857
|
+
modelName: "",
|
|
13858
|
+
address: hostOf(localAddress(provider, env)),
|
|
13859
|
+
secrets: provider.fields.filter((field) => field.kind === "secret").flatMap((field) => env[field.envVar] ?? [])
|
|
13860
|
+
});
|
|
13861
|
+
}
|
|
13862
|
+
return {
|
|
13863
|
+
kind: "model",
|
|
13864
|
+
title: `${name} lists no models`,
|
|
13865
|
+
hint: `Load or download a model in ${name}, then connect again.`,
|
|
13866
|
+
detail: ""
|
|
13867
|
+
};
|
|
13868
|
+
}
|
|
13869
|
+
function missingCredentials(provider) {
|
|
13870
|
+
const name = provider.displayName;
|
|
13871
|
+
if (provider.id === "openai-codex") {
|
|
13872
|
+
return {
|
|
13873
|
+
kind: "credentials",
|
|
13874
|
+
title: "ChatGPT is not signed in",
|
|
13875
|
+
hint: "Sign in with ChatGPT first, here or with bazilion auth openai login.",
|
|
13876
|
+
detail: ""
|
|
13877
|
+
};
|
|
13878
|
+
}
|
|
13879
|
+
const field = provider.fields.find((candidate) => !candidate.advanced);
|
|
13880
|
+
return field ? {
|
|
13881
|
+
kind: "credentials",
|
|
13882
|
+
title: `${name} needs its ${field.label}`,
|
|
13883
|
+
hint: "Fill it in, then connect again.",
|
|
13884
|
+
detail: ""
|
|
13885
|
+
} : {
|
|
13886
|
+
kind: "credentials",
|
|
13887
|
+
title: `${name} has no credentials`,
|
|
13888
|
+
hint: provider.hint ?? "Its credentials come from the daemon\u2019s environment.",
|
|
13889
|
+
detail: ""
|
|
13890
|
+
};
|
|
13891
|
+
}
|
|
13892
|
+
function cleanModels(models) {
|
|
13893
|
+
if (!Array.isArray(models) || models.some((model) => typeof model !== "string")) {
|
|
13894
|
+
throw new DomainError(400, "models must be an array of strings");
|
|
13895
|
+
}
|
|
13896
|
+
return [...new Set(models.map((model) => model.trim()).filter(Boolean))];
|
|
13897
|
+
}
|
|
13898
|
+
async function connectProvider(ctx, id, request, signal) {
|
|
13899
|
+
const { db, authToken, paths } = ctx;
|
|
13900
|
+
const provider = requireProvider(id);
|
|
13901
|
+
const overrides = providerOverrides(provider, request.fields);
|
|
13902
|
+
const env = effectiveEnv(ctx, overrides);
|
|
13903
|
+
const codex = getStatus(db, authToken);
|
|
13904
|
+
if (!hasCredentials2(provider, env, codex.connected)) {
|
|
13905
|
+
return { connected: false, failure: missingCredentials(provider) };
|
|
13906
|
+
}
|
|
13907
|
+
const saved = providerModels_exports.list(db, id);
|
|
13908
|
+
const models = request.models === void 0 ? saved.length > 0 ? saved : [...provider.suggested ?? []] : cleanModels(request.models);
|
|
13909
|
+
if (models.some((model) => isImageModel(id, model))) {
|
|
13910
|
+
throw new DomainError(400, IMAGE_MODEL_AS_CHAT);
|
|
13911
|
+
}
|
|
13912
|
+
let check = null;
|
|
13913
|
+
const dropped = [];
|
|
13914
|
+
if (request.test !== false && models.length === 0) {
|
|
13915
|
+
return { connected: false, failure: await nothingToAsk(provider, env, signal) };
|
|
13916
|
+
}
|
|
13917
|
+
if (request.test !== false) {
|
|
13918
|
+
let refused;
|
|
13919
|
+
for (const model of cheapestFirst(id, models).slice(0, MAX_TEST_ATTEMPTS)) {
|
|
13920
|
+
const asked = await askModel(ctx, provider, model, env, signal);
|
|
13921
|
+
if (asked.ok) {
|
|
13922
|
+
check = { ok: true, at: Date.now(), model, ...nameOf(id, model), ms: asked.ms };
|
|
13923
|
+
break;
|
|
13924
|
+
}
|
|
13925
|
+
if (asked.failure.kind !== "model") return { connected: false, failure: asked.failure };
|
|
13926
|
+
dropped.push({ model, detail: asked.failure.detail });
|
|
13927
|
+
refused = asked.failure;
|
|
13928
|
+
}
|
|
13929
|
+
if (!check) return { connected: false, failure: refused };
|
|
13930
|
+
}
|
|
13931
|
+
const kept = models.filter((model) => !dropped.some((entry) => entry.model === model));
|
|
13932
|
+
let movedTemplates = [];
|
|
13933
|
+
db.raw.transaction(() => {
|
|
13934
|
+
for (const [name, value] of Object.entries(overrides)) {
|
|
13935
|
+
const field = provider.fields.find((candidate) => candidate.envVar === name);
|
|
13936
|
+
if (field) writeSetting(db, authToken, field, value);
|
|
13937
|
+
}
|
|
13938
|
+
movedTemplates = replaceCuratedModels(db, id, kept).movedTemplates;
|
|
13939
|
+
providerState_exports.setEnabled(db, id, true);
|
|
13940
|
+
writeProviderCheck(db, id, check);
|
|
13941
|
+
})();
|
|
13942
|
+
ensureSetupSeeded(db, paths);
|
|
13943
|
+
return { connected: true, provider: providerEntry(ctx, id), check, dropped, movedTemplates };
|
|
13944
|
+
}
|
|
13945
|
+
async function testProvider(ctx, id, signal) {
|
|
13946
|
+
const provider = requireProvider(id);
|
|
13947
|
+
const env = effectiveEnv(ctx);
|
|
13948
|
+
const model = cheapestFirst(id, providerModels_exports.list(ctx.db, id))[0];
|
|
13949
|
+
if (!model) throw new DomainError(409, `${provider.displayName} has no chat model to ask`);
|
|
13950
|
+
let check;
|
|
13951
|
+
if (!hasCredentials2(provider, env, getStatus(ctx.db, ctx.authToken).connected)) {
|
|
13952
|
+
check = { ok: false, at: Date.now(), model, failure: missingCredentials(provider) };
|
|
13953
|
+
} else {
|
|
13954
|
+
const asked = await askModel(ctx, provider, model, env, signal);
|
|
13955
|
+
check = asked.ok ? { ok: true, at: Date.now(), model, ...nameOf(id, model), ms: asked.ms } : { ok: false, at: Date.now(), model, ...nameOf(id, model), failure: asked.failure };
|
|
13956
|
+
}
|
|
13957
|
+
writeProviderCheck(ctx.db, id, check);
|
|
13958
|
+
return { check, provider: providerEntry(ctx, id) };
|
|
13959
|
+
}
|
|
13960
|
+
function recordProviderTest(ctx, providerId, model, outcome) {
|
|
13961
|
+
const provider = findProvider(providerId);
|
|
13962
|
+
if (!provider) return;
|
|
13963
|
+
if ("ms" in outcome) {
|
|
13964
|
+
writeProviderCheck(ctx.db, providerId, {
|
|
13965
|
+
ok: true,
|
|
13966
|
+
at: Date.now(),
|
|
13967
|
+
model,
|
|
13968
|
+
...nameOf(providerId, model),
|
|
13969
|
+
ms: outcome.ms
|
|
13970
|
+
});
|
|
13971
|
+
return;
|
|
13972
|
+
}
|
|
13973
|
+
const env = effectiveEnv(ctx);
|
|
13974
|
+
writeProviderCheck(ctx.db, providerId, {
|
|
13975
|
+
ok: false,
|
|
13976
|
+
at: Date.now(),
|
|
13977
|
+
model,
|
|
13978
|
+
...nameOf(providerId, model),
|
|
13979
|
+
failure: describeProviderFailure(outcome.error, {
|
|
13980
|
+
provider,
|
|
13981
|
+
modelName: chatCatalog(providerId).find((entry) => entry.id === model)?.name ?? model,
|
|
13982
|
+
address: hostOf(localAddress(provider, env)),
|
|
13983
|
+
secrets: provider.fields.filter((field) => field.kind === "secret").flatMap((field) => env[field.envVar] ?? [])
|
|
13984
|
+
})
|
|
13985
|
+
});
|
|
13986
|
+
}
|
|
13987
|
+
function setProviderEnabled(ctx, id, enabled) {
|
|
13988
|
+
const provider = requireProvider(id);
|
|
13989
|
+
if (enabled) {
|
|
13990
|
+
const snap = snapshot2(ctx);
|
|
13991
|
+
if (!hasCredentials2(provider, snap.env, snap.codex.connected)) {
|
|
13992
|
+
throw new DomainError(
|
|
13993
|
+
409,
|
|
13994
|
+
`${provider.displayName} has no credentials yet: connect it first (bazilion provider connect ${id})`
|
|
13995
|
+
);
|
|
13996
|
+
}
|
|
13997
|
+
}
|
|
13998
|
+
providerState_exports.setEnabled(ctx.db, id, enabled);
|
|
13999
|
+
ensureSetupSeeded(ctx.db, ctx.paths);
|
|
14000
|
+
}
|
|
14001
|
+
function disconnectProvider(ctx, id) {
|
|
14002
|
+
const { db, authToken } = ctx;
|
|
14003
|
+
const provider = requireProvider(id);
|
|
14004
|
+
const enabled = providerState_exports.listEnabled(db);
|
|
14005
|
+
let result = { models: [], movedTemplates: [] };
|
|
14006
|
+
db.raw.transaction(() => {
|
|
14007
|
+
providerState_exports.setEnabled(db, id, false);
|
|
14008
|
+
for (const field of provider.fields) {
|
|
14009
|
+
const shared = providersUsingField(field.envVar).some(
|
|
14010
|
+
(other) => other !== id && enabled.has(other)
|
|
14011
|
+
);
|
|
14012
|
+
if (!shared) writeSetting(db, authToken, field, "");
|
|
14013
|
+
}
|
|
14014
|
+
if (provider.id === "openai-codex") clearCredentials(db, authToken);
|
|
14015
|
+
result = replaceCuratedModels(db, id, []);
|
|
14016
|
+
writeProviderCheck(db, id, null);
|
|
14017
|
+
})();
|
|
14018
|
+
return result;
|
|
14019
|
+
}
|
|
14020
|
+
function forgetChecksFor(db, envVar) {
|
|
14021
|
+
for (const id of providersUsingField(envVar)) writeProviderCheck(db, id, null);
|
|
14022
|
+
}
|
|
14023
|
+
|
|
13131
14024
|
// ../daemon/src/routes/auth-login.ts
|
|
13132
14025
|
var authRouter = newRouter();
|
|
13133
14026
|
authRouter.get("/auth/whoami", (c) => {
|
|
@@ -13205,22 +14098,29 @@ authRouter.post("/providers/test", async (c) => {
|
|
|
13205
14098
|
return c.json({ error: "model is required" }, 400);
|
|
13206
14099
|
}
|
|
13207
14100
|
const message = typeof body.message === "string" && body.message ? body.message : "say hi briefly";
|
|
13208
|
-
const
|
|
14101
|
+
const ctx = getCtx();
|
|
14102
|
+
const { db, authToken, paths } = ctx;
|
|
14103
|
+
let tested;
|
|
14104
|
+
const started = Date.now();
|
|
13209
14105
|
try {
|
|
13210
14106
|
assertProviderReady(db, authToken, body.model);
|
|
13211
|
-
|
|
14107
|
+
tested = parseModelString(body.model);
|
|
13212
14108
|
const res = await testProviderModel({
|
|
13213
|
-
|
|
13214
|
-
modelId,
|
|
14109
|
+
...tested,
|
|
13215
14110
|
env: mergeSecretsIntoEnv(db, authToken),
|
|
13216
|
-
...providerName === "openai-codex" ? { apiKey: await loadAccessToken(db, authToken) } : {},
|
|
14111
|
+
...tested.providerName === "openai-codex" ? { apiKey: await loadAccessToken(db, authToken) } : {},
|
|
13217
14112
|
message,
|
|
13218
14113
|
signal: c.req.raw.signal
|
|
13219
14114
|
});
|
|
14115
|
+
recordProviderTest(ctx, tested.providerName, tested.modelId, { ms: Date.now() - started });
|
|
13220
14116
|
ensureSetupSeeded(db, paths);
|
|
13221
14117
|
return c.json(res);
|
|
13222
14118
|
} catch (err) {
|
|
13223
|
-
|
|
14119
|
+
const error = err.message;
|
|
14120
|
+
if (tested && !c.req.raw.signal.aborted) {
|
|
14121
|
+
recordProviderTest(ctx, tested.providerName, tested.modelId, { error });
|
|
14122
|
+
}
|
|
14123
|
+
return c.json({ error }, 400);
|
|
13224
14124
|
}
|
|
13225
14125
|
});
|
|
13226
14126
|
var COOKIE_MAX_AGE_SECONDS = 400 * 24 * 60 * 60;
|
|
@@ -13282,92 +14182,259 @@ authRouter.delete("/sessions/:id", (c) => {
|
|
|
13282
14182
|
return c.body(null, 204);
|
|
13283
14183
|
});
|
|
13284
14184
|
|
|
13285
|
-
// ../daemon/src/
|
|
13286
|
-
var
|
|
13287
|
-
|
|
13288
|
-
|
|
14185
|
+
// ../daemon/src/lib/tools-overview.ts
|
|
14186
|
+
var DOCKER_WAIT_MS = 3e3;
|
|
14187
|
+
var on = (label) => ({ label, tone: "on" });
|
|
14188
|
+
var warning = (label) => ({ label, tone: "warning" });
|
|
14189
|
+
function hasSearchingModel(db, env, authToken) {
|
|
14190
|
+
const enabled = providerState_exports.listEnabled(db);
|
|
14191
|
+
const usable = (id, ready) => ready && enabled.has(id) && providerModels_exports.list(db, id).length > 0;
|
|
14192
|
+
return usable("openai", Boolean(env.OPENAI_API_KEY?.trim())) || usable("openai-codex", hasCredentials(db, authToken));
|
|
14193
|
+
}
|
|
14194
|
+
function describeSearch(db, env, authToken) {
|
|
14195
|
+
const brave = Boolean(env.BRAVE_API_KEY?.trim());
|
|
14196
|
+
const searxng = Boolean(env.SEARXNG_URL?.trim());
|
|
14197
|
+
const own = hasSearchingModel(db, env, authToken);
|
|
14198
|
+
const ownSearch = {
|
|
14199
|
+
state: own ? on("Using the model\u2019s own search") : warning("Nothing to search with")
|
|
14200
|
+
};
|
|
14201
|
+
const automatic = brave ? "Now: Brave." : searxng ? "Now: SearXNG." : own ? "Now: the model\u2019s own search, for Agents on OpenAI or ChatGPT models." : "Now: nothing. Only OpenAI and ChatGPT models search by themselves, and none is in Chat: save a Brave key or a SearXNG address.";
|
|
14202
|
+
const options = {
|
|
14203
|
+
BAZILION_WEB_SEARCH_ROUTE: {
|
|
14204
|
+
auto: { text: automatic, tone: brave || searxng || own ? "ok" : "warning" },
|
|
14205
|
+
...brave ? {} : { brave: { text: "No Brave API key is saved yet.", tone: "warning" } },
|
|
14206
|
+
...searxng ? {} : { searxng: { text: "No SearXNG address is saved yet.", tone: "warning" } },
|
|
14207
|
+
...own ? {} : {
|
|
14208
|
+
native: {
|
|
14209
|
+
text: "No OpenAI or ChatGPT model is in Chat, so no Agent can search.",
|
|
14210
|
+
tone: "warning"
|
|
14211
|
+
}
|
|
14212
|
+
}
|
|
14213
|
+
}
|
|
14214
|
+
};
|
|
14215
|
+
const route = env.BAZILION_WEB_SEARCH_ROUTE?.trim() || "auto";
|
|
14216
|
+
const described = (() => {
|
|
14217
|
+
switch (route) {
|
|
14218
|
+
case "off":
|
|
14219
|
+
return { state: { label: "Off", tone: "off" } };
|
|
14220
|
+
case "brave":
|
|
14221
|
+
return brave ? { state: on("Using Brave") } : { state: warning("Needs a Brave key") };
|
|
14222
|
+
case "searxng":
|
|
14223
|
+
return searxng ? { state: on("Using SearXNG") } : { state: warning("Needs an address") };
|
|
14224
|
+
case "native":
|
|
14225
|
+
return ownSearch;
|
|
14226
|
+
case "auto":
|
|
14227
|
+
return brave ? { state: on("Using Brave") } : searxng ? { state: on("Using SearXNG") } : ownSearch;
|
|
14228
|
+
default:
|
|
14229
|
+
return {
|
|
14230
|
+
state: warning("Not usable"),
|
|
14231
|
+
note: `The stored choice "${route}" is not one of the search backends.`
|
|
14232
|
+
};
|
|
14233
|
+
}
|
|
14234
|
+
})();
|
|
14235
|
+
return { ...described, options };
|
|
14236
|
+
}
|
|
14237
|
+
function dockerProblem(error, image) {
|
|
14238
|
+
if (/not installed/i.test(error)) return "Docker is not installed on this computer.";
|
|
14239
|
+
if (/cannot connect to the docker daemon|docker daemon running|did not (answer|finish)/i.test(error)) {
|
|
14240
|
+
return "Docker is installed but not running. Start it, then open this page again.";
|
|
14241
|
+
}
|
|
14242
|
+
if (/no such image/i.test(error)) {
|
|
14243
|
+
return `Docker is running but does not have the image ${image}. Bazilion never pulls one: run docker pull ${image}`;
|
|
14244
|
+
}
|
|
14245
|
+
return `Docker could not be used: ${error}`;
|
|
14246
|
+
}
|
|
14247
|
+
async function describeCommands(env) {
|
|
14248
|
+
let config;
|
|
14249
|
+
try {
|
|
14250
|
+
config = resolveShellSecurityConfig(env);
|
|
14251
|
+
} catch (error) {
|
|
14252
|
+
return {
|
|
14253
|
+
state: warning("Not usable"),
|
|
14254
|
+
note: `A stored setting cannot be used, so Agents cannot run commands: ${error instanceof Error ? error.message : String(error)}. Save this card to replace it.`
|
|
14255
|
+
};
|
|
14256
|
+
}
|
|
14257
|
+
const image = config.sandboxImage;
|
|
14258
|
+
const docker2 = await Promise.race([
|
|
14259
|
+
checkDockerImage(image),
|
|
14260
|
+
new Promise(
|
|
14261
|
+
(resolve9) => setTimeout(
|
|
14262
|
+
() => resolve9({ ok: false, error: "Docker did not answer in time" }),
|
|
14263
|
+
DOCKER_WAIT_MS
|
|
14264
|
+
)
|
|
14265
|
+
)
|
|
14266
|
+
]);
|
|
14267
|
+
const dockerNote = docker2.ok ? { text: `Docker is running and has the image ${image}.`, tone: "ok" } : { text: dockerProblem(docker2.error, image), tone: "warning" };
|
|
14268
|
+
const asks = config.approvalMode === "dangerous" ? ", asks first" : "";
|
|
14269
|
+
const state2 = config.sandboxMode !== "docker" ? on(`Runs on this computer${asks}`) : docker2.ok ? on(`Runs in Docker${asks}`) : warning("Docker is not ready");
|
|
14270
|
+
return {
|
|
14271
|
+
state: state2,
|
|
14272
|
+
...config.sandboxMode === "docker" && !docker2.ok ? { note: "Agents cannot run commands until this is put right." } : {},
|
|
14273
|
+
options: { BAZILION_BASH_SANDBOX: { docker: dockerNote } }
|
|
14274
|
+
};
|
|
14275
|
+
}
|
|
14276
|
+
async function describe(def, db, env, authToken) {
|
|
14277
|
+
switch (def.id) {
|
|
14278
|
+
case "web-search":
|
|
14279
|
+
return describeSearch(db, env, authToken);
|
|
14280
|
+
case "web-pages":
|
|
14281
|
+
return {
|
|
14282
|
+
state: on(
|
|
14283
|
+
env.FIRECRAWL_API_KEY?.trim() ? "Built-in reader, then Firecrawl" : "Built-in reader"
|
|
14284
|
+
)
|
|
14285
|
+
};
|
|
14286
|
+
case "browser":
|
|
14287
|
+
if (!isBrowserEnabled(env)) return { state: { label: "Off", tone: "off" } };
|
|
14288
|
+
return {
|
|
14289
|
+
state: on(
|
|
14290
|
+
resolveBrowserConfig(env).attach ? "On: your running Chrome" : "On: a browser per Agent"
|
|
14291
|
+
)
|
|
14292
|
+
};
|
|
14293
|
+
case "commands":
|
|
14294
|
+
return describeCommands(env);
|
|
14295
|
+
case "agent-messages": {
|
|
14296
|
+
const limit = def.fields.find((field) => field.envVar === "BAZILION_AGENT_LOOP_MAX_HOPS");
|
|
14297
|
+
if (!limit?.input) return void 0;
|
|
14298
|
+
const hops = effectiveValue(limit.input, env.BAZILION_AGENT_LOOP_MAX_HOPS ?? "");
|
|
14299
|
+
return { state: on(`Stops after ${hops} ${hops === "1" ? "reply" : "replies"}`) };
|
|
14300
|
+
}
|
|
14301
|
+
default:
|
|
14302
|
+
return void 0;
|
|
14303
|
+
}
|
|
14304
|
+
}
|
|
14305
|
+
function withNotes(fields2, notes = {}) {
|
|
14306
|
+
return fields2.map((field) => {
|
|
14307
|
+
const forField = notes[field.envVar];
|
|
14308
|
+
if (!forField || field.input.type !== "choice") return field;
|
|
14309
|
+
return {
|
|
14310
|
+
...field,
|
|
14311
|
+
input: {
|
|
14312
|
+
...field.input,
|
|
14313
|
+
options: field.input.options.map(
|
|
14314
|
+
(option) => forField[option.value] ? { ...option, note: forField[option.value] } : option
|
|
14315
|
+
)
|
|
14316
|
+
}
|
|
14317
|
+
};
|
|
14318
|
+
});
|
|
14319
|
+
}
|
|
14320
|
+
async function toolsOverview(ctx) {
|
|
14321
|
+
const { db, authToken } = ctx;
|
|
14322
|
+
const stored = readStoredSettings(db, authToken);
|
|
13289
14323
|
const env = mergeSecretsIntoEnv(db, authToken);
|
|
13290
|
-
const
|
|
13291
|
-
|
|
13292
|
-
|
|
13293
|
-
|
|
13294
|
-
|
|
13295
|
-
|
|
13296
|
-
|
|
14324
|
+
const base = (def) => ({
|
|
14325
|
+
id: def.id,
|
|
14326
|
+
displayName: def.displayName,
|
|
14327
|
+
...def.hint ? { hint: def.hint } : {},
|
|
14328
|
+
...def.footnote ? { footnote: def.footnote } : {},
|
|
14329
|
+
fields: fieldStates(def.fields, stored)
|
|
14330
|
+
});
|
|
14331
|
+
const tools = await Promise.all(
|
|
14332
|
+
servicesByCategory("tool").map(async (def) => {
|
|
14333
|
+
const card = base(def);
|
|
14334
|
+
const described = await describe(def, db, env, authToken);
|
|
14335
|
+
if (!described) return card;
|
|
13297
14336
|
return {
|
|
13298
|
-
|
|
13299
|
-
|
|
13300
|
-
...
|
|
13301
|
-
|
|
13302
|
-
fields: resolveFieldStates(provider, configValues, secretValues),
|
|
13303
|
-
catalog: catalog.filter((model) => !isImageChoice(provider.id, model)),
|
|
13304
|
-
...live ? {
|
|
13305
|
-
live: {
|
|
13306
|
-
...live,
|
|
13307
|
-
models: live.models.filter((model) => !isImageChoice(provider.id, model))
|
|
13308
|
-
}
|
|
13309
|
-
} : {},
|
|
13310
|
-
curated: providerModels_exports.list(db, provider.id)
|
|
14337
|
+
...card,
|
|
14338
|
+
state: described.state,
|
|
14339
|
+
...described.note ? { note: described.note } : {},
|
|
14340
|
+
fields: withNotes(card.fields, described.options)
|
|
13311
14341
|
};
|
|
13312
14342
|
})
|
|
13313
14343
|
);
|
|
13314
|
-
const body = { providers: entries };
|
|
13315
|
-
return c.json(body);
|
|
13316
|
-
});
|
|
13317
|
-
configRouter.get("/services", (c) => {
|
|
13318
|
-
const { db, authToken } = getCtx();
|
|
13319
|
-
const configValues = readAll(() => openConfig(db).getAll());
|
|
13320
|
-
const secretValues = readAll(() => openSecrets(db, authToken).getAll());
|
|
13321
|
-
const env = mergeSecretsIntoEnv(db, authToken);
|
|
13322
14344
|
const image = imageRoute(env, hasCredentials(db, authToken));
|
|
13323
|
-
const
|
|
13324
|
-
|
|
13325
|
-
|
|
13326
|
-
|
|
13327
|
-
|
|
13328
|
-
|
|
13329
|
-
|
|
13330
|
-
|
|
13331
|
-
|
|
13332
|
-
|
|
13333
|
-
|
|
14345
|
+
const functions = servicesByCategory("function").map((def) => {
|
|
14346
|
+
const card = base(def);
|
|
14347
|
+
return def.id === "image-generation" ? { ...card, note: image.ready ? `Ready: ${image.model}.` : image.reason } : card;
|
|
14348
|
+
});
|
|
14349
|
+
return { tools, functions };
|
|
14350
|
+
}
|
|
14351
|
+
|
|
14352
|
+
// ../daemon/src/routes/config.ts
|
|
14353
|
+
var configRouter = newRouter();
|
|
14354
|
+
configRouter.get(
|
|
14355
|
+
"/providers",
|
|
14356
|
+
(c) => c.json({ providers: providerEntries(getCtx()) })
|
|
14357
|
+
);
|
|
14358
|
+
configRouter.get("/providers/local", async (c) => c.json(await discoverLocalProviders(getCtx())));
|
|
14359
|
+
configRouter.get(
|
|
14360
|
+
"/providers/:name/catalog",
|
|
14361
|
+
async (c) => c.json(await providerCatalog(getCtx(), c.req.param("name"), void 0, c.req.raw.signal))
|
|
14362
|
+
);
|
|
14363
|
+
configRouter.post("/providers/:name/catalog", async (c) => {
|
|
14364
|
+
const body = await jsonBody(c);
|
|
14365
|
+
return c.json(
|
|
14366
|
+
await providerCatalog(getCtx(), c.req.param("name"), body?.fields, c.req.raw.signal)
|
|
14367
|
+
);
|
|
13334
14368
|
});
|
|
14369
|
+
configRouter.post("/providers/:name/connect", async (c) => {
|
|
14370
|
+
const body = await jsonBody(c) ?? {};
|
|
14371
|
+
return c.json(await connectProvider(getCtx(), c.req.param("name"), body, c.req.raw.signal));
|
|
14372
|
+
});
|
|
14373
|
+
configRouter.post(
|
|
14374
|
+
"/providers/:name/test",
|
|
14375
|
+
async (c) => c.json(await testProvider(getCtx(), c.req.param("name"), c.req.raw.signal))
|
|
14376
|
+
);
|
|
14377
|
+
configRouter.delete(
|
|
14378
|
+
"/providers/:name",
|
|
14379
|
+
(c) => c.json(disconnectProvider(getCtx(), c.req.param("name")))
|
|
14380
|
+
);
|
|
13335
14381
|
configRouter.put("/providers/:name/enabled", async (c) => {
|
|
13336
14382
|
const name = c.req.param("name");
|
|
13337
|
-
|
|
14383
|
+
requireProvider(name);
|
|
13338
14384
|
const enabled = (await jsonBody(c))?.enabled;
|
|
13339
14385
|
if (typeof enabled !== "boolean") {
|
|
13340
14386
|
return c.json({ error: 'body must be {"enabled": boolean}' }, 400);
|
|
13341
14387
|
}
|
|
13342
|
-
|
|
13343
|
-
providerState_exports.setEnabled(db, name, enabled);
|
|
13344
|
-
ensureSetupSeeded(db, paths);
|
|
14388
|
+
setProviderEnabled(getCtx(), name, enabled);
|
|
13345
14389
|
return c.json({ name, enabled });
|
|
13346
14390
|
});
|
|
13347
|
-
configRouter.get("/providers/:name/models", (c) => {
|
|
13348
|
-
const name = c.req.param("name");
|
|
13349
|
-
if (!findProvider(name)) return c.json({ error: `unknown provider: ${name}` }, 404);
|
|
13350
|
-
const { db } = getCtx();
|
|
13351
|
-
return c.json({ models: providerModels_exports.list(db, name) });
|
|
13352
|
-
});
|
|
13353
14391
|
configRouter.put("/providers/:name/models", async (c) => {
|
|
13354
|
-
const name = c.req.param("name");
|
|
13355
|
-
if (!findProvider(name)) return c.json({ error: `unknown provider: ${name}` }, 404);
|
|
13356
14392
|
const body = await jsonBody(c);
|
|
13357
14393
|
if (!Array.isArray(body?.models)) {
|
|
13358
14394
|
return c.json({ error: "models must be an array of strings" }, 400);
|
|
13359
14395
|
}
|
|
13360
14396
|
const models = body.models.filter((m) => typeof m === "string");
|
|
13361
|
-
|
|
13362
|
-
|
|
13363
|
-
|
|
13364
|
-
|
|
13365
|
-
|
|
13366
|
-
|
|
13367
|
-
|
|
13368
|
-
|
|
13369
|
-
|
|
13370
|
-
|
|
14397
|
+
return c.json(setProviderModels(getCtx(), c.req.param("name"), models));
|
|
14398
|
+
});
|
|
14399
|
+
configRouter.get("/models", (c) => c.json(modelsOverview(getCtx())));
|
|
14400
|
+
configRouter.get("/tools", async (c) => c.json(await toolsOverview(getCtx())));
|
|
14401
|
+
function fieldState(db, authToken, field) {
|
|
14402
|
+
const [state2] = fieldStates([field], readStoredSettings(db, authToken));
|
|
14403
|
+
return state2;
|
|
14404
|
+
}
|
|
14405
|
+
configRouter.put("/fields", async (c) => {
|
|
14406
|
+
const body = await jsonBody(c);
|
|
14407
|
+
const values = body?.values;
|
|
14408
|
+
if (!values || typeof values !== "object" || Array.isArray(values)) {
|
|
14409
|
+
return c.json({ error: 'body must be {"values": {"NAME": "value", \u2026}}' }, 400);
|
|
14410
|
+
}
|
|
14411
|
+
const accepted = [];
|
|
14412
|
+
const errors = {};
|
|
14413
|
+
for (const [envVar, raw] of Object.entries(values)) {
|
|
14414
|
+
const field = findFieldByEnvVar(envVar);
|
|
14415
|
+
if (!field) errors[envVar] = `unknown setting: ${envVar}`;
|
|
14416
|
+
else if (typeof raw !== "string") errors[envVar] = `${envVar} must be text`;
|
|
14417
|
+
else {
|
|
14418
|
+
const checked = normalizeSetting(field, raw);
|
|
14419
|
+
if ("error" in checked) errors[envVar] = checked.error;
|
|
14420
|
+
else accepted.push({ field, value: checked.value });
|
|
14421
|
+
}
|
|
14422
|
+
}
|
|
14423
|
+
const [firstError] = Object.values(errors);
|
|
14424
|
+
if (firstError) return c.json({ error: firstError, errors }, 400);
|
|
14425
|
+
const { db, authToken } = getCtx();
|
|
14426
|
+
db.raw.transaction(() => {
|
|
14427
|
+
for (const { field, value } of accepted) {
|
|
14428
|
+
writeSetting(db, authToken, field, value);
|
|
14429
|
+
forgetChecksFor(db, field.envVar);
|
|
14430
|
+
}
|
|
14431
|
+
})();
|
|
14432
|
+
return c.json({
|
|
14433
|
+
fields: fieldStates(
|
|
14434
|
+
accepted.map(({ field }) => field),
|
|
14435
|
+
readStoredSettings(db, authToken)
|
|
14436
|
+
)
|
|
14437
|
+
});
|
|
13371
14438
|
});
|
|
13372
14439
|
configRouter.put("/fields/:envVar", async (c) => {
|
|
13373
14440
|
const envVar = c.req.param("envVar");
|
|
@@ -13377,80 +14444,22 @@ configRouter.put("/fields/:envVar", async (c) => {
|
|
|
13377
14444
|
if (!body || typeof body.value !== "string") {
|
|
13378
14445
|
return c.json({ error: 'body must be {"value": "<string>"}' }, 400);
|
|
13379
14446
|
}
|
|
13380
|
-
|
|
13381
|
-
|
|
13382
|
-
}
|
|
14447
|
+
const checked = normalizeSetting(field, body.value);
|
|
14448
|
+
if ("error" in checked) return c.json({ error: checked.error }, 400);
|
|
13383
14449
|
const { db, authToken } = getCtx();
|
|
13384
|
-
|
|
13385
|
-
|
|
13386
|
-
|
|
13387
|
-
else store.set(envVar, body.value);
|
|
13388
|
-
} else {
|
|
13389
|
-
const store = openSecrets(db, authToken);
|
|
13390
|
-
if (body.value === "") store.remove(envVar);
|
|
13391
|
-
else store.set(envVar, body.value);
|
|
13392
|
-
}
|
|
13393
|
-
return c.json(readFieldState(db, authToken, envVar, field.kind));
|
|
14450
|
+
writeSetting(db, authToken, field, checked.value);
|
|
14451
|
+
forgetChecksFor(db, envVar);
|
|
14452
|
+
return c.json(fieldState(db, authToken, field));
|
|
13394
14453
|
});
|
|
13395
|
-
configRouter.get(
|
|
13396
|
-
"/available-models",
|
|
13397
|
-
(c) => c.json({ teams: groupAvailableModels(getCtx().db) })
|
|
13398
|
-
);
|
|
13399
14454
|
configRouter.delete("/fields/:envVar", (c) => {
|
|
13400
14455
|
const envVar = c.req.param("envVar");
|
|
13401
14456
|
const field = findFieldByEnvVar(envVar);
|
|
13402
14457
|
if (!field) return c.json({ error: `unknown envVar: ${envVar}` }, 404);
|
|
13403
14458
|
const { db, authToken } = getCtx();
|
|
13404
|
-
|
|
13405
|
-
|
|
13406
|
-
} else {
|
|
13407
|
-
openSecrets(db, authToken).remove(envVar);
|
|
13408
|
-
}
|
|
14459
|
+
writeSetting(db, authToken, field, "");
|
|
14460
|
+
forgetChecksFor(db, envVar);
|
|
13409
14461
|
return c.body(null, 204);
|
|
13410
14462
|
});
|
|
13411
|
-
function isImageChoice(provider, model) {
|
|
13412
|
-
return IMAGE_MODEL_CHOICES.includes(`${provider}:${model}`);
|
|
13413
|
-
}
|
|
13414
|
-
function mask(value) {
|
|
13415
|
-
if (value.length === 0) return "";
|
|
13416
|
-
return value.length > 8 ? `${value.slice(0, 6)}\u2026` : "***";
|
|
13417
|
-
}
|
|
13418
|
-
function resolveFieldStates(service, configValues, secretValues) {
|
|
13419
|
-
return service.fields.map((f) => {
|
|
13420
|
-
const val = (f.kind === "config" ? configValues[f.envVar] : secretValues[f.envVar]) ?? "";
|
|
13421
|
-
const state2 = {
|
|
13422
|
-
envVar: f.envVar,
|
|
13423
|
-
kind: f.kind,
|
|
13424
|
-
label: f.label,
|
|
13425
|
-
set: val.length > 0,
|
|
13426
|
-
...f.placeholder ? { placeholder: f.placeholder } : {},
|
|
13427
|
-
...f.description ? { description: f.description } : {},
|
|
13428
|
-
...f.options ? { options: f.options } : {},
|
|
13429
|
-
...f.optionLabels ? { optionLabels: f.optionLabels } : {}
|
|
13430
|
-
};
|
|
13431
|
-
if (f.kind === "config") {
|
|
13432
|
-
state2.value = val;
|
|
13433
|
-
} else if (val.length > 0) {
|
|
13434
|
-
state2.preview = mask(val);
|
|
13435
|
-
}
|
|
13436
|
-
return state2;
|
|
13437
|
-
});
|
|
13438
|
-
}
|
|
13439
|
-
function readAll(read2) {
|
|
13440
|
-
try {
|
|
13441
|
-
return read2();
|
|
13442
|
-
} catch {
|
|
13443
|
-
return {};
|
|
13444
|
-
}
|
|
13445
|
-
}
|
|
13446
|
-
function readFieldState(db, authToken, envVar, kind) {
|
|
13447
|
-
if (kind === "config") {
|
|
13448
|
-
const v2 = openConfig(db).get(envVar) ?? "";
|
|
13449
|
-
return { envVar, kind, set: v2.length > 0, value: v2 };
|
|
13450
|
-
}
|
|
13451
|
-
const v = openSecrets(db, authToken).get(envVar) ?? "";
|
|
13452
|
-
return { envVar, kind, set: v.length > 0, ...v.length > 0 ? { preview: mask(v) } : {} };
|
|
13453
|
-
}
|
|
13454
14463
|
|
|
13455
14464
|
// ../daemon/src/routes/conversations.ts
|
|
13456
14465
|
var conversationsRouter = newRouter();
|
|
@@ -13771,10 +14780,10 @@ function claimDaemonPidFile(home) {
|
|
|
13771
14780
|
// ../daemon/src/lib/backup.ts
|
|
13772
14781
|
var snapshotTail = Promise.resolve();
|
|
13773
14782
|
function createBackupSnapshot(db) {
|
|
13774
|
-
const
|
|
13775
|
-
snapshotTail =
|
|
14783
|
+
const snapshot3 = snapshotTail.then(() => takeSnapshot(db));
|
|
14784
|
+
snapshotTail = snapshot3.catch(() => {
|
|
13776
14785
|
});
|
|
13777
|
-
return
|
|
14786
|
+
return snapshot3;
|
|
13778
14787
|
}
|
|
13779
14788
|
async function takeSnapshot(db) {
|
|
13780
14789
|
const directory = mkdtempSync3(join31(tmpdir3(), "bazilion-backup-"));
|
|
@@ -13782,14 +14791,14 @@ async function takeSnapshot(db) {
|
|
|
13782
14791
|
try {
|
|
13783
14792
|
const database = join31(directory, "bazilion.snapshot");
|
|
13784
14793
|
await db.backupTo(database);
|
|
13785
|
-
const
|
|
14794
|
+
const snapshot3 = new DatabaseSync2(database, { readOnly: true });
|
|
13786
14795
|
try {
|
|
13787
|
-
const check =
|
|
14796
|
+
const check = snapshot3.prepare("PRAGMA integrity_check").get();
|
|
13788
14797
|
if (check?.integrity_check !== "ok") {
|
|
13789
14798
|
throw new Error(`SQLite snapshot failed integrity_check: ${check?.integrity_check}`);
|
|
13790
14799
|
}
|
|
13791
14800
|
} finally {
|
|
13792
|
-
|
|
14801
|
+
snapshot3.close();
|
|
13793
14802
|
}
|
|
13794
14803
|
return { directory, database, cleanup };
|
|
13795
14804
|
} catch (error) {
|
|
@@ -13797,8 +14806,8 @@ async function takeSnapshot(db) {
|
|
|
13797
14806
|
throw error;
|
|
13798
14807
|
}
|
|
13799
14808
|
}
|
|
13800
|
-
function createBackupArchive(paths,
|
|
13801
|
-
const snapshotPath = resolve7(
|
|
14809
|
+
function createBackupArchive(paths, snapshot3) {
|
|
14810
|
+
const snapshotPath = resolve7(snapshot3.database);
|
|
13802
14811
|
return create6(
|
|
13803
14812
|
{
|
|
13804
14813
|
cwd: paths.home,
|
|
@@ -13869,12 +14878,12 @@ miscRouter.get("/health/details", async (c) => {
|
|
|
13869
14878
|
parseErrors++;
|
|
13870
14879
|
}
|
|
13871
14880
|
}
|
|
13872
|
-
let
|
|
14881
|
+
let effectiveEnv2 = process.env;
|
|
13873
14882
|
let codexConnected = false;
|
|
13874
14883
|
if (pathChecks.auth && pathChecks.db) {
|
|
13875
14884
|
try {
|
|
13876
14885
|
const { db, authToken } = getCtx();
|
|
13877
|
-
|
|
14886
|
+
effectiveEnv2 = mergeSecretsIntoEnv(db, authToken);
|
|
13878
14887
|
codexConnected = hasCredentials(db, authToken);
|
|
13879
14888
|
} catch {
|
|
13880
14889
|
}
|
|
@@ -13883,17 +14892,17 @@ miscRouter.get("/health/details", async (c) => {
|
|
|
13883
14892
|
const providerSection = {
|
|
13884
14893
|
// Hosted providers with credentials; local servers are reported below.
|
|
13885
14894
|
configured: PROVIDERS.filter(
|
|
13886
|
-
(provider) => provider.id === "openai-codex" ? codexConnected : !provider.local && isProviderConfigured(provider.id,
|
|
14895
|
+
(provider) => provider.id === "openai-codex" ? codexConnected : !provider.local && isProviderConfigured(provider.id, effectiveEnv2)
|
|
13887
14896
|
).map((provider) => provider.id),
|
|
13888
14897
|
lmstudio: {
|
|
13889
|
-
customEndpointConfigured: Boolean(
|
|
13890
|
-
keyConfigured: Boolean(
|
|
14898
|
+
customEndpointConfigured: Boolean(effectiveEnv2.LMSTUDIO_URL?.trim()),
|
|
14899
|
+
keyConfigured: Boolean(effectiveEnv2.LMSTUDIO_API_KEY)
|
|
13891
14900
|
},
|
|
13892
|
-
ollama: { customEndpointConfigured: Boolean(
|
|
14901
|
+
ollama: { customEndpointConfigured: Boolean(effectiveEnv2.OLLAMA_URL?.trim()) }
|
|
13893
14902
|
};
|
|
13894
14903
|
let shellSecurity;
|
|
13895
14904
|
try {
|
|
13896
|
-
const shellConfig = resolveShellSecurityConfig(
|
|
14905
|
+
const shellConfig = resolveShellSecurityConfig(effectiveEnv2);
|
|
13897
14906
|
const docker2 = shellConfig.sandboxMode === "docker" ? await checkDockerImage(shellConfig.sandboxImage) : null;
|
|
13898
14907
|
shellSecurity = {
|
|
13899
14908
|
ok: true,
|
|
@@ -13924,8 +14933,8 @@ miscRouter.get("/health/details", async (c) => {
|
|
|
13924
14933
|
skills: { installed: skills.length, parseErrors },
|
|
13925
14934
|
providers: providerSection,
|
|
13926
14935
|
webSearch: {
|
|
13927
|
-
braveConfigured: Boolean(
|
|
13928
|
-
searxngConfigured: Boolean(
|
|
14936
|
+
braveConfigured: Boolean(effectiveEnv2.BRAVE_API_KEY?.trim()),
|
|
14937
|
+
searxngConfigured: Boolean(effectiveEnv2.SEARXNG_URL?.trim())
|
|
13929
14938
|
},
|
|
13930
14939
|
openclaw: {
|
|
13931
14940
|
path: openclawSkillsDir,
|
|
@@ -13959,18 +14968,18 @@ miscRouter.get("/backup", async (c) => {
|
|
|
13959
14968
|
if (!existsSync17(paths.home)) {
|
|
13960
14969
|
return c.json({ error: `bazilion home not found at ${paths.home}` }, 404);
|
|
13961
14970
|
}
|
|
13962
|
-
let
|
|
14971
|
+
let snapshot3;
|
|
13963
14972
|
try {
|
|
13964
|
-
|
|
14973
|
+
snapshot3 = await createBackupSnapshot(db);
|
|
13965
14974
|
} catch (error) {
|
|
13966
14975
|
const message = error instanceof Error ? error.message : String(error);
|
|
13967
14976
|
return c.json({ error: `could not create database snapshot: ${message}` }, 500);
|
|
13968
14977
|
}
|
|
13969
14978
|
let archive2;
|
|
13970
14979
|
try {
|
|
13971
|
-
archive2 = createBackupArchive(paths,
|
|
14980
|
+
archive2 = createBackupArchive(paths, snapshot3);
|
|
13972
14981
|
} catch (error) {
|
|
13973
|
-
|
|
14982
|
+
snapshot3.cleanup();
|
|
13974
14983
|
const message = error instanceof Error ? error.message : String(error);
|
|
13975
14984
|
return c.json({ error: `could not start backup archive: ${message}` }, 500);
|
|
13976
14985
|
}
|
|
@@ -13983,17 +14992,17 @@ miscRouter.get("/backup", async (c) => {
|
|
|
13983
14992
|
controller.enqueue(Buffer.isBuffer(next.value) ? next.value : Buffer.from(next.value));
|
|
13984
14993
|
return;
|
|
13985
14994
|
}
|
|
13986
|
-
|
|
14995
|
+
snapshot3.cleanup();
|
|
13987
14996
|
controller.close();
|
|
13988
14997
|
} catch (error) {
|
|
13989
|
-
|
|
14998
|
+
snapshot3.cleanup();
|
|
13990
14999
|
controller.error(error);
|
|
13991
15000
|
}
|
|
13992
15001
|
},
|
|
13993
15002
|
async cancel() {
|
|
13994
15003
|
await iterator.return?.();
|
|
13995
15004
|
archive2.destroy();
|
|
13996
|
-
|
|
15005
|
+
snapshot3.cleanup();
|
|
13997
15006
|
}
|
|
13998
15007
|
});
|
|
13999
15008
|
const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
|
|
@@ -15472,7 +16481,7 @@ async function readOrNull(captured, args) {
|
|
|
15472
16481
|
|
|
15473
16482
|
// ../daemon/src/lib/git/capture.ts
|
|
15474
16483
|
import { execFile } from "node:child_process";
|
|
15475
|
-
import { mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync5, rmSync as rmSync15, writeFileSync as writeFileSync13 } from "node:fs";
|
|
16484
|
+
import { mkdirSync as mkdirSync12, mkdtempSync as mkdtempSync5, rmSync as rmSync15, utimesSync, writeFileSync as writeFileSync13 } from "node:fs";
|
|
15476
16485
|
import { tmpdir as tmpdir5 } from "node:os";
|
|
15477
16486
|
import { join as join37 } from "node:path";
|
|
15478
16487
|
var INSPECTION_BUDGET_MS = 5e3;
|
|
@@ -15642,11 +16651,16 @@ objectformat = ${value}`
|
|
|
15642
16651
|
}
|
|
15643
16652
|
};
|
|
15644
16653
|
for (const name of ["HEAD", "index", "packed-refs", "shallow"]) {
|
|
16654
|
+
const written = name === "index" ? git.entry(name) : null;
|
|
15645
16655
|
const content = git.read(name, Math.min(METADATA_READ_LARGE, METADATA_BYTES - bytes));
|
|
15646
16656
|
if (content) {
|
|
15647
16657
|
count++;
|
|
15648
16658
|
bytes += content.length;
|
|
15649
16659
|
writeFileSync13(join37(scratch, name), content, { mode: 384 });
|
|
16660
|
+
if (written) {
|
|
16661
|
+
const seconds = Math.floor(written.mtimeMs / 1e3);
|
|
16662
|
+
utimesSync(join37(scratch, name), seconds, seconds);
|
|
16663
|
+
}
|
|
15650
16664
|
}
|
|
15651
16665
|
}
|
|
15652
16666
|
for (const name of ["refs", "objects"]) {
|
|
@@ -15668,15 +16682,15 @@ objectformat = ${value}`
|
|
|
15668
16682
|
|
|
15669
16683
|
// ../daemon/src/lib/git-review/authors.ts
|
|
15670
16684
|
import { realpathSync as realpathSync8 } from "node:fs";
|
|
15671
|
-
import { isAbsolute as
|
|
16685
|
+
import { isAbsolute as isAbsolute8, join as join38, relative as relative5, resolve as resolve8, sep as sep6 } from "node:path";
|
|
15672
16686
|
var FILE_TOOLS = /* @__PURE__ */ new Set(["write", "edit"]);
|
|
15673
16687
|
var CONVERSATIONS_PER_AGENT = 5;
|
|
15674
16688
|
var SANDBOX_ROOT = "/workspace";
|
|
15675
16689
|
function workspacePath(path, cwd, roots) {
|
|
15676
|
-
const absolute =
|
|
16690
|
+
const absolute = isAbsolute8(path) ? path : resolve8(cwd, path);
|
|
15677
16691
|
for (const root of roots) {
|
|
15678
16692
|
const inside = relative5(root, absolute);
|
|
15679
|
-
if (inside && !inside.startsWith("..") && !
|
|
16693
|
+
if (inside && !inside.startsWith("..") && !isAbsolute8(inside)) {
|
|
15680
16694
|
return inside.split(sep6).join("/");
|
|
15681
16695
|
}
|
|
15682
16696
|
}
|
|
@@ -17704,7 +18718,7 @@ agentTelegramRouter.post("/:id/telegram/bind", async (c) => {
|
|
|
17704
18718
|
if (!live) {
|
|
17705
18719
|
return c.json(
|
|
17706
18720
|
{
|
|
17707
|
-
error: "Telegram bot is not running
|
|
18721
|
+
error: "Telegram bot is not running: set it up under Setup, Telegram (/config/telegram)"
|
|
17708
18722
|
},
|
|
17709
18723
|
503
|
|
17710
18724
|
);
|