worktrust 0.10.5 → 0.10.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/log-session.mjs CHANGED
@@ -124,11 +124,12 @@ const IDLE_BEFORE_SWEEP = 30 * 60 * 1000;
124
124
  /** Under a minute is not a piece of work. */
125
125
  const MIN_SECONDS = 60;
126
126
  /**
127
- * The door's own ceiling for one stretch. A day past it is reported SHORT: under-reporting is the
127
+ * The door's own ceiling for one MEASURED stretch: sixteen hours since 0.10.6 (owner, 2026-10-09; it was eight). Every
128
+ * second of it lies between two messages at most five minutes apart. A day past it is reported SHORT: under-reporting is the
128
129
  * safe direction. Stretches are split by DAY, which is a boundary the clock draws — never by
129
130
  * guessing where one piece of work ended and the next began.
130
131
  */
131
- const MAX_SECONDS = 28800;
132
+ const MAX_SECONDS = 57600;
132
133
  /** The door's ceilings for the layers (a day) and for a day's subagents: the same bounds its columns check. */
133
134
  const DAY_SECONDS = 86400;
134
135
  /** A tool gap is tool time up to thirty minutes (proposed, owner 2026-10-06); past that it is a wait, counted as idle. */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worktrust",
3
- "version": "0.10.5",
3
+ "version": "0.10.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": {
package/worktrust.mjs CHANGED
@@ -2,7 +2,8 @@
2
2
  /**
3
3
  * WorkTrust on a computer, in one command — like `gh auth login` (2026-10-03).
4
4
  *
5
- * npx worktrust show the plan, ask, approve this computer in the app, couple;
5
+ * npx worktrust show the plan, ask, approve this computer in the app, couple (0.10.7: a person's
6
+ * command always runs the newest version, whatever npx had cached);
6
7
  * on a computer already coupled: what is coupled here
7
8
  * npx worktrust --dry-run show the plan only; nothing is written, nothing is sent
8
9
  * npx worktrust --yes no question (for scripts); the computer is still approved in the app
@@ -73,7 +74,7 @@ const command = args.find((arg, at) => !arg.startsWith("--") && !(at > 0 && VALU
73
74
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
74
75
  const has = (name) => args.includes(`--${name}`);
75
76
  /** 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). */
76
- const CLI_VERSION = "0.10.5";
77
+ const CLI_VERSION = "0.10.7";
77
78
  const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
78
79
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
79
80
  const HOME_DIR = join(homedir(), ".worktrust");
@@ -986,6 +987,40 @@ if (agentShell && PERSON_ONLY.has(command)) {
986
987
  process.exit(3);
987
988
  }
988
989
 
990
+ /**
991
+ * ALWAYS THE NEWEST, WHATEVER WAS TYPED (0.10.7, owner: "npx worktrust should simply be right"). npx runs whatever version
992
+ * it cached, and a person should never need `@latest` or `--prefer-online`. A command a PERSON runs in a terminal asks npm
993
+ * which version is newest (the version string only, nothing of this computer, two seconds at most) and, when this one is
994
+ * older, hands the same command to the newest through npx and steps aside. Offline, npm slow, no terminal (a script, a
995
+ * test), an AI agent's shell: this version runs as it is. The bridge and the hook, which run many times a day from the
996
+ * stable copy, never ask.
997
+ */
998
+ const RELAY_COMMANDS = new Set(["default", "connect", "update", "history", "status", "disconnect", "preserve", "codex", "antigravity"]);
999
+ const semverNewer = (a, b) => { const x = a.split(".").map(Number), y = b.split(".").map(Number); for (let i = 0; i < 3; i += 1) if (x[i] !== y[i]) return x[i] > y[i]; return false; };
1000
+ async function newestVersion() {
1001
+ try {
1002
+ const response = await fetch(process.env.WORKTRUST_REGISTRY_URL || "https://registry.npmjs.org/worktrust/latest", { signal: AbortSignal.timeout(2000), headers: { accept: "application/json" } });
1003
+ if (!response.ok) return null;
1004
+ const version = (await response.json())?.version;
1005
+ return typeof version === "string" && /^\d+\.\d+\.\d+$/.test(version) ? version : null;
1006
+ } catch { return null; }
1007
+ }
1008
+ async function relayToNewest() {
1009
+ if (process.env.WORKTRUST_RELAYED === "1" || !RELAY_COMMANDS.has(command) || !process.stdin.isTTY || !process.stdout.isTTY) return;
1010
+ const latest = await newestVersion();
1011
+ if (!latest || !semverNewer(latest, CLI_VERSION)) return;
1012
+ say(` worktrust ${CLI_VERSION} is not the newest: running ${latest} instead.`);
1013
+ const argv = ["--yes", `worktrust@${latest}`, ...args];
1014
+ const env = { ...process.env, WORKTRUST_RELAYED: "1" };
1015
+ // A .cmd shim on Windows needs a shell: one line, each argument quoted for cmd.exe, never an argument list beside it.
1016
+ const quote = (arg) => (/^[\w@%+=:,./\\-]+$/.test(arg) ? arg : `"${String(arg).replace(/"/g, '\\"')}"`);
1017
+ const child = platform() === "win32" ? spawn(["npx", ...argv].map(quote).join(" "), { stdio: "inherit", env, shell: true }) : spawn("npx", argv, { stdio: "inherit", env });
1018
+ const code = await new Promise((done) => { child.on("error", () => done(null)); child.on("close", (exit) => done(exit)); });
1019
+ if (code === null) { say(" The newest could not be started; this version runs instead."); return; }
1020
+ process.exit(code);
1021
+ }
1022
+ await relayToNewest();
1023
+
989
1024
  if (command === "default") { if (keyStore.load()) await again(); else await connect(); }
990
1025
  else if (command === "mcp") await bridge();
991
1026
  else if (command === "hook") await hook();