worktrust 0.11.11 → 0.11.13
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 +62 -0
- package/README.md +37 -10
- package/SECURITY.md +42 -3
- package/cli-colour.mjs +5 -1
- package/cli-look.mjs +1 -0
- package/cli-menu-remote.mjs +8 -3
- package/cli-menu.mjs +15 -9
- package/cli-stop.mjs +158 -0
- package/credential-decoy.mjs +74 -0
- package/credential-store.mjs +24 -0
- package/engine-release.json +1 -1
- package/package-release.json +1 -1
- package/package.json +6 -2
- package/remote-cli.mjs +28 -6
- package/remote-connections.mjs +183 -19
- package/remote-countdown.mjs +5 -1
- package/remote-daemon.mjs +16 -4
- package/remote-desk-sessions.mjs +192 -0
- package/remote-health.mjs +220 -0
- package/remote-pairing.mjs +39 -7
- package/remote-protocol.mjs +317 -18
- package/remote-qr.mjs +48 -17
- package/remote-run.mjs +33 -6
- package/remote-sessions.mjs +2 -2
- package/remote-terminal-sessions.mjs +1 -0
- package/worktrust.mjs +69 -15
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* DECOY CREDENTIALS, A TRIPWIRE (owner, 2026-11-15, B18; the honeywords pattern, Juels & Rivest 2013; SECURITY.md §Decoy
|
|
3
|
+
* credentials). Beside the real coupling in ~/.worktrust this writes credential files in the real file's exact legacy
|
|
4
|
+
* format (base64 of the same JSON: url, a `wt_` token of the real shape, an Ed25519 device key, the dates, the masked
|
|
5
|
+
* account), each with its own fresh random token and key. No legitimate path ever reads or sends one: the CLI, the hook
|
|
6
|
+
* and the MCP bridge read only key.json (credential-store.mjs); scripts/test-cli-decoys.mjs proves no module but this one
|
|
7
|
+
* names a decoy file, and that this module sends only SHA-256 hashes. WorkTrust keeps those hashes per computer under the
|
|
8
|
+
* owner (POST /api/cli/decoys, signed by this computer's own key); a decoy presented at any token door ends every Remote
|
|
9
|
+
* Agent link of the account at once and mails the owner.
|
|
10
|
+
*
|
|
11
|
+
* PROTECTED (the OS keystore seals the real secret: key.json is an envelope that opens nowhere else): FIVE decoys. Every
|
|
12
|
+
* readable credential in the folder is then a decoy, so a copy of the folder holds only decoys and any use trips.
|
|
13
|
+
* FILE MODE (no keystore: the real key must stay a readable file): NINE decoys beside key.json. key.json is the name the
|
|
14
|
+
* open-source CLI reads, so an attacker who reads the code knows which file is real; the decoys catch the copy that is
|
|
15
|
+
* used without reading it (an automated stealer, a careless replay): one of ten files picked blind is a decoy nine
|
|
16
|
+
* times in ten, and trying them all always trips. The keystore mode is the real protection; file mode is detection.
|
|
17
|
+
*
|
|
18
|
+
* Written only after WorkTrust confirmed the hashes, so no decoy exists that would not trip. Never throws, never prints,
|
|
19
|
+
* never asks: a failure leaves the folder as it was and the next `update` tries again.
|
|
20
|
+
*/
|
|
21
|
+
import { createHash, generateKeyPairSync, randomBytes, randomInt } from "node:crypto";
|
|
22
|
+
import { existsSync } from "node:fs";
|
|
23
|
+
import { join } from "node:path";
|
|
24
|
+
import { writePrivateFile } from "./package-integrity.mjs";
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Plausible names in the real file's folder, in the order they are used (five protected, nine in file mode). Each reads as
|
|
28
|
+
* ANOTHER credential, never as a backup of key.json: a name that suggests a restore invites the owner to trip the wire
|
|
29
|
+
* (audit B18 P3c).
|
|
30
|
+
*/
|
|
31
|
+
export const DECOY_NAMES = Object.freeze(["credentials.json", "mcp-key.json", "api-key.json", "token.json", "auth.json", "session-key.json", "bridge-key.json", "access-token.json", "device-key.json"]);
|
|
32
|
+
export const DECOYS_PROTECTED = 5;
|
|
33
|
+
export const DECOYS_FILE_MODE = 9;
|
|
34
|
+
const sha256 = (text) => createHash("sha256").update(text).digest("hex");
|
|
35
|
+
const DAY = 24 * 3600_000;
|
|
36
|
+
|
|
37
|
+
/** One decoy entry, the real entry's shape with every secret its own. */
|
|
38
|
+
function decoyEntry(real, now) {
|
|
39
|
+
const device = generateKeyPairSync("ed25519").privateKey.export({ format: "pem", type: "pkcs8" });
|
|
40
|
+
const renewedAt = new Date(now - randomInt(1, 7 * DAY)).toISOString();
|
|
41
|
+
const coupledAt = new Date(Date.parse(real.coupledAt ?? "") || now - randomInt(30 * DAY, 120 * DAY)).toISOString();
|
|
42
|
+
return { url: real.url, token: `wt_${randomBytes(32).toString("base64url")}`, renewedAt, coupledAt, identified: true, ...(real.profile ? { profile: real.profile } : {}), ...(real.account ? { account: real.account } : {}), ...(real.accountRef ? { accountRef: real.accountRef } : {}), device };
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** Whether this folder already holds decoys (`update` plants once). */
|
|
46
|
+
export const decoysPlanted = (dir) => DECOY_NAMES.some((name) => existsSync(join(dir, name)));
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Make, register and write the decoys. `key` is the real entry (its token and device sign the ONE request, as every CLI
|
|
50
|
+
* door asks); `proof` is the CLI's WorkTrust-Proof builder; `once` skips a folder that already holds decoys. Answers what
|
|
51
|
+
* happened: "planted", "present", "skipped" (no bound key), "refused" or "offline". The decoy tokens leave this function
|
|
52
|
+
* only as files; the network sees their hashes.
|
|
53
|
+
*/
|
|
54
|
+
export async function plantDecoys({ dir, key, protectedMode, proof, agent, once = false, fetchImpl = fetch, now = Date.now() }) {
|
|
55
|
+
try {
|
|
56
|
+
if (!key?.token || !key.device || !key.url) return "skipped";
|
|
57
|
+
if (once && decoysPlanted(dir)) return "present";
|
|
58
|
+
const names = DECOY_NAMES.slice(0, protectedMode ? DECOYS_PROTECTED : DECOYS_FILE_MODE);
|
|
59
|
+
const entries = names.map(() => decoyEntry(key, now));
|
|
60
|
+
// Never the real token (a 2^-256 chance, refused here and by the database all the same).
|
|
61
|
+
if (entries.some((entry) => entry.token === key.token)) return "refused";
|
|
62
|
+
const url = new URL("/api/cli/decoys", key.url).href;
|
|
63
|
+
const body = JSON.stringify({ hashes: entries.map((entry) => sha256(entry.token)) });
|
|
64
|
+
let response;
|
|
65
|
+
try {
|
|
66
|
+
response = await fetchImpl(url, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key.token}`, "user-agent": agent, ...proof(key.device, url, body) }, body, redirect: "error", signal: AbortSignal.timeout(5000) });
|
|
67
|
+
} catch { return "offline"; }
|
|
68
|
+
if (!response.ok || (await response.json().catch(() => null))?.outcome !== "registered") return "refused";
|
|
69
|
+
names.forEach((name, i) => writePrivateFile(join(dir, name), Buffer.from(JSON.stringify(entries[i])).toString("base64")));
|
|
70
|
+
return "planted";
|
|
71
|
+
} catch {
|
|
72
|
+
return "refused";
|
|
73
|
+
}
|
|
74
|
+
}
|
package/credential-store.mjs
CHANGED
|
@@ -98,6 +98,30 @@ export function createCredentialStore(file, vault = nativeKeyStore()) {
|
|
|
98
98
|
};
|
|
99
99
|
}
|
|
100
100
|
|
|
101
|
+
/**
|
|
102
|
+
* THE KEY IN THE OS VAULT BY DEFAULT (0.11.12, owner 2026-11-15: "make protect-key happen automatically when you make the
|
|
103
|
+
* coupling"). The same protect() the command runs, after a new coupling and once at an update. → what happened:
|
|
104
|
+
* "protected" the vault holds the wrapping key, read back once without asking (protect() checks it), the file is sealed
|
|
105
|
+
* "already" it was protected before (a coupling again keeps its sealed slot)
|
|
106
|
+
* "kept" the vault was unavailable or refused: the private 0600 file stays exactly as it was; never a failed coupling
|
|
107
|
+
* "remote" not tried: an SSH session, or Linux without a desktop. There the login keychain or the Secret Service
|
|
108
|
+
* collection can be LOCKED when an AI app later starts the hook, and a read never asks (credential-vault.mjs:
|
|
109
|
+
* no unlock prompt by design), so the hook would stop measuring until someone unlocks it. The file stays.
|
|
110
|
+
* "elsewhere" not tried: this run's HOME is not the OS account's own home (a test harness, a sandbox). The vault is the
|
|
111
|
+
* account's, whatever HOME says (macOS reads it as the OS user, credential-vault.mjs), so a key file in
|
|
112
|
+
* another folder would leave an item in the person's own vault that nothing there needs. Found 2026-11-15:
|
|
113
|
+
* the CLI's regression suite, coupling synthetic homes, wrote 22 such items into the login keychain.
|
|
114
|
+
* A read never raises a prompt: macOS reads go through /usr/bin/osascript with user interaction turned off, the one client
|
|
115
|
+
* that created the item (its default access list), whatever node, npx cache or CLI version asks; Linux `secret-tool search`
|
|
116
|
+
* never unlocks; Windows Credential Manager has no prompt. So the move cannot flood anyone with questions.
|
|
117
|
+
*/
|
|
118
|
+
export function protectByDefault(store, { remote = false, elsewhere = false } = {}) {
|
|
119
|
+
try { if (store.protected()) return "already"; } catch { return "kept"; }
|
|
120
|
+
if (elsewhere) return "elsewhere";
|
|
121
|
+
if (remote) return "remote";
|
|
122
|
+
try { store.protect(); return "protected"; } catch { return "kept"; }
|
|
123
|
+
}
|
|
124
|
+
|
|
101
125
|
/** Archive signing shares the coupling store; an unavailable vault is not an absent device. */
|
|
102
126
|
export function readDeviceSigningKey(file) {
|
|
103
127
|
const entry = createCredentialStore(file).load();
|
package/engine-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"9736ab0801b3889967134a916680acb9dc3d614db6fd221be9c5ae7079d9d173","cli-look.mjs":"1c8eea30fa57dbdbf260e5e45f017a9ca85c77bd511569f931bfd80c8cdb648a","cli-menu-remote.mjs":"eb7a9ada12cf566f668cbcf1f248412c1812b45d0f8845108facbd5f27dfc7a0","cli-menu.mjs":"f6eb43e71c8c941c79736f5073c393d3a349077a2a21af5cd75687b24731178b","cli-stop.mjs":"34f63fb7d27723d52650475582c3b8d36aa57e37457ebf55ab24449743df9847","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-decoy.mjs":"8b9a264a3739fb9f58f8b9102b93a14292962689c8557ff7fad332dcfac3f7d9","credential-store.mjs":"8a83e7086fadaba31b0923101851d348d67cf3c87610f6d3e73a774f64435392","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"171f4abb0d603d58446129e007de9e9dc0f707bde33b1b4481a134376ed301c8","node-guide.mjs":"5bf52c5028b07a80ec4d41be365eb025dfce74328f41f928a26ce6737b1f9cc4","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"d0558bb123a29a934db1bf8162e7c3f37e8ccde4c502178d47e9b4cbb3a0491b","remote-adapter-codex.mjs":"0370611044e6f5f6ef3ca370e0f6ef237468f01ecc890b019da8167730eb75eb","remote-adapter-opencode.mjs":"062c571cc4ab972412044066c236a9f20794cfb841c66cc9c0e9e5ec1133699e","remote-adapter-terminal.mjs":"c047a362474abb90b7968b8a624358af40a989ad137166a03bc955409ff1dc82","remote-admin.mjs":"ac4d434c0a374159b27accac3fdd0324ff96ffe32227fba054cc62d00e58d35b","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"63847226e398f9eb5b8d3989ba2b2436fbedd898385eb5f2f63bbdf07fbe6852","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"b047d324265921ae280bfa4907165e8e0dc8709e6d270e0bea3b788113920f5a","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"099963cfa6c53bca62a18a266be847f7da4ed8fe611eb9b052b575f5f6d5f0bc","remote-countdown.mjs":"b1020c59fcae3cbf6c355976b2a5ef80a3476ffadcd9949e8e884bedfd1efa06","remote-daemon.mjs":"e2e05064271800b6790d474c15f72aa65c0a99131ecf2c43fd075d5dbbb6c933","remote-desk-sessions.mjs":"3a342e525fdf43ba54b40576f84a2399baa0c03c54f9184bfc153242fb50e4a3","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-health.mjs":"0f37d08f97fc6e08c69792cf3d22201b3103a28bdb19613b5abb02b80eb91983","remote-inventory.mjs":"98a65a066772ef183f405a1455c02db6827f06e80ed601796c65c19f9be10f09","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"b27625cc3b5313091252bc8ae907b4b969b96be0fe8c2ee3e9000c767ea60175","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"16ea015ad5de3c357bce730ea8ea98571dc981d8591fb5156b1941b2c557a381","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"ec8c530ad3e880bca21a4d4078ecd68b6aaafcc442b50087127868d952034d5f","remote-protocol.mjs":"53a83b8842139b492504fd29435d51fb4da6e143e9ff326b89ec821f70b1316c","remote-qr.mjs":"a0f4044f0afe8a636be14cf5afe10f53404b57262c23fea37f8cf30b6d0a5220","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"7bdb3aa1327dd64ce79bd3038ad844ba32ccf9c82eb436116f437d3a48e4e871","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"a3a5502e0f6f43b04e37ee778f43d88f4c219776439cfed0d8fa0b511e0c9637","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"b4028b4247245013e9c2e4451f8dbb0ebff531066b78a4ea62499985464a4c43","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"593447f3b7abbf3b91237d6d8a1aebcce9fbddc5ea5874341241ee45d83e5196","remote-store.mjs":"592a87f0ab8f53cc8eee1318a309310e27cb01d4549caebad6d51c3fad1b75ac","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"51b8140d46962eb035ff4ae60e5afea3c83244ea824412ca20e74a8318bbc3a5","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","session-readers.mjs":"14cbd2c92d87511b396feaa54710f00d5e3929b55e01dc559f39c5def13777a2","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"3dfdd9d2189063f24dbd5c2abec6bb21e2bb36f22b89d0d84282e12216022670","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"717455cda6a4a7b598ae834408a954a0c5716a527ffbfb581fdf861a7c867477"},"format":"worktrust-package/1","kind":"engine","version":"0.11.13"},"signature":"3yH78qR7IKPwaG4_cS8c9qZ8doIYoxE_RdMp5_w6K3SoCvHI4ytZ1QFllb-DAjXcFlQwxfQnn58h16fC9nTFCw"}
|
package/package-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CHANGELOG.md":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CHANGELOG.md":"edbd976af2ed18928b63bcbd2265e51b9d54a29bcff71b1abedecfa77e55bd94","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"eb210c9cab5dbb6a2c293a003a7604e7fb6e5f7b95ab22b382171dc7adeed41a","README.md":"95043d00907ab3debfb0525f050d3f621cd42625434217694d3db83dfaaefeea","SECURITY.md":"9fe29600eca56b992d1a22bbdd62a7f1bf60210884d244a2c37165e0c327dd27","chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-colour.mjs":"9736ab0801b3889967134a916680acb9dc3d614db6fd221be9c5ae7079d9d173","cli-look.mjs":"1c8eea30fa57dbdbf260e5e45f017a9ca85c77bd511569f931bfd80c8cdb648a","cli-menu-remote.mjs":"eb7a9ada12cf566f668cbcf1f248412c1812b45d0f8845108facbd5f27dfc7a0","cli-menu.mjs":"f6eb43e71c8c941c79736f5073c393d3a349077a2a21af5cd75687b24731178b","cli-stop.mjs":"34f63fb7d27723d52650475582c3b8d36aa57e37457ebf55ab24449743df9847","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-decoy.mjs":"8b9a264a3739fb9f58f8b9102b93a14292962689c8557ff7fad332dcfac3f7d9","credential-store.mjs":"8a83e7086fadaba31b0923101851d348d67cf3c87610f6d3e73a774f64435392","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"04ba620d1480f94659da3e57aa8b44197098128255c5c8dc32c7eb1a95683cbb","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"171f4abb0d603d58446129e007de9e9dc0f707bde33b1b4481a134376ed301c8","node-guide.mjs":"5bf52c5028b07a80ec4d41be365eb025dfce74328f41f928a26ce6737b1f9cc4","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"79e3f0de638203aa2a227b14483c1e9d828be24d0043b2b84faa499009024bf6","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"d0558bb123a29a934db1bf8162e7c3f37e8ccde4c502178d47e9b4cbb3a0491b","remote-adapter-codex.mjs":"0370611044e6f5f6ef3ca370e0f6ef237468f01ecc890b019da8167730eb75eb","remote-adapter-opencode.mjs":"062c571cc4ab972412044066c236a9f20794cfb841c66cc9c0e9e5ec1133699e","remote-adapter-terminal.mjs":"c047a362474abb90b7968b8a624358af40a989ad137166a03bc955409ff1dc82","remote-admin.mjs":"ac4d434c0a374159b27accac3fdd0324ff96ffe32227fba054cc62d00e58d35b","remote-agent-switch.mjs":"7ff5448f29f05a47d7298d730b21243a1bcf8a215b434a0c7fbf5f3cb0889041","remote-approval-bridge.mjs":"092f17b7969e4f35bea064315d04dcde1faa6a3fd3e737dcc05aece82c7a37c4","remote-approvals.mjs":"63847226e398f9eb5b8d3989ba2b2436fbedd898385eb5f2f63bbdf07fbe6852","remote-attachments.mjs":"2e9c1277329a45cf26c0c62abda632cf0ab9fad78d0504416ecee9805220e16c","remote-cdp.mjs":"70e333a1ebe845e872cc3a703a0a507391f8ce59640bdbd662bdad55eeff216b","remote-changes.mjs":"2141fece4961a5bc1bb1b046f78222812617457b1ba6452275eac6a897e62e19","remote-claude-events.mjs":"58822471203c6a1b66cf81c115c4d713657c3dea5c7b98df959f894ee5b2e704","remote-claude-progress.mjs":"2ca626d3dbc16d8d570abe1df6477b7e44ffb43c1d9145228ec5ea1928e415ca","remote-cli.mjs":"b047d324265921ae280bfa4907165e8e0dc8709e6d270e0bea3b788113920f5a","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"099963cfa6c53bca62a18a266be847f7da4ed8fe611eb9b052b575f5f6d5f0bc","remote-countdown.mjs":"b1020c59fcae3cbf6c355976b2a5ef80a3476ffadcd9949e8e884bedfd1efa06","remote-daemon.mjs":"e2e05064271800b6790d474c15f72aa65c0a99131ecf2c43fd075d5dbbb6c933","remote-desk-sessions.mjs":"3a342e525fdf43ba54b40576f84a2399baa0c03c54f9184bfc153242fb50e4a3","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-health.mjs":"0f37d08f97fc6e08c69792cf3d22201b3103a28bdb19613b5abb02b80eb91983","remote-inventory.mjs":"98a65a066772ef183f405a1455c02db6827f06e80ed601796c65c19f9be10f09","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"b27625cc3b5313091252bc8ae907b4b969b96be0fe8c2ee3e9000c767ea60175","remote-pipeline-config.mjs":"00cde6a61ce21144c51ac56fce42fee159aa9dba6586218a7ea790ce4a6bd40b","remote-pipeline-parsers.mjs":"43ca0d332d7bc883c4759a754a555815ae5dfe133446b91ba9f2e48a350fa20f","remote-pipeline.mjs":"b856ead989b29ddb618ef69bbacd104bae2b02c9d1c5214291d08ce469a8b24e","remote-policy.mjs":"16ea015ad5de3c357bce730ea8ea98571dc981d8591fb5156b1941b2c557a381","remote-preview.mjs":"fe504ad6f83dcb4a4ebdcc018686a9a5a900c47cdf8c45b75e7d02e2f3056155","remote-projects.mjs":"ec8c530ad3e880bca21a4d4078ecd68b6aaafcc442b50087127868d952034d5f","remote-protocol.mjs":"53a83b8842139b492504fd29435d51fb4da6e143e9ff326b89ec821f70b1316c","remote-qr.mjs":"a0f4044f0afe8a636be14cf5afe10f53404b57262c23fea37f8cf30b6d0a5220","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"7bdb3aa1327dd64ce79bd3038ad844ba32ccf9c82eb436116f437d3a48e4e871","remote-screen-approvals.mjs":"c43ab286d36a38d17639d155782ffa017f1a9b6806a09b82ed0142a1290b6000","remote-screen-push.mjs":"4ee8bd48d24b2c87581e9f33d8354a86381f7febd82f89ed509a7a87c1442608","remote-screen-states.mjs":"7c3c86a584bebf52461f3cab39c05ea2a13910061704d48fc622956e842940f7","remote-service.mjs":"a3a5502e0f6f43b04e37ee778f43d88f4c219776439cfed0d8fa0b511e0c9637","remote-session-list.mjs":"494fdbe20f0542806ac6c42ad149c52e2d3ace23a3a7567f96dc7e80d092c727","remote-sessions.mjs":"b4028b4247245013e9c2e4451f8dbb0ebff531066b78a4ea62499985464a4c43","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"593447f3b7abbf3b91237d6d8a1aebcce9fbddc5ea5874341241ee45d83e5196","remote-store.mjs":"592a87f0ab8f53cc8eee1318a309310e27cb01d4549caebad6d51c3fad1b75ac","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"51b8140d46962eb035ff4ae60e5afea3c83244ea824412ca20e74a8318bbc3a5","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","session-readers.mjs":"14cbd2c92d87511b396feaa54710f00d5e3929b55e01dc559f39c5def13777a2","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"3dfdd9d2189063f24dbd5c2abec6bb21e2bb36f22b89d0d84282e12216022670","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"717455cda6a4a7b598ae834408a954a0c5716a527ffbfb581fdf861a7c867477"},"format":"worktrust-package/1","kind":"npm","version":"0.11.13"},"signature":"s_B96oTxz8bpZwkwUYjS_8GVcievlUjKDY8TvKTiO9ksFmZsNU6XZjuMyKj54amdqQWz2KlTenthwOGHuREQCQ"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktrust",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.13",
|
|
4
4
|
"description": "Couple this computer to WorkTrust: approve a code in your browser, and every AI app here reports what you built. Metadata only, no dependencies.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -43,6 +43,7 @@
|
|
|
43
43
|
"package-release.json",
|
|
44
44
|
"history-outbox.mjs",
|
|
45
45
|
"credential-store.mjs",
|
|
46
|
+
"credential-decoy.mjs",
|
|
46
47
|
"credential-vault.mjs",
|
|
47
48
|
"credential-vault-scripts.mjs",
|
|
48
49
|
"self-update.mjs",
|
|
@@ -83,6 +84,7 @@
|
|
|
83
84
|
"remote-approvals.mjs",
|
|
84
85
|
"remote-sessions.mjs",
|
|
85
86
|
"remote-session-list.mjs",
|
|
87
|
+
"remote-desk-sessions.mjs",
|
|
86
88
|
"remote-changes.mjs",
|
|
87
89
|
"remote-endorse.mjs",
|
|
88
90
|
"remote-daemon.mjs",
|
|
@@ -98,11 +100,13 @@
|
|
|
98
100
|
"cli-menu.mjs",
|
|
99
101
|
"cli-menu-remote.mjs",
|
|
100
102
|
"cli-colour.mjs",
|
|
103
|
+
"cli-stop.mjs",
|
|
101
104
|
"cli-look.mjs",
|
|
102
105
|
"node-guide.mjs",
|
|
103
106
|
"remote-countdown.mjs",
|
|
104
107
|
"remote-connections.mjs",
|
|
105
|
-
"remote-admin.mjs"
|
|
108
|
+
"remote-admin.mjs",
|
|
109
|
+
"remote-health.mjs"
|
|
106
110
|
],
|
|
107
111
|
"engines": {
|
|
108
112
|
"node": ">=18"
|
package/remote-cli.mjs
CHANGED
|
@@ -45,10 +45,11 @@ import { ensureRemoteDir, gatewayOf, isLoopbackGateway, issuerKeys, PRODUCTION_G
|
|
|
45
45
|
import { canonicalProject } from "./remote-policy.mjs";
|
|
46
46
|
import { IssuerMissing, PairingDenied, PairingExpired, PairingRefused, compactForQr, oneScan, oneScanInvite, pairComputer } from "./remote-pairing.mjs";
|
|
47
47
|
import { startCountdown, waitKey } from "./remote-countdown.mjs";
|
|
48
|
-
import { askLine, connectionsCommand, disconnectCommand, linkPhone, removePhones } from "./remote-connections.mjs";
|
|
48
|
+
import { accessCommand, askLine, connectionsCommand, disconnectCommand, linkedSummary, linkPhone, reachStep, removePhones, withName } from "./remote-connections.mjs";
|
|
49
49
|
import { installService, removeService, serviceState, servicePlatform } from "./remote-service.mjs";
|
|
50
50
|
import { terminalQr } from "./remote-qr.mjs";
|
|
51
51
|
import { webSocketAvailable } from "./remote-transport.mjs";
|
|
52
|
+
import { healthLine, keptHealth } from "./remote-health.mjs";
|
|
52
53
|
import { guideToNode, remoteStopsHere } from "./node-guide.mjs";
|
|
53
54
|
import { inventory } from "./remote-inventory.mjs";
|
|
54
55
|
import { allowCommand, parsePipelineConfig, PIPELINE_FILE } from "./remote-pipeline-config.mjs";
|
|
@@ -130,11 +131,30 @@ async function approve(io, road) {
|
|
|
130
131
|
const service = installService({ program: [runtime.node, ...runtime.nodeArgs, runtime.entry, "remote", "run"], path: process.env.PATH ?? "" });
|
|
131
132
|
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.`);
|
|
132
133
|
if (service.started) io.say(" ✓ This computer is connected to Remote Agent.");
|
|
133
|
-
if (!io.has("no-pair")) await
|
|
134
|
+
if (!io.has("no-pair")) await linkAndGrant(io, ready);
|
|
134
135
|
}
|
|
135
136
|
|
|
136
|
-
/**
|
|
137
|
-
|
|
137
|
+
/**
|
|
138
|
+
* THE SCAN, THEN THE PHONE AND ITS REACH (0.11.12, remote-connections.mjs accessStep): the summary the moment the daemon confirmed the
|
|
139
|
+
* phone, then the access step through the keyboard's one door (applySettingsChange, the macOS folder question after it), so
|
|
140
|
+
* it ends exactly where Remote Agent › Roots or › Projects would. A refused folder is said and the others still go.
|
|
141
|
+
*/
|
|
142
|
+
async function linkAndGrant(io, ready = null) {
|
|
143
|
+
const phone = await linkPhone(io, ready);
|
|
144
|
+
if (!phone) return;
|
|
145
|
+
for (const line of linkedSummary(await withName(phone))) io.say(line);
|
|
146
|
+
await reachStep(io, keyboardApply(io));
|
|
147
|
+
}
|
|
148
|
+
/** The keyboard's one door for the access step: applySettingsChange, then the macOS folder question; a refusal is said, not fatal. */
|
|
149
|
+
const keyboardApply = (io) => async (change) => {
|
|
150
|
+
const done = applySettingsChange(change, { kind: "keyboard" });
|
|
151
|
+
if (!done.ok) return io.say(` ! ${done.reason}`);
|
|
152
|
+
io.say(` ✓ ${done.message}`);
|
|
153
|
+
if (done.paths && !io.has("no-folder-check")) await askMacFolderAccess(io, done.paths);
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
/** `remote pair`: a new QR for a phone (remote-connections.mjs `linkPhone`, which also ends `remote app`), then its reach. */
|
|
157
|
+
const pair = (io) => linkAndGrant(io);
|
|
138
158
|
|
|
139
159
|
async function phones(io, rest) {
|
|
140
160
|
const list = loadPhones();
|
|
@@ -263,9 +283,10 @@ function status(io) {
|
|
|
263
283
|
const agents = inventory({ env: { ...process.env, PATH: settings.agent_path ?? process.env.PATH } }).reports.filter((r) => r.installed);
|
|
264
284
|
const summary = { enabled: settings.enabled, paused: settings.paused, paired: Boolean(identity), device_id: identity?.device_id ?? null, fingerprint: keys ? fingerprintOf(keys) : null,
|
|
265
285
|
gateway: gatewayOf(settings), gateway_default: settings.gateway === null || settings.gateway === undefined, 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,
|
|
266
|
-
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) };
|
|
286
|
+
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), health: keptHealth() };
|
|
267
287
|
if (io.has("json")) { io.say(JSON.stringify(summary, null, 2)); return; }
|
|
268
288
|
io.say(` Remote: ${settings.enabled ? (settings.paused ? `paused (${settings.paused === "desk" ? "here" : "from a phone"})` : "on") : "off"}`);
|
|
289
|
+
io.say(healthLine(summary.health)); // the remote service's newest sample, a minute old at most (remote-health.mjs)
|
|
269
290
|
io.say(` Paired: ${identity ? `${identity.device_id} · key ${summary.fingerprint}` : "no"}`);
|
|
270
291
|
io.say(` Gateway: ${summary.gateway === PRODUCTION_GATEWAY ? `${new URL(PRODUCTION_GATEWAY).host} (WorkTrust's)` : `${summary.gateway}${isLoopbackGateway(summary.gateway) ? " (this computer: dev relay)" : " (chosen here)"}`}`);
|
|
271
292
|
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"}`}`);
|
|
@@ -280,6 +301,7 @@ export async function remoteCommand(args, io) {
|
|
|
280
301
|
if (remoteStopsHere(sub)) return guideToNode(io, ["remote", ...args], { connected: io.connected?.() }); // Node before 22.4: node-guide.mjs
|
|
281
302
|
if (sub === "app" || sub === "web") return approve(io, sub);
|
|
282
303
|
if (sub === "pair") return pair(io);
|
|
304
|
+
if (sub === "access") { needPaired(io); return accessCommand(io, keyboardApply(io)); } // 0.11.12: a linked phone's reach, chosen later
|
|
283
305
|
if (sub === "status") return status(io);
|
|
284
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; }
|
|
285
307
|
if (sub === "disable") {
|
|
@@ -324,5 +346,5 @@ export async function remoteCommand(args, io) {
|
|
|
324
346
|
if (sub === "terminal") return (await import("./remote-terminal-cli.mjs")).terminalCommand(io, rest, askTyped);
|
|
325
347
|
if (sub === "attach") return (await import("./remote-terminal-cli.mjs")).attachCommand(io, rest);
|
|
326
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; }
|
|
327
|
-
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>]");
|
|
349
|
+
io.say(" npx worktrust remote app | web | pair | access | 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>]");
|
|
328
350
|
}
|
package/remote-connections.mjs
CHANGED
|
@@ -10,11 +10,17 @@
|
|
|
10
10
|
* The computer knows a phone by its keys only: the "name" is its kind and the start of its fingerprint ("Phone 9M8N"),
|
|
11
11
|
* never a model name it was not told.
|
|
12
12
|
*/
|
|
13
|
+
import { readdirSync, statSync } from "node:fs";
|
|
14
|
+
import { homedir } from "node:os";
|
|
15
|
+
import { join, sep } from "node:path";
|
|
13
16
|
import { createInterface } from "node:readline/promises";
|
|
14
|
-
import { gatewayOf, loadIdentity, loadKeys, loadPhones, loadSettings, random, removeFile, savePhones, writeJson } from "./remote-store.mjs";
|
|
17
|
+
import { gatewayOf, loadIdentity, loadKeys, loadPhones, loadProjects, loadRoots, loadSettings, random, removeFile, savePhones, writeJson } from "./remote-store.mjs";
|
|
15
18
|
import * as P from "./remote-protocol.mjs";
|
|
16
19
|
import { terminalQr } from "./remote-qr.mjs";
|
|
17
|
-
import {
|
|
20
|
+
import { pairingQrText, seededInvite } from "./remote-pairing.mjs";
|
|
21
|
+
import { watchKeys } from "./cli-stop.mjs";
|
|
22
|
+
import { startCountdown } from "./remote-countdown.mjs";
|
|
23
|
+
import { suggestedFolders } from "./folder-picker.mjs";
|
|
18
24
|
|
|
19
25
|
const KEEP_REMOVED = 20;
|
|
20
26
|
const when = (ms) => (Number.isFinite(ms) ? new Date(ms).toISOString().slice(0, 16).replace("T", " ") : "never");
|
|
@@ -98,48 +104,206 @@ const pretty = (code) => `${code.slice(0, 4)}-${code.slice(4)}`;
|
|
|
98
104
|
|
|
99
105
|
/**
|
|
100
106
|
* LINK A PHONE (`remote pair`, and the end of `remote app`; moved here from remote-cli.mjs in 0.11.10). Without `ready`: a new
|
|
101
|
-
* invite (
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
*
|
|
107
|
+
* invite (ten minutes, one phone, once), its QR and the typed code, as before. With `ready` (the one-scan invite `remote app`
|
|
108
|
+
* wrote once the issuer named this computer, remote-pairing.mjs `oneScanInvite`): no second QR while the phone that scanned
|
|
109
|
+
* the first one links by itself; after `waitMs`, or for a phone that opened the code with the camera or runs an older app,
|
|
110
|
+
* the SAME invite as the pairing QR, with one line why. A phone that proves the secret is confirmed by the daemon
|
|
105
111
|
* (PROTOCOL.md §Pairing); a phone that asked by the typed code waits for `remote phones confirm` at this keyboard.
|
|
112
|
+
*
|
|
113
|
+
* 0.11.12 (owner, 2026-11-15): the QR is the compact code for WorkTrust's relay (remote-pairing.mjs pairingQrText), with an
|
|
114
|
+
* empty line above and below it; ten minutes instead of five, drained by the countdown under it (remote-countdown.mjs: one
|
|
115
|
+
* line rewritten in place on a terminal, the expiry said once without one; no colour). The printed link carried the pairing
|
|
116
|
+
* secret into the scrollback; it is printed only with --show-link (`showLink`), as `remote app` does since 0.11.10.
|
|
117
|
+
* → the phone the daemon confirmed by the QR, or null.
|
|
106
118
|
*/
|
|
107
|
-
export async function linkPhone(io, ready = null, { waitMs = ONE_SCAN_WAIT_MS, now = Date.now, tick = 1000 } = {}) {
|
|
119
|
+
export async function linkPhone(io, ready = null, { waitMs = ONE_SCAN_WAIT_MS, now = Date.now, tick = 1000, countdown = startCountdown, showLink = Boolean(io.has?.("show-link")) } = {}) {
|
|
108
120
|
const keys = loadKeys(), identity = loadIdentity(), settings = loadSettings();
|
|
109
121
|
if (!keys || !identity) io.fail("this computer is not paired for remote yet: run `npx worktrust remote app` (or `remote web`)");
|
|
110
122
|
// Off is its own state (owner, 2026-11-14): a missing gateway no longer exists, WorkTrust's is the default (gatewayOf).
|
|
111
123
|
if (!settings.enabled) io.fail("remote is off on this computer: run `npx worktrust remote app` (or `remote web`)");
|
|
112
124
|
const started = now();
|
|
113
|
-
const invite = ready ?? { ...
|
|
125
|
+
const invite = ready ?? { ...seededInvite({ gateway: gatewayOf(settings), deviceId: identity.device_id, publicKeys: keys.public, nowMs: started, random }), code: P.generatePairingCode(random), used: false, created_at: started };
|
|
114
126
|
if (!ready) writeJson("invite.json", invite);
|
|
115
|
-
const { code,
|
|
116
|
-
const
|
|
117
|
-
let shown = false;
|
|
127
|
+
const { code, created_at: since } = invite;
|
|
128
|
+
const until = invite.e * 1000;
|
|
129
|
+
let shown = false, bar = null;
|
|
130
|
+
const settle = (line) => { bar?.stop(line); bar = null; };
|
|
118
131
|
const show = (why) => {
|
|
119
132
|
shown = true;
|
|
120
133
|
io.say();
|
|
121
134
|
io.say(why ?? " Scan this with the WorkTrust app (or the phone's camera):");
|
|
122
|
-
io.say(
|
|
123
|
-
io.say(
|
|
135
|
+
io.say();
|
|
136
|
+
io.say(terminalQr(pairingQrText(invite), { color: Boolean(process.stdout.isTTY) && !process.env.NO_COLOR }));
|
|
137
|
+
io.say();
|
|
138
|
+
if (showLink) io.say(` Link: ${pairingQrText(invite)}`);
|
|
124
139
|
io.say(` No camera? Type this code in the app: ${pretty(code)} (then confirm the phone here with \`npx worktrust remote phones\`)`);
|
|
125
|
-
io.say(" The code and the QR work once, for
|
|
140
|
+
io.say(" The code and the QR work once, for ten minutes. Ctrl+C cancels.");
|
|
141
|
+
bar = countdown?.({ expiresAt: until, windowMs: Math.max(1, until - since) }) ?? null;
|
|
126
142
|
};
|
|
127
143
|
if (ready) io.say(" Linking the phone that scanned the code …"); else show();
|
|
128
|
-
const cancel = () => { removeFile("invite.json"); process.exit(130); };
|
|
144
|
+
const cancel = () => { settle(); removeFile("invite.json"); process.exit(130); };
|
|
129
145
|
process.once("SIGINT", cancel);
|
|
130
146
|
const before = new Set(loadPhones().pending.map((p) => p.fingerprint));
|
|
147
|
+
const release = watchKeys(); // 0.11.12: in a command the menu started, Esc cancels the wait like Ctrl+C (cli-stop.mjs)
|
|
131
148
|
try {
|
|
132
|
-
while (now() <
|
|
149
|
+
while (now() < until) {
|
|
133
150
|
await new Promise((resolve) => setTimeout(resolve, tick));
|
|
134
151
|
const phones = loadPhones();
|
|
135
152
|
const paired = phones.confirmed.find((p) => p.how === "qr" && p.confirmed_at >= since);
|
|
136
|
-
if (paired) {
|
|
153
|
+
if (paired) { settle(); return paired; }
|
|
137
154
|
const asked = phones.pending.find((p) => !before.has(p.fingerprint));
|
|
138
|
-
if (asked) { io.say(` A phone asked by code (${asked.fingerprint}). Confirm it at this keyboard: npx worktrust remote phones confirm ${asked.fingerprint}`); return null; }
|
|
155
|
+
if (asked) { settle(); io.say(` A phone asked by code (${asked.fingerprint}). Confirm it at this keyboard: npx worktrust remote phones confirm ${asked.fingerprint}`); return null; }
|
|
139
156
|
if (!shown && now() - started >= waitMs) show(" No phone linked by itself (the code was opened with the camera, or the app is older): scan this in the WorkTrust app.");
|
|
140
157
|
}
|
|
141
|
-
} finally { process.off("SIGINT", cancel); }
|
|
158
|
+
} finally { settle(); process.off("SIGINT", cancel); release(); }
|
|
142
159
|
removeFile("invite.json");
|
|
143
160
|
io.say(" The pairing code expired. Run `npx worktrust remote pair` for a new one.");
|
|
144
161
|
return null;
|
|
145
162
|
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* WHEN A PHONE HAS LINKED (CLI 0.11.12, owner 2026-11-15: "when the phone has linked, the CLI says so at once"). The wait
|
|
166
|
+
* for the scan (linkPhone above) ends with a summary of the phone the daemon just confirmed, and goes
|
|
167
|
+
* straight on to what that phone may reach on this computer:
|
|
168
|
+
*
|
|
169
|
+
* ✓ Phone linked
|
|
170
|
+
* Device id dev_… · ABCD-EFGH-JKMN-PQRS
|
|
171
|
+
* Type iPhone
|
|
172
|
+
*
|
|
173
|
+
* The type is the phone's own name for its kind ("iPhone", "iPad", "Pixel 9", "Browser on macOS"), sent sealed with its first
|
|
174
|
+
* inventory ask (remote-daemon.mjs rememberName); it is waited for a few seconds, and said as "phone" when it did not come.
|
|
175
|
+
* The computer never guesses a model it was not told.
|
|
176
|
+
*
|
|
177
|
+
* THE ACCESS STEP USES THE GRANTS THAT EXIST, nothing new: this computer's ROOTS (folders whose projects a phone may open and
|
|
178
|
+
* add to) and PROJECTS (single folders), the same lists Remote Agent › Roots and › Projects change, through the same door
|
|
179
|
+
* (remote-settings.mjs applySettingsChange, handed in as `apply`, which also asks macOS for a guarded folder). Grants belong
|
|
180
|
+
* to this computer, not to one phone, as they always did; the step ends in exactly the state the menu leaves.
|
|
181
|
+
* Allow all project folders every suggested folder that exists here (~/Desktop, ~/Projects, ~/code …) as a root. "All
|
|
182
|
+
* files" is not offered: the root rule refuses the home folder and anything above it, and
|
|
183
|
+
* folders of secrets, by design (remote-policy.mjs canonicalProject).
|
|
184
|
+
* Choose projects a multi-select of the git projects this computer already knows (directly inside a suggested
|
|
185
|
+
* folder or a root, newest first), each granted as a project.
|
|
186
|
+
* Later nothing changes; the commands are named.
|
|
187
|
+
* Without a terminal, or with --yes, nothing is asked: the commands are named.
|
|
188
|
+
*/
|
|
189
|
+
/** How long the summary waits for the phone's own name (its first inventory ask follows the welcome at once). */
|
|
190
|
+
export const NAME_WAIT_MS = 4_000;
|
|
191
|
+
/** At most this many projects are offered (the inventory's own limit). */
|
|
192
|
+
export const MAX_OFFERED = 30;
|
|
193
|
+
const tildePath = (path) => (path === homedir() || path.startsWith(homedir() + sep) ? `~${path.slice(homedir().length)}` : path);
|
|
194
|
+
|
|
195
|
+
/** The phone's type in words: its own name when it sent one, else its kind. */
|
|
196
|
+
export const phoneType = (phone) => (typeof phone?.name === "string" && phone.name.trim() ? phone.name.trim().slice(0, 64) : phone?.how === "endorsed" || phone?.kind === "browser" ? "browser" : "phone");
|
|
197
|
+
|
|
198
|
+
/** The summary's lines. Pure. */
|
|
199
|
+
export function linkedSummary(phone) {
|
|
200
|
+
return [" ✓ Phone linked", ` Device id ${phone.device_id} · ${phone.fingerprint}`, ` Type ${phoneType(phone)}`];
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
/** The phone's record again once it carries its name, or as it is after `waitMs`. */
|
|
204
|
+
export async function withName(phone, { waitMs = NAME_WAIT_MS, tick = 250, now = Date.now } = {}) {
|
|
205
|
+
const until = now() + waitMs;
|
|
206
|
+
for (;;) {
|
|
207
|
+
const found = loadPhones().confirmed.find((p) => p.device_id === phone.device_id) ?? phone;
|
|
208
|
+
if (found.name || now() >= until) return found;
|
|
209
|
+
await new Promise((resolve) => setTimeout(resolve, tick));
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
/** The git projects directly inside the suggested folders and the roots, not granted yet, newest first. */
|
|
214
|
+
export function knownProjects({ home = homedir(), roots = loadRoots(), granted = loadProjects() } = {}) {
|
|
215
|
+
const have = new Set(granted.map((p) => p.path)), seen = new Set(), out = [];
|
|
216
|
+
for (const dir of [...suggestedFolders(home).map((f) => f.path), ...roots.map((r) => r.path)]) {
|
|
217
|
+
let entries = [];
|
|
218
|
+
try { entries = readdirSync(dir, { withFileTypes: true }).slice(0, 2000); } catch { continue; }
|
|
219
|
+
for (const d of entries) {
|
|
220
|
+
if (d.name.startsWith(".") || !d.isDirectory()) continue;
|
|
221
|
+
const path = join(dir, d.name);
|
|
222
|
+
if (seen.has(path) || have.has(path)) continue;
|
|
223
|
+
try { statSync(join(path, ".git")); } catch { continue; }
|
|
224
|
+
seen.add(path);
|
|
225
|
+
let at = 0;
|
|
226
|
+
try { at = statSync(path).mtimeMs; } catch { /* unread: last */ }
|
|
227
|
+
out.push({ path, at });
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return out.sort((a, b) => b.at - a.at).slice(0, MAX_OFFERED).map((p) => p.path);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** The step's three rows (pure, for the menu's own list, cli-menu.mjs choose). */
|
|
234
|
+
export function accessItems(folders) {
|
|
235
|
+
return [
|
|
236
|
+
{ label: "Allow all project folders", hint: "npx worktrust remote roots add <folder>", info: folders.length ? `Adds ${folders.map(tildePath).join(", ")} as roots.` : "No usual project folder exists here: choose projects.", value: "all", ...(folders.length ? {} : { disabled: true, quiet: "No usual project folder here." }) },
|
|
237
|
+
{ label: "Choose projects ›", hint: "npx worktrust remote projects add <folder>", info: "Tick the projects this phone may steer an agent in.", value: "choose" },
|
|
238
|
+
{ label: "Later", hint: "npx worktrust remote roots", info: "Grant nothing now. The menu's Remote Agent › Roots does it later.", value: "later" },
|
|
239
|
+
];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
const LATER = [" A phone may steer agents only in folders you grant here:", " npx worktrust remote roots add <folder> a folder whose projects it may open", " npx worktrust remote projects add <folder> one project folder"];
|
|
243
|
+
|
|
244
|
+
/**
|
|
245
|
+
* The access step. `apply(change)` is the keyboard's one door (remote-cli.mjs settingsChange); `term` a menu terminal
|
|
246
|
+
* (cli-menu.mjs createTerminal) and `choose` its list; `interactive` false names the commands and asks nothing.
|
|
247
|
+
* → "all" | "chosen" | "later".
|
|
248
|
+
*/
|
|
249
|
+
export async function accessStep(io, { apply, interactive, term = null, choose = null, folders = suggestedFolders().map((f) => f.path), projects = null }) {
|
|
250
|
+
if (!interactive || !term || !choose) { for (const line of LATER) io.say(line); return "later"; }
|
|
251
|
+
io.say();
|
|
252
|
+
term.enter();
|
|
253
|
+
try {
|
|
254
|
+
const picked = await choose(term, { title: "What may this phone reach on this computer?", items: accessItems(folders) });
|
|
255
|
+
if (picked === "quit" || picked === "back" || picked.item.value === "later") { term.erase(); for (const line of LATER) io.say(line); return "later"; }
|
|
256
|
+
if (picked.item.value === "all") {
|
|
257
|
+
term.erase(); term.restore();
|
|
258
|
+
for (const path of folders) await apply({ what: "roots", add: path });
|
|
259
|
+
return "all";
|
|
260
|
+
}
|
|
261
|
+
const offered = projects ?? knownProjects();
|
|
262
|
+
if (offered.length === 0) { term.erase(); io.say(" No git project found in the usual folders. Grant one: npx worktrust remote projects add <folder>"); return "later"; }
|
|
263
|
+
const ticked = await choose(term, { title: "Projects this phone may steer an agent in", multi: true, items: [...offered.map((path) => ({ label: tildePath(path), info: "Space ticks it; Enter grants the ticked projects.", tick: true, path })), { label: "Grant the ticked projects", info: "Enter grants every ticked project.", done: true }] });
|
|
264
|
+
term.erase(); term.restore();
|
|
265
|
+
const chosen = ticked === "quit" || ticked === "back" ? [] : ticked.ticked;
|
|
266
|
+
if (chosen.length === 0) { for (const line of LATER) io.say(line); return "later"; }
|
|
267
|
+
for (const item of chosen) await apply({ what: "projects", add: item.path });
|
|
268
|
+
return "chosen";
|
|
269
|
+
} finally { term.restore(); }
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* A LINKED PHONE THAT WAS NEVER GIVEN A REACH (0.11.12, owner 2026-11-15: "what if someone closes the CLI before choosing?").
|
|
273
|
+
* Nothing is shared by default: the roots and projects lists start empty (remote-store.mjs: a missing file is an empty list)
|
|
274
|
+
* and only the keyboard's door or a signed change from the app fills them, so a phone linked with no choice made reaches no
|
|
275
|
+
* folder at all. While a phone is confirmed and BOTH lists are still empty, the menu's first screen and Remote Agent say
|
|
276
|
+
* "<name> is linked: choose what it may reach" and open this step (`remote access`). Derived from the lists themselves, no
|
|
277
|
+
* new state: Ctrl+C, Esc or Later write nothing, so the lists stay empty and the question stays. Grants belong to the
|
|
278
|
+
* computer: once a folder is granted, every phone linked to it reaches that folder, as before.
|
|
279
|
+
* → the newest confirmed phone's connection row, or null. An unreadable file throws (the caller says not known).
|
|
280
|
+
*/
|
|
281
|
+
const newestFirst = (list) => [...list].sort((a, b) => (b.confirmed_at ?? 0) - (a.confirmed_at ?? 0));
|
|
282
|
+
export function awaitingAccess(phones = loadPhones(), roots = loadRoots(), projects = loadProjects()) {
|
|
283
|
+
if (roots.length > 0 || projects.length > 0 || phones.confirmed.length === 0) return null;
|
|
284
|
+
const newest = newestFirst(phones.confirmed)[0];
|
|
285
|
+
return connections({ ...phones, pending: [] }).find((c) => c.device_id === newest.device_id) ?? null;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** The access step in this terminal: interactive only with a terminal on both ends and no --yes. */
|
|
289
|
+
export async function reachStep(io, apply) {
|
|
290
|
+
const interactive = Boolean(process.stdin.isTTY && process.stdout.isTTY) && !io.has?.("yes");
|
|
291
|
+
const menu = interactive ? await import("./cli-menu.mjs") : null;
|
|
292
|
+
return accessStep(io, { apply, interactive, term: menu?.createTerminal() ?? null, choose: menu?.choose ?? null });
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** `remote access`: the newest linked phone, then the same step. */
|
|
296
|
+
export async function accessCommand(io, apply) {
|
|
297
|
+
if (loadPhones().confirmed.length === 0) return io.say(" No phone is linked to this computer yet: npx worktrust remote pair");
|
|
298
|
+
const waiting = awaitingAccess();
|
|
299
|
+
io.say(waiting ? ` ${waiting.name} is linked. Nothing on this computer is shared with it yet; choose what it may reach.` : ` Granted here: ${loadRoots().length} root folder(s), ${loadProjects().length} project(s). Every linked phone reaches them. Add more:`);
|
|
300
|
+
return reachStep(io, apply);
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* A LINKED PHONE WITH NO REACH CHOSEN (0.11.12, remote-connections.mjs awaitingAccess): the first row, until a folder is
|
|
305
|
+
* granted. Nothing is shared meanwhile; the row opens the same access step `remote pair` ends with.
|
|
306
|
+
*/
|
|
307
|
+
export const awaitingRow = (name, open) => ({ label: `${name} is linked: choose what it may reach ›`, note: { text: "nothing shared yet", tone: "yellow" }, hint: "npx worktrust remote access", info: "Nothing is shared until you choose. Opens the access step.", run: () => open(["remote", "access"]) });
|
|
308
|
+
/** The name of a linked phone still waiting for its reach, or null (also when a file cannot be read: never a guess). */
|
|
309
|
+
export function awaitingName() { try { return awaitingAccess()?.name ?? null; } catch { return null; } }
|
package/remote-countdown.mjs
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
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
4
|
* answer, never a fixed ten minutes), redrawn in place once a second: `[████████░░░░] 7:41 left`. Without a terminal the
|
|
5
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.
|
|
6
|
+
* an expiry) does, and always gives it back. 0.11.12: in a command the MENU started, Esc while the bar runs stops the wait
|
|
7
|
+
* (cli-stop.mjs watchKeys, which owns raw mode for that time); elsewhere the bar is as it was.
|
|
7
8
|
*/
|
|
8
9
|
import { emitKeypressEvents } from "node:readline";
|
|
10
|
+
import { watchKeys } from "./cli-stop.mjs";
|
|
9
11
|
|
|
10
12
|
export const BAR_WIDTH = 24;
|
|
11
13
|
const clock = (ms) => { const s = Math.max(0, Math.ceil(ms / 1000)); return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, "0")}`; };
|
|
@@ -24,6 +26,7 @@ export function startCountdown({ expiresAt, windowMs, out = process.stdout, tty
|
|
|
24
26
|
return { stop: (line) => { if (line) out.write(` ${line}\n`); } };
|
|
25
27
|
}
|
|
26
28
|
const draw = () => out.write(`\r\x1b[2K ${barLine(expiresAt - now(), windowMs)}`);
|
|
29
|
+
const release = watchKeys();
|
|
27
30
|
draw();
|
|
28
31
|
const timer = setInterval(draw, 1000);
|
|
29
32
|
timer.unref?.();
|
|
@@ -33,6 +36,7 @@ export function startCountdown({ expiresAt, windowMs, out = process.stdout, tty
|
|
|
33
36
|
if (stopped) return;
|
|
34
37
|
stopped = true;
|
|
35
38
|
clearInterval(timer);
|
|
39
|
+
release();
|
|
36
40
|
out.write(`\r\x1b[2K${line ? ` ${line}` : ""}\n`);
|
|
37
41
|
},
|
|
38
42
|
};
|