fix(oc-plugin): replace Pi-direct with MACP controller bridge in runTurn
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import path from 'node:path';
|
||||
import * as os from 'node:os';
|
||||
import * as path from 'node:path';
|
||||
|
||||
import {
|
||||
registerAcpRuntimeBackend,
|
||||
@@ -17,10 +18,27 @@ type PluginConfig = {
|
||||
systemPrompt?: string;
|
||||
timeoutMs?: number;
|
||||
logDir?: string;
|
||||
repoRoot?: string;
|
||||
orchDir?: string;
|
||||
defaultDispatch?: string;
|
||||
defaultRuntime?: string;
|
||||
};
|
||||
|
||||
function expandHome(rawPath: string): string {
|
||||
if (rawPath === '~') {
|
||||
return os.homedir();
|
||||
}
|
||||
if (rawPath.startsWith('~/')) {
|
||||
return path.join(os.homedir(), rawPath.slice(2));
|
||||
}
|
||||
return rawPath;
|
||||
}
|
||||
|
||||
function resolveConfig(pluginConfig?: Record<string, unknown>, stateDir?: string) {
|
||||
const config = (pluginConfig ?? {}) as PluginConfig;
|
||||
const repoRoot = config.repoRoot?.trim()
|
||||
? path.resolve(expandHome(config.repoRoot))
|
||||
: path.resolve('/home/jarvis/src/mosaic-mono-v1');
|
||||
return {
|
||||
defaultModel: config.defaultModel?.trim() || 'openai/gpt-5-mini',
|
||||
systemPrompt: config.systemPrompt ?? '',
|
||||
@@ -30,7 +48,15 @@ function resolveConfig(pluginConfig?: Record<string, unknown>, stateDir?: string
|
||||
config.timeoutMs > 0
|
||||
? config.timeoutMs
|
||||
: 300_000,
|
||||
stateDir: config.logDir?.trim() ? path.resolve(config.logDir) : (stateDir ?? process.cwd()),
|
||||
stateDir: config.logDir?.trim()
|
||||
? path.resolve(expandHome(config.logDir))
|
||||
: (stateDir ?? process.cwd()),
|
||||
repoRoot,
|
||||
orchDir: config.orchDir?.trim()
|
||||
? path.resolve(expandHome(config.orchDir))
|
||||
: path.join(repoRoot, '.mosaic', 'orchestrator'),
|
||||
defaultDispatch: config.defaultDispatch?.trim() || 'yolo',
|
||||
defaultRuntime: config.defaultRuntime?.trim() || 'codex',
|
||||
};
|
||||
}
|
||||
|
||||
@@ -51,7 +77,7 @@ function createMacpRuntimeService(pluginConfig?: Record<string, unknown>): OpenC
|
||||
healthy: () => runtime !== null,
|
||||
});
|
||||
ctx.logger.info(
|
||||
`macp runtime backend registered (defaultModel: ${resolved.defaultModel}, timeoutMs: ${resolved.timeoutMs})`,
|
||||
`macp runtime backend registered (defaultRuntime: ${resolved.defaultRuntime}, defaultDispatch: ${resolved.defaultDispatch}, timeoutMs: ${resolved.timeoutMs})`,
|
||||
);
|
||||
},
|
||||
async stop(_ctx: OpenClawPluginServiceContext) {
|
||||
@@ -64,7 +90,8 @@ function createMacpRuntimeService(pluginConfig?: Record<string, unknown>): OpenC
|
||||
const plugin = {
|
||||
id: 'macp',
|
||||
name: 'MACP Runtime',
|
||||
description: 'ACP runtime backend that dispatches Pi oneshot sessions through MACP.',
|
||||
description:
|
||||
'ACP runtime backend that dispatches OpenClaw oneshot sessions through the MACP controller queue.',
|
||||
register(api: OpenClawPluginApi) {
|
||||
api.registerService(createMacpRuntimeService(api.pluginConfig));
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user