bazilion 0.59.0 → 0.60.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 +1 -1
- package/dist/cli.js.map +1 -1
- package/dist/daemon.js +180 -37
- package/dist/daemon.js.map +1 -1
- package/dist/web/client/assets/{AddProviderDialog-CbBtkgU7.js → AddProviderDialog-PK8ZRkVP.js} +1 -1
- package/dist/web/client/assets/{AgentTemplateParts-Tx0RJoDa.js → AgentTemplateParts-DXqswWc_.js} +1 -1
- package/dist/web/client/assets/{ConfirmDialog-Du8-95Zj.js → ConfirmDialog-C7Id43en.js} +1 -1
- package/dist/web/client/assets/{ConnectionsView-Dg9kLuab.js → ConnectionsView-sCcb1DqZ.js} +1 -1
- package/dist/web/client/assets/{SkillsParts-TYzEfrVu.js → SkillsParts-ClIFyTi8.js} +1 -1
- package/dist/web/client/assets/{SpawnTeamModal-Dr98zpUf.js → SpawnTeamModal-BxRg6e3v.js} +1 -1
- package/dist/web/client/assets/{TeamForm-DaH5H-LF.js → TeamForm-e_yDks2o.js} +1 -1
- package/dist/web/client/assets/{TeamThread-DmtbrFq1.js → TeamThread-BFz7jkrt.js} +1 -1
- package/dist/web/client/assets/{UnsavedChangesGuard-fvP4Xr0R.js → UnsavedChangesGuard-Cgc9WraN.js} +1 -1
- package/dist/web/client/assets/{_id--1i1fY0o.js → _id-C24VHwwo.js} +1 -1
- package/dist/web/client/assets/{_id-C_s4pMAk.js → _id-DeCenuG4.js} +1 -1
- package/dist/web/client/assets/{access-99X0FS-H.js → access-Dh3w6dHo.js} +1 -1
- package/dist/web/client/assets/{agents-CDJMwJL1.js → agents-CUQ-DKWA.js} +1 -1
- package/dist/web/client/assets/{agents-DVAJFWJI.js → agents-DHTN7twQ.js} +1 -1
- package/dist/web/client/assets/{attention-CDzRuQGN.js → attention-pzVO90iq.js} +1 -1
- package/dist/web/client/assets/{config-9GESe8FI.js → config-B29EfkVV.js} +1 -1
- package/dist/web/client/assets/{index-DkK2xZ2o.js → index-B8Bft71n.js} +3 -3
- package/dist/web/client/assets/{login-DUmrDZjN.js → login-CUACsY1J.js} +1 -1
- package/dist/web/client/assets/{manage-D6zhY8hA.js → manage-DrwsI5ur.js} +1 -1
- package/dist/web/client/assets/{mcp-ByioWHXZ.js → mcp-DFBkafUW.js} +1 -1
- package/dist/web/client/assets/{routes-DEMmBJiz.js → routes-DPz6Wrxz.js} +3 -3
- package/dist/web/client/assets/{skills-a52e5W9Z.js → skills-B0khtQXg.js} +1 -1
- package/dist/web/client/assets/{style-CiyV21dp.js → style-BEcLEdJR.js} +1 -1
- package/dist/web/client/assets/{system-wJXOiU47.js → system-DexaXrV1.js} +1 -1
- package/dist/web/client/assets/{teams-vRmMRnY_.js → teams-CUgnrqA5.js} +1 -1
- package/dist/web/client/assets/{teams-wLJHtFW_.js → teams-DC-abyJ_.js} +1 -1
- package/dist/web/client/assets/{telegram-CUsT8ZzL.js → telegram-DlnKiJP1.js} +1 -1
- package/dist/web/client/assets/{tools-NMtdwKi0.js → tools-BefW81ig.js} +1 -1
- package/dist/web/client/assets/{usage-DiIpfPPk.js → usage-oJ-ACG85.js} +1 -1
- package/dist/web/client/assets/{welcome-BWN0jtZP.js → welcome-BzesXAyM.js} +1 -1
- package/dist/web/server/assets/{ConnectionsView-CplWLHII.js → ConnectionsView-HoyHjzrZ.js} +2 -2
- package/dist/web/server/assets/{TeamThread-BGl5z8_I.js → TeamThread-Be_seq83.js} +1 -1
- package/dist/web/server/assets/{_tanstack-start-manifest_v-Be9mOSxg.js → _tanstack-start-manifest_v-CEGe-Ovy.js} +57 -57
- package/dist/web/server/assets/{activity-Czfq-5_F.js → activity-Dy1HUqjo.js} +13 -0
- package/dist/web/server/assets/{router-BER0FKkT.js → router-CE6lnn8Z.js} +2 -2
- package/dist/web/server/assets/{routes-qtTyGHXK.js → routes-B0oBIDOC.js} +1 -1
- package/dist/web/server/assets/{routes-DSIwTrHI.js → routes-Ci6C5w_N.js} +4 -4
- package/dist/web/server/server.js +2 -2
- package/dist/worker.js +153 -10
- package/dist/worker.js.map +1 -1
- package/package.json +1 -1
package/dist/daemon.js
CHANGED
|
@@ -3665,8 +3665,8 @@ var IncompatibleDatabaseError = class extends Error {
|
|
|
3665
3665
|
}
|
|
3666
3666
|
};
|
|
3667
3667
|
var SCHEMA_OBJECTS = "SELECT type, name, sql FROM sqlite_schema WHERE sql IS NOT NULL AND substr(name, 1, 7) <> 'sqlite_' ORDER BY type, name";
|
|
3668
|
-
function fingerprint(
|
|
3669
|
-
return
|
|
3668
|
+
function fingerprint(read3) {
|
|
3669
|
+
return read3(SCHEMA_OBJECTS).map((object) => {
|
|
3670
3670
|
const sql = object.sql.replace(/--[^\n]*/g, " ").replace(/\/\*[\s\S]*?\*\//g, " ").replace(/\s+/g, " ").trim();
|
|
3671
3671
|
return `${object.type} ${object.name} ${sql}`;
|
|
3672
3672
|
}).join("\n");
|
|
@@ -3677,7 +3677,7 @@ function readSchemaSql() {
|
|
|
3677
3677
|
return schemaSql;
|
|
3678
3678
|
}
|
|
3679
3679
|
var canonical;
|
|
3680
|
-
function schemaMatches(
|
|
3680
|
+
function schemaMatches(read3) {
|
|
3681
3681
|
if (canonical === void 0) {
|
|
3682
3682
|
const scratch = openInMemoryDb("");
|
|
3683
3683
|
try {
|
|
@@ -3687,12 +3687,12 @@ function schemaMatches(read2) {
|
|
|
3687
3687
|
scratch.close();
|
|
3688
3688
|
}
|
|
3689
3689
|
}
|
|
3690
|
-
return fingerprint(
|
|
3690
|
+
return fingerprint(read3) === canonical;
|
|
3691
3691
|
}
|
|
3692
3692
|
function initSchema(db) {
|
|
3693
|
-
const
|
|
3694
|
-
if (
|
|
3695
|
-
else if (!schemaMatches(
|
|
3693
|
+
const read3 = (query) => db.raw.query(query).all();
|
|
3694
|
+
if (read3(SCHEMA_OBJECTS).length === 0) inTx(db, () => db.raw.exec(readSchemaSql()));
|
|
3695
|
+
else if (!schemaMatches(read3)) throw new IncompatibleDatabaseError();
|
|
3696
3696
|
}
|
|
3697
3697
|
|
|
3698
3698
|
// ../daemon/src/core/paths.ts
|
|
@@ -8389,7 +8389,7 @@ function loadPromptSkills(skillsDir, attachedNames) {
|
|
|
8389
8389
|
var CONTEXT_FILE_ORDER = ["AGENTS.md", "SOUL.md", "TOOLS.md", "IDENTITY.md"];
|
|
8390
8390
|
function loadHomeDocuments(agentDir2) {
|
|
8391
8391
|
const root = resolveRealDirectory(agentDir2);
|
|
8392
|
-
const
|
|
8392
|
+
const read3 = (file) => {
|
|
8393
8393
|
try {
|
|
8394
8394
|
return readRegularFileNoFollow(join17(root, file));
|
|
8395
8395
|
} catch (error) {
|
|
@@ -8398,11 +8398,11 @@ function loadHomeDocuments(agentDir2) {
|
|
|
8398
8398
|
}
|
|
8399
8399
|
};
|
|
8400
8400
|
return {
|
|
8401
|
-
"AGENTS.md":
|
|
8402
|
-
"SOUL.md":
|
|
8403
|
-
"TOOLS.md":
|
|
8404
|
-
"IDENTITY.md":
|
|
8405
|
-
"BOOTSTRAP.md":
|
|
8401
|
+
"AGENTS.md": read3("AGENTS.md"),
|
|
8402
|
+
"SOUL.md": read3("SOUL.md"),
|
|
8403
|
+
"TOOLS.md": read3("TOOLS.md"),
|
|
8404
|
+
"IDENTITY.md": read3("IDENTITY.md"),
|
|
8405
|
+
"BOOTSTRAP.md": read3("BOOTSTRAP.md")
|
|
8406
8406
|
};
|
|
8407
8407
|
}
|
|
8408
8408
|
function buildSystemPrompt(agent, options = {}) {
|
|
@@ -8554,7 +8554,7 @@ ${reviewedLessons.map((lesson) => `- ${lesson}`).join("\n")}`
|
|
|
8554
8554
|
}
|
|
8555
8555
|
parts.push({
|
|
8556
8556
|
id: "memory",
|
|
8557
|
-
text: "# Memory\n\nYou share a persistent memory backend with every other agent in this team. Use `memory_write` to remember things across sessions, and `memory_search` / `memory_read` / `memory_list` to recall them. This memory is for project knowledge \u2014 codebase notes, decisions, things the user told you about the work. For personal notes about yourself (preferences, persona quirks), use `home_write` on IDENTITY.md instead. Always check memory at the start of a session: another agent in the team may have already learned something useful. **Do NOT send peer messages announcing memory writes \u2014 every agent has access to the same store via `memory_search` and will find your note when they need it
|
|
8557
|
+
text: "# Memory\n\nYou share a persistent memory backend with every other agent in this team. Use `memory_write` to remember things across sessions, and `memory_search` / `memory_read` / `memory_list` to recall them. This memory is for project knowledge \u2014 codebase notes, decisions, things the user told you about the work. For personal notes about yourself (preferences, persona quirks), use `home_write` on IDENTITY.md instead. Always check memory at the start of a session: another agent in the team may have already learned something useful. **Do NOT send peer messages announcing memory writes \u2014 every agent has access to the same store via `memory_search` and will find your note when they need it.**\n\nWhen a conversation grows long, its older messages are replaced by a summary. They stay saved: when the summary leaves out a detail you need, find it with `recall` instead of guessing or asking again."
|
|
8558
8558
|
});
|
|
8559
8559
|
return parts;
|
|
8560
8560
|
}
|
|
@@ -9896,6 +9896,143 @@ function messagingTools(host3, fromAgentId) {
|
|
|
9896
9896
|
];
|
|
9897
9897
|
}
|
|
9898
9898
|
|
|
9899
|
+
// ../daemon/src/runtime/tools/recall.ts
|
|
9900
|
+
var MAX_WORDS = 8;
|
|
9901
|
+
var MAX_HITS = 12;
|
|
9902
|
+
var READ_COUNT = 5;
|
|
9903
|
+
var MAX_READ = 20;
|
|
9904
|
+
var BUDGET = 2e4;
|
|
9905
|
+
var MIN_SHARE = 2e3;
|
|
9906
|
+
var BEFORE = 60;
|
|
9907
|
+
var AFTER = 200;
|
|
9908
|
+
var NOTHING_SUMMARIZED = "Nothing in this conversation has been summarized: every message is still in your context.";
|
|
9909
|
+
function recallTool(source) {
|
|
9910
|
+
return {
|
|
9911
|
+
def: {
|
|
9912
|
+
name: "recall",
|
|
9913
|
+
description: "Search or read this conversation's older messages that were summarized to make room. When a conversation fills your context, its older messages are replaced by a summary, but they stay saved. When the summary leaves out something you need (an exact value, a link, a file name, the user's own words, what a tool returned), find it here rather than guessing or asking again. Give `query` to list the summarized messages that hold every word, with their numbers; give `from` (a number from a search, or 1 for the start) to read messages in full.",
|
|
9914
|
+
parameters: {
|
|
9915
|
+
type: "object",
|
|
9916
|
+
properties: {
|
|
9917
|
+
query: {
|
|
9918
|
+
type: "string",
|
|
9919
|
+
description: "words that must all appear in a message (case is ignored)"
|
|
9920
|
+
},
|
|
9921
|
+
from: {
|
|
9922
|
+
type: "integer",
|
|
9923
|
+
minimum: 1,
|
|
9924
|
+
description: "the number of the first message to read"
|
|
9925
|
+
},
|
|
9926
|
+
count: {
|
|
9927
|
+
type: "integer",
|
|
9928
|
+
minimum: 1,
|
|
9929
|
+
maximum: MAX_READ,
|
|
9930
|
+
description: `how many messages to read from \`from\` (default ${READ_COUNT}); long messages are cut, less so when you read fewer`
|
|
9931
|
+
}
|
|
9932
|
+
}
|
|
9933
|
+
}
|
|
9934
|
+
},
|
|
9935
|
+
async invoke(args) {
|
|
9936
|
+
const summarized = summarizedMessages(source);
|
|
9937
|
+
if (summarized.length === 0) return NOTHING_SUMMARIZED;
|
|
9938
|
+
if (args.from !== void 0) return read2(summarized, Number(args.from), args.count);
|
|
9939
|
+
if (typeof args.query === "string") return search(summarized, args.query);
|
|
9940
|
+
throw new Error("recall: give `query` to search or `from` to read");
|
|
9941
|
+
}
|
|
9942
|
+
};
|
|
9943
|
+
}
|
|
9944
|
+
function summarizedMessages(source) {
|
|
9945
|
+
const { messages, compactions } = conversationHistory(source.branch());
|
|
9946
|
+
const end = compactions.at(-1)?.index ?? 0;
|
|
9947
|
+
return messages.slice(0, end).flatMap((message, index) => {
|
|
9948
|
+
const [shown2] = piMessagesToProviderView([message], source.secrets);
|
|
9949
|
+
if (!shown2) return [];
|
|
9950
|
+
const at = message.timestamp;
|
|
9951
|
+
const when = typeof at === "number" && Number.isFinite(at) ? ` \xB7 ${new Date(at).toISOString().slice(0, 16).replace("T", " ")} UTC` : "";
|
|
9952
|
+
return [
|
|
9953
|
+
{
|
|
9954
|
+
number: index + 1,
|
|
9955
|
+
heading: `#${index + 1} \xB7 ${speaker(shown2)}${when}`,
|
|
9956
|
+
text: redactExactValues(textOf(shown2), source.secrets)
|
|
9957
|
+
}
|
|
9958
|
+
];
|
|
9959
|
+
});
|
|
9960
|
+
}
|
|
9961
|
+
function speaker(message) {
|
|
9962
|
+
if (message.role === "tool") {
|
|
9963
|
+
return `result of ${message.toolName ?? "a tool"}${message.isError ? ", failed" : ""}`;
|
|
9964
|
+
}
|
|
9965
|
+
return message.role;
|
|
9966
|
+
}
|
|
9967
|
+
function textOf(message) {
|
|
9968
|
+
const parts = message.content ? [message.content] : [];
|
|
9969
|
+
for (const call of message.toolCalls ?? []) parts.push(`[called ${call.name} ${call.arguments}]`);
|
|
9970
|
+
const images = message.images?.length ?? 0;
|
|
9971
|
+
if (images > 0) parts.push(`[${images === 1 ? "an image" : `${images} images`}]`);
|
|
9972
|
+
if (message.stopped) parts.push(`[${message.stopped}]`);
|
|
9973
|
+
return parts.join("\n");
|
|
9974
|
+
}
|
|
9975
|
+
function search(summarized, query) {
|
|
9976
|
+
const words = [...new Set(query.toLowerCase().split(/\s+/).filter(Boolean))];
|
|
9977
|
+
if (words.join("").length < 2) throw new Error("recall: search for at least two characters");
|
|
9978
|
+
if (words.length > MAX_WORDS) throw new Error(`recall: search for at most ${MAX_WORDS} words`);
|
|
9979
|
+
const hits = summarized.filter((message) => {
|
|
9980
|
+
const lower = message.text.toLowerCase();
|
|
9981
|
+
return words.every((word) => lower.includes(word));
|
|
9982
|
+
});
|
|
9983
|
+
const of = `of the ${summarized.length} summarized messages`;
|
|
9984
|
+
if (hits.length === 0) {
|
|
9985
|
+
return `None ${of} holds every word of "${query}". Search for fewer or other words, or read from 1.`;
|
|
9986
|
+
}
|
|
9987
|
+
const shown2 = hits.slice(-MAX_HITS);
|
|
9988
|
+
const lines = shown2.map((hit) => `${hit.heading}: ${snippetOf(hit.text, words)}`);
|
|
9989
|
+
const earlier = hits.length - shown2.length;
|
|
9990
|
+
return [
|
|
9991
|
+
`${hits.length} ${of} ${hits.length === 1 ? "holds" : "hold"} every word of "${query}"${earlier > 0 ? `; the latest ${shown2.length}` : ""}:`,
|
|
9992
|
+
...lines,
|
|
9993
|
+
...earlier > 0 ? [`${earlier} earlier ones are not listed: add a word to narrow the search.`] : [],
|
|
9994
|
+
"Read one in full with `from` and its number."
|
|
9995
|
+
].join("\n");
|
|
9996
|
+
}
|
|
9997
|
+
function snippetOf(text4, words) {
|
|
9998
|
+
const flat = text4.replace(/\s+/g, " ").trim();
|
|
9999
|
+
const lower = flat.toLowerCase();
|
|
10000
|
+
const at = Math.min(...words.map((word) => lower.indexOf(word)).filter((index) => index >= 0));
|
|
10001
|
+
const start2 = Math.max(0, at - BEFORE);
|
|
10002
|
+
const end = Math.min(flat.length, at + AFTER);
|
|
10003
|
+
return `${start2 > 0 ? "\u2026" : ""}${flat.slice(start2, end).trim()}${end < flat.length ? "\u2026" : ""}`;
|
|
10004
|
+
}
|
|
10005
|
+
function read2(summarized, from, rawCount) {
|
|
10006
|
+
const total = summarized.at(-1)?.number ?? 0;
|
|
10007
|
+
if (!Number.isInteger(from) || from < 1) throw new Error("recall: `from` is a message number");
|
|
10008
|
+
if (from > total) {
|
|
10009
|
+
return `Only messages 1 to ${total} were summarized; the later ones are in your context.`;
|
|
10010
|
+
}
|
|
10011
|
+
const count2 = rawCount === void 0 ? READ_COUNT : Number(rawCount);
|
|
10012
|
+
if (!Number.isInteger(count2) || count2 < 1 || count2 > MAX_READ) {
|
|
10013
|
+
throw new Error(`recall: \`count\` is from 1 to ${MAX_READ}`);
|
|
10014
|
+
}
|
|
10015
|
+
const share = Math.max(MIN_SHARE, Math.floor(BUDGET / count2));
|
|
10016
|
+
const blocks = [];
|
|
10017
|
+
let used = 0;
|
|
10018
|
+
let next = null;
|
|
10019
|
+
for (const message of summarized) {
|
|
10020
|
+
if (message.number < from) continue;
|
|
10021
|
+
if (blocks.length === count2 || blocks.length > 0 && used >= BUDGET) {
|
|
10022
|
+
next = message.number;
|
|
10023
|
+
break;
|
|
10024
|
+
}
|
|
10025
|
+
const cut = message.text.length > share;
|
|
10026
|
+
const body = cut ? `${message.text.slice(0, share)}\u2026 [${(message.text.length - share).toLocaleString("en-US")} more characters cut${count2 > 1 ? "; read this message alone to see more" : ""}]` : message.text;
|
|
10027
|
+
blocks.push(`${message.heading}
|
|
10028
|
+
${body}`);
|
|
10029
|
+
used += body.length;
|
|
10030
|
+
}
|
|
10031
|
+
const last = next === null ? total : next - 1;
|
|
10032
|
+
const head = `Messages ${from} to ${last} of the ${total} summarized${next === null ? "" : `; read on from ${next}`}:`;
|
|
10033
|
+
return [head, ...blocks].join("\n\n");
|
|
10034
|
+
}
|
|
10035
|
+
|
|
9899
10036
|
// ../daemon/src/runtime/tools/team.ts
|
|
9900
10037
|
function agentCreateTool(host3) {
|
|
9901
10038
|
return {
|
|
@@ -10370,6 +10507,7 @@ function toPiPart(part) {
|
|
|
10370
10507
|
function createBazilionCustomTools(opts) {
|
|
10371
10508
|
const handlers = [
|
|
10372
10509
|
...memoryTools(opts.memory),
|
|
10510
|
+
recallTool(opts.recall),
|
|
10373
10511
|
...homeTools(opts.agent.agent.dir),
|
|
10374
10512
|
bootstrapTool(opts.agent.agent.dir),
|
|
10375
10513
|
webFetchTool({ env: opts.env }),
|
|
@@ -10452,7 +10590,7 @@ async function openPiSession(spec) {
|
|
|
10452
10590
|
}
|
|
10453
10591
|
return { session, redactionSecrets, dispose: () => session.dispose() };
|
|
10454
10592
|
}
|
|
10455
|
-
function turnSurface(opts) {
|
|
10593
|
+
function turnSurface(opts, recall) {
|
|
10456
10594
|
const { agent, paths, env } = opts;
|
|
10457
10595
|
const cwd = agent.team.path;
|
|
10458
10596
|
const promptSkills = loadPromptSkills(paths.skillsDir, agent.skills);
|
|
@@ -10467,6 +10605,7 @@ function turnSurface(opts) {
|
|
|
10467
10605
|
const customTools = createBazilionCustomTools({
|
|
10468
10606
|
agent,
|
|
10469
10607
|
memory: opts.memory,
|
|
10608
|
+
recall,
|
|
10470
10609
|
messagingHost: opts.messagingHost,
|
|
10471
10610
|
userMdHost: opts.userMdHost,
|
|
10472
10611
|
browserHost: opts.browserHost,
|
|
@@ -10506,7 +10645,11 @@ async function createBazilionSession(opts) {
|
|
|
10506
10645
|
if (!existsSync15(agent.team.path)) mkdirSync10(agent.team.path, { recursive: true });
|
|
10507
10646
|
mkdirSync10(join22(paths.agentDir(agent.agent.id), "sessions"), { recursive: true });
|
|
10508
10647
|
const sessionManager = openConversation(agent, paths, opts.conversation);
|
|
10509
|
-
const
|
|
10648
|
+
const redactionSecrets = [...new Set(envSecretValues(opts.env).filter(Boolean))];
|
|
10649
|
+
const turn = turnSurface(opts, {
|
|
10650
|
+
branch: () => sessionManager.getBranch(),
|
|
10651
|
+
secrets: redactionSecrets
|
|
10652
|
+
});
|
|
10510
10653
|
return openPiSession({
|
|
10511
10654
|
model: {
|
|
10512
10655
|
providerName,
|
|
@@ -10525,7 +10668,7 @@ async function createBazilionSession(opts) {
|
|
|
10525
10668
|
})),
|
|
10526
10669
|
tools: turn.tools,
|
|
10527
10670
|
hostToolNames: turn.hostToolNames,
|
|
10528
|
-
redactionSecrets
|
|
10671
|
+
redactionSecrets,
|
|
10529
10672
|
refreshApiKey: opts.refreshApiKey
|
|
10530
10673
|
});
|
|
10531
10674
|
}
|
|
@@ -10539,7 +10682,7 @@ var HOST_TOOL_DEFINITIONS = {
|
|
|
10539
10682
|
ls: createLsToolDefinition
|
|
10540
10683
|
};
|
|
10541
10684
|
function describeTurn(opts) {
|
|
10542
|
-
const turn = turnSurface(opts);
|
|
10685
|
+
const turn = turnSurface(opts, { branch: () => [], secrets: [] });
|
|
10543
10686
|
const hostTools = turn.hostToolNames.flatMap((name) => {
|
|
10544
10687
|
const define = HOST_TOOL_DEFINITIONS[name];
|
|
10545
10688
|
return define ? [define(turn.modelCwd)] : [];
|
|
@@ -13210,7 +13353,7 @@ function turnHosts(turn, env) {
|
|
|
13210
13353
|
const { signal } = turn.controller;
|
|
13211
13354
|
const secretsEnv = () => mergeSecretsIntoEnv(db, authToken);
|
|
13212
13355
|
const codexConnected = hasCredentials(db, authToken);
|
|
13213
|
-
const
|
|
13356
|
+
const search2 = searchRoute(env, agent.model, codexConnected);
|
|
13214
13357
|
return {
|
|
13215
13358
|
messagingHost: createDbMessagingHost(db, {
|
|
13216
13359
|
causalParentMessageId: turn.request.causalParentMessageId
|
|
@@ -13238,8 +13381,8 @@ function turnHosts(turn, env) {
|
|
|
13238
13381
|
accessToken: () => loadAccessToken(db, authToken)
|
|
13239
13382
|
}
|
|
13240
13383
|
}) : void 0,
|
|
13241
|
-
webSearchHost:
|
|
13242
|
-
backend:
|
|
13384
|
+
webSearchHost: search2.backend ? createWebSearchHost({
|
|
13385
|
+
backend: search2.backend,
|
|
13243
13386
|
env: secretsEnv,
|
|
13244
13387
|
model: agent.model,
|
|
13245
13388
|
codexToken: () => loadAccessToken(db, authToken),
|
|
@@ -14475,9 +14618,9 @@ function describeProviderFailure(message, context) {
|
|
|
14475
14618
|
|
|
14476
14619
|
// ../daemon/src/lib/setting-fields.ts
|
|
14477
14620
|
import { isAbsolute as isAbsolute7 } from "node:path";
|
|
14478
|
-
function readAll(
|
|
14621
|
+
function readAll(read3) {
|
|
14479
14622
|
try {
|
|
14480
|
-
return
|
|
14623
|
+
return read3();
|
|
14481
14624
|
} catch {
|
|
14482
14625
|
return {};
|
|
14483
14626
|
}
|
|
@@ -15501,28 +15644,28 @@ configRouter.delete("/fields/:envVar", (c) => {
|
|
|
15501
15644
|
// ../daemon/src/lib/conversation-search.ts
|
|
15502
15645
|
import { join as join32 } from "node:path";
|
|
15503
15646
|
var INBOX_WAKE_PREFIX = "[[bazilion:inbox-wake]]\n";
|
|
15504
|
-
var
|
|
15647
|
+
var MAX_WORDS2 = 8;
|
|
15505
15648
|
var MAX_SEARCH_HITS = 50;
|
|
15506
|
-
var
|
|
15507
|
-
var
|
|
15649
|
+
var BEFORE2 = 24;
|
|
15650
|
+
var AFTER2 = 140;
|
|
15508
15651
|
function searchWords(query) {
|
|
15509
15652
|
const words = [...new Set(query.toLowerCase().split(/\s+/).filter(Boolean))];
|
|
15510
15653
|
if (words.join("").length < 2) throw new DomainError(400, "Search for at least two characters");
|
|
15511
|
-
if (words.length >
|
|
15654
|
+
if (words.length > MAX_WORDS2) throw new DomainError(400, `Search for at most ${MAX_WORDS2} words`);
|
|
15512
15655
|
return words;
|
|
15513
15656
|
}
|
|
15514
15657
|
function plainText(markdown) {
|
|
15515
15658
|
return markdown.replace(/^\s*```.*$/gm, " ").replace(/!?\[([^\]]*)\]\([^)]*\)/g, "$1").replace(/^\s{0,3}#{1,6}\s+/gm, "").replace(/^\s*>\s?/gm, "").replace(/^\s*(?:[-*+]|\d+[.)])\s+/gm, "").replace(/^\s*\|?(?:\s*:?-{3,}:?\s*\|)+\s*:?-*:?\s*$/gm, " ").replace(/\|/g, " ").replace(/(\*\*|__|`)/g, "").replace(/(^|[\s(])[*_]([^*_\s][^*_]*?)[*_](?=[\s).,;:!?]|$)/g, "$1$2");
|
|
15516
15659
|
}
|
|
15517
|
-
function
|
|
15660
|
+
function snippetOf2(text4, words) {
|
|
15518
15661
|
const flat = plainText(text4).replace(/\s+/g, " ").trim();
|
|
15519
15662
|
const lower = flat.toLowerCase();
|
|
15520
15663
|
const at = Math.min(
|
|
15521
15664
|
...words.map((word) => lower.indexOf(word)).filter((index) => index >= 0),
|
|
15522
15665
|
flat.length
|
|
15523
15666
|
);
|
|
15524
|
-
const start2 = Math.max(0, at -
|
|
15525
|
-
const end = Math.min(flat.length, at +
|
|
15667
|
+
const start2 = Math.max(0, at - BEFORE2);
|
|
15668
|
+
const end = Math.min(flat.length, at + AFTER2);
|
|
15526
15669
|
return `${start2 > 0 ? "\u2026" : ""}${flat.slice(start2, end).trim()}${end < flat.length ? "\u2026" : ""}`;
|
|
15527
15670
|
}
|
|
15528
15671
|
async function searchConversations(db, paths, options) {
|
|
@@ -15582,7 +15725,7 @@ async function searchConversations(db, paths, options) {
|
|
|
15582
15725
|
active: row.selected === row.id,
|
|
15583
15726
|
role: message.role,
|
|
15584
15727
|
at: typeof at === "number" && Number.isFinite(at) ? at : null,
|
|
15585
|
-
snippet:
|
|
15728
|
+
snippet: snippetOf2(content, words),
|
|
15586
15729
|
nth: nth++
|
|
15587
15730
|
});
|
|
15588
15731
|
}
|
|
@@ -17970,18 +18113,18 @@ async function attachPatches(captured, report, limits = REVIEW_LIMITS, onlyPath)
|
|
|
17970
18113
|
changes.push({ ...change, contentOmitted: "total_limit" });
|
|
17971
18114
|
continue;
|
|
17972
18115
|
}
|
|
17973
|
-
const
|
|
17974
|
-
const bytes =
|
|
17975
|
-
if (bytes > limits.fileBytes && !
|
|
18116
|
+
const read3 = await readChangePatch(captured, report.base, change, limits.patchBytes);
|
|
18117
|
+
const bytes = read3.patch ? Buffer.byteLength(read3.patch) : 0;
|
|
18118
|
+
if (bytes > limits.fileBytes && !read3.truncated) {
|
|
17976
18119
|
changes.push({ ...change, patch: null, contentOmitted: "too_large" });
|
|
17977
18120
|
continue;
|
|
17978
18121
|
}
|
|
17979
18122
|
total += bytes;
|
|
17980
18123
|
changes.push({
|
|
17981
18124
|
...change,
|
|
17982
|
-
patch:
|
|
17983
|
-
patchTruncated:
|
|
17984
|
-
contentOmitted:
|
|
18125
|
+
patch: read3.patch,
|
|
18126
|
+
patchTruncated: read3.truncated,
|
|
18127
|
+
contentOmitted: read3.omitted
|
|
17985
18128
|
});
|
|
17986
18129
|
}
|
|
17987
18130
|
return { ...report, changes };
|