narrarium-engine 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +360 -26
- package/dist/ai/body.d.ts +20 -0
- package/dist/ai/body.d.ts.map +1 -0
- package/dist/ai/body.js +112 -0
- package/dist/ai/body.js.map +1 -0
- package/dist/ai/catalog-fetch.d.ts +51 -0
- package/dist/ai/catalog-fetch.d.ts.map +1 -0
- package/dist/ai/catalog-fetch.js +261 -0
- package/dist/ai/catalog-fetch.js.map +1 -0
- package/dist/ai/catalog-support.d.ts +13 -0
- package/dist/ai/catalog-support.d.ts.map +1 -0
- package/dist/ai/catalog-support.js +28 -0
- package/dist/ai/catalog-support.js.map +1 -0
- package/dist/ai/catalog.d.ts +148 -0
- package/dist/ai/catalog.d.ts.map +1 -0
- package/dist/ai/catalog.js +367 -0
- package/dist/ai/catalog.js.map +1 -0
- package/dist/ai/config.d.ts +83 -7
- package/dist/ai/config.d.ts.map +1 -1
- package/dist/ai/config.js +83 -11
- package/dist/ai/config.js.map +1 -1
- package/dist/ai/fetch-client.d.ts +20 -0
- package/dist/ai/fetch-client.d.ts.map +1 -1
- package/dist/ai/fetch-client.js +49 -24
- package/dist/ai/fetch-client.js.map +1 -1
- package/dist/ai/probe.d.ts +40 -0
- package/dist/ai/probe.d.ts.map +1 -0
- package/dist/ai/probe.js +110 -0
- package/dist/ai/probe.js.map +1 -0
- package/dist/ai/request.d.ts +58 -5
- package/dist/ai/request.d.ts.map +1 -1
- package/dist/ai/request.js +96 -7
- package/dist/ai/request.js.map +1 -1
- package/dist/ai/router.d.ts +12 -1
- package/dist/ai/router.d.ts.map +1 -1
- package/dist/ai/router.js +10 -2
- package/dist/ai/router.js.map +1 -1
- package/dist/ai/routing.d.ts +15 -4
- package/dist/ai/routing.d.ts.map +1 -1
- package/dist/ai/routing.js +25 -6
- package/dist/ai/routing.js.map +1 -1
- package/dist/ai/token-limit.d.ts +4 -4
- package/dist/ai/token-limit.d.ts.map +1 -1
- package/dist/ai/token-limit.js +5 -4
- package/dist/ai/token-limit.js.map +1 -1
- package/dist/ai/types.d.ts +12 -1
- package/dist/ai/types.d.ts.map +1 -1
- package/dist/ai/types.js +12 -0
- package/dist/ai/types.js.map +1 -1
- package/dist/autopilot/errors.d.ts +4 -3
- package/dist/autopilot/errors.d.ts.map +1 -1
- package/dist/autopilot/errors.js +21 -5
- package/dist/autopilot/errors.js.map +1 -1
- package/dist/autopilot/frozen.d.ts +169 -0
- package/dist/autopilot/frozen.d.ts.map +1 -0
- package/dist/autopilot/frozen.js +495 -0
- package/dist/autopilot/frozen.js.map +1 -0
- package/dist/autopilot/outline-check.d.ts +39 -0
- package/dist/autopilot/outline-check.d.ts.map +1 -0
- package/dist/autopilot/outline-check.js +81 -0
- package/dist/autopilot/outline-check.js.map +1 -0
- package/dist/autopilot/planner.d.ts +29 -1
- package/dist/autopilot/planner.d.ts.map +1 -1
- package/dist/autopilot/planner.js +78 -8
- package/dist/autopilot/planner.js.map +1 -1
- package/dist/autopilot/profile-check.d.ts +7 -4
- package/dist/autopilot/profile-check.d.ts.map +1 -1
- package/dist/autopilot/profile-check.js +9 -6
- package/dist/autopilot/profile-check.js.map +1 -1
- package/dist/autopilot/runner.d.ts +17 -3
- package/dist/autopilot/runner.d.ts.map +1 -1
- package/dist/autopilot/runner.js +127 -20
- package/dist/autopilot/runner.js.map +1 -1
- package/dist/autopilot/session.d.ts +34 -1
- package/dist/autopilot/session.d.ts.map +1 -1
- package/dist/autopilot/session.js +202 -2
- package/dist/autopilot/session.js.map +1 -1
- package/dist/autopilot/state.d.ts +12 -3
- package/dist/autopilot/state.d.ts.map +1 -1
- package/dist/autopilot/state.js +203 -12
- package/dist/autopilot/state.js.map +1 -1
- package/dist/autopilot/tasks.d.ts +14 -2
- package/dist/autopilot/tasks.d.ts.map +1 -1
- package/dist/autopilot/tasks.js +480 -36
- package/dist/autopilot/tasks.js.map +1 -1
- package/dist/autopilot/types.d.ts +193 -12
- package/dist/autopilot/types.d.ts.map +1 -1
- package/dist/autopilot/types.js +9 -2
- package/dist/autopilot/types.js.map +1 -1
- package/dist/book/context.d.ts +3 -0
- package/dist/book/context.d.ts.map +1 -1
- package/dist/book/context.js +7 -1
- package/dist/book/context.js.map +1 -1
- package/dist/book/freeze.d.ts +115 -0
- package/dist/book/freeze.d.ts.map +1 -0
- package/dist/book/freeze.js +286 -0
- package/dist/book/freeze.js.map +1 -0
- package/dist/book/outline.d.ts +245 -0
- package/dist/book/outline.d.ts.map +1 -0
- package/dist/book/outline.js +488 -0
- package/dist/book/outline.js.map +1 -0
- package/dist/book/paths.d.ts +18 -0
- package/dist/book/paths.d.ts.map +1 -1
- package/dist/book/paths.js +25 -0
- package/dist/book/paths.js.map +1 -1
- package/dist/book/snapshot.d.ts +25 -1
- package/dist/book/snapshot.d.ts.map +1 -1
- package/dist/book/snapshot.js +24 -4
- package/dist/book/snapshot.js.map +1 -1
- package/dist/director/opinion.d.ts +6 -0
- package/dist/director/opinion.d.ts.map +1 -1
- package/dist/director/opinion.js +4 -1
- package/dist/director/opinion.js.map +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/profiles/evaluation-style.d.ts +44 -0
- package/dist/profiles/evaluation-style.d.ts.map +1 -0
- package/dist/profiles/evaluation-style.js +152 -0
- package/dist/profiles/evaluation-style.js.map +1 -0
- package/dist/server/client.d.ts +46 -2
- package/dist/server/client.d.ts.map +1 -1
- package/dist/server/client.js +57 -0
- package/dist/server/client.js.map +1 -1
- package/dist/server/protocol.d.ts +120 -2
- package/dist/server/protocol.d.ts.map +1 -1
- package/dist/server/protocol.js +36 -0
- package/dist/server/protocol.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -15,14 +15,18 @@ npm install narrarium-engine
|
|
|
15
15
|
| Area | Main exports |
|
|
16
16
|
|---|---|
|
|
17
17
|
| Book access | `BookStore` (list/read/commit with compare-and-swap, `readMany`), `BookConflictError`, `loadBookSnapshot` |
|
|
18
|
+
| Frozen chapters | `frozenChanges`, `freezeChapterChanges`, `markReviewedChanges`, `unfreezeChapterChanges`, `keepChapterFreeze`, `parseChapterFreeze`, `chapterFreezeRecord`, `FrozenChapterError`, `FROZEN_EDITS_MODES`, `FROZEN_ACTIONS`, `settleFrozenChanges`, `frozenQuestion`, `frozenAnswerAction`: see *Frozen chapters* |
|
|
18
19
|
| Autopilot | `AutopilotSession`, `AutopilotRun`, `advanceState`, `nextStep`, `applyIntervention`, `summarizeAutopilotState`, `effectivePublish`, `hostDefaultPublish`, `normalizeRunLimits`, `runnerActivity`, `runnerHeartbeatAgeMs`, `AutopilotRuleError`, `classifyAutopilotError`, `AUTOPILOT_ERROR_KINDS`, `AUTOPILOT_RULE_ERROR_CODES` |
|
|
19
20
|
| Director | `askDirector`, `listDirectorOpinions`, `parseDirector`, `serializeDirector`, `directorPrompt` |
|
|
20
21
|
| Readers | `readerPersonaSystemPrompt`, `mergeReaderPersonas`, `READER_EVALUATION_TOOL`, `chapterReaderText` |
|
|
21
22
|
| Ghostwriters | `parseGhostwriter`, `ghostwriterPrompt` |
|
|
23
|
+
| Outline (Scaletta) | `parseOutline`, `serializeOutlineChapter`, `serializeOutlineBook`, `outlineChanges`, `outlineEntryDigest`, `outlineBookDigest`, `outlineIndex`, `OutlineReader`, `OutlineCache`, `outlineChapterPath`, `parseOutlineChapterPath`, `outlinePlanStatus`, `effectiveTargetChapters`: see *Outline (Scaletta)* |
|
|
24
|
+
| Evaluation style | `parseEvaluationStyle`, `loadEvaluationStyle`, `evaluationStyleBlock`, `EVALUATION_STYLE_MAX_CHARS`: see *Evaluation style* |
|
|
22
25
|
| Markdown | `parseMarkdown` (with `error`), `splitFrontmatter`, `stripFrontmatter`, `renderMarkdown`, `FrontmatterError` |
|
|
23
26
|
| Text | `clipMiddle`, `truncate`, `tail`, `countWords`, `languageCode`, `tokensPerWord`, `scaleOutputTokens`, `sceneCharacterLimit` |
|
|
24
|
-
| AI | `AiPort` (the only door to language models), `createFetchAi` (OpenAI, Azure OpenAI, GitHub Models), `buildChatRequest`, `resolveAiCandidates`, `pickAiRuntimeConfig`, `effectiveAiBase`, `endpointOrigin`, `redactSecrets`, the deadlines and limits of a call (`DEFAULT_REQUEST_TIMEOUT_MS`, `MIN_REQUEST_TIMEOUT_MS`, `DEFAULT_IDLE_TIMEOUT_MS`, `TOTAL_REQUEST_CAP_MS`, `MAX_STREAM_TRANSPORT_BYTES`…) |
|
|
25
|
-
|
|
|
27
|
+
| AI | `AiPort` (the only door to language models), `createFetchAi` (OpenAI, Azure OpenAI, GitHub Models), `buildChatRequest`, `resolveAiCandidates`, `pickAiRuntimeConfig`, `redactAiRuntimeConfig`, `AI_THINKING_LEVELS`, `AI_REASONING_PARAMETERS`, `suggestedReasoningParameter`, `AiToolsRequiredError`, `effectiveAiBase`, `endpointOrigin`, `redactSecrets`, the deadlines and limits of a call (`DEFAULT_REQUEST_TIMEOUT_MS`, `MIN_REQUEST_TIMEOUT_MS`, `DEFAULT_IDLE_TIMEOUT_MS`, `TOTAL_REQUEST_CAP_MS`, `MAX_STREAM_TRANSPORT_BYTES`…) |
|
|
28
|
+
| Model catalog | `fetchModelCatalog` (the models of an OpenAI-compatible endpoint, with the window, the largest answer and the capabilities its gateway declares), `probeEndpoint` (does it answer, and how), `fetchLmStudioModels`, the pure parsers `parseModelList`, `parseModelDetails`, `parseModalities`, `tokenLimitsFromDetails`, `modelFieldsFromCatalogEntry`, `parseLmStudioModels`, `lmStudioContext`, `AiCatalogError`, `AI_MODEL_TYPES`, `catalogTarget`: see *Model catalog and declared capabilities* |
|
|
29
|
+
| Personal server | `NarrariumServerClient`, `pairWithServer`, `pairWithServerDetailed`, `verifyServerIdentity`, `serverCompatibility`, `serverSupportsAutopilotControls`, `serverSupportsAutopilotRules`, `serverSupportsFrozenChapters`, `remoteBookStore`, protocol types (scopes, pairing, updates), `ServerSentEventParser` |
|
|
26
30
|
| Sync | `planFileSync`, `syncBookStores` (three-way sync of two book stores, with the files it leaves out in `skipped`) |
|
|
27
31
|
| Testing | `narrarium-engine/testing`: `MemoryBookStore`, `seedBookFiles`, `createFakeAutopilotAi` |
|
|
28
32
|
|
|
@@ -70,16 +74,16 @@ A run whose heartbeat is older than `RUNNER_STALE_MINUTES` (20) is taken for dea
|
|
|
70
74
|
|
|
71
75
|
### Pipeline
|
|
72
76
|
|
|
73
|
-
1. **Concept** — story design, world context, characters, locations, factions and secrets (skipped when the book already has a design or prose).
|
|
77
|
+
1. **Concept** — story design, world context, characters, locations, factions and secrets (skipped when the book already has a design or prose). The author's outline, when there is one, is binding for it too.
|
|
74
78
|
2. **Summaries of the author's chapters** — only for a book with chapters written by the author: see *Chapters the author wrote*.
|
|
75
|
-
3. **Plan** — chapter plan; simulated readers react to it and the director approves it or asks for changes. The run can pause here for the author.
|
|
76
|
-
4. **Per chapter** — scene plan, prose scene by scene (streamed), then the review cycle:
|
|
79
|
+
3. **Plan** — chapter plan, following the author's outline as binding when there is one, and filling the outline with what it planned; simulated readers react to it and the director approves it or asks for changes (judging with the method and the severity of the evaluation style). The run can pause here for the author. See *Outline (Scaletta)*.
|
|
80
|
+
4. **Per chapter** — when the author changed the outline of the chapter since it was planned, the chapter is planned again (`replan`); then the scene plan, prose scene by scene (streamed), then the review cycle:
|
|
77
81
|
- blind simulated readers (no canon, no secrets) and a panel summary;
|
|
78
|
-
- specialists (continuity, canon, secrets, timeline, voice, style, pacing) with evidence anchored in the text;
|
|
79
|
-
- the **director** accepts or rejects every finding; the software, not the model, derives the repairs;
|
|
82
|
+
- specialists (continuity, canon, secrets, timeline, voice, style, pacing) with evidence anchored in the text, and the criteria of the evaluation style;
|
|
83
|
+
- the **director** accepts or rejects every finding, judging with the evaluation style; the software, not the model, derives the repairs;
|
|
80
84
|
- accepted fixes are applied; a new round verifies them, up to the director's round limit;
|
|
81
85
|
- consolidation: chapter summary, recap, story so far, `plot.md`.
|
|
82
|
-
5. **Final** — the director's judgement on the whole book.
|
|
86
|
+
5. **Final** — the director's judgement on the whole book, with the evaluation style.
|
|
83
87
|
|
|
84
88
|
### Author interventions
|
|
85
89
|
|
|
@@ -110,11 +114,11 @@ What the web app's quick-command bar uses: pause at the end of the chapter, the
|
|
|
110
114
|
|
|
111
115
|
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.
|
|
112
116
|
|
|
113
|
-
**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) and `
|
|
117
|
+
**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` and `frozenEdits` (see *Frozen chapters*) 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. A value nobody knows changes nothing, and a request that changes nothing writes nothing.
|
|
114
118
|
|
|
115
|
-
**What the summary says.** `AutopilotStateSummary`, which the `state` events carry and `snapshot().summary` holds for a client that connects later, has
|
|
119
|
+
**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: 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`.
|
|
116
120
|
|
|
117
|
-
**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.
|
|
121
|
+
**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`, `outlineWrittenChanged`, `outlineWrittenAuto` and `outlineWarnings` (see *Outline (Scaletta)*); so do the insights about the frozen chapters: `frozenMigrated`, `frozenChanged`, `frozenAuto`, `frozenReviewed`, `frozenCleared` and `frozenInvalid` (see *Frozen chapters*).
|
|
118
122
|
|
|
119
123
|
### What the interface reads
|
|
120
124
|
|
|
@@ -122,9 +126,9 @@ Data the web app's pages used to have to guess (from the text of a step, from th
|
|
|
122
126
|
|
|
123
127
|
**The final verdict.** When the `final` step is done, `state.finalReview` is `{ verdict, score, text, at }`: the director's judgement of the whole book as data, where the line of the step said `approve 8/10 — …`. `verdict` is `"approve"` or `"revise"` (a `rewrite` is a `revise`, and so is an approval withheld because its score is under the `approvalScore` of `director.md`); the book is closed all the same, as it always was. `score` is on the scale of the chapters (0-10, one decimal at most), `text` is the director's summary cut with `clipText` at `FINAL_REVIEW_TEXT_CHARACTERS` (1200) characters, and `at` is when the director gave it. `summary.finalReview` has the same fields with the text cut at `FINAL_REVIEW_SUMMARY_CHARACTERS` (400). A book that is not complete any more (its chapters were extended, or a `rewrite` reopened it) has none until the final step is done again.
|
|
124
128
|
|
|
125
|
-
**Working time.** `stats.workedMs` is the sum, over every run, of the durations of the steps that were saved, each from its start to its end as its activity shows. Not counted: the wait for the author, the pauses between runs, the attempts of a step that failed and the waits between them (a step counts the attempt that was saved), the steps that were abandoned. A whole number of milliseconds, never negative, in the state (so it outlives the 200 activities of the log) and in `summary.stats`. A state written before it existed has none (and neither has its summary: not zero, not `NaN`) and it counts from zero at the first step that is saved.
|
|
129
|
+
**Working time.** `stats.workedMs` is the sum, over every run, of the durations of the steps that were saved, each from its start to its end as its activity shows. Not counted: the wait for the author, the pauses between runs, the attempts of a step that failed and the waits between them (a step counts the attempt that was saved), the steps that were abandoned. A whole number of milliseconds, never negative, in the state (so it outlives the 200 activities of the log) and in `summary.stats`. A state written before it existed has none (and neither has its summary: not zero, not `NaN`) and it counts from zero at the first step that is saved. `stats.workedMsSince` is the ISO time (UTC, `2026-02-01T08:00:00.000Z`) at which the first step that the count included began: the count is born with the first step it counts, and the moment is written then, once, and never changed after (not by the steps that follow, not by another run), so that a client can say *since when* the time is counted. A book whose count began before the moment was written has `workedMs` and no `workedMsSince`, and the engine does not make one up: it cannot know. Read from a file it is a date or a date and time with its zone (`2026-02-01`, `2026-02-01T10:00:00+02:00`, said again in UTC) and only next to `workedMs`; any other value is dropped.
|
|
126
130
|
|
|
127
|
-
**Errors.** A step that fails puts `errorKind` and `errorDetail` in its activity (the `task-finished` event carries them too) and, when it ends the run, in `state.lastError`; `summary.lastError` has the same two under the names `kind` and `detail` as well. A step that the author cancelled is no failure and has neither. `AutopilotErrorKind` is a closed list (`AUTOPILOT_ERROR_KINDS`), told from what the engine knows of its errors (`classifyAutopilotError(error)` is the one function, a status or a flag deciding before the words do):
|
|
131
|
+
**Errors.** A step that fails puts `errorKind` and `errorDetail` in its activity (the `task-finished` event carries them too) and, when it ends the run, in `state.lastError`; `summary.lastError` has the same two under the names `kind` and `detail` as well. A step that the author cancelled is no failure and has neither. `state.lastError` (and `summary.lastError`) also says *which* step failed: `activityId` is the id of its activity, the one in the log and in the `task-finished` event (the last attempt, when the step was retried), so a client does not have to guess it from the time. A failure that belongs to no step (the ceiling of steps of a run) has none, and neither has an error saved by an engine that did not say it; the id is read from a file only when it is short and made of letters, digits and `_ . : -`. `AutopilotErrorKind` is a closed list (`AUTOPILOT_ERROR_KINDS`), told from what the engine knows of its errors (`classifyAutopilotError(error)` is the one function, a status or a flag deciding before the words do):
|
|
128
132
|
|
|
129
133
|
| Kind | What it is |
|
|
130
134
|
|---|---|
|
|
@@ -138,16 +142,25 @@ Data the web app's pages used to have to guess (from the text of a step, from th
|
|
|
138
142
|
| `budget` | The routing limits leave no candidate to call (`AiRoutingBudgetError`). |
|
|
139
143
|
| `limit` | No context window holds the prompt (`AiPromptTooLargeError`), or the run's own ceiling of steps. |
|
|
140
144
|
| `profile` | A file of the book the autopilot would rewrite cannot be read: its frontmatter is not valid YAML (`FrontmatterError`). The author fixes it. |
|
|
145
|
+
| `config` | The AI configuration has to change, and repeating the step cannot help: with "Tools only" on, no model of the task can call a function (`AiToolsRequiredError`, see *Tools only*). Nothing was sent. |
|
|
141
146
|
| `conflict` | A file changed under the step and the retries are used up (`BookConflictError`). |
|
|
142
147
|
| `unknown` | Everything else. |
|
|
143
148
|
|
|
144
|
-
`errorDetail` is `{ status?, endpoint?, model?, provider?, integration?, attempt?, retries?, timeoutMs?, timeoutPhase? }`, short and with no secret in any field: `status` is the HTTP status when the provider answered; `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.
|
|
149
|
+
`errorDetail` is `{ status?, endpoint?, model?, provider?, integration?, retryAfterMs?, attempt?, retries?, timeoutMs?, timeoutPhase? }`, short and with no secret in any field: `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.
|
|
145
150
|
|
|
146
151
|
**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`). 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` insight), one when it is over and the attempt starts (the summary has no `retry` then), 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.
|
|
147
152
|
|
|
148
|
-
**The rounds of every chapter.** `PlannedChapter.rounds` is a compact history of the rounds of review of a chapter that closed: one `{ director?, readers?, accepted?, rejected? }` for each, oldest first, written when the director judges the round and kept after the chapter is closed (`state.review` is the round in progress and is cleared when the chapter closes). `director` is the director's vote and `readers` the average of the simulated readers' votes (0-10, one decimal at most); `accepted` and `rejected` are what the director decided, whole numbers. The readers read a chapter once, in the first round of its review, so only that round has `readers` (a chapter rewritten after the author's request is reviewed again without readers). A chapter keeps at most `MAX_CHAPTER_ROUNDS` (8): a chapter that is rewritten adds the rounds of its new review and the oldest leave. A chapter that was never reviewed has none (`rounds` is absent, never an empty list), and the history survives the plan being made again around the chapters when the author raises the number of chapters of a finished book. In `state.json` every round takes one line of about
|
|
153
|
+
**The rounds of every chapter.** `PlannedChapter.rounds` is a compact history of the rounds of review of a chapter that closed: one `{ director?, readers?, verdict?, accepted?, rejected? }` for each, oldest first, written when the director judges the round and kept after the chapter is closed (`state.review` is the round in progress and is cleared when the chapter closes). `director` is the director's vote and `readers` the average of the simulated readers' votes (0-10, one decimal at most); `accepted` and `rejected` are what the director decided, whole numbers. `verdict` is `"approve"` (the round closed the chapter) or `"revise"` (it sent the chapter back for fixes): the verdict the plan acted on, which is not always the one the model gave (an approval under the `approvalScore` of `director.md` is withheld and is a `revise`, and a revision with no applicable fix is an `approve`), so a client reads it here instead of from the text of the log. A round saved by an engine that did not say it has none; a `verdict` read from a file is `approve` or `revise` (case and spaces do not matter) or it is dropped, and a verdict with no number is no round. The readers read a chapter once, in the first round of its review, so only that round has `readers` (a chapter rewritten after the author's request is reviewed again without readers). A chapter keeps at most `MAX_CHAPTER_ROUNDS` (8): a chapter that is rewritten adds the rounds of its new review and the oldest leave. A chapter that was never reviewed has none (`rounds` is absent, never an empty list), and the history survives the plan being made again around the chapters when the author raises the number of chapters of a finished book. In `state.json` every round takes one line of about 100 bytes (the file is still plain JSON), so a book of 5000 chapters with three rounds each adds about 1.4 MiB, and with the eight rounds every chapter may keep about 3.9 MiB, to a file the server accepts up to 8 MiB.
|
|
149
154
|
|
|
150
|
-
**
|
|
155
|
+
**The step that is answering.** `task-progress` says that the model of the running step is answering. A step that writes prose says it as it always did: `preview` (the tail of the text so far) and `characters`, at most about three times a second. A step that answers with a structured value (the concept, the plan, a reader's evaluation, the director's decisions, the summary of a scene) says it with numbers only: `{ type: "task-progress", activityId, characters, bytes, preview: "" }`, where `bytes` is what has arrived of the reply and `characters` the characters of its function arguments, never a word of the reply, and **one event a second** for each step at most (the client reports up to four times a second, and the stream of a server is not flooded). It only exists while the provider streams: with `streamMode: "off"` there is nothing to say until the reply is whole. Like every `task-progress` it is never saved (not in `state.json`, not in the log, not a commit) and never replayed to a client that connects later; `snapshot().live` carries the last one (`{ activity, characters, preview, bytes? }`: `bytes` only when the last one was a structured one). The event is the same one the prose steps have: `preview` stays a string (empty here), and `bytes` is the only new field, so a client that knows nothing of it reads `characters` and an empty preview. A step that writes a scene and then asks for its summary says both kinds one after the other, and the empty `preview` of the second replaces the text of the first for a client that copies every `preview` (a client that wants to keep the scene on screen leaves `preview` alone when `bytes` is present). A client of the personal server gets the events as they are (the engine's client hands over every message of the stream, and a type it does not know is the host's to ignore).
|
|
156
|
+
|
|
157
|
+
**What a model declares.** The safe view of the AI configuration (`redactAiRuntimeConfig(config).integrations[].models[]`, which the personal server's `GET /ai` forwards as it is) says, for every model, what its configuration declares: `supportsToolCalls`, `supportsStreaming`, `supportsReasoning`, `supportsVision`, `maxInputTokens` and `maxOutputTokens`, and the `reasoningParameter` that says how its thinking level is sent (the "Thinking parameter" of the model, «Parametro del thinking»: `reasoning_effort`, `chat_template_kwargs.reasoning_strength` or `none`, with `AI_REASONING_PARAMETERS` for the list and `suggestedReasoningParameter(name, underlyingModel?)` for a hint that a screen may offer, which the engine never applies by itself), each only when it is declared or set (a model that declares nothing is `{ name, capabilities }`, as it always was). An attempt says what it did not do because of it: `onAttempt.notes` (English, absent when there is nothing to say; `ChatRequest.notes` for a host that builds the request itself), and `onAttempt.reasoningParameter` where the level went when it did not go as `reasoning_effort`. A reply cut with nothing written by a model declared as reasoning is a `truncated` error with `reasoningOnly`, so its `errorKind` is `truncated` like any cut reply. What an endpoint says of its models, and whether it answers at all, is what `fetchModelCatalog` and `probeEndpoint` return: see *Model catalog and declared capabilities*. All of it is additive: a configuration that declares nothing reads and runs as it always did.
|
|
158
|
+
|
|
159
|
+
**The outline and the ghostwriter of every chapter.** `PlannedChapter.ghostwriter` is the ghostwriter the outline gives the chapter (the slug of `ghostwriters/<slug>.md`), absent when it is the book's; the chapter's `chapter.md` says it too, so a page that shows the chapter reads it where it always did. `PlannedChapter.outlineDigest` is the digest of the chapter's entry of the outline (`outlineEntryDigest`) as it was when the plan followed it, or wrote it: an entry whose `contentDigest` is not the chapter's `outlineDigest` has been changed by the author since (`outlinePlanStatus(reader, state, language)` says which ones, for a chapter not written yet and for the written ones). `plan.removedChapters` lists the chapters taken out of the plan because the author deleted their entry. `options.fillOutline` (on by default, saved with the other options, not changeable while a run is active) says whether the plan fills the outline. `state.concept.logline` is the pitch of the concept, which becomes the description of the outline. New task kind: `replan` (a chapter planned again from its new entry, or taken out of the plan). New insight codes: `outlineGhostwriter`, `outlineChanged`, `outlineRemoved`, `outlineWrittenChanged`, `outlineWarnings`, each with `chapterNumber` (see *Outline (Scaletta)*). An engine from before these fields drops them on its first write; the outline files stay, the next plan of a newer engine reads them again, and a chapter whose plan lost its digest is not planned again from an entry the autopilot wrote (only from one of the author).
|
|
160
|
+
|
|
161
|
+
**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`.
|
|
162
|
+
|
|
163
|
+
**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.
|
|
151
164
|
|
|
152
165
|
### Long books
|
|
153
166
|
|
|
@@ -173,23 +186,157 @@ Values are read as the author wrote them: an autonomy whatever its case (`Full`,
|
|
|
173
186
|
|
|
174
187
|
### Profiles that cannot be read
|
|
175
188
|
|
|
176
|
-
`parseDirector`, `parseGhostwriter` and `
|
|
189
|
+
`parseDirector`, `parseGhostwriter`, `parseReaderPersona` and `parseEvaluationStyle` never throw and never hide a problem: they return `warnings: string[]` (empty when the file is as it says), each naming the file. A warning is YAML that cannot be read (with its line), a value that is not understood (an autonomy nobody knows, a score that is not a number, a list that is not a list, a reader type that is none of `standard`, `genre`, `custom`, a switch that is neither yes nor no, a criterion of the evaluation style that cannot be read), and the profile then has the default for that value, as it always had. The defaults themselves carry `warnings: []`.
|
|
177
190
|
|
|
178
191
|
A profile with warnings is not what the author wrote, so the engine never goes on with it silently and never replaces the file with the defaults:
|
|
179
192
|
|
|
180
|
-
- before a step, the autopilot checks the director, the files of the simulated readers when readers are used, and the ghostwriter of the chapter for a step that writes. When one has warnings it spends nothing, emits an insight with code `profileProblems` and stops with `status: "waiting-author"` and a `message` that lists the problems (in the language of the book); the author corrects the file and resumes.
|
|
193
|
+
- before a step, the autopilot checks the director, the evaluation style (`evaluation-guidelines.md`, when the book has one), the files of the simulated readers when readers are used, and the ghostwriter of the chapter for a step that writes. When one has warnings it spends nothing, emits an insight with code `profileProblems` and stops with `status: "waiting-author"` and a `message` that lists the problems (in the language of the book); the author corrects the file and resumes.
|
|
181
194
|
- `askDirector` still gives its opinion, and reports the problems of `director.md` in `warnings` next to it.
|
|
182
195
|
- a host that saves a profile should not do it over a file that has warnings.
|
|
183
196
|
|
|
197
|
+
## Outline (Scaletta)
|
|
198
|
+
|
|
199
|
+
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.
|
|
200
|
+
|
|
201
|
+
### The files
|
|
202
|
+
|
|
203
|
+
| Path | Frontmatter | Body |
|
|
204
|
+
|---|---|---|
|
|
205
|
+
| `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. |
|
|
206
|
+
| `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. |
|
|
207
|
+
|
|
208
|
+
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.
|
|
209
|
+
|
|
210
|
+
### Who wrote an entry: `origin` and `digest`
|
|
211
|
+
|
|
212
|
+
- `origin: author`, or no `origin`: the author's. It binds the autopilot, which never rewrites it.
|
|
213
|
+
- `origin: autopilot` with a `digest`: written by the autopilot from its plan. The digest is `outlineEntryDigest({ title, body, ghostwriter })` of what it wrote: sixteen hexadecimal characters of a SHA-256, where line endings and the spaces around the texts do not count. While the entry still matches its digest it is *intact*: the autopilot's own, which binds nothing and which the autopilot may write again when its plan changes. As soon as the author changes its title, its text or its ghostwriter it no longer matches it, and it is the author's.
|
|
214
|
+
- An entry whose frontmatter cannot be read is the author's: it is read as far as it can be (its text is all there), the author is told, and the autopilot never rewrites it.
|
|
215
|
+
- The description of the book follows the same rules, with `outlineBookDigest({ title, body })`.
|
|
216
|
+
|
|
217
|
+
`parseOutline(files)` (pure: no I/O) gives `{ book, chapters, warnings }`. Every entry has `number`, `title` (empty when it has none), `body`, `ghostwriter?`, `origin`, `digest?`, `contentDigest` (the digest of what it says now), `intact`, `unreadable?`, its `frontmatter` and the `hash` of its file. It never throws: two files for one chapter (`007.md` and `0007.md`: the one named as the core names it counts), a number that is not the file's, an `origin` nobody knows, a text over `OUTLINE_ENTRY_MAX_CHARS` (20 000 characters), YAML that cannot be read, a file of `outline/` that is not an entry and chapters without an entry between two that have one are warnings: `{ code, message, path?, number? }`, the message in English and naming the file.
|
|
218
|
+
|
|
219
|
+
### Editing it
|
|
220
|
+
|
|
221
|
+
`outlineChanges({ outline, edit, ghostwriters? })` makes an edit of the author into `{ changes, warnings }`: the `BookFileChange[]` of one commit, each expecting the file as it was read (`null`: a file that must not exist yet), so an edit made on an outline that changed in the meantime is refused by the store instead of overwriting it. `outline` is what `parseOutline` read, with the hashes of the files; `ghostwriters` the slugs of the book's ghostwriters (without it they are not checked). The edits:
|
|
222
|
+
|
|
223
|
+
| `edit` | What it does |
|
|
224
|
+
|---|---|
|
|
225
|
+
| `{ kind: "append", entry }` | A chapter after the last one. |
|
|
226
|
+
| `{ kind: "insert", at, entry }` | A chapter at position `at`; the entries from there on move one number up. Inserting at the head of an outline of 5000 chapters is 5000 renames and one new file, in the same list. |
|
|
227
|
+
| `{ kind: "move", from, to }` | The entry `from` goes to position `to`, the ones in between follow. |
|
|
228
|
+
| `{ kind: "remove", number, renumber? }` | Deletes the entry and leaves its number empty; with `renumber: true` the following ones move one number down. |
|
|
229
|
+
| `{ kind: "update", number, entry }` | Changes the `title`, the `body` or the `ghostwriter` given (`ghostwriter: null` takes it away: the book's writes); creates the entry when there is none. |
|
|
230
|
+
| `{ kind: "book", title?, body? }` | Changes the working title or the description. |
|
|
231
|
+
|
|
232
|
+
`entry` is `{ title?, body?, ghostwriter? }`. Every entry an edit writes or moves is the author's (`origin: author`, no `digest`): an outline the author arranged is never undone by the autopilot. An entry whose frontmatter cannot be read is moved as it is; one that is edited is written anew from the edit, with a warning. What the outline says is never an error: a ghostwriter that does not exist (`ghostwriter-missing`) or is not a file name (`ghostwriter-invalid`), a text cut at 20 000 characters (`text-too-long`), a title cut at `OUTLINE_TITLE_MAX_CHARS`, 200, because it names the chapter's folder (`title-too-long`), and the chapters left without an entry (`gap`) are warnings. Only an argument that is not a number of a chapter throws. `serializeOutlineChapter(entry)` and `serializeOutlineBook(book)` write one file.
|
|
233
|
+
|
|
234
|
+
### What the autopilot does with it
|
|
235
|
+
|
|
236
|
+
- **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.
|
|
237
|
+
- **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.
|
|
238
|
+
- **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.
|
|
239
|
+
- **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.
|
|
240
|
+
- **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`).
|
|
241
|
+
- **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, and decided once the chapter is closed; one that was deleted is said once a run (`outlineWrittenChanged`) and the chapter stays in the book.
|
|
242
|
+
- **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.
|
|
243
|
+
|
|
244
|
+
## Frozen chapters
|
|
245
|
+
|
|
246
|
+
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).
|
|
247
|
+
|
|
248
|
+
### The record
|
|
249
|
+
|
|
250
|
+
```yaml
|
|
251
|
+
frozen:
|
|
252
|
+
at: 2026-01-01T00:00:00.000Z # when (ISO 8601, UTC)
|
|
253
|
+
by: autopilot # or author
|
|
254
|
+
digest: 0f1e2d3c4b5a6978 # the body of chapter.md, its title heading excluded
|
|
255
|
+
files: # every scene, by the name of its file in the chapter's folder
|
|
256
|
+
001-the-arrival.md: 8a7b6c5d4e3f2a1b
|
|
257
|
+
```
|
|
258
|
+
|
|
259
|
+
- **What it fingerprints.** The text, never the frontmatter: a new summary, an id rewritten by a rename, a new title (and the `# Title` line of chapter.md that repeats it), line endings, spaces at the end of a line and the Unicode normalization are no change. A scene is named by its file in the folder, so a folder that is renamed or renumbered keeps its record; a scene file renamed with the same text is no change, two scenes that swapped their texts are. The digests are sixteen hexadecimal characters of a fast 64-bit hash (`textFingerprint`, `chapterBodyDigest`, `sceneBodyDigest`): they tell a change, they do not protect against one.
|
|
260
|
+
- **Read once.** `loadBookSnapshot` computes the digest of every chapter.md and scene when it reads the file, which it does once for each content (`SnapshotCache`): `ChapterInfo.bodyDigest`, `ParagraphInfo.bodyDigest`, the whole document of chapter.md in `ChapterInfo.document`, and the record in `ChapterInfo.frozen`. A record that cannot be read (`frozen: yes`, a digest that is not one, a moment that is not one…) is `ChapterInfo.frozenProblem` and the chapter counts as **not frozen**: it never blocks anything (the run says it once with `frozenInvalid`, and the core's doctor warns with `chapter-frozen-invalid`). `frozen: false`, or no key, is no record. A record is read tolerantly (`by: Author`, a moment in any zone, digests in capitals) and normalized.
|
|
261
|
+
- **Pure functions** (`book/freeze.ts`, no I/O): `freezeChapterChanges(snapshot, slug, by, at)`, `markReviewedChanges(snapshot, slug, at)` (frozen again as it is, keeping `by`) and `unfreezeChapterChanges(snapshot, slug)` answer the `BookFileChange[]` of one compare-and-swap commit of chapter.md (every other key and the body as they are; the file is made for a folder of scenes that has none; a chapter that does not exist is `FrozenChapterError` `chapter_not_found`, a frontmatter that cannot be read `FrontmatterError`). `frozenChanges(snapshot)` answers every frozen chapter whose text changed, in the order of the book: `{ number, slug, title, path, by, frozenAt, changed: { added, removed, modified, body }, fingerprint }`, where `fingerprint` is the same for the same edits and another for any other. It reads nothing: 5000 frozen chapters are checked in a few milliseconds, and a snapshot loaded again reads only the files whose hash changed. `parseChapterFreeze(value)` and `chapterFreezeRecord({ at, by, chapterBody, scenes })` are the reading and the making of a record.
|
|
262
|
+
- **The core** declares the key: `chapterFreezeSchema` (its shape) and `chapterSchema.frozen` (kept as it is, whatever it holds: a tool that rewrites chapter.md never drops it).
|
|
263
|
+
- **A whole text from elsewhere.** `keepChapterFreeze(proposed, current)` is chapter.md as a host writes it from a whole text it did not make itself (a proposal of a model, a tool that writes any file): with the record the file holds now, exactly, and with none when it holds none; everything else as written. A model never freezes a chapter or takes its freeze away, so its change of a frozen chapter is noticed like the author's, and a record it made up is dropped. A frontmatter that cannot be read, in either text, leaves the text as it is. The site's Copilot and the server's MCP `write_file` call it for the paths `parseChapterFilePath` reads.
|
|
264
|
+
|
|
265
|
+
### When the autopilot freezes
|
|
266
|
+
|
|
267
|
+
- **When it approves a chapter**: the closing of the chapter (`consolidate`) writes the record in the same commit as its summary, from the texts it read. A chapter frozen by the author keeps `by: author` when the autopilot closes it again.
|
|
268
|
+
- **After a revision** that rewrote a frozen chapter: the chapter is reviewed and closed again, so it is frozen again.
|
|
269
|
+
- **Never a chapter the author wrote** (`imported`): only the author freezes those (`freezeChapter`).
|
|
270
|
+
- **An older book.** A state saved before frozen chapters existed has no `state.frozenSince`: its first run freezes the chapters the autopilot approved (status `done`, not imported, with no record) in one `freeze` step that needs no model, says it once (`frozenMigrated`), and sets `frozenSince`; a new state has it from its creation. A chapter the author unfreezes afterwards stays unfrozen until the autopilot closes it again.
|
|
271
|
+
|
|
272
|
+
### When a frozen chapter changes: `options.frozenEdits`
|
|
273
|
+
|
|
274
|
+
Before every step the run compares the frozen chapters with their records (and the outline entries of the chapters already closed with the digest the plan keeps of them), and does with every change that has no decision yet what `options.frozenEdits` says:
|
|
275
|
+
|
|
276
|
+
| Mode | What happens |
|
|
277
|
+
|---|---|
|
|
278
|
+
| `ask` (the default) | The run stops (`waiting-author`) with a question, before anything else is done or spent: one change at a time, in the order of the book, the question saying which other chapters changed too. |
|
|
279
|
+
| `auto` | The change is reviewed and the book updated from it (`review-and-update`; for an outline entry, `rewrite-to-outline`) without asking, with the insight `frozenAuto` (`outlineWrittenAuto`). A chapter the author wrote is never rewritten for a decision of the autopilot: its outline change is only said, and the impact of a change never rewrites one. |
|
|
280
|
+
| `notify` | Every change is said once (`frozenChanged`, `outlineWrittenChanged`; its fingerprint is kept in `state.frozenSeen`, so it is not said again in another run), and nothing is done. |
|
|
281
|
+
|
|
282
|
+
The option is saved with the others, read tolerantly (any case; a value nobody knows changes nothing) and can change while a run goes on (`LIVE_AUTOPILOT_OPTIONS`).
|
|
283
|
+
|
|
284
|
+
- **What is never asked about**: the chapters the autopilot has in its hands (being written or reviewed, rewritten by the revision in progress, or the change being carried out): what happens to their files then is its own work. While it finishes work the author asked for (a revision, the chapters it rewrote reviewed again, the review of a change) no new question is asked: what it rewrites is frozen again at its end, and a change it did not reach is asked about once it is over.
|
|
285
|
+
- **A scene deleted** from a frozen chapter is a change to ask about: the plan follows the files of a frozen chapter, so the scene is never written again in silence (a chapter that is not frozen is reconciled as it always was).
|
|
286
|
+
- **A change taken back** withdraws its question; a change changed again is asked again (the question's `id` is `frozen-<number>-<fingerprint>`). A question that is open stops every run until it is answered.
|
|
287
|
+
|
|
288
|
+
### The question
|
|
289
|
+
|
|
290
|
+
`state.question` has `kind: "frozen-change"` ("You changed chapter 3, frozen on 2026-02-01. What should I do?", in the language of the book) or `kind: "outline-change"`, the typed `choices` (`{ id, label }`), the same labels in `options` (for an interface that only shows those), the context in words (what changed, the other chapters) and `frozen`: `{ kind, number, slug, fingerprint, title?, by?, frozenAt?, changed?, others? }`. The run's `message` says why it stopped.
|
|
291
|
+
|
|
292
|
+
`session.answer({ questionId, choice })` chooses by `id`; so does `answer: "<id>"`, and so does a label in either language, which is what an interface that shows `options` sends (and what an older personal server forwards, as it forwards `answer`). `accept: true` without a choice keeps the author's text (`mark-reviewed`; `keep-text` for the outline). Any other text reviews and updates the book (rewrites to the outline) with the text as the author's note for the director; with `asRule` it becomes a permanent rule too. An empty answer chooses nothing (`FrozenChapterError` `invalid_action`).
|
|
293
|
+
|
|
294
|
+
### The actions
|
|
295
|
+
|
|
296
|
+
| Action | What it does |
|
|
297
|
+
|---|---|
|
|
298
|
+
| `review-and-update` ("Review and update the book from this change") | The changed chapter goes back to review, before the plan: one round of the director (and of the specialists when they are on), without readers, whose accepted fixes are advice for the author and are **never applied** (the author's change stands); the round joins its `rounds`, and the chapter is closed (summary, story so far) and frozen again. Then the later chapters already written are checked: a revision (`state.revision` with `afterChapter`, analyzed with the tool `revision_impact`) is given BEFORE (what the autopilot knew of the chapter when it was frozen: its summary, key events and story so far at its close) and AFTER (its new closing), and chooses the scenes of the later chapters to rewrite; they are rewritten (`revise`), reviewed, closed and frozen again. The book's final judgement is made again. |
|
|
299
|
+
| `review-only` ("Only review the chapter") | The same round of the director on the changed chapter, and its closing, frozen again: nothing is rewritten and the later chapters are not checked. A complete book stays complete. |
|
|
300
|
+
| `mark-reviewed` ("Mark as reviewed") | Frozen again as it is, at once, without the model. For an outline entry, the same as `keep-text`. |
|
|
301
|
+
| `rewrite-to-outline` ("Rewrite the chapter to follow the outline") | The plan of the chapter follows the new entry (its purpose becomes the entry's text, its key events are dropped, `outlineDigest` is the entry's), and a revision limited to the chapter (`onlyChapter`) rewrites the scenes the new entry requires; the chapter is reviewed as usual (fixes applied), closed and frozen again, and then the later chapters are checked as for `review-and-update` (unless nothing was rewritten). |
|
|
302
|
+
| `keep-text` ("Keep the text, update only the outline") | The plan follows the new entry (`outlineDigest`), nothing is rewritten. |
|
|
303
|
+
|
|
304
|
+
A decision that needs the model is recorded in `state.pendingReviews` and carried out by the next run before it goes on with the plan (by a run in progress, at its next step), one at a time, in the order of the book; one whose change is gone by then is dropped (`frozenCleared`), and when it is over the run says it (`frozenReviewed`).
|
|
305
|
+
|
|
306
|
+
### For the hosts
|
|
307
|
+
|
|
308
|
+
- `session.frozenStatus()` answers `{ mode, changes, pending, warnings }`: every change, in the order of the book, with `kind`, `number`, `slug`, `title`, `fingerprint`, the `actions` that can be done with it now (all of its kind for a chapter of the plan; only `mark-reviewed` for a chapter the autopilot has no plan for), `by`, `frozenAt` and `changed` (a frozen chapter), `outline` (`{ title, digest }` of the new entry) and the decision already recorded (`pending: { action, at }`); the decisions recorded; and the chapters whose record cannot be read. It refreshes `summary.frozenChanges`.
|
|
309
|
+
- `session.resolveFrozenChange(number, action, { kind?, note? })` decides about a change, as the answer to the question would, also while a run goes on: `mark-reviewed` at once (one commit of chapter.md, and of the state when there is something to close), `keep-text` at once (at the next step of a run in progress); the others recorded for the run. `kind` (`frozen` or `outline`) tells the change of a chapter that has both; without it the action says it. Refused with `FrozenChapterError`: `chapter_not_found`, `not_changed` (nothing to decide about), `invalid_action` (`FROZEN_CHAPTER_ERROR_CODES`). Answers the status after it.
|
|
310
|
+
- `session.freezeChapter(slug)` and `session.unfreezeChapter(slug)` freeze a chapter by hand (`by: author`, as it is now: a change is accepted) or take its record away; the decisions that waited for it are dropped. They answer `{ slug, number, frozen }` (the record, or `null`).
|
|
311
|
+
- `summary.frozenChanges` counts the chapters with a change that waits for the author (a change with a decision recorded does not count), so that a band or a dock says it without the state: what the run found before its last step, or the last `frozenStatus()`. It is absent when none waits (a book without changes has the summary it always had).
|
|
312
|
+
- The routes of the personal server are in *The personal server client*.
|
|
313
|
+
|
|
314
|
+
## Evaluation style
|
|
315
|
+
|
|
316
|
+
`evaluation-guidelines.md`, the "Evaluation style" page of the web app, says how the author judges the book: `criteria`, a mapping of keys to `{ description }` (as the site writes it; a description written as text, a criterion left empty, and a list of `{ name, description }` are read as well), and a body with the critical method, the severity and the structure of a written evaluation. `parseEvaluationStyle(raw)` reads it as `{ title, criteria: [{ name, description }], body, path, warnings }` and `loadEvaluationStyle(store)` reads it from a book (`null` without the file). Like a profile it never throws and never drops a criterion in silence: YAML that cannot be read (with its line) and a criterion that cannot be read are warnings that name the file, and a file with warnings stops the run before it spends anything (`profileProblems`).
|
|
317
|
+
|
|
318
|
+
The autopilot judges with it:
|
|
319
|
+
|
|
320
|
+
| Step | What it reads |
|
|
321
|
+
|---|---|
|
|
322
|
+
| The director's review of a chapter | The criteria, the method and the severity. |
|
|
323
|
+
| The specialists (`FINDINGS`) | The criteria and the severity. |
|
|
324
|
+
| The final judgement of the book | The criteria, the method and the severity (`askDirector` takes it as `evaluationStyle`; an opinion asked by a host is unchanged unless the host passes it). |
|
|
325
|
+
| The review of the plan | Only the method and the severity: the criteria judge chapters. |
|
|
326
|
+
|
|
327
|
+
`evaluationStyleBlock(style, { criteria? })` is what a prompt carries: a block among the data of the request (the author's file, never instructions), delimited by its title and `END OF THE EVALUATION STYLE`, at most `EVALUATION_STYLE_MAX_CHARS` (3000) characters: the criteria first, each at most 400 characters, with a line that says how many are not listed when they do not all fit, then the method, cut with `clipText`, which keeps a part of its own however many criteria there are. The request says to judge with it. The score keeps its scale (0-10), the tools keep their schemas, and the sections a written evaluation would have do not change the answer: the criteria guide the judgement. A book without the file, or with a file that says nothing, sends the requests it always sent.
|
|
328
|
+
|
|
184
329
|
## Files in the book
|
|
185
330
|
|
|
186
331
|
| Path | Content |
|
|
187
332
|
|---|---|
|
|
188
333
|
| `director.md` | Director profile (`type: director`). |
|
|
334
|
+
| `evaluation-guidelines.md` | The evaluation style: criteria, method and severity. See *Evaluation style*. |
|
|
335
|
+
| `outline/book.md`, `outline/chapters/<NNN>.md` | The outline (Scaletta): the description of the book and one entry per chapter. See *Outline (Scaletta)*. |
|
|
189
336
|
| `autopilot/state.json` | Autopilot state: brief, options, plan (with the compact `rounds` of review of every chapter), review cycle, rules, interventions, statistics (with `workedMs`), the final review of the book (`finalReview`) and the last error with its kind. |
|
|
190
337
|
| `autopilot/activity.json` | Last 200 activities (what, why, next, result, model, tokens, cost). |
|
|
191
338
|
| `autopilot/plan.md` | Human-readable mirror of the plan. |
|
|
192
|
-
| `chapters/<chapter>/chapter.md` | The chapter, with its `summary` (written when it is closed, or by the summary step for a chapter the author wrote)
|
|
339
|
+
| `chapters/<chapter>/chapter.md` | The chapter, with its `summary` (written when it is closed, or by the summary step for a chapter the author wrote), its `ghostwriter` when the outline gives it one that is not the book's, and its freeze record (`frozen`) once the director approved it or the author froze it: see *Frozen chapters*. |
|
|
193
340
|
| `resumes/` | `total.md` (one section per chapter) and `chapters/<chapter>.md` (the recap of each one). |
|
|
194
341
|
| `evaluations/director/` | Director opinions (`book.md`, `chapters/<chapter>.md`, `paragraphs/<chapter>/<paragraph>.md`). |
|
|
195
342
|
| `evaluations/readers/` | Simulated reader evaluations, in the same format as the web app. |
|
|
@@ -227,16 +374,16 @@ What every host gets, whatever its options:
|
|
|
227
374
|
|
|
228
375
|
| What | How |
|
|
229
376
|
|---|---|
|
|
230
|
-
| Request | `buildChatRequest(candidate, request, { githubModelsBaseUrl })` is the only place a request is built: URL, headers, body, streaming, tools or JSON-in-prompt, and the output limit parameter of the model family. Pure and exported, so hosts can test their configuration against it. Every request streams (`stream: true`, `stream_options: { include_usage: true }`), a structured one included, unless the integration's `streamMode` is `"off"`: see *Timeouts and streaming*. |
|
|
231
|
-
| Output limit | A structured request gets at least `STRUCTURED_OUTPUT_FLOOR` (4096) tokens. A model known to reason by name (o1/o3/o4, gpt-5, codex-mini; for Azure the declared underlying model, else the deployment name) gets `REASONING_OUTPUT_MARGIN` (12 000) more, because its reasoning is counted in the limit. Never above the model's own `maxOutputTokens`. An Azure deployment of unknown identity gets `max_completion_tokens` from API version 2024-09-01, `max_tokens` before. |
|
|
377
|
+
| Request | `buildChatRequest(candidate, request, { githubModelsBaseUrl })` is the only place a request is built: URL, headers, body, streaming, tools or JSON-in-prompt, and the output limit parameter of the model family. Where the thinking level goes (`reasoning_effort`, or the chat-template argument the model says: see *Thinking*) is decided there too. Pure and exported, so hosts can test their configuration against it. Every request streams (`stream: true`, `stream_options: { include_usage: true }`), a structured one included, unless the integration's `streamMode` is `"off"` or the model declares `supportsStreaming: false`: see *Timeouts and streaming* and *Declared capabilities of a model*. |
|
|
378
|
+
| Output limit | A structured request gets at least `STRUCTURED_OUTPUT_FLOOR` (4096) tokens. A model known to reason by name (o1/o3/o4, gpt-5, codex-mini; for Azure the declared underlying model, else the deployment name) gets `REASONING_OUTPUT_MARGIN` (12 000) more, because its reasoning is counted in the limit; so does a model whose configuration declares `supportsReasoning: true` (a declaration never takes away the margin of a model known by its name). Never above the model's own `maxOutputTokens`. An Azure deployment of unknown identity gets `max_completion_tokens` from API version 2024-09-01, `max_tokens` before. |
|
|
232
379
|
| Prompt size | A candidate whose `maxInputTokens` (context window) cannot hold the prompt (estimated with `likelyMessageTokens`, the tool schema included, against `resolveModelTokenBudgets`: window minus the output reserve minus a 5% margin) is skipped. If no candidate can, `AiPromptTooLargeError` (not retryable) gives the estimate and the largest budget. A prompt is never cut. |
|
|
233
380
|
| Privacy of fallbacks | `fallbackDisclosure.sameBoundaryOnly` excludes fallbacks outside the primary's integration (the boundary). `requireAcknowledgement` asks `options.acknowledgeFallback(from, to, { capability, label })` before content goes to an integration it has not gone to: only `true` allows it, a throw cancels the call, and a host without the hook (the server) never crosses (fail closed). The engine asks at every call that needs the crossing (once per pair of accounts within a call), so a host that remembers acknowledgements answers from its memory. When nothing is left to call, the error names the setting and how to change it. |
|
|
234
381
|
| Routing limits | `routingExecution`: `maxCandidates`, `maxTotalDurationMs`, `maxTokenAttempts`, `maxEstimatedCost`. The total time never interrupts the first candidate before its own timeout; later candidates start only while time remains and run for what remains. Tokens and cost are estimated per attempt from the real prompt and the output limit (reasoning margin included): candidates are kept while the sum fits, and a first attempt that alone exceeds a limit gives `AiRoutingBudgetError`. A configuration without these fields (saved by an older host) has no such limits and no privacy policy. |
|
|
235
382
|
| 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*. |
|
|
236
|
-
| 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*). `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` and `durationMs`, for every attempt that was sent, failed ones included. A hook that throws never breaks a call. |
|
|
383
|
+
| 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` and `durationMs`, for every attempt that was sent, failed ones included. A hook that throws never breaks a call. |
|
|
237
384
|
| 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. |
|
|
238
385
|
| 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. |
|
|
239
|
-
| 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
|
|
386
|
+
| 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*). |
|
|
240
387
|
|
|
241
388
|
### Timeouts and streaming
|
|
242
389
|
|
|
@@ -271,7 +418,48 @@ An integration without its own value says `the default provider timeout` or `the
|
|
|
271
418
|
|
|
272
419
|
**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`.
|
|
273
420
|
|
|
274
|
-
**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 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.
|
|
421
|
+
**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.
|
|
422
|
+
|
|
423
|
+
### Tools only
|
|
424
|
+
|
|
425
|
+
Every autopilot agent answers through a function of its own (the concept, the plan, a reader's evaluation, the director's decisions, the summary of a scene… each has its schema, and the request forces the call with `tool_choice`): the answer is a field that is parsed, not a JSON that the message asked for and that the engine had to find in some text. *Tools only* makes that the only way. It is on unless the configuration turns it off: `AiRuntimeConfig.toolsOnly`, which `pickAiRuntimeConfig` reads from `settings.aiToolsOnly` (and from `toolsOnly` in a configuration that was already picked, which is what a personal server stores and reads back; the settings' own word wins when both are there, and a value that is not a boolean is ignored). A host with no such setting has it on. `redactAiRuntimeConfig(config).toolsOnly` says what is in force.
|
|
426
|
+
|
|
427
|
+
With Tools only on, a request with a function (`json`; a request for prose never changes) behaves like this:
|
|
428
|
+
|
|
429
|
+
- **A model marked as without tool calls is skipped** (`supportsToolCalls: false`: the "Forced tool calls" switch of the model in AI Integrations), a primary and a fallback alike, and nothing is sent to it. A model whose tool calls were never declared is asked as before: only an explicit `false` skips. The privacy policy is applied to the whole route first (a skipped primary is still the account that `sameBoundaryOnly` keeps the content in), and the position of a candidate in the route (`onAttempt.index`) does not move. `AttemptPlan.skipped` and `onAttempt.skipped` say what was left out (`[{ model, reason: "no-tool-calls" }]`, the same list on every attempt of the call, absent when nothing was skipped), and the final error of a call that failed says it too: `Skipped "beta-model" in "Beta": it is marked as without tool calls and "Tools only" is on.` The route is cut to `maxCandidates` before the skipping, so a skipped candidate counts against it.
|
|
430
|
+
- **If none is left**, the call ends before anything is sent with `AiToolsRequiredError` (an `AiProviderError`, not retryable, with `models`: the names of the models that were left out). Its message names them and says the two ways out: `"Tools only" is on, and every model this task can use is marked as without tool calls ("alpha-model" in "Alpha"), so a structured answer has nowhere to go. Turn on "Forced tool calls" for the model in AI Integrations, or turn off "Tools only" in the AI Router. Nothing was sent.` Its `errorKind` is `config`: the configuration has to change, so the run stops at once instead of retrying (see *What the interface reads*).
|
|
431
|
+
- **The answer must be the call of the function.** The arguments of the call are used, however they arrive (whole, or in the pieces of a stream) and with the tolerance they always had (double-encoded, or wrapped in `arguments` or `result`). The text of the reply is never read: not as the answer, and not as a fallback for arguments that are empty (`{}`, still rejected as they were) or that carry none of the expected fields. A reply that has text and no call is rejected, retryable like every rejected reply (the next candidate is tried, and the run repeats the step once with the reason), and what the attempt cost is kept: `openai muse-glimmer-30b: the model answered in text instead of calling the function "result": "Tools only" is on, so the text of a reply is never read as the answer. If this model cannot call functions, turn off "Tools only" in the AI Router.` A reply with nothing at all is still an empty reply.
|
|
432
|
+
|
|
433
|
+
With `toolsOnly: false` it is all as it was: a model without tool calls is used and gets the schema in its system message, and the JSON in a text reply is the answer when the function was not called. `onAttempt.toolsOnly` says which of the two was in force for a call.
|
|
434
|
+
|
|
435
|
+
### Thinking
|
|
436
|
+
|
|
437
|
+
How hard a model is asked to think, per integration and per route target, and in which parameter the level reaches each model. `AiIntegrationConfig.thinking` and `AiRouteTarget.thinking` (the primary and every fallback of a task's route) are one of `AI_THINKING_LEVELS`: `"automatic"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`. `pickAiRuntimeConfig` keeps a level spelled exactly so and drops anything else (the target, or the integration, is kept without it).
|
|
438
|
+
|
|
439
|
+
| The setting | What the request carries |
|
|
440
|
+
|---|---|
|
|
441
|
+
| absent on the target | the level of its integration, when it has one |
|
|
442
|
+
| absent on both | no level |
|
|
443
|
+
| `"automatic"` | no level, even when the integration has one |
|
|
444
|
+
| `"low"`, `"medium"`, `"high"`, `"xhigh"` | the level, in the parameter that the model it goes to says (*How the level is sent*): `reasoning_effort` unless the model says otherwise, in the body of every chat request (OpenAI-compatible, Azure OpenAI, GitHub Models), for prose and for a structured reply, streamed or not |
|
|
445
|
+
|
|
446
|
+
`AiCandidate.thinking` is the level the candidate resolves to (`target.thinking ?? integration.thinking`, absent when neither says), also for a task without a route of its own (then it is the integration's); a fallback has its own, the primary's is never carried to it. The `default` route only chooses the integration of the tasks that have no route, so its `thinking` is not used. `buildChatRequest` sends the four levels and nothing else, in the parameter of the model, and `ChatRequest.thinking` says what it sent; `onAttempt.thinking` is that level and is absent when nothing was sent.
|
|
447
|
+
|
|
448
|
+
*How the level is sent.* Not every model takes its level as `reasoning_effort`, the OpenAI field. Meta's documentation says of Muse Glimmer, the owner's main model, that it takes its level (`low`, `medium`, `high`, `xhigh`) as an argument of its chat template and that `reasoning_effort` is not implemented by llama.cpp (LlmProxy's `docs/model-profiles.md` says the same: «Do not assume the OpenAI field»); ExecuTorch rejects `reasoning_effort` with a 400. So the model says it: `AiChatModelConfig.reasoningParameter`, the **"Thinking parameter"** of the model in AI Integrations («Parametro del thinking» in Italian), one of `AI_REASONING_PARAMETERS`. `pickAiRuntimeConfig` keeps it only when it is spelled exactly so (`normalizeReasoningParameter`), the safe view shows it, and `AiCandidate` carries it.
|
|
449
|
+
|
|
450
|
+
| `reasoningParameter` | What the body carries for a level |
|
|
451
|
+
|---|---|
|
|
452
|
+
| absent, or `reasoning_effort` | `reasoning_effort: "<level>"`, as it always was: a model that does not say is called with the very requests it always had, byte for byte |
|
|
453
|
+
| `chat_template_kwargs.reasoning_strength` | `chat_template_kwargs: { "reasoning_strength": "<level>" }` and no `reasoning_effort`, in the place where `reasoning_effort` goes. It is merged with any other key that `chat_template_kwargs` already has in the body (`applyReasoningLevel` is the one place where a level lands in a body; the body has no other today) |
|
|
454
|
+
| `none` | Nothing, even when the task or the integration asks for a level. The attempt says so in its `notes`: `The thinking level "high" was not sent: "muse-glimmer-30b" has its thinking parameter set to "none".` (a model that is also declared as not reasoning says this one: it is the author's own word) |
|
|
455
|
+
|
|
456
|
+
The levels, and who sets them (the target, the integration, `automatic`), are the same for the three; `supportsReasoning: false` still sends no level, whatever the parameter. `ChatRequest.reasoningParameter` and `onAttempt.reasoningParameter` say where the level went, **only** when it went as the chat-template argument (absent: it went as `reasoning_effort`, or no level was sent), and `thinking` is the level either way. The gateway has to let the field through: LlmProxy does (it rewrites the `model` of the body and caps the token limits, and forwards the rest to the runtime).
|
|
457
|
+
|
|
458
|
+
*The hint.* `suggestedReasoningParameter(modelName, underlyingModel?)` is a pure hint for the screen that offers the setting, never an order: it gives `chat_template_kwargs.reasoning_strength` for the model names that a documented source ties to the chat-template argument, and `undefined` for every other name. Today that is Muse Glimmer and nothing else (`muse-glimmer`, `muse-glimmer-30B`, `meta-models/Muse-Glimmer-30B-GGUF:Q4_K_M`, `unsloth/Muse-Glimmer-30B-GGUF`, `muse-glimmer:30b-mlx`, `meta-muse-glimmer`: what comes before the last `/`, and a tag after the name, do not matter; Muse Spark and every other family are not guessed, because no source says it). The sources are cited in the comment of the function: Meta's "Run inference" and "Prompting guide" pages for Muse Glimmer, and LlmProxy's `docs/model-profiles.md` with its Muse Glimmer profile. With a declared `underlyingModel` (an Azure deployment) that is the name that is read, as `isReasoningModel` does. The engine never applies the hint by itself: a model is called with `reasoning_effort` until its author sets the parameter.
|
|
459
|
+
|
|
460
|
+
*A provider that does not accept it.* A 400 or a 422 that names `reasoning_effort`, `reasoning_strength` or `chat_template_kwargs`, in its message or in its error object (`"param": "reasoning_effort"`), while a level was sent, is a permanent error that is not repeated and says what to change. Either name is a refusal of the level, whichever of the two was sent (a gateway may answer with the name of the one it translated the level into), and the remedy names the setting of the model and offers the other parameter and `none`: `openai muse-glimmer-30b: the model does not accept a thinking level (HTTP 400 — Unrecognized request argument supplied: reasoning_effort). Nothing was applied. Set "Thinking parameter" of the model "muse-glimmer-30b" in AI Integrations to "chat_template_kwargs.reasoning_strength" (the level as an argument of the chat template, as Muse Glimmer takes it) or to "none" (no level is sent), or set thinking to "Automatic" for this task in the AI Router, or for the integration "LlmProxy" in AI Integrations.` When the level was sent as the chat-template argument, the parameter offered first is `"reasoning_effort"` (the OpenAI field). The next candidate of the route is tried (it may have no level, or another parameter); when the run ends on it, its `errorKind` is `provider` and `errorDetail.status` is 400. With no level sent (nothing chosen, `automatic`, `reasoningParameter: "none"` or `supportsReasoning: false`), on any other status, or for an error that talks about the chat template and not about its arguments, the error is the plain one it was. The engine does not know which models reason unless the configuration says it: with `supportsReasoning: false` on a model the level is not sent to it at all (and the attempt says so in its `notes`: `The thinking level "high" was not sent: "muse-glimmer-30b" is declared as not reasoning (supportsReasoning is off).`), so an integration with models of both kinds can carry a level and spare the ones that would refuse it; a model that declares nothing is sent the level, as before, so give a level to an integration that has only models that take one, or to the route targets that use them.
|
|
461
|
+
|
|
462
|
+
`redactAiRuntimeConfig(config)` shows what is set, none of it secret: the level of every integration (`integrations[].thinking`), the route of every routed task with the level of each target (`taskRouting`: `{ primary?, fallbacks }` for each task, `{}` when there is no route), `toolsOnly` and, for every model, what it declares and how its level is sent (`integrations[].models[]`: see *Declared capabilities of a model*, and `reasoningParameter` above).
|
|
275
463
|
|
|
276
464
|
### Costs and budgets
|
|
277
465
|
|
|
@@ -279,16 +467,140 @@ An integration without its own value says `the default provider timeout` or `the
|
|
|
279
467
|
|
|
280
468
|
### Retries
|
|
281
469
|
|
|
282
|
-
A step that failed with a transient provider error is retried up to three times, after about 4 s, 12 s and 36 s (with jitter, never sooner than the provider's `Retry-After`); the `failureRetry` insight carries `attempt`, `retries` and `waitMs`. A rejected reply, or a failure that is not the provider's, is retried once, the first with the reason. The same failure twice in a row that does not depend on the moment (an empty reply, a 500 with the same message) stops the run at once. A reply cut while the model had only reasoned is retried once with an output limit three times larger (`AiRequest.outputBoost`), and the next steps of that kind start with it. `retryDelayMs` is the base delay: every delay scales with it, `0` makes them instant. A pause ends the wait. While the run waits, `summary.retry` says when the next attempt is (see *What the interface reads*).
|
|
470
|
+
A step that failed with a transient provider error is retried up to three times, after about 4 s, 12 s and 36 s (with jitter, never sooner than the provider's `Retry-After`); the `failureRetry` insight carries `attempt`, `retries` and `waitMs`. A rejected reply, or a failure that is not the provider's, is retried once, the first with the reason. The same failure twice in a row that does not depend on the moment (an empty reply, a 500 with the same message) stops the run at once. A failure that is marked as not retryable is never repeated: the run stops with it (a 401, a call that no model can take because Tools only is on, a 400 that refuses the thinking level). A reply cut while the model had only reasoned is retried once with an output limit three times larger (`AiRequest.outputBoost`), and the next steps of that kind start with it; a model declared as reasoning (`supportsReasoning: true`) whose reply is cut with nothing written counts as one that only reasoned, even when its server does not show the reasoning. `retryDelayMs` is the base delay: every delay scales with it, `0` makes them instant. A pause ends the wait. While the run waits, `summary.retry` says when the next attempt is (see *What the interface reads*).
|
|
283
471
|
|
|
284
472
|
### What the model's replies must be
|
|
285
473
|
|
|
286
|
-
- A forced tool call must carry at least one of the schema's required fields (else one of its declared properties);
|
|
474
|
+
- A forced tool call must carry at least one of the schema's required fields (else one of its declared properties). With *Tools only* on (the default) the text of the reply is never read and a reply with no call is rejected; with it off the JSON in the text is used when the call says nothing useful, and a reply with neither is rejected. A rejected reply is retried once with the reason.
|
|
287
475
|
- `<think>` blocks are dropped, and so is everything up to the last `</think>` of a model that never opened it.
|
|
288
476
|
- What the engine escapes in prompts (`&`, `<`, `>`) is un-escaped in prose and in every text field of a structured reply (`unescapePromptData`).
|
|
289
477
|
- The director decides with a score: the reply must carry `verdict` and `score` (0-10; above 10 and up to 100 is read as a percentage). An `approve` below the `approvalScore` of `director.md` counts as `revise`, with the reason in the record, for the plan, every chapter, the final review and `askDirector`.
|
|
290
478
|
- A simulated reader must answer with a score and its reaction. A reader whose reply is still incomplete after the retry is skipped (and said so): the review goes on with those who answered.
|
|
291
479
|
|
|
480
|
+
## Model catalog and declared capabilities
|
|
481
|
+
|
|
482
|
+
*Why.* The models of an integration, their limits and what they can do used to be typed by hand: a model had a switch for tool calls and two numbers, nothing read an endpoint, and the engine did not know whether a model streams, reasons or reads images. An OpenAI-compatible gateway can say all of it. BookWriter reads `GET /models` and `GET /models/details` when the author presses "Read /models", and LlmProxy (the gateway this was built against: its `docs/api-contract.md`) adds `GET /v1/modalities`. The engine reads the same three, validates what comes back, and keeps what a model declares so that its requests follow it. Everything here is additive: a configuration that says none of it is called exactly as it was.
|
|
483
|
+
|
|
484
|
+
### What is read, and from where
|
|
485
|
+
|
|
486
|
+
| Request | Needed | What it gives |
|
|
487
|
+
|---|---|---|
|
|
488
|
+
| `GET <base>/models` | yes | The OpenAI list, `{ "data": [{ "id": … }] }`. Without it there is no catalog. |
|
|
489
|
+
| `GET <base>/models/details` | no | LlmProxy's: for each model its `type` (`chat`, `embedding`, `image`, `speech`, `transcription`, `realtime` or `classifier`), `context_window` (prompt and answer together), `max_output_tokens`, `input_modalities`, `output_modalities`, `endpoints` and `capabilities: { streaming, tools, vision, reasoning }`. |
|
|
490
|
+
| `GET <base>/modalities` | no | LlmProxy's: everything the gateway offers, grouped by type (always the seven, in its own order, the ones that run nothing included) with the paths, the modalities and the models that run for each. |
|
|
491
|
+
| `GET <origin>/api/v1/models` | no | LM Studio's own list, asked only on this computer (see *LM Studio*). |
|
|
492
|
+
|
|
493
|
+
`<base>` is `effectiveAiBase(integration)`: the very base that the chat requests of the integration use (its endpoint, trailing slashes aside, or OpenAI's own), with the key in the same header; `catalogTarget(integration, path)` works it out and is `null` for an integration with no such list. Only integrations of the provider `openai` (any OpenAI-compatible endpoint) have a list to read. Azure OpenAI (a deployment is made by hand, and nobody lists them), GitHub Models (its catalog is at another address and in another shape, which a host reads as it already does) and Microsoft 365 are an `AiCatalogError` of reason `unsupported`, and nothing is sent.
|
|
494
|
+
|
|
495
|
+
**The contract of LlmProxy, as the engine recognizes it.** An entry of `/models/details`:
|
|
496
|
+
|
|
497
|
+
```json
|
|
498
|
+
{ "id": "muse-glimmer-30b", "object": "model", "type": "chat", "context_window": 131072, "max_output_tokens": 8192,
|
|
499
|
+
"input_modalities": ["text", "image"], "output_modalities": ["text"], "endpoints": ["/v1/chat/completions", "/v1/responses"],
|
|
500
|
+
"capabilities": { "streaming": true, "tools": true, "vision": true, "reasoning": true } }
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
- `null` is "not declared": a number that is not a whole number from `CATALOG_MIN_TOKENS` (256) to `CATALOG_MAX_TOKENS` (10 000 000) is absent in the entry the engine makes, never a `0`.
|
|
504
|
+
- **`false` is not "cannot".** The capabilities of a model are `chat && flag`: everything that the administrator did not declare is sent as `false`. A model that streams well, with its box not ticked, says `streaming: false`.
|
|
505
|
+
- LlmProxy's implementation always sends `type`, but the example in its contract leaves it out: an entry with no `type` (or one the engine does not know) has the type `unknown`.
|
|
506
|
+
- `/models/details` and `/modalities` say the same thing about a model. When both are read, what `/models/details` says wins field by field, what only `/modalities` says is kept, and an id that only they know is added (up to 2000).
|
|
507
|
+
|
|
508
|
+
### The parsers
|
|
509
|
+
|
|
510
|
+
Pure: no I/O, no clock. Everything that comes in is data from a server nobody vouches for: it is bounded, validated field by field, never trusted for what it is called (`__proto__`, `constructor` and `prototype` are never an id) and never quoted in an error. The limits are BookWriter's (`fetchModels`, `tokenLimitsFromDetails`).
|
|
511
|
+
|
|
512
|
+
| Function | Reads | Gives |
|
|
513
|
+
|---|---|---|
|
|
514
|
+
| `parseModelList(payload)` | OpenAI `GET /models` | The ids, sorted and without repeats. **All or nothing**, as in BookWriter, so that a wrong answer never replaces a catalog that was right: a payload that is not a list, an entry without a good id (a string of 1 to `CATALOG_MAX_ID_LENGTH` (256) characters, no space at its edges, no control character), an empty list (`empty`), more than `CATALOG_MAX_MODELS` (2000) entries, or a list that says it goes on (`has_more: true`: a first page is not the catalog, and the engine does not follow pages) (`too-large`) is an `AiCatalogError`. |
|
|
515
|
+
| `parseModelDetails(payload)` | `GET /models/details` | `AiModelCatalogEntry[]`, in the order received: `{ id, type, contextWindow?, maxOutputTokens?, inputModalities?, outputModalities?, capabilities }`. The numbers are there only when they are whole and in range; a capability only when it is a boolean; `type` is one of `AI_MODEL_TYPES` (`chat`, `image`, `speech`, `transcription`, `embedding`, `realtime`, `classifier`; case and spaces do not matter) or `unknown`; the modalities are short lower-case words, at most 16. An entry that cannot be one is left out and the others stay; at most 2000 entries are read. Only a payload that is not a list is an `AiCatalogError`. |
|
|
516
|
+
| `parseModalities(payload)` | `GET /modalities` | `AiModalityGroup[]` in the order received: `{ type, endpoints, inputModalities?, outputModalities?, modelCount, models }`. A model with no type of its own has the type of its group; `modelCount` is the gateway's when it is a count, else the models that were read; `endpoints` are short paths, at most 16; at most 32 groups, and 2000 models in each, are read. A payload that is not a list is an `AiCatalogError`. |
|
|
517
|
+
| `tokenLimitsFromDetails(entry)` | an entry | BookWriter's formula: see *The limits*. |
|
|
518
|
+
| `modelFieldsFromCatalogEntry(entry)` | an entry | What the entry can fill in a model of the configuration: see *The limits* and *Declared capabilities of a model*. |
|
|
519
|
+
| `parseLmStudioModels(payload)`, `lmStudioContext(models, id)` | LM Studio | See *LM Studio*. |
|
|
520
|
+
|
|
521
|
+
### Reading an integration
|
|
522
|
+
|
|
523
|
+
`fetchModelCatalog(integration, { fetch?, signal?, timeoutMs? })` gives an `AiModelCatalog`:
|
|
524
|
+
|
|
525
|
+
```ts
|
|
526
|
+
{ models: AiModelCatalogEntry[]; // every model, of every kind, sorted by id
|
|
527
|
+
source: { models: true; details: boolean; modalities: boolean }; // which answers were read
|
|
528
|
+
modalities?: AiModalityGroup[] } // what the gateway offers by kind, when /modalities was read
|
|
529
|
+
```
|
|
530
|
+
|
|
531
|
+
- It asks `GET /models` first (needed), then, together, `/models/details` and `/modalities`. **Every failure of those two is silent**: the catalog is then what `/models` says, an id that only `/models` lists has `type: "unknown"` and says nothing of what it can do, and `source` says which answers were read.
|
|
532
|
+
- **The models of every kind come back, each with its `type`**, so that one call fills the models and the tables of the other tools (images, speech, transcription, embeddings). Without `/models/details` and `/modalities` the list has no kinds and every model is `unknown`: a screen that wants chat models then takes them all, as BookWriter does.
|
|
533
|
+
- A request is a plain GET: `accept` and the header of the key, nothing else, `credentials: "omit"`, `redirect: "error"` (a redirect is refused, not followed: the endpoint it points to is never asked), `cache: "no-store"`, `referrerPolicy: "no-referrer"`. The key is in no message and in no result.
|
|
534
|
+
- *Time.* An endpoint may be silent for `CATALOG_TIMEOUT_MS` (8 s) per request, before it answers and between two pieces of its answer (the silence is what is watched, not the total), and no request lasts more than `CATALOG_TOTAL_CAP_MS` (a minute), so an endpoint that trickles for ever is stopped all the same. `timeoutMs` is the host's choice of the silence, at most ten minutes (the cap is then that long, when it is longer than a minute). No timer outlives a call.
|
|
535
|
+
- *The body* is read in pieces, up to `CATALOG_MAX_BYTES` (600 KB): a type that is not JSON, a length that is not a number or is over the limit is refused before a byte is read; a body that grows past the limit, whatever its length said, is cut where it passes it; the reader is let go however the read ends.
|
|
536
|
+
- A cancelled `signal` is an `AbortError`, never a catalog (a call cancelled before it began sends nothing).
|
|
537
|
+
|
|
538
|
+
**Errors.** A failure of `/models` is an `AiCatalogError` (an `Error` with `name: "AiCatalogError"`, a `reason` and, when an HTTP status gave it, `status`). Its message is in English, names the integration, says why and what to do, and never quotes what the endpoint sent, the address or the key:
|
|
539
|
+
|
|
540
|
+
| `reason` | When | The message says |
|
|
541
|
+
|---|---|---|
|
|
542
|
+
| `unreachable` | No answer: the server is off, the address is wrong, a redirect was refused, the connection dropped (in a browser also CORS, which it cannot tell apart) | check that it runs, the address, the redirect, and CORS |
|
|
543
|
+
| `timeout` | It did not answer, or went silent, within the time; or the whole took longer than the cap | try again |
|
|
544
|
+
| `unauthorized` | 401, 403 | check the key |
|
|
545
|
+
| `not-found` | 404 | the address should end with the version path (`/v1`) |
|
|
546
|
+
| `rate-limited` | 429 | wait and try again |
|
|
547
|
+
| `server-error` | 5xx | it may be busy or restarting: try again |
|
|
548
|
+
| `http-error` | Any other status | check the address and the key |
|
|
549
|
+
| `invalid` | Not JSON, or not a list of models | the address may not be the API base |
|
|
550
|
+
| `empty` | A list with no model | start a model there (a gateway does not list one that is stopped) |
|
|
551
|
+
| `too-large` | More than 2000 models, a list that comes in pages (`has_more: true`), or more than 600 KB | enter the model names by hand |
|
|
552
|
+
| `unsupported` | Azure OpenAI, GitHub Models, Microsoft 365 | there is no list to read |
|
|
553
|
+
|
|
554
|
+
Every message that can be answered by typing says it: *enter the model names by hand*, which is what a host did before and still does.
|
|
555
|
+
|
|
556
|
+
**Providers whose `/models` is not OpenAI's.** Only the OpenAI shape, `{ "data": [{ "id": … }] }`, is read, and a list that comes in pages is refused: nothing here follows pages, and a first page must never pass for the catalog. Checked against the providers' documentation: Anthropic's `GET /v1/models` is `{ "data": [{ "id": …, … }], "has_more": … }` with 20 models to a page (its entries have an `id`, so without the refusal its first page would have been read as everything: it is `too-large`); Together AI answers a bare array; Cohere `{ "models": [{ "name": … }], "next_page_token": … }`; and Ollama's own list (`/api/tags`) is `{ "models": [{ "name": … }] }` (its OpenAI-compatible `/v1/models` is the OpenAI shape and is read). The bare array, `models` and `name` are `invalid`: never a half catalog, and the author enters the names by hand. The limits that a provider declares under other names (Anthropic's `max_input_tokens` and `max_tokens`, OpenRouter's `context_length`) are not read: only LlmProxy's `context_window` and `max_output_tokens` are.
|
|
557
|
+
|
|
558
|
+
### The limits
|
|
559
|
+
|
|
560
|
+
`tokenLimitsFromDetails(entry)` is BookWriter's formula, `{ inputTokens?, outputTokens? }`: **input** is the window minus the answer the model declares, or, when it declares none, minus a quarter of the window up to 4096; an answer with no window is only the answer; an answer that is not smaller than its window is not believed; an input that is not a usable number of tokens (it would be under 256) is not said. A window of 131072 and an answer of 8192 give `{ inputTokens: 122880, outputTokens: 8192 }`; with no answer, an input of 126976.
|
|
561
|
+
|
|
562
|
+
**Mind the difference.** BookWriter's `inputTokens` is what is left for the prompt once the answer is taken off. The engine's `maxInputTokens` is the context window itself (the field is labelled "Context window tokens"), and the engine takes off the answer and a 5% margin itself when it judges a prompt (`resolveModelTokenBudgets`): BookWriter's number put there would take the answer off twice. So `modelFieldsFromCatalogEntry(entry)` is what a host uses to fill a model: `maxInputTokens` is the declared window, `maxOutputTokens` is the declared answer (only when it is smaller than the window) and each capability is there only when it is `true`. `tokenLimitsFromDetails` is for a host that keeps BookWriter's numbers.
|
|
563
|
+
|
|
564
|
+
### Declared capabilities of a model
|
|
565
|
+
|
|
566
|
+
`AiChatModelConfig` has, besides `supportsToolCalls`, `maxInputTokens` and `maxOutputTokens`, three optional booleans: `supportsStreaming`, `supportsReasoning` and `supportsVision`. **Absent is as before**: a candidate that does not say is built into exactly the request it always was. `pickAiRuntimeConfig` keeps them only as booleans (anything else is dropped, so what is stored is picked again unchanged), `AiCandidate` carries them, and a personal server stores them and shows them (`PUT /ai` runs `pickAiRuntimeConfig`; `GET /ai` is the safe view) without any change to the protocol.
|
|
567
|
+
|
|
568
|
+
| Field | What it does |
|
|
569
|
+
|---|---|
|
|
570
|
+
| `supportsToolCalls` | Unchanged: with *Tools only* on, `false` skips the model for a structured request. Anything else is asked as before. |
|
|
571
|
+
| `supportsStreaming` | `false`: the model is called without `stream` and `stream_options` (and with `accept: application/json`), for prose and for a structured request alike (the function is forced all the same), whatever the `streamMode` of the integration says, and the attempt's `notes` say `Streaming was not used: "muse-glimmer-30b" is declared as not streaming (supportsStreaming is off).` It never turns on what `streamMode: "off"` turned off (and then there is no note: the integration already said it). |
|
|
572
|
+
| `supportsReasoning` | `true`: the model gets the output margin of a model that reasons (+12 000, never above its `maxOutputTokens`); a reply cut by the output limit with nothing written is a reply cut while reasoning (`reasoningOnly`: `…the model, which is declared as reasoning, used its output limit before writing the reply (its reasoning counts in the limit)`), which the autopilot retries once with a limit three times larger even when the server does not show its reasoning; and a thinking level may be sent (in the parameter of the model: see *Thinking*). `false`: a thinking level is **not** sent, and the attempt says so (see *Thinking*): a provider is never given a request that it would refuse. A model known to reason by its name keeps its margin whatever `false` says. The temperature and the name of the limit parameter (`max_tokens` or `max_completion_tokens`) do not change either: they follow the family of the model, not whether it reasons, because a local model that reasons takes both. |
|
|
573
|
+
| `supportsVision` | Nothing in a request depends on it: it is data for the interface (the engine sends no image). |
|
|
574
|
+
| `maxInputTokens`, `maxOutputTokens` | As before: the window decides whether a prompt fits (a candidate that cannot hold it is skipped) and no request asks for more than the largest answer. |
|
|
575
|
+
|
|
576
|
+
**Mind the window.** The margin of `supportsReasoning: true` comes out of the context window: the budget of a prompt is the window, minus the output limit of the request (the margin included), minus 5%. A model declared as reasoning with a window of 8192 and no declared answer, asked by a step for 2500 tokens, is asked for 14 500: the budget of the prompt is one token and the model is skipped (`AiPromptTooLargeError`, whose advice is about the window, not about the margin). With a window of 32 768 and a step that asks for 9000, the budget falls from 22 129 to 10 129 tokens; from 65 536 up there is room. Declare the largest answer of the model (`maxOutputTokens`: a catalog fills it in when the gateway declares it): no request asks for more, and the budget is computed with it (a window of 131 072 and an answer of 8192 leave 116 326 tokens for the prompt, margin or not). The same arithmetic has always applied to a model known to reason by its name.
|
|
577
|
+
|
|
578
|
+
`redactAiRuntimeConfig` shows `integrations[].models[]` as `RedactedAiModel`: `{ name, capabilities }` and, only for what the model declares, the six fields above (and its `reasoningParameter`, when it sets one: not a thing a catalog declares, but the author's word on how its level is sent, see *Thinking*).
|
|
579
|
+
|
|
580
|
+
**`false` is not a restriction.** LlmProxy says `false` for everything that nobody declared, so a catalog cannot tell a model that does not stream from one whose administrator did not tick the box. Importing `false` as `supportsStreaming: false` would turn streaming off for a model that works, and as `supportsToolCalls: false` it would take the model off every structured task: **`modelFieldsFromCatalogEntry` never turns `false` into a restriction, it only says `true`**, and a host that merges a catalog does `{ ...model, ...modelFieldsFromCatalogEntry(entry) }`: what the gateway declares wins for the fields it declares (as BookWriter's explicit "Read /models" does), and what it leaves out stays as the author wrote it. A `false` that the author sets by hand is respected. (This is also why the engine, unlike BookWriter, asks a model for a function unless it is marked `supportsToolCalls: false`: see *Tools only*.)
|
|
581
|
+
|
|
582
|
+
### The connection probe
|
|
583
|
+
|
|
584
|
+
`probeEndpoint(integration, { fetch?, signal?, timeoutMs? })` asks an OpenAI-compatible endpoint one short question, `GET <base>/models` (the same request as the first of the catalog, with the key, so that a gateway that refuses it is told from one that is off), and waits `PROBE_TIMEOUT_MS` (4 s, as BookWriter's `localEndpointTimeoutHint` does). It is the base of a "Check the connection" in an error panel (a failure of kind `network` or `timeout`: see *What the interface reads*). The result, `AiEndpointProbe`:
|
|
585
|
+
|
|
586
|
+
| `outcome` | When | The rest |
|
|
587
|
+
|---|---|---|
|
|
588
|
+
| `ok` | A 2xx arrived | `httpStatus`, `latencyMs` (until the answer began), `cors: "ok"` and, when the body is a list of models that could be read in time (up to 256 KB), `models`. A gateway with nothing running answers `models: 0` and the message says to start one. A 2xx that is not a list of models is `ok` all the same, without `models`, and the message says that the address may not be the API base (a web page, say). |
|
|
589
|
+
| `http-error` | Any other status: the server is reachable, and the status says what to fix | `httpStatus`, `latencyMs`, `cors: "ok"`; 401 and 403 say to check the key, 404 the version path (`/v1`), 429 to wait, 5xx that it may be busy or restarting. The body of an error is never read. |
|
|
590
|
+
| `unreachable` | No answer within the time, or the connection failed | `latencyMs`, `cors: "blocked-or-unreachable"`. **In a browser a request that CORS blocked looks exactly like a server that is off, an address that is wrong or a connection that failed**, and the message says so, and what to check. |
|
|
591
|
+
|
|
592
|
+
`message` is in English, with the remedy, and never has the key, the address or a word of what the endpoint sent. The probe throws only for a cancel (`AbortError`) and for an integration with no list to ask (`AiCatalogError`, reason `unsupported`): what the endpoint does is a result, never an exception.
|
|
593
|
+
|
|
594
|
+
### LM Studio
|
|
595
|
+
|
|
596
|
+
`parseLmStudioModels(payload)` reads LM Studio's own `GET /api/v1/models` as BookWriter's `lmstudio-models.ts` does: only the entries of `type: "llm"` (at most `LMSTUDIO_MAX_MODELS`, 500, with keys of at most `LMSTUDIO_MAX_KEY_LENGTH`, 200, characters), each as `{ key, reasoning?, maxContext?, loaded }`. `reasoning` is `{ options, default? }`, the levels the model allows in the engine's order (only `low`, `medium`, `high` and `xhigh` are levels: `off` and `on` are not) and the default when it is one of them; `null` when the server says the model has no level to choose; absent when it says nothing of reasoning. `maxContext` is the longest context the model supports and `loaded` the instances that are loaded now, with the context each was loaded with (at most 16). `lmStudioContext(models, modelId)` finds a model by its key or by the id of a loaded instance, as BookWriter does, and gives `{ loaded?, max? }`.
|
|
597
|
+
|
|
598
|
+
`fetchLmStudioModels(integration, options)` asks for that list at the root of the server (`<origin>/api/v1/models`, whatever path the endpoint has), **only of a server on this computer** (`localhost`, `127.0.0.1` or `[::1]`, with no credentials in its address) and only for an OpenAI-compatible integration; a key that is configured is sent, to this computer only. Anything else, and any failure (a server that is not LM Studio, one that cannot be reached, an answer that is not its list), gives `undefined`: this list is an extra, and the caller keeps what it knew. It throws only for a cancel.
|
|
599
|
+
|
|
600
|
+
### What stays with the host
|
|
601
|
+
|
|
602
|
+
The engine reads and says; it never reads a catalog by itself during a run and never saves one. The host decides when (an explicit "Read models" is what BookWriter does, and every failure there leaves the author typing), which models of the catalog become models of the configuration (the `chat` ones, and the `unknown` ones when neither `source.details` nor `source.modalities` was read), and keeps what the author typed for every field that the gateway leaves out. A host that runs these functions on a server must give them a `fetch` that applies its own policy for the endpoints that a key may be sent to: the functions do not decide that (`effectiveAiBase` is what to compare).
|
|
603
|
+
|
|
292
604
|
## Sync
|
|
293
605
|
|
|
294
606
|
`syncBookStores({ local, remote, base })` is a three-way sync of two `BookStore`s (the browser's working copy and the personal server's): it copies what changed on one side, reports what changed on both (`conflicts`, settled by `resolveConflict`) and returns the `base` to remember for the next one. It reads from a store that has `readMany` a batch of paths at a time, and commits in chunks of at most 400 changes and 24 MiB, so a book of any size passes the limits of one request.
|
|
@@ -310,6 +622,7 @@ A skipped file is not recorded as synced (a file that was never synced stays out
|
|
|
310
622
|
- **Version compatibility.** `serverCompatibility(info)` tells whether the server speaks an API this engine supports (`MIN_SUPPORTED_SERVER_API` to `MAX_SUPPORTED_SERVER_API`, both 1 today): `{ status: "ok" | "server-older" | "server-newer", message }`. A server that does not say which API it speaks is an older one. It never throws; `verifyServerIdentity` returns it as `compatibility`, and so does `client.verifiedInfo()` in `identity`, so the host decides how to show it (update the server, or update the app).
|
|
311
623
|
- **Pairing.** `pairWithServer(options)` still answers the token. `pairWithServerDetailed(options)` answers `{ token, verification?, requestVerification?, compatibility? }`, and `onWaitingApproval({ verification?, compatibility? })` is called while the owner approves. The verification is four digits the server derives (see the server README): while the request waits, the admin panel shows the same four digits next to it (`requestVerification`, which `onWaitingApproval` receives as `verification`), so the owner can tell this device's request from another one; once approved, the panel shows the digits of the token next to the client (`verification` of the result). `onPaired(pairing)` hands over the same details to a host that keeps calling `pairWithServer`. An older server that sends none is fine; a value that is not four digits is ignored.
|
|
312
624
|
- **Signing out.** `client.signOut()` revokes the token the client holds (`DELETE /api/v1/session`) and no other: `{ revoked: true }`, or `{ revoked: false }` when the token was already revoked. A server that cannot be reached is an error, because the token may still be valid there (`forgetSession()` is the older call and reports a revoked token as an error).
|
|
625
|
+
- **The AI status.** `client.aiStatus()` (`GET /api/v1/ai`) answers `ServerAiStatus`: `configured`, the `integrations` without their keys (an integration that sets a thinking level says it), `routedTasks`, `updatedAt` and, while the owner has to approve an endpoint, `pendingApproval`. A server that passes `redactAiRuntimeConfig` on may also say `toolsOnly` (whether Tools only is in force) and `taskRouting` (the route of every routed task, with the thinking level of each target): both are optional, and a client of an older server gets neither (a missing `toolsOnly` is *unknown*, not *on*). `putAiConfig(config)` (`PUT /api/v1/ai`) sends what `pickAiRuntimeConfig` reads, so `toolsOnly` and the `thinking` of the integrations and of the route targets travel with the rest, and a server that runs the same engine keeps them (it picks the configuration when it saves it and when it reads it back).
|
|
313
626
|
- **Quick controls.** Pause at the end of the chapter, the limits of one run and the settings that can change during a run (see *Quick controls* above) go through three calls. A server that implements them announces `SERVER_FEATURE_AUTOPILOT_CONTROLS` (`"autopilot-controls"`) in the `features` of `GET /api/v1/info`, and `serverSupportsAutopilotControls(info)` reads it (never throws; an older server, or an odd answer, says no). Ask before sending what an older server would read as something else: it ignores `limits` (the run would not stop after the step or the chapter that was asked for, and goes on spending) and takes every pause mode but `now` for `after-step` (a `cancel` would pause). The calls need the `run` permission, like the other commands that steer a run, answer the snapshot (`AutopilotSnapshot`, with the server session's `summary`: `pausePending`, `limits`, `publish`), and fail as `{ "code", "message" }` with the status below, which `ServerRequestError` carries as `status` and `code`. Every one also answers 401 `unauthorized`, 403 `scope` (no `run` permission) and 404 `book_not_found`.
|
|
314
627
|
|
|
315
628
|
| Client method | Request | Answer |
|
|
@@ -329,6 +642,27 @@ A skipped file is not recorded as synced (a file that was never synced stays out
|
|
|
329
642
|
|
|
330
643
|
The `code` of a refusal of a rule is the `code` of the engine's `AutopilotRuleError` (`AUTOPILOT_RULE_ERROR_CODES`: `rule_empty`, `rule_too_long`, `rule_not_found`, `rule_changed`, `rule_duplicate`), which a server can answer as it is (`400` for the first, the third and the last, `404` for `rule_not_found`, `409` for `rule_changed`); `isAutopilotRuleErrorCode(error.code)` tells a refusal of a rule from the other codes of `ServerRequestError`. The client sends the text as it is given and an index as it is given (a number that names no rule is `404 rule_not_found`), and what it gets back is the error it always gives, with the status and the code of the server. The answer to a question of the director that is kept as a rule needs nothing new: `answer(bookId, { questionId, answer, asRule: true })` has always carried `asRule` (`QuestionAnswer`), and a note used once is still the default.
|
|
331
644
|
|
|
645
|
+
- **Frozen chapters.** The changes of the frozen chapters and the decisions about them (see *Frozen chapters*) go through three routes, which the engine's session already serves (`session.frozenStatus`, `session.resolveFrozenChange`, `session.freezeChapter` and `unfreezeChapter`). A server that implements them announces `SERVER_FEATURE_AUTOPILOT_FROZEN` (`"autopilot-frozen"`) in the `features` of `GET /api/v1/info`, and `serverSupportsFrozenChapters(info)` reads it (never throws; an older server, or an odd answer, says no): an older server answers `404 not_found` to the routes. The question needs no new route: an answer is the `answer` of `POST …/autopilot/answer` (the `id` of a choice, or its label), which every server forwards. Every call also answers `401 unauthorized`, `403 scope` and `404 book_not_found`, and `503 maintenance` while the server is about to restart.
|
|
646
|
+
|
|
647
|
+
| Client method | Request | Answer |
|
|
648
|
+
|---|---|---|
|
|
649
|
+
| `frozenStatus(bookId)` | `GET /api/v1/books/:id/autopilot/frozen`, permission `read`. | `200` the `FrozenStatus` (`{ mode, changes, pending, warnings }`). |
|
|
650
|
+
| `resolveFrozenChange(bookId, number, action, { kind?, note? })` | `POST /api/v1/books/:id/autopilot/frozen/:number` with `{ "action": "review-and-update" \| "review-only" \| "mark-reviewed" \| "rewrite-to-outline" \| "keep-text", "kind"?: "frozen" \| "outline", "note"?: string }`, permission `run`. Also while the autopilot runs. | `200` the `FrozenStatus` after it. `400 invalid_request` for a body that is not a JSON object, a number that is not a whole number from 1, or a `note` that is not text; `400 invalid_action`; `404 chapter_not_found`; `409 not_changed` (nothing to decide: it was decided, or taken back, elsewhere); `409 conflict` (the files kept changing under the write: try again); `409 state_corrupt`; `422 frontmatter_invalid` (the chapter.md cannot be read: the author corrects it). |
|
|
651
|
+
| `freezeChapter(bookId, slug, frozen)` | `POST /api/v1/books/:id/chapters/:slug/freeze` with `{ "frozen": boolean }`, permission `write`. | `200` `{ slug, number, frozen }` (the record, or `null`). `400 invalid_request` for a `frozen` that is not a boolean; `404 chapter_not_found`; `409 conflict`; `422 frontmatter_invalid`. |
|
|
652
|
+
|
|
653
|
+
The `code` of a refusal is the `code` of the engine's `FrozenChapterError` (`FROZEN_CHAPTER_ERROR_CODES`), and `isFrozenChapterErrorCode(error.code)` tells one from the other codes of `ServerRequestError`. The setting `frozenEdits` changes through `PUT …/autopilot/options`, like the other live settings.
|
|
654
|
+
|
|
655
|
+
- **The MCP endpoint of a book.** A server that gives each book its own MCP endpoint (`/mcp/<slug>`, which an assistant such as Claude Code, ChatGPT or Claude.ai connects to) announces `SERVER_FEATURE_MCP` (`"mcp"`) in the `features` of `GET /api/v1/info`; one on which apps such as ChatGPT and Claude.ai connect by themselves, through OAuth, also announces `SERVER_FEATURE_MCP_OAUTH` (`"mcp-oauth"`). `serverSupportsMcp(info)` and `serverSupportsMcpOAuth(info)` read them (never throw; an older server, or an odd answer, says no; each entry is read by itself, so one is never taken for the other). A client asks before it offers the setting: a server without `mcp` answers `404 not_found` to the routes below, and a server with `mcp` but without `mcp-oauth` answers `404 not_found` to the two that list and revoke apps, and its status carries neither `connections` nor `oauth` (a missing `connections` is *unknown*, not *none*). The calls fail as `{ "code", "message" }` with the status below, which `ServerRequestError` carries as `status` and `code`; every one also answers `401 unauthorized`, `403 scope` (a token without the permission in the table), `400 invalid_book` for a book id the server cannot keep and `404 book_not_found` for a book that is not there. The types are `ServerMcpStatus` (with `ServerMcpOAuth`), `UpdateMcpRequest`, `ServerMcpClient` and `ServerMcpClientScope`; the answers are passed on as the server gave them (what a newer server adds is not dropped), except that `listMcpClients` answers the list itself, an empty one when nothing is connected and also for an answer that has no list.
|
|
656
|
+
|
|
657
|
+
| Client method | Request | Answer |
|
|
658
|
+
|---|---|---|
|
|
659
|
+
| `mcpStatus(bookId)` | `GET /api/v1/books/:id/mcp` (`read`). | `200` the status: `{ bookId, enabled, slug, path, url, public, message?, protocolVersions, updatedAt, connections?, oauth? }`. `enabled` is false until the owner switches the book on. `url` is the address to paste into the assistant (`<public address>/mcp/<slug>`, or the local one while the server has no public address); `public` says whether it can be reached from outside, and `message` says why not when it cannot. `connections` is how many apps are connected through OAuth, and `oauth` is `{ issuer, metadataUrl, resourceMetadataUrl, scopes }`, where the OAuth server is (both only from a server that announces `mcp-oauth`). Asking for the status of a book that has no slug yet gives it one, and the slug is kept. |
|
|
660
|
+
| `updateMcp(bookId, { enabled?, slug? })` | `PUT /api/v1/books/:id/mcp` (`write`) with `{ "enabled"?: boolean, "slug"?: string }`. Only what is given is sent, and only those two (a `false` is a value). | `200` the status after the change. `400 invalid_slug` (a slug is 1 to 80 characters: lowercase letters and digits, joined by single hyphens), `409 slug_taken` (another book has it), `400 invalid_request` (a body that has neither key, or an `enabled` that is not a boolean), `503 maintenance` while the server is about to restart. **Switching a book off, or giving it another slug, disconnects every app that was connected to it** (`connections` is 0 in the answer): they do not come back when it is switched on again, the owner allows them again. |
|
|
661
|
+
| `listMcpClients(bookId)` | `GET /api/v1/books/:id/mcp/clients` (`write`: it says who may change the book). | `200` `{ "clients": [...] }`, and the method answers the array of `ServerMcpClient`: `{ id, clientId, name, redirectHost, scopes, createdAt, lastUsedAt }`. `id` is the connection's (what `revokeMcpClient` takes; the same app connected twice has two), `clientId` the id the app registered under, `name` what the app calls itself (cleaned, one line: show it as text), `redirectHost` the host the app sends the owner back to, `scopes` what the owner allowed (`read`, `write`, `run`; show the ones you know and leave out the rest), and the two dates are ISO times. Never a token. |
|
|
662
|
+
| `revokeMcpClient(bookId, id)` | `DELETE /api/v1/books/:id/mcp/clients/:id` (`write`), no body. | `200` `{ "revoked": true }`: the app's next call is refused and its tokens are useless, so it has to ask the owner again. `404 client_missing` when the book has no such connection (it was revoked already, it ended with the book's switch or slug, or it belongs to another book), told apart from `404 book_not_found` by the code. |
|
|
663
|
+
|
|
664
|
+
The apps are allowed by the owner on a page of his own server, with a passkey or the admin code: this client never does it, it only lists and revokes. The passkeys, the apps of every book at once and the audit of what was called are the server's admin panel's, and are not part of this API. A host that offers the setting shows `url` to copy and says what it needs: it can be pasted into ChatGPT or Claude.ai only when `public` is true.
|
|
665
|
+
|
|
332
666
|
## Tests
|
|
333
667
|
|
|
334
668
|
```bash
|