@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/src/talk-driver.ts
CHANGED
|
@@ -13,7 +13,6 @@ import {
|
|
|
13
13
|
type RealtimeVoiceBridgeSession,
|
|
14
14
|
type RealtimeVoiceResponseOutcome,
|
|
15
15
|
type RealtimeVoiceTranscriptEntry,
|
|
16
|
-
type TalkEvent,
|
|
17
16
|
type TalkEventInput,
|
|
18
17
|
} from "openclaw/plugin-sdk/realtime-voice";
|
|
19
18
|
import { raceWithTimeout } from "openclaw/plugin-sdk/time-runtime";
|
|
@@ -30,18 +29,14 @@ import {
|
|
|
30
29
|
REALTIME_READY_TIMEOUT_MS,
|
|
31
30
|
resolveFaceTimeRealtimeProvider,
|
|
32
31
|
} from "./talk-driver-config.js";
|
|
33
|
-
import { createFaceTimeInitialGreeting } from "./talk-initial-greeting.js";
|
|
34
32
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
suspendMedia(reason?: string): Promise<void>;
|
|
43
|
-
close(reason?: string): Promise<void>;
|
|
44
|
-
};
|
|
33
|
+
// The carrier can report active before its newly enabled media route is audible.
|
|
34
|
+
// Give that route one short settling window. Only a real caller transcript may
|
|
35
|
+
// cancel the greeting because raw VAD can fire on route noise and never report a
|
|
36
|
+
// matching stop event, which would otherwise leave an answered call silent.
|
|
37
|
+
const FACETIME_INITIAL_GREETING =
|
|
38
|
+
"Greet the caller briefly, introduce yourself using your configured identity, and ask how you can help.";
|
|
39
|
+
const FACETIME_GREETING_MEDIA_SETTLE_MS = 100;
|
|
45
40
|
|
|
46
41
|
export async function startFaceTimeTalkDriver(params: {
|
|
47
42
|
config: FaceTimeConfig;
|
|
@@ -50,12 +45,11 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
50
45
|
logger: RuntimeLogger;
|
|
51
46
|
callUUID: string;
|
|
52
47
|
senderId: string;
|
|
53
|
-
senderIsOwner: true;
|
|
54
48
|
captureBinary: string;
|
|
55
49
|
signal?: AbortSignal;
|
|
56
50
|
onHangupRequested: () => Promise<void>;
|
|
57
51
|
onFailure?: (error: Error) => boolean | Promise<boolean>;
|
|
58
|
-
})
|
|
52
|
+
}) {
|
|
59
53
|
if (params.signal?.aborted) {
|
|
60
54
|
throw new Error("FaceTime talk startup aborted");
|
|
61
55
|
}
|
|
@@ -110,7 +104,6 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
110
104
|
| undefined;
|
|
111
105
|
const settledResponseIds = new Set<string>();
|
|
112
106
|
let suppressNextUnkeyedLegacyTerminal = false;
|
|
113
|
-
const consultRef: { current?: ReturnType<typeof createFaceTimeConsultController> } = {};
|
|
114
107
|
let failurePromise: Promise<boolean> | undefined;
|
|
115
108
|
let activated = false;
|
|
116
109
|
let providerReady = false;
|
|
@@ -139,13 +132,29 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
139
132
|
startupFailureDeferred.reject(error);
|
|
140
133
|
};
|
|
141
134
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
135
|
+
let timer: NodeJS.Timeout | undefined;
|
|
136
|
+
let dismissed = false;
|
|
137
|
+
const initialGreeting = {
|
|
138
|
+
instructions: FACETIME_INITIAL_GREETING,
|
|
139
|
+
schedule() {
|
|
140
|
+
if (dismissed || timer) {
|
|
141
|
+
return;
|
|
146
142
|
}
|
|
143
|
+
timer = setTimeout(() => {
|
|
144
|
+
timer = undefined;
|
|
145
|
+
dismissed = true;
|
|
146
|
+
if (!stopped && !mediaSuspended && activated && providerReady) {
|
|
147
|
+
bridge?.triggerGreeting(FACETIME_INITIAL_GREETING);
|
|
148
|
+
}
|
|
149
|
+
}, FACETIME_GREETING_MEDIA_SETTLE_MS);
|
|
150
|
+
timer.unref?.();
|
|
147
151
|
},
|
|
148
|
-
|
|
152
|
+
cancel() {
|
|
153
|
+
dismissed = true;
|
|
154
|
+
clearTimeout(timer);
|
|
155
|
+
timer = undefined;
|
|
156
|
+
},
|
|
157
|
+
};
|
|
149
158
|
|
|
150
159
|
const reportFailure = (error: Error): Promise<boolean> => {
|
|
151
160
|
if (failurePromise) {
|
|
@@ -170,7 +179,7 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
170
179
|
mediaSuspensionError ??= new Error(`FaceTime model media suspended: ${reason}`);
|
|
171
180
|
mediaSuspendedDeferred.reject(mediaSuspensionError);
|
|
172
181
|
interruptProviderConnect?.();
|
|
173
|
-
|
|
182
|
+
consultController.abortForClose();
|
|
174
183
|
suspendMediaPromise = (async () => {
|
|
175
184
|
try {
|
|
176
185
|
await bridge?.close();
|
|
@@ -309,7 +318,7 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
309
318
|
};
|
|
310
319
|
const resetProviderContinuity = () => {
|
|
311
320
|
modelMediaGeneration += 1;
|
|
312
|
-
|
|
321
|
+
consultController.abortForClose();
|
|
313
322
|
pump?.clearOutputAudio();
|
|
314
323
|
resetResponsePlayback();
|
|
315
324
|
finishOutputAudio("continuity-reset");
|
|
@@ -325,7 +334,6 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
325
334
|
requesterSessionKey,
|
|
326
335
|
normalizedCallUUID,
|
|
327
336
|
senderId: params.senderId,
|
|
328
|
-
senderIsOwner: params.senderIsOwner,
|
|
329
337
|
transcript,
|
|
330
338
|
getBridge: () => bridge,
|
|
331
339
|
getGeneration: () => modelMediaGeneration,
|
|
@@ -337,7 +345,6 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
337
345
|
close,
|
|
338
346
|
onHangupRequested: params.onHangupRequested,
|
|
339
347
|
});
|
|
340
|
-
consultRef.current = consultController;
|
|
341
348
|
|
|
342
349
|
remember({ type: "session.started", payload: { callUUID: params.callUUID } });
|
|
343
350
|
const pump = startFaceTimeAudioPump({
|
|
@@ -627,7 +634,6 @@ export async function startFaceTimeTalkDriver(params: {
|
|
|
627
634
|
throw error;
|
|
628
635
|
}
|
|
629
636
|
return {
|
|
630
|
-
callUUID: params.callUUID,
|
|
631
637
|
get recentTalkEvents() {
|
|
632
638
|
return talk.recentEvents;
|
|
633
639
|
},
|
|
@@ -1,29 +1,18 @@
|
|
|
1
|
+
import type { TalkEvent } from "openclaw/plugin-sdk/realtime-voice";
|
|
1
2
|
import {
|
|
2
3
|
asFiniteNumber,
|
|
3
4
|
asRecord,
|
|
4
5
|
normalizeOptionalString,
|
|
5
6
|
} from "openclaw/plugin-sdk/string-coerce-runtime";
|
|
6
7
|
|
|
7
|
-
export
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
callId?: string;
|
|
11
|
-
final?: boolean;
|
|
12
|
-
byteLength?: number;
|
|
13
|
-
name?: string;
|
|
14
|
-
text?: string;
|
|
15
|
-
message?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export function summarizeRecentTalkEvents(events: readonly unknown[]) {
|
|
19
|
-
return events.slice(-12).map((event): FaceTimeTalkEventSummary => {
|
|
20
|
-
const record = asRecord(event);
|
|
21
|
-
const payload = asRecord(record.payload);
|
|
8
|
+
export function summarizeRecentTalkEvents(events: readonly TalkEvent[]) {
|
|
9
|
+
return events.slice(-12).map((event) => {
|
|
10
|
+
const payload = asRecord(event.payload);
|
|
22
11
|
return {
|
|
23
|
-
type:
|
|
24
|
-
turnId: normalizeOptionalString(
|
|
25
|
-
callId: normalizeOptionalString(
|
|
26
|
-
final:
|
|
12
|
+
type: event.type,
|
|
13
|
+
turnId: normalizeOptionalString(event.turnId),
|
|
14
|
+
callId: normalizeOptionalString(event.callId),
|
|
15
|
+
final: event.final,
|
|
27
16
|
byteLength: asFiniteNumber(payload.byteLength),
|
|
28
17
|
name: normalizeOptionalString(payload.name),
|
|
29
18
|
text: normalizeOptionalString(payload.text),
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
// deno-lint-ignore-file no-explicit-any
|
|
2
|
-
import { Settings } from '../settings/index.mjs';
|
|
3
|
-
/** Conditionally freezes the value if `immutableTypes` is true, otherwise no action. */
|
|
4
|
-
export function Freeze(value) {
|
|
5
|
-
return Settings.Get().immutableTypes ? Object.freeze(value) : value;
|
|
6
|
-
}
|
package/src/call-lifecycle.ts
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
|
|
2
|
-
|
|
3
|
-
type FaceTimeCarrierMode = "ringing" | "muted" | "active" | "closing" | "closed";
|
|
4
|
-
|
|
5
|
-
type FaceTimeModelMediaMode = "starting" | "ready" | "active" | "suspended" | "closed";
|
|
6
|
-
|
|
7
|
-
type FaceTimeCallPhase = "ringing" | "answering" | "active" | "closing" | "closed";
|
|
8
|
-
|
|
9
|
-
function normalizeCallIdentity(value: string): string {
|
|
10
|
-
return value.trim().toLowerCase();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class FaceTimeCallInstance {
|
|
14
|
-
readonly lifecycleAbort = new AbortController();
|
|
15
|
-
readonly aliases = new Set<string>();
|
|
16
|
-
generation = 1;
|
|
17
|
-
phase: FaceTimeCallPhase;
|
|
18
|
-
carrierMode: FaceTimeCarrierMode;
|
|
19
|
-
modelMediaMode: FaceTimeModelMediaMode = "starting";
|
|
20
|
-
#carrierClosure = createDeferred<void>();
|
|
21
|
-
readonly carrierClosure = this.#carrierClosure.promise;
|
|
22
|
-
#commandTail: Promise<void> = Promise.resolve();
|
|
23
|
-
|
|
24
|
-
constructor(canonicalId: string, phase: "ringing" | "active") {
|
|
25
|
-
this.phase = phase;
|
|
26
|
-
this.carrierMode = phase === "ringing" ? "ringing" : "muted";
|
|
27
|
-
this.aliases.add(normalizeCallIdentity(canonicalId));
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
captureGeneration(): number {
|
|
31
|
-
return this.generation;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
assertCurrent(generation: number, allowClosing = false): void {
|
|
35
|
-
const phaseAllowed = allowClosing
|
|
36
|
-
? this.phase !== "closed" && this.carrierMode !== "closed"
|
|
37
|
-
: this.phase !== "closing" && this.phase !== "closed";
|
|
38
|
-
if (
|
|
39
|
-
generation !== this.generation ||
|
|
40
|
-
!phaseAllowed ||
|
|
41
|
-
(!allowClosing && this.lifecycleAbort.signal.aborted)
|
|
42
|
-
) {
|
|
43
|
-
throw new Error("FaceTime call lifecycle changed during carrier command");
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
async runCarrierCommand<T>(params: {
|
|
48
|
-
generation: number;
|
|
49
|
-
allowClosing?: boolean;
|
|
50
|
-
action: () => Promise<T>;
|
|
51
|
-
}): Promise<T> {
|
|
52
|
-
const previous = this.#commandTail;
|
|
53
|
-
const { promise, resolve: release } = createDeferred<void>();
|
|
54
|
-
this.#commandTail = promise;
|
|
55
|
-
await previous;
|
|
56
|
-
try {
|
|
57
|
-
this.assertCurrent(params.generation, params.allowClosing);
|
|
58
|
-
const result = await params.action();
|
|
59
|
-
this.assertCurrent(params.generation, params.allowClosing);
|
|
60
|
-
return result;
|
|
61
|
-
} finally {
|
|
62
|
-
release();
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
beginAnswering(): number {
|
|
67
|
-
if (this.phase !== "ringing") {
|
|
68
|
-
throw new Error(`cannot answer FaceTime call in ${this.phase} phase`);
|
|
69
|
-
}
|
|
70
|
-
this.phase = "answering";
|
|
71
|
-
this.carrierMode = "muted";
|
|
72
|
-
return this.generation;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
markCarrierActive(generation: number): void {
|
|
76
|
-
this.assertCurrent(generation);
|
|
77
|
-
this.phase = "active";
|
|
78
|
-
this.carrierMode = "active";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
markModelReady(generation: number): void {
|
|
82
|
-
this.assertCurrent(generation);
|
|
83
|
-
this.modelMediaMode = "ready";
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
markModelActive(generation: number): void {
|
|
87
|
-
this.assertCurrent(generation);
|
|
88
|
-
this.modelMediaMode = "active";
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
suspendModelMedia(): void {
|
|
92
|
-
if (this.modelMediaMode !== "closed") {
|
|
93
|
-
this.modelMediaMode = "suspended";
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
beginClosing(): number {
|
|
98
|
-
if (this.phase === "closed") {
|
|
99
|
-
return this.generation;
|
|
100
|
-
}
|
|
101
|
-
if (this.phase !== "closing") {
|
|
102
|
-
this.generation += 1;
|
|
103
|
-
this.phase = "closing";
|
|
104
|
-
this.carrierMode = "closing";
|
|
105
|
-
this.suspendModelMedia();
|
|
106
|
-
this.lifecycleAbort.abort(new Error("FaceTime call is closing"));
|
|
107
|
-
}
|
|
108
|
-
return this.generation;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// Carrier proof releases startup before local media teardown can be joined.
|
|
112
|
-
markCarrierClosed(): void {
|
|
113
|
-
this.beginClosing();
|
|
114
|
-
this.carrierMode = "closed";
|
|
115
|
-
this.#carrierClosure.resolve(undefined);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
markClosed(): void {
|
|
119
|
-
this.phase = "closed";
|
|
120
|
-
this.carrierMode = "closed";
|
|
121
|
-
this.modelMediaMode = "closed";
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
export class FaceTimeCallRegistry<T extends FaceTimeCallInstance> {
|
|
126
|
-
#active: T | undefined;
|
|
127
|
-
|
|
128
|
-
get active(): T | undefined {
|
|
129
|
-
return this.#active;
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
get size(): number {
|
|
133
|
-
return this.#active && this.#active.phase !== "closed" ? 1 : 0;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
values(): IterableIterator<T> {
|
|
137
|
-
return (this.#active && this.#active.phase !== "closed" ? [this.#active] : [])[
|
|
138
|
-
Symbol.iterator
|
|
139
|
-
]();
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
get(identity: string): T | undefined {
|
|
143
|
-
return this.#active?.aliases.has(normalizeCallIdentity(identity)) ? this.#active : undefined;
|
|
144
|
-
}
|
|
145
|
-
|
|
146
|
-
has(identity: string): boolean {
|
|
147
|
-
return this.get(identity) !== undefined;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
create(call: T): void {
|
|
151
|
-
if (this.#active && this.#active.phase !== "closed") {
|
|
152
|
-
throw new Error("another FaceTime call lifecycle is already active");
|
|
153
|
-
}
|
|
154
|
-
this.#active = call;
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
retainAlias(call: T, identity: string): void {
|
|
158
|
-
if (this.#active !== call || call.phase === "closed") {
|
|
159
|
-
throw new Error("cannot retain an alias for an inactive FaceTime call");
|
|
160
|
-
}
|
|
161
|
-
call.aliases.add(normalizeCallIdentity(identity));
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
close(call: T): void {
|
|
165
|
-
if (this.#active !== call) {
|
|
166
|
-
return;
|
|
167
|
-
}
|
|
168
|
-
call.markClosed();
|
|
169
|
-
this.#active = undefined;
|
|
170
|
-
}
|
|
171
|
-
}
|
package/src/runtime-lifecycle.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export async function stopRetainedRuntime<T extends { stop(): Promise<void> }>(
|
|
2
|
-
current: Promise<T> | undefined,
|
|
3
|
-
clearIfCurrent: (stopped: Promise<T>) => void,
|
|
4
|
-
): Promise<void> {
|
|
5
|
-
if (!current) {
|
|
6
|
-
return;
|
|
7
|
-
}
|
|
8
|
-
let runtime: T;
|
|
9
|
-
try {
|
|
10
|
-
runtime = await current;
|
|
11
|
-
} catch (error) {
|
|
12
|
-
clearIfCurrent(current);
|
|
13
|
-
throw error;
|
|
14
|
-
}
|
|
15
|
-
await runtime.stop();
|
|
16
|
-
clearIfCurrent(current);
|
|
17
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
// The carrier can report active before its newly enabled media route is audible.
|
|
2
|
-
// Give that route one short settling window. Only a real caller transcript may
|
|
3
|
-
// cancel the greeting because raw VAD can fire on route noise and never report a
|
|
4
|
-
// matching stop event, which would otherwise leave an answered call silent.
|
|
5
|
-
const FACETIME_INITIAL_GREETING =
|
|
6
|
-
"Greet the caller briefly, introduce yourself using your configured identity, and ask how you can help.";
|
|
7
|
-
const FACETIME_GREETING_MEDIA_SETTLE_MS = 100;
|
|
8
|
-
|
|
9
|
-
export function createFaceTimeInitialGreeting(params: { speak: (instructions: string) => void }): {
|
|
10
|
-
readonly instructions: string;
|
|
11
|
-
schedule(): void;
|
|
12
|
-
cancel(): void;
|
|
13
|
-
} {
|
|
14
|
-
let timer: NodeJS.Timeout | undefined;
|
|
15
|
-
let dismissed = false;
|
|
16
|
-
|
|
17
|
-
const clear = () => {
|
|
18
|
-
if (timer) {
|
|
19
|
-
clearTimeout(timer);
|
|
20
|
-
timer = undefined;
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
return {
|
|
25
|
-
instructions: FACETIME_INITIAL_GREETING,
|
|
26
|
-
schedule() {
|
|
27
|
-
if (dismissed || timer) {
|
|
28
|
-
return;
|
|
29
|
-
}
|
|
30
|
-
timer = setTimeout(() => {
|
|
31
|
-
timer = undefined;
|
|
32
|
-
dismissed = true;
|
|
33
|
-
params.speak(FACETIME_INITIAL_GREETING);
|
|
34
|
-
}, FACETIME_GREETING_MEDIA_SETTLE_MS);
|
|
35
|
-
timer.unref?.();
|
|
36
|
-
},
|
|
37
|
-
cancel() {
|
|
38
|
-
dismissed = true;
|
|
39
|
-
clear();
|
|
40
|
-
},
|
|
41
|
-
};
|
|
42
|
-
}
|