@blario/react-native 0.0.0 → 0.1.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.
Files changed (313) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +401 -0
  3. package/dist/BlarProvider.d.ts +74 -0
  4. package/dist/actions/batched.d.ts +1 -0
  5. package/dist/actions/click.d.ts +4 -0
  6. package/dist/actions/commit-watch.d.ts +15 -0
  7. package/dist/actions/events.d.ts +35 -0
  8. package/dist/actions/executor.d.ts +29 -0
  9. package/dist/actions/highlight.d.ts +4 -0
  10. package/dist/actions/interaction-guards.d.ts +9 -0
  11. package/dist/actions/landing.d.ts +11 -0
  12. package/dist/actions/navigation-driver.d.ts +22 -0
  13. package/dist/actions/parse.d.ts +4 -0
  14. package/dist/actions/result.d.ts +4 -0
  15. package/dist/actions/scrolling.d.ts +12 -0
  16. package/dist/actions/services.d.ts +20 -0
  17. package/dist/actions/settle.d.ts +13 -0
  18. package/dist/actions/switch.d.ts +3 -0
  19. package/dist/actions/target.d.ts +25 -0
  20. package/dist/actions/text-input.d.ts +9 -0
  21. package/dist/actions/types.d.ts +59 -0
  22. package/dist/agent/batch-commands.d.ts +17 -0
  23. package/dist/agent/compose.d.ts +23 -0
  24. package/dist/agent/controller.d.ts +28 -0
  25. package/dist/agent/frame-runner.d.ts +9 -0
  26. package/dist/agent/frames.d.ts +180 -0
  27. package/dist/agent/handlers/agent-command.d.ts +5 -0
  28. package/dist/agent/handlers/batch.d.ts +5 -0
  29. package/dist/agent/handlers/consent-screenshot.d.ts +4 -0
  30. package/dist/agent/handlers/context.d.ts +16 -0
  31. package/dist/agent/handlers/dom-state.d.ts +4 -0
  32. package/dist/agent/handlers/element-context.d.ts +2 -0
  33. package/dist/agent/handlers/screenshot.d.ts +3 -0
  34. package/dist/agent/handlers/text-dom.d.ts +5 -0
  35. package/dist/agent/stage.d.ts +13 -0
  36. package/dist/agent-mode/action-description.d.ts +3 -0
  37. package/dist/agent-mode/bubbles.d.ts +10 -0
  38. package/dist/agent-mode/colors.d.ts +12 -0
  39. package/dist/agent-mode/controller.d.ts +92 -0
  40. package/dist/agent-mode/cursor-follow.d.ts +12 -0
  41. package/dist/agent-mode/cursor.d.ts +37 -0
  42. package/dist/agent-mode/frames.d.ts +36 -0
  43. package/dist/agent-mode/haptics.d.ts +6 -0
  44. package/dist/agent-mode/keep-awake.d.ts +19 -0
  45. package/dist/agent-mode/layer-stacking.d.ts +7 -0
  46. package/dist/agent-mode/markdown.d.ts +19 -0
  47. package/dist/agent-mode/panel-geometry.d.ts +6 -0
  48. package/dist/agent-mode/resume.d.ts +13 -0
  49. package/dist/agent-mode/run-memory.d.ts +19 -0
  50. package/dist/agent-mode/spotlight-controller.d.ts +68 -0
  51. package/dist/agent-mode/spotlight.d.ts +6 -0
  52. package/dist/agent-mode/state.d.ts +9 -0
  53. package/dist/agent-mode/status.d.ts +11 -0
  54. package/dist/agent-mode/timers.d.ts +6 -0
  55. package/dist/agent-mode/ui/AgentDock.d.ts +37 -0
  56. package/dist/agent-mode/ui/AgentLayer.d.ts +19 -0
  57. package/dist/agent-mode/ui/AgentLayerHost.d.ts +8 -0
  58. package/dist/agent-mode/ui/AgentPanel.d.ts +19 -0
  59. package/dist/agent-mode/ui/AgentTap.d.ts +10 -0
  60. package/dist/agent-mode/ui/MarkdownText.d.ts +8 -0
  61. package/dist/agent-mode/ui/MessageBubbles.d.ts +9 -0
  62. package/dist/agent-mode/ui/PendingOverlay.d.ts +5 -0
  63. package/dist/agent-mode/ui/SpotlightLayer.d.ts +9 -0
  64. package/dist/agent-mode/ui/SpotlightOverlay.d.ts +7 -0
  65. package/dist/agent-mode/ui/StatusCard.d.ts +14 -0
  66. package/dist/agent-mode/ui/TargetPulse.d.ts +9 -0
  67. package/dist/agent-mode/ui/TouchShield.d.ts +5 -0
  68. package/dist/agent-mode/ui/WarningIcon.d.ts +6 -0
  69. package/dist/agent-mode/ui/full-window-overlay.d.ts +5 -0
  70. package/dist/agent-mode/ui/layer-host.d.ts +2 -0
  71. package/dist/backend/api-client.d.ts +38 -0
  72. package/dist/backend/api-types.d.ts +25 -0
  73. package/dist/backend/app-info.d.ts +14 -0
  74. package/dist/backend/backend-transport.d.ts +70 -0
  75. package/dist/backend/backoff.d.ts +9 -0
  76. package/dist/backend/base64.d.ts +1 -0
  77. package/dist/backend/errors.d.ts +17 -0
  78. package/dist/backend/foreground.d.ts +1 -0
  79. package/dist/backend/health.d.ts +17 -0
  80. package/dist/backend/identity-proof.d.ts +23 -0
  81. package/dist/backend/identity.d.ts +27 -0
  82. package/dist/backend/message-metadata.d.ts +19 -0
  83. package/dist/backend/presence.d.ts +20 -0
  84. package/dist/backend/response-cache.d.ts +9 -0
  85. package/dist/backend/session-change.d.ts +2 -0
  86. package/dist/backend/session-socket.d.ts +49 -0
  87. package/dist/backend/session.d.ts +39 -0
  88. package/dist/backend/socket-url.d.ts +9 -0
  89. package/dist/backend/storage.d.ts +13 -0
  90. package/dist/backend/tab-id.d.ts +2 -0
  91. package/dist/blar.d.ts +37 -0
  92. package/dist/chat/ChatLayer.d.ts +29 -0
  93. package/dist/chat/ChatSheet.d.ts +11 -0
  94. package/dist/chat/ChatView.d.ts +19 -0
  95. package/dist/chat/Launcher.d.ts +14 -0
  96. package/dist/chat/bridge.d.ts +22 -0
  97. package/dist/chat/chat-coordinator.d.ts +57 -0
  98. package/dist/chat/chat-state.d.ts +20 -0
  99. package/dist/chat/navigation.d.ts +5 -0
  100. package/dist/chat/options.d.ts +22 -0
  101. package/dist/chat/webview.d.ts +10 -0
  102. package/dist/chat/widget-bundle.generated.d.ts +2 -0
  103. package/dist/chat/widget-shell.d.ts +24 -0
  104. package/dist/confirmation/port.d.ts +12 -0
  105. package/dist/fiber/locate.d.ts +7 -0
  106. package/dist/fiber/narrow.d.ts +5 -0
  107. package/dist/fiber/reader.d.ts +10 -0
  108. package/dist/fiber/text.d.ts +4 -0
  109. package/dist/fiber/types.d.ts +21 -0
  110. package/dist/host/border-radius.d.ts +1 -0
  111. package/dist/host/instance.d.ts +9 -0
  112. package/dist/host/measure.d.ts +3 -0
  113. package/dist/host/rect.d.ts +22 -0
  114. package/dist/host/visible-area.d.ts +2 -0
  115. package/dist/index.d.ts +10 -0
  116. package/dist/nudge/NudgeBubble.d.ts +15 -0
  117. package/dist/nudge/nudge.d.ts +23 -0
  118. package/dist/optional/expo-haptics.d.ts +1 -0
  119. package/dist/optional/expo-keep-awake.d.ts +1 -0
  120. package/dist/optional/react-native-haptic-feedback.d.ts +1 -0
  121. package/dist/optional/react-native-keep-awake.d.ts +1 -0
  122. package/dist/overlay/AgentOverlay.d.ts +5 -0
  123. package/dist/screenshot/capture-backend.d.ts +6 -0
  124. package/dist/screenshot/screenshotter.d.ts +18 -0
  125. package/dist/screenshot/skia.d.ts +35 -0
  126. package/dist/screenshot/view-shot.d.ts +2 -0
  127. package/dist/snapshot/capture.d.ts +36 -0
  128. package/dist/snapshot/classify.d.ts +11 -0
  129. package/dist/snapshot/collect.d.ts +27 -0
  130. package/dist/snapshot/element-context.d.ts +9 -0
  131. package/dist/snapshot/icon.d.ts +2 -0
  132. package/dist/snapshot/kinds.d.ts +3 -0
  133. package/dist/snapshot/modals.d.ts +2 -0
  134. package/dist/snapshot/navigation.d.ts +14 -0
  135. package/dist/snapshot/ordering.d.ts +2 -0
  136. package/dist/snapshot/properties.d.ts +14 -0
  137. package/dist/snapshot/registry.d.ts +16 -0
  138. package/dist/snapshot/render.d.ts +10 -0
  139. package/dist/snapshot/route-summary.d.ts +3 -0
  140. package/dist/snapshot/scroll.d.ts +15 -0
  141. package/dist/snapshot/text-layout.d.ts +8 -0
  142. package/dist/snapshot/view.d.ts +30 -0
  143. package/dist/snapshot/visibility.d.ts +17 -0
  144. package/dist/snapshot/wrappers.d.ts +11 -0
  145. package/dist/telemetry/SdkErrorBoundary.d.ts +15 -0
  146. package/dist/telemetry/build-info.generated.d.ts +2 -0
  147. package/dist/telemetry/envelope.d.ts +53 -0
  148. package/dist/telemetry/reporter.d.ts +33 -0
  149. package/dist/telemetry/scrub.d.ts +1 -0
  150. package/dist/telemetry/sdk-reporter.d.ts +5 -0
  151. package/dist/transport/connection-options.d.ts +18 -0
  152. package/dist/transport/relay-transport.d.ts +17 -0
  153. package/dist/transport/transport.d.ts +7 -0
  154. package/dist/ui/insets.d.ts +8 -0
  155. package/dist/ui/strings.d.ts +33 -0
  156. package/dist/ui/useInsets.d.ts +2 -0
  157. package/dist/version.d.ts +1 -0
  158. package/package.json +87 -3
  159. package/src/BlarProvider.tsx +462 -0
  160. package/src/actions/batched.ts +16 -0
  161. package/src/actions/click.ts +54 -0
  162. package/src/actions/commit-watch.ts +86 -0
  163. package/src/actions/events.ts +58 -0
  164. package/src/actions/executor.ts +147 -0
  165. package/src/actions/highlight.ts +13 -0
  166. package/src/actions/interaction-guards.ts +44 -0
  167. package/src/actions/landing.ts +26 -0
  168. package/src/actions/navigation-driver.ts +131 -0
  169. package/src/actions/parse.ts +82 -0
  170. package/src/actions/result.ts +14 -0
  171. package/src/actions/scrolling.ts +112 -0
  172. package/src/actions/services.ts +24 -0
  173. package/src/actions/settle.ts +40 -0
  174. package/src/actions/switch.ts +31 -0
  175. package/src/actions/target.ts +77 -0
  176. package/src/actions/text-input.ts +82 -0
  177. package/src/actions/types.ts +52 -0
  178. package/src/agent/batch-commands.ts +33 -0
  179. package/src/agent/compose.ts +67 -0
  180. package/src/agent/controller.ts +106 -0
  181. package/src/agent/frame-runner.ts +27 -0
  182. package/src/agent/frames.ts +193 -0
  183. package/src/agent/handlers/agent-command.ts +74 -0
  184. package/src/agent/handlers/batch.ts +72 -0
  185. package/src/agent/handlers/consent-screenshot.ts +44 -0
  186. package/src/agent/handlers/context.ts +17 -0
  187. package/src/agent/handlers/dom-state.ts +19 -0
  188. package/src/agent/handlers/element-context.ts +9 -0
  189. package/src/agent/handlers/screenshot.ts +24 -0
  190. package/src/agent/handlers/text-dom.ts +17 -0
  191. package/src/agent/stage.ts +22 -0
  192. package/src/agent-mode/action-description.ts +25 -0
  193. package/src/agent-mode/bubbles.ts +31 -0
  194. package/src/agent-mode/colors.ts +40 -0
  195. package/src/agent-mode/controller.ts +459 -0
  196. package/src/agent-mode/cursor-follow.ts +43 -0
  197. package/src/agent-mode/cursor.ts +118 -0
  198. package/src/agent-mode/frames.ts +70 -0
  199. package/src/agent-mode/haptics.ts +49 -0
  200. package/src/agent-mode/keep-awake.ts +107 -0
  201. package/src/agent-mode/layer-stacking.ts +16 -0
  202. package/src/agent-mode/markdown.ts +84 -0
  203. package/src/agent-mode/panel-geometry.ts +27 -0
  204. package/src/agent-mode/resume.ts +16 -0
  205. package/src/agent-mode/run-memory.ts +65 -0
  206. package/src/agent-mode/spotlight-controller.ts +255 -0
  207. package/src/agent-mode/spotlight.ts +14 -0
  208. package/src/agent-mode/state.ts +36 -0
  209. package/src/agent-mode/status.ts +13 -0
  210. package/src/agent-mode/timers.ts +11 -0
  211. package/src/agent-mode/ui/AgentDock.tsx +285 -0
  212. package/src/agent-mode/ui/AgentLayer.tsx +123 -0
  213. package/src/agent-mode/ui/AgentLayerHost.tsx +37 -0
  214. package/src/agent-mode/ui/AgentPanel.tsx +187 -0
  215. package/src/agent-mode/ui/AgentTap.tsx +190 -0
  216. package/src/agent-mode/ui/MarkdownText.tsx +55 -0
  217. package/src/agent-mode/ui/MessageBubbles.tsx +58 -0
  218. package/src/agent-mode/ui/PendingOverlay.tsx +32 -0
  219. package/src/agent-mode/ui/SpotlightLayer.tsx +60 -0
  220. package/src/agent-mode/ui/SpotlightOverlay.tsx +35 -0
  221. package/src/agent-mode/ui/StatusCard.tsx +137 -0
  222. package/src/agent-mode/ui/TargetPulse.tsx +74 -0
  223. package/src/agent-mode/ui/TouchShield.tsx +22 -0
  224. package/src/agent-mode/ui/WarningIcon.tsx +32 -0
  225. package/src/agent-mode/ui/full-window-overlay.ts +16 -0
  226. package/src/agent-mode/ui/layer-host.ts +11 -0
  227. package/src/backend/api-client.ts +210 -0
  228. package/src/backend/api-types.ts +56 -0
  229. package/src/backend/app-info.ts +40 -0
  230. package/src/backend/backend-transport.ts +338 -0
  231. package/src/backend/backoff.ts +16 -0
  232. package/src/backend/base64.ts +25 -0
  233. package/src/backend/errors.ts +32 -0
  234. package/src/backend/foreground.ts +10 -0
  235. package/src/backend/health.ts +64 -0
  236. package/src/backend/identity-proof.ts +151 -0
  237. package/src/backend/identity.ts +31 -0
  238. package/src/backend/message-metadata.ts +28 -0
  239. package/src/backend/presence.ts +95 -0
  240. package/src/backend/response-cache.ts +45 -0
  241. package/src/backend/session-change.ts +14 -0
  242. package/src/backend/session-socket.ts +292 -0
  243. package/src/backend/session.ts +188 -0
  244. package/src/backend/socket-url.ts +25 -0
  245. package/src/backend/storage.ts +49 -0
  246. package/src/backend/tab-id.ts +24 -0
  247. package/src/blar.ts +100 -0
  248. package/src/chat/ChatLayer.tsx +109 -0
  249. package/src/chat/ChatSheet.tsx +84 -0
  250. package/src/chat/ChatView.tsx +133 -0
  251. package/src/chat/Launcher.tsx +72 -0
  252. package/src/chat/bridge.ts +56 -0
  253. package/src/chat/chat-coordinator.ts +189 -0
  254. package/src/chat/chat-state.ts +35 -0
  255. package/src/chat/navigation.ts +15 -0
  256. package/src/chat/options.ts +39 -0
  257. package/src/chat/webview.ts +23 -0
  258. package/src/chat/widget-bundle.generated.ts +2 -0
  259. package/src/chat/widget-shell.ts +170 -0
  260. package/src/confirmation/port.ts +15 -0
  261. package/src/fiber/locate.ts +41 -0
  262. package/src/fiber/narrow.ts +15 -0
  263. package/src/fiber/reader.ts +98 -0
  264. package/src/fiber/text.ts +52 -0
  265. package/src/fiber/types.ts +24 -0
  266. package/src/host/border-radius.ts +11 -0
  267. package/src/host/instance.ts +30 -0
  268. package/src/host/measure.ts +25 -0
  269. package/src/host/rect.ts +45 -0
  270. package/src/host/visible-area.ts +5 -0
  271. package/src/index.ts +10 -0
  272. package/src/nudge/NudgeBubble.tsx +117 -0
  273. package/src/nudge/nudge.ts +100 -0
  274. package/src/optional/expo-haptics.ts +11 -0
  275. package/src/optional/expo-keep-awake.ts +11 -0
  276. package/src/optional/react-native-haptic-feedback.ts +11 -0
  277. package/src/optional/react-native-keep-awake.ts +11 -0
  278. package/src/overlay/AgentOverlay.tsx +16 -0
  279. package/src/screenshot/capture-backend.ts +7 -0
  280. package/src/screenshot/screenshotter.ts +39 -0
  281. package/src/screenshot/skia.ts +107 -0
  282. package/src/screenshot/view-shot.ts +41 -0
  283. package/src/snapshot/capture.ts +163 -0
  284. package/src/snapshot/classify.ts +40 -0
  285. package/src/snapshot/collect.ts +136 -0
  286. package/src/snapshot/element-context.ts +66 -0
  287. package/src/snapshot/icon.ts +21 -0
  288. package/src/snapshot/kinds.ts +10 -0
  289. package/src/snapshot/modals.ts +21 -0
  290. package/src/snapshot/navigation.ts +47 -0
  291. package/src/snapshot/ordering.ts +26 -0
  292. package/src/snapshot/properties.ts +71 -0
  293. package/src/snapshot/registry.ts +33 -0
  294. package/src/snapshot/render.ts +140 -0
  295. package/src/snapshot/route-summary.ts +15 -0
  296. package/src/snapshot/scroll.ts +90 -0
  297. package/src/snapshot/text-layout.ts +59 -0
  298. package/src/snapshot/view.ts +87 -0
  299. package/src/snapshot/visibility.ts +63 -0
  300. package/src/snapshot/wrappers.ts +69 -0
  301. package/src/telemetry/SdkErrorBoundary.tsx +28 -0
  302. package/src/telemetry/build-info.generated.ts +2 -0
  303. package/src/telemetry/envelope.ts +83 -0
  304. package/src/telemetry/reporter.ts +170 -0
  305. package/src/telemetry/scrub.ts +10 -0
  306. package/src/telemetry/sdk-reporter.ts +37 -0
  307. package/src/transport/connection-options.ts +65 -0
  308. package/src/transport/relay-transport.ts +82 -0
  309. package/src/transport/transport.ts +8 -0
  310. package/src/ui/insets.ts +31 -0
  311. package/src/ui/strings.ts +102 -0
  312. package/src/ui/useInsets.ts +10 -0
  313. package/src/version.ts +1 -0
@@ -0,0 +1,23 @@
1
+ import type { BlarIdentity, IdentityProof, IdentityRefusalReason } from './identity.ts';
2
+ export declare function readJwtExpiry(token: string): number | null;
3
+ export declare class IdentityProofStore {
4
+ private readonly now;
5
+ private identity;
6
+ private cached;
7
+ private expiresAt;
8
+ private inFlight;
9
+ private mintFailure;
10
+ constructor(now?: () => number);
11
+ setIdentity(identity: BlarIdentity | null): void;
12
+ getIdentity(): BlarIdentity | null;
13
+ hasIdentity(): boolean;
14
+ canRefresh(): boolean;
15
+ refusalReason(): IdentityRefusalReason;
16
+ get(options?: {
17
+ refresh?: boolean;
18
+ }): Promise<IdentityProof | null>;
19
+ private mint;
20
+ private fromProviderProof;
21
+ private storeToken;
22
+ private storeSignature;
23
+ }
@@ -0,0 +1,27 @@
1
+ export interface BlarIdentityProofInput {
2
+ externalId?: string;
3
+ identityToken?: string;
4
+ identitySignature?: string;
5
+ }
6
+ export type CustomFields = Record<string, string | number | boolean>;
7
+ export interface BlarIdentity {
8
+ externalId: string;
9
+ email?: string;
10
+ name?: string;
11
+ phone?: string;
12
+ contactCompany?: string;
13
+ contactCompanyExternalId?: string;
14
+ country?: string;
15
+ identityToken?: string;
16
+ identitySignature?: string;
17
+ getProof?: () => Promise<BlarIdentityProofInput>;
18
+ getIdentityToken?: () => Promise<string>;
19
+ getIdentitySignature?: () => Promise<string>;
20
+ customFields?: CustomFields;
21
+ }
22
+ export interface IdentityProof {
23
+ header: 'X-Identity-Token' | 'X-Identity-Signature';
24
+ value: string;
25
+ protocol: string;
26
+ }
27
+ export type IdentityRefusalReason = 'provider_failed' | 'static_token_expired' | 'identify_refused' | 'subject_mismatch';
@@ -0,0 +1,19 @@
1
+ import type { TextDomResponseData } from '../agent/frames.ts';
2
+ import type { Size } from '../host/rect.ts';
3
+ import type { AppInfo } from './app-info.ts';
4
+ export interface MessageMetadata extends AppInfo {
5
+ url: string;
6
+ tab_id: string;
7
+ debug_context: {
8
+ viewport: Size;
9
+ };
10
+ text_dom?: TextDomResponseData;
11
+ }
12
+ export interface MessageMetadataInput {
13
+ screen: string;
14
+ tabId: string;
15
+ viewport: Size;
16
+ appInfo: AppInfo;
17
+ textDom: TextDomResponseData | null;
18
+ }
19
+ export declare function buildMessageMetadata(input: MessageMetadataInput): MessageMetadata;
@@ -0,0 +1,20 @@
1
+ import type { ApiClient } from './api-client.ts';
2
+ export declare class PresenceManager {
3
+ private readonly api;
4
+ private readonly onPendingNudge;
5
+ private readonly log;
6
+ private readonly now;
7
+ private timer;
8
+ private subscription;
9
+ private lastInteraction;
10
+ private inFlight;
11
+ private started;
12
+ constructor(api: ApiClient, onPendingNudge?: () => void, log?: (message: string) => void, now?: () => number);
13
+ start(): void;
14
+ stop(): void;
15
+ noteInteraction(): void;
16
+ isPresent(): boolean;
17
+ private fireNow;
18
+ private scheduleNext;
19
+ private send;
20
+ }
@@ -0,0 +1,9 @@
1
+ export declare class ResponseCache {
2
+ private readonly now;
3
+ private readonly frames;
4
+ constructor(now?: () => number);
5
+ store(commandId: string, payload: string): void;
6
+ clear(): void;
7
+ drain(): string[];
8
+ private sweep;
9
+ }
@@ -0,0 +1,2 @@
1
+ import type { SessionState } from './session.ts';
2
+ export declare function watchSessionChanges(subscribe: (listener: (state: SessionState) => void) => () => void, onChanged: () => void): () => void;
@@ -0,0 +1,49 @@
1
+ import type { IdentityProof } from './identity.ts';
2
+ export type SocketState = 'connecting' | 'connected' | 'reconnecting' | 'disconnected' | 'failed';
3
+ export interface SessionSocketOptions {
4
+ apiBaseUrl: string;
5
+ publishableKey: string;
6
+ tabId: string;
7
+ getSourceId: () => string | null;
8
+ getProof: () => Promise<IdentityProof | null> | null;
9
+ refreshProof: () => Promise<IdentityProof | null>;
10
+ getLastSeenSeq: () => number;
11
+ onMessage: (raw: string, frame: Record<string, unknown> | null) => void;
12
+ onState: (state: SocketState) => void;
13
+ onIdentityRejected: () => void;
14
+ watchForeground: (onActive: () => void) => () => void;
15
+ }
16
+ export declare class SessionSocket {
17
+ private readonly options;
18
+ private socket;
19
+ private sessionId;
20
+ private epoch;
21
+ private attempts;
22
+ private intentionallyClosed;
23
+ private identityRefreshUsed;
24
+ private exhausted;
25
+ private lastFrameAt;
26
+ private reconnectTimer;
27
+ private livenessTimer;
28
+ private stopWatchingForeground;
29
+ private readonly cache;
30
+ private cacheScope;
31
+ constructor(options: SessionSocketOptions);
32
+ connect(sessionId: number): void;
33
+ disconnect(): void;
34
+ isOpen(): boolean;
35
+ send(payload: string): boolean;
36
+ sendOrCache(commandId: string, payload: string): void;
37
+ private open;
38
+ private handleClose;
39
+ private handleIdentityRejection;
40
+ private scheduleReconnect;
41
+ private recover;
42
+ private watchForeground;
43
+ private startLiveness;
44
+ private stopLiveness;
45
+ private dropStaleSocket;
46
+ private discardSocket;
47
+ private detach;
48
+ private clearTimers;
49
+ }
@@ -0,0 +1,39 @@
1
+ import type { ApiClient } from './api-client.ts';
2
+ import type { BlarIdentity } from './identity.ts';
3
+ import type { KeyValueStorage } from './storage.ts';
4
+ export interface SessionState {
5
+ sourceId: string | null;
6
+ sessionId: number | null;
7
+ conversationId: number | null;
8
+ aiActive: boolean;
9
+ identified: boolean;
10
+ isIdentityVerified: boolean;
11
+ }
12
+ type Listener = (state: SessionState) => void;
13
+ export declare class BackendSession {
14
+ private readonly api;
15
+ private readonly storage;
16
+ private state;
17
+ private readonly listeners;
18
+ private restoring;
19
+ private readonly storageKey;
20
+ constructor(api: ApiClient, storage: KeyValueStorage);
21
+ getState(): SessionState;
22
+ subscribe(listener: Listener): () => void;
23
+ boot(identity: BlarIdentity | null): Promise<void>;
24
+ setUser(identity: BlarIdentity): Promise<void>;
25
+ private identify;
26
+ logout(): Promise<void>;
27
+ refresh(): Promise<SessionState>;
28
+ adoptSession(sessionId: number): void;
29
+ leaveSession(): void;
30
+ ensureSessionId(): Promise<number | null>;
31
+ private loadAnonymous;
32
+ private restoreSession;
33
+ private restore;
34
+ private fallBackToAnonymous;
35
+ private dropSource;
36
+ private apply;
37
+ private update;
38
+ }
39
+ export {};
@@ -0,0 +1,9 @@
1
+ export interface SocketUrlParts {
2
+ apiBaseUrl: string;
3
+ sessionId: number;
4
+ publishableKey: string;
5
+ sourceId: string;
6
+ tabId: string;
7
+ lastSeenSeq: number;
8
+ }
9
+ export declare function buildSocketUrl(parts: SocketUrlParts): string | null;
@@ -0,0 +1,13 @@
1
+ export interface KeyValueStorage {
2
+ getItem: (key: string) => Promise<string | null>;
3
+ setItem: (key: string, value: string) => Promise<void>;
4
+ removeItem: (key: string) => Promise<void>;
5
+ }
6
+ declare class MemoryStorage implements KeyValueStorage {
7
+ private readonly values;
8
+ getItem(key: string): Promise<string | null>;
9
+ setItem(key: string, value: string): Promise<void>;
10
+ removeItem(key: string): Promise<void>;
11
+ }
12
+ export declare function createDefaultStorage(): KeyValueStorage;
13
+ export { MemoryStorage };
@@ -0,0 +1,2 @@
1
+ export declare function getTabId(): string;
2
+ export declare function generateIdempotencyKey(): string;
package/dist/blar.d.ts ADDED
@@ -0,0 +1,37 @@
1
+ import type { BackendTransport } from './backend/backend-transport.ts';
2
+ import type { BlarIdentity } from './backend/identity.ts';
3
+ import type { MessageMetadata } from './backend/message-metadata.ts';
4
+ export interface MessageMetadataOptions {
5
+ includeTextDom: boolean;
6
+ }
7
+ export interface ChatControls {
8
+ open: () => void;
9
+ close: () => void;
10
+ getUnread: () => number;
11
+ isOpen: () => boolean;
12
+ }
13
+ export type MessageMetadataReader = (options: MessageMetadataOptions) => Promise<MessageMetadata | null>;
14
+ declare class BlarClient {
15
+ private transport;
16
+ private metadataReader;
17
+ private chat;
18
+ private pendingUser;
19
+ private logoutRequested;
20
+ attach(transport: BackendTransport, metadataReader: MessageMetadataReader): void;
21
+ detach(transport: BackendTransport): void;
22
+ attachChat(controls: ChatControls): void;
23
+ detachChat(controls: ChatControls): void;
24
+ open(): void;
25
+ close(): void;
26
+ getUnreadCount(): number;
27
+ isChatOpen(): boolean;
28
+ setUser(identity: BlarIdentity): Promise<void>;
29
+ logout(): Promise<void>;
30
+ consumePendingUser(): BlarIdentity | null;
31
+ isConnected(): boolean;
32
+ getTabId(): string | null;
33
+ getSessionState(): ReturnType<BackendTransport['getState']> | null;
34
+ getMessageMetadata(options?: MessageMetadataOptions): Promise<MessageMetadata | null>;
35
+ }
36
+ export declare const Blar: BlarClient;
37
+ export {};
@@ -0,0 +1,29 @@
1
+ import React from 'react';
2
+ import type { WidgetProof } from '../backend/backend-transport.ts';
3
+ import type { BlarIdentity } from '../backend/identity.ts';
4
+ import type { MessageMetadata } from '../backend/message-metadata.ts';
5
+ import type { Language, UiStrings } from '../ui/strings.ts';
6
+ import type { ChatSnapshot } from './chat-coordinator.ts';
7
+ import type { ResolvedChatOptions } from './options.ts';
8
+ export interface ChatLayerProps {
9
+ snapshot: ChatSnapshot;
10
+ options: ResolvedChatOptions;
11
+ strings: UiStrings;
12
+ language: Language;
13
+ publishableKey: string;
14
+ apiBaseUrl: string;
15
+ tabId: string;
16
+ identity: BlarIdentity | null;
17
+ getMetadata: (options: {
18
+ includeTextDom: boolean;
19
+ }) => Promise<MessageMetadata | null>;
20
+ getProof: () => Promise<WidgetProof | null>;
21
+ onOpen: () => void;
22
+ onClose: () => void;
23
+ onSessionChanged: (sessionId: number | null) => void;
24
+ onAcceptNudge: () => void;
25
+ onDeclineNudge: () => void;
26
+ onSnoozeNudge: () => void;
27
+ log?: (message: string) => void;
28
+ }
29
+ export declare function ChatLayer(props: ChatLayerProps): React.JSX.Element;
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import type { UiStrings } from '../ui/strings.ts';
3
+ import type { SheetMode } from './chat-state.ts';
4
+ export interface ChatSheetProps {
5
+ mode: SheetMode;
6
+ mounted: boolean;
7
+ strings: UiStrings;
8
+ onClose: () => void;
9
+ children: React.ReactNode;
10
+ }
11
+ export declare function ChatSheet({ mode, mounted, strings, onClose, children }: ChatSheetProps): React.JSX.Element | null;
@@ -0,0 +1,19 @@
1
+ import React from 'react';
2
+ import type { WidgetProof } from '../backend/backend-transport.ts';
3
+ import type { MessageMetadata } from '../backend/message-metadata.ts';
4
+ import type { SessionRequest } from './chat-coordinator.ts';
5
+ import { type WidgetShellOptions } from './widget-shell.ts';
6
+ export interface ChatViewProps {
7
+ shell: WidgetShellOptions;
8
+ unavailableText: string;
9
+ getMetadata: (options: {
10
+ includeTextDom: boolean;
11
+ }) => Promise<MessageMetadata | null>;
12
+ getProof: () => Promise<WidgetProof | null>;
13
+ onClosed: () => void;
14
+ onSessionChanged: (sessionId: number | null) => void;
15
+ open: boolean;
16
+ sessionRequest: SessionRequest | null;
17
+ log?: (message: string) => void;
18
+ }
19
+ export declare function ChatView({ shell, unavailableText, getMetadata, getProof, onClosed, onSessionChanged, open, sessionRequest, log }: ChatViewProps): React.JSX.Element;
@@ -0,0 +1,14 @@
1
+ import React from 'react';
2
+ export interface LauncherPlacement {
3
+ side: 'left' | 'right';
4
+ offsetX: number;
5
+ offsetY: number;
6
+ }
7
+ export interface LauncherProps {
8
+ unread: number;
9
+ label: string;
10
+ color: string;
11
+ placement: LauncherPlacement;
12
+ onPress: () => void;
13
+ }
14
+ export declare function Launcher({ unread, label, color, placement, onPress }: LauncherProps): React.JSX.Element;
@@ -0,0 +1,22 @@
1
+ import { type UnknownRecord } from '../fiber/narrow.ts';
2
+ export type NativeCallName = 'metadata' | 'proof';
3
+ export type PageMessage = {
4
+ kind: 'ready';
5
+ } | {
6
+ kind: 'closed';
7
+ } | {
8
+ kind: 'session';
9
+ sessionId: number | null;
10
+ } | {
11
+ kind: 'call';
12
+ id: string;
13
+ name: NativeCallName;
14
+ args: UnknownRecord;
15
+ } | {
16
+ kind: 'log';
17
+ level: string;
18
+ text: string;
19
+ };
20
+ export declare function parsePageMessage(raw: string): PageMessage | null;
21
+ export declare function buildResolveScript(id: string, value: unknown, error: string | null): string;
22
+ export declare function buildEventScript(name: string, payload: unknown): string;
@@ -0,0 +1,57 @@
1
+ import { type NudgeView } from '../nudge/nudge.ts';
2
+ import { type ChatState } from './chat-state.ts';
3
+ export interface ChatBackend {
4
+ getSessionId: () => number | null;
5
+ openNudge: () => Promise<number | null>;
6
+ dismissNudge: (milestoneMessageId: number) => Promise<void>;
7
+ snoozeNudge: (milestoneMessageId: number) => Promise<void>;
8
+ switchSession: (sessionId: number) => Promise<void>;
9
+ }
10
+ export interface ChatEvents {
11
+ onSessionReplaced?: () => void;
12
+ }
13
+ export interface SessionRequest {
14
+ id: number;
15
+ sessionId: number;
16
+ }
17
+ export interface ChatSnapshot {
18
+ chat: ChatState;
19
+ nudge: NudgeView | null;
20
+ chatKey: number;
21
+ mounted: boolean;
22
+ sessionRequest: SessionRequest | null;
23
+ }
24
+ type Listener = (snapshot: ChatSnapshot) => void;
25
+ export declare class ChatCoordinator {
26
+ private readonly backend;
27
+ private readonly events;
28
+ private chat;
29
+ private nudge;
30
+ private nudgeLatched;
31
+ private chatKey;
32
+ private mounted;
33
+ private sessionRequest;
34
+ private snapshot;
35
+ private readonly listeners;
36
+ constructor(backend: ChatBackend, events?: ChatEvents);
37
+ getSnapshot(): ChatSnapshot;
38
+ subscribe(listener: Listener): () => void;
39
+ open(): void;
40
+ close(): void;
41
+ agentEngaged(): void;
42
+ agentReleased(): void;
43
+ handleFrame(frame: Record<string, unknown>): void;
44
+ acceptNudge(): Promise<void>;
45
+ declineNudge(): void;
46
+ snoozeNudge(): void;
47
+ reset(): void;
48
+ private followStartedSession;
49
+ private isVisibleMessage;
50
+ private surfaceNudge;
51
+ private reportAndHide;
52
+ private hideNudge;
53
+ private dispatch;
54
+ private publish;
55
+ private buildSnapshot;
56
+ }
57
+ export {};
@@ -0,0 +1,20 @@
1
+ export type SheetMode = 'closed' | 'open' | 'collapsed';
2
+ export interface ChatState {
3
+ mode: SheetMode;
4
+ unread: number;
5
+ agentWorking: boolean;
6
+ }
7
+ export type ChatEvent = {
8
+ type: 'open';
9
+ } | {
10
+ type: 'close';
11
+ } | {
12
+ type: 'agent_started';
13
+ } | {
14
+ type: 'agent_finished';
15
+ } | {
16
+ type: 'message_arrived';
17
+ };
18
+ export declare const INITIAL_CHAT_STATE: ChatState;
19
+ export declare function reduceChat(state: ChatState, event: ChatEvent): ChatState;
20
+ export declare function shouldShowLauncher(state: ChatState): boolean;
@@ -0,0 +1,5 @@
1
+ export interface ChatNavigation {
2
+ url: string;
3
+ isTopFrame: boolean;
4
+ }
5
+ export declare function leavesChat(navigation: ChatNavigation, documentUrl: string): boolean;
@@ -0,0 +1,22 @@
1
+ import type { LauncherPlacement } from './Launcher.tsx';
2
+ export interface LauncherOptions {
3
+ visible?: boolean;
4
+ side?: 'left' | 'right';
5
+ offsetX?: number;
6
+ offsetY?: number;
7
+ }
8
+ export interface ChatOptions {
9
+ enabled?: boolean;
10
+ launcher?: LauncherOptions;
11
+ primaryColor?: string;
12
+ scriptUrl?: string;
13
+ }
14
+ export interface ResolvedChatOptions {
15
+ enabled: boolean;
16
+ launcherVisible: boolean;
17
+ placement: LauncherPlacement;
18
+ primaryColor: string;
19
+ widgetColor: string | null;
20
+ scriptUrl: string | null;
21
+ }
22
+ export declare function resolveChatOptions(options: ChatOptions | undefined): ResolvedChatOptions;
@@ -0,0 +1,10 @@
1
+ import type { ComponentType, Ref } from 'react';
2
+ import type { WebViewProps } from 'react-native-webview';
3
+ export interface WebViewHandle {
4
+ injectJavaScript: (script: string) => void;
5
+ reload: () => void;
6
+ }
7
+ export type WebViewComponent = ComponentType<WebViewProps & {
8
+ ref?: Ref<WebViewHandle>;
9
+ }>;
10
+ export declare function loadWebView(): WebViewComponent | null;
@@ -0,0 +1,2 @@
1
+ export declare const WIDGET_BUNDLE_DIGEST: string | null;
2
+ export declare const WIDGET_BUNDLE: string | null;
@@ -0,0 +1,24 @@
1
+ export interface ShellIdentity {
2
+ externalId: string;
3
+ email?: string;
4
+ name?: string;
5
+ phone?: string;
6
+ contactCompany?: string;
7
+ contactCompanyExternalId?: string;
8
+ country?: string;
9
+ customFields?: Record<string, string | number | boolean>;
10
+ identityToken?: string;
11
+ identitySignature?: string;
12
+ providesProof: boolean;
13
+ }
14
+ export interface WidgetShellOptions {
15
+ bundle: string | null;
16
+ scriptUrl: string | null;
17
+ publishableKey: string;
18
+ apiBaseUrl: string;
19
+ language: 'es' | 'en';
20
+ tabId: string;
21
+ primaryColor: string | null;
22
+ identity: ShellIdentity | null;
23
+ }
24
+ export declare function buildWidgetShell(options: WidgetShellOptions): string;
@@ -0,0 +1,12 @@
1
+ import type { TargetView } from '../actions/target.ts';
2
+ import type { AgentAction, RiskLevel } from '../actions/types.ts';
3
+ export interface ConfirmationRequest {
4
+ riskLevel: RiskLevel;
5
+ action: AgentAction;
6
+ explanation: string | null;
7
+ target: TargetView | null;
8
+ }
9
+ export type ConfirmationOutcome = 'confirmed' | 'declined' | 'timed_out';
10
+ export interface ConfirmationPort {
11
+ confirm: (request: ConfirmationRequest) => Promise<ConfirmationOutcome>;
12
+ }
@@ -0,0 +1,7 @@
1
+ import type { Fiber } from './types.ts';
2
+ export interface LocatedFiber {
3
+ fiber: Fiber;
4
+ ancestors: Fiber[];
5
+ }
6
+ export declare function locateCurrent(start: Fiber, target: Fiber): LocatedFiber | null;
7
+ export declare function currentRootFiber(anchor: Fiber): Fiber | null;
@@ -0,0 +1,5 @@
1
+ export type UnknownRecord = Record<string, unknown>;
2
+ export type UnknownFunction = (...args: unknown[]) => unknown;
3
+ export declare function isRecord(value: unknown): value is UnknownRecord;
4
+ export declare function isFunction(value: unknown): value is UnknownFunction;
5
+ export declare function nonEmptyString(value: unknown): string | null;
@@ -0,0 +1,10 @@
1
+ import { type Fiber, type FiberRoot, type Props } from './types.ts';
2
+ export declare function propsOf(fiber: Fiber): Props;
3
+ export declare function childrenOf(fiber: Fiber): Fiber[];
4
+ export declare function componentName(fiber: Fiber): string;
5
+ export declare function isHostComponent(fiber: Fiber): boolean;
6
+ export declare function isHostText(fiber: Fiber): boolean;
7
+ export declare function hostRootOf(fiber: Fiber): Fiber | null;
8
+ export declare function fiberRootOf(fiber: Fiber): FiberRoot | null;
9
+ export declare function currentHostRoot(fiber: Fiber): Fiber | null;
10
+ export declare function firstHostDescendant(fiber: Fiber): Fiber | null;
@@ -0,0 +1,4 @@
1
+ import type { Fiber } from './types.ts';
2
+ export declare function normalizeText(value: string): string;
3
+ export declare function collectText(fiber: Fiber, limit: number): string;
4
+ export declare function precedingText(ancestors: Fiber[], fiber: Fiber, limit: number): string;
@@ -0,0 +1,21 @@
1
+ export type Props = Readonly<Record<string, unknown>>;
2
+ export interface Fiber {
3
+ tag: number;
4
+ key: string | null;
5
+ type: unknown;
6
+ memoizedProps: unknown;
7
+ stateNode: unknown;
8
+ child: Fiber | null;
9
+ sibling: Fiber | null;
10
+ return: Fiber | null;
11
+ alternate: Fiber | null;
12
+ }
13
+ export interface FiberRoot {
14
+ current: Fiber;
15
+ }
16
+ export declare const FiberTag: {
17
+ readonly ClassComponent: 1;
18
+ readonly HostRoot: 3;
19
+ readonly HostComponent: 5;
20
+ readonly HostText: 6;
21
+ };
@@ -0,0 +1 @@
1
+ export declare function borderRadiusOf(style: unknown): number;
@@ -0,0 +1,9 @@
1
+ import type { Fiber } from '../fiber/types.ts';
2
+ export type MeasureCallback = (x: number, y: number, width: number, height: number) => void;
3
+ export interface HostInstance {
4
+ measureInWindow: (callback: MeasureCallback) => void;
5
+ setNativeProps?: (props: Record<string, unknown>) => void;
6
+ focus?: () => void;
7
+ blur?: () => void;
8
+ }
9
+ export declare function hostInstanceOf(host: Fiber): HostInstance | null;
@@ -0,0 +1,3 @@
1
+ import type { Fiber } from '../fiber/types.ts';
2
+ import type { Rect } from './rect.ts';
3
+ export declare function measureHost(host: Fiber): Promise<Rect | null>;
@@ -0,0 +1,22 @@
1
+ export interface Rect {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ }
7
+ export interface Point {
8
+ x: number;
9
+ y: number;
10
+ }
11
+ export interface Size {
12
+ width: number;
13
+ height: number;
14
+ }
15
+ export declare function intersects(first: Rect, second: Rect): boolean;
16
+ export declare function isVisibleIn(rect: Rect, viewport: Size): boolean;
17
+ export declare function centerOf(rect: Rect): Point;
18
+ export interface Band {
19
+ top: number;
20
+ bottom: number;
21
+ }
22
+ export declare function scrollDeltaIntoBand(target: Rect, band: Band): number;
@@ -0,0 +1,2 @@
1
+ import type { Size } from './rect.ts';
2
+ export declare function visibleViewport(window: Size, keyboardHeight: number): Size;
@@ -0,0 +1,10 @@
1
+ export { BlarProvider } from './BlarProvider.tsx';
2
+ export type { BlarProviderProps } from './BlarProvider.tsx';
3
+ export { Blar } from './blar.ts';
4
+ export type { ChatControls, MessageMetadataOptions } from './blar.ts';
5
+ export type { ChatOptions, LauncherOptions } from './chat/options.ts';
6
+ export type { Language, UiStringOverrides, UiStrings } from './ui/strings.ts';
7
+ export type { NavigationRefLike } from './actions/navigation-driver.ts';
8
+ export type { BlarIdentity, BlarIdentityProofInput, CustomFields } from './backend/identity.ts';
9
+ export type { MessageMetadata } from './backend/message-metadata.ts';
10
+ export { SDK_VERSION } from './version.ts';