@openclaw/facetime 2026.10.10-beta.5 → 2026.11.5-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/.setup/{setup-DMPG615Z.mjs → setup-ByISvnBj.mjs} +55 -107
- package/dist/.source-module-urls/38481bccca5fbb406e50ac928748f9f04f5a6cf5623980901b3cebc6ee82dfb6.json +1 -1
- package/dist/doctor-contract-api.js +6 -12
- package/dist/index.js +12 -28
- package/dist/runtime-api.js +245 -380
- 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,21 +1,22 @@
|
|
|
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-ByISvnBj.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";
|
|
16
17
|
import { resolveRealtimeVoiceAgentContextInstructions } from "openclaw/plugin-sdk/realtime-bootstrap-context";
|
|
17
18
|
import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
18
|
-
|
|
19
|
+
// extensions/facetime/src/call-events.ts
|
|
19
20
|
const TU_CALL_STATUS = {
|
|
20
21
|
outgoingCreated: 0,
|
|
21
22
|
active: 1,
|
|
@@ -157,129 +158,11 @@ function isEndedCall(event) {
|
|
|
157
158
|
function isUnknownCallStatus(event) {
|
|
158
159
|
return !isIncomingRingingCall(event) && !isOutgoingRingingCall(event) && !isActiveCall(event) && !isEndedCall(event);
|
|
159
160
|
}
|
|
160
|
-
|
|
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
|
-
//#region extensions/facetime/helper-endpoint.json
|
|
161
|
+
// extensions/facetime/helper-endpoint.json
|
|
278
162
|
var host = "127.0.0.1";
|
|
279
163
|
var basePort = 45670;
|
|
280
164
|
var maxPort = 65535;
|
|
281
|
-
|
|
282
|
-
//#region extensions/facetime/src/helper-endpoint.ts
|
|
165
|
+
// extensions/facetime/src/helper-endpoint.ts
|
|
283
166
|
function resolveFaceTimeHelperEndpoint() {
|
|
284
167
|
const uid = typeof process.getuid === "function" ? process.getuid() : 501;
|
|
285
168
|
if (host !== "127.0.0.1" || !Number.isSafeInteger(basePort) || !Number.isSafeInteger(maxPort) || basePort < 1024 || maxPort > 65535 || basePort > maxPort || !Number.isSafeInteger(uid)) throw new Error("Invalid FaceTime loopback helper endpoint contract");
|
|
@@ -288,14 +171,8 @@ function resolveFaceTimeHelperEndpoint() {
|
|
|
288
171
|
port: Math.min(Math.max(basePort + uid - 501, basePort), maxPort)
|
|
289
172
|
};
|
|
290
173
|
}
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
var FaceTimeHelperActionError = class extends Error {
|
|
294
|
-
constructor(message) {
|
|
295
|
-
super(message);
|
|
296
|
-
this.name = "FaceTimeHelperActionError";
|
|
297
|
-
}
|
|
298
|
-
};
|
|
174
|
+
// extensions/facetime/src/helper-results.ts
|
|
175
|
+
const DIAL_BUNDLES = /* @__PURE__ */ new Set(["com.apple.FaceTime", "com.apple.FaceTime.FTConversationService"]);
|
|
299
176
|
var FaceTimeHelperAmbiguousError = class extends Error {
|
|
300
177
|
constructor(message, result = {}) {
|
|
301
178
|
super(message);
|
|
@@ -310,37 +187,30 @@ var FaceTimeHelperUnavailableError = class extends Error {
|
|
|
310
187
|
}
|
|
311
188
|
};
|
|
312
189
|
function readHelperResults(result) {
|
|
313
|
-
return
|
|
190
|
+
return result.helperResults ?? [result];
|
|
314
191
|
}
|
|
315
192
|
function requireCompleteTopology(result) {
|
|
316
193
|
const results = readHelperResults(result);
|
|
317
|
-
if (result.topologyComplete !== true ||
|
|
194
|
+
if (result.topologyComplete !== true || results.length !== result.helpersContacted) throw new FaceTimeHelperAmbiguousError("FaceTime helper topology was incomplete", result);
|
|
318
195
|
return results;
|
|
319
196
|
}
|
|
320
|
-
function
|
|
197
|
+
function assertFaceTimeNativeAction(action, result) {
|
|
321
198
|
const present = requireCompleteTopology(result).filter((entry) => entry.outcome !== "absent");
|
|
322
199
|
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
|
|
200
|
+
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;
|
|
201
|
+
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;
|
|
202
|
+
if (action === "terminate" && present.every((observed) => observed.outcome === "termination-requested")) return;
|
|
203
|
+
throw new Error(`FaceTime ${action} postcondition was not observed`);
|
|
327
204
|
}
|
|
328
205
|
function projectCompleteFaceTimeAbsence(result) {
|
|
329
206
|
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
|
-
};
|
|
207
|
+
if (result.topologyGeneration === void 0) throw new FaceTimeHelperAmbiguousError("FaceTime topology generation is missing", result);
|
|
208
|
+
return result.topologyGeneration;
|
|
335
209
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const
|
|
339
|
-
const
|
|
340
|
-
...FACETIME_DIAL_HELPER_BUNDLES,
|
|
341
|
-
"com.apple.mobilephone",
|
|
342
|
-
"com.apple.TelephonyUtilities"
|
|
343
|
-
]);
|
|
210
|
+
// extensions/facetime/src/helper-rpc.ts
|
|
211
|
+
const LEGACY_PHONE_BUNDLES = /* @__PURE__ */ new Set(["com.apple.mobilephone", "com.apple.TelephonyUtilities"]);
|
|
212
|
+
const FACETIME_HELPER_BUNDLES = /* @__PURE__ */ new Set([...DIAL_BUNDLES, ...LEGACY_PHONE_BUNDLES]);
|
|
213
|
+
const isCallHelper = (bundleIdentifier) => DIAL_BUNDLES.has(bundleIdentifier);
|
|
344
214
|
const MAX_FRAME_BYTES = 65536;
|
|
345
215
|
const MAX_CONNECTIONS = 8;
|
|
346
216
|
const MAX_PENDING_ACTIONS = 32;
|
|
@@ -348,15 +218,9 @@ const AUTH_DEADLINE_MS = 3e3;
|
|
|
348
218
|
function helperHmac(ipcKey, message) {
|
|
349
219
|
return createHmac("sha256", ipcKey).update(message).digest("hex");
|
|
350
220
|
}
|
|
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
221
|
function hasExactKeys(record, keys) {
|
|
357
|
-
const actual = Object.keys(record)
|
|
358
|
-
|
|
359
|
-
return actual.length === expected.length && actual.every((key, index) => key === expected[index]);
|
|
222
|
+
const actual = Object.keys(record);
|
|
223
|
+
return actual.length === keys.length && actual.every((key) => keys.includes(key));
|
|
360
224
|
}
|
|
361
225
|
var FaceTimeHelperSocketServer = class {
|
|
362
226
|
#server;
|
|
@@ -447,10 +311,10 @@ var FaceTimeHelperSocketServer = class {
|
|
|
447
311
|
return await this.#sendActionToAll("inspect-call", { callUUIDs }, 750, requiredPeerProcessIds);
|
|
448
312
|
}
|
|
449
313
|
get connectedSockets() {
|
|
450
|
-
return this.#socketPeers.
|
|
314
|
+
return [...this.#socketPeers.values()].filter((peer) => isCallHelper(peer.bundleIdentifier)).length;
|
|
451
315
|
}
|
|
452
316
|
get connectedHelperBundles() {
|
|
453
|
-
return [...new Set([...this.#socketPeers.values()].map((peer) => peer.bundleIdentifier))];
|
|
317
|
+
return [...new Set([...this.#socketPeers.values()].filter((peer) => isCallHelper(peer.bundleIdentifier)).map((peer) => peer.bundleIdentifier))];
|
|
454
318
|
}
|
|
455
319
|
#handleSocket(socket) {
|
|
456
320
|
if (this.#sockets.size >= MAX_CONNECTIONS) {
|
|
@@ -487,7 +351,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
487
351
|
});
|
|
488
352
|
socket.on("close", () => {
|
|
489
353
|
const disconnectedBundle = this.#socketPeers.get(socket)?.bundleIdentifier;
|
|
490
|
-
if (disconnectedBundle) this.#connectionGeneration += 1;
|
|
354
|
+
if (disconnectedBundle && isCallHelper(disconnectedBundle)) this.#connectionGeneration += 1;
|
|
491
355
|
this.#sockets.delete(socket);
|
|
492
356
|
this.#socketPeers.delete(socket);
|
|
493
357
|
this.#pendingHandshakes.delete(socket);
|
|
@@ -497,7 +361,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
497
361
|
clearTimeout(deadline);
|
|
498
362
|
this.#authDeadlineTimers.delete(socket);
|
|
499
363
|
}
|
|
500
|
-
if (disconnectedBundle) this.params.onDisconnect?.(disconnectedBundle);
|
|
364
|
+
if (disconnectedBundle && isCallHelper(disconnectedBundle)) this.params.onDisconnect?.(disconnectedBundle);
|
|
501
365
|
});
|
|
502
366
|
}
|
|
503
367
|
#handleLine(socket, line) {
|
|
@@ -537,12 +401,21 @@ var FaceTimeHelperSocketServer = class {
|
|
|
537
401
|
if (pending) {
|
|
538
402
|
this.#pending.delete(transactionId);
|
|
539
403
|
clearTimeout(pending.timeout);
|
|
540
|
-
|
|
541
|
-
|
|
404
|
+
const peer = this.#socketPeers.get(socket);
|
|
405
|
+
const result = Object.assign(payload, {
|
|
406
|
+
helperBundleIdentifier: peer?.bundleIdentifier ?? "unknown",
|
|
407
|
+
helperPeer: peer,
|
|
408
|
+
helperResults: void 0,
|
|
409
|
+
helpersContacted: void 0,
|
|
410
|
+
topologyGeneration: void 0,
|
|
411
|
+
topologyComplete: void 0
|
|
412
|
+
});
|
|
413
|
+
if (typeof payload.error === "string" && payload.error) pending.reject(payload.ambiguous === true ? new FaceTimeHelperAmbiguousError(payload.error, result) : new Error(payload.error));
|
|
414
|
+
else pending.resolve(result);
|
|
542
415
|
return;
|
|
543
416
|
}
|
|
544
417
|
const peer = this.#socketPeers.get(socket);
|
|
545
|
-
if (peer) this.params.onMessage(payload, peer);
|
|
418
|
+
if (peer && isCallHelper(peer.bundleIdentifier)) this.params.onMessage(payload, peer);
|
|
546
419
|
}
|
|
547
420
|
#handleClientHello(socket, record) {
|
|
548
421
|
if (this.#pendingHandshakes.has(socket) || this.#socketAuthSessions.has(socket) || !hasExactKeys(record, [
|
|
@@ -564,11 +437,11 @@ var FaceTimeHelperSocketServer = class {
|
|
|
564
437
|
const clientNonce = typeof record.client_nonce === "string" ? record.client_nonce : "";
|
|
565
438
|
const proof = typeof record.proof === "string" ? record.proof : "";
|
|
566
439
|
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 || !
|
|
440
|
+
if (!FACETIME_HELPER_BUNDLES.has(bundleIdentifier) || processId <= 0 || processStartedAtMs <= 0 || clientNonce.length < 32 || !safeEqualSecret(proof, expectedProof)) {
|
|
568
441
|
socket.destroy();
|
|
569
442
|
return;
|
|
570
443
|
}
|
|
571
|
-
if (buildId !== this.params.buildId) {
|
|
444
|
+
if (buildId !== this.params.buildId && isCallHelper(bundleIdentifier)) {
|
|
572
445
|
this.params.onStale?.(bundleIdentifier, processId);
|
|
573
446
|
socket.destroy();
|
|
574
447
|
return;
|
|
@@ -598,7 +471,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
598
471
|
"event",
|
|
599
472
|
"connection_epoch",
|
|
600
473
|
"proof"
|
|
601
|
-
]) || record.connection_epoch !== handshake.connectionEpoch || typeof record.proof !== "string" || !
|
|
474
|
+
]) || record.connection_epoch !== handshake.connectionEpoch || typeof record.proof !== "string" || !safeEqualSecret(record.proof, helperHmac(handshake.connectionKey, `client-finish\n${handshake.connectionEpoch}`))) {
|
|
602
475
|
socket.destroy();
|
|
603
476
|
return;
|
|
604
477
|
}
|
|
@@ -620,14 +493,14 @@ var FaceTimeHelperSocketServer = class {
|
|
|
620
493
|
bundleIdentifier: session.bundleIdentifier,
|
|
621
494
|
processId: session.processId,
|
|
622
495
|
processStartedAtMs: session.processStartedAtMs,
|
|
623
|
-
connectionGeneration: ++this.#connectionGeneration
|
|
496
|
+
connectionGeneration: isCallHelper(session.bundleIdentifier) ? ++this.#connectionGeneration : this.#connectionGeneration
|
|
624
497
|
});
|
|
625
498
|
const deadline = this.#authDeadlineTimers.get(socket);
|
|
626
499
|
if (deadline) {
|
|
627
500
|
clearTimeout(deadline);
|
|
628
501
|
this.#authDeadlineTimers.delete(socket);
|
|
629
502
|
}
|
|
630
|
-
this.params.onConnect?.(session.bundleIdentifier);
|
|
503
|
+
if (isCallHelper(session.bundleIdentifier)) this.params.onConnect?.(session.bundleIdentifier);
|
|
631
504
|
}
|
|
632
505
|
#consumeHelperEnvelope(socket, record) {
|
|
633
506
|
const session = this.#socketAuthSessions.get(socket);
|
|
@@ -639,7 +512,7 @@ var FaceTimeHelperSocketServer = class {
|
|
|
639
512
|
"auth"
|
|
640
513
|
]) || 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
514
|
const expectedAuth = helperHmac(session.connectionKey, `message\nhelper-to-server\n${session.connectionEpoch}\n${record.sequence}\n${record.payload_json}`);
|
|
642
|
-
if (!
|
|
515
|
+
if (!safeEqualSecret(record.auth, expectedAuth)) return;
|
|
643
516
|
let payload;
|
|
644
517
|
try {
|
|
645
518
|
payload = JSON.parse(record.payload_json);
|
|
@@ -663,37 +536,28 @@ var FaceTimeHelperSocketServer = class {
|
|
|
663
536
|
payload_json: payloadJson,
|
|
664
537
|
auth: helperHmac(session.connectionKey, `message\nserver-to-helper\n${session.connectionEpoch}\n${sequence}\n${payloadJson}`)
|
|
665
538
|
});
|
|
666
|
-
if (Buffer.byteLength(envelope) > MAX_FRAME_BYTES) throw new
|
|
539
|
+
if (Buffer.byteLength(envelope) > MAX_FRAME_BYTES) throw new Error("FaceTime helper message exceeds the frame limit");
|
|
667
540
|
session.outgoingSequence = sequence;
|
|
668
541
|
socket.write(`${envelope}\r\n`);
|
|
669
542
|
}
|
|
670
543
|
async #sendAction(action, data) {
|
|
671
|
-
const socket = [...this.#sockets].find((candidate) => !candidate.destroyed &&
|
|
544
|
+
const socket = [...this.#sockets].find((candidate) => !candidate.destroyed && DIAL_BUNDLES.has(this.#socketPeers.get(candidate)?.bundleIdentifier ?? ""));
|
|
672
545
|
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
|
-
};
|
|
546
|
+
return await this.#sendActionOnSocket(socket, action, data);
|
|
678
547
|
}
|
|
679
548
|
async #sendActionToAll(action, data, timeoutMs = 5e3, requiredPeerProcessIds = []) {
|
|
680
|
-
const sockets = [...this.#sockets].filter((candidate) => !candidate.destroyed &&
|
|
549
|
+
const sockets = [...this.#sockets].filter((candidate) => !candidate.destroyed && isCallHelper(this.#socketPeers.get(candidate)?.bundleIdentifier ?? ""));
|
|
681
550
|
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
551
|
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
|
-
}] : []);
|
|
552
|
+
const fulfilled = results.flatMap((result) => result.status === "fulfilled" ? [result.value] : []);
|
|
689
553
|
if (fulfilled.length > 0) {
|
|
690
554
|
const fulfilledProcessIds = new Set(fulfilled.flatMap(({ helperPeer }) => helperPeer ? [helperPeer.processId] : []));
|
|
691
555
|
return {
|
|
556
|
+
...fulfilled[fulfilled.length - 1],
|
|
692
557
|
helpersContacted: sockets.length,
|
|
693
558
|
topologyGeneration: this.#connectionGeneration,
|
|
694
559
|
topologyComplete: fulfilled.length === sockets.length && requiredPeerProcessIds.every((processId) => fulfilledProcessIds.has(processId)),
|
|
695
|
-
helperResults: fulfilled
|
|
696
|
-
...fulfilled[fulfilled.length - 1]
|
|
560
|
+
helperResults: fulfilled
|
|
697
561
|
};
|
|
698
562
|
}
|
|
699
563
|
const firstRejected = results.find((result) => result.status === "rejected");
|
|
@@ -702,7 +566,6 @@ var FaceTimeHelperSocketServer = class {
|
|
|
702
566
|
async #sendActionOnSocket(socket, action, data, timeoutMs = 5e3) {
|
|
703
567
|
if (this.#pending.size >= MAX_PENDING_ACTIONS) throw new FaceTimeHelperUnavailableError("FaceTime helper action queue is full");
|
|
704
568
|
const transactionId = randomUUID();
|
|
705
|
-
if (!this.#socketAuthSessions.has(socket)) throw new FaceTimeHelperUnavailableError("FaceTime helper socket is not authenticated");
|
|
706
569
|
return await new Promise((resolve, reject) => {
|
|
707
570
|
const timeout = setTimeout(() => {
|
|
708
571
|
this.#pending.delete(transactionId);
|
|
@@ -727,17 +590,8 @@ var FaceTimeHelperSocketServer = class {
|
|
|
727
590
|
});
|
|
728
591
|
}
|
|
729
592
|
};
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
const TARGET_BUNDLES = {
|
|
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"];
|
|
593
|
+
// extensions/facetime/src/helper-supervisor.ts
|
|
594
|
+
const FACETIME_HELPER_TARGETS = ["FaceTime"];
|
|
741
595
|
const RETRY_DELAYS_MS = [
|
|
742
596
|
1e3,
|
|
743
597
|
2e3,
|
|
@@ -747,7 +601,7 @@ const RETRY_DELAYS_MS = [
|
|
|
747
601
|
6e4
|
|
748
602
|
];
|
|
749
603
|
function targetForBundle(bundleIdentifier) {
|
|
750
|
-
return
|
|
604
|
+
return DIAL_BUNDLES.has(bundleIdentifier) ? "FaceTime" : void 0;
|
|
751
605
|
}
|
|
752
606
|
var FaceTimeHelperSupervisor = class {
|
|
753
607
|
#states;
|
|
@@ -757,7 +611,7 @@ var FaceTimeHelperSupervisor = class {
|
|
|
757
611
|
#abortController = new AbortController();
|
|
758
612
|
constructor(params) {
|
|
759
613
|
this.params = params;
|
|
760
|
-
this.#states = new Map(FACETIME_HELPER_TARGETS.filter((target) => existsSync(
|
|
614
|
+
this.#states = new Map(FACETIME_HELPER_TARGETS.filter((target) => existsSync(`/System/Applications/${target}.app`)).map((target) => [target, {
|
|
761
615
|
target,
|
|
762
616
|
connected: false,
|
|
763
617
|
attempts: 0,
|
|
@@ -821,9 +675,8 @@ var FaceTimeHelperSupervisor = class {
|
|
|
821
675
|
#refreshConnections() {
|
|
822
676
|
const bundles = new Set(this.params.connectedBundles());
|
|
823
677
|
for (const target of FACETIME_HELPER_TARGETS) {
|
|
824
|
-
const acceptedBundles = TARGET_BUNDLES[target];
|
|
825
678
|
const state = this.#states.get(target);
|
|
826
|
-
if (state) state.connected = [...
|
|
679
|
+
if (state) state.connected = [...DIAL_BUNDLES].some((bundle) => bundles.has(bundle));
|
|
827
680
|
}
|
|
828
681
|
}
|
|
829
682
|
#cancelTimer(target) {
|
|
@@ -879,8 +732,8 @@ var FaceTimeHelperSupervisor = class {
|
|
|
879
732
|
this.#injectionChain = pending.catch(() => void 0);
|
|
880
733
|
}
|
|
881
734
|
async #waitForAuthenticatedConnection(target) {
|
|
882
|
-
const deadline =
|
|
883
|
-
while (this.#started &&
|
|
735
|
+
const deadline = performance.now() + 1e4;
|
|
736
|
+
while (this.#started && performance.now() < deadline) {
|
|
884
737
|
this.#refreshConnections();
|
|
885
738
|
const state = this.#states.get(target);
|
|
886
739
|
if (!state || state.connected || state.stale) return;
|
|
@@ -931,8 +784,7 @@ var FaceTimeHelperSupervisor = class {
|
|
|
931
784
|
}
|
|
932
785
|
}
|
|
933
786
|
};
|
|
934
|
-
|
|
935
|
-
//#region extensions/facetime/src/outbound-call.ts
|
|
787
|
+
// extensions/facetime/src/outbound-call.ts
|
|
936
788
|
function normalizeFaceTimeOutboundIdentityEvent(value) {
|
|
937
789
|
if (!value || typeof value !== "object" || Array.isArray(value)) return;
|
|
938
790
|
const record = asRecord(value);
|
|
@@ -1014,8 +866,7 @@ function retainFaceTimeDialCallUUID(pending, callUUID) {
|
|
|
1014
866
|
function doesPendingFaceTimeDialHaveCallUUID(pending, callUUID) {
|
|
1015
867
|
return pending.callUUID === callUUID || pending.callUUIDAliases?.has(callUUID) === true;
|
|
1016
868
|
}
|
|
1017
|
-
|
|
1018
|
-
//#region extensions/facetime/src/pending-dial-store.ts
|
|
869
|
+
// extensions/facetime/src/pending-dial-store.ts
|
|
1019
870
|
const PENDING_DIAL_KEY = "active";
|
|
1020
871
|
function decodePendingDial(value) {
|
|
1021
872
|
if (!value || value.version !== 1 || !Number.isSafeInteger(value.ownerEpoch) || value.ownerEpoch < 1 || typeof value.dialID !== "string" || typeof value.handle !== "string" || value.mode !== "audio" && value.mode !== "video" || value.delivery !== "in-flight" && value.delivery !== "accepted" && value.delivery !== "ambiguous" && value.delivery !== "cancelling" || typeof value.requestedAt !== "string") return;
|
|
@@ -1074,8 +925,7 @@ var PendingFaceTimeDialStore = class {
|
|
|
1074
925
|
return this.#tail;
|
|
1075
926
|
}
|
|
1076
927
|
};
|
|
1077
|
-
|
|
1078
|
-
//#region extensions/facetime/src/audio-pump.ts
|
|
928
|
+
// extensions/facetime/src/audio-pump.ts
|
|
1079
929
|
const CAFFEINATE_COMMAND = "/usr/bin/caffeinate";
|
|
1080
930
|
const CAPTURE_CLOSE_SAFE_FRAME = Buffer.from([
|
|
1081
931
|
4,
|
|
@@ -1272,7 +1122,6 @@ function createAudioReadiness() {
|
|
|
1272
1122
|
function startFaceTimeAudioPump(params) {
|
|
1273
1123
|
const childEnv = sanitizedAudioChildEnv();
|
|
1274
1124
|
const playbackClock = new PlaybackClock();
|
|
1275
|
-
let playbackGeneration = 1;
|
|
1276
1125
|
let drainTimer;
|
|
1277
1126
|
let outputProcess;
|
|
1278
1127
|
const captureProcess = spawnAudioProcess({
|
|
@@ -1300,10 +1149,8 @@ function startFaceTimeAudioPump(params) {
|
|
|
1300
1149
|
});
|
|
1301
1150
|
};
|
|
1302
1151
|
const cancelDrainTimer = () => {
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
drainTimer = void 0;
|
|
1306
|
-
}
|
|
1152
|
+
clearTimeout(drainTimer);
|
|
1153
|
+
drainTimer = void 0;
|
|
1307
1154
|
};
|
|
1308
1155
|
const spawnOutput = () => {
|
|
1309
1156
|
const proc = spawnAudioProcess({ kind: "playback" }, childEnv);
|
|
@@ -1328,7 +1175,6 @@ function startFaceTimeAudioPump(params) {
|
|
|
1328
1175
|
if (stopped || mediaSuspended) return;
|
|
1329
1176
|
const previous = outputProcess;
|
|
1330
1177
|
outputProcess = spawnOutput();
|
|
1331
|
-
playbackGeneration += 1;
|
|
1332
1178
|
cancelDrainTimer();
|
|
1333
1179
|
playbackClock.reset();
|
|
1334
1180
|
terminateProcess(previous, "SIGKILL");
|
|
@@ -1419,9 +1265,8 @@ function startFaceTimeAudioPump(params) {
|
|
|
1419
1265
|
return;
|
|
1420
1266
|
}
|
|
1421
1267
|
cancelDrainTimer();
|
|
1422
|
-
const generation = playbackGeneration;
|
|
1423
1268
|
const notifyWhenDrained = () => {
|
|
1424
|
-
if (stopped || mediaSuspended
|
|
1269
|
+
if (stopped || mediaSuspended) return;
|
|
1425
1270
|
const delayMs = Math.ceil(playbackClock.millisecondsUntilDrained());
|
|
1426
1271
|
if (delayMs > 0) {
|
|
1427
1272
|
drainTimer = setTimeout(notifyWhenDrained, Math.max(1, delayMs));
|
|
@@ -1430,10 +1275,7 @@ function startFaceTimeAudioPump(params) {
|
|
|
1430
1275
|
}
|
|
1431
1276
|
drainTimer = void 0;
|
|
1432
1277
|
playbackClock.retireItems();
|
|
1433
|
-
params.onPlaybackDrained?.(
|
|
1434
|
-
generation,
|
|
1435
|
-
playedFrames: Math.floor(playbackClock.playedFrames())
|
|
1436
|
-
});
|
|
1278
|
+
params.onPlaybackDrained?.();
|
|
1437
1279
|
};
|
|
1438
1280
|
notifyWhenDrained();
|
|
1439
1281
|
},
|
|
@@ -1452,8 +1294,7 @@ function startFaceTimeAudioPump(params) {
|
|
|
1452
1294
|
stop
|
|
1453
1295
|
};
|
|
1454
1296
|
}
|
|
1455
|
-
|
|
1456
|
-
//#region extensions/facetime/src/talk-driver-config.ts
|
|
1297
|
+
// extensions/facetime/src/talk-driver-config.ts
|
|
1457
1298
|
const CONSULT_SYSTEM_PROMPT = [
|
|
1458
1299
|
"You are the configured OpenClaw agent receiving a delegated request from an authenticated owner in a private 1:1 FaceTime call.",
|
|
1459
1300
|
"The authenticated caller is the configured owner/user described by this agent's workspace context, including USER.md. When asked who is speaking, identify them from that workspace context without asking them to reconfirm.",
|
|
@@ -1544,8 +1385,7 @@ async function resolveFaceTimeRealtimeProvider(params) {
|
|
|
1544
1385
|
noRegisteredProviderMessage: "No realtime voice provider registered"
|
|
1545
1386
|
});
|
|
1546
1387
|
}
|
|
1547
|
-
|
|
1548
|
-
//#region extensions/facetime/src/preflight.ts
|
|
1388
|
+
// extensions/facetime/src/preflight.ts
|
|
1549
1389
|
function parseDefaultAudioDevices(raw) {
|
|
1550
1390
|
const parsed = JSON.parse(raw);
|
|
1551
1391
|
const record = asRecord(parsed);
|
|
@@ -1565,9 +1405,6 @@ function parseDefaultAudioDevices(raw) {
|
|
|
1565
1405
|
}
|
|
1566
1406
|
};
|
|
1567
1407
|
}
|
|
1568
|
-
function firstLine(value) {
|
|
1569
|
-
return typeof value === "string" ? value.trim().split(/\r?\n/u)[0] || void 0 : void 0;
|
|
1570
|
-
}
|
|
1571
1408
|
function pushCheck(checks, check) {
|
|
1572
1409
|
checks.push({
|
|
1573
1410
|
required: true,
|
|
@@ -1597,27 +1434,6 @@ function findPhysicalOutputProblem(defaults, devices) {
|
|
|
1597
1434
|
if (defaults.output.isAggregate) return `system output is aggregate device ${defaults.output.name}`;
|
|
1598
1435
|
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
1436
|
}
|
|
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
1437
|
async function runFaceTimePreflight(params) {
|
|
1622
1438
|
const runCommandWithTimeout = params.runtime.system.runCommandWithTimeout;
|
|
1623
1439
|
const checks = [];
|
|
@@ -1638,9 +1454,16 @@ async function runFaceTimePreflight(params) {
|
|
|
1638
1454
|
ok: executable.code === 0,
|
|
1639
1455
|
message: executable.code === 0 ? params.captureBinary : "capture helper is missing; reinstall with brew install openclaw/tap/openclaw-facetime"
|
|
1640
1456
|
});
|
|
1641
|
-
await
|
|
1642
|
-
|
|
1643
|
-
|
|
1457
|
+
const result = await runCommandWithTimeout([
|
|
1458
|
+
"/usr/bin/pgrep",
|
|
1459
|
+
"-x",
|
|
1460
|
+
"FaceTime"
|
|
1461
|
+
], { timeoutMs: 5e3 });
|
|
1462
|
+
pushCheck(checks, {
|
|
1463
|
+
id: "call-app-running",
|
|
1464
|
+
label: "FaceTime process",
|
|
1465
|
+
ok: result.code === 0,
|
|
1466
|
+
message: result.code === 0 ? "FaceTime" : "open FaceTime for audio or video calls"
|
|
1644
1467
|
});
|
|
1645
1468
|
const profiler = await runCommandWithTimeout([
|
|
1646
1469
|
"/usr/sbin/system_profiler",
|
|
@@ -1737,13 +1560,12 @@ async function runFaceTimePreflight(params) {
|
|
|
1737
1560
|
checks
|
|
1738
1561
|
};
|
|
1739
1562
|
}
|
|
1740
|
-
|
|
1741
|
-
//#region extensions/facetime/src/runtime-carrier-process.ts
|
|
1563
|
+
// extensions/facetime/src/runtime-carrier-process.ts
|
|
1742
1564
|
async function terminateExactCarrierProcesses(params) {
|
|
1743
1565
|
params.assertCurrent();
|
|
1744
1566
|
if (params.peers.size === 0) throw new Error("no authenticated carrier process identity is available for safe shutdown");
|
|
1745
1567
|
for (const peer of params.peers.values()) {
|
|
1746
|
-
const expected = peer.bundleIdentifier === "com.apple.FaceTime" ? "FaceTime" : peer.bundleIdentifier === "com.apple.FaceTime.FTConversationService" ? "FTConversationService" :
|
|
1568
|
+
const expected = peer.bundleIdentifier === "com.apple.FaceTime" ? "FaceTime" : peer.bundleIdentifier === "com.apple.FaceTime.FTConversationService" ? "FTConversationService" : "";
|
|
1747
1569
|
const inspectExactProcess = async () => {
|
|
1748
1570
|
const inspected = await params.runtime.system.runCommandWithTimeout([
|
|
1749
1571
|
"/bin/ps",
|
|
@@ -1785,21 +1607,9 @@ async function terminateExactCarrierProcesses(params) {
|
|
|
1785
1607
|
if (alive) throw new Error("authenticated carrier process remains alive after force termination");
|
|
1786
1608
|
}
|
|
1787
1609
|
}
|
|
1788
|
-
|
|
1789
|
-
//#region extensions/facetime/src/runtime-helper-results.ts
|
|
1790
|
-
const OUTBOUND_DIAL_HELPER_BUNDLES = /* @__PURE__ */ new Set(["com.apple.FaceTime", "com.apple.FaceTime.FTConversationService"]);
|
|
1610
|
+
// extensions/facetime/src/runtime-helper-results.ts
|
|
1791
1611
|
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;
|
|
1612
|
+
return readHelperResults(result).flatMap((entry) => entry.helperPeer ? [entry.helperPeer] : []);
|
|
1803
1613
|
}
|
|
1804
1614
|
function retainHelperResultPeers(call, result) {
|
|
1805
1615
|
for (const peer of readHelperPeers(result)) call.carrierPeers.set(peer.processId, peer);
|
|
@@ -1807,7 +1617,7 @@ function retainHelperResultPeers(call, result) {
|
|
|
1807
1617
|
function retainOutboundDialHelperPeers(peers, result) {
|
|
1808
1618
|
for (const entry of readHelperResults(result)) {
|
|
1809
1619
|
if (entry.found === false && entry.retained_outbound_dial !== true && entry.cancelled !== true) continue;
|
|
1810
|
-
for (const peer of readHelperPeers(entry)) if (
|
|
1620
|
+
for (const peer of readHelperPeers(entry)) if (DIAL_BUNDLES.has(peer.bundleIdentifier)) peers.set(peer.processId, peer);
|
|
1811
1621
|
}
|
|
1812
1622
|
}
|
|
1813
1623
|
function readOutboundCallUUID(result) {
|
|
@@ -1817,7 +1627,7 @@ function readOutboundProxyIdentifier(result) {
|
|
|
1817
1627
|
return readHelperResults(result).map((entry) => normalizeOptionalString(entry.proxy_identifier)).find((value) => Boolean(value));
|
|
1818
1628
|
}
|
|
1819
1629
|
function hasDialHelperConfirmation(results) {
|
|
1820
|
-
return results.some((entry) =>
|
|
1630
|
+
return results.some((entry) => DIAL_BUNDLES.has(entry.helperBundleIdentifier ?? ""));
|
|
1821
1631
|
}
|
|
1822
1632
|
function hasDefinitiveDialHelperAbsence(result, requiredPeerProcessIds) {
|
|
1823
1633
|
const results = readHelperResults(result);
|
|
@@ -1849,7 +1659,7 @@ async function reconcilePendingFaceTimeCarrier(params) {
|
|
|
1849
1659
|
await params.persist();
|
|
1850
1660
|
}
|
|
1851
1661
|
if (reconciledCallUUID || reconciledProxyIdentifier || readHelperResults(result).some((entry) => entry.found === true)) return;
|
|
1852
|
-
const topologyGeneration =
|
|
1662
|
+
const topologyGeneration = result.topologyGeneration;
|
|
1853
1663
|
const completeAbsence = hasDefinitiveDialHelperAbsence(result, params.peers.keys());
|
|
1854
1664
|
if (completeAbsence && topologyGeneration !== void 0 && topologyGeneration === previousAbsentTopology && previousAbsenceCurrent?.()) {
|
|
1855
1665
|
await params.clear();
|
|
@@ -1860,8 +1670,7 @@ async function reconcilePendingFaceTimeCarrier(params) {
|
|
|
1860
1670
|
if (attempt + 1 < 12) await sleep(250);
|
|
1861
1671
|
}
|
|
1862
1672
|
}
|
|
1863
|
-
|
|
1864
|
-
//#region extensions/facetime/src/talk-consult-controller.ts
|
|
1673
|
+
// extensions/facetime/src/talk-consult-controller.ts
|
|
1865
1674
|
function createFaceTimeConsultController(params) {
|
|
1866
1675
|
const pending = /* @__PURE__ */ new Map();
|
|
1867
1676
|
let hangupRequested = false;
|
|
@@ -1887,7 +1696,6 @@ function createFaceTimeConsultController(params) {
|
|
|
1887
1696
|
};
|
|
1888
1697
|
const abortConsult = (consult, reason) => {
|
|
1889
1698
|
consult.abortController.abort(/* @__PURE__ */ new Error(`FaceTime agent consult ${reason}`));
|
|
1890
|
-
consult.runRegistration?.controller.abort(/* @__PURE__ */ new Error(`FaceTime agent consult run ${reason}`));
|
|
1891
1699
|
};
|
|
1892
1700
|
const abortForClose = () => {
|
|
1893
1701
|
for (const consult of pending.values()) {
|
|
@@ -2099,7 +1907,7 @@ function createFaceTimeConsultController(params) {
|
|
|
2099
1907
|
sessionKey: params.consultSessionKey,
|
|
2100
1908
|
spawnedBy: params.requesterSessionKey,
|
|
2101
1909
|
senderId: params.senderId,
|
|
2102
|
-
senderIsOwner:
|
|
1910
|
+
senderIsOwner: true,
|
|
2103
1911
|
contextMode: "fork",
|
|
2104
1912
|
messageProvider: AGENT_CONSULT_MESSAGE_PROVIDER,
|
|
2105
1913
|
lane: `facetime:${params.normalizedCallUUID}`,
|
|
@@ -2113,21 +1921,7 @@ function createFaceTimeConsultController(params) {
|
|
|
2113
1921
|
toolsAllow: resolveRealtimeVoiceAgentConsultToolsAllow(params.config.realtime.toolPolicy),
|
|
2114
1922
|
extraSystemPrompt: CONSULT_SYSTEM_PROMPT,
|
|
2115
1923
|
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
|
-
}
|
|
1924
|
+
abortSignal: consult.abortController.signal
|
|
2131
1925
|
}).then((result) => deliverResult(result), async (error) => {
|
|
2132
1926
|
if (!ownsConsult(consult) || consult.cancelRequested) return;
|
|
2133
1927
|
const message = formatErrorMessage(error);
|
|
@@ -2140,38 +1934,9 @@ function createFaceTimeConsultController(params) {
|
|
|
2140
1934
|
handleToolCall
|
|
2141
1935
|
};
|
|
2142
1936
|
}
|
|
2143
|
-
|
|
2144
|
-
//#region extensions/facetime/src/talk-initial-greeting.ts
|
|
1937
|
+
// extensions/facetime/src/talk-driver.ts
|
|
2145
1938
|
const FACETIME_INITIAL_GREETING = "Greet the caller briefly, introduce yourself using your configured identity, and ask how you can help.";
|
|
2146
1939
|
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
1940
|
async function startFaceTimeTalkDriver(params) {
|
|
2176
1941
|
if (params.signal?.aborted) throw new Error("FaceTime talk startup aborted");
|
|
2177
1942
|
const consultAgentId = agentIdFromSessionKey(params.config.realtime.sessionKey, params.fullConfig);
|
|
@@ -2201,7 +1966,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2201
1966
|
let response;
|
|
2202
1967
|
const settledResponseIds = /* @__PURE__ */ new Set();
|
|
2203
1968
|
let suppressNextUnkeyedLegacyTerminal = false;
|
|
2204
|
-
const consultRef = {};
|
|
2205
1969
|
let failurePromise;
|
|
2206
1970
|
let activated = false;
|
|
2207
1971
|
let providerReady = false;
|
|
@@ -2224,9 +1988,25 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2224
1988
|
startupFailure = error;
|
|
2225
1989
|
startupFailureDeferred.reject(error);
|
|
2226
1990
|
};
|
|
2227
|
-
|
|
2228
|
-
|
|
2229
|
-
|
|
1991
|
+
let timer;
|
|
1992
|
+
let dismissed = false;
|
|
1993
|
+
const initialGreeting = {
|
|
1994
|
+
instructions: FACETIME_INITIAL_GREETING,
|
|
1995
|
+
schedule() {
|
|
1996
|
+
if (dismissed || timer) return;
|
|
1997
|
+
timer = setTimeout(() => {
|
|
1998
|
+
timer = void 0;
|
|
1999
|
+
dismissed = true;
|
|
2000
|
+
if (!stopped && !mediaSuspended && activated && providerReady) bridge?.triggerGreeting(FACETIME_INITIAL_GREETING);
|
|
2001
|
+
}, FACETIME_GREETING_MEDIA_SETTLE_MS);
|
|
2002
|
+
timer.unref?.();
|
|
2003
|
+
},
|
|
2004
|
+
cancel() {
|
|
2005
|
+
dismissed = true;
|
|
2006
|
+
clearTimeout(timer);
|
|
2007
|
+
timer = void 0;
|
|
2008
|
+
}
|
|
2009
|
+
};
|
|
2230
2010
|
const reportFailure = (error) => {
|
|
2231
2011
|
if (failurePromise) return failurePromise;
|
|
2232
2012
|
failurePromise = Promise.resolve(params.onFailure?.(error)).then((safeToClose) => safeToClose !== false);
|
|
@@ -2241,7 +2021,7 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2241
2021
|
mediaSuspensionError ??= /* @__PURE__ */ new Error(`FaceTime model media suspended: ${reason}`);
|
|
2242
2022
|
mediaSuspendedDeferred.reject(mediaSuspensionError);
|
|
2243
2023
|
interruptProviderConnect?.();
|
|
2244
|
-
|
|
2024
|
+
consultController.abortForClose();
|
|
2245
2025
|
suspendMediaPromise = (async () => {
|
|
2246
2026
|
try {
|
|
2247
2027
|
await bridge?.close();
|
|
@@ -2350,7 +2130,7 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2350
2130
|
};
|
|
2351
2131
|
const resetProviderContinuity = () => {
|
|
2352
2132
|
modelMediaGeneration += 1;
|
|
2353
|
-
|
|
2133
|
+
consultController.abortForClose();
|
|
2354
2134
|
pump?.clearOutputAudio();
|
|
2355
2135
|
resetResponsePlayback();
|
|
2356
2136
|
finishOutputAudio("continuity-reset");
|
|
@@ -2366,7 +2146,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2366
2146
|
requesterSessionKey,
|
|
2367
2147
|
normalizedCallUUID,
|
|
2368
2148
|
senderId: params.senderId,
|
|
2369
|
-
senderIsOwner: params.senderIsOwner,
|
|
2370
2149
|
transcript,
|
|
2371
2150
|
getBridge: () => bridge,
|
|
2372
2151
|
getGeneration: () => modelMediaGeneration,
|
|
@@ -2378,7 +2157,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2378
2157
|
close,
|
|
2379
2158
|
onHangupRequested: params.onHangupRequested
|
|
2380
2159
|
});
|
|
2381
|
-
consultRef.current = consultController;
|
|
2382
2160
|
remember({
|
|
2383
2161
|
type: "session.started",
|
|
2384
2162
|
payload: { callUUID: params.callUUID }
|
|
@@ -2606,7 +2384,6 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2606
2384
|
throw error;
|
|
2607
2385
|
}
|
|
2608
2386
|
return {
|
|
2609
|
-
callUUID: params.callUUID,
|
|
2610
2387
|
get recentTalkEvents() {
|
|
2611
2388
|
return talk.recentEvents;
|
|
2612
2389
|
},
|
|
@@ -2630,8 +2407,7 @@ async function startFaceTimeTalkDriver(params) {
|
|
|
2630
2407
|
close
|
|
2631
2408
|
};
|
|
2632
2409
|
}
|
|
2633
|
-
|
|
2634
|
-
//#region extensions/facetime/src/runtime-call-control.ts
|
|
2410
|
+
// extensions/facetime/src/runtime-call-control.ts
|
|
2635
2411
|
function createFaceTimeCallControl(params) {
|
|
2636
2412
|
const runCarrierActionAcrossAliases = async (request) => {
|
|
2637
2413
|
const candidates = [request.call.carrierCallUUID, ...[...request.call.carrierCallUUIDs].toReversed()].filter((candidate, index, all) => all.indexOf(candidate) === index);
|
|
@@ -2642,7 +2418,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2642
2418
|
allowClosing: true,
|
|
2643
2419
|
action: async () => await request.run(candidate)
|
|
2644
2420
|
});
|
|
2645
|
-
|
|
2421
|
+
assertFaceTimeNativeAction(request.action, result);
|
|
2646
2422
|
request.call.promoteCarrierCallUUID(candidate);
|
|
2647
2423
|
return result;
|
|
2648
2424
|
} catch (error) {
|
|
@@ -2670,8 +2446,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2670
2446
|
captureBinary: params.captureBinary,
|
|
2671
2447
|
feedDevice: "OpenClaw-Feed",
|
|
2672
2448
|
microphoneDevice: "OpenClaw-Mic",
|
|
2673
|
-
processInputVerified: false
|
|
2674
|
-
processOutputSuppressed: false
|
|
2449
|
+
processInputVerified: false
|
|
2675
2450
|
};
|
|
2676
2451
|
call.lastRoutingError = void 0;
|
|
2677
2452
|
})();
|
|
@@ -2689,26 +2464,23 @@ function createFaceTimeCallControl(params) {
|
|
|
2689
2464
|
if (call.lifecycleAbort.signal.aborted) throw new Error("FaceTime call closed during audio routing");
|
|
2690
2465
|
};
|
|
2691
2466
|
const enableCallAudio = async (call) => {
|
|
2692
|
-
const generation = call.
|
|
2467
|
+
const generation = call.generation;
|
|
2693
2468
|
const mutedResult = await call.runCarrierCommand({
|
|
2694
2469
|
generation,
|
|
2695
2470
|
action: async () => await params.helper.setMuted(call.carrierCallUUID, false)
|
|
2696
2471
|
});
|
|
2697
2472
|
call.lastHelperAction = mutedResult;
|
|
2698
2473
|
retainHelperResultPeers(call, mutedResult);
|
|
2699
|
-
|
|
2474
|
+
assertFaceTimeNativeAction("unmute", mutedResult);
|
|
2700
2475
|
const transmissionResult = await call.runCarrierCommand({
|
|
2701
2476
|
generation,
|
|
2702
2477
|
action: async () => await params.helper.startTransmission(call.carrierCallUUID)
|
|
2703
2478
|
});
|
|
2704
2479
|
call.lastHelperAction = transmissionResult;
|
|
2705
2480
|
retainHelperResultPeers(call, transmissionResult);
|
|
2706
|
-
|
|
2481
|
+
assertFaceTimeNativeAction("activate", transmissionResult);
|
|
2707
2482
|
call.markCarrierActive(generation);
|
|
2708
|
-
if (call.audioTransport)
|
|
2709
|
-
call.audioTransport.processInputVerified = true;
|
|
2710
|
-
call.audioTransport.processOutputSuppressed = call.talk?.processOutputSuppressed() === true;
|
|
2711
|
-
}
|
|
2483
|
+
if (call.audioTransport) call.audioTransport.processInputVerified = true;
|
|
2712
2484
|
};
|
|
2713
2485
|
const closeCall = async (call, reason) => {
|
|
2714
2486
|
if (params.calls.active !== call) return;
|
|
@@ -2747,7 +2519,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2747
2519
|
const readCompleteAbsenceGeneration = (error) => {
|
|
2748
2520
|
if (!(error instanceof FaceTimeHelperAmbiguousError)) return;
|
|
2749
2521
|
try {
|
|
2750
|
-
return projectCompleteFaceTimeAbsence(error.result)
|
|
2522
|
+
return projectCompleteFaceTimeAbsence(error.result);
|
|
2751
2523
|
} catch {
|
|
2752
2524
|
return;
|
|
2753
2525
|
}
|
|
@@ -2778,8 +2550,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2778
2550
|
});
|
|
2779
2551
|
const first = projectCompleteFaceTimeAbsence(await inspect());
|
|
2780
2552
|
await sleepWithAbort(100, void 0, { ref: false });
|
|
2781
|
-
|
|
2782
|
-
return first.topologyGeneration === second.topologyGeneration && params.getHelperTopologyVersion() === topologyVersion;
|
|
2553
|
+
return first === projectCompleteFaceTimeAbsence(await inspect()) && params.getHelperTopologyVersion() === topologyVersion;
|
|
2783
2554
|
} catch {
|
|
2784
2555
|
return false;
|
|
2785
2556
|
}
|
|
@@ -2822,7 +2593,7 @@ function createFaceTimeCallControl(params) {
|
|
|
2822
2593
|
})()]);
|
|
2823
2594
|
};
|
|
2824
2595
|
const terminateCarrierProcesses = async (call) => {
|
|
2825
|
-
const generation = call.
|
|
2596
|
+
const generation = call.generation;
|
|
2826
2597
|
await terminateExactCarrierProcesses({
|
|
2827
2598
|
runtime: params.runtime,
|
|
2828
2599
|
peers: call.carrierPeers,
|
|
@@ -2853,7 +2624,6 @@ function createFaceTimeCallControl(params) {
|
|
|
2853
2624
|
logger: params.logger,
|
|
2854
2625
|
callUUID,
|
|
2855
2626
|
senderId: call.senderId,
|
|
2856
|
-
senderIsOwner: call.senderIsOwner,
|
|
2857
2627
|
captureBinary: params.captureBinary,
|
|
2858
2628
|
signal: call.lifecycleAbort.signal,
|
|
2859
2629
|
async onHangupRequested() {
|
|
@@ -2873,7 +2643,6 @@ function createFaceTimeCallControl(params) {
|
|
|
2873
2643
|
return;
|
|
2874
2644
|
}
|
|
2875
2645
|
call.talk = talk;
|
|
2876
|
-
if (call.audioTransport) call.audioTransport.processOutputSuppressed = true;
|
|
2877
2646
|
params.logger.info("[facetime] realtime talk suppression ready");
|
|
2878
2647
|
})();
|
|
2879
2648
|
}
|
|
@@ -2885,13 +2654,11 @@ function createFaceTimeCallControl(params) {
|
|
|
2885
2654
|
}
|
|
2886
2655
|
};
|
|
2887
2656
|
const activateCallTalk = async (call) => {
|
|
2888
|
-
const generation = call.
|
|
2657
|
+
const generation = call.generation;
|
|
2889
2658
|
if (!call.talkActivation) call.talkActivation = (async () => {
|
|
2890
2659
|
await call.talk?.readyForAudio();
|
|
2891
|
-
call.assertCurrent(generation);
|
|
2892
2660
|
call.markModelReady(generation);
|
|
2893
2661
|
await enableCallAudio(call);
|
|
2894
|
-
call.assertCurrent(generation);
|
|
2895
2662
|
call.markModelActive(generation);
|
|
2896
2663
|
call.talk?.activate();
|
|
2897
2664
|
})();
|
|
@@ -2912,15 +2679,27 @@ function createFaceTimeCallControl(params) {
|
|
|
2912
2679
|
stopCall
|
|
2913
2680
|
};
|
|
2914
2681
|
}
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2682
|
+
// extensions/facetime/src/runtime-state.ts
|
|
2683
|
+
function normalizeCallIdentity(value) {
|
|
2684
|
+
return value.trim().toLowerCase();
|
|
2685
|
+
}
|
|
2686
|
+
var ActiveFaceTimeCall = class {
|
|
2687
|
+
#carrierClosure;
|
|
2688
|
+
#commandTail;
|
|
2918
2689
|
constructor(params) {
|
|
2919
|
-
|
|
2690
|
+
this.lifecycleAbort = new AbortController();
|
|
2691
|
+
this.aliases = /* @__PURE__ */ new Set();
|
|
2692
|
+
this.generation = 1;
|
|
2693
|
+
this.modelMediaMode = "starting";
|
|
2694
|
+
this.#carrierClosure = createDeferred();
|
|
2695
|
+
this.carrierClosure = this.#carrierClosure.promise;
|
|
2696
|
+
this.#commandTail = Promise.resolve();
|
|
2920
2697
|
this.retiredCarrierCallUUIDs = /* @__PURE__ */ new Set();
|
|
2921
2698
|
this.carrierPeers = /* @__PURE__ */ new Map();
|
|
2922
|
-
this.senderIsOwner = true;
|
|
2923
2699
|
this.audioReady = false;
|
|
2700
|
+
this.phase = params.phase;
|
|
2701
|
+
this.carrierMode = params.phase === "ringing" ? "ringing" : "muted";
|
|
2702
|
+
this.aliases.add(normalizeCallIdentity(params.callUUID));
|
|
2924
2703
|
this.callUUID = params.callUUID;
|
|
2925
2704
|
this.carrierCallUUID = params.callUUID;
|
|
2926
2705
|
this.carrierCallUUIDs = /* @__PURE__ */ new Set([params.callUUID]);
|
|
@@ -2928,6 +2707,67 @@ var ActiveFaceTimeCall = class extends FaceTimeCallInstance {
|
|
|
2928
2707
|
this.handle = params.handle;
|
|
2929
2708
|
if (params.peer) this.carrierPeers.set(params.peer.processId, params.peer);
|
|
2930
2709
|
}
|
|
2710
|
+
assertCurrent(generation, allowClosing = false) {
|
|
2711
|
+
const phaseAllowed = allowClosing ? this.phase !== "closed" && this.carrierMode !== "closed" : this.phase !== "closing" && this.phase !== "closed";
|
|
2712
|
+
if (generation !== this.generation || !phaseAllowed || !allowClosing && this.lifecycleAbort.signal.aborted) throw new Error("FaceTime call lifecycle changed during carrier command");
|
|
2713
|
+
}
|
|
2714
|
+
async runCarrierCommand(params) {
|
|
2715
|
+
const previous = this.#commandTail;
|
|
2716
|
+
const { promise, resolve: release } = createDeferred();
|
|
2717
|
+
this.#commandTail = promise;
|
|
2718
|
+
await previous;
|
|
2719
|
+
try {
|
|
2720
|
+
this.assertCurrent(params.generation, params.allowClosing);
|
|
2721
|
+
const result = await params.action();
|
|
2722
|
+
this.assertCurrent(params.generation, params.allowClosing);
|
|
2723
|
+
return result;
|
|
2724
|
+
} finally {
|
|
2725
|
+
release();
|
|
2726
|
+
}
|
|
2727
|
+
}
|
|
2728
|
+
beginAnswering() {
|
|
2729
|
+
if (this.phase !== "ringing") throw new Error(`cannot answer FaceTime call in ${this.phase} phase`);
|
|
2730
|
+
this.phase = "answering";
|
|
2731
|
+
this.carrierMode = "muted";
|
|
2732
|
+
return this.generation;
|
|
2733
|
+
}
|
|
2734
|
+
markCarrierActive(generation) {
|
|
2735
|
+
this.assertCurrent(generation);
|
|
2736
|
+
this.phase = "active";
|
|
2737
|
+
this.carrierMode = "active";
|
|
2738
|
+
}
|
|
2739
|
+
markModelReady(generation) {
|
|
2740
|
+
this.assertCurrent(generation);
|
|
2741
|
+
this.modelMediaMode = "ready";
|
|
2742
|
+
}
|
|
2743
|
+
markModelActive(generation) {
|
|
2744
|
+
this.assertCurrent(generation);
|
|
2745
|
+
this.modelMediaMode = "active";
|
|
2746
|
+
}
|
|
2747
|
+
suspendModelMedia() {
|
|
2748
|
+
if (this.modelMediaMode !== "closed") this.modelMediaMode = "suspended";
|
|
2749
|
+
}
|
|
2750
|
+
beginClosing() {
|
|
2751
|
+
if (this.phase === "closed") return this.generation;
|
|
2752
|
+
if (this.phase !== "closing") {
|
|
2753
|
+
this.generation += 1;
|
|
2754
|
+
this.phase = "closing";
|
|
2755
|
+
this.carrierMode = "closing";
|
|
2756
|
+
this.suspendModelMedia();
|
|
2757
|
+
this.lifecycleAbort.abort(/* @__PURE__ */ new Error("FaceTime call is closing"));
|
|
2758
|
+
}
|
|
2759
|
+
return this.generation;
|
|
2760
|
+
}
|
|
2761
|
+
markCarrierClosed() {
|
|
2762
|
+
this.beginClosing();
|
|
2763
|
+
this.carrierMode = "closed";
|
|
2764
|
+
this.#carrierClosure.resolve(void 0);
|
|
2765
|
+
}
|
|
2766
|
+
markClosed() {
|
|
2767
|
+
this.phase = "closed";
|
|
2768
|
+
this.carrierMode = "closed";
|
|
2769
|
+
this.modelMediaMode = "closed";
|
|
2770
|
+
}
|
|
2931
2771
|
promoteCarrierCallUUID(callUUID) {
|
|
2932
2772
|
if (callUUID !== this.carrierCallUUID) {
|
|
2933
2773
|
this.retiredCarrierCallUUIDs.add(this.carrierCallUUID);
|
|
@@ -2937,6 +2777,37 @@ var ActiveFaceTimeCall = class extends FaceTimeCallInstance {
|
|
|
2937
2777
|
this.carrierCallUUID = callUUID;
|
|
2938
2778
|
}
|
|
2939
2779
|
};
|
|
2780
|
+
var FaceTimeCallRegistry = class {
|
|
2781
|
+
#active;
|
|
2782
|
+
get active() {
|
|
2783
|
+
return this.#active;
|
|
2784
|
+
}
|
|
2785
|
+
get size() {
|
|
2786
|
+
return this.#active && this.#active.phase !== "closed" ? 1 : 0;
|
|
2787
|
+
}
|
|
2788
|
+
values() {
|
|
2789
|
+
return (this.#active && this.#active.phase !== "closed" ? [this.#active] : [])[Symbol.iterator]();
|
|
2790
|
+
}
|
|
2791
|
+
get(identity) {
|
|
2792
|
+
return this.#active?.aliases.has(normalizeCallIdentity(identity)) ? this.#active : void 0;
|
|
2793
|
+
}
|
|
2794
|
+
has(identity) {
|
|
2795
|
+
return this.get(identity) !== void 0;
|
|
2796
|
+
}
|
|
2797
|
+
create(call) {
|
|
2798
|
+
if (this.#active && this.#active.phase !== "closed") throw new Error("another FaceTime call lifecycle is already active");
|
|
2799
|
+
this.#active = call;
|
|
2800
|
+
}
|
|
2801
|
+
retainAlias(call, identity) {
|
|
2802
|
+
if (this.#active !== call || call.phase === "closed") throw new Error("cannot retain an alias for an inactive FaceTime call");
|
|
2803
|
+
call.aliases.add(normalizeCallIdentity(identity));
|
|
2804
|
+
}
|
|
2805
|
+
close(call) {
|
|
2806
|
+
if (this.#active !== call) return;
|
|
2807
|
+
call.markClosed();
|
|
2808
|
+
this.#active = void 0;
|
|
2809
|
+
}
|
|
2810
|
+
};
|
|
2940
2811
|
function updateCallStatus(call, event) {
|
|
2941
2812
|
call.callStatus = event.data.call_status;
|
|
2942
2813
|
call.isSendingAudio = event.data.is_sending_audio ?? call.isSendingAudio;
|
|
@@ -2954,8 +2825,7 @@ function updateCallStatus(call, event) {
|
|
|
2954
2825
|
if (event.data.local_meter_level !== void 0) call.maxLocalMeterLevel = Math.max(call.maxLocalMeterLevel ?? 0, event.data.local_meter_level);
|
|
2955
2826
|
if (event.data.remote_meter_level !== void 0) call.maxRemoteMeterLevel = Math.max(call.maxRemoteMeterLevel ?? 0, event.data.remote_meter_level);
|
|
2956
2827
|
}
|
|
2957
|
-
|
|
2958
|
-
//#region extensions/facetime/src/runtime-call-events.ts
|
|
2828
|
+
// extensions/facetime/src/runtime-call-events.ts
|
|
2959
2829
|
function createFaceTimeCallEventHandler(params) {
|
|
2960
2830
|
const eventIdentities = (event) => [
|
|
2961
2831
|
event.data.call_uuid,
|
|
@@ -3036,7 +2906,7 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3036
2906
|
generation,
|
|
3037
2907
|
action: async () => await params.helper.answerCall(callUUID)
|
|
3038
2908
|
});
|
|
3039
|
-
|
|
2909
|
+
assertFaceTimeNativeAction("answer", answerResult);
|
|
3040
2910
|
retainHelperResultPeers(call, answerResult);
|
|
3041
2911
|
await params.callControl.activateCallTalk(call);
|
|
3042
2912
|
params.logger.info("[facetime] answered authorized FaceTime call");
|
|
@@ -3142,14 +3012,14 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3142
3012
|
retainPendingDial(ringingCall, pending);
|
|
3143
3013
|
}
|
|
3144
3014
|
if (ringingCall) try {
|
|
3145
|
-
const generation = ringingCall.
|
|
3015
|
+
const generation = ringingCall.generation;
|
|
3146
3016
|
const muteResult = await ringingCall.runCarrierCommand({
|
|
3147
3017
|
generation,
|
|
3148
3018
|
action: async () => await params.helper.safetyMute(ringingCall.carrierCallUUID)
|
|
3149
3019
|
});
|
|
3150
3020
|
ringingCall.lastHelperAction = muteResult;
|
|
3151
3021
|
retainHelperResultPeers(ringingCall, muteResult);
|
|
3152
|
-
|
|
3022
|
+
assertFaceTimeNativeAction("safe-mute", muteResult);
|
|
3153
3023
|
} catch (error) {
|
|
3154
3024
|
params.logger.warn(`[facetime] outbound ringing safety mute failed: ${formatErrorMessage(error)}`);
|
|
3155
3025
|
await params.callControl.attemptCarrierHangup(ringingCall, "outbound-ringing-safety-mute-failed");
|
|
@@ -3204,17 +3074,15 @@ function createFaceTimeCallEventHandler(params) {
|
|
|
3204
3074
|
};
|
|
3205
3075
|
return { handleCallEvent };
|
|
3206
3076
|
}
|
|
3207
|
-
|
|
3208
|
-
//#region extensions/facetime/src/talk-events-summary.ts
|
|
3077
|
+
// extensions/facetime/src/talk-events-summary.ts
|
|
3209
3078
|
function summarizeRecentTalkEvents(events) {
|
|
3210
3079
|
return events.slice(-12).map((event) => {
|
|
3211
|
-
const
|
|
3212
|
-
const payload = asRecord(record.payload);
|
|
3080
|
+
const payload = asRecord(event.payload);
|
|
3213
3081
|
return {
|
|
3214
|
-
type:
|
|
3215
|
-
turnId: normalizeOptionalString(
|
|
3216
|
-
callId: normalizeOptionalString(
|
|
3217
|
-
final:
|
|
3082
|
+
type: event.type,
|
|
3083
|
+
turnId: normalizeOptionalString(event.turnId),
|
|
3084
|
+
callId: normalizeOptionalString(event.callId),
|
|
3085
|
+
final: event.final,
|
|
3218
3086
|
byteLength: asFiniteNumber(payload.byteLength),
|
|
3219
3087
|
name: normalizeOptionalString(payload.name),
|
|
3220
3088
|
text: normalizeOptionalString(payload.text),
|
|
@@ -3222,8 +3090,7 @@ function summarizeRecentTalkEvents(events) {
|
|
|
3222
3090
|
};
|
|
3223
3091
|
});
|
|
3224
3092
|
}
|
|
3225
|
-
|
|
3226
|
-
//#region extensions/facetime/src/runtime-status.ts
|
|
3093
|
+
// extensions/facetime/src/runtime-status.ts
|
|
3227
3094
|
function buildFaceTimeRuntimeStatus(params) {
|
|
3228
3095
|
const calls = [...params.calls.values()];
|
|
3229
3096
|
return {
|
|
@@ -3283,8 +3150,7 @@ function buildFaceTimeRuntimeStatus(params) {
|
|
|
3283
3150
|
}))
|
|
3284
3151
|
};
|
|
3285
3152
|
}
|
|
3286
|
-
|
|
3287
|
-
//#region extensions/facetime/src/runtime.ts
|
|
3153
|
+
// extensions/facetime/src/runtime.ts
|
|
3288
3154
|
const OUTBOUND_RECONCILE_DELAY_MS = 1e3;
|
|
3289
3155
|
async function createFaceTimeRuntime(params) {
|
|
3290
3156
|
const config = resolveFaceTimeConfig(params.config);
|
|
@@ -3407,7 +3273,7 @@ async function createFaceTimeRuntime(params) {
|
|
|
3407
3273
|
}).finally(scheduleOutboundReconciliation);
|
|
3408
3274
|
const helperResults = readHelperResults(result);
|
|
3409
3275
|
const cancelled = helperResults.some((entry) => entry.cancelled === true);
|
|
3410
|
-
const helpersContacted =
|
|
3276
|
+
const helpersContacted = result.helpersContacted ?? helperResults.length;
|
|
3411
3277
|
const definitivelyAbsent = helperResults.length === helpersContacted && hasDialHelperConfirmation(helperResults) && helperResults.every((entry) => entry.found === false && entry.cancelled === false);
|
|
3412
3278
|
if (!cancelled && !definitivelyAbsent) throw new Error("FaceTime helper could not confirm outbound call cancellation");
|
|
3413
3279
|
const replyCallUUID = helperResults.map(readOutboundCallUUID).find((value) => Boolean(value));
|
|
@@ -3434,7 +3300,7 @@ async function createFaceTimeRuntime(params) {
|
|
|
3434
3300
|
if (helperStopped) return;
|
|
3435
3301
|
const outboundIdentity = normalizeFaceTimeOutboundIdentityEvent(message);
|
|
3436
3302
|
if (outboundIdentity && outboundCallPending?.dialID === outboundIdentity.data.dial_id) {
|
|
3437
|
-
if (
|
|
3303
|
+
if (DIAL_BUNDLES.has(peer.bundleIdentifier)) outboundCarrierPeers.set(peer.processId, peer);
|
|
3438
3304
|
retainFaceTimeDialCallUUID(outboundCallPending, outboundIdentity.data.call_uuid);
|
|
3439
3305
|
if (outboundIdentity.data.proxy_identifier) outboundCallPending.proxyIdentifier = outboundIdentity.data.proxy_identifier;
|
|
3440
3306
|
return observePendingOperation(persistOutboundCallPending());
|
|
@@ -3719,5 +3585,4 @@ async function createFaceTimeRuntime(params) {
|
|
|
3719
3585
|
}
|
|
3720
3586
|
};
|
|
3721
3587
|
}
|
|
3722
|
-
//#endregion
|
|
3723
3588
|
export { createFaceTimeRuntime };
|