fix: restore main ci type checks

This commit is contained in:
Peter Steinberger 2026-04-06 05:36:24 +01:00
parent 319217a30d
commit b62badd8a3
No known key found for this signature in database
12 changed files with 51 additions and 35 deletions

View File

@ -23,9 +23,7 @@ export function resolveDiscordDraftStreamingChunking(
const accountCfg = resolveAccountEntry(cfg?.channels?.discord?.accounts, normalizedAccountId);
const draftCfg =
resolveChannelStreamingPreviewChunk(accountCfg) ??
resolveChannelStreamingPreviewChunk(cfg?.channels?.discord) ??
accountCfg?.draftChunk ??
cfg?.channels?.discord?.draftChunk;
resolveChannelStreamingPreviewChunk(cfg?.channels?.discord);
const maxRequested = Math.max(
1,

View File

@ -22,7 +22,17 @@ import { initializeMemoryWikiVault } from "./vault.js";
const READ_SCOPE = "operator.read" as const;
const WRITE_SCOPE = "operator.write" as const;
type GatewayMethodContext = Parameters<
Parameters<OpenClawPluginApi["registerGatewayMethod"]>[1]
>[0];
type GatewayRespond = GatewayMethodContext["respond"];
function readStringParam(params: Record<string, unknown>, key: string): string | undefined;
function readStringParam(
params: Record<string, unknown>,
key: string,
options: { required: true },
): string;
function readStringParam(
params: Record<string, unknown>,
key: string,
@ -67,16 +77,9 @@ function readEnumParam<T extends string>(
throw new Error(`${key} must be one of: ${allowed.join(", ")}.`);
}
function respondError(
respond: Parameters<OpenClawPluginApi["registerGatewayMethod"]>[1] extends (
ctx: infer T,
) => unknown
? T["respond"]
: never,
error: unknown,
) {
function respondError(respond: GatewayRespond, error: unknown) {
const message = error instanceof Error ? error.message : String(error);
respond(false, undefined, { message });
respond(false, undefined, { code: "internal_error", message });
}
async function syncImportedSourcesIfNeeded(

View File

@ -15,12 +15,13 @@ describe("runObsidianSearch", () => {
{ homedir: "/Users/tester" },
);
const calls: Array<{ command: string; argv: string[] }> = [];
const exec: NonNullable<
NonNullable<Parameters<typeof runObsidianSearch>[0]["deps"]>["exec"]
> = async (command, argv) => {
calls.push({ command, argv: [...argv] });
const execImpl = async (command: string, argv?: readonly string[] | null) => {
calls.push({ command, argv: argv ? [...argv] : [] });
return { stdout: "search output\n", stderr: "" };
};
const exec = execImpl as unknown as NonNullable<
NonNullable<Parameters<typeof runObsidianSearch>[0]["deps"]>["exec"]
>;
const result = await runObsidianSearch({
config,

View File

@ -405,7 +405,7 @@ describe("dispatchTelegramMessage draft streaming", () => {
await dispatchWithContext({
context: createContext(),
telegramCfg: { blockStreaming: true },
telegramCfg: { streaming: { block: { enabled: true } } },
});
expect(createTelegramDraftStream).not.toHaveBeenCalled();
@ -655,7 +655,10 @@ describe("dispatchTelegramMessage draft streaming", () => {
it.each([
{ label: "default account config", telegramCfg: {} },
{ label: "account blockStreaming override", telegramCfg: { blockStreaming: true } },
{
label: "account blockStreaming override",
telegramCfg: { streaming: { block: { enabled: true } } },
},
])("disables block streaming when streamMode is off ($label)", async ({ telegramCfg }) => {
dispatchReplyWithBufferedBlockDispatcher.mockImplementation(async ({ dispatcherOptions }) => {
await dispatcherOptions.deliver({ text: "Hello" }, { kind: "final" });

View File

@ -55,10 +55,14 @@ describe("resolveTelegramDraftStreamingChunking", () => {
accounts: {
default: {
allowFrom: ["*"],
draftChunk: {
minChars: 10,
maxChars: 20,
breakPreference: "sentence",
streaming: {
preview: {
chunk: {
minChars: 10,
maxChars: 20,
breakPreference: "sentence",
},
},
},
},
},

View File

@ -23,9 +23,7 @@ export function resolveTelegramDraftStreamingChunking(
const accountCfg = resolveAccountEntry(cfg?.channels?.telegram?.accounts, normalizedAccountId);
const draftCfg =
resolveChannelStreamingPreviewChunk(accountCfg) ??
resolveChannelStreamingPreviewChunk(cfg?.channels?.telegram) ??
accountCfg?.draftChunk ??
cfg?.channels?.telegram?.draftChunk;
resolveChannelStreamingPreviewChunk(cfg?.channels?.telegram);
const maxRequested = Math.max(
1,

View File

@ -110,7 +110,12 @@ function createReplyConfig(streamMode?: "block"): OpenClawConfig {
workspace: "/tmp/workspace",
},
},
channels: { telegram: { allowFrom: ["*"], ...(streamMode ? { streaming: streamMode } : {}) } },
channels: {
telegram: {
allowFrom: ["*"],
...(streamMode ? { streaming: { mode: streamMode } } : {}),
},
},
session: { store: "/tmp/sessions.json" },
};
}

View File

@ -981,7 +981,7 @@ describe("patchChannelConfigForAccount", () => {
botToken: "legacy-token",
allowFrom: ["100"],
groupPolicy: "allowlist",
streaming: "partial",
streaming: { mode: "partial" },
},
},
};
@ -997,7 +997,7 @@ describe("patchChannelConfigForAccount", () => {
botToken: "legacy-token",
allowFrom: ["100"],
groupPolicy: "allowlist",
streaming: "partial",
streaming: { mode: "partial" },
});
expect(next.channels?.telegram?.botToken).toBeUndefined();
expect(next.channels?.telegram?.allowFrom).toBeUndefined();

View File

@ -384,7 +384,7 @@ describe("normalizeCompatibilityConfigValues", () => {
dmPolicy: "allowlist",
allowFrom: ["123"],
groupPolicy: "allowlist",
streaming: "partial",
streaming: { mode: "partial" },
accounts: {
alerts: {
enabled: true,
@ -400,7 +400,7 @@ describe("normalizeCompatibilityConfigValues", () => {
dmPolicy: "allowlist",
allowFrom: ["123"],
groupPolicy: "allowlist",
streaming: "partial",
streaming: { mode: "partial" },
});
expect(res.config.channels?.telegram?.botToken).toBeUndefined();
expect(res.config.channels?.telegram?.dmPolicy).toBeUndefined();

View File

@ -5,8 +5,8 @@ import {
setConfigValueAtPath,
unsetConfigValueAtPath,
} from "./config-paths.js";
import { validateConfigObject } from "./config.js";
import { buildWebSearchProviderConfig } from "./test-helpers.js";
import { readConfigFileSnapshot, validateConfigObject } from "./config.js";
import { buildWebSearchProviderConfig, withTempHome, writeOpenClawConfig } from "./test-helpers.js";
import { OpenClawSchema } from "./zod-schema.js";
describe("$schema key in config (#14998)", () => {

View File

@ -1,4 +1,6 @@
import { describe, expect, it } from "vitest";
import { migrateLegacyConfig } from "../commands/doctor/shared/legacy-config-migrate.js";
import type { OpenClawConfig } from "./config.js";
import { validateConfigObject } from "./validation.js";
function getChannelConfig(config: unknown, provider: string) {
@ -234,7 +236,9 @@ describe("legacy config detection", () => {
{
name: "streamMode with streaming boolean",
input: { channels: { discord: { streaming: false, streamMode: "block" } } },
expectedChanges: ["Moved channels.discord.streamMode → channels.discord.streaming.mode (block)."],
expectedChanges: [
"Moved channels.discord.streamMode → channels.discord.streaming.mode (block).",
],
expectedStreaming: "block",
},
] as const)(

View File

@ -1,5 +1,5 @@
import { mkdtempSync } from "node:fs";
import { mkdtemp, rm, type RmOptions } from "node:fs/promises";
import { mkdtempSync, type RmOptions } from "node:fs";
import { mkdtemp, rm } from "node:fs/promises";
import { tmpdir } from "node:os";
import path from "node:path";
import { afterEach } from "vitest";