mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-19 17:04:41 +00:00
Merge remote-tracking branch 'origin/main' into feat/no-extensions-flag
This commit is contained in:
commit
893e00579d
5 changed files with 123 additions and 9 deletions
|
|
@ -313,7 +313,7 @@ async function loadExtensionWithBun(
|
|||
setFlagValue,
|
||||
} = createExtensionAPI(handlers, tools, cwd, extensionPath, eventBus, sharedUI);
|
||||
|
||||
factory(api);
|
||||
await factory(api);
|
||||
|
||||
return {
|
||||
extension: {
|
||||
|
|
@ -401,7 +401,7 @@ async function loadExtension(
|
|||
setFlagValue,
|
||||
} = createExtensionAPI(handlers, tools, cwd, extensionPath, eventBus, sharedUI);
|
||||
|
||||
factory(api);
|
||||
await factory(api);
|
||||
|
||||
return {
|
||||
extension: {
|
||||
|
|
@ -436,13 +436,13 @@ async function loadExtension(
|
|||
/**
|
||||
* Create a LoadedExtension from an inline factory function.
|
||||
*/
|
||||
export function loadExtensionFromFactory(
|
||||
export async function loadExtensionFromFactory(
|
||||
factory: ExtensionFactory,
|
||||
cwd: string,
|
||||
eventBus: EventBus,
|
||||
sharedUI: { ui: ExtensionUIContext; hasUI: boolean },
|
||||
name = "<inline>",
|
||||
): LoadedExtension {
|
||||
): Promise<LoadedExtension> {
|
||||
const handlers = new Map<string, HandlerFn[]>();
|
||||
const tools = new Map<string, RegisteredTool>();
|
||||
const {
|
||||
|
|
@ -464,7 +464,7 @@ export function loadExtensionFromFactory(
|
|||
setFlagValue,
|
||||
} = createExtensionAPI(handlers, tools, cwd, name, eventBus, sharedUI);
|
||||
|
||||
factory(api);
|
||||
await factory(api);
|
||||
|
||||
return {
|
||||
path: name,
|
||||
|
|
|
|||
|
|
@ -649,8 +649,8 @@ export interface ExtensionAPI {
|
|||
events: EventBus;
|
||||
}
|
||||
|
||||
/** Extension factory function type. */
|
||||
export type ExtensionFactory = (pi: ExtensionAPI) => void;
|
||||
/** Extension factory function type. Supports both sync and async initialization. */
|
||||
export type ExtensionFactory = (pi: ExtensionAPI) => void | Promise<void>;
|
||||
|
||||
// ============================================================================
|
||||
// Loaded Extension Types
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -178,7 +178,13 @@ export class SettingsManager {
|
|||
mkdirSync(dir, { recursive: true });
|
||||
}
|
||||
|
||||
// Save only global settings (project settings are read-only)
|
||||
// Re-read current file to preserve any settings added externally while running
|
||||
const currentFileSettings = SettingsManager.loadFromFile(this.settingsPath);
|
||||
// Merge: file settings as base, globalSettings (in-memory changes) as overrides
|
||||
const mergedSettings = deepMergeSettings(currentFileSettings, this.globalSettings);
|
||||
this.globalSettings = mergedSettings;
|
||||
|
||||
// Save merged settings (project settings are read-only)
|
||||
writeFileSync(this.settingsPath, JSON.stringify(this.globalSettings, null, 2), "utf-8");
|
||||
} catch (error) {
|
||||
console.error(`Warning: Could not save settings file: ${error}`);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue