@kortix/agent-tunnel 0.13.52 → 0.13.54

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 CHANGED
@@ -27,11 +27,36 @@ Connecting the same computer again reuses its entry. The agent sends a SHA-256
27
27
  hash of the hardware ID (IOPlatformUUID, `/etc/machine-id`, or `MachineGuid`);
28
28
  the raw ID never leaves the computer.
29
29
 
30
- After approval, the interactive flow asks whether it should install a persistent background service. The default answer is yes.
30
+ After approval, `connect` in a terminal installs the background service, the
31
+ same way the desktop app does, and prints the commands that pause, resume,
32
+ and remove it. It asks no question. `--foreground` keeps the connection in the
33
+ terminal instead. A script without a TTY, or `--json`, stays in the foreground
34
+ unless it passes `--daemon`.
35
+
36
+ ## One runtime with the desktop app (macOS)
37
+
38
+ When the Kortix desktop app is installed (`/Applications/Kortix.app` or
39
+ `~/Applications/Kortix.app`), the service a CLI install writes runs on the
40
+ app's own agent and driver: `Kortix.app/Contents/MacOS/Kortix` with
41
+ `ELECTRON_RUN_AS_NODE=1` and `Contents/Resources/agent-tunnel/agent-cli.js`.
42
+ A CLI install and an app install are then the same connection. macOS grants
43
+ Accessibility and Screen Recording to Kortix once, never to `node` or a
44
+ terminal, and **Your computer** in the app controls it.
45
+
46
+ This CLI is the one control surface of the computer. The desktop app runs
47
+ these same commands (`status --json`, `access`, `keep-awake`, `stop`,
48
+ `start`, `logout`) and never edits the agent's files itself. A change made
49
+ in the app, in the terminal, or through Kortix is the same change. Without the app,
50
+ the service runs on `node`, and Computer Use needs a separately installed
51
+ `cua-driver`.
52
+
53
+ The service restarts itself when its code changes on disk (an app update or
54
+ a new vendored bundle). macOS refuses every permission to a process whose
55
+ binary was replaced under it, so a stale process would lose Computer Use.
31
56
 
32
57
  ## Run in the background
33
58
 
34
- Install the operating-system background service during connection:
59
+ The service is the default for a person at a terminal. A script installs it with `--daemon`:
35
60
 
36
61
  ```bash
37
62
  npx --yes @kortix/agent-tunnel@latest connect \
@@ -62,8 +87,8 @@ The agent itself never stops on its own:
62
87
  - A handshake that does not reach `auth_ok` within 20 s is dropped and retried.
63
88
  - No saved credential: it waits and checks `config.json` every 60 s.
64
89
 
65
- It changes the computer's sleep settings only when `access.json` sets
66
- `keepAwake` (see below).
90
+ It changes the computer's sleep settings only while `keep-awake` is on (see
91
+ "Access control").
67
92
 
68
93
  ## Manage the background service
69
94
 
@@ -85,9 +110,11 @@ which removes the machine and its accounts in Kortix. It then clears the local
85
110
  credential and removes the service. If Kortix cannot be reached, the local
86
111
  sign-out still completes; `logout --json` then reports `"serverUnpaired": false`.
87
112
 
88
- `service-status --json` prints the pairing, the service (`installed`, `active`,
89
- `enabled` = not paused, `upToDate` = the unit matches what `install-service`
90
- writes now), the live connection state, and `access`.
113
+ `status --json` (and its alias `service-status --json`) prints the pairing,
114
+ the approved `capabilities`, the service (`installed`, `active`, `enabled` =
115
+ not paused, `upToDate` = the unit matches what `install-service` writes now),
116
+ the live connection `state` (a process that died without saying so reads as
117
+ `offline`), and `access` (the same object `access --json` prints).
91
118
 
92
119
  Credentials are stored in `~/.agent-tunnel/config.json`. Agent Tunnel requires
93
120
  the file to be regular, owned by the current user, and mode `0600` on POSIX.
@@ -104,7 +131,7 @@ Remote API URLs must use HTTPS. Plain HTTP is accepted only for `localhost`,
104
131
  | `config.json` | Credential and local limits, mode `0600`. |
105
132
  | `state.json` | `{ tunnelId, apiUrl, status: online\|offline\|connecting\|rejected\|standby, since, agentVersion, pid }`, rewritten atomically on every connection change. No credential. |
106
133
  | `access.json` | `{ mode: ask\|always\|off, grantedUntil, deniedUntil, keepAwake }`, mode `0600`. See "Access control". |
107
- | `access-request.json` | `{ id, requestedAt, capability, method }`: the call waiting for the owner. |
134
+ | `access-request.json` | `{ id, requestedAt, capability, method, change? }`: the call, or the wider access asked for through Kortix (`change`), waiting for the owner. |
108
135
  | `desktop-app.json` | Written by the Kortix desktop app: how to start it to show an access prompt. |
109
136
  | `logs/` | Service output. |
110
137
 
@@ -116,8 +143,22 @@ service definition carries `AGENT_TUNNEL_HOME` into the service environment.
116
143
 
117
144
  ## Access control
118
145
 
119
- The machine decides, before every call, whether an agent may use it.
120
- `access.json` holds the owner's answer:
146
+ The machine decides, before every call, whether an agent may use it. Change
147
+ it with the CLI:
148
+
149
+ ```bash
150
+ npx --yes @kortix/agent-tunnel@latest access # show it
151
+ npx --yes @kortix/agent-tunnel@latest access ask # or always, off
152
+ npx --yes @kortix/agent-tunnel@latest access --allow-for 60 # in ask: allow for 60 minutes (max 1440)
153
+ npx --yes @kortix/agent-tunnel@latest access --revoke # end the current allowance
154
+ npx --yes @kortix/agent-tunnel@latest access --deny # answer the waiting request with No
155
+ npx --yes @kortix/agent-tunnel@latest keep-awake on # or off (macOS and Linux)
156
+ ```
157
+
158
+ Every command takes `--json` and prints `{ mode, grantedUntil, deniedUntil,
159
+ keepAwake, keepAwakeSupported, pendingRequest }`. A wrong mode or duration
160
+ exits `1` and changes nothing. The person at the terminal is the computer's
161
+ owner, so these commands also widen access.
121
162
 
122
163
  | `mode` | Effect |
123
164
  | --- | --- |
@@ -125,17 +166,36 @@ The machine decides, before every call, whether an agent may use it.
125
166
  | `ask` | A call runs while `grantedUntil` is in the future (at most 24 h ahead). Otherwise the agent writes `access-request.json`, starts the desktop app if it is not running, and holds the call for 20 s. A grant runs it. No answer returns `-32010 computer_access_pending`. A denial sets `deniedUntil` 10 minutes ahead and returns `-32011 computer_access_denied`; calls fail at once until then. |
126
167
  | `off` | Every call returns `-32012 computer_access_off`. |
127
168
 
169
+ **Through Kortix.** The owner can also change access from the Kortix web app
170
+ or the desktop app's window (`POST /v1/tunnel/connections/:id/access`, user
171
+ credentials only; no agent or session token reaches it). Kortix relays the
172
+ change to the agent as `tunnel.access.set`:
173
+
174
+ - A narrowing (`ask`, `off`, `--revoke`, `--deny`, keep awake) applies at once,
175
+ even while access is `off`.
176
+ - A widening (`always`, or a longer allowance) needs the owner on the computer.
177
+ The agent writes it to `access-request.json` with `change`, and the desktop
178
+ app shows a native **Allow** / **Cancel** dialog. **Allow** runs the matching
179
+ `access` command; **Cancel** runs `access --deny`, which declines the change
180
+ without refusing calls. The relayed call waits up to 20 s and otherwise fails
181
+ with `-32014 computer_access_unconfirmed`. A computer without the desktop
182
+ app fails at once, naming the command to run on it.
183
+
128
184
  A pairing made from the Kortix desktop app starts in `ask`: the app shows the
129
185
  prompt. A pairing made with this CLI alone starts in `always`, because nothing
130
186
  on the machine could answer a prompt. This is a deliberate deviation from
131
187
  "new pairings default to ask". Every new pairing resets `access.json`, so a
132
188
  grant or `always` from an earlier pairing never carries over, and `logout`
133
189
  deletes it. The agent home (`config.json`, `access.json`, `desktop-app.json`)
134
- is always a blocked path: no file or shell call can change these files. The agent reports `{ mode, grantedUntil }`
135
- to Kortix as the signed notification `tunnel.access.state` on connect and on
136
- every change.
190
+ is always a blocked path: no file or shell call can change these files.
191
+
192
+ The agent reports its state to Kortix as the signed notification
193
+ `tunnel.access.state` on connect and on every change: the access fields, the
194
+ waiting request, and `desktopPermissions` (`{ accessibility, screenRecording }`
195
+ as macOS answers for the agent process itself, checked every 60 s). Kortix
196
+ shows exactly this.
137
197
 
138
- `keepAwake: true` keeps the computer from sleeping while the agent runs:
198
+ `keep-awake on` keeps the computer from sleeping while the agent runs:
139
199
  `caffeinate -s` on macOS (on AC power only), `systemd-inhibit --what=sleep` on
140
200
  Linux. Windows is not supported.
141
201