@stim-cli/server 1.20.1 → 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 +661 -268
- 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-Dy0DlR96.mjs → stim-server-BQKNg9Jp.mjs} +3618 -2787
- 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,73 +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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
|
272
|
+
`control` capability, but it is full access to this account in practice (see
|
|
273
|
+
[Build access](#build-access)).
|
|
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.
|
|
276
|
+
|
|
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
|
|
130
281
|
tailnet-only HTTPS route on 7443 or the next free port. Older managed services
|
|
131
282
|
use the service update busy-wait and rollback behavior. Newer versions stay
|
|
132
|
-
installed; tools report a Stim build difference. A reused server must
|
|
133
|
-
|
|
134
|
-
|
|
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.
|
|
135
286
|
|
|
136
287
|
When a Desktop-run server already answers on the port, setup reuses it and
|
|
137
288
|
installs no LaunchAgent. It requires an existing tailnet route and refuses
|
|
@@ -166,7 +317,7 @@ earlier releases did. Plain progress goes to stdout; errors use
|
|
|
166
317
|
`stim-server: <message>` on stderr (when stdout is a terminal, the refusal appears on stdout only).
|
|
167
318
|
`--json` sends the long (verbose) progress to stderr, without the banner, and prints one final payload with `ok`,
|
|
168
319
|
`label`, `port`, `route` (state, DNS name, HTTPS port), `server` (version and
|
|
169
|
-
Stim build), `managed`, separate `granted`
|
|
320
|
+
Stim build), `managed`, separate `granted` record ids and client names,
|
|
170
321
|
`permissions`, `tools` and `warnings`. Final permission values are `granted`,
|
|
171
322
|
`denied` (not authorized), `skipped` or `not-needed`; a timed-out wait remains
|
|
172
323
|
`pending` in the journal and names its unavailable feature. Exit codes come
|
|
@@ -179,13 +330,13 @@ from the final journal:
|
|
|
179
330
|
| 2 | No grant before expiry, or an already expired command. |
|
|
180
331
|
| 3 | At least one grant, but another chosen capability, permission or tool is missing; the output names affected features. |
|
|
181
332
|
|
|
182
|
-
Setup writes `$STIM_HOME/server/setup/<
|
|
333
|
+
Setup writes `$STIM_HOME/server/setup/<journal>.json` from its first
|
|
183
334
|
step and after every change, including completion and the exit code. The
|
|
184
|
-
|
|
335
|
+
`GET /setup/<journal>` route described above mirrors it until expiry,
|
|
185
336
|
hiding tools until a build grant. Each valid setup run prunes journals more
|
|
186
337
|
than one hour past expiry. A dedicated `server/setup.claims` ownership claim
|
|
187
338
|
serializes runs; the service update claim is released before waiting for
|
|
188
|
-
|
|
339
|
+
the requesting machine and permissions. A competing setup refuses with the exact claim
|
|
189
340
|
and removal command. Ctrl-C or SIGTERM finishes the running step as failed
|
|
190
341
|
with detail `interrupted`, completes the journal, releases the setup claim,
|
|
191
342
|
and exits 1. A typed N also exits 1; a question timeout follows ticket expiry
|
|
@@ -194,8 +345,8 @@ and exits 2.
|
|
|
194
345
|
The `To undo` line (or the `--verbose` summary) lists the undo commands:
|
|
195
346
|
|
|
196
347
|
```bash
|
|
197
|
-
stim-server devices revoke <build-
|
|
198
|
-
stim-server devices revoke <device-host-
|
|
348
|
+
stim-server devices revoke <build-client-id>
|
|
349
|
+
stim-server devices revoke <device-host-client-id>
|
|
199
350
|
stim-server service uninstall --label <label>
|
|
200
351
|
```
|
|
201
352
|
|
|
@@ -209,12 +360,13 @@ permissions remain; remove permission grants in System Settings if desired.
|
|
|
209
360
|
|
|
210
361
|
## Tailscale
|
|
211
362
|
|
|
212
|
-
Tailscale carries
|
|
213
|
-
|
|
214
|
-
|
|
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
|
|
215
367
|
same tailnet or with the Mac shared to the phone's user.
|
|
216
368
|
|
|
217
|
-
`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
|
|
218
370
|
addresses, never on every interface. It re-reads the Tailscale state in the
|
|
219
371
|
background, so a server that started before Tailscale was up, or while it did
|
|
220
372
|
not answer, starts listening on the Tailscale addresses once it runs, and stops
|
|
@@ -245,10 +397,10 @@ Funnel port makes it public, and `pair` refuses.
|
|
|
245
397
|
When Tailscale is not running, `stim-server` listens on loopback only and
|
|
246
398
|
says so on stderr. Start Tailscale, then restart `stim-server`.
|
|
247
399
|
|
|
248
|
-
Desktop uses `route.setup` with no parameters on its
|
|
249
|
-
|
|
250
|
-
no-op. The server refuses
|
|
251
|
-
|
|
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
|
|
252
404
|
through Funnel. Only the fixed `tailscale serve --bg --https=<free port>
|
|
253
405
|
http://127.0.0.1:<server port>` invocation runs, followed by route verification.
|
|
254
406
|
No LaunchAgent or Funnel configuration is created. Failure output remains
|
|
@@ -259,35 +411,72 @@ available for an explicit retry, including Tailscale's HTTPS approval link.
|
|
|
259
411
|
`stim-server pair` prints the JSON that the pairing QR code encodes:
|
|
260
412
|
|
|
261
413
|
```json
|
|
262
|
-
{
|
|
414
|
+
{
|
|
415
|
+
"v": 2,
|
|
416
|
+
"name": "Janic's MacBook Pro",
|
|
417
|
+
"endpoint": "wss://janics-mbp.tail1234.ts.net:7443",
|
|
418
|
+
"pairingToken": "...",
|
|
419
|
+
"fingerprint": "..."
|
|
420
|
+
}
|
|
263
421
|
```
|
|
264
422
|
|
|
265
|
-
The endpoint names the route's port, and omits it for 443.
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
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.
|
|
284
473
|
The server answers 403 to a WebSocket upgrade that carries `Sec-Fetch-Site`, or
|
|
285
474
|
an `Origin` other than the requested host (`http:` on loopback, `https:`
|
|
286
475
|
through the route), and counts no failed attempt, so a web page can neither
|
|
287
|
-
connect nor block this
|
|
476
|
+
connect nor block this machine's clients.
|
|
288
477
|
|
|
289
478
|
Paired devices live in `$STIM_HOME/server/devices.json`. Revoking a device
|
|
290
|
-
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
|
|
291
480
|
and once a second, so a missed filesystem notification cannot leave a revoked
|
|
292
481
|
connection authorized.
|
|
293
482
|
|
|
@@ -298,7 +487,7 @@ A paired device has the `read` capability, which serves state, or also
|
|
|
298
487
|
With the `workspace-diff` feature, `read` also serves changed and untracked
|
|
299
488
|
text file contents in registered workspaces, including any non-ignored
|
|
300
489
|
untracked text file such as an unignored `.env`. Pairing grants `read` only,
|
|
301
|
-
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,
|
|
302
491
|
`stim-server devices grant <id> --control` adds control to a paired device and
|
|
303
492
|
`--read` takes it away. Nothing a client sends changes its own capabilities.
|
|
304
493
|
The server checks the device's capabilities in `devices.json` on every action
|
|
@@ -308,47 +497,76 @@ registration check. `hello` reports
|
|
|
308
497
|
the capabilities and actions of the connection's device when it connects; a
|
|
309
498
|
connection sees a new grant after it reconnects. Under Stim Host, an approved
|
|
310
499
|
`hello` also carries the same `host` grants as `/health`, which `stim doctor`
|
|
311
|
-
reports for remote
|
|
500
|
+
reports for remote machines.
|
|
501
|
+
|
|
502
|
+
Every method other than `hello` needs `read`, except the methods with their own
|
|
503
|
+
approval: `build.*` needs `build`, the `device-host.*` methods that run a hosted
|
|
504
|
+
session need `device-host`, and `server.update.*` needs the build or device-host
|
|
505
|
+
approval of the requesting machine (see [Remote update](#remote-update)). A device
|
|
506
|
+
with only `build` gets `forbidden` for every other method.
|
|
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
|
+
```
|
|
312
532
|
|
|
313
|
-
|
|
314
|
-
|
|
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.
|
|
315
535
|
|
|
316
536
|
## Build access
|
|
317
537
|
|
|
318
|
-
`build` lets another
|
|
538
|
+
`build` lets another machine on the tailnet run its project's code on this machine to
|
|
319
539
|
build for it: config plugins, CocoaPods hooks, Xcode script phases and Gradle
|
|
320
|
-
plugins run as the user `stim-server` runs as.
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
`stim-server
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
`devices grant`
|
|
348
|
-
`control` to a build client. Build clients live in
|
|
349
|
-
`$STIM_HOME/server/build-clients.json`, apart from `devices.json
|
|
350
|
-
`stim-server` release without `build` never reads them and refuses their
|
|
351
|
-
tokens.
|
|
540
|
+
plugins run as the user `stim-server` runs as. The offload worker runs with that
|
|
541
|
+
user's real home directory and no sandbox, so a build grant is equivalent to
|
|
542
|
+
full access to the account `stim-server` runs as. In practice it includes
|
|
543
|
+
everything `read` and `control` allow: project code can edit the
|
|
544
|
+
server's `devices.json` (under `~/.stim/server` by default, which the worker's
|
|
545
|
+
real home directory still reaches) to grant itself either, read other build
|
|
546
|
+
clients' checkouts and blobs, and persist through LaunchAgents or shell startup
|
|
547
|
+
files. `devices grant` never turns a paired device into a build client, and the
|
|
548
|
+
protocol does not list `read` or `control` among a build client's capabilities,
|
|
549
|
+
but do not rely on that as a boundary. Grant it only to machines you trust with
|
|
550
|
+
that. Revoking the grant stops future builds and kills the running job's
|
|
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`.
|
|
352
570
|
|
|
353
571
|
## Device-host approval
|
|
354
572
|
|
|
@@ -356,37 +574,30 @@ Device hosting has a separate `device-host` capability. An approved client can
|
|
|
356
574
|
reserve, boot, reconnect to and stop its own iOS simulator or Android emulator
|
|
357
575
|
through the protocol. It can deliver, install and launch a compatible iOS app
|
|
358
576
|
bundle, Android APK or prebuilt macOS app, stream the iOS simulator, Android emulator or macOS app and control it. Hosted
|
|
359
|
-
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).
|
|
360
578
|
|
|
361
579
|
The Stim client can name expected hosts with
|
|
362
580
|
`stim settings set remote.machines '["<mac>"]'` and request access with
|
|
363
|
-
`stim doctor --fix
|
|
364
|
-
|
|
365
|
-
|
|
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
|
|
366
585
|
approval request. Use `stim ios --remote <machine>` or `stim android --remote <machine>` for explicit placement.
|
|
367
586
|
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
On the hosting Mac, inspect `stim-server devices`, then approve the matching
|
|
377
|
-
request with `stim-server devices grant <id> --device-host`, run
|
|
378
|
-
[`stim-server setup`](#set-up-a-worker-mac) there with its node and ticket, or use **Allow**
|
|
379
|
-
in Stim Desktop. Approve only an expected request: it authorizes that Mac to
|
|
380
|
-
reserve session-owned simulators or emulators and run native app code. **Deny**
|
|
381
|
-
or `stim-server devices revoke <id>` removes it; revocation also closes its
|
|
382
|
-
open authenticated connections. The local-process trust boundary described in
|
|
383
|
-
[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.
|
|
384
595
|
|
|
385
596
|
Hosting clients live in `$STIM_HOME/server/device-host-clients.json`, separate
|
|
386
|
-
from phone pairings and build clients. A hosting
|
|
387
|
-
`control` or `build` access, including access to unrelated workspaces.
|
|
388
|
-
|
|
389
|
-
|
|
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.
|
|
390
601
|
|
|
391
602
|
### Hosted here
|
|
392
603
|
|
|
@@ -406,9 +617,9 @@ Each row has `id`, `client: { id, name }`, `platform`, nullable `device` and `ap
|
|
|
406
617
|
session through the existing stop path, closing Metro, view, agent and logs
|
|
407
618
|
before owned-device teardown. Repeating a stopped session returns `stopped`;
|
|
408
619
|
an absent id gets `unknown-session`.
|
|
409
|
-
Both requests
|
|
410
|
-
|
|
411
|
-
|
|
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
|
|
412
623
|
attached to this server reads as `unknown`; stop reconciles it through the same
|
|
413
624
|
ownership checks. The approved-client `device-host.stop` remains limited to
|
|
414
625
|
that client's own sessions.
|
|
@@ -449,7 +660,12 @@ This protocol does not select a host for `stim ios` or `stim android`.
|
|
|
449
660
|
|
|
450
661
|
On the hosting Mac, `hosting.agentDriver` names the tool that lets a client's
|
|
451
662
|
coding agent drive the macOS app hosted for that client. `none` (the default)
|
|
452
|
-
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
|
|
453
669
|
hosted macOS apps: it starts with the first, stops after the last, on
|
|
454
670
|
revocation and on server shutdown, and restarts if it exits while apps run. The
|
|
455
671
|
daemon is held under an ownership claim at `server/agent-device.claims` whose
|
|
@@ -465,10 +681,13 @@ ANY /device-host/agent/<session>/<driver path>
|
|
|
465
681
|
|
|
466
682
|
on the tailnet `serve` route is forwarded to the loopback daemon, with the
|
|
467
683
|
daemon's own token, only when all of these hold: the request carries that
|
|
468
|
-
session's token as a bearer token,
|
|
469
|
-
session's
|
|
470
|
-
|
|
471
|
-
|
|
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.
|
|
472
691
|
|
|
473
692
|
The `agent-device` adapter runs the binary that `STIM_AGENT_DEVICE_BIN` names
|
|
474
693
|
in `stim-server`'s environment, or else the first of
|
|
@@ -620,13 +839,13 @@ session before starting another transfer. Manifest, file and partial blobs are s
|
|
|
620
839
|
by attempts of one session in its content-addressed store; offers recheck complete
|
|
621
840
|
blob digests and request only missing bytes.
|
|
622
841
|
|
|
623
|
-
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
|
|
624
843
|
the manifest arrives, send `device-host.app.handoff` with
|
|
625
844
|
`{session, attempt, build: {handoff, sha256}}`, where `handoff` is the token
|
|
626
845
|
and `sha256` the archive digest from that job's `build.artifact` answer. The
|
|
627
846
|
server hands the build over only when the build client that ran it still has
|
|
628
847
|
`build`, the caller has `device-host`, and both approvals belong to the same
|
|
629
|
-
|
|
848
|
+
client key. It copies only regular files, and links where the manifest
|
|
630
849
|
declares links, whose directory resolves inside the staged bundle and whose
|
|
631
850
|
bytes match their manifest digest; it answers `{files, bytes}` for what it
|
|
632
851
|
took. The token is spent once the handoff starts. Re-offer and upload whatever
|
|
@@ -677,10 +896,10 @@ retain the same reconciliation rules as iOS.
|
|
|
677
896
|
|
|
678
897
|
With `hosting.agentDriver: agent-device`, each installed Android session gets
|
|
679
898
|
its own daemon and child-aware claim under `device-host/sessions/<session>/agent-device.claims`.
|
|
680
|
-
Both
|
|
899
|
+
Both machines need agent-device 0.21.22 or later. The host verifies the serial policy
|
|
681
900
|
digest and `android-instance` backend and advertises `hosted-android-agent`.
|
|
682
901
|
`device-host.app.attach` and session attach carry a session grant with
|
|
683
|
-
`android:mobile:<serial>` and the same token
|
|
902
|
+
`android:mobile:<serial>` and the same token checks as iOS.
|
|
684
903
|
The client writes a 0600 remote config under `hosted-android/<slot>/` and reports
|
|
685
904
|
it as `android.host.agent`. Use `agent-device <command> --remote-config <file>`.
|
|
686
905
|
Missing or unsupported agent-device reports `driver: none` with its reason.
|
|
@@ -857,8 +1076,9 @@ Automatic native macOS placement remains separate work.
|
|
|
857
1076
|
### Hosted viewer relay
|
|
858
1077
|
|
|
859
1078
|
The client's stim-server relays a hosted workspace's iOS simulator, Android emulator or macOS view and input to
|
|
860
|
-
its host using the client's approved device-host credential over
|
|
861
|
-
|
|
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
|
|
862
1082
|
server. The `macos-hosted`, `ios-hosted` and `android-hosted` features advertise these relays.
|
|
863
1083
|
iOS resolves `ios.host` and Android resolves `android.host` by the requested slot; macOS retains its default slot.
|
|
864
1084
|
The local platform and slot replace the host's private target fields in events
|
|
@@ -868,7 +1088,7 @@ The relay forwards iOS device artwork and orientation metadata. Hosted targets
|
|
|
868
1088
|
refuse replay (`at`/`rate`), `duoFrame` and `physical` with `bad-request`.
|
|
869
1089
|
All of the client's relayed subscriptions and control sessions for one host share one connection,
|
|
870
1090
|
whichever local client opened them. Each request still checks the credential
|
|
871
|
-
and the pinned
|
|
1091
|
+
and the pinned key; a changed credential or endpoint opens a new connection.
|
|
872
1092
|
Ending a subscription or session sends `device-host.unsubscribe` or
|
|
873
1093
|
`device-host.control.end`, and the connection closes when the last one ends.
|
|
874
1094
|
The host's per-connection limits, such as its 32 subscriptions and input
|
|
@@ -962,8 +1182,10 @@ before replacement. Automatic placement remains in
|
|
|
962
1182
|
## Run as a service
|
|
963
1183
|
|
|
964
1184
|
`stim-server service install` runs stim-server as a per-user LaunchAgent on
|
|
965
|
-
macOS,
|
|
966
|
-
|
|
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:
|
|
967
1189
|
|
|
968
1190
|
```bash
|
|
969
1191
|
stim-server service install [--port <n>] [--label <name>] [--serve]
|
|
@@ -1050,10 +1272,9 @@ foreground `tailscale serve` session counts as present. To move a service that
|
|
|
1050
1272
|
created a route to another `--port`, run `uninstall` first.
|
|
1051
1273
|
|
|
1052
1274
|
`--env KEY=VALUE` and `--path-prepend <dir>` pin variables and PATH entries for
|
|
1053
|
-
the server.
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
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
|
|
1057
1278
|
`EnvironmentVariables`, so it stays out of the server's process arguments, and
|
|
1058
1279
|
passes only the name as `--env KEY`; the server reads that variable from the
|
|
1059
1280
|
environment launchd gives it. The values sit in plain text in the plist. A
|
|
@@ -1083,14 +1304,16 @@ the job to it. `--release <version>` takes an exact version from the public npm
|
|
|
1083
1304
|
registry (`https://registry.npmjs.org/`, never a registry `.npmrc` names), and
|
|
1084
1305
|
npm checks each package against the registry's integrity. `--from <dir>`
|
|
1085
1306
|
installs the `.tgz` packages in that directory, such as `pnpm pack` output of
|
|
1086
|
-
the `@stim-cli/core`, `@stim-cli/cache`, `@stim-cli/metro`, `stim
|
|
1087
|
-
`@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.
|
|
1088
1310
|
Either way, `npm audit signatures` must verify the registry signature of every
|
|
1089
1311
|
package that came from the registry, and the provenance attestation of each one
|
|
1090
1312
|
that has it, or the update stops before it touches the job. Install scripts
|
|
1091
1313
|
never run. Each install goes to
|
|
1092
1314
|
`~/Library/Application Support/Stim/services/<label>/versions/`, in a directory
|
|
1093
|
-
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
|
|
1094
1317
|
`node` before the switch. `update` then waits up to 30 minutes for `/health` to
|
|
1095
1318
|
report no offloaded build and no hosted session (a server older than `busy` in
|
|
1096
1319
|
`/health` restarts without waiting), rewrites only the server script in the
|
|
@@ -1109,24 +1332,116 @@ and uninstall of one label run one at a time.
|
|
|
1109
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
|
|
1110
1333
|
second service beside the first, for example with another `STIM_HOME`.
|
|
1111
1334
|
|
|
1112
|
-
To set up a remote
|
|
1335
|
+
To set up a remote machine: install Stim and stim-server on it, run
|
|
1113
1336
|
`stim-server service install --serve` (with the pins its toolchain needs), set
|
|
1114
1337
|
`server.workerRoot` there, and on each client run
|
|
1115
|
-
`stim settings set remote.machines '["<
|
|
1116
|
-
|
|
1117
|
-
|
|
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.
|
|
1118
1434
|
|
|
1119
1435
|
## Remote update
|
|
1120
1436
|
|
|
1121
|
-
A
|
|
1122
|
-
(`--device-host`) can update this
|
|
1123
|
-
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
|
|
1124
1440
|
server that offers it lists `server-update` in its `hello` features. A paired
|
|
1125
|
-
phone, a `read` or `control` device and
|
|
1126
|
-
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`:
|
|
1127
1442
|
|
|
1128
1443
|
- `server.update.status` returns `server` (`version` and `stimBuild`),
|
|
1129
|
-
`service` (the label of the
|
|
1444
|
+
`service` (the label of the service this server runs under, or `null` when
|
|
1130
1445
|
it does not run as a `stim-server service` and so cannot update itself),
|
|
1131
1446
|
`acceptsClientBuilds`, `running` (the update in progress, with its `state`,
|
|
1132
1447
|
`missing` package bytes and the last lines of its `log`) and `last` (how the
|
|
@@ -1136,8 +1451,10 @@ methods need that approval, not `read`:
|
|
|
1136
1451
|
- `server.update.start` takes `{ "release": "<version>" }`, an exact version
|
|
1137
1452
|
that `stim-server service update --release` installs, or
|
|
1138
1453
|
`{ "packages": [{ "name", "size", "sha256" }] }`, at most 8 `.tgz` packages
|
|
1139
|
-
of the client's own build.
|
|
1140
|
-
|
|
1454
|
+
of the client's own build. A `release` older than the version this server
|
|
1455
|
+
runs is refused with `bad-request`; run `stim-server service update --release`
|
|
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
|
|
1141
1458
|
release needs no setting. One update runs at a time.
|
|
1142
1459
|
- `server.update.chunk` takes `{ id, name, offset, data }`, at most 32 KiB of
|
|
1143
1460
|
base64 at the package's next offset. A package whose bytes do not match its
|
|
@@ -1157,10 +1474,10 @@ arrives once every package is in gets `action-busy`, and a retried reservation
|
|
|
1157
1474
|
of an existing hosted session still answers during the drain.
|
|
1158
1475
|
|
|
1159
1476
|
Stim Desktop starts these updates through its own local stim-server with two
|
|
1160
|
-
methods that only the local
|
|
1477
|
+
methods that only the local Unix socket connection may call:
|
|
1161
1478
|
`machines.update.start` takes `{ "machine" }`, an approved `remote.machines`
|
|
1162
|
-
entry. It connects to that machine
|
|
1163
|
-
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
|
|
1164
1481
|
server runs from a Stim checkout, it instead packs the checkout's workspace
|
|
1165
1482
|
packages as `npm pack` would and sends them. `machines.update.status` takes
|
|
1166
1483
|
the same `{ "machine" }` and returns `remote` (the machine's
|
|
@@ -1173,7 +1490,9 @@ A client with `build` runs its iOS simulator builds and Android emulator
|
|
|
1173
1490
|
debug builds and macOS SwiftPM Debug builds here with these methods.
|
|
1174
1491
|
They need `build`, not `read`; a device without `build` gets `forbidden`.
|
|
1175
1492
|
The server re-reads the build clients on every call, and revoking a client
|
|
1176
|
-
closes its connections and cancels its builds.
|
|
1493
|
+
closes its connections and cancels its builds. Once those builds end, it
|
|
1494
|
+
deletes the client's directory under the worker root. A client that has not
|
|
1495
|
+
connected since stim-server started keeps its directory when revoked.
|
|
1177
1496
|
|
|
1178
1497
|
- `build.offer` takes `repo` (the client's name for its repository: letters,
|
|
1179
1498
|
digits, `.`, `_` and `-`, at most 80), an optional `lockfile` sha256, and an
|
|
@@ -1182,18 +1501,19 @@ closes its connections and cancels its builds.
|
|
|
1182
1501
|
same Ruby selection and UTF-8 locale defaults as `pod install`; omitting
|
|
1183
1502
|
`rubyVersion` uses the worker's default Ruby. It
|
|
1184
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`);
|
|
1185
1505
|
`arch`; `xcode`; `simulatorSdk`; `macosSdk` (from
|
|
1186
1506
|
`xcrun --sdk macosx --show-sdk-version`); `cocoapods`; `runtimes`, the simulator
|
|
1187
1507
|
runtimes with an iPhone simulator to build for; `jdk`, the major version of
|
|
1188
1508
|
the JDK in `JAVA_HOME` or the macOS default; and `androidSdk`, the `ndk`,
|
|
1189
|
-
`buildTools` and `platforms` directories of the SDK in `ANDROID_HOME` or
|
|
1190
|
-
`~/
|
|
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`
|
|
1191
1511
|
(`checkout`, `dependencies` when the last install used that lockfile, and
|
|
1192
1512
|
`build` once a build ran there, including a non-empty repository `macos/`
|
|
1193
1513
|
scratch directory) for that repository. `capacity` holds
|
|
1194
1514
|
`running` and `max` offloaded builds, `diskFreeBytes` of the worker root's
|
|
1195
1515
|
volume and `minDiskFreeBytes`, `cpus`, `loadPerCore` (the 5-minute load
|
|
1196
|
-
average per CPU), `builds` (this
|
|
1516
|
+
average per CPU), `builds` (this machine's own Stim runs in prebuild, pods or
|
|
1197
1517
|
compile that it did not offload, plus the offloaded builds it runs), `maxBuilds` (its
|
|
1198
1518
|
`concurrency.maxBuilds`, 0 when unlimited), `maxLoadPerCore` (its
|
|
1199
1519
|
`server.maxLoadPerCore`, default 2), `memoryUsedBytes` (Activity Monitor's
|
|
@@ -1207,16 +1527,35 @@ closes its connections and cancels its builds.
|
|
|
1207
1527
|
simulator-runtime facts. Unused report fields are null. This report has its own
|
|
1208
1528
|
cache, ignores Ruby selection, and is reused for native Xcode build admission.
|
|
1209
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.
|
|
1210
1543
|
- `build.sync` takes `repo`, `files` and `done`. `files` is one page of the
|
|
1211
1544
|
manifest, each `{ "path", "kind": "file"|"exec"|"link", "size", "sha256" }`,
|
|
1212
1545
|
a link's blob being its target. Pages accumulate until `done`; the next
|
|
1213
1546
|
`build.sync` starts a new manifest. A path is relative, with no `.`, `..`,
|
|
1214
1547
|
empty or `.git` component (in any case). The result's `missing` lists the digests of the
|
|
1215
|
-
page this
|
|
1548
|
+
page this machine lacks. The client then sends each as binary frames: 32 bytes of
|
|
1216
1549
|
the sha256, then the next bytes of that blob, one blob after another. A frame
|
|
1217
1550
|
for a blob that was not asked for, one that overruns its size, or bytes that
|
|
1218
1551
|
do not match the digest close the connection with 4400. Blobs are kept per
|
|
1219
|
-
client and shared by all its repositories.
|
|
1552
|
+
client and shared by all its repositories. `build.sync` fails with
|
|
1553
|
+
`build-busy` while the worker root's volume has less than 10 GiB free, and
|
|
1554
|
+
with `limit-exceeded` once the sizes in one manifest add up to more than
|
|
1555
|
+
20 GiB. A blob whose size would leave that volume under 10 GiB free also
|
|
1556
|
+
closes the connection with 4400. When a client's build ends and no other
|
|
1557
|
+
build of that client runs, the server deletes the client's blobs that no
|
|
1558
|
+
repository checkout and no open connection's manifest uses.
|
|
1220
1559
|
- `build.start` takes `repo`, `project` (the app directory in the repository),
|
|
1221
1560
|
`platform` (`ios`, `android` or `macos`), `configuration`, `scheme`, `runtime` (a
|
|
1222
1561
|
simulator runtime identifier, required for `ios`, null for `android`),
|
|
@@ -1226,7 +1565,7 @@ closes its connections and cancels its builds.
|
|
|
1226
1565
|
synced on this connection. It returns `{ "job" }`. It fails with
|
|
1227
1566
|
`build-busy` while the offer would be declined, naming the reason, or while
|
|
1228
1567
|
another build of the same client and repository runs, or while every one
|
|
1229
|
-
of this
|
|
1568
|
+
of this machine's `concurrency.maxBuilds` slots is held, and with
|
|
1230
1569
|
`build-refused` when `stimBuild` differs. The build runs `offload-worker.mjs` of the bundled Stim with
|
|
1231
1570
|
`STIM_HOME` set to the repository's area. It makes the area's checkout
|
|
1232
1571
|
hold exactly the manifest (a file git lists as untracked and not ignored,
|
|
@@ -1239,12 +1578,15 @@ closes its connections and cancels its builds.
|
|
|
1239
1578
|
Gradle daemon leaves the build's process group, so no claim or slot tracks
|
|
1240
1579
|
it. An Android build keeps the client's daemon warm, with Gradle's idle
|
|
1241
1580
|
timeout set to `server.gradleDaemonIdleMinutes` (default 30; 0 stops it
|
|
1242
|
-
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
|
|
1243
1584
|
fixes a daemon's idle timeout when the daemon starts, so a new value
|
|
1244
1585
|
applies to the next daemon. Once no build of that client runs, stim-server
|
|
1245
1586
|
sends SIGTERM to each daemon whose command line runs from the client's
|
|
1246
|
-
Gradle home
|
|
1247
|
-
|
|
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
|
|
1248
1590
|
available memory (total memory minus Activity Monitor's Memory Used). It
|
|
1249
1591
|
checks every minute and on each change under its server directory. A daemon
|
|
1250
1592
|
whose Gradle home is deleted stops itself within seconds, because Gradle
|
|
@@ -1304,23 +1646,30 @@ closes its connections and cancels its builds.
|
|
|
1304
1646
|
as binary frames, each 32 bytes of its sha256 and then the next bytes, then
|
|
1305
1647
|
answers `{ "name", "size", "sha256" }`, and deletes it here. For an iOS simulator, Android emulator or macOS
|
|
1306
1648
|
job the answer also carries `handoff`, a single-use token, and the staged
|
|
1307
|
-
`.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
|
|
1308
1650
|
`device-host.app.handoff`. A client keeps at most one such bundle; its next
|
|
1309
1651
|
fetched native build or a revoked approval deletes it. An archive nobody fetched is deleted when its job
|
|
1310
1652
|
is cancelled; one left by a server that crashed stays under
|
|
1311
1653
|
`repos/<repo>/out/` until you delete it.
|
|
1312
1654
|
|
|
1313
|
-
The worker root is `server.workerRoot` in this
|
|
1655
|
+
The worker root is `server.workerRoot` in this machine's Stim settings, or
|
|
1314
1656
|
`$STIM_HOME/build-worker`. Each client gets `<root>/<device id>/`, with its
|
|
1315
1657
|
blobs, caches (`CP_HOME_DIR`, `CP_CACHE_DIR`, the pnpm store and
|
|
1316
1658
|
`GRADLE_USER_HOME` and SwiftPM) and one area
|
|
1317
1659
|
per repository under `repos/<repo>/`: the checkout, its own Stim home with
|
|
1318
1660
|
DerivedData, the compilation cache and ccache, and the output. A build never reads or
|
|
1319
|
-
writes this
|
|
1661
|
+
writes this machine's own Stim home. An ownership claim at
|
|
1320
1662
|
`repos/<repo>.claims`, whose child is the build's process group, guards each
|
|
1321
1663
|
area; it is released only once that group is gone, and a claim whose server
|
|
1322
|
-
and build are both gone is recovered by the next build.
|
|
1323
|
-
|
|
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
|
|
1324
1673
|
(`$STIM_HOME/build-slots/`), the same claims local Stim builds take, with the
|
|
1325
1674
|
same child, so a local build waits for it and `builds` counts it. Each finished build
|
|
1326
1675
|
appends a `build` record to the [action log](#actions) with the repository as
|
|
@@ -1329,40 +1678,44 @@ client's directory to reclaim it.
|
|
|
1329
1678
|
|
|
1330
1679
|
## Protocol
|
|
1331
1680
|
|
|
1332
|
-
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" }`,
|
|
1333
1684
|
answered by `{ "id", "result" }` or `{ "id", "error": { "code", "message" } }`.
|
|
1334
1685
|
Events are `{ "event", "subscription", ... }`.
|
|
1335
1686
|
|
|
1336
|
-
- `hello` must come first. Params: `
|
|
1337
|
-
`
|
|
1338
|
-
|
|
1339
|
-
|
|
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
|
|
1340
1692
|
device's `capabilities` (see [Scopes](#scopes)), the server's `features`
|
|
1341
1693
|
(`physical-ios` and `physical-android` when it serves `physical: true` for
|
|
1342
1694
|
that platform: see `frames.subscribe` below for an iPhone and
|
|
1343
1695
|
[Physical Android devices](#physical-android-devices), and `notifications`
|
|
1344
1696
|
for `notifications.list` and the `notification` event),
|
|
1345
1697
|
the `actions` it may run
|
|
1346
|
-
(none without `control`)
|
|
1347
|
-
|
|
1698
|
+
(none without `control`) and the record the connection authenticated as.
|
|
1699
|
+
`server.home` is the home folder
|
|
1348
1700
|
of the user the server runs as, so clients can show paths under it as
|
|
1349
|
-
`~/...`.
|
|
1701
|
+
`~/...`.
|
|
1350
1702
|
- `status.subscribe` returns a subscription id. Each `status` event carries a
|
|
1351
1703
|
full payload as `stim status --watch --json` prints it, including each
|
|
1352
1704
|
environment's `physicalDevices`, the phones it leases, and its `agents`, the
|
|
1353
1705
|
Claude Code and Codex sessions working in it. Those carry the session id,
|
|
1354
1706
|
working directory, the short session name the tool keeps, and times, never
|
|
1355
1707
|
prompts or conversation. `openUrl` there is a `claude://` or `codex://` link
|
|
1356
|
-
that only the
|
|
1708
|
+
that only the machine can open; the server has no action that opens it. `webUrl`
|
|
1357
1709
|
is a Claude Code session's `https://claude.ai/code/` link while Remote Control
|
|
1358
1710
|
is connected, which a phone opens in the Claude app or a browser.
|
|
1359
1711
|
`endedAgents` lists the sessions that stopped running there in the last 3
|
|
1360
1712
|
days, with the same fields as last found, no `pid`, and `endedAt`. The server
|
|
1361
1713
|
drops `CLAUDE_CODE_SESSION_ID` and `CODEX_THREAD_ID` from the environment of
|
|
1362
1714
|
the `stim` commands it runs, so a phone's reload is not recorded as the work
|
|
1363
|
-
of the agent session that started the server.
|
|
1364
|
-
|
|
1365
|
-
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
|
|
1366
1719
|
and memory history from each payload's `machine.owners`, and every `status`
|
|
1367
1720
|
event carries it beside the payload as `usage`, once it holds a reading:
|
|
1368
1721
|
`{ "intervalMs", "endAt", "environments", "devices" }`. It covers the last 10
|
|
@@ -1379,6 +1732,35 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1379
1732
|
`grantedAt` times as `ownLeases`, so a client can tell a person controlling a
|
|
1380
1733
|
device from an agent driving it: an `activity.driver` of `stim device lock`
|
|
1381
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.
|
|
1382
1764
|
- `logs.query` returns `{ "records" }`, and `logs.subscribe` sends `logs`
|
|
1383
1765
|
events: first the last `tail` matching records, then new ones in batches.
|
|
1384
1766
|
Both take the Stim Desktop log viewer's filters: exactly one of `workspace`
|
|
@@ -1405,8 +1787,8 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1405
1787
|
with a message naming the archive id.
|
|
1406
1788
|
- `stats.get` returns the same payload as `stim stats --json`, using the shared
|
|
1407
1789
|
core reader in a bounded, cancellable server child. The stats part of
|
|
1408
|
-
`machine.details` uses the same reader. `settings.get`
|
|
1409
|
-
|
|
1790
|
+
`machine.details` uses the same reader. `settings.get` uses the in-process
|
|
1791
|
+
settings API, which masks sensitive values. Without `workspace`,
|
|
1410
1792
|
these reads use the home directory as their project context.
|
|
1411
1793
|
- `frames.subscribe` takes `workspace`, `platform` (`ios`, `android`, `web` or `macos`),
|
|
1412
1794
|
`slot` (`default` when absent), `fps` (1 to 30, 5 by default) and `maxEdge`
|
|
@@ -1506,7 +1888,7 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1506
1888
|
and on an iPhone Duo bit 1 while folded or bit 2 while unfolded,
|
|
1507
1889
|
u16 header length, u32 sequence number of the messages sent on this
|
|
1508
1890
|
subscription, f64 capture time in milliseconds since the epoch on the
|
|
1509
|
-
|
|
1891
|
+
machine's clock, u16 width, u16 height, u8 subscription id length and the
|
|
1510
1892
|
ASCII id), then one Annex-B access unit. Every keyframe carries its SPS
|
|
1511
1893
|
and PPS, and the stream has no B-frames, so each access unit is shown as
|
|
1512
1894
|
it arrives. A change of size, such as a rotation or a Duo fold, restarts
|
|
@@ -1614,7 +1996,7 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1614
1996
|
it.
|
|
1615
1997
|
- `recording`: true while the server records the device now.
|
|
1616
1998
|
- `spans`: the recorded time ranges `{ start, end }`, in epoch milliseconds on
|
|
1617
|
-
the
|
|
1999
|
+
the machine's clock, oldest first. Segments less than 1.5 seconds apart form
|
|
1618
2000
|
one span; the gaps between spans are time nothing was recorded, such as
|
|
1619
2001
|
after `stim stop`.
|
|
1620
2002
|
- `markers`: `{ at, kind, command?, label }` from the start of the first span
|
|
@@ -1730,7 +2112,7 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1730
2112
|
without running `stim`: `volumes`, one per volume that holds a Stim
|
|
1731
2113
|
workspace, Stim home, or the simulators, with `mount`, `holds`, `freeBytes`
|
|
1732
2114
|
(free space without purgeable space, which Stim's disk budget measures) and
|
|
1733
|
-
`totalBytes`; `memory` with `totalBytes`, `usedBytes` (the
|
|
2115
|
+
`totalBytes`; `memory` with `totalBytes`, `usedBytes` (the machine's memory in
|
|
1734
2116
|
use as Activity Monitor's "Memory Used" counts it: app memory, wired and
|
|
1735
2117
|
compressed; null off macOS) and the macOS `pressure` level (`normal`,
|
|
1736
2118
|
`warning`, `critical`, or null); `load` with the 1, 5 and 15
|
|
@@ -1743,23 +2125,27 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1743
2125
|
critical) and `diskFreeBytes` of the startup volume; a field is null when it
|
|
1744
2126
|
cannot be read. `sinceMs` returns only the samples taken after it.
|
|
1745
2127
|
- `machine.details` returns `{ "gc", "stats", "measuredAt" }`: the payloads of
|
|
1746
|
-
|
|
2128
|
+
GC dry-run and stats report APIs, both read in process from the home directory, so
|
|
1747
2129
|
a phone can show what Stim Desktop's Machine page shows about disk: every
|
|
1748
2130
|
simulator, AVD, iOS runtime and system image, shared caches, recordings,
|
|
1749
2131
|
workspace build outputs and logs, and what `stim gc --delete` would free. The
|
|
1750
|
-
|
|
1751
|
-
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
|
|
1752
2134
|
`gcError` or `statsError` says why. It needs only `read`. The server keeps
|
|
1753
2135
|
one result for 60 seconds, shared by every connection: a request while the
|
|
1754
|
-
|
|
1755
|
-
|
|
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
|
|
1756
2141
|
`unknown-method`. It also carries `buildMachines`, the `remoteMachines` list
|
|
1757
|
-
of `stim doctor --json
|
|
1758
|
-
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
|
|
1759
2144
|
when `remote.machines` names a machine, else the list is empty; it runs it
|
|
1760
2145
|
in the registered workspace that ran doctor for iOS most recently, because
|
|
1761
|
-
doctor judges a machine against an app.
|
|
1762
|
-
|
|
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
|
|
1763
2149
|
`buildMachinesError` when doctor failed, the config could not be read, or no
|
|
1764
2150
|
registered workspace exists. The reply never waits for doctor, whose offer
|
|
1765
2151
|
to an unreachable machine can take about 13 seconds: it carries the last
|
|
@@ -1768,10 +2154,10 @@ Events are `{ "event", "subscription", ... }`.
|
|
|
1768
2154
|
at a time, and sets `buildMachinesPending` while that background run has not
|
|
1769
2155
|
settled a result yet, or the settled one is 60 seconds old or older. A client
|
|
1770
2156
|
that wants the refreshed result asks `machine.details` again. It also
|
|
1771
|
-
carries `buildClients`, the builds this
|
|
1772
|
-
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`,
|
|
1773
2159
|
`name`, `builds`, `failed`, `buildMs`, `lastAt` and the same three counts
|
|
1774
|
-
for `today`, most recent client first, with `today` on this
|
|
2160
|
+
for `today`, most recent client first, with `today` on this machine's local
|
|
1775
2161
|
calendar day. Servers that predate it leave it out.
|
|
1776
2162
|
- `unsubscribe` ends a subscription.
|
|
1777
2163
|
- `push.register` takes `token`, an Expo push token, `events`, one or more
|
|
@@ -1816,8 +2202,8 @@ so clients can replay what happened while nobody watched. It records a device
|
|
|
1816
2202
|
while `stim status` shows an automation tool driving it (`activity.state` is
|
|
1817
2203
|
`driven`), or while a client has a `frames.subscribe` subscription to it. It
|
|
1818
2204
|
records nothing else, holds no device awake and changes no device setting. To
|
|
1819
|
-
see drivers, the
|
|
1820
|
-
|
|
2205
|
+
see drivers, it reads the status watch the server runs for as long as it
|
|
2206
|
+
runs, shared with status subscribers.
|
|
1821
2207
|
|
|
1822
2208
|
Recording goes through the device's `stim-frames` helper, shared with live
|
|
1823
2209
|
subscribers. The helper runs a second H.264 encoder for it, at 720 pixels on
|
|
@@ -1852,7 +2238,7 @@ the `.part` segments of a server that stopped. When a status payload shows
|
|
|
1852
2238
|
workspace within seconds and deletes its recordings. `stim stop` ends recording
|
|
1853
2239
|
and keeps the footage; `stim worktree remove` and `stim gc` delete it. A gc that
|
|
1854
2240
|
deletes the segment being written loses the rest of that segment; the next one
|
|
1855
|
-
is written as usual. Recordings stay on the
|
|
2241
|
+
is written as usual. Recordings stay on the machine and are served only to paired
|
|
1856
2242
|
clients.
|
|
1857
2243
|
|
|
1858
2244
|
## Push notifications
|
|
@@ -1870,7 +2256,7 @@ shows them in its attention strip. The server pushes, per device and only for
|
|
|
1870
2256
|
the events the device chose:
|
|
1871
2257
|
|
|
1872
2258
|
- `started`: a workspace began warming (`phase` `warming`), or an agent first
|
|
1873
|
-
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
|
|
1874
2260
|
once an agent drives it. An agent driving the workspace updates the warming
|
|
1875
2261
|
notification in place.
|
|
1876
2262
|
- `stuck`: an agent drove the workspace, its devices are still up, and nothing
|
|
@@ -1924,9 +2310,9 @@ registers does not push. During the phone's quiet hours nothing pushes: a
|
|
|
1924
2310
|
problem that still holds when they end pushes then, and what started or
|
|
1925
2311
|
finished during them does not.
|
|
1926
2312
|
|
|
1927
|
-
While at least one device is paired, the server
|
|
1928
|
-
|
|
1929
|
-
|
|
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.
|
|
1930
2316
|
While a device wants `finished`, it looks up the pull requests of worktree
|
|
1931
2317
|
branches that have an upstream every 5 minutes, with one `gh api graphql` call
|
|
1932
2318
|
per repository, the lookup `stim gc` uses. Without `gh`, or when it is signed
|
|
@@ -1938,9 +2324,9 @@ count. More than three at once become one summary push that opens the
|
|
|
1938
2324
|
phone's home screen.
|
|
1939
2325
|
|
|
1940
2326
|
Pushes go to the Expo push service, `https://exp.host/--/api/v2/push/send`,
|
|
1941
|
-
which forwards them to Apple. No APNs key or other secret lives on the
|
|
1942
|
-
workspace push carries the workspace title, a one-line cause and the
|
|
1943
|
-
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
|
|
1944
2330
|
`data` it carries the `ref`, the screen to open (`home`, `machine`,
|
|
1945
2331
|
`workspace`, `device`, `build` or `url`), and the workspace's absolute path,
|
|
1946
2332
|
with the platform and slot for a device, the platform for build details and
|
|
@@ -1975,9 +2361,9 @@ and needs-attention vectors. Notification delivery remains local to each.
|
|
|
1975
2361
|
|
|
1976
2362
|
## Notification history
|
|
1977
2363
|
|
|
1978
|
-
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
|
|
1979
2365
|
a phone was pushed, so a phone can list what it missed. While any device is
|
|
1980
|
-
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
|
|
1981
2367
|
quiet hours and the lowest `stuckMinutes` a registered device asked for (15
|
|
1982
2368
|
without one). Each notification it produces is an entry; a `control` conflict is
|
|
1983
2369
|
an entry too, listed only to the phone that lost the device. Pull request
|
|
@@ -2014,13 +2400,14 @@ A device with `control` can send `action` with params `{ "action", "workspace" }
|
|
|
2014
2400
|
| Action | Params | Runs in the workspace |
|
|
2015
2401
|
| -------- | -------------------------------------------------------------------- | ------------------------------- |
|
|
2016
2402
|
| `reload` | `platform` (`ios` or `android`), optional; needed when both are live | `stim reload [platform] --json` |
|
|
2017
|
-
| `stop` | none |
|
|
2403
|
+
| `stop` | none | in-process workspace stop API |
|
|
2018
2404
|
|
|
2019
|
-
|
|
2020
|
-
|
|
2021
|
-
|
|
2022
|
-
|
|
2023
|
-
|
|
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:
|
|
2024
2411
|
|
|
2025
2412
|
- `forbidden` when the device has only `read`;
|
|
2026
2413
|
- `unknown-action` for any other action;
|
|
@@ -2031,10 +2418,13 @@ nothing with:
|
|
|
2031
2418
|
- `action-busy` while another action runs in that workspace. The server runs
|
|
2032
2419
|
one action per workspace at a time, across all connections.
|
|
2033
2420
|
|
|
2034
|
-
|
|
2035
|
-
and
|
|
2036
|
-
and
|
|
2037
|
-
|
|
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.
|
|
2038
2428
|
|
|
2039
2429
|
Every `action` request from a paired device, refused or run, appends one line
|
|
2040
2430
|
to `$STIM_HOME/server/actions.ndjson`: `at`, `device` (`id` and `name`),
|
|
@@ -2200,8 +2590,11 @@ appends a line to the action log, with `action` set to `control.begin`,
|
|
|
2200
2590
|
ended or whom it took the device from. Inputs are not logged.
|
|
2201
2591
|
|
|
2202
2592
|
The error codes `unauthorized`, `pairing-expired`, and `protocol-unsupported`
|
|
2203
|
-
refuse the client until it pairs again or updates; `
|
|
2204
|
-
|
|
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.
|
|
2205
2598
|
|
|
2206
2599
|
The package exports the message types, and the build writes their JSON Schema
|
|
2207
2600
|
to `dist/protocol.schema.json`, exported as `@stim-cli/server/protocol.schema.json`.
|