Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
surface catalog_lookup in intent gating when an utterance names a user-defined type
[._.]/ Adam Eivycd67cc1c2929
diff --git a/server/services/voice/tools.js b/server/services/voice/tools.jsindex 0cee637798..142612477a 100644--- a/server/services/voice/tools.js+++ b/server/services/voice/tools.js@@ -462,6 +462,10 @@ const activeCatalogTypeIds = () => {return ids.length ? ids : CATALOG_INGREDIENT_TYPES;};+// Escape a freeform string (a user-type label can be anything) for safe use+// inside a `new RegExp(...)` so a label like "C++ faction" can't throw or inject.+const escapeRegExp = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');+// Pull a short snippet from an ingredient's type-specific payload. Mirrors// the fallback chain used by client/src/pages/Catalog.jsx so voice + UI agree// on what "the body" of an ingredient is. Trimmed to 200 chars.@@ -2164,6 +2168,26 @@ export const classifyIntent = (userText) => {for (const [group, re] of Object.entries(GROUP_INTENT)) {if (re.test(userText)) active.add(group);}+ // The static `catalog` regex only knows the six built-in nouns. A user-defined+ // type (e.g. "wardrobe", "faction") wouldn't trip it, so "search my wardrobes"+ // would never surface `catalog_lookup` (the enum-widening in resolveParameters+ // can't help a tool that intent-gating already dropped). Activate the catalog+ // group when the utterance mentions any active user type's id or label —+ // singular or simple plural. System types are already covered by the regex.+ if (!active.has('catalog')) {+ const customNouns = getActiveCatalogTypes()+ .filter((t) => t.system === false)+ .flatMap((t) => [t.id, t.label])+ .filter((s) => typeof s === 'string' && s.trim().length > 1)+ .map((s) => s.trim().toLowerCase());+ if (customNouns.length) {+ const lower = userText.toLowerCase();+ // Match the noun as a whole word, optionally pluralized (foo → foos/fooes).+ if (customNouns.some((n) => new RegExp(`\\b${escapeRegExp(n)}e?s?\\b`).test(lower))) {+ active.add('catalog');+ }+ }+ }return active;};diff --git a/server/services/voice/tools.test.js b/server/services/voice/tools.test.jsindex 7c74ee040c..94a3f99f17 100644--- a/server/services/voice/tools.test.js+++ b/server/services/voice/tools.test.js@@ -212,6 +212,24 @@ describe('getToolSpecs', () => {setUserCatalogTypes([]); // restore the registry for other suites}});++ it('intent gating surfaces catalog_lookup for an utterance naming a user-defined type', async () => {+ const { setUserCatalogTypes } = await import('../../lib/catalogTypes.js');+ try {+ // Before the type exists, "search my wardrobes" must NOT trip the catalog+ // group (proves the static regex doesn't already cover the word).+ const before = getToolSpecsForIntent('search my wardrobes');+ expect(before.specs.some((s) => s.function.name === 'catalog_lookup')).toBe(false);++ setUserCatalogTypes([{ id: 'wardrobe', label: 'Wardrobe', primaryContentKey: 'desc', fields: [] }]);+ const after = getToolSpecsForIntent('search my wardrobes');+ // Now the custom-noun match activates the catalog group and offers the tool.+ expect(after.activeGroups.has('catalog')).toBe(true);+ expect(after.specs.some((s) => s.function.name === 'catalog_lookup')).toBe(true);+ } finally {+ setUserCatalogTypes([]);+ }+ });});describe('dispatchTool unknown tool', () => {