@bike4mind/cli 4.6.0 → 4.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +119 -0
- package/bin/bike4mind-cli.mjs +342 -239
- package/dist/{AgentHistoryStore--J3sgO_-.mjs → AgentHistoryStore-jktM0SmD.mjs} +140 -73
- package/dist/{ApiClient-CdO4Gamg.mjs → ApiClient-CczpydlW.mjs} +3 -3
- package/dist/{BubblewrapRuntime-3jAbC60G.mjs → BubblewrapRuntime-aGfDSJPY.mjs} +2 -2
- package/dist/ConfigStore-BAJ4hIHa.mjs +2 -0
- package/dist/{ConfigStore-Dusy6glb.mjs → ConfigStore-CO6kREaL.mjs} +101 -27
- package/dist/{Logger-C1Wj6xla.mjs → Logger-CHKCF5hd.mjs} +5095 -495
- package/dist/{RemoteSkillSource-qTvRkaNA.mjs → RemoteSkillSource-D_F99yBR.mjs} +5 -0
- package/dist/{SandboxOrchestrator-CQwYq_uy.mjs → SandboxOrchestrator-ULWvuUct.mjs} +1 -1
- package/dist/{SandboxRuntimeAdapter-BsT2iLky.mjs → SandboxRuntimeAdapter-DpDSET-A.mjs} +2 -2
- package/dist/{SandboxRuntimeAdapter-Zg_0th7V.mjs → SandboxRuntimeAdapter-FpZRkE6D.mjs} +1 -1
- package/dist/{SeatbeltRuntime-C2DEkrjy.mjs → SeatbeltRuntime-C0GJ3nnY.mjs} +2 -2
- package/dist/{WorkItemsClient-CxNZaOmc.mjs → WorkItemsClient-aCxMV_Wm.mjs} +1 -1
- package/dist/{buildToolSearch-DOb7mx6F.mjs → buildToolSearch-CbLeZ5wP.mjs} +2 -2
- package/dist/commands/acpCommand.mjs +6 -6
- package/dist/commands/apiCommand.mjs +1 -1
- package/dist/commands/doctorCommand.mjs +2 -2
- package/dist/commands/envCommand.mjs +1 -1
- package/dist/commands/headlessCommand.mjs +7 -7
- package/dist/commands/hostCommand.mjs +2 -2
- package/dist/commands/mcpCommand.mjs +3 -3
- package/dist/commands/mirrorCommand.mjs +2 -2
- package/dist/commands/modelsCommand.mjs +5 -5
- package/dist/commands/pluginCommand.mjs +1 -1
- package/dist/commands/skillsCommand.mjs +4 -4
- package/dist/commands/updateCommand.mjs +2 -2
- package/dist/{dist-CbViwiS9.mjs → dist-BOxr8LQA.mjs} +185 -12
- package/dist/{dist-Citbv0y0.mjs → dist-K7a9yOUb.mjs} +3 -3
- package/dist/{fit-CVWDiavv.mjs → fit-BHDTSpfd.mjs} +4 -4
- package/dist/{grepSearch-BgoOOwGe-B388GxRD.mjs → grepSearch-CLtEqT4j-BnKPtNWr.mjs} +2 -2
- package/dist/index.mjs +2780 -251
- package/dist/{modelServers-BaegigV-.mjs → modelServers-CVufZd1f.mjs} +2 -2
- package/dist/{package-C9pfAdGF.mjs → package-TACInPbw.mjs} +1 -1
- package/dist/{serve-8wyGb8of.mjs → serve-OywSzShu.mjs} +733 -62
- package/dist/{store-BbvSi3KK.mjs → store-CmOg7JIt.mjs} +4 -0
- package/dist/store-OGMXhD4A.mjs +2 -0
- package/dist/{updateChecker-BAKb8KWP.mjs → updateChecker-5v_8LhXy.mjs} +1 -1
- package/package.json +14 -14
- package/dist/ConfigStore-CausUCzY.mjs +0 -2
- package/dist/store-BYeE0shc.mjs +0 -2
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { C as NotAuthenticatedError, D as sanitizeTerminalText, d as sandboxedCommandArg, l as commandTextOf, p as writePathOf, s as loadContextFiles, u as isReadOnlyTool, w as SessionRevokedError } from "./ConfigStore-
|
|
3
|
-
import { a as extractErrorMessage, d as BaseStorage, f as isPrivateIP, l as OllamaBackend, n as B4mStreamEndedError, o as getSettingsMap, p as Logger, r as createClient, s as getSettingsValue, t as B4mApiError, u as OpenAICompatibleBackend } from "./dist-
|
|
4
|
-
import {
|
|
5
|
-
import { n as COMMANDS, r as isReservedCommandName } from "./RemoteSkillSource-
|
|
2
|
+
import { C as NotAuthenticatedError, D as sanitizeTerminalText, d as sandboxedCommandArg, l as commandTextOf, p as writePathOf, s as loadContextFiles, u as isReadOnlyTool, w as SessionRevokedError } from "./ConfigStore-CO6kREaL.mjs";
|
|
3
|
+
import { a as extractErrorMessage, d as BaseStorage, f as isPrivateIP, l as OllamaBackend, n as B4mStreamEndedError, o as getSettingsMap, p as Logger, r as createClient, s as getSettingsValue, t as B4mApiError, u as OpenAICompatibleBackend } from "./dist-BOxr8LQA.mjs";
|
|
4
|
+
import { At as isPlaceholderImageSigningSecret, B as LOW_CONFIDENCE_COMPLETION_MODES, Ct as getMcpProviderMetadata, G as NotFoundError, Ht as reasoningChannelOf, I as ExpectedToolError, Jt as signImageUrl, Kt as secureParameters, M as DecisionTextPartSchema, Mt as isRetryableError, N as DecisionsRequestSchema, Rt as obfuscateApiKey, T as ChatModels, Tt as googleMapsSearchUrl, U as McpServerName, V as MODEL_DECLINED_MESSAGE, Y as PermissionDeniedError, Yt as splitEquals, a as htmlFirstH1, an as withholdsReasoning, at as SEARCH_RESULT_CARDS_LANGUAGE, bt as fromCliTodos, ft as WORK_ITEM_STATUSES, gt as createReasoningWithholder, h as ApiKeyType, i as htmlErrorTitle, in as withRetry, jt as isProviderRefusalStopReason, kt as isExpectedToolError, lt as UnprocessableEntityError, n as SESSION_ID_PATTERN, o as escapeArtifactBodyJson, pn as frontmatterHasSourceStamp, pt as assertAuthOriginMatchesApiKey, r as isValidSessionId, t as logger, w as CUSTOM_MCP_DATA_NOTICE, x as CONFIDENCE_GATE_MODES, z as LOCATION_MAP_LANGUAGE } from "./Logger-CHKCF5hd.mjs";
|
|
5
|
+
import { n as COMMANDS, r as isReservedCommandName } from "./RemoteSkillSource-D_F99yBR.mjs";
|
|
6
6
|
import { n as isPathAllowed, t as assertPathAllowed } from "./pathValidation-BRqf4HFX-CHwtwp3O.mjs";
|
|
7
7
|
import { n as isTerminalShellStatus, t as getShellSessionManager } from "./ShellSessionManager-6o8KZzl1-vrbPAUTq.mjs";
|
|
8
|
-
import { d as detectRuntimes, m as modelBlobsOf } from "./dist-
|
|
9
|
-
import { A as serverRuntimeId, B as parseGenerationInput, Ct as withDefaultOllamaPort, F as GENERATION_FIELDS, H as parseModelContextSetting, I as LOCAL_OLLAMA_RUNTIME_ID, L as REASONING_EFFORT_SETTINGS, R as effortSent, S as desktopUserDataFile, V as parseLocalModelId, X as clean, a as needsCredential, f as serverFetch, i as loginHint, l as resolveServerTarget, m as unusableStatus, r as loadModelServers, y as SSH_PROBE_TIMEOUT_MS, z as localModelId } from "./modelServers-
|
|
8
|
+
import { d as detectRuntimes, m as modelBlobsOf } from "./dist-K7a9yOUb.mjs";
|
|
9
|
+
import { A as serverRuntimeId, B as parseGenerationInput, Ct as withDefaultOllamaPort, F as GENERATION_FIELDS, H as parseModelContextSetting, I as LOCAL_OLLAMA_RUNTIME_ID, L as REASONING_EFFORT_SETTINGS, R as effortSent, S as desktopUserDataFile, V as parseLocalModelId, X as clean, a as needsCredential, f as serverFetch, i as loginHint, l as resolveServerTarget, m as unusableStatus, r as loadModelServers, y as SSH_PROBE_TIMEOUT_MS, z as localModelId } from "./modelServers-CVufZd1f.mjs";
|
|
10
10
|
import { createHash, randomBytes } from "crypto";
|
|
11
11
|
import { existsSync, lstatSync, promises, readdirSync, realpathSync, rmSync, statSync } from "fs";
|
|
12
12
|
import os, { homedir } from "os";
|
|
@@ -36,7 +36,7 @@ import times from "lodash/times.js";
|
|
|
36
36
|
import * as Diff from "diff";
|
|
37
37
|
import { diffLines } from "diff";
|
|
38
38
|
import matter from "gray-matter";
|
|
39
|
-
import { parse } from "shell-quote";
|
|
39
|
+
import { parse as parse$1 } from "shell-quote";
|
|
40
40
|
import { EventEmitter } from "events";
|
|
41
41
|
import { fileURLToPath } from "url";
|
|
42
42
|
import WebSocket from "ws";
|
|
@@ -1278,6 +1278,7 @@ var __exportAll = (all, no_symbols) => {
|
|
|
1278
1278
|
//#endregion
|
|
1279
1279
|
//#region ../../b4m-core/auth/dist/apiKeyService/index.mjs
|
|
1280
1280
|
var apiKeyService_exports$1 = /* @__PURE__ */ __exportAll$2({
|
|
1281
|
+
EXPIRED_API_KEY: () => EXPIRED_API_KEY,
|
|
1281
1282
|
createApiKey: () => createApiKey,
|
|
1282
1283
|
createApiKeySchema: () => createApiKeySchema,
|
|
1283
1284
|
deleteApiKey: () => deleteApiKey,
|
|
@@ -1285,6 +1286,7 @@ var apiKeyService_exports$1 = /* @__PURE__ */ __exportAll$2({
|
|
|
1285
1286
|
getApiKey: () => getApiKey,
|
|
1286
1287
|
getApiKeySchema: () => getApiKeySchema,
|
|
1287
1288
|
getEffectiveApiKey: () => getEffectiveApiKey,
|
|
1289
|
+
getEffectiveApiKeyWithSource: () => getEffectiveApiKeyWithSource,
|
|
1288
1290
|
getEffectiveLLMApiKeys: () => getEffectiveLLMApiKeys,
|
|
1289
1291
|
getFirecrawlConfig: () => getFirecrawlConfig,
|
|
1290
1292
|
getFmpApiKey: () => getFmpApiKey,
|
|
@@ -1297,7 +1299,8 @@ var apiKeyService_exports$1 = /* @__PURE__ */ __exportAll$2({
|
|
|
1297
1299
|
listOwnApiKeys: () => listOwnApiKeys,
|
|
1298
1300
|
setApiKey: () => setApiKey,
|
|
1299
1301
|
sharedAdminKeyProviders: () => sharedAdminKeyProviders,
|
|
1300
|
-
t: () => apiKeyService_exports$2
|
|
1302
|
+
t: () => apiKeyService_exports$2,
|
|
1303
|
+
userKeyProviders: () => userKeyProviders
|
|
1301
1304
|
});
|
|
1302
1305
|
const createApiKeySchema = z$1.object({
|
|
1303
1306
|
apiKey: z$1.string().min(6),
|
|
@@ -1373,6 +1376,8 @@ const ENV_KEY_MAP = {
|
|
|
1373
1376
|
[ApiKeyType.typesafe]: "TYPESAFE_API_KEY"
|
|
1374
1377
|
};
|
|
1375
1378
|
const envKey = (name) => process.env.B4M_SELF_HOST === "true" && process.env[name]?.trim() || null;
|
|
1379
|
+
/** What getEffectiveLLMApiKeys returns in place of a user's own key once it has expired. */
|
|
1380
|
+
const EXPIRED_API_KEY = "expired";
|
|
1376
1381
|
const getSerperKey = async (adapters) => {
|
|
1377
1382
|
const { db } = adapters;
|
|
1378
1383
|
return (await db.adminSettings.findBySettingName("SerperKey"))?.settingValue;
|
|
@@ -1405,25 +1410,47 @@ const getFmpApiKey = async (adapters) => {
|
|
|
1405
1410
|
const { db } = adapters;
|
|
1406
1411
|
return (await db.adminSettings.findBySettingName("FmpApiKey"))?.settingValue;
|
|
1407
1412
|
};
|
|
1408
|
-
|
|
1413
|
+
/**
|
|
1414
|
+
* getEffectiveApiKey, also reporting whether the key is the user's own or the platform's, so a
|
|
1415
|
+
* usage record can tell platform-quota consumption apart from calls billed to a user's own account.
|
|
1416
|
+
*/
|
|
1417
|
+
const getEffectiveApiKeyWithSource = async (userId, params, adapters) => {
|
|
1409
1418
|
const { db } = adapters;
|
|
1410
|
-
|
|
1411
|
-
if (
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
}
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1419
|
+
const userKey = (await getApiKey(userId, params, adapters))?.apiKey;
|
|
1420
|
+
if (userKey) return {
|
|
1421
|
+
key: userKey,
|
|
1422
|
+
source: "user"
|
|
1423
|
+
};
|
|
1424
|
+
const demoKeyName = params.demoKeyName || DEMO_KEY_MAP[params.type];
|
|
1425
|
+
if (demoKeyName) {
|
|
1426
|
+
const settings = await db.adminSettings.findBySettingName(demoKeyName);
|
|
1427
|
+
if (settings?.settingValue) return {
|
|
1428
|
+
key: settings.settingValue,
|
|
1429
|
+
source: "platform"
|
|
1430
|
+
};
|
|
1418
1431
|
}
|
|
1419
|
-
|
|
1432
|
+
const envName = ENV_KEY_MAP[params.type];
|
|
1433
|
+
const selfHostKey = envName ? envKey(envName) : null;
|
|
1434
|
+
return selfHostKey ? {
|
|
1435
|
+
key: selfHostKey,
|
|
1436
|
+
source: "platform"
|
|
1437
|
+
} : void 0;
|
|
1420
1438
|
};
|
|
1439
|
+
const getEffectiveApiKey = async (userId, params, adapters) => (await getEffectiveApiKeyWithSource(userId, params, adapters))?.key;
|
|
1421
1440
|
const sharedAdminKeySources = /* @__PURE__ */ new WeakMap();
|
|
1422
1441
|
/**
|
|
1423
1442
|
* For a result of getEffectiveLLMApiKeys: which providers resolved to the shared admin-setting
|
|
1424
1443
|
* key (not a user's own key, not 'expired', not a self-host env key). Undefined for any other object.
|
|
1425
1444
|
*/
|
|
1426
1445
|
const sharedAdminKeyProviders = (keys) => sharedAdminKeySources.get(keys);
|
|
1446
|
+
const userKeySources = /* @__PURE__ */ new WeakMap();
|
|
1447
|
+
/**
|
|
1448
|
+
* For a result of getEffectiveLLMApiKeys: which providers resolved to the user's own saved key
|
|
1449
|
+
* (including an expired one), as opposed to a platform admin-setting or self-host env key. Lets a
|
|
1450
|
+
* caller tell a provider rejecting the user's key (user-side) from one rejecting ours (outage).
|
|
1451
|
+
* Empty for any other object.
|
|
1452
|
+
*/
|
|
1453
|
+
const userKeyProviders = (keys) => userKeySources.get(keys) ?? /* @__PURE__ */ new Set();
|
|
1427
1454
|
const getEffectiveLLMApiKeys = async (userId, adapters, options) => {
|
|
1428
1455
|
const { db } = adapters;
|
|
1429
1456
|
const logger = options?.logger;
|
|
@@ -1481,7 +1508,7 @@ const getEffectiveLLMApiKeys = async (userId, adapters, options) => {
|
|
|
1481
1508
|
const ollamaEnabled = enableOllama === "true" || enableOllama === true;
|
|
1482
1509
|
const keyOrExpired = (apiKey) => {
|
|
1483
1510
|
if (!apiKey) return null;
|
|
1484
|
-
if (apiKey.expiresAt && apiKey.expiresAt < /* @__PURE__ */ new Date()) return
|
|
1511
|
+
if (apiKey.expiresAt && apiKey.expiresAt < /* @__PURE__ */ new Date()) return EXPIRED_API_KEY;
|
|
1485
1512
|
return apiKey.apiKey;
|
|
1486
1513
|
};
|
|
1487
1514
|
const keys = {
|
|
@@ -1501,6 +1528,18 @@ const getEffectiveLLMApiKeys = async (userId, adapters, options) => {
|
|
|
1501
1528
|
openai: !openaiUserKey && !!openaiDemoKey,
|
|
1502
1529
|
anthropic: !anthropicUserKey && !!anthropicDemoKey
|
|
1503
1530
|
});
|
|
1531
|
+
const userKeyByProvider = {
|
|
1532
|
+
openai: openaiUserKey,
|
|
1533
|
+
anthropic: anthropicUserKey,
|
|
1534
|
+
gemini: geminiUserKey,
|
|
1535
|
+
bfl: bflUserKey,
|
|
1536
|
+
xai: xaiUserKey,
|
|
1537
|
+
kimi: kimiUserKey,
|
|
1538
|
+
deepseek: deepseekUserKey,
|
|
1539
|
+
voyageai: voyageaiUserKey,
|
|
1540
|
+
typesafe: typesafeUserKey
|
|
1541
|
+
};
|
|
1542
|
+
userKeySources.set(keys, new Set(Object.keys(userKeyByProvider).filter((provider) => userKeyByProvider[provider] !== null)));
|
|
1504
1543
|
return keys;
|
|
1505
1544
|
};
|
|
1506
1545
|
const setApiKeySchema = z$1.object({
|
|
@@ -1536,6 +1575,7 @@ const deleteApiKey = async (userId, parameters, { db }) => {
|
|
|
1536
1575
|
return apiKey;
|
|
1537
1576
|
};
|
|
1538
1577
|
var apiKeyService_exports$2 = /* @__PURE__ */ __exportAll({
|
|
1578
|
+
EXPIRED_API_KEY: () => EXPIRED_API_KEY,
|
|
1539
1579
|
createApiKey: () => createApiKey,
|
|
1540
1580
|
createApiKeySchema: () => createApiKeySchema,
|
|
1541
1581
|
deleteApiKey: () => deleteApiKey,
|
|
@@ -1543,6 +1583,7 @@ var apiKeyService_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
1543
1583
|
getApiKey: () => getApiKey,
|
|
1544
1584
|
getApiKeySchema: () => getApiKeySchema,
|
|
1545
1585
|
getEffectiveApiKey: () => getEffectiveApiKey,
|
|
1586
|
+
getEffectiveApiKeyWithSource: () => getEffectiveApiKeyWithSource,
|
|
1546
1587
|
getEffectiveLLMApiKeys: () => getEffectiveLLMApiKeys,
|
|
1547
1588
|
getFirecrawlConfig: () => getFirecrawlConfig,
|
|
1548
1589
|
getFmpApiKey: () => getFmpApiKey,
|
|
@@ -1554,7 +1595,8 @@ var apiKeyService_exports$2 = /* @__PURE__ */ __exportAll({
|
|
|
1554
1595
|
getWolframAlphaKey: () => getWolframAlphaKey,
|
|
1555
1596
|
listOwnApiKeys: () => listOwnApiKeys,
|
|
1556
1597
|
setApiKey: () => setApiKey,
|
|
1557
|
-
sharedAdminKeyProviders: () => sharedAdminKeyProviders
|
|
1598
|
+
sharedAdminKeyProviders: () => sharedAdminKeyProviders,
|
|
1599
|
+
userKeyProviders: () => userKeyProviders
|
|
1558
1600
|
});
|
|
1559
1601
|
//#endregion
|
|
1560
1602
|
//#region ../../b4m-core/services/dist/apiKeyService/index.mjs
|
|
@@ -2528,7 +2570,7 @@ const WEB_SEARCH_MAP_PROMPT = [
|
|
|
2528
2570
|
"explanation or citations. Omit it only if none of the places actually answer the question."
|
|
2529
2571
|
].join("\n");
|
|
2530
2572
|
//#endregion
|
|
2531
|
-
//#region ../../b4m-core/services/dist/websearch-
|
|
2573
|
+
//#region ../../b4m-core/services/dist/websearch-Bm2eZQma.mjs
|
|
2532
2574
|
/**
|
|
2533
2575
|
* Shown to the model under tool results that carry the turn's shared numbers, so it cites them the
|
|
2534
2576
|
* way forced retrieval's header asks it to cite the documents numbered before them. Keep it a directive:
|
|
@@ -2665,6 +2707,41 @@ function safeImageUrl(value) {
|
|
|
2665
2707
|
function dedupeImages(values) {
|
|
2666
2708
|
return [...new Set(values.filter((v) => !!v))].slice(0, MAX_IMAGES_PER_RESULT);
|
|
2667
2709
|
}
|
|
2710
|
+
const GOOGLE_HOSTS = /* @__PURE__ */ new Set(["google.com", "www.google.com"]);
|
|
2711
|
+
/** Host of a breadcrumb-style `displayed_link` ("https://host > a > b"), or undefined when it is not a URL. */
|
|
2712
|
+
function breadcrumbHost(displayedLink) {
|
|
2713
|
+
if (typeof displayedLink !== "string" || !displayedLink) return void 0;
|
|
2714
|
+
try {
|
|
2715
|
+
const shown = new URL(displayedLink.trim().split(/[\s\u203a>]/)[0]);
|
|
2716
|
+
return (shown.protocol === "https:" || shown.protocol === "http:") && !GOOGLE_HOSTS.has(shown.hostname) ? shown.hostname : void 0;
|
|
2717
|
+
} catch {
|
|
2718
|
+
return;
|
|
2719
|
+
}
|
|
2720
|
+
}
|
|
2721
|
+
const MAX_PLATFORM_NAME_CHARS = 40;
|
|
2722
|
+
/** Platform name from SerpAPI's `source` ("Reddit \u00b7 r/investing" -> "Reddit"), never a Google name. */
|
|
2723
|
+
function sourcePlatformName(source) {
|
|
2724
|
+
if (typeof source !== "string") return void 0;
|
|
2725
|
+
const name = source.split(/\s\u00b7\s/)[0]?.replace(/[[\]()\r\n]/g, "").trim();
|
|
2726
|
+
return name && !/^google\b/i.test(name) ? name.slice(0, MAX_PLATFORM_NAME_CHARS) : void 0;
|
|
2727
|
+
}
|
|
2728
|
+
/**
|
|
2729
|
+
* SerpAPI can return Google's own redirect (`google.com/goto?url=<opaque token>`) as `link`, which
|
|
2730
|
+
* hides the destination. Returns what to label it with, or undefined for any other link: the host
|
|
2731
|
+
* of the breadcrumb-style `displayed_link` when that is a URL, else the platform name from `source`
|
|
2732
|
+
* for hits whose breadcrumb is an engagement count ("10+ comments", "920+ views"). Only the host is
|
|
2733
|
+
* read from the breadcrumb: its path follows the site's own breadcrumb names, not its URL path, and
|
|
2734
|
+
* is cut short with an ellipsis when long, while the host always comes first and survives both.
|
|
2735
|
+
*/
|
|
2736
|
+
function googleRedirectDisplayHost(link, displayedLink, source) {
|
|
2737
|
+
try {
|
|
2738
|
+
const parsed = new URL(link);
|
|
2739
|
+
if (!GOOGLE_HOSTS.has(parsed.hostname) || !/^\/(goto|url)$/.test(parsed.pathname)) return void 0;
|
|
2740
|
+
} catch {
|
|
2741
|
+
return;
|
|
2742
|
+
}
|
|
2743
|
+
return breadcrumbHost(displayedLink) ?? sourcePlatformName(source);
|
|
2744
|
+
}
|
|
2668
2745
|
/**
|
|
2669
2746
|
* `inline_images` and `shopping_results` are sibling arrays rather than nested under the organic
|
|
2670
2747
|
* hits, so they are attached by exact link match only - a positional or same-host guess would
|
|
@@ -2988,10 +3065,12 @@ function createSerpApiProvider(adapters) {
|
|
|
2988
3065
|
const extraImages = indexImagesByLink(data.inline_images, data.shopping_results);
|
|
2989
3066
|
return organic.filter((r) => !!r && typeof r.link === "string").map((r) => {
|
|
2990
3067
|
const images = dedupeImages([...extraImages.get(r.link) ?? [], safeImageUrl(r.thumbnail)]);
|
|
3068
|
+
const displayHost = googleRedirectDisplayHost(r.link, r.displayed_link, r.source);
|
|
2991
3069
|
return {
|
|
2992
3070
|
title: r.title ?? r.link,
|
|
2993
3071
|
url: r.link,
|
|
2994
3072
|
snippet: r.snippet ?? "",
|
|
3073
|
+
...displayHost ? { displayHost } : {},
|
|
2995
3074
|
...images.length > 0 ? {
|
|
2996
3075
|
thumbnail: images[0],
|
|
2997
3076
|
images
|
|
@@ -3451,6 +3530,7 @@ async function performWebSearch(adapters, params, imageUrlSigningSecret = "", re
|
|
|
3451
3530
|
sourceSystem: "web_search",
|
|
3452
3531
|
relevanceScore: 1 - index * .1,
|
|
3453
3532
|
fullContext: result.snippet,
|
|
3533
|
+
...result.displayHost ? { displayHost: result.displayHost } : {},
|
|
3454
3534
|
...withImages && result.thumbnail ? {
|
|
3455
3535
|
thumbnail: result.thumbnail,
|
|
3456
3536
|
images: result.images
|
|
@@ -3463,7 +3543,7 @@ async function performWebSearch(adapters, params, imageUrlSigningSecret = "", re
|
|
|
3463
3543
|
const resultLabel = (index) => numberedCitables ? `[${numberedCitables[index].metadata?.citationIndex}]` : `${index + 1}.`;
|
|
3464
3544
|
const formattedResults = results.map((result, index) => {
|
|
3465
3545
|
const imageLine = withImages && result.images?.length ? `Images: ${result.images.map((url) => signImageUrl(url, imageUrlSigningSecret)).join(" | ")}\n` : "";
|
|
3466
|
-
return `${resultLabel(index)} **${stripNewlines(result.title)}**\n${stripNewlines(result.snippet)}\n` + imageLine + `Source: [${safeHostname(result.url)}](${result.url})\n`;
|
|
3546
|
+
return `${resultLabel(index)} **${stripNewlines(result.title)}**\n${stripNewlines(result.snippet)}\n` + imageLine + `Source: [${stripNewlines(result.displayHost ?? safeHostname(result.url))}](${result.url})\n`;
|
|
3467
3547
|
}).join("\n");
|
|
3468
3548
|
const imageSection = withImages && imageResults.length ? `\n${formatImageResults(imageResults, imageUrlSigningSecret)}\n` : "";
|
|
3469
3549
|
const placeSection = withPlaces ? `\n${formatPlaceResults(places, anchor, numberedCitables ? citationNumbersById(numberedCitables) : void 0)}\n` : "";
|
|
@@ -3643,7 +3723,7 @@ async function getModelForWrite(user, modelId, deps) {
|
|
|
3643
3723
|
return isModelOwner(model, user) ? model : null;
|
|
3644
3724
|
}
|
|
3645
3725
|
//#endregion
|
|
3646
|
-
//#region ../../b4m-core/services/dist/toolGenerators-
|
|
3726
|
+
//#region ../../b4m-core/services/dist/toolGenerators-ByeEdDON.mjs
|
|
3647
3727
|
const diceRoll = async (parameters) => {
|
|
3648
3728
|
if (!parameters?.sides || !parameters?.times) throw new Error("Tool dice roll: Missing required parameters");
|
|
3649
3729
|
return sum(times(parameters.times, () => random(1, parameters.sides))).toString();
|
|
@@ -4482,7 +4562,7 @@ const askUserQuestionTool = {
|
|
|
4482
4562
|
* re-export them without pulling the full tool graph. `index.ts` re-exports them
|
|
4483
4563
|
* so the server barrel's public API is unchanged.
|
|
4484
4564
|
*/
|
|
4485
|
-
const generateTools = (userId, user, logger, { db, getEntitlements, retrievalFilter, kbScope, inlinedAttachmentIds, attachedFileIds, fullyInlinedAttachmentIds, suppressLakeArms, sessionRetrievalTags, sessionReaderConsentDatalakeTags, sessionLakeScopeExplicit, sessionIncludeLibraryFiles, sessionPreauthorizedLakeIds, organizationId, authOrigin, apiKeyId, questId, requestConfirmation, slackDestination, numberCitables, decide, toLedgerModel, getAbortSignal }, storage, imageGenerateStorage, statusUpdate, onStart, onFinish, llm, config, model, imageProcessorLambdaName, tools, allowedDirectories, entitlementKeys = [], sessionId, codeMinifier, availableModels, onToolLlmUsage, servingModel) => {
|
|
4565
|
+
const generateTools = (userId, user, logger, { db, getEntitlements, retrievalFilter, kbScope, inlinedAttachmentIds, attachedFileIds, fullyInlinedAttachmentIds, suppressLakeArms, sessionRetrievalTags, sessionReaderConsentDatalakeTags, sessionLakeScopeExplicit, sessionIncludeLibraryFiles, sessionPreauthorizedLakeIds, organizationId, governingOrgModelPolicy, authOrigin, apiKeyId, questId, requestConfirmation, slackDestination, numberCitables, decide, toLedgerModel, getAbortSignal }, storage, imageGenerateStorage, statusUpdate, onStart, onFinish, llm, config, model, imageProcessorLambdaName, tools, allowedDirectories, entitlementKeys = [], sessionId, codeMinifier, availableModels, onToolLlmUsage, servingModel) => {
|
|
4486
4566
|
assertAuthOriginMatchesApiKey(authOrigin, apiKeyId);
|
|
4487
4567
|
const context = {
|
|
4488
4568
|
userId,
|
|
@@ -4516,6 +4596,7 @@ const generateTools = (userId, user, logger, { db, getEntitlements, retrievalFil
|
|
|
4516
4596
|
sessionIncludeLibraryFiles,
|
|
4517
4597
|
sessionPreauthorizedLakeIds,
|
|
4518
4598
|
organizationId,
|
|
4599
|
+
governingOrgModelPolicy,
|
|
4519
4600
|
authOrigin,
|
|
4520
4601
|
apiKeyId,
|
|
4521
4602
|
codeMinifier,
|
|
@@ -6793,7 +6874,7 @@ const getCliOnlyTools = async () => {
|
|
|
6793
6874
|
const [{ createFileTool }, { globFilesTool }, { grepSearchTool }, { deleteFileTool }, { bashExecuteTool }] = await Promise.all([
|
|
6794
6875
|
import("./createFile-B8bur5Rb-CVzCarEA.mjs"),
|
|
6795
6876
|
import("./globFiles-CwJ8qmYo-BR5b2KvO.mjs"),
|
|
6796
|
-
import("./grepSearch-
|
|
6877
|
+
import("./grepSearch-CLtEqT4j-BnKPtNWr.mjs"),
|
|
6797
6878
|
import("./deleteFile-9B3gW_Nb-DG2sovIl.mjs"),
|
|
6798
6879
|
import("./bashExecute-CrdPpBqk-CgK1gZa2.mjs")
|
|
6799
6880
|
]);
|
|
@@ -7754,7 +7835,7 @@ function isWriteTargetingPlanFile(writePath, cwd = process.cwd()) {
|
|
|
7754
7835
|
* it and the live mode so they never exceed the parent but still honor a mid-run plan switch.
|
|
7755
7836
|
*/
|
|
7756
7837
|
async function resolveInteractionMode(override) {
|
|
7757
|
-
const { useCliStore } = await import("./store-
|
|
7838
|
+
const { useCliStore } = await import("./store-OGMXhD4A.mjs");
|
|
7758
7839
|
const liveInteractionMode = useCliStore.getState().interactionMode;
|
|
7759
7840
|
return override ? clampInteractionMode(liveInteractionMode, override) : liveInteractionMode;
|
|
7760
7841
|
}
|
|
@@ -8368,7 +8449,7 @@ function classifyAtDepth(command, depth) {
|
|
|
8368
8449
|
};
|
|
8369
8450
|
let tokens;
|
|
8370
8451
|
try {
|
|
8371
|
-
tokens = parse(trimmed);
|
|
8452
|
+
tokens = parse$1(trimmed);
|
|
8372
8453
|
} catch {
|
|
8373
8454
|
return {
|
|
8374
8455
|
level: "high",
|
|
@@ -14269,6 +14350,7 @@ function buildCliToolList(input, wrapDeps) {
|
|
|
14269
14350
|
input.findDefinitionTool,
|
|
14270
14351
|
input.getFileStructureTool,
|
|
14271
14352
|
...input.workItemTools ?? [],
|
|
14353
|
+
...input.peerTools ?? [],
|
|
14272
14354
|
...input.skillTool ? [input.skillTool] : [],
|
|
14273
14355
|
...input.dynamicAgentTool ? [input.dynamicAgentTool] : [],
|
|
14274
14356
|
...input.coordinateTaskTool ? [input.coordinateTaskTool] : []
|
|
@@ -15147,7 +15229,7 @@ function sessionCommandPrefixes(command) {
|
|
|
15147
15229
|
if (classifyCommandRisk(text).level === "high") return null;
|
|
15148
15230
|
let tokens;
|
|
15149
15231
|
try {
|
|
15150
|
-
tokens = parse(text, (key) => `$${key}`);
|
|
15232
|
+
tokens = parse$1(text, (key) => `$${key}`);
|
|
15151
15233
|
} catch {
|
|
15152
15234
|
return null;
|
|
15153
15235
|
}
|
|
@@ -16536,37 +16618,6 @@ function createSkillTool(deps) {
|
|
|
16536
16618
|
//#endregion
|
|
16537
16619
|
//#region src/tools/writeTodosTool.ts
|
|
16538
16620
|
/**
|
|
16539
|
-
* Valid status values for validation
|
|
16540
|
-
*/
|
|
16541
|
-
const VALID_STATUSES = [
|
|
16542
|
-
"pending",
|
|
16543
|
-
"in_progress",
|
|
16544
|
-
"completed",
|
|
16545
|
-
"cancelled"
|
|
16546
|
-
];
|
|
16547
|
-
/**
|
|
16548
|
-
* Validate todo items
|
|
16549
|
-
* @throws Error if validation fails
|
|
16550
|
-
*/
|
|
16551
|
-
function validateTodos(todos) {
|
|
16552
|
-
if (!Array.isArray(todos)) throw new Error("write_todos: todos must be an array");
|
|
16553
|
-
if (todos.length === 0) throw new Error("write_todos: todos array cannot be empty");
|
|
16554
|
-
let inProgressCount = 0;
|
|
16555
|
-
const validatedTodos = todos.map((item, index) => {
|
|
16556
|
-
if (!item || typeof item !== "object") throw new Error(`write_todos: item at index ${index} must be an object`);
|
|
16557
|
-
const { description, status } = item;
|
|
16558
|
-
if (typeof description !== "string" || description.trim() === "") throw new Error(`write_todos: item at index ${index} must have a non-empty description`);
|
|
16559
|
-
if (typeof status !== "string" || !VALID_STATUSES.includes(status)) throw new Error(`write_todos: item at index ${index} has invalid status "${status}". Must be one of: ${VALID_STATUSES.join(", ")}`);
|
|
16560
|
-
if (status === "in_progress") inProgressCount++;
|
|
16561
|
-
return {
|
|
16562
|
-
description: description.trim(),
|
|
16563
|
-
status
|
|
16564
|
-
};
|
|
16565
|
-
});
|
|
16566
|
-
if (inProgressCount > 1) throw new Error(`write_todos: only one task can be 'in_progress' at a time, but found ${inProgressCount}`);
|
|
16567
|
-
return validatedTodos;
|
|
16568
|
-
}
|
|
16569
|
-
/**
|
|
16570
16621
|
* Format todos for display output
|
|
16571
16622
|
*/
|
|
16572
16623
|
function formatTodosOutput(todos) {
|
|
@@ -16578,7 +16629,7 @@ function formatTodosOutput(todos) {
|
|
|
16578
16629
|
};
|
|
16579
16630
|
return todos.map((todo, index) => {
|
|
16580
16631
|
const emoji = statusEmoji[todo.status];
|
|
16581
|
-
return `${index + 1}. ${emoji} [${todo.status}] ${todo.
|
|
16632
|
+
return `${index + 1}. ${emoji} [${todo.status}] ${todo.content}`;
|
|
16582
16633
|
}).join("\n");
|
|
16583
16634
|
}
|
|
16584
16635
|
/**
|
|
@@ -16599,10 +16650,15 @@ function formatTodosOutput(todos) {
|
|
|
16599
16650
|
function createWriteTodosTool(todoStore) {
|
|
16600
16651
|
return {
|
|
16601
16652
|
toolFn: async (args) => {
|
|
16602
|
-
const
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16653
|
+
const todos = args?.todos;
|
|
16654
|
+
if (!Array.isArray(todos)) throw new Error("write_todos: todos must be an array");
|
|
16655
|
+
const { plan, warnings } = fromCliTodos(todos);
|
|
16656
|
+
const notes = warnings.length > 0 ? `\n\nNotes:\n${warnings.map((w) => `- ${w}`).join("\n")}` : "";
|
|
16657
|
+
if (todos.length > 0 && plan.items.length === 0) throw new Error(`write_todos: no valid todo items; the existing list was kept.${notes}`);
|
|
16658
|
+
todoStore.todos = plan.items;
|
|
16659
|
+
todoStore.onUpdate?.(plan.items);
|
|
16660
|
+
if (plan.items.length === 0) return "Todo list cleared.";
|
|
16661
|
+
return `Todo list updated successfully:\n\n${formatTodosOutput(plan.items)}${notes}`;
|
|
16606
16662
|
},
|
|
16607
16663
|
toolSchema: {
|
|
16608
16664
|
name: "write_todos",
|
|
@@ -16616,7 +16672,7 @@ function createWriteTodosTool(todoStore) {
|
|
|
16616
16672
|
**Important guidelines:**
|
|
16617
16673
|
- Call this tool early when receiving complex requests
|
|
16618
16674
|
- Update the list immediately when starting, completing, or cancelling tasks
|
|
16619
|
-
- Only ONE task should be 'in_progress' at a time
|
|
16675
|
+
- Only ONE task should be 'in_progress' at a time (extra ones are reset to pending)
|
|
16620
16676
|
- Never batch updates - update as soon as state changes
|
|
16621
16677
|
|
|
16622
16678
|
**Status values:**
|
|
@@ -16635,13 +16691,19 @@ If asked to "create a new React component with tests", break it down:
|
|
|
16635
16691
|
type: "object",
|
|
16636
16692
|
properties: { todos: {
|
|
16637
16693
|
type: "array",
|
|
16638
|
-
description: "Complete list of todo items. This replaces any existing list. Each item needs
|
|
16694
|
+
description: "Complete list of todo items (at most 50). This replaces any existing list. Each item needs content and a status.",
|
|
16639
16695
|
items: {
|
|
16640
16696
|
type: "object",
|
|
16641
16697
|
properties: {
|
|
16642
|
-
|
|
16698
|
+
content: {
|
|
16643
16699
|
type: "string",
|
|
16644
|
-
description: "Clear, concise description of the task"
|
|
16700
|
+
description: "Clear, concise description of the task (imperative, e.g. \"Run tests\")",
|
|
16701
|
+
maxLength: 200
|
|
16702
|
+
},
|
|
16703
|
+
activeForm: {
|
|
16704
|
+
type: "string",
|
|
16705
|
+
description: "Present-continuous form shown while in progress (e.g. \"Running tests\")",
|
|
16706
|
+
maxLength: 200
|
|
16645
16707
|
},
|
|
16646
16708
|
status: {
|
|
16647
16709
|
type: "string",
|
|
@@ -16654,7 +16716,7 @@ If asked to "create a new React component with tests", break it down:
|
|
|
16654
16716
|
description: "Current status of the task. Only ONE task can be 'in_progress' at a time."
|
|
16655
16717
|
}
|
|
16656
16718
|
},
|
|
16657
|
-
required: ["
|
|
16719
|
+
required: ["content", "status"]
|
|
16658
16720
|
}
|
|
16659
16721
|
} },
|
|
16660
16722
|
required: ["todos"]
|
|
@@ -16671,6 +16733,11 @@ function createTodoStore(onUpdate) {
|
|
|
16671
16733
|
onUpdate
|
|
16672
16734
|
};
|
|
16673
16735
|
}
|
|
16736
|
+
/** Empty the plan and tell listeners (the Ink plan block) it is gone. */
|
|
16737
|
+
function resetTodoStore(store) {
|
|
16738
|
+
store.todos = [];
|
|
16739
|
+
store.onUpdate?.([]);
|
|
16740
|
+
}
|
|
16674
16741
|
//#endregion
|
|
16675
16742
|
//#region src/tools/findDefinitionTool.ts
|
|
16676
16743
|
const execFileAsync = promisify(execFile);
|
|
@@ -19994,8 +20061,8 @@ async function buildSandbox(input) {
|
|
|
19994
20061
|
const { config, sessionId, permissionManager, checkpointStore } = input;
|
|
19995
20062
|
const log = input.log ?? consoleLog;
|
|
19996
20063
|
const [{ createSandboxRuntime }, { SandboxOrchestrator }, { DEFAULT_SANDBOX_CONFIG }, { ProxyManager }, { ViolationLogStore }] = await Promise.all([
|
|
19997
|
-
import("./SandboxRuntimeAdapter-
|
|
19998
|
-
import("./SandboxOrchestrator-
|
|
20064
|
+
import("./SandboxRuntimeAdapter-FpZRkE6D.mjs"),
|
|
20065
|
+
import("./SandboxOrchestrator-ULWvuUct.mjs"),
|
|
19999
20066
|
import("./types-BFIvwByC.mjs"),
|
|
20000
20067
|
import("./ProxyManager-TxEKlgdO.mjs"),
|
|
20001
20068
|
import("./ViolationLogStore-byEhxa2A.mjs")
|
|
@@ -21360,7 +21427,7 @@ var SubagentOrchestrator = class {
|
|
|
21360
21427
|
const depth = options.depth ?? 1;
|
|
21361
21428
|
if (depth >= 3) throw new Error(`Cannot spawn agent "${agentName}": subagent nesting depth ${depth} reached the limit of 3. Deeper delegation is blocked to prevent unbounded recursion.`);
|
|
21362
21429
|
const resumeId = options.resumeId ?? `sub-${randomBytes(4).toString("hex")}`;
|
|
21363
|
-
const { useCliStore } = await import("./store-
|
|
21430
|
+
const { useCliStore } = await import("./store-OGMXhD4A.mjs");
|
|
21364
21431
|
const parentInteractionMode = options.parentInteractionMode ?? useCliStore.getState().interactionMode;
|
|
21365
21432
|
const effectiveInteractionMode = clampInteractionMode(options.interactionMode ?? parentInteractionMode, parentInteractionMode);
|
|
21366
21433
|
let agentDef;
|
|
@@ -22110,4 +22177,4 @@ var AgentHistoryStore = class {
|
|
|
22110
22177
|
}
|
|
22111
22178
|
};
|
|
22112
22179
|
//#endregion
|
|
22113
|
-
export {
|
|
22180
|
+
export { SIGNED_OUT_BANNER as $, createTodoStore as A, searchFiles as At, isConnectionDrop as B, formatBlockersOutput as C, processFileReferences as Ct, createGetFileStructureTool as D, SessionStore as Dt, formatDecisionsOutput as E, CommandHistoryStore as Et, createCoordinateTaskTool as F, USAGE_CACHE_TTL as Ft, ALWAYS_DENIED_FOR_AGENTS as G, PermissionManager as H, createResumeAgentTool as I, DEFAULT_RETRY_CONFIG as J, DEFAULT_AGENT_MODEL as K, createBackgroundAgentTools as L, resetTodoStore as M, COMPACTION_SUMMARY_MARKER as Mt, createSkillTool as N, DEFAULT_SUBAGENT_HISTORY_TTL_MS as Nt, createWorkItemTools as O, searchCommands as Ot, parseAgentConfig as P, MAX_PASTE_SIZE as Pt, NoLocalModelsError as Q, createAgentDelegateTool as R, createBlockerTools as S, CustomCommandStore as St, createDecisionStore as T, CheckpointStore as Tt, buildCliToolList as U, substituteArguments as V, generateCliTools as W, LOCAL_SESSION_CONTINUES as X, DEFAULT_THOROUGHNESS as Y, LOGGED_OUT_RESTART as Z, createSseBackend as _, wrapTools as _t, loadProjectContext as a, loginBlocked as at, formatReviewGatesOutput as b, classifyCommandRisk as bt, checkSavedSignIn as c, signInUncheckedMessage as ct, attachLocalModels as d, buildSystemPrompt as dt, SIGN_IN_DURING_TURN as et, buildLlmBackend as f, buildSkillsPromptSection as ft, withSignedOutLocalDefault as g, findIterationBoundary as gt, resolveSignedOutHeadlessModel as h, createToolSearchTool as ht, buildProjectAgentStore as i, SignedOutCloudBackend as it, createWriteTodosTool as j, warmFileCache as jt, createFindDefinitionTool as k, formatFileSize as kt, settleSignInRefresh as l, signedOutCommandMessage as lt, resolveHeadlessModel as m, ReActAgent as mt, BackgroundAgentManager as n, SIGN_IN_EXPIRED_HEADLESS as nt, McpManager as o, signInUncheckedHeadlessMessage as ot, defaultLlmBackendDeps as p, DeferredToolRegistry as pt, DEFAULT_MAX_ITERATIONS as q, SubagentOrchestrator as r, SIGN_IN_HINT as rt, buildSandbox as s, signInUncheckedLoginMessage as st, AgentHistoryStore as t, SIGN_IN_EXPIRED as tt, startupMode as u, signedOutNoMatchMessage as ut, createReviewGateStore as v, getProcessHooks as vt, createDecisionLogTool as w, hasFileReferences as wt, createBlockerStore as x, getPlanModeFilePath as xt, createReviewGateTool as y, setWebSocketToolExecutor as yt, FallbackLlmBackend as z };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { b as AuthenticatedApiClient, t as ConfigStore, x as DeviceFlowClient } from "./ConfigStore-
|
|
3
|
-
import { t as logger } from "./Logger-
|
|
4
|
-
import { t as version } from "./package-
|
|
2
|
+
import { b as AuthenticatedApiClient, t as ConfigStore, x as DeviceFlowClient } from "./ConfigStore-CO6kREaL.mjs";
|
|
3
|
+
import { t as logger } from "./Logger-CHKCF5hd.mjs";
|
|
4
|
+
import { t as version } from "./package-TACInPbw.mjs";
|
|
5
5
|
import { isAxiosError } from "axios";
|
|
6
6
|
import { Readable } from "node:stream";
|
|
7
7
|
//#region src/auth/OAuthClient.ts
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { t as logger } from "./Logger-
|
|
3
|
-
import { a as getContainerSocketPaths, c as resolveSandboxPath, o as getProtectedWorkspacePaths, s as isBinaryAvailable, t as assertProxyPort } from "./SandboxRuntimeAdapter-
|
|
2
|
+
import { t as logger } from "./Logger-CHKCF5hd.mjs";
|
|
3
|
+
import { a as getContainerSocketPaths, c as resolveSandboxPath, o as getProtectedWorkspacePaths, s as isBinaryAvailable, t as assertProxyPort } from "./SandboxRuntimeAdapter-DpDSET-A.mjs";
|
|
4
4
|
import { lstatSync, mkdirSync, statSync } from "fs";
|
|
5
5
|
import os from "os";
|
|
6
6
|
import path from "path";
|