narrarium-engine 0.1.9 → 0.1.11

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 (101) hide show
  1. package/README.md +252 -22
  2. package/dist/ai/budget.d.ts +18 -2
  3. package/dist/ai/budget.d.ts.map +1 -1
  4. package/dist/ai/budget.js +9 -2
  5. package/dist/ai/budget.js.map +1 -1
  6. package/dist/ai/fetch-client.d.ts +13 -6
  7. package/dist/ai/fetch-client.d.ts.map +1 -1
  8. package/dist/ai/fetch-client.js +26 -3
  9. package/dist/ai/fetch-client.js.map +1 -1
  10. package/dist/ai/request.d.ts +1 -1
  11. package/dist/ai/request.d.ts.map +1 -1
  12. package/dist/ai/request.js +31 -5
  13. package/dist/ai/request.js.map +1 -1
  14. package/dist/ai/routing.d.ts.map +1 -1
  15. package/dist/ai/routing.js +1 -1
  16. package/dist/ai/routing.js.map +1 -1
  17. package/dist/ai/types.d.ts +29 -2
  18. package/dist/ai/types.d.ts.map +1 -1
  19. package/dist/ai/types.js +5 -2
  20. package/dist/ai/types.js.map +1 -1
  21. package/dist/autopilot/chapter-state.d.ts +19 -0
  22. package/dist/autopilot/chapter-state.d.ts.map +1 -0
  23. package/dist/autopilot/chapter-state.js +31 -0
  24. package/dist/autopilot/chapter-state.js.map +1 -0
  25. package/dist/autopilot/errors.d.ts +2 -1
  26. package/dist/autopilot/errors.d.ts.map +1 -1
  27. package/dist/autopilot/errors.js +17 -1
  28. package/dist/autopilot/errors.js.map +1 -1
  29. package/dist/autopilot/estimate-math.d.ts +19 -0
  30. package/dist/autopilot/estimate-math.d.ts.map +1 -0
  31. package/dist/autopilot/estimate-math.js +74 -0
  32. package/dist/autopilot/estimate-math.js.map +1 -0
  33. package/dist/autopilot/estimate-texts.d.ts +40 -0
  34. package/dist/autopilot/estimate-texts.d.ts.map +1 -0
  35. package/dist/autopilot/estimate-texts.js +130 -0
  36. package/dist/autopilot/estimate-texts.js.map +1 -0
  37. package/dist/autopilot/estimate.d.ts +303 -0
  38. package/dist/autopilot/estimate.d.ts.map +1 -0
  39. package/dist/autopilot/estimate.js +887 -0
  40. package/dist/autopilot/estimate.js.map +1 -0
  41. package/dist/autopilot/frozen.d.ts +1 -4
  42. package/dist/autopilot/frozen.d.ts.map +1 -1
  43. package/dist/autopilot/frozen.js +13 -25
  44. package/dist/autopilot/frozen.js.map +1 -1
  45. package/dist/autopilot/outline-change.d.ts +69 -0
  46. package/dist/autopilot/outline-change.d.ts.map +1 -0
  47. package/dist/autopilot/outline-change.js +42 -0
  48. package/dist/autopilot/outline-change.js.map +1 -0
  49. package/dist/autopilot/outline-check.d.ts +1 -0
  50. package/dist/autopilot/outline-check.d.ts.map +1 -1
  51. package/dist/autopilot/outline-check.js +9 -6
  52. package/dist/autopilot/outline-check.js.map +1 -1
  53. package/dist/autopilot/outline-compose.d.ts +203 -0
  54. package/dist/autopilot/outline-compose.d.ts.map +1 -0
  55. package/dist/autopilot/outline-compose.js +492 -0
  56. package/dist/autopilot/outline-compose.js.map +1 -0
  57. package/dist/autopilot/presets.d.ts +36 -0
  58. package/dist/autopilot/presets.d.ts.map +1 -0
  59. package/dist/autopilot/presets.js +54 -0
  60. package/dist/autopilot/presets.js.map +1 -0
  61. package/dist/autopilot/runner.d.ts +55 -5
  62. package/dist/autopilot/runner.d.ts.map +1 -1
  63. package/dist/autopilot/runner.js +252 -20
  64. package/dist/autopilot/runner.js.map +1 -1
  65. package/dist/autopilot/session.d.ts +61 -9
  66. package/dist/autopilot/session.d.ts.map +1 -1
  67. package/dist/autopilot/session.js +140 -17
  68. package/dist/autopilot/session.js.map +1 -1
  69. package/dist/autopilot/speed.d.ts +30 -0
  70. package/dist/autopilot/speed.d.ts.map +1 -0
  71. package/dist/autopilot/speed.js +71 -0
  72. package/dist/autopilot/speed.js.map +1 -0
  73. package/dist/autopilot/state.d.ts +15 -2
  74. package/dist/autopilot/state.d.ts.map +1 -1
  75. package/dist/autopilot/state.js +67 -2
  76. package/dist/autopilot/state.js.map +1 -1
  77. package/dist/autopilot/types.d.ts +104 -9
  78. package/dist/autopilot/types.d.ts.map +1 -1
  79. package/dist/autopilot/types.js +14 -2
  80. package/dist/autopilot/types.js.map +1 -1
  81. package/dist/index.d.ts +5 -0
  82. package/dist/index.d.ts.map +1 -1
  83. package/dist/index.js +6 -0
  84. package/dist/index.js.map +1 -1
  85. package/dist/server/client.d.ts +52 -6
  86. package/dist/server/client.d.ts.map +1 -1
  87. package/dist/server/client.js +93 -11
  88. package/dist/server/client.js.map +1 -1
  89. package/dist/server/protocol.d.ts +125 -1
  90. package/dist/server/protocol.d.ts.map +1 -1
  91. package/dist/server/protocol.js +47 -0
  92. package/dist/server/protocol.js.map +1 -1
  93. package/dist/util/text.d.ts +6 -0
  94. package/dist/util/text.d.ts.map +1 -1
  95. package/dist/util/text.js +21 -0
  96. package/dist/util/text.js.map +1 -1
  97. package/dist/version.d.ts +1 -1
  98. package/dist/version.d.ts.map +1 -1
  99. package/dist/version.js +1 -1
  100. package/dist/version.js.map +1 -1
  101. package/package.json +1 -1
@@ -19,6 +19,19 @@ export interface AiProgress {
19
19
  events: number;
20
20
  characters: number;
21
21
  }
22
+ /** A part of the content of a message: text, or an image given as a data URL. */
23
+ export type AiContentPart = {
24
+ type: "text";
25
+ text: string;
26
+ } | {
27
+ type: "image";
28
+ dataUrl: string;
29
+ };
30
+ /** One message of a conversation: its role and its content, which is text or a list of parts (text and images). */
31
+ export interface AiMessage {
32
+ role: "system" | "user" | "assistant";
33
+ content: string | AiContentPart[];
34
+ }
22
35
  export interface AiRequest {
23
36
  /** Router capability, e.g. `autopilot`, `director`, `reader-evaluation`, `review`, `simple-tasks`. */
24
37
  capability: string;
@@ -26,6 +39,13 @@ export interface AiRequest {
26
39
  label: string;
27
40
  system: string;
28
41
  user: string;
42
+ /**
43
+ * The conversation to send, for a host that has one (the web app's Copilot: its history, and the images the author attached). When it is there (and is not empty) it is what
44
+ * is sent, with its roles and its parts, in place of `system` and `user`, which are then not read (give empty text). A part of text goes out as it is and an image as an
45
+ * `image_url` with its data URL. With a structured request, the JSON instruction that a model without tool calls receives is added to the first system message (to a
46
+ * system message of its own when there is none). The engine never changes the messages it is given.
47
+ */
48
+ messages?: AiMessage[];
29
49
  /**
30
50
  * When present the reply must be one JSON object matching this schema, delivered as the forced call of a function. With "Tools only" off
31
51
  * (`AiRuntimeConfig.toolsOnly`), a model marked as without tool calls gets the schema in the message instead, and a JSON in the text is read.
@@ -163,13 +183,20 @@ export declare class AiRoutingBudgetError extends AiProviderError {
163
183
  export declare class AiFallbackBlockedError extends AiProviderError {
164
184
  constructor(message: string);
165
185
  }
186
+ /** A model that "Tools only" left out: its name, and the id of the integration it belongs to (two integrations may have models of the same name). */
187
+ export interface AiSkippedModel {
188
+ integration: string;
189
+ model: string;
190
+ }
166
191
  /**
167
192
  * "Tools only" is on and no model of the route can call a function, so a structured request has nowhere to go: nothing was sent, and the same
168
- * configuration would end the same way. `models` are the names of the models that were left out. The message names them and says the two ways out.
193
+ * configuration would end the same way. `models` are the names of the models that were left out, and `skippedModels` the same with the integration
194
+ * of each (empty from a host that made the error without them). The message names them and says the two ways out.
169
195
  */
170
196
  export declare class AiToolsRequiredError extends AiProviderError {
171
197
  readonly models: string[];
172
- constructor(message: string, models?: string[]);
198
+ readonly skippedModels: AiSkippedModel[];
199
+ constructor(message: string, models?: string[], skippedModels?: AiSkippedModel[]);
173
200
  }
174
201
  /** Router capabilities used by the autopilot and the director. Missing routes fall back to `default` models. */
175
202
  export declare const AI_CAPABILITIES: {
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AAAA,iEAAiE;AACjE,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC;AAED,MAAM,WAAW,OAAO;IACtB,WAA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eAAe;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAED,kEAAkE;AAClE,qBAAa,sBAAuB,SAAQ,eAAe;gBAC7C,OAAO,EAAE,MAAM;CAI5B;AAED,qJAAqJ;AACrJ,MAAM,WAAW,cAAc;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;GAIG;AACH,qBAAa,oBAAqB,SAAQ,eAAe;IAC1B,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE;IAAO,QAAQ,CAAC,aAAa,EAAE,cAAc,EAAE;gBAAzF,OAAO,EAAE,MAAM,EAAW,MAAM,GAAE,MAAM,EAAO,EAAW,aAAa,GAAE,cAAc,EAAO;CAI3G;AAED,gHAAgH;AAChH,eAAO,MAAM,eAAe;;;;;;;CAOlB,CAAC"}
package/dist/ai/types.js CHANGED
@@ -70,13 +70,16 @@ export class AiFallbackBlockedError extends AiProviderError {
70
70
  }
71
71
  /**
72
72
  * "Tools only" is on and no model of the route can call a function, so a structured request has nowhere to go: nothing was sent, and the same
73
- * configuration would end the same way. `models` are the names of the models that were left out. The message names them and says the two ways out.
73
+ * configuration would end the same way. `models` are the names of the models that were left out, and `skippedModels` the same with the integration
74
+ * of each (empty from a host that made the error without them). The message names them and says the two ways out.
74
75
  */
75
76
  export class AiToolsRequiredError extends AiProviderError {
76
77
  models;
77
- constructor(message, models = []) {
78
+ skippedModels;
79
+ constructor(message, models = [], skippedModels = []) {
78
80
  super(message, undefined, false);
79
81
  this.models = models;
82
+ this.skippedModels = skippedModels;
80
83
  this.name = "AiToolsRequiredError";
81
84
  }
82
85
  }
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/ai/types.ts"],"names":[],"mappings":"AA2EA,MAAM,OAAO,kBAAmB,SAAQ,KAAK;IACtB;IAArB,YAAqB,UAAkB;QACrC,KAAK,CAAC,sCAAsC,UAAU,oDAAoD,CAAC,CAAC;QADzF,eAAU,GAAV,UA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AsB,CAAC;IACrC,CAAC;CACF;AAED,kEAAkE;AAClE,MAAM,OAAO,sBAAuB,SAAQ,eAAe;IACzD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QACjC,IAAI,CAAC,IAAI,GAAG,wBAAwB,CAAC;IACvC,CAAC;CACF;AAQD;;;;GAIG;AACH,MAAM,OAAO,oBAAqB,SAAQ,eAAe;IACjB;IAAgC;IAAtE,YAAY,OAAe,EAAW,SAAmB,EAAE,EAAW,gBAAkC,EAAE;QACxG,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC;QADG,WAAM,GAAN,MAAM,CAAe;QAAW,kBAAa,GAAb,aAAa,CAAuB;QAExG,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAED,gHAAgH;AAChH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,MAAM,EAAE,WAAW;IACnB,QAAQ,EAAE,UAAU;IACpB,MAAM,EAAE,mBAAmB;IAC3B,aAAa,EAAE,2BAA2B;IAC1C,UAAU,EAAE,QAAQ;IACpB,OAAO,EAAE,cAAc;CACf,CAAC"}
@@ -0,0 +1,19 @@
1
+ import type { AutopilotState, PendingFrozenReview, PlannedChapter } from "./types.js";
2
+ /**
3
+ * What the state of the autopilot says about one chapter, and nothing else: whether the chapter counts as written, which decision is being carried out, and whether the
4
+ * autopilot has the chapter in its hands. A few pure lines, with no import but types, on purpose: the frozen chapters (`frozen.ts`) need them, and so does the rule that
5
+ * tells the author what happens when an entry of the outline changes (`outline-change.ts`), which a page that only shows the outline loads without the rest of the
6
+ * frozen chapters (the run's state, its prompts, its transport) that a module of `frozen.ts` would bring with it.
7
+ */
8
+ /** A chapter counts as written when the author wrote it before the autopilot took over, the autopilot closed it, or one of its scenes is past `planned`. */
9
+ export declare function isPlannedChapterWritten(chapter: Pick<PlannedChapter, "status" | "scenes"> & Partial<Pick<PlannedChapter, "imported">>): boolean;
10
+ /** The decision being carried out, when one is: the autopilot works on one change at a time. */
11
+ export declare function startedReview(state: Pick<AutopilotState, "pendingReviews">): PendingFrozenReview | undefined;
12
+ /** Whether the revision in progress rewrites this chapter (or rewrote it, and reviews it again at its end). */
13
+ export declare function inRevision(state: Pick<AutopilotState, "revision">, number: number): boolean;
14
+ /**
15
+ * The chapters the autopilot has in its hands: being written or reviewed (not `done`), rewritten by the revision in progress, or the
16
+ * change being carried out. What happens to their files then is the autopilot's own work, never a change of the author's to ask about.
17
+ */
18
+ export declare function inHands(state: Pick<AutopilotState, "revision" | "pendingReviews">, chapter: Pick<PlannedChapter, "number" | "status">): boolean;
19
+ //# sourceMappingURL=chapter-state.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chapter-state.d.ts","sourceRoot":"","sources":["../../src/autopilot/chapter-state.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEtF;;;;;GAKG;AAEH,4JAA4J;AAC5J,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,GAAG,OAAO,CAE/I;AAED,gGAAgG;AAChG,wBAAgB,aAAa,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,GAAG,mBAAmB,GAAG,SAAS,CAE5G;AAED,+GAA+G;AAC/G,wBAAgB,UAAU,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAI3F;AAED;;;GAGG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,IAAI,CAAC,cAAc,EAAE,UAAU,GAAG,gBAAgB,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,cAAc,EAAE,QAAQ,GAAG,QAAQ,CAAC,GAAG,OAAO,CAG/I"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * What the state of the autopilot says about one chapter, and nothing else: whether the chapter counts as written, which decision is being carried out, and whether the
3
+ * autopilot has the chapter in its hands. A few pure lines, with no import but types, on purpose: the frozen chapters (`frozen.ts`) need them, and so does the rule that
4
+ * tells the author what happens when an entry of the outline changes (`outline-change.ts`), which a page that only shows the outline loads without the rest of the
5
+ * frozen chapters (the run's state, its prompts, its transport) that a module of `frozen.ts` would bring with it.
6
+ */
7
+ /** A chapter counts as written when the author wrote it before the autopilot took over, the autopilot closed it, or one of its scenes is past `planned`. */
8
+ export function isPlannedChapterWritten(chapter) {
9
+ return chapter.imported === true || chapter.status === "done" || chapter.scenes.some((scene) => scene.status !== "planned");
10
+ }
11
+ /** The decision being carried out, when one is: the autopilot works on one change at a time. */
12
+ export function startedReview(state) {
13
+ return state.pendingReviews?.find((entry) => entry.started);
14
+ }
15
+ /** Whether the revision in progress rewrites this chapter (or rewrote it, and reviews it again at its end). */
16
+ export function inRevision(state, number) {
17
+ const revision = state.revision;
18
+ if (!revision)
19
+ return false;
20
+ return Boolean(revision.targets?.some((target) => target.chapterNumber === number) || revision.revisedChapters?.includes(number) || revision.onlyChapter === number);
21
+ }
22
+ /**
23
+ * The chapters the autopilot has in its hands: being written or reviewed (not `done`), rewritten by the revision in progress, or the
24
+ * change being carried out. What happens to their files then is the autopilot's own work, never a change of the author's to ask about.
25
+ */
26
+ export function inHands(state, chapter) {
27
+ if (chapter.status !== "done" || inRevision(state, chapter.number))
28
+ return true;
29
+ return startedReview(state)?.number === chapter.number;
30
+ }
31
+ //# sourceMappingURL=chapter-state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"chapter-state.js","sourceRoot":"","sources":["../../src/autopilot/chapter-state.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,4JAA4J;AAC5J,MAAM,UAAU,uBAAuB,CAAC,OAA8F;IACpI,OAAO,OAAO,CAAC,QAAQ,KAAK,IAAI,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC;AAC9H,CAAC;AAED,gGAAgG;AAChG,MAAM,UAAU,aAAa,CAAC,KAA6C;IACzE,OAAO,KAAK,CAAC,cAAc,EAAE,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED,+GAA+G;AAC/G,MAAM,UAAU,UAAU,CAAC,KAAuC,EAAE,MAAc;IAChF,MAAM,QAAQ,GAAG,KAAK,CAAC,QAAQ,CAAC;IAChC,IAAI,CAAC,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5B,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,aAAa,KAAK,MAAM,CAAC,IAAI,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC,MAAM,CAAC,IAAI,QAAQ,CAAC,WAAW,KAAK,MAAM,CAAC,CAAC;AACvK,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,OAAO,CAAC,KAA0D,EAAE,OAAkD;IACpI,IAAI,OAAO,CAAC,MAAM,KAAK,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,MAAM,CAAC;QAAE,OAAO,IAAI,CAAC;IAChF,OAAO,aAAa,CAAC,KAAK,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC;AACzD,CAAC"}
@@ -3,7 +3,8 @@ import { type AutopilotErrorDetail, type AutopilotErrorKind } from "./types.js";
3
3
  * 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
4
4
  * `auth`, 429 `rate_limit`, 408 `timeout`, any other 4xx or 5xx `provider`), the flags of `AiProviderError` (`timedOut`, `truncated`,
5
5
  * `transient`), its subclasses (`AiPromptTooLargeError` is `limit`, `AiRoutingBudgetError` `budget`, `AiToolsRequiredError` `config`,
6
- * `AiFallbackBlockedError` and `AiUnavailableError` `refused`), `FrontmatterError` (`profile`) and a file conflict (`conflict`); an error that says none of these
6
+ * `AiFallbackBlockedError` and `AiUnavailableError` `refused`), `FrontmatterError` (`profile`), a file conflict and a conflict with GitHub (`conflict`, the second with
7
+ * `githubConflicts`, the number of files); an error that says none of these
7
8
  * is read by its words (a provider that does not say `timedOut` still says "timed out"), and what is still nothing is `unknown`.
8
9
  * 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
9
10
  * (never its path or query), the model, the provider and the integration, with no credential in any of them: whatever the error carries
@@ -1 +1 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/autopilot/errors.ts"],"names":[],"mappings":"AAOA,OAAO,EAAyB,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAsHvG;;;;;;;;;;;GAWG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAejH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,kBAAkB,CAAC;IAAC,WAAW,CAAC,EAAE,oBAAoB,CAAA;CAAE,CAIxK;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAEjF;AAMD,iLAAiL;AACjL,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CAyBrF"}
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/autopilot/errors.ts"],"names":[],"mappings":"AAQA,OAAO,EAAyB,KAAK,oBAAoB,EAAE,KAAK,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAkIvG;;;;;;;;;;;;GAYG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,OAAO,GAAG;IAAE,IAAI,EAAE,kBAAkB,CAAC;IAAC,MAAM,EAAE,oBAAoB,CAAA;CAAE,CAejH;AAED;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,CAAC,EAAE;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,SAAS,EAAE,kBAAkB,CAAC;IAAC,WAAW,CAAC,EAAE,oBAAoB,CAAA;CAAE,CAIxK;AAED,mEAAmE;AACnE,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,OAAO,GAAG,kBAAkB,GAAG,SAAS,CAEjF;AAMD,iLAAiL;AACjL,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,OAAO,GAAG,oBAAoB,GAAG,SAAS,CA2BrF"}
@@ -3,6 +3,7 @@ import { endpointOrigin } from "../ai/request.js";
3
3
  import { AiFallbackBlockedError, AiProviderError, AiPromptTooLargeError, AiReplyRejectedError, AiRoutingBudgetError, AiToolsRequiredError, AiUnavailableError } from "../ai/types.js";
4
4
  import { isBookConflictError } from "../book/store.js";
5
5
  import { FrontmatterError } from "../markdown/frontmatter.js";
6
+ import { GITHUB_CONFLICT_CODE } from "../server/protocol.js";
6
7
  import { StructuredReplyError } from "../util/json.js";
7
8
  import { clipText } from "../util/text.js";
8
9
  import { AUTOPILOT_ERROR_KINDS } from "./types.js";
@@ -12,6 +13,8 @@ const MAX_DETAIL_CHARACTERS = 160;
12
13
  const MAX_RETRY_COUNT = 99;
13
14
  /** The longest deadline or wait a detail read from a file can name: a day, far above the four hours and the five minutes the engine allows. */
14
15
  const MAX_TIMEOUT_MS = 86_400_000;
16
+ /** The most files a conflict with GitHub is said to have: a book holds far fewer. */
17
+ const MAX_CONFLICT_FILES = 1_000_000;
15
18
  const TIMEOUT_PHASES = ["start", "idle", "total"];
16
19
  const TIMEOUT_WORDS = /\btime[ds]?[ -]?out\b|deadline exceeded/i;
17
20
  const RATE_LIMIT_WORDS = /\brate[ _-]?limit|too many requests/i;
@@ -47,6 +50,9 @@ function kindOf(error) {
47
50
  if (isBookConflictError(error))
48
51
  return "conflict";
49
52
  const source = record(error);
53
+ // The server's commits and GitHub's changed the same files: the author chooses, and repeating the step cannot settle it.
54
+ if (source.code === GITHUB_CONFLICT_CODE)
55
+ return "conflict";
50
56
  if (source.code === "frontmatter_invalid" || isA(error, "FrontmatterError", FrontmatterError))
51
57
  return "profile";
52
58
  if (isA(error, "AiPromptTooLargeError", AiPromptTooLargeError))
@@ -104,6 +110,10 @@ function waitMilliseconds(value) {
104
110
  function timeoutPhase(value) {
105
111
  return TIMEOUT_PHASES.find((phase) => phase === value);
106
112
  }
113
+ /** How many files a conflict with GitHub has: a whole number from one. */
114
+ function conflictFiles(value) {
115
+ return typeof value === "number" && Number.isInteger(value) && value >= 1 && value <= MAX_CONFLICT_FILES ? value : undefined;
116
+ }
107
117
  function detailOf(error) {
108
118
  const source = record(error);
109
119
  const target = record(source.target);
@@ -119,6 +129,8 @@ function detailOf(error) {
119
129
  const timeout = record(source.timeout);
120
130
  const timeoutMs = timeoutMilliseconds(timeout.ms);
121
131
  const phase = timeoutPhase(timeout.phase);
132
+ // A conflict with GitHub says how many files the author has to decide about.
133
+ const githubConflicts = source.code === GITHUB_CONFLICT_CODE ? conflictFiles(source.total) : undefined;
122
134
  return {
123
135
  ...(status !== undefined ? { status } : {}),
124
136
  ...(endpoint ? { endpoint } : {}),
@@ -128,13 +140,15 @@ function detailOf(error) {
128
140
  ...(retryAfterMs !== undefined ? { retryAfterMs } : {}),
129
141
  ...(timeoutMs !== undefined ? { timeoutMs } : {}),
130
142
  ...(phase ? { timeoutPhase: phase } : {}),
143
+ ...(githubConflicts !== undefined ? { githubConflicts } : {}),
131
144
  };
132
145
  }
133
146
  /**
134
147
  * 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
135
148
  * `auth`, 429 `rate_limit`, 408 `timeout`, any other 4xx or 5xx `provider`), the flags of `AiProviderError` (`timedOut`, `truncated`,
136
149
  * `transient`), its subclasses (`AiPromptTooLargeError` is `limit`, `AiRoutingBudgetError` `budget`, `AiToolsRequiredError` `config`,
137
- * `AiFallbackBlockedError` and `AiUnavailableError` `refused`), `FrontmatterError` (`profile`) and a file conflict (`conflict`); an error that says none of these
150
+ * `AiFallbackBlockedError` and `AiUnavailableError` `refused`), `FrontmatterError` (`profile`), a file conflict and a conflict with GitHub (`conflict`, the second with
151
+ * `githubConflicts`, the number of files); an error that says none of these
138
152
  * is read by its words (a provider that does not say `timedOut` still says "timed out"), and what is still nothing is `unknown`.
139
153
  * 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
140
154
  * (never its path or query), the model, the provider and the integration, with no credential in any of them: whatever the error carries
@@ -189,6 +203,7 @@ export function normalizeErrorDetail(value) {
189
203
  const retries = retryCount(source.retries);
190
204
  const timeoutMs = timeoutMilliseconds(source.timeoutMs);
191
205
  const phase = timeoutPhase(source.timeoutPhase);
206
+ const githubConflicts = conflictFiles(source.githubConflicts);
192
207
  const detail = {
193
208
  ...(status !== undefined ? { status } : {}),
194
209
  ...(endpoint ? { endpoint } : {}),
@@ -200,6 +215,7 @@ export function normalizeErrorDetail(value) {
200
215
  ...(retries !== undefined ? { retries } : {}),
201
216
  ...(timeoutMs !== undefined ? { timeoutMs } : {}),
202
217
  ...(phase ? { timeoutPhase: phase } : {}),
218
+ ...(githubConflicts !== undefined ? { githubConflicts } : {}),
203
219
  };
204
220
  return Object.keys(detail).length ? detail : undefined;
205
221
  }
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../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,WAAW,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvC,GAAG,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACvD,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;QAC7C,GAAG,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACjD,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,GAAG,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC9D,CAAC;IACF,OAAO,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AACzD,CAAC"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * The sum, over the chapters `from` to `to` of a book (the first is chapter 1), of what each one adds to a prompt that grows by `slope` with every
3
+ * chapter before it until it reaches `cap`: `min(cap, slope × (chapter − 1))`. It is how the story so far and the lists of the chapters grow: a prompt
4
+ * carries the chapters before the one it is about, up to the limit the engine puts on that part of the prompt.
5
+ *
6
+ * Closed form: the chapters on the slope are summed as an arithmetic series, the ones at the cap are counted, so that a book of any length costs the same.
7
+ * Chapters before the first add nothing. Anything that is not a finite number, a slope or a cap of nothing, or no chapter at all, gives 0.
8
+ */
9
+ export declare function sumCappedRamp(slope: number, cap: number, from: number, to: number): number;
10
+ /**
11
+ * What a list of `lines` chapters weighs in a prompt, as `layoutChapters` lays it out within a budget (`cap`): while every line fits (`line` each) the list is whole;
12
+ * a list that does not fit keeps the first and the last five chapters and the thirty around the one it is about, `full` lines in all, and the other chapters
13
+ * give up their summary and keep a title (`title` each), up to the budget. The levels that condense further (blocks of chapters) are not followed: the list is never
14
+ * more than `cap`, which is where this stops.
15
+ */
16
+ export declare function windowedList(lines: number, line: number, title: number, full: number, cap: number): number;
17
+ /** The sum of `windowedList` over the lists of `from` to `to` lines, in closed form: the lists that fit whole are an arithmetic series, the others a ramp that stops at the cap. */
18
+ export declare function sumWindowedList(from: number, to: number, line: number, title: number, full: number, cap: number): number;
19
+ //# sourceMappingURL=estimate-math.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-math.d.ts","sourceRoot":"","sources":["../../src/autopilot/estimate-math.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAc1F;AAED;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAM1G;AAED,oLAAoL;AACpL,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAsBxH"}
@@ -0,0 +1,74 @@
1
+ const isNumber = (value) => typeof value === "number" && Number.isFinite(value);
2
+ /**
3
+ * The sum, over the chapters `from` to `to` of a book (the first is chapter 1), of what each one adds to a prompt that grows by `slope` with every
4
+ * chapter before it until it reaches `cap`: `min(cap, slope × (chapter − 1))`. It is how the story so far and the lists of the chapters grow: a prompt
5
+ * carries the chapters before the one it is about, up to the limit the engine puts on that part of the prompt.
6
+ *
7
+ * Closed form: the chapters on the slope are summed as an arithmetic series, the ones at the cap are counted, so that a book of any length costs the same.
8
+ * Chapters before the first add nothing. Anything that is not a finite number, a slope or a cap of nothing, or no chapter at all, gives 0.
9
+ */
10
+ export function sumCappedRamp(slope, cap, from, to) {
11
+ if (!isNumber(slope) || !isNumber(cap) || !isNumber(from) || !isNumber(to))
12
+ return 0;
13
+ if (slope <= 0 || cap <= 0)
14
+ return 0;
15
+ const first = Math.max(1, Math.ceil(from));
16
+ const last = Math.floor(to);
17
+ if (last < first)
18
+ return 0;
19
+ // The last chapter still on the slope: from the next one on, the prompt is at its cap (where the two meet the value is the same).
20
+ const lastOnSlope = Math.floor(cap / slope) + 1;
21
+ let total = 0;
22
+ const slopeEnd = Math.min(last, lastOnSlope);
23
+ if (first <= slopeEnd)
24
+ total += (slope * (first - 1 + (slopeEnd - 1)) * (slopeEnd - first + 1)) / 2;
25
+ const capStart = Math.max(first, lastOnSlope + 1);
26
+ if (last >= capStart)
27
+ total += cap * (last - capStart + 1);
28
+ return total;
29
+ }
30
+ /**
31
+ * What a list of `lines` chapters weighs in a prompt, as `layoutChapters` lays it out within a budget (`cap`): while every line fits (`line` each) the list is whole;
32
+ * a list that does not fit keeps the first and the last five chapters and the thirty around the one it is about, `full` lines in all, and the other chapters
33
+ * give up their summary and keep a title (`title` each), up to the budget. The levels that condense further (blocks of chapters) are not followed: the list is never
34
+ * more than `cap`, which is where this stops.
35
+ */
36
+ export function windowedList(lines, line, title, full, cap) {
37
+ if (![lines, line, title, full, cap].every(isNumber) || lines <= 0 || line <= 0 || cap <= 0)
38
+ return 0;
39
+ const whole = lines * line;
40
+ if (whole <= cap)
41
+ return whole;
42
+ if (lines <= full)
43
+ return cap;
44
+ return Math.min(cap, full * line + (lines - full) * Math.max(0, title));
45
+ }
46
+ /** The sum of `windowedList` over the lists of `from` to `to` lines, in closed form: the lists that fit whole are an arithmetic series, the others a ramp that stops at the cap. */
47
+ export function sumWindowedList(from, to, line, title, full, cap) {
48
+ if (![from, to, line, title, full, cap].every(isNumber) || line <= 0 || cap <= 0)
49
+ return 0;
50
+ const first = Math.max(1, Math.ceil(from));
51
+ const last = Math.floor(to);
52
+ if (last < first)
53
+ return 0;
54
+ const lastWhole = Math.floor(cap / line);
55
+ let total = 0;
56
+ const wholeEnd = Math.min(last, lastWhole);
57
+ if (first <= wholeEnd)
58
+ total += (line * (first + wholeEnd) * (wholeEnd - first + 1)) / 2;
59
+ // Lists that do not fit and are no longer than the lines kept whole are at the cap.
60
+ const cappedStart = Math.max(first, lastWhole + 1);
61
+ const cappedEnd = Math.min(last, Math.max(0, Math.floor(full)));
62
+ if (cappedStart <= cappedEnd)
63
+ total += cap * (cappedEnd - cappedStart + 1);
64
+ // The others keep `full` lines and a title for each line more, up to the cap.
65
+ const condensedStart = Math.max(cappedStart, Math.floor(full) + 1);
66
+ if (condensedStart <= last) {
67
+ const count = last - condensedStart + 1;
68
+ const titleTokens = Math.max(0, title);
69
+ const constant = full * (line - titleTokens);
70
+ total += constant >= cap ? cap * count : constant * count + sumCappedRamp(titleTokens, cap - constant, condensedStart + 1, last + 1);
71
+ }
72
+ return total;
73
+ }
74
+ //# sourceMappingURL=estimate-math.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-math.js","sourceRoot":"","sources":["../../src/autopilot/estimate-math.ts"],"names":[],"mappings":"AAAA,MAAM,QAAQ,GAAG,CAAC,KAAc,EAAmB,EAAE,CAAC,OAAO,KAAK,KAAK,QAAQ,IAAI,MAAM,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;AAE1G;;;;;;;GAOG;AACH,MAAM,UAAU,aAAa,CAAC,KAAa,EAAE,GAAW,EAAE,IAAY,EAAE,EAAU;IAChF,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,I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}
@@ -0,0 +1,40 @@
1
+ import type { EstimateCallKind, EstimateCapability } from "./estimate.js";
2
+ /** A whole number with the separator of the language between thousands: `8,192` in English, `8.192` in Italian. */
3
+ export declare function formatCount(value: number, italian: boolean): string;
4
+ /** Everything the estimate says in words. `italian` picks the language; no text is built anywhere else. */
5
+ export declare function estimateTexts(italian: boolean): {
6
+ capability: (id: EstimateCapability) => string;
7
+ noModel: (id: EstimateCapability) => string;
8
+ smallWindow: (id: EstimateCapability, model: string, window: number, budget: number, prompt: number, kind: EstimateCallKind, fits: boolean) => string;
9
+ smallOutput: (id: EstimateCapability, model: string, limit: number, reply: number, kind: EstimateCallKind) => string;
10
+ noPrice: (id: EstimateCapability, model: string) => string;
11
+ noSpeed: (id: EstimateCapability, model: string) => string;
12
+ reasoningModel: (id: EstimateCapability, model: string) => string;
13
+ outlineLonger: (brief: number, outline: number) => string;
14
+ /** The assumptions, one sentence each, in the order of the pipeline. */
15
+ assumptions: (facts: AssumptionFacts) => string[];
16
+ };
17
+ /** What the assumptions say of the book, so that the words are built in one place. */
18
+ export interface AssumptionFacts {
19
+ chapters: number;
20
+ written: number;
21
+ toWrite: number;
22
+ scenes: number;
23
+ wordsPerScene: number;
24
+ words: number;
25
+ pinned: boolean;
26
+ /** As text, for a book whose rounds, repairs and revisions were given. */
27
+ rounds: string;
28
+ repairs: string;
29
+ revisions: string;
30
+ maxRounds: number;
31
+ readers: number;
32
+ planReaders: number;
33
+ panel: number;
34
+ specialists: boolean;
35
+ tokensPerWord: number;
36
+ inputPerWord: number;
37
+ cached: boolean;
38
+ outlineWords: number;
39
+ }
40
+ //# sourceMappingURL=estimate-texts.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-texts.d.ts","sourceRoot":"","sources":["../../src/autopilot/estimate-texts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AA6C1E,mHAAmH;AACnH,wBAAgB,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAEnE;AAQD,2GAA2G;AAC3G,wBAAgB,aAAa,CAAC,OAAO,EAAE,OAAO;qBAGpB,kBAAkB;kBAI1B,kBAAkB;sBAGd,kBAAkB,SAAS,MAAM,UAAU,MAAM,UAAU,MAAM,UAAU,MAAM,QAAQ,gBAAgB,QAAQ,OAAO;sBAGxH,kBAAkB,SAAS,MAAM,SAAS,MAAM,SAAS,MAAM,QAAQ,gBAAgB;kBAG3F,kBAAkB,SAAS,MAAM;kBAGjC,kBAAkB,SAAS,MAAM;yBAG1B,kBAAkB,SAAS,MAAM;2BAG/B,MAAM,WAAW,MAAM;IAG9C,wEAAwE;yBACnD,eAAe,KAAG,MAAM,EAAE;EA+ClD;AAED,sFAAsF;AACtF,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;IAChB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,OAAO,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;CACtB"}
@@ -0,0 +1,130 @@
1
+ /** The words of the estimate in the language of the book: Italian for an Italian book, English for every other. */
2
+ const CAPABILITY_LABEL = {
3
+ en: { autopilot: "Autopilot", director: "Director", "reader-evaluation": "Reader evaluation", "reader-evaluation-summary": "Reader evaluation summary", review: "Review", "simple-tasks": "Simple tasks" },
4
+ it: { autopilot: "Autopilot", director: "Direttore", "reader-evaluation": "Valutazione lettore", "reader-evaluation-summary": "Sintesi valutazioni lettori", review: "Revisione", "simple-tasks": "Task semplici" },
5
+ };
6
+ const STEP_LABEL = {
7
+ en: {
8
+ concept: "concept",
9
+ "summarize-imported": "summary of a chapter the author wrote",
10
+ plan: "chapter plan",
11
+ "plan-reader": "reader's reaction to the plan",
12
+ "plan-review": "review of the plan",
13
+ scenes: "plan of the scenes",
14
+ write: "writing a scene",
15
+ "scene-summary": "summary of a scene",
16
+ reader: "reader's evaluation of a chapter",
17
+ "readers-summary": "summary of the readers' evaluations",
18
+ specialists: "specialists' review",
19
+ "director-review": "director's review of a chapter",
20
+ repair: "repair of a scene",
21
+ consolidate: "closing of a chapter",
22
+ final: "director's final review of the book",
23
+ },
24
+ it: {
25
+ concept: "concept",
26
+ "summarize-imported": "riassunto di un capitolo dell'autore",
27
+ plan: "piano dei capitoli",
28
+ "plan-reader": "reazione di un lettore al piano",
29
+ "plan-review": "revisione del piano",
30
+ scenes: "piano delle scene",
31
+ write: "scrittura di una scena",
32
+ "scene-summary": "riassunto di una scena",
33
+ reader: "valutazione di un lettore su un capitolo",
34
+ "readers-summary": "sintesi delle valutazioni dei lettori",
35
+ specialists: "revisione degli specialisti",
36
+ "director-review": "revisione di un capitolo del direttore",
37
+ repair: "correzione di una scena",
38
+ consolidate: "chiusura di un capitolo",
39
+ final: "giudizio finale del direttore sul libro",
40
+ },
41
+ };
42
+ /** A whole number with the separator of the language between thousands: `8,192` in English, `8.192` in Italian. */
43
+ export function formatCount(value, italian) {
44
+ return String(Math.round(value)).replace(/\B(?=(\d{3})+(?!\d))/g, italian ? "." : ",");
45
+ }
46
+ /** A number of tokens a word costs, as it is written: `2.4` in English, `2,4` in Italian. */
47
+ function formatFactor(value, italian) {
48
+ const text = String(Math.round(value * 100) / 100);
49
+ return italian ? text.replace(".", ",") : text;
50
+ }
51
+ /** Everything the estimate says in words. `italian` picks the language; no text is built anywhere else. */
52
+ export function estimateTexts(italian) {
53
+ const set = italian ? "it" : "en";
54
+ const count = (value) => formatCount(value, italian);
55
+ const capability = (id) => CAPABILITY_LABEL[set][id];
56
+ const step = (kind) => STEP_LABEL[set][kind];
57
+ return {
58
+ capability,
59
+ noModel: (id) => (italian
60
+ ? `Nessun modello è configurato per «${capability(id)}»: l'autopilot si fermerebbe al primo passo che lo richiede.`
61
+ : `No model is configured for «${capability(id)}»: the autopilot would stop at the first step that needs it.`),
62
+ smallWindow: (id, model, window, budget, prompt, kind, fits) => (italian
63
+ ? `«${capability(id)}»: la finestra di ${model} (${count(window)} token) lascia ${count(budget)} token a un prompt; il più grande, nel passo «${step(kind)}», è di circa ${count(prompt)} token${fits ? ": ci sta, ma con poco margine" : ": non ci sta"}.`
64
+ : `«${capability(id)}»: the window of ${model} (${count(window)} tokens) leaves ${count(budget)} tokens for a prompt; the largest one, in the step «${step(kind)}», is about ${count(prompt)} tokens${fits ? ": it fits, with little room to spare" : ": it does not fit"}.`),
65
+ smallOutput: (id, model, limit, reply, kind) => (italian
66
+ ? `«${capability(id)}»: ${model} non può rispondere con più di ${count(limit)} token, e la risposta tipica del passo «${step(kind)}» è di circa ${count(reply)}: verrebbe tagliata.`
67
+ : `«${capability(id)}»: ${model} cannot answer with more than ${count(limit)} tokens, and the typical reply of the step «${step(kind)}» is about ${count(reply)}: it would be cut.`),
68
+ noPrice: (id, model) => (italian
69
+ ? `«${capability(id)}»: ${model} non ha un prezzo, quindi il costo non è noto.`
70
+ : `«${capability(id)}»: ${model} has no price, so the cost is not known.`),
71
+ noSpeed: (id, model) => (italian
72
+ ? `«${capability(id)}»: la velocità di ${model} non è nota, quindi il tempo non è stimato.`
73
+ : `«${capability(id)}»: the speed of ${model} is not known, so the time is not estimated.`),
74
+ reasoningModel: (id, model) => (italian
75
+ ? `«${capability(id)}»: ${model} ragiona prima di rispondere e spende token di ragionamento che non sono contati qui.`
76
+ : `«${capability(id)}»: ${model} reasons before it answers and spends reasoning tokens that are not counted here.`),
77
+ outlineLonger: (brief, outline) => (italian
78
+ ? `La scaletta chiede ${count(outline)} capitoli e il brief ${count(brief)}: il libro ne ha ${count(outline)}, e la stima li conta tutti.`
79
+ : `The outline asks for ${count(outline)} chapters and the brief for ${count(brief)}: the book has ${count(outline)}, and the estimate counts them all.`),
80
+ /** The assumptions, one sentence each, in the order of the pipeline. */
81
+ assumptions: (facts) => {
82
+ const lines = [];
83
+ const factor = formatFactor(facts.tokensPerWord, italian);
84
+ const written = facts.written > 0;
85
+ lines.push(italian
86
+ ? `Il libro ha ${count(facts.chapters)} capitoli di ${count(facts.scenes)} scene di circa ${count(facts.wordsPerScene)} parole${written ? `; ${count(facts.written)} sono già scritti e restano ${count(facts.toWrite)} da scrivere` : ""} (${count(facts.words)} parole da scrivere). Un capitolo scritto a metà conta per intero.`
87
+ : `The book has ${count(facts.chapters)} chapters of ${count(facts.scenes)} scenes of about ${count(facts.wordsPerScene)} words${written ? `; ${count(facts.written)} are already written and ${count(facts.toWrite)} are left` : ""} (${count(facts.words)} words to write). A chapter written halfway counts as a whole one.`);
88
+ if (facts.pinned) {
89
+ lines.push(italian
90
+ ? `I giri di revisione (${facts.rounds}), le scene corrette per capitolo (${facts.repairs}) e le revisioni del piano (${facts.revisions}) sono quelli dati: il numero di chiamate è uno solo.`
91
+ : `The rounds of review (${facts.rounds}), the scenes repaired in a chapter (${facts.repairs}) and the revisions of the plan (${facts.revisions}) are the ones given: the number of calls is a single one.`);
92
+ }
93
+ else {
94
+ lines.push(italian
95
+ ? `Le chiamate sono contate dalla pipeline passo per passo. Il caso migliore approva ogni capitolo alla prima revisione e il piano al primo sguardo; il peggiore dà a ogni capitolo ${count(facts.maxRounds)} giri di revisione con ogni scena corretta e fa rivedere il piano due volte. Una corsa vera sta in mezzo.`
96
+ : `The calls are counted from the pipeline, step by step. The best case approves every chapter at its first review and the plan at its first look; the worst case gives every chapter ${count(facts.maxRounds)} rounds of review with every scene repaired and has the plan revised twice. A real run falls in between.`);
97
+ }
98
+ lines.push(italian
99
+ ? `${facts.readers > 0 ? `${count(facts.readers)} lettori simulati leggono ogni capitolo` : "Nessun lettore simulato legge i capitoli"}${facts.planReaders > 0 ? `, ${count(facts.planReaders)} leggono il piano` : ""}${facts.specialists ? "; gli specialisti rivedono ogni capitolo" : ""}. Il gruppo di lettori è di ${count(facts.panel)}.`
100
+ : `${facts.readers > 0 ? `${count(facts.readers)} simulated readers read every chapter` : "No simulated reader reads the chapters"}${facts.planReaders > 0 ? `, ${count(facts.planReaders)} read the plan` : ""}${facts.specialists ? "; the specialists review every chapter" : ""}. The panel of readers has ${count(facts.panel)}.`);
101
+ lines.push(italian
102
+ ? `I prompt sono contati come li conta il router del motore (quattro caratteri per token); il testo del libro a ${formatFactor(facts.inputPerWord, true)} token a parola e le risposte a ${factor} token a parola (il fattore del motore per la lingua, generoso per l'inglese e l'italiano): le risposte e il costo sono un'ipotesi prudente.`
103
+ : `Prompts are counted the way the engine's router counts them (four characters a token); the text of the book at ${formatFactor(facts.inputPerWord, false)} tokens a word and the replies at ${factor} tokens a word (the engine's own factor for the language, generous for English and Italian): replies and cost are a prudent guess.`);
104
+ lines.push(italian
105
+ ? "I file del libro e le risposte hanno una dimensione tipica (ESTIMATE_TYPICAL): passa in «context» quello che hai misurato per sostituirla."
106
+ : "The files of the book and the replies are given a typical size (ESTIMATE_TYPICAL): pass what you have measured in \"context\" to replace it.");
107
+ lines.push(italian
108
+ ? "Il tempo è fatto dei token che i modelli scrivono, alla velocità misurata o dichiarata di ciascun modello: la lettura del prompt, la rete e i nuovi tentativi non sono contati."
109
+ : "The time is the tokens the models write, at the speed measured or declared for each model: reading the prompt, the network and the retries are not counted.");
110
+ lines.push(italian
111
+ ? "Un modello che ragiona spende token di ragionamento che qui non sono contati, né in token né in denaro."
112
+ : "A model that reasons spends reasoning tokens that are not counted here, neither in tokens nor in money.");
113
+ if (facts.cached) {
114
+ lines.push(italian
115
+ ? "Il caso migliore conta l'inizio fisso di ogni richiesta (le istruzioni e le funzioni) al prezzo della cache; il peggiore non conta nessuna cache."
116
+ : "The best case counts the fixed start of every request (the instructions and the functions) at the cached price; the worst case counts no cache.");
117
+ }
118
+ if (facts.outlineWords > 0) {
119
+ lines.push(italian
120
+ ? `La scaletta pesa ${count(facts.outlineWords)} parole.`
121
+ : `The outline weighs ${count(facts.outlineWords)} words.`);
122
+ }
123
+ lines.push(italian
124
+ ? "Le pause, i budget e le opzioni che non cambiano quello che si chiede ai modelli (pausa dopo il piano o dopo ogni capitolo, capitoli per corsa, riempimento della scaletta) non cambiano i numeri."
125
+ : "The pauses, the budgets and the options that do not change what is asked of the models (pause after the plan or after each chapter, chapters per run, filling the outline) do not change the numbers.");
126
+ return lines;
127
+ },
128
+ };
129
+ }
130
+ //# sourceMappingURL=estimate-texts.js.map