@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.
- package/README.md +36 -14
- package/dist/adapters/ably.cjs +79 -3
- package/dist/adapters/ably.d.cts +2 -1
- package/dist/adapters/async-storage.cjs +158 -0
- package/dist/adapters/async-storage.d.cts +14 -0
- package/dist/adapters/device.cjs +1110 -0
- package/dist/adapters/device.d.cts +49 -0
- package/dist/adapters/expo-router.cjs +112 -6
- package/dist/adapters/expo-router.d.cts +1 -1
- package/dist/adapters/jotai.cjs +266 -0
- package/dist/adapters/jotai.d.cts +19 -0
- package/dist/adapters/react-native-mmkv.cjs +80 -0
- package/dist/adapters/react-native-mmkv.d.cts +3 -1
- package/dist/adapters/react-native-webview.d.cts +1 -1
- package/dist/adapters/react-navigation.cjs +293 -0
- package/dist/adapters/react-navigation.d.cts +55 -0
- package/dist/adapters/redux.cjs +322 -0
- package/dist/adapters/redux.d.cts +28 -0
- package/dist/adapters/secure-store.cjs +169 -0
- package/dist/adapters/secure-store.d.cts +28 -0
- package/dist/adapters/socket-io.cjs +77 -3
- package/dist/adapters/socket-io.d.cts +2 -1
- package/dist/adapters/tanstack-query.cjs +3 -0
- package/dist/adapters/tanstack-query.d.cts +13 -4
- package/dist/adapters/zustand.cjs +193 -22
- package/dist/adapters/zustand.d.cts +11 -15
- package/dist/{chunk-TA2OLPPT.js → chunk-Y6QFU5ON.js} +477 -165
- package/dist/cli.js +2370 -103
- package/dist/client/index.cjs +441 -136
- package/dist/client/index.d.ts +67 -4
- package/dist/client/index.js +5 -3
- package/dist/expo/index.d.cts +1 -1
- package/dist/network/index.cjs +320 -73
- package/dist/network/index.d.cts +18 -3
- package/dist/noop/async-storage.cjs +26 -0
- package/dist/noop/device.cjs +26 -0
- package/dist/noop/jotai.cjs +26 -0
- package/dist/noop/react-navigation.cjs +26 -0
- package/dist/noop/realtime.cjs +6 -1
- package/dist/noop/redux.cjs +28 -0
- package/dist/noop/secure-store.cjs +26 -0
- package/dist/realtime/index.cjs +71 -4
- package/dist/realtime/index.d.cts +21 -2
- package/dist/runtime/index.cjs +838 -128
- package/dist/runtime/index.d.cts +4 -2
- package/dist/store-common-j0cHHvBr.d.cts +23 -0
- package/dist/{types-BmpykP1P.d.cts → types-qlwdcGjt.d.cts} +22 -0
- package/entries/async-storage.cjs +9 -0
- package/entries/device.cjs +9 -0
- package/entries/jotai.cjs +9 -0
- package/entries/react-navigation.cjs +9 -0
- package/entries/redux.cjs +9 -0
- package/entries/secure-store.cjs +9 -0
- package/package.json +34 -2
- package/skills/agent-bridge/SKILL.md +70 -22
- package/skills/agent-bridge/references/device.md +21 -0
- package/skills/agent-bridge/references/flows.md +19 -8
- package/skills/agent-bridge/references/large-data.md +6 -6
- package/skills/agent-bridge/references/network.md +25 -7
- package/skills/agent-bridge/references/realtime.md +5 -5
- package/skills/agent-bridge/references/restore.md +25 -7
- package/skills/agent-bridge/references/screen.md +25 -11
- package/skills/agent-bridge/references/state.md +31 -11
- package/skills/agent-bridge/references/webview.md +9 -9
- package/skills/agent-bridge/references/writing-scenarios.md +3 -3
package/dist/client/index.d.ts
CHANGED
|
@@ -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
|
|
75
|
-
*
|
|
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 };
|
package/dist/client/index.js
CHANGED
|
@@ -4,13 +4,15 @@ import {
|
|
|
4
4
|
connectSession,
|
|
5
5
|
listDevices,
|
|
6
6
|
listSessions,
|
|
7
|
-
runFlow
|
|
8
|
-
|
|
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
|
};
|
package/dist/expo/index.d.cts
CHANGED