@burtson-labs/bandit-engine 2.0.103 → 2.0.104
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-HCZEF3ZM.mjs → chat-TIX4XHMD.mjs} +2 -2
- package/dist/{chunk-SWLZ7QJB.mjs → chunk-BJOPAWGI.mjs} +2 -2
- package/dist/{chunk-GM5V2RJS.mjs → chunk-EGIUL7QB.mjs} +48 -17
- package/dist/chunk-EGIUL7QB.mjs.map +1 -0
- package/dist/index.js +47 -16
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +2 -2
- package/dist/management/management.js +47 -16
- package/dist/management/management.js.map +1 -1
- package/dist/management/management.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-GM5V2RJS.mjs.map +0 -1
- /package/dist/{chat-HCZEF3ZM.mjs.map → chat-TIX4XHMD.mjs.map} +0 -0
- /package/dist/{chunk-SWLZ7QJB.mjs.map → chunk-BJOPAWGI.mjs.map} +0 -0
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
chat_default
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-EGIUL7QB.mjs";
|
|
4
4
|
import {
|
|
5
5
|
chat_provider_default
|
|
6
6
|
} from "./chunk-VTKRZNLI.mjs";
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
useGatewayHealth,
|
|
11
11
|
useGatewayMemory,
|
|
12
12
|
useGatewayModels
|
|
13
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-BJOPAWGI.mjs";
|
|
14
14
|
import "./chunk-KYC7CC6C.mjs";
|
|
15
15
|
import "./chunk-HAUDGBUS.mjs";
|
|
16
16
|
import "./chunk-BN3D45E2.mjs";
|
|
@@ -23771,7 +23771,7 @@ TOOL USAGE PROTOCOL (conservative approach)
|
|
|
23771
23771
|
* web_search() - when asked about recent/current events, breaking news, live information (weather, prices, sports scores), or when you need to look up documentation, libraries, APIs, error messages, or verify a specific fact
|
|
23772
23772
|
* web_fetch() - to read the FULL contents of a specific URL you already have. Reach for this when the user wants to "tell me more", "go deeper", "read/open that article", or asks for details about a specific source, link, or article from an EARLIER answer: take that item's URL from the previous Sources list in this conversation and fetch it, then answer from the page's actual content (not just the prior summary)
|
|
23773
23773
|
* image_generation() - ONLY when explicitly asked to create or generate an image
|
|
23774
|
-
* create_file({"content": "...", "filename": "report.docx", "format": "docx"}) - when the user asks for a downloadable FILE (a document, spreadsheet, slides, markdown, code, etc.) or to "export"/"download"/"save" something. Formats: md, txt, csv, json, html, xml, yaml, docx, pptx. For docx/pptx write well-structured Markdown (use "## " headings to start each slide for pptx). It returns a temporary download link \u2014 ALWAYS tell the user the file expires (~1 hour). If it is unclear whether they want it shown inline vs. as a downloadable file, use ask_user first.
|
|
23774
|
+
* create_file({"content": "...", "filename": "report.docx", "format": "docx"}) - when the user asks for a downloadable FILE (a document, spreadsheet, slides, markdown, code, etc.) or to "export"/"download"/"save" something. Formats: md, txt, csv, json, html, xml, yaml, docx, pptx. PDF is NOT a supported format \u2014 if the user asks for a PDF, create a docx instead. For docx/pptx write well-structured Markdown (use "## " headings to start each slide for pptx). It returns a temporary download link \u2014 ALWAYS tell the user the file expires (~1 hour). If it is unclear whether they want it shown inline vs. as a downloadable file, use ask_user first.
|
|
23775
23775
|
* ask_user({"questions": [{"question": "...", "header": "Format", "options": [{"label": "Inline (Recommended)"}, {"label": "Download a file"}]}]}) - when you are genuinely BLOCKED on a decision that is the USER's to make and cannot resolve from the request, context, or sensible defaults (e.g. show content inline vs. let them download it, which format/option they want). Renders clickable options the user answers in one step \u2014 better than asking in prose and ending your turn. Give 1-4 questions, each with 2-4 options; if one is clearly best, list it first and append " (Recommended)". The user may also type their own answer; act on it directly.
|
|
23776
23776
|
- For general questions about concepts, definitions, explanations, or how-to topics, use your built-in knowledge WITHOUT calling tools.
|
|
23777
23777
|
- Examples of what NOT to use tools for: "who are you?", "what is React?", "explain machine learning", "how does X work?", general programming questions.
|
|
@@ -23957,16 +23957,50 @@ ${fn}(${argStr})
|
|
|
23957
23957
|
\`\`\``;
|
|
23958
23958
|
}
|
|
23959
23959
|
}
|
|
23960
|
-
|
|
23961
|
-
const
|
|
23962
|
-
const
|
|
23963
|
-
|
|
23964
|
-
|
|
23965
|
-
|
|
23966
|
-
|
|
23960
|
+
const extractToolCalls = (message) => {
|
|
23961
|
+
const KNOWN = ["web_search", "web_fetch", "image_generation", "create_file", "ask_user", "ask-user"];
|
|
23962
|
+
const out = [];
|
|
23963
|
+
const nameRe = new RegExp(`\\b(${KNOWN.join("|")})\\s*\\(`, "g");
|
|
23964
|
+
let m;
|
|
23965
|
+
while ((m = nameRe.exec(message)) !== null) {
|
|
23966
|
+
const functionName = m[1];
|
|
23967
|
+
const openIdx = m.index + m[0].length - 1;
|
|
23968
|
+
let depth = 0;
|
|
23969
|
+
let i = openIdx;
|
|
23970
|
+
let inStr = false;
|
|
23971
|
+
let esc = false;
|
|
23972
|
+
for (; i < message.length; i++) {
|
|
23973
|
+
const ch = message[i];
|
|
23974
|
+
if (inStr) {
|
|
23975
|
+
if (esc) esc = false;
|
|
23976
|
+
else if (ch === "\\") esc = true;
|
|
23977
|
+
else if (ch === '"') inStr = false;
|
|
23978
|
+
} else if (ch === '"') inStr = true;
|
|
23979
|
+
else if (ch === "(") depth++;
|
|
23980
|
+
else if (ch === ")") {
|
|
23981
|
+
depth--;
|
|
23982
|
+
if (depth === 0) {
|
|
23983
|
+
i++;
|
|
23984
|
+
break;
|
|
23985
|
+
}
|
|
23986
|
+
}
|
|
23987
|
+
}
|
|
23988
|
+
if (depth !== 0) continue;
|
|
23989
|
+
const params = message.slice(openIdx + 1, i - 1).trim();
|
|
23990
|
+
let start = m.index;
|
|
23991
|
+
let end = i;
|
|
23992
|
+
const fenceOpen = message.slice(0, m.index).match(/```[a-zA-Z0-9_-]*[ \t]*\n[ \t]*$/);
|
|
23993
|
+
if (fenceOpen) {
|
|
23994
|
+
start = m.index - fenceOpen[0].length;
|
|
23995
|
+
const fenceClose = message.slice(i).match(/^[ \t]*\n```/);
|
|
23996
|
+
if (fenceClose) end = i + fenceClose[0].length;
|
|
23997
|
+
}
|
|
23998
|
+
out.push({ raw: message.slice(start, end), functionName, params });
|
|
23999
|
+
nameRe.lastIndex = i;
|
|
23967
24000
|
}
|
|
23968
|
-
|
|
23969
|
-
|
|
24001
|
+
return out;
|
|
24002
|
+
};
|
|
24003
|
+
const toolCallMatches = extractToolCalls(fullMessage);
|
|
23970
24004
|
let enhancedMessage = fullMessage;
|
|
23971
24005
|
const summarizableResults = [];
|
|
23972
24006
|
const inlineImageBlocks = [];
|
|
@@ -23974,13 +24008,10 @@ ${fm[1].trim()}
|
|
|
23974
24008
|
if (toolCallMatches && toolCallMatches.length > 0 && mcpToolsAvailable) {
|
|
23975
24009
|
debugLogger.info("Detected tool calls in AI response", {
|
|
23976
24010
|
toolCallCount: toolCallMatches.length,
|
|
23977
|
-
toolCalls: toolCallMatches
|
|
24011
|
+
toolCalls: toolCallMatches.map((t) => t.functionName)
|
|
23978
24012
|
});
|
|
23979
|
-
for (const
|
|
23980
|
-
const
|
|
23981
|
-
const functionCallMatch = toolCallCode.match(/^(\w+)\(\s*(.*?)\s*\)$/);
|
|
23982
|
-
if (!functionCallMatch) continue;
|
|
23983
|
-
const [, functionName, params] = functionCallMatch;
|
|
24013
|
+
for (const call of toolCallMatches) {
|
|
24014
|
+
const { raw: match, functionName, params } = call;
|
|
23984
24015
|
try {
|
|
23985
24016
|
let parsedParams = {};
|
|
23986
24017
|
const raw = params.trim();
|