@openclaw/voice-call 2026.10.2 → 2026.10.5-beta.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,5 +1,5 @@
1
- import { c as resolveVoiceCallSessionKey } from "./config-CX9J-053.mjs";
2
- import { m as resolveCallAgentId, p as resolveVoiceResponseModel } from "./runtime-entry-CbSKxSKk.mjs";
1
+ import { c as resolveVoiceCallSessionKey } from "./config-CsrGuamE.mjs";
2
+ import { m as resolveVoiceResponseModel, x as resolveCallAgentId } from "./runtime-entry-STjFmi_B.mjs";
3
3
  import { normalizeLowercaseStringOrEmpty, normalizeStringEntries } from "openclaw/plugin-sdk/string-coerce-runtime";
4
4
  import { resolveAgentConfig } from "openclaw/plugin-sdk/agent-scope-runtime";
5
5
  import { isValidAgentHarnessSessionStoreEntry } from "openclaw/plugin-sdk/session-store-runtime";
@@ -8,10 +8,6 @@ import { truncateUtf16Safe } from "openclaw/plugin-sdk/text-utility-runtime";
8
8
  import { resolveDefaultModelForAgent } from "openclaw/plugin-sdk/agent-runtime";
9
9
  import { ModelSelectionLockedError, applyModelOverrideWithAuthProfileCompatibility, resolvePersistedSessionRuntimeId } from "openclaw/plugin-sdk/model-session-runtime";
10
10
  //#region extensions/voice-call/src/response-generator.ts
11
- /**
12
- * Voice call response generator - uses the embedded OpenClaw agent for tool support.
13
- * Routes voice responses through the same agent infrastructure as messaging.
14
- */
15
11
  const VOICE_SPOKEN_OUTPUT_CONTRACT = [
16
12
  "Output format requirements:",
17
13
  "- Return only valid JSON in this exact shape: {\"spoken\":\"...\"}",
@@ -103,36 +99,18 @@ function extractSpokenTextFromPayloads(payloads) {
103
99
  if (payload.isError || payload.isReasoning) continue;
104
100
  const rawText = payload.text?.trim() ?? "";
105
101
  if (!rawText) continue;
106
- const structured = tryParseSpokenJson(rawText);
107
- if (structured !== null) {
108
- if (structured.length > 0) spokenSegments.push(structured);
109
- continue;
110
- }
111
- const plain = sanitizePlainSpokenText(rawText);
112
- if (plain) spokenSegments.push(plain);
113
- }
114
- return spokenSegments.length > 0 ? spokenSegments.join(" ").trim() : null;
115
- }
116
- async function deliverEarlyText(callback, text) {
117
- try {
118
- return await callback(text);
119
- } catch (error) {
120
- console.error("[voice-call] Early TTS delivery failed:", error);
121
- return false;
102
+ const spoken = tryParseSpokenJson(rawText) ?? sanitizePlainSpokenText(rawText);
103
+ if (spoken) spokenSegments.push(spoken);
122
104
  }
105
+ return spokenSegments.join(" ") || null;
123
106
  }
124
107
  function resolveVoiceSandboxSessionKey(agentId, sessionKey) {
125
108
  const trimmed = sessionKey.trim();
126
109
  if (trimmed.toLowerCase().startsWith("agent:")) return trimmed;
127
110
  return `agent:${agentId}:${trimmed}`;
128
111
  }
129
- /**
130
- * Generate a voice response using the embedded OpenClaw agent with full tool support.
131
- * Uses the same agent infrastructure as messaging for consistent behavior.
132
- */
133
112
  async function generateVoiceResponse(params) {
134
- const { voiceConfig, callId, sessionKey, from, senderIsOwner, transcript, userMessage, coreConfig, agentRuntime, onEarlyText } = params;
135
- const cfg = coreConfig;
113
+ const { voiceConfig, callId, sessionKey, from, senderIsOwner, transcript, userMessage, coreConfig: cfg, agentRuntime, onEarlyText } = params;
136
114
  const agentId = resolveCallAgentId(params);
137
115
  const resolvedSessionKey = resolveVoiceCallSessionKey({
138
116
  config: {
@@ -142,7 +120,7 @@ async function generateVoiceResponse(params) {
142
120
  callId,
143
121
  phone: from,
144
122
  explicitSessionKey: sessionKey,
145
- coreSession: coreConfig.session
123
+ coreSession: cfg.session
146
124
  });
147
125
  const toolsAllow = resolveAgentConfig(cfg, agentId)?.tools?.allow;
148
126
  const storePath = agentRuntime.session.resolveStorePath(cfg.session?.store, { agentId });
@@ -155,7 +133,7 @@ async function generateVoiceResponse(params) {
155
133
  const workspaceDir = agentRuntime.resolveAgentWorkspaceDir(cfg, agentId);
156
134
  await agentRuntime.ensureAgentWorkspace({ dir: workspaceDir });
157
135
  const now = Date.now();
158
- const existingSessionEntry = agentRuntime.session.getSessionEntry({
136
+ let sessionEntry = agentRuntime.session.getSessionEntry({
159
137
  storePath,
160
138
  sessionKey: resolvedSessionKey
161
139
  });
@@ -167,7 +145,6 @@ async function generateVoiceResponse(params) {
167
145
  cfg,
168
146
  agentId
169
147
  });
170
- let sessionEntry = existingSessionEntry;
171
148
  if (sessionEntry?.modelSelectionLocked === true && voiceConfig.responseModel) throw new ModelSelectionLockedError();
172
149
  if (!sessionEntry?.sessionId || voiceConfig.responseModel) sessionEntry = await agentRuntime.session.patchSessionEntry({
173
150
  storePath,
@@ -292,7 +269,12 @@ async function generateVoiceResponse(params) {
292
269
  const text = extractSpokenTextFromPayloads(pendingPayloads);
293
270
  if (!text) return;
294
271
  lastFlushedText = text;
295
- deliveredEarly = await deliverEarlyText(onEarlyText, text);
272
+ try {
273
+ deliveredEarly = await onEarlyText(text);
274
+ } catch (error) {
275
+ console.error("[voice-call] Early TTS delivery failed:", error);
276
+ deliveredEarly = false;
277
+ }
296
278
  }
297
279
  });
298
280
  const text = extractSpokenTextFromPayloads(result.payloads ?? []) ?? lastFlushedText ?? extractSpokenTextFromPayloads(blockReplyPayloads);