appduct 0.14.0 → 0.15.1
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 +60 -287
- package/dist/artifact-inspect.d.ts +38 -39
- package/dist/bin.js +45 -3
- package/dist/cli/result-types.d.ts +27 -1
- package/dist/cli/routes/daemon/index.js +32 -1
- package/dist/cli/routes/daemon/run.js +963 -521
- package/dist/cli/routes/daemon/start.js +40 -1
- package/dist/cli/routes/daemon/status.js +41 -1
- package/dist/cli/routes/daemon/stop.js +40 -1
- package/dist/cli/routes/doctor.js +40 -2
- package/dist/cli/routes/events/index.js +32 -1
- package/dist/cli/routes/events/ls.js +40 -1
- package/dist/cli/routes/events/since.js +40 -1
- package/dist/cli/routes/events/tail.js +40 -1
- package/dist/cli/routes/init.js +207 -107
- package/dist/cli/routes/keygen.js +32 -1
- package/dist/cli/routes/mcp.js +135 -24
- package/dist/cli/routes/sessions/index.js +32 -1
- package/dist/cli/routes/sessions/link.js +141 -21
- package/dist/cli/routes/sessions/ls.js +40 -1
- package/dist/cli/routes/sessions/revoke.js +40 -1
- package/dist/cli/routes/tools/call.js +40 -1
- package/dist/cli/routes/tools/describe.js +40 -1
- package/dist/cli/routes/tools/index.js +32 -1
- package/dist/cli/routes/tools/ls.js +40 -1
- package/dist/client/attach-page.d.ts +39 -0
- package/dist/client/bootstrap.d.ts +17 -3
- package/dist/client/index.d.ts +2 -1
- package/dist/client/index.js +287 -112
- package/dist/commands/doctor.d.ts +3 -4
- package/dist/commands/init.d.ts +8 -2
- package/dist/commands/link.d.ts +10 -1
- package/dist/daemon/calls.d.ts +1 -1
- package/dist/daemon/config.d.ts +6 -0
- package/dist/daemon/daemon.d.ts +6 -1
- package/dist/daemon/links.d.ts +9 -5
- package/dist/daemon/listener.d.ts +28 -1
- package/dist/daemon/rpc-errors.d.ts +3 -0
- package/dist/daemon/sessions.d.ts +11 -7
- package/dist/daemon/tls.d.ts +0 -3
- package/dist/devtools-relay/attach-tab.d.ts +33 -0
- package/dist/devtools-relay/index.d.ts +8 -0
- package/dist/devtools-relay/memory-daemon-sockets.d.ts +20 -0
- package/dist/devtools-relay/memory-devtools-browser.d.ts +10 -0
- package/dist/devtools-relay/memory-page-channel.d.ts +16 -0
- package/dist/devtools-relay/node-daemon-socket.d.ts +3 -0
- package/dist/devtools-relay/node-devtools-browser.d.ts +3 -0
- package/dist/devtools-relay/ports.d.ts +48 -0
- package/dist/devtools-relay/relay.d.ts +16 -0
- package/dist/index.js +45 -3
- package/dist/link.d.ts +35 -1
- package/dist/mcp/connect-tool.d.ts +15 -2
- package/dist/native-scheme.d.ts +11 -7
- package/dist/scheme.d.ts +5 -1
- package/package.json +15 -5
package/README.md
CHANGED
|
@@ -1,202 +1,68 @@
|
|
|
1
|
-
|
|
1
|
+
<a href="https://callstackincubator.github.io/appduct/"><img src="https://raw.githubusercontent.com/callstackincubator/appduct/main/.github/assets/readme-banner.png" alt="Appduct by Callstack. Your app is an MCP server now: your agent calls its functions over MCP, on iOS, Android, React Native, Flutter and web." width="100%" /></a>
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
# Appduct CLI, MCP server and test client
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Call tools inside a running iOS, Android, React Native, Flutter or Web app from your terminal, an AI agent or a test suite. The `appduct` package connects to apps that have an Appduct SDK installed and tools registered.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
## Requirements
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
-
|
|
12
|
-
- **Same surface for humans and agents.** The CLI (`sessions`, `tools`, `events`, ...) and `appduct mcp` use the same RPC methods, so an agent sees the tools a human operator does.
|
|
13
|
-
- **Hardened control plane.** The CLI and MCP server never touch sockets, keys, or state files directly — everything goes through a Unix-domain-socket RPC surface gated by filesystem permissions (see [`docs/SECURITY.md`][security]).
|
|
14
|
-
- **Fits production-minded apps.** The app only exposes what you register; trust boundaries are pins and TLS, and production deployments can gate tools with policy and audit every call.
|
|
9
|
+
- Node 20 or newer.
|
|
10
|
+
- An Appduct-enabled app. Choose an [SDK setup guide](https://callstackincubator.github.io/appduct/start/introduction/#packages), or [try a playground](https://callstackincubator.github.io/appduct/start/playground/).
|
|
11
|
+
- For automatic device delivery: Xcode for an iOS Simulator, or `adb` for Android. Physical devices can use a QR code; Web pages use their URL.
|
|
15
12
|
|
|
16
13
|
## Getting started
|
|
17
14
|
|
|
15
|
+
Install the CLI:
|
|
16
|
+
|
|
18
17
|
```bash
|
|
19
18
|
npm install -g appduct
|
|
20
|
-
appduct sessions link --scheme myapp --qr
|
|
21
19
|
```
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
Scan the QR (or open the deep link) in an Appduct-enabled app, then:
|
|
21
|
+
With your app running, connect from its project directory:
|
|
26
22
|
|
|
27
23
|
```bash
|
|
28
|
-
appduct
|
|
29
|
-
appduct tools call sum --input '{"a":2,"b":3}'
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
That's the whole loop. There is no host process to start — `appduct` auto-spawns its daemon the first time any command needs it.
|
|
33
|
-
|
|
34
|
-
## Commands
|
|
35
|
-
|
|
36
|
-
Every command is `appduct <noun> <verb> [selector] [args]`, the same shape as `appduct daemon run|start|stop|status`:
|
|
37
|
-
|
|
38
|
-
| Command | Role |
|
|
39
|
-
| --- | --- |
|
|
40
|
-
| `appduct init [--scheme <s>] [--ios-app-id <id>] [--android-app-id <id>] [--force]` | set up an app directory: write `.appduct/config.json`, print the MCP snippet |
|
|
41
|
-
| `appduct keygen [--out <path>] [--force]` | generate a daemon private key, print its app pin |
|
|
42
|
-
| `appduct sessions ls` | list sessions: alias, state, device, tool count |
|
|
43
|
-
| `appduct sessions link [--ttl <s>] [--qr] [--open android\|ios-sim\|ios-device] [--device <id>] [--app-id <id>] [--scheme <s>]` | mint a pending session and print its deep link |
|
|
44
|
-
| `appduct sessions revoke [selector]` | revoke a session |
|
|
45
|
-
| `appduct tools ls [selector] [--full] [--group <name>] [--filter <text>] [--limit <n>] [--offset <n>]` | list a session's tools (one call signature + description per line) |
|
|
46
|
-
| `appduct tools ls [selector] --groups` | list a session's tool groups with their tool counts |
|
|
47
|
-
| `appduct tools describe [selector] <name>` | show one tool's full schema |
|
|
48
|
-
| `appduct tools call [selector] <name> --input '<json>' [--timeout <ms>]` | call a tool |
|
|
49
|
-
| `appduct events ls [selector] [--name <glob>] [--limit <n>] [--offset <n>]` | list the events the app declares, one signature line each; an exact `--name` prints the full payload schema; `--limit`/`--offset` page a long list, ending with a `Showing n of total events (offset o).` line when events were left out; `--json` carries the full descriptors, with `total` counting matches before paging |
|
|
50
|
-
| `appduct events tail [selector] [--follow]` | stream the events the app posts with `postEvent`; `--json` emits NDJSON |
|
|
51
|
-
| `appduct events since [selector] <cursor>` | one-shot pull the events retained since `<cursor>`; `--json` emits NDJSON |
|
|
52
|
-
| `appduct daemon run\|start\|stop\|status` | daemon lifecycle |
|
|
53
|
-
| `appduct mcp [--scheme <s>]` | start a stdio MCP server proxying connected apps' tools to MCP clients |
|
|
54
|
-
| `appduct doctor <artifact> [--assert-present\|--assert-absent]` | release-gate step: report or assert whether a built `.app`/`.ipa`/`.apk`/`.aab` contains Appduct |
|
|
55
|
-
|
|
56
|
-
Every command that targets a session accepts an optional `selector` (a session id or an alias from `appduct sessions ls`); omit it when exactly one session is active. Global flags: `--json` (machine-readable output; compact by default, one line), `--pretty` (indent `--json` output, and JSON values embedded in human output, 2 spaces — never NDJSON event lines), `--verbose` (include the `meta` block — `command`, `timestamp`, `duration_ms` — omitted by default in both human and `--json` output), `--no-color`, `--state-dir <path>` (default `~/.appduct`), `--daemon-restart` (on a daemon/CLI version mismatch, restart the daemon even though that drops live sessions and unclaimed links — `APPDUCT_DAEMON_RESTART=1` and `config.json`'s `restartDaemonOnVersionMismatch` do the same for every command, and `--no-daemon-restart` overrules both for one). Run `appduct <noun> --help` for the exact flags any of its verbs takes.
|
|
57
|
-
|
|
58
|
-
`--timeout` on `tools call` is clamped to 1,000–600,000 ms and can only **shorten** the deadline, never extend it past the app's own timer: the app aborts the handler at the tool's declared `timeoutMs`, or 10 seconds for a tool that declares none, regardless of what the caller asks for. If a tool needs more room, declare `timeoutMs` on its registration.
|
|
59
|
-
|
|
60
|
-
### `appduct tools ls`: a signature per tool
|
|
61
|
-
|
|
62
|
-
`appduct tools ls` prints one call signature plus a one-line description per tool, not the full schema — cheap to read even against an app that registers hundreds of tools:
|
|
63
|
-
|
|
64
|
-
```
|
|
65
|
-
Tools
|
|
66
|
-
seed_cart(items: int, sku?: string, clear?: bool = true) -> { added: int, cartId: string }
|
|
67
|
-
Fill the cart with test items for the current user.
|
|
68
|
-
set_flag(name: "dark_mode" | "new_checkout", enabled: bool) [prompt]
|
|
69
|
-
Toggle a feature flag.
|
|
70
|
-
|
|
71
|
-
Run `appduct tools describe <name>` for a tool's full schema.
|
|
24
|
+
appduct sessions link --qr
|
|
72
25
|
```
|
|
73
26
|
|
|
74
|
-
|
|
27
|
+
Scan the QR code with the device's camera. The app needs a URL scheme, which the CLI can discover from static project files; use `--scheme myapp` if needed. A physical device must be on the same local network as your computer.
|
|
75
28
|
|
|
76
|
-
|
|
29
|
+
For a simulator, Android device or Web page, choose one of these paths instead:
|
|
77
30
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
```
|
|
83
|
-
Tools
|
|
84
|
-
cart
|
|
85
|
-
add_item(sku: string, quantity: number)
|
|
86
|
-
Add a product to the cart
|
|
87
|
-
checkout
|
|
88
|
-
begin_checkout()
|
|
89
|
-
Start checkout with the current cart
|
|
90
|
-
checkout/payment
|
|
91
|
-
pay_with_card(card: string)
|
|
92
|
-
Pay for the order with a test card
|
|
93
|
-
(ungrouped)
|
|
94
|
-
reset_app()
|
|
95
|
-
Clear all local data
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
On a large app, start with `--groups` to see what there is, then list one group:
|
|
99
|
-
|
|
100
|
-
```
|
|
101
|
-
$ appduct tools ls --groups
|
|
102
|
-
Groups
|
|
103
|
-
cart 12
|
|
104
|
-
checkout 8
|
|
105
|
-
checkout/payment 3
|
|
106
|
-
(ungrouped) 2
|
|
107
|
-
|
|
108
|
-
22 tools in total. Run `appduct tools ls --group <name>` to list one group's tools.
|
|
109
|
-
|
|
110
|
-
$ appduct tools ls --group checkout
|
|
31
|
+
```bash
|
|
32
|
+
appduct sessions link --open ios-sim
|
|
33
|
+
appduct sessions link --open android --app-id com.example.shop
|
|
34
|
+
appduct sessions link --open web http://localhost:5173/
|
|
111
35
|
```
|
|
112
36
|
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
### The deep-link scheme
|
|
116
|
-
|
|
117
|
-
`appduct sessions link`, `appduct mcp`, and the MCP `appduct_connect` tool all resolve the scheme the same way, first match wins:
|
|
118
|
-
|
|
119
|
-
1. `--scheme <s>`
|
|
120
|
-
2. the `APPDUCT_SCHEME` environment variable
|
|
121
|
-
3. the nearest `.appduct/config.json` that declares a `scheme`, walking up from the working directory (a file without that key doesn't stop the walk; the walk skips `~/.appduct` and the active state dir, so global config is never mistaken for a project's)
|
|
122
|
-
4. `scheme` in `<state-dir>/config.json`
|
|
123
|
-
5. a static-file project probe, tried in this order (no walk-up — an app root is where you run these commands):
|
|
124
|
-
1. `<cwd>/app.json`'s `expo.scheme` — a string, or the first entry of an array
|
|
125
|
-
2. **Android**: `app/build.gradle.kts` or `app/build.gradle`'s `appductScheme` manifest placeholder (`manifestPlaceholders["appductScheme"] = "myapp"` or `manifestPlaceholders.appductScheme = "myapp"`), then `app/src/main/AndroidManifest.xml`'s first `<data android:scheme>` inside an intent filter that also declares `android.intent.action.VIEW`
|
|
126
|
-
3. **iOS**: any `Info.plist` up to two levels below the app root (excluding `Pods`, `build`, `node_modules`, `DerivedData`) for the first `CFBundleURLSchemes` entry, then xcodegen's `project.yml` for the same key under `info.properties.CFBundleURLTypes`
|
|
127
|
-
6. otherwise an error naming every location above
|
|
128
|
-
|
|
129
|
-
In an Expo app root, none of this needs configuring; a plain Xcode or Gradle app root doesn't either, once its `Info.plist`/`AndroidManifest.xml`/`build.gradle` already declares deep links. These probes never execute `app.config.js`/`app.config.ts`, `xcodebuild`, `plutil`, or a Gradle evaluation — each is a plain, defensively-parsed read of a static project file. If your project uses dynamic config, or the probes can't make sense of your setup, use `--scheme`, `APPDUCT_SCHEME`, or `appduct init --scheme <s>` instead.
|
|
130
|
-
|
|
131
|
-
**Disagreement is never guessed away.** If more than one native probe resolves to a different scheme (say, an `android/` and an `ios/` tree in the same repo declaring different values), resolution fails with a usage error naming every conflicting source instead of picking one.
|
|
132
|
-
|
|
133
|
-
`appduct init`, run in an app root, writes `.appduct/config.json` (mode `0600`, in a `0700` directory) with the discovered scheme and prints the MCP server entry to paste, plus the `import "@appduct/react-native/auto"` reminder. It never generates keys or touches daemon state.
|
|
134
|
-
|
|
135
|
-
`init` only looks at `--scheme` and the static-file discovery in step 5 above (`app.json`, then the native probes), plus whatever the file already records — it deliberately ignores `APPDUCT_SCHEME` and does not walk up to a parent `.appduct/config.json`, since baking either into a committed file would be wrong (a shell variable that happened to be exported, or a parent project's scheme silently copied into a sub-package). `--json`'s `source` field reports which input won: `"--scheme"`, `"app.json"`, one of the four native-probe names (`"android-gradle"`, `"android-manifest"`, `"ios-info-plist"`, `"ios-project-yml"`), or `"already-recorded"`.
|
|
136
|
-
|
|
137
|
-
It's idempotent and safe to re-run:
|
|
138
|
-
|
|
139
|
-
- A plain re-run keeps whatever scheme is already recorded. If discovery has since found a different value, the result carries a `note` rather than failing.
|
|
140
|
-
- `--scheme <different>` needs `--force` to replace a recorded scheme; `--force` on its own re-adopts `app.json`'s value.
|
|
141
|
-
- `--force` merges into the existing JSON rather than truncating it.
|
|
142
|
-
|
|
143
|
-
`--ios-app-id <id>` and `--android-app-id <id>` write `appId.ios` and `appId.android` into the same file — the installed app ids that `--open android`, `--open ios-device` and `appduct_connect` need (see [Delivering the link to a device](#delivering-the-link-to-a-device)). They're two flags rather than one because the platforms' ids don't always match, and `init` never guesses one from the other. Like `--scheme`, replacing an id that's already recorded needs `--force`.
|
|
144
|
-
|
|
145
|
-
A project `.appduct/config.json` holds client-side settings only — it can never redirect the state directory, key, or policy (`--state-dir` / `APPDUCT_STATE_DIR` do that). **Do not point `--state-dir` at a project `.appduct/` directory you commit** — the state dir is where the daemon keeps `key.pem` and its audit log, and a committed one would publish a private key. The two directories share a name and nothing else.
|
|
146
|
-
|
|
147
|
-
`appduct mcp` is the one exception to step 6: it starts even with no scheme, because it's still useful for proxying tools to a session paired another way. Only `appduct_connect` fails, and its error names every location tried.
|
|
148
|
-
|
|
149
|
-
### Delivering the link to a device
|
|
150
|
-
|
|
151
|
-
`--open` hands the freshly minted deep link straight to a device, so nothing has to scan a QR code:
|
|
152
|
-
|
|
153
|
-
| `--open` | Mechanism | Address in the link |
|
|
154
|
-
| --- | --- | --- |
|
|
155
|
-
| `android` | `adb reverse tcp:<port> tcp:<port>`, then `adb shell am start -a android.intent.action.VIEW -d '<link>' -p <app-id>` | `127.0.0.1` (the port is forwarded onto the device) |
|
|
156
|
-
| `ios-sim` | `xcrun simctl openurl <udid> <link>` | `127.0.0.1` (the simulator shares the host's network) |
|
|
157
|
-
| `ios-device` **(experimental)** | `xcrun devicectl device process launch --device <udid> [--terminate-existing] --payload-url <link> <app-id>` | the machine's detected LAN address — there's no `adb reverse` equivalent on iOS |
|
|
158
|
-
|
|
159
|
-
With no `--device`, every target requires exactly one device and errors naming each candidate rather than picking one arbitrarily: `android` counts attached devices (`ANDROID_SERIAL` disambiguates), `ios-sim` counts booted simulators, and `ios-device` counts connected iOS devices only — `devicectl` lists every device the Mac has ever paired, so disconnected phones and non-iOS ones are filtered out first.
|
|
160
|
-
|
|
161
|
-
**`android` and `ios-device` need the installed app's id** — the Android package name or the iOS bundle id. Pass `--app-id <id>` (`appId` over MCP), or record it once in `.appduct/config.json` with `appduct init --android-app-id <id> --ios-app-id <id>`. Without one the command fails before minting anything. Naming the app is what keeps Android from showing an "Open with" chooser when more than one installed app declares your scheme — `adb` would report success, and the session would never be claimed. `ios-sim` needs no app id (`simctl openurl` has no equivalent), and passing one with it is an error. The id may contain only letters, digits, `.`, `_` and `-`, and must start with a letter or digit.
|
|
162
|
-
|
|
163
|
-
#### `--open ios-device` (experimental)
|
|
164
|
-
|
|
165
|
-
This is the only automated path for a wired iPhone or iPad — otherwise you're scanning a QR code by hand. It relies on `xcrun devicectl`'s undocumented `--payload-url` flag, which can't be verified in CI, so treat a failure here as a reason to fall back to the QR flow rather than as a bug in your app.
|
|
166
|
-
|
|
167
|
-
It needs all of:
|
|
168
|
-
|
|
169
|
-
- **iOS 17 or newer** on the device, and **Xcode 15 or newer** on the host (`devicectl` doesn't exist before that). For iOS 16 and below, use the QR/deep-link flow instead.
|
|
170
|
-
- The device **paired and trusted** by this Mac, with **Developer Mode** enabled on it (Settings → Privacy & Security → Developer Mode).
|
|
171
|
-
- A **development-signed build of your app already installed** — `devicectl` launches an installed app, it doesn't install one.
|
|
172
|
-
- The phone and this machine **on the same network**, reachable at the address the link advertises. `appduct sessions link` prints it on its `Endpoint` line (`--json`: `endpoint.address`); `advertisedIp` in `config.json` overrides detection. If no routable address is found, detection falls back to `127.0.0.1` — which a phone can't reach — so `ios-device` refuses to deliver such a link and tells you to set `advertisedIp`.
|
|
173
|
-
- The app's **bundle id** — see [Delivering the link to a device](#delivering-the-link-to-a-device) for how to supply it.
|
|
37
|
+
The Web command prints a URL to open. Once connected, list tools and call one your app registered:
|
|
174
38
|
|
|
175
39
|
```bash
|
|
176
|
-
appduct
|
|
40
|
+
appduct tools ls
|
|
41
|
+
appduct tools call seed_cart --input '{"items":3}'
|
|
177
42
|
```
|
|
178
43
|
|
|
179
|
-
|
|
44
|
+
The SDK quick starts register this example tool, which returns `{"added":3}`. Appduct starts its background service automatically.
|
|
180
45
|
|
|
181
|
-
|
|
182
|
-
- **A physical iPhone is never auto-detected.** `appduct_connect` called without a `target` only considers booted simulators and attached Android devices, and `appduct sessions link` without `--open` doesn't look for a device at all — a paired iPhone is often someone's personal phone, so it has to be asked for explicitly.
|
|
46
|
+
## Common commands
|
|
183
47
|
|
|
184
|
-
|
|
48
|
+
| Command | What you can do |
|
|
49
|
+
| --- | --- |
|
|
50
|
+
| `appduct init` | Record your project's scheme and app ids, and print MCP configuration. |
|
|
51
|
+
| `appduct sessions ls` | Find connected sessions and their aliases. |
|
|
52
|
+
| `appduct tools ls` | Find registered tools; use `--groups` or `--group cart` for larger registries. |
|
|
53
|
+
| `appduct tools describe seed_cart` | Read a tool's full schema. |
|
|
54
|
+
| `appduct tools call seed_cart --input '{"items":3}'` | Call a tool. |
|
|
55
|
+
| `appduct events ls` | Find the events the app declares. |
|
|
56
|
+
| `appduct events tail --follow` | Watch events the app posts. |
|
|
57
|
+
| `appduct sessions revoke` | Disconnect a session. |
|
|
58
|
+
| `appduct daemon status` | Inspect the background service. |
|
|
59
|
+
| `appduct doctor build/Shop.ipa --assert-absent` | Check that a built app excludes Appduct. |
|
|
185
60
|
|
|
186
|
-
|
|
61
|
+
Run `appduct <command> --help` for flags, or read the [CLI reference](https://callstackincubator.github.io/appduct/reference/cli/). Use `--json` for scripts.
|
|
187
62
|
|
|
188
|
-
|
|
189
|
-
{
|
|
190
|
-
"mcpServers": {
|
|
191
|
-
"appduct": {
|
|
192
|
-
"command": "appduct",
|
|
193
|
-
"args": ["mcp"]
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
```
|
|
63
|
+
## Connect an agent
|
|
198
64
|
|
|
199
|
-
|
|
65
|
+
Add this entry to your agent's MCP configuration, replacing `myapp` with your app's scheme:
|
|
200
66
|
|
|
201
67
|
```json
|
|
202
68
|
{
|
|
@@ -209,123 +75,44 @@ An MCP server is usually launched with a working directory you don't control, so
|
|
|
209
75
|
}
|
|
210
76
|
```
|
|
211
77
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
| Tool | Does what | CLI equivalent |
|
|
215
|
-
| --- | --- | --- |
|
|
216
|
-
| `appduct_list_tools` | Lists the app's tools as one-line signatures, with each tool's group and policy, plus the app's groups with counts. Returns 50 at a time unless given `limit`; takes `group`, `filter` and `offset`. | `appduct tools ls` |
|
|
217
|
-
| `appduct_describe_tool` | Shows one tool's full input and output schema. | `appduct tools describe <name>` |
|
|
218
|
-
| `appduct_call_tool` | Calls a tool by `name` with `args`, with progress and errors preserved. | `appduct tools call` |
|
|
78
|
+
The agent can connect a device, list your app's tools, inspect their schemas and call them. App tools are reached through `appduct_list_tools`, `appduct_describe_tool` and `appduct_call_tool`; event and connection tools are available too. See [Use Appduct with an agent](https://callstackincubator.github.io/appduct/guides/agents/) for client setup and approval policy.
|
|
219
79
|
|
|
220
|
-
|
|
80
|
+
## Call tools from tests
|
|
221
81
|
|
|
222
|
-
|
|
82
|
+
<a id="test-runners-appductclient"></a>
|
|
223
83
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
Five more built-in tools cover what the app's own tools can't. `appduct_connect` mints a link and, by default, delivers it to whichever `android`/`ios-sim` device it detects — pass `target`/`device` to choose, or `target: "none"` to force the human flow — falling back to a QR code, plus instructions to show it, only when there's nothing to deliver to. Delivering to `android` (chosen or detected) needs `appId`, resolved the same way as `--app-id` (see [Delivering the link to a device](#delivering-the-link-to-a-device)); passing it with `target: "ios-sim"` or `"none"` is an error. `appduct_wait_for_session` then waits for that session to be claimed. `target: "ios-device"` reaches a paired physical iPhone or iPad, with `appId` and the [prerequisites above](#--open-ios-device-experimental) — it's experimental and never auto-detected, so an agent has to ask for it by name.
|
|
227
|
-
|
|
228
|
-
The other three give an agent a pull surface over `postEvent()`-pushed app events. `appduct_list_events` lists the events the app declared (`appduct events ls`) as signatures with descriptions, plus the payload schema when `name` is an exact name, so an agent learns the names before it waits on one. `appduct_events` drains everything retained since a cursor, and `appduct_wait_for_event` blocks for the next event whose name matches `name`, a whole-name glob (`*` waits for any name) — checking what's already retained before waiting live — rejecting with `tool_timeout` if none arrives in time.
|
|
229
|
-
|
|
230
|
-
## Test runners: `appduct/client`
|
|
231
|
-
|
|
232
|
-
A thin typed wrapper over the same daemon RPC the CLI and MCP server use — for a Jest/Vitest/Detox spec that drives a running app without spawning `appduct tools call ... --json` and parsing stdout:
|
|
84
|
+
Install `appduct` as a dev dependency of your test project. With the app connected:
|
|
233
85
|
|
|
234
86
|
```ts
|
|
235
87
|
import { connect } from "appduct/client";
|
|
236
88
|
|
|
237
|
-
// auto-spawns the daemon and picks the single session, or pass { selector: "pixel-8" } to target one explicitly
|
|
238
89
|
const app = await connect();
|
|
239
|
-
|
|
240
|
-
await app.
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
app.close();
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
Errors surface as an `AppductError` whose `type` preserves the daemon's wire error type verbatim, so a test can assert on it directly instead of string-matching stderr:
|
|
247
|
-
|
|
248
|
-
```ts
|
|
249
|
-
await expect(app.call("checkout", {})).rejects.toMatchObject({ type: "policy_denied" });
|
|
250
|
-
```
|
|
251
|
-
|
|
252
|
-
Pair a simulator/emulator in a `globalSetup` without shelling out, via `link`/`waitForSession`:
|
|
253
|
-
|
|
254
|
-
```ts
|
|
255
|
-
import { link, waitForSession } from "appduct/client";
|
|
256
|
-
|
|
257
|
-
const { sessionId } = await link({ target: "ios-sim" });
|
|
258
|
-
const app = await waitForSession(sessionId, { timeoutMs: 60_000 });
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
`app.call`'s tool name and args/result types can't be inferred automatically — tools are registered by the connected app at runtime — so declare your own tool map once for typed calls throughout a suite:
|
|
262
|
-
|
|
263
|
-
```ts
|
|
264
|
-
type Tools = {
|
|
265
|
-
sum: { args: { a: number; b: number }; result: { total: number } };
|
|
266
|
-
};
|
|
267
|
-
|
|
268
|
-
const app = await connect<Tools>();
|
|
269
|
-
const { total } = await app.call("sum", { a: 2, b: 3 }); // typed
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
`waitForEvent`'s first argument is a whole-name glob (`*` waits for any name, `"cart.*"` for any name starting with `cart.`). It first drains the daemon's per-session retained buffer for an already-arrived match before falling back to a live wait, so it's safe to call after the action that emits the event. Pass `since` (the `cursor` from a previous `app.events()`/`waitForEvent()` call) to skip events already handled, and `payloadMaxBytes` to cap the resolved event's payload the same way `app.events()` does — without it the payload always comes back whole:
|
|
273
|
-
|
|
274
|
-
```ts
|
|
275
|
-
const { events, cursor } = await app.events(); // pull: what already happened
|
|
276
|
-
const next = await app.waitForEvent("checkout_done", { since: cursor });
|
|
277
|
-
const capped = await app.waitForEvent("checkout_done", { payloadMaxBytes: 1024 }); // check `truncated` before reading `payload`
|
|
278
|
-
```
|
|
279
|
-
|
|
280
|
-
For everything else, the package exports `runCli` and the command handlers from [`src/index.ts`](https://github.com/callstackincubator/appduct/blob/main/packages/appduct/src/index.ts), so you can embed the same behavior in Node or Bun scripts without shelling out.
|
|
281
|
-
|
|
282
|
-
## Keys and pins
|
|
283
|
-
|
|
284
|
-
You can skip this entirely while your app has no `cliPins` configured — the zero-config default, in any build type. The daemon auto-generates its own `key.pem` the first time it starts if one isn't already there (mode `0600`) and prints its `sha256/...` fingerprint on that first run; `appduct sessions link` carries that fingerprint on the deep link for the app to pick up. See [`docs/SECURITY.md`][security]'s "Trust modes" for what that does and doesn't protect.
|
|
285
|
-
|
|
286
|
-
For a build that should trust only a key you embedded ahead of time, generate one explicitly:
|
|
287
|
-
|
|
288
|
-
```bash
|
|
289
|
-
appduct keygen
|
|
90
|
+
try {
|
|
91
|
+
const result = await app.call("seed_cart", { items: 3 });
|
|
92
|
+
// result: { added: 3 }
|
|
93
|
+
} finally {
|
|
94
|
+
app.close();
|
|
95
|
+
}
|
|
290
96
|
```
|
|
291
97
|
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
`appduct sessions link`'s deep link is `<scheme>:///?appduct=<payload>&pin=<sha256/...>`. The `appduct` param is the binary v2 bootstrap payload (address, session id, token, expiry); `pin` is a separate, out-of-band query param carrying the daemon's current SPKI fingerprint for apps that want to pick it up. An app build with embedded `cliPins` ignores `pin` outright — embedded pins always win, in every build type. A build with no embedded pins trusts it for that one session.
|
|
295
|
-
|
|
296
|
-
## Daemon lifecycle
|
|
297
|
-
|
|
298
|
-
The daemon auto-starts the first time any CLI or MCP command needs it — you don't normally run `appduct daemon start` yourself. It writes state to `<state-dir>/` (`daemon.sock`, `daemon.pid`, `daemon.log`, `daemon.log.1`, `events.log`, `events.log.1`, `key.pem`, `config.json`, `audit/`), holds a single-instance lock via the pidfile, and runs independently of any one device's connection, so a reload or crash on the device side never costs you the daemon process.
|
|
299
|
-
|
|
300
|
-
Use `appduct daemon status` to see what's running (version, pid, `wssPort`, pinned keys, live sessions, effective policy, and the audit log's retention window, file count, size, and failure counters) and `appduct daemon stop` to shut it down explicitly.
|
|
301
|
-
|
|
302
|
-
Because the daemon outlives the CLI that started it, upgrading Appduct would otherwise leave the old daemon serving your commands. Every CLI/MCP process compares its version with the daemon's on its first command and replaces a stale daemon when nothing would be lost; when there is something at stake — connected sessions, or an unexpired link nobody has scanned yet — the command stops instead, naming both versions, until you run `appduct daemon stop` or pass `--daemon-restart`. A daemon newer than your CLI is left alone with a warning, so a project-local install never downgrades a global one's daemon.
|
|
303
|
-
|
|
304
|
-
No log grows without bound: `audit/<YYYY-MM-DD>.jsonl` files older than `auditRetentionDays` (default 30) are pruned at daemon start and once a day after, a `daemon.log` over `daemonLogMaxBytes` (default 10 MiB) is rotated to `daemon.log.1` when a daemon is next spawned, and `events.log` is rotated to `events.log.1` as soon as it passes `eventsLogMaxBytes` (default 10 MiB). `events.log` records the daemon's own events (links, sessions, tool registries and tool calls), one JSON line each, for debugging Appduct itself; your app's events are never written to it. All three are `config.json` keys — see [`ARCHITECTURE.md` §3][architecture].
|
|
305
|
-
|
|
306
|
-
## Release gate: `appduct doctor`
|
|
307
|
-
|
|
308
|
-
Appduct's inclusion in a build is controlled entirely by autolinking exclusion (see [`docs/BUILD-VARIANTS.md`][build-variants]) — there's no runtime `debuggable` check to catch a pipeline that forgot to exclude the package. `doctor` checks the built artifact itself, not the config you think produced it:
|
|
309
|
-
|
|
310
|
-
```bash
|
|
311
|
-
appduct doctor ./build/MyApp.ipa --assert-absent
|
|
312
|
-
appduct doctor ./build/app-release.apk --assert-absent
|
|
313
|
-
```
|
|
98
|
+
The client also pairs devices, waits for sessions, reads events and supports a typed tool map. Failures reject with an `AppductError` whose `type` names the error. See [Test setup](https://callstackincubator.github.io/appduct/guides/cli/#drive-the-app-from-a-test-suite) and the [client reference](https://callstackincubator.github.io/appduct/reference/cli/#appductclient).
|
|
314
99
|
|
|
315
|
-
|
|
100
|
+
<a id="the-deep-link-scheme"></a>
|
|
316
101
|
|
|
317
|
-
##
|
|
102
|
+
## Things to know
|
|
318
103
|
|
|
319
|
-
- **
|
|
320
|
-
- **
|
|
104
|
+
- **Select a session when several are connected.** Pass an alias or session id from `appduct sessions ls`; the CLI won't guess.
|
|
105
|
+
- **Declare longer timeouts in the app.** `tools call --timeout` can shorten a deadline, but it can't extend the app's timer. See [Long-running tools](https://callstackincubator.github.io/appduct/guides/writing-tools/#long-running-tools).
|
|
106
|
+
- **Keep project settings and private state separate.** `appduct init` writes project settings to `.appduct/config.json`. The daemon keeps its key and logs in `~/.appduct`; don't commit that directory.
|
|
107
|
+
- **Pin builds you distribute.** `appduct keygen` prints a pin to embed in the app. See [Security](https://callstackincubator.github.io/appduct/guides/security/) for trust, policy and key rotation.
|
|
108
|
+
- **Reconnect after stopping the daemon.** `appduct daemon stop` disconnects apps. Config changes require a restart; see [Service configuration](https://callstackincubator.github.io/appduct/reference/cli/#background-service-state-dirconfigjson).
|
|
321
109
|
|
|
322
|
-
##
|
|
110
|
+
## Learn more
|
|
323
111
|
|
|
324
|
-
- [
|
|
325
|
-
- [
|
|
326
|
-
- [
|
|
327
|
-
- [Build variants]
|
|
328
|
-
- [Monorepo README](https://github.com/callstackincubator/appduct/blob/main/README.md)
|
|
112
|
+
- [CLI guide](https://callstackincubator.github.io/appduct/guides/cli/): devices, events and scripting
|
|
113
|
+
- [CLI reference](https://callstackincubator.github.io/appduct/reference/cli/): commands, configuration, MCP tools and client API
|
|
114
|
+
- SDKs: [iOS](https://callstackincubator.github.io/appduct/install/ios/), [Android](https://callstackincubator.github.io/appduct/install/android/), [React Native](https://callstackincubator.github.io/appduct/install/react-native/), [Flutter](https://callstackincubator.github.io/appduct/install/flutter/), [Web](https://callstackincubator.github.io/appduct/install/web/)
|
|
115
|
+
- [Build variants](https://callstackincubator.github.io/appduct/guides/build-variants/): inclusion and artifact checks
|
|
329
116
|
|
|
330
117
|
## Made with ❤️ at Callstack
|
|
331
118
|
|
|
@@ -333,18 +120,4 @@ Exit codes, what it inspects per platform, and the marker-only detection rules o
|
|
|
333
120
|
|
|
334
121
|
Like the project? ⚛️ [Join the team](https://callstack.com/careers/?utm_campaign=Senior_RN&utm_source=github&utm_medium=readme) who does amazing stuff for clients and drives React Native Open Source! 🔥
|
|
335
122
|
|
|
336
|
-
[appduct-banner]: https://img.shields.io/badge/Appduct-callstack%2Fincubator-111827?style=for-the-badge&logo=github&logoColor=white
|
|
337
|
-
[repo]: https://github.com/callstackincubator/appduct
|
|
338
123
|
[callstack-readme-with-love]: https://callstack.com/?utm_source=github.com&utm_medium=referral&utm_campaign=appduct&utm_term=readme-with-love
|
|
339
|
-
[architecture]: https://github.com/callstackincubator/appduct/blob/main/docs/ARCHITECTURE.md
|
|
340
|
-
[protocol]: https://github.com/callstackincubator/appduct/blob/main/docs/PROTOCOL.md
|
|
341
|
-
[security]: https://github.com/callstackincubator/appduct/blob/main/docs/SECURITY.md
|
|
342
|
-
[build-variants]: https://github.com/callstackincubator/appduct/blob/main/docs/BUILD-VARIANTS.md
|
|
343
|
-
[license-badge]: https://img.shields.io/npm/l/appduct?style=for-the-badge
|
|
344
|
-
[license]: https://github.com/callstackincubator/appduct/blob/main/LICENSE
|
|
345
|
-
[npm-downloads-badge]: https://img.shields.io/npm/dm/appduct?style=for-the-badge
|
|
346
|
-
[npm-downloads]: https://www.npmjs.com/package/appduct
|
|
347
|
-
[prs-welcome-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=for-the-badge
|
|
348
|
-
[prs-welcome]: https://github.com/callstackincubator/appduct/pulls
|
|
349
|
-
[chat-badge]: https://img.shields.io/discord/426714625279524876.svg?style=for-the-badge
|
|
350
|
-
[chat]: https://discord.gg/xgGt7KAjxv
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `appduct doctor
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
2
|
+
* `appduct doctor`: the artifact-level replacement for the runtime `debuggable`/`#if DEBUG` gate
|
|
3
|
+
* removed elsewhere in opt-in hardening. Given a built `.app`/`.ipa`/`.apk`/`.aab`, decide whether
|
|
4
|
+
* Appduct's native code actually shipped inside it — not whether the config that's supposed to have
|
|
5
|
+
* produced it looks right.
|
|
6
6
|
*
|
|
7
7
|
* The one property everything here is built around: **never report "absent" because a tool was
|
|
8
8
|
* missing or the artifact couldn't be read.** That failure mode is strictly worse than not having
|
|
@@ -14,31 +14,30 @@
|
|
|
14
14
|
* Detection strategy, and why no single signal is authoritative on either platform:
|
|
15
15
|
*
|
|
16
16
|
* - iOS: `present` is decided by real-code-only symbols alone, exactly like Android below —
|
|
17
|
-
* `AppductCoreMarker` (`packages/native/ios/Sources/AppductCore/Real/AppductCoreMarker.swift
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
* the Android signals below aren't all treated as equally authoritative either.
|
|
17
|
+
* `AppductCoreMarker` (`packages/native/ios/Sources/AppductCore/Real/AppductCoreMarker.swift`),
|
|
18
|
+
* an `@objc` class compiled only into the real implementation, never into the SwiftPM package's
|
|
19
|
+
* `Stub/` branch, so its presence cannot be confused with a stub build. `RCTNativeAppduct`
|
|
20
|
+
* (`RCT_EXPORT_MODULE`, see `packages/react-native/ios/RCTNativeAppduct.mm`) is kept as a second
|
|
21
|
+
* real-code signal for artifacts built before the marker existed. Both are Objective-C runtime
|
|
22
|
+
* metadata — they live in `__objc_classname`/`__objc_data`, and `strip`/release optimization
|
|
23
|
+
* leaves them alone because removing them would break `+[NSObject class]`-based dispatch. (A
|
|
24
|
+
* build that dead-strips the whole translation unit for lack of `-ObjC`/`-force_load` could still
|
|
25
|
+
* drop them — these signals assume the module actually links into the binary, which is the thing
|
|
26
|
+
* being checked in the first place.) The plugin-authored `Info.plist` keys
|
|
27
|
+
* (`AppductCliPins`/`AppductTrust`/`AppductAllowPrivateLanOnly`) are reported as a corroborating
|
|
28
|
+
* signal only and can no longer flip `present` to `true` on their own — an app author can write
|
|
29
|
+
* these keys by hand (or a future stub could ship them) without the real implementation being
|
|
30
|
+
* present, exactly the reason the Android signals below aren't all treated as equally
|
|
31
|
+
* authoritative either.
|
|
33
32
|
* - Android: the primary signal is `AppductNativeMarker`
|
|
34
33
|
* (`packages/native/android/core/src/main/java/com/callstack/appduct/AppductNativeMarker.kt`,
|
|
35
34
|
* vendored into `@appduct/react-native` at `android/core/src/main/java/...`), a marker class with no
|
|
36
35
|
* other purpose. Its fully-qualified name is kept unminified and unremoved by a `-keep` rule in
|
|
37
36
|
* `consumer-rules.pro` (same vendoring path), shipped to every consuming app via `consumerProguardFiles`
|
|
38
37
|
* (see `../build.gradle`) — R8 applies it regardless of whether the app used the Expo config plugin or
|
|
39
|
-
* bare-RN autolinking, and regardless of whether the app authored any keep rules of its own
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* bare-RN autolinking, and regardless of whether the app authored any keep rules of its own.
|
|
39
|
+
* This is the only Android signal guaranteed to survive minification in every supported consumer
|
|
40
|
+
* setup.
|
|
42
41
|
*
|
|
43
42
|
* Two more signals are kept as fallbacks for artifacts built before this marker existed: the
|
|
44
43
|
* `com.callstack.appduct` package string in the dex string pool (and its pre-rename spelling,
|
|
@@ -56,30 +55,34 @@
|
|
|
56
55
|
* a real inclusion to "absent" just because one check missed — but the Info.plist keys signal cannot
|
|
57
56
|
* flip it to `true` by itself, matching Android's marker-only rule below (a stub that ships the same
|
|
58
57
|
* plist keys without the real implementation is exactly the failure mode this guards against, even
|
|
59
|
-
* though no such stub exists yet
|
|
58
|
+
* though no such stub exists yet).
|
|
60
59
|
*
|
|
61
60
|
* On Android, `present` is decided by the keep-rule marker alone, not an OR across all three
|
|
62
61
|
* signals. The other two are reported in `signals` for corroboration/debugging but cannot flip
|
|
63
62
|
* `present` to `true` on their own: `android/build.gradle`'s `APPDUCT_ENABLED`-gated vendored
|
|
64
|
-
* source-directory swap (`core` vs `core-noop
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* the *same* fully-qualified name the real one uses (required so the shared, non-variant-aware
|
|
63
|
+
* source-directory swap (`core` vs `core-noop`; previously a `src/debug`/`src/release-stub` swap)
|
|
64
|
+
* compiles a genuine no-op `AppductPackage` into a default release build at the *same*
|
|
65
|
+
* fully-qualified name the real one uses (required so the shared, non-variant-aware
|
|
68
66
|
* `PackageList.java` still resolves), and the config plugin writes the same manifest meta-data
|
|
69
67
|
* regardless of variant (Expo mods edit the single merged manifest, not a per-variant one). Both
|
|
70
68
|
* fallback signals therefore fire on that harmless stub exactly as they would on the real module, and
|
|
71
69
|
* can no longer prove inclusion by themselves.
|
|
72
70
|
*
|
|
73
|
-
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
71
|
+
* Flutter: the Dart core writes `appduct-dart-core/` into the AOT snapshot only when
|
|
72
|
+
* `appductEnabled` is true; that string in `libapp.so` / `App.framework/App` is a third
|
|
73
|
+
* authoritative signal on both platforms. The native shim is in every Flutter build and proves
|
|
74
|
+
* nothing, so doctor reports on the Dart core alone.
|
|
75
|
+
*
|
|
76
|
+
* `appduct doctor` is strictly better than the runtime check it replaces: it runs in CI, before
|
|
77
|
+
* distribution, against the thing actually shipped. The keep-rule marker closes the
|
|
78
|
+
* previously-documented gap where a bare-RN app with no config plugin and no keep rule could evade
|
|
79
|
+
* both older Android signals under R8 minification — that gap applied to builds produced before
|
|
80
|
+
* this library shipped the marker/keep rule; an app that pins an older `@appduct/react-native`
|
|
81
|
+
* version still lacks it, and doctor cannot detect inclusion on such a build at all.
|
|
79
82
|
*/
|
|
80
83
|
export type ArtifactPlatform = "ios" | "android";
|
|
81
84
|
export type ArtifactFormat = "app" | "ipa" | "apk" | "aab";
|
|
82
|
-
export type DetectionSignal = "ios-core-marker-symbol" | "ios-objc-class-symbol" | "ios-info-plist-keys" | "android-keep-rule-marker" | "android-dex-package-symbol" | "android-manifest-meta-data-keys";
|
|
85
|
+
export type DetectionSignal = "ios-core-marker-symbol" | "ios-objc-class-symbol" | "ios-info-plist-keys" | "android-keep-rule-marker" | "android-dex-package-symbol" | "android-manifest-meta-data-keys" | "flutter-dart-core-marker";
|
|
83
86
|
export type ArtifactInspection = {
|
|
84
87
|
platform: ArtifactPlatform;
|
|
85
88
|
format: ArtifactFormat;
|
|
@@ -97,10 +100,6 @@ export type ExecBufferResult = {
|
|
|
97
100
|
* corrupt-archive failure without needing either condition to be true on the machine running the
|
|
98
101
|
* tests. */
|
|
99
102
|
export type ExecBufferFn = (command: string, args: string[]) => Promise<ExecBufferResult>;
|
|
100
|
-
/** Real subprocess execution via `execFile`, buffered as raw bytes. `maxBuffer` is generous (an
|
|
101
|
-
* artifact's full decompressed contents are read into memory at once — see {@link readZipEntries})
|
|
102
|
-
* since real `.ipa`/`.apk`/`.aab` files can run into the hundreds of MB. */
|
|
103
|
-
export declare const defaultExecBuffer: ExecBufferFn;
|
|
104
103
|
export type InspectArtifactOptions = {
|
|
105
104
|
exec?: ExecBufferFn;
|
|
106
105
|
};
|