strom-research 1.30.0-beta.4 → 1.30.0-beta.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.cs.md CHANGED
@@ -7,7 +7,7 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
7
7
 
8
8
  ## 1.30.0
9
9
 
10
- *Připravuje se: bety do 1.30.0-beta.4. Oddíl bude úplný s vydáním.*
10
+ *Připravuje se: bety do 1.30.0-beta.5. Oddíl bude úplný s vydáním.*
11
11
 
12
12
  - **Údaje ověřené proti originálu.** Narození, křest, sňatek, úmrtí nebo pohřeb, který cituje původní záznam, ale
13
13
  zůstává pravděpodobný nebo možný, agent ověří proti tomu originálu: podívá se na sken a údaj buď povýší na doložený,
@@ -59,6 +59,7 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
59
59
  mnohem rychleji:** strom pro aplikaci se sestaví jednou pro každý stav výzkumu a zůstane uložený i po novém spuštění
60
60
  mostu, a během sledování se změna ohlásí, až je její strom připravený. Most už neskončí, když je disk výzkumu na
61
61
  chvíli nedostupný, a druhý most téhož výzkumu spuštěný navíc hned skončí a neběží dál bez povšimnutí.
62
+ Aktualizace ve chvíli, kdy strom most spouští, už nenechá běžet dva mosty: zůstane jeden, na adrese, kterou aplikace sleduje.
62
63
  Aplikaci, která nejnovější strom už má, se znovu nic neposílá.
63
64
  Aplikace, která o to požádá, dostane strom s obrázky označenými podle obsahu a načte jen ty, které ještě nemá.
64
65
 
@@ -82,6 +83,10 @@ Změny každé verze ve zkratce. Úplné poznámky a instalační řádky jsou n
82
83
  **Stavba konektoru:** `strom connector test` varuje, když jeden snímek stojí mnoho požadavků (dlaždice), a řekne, co
83
84
  hledat nejdřív – odkaz portálu na celý snímek nebo stažení celé knihy – s dobou, jakou by kniha trvala v tempu archivu;
84
85
  `strom connector new` cituje, co strom ví o podmínkách archivu.
86
+ **macOS: aplikace Strom otevřená z výzkumu** (sledovat živě, soubor pro aplikaci) už nenechá v Docku mezi nedávnými
87
+ aplikacemi ikonu Google Chrome: adresa jde rovnou do už běžícího prohlížeče, okno aplikace se otevře jako dřív.
88
+ **Snímek, který měl uložit prohlížeč agenta a prohlížeč ho zadržel** (Chrome uloží jeden soubor webu sám, další až
89
+ po povolení stahování více souborů), se ohlásí: Co čeká uvede web, kterému to jednou povolit v adresním řádku prohlížeče.
85
90
 
86
91
  ## 1.29.0
87
92
 
package/CHANGELOG.de.md CHANGED
@@ -7,7 +7,7 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
7
7
 
8
8
  ## 1.30.0
9
9
 
10
- *In Vorbereitung: die Betas bis 1.30.0-beta.4. Der Abschnitt ist mit dem Release vollständig.*
10
+ *In Vorbereitung: die Betas bis 1.30.0-beta.5. Der Abschnitt ist mit dem Release vollständig.*
11
11
 
12
12
  - **Angaben am Original geprüft.** Angaben zu Geburt, Taufe, Heirat, Tod oder Begräbnis, die ihren ursprünglichen
13
13
  Eintrag zitieren, aber wahrscheinlich oder möglich bleiben, prüft der Agent an diesem Original: er sieht sich den Scan
@@ -70,6 +70,7 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
70
70
  Brücke, und beim Verfolgen wird eine Änderung gemeldet, sobald ihr Baum bereit ist. Die Brücke endet nicht mehr,
71
71
  wenn das Laufwerk der Forschung kurz nicht erreichbar ist, und eine zusätzlich gestartete zweite Brücke derselben
72
72
  Forschung endet sofort, statt unbemerkt weiterzulaufen.
73
+ Ein Update, während strom die Brücke startet, lässt keine zwei Brücken mehr laufen: Eine bleibt, unter der Adresse, der die App folgt.
73
74
  Einer App, die den neuesten Stammbaum schon hat, wird nichts erneut gesendet.
74
75
  Eine App, die darum bittet, bekommt den Stammbaum mit jedem Bild nach seinem Inhalt benannt und lädt nur die Bilder, die sie noch nicht hat.
75
76
 
@@ -98,6 +99,12 @@ Die Änderungen jeder Version in Kürze. Die vollständigen Hinweise und die Ins
98
99
  zuerst zu suchen ist – den Link des Portals auf das ganze Bild oder das Herunterladen eines ganzen Buches – mit der
99
100
  Zeit, die ein Buch im Tempo des Archivs bräuchte; `strom connector new` zitiert, was strom von den Bedingungen des
100
101
  Archivs weiß.
102
+ **macOS: Die App Strom, aus der Forschung geöffnet** (live verfolgen, eine Datei für die App), lässt im Dock unter
103
+ den zuletzt verwendeten Apps kein Symbol von Google Chrome mehr zurück: Die Adresse geht direkt an den bereits
104
+ laufenden Browser, das Fenster der App öffnet sich wie bisher.
105
+ **Eine Aufnahme, die der Browser des Agenten speichern sollte und der Browser zurückhielt** (Chrome speichert eine
106
+ Datei einer Website von selbst, die nächste erst, wenn sie mehrere Dateien herunterladen darf), wird gemeldet: „Was
107
+ wartet“ nennt die Website, der das einmal in der Adressleiste des Browsers zu erlauben ist.
101
108
 
102
109
  ## 1.29.0
103
110
 
package/CHANGELOG.md CHANGED
@@ -7,7 +7,7 @@ The changes of each version in short. The full notes and the install lines are o
7
7
 
8
8
  ## 1.30.0
9
9
 
10
- *In preparation: the betas up to 1.30.0-beta.4. The section is complete with the release.*
10
+ *In preparation: the betas up to 1.30.0-beta.5. The section is complete with the release.*
11
11
 
12
12
  - **Facts checked against their originals.** A birth, a baptism, a marriage, a death or a burial that cites its
13
13
  original record but stays probable or possible is verified by the agent against that original: it looks at the scan
@@ -63,6 +63,7 @@ The changes of each version in short. The full notes and the install lines are o
63
63
  and kept, also when the bridge starts again, and while the app follows, a change is told once its tree is ready.
64
64
  The bridge no longer ends when the research's disk is away for a moment, and a second bridge started for the same
65
65
  research ends at once instead of running on unseen.
66
+ An update while strom starts the bridge no longer leaves two bridges: one stays, at the address the app follows.
66
67
  An app that has the newest tree already is sent nothing again.
67
68
  An app that asks for it is sent the tree with each image named by its content, and loads only the images it does not have yet.
68
69
 
@@ -88,6 +89,11 @@ The changes of each version in short. The full notes and the install lines are o
88
89
  **Building a connector:** `strom connector test` warns when one image costs many requests (tiles) and says what to
89
90
  look for first – the portal's link to the whole image, or the download of a whole book – with the time a book would
90
91
  take at the archive's pace; `strom connector new` quotes what strom knows of the archive's terms.
92
+ **macOS: the Strom app opened from the research** (follow live, a file for the app) leaves no Google Chrome icon in
93
+ the Dock's recent apps: the address goes straight to the browser already running, the app's window opens as before.
94
+ **An image the agent's browser was to save and the browser held back** (Chrome saves one file of a site by itself, the
95
+ next only once the site may download several files) is said: what waits names the site to allow, once, in the
96
+ browser's address bar.
91
97
 
92
98
  ## 1.29.0
93
99
 
package/CHANGELOG.pl.md CHANGED
@@ -7,7 +7,7 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
7
7
 
8
8
  ## 1.30.0
9
9
 
10
- *W przygotowaniu: bety do 1.30.0-beta.4. Sekcja będzie kompletna z wydaniem.*
10
+ *W przygotowaniu: bety do 1.30.0-beta.5. Sekcja będzie kompletna z wydaniem.*
11
11
 
12
12
  - **Dane sprawdzane z oryginałem.** Urodzenie, chrzest, ślub, zgon lub pochówek, który cytuje pierwotny zapis, ale
13
13
  pozostaje prawdopodobny lub możliwy, agent sprawdzi z tym oryginałem: obejrzy skan i albo podniesie daną do
@@ -63,6 +63,7 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
63
63
  zostaje zapisane, także po ponownym uruchomieniu mostu, a podczas śledzenia zmiana jest zgłaszana, gdy jej drzewo
64
64
  jest gotowe. Most nie kończy się już, gdy dysk badania jest na chwilę niedostępny, a drugi most tego samego badania
65
65
  uruchomiony dodatkowo kończy się od razu, zamiast działać dalej niezauważony.
66
+ Aktualizacja w chwili, gdy strom uruchamia most, nie zostawia już dwóch mostów: zostaje jeden, pod adresem, który śledzi aplikacja.
66
67
  Aplikacji, która ma już najnowsze drzewo, nic nie jest wysyłane ponownie.
67
68
  Aplikacja, która o to poprosi, dostaje drzewo z obrazami oznaczonymi według ich zawartości i wczytuje tylko te, których jeszcze nie ma.
68
69
 
@@ -89,6 +90,12 @@ Zmiany każdej wersji w skrócie. Pełne informacje o wydaniach i polecenia inst
89
90
  **Budowa konektora:** `strom connector test` ostrzega, gdy jeden skan kosztuje wiele żądań (kafelki), i mówi, czego
90
91
  szukać najpierw – linku portalu do całego skanu lub pobrania całej księgi – z czasem, jaki zajęłaby księga w tempie
91
92
  archiwum; `strom connector new` cytuje, co strom wie o warunkach archiwum.
93
+ **macOS: aplikacja Strom otwarta z badania** (śledzenie na żywo, plik dla aplikacji) nie zostawia już w Docku wśród
94
+ ostatnio używanych aplikacji ikony Google Chrome: adres trafia prosto do już działającej przeglądarki, okno aplikacji
95
+ otwiera się jak dotąd.
96
+ **Skan, który miała zapisać przeglądarka agenta, a przeglądarka go wstrzymała** (Chrome zapisuje sam jeden plik
97
+ witryny, kolejny dopiero po zezwoleniu na pobieranie wielu plików), jest zgłaszany: „Co czeka“ podaje witrynę, której
98
+ trzeba na to jednorazowo zezwolić w pasku adresu przeglądarki.
92
99
 
93
100
  ## 1.29.0
94
101
 
@@ -2595,6 +2595,7 @@
2595
2595
  "wait.group.connectors": "Stahovače",
2596
2596
  "browser.wait": "snímky {images} knihy {book}, ukládá je prohlížeč agenta z {url}",
2597
2597
  "browser.save.other": "karta prohlížeče ukazuje jiný snímek než {n} ({url}), nic se neuložilo",
2598
+ "browser.wait.held": "snímky {images} knihy {book}, ukládá je prohlížeč agenta z {url} — prohlížeč snímek {n} zadržel: povolit webu {host} stahování více souborů, jednou (ikona vpravo v adresním řádku prohlížeče)",
2598
2599
  "wait.group.app": "Aplikace Strom",
2599
2600
  "wait.group.tune": "Čtení snímků",
2600
2601
  "wait.group.conflicts": "K rozhodnutí – rozpory",
@@ -2595,6 +2595,7 @@
2595
2595
  "wait.group.connectors": "Downloader",
2596
2596
  "browser.wait": "Aufnahmen {images} des Buches {book}, vom Browser des Agenten gespeichert ({url})",
2597
2597
  "browser.save.other": "der Tab des Browsers zeigt eine andere Aufnahme als {n} ({url}), nichts wurde gespeichert",
2598
+ "browser.wait.held": "Aufnahmen {images} des Buches {book}, vom Browser des Agenten gespeichert ({url}) — der Browser hat Aufnahme {n} zurückgehalten: {host} das Herunterladen mehrerer Dateien erlauben, einmal (das Symbol rechts in der Adressleiste des Browsers)",
2598
2599
  "wait.group.app": "Die Strom-App",
2599
2600
  "wait.group.tune": "Das Lesen der Scans",
2600
2601
  "wait.group.conflicts": "Widersprüche zu entscheiden",
@@ -2595,6 +2595,7 @@
2595
2595
  "wait.group.connectors": "Programy pobierające",
2596
2596
  "browser.wait": "skany {images} księgi {book}, zapisywane przez przeglądarkę agenta z {url}",
2597
2597
  "browser.save.other": "karta przeglądarki pokazuje inny skan niż {n} ({url}), nic nie zostało zapisane",
2598
+ "browser.wait.held": "skany {images} księgi {book}, zapisywane przez przeglądarkę agenta z {url} — przeglądarka wstrzymała skan {n}: zezwolić witrynie {host} na pobieranie wielu plików, jednorazowo (ikona po prawej stronie paska adresu przeglądarki)",
2598
2599
  "wait.group.app": "Aplikacja Strom",
2599
2600
  "wait.group.tune": "Odczyt skanów",
2600
2601
  "wait.group.conflicts": "Do rozstrzygnięcia – sprzeczności",
@@ -34,7 +34,7 @@ import { askedNow, folderFiles, handedImages, inboxState, inboxWaitOf, inboxWait
34
34
  import { formatOf } from "../image/index.js";
35
35
  import { pdfScans } from "../image/pdf.js";
36
36
  import { readableFile } from "../core/readable.js";
37
- import { PLAN_TTL_MS, saveScript, waitFileBase } from "../core/browser.js";
37
+ import { HELD_AFTER_MS, PLAN_TTL_MS, findDownload, loadSaves, noteSave, saveScript, storeSaves, waitFileBase } from "../core/browser.js";
38
38
  import { bookOn, browserGate, otherWay } from "../core/webgate.js";
39
39
  import { allows } from "../core/terms.js";
40
40
  import { phrase } from "../core/phrases.js";
@@ -447,6 +447,58 @@ function stillWaiting(tree, recordset) {
447
447
  return `${t.id} still waits for images ${runs(missing)} of ${recordset} (it asked for ${t.awaits.images}) — it comes back once they are there`;
448
448
  });
449
449
  }
450
+ /**
451
+ * The images strom media save gave the agent's tab a script for whose file never came — not in the downloads folder
452
+ * (nor still downloading), not in the task's folder, not registered, a while after the script was given: Chrome saves
453
+ * one file of a site by itself and holds the next back until the person allows the site to download several files.
454
+ * The first time an image is found so, its task's wait says it to the person (in the research language). Records of
455
+ * images registered since, or of tasks that wait for them no more, go.
456
+ */
457
+ export function heldSaves(tree, shared, downloads, now = Date.now()) {
458
+ const saves = loadSaves(tree.root);
459
+ if (!saves.length)
460
+ return [];
461
+ const keep = [];
462
+ const held = [];
463
+ for (const r of saves) {
464
+ const t = tree.get(r.task);
465
+ const want = t?.state === "waiting" && t.awaits?.recordset === r.recordset ? (parseImageList(t.awaits.images) ?? []) : [];
466
+ if (!want.includes(r.n) || registeredImages(tree, r.recordset).has(r.n))
467
+ continue;
468
+ keep.push(r);
469
+ const dl = findDownload(downloads, r.file);
470
+ const dir = path.join(shared, "inbox", t.awaits.folder);
471
+ const inFolder = fs.existsSync(dir) && folderFiles(dir).length > 0;
472
+ if (dl.file || dl.unfinished || inFolder || now - r.at < HELD_AFTER_MS)
473
+ continue;
474
+ held.push(r);
475
+ }
476
+ const fresh = held.filter((r) => !r.held);
477
+ if (!tree.dryRun) {
478
+ if (fresh.length)
479
+ tree.withTreeLock(() => {
480
+ for (const id of new Set(fresh.map((r) => r.task))) {
481
+ const mine = held.filter((r) => r.task === id);
482
+ const t = tree.get(id);
483
+ const b = tree.get(mine[0].recordset);
484
+ const said = phrase(tree.lang, "browser.wait.held", { images: t.awaits.images, book: b ? `${b.id} ${b.title}` : mine[0].recordset, url: mine[0].url, n: runs(mine.map((r) => r.n)), host: mine[0].host });
485
+ if (t.waitingOn !== said)
486
+ update(tree, id, "task", (x) => ({ ...x, waitingOn: said }), { op: "task.wait", summary: `${id} wait: image ${runs(mine.map((r) => r.n))} of ${mine[0].recordset} held back by the browser — ${mine[0].host} to be allowed to download several files` });
487
+ }
488
+ });
489
+ storeSaves(tree.root, keep.map((r) => (held.includes(r) ? { ...r, held: true } : r)));
490
+ }
491
+ return held;
492
+ }
493
+ /** What the agent is told of an image its browser held back. */
494
+ function heldLine(ctx, h, downloads) {
495
+ const since = new Date(h.at).toTimeString().slice(0, 8);
496
+ return (`⚠ image ${h.n} of ${h.recordset} (${h.task}): nothing came into ${ctx.display(downloads)} since strom media save gave its script (${since}). ` +
497
+ `The script answered "strom-result ${h.n}:200:…": the browser held the file back — Chrome saves one file of a site by itself and the next only once the person allows ${h.host} to download several files ` +
498
+ `(once: the icon at the right end of the address bar, or the site's settings → Automatic downloads). Tell the user exactly that; it is the person's permission — never change the browser's settings yourself, never save the image another way. ` +
499
+ `${h.task} waits for it meanwhile and what waits says it to the person; go on with other work. Once allowed: strom media save ${h.task} --image ${h.n} --at ${h.url}, its script in that tab again, then strom media add --inbox --waiting. ` +
500
+ `The script answered anything else: tell the user what it said. The browser saves elsewhere: strom config set browser.downloads <folder>.`);
501
+ }
450
502
  /** What was taken of the folders, a line each (strom media add --inbox --waiting, a session's start). */
451
503
  export function takenLines(taken) {
452
504
  return taken.map((t) => {
@@ -997,11 +1049,14 @@ register({
997
1049
  if (args.length || opts.recordset || opts.first !== undefined || opts.image !== undefined)
998
1050
  throw new UsageError("--waiting takes the folders of the waiting tasks as they are: no folder, --recordset, --first or --image");
999
1051
  // what the agent's browser saved for them (strom media save) first goes into their folders
1000
- const taken = takeWaiting(tree, shared, { downloads: ctx.settings.downloads() });
1052
+ const downloads = ctx.settings.downloads();
1053
+ const taken = takeWaiting(tree, shared, { downloads });
1001
1054
  const woken = taken.flatMap((t) => t.woken);
1055
+ // what the agent's browser was to save and never saved: held back by the browser — said, to the person too
1056
+ const held = heldSaves(tree, shared, downloads);
1002
1057
  return {
1003
- text: lines(taken.length ? undefined : "no task waits for images saved into the inbox, or none of their folders holds a file", ...takenLines(taken)),
1004
- data: { taken, woken },
1058
+ text: lines(taken.length || held.length ? undefined : "no task waits for images saved into the inbox, or none of their folders holds a file", ...takenLines(taken), ...held.map((h) => heldLine(ctx, h, downloads))),
1059
+ data: { taken, woken, held: held.map((h) => ({ task: h.task, recordset: h.recordset, image: h.n, host: h.host, url: h.url, since: new Date(h.at).toISOString() })) },
1005
1060
  };
1006
1061
  }
1007
1062
  let paths;
@@ -1208,7 +1263,9 @@ register({
1208
1263
  const want = [...new Set([...(w?.by === "images" ? (w.want ?? []) : []), n])].sort((x, y) => x - y);
1209
1264
  const images = runs(want);
1210
1265
  const lang = tree.lang;
1211
- const was = t.state === "waiting" && t.awaits?.images === images;
1266
+ // said held back before (its wait asks the person to allow the downloads): the wait as it is again, the script given anew
1267
+ const wasHeld = loadSaves(tree.root).some((r) => r.task === t.id && r.held);
1268
+ const was = t.state === "waiting" && t.awaits?.images === images && !wasHeld;
1212
1269
  if (!was && !tree.dryRun)
1213
1270
  update(tree, t.id, "task", (x) => {
1214
1271
  const next = { ...x, state: "waiting", waitingOn: phrase(lang, "browser.wait", { images, book: `${b.id} ${b.title}`, url: u.href }), awaits: { recordset: b.id, images, folder: inboxFolderFor(b) }, ...(x.where.includes(b.id) ? {} : { where: [...x.where, b.id] }) };
@@ -1220,6 +1277,12 @@ register({
1220
1277
  if (!tree.dryRun)
1221
1278
  fs.mkdirSync(dir, { recursive: true });
1222
1279
  const file = waitFileBase(t.id, n);
1280
+ if (!tree.dryRun) {
1281
+ noteSave(tree.root, { task: t.id, n, recordset: b.id, host: u.hostname, url: u.href, file, at: Date.now() });
1282
+ // the task's other images held back before: asked of the person once more by this wait, so said anew
1283
+ if (wasHeld)
1284
+ storeSaves(tree.root, loadSaves(tree.root).map(({ held, ...r }) => (r.task === t.id || !held ? r : { ...r, held })));
1285
+ }
1223
1286
  const script = saveScript({ url: u.href, file, n, until: Date.now() + PLAN_TTL_MS, other: phrase(lang, "browser.save.other", { n: String(n), url: u.href }) });
1224
1287
  const then = "strom media add --inbox --waiting";
1225
1288
  return {
@@ -519,8 +519,9 @@ function waitOptions(tree, id, opts, has = {}) {
519
519
  if (opts.kind !== undefined) {
520
520
  const k = String(opts.kind).trim().toLowerCase();
521
521
  if (has.images || has.check) {
522
- // --kind images with --images (--kind check with --check) only repeats what the flag says: taken as said
523
- if (k === (has.images ? "images" : "check"))
522
+ // --kind images with --images (--kind check with --check) only repeats what the flag says: taken as said; so does
523
+ // --kind web — the images are saved from a site, the check is of one: the flag says which
524
+ if (k === (has.images ? "images" : "check") || k === "web")
524
525
  return waitOptions(tree, id, { ...opts, kind: undefined }, has);
525
526
  throw new UsageError(`--kind: --${has.images ? "images" : "check"} says the kind itself (${has.images ? "images the user saves by hand" : "a site only the user checks"})`, { hint: `leave out --kind` });
526
527
  }
@@ -1017,7 +1018,7 @@ register({
1017
1018
  "start: strom media add --inbox --waiting) — a part of them, it waits on and says which are missing. Files named\n" +
1018
1019
  "otherwise are taken by their order when there are as many as images missing.\n" +
1019
1020
  "--kind web on a task whose --where names one book: images of that book saved into its folder of the inbox bring it\n" +
1020
- "back too (which ones not known yet) — with the numbers known, --images.\n" +
1021
+ "back too (which ones not known yet) — with the numbers known, --images in its place (it says the kind itself).\n" +
1021
1022
  "--check <URL>: the user looks at a site strom and your web tools may not read (it refused strom, or its terms\n" +
1022
1023
  "forbid or restrict automation) — only after another way to the same records was tried and the blocked way recorded\n" +
1023
1024
  "in this session (strom search add … --note \"<host>: …\"); --on says what to check there. They answer in strom's\n" +
@@ -1033,7 +1034,8 @@ register({
1033
1034
  { name: "on", type: "string", value: "<for the user: impersonal, research language>", description: "what it waits for, for the user: which book, its link, which images" },
1034
1035
  { name: "images", type: "string", value: "<B…:n-m>", description: "the images the user saves by hand, numbered as the portal's viewer counts them (B0001:40-69, B0001:9,12)" },
1035
1036
  { name: "check", type: "string", value: "<URL>", description: "a site for the user to check (one strom may not read): only after another way was tried and the blocked way recorded (strom search add)" },
1036
- ...WAIT_OPTIONS,
1037
+ // --images and --check say the kind themselves: --kind is for a wait of neither
1038
+ ...WAIT_OPTIONS.map((o) => (o.name === "kind" ? { ...o, description: `${o.description} — not with --images or --check: they say the kind themselves` } : o)),
1037
1039
  ],
1038
1040
  examples: [
1039
1041
  'strom task wait T0002 --on "reply of the archive to the request of 21 Sep"',
@@ -511,6 +511,31 @@ export function viewerScript(plan) {
511
511
  return "strom-result " + out.join(" ");
512
512
  })()`;
513
513
  }
514
+ /** A file the browser has had this long to come before it counts as held back (the script runs after strom media save). */
515
+ export const HELD_AFTER_MS = 5_000;
516
+ function savesFile(root) {
517
+ return path.join(root, ".strom", "browser-saves.json");
518
+ }
519
+ export function loadSaves(root) {
520
+ let all;
521
+ try {
522
+ all = readJsonIfExists(savesFile(root));
523
+ }
524
+ catch {
525
+ all = undefined; // a broken file: as if none were given
526
+ }
527
+ return Array.isArray(all) ? all.filter((r) => r && typeof r.task === "string" && Number.isInteger(r.n) && typeof r.file === "string") : [];
528
+ }
529
+ export function storeSaves(root, saves) {
530
+ if (saves.length)
531
+ writeJson(savesFile(root), saves);
532
+ else
533
+ fs.rmSync(savesFile(root), { force: true });
534
+ }
535
+ /** The script for image n of a task was given now: the one record of it (an earlier one of the same image replaced). */
536
+ export function noteSave(root, rec) {
537
+ storeSaves(root, [...loadSaves(root).filter((r) => r.task !== rec.task || r.n !== rec.n), rec]);
538
+ }
514
539
  /** The name an image saved from the tab for a waiting task is saved under: strom-T0007-0040 (taken by strom media add --inbox --waiting). */
515
540
  export function waitFileBase(task, n) {
516
541
  return `strom-${safe(task)}-${String(n).padStart(4, "0")}`;
@@ -159,17 +159,23 @@ const USER_DATA = {
159
159
  Chromium: { mac: "Chromium", win: "Chromium\\User Data", linux: "chromium" },
160
160
  Vivaldi: { mac: "Vivaldi", win: "Vivaldi\\User Data", linux: "vivaldi" },
161
161
  };
162
- /** The profile of the browser an installed web app belongs to: the one that holds its files (only folder names are looked at). */
163
- export function webAppProfile(browser, appId, env, platform = process.platform) {
162
+ /** The folder a browser keeps its profiles in (its user data). */
163
+ function userDataDir(browser, env, platform) {
164
164
  const d = USER_DATA[browser];
165
165
  if (!d)
166
166
  return undefined;
167
167
  const home = userHome(env);
168
- const root = platform === "darwin"
168
+ return platform === "darwin"
169
169
  ? path.join(home, "Library", "Application Support", d.mac)
170
170
  : platform === "win32"
171
171
  ? path.join(env.LOCALAPPDATA ?? path.join(home, "AppData", "Local"), d.win)
172
172
  : path.join(env.XDG_CONFIG_HOME ?? path.join(home, ".config"), d.linux);
173
+ }
174
+ /** The profile of the browser an installed web app belongs to: the one that holds its files (only folder names are looked at). */
175
+ export function webAppProfile(browser, appId, env, platform = process.platform) {
176
+ const root = userDataDir(browser, env, platform);
177
+ if (!root)
178
+ return undefined;
173
179
  let dirs = [];
174
180
  try {
175
181
  dirs = fs.readdirSync(root);
@@ -195,8 +201,54 @@ export function openWebApp(app, url, env, platform = process.platform) {
195
201
  const exe = platform === "darwin" ? path.join(b.path, "Contents", "MacOS", path.basename(b.path, ".app")) : b.path;
196
202
  if (platform !== "darwin" && platform !== "win32" && !env.DISPLAY && !env.WAYLAND_DISPLAY)
197
203
  return false;
204
+ // macOS, the browser running: the request goes to it as that program would hand it over, with no program started —
205
+ // a program started outside the system's launcher stays in the Dock's recent apps as the browser not running (found
206
+ // 9. 11. 2026 with "follow live"). Not taken (not running, no answer, shutting down): the program as before.
207
+ if (platform === "darwin") {
208
+ const dir = userDataDir(app.browser, env, platform);
209
+ if (dir && handToRunning(path.join(dir, "SingletonSocket"), [exe, ...args]))
210
+ return true;
211
+ }
198
212
  return launch(exe, args, env);
199
213
  }
214
+ /**
215
+ * What a second start of a Chromium browser sends the one running, through the socket in its user data
216
+ * (ProcessSingleton, POSIX): START, the folder it runs in and its command line, each ended by a NUL but the last.
217
+ */
218
+ export function singletonMessage(argv, cwd = "/") {
219
+ return ["START", cwd, ...argv].join("\0");
220
+ }
221
+ /** Read by the helper below: the socket, then the message in base64; exit 0 only on the browser's ACK. */
222
+ const HAND_OVER = `const net=require("node:net");const c=net.connect(process.argv[1]);let got="";
223
+ c.on("connect",()=>c.end(Buffer.from(process.argv[2],"base64")));c.on("data",(d)=>{got+=d});
224
+ c.on("close",()=>process.exit(got.startsWith("ACK")?0:1));c.on("error",()=>process.exit(1));`;
225
+ /**
226
+ * Hand a command line to the Chromium browser running on that socket, as its own second start would: true when it
227
+ * answered ACK (it opens what it was asked to). Nothing there, refused, no answer within 5 s, or SHUTDOWN: false.
228
+ */
229
+ export function handToRunning(socket, argv, timeoutMs = 5000) {
230
+ try {
231
+ fs.lstatSync(socket);
232
+ }
233
+ catch {
234
+ return false;
235
+ }
236
+ // the socket's own path (the link points to a short one in the temporary folder): a long one is refused by the system
237
+ let at = socket;
238
+ try {
239
+ at = fs.realpathSync(socket);
240
+ }
241
+ catch {
242
+ return false;
243
+ }
244
+ const r = spawnSync(process.execPath, ["-e", HAND_OVER, at, Buffer.from(singletonMessage(argv), "utf8").toString("base64")], {
245
+ stdio: "ignore",
246
+ timeout: timeoutMs,
247
+ windowsHide: true,
248
+ env: {},
249
+ });
250
+ return r.status === 0;
251
+ }
200
252
  /** Open an address in that browser; false when this computer cannot (no desktop) or tests ask not to. */
201
253
  export function openInBrowser(browser, url, env, platform = process.platform) {
202
254
  if (env.STROM_NO_OPEN === "1")
package/dist/core/live.js CHANGED
@@ -821,16 +821,124 @@ export function liveRunning(root) {
821
821
  return undefined;
822
822
  }
823
823
  /**
824
- * Another bridge of this tree up already (live.json names it, it runs and is a bridge): one that started late — strom
825
- * gave up waiting for it, and another was started meanwhile — is never a second bridge of the tree nobody knows of
826
- * (found in tests on a busy computer: bridges no `strom live stop` could reach, live.json naming another). A bridge
827
- * started to take over (STROM_LIVE_RENEWED) asks the one it replaces to end: never this.
824
+ * Where the tree's bridge claims the tree (.strom/live-owner.json: its pid, its folder, since when) — one bridge per
825
+ * research, whatever starts them and when: a newer strom's bridge taking over from the one before and a strom starting
826
+ * the tree's bridge at that moment once ran both, one at the address the app follows, the other at another port, both
827
+ * taking in the inbox (found 2026-11-09 at an update). Claimed and given up only under the tree's owner lock
828
+ * (liveOwnerLock), which also guards live.json being written and removed at a start and an end.
828
829
  */
829
- function otherBridge(root, env) {
830
- if (env.STROM_LIVE_RENEWED)
830
+ function liveOwnerFile(root) {
831
+ return path.join(root, ".strom", "live-owner.json");
832
+ }
833
+ /**
834
+ * How long a claim counts by itself while its bridge is not in live.json yet (it starts: the tree settled, /status made
835
+ * first, its port waited for): after it only a bridge live.json names holds the tree — a claim left by one ended without
836
+ * a word is never another's process that got its number (Windows tells no bridge by its command).
837
+ */
838
+ const CLAIM_FRESH_MS = 120_000;
839
+ /** What a tree's claim is done under (a moment: read, compare, write); never waited for long — without it, as before. */
840
+ function withLiveOwner(root, fn) {
841
+ let release;
842
+ try {
843
+ // a research gone (its .strom deleted, moved): its folder never made again for a lock
844
+ if (fs.existsSync(path.join(root, ".strom")))
845
+ release = acquireLock(path.join(root, ".strom", "live-owner.lock"), { owner: "the tree's bridge", waitMs: 10_000, staleMs: 60_000 });
846
+ }
847
+ catch {
848
+ // its folder not to be written, or held by one stuck: the claim and the notes as they come
849
+ }
850
+ try {
851
+ return fn();
852
+ }
853
+ finally {
854
+ release?.();
855
+ }
856
+ }
857
+ /**
858
+ * The bridge this one takes over from: the one that started it with a newer strom (STROM_LIVE_REPLACES; one of an
859
+ * older strom names none — its parent then, which started it). None: a bridge started by strom, which ended the one before.
860
+ */
861
+ function replacedBridge(env) {
862
+ const said = Number(env.STROM_LIVE_REPLACES);
863
+ if (Number.isInteger(said) && said > 0)
864
+ return said;
865
+ return env.STROM_LIVE_RENEWED ? process.ppid : undefined;
866
+ }
867
+ /**
868
+ * Another bridge holding this tree (it runs and is a bridge, never the one this one takes over from): the one whose claim
869
+ * counts (live-owner.json), else the one live.json names (a bridge of an older strom claims nothing) — one that started
870
+ * late (strom gave up waiting for it, another was started meanwhile) or at the same moment as another is never a second
871
+ * bridge of the tree.
872
+ */
873
+ function rivalBridge(root, env, ignore) {
874
+ const replaces = replacedBridge(env);
875
+ const named = liveRunning(root);
876
+ const other = (pid) => typeof pid === "number" && pid !== process.pid && pid !== replaces && pid !== ignore && isBridge(pid);
877
+ try {
878
+ const owner = JSON.parse(fs.readFileSync(liveOwnerFile(root), "utf8"));
879
+ const fresh = named?.pid === owner.pid || Date.now() - Date.parse(String(owner.at)) < CLAIM_FRESH_MS;
880
+ if (fresh && other(owner.pid) && !foreignNote(root, owner))
881
+ return owner.pid;
882
+ }
883
+ catch {
884
+ // no claim: a bridge of an older strom, or none
885
+ }
886
+ return named && other(named.pid) ? named.pid : undefined;
887
+ }
888
+ /** This bridge holds the tree now (under the owner lock). */
889
+ function writeOwner(root) {
890
+ // no research there (moved, taken off): nothing made
891
+ if (!fs.existsSync(path.join(root, TREE_FILE)))
892
+ return;
893
+ const file = liveOwnerFile(root);
894
+ fs.mkdirSync(path.dirname(file), { recursive: true });
895
+ fs.writeFileSync(`${file}.${process.pid}`, JSON.stringify({ pid: process.pid, root: realRoot(root), at: new Date().toISOString() }));
896
+ fs.renameSync(`${file}.${process.pid}`, file);
897
+ }
898
+ /**
899
+ * Claim the tree for this bridge: the other bridge that holds it (this one then ends), else none — claimed. `ignore`: a
900
+ * bridge that holds it no more (the new one that did not take over, being ended).
901
+ */
902
+ function claimTree(root, env, ignore) {
903
+ return withLiveOwner(root, () => {
904
+ const rival = rivalBridge(root, env, ignore);
905
+ if (rival)
906
+ return rival;
907
+ try {
908
+ writeOwner(root);
909
+ }
910
+ catch {
911
+ // a folder not to be written: live.json says the bridge
912
+ }
831
913
  return undefined;
832
- const now = liveRunning(root);
833
- return now && now.pid !== process.pid && isBridge(now.pid) ? now : undefined;
914
+ });
915
+ }
916
+ /** The claim given up by the bridge that ends (only its own: the bridge it handed over to holds it already). */
917
+ function dropOwner(root) {
918
+ withLiveOwner(root, () => {
919
+ try {
920
+ const owner = JSON.parse(fs.readFileSync(liveOwnerFile(root), "utf8"));
921
+ if (owner.pid === process.pid)
922
+ fs.rmSync(liveOwnerFile(root), { force: true });
923
+ }
924
+ catch {
925
+ // none
926
+ }
927
+ });
928
+ }
929
+ /** live.json removed when it still names that bridge (an ended one's): never the note of one that came up meanwhile. */
930
+ function dropLiveNote(root, pid) {
931
+ withLiveOwner(root, () => {
932
+ try {
933
+ const now = JSON.parse(fs.readFileSync(liveFile(root), "utf8"));
934
+ if (now.pid === pid || typeof now.pid !== "number" || !alive(now.pid))
935
+ fs.rmSync(liveFile(root), { force: true });
936
+ }
937
+ catch {
938
+ // none, or not readable: nobody's
939
+ fs.rmSync(liveFile(root), { force: true });
940
+ }
941
+ });
834
942
  }
835
943
  /**
836
944
  * Tests only: the folder where a run of the tests keeps a note of each bridge (STROM_TEST_BRIDGES; test/setup.ts), so
@@ -933,7 +1041,12 @@ export function notStartedWhy(root, since) {
933
1041
  function startNow(root, env, running) {
934
1042
  if (running)
935
1043
  stopLive(root, `a bridge of strom ${VERSION} is wanted (this one: ${running.version ?? "older"})`, { back: true });
936
- fs.rmSync(liveFile(root), { force: true });
1044
+ // the one ended was handing over to the bridge of the strom on disk, which runs now (one started would be of that
1045
+ // strom too): that one is the tree's
1046
+ const meanwhile = liveRunning(root);
1047
+ if (meanwhile && meanwhile.pid !== running?.pid)
1048
+ return meanwhile;
1049
+ dropLiveNote(root, meanwhile?.pid ?? running?.pid ?? 0);
937
1050
  const before = readLast(root);
938
1051
  spawnBridge(root, env);
939
1052
  // (a stuck bridge before it is ended first: up to some seconds)
@@ -963,9 +1076,11 @@ function spawnBridge(root, env, extra = {}) {
963
1076
  catch {
964
1077
  // without a log
965
1078
  }
1079
+ // the bridge a bridge takes over from is said to it alone, never passed on to one a strom of it starts
1080
+ const { STROM_LIVE_REPLACES: _replaced, ...inherited } = env;
966
1081
  const child = spawn(command, [...args, "live", "serve"], {
967
1082
  cwd: bridgeCwd(root, env),
968
- env: { ...env, STROM_TREE: root, STROM_SPAWNED: "1", ...extra },
1083
+ env: { ...inherited, STROM_TREE: root, STROM_SPAWNED: "1", ...extra },
969
1084
  detached: true,
970
1085
  stdio: "ignore",
971
1086
  windowsHide: true,
@@ -1171,7 +1286,8 @@ export function stopLive(root, why = "strom live stop", opts = {}) {
1171
1286
  noteLive(root, `the bridge ${info.pid} could not be ended`);
1172
1287
  return "alive";
1173
1288
  }
1174
- fs.rmSync(liveFile(root), { force: true });
1289
+ // (the bridge it handed over to may have written its own note meanwhile: kept)
1290
+ dropLiveNote(root, info.pid);
1175
1291
  // no bridge of that number ran (it ended meanwhile, the number another program's): none was stopped
1176
1292
  return how === "gone" ? "none" : how;
1177
1293
  }
@@ -2291,6 +2407,13 @@ function phoneSummaryNow(env) {
2291
2407
  /** Run the bridge of the tree here, until idle or stopped. */
2292
2408
  export function serveLive(root, env) {
2293
2409
  noteTestBridge(root, env);
2410
+ // the tree's bridge runs already, or another one claimed the tree a moment before (a newer strom's bridge taking over
2411
+ // while a strom starts one): this one is not needed — it ends before it writes or takes anything
2412
+ const before = claimTree(root, env);
2413
+ if (before) {
2414
+ noteLive(root, `another bridge of this tree runs already (${before}): this one (${process.pid}) ends`);
2415
+ return Promise.resolve();
2416
+ }
2294
2417
  // the stroms it started that write (a send, an adoption, an original, a batch): never started again under them
2295
2418
  const kids = new Set();
2296
2419
  const track = (child) => {
@@ -6224,12 +6347,6 @@ export function serveLive(root, env) {
6224
6347
  process.on("uncaughtException", (e) => noteLive(root, `uncaught: ${errorText(e)}`));
6225
6348
  process.on("unhandledRejection", (e) => noteLive(root, `unhandled: ${errorText(e)}`));
6226
6349
  return new Promise((resolve) => {
6227
- // the tree's bridge runs already (this one started late, another started meanwhile): this one is not needed
6228
- const before = otherBridge(root, env);
6229
- if (before) {
6230
- noteLive(root, `another bridge of this tree runs already (${before.pid}): this one (${process.pid}) ends`);
6231
- return resolve();
6232
- }
6233
6350
  let up = false;
6234
6351
  let wanted = last?.port ?? 0;
6235
6352
  let tries = 0;
@@ -6270,17 +6387,31 @@ export function serveLive(root, env) {
6270
6387
  server.listen(wanted, "127.0.0.1");
6271
6388
  server.once("listening", () => {
6272
6389
  up = true;
6273
- // another bridge of this tree came up while this one started (two started at once): this one goes, nothing of it written
6274
- const meanwhile = otherBridge(root, env);
6275
- if (meanwhile) {
6276
- noteLive(root, `another bridge of this tree came up meanwhile (${meanwhile.pid}): this one (${process.pid}) ends`);
6390
+ // another bridge of this tree came up while this one started (its claim taken over meanwhile, a bridge of an older
6391
+ // strom that claims nothing): this one goes, nothing of it written — the check and the notes one step under the
6392
+ // tree's owner lock, so no other bridge writes its own between them
6393
+ const port = server.address().port;
6394
+ const meanwhile = withLiveOwner(root, () => {
6395
+ const rival = rivalBridge(root, env);
6396
+ if (rival)
6397
+ return rival;
6398
+ try {
6399
+ writeOwner(root);
6400
+ }
6401
+ catch {
6402
+ // a folder not to be written: live.json says the bridge
6403
+ }
6404
+ live = { port, token, pid: process.pid, url: `http://127.0.0.1:${port}/${token}`, started: new Date().toISOString(), version: VERSION };
6405
+ writeLive(root, live);
6406
+ writeLast(root, { port, token, pid: process.pid, started: live.started });
6407
+ return undefined;
6408
+ });
6409
+ if (meanwhile || !live) {
6410
+ noteLive(root, `another bridge of this tree came up meanwhile (${meanwhile}): this one (${process.pid}) ends`);
6411
+ dropOwner(root);
6277
6412
  server.close();
6278
6413
  return resolve();
6279
6414
  }
6280
- const port = server.address().port;
6281
- live = { port, token, pid: process.pid, url: `http://127.0.0.1:${port}/${token}`, started: new Date().toISOString(), version: VERSION };
6282
- writeLive(root, live);
6283
- writeLast(root, { port, token, pid: process.pid, started: live.started });
6284
6415
  // its research gone: no strom.json there, or the .strom it was started with deleted (gone, or another one in its
6285
6416
  // place) — the bridge then ends and makes neither again (noteLive, writeLast make no folder)
6286
6417
  // — and still gone when looked at again a while later (STROM_LIVE_GONE_MS): a disk away for a moment (a network
@@ -6457,13 +6588,19 @@ export function serveLive(root, env) {
6457
6588
  const back = (why) => {
6458
6589
  if (!handing)
6459
6590
  return;
6591
+ const was = handing.pid;
6460
6592
  handing = undefined;
6461
6593
  renewing = false;
6594
+ // the tree claimed again (the new one claimed it as it started) — unless another bridge holds it meanwhile:
6595
+ // then that one is the tree's, and this one ends (the new one ended at once for it)
6596
+ const rival = claimTree(root, env, was);
6597
+ if (rival)
6598
+ return stop(`another bridge of this tree runs (${rival}): the bridge of strom ${disk.version} ended for it`, "restart", true);
6462
6599
  noteLive(root, `the bridge of strom ${disk.version} did not take over (${why}): this one (${runs}) goes on`);
6463
6600
  };
6464
6601
  let child;
6465
6602
  try {
6466
- child = spawnBridge(root, env, { STROM_LIVE_RENEWED: disk.version, STROM_LIVE_STATUS_FOR: statusVersion ?? "", ...(gedFollow ? { STROM_LIVE_GED_FOR: gedFollow.version ?? "", ...(gedFollow.images === "ref" ? { STROM_LIVE_GED_IMAGES: "ref" } : {}) } : {}) });
6603
+ child = spawnBridge(root, env, { STROM_LIVE_RENEWED: disk.version, STROM_LIVE_REPLACES: String(process.pid), STROM_LIVE_STATUS_FOR: statusVersion ?? "", ...(gedFollow ? { STROM_LIVE_GED_FOR: gedFollow.version ?? "", ...(gedFollow.images === "ref" ? { STROM_LIVE_GED_IMAGES: "ref" } : {}) } : {}) });
6467
6604
  }
6468
6605
  catch (e) {
6469
6606
  renewing = false;
@@ -6721,13 +6858,19 @@ export function serveLive(root, env) {
6721
6858
  for (const s of streams)
6722
6859
  s.end();
6723
6860
  server.close();
6724
- try {
6725
- const now = JSON.parse(fs.readFileSync(liveFile(root), "utf8"));
6726
- if (now.pid === process.pid && !handed)
6727
- fs.rmSync(liveFile(root), { force: true });
6728
- }
6729
- catch {
6730
- // gone already
6861
+ // its claim given up (one it handed over to holds it already), its note removed — never another bridge's
6862
+ dropOwner(root);
6863
+ if (!handed) {
6864
+ withLiveOwner(root, () => {
6865
+ try {
6866
+ const now = JSON.parse(fs.readFileSync(liveFile(root), "utf8"));
6867
+ if (now.pid === process.pid)
6868
+ fs.rmSync(liveFile(root), { force: true });
6869
+ }
6870
+ catch {
6871
+ // gone already
6872
+ }
6873
+ });
6731
6874
  }
6732
6875
  const was = readLast(root);
6733
6876
  if (was?.pid === process.pid && !was.ended)
@@ -282,6 +282,7 @@ export const PHRASES = {
282
282
  "wait.group.connectors": "Downloaders",
283
283
  "browser.wait": "images {images} of {book}, saved by the agent's browser from {url}",
284
284
  "browser.save.other": "the browser's tab shows another image than {n} ({url}), nothing was saved",
285
+ "browser.wait.held": "images {images} of {book}, saved by the agent's browser from {url} — the browser held image {n} back: {host} to be allowed to download several files, once (the icon at the right end of the browser's address bar)",
285
286
  "wait.group.app": "The Strom app",
286
287
  "wait.group.tune": "The reading of scans",
287
288
  "wait.group.conflicts": "Conflicts to decide",
package/dist/core/tree.js CHANGED
@@ -32,7 +32,7 @@ export const TREE_FILE = "strom.json";
32
32
  export const SEAL_FOREIGN = "seal.foreign";
33
33
  // between releases the candidate being made (a bridge run from the sources says what it is: the Strom app goes by it);
34
34
  // at a release the release's own (package.json)
35
- export const VERSION = "1.30.0-beta.4";
35
+ export const VERSION = "1.30.0-beta.5";
36
36
  /** What a new research is settled with from the start: nothing an older strom counted otherwise to set right in it. */
37
37
  export const NEW_TREE_SETTLED = ["readers-1", "proven-originals-1", "origins-1", "verify-originals-1", "origins-tree-1"];
38
38
  const GITIGNORE = `# Strom Research — local state and large files are not versioned
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "strom-research",
3
- "version": "1.30.0-beta.4",
3
+ "version": "1.30.0-beta.5",
4
4
  "stromDoc": "b0cbb0d2f7881647551ff5b23fb37943e268e206",
5
5
  "description": "Genealogical research toolkit for AI coding agents",
6
6
  "type": "module",