worktrust 0.10.32 → 0.10.33

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
+ ## 0.10.33: one line per autonomous process per day; a fair-use limit keeps the line
4
+
5
+ A finished headless or scheduled run (a run no person started) is no longer a line of its own. It waits on this
6
+ computer, in `~/.worktrust/process-days`, folded into its process's UTC day: a process is the AI app, how the session
7
+ was started, the timer's opaque reference when a timer started it, and the project folder, as a hash (`process_ref`),
8
+ never a name or a path. Once the day is over and quiet it goes as ONE line with how many runs it holds
9
+ (`process_runs`); the runs' timelines are joined at minute resolution, which keeps every counted second, with each
10
+ run's call outcomes, its turns' length buckets and its subagent runs kept in step (every turn and each minute's first
11
+ completed call stay). A run that
12
+ finishes after its day was sent becomes the day's next part, and once WorkTrust holds its parts it is merged into the
13
+ last one, which goes again whole. When WorkTrust answers a fair-use limit (429 with Retry-After) nothing is lost: the
14
+ line stays where it was and goes after the wait. What is measured is unchanged, so the measure rules stay 2 and no
15
+ re-measure is offered.
16
+
3
17
  ## 0.10.32: a re-measure sends only the days that changed; which subagents were active at once; each call's outcome
4
18
 
5
19
  Before a re-measure sends anything, the CLI asks WorkTrust, once per AI app, which of this computer's days it holds as
@@ -1 +1 @@
1
- {"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","history-outbox.mjs":"b84e22542bb2d8195a469ee5f4116356ae9eac4a53ff2d40f0268b5b1de99dc5","log-session.mjs":"35d01fb00a472c022560a880c0863b57f24cb8311040bba21c3f0cf903b9074c","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"ed6fef364aa28f39361d8f627abcda2162498cbaa13e90cc5860a768cb355fa2","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"0e481fde109620dd23f750d7b9b0741c0ea831c45961a176164ef2a74f3dd7c0"},"format":"worktrust-package/1","kind":"engine","version":"0.10.32"},"signature":"j7kCqXaW7lS8jyExo_Ag4eCHLtVYFSMIOJY745sZrrFyRTOfOc59k8kYFKCST-KMkQQctNK9QuLZAox_1UzwDQ"}
1
+ {"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","history-outbox.mjs":"b88072a28aa1dd94d9fab880f96b711b5fbed76ca62e5de24d612c08171e5b71","log-session.mjs":"d20e20c4fa5e4dd6a48a2c3b7caf4cefb090063503f38dc4716d8daee6d3bf22","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"ed6fef364aa28f39361d8f627abcda2162498cbaa13e90cc5860a768cb355fa2","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"804e7527618ff4ddea6b6457ff9878c1179581827580387b4468fd02af364266"},"format":"worktrust-package/1","kind":"engine","version":"0.10.33"},"signature":"hpJAJKGQjzzyecwWYTpU2zL-StLIzDzTBSG9-C9f4skwv_Vy7zZOFP9MM3PlQcKJvyAk-sPQT8n0JYCuZWpmBw"}
@@ -163,3 +163,126 @@ export async function resumeHistory(target, {send, confirmed, note, retryReview=
163
163
  }
164
164
  /** A queued batch's id, as queuedHistory names it, so a send can hand its own batches to resumeHistory (`only`). */
165
165
  export const historyIdOf=(target,body,source)=>digest(scopeOf(target)+'\0'+source+'\0'+body);
166
+
167
+ /**
168
+ * ONE LINE PER PROCESS PER DAY (0.10.33; owner, 2026-10-28; docs/FAIR-USE.md §1). An autonomous process (a headless or scheduled
169
+ * session: `claude -p` from cron, an agent every ten minutes) writes a new transcript per run, and every run used to be a line
170
+ * of its own: 144 a day for one process, a hundred processes 14,400. Its runs of one UTC day are one line now. A process is its
171
+ * client, its session kind, its schedule (when the client names one) and its project folder, as a hash: never content, never the
172
+ * path. The runs wait here, on disk, folded as they finish; the day is sent once it is over and quiet. A run is folded once (by
173
+ * its id), and a run that finishes after its day was sent becomes the day's next part; once the database's PROCESS_PARTS are spent
174
+ * it is merged into the last part, which goes again whole. Nothing is ever let go before WorkTrust took it.
175
+ * Nothing here reads a transcript or the network: the hook hands it measured runs and sends what it answers.
176
+ */
177
+ export const PROCESS_PARTS=3; // the database's analysis.process_day_max_parts()
178
+ const STEP=/(G?)([HIURATWhiuratw])([0-9]{1,6})/g;
179
+ const PART_CHARS=150_000; // a part stays well inside the door's 200,000 characters of timeline
180
+ const b64=s=>createHash('sha256').update(s).digest('base64url');
181
+ export const processRefOf=({source,kind,schedule,cwd,day})=>b64(`worktrust-process/1|${source??'claude'}|${kind}|${schedule??''}|${cwd?digest(String(cwd)):''}|${day}`);
182
+ export const lineRefOf=(ref,part)=>b64(`worktrust-process-line/1|${ref}|${part}`);
183
+ /** A run's timeline at MINUTE RESOLUTION: per wall-clock minute its first and its last step, each with its own kind.
184
+ * A dropped step lies inside one minute between two kept ones, so every merged gap is under a minute, below the idle cap, and the
185
+ * seconds WorkTrust counts from the timeline are exactly the same; a day holds at most two steps a minute (2,880). The calls of a
186
+ * minute whose first and last steps are not the model's answers are not kept: a call counts at most once per five minutes anyway. */
187
+ export function minuteCompact(timeline,fromMs){return minuteCompactRun(timeline,fromMs).timeline;}
188
+ const ANSWER='ATW';
189
+ /** THE SAME, WITH WHAT RIDES ON THE STEPS (release 9 integration, 2026-10-29): 0.10.32's call outcomes (one character per
190
+ * answer step, A/T/W) and input lengths (one bucket per H) are aligned with the timeline's steps, so a compacted timeline
191
+ * carries exactly the outcomes of its kept answer steps and the lengths of its kept turns. Every H is kept (a person's turn
192
+ * starts steered time: dropping one would move it), and in each minute the first answer recorded as completed ('1') is
193
+ * kept beside the first and last step, so the guardrail never loses a positive call to the compaction. Seconds stay exact:
194
+ * every kept set holds each minute's first and last step. Without outcomes or lengths, null comes back for them. */
195
+ export function minuteCompactRun(timeline,fromMs,outcomes=null,lengths=null){
196
+ const steps=[...String(timeline).matchAll(STEP)].map(m=>({g:m[1],k:m[2],K:m[2].toUpperCase(),gap:Number(m[3])}));
197
+ if(!steps.length)return {timeline:'',outcomes:outcomes==null?null:'',lengths:lengths==null?null:''};
198
+ let c=0;const at=steps.map(s=>(c+=s.gap));const first=steps.findIndex(s=>s.k===s.K);const base=fromMs-1000*(at[Math.max(0,first)]??0);
199
+ let ai=0,hi=0;const oc=steps.map(s=>ANSWER.includes(s.K)?(outcomes==null?null:String(outcomes)[ai++]??null):null);
200
+ const lg=steps.map(s=>s.K==='H'?(lengths==null?null:String(lengths)[hi++]??null):null);
201
+ const groups=new Map(),keep=new Set();
202
+ steps.forEach((s,i)=>{const m=Math.floor((base+1000*at[i])/60_000),g=groups.get(m)??{first:i,last:i,done:-1};g.last=i;if(g.done<0&&oc[i]==='1')g.done=i;groups.set(m,g);});
203
+ for(const g of groups.values()){keep.add(g.first);keep.add(g.last);if(g.done>=0)keep.add(g.done);}
204
+ steps.forEach((s,i)=>{if(s.K==='H')keep.add(i);});
205
+ let out='',o='',l='',gap=0;
206
+ for(let i=0;i<steps.length;i++){gap+=i===0?0:steps[i].gap;if(!keep.has(i))continue;out+=`${steps[i].g}${steps[i].k}${Math.min(999999,gap)}`;gap=0;if(oc[i]!=null)o+=oc[i];if(lg[i]!=null)l+=lg[i];}
207
+ return {timeline:out,outcomes:outcomes==null?null:o,lengths:lengths==null?null:l};
208
+ }
209
+ const stepsOf=(t,kinds)=>[...String(t??'').matchAll(STEP)].filter(m=>kinds.includes(m[2].toUpperCase())).length;
210
+ /** The runs of one part as ONE stretch: their timelines joined in time order, each run's first step at a zero gap (the time
211
+ * between two runs belongs to neither, as it did when each was a line), a later run's bridge left out; tokens summed, the model
212
+ * the one most runs used, the window from the first run's start to the last run's end. Release 9: the runs' call outcomes and
213
+ * input lengths joined in the same order (a bridge left out takes its own character with it; a run whose steps carry none
214
+ * makes the part carry none, never a misaligned string), and their subagent runs (wall-clock stamps) listed together. */
215
+ export function combineRuns(runs){
216
+ const sorted=[...runs].sort((a,b)=>a.from-b.from),models=new Map();let timeline='',shapeKnown=true,outcomes='',lengths='',agents=[];
217
+ const sum={tokensIn:0,tokensOut:0,cacheRead:0,cacheWrite:0};
218
+ for(const [i,run] of sorted.entries()){
219
+ let t=run.timeline,o=run.outcomes??null,l=run.lengths??null;
220
+ if(o==null&&stepsOf(t,ANSWER)>0)outcomes=null;if(l==null&&stepsOf(t,'H')>0)lengths=null;
221
+ if(i>0){const bridge=/^G?([hiuratw])[0-9]{1,6}/.exec(t);if(bridge){const K=bridge[1].toUpperCase();if(o!=null&&ANSWER.includes(K))o=o.slice(1);if(l!=null&&K==='H')l=l.slice(1);}
222
+ t=t.replace(/^G?[hiuratw][0-9]{1,6}/,'').replace(/^(G?[HIURATW])[0-9]{1,6}/,(_,head)=>`${head}0`);}
223
+ timeline+=t;if(outcomes!=null&&o!=null)outcomes+=o;if(lengths!=null&&l!=null)lengths+=l;
224
+ for(const key of Object.keys(sum))sum[key]+=Number(run[key])||0;shapeKnown&&=run.shapeKnown!==false;
225
+ if(run.model)models.set(run.model,(models.get(run.model)??0)+1);
226
+ if(Array.isArray(run.agents))agents=agents.concat(run.agents);
227
+ }
228
+ return {...(shapeKnown?sum:{tokensIn:0,tokensOut:0,cacheRead:0,cacheWrite:0}),shapeKnown,timeline:timeline||null,model:[...models].sort((a,b)=>b[1]-a[1])[0]?.[0]??null,
229
+ from:sorted[0]?.from,to:Math.max(...sorted.map(r=>r.to)),offset:sorted[0]?.offset,
230
+ outcomes:outcomes&&outcomes.length===stepsOf(timeline,ANSWER)?outcomes:null,lengths:lengths&&lengths.length===stepsOf(timeline,'H')?lengths:null,
231
+ agents:agents.length?{list:agents}:null};
232
+ }
233
+ /** A process-day's runs in time order, cut into parts whose timelines stay under PART_CHARS (one part on any real day). */
234
+ export function processParts(runs){
235
+ const out=[];let part=[],chars=0;
236
+ for(const run of [...runs].sort((a,b)=>a.from-b.from)){if(part.length&&chars+run.timeline.length>PART_CHARS){out.push(part);part=[];chars=0;}part.push(run);chars+=run.timeline.length;}
237
+ if(part.length)out.push(part);
238
+ return out;
239
+ }
240
+ /** One file per process-day under ~/.worktrust/process-days (a hundred processes stay a hundred small files), one lock. */
241
+ function processStore(){
242
+ const home=join(homedir(),'.worktrust');directory(home);const root=join(home,'process-days');directory(root);
243
+ const path=ref=>{if(!/^[A-Za-z0-9_-]{43}$/.test(ref))throw Error('PROCESS_DAY_UNSAFE');return join(root,ref+'.json');};
244
+ return {root,load:ref=>read(path(ref)),save:(ref,value)=>write(path(ref),value),drop:ref=>{const p=path(ref);if(existsSync(p)){regular(p);unlinkSync(p);}},
245
+ refs:()=>readdirSync(root).filter(f=>/^[A-Za-z0-9_-]{43}\.json$/.test(f)).map(f=>f.slice(0,43))};
246
+ }
247
+ /** Folds one finished run into its process-day, on disk, before the caller passes the transcript's mark. Idempotent by run id. */
248
+ export function foldProcessRun(key,run){
249
+ const store=processStore();
250
+ return reservation(store.root,()=>{
251
+ const day=store.load(key.ref)??{format:'worktrust-process-day/1',day:key.day,source:key.source,kind:key.kind,cwd:key.cwd,steered:key.steered??null,schedule:key.schedule??null,codex:key.codex===true,sent:0,ids:[],runs:[]};
252
+ const id=digest(run.id).slice(0,20);if(day.ids.includes(id))return 'held';
253
+ day.ids.push(id);day.runs.push({...run,id});store.save(key.ref,day);return 'folded';
254
+ });
255
+ }
256
+ /** The process-days to send now: the UTC day over and every run quiet for `quietMs`, not waiting on a retry; each as its parts
257
+ * (runs cut so a part's timeline stays under PART_CHARS). A sent day is let go thirty days after it ends (its ids and last part kept till then, so a late run merges). */
258
+ export function dueProcessDays(now,quietMs){
259
+ const store=processStore();
260
+ return reservation(store.root,()=>{
261
+ const out=[];
262
+ for(const ref of store.refs()){
263
+ const day=store.load(ref);if(!day)continue;
264
+ const end=Date.parse(`${day.day}T00:00:00Z`)+86_400_000;
265
+ if(!day.runs.length){if(now>end+30*86_400_000)store.drop(ref);continue;}
266
+ if(now<end+quietMs||now-Math.max(...day.runs.map(r=>r.to))<quietMs||Number(day.retryAt)>now)continue;
267
+ // THE PARTS ARE SPENT (the database holds PROCESS_PARTS lines of a day): a later run is MERGED into the last part, sent
268
+ // again with every run it held, and the database puts the fuller line in its place. Nothing is ever let go unsent.
269
+ const parts=processParts(day.runs),room=Math.max(0,PROCESS_PARTS-day.sent);
270
+ if(room===0)out.push({ref,...day,part:PROCESS_PARTS,runs:[...(day.lastRuns??[]),...day.runs],pending:day.runs.map(r=>r.id)});
271
+ else{const keep=parts.slice(0,room-1),rest=parts.slice(room-1).flat();keep.forEach((runs,i)=>out.push({ref,...day,part:day.sent+i+1,runs,pending:runs.map(r=>r.id)}));
272
+ if(rest.length)out.push({ref,...day,part:day.sent+keep.length+1,runs:rest,pending:rest.map(r=>r.id)});}
273
+ }
274
+ return out;
275
+ });
276
+ }
277
+ /** WorkTrust took the part: its new runs leave the pending list; the ids stay, so a run is never folded twice. */
278
+ export function markProcessSent(ref,due){
279
+ const store=processStore();
280
+ reservation(store.root,()=>{const day=store.load(ref);if(!day)return;const gone=new Set(due.pending);day.runs=day.runs.filter(r=>!gone.has(r.id));
281
+ // The last part's runs stay (the day's own copy) until the day is let go: a run that comes later is merged into them.
282
+ day.sent=Math.max(day.sent,due.part);if(due.part>=PROCESS_PARTS)day.lastRuns=due.runs;delete day.retryAt;store.save(ref,day);});
283
+ }
284
+ /** Not taken now (a limit, the network): kept, and asked again after `seconds`. */
285
+ export function deferProcessDay(ref,seconds){
286
+ const store=processStore();
287
+ reservation(store.root,()=>{const day=store.load(ref);if(!day)return;day.retryAt=Date.now()+Math.max(1,Math.min(MAX_RETRY_SECONDS,seconds))*1000;store.save(ref,day);});
288
+ }
package/log-session.mjs CHANGED
@@ -981,7 +981,7 @@ function confirmedReceipt(answer, expectedCount = null) {
981
981
  if (!Array.isArray(content) || content.length !== 1 || content[0].type !== "text") throw Error();
982
982
  const receipt = JSON.parse(content[0].text);
983
983
  if (expectedCount === null) {
984
- if (!(receipt.receipt === "received" && ["accepted", "flagged", "pending"].includes(receipt.status)) && !(receipt.receipt === "unchanged" && receipt.reason === "duplicate")) throw Error();
984
+ if (!(receipt.receipt === "received" && ["accepted", "flagged", "pending"].includes(receipt.status)) && !(receipt.receipt === "unchanged" && (receipt.reason === "duplicate" || receipt.reason === "process_day_held"))) throw Error();
985
985
  } else if (receipt.staged === true) {
986
986
  // KEPT ON THE SERVER (0.10.27): a batch of a run WorkTrust holds and rebuilds itself; every line counted as kept or refused.
987
987
  if (receipt.receipt !== "received" || receipt.received !== expectedCount || !Number.isInteger(receipt.kept) || receipt.kept < 0
@@ -1248,11 +1248,51 @@ async function send(door, payload) {
1248
1248
  retainMeasurement(payload, entrySource.get(payload));
1249
1249
  const body = JSON.stringify({ jsonrpc: "2.0", id: 1, method: "tools/call", params: { name: "log_work", arguments: payload } });
1250
1250
  const response = await fetch(door.url, { method: "POST", headers: { "content-type": "application/json", accept: "application/json, text/event-stream", authorization: `Bearer ${door.token}`, ...clientOf(entrySource.get(payload)), ...proofFor(door.url, body) }, body });
1251
+ // A FAIR-USE LIMIT (0.10.33; owner, 2026-10-28): 429 with Retry-After. Nothing was stored; the line is kept and sent again after the delay.
1252
+ if (response.status === 429) throw Object.assign(new Error("door said 429"), { retryAfter: Math.max(1, Math.min(86_400, Number(response.headers.get("retry-after")) || 60)) });
1251
1253
  if (!response.ok) throw new Error(`door said ${response.status}`);
1252
1254
  const text = await response.text();
1253
1255
  confirmedReceipt(text);
1254
1256
  return text;
1255
1257
  }
1258
+ /**
1259
+ * ONE LINE PER PROCESS PER DAY (0.10.33; owner, 2026-10-28; docs/FAIR-USE.md §1): a finished headless or scheduled run is folded
1260
+ * into its process's UTC day on disk (history-outbox.mjs) and the day goes as ONE line once it is over and quiet: live while the
1261
+ * door takes it, else through the history outbox; a refusal keeps it. A copy without that module sends each run as before.
1262
+ */
1263
+ const PROCESS = await import("./history-outbox.mjs").then((m) => (m.foldProcessRun ? m : null), () => null);
1264
+ const isProcessRun = (stretch) => Boolean(PROCESS && stretch.timeline && (stretch.session === "headless" || stretch.session === "scheduled"));
1265
+ const processKey = (source, stretch, codex) => { const day = new Date(stretch.to).toISOString().slice(0, 10); return { ref: PROCESS.processRefOf({ source, kind: stretch.session, schedule: stretch.schedule?.ref ?? null, cwd: stretch.cwd, day }), day, source: source ?? "claude", kind: stretch.session, cwd: stretch.cwd ?? null, steered: stretch.steered ?? null, schedule: stretch.schedule ?? null, codex }; };
1266
+ // A RUN KEEPS WHAT RIDES ON ITS STEPS (release 9): its call outcomes and input lengths compacted with the timeline
1267
+ // (minuteCompactRun), and its subagent runs as read (wall-clock stamps), so the day's line carries them as each run's did.
1268
+ const processRun = (id, stretch) => { const compact = PROCESS.minuteCompactRun ? PROCESS.minuteCompactRun(stretch.timeline, stretch.from, stretch.outcomes ?? null, stretch.lengths ?? null) : { timeline: PROCESS.minuteCompact(stretch.timeline, stretch.from), outcomes: null, lengths: null };
1269
+ return { id: `${id}|${stretch.from}`, from: stretch.from, to: stretch.to, offset: stretch.offset, timeline: compact.timeline, outcomes: compact.outcomes, lengths: compact.lengths, agents: stretch.agents?.list ?? null, tokensIn: stretch.tokensIn, tokensOut: stretch.tokensOut, cacheRead: stretch.cacheRead, cacheWrite: stretch.cacheWrite, shapeKnown: stretch.shapeKnown, model: stretch.model ?? null }; };
1270
+ function processPayload(group, part, runs) {
1271
+ const payload = { ...payloadFor({ ...PROCESS.combineRuns(runs), cwd: group.cwd && existsSync(group.cwd) ? group.cwd : null, ref: PROCESS.lineRefOf(group.ref, part), steered: group.steered, session: group.kind, schedule: group.schedule ?? null, derived: null, live: null }), process_ref: group.ref, process_runs: runs.length };
1272
+ if (group.source && group.source !== "claude") entrySource.set(payload, group.source);
1273
+ return payload;
1274
+ }
1275
+ const liveWaiting = () => Date.parse(state.__liveRetryAt ?? "") > Date.now();
1276
+ const liveWait = (seconds) => { state.__liveRetryAt = new Date(Date.now() + seconds * 1000).toISOString(); LIVE_NOTED.n += 1; };
1277
+ const LIVE_NOTED = { n: 0 };
1278
+ async function sendProcessDays() {
1279
+ let n = 0;
1280
+ for (const due of PROCESS ? PROCESS.dueProcessDays(Date.now(), IDLE_BEFORE_SWEEP) : []) {
1281
+ const payload = processPayload(due, due.part, due.runs);
1282
+ if (DRY) { console.log(JSON.stringify({ ...payload, client: due.source, route: "process-day" }, null, 1)); continue; }
1283
+ if (Date.now() - Date.parse(payload.at) > WINDOW_HOURS * 3600_000 - IDLE_BEFORE_SWEEP) {
1284
+ const before = HISTORY_PERSISTED.n;
1285
+ await sendHistory(door, [payload]).catch(() => 0);
1286
+ if (HISTORY_PERSISTED.n > before) { PROCESS.markProcessSent(due.ref, due); n += 1; } else PROCESS.deferProcessDay(due.ref, 300);
1287
+ continue;
1288
+ }
1289
+ if (liveWaiting()) continue;
1290
+ // HELD IS NOT TAKEN (0.10.33): a day WorkTrust holds whole against this part keeps its runs here and asks again later.
1291
+ try { const held = /process_day_held/.test(await send(due.codex ? codexDoor ?? door : door, payload)); if (held) PROCESS.deferProcessDay(due.ref, 21_600); else { PROCESS.markProcessSent(due.ref, due); n += 1; } }
1292
+ catch (error) { PROCESS.deferProcessDay(due.ref, error.retryAfter ?? 300); if (error.retryAfter) liveWait(error.retryAfter); }
1293
+ }
1294
+ return n;
1295
+ }
1256
1296
 
1257
1297
  /**
1258
1298
  * THE MONTHS ALREADY ON THIS MACHINE, AS HISTORY.
@@ -1269,7 +1309,7 @@ async function send(door, payload) {
1269
1309
  * average of one. Younger than the live window is left alone — that is `log_work`'s half.
1270
1310
  */
1271
1311
  function historyEntries(floor = null, all = false) {
1272
- const entries = [];
1312
+ const entries = [], processGroups = new Map();
1273
1313
  for (const { file } of allTranscripts()) {
1274
1314
  const lines = parsedLines(file);
1275
1315
  if (!lines) continue;
@@ -1295,7 +1335,15 @@ function historyEntries(floor = null, all = false) {
1295
1335
  // The live window belongs to the hook: a stretch that log_work may still report is not history.
1296
1336
  if (!all && Date.now() - last < WINDOW_HOURS * 3600_000) continue;
1297
1337
  // The same measure as a live day (seconds, layers, tokens, turns, model); history differs only in the door it goes through.
1298
- const entry = payloadFor({ ...measure(cwd, messages, session), ref: stretchRef(file, day), steered, session, agents: agents.get(day) ?? null, live: liveOf(file, day) });
1338
+ const stretch = { ...measure(cwd, messages, session), ref: stretchRef(file, day), steered, session, agents: agents.get(day) ?? null, live: liveOf(file, day) };
1339
+ // ONE LINE PER PROCESS PER DAY (0.10.33), as live: an autonomous run joins its process's day, sent below as one line.
1340
+ if (isProcessRun(stretch)) {
1341
+ const key = processKey(CODEX_ROLLOUT.test(file) ? "codex" : ANTIGRAVITY_TRANSCRIPT.test(file) ? "antigravity" : DATABASE_SESSION.test(file) ? file.slice(0, file.indexOf(":")) : null, stretch, false);
1342
+ const group = processGroups.get(key.ref) ?? { ...key, runs: [], file, from: stretch.from, folder: cwd ? String(cwd).split(/[\\/]/).filter(Boolean).pop() ?? null : null };
1343
+ group.runs.push(processRun(file, stretch)); processGroups.set(key.ref, group);
1344
+ continue;
1345
+ }
1346
+ const entry = payloadFor(stretch);
1299
1347
  if (CODEX_ROLLOUT.test(file)) entrySource.set(entry, "codex");
1300
1348
  if (ANTIGRAVITY_TRANSCRIPT.test(file)) entrySource.set(entry, "antigravity");
1301
1349
  if (DATABASE_SESSION.test(file)) entrySource.set(entry, file.slice(0, file.indexOf(":")));
@@ -1303,6 +1351,7 @@ function historyEntries(floor = null, all = false) {
1303
1351
  entries.push(entry);
1304
1352
  }
1305
1353
  }
1354
+ for (const group of processGroups.values()) PROCESS.processParts(group.runs).forEach((runs, i) => { const entry = processPayload(group, i + 1, runs); entryFile.set(entry, { file: group.file, from: group.from, folder: group.folder }); entries.push(entry); });
1306
1355
  const seen = new Set(); // ONE SESSION FILE IN TWO PROJECT FOLDERS (a copied folder) IS ONE STRETCH (0.6.16, audit M6), as live and preserve count it
1307
1356
  return entries.filter((entry) => !seen.has(entry.stretch_ref) && seen.add(entry.stretch_ref)).sort((a, b) => a.at.localeCompare(b.at));
1308
1357
  }
@@ -1757,7 +1806,7 @@ if (work.length > 0 && input?.transcript_path && work[0].file === input.transcri
1757
1806
  const found = timerSchedule(), secret = found ? repoCodeSecret() : null, timer = found && secret ? { cadence: found.cadence, ref: createHmac("sha256", secret).update(`worktrust-schedule-ref|${found.ref}`).digest("base64url") } : null; // the label's hash keyed with this computer's secret, as repo_code (L4)
1758
1807
  if (timer &&state[work[0].id]?.schedule?.ref !== timer.ref) { state[work[0].id] = { ...(state[work[0].id] ?? {}), schedule: timer }; scheduleNoted = true; }
1759
1808
  }
1760
- let sent = 0, filed = 0, positioned = false;
1809
+ let sent = 0, filed = 0, folded = 0, positioned = false;
1761
1810
  const late = []; // measured days the live door will no longer take: they are not dropped, they are filed
1762
1811
  const heldBack = new Map(); // per transcript with a late day: its state before that day, put back unless history took every late day
1763
1812
  for (const entry of work) {
@@ -1776,14 +1825,24 @@ for (const entry of work) {
1776
1825
  // every day but today, on whichever run comes first — it no longer waits for its own end.
1777
1826
  if (Date.now() - stretch.to < IDLE_BEFORE_SWEEP) break;
1778
1827
  const total = grownBy(stretch, reported);
1779
- const payload = payloadFor({ ...stretch, schedule: state[entry.id]?.schedule ?? null });
1828
+ // THE TIMER'S SCHEDULE (0.10.32) travels with the run, so a scheduled process-day is its own process and its line names it.
1829
+ const timed = { ...stretch, schedule: state[entry.id]?.schedule ?? null };
1830
+ // ONE LINE PER PROCESS PER DAY (0.10.33): a finished autonomous run waits on disk for its day's line; the mark passes it once it is there.
1831
+ if (isProcessRun(timed)) {
1832
+ if (DRY) { console.log(JSON.stringify({ process_run: true, session_kind: timed.session, stretch_ref: timed.ref ?? null, at: new Date(timed.to).toISOString() })); through = timed.to; reported = total; continue; }
1833
+ try { PROCESS.foldProcessRun(processKey(LIVE_SOURCE.exec(String(entry.id))?.[1], timed, String(entry.id).startsWith("codex:")), processRun(entry.id, timed)); through = timed.to; reported = total; folded += 1; continue; } catch { break; }
1834
+ }
1835
+ const payload = payloadFor(timed);
1780
1836
  const source = LIVE_SOURCE.exec(String(entry.id))?.[1];
1781
1837
  if (source) entrySource.set(payload, source);
1782
1838
  if (DRY) { console.log(JSON.stringify({ ...payload, client: source ?? "claude", route: Date.now() - stretch.to > WINDOW_HOURS * 3600_000 ? "history" : "log_work" }, null, 1)); through = stretch.to; reported = total; continue; }
1783
1839
  // MEASURED TIME IS NEVER DROPPED. The live door refuses anything older than two days, which is right, and used to mean a machine closed
1784
1840
  // for a fortnight lost the fortnight. The same numbers go through the history door instead, standing as history stands. Late is not untrue.
1785
1841
  if (Date.now() - stretch.to > WINDOW_HOURS * 3600_000) { before ??= { mark: through === null ? state[entry.id] : { ...state[entry.id], through: new Date(through).toISOString() } }; late.push(payload); through = stretch.to; reported = total; continue; }
1842
+ // A LIMIT SAID WHEN (0.10.33): while WorkTrust asked to wait, nothing is sent; the mark stays and the next run sends it.
1843
+ if (liveWaiting()) break;
1786
1844
  try { await send(doorFor(entry), payload); through = stretch.to; reported = total; sent += 1; } catch (error) {
1845
+ if (error.retryAfter) liveWait(error.retryAfter);
1787
1846
  if (process.env.WORKTRUST_HOOK_DEBUG) console.error(`worktrust: ${error.message}`);
1788
1847
  break;
1789
1848
  }
@@ -1803,7 +1862,9 @@ if (!DRY && late.length > 0) {
1803
1862
  // session whose first late day waited (the owner's, from 2026-10-18) never moved again.
1804
1863
  if (filed < late.length && HISTORY_PERSISTED.n < late.length) for (const [id, mark] of heldBack) { if (mark) state[id] = mark; else delete state[id]; }
1805
1864
  }
1806
- if (!DRY && (sent > 0 || filed > 0 || scheduleNoted || positioned || (late.length > 0 && HISTORY_PERSISTED.n >= late.length))) writeState(state);
1865
+ // THE PROCESS-DAYS THAT ARE OVER (0.10.33): one line each; what WorkTrust does not take now stays on disk for the next run.
1866
+ await sendProcessDays();
1867
+ if (!DRY && (sent > 0 || filed > 0 || folded > 0 || scheduleNoted || positioned || LIVE_NOTED.n > 0 || (late.length > 0 && HISTORY_PERSISTED.n >= late.length))) writeState(state);
1807
1868
  // What an earlier run left in the outbox because the server never received it: a few batches a run, by itself; not in a run
1808
1869
  // that just sent late days itself (a batch it just tried waits for the next run). Since 0.10.32 the mark passes a late day the
1809
1870
  // outbox keeps, so the next run has no late day of its own and asks; before, a long session always had one and never asked.
@@ -1 +1 @@
1
- {"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"c6f5280c5bf81a14db4bdc282218fb005706e92dd9a9170c0e727716ee91685a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"3096ed1693974a90e1f4f59bf01c9559d94a7941d933e36fb81d3995a97f25c1","README.md":"34923747bec318637e6c93c543eb49b2a37cf2f67789b971ae3f7527975c860d","SECURITY.md":"b672649c7c7bf18538dd4560d7b533498721e0be765a000796d7d18390b5cbb6","chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"9466dc34e51c5c7443c68c9074cd21fb9be9d86e2633005d5033feb5d865c2cb","history-outbox.mjs":"b84e22542bb2d8195a469ee5f4116356ae9eac4a53ff2d40f0268b5b1de99dc5","log-session.mjs":"35d01fb00a472c022560a880c0863b57f24cb8311040bba21c3f0cf903b9074c","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"50adbece5072911c0a1421f92669fe7196013427a6fd08eb81456c7b56b5e5dc","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"ed6fef364aa28f39361d8f627abcda2162498cbaa13e90cc5860a768cb355fa2","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"0e481fde109620dd23f750d7b9b0741c0ea831c45961a176164ef2a74f3dd7c0"},"format":"worktrust-package/1","kind":"npm","version":"0.10.32"},"signature":"r4b807x7NWQzjC04Eu7Rto-dydbPoaNq_pd2MczLVIJC2Z_5fuaf8PQtxPLbrQbCqw1q19b_X_mWBl_giwvtBw"}
1
+ {"keyId":"608168ccdef72562fc91f9c0f9f2c2d6876bece7f7362cb545b818f7947da6b5","payload":{"files":{"AGENTS.md":"c6f5280c5bf81a14db4bdc282218fb005706e92dd9a9170c0e727716ee91685a","CLAUDE.md":"5933504f93e5a40369a4790e96dd5dad791d849d3178b1833eb64088e456aaeb","LICENSE":"3096ed1693974a90e1f4f59bf01c9559d94a7941d933e36fb81d3995a97f25c1","README.md":"f11eb9e172a9acad48bc0e27f5859cbeaa7c37c1b2989b52dfc49e164cede038","SECURITY.md":"b672649c7c7bf18538dd4560d7b533498721e0be765a000796d7d18390b5cbb6","chat-exports.mjs":"04eafe333940ec03d5058d8d51062124aa12ab882bf04db03bcda5613ec69298","claude-mod.mjs":"02d86b0cdddf39879efc5194c0a5be6b41456faedec28963dc123a4e88dc3942","config-edits.mjs":"0eba2f176ef6f7afba071d6e00de0ff19ba2b283180a801dfd957aa38c1edd94","count-behaviour.mjs":"1beaec2a4d0aead76d166f89cc52441a9cf48f2e69da9888ca2091dd3a10a37b","credential-store.mjs":"a4b3540a61f4ce19e535c7f1d260c0d817686cd066d559a76db2ab108144abba","credential-vault-scripts.mjs":"7e42fe1db3885c2dec6f1de87bebfbefe2292d29179a68f3da87d19eb6c7704b","credential-vault.mjs":"279baabb217e2a3f170e8d7f2b271a88484531f9031c441360ea91561a70da99","engine-release.json":"0e83cb929dac8a4c851ea47bbcbdd6d7f8ad1148d1084ef24619cb16e45bfd31","history-outbox.mjs":"b88072a28aa1dd94d9fab880f96b711b5fbed76ca62e5de24d612c08171e5b71","log-session.mjs":"d20e20c4fa5e4dd6a48a2c3b7caf4cefb090063503f38dc4716d8daee6d3bf22","orchestration-contract.mjs":"ec08f303a166365b99e70b675de4cfe76c6156c2567e14b5569f6d992f0231b7","orchestration-evidence.mjs":"d0d06cecf0eb08e5c6e653c62a4f45b1eddf2119c2acb8341056b34f488d214a","orchestration-report.mjs":"d4e0a9ad8e4a01b462d22c6b1866aac291565c533ff476085d3367cb6d59bc1b","package-integrity.mjs":"a8210c9494a56bfb9a5ea3d10064c7a269f0b6330c0af7c0700e706c3c0224e3","package.json":"1d9dbab38feaf5829be7df1feacf0a2b23b1374599d11c27d86c6661e26df80e","preserve-lines.mjs":"2df64a69687aa51219bf7b86b88d175cc50990fa29574b31897e41a9ebeecf43","preserve-summary.mjs":"137f781ed7021596a3f0ea67afcf2ab8616ac293f833dbb8f176e838e0ed8321","preserve.mjs":"3e369083ba43bcda2fa0622fd526aa64fcf8ad66e7b6e8f23821752c4d47ad27","runtime-install.mjs":"aab47b52c79d726ef428a24f982c648fa3f1c2dc2b574f633611d02924864e5f","session-databases.mjs":"543fd3b82d28d96d789be0a1dc9186c5fafa783e98b87e5b3b17b211542e2b4d","setup-mcp.mjs":"0c29113179561af1c1e9ff8b7a786e7240edf48a2244993e12335e5ee362c812","stack-rules.mjs":"b23c56e72ec56ba02b17ed895f869172d988c468a697e8d6026b0e268f61e489","stretch-evidence.mjs":"5f5667b92adf11b1a5a6330a0f26dd6db73d56fe60823d9a5246dab71d27d380","transcript-readers.mjs":"ed6fef364aa28f39361d8f627abcda2162498cbaa13e90cc5860a768cb355fa2","worktrust-launch.mjs":"84801bd29d472d48188c126b9ebe3989a3132b54e13cc4fe534ff7c383a294ee","worktrust.mjs":"804e7527618ff4ddea6b6457ff9878c1179581827580387b4468fd02af364266"},"format":"worktrust-package/1","kind":"npm","version":"0.10.33"},"signature":"zLrY_UyNlKq0iWFgAOn-mxP7K64ppxvECzEciY5qwu8E0N3fpmOmlN5v7AvX30KXY2XNwMmZeNMxlDsD4nttCQ"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "worktrust",
3
- "version": "0.10.32",
3
+ "version": "0.10.33",
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
@@ -76,7 +76,7 @@ const command = args.includes("--help") ? "help" : args.includes("--version") ?
76
76
  const flag = (name) => { const at = args.indexOf(`--${name}`); return at >= 0 ? args[at + 1] : undefined; };
77
77
  const has = (name) => args.includes(`--${name}`);
78
78
  /** 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). */
79
- const CLI_VERSION = "0.10.32";
79
+ const CLI_VERSION = "0.10.33";
80
80
  /**
81
81
  * 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
82
82
  * to offer). Raised ONLY when what is measured changes: the timeline, the seconds, the tokens, the steering, the session
@@ -84,6 +84,12 @@ const CLI_VERSION = "0.10.32";
84
84
  * the earlier install measured by other rules, and names what changed from MEASURE_CHANGES; installed-release.json and
85
85
  * history.json record it. 1 is the rules of 0.10.29, which 0.10.30 and 0.10.31 kept; 2 (0.10.32) adds the subagent runs, each
86
86
  * agent call's outcome and who wrote each turn of a run no person started.
87
+ * 0.10.33 KEEPS 2 (release 9, 2026-10-29): one line per autonomous process per day changes how finished headless and
88
+ * scheduled runs are PACKED into lines, not what is measured: the timeline, the seconds (the minute compaction keeps every
89
+ * counted second), the tokens, the steering, the session kinds and the readers are the same. On production (read-only) the
90
+ * existing data a re-measure would repack is 4 headless lines of one person on 2 days, none scheduled, none with a person's
91
+ * second and none under the 60 s floor, so a re-measure would move no figure the passport shows; raising would offer every
92
+ * person a re-measure for nothing. New runs arrive folded from 0.10.33 on.
87
93
  */
88
94
  const MEASURE_RULES = 2;
89
95
  /** What each measure-rules version changed, in the words the re-measure offer says (one entry per raise, never rewritten). */
@@ -233,7 +239,7 @@ async function pairByBrowser(host, extra) {
233
239
  server.close();
234
240
  if (!code) fail("no approval arrived in time. Run `worktrust connect` again.");
235
241
  const exchange = await post("/api/cli/token", { device_code: secret, code, code_verifier: verifier }).catch(() => null);
236
- 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.");
242
+ if (exchange?.json?.error === "device_limit") fail("The devices your plan allows are already connected. In WorkTrust Sources, disconnect a device (or upgrade to Premium for more), then connect again. Every connected device keeps working and earlier measurements are kept.");
237
243
  if (!exchange || exchange.status !== 200 || !exchange.json.token) fail(`the approval could not be exchanged (${exchange?.json?.error ?? "no answer"}). Run \`worktrust connect\` again.`);
238
244
  say(` ✓ Approved as "${exchange.json.label}"${exchange.json.account ? ` for the WorkTrust account ${exchange.json.account}` : ""}`);
239
245
  if (exchange.json.account) say(" Not your account? Run `npx worktrust disconnect` now and revoke it in WorkTrust.");
@@ -268,7 +274,7 @@ async function pairByCode(host, extra) {
268
274
  if (answer.json.account) say(" Not your account? Run `npx worktrust disconnect` now and revoke it in WorkTrust.");
269
275
  return paired(answer.json);
270
276
  }
271
- 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.");
277
+ if (answer.json.error === "device_limit") fail("The devices your plan allows are already connected. In WorkTrust Sources, disconnect a device (or upgrade to Premium for more), then connect again. Every connected device keeps working and earlier measurements are kept.");
272
278
  if (answer.json.error === "slow_down") wait += 2000;
273
279
  else if (answer.json.error === "expired_token") fail("the code expired. Run `worktrust connect` again.");
274
280
  else if (answer.json.error === "invalid_grant") fail("this pairing was already used. Run `worktrust connect` again.");