narrarium-engine 0.1.10 → 0.1.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (74) hide show
  1. package/README.md +50 -19
  2. package/dist/autopilot/brief.d.ts +14 -0
  3. package/dist/autopilot/brief.d.ts.map +1 -0
  4. package/dist/autopilot/brief.js +28 -0
  5. package/dist/autopilot/brief.js.map +1 -0
  6. package/dist/autopilot/estimate-texts.d.ts +0 -1
  7. package/dist/autopilot/estimate-texts.d.ts.map +1 -1
  8. package/dist/autopilot/estimate-texts.js +0 -3
  9. package/dist/autopilot/estimate-texts.js.map +1 -1
  10. package/dist/autopilot/estimate.d.ts +3 -5
  11. package/dist/autopilot/estimate.d.ts.map +1 -1
  12. package/dist/autopilot/estimate.js +5 -7
  13. package/dist/autopilot/estimate.js.map +1 -1
  14. package/dist/autopilot/outline-compose.d.ts.map +1 -1
  15. package/dist/autopilot/outline-compose.js +5 -1
  16. package/dist/autopilot/outline-compose.js.map +1 -1
  17. package/dist/autopilot/planner.d.ts +20 -7
  18. package/dist/autopilot/planner.d.ts.map +1 -1
  19. package/dist/autopilot/planner.js +38 -16
  20. package/dist/autopilot/planner.js.map +1 -1
  21. package/dist/autopilot/presets.d.ts +17 -25
  22. package/dist/autopilot/presets.d.ts.map +1 -1
  23. package/dist/autopilot/presets.js +9 -39
  24. package/dist/autopilot/presets.js.map +1 -1
  25. package/dist/autopilot/runner.d.ts +16 -4
  26. package/dist/autopilot/runner.d.ts.map +1 -1
  27. package/dist/autopilot/runner.js +75 -22
  28. package/dist/autopilot/runner.js.map +1 -1
  29. package/dist/autopilot/session.d.ts +53 -6
  30. package/dist/autopilot/session.d.ts.map +1 -1
  31. package/dist/autopilot/session.js +139 -12
  32. package/dist/autopilot/session.js.map +1 -1
  33. package/dist/autopilot/state.d.ts +6 -0
  34. package/dist/autopilot/state.d.ts.map +1 -1
  35. package/dist/autopilot/state.js +26 -13
  36. package/dist/autopilot/state.js.map +1 -1
  37. package/dist/autopilot/tasks.d.ts.map +1 -1
  38. package/dist/autopilot/tasks.js +15 -11
  39. package/dist/autopilot/tasks.js.map +1 -1
  40. package/dist/autopilot/types.d.ts +38 -6
  41. package/dist/autopilot/types.d.ts.map +1 -1
  42. package/dist/autopilot/types.js +5 -2
  43. package/dist/autopilot/types.js.map +1 -1
  44. package/dist/book/outline-brief.d.ts +74 -0
  45. package/dist/book/outline-brief.d.ts.map +1 -0
  46. package/dist/book/outline-brief.js +161 -0
  47. package/dist/book/outline-brief.js.map +1 -0
  48. package/dist/book/outline.d.ts +13 -5
  49. package/dist/book/outline.d.ts.map +1 -1
  50. package/dist/book/outline.js +31 -24
  51. package/dist/book/outline.js.map +1 -1
  52. package/dist/book/paths.d.ts +5 -0
  53. package/dist/book/paths.d.ts.map +1 -1
  54. package/dist/book/paths.js +5 -0
  55. package/dist/book/paths.js.map +1 -1
  56. package/dist/index.d.ts +1 -0
  57. package/dist/index.d.ts.map +1 -1
  58. package/dist/index.js +1 -0
  59. package/dist/index.js.map +1 -1
  60. package/dist/server/client.d.ts +19 -8
  61. package/dist/server/client.d.ts.map +1 -1
  62. package/dist/server/client.js +41 -15
  63. package/dist/server/client.js.map +1 -1
  64. package/dist/server/protocol.d.ts +24 -1
  65. package/dist/server/protocol.d.ts.map +1 -1
  66. package/dist/server/protocol.js +25 -0
  67. package/dist/server/protocol.js.map +1 -1
  68. package/dist/testing/index.d.ts +3 -0
  69. package/dist/testing/index.d.ts.map +1 -1
  70. package/dist/testing/index.js +8 -0
  71. package/dist/testing/index.js.map +1 -1
  72. package/dist/version.d.ts +1 -1
  73. package/dist/version.js +1 -1
  74. package/package.json +1 -1
package/README.md CHANGED
@@ -16,7 +16,7 @@ npm install narrarium-engine
16
16
  |---|---|
17
17
  | Book access | `BookStore` (list/read/commit with compare-and-swap, `readMany`), `BookConflictError`, `loadBookSnapshot` |
18
18
  | Frozen chapters | `frozenChanges`, `freezeChapterChanges`, `markReviewedChanges`, `unfreezeChapterChanges`, `keepChapterFreeze`, `parseChapterFreeze`, `chapterFreezeRecord`, `FrozenChapterError`, `FROZEN_EDITS_MODES`, `FROZEN_ACTIONS`, `settleFrozenChanges`, `frozenQuestion`, `frozenAnswerAction`: see *Frozen chapters* |
19
- | Autopilot | `AutopilotSession`, `AutopilotRun`, `advanceState`, `nextStep`, `applyIntervention`, `summarizeAutopilotState`, `effectivePublish`, `hostDefaultPublish`, `normalizeRunLimits`, `runnerActivity`, `runnerHeartbeatAgeMs`, `AutopilotRuleError`, `classifyAutopilotError`, `AUTOPILOT_ERROR_KINDS`, `AUTOPILOT_RULE_ERROR_CODES`, «Retry later» and «Retry now» (`classifyRetry`, `readLongRetry`, `longRetryProblem`, `LONG_RETRY_MAX_MINUTES`, `LONG_RETRY_MAX_CYCLES`, `session.retryNow()`: see *Retries*) |
19
+ | Autopilot | `AutopilotSession`, `AutopilotRun`, `advanceState`, `nextStep`, `applyIntervention`, `summarizeAutopilotState`, `effectivePublish`, `hostDefaultPublish`, `normalizeRunLimits`, `runnerActivity`, `runnerHeartbeatAgeMs`, `AutopilotRuleError`, `classifyAutopilotError`, `AUTOPILOT_ERROR_KINDS`, `AUTOPILOT_RULE_ERROR_CODES`, «Retry later» and «Retry now» (`classifyRetry`, `readLongRetry`, `longRetryProblem`, `LONG_RETRY_MAX_MINUTES`, `LONG_RETRY_MAX_CYCLES`, `session.retryNow()`: see *Retries*), «Resume after a restart» (`session.stopForShutdown()`, `session.forgetStopCause()`, `session.restartResumeCause()`, `session.holdAfterRestart()`, `withoutStopCause`: see *Quick controls*) |
20
20
  | Director | `askDirector`, `listDirectorOpinions`, `parseDirector`, `serializeDirector`, `directorPrompt` |
21
21
  | Readers | `readerPersonaSystemPrompt`, `mergeReaderPersonas`, `READER_EVALUATION_TOOL`, `chapterReaderText` |
22
22
  | Ghostwriters | `parseGhostwriter`, `ghostwriterPrompt` |
@@ -48,7 +48,7 @@ const session = new AutopilotSession({
48
48
 
49
49
  session.subscribe((event) => console.log(event.type, event));
50
50
  await session.start({
51
- brief: { idea: "A harbor town built on glass hides a lie.", targetChapters: 12 },
51
+ brief: { idea: "A harbor town built on glass hides a lie.", wordsPerScene: 1400 }, // the chapters are the outline's entries
52
52
  options: { pauseAfterPlan: true },
53
53
  });
54
54
  await session.waitForIdle();
@@ -115,13 +115,21 @@ What the web app's quick-command bar uses: pause at the end of the chapter, the
115
115
 
116
116
  The engine applies it, so a host only says *how* to publish: `hooks.afterCommit` is called after every saved step when the way is `"step"`; `hooks.afterChapter` when a chapter is closed and the way is `"chapter"` or `"step"`; neither when it is `"off"`. A host that publishes in every way needs both hooks. The way is read at the end of every step and of every chapter, from the state that step saved. A publish that fails is reported as before (a `sync` event with `syncFailed`, or `publishFailed` for a chapter) and never stops the run. `beforeStep` is not a publish: it is called before every step whatever the way.
117
117
 
118
- **Changing settings during a run.** `session.updateOptions(partial)` saves the options and answers the saved state. While a run is active only `publishEvery` (`null` takes the choice back, so that the host decides again), `pauseAfterEachChapter`, `frozenEdits` (see *Frozen chapters*) and `longRetry` («Retry later», `null` turns it off: see *Retries*) can change (`LIVE_AUTOPILOT_OPTIONS`); any other option throws `AutopilotBusyError`, as `configure` does, and nothing of that request is applied. With no run active any option can change. The change is a compare-and-swap commit, like an intervention: the step in flight is neither failed nor repeated, the run takes the author's value into the state the step saves (`reconcileAuthorChanges`) and reads it at the end of that step, or of the chapter (`longRetry` when a step has failed: a run that waits for it stops when it is turned off, and new minutes or cycles count from the next cycle). A value nobody knows changes nothing, and a request that changes nothing writes nothing.
118
+ **Changing settings during a run.** `session.updateOptions(partial)` saves the options and answers the saved state. While a run is active only `publishEvery` (`null` takes the choice back, so that the host decides again), `pauseAfterEachChapter`, `frozenEdits` (see *Frozen chapters*), `longRetry` («Retry later», `null` turns it off: see *Retries*) and `resumeAfterRestart` («Resume after a restart», below) can change (`LIVE_AUTOPILOT_OPTIONS`); any other option throws `AutopilotBusyError`, as `configure` does, and nothing of that request is applied. With no run active any option can change. The change is a compare-and-swap commit, like an intervention: the step in flight is neither failed nor repeated, the run takes the author's value into the state the step saves (`reconcileAuthorChanges`) and reads it at the end of that step, or of the chapter (`longRetry` when a step has failed: a run that waits for it stops when it is turned off, and new minutes or cycles count from the next cycle). A value nobody knows changes nothing, and a request that changes nothing writes nothing.
119
119
 
120
120
  **Retry now.** `session.retryNow()` ends the wait before the next attempt of a failed step (a quick retry, or a cycle of «Retry later») so that the attempt starts at once: see *Retries*.
121
121
 
122
+ **Resume after a restart.** `options.resumeAfterRestart` («Resume after a restart», «Riprendi da solo dopo un riavvio del server») is `true` or absent: off, the default, also for every book written before it (a value that is not `true` or `false` changes nothing, as for every switch of the options). It is saved with the other options and can change while a run goes on. Only a personal server reads it, when it starts again; the engine gives it what it needs:
123
+
124
+ - `session.stopForShutdown()` is the host's own stop (Ctrl+C, a service stop): it stops the run as `pause("now")` does (a start in flight is stopped as soon as its run exists) and the run ends `paused` with `state.stoppedBy: "server-shutdown"`, the message «In pausa perché il server si è fermato.» (*Paused because the server stopped.*, in the language of the book) and the `run-ended` code `serverShutdown`. A pause the author asked for before it (`now`, or one that waits for the end of the step or of the chapter) stays the author's, and the state says nothing of the server. It answers whether a run was active or starting.
125
+ - `state.stoppedBy` is written only so, only on a `paused` state, and read only so from a file: a missing field is none (null), as in the files of older engines, and any other value is dropped. Any start (a resume, a single step, a start of the host) takes it away when the run saves its start (`withoutStopCause`), and so does a pause of the author with no run active: `session.pause()` then answers `false` and writes nothing, and the host calls `session.forgetStopCause()`, which answers the saved state, or `null` (and writes nothing) when there was nothing to take away.
126
+ - `session.restartResumeCause()` reads, and changes nothing: `"server-shutdown"` for a run paused so, `"interrupted"` for a state that still says `running` with this host's runner (its process ended without pausing it) or with a runner silent for longer than `RUNNER_STALE_MINUTES`, and `null` for anything else (the option off, a pause of the author or of the run itself, a live run of another host, a run active here, no state, a state that cannot be read).
127
+ - `session.start({ afterRestart: true })` is the host's resume after a restart (never taken from a request): the run says so first, right after `run-started`, with the insight `resumedAfterRestart` («Ripreso da solo dopo il riavvio del server.», *Resumed by itself after the server restarted.*, in the language of the book).
128
+ - `session.holdAfterRestart({ times, hours })` leaves such a run to the author when the host will not resume it (it already did so `times` times in the last `hours` hours): the state is `paused`, without `stoppedBy` and without a runner, with a message that says why («Non ripreso dopo il riavvio del server: l'autopilot si è già ripreso da solo 3 volte nelle ultime 24 ore. Riprendilo quando vuoi.», *Not resumed after the server restart: the autopilot already resumed by itself 3 times in the last 24 hours. Resume it when you are ready.*). It writes nothing for a run that is no longer such a run, nor for a book without a state, and answers `null` then.
129
+
122
130
  **What the summary says.** `AutopilotStateSummary`, which the `state` events carry and `snapshot().summary` holds for a client that connects later, has five fields that are never saved: `frozenChanges` (how many chapters have a change that waits for the author, absent when none does: see *Frozen chapters*), `pausePending` (`"after-step"`, `"after-chapter"` or `null`), `limits` (`{ steps?, chapters?, stepsDone, chaptersDone }` of the run in progress, `null` when it has none or is over; `chapters` is the stricter of the run's limit and `chaptersPerRun`), `publish` (`effectivePublish` of the options and the host's default) and `retry` (the retry the run is waiting for, present only while it is, with `longTerm` in a wait of «Retry later»: see *What the interface reads*). A summary made from the state file alone (`summarizeAutopilotState(state)`) has no `frozenChanges`, no `pausePending`, no `limits` and no `retry`: nothing in the file says them, so a client takes them from the events and the snapshot. They change without the state being written, so `updatedAt` does not move: every change of the pause that waits, and every saved step, is a `state` event, and a client keeps the newest event it has seen, whatever its `updatedAt`.
123
131
 
124
- **Message codes.** `run-ended` and `insight` events carry a `code` when a client can say it in its own language: `chapterPause`, `stepLimit` and `chapterLimit` join `takenOver` and the others (`AutopilotMessageCode`). The `message` of the event, and of the saved state, is always in the language of the book. The insights about the outline have codes of their own and say which chapter they are about (`chapterNumber`, and `ghostwriter` for one that does not exist): `outlineGhostwriter`, `outlineChanged`, `outlineRemoved`, `outlineChangedWhileWriting`, `outlineWrittenChanged`, `outlineRemovedWritten`, `outlineWrittenAuto` and `outlineWarnings` (see *Outline (Scaletta)*); so do the insights about the frozen chapters: `frozenMigrated`, `frozenChanged`, `frozenAuto`, `frozenReviewed`, `frozenCleared` and `frozenInvalid` (see *Frozen chapters*). The retries have theirs: `failureRetry` (a quick retry), `longRetryWait` (a wait of «Retry later», with `cycle`, `cycles` and `waitMs`), `retrySkipped` («Retry now» ended a wait, with the `waitMs` that was left), and two that end a run, as the `code` of `run-ended` (and, the first, as an insight with the last `cycle` and `cycles`): `longRetryExhausted` (the cycles are used up) and `longRetryOff` («Retry later» was turned off while the run waited for it). See *Retries*.
132
+ **Message codes.** `run-ended` and `insight` events carry a `code` when a client can say it in its own language: `chapterPause`, `stepLimit` and `chapterLimit` join `takenOver` and the others (`AutopilotMessageCode`). The `message` of the event, and of the saved state, is always in the language of the book. The insights about the outline have codes of their own and say which chapter they are about (`chapterNumber`, and `ghostwriter` for one that does not exist): `outlineGhostwriter`, `outlineChanged`, `outlineRemoved`, `outlineChangedWhileWriting`, `outlineWrittenChanged`, `outlineRemovedWritten`, `outlineWrittenAuto` and `outlineWarnings` (see *Outline (Scaletta)*); so do the insights about the frozen chapters: `frozenMigrated`, `frozenChanged`, `frozenAuto`, `frozenReviewed`, `frozenCleared` and `frozenInvalid` (see *Frozen chapters*). The retries have theirs: `failureRetry` (a quick retry), `longRetryWait` (a wait of «Retry later», with `cycle`, `cycles` and `waitMs`), `retrySkipped` («Retry now» ended a wait, with the `waitMs` that was left), and two that end a run, as the `code` of `run-ended` (and, the first, as an insight with the last `cycle` and `cycles`): `longRetryExhausted` (the cycles are used up) and `longRetryOff` («Retry later» was turned off while the run waited for it). See *Retries*. A restart of the server has two: `serverShutdown` (the `code` of `run-ended` when the server's stop paused the run) and `resumedAfterRestart` (an insight: the server resumed the run by itself). See *Resume after a restart*.
125
133
 
126
134
  ### What the interface reads
127
135
 
@@ -167,7 +175,7 @@ Data the web app's pages used to have to guess (from the text of a step, from th
167
175
 
168
176
  **Frozen chapters.** What the pages read of them (see *Frozen chapters* for what they mean): `summary.frozenChanges` (not saved: how many chapters have a change that waits for the author's decision, as the run found it before its last step or the last `frozenStatus()`; absent when none waits, as `retry` is, until one of them looked, and from a summary made from the state file alone); `options.frozenEdits` (`"ask"`, `"auto"`, `"notify"`); `state.pendingReviews` (the decisions recorded: `{ id, kind, number, action, fingerprint, at, note?, auto?, started? }`, `started` while one is carried out, with `phase` and the chapter as it was `before`); `state.question` of kind `frozen-change` or `outline-change`, with `choices` (`{ id, label }`, the labels in the language of the book), `options` (the same labels) and `frozen` (`{ kind, number, slug, fingerprint, title?, by?, frozenAt?, changed?, others? }`); `QuestionAnswer.choice`; `state.frozenSince` and `state.frozenSeen` (the engine's bookkeeping); `state.review.authorEdit` (the round of review of an author's change); `state.revision.afterChapter`, `onlyChapter` and `source` (a revision that comes from a change: `{ kind, chapterNumber, note?, auto?, before?, after? }`); the snapshot's `ChapterInfo.frozen`, `frozenProblem`, `bodyDigest` and `document`, and `ParagraphInfo.bodyDigest`. New task kind: `freeze` (without the model). New insight codes to say in the language of the interface, each with `chapterNumber` but the first: `frozenMigrated` (the chapters an older engine approved are frozen now), `frozenChanged` (`notify`: a frozen chapter changed), `frozenAuto` (`auto`: a change is reviewed and the book updated from it), `outlineWrittenAuto` (`auto`: a chapter is rewritten to follow its outline), `frozenReviewed` (a decision was carried out, or a change was marked as reviewed), `frozenCleared` (a change is gone: its question, or its decision, is dropped), `frozenInvalid` (a record that cannot be read; a warning). New kinds of question: `frozen-change`, `outline-change`; their choices are the actions, by id: `review-and-update`, `review-only`, `mark-reviewed`, `rewrite-to-outline`, `keep-text`.
169
177
 
170
- **Older and newer engines.** Every new field is read tolerantly (a value that is not valid is dropped, never made up) and an older file reads as it always did. An engine from before these fields reads a file that has them without trouble but does not know them: `normalizeAutopilotState` of that engine drops `finalReview`, `stats.workedMs`, the kind and the detail of `lastError`, and the `rounds` of the chapters, so the first time it writes the state the history is lost (the activities keep their `errorKind` and `errorDetail`, which it does not look at). The worked time then starts again from zero in the engine that knows it, and the rounds start again with the next review. An engine that knows the rounds and the worked time but not what was added after them (the `verdict` of a round, `stats.workedMsSince`, `lastError.activityId` and the `retryAfterMs` of an error detail) drops those four on its first write, and the engine that knows them does not make them up again: a book that goes back and forth between the two keeps its rounds and its time, and loses the verdicts, the moment and the id of the failed step written meanwhile. The frozen chapters are the same story: an engine from before them drops `pendingReviews`, `frozenSince`, `frozenSeen`, `options.frozenEdits`, the `authorEdit` of a review and the `afterChapter`, `onlyChapter` and `source` of a revision, and reads a question about a change as a question of the director with free text (its `choices` and `frozen` dropped); the records in chapter.md stay. The engine that knows them then asks again about what is still changed, and a state without `frozenSince` freezes the chapters the autopilot approved, once, without asking. «Retry later» is the same story: an engine from before it drops `options.longRetry` (and `stats.workedMsPartial`) the first time it writes the state, so the option is off after that; a run of a newer engine that waits for it then stops as if the author had turned it off (`longRetryOff`). An engine that knows «Retry later» but not `lastError.code` drops the code the first time it writes the state: the error stays, and a page that opens after that cannot say what stopped the run (the `run-ended` event still says it to a client that was connected). A client that does not know a new code of an insight (`longRetryWait`, `retrySkipped`, `outlineChangedWhileWriting`, `outlineRemovedWritten`…) shows its `title`, which is always in the language of the book. A conflict with GitHub is the same: an engine from before it drops `errorDetail.githubConflicts` the first time it writes the state (the kind stays `conflict`), and a personal server from before it stops the run with an error of no kind whose words send the author to the web app, answers a sync with `409 sync_failed`, and has no list to resolve it (the client refuses it with `feature_unavailable`).
178
+ **Older and newer engines.** Every new field is read tolerantly (a value that is not valid is dropped, never made up) and an older file reads as it always did. An engine from before these fields reads a file that has them without trouble but does not know them: `normalizeAutopilotState` of that engine drops `finalReview`, `stats.workedMs`, the kind and the detail of `lastError`, and the `rounds` of the chapters, so the first time it writes the state the history is lost (the activities keep their `errorKind` and `errorDetail`, which it does not look at). The worked time then starts again from zero in the engine that knows it, and the rounds start again with the next review. An engine that knows the rounds and the worked time but not what was added after them (the `verdict` of a round, `stats.workedMsSince`, `lastError.activityId` and the `retryAfterMs` of an error detail) drops those four on its first write, and the engine that knows them does not make them up again: a book that goes back and forth between the two keeps its rounds and its time, and loses the verdicts, the moment and the id of the failed step written meanwhile. The frozen chapters are the same story: an engine from before them drops `pendingReviews`, `frozenSince`, `frozenSeen`, `options.frozenEdits`, the `authorEdit` of a review and the `afterChapter`, `onlyChapter` and `source` of a revision, and reads a question about a change as a question of the director with free text (its `choices` and `frozen` dropped); the records in chapter.md stay. The engine that knows them then asks again about what is still changed, and a state without `frozenSince` freezes the chapters the autopilot approved, once, without asking. «Retry later» is the same story: an engine from before it drops `options.longRetry` (and `stats.workedMsPartial`) the first time it writes the state, so the option is off after that; a run of a newer engine that waits for it then stops as if the author had turned it off (`longRetryOff`). An engine that knows «Retry later» but not `lastError.code` drops the code the first time it writes the state: the error stays, and a page that opens after that cannot say what stopped the run (the `run-ended` event still says it to a client that was connected). A client that does not know a new code of an insight (`longRetryWait`, `retrySkipped`, `outlineChangedWhileWriting`, `outlineRemovedWritten`…) shows its `title`, which is always in the language of the book. «Resume after a restart» is the same story: an engine from before it drops `options.resumeAfterRestart` and `stoppedBy` the first time it writes the state, so the option is off after that and a run the server paused when it stopped reads as paused by the author: nothing resumes it by itself. A conflict with GitHub is the same: an engine from before it drops `errorDetail.githubConflicts` the first time it writes the state (the kind stays `conflict`), and a personal server from before it stops the run with an error of no kind whose words send the author to the web app, answers a sync with `409 sync_failed`, and has no list to resolve it (the client refuses it with `feature_unavailable`).
171
179
 
172
180
  ### Long books
173
181
 
@@ -203,13 +211,14 @@ A profile with warnings is not what the author wrote, so the engine never goes o
203
211
 
204
212
  ## Outline (Scaletta)
205
213
 
206
- The outline is the author's chapter-by-chapter trace of the book: a rough description of the book and, for every chapter, a hypothetical title, what happens in it and, when it is not the book's, the ghostwriter that writes it. It is a main part of the book, useful without the autopilot too, kept in files of the book, and the autopilot follows it as binding. It is not `plot.md`, which the autopilot generates from the chapters it closes.
214
+ The outline is the author's chapter-by-chapter trace of the book: the idea, promise or pitch of the book (its description) and, for every chapter, a hypothetical title, what happens in it and, when it is not the book's, the ghostwriter that writes it. It is a main part of the book, useful without the autopilot too, kept in files of the book, and the autopilot follows it as binding. It is not `plot.md`, which the autopilot generates from the chapters it closes.
207
215
 
208
216
  ### The files
209
217
 
210
218
  | Path | Frontmatter | Body |
211
219
  |---|---|---|
212
- | `outline/book.md` | `type: outline`, `id: outline:book`, `title?` (a working title: the book's own stays in `book.md`), `origin?`, `digest?` | The rough description of the book, free Markdown. |
220
+ | `outline/book.md` | `type: outline`, `id: outline:book`, `title?` (a working title: the book's own stays in `book.md`), `origin?`, `digest?` | The idea, promise or pitch of the book (the description), free Markdown, at most 1 000 000 characters. It is the brief's idea too: stored here and nowhere else. |
221
+ | `outline/_brief.md` | `type: outline-brief`, `id: outline:brief`, `genre?`, `audience?`, `wordsPerScene` (a whole number from 200 to 8 000; 1 400 when absent) | The synopsis, free Markdown. An `idea` key found here is ignored and never written. It is the brief of the autopilot, not an entry: see *The brief*. |
213
222
  | `outline/chapters/<NNN>.md` | `type: outline-chapter`, `id: outline-chapter:<NNN>`, `number`, `title?` (the hypothetical title), `ghostwriter?` (the slug of `ghostwriters/<slug>.md`; absent: the book's), `origin: author \| autopilot`, `digest?` | What happens in the chapter, plain text. |
214
223
 
215
224
  One file per chapter: the outline has no maximum, and no file grows with the book. `<NNN>` has the zero-padding of the chapter folders (`formatOrdinal`): `outlineChapterPath(7)` is `outline/chapters/007.md`, `outlineChapterPath(1500)` is `outline/chapters/1500.md`, and `parseOutlineChapterPath(path)` reads the number back. The number of an entry is the one of its file's name; a frontmatter that says another is a warning, and the name wins. The keys the format does not know are kept whenever the engine rewrites a file. The core (`narrarium`) has the same paths (`OUTLINE_BOOK_FILE`, `OUTLINE_CHAPTERS_DIRECTORY`, `outlineChapterPath`, `parseOutlineChapterPath`), validates the files with `outlineBookSchema` and `outlineChapterSchema` (passthrough), searches them and renames references in them with the rest of the book (`CONTENT_GLOB`), and its doctor warns, never errs, about a number that is not the file's and a ghostwriter that does not exist.
@@ -264,13 +273,33 @@ An entry that cannot be read changes nothing until the author corrects it, and n
264
273
  ### What the autopilot does with it
265
274
 
266
275
  - **What binds.** The outline binds through the entries of the author (every entry but the autopilot's intact ones) and the description of the author. A book whose outline has nothing of the author, none at all or only the autopilot's intact entries, is asked exactly what it was asked before the outline existed.
267
- - **As many chapters as it has.** The book is planned to `effectiveTargetChapters(state, { lastChapter })`: the brief's `targetChapters`, or the last chapter an entry of the author asks for when it is further. An entry the author adds after the last chapter of a finished book extends it, as raising `targetChapters` does.
276
+ - **As many chapters as it has.** The book is `bookChapters(outline)` long: the number of its last chapter entry (the entries are the chapters; a number between two entries that has none is planned freely). An entry the author adds after the last chapter of a finished book extends it. With no chapter entry and no approved plan the run stops with «The outline has no chapters: write the chapters in the Scaletta, then resume.»
268
277
  - **The plan follows it.** The request of every batch of the plan carries the description of the book (at most 3000 characters), the entries of the chapters it plans (whole, as far as their share of 24 000 characters allows) and, condensed like every list of chapters, the entries of the chapters not planned yet, with the rule: the same chapters, in the same order, with the same hypothetical titles (the model refines a title only where the entry has none: the engine keeps the entry's own) and the same events; enrich, never change. `brief.synopsis` stays the fallback: alone it binds as it always did; next to an outline it applies where the outline says nothing, and the outline wins. The concept is told that the outline binds it, and the director is told not to ask the plan to change it.
269
278
  - **The ghostwriter of a chapter.** A chapter takes the ghostwriter of its entry (`PlannedChapter.ghostwriter`) and the `chapter.md` the plan creates says it, when it is not the book's: the chain scene, chapter, book is the one it always was. An entry that names a ghostwriter that does not exist is said (`outlineGhostwriter`, with `chapterNumber` and `ghostwriter`), and the book's writes the chapter; when the author creates it before the chapter starts, the chapter takes it.
270
279
  - **The plan fills it.** After every plan, and every revision of it, the plan writes, in the same commit, the entries of the chapters it planned that have none: the title, and as text the summary of the plan followed by its key events as a list, with `origin: autopilot` and the `digest` of what it wrote; and `outline/book.md` when it is missing, with the logline of the concept (or the brief's idea). The chapters the author wrote get an entry only when they have none, with their summary. An entry of the author is never touched; an intact one of the autopilot follows the plan when the director has it revised. `options.fillOutline: false` writes nothing. Every chapter keeps the digest of its entry (`outlineDigest`).
271
280
  - **The author changes it.** Before the scenes of a chapter with nothing written are planned, its entry is compared with `outlineDigest`. An entry the author changed (or wrote for a chapter that had none) has the chapter planned again (`replan`: its title, summary, purpose, events and ghostwriter follow the new entry, its scenes are planned again), with the insight `outlineChanged` ("You changed the outline of chapter 7: I am planning it again"), and no other chapter is touched. An entry the author deleted takes its chapter out of the plan, and out of the book when its folder is empty (`outlineRemoved`): the following chapters keep their numbers, and the chapter counts in `plan.removedChapters` so that the book is not extended to replace it. Deleting the whole `outline/` takes no chapter out. An entry that cannot be read changes nothing until it is corrected (`outlineWarnings`). The entry of a chapter already closed that the author changed is decided like a change of a frozen chapter (`options.frozenEdits`: asked by default, with the choices `rewrite-to-outline`, `keep-text` and `mark-reviewed`; see *Frozen chapters*); one of a chapter still being written is said once a run (`outlineChangedWhileWriting`), and decided once the chapter is closed; one that was deleted is said once a run (`outlineRemovedWritten`) and the chapter stays in the book.
272
281
  - **What it costs.** The snapshot knows the files of the outline and their hashes from the list of the book (`snapshot.outline`, an `OutlineIndex`), without reading them; `OutlineReader` reads an entry only when a step needs it, through a cache of the run keyed by path and hash.
273
282
 
283
+ ### The brief (`outline/_brief.md`)
284
+
285
+ The brief the autopilot starts from is kept in two files of the Scaletta, and each text has one home. The **idea** (the idea, promise or pitch of the book) is the description of the book: the body of `outline/book.md`, stored there and nowhere else. `outline/_brief.md` keeps `genre`, `audience`, `wordsPerScene` and the **synopsis** (its body). Two functions compose and split them:
286
+
287
+ - `readOutlineBrief(store, sources?)` → `{ brief: { idea, genre, audience, wordsPerScene, synopsis }, hash?, unreadable?, bookUnreadable?, frontmatter }`. `brief.idea` is the body of `outline/book.md`, or `""` when there is none or the autopilot wrote it (a logline of its own is not the author's idea). `hash` is the hash of `_brief.md` (absent when the file does not exist). `sources` says what is known already (`book`: the description already read, `null` for none; `brief: false`: the brief file is known not to exist), so that a host reads each file once.
288
+ - `writeOutlineBrief(store, fields, message?)` → `OutlineBrief` (the brief as saved). `fields` is any part of `{ idea, genre, audience, wordsPerScene, synopsis }`; the rest is kept. The idea goes to `outline/book.md` through the outline's own builder (`serializeOutlineBook`: the working title and the other keys of the file are kept; the author is the writer), the fields to `_brief.md`, in ONE commit, compare-and-swap on both files (a change made meanwhile is merged, never overwritten; five attempts). A file whose frontmatter cannot be read is never written over. `outlineBriefChanges(store, fields)` → `{ changes, brief }` is the same write, not committed: the start uses it.
289
+ - `parseOutlineBrief(content, hash?)` and `serializeOutlineBrief(fields, frontmatter?)` are the file of `_brief.md` alone: `OutlineBriefFields` is `{ genre, audience, wordsPerScene, synopsis }`, with no idea.
290
+
291
+ **The limits.** The idea is the description of the book, and it is never cut: an idea of more than `OUTLINE_BOOK_MAX_CHARS` (1 000 000 characters) is refused with `OutlineTextLimitError` (`code: "text_too_long"`, the length and the limit in the message) and nothing is written. The server answers a configure or start that carries it with 413 `text_too_long`; the MCP `edit_outline` schema refuses a `book` body over 400 000 characters (its text limit) before the engine is asked. A description over the limit that a file already holds is read whole, with a warning, and a title-only edit leaves it as it is. Chapter entries keep their own limit (`OUTLINE_ENTRY_MAX_CHARS`, 20 000, cut with a warning as before).
292
+
293
+ **Legacy.** A state saved with a brief idea, in a book whose `outline/book.md` has no author's description, gets that idea written into `book.md` once, in the start commit (with the state, in the same commit). A description the author wrote is never overwritten. The fields of a state move to `_brief.md` only when that file does not exist yet.
294
+
295
+ - **The name starts with an underscore, and it is no entry.** `OUTLINE_BRIEF_FILE` is `outline/_brief.md`. `outlineIndex` and `parseOutline` never read it as a chapter, so it has no number, is never counted, and is never a warning. `write_file` refuses the whole `outline/` folder, so the brief changes only through the brief's own routes; `edit_outline` writes only the chapter entries and `outline/book.md` (the description, which is also the idea), so it can neither delete, renumber nor move `_brief.md`.
296
+ - **The brief has no number of chapters.** The chapters are the chapter entries of the Scaletta: `bookChapters(outline)` is the number of the last entry (its number; the entries are the chapters). `targetChapters` and `scenesPerChapter` are not read any more.
297
+ - **The scenes are the planner's.** `scenesForChapter(text)` gives a chapter 2 scenes when its outline entry is up to 40 words, 3 up to 100 words, and 4 above (`SCENES_PER_CHAPTER` is 2 to 4). The text is the entry's body; a chapter without an entry is read from its summary, goal and key events. `wordsPerScene` is the target of every scene.
298
+ - **The run reads it at every start and configuration.** `AutopilotSession.start({ brief })` and `configure({ brief })` save a brief sent to the file first; the run then reads the file (`readBrief`). `state.brief` is the snapshot the run uses, and it is refreshed when the run starts or the author configures it. A book whose brief is only in its state (saved before the brief had a file) gets the file in the start commit, once.
299
+ - **No chapter entries, no run.** With no chapter entry and no approved plan, the planner stops: «The outline has no chapters: write the chapters in the Scaletta, then resume.» A plan that is already approved keeps going to the end of its own chapters.
300
+ - **Legacy states.** A state saved with `targetChapters` and `scenesPerChapter` in its brief still loads and runs: the two counts are not read. A plan of N chapters runs to the end of ITS plan. A completed book is not extended unless the author adds chapter entries to the Scaletta: the highest planned chapter number is compared with the last chapter entry, never the number of chapters planned (a book may go on from chapter 1 200, and no chapter past its last entry is ever planned).
301
+ - **Presets.** The brief has none: `autopilotPresetSkeleton(id)` gives the chapter entries a new book's outline starts with (see *Presets*).
302
+
274
303
  ## Frozen chapters
275
304
 
276
305
  A chapter is **frozen** when the autopilot's director approves it, or when the author freezes it by hand: its `chapter.md` holds a record of the chapter as it was. A change of its text after that is never ignored: before every step the autopilot notices it and, unless the author chose otherwise, stops and asks what to do (as BookWriter's "Review from a saved change": nothing starts by itself).
@@ -381,10 +410,10 @@ const estimate = estimateAutopilotRun({
381
410
 
382
411
  | Field | Meaning |
383
412
  |---|---|
384
- | `brief`, `options` | Read as the engine reads them (`normalizeBrief`, `normalizeOptions`): what is missing is the default, a number past the limits is the limit, anything that is not a value is ignored. Only `targetChapters`, `scenesPerChapter`, `wordsPerScene` (and the idea and the synopsis, for their words) and `readers`, `maxReaders`, `readersOnPlan`, `specialists` change the numbers. `pauseAfterPlan`, `pauseAfterEachChapter`, `chaptersPerRun`, the budgets, `fillOutline`, `syncAfterChapter` and `publishEvery` change nothing the models are asked: they are accepted and ignored. |
413
+ | `brief` (`outline/_brief.md`, see *The brief*), `options` | Read as the engine reads them (`normalizeBrief`, `normalizeOptions`): what is missing is the default, a number past the limits is the limit, anything that is not a value is ignored. Only `wordsPerScene` (and the idea and the synopsis, for their words), the chapters of `outline` and the `scenesPerChapter` hint (2 to 4 for the planner; 3 when it is not told) and `readers`, `maxReaders`, `readersOnPlan`, `specialists` change the numbers. `pauseAfterPlan`, `pauseAfterEachChapter`, `chaptersPerRun`, the budgets, `fillOutline`, `syncAfterChapter` and `publishEvery` change nothing the models are asked: they are accepted and ignored. |
385
414
  | `maxReviewRounds` | The most rounds of review a chapter gets, 1 to 3 (2 when it says nothing), as in the director's profile. |
386
415
  | `models` | `{ [capability]: { model, maxInputTokens?, maxOutputTokens?, pricing?, tokensPerSecond?, supportsReasoning?, provider?, underlyingModel? } \| null }` for the six capabilities the autopilot uses: `autopilot`, `director`, `reader-evaluation`, `reader-evaluation-summary`, `review`, `simple-tasks` (`ESTIMATE_CAPABILITIES`). `estimateModelsFromConfig(config, speeds?)` builds it from an `AiRuntimeConfig` with the first candidate of `resolveAiCandidates`, and copies no key and no address. |
387
- | `outline` | `{ entries, lastChapter, words }` of the author's entries. When the outline asks for more chapters than the brief, the book has the outline's (the same rule as `effectiveTargetChapters`) and the estimate says so (`outlineLongerThanBrief`). |
416
+ | `outline` | `{ entries, lastChapter, words }` of the author's entries: the chapters of the book are the outline's (`bookChapters`), the chapters already planned when it has none (`progress.planned`). |
388
417
  | `progress` | `{ chaptersDone, planned, conceptDone, finalDone, withoutSummary, withoutSummaryWords }`: a book that is started counts only the rest. `estimateProgressFromState(state)` reads the first five from the state of the autopilot; for a book the autopilot has not started, `estimateProgressFromChapters(snapshot.chapters)` reads `chaptersDone` and `withoutSummary` from the chapters that have prose. `conceptDone` is, when it is not said, whether there is a chapter or a plan; a book whose story design the author wrote (`isThinDocument(body)` is false) has no concept step either, and the host says so. A chapter written halfway counts as whole. |
389
418
  | `scenario` | `{ rounds, repairs, planRevisions }`, each a number or `{ min, max }`: what the reviews of the run will be, when the host knows. See *The interval*. |
390
419
  | `context` | Sizes in words that the host has measured (`countWords` of the files): `designWords`, `worldWords`, `ghostwriterWords`, `directorWords` (the whole profile), `canonWords` (the manifest of the canon; `0` for a book with no canon), `secretsWords`, `rulesWords`, `notesWords` (the director's standing notes now), `styleWords` (the evaluation style as a chapter's review carries it, criteria and method: the review of the plan carries about half). Each defaults to `ESTIMATE_TYPICAL`. `estimateContextFromState(state)` gives the rules of the author and, once the plan is approved, the notes of the director. |
@@ -408,7 +437,7 @@ The estimate is an interval because the reviews are the model's: how many rounds
408
437
  | | rounds `r` | scenes repaired in a chapter `p` | revisions of the plan `v` |
409
438
  |---|---|---|---|
410
439
  | `min` | 1 | 0 | 0 |
411
- | `max` | the director's `maxReviewRounds` | `r × scenesPerChapter` | 2 (the third review of the plan is an approval) |
440
+ | `max` | the director's `maxReviewRounds` | `r × scenes` (the scenes of a chapter: the planner's, 2 to 4, see *The brief*) | 2 (the third review of the plan is an approval) |
412
441
 
413
442
  `scenario` pins any of them; when only some are given the others keep their end (`repairs` goes from `rounds.min − 1` to `rounds.max × scenes`), and the rounds are clamped to 1 and the director's limit. A scenario that pins all three makes `min` and `max` the same number. The ends are bounds, not a "typical" run, and there is no third figure.
414
443
 
@@ -469,7 +498,6 @@ A reply is the words of the schema or of the scene at `tokensPerWord(language)`
469
498
  | `noPrice` | warning | `capability`, `model` | The model has no price: the cost is `null`. |
470
499
  | `noSpeed` | info | `capability`, `model` | The model has no speed: the minutes are `null`. |
471
500
  | `reasoningModel` | info | `capability`, `model` | The model reasons (`supportsReasoning`, or by its name as the router knows it): its reasoning tokens are not counted. |
472
- | `outlineLongerThanBrief` | info | `briefChapters`, `outlineChapters` | The outline asks for more chapters than the brief: the book has the outline's. |
473
501
 
474
502
  ### What it assumes, and what it leaves out
475
503
 
@@ -504,15 +532,15 @@ What the runs show (`ESTIMATE_REPORT=1 node --test test/estimate-run.test.mjs` p
504
532
 
505
533
  ### Presets
506
534
 
507
- `AUTOPILOT_PRESETS` are the three books the interface offers first, from the shortest to the longest. Each has an `id`, the three numbers of the brief, the four options that change the cost and the rounds of the review: its names and descriptions are the interface's. They are frozen.
535
+ `AUTOPILOT_PRESETS` are the three starting points of a NEW book, from the shortest to the longest. They are not an autopilot setting: once the book exists its outline and its brief say the rest. `autopilotPresetSkeleton(id)` returns the skeleton of one: `chapters` (the chapter entries the new book's outline is created with), `wordsPerScene`, the review options (`readers`, `maxReaders`, `readersOnPlan`, `specialists`) and `maxReviewRounds`. It is `undefined` for any other id, the custom book included. The skeleton is frozen.
508
536
 
509
- | `id` | Chapters × scenes × words | Words | Readers | Plan readers | Specialists | Rounds |
537
+ | `id` | Chapters | Words per scene | Readers | Plan readers | Specialists | Rounds |
510
538
  |---|---|---|---|---|---|---|
511
- | `story` | 4 × 2 × 900 | 7 200 | 3 | no | yes | 2 |
512
- | `novella` | 12 × 3 × 1 400 | 50 400 | 5 | yes | yes | 2 |
513
- | `novel-draft` | 24 × 3 × 1 500 | 108 000 | 3 | yes | yes | 1 |
539
+ | `story` | 4 | 900 | 3 | no | yes | 2 |
540
+ | `novella` | 12 | 1 400 | 5 | yes | yes | 2 |
541
+ | `novel-draft` | 24 | 1 500 | 3 | yes | yes | 1 |
514
542
 
515
- `novella` is what a new book starts with (`DEFAULT_BRIEF`, `DEFAULT_OPTIONS`). `matchAutopilotPreset({ brief, options, maxReviewRounds? })` answers the `id` of the preset the values are, or `null`: what the interface calls "custom". The values are compared as the engine takes them (`normalizeBrief`, `normalizeOptions`; the rounds as a profile does, a whole number from 1 to 3), and only the values that change the cost are compared: the pauses, the budgets, the outline and the idea do not make a book custom. The rounds are compared only when they are given, because they are not a field of the brief or of the options. `autopilotPreset(id)` is the preset of an id, and `AUTOPILOT_PRESET_IDS` their ids in order. A form fills its fields from a preset (`brief`, `options` and the director's `maxReviewRounds`) and shows the matching preset again after every change.
543
+ `novella` is what a new book starts with (`DEFAULT_BRIEF`, `DEFAULT_OPTIONS`). The presets have no publish option: where a book is published is the author's choice, as it always was.
516
544
 
517
545
  ### Measured speed
518
546
 
@@ -834,7 +862,7 @@ A skipped file is not recorded as synced (a file that was never synced stays out
834
862
  |---|---|---|
835
863
  | `pauseAutopilot(bookId, mode)` | `POST /api/v1/books/:id/autopilot/pause` with `{ "mode": "now" \| "after-step" \| "after-chapter" \| "cancel" }`. A body without `mode` is `after-step`, as it always was. | `200` the snapshot. `cancel` with nothing waiting, and any mode with nothing running, are `200` too: the summary's `pausePending` says what is waiting now. `400 invalid_request` for a `mode` that is none of the four, or a body that is not a JSON object. |
836
864
  | `startAutopilot(bookId, input)` | `POST /api/v1/books/:id/autopilot/start` with the body it always had (`brief`, `options`, `force`) and `limits?: { "steps"?: number, "chapters"?: number }`. | `200` the snapshot. `400 invalid_request` when `limits` is present and is not a JSON object. The server hands the numbers to the engine as they are (a value that is not a whole number above zero is no limit) and does not save them. The other answers are as before: `409 busy`, `412 ai_not_configured`, `429 too_many_runs`, `503 maintenance`. |
837
- | `updateAutopilotOptions(bookId, input)`, also `updateOptions` | `PUT /api/v1/books/:id/autopilot/options` with `{ "publishEvery"?: "off" \| "chapter" \| "step" \| null, "pauseAfterEachChapter"?: boolean, "frozenEdits"?: "ask" \| "auto" \| "notify", "longRetry"?: { "everyMinutes", "cycles" } \| null }`: at least one, and nothing else (`frozenEdits` from a server that announces `autopilot-frozen`, `longRetry` from one that announces `autopilot-retry`: see *Retry later and Retry now* below). `null` takes the choice back, so that the server's default decides again (for `longRetry`, it turns it off). | `200` the snapshot, of the state that was saved (as `configure` answers), also while the autopilot runs: the step in flight is not repeated, and the run reads the new value at the end of the step, or of the chapter. `400 invalid_request` for a body that is not a JSON object, has none of the keys or has another key, or a value of the wrong type (`publishEvery` that is not one of the four, `pauseAfterEachChapter` that is not a boolean, a `longRetry` that is not a policy: the message says why). `409 conflict` when the state file kept changing under the write (try again) and `409 state_corrupt` when it cannot be read; `503 maintenance` while the server is about to restart. |
865
+ | `updateAutopilotOptions(bookId, input)`, also `updateOptions` | `PUT /api/v1/books/:id/autopilot/options` with `{ "publishEvery"?: "off" \| "chapter" \| "step" \| null, "pauseAfterEachChapter"?: boolean, "frozenEdits"?: "ask" \| "auto" \| "notify", "longRetry"?: { "everyMinutes", "cycles" } \| null, "resumeAfterRestart"?: boolean }`: at least one, and nothing else (`frozenEdits` from a server that announces `autopilot-frozen`, `longRetry` from one that announces `autopilot-retry`: see *Retry later and Retry now* below, `resumeAfterRestart` from one that announces `autopilot-auto-resume`: see *Resume after a restart* below). `null` takes the choice back, so that the server's default decides again (for `longRetry`, it turns it off). | `200` the snapshot, of the state that was saved (as `configure` answers), also while the autopilot runs: the step in flight is not repeated, and the run reads the new value at the end of the step, or of the chapter. `400 invalid_request` for a body that is not a JSON object, has none of the keys or has another key, or a value of the wrong type (`publishEvery` that is not one of the four, `pauseAfterEachChapter` or `resumeAfterRestart` that is not a boolean, a `longRetry` that is not a policy: the message says why). `409 conflict` when the state file kept changing under the write (try again) and `409 state_corrupt` when it cannot be read; `503 maintenance` while the server is about to restart. |
838
866
 
839
867
  The server answers with the engine's `session.pause`, `session.cancelPause`, `session.start({ …, limits })` and `session.updateOptions`, and takes `defaultPublish: "step"` as its default (which is what it does when it passes none). It can validate the bodies against the lists the engine exports for that: `PAUSE_AUTOPILOT_MODES`, `AUTOPILOT_PUBLISH_MODES` and `LIVE_AUTOPILOT_OPTIONS`. For a GitHub book its `afterCommit` hook pushes (what the engine calls after every step in `step` mode) and its `afterChapter` hook pushes too (what it calls when a chapter is closed in `chapter` and `step` mode): without that one, `chapter` would publish nothing.
840
868
 
@@ -865,6 +893,9 @@ A skipped file is not recorded as synced (a file that was never synced stays out
865
893
  | `configureAutopilot(bookId, { options: { longRetry } })`, `startAutopilot(bookId, { options: { longRetry } })` | As always: the options go to the engine as they are. | As always. The engine reads them as it reads every option there: a value that is not a policy changes nothing. |
866
894
  | `retryNow(bookId)` | `POST /api/v1/books/:id/autopilot/retry-now`, no body (or `{}`). | `200` the snapshot with `skipped` (`RetryNowResponse`): `true` when the run was waiting and the attempt starts now (the snapshot's `summary.retry` is gone), `false` when there was nothing to skip (no run, or a run that is not waiting: nothing happens). `400 invalid_request` for any other body; `503 maintenance` while the server is about to restart (unlike a pause, which is never refused: «Retry now» sets the run going again). |
867
895
 
896
+ - **The length of the book comes from its Scaletta.** A server that takes the chapters from the outline and the brief from `outline/_brief.md` announces `SERVER_FEATURE_AUTOPILOT_OUTLINE_BRIEF` (`"autopilot-outline-brief"`), and `serverHasOutlineBrief(infoOrFeatures)` reads it (never throws). An older server plans the default number of chapters and ignores the Scaletta, so `startAutopilot` and `configureAutopilot` refuse it before sending anything: a `ServerRequestError` with status 501 and code `feature_unavailable`, which says to update the server. The client asks the server's `info` once for both checks.
897
+ - **Resume after a restart.** A server that resumes a run by itself when it starts again announces `SERVER_FEATURE_AUTOPILOT_AUTO_RESUME` (`"autopilot-auto-resume"`), and `serverSupportsAutopilotAutoResume(infoOrFeatures)` reads it (it takes the info or the list of its features; never throws). Such a server takes `options.resumeAfterRestart` (`true` or `false`) in the options route, `configure` and `start`; it pauses every run with `session.stopForShutdown()` when it stops, and when it starts again it resumes, one book at a time, the runs that `session.restartResumeCause()` names (with `session.start({ afterRestart: true })`, through every check a start of the author has: the AI configuration, the number of runs, the owner's switch and caps), at most three times a day per book (see the server's README). **The client never sends `resumeAfterRestart` to a server that does not announce the feature** (`false` included), for the same reason as `longRetry`: `updateAutopilotOptions`, `configureAutopilot` and `startAutopilot` ask the server's `info()` first and refuse with `501 feature_unavailable` before anything is sent. A request without the setting asks nothing more.
898
+
868
899
  - **Conflicts with GitHub.** When the server's commits and GitHub's changed the same files, the server's run stops with a `conflict` (`errorDetail.githubConflicts`: how many files), its sync answers `409 github_conflict` (with `conflicts` in the `details` of the `ServerRequestError`), and `lastSync.conflicts` says it in the summary of the book. The author chooses which version of each file to keep, the server's or GitHub's, through two calls of a server that announces `SERVER_FEATURE_GITHUB_CONFLICTS` (`"github-conflicts"`), which `serverSupportsGithubConflicts(infoOrFeatures)` reads (never throws). **The client refuses a server without the feature before sending anything**: it asks `info()` once (and again until the server says yes, so that an update is noticed) and throws a `ServerRequestError` with status `501` and code `feature_unavailable`, whose message says to update the server. A refusal of the server keeps what it said with it in `ServerRequestError.details` (the fields of the answer other than `code` and `message`). Every call also answers `401 unauthorized`, `403 scope`, `404 book_not_found` and `409 no_remote` (a book that is not on GitHub). The rules (which version a deleted file follows, the autopilot's own files that are never asked about, the names the server does not write, the push that GitHub refuses) are in the server's README, *Conflicts with GitHub*.
869
900
 
870
901
  | Client method | Request | Answer |
@@ -0,0 +1,14 @@
1
+ import type { BookFileChange, BookStore } from "../book/store.js";
2
+ import type { AutopilotBrief, AutopilotState } from "./types.js";
3
+ /**
4
+ * The brief a run starts from or a configuration reads: the idea from the description of the book (`outline/book.md`), the fields from
5
+ * `outline/_brief.md`. A book saved before the brief had these files moves what its state held into them, once: the idea when the author has
6
+ * written no description (a description that the author wrote is never overwritten), and the fields when `_brief.md` does not exist. The
7
+ * returned `changes` make that move, and the caller commits them with its own commit. A file whose frontmatter cannot be read stops the
8
+ * reading: the brief is never taken as the defaults over an author's text.
9
+ */
10
+ export declare function readBrief(store: BookStore, state?: Pick<AutopilotState, "brief"> | null): Promise<{
11
+ brief: AutopilotBrief;
12
+ changes: BookFileChange[];
13
+ }>;
14
+ //# sourceMappingURL=brief.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brief.d.ts","sourceRoot":"","sources":["../../src/autopilot/brief.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElE,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjE;;;;;;GAMG;AACH,wBAAsB,SAAS,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,OAAO,CAAC,GAAG,IAAI,GAAG,OAAO,CAAC;IAAE,KAAK,EAAE,cAAc,CAAC;IAAC,OAAO,EAAE,cAAc,EAAE,CAAA;CAAE,CAAC,CAY7J"}
@@ -0,0 +1,28 @@
1
+ import { outlineBriefChanges, readOutlineBrief } from "../book/outline-brief.js";
2
+ import { DEFAULT_BRIEF } from "./state.js";
3
+ /**
4
+ * The brief a run starts from or a configuration reads: the idea from the description of the book (`outline/book.md`), the fields from
5
+ * `outline/_brief.md`. A book saved before the brief had these files moves what its state held into them, once: the idea when the author has
6
+ * written no description (a description that the author wrote is never overwritten), and the fields when `_brief.md` does not exist. The
7
+ * returned `changes` make that move, and the caller commits them with its own commit. A file whose frontmatter cannot be read stops the
8
+ * reading: the brief is never taken as the defaults over an author's text.
9
+ */
10
+ export async function readBrief(store, state) {
11
+ const reading = await readOutlineBrief(store);
12
+ if (reading.unreadable)
13
+ throw new Error("outline/_brief.md: its frontmatter is not valid YAML: correct the file before the autopilot reads its brief.");
14
+ if (reading.bookUnreadable)
15
+ throw new Error("outline/book.md: its frontmatter is not valid YAML: correct the file before the autopilot reads the idea of the book.");
16
+ const legacy = state?.brief ?? DEFAULT_BRIEF;
17
+ const moved = {};
18
+ if (!reading.brief.idea && legacy.idea)
19
+ moved.idea = legacy.idea;
20
+ const fieldsMoved = Boolean(legacy.synopsis || legacy.genre || legacy.audience || legacy.wordsPerScene !== DEFAULT_BRIEF.wordsPerScene);
21
+ if (!reading.hash && fieldsMoved)
22
+ Object.assign(moved, { genre: legacy.genre, audience: legacy.audience, wordsPerScene: legacy.wordsPerScene, synopsis: legacy.synopsis });
23
+ if (Object.keys(moved).length === 0)
24
+ return { brief: reading.brief, changes: [] };
25
+ const planned = await outlineBriefChanges(store, moved);
26
+ return { brief: planned.brief, changes: planned.changes };
27
+ }
28
+ //# sourceMappingURL=brief.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brief.js","sourceRoot":"","sources":["../../src/autopilot/brief.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAqB,MAAM,0B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AAK,CAAC,CAAC;IACxD,OAAO,EAAE,KAAK,EAAE,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AAC5D,CAAC"}
@@ -10,7 +10,6 @@ export declare function estimateTexts(italian: boolean): {
10
10
  noPrice: (id: EstimateCapability, model: string) => string;
11
11
  noSpeed: (id: EstimateCapability, model: string) => string;
12
12
  reasoningModel: (id: EstimateCapability, model: string) => string;
13
- outlineLonger: (brief: number, outline: number) => string;
14
13
  /** The assumptions, one sentence each, in the order of the pipeline. */
15
14
  assumptions: (facts: AssumptionFacts) => string[];
16
15
  };
@@ -1 +1 @@
1
- {"version":3,"file":"estimate-texts.d.ts","sourceRoot":"","sources":["../../src/autopilot/estimate-texts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA6C1E,mHAAmH;AACnH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAEnE;AAQD,2GAA2G;AAC3G,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO;qBAGpB,kBAAkB;kBAI1B,kBAAkB;sBAGd,kBAAkB,SAAS,MAAM,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,QAAQ,gBAAgB,QAAQ,OAAO;sBAGxH,kBAAkB,SAAS,MAAM,SAAS,MAAM,SAAS,MAAM,QAAQ,gBAAgB;kBAG3F,kBAAkB,SAAS,MAAM;kBAGjC,kBAAkB,SAAS,MAAM;yBAG1B,kBAAkB,SAAS,MAAM;2BAG/B,MAAM,WAAW,MAAM;IAG9C,wEAAwE;yBACnD,eAAe,KAAG,MAAM,EAAE;EA+ClD;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAA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AM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -74,9 +74,6 @@ export function estimateTexts(italian) {
74
74
  reasoningModel: (id, model) => (italian
75
75
  ? `«${capability(id)}»: ${model} ragiona prima di rispondere e spende token di ragionamento che non sono contati qui.`
76
76
  : `«${capability(id)}»: ${model} reasons before it answers and spends reasoning tokens that are not counted here.`),
77
- outlineLonger: (brief, outline) => (italian
78
- ? `La scaletta chiede ${count(outline)} capitoli e il brief ${count(brief)}: il libro ne ha ${count(outline)}, e la stima li conta tutti.`
79
- : `The outline asks for ${count(outline)} chapters and the brief for ${count(brief)}: the book has ${count(outline)}, and the estimate counts them all.`),
80
77
  /** The assumptions, one sentence each, in the order of the pipeline. */
81
78
  assumptions: (facts) => {
82
79
  const lines = [];
@@ -1 +1 @@
1
- {"version":3,"file":"estimate-texts.js","sourceRoot":"","sources":["../../src/autopilot/estimate-texts.ts"],"names":[],"mappings":"AAEA,mHAAmH;AACnH,MAAM,gBAAgB,GAA4D;IAChF,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,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EAAE,IAAI,CAAC,mCAAmC,MAAM,8IAA8I;gBAC/U,CAAC,CAAC,kHAAkH,YAAY,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,qCAAqC,MAAM,oIAAoI,CAAC,CAAC;YAC9U,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,4IAA4I;gBAC9I,CAAC,CAAC,8IAA8I,CAAC,CAAC;YACpJ,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,iLAAiL;gBACnL,CAAC,CAAC,6JAA6J,CAAC,CAAC;YACnK,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,yGAAyG;gBAC3G,CAAC,CAAC,yGAAyG,CAAC,CAAC;YAC/G,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBACjB,KAAK,CAAC,IAAI,CAAC,OAAO;oBAChB,CAAC,CAAC,mJAAmJ;oBACrJ,CAAC,CAAC,iJAAiJ,CAAC,CAAC;YACzJ,CAAC;YACD,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;gBAC3B,KAAK,CAAC,IAAI,CAAC,OAAO;oBAChB,CAAC,CAAC,oBAAoB,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU;oBACzD,CAAC,CAAC,sBAAsB,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAChE,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,oMAAoM;gBACtM,CAAC,CAAC,uMAAuM,CAAC,CAAC;YAC7M,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -157,8 +157,10 @@ export interface EstimateOutline {
157
157
  words?: number;
158
158
  }
159
159
  export interface EstimateInput {
160
- /** The brief of the form: the chapters, the scenes of a chapter, the words of a scene, and the idea and the synopsis, which weigh in the prompts that carry them. */
160
+ /** The brief of the form: the words of a scene, and the idea and the synopsis, which weigh in the prompts that carry them. The chapters are `outline`'s. */
161
161
  brief?: Partial<AutopilotBrief>;
162
+ /** The scenes a chapter is expected to have (the planner's rule gives 2 to 4 for each chapter); the middle of the range when missing. */
163
+ scenesPerChapter?: number;
162
164
  /** `readers`, `maxReaders`, `readersOnPlan` and `specialists` change the calls; the others (`pauseAfterPlan`, `chaptersPerRun`, the budgets…) do not. */
163
165
  options?: Partial<AutopilotOptions>;
164
166
  /** `maxReviewRounds` of the director's profile (1 to 3, 2 when it says nothing). */
@@ -237,10 +239,6 @@ export type EstimateWarning = (EstimateWarningBase & {
237
239
  code: "reasoningModel";
238
240
  capability: EstimateCapability;
239
241
  model: string;
240
- }) | (EstimateWarningBase & {
241
- code: "outlineLongerThanBrief";
242
- briefChapters: number;
243
- outlineChapters: number;
244
242
  });
245
243
  export type EstimateWarningCode = EstimateWarning["code"];
246
244
  export interface EstimateResult {
@@ -1 +1 @@
1
- {"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../src/autopilot/estimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAqBvD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAOnF,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,gHAOvB,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,uNAgBrB,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAoBpE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B,yDAAyD;;IAEzD,sJAAsJ;;;;IAItJ,yIAAyI;;IAEzI,sJAAsJ;;IAEtJ,+JAA+J;;;;IAI/J,4LAA4L;;;IAG5L,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,CAAC,CAMrO;AAED;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,aAAa,GAAG,eAAe,GAAG,MAAM,CAAC,GAAG,IAAI,GAAG,SAAS,GAAG,IAAI,CAAC,eAAe,EAAE,YAAY,GAAG,YAAY,CAAC,CAOrL"}
@@ -11,7 +11,7 @@ import { asInteger, asNumber, asRecord } from "../util/json.js";
11
11
  import { OUTPUT_TOKENS_CEILING, countWords, isItalian, languageCode, scaleOutputTokens, tokensPerWord } from "../util/text.js";
12
12
  import { sumCappedRamp, sumWindowedList, windowedList } from "./estimate-math.js";
13
13
  import { estimateTexts } from "./estimate-texts.js";
14
- import { PLAN_BATCH_CHAPTERS } from "./planner.js";
14
+ import { PLAN_BATCH_CHAPTERS, SCENES_PER_CHAPTER } from "./planner.js";
15
15
  import { CHAPTER_REVIEW_TOOL, CHAPTER_SUMMARY_TOOL, CONCEPT_TOOL, CONSOLIDATION_TOOL, FINDINGS_TOOL, PLAN_REACTION_TOOL, PLAN_REVIEW_TOOL, PLAN_TOOL, SCENES_TOOL, SCENE_SUMMARY_TOOL, architectSystemPrompt, continuitySystemPrompt, specialistsSystemPrompt, writerSystemPrompt, } from "./prompts.js";
16
16
  import { MAX_BOOK_CHAPTERS, MAX_DIRECTOR_NOTES, normalizeBrief, normalizeOptions } from "./state.js";
17
17
  // What a run will cost before it starts. The estimate is arithmetic over the pipeline: it counts the calls the steps of the autopilot make (the formulas
@@ -379,13 +379,14 @@ export function estimateAutopilotRun(input) {
379
379
  const ratio = tpw / LATIN_TOKENS_PER_WORD;
380
380
  /** Tokens of `count` words of the book in a prompt. */
381
381
  const w = (count) => count * INPUT_TOKENS_PER_WORD * ratio;
382
- const scenes = brief.scenesPerChapter;
382
+ // The scenes of each chapter are the planner's (`scenesForChapter`): the host says how many it expects, else the middle of the range.
383
+ const scenes = whole(source.scenesPerChapter, Math.round((SCENES_PER_CHAPTER.min + SCENES_PER_CHAPTER.max) / 2), 1, 20);
383
384
  const sceneWords = brief.wordsPerScene;
384
385
  const chapterWords = scenes * sceneWords;
385
386
  const maxRounds = whole(source.maxReviewRounds, 2, 1, MAX_ROUNDS);
386
- // The book: the chapters the brief asks for, or the outline's if it asks for more.
387
+ // The book: the chapters of the outline (its chapter entries), or the chapters already planned when the outline has none.
387
388
  const outlineChapters = outlineChaptersOf(outline);
388
- const chapters = Math.min(MAX_BOOK_CHAPTERS, Math.max(brief.targetChapters, outlineChapters));
389
+ const chapters = Math.min(MAX_BOOK_CHAPTERS, Math.max(outlineChapters, whole(progress.planned, 0, 0, MAX_BOOK_CHAPTERS)));
389
390
  const outlineEntries = whole(outline.entries, 0, 0, MAX_BOOK_CHAPTERS) || (outlineChapters > 0 ? outlineChapters : 0);
390
391
  const outlineWords = outlineEntries > 0 ? knob(outline.words, outlineEntries * T.outlineEntryWords) : 0;
391
392
  // Where it is.
@@ -742,9 +743,6 @@ export function estimateAutopilotRun(input) {
742
743
  if (model.reasoning)
743
744
  warnings.push({ code: "reasoningModel", severity: "info", capability, model: model.name, text: text.reasoningModel(capability, model.name) });
744
745
  }
745
- if (outlineChapters > brief.targetChapters) {
746
- warnings.push({ code: "outlineLongerThanBrief", severity: "info", briefChapters: brief.targetChapters, outlineChapters, text: text.outlineLonger(brief.targetChapters, outlineChapters) });
747
- }
748
746
  const gravity = { error: 0, warning: 1, info: 2 };
749
747
  warnings.sort((left, right) => gravity[left.severity] - gravity[right.severity]);
750
748
  const sumKinds = (select) => ESTIMATE_CALL_KINDS.reduce((total, kind) => ({ min: total.min + select(steps[kind]).min, max: total.max + select(steps[kind]).max }), rangeOf(0, 0));