mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 13:20:43 +00:00
refactor: remove stale extension helpers
This commit is contained in:
@@ -21,14 +21,6 @@ export type BrowserActResponse = {
|
||||
results?: Array<{ ok: boolean; error?: string }>;
|
||||
};
|
||||
|
||||
export type BrowserDownloadPayload = {
|
||||
url: string;
|
||||
suggestedFilename: string;
|
||||
path: string;
|
||||
};
|
||||
|
||||
type BrowserDownloadResult = { ok: true; targetId: string; download: BrowserDownloadPayload };
|
||||
|
||||
const BROWSER_ACT_REQUEST_TIMEOUT_SLACK_MS = 5_000;
|
||||
|
||||
function normalizePositiveTimeoutMs(value: unknown): number | undefined {
|
||||
@@ -52,21 +44,6 @@ function resolveBrowserActRequestTimeoutMs(req: BrowserActRequest): number {
|
||||
return Math.max(...candidateTimeouts);
|
||||
}
|
||||
|
||||
async function postDownloadRequest(
|
||||
baseUrl: string | undefined,
|
||||
route: "/wait/download" | "/download",
|
||||
body: Record<string, unknown>,
|
||||
profile?: string,
|
||||
): Promise<BrowserDownloadResult> {
|
||||
const q = buildProfileQuery(profile);
|
||||
return await fetchBrowserJson<BrowserDownloadResult>(withBaseUrl(baseUrl, `${route}${q}`), {
|
||||
method: "POST",
|
||||
headers: { "Content-Type": "application/json" },
|
||||
body: JSON.stringify(body),
|
||||
timeoutMs: 20000,
|
||||
});
|
||||
}
|
||||
|
||||
export async function browserNavigate(
|
||||
baseUrl: string | undefined,
|
||||
opts: {
|
||||
@@ -136,50 +113,6 @@ export async function browserArmFileChooser(
|
||||
});
|
||||
}
|
||||
|
||||
export async function browserWaitForDownload(
|
||||
baseUrl: string | undefined,
|
||||
opts: {
|
||||
path?: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
profile?: string;
|
||||
},
|
||||
): Promise<BrowserDownloadResult> {
|
||||
return await postDownloadRequest(
|
||||
baseUrl,
|
||||
"/wait/download",
|
||||
{
|
||||
targetId: opts.targetId,
|
||||
path: opts.path,
|
||||
timeoutMs: opts.timeoutMs,
|
||||
},
|
||||
opts.profile,
|
||||
);
|
||||
}
|
||||
|
||||
export async function browserDownload(
|
||||
baseUrl: string | undefined,
|
||||
opts: {
|
||||
ref: string;
|
||||
path: string;
|
||||
targetId?: string;
|
||||
timeoutMs?: number;
|
||||
profile?: string;
|
||||
},
|
||||
): Promise<BrowserDownloadResult> {
|
||||
return await postDownloadRequest(
|
||||
baseUrl,
|
||||
"/download",
|
||||
{
|
||||
targetId: opts.targetId,
|
||||
ref: opts.ref,
|
||||
path: opts.path,
|
||||
timeoutMs: opts.timeoutMs,
|
||||
},
|
||||
opts.profile,
|
||||
);
|
||||
}
|
||||
|
||||
export async function browserAct(
|
||||
baseUrl: string | undefined,
|
||||
req: BrowserActRequest,
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
import type { BrowserActionPathResult, BrowserActionTargetOk } from "./client-actions-types.js";
|
||||
import { buildProfileQuery, withBaseUrl } from "./client-actions-url.js";
|
||||
import { fetchBrowserJson } from "./client-fetch.js";
|
||||
import type {
|
||||
BrowserConsoleMessage,
|
||||
BrowserNetworkRequest,
|
||||
BrowserPageError,
|
||||
} from "./pw-session.js";
|
||||
import type { BrowserConsoleMessage, BrowserNetworkRequest } from "./pw-session.js";
|
||||
|
||||
function buildQuerySuffix(params: Array<[string, string | boolean | undefined]>): string {
|
||||
const query = new URLSearchParams();
|
||||
@@ -52,23 +48,6 @@ export async function browserPdfSave(
|
||||
});
|
||||
}
|
||||
|
||||
export async function browserPageErrors(
|
||||
baseUrl: string | undefined,
|
||||
opts: { targetId?: string; clear?: boolean; profile?: string } = {},
|
||||
): Promise<{ ok: true; targetId: string; url?: string; errors: BrowserPageError[] }> {
|
||||
const suffix = buildQuerySuffix([
|
||||
["targetId", opts.targetId],
|
||||
["clear", typeof opts.clear === "boolean" ? opts.clear : undefined],
|
||||
["profile", opts.profile],
|
||||
]);
|
||||
return await fetchBrowserJson<{
|
||||
ok: true;
|
||||
targetId: string;
|
||||
url?: string;
|
||||
errors: BrowserPageError[];
|
||||
}>(withBaseUrl(baseUrl, `/errors${suffix}`), { timeoutMs: 20000 });
|
||||
}
|
||||
|
||||
export async function browserRequests(
|
||||
baseUrl: string | undefined,
|
||||
opts: {
|
||||
|
||||
@@ -1,55 +0,0 @@
|
||||
import type { Mock } from "vitest";
|
||||
import { vi } from "vitest";
|
||||
|
||||
type MatrixBotSdkMockParams = {
|
||||
matrixClient?: unknown;
|
||||
simpleFsStorageProvider?: unknown;
|
||||
rustSdkCryptoStorageProvider?: unknown;
|
||||
includeVerboseLogService?: boolean;
|
||||
};
|
||||
|
||||
type MatrixBotSdkMock = {
|
||||
ConsoleLogger: new () => {
|
||||
trace: Mock<() => void>;
|
||||
debug: Mock<() => void>;
|
||||
info: Mock<() => void>;
|
||||
warn: Mock<() => void>;
|
||||
error: Mock<() => void>;
|
||||
};
|
||||
MatrixClient: unknown;
|
||||
LogService: {
|
||||
setLogger: Mock<() => void>;
|
||||
warn?: Mock<() => void>;
|
||||
info?: Mock<() => void>;
|
||||
debug?: Mock<() => void>;
|
||||
};
|
||||
SimpleFsStorageProvider: unknown;
|
||||
RustSdkCryptoStorageProvider: unknown;
|
||||
};
|
||||
|
||||
export function createMatrixBotSdkMock(params: MatrixBotSdkMockParams = {}): MatrixBotSdkMock {
|
||||
return {
|
||||
ConsoleLogger: class {
|
||||
trace = vi.fn();
|
||||
debug = vi.fn();
|
||||
info = vi.fn();
|
||||
warn = vi.fn();
|
||||
error = vi.fn();
|
||||
},
|
||||
MatrixClient: params.matrixClient ?? function MatrixClient() {},
|
||||
LogService: {
|
||||
setLogger: vi.fn(),
|
||||
...(params.includeVerboseLogService
|
||||
? {
|
||||
warn: vi.fn(),
|
||||
info: vi.fn(),
|
||||
debug: vi.fn(),
|
||||
}
|
||||
: {}),
|
||||
},
|
||||
SimpleFsStorageProvider:
|
||||
params.simpleFsStorageProvider ?? function SimpleFsStorageProvider() {},
|
||||
RustSdkCryptoStorageProvider:
|
||||
params.rustSdkCryptoStorageProvider ?? function RustSdkCryptoStorageProvider() {},
|
||||
};
|
||||
}
|
||||
@@ -66,9 +66,6 @@ export const TwilioConfigSchema = z
|
||||
authToken: SecretInputSchema.optional(),
|
||||
})
|
||||
.strict();
|
||||
export type TwilioConfig = Omit<z.infer<typeof TwilioConfigSchema>, "authToken"> & {
|
||||
authToken?: SecretInput;
|
||||
};
|
||||
|
||||
export const PlivoConfigSchema = z
|
||||
.object({
|
||||
@@ -98,7 +95,6 @@ export const VoiceCallServeConfigSchema = z
|
||||
})
|
||||
.strict()
|
||||
.default({ port: 3334, bind: "127.0.0.1", path: "/voice/webhook" });
|
||||
export type VoiceCallServeConfig = z.infer<typeof VoiceCallServeConfigSchema>;
|
||||
|
||||
export const VoiceCallTailscaleConfigSchema = z
|
||||
.object({
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { randomUUID } from "node:crypto";
|
||||
import fs from "node:fs";
|
||||
import fsp from "node:fs/promises";
|
||||
import os from "node:os";
|
||||
import path from "node:path";
|
||||
import { loadOutboundMediaFromUrl } from "openclaw/plugin-sdk/outbound-media";
|
||||
@@ -1910,16 +1909,3 @@ export async function resolveZaloAllowFromEntries(params: {
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
export async function clearProfileRuntimeArtifacts(profileInput?: string | null): Promise<void> {
|
||||
const profile = normalizeProfile(profileInput);
|
||||
resetQrLogin(profile);
|
||||
clearCachedGroupContext(profile);
|
||||
const listener = activeListeners.get(profile);
|
||||
if (listener) {
|
||||
listener.stop();
|
||||
activeListeners.delete(profile);
|
||||
}
|
||||
invalidateApi(profile);
|
||||
await fsp.mkdir(resolveCredentialsDir(), { recursive: true }).catch(() => undefined);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user