diff --git a/extensions/codex/src/app-server/dynamic-tool-build-state.ts b/extensions/codex/src/app-server/dynamic-tool-build-state.ts index 7c8b16b95268..528bc96d8fc3 100644 --- a/extensions/codex/src/app-server/dynamic-tool-build-state.ts +++ b/extensions/codex/src/app-server/dynamic-tool-build-state.ts @@ -1,7 +1,7 @@ type OpenClawCodingToolsFactory = (typeof import("openclaw/plugin-sdk/agent-harness"))["createOpenClawCodingTools"]; type AgentHarnessCodingToolsFactory = - (typeof import("openclaw/plugin-sdk/agent-harness-tool-authority-runtime"))["createOpenClawCodingToolsForAgentHarness"]; + (typeof import("openclaw/plugin-sdk/agent-harness-tool-runtime"))["createOpenClawCodingToolsForAgentHarness"]; /** Mutable dependency seam shared by dynamic-tool construction and its behavioral tests. */ export const dynamicToolBuildState: { diff --git a/extensions/codex/src/app-server/dynamic-tool-build.lazy-import.test.ts b/extensions/codex/src/app-server/dynamic-tool-build.lazy-import.test.ts index 05a6da6f85dd..68bc19b076c2 100644 --- a/extensions/codex/src/app-server/dynamic-tool-build.lazy-import.test.ts +++ b/extensions/codex/src/app-server/dynamic-tool-build.lazy-import.test.ts @@ -1,13 +1,13 @@ import { afterEach, expect, it, vi } from "vitest"; afterEach(() => { - vi.doUnmock("openclaw/plugin-sdk/agent-harness-tool-authority-runtime"); + vi.doUnmock("openclaw/plugin-sdk/agent-harness-tool-runtime"); vi.resetModules(); }); it("does not load the private tool builder before a tool-capable turn", async () => { let toolBuilderImports = 0; - vi.doMock("openclaw/plugin-sdk/agent-harness-tool-authority-runtime", () => { + vi.doMock("openclaw/plugin-sdk/agent-harness-tool-runtime", () => { toolBuilderImports += 1; return { createOpenClawCodingToolsForAgentHarness: vi.fn(() => []), diff --git a/extensions/codex/src/app-server/dynamic-tool-build.ts b/extensions/codex/src/app-server/dynamic-tool-build.ts index 67854e6d83d9..7bbe3721fd92 100644 --- a/extensions/codex/src/app-server/dynamic-tool-build.ts +++ b/extensions/codex/src/app-server/dynamic-tool-build.ts @@ -235,7 +235,7 @@ export async function buildDynamicTools(input: DynamicToolBuildParams) { const agentHarnessCodingToolsFactory = injectedOpenClawCodingToolsFactory ? undefined : (dynamicToolBuildState.agentHarnessCodingToolsFactory ?? - (await import("openclaw/plugin-sdk/agent-harness-tool-authority-runtime")) + (await import("openclaw/plugin-sdk/agent-harness-tool-runtime")) .createOpenClawCodingToolsForAgentHarness); const createOpenClawCodingTools = injectedOpenClawCodingToolsFactory ?? diff --git a/extensions/codex/src/app-server/side-question.test.ts b/extensions/codex/src/app-server/side-question.test.ts index 1c277643f58f..6c60a5233177 100644 --- a/extensions/codex/src/app-server/side-question.test.ts +++ b/extensions/codex/src/app-server/side-question.test.ts @@ -100,7 +100,7 @@ vi.mock("./provider-capabilities.js", () => ({ resolveCodexProviderWebSearchSupportForClientMock(...args), })); -vi.mock("openclaw/plugin-sdk/agent-harness-tool-authority-runtime", () => ({ +vi.mock("openclaw/plugin-sdk/agent-harness-tool-runtime", () => ({ createOpenClawCodingToolsForAgentHarnessSideQuestion: (params: unknown, options: unknown) => createOpenClawCodingToolsForSideQuestionMock(params, options), })); diff --git a/extensions/codex/src/app-server/side-question.ts b/extensions/codex/src/app-server/side-question.ts index 7345a8e9a7df..bc22cca775a2 100644 --- a/extensions/codex/src/app-server/side-question.ts +++ b/extensions/codex/src/app-server/side-question.ts @@ -938,7 +938,7 @@ async function createCodexSideToolBridge(input: { let tools: AnyAgentTool[] = []; if (supportsModelTools(runtimeModel)) { const { createOpenClawCodingToolsForAgentHarnessSideQuestion } = - await import("openclaw/plugin-sdk/agent-harness-tool-authority-runtime"); + await import("openclaw/plugin-sdk/agent-harness-tool-runtime"); const sandboxSessionKey = input.params.sandboxSessionKey?.trim() || input.params.sessionKey?.trim() || diff --git a/extensions/copilot/src/tool-bridge.lazy-import.test.ts b/extensions/copilot/src/tool-bridge.lazy-import.test.ts deleted file mode 100644 index 79df4c88c18e..000000000000 --- a/extensions/copilot/src/tool-bridge.lazy-import.test.ts +++ /dev/null @@ -1,43 +0,0 @@ -import { afterEach, expect, it, vi } from "vitest"; - -afterEach(() => { - vi.doUnmock("openclaw/plugin-sdk/agent-harness-tool-authority-runtime"); - vi.resetModules(); -}); - -it("loads the private tool builder only after the tool-construction guard", async () => { - let toolBuilderImports = 0; - vi.doMock("openclaw/plugin-sdk/agent-harness-tool-authority-runtime", () => { - toolBuilderImports += 1; - return { - createOpenClawCodingToolsForAgentHarness: vi.fn(() => []), - }; - }); - - const { createCopilotToolBridge } = await import("./tool-bridge.js"); - expect(toolBuilderImports).toBe(0); - - await expect( - createCopilotToolBridge({ - admittedAttempt: {} as never, - agentId: "agent-1", - attemptParams: { disableTools: true } as never, - modelId: "gpt-4o", - modelProvider: "github-copilot", - sessionId: "session-1", - }), - ).resolves.toEqual({ codeModeEngaged: false, sdkTools: [], sourceTools: [] }); - expect(toolBuilderImports).toBe(0); - - await expect( - createCopilotToolBridge({ - admittedAttempt: {} as never, - agentId: "agent-1", - attemptParams: {} as never, - modelId: "gpt-4o", - modelProvider: "github-copilot", - sessionId: "session-1", - }), - ).resolves.toMatchObject({ sdkTools: [], sourceTools: [] }); - expect(toolBuilderImports).toBe(1); -}); diff --git a/extensions/copilot/src/tool-bridge.ts b/extensions/copilot/src/tool-bridge.ts index a6b0608c625b..ae5bc0336bd5 100644 --- a/extensions/copilot/src/tool-bridge.ts +++ b/extensions/copilot/src/tool-bridge.ts @@ -22,7 +22,10 @@ import { resolveModelAuthMode, sanitizeToolResult, } from "openclaw/plugin-sdk/agent-harness-runtime"; -import { createAgentHarnessToolSurfaceRuntime } from "openclaw/plugin-sdk/agent-harness-tool-runtime"; +import { + createAgentHarnessToolSurfaceRuntime, + createOpenClawCodingToolsForAgentHarness, +} from "openclaw/plugin-sdk/agent-harness-tool-runtime"; type CreateOpenClawCodingTools = (typeof import("openclaw/plugin-sdk/agent-harness"))["createOpenClawCodingTools"]; @@ -201,11 +204,8 @@ export async function createCopilotToolBridge( const createOpenClawCodingTools = input.createOpenClawCodingTools ?? (admittedAttempt - ? async (options: OpenClawCodingToolsOptions) => { - const { createOpenClawCodingToolsForAgentHarness } = - await import("openclaw/plugin-sdk/agent-harness-tool-authority-runtime"); - return createOpenClawCodingToolsForAgentHarness(admittedAttempt, options); - } + ? (options: OpenClawCodingToolsOptions) => + createOpenClawCodingToolsForAgentHarness(admittedAttempt, options) : (await import("openclaw/plugin-sdk/agent-harness")).createOpenClawCodingTools); const toolSurfaceRuntime = createAgentHarnessToolSurfaceRuntime({ diff --git a/extensions/tsconfig.package-boundary.paths.json b/extensions/tsconfig.package-boundary.paths.json index e3ab6fa37c9f..52c2ab71731e 100644 --- a/extensions/tsconfig.package-boundary.paths.json +++ b/extensions/tsconfig.package-boundary.paths.json @@ -134,9 +134,6 @@ "openclaw/plugin-sdk/agent-harness-exec-review-runtime": [ "../packages/plugin-sdk/dist/src/plugin-sdk/agent-harness-exec-review-runtime.d.ts" ], - "openclaw/plugin-sdk/agent-harness-tool-authority-runtime": [ - "../packages/plugin-sdk/dist/src/plugin-sdk/agent-harness-tool-authority-runtime.d.ts" - ], "openclaw/plugin-sdk/agent-harness-tool-runtime": [ "../packages/plugin-sdk/dist/src/plugin-sdk/agent-harness-tool-runtime.d.ts" ], diff --git a/extensions/xai/tsconfig.json b/extensions/xai/tsconfig.json index b6cf55bdff3b..0fcdf320592b 100644 --- a/extensions/xai/tsconfig.json +++ b/extensions/xai/tsconfig.json @@ -131,9 +131,6 @@ "openclaw/plugin-sdk/agent-harness-exec-review-runtime": [ "../../packages/plugin-sdk/dist/src/plugin-sdk/agent-harness-exec-review-runtime.d.ts" ], - "openclaw/plugin-sdk/agent-harness-tool-authority-runtime": [ - "../../packages/plugin-sdk/dist/src/plugin-sdk/agent-harness-tool-authority-runtime.d.ts" - ], "openclaw/plugin-sdk/agent-harness-tool-runtime": [ "../../packages/plugin-sdk/dist/src/plugin-sdk/agent-harness-tool-runtime.d.ts" ], diff --git a/package.json b/package.json index 94e5343ee8b5..dee7f57f31b5 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,6 @@ "!dist/plugin-sdk/agent-core.d.ts", "!dist/plugin-sdk/agent-harness-exec-review-runtime.d.ts", "!dist/plugin-sdk/agent-harness-task-runtime.d.ts", - "!dist/plugin-sdk/agent-harness-tool-authority-runtime.d.ts", "!dist/plugin-sdk/agent-harness-tool-runtime.d.ts", "!dist/plugin-sdk/agent-runtime-test-contracts.js", "!dist/plugin-sdk/agent-runtime-test-contracts.d.ts", diff --git a/scripts/lib/plugin-sdk-entries.mjs b/scripts/lib/plugin-sdk-entries.mjs index 5567c10f6baf..9adb7747c9cd 100644 --- a/scripts/lib/plugin-sdk-entries.mjs +++ b/scripts/lib/plugin-sdk-entries.mjs @@ -84,10 +84,6 @@ export const packagedPrivatePluginSdkRuntimeEntrypoints = productionPluginSdkEntrypointSet.has(entry), ); -const ownerRestrictedPrivatePluginSdkRuntimeEntrypointSet = new Set([ - "agent-harness-tool-authority-runtime", -]); - /** Private entrypoints reserved for local tests and QA builds. */ const nonProductionPrivatePluginSdkEntrypoints = privateLocalOnlyPluginSdkEntrypoints.filter( (entry) => !productionPluginSdkEntrypointSet.has(entry), @@ -135,10 +131,7 @@ export function buildPluginSdkPackageExports() { ], ]; } - if ( - packagedPrivatePluginSdkRuntimeEntrypoints.includes(entry) && - !ownerRestrictedPrivatePluginSdkRuntimeEntrypointSet.has(entry) - ) { + if (packagedPrivatePluginSdkRuntimeEntrypoints.includes(entry)) { // Official plugins ship separately but execute against the host's private runtime. // Their declarations stay pack-excluded by listUnpackagedPrivatePluginSdkDistArtifacts. return [ diff --git a/scripts/lib/plugin-sdk-entrypoints.json b/scripts/lib/plugin-sdk-entrypoints.json index 22b1ddf031eb..9cf93e1ecaa5 100644 --- a/scripts/lib/plugin-sdk-entrypoints.json +++ b/scripts/lib/plugin-sdk-entrypoints.json @@ -107,7 +107,6 @@ "agent-harness", "agent-harness-exec-review-runtime", "agent-harness-runtime", - "agent-harness-tool-authority-runtime", "agent-harness-tool-runtime", "hook-runtime", "html-entity-runtime", diff --git a/scripts/lib/plugin-sdk-private-local-only-subpaths.json b/scripts/lib/plugin-sdk-private-local-only-subpaths.json index cbdd986555f3..3a552e30a7dc 100644 --- a/scripts/lib/plugin-sdk-private-local-only-subpaths.json +++ b/scripts/lib/plugin-sdk-private-local-only-subpaths.json @@ -8,7 +8,6 @@ "agent-core", "agent-harness-exec-review-runtime", "agent-harness-task-runtime", - "agent-harness-tool-authority-runtime", "agent-harness-tool-runtime", "agent-runtime-test-contracts", "agent-sessions", diff --git a/src/plugin-sdk/agent-harness-tool-authority-runtime.ts b/src/plugin-sdk/agent-harness-tool-authority-runtime.ts deleted file mode 100644 index ca75062dffc1..000000000000 --- a/src/plugin-sdk/agent-harness-tool-authority-runtime.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { - createOpenClawCodingToolsForAgentHarness as createCoreOpenClawCodingToolsForAgentHarness, - createOpenClawCodingToolsForAgentHarnessSideQuestion as createCoreOpenClawCodingToolsForAgentHarnessSideQuestion, -} from "../agents/agent-tools-internal.js"; -import type { - AgentHarnessSideQuestionParams, - EmbeddedRunAttemptParams, -} from "./agent-harness-runtime.js"; - -type OpenClawCodingToolsOptions = NonNullable< - Parameters[0] ->; - -/** - * Build tools for the exact host-admitted attempt without exposing its private - * execution attribution to plugin code. - */ -export function createOpenClawCodingToolsForAgentHarness( - attempt: EmbeddedRunAttemptParams, - options?: OpenClawCodingToolsOptions, -): ReturnType { - return createCoreOpenClawCodingToolsForAgentHarness(attempt, options); -} - -/** - * Build tools for the exact host-admitted side-question request without - * exposing its private execution attribution to plugin code. - */ -export function createOpenClawCodingToolsForAgentHarnessSideQuestion( - params: AgentHarnessSideQuestionParams, - options?: OpenClawCodingToolsOptions, -): ReturnType { - return createCoreOpenClawCodingToolsForAgentHarnessSideQuestion(params, options); -} diff --git a/src/plugin-sdk/agent-harness-tool-runtime.ts b/src/plugin-sdk/agent-harness-tool-runtime.ts index a94ea315246d..ceb067aea7cb 100644 --- a/src/plugin-sdk/agent-harness-tool-runtime.ts +++ b/src/plugin-sdk/agent-harness-tool-runtime.ts @@ -1,13 +1,21 @@ +import { + createOpenClawCodingToolsForAgentHarness as createCoreOpenClawCodingToolsForAgentHarness, + createOpenClawCodingToolsForAgentHarnessSideQuestion as createCoreOpenClawCodingToolsForAgentHarnessSideQuestion, +} from "../agents/agent-tools-internal.js"; /** - * Focused runtime SDK subpath for native harness tool-surface routing. + * Packaged private runtime facade for official harness plugins. * - * Keep tool-search and code-mode dependencies out of the lightweight harness - * lifecycle facade used during plugin startup. + * This subpath is local-only and declaration-excluded. Keep tool-search and + * code-mode dependencies out of the lightweight startup lifecycle facade. */ import { createAgentHarnessToolSurfaceRuntime as createCoreAgentHarnessToolSurfaceRuntime, type AgentHarnessToolSurfaceRuntime as CoreAgentHarnessToolSurfaceRuntime, } from "../agents/harness/tool-surface-bridge.js"; +import type { + AgentHarnessSideQuestionParams, + EmbeddedRunAttemptParams, +} from "./agent-harness-runtime.js"; type OpenClawCodingToolsOptions = NonNullable< Parameters[0] @@ -33,3 +41,25 @@ export function createAgentHarnessToolSurfaceRuntime( ): AgentHarnessToolSurfaceRuntime { return createCoreAgentHarnessToolSurfaceRuntime(params); } + +/** + * Build tools for the exact host-admitted attempt without exposing its private + * execution attribution to plugin code. + */ +export function createOpenClawCodingToolsForAgentHarness( + attempt: EmbeddedRunAttemptParams, + options?: OpenClawCodingToolsOptions, +): ReturnType { + return createCoreOpenClawCodingToolsForAgentHarness(attempt, options); +} + +/** + * Build tools for the exact host-admitted side-question request without + * exposing its private execution attribution to plugin code. + */ +export function createOpenClawCodingToolsForAgentHarnessSideQuestion( + params: AgentHarnessSideQuestionParams, + options?: OpenClawCodingToolsOptions, +): ReturnType { + return createCoreOpenClawCodingToolsForAgentHarnessSideQuestion(params, options); +} diff --git a/src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts b/src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts index ec05c6c44993..78c46c43e31b 100644 --- a/src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts +++ b/src/plugins/contracts/plugin-sdk-package-contract-guardrails.test.ts @@ -817,26 +817,6 @@ describe("plugin-sdk package contract guardrails", () => { }); }); - it("keeps the agent harness tool authority runtime owner-restricted", () => { - const entrypoint = "agent-harness-tool-authority-runtime"; - const localOnly = new Set(privateLocalOnlyPluginSdkEntrypoints); - const packageExports = new Set(collectPluginSdkPackageExports()); - const typedExports = collectTypedPluginSdkPackageExports(); - const excludedDeclarations = collectPackExcludedPluginSdkDeclarations(); - - expect({ - localOnly: localOnly.has(entrypoint), - packageExport: packageExports.has(entrypoint), - typedExport: typedExports.has(entrypoint), - declarationExcluded: excludedDeclarations.has(entrypoint), - }).toEqual({ - localOnly: true, - packageExport: false, - typedExport: false, - declarationExcluded: true, - }); - }); - it("keeps configured local-origin fetch helpers out of deprecated infra-runtime", () => { const source = fs.readFileSync(resolve(REPO_ROOT, "src/plugin-sdk/infra-runtime.ts"), "utf8"); diff --git a/src/plugins/sdk-alias.test.ts b/src/plugins/sdk-alias.test.ts index 7b9e39d15238..3378ad16cd72 100644 --- a/src/plugins/sdk-alias.test.ts +++ b/src/plugins/sdk-alias.test.ts @@ -654,106 +654,6 @@ describe("plugin sdk alias helpers", () => { expect(shadowCodexSubpaths).toEqual(["core"]); }); - it("aliases harness tool authority only for trusted official harness plugins", () => { - const fixture = createPluginSdkAliasFixture({ - packageExports: { - "./plugin-sdk/core": { default: "./dist/plugin-sdk/core.js" }, - }, - }); - const authoritySubpath = "agent-harness-tool-authority-runtime"; - const sourceAuthorityPath = path.join( - fixture.root, - "src", - "plugin-sdk", - `${authoritySubpath}.ts`, - ); - const distAuthorityPath = path.join( - fixture.root, - "dist", - "plugin-sdk", - `${authoritySubpath}.js`, - ); - fs.writeFileSync( - path.join(fixture.root, "scripts", "lib", "plugin-sdk-private-local-only-subpaths.json"), - JSON.stringify([authoritySubpath], null, 2), - "utf-8", - ); - fs.writeFileSync(sourceAuthorityPath, "export const authority = true;\n", "utf-8"); - fs.writeFileSync(distAuthorityPath, "export const authority = true;\n", "utf-8"); - - const sourceCodexEntry = writePluginEntry( - fixture.root, - bundledPluginFile("codex", "src/index.ts"), - ); - const sourceCopilotEntry = writePluginEntry( - fixture.root, - bundledPluginFile("copilot", "src/index.ts"), - ); - const sourceOtherEntry = writePluginEntry( - fixture.root, - bundledPluginFile("demo", "src/index.ts"), - ); - const { packageRoot: installedCodexRoot, pluginEntry: installedCodexEntry } = - writeInstalledPluginEntry({ - installRoot: path.join(makeTempDir(), ".openclaw", "npm"), - packageName: "@openclaw/codex", - }); - const { packageRoot: installedCopilotRoot, pluginEntry: installedCopilotEntry } = - writeInstalledPluginEntry({ - installRoot: path.join(makeTempDir(), ".openclaw", "npm"), - packageName: "@openclaw/copilot", - }); - const { packageRoot: installedOtherRoot, pluginEntry: installedOtherEntry } = - writeInstalledPluginEntry({ - installRoot: path.join(makeTempDir(), ".openclaw", "npm"), - packageName: "@openclaw/demo", - }); - - const sourceCodexAliases = buildPluginLoaderAliasMap(sourceCodexEntry); - const sourceCopilotAliases = buildPluginLoaderAliasMap(sourceCopilotEntry); - const sourceOtherAliases = buildPluginLoaderAliasMap(sourceOtherEntry); - const installedCodexAliases = withCwd(installedCodexRoot, () => - buildPluginLoaderAliasMap( - installedCodexEntry, - path.join(fixture.root, "openclaw.mjs"), - undefined, - "dist", - ), - ); - const installedCopilotAliases = withCwd(installedCopilotRoot, () => - buildPluginLoaderAliasMap( - installedCopilotEntry, - path.join(fixture.root, "openclaw.mjs"), - undefined, - "dist", - ), - ); - const installedOtherAliases = withCwd(installedOtherRoot, () => - buildPluginLoaderAliasMap( - installedOtherEntry, - path.join(fixture.root, "openclaw.mjs"), - undefined, - "dist", - ), - ); - const specifier = `openclaw/plugin-sdk/${authoritySubpath}`; - - expect(fs.realpathSync(sourceCodexAliases[specifier] ?? "")).toBe( - fs.realpathSync(sourceAuthorityPath), - ); - expect(fs.realpathSync(sourceCopilotAliases[specifier] ?? "")).toBe( - fs.realpathSync(sourceAuthorityPath), - ); - expect(fs.realpathSync(installedCodexAliases[specifier] ?? "")).toBe( - fs.realpathSync(distAuthorityPath), - ); - expect(fs.realpathSync(installedCopilotAliases[specifier] ?? "")).toBe( - fs.realpathSync(distAuthorityPath), - ); - expect(sourceOtherAliases[specifier]).toBeUndefined(); - expect(installedOtherAliases[specifier]).toBeUndefined(); - }); - it("does not reuse a non-private cached subpath list after private qa gets enabled", () => { const fixture = createPluginSdkAliasFixture({ packageExports: { diff --git a/src/plugins/sdk-alias.ts b/src/plugins/sdk-alias.ts index cafc2cbc4ba8..148931838be4 100644 --- a/src/plugins/sdk-alias.ts +++ b/src/plugins/sdk-alias.ts @@ -419,7 +419,6 @@ const cachedWorkspacePackageAliasMaps = new PluginLruCache