@burtson-labs/bandit-engine 2.0.102 → 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.
@@ -9738,7 +9738,7 @@ var MCPToolsTabV2_default = MCPToolsTabV2;
9738
9738
 
9739
9739
  // src/management/management.tsx
9740
9740
  import { jsx as jsx14, jsxs as jsxs14 } from "react/jsx-runtime";
9741
- var preloadChatPage = () => import("./chat-PMO3WTM4.mjs");
9741
+ var preloadChatPage = () => import("./chat-HCZEF3ZM.mjs");
9742
9742
  var buildCapabilitiesUrl = (gatewayApiUrl) => {
9743
9743
  const trimmed = gatewayApiUrl.replace(/\/$/, "");
9744
9744
  if (trimmed.endsWith("/api")) {
@@ -11104,4 +11104,4 @@ export {
11104
11104
  useGatewayMemory,
11105
11105
  management_default
11106
11106
  };
11107
- //# sourceMappingURL=chunk-7NXSMMCU.mjs.map
11107
+ //# sourceMappingURL=chunk-SWLZ7QJB.mjs.map
package/dist/index.js CHANGED
@@ -15388,7 +15388,7 @@ ${sourcesMarkdownList.join("\n")}`;
15388
15388
  });
15389
15389
 
15390
15390
  // src/chat/source-chips.tsx
15391
- var import_react18, import_material11, import_jsx_runtime14, parseWebSources, stripSourcesForDisplay, domainOf, SourceChip, SourceChips, source_chips_default;
15391
+ var import_react18, import_material11, import_jsx_runtime14, parseWebSources, stripSourcesForDisplay, linkifyCitations, domainOf, SourceChip, SourceChips, source_chips_default;
15392
15392
  var init_source_chips = __esm({
15393
15393
  "src/chat/source-chips.tsx"() {
15394
15394
  "use strict";
@@ -15423,6 +15423,14 @@ var init_source_chips = __esm({
15423
15423
  );
15424
15424
  return c.replace(/\s+$/u, "");
15425
15425
  };
15426
+ linkifyCitations = (content, sources) => {
15427
+ if (!content || sources.length === 0) return content;
15428
+ const link = (text) => text.replace(/\[(\d{1,2})\]/g, (full, num) => {
15429
+ const src = sources[parseInt(num, 10) - 1];
15430
+ return src ? `[\\[${num}\\]](${src.url})` : full;
15431
+ });
15432
+ return content.split(/(```[\s\S]*?```)/g).map((seg, i) => i % 2 === 0 ? link(seg) : seg).join("");
15433
+ };
15426
15434
  domainOf = (url) => {
15427
15435
  try {
15428
15436
  return new URL(url).hostname.replace(/^www\./, "");
@@ -15631,7 +15639,7 @@ var init_chat_messages = __esm({
15631
15639
  /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
15632
15640
  StreamingMarkdown_default,
15633
15641
  {
15634
- content: stripSourcesForDisplay(content),
15642
+ content: linkifyCitations(stripSourcesForDisplay(content), parseWebSources(content)),
15635
15643
  isStreaming: isStreaming && isLast,
15636
15644
  sources: sourceSummaries
15637
15645
  }
@@ -21897,6 +21905,29 @@ _This link is temporary and expires in about ${mins} minutes._`;
21897
21905
  try {
21898
21906
  const toolResultsText = summarizableResults.map((r) => `## ${r.name}
21899
21907
  ${r.output}`).join("\n\n");
21908
+ const dedupeSources = (arr) => {
21909
+ const seen = /* @__PURE__ */ new Set();
21910
+ return arr.filter((s) => seen.has(s.url) ? false : (seen.add(s.url), true));
21911
+ };
21912
+ const citeDomain = (u) => {
21913
+ try {
21914
+ return new URL(u).hostname.replace(/^www\./, "");
21915
+ } catch {
21916
+ return u;
21917
+ }
21918
+ };
21919
+ const buildCitationGuide = () => {
21920
+ const cite = dedupeSources(collectedSources).slice(0, 6);
21921
+ if (!cite.length)
21922
+ return `
21923
+
21924
+ Do NOT add citations, footnotes, superscript reference numbers, or a Sources list \u2014 sources are attached automatically.`;
21925
+ const list = cite.map((s, i) => `[${i + 1}] ${s.title || citeDomain(s.url)}`).join("\n");
21926
+ return `
21927
+
21928
+ 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):
21929
+ ${list}`;
21930
+ };
21900
21931
  const MAX_CHAIN_ROUNDS = 4;
21901
21932
  const enabledToolsForChain = getEnabledMCPToolsForAI();
21902
21933
  const convo = [
@@ -21912,7 +21943,7 @@ ${r.output}`).join("\n\n");
21912
21943
  ${toolResultsText}
21913
21944
  ===END TOOL RESULTS===
21914
21945
 
21915
- 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. Do NOT add citations, footnotes, superscript reference numbers (e.g. \xB9 \xB2 \xB3), or a Sources/References/Citations list \u2014 the sources are attached automatically below your answer. Just write the answer naturally.`
21946
+ 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()}`
21916
21947
  }
21917
21948
  ];
21918
21949
  const streamTurn = (req) => new Promise((resolve) => {
@@ -22058,7 +22089,7 @@ That step failed: ${e instanceof Error ? e.message : String(e)}`);
22058
22089
  ${roundOut.join("\n\n")}
22059
22090
  ===END TOOL RESULTS===
22060
22091
 
22061
- Now give your final answer to my original request, or call another tool if you still genuinely need to. Do NOT add citations, footnotes, superscript reference numbers, or a Sources list \u2014 sources are attached automatically.`
22092
+ Now give your final answer to my original request, or call another tool if you still genuinely need to.${buildCitationGuide()}`
22062
22093
  });
22063
22094
  }
22064
22095
  setIsThinking?.(false);
@@ -22071,7 +22102,7 @@ Now give your final answer to my original request, or call another tool if you s
22071
22102
  const sourcesMd = collectedSources.length ? `
22072
22103
 
22073
22104
  **Sources**
22074
- ${collectedSources.slice(0, 6).map((s) => {
22105
+ ${dedupeSources(collectedSources).slice(0, 6).map((s) => {
22075
22106
  let domain = s.url;
22076
22107
  try {
22077
22108
  domain = new URL(s.url).hostname.replace(/^www\./, "");