mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 06:30:42 +00:00
refactor: prune unused extension internals
This commit is contained in:
@@ -23,7 +23,6 @@ type HarnessState = {
|
||||
attachOnly?: boolean;
|
||||
}
|
||||
>;
|
||||
createTargetId: string | null;
|
||||
prevGatewayPort: string | undefined;
|
||||
prevGatewayToken: string | undefined;
|
||||
prevGatewayPassword: string | undefined;
|
||||
@@ -37,7 +36,6 @@ const state: HarnessState = {
|
||||
cfgEvaluateEnabled: true,
|
||||
cfgDefaultProfile: "openclaw",
|
||||
cfgProfiles: {},
|
||||
createTargetId: null,
|
||||
prevGatewayPort: undefined,
|
||||
prevGatewayToken: undefined,
|
||||
prevGatewayPassword: undefined,
|
||||
@@ -59,14 +57,6 @@ export function restoreGatewayPortEnv(prevGatewayPort: string | undefined): void
|
||||
process.env.OPENCLAW_GATEWAY_PORT = prevGatewayPort;
|
||||
}
|
||||
|
||||
export function setBrowserControlServerCreateTargetId(targetId: string | null): void {
|
||||
state.createTargetId = targetId;
|
||||
}
|
||||
|
||||
export function setBrowserControlServerAttachOnly(attachOnly: boolean): void {
|
||||
state.cfgAttachOnly = attachOnly;
|
||||
}
|
||||
|
||||
export function setBrowserControlServerEvaluateEnabled(enabled: boolean): void {
|
||||
state.cfgEvaluateEnabled = enabled;
|
||||
}
|
||||
@@ -360,10 +350,6 @@ const chromeMcpMocks = vi.hoisted(() => ({
|
||||
uploadChromeMcpFile: vi.fn(async () => {}),
|
||||
}));
|
||||
|
||||
export function getChromeMcpMocks(): Record<string, MockFn> {
|
||||
return chromeMcpMocks as unknown as Record<string, MockFn>;
|
||||
}
|
||||
|
||||
const chromeUserDataDir = vi.hoisted(() => ({ dir: "/tmp/openclaw" }));
|
||||
installChromeUserDataDirHooks(chromeUserDataDir);
|
||||
|
||||
@@ -435,10 +421,6 @@ vi.mock("../config/config.js", async () => {
|
||||
|
||||
const launchCalls = vi.hoisted(() => [] as Array<{ port: number }>);
|
||||
|
||||
export function getLaunchCalls() {
|
||||
return launchCalls;
|
||||
}
|
||||
|
||||
vi.mock("./chrome.js", () => ({
|
||||
isChromeCdpReady: vi.fn(async () => state.reachable),
|
||||
isChromeReachable: vi.fn(async () => state.reachable),
|
||||
@@ -535,7 +517,6 @@ export async function resetBrowserControlServerTestContext(): Promise<void> {
|
||||
state.cfgEvaluateEnabled = true;
|
||||
state.cfgDefaultProfile = "openclaw";
|
||||
state.cfgProfiles = defaultProfilesForState(state.testPort);
|
||||
state.createTargetId = null;
|
||||
|
||||
mockClearAll(pwMocks);
|
||||
mockClearAll(cdpMocks);
|
||||
@@ -583,9 +564,6 @@ export function installBrowserControlServerHooks() {
|
||||
beforeEach(async () => {
|
||||
vi.useRealTimers();
|
||||
cdpMocks.createTargetViaCdp.mockImplementation(async () => {
|
||||
if (state.createTargetId) {
|
||||
return { targetId: state.createTargetId };
|
||||
}
|
||||
throw new Error("cdp disabled");
|
||||
});
|
||||
|
||||
|
||||
@@ -21,8 +21,6 @@ import {
|
||||
normalizeTarget as coreNormalizeTarget,
|
||||
looksLikeQQBotTarget,
|
||||
} from "./engine/messaging/target-parser.js";
|
||||
// Re-export text helpers from core/.
|
||||
export { chunkText, TEXT_CHUNK_LIMIT } from "./engine/utils/text-chunk.js";
|
||||
import type { ResolvedQQBotAccount } from "./types.js";
|
||||
|
||||
// Shared promise so concurrent multi-account startups serialize the dynamic
|
||||
|
||||
@@ -14,33 +14,11 @@ import {
|
||||
postJsonRequest,
|
||||
resolveProviderHttpRequestConfig,
|
||||
} from "openclaw/plugin-sdk/provider-http";
|
||||
import { QWEN_STANDARD_CN_BASE_URL, QWEN_STANDARD_GLOBAL_BASE_URL } from "./models.js";
|
||||
import { QWEN_STANDARD_GLOBAL_BASE_URL } from "./models.js";
|
||||
|
||||
const DEFAULT_QWEN_VIDEO_MODEL = "qwen-vl-max-latest";
|
||||
const DEFAULT_QWEN_VIDEO_PROMPT = "Describe the video in detail.";
|
||||
|
||||
function resolveQwenStandardBaseUrl(
|
||||
cfg: { models?: { providers?: Record<string, { baseUrl?: string } | undefined> } } | undefined,
|
||||
providerId: string,
|
||||
): string {
|
||||
const direct = cfg?.models?.providers?.[providerId]?.baseUrl?.trim();
|
||||
if (!direct) {
|
||||
return QWEN_STANDARD_GLOBAL_BASE_URL;
|
||||
}
|
||||
try {
|
||||
const url = new URL(direct);
|
||||
if (url.hostname === "coding-intl.dashscope.aliyuncs.com") {
|
||||
return QWEN_STANDARD_GLOBAL_BASE_URL;
|
||||
}
|
||||
if (url.hostname === "coding.dashscope.aliyuncs.com") {
|
||||
return QWEN_STANDARD_CN_BASE_URL;
|
||||
}
|
||||
return `${url.origin}${url.pathname}`.replace(/\/+$/u, "");
|
||||
} catch {
|
||||
return QWEN_STANDARD_GLOBAL_BASE_URL;
|
||||
}
|
||||
}
|
||||
|
||||
export async function describeQwenVideo(
|
||||
params: VideoDescriptionRequest,
|
||||
): Promise<VideoDescriptionResult> {
|
||||
@@ -108,9 +86,3 @@ export function buildQwenMediaUnderstandingProvider(): MediaUnderstandingProvide
|
||||
describeVideo: describeQwenVideo,
|
||||
};
|
||||
}
|
||||
|
||||
export function resolveQwenMediaUnderstandingBaseUrl(
|
||||
cfg: { models?: { providers?: Record<string, { baseUrl?: string } | undefined> } } | undefined,
|
||||
): string {
|
||||
return resolveQwenStandardBaseUrl(cfg, "qwen");
|
||||
}
|
||||
|
||||
@@ -8,10 +8,6 @@ type DetectZaiEndpointFn = typeof detectZaiEndpointCore;
|
||||
|
||||
let detectZaiEndpointImpl: DetectZaiEndpointFn = detectZaiEndpointCore;
|
||||
|
||||
export function setDetectZaiEndpointForTesting(fn?: DetectZaiEndpointFn): void {
|
||||
detectZaiEndpointImpl = fn ?? detectZaiEndpointCore;
|
||||
}
|
||||
|
||||
export async function detectZaiEndpoint(
|
||||
...args: Parameters<DetectZaiEndpointFn>
|
||||
): ReturnType<DetectZaiEndpointFn> {
|
||||
|
||||
Reference in New Issue
Block a user