Skip to content

Commit 80e681a

Browse files
committed
Plugins: integrate LSP tool runtime into Pi embedded runner
1 parent 8193af6 commit 80e681a

2 files changed

Lines changed: 35 additions & 8 deletions

File tree

src/agents/pi-embedded-runner/compact.ts

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ import { supportsModelTools } from "../model-tool-support.js";
5353
import { ensureOpenClawModelsJson } from "../models-config.js";
5454
import { createConfiguredOllamaStreamFn } from "../ollama-stream.js";
5555
import { resolveOwnerDisplaySetting } from "../owner-display.js";
56+
import { createBundleLspToolRuntime } from "../pi-bundle-lsp-runtime.js";
5657
import { createBundleMcpToolRuntime } from "../pi-bundle-mcp-tools.js";
5758
import {
5859
ensureSessionHeader,
@@ -603,10 +604,21 @@ export async function compactEmbeddedPiSessionDirect(
603604
reservedToolNames: tools.map((tool) => tool.name),
604605
})
605606
: undefined;
606-
const effectiveTools =
607-
bundleMcpRuntime && bundleMcpRuntime.tools.length > 0
608-
? [...tools, ...bundleMcpRuntime.tools]
609-
: tools;
607+
const bundleLspRuntime = toolsEnabled
608+
? await createBundleLspToolRuntime({
609+
workspaceDir: effectiveWorkspace,
610+
cfg: params.config,
611+
reservedToolNames: [
612+
...tools.map((tool) => tool.name),
613+
...(bundleMcpRuntime?.tools.map((tool) => tool.name) ?? []),
614+
],
615+
})
616+
: undefined;
617+
const effectiveTools = [
618+
...tools,
619+
...(bundleMcpRuntime?.tools ?? []),
620+
...(bundleLspRuntime?.tools ?? []),
621+
];
610622
const allowedToolNames = collectAllowedToolNames({ tools: effectiveTools });
611623
logToolSchemasForGoogle({ tools: effectiveTools, provider });
612624
const machineName = await getMachineDisplayName();
@@ -1092,6 +1104,7 @@ export async function compactEmbeddedPiSessionDirect(
10921104
});
10931105
session.dispose();
10941106
await bundleMcpRuntime?.dispose();
1107+
await bundleLspRuntime?.dispose();
10951108
}
10961109
} finally {
10971110
await sessionLock.release();

src/agents/pi-embedded-runner/run/attempt.ts

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ import { supportsModelTools } from "../../model-tool-support.js";
6161
import { createConfiguredOllamaStreamFn } from "../../ollama-stream.js";
6262
import { createOpenAIWebSocketStreamFn, releaseWsSession } from "../../openai-ws-stream.js";
6363
import { resolveOwnerDisplaySetting } from "../../owner-display.js";
64+
import { createBundleLspToolRuntime } from "../../pi-bundle-lsp-runtime.js";
6465
import { createBundleMcpToolRuntime } from "../../pi-bundle-mcp-tools.js";
6566
import {
6667
downgradeOpenAIFunctionCallReasoningPairs,
@@ -1570,10 +1571,22 @@ export async function runEmbeddedAttempt(
15701571
],
15711572
})
15721573
: undefined;
1573-
const effectiveTools =
1574-
bundleMcpRuntime && bundleMcpRuntime.tools.length > 0
1575-
? [...tools, ...bundleMcpRuntime.tools]
1576-
: tools;
1574+
const bundleLspRuntime = toolsEnabled
1575+
? await createBundleLspToolRuntime({
1576+
workspaceDir: effectiveWorkspace,
1577+
cfg: params.config,
1578+
reservedToolNames: [
1579+
...tools.map((tool) => tool.name),
1580+
...(clientTools?.map((tool) => tool.function.name) ?? []),
1581+
...(bundleMcpRuntime?.tools.map((tool) => tool.name) ?? []),
1582+
],
1583+
})
1584+
: undefined;
1585+
const effectiveTools = [
1586+
...tools,
1587+
...(bundleMcpRuntime?.tools ?? []),
1588+
...(bundleLspRuntime?.tools ?? []),
1589+
];
15771590
const allowedToolNames = collectAllowedToolNames({
15781591
tools: effectiveTools,
15791592
clientTools,
@@ -2913,6 +2926,7 @@ export async function runEmbeddedAttempt(
29132926
session?.dispose();
29142927
releaseWsSession(params.sessionId);
29152928
await bundleMcpRuntime?.dispose();
2929+
await bundleLspRuntime?.dispose();
29162930
await sessionLock.release();
29172931
}
29182932
} finally {

0 commit comments

Comments
 (0)