@openclaw/facetime 2026.10.1-beta.2 → 2026.10.5-beta.1

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,4 +1,4 @@
1
- import { l as resolveFaceTimeConfig, n as ensureCaptureBinary, r as ensureHelperArtifacts, s as installFaceTimeDriver, t as runFaceTimeSetup, u as validateFaceTimeConfig } from "./.setup/setup-zO6FazjC.mjs";
1
+ import { l as resolveFaceTimeConfig, n as ensureCaptureBinary, r as ensureHelperArtifacts, s as installFaceTimeDriver, t as runFaceTimeSetup, u as validateFaceTimeConfig } from "./.setup/setup-DpCR3Ga3.mjs";
2
2
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
3
3
  import { REALTIME_VOICE_AGENT_CONSULT_SENDER_AUTH_VERSION, REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME, REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ, buildRealtimeVoiceAgentCancelProviderResult, buildRealtimeVoiceAgentConsultPolicyInstructions, buildRealtimeVoiceAgentConsultWorkingResponse, consultRealtimeVoiceAgent, createRealtimeVoiceBridgeSession, createTalkSessionController, getRealtimeVoiceProvider, recordRealtimeVoiceTranscript, recordTalkObservabilityEvent, resolveConfiguredRealtimeVoiceProvider, resolveRealtimeVoiceAgentConsultTools, resolveRealtimeVoiceAgentConsultToolsAllow } from "openclaw/plugin-sdk/realtime-voice";
4
4
  import { asBoolean, asFiniteNumber, asRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
@@ -43,21 +43,8 @@ function normalizeCallTransport(value) {
43
43
  isVoip: asBoolean(transport.is_voip ?? transport.isVoip),
44
44
  isEmergency: asBoolean(transport.is_emergency ?? transport.isEmergency)
45
45
  };
46
- if (transport.kind === "facetime" && (transport.classifier_version === "tu-provider-v1" || transport.classifierVersion === "tu-provider-v1") && (base.service === 2 || base.service === 3) && base.providerClassified === true && base.providerIsFaceTime === true && base.providerIsTelephony === false && base.isUsingBaseband === false && base.isWifiCall === false && base.isVoip === true && base.isEmergency === false) return {
47
- kind: "facetime",
48
- classifierVersion: base.classifierVersion,
49
- service: base.service,
50
- ...base.faceTimeTransportType !== void 0 ? { faceTimeTransportType: base.faceTimeTransportType } : {},
51
- providerClassified: true,
52
- providerIsFaceTime: true,
53
- providerIsTelephony: false,
54
- isUsingBaseband: false,
55
- isWifiCall: false,
56
- isVoip: true,
57
- isEmergency: false
58
- };
59
46
  return {
60
- kind: transport.kind === "cellular" ? "cellular" : "unknown",
47
+ kind: transport.kind === "facetime" && (transport.classifier_version === "tu-provider-v1" || transport.classifierVersion === "tu-provider-v1") && (base.service === 2 || base.service === 3) && base.providerClassified === true && base.providerIsFaceTime === true && base.providerIsTelephony === false && base.isUsingBaseband === false && base.isWifiCall === false && base.isVoip === true && base.isEmergency === false ? "facetime" : transport.kind === "cellular" ? "cellular" : "unknown",
61
48
  classifierVersion: base.classifierVersion,
62
49
  ...base.service !== void 0 ? { service: base.service } : {},
63
50
  ...base.faceTimeTransportType !== void 0 ? { faceTimeTransportType: base.faceTimeTransportType } : {},
@@ -92,11 +79,8 @@ function collectHandleCandidates(value, candidates = [], seen = /* @__PURE__ */
92
79
  for (const [key, nested] of Object.entries(record)) if (handleValueKeys.has(key) || nested && typeof nested === "object") collectHandleCandidates(nested, candidates, seen);
93
80
  return candidates;
94
81
  }
95
- function normalizeFaceTimeHandleCandidates(value) {
96
- return [...new Set(collectHandleCandidates(value).map((candidate) => candidate.trim()))];
97
- }
98
82
  function normalizeFaceTimeHandle(value) {
99
- return normalizeFaceTimeHandleCandidates(value)[0];
83
+ return collectHandleCandidates(value)[0];
100
84
  }
101
85
  function canonicalizeFaceTimeHandle(value) {
102
86
  const stripped = value.trim().toLowerCase().replace(/^mailto:/, "").replace(/^tel:/, "").replace(/^facetime-audio:/, "").replace(/^facetime:/, "");
@@ -140,7 +124,7 @@ function normalizeFaceTimeCallEvent(value) {
140
124
  function resolveAuthorizedFaceTimeOwner(params) {
141
125
  if (!isVerifiedFaceTimeTransport(params.event)) return;
142
126
  const ownerHandles = new Set(params.ownerHandles.map(canonicalizeFaceTimeHandle).filter(Boolean));
143
- const senderId = normalizeFaceTimeHandleCandidates(params.event.data.handle).map(canonicalizeFaceTimeHandle).find((candidate) => ownerHandles.has(candidate));
127
+ const senderId = collectHandleCandidates(params.event.data.handle).map(canonicalizeFaceTimeHandle).find((candidate) => ownerHandles.has(candidate));
144
128
  if (!senderId) return;
145
129
  return {
146
130
  senderId,
@@ -302,7 +286,8 @@ var basePort = 45670;
302
286
  var maxPort = 65535;
303
287
  //#endregion
304
288
  //#region extensions/facetime/src/helper-endpoint.ts
305
- function resolveFaceTimeHelperEndpoint(uid = typeof process.getuid === "function" ? process.getuid() : 501) {
289
+ function resolveFaceTimeHelperEndpoint() {
290
+ const uid = typeof process.getuid === "function" ? process.getuid() : 501;
306
291
  if (host !== "127.0.0.1" || !Number.isSafeInteger(basePort) || !Number.isSafeInteger(maxPort) || basePort < 1024 || maxPort > 65535 || basePort > maxPort || !Number.isSafeInteger(uid)) throw new Error("Invalid FaceTime loopback helper endpoint contract");
307
292
  return {
308
293
  host,
@@ -759,7 +744,7 @@ const TARGET_APP_PATHS = {
759
744
  Phone: "/System/Applications/Phone.app"
760
745
  };
761
746
  const FACETIME_HELPER_TARGETS = ["FaceTime", "Phone"];
762
- const DEFAULT_RETRY_DELAYS_MS = [
747
+ const RETRY_DELAYS_MS = [
763
748
  1e3,
764
749
  2e3,
765
750
  5e3,
@@ -773,16 +758,13 @@ function targetForBundle(bundleIdentifier) {
773
758
  var FaceTimeHelperSupervisor = class {
774
759
  #states;
775
760
  #timers = /* @__PURE__ */ new Map();
776
- #retryDelaysMs;
777
761
  #injectionChain = Promise.resolve();
778
762
  #started = false;
779
763
  #generation = 0;
780
764
  #abortController = new AbortController();
781
765
  constructor(params) {
782
766
  this.params = params;
783
- this.#retryDelaysMs = params.retryDelaysMs && params.retryDelaysMs.length > 0 ? params.retryDelaysMs : DEFAULT_RETRY_DELAYS_MS;
784
- const targetAvailable = params.targetAvailable ?? ((target) => existsSync(TARGET_APP_PATHS[target]));
785
- this.#states = new Map(FACETIME_HELPER_TARGETS.filter((target) => targetAvailable(target)).map((target) => [target, {
767
+ this.#states = new Map(FACETIME_HELPER_TARGETS.filter((target) => existsSync(TARGET_APP_PATHS[target])).map((target) => [target, {
786
768
  target,
787
769
  connected: false,
788
770
  attempts: 0,
@@ -798,7 +780,7 @@ var FaceTimeHelperSupervisor = class {
798
780
  this.#generation += 1;
799
781
  this.#abortController = new AbortController();
800
782
  this.#refreshConnections();
801
- for (const target of this.#states.keys()) if (!this.#states.get(target)?.connected) this.#schedule(target, this.params.initialGraceMs ?? 6e3);
783
+ for (const target of this.#states.keys()) if (!this.#states.get(target)?.connected) this.#schedule(target, 6e3);
802
784
  }
803
785
  async stop() {
804
786
  this.#started = false;
@@ -826,7 +808,7 @@ var FaceTimeHelperSupervisor = class {
826
808
  const target = targetForBundle(bundleIdentifier);
827
809
  if (!target) return;
828
810
  this.#refreshConnections();
829
- if (this.#started && !this.#states.get(target)?.connected) this.#schedule(target, this.#retryDelaysMs[0] ?? 1e3);
811
+ if (this.#started && !this.#states.get(target)?.connected) this.#schedule(target, RETRY_DELAYS_MS[0]);
830
812
  }
831
813
  stale(bundleIdentifier, processId) {
832
814
  const target = targetForBundle(bundleIdentifier);
@@ -874,18 +856,15 @@ var FaceTimeHelperSupervisor = class {
874
856
  const timer = setTimeout(() => {
875
857
  this.#timers.delete(target);
876
858
  if (!this.#started) return;
877
- const processAlive = this.params.processAlive ?? ((candidate) => {
878
- try {
879
- process.kill(candidate, 0);
880
- return true;
881
- } catch (error) {
882
- if (error && typeof error === "object" && "code" in error) return error.code !== "ESRCH";
883
- return true;
884
- }
885
- });
886
859
  const state = this.#states.get(target);
887
860
  if (!state?.stale || state.staleProcessId !== processId) return;
888
- if (processAlive(processId)) {
861
+ let processAlive = true;
862
+ try {
863
+ process.kill(processId, 0);
864
+ } catch (error) {
865
+ processAlive = !(error && typeof error === "object" && "code" in error && error.code === "ESRCH");
866
+ }
867
+ if (processAlive) {
889
868
  this.#scheduleStaleProcessCheck(target, processId);
890
869
  return;
891
870
  }
@@ -910,7 +889,7 @@ var FaceTimeHelperSupervisor = class {
910
889
  this.#injectionChain = pending.catch(() => void 0);
911
890
  }
912
891
  async #waitForAuthenticatedConnection(target, generation) {
913
- const deadline = Date.now() + (this.params.connectionGraceMs ?? 1e4);
892
+ const deadline = Date.now() + 1e4;
914
893
  while (this.#started && generation === this.#generation && Date.now() < deadline) {
915
894
  this.#refreshConnections();
916
895
  const state = this.#states.get(target);
@@ -957,8 +936,8 @@ var FaceTimeHelperSupervisor = class {
957
936
  if (!this.#started || generation !== this.#generation) return;
958
937
  this.#refreshConnections();
959
938
  if (!state.connected && !state.stale) {
960
- const retryIndex = Math.min(state.attempts - 1, this.#retryDelaysMs.length - 1);
961
- this.#schedule(target, this.#retryDelaysMs[retryIndex] ?? 6e4);
939
+ const retryIndex = Math.min(state.attempts - 1, RETRY_DELAYS_MS.length - 1);
940
+ this.#schedule(target, RETRY_DELAYS_MS[retryIndex] ?? 6e4);
962
941
  }
963
942
  }
964
943
  };
@@ -1134,8 +1113,8 @@ const SOX_COMMAND = [
1134
1113
  const FACETIME_FEED_DEVICE_NAME = "OpenClaw-Feed";
1135
1114
  const FACETIME_MIC_DEVICE_NAME = "OpenClaw-Mic";
1136
1115
  const MAX_PLAYBACK_BUFFERED_BYTES = 2097152;
1137
- function sanitizedAudioChildEnv(env = process.env) {
1138
- return Object.fromEntries(Object.entries(env).filter(([key]) => !/(?:API_?KEY|AUTH|CREDENTIAL|PASSWORD|SECRET|TOKEN)/iu.test(key)));
1116
+ function sanitizedAudioChildEnv() {
1117
+ return Object.fromEntries(Object.entries(process.env).filter(([key]) => !/(?:API_?KEY|AUTH|CREDENTIAL|PASSWORD|SECRET|TOKEN)/iu.test(key)));
1139
1118
  }
1140
1119
  var PlaybackClock = class {
1141
1120
  constructor() {
@@ -1146,7 +1125,8 @@ var PlaybackClock = class {
1146
1125
  this.retiredFrames = 0;
1147
1126
  this.items = [];
1148
1127
  }
1149
- append(frames, itemId, nowMs = Date.now()) {
1128
+ append(frames, itemId) {
1129
+ const nowMs = Date.now();
1150
1130
  if (nowMs >= this.playbackUntilMs) {
1151
1131
  this.playedFramesBeforeSegment = this.generatedFrames;
1152
1132
  this.playbackStartsAtMs = nowMs + OUTPUT_LATENCY_BUDGET_MS;
@@ -1178,16 +1158,17 @@ var PlaybackClock = class {
1178
1158
  this.items = [];
1179
1159
  this.retiredFrames = this.generatedFrames;
1180
1160
  }
1181
- playedFrames(nowMs = Date.now()) {
1161
+ playedFrames() {
1162
+ const nowMs = Date.now();
1182
1163
  if (nowMs <= this.playbackStartsAtMs) return this.playedFramesBeforeSegment;
1183
1164
  const elapsedFrames = (nowMs - this.playbackStartsAtMs) / 1e3 * FACETIME_AUDIO_SAMPLE_RATE_HZ;
1184
1165
  return Math.min(this.generatedFrames, this.playedFramesBeforeSegment + elapsedFrames);
1185
1166
  }
1186
- queuedFrames(nowMs = Date.now()) {
1187
- return Math.max(0, this.generatedFrames - this.playedFrames(nowMs));
1167
+ queuedFrames() {
1168
+ return Math.max(0, this.generatedFrames - this.playedFrames());
1188
1169
  }
1189
- millisecondsUntilDrained(nowMs = Date.now()) {
1190
- return Math.max(0, this.playbackUntilMs - nowMs);
1170
+ millisecondsUntilDrained() {
1171
+ return Math.max(0, this.playbackUntilMs - Date.now());
1191
1172
  }
1192
1173
  reset() {
1193
1174
  this.generatedFrames = 0;
@@ -1219,6 +1200,47 @@ function buildSoxOutputArguments() {
1219
1200
  FACETIME_FEED_DEVICE_NAME
1220
1201
  ];
1221
1202
  }
1203
+ function spawnAudioProcess(process, env) {
1204
+ let command;
1205
+ let args;
1206
+ let stdio;
1207
+ switch (process.kind) {
1208
+ case "capture":
1209
+ command = process.command;
1210
+ args = [];
1211
+ stdio = [
1212
+ "pipe",
1213
+ "pipe",
1214
+ "pipe"
1215
+ ];
1216
+ break;
1217
+ case "playback":
1218
+ command = SOX_COMMAND;
1219
+ args = buildSoxOutputArguments();
1220
+ stdio = [
1221
+ "pipe",
1222
+ "ignore",
1223
+ "pipe"
1224
+ ];
1225
+ break;
1226
+ case "wake":
1227
+ command = CAFFEINATE_COMMAND;
1228
+ args = [
1229
+ "-d",
1230
+ "-i",
1231
+ ...process.capturePid ? ["-w", String(process.capturePid)] : []
1232
+ ];
1233
+ stdio = [
1234
+ "ignore",
1235
+ "ignore",
1236
+ "pipe"
1237
+ ];
1238
+ }
1239
+ return spawn(command, args, {
1240
+ env,
1241
+ stdio
1242
+ });
1243
+ }
1222
1244
  async function terminateProcess(proc, signal = "SIGTERM") {
1223
1245
  if (proc.killed && signal !== "SIGKILL") return;
1224
1246
  let exited = false;
@@ -1228,36 +1250,27 @@ async function terminateProcess(proc, signal = "SIGTERM") {
1228
1250
  resolve();
1229
1251
  });
1230
1252
  });
1231
- try {
1232
- proc.kill(signal);
1233
- } catch {
1234
- return;
1235
- }
1236
- await Promise.race([exitedPromise, sleepWithAbort(500, void 0, { ref: false })]);
1237
- if (!exited && signal !== "SIGKILL") {
1253
+ const signals = signal === "SIGKILL" ? [signal] : [signal, "SIGKILL"];
1254
+ for (const nextSignal of signals) {
1238
1255
  try {
1239
- proc.kill("SIGKILL");
1256
+ proc.kill(nextSignal);
1240
1257
  } catch {
1241
1258
  return;
1242
1259
  }
1243
1260
  await Promise.race([exitedPromise, sleepWithAbort(500, void 0, { ref: false })]);
1261
+ if (exited) return;
1244
1262
  }
1245
1263
  }
1246
1264
  function startFaceTimeAudioPump(params) {
1247
- const spawnFn = params.spawn ?? ((command, args, options) => spawn(command, args, options));
1248
1265
  const childEnv = sanitizedAudioChildEnv();
1249
1266
  const playbackClock = new PlaybackClock();
1250
1267
  let playbackGeneration = 1;
1251
1268
  let drainTimer;
1252
1269
  let outputProcess;
1253
- const captureProcess = spawnFn(params.captureBinary, [], {
1254
- env: childEnv,
1255
- stdio: [
1256
- "pipe",
1257
- "pipe",
1258
- "pipe"
1259
- ]
1260
- });
1270
+ const captureProcess = spawnAudioProcess({
1271
+ kind: "capture",
1272
+ command: params.captureBinary
1273
+ }, childEnv);
1261
1274
  let stopped = false;
1262
1275
  let mediaSuspended = false;
1263
1276
  let captureSuppressionActive = false;
@@ -1309,20 +1322,12 @@ function startFaceTimeAudioPump(params) {
1309
1322
  }
1310
1323
  };
1311
1324
  const spawnOutput = () => {
1312
- const proc = spawnFn(SOX_COMMAND, buildSoxOutputArguments(), {
1313
- env: childEnv,
1314
- stdio: [
1315
- "pipe",
1316
- "ignore",
1317
- "pipe"
1318
- ]
1319
- });
1320
- proc.on("error", (error) => {
1325
+ const proc = spawnAudioProcess({ kind: "playback" }, childEnv);
1326
+ const onError = (error) => {
1321
1327
  if (!stopped && !mediaSuspended && proc === outputProcess) reportFailure(error, false);
1322
- });
1323
- proc.stdin?.on("error", (error) => {
1324
- if (!stopped && !mediaSuspended && proc === outputProcess) reportFailure(error, false);
1325
- });
1328
+ };
1329
+ proc.on("error", onError);
1330
+ proc.stdin?.on("error", onError);
1326
1331
  proc.on("exit", (code, signal) => {
1327
1332
  if (!stopped && !mediaSuspended && proc === outputProcess) reportFailure(/* @__PURE__ */ new Error(`SoX playback exited (${code ?? signal ?? "done"})`), false);
1328
1333
  });
@@ -1371,18 +1376,10 @@ function startFaceTimeAudioPump(params) {
1371
1376
  wakeProcess ? terminateProcess(wakeProcess) : Promise.resolve()
1372
1377
  ]);
1373
1378
  };
1374
- const wakeProcess = existsSync(CAFFEINATE_COMMAND) ? spawnFn(CAFFEINATE_COMMAND, [
1375
- "-d",
1376
- "-i",
1377
- ...captureProcess.pid ? ["-w", String(captureProcess.pid)] : []
1378
- ], {
1379
- env: childEnv,
1380
- stdio: [
1381
- "ignore",
1382
- "ignore",
1383
- "pipe"
1384
- ]
1385
- }) : void 0;
1379
+ const wakeProcess = existsSync(CAFFEINATE_COMMAND) ? spawnAudioProcess({
1380
+ kind: "wake",
1381
+ capturePid: captureProcess.pid
1382
+ }, childEnv) : void 0;
1386
1383
  wakeProcess?.on("error", () => void 0);
1387
1384
  captureProcess.on("error", (error) => reportFailure(error, true));
1388
1385
  captureProcess.stdin?.on("error", (error) => reportFailure(error, false));
@@ -1822,6 +1819,81 @@ async function terminateExactCarrierProcesses(params) {
1822
1819
  }
1823
1820
  }
1824
1821
  //#endregion
1822
+ //#region extensions/facetime/src/runtime-helper-results.ts
1823
+ const OUTBOUND_DIAL_HELPER_BUNDLES = /* @__PURE__ */ new Set(["com.apple.FaceTime", "com.apple.FaceTime.FTConversationService"]);
1824
+ function readHelperPeers(result) {
1825
+ const peers = [];
1826
+ for (const entry of readHelperResults(result)) {
1827
+ const peer = entry.helperPeer;
1828
+ if (peer && typeof peer === "object" && "processId" in peer && "bundleIdentifier" in peer && "connectionGeneration" in peer && "processStartedAtMs" in peer && typeof peer.processId === "number" && typeof peer.bundleIdentifier === "string" && typeof peer.connectionGeneration === "number" && typeof peer.processStartedAtMs === "number") peers.push({
1829
+ bundleIdentifier: peer.bundleIdentifier,
1830
+ processId: peer.processId,
1831
+ processStartedAtMs: peer.processStartedAtMs,
1832
+ connectionGeneration: peer.connectionGeneration
1833
+ });
1834
+ }
1835
+ return peers;
1836
+ }
1837
+ function retainHelperResultPeers(call, result) {
1838
+ for (const peer of readHelperPeers(result)) call.carrierPeers.set(peer.processId, peer);
1839
+ }
1840
+ function retainOutboundDialHelperPeers(peers, result) {
1841
+ for (const entry of readHelperResults(result)) {
1842
+ if (entry.found === false && entry.retained_outbound_dial !== true && entry.cancelled !== true) continue;
1843
+ for (const peer of readHelperPeers(entry)) if (OUTBOUND_DIAL_HELPER_BUNDLES.has(peer.bundleIdentifier)) peers.set(peer.processId, peer);
1844
+ }
1845
+ }
1846
+ function readOutboundCallUUID(result) {
1847
+ return readHelperResults(result).map((entry) => normalizeOptionalString(entry.call_uuid)).find((value) => Boolean(value));
1848
+ }
1849
+ function readOutboundProxyIdentifier(result) {
1850
+ return readHelperResults(result).map((entry) => normalizeOptionalString(entry.proxy_identifier)).find((value) => Boolean(value));
1851
+ }
1852
+ function hasDialHelperConfirmation(results) {
1853
+ return results.some((entry) => typeof entry.helperBundleIdentifier === "string" && OUTBOUND_DIAL_HELPER_BUNDLES.has(entry.helperBundleIdentifier));
1854
+ }
1855
+ function hasDefinitiveDialHelperAbsence(result, requiredPeerProcessIds) {
1856
+ const results = readHelperResults(result);
1857
+ const observedProcessIds = new Set(readHelperPeers(result).map((peer) => peer.processId));
1858
+ return result.topologyComplete === true && results.length === result.helpersContacted && hasDialHelperConfirmation(results) && results.every((entry) => entry.found === false && entry.retained_outbound_dial !== true) && [...requiredPeerProcessIds].every((processId) => observedProcessIds.has(processId));
1859
+ }
1860
+ async function reconcilePendingFaceTimeCarrier(params) {
1861
+ const { pending } = params;
1862
+ let previousAbsentTopology;
1863
+ let previousAbsenceCurrent;
1864
+ for (let attempt = 0; attempt < 12; attempt += 1) {
1865
+ if (!params.isCurrent()) return;
1866
+ const { ownerEpoch, delivery, callUUID, proxyIdentifier } = pending;
1867
+ const aliases = new Set(pending.callUUIDAliases);
1868
+ const isSnapshotCurrent = () => params.isCurrent() && pending.ownerEpoch === ownerEpoch && pending.delivery === delivery && pending.callUUID === callUUID && pending.proxyIdentifier === proxyIdentifier && (pending.callUUIDAliases?.size ?? 0) === aliases.size && [...aliases].every((alias) => pending.callUUIDAliases?.has(alias) === true);
1869
+ const result = await params.helper.findOutgoingCall(pending.handle, callUUID, pending.dialID, proxyIdentifier, pending.requestedAt, pending.mode);
1870
+ if (!params.isCurrent()) return;
1871
+ if (!isSnapshotCurrent()) {
1872
+ previousAbsentTopology = void 0;
1873
+ previousAbsenceCurrent = void 0;
1874
+ continue;
1875
+ }
1876
+ retainOutboundDialHelperPeers(params.peers, result);
1877
+ const reconciledCallUUID = readOutboundCallUUID(result);
1878
+ const reconciledProxyIdentifier = readOutboundProxyIdentifier(result);
1879
+ if (reconciledCallUUID || reconciledProxyIdentifier) {
1880
+ retainFaceTimeDialCallUUID(pending, reconciledCallUUID);
1881
+ if (reconciledProxyIdentifier) pending.proxyIdentifier = reconciledProxyIdentifier;
1882
+ await params.persist();
1883
+ }
1884
+ if (reconciledCallUUID || reconciledProxyIdentifier || readHelperResults(result).some((entry) => entry.found === true)) return;
1885
+ const topologyGeneration = typeof result.topologyGeneration === "number" ? result.topologyGeneration : void 0;
1886
+ const completeAbsence = hasDefinitiveDialHelperAbsence(result, params.peers.keys());
1887
+ if (completeAbsence && topologyGeneration !== void 0 && topologyGeneration === previousAbsentTopology && previousAbsenceCurrent?.()) {
1888
+ await params.clear();
1889
+ return;
1890
+ }
1891
+ previousAbsentTopology = completeAbsence ? topologyGeneration : void 0;
1892
+ previousAbsenceCurrent = completeAbsence ? isSnapshotCurrent : void 0;
1893
+ if (attempt + 1 < 12) await sleep(250);
1894
+ }
1895
+ }
1896
+ //#endregion
1825
1897
  //#region extensions/facetime/src/talk-consult-controller.ts
1826
1898
  function createFaceTimeConsultController(params) {
1827
1899
  const pending = /* @__PURE__ */ new Map();
@@ -2122,7 +2194,7 @@ function createFaceTimeInitialGreeting(params) {
2122
2194
  timer = void 0;
2123
2195
  dismissed = true;
2124
2196
  params.speak(FACETIME_INITIAL_GREETING);
2125
- }, params.delayMs ?? FACETIME_GREETING_MEDIA_SETTLE_MS);
2197
+ }, FACETIME_GREETING_MEDIA_SETTLE_MS);
2126
2198
  timer.unref?.();
2127
2199
  },
2128
2200
  cancel() {
@@ -2657,14 +2729,14 @@ function createFaceTimeCallControl(params) {
2657
2729
  action: async () => await params.helper.setMuted(call.carrierCallUUID, false)
2658
2730
  });
2659
2731
  call.lastHelperAction = mutedResult;
2660
- params.retainHelperResultPeers(call, mutedResult);
2732
+ retainHelperResultPeers(call, mutedResult);
2661
2733
  projectFaceTimeNativeAction("unmute", mutedResult);
2662
2734
  const transmissionResult = await call.runCarrierCommand({
2663
2735
  generation,
2664
2736
  action: async () => await params.helper.startTransmission(call.carrierCallUUID)
2665
2737
  });
2666
2738
  call.lastHelperAction = transmissionResult;
2667
- params.retainHelperResultPeers(call, transmissionResult);
2739
+ retainHelperResultPeers(call, transmissionResult);
2668
2740
  projectFaceTimeNativeAction("activate", transmissionResult);
2669
2741
  call.markCarrierActive(generation);
2670
2742
  if (call.audioTransport) {
@@ -2679,18 +2751,13 @@ function createFaceTimeCallControl(params) {
2679
2751
  call.carrierHangupRetryTimer = void 0;
2680
2752
  }
2681
2753
  call.beginClosing();
2682
- await call.audioRouting?.catch((error) => {
2683
- params.logger.debug?.(`[facetime] audio routing cancellation for active call: ${formatErrorMessage(error)}`);
2684
- });
2685
- await call.talkStarting?.catch((error) => {
2686
- params.logger.debug?.(`[facetime] talk startup cancellation for active call: ${formatErrorMessage(error)}`);
2687
- });
2688
- await call.talk?.close(reason).catch((error) => {
2689
- params.logger.debug?.(`[facetime] talk close ignored for active call: ${formatErrorMessage(error)}`);
2690
- });
2691
- await call.talkActivation?.catch((error) => {
2692
- params.logger.debug?.(`[facetime] talk activation cancellation for active call: ${formatErrorMessage(error)}`);
2693
- });
2754
+ const logCleanupFailure = (stage) => (error) => {
2755
+ params.logger.debug?.(`[facetime] ${stage} for active call: ${formatErrorMessage(error)}`);
2756
+ };
2757
+ await call.audioRouting?.catch(logCleanupFailure("audio routing cancellation"));
2758
+ await call.talkStarting?.catch(logCleanupFailure("talk startup cancellation"));
2759
+ await call.talk?.close(reason).catch(logCleanupFailure("talk close ignored"));
2760
+ await call.talkActivation?.catch(logCleanupFailure("talk activation cancellation"));
2694
2761
  call.audioReady = false;
2695
2762
  call.audioTransport = void 0;
2696
2763
  params.calls.close(call);
@@ -2719,27 +2786,23 @@ function createFaceTimeCallControl(params) {
2719
2786
  return;
2720
2787
  }
2721
2788
  };
2722
- try {
2723
- const muted = await runCarrierActionAcrossAliases({
2724
- call,
2725
- generation,
2726
- action: "safe-mute",
2727
- run: async (callUUID) => await params.helper.safetyMute(callUUID)
2728
- });
2729
- params.retainHelperResultPeers(call, muted);
2730
- } catch (error) {
2731
- if (readCompleteAbsenceGeneration(error) === void 0) params.logger.warn(`[facetime] failed to confirm carrier safety mute: ${formatErrorMessage(error)}`);
2732
- }
2733
- try {
2734
- const leave = await runCarrierActionAcrossAliases({
2789
+ for (const [action, method, failure] of [[
2790
+ "safe-mute",
2791
+ "safetyMute",
2792
+ "failed to confirm carrier safety mute"
2793
+ ], [
2794
+ "terminate",
2795
+ "leaveCall",
2796
+ "carrier termination request failed"
2797
+ ]]) try {
2798
+ retainHelperResultPeers(call, await runCarrierActionAcrossAliases({
2735
2799
  call,
2736
2800
  generation,
2737
- action: "terminate",
2738
- run: async (callUUID) => await params.helper.leaveCall(callUUID)
2739
- });
2740
- params.retainHelperResultPeers(call, leave);
2801
+ action,
2802
+ run: async (callUUID) => await params.helper[method](callUUID)
2803
+ }));
2741
2804
  } catch (error) {
2742
- if (readCompleteAbsenceGeneration(error) === void 0) params.logger.warn(`[facetime] carrier termination request failed: ${formatErrorMessage(error)}`);
2805
+ if (readCompleteAbsenceGeneration(error) === void 0) params.logger.warn(`[facetime] ${failure}: ${formatErrorMessage(error)}`);
2743
2806
  }
2744
2807
  try {
2745
2808
  const inspect = async () => await call.runCarrierCommand({
@@ -2855,13 +2918,13 @@ function createFaceTimeCallControl(params) {
2855
2918
  if (call.talkStarting === starting) call.talkStarting = void 0;
2856
2919
  }
2857
2920
  };
2858
- const activateCallTalk = async (call, options) => {
2921
+ const activateCallTalk = async (call) => {
2859
2922
  const generation = call.captureGeneration();
2860
2923
  if (!call.talkActivation) call.talkActivation = (async () => {
2861
2924
  await call.talk?.readyForAudio();
2862
2925
  call.assertCurrent(generation);
2863
2926
  call.markModelReady(generation);
2864
- if (options.unmute) await enableCallAudio(call);
2927
+ await enableCallAudio(call);
2865
2928
  call.assertCurrent(generation);
2866
2929
  call.markModelActive(generation);
2867
2930
  call.talk?.activate();
@@ -2870,7 +2933,7 @@ function createFaceTimeCallControl(params) {
2870
2933
  try {
2871
2934
  await activation;
2872
2935
  call.assertCurrent(generation);
2873
- if (options.unmute && call.carrierMode !== "active") await enableCallAudio(call);
2936
+ if (call.carrierMode !== "active") await enableCallAudio(call);
2874
2937
  } finally {
2875
2938
  if (call.talkActivation === activation) call.talkActivation = void 0;
2876
2939
  }
@@ -2884,81 +2947,6 @@ function createFaceTimeCallControl(params) {
2884
2947
  };
2885
2948
  }
2886
2949
  //#endregion
2887
- //#region extensions/facetime/src/runtime-helper-results.ts
2888
- const OUTBOUND_DIAL_HELPER_BUNDLES = /* @__PURE__ */ new Set(["com.apple.FaceTime", "com.apple.FaceTime.FTConversationService"]);
2889
- function readHelperPeers(result) {
2890
- const peers = [];
2891
- for (const entry of readHelperResults(result)) {
2892
- const peer = entry.helperPeer;
2893
- if (peer && typeof peer === "object" && "processId" in peer && "bundleIdentifier" in peer && "connectionGeneration" in peer && "processStartedAtMs" in peer && typeof peer.processId === "number" && typeof peer.bundleIdentifier === "string" && typeof peer.connectionGeneration === "number" && typeof peer.processStartedAtMs === "number") peers.push({
2894
- bundleIdentifier: peer.bundleIdentifier,
2895
- processId: peer.processId,
2896
- processStartedAtMs: peer.processStartedAtMs,
2897
- connectionGeneration: peer.connectionGeneration
2898
- });
2899
- }
2900
- return peers;
2901
- }
2902
- function retainHelperResultPeers(call, result) {
2903
- for (const peer of readHelperPeers(result)) call.carrierPeers.set(peer.processId, peer);
2904
- }
2905
- function retainOutboundDialHelperPeers(peers, result) {
2906
- for (const entry of readHelperResults(result)) {
2907
- if (entry.found === false && entry.retained_outbound_dial !== true && entry.cancelled !== true) continue;
2908
- for (const peer of readHelperPeers(entry)) if (OUTBOUND_DIAL_HELPER_BUNDLES.has(peer.bundleIdentifier)) peers.set(peer.processId, peer);
2909
- }
2910
- }
2911
- function readOutboundCallUUID(result) {
2912
- return readHelperResults(result).map((entry) => normalizeOptionalString(entry.call_uuid)).find((value) => Boolean(value));
2913
- }
2914
- function readOutboundProxyIdentifier(result) {
2915
- return readHelperResults(result).map((entry) => normalizeOptionalString(entry.proxy_identifier)).find((value) => Boolean(value));
2916
- }
2917
- function hasDialHelperConfirmation(results) {
2918
- return results.some((entry) => typeof entry.helperBundleIdentifier === "string" && OUTBOUND_DIAL_HELPER_BUNDLES.has(entry.helperBundleIdentifier));
2919
- }
2920
- function hasDefinitiveDialHelperAbsence(result, requiredPeerProcessIds) {
2921
- const results = readHelperResults(result);
2922
- const observedProcessIds = new Set(readHelperPeers(result).map((peer) => peer.processId));
2923
- return result.topologyComplete === true && results.length === result.helpersContacted && hasDialHelperConfirmation(results) && results.every((entry) => entry.found === false && entry.retained_outbound_dial !== true) && [...requiredPeerProcessIds].every((processId) => observedProcessIds.has(processId));
2924
- }
2925
- async function reconcilePendingFaceTimeCarrier(params) {
2926
- const { pending } = params;
2927
- let previousAbsentTopology;
2928
- let previousAbsenceCurrent;
2929
- for (let attempt = 0; attempt < 12; attempt += 1) {
2930
- if (!params.isCurrent()) return;
2931
- const { ownerEpoch, delivery, callUUID, proxyIdentifier } = pending;
2932
- const aliases = new Set(pending.callUUIDAliases);
2933
- const isSnapshotCurrent = () => params.isCurrent() && pending.ownerEpoch === ownerEpoch && pending.delivery === delivery && pending.callUUID === callUUID && pending.proxyIdentifier === proxyIdentifier && (pending.callUUIDAliases?.size ?? 0) === aliases.size && [...aliases].every((alias) => pending.callUUIDAliases?.has(alias) === true);
2934
- const result = await params.helper.findOutgoingCall(pending.handle, callUUID, pending.dialID, proxyIdentifier, pending.requestedAt, pending.mode);
2935
- if (!params.isCurrent()) return;
2936
- if (!isSnapshotCurrent()) {
2937
- previousAbsentTopology = void 0;
2938
- previousAbsenceCurrent = void 0;
2939
- continue;
2940
- }
2941
- retainOutboundDialHelperPeers(params.peers, result);
2942
- const reconciledCallUUID = readOutboundCallUUID(result);
2943
- const reconciledProxyIdentifier = readOutboundProxyIdentifier(result);
2944
- if (reconciledCallUUID || reconciledProxyIdentifier) {
2945
- retainFaceTimeDialCallUUID(pending, reconciledCallUUID);
2946
- if (reconciledProxyIdentifier) pending.proxyIdentifier = reconciledProxyIdentifier;
2947
- await params.persist();
2948
- }
2949
- if (reconciledCallUUID || reconciledProxyIdentifier || readHelperResults(result).some((entry) => entry.found === true)) return;
2950
- const topologyGeneration = typeof result.topologyGeneration === "number" ? result.topologyGeneration : void 0;
2951
- const completeAbsence = hasDefinitiveDialHelperAbsence(result, params.peers.keys());
2952
- if (completeAbsence && topologyGeneration !== void 0 && topologyGeneration === previousAbsentTopology && previousAbsenceCurrent?.()) {
2953
- await params.clear();
2954
- return;
2955
- }
2956
- previousAbsentTopology = completeAbsence ? topologyGeneration : void 0;
2957
- previousAbsenceCurrent = completeAbsence ? isSnapshotCurrent : void 0;
2958
- if (attempt + 1 < 12) await sleep(250);
2959
- }
2960
- }
2961
- //#endregion
2962
2950
  //#region extensions/facetime/src/runtime-state.ts
2963
2951
  var ActiveFaceTimeCall = class extends FaceTimeCallInstance {
2964
2952
  constructor(params) {
@@ -3084,7 +3072,7 @@ function createFaceTimeCallEventHandler(params) {
3084
3072
  });
3085
3073
  projectFaceTimeNativeAction("answer", answerResult);
3086
3074
  retainHelperResultPeers(call, answerResult);
3087
- await params.callControl.activateCallTalk(call, { unmute: true });
3075
+ await params.callControl.activateCallTalk(call);
3088
3076
  params.logger.info("[facetime] answered authorized FaceTime call");
3089
3077
  } catch (error) {
3090
3078
  params.logger.warn(`[facetime] failed to answer FaceTime call: ${formatErrorMessage(error)}`);
@@ -3129,7 +3117,7 @@ function createFaceTimeCallEventHandler(params) {
3129
3117
  updateCallStatus(call, event);
3130
3118
  try {
3131
3119
  await params.callControl.startCallTalk(call);
3132
- await params.callControl.activateCallTalk(call, { unmute: true });
3120
+ await params.callControl.activateCallTalk(call);
3133
3121
  params.logger.info("[facetime] realtime talk session active");
3134
3122
  } catch (error) {
3135
3123
  if (call.lifecycleAbort.signal.aborted || params.calls.active !== call) return;
@@ -3252,8 +3240,8 @@ function createFaceTimeCallEventHandler(params) {
3252
3240
  }
3253
3241
  //#endregion
3254
3242
  //#region extensions/facetime/src/talk-events-summary.ts
3255
- function summarizeRecentTalkEvents(events, limit = 12) {
3256
- return events.slice(-limit).map((event) => {
3243
+ function summarizeRecentTalkEvents(events) {
3244
+ return events.slice(-12).map((event) => {
3257
3245
  const record = asRecord(event);
3258
3246
  const payload = asRecord(record.payload);
3259
3247
  return {
@@ -3514,8 +3502,7 @@ async function createFaceTimeRuntime(params) {
3514
3502
  logger: params.logger,
3515
3503
  captureBinary,
3516
3504
  isStopping: () => stopping,
3517
- getHelperTopologyVersion: () => helperTopologyVersion,
3518
- retainHelperResultPeers
3505
+ getHelperTopologyVersion: () => helperTopologyVersion
3519
3506
  });
3520
3507
  const { attemptCarrierHangup, stopCall } = callControl;
3521
3508
  const callEvents = createFaceTimeCallEventHandler({
@@ -3548,7 +3535,6 @@ async function createFaceTimeRuntime(params) {
3548
3535
  config,
3549
3536
  fullConfig: params.fullConfig,
3550
3537
  runtime: params.runtime,
3551
- logger: params.logger,
3552
3538
  helperConnected: helper.connectedSockets > 0,
3553
3539
  captureBinary
3554
3540
  });
@@ -3687,7 +3673,6 @@ async function createFaceTimeRuntime(params) {
3687
3673
  driverInstallTask = installFaceTimeDriver({
3688
3674
  pluginRoot: params.pluginRoot,
3689
3675
  runCommandWithTimeout: params.runtime.system.runCommandWithTimeout,
3690
- callActive: false,
3691
3676
  signal: installAbortController.signal
3692
3677
  }).then((result) => {
3693
3678
  driverInstall = {