diff --git a/.openclaw-sync/source.json b/.openclaw-sync/source.json index 2eb0b8e92..545f7f3f5 100644 --- a/.openclaw-sync/source.json +++ b/.openclaw-sync/source.json @@ -1,5 +1,5 @@ { "repository": "openclaw/openclaw", - "sha": "6bc0dc8fb6714b4e858fb65f9f8051e6b64c8440", - "syncedAt": "2026-04-24T18:16:21.926Z" + "sha": "a43c1f880757e830b5fb4d3c7b5532a625f0e3e4", + "syncedAt": "2026-04-24T18:34:48.414Z" } diff --git a/docs/plugins/sdk-provider-plugins.md b/docs/plugins/sdk-provider-plugins.md index 978555aea..b34e9611b 100644 --- a/docs/plugins/sdk-provider-plugins.md +++ b/docs/plugins/sdk-provider-plugins.md @@ -493,18 +493,42 @@ API key auth, and dynamic model resolution. ```typescript + import { + assertOkOrThrowProviderError, + postJsonRequest, + } from "openclaw/plugin-sdk/provider-http"; + api.registerSpeechProvider({ id: "acme-ai", label: "Acme Speech", isConfigured: ({ config }) => Boolean(config.messages?.tts), - synthesize: async (req) => ({ - audioBuffer: Buffer.from(/* PCM data */), - outputFormat: "mp3", - fileExtension: ".mp3", - voiceCompatible: false, - }), + synthesize: async (req) => { + const { response, release } = await postJsonRequest({ + url: "https://api.example.com/v1/speech", + headers: new Headers({ "Content-Type": "application/json" }), + body: { text: req.text }, + timeoutMs: req.timeoutMs, + fetchFn: fetch, + auditContext: "acme speech", + }); + try { + await assertOkOrThrowProviderError(response, "Acme Speech API error"); + return { + audioBuffer: Buffer.from(await response.arrayBuffer()), + outputFormat: "mp3", + fileExtension: ".mp3", + voiceCompatible: false, + }; + } finally { + await release(); + } + }, }); ``` + + Use `assertOkOrThrowProviderError(...)` for provider HTTP failures so + plugins share capped error-body reads, JSON error parsing, and + request-id suffixes. Prefer `createRealtimeTranscriptionWebSocketSession(...)` — the shared diff --git a/docs/plugins/sdk-subpaths.md b/docs/plugins/sdk-subpaths.md index 8b9253989..db67fd39c 100644 --- a/docs/plugins/sdk-subpaths.md +++ b/docs/plugins/sdk-subpaths.md @@ -94,7 +94,7 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview) | `plugin-sdk/provider-auth` | `createProviderApiKeyAuthMethod`, `ensureApiKeyFromOptionEnvOrPrompt`, `upsertAuthProfile`, `upsertApiKeyProfile`, `writeOAuthCredentials` | | `plugin-sdk/provider-model-shared` | `ProviderReplayFamily`, `buildProviderReplayFamilyHooks`, `normalizeModelCompat`, shared replay-policy builders, provider-endpoint helpers, and model-id normalization helpers such as `normalizeNativeXaiModelId` | | `plugin-sdk/provider-catalog-shared` | `findCatalogTemplate`, `buildSingleProviderApiKeyCatalog`, `supportsNativeStreamingUsageCompat`, `applyProviderNativeStreamingUsageCompat` | - | `plugin-sdk/provider-http` | Generic provider HTTP/endpoint capability helpers, including audio transcription multipart form helpers | + | `plugin-sdk/provider-http` | Generic provider HTTP/endpoint capability helpers, provider HTTP errors, and audio transcription multipart form helpers | | `plugin-sdk/provider-web-fetch-contract` | Narrow web-fetch config/selection contract helpers such as `enablePluginInConfig` and `WebFetchProviderPlugin` | | `plugin-sdk/provider-web-fetch` | Web-fetch provider registration/cache helpers | | `plugin-sdk/provider-web-search-config-contract` | Narrow web-search config/credential helpers for providers that do not need plugin-enable wiring | @@ -218,8 +218,8 @@ For the plugin authoring guide, see [Plugin SDK overview](/plugins/sdk-overview) | `plugin-sdk/media-understanding` | Media understanding provider types plus provider-facing image/audio helper exports | | `plugin-sdk/text-runtime` | Shared text/markdown/logging helpers such as assistant-visible-text stripping, markdown render/chunking/table helpers, redaction helpers, directive-tag helpers, and safe-text utilities | | `plugin-sdk/text-chunking` | Outbound text chunking helper | - | `plugin-sdk/speech` | Speech provider types plus provider-facing directive, registry, and validation helpers | - | `plugin-sdk/speech-core` | Shared speech provider types, registry, directive, and normalization helpers | + | `plugin-sdk/speech` | Speech provider types plus provider-facing directive, registry, validation, and speech helper exports | + | `plugin-sdk/speech-core` | Shared speech provider types, registry, directive, normalization, and speech helper exports | | `plugin-sdk/realtime-transcription` | Realtime transcription provider types, registry helpers, and shared WebSocket session helper | | `plugin-sdk/realtime-voice` | Realtime voice provider types and registry helpers | | `plugin-sdk/image-generation` | Image generation provider types |