@avasapp/agent-bridge 0.4.2 → 0.6.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 (65) hide show
  1. package/README.md +36 -14
  2. package/dist/adapters/ably.cjs +79 -3
  3. package/dist/adapters/ably.d.cts +2 -1
  4. package/dist/adapters/async-storage.cjs +158 -0
  5. package/dist/adapters/async-storage.d.cts +14 -0
  6. package/dist/adapters/device.cjs +1110 -0
  7. package/dist/adapters/device.d.cts +49 -0
  8. package/dist/adapters/expo-router.cjs +112 -6
  9. package/dist/adapters/expo-router.d.cts +1 -1
  10. package/dist/adapters/jotai.cjs +266 -0
  11. package/dist/adapters/jotai.d.cts +19 -0
  12. package/dist/adapters/react-native-mmkv.cjs +80 -0
  13. package/dist/adapters/react-native-mmkv.d.cts +3 -1
  14. package/dist/adapters/react-native-webview.d.cts +1 -1
  15. package/dist/adapters/react-navigation.cjs +293 -0
  16. package/dist/adapters/react-navigation.d.cts +55 -0
  17. package/dist/adapters/redux.cjs +322 -0
  18. package/dist/adapters/redux.d.cts +28 -0
  19. package/dist/adapters/secure-store.cjs +169 -0
  20. package/dist/adapters/secure-store.d.cts +28 -0
  21. package/dist/adapters/socket-io.cjs +77 -3
  22. package/dist/adapters/socket-io.d.cts +2 -1
  23. package/dist/adapters/tanstack-query.cjs +3 -0
  24. package/dist/adapters/tanstack-query.d.cts +13 -4
  25. package/dist/adapters/zustand.cjs +193 -22
  26. package/dist/adapters/zustand.d.cts +11 -15
  27. package/dist/{chunk-TA2OLPPT.js → chunk-Y6QFU5ON.js} +477 -165
  28. package/dist/cli.js +2370 -103
  29. package/dist/client/index.cjs +441 -136
  30. package/dist/client/index.d.ts +67 -4
  31. package/dist/client/index.js +5 -3
  32. package/dist/expo/index.d.cts +1 -1
  33. package/dist/network/index.cjs +320 -73
  34. package/dist/network/index.d.cts +18 -3
  35. package/dist/noop/async-storage.cjs +26 -0
  36. package/dist/noop/device.cjs +26 -0
  37. package/dist/noop/jotai.cjs +26 -0
  38. package/dist/noop/react-navigation.cjs +26 -0
  39. package/dist/noop/realtime.cjs +6 -1
  40. package/dist/noop/redux.cjs +28 -0
  41. package/dist/noop/secure-store.cjs +26 -0
  42. package/dist/realtime/index.cjs +71 -4
  43. package/dist/realtime/index.d.cts +21 -2
  44. package/dist/runtime/index.cjs +838 -128
  45. package/dist/runtime/index.d.cts +4 -2
  46. package/dist/store-common-j0cHHvBr.d.cts +23 -0
  47. package/dist/{types-BmpykP1P.d.cts → types-qlwdcGjt.d.cts} +22 -0
  48. package/entries/async-storage.cjs +9 -0
  49. package/entries/device.cjs +9 -0
  50. package/entries/jotai.cjs +9 -0
  51. package/entries/react-navigation.cjs +9 -0
  52. package/entries/redux.cjs +9 -0
  53. package/entries/secure-store.cjs +9 -0
  54. package/package.json +34 -2
  55. package/skills/agent-bridge/SKILL.md +70 -22
  56. package/skills/agent-bridge/references/device.md +21 -0
  57. package/skills/agent-bridge/references/flows.md +19 -8
  58. package/skills/agent-bridge/references/large-data.md +6 -6
  59. package/skills/agent-bridge/references/network.md +25 -7
  60. package/skills/agent-bridge/references/realtime.md +5 -5
  61. package/skills/agent-bridge/references/restore.md +25 -7
  62. package/skills/agent-bridge/references/screen.md +25 -11
  63. package/skills/agent-bridge/references/state.md +31 -11
  64. package/skills/agent-bridge/references/webview.md +9 -9
  65. package/skills/agent-bridge/references/writing-scenarios.md +3 -3
@@ -44,9 +44,29 @@ type FlowApi = {
44
44
  step: (label: string, tool: string, ...args: unknown[]) => Promise<unknown>;
45
45
  /** What each declared scenario's apply returned, by name. */
46
46
  scenarios: Record<string, unknown>;
47
+ expect: FlowExpect;
48
+ };
49
+ /** Checks that throw a readable message; each runs as a timed step. */
50
+ type FlowExpect = {
51
+ /** Text, label or testID is on screen (waits up to `timeoutMs`, default 5000). */
52
+ text: (target: string, options?: {
53
+ timeoutMs?: number;
54
+ }) => Promise<void>;
55
+ /** The target is not on screen (waits for it to leave). */
56
+ gone: (target: string, options?: {
57
+ timeoutMs?: number;
58
+ }) => Promise<void>;
59
+ /** `router.current` has this pathname (waits up to `timeoutMs`, default 2000). */
60
+ route: (pathname: string, options?: {
61
+ timeoutMs?: number;
62
+ }) => Promise<void>;
63
+ /** A tool's result contains `match`: objects by the keys given, arrays and values exactly. */
64
+ result: (tool: string, args: unknown[], match: unknown) => Promise<void>;
47
65
  };
48
66
  /** A flow file: `export default async ({ step, call }) => {}`, plus what it needs. */
49
67
  type FlowModule = {
68
+ /** Shown in the run summary and matched by `--grep`; default: the file name. */
69
+ name?: string;
50
70
  default: (api: FlowApi) => Promise<void>;
51
71
  /** Applied before the flow and undone after it, even when it fails. */
52
72
  scenario?: FlowScenario;
@@ -60,6 +80,13 @@ type FlowResult = {
60
80
  restoreErrors: string[];
61
81
  /** "app reloaded; N pending restores lost" warnings seen during the flow. */
62
82
  notices: string[];
83
+ /** The app stopped answering (a timeout or closed connection), so no restore was tried. */
84
+ unreachable: boolean;
85
+ };
86
+ /** What was on screen when a flow failed. */
87
+ type FailureState = {
88
+ screen?: string[];
89
+ route?: unknown;
63
90
  };
64
91
  type RunFlowOptions = {
65
92
  /** Where step lines go. Default: console.log. */
@@ -69,14 +96,50 @@ type RunFlowOptions = {
69
96
  name: string;
70
97
  options?: unknown;
71
98
  }>;
99
+ /** Leave the app as the flow left it: no closing bridge.restore (for debugging). */
100
+ keep?: boolean;
101
+ /** Called with what was on screen when the flow failed. */
102
+ onFailure?: (state: FailureState) => void;
103
+ /** Called once the flow and its restore are done, also when it failed. */
104
+ onFinish?: (result: FlowResult) => void;
72
105
  };
73
106
  /**
74
- * Runs a flow module you imported: applies its scenarios, runs it, and when
75
- * there were any, undoes everything with bridge.restore afterwards, even
107
+ * Runs a flow module you imported: applies its scenarios, runs it, and
108
+ * undoes everything with bridge.restore afterwards (unless `keep`), even
76
109
  * when it fails. Throws what the flow threw; otherwise returns how it went.
77
110
  * It runs only the code you hand it, in this process.
78
111
  */
79
112
  declare function runFlow(bridge: AgentBridge, flow: FlowModule, options?: RunFlowOptions): Promise<FlowResult>;
113
+ type FlowEntry = {
114
+ file: string;
115
+ name: string;
116
+ module: FlowModule;
117
+ };
118
+ type FlowRun = {
119
+ file: string;
120
+ name: string;
121
+ status: 'passed' | 'failed' | 'skipped';
122
+ ms: number;
123
+ steps: number;
124
+ errors: number;
125
+ /** Why it failed: what the flow threw, restore failures, or app errors under `strict`. */
126
+ error?: string;
127
+ state?: FailureState;
128
+ restoreErrors: string[];
129
+ notices: string[];
130
+ };
131
+ type RunFlowsOptions = RunFlowOptions & {
132
+ /** Stop at the first failure; the rest are reported as skipped. */
133
+ bail?: boolean;
134
+ /** Count an error the app logged as a failure. */
135
+ strict?: boolean;
136
+ /** One flow, text output: no name header, and the failure goes to `printError`. */
137
+ single?: boolean;
138
+ /** Where a failed flow's reason goes when `single`. Default: console.error. */
139
+ printError?: (line: string) => void;
140
+ };
141
+ /** Runs flows in order on one connection, each followed by a restore (see `keep`), and never throws for a failing flow. */
142
+ declare function runFlows(bridge: AgentBridge, entries: FlowEntry[], options?: RunFlowsOptions): Promise<FlowRun[]>;
80
143
 
81
144
  /** What a running session writes next to its socket. Readable only by the user. */
82
145
  type SessionState = {
@@ -126,7 +189,7 @@ type ConnectOptions = {
126
189
  device?: string;
127
190
  /** "auto" tries Expo's socket first and falls back to CDP. */
128
191
  transport?: 'auto' | TransportName;
129
- /** Per-call timeout. Default 10 s. */
192
+ /** Per-call timeout. Default 10 s; stretched when a call's own `timeoutMs` argument is longer. */
130
193
  timeoutMs?: number;
131
194
  };
132
195
  declare class AgentBridgeCallError extends Error {
@@ -170,4 +233,4 @@ type ListedDevice = {
170
233
  /** Apps with the bridge on Expo's socket, plus every React Native page Metro knows. */
171
234
  declare function listDevices(options?: Pick<ConnectOptions, 'metro'>): Promise<ListedDevice[]>;
172
235
 
173
- export { type AgentBridge, AgentBridgeCallError, type ConnectOptions, type DeviceInfo, type FlowApi, type FlowModule, type FlowResult, type FlowScenario, type ListedDevice, type LogEntry, type RunFlowOptions, type SessionConnectOptions, type SessionState, type Timed, type ToolInfo, type TransportName, connect, connectSession, listDevices, listSessions, runFlow };
236
+ export { type AgentBridge, AgentBridgeCallError, type ConnectOptions, type DeviceInfo, type FlowApi, type FlowExpect, type FlowModule, type FlowResult, type FlowRun, type FlowScenario, type ListedDevice, type LogEntry, type RunFlowOptions, type SessionConnectOptions, type SessionState, type Timed, type ToolInfo, type TransportName, connect, connectSession, listDevices, listSessions, runFlow, runFlows };
@@ -4,13 +4,15 @@ import {
4
4
  connectSession,
5
5
  listDevices,
6
6
  listSessions,
7
- runFlow
8
- } from "../chunk-TA2OLPPT.js";
7
+ runFlow,
8
+ runFlows
9
+ } from "../chunk-Y6QFU5ON.js";
9
10
  export {
10
11
  AgentBridgeCallError,
11
12
  connect,
12
13
  connectSession,
13
14
  listDevices,
14
15
  listSessions,
15
- runFlow
16
+ runFlow,
17
+ runFlows
16
18
  };
@@ -1,4 +1,4 @@
1
- import { a as Transport } from '../types-BmpykP1P.cjs';
1
+ import { a as Transport } from '../types-qlwdcGjt.cjs';
2
2
 
3
3
  /**
4
4
  * Plain JSON over Expo's dev-tools plugin socket: no string evaluation, emoji