@openclaw/facetime 2026.9.8 → 2026.10.1-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.
@@ -3,6 +3,7 @@ import { access } from "node:fs/promises";
3
3
  import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
4
4
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
5
5
  import type { PluginRuntime, RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime";
6
+ import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
6
7
  import { FACETIME_FEED_DEVICE_NAME, FACETIME_MIC_DEVICE_NAME } from "./audio-pump.js";
7
8
  import { FaceTimeCallRegistry } from "./call-lifecycle.js";
8
9
  import type { FaceTimeConfig } from "./config.js";
@@ -10,9 +11,9 @@ import {
10
11
  FaceTimeHelperAmbiguousError,
11
12
  projectCompleteFaceTimeAbsence,
12
13
  projectFaceTimeNativeAction,
13
- type FaceTimeHelperSocketServer,
14
14
  type HelperActionResult,
15
- } from "./helper-rpc.js";
15
+ } from "./helper-results.js";
16
+ import type { FaceTimeHelperSocketServer } from "./helper-rpc.js";
16
17
  import { terminateExactCarrierProcesses } from "./runtime-carrier-process.js";
17
18
  import type { ActiveFaceTimeCall } from "./runtime-state.js";
18
19
  import { startFaceTimeTalkDriver } from "./talk-driver.js";
@@ -41,13 +42,15 @@ export function createFaceTimeCallControl(params: {
41
42
  ].filter((candidate, index, all) => all.indexOf(candidate) === index);
42
43
  let lastAbsent: FaceTimeHelperAmbiguousError | undefined;
43
44
  for (const candidate of candidates) {
44
- let result: HelperActionResult;
45
45
  try {
46
- result = await request.call.runCarrierCommand({
46
+ const result = await request.call.runCarrierCommand({
47
47
  generation: request.generation,
48
48
  allowClosing: true,
49
49
  action: async () => await request.run(candidate),
50
50
  });
51
+ projectFaceTimeNativeAction(request.action, result);
52
+ request.call.promoteCarrierCallUUID(candidate);
53
+ return result;
51
54
  } catch (error) {
52
55
  if (!(error instanceof FaceTimeHelperAmbiguousError)) {
53
56
  throw error;
@@ -58,25 +61,6 @@ export function createFaceTimeCallControl(params: {
58
61
  } catch {
59
62
  throw error;
60
63
  }
61
- continue;
62
- }
63
- try {
64
- projectFaceTimeNativeAction(request.action, result);
65
- request.call.promoteCarrierCallUUID(candidate);
66
- return result;
67
- } catch (error) {
68
- try {
69
- projectCompleteFaceTimeAbsence(result);
70
- lastAbsent =
71
- error instanceof FaceTimeHelperAmbiguousError
72
- ? error
73
- : new FaceTimeHelperAmbiguousError(
74
- `FaceTime ${request.action} carrier owner is missing`,
75
- result,
76
- );
77
- } catch {
78
- throw error;
79
- }
80
64
  }
81
65
  }
82
66
  throw lastAbsent ?? new Error(`FaceTime ${request.action} carrier owner is missing`);
@@ -256,10 +240,7 @@ export function createFaceTimeCallControl(params: {
256
240
  ),
257
241
  });
258
242
  const first = projectCompleteFaceTimeAbsence(await inspect());
259
- await new Promise<void>((resolve) => {
260
- const timer = setTimeout(resolve, 100);
261
- timer.unref?.();
262
- });
243
+ await sleepWithAbort(100, undefined, { ref: false });
263
244
  const second = projectCompleteFaceTimeAbsence(await inspect());
264
245
  return (
265
246
  first.topologyGeneration === second.topologyGeneration &&
@@ -320,10 +301,7 @@ export function createFaceTimeCallControl(params: {
320
301
  ) {
321
302
  return true;
322
303
  }
323
- await new Promise<void>((resolve) => {
324
- const timer = setTimeout(resolve, 1_000);
325
- timer.unref?.();
326
- });
304
+ await sleepWithAbort(1_000, undefined, { ref: false });
327
305
  }
328
306
  return true;
329
307
  })(),
@@ -14,18 +14,15 @@ import {
14
14
  } from "./call-events.js";
15
15
  import type { FaceTimeCallRegistry } from "./call-lifecycle.js";
16
16
  import type { FaceTimeConfig } from "./config.js";
17
- import {
18
- projectFaceTimeNativeAction,
19
- type FaceTimeHelperPeer,
20
- type FaceTimeHelperSocketServer,
21
- } from "./helper-rpc.js";
17
+ import { projectFaceTimeNativeAction } from "./helper-results.js";
18
+ import type { FaceTimeHelperPeer, FaceTimeHelperSocketServer } from "./helper-rpc.js";
22
19
  import {
23
20
  doesFaceTimeCallMatchPendingDial,
24
21
  retainFaceTimeDialCallUUID,
25
22
  type PendingFaceTimeDial,
26
23
  } from "./outbound-call.js";
27
24
  import { retainHelperResultPeers } from "./runtime-helper-results.js";
28
- import { ActiveFaceTimeCall, readCallUUID, updateCallStatus } from "./runtime-state.js";
25
+ import { ActiveFaceTimeCall, updateCallStatus } from "./runtime-state.js";
29
26
 
30
27
  type CallControl = {
31
28
  activateCallTalk(call: ActiveFaceTimeCall, options: { unmute: boolean }): Promise<void>;
@@ -74,7 +71,7 @@ export function createFaceTimeCallEventHandler(params: {
74
71
  event: FaceTimeCallStatusEvent,
75
72
  pending: PendingFaceTimeDial,
76
73
  ): Promise<AuthenticatedFaceTimeOwner | undefined> => {
77
- retainFaceTimeDialCallUUID(pending, readCallUUID(event));
74
+ retainFaceTimeDialCallUUID(pending, event.data.call_uuid);
78
75
  await params.persistPendingDial();
79
76
  if (params.isStopping() || params.getPendingDial() !== pending) {
80
77
  return undefined;
@@ -115,7 +112,7 @@ export function createFaceTimeCallEventHandler(params: {
115
112
  params.calls.retainAlias(call, alias);
116
113
  }
117
114
  }
118
- call.carrierCallUUIDs.add(String(event.data.call_uuid));
115
+ call.carrierCallUUIDs.add(event.data.call_uuid);
119
116
  };
120
117
  const retainPendingDial = (call: ActiveFaceTimeCall, pending: PendingFaceTimeDial) => {
121
118
  params.calls.retainAlias(call, pending.dialID);
@@ -135,7 +132,7 @@ export function createFaceTimeCallEventHandler(params: {
135
132
  owner: AuthenticatedFaceTimeOwner,
136
133
  peer?: FaceTimeHelperPeer,
137
134
  ) => {
138
- const callUUID = readCallUUID(event);
135
+ const callUUID = event.data.call_uuid;
139
136
  if (params.isDriverInstallPending()) {
140
137
  params.logger.warn("[facetime] ignored incoming call; audio driver installation is pending");
141
138
  return;
@@ -196,7 +193,7 @@ export function createFaceTimeCallEventHandler(params: {
196
193
  peer?: FaceTimeHelperPeer,
197
194
  pending?: PendingFaceTimeDial,
198
195
  ) => {
199
- const callUUID = readCallUUID(event);
196
+ const callUUID = event.data.call_uuid;
200
197
  if (params.isDriverInstallPending()) {
201
198
  params.logger.warn("[facetime] ignored active call; audio driver installation is pending");
202
199
  return;
@@ -247,7 +244,7 @@ export function createFaceTimeCallEventHandler(params: {
247
244
  if (params.isStopping()) {
248
245
  return;
249
246
  }
250
- const callUUID = readCallUUID(event);
247
+ const callUUID = event.data.call_uuid;
251
248
  const existingCall = resolveEventCall(event);
252
249
  const pending = params.getPendingDial();
253
250
  if (existingCall) {
@@ -1,9 +1,7 @@
1
- import {
2
- readHelperResults,
3
- type FaceTimeHelperPeer,
4
- type FaceTimeHelperSocketServer,
5
- type HelperActionResult,
6
- } from "./helper-rpc.js";
1
+ import { sleep } from "openclaw/plugin-sdk/runtime-env";
2
+ import { normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
3
+ import { readHelperResults, type HelperActionResult } from "./helper-results.js";
4
+ import type { FaceTimeHelperPeer, FaceTimeHelperSocketServer } from "./helper-rpc.js";
7
5
  import { retainFaceTimeDialCallUUID, type PendingFaceTimeDial } from "./outbound-call.js";
8
6
  import type { ActiveFaceTimeCall } from "./runtime-state.js";
9
7
 
@@ -71,21 +69,13 @@ export function retainOutboundDialHelperPeers(
71
69
 
72
70
  export function readOutboundCallUUID(result: HelperActionResult): string | undefined {
73
71
  return readHelperResults(result)
74
- .map((entry) =>
75
- typeof entry.call_uuid === "string" && entry.call_uuid.trim()
76
- ? entry.call_uuid.trim()
77
- : undefined,
78
- )
72
+ .map((entry) => normalizeOptionalString(entry.call_uuid))
79
73
  .find((value) => Boolean(value));
80
74
  }
81
75
 
82
76
  export function readOutboundProxyIdentifier(result: HelperActionResult): string | undefined {
83
77
  return readHelperResults(result)
84
- .map((entry) =>
85
- typeof entry.proxy_identifier === "string" && entry.proxy_identifier.trim()
86
- ? entry.proxy_identifier.trim()
87
- : undefined,
88
- )
78
+ .map((entry) => normalizeOptionalString(entry.proxy_identifier))
89
79
  .find((value) => Boolean(value));
90
80
  }
91
81
 
@@ -189,9 +179,7 @@ export async function reconcilePendingFaceTimeCarrier(params: {
189
179
  previousAbsentTopology = completeAbsence ? topologyGeneration : undefined;
190
180
  previousAbsenceCurrent = completeAbsence ? isSnapshotCurrent : undefined;
191
181
  if (attempt + 1 < OUTBOUND_RECONCILE_ATTEMPTS) {
192
- await new Promise<void>((resolve) => {
193
- setTimeout(resolve, OUTBOUND_RECONCILE_INTERVAL_MS);
194
- });
182
+ await sleep(OUTBOUND_RECONCILE_INTERVAL_MS);
195
183
  }
196
184
  }
197
185
  }
@@ -1,6 +1,7 @@
1
1
  import type { FaceTimeCallStatusEvent, AuthenticatedFaceTimeOwner } from "./call-events.js";
2
2
  import { FaceTimeCallInstance } from "./call-lifecycle.js";
3
- import type { HelperActionResult, FaceTimeHelperPeer } from "./helper-rpc.js";
3
+ import type { HelperActionResult } from "./helper-results.js";
4
+ import type { FaceTimeHelperPeer } from "./helper-rpc.js";
4
5
  import type { FaceTimeHelperSupervisorStatus } from "./helper-supervisor.js";
5
6
  import type { FaceTimeDialMode, PendingFaceTimeDial } from "./outbound-call.js";
6
7
  import type { FaceTimeTalkDriver } from "./talk-driver.js";
@@ -136,65 +137,27 @@ export type FaceTimeRuntimeStatus = {
136
137
  }>;
137
138
  };
138
139
 
139
- export function readCallUUID(event: FaceTimeCallStatusEvent): string {
140
- return String(event.data.call_uuid);
141
- }
142
-
143
140
  export function updateCallStatus(call: ActiveFaceTimeCall, event: FaceTimeCallStatusEvent): void {
144
- call.callStatus =
145
- typeof event.data.call_status === "number" ? event.data.call_status : call.callStatus;
146
- call.isSendingAudio =
147
- typeof event.data.is_sending_audio === "boolean"
148
- ? event.data.is_sending_audio
149
- : call.isSendingAudio;
150
- call.isSendingTransmission =
151
- typeof event.data.is_sending_transmission === "boolean"
152
- ? event.data.is_sending_transmission
153
- : call.isSendingTransmission;
154
- call.isUplinkMuted =
155
- typeof event.data.is_uplink_muted === "boolean"
156
- ? event.data.is_uplink_muted
157
- : call.isUplinkMuted;
158
- call.isSendingVideo =
159
- typeof event.data.is_sending_video === "boolean"
160
- ? event.data.is_sending_video
161
- : call.isSendingVideo;
162
- call.conversationUUID =
163
- typeof event.data.conversation_uuid === "string"
164
- ? event.data.conversation_uuid
165
- : call.conversationUUID;
166
- call.conversationGroupUUID =
167
- typeof event.data.conversation_group_uuid === "string"
168
- ? event.data.conversation_group_uuid
169
- : call.conversationGroupUUID;
141
+ call.callStatus = event.data.call_status;
142
+ call.isSendingAudio = event.data.is_sending_audio ?? call.isSendingAudio;
143
+ call.isSendingTransmission = event.data.is_sending_transmission ?? call.isSendingTransmission;
144
+ call.isUplinkMuted = event.data.is_uplink_muted ?? call.isUplinkMuted;
145
+ call.isSendingVideo = event.data.is_sending_video ?? call.isSendingVideo;
146
+ call.conversationUUID = event.data.conversation_uuid ?? call.conversationUUID;
147
+ call.conversationGroupUUID = event.data.conversation_group_uuid ?? call.conversationGroupUUID;
170
148
  call.conversationAudioEnabled =
171
- typeof event.data.conversation_audio_enabled === "boolean"
172
- ? event.data.conversation_audio_enabled
173
- : call.conversationAudioEnabled;
149
+ event.data.conversation_audio_enabled ?? call.conversationAudioEnabled;
174
150
  call.conversationVideoEnabled =
175
- typeof event.data.conversation_video_enabled === "boolean"
176
- ? event.data.conversation_video_enabled
177
- : call.conversationVideoEnabled;
178
- call.conversationAVMode =
179
- typeof event.data.conversation_av_mode === "number"
180
- ? event.data.conversation_av_mode
181
- : call.conversationAVMode;
151
+ event.data.conversation_video_enabled ?? call.conversationVideoEnabled;
152
+ call.conversationAVMode = event.data.conversation_av_mode ?? call.conversationAVMode;
182
153
  call.conversationResolvedAudioVideoMode =
183
- typeof event.data.conversation_resolved_audio_video_mode === "number"
184
- ? event.data.conversation_resolved_audio_video_mode
185
- : call.conversationResolvedAudioVideoMode;
186
- call.localMeterLevel =
187
- typeof event.data.local_meter_level === "number"
188
- ? event.data.local_meter_level
189
- : call.localMeterLevel;
190
- call.remoteMeterLevel =
191
- typeof event.data.remote_meter_level === "number"
192
- ? event.data.remote_meter_level
193
- : call.remoteMeterLevel;
194
- if (typeof event.data.local_meter_level === "number") {
154
+ event.data.conversation_resolved_audio_video_mode ?? call.conversationResolvedAudioVideoMode;
155
+ call.localMeterLevel = event.data.local_meter_level ?? call.localMeterLevel;
156
+ call.remoteMeterLevel = event.data.remote_meter_level ?? call.remoteMeterLevel;
157
+ if (event.data.local_meter_level !== undefined) {
195
158
  call.maxLocalMeterLevel = Math.max(call.maxLocalMeterLevel ?? 0, event.data.local_meter_level);
196
159
  }
197
- if (typeof event.data.remote_meter_level === "number") {
160
+ if (event.data.remote_meter_level !== undefined) {
198
161
  call.maxRemoteMeterLevel = Math.max(
199
162
  call.maxRemoteMeterLevel ?? 0,
200
163
  event.data.remote_meter_level,
package/src/runtime.ts CHANGED
@@ -2,6 +2,7 @@ import { randomUUID } from "node:crypto";
2
2
  import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
3
3
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
4
4
  import type { PluginRuntime, RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime";
5
+ import { sleep } from "openclaw/plugin-sdk/runtime-env";
5
6
  import { normalizeFaceTimeCallEvent } from "./call-events.js";
6
7
  import { FaceTimeCallRegistry } from "./call-lifecycle.js";
7
8
  import { resolveFaceTimeConfig, validateFaceTimeConfig, type FaceTimeConfig } from "./config.js";
@@ -9,11 +10,10 @@ import { installFaceTimeDriver } from "./driver-setup.js";
9
10
  import { resolveFaceTimeHelperEndpoint } from "./helper-endpoint.js";
10
11
  import {
11
12
  FaceTimeHelperAmbiguousError,
12
- FaceTimeHelperSocketServer,
13
13
  FaceTimeHelperUnavailableError,
14
14
  readHelperResults,
15
- type FaceTimeHelperPeer,
16
- } from "./helper-rpc.js";
15
+ } from "./helper-results.js";
16
+ import { FaceTimeHelperSocketServer, type FaceTimeHelperPeer } from "./helper-rpc.js";
17
17
  import { FaceTimeHelperSupervisor } from "./helper-supervisor.js";
18
18
  import {
19
19
  doesPendingFaceTimeDialHaveCallUUID,
@@ -105,12 +105,11 @@ export async function createFaceTimeRuntime(params: {
105
105
  });
106
106
  let stopping = false;
107
107
  let helperStopped = false;
108
- const helperRef: { current?: FaceTimeHelperSocketServer } = {};
109
108
  const helperSupervisor = new FaceTimeHelperSupervisor({
110
109
  pluginRoot: params.pluginRoot,
111
110
  logger: params.logger,
112
111
  runCommandWithTimeout: params.runtime.system.runCommandWithTimeout,
113
- connectedBundles: () => helperRef.current?.connectedHelperBundles ?? [],
112
+ connectedBundles: () => helper.connectedHelperBundles,
114
113
  });
115
114
  const pendingOperations = new Set<Promise<void>>();
116
115
  const observePendingOperation = (operation: Promise<void>) => {
@@ -264,9 +263,6 @@ export async function createFaceTimeRuntime(params: {
264
263
  };
265
264
  let helperTopologyVersion = 0;
266
265
  const helperEndpoint = resolveFaceTimeHelperEndpoint();
267
- const callEventRef: {
268
- current?: ReturnType<typeof createFaceTimeCallEventHandler>;
269
- } = {};
270
266
  const helper = new FaceTimeHelperSocketServer({
271
267
  ...helperEndpoint,
272
268
  logger: params.logger,
@@ -289,16 +285,13 @@ export async function createFaceTimeRuntime(params: {
289
285
  }
290
286
  const event = normalizeFaceTimeCallEvent(message);
291
287
  if (event) {
292
- const operation = callEventRef.current?.handleCallEvent(event, peer);
293
- if (operation) {
294
- return observePendingOperation(operation);
295
- }
288
+ return observePendingOperation(callEvents.handleCallEvent(event, peer));
296
289
  }
297
290
  return undefined;
298
291
  },
299
292
  onConnect(bundleIdentifier) {
300
293
  helperTopologyVersion += 1;
301
- helperSupervisor?.connected(bundleIdentifier);
294
+ helperSupervisor.connected(bundleIdentifier);
302
295
  for (const call of calls.values()) {
303
296
  if (call.carrierHangupPending) {
304
297
  void attemptCarrierHangup(call, "helper-reconnected");
@@ -312,7 +305,7 @@ export async function createFaceTimeRuntime(params: {
312
305
  },
313
306
  onDisconnect(bundleIdentifier) {
314
307
  helperTopologyVersion += 1;
315
- helperSupervisor?.disconnected(bundleIdentifier);
308
+ helperSupervisor.disconnected(bundleIdentifier);
316
309
  if (stopping || calls.size === 0) {
317
310
  return;
318
311
  }
@@ -328,11 +321,9 @@ export async function createFaceTimeRuntime(params: {
328
321
  }
329
322
  },
330
323
  onStale(bundleIdentifier, processId) {
331
- helperSupervisor?.stale(bundleIdentifier, processId);
324
+ helperSupervisor.stale(bundleIdentifier, processId);
332
325
  },
333
326
  });
334
- helperRef.current = helper;
335
-
336
327
  const callControl = createFaceTimeCallControl({
337
328
  calls,
338
329
  helper,
@@ -346,7 +337,7 @@ export async function createFaceTimeRuntime(params: {
346
337
  retainHelperResultPeers,
347
338
  });
348
339
  const { attemptCarrierHangup, stopCall } = callControl;
349
- callEventRef.current = createFaceTimeCallEventHandler({
340
+ const callEvents = createFaceTimeCallEventHandler({
350
341
  calls,
351
342
  helper,
352
343
  config,
@@ -391,9 +382,7 @@ export async function createFaceTimeRuntime(params: {
391
382
 
392
383
  return {
393
384
  config,
394
- async status() {
395
- return await readStatus();
396
- },
385
+ status: readStatus,
397
386
  async dial(dialParams) {
398
387
  if (stopping) {
399
388
  throw new Error("cannot start an outbound FaceTime call while the plugin is stopping");
@@ -543,9 +532,7 @@ export async function createFaceTimeRuntime(params: {
543
532
  for (let attempt = 0; attempt < OUTBOUND_RECONCILE_ATTEMPTS && !call; attempt += 1) {
544
533
  call = findCall();
545
534
  if (!call && attempt + 1 < OUTBOUND_RECONCILE_ATTEMPTS) {
546
- await new Promise<void>((resolve) => {
547
- setTimeout(resolve, OUTBOUND_RECONCILE_INTERVAL_MS);
548
- });
535
+ await sleep(OUTBOUND_RECONCILE_INTERVAL_MS);
549
536
  }
550
537
  }
551
538
  }
@@ -584,9 +571,7 @@ export async function createFaceTimeRuntime(params: {
584
571
  preflight,
585
572
  });
586
573
  },
587
- async preflight() {
588
- return await runPreflight();
589
- },
574
+ preflight: runPreflight,
590
575
  async installDriver() {
591
576
  if (stopping) {
592
577
  throw new Error("cannot install the FaceTime audio driver while the plugin is stopping");
@@ -16,6 +16,7 @@ import {
16
16
  type TalkEvent,
17
17
  type TalkEventInput,
18
18
  } from "openclaw/plugin-sdk/realtime-voice";
19
+ import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
19
20
  import { startFaceTimeAudioPump } from "./audio-pump.js";
20
21
  import type { FaceTimeConfig } from "./config.js";
21
22
  import { createFaceTimeConsultController } from "./talk-consult-controller.js";
@@ -154,9 +155,9 @@ export async function startFaceTimeTalkDriver(params: {
154
155
  if (failurePromise) {
155
156
  return failurePromise;
156
157
  }
157
- failurePromise = Promise.resolve(params.onFailure?.(error)).then((safeToClose) => {
158
- return safeToClose !== false;
159
- });
158
+ failurePromise = Promise.resolve(params.onFailure?.(error)).then(
159
+ (safeToClose) => safeToClose !== false,
160
+ );
160
161
  return failurePromise;
161
162
  };
162
163
 
@@ -382,13 +383,10 @@ export async function startFaceTimeTalkDriver(params: {
382
383
  }
383
384
  return safeToClose;
384
385
  },
385
- onPlaybackDrained() {
386
- finishDrainedResponse();
387
- },
386
+ onPlaybackDrained: finishDrainedResponse,
388
387
  });
389
388
  const providerConnect = (async () => {
390
389
  let removeAbortListener: (() => void) | undefined;
391
- let readinessTimer: NodeJS.Timeout | undefined;
392
390
  const interrupted = new Promise<never>((_resolve, reject) => {
393
391
  const interrupt = () => reject(new Error("FaceTime talk startup aborted"));
394
392
  interruptProviderConnect = interrupt;
@@ -398,12 +396,6 @@ export async function startFaceTimeTalkDriver(params: {
398
396
  interrupt();
399
397
  }
400
398
  });
401
- const readinessTimedOut = new Promise<never>((_resolve, reject) => {
402
- readinessTimer = setTimeout(() => {
403
- reject(new Error("Realtime provider was not ready within 15 seconds"));
404
- }, REALTIME_READY_TIMEOUT_MS);
405
- readinessTimer.unref?.();
406
- });
407
399
  const prepareAndConnect = async () => {
408
400
  const providerResolution = resolveFaceTimeRealtimeProvider({
409
401
  config: params.config,
@@ -590,12 +582,19 @@ export async function startFaceTimeTalkDriver(params: {
590
582
  try {
591
583
  // Provider connect() may return before the server's setup-complete
592
584
  // event. onReady is the contract that the session can accept audio.
593
- await Promise.race([
594
- Promise.all([prepareAndConnect(), providerReadyDeferred.promise]),
595
- startupFailurePromise,
596
- interrupted,
597
- readinessTimedOut,
598
- ]);
585
+ await raceWithTimeout(
586
+ () =>
587
+ Promise.race([
588
+ Promise.all([prepareAndConnect(), providerReadyDeferred.promise]),
589
+ startupFailurePromise,
590
+ interrupted,
591
+ ]),
592
+ REALTIME_READY_TIMEOUT_MS,
593
+ () => {
594
+ throw new Error("Realtime provider was not ready within 15 seconds");
595
+ },
596
+ { ref: false },
597
+ );
599
598
  if (startupFailure) {
600
599
  throw startupFailure;
601
600
  }
@@ -615,9 +614,6 @@ export async function startFaceTimeTalkDriver(params: {
615
614
  }
616
615
  throw normalized;
617
616
  } finally {
618
- if (readinessTimer) {
619
- clearTimeout(readinessTimer);
620
- }
621
617
  interruptProviderConnect = undefined;
622
618
  removeAbortListener?.();
623
619
  }
@@ -650,9 +646,7 @@ export async function startFaceTimeTalkDriver(params: {
650
646
  });
651
647
  await audioReadyPromise;
652
648
  },
653
- processOutputSuppressed() {
654
- return pump?.processOutputSuppressed() ?? false;
655
- },
649
+ processOutputSuppressed: pump.processOutputSuppressed,
656
650
  realtimeActive() {
657
651
  return providerReady && !mediaSuspended && !stopped;
658
652
  },
@@ -1,4 +1,8 @@
1
- import { asRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
1
+ import {
2
+ asFiniteNumber,
3
+ asRecord,
4
+ normalizeOptionalString,
5
+ } from "openclaw/plugin-sdk/string-coerce-runtime";
2
6
 
3
7
  export type FaceTimeTalkEventSummary = {
4
8
  type: string;
@@ -11,10 +15,6 @@ export type FaceTimeTalkEventSummary = {
11
15
  message?: string;
12
16
  };
13
17
 
14
- function optionalNumber(value: unknown): number | undefined {
15
- return typeof value === "number" && Number.isFinite(value) ? value : undefined;
16
- }
17
-
18
18
  export function summarizeRecentTalkEvents(events: readonly unknown[], limit = 12) {
19
19
  return events.slice(-limit).map((event): FaceTimeTalkEventSummary => {
20
20
  const record = asRecord(event);
@@ -24,7 +24,7 @@ export function summarizeRecentTalkEvents(events: readonly unknown[], limit = 12
24
24
  turnId: normalizeOptionalString(record.turnId),
25
25
  callId: normalizeOptionalString(record.callId),
26
26
  final: typeof record.final === "boolean" ? record.final : undefined,
27
- byteLength: optionalNumber(payload.byteLength),
27
+ byteLength: asFiniteNumber(payload.byteLength),
28
28
  name: normalizeOptionalString(payload.name),
29
29
  text: normalizeOptionalString(payload.text),
30
30
  message: normalizeOptionalString(payload.message),