feat(extensions): support async extension factory functions

Extensions can now use async initialization, enabling:
- Dynamic imports (e.g., loading tools from external packages)
- Async setup (config fetching, service connections)
- Lazy-loaded dependencies

Changes:
- ExtensionFactory type now returns void | Promise<void>
- loadExtensionFromFactory is now async, returns Promise<LoadedExtension>
- All factory(api) calls are now awaited

Backwards compatible: sync extensions continue to work unchanged.
This commit is contained in:
Austin Mudd 2026-01-06 14:35:43 -08:00
parent 282273e156
commit aea9f8439d
3 changed files with 8 additions and 8 deletions

View file

@ -488,7 +488,7 @@ export async function createAgentSession(options: CreateAgentSessionOptions = {}
};
for (let i = 0; i < options.extensions.length; i++) {
const factory = options.extensions[i];
const loaded = loadExtensionFromFactory(factory, cwd, eventBus, uiHolder, `<inline-${i}>`);
const loaded = await loadExtensionFromFactory(factory, cwd, eventBus, uiHolder, `<inline-${i}>`);
extensionsResult.extensions.push(loaded);
}
// Extend setUIContext to update inline extensions too