From eb8f0e1bf2430437eed399b7cb93022a71a9b143 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sun, 5 Apr 2026 15:44:16 +0100 Subject: [PATCH] fix(ci): restore plugin sdk exports and ACP typing --- extensions/anthropic/index.test.ts | 5 ++-- package.json | 16 +++++++++++++ scripts/lib/plugin-sdk-entrypoints.json | 2 ++ src/auto-reply/reply/dispatch-acp.runtime.ts | 9 ++++---- .../reply/dispatch-from-config.test.ts | 23 ++++++++++++++++--- src/media-understanding/runtime.test.ts | 12 ++++++---- 6 files changed, 53 insertions(+), 14 deletions(-) diff --git a/extensions/anthropic/index.test.ts b/extensions/anthropic/index.test.ts index 5aa2a73be27..5278ed30861 100644 --- a/extensions/anthropic/index.test.ts +++ b/extensions/anthropic/index.test.ts @@ -1,5 +1,5 @@ +import { capturePluginRegistration } from "openclaw/plugin-sdk/testing"; import { describe, expect, it, vi } from "vitest"; -import { createCapturedPluginRegistration } from "../../src/test-utils/plugin-registration.js"; import { registerSingleProviderPlugin } from "../../test/helpers/plugins/plugin-registration.js"; const { readClaudeCliCredentialsForSetupMock, readClaudeCliCredentialsForRuntimeMock } = vi.hoisted( @@ -20,8 +20,7 @@ import anthropicPlugin from "./index.js"; describe("anthropic provider replay hooks", () => { it("registers the claude-cli backend", async () => { - const captured = createCapturedPluginRegistration(); - await anthropicPlugin.register(captured.api); + const captured = capturePluginRegistration({ register: anthropicPlugin.register }); expect(captured.cliBackends).toContainEqual( expect.objectContaining({ diff --git a/package.json b/package.json index bd90fff8452..425010eb2e3 100644 --- a/package.json +++ b/package.json @@ -67,10 +67,18 @@ "types": "./dist/plugin-sdk/runtime.d.ts", "default": "./dist/plugin-sdk/runtime.js" }, + "./plugin-sdk/runtime-doctor": { + "types": "./dist/plugin-sdk/runtime-doctor.d.ts", + "default": "./dist/plugin-sdk/runtime-doctor.js" + }, "./plugin-sdk/runtime-env": { "types": "./dist/plugin-sdk/runtime-env.d.ts", "default": "./dist/plugin-sdk/runtime-env.js" }, + "./plugin-sdk/runtime-secret-resolution": { + "types": "./dist/plugin-sdk/runtime-secret-resolution.d.ts", + "default": "./dist/plugin-sdk/runtime-secret-resolution.js" + }, "./plugin-sdk/setup": { "types": "./dist/plugin-sdk/setup.d.ts", "default": "./dist/plugin-sdk/setup.js" @@ -279,6 +287,10 @@ "types": "./dist/plugin-sdk/acp-runtime.d.ts", "default": "./dist/plugin-sdk/acp-runtime.js" }, + "./plugin-sdk/acp-binding-runtime": { + "types": "./dist/plugin-sdk/acp-binding-runtime.d.ts", + "default": "./dist/plugin-sdk/acp-binding-runtime.js" + }, "./plugin-sdk/lazy-runtime": { "types": "./dist/plugin-sdk/lazy-runtime.d.ts", "default": "./dist/plugin-sdk/lazy-runtime.js" @@ -503,6 +515,10 @@ "types": "./dist/plugin-sdk/googlechat.d.ts", "default": "./dist/plugin-sdk/googlechat.js" }, + "./plugin-sdk/googlechat-runtime-shared": { + "types": "./dist/plugin-sdk/googlechat-runtime-shared.d.ts", + "default": "./dist/plugin-sdk/googlechat-runtime-shared.js" + }, "./plugin-sdk/image-generation": { "types": "./dist/plugin-sdk/image-generation.d.ts", "default": "./dist/plugin-sdk/image-generation.js" diff --git a/scripts/lib/plugin-sdk-entrypoints.json b/scripts/lib/plugin-sdk-entrypoints.json index 80b69a672d9..46bd1614f4e 100644 --- a/scripts/lib/plugin-sdk-entrypoints.json +++ b/scripts/lib/plugin-sdk-entrypoints.json @@ -61,6 +61,7 @@ "process-runtime", "windows-spawn", "acp-runtime", + "acp-binding-runtime", "lazy-runtime", "testing", "temp-path", @@ -117,6 +118,7 @@ "global-singleton", "directory-runtime", "googlechat", + "googlechat-runtime-shared", "image-generation", "image-generation-core", "video-generation", diff --git a/src/auto-reply/reply/dispatch-acp.runtime.ts b/src/auto-reply/reply/dispatch-acp.runtime.ts index 8600cc18ddf..f87f7a58196 100644 --- a/src/auto-reply/reply/dispatch-acp.runtime.ts +++ b/src/auto-reply/reply/dispatch-acp.runtime.ts @@ -1,5 +1,6 @@ -import type { shouldBypassAcpDispatchForCommand as ShouldBypassAcpDispatchForCommand } from "./dispatch-acp-command-bypass.js"; -import type { tryDispatchAcpReply as TryDispatchAcpReply } from "./dispatch-acp.js"; +type ShouldBypassAcpDispatchForCommand = + (typeof import("./dispatch-acp-command-bypass.js"))["shouldBypassAcpDispatchForCommand"]; +type TryDispatchAcpReply = (typeof import("./dispatch-acp.js"))["tryDispatchAcpReply"]; let dispatchAcpPromise: Promise | null = null; let dispatchAcpCommandBypassPromise: Promise< @@ -18,14 +19,14 @@ function loadDispatchAcpCommandBypass() { export async function shouldBypassAcpDispatchForCommand( ...args: Parameters -): Promise> { +): Promise>> { const mod = await loadDispatchAcpCommandBypass(); return mod.shouldBypassAcpDispatchForCommand(...args); } export async function tryDispatchAcpReply( ...args: Parameters -): ReturnType { +): Promise>> { const mod = await loadDispatchAcp(); return await mod.tryDispatchAcpReply(...args); } diff --git a/src/auto-reply/reply/dispatch-from-config.test.ts b/src/auto-reply/reply/dispatch-from-config.test.ts index 2346d187237..97f9021e36f 100644 --- a/src/auto-reply/reply/dispatch-from-config.test.ts +++ b/src/auto-reply/reply/dispatch-from-config.test.ts @@ -56,8 +56,19 @@ const internalHookMocks = vi.hoisted(() => ({ })); const acpMocks = vi.hoisted(() => ({ listAcpSessionEntries: vi.fn(async () => []), - readAcpSessionEntry: vi.fn<() => unknown>(() => null), - upsertAcpSessionMeta: vi.fn(async () => null), + readAcpSessionEntry: vi.fn<(params: { sessionKey: string; cfg?: OpenClawConfig }) => unknown>( + () => null, + ), + upsertAcpSessionMeta: vi.fn< + (params: { + sessionKey: string; + cfg?: OpenClawConfig; + mutate: ( + current: Record | undefined, + entry: { acp?: Record } | undefined, + ) => Record | null | undefined; + }) => Promise + >(async () => null), requireAcpRuntimeBackend: vi.fn<() => unknown>(), })); const sessionBindingMocks = vi.hoisted(() => ({ @@ -317,7 +328,13 @@ function createAcpRuntime(events: Array>) { runtimeSessionName: `${input.sessionKey}:${input.mode}`, }) as { sessionKey: string; backend: string; runtimeSessionName: string }, ), - runTurn: vi.fn(async function* (_params: { text?: string }) { + runTurn: vi.fn(async function* (_params: { + text?: string; + attachments?: unknown[]; + mode?: string; + requestId?: string; + signal?: AbortSignal; + }) { for (const event of events) { yield event; } diff --git a/src/media-understanding/runtime.test.ts b/src/media-understanding/runtime.test.ts index c6bb1cf2167..e0efc034b4d 100644 --- a/src/media-understanding/runtime.test.ts +++ b/src/media-understanding/runtime.test.ts @@ -1,6 +1,6 @@ import { afterEach, describe, expect, it, vi } from "vitest"; import type { OpenClawConfig } from "../config/config.js"; -import type { MediaUnderstandingOutput } from "../media-understanding/types.js"; +import type { MediaAttachment, MediaUnderstandingOutput } from "../media-understanding/types.js"; import { describeImageFile, runMediaUnderstandingFile } from "./runtime.js"; const mocks = vi.hoisted(() => { @@ -8,7 +8,7 @@ const mocks = vi.hoisted(() => { return { buildProviderRegistry: vi.fn(() => new Map()), createMediaAttachmentCache: vi.fn(() => ({ cleanup })), - normalizeMediaAttachments: vi.fn(() => []), + normalizeMediaAttachments: vi.fn<() => MediaAttachment[]>(() => []), normalizeMediaProviderId: vi.fn((provider: string) => provider.trim().toLowerCase()), runCapability: vi.fn(), cleanup, @@ -35,7 +35,9 @@ describe("media-understanding runtime", () => { }); it("returns disabled state without loading providers", async () => { - mocks.normalizeMediaAttachments.mockReturnValue([{ kind: "image" }]); + mocks.normalizeMediaAttachments.mockReturnValue([ + { index: 0, path: "/tmp/sample.jpg", mime: "image/jpeg" }, + ]); await expect( runMediaUnderstandingFile({ @@ -72,7 +74,9 @@ describe("media-understanding runtime", () => { model: "vision-v1", text: "image ok", }; - mocks.normalizeMediaAttachments.mockReturnValue([{ kind: "image" }]); + mocks.normalizeMediaAttachments.mockReturnValue([ + { index: 0, path: "/tmp/sample.jpg", mime: "image/jpeg" }, + ]); mocks.runCapability.mockResolvedValue({ outputs: [output], });