@ateam-ai-mobile/expo 0.1.20 → 0.1.22

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.
Files changed (56) hide show
  1. package/dist/aiLive/provider.d.mts +26 -0
  2. package/dist/aiLive/provider.d.ts +26 -0
  3. package/dist/aiLive/provider.js +476 -0
  4. package/dist/aiLive/provider.js.map +1 -0
  5. package/dist/aiLive/provider.mjs +17 -0
  6. package/dist/aiLive/provider.mjs.map +1 -0
  7. package/dist/bootstrap.js +428 -7
  8. package/dist/bootstrap.js.map +1 -1
  9. package/dist/bootstrap.mjs +12 -8
  10. package/dist/bootstrap.mjs.map +1 -1
  11. package/dist/capabilities/index.d.mts +40 -1
  12. package/dist/capabilities/index.d.ts +40 -1
  13. package/dist/capabilities/index.js +49 -1
  14. package/dist/capabilities/index.js.map +1 -1
  15. package/dist/capabilities/index.mjs +54 -6
  16. package/dist/capabilities/index.mjs.map +1 -1
  17. package/dist/{chunk-42FP5DTO.mjs → chunk-2ZQEQJQ6.mjs} +1 -1
  18. package/dist/chunk-2ZQEQJQ6.mjs.map +1 -0
  19. package/dist/{chunk-KRGCWVDJ.mjs → chunk-4HJ5FO3S.mjs} +2 -2
  20. package/dist/{chunk-RZDAY2GS.mjs → chunk-GGEFDRQQ.mjs} +5 -5
  21. package/dist/chunk-GGEFDRQQ.mjs.map +1 -0
  22. package/dist/{chunk-SOUNJY7R.mjs → chunk-NH3CHSLR.mjs} +10 -10
  23. package/dist/chunk-PV2EHH2P.mjs +426 -0
  24. package/dist/chunk-PV2EHH2P.mjs.map +1 -0
  25. package/dist/{chunk-6JX222YX.mjs → chunk-WQK6PUBN.mjs} +9 -2
  26. package/dist/chunk-WQK6PUBN.mjs.map +1 -0
  27. package/dist/device/createDeviceProvider.js.map +1 -1
  28. package/dist/device/createDeviceProvider.mjs +6 -6
  29. package/dist/device-bridge/index.js +1 -1
  30. package/dist/device-bridge/index.js.map +1 -1
  31. package/dist/device-bridge/index.mjs +3 -3
  32. package/dist/index.js.map +1 -1
  33. package/dist/index.mjs +1 -1
  34. package/dist/push/silentSync.js.map +1 -1
  35. package/dist/push/silentSync.mjs +5 -5
  36. package/dist/vision/index.d.mts +7 -1
  37. package/dist/vision/index.d.ts +7 -1
  38. package/dist/vision/index.js +8 -0
  39. package/dist/vision/index.js.map +1 -1
  40. package/dist/vision/index.mjs +3 -1
  41. package/ios/AdaVisionModule.swift +44 -1
  42. package/package.json +10 -4
  43. package/src/aiLive/provider.ts +331 -0
  44. package/src/aiLive/streamProtocol.ts +90 -0
  45. package/src/bootstrap.ts +7 -1
  46. package/src/capabilities/index.ts +2 -0
  47. package/src/capabilities/picturesToAi.ts +40 -0
  48. package/src/capabilities/store.ts +50 -0
  49. package/src/device-bridge/capabilities.ts +2 -1
  50. package/src/index.ts +3 -0
  51. package/src/vision/index.ts +14 -0
  52. package/dist/chunk-42FP5DTO.mjs.map +0 -1
  53. package/dist/chunk-6JX222YX.mjs.map +0 -1
  54. package/dist/chunk-RZDAY2GS.mjs.map +0 -1
  55. /package/dist/{chunk-KRGCWVDJ.mjs.map → chunk-4HJ5FO3S.mjs.map} +0 -0
  56. /package/dist/{chunk-SOUNJY7R.mjs.map → chunk-NH3CHSLR.mjs.map} +0 -0
@@ -0,0 +1,26 @@
1
+ import { AiLiveProvider } from '@ateam-ai-mobile/plugin-runtime';
2
+
3
+ declare const LIVE_KIND = "ai-models.live";
4
+ interface AiLiveDeps {
5
+ WebSocketImpl: any;
6
+ wsBase(): string;
7
+ token(): string | null;
8
+ tenant(): string | null;
9
+ jpegById(id: string, maxSide: number, quality: number): Promise<string>;
10
+ now(): number;
11
+ setInterval(fn: () => void, ms: number): any;
12
+ clearInterval(handle: any): void;
13
+ setTimeout(fn: () => void, ms: number): any;
14
+ clearTimeout(handle: any): void;
15
+ }
16
+ /** Core answers "opened" in one round trip (it starts the session first). Past this, the start gives up
17
+ * and closes the connection, so a start can never hang a screen's queue. */
18
+ declare const OPEN_TIMEOUT_MS = 20000;
19
+ /** A stop waits this long, at most, for its connection to finish closing: Core ends the session when it
20
+ * sees the close, so a restart right after a stop must not open the next one before (Codex on #53).
21
+ * Past this the transport is taken as broken, and Core's own 60 s rule ends that session. */
22
+ declare const CLOSE_WAIT_MS = 3000;
23
+ declare const defaultAiLiveDeps: () => AiLiveDeps;
24
+ declare function createAiLiveProvider(overrides?: Partial<AiLiveDeps>): AiLiveProvider;
25
+
26
+ export { type AiLiveDeps, CLOSE_WAIT_MS, LIVE_KIND, OPEN_TIMEOUT_MS, createAiLiveProvider, defaultAiLiveDeps };
@@ -0,0 +1,26 @@
1
+ import { AiLiveProvider } from '@ateam-ai-mobile/plugin-runtime';
2
+
3
+ declare const LIVE_KIND = "ai-models.live";
4
+ interface AiLiveDeps {
5
+ WebSocketImpl: any;
6
+ wsBase(): string;
7
+ token(): string | null;
8
+ tenant(): string | null;
9
+ jpegById(id: string, maxSide: number, quality: number): Promise<string>;
10
+ now(): number;
11
+ setInterval(fn: () => void, ms: number): any;
12
+ clearInterval(handle: any): void;
13
+ setTimeout(fn: () => void, ms: number): any;
14
+ clearTimeout(handle: any): void;
15
+ }
16
+ /** Core answers "opened" in one round trip (it starts the session first). Past this, the start gives up
17
+ * and closes the connection, so a start can never hang a screen's queue. */
18
+ declare const OPEN_TIMEOUT_MS = 20000;
19
+ /** A stop waits this long, at most, for its connection to finish closing: Core ends the session when it
20
+ * sees the close, so a restart right after a stop must not open the next one before (Codex on #53).
21
+ * Past this the transport is taken as broken, and Core's own 60 s rule ends that session. */
22
+ declare const CLOSE_WAIT_MS = 3000;
23
+ declare const defaultAiLiveDeps: () => AiLiveDeps;
24
+ declare function createAiLiveProvider(overrides?: Partial<AiLiveDeps>): AiLiveProvider;
25
+
26
+ export { type AiLiveDeps, CLOSE_WAIT_MS, LIVE_KIND, OPEN_TIMEOUT_MS, createAiLiveProvider, defaultAiLiveDeps };
@@ -0,0 +1,476 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/aiLive/provider.ts
21
+ var provider_exports = {};
22
+ __export(provider_exports, {
23
+ CLOSE_WAIT_MS: () => CLOSE_WAIT_MS,
24
+ LIVE_KIND: () => LIVE_KIND,
25
+ OPEN_TIMEOUT_MS: () => OPEN_TIMEOUT_MS,
26
+ createAiLiveProvider: () => createAiLiveProvider,
27
+ defaultAiLiveDeps: () => defaultAiLiveDeps
28
+ });
29
+ module.exports = __toCommonJS(provider_exports);
30
+ var import_core = require("@ateam-ai-mobile/core");
31
+ var import_plugin_runtime = require("@ateam-ai-mobile/plugin-runtime");
32
+
33
+ // src/vision/index.ts
34
+ var import_expo_modules_core = require("expo-modules-core");
35
+ var import_expo = require("expo");
36
+ var CameraPreview = (() => {
37
+ try {
38
+ return (0, import_expo.requireNativeView)("AdaVision");
39
+ } catch {
40
+ return null;
41
+ }
42
+ })();
43
+ var native = (0, import_expo_modules_core.requireOptionalNativeModule)("AdaVision");
44
+ function verb(name) {
45
+ if (!native) throw new Error("ada-vision native module not present in this build");
46
+ const fn = native[name];
47
+ if (typeof fn !== "function") {
48
+ throw Object.assign(new Error(`UNAVAILABLE: ada-vision ${String(name)} is not implemented on this platform (iOS only)`), { code: "UNAVAILABLE" });
49
+ }
50
+ return fn.bind(native);
51
+ }
52
+ async function jpegById(id, maxSide = 768, quality = 0.7) {
53
+ if (native && typeof native.jpegById !== "function") {
54
+ throw new Error("sending pictures to AI needs a newer app build \u2014 this one cannot make a picture from a camera frame");
55
+ }
56
+ return verb("jpegById")(id, maxSide, quality);
57
+ }
58
+
59
+ // src/aiLive/streamProtocol.ts
60
+ var STREAM_PATH = "/ws/stream";
61
+ var SUBPROTOCOL = "adas.v1";
62
+ var HEADER_BYTES = 14;
63
+ var ENVELOPE_VERSION = 1;
64
+ var CLOSE = Object.freeze({
65
+ AUTH_MISSING: 4001,
66
+ AUTH_FAILED: 4002,
67
+ NO_SUCH_WORKSPACE: 4003,
68
+ NOT_ENTITLED: 4004,
69
+ BAD_REQUEST: 4400,
70
+ UNKNOWN_KIND: 4404,
71
+ TIMEOUT: 4408,
72
+ OVER_LIMIT: 4429,
73
+ TOO_BIG: 1009,
74
+ CONSUMER_FAILING: 1011
75
+ });
76
+ function encodeFrame({ seq, tCapture, payload }) {
77
+ const out = new Uint8Array(HEADER_BYTES + payload.length);
78
+ const v = new DataView(out.buffer);
79
+ v.setUint8(0, ENVELOPE_VERSION);
80
+ v.setUint8(1, 0);
81
+ v.setUint32(2, seq >>> 0, false);
82
+ v.setFloat64(6, tCapture, false);
83
+ out.set(payload, HEADER_BYTES);
84
+ return out;
85
+ }
86
+ function openMessage(kind, params) {
87
+ return JSON.stringify(params ? { type: "open", kind, params } : { type: "open", kind });
88
+ }
89
+ var CLOSE_MESSAGE = JSON.stringify({ type: "close" });
90
+ function parseServerEvent(text) {
91
+ if (typeof text !== "string") return null;
92
+ try {
93
+ const m = JSON.parse(text);
94
+ return m && typeof m.event === "string" ? { event: m.event, data: m.data } : null;
95
+ } catch {
96
+ return null;
97
+ }
98
+ }
99
+ var WHY = {
100
+ [CLOSE.AUTH_MISSING]: "The login or the workspace was missing. Sign in again and try once more.",
101
+ [CLOSE.AUTH_FAILED]: "The login was refused. Sign in again and try once more.",
102
+ [CLOSE.NO_SUCH_WORKSPACE]: "This workspace was not found.",
103
+ [CLOSE.NOT_ENTITLED]: "This workspace may not stream right now.",
104
+ [CLOSE.TIMEOUT]: "The connection to the AI timed out.",
105
+ [CLOSE.OVER_LIMIT]: "Too many cameras are sending to this workspace. Stop another one first.",
106
+ [CLOSE.TOO_BIG]: "A picture was too big to send.",
107
+ [CLOSE.CONSUMER_FAILING]: "The AI stopped taking pictures. Check the live session in AI Models."
108
+ };
109
+ function describeClose(code, reason) {
110
+ if (code === CLOSE.BAD_REQUEST && reason) return reason;
111
+ return WHY[code] || (reason ? reason : `The connection to the AI closed (${code}).`);
112
+ }
113
+ var B64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
114
+ var B64_INDEX = (() => {
115
+ const t = new Int16Array(256).fill(-1);
116
+ for (let i = 0; i < 64; i++) t[B64.charCodeAt(i)] = i;
117
+ return t;
118
+ })();
119
+ function base64ToBytes(b64) {
120
+ const clean = b64.replace(/[^A-Za-z0-9+/]/g, "");
121
+ const out = new Uint8Array(Math.floor(clean.length * 3 / 4));
122
+ let o = 0, acc = 0, bits = 0;
123
+ for (let i = 0; i < clean.length; i++) {
124
+ acc = acc << 6 | B64_INDEX[clean.charCodeAt(i)];
125
+ bits += 6;
126
+ if (bits >= 8) {
127
+ bits -= 8;
128
+ out[o++] = acc >> bits & 255;
129
+ }
130
+ }
131
+ return o === out.length ? out : out.subarray(0, o);
132
+ }
133
+
134
+ // src/aiLive/provider.ts
135
+ var LIVE_KIND = "ai-models.live";
136
+ var FRESH_MS = 3e3;
137
+ var MAX_BUFFERED = 512 * 1024;
138
+ var DEFAULT_CAMERA = { fps: 1, maxPx: 768 };
139
+ var OPEN_TIMEOUT_MS = 2e4;
140
+ var CLOSE_WAIT_MS = 3e3;
141
+ var isEpisode = (d) => !!d && typeof d === "object" && typeof d.type === "string" && typeof d.class === "string" && typeof d.episodeId === "string" && typeof d.actorId === "string" && d.actorId.length > 0 && Number.isFinite(d.at);
142
+ var defaultAiLiveDeps = () => ({
143
+ WebSocketImpl: globalThis.WebSocket,
144
+ wsBase: import_core.getCoreWsUrl,
145
+ token: import_core.getToken,
146
+ tenant: import_core.getTenant,
147
+ jpegById,
148
+ now: Date.now,
149
+ setInterval: (fn, ms) => setInterval(fn, ms),
150
+ clearInterval: (h) => clearInterval(h),
151
+ setTimeout: (fn, ms) => setTimeout(fn, ms),
152
+ clearTimeout: (h) => clearTimeout(h)
153
+ });
154
+ var idle = () => ({ state: "idle", camera: null, sent: 0, skipped: 0, lastEpisode: null, lastError: null });
155
+ function createAiLiveProvider(overrides = {}) {
156
+ const deps = { ...defaultAiLiveDeps(), ...overrides };
157
+ let owner = null;
158
+ let snap = idle();
159
+ let ws = null;
160
+ let loop = null;
161
+ let visual = null;
162
+ let allowed = () => false;
163
+ let stopReason = null;
164
+ let tearingDown = null;
165
+ const waitingToStart = /* @__PURE__ */ new Map();
166
+ const closedOf = /* @__PURE__ */ new WeakMap();
167
+ let closingOnPurpose = false;
168
+ let seq = 0;
169
+ let busy = false;
170
+ let gen = 0;
171
+ let lastFrameId = null;
172
+ let camera = DEFAULT_CAMERA;
173
+ let lastOwner = null;
174
+ const episodeCbs = /* @__PURE__ */ new Map();
175
+ const snapCbs = /* @__PURE__ */ new Map();
176
+ const sendingCbs = /* @__PURE__ */ new Set();
177
+ let wasSending = false;
178
+ const add = (m, who, cb) => {
179
+ let set2 = m.get(who);
180
+ if (!set2) {
181
+ set2 = /* @__PURE__ */ new Set();
182
+ m.set(who, set2);
183
+ }
184
+ set2.add(cb);
185
+ return { unsubscribe: () => {
186
+ set2.delete(cb);
187
+ } };
188
+ };
189
+ const set = (patch) => {
190
+ snap = { ...snap, ...patch };
191
+ for (const cb of lastOwner && snapCbs.get(lastOwner) || []) {
192
+ try {
193
+ cb(snap);
194
+ } catch {
195
+ }
196
+ }
197
+ const sending = snap.state === "starting" || snap.state === "sending";
198
+ if (sending !== wasSending) {
199
+ wasSending = sending;
200
+ for (const cb of sendingCbs) {
201
+ try {
202
+ cb();
203
+ } catch {
204
+ }
205
+ }
206
+ }
207
+ };
208
+ function stopTimers() {
209
+ if (loop != null) {
210
+ deps.clearInterval(loop);
211
+ loop = null;
212
+ }
213
+ }
214
+ async function slot() {
215
+ const mySeq = seq++;
216
+ const g = gen;
217
+ const sock = ws;
218
+ const current = () => g === gen && ws === sock && sock?.readyState === 1;
219
+ const consentGone = () => {
220
+ if (allowed()) return false;
221
+ if (g === gen) void teardown("stopped", import_plugin_runtime.CONSENT_TAKEN_BACK);
222
+ return true;
223
+ };
224
+ if (consentGone()) return;
225
+ if (busy || !current()) {
226
+ set({ skipped: snap.skipped + 1 });
227
+ return;
228
+ }
229
+ if ((sock.bufferedAmount || 0) > MAX_BUFFERED) {
230
+ set({ skipped: snap.skipped + 1 });
231
+ return;
232
+ }
233
+ busy = true;
234
+ try {
235
+ const v = await visual.getSnapshot();
236
+ if (!current()) return;
237
+ const f = v?.latest;
238
+ const id = f?.handle?.id;
239
+ const t = Number(f?.timestamp);
240
+ if (!id || id === lastFrameId || !(deps.now() - t < FRESH_MS)) {
241
+ set({ skipped: snap.skipped + 1 });
242
+ return;
243
+ }
244
+ const b64 = await deps.jpegById(id, camera.maxPx, 0.7);
245
+ if (!current() || consentGone()) return;
246
+ const frame = encodeFrame({ seq: mySeq, tCapture: t, payload: base64ToBytes(b64) });
247
+ sock.send(frame.buffer);
248
+ lastFrameId = id;
249
+ set({ sent: snap.sent + 1 });
250
+ } catch (e) {
251
+ if (g === gen) set({ skipped: snap.skipped + 1, lastError: String(e?.message || e) });
252
+ } finally {
253
+ if (g === gen) busy = false;
254
+ }
255
+ }
256
+ function openSocket() {
257
+ return new Promise((resolve, reject) => {
258
+ const token = deps.token();
259
+ const tenant = deps.tenant();
260
+ if (!token || !tenant) {
261
+ reject(new Error("not signed in to a workspace"));
262
+ return;
263
+ }
264
+ const url = `${deps.wsBase()}${STREAM_PATH}?tenant=${encodeURIComponent(tenant)}`;
265
+ let opened = false;
266
+ const sock = new deps.WebSocketImpl(url, [SUBPROTOCOL, `adas.bearer.${token}`]);
267
+ ws = sock;
268
+ sock.binaryType = "arraybuffer";
269
+ let markClosed = () => {
270
+ };
271
+ closedOf.set(sock, new Promise((r) => {
272
+ markClosed = r;
273
+ }));
274
+ const gaveUp = deps.setTimeout(() => {
275
+ if (opened) return;
276
+ reject(new Error("Core did not answer in time. Try again."));
277
+ try {
278
+ sock.close();
279
+ } catch {
280
+ }
281
+ }, OPEN_TIMEOUT_MS);
282
+ sock.onopen = () => {
283
+ try {
284
+ sock.send(openMessage(LIVE_KIND, { session: "own", source: "phone" }));
285
+ } catch (e) {
286
+ reject(e);
287
+ }
288
+ };
289
+ sock.onmessage = (m) => {
290
+ if (ws !== sock) return;
291
+ const ev = parseServerEvent(m?.data);
292
+ if (!ev) return;
293
+ if (ev.event === "session" && !opened) {
294
+ const c = ev.data?.camera;
295
+ camera = c && Number(c.fps) > 0 && Number(c.maxPx) > 0 ? { fps: Number(c.fps), maxPx: Number(c.maxPx) } : DEFAULT_CAMERA;
296
+ return;
297
+ }
298
+ if (ev.event === "opened" && !opened) {
299
+ opened = true;
300
+ deps.clearTimeout(gaveUp);
301
+ resolve();
302
+ return;
303
+ }
304
+ if (ev.event === "episode" && isEpisode(ev.data)) {
305
+ const episode = ev.data;
306
+ set({ lastEpisode: episode });
307
+ for (const cb of owner && episodeCbs.get(owner) || []) {
308
+ try {
309
+ cb(episode);
310
+ } catch {
311
+ }
312
+ }
313
+ }
314
+ };
315
+ sock.onerror = () => {
316
+ };
317
+ sock.onclose = (c) => {
318
+ markClosed();
319
+ const why = describeClose(Number(c?.code), c?.reason);
320
+ if (!opened) {
321
+ deps.clearTimeout(gaveUp);
322
+ reject(new Error(why));
323
+ return;
324
+ }
325
+ if (closingOnPurpose || ws !== sock) return;
326
+ void teardown("error", why);
327
+ };
328
+ });
329
+ }
330
+ function teardown(state, lastError) {
331
+ if (tearingDown) return tearingDown;
332
+ const p = teardownNow(state, lastError);
333
+ tearingDown = p;
334
+ void p.then(() => {
335
+ }, () => {
336
+ }).then(() => {
337
+ if (tearingDown === p) tearingDown = null;
338
+ });
339
+ return p;
340
+ }
341
+ async function teardownNow(state, lastError) {
342
+ stopReason = lastError;
343
+ allowed = () => false;
344
+ gen++;
345
+ stopTimers();
346
+ const sock = ws;
347
+ ws = null;
348
+ closingOnPurpose = true;
349
+ try {
350
+ if (sock && sock.readyState === 1) sock.send(CLOSE_MESSAGE);
351
+ } catch {
352
+ }
353
+ try {
354
+ sock?.close?.();
355
+ } catch {
356
+ }
357
+ closingOnPurpose = false;
358
+ const v = visual;
359
+ visual = null;
360
+ let gaveUp = null;
361
+ const closed = sock && closedOf.get(sock);
362
+ await Promise.all([
363
+ (async () => {
364
+ try {
365
+ await v?.stop?.();
366
+ } catch {
367
+ }
368
+ })(),
369
+ closed ? Promise.race([closed, new Promise((r) => {
370
+ gaveUp = deps.setTimeout(r, CLOSE_WAIT_MS);
371
+ })]) : Promise.resolve()
372
+ ]);
373
+ if (gaveUp != null) deps.clearTimeout(gaveUp);
374
+ owner = null;
375
+ set({ state, lastError });
376
+ }
377
+ return {
378
+ async start(opts, who, ctx) {
379
+ if (tearingDown) {
380
+ const wait = { cancelled: false };
381
+ waitingToStart.set(who, wait);
382
+ try {
383
+ while (tearingDown) {
384
+ try {
385
+ await tearingDown;
386
+ } catch {
387
+ }
388
+ }
389
+ } finally {
390
+ if (waitingToStart.get(who) === wait) waitingToStart.delete(who);
391
+ }
392
+ if (wait.cancelled) throw Object.assign(new Error("aiLive: stopped before it started."), { code: "STOPPED" });
393
+ }
394
+ if (owner && owner !== who) throw Object.assign(new Error("aiLive: another screen is sending to AI right now. Close it first."), { code: "CONFLICT" });
395
+ if (owner === who) return snap;
396
+ const cam = opts?.camera === "front" ? "front" : "back";
397
+ if (opts?.camera && opts.camera !== "front" && opts.camera !== "back") throw new Error(`aiLive: unknown camera "${String(opts.camera)}" \u2014 use "front" or "back"`);
398
+ owner = who;
399
+ lastOwner = who;
400
+ visual = ctx.visual;
401
+ allowed = typeof ctx.allowed === "function" ? ctx.allowed : () => false;
402
+ gen++;
403
+ seq = 0;
404
+ lastFrameId = null;
405
+ busy = false;
406
+ const g = gen;
407
+ const cameraOfScreen = ctx.visual;
408
+ snap = { ...idle(), camera: cam };
409
+ set({ state: "starting" });
410
+ const stillStarting = async () => {
411
+ if (g === gen && !allowed()) await teardown("stopped", import_plugin_runtime.CONSENT_TAKEN_BACK);
412
+ if (g !== gen) throw Object.assign(new Error(stopReason || "aiLive: stopped before it started sending."), { code: "STOPPED" });
413
+ };
414
+ try {
415
+ await stillStarting();
416
+ camera = DEFAULT_CAMERA;
417
+ if (g !== gen) throw Object.assign(new Error(stopReason || "aiLive: stopped before it started sending."), { code: "STOPPED" });
418
+ await openSocket();
419
+ await stillStarting();
420
+ await cameraOfScreen.start({ intent: "stream", facing: cam });
421
+ if (g !== gen) {
422
+ try {
423
+ await cameraOfScreen.stop?.();
424
+ } catch {
425
+ }
426
+ }
427
+ await stillStarting();
428
+ if (g !== gen) throw Object.assign(new Error(stopReason || "aiLive: stopped before it started sending."), { code: "STOPPED" });
429
+ loop = deps.setInterval(() => {
430
+ void slot();
431
+ }, Math.max(200, Math.round(1e3 / camera.fps)));
432
+ set({ state: "sending" });
433
+ return snap;
434
+ } catch (e) {
435
+ if (g !== gen) {
436
+ throw e?.code === "STOPPED" ? e : Object.assign(new Error(stopReason || "aiLive: stopped before it started sending."), { code: "STOPPED" });
437
+ }
438
+ await teardown("error", String(e?.message || e));
439
+ throw e;
440
+ }
441
+ },
442
+ async stop(who, why) {
443
+ const waiting = waitingToStart.get(who);
444
+ if (waiting) waiting.cancelled = true;
445
+ if (owner !== who) return;
446
+ await teardown("stopped", why ?? null);
447
+ },
448
+ getSnapshot: (who) => lastOwner === who ? snap : idle(),
449
+ onEpisode: (cb, who) => add(episodeCbs, who, cb),
450
+ subscribe: (cb, who) => add(snapCbs, who, cb),
451
+ forget(who) {
452
+ episodeCbs.delete(who);
453
+ snapCbs.delete(who);
454
+ if (lastOwner === who && owner === null) {
455
+ lastOwner = null;
456
+ snap = idle();
457
+ }
458
+ },
459
+ isSending: () => snap.state === "starting" || snap.state === "sending",
460
+ subscribeSending(cb) {
461
+ sendingCbs.add(cb);
462
+ return { unsubscribe: () => {
463
+ sendingCbs.delete(cb);
464
+ } };
465
+ }
466
+ };
467
+ }
468
+ // Annotate the CommonJS export names for ESM import in node:
469
+ 0 && (module.exports = {
470
+ CLOSE_WAIT_MS,
471
+ LIVE_KIND,
472
+ OPEN_TIMEOUT_MS,
473
+ createAiLiveProvider,
474
+ defaultAiLiveDeps
475
+ });
476
+ //# sourceMappingURL=provider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/aiLive/provider.ts","../../src/vision/index.ts","../../src/aiLive/streamProtocol.ts"],"sourcesContent":["/**\n * The AI live provider: this phone's camera → the workspace's live session → the chosen AI,\n * and what the AI saw back to the screen. Installed by the host once at startup:\n * import { createAiLiveProvider } from '@ateam-ai-mobile/expo/ai-live';\n * setAiLiveProvider(createAiLiveProvider());\n * A plugin reaches it only through props.aiLive,\n * whose gate (plugin-runtime aiLiveHost) has already checked the two-sided consent. The gate\n * passes that check as ctx.allowed, and it is asked again right before every picture: once the\n * person takes the yes back, nothing more is sent and the session stops (GPT review 2026-10-30).\n *\n * One camera, one sender: while one screen sends, another's start() is refused by name.\n *\n * ONE CONNECTION IS THE SESSION (owner direction 2026-10-30). start():\n * 1. opens Core's stream endpoint (/ws/stream, kind \"ai-models.live\", the login in the\n * subprotocol) asking for a session of its own (params.session \"own\"). That one round trip\n * IS starting the person's live session: Core starts it with its own $0.50 cap, refuses in\n * plain words when the person already has one running (never joins), and says how to send\n * ({\"event\":\"session\"}: the rate and size the setup was tested at) before \"opened\";\n * 2. turns on the screen's held camera on the requested side;\n * 3. sends one picture per slot at that rate and size, from the newest fresh frame, as a JPEG\n * made by native (jpegById). A slot with no fresh frame, or while the socket is still busy,\n * sends nothing and still takes its sequence number, so Core reports it as a gap;\n * 4. {\"event\":\"episode\"} from Core → the screen's onEpisode callbacks.\n * stop() closes the connection and the camera; Core ends the session when the connection ends,\n * whatever ended it (a stop, the screen closing, the app killed, the network lost).\n */\nimport { getCoreWsUrl, getTenant, getToken } from '@ateam-ai-mobile/core';\nimport { CONSENT_TAKEN_BACK } from '@ateam-ai-mobile/plugin-runtime';\nimport type { AiLiveEpisode, AiLiveProvider, AiLiveSnapshot, AiLiveStartOptions, DeviceState, Subscription } from '@ateam-ai-mobile/plugin-runtime';\nimport { jpegById as nativeJpegById } from '../vision';\nimport { CLOSE_MESSAGE, STREAM_PATH, SUBPROTOCOL, base64ToBytes, describeClose, encodeFrame, openMessage, parseServerEvent } from './streamProtocol';\n\nexport const LIVE_KIND = 'ai-models.live';\n/** A frame older than this is not \"what the camera sees now\" and is not sent. */\nconst FRESH_MS = 3000;\n/** Bytes still waiting in the socket above which a slot is skipped rather than queued. */\nconst MAX_BUFFERED = 512 * 1024;\nconst DEFAULT_CAMERA = { fps: 1, maxPx: 768 };\n\ntype Visual = DeviceState['visual'];\n\nexport interface AiLiveDeps {\n WebSocketImpl: any;\n wsBase(): string;\n token(): string | null;\n tenant(): string | null;\n jpegById(id: string, maxSide: number, quality: number): Promise<string>;\n now(): number;\n setInterval(fn: () => void, ms: number): any;\n clearInterval(handle: any): void;\n setTimeout(fn: () => void, ms: number): any;\n clearTimeout(handle: any): void;\n}\n\n/** Core answers \"opened\" in one round trip (it starts the session first). Past this, the start gives up\n * and closes the connection, so a start can never hang a screen's queue. */\nexport const OPEN_TIMEOUT_MS = 20_000;\n/** A stop waits this long, at most, for its connection to finish closing: Core ends the session when it\n * sees the close, so a restart right after a stop must not open the next one before (Codex on #53).\n * Past this the transport is taken as broken, and Core's own 60 s rule ends that session. */\nexport const CLOSE_WAIT_MS = 3_000;\n\nconst isEpisode = (d: any): d is AiLiveEpisode =>\n !!d && typeof d === 'object' && typeof d.type === 'string' && typeof d.class === 'string' &&\n typeof d.episodeId === 'string' && typeof d.actorId === 'string' && d.actorId.length > 0 && Number.isFinite(d.at);\n\nexport const defaultAiLiveDeps = (): AiLiveDeps => ({\n WebSocketImpl: (globalThis as any).WebSocket,\n wsBase: getCoreWsUrl,\n token: getToken,\n tenant: getTenant,\n jpegById: nativeJpegById,\n now: Date.now,\n setInterval: (fn, ms) => setInterval(fn, ms),\n clearInterval: (h) => clearInterval(h),\n setTimeout: (fn, ms) => setTimeout(fn, ms),\n clearTimeout: (h) => clearTimeout(h),\n});\n\nconst idle = (): AiLiveSnapshot => ({ state: 'idle', camera: null, sent: 0, skipped: 0, lastEpisode: null, lastError: null });\n\nexport function createAiLiveProvider(overrides: Partial<AiLiveDeps> = {}): AiLiveProvider {\n const deps: AiLiveDeps = { ...defaultAiLiveDeps(), ...overrides };\n let owner: string | null = null; // the screen sending now\n let snap: AiLiveSnapshot = idle();\n let ws: any = null;\n let loop: any = null;\n let visual: Visual | null = null;\n let allowed: () => boolean = () => false; // the two-sided consent, asked before every picture\n let stopReason: string | null = null; // why the last teardown happened, known before it finishes\n // A teardown still finishing (the camera, the connection): a start waits for it, so a quick restart neither\n // reads the old session as its own nor is cleared by it afterwards (Codex on #53). Every teardown is\n // tracked, the ones the provider starts itself (consent gone, the connection dropped) included.\n let tearingDown: Promise<void> | null = null;\n // Screens whose start is waiting for that teardown, before they own anything: a stop meanwhile cancels\n // the start (it would otherwise go ahead after the screen had stopped or closed; Codex on #53).\n const waitingToStart = new Map<string, { cancelled: boolean }>();\n /** Each connection's \"it has closed\": a stop waits for it (CLOSE_WAIT_MS at most). */\n const closedOf = new WeakMap<object, Promise<void>>();\n let closingOnPurpose = false;\n let seq = 0;\n let busy = false;\n // Which session a slot belongs to. A slot awaits the camera and the JPEG maker; when the screen\n // stops (or another starts) meanwhile, that slot's picture must go nowhere, not into the next one.\n let gen = 0;\n let lastFrameId: string | null = null;\n let camera = DEFAULT_CAMERA;\n let lastOwner: string | null = null; // whose the current snapshot is (it outlives a stop)\n // Each screen hears only its own session: callbacks are kept per holder.\n const episodeCbs = new Map<string, Set<(ev: AiLiveEpisode) => void>>();\n const snapCbs = new Map<string, Set<(s: AiLiveSnapshot) => void>>();\n const sendingCbs = new Set<() => void>();\n let wasSending = false;\n const add = <T>(m: Map<string, Set<T>>, who: string, cb: T): Subscription => {\n let set = m.get(who);\n if (!set) { set = new Set(); m.set(who, set); }\n set.add(cb);\n return { unsubscribe: () => { set!.delete(cb); } };\n };\n\n const set = (patch: Partial<AiLiveSnapshot>) => {\n snap = { ...snap, ...patch };\n for (const cb of (lastOwner && snapCbs.get(lastOwner)) || []) { try { cb(snap); } catch { /* a listener's error is its own */ } }\n const sending = snap.state === 'starting' || snap.state === 'sending';\n if (sending !== wasSending) { wasSending = sending; for (const cb of sendingCbs) { try { cb(); } catch { /* idem */ } } }\n };\n\n function stopTimers() {\n if (loop != null) { deps.clearInterval(loop); loop = null; }\n }\n\n async function slot() {\n const mySeq = seq++; // every slot takes a number, sent or not\n const g = gen;\n const sock = ws;\n const current = () => g === gen && ws === sock && sock?.readyState === 1;\n const consentGone = () => { if (allowed()) return false; if (g === gen) void teardown('stopped', CONSENT_TAKEN_BACK); return true; };\n if (consentGone()) return;\n if (busy || !current()) { set({ skipped: snap.skipped + 1 }); return; }\n if ((sock.bufferedAmount || 0) > MAX_BUFFERED) { set({ skipped: snap.skipped + 1 }); return; }\n busy = true;\n try {\n const v = await visual!.getSnapshot();\n if (!current()) return;\n const f: any = v?.latest;\n const id = f?.handle?.id;\n const t = Number(f?.timestamp);\n if (!id || id === lastFrameId || !(deps.now() - t < FRESH_MS)) { set({ skipped: snap.skipped + 1 }); return; }\n const b64 = await deps.jpegById(id, camera.maxPx, 0.7);\n if (!current() || consentGone()) return;\n const frame = encodeFrame({ seq: mySeq, tCapture: t, payload: base64ToBytes(b64) });\n sock.send(frame.buffer);\n lastFrameId = id;\n set({ sent: snap.sent + 1 });\n } catch (e: any) {\n if (g === gen) set({ skipped: snap.skipped + 1, lastError: String(e?.message || e) });\n } finally {\n if (g === gen) busy = false;\n }\n }\n\n function openSocket(): Promise<void> {\n return new Promise((resolve, reject) => {\n const token = deps.token();\n const tenant = deps.tenant();\n if (!token || !tenant) { reject(new Error('not signed in to a workspace')); return; }\n const url = `${deps.wsBase()}${STREAM_PATH}?tenant=${encodeURIComponent(tenant)}`;\n let opened = false;\n const sock = new deps.WebSocketImpl(url, [SUBPROTOCOL, `adas.bearer.${token}`]);\n ws = sock;\n sock.binaryType = 'arraybuffer';\n let markClosed: () => void = () => {};\n closedOf.set(sock, new Promise<void>((r) => { markClosed = r; }));\n const gaveUp = deps.setTimeout(() => {\n if (opened) return;\n reject(new Error('Core did not answer in time. Try again.'));\n try { sock.close(); } catch { /* closing anyway */ }\n }, OPEN_TIMEOUT_MS);\n // Its own session: opening IS starting it, and Core ends it when this connection ends.\n sock.onopen = () => { try { sock.send(openMessage(LIVE_KIND, { session: 'own', source: 'phone' })); } catch (e) { reject(e); } };\n sock.onmessage = (m: any) => {\n // Only the current connection speaks for the current session. A message from a connection\n // already stopped or replaced (it can still be queued after a stop, a restart or a switch to\n // another screen) is dropped whole: its episode never reaches a newer screen, and its \"session\"\n // or \"opened\" never touches a newer connection (GPT code review v5).\n if (ws !== sock) return;\n const ev = parseServerEvent(m?.data);\n if (!ev) return;\n if (ev.event === 'session' && !opened) {\n const c = ev.data?.camera;\n camera = c && Number(c.fps) > 0 && Number(c.maxPx) > 0 ? { fps: Number(c.fps), maxPx: Number(c.maxPx) } : DEFAULT_CAMERA;\n return;\n }\n if (ev.event === 'opened' && !opened) { opened = true; deps.clearTimeout(gaveUp); resolve(); return; }\n // Only a whole episode reaches the screen: what happened, of which class, and whose camera saw it\n // (actorId: live sessions are per person). Anything less is dropped, never passed on half-made.\n if (ev.event === 'episode' && isEpisode(ev.data)) {\n const episode = ev.data;\n set({ lastEpisode: episode });\n for (const cb of (owner && episodeCbs.get(owner)) || []) { try { cb(episode); } catch { /* a listener's error is its own */ } }\n }\n };\n sock.onerror = () => { /* the close that follows says why */ };\n sock.onclose = (c: any) => {\n markClosed();\n const why = describeClose(Number(c?.code), c?.reason);\n if (!opened) { deps.clearTimeout(gaveUp); reject(new Error(why)); return; }\n if (closingOnPurpose || ws !== sock) return;\n void teardown('error', why);\n };\n });\n }\n\n function teardown(state: 'stopped' | 'error', lastError: string | null): Promise<void> {\n // One at a time: a second stop while one is finishing joins it (Codex on #53). Two at once could\n // finish out of order and the first, resuming late, would stop a session started in between.\n if (tearingDown) return tearingDown;\n const p = teardownNow(state, lastError);\n tearingDown = p;\n void p.then(() => {}, () => {}).then(() => { if (tearingDown === p) tearingDown = null; });\n return p;\n }\n\n // Closing the connection ends the session (Core); the camera is this phone's to stop.\n async function teardownNow(state: 'stopped' | 'error', lastError: string | null) {\n stopReason = lastError;\n allowed = () => false;\n gen++;\n stopTimers();\n const sock = ws;\n ws = null;\n closingOnPurpose = true;\n try { if (sock && sock.readyState === 1) sock.send(CLOSE_MESSAGE); } catch { /* closing anyway */ }\n try { sock?.close?.(); } catch { /* already closed */ }\n closingOnPurpose = false;\n const v = visual;\n visual = null;\n // The camera off, and the connection really closed (so Core has ended its session) before this stop\n // is done: a start right after it then never meets the old session (Codex on #53).\n let gaveUp: any = null;\n const closed = sock && closedOf.get(sock);\n await Promise.all([\n (async () => { try { await v?.stop?.(); } catch { /* the camera hold is released by the gate too */ } })(),\n closed ? Promise.race([closed, new Promise<void>((r) => { gaveUp = deps.setTimeout(r, CLOSE_WAIT_MS); })]) : Promise.resolve(),\n ]);\n if (gaveUp != null) deps.clearTimeout(gaveUp);\n owner = null;\n set({ state, lastError });\n }\n\n return {\n async start(opts: AiLiveStartOptions, who: string, ctx: { visual: Visual; allowed: () => boolean }) {\n if (tearingDown) {\n const wait = { cancelled: false };\n waitingToStart.set(who, wait);\n try {\n while (tearingDown) { try { await tearingDown; } catch { /* it stopped either way */ } }\n } finally {\n if (waitingToStart.get(who) === wait) waitingToStart.delete(who);\n }\n if (wait.cancelled) throw Object.assign(new Error('aiLive: stopped before it started.'), { code: 'STOPPED' });\n }\n if (owner && owner !== who) throw Object.assign(new Error('aiLive: another screen is sending to AI right now. Close it first.'), { code: 'CONFLICT' });\n if (owner === who) return snap;\n const cam = opts?.camera === 'front' ? 'front' : 'back';\n if (opts?.camera && opts.camera !== 'front' && opts.camera !== 'back') throw new Error(`aiLive: unknown camera \"${String(opts.camera)}\" — use \"front\" or \"back\"`);\n owner = who;\n lastOwner = who;\n visual = ctx.visual;\n allowed = typeof ctx.allowed === 'function' ? ctx.allowed : () => false;\n gen++; seq = 0; lastFrameId = null; busy = false;\n const g = gen;\n const cameraOfScreen = ctx.visual;\n snap = { ...idle(), camera: cam };\n set({ state: 'starting' });\n // Starting takes several awaits, and the screen may be stopped, or the yes taken back,\n // during any of them (Codex P1 on #53). After each: a stop already tore it down, so say why\n // and go no further; a yes taken back unannounced tears it down here.\n const stillStarting = async () => {\n if (g === gen && !allowed()) await teardown('stopped', CONSENT_TAKEN_BACK);\n if (g !== gen) throw Object.assign(new Error(stopReason || 'aiLive: stopped before it started sending.'), { code: 'STOPPED' });\n };\n try {\n await stillStarting();\n // One round trip: the connection starts the session (or Core refuses, in its own words), and\n // says how to send. Before the camera, so a refusal never turns the camera on.\n camera = DEFAULT_CAMERA;\n // Checked again with nothing in between: a stop that landed while the check above resolved has\n // already torn this start down, and opening now would start a session nobody closes (Codex on #53).\n if (g !== gen) throw Object.assign(new Error(stopReason || 'aiLive: stopped before it started sending.'), { code: 'STOPPED' });\n await openSocket();\n await stillStarting();\n await cameraOfScreen.start({ intent: 'stream', facing: cam } as any);\n if (g !== gen) { try { await cameraOfScreen.stop?.(); } catch { /* released by the gate too */ } }\n await stillStarting();\n // Again with nothing in between: a stop that landed while the last check resolved must not see\n // pictures start or the state flip back to \"sending\" (Codex on #53).\n if (g !== gen) throw Object.assign(new Error(stopReason || 'aiLive: stopped before it started sending.'), { code: 'STOPPED' });\n loop = deps.setInterval(() => { void slot(); }, Math.max(200, Math.round(1000 / camera.fps)));\n set({ state: 'sending' });\n return snap;\n } catch (e: any) {\n if (g !== gen) {\n // Already torn down by a stop: report why it stopped, not the closed socket.\n throw e?.code === 'STOPPED' ? e : Object.assign(new Error(stopReason || 'aiLive: stopped before it started sending.'), { code: 'STOPPED' });\n }\n await teardown('error', String(e?.message || e));\n throw e;\n }\n },\n async stop(who: string, why?: string) {\n const waiting = waitingToStart.get(who);\n if (waiting) waiting.cancelled = true;\n if (owner !== who) return;\n await teardown('stopped', why ?? null);\n },\n getSnapshot: (who: string) => (lastOwner === who ? snap : idle()),\n onEpisode: (cb, who) => add(episodeCbs, who, cb),\n subscribe: (cb, who) => add(snapCbs, who, cb),\n forget(who: string) {\n episodeCbs.delete(who);\n snapCbs.delete(who);\n if (lastOwner === who && owner === null) { lastOwner = null; snap = idle(); }\n },\n isSending: () => snap.state === 'starting' || snap.state === 'sending',\n subscribeSending(cb) {\n sendingCbs.add(cb);\n return { unsubscribe: () => { sendingCbs.delete(cb); } } as Subscription;\n },\n };\n}\n","// ada-vision — on-device image understanding, our own native code (no camera lib).\n//\n// On-device, frames never leave the phone:\n// assessQuality(uri) — one-shot quality of a LOCAL frame file.\n// startVision()/onVisionFrame — the headless camera session that publishes a\n// timeline frame (id + quality, never pixels) at a\n// cadence; readText/describe/detectObjects resolve\n// a published id ON-DEVICE.\n//\n// The luma math mirrors ./analysis.js (which has the exhaustive unit tests).\n//\n// requireOptionalNativeModule: on a binary WITHOUT the native module, the import\n// is null, isSupported() is false, and the session calls refuse cleanly (no crash).\n\nimport type { ComponentType } from 'react';\nimport { requireOptionalNativeModule } from 'expo-modules-core';\nimport { requireNativeView } from 'expo';\n\n/** TEST-ONLY live preview bound to the same headless session (so a tester can\n * aim). The real Guide runs headless and never mounts this. Null on a binary\n * without the native view, so importing this module never crashes. */\nexport const CameraPreview: ComponentType<any> | null = (() => {\n try { return requireNativeView('AdaVision'); } catch { return null; }\n})();\n\nexport interface RawFrameQuality {\n blur: 'sharp' | 'slight' | 'severe' | 'unknown';\n exposure: 'good' | 'dark' | 'bright' | 'unknown';\n /** true = lens covered; false = clearly not; null = not assessed. */\n obstructed: boolean | null;\n}\n\ninterface Subscription { remove(): void }\n\n/** A published timeline frame from the vision session (metadata only — never\n * pixels; the buffer stays in the native ring, resolved by id). */\nexport interface VisionFrame {\n id: string;\n ts: number;\n expiresAt: number;\n blur: RawFrameQuality['blur'];\n exposure: RawFrameQuality['exposure'];\n obstructed: RawFrameQuality['obstructed'];\n}\n\n/** One OCR result on a frame — matches the SDK's VisionText. */\nexport interface VisionText {\n text: string;\n /** 0..1 recogniser confidence (never a 1.0 filler). */\n confidence: number | null;\n /** Normalised 0..1 box, origin TOP-left, in the UPRIGHT portrait frame (native\n * rotates frames at capture) — x runs from the user's left to their right. */\n box?: { x: number; y: number; width: number; height: number };\n}\n\n/** One classifier label — a vocabulary term, NOT prose. Matches VisionLabel. */\nexport interface VisionLabel {\n label: string;\n confidence: number | null;\n}\n\n/** One detected object — a located item with a box, from the bundled detector. */\nexport interface VisionObject {\n /** Open-Images class name (e.g. \"Car\", \"Traffic light\", \"Building\", \"Person\"). */\n label: string;\n /** 0..1 detector confidence. */\n confidence: number | null;\n /** Normalised 0..1 box, origin TOP-left, in the UPRIGHT portrait frame (native\n * rotates frames at capture) — x runs from the user's left to their right. */\n box?: { x: number; y: number; width: number; height: number };\n}\n\ninterface AdaVisionNative {\n isSupported(): boolean;\n assessQuality(uri: string): Promise<RawFrameQuality>;\n startVision(intervalMs: number): Promise<void>;\n /** Absent from binaries built before the front camera existed. */\n startVisionCamera?(intervalMs: number, facing: VisionFacing): Promise<void>;\n /** Absent from binaries built before AI live existed. A base64 JPEG. */\n jpegById?(id: string, maxSide: number, quality: number): Promise<string>;\n stopVision(): void;\n visionRetentionMs(): number;\n qualityById(id: string): RawFrameQuality | null;\n readText(id: string, languages: string[] | null): Promise<VisionText[]>;\n describe(id: string, maxLabels: number): Promise<VisionLabel[]>;\n detectObjects(id: string, maxItems: number, minConfidence: number): Promise<VisionObject[]>;\n addListener(event: 'visionFrame', cb: (f: VisionFrame) => void): Subscription;\n}\n\nconst native = requireOptionalNativeModule<AdaVisionNative>('AdaVision');\n\n/** The native function, or a refusal by name: Android's AdaVision has assessQuality only\n * (AI Models F4), so a verb it lacks says so instead of failing as \"not a function\". */\nfunction verb<K extends keyof AdaVisionNative>(name: K): AdaVisionNative[K] {\n if (!native) throw new Error('ada-vision native module not present in this build');\n const fn = native[name];\n if (typeof fn !== 'function') {\n throw Object.assign(new Error(`UNAVAILABLE: ada-vision ${String(name)} is not implemented on this platform (iOS only)`), { code: 'UNAVAILABLE' });\n }\n return (fn as Function).bind(native) as AdaVisionNative[K];\n}\n\n/** Is the native vision module present in this binary? */\nexport function isSupported(): boolean {\n try { return native?.isSupported() ?? false; } catch { return false; }\n}\n\n/** One-shot: measure a frame's quality from its LOCAL file. Throws if it cannot look. */\nexport async function assessQuality(uri: string): Promise<RawFrameQuality> {\n if (!native) throw new Error('ada-vision native module not present in this build');\n return native.assessQuality(uri);\n}\n\n// ── Vision session (feeds the Visual Engine) ──\n\n/** Which camera the vision session reads. */\nexport type VisionFacing = 'front' | 'back';\n\n/**\n * Start the vision session on `facing` — publishes a timeline frame every\n * `intervalMs`. The back camera works on every binary; the front camera needs a\n * binary built with it, and an older one REFUSES it rather than quietly reading\n * the back camera instead.\n */\nexport async function startVision(intervalMs = 1000, facing: VisionFacing = 'back'): Promise<void> {\n if (facing !== 'front' && facing !== 'back') {\n throw new Error(`Unknown camera \"${String(facing)}\" — use \"front\" or \"back\"`);\n }\n if (facing === 'back') return verb('startVision')(intervalMs);\n if (native && typeof native.startVisionCamera !== 'function') {\n throw new Error('the front camera needs a newer app build — this one can read the back camera only');\n }\n return verb('startVisionCamera')!(intervalMs, facing);\n}\n\n/** Stop the vision session and release the camera. */\nexport function stopVision(): void {\n native?.stopVision?.();\n}\n\n/** Subscribe to published timeline frames (id + quality + expiry; no pixels). */\nexport function onVisionFrame(cb: (f: VisionFrame) => void): Subscription {\n if (!native) return { remove() {} };\n return native.addListener('visionFrame', cb);\n}\n\n/** How far back the native ring can still resolve a frame id (ms). */\nexport function visionRetentionMs(): number {\n return native?.visionRetentionMs?.() ?? 0;\n}\n\n/** Resolve a published frame id → its measured quality (null if evicted). */\nexport function qualityById(id: string): RawFrameQuality | null {\n return native?.qualityById?.(id) ?? null;\n}\n\n/** On-device OCR on a published frame. [] = looked, no text; throws = couldn't look. */\nexport async function readText(id: string, languages?: string[]): Promise<VisionText[]> {\n return verb('readText')(id, languages ?? null);\n}\n\n/** On-device image classification → labels (not prose). [] = nothing recognised. */\nexport async function describe(id: string, maxLabels = 5): Promise<VisionLabel[]> {\n return verb('describe')(id, maxLabels);\n}\n\n/** On-device object detection (bundled YOLOv8n, Open-Images vocabulary) → located\n * items with boxes. [] = looked, found nothing above `minConfidence`; throws =\n * couldn't look (id aged out, or the model isn't in this build). */\nexport async function detectObjects(id: string, maxItems = 10, minConfidence = 0.25): Promise<VisionObject[]> {\n return verb('detectObjects')(id, maxItems, minConfidence);\n}\n\n/**\n * A published frame as a base64 JPEG, its longer side at most `maxSide`. FOR THE SDK'S AI LIVE SENDER ONLY\n * (aiLive/provider.ts), which calls it after the two-sided \"Pictures to AI\" consent: this is the one way a\n * picture leaves native, and no plugin-facing API reaches it. An older binary refuses by name.\n */\nexport async function jpegById(id: string, maxSide = 768, quality = 0.7): Promise<string> {\n if (native && typeof native.jpegById !== 'function') {\n throw new Error('sending pictures to AI needs a newer app build — this one cannot make a picture from a camera frame');\n }\n return verb('jpegById')!(id, maxSide, quality);\n}\n","/**\n * The wire protocol of Core's binary stream endpoint (/ws/stream), for the AI live sender.\n *\n * A PORT of Core's `packages/media-stream/src/index.js` (@ateam-ai/media-stream, not on npm\n * yet), limited to what a sender needs. The frame bytes are pinned by\n * tests/aiLiveStreamProtocol.test.mjs against the layout that file documents, so a drift is\n * a red test, not a silent mismatch. DEAD — replace with an import of @ateam-ai/media-stream\n * once Core publishes it.\n *\n * Frame envelope (bytes): 0 version (1) · 1 flags · 2-5 seq uint32 BE (one per sampling slot\n * of the SENDER, taken or skipped) · 6-13 tCapture float64 BE (ms since the epoch) · 14- payload.\n */\nexport const STREAM_PATH = '/ws/stream';\nexport const SUBPROTOCOL = 'adas.v1';\nexport const HEADER_BYTES = 14;\nconst ENVELOPE_VERSION = 1;\n\nexport const CLOSE = Object.freeze({\n AUTH_MISSING: 4001,\n AUTH_FAILED: 4002,\n NO_SUCH_WORKSPACE: 4003,\n NOT_ENTITLED: 4004,\n BAD_REQUEST: 4400,\n UNKNOWN_KIND: 4404,\n TIMEOUT: 4408,\n OVER_LIMIT: 4429,\n TOO_BIG: 1009,\n CONSUMER_FAILING: 1011,\n});\n\nexport function encodeFrame({ seq, tCapture, payload }: { seq: number; tCapture: number; payload: Uint8Array }): Uint8Array {\n const out = new Uint8Array(HEADER_BYTES + payload.length);\n const v = new DataView(out.buffer);\n v.setUint8(0, ENVELOPE_VERSION);\n v.setUint8(1, 0);\n v.setUint32(2, seq >>> 0, false);\n v.setFloat64(6, tCapture, false);\n out.set(payload, HEADER_BYTES);\n return out;\n}\n\nexport function openMessage(kind: string, params?: Record<string, unknown>): string {\n return JSON.stringify(params ? { type: 'open', kind, params } : { type: 'open', kind });\n}\n\nexport const CLOSE_MESSAGE = JSON.stringify({ type: 'close' });\n\n/** A server text frame → { event, data }, or null for anything that is not an event. */\nexport function parseServerEvent(text: unknown): { event: string; data: any } | null {\n if (typeof text !== 'string') return null;\n try {\n const m = JSON.parse(text);\n return m && typeof m.event === 'string' ? { event: m.event, data: m.data } : null;\n } catch {\n return null;\n }\n}\n\nconst WHY: Record<number, string> = {\n [CLOSE.AUTH_MISSING]: 'The login or the workspace was missing. Sign in again and try once more.',\n [CLOSE.AUTH_FAILED]: 'The login was refused. Sign in again and try once more.',\n [CLOSE.NO_SUCH_WORKSPACE]: 'This workspace was not found.',\n [CLOSE.NOT_ENTITLED]: 'This workspace may not stream right now.',\n [CLOSE.TIMEOUT]: 'The connection to the AI timed out.',\n [CLOSE.OVER_LIMIT]: 'Too many cameras are sending to this workspace. Stop another one first.',\n [CLOSE.TOO_BIG]: 'A picture was too big to send.',\n [CLOSE.CONSUMER_FAILING]: 'The AI stopped taking pictures. Check the live session in AI Models.',\n};\n\n/** A close as one plain sentence: the server's own words for a refused open. */\nexport function describeClose(code: number, reason?: string): string {\n if (code === CLOSE.BAD_REQUEST && reason) return reason;\n return WHY[code] || (reason ? reason : `The connection to the AI closed (${code}).`);\n}\n\nconst B64 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';\nconst B64_INDEX = (() => { const t = new Int16Array(256).fill(-1); for (let i = 0; i < 64; i++) t[B64.charCodeAt(i)] = i; return t; })();\n\n/** Base64 (the native module's JPEG) → bytes. Ignores padding and line breaks. */\nexport function base64ToBytes(b64: string): Uint8Array {\n const clean = b64.replace(/[^A-Za-z0-9+/]/g, '');\n const out = new Uint8Array(Math.floor((clean.length * 3) / 4));\n let o = 0, acc = 0, bits = 0;\n for (let i = 0; i < clean.length; i++) {\n acc = (acc << 6) | B64_INDEX[clean.charCodeAt(i)];\n bits += 6;\n if (bits >= 8) { bits -= 8; out[o++] = (acc >> bits) & 0xff; }\n }\n return o === out.length ? out : out.subarray(0, o);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA0BA,kBAAkD;AAClD,4BAAmC;;;ACZnC,+BAA4C;AAC5C,kBAAkC;AAK3B,IAAM,iBAA4C,MAAM;AAC7D,MAAI;AAAE,eAAO,+BAAkB,WAAW;AAAA,EAAG,QAAQ;AAAE,WAAO;AAAA,EAAM;AACtE,GAAG;AAkEH,IAAM,aAAS,sDAA6C,WAAW;AAIvE,SAAS,KAAsC,MAA6B;AAC1E,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,oDAAoD;AACjF,QAAM,KAAK,OAAO,IAAI;AACtB,MAA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UT_MS,
14
+ createAiLiveProvider,
15
+ defaultAiLiveDeps
16
+ };
17
+ //# sourceMappingURL=provider.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}