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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user