@blario/react-native 0.0.0-stage → 0.1.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 (313) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +377 -2
  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 +85 -4
  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 +82 -0
  250. package/src/chat/ChatView.tsx +127 -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,20 @@
1
+ import type { RegisteredElement } from '../snapshot/registry.ts';
2
+ import type { CursorPort } from './landing.ts';
3
+ import { NavigationDriver } from './navigation-driver.ts';
4
+ import { TargetResolver, type TargetView } from './target.ts';
5
+ export interface ReadingRequest extends TargetView {
6
+ text: string | null;
7
+ }
8
+ export interface ReadingPort {
9
+ read: (request: ReadingRequest) => Promise<boolean>;
10
+ }
11
+ export interface InputMemory {
12
+ last: RegisteredElement | null;
13
+ }
14
+ export interface ActionServices {
15
+ resolver: TargetResolver;
16
+ navigation: NavigationDriver;
17
+ reading: ReadingPort;
18
+ cursor: CursorPort;
19
+ inputMemory: InputMemory;
20
+ }
@@ -0,0 +1,13 @@
1
+ export interface SettleOptions {
2
+ minWaitMs: number;
3
+ quietMs: number;
4
+ capMs: number;
5
+ pollMs: number;
6
+ }
7
+ export interface Clock {
8
+ now: () => number;
9
+ sleep: (milliseconds: number) => Promise<void>;
10
+ }
11
+ export declare const DEFAULT_SETTLE: SettleOptions;
12
+ export declare const SYSTEM_CLOCK: Clock;
13
+ export declare function waitForSettle(sample: () => Promise<string>, options?: SettleOptions, clock?: Clock): Promise<string>;
@@ -0,0 +1,3 @@
1
+ import type { ResolvedTarget } from './target.ts';
2
+ import type { HandlerResult } from './types.ts';
3
+ export declare function toggleSwitch(target: ResolvedTarget, desired: boolean | null): HandlerResult;
@@ -0,0 +1,25 @@
1
+ import type { Band, Rect } from '../host/rect.ts';
2
+ import type { Fiber, Props } from '../fiber/types.ts';
3
+ import { ElementRegistry, type RegisteredElement } from '../snapshot/registry.ts';
4
+ export interface ResolvedTarget {
5
+ element: RegisteredElement;
6
+ fiber: Fiber;
7
+ ancestors: Fiber[];
8
+ props: Props;
9
+ host: Fiber | null;
10
+ }
11
+ export declare class TargetResolver {
12
+ private readonly registry;
13
+ private readonly getAnchorFiber;
14
+ constructor(registry: ElementRegistry, getAnchorFiber: () => Fiber | null);
15
+ resolveAgentId(agentId: string): ResolvedTarget | null;
16
+ resolveElement(element: RegisteredElement): ResolvedTarget | null;
17
+ }
18
+ export interface TargetView {
19
+ measure: () => Promise<Rect | null>;
20
+ radius: number;
21
+ reveal?: (band: Band) => Promise<void>;
22
+ }
23
+ export declare function measureTarget(target: ResolvedTarget): () => Promise<Rect | null>;
24
+ export declare function viewOf(target: ResolvedTarget): TargetView;
25
+ export declare function nameOf(target: ResolvedTarget): string | null;
@@ -0,0 +1,9 @@
1
+ import type { ActionServices } from './services.ts';
2
+ import type { ResolvedTarget } from './target.ts';
3
+ import type { AgentAction, HandlerResult } from './types.ts';
4
+ type TypeAction = Extract<AgentAction, {
5
+ type: 'type';
6
+ }>;
7
+ export declare function typeText(target: ResolvedTarget, action: TypeAction, services: ActionServices): HandlerResult;
8
+ export declare function submitInput(target: ResolvedTarget): HandlerResult;
9
+ export {};
@@ -0,0 +1,59 @@
1
+ import type { UnknownRecord } from '../fiber/narrow.ts';
2
+ export type ScrollDirectionName = 'up' | 'down' | 'left' | 'right';
3
+ export type AgentAction = {
4
+ type: 'click';
5
+ } | {
6
+ type: 'type';
7
+ value: string;
8
+ clear_first: boolean;
9
+ } | {
10
+ type: 'check';
11
+ checked: boolean | null;
12
+ } | {
13
+ type: 'press_key';
14
+ key: string;
15
+ } | {
16
+ type: 'scroll';
17
+ direction: ScrollDirectionName;
18
+ amount: number | null;
19
+ } | {
20
+ type: 'scroll_to';
21
+ } | {
22
+ type: 'navigate';
23
+ route: string;
24
+ params: UnknownRecord | null;
25
+ } | {
26
+ type: 'highlight';
27
+ };
28
+ export type ActionErrorCode = 'element_not_found' | 'element_not_interactable' | 'unsupported_action' | 'execution_error' | 'user_cancelled' | 'timeout';
29
+ export type RiskLevel = 'safe' | 'reversible' | 'irreversible' | 'destructive';
30
+ export type FailedResult = {
31
+ ok: false;
32
+ error: ActionErrorCode;
33
+ message: string;
34
+ };
35
+ export type HandlerResult = {
36
+ ok: true;
37
+ message?: string;
38
+ } | FailedResult;
39
+ export interface ActionOutcome {
40
+ success: boolean;
41
+ no_op: boolean;
42
+ error?: ActionErrorCode;
43
+ message?: string;
44
+ }
45
+ export interface PageContentRequest {
46
+ viewportOnly: boolean;
47
+ maxChars: number;
48
+ }
49
+ export interface AgentCommandData {
50
+ command_id: string;
51
+ action: AgentAction;
52
+ agent_id: string | null;
53
+ risk_level: RiskLevel;
54
+ confirmation_required: boolean;
55
+ teaching_explanation: string | null;
56
+ include_page_content: boolean;
57
+ page_content_options: PageContentRequest;
58
+ dom_settle_ms: number;
59
+ }
@@ -0,0 +1,17 @@
1
+ import type { AgentCommandData, PageContentRequest } from '../actions/types.ts';
2
+ export type BatchEntry = {
3
+ kind: 'action';
4
+ command: AgentCommandData;
5
+ } | {
6
+ kind: 'dom_state';
7
+ commandId: string;
8
+ } | {
9
+ kind: 'text_dom';
10
+ commandId: string;
11
+ options: PageContentRequest;
12
+ } | {
13
+ kind: 'invalid';
14
+ commandId: string;
15
+ reason: string;
16
+ };
17
+ export declare function parseBatchEntries(data: unknown): BatchEntry[];
@@ -0,0 +1,23 @@
1
+ import { type NavigationRefLike } from '../actions/navigation-driver.ts';
2
+ import type { CursorPort } from '../actions/landing.ts';
3
+ import type { ReadingPort } from '../actions/services.ts';
4
+ import type { Fiber } from '../fiber/types.ts';
5
+ import type { Size } from '../host/rect.ts';
6
+ import type { ConfirmationPort } from '../confirmation/port.ts';
7
+ import type { AgentStage } from './stage.ts';
8
+ import type { AgentTransport } from '../transport/transport.ts';
9
+ import { AgentController } from './controller.ts';
10
+ export interface AgentEnvironment {
11
+ transport: AgentTransport;
12
+ getAnchorFiber: () => Fiber | null;
13
+ getViewport: () => Size;
14
+ getNavigationRef: () => NavigationRefLike | null;
15
+ getCaptureTarget: () => unknown;
16
+ reading: ReadingPort;
17
+ cursor: CursorPort;
18
+ confirmation: ConfirmationPort;
19
+ stage: AgentStage;
20
+ onCommit?: () => void;
21
+ onSettled?: () => void;
22
+ }
23
+ export declare function createAgentController(environment: AgentEnvironment): AgentController;
@@ -0,0 +1,28 @@
1
+ import type { CommitWatch } from '../actions/commit-watch.ts';
2
+ import { type MessageMetadata } from '../backend/message-metadata.ts';
3
+ import type { Size } from '../host/rect.ts';
4
+ import type { AgentTransport } from '../transport/transport.ts';
5
+ import type { HandlerContext } from './handlers/context.ts';
6
+ export interface ControllerDependencies {
7
+ transport: AgentTransport;
8
+ commitWatch: CommitWatch;
9
+ getViewport: () => Size;
10
+ context: Omit<HandlerContext, 'send'>;
11
+ onSettled?: () => void;
12
+ }
13
+ export declare class AgentController {
14
+ private readonly dependencies;
15
+ private queue;
16
+ private readonly context;
17
+ constructor(dependencies: ControllerDependencies);
18
+ start(): void;
19
+ stop(): void;
20
+ readMessageMetadata(options: {
21
+ includeTextDom: boolean;
22
+ tabId: string;
23
+ }): Promise<MessageMetadata>;
24
+ private receive;
25
+ private handle;
26
+ private route;
27
+ private send;
28
+ }
@@ -0,0 +1,9 @@
1
+ import type { RoutedFrame } from './frames.ts';
2
+ import type { Admission, AgentStage } from './stage.ts';
3
+ export declare function admissionFor(frame: RoutedFrame): Admission | null;
4
+ export interface FrameRunnerOptions {
5
+ stage: AgentStage;
6
+ handle: (frame: RoutedFrame) => Promise<void>;
7
+ onSettled?: () => void;
8
+ }
9
+ export declare function runFrame(frame: RoutedFrame, options: FrameRunnerOptions): Promise<void>;
@@ -0,0 +1,180 @@
1
+ import type { ActionErrorCode, ActionOutcome, PageContentRequest } from '../actions/types.ts';
2
+ export interface ScreenshotOptions {
3
+ quality: number;
4
+ maxWidth: number;
5
+ }
6
+ export type InboundFrame = {
7
+ kind: 'ping';
8
+ } | {
9
+ kind: 'agent_command';
10
+ commandId: string;
11
+ data: unknown;
12
+ } | {
13
+ kind: 'agent_command_batch';
14
+ commandId: string;
15
+ data: unknown;
16
+ } | {
17
+ kind: 'request_dom_state';
18
+ commandId: string;
19
+ } | {
20
+ kind: 'request_text_dom';
21
+ commandId: string;
22
+ options: PageContentRequest;
23
+ } | {
24
+ kind: 'request_screenshot';
25
+ commandId: string;
26
+ options: ScreenshotOptions;
27
+ } | {
28
+ kind: 'request_element_context';
29
+ commandId: string;
30
+ agentIds: string[];
31
+ } | {
32
+ kind: 'unknown';
33
+ name: string;
34
+ };
35
+ export type RoutedFrame = Exclude<InboundFrame, {
36
+ kind: 'ping' | 'unknown';
37
+ }>;
38
+ export interface DomStateResponseData {
39
+ schema_version: 3;
40
+ platform: 'react-native';
41
+ url: string;
42
+ title: string;
43
+ screen: string;
44
+ routes: string[];
45
+ html_snapshot: string;
46
+ }
47
+ export interface TextDomResponseData {
48
+ url: string;
49
+ title: string;
50
+ screen: string;
51
+ text_tree: string;
52
+ refs: never[];
53
+ }
54
+ export interface BoundingBox {
55
+ x: number;
56
+ y: number;
57
+ width: number;
58
+ height: number;
59
+ }
60
+ export interface ElementContextItem {
61
+ agent_id: string;
62
+ found: boolean;
63
+ tag_name?: string;
64
+ visible?: boolean;
65
+ line?: string;
66
+ bounding_box?: BoundingBox;
67
+ text_content?: string;
68
+ placeholder?: string;
69
+ nearest_label?: string;
70
+ sibling_text?: string[];
71
+ }
72
+ export interface ElementContextResponseData {
73
+ elements: ElementContextItem[];
74
+ }
75
+ export type PageContentSkipReason = 'no_op';
76
+ export interface AgentCommandResponseData extends ActionOutcome {
77
+ page_content?: TextDomResponseData;
78
+ page_content_skipped?: PageContentSkipReason;
79
+ }
80
+ export interface BatchActionResult {
81
+ command_id: string;
82
+ success: boolean;
83
+ message: string;
84
+ error?: ActionErrorCode;
85
+ no_op?: boolean;
86
+ total_duration_ms: number;
87
+ }
88
+ export interface BatchDomStateResult {
89
+ command_id: string;
90
+ type: 'dom_state';
91
+ dom_state: DomStateResponseData;
92
+ total_duration_ms: number;
93
+ }
94
+ export interface BatchTextDomResult {
95
+ command_id: string;
96
+ type: 'text_dom';
97
+ text_dom: TextDomResponseData;
98
+ total_duration_ms: number;
99
+ }
100
+ export type BatchCommandResult = BatchActionResult | BatchDomStateResult | BatchTextDomResult;
101
+ export interface BatchResponseData {
102
+ results: BatchCommandResult[];
103
+ stopped_at: number | null;
104
+ stopped_reason?: 'cancelled' | 'check_unreached';
105
+ }
106
+ export interface ScreenshotResponseData {
107
+ success: true;
108
+ image: string;
109
+ format: 'jpeg';
110
+ screen: string;
111
+ timestamp: number;
112
+ partial?: true;
113
+ omitted?: Array<'modal'>;
114
+ }
115
+ export interface ConsentScreenshotMetadata {
116
+ action_type: string;
117
+ element_description: string;
118
+ url: string;
119
+ }
120
+ export type ConsentScreenshotData = {
121
+ success: true;
122
+ image: string;
123
+ screenshot_metadata: ConsentScreenshotMetadata;
124
+ capture_duration_ms: number;
125
+ sent_at: number;
126
+ } | {
127
+ success: false;
128
+ screenshot_error: 'CAPTURE_FAILED';
129
+ sent_at: number;
130
+ };
131
+ export type OutboundFrame = {
132
+ type: 'command_ack';
133
+ command_id: string;
134
+ } | {
135
+ type: 'pong';
136
+ } | {
137
+ type: 'sdk_response';
138
+ command_id: string;
139
+ response_type: 'dom_state_response';
140
+ data: DomStateResponseData;
141
+ } | {
142
+ type: 'sdk_response';
143
+ command_id: string;
144
+ response_type: 'text_dom_response';
145
+ data: TextDomResponseData;
146
+ } | {
147
+ type: 'sdk_response';
148
+ command_id: string;
149
+ response_type: 'element_context_response';
150
+ data: ElementContextResponseData;
151
+ } | {
152
+ type: 'sdk_response';
153
+ command_id: string;
154
+ response_type: 'agent_command_response';
155
+ data: AgentCommandResponseData;
156
+ } | {
157
+ type: 'sdk_response';
158
+ command_id: string;
159
+ response_type: 'agent_command_response';
160
+ data: ConsentScreenshotData;
161
+ } | {
162
+ type: 'sdk_response';
163
+ command_id: string;
164
+ response_type: 'agent_command_batch_response';
165
+ data: BatchResponseData;
166
+ } | {
167
+ type: 'sdk_response';
168
+ command_id: string;
169
+ response_type: 'screenshot_response';
170
+ data: ScreenshotResponseData;
171
+ } | {
172
+ type: 'sdk_error';
173
+ command_id: string;
174
+ error: string;
175
+ code?: string;
176
+ } | {
177
+ type: 'agent_cancel';
178
+ reason: string;
179
+ };
180
+ export declare function parseInboundFrame(raw: string): InboundFrame | null;
@@ -0,0 +1,5 @@
1
+ import type { AgentCommandData } from '../../actions/types.ts';
2
+ import type { AgentCommandResponseData } from '../frames.ts';
3
+ import type { HandlerContext } from './context.ts';
4
+ export declare function runAgentCommand(context: HandlerContext, command: AgentCommandData): Promise<AgentCommandResponseData>;
5
+ export declare function handleAgentCommand(context: HandlerContext, commandId: string, data: unknown): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import { type BatchEntry } from '../batch-commands.ts';
2
+ import type { BatchResponseData } from '../frames.ts';
3
+ import type { HandlerContext } from './context.ts';
4
+ export declare function runBatch(context: HandlerContext, entries: BatchEntry[]): Promise<BatchResponseData>;
5
+ export declare function handleBatch(context: HandlerContext, batchId: string, data: unknown): Promise<void>;
@@ -0,0 +1,4 @@
1
+ import { type ResolvedTarget } from '../../actions/target.ts';
2
+ import type { AgentCommandData } from '../../actions/types.ts';
3
+ import type { HandlerContext } from './context.ts';
4
+ export declare function sendConsentScreenshot(context: HandlerContext, command: AgentCommandData, target: ResolvedTarget | null): Promise<void>;
@@ -0,0 +1,16 @@
1
+ import type { ActionExecutor } from '../../actions/executor.ts';
2
+ import type { ConfirmationPort } from '../../confirmation/port.ts';
3
+ import type { Screenshotter } from '../../screenshot/screenshotter.ts';
4
+ import type { SnapshotCapturer } from '../../snapshot/capture.ts';
5
+ import type { ElementContextReader } from '../../snapshot/element-context.ts';
6
+ import type { OutboundFrame } from '../frames.ts';
7
+ import type { AgentStage } from '../stage.ts';
8
+ export interface HandlerContext {
9
+ capturer: SnapshotCapturer;
10
+ executor: ActionExecutor;
11
+ screenshotter: Screenshotter;
12
+ elementContext: ElementContextReader;
13
+ confirmation: ConfirmationPort;
14
+ stage: AgentStage;
15
+ send: (frame: OutboundFrame) => void;
16
+ }
@@ -0,0 +1,4 @@
1
+ import type { DomStateResponseData } from '../frames.ts';
2
+ import type { HandlerContext } from './context.ts';
3
+ export declare function readDomState(context: HandlerContext): Promise<DomStateResponseData>;
4
+ export declare function handleDomState(context: HandlerContext, commandId: string): Promise<void>;
@@ -0,0 +1,2 @@
1
+ import type { HandlerContext } from './context.ts';
2
+ export declare function handleElementContext(context: HandlerContext, commandId: string, agentIds: string[]): Promise<void>;
@@ -0,0 +1,3 @@
1
+ import type { ScreenshotOptions } from '../frames.ts';
2
+ import type { HandlerContext } from './context.ts';
3
+ export declare function handleScreenshot(context: HandlerContext, commandId: string, options: ScreenshotOptions): Promise<void>;
@@ -0,0 +1,5 @@
1
+ import type { PageContentRequest } from '../../actions/types.ts';
2
+ import type { TextDomResponseData } from '../frames.ts';
3
+ import type { HandlerContext } from './context.ts';
4
+ export declare function readTextDom(context: HandlerContext, options: PageContentRequest): Promise<TextDomResponseData>;
5
+ export declare function handleTextDom(context: HandlerContext, commandId: string, options: PageContentRequest): Promise<void>;
@@ -0,0 +1,13 @@
1
+ import type { AgentCommandData } from '../actions/types.ts';
2
+ export interface Admission {
3
+ kind: 'command' | 'batch';
4
+ keepText: string | null;
5
+ }
6
+ export interface AgentStage {
7
+ received: () => void;
8
+ admit: (admission: Admission) => Promise<boolean>;
9
+ beforeAction: (command: AgentCommandData) => void;
10
+ settled: () => void;
11
+ isCancelled: () => boolean;
12
+ }
13
+ export declare const OPEN_STAGE: AgentStage;
@@ -0,0 +1,3 @@
1
+ import type { AgentAction } from '../actions/types.ts';
2
+ import type { UiStrings } from '../ui/strings.ts';
3
+ export declare function describeAction(action: AgentAction, strings: UiStrings): string;
@@ -0,0 +1,10 @@
1
+ export interface AgentBubble {
2
+ id: string;
3
+ text: string;
4
+ leaving: boolean;
5
+ }
6
+ export declare function readingTimeMs(text: string): number;
7
+ export declare function isShowing(bubbles: readonly AgentBubble[], text: string): boolean;
8
+ export declare function keepOnly(bubbles: readonly AgentBubble[], keepText: string | null): AgentBubble[];
9
+ export declare function markLeaving(bubbles: readonly AgentBubble[], id: string): AgentBubble[];
10
+ export declare function without(bubbles: readonly AgentBubble[], id: string): AgentBubble[];
@@ -0,0 +1,12 @@
1
+ export interface Rgb {
2
+ r: number;
3
+ g: number;
4
+ b: number;
5
+ }
6
+ export declare function parseHex(color: string): Rgb | null;
7
+ export declare function luminance(color: string): number | null;
8
+ export declare const ON_LIGHT = "#14161a";
9
+ export declare const ON_DARK = "#ffffff";
10
+ /** Text that reads on a brand-coloured surface: near-black on a light brand, white otherwise. */
11
+ export declare function onColor(color: string): string;
12
+ export declare function withAlpha(color: string, alpha: number): string;
@@ -0,0 +1,92 @@
1
+ import type { AgentCommandData } from '../actions/types.ts';
2
+ import type { Admission, AgentStage } from '../agent/stage.ts';
3
+ import { type AgentBubble } from './bubbles.ts';
4
+ import { type AgentModeEvent } from './frames.ts';
5
+ import type { KeepAwake } from './keep-awake.ts';
6
+ import { type RunMemory } from './run-memory.ts';
7
+ import { type AgentModePhase } from './state.ts';
8
+ import { type AgentStatus } from './status.ts';
9
+ import { type Timers } from './timers.ts';
10
+ export type CancelReason = 'user_requested' | 'user_cancelled';
11
+ export type ResumeDecision = 'resumed' | 'discarded' | 'kept' | 'none';
12
+ export interface QueuedChip {
13
+ message: string | null;
14
+ }
15
+ export interface AgentModeSnapshot {
16
+ phase: AgentModePhase;
17
+ status: AgentStatus;
18
+ bubbles: AgentBubble[];
19
+ queued: QueuedChip | null;
20
+ }
21
+ export interface AgentModeEffects {
22
+ sendCancel: (reason: CancelReason) => void;
23
+ onActive: () => void;
24
+ onIdle: () => void;
25
+ }
26
+ type Listener = (snapshot: AgentModeSnapshot) => void;
27
+ export declare const PENDING_MS = 2000;
28
+ export declare const RUN_IDLE_TIMEOUT_MS = 120000;
29
+ export declare const QUEUED_CHIP_MS = 5000;
30
+ export declare const BUBBLE_EXIT_MS = 300;
31
+ export declare const HANDOFF_WAIT_MS = 30000;
32
+ export declare class AgentModeController implements AgentStage {
33
+ private readonly effects;
34
+ private readonly keepAwake;
35
+ private readonly memory;
36
+ private readonly timers;
37
+ private readonly machine;
38
+ private readonly listeners;
39
+ private readonly bubbleTimers;
40
+ private waiting;
41
+ private status;
42
+ private bubbles;
43
+ private queued;
44
+ private runGeneration;
45
+ private cancelledRun;
46
+ private bubbleCounter;
47
+ private pendingTimer;
48
+ private watchdog;
49
+ private queuedTimer;
50
+ private handoffWatchdog;
51
+ private absorbCompletion;
52
+ private snapshot;
53
+ constructor(effects: AgentModeEffects, keepAwake: KeepAwake, memory?: RunMemory, timers?: Timers);
54
+ getSnapshot(): AgentModeSnapshot;
55
+ subscribe(listener: Listener): () => void;
56
+ connecting(sessionId: number): ResumeDecision;
57
+ received(): void;
58
+ admit(admission: Admission): Promise<boolean>;
59
+ beforeAction(command: AgentCommandData): void;
60
+ settled(): void;
61
+ isCancelled(): boolean;
62
+ stop(): void;
63
+ endClosedRun(): void;
64
+ socketFailed(): void;
65
+ handleEvent(event: AgentModeEvent): void;
66
+ dispose(): void;
67
+ private enterPending;
68
+ private finishPending;
69
+ private enterActive;
70
+ private applyHistory;
71
+ private openRun;
72
+ private latch;
73
+ private exit;
74
+ private leavePending;
75
+ private teardown;
76
+ private showProgress;
77
+ private showMessage;
78
+ private showQueued;
79
+ private showBubble;
80
+ private replaceBubbles;
81
+ private noteActivity;
82
+ private rememberRun;
83
+ private beginHandoffWait;
84
+ private armHandoffWatchdog;
85
+ private noteHandoffActivity;
86
+ private clearHandoffWait;
87
+ private armWatchdog;
88
+ private clearTimer;
89
+ private publish;
90
+ private buildSnapshot;
91
+ }
92
+ export {};
@@ -0,0 +1,12 @@
1
+ import type { Clock } from '../actions/settle.ts';
2
+ import type { Rect } from '../host/rect.ts';
3
+ export declare const FOLLOW_MIN_MS = 350;
4
+ export declare const FOLLOW_MAX_MS = 1400;
5
+ export declare const FOLLOW_POLL_MS = 33;
6
+ export interface Follow {
7
+ measure: () => Promise<Rect | null>;
8
+ place: (rect: Rect) => void;
9
+ isLive: () => boolean;
10
+ clock: Clock;
11
+ }
12
+ export declare function followUntilLanded({ measure, place, isLive, clock }: Follow): Promise<void>;
@@ -0,0 +1,37 @@
1
+ import type { Clock } from '../actions/settle.ts';
2
+ import type { Rect } from '../host/rect.ts';
3
+ export interface CursorSnapshot {
4
+ tap: number;
5
+ target: Rect | null;
6
+ landed: boolean;
7
+ }
8
+ export interface CursorEnvironment {
9
+ clock: Clock;
10
+ isForeground: () => boolean;
11
+ }
12
+ type Listener = (snapshot: CursorSnapshot) => void;
13
+ export declare const ATTACH_MAX_MS = 1000;
14
+ export declare const PRESS_MS = 450;
15
+ export declare class CursorController {
16
+ private readonly environment;
17
+ private snapshot;
18
+ private readonly listeners;
19
+ private arrival;
20
+ private sessionEnded;
21
+ private move;
22
+ private attached;
23
+ private onAttached;
24
+ constructor(environment: CursorEnvironment);
25
+ getSnapshot(): CursorSnapshot;
26
+ subscribe(listener: Listener): () => void;
27
+ beginSession(): void;
28
+ moveTo(measure: () => Promise<Rect | null>): void;
29
+ attach(): void;
30
+ detach(): void;
31
+ whenLanded(): Promise<void>;
32
+ endSession(): void;
33
+ private tap;
34
+ private untilAttached;
35
+ private publish;
36
+ }
37
+ export {};