mirror of
https://github.com/openclaw/openclaw.git
synced 2026-03-20 06:20:55 +00:00
Plugins: integrate LSP tool runtime into Pi embedded runner
This commit is contained in:
@@ -53,6 +53,7 @@ import { supportsModelTools } from "../model-tool-support.js";
|
||||
import { ensureOpenClawModelsJson } from "../models-config.js";
|
||||
import { createConfiguredOllamaStreamFn } from "../ollama-stream.js";
|
||||
import { resolveOwnerDisplaySetting } from "../owner-display.js";
|
||||
import { createBundleLspToolRuntime } from "../pi-bundle-lsp-runtime.js";
|
||||
import { createBundleMcpToolRuntime } from "../pi-bundle-mcp-tools.js";
|
||||
import {
|
||||
ensureSessionHeader,
|
||||
@@ -603,10 +604,21 @@ export async function compactEmbeddedPiSessionDirect(
|
||||
reservedToolNames: tools.map((tool) => tool.name),
|
||||
})
|
||||
: undefined;
|
||||
const effectiveTools =
|
||||
bundleMcpRuntime && bundleMcpRuntime.tools.length > 0
|
||||
? [...tools, ...bundleMcpRuntime.tools]
|
||||
: tools;
|
||||
const bundleLspRuntime = toolsEnabled
|
||||
? await createBundleLspToolRuntime({
|
||||
workspaceDir: effectiveWorkspace,
|
||||
cfg: params.config,
|
||||
reservedToolNames: [
|
||||
...tools.map((tool) => tool.name),
|
||||
...(bundleMcpRuntime?.tools.map((tool) => tool.name) ?? []),
|
||||
],
|
||||
})
|
||||
: undefined;
|
||||
const effectiveTools = [
|
||||
...tools,
|
||||
...(bundleMcpRuntime?.tools ?? []),
|
||||
...(bundleLspRuntime?.tools ?? []),
|
||||
];
|
||||
const allowedToolNames = collectAllowedToolNames({ tools: effectiveTools });
|
||||
logToolSchemasForGoogle({ tools: effectiveTools, provider });
|
||||
const machineName = await getMachineDisplayName();
|
||||
@@ -1092,6 +1104,7 @@ export async function compactEmbeddedPiSessionDirect(
|
||||
});
|
||||
session.dispose();
|
||||
await bundleMcpRuntime?.dispose();
|
||||
await bundleLspRuntime?.dispose();
|
||||
}
|
||||
} finally {
|
||||
await sessionLock.release();
|
||||
|
||||
@@ -61,6 +61,7 @@ import { supportsModelTools } from "../../model-tool-support.js";
|
||||
import { createConfiguredOllamaStreamFn } from "../../ollama-stream.js";
|
||||
import { createOpenAIWebSocketStreamFn, releaseWsSession } from "../../openai-ws-stream.js";
|
||||
import { resolveOwnerDisplaySetting } from "../../owner-display.js";
|
||||
import { createBundleLspToolRuntime } from "../../pi-bundle-lsp-runtime.js";
|
||||
import { createBundleMcpToolRuntime } from "../../pi-bundle-mcp-tools.js";
|
||||
import {
|
||||
downgradeOpenAIFunctionCallReasoningPairs,
|
||||
@@ -1570,10 +1571,22 @@ export async function runEmbeddedAttempt(
|
||||
],
|
||||
})
|
||||
: undefined;
|
||||
const effectiveTools =
|
||||
bundleMcpRuntime && bundleMcpRuntime.tools.length > 0
|
||||
? [...tools, ...bundleMcpRuntime.tools]
|
||||
: tools;
|
||||
const bundleLspRuntime = toolsEnabled
|
||||
? await createBundleLspToolRuntime({
|
||||
workspaceDir: effectiveWorkspace,
|
||||
cfg: params.config,
|
||||
reservedToolNames: [
|
||||
...tools.map((tool) => tool.name),
|
||||
...(clientTools?.map((tool) => tool.function.name) ?? []),
|
||||
...(bundleMcpRuntime?.tools.map((tool) => tool.name) ?? []),
|
||||
],
|
||||
})
|
||||
: undefined;
|
||||
const effectiveTools = [
|
||||
...tools,
|
||||
...(bundleMcpRuntime?.tools ?? []),
|
||||
...(bundleLspRuntime?.tools ?? []),
|
||||
];
|
||||
const allowedToolNames = collectAllowedToolNames({
|
||||
tools: effectiveTools,
|
||||
clientTools,
|
||||
@@ -2913,6 +2926,7 @@ export async function runEmbeddedAttempt(
|
||||
session?.dispose();
|
||||
releaseWsSession(params.sessionId);
|
||||
await bundleMcpRuntime?.dispose();
|
||||
await bundleLspRuntime?.dispose();
|
||||
await sessionLock.release();
|
||||
}
|
||||
} finally {
|
||||
|
||||
Reference in New Issue
Block a user