@guideai/react-native 0.8.0 → 0.10.0

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 (33) hide show
  1. package/README.md +25 -3
  2. package/dist/{GuideAIChat-W8KQ4Y6i.cjs → GuideAIChat-BtbkPIvE.cjs} +285 -26
  3. package/dist/GuideAIChat-BtbkPIvE.cjs.map +1 -0
  4. package/dist/{GuideAIChat-Ba6n1ePs.js → GuideAIChat-CKW6dgl_.js} +286 -27
  5. package/dist/GuideAIChat-CKW6dgl_.js.map +1 -0
  6. package/dist/index.cjs +1 -1
  7. package/dist/index.d.ts +119 -12
  8. package/dist/index.mjs +2 -2
  9. package/dist/ui.cjs +2 -2
  10. package/dist/ui.d.ts +24 -8
  11. package/dist/ui.mjs +3 -3
  12. package/dist/{useConversations-SbhtYN_R.js → useConversations-BljCr0Od.js} +1085 -52
  13. package/dist/useConversations-BljCr0Od.js.map +1 -0
  14. package/dist/{useConversations-CJEaVqch.cjs → useConversations-UiwD_WVF.cjs} +1085 -52
  15. package/dist/useConversations-UiwD_WVF.cjs.map +1 -0
  16. package/dist/voice.cjs +2873 -19
  17. package/dist/voice.cjs.map +1 -1
  18. package/dist/voice.d.ts +25 -9
  19. package/dist/voice.mjs +2874 -20
  20. package/dist/voice.mjs.map +1 -1
  21. package/package.json +6 -2
  22. package/dist/GuideAIChat-Ba6n1ePs.js.map +0 -1
  23. package/dist/GuideAIChat-CxyWFl_o.cjs +0 -2493
  24. package/dist/GuideAIChat-CxyWFl_o.cjs.map +0 -1
  25. package/dist/GuideAIChat-DOC4zx-a.js +0 -2494
  26. package/dist/GuideAIChat-DOC4zx-a.js.map +0 -1
  27. package/dist/GuideAIChat-W8KQ4Y6i.cjs.map +0 -1
  28. package/dist/useConversations-B_7km_uH.js +0 -4243
  29. package/dist/useConversations-B_7km_uH.js.map +0 -1
  30. package/dist/useConversations-CJEaVqch.cjs.map +0 -1
  31. package/dist/useConversations-CTbQBTz-.cjs +0 -4242
  32. package/dist/useConversations-CTbQBTz-.cjs.map +0 -1
  33. package/dist/useConversations-SbhtYN_R.js.map +0 -1
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
- const useConversations = require("./useConversations-CJEaVqch.cjs");
3
+ const useConversations = require("./useConversations-UiwD_WVF.cjs");
4
4
  const jsxRuntime = require("react/jsx-runtime");
5
5
  const React = require("react");
6
6
  function GuideAIScreen({
package/dist/index.d.ts CHANGED
@@ -838,6 +838,46 @@ interface AsyncKeyValueStorage {
838
838
  multiGet(keys: readonly string[]): Promise<ReadonlyArray<readonly [string, string | null]>>;
839
839
  }
840
840
 
841
+ /** One block of mic audio, as react-native-audio-api delivers it. */
842
+ interface PhoneAudioReady {
843
+ buffer: {
844
+ sampleRate: number;
845
+ getChannelData(channel: number): Float32Array;
846
+ };
847
+ numFrames: number;
848
+ }
849
+ type AudioResult = {
850
+ status: 'success';
851
+ } | {
852
+ status: 'error';
853
+ message: string;
854
+ };
855
+ interface PhoneRecorder {
856
+ onAudioReady(options: {
857
+ sampleRate: number;
858
+ bufferLength: number;
859
+ channelCount: number;
860
+ }, callback: (event: PhoneAudioReady) => void): AudioResult | void;
861
+ clearOnAudioReady(): void;
862
+ start(): Promise<AudioResult | unknown>;
863
+ stop(): Promise<unknown>;
864
+ }
865
+ /** What live voice uses of `import * as AudioAPI from 'react-native-audio-api'`. */
866
+ interface GuideAIAudioModule {
867
+ AudioContext: new (options?: {
868
+ sampleRate?: number;
869
+ }) => unknown;
870
+ AudioRecorder: new (options?: {
871
+ iosVoiceProcessing?: boolean;
872
+ androidInputPreset?: string;
873
+ }) => PhoneRecorder;
874
+ AudioManager: {
875
+ requestRecordingPermissions(): Promise<string>;
876
+ setSystemOptions?(options: unknown): void;
877
+ setAudioSessionActivity?(enabled: boolean): Promise<unknown>;
878
+ };
879
+ }
880
+
841
881
  interface GuideAIConversation {
842
882
  id: string;
843
883
  /** The first thing the user asked, shortened. */
@@ -942,6 +982,15 @@ interface GuideAIConfig {
942
982
  * Omitted: captions only.
943
983
  */
944
984
  speech?: GuideAISpeech;
985
+ /**
986
+ * Streaming audio for live voice: `import * as AudioAPI from
987
+ * 'react-native-audio-api'` and pass it here. The call then streams the
988
+ * mic and the answer's voice as the web SDK does — it hears you finish in
989
+ * a fraction of a second, speaks while the answer is still being written,
990
+ * and you can talk over it. Without it, live voice records each turn and
991
+ * uploads it (slower). Needs a development build, not Expo Go.
992
+ */
993
+ audio?: GuideAIAudioModule;
945
994
  /**
946
995
  * Log the full conversation and every request. Development only —
947
996
  * it prints message content to the console.
@@ -1040,6 +1089,11 @@ interface GuideAIMessage {
1040
1089
  * `explainOnWhiteboard(id)`.
1041
1090
  */
1042
1091
  whiteboard?: boolean;
1092
+ /**
1093
+ * This answer can also be taught as a Full lesson (the Blueprint offers
1094
+ * it). Draw a button that calls `explainOnWhiteboard(id, { lesson: true })`.
1095
+ */
1096
+ lesson?: boolean;
1043
1097
  /**
1044
1098
  * Pictures the agent drew. They are also in `content` as Markdown
1045
1099
  * images where they belong; use this list to place them yourself.
@@ -1079,6 +1133,11 @@ interface GuideAIVoiceResult {
1079
1133
  * calls, the transport. That split is what lets the agent be upgraded
1080
1134
  * underneath a host's UI without them changing a line.
1081
1135
  */
1136
+ /** How `send` reports the answer while it is being written. */
1137
+ interface GuideAISendOptions {
1138
+ /** Each piece of the answer as it arrives. */
1139
+ onDelta?(delta: string): void;
1140
+ }
1082
1141
  interface UseGuideAIResult {
1083
1142
  /**
1084
1143
  * The conversation so far, oldest first, ready to draw. An answer that
@@ -1094,11 +1153,16 @@ interface UseGuideAIResult {
1094
1153
  followUps: string[];
1095
1154
  /** The Blueprint has the whiteboard block. */
1096
1155
  whiteboardAvailable: boolean;
1156
+ /** The Blueprint offers Full lessons beside the whiteboard. */
1157
+ lessonsAvailable: boolean;
1097
1158
  /**
1098
- * Explain an answer on the whiteboard, with the question it answered.
1099
- * Mount `<GuideAIWhiteboard />` once to show the board.
1159
+ * Explain an answer on the whiteboard, with the question it answered;
1160
+ * `{ lesson: true }` for the Full lesson. Mount `<GuideAIWhiteboard />`
1161
+ * once to show the board.
1100
1162
  */
1101
- explainOnWhiteboard(messageId: string): Promise<boolean>;
1163
+ explainOnWhiteboard(messageId: string, options?: {
1164
+ lesson?: boolean;
1165
+ }): Promise<boolean>;
1102
1166
  /**
1103
1167
  * The current input text, and its setter.
1104
1168
  *
@@ -1112,9 +1176,10 @@ interface UseGuideAIResult {
1112
1176
  * Send `input`, or an explicit string.
1113
1177
  *
1114
1178
  * Ignores empty text and calls made while a turn is in flight, so a
1115
- * host does not have to guard their send button.
1179
+ * host does not have to guard their send button. `onDelta` hears the
1180
+ * answer as it is written (live voice speaks it from there).
1116
1181
  */
1117
- send(question?: string): Promise<string | null>;
1182
+ send(question?: string, options?: GuideAISendOptions): Promise<string | null>;
1118
1183
  /** True from send() until the turn settles. Drives a disabled state. */
1119
1184
  busy: boolean;
1120
1185
  /** Whether `send()` would do anything right now. */
@@ -1125,15 +1190,15 @@ interface UseGuideAIResult {
1125
1190
  retry(): Promise<void>;
1126
1191
  /** Start a new conversation. The current one stays in the chat history (useConversations). */
1127
1192
  clear(): void;
1128
- /** Approve the message's `pendingAction`; the agent carries it out. */
1129
- confirm(messageId: string): Promise<void>;
1193
+ /** Approve the message's `pendingAction`; the agent carries it out. Resolves with its reply. */
1194
+ confirm(messageId: string): Promise<string | null>;
1130
1195
  /** Decline the message's `pendingAction`. Nothing is changed. */
1131
1196
  cancel(messageId: string): void;
1132
1197
  /**
1133
1198
  * Push-to-talk: transcribe a recording and send it as the next message.
1134
1199
  * Recording is the host's (no native module here); this uploads it.
1135
1200
  */
1136
- sendVoice(recording: GuideAIVoiceRecording): Promise<GuideAIVoiceResult>;
1201
+ sendVoice(recording: GuideAIVoiceRecording, options?: GuideAISendOptions): Promise<GuideAIVoiceResult>;
1137
1202
  /** True while a recording is being transcribed. */
1138
1203
  transcribing: boolean;
1139
1204
  }
@@ -1296,22 +1361,64 @@ interface BoardScene {
1296
1361
  photos?: Record<string, Photo>;
1297
1362
  }
1298
1363
 
1364
+ type IsoAction = Record<string, unknown>;
1365
+ interface IsoStep {
1366
+ say: string;
1367
+ do: IsoAction[];
1368
+ clear?: boolean;
1369
+ metrics?: Record<string, string | [string, string]>;
1370
+ chapter?: string;
1371
+ title?: string;
1372
+ body?: string[];
1373
+ callout?: {
1374
+ kind: string;
1375
+ text: string;
1376
+ };
1377
+ changes?: string[];
1378
+ }
1379
+ interface IsoMetric {
1380
+ id: string;
1381
+ label: string;
1382
+ icon?: string;
1383
+ better?: 'low' | 'high';
1384
+ }
1385
+ interface IsoPlan {
1386
+ kind: 'iso';
1387
+ lesson: boolean;
1388
+ title: string;
1389
+ summary?: string;
1390
+ sample?: boolean;
1391
+ metrics: IsoMetric[];
1392
+ goals?: {
1393
+ text: string;
1394
+ step: number;
1395
+ }[];
1396
+ steps: IsoStep[];
1397
+ }
1398
+
1299
1399
  type WhiteboardStatus = 'closed' | 'loading' | 'playing' | 'error';
1300
1400
  interface WhiteboardState {
1301
1401
  status: WhiteboardStatus;
1302
- scene: BoardScene | null;
1402
+ /** A pen board, or a 3D board / Full lesson (`kind: 'iso'`). */
1403
+ scene: BoardScene | IsoPlan | null;
1303
1404
  error: string | null;
1304
1405
  /** What was asked, for the loading title and Try again. */
1305
1406
  question: string;
1306
1407
  answer?: string;
1408
+ /** A Full lesson was asked for. */
1409
+ lesson?: boolean;
1307
1410
  }
1308
1411
 
1309
1412
  interface UseWhiteboardResult {
1310
1413
  /** The Blueprint has "Explain on a whiteboard". False until the server says so. */
1311
1414
  available: boolean;
1415
+ /** The Blueprint also offers a Full lesson (a 3D lesson that plays by itself). */
1416
+ lessons: boolean;
1312
1417
  state: WhiteboardState;
1313
- /** Explain an answer on the board: the question asked, and the answer given. */
1314
- explain(question: string, answer?: string): Promise<boolean>;
1418
+ /** Explain an answer on the board: the question asked, and the answer given; `lesson` for the Full lesson. */
1419
+ explain(question: string, answer?: string, options?: {
1420
+ lesson?: boolean;
1421
+ }): Promise<boolean>;
1315
1422
  /** Draw a board the host built (see `whiteboardLayouts`). Throws SceneError if it cannot be drawn. */
1316
1423
  play(scene: unknown): void;
1317
1424
  retry(): void;
@@ -1372,4 +1479,4 @@ declare const whiteboardLayouts: {
1372
1479
  };
1373
1480
 
1374
1481
  export { GuideAI, GuideAIScreen, useConversations, useGuideAI, useGuideAIElement, useOnboarding, useWhiteboard, whiteboardLayouts };
1375
- export type { AsyncKeyValueStorage, AuthTokenGetter, DeclaredElement, ElementHandlers, GuideAIConfig, GuideAIConversation, HeadlessImage as GuideAIImage, GuideAIMessage, GuideAIScreenProps, GuideAISpeech, GuideAIUserProfile, GuideAIVoiceRecording, GuideAIVoiceResult, NavigationRefLike, OnboardingState, OnboardingStepState, RequestHeadersGetter, SyncNativeStore, UseConversationsResult, UseGuideAIElementOptions, UseGuideAIResult, UseWhiteboardResult, WhiteboardState, WhiteboardStatus };
1482
+ export type { AsyncKeyValueStorage, AuthTokenGetter, DeclaredElement, ElementHandlers, GuideAIAudioModule, GuideAIConfig, GuideAIConversation, HeadlessImage as GuideAIImage, GuideAIMessage, GuideAIScreenProps, GuideAISendOptions, GuideAISpeech, GuideAIUserProfile, GuideAIVoiceRecording, GuideAIVoiceResult, NavigationRefLike, OnboardingState, OnboardingStepState, RequestHeadersGetter, SyncNativeStore, UseConversationsResult, UseGuideAIElementOptions, UseGuideAIResult, UseWhiteboardResult, WhiteboardState, WhiteboardStatus };
package/dist/index.mjs CHANGED
@@ -1,5 +1,5 @@
1
- import { u as useGuideAIRuntime, S as ScreenRegistry, R as RegistryContext, a as useScreenRegistry, L as LIMITS } from "./useConversations-SbhtYN_R.js";
2
- import { G, b, c, d, e } from "./useConversations-SbhtYN_R.js";
1
+ import { u as useGuideAIRuntime, S as ScreenRegistry, R as RegistryContext, a as useScreenRegistry, L as LIMITS } from "./useConversations-BljCr0Od.js";
2
+ import { G, b, c, d, e } from "./useConversations-BljCr0Od.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
4
  import { useMemo, useEffect, useRef } from "react";
5
5
  function GuideAIScreen({
package/dist/ui.cjs CHANGED
@@ -3,8 +3,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
3
  const jsxRuntime = require("react/jsx-runtime");
4
4
  const React = require("react");
5
5
  const reactNative = require("react-native");
6
- const GuideAIChat = require("./GuideAIChat-W8KQ4Y6i.cjs");
7
- const useConversations = require("./useConversations-CJEaVqch.cjs");
6
+ const GuideAIChat = require("./GuideAIChat-BtbkPIvE.cjs");
7
+ const useConversations = require("./useConversations-UiwD_WVF.cjs");
8
8
  const POLL_INTERVAL_MS = 3e3;
9
9
  const CONVERSATION_KEY = "guideai_support_conversation";
10
10
  function useStoredConversation() {
package/dist/ui.d.ts CHANGED
@@ -32,6 +32,11 @@ interface GuideAIMessage {
32
32
  * `explainOnWhiteboard(id)`.
33
33
  */
34
34
  whiteboard?: boolean;
35
+ /**
36
+ * This answer can also be taught as a Full lesson (the Blueprint offers
37
+ * it). Draw a button that calls `explainOnWhiteboard(id, { lesson: true })`.
38
+ */
39
+ lesson?: boolean;
35
40
  /**
36
41
  * Pictures the agent drew. They are also in `content` as Markdown
37
42
  * images where they belong; use this list to place them yourself.
@@ -71,6 +76,11 @@ interface GuideAIVoiceResult {
71
76
  * calls, the transport. That split is what lets the agent be upgraded
72
77
  * underneath a host's UI without them changing a line.
73
78
  */
79
+ /** How `send` reports the answer while it is being written. */
80
+ interface GuideAISendOptions {
81
+ /** Each piece of the answer as it arrives. */
82
+ onDelta?(delta: string): void;
83
+ }
74
84
  interface UseGuideAIResult {
75
85
  /**
76
86
  * The conversation so far, oldest first, ready to draw. An answer that
@@ -86,11 +96,16 @@ interface UseGuideAIResult {
86
96
  followUps: string[];
87
97
  /** The Blueprint has the whiteboard block. */
88
98
  whiteboardAvailable: boolean;
99
+ /** The Blueprint offers Full lessons beside the whiteboard. */
100
+ lessonsAvailable: boolean;
89
101
  /**
90
- * Explain an answer on the whiteboard, with the question it answered.
91
- * Mount `<GuideAIWhiteboard />` once to show the board.
102
+ * Explain an answer on the whiteboard, with the question it answered;
103
+ * `{ lesson: true }` for the Full lesson. Mount `<GuideAIWhiteboard />`
104
+ * once to show the board.
92
105
  */
93
- explainOnWhiteboard(messageId: string): Promise<boolean>;
106
+ explainOnWhiteboard(messageId: string, options?: {
107
+ lesson?: boolean;
108
+ }): Promise<boolean>;
94
109
  /**
95
110
  * The current input text, and its setter.
96
111
  *
@@ -104,9 +119,10 @@ interface UseGuideAIResult {
104
119
  * Send `input`, or an explicit string.
105
120
  *
106
121
  * Ignores empty text and calls made while a turn is in flight, so a
107
- * host does not have to guard their send button.
122
+ * host does not have to guard their send button. `onDelta` hears the
123
+ * answer as it is written (live voice speaks it from there).
108
124
  */
109
- send(question?: string): Promise<string | null>;
125
+ send(question?: string, options?: GuideAISendOptions): Promise<string | null>;
110
126
  /** True from send() until the turn settles. Drives a disabled state. */
111
127
  busy: boolean;
112
128
  /** Whether `send()` would do anything right now. */
@@ -117,15 +133,15 @@ interface UseGuideAIResult {
117
133
  retry(): Promise<void>;
118
134
  /** Start a new conversation. The current one stays in the chat history (useConversations). */
119
135
  clear(): void;
120
- /** Approve the message's `pendingAction`; the agent carries it out. */
121
- confirm(messageId: string): Promise<void>;
136
+ /** Approve the message's `pendingAction`; the agent carries it out. Resolves with its reply. */
137
+ confirm(messageId: string): Promise<string | null>;
122
138
  /** Decline the message's `pendingAction`. Nothing is changed. */
123
139
  cancel(messageId: string): void;
124
140
  /**
125
141
  * Push-to-talk: transcribe a recording and send it as the next message.
126
142
  * Recording is the host's (no native module here); this uploads it.
127
143
  */
128
- sendVoice(recording: GuideAIVoiceRecording): Promise<GuideAIVoiceResult>;
144
+ sendVoice(recording: GuideAIVoiceRecording, options?: GuideAISendOptions): Promise<GuideAIVoiceResult>;
129
145
  /** True while a recording is being transcribed. */
130
146
  transcribing: boolean;
131
147
  }
package/dist/ui.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
2
  import { useState, useRef, useEffect, useCallback, useMemo, useContext, createContext } from "react";
3
3
  import { Platform, StatusBar, KeyboardAvoidingView, View, Text, Pressable, ScrollView, TextInput, ActivityIndicator, FlatList, StyleSheet, Dimensions, Animated, PanResponder, Modal, Easing } from "react-native";
4
- import { r as resolveTheme, G as GuideAIChat } from "./GuideAIChat-Ba6n1ePs.js";
5
- import { D, a, b, c, d, M, e, l } from "./GuideAIChat-Ba6n1ePs.js";
6
- import { r as requireConfigured, E as EP, d as useOnboarding } from "./useConversations-SbhtYN_R.js";
4
+ import { r as resolveTheme, G as GuideAIChat } from "./GuideAIChat-CKW6dgl_.js";
5
+ import { D, a, b, c, d, M, e, l } from "./GuideAIChat-CKW6dgl_.js";
6
+ import { r as requireConfigured, E as EP, d as useOnboarding } from "./useConversations-BljCr0Od.js";
7
7
  const POLL_INTERVAL_MS = 3e3;
8
8
  const CONVERSATION_KEY = "guideai_support_conversation";
9
9
  function useStoredConversation() {