narrarium-engine 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. package/README.md +82 -7
  2. package/dist/ai/fetch-client.d.ts.map +1 -1
  3. package/dist/ai/fetch-client.js +5 -1
  4. package/dist/ai/fetch-client.js.map +1 -1
  5. package/dist/ai/request.d.ts +5 -0
  6. package/dist/ai/request.d.ts.map +1 -1
  7. package/dist/ai/request.js +15 -0
  8. package/dist/ai/request.js.map +1 -1
  9. package/dist/ai/types.d.ts +15 -0
  10. package/dist/ai/types.d.ts.map +1 -1
  11. package/dist/ai/types.js +1 -0
  12. package/dist/ai/types.js.map +1 -1
  13. package/dist/autopilot/errors.d.ts +31 -0
  14. package/dist/autopilot/errors.d.ts.map +1 -0
  15. package/dist/autopilot/errors.js +166 -0
  16. package/dist/autopilot/errors.js.map +1 -0
  17. package/dist/autopilot/runner.d.ts +71 -9
  18. package/dist/autopilot/runner.d.ts.map +1 -1
  19. package/dist/autopilot/runner.js +223 -45
  20. package/dist/autopilot/runner.js.map +1 -1
  21. package/dist/autopilot/session.d.ts +40 -5
  22. package/dist/autopilot/session.d.ts.map +1 -1
  23. package/dist/autopilot/session.js +113 -16
  24. package/dist/autopilot/session.js.map +1 -1
  25. package/dist/autopilot/state.d.ts +60 -3
  26. package/dist/autopilot/state.d.ts.map +1 -1
  27. package/dist/autopilot/state.js +157 -5
  28. package/dist/autopilot/state.js.map +1 -1
  29. package/dist/autopilot/tasks.d.ts.map +1 -1
  30. package/dist/autopilot/tasks.js +11 -2
  31. package/dist/autopilot/tasks.js.map +1 -1
  32. package/dist/autopilot/types.d.ts +166 -10
  33. package/dist/autopilot/types.d.ts.map +1 -1
  34. package/dist/autopilot/types.js +4 -0
  35. package/dist/autopilot/types.js.map +1 -1
  36. package/dist/index.d.ts +1 -0
  37. package/dist/index.d.ts.map +1 -1
  38. package/dist/index.js +1 -0
  39. package/dist/index.js.map +1 -1
  40. package/dist/server/client.d.ts +27 -2
  41. package/dist/server/client.d.ts.map +1 -1
  42. package/dist/server/client.js +35 -0
  43. package/dist/server/client.js.map +1 -1
  44. package/dist/server/protocol.d.ts +38 -2
  45. package/dist/server/protocol.d.ts.map +1 -1
  46. package/dist/server/protocol.js +25 -0
  47. package/dist/server/protocol.js.map +1 -1
  48. package/dist/version.d.ts +1 -1
  49. package/dist/version.js +1 -1
  50. package/package.json +1 -1
@@ -0,0 +1,166 @@
1
+ import { redactSecrets } from "../ai/redact.js";
2
+ import { endpointOrigin } from "../ai/request.js";
3
+ import { AiFallbackBlockedError, AiProviderError, AiPromptTooLargeError, AiReplyRejectedError, AiRoutingBudgetError, AiUnavailableError } from "../ai/types.js";
4
+ import { isBookConflictError } from "../book/store.js";
5
+ import { FrontmatterError } from "../markdown/frontmatter.js";
6
+ import { StructuredReplyError } from "../util/json.js";
7
+ import { clipText } from "../util/text.js";
8
+ import { AUTOPILOT_ERROR_KINDS } from "./types.js";
9
+ /** Characters of one text of an error's detail (a model, a provider, an integration): they are names, not messages. */
10
+ const MAX_DETAIL_CHARACTERS = 160;
11
+ /** Retries are counted up to this, far above any the engine grants: a number from a file can never be bigger. */
12
+ const MAX_RETRY_COUNT = 99;
13
+ const TIMEOUT_WORDS = /\btime[ds]?[ -]?out\b|deadline exceeded/i;
14
+ const RATE_LIMIT_WORDS = /\brate[ _-]?limit|too many requests/i;
15
+ const NETWORK_WORDS = /fetch failed|failed to fetch|\bnetwork\b|connection (?:error|reset|refused|closed|lost|aborted|failed)|\beconn\w*|\benotfound\b|\beai_again\b|\betimedout\b|\bsocket\b|getaddrinfo|\bdns\b|\boffline\b|unreachable|not reachable|stream ended|could not be read|empty stream|other side closed/i;
16
+ const OVERLOAD_WORDS = /overload|temporar|unavailable|capacity|\bbusy\b|try again/i;
17
+ function record(value) {
18
+ return value && typeof value === "object" ? value : {};
19
+ }
20
+ /** Whether an error is of a class, also when it comes from another copy of the engine (a bundle can hold two): by the class, or by the name its constructor gives it (a literal: a bundler may rename the class). */
21
+ function isA(error, name, type) {
22
+ return error instanceof type || record(error).name === name;
23
+ }
24
+ function kindOfStatus(status) {
25
+ if (typeof status !== "number" || !Number.isInteger(status))
26
+ return undefined;
27
+ if (status === 401 || status === 403)
28
+ return "auth";
29
+ if (status === 429)
30
+ return "rate_limit";
31
+ if (status === 408)
32
+ return "timeout";
33
+ return status >= 400 && status <= 599 ? "provider" : undefined;
34
+ }
35
+ /** The words an error says, its message and its codes, to read what its status and its flags do not say. */
36
+ function wordsOf(error) {
37
+ if (typeof error === "string")
38
+ return error;
39
+ const source = record(error);
40
+ const cause = record(source.cause);
41
+ return [source.message, source.code, cause.code].filter((entry) => typeof entry === "string").join(" ");
42
+ }
43
+ function kindOf(error) {
44
+ if (isBookConflictError(error))
45
+ return "conflict";
46
+ const source = record(error);
47
+ if (source.code === "frontmatter_invalid" || isA(error, "FrontmatterError", FrontmatterError))
48
+ return "profile";
49
+ if (isA(error, "AiPromptTooLargeError", AiPromptTooLargeError))
50
+ return "limit";
51
+ if (isA(error, "AiRoutingBudgetError", AiRoutingBudgetError))
52
+ return "budget";
53
+ if (isA(error, "AiFallbackBlockedError", AiFallbackBlockedError) || isA(error, "AiUnavailableError", AiUnavailableError))
54
+ return "refused";
55
+ if (source.truncated === true)
56
+ return "truncated";
57
+ if (source.timedOut === true)
58
+ return "timeout";
59
+ const byStatus = kindOfStatus(source.status);
60
+ if (byStatus)
61
+ return byStatus;
62
+ const words = wordsOf(error);
63
+ if (TIMEOUT_WORDS.test(words))
64
+ return "timeout";
65
+ if (RATE_LIMIT_WORDS.test(words))
66
+ return "rate_limit";
67
+ if (NETWORK_WORDS.test(words))
68
+ return "network";
69
+ if (!isA(error, "AiProviderError", AiProviderError) && !isA(error, "AiReplyRejectedError", AiReplyRejectedError) && !isA(error, "StructuredReplyError", StructuredReplyError))
70
+ return "unknown";
71
+ // The engine marks a failure that depends on the moment `transient`: a connection that dropped is the likeliest, an overloaded provider the other.
72
+ return source.transient === true && !OVERLOAD_WORDS.test(words) ? "network" : "provider";
73
+ }
74
+ /** A name or an id for the detail: without a credential, on one line, short. `undefined` for anything that is not a text. */
75
+ function shortText(value) {
76
+ if (typeof value !== "string")
77
+ return undefined;
78
+ // Cut first, so that a text of any size costs the same to redact; a credential cut in two is left in the part that is cut away, or is shorter than what the pattern knows.
79
+ const text = clipText(redactSecrets(clipText(value, MAX_DETAIL_CHARACTERS * 4)).replace(/\s+/g, " ").trim(), MAX_DETAIL_CHARACTERS).trim();
80
+ return text || undefined;
81
+ }
82
+ function httpStatus(value) {
83
+ return typeof value === "number" && Number.isInteger(value) && value >= 100 && value <= 599 ? value : undefined;
84
+ }
85
+ function detailOf(error) {
86
+ const source = record(error);
87
+ const target = record(source.target);
88
+ const status = httpStatus(source.status);
89
+ const endpoint = endpointOrigin(target.endpoint ?? source.endpoint);
90
+ const model = shortText(source.model) ?? shortText(target.model);
91
+ const provider = shortText(source.provider) ?? shortText(target.provider);
92
+ const integration = shortText(source.integrationId) ?? shortText(target.integrationId);
93
+ return {
94
+ ...(status !== undefined ? { status } : {}),
95
+ ...(endpoint ? { endpoint } : {}),
96
+ ...(model ? { model } : {}),
97
+ ...(provider ? { provider } : {}),
98
+ ...(integration ? { integration } : {}),
99
+ };
100
+ }
101
+ /**
102
+ * What kind of failure an error is, and where it happened, from what the engine knows of its own errors: a status (401 and 403 are
103
+ * `auth`, 429 `rate_limit`, 408 `timeout`, any other 4xx or 5xx `provider`), the flags of `AiProviderError` (`timedOut`, `truncated`,
104
+ * `transient`), its subclasses (`AiPromptTooLargeError` is `limit`, `AiRoutingBudgetError` `budget`, `AiFallbackBlockedError` and
105
+ * `AiUnavailableError` `refused`), `FrontmatterError` (`profile`) and a file conflict (`conflict`); an error that says none of these
106
+ * is read by its words (a provider that does not say `timedOut` still says "timed out"), and what is still nothing is `unknown`.
107
+ * A class, a status or a flag always decides before the words do. The detail holds the status, the origin of the integration's address
108
+ * (never its path or query), the model, the provider and the integration, with no credential in any of them: whatever the error carries
109
+ * is redacted, and the endpoint is cut down to its origin. It is empty for an error that knows none of this.
110
+ */
111
+ export function classifyAutopilotError(error) {
112
+ // It runs where a run has just failed: whatever the error is (a getter that throws, a proxy), it must not fail again.
113
+ let kind = "unknown";
114
+ let detail = {};
115
+ try {
116
+ kind = kindOf(error);
117
+ }
118
+ catch {
119
+ // An error nobody can read is of no kind.
120
+ }
121
+ try {
122
+ detail = detailOf(error);
123
+ }
124
+ catch {
125
+ // And says nothing of where it happened.
126
+ }
127
+ return { kind, detail };
128
+ }
129
+ /**
130
+ * The fields a failure adds to its activity and to `lastError`: `errorKind`, and `errorDetail` when there is any (the detail of
131
+ * `classifyAutopilotError`, with the retry the failure belongs to when it was retried).
132
+ */
133
+ export function autopilotErrorFields(error, retry) {
134
+ const { kind, detail } = classifyAutopilotError(error);
135
+ const full = { ...detail, ...(retry ? { attempt: retry.attempt, retries: retry.retries } : {}) };
136
+ return { errorKind: kind, ...(Object.keys(full).length ? { errorDetail: full } : {}) };
137
+ }
138
+ /** A kind read from a file: one of the closed list, or nothing. */
139
+ export function normalizeErrorKind(value) {
140
+ return typeof value === "string" && AUTOPILOT_ERROR_KINDS.includes(value) ? value : undefined;
141
+ }
142
+ function retryCount(value) {
143
+ return typeof value === "number" && Number.isInteger(value) && value >= 0 && value <= MAX_RETRY_COUNT ? value : undefined;
144
+ }
145
+ /** A detail read from a file (also a hand-edited one): only the known fields that are valid, the endpoint only as an origin, no credential. `undefined` when nothing is left. */
146
+ export function normalizeErrorDetail(value) {
147
+ const source = record(value);
148
+ const status = httpStatus(source.status);
149
+ const endpoint = endpointOrigin(source.endpoint);
150
+ const model = shortText(source.model);
151
+ const provider = shortText(source.provider);
152
+ const integration = shortText(source.integration);
153
+ const attempt = retryCount(source.attempt);
154
+ const retries = retryCount(source.retries);
155
+ const detail = {
156
+ ...(status !== undefined ? { status } : {}),
157
+ ...(endpoint ? { endpoint } : {}),
158
+ ...(model ? { model } : {}),
159
+ ...(provider ? { provider } : {}),
160
+ ...(integration ? { integration } : {}),
161
+ ...(attempt !== undefined ? { attempt } : {}),
162
+ ...(retries !== undefined ? { retries } : {}),
163
+ };
164
+ return Object.keys(detail).length ? detail : undefined;
165
+ }
166
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/autopilot/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAE,qBAAqB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAChK,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,4BAA4B,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,qBAAqB,EAAsD,MAAM,YAAY,CAAC;AAEvG,uHAAuH;AACvH,MAAM,qBAAqB,GAAG,GAAG,CAAC;AAClC,iHAAiH;AACjH,MAAM,eAAe,GAAG,EAAE,CAAC;AAE3B,MAAM,aAAa,GAAG,0CAA0C,CAAC;AACjE,MAAM,gBAAgB,GAAG,sCAAsC,CAAC;AAChE,MAAM,aAAa,GAAG,iSAAiS,CAAC;AACxT,MAAM,cAAc,GAAG,4DAA4D,CAAC;AAEpF,SAAS,MAAM,CAAC,KAAc;IAC5B,OAAO,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAgC,CAAC,CAAC,CAAC,EAAE,CAAC;AACpF,CAAC;AAED,qNAAqN;AACrN,SAAS,GAAG,CAAC,KAAc,EAAE,IAAY,EAAE,IAAgD;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IAClD,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAyB;QACnC,GAAG,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3B,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAC7C,GAAG,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9C,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
@@ -1,17 +1,24 @@
1
1
  import { type AiPort } from "../ai/types.js";
2
2
  import { type BookFileChange, type BookStore } from "../book/store.js";
3
3
  import { type TaskDescriptor } from "./planner.js";
4
- import type { AutopilotActivity, AutopilotEventBody, AutopilotState, InterventionInput, QuestionAnswer, StartOptions } from "./types.js";
4
+ import { type AutopilotActivity, type AutopilotEventBody, type AutopilotLimitsSummary, type AutopilotPausePending, type AutopilotPublishMode, type AutopilotRetryInfo, type AutopilotState, type InterventionInput, type QuestionAnswer, type StartOptions } from "./types.js";
5
+ /**
6
+ * What a host gives the run. Which of the two `after…` hooks are called, and when, is decided by the engine from where the book is
7
+ * published (`options.publishEvery`, else the host's `defaultPublish`, else `options.syncAfterChapter`: see `effectivePublish`),
8
+ * so a host only says how to publish: `afterCommit` is called after every saved step when the book is published after every step,
9
+ * `afterChapter` when a chapter is closed and the book is published after every chapter or every step, and neither when it is not
10
+ * published. A publish that fails is reported (`sync` event) and never stops the run.
11
+ */
5
12
  export interface AutopilotHooks {
6
13
  /** Before every step, e.g. fast-forward the working copy from GitHub (server). */
7
14
  beforeStep?(signal: AbortSignal): Promise<void>;
8
- /** After every committed step, e.g. push to GitHub (server). */
15
+ /** After every committed step, when the book is published after every step: e.g. push to GitHub (server). */
9
16
  afterCommit?(info: {
10
17
  task: TaskDescriptor;
11
18
  message: string;
12
19
  paths: string[];
13
20
  }): Promise<void>;
14
- /** After a chapter is approved, e.g. publish the local commits to GitHub (browser). */
21
+ /** After a chapter is approved, when the book is published after every chapter or every step: e.g. publish the local commits to GitHub (browser). */
15
22
  afterChapter?(info: {
16
23
  chapterNumber: number;
17
24
  title: string;
@@ -27,6 +34,11 @@ export interface AutopilotRunConfig {
27
34
  hostId?: string;
28
35
  now?: () => Date;
29
36
  hooks?: AutopilotHooks;
37
+ /**
38
+ * Where the host publishes when the author has not chosen (`options.publishEvery`). Without it a server host publishes after every
39
+ * step, as it always did, and a browser host as `options.syncAfterChapter` says.
40
+ */
41
+ defaultPublish?: AutopilotPublishMode;
30
42
  emit: (event: AutopilotEventBody) => void;
31
43
  /**
32
44
  * Base delay before the automatic retry of a failed step (ms, default 4000). Transient provider errors are retried up
@@ -84,10 +96,11 @@ export declare function applyAnswer(state: AutopilotState, answer: QuestionAnswe
84
96
  /**
85
97
  * What the author saved in the state file while a step ran, carried into the state that step produced. `base` is the state
86
98
  * as the run last read it, `stored` the file as it is now and `working` the run's own. The author owns the interventions,
87
- * the rules and what a rewrite changes: they are merged (interventions by id, rules by text, the effects of a new rewrite land
88
- * on `working`, as they did when they were handed over in memory), and the run wins on everything else. `foreign` says that
89
- * `stored` differs from `base` in something the author does not own or the run does not write by itself (its own heartbeat):
90
- * that is a conflict.
99
+ * the rules, what a rewrite changes and the settings that can change during a run (`LIVE_AUTOPILOT_OPTIONS`: where the book is
100
+ * published and whether to pause after every chapter): they are merged (interventions by id, rules by text, the effects of a new
101
+ * rewrite land on `working`, as they did when they were handed over in memory, a setting by its value as the author left it), and
102
+ * the run wins on everything else. `foreign` says that `stored` differs from `base` in something the author does not own or the run
103
+ * does not write by itself (its own heartbeat): that is a conflict.
91
104
  */
92
105
  export declare function reconcileAuthorChanges(working: AutopilotState, base: AutopilotState, stored: AutopilotState): {
93
106
  state: AutopilotState;
@@ -116,7 +129,12 @@ export declare class AutopilotRun {
116
129
  readonly runId: string;
117
130
  private readonly controller;
118
131
  private stepController;
132
+ /** A pause now or after the step was asked for: the run stops as soon as the step in flight is saved (or abandoned, for now). */
119
133
  private stopRequested;
134
+ /** A pause at the end of the chapter was asked for: the run goes on until the chapter in progress is closed and published. */
135
+ private chapterStopRequested;
136
+ /** The step in flight, or waiting to be retried, is part of a chapter in progress: a pause at the end of the chapter does not cut its wait. */
137
+ private inChapter;
120
138
  private interrupted;
121
139
  /** Another run is recorded as the owner of the book: this one saves nothing more and ends. */
122
140
  private leaseLost;
@@ -124,12 +142,23 @@ export declare class AutopilotRun {
124
142
  private readonly cache;
125
143
  private readonly store;
126
144
  private readonly now;
145
+ /** Steps this run saved, and chapters it closed: what the limits of the run count. A step that failed or was abandoned is not one. */
146
+ private stepsThisRun;
127
147
  private chaptersThisRun;
148
+ /** The limits of this run, as `StartOptions.limits` gave them. They are not saved. */
149
+ private limits;
150
+ /** The chapter the step saved last closed, until another step is saved: a pause at the end of the chapter asked right then says which. */
151
+ private closedChapter;
152
+ /** Why the run ended, when a client can say it in its language (`run-ended`'s `code`). */
153
+ private endCode;
154
+ private readonly defaultPublish;
128
155
  private current;
129
156
  /** Output limit multiplier per kind of step, raised after a reply cut while the model only reasoned; kept for the run, never saved. */
130
157
  private readonly outputBoosts;
131
158
  /** The wait between two tries of a failed step, ended early by a pause. */
132
159
  private waiting;
160
+ /** While the run waits to try a failed step again: when, and which retry. Told in the summary, never saved. */
161
+ private retry;
133
162
  /** The run already said that the money budget cannot apply to a model without a price. */
134
163
  private budgetWarned;
135
164
  /** What the planner reported during this run, so that each finding is said once however many steps it takes. */
@@ -149,6 +178,33 @@ export declare class AutopilotRun {
149
178
  stop(): void;
150
179
  /** Finish and save the current step, then pause. A wait before a retry ends at once. */
151
180
  stopAfterStep(): void;
181
+ /**
182
+ * Finish and save the current step and go on to the end of the chapter in progress (its closing and its publishing included),
183
+ * then pause. With no chapter in progress (the concept, the plan, the first step of a chapter that has not started, the final
184
+ * judgement) it is `stopAfterStep`, and so is a wait before a retry of such a step (after the final judgement the book is complete,
185
+ * and the run says so); the wait before the retry of a step of the chapter goes on, because the chapter still has to be finished.
186
+ */
187
+ stopAfterChapter(): void;
188
+ /**
189
+ * Take back a pause that is waiting (`stopAfterStep`, `stopAfterChapter`): `true` when there was one. A `stop` that already
190
+ * happened cannot be undone, nor can a pause of a run that is closing.
191
+ */
192
+ cancelPause(): boolean;
193
+ /** The pause that waits for the run to reach it; `null` when none does (a stop that happened is not waiting). */
194
+ get pausePending(): AutopilotPausePending | null;
195
+ /** The limit of chapters of this run: the stricter of the one the run was started with and the saved option `chaptersPerRun` (0 = none). */
196
+ private chaptersLimit;
197
+ /**
198
+ * What the run knows that the state file does not: the pause that waits, the limits of the run with how far it got, and the retry it is
199
+ * waiting for (only while it is). A run that is over has none of them.
200
+ */
201
+ runtime(): {
202
+ pausePending: AutopilotPausePending | null;
203
+ limits: AutopilotLimitsSummary | null;
204
+ retry?: AutopilotRetryInfo;
205
+ };
206
+ /** The summary of a state as this run says it: with the pause that waits, its limits, and where the book is published. */
207
+ private summarize;
152
208
  /** Queue an intervention in memory (a session saves it at once instead); with `interrupt` the running step is abandoned and repeated with it. */
153
209
  intervene(input: InterventionInput): void;
154
210
  /** Abandon the step in flight: it is repeated on the latest saved state, which already holds the intervention that asked for it. */
@@ -156,7 +212,10 @@ export declare class AutopilotRun {
156
212
  private emit;
157
213
  private stepContext;
158
214
  private announce;
159
- /** Waits before a retry; `false` when a pause ended the wait (or came before it). */
215
+ /**
216
+ * Waits before a retry; `false` when a pause ended the wait (or came before it). A pause at the end of the chapter does not, for a step of the chapter.
217
+ * While it waits the summary says when the next attempt is (`retry`, with a `state` event), and it says so no more once the wait is over.
218
+ */
160
219
  private waitBeforeRetry;
161
220
  private drainQueue;
162
221
  /** The next heartbeat is due after `persistHeartbeatMs` without a write of the state file: every write of the run starts the wait again. */
@@ -191,7 +250,10 @@ export declare class AutopilotRun {
191
250
  * in the same commit, so the budget limit never under-counts rejected replies.
192
251
  */
193
252
  private persistFailure;
194
- /** Close the run with a final status, persisted together with any queued intervention and with what the author saved since the run last read the state. */
253
+ /**
254
+ * Close the run with a final status, persisted together with any queued intervention and with what the author saved since the run last read the state.
255
+ * `code` is the reason a client can say in its language (`run-ended`'s `code`), when there is one.
256
+ */
195
257
  private finish;
196
258
  }
197
259
  //# sourceMappingURL=runner.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/autopilot/runner.ts"],"names":[],"mappings":"AACA,OAAO,EAAyC,KAAK,MAAM,EAAiD,MAAM,gBAAgB,CAAC;AAInI,OAAO,EAA4D,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAQjI,OAAO,EAAsF,KAAK,cAAc,EAAE,MAAM,cAAc,CAAC;AAkBvI,OAAO,KAAK,EACV,iBAAiB,EACjB,kBAAkB,EAClB,cAAc,EAEd,iBAAiB,EACjB,cAAc,EACd,YAAY,EACb,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,cAAc;IAC7B,kFAAkF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