mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-08 10:20:44 +00:00
fix(plugins): remove Pi tool result compat
This commit is contained in:
@@ -49,7 +49,6 @@ export type BuildPluginApiParams = {
|
||||
| "registerContextEngine"
|
||||
| "registerCompactionProvider"
|
||||
| "registerAgentHarness"
|
||||
| "registerEmbeddedExtensionFactory"
|
||||
| "registerCodexAppServerExtensionFactory"
|
||||
| "registerAgentToolResultMiddleware"
|
||||
| "registerDetachedTaskRuntime"
|
||||
@@ -105,8 +104,6 @@ const noopRegisterCommand: OpenClawPluginApi["registerCommand"] = () => {};
|
||||
const noopRegisterContextEngine: OpenClawPluginApi["registerContextEngine"] = () => {};
|
||||
const noopRegisterCompactionProvider: OpenClawPluginApi["registerCompactionProvider"] = () => {};
|
||||
const noopRegisterAgentHarness: OpenClawPluginApi["registerAgentHarness"] = () => {};
|
||||
const noopRegisterEmbeddedExtensionFactory: OpenClawPluginApi["registerEmbeddedExtensionFactory"] =
|
||||
() => {};
|
||||
const noopRegisterCodexAppServerExtensionFactory: OpenClawPluginApi["registerCodexAppServerExtensionFactory"] =
|
||||
() => {};
|
||||
const noopRegisterAgentToolResultMiddleware: OpenClawPluginApi["registerAgentToolResultMiddleware"] =
|
||||
@@ -180,8 +177,6 @@ export function buildPluginApi(params: BuildPluginApiParams): OpenClawPluginApi
|
||||
registerCompactionProvider:
|
||||
handlers.registerCompactionProvider ?? noopRegisterCompactionProvider,
|
||||
registerAgentHarness: handlers.registerAgentHarness ?? noopRegisterAgentHarness,
|
||||
registerEmbeddedExtensionFactory:
|
||||
handlers.registerEmbeddedExtensionFactory ?? noopRegisterEmbeddedExtensionFactory,
|
||||
registerCodexAppServerExtensionFactory:
|
||||
handlers.registerCodexAppServerExtensionFactory ?? noopRegisterCodexAppServerExtensionFactory,
|
||||
registerAgentToolResultMiddleware:
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { ExtensionFactory } from "@mariozechner/pi-coding-agent";
|
||||
import type { OpenClawConfig } from "../config/types.openclaw.js";
|
||||
import type {
|
||||
AgentToolResultMiddleware,
|
||||
@@ -43,7 +42,6 @@ export type CapturedPluginRegistration = {
|
||||
cliRegistrars: CapturedPluginCliRegistration[];
|
||||
cliBackends: CliBackendPlugin[];
|
||||
textTransforms: PluginTextTransformRegistration[];
|
||||
embeddedExtensionFactories: ExtensionFactory[];
|
||||
codexAppServerExtensionFactories: CodexAppServerExtensionFactory[];
|
||||
agentToolResultMiddlewares: PluginAgentToolResultMiddlewareRegistration[];
|
||||
speechProviders: SpeechProviderPlugin[];
|
||||
@@ -68,7 +66,6 @@ export function createCapturedPluginRegistration(params?: {
|
||||
const cliRegistrars: CapturedPluginCliRegistration[] = [];
|
||||
const cliBackends: CliBackendPlugin[] = [];
|
||||
const textTransforms: PluginTextTransformRegistration[] = [];
|
||||
const embeddedExtensionFactories: ExtensionFactory[] = [];
|
||||
const codexAppServerExtensionFactories: CodexAppServerExtensionFactory[] = [];
|
||||
const agentToolResultMiddlewares: PluginAgentToolResultMiddlewareRegistration[] = [];
|
||||
const speechProviders: SpeechProviderPlugin[] = [];
|
||||
@@ -95,7 +92,6 @@ export function createCapturedPluginRegistration(params?: {
|
||||
cliRegistrars,
|
||||
cliBackends,
|
||||
textTransforms,
|
||||
embeddedExtensionFactories,
|
||||
codexAppServerExtensionFactories,
|
||||
agentToolResultMiddlewares,
|
||||
speechProviders,
|
||||
@@ -148,9 +144,6 @@ export function createCapturedPluginRegistration(params?: {
|
||||
registerAgentHarness(harness: AgentHarness) {
|
||||
agentHarnesses.push(harness);
|
||||
},
|
||||
registerEmbeddedExtensionFactory(factory: ExtensionFactory) {
|
||||
embeddedExtensionFactories.push(factory);
|
||||
},
|
||||
registerCodexAppServerExtensionFactory(factory: CodexAppServerExtensionFactory) {
|
||||
codexAppServerExtensionFactories.push(factory);
|
||||
},
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
import type { ExtensionFactory } from "@mariozechner/pi-coding-agent";
|
||||
import { getActivePluginRegistry } from "./runtime.js";
|
||||
|
||||
export const PI_EMBEDDED_EXTENSION_RUNTIME_ID = "pi";
|
||||
|
||||
export function listEmbeddedExtensionFactories(): ExtensionFactory[] {
|
||||
return getActivePluginRegistry()?.embeddedExtensionFactories?.map((entry) => entry.factory) ?? [];
|
||||
}
|
||||
@@ -42,7 +42,6 @@ export function createMockPluginRegistry(
|
||||
musicGenerationProviders: [],
|
||||
webFetchProviders: [],
|
||||
webSearchProviders: [],
|
||||
embeddedExtensionFactories: [],
|
||||
codexAppServerExtensionFactories: [],
|
||||
agentToolResultMiddlewares: [],
|
||||
memoryEmbeddingProviders: [],
|
||||
|
||||
@@ -292,7 +292,6 @@ type PluginRegistrySnapshot = {
|
||||
musicGenerationProviders: PluginRegistry["musicGenerationProviders"];
|
||||
webFetchProviders: PluginRegistry["webFetchProviders"];
|
||||
webSearchProviders: PluginRegistry["webSearchProviders"];
|
||||
embeddedExtensionFactories: PluginRegistry["embeddedExtensionFactories"];
|
||||
codexAppServerExtensionFactories: PluginRegistry["codexAppServerExtensionFactories"];
|
||||
agentToolResultMiddlewares: PluginRegistry["agentToolResultMiddlewares"];
|
||||
memoryEmbeddingProviders: PluginRegistry["memoryEmbeddingProviders"];
|
||||
@@ -331,7 +330,6 @@ function snapshotPluginRegistry(registry: PluginRegistry): PluginRegistrySnapsho
|
||||
musicGenerationProviders: [...registry.musicGenerationProviders],
|
||||
webFetchProviders: [...registry.webFetchProviders],
|
||||
webSearchProviders: [...registry.webSearchProviders],
|
||||
embeddedExtensionFactories: [...registry.embeddedExtensionFactories],
|
||||
codexAppServerExtensionFactories: [...registry.codexAppServerExtensionFactories],
|
||||
agentToolResultMiddlewares: [...registry.agentToolResultMiddlewares],
|
||||
memoryEmbeddingProviders: [...registry.memoryEmbeddingProviders],
|
||||
@@ -369,7 +367,6 @@ function restorePluginRegistry(registry: PluginRegistry, snapshot: PluginRegistr
|
||||
registry.musicGenerationProviders = snapshot.arrays.musicGenerationProviders;
|
||||
registry.webFetchProviders = snapshot.arrays.webFetchProviders;
|
||||
registry.webSearchProviders = snapshot.arrays.webSearchProviders;
|
||||
registry.embeddedExtensionFactories = snapshot.arrays.embeddedExtensionFactories;
|
||||
registry.codexAppServerExtensionFactories = snapshot.arrays.codexAppServerExtensionFactories;
|
||||
registry.agentToolResultMiddlewares = snapshot.arrays.agentToolResultMiddlewares;
|
||||
registry.memoryEmbeddingProviders = snapshot.arrays.memoryEmbeddingProviders;
|
||||
|
||||
@@ -20,7 +20,6 @@ export function createEmptyPluginRegistry(): PluginRegistry {
|
||||
musicGenerationProviders: [],
|
||||
webFetchProviders: [],
|
||||
webSearchProviders: [],
|
||||
embeddedExtensionFactories: [],
|
||||
codexAppServerExtensionFactories: [],
|
||||
agentToolResultMiddlewares: [],
|
||||
memoryEmbeddingProviders: [],
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import type { ExtensionFactory } from "@mariozechner/pi-coding-agent";
|
||||
import type { AgentHarness } from "../agents/harness/types.js";
|
||||
import type { ChannelPlugin } from "../channels/plugins/types.plugin.js";
|
||||
import type { OperatorScope } from "../gateway/operator-scopes.js";
|
||||
@@ -152,14 +151,6 @@ export type PluginWebSearchProviderRegistration =
|
||||
PluginOwnedProviderRegistration<WebSearchProviderPlugin>;
|
||||
export type PluginMemoryEmbeddingProviderRegistration =
|
||||
PluginOwnedProviderRegistration<MemoryEmbeddingProviderAdapter>;
|
||||
export type PluginEmbeddedExtensionFactoryRegistration = {
|
||||
pluginId: string;
|
||||
pluginName?: string;
|
||||
rawFactory: ExtensionFactory;
|
||||
factory: ExtensionFactory;
|
||||
source: string;
|
||||
rootDir?: string;
|
||||
};
|
||||
export type PluginCodexAppServerExtensionFactoryRegistration = {
|
||||
pluginId: string;
|
||||
pluginName?: string;
|
||||
@@ -323,7 +314,6 @@ export type PluginRegistry = {
|
||||
musicGenerationProviders: PluginMusicGenerationProviderRegistration[];
|
||||
webFetchProviders: PluginWebFetchProviderRegistration[];
|
||||
webSearchProviders: PluginWebSearchProviderRegistration[];
|
||||
embeddedExtensionFactories: PluginEmbeddedExtensionFactoryRegistration[];
|
||||
codexAppServerExtensionFactories: PluginCodexAppServerExtensionFactoryRegistration[];
|
||||
agentToolResultMiddlewares: PluginAgentToolResultMiddlewareRegistration[];
|
||||
memoryEmbeddingProviders: PluginMemoryEmbeddingProviderRegistration[];
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import path from "node:path";
|
||||
import type { ExtensionFactory } from "@mariozechner/pi-coding-agent";
|
||||
import {
|
||||
getRegisteredAgentHarness,
|
||||
registerAgentHarness as registerGlobalAgentHarness,
|
||||
@@ -43,7 +42,6 @@ import {
|
||||
getRegisteredCompactionProvider,
|
||||
registerCompactionProvider,
|
||||
} from "./compaction-provider.js";
|
||||
import { PI_EMBEDDED_EXTENSION_RUNTIME_ID } from "./embedded-extension-factory.js";
|
||||
import { normalizePluginHttpPath } from "./http-path.js";
|
||||
import { findOverlappingPluginHttpRoute } from "./http-route-overlap.js";
|
||||
import {
|
||||
@@ -229,69 +227,6 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
registry.diagnostics.push(diag);
|
||||
};
|
||||
|
||||
const registerPiEmbeddedExtensionFactory = (
|
||||
record: PluginRecord,
|
||||
factory: Parameters<OpenClawPluginApi["registerEmbeddedExtensionFactory"]>[0],
|
||||
) => {
|
||||
if (record.origin !== "bundled") {
|
||||
pushDiagnostic({
|
||||
level: "error",
|
||||
pluginId: record.id,
|
||||
source: record.source,
|
||||
message: "only bundled plugins can register Pi embedded extension factories",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (
|
||||
!(record.contracts?.embeddedExtensionFactories ?? []).includes(
|
||||
PI_EMBEDDED_EXTENSION_RUNTIME_ID,
|
||||
)
|
||||
) {
|
||||
pushDiagnostic({
|
||||
level: "error",
|
||||
pluginId: record.id,
|
||||
source: record.source,
|
||||
message:
|
||||
'plugin must declare contracts.embeddedExtensionFactories: ["pi"] to register Pi embedded extension factories',
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (typeof (factory as unknown) !== "function") {
|
||||
pushDiagnostic({
|
||||
level: "error",
|
||||
pluginId: record.id,
|
||||
source: record.source,
|
||||
message: "embedded extension factory must be a function",
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (
|
||||
registry.embeddedExtensionFactories.some(
|
||||
(entry) => entry.pluginId === record.id && entry.rawFactory === factory,
|
||||
)
|
||||
) {
|
||||
return;
|
||||
}
|
||||
const safeFactory: ExtensionFactory = async (pi) => {
|
||||
try {
|
||||
await factory(pi);
|
||||
} catch (error) {
|
||||
const detail = error instanceof Error ? error.message : String(error);
|
||||
registryParams.logger.warn(
|
||||
`[plugins] embedded extension factory failed for ${record.id}: ${detail}`,
|
||||
);
|
||||
}
|
||||
};
|
||||
registry.embeddedExtensionFactories.push({
|
||||
pluginId: record.id,
|
||||
pluginName: record.name,
|
||||
rawFactory: factory,
|
||||
factory: safeFactory,
|
||||
source: record.source,
|
||||
rootDir: record.rootDir,
|
||||
});
|
||||
};
|
||||
|
||||
const registerCodexAppServerExtensionFactory = (
|
||||
record: PluginRecord,
|
||||
factory: Parameters<OpenClawPluginApi["registerCodexAppServerExtensionFactory"]>[0],
|
||||
@@ -1585,9 +1520,6 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
|
||||
}
|
||||
registerCompactionProvider(provider, { ownerPluginId: record.id });
|
||||
},
|
||||
registerEmbeddedExtensionFactory: (factory) => {
|
||||
registerPiEmbeddedExtensionFactory(record, factory);
|
||||
},
|
||||
registerCodexAppServerExtensionFactory: (factory) => {
|
||||
registerCodexAppServerExtensionFactory(record, factory);
|
||||
},
|
||||
|
||||
@@ -129,7 +129,6 @@ export function createPluginLoadResult(
|
||||
musicGenerationProviders: [],
|
||||
webFetchProviders: [],
|
||||
webSearchProviders: [],
|
||||
embeddedExtensionFactories: [],
|
||||
codexAppServerExtensionFactories: [],
|
||||
agentToolResultMiddlewares: [],
|
||||
memoryEmbeddingProviders: [],
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { IncomingMessage, ServerResponse } from "node:http";
|
||||
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
||||
import type { StreamFn } from "@mariozechner/pi-agent-core";
|
||||
import type { ExtensionFactory, ModelRegistry } from "@mariozechner/pi-coding-agent";
|
||||
import type { ModelRegistry } from "@mariozechner/pi-coding-agent";
|
||||
import type { Command } from "commander";
|
||||
import type {
|
||||
ApiKeyCredential,
|
||||
@@ -2152,16 +2152,15 @@ export type OpenClawPluginApi = {
|
||||
/** Register an agent harness implementation. */
|
||||
registerAgentHarness: (harness: AgentHarness) => void;
|
||||
/**
|
||||
* Register a Pi embedded extension factory for OpenClaw embedded runs.
|
||||
*
|
||||
* @deprecated This is a bundled compatibility seam. New tool-result transforms
|
||||
* should use `registerAgentToolResultMiddleware(...)` and declare
|
||||
* `contracts.agentToolResultMiddleware` for the targeted runtimes.
|
||||
* Register a Codex app-server extension factory for Codex harness tool-result
|
||||
* middleware. Only bundled plugins may use this seam, and
|
||||
* `contracts.embeddedExtensionFactories` must include `"codex-app-server"`.
|
||||
*/
|
||||
registerEmbeddedExtensionFactory: (factory: ExtensionFactory) => void;
|
||||
/** Register a Codex app-server extension factory for Codex harness tool-result middleware. Only bundled plugins may use this seam, and `contracts.embeddedExtensionFactories` must include `"codex-app-server"`. */
|
||||
registerCodexAppServerExtensionFactory: (factory: CodexAppServerExtensionFactory) => void;
|
||||
/** Register runtime-neutral tool-result middleware. Declare `contracts.agentToolResultMiddleware` for every targeted runtime. */
|
||||
/**
|
||||
* Register runtime-neutral tool-result middleware. Declare
|
||||
* `contracts.agentToolResultMiddleware` for every targeted runtime.
|
||||
*/
|
||||
registerAgentToolResultMiddleware: (
|
||||
handler: AgentToolResultMiddleware,
|
||||
options?: AgentToolResultMiddlewareOptions,
|
||||
|
||||
Reference in New Issue
Block a user