fix: restore helper imports and plugin hook test exports

This commit is contained in:
Peter Steinberger
2026-03-02 19:54:47 +00:00
parent 7003615972
commit 4b50018406
3 changed files with 29 additions and 2 deletions

View File

@@ -2,7 +2,7 @@ import { type Context, complete } from "@mariozechner/pi-ai";
import { Type } from "@sinclair/typebox"; import { Type } from "@sinclair/typebox";
import type { OpenClawConfig } from "../../config/config.js"; import type { OpenClawConfig } from "../../config/config.js";
import { resolveUserPath } from "../../utils.js"; import { resolveUserPath } from "../../utils.js";
import { loadWebMedia } from "../../web/media.js"; import { getDefaultLocalRoots, loadWebMedia } from "../../web/media.js";
import { minimaxUnderstandImage } from "../minimax-vlm.js"; import { minimaxUnderstandImage } from "../minimax-vlm.js";
import { import {
coerceImageAssistantText, coerceImageAssistantText,
@@ -24,6 +24,7 @@ import {
discoverAuthStorage, discoverAuthStorage,
discoverModels, discoverModels,
ensureOpenClawModelsJson, ensureOpenClawModelsJson,
normalizeWorkspaceDir,
resolveSandboxedBridgeMediaPath, resolveSandboxedBridgeMediaPath,
runWithImageModelFallback, runWithImageModelFallback,
type AnyAgentTool, type AnyAgentTool,

View File

@@ -3,7 +3,7 @@ import { Type } from "@sinclair/typebox";
import type { OpenClawConfig } from "../../config/config.js"; import type { OpenClawConfig } from "../../config/config.js";
import { extractPdfContent, type PdfExtractedContent } from "../../media/pdf-extract.js"; import { extractPdfContent, type PdfExtractedContent } from "../../media/pdf-extract.js";
import { resolveUserPath } from "../../utils.js"; import { resolveUserPath } from "../../utils.js";
import { loadWebMediaRaw } from "../../web/media.js"; import { getDefaultLocalRoots, loadWebMediaRaw } from "../../web/media.js";
import { import {
coerceImageModelConfig, coerceImageModelConfig,
type ImageModelConfig, type ImageModelConfig,
@@ -30,6 +30,7 @@ import {
discoverAuthStorage, discoverAuthStorage,
discoverModels, discoverModels,
ensureOpenClawModelsJson, ensureOpenClawModelsJson,
normalizeWorkspaceDir,
resolveSandboxedBridgeMediaPath, resolveSandboxedBridgeMediaPath,
runWithImageModelFallback, runWithImageModelFallback,
type AnyAgentTool, type AnyAgentTool,

View File

@@ -1,4 +1,5 @@
import type { PluginRegistry } from "./registry.js"; import type { PluginRegistry } from "./registry.js";
import type { PluginHookAgentContext, PluginHookRegistration } from "./types.js";
export function createMockPluginRegistry( export function createMockPluginRegistry(
hooks: Array<{ hookName: string; handler: (...args: unknown[]) => unknown }>, hooks: Array<{ hookName: string; handler: (...args: unknown[]) => unknown }>,
@@ -22,3 +23,27 @@ export function createMockPluginRegistry(
commands: [], commands: [],
} as unknown as PluginRegistry; } as unknown as PluginRegistry;
} }
export const TEST_PLUGIN_AGENT_CTX: PluginHookAgentContext = {
agentId: "test-agent",
sessionKey: "test-session",
sessionId: "test-session-id",
workspaceDir: "/tmp/openclaw-test",
messageProvider: "test",
};
export function addTestHook(params: {
registry: PluginRegistry;
pluginId: string;
hookName: PluginHookRegistration["hookName"];
handler: PluginHookRegistration["handler"];
priority?: number;
}) {
params.registry.typedHooks.push({
pluginId: params.pluginId,
hookName: params.hookName,
handler: params.handler,
priority: params.priority ?? 0,
source: "test",
} as PluginHookRegistration);
}