@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.
- package/README.md +220 -20
- package/dist/adapters/ably.cjs +22 -4
- package/dist/adapters/ably.d.cts +8 -1
- package/dist/adapters/expo-router.cjs +22 -1
- package/dist/adapters/expo-router.d.cts +5 -1
- package/dist/adapters/react-native-mmkv.cjs +1 -0
- package/dist/adapters/react-native-mmkv.d.cts +1 -1
- package/dist/adapters/react-native-webview.cjs +672 -0
- package/dist/adapters/react-native-webview.d.cts +79 -0
- package/dist/adapters/socket-io.cjs +3 -1
- package/dist/adapters/socket-io.d.cts +1 -1
- package/dist/adapters/tanstack-query.cjs +256 -17
- package/dist/adapters/tanstack-query.d.cts +1 -1
- package/dist/adapters/zustand.cjs +152 -12
- package/dist/adapters/zustand.d.cts +19 -3
- package/dist/{chunk-LBYZ5JHF.js → chunk-AJD3XTNT.js} +329 -46
- package/dist/cli.js +848 -98
- package/dist/client/index.cjs +311 -47
- package/dist/client/index.d.ts +64 -3
- package/dist/client/index.js +5 -3
- package/dist/expo/index.d.cts +1 -1
- package/dist/network/index.cjs +434 -66
- package/dist/network/index.d.cts +53 -3
- package/dist/noop/index.cjs +12 -0
- package/dist/noop/network.cjs +7 -1
- package/dist/noop/react-native-webview.cjs +31 -0
- package/dist/realtime/index.cjs +2 -1
- package/dist/realtime/index.d.cts +3 -1
- package/dist/runtime/index.cjs +1067 -111
- package/dist/runtime/index.d.cts +51 -5
- package/dist/types-BmpykP1P.d.cts +137 -0
- package/entries/react-native-webview.cjs +9 -0
- package/package.json +18 -6
- package/skills/agent-bridge/SKILL.md +226 -8
- package/dist/types-C6DUUHnB.d.cts +0 -76
package/dist/network/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Tools } from '../types-
|
|
1
|
+
import { T as Tools } from '../types-BmpykP1P.cjs';
|
|
2
2
|
|
|
3
3
|
/** Which requests a mock answers. A bare string is a URL substring. */
|
|
4
4
|
type MockMatch = string | {
|
|
@@ -38,6 +38,8 @@ type MockOptions = {
|
|
|
38
38
|
times?: number;
|
|
39
39
|
/** Wait before answering. */
|
|
40
40
|
delayMs?: number;
|
|
41
|
+
/** Higher is tried first among mocks from the same source (agent mocks still come before the app's). Default 0; ties go to the newest. Negative makes a fallback. */
|
|
42
|
+
priority?: number;
|
|
41
43
|
/** Registering again with the same id replaces the mock (handy with Fast Refresh). */
|
|
42
44
|
id?: string;
|
|
43
45
|
};
|
|
@@ -50,13 +52,44 @@ type LogEntry = {
|
|
|
50
52
|
id: number;
|
|
51
53
|
method: string;
|
|
52
54
|
url: string;
|
|
55
|
+
/** When the request started, epoch ms (the app's clock). */
|
|
56
|
+
startedAt: number;
|
|
53
57
|
status?: number;
|
|
54
58
|
ms: number;
|
|
55
59
|
pending?: boolean;
|
|
56
60
|
requestBody?: string;
|
|
57
61
|
responseBody?: string;
|
|
62
|
+
/** From net.entry: a body shown is only a preview because the whole one was too large or is gone. */
|
|
63
|
+
truncated?: boolean;
|
|
58
64
|
error?: string;
|
|
59
65
|
mocked?: boolean;
|
|
66
|
+
/** Failed by strict mode: no mock answered it. */
|
|
67
|
+
blocked?: boolean;
|
|
68
|
+
};
|
|
69
|
+
type StrictOptions = {
|
|
70
|
+
/** URLs strict mode lets through to the network: substrings or RegExps. */
|
|
71
|
+
allow?: Array<string | RegExp>;
|
|
72
|
+
/** Status of the error response. Default 501. */
|
|
73
|
+
status?: number;
|
|
74
|
+
/** Fail like a network failure instead of answering with a status. */
|
|
75
|
+
offline?: boolean;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
/** What a `mockApi` handler sees: the request, plus its path params and query. */
|
|
79
|
+
type ApiRequest = MockRequest & {
|
|
80
|
+
/** `:name` segments of the route, and `*` as "*". */
|
|
81
|
+
params: Record<string, string>;
|
|
82
|
+
query: Record<string, string>;
|
|
83
|
+
};
|
|
84
|
+
type ApiHandler = (request: ApiRequest) => MockResponse | undefined | Promise<MockResponse | undefined>;
|
|
85
|
+
/** "METHOD /path" (or "/path" for any method) → a response or a handler. */
|
|
86
|
+
type ApiRoutes = Record<string, MockResponse | ApiHandler>;
|
|
87
|
+
type MockApiOptions = Omit<MockOptions, 'id'> & {
|
|
88
|
+
/**
|
|
89
|
+
* Registering again with the same id replaces these routes (handy with
|
|
90
|
+
* Fast Refresh). Each route's mock id is `<id> <METHOD /path>`.
|
|
91
|
+
*/
|
|
92
|
+
id?: string;
|
|
60
93
|
};
|
|
61
94
|
|
|
62
95
|
/**
|
|
@@ -67,7 +100,8 @@ type LogEntry = {
|
|
|
67
100
|
declare function installNetwork(): void;
|
|
68
101
|
/**
|
|
69
102
|
* Answers matching requests from the app's own code, e.g. a fake backend.
|
|
70
|
-
* Agent mocks (from `net.mock`)
|
|
103
|
+
* Agent mocks (from `net.mock`) are tried first, whatever their priority;
|
|
104
|
+
* `net.restore` keeps these.
|
|
71
105
|
*/
|
|
72
106
|
declare function mock(match: MockMatch, response: MockResponse | MockHandler, options?: MockOptions): {
|
|
73
107
|
id: string;
|
|
@@ -75,6 +109,22 @@ declare function mock(match: MockMatch, response: MockResponse | MockHandler, op
|
|
|
75
109
|
};
|
|
76
110
|
/** Registers several app mocks. Returns a function that removes them. */
|
|
77
111
|
declare function mockRequests(routes: MockRoute[]): () => void;
|
|
112
|
+
/**
|
|
113
|
+
* Answers many endpoints under one base URL, e.g. a scenario's fixtures:
|
|
114
|
+
* `mockApi(API, { 'GET /me': { json: user }, 'GET /plants/:id': ({ params }) => ... })`.
|
|
115
|
+
* `:name` matches a path segment and `*` the rest; the query string is ignored.
|
|
116
|
+
* Pass '' as the base URL to match the path on any host. Returns a function
|
|
117
|
+
* that removes the routes.
|
|
118
|
+
*/
|
|
119
|
+
declare function mockApi(baseUrl: string, routes: ApiRoutes, options?: MockApiOptions): () => void;
|
|
120
|
+
/**
|
|
121
|
+
* Strict mode: a fetch or XMLHttpRequest that no mock answers fails with an
|
|
122
|
+
* error response (501 by default, or like offline with `offline: true`) and
|
|
123
|
+
* a console error naming it, instead of
|
|
124
|
+
* reaching a server. Only JS requests: native networking (images, native
|
|
125
|
+
* SDKs, WebSockets) isn't covered. Returns a function that turns it off.
|
|
126
|
+
*/
|
|
127
|
+
declare function strictNetwork(options?: StrictOptions): () => void;
|
|
78
128
|
type NetworkToolsOptions = {
|
|
79
129
|
/** Extra URLs never to log or mock: substrings or RegExps. */
|
|
80
130
|
skip?: Array<string | RegExp>;
|
|
@@ -82,4 +132,4 @@ type NetworkToolsOptions = {
|
|
|
82
132
|
/** Read the request log and mock responses: `net.*`. */
|
|
83
133
|
declare function networkTools(options?: NetworkToolsOptions): Tools;
|
|
84
134
|
|
|
85
|
-
export { type LogEntry, type MockHandler, type MockMatch, type MockOptions, type MockRequest, type MockResponse, type MockRoute, type NetworkToolsOptions, installNetwork, mock, mockRequests, networkTools };
|
|
135
|
+
export { type ApiHandler, type ApiRequest, type ApiRoutes, type LogEntry, type MockApiOptions, type MockHandler, type MockMatch, type MockOptions, type MockRequest, type MockResponse, type MockRoute, type NetworkToolsOptions, type StrictOptions, installNetwork, mock, mockApi, mockRequests, networkTools, strictNetwork };
|
package/dist/noop/index.cjs
CHANGED
|
@@ -21,6 +21,8 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var noop_exports = {};
|
|
22
22
|
__export(noop_exports, {
|
|
23
23
|
cdpTransport: () => cdpTransport,
|
|
24
|
+
createGate: () => createGate,
|
|
25
|
+
onRestore: () => onRestore,
|
|
24
26
|
settle: () => settle,
|
|
25
27
|
startAgentBridge: () => startAgentBridge,
|
|
26
28
|
useAgentBridge: () => useAgentBridge
|
|
@@ -34,3 +36,13 @@ var useAgentBridge = () => {
|
|
|
34
36
|
};
|
|
35
37
|
var cdpTransport = inert;
|
|
36
38
|
var settle = () => Promise.resolve({ commits: 0, ms: 0 });
|
|
39
|
+
var onRestore = () => {
|
|
40
|
+
};
|
|
41
|
+
var createGate = (name) => ({
|
|
42
|
+
name,
|
|
43
|
+
closed: false,
|
|
44
|
+
close: () => () => {
|
|
45
|
+
},
|
|
46
|
+
subscribe: () => () => {
|
|
47
|
+
}
|
|
48
|
+
});
|
package/dist/noop/network.cjs
CHANGED
|
@@ -22,8 +22,10 @@ var network_exports = {};
|
|
|
22
22
|
__export(network_exports, {
|
|
23
23
|
installNetwork: () => installNetwork,
|
|
24
24
|
mock: () => mock,
|
|
25
|
+
mockApi: () => mockApi,
|
|
25
26
|
mockRequests: () => mockRequests,
|
|
26
|
-
networkTools: () => networkTools
|
|
27
|
+
networkTools: () => networkTools,
|
|
28
|
+
strictNetwork: () => strictNetwork
|
|
27
29
|
});
|
|
28
30
|
module.exports = __toCommonJS(network_exports);
|
|
29
31
|
var installNetwork = () => {
|
|
@@ -32,3 +34,7 @@ var mock = () => ({ id: "", remove: () => false });
|
|
|
32
34
|
var mockRequests = () => () => {
|
|
33
35
|
};
|
|
34
36
|
var networkTools = () => ({});
|
|
37
|
+
var mockApi = () => () => {
|
|
38
|
+
};
|
|
39
|
+
var strictNetwork = () => () => {
|
|
40
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/noop/react-native-webview.ts
|
|
21
|
+
var react_native_webview_exports = {};
|
|
22
|
+
__export(react_native_webview_exports, {
|
|
23
|
+
useWebViewTools: () => useWebViewTools,
|
|
24
|
+
webviewTools: () => webviewTools
|
|
25
|
+
});
|
|
26
|
+
module.exports = __toCommonJS(react_native_webview_exports);
|
|
27
|
+
var useWebViewTools = () => ({
|
|
28
|
+
props: {},
|
|
29
|
+
wrap: (onMessage) => onMessage
|
|
30
|
+
});
|
|
31
|
+
var webviewTools = () => ({});
|
package/dist/realtime/index.cjs
CHANGED
|
@@ -221,7 +221,7 @@ function createRealtimeTap(options = {}) {
|
|
|
221
221
|
}
|
|
222
222
|
},
|
|
223
223
|
[`${ns}.emit`]: {
|
|
224
|
-
description: "Deliver a fake message to every listener on a channel: [channel, message]. Runs the app's own handlers. Returns { id, delivered }.",
|
|
224
|
+
description: "Deliver a fake message to every listener on a channel: [channel, message]. Runs the app's own handlers. Returns { id, delivered }." + (options.emitUsage ? ` ${options.emitUsage}` : ""),
|
|
225
225
|
run: (channel, ...values) => {
|
|
226
226
|
const entries = channels.get(channel);
|
|
227
227
|
if (!entries?.size)
|
|
@@ -257,6 +257,7 @@ function createRealtimeTap(options = {}) {
|
|
|
257
257
|
run: (channel) => setMute(channel, null)
|
|
258
258
|
},
|
|
259
259
|
[`${ns}.restore`]: {
|
|
260
|
+
pending: () => mutes.size > 0 || faked !== null,
|
|
260
261
|
description: "Undo the agent: unmute every channel and go back to the real connection state.",
|
|
261
262
|
run: () => {
|
|
262
263
|
const unmuted = [...mutes.keys()];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as Tools } from '../types-
|
|
1
|
+
import { T as Tools } from '../types-BmpykP1P.cjs';
|
|
2
2
|
|
|
3
3
|
/** How a message shows up in `realtime.log`. */
|
|
4
4
|
type MessageSummary = {
|
|
@@ -34,6 +34,8 @@ type RealtimeTapOptions<M> = {
|
|
|
34
34
|
channel: string;
|
|
35
35
|
id: string;
|
|
36
36
|
}) => M;
|
|
37
|
+
/** What to pass to `realtime.emit` for this library, appended to its description. */
|
|
38
|
+
emitUsage?: string;
|
|
37
39
|
/** Extra fields for `realtime.channels`, e.g. the library's channel state. */
|
|
38
40
|
channelInfo?: (channel: string) => Record<string, unknown>;
|
|
39
41
|
/** Adds `realtime.connection`, to fake connection states. */
|