惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
月光博客
月光博客
爱范儿
爱范儿
The Cloudflare Blog
Y
Y Combinator Blog
B
Blog RSS Feed
Stack Overflow Blog
Stack Overflow Blog
博客园 - 叶小钗
G
Google Developers Blog
J
Java Code Geeks
P
Proofpoint News Feed
美团技术团队
Engineering at Meta
Engineering at Meta
腾讯CDC
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
WordPress大学
WordPress大学
博客园 - 聂微东
雷峰网
雷峰网
有赞技术团队
有赞技术团队
L
LangChain Blog
N
Netflix TechBlog - Medium
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 【当耐特】

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
feat: add browser realtime talk · openclaw/openclaw@04066d2
steipete · 2026-04-24 · via Recent Commits to openclaw:main

@@ -6,6 +6,8 @@ import {

66

} from "openclaw/plugin-sdk/proxy-capture";

77

import type {

88

RealtimeVoiceBridge,

9+

RealtimeVoiceBrowserSession,

10+

RealtimeVoiceBrowserSessionCreateRequest,

911

RealtimeVoiceBridgeCreateRequest,

1012

RealtimeVoiceProviderConfig,

1113

RealtimeVoiceProviderPlugin,

@@ -59,6 +61,8 @@ type OpenAIRealtimeVoiceBridgeConfig = RealtimeVoiceBridgeCreateRequest & {

5961

azureApiVersion?: string;

6062

};

616364+

const OPENAI_REALTIME_DEFAULT_MODEL = "gpt-realtime-1.5";

65+6266

type RealtimeEvent = {

6367

type: string;

6468

delta?: string;

@@ -117,7 +121,7 @@ function base64ToBuffer(b64: string): Buffer {

117121

}

118122119123

class OpenAIRealtimeVoiceBridge implements RealtimeVoiceBridge {

120-

private static readonly DEFAULT_MODEL = "gpt-realtime-1.5";

124+

private static readonly DEFAULT_MODEL = OPENAI_REALTIME_DEFAULT_MODEL;

121125

private static readonly MAX_RECONNECT_ATTEMPTS = 5;

122126

private static readonly BASE_RECONNECT_DELAY_MS = 1000;

123127

private static readonly CONNECT_TIMEOUT_MS = 10_000;

@@ -579,6 +583,77 @@ class OpenAIRealtimeVoiceBridge implements RealtimeVoiceBridge {

579583

}

580584

}

581585586+

function readStringField(value: unknown, key: string): string | undefined {

587+

if (!value || typeof value !== "object") {

588+

return undefined;

589+

}

590+

const raw = (value as Record<string, unknown>)[key];

591+

return typeof raw === "string" && raw.trim() ? raw.trim() : undefined;

592+

}

593+594+

async function createOpenAIRealtimeBrowserSession(

595+

req: RealtimeVoiceBrowserSessionCreateRequest,

596+

): Promise<RealtimeVoiceBrowserSession> {

597+

const config = normalizeProviderConfig(req.providerConfig);

598+

const apiKey = config.apiKey || process.env.OPENAI_API_KEY;

599+

if (!apiKey) {

600+

throw new Error("OpenAI API key missing");

601+

}

602+

if (config.azureEndpoint || config.azureDeployment) {

603+

throw new Error("OpenAI Realtime browser sessions do not support Azure endpoints yet");

604+

}

605+606+

const model = req.model ?? config.model ?? OPENAI_REALTIME_DEFAULT_MODEL;

607+

const voice = (req.voice ?? config.voice ?? "alloy") as OpenAIRealtimeVoice;

608+

const session: Record<string, unknown> = {

609+

type: "realtime",

610+

model,

611+

instructions: req.instructions,

612+

audio: {

613+

output: { voice },

614+

},

615+

};

616+

if (req.tools && req.tools.length > 0) {

617+

session.tools = req.tools;

618+

session.tool_choice = "auto";

619+

}

620+621+

const response = await fetch("https://api.openai.com/v1/realtime/client_secrets", {

622+

method: "POST",

623+

headers: {

624+

Authorization: `Bearer ${apiKey}`,

625+

"Content-Type": "application/json",

626+

},

627+

body: JSON.stringify({ session }),

628+

});

629+

if (!response.ok) {

630+

const detail = await response.text().catch(() => "");

631+

throw new Error(

632+

`OpenAI Realtime browser session failed (${response.status}): ${detail || response.statusText}`,

633+

);

634+

}

635+

const payload = (await response.json()) as unknown;

636+

const nestedSecret =

637+

payload && typeof payload === "object"

638+

? (payload as Record<string, unknown>).client_secret

639+

: undefined;

640+

const clientSecret = readStringField(payload, "value") ?? readStringField(nestedSecret, "value");

641+

if (!clientSecret) {

642+

throw new Error("OpenAI Realtime browser session did not return a client secret");

643+

}

644+

const expiresAt =

645+

payload && typeof payload === "object"

646+

? (payload as Record<string, unknown>).expires_at

647+

: undefined;

648+

return {

649+

provider: "openai",

650+

clientSecret,

651+

model,

652+

voice,

653+

...(typeof expiresAt === "number" ? { expiresAt } : {}),

654+

};

655+

}

656+582657

export function buildOpenAIRealtimeVoiceProvider(): RealtimeVoiceProviderPlugin {

583658

return {

584659

id: "openai",

@@ -607,6 +682,7 @@ export function buildOpenAIRealtimeVoiceProvider(): RealtimeVoiceProviderPlugin

607682

azureApiVersion: config.azureApiVersion,

608683

});

609684

},

685+

createBrowserSession: createOpenAIRealtimeBrowserSession,

610686

};

611687

}

612688