mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-09 08:11:09 +00:00
fix(extensions): align provider helper surfaces
This commit is contained in:
@@ -104,22 +104,42 @@ async function postFirecrawlJson<T>(
|
||||
},
|
||||
async ({ response }) => {
|
||||
if (!response.ok) {
|
||||
let detail = response.statusText;
|
||||
const errorBody = await readResponseText(response, { maxBytes: 64_000 });
|
||||
try {
|
||||
const payload = JSON.parse(errorBody.text) as Record<string, unknown>;
|
||||
let detail =
|
||||
typeof response.statusText === "string" && response.statusText.trim()
|
||||
? response.statusText.trim()
|
||||
: "request failed";
|
||||
|
||||
const readJsonPayload = async (): Promise<Record<string, unknown> | null> => {
|
||||
const candidate = response as Response & { clone?: () => Response };
|
||||
const jsonResponse = typeof candidate.clone === "function" ? candidate.clone() : response;
|
||||
if (typeof jsonResponse.json !== "function") {
|
||||
return null;
|
||||
}
|
||||
try {
|
||||
const payload = await jsonResponse.json();
|
||||
return payload && typeof payload === "object" && !Array.isArray(payload)
|
||||
? (payload as Record<string, unknown>)
|
||||
: null;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
};
|
||||
|
||||
const payload = await readJsonPayload();
|
||||
if (payload) {
|
||||
detail =
|
||||
typeof payload.error === "string"
|
||||
? payload.error
|
||||
: typeof payload.message === "string"
|
||||
? payload.message
|
||||
: detail;
|
||||
} catch {
|
||||
} else {
|
||||
const errorBody = await readResponseText(response, { maxBytes: 64_000 });
|
||||
if (errorBody.text) {
|
||||
detail = errorBody.text;
|
||||
}
|
||||
}
|
||||
const safeDetail = wrapWebContent(detail.slice(0, 1_000), "web_fetch");
|
||||
const safeDetail = wrapWebContent(String(detail).slice(0, 1_000), "web_fetch");
|
||||
throw new Error(`${params.errorLabel} API error (${response.status}): ${safeDetail}`);
|
||||
}
|
||||
return await parse(response);
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
export * from "openclaw/plugin-sdk/github-copilot-token";
|
||||
import {
|
||||
DEFAULT_COPILOT_API_BASE_URL,
|
||||
deriveCopilotApiBaseUrlFromToken,
|
||||
resolveCopilotApiToken,
|
||||
} from "openclaw/plugin-sdk/github-copilot-token";
|
||||
|
||||
export { DEFAULT_COPILOT_API_BASE_URL, deriveCopilotApiBaseUrlFromToken, resolveCopilotApiToken };
|
||||
|
||||
@@ -51,6 +51,7 @@ function fakeApi(overrides: Partial<OpenClawPluginApi> = {}): OpenClawPluginApi
|
||||
registerRealtimeVoiceProvider() {},
|
||||
registerMediaUnderstandingProvider() {},
|
||||
registerImageGenerationProvider() {},
|
||||
registerVideoGenerationProvider() {},
|
||||
registerWebFetchProvider() {},
|
||||
registerWebSearchProvider() {},
|
||||
registerInteractiveHandler() {},
|
||||
|
||||
@@ -57,6 +57,7 @@ function createTelegramPluginRegistry() {
|
||||
speechProviders: [],
|
||||
mediaUnderstandingProviders: [],
|
||||
imageGenerationProviders: [],
|
||||
videoGenerationProviders: [],
|
||||
webFetchProviders: [],
|
||||
webSearchProviders: [],
|
||||
gatewayHandlers: {},
|
||||
|
||||
70
src/plugin-sdk/whatsapp-surface.ts
Normal file
70
src/plugin-sdk/whatsapp-surface.ts
Normal file
@@ -0,0 +1,70 @@
|
||||
// Generated by scripts/generate-plugin-sdk-facades.mjs. Do not edit manually.
|
||||
import type { PluginSdkFacadeTypeMap } from "../generated/plugin-sdk-facade-type-map.generated.js";
|
||||
type FacadeEntry = PluginSdkFacadeTypeMap["whatsapp-surface"];
|
||||
type FacadeModule = FacadeEntry["module"];
|
||||
type FacadeModule2 = FacadeEntry["sourceModules"]["source2"]["module"];
|
||||
import {
|
||||
createLazyFacadeObjectValue,
|
||||
loadBundledPluginPublicSurfaceModuleSync,
|
||||
} from "./facade-runtime.js";
|
||||
|
||||
function loadFacadeModule(): FacadeModule {
|
||||
return loadBundledPluginPublicSurfaceModuleSync<FacadeModule>({
|
||||
dirName: "whatsapp",
|
||||
artifactBasename: "api.js",
|
||||
});
|
||||
}
|
||||
|
||||
function loadFacadeModule2(): FacadeModule2 {
|
||||
return loadBundledPluginPublicSurfaceModuleSync<FacadeModule2>({
|
||||
dirName: "whatsapp",
|
||||
artifactBasename: "constants.js",
|
||||
});
|
||||
}
|
||||
export const DEFAULT_WEB_MEDIA_BYTES: FacadeModule2["DEFAULT_WEB_MEDIA_BYTES"] =
|
||||
loadFacadeModule2()["DEFAULT_WEB_MEDIA_BYTES"];
|
||||
export const hasAnyWhatsAppAuth: FacadeModule["hasAnyWhatsAppAuth"] = ((...args) =>
|
||||
loadFacadeModule()["hasAnyWhatsAppAuth"](...args)) as FacadeModule["hasAnyWhatsAppAuth"];
|
||||
export const listEnabledWhatsAppAccounts: FacadeModule["listEnabledWhatsAppAccounts"] = ((
|
||||
...args
|
||||
) =>
|
||||
loadFacadeModule()["listEnabledWhatsAppAccounts"](
|
||||
...args,
|
||||
)) as FacadeModule["listEnabledWhatsAppAccounts"];
|
||||
export const listWhatsAppDirectoryGroupsFromConfig: FacadeModule["listWhatsAppDirectoryGroupsFromConfig"] =
|
||||
((...args) =>
|
||||
loadFacadeModule()["listWhatsAppDirectoryGroupsFromConfig"](
|
||||
...args,
|
||||
)) as FacadeModule["listWhatsAppDirectoryGroupsFromConfig"];
|
||||
export const listWhatsAppDirectoryPeersFromConfig: FacadeModule["listWhatsAppDirectoryPeersFromConfig"] =
|
||||
((...args) =>
|
||||
loadFacadeModule()["listWhatsAppDirectoryPeersFromConfig"](
|
||||
...args,
|
||||
)) as FacadeModule["listWhatsAppDirectoryPeersFromConfig"];
|
||||
export const resolveWhatsAppAccount: FacadeModule["resolveWhatsAppAccount"] = ((...args) =>
|
||||
loadFacadeModule()["resolveWhatsAppAccount"](...args)) as FacadeModule["resolveWhatsAppAccount"];
|
||||
export const resolveWhatsAppGroupRequireMention: FacadeModule["resolveWhatsAppGroupRequireMention"] =
|
||||
((...args) =>
|
||||
loadFacadeModule()["resolveWhatsAppGroupRequireMention"](
|
||||
...args,
|
||||
)) as FacadeModule["resolveWhatsAppGroupRequireMention"];
|
||||
export const resolveWhatsAppGroupToolPolicy: FacadeModule["resolveWhatsAppGroupToolPolicy"] = ((
|
||||
...args
|
||||
) =>
|
||||
loadFacadeModule()["resolveWhatsAppGroupToolPolicy"](
|
||||
...args,
|
||||
)) as FacadeModule["resolveWhatsAppGroupToolPolicy"];
|
||||
export const resolveWhatsAppOutboundTarget: FacadeModule["resolveWhatsAppOutboundTarget"] = ((
|
||||
...args
|
||||
) =>
|
||||
loadFacadeModule()["resolveWhatsAppOutboundTarget"](
|
||||
...args,
|
||||
)) as FacadeModule["resolveWhatsAppOutboundTarget"];
|
||||
export const whatsappAccessControlTesting: FacadeModule["whatsappAccessControlTesting"] =
|
||||
createLazyFacadeObjectValue(
|
||||
() => loadFacadeModule()["whatsappAccessControlTesting"] as object,
|
||||
) as FacadeModule["whatsappAccessControlTesting"];
|
||||
export type WebChannelStatus = FacadeEntry["types"]["WebChannelStatus"];
|
||||
export type WebInboundMessage = FacadeEntry["types"]["WebInboundMessage"];
|
||||
export type WebListenerCloseReason = FacadeEntry["types"]["WebListenerCloseReason"];
|
||||
export type WebMonitorTuning = FacadeEntry["types"]["WebMonitorTuning"];
|
||||
Reference in New Issue
Block a user