@burtson-labs/bandit-engine 2.0.101 → 2.0.103
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/{chat-PMO3WTM4.mjs → chat-HCZEF3ZM.mjs} +2 -2
- package/dist/{chunk-R3HBSHLE.mjs → chunk-GM5V2RJS.mjs} +36 -5
- package/dist/chunk-GM5V2RJS.mjs.map +1 -0
- package/dist/{chunk-JTDQTYJR.mjs → chunk-SWLZ7QJB.mjs} +4 -4
- package/dist/chunk-SWLZ7QJB.mjs.map +1 -0
- package/dist/index.js +38 -7
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/management/management.js +38 -7
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-JTDQTYJR.mjs.map +0 -1
- package/dist/chunk-R3HBSHLE.mjs.map +0 -1
- /package/dist/{chat-PMO3WTM4.mjs.map → chat-HCZEF3ZM.mjs.map} +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chat_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-GM5V2RJS.mjs";
|
|
4
4
|
import "./chunk-ONQMRE2G.mjs";
|
|
5
5
|
import "./chunk-KYC7CC6C.mjs";
|
|
6
6
|
import "./chunk-BN3D45E2.mjs";
|
|
@@ -13,4 +13,4 @@ import "./chunk-BJTO5JO5.mjs";
|
|
|
13
13
|
export {
|
|
14
14
|
chat_default as default
|
|
15
15
|
};
|
|
16
|
-
//# sourceMappingURL=chat-
|
|
16
|
+
//# sourceMappingURL=chat-HCZEF3ZM.mjs.map
|
|
@@ -436,6 +436,14 @@ var stripSourcesForDisplay = (content) => {
|
|
|
436
436
|
);
|
|
437
437
|
return c.replace(/\s+$/u, "");
|
|
438
438
|
};
|
|
439
|
+
var linkifyCitations = (content, sources) => {
|
|
440
|
+
if (!content || sources.length === 0) return content;
|
|
441
|
+
const link = (text) => text.replace(/\[(\d{1,2})\]/g, (full, num) => {
|
|
442
|
+
const src = sources[parseInt(num, 10) - 1];
|
|
443
|
+
return src ? `[\\[${num}\\]](${src.url})` : full;
|
|
444
|
+
});
|
|
445
|
+
return content.split(/(```[\s\S]*?```)/g).map((seg, i) => i % 2 === 0 ? link(seg) : seg).join("");
|
|
446
|
+
};
|
|
439
447
|
var domainOf = (url) => {
|
|
440
448
|
try {
|
|
441
449
|
return new URL(url).hostname.replace(/^www\./, "");
|
|
@@ -633,7 +641,7 @@ var ChatMessages = ({
|
|
|
633
641
|
/* @__PURE__ */ jsx6(
|
|
634
642
|
StreamingMarkdown_default,
|
|
635
643
|
{
|
|
636
|
-
content: stripSourcesForDisplay(content),
|
|
644
|
+
content: linkifyCitations(stripSourcesForDisplay(content), parseWebSources(content)),
|
|
637
645
|
isStreaming: isStreaming && isLast,
|
|
638
646
|
sources: sourceSummaries
|
|
639
647
|
}
|
|
@@ -4017,6 +4025,29 @@ _This link is temporary and expires in about ${mins} minutes._`;
|
|
|
4017
4025
|
try {
|
|
4018
4026
|
const toolResultsText = summarizableResults.map((r) => `## ${r.name}
|
|
4019
4027
|
${r.output}`).join("\n\n");
|
|
4028
|
+
const dedupeSources = (arr) => {
|
|
4029
|
+
const seen = /* @__PURE__ */ new Set();
|
|
4030
|
+
return arr.filter((s) => seen.has(s.url) ? false : (seen.add(s.url), true));
|
|
4031
|
+
};
|
|
4032
|
+
const citeDomain = (u) => {
|
|
4033
|
+
try {
|
|
4034
|
+
return new URL(u).hostname.replace(/^www\./, "");
|
|
4035
|
+
} catch {
|
|
4036
|
+
return u;
|
|
4037
|
+
}
|
|
4038
|
+
};
|
|
4039
|
+
const buildCitationGuide = () => {
|
|
4040
|
+
const cite = dedupeSources(collectedSources).slice(0, 6);
|
|
4041
|
+
if (!cite.length)
|
|
4042
|
+
return `
|
|
4043
|
+
|
|
4044
|
+
Do NOT add citations, footnotes, superscript reference numbers, or a Sources list \u2014 sources are attached automatically.`;
|
|
4045
|
+
const list = cite.map((s, i) => `[${i + 1}] ${s.title || citeDomain(s.url)}`).join("\n");
|
|
4046
|
+
return `
|
|
4047
|
+
|
|
4048
|
+
When a statement is supported by one of the sources below, add an inline citation right after it using that source's number in square brackets \u2014 e.g. [1] or [2]. Use ONLY these numbers, never invent one, never use superscripts, and do NOT write your own Sources/References list (the numbered list is attached automatically below your answer):
|
|
4049
|
+
${list}`;
|
|
4050
|
+
};
|
|
4020
4051
|
const MAX_CHAIN_ROUNDS = 4;
|
|
4021
4052
|
const enabledToolsForChain = getEnabledMCPToolsForAI();
|
|
4022
4053
|
const convo = [
|
|
@@ -4032,7 +4063,7 @@ ${r.output}`).join("\n\n");
|
|
|
4032
4063
|
${toolResultsText}
|
|
4033
4064
|
===END TOOL RESULTS===
|
|
4034
4065
|
|
|
4035
|
-
Use them to fully complete my original request. If you still need to take an action I asked for (for example, actually create a file I want to download), call the appropriate tool now with a \`\`\`tool_code\`\`\` block. Otherwise give your final answer
|
|
4066
|
+
Use them to fully complete my original request. If you still need to take an action I asked for (for example, actually create a file I want to download), call the appropriate tool now with a \`\`\`tool_code\`\`\` block. Otherwise give your final answer.${buildCitationGuide()}`
|
|
4036
4067
|
}
|
|
4037
4068
|
];
|
|
4038
4069
|
const streamTurn = (req) => new Promise((resolve) => {
|
|
@@ -4178,7 +4209,7 @@ That step failed: ${e instanceof Error ? e.message : String(e)}`);
|
|
|
4178
4209
|
${roundOut.join("\n\n")}
|
|
4179
4210
|
===END TOOL RESULTS===
|
|
4180
4211
|
|
|
4181
|
-
Now give your final answer to my original request, or call another tool if you still genuinely need to
|
|
4212
|
+
Now give your final answer to my original request, or call another tool if you still genuinely need to.${buildCitationGuide()}`
|
|
4182
4213
|
});
|
|
4183
4214
|
}
|
|
4184
4215
|
setIsThinking?.(false);
|
|
@@ -4191,7 +4222,7 @@ Now give your final answer to my original request, or call another tool if you s
|
|
|
4191
4222
|
const sourcesMd = collectedSources.length ? `
|
|
4192
4223
|
|
|
4193
4224
|
**Sources**
|
|
4194
|
-
${collectedSources.slice(0, 6).map((s) => {
|
|
4225
|
+
${dedupeSources(collectedSources).slice(0, 6).map((s) => {
|
|
4195
4226
|
let domain = s.url;
|
|
4196
4227
|
try {
|
|
4197
4228
|
domain = new URL(s.url).hostname.replace(/^www\./, "");
|
|
@@ -10663,4 +10694,4 @@ var chat_default = Chat;
|
|
|
10663
10694
|
export {
|
|
10664
10695
|
chat_default
|
|
10665
10696
|
};
|
|
10666
|
-
//# sourceMappingURL=chunk-
|
|
10697
|
+
//# sourceMappingURL=chunk-GM5V2RJS.mjs.map
|