@stim-cli/server 1.20.2 → 1.21.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 +632 -265
- package/dist/{protocol-CjUChTWJ.mjs → protocol-D21Ab4EI.mjs} +391 -56
- package/dist/protocol.mjs +1 -1
- package/dist/protocol.schema.json +1103 -123
- package/dist/stim-frames/ProcessStream.swift +2 -1
- package/dist/stim-frames/SimulatorPosture.swift +0 -6
- package/dist/{stim-server-FWcuNpW7.mjs → stim-server-BQKNg9Jp.mjs} +3592 -2839
- package/dist/stim-server.mjs +1 -1
- package/dist/stim-service-runner.d.mts +13 -0
- package/dist/stim-service-runner.mjs +96 -0
- package/package.json +8 -3
- package/dist/stats-read.d.mts +0 -1
- package/dist/stats-read.mjs +0 -46
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# @stim-cli/server
|
|
2
2
|
|
|
3
3
|
`stim-server` serves Stim state to paired clients, such as the Stim phone app,
|
|
4
|
-
and lets the clients the
|
|
5
|
-
in a workspace. It runs on the
|
|
6
|
-
|
|
4
|
+
and lets the clients the machine grants control run `stim reload` and `stim stop`
|
|
5
|
+
in a workspace. It runs on the same machine as Stim. Private Desktop project
|
|
6
|
+
checks also record completed doctor checks in project state. It writes its own pairing state and action
|
|
7
7
|
log under `$STIM_HOME/server/`, and the device recordings described under
|
|
8
8
|
[Recording](#recording).
|
|
9
9
|
|
|
@@ -16,23 +16,22 @@ The design is in
|
|
|
16
16
|
stim-server [--port <n>] [--loopback-only]
|
|
17
17
|
# serve paired clients, port 7787 by default
|
|
18
18
|
stim-server pair [--port <n>] [--control]
|
|
19
|
-
# print a single-use pairing payload
|
|
20
|
-
stim-server devices [list] # list pairings,
|
|
21
|
-
stim-server devices grant <id> --control|--read
|
|
22
|
-
# let a paired device run actions, or only read
|
|
23
|
-
|
|
24
|
-
stim-server devices revoke <id> # revoke a paired device or client, or deny a request
|
|
19
|
+
# print a single-use pairing payload with this server's key fingerprint
|
|
20
|
+
stim-server devices [list] # list pairings, approved clients and hosted sessions
|
|
21
|
+
stim-server devices grant <id> --control|--read
|
|
22
|
+
# let a paired device run actions, or only read
|
|
23
|
+
stim-server devices revoke <id> # revoke a paired device or approved client and close its connections
|
|
25
24
|
stim-server log # list the actions paired devices ran
|
|
26
|
-
stim-server setup --
|
|
27
|
-
# worker-side approval
|
|
25
|
+
STIM_SETUP_TICKET=<t> stim-server setup --expires <iso> --build|--device-host
|
|
26
|
+
# worker-side approval of the machine holding this ticket, see below
|
|
28
27
|
stim-server service install|status|update|rollback|uninstall
|
|
29
28
|
# run stim-server as a macOS LaunchAgent, see below
|
|
30
29
|
```
|
|
31
30
|
|
|
32
31
|
`--loopback-only` makes the server listen on `127.0.0.1` only and refuse any request
|
|
33
32
|
that names a remote peer (`X-Forwarded-For`, as `tailscale serve --https` adds), so
|
|
34
|
-
phones and other
|
|
35
|
-
Without it, the server also listens on this
|
|
33
|
+
phones and other machines cannot connect; `/health` then reports `loopbackOnly: true`.
|
|
34
|
+
Without it, the server also listens on this machine's Tailscale addresses while Tailscale
|
|
36
35
|
runs (see [Tailscale](#tailscale)). Stim Desktop starts its own server with the flag
|
|
37
36
|
unless it serves phones.
|
|
38
37
|
|
|
@@ -42,17 +41,16 @@ serving command: see [Run as a service](#run-as-a-service). When serving, a bare
|
|
|
42
41
|
|
|
43
42
|
`pair --json` prints `{ "qr": <payload>, "expiresAt": "<ISO time>" }`, and
|
|
44
43
|
`devices --json` prints `{ "devices": [...] }` with each device's `id`, `name`,
|
|
45
|
-
`
|
|
46
|
-
followed by the [build clients](#build-access)
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
pending record without `requestedCapability` is a build request.
|
|
44
|
+
`from` (where it paired from, as a label only), `keyFingerprint`, `pairedAt`,
|
|
45
|
+
`lastSeenAt` and `capabilities`, followed by the [build clients](#build-access)
|
|
46
|
+
and [device-host clients](#device-host-approval). The plain listing shows
|
|
47
|
+
`from` and the first 12 characters of the key fingerprint.
|
|
50
48
|
`log --json` prints `{ "actions": [...] }`, the records described under
|
|
51
49
|
[Actions](#actions).
|
|
52
50
|
|
|
53
|
-
`GET http://127.0.0.1:7787/health` answers requests from this
|
|
51
|
+
`GET http://127.0.0.1:7787/health` answers requests from this machine with the
|
|
54
52
|
server's name, versions, `stimBuild` (the digest of the bundled Stim's build,
|
|
55
|
-
which offload compares between
|
|
53
|
+
which offload compares between machines), protocol, `stimHome`, `startup`, `busy`
|
|
56
54
|
(the offloaded `builds` and `hostedSessions` running now) and the current
|
|
57
55
|
Tailscale state. It answers HTTP 200 once `startup.state` is `ready`; while the
|
|
58
56
|
state is `pending` or `degraded` (see the LaunchAgent notes below) it answers
|
|
@@ -65,75 +63,226 @@ setup command would use. When the server runs under Stim Host, it also carries
|
|
|
65
63
|
app (checked at most every 5 seconds), or `null` when the check fails. Stim
|
|
66
64
|
Desktop uses it to find a running server and show its route. A request through `tailscale serve` or on a Tailscale address
|
|
67
65
|
without an `Origin` or `Sec-Fetch-Site` header, which a web page's request
|
|
68
|
-
carries, gets only `{ "
|
|
69
|
-
Desktop's Remote
|
|
70
|
-
tailnet. A request from this
|
|
66
|
+
carries, gets only `{ "version" }`, which Stim
|
|
67
|
+
Desktop's Remote Machines list uses to find stim-server on the other machines of the
|
|
68
|
+
tailnet. A request from this machine with a `Host` other than `127.0.0.1` or
|
|
71
69
|
`localhost` gets HTTP 426, like any other plain HTTP request.
|
|
72
70
|
|
|
73
|
-
`GET /setup/<
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
The journal lives at `$STIM_HOME/server/setup/<
|
|
80
|
-
only by stim-server and read through core's state reader. It contains
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
The route returns 503 until startup is ready, caches peer identity for 30 seconds
|
|
86
|
-
and returns 429 after repeated identity failures. All responses use
|
|
71
|
+
`GET /setup/<journal>` returns a setup journal. The name is exactly 64
|
|
72
|
+
lowercase hex characters, `SHA-256("stim setup journal v1" || ticket)` of the
|
|
73
|
+
32-byte setup ticket, so only the ticket's holder can derive it. The journal
|
|
74
|
+
holds no secret, so the route serves it to whoever names it; it never
|
|
75
|
+
authenticates the caller.
|
|
76
|
+
|
|
77
|
+
The journal lives at `$STIM_HOME/server/setup/<journal>.json`, written atomically
|
|
78
|
+
only by stim-server and read through core's state reader. It contains ISO
|
|
79
|
+
`expiresAt`, requested capabilities, steps, granted record ids, completion
|
|
80
|
+
state and optional exit code; it contains no ticket, PSK or token. Browser
|
|
81
|
+
requests, invalid paths, missing, malformed or expired journals get the same 404. The route returns 503 until startup is ready and 429 after repeated
|
|
82
|
+
failures from one peer address. All responses use
|
|
87
83
|
`cache-control: no-store`. Steps whose ids start with `tools` appear only after
|
|
88
84
|
a build grant. The server prunes journals more than one hour past expiry at
|
|
89
85
|
startup and hourly.
|
|
90
86
|
|
|
91
87
|
`stim-server` runs the `stim` version this package was released with, not the
|
|
92
|
-
one on your PATH. It
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
88
|
+
one on your PATH. It never runs a login shell. At start it fills the gaps in
|
|
89
|
+
the environment it was given, the way `stim doctor` reports under **Toolchain**:
|
|
90
|
+
it appends the default Node of nvm, fnm, Volta, mise or asdf, Homebrew,
|
|
91
|
+
`~/.local/bin`, pnpm's and bun's global directories and the Android SDK tools to
|
|
92
|
+
`PATH`, sets `ANDROID_HOME` to `~/Library/Android/sdk` when that exists, and sets
|
|
93
|
+
`JAVA_HOME` to a Homebrew `openjdk` (17, then 21, then the newest), else Android
|
|
94
|
+
Studio's bundled runtime, when no JDK is installed under
|
|
95
|
+
`/Library/Java/JavaVirtualMachines`. It never replaces a variable it was given,
|
|
96
|
+
and its own Node's directory is always the last `PATH` entry. CocoaPods uses the
|
|
97
|
+
project's `.ruby-version` Ruby, else rvm's or rbenv's default Ruby, and reads the
|
|
98
|
+
login shell only when neither exists. Anything else a shell profile sets, such as
|
|
99
|
+
`STIM_*` variables, reaches the server only through its environment or `--env`.
|
|
100
|
+
|
|
101
|
+
## Private Desktop bootstrap
|
|
102
|
+
|
|
103
|
+
When Desktop launches its bundled server, it passes a fresh 32-byte key through
|
|
104
|
+
the child's stdin pipe. The key stays in memory; it is absent from arguments,
|
|
105
|
+
environment values, logs and pairing records. `STIM_DESKTOP_BOOTSTRAP_FD=0`
|
|
106
|
+
marks that private startup input and is removed before the server starts other
|
|
107
|
+
processes. Invalid or missing marked input refuses startup.
|
|
108
|
+
Desktop keeps the pipe open until its child exits. The server shuts down when
|
|
109
|
+
that pipe closes, including when Desktop crashes or is forcibly killed.
|
|
110
|
+
|
|
111
|
+
A connection on the local Unix socket can send `desktopBootstrap: true` in
|
|
112
|
+
`hello`. The server returns a fresh per-connection nonce and an HMAC-SHA256
|
|
113
|
+
proof over `server:<nonce>`. Desktop verifies the child before sending the
|
|
114
|
+
separate `client:<nonce>` proof through `desktop.authenticate`. Each challenge
|
|
115
|
+
answers one proof, so a wrong, replayed or late proof cannot win; disconnect
|
|
116
|
+
ends the authority, and it adds no persisted capability. Network connections,
|
|
117
|
+
which run Noise, never get a challenge.
|
|
118
|
+
|
|
119
|
+
On a server Desktop started, only a socket that passed this proof can call the
|
|
120
|
+
Desktop-only methods (`route.setup`, `machines.update.*`, `device-host.sessions`
|
|
121
|
+
and `device-host.sessions.stop`, plus `desktop.reports.*`, `desktop.settings.get`,
|
|
122
|
+
`desktop.logs.subscribe`, `desktop.doctor.run` and `desktop.stop.subscribe`); another client of this user on the socket, such
|
|
123
|
+
as the CLI, keeps read and control without them. A server Desktop adopted or that
|
|
124
|
+
runs on its own, such as a `stim-server service`, has no private key: it offers no
|
|
125
|
+
challenge and keeps serving those methods to this user's socket. Starting a fresh
|
|
126
|
+
bundled child establishes a new private key. Desktop also refuses a socket whose
|
|
127
|
+
server reports another TCP port than the server it adopted, before it sends any
|
|
128
|
+
proof.
|
|
129
|
+
|
|
130
|
+
`desktop.settings.write` requires the private proof even on an adopted or
|
|
131
|
+
standalone server. Only a server started by Desktop advertises the local-only
|
|
132
|
+
`desktop-settings-write` feature. The method accepts an absolute existing `cwd`,
|
|
133
|
+
setting `key`, optional `scope`, and either `"action": "set"` with a text `value`,
|
|
134
|
+
or `"action": "unset"` without `value`. It runs the shared settings API in process
|
|
135
|
+
and returns its masked setting payload or a typed refusal (`code`, `message`,
|
|
136
|
+
`remedy`). Timeout and output failures use the RPC error channel. Writes resolve
|
|
137
|
+
the selected folder through the shared settings API and share its workspace
|
|
138
|
+
admission with control actions. They stay admitted until their cleanup
|
|
139
|
+
drains, including after timeout or disconnect. Pending writes cancel; recording
|
|
140
|
+
deletion after commit finishes before shutdown. The audit records the key, scope
|
|
141
|
+
and result without setting values. This method grants no phone or network access.
|
|
142
|
+
|
|
143
|
+
The local-only `desktop-doctor-run` feature provides `desktop.doctor.run` with
|
|
144
|
+
an absolute `cwd` and optional `ios` or `android` `platform`. It performs a fresh
|
|
145
|
+
doctor check without a CLI process or repairs, returns the doctor JSON report,
|
|
146
|
+
and records the completed native check in project state. A chosen supported
|
|
147
|
+
project need not already be registered. Recording happens after report execution
|
|
148
|
+
and owned cleanup succeed. Recording waits asynchronously for the config lock,
|
|
149
|
+
honors cancellation and reports unavailable state. The existing private Desktop bootstrap gate applies;
|
|
150
|
+
phone and network clients cannot call it or see the feature. Request caps, output
|
|
151
|
+
limits and the report execution/cleanup budgets apply. Disconnect or shutdown
|
|
152
|
+
cancels the request and drains its owned work. Cached doctor report reads do not
|
|
153
|
+
record checks.
|
|
154
|
+
|
|
155
|
+
The local-only `desktop-stop` feature provides `desktop.stop.subscribe` with an
|
|
156
|
+
absolute `cwd` and optional `slot` (`web` closes only the owned Chrome). It stops
|
|
157
|
+
that exact canonical workspace through the shared API, without searching for a
|
|
158
|
+
monorepo child or starting the CLI. The response gives a subscription; ordered
|
|
159
|
+
`desktop-stop-progress` events carry `stream` and `message` chunks, followed by
|
|
160
|
+
`desktop-stop-ended` with `exitCode`, CLI-compatible JSON `stdout` and a human
|
|
161
|
+
summary or failure `message`. Cumulative progress and final JSON have separate
|
|
162
|
+
output bounds, and the action duration limit applies. A terminal
|
|
163
|
+
timeout or output failure does not release workspace admission until actual
|
|
164
|
+
cleanup finishes. Public control actions share this admission. Unsubscribe or
|
|
165
|
+
disconnect cancels waiting work; teardown already underway finishes. Server
|
|
166
|
+
shutdown cancels and drains it, and the action audit records the result. This
|
|
167
|
+
method does not change phone or network permissions. Desktop stop consumers
|
|
168
|
+
still use the CLI until they adopt this feature.
|
|
169
|
+
|
|
170
|
+
The local-only `desktop-settings` feature provides `desktop.settings.get` with
|
|
171
|
+
`{ "cwd": "/absolute/folder" }`. It reads the same masked settings, layers,
|
|
172
|
+
environment overrides and source files as `stim settings --json`, including for
|
|
173
|
+
a selected folder that is not registered with Stim. Each call reads current
|
|
174
|
+
settings, without a CLI process or a shared report cache. The existing Desktop
|
|
175
|
+
bootstrap boundary, request cap, byte quota, cancellation and 60-second read limit
|
|
176
|
+
apply. Network clients retain `settings.get`'s registered-workspace restriction.
|
|
177
|
+
|
|
178
|
+
The local-only `desktop-reports` feature provides full doctor and GC dry-run
|
|
179
|
+
reports without starting a CLI process. `desktop.reports.get` takes
|
|
180
|
+
`{ "report": "gc" }` or `{ "report": "doctor", "cwd": "/absolute/project" }`.
|
|
181
|
+
Doctor accepts a selected folder before it is registered with Stim. The result is
|
|
182
|
+
`{ "pending": false, "value": { ... }, "measuredAt": "..." }`; a failed read
|
|
183
|
+
returns `stim-failed`. Doctor never repairs the project or records a CLI run, and
|
|
184
|
+
GC never deletes anything.
|
|
185
|
+
|
|
186
|
+
The local-only `desktop-report-platform` feature adds an optional `"platform": "ios"`
|
|
187
|
+
or `"platform": "android"` to doctor targets. Omitting it checks all selected platforms.
|
|
188
|
+
Reports for each cwd and selector have separate cache entries and subscriptions.
|
|
189
|
+
Clients requiring a filtered report check this feature before requesting one.
|
|
190
|
+
|
|
191
|
+
`desktop.reports.subscribe` takes the same target and returns a subscription id.
|
|
192
|
+
It pushes `desktop-report` events with that `subscription`, `target`, and a
|
|
193
|
+
`snapshot` containing `pending`, `value`, optional `error`, and `measuredAt` after
|
|
194
|
+
the first completed read. During refresh it retains the last settled value or
|
|
195
|
+
error. All connections share one in-flight read and a 60-second result per target.
|
|
196
|
+
Active subscriptions refresh after 60 seconds; no refresh timer runs without
|
|
197
|
+
subscribers. `unsubscribe` and disconnect remove the subscription. Cancelling a
|
|
198
|
+
get request does not cancel another reader's shared work.
|
|
199
|
+
|
|
200
|
+
After changing settings, running an action, or explicitly refreshing a view,
|
|
201
|
+
Desktop calls `desktop.reports.invalidate` without parameters. This invalidates
|
|
202
|
+
all report targets and refreshes active subscriptions. Results started before
|
|
203
|
+
invalidation cannot replace a newer result or satisfy a waiting get. The existing
|
|
204
|
+
request and subscription caps, report byte quota, API execution and cleanup
|
|
205
|
+
budgets, and 150-second server limit apply. At most four shared report probes run
|
|
206
|
+
at once across connections and targets. A new target above that limit returns a
|
|
207
|
+
busy error without starting or queuing work; invalidate and retry after a probe
|
|
208
|
+
finishes. Unsubscribing does not release a probe's slot before it drains.
|
|
209
|
+
Server shutdown stops refreshes and
|
|
210
|
+
cancels and drains the shared probes. These methods and events are excluded from
|
|
211
|
+
the phone protocol and unavailable over network connections.
|
|
212
|
+
|
|
213
|
+
`desktop.logs.subscribe` reads a registered workspace's complete retained logs
|
|
214
|
+
for the private local Desktop connection. It accepts `workspace` and optional
|
|
215
|
+
`sources`, `level`, `grep` and `errors`; Desktop applies scoped build time, platform
|
|
216
|
+
and legacy slot bounds. `desktop-full-logs` advertises it only on the local socket,
|
|
217
|
+
with the same private bootstrap admission as Desktop reports. Network and phone
|
|
218
|
+
clients keep the existing 5,000-record tail limit.
|
|
219
|
+
|
|
220
|
+
Full backfill selects timeline records in batches of at most 500 and waits for
|
|
221
|
+
the send queue before selecting more. Agent actions still use the existing
|
|
222
|
+
attribution reader and retain matching records during backfill. A disconnect,
|
|
223
|
+
unsubscribe or backfill deadline cancels the read and releases its open files.
|
|
224
|
+
|
|
225
|
+
## Set up a worker machine
|
|
226
|
+
|
|
227
|
+
A person on the worker runs the command generated for their client machine.
|
|
228
|
+
The client machine makes the setup ticket, 32 random bytes: Stim Desktop's Add
|
|
229
|
+
Machine flow shows the command, and on a machine without Desktop,
|
|
230
|
+
`stim doctor --fix` prints it.
|
|
99
231
|
|
|
100
232
|
```bash
|
|
101
|
-
|
|
233
|
+
STIM_SETUP_TICKET=<43-base64url-characters> stim-server setup --expires <ISO-time> \
|
|
102
234
|
--build --device-host [--port <n>] [--label <name>] \
|
|
103
235
|
[--env KEY=VALUE]... [--path-prepend <dir>]... [--yes] [--json] [--verbose]
|
|
104
236
|
```
|
|
105
237
|
|
|
238
|
+
The ticket travels in the `STIM_SETUP_TICKET` environment variable, because
|
|
239
|
+
other users on the worker can read a process's command-line arguments but not
|
|
240
|
+
its environment. Setup refuses `--ticket` and `--client`: the ticket alone
|
|
241
|
+
names the requesting machine. On Windows the generated command runs in a PowerShell script block that
|
|
242
|
+
sets `$env:STIM_SETUP_TICKET` and removes it when setup ends.
|
|
243
|
+
|
|
106
244
|
If the server is not installed globally, use `npx --yes --package @stim-cli/server@<version> stim-server`
|
|
107
|
-
in place of `stim-server`, with the exact version from the client
|
|
245
|
+
in place of `stim-server`, with the exact version from the client machine.
|
|
108
246
|
At least one capability is required. The expiry must be in the future and at
|
|
109
247
|
most two hours ahead. The defaults are port 7787 and label `dev.stim.server`.
|
|
110
248
|
Argument and preflight refusals change nothing. Preflight requires macOS,
|
|
111
|
-
Node 22.12+, running Tailscale,
|
|
112
|
-
GUI login session.
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
249
|
+
Linux or Windows, Node 22.12+, running Tailscale, and
|
|
250
|
+
this user's GUI login session on macOS or systemd user manager on Linux. On
|
|
251
|
+
Linux and Windows, setup takes `--build` only and refuses `--device-host`, because hosting
|
|
252
|
+
needs a Mac; see [On Linux](#on-linux) and [On Windows](#on-windows). Off macOS, stim-server also refuses a
|
|
253
|
+
device-host connection at hello.
|
|
254
|
+
|
|
255
|
+
Running setup on the worker is the worker-side approval. It approves the
|
|
256
|
+
client key that holds this ticket, once per chosen capability, until this
|
|
257
|
+
expiry. A terminal asks Y/n for each grant (default Yes: Enter, `y` and `yes` approve;
|
|
117
258
|
`n`, `no` and any other answer decline); use `--yes` to approve without those
|
|
118
259
|
questions, including without a terminal. Without
|
|
119
260
|
a terminal or `--yes`, setup refuses before installing anything unless every
|
|
120
261
|
chosen capability already has a matching approval. A person on
|
|
121
|
-
the worker still approves; an SSH-driven run is not offered.
|
|
122
|
-
|
|
262
|
+
the worker still approves; an SSH-driven run is not offered. Only after the
|
|
263
|
+
person approves does setup store the ticket's derived PSK and lookup in
|
|
264
|
+
`$STIM_HOME/server/secrets.json`. Until then the requesting machine's handshake
|
|
265
|
+
gets `unknown-secret`, and its `stim doctor` reports the machine as pending and
|
|
266
|
+
tries again on every run. The requester's next first-contact handshake with the
|
|
267
|
+
ticket records its public key once per approved capability, which spends the
|
|
268
|
+
ticket. From then on the ticket admits only that key, until it expires, so a
|
|
269
|
+
requester that lost the reply can retry; setup deletes an unspent secret when it
|
|
270
|
+
ends. Build and
|
|
271
|
+
device-host approvals are separate records. A build grant carries no `read` or
|
|
123
272
|
`control` capability, but it is full access to this account in practice (see
|
|
124
273
|
[Build access](#build-access)).
|
|
125
|
-
A rerun before expiry reports
|
|
126
|
-
|
|
127
|
-
any change. Requests themselves lapse after 15 minutes.
|
|
274
|
+
A rerun before expiry reports capabilities the ticket already recorded as
|
|
275
|
+
already approved. After expiry it refuses with exit 2 before any change.
|
|
128
276
|
|
|
129
|
-
Setup installs its exact server release into
|
|
130
|
-
`~/Library/Application Support/Stim/services/<label>/versions
|
|
131
|
-
Stim Host, installs or reuses the managed
|
|
277
|
+
Setup installs its exact server release into the service's `versions/`
|
|
278
|
+
directory (`~/Library/Application Support/Stim/services/<label>/versions/` on
|
|
279
|
+
macOS), installs Stim Host on macOS, installs or reuses the managed
|
|
280
|
+
LaunchAgent, systemd user service or scheduled task, and creates or reuses a
|
|
132
281
|
tailnet-only HTTPS route on 7443 or the next free port. Older managed services
|
|
133
282
|
use the service update busy-wait and rollback behavior. Newer versions stay
|
|
134
|
-
installed; tools report a Stim build difference. A reused server must
|
|
135
|
-
|
|
136
|
-
|
|
283
|
+
installed; tools report a Stim build difference. A reused server must
|
|
284
|
+
speak protocol 2 (stim-server **1.21.0** or later), which setup tickets
|
|
285
|
+
authenticate with. An older server refuses immediately with an update remedy.
|
|
137
286
|
|
|
138
287
|
When a Desktop-run server already answers on the port, setup reuses it and
|
|
139
288
|
installs no LaunchAgent. It requires an existing tailnet route and refuses
|
|
@@ -168,7 +317,7 @@ earlier releases did. Plain progress goes to stdout; errors use
|
|
|
168
317
|
`stim-server: <message>` on stderr (when stdout is a terminal, the refusal appears on stdout only).
|
|
169
318
|
`--json` sends the long (verbose) progress to stderr, without the banner, and prints one final payload with `ok`,
|
|
170
319
|
`label`, `port`, `route` (state, DNS name, HTTPS port), `server` (version and
|
|
171
|
-
Stim build), `managed`, separate `granted`
|
|
320
|
+
Stim build), `managed`, separate `granted` record ids and client names,
|
|
172
321
|
`permissions`, `tools` and `warnings`. Final permission values are `granted`,
|
|
173
322
|
`denied` (not authorized), `skipped` or `not-needed`; a timed-out wait remains
|
|
174
323
|
`pending` in the journal and names its unavailable feature. Exit codes come
|
|
@@ -181,13 +330,13 @@ from the final journal:
|
|
|
181
330
|
| 2 | No grant before expiry, or an already expired command. |
|
|
182
331
|
| 3 | At least one grant, but another chosen capability, permission or tool is missing; the output names affected features. |
|
|
183
332
|
|
|
184
|
-
Setup writes `$STIM_HOME/server/setup/<
|
|
333
|
+
Setup writes `$STIM_HOME/server/setup/<journal>.json` from its first
|
|
185
334
|
step and after every change, including completion and the exit code. The
|
|
186
|
-
|
|
335
|
+
`GET /setup/<journal>` route described above mirrors it until expiry,
|
|
187
336
|
hiding tools until a build grant. Each valid setup run prunes journals more
|
|
188
337
|
than one hour past expiry. A dedicated `server/setup.claims` ownership claim
|
|
189
338
|
serializes runs; the service update claim is released before waiting for
|
|
190
|
-
|
|
339
|
+
the requesting machine and permissions. A competing setup refuses with the exact claim
|
|
191
340
|
and removal command. Ctrl-C or SIGTERM finishes the running step as failed
|
|
192
341
|
with detail `interrupted`, completes the journal, releases the setup claim,
|
|
193
342
|
and exits 1. A typed N also exits 1; a question timeout follows ticket expiry
|
|
@@ -196,8 +345,8 @@ and exits 2.
|
|
|
196
345
|
The `To undo` line (or the `--verbose` summary) lists the undo commands:
|
|
197
346
|
|
|
198
347
|
```bash
|
|
199
|
-
stim-server devices revoke <build-
|
|
200
|
-
stim-server devices revoke <device-host-
|
|
348
|
+
stim-server devices revoke <build-client-id>
|
|
349
|
+
stim-server devices revoke <device-host-client-id>
|
|
201
350
|
stim-server service uninstall --label <label>
|
|
202
351
|
```
|
|
203
352
|
|
|
@@ -211,12 +360,13 @@ permissions remain; remove permission grants in System Settings if desired.
|
|
|
211
360
|
|
|
212
361
|
## Tailscale
|
|
213
362
|
|
|
214
|
-
Tailscale carries
|
|
215
|
-
|
|
216
|
-
|
|
363
|
+
Tailscale carries the traffic between the phone and the Mac, on the same
|
|
364
|
+
Wi-Fi or across networks. Stim authenticates and encrypts every network
|
|
365
|
+
connection itself with a Noise handshake (see [Pairing](#pairing)), so
|
|
366
|
+
Tailscale's identity of a peer only labels it. You need Tailscale on the Mac and on the phone, in the
|
|
217
367
|
same tailnet or with the Mac shared to the phone's user.
|
|
218
368
|
|
|
219
|
-
`stim-server` listens only on `127.0.0.1` and on the
|
|
369
|
+
`stim-server` listens only on `127.0.0.1` and on the machine's Tailscale
|
|
220
370
|
addresses, never on every interface. It re-reads the Tailscale state in the
|
|
221
371
|
background, so a server that started before Tailscale was up, or while it did
|
|
222
372
|
not answer, starts listening on the Tailscale addresses once it runs, and stops
|
|
@@ -247,10 +397,10 @@ Funnel port makes it public, and `pair` refuses.
|
|
|
247
397
|
When Tailscale is not running, `stim-server` listens on loopback only and
|
|
248
398
|
says so on stderr. Start Tailscale, then restart `stim-server`.
|
|
249
399
|
|
|
250
|
-
Desktop uses `route.setup` with no parameters on its
|
|
251
|
-
|
|
252
|
-
no-op. The server refuses
|
|
253
|
-
|
|
400
|
+
Desktop uses `route.setup` with no parameters on its connection to the local
|
|
401
|
+
Unix socket (see [Pairing](#pairing)). The result is a verified
|
|
402
|
+
`ServeRoute`; an existing route is a no-op. The server refuses it on any network
|
|
403
|
+
connection, unknown configuration and any route exposing this server
|
|
254
404
|
through Funnel. Only the fixed `tailscale serve --bg --https=<free port>
|
|
255
405
|
http://127.0.0.1:<server port>` invocation runs, followed by route verification.
|
|
256
406
|
No LaunchAgent or Funnel configuration is created. Failure output remains
|
|
@@ -261,35 +411,72 @@ available for an explicit retry, including Tailscale's HTTPS approval link.
|
|
|
261
411
|
`stim-server pair` prints the JSON that the pairing QR code encodes:
|
|
262
412
|
|
|
263
413
|
```json
|
|
264
|
-
{
|
|
414
|
+
{
|
|
415
|
+
"v": 2,
|
|
416
|
+
"name": "Janic's MacBook Pro",
|
|
417
|
+
"endpoint": "wss://janics-mbp.tail1234.ts.net:7443",
|
|
418
|
+
"pairingToken": "...",
|
|
419
|
+
"fingerprint": "..."
|
|
420
|
+
}
|
|
265
421
|
```
|
|
266
422
|
|
|
267
|
-
The endpoint names the route's port, and omits it for 443.
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
423
|
+
The endpoint names the route's port, and omits it for 443. `fingerprint` is
|
|
424
|
+
base64url, without padding, of the SHA-256 of the server's public key. When a
|
|
425
|
+
route to the server is on a port with Funnel on, `pair` refuses and exits 1
|
|
426
|
+
without creating a token.
|
|
427
|
+
|
|
428
|
+
Every network connection, loopback TCP included, runs a Noise handshake before
|
|
429
|
+
any request, as the
|
|
430
|
+
[design](../../docs/specs/2026-10-13-pluggable-transports-design.md#authentication)
|
|
431
|
+
specifies. The server has one long-term X25519 key in
|
|
432
|
+
`$STIM_HOME/server/identity.key`, and each client has its own. There are no
|
|
433
|
+
device tokens.
|
|
434
|
+
|
|
435
|
+
- **First contact (`XXpsk2`).** The pairing token is 32 random bytes, pairs
|
|
436
|
+
one client key and expires after 5 minutes. The client proves it holds the token in the
|
|
437
|
+
handshake, then pins the server's key; the phone also checks the key against
|
|
438
|
+
the QR code's `fingerprint`. The server records the client's public key in
|
|
439
|
+
`devices.json` with the capabilities stored with the token, and spends the
|
|
440
|
+
token: until it expires it admits only that key again, so a client that lost
|
|
441
|
+
the reply can retry. The server keeps only the token's derived PSK and lookup in
|
|
442
|
+
`$STIM_HOME/server/secrets.json`.
|
|
443
|
+
- **Returning client (`XX`).** The server accepts the client's key only if a
|
|
444
|
+
record has it, and the client accepts only the server key it pinned.
|
|
445
|
+
|
|
446
|
+
A refusal during the handshake closes the WebSocket with code 4401 and the
|
|
447
|
+
reason `unknown-secret` (no valid token or ticket matches), `unauthorized` (no
|
|
448
|
+
record has the key, or it was revoked) or `handshake-failed`. A client that
|
|
449
|
+
gets another server key than it pinned closes with `server-key-mismatch`. A
|
|
450
|
+
protocol 1 client gets `protocol-unsupported` in cleartext with an "update,
|
|
451
|
+
then pair again" message. Pairings, approvals and credentials from protocol 1
|
|
452
|
+
are not carried over: phones pair again, and remote machines are approved
|
|
453
|
+
again with a new setup ticket.
|
|
454
|
+
|
|
455
|
+
Stim Desktop and other clients of the server's own user on the same machine do
|
|
456
|
+
not pair. They connect to the Unix socket `$STIM_HOME/server/local.sock`, mode
|
|
457
|
+
0600 in a 0700 directory, which serves only this user and needs no handshake.
|
|
458
|
+
That connection gets read and control. The Desktop-only methods (`route.setup`,
|
|
459
|
+
`machines.update.*`, `device-host.sessions` and `device-host.sessions.stop`)
|
|
460
|
+
work only there; on a server Desktop started, only after the private Desktop
|
|
461
|
+
bootstrap proof (see [Private Desktop bootstrap](#private-desktop-bootstrap)).
|
|
462
|
+
Windows has no socket.
|
|
463
|
+
|
|
464
|
+
The network address, `tailscale whois` and the `X-Forwarded-For` header that
|
|
465
|
+
`tailscale serve` adds never authenticate. They only label a record (`from` in
|
|
466
|
+
`stim-server devices`) and key the rate limits below.
|
|
467
|
+
|
|
468
|
+
A connection must finish the handshake and send `hello` within 5 seconds of
|
|
469
|
+
each step. Five failed attempts from the same peer address within a minute
|
|
470
|
+
block new connections from it for up to a minute. An `unknown-secret` refusal
|
|
471
|
+
is not a failed attempt: a requesting machine retries with its setup ticket
|
|
472
|
+
until setup on this machine stores it.
|
|
286
473
|
The server answers 403 to a WebSocket upgrade that carries `Sec-Fetch-Site`, or
|
|
287
474
|
an `Origin` other than the requested host (`http:` on loopback, `https:`
|
|
288
475
|
through the route), and counts no failed attempt, so a web page can neither
|
|
289
|
-
connect nor block this
|
|
476
|
+
connect nor block this machine's clients.
|
|
290
477
|
|
|
291
478
|
Paired devices live in `$STIM_HOME/server/devices.json`. Revoking a device
|
|
292
|
-
closes its open connections. The server checks registrations on file changes
|
|
479
|
+
deletes its record and closes its open connections. The server checks registrations on file changes
|
|
293
480
|
and once a second, so a missed filesystem notification cannot leave a revoked
|
|
294
481
|
connection authorized.
|
|
295
482
|
|
|
@@ -300,7 +487,7 @@ A paired device has the `read` capability, which serves state, or also
|
|
|
300
487
|
With the `workspace-diff` feature, `read` also serves changed and untracked
|
|
301
488
|
text file contents in registered workspaces, including any non-ignored
|
|
302
489
|
untracked text file such as an unignored `.env`. Pairing grants `read` only,
|
|
303
|
-
unless the pairing code came from `stim-server pair --control`. On the
|
|
490
|
+
unless the pairing code came from `stim-server pair --control`. On the machine,
|
|
304
491
|
`stim-server devices grant <id> --control` adds control to a paired device and
|
|
305
492
|
`--read` takes it away. Nothing a client sends changes its own capabilities.
|
|
306
493
|
The server checks the device's capabilities in `devices.json` on every action
|
|
@@ -310,17 +497,45 @@ registration check. `hello` reports
|
|
|
310
497
|
the capabilities and actions of the connection's device when it connects; a
|
|
311
498
|
connection sees a new grant after it reconnects. Under Stim Host, an approved
|
|
312
499
|
`hello` also carries the same `host` grants as `/health`, which `stim doctor`
|
|
313
|
-
reports for remote
|
|
500
|
+
reports for remote machines.
|
|
314
501
|
|
|
315
502
|
Every method other than `hello` needs `read`, except the methods with their own
|
|
316
503
|
approval: `build.*` needs `build`, the `device-host.*` methods that run a hosted
|
|
317
504
|
session need `device-host`, and `server.update.*` needs the build or device-host
|
|
318
|
-
approval of the requesting
|
|
505
|
+
approval of the requesting machine (see [Remote update](#remote-update)). A device
|
|
319
506
|
with only `build` gets `forbidden` for every other method.
|
|
320
507
|
|
|
508
|
+
## Pause incoming work
|
|
509
|
+
|
|
510
|
+
On the worker machine, pause new builds and hosted sessions independently:
|
|
511
|
+
|
|
512
|
+
```bash
|
|
513
|
+
stim settings set server.buildsPaused true
|
|
514
|
+
stim settings set server.devicesPaused true
|
|
515
|
+
```
|
|
516
|
+
|
|
517
|
+
The running server reads these machine settings without a restart. A pause
|
|
518
|
+
rejects new work even when a client received an offer before the setting changed.
|
|
519
|
+
Running builds and existing hosted sessions continue; clients can still attach,
|
|
520
|
+
fetch completed artifacts, and stop their sessions. Hosted sessions include iOS,
|
|
521
|
+
Android and macOS. Client approvals are preserved, and local CLI builds and devices
|
|
522
|
+
remain available. These worker settings apply to every requesting machine, including
|
|
523
|
+
explicitly selected workers; Desktop's pool switches only affect that requester's
|
|
524
|
+
automatic placement.
|
|
525
|
+
|
|
526
|
+
Resume either capability when the machine is available again:
|
|
527
|
+
|
|
528
|
+
```bash
|
|
529
|
+
stim settings set server.buildsPaused false
|
|
530
|
+
stim settings set server.devicesPaused false
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
Both settings default to `false`. Pausing does not make the machine idle: let
|
|
534
|
+
existing work finish or stop the relevant sessions before timing benchmarks.
|
|
535
|
+
|
|
321
536
|
## Build access
|
|
322
537
|
|
|
323
|
-
`build` lets another
|
|
538
|
+
`build` lets another machine on the tailnet run its project's code on this machine to
|
|
324
539
|
build for it: config plugins, CocoaPods hooks, Xcode script phases and Gradle
|
|
325
540
|
plugins run as the user `stim-server` runs as. The offload worker runs with that
|
|
326
541
|
user's real home directory and no sandbox, so a build grant is equivalent to
|
|
@@ -331,40 +546,27 @@ real home directory still reaches) to grant itself either, read other build
|
|
|
331
546
|
clients' checkouts and blobs, and persist through LaunchAgents or shell startup
|
|
332
547
|
files. `devices grant` never turns a paired device into a build client, and the
|
|
333
548
|
protocol does not list `read` or `control` among a build client's capabilities,
|
|
334
|
-
but do not rely on that as a boundary. Grant it only to
|
|
549
|
+
but do not rely on that as a boundary. Grant it only to machines you trust with
|
|
335
550
|
that. Revoking the grant stops future builds and kills the running job's
|
|
336
|
-
process group. It does not undo anything project code already did.
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
`
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
**Deny** run those commands. Until then, `hello` with its token
|
|
356
|
-
fails with `approval-pending`, which does not count as a failed attempt, while
|
|
357
|
-
the request itself does, so a peer cannot send more requests than failed
|
|
358
|
-
attempts. A request lapses after 15 minutes. Each node has at most one pending
|
|
359
|
-
request, the newest, and the server holds at most 8; more fail with
|
|
360
|
-
`limit-exceeded`. There is no pairing code for `build`: `stim-server pair`
|
|
361
|
-
never grants it.
|
|
362
|
-
|
|
363
|
-
`devices grant` never gives `build` to a paired device, or `read` or
|
|
364
|
-
`control` to a build client. Build clients live in
|
|
365
|
-
`$STIM_HOME/server/build-clients.json`, apart from `devices.json`, so a
|
|
366
|
-
`stim-server` release without `build` never reads them and refuses their
|
|
367
|
-
tokens.
|
|
551
|
+
process group. It does not undo anything project code already did. Approve a
|
|
552
|
+
machine only when you expect it.
|
|
553
|
+
|
|
554
|
+
A machine gets `build` only through
|
|
555
|
+
[`stim-server setup`](#set-up-a-worker-machine) on this machine. The requesting
|
|
556
|
+
machine makes a setup ticket and connects with it in a first-contact handshake,
|
|
557
|
+
naming itself in the handshake (at most 64 characters). Until a person runs
|
|
558
|
+
setup with that ticket and approves, the handshake fails with `unknown-secret`
|
|
559
|
+
and the requester retries. Once approved, the next handshake records the
|
|
560
|
+
requester's public key as a build client, and the requester pins this server's
|
|
561
|
+
key in its `$STIM_HOME/build-machines.json`. Later connections send `hello`
|
|
562
|
+
with `access: "build"` and authenticate by that key alone.
|
|
563
|
+
`stim-server devices revoke <id>` deletes the record and closes its
|
|
564
|
+
connections. There is no pairing code for `build`: `stim-server pair` never
|
|
565
|
+
grants it.
|
|
566
|
+
|
|
567
|
+
`devices grant` takes only `--control` or `--read`: it never gives `build` to a
|
|
568
|
+
paired device, or `read` or `control` to a build client. Build clients live in
|
|
569
|
+
`$STIM_HOME/server/build-clients.json`, apart from `devices.json`.
|
|
368
570
|
|
|
369
571
|
## Device-host approval
|
|
370
572
|
|
|
@@ -372,37 +574,30 @@ Device hosting has a separate `device-host` capability. An approved client can
|
|
|
372
574
|
reserve, boot, reconnect to and stop its own iOS simulator or Android emulator
|
|
373
575
|
through the protocol. It can deliver, install and launch a compatible iOS app
|
|
374
576
|
bundle, Android APK or prebuilt macOS app, stream the iOS simulator, Android emulator or macOS app and control it. Hosted
|
|
375
|
-
iOS and Android apps connect back to Metro on the client
|
|
577
|
+
iOS and Android apps connect back to Metro on the client machine. Automatic placement remains in [#2266](https://github.com/appandflow/stim/issues/2266).
|
|
376
578
|
|
|
377
579
|
The Stim client can name expected hosts with
|
|
378
580
|
`stim settings set remote.machines '["<mac>"]'` and request access with
|
|
379
|
-
`stim doctor --fix
|
|
380
|
-
|
|
381
|
-
|
|
581
|
+
`stim doctor --fix`, which makes a setup ticket and prints the setup command.
|
|
582
|
+
Once a person runs it on the worker, doctor stores a separate private credential
|
|
583
|
+
in `$STIM_HOME/device-host-machines.json` that pins the worker's stim-server key,
|
|
584
|
+
and reports approval under `deviceHosts` in doctor JSON. Plain doctor makes no
|
|
382
585
|
approval request. Use `stim ios --remote <machine>` or `stim android --remote <machine>` for explicit placement.
|
|
383
586
|
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
On the hosting Mac, inspect `stim-server devices`, then approve the matching
|
|
393
|
-
request with `stim-server devices grant <id> --device-host`, run
|
|
394
|
-
[`stim-server setup`](#set-up-a-worker-mac) there with its node and ticket, or use **Allow**
|
|
395
|
-
in Stim Desktop. Approve only an expected request: it authorizes that Mac to
|
|
396
|
-
reserve session-owned simulators or emulators and run native app code. **Deny**
|
|
397
|
-
or `stim-server devices revoke <id>` removes it; revocation also closes its
|
|
398
|
-
open authenticated connections. The local-process trust boundary described in
|
|
399
|
-
[Build access](#build-access) applies here too.
|
|
587
|
+
As with build, the client spends its setup ticket in a first-contact
|
|
588
|
+
handshake and gets `unknown-secret` until a person on the hosting Mac runs
|
|
589
|
+
[`stim-server setup`](#set-up-a-worker-machine) with `--device-host` and that
|
|
590
|
+
ticket. One ticket can approve build and device hosting together, as one record
|
|
591
|
+
for each. Later connections send `hello` with `access: "device-host"`. Approve
|
|
592
|
+
only an expected machine: it can reserve session-owned simulators or emulators
|
|
593
|
+
and run native app code. `stim-server devices revoke <id>` removes it and also
|
|
594
|
+
closes its open authenticated connections.
|
|
400
595
|
|
|
401
596
|
Hosting clients live in `$STIM_HOME/server/device-host-clients.json`, separate
|
|
402
|
-
from phone pairings and build clients. A hosting
|
|
403
|
-
`control` or `build` access, including access to unrelated workspaces.
|
|
404
|
-
|
|
405
|
-
|
|
597
|
+
from phone pairings and build clients. A hosting record grants no `read`,
|
|
598
|
+
`control` or `build` access, including access to unrelated workspaces. Read,
|
|
599
|
+
control and build records cannot gain hosting through `devices grant`, and
|
|
600
|
+
`pair` never grants it.
|
|
406
601
|
|
|
407
602
|
### Hosted here
|
|
408
603
|
|
|
@@ -422,9 +617,9 @@ Each row has `id`, `client: { id, name }`, `platform`, nullable `device` and `ap
|
|
|
422
617
|
session through the existing stop path, closing Metro, view, agent and logs
|
|
423
618
|
before owned-device teardown. Repeating a stopped session returns `stopped`;
|
|
424
619
|
an absent id gets `unknown-session`.
|
|
425
|
-
Both requests
|
|
426
|
-
|
|
427
|
-
|
|
620
|
+
Both requests work only on the local Unix socket that Stim Desktop uses (see
|
|
621
|
+
[Pairing](#pairing)). Every network connection, paired phones and remote
|
|
622
|
+
hosting clients included, gets `forbidden`. A session whose active owner is not
|
|
428
623
|
attached to this server reads as `unknown`; stop reconciles it through the same
|
|
429
624
|
ownership checks. The approved-client `device-host.stop` remains limited to
|
|
430
625
|
that client's own sessions.
|
|
@@ -465,7 +660,12 @@ This protocol does not select a host for `stim ios` or `stim android`.
|
|
|
465
660
|
|
|
466
661
|
On the hosting Mac, `hosting.agentDriver` names the tool that lets a client's
|
|
467
662
|
coding agent drive the macOS app hosted for that client. `none` (the default)
|
|
468
|
-
starts nothing.
|
|
663
|
+
starts nothing. Each tool is a driver package implementing
|
|
664
|
+
[`@stim-cli/agent-driver`](../agent-driver/README.md) that stim-server depends
|
|
665
|
+
on; today that is `agent-device`, from `@stim-cli/agent-driver-agent-device`. A
|
|
666
|
+
named driver that fails to load leaves the app with `{ "driver": "none" }` and
|
|
667
|
+
a generic notice; the reason, which can name paths on the hosting Mac, goes to
|
|
668
|
+
stim-server's stderr. `stim-server` reference-counts the driver's daemon on running
|
|
469
669
|
hosted macOS apps: it starts with the first, stops after the last, on
|
|
470
670
|
revocation and on server shutdown, and restarts if it exits while apps run. The
|
|
471
671
|
daemon is held under an ownership claim at `server/agent-device.claims` whose
|
|
@@ -481,10 +681,13 @@ ANY /device-host/agent/<session>/<driver path>
|
|
|
481
681
|
|
|
482
682
|
on the tailnet `serve` route is forwarded to the loopback daemon, with the
|
|
483
683
|
daemon's own token, only when all of these hold: the request carries that
|
|
484
|
-
session's token as a bearer token,
|
|
485
|
-
session's
|
|
486
|
-
|
|
487
|
-
|
|
684
|
+
session's token as a bearer token, the session's device-host client still
|
|
685
|
+
holds `device-host`, the session's app is running, and the request comes from the
|
|
686
|
+
tailnet node that client's latest authenticated connection came from. The token is
|
|
687
|
+
the credential; the node check only stops a machine that took over the host's
|
|
688
|
+
MagicDNS name from replaying it, and a request whose node no transport identifies
|
|
689
|
+
is refused. Browser requests and
|
|
690
|
+
other sessions' tokens are refused with 403, an unknown or stopped session with 404.
|
|
488
691
|
|
|
489
692
|
The `agent-device` adapter runs the binary that `STIM_AGENT_DEVICE_BIN` names
|
|
490
693
|
in `stim-server`'s environment, or else the first of
|
|
@@ -636,13 +839,13 @@ session before starting another transfer. Manifest, file and partial blobs are s
|
|
|
636
839
|
by attempts of one session in its content-addressed store; offers recheck complete
|
|
637
840
|
blob digests and request only missing bytes.
|
|
638
841
|
|
|
639
|
-
An iOS simulator, Android emulator or macOS session can take its content from a build this
|
|
842
|
+
An iOS simulator, Android emulator or macOS session can take its content from a build this machine ran instead: after
|
|
640
843
|
the manifest arrives, send `device-host.app.handoff` with
|
|
641
844
|
`{session, attempt, build: {handoff, sha256}}`, where `handoff` is the token
|
|
642
845
|
and `sha256` the archive digest from that job's `build.artifact` answer. The
|
|
643
846
|
server hands the build over only when the build client that ran it still has
|
|
644
847
|
`build`, the caller has `device-host`, and both approvals belong to the same
|
|
645
|
-
|
|
848
|
+
client key. It copies only regular files, and links where the manifest
|
|
646
849
|
declares links, whose directory resolves inside the staged bundle and whose
|
|
647
850
|
bytes match their manifest digest; it answers `{files, bytes}` for what it
|
|
648
851
|
took. The token is spent once the handoff starts. Re-offer and upload whatever
|
|
@@ -693,10 +896,10 @@ retain the same reconciliation rules as iOS.
|
|
|
693
896
|
|
|
694
897
|
With `hosting.agentDriver: agent-device`, each installed Android session gets
|
|
695
898
|
its own daemon and child-aware claim under `device-host/sessions/<session>/agent-device.claims`.
|
|
696
|
-
Both
|
|
899
|
+
Both machines need agent-device 0.21.22 or later. The host verifies the serial policy
|
|
697
900
|
digest and `android-instance` backend and advertises `hosted-android-agent`.
|
|
698
901
|
`device-host.app.attach` and session attach carry a session grant with
|
|
699
|
-
`android:mobile:<serial>` and the same token
|
|
902
|
+
`android:mobile:<serial>` and the same token checks as iOS.
|
|
700
903
|
The client writes a 0600 remote config under `hosted-android/<slot>/` and reports
|
|
701
904
|
it as `android.host.agent`. Use `agent-device <command> --remote-config <file>`.
|
|
702
905
|
Missing or unsupported agent-device reports `driver: none` with its reason.
|
|
@@ -873,8 +1076,9 @@ Automatic native macOS placement remains separate work.
|
|
|
873
1076
|
### Hosted viewer relay
|
|
874
1077
|
|
|
875
1078
|
The client's stim-server relays a hosted workspace's iOS simulator, Android emulator or macOS view and input to
|
|
876
|
-
its host using the client's approved device-host credential over
|
|
877
|
-
|
|
1079
|
+
its host using the client's approved device-host credential, over a connection
|
|
1080
|
+
that goes ahead only with the host that proves the server key pinned at
|
|
1081
|
+
approval. Stim Desktop and phones keep talking only to their own
|
|
878
1082
|
server. The `macos-hosted`, `ios-hosted` and `android-hosted` features advertise these relays.
|
|
879
1083
|
iOS resolves `ios.host` and Android resolves `android.host` by the requested slot; macOS retains its default slot.
|
|
880
1084
|
The local platform and slot replace the host's private target fields in events
|
|
@@ -884,7 +1088,7 @@ The relay forwards iOS device artwork and orientation metadata. Hosted targets
|
|
|
884
1088
|
refuse replay (`at`/`rate`), `duoFrame` and `physical` with `bad-request`.
|
|
885
1089
|
All of the client's relayed subscriptions and control sessions for one host share one connection,
|
|
886
1090
|
whichever local client opened them. Each request still checks the credential
|
|
887
|
-
and the pinned
|
|
1091
|
+
and the pinned key; a changed credential or endpoint opens a new connection.
|
|
888
1092
|
Ending a subscription or session sends `device-host.unsubscribe` or
|
|
889
1093
|
`device-host.control.end`, and the connection closes when the last one ends.
|
|
890
1094
|
The host's per-connection limits, such as its 32 subscriptions and input
|
|
@@ -978,8 +1182,10 @@ before replacement. Automatic placement remains in
|
|
|
978
1182
|
## Run as a service
|
|
979
1183
|
|
|
980
1184
|
`stim-server service install` runs stim-server as a per-user LaunchAgent on
|
|
981
|
-
macOS,
|
|
982
|
-
|
|
1185
|
+
macOS, a systemd user service on Linux ([On Linux](#on-linux)), or a scheduled
|
|
1186
|
+
task on Windows ([On Windows](#on-windows)), so a remote
|
|
1187
|
+
machine or a phone-serving Mac keeps it running without a terminal. Other
|
|
1188
|
+
systems refuse; start stim-server from your own service manager there:
|
|
983
1189
|
|
|
984
1190
|
```bash
|
|
985
1191
|
stim-server service install [--port <n>] [--label <name>] [--serve]
|
|
@@ -1066,10 +1272,9 @@ foreground `tailscale serve` session counts as present. To move a service that
|
|
|
1066
1272
|
created a route to another `--port`, run `uninstall` first.
|
|
1067
1273
|
|
|
1068
1274
|
`--env KEY=VALUE` and `--path-prepend <dir>` pin variables and PATH entries for
|
|
1069
|
-
the server.
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
the server and to the builds it starts. The plist stores each `--env` value in
|
|
1275
|
+
the server. A LaunchAgent gets no shell profile, so these are how a service sees
|
|
1276
|
+
a variable or tool that toolchain discovery does not find. They apply after
|
|
1277
|
+
discovery, to the server and to the builds it starts. The plist stores each `--env` value in
|
|
1073
1278
|
`EnvironmentVariables`, so it stays out of the server's process arguments, and
|
|
1074
1279
|
passes only the name as `--env KEY`; the server reads that variable from the
|
|
1075
1280
|
environment launchd gives it. The values sit in plain text in the plist. A
|
|
@@ -1099,14 +1304,16 @@ the job to it. `--release <version>` takes an exact version from the public npm
|
|
|
1099
1304
|
registry (`https://registry.npmjs.org/`, never a registry `.npmrc` names), and
|
|
1100
1305
|
npm checks each package against the registry's integrity. `--from <dir>`
|
|
1101
1306
|
installs the `.tgz` packages in that directory, such as `pnpm pack` output of
|
|
1102
|
-
the `@stim-cli/core`, `@stim-cli/cache`, `@stim-cli/metro`, `stim
|
|
1103
|
-
`@stim-cli/
|
|
1307
|
+
the `@stim-cli/core`, `@stim-cli/cache`, `@stim-cli/metro`, `stim`,
|
|
1308
|
+
`@stim-cli/transport`, `@stim-cli/transport-tailscale` and `@stim-cli/server`
|
|
1309
|
+
packages of a checkout, and records each file's sha256.
|
|
1104
1310
|
Either way, `npm audit signatures` must verify the registry signature of every
|
|
1105
1311
|
package that came from the registry, and the provenance attestation of each one
|
|
1106
1312
|
that has it, or the update stops before it touches the job. Install scripts
|
|
1107
1313
|
never run. Each install goes to
|
|
1108
1314
|
`~/Library/Application Support/Stim/services/<label>/versions/`, in a directory
|
|
1109
|
-
named by its version, Stim build and server code,
|
|
1315
|
+
named by its version, Stim build and server code, plus the package files for
|
|
1316
|
+
`--from`, and must start with the job's
|
|
1110
1317
|
`node` before the switch. `update` then waits up to 30 minutes for `/health` to
|
|
1111
1318
|
report no offloaded build and no hosted session (a server older than `busy` in
|
|
1112
1319
|
`/health` restarts without waiting), rewrites only the server script in the
|
|
@@ -1125,24 +1332,116 @@ and uninstall of one label run one at a time.
|
|
|
1125
1332
|
installed and, when `install` created it, the serve route. Logs, pairings and the host app stay; other labels may use the app. Use `--label` and `--port` to run a
|
|
1126
1333
|
second service beside the first, for example with another `STIM_HOME`.
|
|
1127
1334
|
|
|
1128
|
-
To set up a remote
|
|
1335
|
+
To set up a remote machine: install Stim and stim-server on it, run
|
|
1129
1336
|
`stim-server service install --serve` (with the pins its toolchain needs), set
|
|
1130
1337
|
`server.workerRoot` there, and on each client run
|
|
1131
|
-
`stim settings set remote.machines '["<
|
|
1132
|
-
|
|
1133
|
-
|
|
1338
|
+
`stim settings set remote.machines '["<machine>"]'` and `stim doctor --fix`.
|
|
1339
|
+
A person on the remote machine approves it by running the `stim-server setup`
|
|
1340
|
+
command doctor printed (see [Set up a worker machine](#set-up-a-worker-machine)).
|
|
1341
|
+
|
|
1342
|
+
### On Linux
|
|
1343
|
+
|
|
1344
|
+
On Linux, `service` manages a systemd user unit with the same commands, flags
|
|
1345
|
+
and checks. A Linux machine takes offloaded Android builds only, so it never
|
|
1346
|
+
installs Stim Host and has no permission grants.
|
|
1347
|
+
|
|
1348
|
+
- `install` writes `~/.config/systemd/user/<label>.service`, runs
|
|
1349
|
+
`systemctl --user daemon-reload`, `enable` and `start`, and logs to
|
|
1350
|
+
`~/.local/state/stim/<label>.log`. The unit runs the absolute `node` and `stim-server.mjs` of the
|
|
1351
|
+
install that ran the command, with `Restart=always` after 30 seconds,
|
|
1352
|
+
`STIM_HOME` and `SHELL` from the installing shell, each `--env` value in an
|
|
1353
|
+
`Environment=` line, and `STIM_SERVICE_LABEL=<label>`, which tells the
|
|
1354
|
+
server its label. The `[X-Stim]` section, which systemd ignores, marks the
|
|
1355
|
+
unit as one `install` wrote and records the serve route and the previous
|
|
1356
|
+
server script. The unit sits in plain text, values included.
|
|
1357
|
+
- `update` and `rollback` keep versions under
|
|
1358
|
+
`~/.local/share/stim/services/<label>/versions/`, whatever the XDG
|
|
1359
|
+
variables say, so every caller finds the same versions; they rewrite only
|
|
1360
|
+
`ExecStart=` and the previous script, run `daemon-reload` and restart the
|
|
1361
|
+
unit, and switch back when the new server does not answer.
|
|
1362
|
+
- `uninstall` stops and disables the unit, removes it and runs
|
|
1363
|
+
`daemon-reload`.
|
|
1364
|
+
- The unit stops when its user manager does, which by default is when you log
|
|
1365
|
+
out. Turn on linger once so it starts at boot and keeps running:
|
|
1366
|
+
`sudo loginctl enable-linger $USER`. `install` prints that command when
|
|
1367
|
+
linger is off, and `status` reports it; Stim never runs sudo.
|
|
1368
|
+
- `systemctl --user` needs your user manager. An SSH or desktop login has one;
|
|
1369
|
+
without a session, Stim falls back to `XDG_RUNTIME_DIR=/run/user/<uid>`,
|
|
1370
|
+
which works once linger is on.
|
|
1371
|
+
- `--serve` runs `tailscale serve` as you, which Tailscale on Linux allows only
|
|
1372
|
+
for its operator: run `sudo tailscale set --operator=$USER` first.
|
|
1373
|
+
- A systemd unit has no login shell, and the service finds the Android SDK only
|
|
1374
|
+
in `~/Android/Sdk`. Pin the JDK and an SDK elsewhere:
|
|
1375
|
+
|
|
1376
|
+
```bash
|
|
1377
|
+
stim-server service install --serve \
|
|
1378
|
+
--env JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64 \
|
|
1379
|
+
--env ANDROID_HOME=$HOME/Android/Sdk
|
|
1380
|
+
```
|
|
1381
|
+
|
|
1382
|
+
- A remote update the server starts for an approved client runs under
|
|
1383
|
+
`systemd-run --user --scope`, so restarting the unit does not stop it.
|
|
1384
|
+
- `stim-server setup` works on Linux for `--build`. It refuses
|
|
1385
|
+
`--device-host`, needs no GUI session, and skips Stim Host, the permission
|
|
1386
|
+
steps and the Xcode, iOS runtime and CocoaPods checks.
|
|
1387
|
+
|
|
1388
|
+
### On Windows
|
|
1389
|
+
|
|
1390
|
+
On Windows, `service` manages a per-user scheduled task with the same commands,
|
|
1391
|
+
flags and checks, and never needs elevation. A Windows machine takes offloaded
|
|
1392
|
+
Android builds only, so it never installs Stim Host and has no permission
|
|
1393
|
+
grants.
|
|
1394
|
+
|
|
1395
|
+
- `install` writes the service file
|
|
1396
|
+
`%LOCALAPPDATA%\Stim\services\<label>.json` (the server's `node`, script,
|
|
1397
|
+
arguments and environment, `STIM_SERVICE_LABEL=<label>`, the serve route and
|
|
1398
|
+
the previous server script), copies the supervisor
|
|
1399
|
+
`stim-service-runner.mjs` into `%LOCALAPPDATA%\Stim\services\<label>\`, and
|
|
1400
|
+
registers the task `\Stim\<label>` with `schtasks /Create`, then starts it.
|
|
1401
|
+
It logs to `%LOCALAPPDATA%\Stim\Logs\<label>.log`.
|
|
1402
|
+
- The task starts at your logon and runs whether or not you are logged on
|
|
1403
|
+
(Task Scheduler's S4U logon type, which an ordinary user can register), so it
|
|
1404
|
+
keeps running after you sign out; after a reboot it starts at your next
|
|
1405
|
+
logon. Task Scheduler restarts a task only when it fails to start, not when
|
|
1406
|
+
its process exits, so the task runs the supervisor, which restarts the
|
|
1407
|
+
server 30 seconds after it exits and reads the service file again each time.
|
|
1408
|
+
The supervisor records its pid, the server's, the number of runs and the last
|
|
1409
|
+
exit code in `supervisor.json`, which `status` reports, and its own errors,
|
|
1410
|
+
such as an unreadable service file, in `supervisor.log` beside it. The task
|
|
1411
|
+
runs at normal priority, so builds are not slowed by Task Scheduler's
|
|
1412
|
+
below-normal default.
|
|
1413
|
+
- Stopping the service ends the supervisor's process tree with
|
|
1414
|
+
`taskkill /T /F`; a remote update the server starts runs detached from that
|
|
1415
|
+
tree, so restarting the service does not stop it.
|
|
1416
|
+
- `update` and `rollback` keep versions under
|
|
1417
|
+
`%LOCALAPPDATA%\Stim\services\<label>\versions\` and rewrite only the
|
|
1418
|
+
service file's arguments and previous script. `uninstall` stops the task,
|
|
1419
|
+
deletes it and removes the service file.
|
|
1420
|
+
- The task's environment is your user environment, without a login shell.
|
|
1421
|
+
Builds start tools such as Expo's config loader with the first `node.exe` on
|
|
1422
|
+
`PATH`, and a version manager's `node.exe` shim, such as pnpm's, breaks their
|
|
1423
|
+
Node IPC, so builds fail with `fingerprint-mismatch`. Stim keeps `PATH` as
|
|
1424
|
+
you set it; `install` names a first `node.exe` that is not the Node running
|
|
1425
|
+
the server, and `--path-prepend` puts the real Node first:
|
|
1426
|
+
|
|
1427
|
+
```powershell
|
|
1428
|
+
stim-server service install --serve --path-prepend "C:\Program Files\nodejs" `
|
|
1429
|
+
--env JAVA_HOME="C:\Program Files\Eclipse Adoptium\jdk-17" `
|
|
1430
|
+
--env ANDROID_HOME="$env:LOCALAPPDATA\Android\Sdk"
|
|
1431
|
+
```
|
|
1432
|
+
|
|
1433
|
+
- `stim-server setup` works on Windows for `--build`, as on Linux.
|
|
1134
1434
|
|
|
1135
1435
|
## Remote update
|
|
1136
1436
|
|
|
1137
|
-
A
|
|
1138
|
-
(`--device-host`) can update this
|
|
1139
|
-
connection, so the remote
|
|
1437
|
+
A machine this one approved for builds (`--build`) or device hosting
|
|
1438
|
+
(`--device-host`) can update this machine's `stim-server service` over its tailnet
|
|
1439
|
+
connection, so the remote machine keeps up with the client without ssh. A
|
|
1140
1440
|
server that offers it lists `server-update` in its `hello` features. A paired
|
|
1141
|
-
phone, a `read` or `control` device and
|
|
1142
|
-
cannot. The methods need that approval, not `read`:
|
|
1441
|
+
phone, a `read` or `control` device and the local socket connection cannot. The methods need that approval, not `read`:
|
|
1143
1442
|
|
|
1144
1443
|
- `server.update.status` returns `server` (`version` and `stimBuild`),
|
|
1145
|
-
`service` (the label of the
|
|
1444
|
+
`service` (the label of the service this server runs under, or `null` when
|
|
1146
1445
|
it does not run as a `stim-server service` and so cannot update itself),
|
|
1147
1446
|
`acceptsClientBuilds`, `running` (the update in progress, with its `state`,
|
|
1148
1447
|
`missing` package bytes and the last lines of its `log`) and `last` (how the
|
|
@@ -1154,8 +1453,8 @@ cannot. The methods need that approval, not `read`:
|
|
|
1154
1453
|
`{ "packages": [{ "name", "size", "sha256" }] }`, at most 8 `.tgz` packages
|
|
1155
1454
|
of the client's own build. A `release` older than the version this server
|
|
1156
1455
|
runs is refused with `bad-request`; run `stim-server service update --release`
|
|
1157
|
-
on this
|
|
1158
|
-
`true` on this
|
|
1456
|
+
on this machine to downgrade it. Packages need `server.acceptClientBuilds` set to
|
|
1457
|
+
`true` on this machine (`stim settings set server.acceptClientBuilds true`); a
|
|
1159
1458
|
release needs no setting. One update runs at a time.
|
|
1160
1459
|
- `server.update.chunk` takes `{ id, name, offset, data }`, at most 32 KiB of
|
|
1161
1460
|
base64 at the package's next offset. A package whose bytes do not match its
|
|
@@ -1175,10 +1474,10 @@ arrives once every package is in gets `action-busy`, and a retried reservation
|
|
|
1175
1474
|
of an existing hosted session still answers during the drain.
|
|
1176
1475
|
|
|
1177
1476
|
Stim Desktop starts these updates through its own local stim-server with two
|
|
1178
|
-
methods that only the local
|
|
1477
|
+
methods that only the local Unix socket connection may call:
|
|
1179
1478
|
`machines.update.start` takes `{ "machine" }`, an approved `remote.machines`
|
|
1180
|
-
entry. It connects to that machine
|
|
1181
|
-
the
|
|
1479
|
+
entry. It connects to that machine with the stored credential, goes ahead only
|
|
1480
|
+
with the stim-server that proves the key pinned at approval, and asks it for this server's npm release. When this
|
|
1182
1481
|
server runs from a Stim checkout, it instead packs the checkout's workspace
|
|
1183
1482
|
packages as `npm pack` would and sends them. `machines.update.status` takes
|
|
1184
1483
|
the same `{ "machine" }` and returns `remote` (the machine's
|
|
@@ -1202,18 +1501,19 @@ connected since stim-server started keeps its directory when revoked.
|
|
|
1202
1501
|
same Ruby selection and UTF-8 locale defaults as `pod install`; omitting
|
|
1203
1502
|
`rubyVersion` uses the worker's default Ruby. It
|
|
1204
1503
|
returns `toolchain` (`stimBuild`, a digest of the bundled Stim's built code;
|
|
1504
|
+
`os`, the OS stim-server runs on as Node names it (`darwin`, `linux`, `win32`);
|
|
1205
1505
|
`arch`; `xcode`; `simulatorSdk`; `macosSdk` (from
|
|
1206
1506
|
`xcrun --sdk macosx --show-sdk-version`); `cocoapods`; `runtimes`, the simulator
|
|
1207
1507
|
runtimes with an iPhone simulator to build for; `jdk`, the major version of
|
|
1208
1508
|
the JDK in `JAVA_HOME` or the macOS default; and `androidSdk`, the `ndk`,
|
|
1209
|
-
`buildTools` and `platforms` directories of the SDK in `ANDROID_HOME` or
|
|
1210
|
-
`~/
|
|
1509
|
+
`buildTools` and `platforms` directories of the SDK in `ANDROID_HOME`, else `~/Library/Android/sdk` on macOS or
|
|
1510
|
+
`~/Android/Sdk` on Linux, null without one), `capacity` and `warm`
|
|
1211
1511
|
(`checkout`, `dependencies` when the last install used that lockfile, and
|
|
1212
1512
|
`build` once a build ran there, including a non-empty repository `macos/`
|
|
1213
1513
|
scratch directory) for that repository. `capacity` holds
|
|
1214
1514
|
`running` and `max` offloaded builds, `diskFreeBytes` of the worker root's
|
|
1215
1515
|
volume and `minDiskFreeBytes`, `cpus`, `loadPerCore` (the 5-minute load
|
|
1216
|
-
average per CPU), `builds` (this
|
|
1516
|
+
average per CPU), `builds` (this machine's own Stim runs in prebuild, pods or
|
|
1217
1517
|
compile that it did not offload, plus the offloaded builds it runs), `maxBuilds` (its
|
|
1218
1518
|
`concurrency.maxBuilds`, 0 when unlimited), `maxLoadPerCore` (its
|
|
1219
1519
|
`server.maxLoadPerCore`, default 2), `memoryUsedBytes` (Activity Monitor's
|
|
@@ -1227,12 +1527,25 @@ connected since stim-server started keeps its directory when revoked.
|
|
|
1227
1527
|
simulator-runtime facts. Unused report fields are null. This report has its own
|
|
1228
1528
|
cache, ignores Ruby selection, and is reused for native Xcode build admission.
|
|
1229
1529
|
Clients use the complete report on older native-build-capable hosts.
|
|
1530
|
+
With `build-artifact-cache`, a native Xcode offer can also send
|
|
1531
|
+
`artifact: { fingerprint, cacheKey }`. Its `artifact` result is null on a miss,
|
|
1532
|
+
or `{ fingerprint, cacheKey, name, size, sha256 }` for a completed archive in
|
|
1533
|
+
this client's repository area. The key includes source, toolchain, SDK,
|
|
1534
|
+
architecture and target options. These are exact lookups, not a full inventory.
|
|
1535
|
+
- `build.cached-artifact` takes `repo` and `artifact: { fingerprint, cacheKey }`.
|
|
1536
|
+
It requires the existing build approval. It verifies and streams the cached
|
|
1537
|
+
archive with the same digest-prefixed binary frames as `build.artifact`, and
|
|
1538
|
+
returns its descriptor or null if missing or corrupt. It starts no build and
|
|
1539
|
+
takes no build slot, even when new builds are declined. Completed native Xcode
|
|
1540
|
+
worker archives survive job-output cleanup in their client's repository cache;
|
|
1541
|
+
removing that client's worker area removes the cache too. Other clients and
|
|
1542
|
+
repositories cannot look up those entries.
|
|
1230
1543
|
- `build.sync` takes `repo`, `files` and `done`. `files` is one page of the
|
|
1231
1544
|
manifest, each `{ "path", "kind": "file"|"exec"|"link", "size", "sha256" }`,
|
|
1232
1545
|
a link's blob being its target. Pages accumulate until `done`; the next
|
|
1233
1546
|
`build.sync` starts a new manifest. A path is relative, with no `.`, `..`,
|
|
1234
1547
|
empty or `.git` component (in any case). The result's `missing` lists the digests of the
|
|
1235
|
-
page this
|
|
1548
|
+
page this machine lacks. The client then sends each as binary frames: 32 bytes of
|
|
1236
1549
|
the sha256, then the next bytes of that blob, one blob after another. A frame
|
|
1237
1550
|
for a blob that was not asked for, one that overruns its size, or bytes that
|
|
1238
1551
|
do not match the digest close the connection with 4400. Blobs are kept per
|
|
@@ -1252,7 +1565,7 @@ connected since stim-server started keeps its directory when revoked.
|
|
|
1252
1565
|
synced on this connection. It returns `{ "job" }`. It fails with
|
|
1253
1566
|
`build-busy` while the offer would be declined, naming the reason, or while
|
|
1254
1567
|
another build of the same client and repository runs, or while every one
|
|
1255
|
-
of this
|
|
1568
|
+
of this machine's `concurrency.maxBuilds` slots is held, and with
|
|
1256
1569
|
`build-refused` when `stimBuild` differs. The build runs `offload-worker.mjs` of the bundled Stim with
|
|
1257
1570
|
`STIM_HOME` set to the repository's area. It makes the area's checkout
|
|
1258
1571
|
hold exactly the manifest (a file git lists as untracked and not ignored,
|
|
@@ -1265,12 +1578,15 @@ connected since stim-server started keeps its directory when revoked.
|
|
|
1265
1578
|
Gradle daemon leaves the build's process group, so no claim or slot tracks
|
|
1266
1579
|
it. An Android build keeps the client's daemon warm, with Gradle's idle
|
|
1267
1580
|
timeout set to `server.gradleDaemonIdleMinutes` (default 30; 0 stops it
|
|
1268
|
-
when the build ends), and stops it when the build gets SIGTERM
|
|
1581
|
+
when the build ends), and stops it when the build gets SIGTERM (on Windows,
|
|
1582
|
+
where a cancel ends the build's process tree with `taskkill /T /F`, the
|
|
1583
|
+
daemon sweep below stops it). Gradle
|
|
1269
1584
|
fixes a daemon's idle timeout when the daemon starts, so a new value
|
|
1270
1585
|
applies to the next daemon. Once no build of that client runs, stim-server
|
|
1271
1586
|
sends SIGTERM to each daemon whose command line runs from the client's
|
|
1272
|
-
Gradle home
|
|
1273
|
-
|
|
1587
|
+
Gradle home (on Windows, every process running from it, the Kotlin daemon
|
|
1588
|
+
included, since Windows cannot delete a jar a running process opened) when a build of the client was cancelled, when the client
|
|
1589
|
+
loses `build`, and, for every client, while this machine has less than 2 GB of
|
|
1274
1590
|
available memory (total memory minus Activity Monitor's Memory Used). It
|
|
1275
1591
|
checks every minute and on each change under its server directory. A daemon
|
|
1276
1592
|
whose Gradle home is deleted stops itself within seconds, because Gradle
|
|
@@ -1330,23 +1646,30 @@ connected since stim-server started keeps its directory when revoked.
|
|
|
1330
1646
|
as binary frames, each 32 bytes of its sha256 and then the next bytes, then
|
|
1331
1647
|
answers `{ "name", "size", "sha256" }`, and deletes it here. For an iOS simulator, Android emulator or macOS
|
|
1332
1648
|
job the answer also carries `handoff`, a single-use token, and the staged
|
|
1333
|
-
`.app` or APK stays for 10 minutes so a hosted session on this
|
|
1649
|
+
`.app` or APK stays for 10 minutes so a hosted session on this machine can take it with
|
|
1334
1650
|
`device-host.app.handoff`. A client keeps at most one such bundle; its next
|
|
1335
1651
|
fetched native build or a revoked approval deletes it. An archive nobody fetched is deleted when its job
|
|
1336
1652
|
is cancelled; one left by a server that crashed stays under
|
|
1337
1653
|
`repos/<repo>/out/` until you delete it.
|
|
1338
1654
|
|
|
1339
|
-
The worker root is `server.workerRoot` in this
|
|
1655
|
+
The worker root is `server.workerRoot` in this machine's Stim settings, or
|
|
1340
1656
|
`$STIM_HOME/build-worker`. Each client gets `<root>/<device id>/`, with its
|
|
1341
1657
|
blobs, caches (`CP_HOME_DIR`, `CP_CACHE_DIR`, the pnpm store and
|
|
1342
1658
|
`GRADLE_USER_HOME` and SwiftPM) and one area
|
|
1343
1659
|
per repository under `repos/<repo>/`: the checkout, its own Stim home with
|
|
1344
1660
|
DerivedData, the compilation cache and ccache, and the output. A build never reads or
|
|
1345
|
-
writes this
|
|
1661
|
+
writes this machine's own Stim home. An ownership claim at
|
|
1346
1662
|
`repos/<repo>.claims`, whose child is the build's process group, guards each
|
|
1347
1663
|
area; it is released only once that group is gone, and a claim whose server
|
|
1348
|
-
and build are both gone is recovered by the next build.
|
|
1349
|
-
|
|
1664
|
+
and build are both gone is recovered by the next build. Windows has no
|
|
1665
|
+
process groups, so there the claim follows the build's worker process, and a
|
|
1666
|
+
cancel ends its whole tree with `taskkill /T /F` before the claim is
|
|
1667
|
+
released. The NDK's ninja on Windows cannot open paths longer than 260
|
|
1668
|
+
characters, so a Windows worker keeps each area's checkout and each client's
|
|
1669
|
+
Gradle home in private short directories, `<SystemDrive>\sw\<6 hex>`, with
|
|
1670
|
+
an owner key beside each; the area's `src` is a junction to its checkout.
|
|
1671
|
+
Removing a client deletes them too. With a non-zero
|
|
1672
|
+
`concurrency.maxBuilds`, the build also holds one of this machine's build slots
|
|
1350
1673
|
(`$STIM_HOME/build-slots/`), the same claims local Stim builds take, with the
|
|
1351
1674
|
same child, so a local build waits for it and `builds` counts it. Each finished build
|
|
1352
1675
|
appends a `build` record to the [action log](#actions) with the repository as
|
|
@@ -1355,40 +1678,44 @@ client's directory to reclaim it.
|
|
|
1355
1678
|
|
|
1356
1679
|
## Protocol
|
|
1357
1680
|
|
|
1358
|
-
JSON messages over a WebSocket.
|
|
1681
|
+
JSON messages over a WebSocket. On a network connection they follow the Noise
|
|
1682
|
+
handshake (see [Pairing](#pairing)) and each WebSocket message is one encrypted
|
|
1683
|
+
transport message; on the local Unix socket they are plain JSON. Requests are `{ "id", "method", "params" }`,
|
|
1359
1684
|
answered by `{ "id", "result" }` or `{ "id", "error": { "code", "message" } }`.
|
|
1360
1685
|
Events are `{ "event", "subscription", ... }`.
|
|
1361
1686
|
|
|
1362
|
-
- `hello` must come first. Params: `
|
|
1363
|
-
`
|
|
1364
|
-
|
|
1365
|
-
|
|
1687
|
+
- `hello` must come first. Params: `client` (`name`, `version`), and
|
|
1688
|
+
optionally `access`, `build` or `device-host`, which picks which of the key's
|
|
1689
|
+
own records the connection acts as (see [Build access](#build-access));
|
|
1690
|
+
without it, the pairing in `devices.json`. It never widens what a record
|
|
1691
|
+
allows. The result carries `protocol` (2), the server name and versions, the
|
|
1366
1692
|
device's `capabilities` (see [Scopes](#scopes)), the server's `features`
|
|
1367
1693
|
(`physical-ios` and `physical-android` when it serves `physical: true` for
|
|
1368
1694
|
that platform: see `frames.subscribe` below for an iPhone and
|
|
1369
1695
|
[Physical Android devices](#physical-android-devices), and `notifications`
|
|
1370
1696
|
for `notifications.list` and the `notification` event),
|
|
1371
1697
|
the `actions` it may run
|
|
1372
|
-
(none without `control`)
|
|
1373
|
-
|
|
1698
|
+
(none without `control`) and the record the connection authenticated as.
|
|
1699
|
+
`server.home` is the home folder
|
|
1374
1700
|
of the user the server runs as, so clients can show paths under it as
|
|
1375
|
-
`~/...`.
|
|
1701
|
+
`~/...`.
|
|
1376
1702
|
- `status.subscribe` returns a subscription id. Each `status` event carries a
|
|
1377
1703
|
full payload as `stim status --watch --json` prints it, including each
|
|
1378
1704
|
environment's `physicalDevices`, the phones it leases, and its `agents`, the
|
|
1379
1705
|
Claude Code and Codex sessions working in it. Those carry the session id,
|
|
1380
1706
|
working directory, the short session name the tool keeps, and times, never
|
|
1381
1707
|
prompts or conversation. `openUrl` there is a `claude://` or `codex://` link
|
|
1382
|
-
that only the
|
|
1708
|
+
that only the machine can open; the server has no action that opens it. `webUrl`
|
|
1383
1709
|
is a Claude Code session's `https://claude.ai/code/` link while Remote Control
|
|
1384
1710
|
is connected, which a phone opens in the Claude app or a browser.
|
|
1385
1711
|
`endedAgents` lists the sessions that stopped running there in the last 3
|
|
1386
1712
|
days, with the same fields as last found, no `pid`, and `endedAt`. The server
|
|
1387
1713
|
drops `CLAUDE_CODE_SESSION_ID` and `CODEX_THREAD_ID` from the environment of
|
|
1388
1714
|
the `stim` commands it runs, so a phone's reload is not recorded as the work
|
|
1389
|
-
of the agent session that started the server.
|
|
1390
|
-
|
|
1391
|
-
subscriber
|
|
1715
|
+
of the agent session that started the server. The server runs the status
|
|
1716
|
+
watch itself, in a worker thread, from the moment it is ready, so a
|
|
1717
|
+
subscriber gets the latest payload at once; all subscribers share it.
|
|
1718
|
+
While any status subscription is open, the server keeps a CPU
|
|
1392
1719
|
and memory history from each payload's `machine.owners`, and every `status`
|
|
1393
1720
|
event carries it beside the payload as `usage`, once it holds a reading:
|
|
1394
1721
|
`{ "intervalMs", "endAt", "environments", "devices" }`. It covers the last 10
|
|
@@ -1405,6 +1732,35 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1405
1732
|
`grantedAt` times as `ownLeases`, so a client can tell a person controlling a
|
|
1406
1733
|
device from an agent driving it: an `activity.driver` of `stim device lock`
|
|
1407
1734
|
whose `since` is in `ownLeases` is a phone.
|
|
1735
|
+
- A server that offers the following status views lists `status-views` in its
|
|
1736
|
+
`hello` features.
|
|
1737
|
+
- `workspaces.subscribe` returns a subscription id and sends `workspaces`
|
|
1738
|
+
events, each with a `seq` that starts at 0 and grows by one. The first
|
|
1739
|
+
carries `snapshot`: `{ "workspaces", "worktrees", "archived" }`. Each
|
|
1740
|
+
workspace is its environment as `status` reports it, without what only a
|
|
1741
|
+
shown workspace needs: a build keeps its outcome, timing and first located
|
|
1742
|
+
diagnostic, each platform's history only its newest build and the failures
|
|
1743
|
+
right before it, `logs` only `errorsSinceMarker`, a pull request no
|
|
1744
|
+
`reviewDecision` or `checkedAt`, and a macOS app no launch `arguments`.
|
|
1745
|
+
`worktrees` are the unprovisioned worktrees' `path`, `branch`, `repository`,
|
|
1746
|
+
`git`, `gitChip` and pull request without `reviewDecision` or `checkedAt`; `archived` is
|
|
1747
|
+
`{ "count", "bytes", "newest" }` with the 10 newest archives. Later events
|
|
1748
|
+
carry only what changed: `workspaces` and `worktrees` as
|
|
1749
|
+
`{ "upsert", "remove" }` (whole entries by `path`, and the paths that are
|
|
1750
|
+
gone), and `archived` when it changed. A client that misses a `seq`
|
|
1751
|
+
subscribes again for a new snapshot.
|
|
1752
|
+
- `workspace.subscribe` with `{ "workspace" }` sends `workspace` events with
|
|
1753
|
+
that workspace's full `environment`, on subscribing and on every change to
|
|
1754
|
+
it, or `null` while no workspace has that path.
|
|
1755
|
+
- `machine.subscribe` sends `machine` events with `capacity`, `machine`,
|
|
1756
|
+
`deviceLeases`, `simctlAvailable` and `maintenance` without `recent` and
|
|
1757
|
+
`sizes`, plus `usage` and `ownLeases` as on `status` events.
|
|
1758
|
+
- `builds.history` with `{ "workspace" }` returns that workspace's full
|
|
1759
|
+
`{ "builds" }`. `archived.list` with optional `before` and `limit` (at most 50) returns `{ "archived", "usage", "next" }`: archives newest removal first,
|
|
1760
|
+
and the `before` of the next page, or null. `worktrees.list` returns the full
|
|
1761
|
+
`{ "worktrees" }` and `maintenance.get` the full `{ "maintenance" }`. These
|
|
1762
|
+
answer from the server's latest status, waiting up to 30 seconds for the
|
|
1763
|
+
first one.
|
|
1408
1764
|
- `logs.query` returns `{ "records" }`, and `logs.subscribe` sends `logs`
|
|
1409
1765
|
events: first the last `tail` matching records, then new ones in batches.
|
|
1410
1766
|
Both take the Stim Desktop log viewer's filters: exactly one of `workspace`
|
|
@@ -1431,8 +1787,8 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1431
1787
|
with a message naming the archive id.
|
|
1432
1788
|
- `stats.get` returns the same payload as `stim stats --json`, using the shared
|
|
1433
1789
|
core reader in a bounded, cancellable server child. The stats part of
|
|
1434
|
-
`machine.details` uses the same reader. `settings.get`
|
|
1435
|
-
|
|
1790
|
+
`machine.details` uses the same reader. `settings.get` uses the in-process
|
|
1791
|
+
settings API, which masks sensitive values. Without `workspace`,
|
|
1436
1792
|
these reads use the home directory as their project context.
|
|
1437
1793
|
- `frames.subscribe` takes `workspace`, `platform` (`ios`, `android`, `web` or `macos`),
|
|
1438
1794
|
`slot` (`default` when absent), `fps` (1 to 30, 5 by default) and `maxEdge`
|
|
@@ -1532,7 +1888,7 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1532
1888
|
and on an iPhone Duo bit 1 while folded or bit 2 while unfolded,
|
|
1533
1889
|
u16 header length, u32 sequence number of the messages sent on this
|
|
1534
1890
|
subscription, f64 capture time in milliseconds since the epoch on the
|
|
1535
|
-
|
|
1891
|
+
machine's clock, u16 width, u16 height, u8 subscription id length and the
|
|
1536
1892
|
ASCII id), then one Annex-B access unit. Every keyframe carries its SPS
|
|
1537
1893
|
and PPS, and the stream has no B-frames, so each access unit is shown as
|
|
1538
1894
|
it arrives. A change of size, such as a rotation or a Duo fold, restarts
|
|
@@ -1640,7 +1996,7 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1640
1996
|
it.
|
|
1641
1997
|
- `recording`: true while the server records the device now.
|
|
1642
1998
|
- `spans`: the recorded time ranges `{ start, end }`, in epoch milliseconds on
|
|
1643
|
-
the
|
|
1999
|
+
the machine's clock, oldest first. Segments less than 1.5 seconds apart form
|
|
1644
2000
|
one span; the gaps between spans are time nothing was recorded, such as
|
|
1645
2001
|
after `stim stop`.
|
|
1646
2002
|
- `markers`: `{ at, kind, command?, label }` from the start of the first span
|
|
@@ -1756,7 +2112,7 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1756
2112
|
without running `stim`: `volumes`, one per volume that holds a Stim
|
|
1757
2113
|
workspace, Stim home, or the simulators, with `mount`, `holds`, `freeBytes`
|
|
1758
2114
|
(free space without purgeable space, which Stim's disk budget measures) and
|
|
1759
|
-
`totalBytes`; `memory` with `totalBytes`, `usedBytes` (the
|
|
2115
|
+
`totalBytes`; `memory` with `totalBytes`, `usedBytes` (the machine's memory in
|
|
1760
2116
|
use as Activity Monitor's "Memory Used" counts it: app memory, wired and
|
|
1761
2117
|
compressed; null off macOS) and the macOS `pressure` level (`normal`,
|
|
1762
2118
|
`warning`, `critical`, or null); `load` with the 1, 5 and 15
|
|
@@ -1769,23 +2125,27 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1769
2125
|
critical) and `diskFreeBytes` of the startup volume; a field is null when it
|
|
1770
2126
|
cannot be read. `sinceMs` returns only the samples taken after it.
|
|
1771
2127
|
- `machine.details` returns `{ "gc", "stats", "measuredAt" }`: the payloads of
|
|
1772
|
-
|
|
2128
|
+
GC dry-run and stats report APIs, both read in process from the home directory, so
|
|
1773
2129
|
a phone can show what Stim Desktop's Machine page shows about disk: every
|
|
1774
2130
|
simulator, AVD, iOS runtime and system image, shared caches, recordings,
|
|
1775
2131
|
workspace build outputs and logs, and what `stim gc --delete` would free. The
|
|
1776
|
-
|
|
1777
|
-
anything for this request. A part is null when its
|
|
2132
|
+
GC read is always the dry run with no other scope; the server never deletes
|
|
2133
|
+
anything for this request. A part is null when its read failed, and
|
|
1778
2134
|
`gcError` or `statsError` says why. It needs only `read`. The server keeps
|
|
1779
2135
|
one result for 60 seconds, shared by every connection: a request while the
|
|
1780
|
-
|
|
1781
|
-
|
|
2136
|
+
reads run waits for them, and `measuredAt` says when they started. GC and
|
|
2137
|
+
doctor have the API's 60 second execution budget; the shared reads also retain
|
|
2138
|
+
the server's 150 second limit. API cleanup has a separate 35 second budget;
|
|
2139
|
+
unfinished cleanup returns `STIM_CLAIM_UNAVAILABLE`, and an unverifiable
|
|
2140
|
+
child is left untouched. Servers that predate it answer
|
|
1782
2141
|
`unknown-method`. It also carries `buildMachines`, the `remoteMachines` list
|
|
1783
|
-
of `stim doctor --json
|
|
1784
|
-
show whether each remote
|
|
2142
|
+
of `stim doctor --json` (never with `--fix`), so a phone can
|
|
2143
|
+
show whether each remote machine takes builds. The server runs doctor only
|
|
1785
2144
|
when `remote.machines` names a machine, else the list is empty; it runs it
|
|
1786
2145
|
in the registered workspace that ran doctor for iOS most recently, because
|
|
1787
|
-
doctor judges a machine against an app.
|
|
1788
|
-
|
|
2146
|
+
doctor judges a machine against an app. This read does not repair or record a
|
|
2147
|
+
CLI doctor run. Changing the selected workspace clears its cached result and
|
|
2148
|
+
prevents an older read from overwriting the new workspace's result. `buildMachines` is null with
|
|
1789
2149
|
`buildMachinesError` when doctor failed, the config could not be read, or no
|
|
1790
2150
|
registered workspace exists. The reply never waits for doctor, whose offer
|
|
1791
2151
|
to an unreachable machine can take about 13 seconds: it carries the last
|
|
@@ -1794,10 +2154,10 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1794
2154
|
at a time, and sets `buildMachinesPending` while that background run has not
|
|
1795
2155
|
settled a result yet, or the settled one is 60 seconds old or older. A client
|
|
1796
2156
|
that wants the refreshed result asks `machine.details` again. It also
|
|
1797
|
-
carries `buildClients`, the builds this
|
|
1798
|
-
per client
|
|
2157
|
+
carries `buildClients`, the builds this machine ran for other machines, one entry
|
|
2158
|
+
per client machine read from the `build` records of the audit log, with `id`,
|
|
1799
2159
|
`name`, `builds`, `failed`, `buildMs`, `lastAt` and the same three counts
|
|
1800
|
-
for `today`, most recent client first, with `today` on this
|
|
2160
|
+
for `today`, most recent client first, with `today` on this machine's local
|
|
1801
2161
|
calendar day. Servers that predate it leave it out.
|
|
1802
2162
|
- `unsubscribe` ends a subscription.
|
|
1803
2163
|
- `push.register` takes `token`, an Expo push token, `events`, one or more
|
|
@@ -1842,8 +2202,8 @@ so clients can replay what happened while nobody watched. It records a device
|
|
|
1842
2202
|
while `stim status` shows an automation tool driving it (`activity.state` is
|
|
1843
2203
|
`driven`), or while a client has a `frames.subscribe` subscription to it. It
|
|
1844
2204
|
records nothing else, holds no device awake and changes no device setting. To
|
|
1845
|
-
see drivers, the
|
|
1846
|
-
|
|
2205
|
+
see drivers, it reads the status watch the server runs for as long as it
|
|
2206
|
+
runs, shared with status subscribers.
|
|
1847
2207
|
|
|
1848
2208
|
Recording goes through the device's `stim-frames` helper, shared with live
|
|
1849
2209
|
subscribers. The helper runs a second H.264 encoder for it, at 720 pixels on
|
|
@@ -1878,7 +2238,7 @@ the `.part` segments of a server that stopped. When a status payload shows
|
|
|
1878
2238
|
workspace within seconds and deletes its recordings. `stim stop` ends recording
|
|
1879
2239
|
and keeps the footage; `stim worktree remove` and `stim gc` delete it. A gc that
|
|
1880
2240
|
deletes the segment being written loses the rest of that segment; the next one
|
|
1881
|
-
is written as usual. Recordings stay on the
|
|
2241
|
+
is written as usual. Recordings stay on the machine and are served only to paired
|
|
1882
2242
|
clients.
|
|
1883
2243
|
|
|
1884
2244
|
## Push notifications
|
|
@@ -1896,7 +2256,7 @@ shows them in its attention strip. The server pushes, per device and only for
|
|
|
1896
2256
|
the events the device chose:
|
|
1897
2257
|
|
|
1898
2258
|
- `started`: a workspace began warming (`phase` `warming`), or an agent first
|
|
1899
|
-
drove one of its devices. It is grouped per
|
|
2259
|
+
drove one of its devices. It is grouped per machine, and opens the workspace, or the device viewer
|
|
1900
2260
|
once an agent drives it. An agent driving the workspace updates the warming
|
|
1901
2261
|
notification in place.
|
|
1902
2262
|
- `stuck`: an agent drove the workspace, its devices are still up, and nothing
|
|
@@ -1950,9 +2310,9 @@ registers does not push. During the phone's quiet hours nothing pushes: a
|
|
|
1950
2310
|
problem that still holds when they end pushes then, and what started or
|
|
1951
2311
|
finished during them does not.
|
|
1952
2312
|
|
|
1953
|
-
While at least one device is paired, the server
|
|
1954
|
-
|
|
1955
|
-
|
|
2313
|
+
While at least one device is paired, the server reads its status watch, even
|
|
2314
|
+
with no client connected, and reads the free space of Stim's volumes and the
|
|
2315
|
+
memory pressure every minute.
|
|
1956
2316
|
While a device wants `finished`, it looks up the pull requests of worktree
|
|
1957
2317
|
branches that have an upstream every 5 minutes, with one `gh api graphql` call
|
|
1958
2318
|
per repository, the lookup `stim gc` uses. Without `gh`, or when it is signed
|
|
@@ -1964,9 +2324,9 @@ count. More than three at once become one summary push that opens the
|
|
|
1964
2324
|
phone's home screen.
|
|
1965
2325
|
|
|
1966
2326
|
Pushes go to the Expo push service, `https://exp.host/--/api/v2/push/send`,
|
|
1967
|
-
which forwards them to Apple. No APNs key or other secret lives on the
|
|
1968
|
-
workspace push carries the workspace title, a one-line cause and the
|
|
1969
|
-
as the subtitle; a machine or summary push has the
|
|
2327
|
+
which forwards them to Apple. No APNs key or other secret lives on the machine. A
|
|
2328
|
+
workspace push carries the workspace title, a one-line cause and the machine's name
|
|
2329
|
+
as the subtitle; a machine or summary push has the machine's name as its title. In
|
|
1970
2330
|
`data` it carries the `ref`, the screen to open (`home`, `machine`,
|
|
1971
2331
|
`workspace`, `device`, `build` or `url`), and the workspace's absolute path,
|
|
1972
2332
|
with the platform and slot for a device, the platform for build details and
|
|
@@ -2001,9 +2361,9 @@ and needs-attention vectors. Notification delivery remains local to each.
|
|
|
2001
2361
|
|
|
2002
2362
|
## Notification history
|
|
2003
2363
|
|
|
2004
|
-
The server logs the notifications the rules produce for the
|
|
2364
|
+
The server logs the notifications the rules produce for the machine, whether or not
|
|
2005
2365
|
a phone was pushed, so a phone can list what it missed. While any device is
|
|
2006
|
-
paired, it runs the rules once more for the
|
|
2366
|
+
paired, it runs the rules once more for the machine itself, with every category, no
|
|
2007
2367
|
quiet hours and the lowest `stuckMinutes` a registered device asked for (15
|
|
2008
2368
|
without one). Each notification it produces is an entry; a `control` conflict is
|
|
2009
2369
|
an entry too, listed only to the phone that lost the device. Pull request
|
|
@@ -2040,13 +2400,14 @@ A device with `control` can send `action` with params `{ "action", "workspace" }
|
|
|
2040
2400
|
| Action | Params | Runs in the workspace |
|
|
2041
2401
|
| -------- | -------------------------------------------------------------------- | ------------------------------- |
|
|
2042
2402
|
| `reload` | `platform` (`ios` or `android`), optional; needed when both are live | `stim reload [platform] --json` |
|
|
2043
|
-
| `stop` | none |
|
|
2403
|
+
| `stop` | none | in-process workspace stop API |
|
|
2044
2404
|
|
|
2045
|
-
|
|
2046
|
-
|
|
2047
|
-
|
|
2048
|
-
|
|
2049
|
-
|
|
2405
|
+
`reload` passes its fixed argument list to the bundled `stim`, without a shell.
|
|
2406
|
+
`stop` calls the typed API in the server process and acts on the exact registered
|
|
2407
|
+
workspace, including a partial workspace that no longer has an app manifest.
|
|
2408
|
+
`workspace` must be a project path Stim has registered, the `path` a status
|
|
2409
|
+
payload lists. The result's `output` retains the CLI JSON shape; stop returns
|
|
2410
|
+
`{ root, ok, ...outcomes }`. The server refuses the request and runs nothing with:
|
|
2050
2411
|
|
|
2051
2412
|
- `forbidden` when the device has only `read`;
|
|
2052
2413
|
- `unknown-action` for any other action;
|
|
@@ -2057,10 +2418,13 @@ nothing with:
|
|
|
2057
2418
|
- `action-busy` while another action runs in that workspace. The server runs
|
|
2058
2419
|
one action per workspace at a time, across all connections.
|
|
2059
2420
|
|
|
2060
|
-
|
|
2061
|
-
and
|
|
2062
|
-
and
|
|
2063
|
-
|
|
2421
|
+
Failures use `action-failed` with the command's error or the stop cleanup summary
|
|
2422
|
+
and bounded diagnostic detail. Registration storage failures retain the original
|
|
2423
|
+
record and report the storage error. An action fails with `action-failed` after
|
|
2424
|
+
120 seconds: reload's CLI child gets SIGTERM, while stop is cancelled. A stop
|
|
2425
|
+
waiting for native work ends its wait; one already tearing down finishes cleanup.
|
|
2426
|
+
The workspace remains busy until that work drains, and server shutdown waits
|
|
2427
|
+
for it. An action keeps running when its client disconnects.
|
|
2064
2428
|
|
|
2065
2429
|
Every `action` request from a paired device, refused or run, appends one line
|
|
2066
2430
|
to `$STIM_HOME/server/actions.ndjson`: `at`, `device` (`id` and `name`),
|
|
@@ -2226,8 +2590,11 @@ appends a line to the action log, with `action` set to `control.begin`,
|
|
|
2226
2590
|
ended or whom it took the device from. Inputs are not logged.
|
|
2227
2591
|
|
|
2228
2592
|
The error codes `unauthorized`, `pairing-expired`, and `protocol-unsupported`
|
|
2229
|
-
refuse the client until it pairs again or updates; `
|
|
2230
|
-
|
|
2593
|
+
refuse the client until it pairs again or updates; `unknown-secret` means the
|
|
2594
|
+
server does not hold the pairing token or setup ticket, or not yet, so a client
|
|
2595
|
+
with a setup ticket retries until setup runs; clients retry the others.
|
|
2596
|
+
Refusals during the handshake arrive as the WebSocket close reason with code
|
|
2597
|
+
4401, not as a JSON error.
|
|
2231
2598
|
|
|
2232
2599
|
The package exports the message types, and the build writes their JSON Schema
|
|
2233
2600
|
to `dist/protocol.schema.json`, exported as `@stim-cli/server/protocol.schema.json`.
|