strom-research 1.34.0 → 1.35.0-beta.2
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 +31 -0
- package/CHANGELOG.de.md +39 -0
- package/CHANGELOG.md +33 -0
- package/CHANGELOG.pl.md +34 -0
- package/assets/archives.json +81 -15
- package/assets/lang/cs.json +37 -0
- package/assets/lang/de.json +37 -0
- package/assets/lang/pl.json +37 -0
- package/assets/strom-doc/CISLA.md +42 -0
- package/assets/strom-doc/PIN +1 -1
- package/assets/strom-doc/REJSTRIK.md +42 -6
- package/assets/strom-doc/cs/A11-lists-of-people.md +300 -0
- package/assets/strom-doc/cs/A12-portrait-and-couple-photo.md +262 -0
- package/assets/strom-doc/cs/A2-loading-a-family-tree.md +10 -2
- package/assets/strom-doc/cs/A3-evidence-in-the-app.md +4 -1
- package/assets/strom-doc/cs/A6-views.md +257 -20
- package/assets/strom-doc/cs/A7-book-pages-and-export.md +14 -1
- package/assets/strom-doc/cs/A9-using-the-app.md +5 -2
- package/assets/strom-doc/cs/R2-lines-and-queue.md +23 -0
- package/assets/strom-doc/cs/R6-awaiting-action.md +119 -1
- package/assets/strom-doc/cs/R7-when-the-agent-works.md +3 -1
- package/assets/strom-doc/cs/R9-archives.md +34 -1
- package/assets/strom-doc/cs/README.md +2 -0
- package/assets/strom-doc/cs/S2-edits-from-the-app.md +50 -5
- package/assets/strom-doc/cs/S4-research-from-the-app.md +230 -6
- package/assets/strom-doc/cs/S6-tree-from-another-program.md +8 -1
- package/assets/strom-doc/de/A11-lists-of-people.md +343 -0
- package/assets/strom-doc/de/A12-portrait-and-couple-photo.md +304 -0
- package/assets/strom-doc/de/A2-loading-a-family-tree.md +12 -2
- package/assets/strom-doc/de/A3-evidence-in-the-app.md +5 -1
- package/assets/strom-doc/de/A6-views.md +306 -21
- package/assets/strom-doc/de/A7-book-pages-and-export.md +16 -1
- package/assets/strom-doc/de/A9-using-the-app.md +7 -4
- package/assets/strom-doc/de/R2-lines-and-queue.md +27 -0
- package/assets/strom-doc/de/R6-awaiting-action.md +136 -1
- package/assets/strom-doc/de/R7-when-the-agent-works.md +3 -1
- package/assets/strom-doc/de/R9-archives.md +39 -1
- package/assets/strom-doc/de/README.md +2 -0
- package/assets/strom-doc/de/S2-edits-from-the-app.md +57 -5
- package/assets/strom-doc/de/S4-research-from-the-app.md +267 -7
- package/assets/strom-doc/de/S6-tree-from-another-program.md +8 -1
- package/assets/strom-doc/en/A11-lists-of-people.md +309 -0
- package/assets/strom-doc/en/A12-portrait-and-couple-photo.md +286 -0
- package/assets/strom-doc/en/A2-loading-a-family-tree.md +12 -2
- package/assets/strom-doc/en/A3-evidence-in-the-app.md +5 -1
- package/assets/strom-doc/en/A6-views.md +278 -21
- package/assets/strom-doc/en/A7-book-pages-and-export.md +15 -1
- package/assets/strom-doc/en/A9-using-the-app.md +10 -7
- package/assets/strom-doc/en/R2-lines-and-queue.md +25 -0
- package/assets/strom-doc/en/R6-awaiting-action.md +128 -1
- package/assets/strom-doc/en/R7-when-the-agent-works.md +3 -1
- package/assets/strom-doc/en/R9-archives.md +35 -1
- package/assets/strom-doc/en/README.md +2 -0
- package/assets/strom-doc/en/S2-edits-from-the-app.md +51 -4
- package/assets/strom-doc/en/S4-research-from-the-app.md +248 -10
- package/assets/strom-doc/en/S6-tree-from-another-program.md +8 -1
- package/assets/strom-doc/pl/A11-lists-of-people.md +313 -0
- package/assets/strom-doc/pl/A12-portrait-and-couple-photo.md +272 -0
- package/assets/strom-doc/pl/A2-loading-a-family-tree.md +12 -2
- package/assets/strom-doc/pl/A3-evidence-in-the-app.md +5 -1
- package/assets/strom-doc/pl/A6-views.md +273 -20
- package/assets/strom-doc/pl/A7-book-pages-and-export.md +15 -1
- package/assets/strom-doc/pl/A9-using-the-app.md +5 -2
- package/assets/strom-doc/pl/R2-lines-and-queue.md +24 -0
- package/assets/strom-doc/pl/R6-awaiting-action.md +128 -1
- package/assets/strom-doc/pl/R7-when-the-agent-works.md +3 -1
- package/assets/strom-doc/pl/R9-archives.md +37 -1
- package/assets/strom-doc/pl/README.md +2 -0
- package/assets/strom-doc/pl/S2-edits-from-the-app.md +52 -4
- package/assets/strom-doc/pl/S4-research-from-the-app.md +243 -6
- package/assets/strom-doc/pl/S6-tree-from-another-program.md +8 -1
- package/dist/brief/brief.js +3 -0
- package/dist/cli/context.js +7 -4
- package/dist/cli/help.js +8 -7
- package/dist/cli/menu-settings.js +62 -3
- package/dist/cli/menu-waiting.js +51 -0
- package/dist/cli/menu.js +4 -1
- package/dist/cli/ui.js +27 -0
- package/dist/commands/links.js +19 -0
- package/dist/commands/media.js +36 -4
- package/dist/commands/setup.js +3 -1
- package/dist/commands/sync.js +40 -2
- package/dist/commands/tasks.js +95 -3
- package/dist/core/books.js +189 -0
- package/dist/core/claudedir.js +4 -4
- package/dist/core/config.js +19 -0
- package/dist/core/inboxwait.js +52 -0
- package/dist/core/inboxwatch.js +6 -4
- package/dist/core/knownterms.js +10 -0
- package/dist/core/links.js +11 -1
- package/dist/core/live.js +105 -6
- package/dist/core/livestatus.js +1 -0
- package/dist/core/notefix.js +44 -4
- package/dist/core/phrases.js +10 -0
- package/dist/core/queue.js +32 -2
- package/dist/core/report.js +5 -9
- package/dist/core/runsync.js +68 -0
- package/dist/core/shorternote.js +95 -0
- package/dist/core/stromapp.js +10 -5
- package/dist/core/sync.js +48 -2
- package/dist/core/terms.js +17 -0
- package/dist/core/tree.js +1 -1
- package/dist/core/waiting.js +4 -0
- package/dist/runners/runner.js +3 -11
- package/package.json +5 -2
package/dist/core/live.js
CHANGED
|
@@ -27,6 +27,15 @@
|
|
|
27
27
|
// the gate the agent works alone under as the settings name it (title and what it is given),
|
|
28
28
|
// null with none set (the loop is not started then, n tasks are), and a session's minutes
|
|
29
29
|
// (run.minutes). busy {sessions, runs} sees a run from its start, while it waits for its gate too.
|
|
30
|
+
// books (feature books, no gate of the app's version; none in an archive or a research waiting
|
|
31
|
+
// for its agent; part books): the books most tasks need, to download by hand (core/books.ts) —
|
|
32
|
+
// {settings {minTasks, minTasksOwn, minTasksDefault, sameBook: yes|no, sameBookOwn,
|
|
33
|
+
// sameBookDefault}, list [as strom task books --json, without ids and dir: id, title, folder,
|
|
34
|
+
// tasks, waiting, offer, download (whole|selected|range|none), downloadTerms? {how, says, from,
|
|
35
|
+
// host}, need?, images?, onDisk, missing?, url?, archive?, years?, pending? (files lying in its
|
|
36
|
+
// folder, not taken yet)], more (beyond 100)}; only books something waits for or offered. A task
|
|
37
|
+
// of the waiting list or the queue names its book (book: B…: the one it waits for, else the one
|
|
38
|
+
// live book its record sets name); a queue item put first by queue.sameBook says sameBook: B….
|
|
30
39
|
// GET <token>/status/<part> one of those parts: {part, rev, head, …its fields as /status carries them}; 404
|
|
31
40
|
// status.part for another name.
|
|
32
41
|
// A queue item off the lines of a research with several (core/offline.ts) says offLine:
|
|
@@ -425,6 +434,10 @@
|
|
|
425
434
|
// POST <token>/offline {mode?: occasional|last|normal|never|default, suggest?: true|false}: strom config set
|
|
426
435
|
// queue.offLine … / queue.suggestLines yes|no --for-tree (default: config unset) — {offLine
|
|
427
436
|
// (without branches), head, parent}; 400 offline.body
|
|
437
|
+
// POST <token>/books {minTasks?: 1…999|"default", sameBook?: yes|no|"default"} (at least one): strom config set
|
|
438
|
+
// books.minTasks … / queue.sameBook … --for-tree ("default": config unset --for-tree) — {books
|
|
439
|
+
// {settings} (as /status books.settings), head, parent (head when nothing changed)}; feature
|
|
440
|
+
// books; 400 books.body, 409 directions.archive, 503 research.busy
|
|
428
441
|
// POST <token>/queue/<T…> {do: next|last|default}: strom task order --next|--last|--default (any open task; next
|
|
429
442
|
// once, the last chosen first) — {task (as queue[]), was ({} or {own: next|last, at}: its turn
|
|
430
443
|
// before), head, parent}; {do: restore, was: {} | {own, at}}: the turn put back exactly as it
|
|
@@ -554,7 +567,8 @@ import { APP_SHOWS_ORIGIN, APP_SHOWS_ORIGIN_BETA, appReadsMainCitation, appSends
|
|
|
554
567
|
import { suggestSurnames } from "./surnames.js";
|
|
555
568
|
import { judgePairs, pairsOf, PAIRS_MAX } from "./duplicates.js";
|
|
556
569
|
import { askOf, qualityRev, readDismissed } from "./quality.js";
|
|
557
|
-
import { configFile, DEFAULT_RUN_MINUTES, LIVE_IDLE_CHOICES, LIVE_IDLE_MAX_MINUTES, loadUserConfig, readStored, Settings } from "./config.js";
|
|
570
|
+
import { BOOKS_MIN_TASKS, BOOKS_MIN_TASKS_MAX, configFile, DEFAULT_RUN_MINUTES, LIVE_IDLE_CHOICES, LIVE_IDLE_MAX_MINUTES, loadUserConfig, readStored, Settings } from "./config.js";
|
|
571
|
+
import { folderFiles } from "./inboxwait.js";
|
|
558
572
|
import { gateLabel } from "./gate.js";
|
|
559
573
|
import { LINK_SCHEME, linkActions, linkHandlerState, linkHandlerStateLater, linkScheme, linkText } from "./links.js";
|
|
560
574
|
import { autoTidy } from "./tidy.js";
|
|
@@ -568,6 +582,7 @@ import { ANSWER_MAX, HIDE_REASONS, OFF_LINE_CHOICES } from "./model.js";
|
|
|
568
582
|
import { normId } from "./records.js";
|
|
569
583
|
import { confirmCheck } from "./confirm.js";
|
|
570
584
|
import { answersInApp, requestTexts, waitingFor } from "./waiting.js";
|
|
585
|
+
import { bookOfTask, bookRows } from "./books.js";
|
|
571
586
|
import { fileRefused } from "./taskfiles.js";
|
|
572
587
|
import { SENDABLE, waitKindOf, waitPhaseOf } from "./waitkind.js";
|
|
573
588
|
import { agentsHere } from "./apps.js";
|
|
@@ -1556,7 +1571,7 @@ export function tagMatches(req, tag) {
|
|
|
1556
1571
|
.map((t) => t.trim().replace(/^W\//u, ""))
|
|
1557
1572
|
.some((t) => t === "*" || t === tag);
|
|
1558
1573
|
}
|
|
1559
|
-
export const BRIDGE_FEATURES = ["sync.again", "sync.undoneSince", "sync.takenBack", "sync.conflictEdit", "sync.since", "sync.ids", "family.noCouple", "family.alone", "adopt.transfer", "adopt.empty", "material.list", "person.titles", "media.codes", "hypothesis.links", "status.recent", "spend.readers", "hypothesis.intree", "archive.permission", "task.check", "waiting.groups", "waiting.sent", "waiting.note", "batch.kept", "live.end", "whats.new", "terminal.choice", "person.marriedSurname", "phone", "read.now", "read.sync", "excerpt.get", "log.sources", "material.assign", "material.thumb", "seal.foreign", "tree.state", "disk.full", "tree.notDownloaded", "sync.removed", "tree.kind", "experiments", "experiments.off", "experiments.link", "experiments.split", "history.events", "history.hide", "experiments.pace", "history.first", "history.regions", "history.hide.all", "history.skip", "history.map", "history.delete", "history.delete.restore", "stories.history", "history.place", "surnames.suggest", "surnames.read", "lineage.read", "duplicates.judge", "quality.dismiss", "quality.read", "person.primary", "fixes.list", "fixes.towns", "history.back", "places.identify", "places.answer", "places.undo", "tasks.offLine", "status.busy", "history.kinds", "history.align", "places.nameKinds", "directions.edit", "directions.order", "directions.found", "directions.people", "directions.places", "offLine.branches", "queue.own", "story.sources", "queue.page", "status.parts", "waiting.answer", "browser.state", "working.place", "working.family", "working.helps", "hypotheses.decide", "sources.confirm", "read.sourceTask", "read.sourceTask.unsure", "read.choose", "read.choices.now", "read.source", "read.sourceEntry", "read.blindText", "read.kinds", "read.variantKind", "read.readerState", "live.idle", "live.stop", "live.start", "sources.proposal", "sources.proposal.undo", "origin", "origin.ids", "verify", "verify.bulk", "facts.confirm", "verify.stop", "ged.stale", "facts.confirm.value", "ged.etag", "ged.imagesByHash", "hypothesis.decide.link", "hypotheses.accept.link", "sources.fields", "sources.split", "queue.search", "queue.next", "work.link", "run.tasks", "event.share", "citations.order", "sync.notWritten.codes", "citations.main", "citations.remove"];
|
|
1574
|
+
export const BRIDGE_FEATURES = ["sync.again", "sync.undoneSince", "sync.takenBack", "sync.conflictEdit", "sync.since", "sync.ids", "family.noCouple", "family.alone", "adopt.transfer", "adopt.empty", "material.list", "person.titles", "media.codes", "hypothesis.links", "status.recent", "spend.readers", "hypothesis.intree", "archive.permission", "task.check", "waiting.groups", "waiting.sent", "waiting.note", "batch.kept", "live.end", "whats.new", "terminal.choice", "person.marriedSurname", "phone", "read.now", "read.sync", "excerpt.get", "log.sources", "material.assign", "material.thumb", "seal.foreign", "tree.state", "disk.full", "tree.notDownloaded", "sync.removed", "tree.kind", "experiments", "experiments.off", "experiments.link", "experiments.split", "history.events", "history.hide", "experiments.pace", "history.first", "history.regions", "history.hide.all", "history.skip", "history.map", "history.delete", "history.delete.restore", "stories.history", "history.place", "surnames.suggest", "surnames.read", "lineage.read", "duplicates.judge", "quality.dismiss", "quality.read", "person.primary", "fixes.list", "fixes.towns", "history.back", "places.identify", "places.answer", "places.undo", "tasks.offLine", "status.busy", "history.kinds", "history.align", "places.nameKinds", "directions.edit", "directions.order", "directions.found", "directions.people", "directions.places", "offLine.branches", "queue.own", "story.sources", "queue.page", "status.parts", "waiting.answer", "browser.state", "working.place", "working.family", "working.helps", "hypotheses.decide", "sources.confirm", "read.sourceTask", "read.sourceTask.unsure", "read.choose", "read.choices.now", "read.source", "read.sourceEntry", "read.blindText", "read.kinds", "read.variantKind", "read.readerState", "live.idle", "live.stop", "live.start", "sources.proposal", "sources.proposal.undo", "origin", "origin.ids", "verify", "verify.bulk", "facts.confirm", "verify.stop", "ged.stale", "facts.confirm.value", "ged.etag", "ged.imagesByHash", "hypothesis.decide.link", "hypotheses.accept.link", "sources.fields", "sources.split", "queue.search", "queue.next", "work.link", "run.tasks", "event.share", "citations.order", "sync.notWritten.codes", "citations.main", "citations.remove", "books"];
|
|
1560
1575
|
/**
|
|
1561
1576
|
* What the bridge says it does to the app of that version: BRIDGE_FEATURES, but origin.ids only where its /tree.ged
|
|
1562
1577
|
* carries the original IDs (the gate of the origins, the same version of the app as the file goes by) — an app that is
|
|
@@ -2065,7 +2080,11 @@ function whereInQueue(place, offLine, file, t, r) {
|
|
|
2065
2080
|
}
|
|
2066
2081
|
/** One task as the queue has it: ranked (in the queue: its place, its why, its own turn), else as it stands among the lines alone. */
|
|
2067
2082
|
function queueItem(tree, place, offLine, file, state, t, r, pos) {
|
|
2068
|
-
return { id: t.id, text: humanTask(tree, t.what, tree.lang), state, ...(pos ? { pos } : {}), ...personOf(t), ...whereInQueue(place, offLine, file, t, r), ...(r?.own ? { own: r.own } : {}), ...(r?.reason ? { why: r.reason } : {}), ...(forStory(t) ? { kind: "story" } : forHistory(t) ? { kind: "history" } : {}) };
|
|
2083
|
+
return { id: t.id, text: humanTask(tree, t.what, tree.lang), state, ...(pos ? { pos } : {}), ...personOf(t), ...whereInQueue(place, offLine, file, t, r), ...(r?.own ? { own: r.own } : {}), ...(r?.reason ? { why: r.reason } : {}), ...(forStory(t) ? { kind: "story" } : forHistory(t) ? { kind: "history" } : {}), ...bookPart(tree, t), ...(r?.sameBook ? { sameBook: r.sameBook } : {}) };
|
|
2084
|
+
}
|
|
2085
|
+
function bookPart(tree, t) {
|
|
2086
|
+
const book = bookOfTask(tree, t);
|
|
2087
|
+
return book ? { book } : {};
|
|
2069
2088
|
}
|
|
2070
2089
|
/** The tasks put aside (parked, not back by their date): after the queue, by their IDs — no place in it. */
|
|
2071
2090
|
function parkedTasks(tree) {
|
|
@@ -2089,7 +2108,7 @@ function rankedNow(tree, settings, h) {
|
|
|
2089
2108
|
return "-";
|
|
2090
2109
|
}
|
|
2091
2110
|
};
|
|
2092
|
-
const key = [h, now().slice(0, 10), settings.strategy(tree.config), settings.offLine(tree.config), mtime(path.join(tree.root, TREE_FILE)), mtime(configFile(tree.env)), mtime(path.join(tree.root, ...OFFLINE_FILE.split("/")))].join("|");
|
|
2111
|
+
const key = [h, now().slice(0, 10), settings.strategy(tree.config), settings.offLine(tree.config), String(settings.sameBook(tree.config)), mtime(path.join(tree.root, TREE_FILE)), mtime(configFile(tree.env)), mtime(path.join(tree.root, ...OFFLINE_FILE.split("/")))].join("|");
|
|
2093
2112
|
const had = rankedCache.get(tree.root);
|
|
2094
2113
|
if (had && had.key === key && Date.now() - had.at < Number(tree.env.STROM_LIVE_QUEUE_MS ?? 10_000))
|
|
2095
2114
|
return had;
|
|
@@ -2365,6 +2384,38 @@ function queueTask(tree, settings, id) {
|
|
|
2365
2384
|
const at = ranked.findIndex((x) => x.task.id === id);
|
|
2366
2385
|
return queueItem(tree, placer(tree, all), settings.offLine(tree.config), readOffline(tree), t.state === "parked" ? "parked" : "next", t, ranked[at], at < 0 ? undefined : at + 1);
|
|
2367
2386
|
}
|
|
2387
|
+
/** At most this many books in /status books (the rest counted in `more`). */
|
|
2388
|
+
const BOOKS_LIST_MAX = 100;
|
|
2389
|
+
/**
|
|
2390
|
+
* The tree's settings of the books (spec 105): books.minTasks and queue.sameBook as they hold, whether set for the tree
|
|
2391
|
+
* (…Own; false: the default), and the defaults — what the app shows and POST /books changes.
|
|
2392
|
+
*/
|
|
2393
|
+
function booksSettings(tree, settings) {
|
|
2394
|
+
return {
|
|
2395
|
+
minTasks: settings.booksMinTasks(tree.config),
|
|
2396
|
+
minTasksOwn: readStored(tree.config, "books.minTasks", "") !== undefined,
|
|
2397
|
+
minTasksDefault: BOOKS_MIN_TASKS,
|
|
2398
|
+
sameBook: settings.sameBook(tree.config) ? "yes" : "no",
|
|
2399
|
+
sameBookOwn: readStored(tree.config, "queue.sameBook", "") !== undefined,
|
|
2400
|
+
sameBookDefault: "no",
|
|
2401
|
+
};
|
|
2402
|
+
}
|
|
2403
|
+
/**
|
|
2404
|
+
* /status books (spec 105, feature books): the settings, and the books — each one something waits on (the app's groups
|
|
2405
|
+
* by book), and those offered to download (offer) — the most tasks first, at most BOOKS_LIST_MAX (more: the rest). Each
|
|
2406
|
+
* as strom task books --json says it, without the task IDs and the folder's path; pending: the files lying in its folder
|
|
2407
|
+
* not taken yet (only when any).
|
|
2408
|
+
*/
|
|
2409
|
+
function booksStatus(tree, settings) {
|
|
2410
|
+
const shared = settings.shared()?.value;
|
|
2411
|
+
const rows = bookRows(tree, settings.booksMinTasks(tree.config)).filter((r) => r.waiting > 0 || r.offer);
|
|
2412
|
+
const shown = rows.slice(0, BOOKS_LIST_MAX).map((r) => {
|
|
2413
|
+
const { ids: _ids, ...row } = r;
|
|
2414
|
+
const pending = shared ? folderFiles(path.join(shared, "inbox", r.folder)).length : 0;
|
|
2415
|
+
return { ...row, ...(pending ? { pending } : {}) };
|
|
2416
|
+
});
|
|
2417
|
+
return { settings: booksSettings(tree, settings), list: shown, more: rows.length - shown.length };
|
|
2418
|
+
}
|
|
2368
2419
|
/** The work off the lines without its branches (the answer to POST /offline): also for a research of one line, where nothing is off them. */
|
|
2369
2420
|
function offLineSummary(tree, settings) {
|
|
2370
2421
|
const v = offLineView(tree, settings);
|
|
@@ -2565,6 +2616,9 @@ export function status(root, env, version, seen) {
|
|
|
2565
2616
|
queueCounts: queueCounts(ranked, order?.parked.length ?? 0, order?.rev),
|
|
2566
2617
|
// the work off the lines of a research of several (spec 038 K7): the tree's choice, the branches, which grow
|
|
2567
2618
|
...(archive ? {} : offLineOf(tree, settings, all, ranked)),
|
|
2619
|
+
// the books the tasks need (spec 105, feature books): those waited on, those offered to download — none in an
|
|
2620
|
+
// archive or a research waiting for its agent
|
|
2621
|
+
...(archive ? {} : { books: booksStatus(tree, settings) }),
|
|
2568
2622
|
...(newer ? { update: { version: newer } } : {}),
|
|
2569
2623
|
...(archive ? {} : { spend: spendOf(root, tree) }),
|
|
2570
2624
|
...(intake ? { lastIntake: intake } : {}),
|
|
@@ -2747,7 +2801,7 @@ export function serveLive(root, env) {
|
|
|
2747
2801
|
try {
|
|
2748
2802
|
const done = settleNotes(Tree.open(root, env));
|
|
2749
2803
|
if (done)
|
|
2750
|
-
noteLive(root, `notes a send of the app wrote to a fact alike: ${counted(done.notes, "note")} of ${counted(done.facts, "fact")} set right, ${counted(done.left.length, "fact")} changed since, left as they are${done.left.length ? ` (${done.left.join(", ")})` : ""}${done.backup ? `; backed up first: ${done.backup.path}` : ""}`);
|
|
2804
|
+
noteLive(root, `notes a send of the app wrote to a fact alike: ${counted(done.notes, "note")} of ${counted(done.facts, "fact")} set right, ${counted(done.left.length, "fact")} changed since, left as they are${done.left.length ? ` (${done.left.join(", ")}; asked of the person: ${done.asked.join(", ")})` : ""}${done.backup ? `; backed up first: ${done.backup.path}` : ""}`);
|
|
2751
2805
|
}
|
|
2752
2806
|
catch (e) {
|
|
2753
2807
|
noteLive(root, `the notes a send of the app wrote to a fact alike not set right now: ${errorText(e)}`);
|
|
@@ -3403,6 +3457,11 @@ export function serveLive(root, env) {
|
|
|
3403
3457
|
writeFor(req, res, origin, liveWrite());
|
|
3404
3458
|
return;
|
|
3405
3459
|
}
|
|
3460
|
+
// the tree's settings of the books (spec 105)
|
|
3461
|
+
if (req.method === "POST" && t === token && what === "books" && !sub) {
|
|
3462
|
+
writeFor(req, res, origin, booksWrite());
|
|
3463
|
+
return;
|
|
3464
|
+
}
|
|
3406
3465
|
// work off the lines: a branch's choice, the tree's, a task's own turn — each a strom command
|
|
3407
3466
|
if (req.method === "POST" && t === token && what === "offline" && !act) {
|
|
3408
3467
|
writeFor(req, res, origin, sub ? offlineBranchWrite(decoded(sub)) : offlineTreeWrite());
|
|
@@ -5713,6 +5772,44 @@ export function serveLive(root, env) {
|
|
|
5713
5772
|
refused: (_tree, code, why, data) => offlineRefused(code, why, data),
|
|
5714
5773
|
};
|
|
5715
5774
|
};
|
|
5775
|
+
/**
|
|
5776
|
+
* The tree's settings of the books (POST /books {"minTasks"?: 1…999|"default", "sameBook"?: "yes"|"no"|"default"}, at
|
|
5777
|
+
* least one; spec 105): strom config set books.minTasks n --for-tree, queue.sameBook yes|no --for-tree (default: config
|
|
5778
|
+
* unset) — as the person's own command; as it is already: 200, head = parent. {books: {settings}, head, parent}. Not in
|
|
5779
|
+
* an archive nor a research waiting for its agent (409 directions.archive).
|
|
5780
|
+
*/
|
|
5781
|
+
const booksWrite = () => {
|
|
5782
|
+
let before = "";
|
|
5783
|
+
return {
|
|
5784
|
+
what: "the settings of the books",
|
|
5785
|
+
codes: { badBody: "books.body", busy: "research.busy", failed: "books.failed" },
|
|
5786
|
+
busyStatus: 503,
|
|
5787
|
+
ask(tree, body) {
|
|
5788
|
+
const { minTasks, sameBook } = body;
|
|
5789
|
+
const okMin = minTasks === undefined || minTasks === "default" || (typeof minTasks === "number" && Number.isInteger(minTasks) && minTasks >= 1 && minTasks <= BOOKS_MIN_TASKS_MAX);
|
|
5790
|
+
const okSame = sameBook === undefined || sameBook === "yes" || sameBook === "no" || sameBook === "default";
|
|
5791
|
+
if (!Object.keys(body).length || Object.keys(body).some((k) => k !== "minTasks" && k !== "sameBook") || !okMin || !okSame)
|
|
5792
|
+
return { code: 400, body: refusal(`the body: {"minTasks"?: 1…${BOOKS_MIN_TASKS_MAX} | "default", "sameBook"?: "yes" | "no" | "default"} (at least one)`, "books.body") };
|
|
5793
|
+
if (actsAsArchive(tree))
|
|
5794
|
+
return directionsArchive(tree);
|
|
5795
|
+
before = head(root);
|
|
5796
|
+
const cmds = [];
|
|
5797
|
+
const min = readStored(tree.config, "books.minTasks", "");
|
|
5798
|
+
if (minTasks === "default" ? min !== undefined : minTasks !== undefined && Number(min) !== minTasks)
|
|
5799
|
+
cmds.push(minTasks === "default" ? ["config", "unset", "books.minTasks", "--for-tree"] : ["config", "set", "books.minTasks", String(minTasks), "--for-tree"]);
|
|
5800
|
+
const same = readStored(tree.config, "queue.sameBook", "");
|
|
5801
|
+
if (sameBook === "default" ? same !== undefined : sameBook !== undefined && same !== sameBook)
|
|
5802
|
+
cmds.push(sameBook === "default" ? ["config", "unset", "queue.sameBook", "--for-tree"] : ["config", "set", "queue.sameBook", sameBook, "--for-tree"]);
|
|
5803
|
+
if (!cmds.length)
|
|
5804
|
+
return { code: 200, body: { books: { settings: booksSettings(tree, new Settings(env, {})) }, head: before, parent: before } };
|
|
5805
|
+
return { args: cmds[0], ...(cmds[1] ? { then: () => cmds[1] } : {}) };
|
|
5806
|
+
},
|
|
5807
|
+
done(tree, _data, h) {
|
|
5808
|
+
return { books: { settings: booksSettings(tree, new Settings(env, {})) }, head: h, parent: before };
|
|
5809
|
+
},
|
|
5810
|
+
refused: (_tree, code, why, data) => offlineRefused(code, why, data),
|
|
5811
|
+
};
|
|
5812
|
+
};
|
|
5716
5813
|
/**
|
|
5717
5814
|
* The bridge itself (POST /live): {"idleMinutes": n} — strom config set live.idleMinutes n (this computer's, every
|
|
5718
5815
|
* tree's bridge; nothing of the research committed; as it is already: 200, nothing written) — or {"do": "stop"}: ended
|
|
@@ -7088,6 +7185,8 @@ export function serveLive(root, env) {
|
|
|
7088
7185
|
child.on("close", (code, signal) => {
|
|
7089
7186
|
if (gone)
|
|
7090
7187
|
return;
|
|
7188
|
+
// what lies in the folders changed (taken, or left there: /status books pending): made again at the next ask
|
|
7189
|
+
keeper.forget();
|
|
7091
7190
|
// ended by a signal: said, and the inbox free to take them at its next look
|
|
7092
7191
|
if (code === null) {
|
|
7093
7192
|
noteLive(root, `images saved for waiting tasks not taken now: its strom ended (${signal ?? "a signal"})`);
|
|
@@ -7106,7 +7205,7 @@ export function serveLive(root, env) {
|
|
|
7106
7205
|
const data = JSON.parse(out);
|
|
7107
7206
|
for (const t of data.taken ?? [])
|
|
7108
7207
|
if (t.added.length || t.problem)
|
|
7109
|
-
noteLive(root, `inbox ${t.folder}: ${t.problem ? `nothing taken — ${t.problem}` : `${counted(t.added.length, "image")} registered`}`);
|
|
7208
|
+
noteLive(root, `inbox ${t.folder}: ${t.problem ? `nothing taken — ${t.problem}` : `${counted(t.added.length, "image")} registered${t.left ? `, ${counted(t.left, "file")} without an image number left lying` : ""}`}`);
|
|
7110
7209
|
if (data.woken?.length)
|
|
7111
7210
|
noteLive(root, `back in the queue (images saved): ${data.woken.join(", ")}`);
|
|
7112
7211
|
}
|
package/dist/core/livestatus.js
CHANGED
package/dist/core/notefix.js
CHANGED
|
@@ -5,14 +5,17 @@
|
|
|
5
5
|
// Found in what each sync wrote (its input's `sync.applied`): a note whose new lines the file did not give that fact
|
|
6
6
|
// (its `_STROM_EID`), else — no file kept, no IDs in it — that its twin has; a participant's note cut to its beginning
|
|
7
7
|
// by an app before APP_SENDS_PART_NOTES. Only while the fact still says what the sync wrote: one changed since is
|
|
8
|
-
// left as it is and
|
|
8
|
+
// left as it is and asked of the person (a task waiting for them: whether the note now is right). The note before is put back, the wrong one kept in the note's history; each fact one
|
|
9
9
|
// operation, the marker in strom.json, one commit.
|
|
10
10
|
import fs from "node:fs";
|
|
11
11
|
import { now, VERSION } from "./tree.js";
|
|
12
12
|
import { inputPath } from "./media.js";
|
|
13
13
|
import { freshConfig, quiet } from "./hypolinks.js";
|
|
14
14
|
import { writableUnasked } from "./integrity.js";
|
|
15
|
-
import { update } from "./records.js";
|
|
15
|
+
import { create, update } from "./records.js";
|
|
16
|
+
import { phrase } from "./phrases.js";
|
|
17
|
+
import { displayName } from "./people.js";
|
|
18
|
+
import { truncate } from "../cli/format.js";
|
|
16
19
|
import { factNote, noteLine, readGedcom, readStromJson } from "./sync.js";
|
|
17
20
|
import { compareVersions } from "./semver.js";
|
|
18
21
|
import { isAppVersion } from "./stromapp.js";
|
|
@@ -25,6 +28,8 @@ export const NOTES_FIX_SINCE = "1.34.0";
|
|
|
25
28
|
export const NOTES_SETTLED = "twin-notes-1";
|
|
26
29
|
/** The first Strom app that sends a participant's longer note whole (its 3.28.0 cut it short). */
|
|
27
30
|
const WHOLE_PART_NOTES = "3.29.0";
|
|
31
|
+
/** The origin of the person's task of a note a send wrote of a fact alike, changed since (left as it is). */
|
|
32
|
+
export const NOTES_LEFT_ORIGIN = "sync:notes-left";
|
|
28
33
|
/** A participant's note the 3.28.0 cut short was longer than this (its ~260 bytes): a shorter one is never taken so. */
|
|
29
34
|
const CUT_LONGER = 200;
|
|
30
35
|
const owners = (tree) => [...tree.list("person"), ...tree.list("family")];
|
|
@@ -216,6 +221,39 @@ export function applyNoteFixes(tree, found) {
|
|
|
216
221
|
}, { op: "tree.settle", summary: found.fixes.length ? "the notes a send of the Strom app wrote to a fact alike set right once" : "the notes a send of the Strom app wrote: none to set right" });
|
|
217
222
|
return byEvent.size;
|
|
218
223
|
}
|
|
224
|
+
/**
|
|
225
|
+
* A note changed since the send wrote a fact alike's there, left as it is: one task for the person per fact, waiting —
|
|
226
|
+
* whether the note now is right is theirs to say (the menu's What waits, the Strom app); the notes before and after the
|
|
227
|
+
* send and now in its words, in the research's language. Inside the tree's lock. The tasks made.
|
|
228
|
+
*/
|
|
229
|
+
export function askLeftNotes(tree, left) {
|
|
230
|
+
const lang = tree.lang;
|
|
231
|
+
const out = [];
|
|
232
|
+
const quote = (t) => `„${truncate(noteLine(t), 200)}“`;
|
|
233
|
+
for (const f of left) {
|
|
234
|
+
if (out.some((t) => t.where.includes(f.event)))
|
|
235
|
+
continue;
|
|
236
|
+
const owner = tree.get(f.owner);
|
|
237
|
+
const event = owner?.events.find((e) => e.id === f.event);
|
|
238
|
+
if (!owner || !event)
|
|
239
|
+
continue;
|
|
240
|
+
const name = owner.type === "person" ? displayName(owner) : owner.id;
|
|
241
|
+
out.push(create(tree, "task", {
|
|
242
|
+
level: "verify",
|
|
243
|
+
priority: 3,
|
|
244
|
+
what: truncate(phrase(lang, "notes.left.what", { event: f.event, owner: name }), 200),
|
|
245
|
+
where: [f.event],
|
|
246
|
+
why: truncate(phrase(lang, "notes.left.why", { input: f.input, event: f.event, before: f.before ? quote(f.before) : "—", wrote: quote(f.wrote), now: event.note ? quote(event.note) : "—" }), 1000),
|
|
247
|
+
doneWhen: truncate(phrase(lang, "notes.left.done", { event: f.event }), 500),
|
|
248
|
+
subject: [owner.id],
|
|
249
|
+
state: "waiting",
|
|
250
|
+
waitingOn: phrase(lang, "notes.left.on", { event: f.event }),
|
|
251
|
+
wait: { kind: "other" },
|
|
252
|
+
origin: NOTES_LEFT_ORIGIN,
|
|
253
|
+
}, (tid) => `+${tid} task: the person says whether the note of ${f.event} is right — a send of the Strom app wrote a fact alike's there, changed since`));
|
|
254
|
+
}
|
|
255
|
+
return out;
|
|
256
|
+
}
|
|
219
257
|
/** A local date and time for the backup's README. */
|
|
220
258
|
function when(d) {
|
|
221
259
|
const p = (n) => String(n).padStart(2, "0");
|
|
@@ -278,8 +316,10 @@ export function settleNotes(tree, opts = {}) {
|
|
|
278
316
|
return;
|
|
279
317
|
const facts = applyNoteFixes(tree, found);
|
|
280
318
|
const left = [...new Set(found.left.map((f) => f.event))];
|
|
281
|
-
|
|
282
|
-
|
|
319
|
+
// one changed since: the person asked whether it is right (1116, N2 of 1115 B1) — never set right unasked
|
|
320
|
+
const asked = askLeftNotes(tree, found.left).map((t) => t.id);
|
|
321
|
+
tree.commit(`Notes a send of the Strom app wrote to a fact alike set right: ${[...new Set(found.fixes.map((f) => f.event))].join(", ") || "none"}${left.length ? `; changed since, left as they are: ${left.join(", ")} (asked: ${asked.join(", ")})` : ""}`);
|
|
322
|
+
out = { facts, notes: found.fixes.length, left, asked, ...(backup ? { backup } : {}) };
|
|
283
323
|
});
|
|
284
324
|
return out;
|
|
285
325
|
}
|
package/dist/core/phrases.js
CHANGED
|
@@ -429,6 +429,16 @@ export const PHRASES = {
|
|
|
429
429
|
"log.quality.afterdeath": "{persons}: dated after the death ({subject}), no error",
|
|
430
430
|
"log.quality.dismiss": "Marked no error: {what}",
|
|
431
431
|
"log.quality.undo": "No longer marked no error: {what}",
|
|
432
|
+
"notes.left.what": "Check the note of {event} ({owner}): a send of the Strom app wrote there the note of a fact alike",
|
|
433
|
+
"notes.left.why": "A send of the Strom app ({input}) wrote to {event} the note of another fact of the same kind, day and source; the note was changed since, so it was left as it is. The note before the send: {before}. What the send wrote: {wrote}. The note now: {now}",
|
|
434
|
+
"notes.left.done": "the note of {event} says what is right of this fact (strom event show {event})",
|
|
435
|
+
"notes.left.on": "Whether the note of {event} is right: a send of the Strom app wrote the note of a fact alike there, and it was changed since",
|
|
436
|
+
"note.shorter.what": "The note of {who} at {event} ({owner}) from the Strom app is shorter than the research's: take it, or keep the research's?",
|
|
437
|
+
"note.shorter.why": "The Strom app ({input}) sent at {event} a note of {who} that is only the beginning of the research's: an older app may have cut it, or it was shortened there. Nothing was taken. The note from the app: {sent}. The research's note: {whole}",
|
|
438
|
+
"note.shorter.done": "the shorter note taken (strom sync note {task} take) or the research's kept (strom sync note {task} keep), as answered",
|
|
439
|
+
"note.shorter.on": "Whether the shorter note of {who} at {event} from the Strom app is taken, or the research's kept",
|
|
440
|
+
"note.shorter.taken": "The shorter note of {who} at {event} from the Strom app taken",
|
|
441
|
+
"note.shorter.kept": "The research's note of {who} at {event} kept",
|
|
432
442
|
"proposal.what": "A new wording proposed for the transcript of {source} ({title}): taken, or the transcript kept",
|
|
433
443
|
"proposal.why": "The transcript of {source} is the person's own reading ({read}); the research does not change it and proposes another wording instead ({by}). The proposed wording: {text}",
|
|
434
444
|
"proposal.done": "the proposed wording taken as the transcript of {source}, or the transcript kept as it is",
|
package/dist/core/queue.js
CHANGED
|
@@ -53,6 +53,7 @@ import { Settings } from "./config.js";
|
|
|
53
53
|
import { personQueued, placesFirst } from "./placeid.js";
|
|
54
54
|
import { branchModeOf, placer, readOffline } from "./offline.js";
|
|
55
55
|
import { readsOriginals, VERIFY_EVERY, verifiesInTurn, verifyLacksImages } from "./verifyfacts.js";
|
|
56
|
+
import { booksOfTask } from "./books.js";
|
|
56
57
|
export const LEVEL_ORDER = { intake: 0, locate: 1, link: 2, verify: 3, enrich: 4, request: 5, narrate: 6 };
|
|
57
58
|
/** Levels that read records: without images of their record sets they can only ask the user for them. */
|
|
58
59
|
const NEEDS_IMAGES = new Set(["link", "verify"]);
|
|
@@ -60,6 +61,8 @@ const NEEDS_IMAGES = new Set(["link", "verify"]);
|
|
|
60
61
|
const RECENT = 4;
|
|
61
62
|
/** Sessions without a story after which a story waiting to be written comes first, once. */
|
|
62
63
|
export const STORY_EVERY = 5;
|
|
64
|
+
/** queue.sameBook: at most this many sessions in a row on one book, then the queue's own order again. */
|
|
65
|
+
export const SAME_BOOK_MAX = 5;
|
|
63
66
|
/** A generation for work about no ancestor (a sibling, a side line, a book): after the close ancestors. */
|
|
64
67
|
const OFF_LINE_GENERATION = 4;
|
|
65
68
|
/**
|
|
@@ -296,6 +299,7 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
|
|
|
296
299
|
return !!t && verifiesInTurn(t);
|
|
297
300
|
});
|
|
298
301
|
const sinceVerify = lastVerify === -1 ? ended.length : lastVerify;
|
|
302
|
+
const sameBook = sameBookTurn(tree, ended, tasksById, withImages, opts.sameBook ?? settings.sameBook(tree.config));
|
|
299
303
|
const verifyAhead = sinceVerify >= VERIFY_EVERY
|
|
300
304
|
? open
|
|
301
305
|
.filter(inTurn)
|
|
@@ -318,6 +322,8 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
|
|
|
318
322
|
? 0
|
|
319
323
|
: 2 * t.priority + intake - (gen - 1) - 2 * recent - 1.5 * tried + lineBonus(lineAt);
|
|
320
324
|
const blocked = lacksImages(tree, t, withImages);
|
|
325
|
+
// queue.sameBook: the next task of the book the last session worked in, its images on disk (one that can be done now)
|
|
326
|
+
const inBook = !!sameBook && !blocked && !forHistory(t) && booksOfTask(tree, t).some((b) => b.id === sameBook.book);
|
|
321
327
|
const storyTurn = storyDue && forStory(t);
|
|
322
328
|
// what the variants of hypotheses would connect: short work the Strom app waits for — before all else (core/hypolinks.ts)
|
|
323
329
|
const first = linksFirst(t, tried);
|
|
@@ -366,6 +372,7 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
|
|
|
366
372
|
placesAsked ? "places the person asked to be identified: on top of the queue" : undefined,
|
|
367
373
|
storyTurn ? STORY_WHY : undefined,
|
|
368
374
|
blocked ? "needs images the user has to download" : undefined,
|
|
375
|
+
inBook ? `the same book as the last session (${sameBook.book}, its images on disk: queue.sameBook; ${sameBook.inRow} in a row so far, at most ${SAME_BOOK_MAX})` : undefined,
|
|
369
376
|
`p${t.priority}`,
|
|
370
377
|
t.level === "intake" ? "the user's material" : at ? `generation ${gen}` : "not about an ancestor",
|
|
371
378
|
lineAt !== undefined && working.length > 1 ? `line ${lineAt + 1} of ${working.length}` : undefined,
|
|
@@ -392,8 +399,9 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
|
|
|
392
399
|
...(p.research ? { research: p.research } : {}),
|
|
393
400
|
...(mine ? { own: mine } : {}),
|
|
394
401
|
...(ahead || verifyNow ? { turn: true } : {}),
|
|
402
|
+
...(inBook ? { sameBook: sameBook.book } : {}),
|
|
395
403
|
};
|
|
396
|
-
return { task: t, why, storyTurn, extra, own: mine === "next" ? -1 : mine === "last" ? 1 : 0, nextAt: mine === "next" ? t.queueAt.at : "", offLine: offRank, doing: t.state === "doing" ? 0 : 1, hist: !hist ? 0 : t.id === turnTask ? -1 : 1, horder: hist ? order(t) : 0, first: first || placesAsked ? 0 : 1, blocked: blocked ? 1 : 0, story: storyTurn ? 0 : forStory(t) ? 2 : 1, score, gen, lineRank: lineAt ?? working.length };
|
|
404
|
+
return { task: t, why, storyTurn, extra, own: mine === "next" ? -1 : mine === "last" ? 1 : 0, nextAt: mine === "next" ? t.queueAt.at : "", offLine: offRank, doing: t.state === "doing" ? 0 : 1, hist: !hist ? 0 : t.id === turnTask ? -1 : 1, horder: hist ? order(t) : 0, first: first || placesAsked ? 0 : 1, blocked: blocked ? 1 : 0, inBook: inBook ? 0 : 1, story: storyTurn ? 0 : forStory(t) ? 2 : 1, score, gen, lineRank: lineAt ?? working.length };
|
|
397
405
|
});
|
|
398
406
|
const cmp = (a, b) => a.doing - b.doing ||
|
|
399
407
|
// the person's own turn: next before everything but the work at hand (the last chosen first: the latest "do it
|
|
@@ -412,7 +420,10 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
|
|
|
412
420
|
// work that can be done now comes before work that waits for the user's download
|
|
413
421
|
a.blocked - b.blocked ||
|
|
414
422
|
// priority: strictly the lines' order of work, the tasks of no line after them
|
|
415
|
-
(strategy === "priority" ? a.lineRank - b.lineRank
|
|
423
|
+
(strategy === "priority" ? a.lineRank - b.lineRank : 0) ||
|
|
424
|
+
// queue.sameBook: the tasks of the book the last session read, its images on disk, before the rest (of its line)
|
|
425
|
+
a.inBook - b.inBook ||
|
|
426
|
+
(strategy === "priority" ? b.task.priority - a.task.priority || a.gen - b.gen : b.score - a.score) ||
|
|
416
427
|
(LEVEL_ORDER[a.task.level] ?? 9) - (LEVEL_ORDER[b.task.level] ?? 9) ||
|
|
417
428
|
a.task.created.localeCompare(b.task.created);
|
|
418
429
|
rows.sort(cmp);
|
|
@@ -429,6 +440,25 @@ export function rankTasks(tree, tasks, strategy = "balanced", opts = {}) {
|
|
|
429
440
|
}
|
|
430
441
|
return rows.map(({ task, why, storyTurn, extra }) => ({ task, why: why.map((w) => (w === STORY_WHY ? (storyTurn ? `a story's turn: none in the last ${STORY_EVERY} sessions` : undefined) : w)).filter(Boolean).join(" · "), ...extra }));
|
|
431
442
|
}
|
|
443
|
+
/**
|
|
444
|
+
* queue.sameBook: the book the last session worked in (named by its task, its images on disk) and how many sessions in
|
|
445
|
+
* a row worked in it — undefined when off, when no such book, or after SAME_BOOK_MAX sessions in a row on it.
|
|
446
|
+
*/
|
|
447
|
+
function sameBookTurn(tree, ended, tasksById, withImages, on) {
|
|
448
|
+
if (!on || !ended.length)
|
|
449
|
+
return undefined;
|
|
450
|
+
const booksOf = (s) => {
|
|
451
|
+
const t = tasksById.get(s.task);
|
|
452
|
+
return t ? booksOfTask(tree, t).map((b) => b.id) : [];
|
|
453
|
+
};
|
|
454
|
+
const book = booksOf(ended[0]).find((id) => withImages.has(id));
|
|
455
|
+
if (!book)
|
|
456
|
+
return undefined;
|
|
457
|
+
let inRow = 0;
|
|
458
|
+
while (inRow < ended.length && booksOf(ended[inRow]).includes(book))
|
|
459
|
+
inRow++;
|
|
460
|
+
return inRow < SAME_BOOK_MAX ? { book, inRow } : undefined;
|
|
461
|
+
}
|
|
432
462
|
/** The place of a story's turn among the reasons of a task (filled in once the one story of the turn is known). */
|
|
433
463
|
const STORY_WHY = "\u0000story";
|
|
434
464
|
/**
|
package/dist/core/report.js
CHANGED
|
@@ -24,6 +24,7 @@ import { check } from "./check.js";
|
|
|
24
24
|
import { installation } from "./self.js";
|
|
25
25
|
import * as stromApp from "./stromapp.js";
|
|
26
26
|
import { cutDenied, DENIED_KEPT, DENIED_KEPT_CHARS } from "../runners/runner.js";
|
|
27
|
+
import { runSync } from "./runsync.js";
|
|
27
28
|
// (kept with the runners, which keep a refused command as long: K031 N1)
|
|
28
29
|
export { cutDenied, DENIED_CHARS, DENIED_KEPT, DENIED_KEPT_CHARS } from "../runners/runner.js";
|
|
29
30
|
/** Whom the report is sent to: the one place it is written (spec 070, Milan 2026-11-08). */
|
|
@@ -86,14 +87,9 @@ export function freeBytes(dir) {
|
|
|
86
87
|
}
|
|
87
88
|
/** The version a program says of itself (its first line), within a few seconds; none: undefined. */
|
|
88
89
|
export function versionOf(program, args = ["--version"], env = process.env, timeoutMs = 4000) {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
return r.status === 0 && first ? first.trim().slice(0, 120) : undefined;
|
|
93
|
-
}
|
|
94
|
-
catch {
|
|
95
|
-
return undefined;
|
|
96
|
-
}
|
|
90
|
+
const r = runSync(program, args, { env, timeout: timeoutMs });
|
|
91
|
+
const first = r.stdout.split(/\r?\n/).find((l) => l.trim());
|
|
92
|
+
return r.status === 0 && first ? first.trim().slice(0, 120) : undefined;
|
|
97
93
|
}
|
|
98
94
|
/** The system: its kind and version, the processor, the language, the time zone. */
|
|
99
95
|
export function systemArea(env) {
|
|
@@ -627,7 +623,7 @@ export function launchedFrom(env, tty) {
|
|
|
627
623
|
/** The settings that say nothing of a person (a whitelist: anything else of the settings never goes). */
|
|
628
624
|
const CONFIG_PLAIN = [
|
|
629
625
|
"lang", "mode", "stromVersion", "lastVersion", "lastChannel", "npmChannel", "stories", "runGate", "archivePace", "readApp", "briefBudget", "runMinutes",
|
|
630
|
-
"webPerHost", "readParallel", "queueStrategy", "queueOffLine", "queueOffLineShare", "queueSuggestLines", "queueSuggestTasks", "queueSuggestPersons",
|
|
626
|
+
"webPerHost", "readParallel", "queueStrategy", "queueOffLine", "queueOffLineShare", "queueSuggestLines", "queueSuggestTasks", "queueSuggestPersons", "queueSameBook", "booksMinTasks",
|
|
631
627
|
"connectorsConsent", "browserDownloads", "experimentsHistory", "experimentsHistoryPace", "experimentsHistoryPlaces", "experimentsPlaceHistory",
|
|
632
628
|
"historyKinds", "historyAsked", "stromApp", "links", "shortcut", "appBrowser", "terminal", "updates", "excerptsQuality", "excerptsFor", "excerptsMb",
|
|
633
629
|
"tuneTranscripts", "tuneAuto", "liveIdleMinutes", "stromAppFollow",
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
// A short command of an agent's run to its end at once (`claude auth status`, a program's --version). On Windows an npm
|
|
2
|
+
// launcher (.cmd, .bat) goes through cmd.exe with its line said verbatim — never node's shell option with arguments,
|
|
3
|
+
// which warns (DEP0190) into what a reader shows — and its time limit ends the whole tree it started: spawnSync's own
|
|
4
|
+
// ends cmd.exe alone and leaves the agent's node running (K040, Windows). Anything else: spawnSync as it is (the program
|
|
5
|
+
// is the agent itself).
|
|
6
|
+
import { spawnSync } from "node:child_process";
|
|
7
|
+
/** Quote one argument for cmd.exe (a .cmd/.bat launcher on Windows). */
|
|
8
|
+
export function cmdQuote(arg) {
|
|
9
|
+
if (/^[\w.\-/:=@]+$/u.test(arg))
|
|
10
|
+
return arg;
|
|
11
|
+
return `"${arg.replace(/"/g, '""')}"`;
|
|
12
|
+
}
|
|
13
|
+
/** Is this program a Windows launcher that only cmd.exe starts? */
|
|
14
|
+
export function isLauncher(program, platform = process.platform) {
|
|
15
|
+
return platform === "win32" && /\.(cmd|bat)$/iu.test(program);
|
|
16
|
+
}
|
|
17
|
+
/** How a program is started: a launcher through cmd.exe, its whole line one argument taken verbatim; else itself. */
|
|
18
|
+
export function startOf(program, args, env, platform = process.platform) {
|
|
19
|
+
if (!isLauncher(program, platform))
|
|
20
|
+
return { file: program, args, verbatim: false };
|
|
21
|
+
const line = [cmdQuote(program), ...args.map(cmdQuote)].join(" ");
|
|
22
|
+
return { file: env.ComSpec ?? env.COMSPEC ?? "cmd.exe", args: ["/d", "/s", "/c", `"${line}"`], verbatim: true };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* What a watchdog runs (node -e, CommonJS): the command, its output passed on; at the time limit everything it started
|
|
26
|
+
* ended — Windows: taskkill of the whole tree, elsewhere its own process group — and exit 124.
|
|
27
|
+
*/
|
|
28
|
+
const WATCHDOG = `
|
|
29
|
+
const cp = require("node:child_process");
|
|
30
|
+
const o = JSON.parse(process.argv[1]);
|
|
31
|
+
const win = process.platform === "win32";
|
|
32
|
+
const c = cp.spawn(o.file, o.args, { stdio: ["ignore", "pipe", "ignore"], windowsHide: true, windowsVerbatimArguments: o.verbatim, detached: !win });
|
|
33
|
+
c.stdout.pipe(process.stdout);
|
|
34
|
+
const t = setTimeout(() => {
|
|
35
|
+
if (win) cp.spawnSync("taskkill", ["/pid", String(c.pid), "/T", "/F"], { stdio: "ignore", windowsHide: true });
|
|
36
|
+
else { try { process.kill(-c.pid, "SIGKILL"); } catch { try { c.kill("SIGKILL"); } catch {} } }
|
|
37
|
+
process.exit(124);
|
|
38
|
+
}, o.ms);
|
|
39
|
+
c.on("error", () => { clearTimeout(t); process.exit(127); });
|
|
40
|
+
c.on("close", (code) => { clearTimeout(t); process.exitCode = code === null ? 1 : code; });
|
|
41
|
+
`;
|
|
42
|
+
/** The exit of a watchdog whose command ran out of time. */
|
|
43
|
+
const TIMED_OUT = 124;
|
|
44
|
+
/**
|
|
45
|
+
* Run a program to its end within `timeout` ms. A Windows launcher — or anything with `wholeTree` — under a watchdog
|
|
46
|
+
* that ends all it started at the limit; else spawnSync's own limit. stdin and stderr ignored. Never throws.
|
|
47
|
+
*/
|
|
48
|
+
export function runSync(program, args, o) {
|
|
49
|
+
const start = startOf(program, args, o.env);
|
|
50
|
+
try {
|
|
51
|
+
if (!start.verbatim && !o.wholeTree) {
|
|
52
|
+
const r = spawnSync(start.file, start.args, { env: o.env, encoding: "utf8", timeout: o.timeout, stdio: ["ignore", "pipe", "ignore"], windowsHide: true });
|
|
53
|
+
return { stdout: r.stdout ?? "", status: r.status, timedOut: r.error?.code === "ETIMEDOUT" };
|
|
54
|
+
}
|
|
55
|
+
const r = spawnSync(process.execPath, ["--input-type=commonjs", "-e", WATCHDOG, JSON.stringify({ ...start, ms: o.timeout })], {
|
|
56
|
+
env: o.env,
|
|
57
|
+
encoding: "utf8",
|
|
58
|
+
// the watchdog's own limit: a little after the command's
|
|
59
|
+
timeout: o.timeout + 5_000,
|
|
60
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
61
|
+
windowsHide: true,
|
|
62
|
+
});
|
|
63
|
+
return { stdout: r.stdout ?? "", status: r.status, timedOut: r.status === TIMED_OUT || r.error?.code === "ETIMEDOUT" };
|
|
64
|
+
}
|
|
65
|
+
catch {
|
|
66
|
+
return { stdout: "", status: null, timedOut: false };
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// A participant's note the Strom app sends that is only the beginning of the research's (core/sync.ts cutShort): a
|
|
2
|
+
// tree the app kept since its 3.28.0 sends a longer note cut short still, or the user cut it — strom cannot tell, so it
|
|
3
|
+
// never takes it (nothing guessed) and asks the person instead: one task waiting for them (origin sync:note-shorter,
|
|
4
|
+
// Task.shorterNote) — the shorter note taken, or the research's kept (strom sync note <T…> take|keep: the person's
|
|
5
|
+
// decision, at their terminal; an agent only carries out the person's answer to the task). One task per fact, who and
|
|
6
|
+
// pair of notes: a send of the same file again asks nothing more, nor does one after the person decided it.
|
|
7
|
+
import { create, update } from "./records.js";
|
|
8
|
+
import { phrase } from "./phrases.js";
|
|
9
|
+
import { displayName } from "./people.js";
|
|
10
|
+
import { UsageError } from "./errors.js";
|
|
11
|
+
import { foldText } from "./text.js";
|
|
12
|
+
import { noteLine } from "./sync.js";
|
|
13
|
+
import { truncate } from "../cli/format.js";
|
|
14
|
+
/** The origin of the person's task of a participant's note sent shorter than the research's. */
|
|
15
|
+
export const SHORTER_ORIGIN = "sync:note-shorter";
|
|
16
|
+
const whoKey = (s) => s.person ?? foldText(noteLine(s.name ?? ""));
|
|
17
|
+
const sameAsk = (a, b) => a.event === b.event && a.role === b.role && whoKey(a) === whoKey(b) && a.sent === b.sent && a.whole === b.whole;
|
|
18
|
+
/** Whether the person was asked of this note already (a task of it, waiting or decided; one a sync's undo dropped: no). */
|
|
19
|
+
export function shorterAsked(tree, s) {
|
|
20
|
+
return tree.list("task").some((t) => t.origin === SHORTER_ORIGIN && t.state !== "dropped" && !!t.shorterNote && sameAsk(t.shorterNote, s));
|
|
21
|
+
}
|
|
22
|
+
/** The research's participant the note is of: the role, who, the note as asked. */
|
|
23
|
+
function partAt(parts, s) {
|
|
24
|
+
return parts.findIndex((x) => x.role === s.role && (s.person ? x.person === s.person : !x.person && whoKey(x) === whoKey(s)) && noteLine(x.note ?? "") === s.whole);
|
|
25
|
+
}
|
|
26
|
+
function ownerOfEvent(tree, event) {
|
|
27
|
+
return [...tree.list("person"), ...tree.list("family")].find((o) => !o.retracted && o.events.some((e) => e.id === event && !e.retracted));
|
|
28
|
+
}
|
|
29
|
+
const whoWords = (tree, s) => (s.person ? `${tree.get(s.person) ? displayName(tree.get(s.person)) : s.person}` : (s.name ?? "?"));
|
|
30
|
+
/**
|
|
31
|
+
* The person asked whether the shorter note is taken (inside the tree's lock, a sync writing): a task waiting for
|
|
32
|
+
* them, in the research's language — none when they were asked of it already. `input`: the sync's input (I…).
|
|
33
|
+
*/
|
|
34
|
+
export function askShorterNote(tree, s, input) {
|
|
35
|
+
if (shorterAsked(tree, s))
|
|
36
|
+
return undefined;
|
|
37
|
+
const owner = ownerOfEvent(tree, s.event);
|
|
38
|
+
if (!owner)
|
|
39
|
+
return undefined;
|
|
40
|
+
const lang = tree.lang;
|
|
41
|
+
const quote = (t) => `„${truncate(t, 300)}“`;
|
|
42
|
+
const name = owner.type === "person" ? displayName(owner) : owner.id;
|
|
43
|
+
const who = whoWords(tree, s);
|
|
44
|
+
const id = tree.peekId("T");
|
|
45
|
+
const said = { event: s.event, owner: name, who, task: id, input, sent: quote(s.sent), whole: quote(s.whole) };
|
|
46
|
+
return create(tree, "task", {
|
|
47
|
+
level: "verify",
|
|
48
|
+
priority: 3,
|
|
49
|
+
what: truncate(phrase(lang, "note.shorter.what", said), 200),
|
|
50
|
+
where: [s.event],
|
|
51
|
+
why: truncate(phrase(lang, "note.shorter.why", said), 1000),
|
|
52
|
+
doneWhen: truncate(phrase(lang, "note.shorter.done", said), 500),
|
|
53
|
+
subject: [owner.id, ...(s.person && s.person !== owner.id ? [s.person] : [])],
|
|
54
|
+
state: "waiting",
|
|
55
|
+
waitingOn: phrase(lang, "note.shorter.on", said),
|
|
56
|
+
wait: { kind: "other" },
|
|
57
|
+
shorterNote: s,
|
|
58
|
+
origin: SHORTER_ORIGIN,
|
|
59
|
+
}, (tid) => `+${tid} task: the person says whether the note of ${who} at ${s.event} the Strom app sent shorter than the research's is taken`);
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* The person's decision of a task of a note sent shorter (`take`: the shorter note written as the participant's;
|
|
63
|
+
* `keep`: the research's note stays): the task done either way. Only the person — or an agent carrying out the person's
|
|
64
|
+
* answer to the task (it holds one). The task and whether the note changed.
|
|
65
|
+
*/
|
|
66
|
+
export function decideShorterNote(tree, taskId, take) {
|
|
67
|
+
return tree.withTreeLock(() => {
|
|
68
|
+
const t = tree.get(taskId);
|
|
69
|
+
if (!t || t.type !== "task" || !t.shorterNote)
|
|
70
|
+
throw new UsageError(`${taskId} asks of no note sent shorter`, { code: "shorter.none", params: { task: taskId }, hint: "strom task list --state waiting" });
|
|
71
|
+
if (t.state === "done" || t.state === "dropped")
|
|
72
|
+
throw new UsageError(`${t.id} is decided already (${t.result ?? t.state})`, { code: "shorter.decided", params: { task: t.id } });
|
|
73
|
+
if (!tree.personWrites && !t.answers?.length)
|
|
74
|
+
throw new UsageError(`whether the shorter note is taken is the person's to decide (strom's menu, What waits; the Strom app) — carry out their answer once ${t.id} has one`, { code: "shorter.person", params: { task: t.id } });
|
|
75
|
+
const s = t.shorterNote;
|
|
76
|
+
let changed = false;
|
|
77
|
+
if (take === "take") {
|
|
78
|
+
const owner = ownerOfEvent(tree, s.event);
|
|
79
|
+
const ev = owner?.events.find((e) => e.id === s.event);
|
|
80
|
+
const parts = ev?.participants ?? [];
|
|
81
|
+
const at = partAt(parts, s);
|
|
82
|
+
if (!owner || !ev || at < 0)
|
|
83
|
+
throw new UsageError(`the note of ${whoWords(tree, s)} at ${s.event} changed since ${t.id} asked — nothing taken (keep it: strom sync note ${t.id} keep)`, { code: "shorter.changed", params: { task: t.id, event: s.event } });
|
|
84
|
+
update(tree, owner.id, owner.type, (o) => ({ ...o, events: o.events.map((e) => (e.id === s.event ? { ...e, participants: parts.map((x, i) => (i === at ? { ...x, note: s.sent } : x)) } : e)) }), { op: "event.edit", summary: `${s.event} ${ev.kind} participants: the note of ${whoWords(tree, s)} as the Strom app sent it, shorter (the person's decision, ${t.id})`, reason: `the person took the shorter note (${t.id})` });
|
|
85
|
+
changed = true;
|
|
86
|
+
}
|
|
87
|
+
const task = update(tree, t.id, "task", (x) => {
|
|
88
|
+
const next = { ...x, state: "done", result: phrase(tree.lang, take === "take" ? "note.shorter.taken" : "note.shorter.kept", { event: s.event, who: whoWords(tree, s) }) };
|
|
89
|
+
delete next.waitingOn;
|
|
90
|
+
delete next.wait;
|
|
91
|
+
return next;
|
|
92
|
+
}, { op: "task.done", summary: `${t.id} done: the ${take === "take" ? "shorter note taken" : "research's note kept"} (the person's decision)` });
|
|
93
|
+
return { task, changed };
|
|
94
|
+
});
|
|
95
|
+
}
|