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
6 changed files with 53 additions and 14 deletions

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