worktrust 0.11.6 → 0.11.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +49 -5
- package/cli-menu-remote.mjs +148 -0
- package/cli-menu.mjs +153 -0
- package/engine-release.json +1 -1
- package/folder-picker.mjs +85 -0
- package/package-release.json +1 -1
- package/package.json +9 -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 +64 -57
- 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 +34 -8
package/README.md
CHANGED
|
@@ -1,11 +1,40 @@
|
|
|
1
1
|
# worktrust
|
|
2
2
|
|
|
3
|
+
## 0.11.7: a menu, folders without typing, and agent modes you allow here
|
|
4
|
+
|
|
5
|
+
**A menu.** `npx worktrust` in your own terminal now opens a menu: move with the arrow keys, Enter opens, Esc or the left
|
|
6
|
+
arrow goes back, q quits, 1 to 9 jump. The first item, Check this computer, does what the bare command did before
|
|
7
|
+
(connect, or show what is connected). Every item shows the short command it runs, so you can type it next time. Without a
|
|
8
|
+
terminal (a script, a hook, the MCP door) nothing changes and nothing waits for a key; every command works as before.
|
|
9
|
+
|
|
10
|
+
**Remote Agent: approve with `remote app` or `remote web`.** `npx worktrust remote app` approves this computer with the
|
|
11
|
+
WorkTrust app (a QR code here), `npx worktrust remote web` in the browser. Each makes the computer's remote keys, asks you
|
|
12
|
+
first, sets up the service and shows the phone's QR code, with `--gateway` and `--device` as before. `remote enable` is
|
|
13
|
+
gone: it now says which two commands to use. While you approve, a bar under the QR code or link counts the request's
|
|
14
|
+
time down; when it runs out, Enter draws a new one. `npx worktrust remote connections` lists every phone and browser
|
|
15
|
+
linked to this computer, and `remote disconnect` closes one (or `--all`), each after a typed confirmation.
|
|
16
|
+
|
|
17
|
+
**Folders without typing.** In the menu, Remote Agent, Roots: tick the folders your projects live in (Desktop, Documents,
|
|
18
|
+
Developer, Projects, code, src, each with the number of projects found), make a new folder for projects, or choose any
|
|
19
|
+
folder with your system's folder picker. A phone can now open the projects that are already inside a root, not only make
|
|
20
|
+
new ones. The rules stay: never your home folder or above it, never a folder of secrets. On a Mac, a folder in Desktop,
|
|
21
|
+
Documents, Downloads or iCloud Drive makes macOS ask once, right away, whether the Remote Agent service may read it.
|
|
22
|
+
|
|
23
|
+
**Agent modes, with a ceiling you set here.** A phone may start Manual (asks for every change) and Plan, as before.
|
|
24
|
+
`npx worktrust remote modes allow edit` lets it start Edit automatically (Claude Code's acceptEdits), and
|
|
25
|
+
`remote modes allow auto` Claude Code's auto mode (which includes edit); `remote modes deny edit` takes both back. The
|
|
26
|
+
computer refuses any mode above what you allowed, whatever a phone sends. No push, no install, no deploy and no secret, in
|
|
27
|
+
every mode; in Edit and Auto the agent also cannot edit its own rules or the files that say what a test runs. Claude Code's
|
|
28
|
+
effort level and extra projects in one session (`--add-dir`) come along where your Claude Code offers them.
|
|
29
|
+
|
|
30
|
+
No measure change: the measure rules stay 4.
|
|
31
|
+
|
|
3
32
|
## 0.11.6: approve a computer with your phone
|
|
4
33
|
|
|
5
34
|
**Two roads to approve this computer for Remote Agent.** `npx worktrust remote app` shows the approval as a QR code in
|
|
6
35
|
the terminal, without opening a browser: scan it with the WorkTrust app, check the code and key, accept Remote Agent's
|
|
7
36
|
terms and approve with your authenticator code. `npx worktrust remote web` opens the approval page in your browser, as
|
|
8
|
-
before. `npx worktrust remote enable`
|
|
37
|
+
before. (Until 0.11.7, `npx worktrust remote enable` asked which one you want.) A request lives ten minutes; the page and the app count
|
|
9
38
|
it down and tell you when to run the command again.
|
|
10
39
|
|
|
11
40
|
**A command the CLI does not know** now says so ("Unknown command: …") before the help, and ends with a failure code.
|
|
@@ -785,20 +814,35 @@ Then revoke the key in WorkTrust: Sources → Devices → this computer → Revo
|
|
|
785
814
|
|
|
786
815
|
## Remote Agent: steer this computer's agents from your phone or browser (`npx worktrust remote`)
|
|
787
816
|
|
|
788
|
-
Off until you run `npx worktrust remote
|
|
789
|
-
except `status`.
|
|
817
|
+
Off until you run `npx worktrust remote app` (or `remote web`) at this keyboard; an AI agent's shell is refused every
|
|
818
|
+
`remote` command except `status`.
|
|
790
819
|
|
|
791
|
-
- `
|
|
820
|
+
- `app` and `web` make a REMOTE key pair for this computer (Ed25519 and X25519, files of mode 0600 in `~/.worktrust/remote/`),
|
|
792
821
|
never the measurement key, and has it approved in WorkTrust with your second factor; then it starts a service while you
|
|
793
822
|
are logged in (launchd on macOS, a systemd user unit on Linux, linger off; on Windows `npx worktrust remote run` in a
|
|
794
823
|
terminal) and draws a QR code for the WorkTrust app. `pair` draws a new one: five minutes, one phone, once. A phone
|
|
795
824
|
that scanned it is confirmed; one that typed the code instead waits for `npx worktrust remote phones confirm`.
|
|
796
825
|
- Two roads to approve the computer's key: `npx worktrust remote app` shows the approval as a QR code here (no browser);
|
|
797
826
|
the WorkTrust app scans it and you approve with your authenticator code. `npx worktrust remote web` opens the approval
|
|
798
|
-
page in your browser.
|
|
827
|
+
page in your browser. Both take `--gateway` and `--device`; `remote enable` (0.11.6 and before) is gone since 0.11.7.
|
|
799
828
|
- `projects add <folder>` grants a folder (its real path; never your home folder, the disk's root or a folder holding
|
|
800
829
|
keys, keychains, browser profiles or wallets). A phone starts agents only in granted folders, several at once (four by
|
|
801
830
|
default).
|
|
831
|
+
- `connections` lists every phone and browser linked to this computer (name, kind, fingerprint, since, last seen) and
|
|
832
|
+
this computer's own link. `disconnect <number|name|fingerprint>` closes one after two confirmations (y, then the start
|
|
833
|
+
of its fingerprint or its name typed); `disconnect --all` closes every one after you type `close all`. Without a
|
|
834
|
+
terminal both refuse. `phones remove` does the same removal. End a key for your whole account in WorkTrust, Settings,
|
|
835
|
+
Remote Agent.
|
|
836
|
+
- `roots add <folder> [--git-init]` adds a folder your projects live in (the same rules). A phone may open the git
|
|
837
|
+
projects already directly inside it (the most recently changed first, thirty in all with the granted ones) and create
|
|
838
|
+
one new, empty project folder in it. A phone names a project by the id this computer gave it, never by a path. In the
|
|
839
|
+
menu (Remote Agent, Roots) you tick suggested folders or use your system's folder picker instead of typing.
|
|
840
|
+
- `modes allow|deny edit|auto` and `modes status`: the agent modes a phone may start here. Manual and Plan always; Edit
|
|
841
|
+
automatically and Auto only once allowed here (Auto includes Edit). The computer refuses a mode above what you allowed.
|
|
842
|
+
`admin on|off`: whether a change made in the WorkTrust app or on the web (allowed modes, folders, roots, connections)
|
|
843
|
+
is taken here. On by default; each such change asks your authenticator there, carries WorkTrust's signature on that
|
|
844
|
+
exact change for this computer (five minutes, one use), is checked here against the keys built into this CLI, and is
|
|
845
|
+
said in the `remote run` terminal. `admin off` keeps every change at this keyboard. The switch itself changes only here.
|
|
802
846
|
- From a phone you may approve: a file edit inside the project, a test, build or lint command from a short reviewed list,
|
|
803
847
|
and a message an agent sends through a connector, shown whole (channel, every recipient, subject, text, attachment
|
|
804
848
|
names). Everything else is decided at this keyboard or not at all: installs from the network, `git push`, deploys,
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE MENU'S DEEPER LEVELS (CLI 0.11.7): Remote Agent ›, its projects, roots, allowed modes and connections, and the history and
|
|
3
|
+
* preservation choices. Each item still runs one direct command (runShown), named in its muted line; this file only reads
|
|
4
|
+
* the remote settings to label the items and never writes one itself: a change goes through the command, so it goes
|
|
5
|
+
* through applySettingsChange (remote-settings.mjs) like a typed one. Folders are chosen without typing (folder-picker.mjs).
|
|
6
|
+
*/
|
|
7
|
+
import { homedir } from "node:os";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { choose, muted, runShown, typed } from "./cli-menu.mjs";
|
|
10
|
+
import { makeProjectsFolder, pickFolder, pickerCommand, suggestedFolders } from "./folder-picker.mjs";
|
|
11
|
+
import { connections } from "./remote-connections.mjs";
|
|
12
|
+
import { loadIdentity, loadProjects, loadRoots, loadSettings } from "./remote-store.mjs";
|
|
13
|
+
import { allowedModes } from "./remote-settings.mjs";
|
|
14
|
+
|
|
15
|
+
const BACK = { label: "← Back", back: true };
|
|
16
|
+
const tilde = (path) => (path.startsWith(homedir()) ? `~${path.slice(homedir().length)}` : path);
|
|
17
|
+
|
|
18
|
+
/** Loop one level: each pick runs, Back or Esc returns; a pick that returns false ends the menu (Ctrl+C after a command). */
|
|
19
|
+
async function level(term, header, title, build) {
|
|
20
|
+
for (;;) {
|
|
21
|
+
const picked = await choose(term, { header, title, items: build() });
|
|
22
|
+
if (picked === "quit") return false;
|
|
23
|
+
if (picked === "back" || picked.item.back) return true;
|
|
24
|
+
if (picked.item.run && (await picked.item.run()) === false) return false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/** The folder the system picker chose, or a typed path where there is no picker. */
|
|
29
|
+
async function chooseFolder(term) {
|
|
30
|
+
const command = pickerCommand();
|
|
31
|
+
if (command) { term.restore(); const path = await pickFolder(command); term.enter(); return path; }
|
|
32
|
+
return typed(term, "No folder picker on this system. Type the folder's path:");
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Roots › Add folders: the suggested folders, ticked with Space, a new folder, or the system's picker. */
|
|
36
|
+
async function addRoots(term, io, header) {
|
|
37
|
+
const have = new Set(loadRoots().map((r) => r.path));
|
|
38
|
+
const offered = suggestedFolders().filter((f) => !have.has(f.path));
|
|
39
|
+
const items = [
|
|
40
|
+
...offered.map((f) => ({ label: `${tilde(f.path)} ${muted(`${f.projects} project${f.projects === 1 ? "" : "s"} found`)}`, tick: true, path: f.path })),
|
|
41
|
+
{ label: "+ Make a new folder for my projects", make: true, hint: "~/Projects by default; new projects in it get git init" },
|
|
42
|
+
{ label: "Choose another folder…", pick: true, hint: "the system's folder picker" },
|
|
43
|
+
BACK,
|
|
44
|
+
];
|
|
45
|
+
const picked = await choose(term, { header, title: "Add folders where your projects live", items, multi: true });
|
|
46
|
+
if (picked === "quit") return false;
|
|
47
|
+
if (picked === "back" || picked.item.back) return true;
|
|
48
|
+
const chosen = picked.ticked.map((i) => ({ path: i.path, gitInit: false }));
|
|
49
|
+
if (picked.item.make) {
|
|
50
|
+
const name = await typed(term, "Name of the new folder in your home folder:", "Projects");
|
|
51
|
+
term.enter();
|
|
52
|
+
if (name) { const made = makeProjectsFolder(name); if (made.ok) chosen.push({ path: made.path, gitInit: true }); else { term.write(` ${made.reason}\n`); await term.key(); } }
|
|
53
|
+
}
|
|
54
|
+
if (picked.item.pick) { const path = await chooseFolder(term); term.enter(); if (path) chosen.push({ path, gitInit: false }); }
|
|
55
|
+
for (const c of chosen) if ((await runShown(term, io, ["remote", "roots", "add", c.path, ...(c.gitInit ? ["--git-init"] : [])])) === false) return false;
|
|
56
|
+
return true;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function rootsMenu(term, io, header) {
|
|
60
|
+
return level(term, header, "Roots for new projects", () => [
|
|
61
|
+
{ label: "+ Add folders", hint: "npx worktrust remote roots add <folder> a phone opens the projects in it and may create new ones", run: () => addRoots(term, io, header) },
|
|
62
|
+
...loadRoots().map((r) => ({ label: `Remove ${tilde(r.path)}`, hint: `npx worktrust remote roots remove ${tilde(r.path)}`, run: () => runShown(term, io, ["remote", "roots", "remove", r.path]) })),
|
|
63
|
+
BACK,
|
|
64
|
+
]);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
function projectsMenu(term, io, header) {
|
|
68
|
+
return level(term, header, "Projects a phone may steer an agent in", () => [
|
|
69
|
+
{ label: "+ Add a project folder…", hint: "npx worktrust remote projects add <folder> the system's folder picker", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["remote", "projects", "add", path]) : true; } },
|
|
70
|
+
...loadProjects().map((p) => ({ label: `Remove ${tilde(p.path)}`, hint: `npx worktrust remote projects remove ${tilde(p.path)}`, run: () => runShown(term, io, ["remote", "projects", "remove", p.path]) })),
|
|
71
|
+
BACK,
|
|
72
|
+
]);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function modesMenu(term, io, header) {
|
|
76
|
+
return level(term, header, "Agent modes a phone may start here", () => {
|
|
77
|
+
const allowed = allowedModes(loadSettings());
|
|
78
|
+
const toggle = (mode, words) => ({ label: `${words}: ${allowed.includes(mode) ? "allowed" : "not allowed"}`, hint: `npx worktrust remote modes ${allowed.includes(mode) ? "deny" : "allow"} ${mode}${mode === "auto" ? " allowing auto allows edit too" : ""}`,
|
|
79
|
+
run: () => runShown(term, io, ["remote", "modes", allowed.includes(mode) ? "deny" : "allow", mode]) });
|
|
80
|
+
return [
|
|
81
|
+
{ label: "Manual (asks for every change): always allowed", disabled: true },
|
|
82
|
+
{ label: "Plan (read-only): always allowed", disabled: true },
|
|
83
|
+
toggle("edit", "Edit automatically"),
|
|
84
|
+
toggle("auto", "Auto (the agent's own automatic mode)"),
|
|
85
|
+
{ label: "Status", hint: "npx worktrust remote modes status", run: () => runShown(term, io, ["remote", "modes", "status"]) },
|
|
86
|
+
BACK,
|
|
87
|
+
];
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
function connectionsMenu(term, io, header) {
|
|
92
|
+
return level(term, header, "Connections to this computer", () => {
|
|
93
|
+
const list = connections();
|
|
94
|
+
return [
|
|
95
|
+
{ label: "List them", hint: "npx worktrust remote connections", run: () => runShown(term, io, ["remote", "connections"]) },
|
|
96
|
+
...list.filter((c) => c.state === "pending").map((c) => ({ label: `Confirm ${c.name} (pending)`, hint: `npx worktrust remote phones confirm ${c.fingerprint}`, run: () => runShown(term, io, ["remote", "phones", "confirm", c.fingerprint]) })),
|
|
97
|
+
...list.map((c) => ({ label: `${c.name} · ${c.kind} · ${c.fingerprint}`, hint: `npx worktrust remote disconnect ${c.n} Enter: disconnect (asks twice)`, run: () => runShown(term, io, ["remote", "disconnect", c.fingerprint]) })),
|
|
98
|
+
...(list.length > 0 ? [{ label: "Close all connections", hint: "npx worktrust remote disconnect --all type close all to confirm", run: () => runShown(term, io, ["remote", "disconnect", "--all"]) }] : []),
|
|
99
|
+
BACK,
|
|
100
|
+
];
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
/** Remote Agent ›. Approved already: "Link a phone" comes first and approving reads "approve again". */
|
|
105
|
+
export function remoteMenu(term, io, header) {
|
|
106
|
+
return level(term, header, "Remote Agent", () => {
|
|
107
|
+
const approved = Boolean(loadIdentity()), settings = loadSettings();
|
|
108
|
+
const approveMenu = { label: approved ? "Approved ✓ · approve again ›" : "Approve this computer ›", hint: approved ? "npx worktrust remote app --repair new keys for this computer" : "npx worktrust remote app | web",
|
|
109
|
+
run: () => level(term, header, approved ? "Approve this computer again (new keys)" : "Approve this computer", () => [
|
|
110
|
+
{ label: "With the WorkTrust app", hint: `npx worktrust remote app${approved ? " --repair" : ""} a QR here, approved on your phone`, run: () => runShown(term, io, ["remote", "app", ...(approved ? ["--repair"] : [])]) },
|
|
111
|
+
{ label: "In the browser", hint: `npx worktrust remote web${approved ? " --repair" : ""}`, run: () => runShown(term, io, ["remote", "web", ...(approved ? ["--repair"] : [])]) },
|
|
112
|
+
BACK,
|
|
113
|
+
]) };
|
|
114
|
+
const link = { label: "Link a phone (QR here)", hint: "npx worktrust remote pair", run: () => runShown(term, io, ["remote", "pair"]) };
|
|
115
|
+
const paused = settings.paused !== null;
|
|
116
|
+
return [
|
|
117
|
+
...(approved ? [link, approveMenu] : [approveMenu, link]),
|
|
118
|
+
{ label: "Projects ›", hint: "npx worktrust remote projects", run: () => projectsMenu(term, io, header) },
|
|
119
|
+
{ label: "Roots for new projects ›", hint: "npx worktrust remote roots", run: () => rootsMenu(term, io, header) },
|
|
120
|
+
{ label: "Allowed modes ›", hint: "npx worktrust remote modes", run: () => modesMenu(term, io, header) },
|
|
121
|
+
{ label: "Connections ›", hint: "npx worktrust remote connections", run: () => connectionsMenu(term, io, header) },
|
|
122
|
+
{ label: paused ? "Resume" : "Pause", hint: `npx worktrust remote ${paused ? "resume" : "pause"}`, run: () => runShown(term, io, ["remote", paused ? "resume" : "pause"]) },
|
|
123
|
+
{ label: "Status", hint: "npx worktrust remote status", run: () => runShown(term, io, ["remote", "status"]) },
|
|
124
|
+
BACK,
|
|
125
|
+
];
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export function historyMenu(term, io, header) {
|
|
130
|
+
return level(term, header, "Import earlier history", () => [
|
|
131
|
+
{ label: "This computer's earlier sessions", hint: "npx worktrust history shows the plan, asks first", run: () => runShown(term, io, ["history"]) },
|
|
132
|
+
{ label: "From your local archive", hint: "npx worktrust history --from-archive", run: () => runShown(term, io, ["history", "--from-archive"]) },
|
|
133
|
+
{ label: "From a ChatGPT or Claude export…", hint: "npx worktrust history --export <path> reconstructed, never verified hours", run: async () => { const path = await typed(term, "The export's path (the zip, its folder or conversations.json):", join(homedir(), "Downloads")); term.enter(); return path ? runShown(term, io, ["history", "--export", path]) : true; } },
|
|
134
|
+
{ label: "From a copied session folder…", hint: "npx worktrust history --from-folder <dir>", run: async () => { const path = await chooseFolder(term); term.enter(); return path ? runShown(term, io, ["history", "--from-folder", path]) : true; } },
|
|
135
|
+
BACK,
|
|
136
|
+
]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export function preserveMenu(term, io, header) {
|
|
140
|
+
return level(term, header, "Preserve evidence", () => [
|
|
141
|
+
{ label: "How long each AI app keeps its sessions", hint: "npx worktrust preserve local only", run: () => runShown(term, io, ["preserve"]) },
|
|
142
|
+
{ label: "Keep them longer", hint: "npx worktrust preserve --apply asks per change", run: () => runShown(term, io, ["preserve", "--apply"]) },
|
|
143
|
+
{ label: "Make a local archive", hint: "npx worktrust preserve --archive", run: () => runShown(term, io, ["preserve", "--archive"]) },
|
|
144
|
+
{ label: "Check the archive", hint: "npx worktrust preserve --verify", run: () => runShown(term, io, ["preserve", "--verify"]) },
|
|
145
|
+
{ label: "Count hours from the archive", hint: "npx worktrust preserve --summary", run: () => runShown(term, io, ["preserve", "--summary"]) },
|
|
146
|
+
BACK,
|
|
147
|
+
]);
|
|
148
|
+
}
|
package/cli-menu.mjs
ADDED
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* THE MENU (CLI 0.11.7, owner 2026-11-12: "a navigable menu"). Bare `npx worktrust` in a person's own terminal opens it;
|
|
3
|
+
* everything else is exactly as before. It opens ONLY when menuWanted says so: stdin and stdout are both terminals, no
|
|
4
|
+
* argument at all (so no --yes, --dry-run or --device), not relayed (WORKTRUST_RELAYED), not started by a hook or the MCP
|
|
5
|
+
* door (their WORKTRUST_HOOK_INPUT / WORKTRUST_MCP_TOKEN), not in an AI agent's shell (worktrust.mjs refuses the bare
|
|
6
|
+
* command there before it gets here), and not turned off (WORKTRUST_MENU=off). Hooks, MCP and scripts never wait for a key.
|
|
7
|
+
*
|
|
8
|
+
* Each item runs the direct command it shows in its muted line, as a child of this CLI with the terminal handed over
|
|
9
|
+
* (io.runCli), so people learn the short form and every command keeps its own questions and its own guards. Keys: ↑/↓
|
|
10
|
+
* move, Enter opens, Esc or ← goes back one level, q quits from the top, 1 to 9 jump, Ctrl+C quits. Raw mode and the
|
|
11
|
+
* cursor are restored on every way out (quit, Ctrl+C, an error). NO_COLOR is respected.
|
|
12
|
+
*/
|
|
13
|
+
import { emitKeypressEvents } from "node:readline";
|
|
14
|
+
import { createInterface } from "node:readline/promises";
|
|
15
|
+
import { loadIdentity, loadSettings } from "./remote-store.mjs";
|
|
16
|
+
|
|
17
|
+
/** Whether bare `npx worktrust` opens the menu here. Pure: the caller passes what it knows. */
|
|
18
|
+
export function menuWanted({ args = [], env = {}, stdinTTY = false, stdoutTTY = false, agentShell = null } = {}) {
|
|
19
|
+
if (args.length !== 0 || !stdinTTY || !stdoutTTY || agentShell) return false;
|
|
20
|
+
if (env.WORKTRUST_MENU === "off" || env.WORKTRUST_RELAYED === "1" || env.WORKTRUST_HOOK_INPUT || env.WORKTRUST_MCP_TOKEN) return false;
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
const colour = () => !process.env.NO_COLOR && process.env.TERM !== "dumb";
|
|
25
|
+
const paint = (code, text) => (colour() ? `\x1b[${code}m${text}\x1b[0m` : text);
|
|
26
|
+
export const muted = (text) => paint("2", text);
|
|
27
|
+
const strong = (text) => paint("1", text);
|
|
28
|
+
const chosen = (text) => (colour() ? `\x1b[7m${text}\x1b[0m` : `> ${text}`);
|
|
29
|
+
|
|
30
|
+
/** The terminal, in raw mode while a list waits for a key; restore() always puts it back. */
|
|
31
|
+
export function createTerminal(input = process.stdin, output = process.stdout) {
|
|
32
|
+
let raw = false;
|
|
33
|
+
const write = (text) => output.write(text);
|
|
34
|
+
const enter = () => { emitKeypressEvents(input); if (input.isTTY && !raw) { input.setRawMode(true); raw = true; } input.resume(); write("\x1b[?25l"); };
|
|
35
|
+
const restore = () => { if (input.isTTY && raw) { try { input.setRawMode(false); } catch { /* gone */ } raw = false; } input.pause(); write("\x1b[?25h"); };
|
|
36
|
+
const key = () => new Promise((resolve) => {
|
|
37
|
+
const on = (str, k = {}) => { input.off("keypress", on); resolve({ str, name: k.name ?? str, ctrl: Boolean(k.ctrl) }); };
|
|
38
|
+
input.on("keypress", on);
|
|
39
|
+
});
|
|
40
|
+
return { write, enter, restore, key, clear: () => write(colour() ? "\x1b[2J\x1b[H" : "\n") };
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* One list: → { item } (Enter or a digit), "back" (Esc, ←), "quit" (q at the top, Ctrl+C). `items`: { label, hint?, info?,
|
|
45
|
+
* disabled? }. `multi`: Space ticks an item that has `tick: true`; the ticked items come back as `ticked`.
|
|
46
|
+
*/
|
|
47
|
+
export async function choose(term, { header = [], title, items, top = false, multi = false, footer = null }) {
|
|
48
|
+
let at = Math.max(0, items.findIndex((i) => !i.disabled));
|
|
49
|
+
const ticked = new Set(items.filter((i) => i.ticked).map((i) => i.label));
|
|
50
|
+
for (;;) {
|
|
51
|
+
term.clear();
|
|
52
|
+
for (const line of header) term.write(`${line}\n`);
|
|
53
|
+
if (title) term.write(`\n ${strong(title)}\n`);
|
|
54
|
+
term.write("\n");
|
|
55
|
+
items.forEach((item, i) => {
|
|
56
|
+
const n = i < 9 ? `${i + 1}` : " ";
|
|
57
|
+
const box = multi && item.tick ? `[${ticked.has(item.label) ? "x" : " "}] ` : "";
|
|
58
|
+
const label = `${n} ${box}${item.label}`;
|
|
59
|
+
term.write(` ${i === at ? chosen(` ${label} `) : item.disabled ? muted(` ${label} `) : ` ${label} `}\n`);
|
|
60
|
+
if (item.hint) term.write(` ${muted(item.hint)}\n`);
|
|
61
|
+
});
|
|
62
|
+
term.write(`\n ${muted(footer ?? (multi ? "↑/↓ move · Space tick · Enter confirm · Esc back" : `↑/↓ move · Enter open · ${top ? "q quit" : "Esc back"} · 1-9 jump`))}\n`);
|
|
63
|
+
const k = await term.key();
|
|
64
|
+
if (k.ctrl && k.name === "c") return "quit";
|
|
65
|
+
if (k.name === "up" || k.name === "k") { do at = (at - 1 + items.length) % items.length; while (items[at].disabled); continue; }
|
|
66
|
+
if (k.name === "down" || k.name === "j") { do at = (at + 1) % items.length; while (items[at].disabled); continue; }
|
|
67
|
+
if (k.name === "escape" || k.name === "left") { if (!top) return "back"; continue; }
|
|
68
|
+
if (k.name === "q" && top) return "quit";
|
|
69
|
+
if (multi && k.name === "space" && items[at].tick) { ticked.has(items[at].label) ? ticked.delete(items[at].label) : ticked.add(items[at].label); continue; }
|
|
70
|
+
if (/^[1-9]$/.test(k.str ?? "") && items[Number(k.str) - 1] && !items[Number(k.str) - 1].disabled) { at = Number(k.str) - 1; if (!multi) return { item: items[at] }; continue; }
|
|
71
|
+
if (k.name === "return" || k.name === "enter") return { item: items[at], ticked: items.filter((i) => ticked.has(i.label)) };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** A line of text typed at the keyboard (out of raw mode), the default already there to edit; null when left empty. */
|
|
76
|
+
export async function typed(term, question, value = "") {
|
|
77
|
+
term.restore();
|
|
78
|
+
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
79
|
+
const answer = prompt.question(` ${question} `);
|
|
80
|
+
if (value) prompt.write(value);
|
|
81
|
+
const text = (await answer).trim();
|
|
82
|
+
prompt.close();
|
|
83
|
+
return text || null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** While a command runs, Ctrl+C is the command's (it reaches the child too); the menu stays. */
|
|
87
|
+
let busy = false;
|
|
88
|
+
|
|
89
|
+
/** Run one direct command with the terminal handed over, then wait for a key before the menu comes back. */
|
|
90
|
+
export async function runShown(term, io, args, label = null) {
|
|
91
|
+
term.restore();
|
|
92
|
+
busy = true;
|
|
93
|
+
term.clear();
|
|
94
|
+
process.stdout.write(` ${muted(`› npx worktrust ${args.join(" ")}`.trimEnd())}${label ? ` ${label}` : ""}\n\n`);
|
|
95
|
+
let code = 1;
|
|
96
|
+
try { code = await io.runCli(args); } catch { code = 1; } finally { busy = false; }
|
|
97
|
+
term.enter();
|
|
98
|
+
term.write(`\n ${muted(code === 0 ? "Done." : "It ended with a message above.")} ${muted("Press any key for the menu.")}\n`);
|
|
99
|
+
const k = await term.key();
|
|
100
|
+
return !(k.ctrl && k.name === "c");
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** The header: the version, a newer one when the check says so, and this computer's state in one line. */
|
|
104
|
+
export function headerLines(state) {
|
|
105
|
+
const remote = (() => {
|
|
106
|
+
try {
|
|
107
|
+
const s = loadSettings();
|
|
108
|
+
if (!loadIdentity()) return "not set up";
|
|
109
|
+
return s.enabled ? (s.paused ? "paused" : "on") : "off";
|
|
110
|
+
} catch { return "unknown"; }
|
|
111
|
+
})();
|
|
112
|
+
return [
|
|
113
|
+
` ${strong(`WorkTrust CLI ${state.version}`)}${state.latest ? ` ${paint("33", `a new version is available: ${state.latest}`)}` : ""}`,
|
|
114
|
+
` ${state.connected ? `Connected as ${state.account ?? "this computer's account (not recorded: run Check this computer)"}` : "Not connected yet"} · Remote Agent ${remote}`,
|
|
115
|
+
];
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/** The top of the menu. `io`: { runCli(args) → Promise<code>, state() → { version, latest, account, connected, door } }. */
|
|
119
|
+
export async function runMenu(io) {
|
|
120
|
+
const term = createTerminal();
|
|
121
|
+
const quit = () => { term.restore(); process.stdout.write("\n"); };
|
|
122
|
+
const onSignal = () => { if (busy) return; quit(); process.exit(130); };
|
|
123
|
+
process.on("SIGINT", onSignal);
|
|
124
|
+
process.on("SIGTERM", onSignal);
|
|
125
|
+
try {
|
|
126
|
+
term.enter();
|
|
127
|
+
const { remoteMenu, historyMenu, preserveMenu } = await import("./cli-menu-remote.mjs");
|
|
128
|
+
for (;;) {
|
|
129
|
+
const state = await io.state();
|
|
130
|
+
const header = headerLines(state);
|
|
131
|
+
const door = state.door === "off" ? "Off" : "On";
|
|
132
|
+
const items = [
|
|
133
|
+
{ label: "Check this computer", hint: state.connected ? "npx worktrust what is coupled here" : "npx worktrust connect this computer", run: () => runShown(term, io, []) },
|
|
134
|
+
{ label: "Update WorkTrust", hint: "npx worktrust update", run: () => runShown(term, io, ["update"]) },
|
|
135
|
+
{ label: "Remote Agent ›", hint: "npx worktrust remote …", run: () => remoteMenu(term, io, header) },
|
|
136
|
+
{ label: "Import earlier history ›", hint: "npx worktrust history …", run: () => historyMenu(term, io, header) },
|
|
137
|
+
{ label: "Preserve evidence ›", hint: "npx worktrust preserve …", run: () => preserveMenu(term, io, header) },
|
|
138
|
+
{ label: `WorkTrust in your AI apps: ${door}`, hint: `npx worktrust mcp ${door === "On" ? "off" : "on"} your hours stay measured by the session hook`, run: () => runShown(term, io, ["mcp", door === "On" ? "off" : "on"]) },
|
|
139
|
+
{ label: "Status", hint: "npx worktrust status", run: () => runShown(term, io, ["status"]) },
|
|
140
|
+
{ label: "Disconnect this computer", hint: "npx worktrust disconnect asks first", run: () => runShown(term, io, ["disconnect"]) },
|
|
141
|
+
{ label: "Help · all commands", hint: "npx worktrust help", run: () => runShown(term, io, ["help"]) },
|
|
142
|
+
{ label: "Quit", hint: "q", quit: true },
|
|
143
|
+
];
|
|
144
|
+
const picked = await choose(term, { header, items, top: true });
|
|
145
|
+
if (picked === "quit" || picked === "back" || picked.item.quit) break;
|
|
146
|
+
if ((await picked.item.run()) === false) break;
|
|
147
|
+
}
|
|
148
|
+
} finally {
|
|
149
|
+
process.off("SIGINT", onSignal);
|
|
150
|
+
process.off("SIGTERM", onSignal);
|
|
151
|
+
quit();
|
|
152
|
+
}
|
|
153
|
+
}
|
package/engine-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"167fe3718415fe690c9e4f7a3a993520e8c652edcf61184cc14cfec2db67d7bc","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":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-menu-remote.mjs":"b7dc18ced2b9cedec5e2263f42265973fcb96b16e34b88ac91e8b53c8be62c68","cli-menu.mjs":"6cf2b7b510bd4c81818885afddb5da0e9c60c4bcdf36280497f7ba3d4ebf30e6","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","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":"167fe3718415fe690c9e4f7a3a993520e8c652edcf61184cc14cfec2db67d7bc","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":"6db24891f7b0c56c00b337e52f4d4aeb8c9a0413b3bf46d0fc8a45328ea71b3e","remote-adapter-codex.mjs":"d2fd6c61d9e3c4a45e9b10da1aa3c15d45c86629d6456e4a8d25ad95b13eb209","remote-adapter-opencode.mjs":"ddd7f3ec0b4ba92f4744453d60fda338b63550e3ec7b23fa3acc668df1d64eb7","remote-adapter-terminal.mjs":"9237d3747a25126fcdad42c0eab10e69393754388a6014b30fb0890b9c735888","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":"33a6194e0653b78cf075edd2aae083179af2ca9aeae190a225aeeabb03a43f67","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"e24ff04ed61647e164b6f055d4f691366f3204fe445140afc5f34abbed5d4080","remote-countdown.mjs":"85cf2d01fe5ca49895e08a3d5de346bb5e4a8dd31b9fda3fd9f9534d9e1e47cf","remote-daemon.mjs":"94d4896b0e1203f7a5bc7224a6221a36f4c20be89caee78b3ab37b9b6a2dac1d","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"a8245604d41373819738eaf06ec1d2242cb5f7b2e60aa316f31d2f8742b8c70d","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"d8c2aba394fe73d850ea000c758e6b926c87b122eaf5c6aa92ec1183e90f90e1","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":"93f8c2031895d4e01006a1951d7c0e79ef71b86b2777eed5dfa966ab131e446d","remote-qr.mjs":"b80e2b4a5bc020cf6ed92e91d06b327cb5197de1c35b3445a0fc2c7a3bf1ab3f","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"c180c401613e0c01dfc471bb6226ebb035a7299839f81c6e38ff714d75d68c3f","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":"1efb7869cef6090cbbeae15ff1e5ffe99dca3742f9c245686d6758bb705587d6","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"7ba22e6110cea3ac75a4f084f8f92a5bd90c31a19d3ce58a88a0843bdadea834","remote-store.mjs":"7226d006d03788ea2a8de30226ab5f6bf45b1bcbb10ee7d4e28bf2c3cca5a2a7","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"e9f20415c2b5d62a09f35a63075002ebd1da56edb32f242d52822d58ecbd8ac3","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"a42bf1c5ad9b74bae6109eb6ac3259ded36c4fd26a4ee72fbf67076e0e849177"},"format":"worktrust-package/1","kind":"engine","version":"0.11.7"},"signature":"2cN0AVHJqNjetQViHZHjJfPeoWSe3C3gU1Va8FD_1F0XjkzVE_vBYul0Acd13Mg5lfmmye7rTCWRcbhIY3KIBw"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* FOLDERS WITHOUT TYPING (CLI 0.11.7, owner 2026-11-12), for the menu at this keyboard only: the folders a person's
|
|
3
|
+
* projects usually live in, with how many git projects each holds; the system's own folder picker; a new folder for
|
|
4
|
+
* projects; and which chosen folders macOS guards with its privacy prompt. Nothing here grants anything: every folder
|
|
5
|
+
* chosen still goes through the root and project rules (remote-settings.mjs applySettingsChange, remote-policy.mjs).
|
|
6
|
+
*
|
|
7
|
+
* The picker runs a FIXED program with fixed arguments, never a shell line and never a word from a phone: macOS
|
|
8
|
+
* `osascript -e 'POSIX path of (choose folder …)'`, Windows PowerShell's FolderBrowserDialog, Linux `zenity` when it is
|
|
9
|
+
* there. Without one (a Linux with no zenity, an SSH session) the person types the path, the only typed fallback.
|
|
10
|
+
*/
|
|
11
|
+
import { spawn } from "node:child_process";
|
|
12
|
+
import { existsSync, lstatSync, mkdirSync, readdirSync, realpathSync, statSync } from "node:fs";
|
|
13
|
+
import { homedir } from "node:os";
|
|
14
|
+
import { delimiter, join, relative, sep } from "node:path";
|
|
15
|
+
|
|
16
|
+
export const SUGGESTED = Object.freeze(["Desktop", "Documents", "Developer", "Projects", "code", "src"]);
|
|
17
|
+
const isDir = (path) => { try { return statSync(path).isDirectory(); } catch { return false; } };
|
|
18
|
+
|
|
19
|
+
/** How many git projects lie directly inside `dir` (a folder holding .git); hidden folders are not counted. */
|
|
20
|
+
export function gitProjectsIn(dir) {
|
|
21
|
+
let n = 0;
|
|
22
|
+
try {
|
|
23
|
+
for (const d of readdirSync(dir, { withFileTypes: true }).slice(0, 2000)) {
|
|
24
|
+
if (d.name.startsWith(".") || !(d.isDirectory() || d.isSymbolicLink())) continue;
|
|
25
|
+
try { lstatSync(join(dir, d.name, ".git")); n += 1; } catch { /* not a git project */ }
|
|
26
|
+
}
|
|
27
|
+
} catch { return 0; }
|
|
28
|
+
return n;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** The suggested folders that exist here, each with its git projects counted: [{ name, path, projects }]. */
|
|
32
|
+
export function suggestedFolders(home = homedir()) {
|
|
33
|
+
return SUGGESTED.map((name) => ({ name, path: join(home, name) })).filter((f) => isDir(f.path)).map((f) => ({ ...f, projects: gitProjectsIn(f.path) }));
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const onPath = (bin, path = process.env.PATH ?? "") => path.split(delimiter).some((dir) => dir && existsSync(join(dir, bin)));
|
|
37
|
+
|
|
38
|
+
const PS_PICKER = "Add-Type -AssemblyName System.Windows.Forms; $d = New-Object System.Windows.Forms.FolderBrowserDialog; $d.Description = 'Choose a folder for WorkTrust Remote Agent'; if ($d.ShowDialog() -eq [System.Windows.Forms.DialogResult]::OK) { [Console]::Out.Write($d.SelectedPath) }";
|
|
39
|
+
|
|
40
|
+
/** The system's folder picker as { file, args }, or null when this system has none (then the path is typed). */
|
|
41
|
+
export function pickerCommand(platform = process.platform, has = onPath, env = process.env) {
|
|
42
|
+
if (platform === "darwin") return { file: "/usr/bin/osascript", args: ["-e", 'POSIX path of (choose folder with prompt "Choose a folder for WorkTrust Remote Agent")'] };
|
|
43
|
+
if (platform === "win32") return { file: join(env.SystemRoot || "C:\\Windows", "System32", "WindowsPowerShell", "v1.0", "powershell.exe"), args: ["-NoProfile", "-STA", "-Command", PS_PICKER] };
|
|
44
|
+
if (platform === "linux" && (env.DISPLAY || env.WAYLAND_DISPLAY) && has("zenity")) return { file: "zenity", args: ["--file-selection", "--directory", "--title=Choose a folder for WorkTrust Remote Agent"] };
|
|
45
|
+
return null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** Open the picker and wait: the chosen folder, or null (cancelled, or no picker). */
|
|
49
|
+
export function pickFolder(command = pickerCommand()) {
|
|
50
|
+
if (!command) return Promise.resolve(null);
|
|
51
|
+
return new Promise((resolve) => {
|
|
52
|
+
let out = "";
|
|
53
|
+
const child = spawn(command.file, command.args, { stdio: ["ignore", "pipe", "ignore"], windowsHide: false });
|
|
54
|
+
child.stdout.setEncoding("utf8");
|
|
55
|
+
child.stdout.on("data", (chunk) => { out += chunk; });
|
|
56
|
+
child.on("error", () => resolve(null));
|
|
57
|
+
child.on("close", (code) => { const path = out.trim().replace(/[\\/]$/, ""); resolve(code === 0 && path ? path : null); });
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** A new folder's name: one segment, no leading dot. */
|
|
62
|
+
export const FOLDER_NAME = /^[A-Za-z0-9_-][A-Za-z0-9 ._-]{0,99}$/;
|
|
63
|
+
|
|
64
|
+
/** Make ~/<name> for new projects (nothing above or beside it); → { ok, path } or { ok: false, reason }. Existing is fine. */
|
|
65
|
+
export function makeProjectsFolder(name, home = homedir()) {
|
|
66
|
+
if (!FOLDER_NAME.test(name ?? "")) return { ok: false, reason: "a folder name: letters, digits, space, . _ -, not starting with a dot" };
|
|
67
|
+
const path = join(home, name);
|
|
68
|
+
if (isDir(path)) return { ok: true, path, made: false };
|
|
69
|
+
try { mkdirSync(path, { mode: 0o755 }); } catch { return { ok: false, reason: "that folder could not be made" }; }
|
|
70
|
+
return { ok: true, path, made: true };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const realOr = (path) => { try { return realpathSync(path); } catch { return path; } };
|
|
74
|
+
const under = (base, path) => { const rel = relative(base, path); return rel === "" || (!rel.startsWith("..") && !rel.startsWith(sep) && !/^[A-Za-z]:/.test(rel)); };
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* The folder macOS guards with its privacy prompt that `path` lies in (Desktop, Documents, Downloads, iCloud Drive), or
|
|
78
|
+
* null: elsewhere, or not macOS. A program launchd starts asks for it on its first read, mid-session, unless it was asked once.
|
|
79
|
+
*/
|
|
80
|
+
export function protectedFolder(path, home = homedir(), platform = process.platform) {
|
|
81
|
+
if (platform !== "darwin") return null;
|
|
82
|
+
const real = realOr(path), h = realOr(home);
|
|
83
|
+
for (const [name, dir] of [["Desktop", "Desktop"], ["Documents", "Documents"], ["Downloads", "Downloads"], ["iCloud Drive", join("Library", "Mobile Documents")]]) if (under(join(h, dir), real)) return name;
|
|
84
|
+
return null;
|
|
85
|
+
}
|
package/package-release.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"b38ea343eb95892d4164274be4184d6e34eade9d4c454e1dcf8bc7735736425e","README.md":"
|
|
1
|
+
{"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"e8abb38c293b57b71d3a6163d6242d1f375e773372b91b6d8ce39c584c51262a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"b38ea343eb95892d4164274be4184d6e34eade9d4c454e1dcf8bc7735736425e","README.md":"0c877624eff2c9aaf0bcbf52fba9ed532c3646f818c5bea34723632626cab73f","SECURITY.md":"6a798d875f48ae84c3a677397e5611e03b94215944952e0f61e13f6cfc949745","chat-exports.mjs":"f026c5a063f62c22ba6f25474a9d9fdbb6074beebbfe1faff2a876c437a1a000","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","cli-menu-remote.mjs":"b7dc18ced2b9cedec5e2263f42265973fcb96b16e34b88ac91e8b53c8be62c68","cli-menu.mjs":"6cf2b7b510bd4c81818885afddb5da0e9c60c4bcdf36280497f7ba3d4ebf30e6","commit-rules.mjs":"e94cc32a5415f6d9e978145ab9505ac4ae0bac9431e6e9104b9b37155260b51f","config-edits.mjs":"527a7674f9d52b284bfda3b8089eb4b930a709bf14aedbec7f6eef1e59ef52ee","count-behaviour.mjs":"06b0ecbc222087160dc64c0b302391631e8e799038364c317c6cd28449c5044d","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"c02fbb7a91195330a6719c931e7af3246a3991f4a727ab1051fb72103b464b85","export-facts.mjs":"3bbb46c80e8678b5cea7e15dcbfc456a2b48595053241c2b3cea508092f9b917","folder-picker.mjs":"daeb379626d5716f91f588064c6b4083618279320c006c177960cc93f056d96a","git-commits.mjs":"af0ed45a2a42c8e17cabfb3649a2f524dbf80230f8a6ec1c6b775fed7d34dc9c","history-outbox.mjs":"85c70389effc5b4ec9d9b33af9192314e67f47af2752515b42a7959344ce2354","history-progress.mjs":"dcc25ee94b727f2605a763349a4d8764640335d6cf0043fb6108cebeed16dcb9","log-session.mjs":"167fe3718415fe690c9e4f7a3a993520e8c652edcf61184cc14cfec2db67d7bc","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"700538ff928a540e53362e371d7b2b5e952674879a330fb730dcb42923e942c2","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"cd111cae0f53a25a2d878a158479abfb1ace353361454843f91a16d241101d46","project-modes.mjs":"ada26e68297fbeb90e4e91d75a90fd2d7cc107b999a9702840675b5a7529463e","remote-adapter-claude-code.mjs":"6db24891f7b0c56c00b337e52f4d4aeb8c9a0413b3bf46d0fc8a45328ea71b3e","remote-adapter-codex.mjs":"d2fd6c61d9e3c4a45e9b10da1aa3c15d45c86629d6456e4a8d25ad95b13eb209","remote-adapter-opencode.mjs":"ddd7f3ec0b4ba92f4744453d60fda338b63550e3ec7b23fa3acc668df1d64eb7","remote-adapter-terminal.mjs":"9237d3747a25126fcdad42c0eab10e69393754388a6014b30fb0890b9c735888","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":"33a6194e0653b78cf075edd2aae083179af2ca9aeae190a225aeeabb03a43f67","remote-coalesce.mjs":"cb0967d9cfe81e3892bcade8349d6814db98be8c2adbdb54df0b8d1b142f65d1","remote-codex-events.mjs":"58657d6070a50c837737cb85f5a1eaf9c2cbc4e1adfe3e970748ab3b2af94631","remote-connections.mjs":"e24ff04ed61647e164b6f055d4f691366f3204fe445140afc5f34abbed5d4080","remote-countdown.mjs":"85cf2d01fe5ca49895e08a3d5de346bb5e4a8dd31b9fda3fd9f9534d9e1e47cf","remote-daemon.mjs":"94d4896b0e1203f7a5bc7224a6221a36f4c20be89caee78b3ab37b9b6a2dac1d","remote-endorse.mjs":"89eda4883567176703e01e44d83e987271bc2a6134e108f517b3b213719a21f9","remote-inventory.mjs":"a8245604d41373819738eaf06ec1d2242cb5f7b2e60aa316f31d2f8742b8c70d","remote-journal.mjs":"907ebd48c53162b22dc743ef95b53c1a6be6886a7495605b5cfa820b8de9d330","remote-live-preview.mjs":"faa70f9260ac05037204c2a0c3facf4ffe42f68408948390b341b453a2932289","remote-opencode-events.mjs":"3108375501ead2c2c78bce1435cc2a9fe6d2af1d7ff1fb42e12ff3e0f5d9af9c","remote-opencode-session.mjs":"681b201d833a7d7d025122b3a79663bcdc0a989aefd39d8018a28113d8810caf","remote-pairing.mjs":"d8c2aba394fe73d850ea000c758e6b926c87b122eaf5c6aa92ec1183e90f90e1","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":"93f8c2031895d4e01006a1951d7c0e79ef71b86b2777eed5dfa966ab131e446d","remote-qr.mjs":"b80e2b4a5bc020cf6ed92e91d06b327cb5197de1c35b3445a0fc2c7a3bf1ab3f","remote-release-plans.mjs":"11884a62b7d6dcccb5e154a26603bdf650f7b40f946329fb174d8c13729bec74","remote-releases.mjs":"fb08b72593ea00013c8b679e0c0d7dee95b0fd7cc5fd31b80ac575d0e340927d","remote-run.mjs":"c180c401613e0c01dfc471bb6226ebb035a7299839f81c6e38ff714d75d68c3f","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":"1efb7869cef6090cbbeae15ff1e5ffe99dca3742f9c245686d6758bb705587d6","remote-settings.mjs":"ca16f39416a457bd5ceb1df847596e1b4bcd2894310eb6514664a619dee4981f","remote-steered.mjs":"d7afde92c62c87abbdb84b0cfea2eea4752e90a2e453e52a54812c4fe0395190","remote-steering.mjs":"7ba22e6110cea3ac75a4f084f8f92a5bd90c31a19d3ce58a88a0843bdadea834","remote-store.mjs":"7226d006d03788ea2a8de30226ab5f6bf45b1bcbb10ee7d4e28bf2c3cca5a2a7","remote-terminal-cli.mjs":"82a048b75e412d0b6db076afbb84cab7c754dec72b6c8b6af4d4906b38e988a7","remote-terminal-sessions.mjs":"6ab51824890a18768d23cedc499f3840b2b02a8ed651463c1fe2d74dd352a361","remote-transport.mjs":"68650fd77ea09b5762377f87cabdc1c73a34d77324aa5bf0cd9742094a50c32b","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","self-update.mjs":"378e3620d48c72cf0bf812be408883b995cdb2223de34a20f762dd73eeffb258","session-databases.mjs":"a16ffbc50ccc0e78f370ebe07f871d1a80f1977472e478e3599e7abfdc90c1b7","session-local-models.mjs":"bacd38ff8dd3056b552982ec52eb57c7b8ca86e1a46cd4cba30fc340e3e28fd4","setup-mcp.mjs":"b732e3dd9b3e522b7cc8acf167ce28ba8f1a8dee797ee15bd7c3b02919b13e6f","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"e9f20415c2b5d62a09f35a63075002ebd1da56edb32f242d52822d58ecbd8ac3","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"a42bf1c5ad9b74bae6109eb6ac3259ded36c4fd26a4ee72fbf67076e0e849177"},"format":"worktrust-package/1","kind":"npm","version":"0.11.7"},"signature":"j6lZJonU8TufZbDcVrgSvKc0Szzb89gldIxkkygjWbZesfTt5jdjbmxnG-7XREgiUCF9l5sIZsjgctE68ZulAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "worktrust",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.7",
|
|
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": {
|
|
@@ -90,7 +90,14 @@
|
|
|
90
90
|
"remote-pairing.mjs",
|
|
91
91
|
"remote-qr.mjs",
|
|
92
92
|
"remote-cli.mjs",
|
|
93
|
-
"remote-agent-switch.mjs"
|
|
93
|
+
"remote-agent-switch.mjs",
|
|
94
|
+
"remote-settings.mjs",
|
|
95
|
+
"folder-picker.mjs",
|
|
96
|
+
"cli-menu.mjs",
|
|
97
|
+
"cli-menu-remote.mjs",
|
|
98
|
+
"remote-countdown.mjs",
|
|
99
|
+
"remote-connections.mjs",
|
|
100
|
+
"remote-admin.mjs"
|
|
94
101
|
],
|
|
95
102
|
"engines": {
|
|
96
103
|
"node": ">=18"
|