fix(ci): restore plugin sdk exports and ACP typing

This commit is contained in:
Peter Steinberger 2026-04-05 15:44:16 +01:00
parent 575371b6f7
commit eb8f0e1bf2
No known key found for this signature in database
6 changed files with 53 additions and 14 deletions

View File

@ -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({

View File

@ -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"

View File

@ -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",

View File

@ -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<typeof import("./dispatch-acp.js")> | null = null;
let dispatchAcpCommandBypassPromise: Promise<
@ -18,14 +19,14 @@ function loadDispatchAcpCommandBypass() {
export async function shouldBypassAcpDispatchForCommand(
...args: Parameters<ShouldBypassAcpDispatchForCommand>
): Promise<ReturnType<ShouldBypassAcpDispatchForCommand>> {
): Promise<Awaited<ReturnType<ShouldBypassAcpDispatchForCommand>>> {
const mod = await loadDispatchAcpCommandBypass();
return mod.shouldBypassAcpDispatchForCommand(...args);
}
export async function tryDispatchAcpReply(
...args: Parameters<TryDispatchAcpReply>
): ReturnType<TryDispatchAcpReply> {
): Promise<Awaited<ReturnType<TryDispatchAcpReply>>> {
const mod = await loadDispatchAcp();
return await mod.tryDispatchAcpReply(...args);
}

View File

@ -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<string, unknown> | undefined,
entry: { acp?: Record<string, unknown> } | undefined,
) => Record<string, unknown> | null | undefined;
}) => Promise<unknown>
>(async () => null),
requireAcpRuntimeBackend: vi.fn<() => unknown>(),
}));
const sessionBindingMocks = vi.hoisted(() => ({
@ -317,7 +328,13 @@ function createAcpRuntime(events: Array<Record<string, unknown>>) {
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;
}

View File

@ -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],
});