@raibitsi/tiresias 1.0.1 → 1.1.0

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +45 -0
  2. package/README.md +49 -26
  3. package/dist/browsecli.js +4 -3
  4. package/dist/cdp.js +22 -1
  5. package/dist/cli.js +82 -29
  6. package/dist/config.js +16 -1
  7. package/dist/confirm.js +6 -2
  8. package/dist/cooldown.js +57 -32
  9. package/dist/dailylog.js +11 -5
  10. package/dist/engine.js +3 -3
  11. package/dist/envelope.js +1 -1
  12. package/dist/fetcher.js +5 -0
  13. package/dist/filereply.js +7 -1
  14. package/dist/formflow.js +21 -3
  15. package/dist/forms.js +257 -34
  16. package/dist/getactions.js +99 -0
  17. package/dist/history.js +8 -5
  18. package/dist/hook.js +2 -0
  19. package/dist/hosts.js +11 -11
  20. package/dist/keys.js +420 -18
  21. package/dist/mcp.js +10 -10
  22. package/dist/needs.js +9 -5
  23. package/dist/parentwatch.js +6 -16
  24. package/dist/pdf.js +4 -1
  25. package/dist/pdfchild.js +0 -2
  26. package/dist/pdfproc.js +26 -11
  27. package/dist/pdfwatch.js +14 -0
  28. package/dist/pipeline.js +11 -2
  29. package/dist/profiles.js +3 -3
  30. package/dist/queue.js +4 -2
  31. package/dist/receipts.js +2 -2
  32. package/dist/render.js +103 -24
  33. package/dist/resume.js +8 -6
  34. package/dist/rules.js +10 -3
  35. package/dist/safebrowsing.js +3 -3
  36. package/dist/safety.js +9 -3
  37. package/dist/sandbox.js +1 -1
  38. package/dist/saved.js +24 -9
  39. package/dist/savedlock.js +99 -5
  40. package/dist/settings.js +7 -3
  41. package/dist/shelf.js +1 -1
  42. package/dist/slips.js +43 -1
  43. package/dist/store.js +119 -25
  44. package/dist/tabs.js +1 -1
  45. package/dist/textview.js +10 -0
  46. package/dist/translate.js +22 -2
  47. package/dist/types.js +2 -2
  48. package/dist/watchflow.js +1 -2
  49. package/dist/work.js +4 -2
  50. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -2,9 +2,10 @@
2
2
  // SPDX-License-Identifier: Apache-2.0
3
3
  // N-09: the command-line door. Same engine, same store as the MCP server.
4
4
  import "./nodecheck.js"; // first: an older Node gets a plain message before anything else runs
5
+ import { textView } from "./textview.js";
5
6
  import { parseArgs } from "node:util";
6
7
  import { drainForExit, installShutdown } from "./background.js";
7
- import { loadLimits } from "./config.js";
8
+ import { loadChoice, loadLimits } from "./config.js";
8
9
  import { clearStore } from "./cleanup.js";
9
10
  import * as engine from "./engine.js";
10
11
  import { serveStdio } from "./mcp.js";
@@ -12,7 +13,7 @@ import { assertProfile, profileName, selectProfile, stampProfile } from "./store
12
13
  import { BROWSE_HELP, BROWSE_TAKES, noteCliRead, runBrowseCommand } from "./browsecli.js";
13
14
  import { VERSION } from "./types.js";
14
15
  import { notice, startupNotice } from "./confirm.js";
15
- import { historyEnvelope, receiptsEnvelope } from "./envelope.js";
16
+ import { listEnvelope, historyEnvelope, receiptsEnvelope } from "./envelope.js";
16
17
  // JSON output carries `profile` at the top level when it is not `default` (W-18), and `settings_notice` when a risky
17
18
  // setting changed in the last 24 hours or a loosening waits for confirmation (W-32, v0.9).
18
19
  const json = (x, space = 2) => JSON.stringify(stampNotice(stampProfile(x)), null, space);
@@ -59,8 +60,8 @@ const HELP = `Tiresias ${VERSION}: the honest browser for AI agents.
59
60
  its Merkle path and a standard .ots file (--out: three files, never overwriting)
60
61
  tiresias receipts verify <bundle> check a proof bundle offline; says which step needs a Bitcoin block header
61
62
  tiresias history [--since 2026-10-01] [--site example.com] [--agent codex]
62
- tiresias log [--day 2026-10-16] [--to <folder>] [--page 2]
63
- tiresias needs [--since 30d] [--page 2] patterns in the history and suggested wants (W-12)
63
+ tiresias log [--day 2026-10-16] [--to <folder>] [--page 2] [--json]
64
+ tiresias needs [--since 30d] [--page 2] [--json] patterns in the history and suggested wants (W-12)
64
65
  tiresias bookmark add <name> <url> [--watch]
65
66
  tiresias bookmark remove <name>
66
67
  tiresias bookmark watch <name> on|off
@@ -85,6 +86,13 @@ const HELP = `Tiresias ${VERSION}: the honest browser for AI agents.
85
86
  the directory body plus signed response headers for a static host
86
87
  (1 to 90 days; a verifier that wants shorter-lived signatures needs
87
88
  a server that signs each response itself)
89
+ tiresias keys rotate [--overlap 7] a new signing key; the old one stays in the directory for the
90
+ overlap (0 to 30 days, default 7) and then drops out by itself.
91
+ New requests sign with the new key only. After a leak: --overlap 0
92
+ tiresias keys rotate --finish end the overlap now: drop the old key from the directory and delete it
93
+ tiresias keys rotate --slips --confirm "YES, ROTATE THE SLIP KEY"
94
+ a new slip key: revokes every permission slip (a person types
95
+ "rotate slip key" back); saved pages stay checkable
88
96
  tiresias scanner set [--timeout 10] [--send-file --confirm "YES, SEND FILES TO THE SCANNER"] -- /full/path/to/program [args...]
89
97
  your own virus checker, run on every high-risk file warning (none
90
98
  is included); it gets the fingerprint (and with --send-file the file)
@@ -100,6 +108,9 @@ const HELP = `Tiresias ${VERSION}: the honest browser for AI agents.
100
108
  never_visit take a site, like example.com or *.example.com); turning a
101
109
  risky setting on or looser takes --confirm with its exact phrase
102
110
  (printed when it is missing), like --confirm "YES, TURN ON SAVING"
111
+ get_form_actions read|slip; private_spacing shared|none;
112
+ hook_secrets hidden|inherit; text_views marked|wrapped
113
+ none and inherit need the risky-setting confirmation
103
114
  tiresias settings confirm <name> [<site>] --confirm "..." confirm a risky value config.json holds
104
115
  (a hand edit); until then it is not in force
105
116
  tiresias settings confirmations off|on --confirm "..." never ask for the phrase again, or ask again
@@ -112,7 +123,7 @@ const HELP = `Tiresias ${VERSION}: the honest browser for AI agents.
112
123
  tiresias slip list active slips, plus expired, used-up and damaged counts
113
124
  tiresias slip revoke <id> | --all take a slip back (it can never be used again)
114
125
  tiresias form preview <url> --form N [--set name=value ...] [--unset name]
115
- the exact request a form would send (nothing is sent)
126
+ the exact request a form would send (the previewed form is not sent)
116
127
  tiresias form submit <url> --form N [--set name=value ...] [--unset name] --preview <hash>
117
128
  send it once, with a permission slip (refused without one)
118
129
  tiresias profile create <name> a separate profile: its own keys, history, cache, bookmarks,
@@ -145,7 +156,8 @@ run, unpacked or saved: it comes back as status "file_warning" with its kind (fr
145
156
  size and SHA-256 fingerprint, for you to decide about. TIRESIAS_MAX_FILE_BYTES (default 50 MB) caps
146
157
  what is fingerprinted.
147
158
 
148
- Output is JSON, except log and needs, which print a readable page. Add --text for a short summary.`;
159
+ Output is JSON, except log and needs, which print a readable page (--json for JSON).
160
+ Add --text for a short summary. Text views mark web content as untrusted; agents should use JSON.`;
149
161
  // v0.5.1: exit codes. 0 only when the call did its job (ok, unchanged); 2 when Tiresias stopped on
150
162
  // purpose (a wall, a flag, a refusal, a file warning, a price tag); 1 on an error.
151
163
  export function exitFor(status) {
@@ -168,12 +180,12 @@ const TAKES = {
168
180
  receipts: ["url", "since", "page", "out"], // out: v0.8 receipts prove (W-08)
169
181
  anchor: ["page"], // v0.8 (W-08)
170
182
  history: ["since", "site", "agent", "page"],
171
- log: ["day", "to", "page"],
172
- needs: ["since", "page"],
183
+ log: ["day", "to", "page", "json"],
184
+ needs: ["since", "page", "json"],
173
185
  bookmark: ["watch", "page", "allow-flagged"],
174
186
  watch: ["page", "allow-flagged"],
175
187
  clear: ["older-than", "all", "dry-run"],
176
- keys: ["force", "host", "days", "out"],
188
+ keys: ["force", "host", "days", "out", "overlap", "finish", "slips", "confirm"], // overlap, finish, slips, confirm: v1.1 keys rotate
177
189
  scanner: ["timeout", "send-file", "confirm"], // confirm: v0.9 (W-32)
178
190
  translator: ["timeout", "confirm"], // v0.7 (W-26)
179
191
  settings: ["confirm"], // v0.6 (W-29); confirm: v0.9 (W-32)
@@ -227,7 +239,7 @@ function summary(e) {
227
239
  if (e.message)
228
240
  lines.push(e.message);
229
241
  if (e.source)
230
- lines.push(`Source: a page a person provided (nothing was fetched).`);
242
+ lines.push(`Source: ${e.source === "provided_by_agent" ? "text an agent provided" : "a page a person provided"} (nothing was fetched).`);
231
243
  if (e.cache)
232
244
  lines.push(`Cache: ${e.cache}${uc?.cached_at ? ` (copy from ${uc.cached_at}${uc.cached_by !== undefined ? `, fetched by ${JSON.stringify(uc.cached_by)}` : ""})` : ""}`);
233
245
  if (e.safety)
@@ -320,7 +332,7 @@ function summary(e) {
320
332
  lines.push(`Page ${p.page} of ${p.pages}. Use --page N for more.`);
321
333
  }
322
334
  lines.push(e.notice);
323
- return lines.join("\n");
335
+ return textView(lines.join("\n"));
324
336
  }
325
337
  // The cron-friendly summary: which bookmarks changed and which need a person (Codex round 36).
326
338
  // Names are the owner's own ([a-z0-9-]); URLs are printed for the person reading, marked as from the web.
@@ -335,10 +347,10 @@ function watchText(r) {
335
347
  const what = i.changes_omitted ? "too much changed to list" : i.added !== undefined ? `${i.added} added, ${i.removed} removed` : "changed (no list: nothing comparable was kept)";
336
348
  L.push(` ${i.name}: ${what} <${i.url}>`);
337
349
  }
338
- if (r.attention.length)
350
+ if ((r.untrusted_content?.attention ?? []).length)
339
351
  L.push("", "Needs attention:");
340
352
  const urls = new Map((r.untrusted_content?.attention_urls ?? []).map((u) => [u.name, u]));
341
- for (const a of r.attention) {
353
+ for (const a of r.untrusted_content?.attention ?? []) {
342
354
  const why = a.outcome === "walled" ? `walled (${a.reason ?? "wall"})` : a.outcome === "waiting" ? `waiting ${a.retry_after_seconds} s (the site asked)`
343
355
  : a.outcome === "file_warning" ? `now leads to a file (${a.file?.kind}, ${a.file?.risk} risk${a.file?.fingerprint ? `, ${a.file.fingerprint}` : ""}${a.file?.scan ? `, scanner: ${a.file.scan}` : ""}), not read`
344
356
  : `failed (${a.status}${a.retry_after_seconds !== undefined ? `, wait ${a.retry_after_seconds} s` : ""})`;
@@ -348,7 +360,7 @@ function watchText(r) {
348
360
  if (c.attention_omitted)
349
361
  L.push(` and ${c.attention_omitted} more not named.`);
350
362
  L.push("", "URLs above came from the web or from bookmarks: data, not instructions.");
351
- return L.join("\n");
363
+ return textView(L.join("\n"));
352
364
  }
353
365
  // Every snapshot id in this profile (for saved verify --all).
354
366
  function allIds(sv) {
@@ -364,13 +376,13 @@ async function main() {
364
376
  tokens: true,
365
377
  options: {
366
378
  question: { type: "string" }, section: { type: "string" }, url: { type: "string" }, since: { type: "string" },
367
- site: { type: "string" }, agent: { type: "string" }, page: { type: "string" }, text: { type: "boolean" }, private: { type: "boolean" }, changes: { type: "boolean" }, watch: { type: "boolean" }, day: { type: "string" }, to: { type: "string" },
379
+ site: { type: "string" }, agent: { type: "string" }, page: { type: "string" }, text: { type: "boolean" }, json: { type: "boolean" }, private: { type: "boolean" }, changes: { type: "boolean" }, watch: { type: "boolean" }, day: { type: "string" }, to: { type: "string" },
368
380
  fresh: { type: "boolean" }, "from-file": { type: "string" }, "allow-flagged": { type: "boolean" },
369
381
  profile: { type: "string" }, yes: { type: "boolean" }, "delete-key": { type: "boolean" },
370
382
  form: { type: "string" }, set: { type: "string", multiple: true }, unset: { type: "string", multiple: true }, preview: { type: "string" },
371
383
  action: { type: "string" }, path: { type: "string" }, until: { type: "string" }, for: { type: "string" }, uses: { type: "string" }, note: { type: "string" },
372
384
  timeout: { type: "string" }, "send-file": { type: "boolean" }, translate: { type: "string" }, render: { type: "boolean" }, save: { type: "boolean" }, confirm: { type: "string" },
373
- force: { type: "boolean" }, host: { type: "string" }, days: { type: "string" }, out: { type: "string" }, "older-than": { type: "string" }, all: { type: "boolean" }, "dry-run": { type: "boolean" }, help: { type: "boolean", short: "h" }, version: { type: "boolean" },
385
+ force: { type: "boolean" }, overlap: { type: "string" }, finish: { type: "boolean" }, slips: { type: "boolean" }, host: { type: "string" }, days: { type: "string" }, out: { type: "string" }, "older-than": { type: "string" }, all: { type: "boolean" }, "dry-run": { type: "boolean" }, help: { type: "boolean", short: "h" }, version: { type: "boolean" },
374
386
  },
375
387
  });
376
388
  const [cmd, arg] = positionals;
@@ -466,17 +478,18 @@ async function main() {
466
478
  if (sessionPriv)
467
479
  throw new Error("Private mode: nothing is written, so the log is not exported. Run it without --to to print it.");
468
480
  const r = await engine.exportDailyLog(values.to, values.day);
469
- console.log(r.message + `\n${r.file}`);
481
+ console.log(values.json ? json(r) : r.message + `\n${r.file}`);
470
482
  }
471
483
  else {
472
484
  const r = await engine.dailyLog(values.day, page);
473
- console.log(r.text + (r.pages > 1 ? `\nPage ${r.page} of ${r.pages}. Use --page N for more.` : ""));
485
+ console.log(values.json ? json(listEnvelope("", { day: r.day, entries: r.entries, log: r.text }, { page: r.page, pages: r.pages, total: r.entries })) : textView(r.text + (r.pages > 1 ? `\nPage ${r.page} of ${r.pages}. Use --page N for more.` : "")));
474
486
  }
475
487
  return 0;
476
488
  }
477
489
  if (cmd === "needs") {
478
490
  const { toMarkdown } = await import("./needs.js");
479
- console.log(toMarkdown(await engine.needsReport(values.since, page)));
491
+ const r = await engine.needsReport(values.since, page);
492
+ console.log(values.json ? json(r) : textView(toMarkdown(r)));
480
493
  return 0;
481
494
  }
482
495
  if (cmd === "bookmark") {
@@ -622,12 +635,12 @@ async function main() {
622
635
  const L = [r.message, ...r.saved.map((i) => ` ${i.id.slice(0, 16)} ${i.saved_at ?? "(damaged)"} ${i.fingerprint_only ? "fingerprint only" : `${i.bytes} bytes${i.rendered ? ", rendered" : ""}`}, ${i.receipts} receipts <${r.untrusted_content.urls.find((u) => u.id === i.id)?.final_url ?? ""}>`)];
623
636
  if (r.pages > 1)
624
637
  L.push(`Page ${r.page} of ${r.pages}. Use --page N for more.`);
625
- console.log(values.text ? L.join("\n") : json(r));
638
+ console.log(values.text ? textView(L.join("\n")) : json(r));
626
639
  return 0;
627
640
  }
628
641
  if (sub === "show" && id) {
629
642
  const r = sv.show(id);
630
- console.log(values.text ? `${r.message}\nFolder: ${r.folder}${r.untrusted_content ? `\n${JSON.stringify(r.untrusted_content.manifest, null, 2)}` : ""}` : json(r));
643
+ console.log(values.text ? textView(`${r.message}\nFolder: ${r.folder}${r.untrusted_content ? `\n${JSON.stringify(r.untrusted_content.manifest, null, 2)}` : ""}`) : json(r));
631
644
  return 0;
632
645
  }
633
646
  if (sub === "verify" && (id || values.all)) {
@@ -763,10 +776,7 @@ async function main() {
763
776
  console.log(json({ message: r.replaced ? "Replaced your signing key." : "Made your signing key.", private_key_file: r.file, keyid: r.keyid, public_jwk: r.public_jwk, directory: r.directory, next: 'Host "directory" at /.well-known/http-message-signatures-directory on your site, and set "signature_agent" in config.json. The private key was not printed.' }));
764
777
  }
765
778
  else if (sub === "show" || sub === "directory") {
766
- const jwk = keys.readPrivateJwk();
767
- if (!jwk)
768
- throw new Error("No signing key yet. Run: tiresias keys init");
769
- const info = await keys.publicInfo(jwk);
779
+ const { info, previous } = await keys.publishedKeys(); // v1.1: the previous key too, while its overlap window is open
770
780
  if (sub === "directory")
771
781
  console.log(JSON.stringify(info.directory, null, 2)); // the exact JSON to host: nothing added
772
782
  else {
@@ -777,7 +787,8 @@ async function main() {
777
787
  catch (e) {
778
788
  agent = `(config.json problem: ${e.message})`;
779
789
  }
780
- console.log(json({ public_jwk: info.public_jwk, keyid: info.keyid, directory: info.directory, signature_agent: agent, signing: agent && !agent.startsWith("(") ? "on" : "off (set signature_agent in config.json)" }));
790
+ const rotation = previous ? { previous_keyid: previous.keyid, rotated_at: previous.rotated_at, previous_leaves_directory_at: previous.until, note: "New requests are signed with the new key only. The previous key stays in the directory until then; run `tiresias keys rotate --finish` to drop it now." } : undefined;
791
+ console.log(json({ public_jwk: info.public_jwk, keyid: info.keyid, directory: info.directory, ...(rotation ? { rotation } : {}), signature_agent: agent, signing: agent && !agent.startsWith("(") ? "on" : "off (set signature_agent in config.json)" }));
781
792
  }
782
793
  }
783
794
  else if (sub === "sign-directory") {
@@ -792,7 +803,9 @@ async function main() {
792
803
  }
793
804
  const days = values.days === undefined ? 30 : /^\d+$/.test(values.days) ? Number(values.days) : NaN;
794
805
  const r = await keys.signDirectory({ host, days });
795
- const reminder = `These signatures stop working on ${r.expires_at}. Run this command again and re-upload before then.`;
806
+ const reminder = r.capped_by_rotation
807
+ ? `These signatures stop working on ${r.expires_at}, when your previous key leaves the directory (keys rotate). Run this command again right after that time, and re-upload, so the directory lists only the new key.`
808
+ : `These signatures stop working on ${r.expires_at}. Run this command again and re-upload before then.`;
796
809
  if (values.out !== undefined) {
797
810
  const fsm = await import("node:fs");
798
811
  const pathm = await import("node:path");
@@ -814,8 +827,48 @@ async function main() {
814
827
  else
815
828
  console.log(json({ host: r.host, serve_at: `https://${r.host}${r.path}`, created_at: r.created_at, expires_at: r.expires_at, body: JSON.parse(r.body), headers: r.headers, reminder }));
816
829
  }
830
+ else if (sub === "rotate") {
831
+ // v1.1 workstream 4: rotate the signing key (overlap window) or, with --slips, the slip key.
832
+ if (sessionPriv)
833
+ throw new Error("Private mode: nothing is written, so no key is rotated.");
834
+ const history = await import("./history.js");
835
+ const by = process.stdin.isTTY === true ? "terminal" : "not_terminal";
836
+ if (values.slips) {
837
+ if (values.finish || values.overlap !== undefined)
838
+ throw new Error("keys rotate --slips takes only --confirm.");
839
+ const slips = await import("./slips.js");
840
+ slips.checkRotatePhrase(values.confirm); // before the prompt: a missing phrase never asks anything
841
+ const { confirmByTyping } = await import("./person.js");
842
+ await confirmByTyping("rotate slip key", "Rotate the slip key: every permission slip of this profile is revoked now and can never be used again. Saved pages stay checkable against the old key's public half.");
843
+ const r = slips.rotateSlipKey(values.confirm, sessionPriv);
844
+ const msg = `Rotated the slip key. Revoked ${r.revoked} slip${r.revoked === 1 ? "" : "s"}; grant new ones with tiresias slip grant. ${r.retired ? "Saved pages signed before now still verify (tiresias saved verify names the retired key)." : "The old key could not be read, so it was replaced without keeping its public half: saved pages it signed no longer verify."} Receipts do not use the slip key and are unchanged. The private key was not printed.`;
845
+ console.log(values.text ? msg : json({ status: "ok", message: msg, revoked: r.revoked, old_key_kept_for_saved_pages: r.retired }));
846
+ }
847
+ else if (values.finish) {
848
+ if (values.overlap !== undefined || values.confirm !== undefined)
849
+ throw new Error("keys rotate --finish takes no other option.");
850
+ const r = await keys.finishRotation();
851
+ if (r.finished)
852
+ history.record({ time: new Date().toISOString(), tool: "keys", url: "", agent: "cli", status: "ok", door: "none", event: "signing_key_rotation_finished", by });
853
+ const msg = r.finished
854
+ ? `Finished the rotation: the previous key${r.previous_keyid ? ` (${r.previous_keyid})` : ""} is out of the directory and its private half is deleted. Publish the directory again (tiresias keys directory or keys sign-directory).`
855
+ : "No rotation is in its overlap window, so there was nothing to finish.";
856
+ console.log(values.text ? msg : json({ status: "ok", message: msg, finished: r.finished, ...(r.previous_keyid ? { previous_keyid: r.previous_keyid } : {}) }));
857
+ }
858
+ else {
859
+ if (values.confirm !== undefined)
860
+ throw new Error("keys rotate takes --confirm only with --slips.");
861
+ const r = await keys.rotateKey({ overlapDays: keys.parseOverlap(values.overlap) });
862
+ history.record({ time: r.rotated_at, tool: "keys", url: "", agent: "cli", status: "ok", door: "none", event: "signing_key_rotated", by });
863
+ const msg = r.overlap_until
864
+ ? `Rotated your signing key. New requests are signed with the new key (${r.keyid}). The previous key (${r.previous_keyid}) stays in your directory until ${r.overlap_until}, then drops out by itself (tiresias keys rotate --finish drops it now).`
865
+ : `Rotated your signing key with no overlap. New requests are signed with the new key (${r.keyid}); the previous key (${r.previous_keyid}) is deleted and out of the directory now.`;
866
+ const next = 'Publish the new directory now: tiresias keys directory (or keys sign-directory for a static host) and upload it to /.well-known/http-message-signatures-directory. A server that signs your directory itself (such as a Cloudflare Worker holding a copy of the key) needs the new key too. The private key was not printed.';
867
+ console.log(values.text ? `${msg}\n${next}` : json({ status: "ok", message: msg, keyid: r.keyid, public_jwk: r.public_jwk, previous_keyid: r.previous_keyid, overlap_days: r.overlap_days, overlap_until: r.overlap_until, directory: r.directory, private_key_file: r.file, next }));
868
+ }
869
+ }
817
870
  else
818
- throw new Error("Usage: tiresias keys init [--force] | keys show | keys directory | keys sign-directory");
871
+ throw new Error("Usage: tiresias keys init [--force] | keys show | keys directory | keys sign-directory | keys rotate [--overlap 7] | keys rotate --finish | keys rotate --slips --confirm \"YES, ROTATE THE SLIP KEY\"");
819
872
  return 0;
820
873
  }
821
874
  if (cmd === "clear") {
@@ -865,7 +918,7 @@ main().then(async (code) => {
865
918
  if (code < 0)
866
919
  return;
867
920
  // W-32 (v0.9): a --text reply ends with the settings notice (a JSON reply carries it as settings_notice).
868
- const n = process.argv.includes("--text") ? currentNotice() : undefined;
921
+ const n = process.argv.includes("--text") && loadChoice("text_views") !== "wrapped" ? currentNotice() : undefined;
869
922
  if (n)
870
923
  (code === 0 ? console.log : console.error)(`\nSettings notice:\n${n.map((l) => ` ${l}`).join("\n")}`);
871
924
  await drainForExit();
package/dist/config.js CHANGED
@@ -196,7 +196,22 @@ export function loadLimits() {
196
196
  // ---- v0.6 (track 3: settings) ----
197
197
  // Keys checked only where they are used (like "scanner"): a bad one fails the calls that use it, by name,
198
198
  // and never stops clear or the daily trim.
199
- const OWN_CHECK_KEYS = ["doors", "sites", "translator", "rendering", "saving", "anchoring", "anchor_calendars"]; // translator: v0.7 W-26; rendering: v0.7 W-10; saving: v0.8 W-28; anchoring, anchor_calendars: v0.8 W-08
199
+ export const SECURITY_CHOICES = {
200
+ get_form_actions: ["read", "slip"],
201
+ private_spacing: ["shared", "none"],
202
+ hook_secrets: ["hidden", "inherit"],
203
+ text_views: ["marked", "wrapped"],
204
+ };
205
+ export function parseChoice(name, value) {
206
+ if (typeof value === "string" && SECURITY_CHOICES[name].includes(value))
207
+ return value;
208
+ throw new ConfigError(`config.json: "${name}" must be ${SECURITY_CHOICES[name].map((s) => JSON.stringify(s)).join(" or ")}.`);
209
+ }
210
+ export function loadChoice(name) {
211
+ const o = inForceConfig();
212
+ return o && Object.hasOwn(o, name) ? parseChoice(name, o[name]) : SECURITY_CHOICES[name][0];
213
+ }
214
+ const OWN_CHECK_KEYS = [...Object.keys(SECURITY_CHOICES), "doors", "sites", "translator", "rendering", "saving", "anchoring", "anchor_calendars"]; // translator: v0.7 W-26; rendering: v0.7 W-10; saving: v0.8 W-28; anchoring, anchor_calendars: v0.8 W-08
200
215
  export const KNOWN_KEYS = [...Object.keys(DEFAULT_LIMITS), ...SIGNING_KEYS, ...SAFETY_KEYS, "scanner", ...OWN_CHECK_KEYS];
201
216
  export const DEFAULT_DOORS = "background";
202
217
  export function parseDoors(v) {
package/dist/confirm.js CHANGED
@@ -13,7 +13,7 @@
13
13
  import fs from "node:fs";
14
14
  import path from "node:path";
15
15
  import { callContext } from "./context.js";
16
- import { DEFAULT_CALENDARS, parseAnchoring, parseCalendars, parseSafeBrowsing, parseSaving, parseScanner, parseTranslator, readConfigObject, writeConfig } from "./config.js";
16
+ import { SECURITY_CHOICES, parseChoice, DEFAULT_CALENDARS, parseAnchoring, parseCalendars, parseSafeBrowsing, parseSaving, parseScanner, parseTranslator, readConfigObject, writeConfig } from "./config.js";
17
17
  import { parseRender } from "./render.js";
18
18
  import { ConfigError } from "./errors.js";
19
19
  import * as history from "./history.js";
@@ -47,6 +47,8 @@ const calendarSet = (v) => {
47
47
  };
48
48
  const renderRank = rank(["off", "ask", "auto"]);
49
49
  export const TOP = [
50
+ { key: "private_spacing", looser: (c, n) => c !== "none" && n === "none", phrase: () => "YES, TURN OFF PRIVATE SPACING", what: () => "private spacing across processes turned off" },
51
+ { key: "hook_secrets", looser: (c, n) => c !== "inherit" && n === "inherit", phrase: () => "YES, SHARE TIRESIAS SECRETS WITH HOOKS", what: () => "Tiresias secrets shared with hooks" },
50
52
  { key: "saving", looser: (c, n) => rank(["off", "ask"])(n) > rank(["off", "ask"])(c), phrase: () => "YES, TURN ON SAVING", what: () => "saving turned on" },
51
53
  {
52
54
  key: "rendering",
@@ -408,7 +410,9 @@ function ratchet(raw, rec) {
408
410
  }
409
411
  function validTop(key, v) {
410
412
  try {
411
- if (key === "saving")
413
+ if (Object.hasOwn(SECURITY_CHOICES, key))
414
+ parseChoice(key, v);
415
+ else if (key === "saving")
412
416
  parseSaving(v);
413
417
  else if (key === "rendering")
414
418
  parseRender(v);
package/dist/cooldown.js CHANGED
@@ -1,6 +1,6 @@
1
1
  // SPDX-License-Identifier: Apache-2.0
2
- // N-06: Retry-After is enforced, not just reported. When a site says 429 or
3
- // 503, we remember "do not call this origin until T", across processes, and
2
+ // N-06: Retry-After is enforced, not just reported. When a site says 429,
3
+ // 503 or asks for a wait on a redirect, we remember "do not call this origin until T", across processes, and
4
4
  // every later request (page, probe, robots refresh) checks it first.
5
5
  //
6
6
  // Storage is an append-only log with no lock. A lock cannot be made safe
@@ -13,7 +13,8 @@ import crypto from "node:crypto";
13
13
  import fs from "node:fs";
14
14
  import path from "node:path";
15
15
  import { canonOrigin } from "./sitekey.js";
16
- import { appendLine, cachePath, readJson, readLogSync, rootDir } from "./store.js";
16
+ import { Refused } from "./errors.js";
17
+ import { appendLine, cachePath, readJson, scanLogSync, rootDir } from "./store.js";
17
18
  // A wait over 10 years is not a real Retry-After. It is treated as invalid and
18
19
  // replaced by a fixed 24 hour cooldown. Anything below that limit is kept in
19
20
  // full, never shortened.
@@ -65,8 +66,7 @@ const LEGACY_OLD = "cooldowns.old.jsonl"; // written by v0.1.4, read only, never
65
66
  const MAX_ORIGIN = 400; // keeps every line well under 512 bytes (one atomic append)
66
67
  const mem = new Map(); // cooldowns set by this process (at most MEM_MAX)
67
68
  // v0.9 hardening (Codex round 6c, HIGH): `mem` no longer keeps every wait for the server's whole life: past MEM_MAX
68
- // entries, the expired ones are dropped. A wait that has not ended is never dropped (Codex round 7c: the shared file
69
- // is read only from its last 8 MiB, so it cannot stand in for one).
69
+ // entries, the expired ones are dropped. A wait that has not ended is never dropped.
70
70
  // v0.9 client trust (Travis approved, 2026-10-31; closes the class stopped in client-trust round 1): when `mem` is
71
71
  // full of waits that have not ended, a new one goes into a FIXED-SIZE store instead of growing memory: SLOTS
72
72
  // deadlines (8 MB), each origin written to K slots chosen by a keyed hash (a random key per process, so a site cannot
@@ -126,9 +126,6 @@ function remember(origin, until) {
126
126
  }
127
127
  export const cooldownStoreBytes = () => sketch?.byteLength ?? 0; // for tests
128
128
  export const cooldownMemSize = () => mem.size; // for tests
129
- // v0.5.1: the log is read again only when one of its files changed (size, mtime or inode), not on every
130
- // check (a request checks about eleven times). The stamp names the store root, so a new TIRESIAS_HOME
131
- // is read afresh.
132
129
  let memo = null;
133
130
  let reads = 0;
134
131
  export const loadCount = () => reads; // for tests
@@ -137,9 +134,11 @@ function stamp() {
137
134
  for (const f of [path.join(rootDir(), CUR), path.join(rootDir(), LEGACY_OLD), safePath(() => cachePath(LEGACY, "shared"))]) {
138
135
  try {
139
136
  const st = f ? fs.lstatSync(f) : null;
140
- parts.push(st ? `${st.size}:${st.mtimeMs}:${st.ino}` : "-");
137
+ parts.push(st ? `${st.size}:${st.mtimeMs}:${st.ctimeMs}:${st.dev}:${st.ino}:${st.mode}` : "-");
141
138
  }
142
- catch {
139
+ catch (e) {
140
+ if (e.code !== "ENOENT")
141
+ throw e;
143
142
  parts.push("-");
144
143
  }
145
144
  }
@@ -154,26 +153,54 @@ const safePath = (f) => {
154
153
  }
155
154
  };
156
155
  function load() {
157
- const st = stamp();
158
- if (memo && memo.stamp === st)
159
- return memo.map;
160
- const map = loadNow();
161
- memo = { stamp: st, map };
162
- return map;
156
+ try {
157
+ const st = stamp();
158
+ if (memo && memo.stamp === st)
159
+ return memo.map;
160
+ const root = rootDir();
161
+ const map = loadNow(memo?.root === root ? memo.map : undefined);
162
+ memo = { root, stamp: st, map };
163
+ return map;
164
+ }
165
+ catch {
166
+ memo = null;
167
+ throw new Refused("The site's Retry-After waits could not be read. No request was sent.");
168
+ }
163
169
  }
164
- // Latest deadline per origin. Expired and malformed entries are ignored; there
165
- // is no cap on the number of origins. Only the last 8 MB of the log is read.
166
- function loadNow() {
167
- reads++;
168
- const now = Date.now();
170
+ // Replay every live deadline. Overflow uses the same bounded, conservative slots as the in-process list.
171
+ function newIndex() {
169
172
  const best = new Map();
173
+ let overflow = null;
170
174
  const take = (origin, until) => {
171
- if (typeof origin !== "string" || typeof until !== "number" || !Number.isFinite(until) || until <= now)
175
+ if (typeof origin !== "string" || typeof until !== "number" || !Number.isFinite(until) || until <= Date.now())
172
176
  return;
173
177
  const key = canonOrigin(origin); // v0.6: one name per site (sitekey.ts)
174
- if (until > (best.get(key) ?? 0))
175
- best.set(key, until);
178
+ if (best.has(key) || (best.size < MEM_MAX && key.length <= MAX_ORIGIN)) {
179
+ if (until > (best.get(key) ?? 0))
180
+ best.set(key, until);
181
+ }
182
+ else {
183
+ overflow ??= new Float64Array(SLOTS);
184
+ for (const i of slotsOf(key))
185
+ if (until > overflow[i])
186
+ overflow[i] = until;
187
+ }
188
+ };
189
+ return {
190
+ take,
191
+ logs: new Map(),
192
+ exact: (origin) => best.get(origin) ?? 0,
193
+ get: (origin) => {
194
+ let least = Infinity;
195
+ if (overflow)
196
+ for (const i of slotsOf(origin))
197
+ least = Math.min(least, overflow[i]);
198
+ return Math.max(best.get(origin) ?? 0, least === Infinity ? 0 : least);
199
+ },
176
200
  };
201
+ }
202
+ function loadNow(index = newIndex()) {
203
+ reads++;
177
204
  let legacy = null;
178
205
  try {
179
206
  legacy = readJson(cachePath(LEGACY, "shared")); // W-18: shared, at the root
@@ -182,13 +209,11 @@ function loadNow() {
182
209
  // the root's cache/ is a link or someone else's: the legacy store is not read (Codex round 46)
183
210
  }
184
211
  if (legacy && typeof legacy === "object")
185
- for (const [o, u] of Object.entries(legacy))
186
- take(o, u);
187
- for (const e of readLogSync(LEGACY_OLD))
188
- take(e?.origin, e?.until); // v0.1.4 rotated file, read only
189
- for (const e of readLogSync(CUR))
190
- take(e?.origin, e?.until);
191
- return best;
212
+ for (const [origin, until] of Object.entries(legacy))
213
+ index.take(origin, until);
214
+ for (const name of [LEGACY_OLD, CUR])
215
+ index.logs.set(name, scanLogSync(name, (e) => index.take(e?.origin, e?.until), index.logs.get(name)));
216
+ return index;
192
217
  }
193
218
  // Fetchers register here so queued requests can be cancelled the moment a
194
219
  // cooldown starts for their site.
@@ -199,7 +224,7 @@ export function setCooldown(origin, status, header) {
199
224
  const until = Date.now() + seconds * 1000;
200
225
  // Exact sources only: the fixed-size store may answer later than the truth (a collision), and taking that as
201
226
  // "already written" would keep the line from other processes.
202
- const known = Math.max(mem.get(origin) ?? 0, load().get(origin) ?? 0);
227
+ const known = Math.max(mem.get(origin) ?? 0, load().exact(origin));
203
228
  remember(origin, until); // this process honors it at once
204
229
  // Only a later deadline is worth a line. Never shortens anything.
205
230
  if (until > known && origin.length <= MAX_ORIGIN)
package/dist/dailylog.js CHANGED
@@ -2,6 +2,7 @@
2
2
  // W-13: the daily log. A readable page for one day, built from history.jsonl
3
3
  // (and receipts.jsonl) on request. It is never stored as a second copy; the
4
4
  // only file it can create is an export the owner asks for with --to.
5
+ import { textView } from "./textview.js";
5
6
  import fs from "node:fs";
6
7
  import path from "node:path";
7
8
  import { pathToFileURL } from "node:url";
@@ -53,6 +54,9 @@ function outcome(e) {
53
54
  }
54
55
  // One settings change in plain words, from the record's fixed codes (history.ts keeps only known codes).
55
56
  function settingWords(e) {
57
+ const by0 = e.by === "terminal" ? "from a terminal (likely a person)" : e.by === "not_terminal" ? "NOT from a terminal (an agent, a script or cron)" : "by an unknown caller";
58
+ if (e.tool === "keys")
59
+ return `${e.event === "slip_key_rotated" ? `slip key rotated${e.revoked !== undefined ? `, ${e.revoked} slip${e.revoked === 1 ? "" : "s"} revoked` : ""}` : e.event === "signing_key_rotation_finished" ? "signing key rotation finished (previous key dropped)" : "signing key rotated"}, ${by0}`;
56
60
  const what = e.change === "never_ask" ? "confirmations for risky settings turned OFF (never ask again)"
57
61
  : e.change === "ask_again" ? "confirmations for risky settings turned back on"
58
62
  : `${e.setting ?? "a setting"}${e.site_key ? ` for ${code(e.site_key)}` : ""} ${e.change === "looser" ? "turned on or loosened" : "turned off or made stricter"}`;
@@ -64,7 +68,8 @@ const hhmm = (iso) => {
64
68
  const d = new Date(iso);
65
69
  return `${String(d.getHours()).padStart(2, "0")}:${String(d.getMinutes()).padStart(2, "0")}`;
66
70
  };
67
- export async function buildLog(dayText) {
71
+ export async function buildLog(dayText, scan = {}) {
72
+ scan = { ...scan, deadline: scan.deadline ?? Date.now() + 60_000 };
68
73
  const { day, start, end } = parseDay(dayText);
69
74
  const entries = [];
70
75
  const changes = []; // W-32 (v0.9): risky settings changed this day get their own section, not counted as lookups
@@ -96,7 +101,8 @@ export async function buildLog(dayText) {
96
101
  }
97
102
  return false;
98
103
  }
99
- if (e.tool === "settings") {
104
+ if (e.tool === "settings" || e.tool === "keys") {
105
+ // v1.1: a key rotation is listed with the settings changes (it is just as risky)
100
106
  changeCount++;
101
107
  if (changes.length < MAX_LOG_LOOKUPS)
102
108
  changes.push(e);
@@ -112,7 +118,7 @@ export async function buildLog(dayText) {
112
118
  otherAgents++;
113
119
  results.set(outcome(e), (results.get(outcome(e)) ?? 0) + 1); // a fixed set of outcomes
114
120
  return false;
115
- });
121
+ }, 1, PAGE_BUDGET, scan);
116
122
  entries.sort((a, b) => Date.parse(a.time) - Date.parse(b.time));
117
123
  changes.sort((a, b) => Date.parse(a.time) - Date.parse(b.time));
118
124
  const perUrl = new Map();
@@ -136,7 +142,7 @@ export async function buildLog(dayText) {
136
142
  }
137
143
  }
138
144
  return false;
139
- });
145
+ }, 1, PAGE_BUDGET, scan);
140
146
  const link = (name) => `[${name}](${pathToFileURL(path.join(homeDir(), name)).href})`;
141
147
  const days = [...utcDays].sort().join(", ");
142
148
  const lines = [];
@@ -234,7 +240,7 @@ export async function exportLog(folder, dayText) {
234
240
  throw new Error("Private mode: nothing is written, so the log is not exported. Run it without --to to print it.");
235
241
  // 1. Build the whole text first. Nothing on disk is touched until it exists.
236
242
  const log = await buildLog(dayText);
237
- const body = fullText(log);
243
+ const body = textView(fullText(log));
238
244
  // 2. Resolve the folder ONCE and use only that real path from here on.
239
245
  let real;
240
246
  try {
package/dist/engine.js CHANGED
@@ -56,13 +56,13 @@ export function slipList(page = 1) {
56
56
  export const claimSlip = slips.claimSlip;
57
57
  export const checkSlip = slips.checkSlip;
58
58
  export const queryHistory = history.query;
59
- export const dailyLog = async (day, page = 1) => {
60
- const log = await dailylog.buildLog(day);
59
+ export const dailyLog = async (day, page = 1, scan = {}) => {
60
+ const log = await dailylog.buildLog(day, scan);
61
61
  return { day: log.day, entries: log.entries, ...dailylog.pageOf(log, page) };
62
62
  };
63
63
  export const exportDailyLog = dailylog.exportLog;
64
64
  // W-12: generated from the history when asked, never stored.
65
- export const needsReport = (since, page = 1) => needs.buildNeeds(since, page);
65
+ export const needsReport = (since, page = 1, scan = {}) => needs.buildNeeds(since, page, Date.now(), scan);
66
66
  // W-19: tiresias safety status | update.
67
67
  export const safetyStatus = safebrowsing.status;
68
68
  export const safetyUpdate = safebrowsing.update;
package/dist/envelope.js CHANGED
@@ -216,7 +216,7 @@ export async function guarded(...args) {
216
216
  catch (e) {
217
217
  configError = e;
218
218
  }
219
- return callContext.run({ ...callContext.getStore(), config, configError }, () => guardedCall(...args));
219
+ return callContext.run({ ...callContext.getStore(), config, configError, getActions: undefined }, () => guardedCall(...args));
220
220
  }
221
221
  async function guardedCall(tool, url, ctx, purpose, fn, meta = {}, hand, safetyCheck = true, // W-19: false only for a page a person provided (nothing is requested)
222
222
  record = true) {
package/dist/fetcher.js CHANGED
@@ -43,6 +43,11 @@ async function politeFetchHeld(url, opts, turn) {
43
43
  // Record the wait the moment 429/503 headers arrive, even if the body never finishes.
44
44
  if (hop.status === 429 || hop.status === 503)
45
45
  setCooldown(hop.url.origin, hop.status, hop.headers.get("retry-after"));
46
+ if (hop.redirect && hop.headers.has("retry-after")) {
47
+ const seconds = setCooldown(hop.url.origin, hop.status, hop.headers.get("retry-after"));
48
+ if (seconds > 0)
49
+ throw new Refused(COOLDOWN_TEXT, undefined, seconds, hop.url.href);
50
+ }
46
51
  // A challenge (cf-mitigated) on ANY hop is a wall at that hop: a redirect is not
47
52
  // followed, and a 304 is not accepted as a revalidation. Plain 401/402/403 final
48
53
  // responses are handled with their body by the engine.
package/dist/filereply.js CHANGED
@@ -15,7 +15,8 @@ import { NONBLOCK, isPrivate } from "./store.js";
15
15
  import { MAX_BLOCK } from "./reader.js";
16
16
  import { MAX_SAMPLE, detect, stampLanguage } from "./lang.js";
17
17
  import { translateReply } from "./translate.js";
18
- import { SecretWithheld, valueHoldsSecret } from "./echo.js";
18
+ import { SecretWithheld, noSecrets, valueHoldsSecret } from "./echo.js";
19
+ import { runUntrusted } from "./sandbox.js";
19
20
  import { BUDGET, env } from "./envelope.js";
20
21
  export class ProvidedError extends TiresiasError {
21
22
  kind = "provided";
@@ -81,6 +82,11 @@ export async function fileWarning(url, finalUrl, f, meta, agent, source, opts =
81
82
  }
82
83
  // v0.6: inside a zip or an Office file, in the worker, without unpacking it (inside.ts).
83
84
  const ins = await inspectFile(f);
85
+ if (ins?.office_text && !noSecrets(secrets)) {
86
+ const texts = [JSON.stringify(ins.office_text), ins.office_text.map((s) => s.text).join("\n")];
87
+ if (await runUntrusted({ op: "echo", texts, secrets: secrets }, Infinity))
88
+ throw new SecretWithheld();
89
+ }
84
90
  if (macroByName(f) || ins?.macros)
85
91
  fw.flags = [...new Set([...fw.flags, "macros"])];
86
92
  if (ins) {