mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 20:00:42 +00:00
refactor: prune unused extension internals
This commit is contained in:
@@ -23,7 +23,6 @@ type HarnessState = {
|
|||||||
attachOnly?: boolean;
|
attachOnly?: boolean;
|
||||||
}
|
}
|
||||||
>;
|
>;
|
||||||
createTargetId: string | null;
|
|
||||||
prevGatewayPort: string | undefined;
|
prevGatewayPort: string | undefined;
|
||||||
prevGatewayToken: string | undefined;
|
prevGatewayToken: string | undefined;
|
||||||
prevGatewayPassword: string | undefined;
|
prevGatewayPassword: string | undefined;
|
||||||
@@ -37,7 +36,6 @@ const state: HarnessState = {
|
|||||||
cfgEvaluateEnabled: true,
|
cfgEvaluateEnabled: true,
|
||||||
cfgDefaultProfile: "openclaw",
|
cfgDefaultProfile: "openclaw",
|
||||||
cfgProfiles: {},
|
cfgProfiles: {},
|
||||||
createTargetId: null,
|
|
||||||
prevGatewayPort: undefined,
|
prevGatewayPort: undefined,
|
||||||
prevGatewayToken: undefined,
|
prevGatewayToken: undefined,
|
||||||
prevGatewayPassword: undefined,
|
prevGatewayPassword: undefined,
|
||||||
@@ -59,14 +57,6 @@ export function restoreGatewayPortEnv(prevGatewayPort: string | undefined): void
|
|||||||
process.env.OPENCLAW_GATEWAY_PORT = prevGatewayPort;
|
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 {
|
export function setBrowserControlServerEvaluateEnabled(enabled: boolean): void {
|
||||||
state.cfgEvaluateEnabled = enabled;
|
state.cfgEvaluateEnabled = enabled;
|
||||||
}
|
}
|
||||||
@@ -360,10 +350,6 @@ const chromeMcpMocks = vi.hoisted(() => ({
|
|||||||
uploadChromeMcpFile: vi.fn(async () => {}),
|
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" }));
|
const chromeUserDataDir = vi.hoisted(() => ({ dir: "/tmp/openclaw" }));
|
||||||
installChromeUserDataDirHooks(chromeUserDataDir);
|
installChromeUserDataDirHooks(chromeUserDataDir);
|
||||||
|
|
||||||
@@ -435,10 +421,6 @@ vi.mock("../config/config.js", async () => {
|
|||||||
|
|
||||||
const launchCalls = vi.hoisted(() => [] as Array<{ port: number }>);
|
const launchCalls = vi.hoisted(() => [] as Array<{ port: number }>);
|
||||||
|
|
||||||
export function getLaunchCalls() {
|
|
||||||
return launchCalls;
|
|
||||||
}
|
|
||||||
|
|
||||||
vi.mock("./chrome.js", () => ({
|
vi.mock("./chrome.js", () => ({
|
||||||
isChromeCdpReady: vi.fn(async () => state.reachable),
|
isChromeCdpReady: vi.fn(async () => state.reachable),
|
||||||
isChromeReachable: 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.cfgEvaluateEnabled = true;
|
||||||
state.cfgDefaultProfile = "openclaw";
|
state.cfgDefaultProfile = "openclaw";
|
||||||
state.cfgProfiles = defaultProfilesForState(state.testPort);
|
state.cfgProfiles = defaultProfilesForState(state.testPort);
|
||||||
state.createTargetId = null;
|
|
||||||
|
|
||||||
mockClearAll(pwMocks);
|
mockClearAll(pwMocks);
|
||||||
mockClearAll(cdpMocks);
|
mockClearAll(cdpMocks);
|
||||||
@@ -583,9 +564,6 @@ export function installBrowserControlServerHooks() {
|
|||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
vi.useRealTimers();
|
vi.useRealTimers();
|
||||||
cdpMocks.createTargetViaCdp.mockImplementation(async () => {
|
cdpMocks.createTargetViaCdp.mockImplementation(async () => {
|
||||||
if (state.createTargetId) {
|
|
||||||
return { targetId: state.createTargetId };
|
|
||||||
}
|
|
||||||
throw new Error("cdp disabled");
|
throw new Error("cdp disabled");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,6 @@ import {
|
|||||||
normalizeTarget as coreNormalizeTarget,
|
normalizeTarget as coreNormalizeTarget,
|
||||||
looksLikeQQBotTarget,
|
looksLikeQQBotTarget,
|
||||||
} from "./engine/messaging/target-parser.js";
|
} 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";
|
import type { ResolvedQQBotAccount } from "./types.js";
|
||||||
|
|
||||||
// Shared promise so concurrent multi-account startups serialize the dynamic
|
// Shared promise so concurrent multi-account startups serialize the dynamic
|
||||||
|
|||||||
@@ -14,33 +14,11 @@ import {
|
|||||||
postJsonRequest,
|
postJsonRequest,
|
||||||
resolveProviderHttpRequestConfig,
|
resolveProviderHttpRequestConfig,
|
||||||
} from "openclaw/plugin-sdk/provider-http";
|
} 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_MODEL = "qwen-vl-max-latest";
|
||||||
const DEFAULT_QWEN_VIDEO_PROMPT = "Describe the video in detail.";
|
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(
|
export async function describeQwenVideo(
|
||||||
params: VideoDescriptionRequest,
|
params: VideoDescriptionRequest,
|
||||||
): Promise<VideoDescriptionResult> {
|
): Promise<VideoDescriptionResult> {
|
||||||
@@ -108,9 +86,3 @@ export function buildQwenMediaUnderstandingProvider(): MediaUnderstandingProvide
|
|||||||
describeVideo: describeQwenVideo,
|
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;
|
let detectZaiEndpointImpl: DetectZaiEndpointFn = detectZaiEndpointCore;
|
||||||
|
|
||||||
export function setDetectZaiEndpointForTesting(fn?: DetectZaiEndpointFn): void {
|
|
||||||
detectZaiEndpointImpl = fn ?? detectZaiEndpointCore;
|
|
||||||
}
|
|
||||||
|
|
||||||
export async function detectZaiEndpoint(
|
export async function detectZaiEndpoint(
|
||||||
...args: Parameters<DetectZaiEndpointFn>
|
...args: Parameters<DetectZaiEndpointFn>
|
||||||
): ReturnType<DetectZaiEndpointFn> {
|
): ReturnType<DetectZaiEndpointFn> {
|
||||||
|
|||||||
Reference in New Issue
Block a user