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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@openclaw/facetime",
3
- "version": "2026.10.1-beta.2",
3
+ "version": "2026.10.5-beta.1",
4
4
  "description": "Experimental FaceTime realtime voice carrier for OpenClaw agents",
5
5
  "license": "MIT",
6
6
  "author": "OpenClaw contributors",
@@ -66,7 +66,7 @@
66
66
  "typebox": "1.3.34"
67
67
  },
68
68
  "peerDependencies": {
69
- "openclaw": ">=2026.10.1-beta.2"
69
+ "openclaw": ">=2026.10.5-beta.1"
70
70
  },
71
71
  "peerDependenciesMeta": {
72
72
  "openclaw": {
@@ -85,11 +85,11 @@
85
85
  "allowInvalidConfigRecovery": true
86
86
  },
87
87
  "compat": {
88
- "pluginApi": ">=2026.10.1-beta.2"
88
+ "pluginApi": ">=2026.10.5-beta.1"
89
89
  },
90
90
  "build": {
91
91
  "bundledDist": false,
92
- "openclawVersion": "2026.10.1-beta.2"
92
+ "openclawVersion": "2026.10.5-beta.1"
93
93
  },
94
94
  "release": {
95
95
  "publishToClawHub": true,
package/src/audio-pump.ts CHANGED
@@ -1,6 +1,5 @@
1
- import { spawn } from "node:child_process";
1
+ import { spawn, type ChildProcess } from "node:child_process";
2
2
  import { existsSync } from "node:fs";
3
- import type { Writable } from "node:stream";
4
3
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
5
4
  import { createDeferred } from "openclaw/plugin-sdk/extension-shared";
6
5
  import type { RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime";
@@ -10,29 +9,6 @@ import type {
10
9
  } from "openclaw/plugin-sdk/realtime-voice";
11
10
  import { sleepWithAbort } from "openclaw/plugin-sdk/runtime-env";
12
11
 
13
- type PumpProcess = {
14
- pid?: number;
15
- killed?: boolean;
16
- stdin?: (Writable & { writableLength?: number }) | null;
17
- stdout?: { on(event: "data", listener: (chunk: Buffer | string) => void): unknown } | null;
18
- stderr?: { on(event: "data", listener: (chunk: Buffer | string) => void): unknown } | null;
19
- kill(signal?: NodeJS.Signals): boolean;
20
- on(
21
- event: "exit",
22
- listener: (code: number | null, signal: NodeJS.Signals | null) => void,
23
- ): unknown;
24
- on(event: "error", listener: (error: Error) => void): unknown;
25
- };
26
-
27
- type SpawnFn = (
28
- command: string,
29
- args: string[],
30
- options: {
31
- env: NodeJS.ProcessEnv;
32
- stdio: ["pipe" | "ignore", "pipe" | "ignore", "pipe" | "ignore"];
33
- },
34
- ) => PumpProcess;
35
-
36
12
  const CAFFEINATE_COMMAND = "/usr/bin/caffeinate";
37
13
  const CAPTURE_CLOSE_SAFE_FRAME = Buffer.from([4, 0, 0, 0, 4, 0, 0, 0, 0]);
38
14
  const FACETIME_AUDIO_SAMPLE_RATE_HZ = 24_000;
@@ -50,6 +26,11 @@ export const FACETIME_FEED_DEVICE_NAME = "OpenClaw-Feed";
50
26
  export const FACETIME_MIC_DEVICE_NAME = "OpenClaw-Mic";
51
27
  const MAX_PLAYBACK_BUFFERED_BYTES = 2 * 1024 * 1024;
52
28
 
29
+ type AudioProcess =
30
+ | { kind: "capture"; command: string }
31
+ | { kind: "playback" }
32
+ | { kind: "wake"; capturePid?: number };
33
+
53
34
  type FaceTimeAudioPump = {
54
35
  suppressionReady(): Promise<void>;
55
36
  routeReady(): Promise<void>;
@@ -64,9 +45,9 @@ type FaceTimeAudioPump = {
64
45
  stop(): Promise<void>;
65
46
  };
66
47
 
67
- function sanitizedAudioChildEnv(env: NodeJS.ProcessEnv = process.env): NodeJS.ProcessEnv {
48
+ function sanitizedAudioChildEnv(): NodeJS.ProcessEnv {
68
49
  return Object.fromEntries(
69
- Object.entries(env).filter(
50
+ Object.entries(process.env).filter(
70
51
  ([key]) => !/(?:API_?KEY|AUTH|CREDENTIAL|PASSWORD|SECRET|TOKEN)/iu.test(key),
71
52
  ),
72
53
  );
@@ -80,7 +61,8 @@ class PlaybackClock {
80
61
  private retiredFrames = 0;
81
62
  private items: Array<{ itemId?: string; frames: number }> = [];
82
63
 
83
- append(frames: number, itemId?: string, nowMs = Date.now()): void {
64
+ append(frames: number, itemId?: string): void {
65
+ const nowMs = Date.now();
84
66
  if (nowMs >= this.playbackUntilMs) {
85
67
  this.playedFramesBeforeSegment = this.generatedFrames;
86
68
  this.playbackStartsAtMs = nowMs + OUTPUT_LATENCY_BUDGET_MS;
@@ -117,7 +99,8 @@ class PlaybackClock {
117
99
  this.retiredFrames = this.generatedFrames;
118
100
  }
119
101
 
120
- playedFrames(nowMs = Date.now()): number {
102
+ playedFrames(): number {
103
+ const nowMs = Date.now();
121
104
  if (nowMs <= this.playbackStartsAtMs) {
122
105
  return this.playedFramesBeforeSegment;
123
106
  }
@@ -126,12 +109,12 @@ class PlaybackClock {
126
109
  return Math.min(this.generatedFrames, this.playedFramesBeforeSegment + elapsedFrames);
127
110
  }
128
111
 
129
- queuedFrames(nowMs = Date.now()): number {
130
- return Math.max(0, this.generatedFrames - this.playedFrames(nowMs));
112
+ queuedFrames(): number {
113
+ return Math.max(0, this.generatedFrames - this.playedFrames());
131
114
  }
132
115
 
133
- millisecondsUntilDrained(nowMs = Date.now()): number {
134
- return Math.max(0, this.playbackUntilMs - nowMs);
116
+ millisecondsUntilDrained(): number {
117
+ return Math.max(0, this.playbackUntilMs - Date.now());
135
118
  }
136
119
 
137
120
  reset(): void {
@@ -166,7 +149,31 @@ function buildSoxOutputArguments(): string[] {
166
149
  ];
167
150
  }
168
151
 
169
- async function terminateProcess(proc: PumpProcess, signal: NodeJS.Signals = "SIGTERM") {
152
+ function spawnAudioProcess(process: AudioProcess, env: NodeJS.ProcessEnv): ChildProcess {
153
+ let command: string;
154
+ let args: string[];
155
+ let stdio: ["pipe" | "ignore", "pipe" | "ignore", "pipe" | "ignore"];
156
+ switch (process.kind) {
157
+ case "capture":
158
+ command = process.command;
159
+ args = [];
160
+ stdio = ["pipe", "pipe", "pipe"];
161
+ break;
162
+ case "playback":
163
+ command = SOX_COMMAND;
164
+ args = buildSoxOutputArguments();
165
+ stdio = ["pipe", "ignore", "pipe"];
166
+ break;
167
+ case "wake":
168
+ command = CAFFEINATE_COMMAND;
169
+ args = ["-d", "-i", ...(process.capturePid ? ["-w", String(process.capturePid)] : [])];
170
+ stdio = ["ignore", "ignore", "pipe"];
171
+ break;
172
+ }
173
+ return spawn(command, args, { env, stdio });
174
+ }
175
+
176
+ async function terminateProcess(proc: ChildProcess, signal: NodeJS.Signals = "SIGTERM") {
170
177
  if (proc.killed && signal !== "SIGKILL") {
171
178
  return;
172
179
  }
@@ -177,19 +184,17 @@ async function terminateProcess(proc: PumpProcess, signal: NodeJS.Signals = "SIG
177
184
  resolve();
178
185
  });
179
186
  });
180
- try {
181
- proc.kill(signal);
182
- } catch {
183
- return;
184
- }
185
- await Promise.race([exitedPromise, sleepWithAbort(500, undefined, { ref: false })]);
186
- if (!exited && signal !== "SIGKILL") {
187
+ const signals: NodeJS.Signals[] = signal === "SIGKILL" ? [signal] : [signal, "SIGKILL"];
188
+ for (const nextSignal of signals) {
187
189
  try {
188
- proc.kill("SIGKILL");
190
+ proc.kill(nextSignal);
189
191
  } catch {
190
192
  return;
191
193
  }
192
194
  await Promise.race([exitedPromise, sleepWithAbort(500, undefined, { ref: false })]);
195
+ if (exited) {
196
+ return;
197
+ }
193
198
  }
194
199
  }
195
200
 
@@ -200,19 +205,16 @@ export function startFaceTimeAudioPump(params: {
200
205
  onError?: (error: Error) => boolean | void | Promise<boolean | void>;
201
206
  onSuppressionLost?: (error: Error) => void | Promise<void>;
202
207
  onPlaybackDrained?: (event: { generation: number; playedFrames: number }) => void;
203
- spawn?: SpawnFn;
204
208
  }): FaceTimeAudioPump {
205
- const spawnFn: SpawnFn =
206
- params.spawn ?? ((command, args, options) => spawn(command, args, options));
207
209
  const childEnv = sanitizedAudioChildEnv();
208
210
  const playbackClock = new PlaybackClock();
209
211
  let playbackGeneration = 1;
210
212
  let drainTimer: NodeJS.Timeout | undefined;
211
- let outputProcess: PumpProcess;
212
- const captureProcess = spawnFn(params.captureBinary, [], {
213
- env: childEnv,
214
- stdio: ["pipe", "pipe", "pipe"],
215
- });
213
+ let outputProcess: ChildProcess;
214
+ const captureProcess = spawnAudioProcess(
215
+ { kind: "capture", command: params.captureBinary },
216
+ childEnv,
217
+ );
216
218
  let stopped = false;
217
219
  let mediaSuspended = false;
218
220
  let captureSuppressionActive = false;
@@ -281,20 +283,14 @@ export function startFaceTimeAudioPump(params: {
281
283
  const spawnOutput = () => {
282
284
  // Playback stays out of the capture helper: an in-process AVAudioEngine can
283
285
  // rebind OpenClaw-Feed after FaceTime claims it and tear down the carrier.
284
- const proc = spawnFn(SOX_COMMAND, buildSoxOutputArguments(), {
285
- env: childEnv,
286
- stdio: ["pipe", "ignore", "pipe"],
287
- });
288
- proc.on("error", (error) => {
286
+ const proc = spawnAudioProcess({ kind: "playback" }, childEnv);
287
+ const onError = (error: Error) => {
289
288
  if (!stopped && !mediaSuspended && proc === outputProcess) {
290
289
  reportFailure(error, false);
291
290
  }
292
- });
293
- proc.stdin?.on("error", (error) => {
294
- if (!stopped && !mediaSuspended && proc === outputProcess) {
295
- reportFailure(error, false);
296
- }
297
- });
291
+ };
292
+ proc.on("error", onError);
293
+ proc.stdin?.on("error", onError);
298
294
  proc.on("exit", (code, signal) => {
299
295
  if (!stopped && !mediaSuspended && proc === outputProcess) {
300
296
  reportFailure(new Error(`SoX playback exited (${code ?? signal ?? "done"})`), false);
@@ -356,11 +352,7 @@ export function startFaceTimeAudioPump(params: {
356
352
  ]);
357
353
  };
358
354
  const wakeProcess = existsSync(CAFFEINATE_COMMAND)
359
- ? spawnFn(
360
- CAFFEINATE_COMMAND,
361
- ["-d", "-i", ...(captureProcess.pid ? ["-w", String(captureProcess.pid)] : [])],
362
- { env: childEnv, stdio: ["ignore", "ignore", "pipe"] },
363
- )
355
+ ? spawnAudioProcess({ kind: "wake", capturePid: captureProcess.pid }, childEnv)
364
356
  : undefined;
365
357
  wakeProcess?.on("error", () => undefined);
366
358
  captureProcess.on("error", (error) => reportFailure(error, true));
@@ -74,7 +74,7 @@ function normalizeCallTransport(value: unknown) {
74
74
  isVoip: asBoolean(transport.is_voip ?? transport.isVoip),
75
75
  isEmergency: asBoolean(transport.is_emergency ?? transport.isEmergency),
76
76
  };
77
- if (
77
+ const verifiedFaceTime =
78
78
  transport.kind === "facetime" &&
79
79
  (transport.classifier_version === "tu-provider-v1" ||
80
80
  transport.classifierVersion === "tu-provider-v1") &&
@@ -85,26 +85,9 @@ function normalizeCallTransport(value: unknown) {
85
85
  base.isUsingBaseband === false &&
86
86
  base.isWifiCall === false &&
87
87
  base.isVoip === true &&
88
- base.isEmergency === false
89
- ) {
90
- return {
91
- kind: "facetime",
92
- classifierVersion: base.classifierVersion,
93
- service: base.service,
94
- ...(base.faceTimeTransportType !== undefined
95
- ? { faceTimeTransportType: base.faceTimeTransportType }
96
- : {}),
97
- providerClassified: true,
98
- providerIsFaceTime: true,
99
- providerIsTelephony: false,
100
- isUsingBaseband: false,
101
- isWifiCall: false,
102
- isVoip: true,
103
- isEmergency: false,
104
- };
105
- }
88
+ base.isEmergency === false;
106
89
  return {
107
- kind: transport.kind === "cellular" ? "cellular" : "unknown",
90
+ kind: verifiedFaceTime ? "facetime" : transport.kind === "cellular" ? "cellular" : "unknown",
108
91
  classifierVersion: base.classifierVersion,
109
92
  ...(base.service !== undefined ? { service: base.service } : {}),
110
93
  ...(base.faceTimeTransportType !== undefined
@@ -160,12 +143,8 @@ function collectHandleCandidates(
160
143
  return candidates;
161
144
  }
162
145
 
163
- function normalizeFaceTimeHandleCandidates(value: unknown): string[] {
164
- return [...new Set(collectHandleCandidates(value).map((candidate) => candidate.trim()))];
165
- }
166
-
167
146
  export function normalizeFaceTimeHandle(value: unknown): string | undefined {
168
- return normalizeFaceTimeHandleCandidates(value)[0];
147
+ return collectHandleCandidates(value)[0];
169
148
  }
170
149
 
171
150
  function canonicalizeFaceTimeHandle(value: string): string {
@@ -229,7 +208,7 @@ export function resolveAuthorizedFaceTimeOwner(params: {
229
208
  return undefined;
230
209
  }
231
210
  const ownerHandles = new Set(params.ownerHandles.map(canonicalizeFaceTimeHandle).filter(Boolean));
232
- const senderId = normalizeFaceTimeHandleCandidates(params.event.data.handle)
211
+ const senderId = collectHandleCandidates(params.event.data.handle)
233
212
  .map(canonicalizeFaceTimeHandle)
234
213
  .find((candidate) => ownerHandles.has(candidate));
235
214
  if (!senderId) {
@@ -36,11 +36,8 @@ export async function inspectFaceTimeDriver(
36
36
  }
37
37
 
38
38
  export async function installFaceTimeDriver(
39
- params: DriverSetupParams & { callActive: boolean },
39
+ params: DriverSetupParams,
40
40
  ): Promise<{ changed: boolean; status: "current" }> {
41
- if (params.callActive) {
42
- throw new Error("Cannot install the FaceTime audio driver during an active or pending call");
43
- }
44
41
  const before = await inspectFaceTimeDriver(params);
45
42
  if (before === "current") {
46
43
  return { changed: false, status: "current" };
@@ -2,9 +2,8 @@ import endpoint from "../helper-endpoint.json" with { type: "json" };
2
2
 
3
3
  type FaceTimeHelperEndpoint = { host: "127.0.0.1"; port: number };
4
4
 
5
- export function resolveFaceTimeHelperEndpoint(
6
- uid = typeof process.getuid === "function" ? process.getuid() : 501,
7
- ): FaceTimeHelperEndpoint {
5
+ export function resolveFaceTimeHelperEndpoint(): FaceTimeHelperEndpoint {
6
+ const uid = typeof process.getuid === "function" ? process.getuid() : 501;
8
7
  if (
9
8
  endpoint.host !== "127.0.0.1" ||
10
9
  !Number.isSafeInteger(endpoint.basePort) ||
@@ -25,11 +25,6 @@ type HelperSupervisorParams = {
25
25
  logger: RuntimeLogger;
26
26
  runCommandWithTimeout: PluginRuntime["system"]["runCommandWithTimeout"];
27
27
  connectedBundles: () => string[];
28
- initialGraceMs?: number;
29
- retryDelaysMs?: readonly number[];
30
- targetAvailable?: (target: FaceTimeHelperTarget) => boolean;
31
- processAlive?: (processId: number) => boolean;
32
- connectionGraceMs?: number;
33
28
  };
34
29
 
35
30
  const TARGET_BUNDLES: Record<FaceTimeHelperTarget, ReadonlySet<string>> = {
@@ -42,7 +37,7 @@ const TARGET_APP_PATHS: Record<FaceTimeHelperTarget, string> = {
42
37
  };
43
38
  const FACETIME_HELPER_TARGETS = ["FaceTime", "Phone"] as const;
44
39
 
45
- const DEFAULT_RETRY_DELAYS_MS = [1_000, 2_000, 5_000, 10_000, 30_000, 60_000] as const;
40
+ const RETRY_DELAYS_MS = [1_000, 2_000, 5_000, 10_000, 30_000, 60_000] as const;
46
41
 
47
42
  function targetForBundle(bundleIdentifier: string): FaceTimeHelperTarget | undefined {
48
43
  return FACETIME_HELPER_TARGETS.find((target) => TARGET_BUNDLES[target].has(bundleIdentifier));
@@ -51,32 +46,27 @@ function targetForBundle(bundleIdentifier: string): FaceTimeHelperTarget | undef
51
46
  export class FaceTimeHelperSupervisor {
52
47
  readonly #states: Map<FaceTimeHelperTarget, HelperSupervisorTargetState>;
53
48
  readonly #timers = new Map<FaceTimeHelperTarget, ReturnType<typeof setTimeout>>();
54
- readonly #retryDelaysMs: readonly number[];
55
49
  #injectionChain: Promise<void> = Promise.resolve();
56
50
  #started = false;
57
51
  #generation = 0;
58
52
  #abortController = new AbortController();
59
53
 
60
54
  constructor(private readonly params: HelperSupervisorParams) {
61
- this.#retryDelaysMs =
62
- params.retryDelaysMs && params.retryDelaysMs.length > 0
63
- ? params.retryDelaysMs
64
- : DEFAULT_RETRY_DELAYS_MS;
65
- const targetAvailable =
66
- params.targetAvailable ?? ((target) => existsSync(TARGET_APP_PATHS[target]));
67
55
  this.#states = new Map(
68
- FACETIME_HELPER_TARGETS.filter((target) => targetAvailable(target)).map((target) => [
69
- target,
70
- {
56
+ FACETIME_HELPER_TARGETS.filter((target) => existsSync(TARGET_APP_PATHS[target])).map(
57
+ (target) => [
71
58
  target,
72
- connected: false,
73
- attempts: 0,
74
- injecting: false,
75
- queued: false,
76
- retryScheduled: false,
77
- stale: false,
78
- },
79
- ]),
59
+ {
60
+ target,
61
+ connected: false,
62
+ attempts: 0,
63
+ injecting: false,
64
+ queued: false,
65
+ retryScheduled: false,
66
+ stale: false,
67
+ },
68
+ ],
69
+ ),
80
70
  );
81
71
  }
82
72
 
@@ -90,7 +80,7 @@ export class FaceTimeHelperSupervisor {
90
80
  this.#refreshConnections();
91
81
  for (const target of this.#states.keys()) {
92
82
  if (!this.#states.get(target)?.connected) {
93
- this.#schedule(target, this.params.initialGraceMs ?? 6_000);
83
+ this.#schedule(target, 6_000);
94
84
  }
95
85
  }
96
86
  }
@@ -130,7 +120,7 @@ export class FaceTimeHelperSupervisor {
130
120
  }
131
121
  this.#refreshConnections();
132
122
  if (this.#started && !this.#states.get(target)?.connected) {
133
- this.#schedule(target, this.#retryDelaysMs[0] ?? 1_000);
123
+ this.#schedule(target, RETRY_DELAYS_MS[0]);
134
124
  }
135
125
  }
136
126
 
@@ -201,24 +191,22 @@ export class FaceTimeHelperSupervisor {
201
191
  if (!this.#started) {
202
192
  return;
203
193
  }
204
- const processAlive =
205
- this.params.processAlive ??
206
- ((candidate: number) => {
207
- try {
208
- process.kill(candidate, 0);
209
- return true;
210
- } catch (error) {
211
- if (error && typeof error === "object" && "code" in error) {
212
- return error.code !== "ESRCH";
213
- }
214
- return true;
215
- }
216
- });
217
194
  const state = this.#states.get(target);
218
195
  if (!state?.stale || state.staleProcessId !== processId) {
219
196
  return;
220
197
  }
221
- if (processAlive(processId)) {
198
+ let processAlive = true;
199
+ try {
200
+ process.kill(processId, 0);
201
+ } catch (error) {
202
+ processAlive = !(
203
+ error &&
204
+ typeof error === "object" &&
205
+ "code" in error &&
206
+ error.code === "ESRCH"
207
+ );
208
+ }
209
+ if (processAlive) {
222
210
  this.#scheduleStaleProcessCheck(target, processId);
223
211
  return;
224
212
  }
@@ -252,7 +240,7 @@ export class FaceTimeHelperSupervisor {
252
240
  target: FaceTimeHelperTarget,
253
241
  generation: number,
254
242
  ): Promise<void> {
255
- const deadline = Date.now() + (this.params.connectionGraceMs ?? 10_000);
243
+ const deadline = Date.now() + 10_000;
256
244
  while (this.#started && generation === this.#generation && Date.now() < deadline) {
257
245
  this.#refreshConnections();
258
246
  const state = this.#states.get(target);
@@ -314,8 +302,8 @@ export class FaceTimeHelperSupervisor {
314
302
  }
315
303
  this.#refreshConnections();
316
304
  if (!state.connected && !state.stale) {
317
- const retryIndex = Math.min(state.attempts - 1, this.#retryDelaysMs.length - 1);
318
- this.#schedule(target, this.#retryDelaysMs[retryIndex] ?? 60_000);
305
+ const retryIndex = Math.min(state.attempts - 1, RETRY_DELAYS_MS.length - 1);
306
+ this.#schedule(target, RETRY_DELAYS_MS[retryIndex] ?? 60_000);
319
307
  }
320
308
  }
321
309
  }
@@ -27,12 +27,7 @@ function resolveHelperStateFile(name: "helper-ipc-key" | "helper-build.sha256"):
27
27
  return resolve(homedir(), "Library", "Application Support", "OpenClaw", "FaceTime", name);
28
28
  }
29
29
 
30
- async function resolveNativeInstall(params: {
31
- access?: typeof access;
32
- readFile?: typeof readFile;
33
- }): Promise<{ buildId: string; capture: string; directory: string; helper: string }> {
34
- const checkAccess = params.access ?? access;
35
- const loadFile = params.readFile ?? readFile;
30
+ async function resolveNativeInstall(): Promise<{ buildId: string; capture: string }> {
36
31
  for (const directory of NATIVE_DIRS) {
37
32
  const capture = resolve(directory, "facetime-audio-capture");
38
33
  const helper = resolve(directory, "FaceTimeHelper.dylib");
@@ -40,19 +35,19 @@ async function resolveNativeInstall(params: {
40
35
  const protocolFile = resolve(directory, "native-protocol.env");
41
36
  try {
42
37
  await Promise.all([
43
- checkAccess(capture, constants.X_OK),
44
- checkAccess(helper, constants.R_OK),
45
- checkAccess(buildIdFile, constants.R_OK),
46
- checkAccess(protocolFile, constants.R_OK),
38
+ access(capture, constants.X_OK),
39
+ access(helper, constants.R_OK),
40
+ access(buildIdFile, constants.R_OK),
41
+ access(protocolFile, constants.R_OK),
47
42
  ]);
48
43
  const [buildId, protocol] = await Promise.all([
49
- loadFile(buildIdFile, "utf8").then((value) => value.trim()),
50
- loadFile(protocolFile, "utf8").then((value) => value.trim()),
44
+ readFile(buildIdFile, "utf8").then((value) => value.trim()),
45
+ readFile(protocolFile, "utf8").then((value) => value.trim()),
51
46
  ]);
52
47
  if (!/^[\da-f]{64}$/u.test(buildId) || protocol !== NATIVE_PROTOCOL) {
53
48
  continue;
54
49
  }
55
- return { buildId, capture, directory, helper };
50
+ return { buildId, capture };
56
51
  } catch {
57
52
  // Try the other supported Homebrew prefix.
58
53
  }
@@ -60,22 +55,14 @@ async function resolveNativeInstall(params: {
60
55
  throw new Error(`Compatible FaceTime native helpers are not installed. Run: ${INSTALL_COMMAND}`);
61
56
  }
62
57
 
63
- export async function inspectFaceTimeNativePackage(
64
- params: {
65
- access?: typeof access;
66
- readFile?: typeof readFile;
67
- } = {},
68
- ): Promise<boolean> {
69
- return await resolveNativeInstall(params).then(
58
+ export async function inspectFaceTimeNativePackage(): Promise<boolean> {
59
+ return await resolveNativeInstall().then(
70
60
  () => true,
71
61
  () => false,
72
62
  );
73
63
  }
74
64
 
75
- export async function inspectFaceTimeArtifacts(params: {
76
- access?: typeof access;
77
- readFile?: typeof readFile;
78
- }): Promise<{
65
+ export async function inspectFaceTimeArtifacts(): Promise<{
79
66
  nativeInstall: boolean;
80
67
  stagedHelper: boolean;
81
68
  helperKey: boolean;
@@ -83,10 +70,9 @@ export async function inspectFaceTimeArtifacts(params: {
83
70
  stagedHelperDylibs: number;
84
71
  cachedDriver: boolean;
85
72
  }> {
86
- const checkAccess = params.access ?? access;
87
73
  const readable = async (file: string, mode: number) => {
88
74
  try {
89
- await checkAccess(file, mode);
75
+ await access(file, mode);
90
76
  return true;
91
77
  } catch {
92
78
  return false;
@@ -112,7 +98,7 @@ export async function inspectFaceTimeArtifacts(params: {
112
98
  stagedHelperDylibs,
113
99
  cachedDriver,
114
100
  ] = await Promise.all([
115
- inspectFaceTimeNativePackage(params),
101
+ inspectFaceTimeNativePackage(),
116
102
  readable(resolveHelperDylib(), constants.R_OK),
117
103
  readable(resolveHelperStateFile("helper-ipc-key"), constants.R_OK),
118
104
  readable(resolveHelperStateFile("helper-build.sha256"), constants.R_OK),
@@ -142,22 +128,15 @@ export async function inspectFaceTimeArtifacts(params: {
142
128
  };
143
129
  }
144
130
 
145
- export async function ensureCaptureBinary(
146
- params: {
147
- access?: typeof access;
148
- readFile?: typeof readFile;
149
- } = {},
150
- ): Promise<string> {
151
- return (await resolveNativeInstall(params)).capture;
131
+ export async function ensureCaptureBinary(): Promise<string> {
132
+ return (await resolveNativeInstall()).capture;
152
133
  }
153
134
 
154
135
  export async function ensureHelperArtifacts(params: {
155
136
  pluginRoot: string;
156
137
  runCommandWithTimeout: PluginRuntime["system"]["runCommandWithTimeout"];
157
- access?: typeof access;
158
- readFile?: typeof readFile;
159
138
  }): Promise<{ buildId: string; dylib: string; ipcKey: string }> {
160
- const installation = await resolveNativeInstall(params);
139
+ const installation = await resolveNativeInstall();
161
140
  const stageScript = resolve(params.pluginRoot, "scripts", "stage-helper.sh");
162
141
  const result = await params.runCommandWithTimeout(["/bin/bash", stageScript, "--if-needed"], {
163
142
  timeoutMs: 120_000,
@@ -167,13 +146,11 @@ export async function ensureHelperArtifacts(params: {
167
146
  `FaceTime native helper staging failed: ${result.stderr || result.stdout || `exit ${result.code}`}`,
168
147
  );
169
148
  }
170
- const checkAccess = params.access ?? access;
171
- const loadFile = params.readFile ?? readFile;
172
149
  const dylib = resolveHelperDylib();
173
- await checkAccess(dylib, constants.R_OK);
174
- const ipcKey = (await loadFile(resolveHelperStateFile("helper-ipc-key"), "utf8")).trim();
150
+ await access(dylib, constants.R_OK);
151
+ const ipcKey = (await readFile(resolveHelperStateFile("helper-ipc-key"), "utf8")).trim();
175
152
  const stagedBuildId = (
176
- await loadFile(resolveHelperStateFile("helper-build.sha256"), "utf8")
153
+ await readFile(resolveHelperStateFile("helper-build.sha256"), "utf8")
177
154
  ).trim();
178
155
  if (!/^[\da-f]{64}$/u.test(ipcKey)) {
179
156
  throw new Error("FaceTime helper produced an invalid IPC authentication key");
package/src/preflight.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import type { OpenClawConfig } from "openclaw/plugin-sdk/config-contracts";
2
2
  import { formatErrorMessage } from "openclaw/plugin-sdk/error-runtime";
3
- import type { PluginRuntime, RuntimeLogger } from "openclaw/plugin-sdk/plugin-runtime";
3
+ import type { PluginRuntime } from "openclaw/plugin-sdk/plugin-runtime";
4
4
  import { asRecord, normalizeOptionalString } from "openclaw/plugin-sdk/string-coerce-runtime";
5
5
  import { FACETIME_FEED_DEVICE_NAME, FACETIME_MIC_DEVICE_NAME } from "./audio-pump.js";
6
6
  import type { FaceTimeConfig } from "./config.js";
@@ -156,7 +156,6 @@ export async function runFaceTimePreflight(params: {
156
156
  config: FaceTimeConfig;
157
157
  fullConfig: OpenClawConfig;
158
158
  runtime: PluginRuntime;
159
- logger?: RuntimeLogger;
160
159
  helperConnected: boolean;
161
160
  captureBinary: string;
162
161
  }): Promise<FaceTimePreflightResult> {