narrarium-engine 0.1.11 → 0.1.13

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 (87) hide show
  1. package/README.md +50 -19
  2. package/dist/ai/deadlines.d.ts.map +1 -1
  3. package/dist/ai/deadlines.js +25 -8
  4. package/dist/ai/deadlines.js.map +1 -1
  5. package/dist/ai/fetch-client.d.ts +19 -1
  6. package/dist/ai/fetch-client.d.ts.map +1 -1
  7. package/dist/ai/fetch-client.js +262 -69
  8. package/dist/ai/fetch-client.js.map +1 -1
  9. package/dist/ai/types.d.ts +60 -0
  10. package/dist/ai/types.d.ts.map +1 -1
  11. package/dist/ai/types.js +19 -0
  12. package/dist/ai/types.js.map +1 -1
  13. package/dist/autopilot/brief.d.ts +14 -0
  14. package/dist/autopilot/brief.d.ts.map +1 -0
  15. package/dist/autopilot/brief.js +28 -0
  16. package/dist/autopilot/brief.js.map +1 -0
  17. package/dist/autopilot/errors.d.ts.map +1 -1
  18. package/dist/autopilot/errors.js +60 -1
  19. package/dist/autopilot/errors.js.map +1 -1
  20. package/dist/autopilot/estimate-texts.d.ts +0 -1
  21. package/dist/autopilot/estimate-texts.d.ts.map +1 -1
  22. package/dist/autopilot/estimate-texts.js +0 -3
  23. package/dist/autopilot/estimate-texts.js.map +1 -1
  24. package/dist/autopilot/estimate.d.ts +3 -5
  25. package/dist/autopilot/estimate.d.ts.map +1 -1
  26. package/dist/autopilot/estimate.js +5 -7
  27. package/dist/autopilot/estimate.js.map +1 -1
  28. package/dist/autopilot/outline-compose.d.ts.map +1 -1
  29. package/dist/autopilot/outline-compose.js +5 -1
  30. package/dist/autopilot/outline-compose.js.map +1 -1
  31. package/dist/autopilot/planner.d.ts +20 -7
  32. package/dist/autopilot/planner.d.ts.map +1 -1
  33. package/dist/autopilot/planner.js +38 -16
  34. package/dist/autopilot/planner.js.map +1 -1
  35. package/dist/autopilot/presets.d.ts +17 -25
  36. package/dist/autopilot/presets.d.ts.map +1 -1
  37. package/dist/autopilot/presets.js +9 -39
  38. package/dist/autopilot/presets.js.map +1 -1
  39. package/dist/autopilot/runner.d.ts +5 -3
  40. package/dist/autopilot/runner.d.ts.map +1 -1
  41. package/dist/autopilot/runner.js +32 -20
  42. package/dist/autopilot/runner.js.map +1 -1
  43. package/dist/autopilot/session.d.ts +6 -1
  44. package/dist/autopilot/session.d.ts.map +1 -1
  45. package/dist/autopilot/session.js +22 -3
  46. package/dist/autopilot/session.js.map +1 -1
  47. package/dist/autopilot/state.d.ts +4 -0
  48. package/dist/autopilot/state.d.ts.map +1 -1
  49. package/dist/autopilot/state.js +7 -12
  50. package/dist/autopilot/state.js.map +1 -1
  51. package/dist/autopilot/tasks.d.ts.map +1 -1
  52. package/dist/autopilot/tasks.js +15 -11
  53. package/dist/autopilot/tasks.js.map +1 -1
  54. package/dist/autopilot/types.d.ts +34 -3
  55. package/dist/autopilot/types.d.ts.map +1 -1
  56. package/dist/autopilot/types.js.map +1 -1
  57. package/dist/book/outline-brief.d.ts +74 -0
  58. package/dist/book/outline-brief.d.ts.map +1 -0
  59. package/dist/book/outline-brief.js +161 -0
  60. package/dist/book/outline-brief.js.map +1 -0
  61. package/dist/book/outline.d.ts +13 -5
  62. package/dist/book/outline.d.ts.map +1 -1
  63. package/dist/book/outline.js +31 -24
  64. package/dist/book/outline.js.map +1 -1
  65. package/dist/book/paths.d.ts +5 -0
  66. package/dist/book/paths.d.ts.map +1 -1
  67. package/dist/book/paths.js +5 -0
  68. package/dist/book/paths.js.map +1 -1
  69. package/dist/index.d.ts +1 -0
  70. package/dist/index.d.ts.map +1 -1
  71. package/dist/index.js +1 -0
  72. package/dist/index.js.map +1 -1
  73. package/dist/server/client.d.ts +6 -0
  74. package/dist/server/client.d.ts.map +1 -1
  75. package/dist/server/client.js +19 -5
  76. package/dist/server/client.js.map +1 -1
  77. package/dist/server/protocol.d.ts +10 -0
  78. package/dist/server/protocol.d.ts.map +1 -1
  79. package/dist/server/protocol.js +11 -0
  80. package/dist/server/protocol.js.map +1 -1
  81. package/dist/testing/index.d.ts +3 -0
  82. package/dist/testing/index.d.ts.map +1 -1
  83. package/dist/testing/index.js +8 -0
  84. package/dist/testing/index.js.map +1 -1
  85. package/dist/version.d.ts +1 -1
  86. package/dist/version.js +1 -1
  87. package/package.json +1 -1
package/README.md CHANGED
@@ -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();
@@ -157,7 +157,7 @@ Data the web app's pages used to have to guess (from the text of a step, from th
157
157
  | `conflict` | A file changed under the step and the retries are used up (`BookConflictError`); or, on a personal server, the server's work conflicts with GitHub (code `github_conflict`, with `githubConflicts` in the detail: the author chooses the version of each file, see *The personal server client*). |
158
158
  | `unknown` | Everything else. |
159
159
 
160
- `errorDetail` is `{ status?, endpoint?, model?, provider?, integration?, retryAfterMs?, attempt?, retries?, timeoutMs?, timeoutPhase?, githubConflicts? }`, short and with no secret in any field: `githubConflicts` is there only for a conflict with GitHub (an error whose `code` is `GITHUB_CONFLICT_CODE`, `"github_conflict"`, and whose `total` says how many files: never retried, the author chooses), a whole number from 1 (read back from a file the same way); `status` is the HTTP status when the provider answered; `retryAfterMs` is what the provider asked for with `Retry-After` in milliseconds, on a 429 or a 503 only and only when it said (the engine's client keeps at most five minutes of it, `0` is a value, and a value read from a file is a whole number from 0 to a day, else it is dropped), so that a client can say *the provider asks to wait 30 s* without guessing it from the retry; `endpoint` is only the **origin** of the integration's address (`new URL(address).origin`: never a path, a query, a fragment or credentials, and nothing at all for an address that is not a web address); `model`, `provider` and `integration` (the id) are passed through `redactSecrets` and cut at 160 characters. `attempt` and `retries` are there only for a failure that is retried: the retry it belongs to (the one that followed it, or the last one made when the run gave up) and how many retries this kind of failure gets, the numbers of the `failureRetry` insight; a failure that is never retried (a 401) has neither. `timeoutPhase` (`"start"`, `"idle"` or `"total"`) and `timeoutMs` are there only for a timeout of the engine's client: which deadline ran out (the provider did not begin answering, it went silent while it answered, or the call took longer than any call may) and how long it was, in milliseconds (a value read from a file is a whole number from 1 ms to a day, else it is dropped); see *Timeouts and streaming*. Where an error came from is `AiProviderError.target` (`{ provider, model, integrationId, endpoint? }`, the endpoint already an origin), which the engine's client sets on the error of the last candidate it tried; it is separate from the error's own `model`, `provider` and `integrationId`, whose presence means that the model had started to answer and is billed. A state written before the errors were classified has `lastError` with a message and no kind: `summary.lastError` then has none either.
160
+ `errorDetail` is `{ status?, endpoint?, model?, provider?, integration?, retryAfterMs?, attempt?, retries?, timeoutMs?, timeoutPhase?, githubConflicts?, transport? }`, short and with no secret in any field: `githubConflicts` is there only for a conflict with GitHub (an error whose `code` is `GITHUB_CONFLICT_CODE`, `"github_conflict"`, and whose `total` says how many files: never retried, the author chooses), a whole number from 1 (read back from a file the same way); `status` is the HTTP status when the provider answered; `retryAfterMs` is what the provider asked for with `Retry-After` in milliseconds, on a 429 or a 503 only and only when it said (the engine's client keeps at most five minutes of it, `0` is a value, and a value read from a file is a whole number from 0 to a day, else it is dropped), so that a client can say *the provider asks to wait 30 s* without guessing it from the retry; `endpoint` is only the **origin** of the integration's address (`new URL(address).origin`: never a path, a query, a fragment or credentials, and nothing at all for an address that is not a web address); `model`, `provider` and `integration` (the id) are passed through `redactSecrets` and cut at 160 characters. `attempt` and `retries` are there only for a failure that is retried: the retry it belongs to (the one that followed it, or the last one made when the run gave up) and how many retries this kind of failure gets, the numbers of the `failureRetry` insight; a failure that is never retried (a 401) has neither. `timeoutPhase` (`"start"`, `"idle"` or `"total"`) and `timeoutMs` are there only for a timeout of the engine's client: which deadline ran out (the provider did not begin answering, it went silent while it answered, or the call took longer than any call may) and how long it was, in milliseconds (a value read from a file is a whole number from 1 ms to a day, else it is dropped); see *Timeouts and streaming*. Where an error came from is `AiProviderError.target` (`{ provider, model, integrationId, endpoint? }`, the endpoint already an origin), which the engine's client sets on the error of the last candidate it tried; it is separate from the error's own `model`, `provider` and `integrationId`, whose presence means that the model had started to answer and is billed. `transport` is there for a call that failed after the provider answered and whose response said something beyond its status (it carried bytes, a request id, an end or a finish reason): `{ status?, bytes?, chunks?, events?, lastChunkAfterMs?, silentMs?, end?, finishReason?, usageReceived?, usageRequested?, tail?, requestId?, partialCharacters? }`, the numbers of `AiTransportDiagnostics`, the last 300 characters of the stream (credentials replaced, no reasoning) and how many characters of the reply had arrived; every field is checked when a state is read, and a file cannot make one longer or put a key in it. A state written before the errors were classified has `lastError` with a message and no kind: `summary.lastError` then has none either.
161
161
 
162
162
  **The retry that is waiting.** While the run waits to try a failed step again, `summary.retry` is `{ at, attempt, retries }`: `at` is the ISO time of the next attempt, `attempt` and `retries` those of the `failureRetry` insight (`retry 2 of 3`). In a wait of «Retry later» it is `{ at, attempt, retries, longTerm: { cycle, cycles } }`: `attempt` and `retries` are then the quick retries that were made, `cycle` the cycle of the wait (from 1) and `cycles` how many there are, `null` for no limit (the numbers of the `longRetryWait` insight: «ripartenza 2 di 3», *restart 2 of 3*); the rest of the summary is what it always was. It is never saved, and it is the fourth field of the summary that only a live session knows (see *What the summary says*). Every change is a `state` event, so a client counts down without guessing: one event when the wait begins (right after the `failureRetry` or `longRetryWait` insight), one when it is over and the attempt starts (the summary has no `retry` then; after «Retry now» that event follows the `retrySkipped` insight at once), and the last summary of a run that ends, or is paused, during the wait has none. A host that gets the state from a `state` event replaces its summary by the newest one it has seen, and so the retry goes away. A client offers «Retry now» (`session.retryNow()`, or `retryNow(bookId)` of the server's client) while `retry` is there.
163
163
 
@@ -211,13 +211,14 @@ A profile with warnings is not what the author wrote, so the engine never goes o
211
211
 
212
212
  ## Outline (Scaletta)
213
213
 
214
- 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.
215
215
 
216
216
  ### The files
217
217
 
218
218
  | Path | Frontmatter | Body |
219
219
  |---|---|---|
220
- | `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*. |
221
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. |
222
223
 
223
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.
@@ -272,13 +273,33 @@ An entry that cannot be read changes nothing until the author corrects it, and n
272
273
  ### What the autopilot does with it
273
274
 
274
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.
275
- - **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.»
276
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.
277
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.
278
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`).
279
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.
280
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.
281
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
+
282
303
  ## Frozen chapters
283
304
 
284
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).
@@ -389,10 +410,10 @@ const estimate = estimateAutopilotRun({
389
410
 
390
411
  | Field | Meaning |
391
412
  |---|---|
392
- | `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. |
393
414
  | `maxReviewRounds` | The most rounds of review a chapter gets, 1 to 3 (2 when it says nothing), as in the director's profile. |
394
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. |
395
- | `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`). |
396
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. |
397
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*. |
398
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. |
@@ -416,7 +437,7 @@ The estimate is an interval because the reviews are the model's: how many rounds
416
437
  | | rounds `r` | scenes repaired in a chapter `p` | revisions of the plan `v` |
417
438
  |---|---|---|---|
418
439
  | `min` | 1 | 0 | 0 |
419
- | `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) |
420
441
 
421
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.
422
443
 
@@ -477,7 +498,6 @@ A reply is the words of the schema or of the scene at `tokensPerWord(language)`
477
498
  | `noPrice` | warning | `capability`, `model` | The model has no price: the cost is `null`. |
478
499
  | `noSpeed` | info | `capability`, `model` | The model has no speed: the minutes are `null`. |
479
500
  | `reasoningModel` | info | `capability`, `model` | The model reasons (`supportsReasoning`, or by its name as the router knows it): its reasoning tokens are not counted. |
480
- | `outlineLongerThanBrief` | info | `briefChapters`, `outlineChapters` | The outline asks for more chapters than the brief: the book has the outline's. |
481
501
 
482
502
  ### What it assumes, and what it leaves out
483
503
 
@@ -512,15 +532,15 @@ What the runs show (`ESTIMATE_REPORT=1 node --test test/estimate-run.test.mjs` p
512
532
 
513
533
  ### Presets
514
534
 
515
- `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.
516
536
 
517
- | `id` | Chapters × scenes × words | Words | Readers | Plan readers | Specialists | Rounds |
537
+ | `id` | Chapters | Words per scene | Readers | Plan readers | Specialists | Rounds |
518
538
  |---|---|---|---|---|---|---|
519
- | `story` | 4 × 2 × 900 | 7 200 | 3 | no | yes | 2 |
520
- | `novella` | 12 × 3 × 1 400 | 50 400 | 5 | yes | yes | 2 |
521
- | `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 |
522
542
 
523
- `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.
524
544
 
525
545
  ### Measured speed
526
546
 
@@ -586,8 +606,8 @@ What every host gets, whatever its options:
586
606
  | Timeouts | Three, in every host: how long the provider has to begin answering (an integration's `requestTimeoutMs`, else `options.defaultTimeoutMs`, else `DEFAULT_REQUEST_TIMEOUT_MS`, 600 s; never under 30 s), the longest silence while it answers (`idleTimeoutMs`, 600 s) and the most one call may take (4 h). See *Timeouts and streaming*. |
587
607
  | Hooks | `onAttempt(attempt)`: `attemptId`, the effective `messages` (with the JSON instruction a model without tools receives), the output limit, `stream`, `streamMode`, `tools`, `endpoint`, `timeoutMs` and `timeouts` (the three deadlines: see *Timeouts and streaming*), `toolsOnly` (whether Tools only was in force), `thinking` (the level sent, absent when none was), `reasoningParameter` (where it went, only when it went as the chat-template argument: see *Thinking*), `skipped` (the models left out, absent when none was: see *Tools only* and *Thinking*) and `notes` (what the attempt does not do that the configuration asked, because of what the model declares, in English; absent when there is nothing to say: see *Declared capabilities of a model*). `onAttemptEnd(end)`: the same `attemptId`, `outcome` (`ok`, `failed`, `cancelled`), `usage`, `cost`, `usageKnown`, `costKnown`, the reply `text` or the `error` (without credentials), `failureKind` (`timeout`, `cancelled`, `provider`), `status`, `retryAfterMs`, `timeoutMs` and `timeoutPhase` (for a timeout), `streamed`, `firstByteMs`, `toolCalled`, `durationMs` and, once a reply was read, `finishReason` (the provider's own word, empty when it said none), `replyCharacters` (its text without the reasoning, and the arguments of its function, `{}` being none) and `reasoningCharacters` (the reasoning field of the provider, and a `<think>` block in the text: the count, never the words), for every attempt that was sent, failed ones included; the three facts are there also for a reply the engine refused after reading it (one that was cut, or filtered), and absent for an attempt that never got one (a refusal, a connection that failed, a deadline that ran out first). The `messages` of `onAttempt` are copies and carry the roles and the parts (an image with its data URL), so a listener cannot change what is sent. A hook that throws never breaks a call. |
588
608
  | Approving endpoints | `effectiveAiBase(integration, githubModelsBaseUrl?)` is the origin and path every request of an integration starts with, defaults included (`https://api.openai.com/v1`, `https://models.github.ai/inference`). A host that approves where API keys may be sent should compare these. |
589
- | Wire format | Server-sent events with several `data:` lines are joined with a newline; the pieces of a forced function call (`delta.tool_calls[].function.arguments`) are joined into the arguments of the reply, and a last piece that carries the whole `message.tool_calls` is read too; a JSON reply to a streaming request (a server that ignores `stream`) is read as the reply; an `error` in a 200 reply is a provider error. |
590
- | Errors | `AiProviderError` carries `status`, `retryable`, `transient` (it depends on the moment: 408, 429, 502, 503, 504, network), `retryAfterMs` (the `Retry-After` of a 429 or 503, at most five minutes), `timedOut` with `timeout` (which deadline ran out, for how long), `truncated` and `reasoningOnly` (the reply was cut while the model reasoned: seen as reasoning, or, with nothing written at all, from a model declared as reasoning). `AiToolsRequiredError` (nothing can be asked: Tools only is on and no model can call a function; see *Tools only*) is the error of a call that was never sent. Keys, `Bearer …`, `api-key: …`, `?key=…` and `sk-…` are removed from every message (`redactSecrets`), also before the runner saves it. The error of a candidate that was tried carries `target` (`{ provider, model, integrationId, endpoint? }`, the endpoint only an origin: see *What the interface reads*). |
609
+ | Wire format | Server-sent events with several `data:` lines are joined with a newline; the pieces of a forced function call (`delta.tool_calls[].function.arguments`) are joined into the arguments of the reply, and a last piece that carries the whole `message.tool_calls` is read too; a JSON reply to a streaming request (a server that ignores `stream`) is read as the reply; an `error` in a 200 reply is a provider error, and so is an `event: error` whatever its data is. A line ends with LF, CR or CRLF (the three that the SSE specification allows, a CRLF cut between two chunks included); a `data:` with no space after it, a last line with no newline, and `: comments`, `id:` and `retry:` lines are read as they should be; a character that a chunk cuts in two is kept until the rest comes. The tokens are read from whichever chunk carries `usage` (`prompt_tokens`/`completion_tokens`, or `input_tokens`/`output_tokens`; the cached ones from `prompt_tokens_details.cached_tokens`, `input_tokens_details.cached_tokens`, `prompt_cache_hit_tokens` or `cache_read_input_tokens`); a count of zero never replaces a real one. |
610
+ | Errors | `AiProviderError` carries `status`, `retryable`, `transient` (it depends on the moment: 408, 429, 502, 503, 504, Cloudflare's 520-524, network, a stream that stopped), `transport` and `partialText` (what the transport saw of the call, and the reply that had arrived: see *A stream that stops halfway*), `retryAfterMs` (the `Retry-After` of a 429 or 503, at most five minutes), `timedOut` with `timeout` (which deadline ran out, for how long), `truncated` and `reasoningOnly` (the reply was cut while the model reasoned: seen as reasoning, or, with nothing written at all, from a model declared as reasoning). `AiToolsRequiredError` (nothing can be asked: Tools only is on and no model can call a function; see *Tools only*) is the error of a call that was never sent. Keys, `Bearer …`, `api-key: …`, `?key=…` and `sk-…` are removed from every message (`redactSecrets`), also before the runner saves it. The error of a candidate that was tried carries `target` (`{ provider, model, integrationId, endpoint? }`, the endpoint only an origin: see *What the interface reads*). |
591
611
 
592
612
  ### Timeouts and streaming
593
613
 
@@ -607,6 +627,16 @@ The author's `signal` wins over all three: a call cancelled is an `AbortError` a
607
627
 
608
628
  **Node's own limits.** In Node the platform's `fetch` (undici) has two limits of its own, 300 s each, whatever the engine's deadlines say: `headersTimeout` (the headers of a response) and `bodyTimeout` (the silence between two pieces of a body). A host that runs the engine in Node and wants a longer silence than five minutes (a model that thinks for ten without sending anything) passes, as `options.fetch`, a `fetch` over a dispatcher with those two raised, or off (`0`).
609
629
 
630
+ **What the server does about it.** The personal server does not have this limit: the `fetch` of its process is its outbound guard (`installOutboundNetwork`, on `node:http`), which limits the connection and nothing after it, so there the idle deadline above is the only limit of a silence (its tests pin it). The measured limit of Node's own `fetch` is 300.9 s on Node 22 and 24: a body that is silent that long ends with `TypeError: terminated` (`BodyTimeoutError`), a response whose headers take that long with `fetch failed` (`HeadersTimeoutError`), and the client reads the first as a lost connection.
631
+
632
+ **Gateways in between.** Whatever the idle deadline is, a gateway between the app and the model has its own, and the shortest one decides. LlmProxy resets the connection (`context.Abort()`: no last chunk, no `[DONE]`, no error event) when its runtime sends nothing for `Gateway:UpstreamIdleTimeoutSeconds` (300 s unless its owner changed it; 5 s to 24 h) or when the runtime's connection breaks, and answers JSON errors (`error.code`: `capacity_exhausted`, `model_not_running`, `capacity_lease_lost`, `upstream_unreachable`, `upstream_timeout`, `rate_limit_exceeded`, `token_budget_exceeded`...) only before the first byte. Cloudflare in front of it closes a connection that has been silent for 100 s (`524`). LlmProxy starts its response before the model says a word, so a long prefill is a silence of the *stream*: **Idle** is its limit, not **Start**. To let a model think for longer than a gateway allows, raise the gateway's limit and the integration's **Idle timeout** together (the gateway's first); and where a call ends as "the connection was lost" with the transport saying that the last chunk came a round number of seconds before the end (`silentMs` of about 100 000 or 300 000), it is the gateway that cut a silent stream. Without a keep-alive from the model there is nothing the client can do about that, and `: keep-alive` comments from a gateway that sends them are enough to keep the count going.
633
+
634
+ **A stream that stops halfway.** When the provider has begun to answer and the reply does not reach its end, the client does not return it and does not forget it: it throws an `AiStreamInterruptedError` (an `AiProviderError`, always `retryable` and `transient`, so the run repeats the step as it repeats any failure of the moment, and does not give up on two identical messages) whose `how` says what happened: `lost` (the connection broke), `ended` (the provider closed the stream without `[DONE]` and without a finish reason, or with one the client does not know), `provider-error` (the runtime reported a failure inside the stream, whatever status it gave it: a 500, a crash, no status) or `provider-abort` (the finish reason was `abort`, `error`...). A failure that cannot change by asking again is final even then: an invalid request (a 4xx other than 408, 409 and 429) or the credentials refused, and one that is reported before the model wrote a word keeps the rule it had (`transient` only when its status or words say so). What had arrived is kept: `error.partialText` is the text, else the arguments of the function, of at most `MAX_PARTIAL_CHARACTERS` characters (never the reasoning, never a credential), and the client **never applies it**. The tokens of the call are an estimate (`usageKnown: false`) unless the usage chunk came before it stopped.
635
+
636
+ `error.transport` (and `end.transport` of `onAttemptEnd`, for the attempt that failed and, as figures only, for one that worked) says what the transport saw: `status` (the response's: a stream that is cut still began with a 200), `bytes`, `chunks` and `events` that arrived, `lastChunkAfterMs` and `lastChunkAt`, `silentMs` (the silence before the end), `tail` (the last 300 characters that arrived, as they came, with credentials replaced and the words of the reasoning left out; only for a failed attempt, and words of the model that a host should treat as it treats the reply), `finishReason`, `usageReceived` and `usageRequested` (whether the provider reported the tokens, and whether the request asked it to), `end` (`done`: `[DONE]`; `closed`: closed without it; `reset`: the connection broke; `error`: the provider reported a failure; `timeout`: a deadline ran out) and `requestId` (`X-LlmProxy-Request-Id`, `X-Request-Id`...: what the provider or its gateway calls the request). The run keeps a short form of it in `errorDetail.transport` (see *What the interface reads*), the debug panel of the app shows its figures and never the tail, and no field of it is ever a key.
637
+
638
+ **The tokens of a stream, and `stream_options`.** The client asks every provider for them (`stream_options: { include_usage: true }`), reads them from whichever chunk carries them and, when none comes (a provider that ignores the option, a stream that stopped before the usage chunk, a count of zero), estimates them from what arrived and says so: `usageKnown: false`, `costKnown: false`, and the run counts the call among its «calls without token count». A provider that **refuses** the option (400 or 422 naming `stream_options` or `include_usage`) is asked again, at once, without it, and the attempt goes on as one attempt; `FetchAiOptions.usageOptionRefusals` is where that is remembered (default: one set for each client, so every call asks once; an embedder that wants to ask once for all its calls shares one set).
639
+
610
640
  **Progress.** `AiRequest.onProgress({ bytes, events, characters })` is called while a reply streams, at most every 250 ms, with numbers and never a word of the reply: the bytes received (comments included), the events of the stream and the characters of the reply so far (text and function arguments, not reasoning). It is how a host says "the model is answering (12 KB)" for a structured reply. A listener that throws never breaks the call.
611
641
 
612
642
  **Closures and limits.** A stream that closes without `[DONE]` and without a `finish_reason` is still *incomplete* (retried as a transient failure); the reader is cancelled however a call ends, the end of the stream aside: after `[DONE]`, an error in the stream, a deadline, the author's cancel. Two limits stop a model that loops: **256 MB** of transport (`MAX_STREAM_TRANSPORT_BYTES`; the JSON envelope of every piece counts) and **16 million characters** of reasoning (`MAX_STREAM_REASONING_CHARACTERS`). Each is an error that says what it used and what to do ("Lower the thinking effort of the model or choose another one") and is **not** retried, because the same loop would come back; what it used is counted in the cost.
@@ -620,9 +650,9 @@ The author's `signal` wins over all three: a call cancelled is an `AbortError` a
620
650
 
621
651
  An integration without its own value says `the default provider timeout` or `the default idle timeout` and where to change it.
622
652
 
623
- **What the hooks say.** `onAttempt(attempt)` carries `timeouts: { startMs, idleMs, capMs, raised?: { from } }` (the deadlines as they are applied, `raised` when the minimum lifted the provider timeout) and `streamMode`; `timeoutMs` is `timeouts.startMs`. `onAttemptEnd(end)` carries `streamed` (the reply was read as a stream), `firstByteMs` (milliseconds to the first byte of its body, or of the response for a JSON reply; absent when nothing arrived), `toolCalled` (for a structured request, whether the model delivered the result as a function call; absent otherwise) and, for a timeout, `timeoutMs` and `timeoutPhase`.
653
+ **What the hooks say.** `onAttempt(attempt)` carries `timeouts: { startMs, idleMs, capMs, raised?: { from } }` (the deadlines as they are applied, `raised` when the minimum lifted the provider timeout) and `streamMode`; `timeoutMs` is `timeouts.startMs`. `onAttemptEnd(end)` carries `streamed` (the reply was read as a stream), `firstByteMs` (milliseconds to the first byte of its body, or of the response for a JSON reply; absent when nothing arrived), `toolCalled` (for a structured request, whether the model delivered the result as a function call; absent otherwise) and, for a timeout, `timeoutMs` and `timeoutPhase`. It also carries `transport` (see *A stream that stops halfway*: for an attempt that worked, its figures only) and, for an attempt that failed after the model had begun to answer, `partialText`.
624
654
 
625
- **Providers that cannot stream.** A provider that rejects `stream_options`, or does not stream with functions, answers 400: the error then adds `If this provider cannot stream its replies, set "Streaming" of the integration "…" to "off"` (only when its own message talks about streaming), and `streamMode: "off"` brings the old behavior back for that integration. A model that cannot stream while the others of its integration can declares `supportsStreaming: false` instead (see *Declared capabilities of a model*): only that model is called without `stream`. Leave a model that reasons streaming wherever you can: its reasoning counts against the output limit, and a reply that does not stream is silent until it is whole, which a proxy or a tunnel may cut (LlmProxy's own documentation says the same of its reasoning models). A connection that is lost while the provider answers is told with what to check: the proxy or the tunnel between the app and the provider.
655
+ **Providers that cannot stream.** A provider that rejects `stream_options` is asked again without it (see *The tokens of a stream, and `stream_options`*); one that does not stream with functions answers 400, and the error then adds `If this provider cannot stream its replies, set "Streaming" of the integration "…" to "off"` (only when its own message talks about streaming), and `streamMode: "off"` brings the old behavior back for that integration. A model that cannot stream while the others of its integration can declares `supportsStreaming: false` instead (see *Declared capabilities of a model*): only that model is called without `stream`. Leave a model that reasons streaming wherever you can: its reasoning counts against the output limit, and a reply that does not stream is silent until it is whole, which a proxy or a tunnel may cut (LlmProxy's own documentation says the same of its reasoning models). A connection that is lost while the provider answers is told with what to check: the proxy or the tunnel between the app and the provider.
626
656
 
627
657
  ### Tools only
628
658
 
@@ -873,6 +903,7 @@ A skipped file is not recorded as synced (a file that was never synced stays out
873
903
  | `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. |
874
904
  | `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). |
875
905
 
906
+ - **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.
876
907
  - **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.
877
908
 
878
909
  - **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*.
@@ -1 +1 @@
1
- {"version":3,"file":"deadlines.d.ts","sourceRoot":"","sources":["../../src/ai/deadlines.ts"],"names":[],"mappings":"AACA,OAAO,EAAgD,KAAK,mBAAmB,EAAE,MAAM,aAAa,CAAC;AACrG,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,yJAAyJ;AACzJ,eAAO,MAAM,0BAA0B,SAAU,CAAC;AAClD,2IAA2I;A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B,0EAA0E;IAC1E,OAAO,IAAI,IAAI,CAAC;CACjB;AAID;;;GAGG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,SAAS,EAAE,SAAS,EAAE,gBAAgB,GAAG,aAAa,CAiFtG"}
@@ -82,12 +82,13 @@ export function startClock(parent, deadlines) {
82
82
  let expired;
83
83
  let over = false;
84
84
  let watching = false;
85
- let reject = () => undefined;
86
- const interruption = new Promise((_resolve, rejectIt) => {
87
- reject = rejectIt;
88
- });
89
- // Nobody may be racing it when it rejects: that is not an unhandled rejection.
90
- interruption.catch(() => undefined);
85
+ /** Why the attempt was interrupted, once it was: what the waits that are open, and the ones that begin later, are rejected with. */
86
+ let interruption;
87
+ /**
88
+ * The waits that are open (`guard`): each one is its own promise, and leaves this set when its own promise settles, so that a stream of a hundred thousand reads leaves nothing
89
+ * behind (racing every read against one promise that lives as long as the call would keep a reaction on it for each read until the call is over).
90
+ */
91
+ const waits = new Set();
91
92
  let capTimer;
92
93
  let startTimer;
93
94
  let idleTimer;
@@ -95,7 +96,10 @@ export function startClock(parent, deadlines) {
95
96
  if (over || controller.signal.aborted)
96
97
  return;
97
98
  controller.abort(reason);
98
- reject(reason);
99
+ interruption = { reason };
100
+ for (const rejectWait of [...waits])
101
+ rejectWait(reason);
102
+ waits.clear();
99
103
  };
100
104
  const expire = (phase, ms) => () => {
101
105
  if (over || controller.signal.aborted)
@@ -120,7 +124,20 @@ export function startClock(parent, deadlines) {
120
124
  }
121
125
  return {
122
126
  signal: controller.signal,
123
- guard: (promise) => Promise.race([interruption, promise]),
127
+ guard: (promise) => new Promise((resolve, rejectWait) => {
128
+ if (interruption) {
129
+ rejectWait(interruption.reason);
130
+ return;
131
+ }
132
+ waits.add(rejectWait);
133
+ promise.then((value) => {
134
+ waits.delete(rejectWait);
135
+ resolve(value);
136
+ }, (error) => {
137
+ waits.delete(rejectWait);
138
+ rejectWait(error);
139
+ });
140
+ }),
124
141
  streaming() {
125
142
  if (over || controller.signal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CAAC,MAAM,CAAC,OAAO;gBAAE,OAAO,EAAE,CAAC;QACjE,CAAC;QACD,OAAO,EAAE,GAAG,EAAE,CAAC,OAAO;QACtB,WAAW,EAAE,GAAG,EAAE,CAAC,IAAI,IAAI,UAAU,CAAC,MAAM,CAAC,OAAO;QACpD,OAAO;YACL,IAAI,GAAG,IAAI,CAAC;YACZ,KAAK,MAAM,KAAK,IAAI,CAAC,QAAQ,EAAE,UAAU,EAAE,SAAS,CAAC;gBAAE,IAAI,KAAK,KAAK,SAAS;oBAAE,YAAY,CAAC,KAAK,CAAC,CAAC;YACpG,QAAQ,GAAG,UAAU,GAAG,SAAS,GAAG,SAAS,CAAC;YAC9C,MAAM,EAAE,mBAAmB,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC9C,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,OAAO;gBAAE,UAAU,CAAC,KAAK,CAAC,UAAU,CAAC,sBAAsB,CAAC,CAAC,CAAC;QACvF,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import type { AiPricingConfig, AiRuntimeConfig, AiStreamMode } from "./config.js";
2
2
  import { type AiReasoningEffort } from "./request.js";
3
- import { type AiMessage, type AiPort, type AiTimeoutPhase, type AiUsage } from "./types.js";
3
+ import { type AiMessage, type AiPort, type AiTimeoutPhase, type AiTransportDiagnostics, type AiUsage } from "./types.js";
4
4
  export { DEFAULT_REQUEST_TIMEOUT_MS, MIN_REQUEST_TIMEOUT_MS, TOTAL_REQUEST_CAP_MS } from "./deadlines.js";
5
5
  /**
6
6
  * Raw bytes of a stream include the JSON envelope of every piece (a few hundred bytes for a few characters), so a long reasoning phase is
@@ -113,6 +113,16 @@ export interface FetchAiAttemptEnd {
113
113
  replyCharacters?: number;
114
114
  /** Characters of reasoning that came with it (the reasoning field of the provider, and a `<think>` block in the text). Only the count, never the words. Present with `finishReason`. */
115
115
  reasoningCharacters?: number;
116
+ /**
117
+ * What the transport saw of the call: the HTTP status, the bytes and chunks that arrived, when the last one did and what the end of them said, how the provider ended the reply, whether it reported
118
+ * the tokens, and how the stream ended. It is what tells a stream that was cut from one that was slow. Absent when no response arrived (the connection failed first). Never a key.
119
+ */
120
+ transport?: AiTransportDiagnostics;
121
+ /**
122
+ * For an attempt that failed after the model had started to answer: the reply that had arrived (its text, or the arguments of its function call), at most `MAX_PARTIAL_CHARACTERS` characters, cleaned of
123
+ * credentials. The engine does not apply it; this is where a host finds it. Absent when none had arrived.
124
+ */
125
+ partialText?: string;
116
126
  durationMs: number;
117
127
  }
118
128
  /** One side of a fallback that crosses a privacy boundary. */
@@ -149,6 +159,14 @@ export interface FetchAiOptions {
149
159
  * where it is. Throw to cancel the whole call.
150
160
  */
151
161
  acknowledgeFallback?: (from: FetchAiFallbackTarget, to: FetchAiFallbackTarget, info: FetchAiFallbackInfo) => boolean | Promise<boolean>;
162
+ /**
163
+ * Where the client remembers the requests that a provider refused because of `stream_options` (`include_usage`), so that they are sent without it from then on: the key is the address of the
164
+ * request. The option is asked of every provider (it is how a stream reports its tokens), and a provider that answers 400 or 422 naming it is asked again, at once, without it and not again after
165
+ * (its replies then carry no token count, and say so: their usage is an estimate). The default is one set for each client, so a call asks every address once, whatever came before it: the
166
+ * app's hosts leave it at that, so that the same configuration builds the same requests in every host, at the price of one refusal (which costs nothing: it is answered before any work) per call
167
+ * to a provider that refuses. An embedder that wants to ask once for all its calls shares one set between its clients.
168
+ */
169
+ usageOptionRefusals?: Set<string>;
152
170
  }
153
171
  /**
154
172
  * OpenAI-compatible chat client built on `fetch`, usable from Node and browsers.
@@ -1 +1 @@
1
- {"version":3,"file":"fetch-client.d.ts","sourceRoot":"","sources":["../../src/ai/fetch-client.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAGlF,OAAO,EAAmC,KAAK,iBAAiB,EAAoB,MAAM,cAAc,CAAC;AAIzG,OAAO,EAAiE,K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