@openclaw/facetime 2026.11.3 → 2026.11.5-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{setup-DMPG615Z.mjs → setup-D3xHzHpV.mjs} +52 -99
- package/dist/.source-module-urls/38481bccca5fbb406e50ac928748f9f04f5a6cf5623980901b3cebc6ee82dfb6.json +1 -0
- package/dist/index.js +9 -22
- package/dist/runtime-api.js +225 -339
- package/docs/phase1-verification.md +1 -1
- package/index.ts +13 -20
- package/node_modules/typebox/build/format/duration.d.mts +2 -2
- package/node_modules/typebox/build/format/duration.mjs +2 -2
- package/node_modules/typebox/build/format/idn_email.d.mts +1 -0
- package/node_modules/typebox/build/format/idn_email.mjs +1 -0
- package/node_modules/typebox/build/format/idn_hostname.d.mts +1 -1
- package/node_modules/typebox/build/format/idn_hostname.mjs +1 -1
- package/node_modules/typebox/build/format/ipv4.d.mts +2 -2
- package/node_modules/typebox/build/format/ipv4.mjs +2 -2
- package/node_modules/typebox/build/format/ipv6.d.mts +1 -1
- package/node_modules/typebox/build/format/ipv6.mjs +1 -1
- package/node_modules/typebox/build/format/relative_json_pointer.d.mts +2 -2
- package/node_modules/typebox/build/format/relative_json_pointer.mjs +2 -2
- package/node_modules/typebox/build/schema/build.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/_unique.d.mts +4 -2
- package/node_modules/typebox/build/schema/engine/_unique.mjs +7 -3
- package/node_modules/typebox/build/schema/engine/additionalItems.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.d.mts +0 -3
- package/node_modules/typebox/build/schema/engine/additionalProperties.mjs +15 -17
- package/node_modules/typebox/build/schema/engine/contains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/index.d.mts +1 -0
- package/node_modules/typebox/build/schema/engine/index.mjs +1 -0
- package/node_modules/typebox/build/schema/engine/items.mjs +7 -4
- package/node_modules/typebox/build/schema/engine/maxContains.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/minContains.mjs +3 -3
- package/node_modules/typebox/build/schema/engine/oneOf.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/patternProperties.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/propertyNames.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedItems.mjs +2 -2
- package/node_modules/typebox/build/schema/engine/unevaluatedProperties.mjs +2 -2
- package/node_modules/typebox/build/system/hashing/hash.mjs +63 -34
- package/node_modules/typebox/build/system/locale/en_US.mjs +2 -1
- package/node_modules/typebox/build/system/memory/assign.d.mts +2 -8
- package/node_modules/typebox/build/system/memory/assign.mjs +13 -6
- package/node_modules/typebox/build/system/memory/clone.d.mts +4 -5
- package/node_modules/typebox/build/system/memory/clone.mjs +8 -96
- package/node_modules/typebox/build/system/memory/create.d.mts +1 -5
- package/node_modules/typebox/build/system/memory/create.mjs +18 -13
- package/node_modules/typebox/build/system/memory/deep.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/deep.mjs +108 -0
- package/node_modules/typebox/build/system/memory/discard.d.mts +1 -1
- package/node_modules/typebox/build/system/memory/discard.mjs +9 -8
- package/node_modules/typebox/build/system/memory/finalize.d.mts +4 -0
- package/node_modules/typebox/build/system/memory/finalize.mjs +30 -0
- package/node_modules/typebox/build/system/memory/keys.d.mts +2 -0
- package/node_modules/typebox/build/system/memory/keys.mjs +8 -0
- package/node_modules/typebox/build/system/memory/update.d.mts +1 -4
- package/node_modules/typebox/build/system/memory/update.mjs +43 -16
- package/node_modules/typebox/build/type/engine/call/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/call/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/composite.d.mts +2 -24
- package/node_modules/typebox/build/type/engine/evaluate/composite.mjs +2 -29
- package/node_modules/typebox/build/type/engine/evaluate/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/index.mjs +1 -0
- package/node_modules/typebox/build/type/engine/evaluate/narrow.d.mts +5 -1
- package/node_modules/typebox/build/type/engine/evaluate/narrow.mjs +6 -1
- package/node_modules/typebox/build/type/engine/evaluate/property.d.mts +30 -0
- package/node_modules/typebox/build/type/engine/evaluate/property.mjs +29 -0
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/immutable/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/object/from_intersect.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_intersect.mjs +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.d.mts +2 -2
- package/node_modules/typebox/build/type/engine/object/from_union.mjs +2 -2
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/optional/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.d.mts +1 -3
- package/node_modules/typebox/build/type/engine/readonly/instantiate_add.mjs +1 -4
- package/node_modules/typebox/build/type/engine/this/index.d.mts +1 -0
- package/node_modules/typebox/build/type/engine/this/index.mjs +1 -0
- package/node_modules/typebox/build/value/clone/clone.d.mts +4 -3
- package/node_modules/typebox/build/value/clone/clone.mjs +5 -7
- package/node_modules/typebox/build/value/repair/from_cyclic.d.mts +2 -0
- package/node_modules/typebox/build/value/repair/from_cyclic.mjs +6 -0
- package/node_modules/typebox/build/value/shared/union_priority_sort.mjs +25 -14
- package/node_modules/typebox/package.json +1 -1
- package/node_modules/typebox/readme.md +1 -1
- package/package.json +5 -6
- package/scripts/inject-helper-terminal.sh +1 -1
- package/scripts/inject-helper.sh +3 -7
- package/scripts/install-driver.sh +1 -1
- package/src/audio-pump.ts +5 -13
- package/src/command-output.ts +3 -0
- package/src/driver-setup.ts +15 -23
- package/src/helper-results.ts +31 -37
- package/src/helper-rpc.ts +55 -68
- package/src/helper-supervisor.ts +20 -28
- package/src/outbound-call.ts +2 -13
- package/src/plugin-paths.ts +13 -23
- package/src/preflight.ts +10 -33
- package/src/runtime-call-control.ts +11 -23
- package/src/runtime-call-events.ts +10 -7
- package/src/runtime-carrier-process.ts +1 -5
- package/src/runtime-helper-results.ts +5 -38
- package/src/runtime-state.ts +178 -10
- package/src/runtime-status.ts +2 -3
- package/src/runtime.ts +5 -7
- package/src/setup.ts +58 -69
- package/src/talk-consult-controller.ts +1 -19
- package/src/talk-driver.ts +31 -25
- package/src/talk-events-summary.ts +8 -19
- package/node_modules/typebox/build/system/memory/freeze.d.mts +0 -4
- package/node_modules/typebox/build/system/memory/freeze.mjs +0 -6
- package/src/call-lifecycle.ts +0 -171
- package/src/runtime-lifecycle.ts +0 -17
- package/src/talk-initial-greeting.ts +0 -42
package/dist/runtime-api.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { c as installFaceTimeDriver, d as validateFaceTimeConfig, i as ensureHelperArtifacts, n as firstLine, r as ensureCaptureBinary, t as runFaceTimeSetup, u as resolveFaceTimeConfig } from "./.setup/setup-D3xHzHpV.mjs";
|
|
2
2
|
import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
|
|
3
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";
|
|
7
7
|
import { access } from "node:fs/promises";
|
|
8
|
-
import { createHmac, randomUUID
|
|
8
|
+
import { createHmac, randomUUID } from "node:crypto";
|
|
9
9
|
import { sleep, sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
|
|
10
|
-
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
11
10
|
import net from "node:net";
|
|
11
|
+
import { safeEqualSecret } from "openclaw/plugin-sdk/security-runtime";
|
|
12
12
|
import { spawn } from "node:child_process";
|
|
13
|
+
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
13
14
|
import { resolveDefaultAgentId } from "openclaw/plugin-sdk/agent-runtime";
|
|
14
15
|
import { parseAgentSessionKey, resolveAgentIdFromSessionKey } from "openclaw/plugin-sdk/routing";
|
|
15
16
|
import { resolveConfiguredSecretInputString } from "openclaw/plugin-sdk/secret-input-runtime";
|
|
@@ -158,122 +159,6 @@ function isUnknownCallStatus(event) {
|
|
|
158
159
|
return !isIncomingRingingCall(event) && !isOutgoingRingingCall(event) && !isActiveCall(event) && !isEndedCall(event);
|
|
159
160
|
}
|
|
160
161
|
//#endregion
|
|
161
|
-
//#region extensions/facetime/src/call-lifecycle.ts
|
|
162
|
-
function normalizeCallIdentity(value) {
|
|
163
|
-
return value.trim().toLowerCase();
|
|
164
|
-
}
|
|
165
|
-
var FaceTimeCallInstance = class {
|
|
166
|
-
#carrierClosure;
|
|
167
|
-
#commandTail;
|
|
168
|
-
constructor(canonicalId, phase) {
|
|
169
|
-
this.lifecycleAbort = new AbortController();
|
|
170
|
-
this.aliases = /* @__PURE__ */ new Set();
|
|
171
|
-
this.generation = 1;
|
|
172
|
-
this.modelMediaMode = "starting";
|
|
173
|
-
this.#carrierClosure = createDeferred();
|
|
174
|
-
this.carrierClosure = this.#carrierClosure.promise;
|
|
175
|
-
this.#commandTail = Promise.resolve();
|
|
176
|
-
this.phase = phase;
|
|
177
|
-
this.carrierMode = phase === "ringing" ? "ringing" : "muted";
|
|
178
|
-
this.aliases.add(normalizeCallIdentity(canonicalId));
|
|
179
|
-
}
|
|
180
|
-
captureGeneration() {
|
|
181
|
-
return this.generation;
|
|
182
|
-
}
|
|
183
|
-
assertCurrent(generation, allowClosing = false) {
|
|
184
|
-
const phaseAllowed = allowClosing ? this.phase !== "closed" && this.carrierMode !== "closed" : this.phase !== "closing" && this.phase !== "closed";
|
|
185
|
-
if (generation !== this.generation || !phaseAllowed || !allowClosing && this.lifecycleAbort.signal.aborted) throw new Error("FaceTime call lifecycle changed during carrier command");
|
|
186
|
-
}
|
|
187
|
-
async runCarrierCommand(params) {
|
|
188
|
-
const previous = this.#commandTail;
|
|
189
|
-
const { promise, resolve: release } = createDeferred();
|
|
190
|
-
this.#commandTail = promise;
|
|
191
|
-
await previous;
|
|
192
|
-
try {
|
|
193
|
-
this.assertCurrent(params.generation, params.allowClosing);
|
|
194
|
-
const result = await params.action();
|
|
195
|
-
this.assertCurrent(params.generation, params.allowClosing);
|
|
196
|
-
return result;
|
|
197
|
-
} finally {
|
|
198
|
-
release();
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
beginAnswering() {
|
|
202
|
-
if (this.phase !== "ringing") throw new Error(`cannot answer FaceTime call in ${this.phase} phase`);
|
|
203
|
-
this.phase = "answering";
|
|
204
|
-
this.carrierMode = "muted";
|
|
205
|
-
return this.generation;
|
|
206
|
-
}
|
|
207
|
-
markCarrierActive(generation) {
|
|
208
|
-
this.assertCurrent(generation);
|
|
209
|
-
this.phase = "active";
|
|
210
|
-
this.carrierMode = "active";
|
|
211
|
-
}
|
|
212
|
-
markModelReady(generation) {
|
|
213
|
-
this.assertCurrent(generation);
|
|
214
|
-
this.modelMediaMode = "ready";
|
|
215
|
-
}
|
|
216
|
-
markModelActive(generation) {
|
|
217
|
-
this.assertCurrent(generation);
|
|
218
|
-
this.modelMediaMode = "active";
|
|
219
|
-
}
|
|
220
|
-
suspendModelMedia() {
|
|
221
|
-
if (this.modelMediaMode !== "closed") this.modelMediaMode = "suspended";
|
|
222
|
-
}
|
|
223
|
-
beginClosing() {
|
|
224
|
-
if (this.phase === "closed") return this.generation;
|
|
225
|
-
if (this.phase !== "closing") {
|
|
226
|
-
this.generation += 1;
|
|
227
|
-
this.phase = "closing";
|
|
228
|
-
this.carrierMode = "closing";
|
|
229
|
-
this.suspendModelMedia();
|
|
230
|
-
this.lifecycleAbort.abort(/* @__PURE__ */ new Error("FaceTime call is closing"));
|
|
231
|
-
}
|
|
232
|
-
return this.generation;
|
|
233
|
-
}
|
|
234
|
-
markCarrierClosed() {
|
|
235
|
-
this.beginClosing();
|
|
236
|
-
this.carrierMode = "closed";
|
|
237
|
-
this.#carrierClosure.resolve(void 0);
|
|
238
|
-
}
|
|
239
|
-
markClosed() {
|
|
240
|
-
this.phase = "closed";
|
|
241
|
-
this.carrierMode = "closed";
|
|
242
|
-
this.modelMediaMode = "closed";
|
|
243
|
-
}
|
|
244
|
-
};
|
|
245
|
-
var FaceTimeCallRegistry = class {
|
|
246
|
-
#active;
|
|
247
|
-
get active() {
|
|
248
|
-
return this.#active;
|
|
249
|
-
}
|
|
250
|
-
get size() {
|
|
251
|
-
return this.#active && this.#active.phase !== "closed" ? 1 : 0;
|
|
252
|
-
}
|
|
253
|
-
values() {
|
|
254
|
-
return (this.#active && this.#active.phase !== "closed" ? [this.#active] : [])[Symbol.iterator]();
|
|
255
|
-
}
|
|
256
|
-
get(identity) {
|
|
257
|
-
return this.#active?.aliases.has(normalizeCallIdentity(identity)) ? this.#active : void 0;
|
|
258
|
-
}
|
|
259
|
-
has(identity) {
|
|
260
|
-
return this.get(identity) !== void 0;
|
|
261
|
-
}
|
|
262
|
-
create(call) {
|
|
263
|
-
if (this.#active && this.#active.phase !== "closed") throw new Error("another FaceTime call lifecycle is already active");
|
|
264
|
-
this.#active = call;
|
|
265
|
-
}
|
|
266
|
-
retainAlias(call, identity) {
|
|
267
|
-
if (this.#active !== call || call.phase === "closed") throw new Error("cannot retain an alias for an inactive FaceTime call");
|
|
268
|
-
call.aliases.add(normalizeCallIdentity(identity));
|
|
269
|
-
}
|
|
270
|
-
close(call) {
|
|
271
|
-
if (this.#active !== call) return;
|
|
272
|
-
call.markClosed();
|
|
273
|
-
this.#active = void 0;
|
|
274
|
-
}
|
|
275
|
-
};
|
|
276
|
-
//#endregion
|
|
277
162
|
//#region extensions/facetime/helper-endpoint.json
|
|
278
163
|
var host = "127.0.0.1";
|
|
279
164
|
var basePort = 45670;
|
|
@@ -290,12 +175,7 @@ function resolveFaceTimeHelperEndpoint() {
|
|
|
290
175
|
}
|
|
291
176
|
//#endregion
|
|
292
177
|
//#region extensions/facetime/src/helper-results.ts
|
|
293
|
-
|
|
294
|
-
constructor(message) {
|
|
295
|
-
super(message);
|
|
296
|
-
this.name = "FaceTimeHelperActionError";
|
|
297
|
-
}
|
|
298
|
-
};
|
|
178
|
+
const DIAL_BUNDLES = /* @__PURE__ */ new Set(["com.apple.FaceTime", "com.apple.FaceTime.FTConversationService"]);
|
|
299
179
|
var FaceTimeHelperAmbiguousError = class extends Error {
|
|
300
180
|
constructor(message, result = {}) {
|
|
301
181
|
super(message);
|
|
@@ -310,37 +190,31 @@ var FaceTimeHelperUnavailableError = class extends Error {
|
|
|
310
190
|
}
|
|
311
191
|
};
|
|
312
192
|
function readHelperResults(result) {
|
|
313
|
-
return
|
|
193
|
+
return result.helperResults ?? [result];
|
|
314
194
|
}
|
|
315
195
|
function requireCompleteTopology(result) {
|
|
316
196
|
const results = readHelperResults(result);
|
|
317
|
-
if (result.topologyComplete !== true ||
|
|
197
|
+
if (result.topologyComplete !== true || results.length !== result.helpersContacted) throw new FaceTimeHelperAmbiguousError("FaceTime helper topology was incomplete", result);
|
|
318
198
|
return results;
|
|
319
199
|
}
|
|
320
|
-
function
|
|
200
|
+
function assertFaceTimeNativeAction(action, result) {
|
|
321
201
|
const present = requireCompleteTopology(result).filter((entry) => entry.outcome !== "absent");
|
|
322
202
|
if (present.length === 0) throw new FaceTimeHelperAmbiguousError(`FaceTime ${action} carrier owner is missing`, result);
|
|
323
|
-
if ((action === "unmute" || action === "activate") && present.every((observed) => observed.muted === false && observed.is_uplink_muted === false && typeof observed.conversation_audio_error !== "string" && (action === "unmute" || observed.is_sending_audio === true && observed.is_sending_transmission === true))) return
|
|
324
|
-
if ((action === "answer" || action === "safe-mute") && present.every((observed) => observed.muted === true && observed.is_uplink_muted === true && (action === "answer" ? observed.outcome === "answered-muted" : observed.downlink_muted === true))) return
|
|
325
|
-
if (action === "terminate" && present.every((observed) => observed.outcome === "termination-requested")) return
|
|
326
|
-
throw new
|
|
203
|
+
if ((action === "unmute" || action === "activate") && present.every((observed) => observed.muted === false && observed.is_uplink_muted === false && typeof observed.conversation_audio_error !== "string" && (action === "unmute" || observed.is_sending_audio === true && observed.is_sending_transmission === true))) return;
|
|
204
|
+
if ((action === "answer" || action === "safe-mute") && present.every((observed) => observed.muted === true && observed.is_uplink_muted === true && (action === "answer" ? observed.outcome === "answered-muted" : observed.downlink_muted === true))) return;
|
|
205
|
+
if (action === "terminate" && present.every((observed) => observed.outcome === "termination-requested")) return;
|
|
206
|
+
throw new Error(`FaceTime ${action} postcondition was not observed`);
|
|
327
207
|
}
|
|
328
208
|
function projectCompleteFaceTimeAbsence(result) {
|
|
329
209
|
if (!requireCompleteTopology(result).every((entry) => entry.outcome === "absent" && entry.found === false)) throw new FaceTimeHelperAmbiguousError("FaceTime carrier is still present", result);
|
|
330
|
-
if (
|
|
331
|
-
return
|
|
332
|
-
status: "absent",
|
|
333
|
-
topologyGeneration: result.topologyGeneration
|
|
334
|
-
};
|
|
210
|
+
if (result.topologyGeneration === void 0) throw new FaceTimeHelperAmbiguousError("FaceTime topology generation is missing", result);
|
|
211
|
+
return result.topologyGeneration;
|
|
335
212
|
}
|
|
336
213
|
//#endregion
|
|
337
214
|
//#region extensions/facetime/src/helper-rpc.ts
|
|
338
|
-
const
|
|
339
|
-
const FACETIME_HELPER_BUNDLES = /* @__PURE__ */ new Set([
|
|
340
|
-
|
|
341
|
-
"com.apple.mobilephone",
|
|
342
|
-
"com.apple.TelephonyUtilities"
|
|
343
|
-
]);
|
|
215
|
+
const LEGACY_PHONE_BUNDLES = /* @__PURE__ */ new Set(["com.apple.mobilephone", "com.apple.TelephonyUtilities"]);
|
|
216
|
+
const FACETIME_HELPER_BUNDLES = /* @__PURE__ */ new Set([...DIAL_BUNDLES, ...LEGACY_PHONE_BUNDLES]);
|
|
217
|
+
const isCallHelper = (bundleIdentifier) => DIAL_BUNDLES.has(bundleIdentifier);
|
|
344
218
|
const MAX_FRAME_BYTES = 65536;
|
|
345
219
|
const MAX_CONNECTIONS = 8;
|
|
346
220
|
const MAX_PENDING_ACTIONS = 32;
|
|
@@ -348,15 +222,9 @@ const AUTH_DEADLINE_MS = 3e3;
|
|
|
348
222
|
function helperHmac(ipcKey, message) {
|
|
349
223
|
return createHmac("sha256", ipcKey).update(message).digest("hex");
|
|
350
224
|
}
|
|
351
|
-
function secureStringsEqual(first, second) {
|
|
352
|
-
const firstBuffer = Buffer.from(first);
|
|
353
|
-
const secondBuffer = Buffer.from(second);
|
|
354
|
-
return firstBuffer.length > 0 && firstBuffer.length === secondBuffer.length && timingSafeEqual(firstBuffer, secondBuffer);
|
|
355
|
-
}
|
|
356
225
|
function hasExactKeys(record, keys) {
|
|
357
|
-
const actual = Object.keys(record)
|
|
358
|
-
|
|
359
|
-
return actual.length === expected.length && actual.every((key, index) => key === expected[index]);
|
|
226
|
+
const actual = Object.keys(record);
|
|
227
|
+
return actual.length === keys.length && actual.every((key) => keys.includes(key));
|
|
360
228
|
}
|
|
361
229
|
var FaceTimeHelperSocketServer = class {
|
|
362
230
|
#server;
|
|
@@ -447,10 +315,10 @@ var FaceTimeHelperSocketServer = class {
|
|
|
447
315
|
return await this.#sendActionToAll("inspect-call", { callUUIDs }, 750, requiredPeerProcessIds);
|
|
448
316
|
}
|
|
449
317
|
get connectedSockets() {
|
|
450
|
-
return this.#socketPeers.
|
|
318
|
+
return [...this.#socketPeers.values()].filter((peer) => isCallHelper(peer.bundleIdentifier)).length;
|
|
451
319
|
}
|
|
452
320
|
get connectedHelperBundles() {
|
|
453
|
-
return [...new Set([...this.#socketPeers.values()].map((peer) => peer.bundleIdentifier))];
|
|
321
|
+
return [...new Set([...this.#socketPeers.values()].filter((peer) => isCallHelper(peer.bundleIdentifier)).map((peer) => peer.bundleIdentifier))];
|
|
454
322
|
}
|
|
455
323
|
#handleSocket(socket) {
|
|
456
324
|
if (this.#sockets.size >= MAX_CONNECTIONS) {
|
|
@@ -487,7 +355,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
487
355
|
});
|
|
488
356
|
socket.on("close", () => {
|
|
489
357
|
const disconnectedBundle = this.#socketPeers.get(socket)?.bundleIdentifier;
|
|
490
|
-
if (disconnectedBundle) this.#connectionGeneration += 1;
|
|
358
|
+
if (disconnectedBundle && isCallHelper(disconnectedBundle)) this.#connectionGeneration += 1;
|
|
491
359
|
this.#sockets.delete(socket);
|
|
492
360
|
this.#socketPeers.delete(socket);
|
|
493
361
|
this.#pendingHandshakes.delete(socket);
|
|
@@ -497,7 +365,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
497
365
|
clearTimeout(deadline);
|
|
498
366
|
this.#authDeadlineTimers.delete(socket);
|
|
499
367
|
}
|
|
500
|
-
if (disconnectedBundle) this.params.onDisconnect?.(disconnectedBundle);
|
|
368
|
+
if (disconnectedBundle && isCallHelper(disconnectedBundle)) this.params.onDisconnect?.(disconnectedBundle);
|
|
501
369
|
});
|
|
502
370
|
}
|
|
503
371
|
#handleLine(socket, line) {
|
|
@@ -537,12 +405,21 @@ var FaceTimeHelperSocketServer = class {
|
|
|
537
405
|
if (pending) {
|
|
538
406
|
this.#pending.delete(transactionId);
|
|
539
407
|
clearTimeout(pending.timeout);
|
|
540
|
-
|
|
541
|
-
|
|
408
|
+
const peer = this.#socketPeers.get(socket);
|
|
409
|
+
const result = Object.assign(payload, {
|
|
410
|
+
helperBundleIdentifier: peer?.bundleIdentifier ?? "unknown",
|
|
411
|
+
helperPeer: peer,
|
|
412
|
+
helperResults: void 0,
|
|
413
|
+
helpersContacted: void 0,
|
|
414
|
+
topologyGeneration: void 0,
|
|
415
|
+
topologyComplete: void 0
|
|
416
|
+
});
|
|
417
|
+
if (typeof payload.error === "string" && payload.error) pending.reject(payload.ambiguous === true ? new FaceTimeHelperAmbiguousError(payload.error, result) : new Error(payload.error));
|
|
418
|
+
else pending.resolve(result);
|
|
542
419
|
return;
|
|
543
420
|
}
|
|
544
421
|
const peer = this.#socketPeers.get(socket);
|
|
545
|
-
if (peer) this.params.onMessage(payload, peer);
|
|
422
|
+
if (peer && isCallHelper(peer.bundleIdentifier)) this.params.onMessage(payload, peer);
|
|
546
423
|
}
|
|
547
424
|
#handleClientHello(socket, record) {
|
|
548
425
|
if (this.#pendingHandshakes.has(socket) || this.#socketAuthSessions.has(socket) || !hasExactKeys(record, [
|
|
@@ -564,11 +441,11 @@ var FaceTimeHelperSocketServer = class {
|
|
|
564
441
|
const clientNonce = typeof record.client_nonce === "string" ? record.client_nonce : "";
|
|
565
442
|
const proof = typeof record.proof === "string" ? record.proof : "";
|
|
566
443
|
const expectedProof = helperHmac(this.params.ipcKey, `client-hello\n${bundleIdentifier}\n${buildId}\n${processId}\n${processStartedAtMs}\n${clientNonce}`);
|
|
567
|
-
if (!FACETIME_HELPER_BUNDLES.has(bundleIdentifier) || processId <= 0 || processStartedAtMs <= 0 || clientNonce.length < 32 || !
|
|
444
|
+
if (!FACETIME_HELPER_BUNDLES.has(bundleIdentifier) || processId <= 0 || processStartedAtMs <= 0 || clientNonce.length < 32 || !safeEqualSecret(proof, expectedProof)) {
|
|
568
445
|
socket.destroy();
|
|
569
446
|
return;
|
|
570
447
|
}
|
|
571
|
-
if (buildId !== this.params.buildId) {
|
|
448
|
+
if (buildId !== this.params.buildId && isCallHelper(bundleIdentifier)) {
|
|
572
449
|
this.params.onStale?.(bundleIdentifier, processId);
|
|
573
450
|
socket.destroy();
|
|
574
451
|
return;
|
|
@@ -598,7 +475,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
598
475
|
"event",
|
|
599
476
|
"connection_epoch",
|
|
600
477
|
"proof"
|
|
601
|
-
]) || record.connection_epoch !== handshake.connectionEpoch || typeof record.proof !== "string" || !
|
|
478
|
+
]) || record.connection_epoch !== handshake.connectionEpoch || typeof record.proof !== "string" || !safeEqualSecret(record.proof, helperHmac(handshake.connectionKey, `client-finish\n${handshake.connectionEpoch}`))) {
|
|
602
479
|
socket.destroy();
|
|
603
480
|
return;
|
|
604
481
|
}
|
|
@@ -620,14 +497,14 @@ var FaceTimeHelperSocketServer = class {
|
|
|
620
497
|
bundleIdentifier: session.bundleIdentifier,
|
|
621
498
|
processId: session.processId,
|
|
622
499
|
processStartedAtMs: session.processStartedAtMs,
|
|
623
|
-
connectionGeneration: ++this.#connectionGeneration
|
|
500
|
+
connectionGeneration: isCallHelper(session.bundleIdentifier) ? ++this.#connectionGeneration : this.#connectionGeneration
|
|
624
501
|
});
|
|
625
502
|
const deadline = this.#authDeadlineTimers.get(socket);
|
|
626
503
|
if (deadline) {
|
|
627
504
|
clearTimeout(deadline);
|
|
628
505
|
this.#authDeadlineTimers.delete(socket);
|
|
629
506
|
}
|
|
630
|
-
this.params.onConnect?.(session.bundleIdentifier);
|
|
507
|
+
if (isCallHelper(session.bundleIdentifier)) this.params.onConnect?.(session.bundleIdentifier);
|
|
631
508
|
}
|
|
632
509
|
#consumeHelperEnvelope(socket, record) {
|
|
633
510
|
const session = this.#socketAuthSessions.get(socket);
|
|
@@ -639,7 +516,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
639
516
|
"auth"
|
|
640
517
|
]) || record.connection_epoch !== session.connectionEpoch || record.direction !== "helper-to-server" || typeof record.sequence !== "number" || !Number.isSafeInteger(record.sequence) || record.sequence !== session.incomingSequence + 1 || typeof record.payload_json !== "string" || typeof record.auth !== "string") return;
|
|
641
518
|
const expectedAuth = helperHmac(session.connectionKey, `message\nhelper-to-server\n${session.connectionEpoch}\n${record.sequence}\n${record.payload_json}`);
|
|
642
|
-
if (!
|
|
519
|
+
if (!safeEqualSecret(record.auth, expectedAuth)) return;
|
|
643
520
|
let payload;
|
|
644
521
|
try {
|
|
645
522
|
payload = JSON.parse(record.payload_json);
|
|
@@ -663,37 +540,28 @@ var FaceTimeHelperSocketServer = class {
|
|
|
663
540
|
payload_json: payloadJson,
|
|
664
541
|
auth: helperHmac(session.connectionKey, `message\nserver-to-helper\n${session.connectionEpoch}\n${sequence}\n${payloadJson}`)
|
|
665
542
|
});
|
|
666
|
-
if (Buffer.byteLength(envelope) > MAX_FRAME_BYTES) throw new
|
|
543
|
+
if (Buffer.byteLength(envelope) > MAX_FRAME_BYTES) throw new Error("FaceTime helper message exceeds the frame limit");
|
|
667
544
|
session.outgoingSequence = sequence;
|
|
668
545
|
socket.write(`${envelope}\r\n`);
|
|
669
546
|
}
|
|
670
547
|
async #sendAction(action, data) {
|
|
671
|
-
const socket = [...this.#sockets].find((candidate) => !candidate.destroyed &&
|
|
548
|
+
const socket = [...this.#sockets].find((candidate) => !candidate.destroyed && DIAL_BUNDLES.has(this.#socketPeers.get(candidate)?.bundleIdentifier ?? ""));
|
|
672
549
|
if (!socket) throw new FaceTimeHelperUnavailableError("Authenticated FaceTime dialing helper is not connected to the facetime event socket");
|
|
673
|
-
return
|
|
674
|
-
...await this.#sendActionOnSocket(socket, action, data),
|
|
675
|
-
helperBundleIdentifier: this.#socketPeers.get(socket)?.bundleIdentifier ?? "unknown",
|
|
676
|
-
helperPeer: this.#socketPeers.get(socket)
|
|
677
|
-
};
|
|
550
|
+
return await this.#sendActionOnSocket(socket, action, data);
|
|
678
551
|
}
|
|
679
552
|
async #sendActionToAll(action, data, timeoutMs = 5e3, requiredPeerProcessIds = []) {
|
|
680
|
-
const sockets = [...this.#sockets].filter((candidate) => !candidate.destroyed &&
|
|
553
|
+
const sockets = [...this.#sockets].filter((candidate) => !candidate.destroyed && isCallHelper(this.#socketPeers.get(candidate)?.bundleIdentifier ?? ""));
|
|
681
554
|
if (sockets.length === 0) throw new FaceTimeHelperUnavailableError("FaceTime helper is not connected to the facetime event socket");
|
|
682
|
-
const peers = sockets.map((socket) => this.#socketPeers.get(socket));
|
|
683
555
|
const results = await Promise.allSettled(sockets.map((socket) => this.#sendActionOnSocket(socket, action, data, timeoutMs)));
|
|
684
|
-
const fulfilled = results.flatMap((result
|
|
685
|
-
...result.value,
|
|
686
|
-
helperBundleIdentifier: peers[index]?.bundleIdentifier ?? "unknown",
|
|
687
|
-
helperPeer: peers[index]
|
|
688
|
-
}] : []);
|
|
556
|
+
const fulfilled = results.flatMap((result) => result.status === "fulfilled" ? [result.value] : []);
|
|
689
557
|
if (fulfilled.length > 0) {
|
|
690
558
|
const fulfilledProcessIds = new Set(fulfilled.flatMap(({ helperPeer }) => helperPeer ? [helperPeer.processId] : []));
|
|
691
559
|
return {
|
|
560
|
+
...fulfilled[fulfilled.length - 1],
|
|
692
561
|
helpersContacted: sockets.length,
|
|
693
562
|
topologyGeneration: this.#connectionGeneration,
|
|
694
563
|
topologyComplete: fulfilled.length === sockets.length && requiredPeerProcessIds.every((processId) => fulfilledProcessIds.has(processId)),
|
|
695
|
-
helperResults: fulfilled
|
|
696
|
-
...fulfilled[fulfilled.length - 1]
|
|
564
|
+
helperResults: fulfilled
|
|
697
565
|
};
|
|
698
566
|
}
|
|
699
567
|
const firstRejected = results.find((result) => result.status === "rejected");
|
|
@@ -702,7 +570,6 @@ var FaceTimeHelperSocketServer = class {
|
|
|
702
570
|
async #sendActionOnSocket(socket, action, data, timeoutMs = 5e3) {
|
|
703
571
|
if (this.#pending.size >= MAX_PENDING_ACTIONS) throw new FaceTimeHelperUnavailableError("FaceTime helper action queue is full");
|
|
704
572
|
const transactionId = randomUUID();
|
|
705
|
-
if (!this.#socketAuthSessions.has(socket)) throw new FaceTimeHelperUnavailableError("FaceTime helper socket is not authenticated");
|
|
706
573
|
return await new Promise((resolve, reject) => {
|
|
707
574
|
const timeout = setTimeout(() => {
|
|
708
575
|
this.#pending.delete(transactionId);
|
|
@@ -729,15 +596,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
729
596
|
};
|
|
730
597
|
//#endregion
|
|
731
598
|
//#region extensions/facetime/src/helper-supervisor.ts
|
|
732
|
-
const
|
|
733
|
-
FaceTime: /* @__PURE__ */ new Set(["com.apple.FaceTime", "com.apple.FaceTime.FTConversationService"]),
|
|
734
|
-
Phone: /* @__PURE__ */ new Set(["com.apple.mobilephone", "com.apple.TelephonyUtilities"])
|
|
735
|
-
};
|
|
736
|
-
const TARGET_APP_PATHS = {
|
|
737
|
-
FaceTime: "/System/Applications/FaceTime.app",
|
|
738
|
-
Phone: "/System/Applications/Phone.app"
|
|
739
|
-
};
|
|
740
|
-
const FACETIME_HELPER_TARGETS = ["FaceTime", "Phone"];
|
|
599
|
+
const FACETIME_HELPER_TARGETS = ["FaceTime"];
|
|
741
600
|
const RETRY_DELAYS_MS = [
|
|
742
601
|
1e3,
|
|
743
602
|
2e3,
|
|
@@ -747,7 +606,7 @@ const RETRY_DELAYS_MS = [
|
|
|
747
606
|
6e4
|
|
748
607
|
];
|
|
749
608
|
function targetForBundle(bundleIdentifier) {
|
|
750
|
-
return
|
|
609
|
+
return DIAL_BUNDLES.has(bundleIdentifier) ? "FaceTime" : void 0;
|
|
751
610
|
}
|
|
752
611
|
var FaceTimeHelperSupervisor = class {
|
|
753
612
|
#states;
|
|
@@ -757,7 +616,7 @@ var FaceTimeHelperSupervisor = class {
|
|
|
757
616
|
#abortController = new AbortController();
|
|
758
617
|
constructor(params) {
|
|
759
618
|
this.params = params;
|
|
760
|
-
this.#states = new Map(FACETIME_HELPER_TARGETS.filter((target) => existsSync(
|
|
619
|
+
this.#states = new Map(FACETIME_HELPER_TARGETS.filter((target) => existsSync(`/System/Applications/${target}.app`)).map((target) => [target, {
|
|
761
620
|
target,
|
|
762
621
|
connected: false,
|
|
763
622
|
attempts: 0,
|
|
@@ -821,9 +680,8 @@ var FaceTimeHelperSupervisor = class {
|
|
|
821
680
|
#refreshConnections() {
|
|
822
681
|
const bundles = new Set(this.params.connectedBundles());
|
|
823
682
|
for (const target of FACETIME_HELPER_TARGETS) {
|
|
824
|
-
const acceptedBundles = TARGET_BUNDLES[target];
|
|
825
683
|
const state = this.#states.get(target);
|
|
826
|
-
if (state) state.connected = [...
|
|
684
|
+
if (state) state.connected = [...DIAL_BUNDLES].some((bundle) => bundles.has(bundle));
|
|
827
685
|
}
|
|
828
686
|
}
|
|
829
687
|
#cancelTimer(target) {
|
|
@@ -879,8 +737,8 @@ var FaceTimeHelperSupervisor = class {
|
|
|
879
737
|
this.#injectionChain = pending.catch(() => void 0);
|
|
880
738
|
}
|
|
881
739
|
async #waitForAuthenticatedConnection(target) {
|
|
882
|
-
const deadline =
|
|
883
|
-
while (this.#started &&
|
|
740
|
+
const deadline = performance.now() + 1e4;
|
|
741
|
+
while (this.#started && performance.now() < deadline) {
|
|
884
742
|
this.#refreshConnections();
|
|
885
743
|
const state = this.#states.get(target);
|
|
886
744
|
if (!state || state.connected || state.stale) return;
|
|
@@ -1272,7 +1130,6 @@ function createAudioReadiness() {
|
|
|
1272
1130
|
function startFaceTimeAudioPump(params) {
|
|
1273
1131
|
const childEnv = sanitizedAudioChildEnv();
|
|
1274
1132
|
const playbackClock = new PlaybackClock();
|
|
1275
|
-
let playbackGeneration = 1;
|
|
1276
1133
|
let drainTimer;
|
|
1277
1134
|
let outputProcess;
|
|
1278
1135
|
const captureProcess = spawnAudioProcess({
|
|
@@ -1300,10 +1157,8 @@ function startFaceTimeAudioPump(params) {
|
|
|
1300
1157
|
});
|
|
1301
1158
|
};
|
|
1302
1159
|
const cancelDrainTimer = () => {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
drainTimer = void 0;
|
|
1306
|
-
}
|
|
1160
|
+
clearTimeout(drainTimer);
|
|
1161
|
+
drainTimer = void 0;
|
|
1307
1162
|
};
|
|
1308
1163
|
const spawnOutput = () => {
|
|
1309
1164
|
const proc = spawnAudioProcess({ kind: "playback" }, childEnv);
|
|
@@ -1328,7 +1183,6 @@ function startFaceTimeAudioPump(params) {
|
|
|
1328
1183
|
if (stopped || mediaSuspended) return;
|
|
1329
1184
|
const previous = outputProcess;
|
|
1330
1185
|
outputProcess = spawnOutput();
|
|
1331
|
-
playbackGeneration += 1;
|
|
1332
1186
|
cancelDrainTimer();
|
|
1333
1187
|
playbackClock.reset();
|
|
1334
1188
|
terminateProcess(previous, "SIGKILL");
|
|
@@ -1419,9 +1273,8 @@ function startFaceTimeAudioPump(params) {
|
|
|
1419
1273
|
return;
|
|
1420
1274
|
}
|
|
1421
1275
|
cancelDrainTimer();
|
|
1422
|
-
const generation = playbackGeneration;
|
|
1423
1276
|
const notifyWhenDrained = () => {
|
|
1424
|
-
if (stopped || mediaSuspended
|
|
1277
|
+
if (stopped || mediaSuspended) return;
|
|
1425
1278
|
const delayMs = Math.ceil(playbackClock.millisecondsUntilDrained());
|
|
1426
1279
|
if (delayMs > 0) {
|
|
1427
1280
|
drainTimer = setTimeout(notifyWhenDrained, Math.max(1, delayMs));
|
|
@@ -1430,10 +1283,7 @@ function startFaceTimeAudioPump(params) {
|
|
|
1430
1283
|
}
|
|
1431
1284
|
drainTimer = void 0;
|
|
1432
1285
|
playbackClock.retireItems();
|
|
1433
|
-
params.onPlaybackDrained?.(
|
|
1434
|
-
generation,
|
|
1435
|
-
playedFrames: Math.floor(playbackClock.playedFrames())
|
|
1436
|
-
});
|
|
1286
|
+
params.onPlaybackDrained?.();
|
|
1437
1287
|
};
|
|
1438
1288
|
notifyWhenDrained();
|
|
1439
1289
|
},
|
|
@@ -1565,9 +1415,6 @@ function parseDefaultAudioDevices(raw) {
|
|
|
1565
1415
|
}
|
|
1566
1416
|
};
|
|
1567
1417
|
}
|
|
1568
|
-
function firstLine(value) {
|
|
1569
|
-
return typeof value === "string" ? value.trim().split(/\r?\n/u)[0] || void 0 : void 0;
|
|
1570
|
-
}
|
|
1571
1418
|
function pushCheck(checks, check) {
|
|
1572
1419
|
checks.push({
|
|
1573
1420
|
required: true,
|
|
@@ -1597,27 +1444,6 @@ function findPhysicalOutputProblem(defaults, devices) {
|
|
|
1597
1444
|
if (defaults.output.isAggregate) return `system output is aggregate device ${defaults.output.name}`;
|
|
1598
1445
|
if (devices.some((device) => device.name === defaults.output.name && device.virtual) || /BlackHole|OpenClaw-(?:Feed|Mic)/iu.test(defaults.output.name)) return `system output is virtual device ${defaults.output.name}`;
|
|
1599
1446
|
}
|
|
1600
|
-
async function checkCallApp(params) {
|
|
1601
|
-
for (const app of ["FaceTime", "Phone"]) if ((await params.runCommandWithTimeout([
|
|
1602
|
-
"/usr/bin/pgrep",
|
|
1603
|
-
"-x",
|
|
1604
|
-
app
|
|
1605
|
-
], { timeoutMs: 5e3 })).code === 0) {
|
|
1606
|
-
pushCheck(params.checks, {
|
|
1607
|
-
id: "call-app-running",
|
|
1608
|
-
label: "FaceTime or Phone process",
|
|
1609
|
-
ok: true,
|
|
1610
|
-
message: app
|
|
1611
|
-
});
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
pushCheck(params.checks, {
|
|
1615
|
-
id: "call-app-running",
|
|
1616
|
-
label: "FaceTime or Phone process",
|
|
1617
|
-
ok: false,
|
|
1618
|
-
message: "open FaceTime for video calls or Phone for FaceTime audio calls"
|
|
1619
|
-
});
|
|
1620
|
-
}
|
|
1621
1447
|
async function runFaceTimePreflight(params) {
|
|
1622
1448
|
const runCommandWithTimeout = params.runtime.system.runCommandWithTimeout;
|
|
1623
1449
|
const checks = [];
|
|
@@ -1638,9 +1464,16 @@ async function runFaceTimePreflight(params) {
|
|
|
1638
1464
|
ok: executable.code === 0,
|
|
1639
1465
|
message: executable.code === 0 ? params.captureBinary : "capture helper is missing; reinstall with brew install openclaw/tap/openclaw-facetime"
|
|
1640
1466
|
});
|
|
1641
|
-
await
|
|
1642
|
-
|
|
1643
|
-
|
|
1467
|
+
const result = await runCommandWithTimeout([
|
|
1468
|
+
"/usr/bin/pgrep",
|
|
1469
|
+
"-x",
|
|
1470
|
+
"FaceTime"
|
|
1471
|
+
], { timeoutMs: 5e3 });
|
|
1472
|
+
pushCheck(checks, {
|
|
1473
|
+
id: "call-app-running",
|
|
1474
|
+
label: "FaceTime process",
|
|
1475
|
+
ok: result.code === 0,
|
|
1476
|
+
message: result.code === 0 ? "FaceTime" : "open FaceTime for audio or video calls"
|
|
1644
1477
|
});
|
|
1645
1478
|
const profiler = await runCommandWithTimeout([
|
|
1646
1479
|
"/usr/sbin/system_profiler",
|
|
@@ -1743,7 +1576,7 @@ async function terminateExactCarrierProcesses(params) {
|
|
|
1743
1576
|
params.assertCurrent();
|
|
1744
1577
|
if (params.peers.size === 0) throw new Error("no authenticated carrier process identity is available for safe shutdown");
|
|
1745
1578
|
for (const peer of params.peers.values()) {
|
|
1746
|
-
const expected = peer.bundleIdentifier === "com.apple.FaceTime" ? "FaceTime" : peer.bundleIdentifier === "com.apple.FaceTime.FTConversationService" ? "FTConversationService" :
|
|
1579
|
+
const expected = peer.bundleIdentifier === "com.apple.FaceTime" ? "FaceTime" : peer.bundleIdentifier === "com.apple.FaceTime.FTConversationService" ? "FTConversationService" : "";
|
|
1747
1580
|
const inspectExactProcess = async () => {
|
|
1748
1581
|
const inspected = await params.runtime.system.runCommandWithTimeout([
|
|
1749
1582
|
"/bin/ps",
|
|
@@ -1787,19 +1620,8 @@ async function terminateExactCarrierProcesses(params) {
|
|
|
1787
1620
|
}
|
|
1788
1621
|
//#endregion
|
|
1789
1622
|
//#region extensions/facetime/src/runtime-helper-results.ts
|
|
1790
|
-
const OUTBOUND_DIAL_HELPER_BUNDLES = /* @__PURE__ */ new Set(["com.apple.FaceTime", "com.apple.FaceTime.FTConversationService"]);
|
|
1791
1623
|
function readHelperPeers(result) {
|
|
1792
|
-
|
|
1793
|
-
for (const entry of readHelperResults(result)) {
|
|
1794
|
-
const peer = entry.helperPeer;
|
|
1795
|
-
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({
|
|
1796
|
-
bundleIdentifier: peer.bundleIdentifier,
|
|
1797
|
-
processId: peer.processId,
|
|
1798
|
-
processStartedAtMs: peer.processStartedAtMs,
|
|
1799
|
-
connectionGeneration: peer.connectionGeneration
|
|
1800
|
-
});
|
|
1801
|
-
}
|
|
1802
|
-
return peers;
|
|
1624
|
+
return readHelperResults(result).flatMap((entry) => entry.helperPeer ? [entry.helperPeer] : []);
|
|
1803
1625
|
}
|
|
1804
1626
|
function retainHelperResultPeers(call, result) {
|
|
1805
1627
|
for (const peer of readHelperPeers(result)) call.carrierPeers.set(peer.processId, peer);
|
|
@@ -1807,7 +1629,7 @@ function retainHelperResultPeers(call, result) {
|
|
|
1807
1629
|
function retainOutboundDialHelperPeers(peers, result) {
|
|
1808
1630
|
for (const entry of readHelperResults(result)) {
|
|
1809
1631
|
if (entry.found === false && entry.retained_outbound_dial !== true && entry.cancelled !== true) continue;
|
|
1810
|
-
for (const peer of readHelperPeers(entry)) if (
|
|
1632
|
+
for (const peer of readHelperPeers(entry)) if (DIAL_BUNDLES.has(peer.bundleIdentifier)) peers.set(peer.processId, peer);
|
|
1811
1633
|
}
|
|
1812
1634
|
}
|
|
1813
1635
|
function readOutboundCallUUID(result) {
|
|
@@ -1817,7 +1639,7 @@ function readOutboundProxyIdentifier(result) {
|
|
|
1817
1639
|
return readHelperResults(result).map((entry) => normalizeOptionalString(entry.proxy_identifier)).find((value) => Boolean(value));
|
|
1818
1640
|
}
|
|
1819
1641
|
function hasDialHelperConfirmation(results) {
|
|
1820
|
-
return results.some((entry) =>
|
|
1642
|
+
return results.some((entry) => DIAL_BUNDLES.has(entry.helperBundleIdentifier ?? ""));
|
|
1821
1643
|
}
|
|
1822
1644
|
function hasDefinitiveDialHelperAbsence(result, requiredPeerProcessIds) {
|
|
1823
1645
|
const results = readHelperResults(result);
|
|
@@ -1849,7 +1671,7 @@ async function reconcilePendingFaceTimeCarrier(params) {
|
|
|
1849
1671
|
await params.persist();
|
|
1850
1672
|
}
|
|
1851
1673
|
if (reconciledCallUUID || reconciledProxyIdentifier || readHelperResults(result).some((entry) => entry.found === true)) return;
|
|
1852
|
-
const topologyGeneration =
|
|
1674
|
+
const topologyGeneration = result.topologyGeneration;
|
|
1853
1675
|
const completeAbsence = hasDefinitiveDialHelperAbsence(result, params.peers.keys());
|
|
1854
1676
|
if (completeAbsence && topologyGeneration !== void 0 && topologyGeneration === previousAbsentTopology && previousAbsenceCurrent?.()) {
|
|
1855
1677
|
await params.clear();
|
|
@@ -1887,7 +1709,6 @@ function createFaceTimeConsultController(params) {
|
|
|
1887
1709
|
};
|
|
1888
1710
|
const abortConsult = (consult, reason) => {
|
|
1889
1711
|
consult.abortController.abort(/* @__PURE__ */ new Error(`FaceTime agent consult ${reason}`));
|
|
1890
|
-
consult.runRegistration?.controller.abort(/* @__PURE__ */ new Error(`FaceTime agent consult run ${reason}`));
|
|
1891
1712
|
};
|
|
1892
1713
|
const abortForClose = () => {
|
|
1893
1714
|
for (const consult of pending.values()) {
|
|
@@ -2099,7 +1920,7 @@ function createFaceTimeConsultController(params) {
|
|
|
2099
1920
|
sessionKey: params.consultSessionKey,
|
|
2100
1921
|
spawnedBy: params.requesterSessionKey,
|
|
2101
1922
|
senderId: params.senderId,
|
|
2102
|
-
senderIsOwner:
|
|
1923
|
+
senderIsOwner: true,
|
|
2103
1924
|
contextMode: "fork",
|
|
2104
1925
|
messageProvider: AGENT_CONSULT_MESSAGE_PROVIDER,
|
|
2105
1926
|
lane: `facetime:${params.normalizedCallUUID}`,
|
|
@@ -2113,21 +1934,7 @@ function createFaceTimeConsultController(params) {
|
|
|
2113
1934
|
toolsAllow: resolveRealtimeVoiceAgentConsultToolsAllow(params.config.realtime.toolPolicy),
|
|
2114
1935
|
extraSystemPrompt: CONSULT_SYSTEM_PROMPT,
|
|
2115
1936
|
thinkLevel: "off",
|
|
2116
|
-
abortSignal: consult.abortController.signal
|
|
2117
|
-
onRunStarted: ({ runId }) => {
|
|
2118
|
-
const registration = {
|
|
2119
|
-
runId,
|
|
2120
|
-
controller: new AbortController()
|
|
2121
|
-
};
|
|
2122
|
-
consult.runRegistration = registration;
|
|
2123
|
-
if (consult.cancelRequested || pending.get(consult.callId) !== consult) registration.controller.abort(/* @__PURE__ */ new Error("FaceTime agent consult was already cancelled"));
|
|
2124
|
-
return {
|
|
2125
|
-
abortSignal: registration.controller.signal,
|
|
2126
|
-
cleanup: () => {
|
|
2127
|
-
if (consult.runRegistration === registration) consult.runRegistration = void 0;
|
|
2128
|
-
}
|
|
2129
|
-
};
|
|
2130
|
-
}
|
|
1937
|
+
abortSignal: consult.abortController.signal
|
|
2131
1938
|
}).then((result) => deliverResult(result), async (error) => {
|
|
2132
1939
|
if (!ownsConsult(consult) || consult.cancelRequested) return;
|
|
2133
1940
|
const message = formatErrorMessage(error);
|
|
@@ -2141,37 +1948,9 @@ function createFaceTimeConsultController(params) {
|
|
|
2141
1948
|
};
|
|
2142
1949
|
}
|
|
2143
1950
|
//#endregion
|
|
2144
|
-
//#region extensions/facetime/src/talk-
|
|
1951
|
+
//#region extensions/facetime/src/talk-driver.ts
|
|
2145
1952
|
const FACETIME_INITIAL_GREETING = "Greet the caller briefly, introduce yourself using your configured identity, and ask how you can help.";
|
|
2146
1953
|
const FACETIME_GREETING_MEDIA_SETTLE_MS = 100;
|
|
2147
|
-
function createFaceTimeInitialGreeting(params) {
|
|
2148
|
-
let timer;
|
|
2149
|
-
let dismissed = false;
|
|
2150
|
-
const clear = () => {
|
|
2151
|
-
if (timer) {
|
|
2152
|
-
clearTimeout(timer);
|
|
2153
|
-
timer = void 0;
|
|
2154
|
-
}
|
|
2155
|
-
};
|
|
2156
|
-
return {
|
|
2157
|
-
instructions: FACETIME_INITIAL_GREETING,
|
|
2158
|
-
schedule() {
|
|
2159
|
-
if (dismissed || timer) return;
|
|
2160
|
-
timer = setTimeout(() => {
|
|
2161
|
-
timer = void 0;
|
|
2162
|
-
dismissed = true;
|
|
2163
|
-
params.speak(FACETIME_INITIAL_GREETING);
|
|
2164
|
-
}, FACETIME_GREETING_MEDIA_SETTLE_MS);
|
|
2165
|
-
timer.unref?.();
|
|
2166
|
-
},
|
|
2167
|
-
cancel() {
|
|
2168
|
-
dismissed = true;
|
|
2169
|
-
clear();
|
|
2170
|
-
}
|
|
2171
|
-
};
|
|
2172
|
-
}
|
|
2173
|
-
//#endregion
|
|
2174
|
-
//#region extensions/facetime/src/talk-driver.ts
|
|
2175
1954
|
async function startFaceTimeTalkDriver(params) {
|
|
2176
1955
|
if (params.signal?.aborted) throw new Error("FaceTime talk startup aborted");
|
|
2177
1956
|
const consultAgentId = agentIdFromSessionKey(params.config.realtime.sessionKey, params.fullConfig);
|
|
@@ -2201,7 +1980,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2201
1980
|
let response;
|
|
2202
1981
|
const settledResponseIds = /* @__PURE__ */ new Set();
|
|
2203
1982
|
let suppressNextUnkeyedLegacyTerminal = false;
|
|
2204
|
-
const consultRef = {};
|
|
2205
1983
|
let failurePromise;
|
|
2206
1984
|
let activated = false;
|
|
2207
1985
|
let providerReady = false;
|
|
@@ -2224,9 +2002,25 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2224
2002
|
startupFailure = error;
|
|
2225
2003
|
startupFailureDeferred.reject(error);
|
|
2226
2004
|
};
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
2005
|
+
let timer;
|
|
2006
|
+
let dismissed = false;
|
|
2007
|
+
const initialGreeting = {
|
|
2008
|
+
instructions: FACETIME_INITIAL_GREETING,
|
|
2009
|
+
schedule() {
|
|
2010
|
+
if (dismissed || timer) return;
|
|
2011
|
+
timer = setTimeout(() => {
|
|
2012
|
+
timer = void 0;
|
|
2013
|
+
dismissed = true;
|
|
2014
|
+
if (!stopped && !mediaSuspended && activated && providerReady) bridge?.triggerGreeting(FACETIME_INITIAL_GREETING);
|
|
2015
|
+
}, FACETIME_GREETING_MEDIA_SETTLE_MS);
|
|
2016
|
+
timer.unref?.();
|
|
2017
|
+
},
|
|
2018
|
+
cancel() {
|
|
2019
|
+
dismissed = true;
|
|
2020
|
+
clearTimeout(timer);
|
|
2021
|
+
timer = void 0;
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2230
2024
|
const reportFailure = (error) => {
|
|
2231
2025
|
if (failurePromise) return failurePromise;
|
|
2232
2026
|
failurePromise = Promise.resolve(params.onFailure?.(error)).then((safeToClose) => safeToClose !== false);
|
|
@@ -2241,7 +2035,7 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2241
2035
|
mediaSuspensionError ??= /* @__PURE__ */ new Error(`FaceTime model media suspended: ${reason}`);
|
|
2242
2036
|
mediaSuspendedDeferred.reject(mediaSuspensionError);
|
|
2243
2037
|
interruptProviderConnect?.();
|
|
2244
|
-
|
|
2038
|
+
consultController.abortForClose();
|
|
2245
2039
|
suspendMediaPromise = (async () => {
|
|
2246
2040
|
try {
|
|
2247
2041
|
await bridge?.close();
|
|
@@ -2350,7 +2144,7 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2350
2144
|
};
|
|
2351
2145
|
const resetProviderContinuity = () => {
|
|
2352
2146
|
modelMediaGeneration += 1;
|
|
2353
|
-
|
|
2147
|
+
consultController.abortForClose();
|
|
2354
2148
|
pump?.clearOutputAudio();
|
|
2355
2149
|
resetResponsePlayback();
|
|
2356
2150
|
finishOutputAudio("continuity-reset");
|
|
@@ -2366,7 +2160,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2366
2160
|
requesterSessionKey,
|
|
2367
2161
|
normalizedCallUUID,
|
|
2368
2162
|
senderId: params.senderId,
|
|
2369
|
-
senderIsOwner: params.senderIsOwner,
|
|
2370
2163
|
transcript,
|
|
2371
2164
|
getBridge: () => bridge,
|
|
2372
2165
|
getGeneration: () => modelMediaGeneration,
|
|
@@ -2378,7 +2171,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2378
2171
|
close,
|
|
2379
2172
|
onHangupRequested: params.onHangupRequested
|
|
2380
2173
|
});
|
|
2381
|
-
consultRef.current = consultController;
|
|
2382
2174
|
remember({
|
|
2383
2175
|
type: "session.started",
|
|
2384
2176
|
payload: { callUUID: params.callUUID }
|
|
@@ -2606,7 +2398,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2606
2398
|
throw error;
|
|
2607
2399
|
}
|
|
2608
2400
|
return {
|
|
2609
|
-
callUUID: params.callUUID,
|
|
2610
2401
|
get recentTalkEvents() {
|
|
2611
2402
|
return talk.recentEvents;
|
|
2612
2403
|
},
|
|
@@ -2642,7 +2433,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2642
2433
|
allowClosing: true,
|
|
2643
2434
|
action: async () => await request.run(candidate)
|
|
2644
2435
|
});
|
|
2645
|
-
|
|
2436
|
+
assertFaceTimeNativeAction(request.action, result);
|
|
2646
2437
|
request.call.promoteCarrierCallUUID(candidate);
|
|
2647
2438
|
return result;
|
|
2648
2439
|
} catch (error) {
|
|
@@ -2670,8 +2461,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2670
2461
|
captureBinary: params.captureBinary,
|
|
2671
2462
|
feedDevice: "OpenClaw-Feed",
|
|
2672
2463
|
microphoneDevice: "OpenClaw-Mic",
|
|
2673
|
-
processInputVerified: false
|
|
2674
|
-
processOutputSuppressed: false
|
|
2464
|
+
processInputVerified: false
|
|
2675
2465
|
};
|
|
2676
2466
|
call.lastRoutingError = void 0;
|
|
2677
2467
|
})();
|
|
@@ -2689,26 +2479,23 @@ function createFaceTimeCallControl(params) {
|
|
|
2689
2479
|
if (call.lifecycleAbort.signal.aborted) throw new Error("FaceTime call closed during audio routing");
|
|
2690
2480
|
};
|
|
2691
2481
|
const enableCallAudio = async (call) => {
|
|
2692
|
-
const generation = call.
|
|
2482
|
+
const generation = call.generation;
|
|
2693
2483
|
const mutedResult = await call.runCarrierCommand({
|
|
2694
2484
|
generation,
|
|
2695
2485
|
action: async () => await params.helper.setMuted(call.carrierCallUUID, false)
|
|
2696
2486
|
});
|
|
2697
2487
|
call.lastHelperAction = mutedResult;
|
|
2698
2488
|
retainHelperResultPeers(call, mutedResult);
|
|
2699
|
-
|
|
2489
|
+
assertFaceTimeNativeAction("unmute", mutedResult);
|
|
2700
2490
|
const transmissionResult = await call.runCarrierCommand({
|
|
2701
2491
|
generation,
|
|
2702
2492
|
action: async () => await params.helper.startTransmission(call.carrierCallUUID)
|
|
2703
2493
|
});
|
|
2704
2494
|
call.lastHelperAction = transmissionResult;
|
|
2705
2495
|
retainHelperResultPeers(call, transmissionResult);
|
|
2706
|
-
|
|
2496
|
+
assertFaceTimeNativeAction("activate", transmissionResult);
|
|
2707
2497
|
call.markCarrierActive(generation);
|
|
2708
|
-
if (call.audioTransport)
|
|
2709
|
-
call.audioTransport.processInputVerified = true;
|
|
2710
|
-
call.audioTransport.processOutputSuppressed = call.talk?.processOutputSuppressed() === true;
|
|
2711
|
-
}
|
|
2498
|
+
if (call.audioTransport) call.audioTransport.processInputVerified = true;
|
|
2712
2499
|
};
|
|
2713
2500
|
const closeCall = async (call, reason) => {
|
|
2714
2501
|
if (params.calls.active !== call) return;
|
|
@@ -2747,7 +2534,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2747
2534
|
const readCompleteAbsenceGeneration = (error) => {
|
|
2748
2535
|
if (!(error instanceof FaceTimeHelperAmbiguousError)) return;
|
|
2749
2536
|
try {
|
|
2750
|
-
return projectCompleteFaceTimeAbsence(error.result)
|
|
2537
|
+
return projectCompleteFaceTimeAbsence(error.result);
|
|
2751
2538
|
} catch {
|
|
2752
2539
|
return;
|
|
2753
2540
|
}
|
|
@@ -2778,8 +2565,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2778
2565
|
});
|
|
2779
2566
|
const first = projectCompleteFaceTimeAbsence(await inspect());
|
|
2780
2567
|
await sleepWithAbort(100, void 0, { ref: false });
|
|
2781
|
-
|
|
2782
|
-
return first.topologyGeneration === second.topologyGeneration && params.getHelperTopologyVersion() === topologyVersion;
|
|
2568
|
+
return first === projectCompleteFaceTimeAbsence(await inspect()) && params.getHelperTopologyVersion() === topologyVersion;
|
|
2783
2569
|
} catch {
|
|
2784
2570
|
return false;
|
|
2785
2571
|
}
|
|
@@ -2822,7 +2608,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2822
2608
|
})()]);
|
|
2823
2609
|
};
|
|
2824
2610
|
const terminateCarrierProcesses = async (call) => {
|
|
2825
|
-
const generation = call.
|
|
2611
|
+
const generation = call.generation;
|
|
2826
2612
|
await terminateExactCarrierProcesses({
|
|
2827
2613
|
runtime: params.runtime,
|
|
2828
2614
|
peers: call.carrierPeers,
|
|
@@ -2853,7 +2639,6 @@ function createFaceTimeCallControl(params) {
|
|
|
2853
2639
|
logger: params.logger,
|
|
2854
2640
|
callUUID,
|
|
2855
2641
|
senderId: call.senderId,
|
|
2856
|
-
senderIsOwner: call.senderIsOwner,
|
|
2857
2642
|
captureBinary: params.captureBinary,
|
|
2858
2643
|
signal: call.lifecycleAbort.signal,
|
|
2859
2644
|
async onHangupRequested() {
|
|
@@ -2873,7 +2658,6 @@ function createFaceTimeCallControl(params) {
|
|
|
2873
2658
|
return;
|
|
2874
2659
|
}
|
|
2875
2660
|
call.talk = talk;
|
|
2876
|
-
if (call.audioTransport) call.audioTransport.processOutputSuppressed = true;
|
|
2877
2661
|
params.logger.info("[facetime] realtime talk suppression ready");
|
|
2878
2662
|
})();
|
|
2879
2663
|
}
|
|
@@ -2885,13 +2669,11 @@ function createFaceTimeCallControl(params) {
|
|
|
2885
2669
|
}
|
|
2886
2670
|
};
|
|
2887
2671
|
const activateCallTalk = async (call) => {
|
|
2888
|
-
const generation = call.
|
|
2672
|
+
const generation = call.generation;
|
|
2889
2673
|
if (!call.talkActivation) call.talkActivation = (async () => {
|
|
2890
2674
|
await call.talk?.readyForAudio();
|
|
2891
|
-
call.assertCurrent(generation);
|
|
2892
2675
|
call.markModelReady(generation);
|
|
2893
2676
|
await enableCallAudio(call);
|
|
2894
|
-
call.assertCurrent(generation);
|
|
2895
2677
|
call.markModelActive(generation);
|
|
2896
2678
|
call.talk?.activate();
|
|
2897
2679
|
})();
|
|
@@ -2914,13 +2696,26 @@ function createFaceTimeCallControl(params) {
|
|
|
2914
2696
|
}
|
|
2915
2697
|
//#endregion
|
|
2916
2698
|
//#region extensions/facetime/src/runtime-state.ts
|
|
2917
|
-
|
|
2699
|
+
function normalizeCallIdentity(value) {
|
|
2700
|
+
return value.trim().toLowerCase();
|
|
2701
|
+
}
|
|
2702
|
+
var ActiveFaceTimeCall = class {
|
|
2703
|
+
#carrierClosure;
|
|
2704
|
+
#commandTail;
|
|
2918
2705
|
constructor(params) {
|
|
2919
|
-
|
|
2706
|
+
this.lifecycleAbort = new AbortController();
|
|
2707
|
+
this.aliases = /* @__PURE__ */ new Set();
|
|
2708
|
+
this.generation = 1;
|
|
2709
|
+
this.modelMediaMode = "starting";
|
|
2710
|
+
this.#carrierClosure = createDeferred();
|
|
2711
|
+
this.carrierClosure = this.#carrierClosure.promise;
|
|
2712
|
+
this.#commandTail = Promise.resolve();
|
|
2920
2713
|
this.retiredCarrierCallUUIDs = /* @__PURE__ */ new Set();
|
|
2921
2714
|
this.carrierPeers = /* @__PURE__ */ new Map();
|
|
2922
|
-
this.senderIsOwner = true;
|
|
2923
2715
|
this.audioReady = false;
|
|
2716
|
+
this.phase = params.phase;
|
|
2717
|
+
this.carrierMode = params.phase === "ringing" ? "ringing" : "muted";
|
|
2718
|
+
this.aliases.add(normalizeCallIdentity(params.callUUID));
|
|
2924
2719
|
this.callUUID = params.callUUID;
|
|
2925
2720
|
this.carrierCallUUID = params.callUUID;
|
|
2926
2721
|
this.carrierCallUUIDs = /* @__PURE__ */ new Set([params.callUUID]);
|
|
@@ -2928,6 +2723,67 @@ var ActiveFaceTimeCall = class extends FaceTimeCallInstance {
|
|
|
2928
2723
|
this.handle = params.handle;
|
|
2929
2724
|
if (params.peer) this.carrierPeers.set(params.peer.processId, params.peer);
|
|
2930
2725
|
}
|
|
2726
|
+
assertCurrent(generation, allowClosing = false) {
|
|
2727
|
+
const phaseAllowed = allowClosing ? this.phase !== "closed" && this.carrierMode !== "closed" : this.phase !== "closing" && this.phase !== "closed";
|
|
2728
|
+
if (generation !== this.generation || !phaseAllowed || !allowClosing && this.lifecycleAbort.signal.aborted) throw new Error("FaceTime call lifecycle changed during carrier command");
|
|
2729
|
+
}
|
|
2730
|
+
async runCarrierCommand(params) {
|
|
2731
|
+
const previous = this.#commandTail;
|
|
2732
|
+
const { promise, resolve: release } = createDeferred();
|
|
2733
|
+
this.#commandTail = promise;
|
|
2734
|
+
await previous;
|
|
2735
|
+
try {
|
|
2736
|
+
this.assertCurrent(params.generation, params.allowClosing);
|
|
2737
|
+
const result = await params.action();
|
|
2738
|
+
this.assertCurrent(params.generation, params.allowClosing);
|
|
2739
|
+
return result;
|
|
2740
|
+
} finally {
|
|
2741
|
+
release();
|
|
2742
|
+
}
|
|
2743
|
+
}
|
|
2744
|
+
beginAnswering() {
|
|
2745
|
+
if (this.phase !== "ringing") throw new Error(`cannot answer FaceTime call in ${this.phase} phase`);
|
|
2746
|
+
this.phase = "answering";
|
|
2747
|
+
this.carrierMode = "muted";
|
|
2748
|
+
return this.generation;
|
|
2749
|
+
}
|
|
2750
|
+
markCarrierActive(generation) {
|
|
2751
|
+
this.assertCurrent(generation);
|
|
2752
|
+
this.phase = "active";
|
|
2753
|
+
this.carrierMode = "active";
|
|
2754
|
+
}
|
|
2755
|
+
markModelReady(generation) {
|
|
2756
|
+
this.assertCurrent(generation);
|
|
2757
|
+
this.modelMediaMode = "ready";
|
|
2758
|
+
}
|
|
2759
|
+
markModelActive(generation) {
|
|
2760
|
+
this.assertCurrent(generation);
|
|
2761
|
+
this.modelMediaMode = "active";
|
|
2762
|
+
}
|
|
2763
|
+
suspendModelMedia() {
|
|
2764
|
+
if (this.modelMediaMode !== "closed") this.modelMediaMode = "suspended";
|
|
2765
|
+
}
|
|
2766
|
+
beginClosing() {
|
|
2767
|
+
if (this.phase === "closed") return this.generation;
|
|
2768
|
+
if (this.phase !== "closing") {
|
|
2769
|
+
this.generation += 1;
|
|
2770
|
+
this.phase = "closing";
|
|
2771
|
+
this.carrierMode = "closing";
|
|
2772
|
+
this.suspendModelMedia();
|
|
2773
|
+
this.lifecycleAbort.abort(/* @__PURE__ */ new Error("FaceTime call is closing"));
|
|
2774
|
+
}
|
|
2775
|
+
return this.generation;
|
|
2776
|
+
}
|
|
2777
|
+
markCarrierClosed() {
|
|
2778
|
+
this.beginClosing();
|
|
2779
|
+
this.carrierMode = "closed";
|
|
2780
|
+
this.#carrierClosure.resolve(void 0);
|
|
2781
|
+
}
|
|
2782
|
+
markClosed() {
|
|
2783
|
+
this.phase = "closed";
|
|
2784
|
+
this.carrierMode = "closed";
|
|
2785
|
+
this.modelMediaMode = "closed";
|
|
2786
|
+
}
|
|
2931
2787
|
promoteCarrierCallUUID(callUUID) {
|
|
2932
2788
|
if (callUUID !== this.carrierCallUUID) {
|
|
2933
2789
|
this.retiredCarrierCallUUIDs.add(this.carrierCallUUID);
|
|
@@ -2937,6 +2793,37 @@ var ActiveFaceTimeCall = class extends FaceTimeCallInstance {
|
|
|
2937
2793
|
this.carrierCallUUID = callUUID;
|
|
2938
2794
|
}
|
|
2939
2795
|
};
|
|
2796
|
+
var FaceTimeCallRegistry = class {
|
|
2797
|
+
#active;
|
|
2798
|
+
get active() {
|
|
2799
|
+
return this.#active;
|
|
2800
|
+
}
|
|
2801
|
+
get size() {
|
|
2802
|
+
return this.#active && this.#active.phase !== "closed" ? 1 : 0;
|
|
2803
|
+
}
|
|
2804
|
+
values() {
|
|
2805
|
+
return (this.#active && this.#active.phase !== "closed" ? [this.#active] : [])[Symbol.iterator]();
|
|
2806
|
+
}
|
|
2807
|
+
get(identity) {
|
|
2808
|
+
return this.#active?.aliases.has(normalizeCallIdentity(identity)) ? this.#active : void 0;
|
|
2809
|
+
}
|
|
2810
|
+
has(identity) {
|
|
2811
|
+
return this.get(identity) !== void 0;
|
|
2812
|
+
}
|
|
2813
|
+
create(call) {
|
|
2814
|
+
if (this.#active && this.#active.phase !== "closed") throw new Error("another FaceTime call lifecycle is already active");
|
|
2815
|
+
this.#active = call;
|
|
2816
|
+
}
|
|
2817
|
+
retainAlias(call, identity) {
|
|
2818
|
+
if (this.#active !== call || call.phase === "closed") throw new Error("cannot retain an alias for an inactive FaceTime call");
|
|
2819
|
+
call.aliases.add(normalizeCallIdentity(identity));
|
|
2820
|
+
}
|
|
2821
|
+
close(call) {
|
|
2822
|
+
if (this.#active !== call) return;
|
|
2823
|
+
call.markClosed();
|
|
2824
|
+
this.#active = void 0;
|
|
2825
|
+
}
|
|
2826
|
+
};
|
|
2940
2827
|
function updateCallStatus(call, event) {
|
|
2941
2828
|
call.callStatus = event.data.call_status;
|
|
2942
2829
|
call.isSendingAudio = event.data.is_sending_audio ?? call.isSendingAudio;
|
|
@@ -3036,7 +2923,7 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3036
2923
|
generation,
|
|
3037
2924
|
action: async () => await params.helper.answerCall(callUUID)
|
|
3038
2925
|
});
|
|
3039
|
-
|
|
2926
|
+
assertFaceTimeNativeAction("answer", answerResult);
|
|
3040
2927
|
retainHelperResultPeers(call, answerResult);
|
|
3041
2928
|
await params.callControl.activateCallTalk(call);
|
|
3042
2929
|
params.logger.info("[facetime] answered authorized FaceTime call");
|
|
@@ -3142,14 +3029,14 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3142
3029
|
retainPendingDial(ringingCall, pending);
|
|
3143
3030
|
}
|
|
3144
3031
|
if (ringingCall) try {
|
|
3145
|
-
const generation = ringingCall.
|
|
3032
|
+
const generation = ringingCall.generation;
|
|
3146
3033
|
const muteResult = await ringingCall.runCarrierCommand({
|
|
3147
3034
|
generation,
|
|
3148
3035
|
action: async () => await params.helper.safetyMute(ringingCall.carrierCallUUID)
|
|
3149
3036
|
});
|
|
3150
3037
|
ringingCall.lastHelperAction = muteResult;
|
|
3151
3038
|
retainHelperResultPeers(ringingCall, muteResult);
|
|
3152
|
-
|
|
3039
|
+
assertFaceTimeNativeAction("safe-mute", muteResult);
|
|
3153
3040
|
} catch (error) {
|
|
3154
3041
|
params.logger.warn(`[facetime] outbound ringing safety mute failed: ${formatErrorMessage(error)}`);
|
|
3155
3042
|
await params.callControl.attemptCarrierHangup(ringingCall, "outbound-ringing-safety-mute-failed");
|
|
@@ -3208,13 +3095,12 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3208
3095
|
//#region extensions/facetime/src/talk-events-summary.ts
|
|
3209
3096
|
function summarizeRecentTalkEvents(events) {
|
|
3210
3097
|
return events.slice(-12).map((event) => {
|
|
3211
|
-
const
|
|
3212
|
-
const payload = asRecord(record.payload);
|
|
3098
|
+
const payload = asRecord(event.payload);
|
|
3213
3099
|
return {
|
|
3214
|
-
type:
|
|
3215
|
-
turnId: normalizeOptionalString(
|
|
3216
|
-
callId: normalizeOptionalString(
|
|
3217
|
-
final:
|
|
3100
|
+
type: event.type,
|
|
3101
|
+
turnId: normalizeOptionalString(event.turnId),
|
|
3102
|
+
callId: normalizeOptionalString(event.callId),
|
|
3103
|
+
final: event.final,
|
|
3218
3104
|
byteLength: asFiniteNumber(payload.byteLength),
|
|
3219
3105
|
name: normalizeOptionalString(payload.name),
|
|
3220
3106
|
text: normalizeOptionalString(payload.text),
|
|
@@ -3407,7 +3293,7 @@ async function createFaceTimeRuntime(params) {
|
|
|
3407
3293
|
}).finally(scheduleOutboundReconciliation);
|
|
3408
3294
|
const helperResults = readHelperResults(result);
|
|
3409
3295
|
const cancelled = helperResults.some((entry) => entry.cancelled === true);
|
|
3410
|
-
const helpersContacted =
|
|
3296
|
+
const helpersContacted = result.helpersContacted ?? helperResults.length;
|
|
3411
3297
|
const definitivelyAbsent = helperResults.length === helpersContacted && hasDialHelperConfirmation(helperResults) && helperResults.every((entry) => entry.found === false && entry.cancelled === false);
|
|
3412
3298
|
if (!cancelled && !definitivelyAbsent) throw new Error("FaceTime helper could not confirm outbound call cancellation");
|
|
3413
3299
|
const replyCallUUID = helperResults.map(readOutboundCallUUID).find((value) => Boolean(value));
|
|
@@ -3434,7 +3320,7 @@ async function createFaceTimeRuntime(params) {
|
|
|
3434
3320
|
if (helperStopped) return;
|
|
3435
3321
|
const outboundIdentity = normalizeFaceTimeOutboundIdentityEvent(message);
|
|
3436
3322
|
if (outboundIdentity && outboundCallPending?.dialID === outboundIdentity.data.dial_id) {
|
|
3437
|
-
if (
|
|
3323
|
+
if (DIAL_BUNDLES.has(peer.bundleIdentifier)) outboundCarrierPeers.set(peer.processId, peer);
|
|
3438
3324
|
retainFaceTimeDialCallUUID(outboundCallPending, outboundIdentity.data.call_uuid);
|
|
3439
3325
|
if (outboundIdentity.data.proxy_identifier) outboundCallPending.proxyIdentifier = outboundIdentity.data.proxy_identifier;
|
|
3440
3326
|
return observePendingOperation(persistOutboundCallPending());
|