@openclaw/facetime 2026.10.5-beta.3 → 2026.10.10-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.
- package/README.md +3 -2
- package/dist/.setup/{setup-DpCR3Ga3.mjs → setup-DMPG615Z.mjs} +13 -23
- package/dist/index.js +1 -1
- package/dist/runtime-api.js +72 -107
- package/node_modules/typebox/build/value/clean/from_object.mjs +1 -1
- package/node_modules/typebox/package.json +1 -1
- package/package.json +6 -6
- package/scripts/install-driver-root.sh +1 -8
- package/scripts/install-driver.applescript +1 -1
- package/src/audio-pump.ts +45 -58
- package/src/call-lifecycle.ts +2 -17
- package/src/helper-supervisor.ts +10 -17
- package/src/pending-dial-store.ts +18 -25
- package/src/preflight.ts +2 -14
- package/src/runtime-call-control.ts +1 -1
- package/src/runtime-call-events.ts +2 -2
- package/src/runtime-carrier-process.ts +1 -3
- package/src/runtime.ts +2 -2
- package/src/setup.ts +17 -28
- package/src/talk-driver-config.ts +2 -11
- package/src/talk-driver.ts +0 -4
package/README.md
CHANGED
|
@@ -25,10 +25,11 @@ openclaw gateway restart
|
|
|
25
25
|
Runtime startup, helper dispatch, and shutdown await the required publications.
|
|
26
26
|
Pending outbound calls reserve admission while persistence waits, preserving the
|
|
27
27
|
same incoming-call policy before and after durable publication.
|
|
28
|
+
The plugin releases with its host and requires the host's V2 state API.
|
|
28
29
|
- `src/helper-rpc.ts` owns bounded loopback IPC with mutual authentication,
|
|
29
30
|
connection-epoch message MACs, replay sequencing, and typed native
|
|
30
31
|
postcondition projection.
|
|
31
|
-
- `src/helper-supervisor.ts` owns
|
|
32
|
+
- `src/helper-supervisor.ts` owns serialized LLDB injection and joins
|
|
32
33
|
in-flight work on stop.
|
|
33
34
|
- `src/audio-pump.ts` owns bounded native capture, SoX playback, and child
|
|
34
35
|
teardown.
|
|
@@ -74,7 +75,7 @@ tools, or modify TCC during automated validation.
|
|
|
74
75
|
The privileged driver script pins BlackHole v0.7.1 and its SHA-256, builds the
|
|
75
76
|
renamed `OpenClawBridge.driver` in a root-only temporary directory, and accepts
|
|
76
77
|
no caller-built artifact, digest, or compiler path. Before compilation it
|
|
77
|
-
requires the
|
|
78
|
+
requires the Xcode bundle at its actual filesystem path and its selected build tools to be
|
|
78
79
|
Apple-signed, root-owned, and not group/world writable, then performs a
|
|
79
80
|
transactional swap. Generated BlackHole/driver artifacts are GPL-3.0 and are
|
|
80
81
|
excluded from the package. See [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md).
|
|
@@ -348,6 +348,8 @@ async function checkFocusMode() {
|
|
|
348
348
|
}
|
|
349
349
|
async function checkNotificationsDuringSharing(runCommandWithTimeout) {
|
|
350
350
|
const script = "/usr/bin/defaults export com.apple.ncprefs - 2>/dev/null | /usr/bin/plutil -extract dnd_prefs raw -o - - | /usr/bin/base64 --decode | /usr/bin/plutil -extract dndMirrored raw -o - -";
|
|
351
|
+
let ready = false;
|
|
352
|
+
let message;
|
|
351
353
|
try {
|
|
352
354
|
const result = await runCommandWithTimeout([
|
|
353
355
|
"/bin/bash",
|
|
@@ -355,31 +357,19 @@ async function checkNotificationsDuringSharing(runCommandWithTimeout) {
|
|
|
355
357
|
script
|
|
356
358
|
], { timeoutMs: 5e3 });
|
|
357
359
|
const value = firstLine(result.stdout)?.toLowerCase();
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
label: "Notifications while sharing the display",
|
|
361
|
-
status: "ready",
|
|
362
|
-
required: true,
|
|
363
|
-
message: "Notifications are allowed while mirroring or sharing the display"
|
|
364
|
-
};
|
|
365
|
-
return {
|
|
366
|
-
id: "notifications-while-sharing",
|
|
367
|
-
label: "Notifications while sharing the display",
|
|
368
|
-
status: "action-required",
|
|
369
|
-
required: true,
|
|
370
|
-
message: value === "false" ? "Incoming call notifications are suppressed while mirroring or sharing the display" : "Could not verify the notification setting used during display sharing",
|
|
371
|
-
actionId: "allow-sharing-notifications"
|
|
372
|
-
};
|
|
360
|
+
ready = result.code === 0 && value === "true";
|
|
361
|
+
message = ready ? "Notifications are allowed while mirroring or sharing the display" : value === "false" ? "Incoming call notifications are suppressed while mirroring or sharing the display" : "Could not verify the notification setting used during display sharing";
|
|
373
362
|
} catch (error) {
|
|
374
|
-
|
|
375
|
-
id: "notifications-while-sharing",
|
|
376
|
-
label: "Notifications while sharing the display",
|
|
377
|
-
status: "action-required",
|
|
378
|
-
required: true,
|
|
379
|
-
message: `Could not verify notification behavior: ${formatErrorMessage(error)}`,
|
|
380
|
-
actionId: "allow-sharing-notifications"
|
|
381
|
-
};
|
|
363
|
+
message = `Could not verify notification behavior: ${formatErrorMessage(error)}`;
|
|
382
364
|
}
|
|
365
|
+
return {
|
|
366
|
+
id: "notifications-while-sharing",
|
|
367
|
+
label: "Notifications while sharing the display",
|
|
368
|
+
status: ready ? "ready" : "action-required",
|
|
369
|
+
required: true,
|
|
370
|
+
message,
|
|
371
|
+
...!ready ? { actionId: "allow-sharing-notifications" } : {}
|
|
372
|
+
};
|
|
383
373
|
}
|
|
384
374
|
async function checkCommand(runCommandWithTimeout, argv, readyMessage) {
|
|
385
375
|
try {
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as inspectFaceTimeNativePackage, c as uninstallFaceTimeDriver, i as inspectFaceTimeArtifacts, l as resolveFaceTimeConfig, o as inspectFaceTimeDriver, t as runFaceTimeSetup, u as validateFaceTimeConfig } from "./.setup/setup-
|
|
1
|
+
import { a as inspectFaceTimeNativePackage, c as uninstallFaceTimeDriver, i as inspectFaceTimeArtifacts, l as resolveFaceTimeConfig, o as inspectFaceTimeDriver, t as runFaceTimeSetup, u as validateFaceTimeConfig } from "./.setup/setup-DMPG615Z.mjs";
|
|
2
2
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
3
3
|
import { ErrorCodes, errorShape } from "openclaw/plugin-sdk/gateway-runtime";
|
|
4
4
|
import { definePluginEntry } from "openclaw/plugin-sdk/plugin-entry";
|
package/dist/runtime-api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { l as resolveFaceTimeConfig, n as ensureCaptureBinary, r as ensureHelperArtifacts, s as installFaceTimeDriver, t as runFaceTimeSetup, u as validateFaceTimeConfig } from "./.setup/setup-
|
|
1
|
+
import { l as resolveFaceTimeConfig, n as ensureCaptureBinary, r as ensureHelperArtifacts, s as installFaceTimeDriver, t as runFaceTimeSetup, u as validateFaceTimeConfig } from "./.setup/setup-DMPG615Z.mjs";
|
|
2
2
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME, REALTIME_VOICE_AUDIO_FORMAT_PCM16_24KHZ, buildRealtimeVoiceAgentCancelProviderResult, buildRealtimeVoiceAgentConsultPolicyInstructions, buildRealtimeVoiceAgentConsultWorkingResponse, consultRealtimeVoiceAgent, createRealtimeVoiceBridgeSession, createTalkSessionController, getRealtimeVoiceProvider, recordRealtimeVoiceTranscript, recordTalkObservabilityEvent, resolveConfiguredRealtimeVoiceProviderAsync, resolveRealtimeVoiceAgentConsultTools, resolveRealtimeVoiceAgentConsultToolsAllow } from "openclaw/plugin-sdk/realtime-voice";
|
|
4
4
|
import { asBoolean, asFiniteNumber, asRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
5
5
|
import { resolve } from "node:path";
|
|
6
6
|
import { constants, existsSync } from "node:fs";
|
|
@@ -243,7 +243,6 @@ var FaceTimeCallInstance = class {
|
|
|
243
243
|
};
|
|
244
244
|
var FaceTimeCallRegistry = class {
|
|
245
245
|
#active;
|
|
246
|
-
#aliases = /* @__PURE__ */ new Map();
|
|
247
246
|
get active() {
|
|
248
247
|
return this.#active;
|
|
249
248
|
}
|
|
@@ -254,7 +253,7 @@ var FaceTimeCallRegistry = class {
|
|
|
254
253
|
return (this.#active && this.#active.phase !== "closed" ? [this.#active] : [])[Symbol.iterator]();
|
|
255
254
|
}
|
|
256
255
|
get(identity) {
|
|
257
|
-
return this.#aliases.
|
|
256
|
+
return this.#active?.aliases.has(normalizeCallIdentity(identity)) ? this.#active : void 0;
|
|
258
257
|
}
|
|
259
258
|
has(identity) {
|
|
260
259
|
return this.get(identity) !== void 0;
|
|
@@ -262,20 +261,14 @@ var FaceTimeCallRegistry = class {
|
|
|
262
261
|
create(call) {
|
|
263
262
|
if (this.#active && this.#active.phase !== "closed") throw new Error("another FaceTime call lifecycle is already active");
|
|
264
263
|
this.#active = call;
|
|
265
|
-
for (const alias of call.aliases) this.#aliases.set(alias, call);
|
|
266
264
|
}
|
|
267
265
|
retainAlias(call, identity) {
|
|
268
266
|
if (this.#active !== call || call.phase === "closed") throw new Error("cannot retain an alias for an inactive FaceTime call");
|
|
269
|
-
|
|
270
|
-
const existing = this.#aliases.get(alias);
|
|
271
|
-
if (existing && existing !== call) throw new Error("FaceTime call alias already belongs to another lifecycle");
|
|
272
|
-
call.aliases.add(alias);
|
|
273
|
-
this.#aliases.set(alias, call);
|
|
267
|
+
call.aliases.add(normalizeCallIdentity(identity));
|
|
274
268
|
}
|
|
275
269
|
close(call) {
|
|
276
270
|
if (this.#active !== call) return;
|
|
277
271
|
call.markClosed();
|
|
278
|
-
for (const alias of call.aliases) if (this.#aliases.get(alias) === call) this.#aliases.delete(alias);
|
|
279
272
|
this.#active = void 0;
|
|
280
273
|
}
|
|
281
274
|
};
|
|
@@ -760,7 +753,6 @@ var FaceTimeHelperSupervisor = class {
|
|
|
760
753
|
#timers = /* @__PURE__ */ new Map();
|
|
761
754
|
#injectionChain = Promise.resolve();
|
|
762
755
|
#started = false;
|
|
763
|
-
#generation = 0;
|
|
764
756
|
#abortController = new AbortController();
|
|
765
757
|
constructor(params) {
|
|
766
758
|
this.params = params;
|
|
@@ -777,14 +769,12 @@ var FaceTimeHelperSupervisor = class {
|
|
|
777
769
|
start() {
|
|
778
770
|
if (this.#started) return;
|
|
779
771
|
this.#started = true;
|
|
780
|
-
this.#generation += 1;
|
|
781
772
|
this.#abortController = new AbortController();
|
|
782
773
|
this.#refreshConnections();
|
|
783
774
|
for (const target of this.#states.keys()) if (!this.#states.get(target)?.connected) this.#schedule(target, 6e3);
|
|
784
775
|
}
|
|
785
776
|
async stop() {
|
|
786
777
|
this.#started = false;
|
|
787
|
-
this.#generation += 1;
|
|
788
778
|
this.#abortController.abort(/* @__PURE__ */ new Error("FaceTime helper supervisor stopped"));
|
|
789
779
|
for (const timer of this.#timers.values()) clearTimeout(timer);
|
|
790
780
|
this.#timers.clear();
|
|
@@ -881,16 +871,15 @@ var FaceTimeHelperSupervisor = class {
|
|
|
881
871
|
const state = this.#states.get(target);
|
|
882
872
|
if (!state || state.queued || state.injecting) return;
|
|
883
873
|
state.queued = true;
|
|
884
|
-
const generation = this.#generation;
|
|
885
874
|
const pending = this.#injectionChain.then(async () => {
|
|
886
875
|
state.queued = false;
|
|
887
|
-
if (this.#started
|
|
876
|
+
if (this.#started) await this.#inject(target);
|
|
888
877
|
});
|
|
889
878
|
this.#injectionChain = pending.catch(() => void 0);
|
|
890
879
|
}
|
|
891
|
-
async #waitForAuthenticatedConnection(target
|
|
880
|
+
async #waitForAuthenticatedConnection(target) {
|
|
892
881
|
const deadline = Date.now() + 1e4;
|
|
893
|
-
while (this.#started &&
|
|
882
|
+
while (this.#started && Date.now() < deadline) {
|
|
894
883
|
this.#refreshConnections();
|
|
895
884
|
const state = this.#states.get(target);
|
|
896
885
|
if (!state || state.connected || state.stale) return;
|
|
@@ -898,8 +887,8 @@ var FaceTimeHelperSupervisor = class {
|
|
|
898
887
|
}
|
|
899
888
|
this.#refreshConnections();
|
|
900
889
|
}
|
|
901
|
-
async #inject(target
|
|
902
|
-
if (!this.#started
|
|
890
|
+
async #inject(target) {
|
|
891
|
+
if (!this.#started) return;
|
|
903
892
|
this.#refreshConnections();
|
|
904
893
|
const state = this.#states.get(target);
|
|
905
894
|
if (!state || state.connected || state.injecting || state.stale) return;
|
|
@@ -917,23 +906,23 @@ var FaceTimeHelperSupervisor = class {
|
|
|
917
906
|
signal: this.#abortController.signal,
|
|
918
907
|
killProcessTree: true
|
|
919
908
|
});
|
|
920
|
-
if (!this.#started
|
|
909
|
+
if (!this.#started) return;
|
|
921
910
|
if (result.code !== 0) throw new Error(result.stderr || result.stdout || `exit ${result.code}`);
|
|
922
911
|
state.lastError = void 0;
|
|
923
912
|
this.params.logger.info(`[facetime] injected helper into ${target}`);
|
|
924
913
|
if (!state.connected && !state.stale) {
|
|
925
|
-
await this.#waitForAuthenticatedConnection(target
|
|
914
|
+
await this.#waitForAuthenticatedConnection(target);
|
|
926
915
|
if (!state.connected && !state.stale) throw new Error(`${target} helper injection completed but no authenticated connection arrived`);
|
|
927
916
|
}
|
|
928
917
|
} catch (error) {
|
|
929
|
-
if (this.#started
|
|
918
|
+
if (this.#started) {
|
|
930
919
|
state.lastError = formatErrorMessage(error);
|
|
931
920
|
this.params.logger.warn(`[facetime] ${target} helper injection failed: ${state.lastError}`);
|
|
932
921
|
}
|
|
933
922
|
} finally {
|
|
934
923
|
state.injecting = false;
|
|
935
924
|
}
|
|
936
|
-
if (!this.#started
|
|
925
|
+
if (!this.#started) return;
|
|
937
926
|
this.#refreshConnections();
|
|
938
927
|
if (!state.connected && !state.stale) {
|
|
939
928
|
const retryIndex = Math.min(state.attempts - 1, RETRY_DELAYS_MS.length - 1);
|
|
@@ -1041,6 +1030,17 @@ var PendingFaceTimeDialStore = class {
|
|
|
1041
1030
|
constructor(store) {
|
|
1042
1031
|
this.store = store;
|
|
1043
1032
|
}
|
|
1033
|
+
async #deleteMatching(expectedDialID) {
|
|
1034
|
+
let observation = await this.store.observe(PENDING_DIAL_KEY);
|
|
1035
|
+
for (;;) {
|
|
1036
|
+
const result = await this.store.compareAndApply(PENDING_DIAL_KEY, observation.comparison, {
|
|
1037
|
+
operation: "delete",
|
|
1038
|
+
action: observation.value?.dialID === expectedDialID ? "delete" : "keep"
|
|
1039
|
+
});
|
|
1040
|
+
if (result.status !== "conflict") return result.status === "applied";
|
|
1041
|
+
observation = result.current;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
1044
|
#enqueue(operation) {
|
|
1045
1045
|
const pending = this.#tail.then(operation);
|
|
1046
1046
|
this.#tail = pending.then(() => void 0, () => void 0);
|
|
@@ -1062,22 +1062,7 @@ var PendingFaceTimeDialStore = class {
|
|
|
1062
1062
|
clear(expectedDialID) {
|
|
1063
1063
|
const existing = this.#clearing.get(expectedDialID);
|
|
1064
1064
|
if (existing) return existing;
|
|
1065
|
-
const clearing = this.#enqueue(
|
|
1066
|
-
const { observe, compareAndApply } = this.store;
|
|
1067
|
-
if (!observe || !compareAndApply) {
|
|
1068
|
-
if (!this.store.deleteIf) throw new Error("FaceTime pending dial cleanup requires atomic plugin-state deletion");
|
|
1069
|
-
return this.store.deleteIf(PENDING_DIAL_KEY, (current) => current.dialID === expectedDialID);
|
|
1070
|
-
}
|
|
1071
|
-
let observation = await observe(PENDING_DIAL_KEY);
|
|
1072
|
-
for (;;) {
|
|
1073
|
-
const result = await compareAndApply(PENDING_DIAL_KEY, observation.comparison, {
|
|
1074
|
-
operation: "delete",
|
|
1075
|
-
action: observation.value?.dialID === expectedDialID ? "delete" : "keep"
|
|
1076
|
-
});
|
|
1077
|
-
if (result.status !== "conflict") return result.status === "applied";
|
|
1078
|
-
observation = result.current;
|
|
1079
|
-
}
|
|
1080
|
-
}).finally(() => this.#clearing.delete(expectedDialID));
|
|
1065
|
+
const clearing = this.#enqueue(() => this.#deleteMatching(expectedDialID)).finally(() => this.#clearing.delete(expectedDialID));
|
|
1081
1066
|
this.#clearing.set(expectedDialID, clearing);
|
|
1082
1067
|
return clearing;
|
|
1083
1068
|
}
|
|
@@ -1261,6 +1246,28 @@ async function terminateProcess(proc, signal = "SIGTERM") {
|
|
|
1261
1246
|
if (exited) return;
|
|
1262
1247
|
}
|
|
1263
1248
|
}
|
|
1249
|
+
function createAudioReadiness() {
|
|
1250
|
+
const deferred = createDeferred();
|
|
1251
|
+
let settled = false;
|
|
1252
|
+
let timer;
|
|
1253
|
+
deferred.promise.catch(() => {});
|
|
1254
|
+
return {
|
|
1255
|
+
promise: deferred.promise,
|
|
1256
|
+
start(timeoutMs, onTimeout) {
|
|
1257
|
+
if (settled || timer) return;
|
|
1258
|
+
timer = setTimeout(onTimeout, timeoutMs);
|
|
1259
|
+
timer.unref?.();
|
|
1260
|
+
},
|
|
1261
|
+
settle(error) {
|
|
1262
|
+
if (settled) return;
|
|
1263
|
+
settled = true;
|
|
1264
|
+
clearTimeout(timer);
|
|
1265
|
+
timer = void 0;
|
|
1266
|
+
if (error) deferred.reject(error);
|
|
1267
|
+
else deferred.resolve();
|
|
1268
|
+
}
|
|
1269
|
+
};
|
|
1270
|
+
}
|
|
1264
1271
|
function startFaceTimeAudioPump(params) {
|
|
1265
1272
|
const childEnv = sanitizedAudioChildEnv();
|
|
1266
1273
|
const playbackClock = new PlaybackClock();
|
|
@@ -1275,41 +1282,17 @@ function startFaceTimeAudioPump(params) {
|
|
|
1275
1282
|
let mediaSuspended = false;
|
|
1276
1283
|
let captureSuppressionActive = false;
|
|
1277
1284
|
let captureFailureReported = false;
|
|
1278
|
-
let captureReadySettled = false;
|
|
1279
|
-
let routeReadySettled = false;
|
|
1280
|
-
let routeReadyTimer;
|
|
1281
1285
|
let captureStderr = "";
|
|
1282
|
-
const captureReady =
|
|
1283
|
-
const routeReady =
|
|
1284
|
-
const captureReadyPromise = captureReady.promise;
|
|
1285
|
-
const routeReadyPromise = routeReady.promise;
|
|
1286
|
-
captureReadyPromise.catch(() => {});
|
|
1287
|
-
routeReadyPromise.catch(() => {});
|
|
1288
|
-
const settleCaptureReady = (error) => {
|
|
1289
|
-
if (captureReadySettled) return;
|
|
1290
|
-
captureReadySettled = true;
|
|
1291
|
-
clearTimeout(captureReadyTimer);
|
|
1292
|
-
if (error) captureReady.reject(error);
|
|
1293
|
-
else captureReady.resolve();
|
|
1294
|
-
};
|
|
1295
|
-
const settleRouteReady = (error) => {
|
|
1296
|
-
if (routeReadySettled) return;
|
|
1297
|
-
routeReadySettled = true;
|
|
1298
|
-
if (routeReadyTimer) {
|
|
1299
|
-
clearTimeout(routeReadyTimer);
|
|
1300
|
-
routeReadyTimer = void 0;
|
|
1301
|
-
}
|
|
1302
|
-
if (error) routeReady.reject(error);
|
|
1303
|
-
else routeReady.resolve();
|
|
1304
|
-
};
|
|
1286
|
+
const captureReady = createAudioReadiness();
|
|
1287
|
+
const routeReady = createAudioReadiness();
|
|
1305
1288
|
const reportFailure = (error, suppressionLost) => {
|
|
1306
1289
|
if (stopped) return;
|
|
1307
1290
|
if (suppressionLost) {
|
|
1308
1291
|
captureSuppressionActive = false;
|
|
1309
1292
|
params.onSuppressionLost?.(error);
|
|
1310
1293
|
}
|
|
1311
|
-
|
|
1312
|
-
|
|
1294
|
+
captureReady.settle(error);
|
|
1295
|
+
routeReady.settle(error);
|
|
1313
1296
|
params.logger.warn(`[facetime] native audio bridge failed: ${formatErrorMessage(error)}`);
|
|
1314
1297
|
Promise.resolve(params.onError?.(error)).then((safeToStop) => {
|
|
1315
1298
|
if (safeToStop !== false) stop();
|
|
@@ -1337,17 +1320,9 @@ function startFaceTimeAudioPump(params) {
|
|
|
1337
1320
|
return proc;
|
|
1338
1321
|
};
|
|
1339
1322
|
outputProcess = spawnOutput();
|
|
1340
|
-
|
|
1323
|
+
captureReady.start(1e4, () => {
|
|
1341
1324
|
reportFailure(/* @__PURE__ */ new Error("FaceTime process tap was not ready within 10 seconds"), true);
|
|
1342
|
-
}
|
|
1343
|
-
captureReadyTimer.unref?.();
|
|
1344
|
-
const startRouteReadyTimer = () => {
|
|
1345
|
-
if (routeReadySettled || routeReadyTimer) return;
|
|
1346
|
-
routeReadyTimer = setTimeout(() => {
|
|
1347
|
-
reportFailure(/* @__PURE__ */ new Error("FaceTime input route was not verified within 15 seconds"), true);
|
|
1348
|
-
}, 15e3);
|
|
1349
|
-
routeReadyTimer.unref?.();
|
|
1350
|
-
};
|
|
1325
|
+
});
|
|
1351
1326
|
const clearPlayback = () => {
|
|
1352
1327
|
if (stopped || mediaSuspended) return;
|
|
1353
1328
|
const previous = outputProcess;
|
|
@@ -1361,8 +1336,8 @@ function startFaceTimeAudioPump(params) {
|
|
|
1361
1336
|
if (stopped) return;
|
|
1362
1337
|
mediaSuspended = true;
|
|
1363
1338
|
captureSuppressionActive = false;
|
|
1364
|
-
|
|
1365
|
-
|
|
1339
|
+
captureReady.settle(/* @__PURE__ */ new Error("FaceTime native audio bridge stopped before readiness"));
|
|
1340
|
+
routeReady.settle(/* @__PURE__ */ new Error("FaceTime input route stopped before verification"));
|
|
1366
1341
|
cancelDrainTimer();
|
|
1367
1342
|
playbackClock.reset();
|
|
1368
1343
|
try {
|
|
@@ -1391,9 +1366,9 @@ function startFaceTimeAudioPump(params) {
|
|
|
1391
1366
|
for (const line of captureStderr.split(/\r?\n/u).slice(0, -1)) {
|
|
1392
1367
|
if (line.includes("started FaceTime process tap")) {
|
|
1393
1368
|
captureSuppressionActive = true;
|
|
1394
|
-
|
|
1369
|
+
captureReady.settle();
|
|
1395
1370
|
}
|
|
1396
|
-
if (line.includes("verified OpenClaw-Mic input route"))
|
|
1371
|
+
if (line.includes("verified OpenClaw-Mic input route")) routeReady.settle();
|
|
1397
1372
|
const fatal = line.match(/facetime-audio-capture: fatal(?:-safety-retained)?:\s*(.*)$/u);
|
|
1398
1373
|
if (!captureFailureReported && fatal) {
|
|
1399
1374
|
captureFailureReported = true;
|
|
@@ -1410,10 +1385,12 @@ function startFaceTimeAudioPump(params) {
|
|
|
1410
1385
|
}
|
|
1411
1386
|
});
|
|
1412
1387
|
return {
|
|
1413
|
-
suppressionReady: async () => await
|
|
1388
|
+
suppressionReady: async () => await captureReady.promise,
|
|
1414
1389
|
routeReady: async () => {
|
|
1415
|
-
|
|
1416
|
-
|
|
1390
|
+
routeReady.start(15e3, () => {
|
|
1391
|
+
reportFailure(/* @__PURE__ */ new Error("FaceTime input route was not verified within 15 seconds"), true);
|
|
1392
|
+
});
|
|
1393
|
+
await routeReady.promise;
|
|
1417
1394
|
},
|
|
1418
1395
|
processOutputSuppressed: () => captureSuppressionActive,
|
|
1419
1396
|
writeOutputAudio(audio, metadata) {
|
|
@@ -1500,9 +1477,6 @@ const FACETIME_END_CALL_TOOL = {
|
|
|
1500
1477
|
properties: {}
|
|
1501
1478
|
}
|
|
1502
1479
|
};
|
|
1503
|
-
function assertAuthenticatedSenderConsultSupport() {
|
|
1504
|
-
if (REALTIME_VOICE_AGENT_CONSULT_SENDER_AUTH_VERSION !== 1) throw new Error("OpenClaw host does not support authenticated sender identity for realtime agent consults; update OpenClaw before enabling FaceTime");
|
|
1505
|
-
}
|
|
1506
1480
|
function agentIdFromSessionKey(sessionKey, config) {
|
|
1507
1481
|
if (parseAgentSessionKey(sessionKey)) return resolveAgentIdFromSessionKey(sessionKey);
|
|
1508
1482
|
return resolveAgentIdFromSessionKey(sessionKey, resolveDefaultAgentId(config));
|
|
@@ -1558,7 +1532,7 @@ async function resolveFaceTimeRealtimeProvider(params) {
|
|
|
1558
1532
|
}
|
|
1559
1533
|
return [providerId, { ...providerConfig }];
|
|
1560
1534
|
})));
|
|
1561
|
-
return
|
|
1535
|
+
return resolveConfiguredRealtimeVoiceProviderAsync({
|
|
1562
1536
|
configuredProviderId,
|
|
1563
1537
|
providerConfigs: providers,
|
|
1564
1538
|
providerConfigOverrides: params.config.realtime.voice ? { voice: params.config.realtime.voice } : void 0,
|
|
@@ -1602,7 +1576,7 @@ function pushCheck(checks, check) {
|
|
|
1602
1576
|
function parseCoreAudioDevices(systemProfilerOutput) {
|
|
1603
1577
|
try {
|
|
1604
1578
|
const parsed = asRecord(JSON.parse(systemProfilerOutput));
|
|
1605
|
-
|
|
1579
|
+
return (Array.isArray(parsed.SPAudioDataType) ? parsed.SPAudioDataType : []).flatMap((entry) => {
|
|
1606
1580
|
const record = asRecord(entry);
|
|
1607
1581
|
const items = record["_items"];
|
|
1608
1582
|
return Array.isArray(items) ? items : [record];
|
|
@@ -1614,17 +1588,9 @@ function parseCoreAudioDevices(systemProfilerOutput) {
|
|
|
1614
1588
|
virtual: record.coreaudio_device_transport === "coreaudio_device_type_virtual"
|
|
1615
1589
|
}] : [];
|
|
1616
1590
|
});
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
const devices = [];
|
|
1620
|
-
for (const line of systemProfilerOutput.split(/\r?\n/u)) {
|
|
1621
|
-
const match = line.match(/^\s{8}(.+):\s*$/u);
|
|
1622
|
-
if (match?.[1]) devices.push({
|
|
1623
|
-
name: match[1].trim(),
|
|
1624
|
-
virtual: false
|
|
1625
|
-
});
|
|
1591
|
+
} catch {
|
|
1592
|
+
return [];
|
|
1626
1593
|
}
|
|
1627
|
-
return [...new Map(devices.map((device) => [device.name, device])).values()];
|
|
1628
1594
|
}
|
|
1629
1595
|
function findPhysicalOutputProblem(defaults, devices) {
|
|
1630
1596
|
if (defaults.output.isAggregate) return `system output is aggregate device ${defaults.output.name}`;
|
|
@@ -1774,7 +1740,7 @@ async function runFaceTimePreflight(params) {
|
|
|
1774
1740
|
//#region extensions/facetime/src/runtime-carrier-process.ts
|
|
1775
1741
|
async function terminateExactCarrierProcesses(params) {
|
|
1776
1742
|
params.assertCurrent();
|
|
1777
|
-
if (params.peers.size === 0) throw new Error("no authenticated carrier process identity is available for
|
|
1743
|
+
if (params.peers.size === 0) throw new Error("no authenticated carrier process identity is available for safe shutdown");
|
|
1778
1744
|
for (const peer of params.peers.values()) {
|
|
1779
1745
|
const expected = peer.bundleIdentifier === "com.apple.FaceTime" ? "FaceTime" : peer.bundleIdentifier === "com.apple.FaceTime.FTConversationService" ? "FTConversationService" : peer.bundleIdentifier === "com.apple.mobilephone" ? "Phone" : peer.bundleIdentifier === "com.apple.TelephonyUtilities" ? "TelephonyUtilities" : "";
|
|
1780
1746
|
const inspectExactProcess = async () => {
|
|
@@ -2207,7 +2173,6 @@ function createFaceTimeInitialGreeting(params) {
|
|
|
2207
2173
|
//#region extensions/facetime/src/talk-driver.ts
|
|
2208
2174
|
async function startFaceTimeTalkDriver(params) {
|
|
2209
2175
|
if (params.signal?.aborted) throw new Error("FaceTime talk startup aborted");
|
|
2210
|
-
assertAuthenticatedSenderConsultSupport();
|
|
2211
2176
|
const consultAgentId = agentIdFromSessionKey(params.config.realtime.sessionKey, params.fullConfig);
|
|
2212
2177
|
const normalizedCallUUID = params.callUUID.trim().toLowerCase();
|
|
2213
2178
|
const consultSessionKey = `agent:${consultAgentId}:facetime:${normalizedCallUUID}`;
|
|
@@ -2871,7 +2836,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2871
2836
|
await closeCall(call, "runtime-stop-carrier-terminated");
|
|
2872
2837
|
} catch (error) {
|
|
2873
2838
|
await call.talk?.suspendMedia("runtime-stop-carrier-unconfirmed");
|
|
2874
|
-
throw new Error(`FaceTime
|
|
2839
|
+
throw new Error(`FaceTime safety shutdown failed: ${formatErrorMessage(error)}; carrier closure remains unconfirmed`, { cause: error });
|
|
2875
2840
|
}
|
|
2876
2841
|
};
|
|
2877
2842
|
const startCallTalk = async (call) => {
|
|
@@ -3137,7 +3102,7 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3137
3102
|
}
|
|
3138
3103
|
const verifiedTransport = isVerifiedFaceTimeTransport(event);
|
|
3139
3104
|
if (existingCall && !verifiedTransport && !isEndedCall(event)) {
|
|
3140
|
-
params.logger.warn("[facetime] managed call transport lost FaceTime verification; closing
|
|
3105
|
+
params.logger.warn("[facetime] managed call transport lost FaceTime verification; closing the call");
|
|
3141
3106
|
await params.callControl.attemptCarrierHangup(existingCall, "transport-verification-lost");
|
|
3142
3107
|
return;
|
|
3143
3108
|
}
|
|
@@ -3231,7 +3196,7 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3231
3196
|
if (isUnknownCallStatus(event)) {
|
|
3232
3197
|
const unknownCall = params.calls.get(callUUID);
|
|
3233
3198
|
if (unknownCall) {
|
|
3234
|
-
params.logger.warn("[facetime] unknown native call status; closing carrier
|
|
3199
|
+
params.logger.warn("[facetime] unknown native call status; closing the carrier");
|
|
3235
3200
|
await params.callControl.attemptCarrierHangup(unknownCall, "unknown-native-status");
|
|
3236
3201
|
}
|
|
3237
3202
|
}
|
|
@@ -3326,7 +3291,7 @@ async function createFaceTimeRuntime(params) {
|
|
|
3326
3291
|
const validation = validateFaceTimeConfig(config);
|
|
3327
3292
|
if (!validation.valid) throw new Error(`Invalid facetime config: ${validation.errors.join("; ")}`);
|
|
3328
3293
|
const calls = new FaceTimeCallRegistry();
|
|
3329
|
-
const pendingDialStore = new PendingFaceTimeDialStore(params.runtime.state.
|
|
3294
|
+
const pendingDialStore = new PendingFaceTimeDialStore(params.runtime.state.openKeyedStoreV2({
|
|
3330
3295
|
namespace: "pending-dial",
|
|
3331
3296
|
maxEntries: 1,
|
|
3332
3297
|
overflowPolicy: "reject-new"
|
|
@@ -3728,7 +3693,7 @@ async function createFaceTimeRuntime(params) {
|
|
|
3728
3693
|
runtime: params.runtime,
|
|
3729
3694
|
peers: outboundCarrierPeers,
|
|
3730
3695
|
assertCurrent: () => {
|
|
3731
|
-
if (outboundCallPending !== shutdownPending || shutdownPending.ownerEpoch !== pendingEpoch) throw new Error("pending FaceTime dial changed during
|
|
3696
|
+
if (outboundCallPending !== shutdownPending || shutdownPending.ownerEpoch !== pendingEpoch) throw new Error("pending FaceTime dial changed during shutdown");
|
|
3732
3697
|
}
|
|
3733
3698
|
});
|
|
3734
3699
|
await clearOutboundCallPending(shutdownPending.dialID);
|
|
@@ -12,7 +12,7 @@ export function FromObject(context, type, value) {
|
|
|
12
12
|
return value;
|
|
13
13
|
const additionalProperties = GetAdditionalProperties(type);
|
|
14
14
|
for (const key of Guard.Keys(value)) {
|
|
15
|
-
if (Guard.HasPropertyKey(type.properties, key)) {
|
|
15
|
+
if (Guard.HasPropertyKey(type.properties, key) && IsSchema(type.properties[key])) {
|
|
16
16
|
value[key] = FromType(context, type.properties[key], value[key]);
|
|
17
17
|
continue;
|
|
18
18
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@openclaw/facetime",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.10-beta.1",
|
|
4
4
|
"description": "Experimental FaceTime realtime voice carrier for OpenClaw agents",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "OpenClaw contributors",
|
|
@@ -63,10 +63,10 @@
|
|
|
63
63
|
"inject:helper:terminal": "bash scripts/inject-helper-terminal.sh"
|
|
64
64
|
},
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"typebox": "1.3.
|
|
66
|
+
"typebox": "1.3.35"
|
|
67
67
|
},
|
|
68
68
|
"peerDependencies": {
|
|
69
|
-
"openclaw": ">=2026.10.
|
|
69
|
+
"openclaw": ">=2026.10.10-beta.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependenciesMeta": {
|
|
72
72
|
"openclaw": {
|
|
@@ -81,15 +81,15 @@
|
|
|
81
81
|
"clawhubSpec": "clawhub:@openclaw/facetime",
|
|
82
82
|
"npmSpec": "@openclaw/facetime",
|
|
83
83
|
"defaultChoice": "npm",
|
|
84
|
-
"minHostVersion": ">=2026.
|
|
84
|
+
"minHostVersion": ">=2026.10.3",
|
|
85
85
|
"allowInvalidConfigRecovery": true
|
|
86
86
|
},
|
|
87
87
|
"compat": {
|
|
88
|
-
"pluginApi": ">=2026.10.
|
|
88
|
+
"pluginApi": ">=2026.10.10-beta.1"
|
|
89
89
|
},
|
|
90
90
|
"build": {
|
|
91
91
|
"bundledDist": false,
|
|
92
|
-
"openclawVersion": "2026.10.
|
|
92
|
+
"openclawVersion": "2026.10.10-beta.1"
|
|
93
93
|
},
|
|
94
94
|
"release": {
|
|
95
95
|
"publishToClawHub": true,
|
|
@@ -125,7 +125,6 @@ build_and_install() {
|
|
|
125
125
|
LIBTOOL="$libtool" \
|
|
126
126
|
'GCC_PREPROCESSOR_DEFINITIONS=$GCC_PREPROCESSOR_DEFINITIONS kNumber_Of_Channels=2 kPlugIn_BundleID=\"ai.openclaw.BlackHoleBridge\" kDriver_Name=\"OpenClawBridge\" kHas_Driver_Name_Format=false kDevice_Name=\"OpenClaw-Mic\" kDevice2_Name=\"OpenClaw-Feed\" kDevice_IsHidden=false kDevice2_IsHidden=false kDevice_HasInput=true kDevice_HasOutput=false kDevice2_HasInput=false kDevice2_HasOutput=true'
|
|
127
127
|
|
|
128
|
-
/usr/bin/codesign --force --deep --sign - "$driver"
|
|
129
128
|
/usr/libexec/PlistBuddy -c "Add :OpenClawDriverRecipe string $recipe" \
|
|
130
129
|
"$driver/Contents/Info.plist"
|
|
131
130
|
/usr/libexec/PlistBuddy -c "Add :OpenClawBlackHoleVersion string $version" \
|
|
@@ -147,13 +146,7 @@ build_and_install() {
|
|
|
147
146
|
}
|
|
148
147
|
|
|
149
148
|
case "${1:-}" in
|
|
150
|
-
--install)
|
|
151
|
-
if test "$#" -ne 1; then
|
|
152
|
-
echo "Usage: $0 --install | --uninstall" >&2
|
|
153
|
-
exit 2
|
|
154
|
-
fi
|
|
155
|
-
;;
|
|
156
|
-
--uninstall)
|
|
149
|
+
--install|--uninstall)
|
|
157
150
|
if test "$#" -ne 1; then
|
|
158
151
|
echo "Usage: $0 --install | --uninstall" >&2
|
|
159
152
|
exit 2
|
|
@@ -5,7 +5,7 @@ on run argv
|
|
|
5
5
|
set sourceTransaction to item 3 of argv
|
|
6
6
|
set installMode to item 4 of argv
|
|
7
7
|
if installMode is not "--install" and installMode is not "--uninstall" then error "Expected --install or --uninstall"
|
|
8
|
-
set expectedInstallerDigest to "
|
|
8
|
+
set expectedInstallerDigest to "cc2c5f21121c4e0d32c401871e3bea423aed7671d379556ba3848d261335c179"
|
|
9
9
|
set expectedVerifierDigest to "4f402898b1b9c8b230bef1c6c26675a26981d2bbccb8ebe25cf2bb3095470eb3"
|
|
10
10
|
set expectedTransactionDigest to "ddc19e86c01e66a25672a3494a47e24b2ee6c0609dc4d78e37d492522b7609b3"
|
|
11
11
|
set protectedCommand to "set -eu; umask 077; " & ¬
|
package/src/audio-pump.ts
CHANGED
|
@@ -198,6 +198,36 @@ async function terminateProcess(proc: ChildProcess, signal: NodeJS.Signals = "SI
|
|
|
198
198
|
}
|
|
199
199
|
}
|
|
200
200
|
|
|
201
|
+
function createAudioReadiness() {
|
|
202
|
+
const deferred = createDeferred<void>();
|
|
203
|
+
let settled = false;
|
|
204
|
+
let timer: NodeJS.Timeout | undefined;
|
|
205
|
+
void deferred.promise.catch(() => {});
|
|
206
|
+
return {
|
|
207
|
+
promise: deferred.promise,
|
|
208
|
+
start(timeoutMs: number, onTimeout: () => void) {
|
|
209
|
+
if (settled || timer) {
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
timer = setTimeout(onTimeout, timeoutMs);
|
|
213
|
+
timer.unref?.();
|
|
214
|
+
},
|
|
215
|
+
settle(error?: Error) {
|
|
216
|
+
if (settled) {
|
|
217
|
+
return;
|
|
218
|
+
}
|
|
219
|
+
settled = true;
|
|
220
|
+
clearTimeout(timer);
|
|
221
|
+
timer = undefined;
|
|
222
|
+
if (error) {
|
|
223
|
+
deferred.reject(error);
|
|
224
|
+
} else {
|
|
225
|
+
deferred.resolve();
|
|
226
|
+
}
|
|
227
|
+
},
|
|
228
|
+
};
|
|
229
|
+
}
|
|
230
|
+
|
|
201
231
|
export function startFaceTimeAudioPump(params: {
|
|
202
232
|
captureBinary: string;
|
|
203
233
|
logger: RuntimeLogger;
|
|
@@ -219,44 +249,9 @@ export function startFaceTimeAudioPump(params: {
|
|
|
219
249
|
let mediaSuspended = false;
|
|
220
250
|
let captureSuppressionActive = false;
|
|
221
251
|
let captureFailureReported = false;
|
|
222
|
-
let captureReadySettled = false;
|
|
223
|
-
let routeReadySettled = false;
|
|
224
|
-
let routeReadyTimer: NodeJS.Timeout | undefined;
|
|
225
252
|
let captureStderr = "";
|
|
226
|
-
const captureReady =
|
|
227
|
-
const routeReady =
|
|
228
|
-
const captureReadyPromise = captureReady.promise;
|
|
229
|
-
const routeReadyPromise = routeReady.promise;
|
|
230
|
-
void captureReadyPromise.catch(() => {});
|
|
231
|
-
void routeReadyPromise.catch(() => {});
|
|
232
|
-
|
|
233
|
-
const settleCaptureReady = (error?: Error) => {
|
|
234
|
-
if (captureReadySettled) {
|
|
235
|
-
return;
|
|
236
|
-
}
|
|
237
|
-
captureReadySettled = true;
|
|
238
|
-
clearTimeout(captureReadyTimer);
|
|
239
|
-
if (error) {
|
|
240
|
-
captureReady.reject(error);
|
|
241
|
-
} else {
|
|
242
|
-
captureReady.resolve();
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
const settleRouteReady = (error?: Error) => {
|
|
246
|
-
if (routeReadySettled) {
|
|
247
|
-
return;
|
|
248
|
-
}
|
|
249
|
-
routeReadySettled = true;
|
|
250
|
-
if (routeReadyTimer) {
|
|
251
|
-
clearTimeout(routeReadyTimer);
|
|
252
|
-
routeReadyTimer = undefined;
|
|
253
|
-
}
|
|
254
|
-
if (error) {
|
|
255
|
-
routeReady.reject(error);
|
|
256
|
-
} else {
|
|
257
|
-
routeReady.resolve();
|
|
258
|
-
}
|
|
259
|
-
};
|
|
253
|
+
const captureReady = createAudioReadiness();
|
|
254
|
+
const routeReady = createAudioReadiness();
|
|
260
255
|
const reportFailure = (error: Error, suppressionLost: boolean) => {
|
|
261
256
|
if (stopped) {
|
|
262
257
|
return;
|
|
@@ -265,8 +260,8 @@ export function startFaceTimeAudioPump(params: {
|
|
|
265
260
|
captureSuppressionActive = false;
|
|
266
261
|
void params.onSuppressionLost?.(error);
|
|
267
262
|
}
|
|
268
|
-
|
|
269
|
-
|
|
263
|
+
captureReady.settle(error);
|
|
264
|
+
routeReady.settle(error);
|
|
270
265
|
params.logger.warn(`[facetime] native audio bridge failed: ${formatErrorMessage(error)}`);
|
|
271
266
|
void Promise.resolve(params.onError?.(error)).then((safeToStop) => {
|
|
272
267
|
if (safeToStop !== false) {
|
|
@@ -304,19 +299,9 @@ export function startFaceTimeAudioPump(params: {
|
|
|
304
299
|
return proc;
|
|
305
300
|
};
|
|
306
301
|
outputProcess = spawnOutput();
|
|
307
|
-
|
|
302
|
+
captureReady.start(10_000, () => {
|
|
308
303
|
reportFailure(new Error("FaceTime process tap was not ready within 10 seconds"), true);
|
|
309
|
-
}
|
|
310
|
-
captureReadyTimer.unref?.();
|
|
311
|
-
const startRouteReadyTimer = () => {
|
|
312
|
-
if (routeReadySettled || routeReadyTimer) {
|
|
313
|
-
return;
|
|
314
|
-
}
|
|
315
|
-
routeReadyTimer = setTimeout(() => {
|
|
316
|
-
reportFailure(new Error("FaceTime input route was not verified within 15 seconds"), true);
|
|
317
|
-
}, 15_000);
|
|
318
|
-
routeReadyTimer.unref?.();
|
|
319
|
-
};
|
|
304
|
+
});
|
|
320
305
|
const clearPlayback = () => {
|
|
321
306
|
if (stopped || mediaSuspended) {
|
|
322
307
|
return;
|
|
@@ -334,8 +319,8 @@ export function startFaceTimeAudioPump(params: {
|
|
|
334
319
|
}
|
|
335
320
|
mediaSuspended = true;
|
|
336
321
|
captureSuppressionActive = false;
|
|
337
|
-
|
|
338
|
-
|
|
322
|
+
captureReady.settle(new Error("FaceTime native audio bridge stopped before readiness"));
|
|
323
|
+
routeReady.settle(new Error("FaceTime input route stopped before verification"));
|
|
339
324
|
cancelDrainTimer();
|
|
340
325
|
playbackClock.reset();
|
|
341
326
|
try {
|
|
@@ -368,10 +353,10 @@ export function startFaceTimeAudioPump(params: {
|
|
|
368
353
|
for (const line of captureStderr.split(/\r?\n/u).slice(0, -1)) {
|
|
369
354
|
if (line.includes("started FaceTime process tap")) {
|
|
370
355
|
captureSuppressionActive = true;
|
|
371
|
-
|
|
356
|
+
captureReady.settle();
|
|
372
357
|
}
|
|
373
358
|
if (line.includes("verified OpenClaw-Mic input route")) {
|
|
374
|
-
|
|
359
|
+
routeReady.settle();
|
|
375
360
|
}
|
|
376
361
|
const fatal = line.match(/facetime-audio-capture: fatal(?:-safety-retained)?:\s*(.*)$/u);
|
|
377
362
|
if (!captureFailureReported && fatal) {
|
|
@@ -399,10 +384,12 @@ export function startFaceTimeAudioPump(params: {
|
|
|
399
384
|
});
|
|
400
385
|
|
|
401
386
|
return {
|
|
402
|
-
suppressionReady: async () => await
|
|
387
|
+
suppressionReady: async () => await captureReady.promise,
|
|
403
388
|
routeReady: async () => {
|
|
404
|
-
|
|
405
|
-
|
|
389
|
+
routeReady.start(15_000, () => {
|
|
390
|
+
reportFailure(new Error("FaceTime input route was not verified within 15 seconds"), true);
|
|
391
|
+
});
|
|
392
|
+
await routeReady.promise;
|
|
406
393
|
},
|
|
407
394
|
processOutputSuppressed: () => captureSuppressionActive,
|
|
408
395
|
writeOutputAudio(audio, metadata) {
|
package/src/call-lifecycle.ts
CHANGED
|
@@ -124,7 +124,6 @@ export class FaceTimeCallInstance {
|
|
|
124
124
|
|
|
125
125
|
export class FaceTimeCallRegistry<T extends FaceTimeCallInstance> {
|
|
126
126
|
#active: T | undefined;
|
|
127
|
-
readonly #aliases = new Map<string, T>();
|
|
128
127
|
|
|
129
128
|
get active(): T | undefined {
|
|
130
129
|
return this.#active;
|
|
@@ -141,7 +140,7 @@ export class FaceTimeCallRegistry<T extends FaceTimeCallInstance> {
|
|
|
141
140
|
}
|
|
142
141
|
|
|
143
142
|
get(identity: string): T | undefined {
|
|
144
|
-
return this.#aliases.
|
|
143
|
+
return this.#active?.aliases.has(normalizeCallIdentity(identity)) ? this.#active : undefined;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
146
|
has(identity: string): boolean {
|
|
@@ -153,22 +152,13 @@ export class FaceTimeCallRegistry<T extends FaceTimeCallInstance> {
|
|
|
153
152
|
throw new Error("another FaceTime call lifecycle is already active");
|
|
154
153
|
}
|
|
155
154
|
this.#active = call;
|
|
156
|
-
for (const alias of call.aliases) {
|
|
157
|
-
this.#aliases.set(alias, call);
|
|
158
|
-
}
|
|
159
155
|
}
|
|
160
156
|
|
|
161
157
|
retainAlias(call: T, identity: string): void {
|
|
162
158
|
if (this.#active !== call || call.phase === "closed") {
|
|
163
159
|
throw new Error("cannot retain an alias for an inactive FaceTime call");
|
|
164
160
|
}
|
|
165
|
-
|
|
166
|
-
const existing = this.#aliases.get(alias);
|
|
167
|
-
if (existing && existing !== call) {
|
|
168
|
-
throw new Error("FaceTime call alias already belongs to another lifecycle");
|
|
169
|
-
}
|
|
170
|
-
call.aliases.add(alias);
|
|
171
|
-
this.#aliases.set(alias, call);
|
|
161
|
+
call.aliases.add(normalizeCallIdentity(identity));
|
|
172
162
|
}
|
|
173
163
|
|
|
174
164
|
close(call: T): void {
|
|
@@ -176,11 +166,6 @@ export class FaceTimeCallRegistry<T extends FaceTimeCallInstance> {
|
|
|
176
166
|
return;
|
|
177
167
|
}
|
|
178
168
|
call.markClosed();
|
|
179
|
-
for (const alias of call.aliases) {
|
|
180
|
-
if (this.#aliases.get(alias) === call) {
|
|
181
|
-
this.#aliases.delete(alias);
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
169
|
this.#active = undefined;
|
|
185
170
|
}
|
|
186
171
|
}
|
package/src/helper-supervisor.ts
CHANGED
|
@@ -48,7 +48,6 @@ export class FaceTimeHelperSupervisor {
|
|
|
48
48
|
readonly #timers = new Map<FaceTimeHelperTarget, ReturnType<typeof setTimeout>>();
|
|
49
49
|
#injectionChain: Promise<void> = Promise.resolve();
|
|
50
50
|
#started = false;
|
|
51
|
-
#generation = 0;
|
|
52
51
|
#abortController = new AbortController();
|
|
53
52
|
|
|
54
53
|
constructor(private readonly params: HelperSupervisorParams) {
|
|
@@ -75,7 +74,6 @@ export class FaceTimeHelperSupervisor {
|
|
|
75
74
|
return;
|
|
76
75
|
}
|
|
77
76
|
this.#started = true;
|
|
78
|
-
this.#generation += 1;
|
|
79
77
|
this.#abortController = new AbortController();
|
|
80
78
|
this.#refreshConnections();
|
|
81
79
|
for (const target of this.#states.keys()) {
|
|
@@ -87,7 +85,6 @@ export class FaceTimeHelperSupervisor {
|
|
|
87
85
|
|
|
88
86
|
async stop(): Promise<void> {
|
|
89
87
|
this.#started = false;
|
|
90
|
-
this.#generation += 1;
|
|
91
88
|
this.#abortController.abort(new Error("FaceTime helper supervisor stopped"));
|
|
92
89
|
for (const timer of this.#timers.values()) {
|
|
93
90
|
clearTimeout(timer);
|
|
@@ -226,22 +223,18 @@ export class FaceTimeHelperSupervisor {
|
|
|
226
223
|
return;
|
|
227
224
|
}
|
|
228
225
|
state.queued = true;
|
|
229
|
-
const generation = this.#generation;
|
|
230
226
|
const pending = this.#injectionChain.then(async () => {
|
|
231
227
|
state.queued = false;
|
|
232
|
-
if (this.#started
|
|
233
|
-
await this.#inject(target
|
|
228
|
+
if (this.#started) {
|
|
229
|
+
await this.#inject(target);
|
|
234
230
|
}
|
|
235
231
|
});
|
|
236
232
|
this.#injectionChain = pending.catch(() => undefined);
|
|
237
233
|
}
|
|
238
234
|
|
|
239
|
-
async #waitForAuthenticatedConnection(
|
|
240
|
-
target: FaceTimeHelperTarget,
|
|
241
|
-
generation: number,
|
|
242
|
-
): Promise<void> {
|
|
235
|
+
async #waitForAuthenticatedConnection(target: FaceTimeHelperTarget): Promise<void> {
|
|
243
236
|
const deadline = Date.now() + 10_000;
|
|
244
|
-
while (this.#started &&
|
|
237
|
+
while (this.#started && Date.now() < deadline) {
|
|
245
238
|
this.#refreshConnections();
|
|
246
239
|
const state = this.#states.get(target);
|
|
247
240
|
if (!state || state.connected || state.stale) {
|
|
@@ -252,8 +245,8 @@ export class FaceTimeHelperSupervisor {
|
|
|
252
245
|
this.#refreshConnections();
|
|
253
246
|
}
|
|
254
247
|
|
|
255
|
-
async #inject(target: FaceTimeHelperTarget
|
|
256
|
-
if (!this.#started
|
|
248
|
+
async #inject(target: FaceTimeHelperTarget): Promise<void> {
|
|
249
|
+
if (!this.#started) {
|
|
257
250
|
return;
|
|
258
251
|
}
|
|
259
252
|
this.#refreshConnections();
|
|
@@ -273,7 +266,7 @@ export class FaceTimeHelperSupervisor {
|
|
|
273
266
|
killProcessTree: true,
|
|
274
267
|
},
|
|
275
268
|
);
|
|
276
|
-
if (!this.#started
|
|
269
|
+
if (!this.#started) {
|
|
277
270
|
return;
|
|
278
271
|
}
|
|
279
272
|
if (result.code !== 0) {
|
|
@@ -282,7 +275,7 @@ export class FaceTimeHelperSupervisor {
|
|
|
282
275
|
state.lastError = undefined;
|
|
283
276
|
this.params.logger.info(`[facetime] injected helper into ${target}`);
|
|
284
277
|
if (!state.connected && !state.stale) {
|
|
285
|
-
await this.#waitForAuthenticatedConnection(target
|
|
278
|
+
await this.#waitForAuthenticatedConnection(target);
|
|
286
279
|
if (!state.connected && !state.stale) {
|
|
287
280
|
throw new Error(
|
|
288
281
|
`${target} helper injection completed but no authenticated connection arrived`,
|
|
@@ -290,14 +283,14 @@ export class FaceTimeHelperSupervisor {
|
|
|
290
283
|
}
|
|
291
284
|
}
|
|
292
285
|
} catch (error) {
|
|
293
|
-
if (this.#started
|
|
286
|
+
if (this.#started) {
|
|
294
287
|
state.lastError = formatErrorMessage(error);
|
|
295
288
|
this.params.logger.warn(`[facetime] ${target} helper injection failed: ${state.lastError}`);
|
|
296
289
|
}
|
|
297
290
|
} finally {
|
|
298
291
|
state.injecting = false;
|
|
299
292
|
}
|
|
300
|
-
if (!this.#started
|
|
293
|
+
if (!this.#started) {
|
|
301
294
|
return;
|
|
302
295
|
}
|
|
303
296
|
this.#refreshConnections();
|
|
@@ -37,7 +37,21 @@ export class PendingFaceTimeDialStore {
|
|
|
37
37
|
#tail: Promise<void> = Promise.resolve();
|
|
38
38
|
readonly #clearing = new Map<string, Promise<boolean>>();
|
|
39
39
|
|
|
40
|
-
constructor(private readonly store: PluginStateKeyedStore<StoredPendingFaceTimeDial>) {}
|
|
40
|
+
constructor(private readonly store: PluginStateKeyedStore<StoredPendingFaceTimeDial, 2>) {}
|
|
41
|
+
|
|
42
|
+
async #deleteMatching(expectedDialID: string): Promise<boolean> {
|
|
43
|
+
let observation = await this.store.observe(PENDING_DIAL_KEY);
|
|
44
|
+
for (;;) {
|
|
45
|
+
const result = await this.store.compareAndApply(PENDING_DIAL_KEY, observation.comparison, {
|
|
46
|
+
operation: "delete",
|
|
47
|
+
action: observation.value?.dialID === expectedDialID ? "delete" : "keep",
|
|
48
|
+
});
|
|
49
|
+
if (result.status !== "conflict") {
|
|
50
|
+
return result.status === "applied";
|
|
51
|
+
}
|
|
52
|
+
observation = result.current;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
41
55
|
|
|
42
56
|
#enqueue<T>(operation: () => Promise<T>): Promise<T> {
|
|
43
57
|
const pending = this.#tail.then(operation);
|
|
@@ -71,30 +85,9 @@ export class PendingFaceTimeDialStore {
|
|
|
71
85
|
if (existing) {
|
|
72
86
|
return existing;
|
|
73
87
|
}
|
|
74
|
-
const clearing = this.#enqueue(
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
// FaceTime supports released 2026.9.4 hosts that predate comparisons.
|
|
78
|
-
if (!this.store.deleteIf) {
|
|
79
|
-
throw new Error("FaceTime pending dial cleanup requires atomic plugin-state deletion");
|
|
80
|
-
}
|
|
81
|
-
return this.store.deleteIf(
|
|
82
|
-
PENDING_DIAL_KEY,
|
|
83
|
-
(current) => current.dialID === expectedDialID,
|
|
84
|
-
);
|
|
85
|
-
}
|
|
86
|
-
let observation = await observe(PENDING_DIAL_KEY);
|
|
87
|
-
for (;;) {
|
|
88
|
-
const result = await compareAndApply(PENDING_DIAL_KEY, observation.comparison, {
|
|
89
|
-
operation: "delete",
|
|
90
|
-
action: observation.value?.dialID === expectedDialID ? "delete" : "keep",
|
|
91
|
-
});
|
|
92
|
-
if (result.status !== "conflict") {
|
|
93
|
-
return result.status === "applied";
|
|
94
|
-
}
|
|
95
|
-
observation = result.current;
|
|
96
|
-
}
|
|
97
|
-
}).finally(() => this.#clearing.delete(expectedDialID));
|
|
88
|
+
const clearing = this.#enqueue(() => this.#deleteMatching(expectedDialID)).finally(() =>
|
|
89
|
+
this.#clearing.delete(expectedDialID),
|
|
90
|
+
);
|
|
98
91
|
this.#clearing.set(expectedDialID, clearing);
|
|
99
92
|
return clearing;
|
|
100
93
|
}
|
package/src/preflight.ts
CHANGED
|
@@ -81,7 +81,7 @@ function parseCoreAudioDevices(systemProfilerOutput: string): CoreAudioDevicePro
|
|
|
81
81
|
const items = record["_items"];
|
|
82
82
|
return Array.isArray(items) ? items : [record];
|
|
83
83
|
});
|
|
84
|
-
|
|
84
|
+
return deviceEntries.flatMap((entry): CoreAudioDeviceProfile[] => {
|
|
85
85
|
const record = asRecord(entry);
|
|
86
86
|
const name = record["_name"];
|
|
87
87
|
return typeof name === "string"
|
|
@@ -93,21 +93,9 @@ function parseCoreAudioDevices(systemProfilerOutput: string): CoreAudioDevicePro
|
|
|
93
93
|
]
|
|
94
94
|
: [];
|
|
95
95
|
});
|
|
96
|
-
if (devices.length > 0) {
|
|
97
|
-
return devices;
|
|
98
|
-
}
|
|
99
96
|
} catch {
|
|
100
|
-
|
|
101
|
-
// provide the human-readable device list without transport metadata.
|
|
102
|
-
}
|
|
103
|
-
const devices: CoreAudioDeviceProfile[] = [];
|
|
104
|
-
for (const line of systemProfilerOutput.split(/\r?\n/u)) {
|
|
105
|
-
const match = line.match(/^\s{8}(.+):\s*$/u);
|
|
106
|
-
if (match?.[1]) {
|
|
107
|
-
devices.push({ name: match[1].trim(), virtual: false });
|
|
108
|
-
}
|
|
97
|
+
return [];
|
|
109
98
|
}
|
|
110
|
-
return [...new Map(devices.map((device) => [device.name, device])).values()];
|
|
111
99
|
}
|
|
112
100
|
|
|
113
101
|
function findPhysicalOutputProblem(
|
|
@@ -302,7 +302,7 @@ export function createFaceTimeCallControl(params: {
|
|
|
302
302
|
} catch (error) {
|
|
303
303
|
await call.talk?.suspendMedia("runtime-stop-carrier-unconfirmed");
|
|
304
304
|
throw new Error(
|
|
305
|
-
`FaceTime
|
|
305
|
+
`FaceTime safety shutdown failed: ${formatErrorMessage(error)}; carrier closure remains unconfirmed`,
|
|
306
306
|
{ cause: error },
|
|
307
307
|
);
|
|
308
308
|
}
|
|
@@ -251,7 +251,7 @@ export function createFaceTimeCallEventHandler(params: {
|
|
|
251
251
|
const verifiedTransport = isVerifiedFaceTimeTransport(event);
|
|
252
252
|
if (existingCall && !verifiedTransport && !isEndedCall(event)) {
|
|
253
253
|
params.logger.warn(
|
|
254
|
-
"[facetime] managed call transport lost FaceTime verification; closing
|
|
254
|
+
"[facetime] managed call transport lost FaceTime verification; closing the call",
|
|
255
255
|
);
|
|
256
256
|
await params.callControl.attemptCarrierHangup(existingCall, "transport-verification-lost");
|
|
257
257
|
return;
|
|
@@ -384,7 +384,7 @@ export function createFaceTimeCallEventHandler(params: {
|
|
|
384
384
|
if (isUnknownCallStatus(event)) {
|
|
385
385
|
const unknownCall = params.calls.get(callUUID);
|
|
386
386
|
if (unknownCall) {
|
|
387
|
-
params.logger.warn("[facetime] unknown native call status; closing carrier
|
|
387
|
+
params.logger.warn("[facetime] unknown native call status; closing the carrier");
|
|
388
388
|
await params.callControl.attemptCarrierHangup(unknownCall, "unknown-native-status");
|
|
389
389
|
}
|
|
390
390
|
}
|
|
@@ -8,9 +8,7 @@ export async function terminateExactCarrierProcesses(params: {
|
|
|
8
8
|
}): Promise<void> {
|
|
9
9
|
params.assertCurrent();
|
|
10
10
|
if (params.peers.size === 0) {
|
|
11
|
-
throw new Error(
|
|
12
|
-
"no authenticated carrier process identity is available for fail-closed shutdown",
|
|
13
|
-
);
|
|
11
|
+
throw new Error("no authenticated carrier process identity is available for safe shutdown");
|
|
14
12
|
}
|
|
15
13
|
for (const peer of params.peers.values()) {
|
|
16
14
|
const expected =
|
package/src/runtime.ts
CHANGED
|
@@ -77,7 +77,7 @@ export async function createFaceTimeRuntime(params: {
|
|
|
77
77
|
|
|
78
78
|
const calls = new FaceTimeCallRegistry<ActiveFaceTimeCall>();
|
|
79
79
|
const pendingDialStore = new PendingFaceTimeDialStore(
|
|
80
|
-
params.runtime.state.
|
|
80
|
+
params.runtime.state.openKeyedStoreV2({
|
|
81
81
|
namespace: "pending-dial",
|
|
82
82
|
maxEntries: 1,
|
|
83
83
|
overflowPolicy: "reject-new",
|
|
@@ -662,7 +662,7 @@ export async function createFaceTimeRuntime(params: {
|
|
|
662
662
|
outboundCallPending !== shutdownPending ||
|
|
663
663
|
shutdownPending.ownerEpoch !== pendingEpoch
|
|
664
664
|
) {
|
|
665
|
-
throw new Error("pending FaceTime dial changed during
|
|
665
|
+
throw new Error("pending FaceTime dial changed during shutdown");
|
|
666
666
|
}
|
|
667
667
|
},
|
|
668
668
|
});
|
package/src/setup.ts
CHANGED
|
@@ -234,41 +234,30 @@ async function checkNotificationsDuringSharing(
|
|
|
234
234
|
"/usr/bin/plutil -extract dnd_prefs raw -o - - | " +
|
|
235
235
|
"/usr/bin/base64 --decode | " +
|
|
236
236
|
"/usr/bin/plutil -extract dndMirrored raw -o - -";
|
|
237
|
+
let ready = false;
|
|
238
|
+
let message: string;
|
|
237
239
|
try {
|
|
238
240
|
const result = await runCommandWithTimeout(["/bin/bash", "-c", script], {
|
|
239
241
|
timeoutMs: 5_000,
|
|
240
242
|
});
|
|
241
243
|
const value = firstLine(result.stdout)?.toLowerCase();
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
message: "Notifications are allowed while mirroring or sharing the display",
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
return {
|
|
252
|
-
id: "notifications-while-sharing",
|
|
253
|
-
label: "Notifications while sharing the display",
|
|
254
|
-
status: "action-required",
|
|
255
|
-
required: true,
|
|
256
|
-
message:
|
|
257
|
-
value === "false"
|
|
258
|
-
? "Incoming call notifications are suppressed while mirroring or sharing the display"
|
|
259
|
-
: "Could not verify the notification setting used during display sharing",
|
|
260
|
-
actionId: "allow-sharing-notifications",
|
|
261
|
-
};
|
|
244
|
+
ready = result.code === 0 && value === "true";
|
|
245
|
+
message = ready
|
|
246
|
+
? "Notifications are allowed while mirroring or sharing the display"
|
|
247
|
+
: value === "false"
|
|
248
|
+
? "Incoming call notifications are suppressed while mirroring or sharing the display"
|
|
249
|
+
: "Could not verify the notification setting used during display sharing";
|
|
262
250
|
} catch (error) {
|
|
263
|
-
|
|
264
|
-
id: "notifications-while-sharing",
|
|
265
|
-
label: "Notifications while sharing the display",
|
|
266
|
-
status: "action-required",
|
|
267
|
-
required: true,
|
|
268
|
-
message: `Could not verify notification behavior: ${formatErrorMessage(error)}`,
|
|
269
|
-
actionId: "allow-sharing-notifications",
|
|
270
|
-
};
|
|
251
|
+
message = `Could not verify notification behavior: ${formatErrorMessage(error)}`;
|
|
271
252
|
}
|
|
253
|
+
return {
|
|
254
|
+
id: "notifications-while-sharing",
|
|
255
|
+
label: "Notifications while sharing the display",
|
|
256
|
+
status: ready ? "ready" : "action-required",
|
|
257
|
+
required: true,
|
|
258
|
+
message,
|
|
259
|
+
...(!ready ? { actionId: "allow-sharing-notifications" as const } : {}),
|
|
260
|
+
};
|
|
272
261
|
}
|
|
273
262
|
|
|
274
263
|
async function checkCommand(
|
|
@@ -4,8 +4,7 @@ import {
|
|
|
4
4
|
buildRealtimeVoiceAgentConsultPolicyInstructions,
|
|
5
5
|
getRealtimeVoiceProvider,
|
|
6
6
|
REALTIME_VOICE_AGENT_CONSULT_TOOL_NAME,
|
|
7
|
-
|
|
8
|
-
resolveConfiguredRealtimeVoiceProvider,
|
|
7
|
+
resolveConfiguredRealtimeVoiceProviderAsync,
|
|
9
8
|
type RealtimeVoiceTool,
|
|
10
9
|
} from "openclaw/plugin-sdk/realtime-voice";
|
|
11
10
|
import { parseAgentSessionKey, resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing";
|
|
@@ -39,14 +38,6 @@ export const FACETIME_END_CALL_TOOL: RealtimeVoiceTool = {
|
|
|
39
38
|
},
|
|
40
39
|
};
|
|
41
40
|
|
|
42
|
-
export function assertAuthenticatedSenderConsultSupport(): void {
|
|
43
|
-
if (REALTIME_VOICE_AGENT_CONSULT_SENDER_AUTH_VERSION !== 1) {
|
|
44
|
-
throw new Error(
|
|
45
|
-
"OpenClaw host does not support authenticated sender identity for realtime agent consults; update OpenClaw before enabling FaceTime",
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
41
|
export function agentIdFromSessionKey(sessionKey: string, config: OpenClawConfig): string {
|
|
51
42
|
if (parseAgentSessionKey(sessionKey)) {
|
|
52
43
|
return resolveAgentIdFromSessionKey(sessionKey);
|
|
@@ -133,7 +124,7 @@ export async function resolveFaceTimeRealtimeProvider(params: {
|
|
|
133
124
|
}),
|
|
134
125
|
),
|
|
135
126
|
);
|
|
136
|
-
return
|
|
127
|
+
return resolveConfiguredRealtimeVoiceProviderAsync({
|
|
137
128
|
configuredProviderId,
|
|
138
129
|
providerConfigs: providers,
|
|
139
130
|
providerConfigOverrides: params.config.realtime.voice
|
package/src/talk-driver.ts
CHANGED
|
@@ -22,7 +22,6 @@ import type { FaceTimeConfig } from "./config.js";
|
|
|
22
22
|
import { createFaceTimeConsultController } from "./talk-consult-controller.js";
|
|
23
23
|
import {
|
|
24
24
|
agentIdFromSessionKey,
|
|
25
|
-
assertAuthenticatedSenderConsultSupport,
|
|
26
25
|
buildRealtimeInstructions,
|
|
27
26
|
FACETIME_END_CALL_TOOL,
|
|
28
27
|
INPUT_AUDIO_STATUS_INTERVAL_MS,
|
|
@@ -60,9 +59,6 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
60
59
|
if (params.signal?.aborted) {
|
|
61
60
|
throw new Error("FaceTime talk startup aborted");
|
|
62
61
|
}
|
|
63
|
-
// Fail closed before the call is answered; older hosts silently ignore the
|
|
64
|
-
// owner fields and would otherwise create a privilege-downgrade footgun.
|
|
65
|
-
assertAuthenticatedSenderConsultSupport();
|
|
66
62
|
const consultAgentId = agentIdFromSessionKey(
|
|
67
63
|
params.config.realtime.sessionKey,
|
|
68
64
|
params.fullConfig,
|