feat: share the tool catalog with voice

This commit is contained in:
Sameh Khamis committed 2026-10-01 13:52:36 -07:00
1 parent 0953ebb026
commit 1a03e7483d
19 files changed
+288 -15

No files matched your search

+22
View File
@@ -0,0 +1,22 @@
/** The standalone tool catalog for voice, loaded the first time voice needs it. */
let pending = null;
export function loadToolCatalog() {
pending ??= Promise.all([
import('../tools/index.js'),
import('../tools/services.js'),
]).then(([{ composeCatalog, coreTools }, { createToolServices }]) =>
composeCatalog({
tools: coreTools,
services: createToolServices({
fetchImpl: (...args) => globalThis.fetch(...args),
appUrl: globalThis.location.origin,
}),
}),
);
pending.catch(() => {
pending = null;
});
return pending;
}
+2
View File
@@ -1,6 +1,7 @@
import { createAssetDirectorySource } from '../director/packs/source.js';
import { createApplicationTools } from '../app/tools.js';
import { startStandaloneChrome } from './startupChrome.js';
import { loadToolCatalog } from './toolCatalog.js';
export function createStandaloneTools(options) {
return createApplicationTools({
startChrome: startStandaloneChrome,
@@ -12,5 +13,6 @@ export function createStandaloneTools(options) {
},
},
...options,
voice: { toolCatalog: loadToolCatalog, ...options?.voice },
});
}