completed tools and setup
This commit is contained in:
@@ -3964,6 +3964,7 @@ async function sendMessage() {
|
||||
model,
|
||||
cli,
|
||||
attachments: pendingAttachments.length ? pendingAttachments : undefined,
|
||||
externalTestingEnabled: !!builderState.externalTestingEnabled // Send feature toggle state to server
|
||||
};
|
||||
// Preserve opencodeSessionId to continue in the same session
|
||||
if (currentSession && currentSession.opencodeSessionId) {
|
||||
|
||||
@@ -8800,6 +8800,14 @@ async function sendToOpencode({ session, model, content, message, cli, streamCal
|
||||
args.push('--session', opencodeSessionId);
|
||||
}
|
||||
|
||||
// Configure WP CLI Testing MCP server if feature is enabled
|
||||
const wpCliMcpEnabled = message?.externalTestingEnabled === true;
|
||||
log('WP CLI Testing MCP server configuration', {
|
||||
enabled: wpCliMcpEnabled,
|
||||
messageId: message?.id,
|
||||
sessionId: session.id
|
||||
});
|
||||
|
||||
// Ensure content is properly passed as the final argument
|
||||
if (typeof clean !== 'string' || clean.length === 0) {
|
||||
throw new Error('Message content is invalid or empty after sanitization');
|
||||
@@ -8866,6 +8874,36 @@ async function sendToOpencode({ session, model, content, message, cli, streamCal
|
||||
|
||||
// Use the OpenCode process manager for execution
|
||||
// This ensures all sessions share the same OpenCode instance when possible
|
||||
|
||||
// Build environment variables including WP CLI MCP server config
|
||||
const executionEnv = {
|
||||
...process.env,
|
||||
OPENAI_API_KEY: OPENCODE_OLLAMA_API_KEY
|
||||
};
|
||||
|
||||
// Add WP CLI Testing MCP server to OpenCode config if enabled
|
||||
if (wpCliMcpEnabled) {
|
||||
const wpMcpServerPath = path.resolve(__dirname, '../opencode/mcp-servers/wp-cli-testing/index.js');
|
||||
log('Enabling WP CLI Testing MCP server', { path: wpMcpServerPath, messageId: message?.id });
|
||||
|
||||
// Configure OpenCode to include the WP CLI testing MCP server
|
||||
// We pass this via environment variable that OpenCode can read
|
||||
executionEnv.OPENCODE_EXTRA_MCP_SERVERS = JSON.stringify([
|
||||
{
|
||||
name: 'wp-cli-testing',
|
||||
command: 'node',
|
||||
args: [wpMcpServerPath],
|
||||
disabled: false
|
||||
}
|
||||
]);
|
||||
} else {
|
||||
// Safety: ensure the tools are not injected when the builder toggle is off,
|
||||
// even if the parent process environment happens to have the variable set.
|
||||
if (executionEnv.OPENCODE_EXTRA_MCP_SERVERS) {
|
||||
delete executionEnv.OPENCODE_EXTRA_MCP_SERVERS;
|
||||
}
|
||||
}
|
||||
|
||||
const { stdout, stderr } = await opencodeManager.executeInSession(
|
||||
session?.id || 'standalone',
|
||||
workspaceDir,
|
||||
@@ -8873,10 +8911,7 @@ async function sendToOpencode({ session, model, content, message, cli, streamCal
|
||||
args,
|
||||
{
|
||||
timeout: 600000, // 10 minute timeout to prevent stuck processes
|
||||
env: {
|
||||
...process.env,
|
||||
OPENAI_API_KEY: OPENCODE_OLLAMA_API_KEY
|
||||
},
|
||||
env: executionEnv,
|
||||
onData: (type, chunk) => {
|
||||
try {
|
||||
const now = Date.now();
|
||||
|
||||
Reference in New Issue
Block a user