narrarium-engine 0.1.8 → 0.1.10

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 (144) hide show
  1. package/README.md +409 -27
  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/catalog-fetch.d.ts.map +1 -1
  7. package/dist/ai/catalog-fetch.js +2 -1
  8. package/dist/ai/catalog-fetch.js.map +1 -1
  9. package/dist/ai/fetch-client.d.ts +13 -6
  10. package/dist/ai/fetch-client.d.ts.map +1 -1
  11. package/dist/ai/fetch-client.js +26 -3
  12. package/dist/ai/fetch-client.js.map +1 -1
  13. package/dist/ai/request.d.ts +1 -1
  14. package/dist/ai/request.d.ts.map +1 -1
  15. package/dist/ai/request.js +31 -5
  16. package/dist/ai/request.js.map +1 -1
  17. package/dist/ai/routing.d.ts.map +1 -1
  18. package/dist/ai/routing.js +1 -1
  19. package/dist/ai/routing.js.map +1 -1
  20. package/dist/ai/types.d.ts +29 -2
  21. package/dist/ai/types.d.ts.map +1 -1
  22. package/dist/ai/types.js +5 -2
  23. package/dist/ai/types.js.map +1 -1
  24. package/dist/autopilot/chapter-state.d.ts +19 -0
  25. package/dist/autopilot/chapter-state.d.ts.map +1 -0
  26. package/dist/autopilot/chapter-state.js +31 -0
  27. package/dist/autopilot/chapter-state.js.map +1 -0
  28. package/dist/autopilot/errors.d.ts +2 -1
  29. package/dist/autopilot/errors.d.ts.map +1 -1
  30. package/dist/autopilot/errors.js +17 -1
  31. package/dist/autopilot/errors.js.map +1 -1
  32. package/dist/autopilot/estimate-math.d.ts +19 -0
  33. package/dist/autopilot/estimate-math.d.ts.map +1 -0
  34. package/dist/autopilot/estimate-math.js +74 -0
  35. package/dist/autopilot/estimate-math.js.map +1 -0
  36. package/dist/autopilot/estimate-texts.d.ts +40 -0
  37. package/dist/autopilot/estimate-texts.d.ts.map +1 -0
  38. package/dist/autopilot/estimate-texts.js +130 -0
  39. package/dist/autopilot/estimate-texts.js.map +1 -0
  40. package/dist/autopilot/estimate.d.ts +303 -0
  41. package/dist/autopilot/estimate.d.ts.map +1 -0
  42. package/dist/autopilot/estimate.js +887 -0
  43. package/dist/autopilot/estimate.js.map +1 -0
  44. package/dist/autopilot/frozen.d.ts +166 -0
  45. package/dist/autopilot/frozen.d.ts.map +1 -0
  46. package/dist/autopilot/frozen.js +483 -0
  47. package/dist/autopilot/frozen.js.map +1 -0
  48. package/dist/autopilot/outline-change.d.ts +69 -0
  49. package/dist/autopilot/outline-change.d.ts.map +1 -0
  50. package/dist/autopilot/outline-change.js +42 -0
  51. package/dist/autopilot/outline-change.js.map +1 -0
  52. package/dist/autopilot/outline-check.d.ts +40 -0
  53. package/dist/autopilot/outline-check.d.ts.map +1 -0
  54. package/dist/autopilot/outline-check.js +84 -0
  55. package/dist/autopilot/outline-check.js.map +1 -0
  56. package/dist/autopilot/outline-compose.d.ts +203 -0
  57. package/dist/autopilot/outline-compose.d.ts.map +1 -0
  58. package/dist/autopilot/outline-compose.js +492 -0
  59. package/dist/autopilot/outline-compose.js.map +1 -0
  60. package/dist/autopilot/planner.d.ts +29 -1
  61. package/dist/autopilot/planner.d.ts.map +1 -1
  62. package/dist/autopilot/planner.js +78 -8
  63. package/dist/autopilot/planner.js.map +1 -1
  64. package/dist/autopilot/presets.d.ts +36 -0
  65. package/dist/autopilot/presets.d.ts.map +1 -0
  66. package/dist/autopilot/presets.js +54 -0
  67. package/dist/autopilot/presets.js.map +1 -0
  68. package/dist/autopilot/profile-check.d.ts +7 -4
  69. package/dist/autopilot/profile-check.d.ts.map +1 -1
  70. package/dist/autopilot/profile-check.js +9 -6
  71. package/dist/autopilot/profile-check.js.map +1 -1
  72. package/dist/autopilot/runner.d.ts +61 -7
  73. package/dist/autopilot/runner.d.ts.map +1 -1
  74. package/dist/autopilot/runner.js +313 -32
  75. package/dist/autopilot/runner.js.map +1 -1
  76. package/dist/autopilot/session.d.ts +50 -7
  77. package/dist/autopilot/session.d.ts.map +1 -1
  78. package/dist/autopilot/session.js +225 -10
  79. package/dist/autopilot/session.js.map +1 -1
  80. package/dist/autopilot/speed.d.ts +30 -0
  81. package/dist/autopilot/speed.d.ts.map +1 -0
  82. package/dist/autopilot/speed.js +71 -0
  83. package/dist/autopilot/speed.js.map +1 -0
  84. package/dist/autopilot/state.d.ts +21 -2
  85. package/dist/autopilot/state.d.ts.map +1 -1
  86. package/dist/autopilot/state.js +215 -3
  87. package/dist/autopilot/state.js.map +1 -1
  88. package/dist/autopilot/tasks.d.ts +14 -2
  89. package/dist/autopilot/tasks.d.ts.map +1 -1
  90. package/dist/autopilot/tasks.js +478 -34
  91. package/dist/autopilot/tasks.js.map +1 -1
  92. package/dist/autopilot/types.d.ts +238 -14
  93. package/dist/autopilot/types.d.ts.map +1 -1
  94. package/dist/autopilot/types.js +18 -2
  95. package/dist/autopilot/types.js.map +1 -1
  96. package/dist/book/context.d.ts +3 -0
  97. package/dist/book/context.d.ts.map +1 -1
  98. package/dist/book/context.js +7 -1
  99. package/dist/book/context.js.map +1 -1
  100. package/dist/book/freeze.d.ts +115 -0
  101. package/dist/book/freeze.d.ts.map +1 -0
  102. package/dist/book/freeze.js +286 -0
  103. package/dist/book/freeze.js.map +1 -0
  104. package/dist/book/outline.d.ts +245 -0
  105. package/dist/book/outline.d.ts.map +1 -0
  106. package/dist/book/outline.js +488 -0
  107. package/dist/book/outline.js.map +1 -0
  108. package/dist/book/paths.d.ts +18 -0
  109. package/dist/book/paths.d.ts.map +1 -1
  110. package/dist/book/paths.js +25 -0
  111. package/dist/book/paths.js.map +1 -1
  112. package/dist/book/snapshot.d.ts +25 -1
  113. package/dist/book/snapshot.d.ts.map +1 -1
  114. package/dist/book/snapshot.js +24 -4
  115. package/dist/book/snapshot.js.map +1 -1
  116. package/dist/director/opinion.d.ts +6 -0
  117. package/dist/director/opinion.d.ts.map +1 -1
  118. package/dist/director/opinion.js +4 -1
  119. package/dist/director/opinion.js.map +1 -1
  120. package/dist/index.d.ts +10 -0
  121. package/dist/index.d.ts.map +1 -1
  122. package/dist/index.js +11 -0
  123. package/dist/index.js.map +1 -1
  124. package/dist/profiles/evaluation-style.d.ts +44 -0
  125. package/dist/profiles/evaluation-style.d.ts.map +1 -0
  126. package/dist/profiles/evaluation-style.js +152 -0
  127. package/dist/profiles/evaluation-style.js.map +1 -0
  128. package/dist/server/client.d.ts +92 -7
  129. package/dist/server/client.d.ts.map +1 -1
  130. package/dist/server/client.js +138 -11
  131. package/dist/server/client.js.map +1 -1
  132. package/dist/server/protocol.d.ts +226 -2
  133. package/dist/server/protocol.d.ts.map +1 -1
  134. package/dist/server/protocol.js +69 -0
  135. package/dist/server/protocol.js.map +1 -1
  136. package/dist/util/text.d.ts +6 -0
  137. package/dist/util/text.d.ts.map +1 -1
  138. package/dist/util/text.js +21 -0
  139. package/dist/util/text.js.map +1 -1
  140. package/dist/version.d.ts +1 -1
  141. package/dist/version.d.ts.map +1 -1
  142. package/dist/version.js +1 -1
  143. package/dist/version.js.map +1 -1
  144. package/package.json +1 -1
@@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate-texts.js","sourceRoot":"","sources":["../../src/autopilot/estimate-texts.ts"],"names":[],"mappings":"AAEA,mHAAmH;AACnH,MAAM,gBAAgB,GAA4D;IAChF,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,2BAA2B,EAAE,2BAA2B,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,cAAc,EAAE;IAC1M,EAAE,EAAE,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,WAAW,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,2BAA2B,EAAE,6BAA6B,EAAE,MAAM,EAAE,WAAW,EAAE,cAAc,EAAE,eAAe,EAAE;CACpN,CAAC;AAEF,MAAM,UAAU,GAA0D;IACxE,EAAE,EAAE;QACF,OAAO,EAAE,SAAS;QAClB,oBAAoB,EAAE,uCAAuC;QAC7D,IAAI,EAAE,cAAc;QACpB,aAAa,EAAE,+BAA+B;QAC9C,aAAa,EAAE,oBAAoB;QACnC,MAAM,EAAE,oBAAoB;QAC5B,KAAK,EAAE,iBAAiB;QACxB,eAAe,EAAE,oBAAoB;QACrC,MAAM,EAAE,kCAAkC;QAC1C,iBAAiB,EAAE,qCAAqC;QACxD,WAAW,EAAE,qBAAqB;QAClC,iBAAiB,EAAE,gCAAgC;QACnD,MAAM,EAAE,mBAAmB;QAC3B,WAAW,EAAE,sBAAsB;QACnC,KAAK,EAAE,qCAAqC;KAC7C;IACD,EAAE,EAAE;QACF,OAAO,EAAE,SAAS;QAClB,oBAAoB,EAAE,sCAAsC;QAC5D,IAAI,EAAE,oBA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AC,CAAC,kHAAkH,YAAY,CAAC,KAAK,CAAC,YAAY,EAAE,KAAK,CAAC,qCAAqC,MAAM,oIAAoI,CAAC,CAAC;YAC9U,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,4IAA4I;gBAC9I,CAAC,CAAC,8IAA8I,CAAC,CAAC;YACpJ,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,iLAAiL;gBACnL,CAAC,CAAC,6JAA6J,CAAC,CAAC;YACnK,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,yGAAyG;gBAC3G,CAAC,CAAC,yGAAyG,CAAC,CAAC;YAC/G,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;gBACjB,KAAK,CAAC,IAAI,CAAC,OAAO;oBAChB,CAAC,CAAC,mJAAmJ;oBACrJ,CAAC,CAAC,iJAAiJ,CAAC,CAAC;YACzJ,CAAC;YACD,IAAI,KAAK,CAAC,YAAY,GAAG,CAAC,EAAE,CAAC;gBAC3B,KAAK,CAAC,IAAI,CAAC,OAAO;oBAChB,CAAC,CAAC,oBAAoB,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,UAAU;oBACzD,CAAC,CAAC,sBAAsB,KAAK,CAAC,KAAK,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;YAChE,CAAC;YACD,KAAK,CAAC,IAAI,CAAC,OAAO;gBAChB,CAAC,CAAC,oMAAoM;gBACtM,CAAC,CAAC,uMAAuM,CAAC,CAAC;YAC7M,OAAO,KAAK,CAAC;QACf,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,303 @@
1
+ import type { AiRuntimeConfig } from "../ai/config.js";
2
+ import type { AutopilotBrief, AutopilotOptions, AutopilotState } from "./types.js";
3
+ /** The capabilities of the router that the autopilot uses (`AI_CAPABILITIES`). */
4
+ export declare const ESTIMATE_CAPABILITIES: readonly ["autopilot", "director", "reader-evaluation", "reader-evaluation-summary", "review", "simple-tasks"];
5
+ export type EstimateCapability = (typeof ESTIMATE_CAPABILITIES)[number];
6
+ /**
7
+ * The kinds of call a run makes, in the order of the pipeline; the names are the ones the labels of the requests start with
8
+ * (`autopilot:concept`, `autopilot:scenes:3`, `reader-evaluation:…`, `director:book`). Two of them are made inside a step of another kind:
9
+ * `scene-summary` is asked by `write` and `repair`, after the scene.
10
+ */
11
+ export declare const ESTIMATE_CALL_KINDS: readonly ["concept", "summarize-imported", "plan", "plan-reader", "plan-review", "scenes", "write", "scene-summary", "reader", "readers-summary", "specialists", "director-review", "repair", "consolidate", "final"];
12
+ export type EstimateCallKind = (typeof ESTIMATE_CALL_KINDS)[number];
13
+ /**
14
+ * The sizes the estimate assumes where it cannot know them, in words (a word is six characters, the space included). They are the estimate's own
15
+ * assumptions, not measures of your book: pass what you have measured in `context`, and what a run has really spent will show where they are wrong.
16
+ * A real model may be longer or shorter than the replies it assumes; the tests that check the estimate against the pipeline answer with replies of these sizes.
17
+ */
18
+ export declare const ESTIMATE_TYPICAL: Readonly<{
19
+ /** The idea of the brief, when the author wrote none. */
20
+ ideaWords: 60;
21
+ /** What a book that is just begun holds in the files the concept reads: its description, the story design and the world context, all to be filled. */
22
+ freshBookWords: 34;
23
+ designWords: 700;
24
+ worldWords: 250;
25
+ /** The default ghostwriter profile (`defaultGhostwriter`): 906 characters, at six a word. What a book that did not write its own has. */
26
+ ghostwriterWords: 150;
27
+ /** The canon manifest: a line (kind, name, summary) for each entry, and a summary for the characters: about six characters and four other entries. */
28
+ canonWords: 270;
29
+ /** The rules of what may be revealed, which the writer and the reviewers read, and the lines of the secrets in the manifest and in the plan of the reveals. */
30
+ secretsWords: 105;
31
+ secretLineWords: 20;
32
+ revealsWords: 45;
33
+ /** The binding rules of the author and the evaluation style of the book (the whole block of a chapter's review; the review of the plan carries about half: the method and the severity). */
34
+ rulesWords: 0;
35
+ styleWords: 0;
36
+ /** The standing guidance of the director when the plan is approved, and what each chapter adds to it, up to `MAX_DIRECTOR_NOTES` notes. */
37
+ notesWords: 30;
38
+ noteWords: 25;
39
+ /** An entry of the author's outline. */
40
+ outlineEntryWords: 60;
41
+ /** One entry of the canon as the prompts that quote it give it (a heading and its body), and how many a scene, a repair and the specialists quote. */
42
+ canonEntryWords: 45;
43
+ canonEntriesScene: 4;
44
+ canonEntriesSpecialists: 6;
45
+ /**
46
+ * A chapter of the plan as a block (title, summary, purpose, point of view, key events) and as a line of a list (number, title, summary); and the line of a chapter that is
47
+ * closed, whose summary is the one the closing wrote (`consolidate`), a little longer than the plan's.
48
+ */
49
+ chapterWords: 130;
50
+ chapterLineWords: 55;
51
+ closedLineWords: 64;
52
+ /** A scene of the plan as a block, and as a line. */
53
+ sceneWords: 110;
54
+ sceneLineWords: 25;
55
+ /** The story so far: what a chapter adds to it, and the length it is asked to stay under (`STORY_SO_FAR_TARGET_WORDS`). */
56
+ storyWordsPerChapter: 75;
57
+ storyWordsTarget: 900;
58
+ /**
59
+ * The longest a list of chapters is in a prompt: 24 000 characters (`OUTLINE_MAX_CHARS`). A list that does not fit keeps the `listFullLines` lines around the chapter it is
60
+ * about whole, and gives every other chapter a line of `titleLineWords`.
61
+ */
62
+ listCapWords: 4000;
63
+ listFullLines: 30;
64
+ titleLineWords: 5;
65
+ /** The specialists' findings in a round, the proposals of the readers' summary, and the lines they make in the director's prompt. */
66
+ findings: 5;
67
+ findingWords: 55;
68
+ readerProposals: 4;
69
+ proposalWords: 35;
70
+ /** A reader as one line of the director's prompt, and a fix the director accepts as the repair is told it. */
71
+ readerLineWords: 55;
72
+ fixWords: 25;
73
+ /** A scene's summary. */
74
+ summaryWords: 35;
75
+ conceptWords: 1550;
76
+ chapterReplyWords: 125;
77
+ sceneReplyWords: 105;
78
+ planReactionWords: 100;
79
+ planReviewWords: 100;
80
+ readerWords: 150;
81
+ readersSummaryWords: 190;
82
+ findingReplyWords: 48;
83
+ directorBaseWords: 75;
84
+ decisionWords: 20;
85
+ consolidateBaseWords: 100;
86
+ recapSceneWords: 25;
87
+ importedSummaryWords: 60;
88
+ finalWords: 330;
89
+ }>;
90
+ /** The sizes of the files of the book, in words, when the host has measured them (each defaults to `ESTIMATE_TYPICAL`). */
91
+ export interface EstimateContext {
92
+ designWords?: number;
93
+ worldWords?: number;
94
+ ghostwriterWords?: number;
95
+ /** The director's profile (`director.md`): its default is the default profile's own size. */
96
+ directorWords?: number;
97
+ canonWords?: number;
98
+ secretsWords?: number;
99
+ rulesWords?: number;
100
+ notesWords?: number;
101
+ styleWords?: number;
102
+ }
103
+ /** What the model of a capability is: how it is called, what a request may hold, what it costs, how fast it writes. Nothing here is a secret. */
104
+ export interface EstimateModel {
105
+ model: string;
106
+ provider?: string;
107
+ underlyingModel?: string;
108
+ /** The window of the model: a prompt and its answer together. Not declared: not checked. */
109
+ maxInputTokens?: number;
110
+ /** The largest answer the model can give. */
111
+ maxOutputTokens?: number;
112
+ pricing?: {
113
+ inputPerMTok?: number;
114
+ cachedPerMTok?: number;
115
+ outputPerMTok?: number;
116
+ };
117
+ supportsReasoning?: boolean;
118
+ tokensPerSecond?: number;
119
+ }
120
+ export type EstimateCount = number | {
121
+ min?: number;
122
+ max?: number;
123
+ };
124
+ /**
125
+ * What the reviews of the run will be, when the host knows. Without it the estimate is an interval: from the least the pipeline does (every chapter approved at its
126
+ * first review, the plan at its first look) to the most (every round used, every scene repaired, the plan revised twice).
127
+ */
128
+ export interface EstimateScenario {
129
+ /** Rounds of review of a chapter, from 1 to the director's `maxReviewRounds`. */
130
+ rounds?: EstimateCount;
131
+ /** Scenes repaired in a chapter, in all its rounds. */
132
+ repairs?: EstimateCount;
133
+ /** Times the director sends the plan back, from 0 to 2. */
134
+ planRevisions?: EstimateCount;
135
+ }
136
+ /** Where the book is: a resume, or chapters added to a book, counts only what is left. */
137
+ export interface EstimateProgress {
138
+ /** Chapters done (the first `chaptersDone` of the book). A chapter written halfway counts as whole. */
139
+ chaptersDone?: number;
140
+ /** Chapters of the approved plan (0 when there is no approved plan yet). */
141
+ planned?: number;
142
+ /** The concept is done. Not said: it is when there is a chapter or a plan. */
143
+ conceptDone?: boolean;
144
+ /** The director has judged the book as it is. */
145
+ finalDone?: boolean;
146
+ /** Chapters the author wrote that have no summary yet: each costs one call of the simple tasks. */
147
+ withoutSummary?: number;
148
+ /** Their words, in all (not said: the length of a chapter of the brief). */
149
+ withoutSummaryWords?: number;
150
+ }
151
+ export interface EstimateOutline {
152
+ /** Chapters the author wrote an entry for. */
153
+ entries?: number;
154
+ /** The number of the last of them. */
155
+ lastChapter?: number;
156
+ /** Their words, in all (not said: `ESTIMATE_TYPICAL.outlineEntryWords` for each). */
157
+ words?: number;
158
+ }
159
+ export interface EstimateInput {
160
+ /** The brief of the form: the chapters, the scenes of a chapter, the words of a scene, and the idea and the synopsis, which weigh in the prompts that carry them. */
161
+ brief?: Partial<AutopilotBrief>;
162
+ /** `readers`, `maxReaders`, `readersOnPlan` and `specialists` change the calls; the others (`pauseAfterPlan`, `chaptersPerRun`, the budgets…) do not. */
163
+ options?: Partial<AutopilotOptions>;
164
+ /** `maxReviewRounds` of the director's profile (1 to 3, 2 when it says nothing). */
165
+ maxReviewRounds?: number;
166
+ /** The language of the book: its name or its code. The texts of the estimate are in Italian for an Italian book and in English for every other. */
167
+ language?: string;
168
+ /** The model of each capability, `null` or missing when there is none. */
169
+ models?: Partial<Record<EstimateCapability, EstimateModel | null | undefined>>;
170
+ outline?: EstimateOutline;
171
+ progress?: EstimateProgress;
172
+ scenario?: EstimateScenario;
173
+ context?: EstimateContext;
174
+ /** Readers in the panel that are enabled (the built-in panel has eight). */
175
+ readerPanelSize?: number;
176
+ /** The money of the prices; only passed on to the result. */
177
+ currency?: string;
178
+ /** Tokens a word of the book costs, when the host has measured it (not said: the engine's own factor for the language, `tokensPerWord`). */
179
+ tokensPerWord?: number;
180
+ }
181
+ export interface EstimateRange {
182
+ min: number;
183
+ max: number;
184
+ }
185
+ export interface EstimateStep {
186
+ capability: EstimateCapability;
187
+ calls: EstimateRange;
188
+ inputTokens: EstimateRange;
189
+ outputTokens: EstimateRange;
190
+ }
191
+ export interface EstimateCapabilityResult {
192
+ /** The model that is asked, `null` when there is none. */
193
+ model: string | null;
194
+ calls: EstimateRange;
195
+ inputTokens: EstimateRange;
196
+ /** The part of the input that a provider that caches the start of a request would bill at the cached price: counted only for a model that declares that price. */
197
+ cachedInputTokens: EstimateRange;
198
+ outputTokens: EstimateRange;
199
+ /** `null` when the model has no price (or there is no model); `{ min: 0, max: 0 }` when the capability makes no call. */
200
+ cost: EstimateRange | null;
201
+ /** `null` when the speed of the model is not known; `{ min: 0, max: 0 }` when the capability makes no call. */
202
+ minutes: EstimateRange | null;
203
+ }
204
+ interface EstimateWarningBase {
205
+ severity: "error" | "warning" | "info";
206
+ /** The text, in the language of the book. */
207
+ text: string;
208
+ }
209
+ /** What the interface needs to say something about a run before it starts. A structured warning has a stable `code` and its numbers; the text is only the engine's own wording. */
210
+ export type EstimateWarning = (EstimateWarningBase & {
211
+ code: "noModel";
212
+ capability: EstimateCapability;
213
+ }) | (EstimateWarningBase & {
214
+ code: "smallWindow";
215
+ capability: EstimateCapability;
216
+ model: string;
217
+ step: EstimateCallKind;
218
+ window: number;
219
+ inputBudget: number;
220
+ typicalPrompt: number;
221
+ }) | (EstimateWarningBase & {
222
+ code: "smallOutput";
223
+ capability: EstimateCapability;
224
+ model: string;
225
+ step: EstimateCallKind;
226
+ maxOutputTokens: number;
227
+ typicalReply: number;
228
+ }) | (EstimateWarningBase & {
229
+ code: "noPrice";
230
+ capability: EstimateCapability;
231
+ model: string;
232
+ }) | (EstimateWarningBase & {
233
+ code: "noSpeed";
234
+ capability: EstimateCapability;
235
+ model: string;
236
+ }) | (EstimateWarningBase & {
237
+ code: "reasoningModel";
238
+ capability: EstimateCapability;
239
+ model: string;
240
+ }) | (EstimateWarningBase & {
241
+ code: "outlineLongerThanBrief";
242
+ briefChapters: number;
243
+ outlineChapters: number;
244
+ });
245
+ export type EstimateWarningCode = EstimateWarning["code"];
246
+ export interface EstimateResult {
247
+ /** The language of the texts, as a code. */
248
+ language: string;
249
+ /** The chapters of the book (the outline can make it longer than the brief). */
250
+ chapters: number;
251
+ /** The chapters this run writes. */
252
+ chaptersToWrite: number;
253
+ /** The words it writes, at the length the brief asks. */
254
+ words: number;
255
+ calls: EstimateRange;
256
+ inputTokens: EstimateRange;
257
+ cachedInputTokens: EstimateRange;
258
+ outputTokens: EstimateRange;
259
+ /** `null` when a capability that makes calls has no price: then `unpriced` says which. */
260
+ cost: (EstimateRange & {
261
+ currency?: string;
262
+ }) | null;
263
+ unpriced: EstimateCapability[];
264
+ /** `null` when the speed of a model that is asked is not known: then `unmeasured` says which. */
265
+ minutes: EstimateRange | null;
266
+ unmeasured: EstimateCapability[];
267
+ capabilities: Record<EstimateCapability, EstimateCapabilityResult>;
268
+ steps: Record<EstimateCallKind, EstimateStep>;
269
+ warnings: EstimateWarning[];
270
+ assumptions: string[];
271
+ }
272
+ export declare function estimateAutopilotRun(input?: EstimateInput | null): EstimateResult;
273
+ /** What a host knows of how fast its models write: `measuredSpeed` gives a map like this one. */
274
+ export type EstimateSpeeds = ReadonlyMap<string, {
275
+ tokensPerSecond: number;
276
+ }> | Readonly<Record<string, {
277
+ tokensPerSecond: number;
278
+ } | undefined>>;
279
+ /**
280
+ * The model of each capability as the router would choose it (the first of `resolveAiCandidates`): its name, its window, its largest answer, its prices, whether it
281
+ * reasons, and the speed `speeds` has for it. No key, no address: only what the estimate reads. A capability the configuration has no model for is not in the answer.
282
+ */
283
+ export declare function estimateModelsFromConfig(config: AiRuntimeConfig | null | undefined, speeds?: EstimateSpeeds): Partial<Record<EstimateCapability, EstimateModel>>;
284
+ /**
285
+ * Where a book is, read from the state of the autopilot: the chapters done, the chapters of the plan when it is approved, whether the concept and the judgement of
286
+ * the whole book are done, and the chapters the author wrote that have no summary yet. What `EstimateInput.progress` takes for a book that is already started.
287
+ */
288
+ export declare function estimateProgressFromState(state: Pick<AutopilotState, "plan" | "concept" | "finalDone"> | null | undefined): Required<Omit<EstimateProgress, "withoutSummaryWords">>;
289
+ /**
290
+ * Where a book is by its chapters alone, for a book the autopilot has not started (it has no state): every chapter with prose is the author's, so it is done, and the ones
291
+ * with no summary each cost a call before the plan. `snapshot.chapters` is what it takes. For a book with a state, `estimateProgressFromState` is the one to use.
292
+ */
293
+ export declare function estimateProgressFromChapters(chapters: ReadonlyArray<{
294
+ summary?: string | null;
295
+ paragraphs?: ReadonlyArray<unknown> | null;
296
+ }> | null | undefined): Required<Pick<EstimateProgress, "chaptersDone" | "withoutSummary">>;
297
+ /**
298
+ * What the state knows of the words the prompts carry: the author's rules (`constraints`), and the standing guidance of the director (`directorNotes`) once the plan is
299
+ * approved. What `EstimateInput.context` takes for a book that is already started, so that the estimate does not start from the typical notes of a book that has none.
300
+ */
301
+ export declare function estimateContextFromState(state: Pick<AutopilotState, "constraints" | "directorNotes" | "plan"> | null | undefined): Pick<EstimateContext, "rulesWords" | "notesWords">;
302
+ export {};
303
+ //# sourceMappingURL=estimate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"estimate.d.ts","sourceRoot":"","sources":["../../src/autopilot/estimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAqBvD,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAOnF,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,gHAOvB,CAAC;AAEZ,MAAM,MAAM,kBAAkB,GAAG,CAAC,OAAO,qBAAqB,CAAC,CAAC,MAAM,CAAC,CAAC;AAExE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,uNAgBrB,CAAC;AAEZ,MAAM,MAAM,gBAAgB,GAAG,CAAC,OAAO,mBAAmB,CAAC,CAAC,MAAM,CAAC,CAAC;AAoBpE;;;;GAIG;AACH,eAAO,MAAM,gBAAgB;IAC3B,yDAAyD;;IAEzD,sJAAsJ;;;;IAItJ,yIAAyI;;IAEz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