@ateam-ai-mobile/plugin-runtime 0.1.20 → 0.1.21

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.
@@ -141,6 +141,7 @@ import { apiFetchRaw, getTenant as getTenant2 } from "@ateam-ai-mobile/core";
141
141
  // src/sdk/index.ts
142
142
  var sdk_exports = {};
143
143
  __export(sdk_exports, {
144
+ AI_LIVE_IDLE: () => AI_LIVE_IDLE,
144
145
  ActionButton: () => ActionButton,
145
146
  ActivityIndicator: () => ActivityIndicator,
146
147
  Animated: () => Animated,
@@ -213,6 +214,16 @@ function registerService(id, config) {
213
214
  // src/sdk/voice.ts
214
215
  var PLATFORM_VOICE_CALLER = /* @__PURE__ */ Symbol("adas.voice.platform");
215
216
 
217
+ // src/sdk/aiLive.ts
218
+ var AI_LIVE_IDLE = Object.freeze({
219
+ state: "idle",
220
+ camera: null,
221
+ sent: 0,
222
+ skipped: 0,
223
+ lastEpisode: null,
224
+ lastError: null
225
+ });
226
+
216
227
  // src/sdk/device-state.ts
217
228
  var device_state_exports = {};
218
229
  __export(device_state_exports, {
@@ -647,6 +658,19 @@ function setCameraPreviewProvider(Component) {
647
658
  function getCameraPreviewProvider() {
648
659
  return _cameraPreview;
649
660
  }
661
+ var _picturesToAiConsent = null;
662
+ function setPicturesToAiConsentProvider(provider) {
663
+ _picturesToAiConsent = provider;
664
+ }
665
+ function mayPicturesLeavePhone(declared) {
666
+ if (declared?.picturesToAi !== true) return false;
667
+ if (!_picturesToAiConsent) return false;
668
+ try {
669
+ return _picturesToAiConsent() === true;
670
+ } catch {
671
+ return false;
672
+ }
673
+ }
650
674
  var _nativeRegistry = /* @__PURE__ */ new Map();
651
675
  function registerNativePlugin(id, plugin) {
652
676
  _nativeRegistry.set(id, plugin);
@@ -3048,6 +3072,85 @@ function gateVoice(declared, pluginId) {
3048
3072
  );
3049
3073
  }
3050
3074
 
3075
+ // src/aiLiveHost.ts
3076
+ var _provider3 = null;
3077
+ function setAiLiveProvider(provider) {
3078
+ _provider3 = provider || null;
3079
+ }
3080
+ function denial2(why) {
3081
+ return Object.assign(new Error(`aiLive: ${why}`), { code: "RESTRICTED" });
3082
+ }
3083
+ function deniedAiLive(why) {
3084
+ const fail = () => {
3085
+ throw denial2(why);
3086
+ };
3087
+ return {
3088
+ async start() {
3089
+ return fail();
3090
+ },
3091
+ async stop() {
3092
+ },
3093
+ getSnapshot() {
3094
+ return { state: "error", camera: null, sent: 0, skipped: 0, lastEpisode: null, lastError: why };
3095
+ },
3096
+ onEpisode() {
3097
+ return fail();
3098
+ },
3099
+ subscribe() {
3100
+ return fail();
3101
+ }
3102
+ };
3103
+ }
3104
+ var aiLiveCameraHolder = (holder) => `${holder}#aiLive`;
3105
+ function gateAiLive(capabilities, pluginId, holder, camera) {
3106
+ if (capabilities?.picturesToAi !== true) {
3107
+ return deniedAiLive("not declared in this plugin's capabilities. Add `capabilities: { picturesToAi: true }` to send camera pictures to the workspace's chosen AI.");
3108
+ }
3109
+ if (!pluginId || !holder) return deniedAiLive("no plugin identity \u2014 it fails closed without a screen to bind the session to.");
3110
+ if (!_provider3) return deniedAiLive("no live AI in this build \u2014 the app has not called setAiLiveProvider.");
3111
+ const provider = _provider3;
3112
+ return {
3113
+ async start(opts) {
3114
+ if (!mayPicturesLeavePhone(capabilities)) {
3115
+ throw denial2(`the person on this phone has not allowed camera pictures to go to AI. They can turn on "Pictures to AI" in the app's settings (What Ada can access).`);
3116
+ }
3117
+ try {
3118
+ return await provider.start(opts || {}, holder, { visual: camera() });
3119
+ } catch (e) {
3120
+ await releaseDeviceStateHolds(aiLiveCameraHolder(holder));
3121
+ throw e;
3122
+ }
3123
+ },
3124
+ async stop() {
3125
+ try {
3126
+ await provider.stop(holder);
3127
+ } finally {
3128
+ await releaseDeviceStateHolds(aiLiveCameraHolder(holder));
3129
+ }
3130
+ },
3131
+ getSnapshot: () => provider.getSnapshot(holder),
3132
+ onEpisode: (cb) => provider.onEpisode(cb, holder),
3133
+ subscribe: (cb) => provider.subscribe(cb, holder)
3134
+ };
3135
+ }
3136
+ async function releaseAiLive(holder) {
3137
+ try {
3138
+ await _provider3?.stop(holder);
3139
+ } catch {
3140
+ }
3141
+ try {
3142
+ _provider3?.forget(holder);
3143
+ } catch {
3144
+ }
3145
+ await releaseDeviceStateHolds(aiLiveCameraHolder(holder));
3146
+ }
3147
+ var NOTHING = { unsubscribe() {
3148
+ } };
3149
+ var aiLiveIndicator = {
3150
+ isSending: () => !!_provider3?.isSending(),
3151
+ subscribe: (cb) => _provider3?.subscribeSending(cb) ?? NOTHING
3152
+ };
3153
+
3051
3154
  // src/pluginRuntime.ts
3052
3155
  function mergeCaps(decl) {
3053
3156
  if (!decl) return void 0;
@@ -3063,7 +3166,8 @@ function resolvePluginRuntimeProps(src, holder = src.pluginId) {
3063
3166
  const native = gatePluginNative(getPluginNative(), capabilities, src.pluginId);
3064
3167
  const deviceState = gateDeviceState(stateDomains, holder);
3065
3168
  const voice = gateVoice(!!capabilities?.voice, src.pluginId);
3066
- return { device: native, native, deviceState, voice };
3169
+ const aiLive = gateAiLive(capabilities, src.pluginId, holder, () => gateDeviceState(["visual"], aiLiveCameraHolder(holder)).visual);
3170
+ return { device: native, native, deviceState, voice, aiLive };
3067
3171
  }
3068
3172
 
3069
3173
  // src/tools/loader.ts
@@ -3167,6 +3271,7 @@ export {
3167
3271
  registerTools,
3168
3272
  registerService,
3169
3273
  PLATFORM_VOICE_CALLER,
3274
+ AI_LIVE_IDLE,
3170
3275
  isActionable,
3171
3276
  neverObserved,
3172
3277
  explainCapability,
@@ -3203,6 +3308,8 @@ export {
3203
3308
  gatePluginNative,
3204
3309
  setCameraPreviewProvider,
3205
3310
  getCameraPreviewProvider,
3311
+ setPicturesToAiConsentProvider,
3312
+ mayPicturesLeavePhone,
3206
3313
  registerNativePlugin,
3207
3314
  unregisterNativePlugin,
3208
3315
  nativePluginRegistry,
@@ -3221,6 +3328,10 @@ export {
3221
3328
  setVoiceProvider,
3222
3329
  implementedVoice,
3223
3330
  gateVoice,
3331
+ setAiLiveProvider,
3332
+ gateAiLive,
3333
+ releaseAiLive,
3334
+ aiLiveIndicator,
3224
3335
  resolvePluginGrants,
3225
3336
  resolvePluginRuntimeProps,
3226
3337
  useNativeBridge,
@@ -3255,4 +3366,4 @@ export {
3255
3366
  ensureDeviceToolsLoaded,
3256
3367
  resetDeviceToolLoader
3257
3368
  };
3258
- //# sourceMappingURL=chunk-56Z2X5ZB.mjs.map
3369
+ //# sourceMappingURL=chunk-32IN24XO.mjs.map