From e794417623b56e6da67233ba1cce0076fa8de7da Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Sat, 14 Mar 2026 00:51:01 +0000 Subject: [PATCH] fix: resolve current ci regressions --- .../pi-embedded-runner/compact.hooks.test.ts | 2 +- src/commands/models/list.probe.ts | 3 ++- src/daemon/service-audit.test.ts | 2 +- src/infra/channel-summary.test.ts | 7 ++++--- src/infra/heartbeat-runner.scheduler.test.ts | 6 ++++-- src/infra/outbound/deliver.test.ts | 3 ++- src/line/bot-handlers.test.ts | 15 ++++++++------- src/media/fetch.telegram-network.test.ts | 10 +++++----- src/plugins/test-helpers/fs-fixtures.ts | 5 ++--- src/telegram/draft-stream.test.ts | 2 +- 10 files changed, 30 insertions(+), 25 deletions(-) diff --git a/src/agents/pi-embedded-runner/compact.hooks.test.ts b/src/agents/pi-embedded-runner/compact.hooks.test.ts index 4e1f1cd3799..af7cfd7e1bf 100644 --- a/src/agents/pi-embedded-runner/compact.hooks.test.ts +++ b/src/agents/pi-embedded-runner/compact.hooks.test.ts @@ -372,7 +372,7 @@ function wrappedCompactionArgs(overrides: Record = {}) { sessionFile: TEST_SESSION_FILE, workspaceDir: TEST_WORKSPACE_DIR, customInstructions: TEST_CUSTOM_INSTRUCTIONS, - enqueue: (task: () => unknown) => task(), + enqueue: async (task: () => Promise | T) => await task(), ...overrides, }; } diff --git a/src/commands/models/list.probe.ts b/src/commands/models/list.probe.ts index 91418c5a1c2..7b75d1be726 100644 --- a/src/commands/models/list.probe.ts +++ b/src/commands/models/list.probe.ts @@ -431,6 +431,7 @@ async function probeTarget(params: { error: "No model available for probe", }; } + const model = target.model; const sessionId = `probe-${target.provider}-${crypto.randomUUID()}`; const sessionFile = resolveSessionTranscriptPath(sessionId, agentId); @@ -439,7 +440,7 @@ async function probeTarget(params: { const start = Date.now(); const buildResult = (status: AuthProbeResult["status"], error?: string): AuthProbeResult => ({ provider: target.provider, - model: `${target.model.provider}/${target.model.model}`, + model: `${model.provider}/${model.model}`, profileId: target.profileId, label: target.label, source: target.source, diff --git a/src/daemon/service-audit.test.ts b/src/daemon/service-audit.test.ts index 505f8f97d7d..f7e87b6a518 100644 --- a/src/daemon/service-audit.test.ts +++ b/src/daemon/service-audit.test.ts @@ -22,7 +22,7 @@ function createGatewayAudit({ expectedGatewayToken?: string; path?: string; serviceToken?: string; - environmentValueSources?: Record; + environmentValueSources?: Record; } = {}) { return auditGatewayServiceConfig({ env: { HOME: "/tmp" }, diff --git a/src/infra/channel-summary.test.ts b/src/infra/channel-summary.test.ts index e2db1dffc5a..c0fc17ba255 100644 --- a/src/infra/channel-summary.test.ts +++ b/src/infra/channel-summary.test.ts @@ -179,6 +179,7 @@ function makeFallbackSummaryPlugin(params: { id: "fallback-plugin", meta: { id: "fallback-plugin", + label: "Fallback", selectionLabel: "Fallback", docsPath: "/channels/fallback", blurb: "test", @@ -289,7 +290,7 @@ describe("buildChannelSummary", () => { ]); }); - it("falls back to plugin id and default account id when no label or accounts exist", async () => { + it("uses the channel label and default account id when no accounts exist", async () => { vi.mocked(listChannelPlugins).mockReturnValue([ makeFallbackSummaryPlugin({ enabled: true, @@ -304,7 +305,7 @@ describe("buildChannelSummary", () => { includeAllowFrom: false, }); - expect(lines).toEqual(["fallback-plugin: configured", " - fallback-account"]); + expect(lines).toEqual(["Fallback: configured", " - fallback-account"]); }); it("shows not-configured status when enabled accounts exist without configured ones", async () => { @@ -321,6 +322,6 @@ describe("buildChannelSummary", () => { includeAllowFrom: false, }); - expect(lines).toEqual(["fallback-plugin: not configured"]); + expect(lines).toEqual(["Fallback: not configured"]); }); }); diff --git a/src/infra/heartbeat-runner.scheduler.test.ts b/src/infra/heartbeat-runner.scheduler.test.ts index b75fa195d03..10313dc33ad 100644 --- a/src/infra/heartbeat-runner.scheduler.test.ts +++ b/src/infra/heartbeat-runner.scheduler.test.ts @@ -4,12 +4,14 @@ import { startHeartbeatRunner } from "./heartbeat-runner.js"; import { requestHeartbeatNow, resetHeartbeatWakeStateForTests } from "./heartbeat-wake.js"; describe("startHeartbeatRunner", () => { + type RunOnce = Parameters[0]["runOnce"]; + function useFakeHeartbeatTime() { vi.useFakeTimers(); vi.setSystemTime(new Date(0)); } - function startDefaultRunner(runOnce: Parameters[0]["runOnce"]) { + function startDefaultRunner(runOnce: RunOnce) { return startHeartbeatRunner({ cfg: heartbeatConfig(), runOnce, @@ -40,7 +42,7 @@ describe("startHeartbeatRunner", () => { async function expectWakeDispatch(params: { cfg: OpenClawConfig; - runSpy: ReturnType; + runSpy: RunOnce; wake: { reason: string; agentId?: string; sessionKey?: string; coalesceMs: number }; expectedCall: Record; }) { diff --git a/src/infra/outbound/deliver.test.ts b/src/infra/outbound/deliver.test.ts index 9fba810da10..572046cfcc1 100644 --- a/src/infra/outbound/deliver.test.ts +++ b/src/infra/outbound/deliver.test.ts @@ -3,6 +3,7 @@ import { afterEach, beforeEach, describe, expect, it, vi } from "vitest"; import { signalOutbound } from "../../channels/plugins/outbound/signal.js"; import { telegramOutbound } from "../../channels/plugins/outbound/telegram.js"; import { whatsappOutbound } from "../../channels/plugins/outbound/whatsapp.js"; +import type { ChannelOutboundAdapter } from "../../channels/plugins/types.adapters.js"; import type { OpenClawConfig } from "../../config/config.js"; import { STATE_DIR } from "../../config/paths.js"; import { setActivePluginRegistry } from "../../plugins/runtime.js"; @@ -83,7 +84,7 @@ type DeliverOutboundArgs = Parameters[0]; type DeliverOutboundPayload = DeliverOutboundArgs["payloads"][number]; type DeliverSession = DeliverOutboundArgs["session"]; -function setMatrixTextOnlyPlugin(sendText: ReturnType) { +function setMatrixTextOnlyPlugin(sendText: NonNullable) { setActivePluginRegistry( createTestRegistry([ { diff --git a/src/line/bot-handlers.test.ts b/src/line/bot-handlers.test.ts index f1dc1965407..21d54c41f0d 100644 --- a/src/line/bot-handlers.test.ts +++ b/src/line/bot-handlers.test.ts @@ -1,5 +1,6 @@ import type { MessageEvent, PostbackEvent } from "@line/bot-sdk"; import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest"; +import type { LineAccountConfig } from "./types.js"; // Avoid pulling in globals/pairing/media dependencies; this suite only asserts // allowlist/groupPolicy gating and message-context wiring. @@ -79,7 +80,7 @@ function createReplayMessageEvent(params: { }) { return { type: "message", - message: { id: params.messageId, type: "text", text: "hello" }, + message: { id: params.messageId, type: "text", text: "hello", quoteToken: "quote-token" }, replyToken: "reply-token", timestamp: Date.now(), source: { type: "group", groupId: params.groupId, userId: params.userId }, @@ -111,8 +112,8 @@ function createTestMessageEvent(params: { function createLineWebhookTestContext(params: { processMessage: LineWebhookContext["processMessage"]; - groupPolicy?: "open"; - dmPolicy?: "open"; + groupPolicy?: LineAccountConfig["groupPolicy"]; + dmPolicy?: LineAccountConfig["dmPolicy"]; requireMention?: boolean; groupHistories?: Map; replayCache?: ReturnType; @@ -157,7 +158,7 @@ function createOpenGroupReplayContext( } async function expectGroupMessageBlocked(params: { - processMessage: ReturnType; + processMessage: LineWebhookContext["processMessage"]; event: MessageEvent; context: Parameters[1]; }) { @@ -182,7 +183,7 @@ async function expectRequireMentionGroupMessageProcessed(event: MessageEvent) { async function startInflightReplayDuplicate(params: { event: MessageEvent; - processMessage: ReturnType; + processMessage: LineWebhookContext["processMessage"]; }) { const context = createOpenGroupReplayContext( params.processMessage, @@ -248,7 +249,7 @@ describe("handleLineWebhookEvents", () => { await expectGroupMessageBlocked({ processMessage, event: createTestMessageEvent({ - message: { id: "m2", type: "text", text: "hi" }, + message: { id: "m2", type: "text", text: "hi", quoteToken: "quote-token" }, source: { type: "group", groupId: "group-1", userId: "user-2" }, webhookEventId: "evt-2", }), @@ -373,7 +374,7 @@ describe("handleLineWebhookEvents", () => { await expectGroupMessageBlocked({ processMessage, event: createTestMessageEvent({ - message: { id: "m5b", type: "text", text: "hi" }, + message: { id: "m5b", type: "text", text: "hi", quoteToken: "quote-token" }, source: { type: "group", groupId: "group-1", userId: "user-5" }, webhookEventId: "evt-5b", }), diff --git a/src/media/fetch.telegram-network.test.ts b/src/media/fetch.telegram-network.test.ts index 2fbb09e1115..5dbda7bc019 100644 --- a/src/media/fetch.telegram-network.test.ts +++ b/src/media/fetch.telegram-network.test.ts @@ -139,7 +139,7 @@ describe("fetchRemoteMedia telegram network policy", () => { { address: "149.154.167.220", family: 4 }, { address: "2001:67c:4e8:f004::9", family: 6 }, ]) as unknown as LookupFn; - undiciFetch + undiciMocks.fetch .mockRejectedValueOnce(createTelegramFetchFailedError("EHOSTUNREACH")) .mockResolvedValueOnce( new Response(new Uint8Array([0xff, 0xd8, 0xff, 0x00]), { @@ -169,7 +169,7 @@ describe("fetchRemoteMedia telegram network policy", () => { }, }); - const firstInit = undiciFetch.mock.calls[0]?.[1] as + const firstInit = undiciMocks.fetch.mock.calls[0]?.[1] as | (RequestInit & { dispatcher?: { options?: { @@ -178,7 +178,7 @@ describe("fetchRemoteMedia telegram network policy", () => { }; }) | undefined; - const secondInit = undiciFetch.mock.calls[1]?.[1] as + const secondInit = undiciMocks.fetch.mock.calls[1]?.[1] as | (RequestInit & { dispatcher?: { options?: { @@ -188,7 +188,7 @@ describe("fetchRemoteMedia telegram network policy", () => { }) | undefined; - expect(undiciFetch).toHaveBeenCalledTimes(2); + expect(undiciMocks.fetch).toHaveBeenCalledTimes(2); expect(firstInit?.dispatcher?.options?.connect).toEqual( expect.objectContaining({ autoSelectFamily: true, @@ -212,7 +212,7 @@ describe("fetchRemoteMedia telegram network policy", () => { ]) as unknown as LookupFn; const primaryError = createTelegramFetchFailedError("EHOSTUNREACH"); const fallbackError = createTelegramFetchFailedError("ETIMEDOUT"); - undiciFetch.mockRejectedValueOnce(primaryError).mockRejectedValueOnce(fallbackError); + undiciMocks.fetch.mockRejectedValueOnce(primaryError).mockRejectedValueOnce(fallbackError); const telegramTransport = resolveTelegramTransport(undefined, { network: { diff --git a/src/plugins/test-helpers/fs-fixtures.ts b/src/plugins/test-helpers/fs-fixtures.ts index ec6b88fa4e4..4c65d0662fd 100644 --- a/src/plugins/test-helpers/fs-fixtures.ts +++ b/src/plugins/test-helpers/fs-fixtures.ts @@ -1,4 +1,3 @@ -import { randomUUID } from "node:crypto"; import fs from "node:fs"; import os from "node:os"; import path from "node:path"; @@ -16,8 +15,8 @@ export function mkdirSafeDir(dir: string) { } export function makeTrackedTempDir(prefix: string, trackedDirs: string[]) { - const dir = path.join(os.tmpdir(), `${prefix}-${randomUUID()}`); - mkdirSafeDir(dir); + const dir = fs.mkdtempSync(path.join(os.tmpdir(), String(prefix) + "-")); + chmodSafeDir(dir); trackedDirs.push(dir); return dir; } diff --git a/src/telegram/draft-stream.test.ts b/src/telegram/draft-stream.test.ts index 9d6888d2755..7fe7a1713cb 100644 --- a/src/telegram/draft-stream.test.ts +++ b/src/telegram/draft-stream.test.ts @@ -56,7 +56,7 @@ function expectDmMessagePreviewViaSendMessage( async function createDmDraftTransportStream(params: { api?: ReturnType; previewTransport?: "draft" | "message"; - warn?: ReturnType; + warn?: (message: string) => void; }) { const api = params.api ?? createMockDraftApi(); const stream = createDraftStream(api, {