worktrust 0.11.9 → 0.11.11
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 +43 -0
- package/LICENSE +3 -0
- package/README.md +18 -12
- package/cli-look.mjs +192 -0
- package/cli-menu-remote.mjs +31 -7
- package/cli-menu.mjs +28 -14
- package/engine-release.json +1 -1
- package/log-session.mjs +6 -169
- package/package-release.json +1 -1
- package/package.json +3 -1
- package/remote-adapter-claude-code.mjs +30 -4
- package/remote-adapter-codex.mjs +49 -6
- package/remote-adapter-opencode.mjs +63 -10
- package/remote-adapter-terminal.mjs +4 -3
- package/remote-cli.mjs +22 -44
- package/remote-connections.mjs +55 -1
- package/remote-daemon.mjs +5 -2
- package/remote-inventory.mjs +12 -2
- package/remote-pairing.mjs +42 -4
- package/remote-protocol.mjs +119 -20
- package/remote-qr.mjs +40 -15
- package/remote-run.mjs +7 -5
- package/remote-sessions.mjs +15 -15
- package/remote-steering.mjs +60 -0
- package/remote-store.mjs +10 -0
- package/session-readers.mjs +212 -0
- package/transcript-readers.mjs +5 -5
- package/worktrust.mjs +57 -19
package/worktrust.mjs
CHANGED
|
@@ -83,7 +83,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
|
|
|
83
83
|
const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
|
|
84
84
|
const has = (name) => args.includes(`--${name}`);
|
|
85
85
|
/** This CLI's version, said to the door so the app can tell which computer runs an old one (check-cli-package holds it equal to package.json). */
|
|
86
|
-
const CLI_VERSION = "0.11.
|
|
86
|
+
const CLI_VERSION = "0.11.11";
|
|
87
87
|
/**
|
|
88
88
|
* HOW THIS CLI MEASURES, AS A NUMBER OF ITS OWN (0.10.31; owner, 2026-10-28: 0.10.30 offered a re-measure it had no reason
|
|
89
89
|
* to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
|
|
@@ -119,9 +119,9 @@ const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.w
|
|
|
119
119
|
const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
|
|
120
120
|
const HOME_DIR = join(homedir(), ".worktrust");
|
|
121
121
|
const HERE = dirname(fileURLToPath(import.meta.url));
|
|
122
|
-
const SCRIPTS = ["credential-store.mjs", "remote-protocol.mjs", "remote-store.mjs", "remote-policy.mjs", "remote-journal.mjs", "remote-steered.mjs", "remote-inventory.mjs", "remote-claude-events.mjs", "remote-claude-progress.mjs", "remote-attachments.mjs", "remote-preview.mjs", "remote-coalesce.mjs", "remote-steering.mjs", "remote-codex-events.mjs", "remote-adapter-codex.mjs", "remote-opencode-events.mjs", "remote-adapter-opencode.mjs", "remote-opencode-session.mjs", "remote-adapter-terminal.mjs", "remote-terminal-sessions.mjs", "remote-terminal-cli.mjs", "remote-screen-states.mjs", "remote-screen-approvals.mjs", "remote-screen-push.mjs", "remote-cdp.mjs", "remote-live-preview.mjs", "remote-projects.mjs", "remote-pipeline-config.mjs", "remote-pipeline-parsers.mjs", "remote-pipeline.mjs", "remote-releases.mjs", "remote-release-plans.mjs", "remote-adapter-claude-code.mjs", "remote-approval-bridge.mjs", "remote-approvals.mjs", "remote-sessions.mjs", "remote-session-list.mjs", "remote-changes.mjs", "remote-endorse.mjs", "remote-daemon.mjs", "remote-transport.mjs", "remote-run.mjs", "remote-service.mjs", "remote-pairing.mjs", "remote-qr.mjs", "remote-cli.mjs", "remote-agent-switch.mjs", "remote-settings.mjs", "folder-picker.mjs", "cli-menu.mjs", "cli-menu-remote.mjs", "cli-colour.mjs", "node-guide.mjs", "remote-countdown.mjs", "remote-connections.mjs", "remote-admin.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs", "project-modes.mjs", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
|
|
122
|
+
const SCRIPTS = ["credential-store.mjs", "remote-protocol.mjs", "remote-store.mjs", "remote-policy.mjs", "remote-journal.mjs", "remote-steered.mjs", "remote-inventory.mjs", "remote-claude-events.mjs", "remote-claude-progress.mjs", "remote-attachments.mjs", "remote-preview.mjs", "remote-coalesce.mjs", "remote-steering.mjs", "remote-codex-events.mjs", "remote-adapter-codex.mjs", "remote-opencode-events.mjs", "remote-adapter-opencode.mjs", "remote-opencode-session.mjs", "remote-adapter-terminal.mjs", "remote-terminal-sessions.mjs", "remote-terminal-cli.mjs", "remote-screen-states.mjs", "remote-screen-approvals.mjs", "remote-screen-push.mjs", "remote-cdp.mjs", "remote-live-preview.mjs", "remote-projects.mjs", "remote-pipeline-config.mjs", "remote-pipeline-parsers.mjs", "remote-pipeline.mjs", "remote-releases.mjs", "remote-release-plans.mjs", "remote-adapter-claude-code.mjs", "remote-approval-bridge.mjs", "remote-approvals.mjs", "remote-sessions.mjs", "remote-session-list.mjs", "remote-changes.mjs", "remote-endorse.mjs", "remote-daemon.mjs", "remote-transport.mjs", "remote-run.mjs", "remote-service.mjs", "remote-pairing.mjs", "remote-qr.mjs", "remote-cli.mjs", "remote-agent-switch.mjs", "remote-settings.mjs", "folder-picker.mjs", "cli-menu.mjs", "cli-menu-remote.mjs", "cli-colour.mjs", "cli-look.mjs", "node-guide.mjs", "remote-countdown.mjs", "remote-connections.mjs", "remote-admin.mjs", "credential-vault.mjs", "credential-vault-scripts.mjs", "history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs", "package-integrity.mjs", "worktrust-launch.mjs", "project-modes.mjs", "commit-rules.mjs", "git-commits.mjs", "self-update.mjs", "history-progress.mjs"];
|
|
123
123
|
/** The modules the scripts import by name from beside them; a download keeps that name. */
|
|
124
|
-
const IMPORTED = new Set(["project-modes.mjs", "transcript-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "commit-rules.mjs", "git-commits.mjs"]);
|
|
124
|
+
const IMPORTED = new Set(["project-modes.mjs", "transcript-readers.mjs", "session-readers.mjs", "session-databases.mjs", "session-local-models.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "export-facts.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "commit-rules.mjs", "git-commits.mjs"]);
|
|
125
125
|
const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
|
|
126
126
|
const BUNDLED = SCRIPTS.every((name) => existsSync(join(HERE, name)));
|
|
127
127
|
const PLACEHOLDER = `wt_${"0".repeat(43)}`;
|
|
@@ -1430,19 +1430,34 @@ async function measuredHere() {
|
|
|
1430
1430
|
const read = await busyWith("Counting what this computer measured", () => run(hook, ["--evidence-summary"], "", true, { WORKTRUST_MCP_URL: "", WORKTRUST_HOOK_INPUT: "" }));
|
|
1431
1431
|
let m = null;
|
|
1432
1432
|
try { m = JSON.parse(read.out.trim().split("\n").filter((text) => text.startsWith("{")).pop()); } catch { return; }
|
|
1433
|
-
|
|
1434
|
-
const
|
|
1435
|
-
say();
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1433
|
+
// 0.11.10: the lines are cli-look.mjs's measuredLines (pure; the changed files and the classes now say what they count).
|
|
1434
|
+
const { measuredLines } = await import("./cli-look.mjs");
|
|
1435
|
+
for (const line of measuredLines(m)) say(line);
|
|
1436
|
+
if (m?.stretches) say(" Each AI app's sessions on this computer, counted: npx worktrust look");
|
|
1437
|
+
}
|
|
1438
|
+
|
|
1439
|
+
/**
|
|
1440
|
+
* LOOK AT THIS COMPUTER (`npx worktrust look`, 0.11.10; owner, 2026-11-14): per AI app the sessions its own files hold and
|
|
1441
|
+
* their first and last day (cli-look.mjs). It reads no key, writes nothing and calls no network: not the registry either
|
|
1442
|
+
* (look is not a RELAY_COMMAND). In a person's own terminal (menuWanted) a short list follows, each row a command as a child.
|
|
1443
|
+
*/
|
|
1444
|
+
async function look(agentShell) {
|
|
1445
|
+
if (!existsSync(join(HERE, "cli-look.mjs"))) fail("worktrust look needs the complete WorkTrust package. Nothing was read.");
|
|
1446
|
+
const { lookAt, lookLines, lookNext } = await import("./cli-look.mjs");
|
|
1447
|
+
const live = Boolean(process.stderr.isTTY), tell = (words) => process.stderr.write(live ? `\r\x1b[K ${words}` : ` ${words}\n`);
|
|
1448
|
+
tell("Looking for AI apps…");
|
|
1449
|
+
const found = lookAt({ progress: (name) => tell(`Reading ${name}…`) });
|
|
1450
|
+
if (live) process.stderr.write("\r\x1b[K");
|
|
1451
|
+
for (const line of lookLines(found, { columns: process.stdout.columns || 80 })) say(line);
|
|
1452
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) return;
|
|
1453
|
+
const menu = await import("./cli-menu.mjs");
|
|
1454
|
+
if (!menu.menuWanted({ args: [], env: process.env, stdinTTY: true, stdoutTTY: true, agentShell })) return;
|
|
1455
|
+
const runCli = (cliArgs) => new Promise((resolve) => {
|
|
1456
|
+
const child = spawn(moduleExecutable(HERE), [...moduleArgs(HERE, "worktrust.mjs", cliArgs)], { stdio: "inherit", env: { ...process.env, WORKTRUST_MENU: "off", WORKTRUST_RELAYED: "1" } });
|
|
1457
|
+
child.on("error", () => resolve(1));
|
|
1458
|
+
child.on("exit", (code, signal) => resolve(code ?? (signal ? 130 : 1)));
|
|
1459
|
+
});
|
|
1460
|
+
process.exitCode = await lookNext({ runCli }, { connected: existsSync(KEY_FILE) });
|
|
1446
1461
|
}
|
|
1447
1462
|
|
|
1448
1463
|
/** Claude Code's `cleanupPeriodDays` (its default 30), or null without Claude Code here. Read only: preserve.mjs changes it, on a yes. */
|
|
@@ -1577,6 +1592,23 @@ async function followDoorWish(key) {
|
|
|
1577
1592
|
saveDoorState({ mode: wish.mode, asked: state?.asked ?? new Date().toISOString() });
|
|
1578
1593
|
await accepted(key.url, key.token, key.device, doorModeAgent());
|
|
1579
1594
|
}
|
|
1595
|
+
/**
|
|
1596
|
+
* THE ACCOUNT'S TYPE, FOR THE MENU (owner, 2026-11-14; 0.11.10): the same signed ask as followDoorWish, read-only here (no
|
|
1597
|
+
* wish is acted on), three seconds at most. `account` is WorkTrust's own answer for this key's owner: `plan` (free | premium,
|
|
1598
|
+
* else not known), `remote` (open | premium_required, else not known: only premium_required locks Remote Agent in the menu)
|
|
1599
|
+
* and `upgrade`, kept only when it is an address on this key's own WorkTrust. Offline or refused: null, which claims nothing.
|
|
1600
|
+
*/
|
|
1601
|
+
async function askAccount(key) {
|
|
1602
|
+
if (!key?.device) return null;
|
|
1603
|
+
try {
|
|
1604
|
+
const url = new URL("/api/cli/door", key.url).href, body = "{}";
|
|
1605
|
+
const response = await fetch(url, { method: "POST", headers: { "content-type": "application/json", authorization: `Bearer ${key.token}`, "user-agent": `worktrust-cli/${CLI_VERSION}`, ...proof(key.device, url, body) }, body, redirect: "error", signal: AbortSignal.timeout(3000) });
|
|
1606
|
+
const account = response.ok ? (await response.json())?.account : null;
|
|
1607
|
+
if (!account || typeof account !== "object") return null;
|
|
1608
|
+
let upgrade = null; try { const at = new URL(account.upgrade); upgrade = at.origin === new URL(key.url).origin && /^https?:$/.test(at.protocol) ? at.href : null; } catch { upgrade = null; }
|
|
1609
|
+
return { plan: ["free", "premium"].includes(account.plan) ? account.plan : null, remoteAccess: ["open", "premium_required"].includes(account.remote) ? account.remote : null, upgrade };
|
|
1610
|
+
} catch { return null; }
|
|
1611
|
+
}
|
|
1580
1612
|
/**
|
|
1581
1613
|
* CLI ACTIVE, PER COMPUTER (owner, 2026-11-05; 0.10.37). The owner may pause this computer's CLI from Sources: the same answer
|
|
1582
1614
|
* from api/cli/door carries `measure` (active | paused) and its moment. A wish newer than the last change here is kept in
|
|
@@ -1706,6 +1738,7 @@ function help() {
|
|
|
1706
1738
|
say(" days this computer's own sessions lack, reconstructed, never verified hours (asks first)");
|
|
1707
1739
|
say(" worktrust disconnect take WorkTrust out of every AI app here (asks first)");
|
|
1708
1740
|
say(" worktrust status what is coupled here");
|
|
1741
|
+
say(" worktrust look what your AI apps recorded here: sessions per app and their first and last day; reads only, sends nothing");
|
|
1709
1742
|
say(" worktrust project a folder's mode: exclude (nothing read), confidential (hours and tokens count, no name,");
|
|
1710
1743
|
say(" branch, path or commit sent) or normal; `project list` shows them (default folder: here)");
|
|
1711
1744
|
say(" worktrust remote steer this computer's agents from your phone (opt-in, its own key, never your AI Hours):");
|
|
@@ -1787,6 +1820,7 @@ if (command === "default" && BUNDLED && (await import("./cli-menu.mjs")).menuWan
|
|
|
1787
1820
|
try { keyStore.load(); }
|
|
1788
1821
|
catch { fail("The local WorkTrust key file is unsafe or damaged, or the OS vault is locked or unavailable. Unlock your OS vault and retry. Do not delete the key file or reset the keychain."); }
|
|
1789
1822
|
let latest, latestKnown = false; // 0.11.9: whether the registry answered at all (no answer is not "up to date")
|
|
1823
|
+
let account = null, accountAt = 0; // 0.11.10: the account's type and Remote Agent's access, asked again after a minute or an upgrade
|
|
1790
1824
|
const runCli = (cliArgs) => new Promise((resolve) => {
|
|
1791
1825
|
const child = spawn(moduleExecutable(HERE), [...moduleArgs(HERE, "worktrust.mjs", cliArgs)], { stdio: "inherit", env: { ...process.env, WORKTRUST_MENU: "off", WORKTRUST_RELAYED: "1", ...(has("no-color") || has("no-colour") ? { NO_COLOR: "1" } : {}) } });
|
|
1792
1826
|
child.on("error", () => resolve(1));
|
|
@@ -1795,18 +1829,21 @@ if (command === "default" && BUNDLED && (await import("./cli-menu.mjs")).menuWan
|
|
|
1795
1829
|
const state = async () => {
|
|
1796
1830
|
if (latest === undefined) { const v = await newestVersion(); latestKnown = v !== null; latest = v && semverNewer(v, CLI_VERSION) ? v : null; }
|
|
1797
1831
|
let key = null; try { key = keyStore.load(); } catch { key = null; }
|
|
1832
|
+
if (key && Date.now() - accountAt > 60_000) { account = await askAccount(key); accountAt = Date.now(); }
|
|
1798
1833
|
// `installed` is read again at every ask (0.11.8): the menu's Update item says "up to date" the moment an update ends.
|
|
1799
1834
|
// THE SUMMARY'S FACTS (0.11.9): what this computer's own files say, never the key: its name, the day it was coupled, whether
|
|
1800
1835
|
// the session hook stands in Claude Code's settings, and how many AI apps' doors the person agreed to (the consent record).
|
|
1801
1836
|
let apps = null; try { apps = Object.keys(JSON.parse(readPrivateFile(CONSENT_FILE) ?? "null")?.entries ?? {}).filter((name) => name.startsWith("door:")).length; } catch { apps = null; }
|
|
1802
1837
|
return { version: CLI_VERSION, installed: stableVersion(), latest, latestKnown, connected: Boolean(key), account: key?.account ?? null, door: doorOff() ? "off" : "on",
|
|
1803
|
-
host: hostname().replace(/\.local$/i, ""), since: key?.coupledAt ?? null, hook: sessionHookHere(), apps
|
|
1838
|
+
host: hostname().replace(/\.local$/i, ""), since: key?.coupledAt ?? null, hook: sessionHookHere(), apps,
|
|
1839
|
+
plan: key ? account?.plan ?? null : null, remoteAccess: key ? account?.remoteAccess ?? null : null, upgrade: key ? account?.upgrade ?? null : null };
|
|
1804
1840
|
};
|
|
1805
|
-
|
|
1841
|
+
const openUrl = (url) => { openBrowser(url); accountAt = 0; }; // after an upgrade, the next read asks the account again
|
|
1842
|
+
return (await import("./cli-menu.mjs")).runMenu({ runCli, state, openUrl });
|
|
1806
1843
|
}
|
|
1807
1844
|
if (await relayToNewest()) return;
|
|
1808
1845
|
|
|
1809
|
-
if (!["version", "help", "preserve", "project"].includes(command)) {
|
|
1846
|
+
if (!["version", "help", "preserve", "project", "look"].includes(command)) { // 0.11.10: look reads no key (it reads, prints and writes nothing)
|
|
1810
1847
|
try { keyStore.load(); }
|
|
1811
1848
|
catch { fail("The local WorkTrust key file is unsafe or damaged, or the OS vault is locked or unavailable. Upload stopped. Unlock your OS vault and retry. Do not delete the key file or reset the keychain."); }
|
|
1812
1849
|
}
|
|
@@ -1831,6 +1868,7 @@ else if (command === "codex") await offerCodex();
|
|
|
1831
1868
|
else if (command === "antigravity") await offerAntigravity();
|
|
1832
1869
|
else if (command === "disconnect") await disconnect();
|
|
1833
1870
|
else if (command === "status") await status();
|
|
1871
|
+
else if (command === "look") await look(agentShell);
|
|
1834
1872
|
else if (command === "project") { if (!projectCommand) fail("worktrust project needs the complete WorkTrust package. Nothing was changed."); projectCommand(args.slice(args.indexOf("project") + 1).filter((arg) => !arg.startsWith("--")), { say, fail }); }
|
|
1835
1873
|
else if (command === "remote") await (await import("./remote-cli.mjs")).remoteCommand(args.slice(args.indexOf("remote") + 1).filter((a, i, all) => !a.startsWith("--") && !(i > 0 && ["--gateway", "--origin"].includes(all[i - 1]))), { say, fail, ask, has, flag, connected: () => { try { return Boolean(keyStore.load()); } catch { return false; } }, origin: ORIGIN, os: OS, openBrowser, prepare: async () => { await prepareBundledRuntime(); return { node: NODE, nodeArgs: [...NODE_FLAGS, ...NODE_ARGS], entry: STABLE }; } });
|
|
1836
1874
|
else if (command === "preserve") await preserve();
|