worktrust 0.11.6 → 0.11.8
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/CHANGELOG.md +346 -0
- package/README.md +211 -283
- package/cli-colour.mjs +86 -0
- package/cli-menu-remote.mjs +148 -0
- package/cli-menu.mjs +245 -0
- package/engine-release.json +1 -1
- package/folder-picker.mjs +85 -0
- package/node-guide.mjs +134 -0
- package/package-release.json +1 -1
- package/package.json +12 -2
- package/remote-adapter-claude-code.mjs +27 -7
- package/remote-admin.mjs +109 -0
- package/remote-approvals.mjs +2 -2
- package/remote-cli.mjs +66 -58
- package/remote-connections.mjs +91 -0
- package/remote-countdown.mjs +52 -0
- package/remote-daemon.mjs +56 -7
- package/remote-inventory.mjs +28 -0
- package/remote-pairing.mjs +22 -9
- package/remote-policy.mjs +15 -0
- package/remote-projects.mjs +39 -1
- package/remote-protocol.mjs +253 -4
- package/remote-run.mjs +14 -7
- package/remote-service.mjs +36 -2
- package/remote-sessions.mjs +15 -9
- package/remote-settings.mjs +191 -0
- package/remote-store.mjs +4 -1
- package/worktrust.mjs +50 -15
package/remote-cli.mjs
CHANGED
|
@@ -2,22 +2,30 @@
|
|
|
2
2
|
* `npx worktrust remote ...`: STEER THIS COMPUTER'S AGENTS FROM YOUR PHONE (2026-11-07). Opt-in, at this keyboard only (an
|
|
3
3
|
* AI agent's shell is refused by worktrust.mjs, `status` excepted). docs/remote-agents/PROTOCOL.md is the contract.
|
|
4
4
|
*
|
|
5
|
-
* remote
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
5
|
+
* remote app | web [--gateway <wss://…>] [--device] make this computer's REMOTE keys (not the measurement key), have
|
|
6
|
+
* them approved in the WorkTrust app (a QR here, no browser) | in the
|
|
7
|
+
* browser's approval page, start the service, show a pairing QR.
|
|
8
|
+
* `remote enable`, which asked which of the two, is gone (owner,
|
|
9
|
+
* 2026-11-12, CLI 0.11.7): an unknown subcommand that names them
|
|
9
10
|
* remote pair a new QR for a phone (five minutes, one phone, once)
|
|
10
11
|
* remote status [--json] what is on, paired, running, granted and installed
|
|
11
12
|
* remote pause | resume refuse every command for now | take them again
|
|
12
13
|
* remote disable [--forget] the hard off: the service removed; --forget also deletes the keys
|
|
14
|
+
* remote connections every phone and browser linked here, and this computer's own link
|
|
15
|
+
* remote disconnect <n|name|fingerprint> | --all close one (y, then its short fingerprint or name typed) | every one
|
|
16
|
+
* (`close all` typed); remote-connections.mjs
|
|
13
17
|
* remote phones [confirm <id> | remove <id>|--all] phones: pending ones are confirmed here; --all cuts every one at once
|
|
14
18
|
* remote phones allow-endorse on|off may a confirmed phone add a browser it scanned (default off)
|
|
15
19
|
* remote projects add <folder> | remove <id> | list the folders a phone may steer an agent in
|
|
16
20
|
* remote run the daemon in the foreground (Windows runs only this way)
|
|
17
21
|
* remote pipeline review <folder> | status read a granted folder's .worktrust/pipeline.json, show every stage
|
|
18
22
|
* and command, and on a typed yes let a phone start it (pins a hash)
|
|
19
|
-
* remote roots add <dir> [--git-init] | remove <id|dir> | list parent folders where a phone may
|
|
20
|
-
*
|
|
23
|
+
* remote roots add <dir> [--git-init] | remove <id|dir> | list parent folders where a phone may open the git projects
|
|
24
|
+
* already in them (0.11.7) and create ONE new, empty project folder
|
|
25
|
+
* (project.create); --git-init runs `git init` in it
|
|
26
|
+
* remote modes allow|deny edit|auto | status the ceiling of agent modes a phone may start (0.11.7; default manual
|
|
27
|
+
* and plan), remote-settings.mjs
|
|
28
|
+
* remote admin on|off RESERVED: managing this computer from the app or the web (part B)
|
|
21
29
|
* remote preview allow|deny <port|file> <folder> | list what a phone may preview: a dev-server port on 127.0.0.1 or a
|
|
22
30
|
* built HTML file, per granted folder (rendered with your Chrome)
|
|
23
31
|
* remote codex on | off offer Codex to a phone (off by default): Codex runs the reads it
|
|
@@ -33,19 +41,23 @@ import { basename } from "node:path";
|
|
|
33
41
|
import { hostname } from "node:os";
|
|
34
42
|
import { createInterface } from "node:readline/promises";
|
|
35
43
|
import * as P from "./remote-protocol.mjs";
|
|
36
|
-
import { ensureRemoteDir, isLoopbackGateway, issuerKeys, loadIdentity, loadKeys, loadPhones, loadProjects, loadSettings, newKeys,
|
|
44
|
+
import { ensureRemoteDir, isLoopbackGateway, issuerKeys, loadIdentity, loadKeys, loadPhones, loadProjects, loadSettings, newKeys, random, readJson, removeFile, saveIdentity, saveKeys, savePhones, saveSettings, writeJson } from "./remote-store.mjs";
|
|
37
45
|
import { canonicalProject } from "./remote-policy.mjs";
|
|
38
|
-
import { IssuerMissing,
|
|
46
|
+
import { IssuerMissing, PairingDenied, PairingExpired, PairingRefused, pairComputer } from "./remote-pairing.mjs";
|
|
47
|
+
import { startCountdown, waitKey } from "./remote-countdown.mjs";
|
|
48
|
+
import { askLine, connectionsCommand, disconnectCommand, removePhones } from "./remote-connections.mjs";
|
|
39
49
|
import { installService, removeService, serviceState, servicePlatform } from "./remote-service.mjs";
|
|
40
50
|
import { qrMatrix, renderQr } from "./remote-qr.mjs";
|
|
41
51
|
import { webSocketAvailable } from "./remote-transport.mjs";
|
|
52
|
+
import { guideToNode, remoteStopsHere } from "./node-guide.mjs";
|
|
42
53
|
import { inventory } from "./remote-inventory.mjs";
|
|
43
54
|
import { allowCommand, parsePipelineConfig, PIPELINE_FILE } from "./remote-pipeline-config.mjs";
|
|
44
55
|
import { pipelineState, projectReviewHash, readProjectFile } from "./remote-pipeline.mjs";
|
|
45
56
|
import { openJournal } from "./remote-journal.mjs";
|
|
46
57
|
import { loadPreviewGrants, savePreviewGrants } from "./remote-store.mjs";
|
|
47
|
-
import { loadDeskMarks, loadPipelineReviews, loadRoots, remotePath, saveDeskMarks, savePipelineReviews
|
|
48
|
-
import {
|
|
58
|
+
import { loadDeskMarks, loadPipelineReviews, loadRoots, remotePath, saveDeskMarks, savePipelineReviews } from "./remote-store.mjs";
|
|
59
|
+
import { rootLabel } from "./remote-projects.mjs";
|
|
60
|
+
import { adminCommand, allowedModes, applySettingsChange, askMacFolderAccess, folderCheck, modesCommand } from "./remote-settings.mjs";
|
|
49
61
|
|
|
50
62
|
const fingerprintOf = (keys) => P.deviceFingerprint(keys.public);
|
|
51
63
|
const pretty = (code) => `${code.slice(0, 4)}-${code.slice(4)}`;
|
|
@@ -60,12 +72,12 @@ export async function askTyped(question) {
|
|
|
60
72
|
|
|
61
73
|
function needPaired(io) {
|
|
62
74
|
const keys = loadKeys(), identity = loadIdentity();
|
|
63
|
-
if (!keys || !identity) io.fail("this computer is not paired for remote yet: run `npx worktrust remote
|
|
75
|
+
if (!keys || !identity) io.fail("this computer is not paired for remote yet: run `npx worktrust remote app` (or `remote web`)");
|
|
64
76
|
return { keys, identity };
|
|
65
77
|
}
|
|
66
78
|
|
|
67
|
-
|
|
68
|
-
|
|
79
|
+
/** `remote app` | `remote web`: the two roads to approve this computer; each does all of what `remote enable` did. */
|
|
80
|
+
async function approve(io, road) {
|
|
69
81
|
const settings = loadSettings();
|
|
70
82
|
const gateway = io.flag("gateway") ?? process.env.WORKTRUST_REMOTE_GATEWAY ?? settings.gateway;
|
|
71
83
|
if (gateway && !P.isGatewayOrigin(gateway)) io.fail("--gateway is an origin: wss://host[:port], or ws://127.0.0.1:<port> for the dev relay");
|
|
@@ -82,9 +94,19 @@ async function enable(io, sub = "enable") {
|
|
|
82
94
|
if (!identity || io.has("repair")) {
|
|
83
95
|
const keys = newKeys();
|
|
84
96
|
const pub = P.publicKeysOf(P.importSecretKeys(keys));
|
|
85
|
-
const road = sub !== "enable" ? sub : io.has("device") ? "web" : await chooseRoad({ yes: io.has("yes") });
|
|
86
97
|
try {
|
|
87
|
-
|
|
98
|
+
// The request's own clock under the QR or link (remote-countdown.mjs); after an expiry, Enter asks again with a new one.
|
|
99
|
+
let paired = null;
|
|
100
|
+
while (!paired) {
|
|
101
|
+
try {
|
|
102
|
+
paired = await pairComputer({ origin: io.origin, secret: P.importSecretKeys(keys), publicKeys: pub, host: hostname(), os: io.os, device: io.has("device"), road, showQr: (link) => io.say(renderQr(qrMatrix(link).modules, { color: Boolean(process.stdout.isTTY) && !process.env.NO_COLOR })), issuerKeys: issuerKeys(gateway), say: io.say, openBrowser: io.openBrowser, countdown: (w) => startCountdown(w) });
|
|
103
|
+
} catch (error) {
|
|
104
|
+
if (error instanceof PairingDenied) return;
|
|
105
|
+
if (!(error instanceof PairingExpired) || !process.stdin.isTTY) throw error;
|
|
106
|
+
io.say(` Press Enter for a new ${road === "app" ? "QR code" : "approval page"}, or q to quit.`);
|
|
107
|
+
if ((await waitKey()) !== "enter") return;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
88
110
|
saveKeys(keys);
|
|
89
111
|
identity = { v: 1, device_id: paired.device_id, binding: paired.binding, sub: paired.sub, origin: io.origin, paired_at: Date.now() };
|
|
90
112
|
saveIdentity(identity);
|
|
@@ -95,19 +117,20 @@ async function enable(io, sub = "enable") {
|
|
|
95
117
|
}
|
|
96
118
|
} else io.say(` Already paired (${identity.device_id}); --repair pairs again with new keys.`);
|
|
97
119
|
saveSettings({ ...settings, enabled: true, paused: null, gateway: gateway ?? null, agent_path: process.env.PATH ?? null });
|
|
98
|
-
if (loadProjects().length === 0) io.say(" No folder is granted yet: npx worktrust remote
|
|
120
|
+
if (loadProjects().length === 0 && loadRoots().length === 0) io.say(" No folder is granted yet: npx worktrust remote roots add <folder> (or the menu: npx worktrust › Remote Agent › Roots)");
|
|
99
121
|
if (!gateway) { io.say(" No gateway is set: the production gateway is not live yet. Nothing runs until one is (--gateway)."); return; }
|
|
100
|
-
if (servicePlatform() === "foreground") { io.say(" Windows: there is no service; run `npx worktrust remote run` and keep that terminal open."); return; }
|
|
122
|
+
if (servicePlatform() === "foreground") { io.say(" ✓ This computer is connected to Remote Agent."); io.say(" Windows: there is no service; run `npx worktrust remote run` and keep that terminal open."); return; }
|
|
101
123
|
const runtime = await io.prepare();
|
|
102
124
|
const service = installService({ program: [runtime.node, ...runtime.nodeArgs, runtime.entry, "remote", "run"], path: process.env.PATH ?? "" });
|
|
103
125
|
io.say(service.started ? ` ✓ The service runs (${service.kind}, while you are logged in; linger stays off).` : ` ! The service file was written (${service.file}) but did not start; run \`npx worktrust remote run\` to see why.`);
|
|
126
|
+
if (service.started) io.say(" ✓ This computer is connected to Remote Agent.");
|
|
104
127
|
if (!io.has("no-pair")) await pair(io);
|
|
105
128
|
}
|
|
106
129
|
|
|
107
130
|
async function pair(io) {
|
|
108
131
|
const { keys, identity } = needPaired(io);
|
|
109
132
|
const settings = loadSettings();
|
|
110
|
-
if (!settings.enabled || !settings.gateway) io.fail("remote is off or has no gateway: run `npx worktrust remote
|
|
133
|
+
if (!settings.enabled || !settings.gateway) io.fail("remote is off or has no gateway: run `npx worktrust remote app` (or `remote web`)");
|
|
111
134
|
const started = Date.now();
|
|
112
135
|
const invite = P.createPairingInvite({ gateway: settings.gateway, deviceId: identity.device_id, ed25519_pub: keys.public.ed25519_pub, x25519_pub: keys.public.x25519_pub, nowMs: started, random });
|
|
113
136
|
const code = P.generatePairingCode(random);
|
|
@@ -160,14 +183,13 @@ async function phones(io, rest) {
|
|
|
160
183
|
if (rest[0] === "remove" && (rest[1] === "--all" || io.has("all"))) { // EVERY DEVICE OFF, FROM THE SOURCE (owner, 2026-11-09): the daemon reads this list per message
|
|
161
184
|
const all = [...list.confirmed, ...list.pending], at = Date.now(); if (all.length === 0) return io.say(" No phone or browser is connected to this computer.");
|
|
162
185
|
if (process.stdin.isTTY && !(await askTyped(` Disconnect all ${all.length} phones and browsers from this computer now?`))) return io.say(" Nothing changed.");
|
|
163
|
-
|
|
186
|
+
removePhones(all.map((p) => p.fingerprint), at);
|
|
164
187
|
return io.say(` ✓ Disconnected ${all.length}: none of them can steer this computer any more. Live sessions they started keep running here; stop them with npx worktrust remote disable, or pause everything with npx worktrust remote pause.\n End their keys for your whole account too: app.worktrust.io › Settings › Remote Agent, or Remote Agent settings on your phone.`);
|
|
165
188
|
}
|
|
166
189
|
if (rest[0] === "remove") {
|
|
167
190
|
const phone = find(rest[1]);
|
|
168
191
|
if (!phone) io.fail("no phone by that fingerprint or id");
|
|
169
|
-
|
|
170
|
-
removed: [...list.removed.filter((p) => p.device_id !== phone.device_id), { device_id: phone.device_id, fingerprint: phone.fingerprint, how: "keyboard", removed_at: Date.now() }].slice(-20) });
|
|
192
|
+
removePhones([phone.fingerprint]);
|
|
171
193
|
io.say(` ✓ Removed ${phone.fingerprint}: it can no longer steer this computer. Revoke it in WorkTrust too.`);
|
|
172
194
|
return;
|
|
173
195
|
}
|
|
@@ -185,25 +207,18 @@ async function phones(io, rest) {
|
|
|
185
207
|
}
|
|
186
208
|
}
|
|
187
209
|
|
|
210
|
+
/** A change at this keyboard, through the one door (remote-settings.mjs); macOS is asked at once for a guarded folder. */
|
|
211
|
+
async function settingsChange(io, change) {
|
|
212
|
+
if (change.add !== undefined) needPaired(io);
|
|
213
|
+
const done = applySettingsChange(change, { kind: "keyboard" });
|
|
214
|
+
if (!done.ok) io.fail(done.reason);
|
|
215
|
+
io.say(` ✓ ${done.message}`);
|
|
216
|
+
if (done.paths && !io.has("no-folder-check")) await askMacFolderAccess(io, done.paths);
|
|
217
|
+
}
|
|
218
|
+
|
|
188
219
|
function projects(io, rest) {
|
|
189
220
|
const list = loadProjects();
|
|
190
|
-
if (rest[0] === "add") {
|
|
191
|
-
const { keys } = needPaired(io);
|
|
192
|
-
const canonical = canonicalProject(rest[1]);
|
|
193
|
-
if (!canonical.ok) io.fail(`not granted: ${canonical.reason}`);
|
|
194
|
-
const project_id = projectIdOf(keys.projectSecret, canonical.path);
|
|
195
|
-
if (!list.some((p) => p.project_id === project_id)) saveProjects([...list, { project_id, path: canonical.path, added_at: Date.now() }]);
|
|
196
|
-
io.say(` ✓ Granted: ${canonical.path}`);
|
|
197
|
-
return;
|
|
198
|
-
}
|
|
199
|
-
if (rest[0] === "remove") {
|
|
200
|
-
const canonical = canonicalProject(rest[1] ?? "");
|
|
201
|
-
const kept = list.filter((p) => p.project_id !== rest[1] && p.path !== rest[1] && !(canonical.ok && p.path === canonical.path));
|
|
202
|
-
if (kept.length === list.length) io.fail("no granted folder by that path or id");
|
|
203
|
-
saveProjects(kept);
|
|
204
|
-
io.say(" ✓ Removed.");
|
|
205
|
-
return;
|
|
206
|
-
}
|
|
221
|
+
if (rest[0] === "add" || rest[0] === "remove") return settingsChange(io, { what: "projects", [rest[0]]: rest[1] ?? "" });
|
|
207
222
|
io.say(` Granted folders (${list.length}):`);
|
|
208
223
|
for (const p of list) io.say(` ${p.path} (${basename(p.path)})`);
|
|
209
224
|
}
|
|
@@ -211,23 +226,8 @@ function projects(io, rest) {
|
|
|
211
226
|
/** `remote roots …`: where a phone may create a new project folder, added here at the keyboard only. */
|
|
212
227
|
function roots(io, rest) {
|
|
213
228
|
const list = loadRoots();
|
|
214
|
-
if (rest[0] === "add") {
|
|
215
|
-
|
|
216
|
-
const root = checkRoot(rest[1] ?? "");
|
|
217
|
-
if (!root.ok) io.fail(`not added: ${root.reason}`);
|
|
218
|
-
if (list.length >= MAX_ROOTS && !list.some((r) => r.path === root.path)) io.fail(`at most ${MAX_ROOTS} roots`);
|
|
219
|
-
const root_id = rootIdOf(keys.projectSecret, root.path);
|
|
220
|
-
saveRoots([...list.filter((r) => r.root_id !== root_id), { root_id, path: root.path, git_init: io.has("git-init"), added_at: Date.now() }]);
|
|
221
|
-
io.say(` ✓ Root: ${root.path} (${rootLabel(root.path)}). A phone may create one new, empty folder in it per request${io.has("git-init") ? ", with git init" : ""}.`);
|
|
222
|
-
return;
|
|
223
|
-
}
|
|
224
|
-
if (rest[0] === "remove") {
|
|
225
|
-
const kept = list.filter((r) => r.root_id !== rest[1] && r.path !== rest[1] && r.path !== checkRoot(rest[1] ?? "").path);
|
|
226
|
-
if (kept.length === list.length) io.fail("no root by that path or id");
|
|
227
|
-
saveRoots(kept);
|
|
228
|
-
io.say(" ✓ Removed. Projects made in it stay granted: npx worktrust remote projects remove <folder>.");
|
|
229
|
-
return;
|
|
230
|
-
}
|
|
229
|
+
if (rest[0] === "add") return settingsChange(io, { what: "roots", add: rest[1] ?? "", git_init: io.has("git-init") });
|
|
230
|
+
if (rest[0] === "remove") return settingsChange(io, { what: "roots", remove: rest[1] ?? "" });
|
|
231
231
|
io.say(` Roots (${list.length}):`);
|
|
232
232
|
for (const r of list) io.say(` ${r.path} (${rootLabel(r.path)}${r.git_init ? ", git init" : ""})`);
|
|
233
233
|
}
|
|
@@ -284,7 +284,7 @@ function status(io) {
|
|
|
284
284
|
const settings = loadSettings(), identity = loadIdentity(), keys = identity ? loadKeys() : null, phonesList = loadPhones(), service = serviceState();
|
|
285
285
|
const agents = inventory({ env: { ...process.env, PATH: settings.agent_path ?? process.env.PATH } }).reports.filter((r) => r.installed);
|
|
286
286
|
const summary = { enabled: settings.enabled, paused: settings.paused, paired: Boolean(identity), device_id: identity?.device_id ?? null, fingerprint: keys ? fingerprintOf(keys) : null,
|
|
287
|
-
gateway: settings.gateway, service, node_websocket: webSocketAvailable(), phones: { confirmed: phonesList.confirmed.length, pending: phonesList.pending.length, browsers_added: phonesList.confirmed.filter((p) => p.how === "endorsed").length, allow_endorse: settings.allow_endorse === true }, projects: loadProjects().length,
|
|
287
|
+
gateway: settings.gateway, service, node_websocket: webSocketAvailable(), phones: { confirmed: phonesList.confirmed.length, pending: phonesList.pending.length, browsers_added: phonesList.confirmed.filter((p) => p.how === "endorsed").length, allow_endorse: settings.allow_endorse === true }, projects: loadProjects().length, modes_allowed: allowedModes(settings), admin: settings.admin !== false,
|
|
288
288
|
agents: agents.map((a) => ({ adapter: a.adapter, version: a.version, adapter_ready: a.capabilities.start, switched_off: a.capabilities.start && (a.adapter === "codex" || a.adapter === "opencode") && settings[a.adapter] !== true, models: a.models === null ? "not listed" : a.models.length })), invite_open: Boolean(readJson("invite.json")?.used === false) };
|
|
289
289
|
if (io.has("json")) { io.say(JSON.stringify(summary, null, 2)); return; }
|
|
290
290
|
io.say(` Remote: ${settings.enabled ? (settings.paused ? `paused (${settings.paused === "desk" ? "here" : "from a phone"})` : "on") : "off"}`);
|
|
@@ -293,12 +293,14 @@ function status(io) {
|
|
|
293
293
|
io.say(` Service: ${service.kind === "foreground" ? "none on this system: run `npx worktrust remote run`" : `${service.installed ? "installed" : "not installed"}, ${service.running ? "running" : "not running"}`}`);
|
|
294
294
|
io.say(` Phones: ${summary.phones.confirmed} confirmed (${summary.phones.browsers_added} browsers added by a phone), ${summary.phones.pending} pending · Folders granted: ${summary.projects}`);
|
|
295
295
|
io.say(` Phones may add a browser: ${summary.phones.allow_endorse ? "yes" : "no"}`);
|
|
296
|
+
io.say(` Agent modes a phone may start: ${allowedModes(settings).join(", ")} (npx worktrust remote modes)`);
|
|
296
297
|
for (const a of summary.agents) io.say(` Agent: ${a.adapter} ${a.version ?? ""} · ${a.switched_off ? `installed, switched off: npx worktrust remote ${a.adapter} on` : a.adapter_ready ? "remote adapter ready" : "installed, no adapter yet"} · models: ${a.models}`);
|
|
297
298
|
}
|
|
298
299
|
|
|
299
300
|
export async function remoteCommand(args, io) {
|
|
300
301
|
const [sub = "help", ...rest] = args;
|
|
301
|
-
if (sub
|
|
302
|
+
if (remoteStopsHere(sub)) return guideToNode(io, ["remote", ...args], { connected: io.connected?.() }); // Node before 22.4: node-guide.mjs
|
|
303
|
+
if (sub === "app" || sub === "web") return approve(io, sub);
|
|
302
304
|
if (sub === "pair") return pair(io);
|
|
303
305
|
if (sub === "status") return status(io);
|
|
304
306
|
if (sub === "pause" || sub === "resume") { const s = loadSettings(); saveSettings({ ...s, paused: sub === "pause" ? "desk" : null }); io.say(sub === "pause" ? " Paused: every command from a phone is refused until `npx worktrust remote resume`." : " Resumed."); return; }
|
|
@@ -310,10 +312,15 @@ export async function remoteCommand(args, io) {
|
|
|
310
312
|
return;
|
|
311
313
|
}
|
|
312
314
|
if (sub === "phones") return phones(io, rest);
|
|
315
|
+
if (sub === "connections") return connectionsCommand(io);
|
|
316
|
+
if (sub === "disconnect") return disconnectCommand(io, rest, askLine);
|
|
313
317
|
if (sub === "projects") return projects(io, rest);
|
|
314
318
|
if (sub === "run") return (await import("./remote-run.mjs")).runDaemon({ say: io.say });
|
|
315
319
|
if (sub === "pipeline") return pipeline(io, rest);
|
|
316
320
|
if (sub === "roots") return roots(io, rest);
|
|
321
|
+
if (sub === "modes") return modesCommand(io, rest);
|
|
322
|
+
if (sub === "admin") return adminCommand(io, rest);
|
|
323
|
+
if (sub === "folder-check") return folderCheck(); // internal: the one-shot launchd job of askMacFolderAccess
|
|
317
324
|
if (sub === "preview") {
|
|
318
325
|
const grants = loadPreviewGrants();
|
|
319
326
|
if (rest[0] === "allow" || rest[0] === "deny") {
|
|
@@ -338,5 +345,6 @@ export async function remoteCommand(args, io) {
|
|
|
338
345
|
if (sub === "releases") return releasesCommand(io, rest);
|
|
339
346
|
if (sub === "terminal") return (await import("./remote-terminal-cli.mjs")).terminalCommand(io, rest, askTyped);
|
|
340
347
|
if (sub === "attach") return (await import("./remote-terminal-cli.mjs")).attachCommand(io, rest);
|
|
341
|
-
|
|
348
|
+
if (sub !== "help") { io.say(sub === "enable" ? " Unknown command: remote enable. Use `npx worktrust remote app` (approve with your phone) or `npx worktrust remote web` (approve in the browser)." : ` Unknown command: remote ${sub}. The remote commands are below.`); process.exitCode = 1; }
|
|
349
|
+
io.say(" npx worktrust remote app | web | pair | connections | disconnect <n|name|fingerprint>|--all | status | pause | resume | disable [--forget] | phones [confirm|remove <id>|remove --all|allow-endorse on|off] | projects add|remove|list | run | pipeline review <folder>|status | roots add|remove|list | modes allow|deny edit|auto|status | admin on|off | preview allow|deny|list | codex on|off | opencode on|off | terminal on|off|list|start | attach <id> | releases [released <n>]");
|
|
342
350
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WHAT IS LINKED TO THIS COMPUTER, AND CLOSING IT (CLI 0.11.7, owner 2026-11-12). `remote connections` lists every phone and
|
|
3
|
+
* browser linked to this computer (name, kind, fingerprint, since, last seen) and this computer's own link; `remote
|
|
4
|
+
* disconnect <number | name | fingerprint>` closes one after TWO confirmations (y, then its short fingerprint or its name
|
|
5
|
+
* typed), and `remote disconnect --all` closes every one after `close all` typed exactly. Both are the same removal as
|
|
6
|
+
* `remote phones remove` (kept, and folded onto removePhones here): the phone leaves the confirmed and pending lists for
|
|
7
|
+
* `removed`, which the daemon reads per message, so it can no longer steer this computer. Its key for the whole account
|
|
8
|
+
* is ended in WorkTrust (Settings › Remote Agent), as before. No prompt without a terminal: the command refuses instead.
|
|
9
|
+
*
|
|
10
|
+
* The computer knows a phone by its keys only: the "name" is its kind and the start of its fingerprint ("Phone 9M8N"),
|
|
11
|
+
* never a model name it was not told.
|
|
12
|
+
*/
|
|
13
|
+
import { createInterface } from "node:readline/promises";
|
|
14
|
+
import { loadIdentity, loadKeys, loadPhones, savePhones } from "./remote-store.mjs";
|
|
15
|
+
import * as P from "./remote-protocol.mjs";
|
|
16
|
+
|
|
17
|
+
const KEEP_REMOVED = 20;
|
|
18
|
+
const when = (ms) => (Number.isFinite(ms) ? new Date(ms).toISOString().slice(0, 16).replace("T", " ") : "never");
|
|
19
|
+
export const shortPrint = (fingerprint) => String(fingerprint ?? "").replace(/[^A-Za-z0-9]/g, "").slice(0, 4).toUpperCase();
|
|
20
|
+
|
|
21
|
+
/** A line typed at this keyboard (the typed confirmations below). */
|
|
22
|
+
export async function askLine(question) {
|
|
23
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
24
|
+
const answer = await prompt.question(`${question} `);
|
|
25
|
+
prompt.close();
|
|
26
|
+
return answer;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Every phone and browser, numbered from 1: confirmed first, then pending. */
|
|
30
|
+
export function connections(phones = loadPhones()) {
|
|
31
|
+
const row = (p, state) => {
|
|
32
|
+
const kind = p.how === "endorsed" ? "browser" : p.kind === "browser" ? "browser" : "phone";
|
|
33
|
+
return { device_id: p.device_id, fingerprint: p.fingerprint, kind, state, name: p.name ?? `${kind === "browser" ? "Browser" : "Phone"} ${shortPrint(p.fingerprint)}`, since: p.confirmed_at ?? p.seen_at ?? null, last_seen: p.seen_at ?? null };
|
|
34
|
+
};
|
|
35
|
+
return [...phones.confirmed.map((p) => row(p, "confirmed")), ...phones.pending.map((p) => row(p, "pending"))].map((c, i) => ({ n: i + 1, ...c }));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** One connection by its number in the list, its name, its fingerprint (whole, or its first four) or its device id. */
|
|
39
|
+
export function findConnection(list, key) {
|
|
40
|
+
const k = String(key ?? "").trim();
|
|
41
|
+
if (!k) return null;
|
|
42
|
+
if (/^\d{1,3}$/.test(k)) return list.find((c) => c.n === Number(k)) ?? null;
|
|
43
|
+
const upper = k.toUpperCase();
|
|
44
|
+
return list.find((c) => c.device_id === k || c.fingerprint.toUpperCase() === upper || c.name.toLowerCase() === k.toLowerCase())
|
|
45
|
+
?? (shortPrint(k).length === 4 ? list.filter((c) => shortPrint(c.fingerprint) === shortPrint(k)).at(0) ?? null : null);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Take phones off this computer, the one removal `remote phones remove` and `remote disconnect` share. */
|
|
49
|
+
export function removePhones(fingerprints, at = Date.now()) {
|
|
50
|
+
const phones = loadPhones(), gone = new Set(fingerprints);
|
|
51
|
+
const out = [...phones.confirmed, ...phones.pending].filter((p) => gone.has(p.fingerprint));
|
|
52
|
+
savePhones({ ...phones, pending: phones.pending.filter((p) => !gone.has(p.fingerprint)), confirmed: phones.confirmed.filter((p) => !gone.has(p.fingerprint)),
|
|
53
|
+
removed: [...phones.removed.filter((p) => !out.some((x) => x.device_id === p.device_id)), ...out.map((p) => ({ device_id: p.device_id, fingerprint: p.fingerprint, how: "keyboard", removed_at: at }))].slice(-KEEP_REMOVED) });
|
|
54
|
+
return out.length;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** `remote connections`. */
|
|
58
|
+
export function connectionsCommand(io) {
|
|
59
|
+
const identity = loadIdentity(), keys = identity ? loadKeys() : null;
|
|
60
|
+
io.say(identity ? ` This computer: ${identity.device_id} · key ${P.deviceFingerprint(keys.public)} · linked ${when(identity.paired_at)}` : " This computer: not linked to Remote Agent (npx worktrust remote app)");
|
|
61
|
+
const list = connections();
|
|
62
|
+
io.say(` Linked to it (${list.length}):`);
|
|
63
|
+
for (const c of list) io.say(` ${String(c.n).padStart(2)} ${c.name.padEnd(16)} ${c.kind.padEnd(8)} ${c.fingerprint} since ${when(c.since)} · last seen ${when(c.last_seen)}${c.state === "pending" ? " (pending: npx worktrust remote phones confirm " + c.fingerprint + ")" : ""}`);
|
|
64
|
+
if (list.length) io.say(" Close one: npx worktrust remote disconnect <number|name|fingerprint> all: npx worktrust remote disconnect --all");
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/**
|
|
68
|
+
* `remote disconnect <key> | --all`. `ask(question)` → the typed answer (a terminal's line); tests pass their own. Without a
|
|
69
|
+
* terminal it refuses: closing a link is confirmed by a person at this keyboard.
|
|
70
|
+
*/
|
|
71
|
+
export async function disconnectCommand(io, rest, ask, tty = Boolean(process.stdin.isTTY)) {
|
|
72
|
+
const list = connections();
|
|
73
|
+
const all = rest[0] === "--all" || io.has("all");
|
|
74
|
+
if (!tty) return io.fail("closing a connection is confirmed at this keyboard: run it in a terminal");
|
|
75
|
+
if (list.length === 0) return io.say(" No phone or browser is linked to this computer.");
|
|
76
|
+
if (all) {
|
|
77
|
+
io.say(` This closes every connection to this computer (${list.length}):`);
|
|
78
|
+
for (const c of list) io.say(` ${c.name} (${c.kind}, ${c.fingerprint})`);
|
|
79
|
+
if ((await ask(" Type close all to confirm:")).trim() !== "close all") return io.say(" Cancelled. Nothing was closed.");
|
|
80
|
+
const n = removePhones(list.map((c) => c.fingerprint));
|
|
81
|
+
io.say(` ✓ Closed ${n}: none of them can steer this computer any more. End their keys for your whole account too: app.worktrust.io › Settings › Remote Agent.`);
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
const c = findConnection(list, rest[0]);
|
|
85
|
+
if (!c) return io.fail("no connection by that number, name or fingerprint (npx worktrust remote connections lists them)");
|
|
86
|
+
if (!/^y(es)?$/i.test((await ask(` Disconnect ${c.name} (${c.fingerprint})? It can no longer steer this computer. [y/N]`)).trim())) return io.say(" Cancelled. Nothing was closed.");
|
|
87
|
+
const typed = (await ask(` To confirm, type ${shortPrint(c.fingerprint)} (the start of its fingerprint) or its name:`)).trim();
|
|
88
|
+
if (typed.toUpperCase() !== shortPrint(c.fingerprint) && typed.toLowerCase() !== c.name.toLowerCase()) return io.say(" That does not match. Cancelled. Nothing was closed.");
|
|
89
|
+
removePhones([c.fingerprint]);
|
|
90
|
+
io.say(` ✓ Disconnected ${c.name}: it can no longer steer this computer. End its key for your whole account too: app.worktrust.io › Settings › Remote Agent.`);
|
|
91
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE APPROVAL'S CLOCK IN THE TERMINAL (CLI 0.11.7, owner 2026-11-12, after testing `remote app` live). While `remote app`
|
|
3
|
+
* or `remote web` waits for the approval, a bar under the QR or link drains over the request's own window (the issuer's
|
|
4
|
+
* answer, never a fixed ten minutes), redrawn in place once a second: `[████████░░░░] 7:41 left`. Without a terminal the
|
|
5
|
+
* expiry time is printed once. The bar reads no key and never touches raw mode; waitKey (the "new QR code?" question after
|
|
6
|
+
* an expiry) does, and always gives it back.
|
|
7
|
+
*/
|
|
8
|
+
import { emitKeypressEvents } from "node:readline";
|
|
9
|
+
|
|
10
|
+
export const BAR_WIDTH = 24;
|
|
11
|
+
const clock = (ms) => { const s = Math.max(0, Math.ceil(ms / 1000)); return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`; };
|
|
12
|
+
|
|
13
|
+
/** One line of the bar for `left` of `windowMs` milliseconds. Pure. */
|
|
14
|
+
export function barLine(left, windowMs, width = BAR_WIDTH) {
|
|
15
|
+
const share = windowMs > 0 ? Math.min(1, Math.max(0, left / windowMs)) : 0;
|
|
16
|
+
const full = Math.round(share * width);
|
|
17
|
+
return `[${"█".repeat(full)}${"░".repeat(width - full)}] ${clock(left)} left`;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Start the bar; → { stop(finalLine?) }. `out` is stdout, `tty` whether it is a terminal, `now` the clock. */
|
|
21
|
+
export function startCountdown({ expiresAt, windowMs, out = process.stdout, tty = Boolean(process.stdout.isTTY), now = Date.now }) {
|
|
22
|
+
if (!tty) {
|
|
23
|
+
out.write(` This request expires at ${new Date(expiresAt).toTimeString().slice(0, 5)} (in ${clock(expiresAt - now())}).\n`);
|
|
24
|
+
return { stop: (line) => { if (line) out.write(` ${line}\n`); } };
|
|
25
|
+
}
|
|
26
|
+
const draw = () => out.write(`\r\x1b[2K ${barLine(expiresAt - now(), windowMs)}`);
|
|
27
|
+
draw();
|
|
28
|
+
const timer = setInterval(draw, 1000);
|
|
29
|
+
timer.unref?.();
|
|
30
|
+
let stopped = false;
|
|
31
|
+
return {
|
|
32
|
+
stop(line) {
|
|
33
|
+
if (stopped) return;
|
|
34
|
+
stopped = true;
|
|
35
|
+
clearInterval(timer);
|
|
36
|
+
out.write(`\r\x1b[2K${line ? ` ${line}` : ""}\n`);
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** One key from a terminal: "enter", "q" or another; null without a terminal. Raw mode only for that key, always restored. */
|
|
42
|
+
export function waitKey(input = process.stdin) {
|
|
43
|
+
if (!input.isTTY) return Promise.resolve(null);
|
|
44
|
+
emitKeypressEvents(input);
|
|
45
|
+
return new Promise((resolve) => {
|
|
46
|
+
const done = (value) => { input.off("keypress", on); try { input.setRawMode(false); } catch { /* gone */ } input.pause(); resolve(value); };
|
|
47
|
+
const on = (str, k = {}) => done(k.ctrl && k.name === "c" ? "q" : k.name === "return" || k.name === "enter" ? "enter" : (k.name ?? str ?? "").toLowerCase());
|
|
48
|
+
try { input.setRawMode(true); } catch { resolve(null); return; }
|
|
49
|
+
input.resume();
|
|
50
|
+
input.on("keypress", on);
|
|
51
|
+
});
|
|
52
|
+
}
|
package/remote-daemon.mjs
CHANGED
|
@@ -14,7 +14,10 @@ import { basename } from "node:path";
|
|
|
14
14
|
import * as P from "./remote-protocol.mjs";
|
|
15
15
|
import { confirmedFingerprints, controllerKeys, loadChannels, loadEndorsements, loadPhones, loadProjects, loadRoots, loadSettings, readJson, saveChannels, saveEndorsements, savePhones, saveProjects, saveSettings, writeJson } from "./remote-store.mjs";
|
|
16
16
|
import { acceptEndorsement } from "./remote-endorse.mjs";
|
|
17
|
-
import { createProject, rootLabel, worktreeMain } from "./remote-projects.mjs";
|
|
17
|
+
import { createProject, rootLabel, sessionProjects, worktreeMain } from "./remote-projects.mjs";
|
|
18
|
+
import { agentOptionsOf } from "./remote-inventory.mjs";
|
|
19
|
+
import { allowedModes, applySettingsChange } from "./remote-settings.mjs";
|
|
20
|
+
import { adminInventory } from "./remote-admin.mjs";
|
|
18
21
|
|
|
19
22
|
// What a paused computer still answers: reading, configuring, disconnecting, and taking work away (a pipeline's cancel).
|
|
20
23
|
const LIVE_COMMANDS = new Set(["preview.live_start", "preview.live_input", "preview.live_viewport", "preview.live_follow"]);
|
|
@@ -30,11 +33,21 @@ export function createDaemonCore(o) {
|
|
|
30
33
|
const persist = () => saveChannels([...channels.values()]);
|
|
31
34
|
let sessions = null, approvals = o.approvals ?? null, releases = null;
|
|
32
35
|
|
|
36
|
+
/**
|
|
37
|
+
* THE 0.11.7 INVENTORY FIELDS REACH ONLY A PHONE THAT ASKED FOR THEM (inventory.get `extended`): an older phone refuses
|
|
38
|
+
* unknown keys, so every other channel gets the inventory without them. Kept per phone for the daemon's life; a phone
|
|
39
|
+
* asks again on every inventory.get.
|
|
40
|
+
*/
|
|
41
|
+
const extendedPeers = new Set();
|
|
42
|
+
const EXTENDED_KEYS = ["agent_options", "modes_allowed", "admin", "folders", "connections"];
|
|
43
|
+
const bodyFor = (channel, record) => (record.type !== "device.inventory" || extendedPeers.has(channel.peer_device_id) ? record.body
|
|
44
|
+
: Object.fromEntries(Object.entries(record.body).filter(([key]) => !EXTENDED_KEYS.includes(key))));
|
|
45
|
+
|
|
33
46
|
function sealAll(record) {
|
|
34
47
|
for (const [id, channel] of channels) {
|
|
35
48
|
if (!confirmed().has(channel.peer_fingerprint)) { channels.delete(id); continue; } // a revoked phone hears nothing
|
|
36
49
|
const draft = { protocol_version: channel.protocol_version, session_id: record.session_id, device_id: self, event_seq: record.event_seq, type: record.type, occurred_at: record.occurred_at, command_id: record.command_id, notify: record.notify, ...(record.lane ? { lane: record.lane } : {}) };
|
|
37
|
-
const sealed = P.sealEvent(channel, draft, record
|
|
50
|
+
const sealed = P.sealEvent(channel, draft, bodyFor(channel, record), o.random);
|
|
38
51
|
if (!sealed.ok) { o.log("seal_refused", { type: record.type, code: sealed.code }); continue; }
|
|
39
52
|
channels.set(id, sealed.value.channel);
|
|
40
53
|
o.send({ frame: "event", envelope: sealed.value.envelope });
|
|
@@ -72,17 +85,24 @@ export function createDaemonCore(o) {
|
|
|
72
85
|
|
|
73
86
|
function inventoryBody(refresh) {
|
|
74
87
|
const settings = loadSettings();
|
|
88
|
+
const inv = o.inventory(refresh);
|
|
75
89
|
return {
|
|
76
90
|
remote_enabled: settings.enabled && settings.paused === null,
|
|
77
91
|
default_adapter: settings.default_adapter ?? null,
|
|
78
92
|
default_model: settings.default_model ?? null,
|
|
79
|
-
adapters:
|
|
93
|
+
adapters: inv.reports,
|
|
80
94
|
// A worktree names its main repository (`main`), only when it is one: a phone groups its sessions under that project.
|
|
81
|
-
|
|
95
|
+
// 0.11.7: the existing git projects inside each root follow the granted ones (root_id set), 30 in all.
|
|
96
|
+
projects: (o.projectSecret ? sessionProjects({ projects: loadProjects, roots: loadRoots, projectSecret: o.projectSecret }) : loadProjects().slice(0, 30)).map((p) => {
|
|
82
97
|
const main = worktreeMain(p.path);
|
|
83
98
|
return { project_id: p.project_id, label: (basename(p.path) || p.path).slice(0, 256), path: p.path.slice(0, 4096), last_used_at: null, root_id: p.root_id ?? null, ...(main ? { main: main.slice(0, 4096) } : {}) };
|
|
84
99
|
}),
|
|
85
100
|
roots: loadRoots().slice(0, 20).map((r) => ({ root_id: r.root_id, label: rootLabel(r.path), git_init: r.git_init === true })),
|
|
101
|
+
// Sealed only for a phone that asked `extended` (bodyFor above): what each agent offers, and the keyboard's ceiling.
|
|
102
|
+
...(inv.features ? { agent_options: agentOptionsOf(inv), modes_allowed: allowedModes(settings) } : {}),
|
|
103
|
+
// Part B, also only for an `extended` phone: the admin switch, the folders this computer suggests (by its own ids),
|
|
104
|
+
// and the phones and browsers linked to it (remote-admin.mjs).
|
|
105
|
+
...adminInventory({ projectSecret: o.projectSecret, settings }),
|
|
86
106
|
// Every session this computer knows, live or in the journal, newest activity first, with its name and its release task.
|
|
87
107
|
sessions: (sessions?.listAll?.() ?? sessions?.list() ?? []).map((s) => ({ ...s, ...(releases?.ownerOf(s.session_id) ?? {}) })).slice(0, 100),
|
|
88
108
|
};
|
|
@@ -100,7 +120,29 @@ export function createDaemonCore(o) {
|
|
|
100
120
|
emit(env.session_id, "command.rejected", { reason }, env.command_id);
|
|
101
121
|
}
|
|
102
122
|
|
|
103
|
-
|
|
123
|
+
/**
|
|
124
|
+
* PART B: one settings change from the app or the web (device.configure `settings_change`). applySettingsChange checks
|
|
125
|
+
* `remote admin on`, then the issuer-signed proof against THIS computer's pinned keys, device id and account (o.local,
|
|
126
|
+
* never the payload), then resolves the change from this computer's own lists by id. The run terminal says it in words.
|
|
127
|
+
*/
|
|
128
|
+
function settingsChange(env, sent) {
|
|
129
|
+
const done = applySettingsChange(sent.change, { kind: "admin", proof: sent.proof, issuerKeys: o.issuerKeys, claims: o.local.claims, now: o.now() });
|
|
130
|
+
if (!done.ok) { o.log("settings_refused", { code: done.code ?? "not_allowed" }); return done.code ?? "not_allowed"; }
|
|
131
|
+
const by = loadPhones().confirmed.find((p) => p.device_id === env.sender_device_id);
|
|
132
|
+
o.log("settings_changed", { setting: done.setting, by: by?.name ?? by?.fingerprint ?? env.sender_device_id });
|
|
133
|
+
emit(null, "device.inventory", inventoryBody(false));
|
|
134
|
+
return "taken";
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/** A phone's or browser's own name (inventory.get `device_name`, validated by the protocol), kept with its record here. */
|
|
138
|
+
function rememberName(deviceId, name) {
|
|
139
|
+
const phones = loadPhones();
|
|
140
|
+
if (!phones.confirmed.some((p) => p.device_id === deviceId && p.name !== name)) return;
|
|
141
|
+
savePhones({ ...phones, confirmed: phones.confirmed.map((p) => (p.device_id === deviceId ? { ...p, name: name.slice(0, 64) } : p)) });
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
async function configure(payload, env) {
|
|
145
|
+
if (payload.settings_change) return settingsChange(env, payload.settings_change);
|
|
104
146
|
const settings = loadSettings();
|
|
105
147
|
if (payload.remote_enabled === true && settings.paused === "desk") return "remote_paused"; // the desk's pause is the person's, at the keyboard
|
|
106
148
|
const next = { ...settings };
|
|
@@ -137,8 +179,13 @@ export function createDaemonCore(o) {
|
|
|
137
179
|
const settings = loadSettings();
|
|
138
180
|
if (!settings.enabled) return "remote_paused";
|
|
139
181
|
if (settings.paused !== null && !DEVICE_COMMANDS.has(env.type)) return "remote_paused";
|
|
140
|
-
if (env.type === "inventory.get") {
|
|
141
|
-
|
|
182
|
+
if (env.type === "inventory.get") {
|
|
183
|
+
if (payload.extended === true && env.sender_device_id) extendedPeers.add(env.sender_device_id);
|
|
184
|
+
if (payload.device_name && env.sender_device_id) rememberName(env.sender_device_id, payload.device_name);
|
|
185
|
+
emit(null, "device.inventory", inventoryBody(payload.refresh_models));
|
|
186
|
+
return "taken";
|
|
187
|
+
}
|
|
188
|
+
if (env.type === "device.configure") return configure(payload, env);
|
|
142
189
|
if (env.type === "status.get" && payload.scope === "device") { emit(null, "device.inventory", inventoryBody(false)); return "taken"; }
|
|
143
190
|
if (env.type === "pairing.revoke") return "taken";
|
|
144
191
|
if (env.type === "project.create") {
|
|
@@ -210,6 +257,8 @@ export function createDaemonCore(o) {
|
|
|
210
257
|
writeJson("invite.json", { ...live, used: true, used_at: o.now(), used_by: phone.fingerprint });
|
|
211
258
|
savePhones({ ...phones, removed: phones.removed.filter((p) => p.device_id !== phone.device_id), pending: phones.pending.filter((p) => p.fingerprint !== phone.fingerprint), confirmed: [...phones.confirmed.filter((p) => p.fingerprint !== phone.fingerprint), { ...phone, how: "qr", confirmed_at: o.now() }] });
|
|
212
259
|
}
|
|
260
|
+
// Last seen (0.11.7, `remote connections`): the moment this phone last opened a channel, kept with it on this computer only.
|
|
261
|
+
{ const now = loadPhones(); savePhones({ ...now, confirmed: now.confirmed.map((p) => (p.fingerprint === phone.fingerprint ? { ...p, seen_at: o.now() } : p)) }); }
|
|
213
262
|
for (const [id, c] of channels) if (c.peer_device_id === phone.device_id) channels.delete(id);
|
|
214
263
|
channels.set(accepted.value.channel.channel_id, accepted.value.channel);
|
|
215
264
|
persist();
|
package/remote-inventory.mjs
CHANGED
|
@@ -64,9 +64,37 @@ export function claudeFeatures(help) {
|
|
|
64
64
|
// The agent's planning tools run without a prompt (they only write a plan), and one line says to use them (2026-11-08).
|
|
65
65
|
allowed: /--allowedTools/.test(h),
|
|
66
66
|
appendPrompt: /--append-system-prompt/.test(h),
|
|
67
|
+
// CLI 0.11.7 (owner, 2026-11-12): the finer modes, the effort levels and the extra directories, each only as its help names it.
|
|
68
|
+
editMode: choices.includes("acceptEdits") ? "acceptEdits" : null,
|
|
69
|
+
autoMode: choices.includes("auto") ? "auto" : null,
|
|
70
|
+
efforts: claudeEfforts(h),
|
|
71
|
+
addDir: /--add-dir <directories?\.\.\.>/.test(h),
|
|
67
72
|
};
|
|
68
73
|
}
|
|
69
74
|
|
|
75
|
+
/** The effort levels Claude Code's own --effort help lists, in the protocol's order; none when the help names none. */
|
|
76
|
+
export function claudeEfforts(help) {
|
|
77
|
+
const block = /--effort <level>([\s\S]*?)(?=\n\s{2}-|\n\s*\n|$)/.exec(help ?? "")?.[1] ?? "";
|
|
78
|
+
const named = /\(([^)]*)\)/.exec(block.replace(/\s+/g, " "))?.[1]?.split(",").map((w) => w.trim()) ?? [];
|
|
79
|
+
return P.AGENT_EFFORTS.filter((e) => named.includes(e));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* WHAT EACH OFFERED ADAPTER CAN DO BEYOND `permission_modes` (CLI 0.11.7), for an extended inventory: Claude Code
|
|
84
|
+
* structured from its own help (acceptEdits is `edit`, auto is `auto`, --effort, --add-dir); every other report, and Claude
|
|
85
|
+
* Code in a terminal, offers manual and plan as its permission modes say, no effort and one project (Codex's app-server
|
|
86
|
+
* sandbox keeps writable roots empty on purpose; owner decision open, PROTOCOL.md "Agent modes").
|
|
87
|
+
*/
|
|
88
|
+
export function agentOptionsOf(inv) {
|
|
89
|
+
const f = inv.features?.["claude-code"] ?? {};
|
|
90
|
+
return inv.reports.filter((r) => r.installed && r.capabilities.start).map((r) => {
|
|
91
|
+
const base = r.capabilities.permission_modes.map((m) => (m === "plan" ? "plan" : "manual"));
|
|
92
|
+
if (r.adapter !== "claude-code" || r.mode !== "structured") return { adapter: r.adapter, mode: r.mode, agent_modes: P.AGENT_MODES.filter((m) => base.includes(m)), efforts: [], extra_projects: 0 };
|
|
93
|
+
const modes = new Set([...base, ...(f.editMode ? ["edit"] : []), ...(f.autoMode ? ["auto"] : [])]);
|
|
94
|
+
return { adapter: r.adapter, mode: r.mode, agent_modes: P.AGENT_MODES.filter((m) => modes.has(m)), efforts: [...(f.efforts ?? [])], extra_projects: f.addDir ? P.MAX_EXTRA_PROJECTS : 0 };
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
|
|
70
98
|
/** The model aliases Claude Code's own --model help names, in its order; none when the help names none. */
|
|
71
99
|
export function claudeAliases(help) {
|
|
72
100
|
const block = /--model <model>([\s\S]*?)(?=\n\s{2}-|\n\s*\n|$)/.exec(help ?? "")?.[1]?.replace(/\s+/g, " ") ?? "";
|