Main entry point: - create-hooks.ts, create-tools.ts, create-managers.ts - plugin-interface.ts: plugin interface types - plugin/ directory: plugin lifecycle modules Config handler: - agent-config-handler.ts, command-config-handler.ts - tool-config-handler.ts, mcp-config-handler.ts - provider-config-handler.ts, category-config-resolver.ts - agent-priority-order.ts, prometheus-agent-config-builder.ts - plugin-components-loader.ts
45 lines
1.6 KiB
TypeScript
45 lines
1.6 KiB
TypeScript
import type { OhMyOpenCodeConfig } from "../config";
|
|
import type { ModelCacheState } from "../plugin-state";
|
|
import { log } from "../shared";
|
|
import { applyAgentConfig } from "./agent-config-handler";
|
|
import { applyCommandConfig } from "./command-config-handler";
|
|
import { applyMcpConfig } from "./mcp-config-handler";
|
|
import { applyProviderConfig } from "./provider-config-handler";
|
|
import { loadPluginComponents } from "./plugin-components-loader";
|
|
import { applyToolConfig } from "./tool-config-handler";
|
|
|
|
export { resolveCategoryConfig } from "./category-config-resolver";
|
|
|
|
export interface ConfigHandlerDeps {
|
|
ctx: { directory: string; client?: any };
|
|
pluginConfig: OhMyOpenCodeConfig;
|
|
modelCacheState: ModelCacheState;
|
|
}
|
|
|
|
export function createConfigHandler(deps: ConfigHandlerDeps) {
|
|
const { ctx, pluginConfig, modelCacheState } = deps;
|
|
|
|
return async (config: Record<string, unknown>) => {
|
|
applyProviderConfig({ config, modelCacheState });
|
|
|
|
const pluginComponents = await loadPluginComponents({ pluginConfig });
|
|
|
|
const agentResult = await applyAgentConfig({
|
|
config,
|
|
pluginConfig,
|
|
ctx,
|
|
pluginComponents,
|
|
});
|
|
|
|
applyToolConfig({ config, pluginConfig, agentResult });
|
|
await applyMcpConfig({ config, pluginConfig, pluginComponents });
|
|
await applyCommandConfig({ config, pluginConfig, pluginComponents });
|
|
|
|
log("[config-handler] config handler applied", {
|
|
agentCount: Object.keys(agentResult).length,
|
|
commandCount: Object.keys((config.command as Record<string, unknown>) ?? {})
|
|
.length,
|
|
});
|
|
};
|
|
}
|