@avasapp/agent-bridge 0.2.0 → 0.4.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 (35) hide show
  1. package/README.md +220 -20
  2. package/dist/adapters/ably.cjs +22 -4
  3. package/dist/adapters/ably.d.cts +8 -1
  4. package/dist/adapters/expo-router.cjs +22 -1
  5. package/dist/adapters/expo-router.d.cts +5 -1
  6. package/dist/adapters/react-native-mmkv.cjs +1 -0
  7. package/dist/adapters/react-native-mmkv.d.cts +1 -1
  8. package/dist/adapters/react-native-webview.cjs +672 -0
  9. package/dist/adapters/react-native-webview.d.cts +79 -0
  10. package/dist/adapters/socket-io.cjs +3 -1
  11. package/dist/adapters/socket-io.d.cts +1 -1
  12. package/dist/adapters/tanstack-query.cjs +256 -17
  13. package/dist/adapters/tanstack-query.d.cts +1 -1
  14. package/dist/adapters/zustand.cjs +152 -12
  15. package/dist/adapters/zustand.d.cts +19 -3
  16. package/dist/{chunk-LBYZ5JHF.js → chunk-AJD3XTNT.js} +329 -46
  17. package/dist/cli.js +848 -98
  18. package/dist/client/index.cjs +311 -47
  19. package/dist/client/index.d.ts +64 -3
  20. package/dist/client/index.js +5 -3
  21. package/dist/expo/index.d.cts +1 -1
  22. package/dist/network/index.cjs +434 -66
  23. package/dist/network/index.d.cts +53 -3
  24. package/dist/noop/index.cjs +12 -0
  25. package/dist/noop/network.cjs +7 -1
  26. package/dist/noop/react-native-webview.cjs +31 -0
  27. package/dist/realtime/index.cjs +2 -1
  28. package/dist/realtime/index.d.cts +3 -1
  29. package/dist/runtime/index.cjs +1067 -111
  30. package/dist/runtime/index.d.cts +51 -5
  31. package/dist/types-BmpykP1P.d.cts +137 -0
  32. package/entries/react-native-webview.cjs +9 -0
  33. package/package.json +18 -6
  34. package/skills/agent-bridge/SKILL.md +226 -8
  35. package/dist/types-C6DUUHnB.d.cts +0 -76
@@ -20,11 +20,64 @@ type DeviceInfo = {
20
20
  name: string;
21
21
  platform: string;
22
22
  protocol: number;
23
+ /** Same as ResultMessage.loadId. Absent from older runtimes. */
24
+ loadId?: string;
23
25
  tools: ToolInfo[];
24
26
  };
25
27
 
26
28
  type TransportName = 'expo' | 'cdp';
27
29
 
30
+ /** A scenario a flow needs: a name, or a name with options. */
31
+ type FlowScenario = string | {
32
+ name: string;
33
+ options?: unknown;
34
+ };
35
+ type FlowApi = {
36
+ bridge: AgentBridge;
37
+ call: AgentBridge['call'];
38
+ /**
39
+ * Times one call. Arguments are spread, `step('press', 'screen.press', 'Confirm')`.
40
+ * A single array is the whole argument list, as with `agent-bridge call`, so
41
+ * to pass one array as the only argument wrap it: `step('s', 'cart.setItems', [[a, b]])`.
42
+ * `call` does not do this: it passes its arguments as they are.
43
+ */
44
+ step: (label: string, tool: string, ...args: unknown[]) => Promise<unknown>;
45
+ /** What each declared scenario's apply returned, by name. */
46
+ scenarios: Record<string, unknown>;
47
+ };
48
+ /** A flow file: `export default async ({ step, call }) => {}`, plus what it needs. */
49
+ type FlowModule = {
50
+ default: (api: FlowApi) => Promise<void>;
51
+ /** Applied before the flow and undone after it, even when it fails. */
52
+ scenario?: FlowScenario;
53
+ scenarios?: FlowScenario[];
54
+ };
55
+ type FlowResult = {
56
+ steps: number;
57
+ /** Errors the app logged during the flow. */
58
+ errors: number;
59
+ /** Restorers that failed in the closing bridge.restore, with why. */
60
+ restoreErrors: string[];
61
+ /** "app reloaded; N pending restores lost" warnings seen during the flow. */
62
+ notices: string[];
63
+ };
64
+ type RunFlowOptions = {
65
+ /** Where step lines go. Default: console.log. */
66
+ print?: (line: string) => void;
67
+ /** More scenarios to apply, e.g. from `--scenario`; one of the same name replaces the flow's. */
68
+ scenarios?: Array<{
69
+ name: string;
70
+ options?: unknown;
71
+ }>;
72
+ };
73
+ /**
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
76
+ * when it fails. Throws what the flow threw; otherwise returns how it went.
77
+ * It runs only the code you hand it, in this process.
78
+ */
79
+ declare function runFlow(bridge: AgentBridge, flow: FlowModule, options?: RunFlowOptions): Promise<FlowResult>;
80
+
28
81
  /** What a running session writes next to its socket. Readable only by the user. */
29
82
  type SessionState = {
30
83
  name: string;
@@ -36,6 +89,8 @@ type SessionState = {
36
89
  deviceId: string;
37
90
  platform: string;
38
91
  };
92
+ /** The project the session was started in (see `projectRoot`). */
93
+ project?: string;
39
94
  /** The --device filter the session was started with, reused to reconnect. */
40
95
  deviceFilter?: string;
41
96
  transport: TransportName;
@@ -48,7 +103,7 @@ type SessionState = {
48
103
  declare function listSessions(dir?: string): SessionState[];
49
104
 
50
105
  type SessionConnectOptions = {
51
- /** Session name. Defaults to $AGENT_BRIDGE_SESSION, else the only session on this Metro. */
106
+ /** Session name. Defaults to $AGENT_BRIDGE_SESSION, else the only session (matching --metro/--device when given). */
52
107
  name?: string;
53
108
  metro?: string;
54
109
  device?: string;
@@ -78,9 +133,13 @@ declare class AgentBridgeCallError extends Error {
78
133
  readonly tool: string;
79
134
  /** Errors the app attached to the failed reply. */
80
135
  readonly logs: LogEntry[];
136
+ /** Through a session: the app reloaded, so its pending restores are lost. */
137
+ readonly notice?: string | undefined;
81
138
  constructor(tool: string, message: string,
82
139
  /** Errors the app attached to the failed reply. */
83
- logs?: LogEntry[]);
140
+ logs?: LogEntry[],
141
+ /** Through a session: the app reloaded, so its pending restores are lost. */
142
+ notice?: string | undefined);
84
143
  }
85
144
  /** `logs`: errors the app recorded since its previous reply. */
86
145
  type Timed<T> = {
@@ -88,6 +147,8 @@ type Timed<T> = {
88
147
  ms: number;
89
148
  appMs: number;
90
149
  logs: LogEntry[];
150
+ /** Through a session: the app reloaded since the previous call, so its restores are lost. */
151
+ notice?: string;
91
152
  };
92
153
  type AgentBridge = {
93
154
  transport: TransportName;
@@ -109,4 +170,4 @@ type ListedDevice = {
109
170
  /** Apps with the bridge on Expo's socket, plus every React Native page Metro knows. */
110
171
  declare function listDevices(options?: Pick<ConnectOptions, 'metro'>): Promise<ListedDevice[]>;
111
172
 
112
- export { type AgentBridge, AgentBridgeCallError, type ConnectOptions, type DeviceInfo, type ListedDevice, type LogEntry, type SessionConnectOptions, type SessionState, type Timed, type ToolInfo, type TransportName, connect, connectSession, listDevices, listSessions };
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 };
@@ -3,12 +3,14 @@ import {
3
3
  connect,
4
4
  connectSession,
5
5
  listDevices,
6
- listSessions
7
- } from "../chunk-LBYZ5JHF.js";
6
+ listSessions,
7
+ runFlow
8
+ } from "../chunk-AJD3XTNT.js";
8
9
  export {
9
10
  AgentBridgeCallError,
10
11
  connect,
11
12
  connectSession,
12
13
  listDevices,
13
- listSessions
14
+ listSessions,
15
+ runFlow
14
16
  };
@@ -1,4 +1,4 @@
1
- import { a as Transport } from '../types-C6DUUHnB.cjs';
1
+ import { a as Transport } from '../types-BmpykP1P.cjs';
2
2
 
3
3
  /**
4
4
  * Plain JSON over Expo's dev-tools plugin socket: no string evaluation, emoji