mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-10 01:33:29 +00:00
chore(tsgo/lint): fix CI errors
This commit is contained in:
@@ -227,7 +227,7 @@ function createTelegramOutboundPlugin() {
|
||||
};
|
||||
to: string;
|
||||
text: string;
|
||||
accountId?: string;
|
||||
accountId?: string | null;
|
||||
mediaUrl?: string;
|
||||
},
|
||||
mediaUrl?: string,
|
||||
|
||||
@@ -22,23 +22,25 @@ export function setDefaultChannelPluginRegistryForTests(): void {
|
||||
setActivePluginRegistry(createTestRegistry(channels));
|
||||
}
|
||||
|
||||
export function patchChannelOnboardingAdapter<K extends keyof ChannelOnboardingAdapter>(
|
||||
export function patchChannelOnboardingAdapter(
|
||||
channel: ChannelChoice,
|
||||
patch: Pick<ChannelOnboardingAdapter, K>,
|
||||
patch: Partial<ChannelOnboardingAdapter>,
|
||||
): () => void {
|
||||
const adapter = getChannelOnboardingAdapter(channel);
|
||||
if (!adapter) {
|
||||
throw new Error(`missing onboarding adapter for ${channel}`);
|
||||
}
|
||||
const keys = Object.keys(patch) as K[];
|
||||
const previous = {} as Pick<ChannelOnboardingAdapter, K>;
|
||||
const keys = Object.keys(patch);
|
||||
const adapterRecord = adapter as unknown as Record<string, unknown>;
|
||||
const patchRecord = patch as Record<string, unknown>;
|
||||
const previous = new Map<string, unknown>();
|
||||
for (const key of keys) {
|
||||
previous[key] = adapter[key];
|
||||
adapter[key] = patch[key];
|
||||
previous.set(key, adapterRecord[key]);
|
||||
adapterRecord[key] = patchRecord[key];
|
||||
}
|
||||
return () => {
|
||||
for (const key of keys) {
|
||||
adapter[key] = previous[key];
|
||||
adapterRecord[key] = previous.get(key);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
import type { ChannelOnboardingAdapter } from "../channels/plugins/onboarding-types.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import { createEmptyPluginRegistry } from "../plugins/registry.js";
|
||||
import { setActivePluginRegistry } from "../plugins/runtime.js";
|
||||
@@ -82,14 +83,17 @@ function createTelegramCfg(botToken: string, enabled?: boolean): OpenClawConfig
|
||||
} as OpenClawConfig;
|
||||
}
|
||||
|
||||
function patchTelegramAdapter(overrides: Parameters<typeof patchChannelOnboardingAdapter>[1]) {
|
||||
return patchChannelOnboardingAdapter("telegram", {
|
||||
getStatus: vi.fn(async ({ cfg }: { cfg: OpenClawConfig }) => ({
|
||||
function patchTelegramAdapter(overrides: Partial<ChannelOnboardingAdapter>) {
|
||||
const getStatus =
|
||||
overrides.getStatus ??
|
||||
vi.fn(async ({ cfg }: { cfg: OpenClawConfig }) => ({
|
||||
channel: "telegram",
|
||||
configured: Boolean(cfg.channels?.telegram?.botToken),
|
||||
statusLines: [],
|
||||
})),
|
||||
}));
|
||||
return patchChannelOnboardingAdapter("telegram", {
|
||||
...overrides,
|
||||
getStatus,
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { CONTEXT_WINDOW_HARD_MIN_TOKENS } from "../agents/context-window-guard.js";
|
||||
import type { OpenClawConfig } from "../config/config.js";
|
||||
import type { ModelProviderConfig } from "../config/types.models.js";
|
||||
import { defaultRuntime } from "../runtime.js";
|
||||
import {
|
||||
applyCustomApiConfig,
|
||||
@@ -76,28 +78,29 @@ function expectOpenAiCompatResult(params: {
|
||||
expect(params.result.config.models?.providers?.custom?.api).toBe("openai-completions");
|
||||
}
|
||||
|
||||
function buildCustomProviderConfig(contextWindow?: number) {
|
||||
function buildCustomProviderConfig(contextWindow?: number): OpenClawConfig {
|
||||
if (contextWindow === undefined) {
|
||||
return {};
|
||||
}
|
||||
const customProvider = {
|
||||
api: "openai-completions",
|
||||
baseUrl: "https://llm.example.com/v1",
|
||||
models: [
|
||||
{
|
||||
id: "foo-large",
|
||||
name: "foo-large",
|
||||
contextWindow,
|
||||
maxTokens: contextWindow > CONTEXT_WINDOW_HARD_MIN_TOKENS ? 4096 : 1024,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
reasoning: false,
|
||||
},
|
||||
],
|
||||
} satisfies ModelProviderConfig;
|
||||
return {
|
||||
models: {
|
||||
providers: {
|
||||
custom: {
|
||||
api: "openai-completions",
|
||||
baseUrl: "https://llm.example.com/v1",
|
||||
models: [
|
||||
{
|
||||
id: "foo-large",
|
||||
name: "foo-large",
|
||||
contextWindow,
|
||||
maxTokens: contextWindow > CONTEXT_WINDOW_HARD_MIN_TOKENS ? 4096 : 1024,
|
||||
input: ["text"],
|
||||
cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0 },
|
||||
reasoning: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
custom: customProvider,
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user