feat: add provider-specific tool policies

This commit is contained in:
Peter Steinberger
2026-01-13 09:59:21 +00:00
parent 512dbedee3
commit fa8d9b9189
7 changed files with 121 additions and 16 deletions

View File

@@ -11,6 +11,7 @@ describe("createReplyDispatcher", () => {
expect(dispatcher.sendFinalReply({ text: " " })).toBe(false);
expect(dispatcher.sendFinalReply({ text: SILENT_REPLY_TOKEN })).toBe(false);
expect(dispatcher.sendFinalReply({ text: `${SILENT_REPLY_TOKEN} -- nope` })).toBe(false);
expect(dispatcher.sendFinalReply({ text: `interject.${SILENT_REPLY_TOKEN}` })).toBe(false);
await dispatcher.waitForIdle();
expect(deliver).not.toHaveBeenCalled();

View File

@@ -10,6 +10,9 @@ export function isSilentReplyText(
token: string = SILENT_REPLY_TOKEN,
): boolean {
if (!text) return false;
const re = new RegExp(`^\\s*${escapeRegExp(token)}(?=$|\\W)`);
return re.test(text);
const escaped = escapeRegExp(token);
const prefix = new RegExp(`^\\s*${escaped}(?=$|\\W)`);
if (prefix.test(text)) return true;
const suffix = new RegExp(`\\b${escaped}\\b\\W*$`);
return suffix.test(text);
}