worktrust 0.10.21 → 0.10.24

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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # worktrust
2
2
 
3
+ ## Candidate 0.10.24: delivery and account limits
4
+
5
+ Not published yet. After an approved update, WorkTrust receives the running version without
6
+ an activity upload. Pending metadata batches can be resumed with `worktrust history --resume`,
7
+ even after an AI app removed the original session files. Review-held revisions need review;
8
+ reconnecting does not approve them. Keep archives for work that was never queued.
9
+
10
+ The corresponding server candidate limits new personal registrations to five active device
11
+ identities. AI apps sharing one key share one slot; cloned keys share account upload capacity.
12
+ Retiring a device preserves earlier data. Existing accounts above the limit are preserved but
13
+ cannot add another identity. Version labels and device signatures are not independent evidence
14
+ of time or correctness. A CLI update does not automatically publish a passport.
15
+
16
+
3
17
  Couple a computer to [WorkTrust](https://worktrust.io) in one command. WorkTrust keeps a verified
4
18
  record of the work you do with AI without anyone reading that work: it receives metadata only.
5
19
 
@@ -9,12 +23,9 @@ npx worktrust@latest
9
23
 
10
24
  **The official npm package** is `worktrust`, published by the npm account **worktrustio** with
11
25
  provenance from this repository (github.com/fhomey/worktrust-cli). Check it on npmjs.com before you run
12
- it; a package of another name or from another publisher is not ours. Without npm, the same script runs
13
- from WorkTrust's own site:
14
-
15
- ```
16
- curl -fsSO https://app.worktrust.io/counter/worktrust.mjs && node worktrust.mjs
17
- ```
26
+ it; a package of another name or from another publisher is not ours. Use the complete package:
27
+ individual support scripts are no longer downloaded and executed during setup. Version 0.10.22
28
+ adds a signed launcher. Check the registry for availability; 0.10.21 does not include this guard.
18
29
 
19
30
  **Python tool runners:** this repository also builds `worktrust` for `uvx` and `pipx` from the
20
31
  same measurement modules. Native wheels (0.10.13+) include a pinned official Node runtime,
@@ -254,7 +265,7 @@ and counts, exactly as the session hook reads it.
254
265
 
255
266
  ## Rebuild the history
256
267
 
257
- From **0.10.21 (release candidate)**, changed measured history waits for review before it
268
+ From **0.10.21**, changed measured history waits for review before it
258
269
  can replace measurements already received for that computer, client and historical day.
259
270
  The earlier receipt is retained as local activity, not independent proof of human effort.
260
271
  Other computers and periods remain on the record, including an unavailable old laptop.
@@ -391,7 +402,7 @@ which would delete every password on the computer, and many people rightly keep
391
402
 
392
403
  ## What it reads, writes and sends
393
404
 
394
- From **0.10.21 (release candidate)**, before each submission the hook keeps a local
405
+ From **0.10.21**, before each submission the hook keeps a local
395
406
  metadata file in `~/.worktrust/measurements/`. The `worktrust-measurement/1` format retains
396
407
  the available timeline, opaque stretch reference, dates, counts and collector identifiers.
397
408
  It omits prompts, answers, titles, repository names, file paths, endpoint URLs and credentials.
@@ -423,13 +434,13 @@ never as proof.
423
434
 
424
435
  ## Why you can check it
425
436
 
426
- - **No dependencies and no install scripts.** Plain files, readable
437
+ - **No npm dependencies and no install scripts.** Plain files, readable
427
438
  in an afternoon: `worktrust.mjs` (this command), `setup-mcp.mjs` (writes the MCP entries),
428
439
  `log-session.mjs` (the session hook), `count-behaviour.mjs` (the local counter) and `preserve.mjs`
429
440
  (keep your history), with the readers they import.
430
441
  - **Bundled measurement modules.** The npm package includes its counter and readers. Interactive
431
- commands can check the registry and relay through `npx` to a newer package; that can download code.
432
- The standalone bootstrap can also download support modules. See SECURITY.md for the distinction.
442
+ commands can check the registry for a version notice; they no longer execute another npm
443
+ version automatically. Installation stays with the selected package manager. See SECURITY.md.
433
444
  - **Provenance.** The release workflow requests npm provenance from the public source repository.
434
445
  Verify the actual version's attestation and contents before relying on that origin; the manifest
435
446
  setting alone does not establish it. `npm audit signatures` checks an installed dependency tree.
@@ -479,3 +490,23 @@ The licence is free of charge. `preserve` (with `--apply`, `--archive`, `--verif
479
490
  with or without an account; every other feature is for WorkTrust account holders, and without an account the rest may
480
491
  only be installed and evaluated. The archives and files the CLI makes from your own data are yours.
481
492
  From 0.10.18 on; versions up to and including 0.10.17 were published under the MIT licence and stay under it.
493
+
494
+ ## Release signatures and the limits of verification
495
+
496
+ From 0.10.22, the official launcher verifies fixed release files through `worktrust-launch.mjs` before
497
+ starting the shared engine. Python uses the `pycryptodomex` library to verify its package and
498
+ bundled runtime before Node executes. Final npm/Python/source/preservation downloads are
499
+ covered by an Ed25519-signed `release-artifacts.json`, containing their SHA-256 values and the
500
+ source commit. Verify against the separately pinned publisher key, not a key supplied by the manifest.
501
+
502
+ The initial package-manager installation and host interpreter are trusted bootstrap boundaries.
503
+ A computer owner can alter or bypass a launcher; software signatures do not attest execution.
504
+
505
+ Local Claude records and other client activity are outside this release manifest. An official
506
+ CLI can read edited input. `cli_digest` remains client-reported diagnostic metadata and cannot
507
+ prove which program ran. SHA-256/SHA-512 are not encryption; HTTPS protects transport. Public
508
+ claim eligibility remains the server publication gate's responsibility.
509
+
510
+ Revoking a computer key stops new submissions, not the validity of every historical publication.
511
+ Passport withdrawal is a separate audited operation. Neither operation automatically erases the
512
+ person's prior data. Release signing keys, computer keys and passport signing keys are separate.
package/SECURITY.md CHANGED
@@ -12,7 +12,7 @@ private transcripts or account data in a public issue.
12
12
  A setup dry run is not a sandbox for the whole invocation: the standalone bootstrap can download
13
13
  scripts first, and the interactive entry can check for a newer release.
14
14
  - Submissions go to the configured WorkTrust MCP endpoint. Interactive commands can also contact
15
- the npm registry and relay through `npx` to a newer version. The npm package bundles its runtime
15
+ the npm registry for a version notice. The unpublished patch based on 0.10.21 no longer executes a newer version from that notice. The npm package bundles its runtime
16
16
  modules, but installation and automatic relay still use the network. `preserve` itself is local.
17
17
  A custom `--origin`, URL or registry override changes whom you trust.
18
18
  - The key it receives is a WorkTrust coupling for this computer: it can submit work metadata to your
@@ -78,6 +78,13 @@ are resource bounds, not a sandbox or independent validation of the export's tru
78
78
 
79
79
  ## Verifying a version
80
80
 
81
+ The unpublished maintenance patch based on 0.10.21 removes automatic execution based only on a newer registry
82
+ version string. The separate signed release/receipt components in the monorepo's
83
+ `tools/worktrust-release` are engineering candidates: production signing keys, final artifact
84
+ signing and npm/Python launcher integration are not yet provisioned. The current Python bundle
85
+ manifest detects file corruption but is not itself an authenticated WorkTrust release signature.
86
+ Do not treat its matching SHA-256 values as proof that modified input describes genuine work.
87
+
81
88
  The release configuration names https://github.com/fhomey/worktrust-cli and requests npm provenance.
82
89
  Check the particular published version's attestation and compare its contents to that commit before
83
90
  relying on those properties. A manifest flag or matching version string alone is not proof that an
@@ -0,0 +1 @@
1
+ {"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","history-outbox.mjs":"1bdca17b807c76e4a8e7bf42c6f07e12e8ae8e4466417cafdd26b1f58bf178a5","log-session.mjs":"6098eedb253b165819fdb4293adb6ddaa6c5843db0bbb007759701918955f664","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"b9d81dc88cf5c19ccfbf334a7af84a0c4e299a0e9e4d4091132253e22f855dc3","preserve-lines.mjs":"18081b745b8c47838448b0a49a129a363e29d3f2f5207bc591187d860157b456","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"38f83bd933853a986fef61f4e452c27d4a3adc6000f5c9201ef70f270b404eac","runtime-install.mjs":"b9d2e4febbf400a679eeb3a14b74eef6c2062c5b626d45872a193b7502d3201c","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"70f63b61cf1e28fb2b7471e7768d596b0cf166ccdc9d1ce859ee58d29b2ecabc","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5b31a6f29b785d277e92257532f3c7cee366a79759decc7a75cfbaec2686ee13","transcript-readers.mjs":"413948644a74dc0bf1b49548be193bf596bcf82ac7eae668f624345a18e189e7","worktrust-launch.mjs":"f28f699f986c72d99af8a7542d317f6dbb9e26d114f6ad083013567e08b8a650","worktrust.mjs":"c1cce642ba2ef4099b0fc3d375a4f8e8cb669b6694b0c99f08164a38d5d943d9"},"format":"worktrust-package/1","kind":"engine","version":"0.10.24"},"signature":"P-IcgjGPwCdX-87Wlbc23kMzU2cCdBr15y84UdbYqJX7miLCLqdQX_gLaYrj7GdyqxwvBP2ryBtCQMm8LjTlDA"}
@@ -0,0 +1,93 @@
1
+ /** Local metadata queue. Never reads transcripts, credentials or the network; preserve does not load it. */
2
+ import {createHash,randomBytes} from 'node:crypto';
3
+ import {existsSync,lstatSync,mkdirSync,readdirSync,readFileSync,openSync,writeFileSync,fsyncSync,closeSync,renameSync,unlinkSync,constants} from 'node:fs';
4
+ import {join} from 'node:path';
5
+ import {homedir} from 'node:os';
6
+ const MAX_RETRY_SECONDS=24*60*60;
7
+ const digest=s=>createHash('sha256').update(s).digest('hex');
8
+ const scopeOf=target=>digest(target.url+'\0'+(target.token===process.env.WORKTRUST_MCP_TOKEN && /^[a-f0-9]{64}$/.test(process.env.WORKTRUST_HISTORY_SCOPE??'') ? 'device:'+process.env.WORKTRUST_HISTORY_SCOPE : 'token:'+target.token));
9
+ const regular=p=>{const s=lstatSync(p);if(s.isSymbolicLink()||!s.isFile())throw Error('HISTORY_QUEUE_UNSAFE');return s;};
10
+ function directory(p) {if(!existsSync(p))mkdirSync(p,{mode:0o700});const s=lstatSync(p);if(s.isSymbolicLink()||!s.isDirectory())throw Error('HISTORY_QUEUE_UNSAFE');}
11
+ function write(p,value) {
12
+ const temporary=p+'.'+randomBytes(8).toString('hex')+'.tmp';
13
+ const fd=openSync(temporary,constants.O_CREAT|constants.O_EXCL|constants.O_WRONLY|(constants.O_NOFOLLOW??0),0o600);
14
+ try {writeFileSync(fd,JSON.stringify(value));fsyncSync(fd);}finally{closeSync(fd);}
15
+ try {if(existsSync(p))regular(p);renameSync(temporary,p);}finally{if(existsSync(temporary))unlinkSync(temporary);}
16
+ }
17
+ /** Serialize local space reservations; never wait in a hook for another process. */
18
+ function reservation(root,run) {
19
+ const path=join(root,'.reservation');let fd;
20
+ try {fd=openSync(path,constants.O_CREAT|constants.O_EXCL|constants.O_WRONLY,0o600);}
21
+ catch(error) {
22
+ if(error.code!=='EEXIST')throw error;
23
+ const lock=read(path),before=regular(path);
24
+ if(!Number.isSafeInteger(lock?.pid)||lock.pid<=0)throw Error('HISTORY_QUEUE_BUSY');
25
+ try{process.kill(lock.pid,0);throw Error('HISTORY_QUEUE_BUSY');}
26
+ catch(error){if(error.code!=='ESRCH')throw Error('HISTORY_QUEUE_BUSY');}
27
+ if(regular(path).ino!==before.ino)throw Error('HISTORY_QUEUE_BUSY');
28
+ unlinkSync(path);return reservation(root,run);
29
+ }
30
+ try{writeFileSync(fd,JSON.stringify({pid:process.pid}));fsyncSync(fd);return run();}
31
+ finally{closeSync(fd);unlinkSync(path);}
32
+ }
33
+ function read(p) {if(!existsSync(p))return null;if(regular(p).size>4_500_000)throw Error('HISTORY_QUEUE_UNSAFE');return JSON.parse(readFileSync(p,'utf8'));}
34
+ export function queuedHistory(target,body,source) {
35
+ const home=join(homedir(),'.worktrust');directory(home);
36
+ const root=join(home,'history-outbox');directory(root);
37
+ // No bearer, endpoint, local path or user content is stored as an identifier.
38
+ const scope=scopeOf(target),id=digest(scope+'\0'+source+'\0'+body);
39
+ const request=join(root,id+'.request.json'),ack=join(root,id+'.ack.json'),state=join(root,id+'.state.json');
40
+ const acknowledged=read(ack);
41
+ if(acknowledged?.id===id)return {status:'acknowledged',confirm(){},defer(){}};
42
+ const current=read(state);
43
+ reservation(root,()=>{
44
+ if(!existsSync(request)) {
45
+ const files=readdirSync(root);let bytes=0,pending=0;
46
+ for(const file of files) {const stat=regular(join(root,file));bytes+=stat.size;if(file.endsWith('.request.json'))pending++;}
47
+ if(files.length>=12000||pending>=512||bytes+Buffer.byteLength(JSON.stringify({id,scope,source,body}))+1024>64*1024*1024)throw Error('HISTORY_QUEUE_FULL');
48
+ write(request,{id,scope,source,body});
49
+ } else if(read(request)?.body!==body)throw Error('HISTORY_QUEUE_CHANGED');
50
+ });
51
+ const status=current?.status==='review'?'review':Number(current?.retryAt)>Date.now()?'waiting':'pending';
52
+ return {status,retryAt:current?.retryAt??null,
53
+ confirm(){write(ack,{id,confirmedAt:new Date().toISOString()});if(existsSync(request)){regular(request);unlinkSync(request);}if(existsSync(state)){regular(state);unlinkSync(state);}},
54
+ defer(reason,seconds=0){if(existsSync(ack))return;write(state,{id,status:reason==='review'?'review':'retry',retryAt:Date.now()+Math.max(0,Math.min(MAX_RETRY_SECONDS,seconds))*1000});},
55
+ };
56
+ }
57
+ export function historyRefusal(text,response) {
58
+ let rpc;
59
+ try {rpc=JSON.parse(text.trim().startsWith('{')?text:text.split(/\r?\n/).find(s=>s.startsWith('data:'))?.slice(5));}catch{/* Unknown reply stays retryable, never acknowledged. */}
60
+ const review=rpc?.id===1 && (rpc?.error?.data?.outcome==='review' || String(rpc?.error?.message??'').startsWith('history replacement held for review:'));
61
+ const raw=Number(response.headers.get('retry-after'));
62
+ return {reason:review?'review':response.status===429?'capacity':'unconfirmed',seconds:Number.isFinite(raw)&&raw>0?Math.min(MAX_RETRY_SECONDS,raw):0};
63
+ }
64
+
65
+ /** Explicit recovery, even after the AI client removed its source files. A changed account/key
66
+ * cannot replay another coupling's pending data. Review is retried only on an explicit request. */
67
+ export async function resumeHistory(target, {send, confirmed, note, retryReview=false, dry=false}) {
68
+ const root=join(homedir(),'.worktrust','history-outbox'),scope=scopeOf(target);
69
+ const totals={received:0,review:0,waiting:0,batches:0};let paused=null;
70
+ if(!existsSync(root))return totals;
71
+ directory(root);
72
+ const files=readdirSync(root);if(files.length>12000)throw Error('HISTORY_QUEUE_FULL');
73
+ for(const file of files.sort()) {
74
+ if(!/^[a-f0-9]{64}\.request\.json$/.test(file))continue;
75
+ const item=read(join(root,file));if(item?.scope!==scope)continue;
76
+ if(typeof item.body!=='string'||typeof item.source!=='string'||item.id!==digest(scope+'\0'+item.source+'\0'+item.body)||file!==item.id+'.request.json')throw Error('HISTORY_QUEUE_CHANGED');
77
+ const rpc=JSON.parse(item.body),entries=rpc?.params?.arguments?.entries;
78
+ if(rpc.jsonrpc!=='2.0'||rpc.id!==1||rpc.method!=='tools/call'||rpc.params.name!=='import_history'||!Array.isArray(entries)||!entries.length||entries.length>200)throw Error('HISTORY_QUEUE_CHANGED');
79
+ const queued=queuedHistory(target,item.body,item.source);totals.batches++;
80
+ if(queued.status==='acknowledged')continue;
81
+ if(queued.status==='review'&&!retryReview){totals.review+=entries.length;continue;}
82
+ if(dry){totals.waiting+=entries.length;continue;}
83
+ if(queued.status==='waiting'&&!paused)paused={reason:'unconfirmed',seconds:Math.max(1,Math.ceil((queued.retryAt-Date.now())/1000))};
84
+ if(paused){if(queued.status==='review'){totals.review+=entries.length;continue;}queued.defer(paused.reason,paused.seconds);totals.waiting+=entries.length;continue;}
85
+ try {
86
+ const response=await send(item.body,item.source),text=await response.text();
87
+ try{if(!response.ok)throw Error();confirmed(text,entries.length);}
88
+ catch{const refusal=historyRefusal(text,response);if(refusal.reason!=='review')paused={reason:refusal.reason,seconds:refusal.seconds>0?refusal.seconds:5};queued.defer(refusal.reason,paused?.seconds??refusal.seconds);totals[refusal.reason==='review'?'review':'waiting']+=entries.length;continue;}
89
+ queued.confirm();totals.received+=entries.length;note(text);
90
+ }catch{paused={reason:'unconfirmed',seconds:5};queued.defer(paused.reason,paused.seconds);totals.waiting+=entries.length;}
91
+ }
92
+ return totals;
93
+ }
package/log-session.mjs CHANGED
@@ -90,12 +90,7 @@ const PINNED = join(homedir(), ".worktrust", "pinned");
90
90
  const ours = (command) => /log-session|worktrust\.mjs" hook|worktrust\.mjs hook/.test(String(command ?? ""));
91
91
  const COUNTER_EVERY_MS = 24 * 3600_000;
92
92
  /**
93
- * THE COUNTER KEEPS UP WITH THE DEPLOYMENT. The install fetched it once and never again, so a
94
- * machine set up in August counted with an August rubric in September while the door already
95
- * spoke a newer vocabulary. Now the version stamped in the local copy is compared with the one the
96
- * deployment serves — numerically, the way the door picks its newest rubric — and a newer copy
97
- * replaces the old one. A rubric bump is what makes the previous reading superseded on the
98
- * mirror; this is how the machine hears about it. Nothing else is read off the network here.
93
+ * Counter compatibility is pinned by the verified release.
99
94
  */
100
95
  const versionOf = (text) => /export const ANALYZER_VERSION = "counter@(\d+)\.(\d+)\.(\d+)"/.exec(text ?? "")?.slice(1, 4).map(Number) ?? null;
101
96
  const newer = (a, b) => { if (!a || !b) return false; for (let i = 0; i < 3; i += 1) { if (a[i] === b[i]) continue; return a[i] > b[i]; } return false; };
@@ -258,7 +253,7 @@ const { stackOfFiles = () => [], displayStackOfFiles = () => [] } = (await impor
258
253
  const EXPORT_PATHS = []; for (let i = 0; i < args.length; i += 1) if (args[i] === "--export" && args[i + 1]) EXPORT_PATHS.push(args[i + 1]);
259
254
  const DATABASE_CLIENTS = ["hermes", "goose", "opencode", "openclaw", "cursor", "copilot"]; // the registry's keys, the name each line carries
260
255
  const LIVE_SOURCE = new RegExp(`^(codex|antigravity|${DATABASE_CLIENTS.join("|")}):`); // a sweep entry's id → the client it names (every database client, 0.6.16)
261
- const READER_FILES = ["transcript-readers.mjs", "session-databases.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "claude-mod.mjs"]; // 0.7.4: the derived record travels with the hook; 0.10.10: the export reader; 0.10.11: the stack rules; 0.10.15: the mod
256
+ const READER_FILES = ["history-outbox.mjs", "transcript-readers.mjs", "session-databases.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "claude-mod.mjs"]; // 0.7.4: the derived record travels with the hook; 0.10.10: the export reader; 0.10.11: the stack rules; 0.10.15: the mod
262
257
  /** The readers go where the hook and the counter run: copied from beside this file, else (or for a newer counter) from the deployment. */
263
258
  async function installReaders(origin, fromNetwork = false) {
264
259
  let installed = true;
@@ -735,31 +730,44 @@ function retainMeasurement(payload, source) {
735
730
  }
736
731
  } finally { closeSync(fd); unlinkSync(temporary); }
737
732
  }
733
+ const HISTORY_DELIVERY = { review: 0, waiting: 0 };
738
734
  async function sendHistory(door, entries, announce = false, rebuild = false, named = false, { byDay = false, withdrawUnknown = false } = {}) {
739
735
  let accepted = 0;
740
- // A Codex entry goes through Codex's own coupling where one exists (see codexDoor), the rest
741
- // through the door given: the record files a line under the coupling that sent it. Antigravity's
742
- // go apart too, so their batch can name the client (clientOf).
743
- // An export's lines go as their own group too (0.10.10), so the record names the product (ChatGPT, Claude on the web).
744
- for (const [source, group] of [["claude", entries.filter((entry) => !entrySource.has(entry))], ["codex", entries.filter((entry) => entrySource.get(entry) === "codex")], ...["antigravity", ...DATABASE_CLIENTS, ...EXPORT_CLIENTS].map((client) => [client, entries.filter((entry) => entrySource.get(entry) === client)])]) {
736
+ const { queuedHistory, historyRefusal } = await import("./history-outbox.mjs");
737
+ // Keep each source and its approved coupling separate.
738
+ const groups = [["claude", entries.filter((entry) => !entrySource.has(entry))], ["codex", entries.filter((entry) => entrySource.get(entry) === "codex")], ...["antigravity", ...DATABASE_CLIENTS, ...EXPORT_CLIENTS].map((client) => [client, entries.filter((entry) => entrySource.get(entry) === client)])];
739
+ const encodeBatch = batch => JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "import_history", arguments: { ...(rebuild ? { rebuild: true } : {}), ...(withdrawUnknown ? { withdraw_unknown: true } : {}), entries: batch.map(({commits, ...rest}) => { void commits; return rest; }) } } });
740
+ // Persist the approved plan before sending, so later batches survive removed source files too.
741
+ try { for (const [source, group] of groups) { const target = source === "codex" ? codexDoor ?? door : door; if (target) for (const batch of batchesOf(group, byDay)) queuedHistory(target, encodeBatch(batch), source); } }
742
+ catch { console.error("History queue is full, busy or unavailable. Resume the saved batches before retrying this import; nothing was marked complete."); HISTORY_DELIVERY.waiting += entries.length; return 0; }
743
+ for (const [source, group] of groups) {
745
744
  const target = source === "codex" ? codexDoor ?? door : door;
746
745
  if (group.length === 0 || !target) continue;
747
746
  let number = 0;
748
747
  for (const batch of batchesOf(group, byDay)) {
749
748
  number += 1;
750
- // History carries no shas: an imported line forms no session, and the join is the live route's. REBUILD (owner, 2026-10-07): `rebuild: true`
751
- // tells the door to replace this computer's earlier lines on the days and for the client the batch carries, and every group names its client.
752
- // WITHDRAW UNKNOWN (owner, 2026-10-10): with an export, after the person's yes, `withdraw_unknown: true` also withdraws the AI-app lines on its days.
753
- const body = JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "import_history", arguments: { ...(rebuild ? { rebuild: true } : {}), ...(withdrawUnknown ? { withdraw_unknown: true } : {}), entries: batch.map((entry) => { const { commits, ...rest } = entry; void commits; return rest; }) } } });
749
+ // Imported entries carry no live commit/session join.
750
+ const body = encodeBatch(batch);
754
751
  for (const entry of batch) retainMeasurement(entry, source);
755
752
  // `named` (0.10.10): a copied folder's lines name their client too, so the record says which app the copy came from.
756
- const response = await fetch(target.url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${target.token}`, ...clientOf(source, rebuild || named), ...proofFor(target.url, body) }, body });
757
- const text = await response.text();
758
- if (announce) console.log(`batch ${number}: ${response.status} ${text.slice(0, 200).replace(/\\n/g, " ")}`);
759
- if (!response.ok) break;
760
- try { confirmedReceipt(text, batch.length); } catch { break; }
761
- accepted += batch.length;
762
- noteReceipt(text);
753
+ let queued;
754
+ try { queued = queuedHistory(target, body, source); }
755
+ catch { console.error("Pending history could not be stored safely. Nothing was marked complete; keep the local WorkTrust folder for recovery."); HISTORY_DELIVERY.waiting += batch.length; break; }
756
+ if (queued.status === "acknowledged" && !byDay) { accepted += batch.length; RECEIPTS.alreadyHeld += batch.length; continue; }
757
+ if (queued.status === "review" && !flag("retry-review")) { HISTORY_DELIVERY.review += batch.length; continue; }
758
+ if (queued.status === "waiting") { HISTORY_DELIVERY.waiting += batch.length; continue; }
759
+ try {
760
+ const response = await fetch(target.url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${target.token}`, ...clientOf(source, rebuild || named), ...proofFor(target.url, body) }, body, redirect: "error", signal: AbortSignal.timeout(65_000) });
761
+ const text = await response.text();
762
+ try { if (!response.ok) throw Error(); confirmedReceipt(text, batch.length); }
763
+ catch {
764
+ const refusal = historyRefusal(text, response); queued.defer(refusal.reason, refusal.seconds);
765
+ if (refusal.reason === "review") { HISTORY_DELIVERY.review += batch.length; continue; }
766
+ HISTORY_DELIVERY.waiting += batch.length; break;
767
+ }
768
+ queued.confirm(); accepted += batch.length; noteReceipt(text);
769
+ if (announce) console.log(`batch ${number}: received ${batch.length}`);
770
+ } catch { queued.defer("unconfirmed"); HISTORY_DELIVERY.waiting += batch.length; break; }
763
771
  }
764
772
  }
765
773
  return accepted;
@@ -792,7 +800,7 @@ const proofFor = (url, body) => {
792
800
  * on this computer, and the door names a coupling's clients by the user-agent it hears (mcp_identify's
793
801
  * agents_seen). An Antigravity line names Antigravity: the product name, nothing of the work.
794
802
  */
795
- const clientOf = (source, always = false) => (always || source === "antigravity" || DATABASE_CLIENTS.includes(source) || EXPORT_CLIENTS.includes(source) ? { "user-agent": `${source ?? "claude"}/hook (worktrust-hook)` } : {});
803
+ const clientOf = (source, always = false) => (CLI_VERSION_SENT || always || source === "antigravity" || DATABASE_CLIENTS.includes(source) || EXPORT_CLIENTS.includes(source) ? { "user-agent": `${source ?? "claude"}/hook (worktrust-hook)${CLI_VERSION_SENT ? ` worktrust-cli/${CLI_VERSION_SENT}` : ""}` } : {});
796
804
 
797
805
  async function send(door, payload) {
798
806
  retainMeasurement(payload, entrySource.get(payload));
@@ -1201,6 +1209,21 @@ if (!door && !codexDoor && !DRY) { return await exitFlushed(0); } // Not coupled
1201
1209
  * device key (only lines this computer signed travel), an archive that verifies, a stretch whose session is gone from
1202
1210
  * this computer (one still here goes through the ordinary history), a door that knows the mark, and the person asking.
1203
1211
  */
1212
+ if (flag("history") && flag("resume")) {
1213
+ const { resumeHistory } = await import("./history-outbox.mjs");
1214
+ const totals = { received: 0, review: 0, waiting: 0, batches: 0 };
1215
+ try {
1216
+ for (const target of [door, ...(codexDoor && codexDoor.token !== door?.token ? [codexDoor] : [])].filter(Boolean)) {
1217
+ const result = await resumeHistory(target, { dry: DRY, retryReview: flag("retry-review"), confirmed: confirmedReceipt, note: noteReceipt,
1218
+ send: (body, source) => fetch(target.url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${target.token}`, ...clientOf(source, true), ...proofFor(target.url, body) }, body, redirect: "error", signal: AbortSignal.timeout(65_000) }),
1219
+ });
1220
+ for (const key of Object.keys(totals)) totals[key] += result[key];
1221
+ }
1222
+ console.log(JSON.stringify({ resumed: totals.received, ...totals, ...RECEIPTS }));
1223
+ return await exitFlushed(DRY || (!totals.waiting && !totals.review) ? 0 : 1);
1224
+ } catch { console.log("Pending history could not be read safely. Nothing was marked complete; keep the local WorkTrust folder for recovery."); return await exitFlushed(1); }
1225
+ }
1226
+
1204
1227
  if (flag("history") && flag("from-archive")) {
1205
1228
  const named = value("from-archive"), dir = named && !named.startsWith("--") ? named.replace(/^~(?=\/|$)/, homedir()) : join(homedir(), "AI-Evidence");
1206
1229
  const say = (text) => console.log(text);
@@ -1262,7 +1285,7 @@ if (flag("history")) {
1262
1285
  // An export that arrived whole is remembered by its digest (never by a conversation), so the bare command offers it no more.
1263
1286
  if (fromExports && accepted === entries.length) for (const report of fromExports.reports) rememberExport(report.digest, { vendor: report.vendor, sent: true, at: new Date().toISOString(), conversations: report.conversations });
1264
1287
  // ONE LINE FOR THE COMMAND TO ASK WITH (2026-10-10): what the door replaced, how many AI-app lines lie on the export's days, how many it withdrew.
1265
- if (fromExports) console.log(JSON.stringify({ export_sent: accepted, of: entries.length, ...RECEIPTS })); else console.log(JSON.stringify({ history_sent: accepted, of: entries.length, ...RECEIPTS })); // the same line for a history send: what the door did with it, and WorkTrust's measuredSeconds for what it stored
1288
+ if (fromExports) console.log(JSON.stringify({ export_sent: accepted, of: entries.length, ...RECEIPTS })); else console.log(JSON.stringify({ history_sent: accepted, of: entries.length, ...RECEIPTS, delivery: HISTORY_DELIVERY })); // the same line for a history send: what the door did with it, and WorkTrust's measuredSeconds for what it stored
1266
1289
  return await exitFlushed(accepted === entries.length ? 0 : 1);
1267
1290
  }
1268
1291
 
@@ -0,0 +1,82 @@
1
+ /** Official launcher verification. Pinned keys are generated from reviewed release configuration. */
2
+ import { createHash, createPublicKey, verify, randomBytes } from 'node:crypto';
3
+ import { existsSync, lstatSync, readFileSync, readdirSync, mkdirSync, writeFileSync, renameSync, rmSync } from 'node:fs';
4
+ import { join, dirname } from 'node:path';
5
+
6
+ export const RELEASE_KEYS = {"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5":"-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAxe/h8yLe+e4iKYSx/2lzS7MgHIgzM+mi1XjofW1VKo4=\n-----END PUBLIC KEY-----\n"}; // GENERATED_RELEASE_KEYS
7
+ const hash = bytes => createHash('sha256').update(bytes).digest('hex');
8
+ const canonical = value => {
9
+ if (value === null || typeof value === 'boolean' || typeof value === 'string') return JSON.stringify(value);
10
+ if (typeof value === 'number' && Number.isSafeInteger(value)) return String(value);
11
+ if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
12
+ if (value && Object.getPrototypeOf(value) === Object.prototype) return `{${Object.keys(value).sort().map(k => `${JSON.stringify(k)}:${canonical(value[k])}`).join(',')}}`;
13
+ throw Error('PACKAGE_INVALID_MANIFEST');
14
+ };
15
+ const exact = (value, keys) => value && Object.keys(value).sort().join(',') === keys.sort().join(',');
16
+ const safe = name => {
17
+ if (typeof name !== 'string' || name.length > 240) return false;
18
+ const parts = name.split('/');
19
+ return parts.every((p, i) => (/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(p) && p !== '..')
20
+ || (p === '.claude-plugin' && i > 0 && i < parts.length - 1 && parts[i - 1] === 'agent'));
21
+ };
22
+ function regular(path) {
23
+ const s = lstatSync(path);
24
+ if (s.isSymbolicLink() || !s.isFile()) throw Error('PACKAGE_NON_REGULAR_FILE');
25
+ return s;
26
+ }
27
+ function filesIn(root, prefix = '') {
28
+ const s = lstatSync(root);
29
+ if (s.isSymbolicLink() || !s.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY');
30
+ return readdirSync(root).flatMap(name => {
31
+ const path = join(root, name), stat = lstatSync(path);
32
+ if (stat.isSymbolicLink()) throw Error('PACKAGE_NON_REGULAR_FILE');
33
+ return stat.isDirectory() ? filesIn(path, prefix + name + '/') : [prefix + name];
34
+ });
35
+ }
36
+ export function verifyPackage(root, kind = 'npm') {
37
+ const signatureName = kind === 'engine' ? 'engine-release.json' : 'package-release.json';
38
+ const path = join(root, signatureName);
39
+ if (regular(path).size > 1024 * 1024) throw Error('PACKAGE_MANIFEST_TOO_LARGE');
40
+ const signed = JSON.parse(readFileSync(path, 'utf8'));
41
+ if (!exact(signed, ['keyId', 'payload', 'signature']) || !Object.hasOwn(RELEASE_KEYS, signed.keyId) || !/^[A-Za-z0-9_-]{86}$/.test(signed.signature)) throw Error('PACKAGE_UNTRUSTED_SIGNATURE');
42
+ const pem = RELEASE_KEYS[signed.keyId], key = createPublicKey(pem);
43
+ if (key.asymmetricKeyType !== 'ed25519' || hash(key.export({ format: 'der', type: 'spki' })) !== signed.keyId
44
+ || !verify(null, Buffer.from('worktrust:package:1\n' + canonical(signed.payload)), key, Buffer.from(signed.signature, 'base64url'))) throw Error('PACKAGE_UNTRUSTED_SIGNATURE');
45
+ const m = signed.payload;
46
+ if (!exact(m, ['format', 'kind', 'version', 'files']) || m.format !== 'worktrust-package/1' || m.kind !== kind || !/^\d+\.\d+\.\d+$/.test(m.version)
47
+ || !m.files || Array.isArray(m.files) || typeof m.files !== 'object' || Object.keys(m.files).length > 2000 || !Object.hasOwn(m.files, 'worktrust.mjs')) throw Error('PACKAGE_INVALID_MANIFEST');
48
+ const expected = Object.keys(m.files).sort();
49
+ for (const name of expected) {
50
+ if (!safe(name) || name === signatureName || !/^[a-f0-9]{64}$/.test(m.files[name])) throw Error('PACKAGE_INVALID_MANIFEST');
51
+ let parent = root;
52
+ for (const part of name.split('/').slice(0, -1)) { parent = join(parent, part); const s = lstatSync(parent); if (s.isSymbolicLink() || !s.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY'); }
53
+ const file = join(root, name);
54
+ if (regular(file).size > 128 * 1024 * 1024 || hash(readFileSync(file)) !== m.files[name]) throw Error('PACKAGE_FILE_CHANGED');
55
+ }
56
+ const found = filesIn(root).filter(name => name !== signatureName && (kind !== 'engine' || name.endsWith('.mjs'))).sort();
57
+ if (JSON.stringify(found) !== JSON.stringify(expected)) throw Error('PACKAGE_FILE_LIST_CHANGED');
58
+ if (/const CLI_VERSION = "([^"]+)";/.exec(readFileSync(join(root, 'worktrust.mjs'), 'utf8'))?.[1] !== m.version) throw Error('PACKAGE_VERSION_MISMATCH');
59
+ return { manifest: m, identity: hash(readFileSync(path)), signatureName };
60
+ }
61
+ export function installSignedPackage(source, home) {
62
+ const checked = verifyPackage(source), store = join(home, 'verified');
63
+ if (!existsSync(home)) mkdirSync(home, { mode: 0o700 });
64
+ const owned = lstatSync(home);
65
+ if (owned.isSymbolicLink() || !owned.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY');
66
+ if (!existsSync(store)) mkdirSync(store, { mode: 0o700 });
67
+ const stored = lstatSync(store);
68
+ if (stored.isSymbolicLink() || !stored.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY');
69
+ const target = join(store, checked.identity);
70
+ if (existsSync(target)) { if (verifyPackage(target).identity !== checked.identity) throw Error('PACKAGE_INSTALLATION_IDENTITY_MISMATCH'); return join(target, 'worktrust-launch.mjs'); }
71
+ const pending = join(store, '.pending-' + randomBytes(16).toString('hex'));
72
+ mkdirSync(pending, { mode: 0o700 });
73
+ try {
74
+ for (const name of [...Object.keys(checked.manifest.files), checked.signatureName]) {
75
+ const path = join(pending, name); mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
76
+ writeFileSync(path, readFileSync(join(source, name)), { flag: 'wx', mode: 0o600 });
77
+ }
78
+ if (verifyPackage(pending).identity !== checked.identity) throw Error('PACKAGE_INSTALLATION_IDENTITY_MISMATCH');
79
+ try { renameSync(pending, target); } catch (error) { if (!existsSync(target)) throw error; if (verifyPackage(target).identity !== checked.identity) throw Error('PACKAGE_INSTALLATION_IDENTITY_MISMATCH'); }
80
+ } finally { rmSync(pending, { recursive: true, force: true }); }
81
+ return join(target, 'worktrust-launch.mjs');
82
+ }
@@ -0,0 +1 @@
1
+ {"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"d1db152d88338df23b5900beed6a69bedc2900b6f53fef3f036b46dd7a07b841","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"3096ed1693974a90e1f4f59bf01c9559d94a7941d933e36fb81d3995a97f25c1","README.md":"d6db7aff9f8c6ff8da1c67e9f16aa8ebf4a55efc21265e16c81b6408237ab056","SECURITY.md":"e3ed1927cbceef97b38ca630aadd0a91a0df02368f822f4fd66e3ed0b6a07e8d","chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","engine-release.json":"c31900cf37fb8ff571190ef1235fab4bed57007fc8c111e701da26dc5ad6dc90","history-outbox.mjs":"1bdca17b807c76e4a8e7bf42c6f07e12e8ae8e4466417cafdd26b1f58bf178a5","log-session.mjs":"6098eedb253b165819fdb4293adb6ddaa6c5843db0bbb007759701918955f664","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"b9d81dc88cf5c19ccfbf334a7af84a0c4e299a0e9e4d4091132253e22f855dc3","package.json":"e2994c95ae40d276855b29263b3f284baccd1536f84db44a29259757dcf46b99","preserve-lines.mjs":"18081b745b8c47838448b0a49a129a363e29d3f2f5207bc591187d860157b456","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"38f83bd933853a986fef61f4e452c27d4a3adc6000f5c9201ef70f270b404eac","runtime-install.mjs":"b9d2e4febbf400a679eeb3a14b74eef6c2062c5b626d45872a193b7502d3201c","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"70f63b61cf1e28fb2b7471e7768d596b0cf166ccdc9d1ce859ee58d29b2ecabc","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5b31a6f29b785d277e92257532f3c7cee366a79759decc7a75cfbaec2686ee13","transcript-readers.mjs":"413948644a74dc0bf1b49548be193bf596bcf82ac7eae668f624345a18e189e7","worktrust-launch.mjs":"f28f699f986c72d99af8a7542d317f6dbb9e26d114f6ad083013567e08b8a650","worktrust.mjs":"c1cce642ba2ef4099b0fc3d375a4f8e8cb669b6694b0c99f08164a38d5d943d9"},"format":"worktrust-package/1","kind":"npm","version":"0.10.24"},"signature":"L6nxsuFrIoXcxsVvNrPkxkMV_woNpE5IGJLWjsvwGKdxtUkq2P6Foe7r2HmWavXleroNIcWcPf4CljteUCO9CQ"}
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "worktrust",
3
- "version": "0.10.21",
3
+ "version": "0.10.24",
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": {
7
- "worktrust": "worktrust.mjs"
7
+ "worktrust": "worktrust-launch.mjs"
8
8
  },
9
9
  "files": [
10
10
  "worktrust.mjs",
@@ -29,7 +29,12 @@
29
29
  "orchestration-contract.mjs",
30
30
  "orchestration-evidence.mjs",
31
31
  "orchestration-report.mjs",
32
- "claude-mod.mjs"
32
+ "claude-mod.mjs",
33
+ "package-integrity.mjs",
34
+ "worktrust-launch.mjs",
35
+ "engine-release.json",
36
+ "package-release.json",
37
+ "history-outbox.mjs"
33
38
  ],
34
39
  "engines": {
35
40
  "node": ">=18"
@@ -30,6 +30,7 @@ export function installRuntime(runtime, engine, home, moduleNames) {
30
30
  if (!/^[a-z][a-z0-9-]*\.mjs$/.test(name)) throw Error("invalid engine module name");
31
31
  contents.set(`engine/${name}`, checkedBytes(join(engine, name)));
32
32
  }
33
+ if (existsSync(join(engine, "engine-release.json"))) contents.set("engine/engine-release.json", checkedBytes(join(engine, "engine-release.json")));
33
34
  const identities = Object.fromEntries([...contents].map(([name, bytes]) => [name, hash(bytes)]));
34
35
  const identity = Buffer.from(JSON.stringify(identities));
35
36
  const installations = join(home, "installations"), installed = join(installations, hash(identity));
@@ -60,5 +61,5 @@ export function installRuntime(runtime, engine, home, moduleNames) {
60
61
  } finally { rmSync(temporary, { recursive: true, force: true }); }
61
62
  }
62
63
  // Existing immutable directories are never replaced, including executables used by Windows processes.
63
- return { executable: join(installed, "runtime", executable), bridge: join(installed, "engine", "worktrust.mjs") };
64
+ return { executable: join(installed, "runtime", executable), bridge: join(installed, "engine", contents.has("engine/engine-release.json") ? "worktrust-launch.mjs" : "worktrust.mjs") };
64
65
  }
@@ -0,0 +1,96 @@
1
+ #!/usr/bin/env node
2
+ // GENERATED by scripts/build-cli-launchers.mjs; verify before importing any local module.
3
+ /** Official launcher verification. Pinned keys are generated from reviewed release configuration. */
4
+ import { createHash, createPublicKey, verify, randomBytes } from 'node:crypto';
5
+ import { existsSync, lstatSync, readFileSync, readdirSync, mkdirSync, writeFileSync, renameSync, rmSync } from 'node:fs';
6
+ import { join, dirname } from 'node:path';
7
+
8
+ const RELEASE_KEYS = {"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5":"-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEAxe/h8yLe+e4iKYSx/2lzS7MgHIgzM+mi1XjofW1VKo4=\n-----END PUBLIC KEY-----\n"}; // GENERATED_RELEASE_KEYS
9
+ const hash = bytes => createHash('sha256').update(bytes).digest('hex');
10
+ const canonical = value => {
11
+ if (value === null || typeof value === 'boolean' || typeof value === 'string') return JSON.stringify(value);
12
+ if (typeof value === 'number' && Number.isSafeInteger(value)) return String(value);
13
+ if (Array.isArray(value)) return `[${value.map(canonical).join(',')}]`;
14
+ if (value && Object.getPrototypeOf(value) === Object.prototype) return `{${Object.keys(value).sort().map(k => `${JSON.stringify(k)}:${canonical(value[k])}`).join(',')}}`;
15
+ throw Error('PACKAGE_INVALID_MANIFEST');
16
+ };
17
+ const exact = (value, keys) => value && Object.keys(value).sort().join(',') === keys.sort().join(',');
18
+ const safe = name => {
19
+ if (typeof name !== 'string' || name.length > 240) return false;
20
+ const parts = name.split('/');
21
+ return parts.every((p, i) => (/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(p) && p !== '..')
22
+ || (p === '.claude-plugin' && i > 0 && i < parts.length - 1 && parts[i - 1] === 'agent'));
23
+ };
24
+ function regular(path) {
25
+ const s = lstatSync(path);
26
+ if (s.isSymbolicLink() || !s.isFile()) throw Error('PACKAGE_NON_REGULAR_FILE');
27
+ return s;
28
+ }
29
+ function filesIn(root, prefix = '') {
30
+ const s = lstatSync(root);
31
+ if (s.isSymbolicLink() || !s.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY');
32
+ return readdirSync(root).flatMap(name => {
33
+ const path = join(root, name), stat = lstatSync(path);
34
+ if (stat.isSymbolicLink()) throw Error('PACKAGE_NON_REGULAR_FILE');
35
+ return stat.isDirectory() ? filesIn(path, prefix + name + '/') : [prefix + name];
36
+ });
37
+ }
38
+ function verifyPackage(root, kind = 'npm') {
39
+ const signatureName = kind === 'engine' ? 'engine-release.json' : 'package-release.json';
40
+ const path = join(root, signatureName);
41
+ if (regular(path).size > 1024 * 1024) throw Error('PACKAGE_MANIFEST_TOO_LARGE');
42
+ const signed = JSON.parse(readFileSync(path, 'utf8'));
43
+ if (!exact(signed, ['keyId', 'payload', 'signature']) || !Object.hasOwn(RELEASE_KEYS, signed.keyId) || !/^[A-Za-z0-9_-]{86}$/.test(signed.signature)) throw Error('PACKAGE_UNTRUSTED_SIGNATURE');
44
+ const pem = RELEASE_KEYS[signed.keyId], key = createPublicKey(pem);
45
+ if (key.asymmetricKeyType !== 'ed25519' || hash(key.export({ format: 'der', type: 'spki' })) !== signed.keyId
46
+ || !verify(null, Buffer.from('worktrust:package:1\n' + canonical(signed.payload)), key, Buffer.from(signed.signature, 'base64url'))) throw Error('PACKAGE_UNTRUSTED_SIGNATURE');
47
+ const m = signed.payload;
48
+ if (!exact(m, ['format', 'kind', 'version', 'files']) || m.format !== 'worktrust-package/1' || m.kind !== kind || !/^\d+\.\d+\.\d+$/.test(m.version)
49
+ || !m.files || Array.isArray(m.files) || typeof m.files !== 'object' || Object.keys(m.files).length > 2000 || !Object.hasOwn(m.files, 'worktrust.mjs')) throw Error('PACKAGE_INVALID_MANIFEST');
50
+ const expected = Object.keys(m.files).sort();
51
+ for (const name of expected) {
52
+ if (!safe(name) || name === signatureName || !/^[a-f0-9]{64}$/.test(m.files[name])) throw Error('PACKAGE_INVALID_MANIFEST');
53
+ let parent = root;
54
+ for (const part of name.split('/').slice(0, -1)) { parent = join(parent, part); const s = lstatSync(parent); if (s.isSymbolicLink() || !s.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY'); }
55
+ const file = join(root, name);
56
+ if (regular(file).size > 128 * 1024 * 1024 || hash(readFileSync(file)) !== m.files[name]) throw Error('PACKAGE_FILE_CHANGED');
57
+ }
58
+ const found = filesIn(root).filter(name => name !== signatureName && (kind !== 'engine' || name.endsWith('.mjs'))).sort();
59
+ if (JSON.stringify(found) !== JSON.stringify(expected)) throw Error('PACKAGE_FILE_LIST_CHANGED');
60
+ if (/const CLI_VERSION = "([^"]+)";/.exec(readFileSync(join(root, 'worktrust.mjs'), 'utf8'))?.[1] !== m.version) throw Error('PACKAGE_VERSION_MISMATCH');
61
+ return { manifest: m, identity: hash(readFileSync(path)), signatureName };
62
+ }
63
+ function installSignedPackage(source, home) {
64
+ const checked = verifyPackage(source), store = join(home, 'verified');
65
+ if (!existsSync(home)) mkdirSync(home, { mode: 0o700 });
66
+ const owned = lstatSync(home);
67
+ if (owned.isSymbolicLink() || !owned.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY');
68
+ if (!existsSync(store)) mkdirSync(store, { mode: 0o700 });
69
+ const stored = lstatSync(store);
70
+ if (stored.isSymbolicLink() || !stored.isDirectory()) throw Error('PACKAGE_NON_REGULAR_DIRECTORY');
71
+ const target = join(store, checked.identity);
72
+ if (existsSync(target)) { if (verifyPackage(target).identity !== checked.identity) throw Error('PACKAGE_INSTALLATION_IDENTITY_MISMATCH'); return join(target, 'worktrust-launch.mjs'); }
73
+ const pending = join(store, '.pending-' + randomBytes(16).toString('hex'));
74
+ mkdirSync(pending, { mode: 0o700 });
75
+ try {
76
+ for (const name of [...Object.keys(checked.manifest.files), checked.signatureName]) {
77
+ const path = join(pending, name); mkdirSync(dirname(path), { recursive: true, mode: 0o700 });
78
+ writeFileSync(path, readFileSync(join(source, name)), { flag: 'wx', mode: 0o600 });
79
+ }
80
+ if (verifyPackage(pending).identity !== checked.identity) throw Error('PACKAGE_INSTALLATION_IDENTITY_MISMATCH');
81
+ try { renameSync(pending, target); } catch (error) { if (!existsSync(target)) throw error; if (verifyPackage(target).identity !== checked.identity) throw Error('PACKAGE_INSTALLATION_IDENTITY_MISMATCH'); }
82
+ } finally { rmSync(pending, { recursive: true, force: true }); }
83
+ return join(target, 'worktrust-launch.mjs');
84
+ }
85
+
86
+ import { fileURLToPath } from 'node:url';
87
+ const root = dirname(fileURLToPath(import.meta.url));
88
+ try {
89
+ verifyPackage(root, existsSync(join(root, 'package.json')) ? 'npm' : 'engine');
90
+ process.argv[1] = join(root, 'worktrust.mjs');
91
+ await import('./worktrust.mjs');
92
+ } catch (error) {
93
+ const category = /^PACKAGE_[A-Z_]+$/.test(error.message) ? error.message : 'PACKAGE_VERIFICATION_FAILED';
94
+ process.stderr.write(`worktrust: ${category}. Execution stopped; reinstall an official WorkTrust release.\n`);
95
+ process.exitCode = 1;
96
+ }
package/worktrust.mjs CHANGED
@@ -63,7 +63,7 @@
63
63
  * No dependencies: Node 18 or later.
64
64
  */
65
65
  import { execFileSync, spawn } from "node:child_process";
66
- import { createHash, generateKeyPairSync, randomBytes, sign } from "node:crypto";
66
+ import { createHash, createPublicKey, generateKeyPairSync, randomBytes, sign } from "node:crypto";
67
67
  import { createServer } from "node:http";
68
68
  import { chmodSync, closeSync, copyFileSync, existsSync, lstatSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
69
69
  import { homedir, hostname, platform } from "node:os";
@@ -78,12 +78,12 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
78
78
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
79
79
  const has = (name) => args.includes(`--${name}`);
80
80
  /** 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). */
81
- const CLI_VERSION = "0.10.21";
81
+ const CLI_VERSION = "0.10.24";
82
82
  const ORIGIN = (flag("origin") ?? process.env.WORKTRUST_ORIGIN ?? "https://app.worktrust.io").replace(/\/$/, "");
83
83
  const MCP = flag("url") ?? process.env.WORKTRUST_MCP_URL ?? `${ORIGIN}/api/mcp`;
84
84
  const HOME_DIR = join(homedir(), ".worktrust");
85
85
  const HERE = dirname(fileURLToPath(import.meta.url));
86
- const SCRIPTS = ["setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs", "claude-mod.mjs"];
86
+ const SCRIPTS = ["history-outbox.mjs", "setup-mcp.mjs", "log-session.mjs", "count-behaviour.mjs", "transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.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"];
87
87
  /** The modules the scripts import by name from beside them; a download keeps that name. */
88
88
  const IMPORTED = new Set(["transcript-readers.mjs", "session-databases.mjs", "config-edits.mjs", "stretch-evidence.mjs", "chat-exports.mjs", "stack-rules.mjs", "runtime-install.mjs", "orchestration-contract.mjs", "orchestration-evidence.mjs", "orchestration-report.mjs"]);
89
89
  const downloaded = (name) => (IMPORTED.has(name) ? name : `${name}.download.mjs`);
@@ -128,21 +128,21 @@ async function post(path, body) {
128
128
  /** The three scripts: from the package when it carries them; otherwise from the same site, once, into ~/.worktrust. */
129
129
  async function scripts() {
130
130
  if (BUNDLED) return Object.fromEntries(SCRIPTS.map((name) => [name, join(HERE, name)]));
131
- mkdirSync(HOME_DIR, { recursive: true, mode: 0o700 });
132
- const paths = {};
133
- for (const name of SCRIPTS) {
134
- const response = await fetch(`${ORIGIN}/counter/${name}`);
135
- if (!response.ok) fail(`could not download ${name} (${response.status}).`);
136
- paths[name] = join(HOME_DIR, downloaded(name));
137
- writeFileSync(paths[name], await response.text(), { mode: 0o600 });
138
- }
139
- return paths;
131
+ fail("Use the complete official npm/Python package or preservation kit. Individual scripts are not downloaded or executed without release verification.");
132
+ }
133
+
134
+ /** Stable across bearer renewal, distinct across account/device replacement. Never sent to the server. */
135
+ function historyQueueScope(token) {
136
+ const key = keyStore.load();
137
+ if (!key || key.token !== token || !key.accountRef || !key.device) return "";
138
+ try { return createHash("sha256").update(`${key.accountRef}\0${createPublicKey(key.device).export({ format: "jwk" }).x}`).digest("hex"); }
139
+ catch { return ""; }
140
140
  }
141
141
 
142
142
  /** Run a script; its output is shown, or collected for the plan. The key travels in the environment only. */
143
143
  function run(path, scriptArgs, token, collect = false, extraEnv = {}) {
144
144
  return new Promise((resolve) => {
145
- const child = spawn(process.execPath, [...NODE_FLAGS, path, ...scriptArgs], { stdio: collect ? ["ignore", "pipe", "pipe"] : "inherit", env: { ...process.env, WORKTRUST_MCP_URL: MCP, WORKTRUST_MCP_TOKEN: token, WORKTRUST_NODE: NODE, WORKTRUST_CLI_VERSION: CLI_VERSION, ...extraEnv } });
145
+ const child = spawn(process.execPath, [...NODE_FLAGS, path, ...scriptArgs], { stdio: collect ? ["ignore", "pipe", "pipe"] : "inherit", env: { ...process.env, WORKTRUST_MCP_URL: MCP, WORKTRUST_MCP_TOKEN: token, WORKTRUST_NODE: NODE, WORKTRUST_CLI_VERSION: CLI_VERSION, WORKTRUST_HISTORY_SCOPE: historyQueueScope(token), ...extraEnv } });
146
146
  let out = "";
147
147
  child.stdout?.on("data", (chunk) => { out += chunk; });
148
148
  child.stderr?.on("data", (chunk) => { out += chunk; });
@@ -221,6 +221,7 @@ async function pairByBrowser(host, extra) {
221
221
  server.close();
222
222
  if (!code) fail("no approval arrived in time. Run `worktrust connect` again.");
223
223
  const exchange = await post("/api/cli/token", { device_code: secret, code, code_verifier: verifier }).catch(() => null);
224
+ if (exchange?.json?.error === "device_limit") fail("Five devices are already connected. In WorkTrust Sources, disconnect a device, then connect again. Earlier measurements are kept.");
224
225
  if (!exchange || exchange.status !== 200 || !exchange.json.token) fail(`the approval could not be exchanged (${exchange?.json?.error ?? "no answer"}). Run \`worktrust connect\` again.`);
225
226
  say(` ✓ Approved as "${exchange.json.label}"${exchange.json.account ? ` for the WorkTrust account ${exchange.json.account}` : ""}`);
226
227
  if (exchange.json.account) say(" Not your account? Run `npx worktrust disconnect` now and revoke it in WorkTrust.");
@@ -255,6 +256,7 @@ async function pairByCode(host, extra) {
255
256
  if (answer.json.account) say(" Not your account? Run `npx worktrust disconnect` now and revoke it in WorkTrust.");
256
257
  return paired(answer.json);
257
258
  }
259
+ if (answer.json.error === "device_limit") fail("Five devices are already connected. In WorkTrust Sources, disconnect a device, then connect again. Earlier measurements are kept.");
258
260
  if (answer.json.error === "slow_down") wait += 2000;
259
261
  else if (answer.json.error === "expired_token") fail("the code expired. Run `worktrust connect` again.");
260
262
  else if (answer.json.error === "invalid_grant") fail("this pairing was already used. Run `worktrust connect` again.");
@@ -277,7 +279,14 @@ const ensureHome = () => { mkdirSync(HOME_DIR, { recursive: true, mode: 0o700 })
277
279
 
278
280
  /** A tool-runner cache is disposable. Install the whole verified runtime/engine before changing wiring. */
279
281
  async function prepareBundledRuntime() {
280
- if (!process.env.WORKTRUST_BUNDLED_RUNTIME_DIR || runtimePrepared) return;
282
+ if (runtimePrepared) return;
283
+ if (!process.env.WORKTRUST_BUNDLED_RUNTIME_DIR) {
284
+ if (existsSync(join(HERE, "package-release.json"))) {
285
+ if (existsSync(HOME_DIR) && (!lstatSync(HOME_DIR).isDirectory() || lstatSync(HOME_DIR).isSymbolicLink())) fail("the WorkTrust directory must be a directory, not a symlink.");
286
+ ensureHome(); const { installSignedPackage } = await import("./package-integrity.mjs"); STABLE = installSignedPackage(HERE, HOME_DIR); runtimePrepared = true;
287
+ }
288
+ return;
289
+ }
281
290
  const { installRuntime } = await import("./runtime-install.mjs");
282
291
  if (existsSync(HOME_DIR) && (!lstatSync(HOME_DIR).isDirectory() || lstatSync(HOME_DIR).isSymbolicLink())) fail("the WorkTrust directory must be a directory, not a symlink.");
283
292
  ensureHome();
@@ -357,7 +366,7 @@ function proof(device, url, body) {
357
366
  async function accepted(url, token, device) {
358
367
  try {
359
368
  const body = JSON.stringify({ jsonrpc: "2.0", id: 0, method: "tools/list" });
360
- const response = await fetch(url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json", authorization: `Bearer ${token}`, "user-agent": "worktrust-bridge", ...proof(device, url, body) }, body, redirect: "error", signal: AbortSignal.timeout(5000) });
369
+ const response = await fetch(url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json", authorization: `Bearer ${token}`, "user-agent": `worktrust-bridge worktrust-cli/${CLI_VERSION}`, ...proof(device, url, body) }, body, redirect: "error", signal: AbortSignal.timeout(5000) });
361
370
  if (response.status === 401 || response.status === 403) return false;
362
371
  if (response.status !== 200) return null;
363
372
  const answer = await response.json();
@@ -501,7 +510,7 @@ async function hook() {
501
510
  if (has("hermes") || has("goose")) return sessionEnd();
502
511
  const key = await freshKey();
503
512
  if (!key) return;
504
- const child = spawn(process.execPath, [...NODE_FLAGS, join(BUNDLED ? HERE : HOME_DIR, "log-session.mjs"), ...args.filter((arg) => arg !== "hook")], { stdio: "inherit", env: { ...process.env, WORKTRUST_MCP_URL: key.url, WORKTRUST_MCP_TOKEN: key.token, WORKTRUST_CLI_VERSION: CLI_VERSION, ...(key.device ? { WORKTRUST_DEVICE_KEY: key.device } : {}) } }); // 0.10.20: the hook names the version that started it, beside each line
513
+ const child = spawn(process.execPath, [...NODE_FLAGS, join(BUNDLED ? HERE : HOME_DIR, "log-session.mjs"), ...args.filter((arg) => arg !== "hook")], { stdio: "inherit", env: { ...process.env, WORKTRUST_MCP_URL: key.url, WORKTRUST_MCP_TOKEN: key.token, WORKTRUST_CLI_VERSION: CLI_VERSION, WORKTRUST_HISTORY_SCOPE: historyQueueScope(key.token), ...(key.device ? { WORKTRUST_DEVICE_KEY: key.device } : {}) } }); // 0.10.20: the hook names the version that started it, beside each line
505
514
  process.exitCode = await new Promise((resolve, reject) => { child.on("error", reject); child.on("close", (code) => resolve(code ?? 1)); });
506
515
  }
507
516
 
@@ -579,10 +588,11 @@ async function update() {
579
588
  // Codex installed since, or a No said at connect: the one question, asked again (or "already set").
580
589
  await offerCodex();
581
590
  await offerAntigravity();
591
+ const reported = await accepted(key.url, key.token, key.device);
592
+ say(reported === true ? ` ✓ WorkTrust received CLI version ${CLI_VERSION}.` : " ! Installed locally. WorkTrust could not confirm the version yet; it will be reported on the next connection.");
582
593
  await offerRebuild(previousVersion, paths, key);
583
594
  say();
584
- say(" Done. Quit your AI apps completely and open them again; the CLI version shows in WorkTrust");
585
- say(" under Sources → CLI once one of them has spoken. A key an app held by hand still works until you end it there.");
595
+ say(" Done. Quit your AI apps completely and open them again to use the updated CLI.");
586
596
  }
587
597
 
588
598
  async function connect() {
@@ -692,7 +702,7 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false)
692
702
  if (!has("history") && !(rebuild ? await ask("Send them (re-measured; this computer's earlier lines for these days are replaced, a day is counted once)?", false) : await ask("Send these as history (hours and tokens per day; never text)?", false))) { historyDone(false); say(" Not sent. Send them later with: npx worktrust"); return; }
693
703
  // Marked unfinished before the first batch leaves (0.10.9): a send stopped halfway (Ctrl+C, a closed lid) is finished by the next run.
694
704
  historyDone(false);
695
- const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : [])], token, true, env);
705
+ const sent = await run(paths["log-session.mjs"], ["--history", ...(rebuild ? ["--rebuild"] : []), ...(has("retry-review") ? ["--retry-review"] : [])], token, true, env);
696
706
  historyDone(sent.code === 0);
697
707
  // WHAT ACTUALLY HAPPENED, FROM THE DOOR'S RECEIPTS (owner, 2026-10-10): a re-measure in which nothing changed must not say
698
708
  // "replaced". The hook sums the receipts of every batch and prints one line; without it (an older hook) the sentence stays neutral.
@@ -702,8 +712,10 @@ async function offerHistory(paths, token, devicePem, url = MCP, rebuild = false)
702
712
  : n(did.replaced) > 0 ? `${n(did.replaced)} of this computer's earlier lines were replaced (withdrawn and kept, never deleted)${n(did.new) > 0 ? `, ${n(did.new)} new` : ""}${n(did.filled) > 0 ? `, ${n(did.filled)} lines gained what was missing` : ""}.`
703
713
  : n(did.new) === 0 ? `Nothing changed: the same measurement${n(did.filled) > 0 ? `; ${n(did.filled)} lines gained what was missing (the stack, the tools seen, a layer)` : ""}; ${n(did.alreadyHeld)} lines already held.`
704
714
  : `${n(did.new)} new lines${n(did.filled) > 0 ? `, ${n(did.filled)} lines gained what was missing` : ""}; ${n(did.alreadyHeld)} already held.`;
705
- if (rebuild) say(sent.code === 0 ? ` ✓ Re-measured. ${outcome}` : " Not all of it arrived. Run npx worktrust again: it finishes what did not arrive, a day already rebuilt is counted once.");
706
- else say(sent.code === 0 ? " ✓ Sent as history. Measured sessions count toward your verified hours; a day WorkTrust already holds is kept once." : " Not all of it arrived. Run npx worktrust history again: a line already received is kept once.");
715
+ if (Number(did?.delivery?.review) > 0) say(` ${did.delivery.review} lines are waiting for review. Earlier measurements remain unchanged. Reconnecting or repeating the import does not approve them.`);
716
+ if (Number(did?.delivery?.waiting) > 0) say(" Pending batches remain on this computer. Run npx worktrust history --resume after the upload limit or connection recovers.");
717
+ if (rebuild && !Number(did?.delivery?.review) && !Number(did?.delivery?.waiting)) say(sent.code === 0 ? ` ✓ Re-measured. ${outcome}` : " Not all of it arrived. Run npx worktrust again: it finishes what did not arrive, a day already rebuilt is counted once.");
718
+ else if (!rebuild) say(sent.code === 0 ? " ✓ Sent as history. Activity is recorded with its origin; independent verification and passport publication are separate. A day WorkTrust already holds is kept once." : " Not all of it arrived. Run npx worktrust history again: a line already received is kept once.");
707
719
  if (did && Number(did.measuredSeconds) > 0) say(` Measured by WorkTrust: ${(Number(did.measuredSeconds) / 3600).toFixed(1)} h for what this send stored${n(did.corrected) > 0 ? ` (${n(did.corrected)} lines corrected: a figure sent beside the timeline differed)` : ""}.`);
708
720
  }
709
721
 
@@ -764,6 +776,11 @@ async function again() {
764
776
  async function history() {
765
777
  const key = await freshKey();
766
778
  if (!key) fail("this computer is not coupled through the key file. Run npx worktrust first.");
779
+ if (has("resume")) {
780
+ if (!has("dry-run") && !has("history") && !(await ask("Resume previously approved metadata uploads? Lines held for review stay held.", false))) return;
781
+ const paths = await scripts(), sent = await run(paths["log-session.mjs"], ["--history", "--resume", ...(has("dry-run") ? ["--dry-run"] : []), ...(has("retry-review") ? ["--retry-review"] : [])], key.token, true, { WORKTRUST_MCP_URL: key.url, ...(key.device ? { WORKTRUST_DEVICE_KEY: key.device } : {}) });
782
+ say(sent.out.trim()); process.exitCode = sent.code; return;
783
+ }
767
784
  if (has("from-archive")) return offerArchive(await scripts(), key);
768
785
  if (has("export")) { if (!flag("export") || flag("export").startsWith("--")) fail("--export needs the export's path: the zip, its folder, conversations.json, a conversations-000.zip part, or the manifest"); await offerExport(await scripts(), key, flag("export")); return; }
769
786
  if (has("from-folder")) { if (!flag("from-folder") || flag("from-folder").startsWith("--")) fail("--from-folder needs the copied folder's path"); await offerFolder(await scripts(), key, flag("from-folder")); return; }
@@ -1151,6 +1168,8 @@ function help() {
1151
1168
  say(" --replace yes in advance to coupling a computer that is already coupled");
1152
1169
  say(" worktrust update this computer onto the newest CLI: same key, no new pairing");
1153
1170
  say(" worktrust history send this computer's earlier sessions as history (asks first)");
1171
+ say(" --resume retry saved metadata batches, even if source files are gone (asks first)");
1172
+ say(" --retry-review explicitly retry held batches after support resolves their review");
1154
1173
  say(" --rebuild re-measure them with the current rules; WorkTrust replaces this computer's earlier lines,");
1155
1174
  say(" day by day, never counting a day twice (shows the plan per AI app, asks first; --dry-run: the plan only)");
1156
1175
  say(" --from-archive [dir] send what your archive (preserve --archive) holds of sessions your AI apps already deleted,");
@@ -1193,15 +1212,10 @@ if (agentShell && PERSON_ONLY.has(command)) {
1193
1212
  return (process.exitCode = 3);
1194
1213
  }
1195
1214
 
1196
- /**
1197
- * ALWAYS THE NEWEST, WHATEVER WAS TYPED (0.10.7, owner: "npx worktrust should simply be right"). npx runs whatever version
1198
- * it cached, and a person should never need `@latest` or `--prefer-online`. A command a PERSON runs in a terminal asks npm
1199
- * which version is newest (the version string only, nothing of this computer, two seconds at most) and, when this one is
1200
- * older, hands the same command to the newest through npx and steps aside. Offline, npm slow, no terminal (a script, a
1201
- * 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
1202
- * stable copy, never ask.
1215
+ /** Interactive version notice only. Registry metadata is not a trusted signed release catalogue.
1216
+ * Hooks, bridge and offline preserve never check. Installation remains with the person's package manager
1217
+ * until the signed release updater has a provisioned trust root and has passed the distribution gates.
1203
1218
  */
1204
- // NOT `preserve` (0.10.8): it promises no network connection at all (the site and its kit say so), so it never asks npm.
1205
1219
  const RELAY_COMMANDS = new Set(["default", "connect", "update", "history", "status", "disconnect", "codex", "antigravity"]);
1206
1220
  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; };
1207
1221
  async function newestVersion() {
@@ -1216,15 +1230,8 @@ async function relayToNewest() {
1216
1230
  if (process.env.WORKTRUST_RELAYED === "1" || !RELAY_COMMANDS.has(command) || !process.stdin.isTTY || !process.stdout.isTTY) return;
1217
1231
  const latest = await newestVersion();
1218
1232
  if (!latest || !semverNewer(latest, CLI_VERSION)) return;
1219
- say(` worktrust ${CLI_VERSION} is not the newest: running ${latest} instead.`);
1220
- const argv = ["--yes", `worktrust@${latest}`, ...args];
1221
- const env = { ...process.env, WORKTRUST_RELAYED: "1" };
1222
- // A .cmd shim on Windows needs a shell: one line, each argument quoted for cmd.exe, never an argument list beside it.
1223
- const quote = (arg) => (/^[\w@%+=:,./\\-]+$/.test(arg) ? arg : `"${String(arg).replace(/"/g, '\\"')}"`);
1224
- const child = platform() === "win32" ? spawn(["npx", ...argv].map(quote).join(" "), { stdio: "inherit", env, shell: true }) : spawn("npx", argv, { stdio: "inherit", env });
1225
- const code = await new Promise((done) => { child.on("error", () => done(null)); child.on("close", (exit) => done(exit)); });
1226
- if (code === null) { say(" The newest could not be started; this version runs instead."); return; }
1227
- process.exitCode = code; return true;
1233
+ say(` WorkTrust ${latest} is available. Automatic execution is paused until signed release verification is configured.`);
1234
+ say(" Update explicitly using the package manager you installed with. This invocation keeps its current version.");
1228
1235
  }
1229
1236
  if (await relayToNewest()) return;
1230
1237