narrarium-engine 0.0.0-stage → 0.1.0

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 (142) hide show
  1. package/README.md +104 -2
  2. package/dist/ai/config.d.ts +69 -0
  3. package/dist/ai/config.d.ts.map +1 -0
  4. package/dist/ai/config.js +100 -0
  5. package/dist/ai/config.js.map +1 -0
  6. package/dist/ai/fetch-client.d.ts +34 -0
  7. package/dist/ai/fetch-client.d.ts.map +1 -0
  8. package/dist/ai/fetch-client.js +322 -0
  9. package/dist/ai/fetch-client.js.map +1 -0
  10. package/dist/ai/router.d.ts +20 -0
  11. package/dist/ai/router.d.ts.map +1 -0
  12. package/dist/ai/router.js +95 -0
  13. package/dist/ai/router.js.map +1 -0
  14. package/dist/ai/structured.d.ts +59 -0
  15. package/dist/ai/structured.d.ts.map +1 -0
  16. package/dist/ai/structured.js +210 -0
  17. package/dist/ai/structured.js.map +1 -0
  18. package/dist/ai/token-limit.d.ts +5 -0
  19. package/dist/ai/token-limit.d.ts.map +1 -0
  20. package/dist/ai/token-limit.js +16 -0
  21. package/dist/ai/token-limit.js.map +1 -0
  22. package/dist/ai/types.d.ts +86 -0
  23. package/dist/ai/types.d.ts.map +1 -0
  24. package/dist/ai/types.js +46 -0
  25. package/dist/ai/types.js.map +1 -0
  26. package/dist/autopilot/planner.d.ts +56 -0
  27. package/dist/autopilot/planner.d.ts.map +1 -0
  28. package/dist/autopilot/planner.js +357 -0
  29. package/dist/autopilot/planner.js.map +1 -0
  30. package/dist/autopilot/prompts.d.ts +16 -0
  31. package/dist/autopilot/prompts.d.ts.map +1 -0
  32. package/dist/autopilot/prompts.js +284 -0
  33. package/dist/autopilot/prompts.js.map +1 -0
  34. package/dist/autopilot/runner.d.ts +92 -0
  35. package/dist/autopilot/runner.d.ts.map +1 -0
  36. package/dist/autopilot/runner.js +531 -0
  37. package/dist/autopilot/runner.js.map +1 -0
  38. package/dist/autopilot/session.d.ts +84 -0
  39. package/dist/autopilot/session.d.ts.map +1 -0
  40. package/dist/autopilot/session.js +248 -0
  41. package/dist/autopilot/session.js.map +1 -0
  42. package/dist/autopilot/state.d.ts +26 -0
  43. package/dist/autopilot/state.d.ts.map +1 -0
  44. package/dist/autopilot/state.js +398 -0
  45. package/dist/autopilot/state.js.map +1 -0
  46. package/dist/autopilot/story-so-far.d.ts +51 -0
  47. package/dist/autopilot/story-so-far.d.ts.map +1 -0
  48. package/dist/autopilot/story-so-far.js +137 -0
  49. package/dist/autopilot/story-so-far.js.map +1 -0
  50. package/dist/autopilot/tasks.d.ts +42 -0
  51. package/dist/autopilot/tasks.d.ts.map +1 -0
  52. package/dist/autopilot/tasks.js +1354 -0
  53. package/dist/autopilot/tasks.js.map +1 -0
  54. package/dist/autopilot/types.d.ts +373 -0
  55. package/dist/autopilot/types.d.ts.map +1 -0
  56. package/dist/autopilot/types.js +2 -0
  57. package/dist/autopilot/types.js.map +1 -0
  58. package/dist/book/context.d.ts +55 -0
  59. package/dist/book/context.d.ts.map +1 -0
  60. package/dist/book/context.js +163 -0
  61. package/dist/book/context.js.map +1 -0
  62. package/dist/book/paths.d.ts +57 -0
  63. package/dist/book/paths.d.ts.map +1 -0
  64. package/dist/book/paths.js +92 -0
  65. package/dist/book/paths.js.map +1 -0
  66. package/dist/book/snapshot.d.ts +69 -0
  67. package/dist/book/snapshot.d.ts.map +1 -0
  68. package/dist/book/snapshot.js +139 -0
  69. package/dist/book/snapshot.js.map +1 -0
  70. package/dist/book/store.d.ts +39 -0
  71. package/dist/book/store.d.ts.map +1 -0
  72. package/dist/book/store.js +28 -0
  73. package/dist/book/store.js.map +1 -0
  74. package/dist/director/opinion.d.ts +80 -0
  75. package/dist/director/opinion.d.ts.map +1 -0
  76. package/dist/director/opinion.js +302 -0
  77. package/dist/director/opinion.js.map +1 -0
  78. package/dist/index.d.ts +33 -0
  79. package/dist/index.d.ts.map +1 -0
  80. package/dist/index.js +33 -0
  81. package/dist/index.js.map +1 -0
  82. package/dist/markdown/frontmatter.d.ts +17 -0
  83. package/dist/markdown/frontmatter.d.ts.map +1 -0
  84. package/dist/markdown/frontmatter.js +67 -0
  85. package/dist/markdown/frontmatter.js.map +1 -0
  86. package/dist/profiles/director.d.ts +35 -0
  87. package/dist/profiles/director.d.ts.map +1 -0
  88. package/dist/profiles/director.js +169 -0
  89. package/dist/profiles/director.js.map +1 -0
  90. package/dist/profiles/ghostwriter.d.ts +30 -0
  91. package/dist/profiles/ghostwriter.d.ts.map +1 -0
  92. package/dist/profiles/ghostwriter.js +140 -0
  93. package/dist/profiles/ghostwriter.js.map +1 -0
  94. package/dist/profiles/readers.d.ts +35 -0
  95. package/dist/profiles/readers.d.ts.map +1 -0
  96. package/dist/profiles/readers.js +189 -0
  97. package/dist/profiles/readers.js.map +1 -0
  98. package/dist/prompt/trust.d.ts +6 -0
  99. package/dist/prompt/trust.d.ts.map +1 -0
  100. package/dist/prompt/trust.js +12 -0
  101. package/dist/prompt/trust.js.map +1 -0
  102. package/dist/readers/evaluation.d.ts +26 -0
  103. package/dist/readers/evaluation.d.ts.map +1 -0
  104. package/dist/readers/evaluation.js +92 -0
  105. package/dist/readers/evaluation.js.map +1 -0
  106. package/dist/server/client.d.ts +90 -0
  107. package/dist/server/client.d.ts.map +1 -0
  108. package/dist/server/client.js +231 -0
  109. package/dist/server/client.js.map +1 -0
  110. package/dist/server/protocol.d.ts +225 -0
  111. package/dist/server/protocol.d.ts.map +1 -0
  112. package/dist/server/protocol.js +120 -0
  113. package/dist/server/protocol.js.map +1 -0
  114. package/dist/sync/files.d.ts +43 -0
  115. package/dist/sync/files.d.ts.map +1 -0
  116. package/dist/sync/files.js +88 -0
  117. package/dist/sync/files.js.map +1 -0
  118. package/dist/testing/index.d.ts +46 -0
  119. package/dist/testing/index.d.ts.map +1 -0
  120. package/dist/testing/index.js +202 -0
  121. package/dist/testing/index.js.map +1 -0
  122. package/dist/util/abort.d.ts +11 -0
  123. package/dist/util/abort.d.ts.map +1 -0
  124. package/dist/util/abort.js +53 -0
  125. package/dist/util/abort.js.map +1 -0
  126. package/dist/util/hash.d.ts +4 -0
  127. package/dist/util/hash.d.ts.map +1 -0
  128. package/dist/util/hash.js +11 -0
  129. package/dist/util/hash.js.map +1 -0
  130. package/dist/util/json.d.ts +20 -0
  131. package/dist/util/json.d.ts.map +1 -0
  132. package/dist/util/json.js +133 -0
  133. package/dist/util/json.js.map +1 -0
  134. package/dist/util/text.d.ts +17 -0
  135. package/dist/util/text.d.ts.map +1 -0
  136. package/dist/util/text.js +99 -0
  137. package/dist/util/text.js.map +1 -0
  138. package/dist/version.d.ts +3 -0
  139. package/dist/version.d.ts.map +1 -0
  140. package/dist/version.js +3 -0
  141. package/dist/version.js.map +1 -0
  142. package/package.json +51 -4
@@ -0,0 +1,398 @@
1
+ import { asArray, asBoolean, asInteger, asNumber, asOneOf, asRecord, asString, asStringList } from "../util/json.js";
2
+ import { countWords } from "../util/text.js";
3
+ export const MAX_ACTIVITIES = 200;
4
+ export const MAX_INTERVENTIONS = 100;
5
+ export const MAX_DIRECTOR_NOTES = 12;
6
+ export const MAX_CONSTRAINTS = 80;
7
+ export const MAX_REVISION_NOTES = 40;
8
+ /** A capped list keeps its newest entries: the author's latest rules matter most. */
9
+ function newestList(value, max) {
10
+ return asStringList(value, Number.MAX_SAFE_INTEGER).slice(-max);
11
+ }
12
+ /** Permanent author rules, newest kept when the cap is reached. */
13
+ export function capConstraints(constraints) {
14
+ return newestList(constraints, MAX_CONSTRAINTS);
15
+ }
16
+ export const DEFAULT_BRIEF = {
17
+ idea: "",
18
+ synopsis: "",
19
+ targetChapters: 12,
20
+ scenesPerChapter: 3,
21
+ wordsPerScene: 1400,
22
+ genre: "",
23
+ audience: "",
24
+ };
25
+ export const DEFAULT_OPTIONS = {
26
+ readers: true,
27
+ maxReaders: 5,
28
+ readersOnPlan: true,
29
+ specialists: true,
30
+ pauseAfterPlan: true,
31
+ pauseAfterEachChapter: false,
32
+ chaptersPerRun: 0,
33
+ budgetLimit: 0,
34
+ syncAfterChapter: true,
35
+ };
36
+ const STATUSES = ["idle", "running", "paused", "waiting-author", "error", "completed"];
37
+ const PHASES = ["concept", "plan", "write", "review", "final", "completed"];
38
+ export function normalizeBrief(value, base = DEFAULT_BRIEF) {
39
+ const source = asRecord(value);
40
+ return {
41
+ idea: asString(source.idea, base.idea),
42
+ synopsis: asString(source.synopsis, base.synopsis),
43
+ targetChapters: asInteger(source.targetChapters, base.targetChapters, 1, 200),
44
+ scenesPerChapter: asInteger(source.scenesPerChapter, base.scenesPerChapter, 1, 20),
45
+ wordsPerScene: asInteger(source.wordsPerScene, base.wordsPerScene, 200, 8000),
46
+ genre: asString(source.genre, base.genre),
47
+ audience: asString(source.audience, base.audience),
48
+ };
49
+ }
50
+ export function normalizeOptions(value, base = DEFAULT_OPTIONS) {
51
+ const source = asRecord(value);
52
+ return {
53
+ readers: asBoolean(source.readers, base.readers),
54
+ maxReaders: asInteger(source.maxReaders, base.maxReaders, 1, 20),
55
+ readersOnPlan: asBoolean(source.readersOnPlan, base.readersOnPlan),
56
+ specialists: asBoolean(source.specialists, base.specialists),
57
+ pauseAfterPlan: asBoolean(source.pauseAfterPlan, base.pauseAfterPlan),
58
+ pauseAfterEachChapter: asBoolean(source.pauseAfterEachChapter, base.pauseAfterEachChapter),
59
+ chaptersPerRun: asInteger(source.chaptersPerRun, base.chaptersPerRun, 0, 200),
60
+ budgetLimit: asNumber(source.budgetLimit, base.budgetLimit, 0, 1_000_000),
61
+ syncAfterChapter: asBoolean(source.syncAfterChapter, base.syncAfterChapter),
62
+ };
63
+ }
64
+ function normalizeScene(value, index) {
65
+ const source = asRecord(value);
66
+ return {
67
+ number: asInteger(source.number, index + 1, 1, 999),
68
+ title: asString(source.title) || `Scene ${index + 1}`,
69
+ goal: asString(source.goal),
70
+ beats: asStringList(source.beats, 20),
71
+ pov: asString(source.pov) || undefined,
72
+ location: asString(source.location) || undefined,
73
+ characters: asStringList(source.characters, 20),
74
+ summary: asString(source.summary) || undefined,
75
+ status: asOneOf(source.status, ["planned", "written", "reviewed"], "planned"),
76
+ slug: asString(source.slug) || undefined,
77
+ path: asString(source.path) || undefined,
78
+ words: typeof source.words === "number" ? source.words : undefined,
79
+ revisions: asInteger(source.revisions, 0, 0, 999),
80
+ };
81
+ }
82
+ function normalizeChapter(value, index) {
83
+ const source = asRecord(value);
84
+ const number = asInteger(source.number, index + 1, 1, 999);
85
+ return {
86
+ number,
87
+ title: asString(source.title) || `Chapter ${number}`,
88
+ slug: asString(source.slug),
89
+ summary: asString(source.summary),
90
+ goal: asString(source.goal),
91
+ pov: asStringList(source.pov, 10),
92
+ keyEvents: asStringList(source.keyEvents, 20),
93
+ reveals: asStringList(source.reveals, 20),
94
+ status: asOneOf(source.status, ["planned", "writing", "review", "done"], "planned"),
95
+ imported: source.imported === true ? true : undefined,
96
+ skipReaders: source.skipReaders === true ? true : undefined,
97
+ scenes: asArray(source.scenes).map(normalizeScene),
98
+ score: typeof source.score === "number" ? source.score : undefined,
99
+ storySoFarAtClose: asString(source.storySoFarAtClose) || undefined,
100
+ };
101
+ }
102
+ function normalizePlan(value) {
103
+ if (!value || typeof value !== "object")
104
+ return null;
105
+ const source = asRecord(value);
106
+ return {
107
+ chapters: asArray(source.chapters).map(normalizeChapter).sort((left, right) => left.number - right.number),
108
+ approved: asBoolean(source.approved, false),
109
+ rounds: asInteger(source.rounds, 0, 0, 99),
110
+ revisionNotes: newestList(source.revisionNotes, MAX_REVISION_NOTES),
111
+ readerReactions: asArray(source.readerReactions).map((entry) => {
112
+ const reaction = asRecord(entry);
113
+ return {
114
+ slug: asString(reaction.slug),
115
+ name: asString(reaction.name),
116
+ interest: asNumber(reaction.interest, 5, 1, 10),
117
+ reaction: asString(reaction.reaction),
118
+ concerns: asStringList(reaction.concerns, 12),
119
+ wishes: asStringList(reaction.wishes, 12),
120
+ };
121
+ }).filter((reaction) => reaction.slug),
122
+ readersDone: asBoolean(source.readersDone, false),
123
+ awaitingAuthor: asBoolean(source.awaitingAuthor, false),
124
+ };
125
+ }
126
+ function normalizeSecrets(value) {
127
+ return asArray(value).map((entry) => {
128
+ const secret = asRecord(entry);
129
+ const revealChapter = asInteger(secret.revealChapter, 0, 0, 999);
130
+ return { slug: asString(secret.slug), title: asString(secret.title), revealChapter: revealChapter || undefined };
131
+ }).filter((secret) => secret.slug);
132
+ }
133
+ function normalizeReview(value) {
134
+ if (!value || typeof value !== "object")
135
+ return null;
136
+ const source = asRecord(value);
137
+ return {
138
+ chapterNumber: asInteger(source.chapterNumber, 1, 1, 999),
139
+ round: asInteger(source.round, 1, 1, 99),
140
+ readersPending: asStringList(source.readersPending, 40),
141
+ readerScores: asArray(source.readerScores).map((entry) => {
142
+ const score = asRecord(entry);
143
+ return {
144
+ slug: asString(score.slug),
145
+ name: asString(score.name),
146
+ score: asNumber(score.score, 5, 1, 10),
147
+ mainProblem: asString(score.mainProblem),
148
+ prioritySuggestion: asString(score.prioritySuggestion),
149
+ path: asString(score.path),
150
+ };
151
+ }).filter((score) => score.slug),
152
+ readersSummaryDone: asBoolean(source.readersSummaryDone, false),
153
+ findings: asArray(source.findings).map((entry, index) => {
154
+ const finding = asRecord(entry);
155
+ const sceneNumber = asInteger(finding.sceneNumber, 0, 0, 999);
156
+ return {
157
+ id: asString(finding.id) || `F${index + 1}`,
158
+ source: asOneOf(finding.source, ["specialist", "reader"], "specialist"),
159
+ category: asString(finding.category) || "general",
160
+ severity: asOneOf(finding.severity, ["critical", "major", "minor"], "minor"),
161
+ sceneNumber: sceneNumber || undefined,
162
+ evidence: asString(finding.evidence) || undefined,
163
+ anchored: asBoolean(finding.anchored, false),
164
+ problem: asString(finding.problem),
165
+ remediation: asString(finding.remediation),
166
+ reader: asString(finding.reader) || undefined,
167
+ };
168
+ }),
169
+ specialistsDone: asBoolean(source.specialistsDone, false),
170
+ directorDone: asBoolean(source.directorDone, false),
171
+ verdict: source.verdict === "approve" || source.verdict === "revise" ? source.verdict : undefined,
172
+ score: typeof source.score === "number" ? source.score : undefined,
173
+ summary: asString(source.summary) || undefined,
174
+ decisions: asArray(source.decisions).map((entry) => {
175
+ const decision = asRecord(entry);
176
+ const sceneNumber = asInteger(decision.sceneNumber, 0, 0, 999);
177
+ return {
178
+ findingId: asString(decision.findingId),
179
+ action: asOneOf(decision.action, ["accept", "reject"], "reject"),
180
+ rationale: asString(decision.rationale),
181
+ remediation: asString(decision.remediation),
182
+ sceneNumber: sceneNumber || undefined,
183
+ };
184
+ }),
185
+ repairQueue: asArray(source.repairQueue).map((entry) => asInteger(entry, 0, 0, 999)).filter((entry) => entry > 0),
186
+ previousFixes: asStringList(source.previousFixes, 40),
187
+ history: asArray(source.history).map((entry) => {
188
+ const item = asRecord(entry);
189
+ return {
190
+ round: asInteger(item.round, 1, 1, 99),
191
+ verdict: item.verdict === "approve" ? "approve" : "revise",
192
+ score: asNumber(item.score, 0, 0, 10),
193
+ accepted: asInteger(item.accepted, 0, 0, 999),
194
+ rejected: asInteger(item.rejected, 0, 0, 999),
195
+ };
196
+ }),
197
+ };
198
+ }
199
+ function normalizeQuestion(value) {
200
+ if (!value || typeof value !== "object")
201
+ return null;
202
+ const source = asRecord(value);
203
+ const question = asString(source.question);
204
+ if (!question)
205
+ return null;
206
+ const chapterNumber = asInteger(source.chapterNumber, 0, 0, 999);
207
+ return {
208
+ id: asString(source.id) || `question-${Date.now()}`,
209
+ kind: asOneOf(source.kind, ["plan-approval", "chapter-approval", "round-limit", "director"], "director"),
210
+ question,
211
+ context: asString(source.context),
212
+ options: asStringList(source.options, 6),
213
+ chapterNumber: chapterNumber || undefined,
214
+ askedAt: asString(source.askedAt) || new Date(0).toISOString(),
215
+ };
216
+ }
217
+ function normalizeRevision(value) {
218
+ if (!value || typeof value !== "object")
219
+ return null;
220
+ const source = asRecord(value);
221
+ const instruction = asString(source.instruction);
222
+ if (!instruction)
223
+ return null;
224
+ const revisedChapters = [...new Set(asArray(source.revisedChapters).map((entry) => asInteger(entry, 0, 0, 999)).filter((entry) => entry > 0))].sort((left, right) => left - right);
225
+ return {
226
+ id: asString(source.id) || `revision-${Date.now()}`,
227
+ instruction,
228
+ createdAt: asString(source.createdAt) || new Date(0).toISOString(),
229
+ targets: Array.isArray(source.targets)
230
+ ? source.targets.map((entry) => {
231
+ const target = asRecord(entry);
232
+ return { chapterNumber: asInteger(target.chapterNumber, 1, 1, 999), sceneNumber: asInteger(target.sceneNumber, 1, 1, 999), instruction: asString(target.instruction) };
233
+ })
234
+ : null,
235
+ cursor: asInteger(source.cursor, 0, 0, 9999),
236
+ ...(revisedChapters.length ? { revisedChapters } : {}),
237
+ };
238
+ }
239
+ function normalizeInterventions(value) {
240
+ return asArray(value).map((entry) => {
241
+ const source = asRecord(entry);
242
+ return {
243
+ id: asString(source.id),
244
+ scope: asOneOf(source.scope, ["next_step", "from_now", "rewrite"], "next_step"),
245
+ text: asString(source.text),
246
+ createdAt: asString(source.createdAt),
247
+ during: asString(source.during),
248
+ status: asOneOf(source.status, ["pending", "applied"], "applied"),
249
+ appliedAt: asString(source.appliedAt) || undefined,
250
+ appliedBy: asString(source.appliedBy) || undefined,
251
+ };
252
+ }).filter((entry) => entry.id && entry.text).slice(-MAX_INTERVENTIONS);
253
+ }
254
+ export function createAutopilotState(now, brief, options) {
255
+ const at = now.toISOString();
256
+ return {
257
+ schemaVersion: 1,
258
+ status: "idle",
259
+ phase: "concept",
260
+ brief: normalizeBrief(brief ?? {}),
261
+ options: normalizeOptions(options ?? {}),
262
+ concept: { done: false, generated: false, secrets: [] },
263
+ plan: null,
264
+ review: null,
265
+ revision: null,
266
+ finalDone: false,
267
+ constraints: [],
268
+ interventions: [],
269
+ directorNotes: [],
270
+ question: null,
271
+ runner: null,
272
+ stats: { tasks: 0, aiCalls: 0, inputTokens: 0, outputTokens: 0, cost: 0, failures: 0 },
273
+ message: null,
274
+ lastError: null,
275
+ createdAt: at,
276
+ updatedAt: at,
277
+ version: 0,
278
+ };
279
+ }
280
+ /** Tolerant reader for `autopilot/state.json`, including hand edits and older files. */
281
+ export function normalizeAutopilotState(value, now = new Date()) {
282
+ const source = asRecord(value);
283
+ const base = createAutopilotState(now);
284
+ const stats = asRecord(source.stats);
285
+ const concept = asRecord(source.concept);
286
+ const lastError = asRecord(source.lastError);
287
+ const runner = asRecord(source.runner);
288
+ return {
289
+ schemaVersion: 1,
290
+ status: asOneOf(source.status, STATUSES, "idle"),
291
+ phase: asOneOf(source.phase, PHASES, "concept"),
292
+ brief: normalizeBrief(source.brief),
293
+ options: normalizeOptions(source.options),
294
+ concept: { done: asBoolean(concept.done, false), generated: asBoolean(concept.generated, false), secrets: normalizeSecrets(concept.secrets) },
295
+ plan: normalizePlan(source.plan),
296
+ review: normalizeReview(source.review),
297
+ revision: normalizeRevision(source.revision),
298
+ finalDone: asBoolean(source.finalDone, false),
299
+ constraints: newestList(source.constraints, MAX_CONSTRAINTS),
300
+ interventions: normalizeInterventions(source.interventions),
301
+ directorNotes: newestList(source.directorNotes, MAX_DIRECTOR_NOTES),
302
+ question: normalizeQuestion(source.question),
303
+ runner: asString(runner.runId)
304
+ ? {
305
+ host: runner.host === "server" ? "server" : "browser",
306
+ label: asString(runner.label),
307
+ ...(asString(runner.hostId) ? { hostId: asString(runner.hostId) } : {}),
308
+ runId: asString(runner.runId),
309
+ startedAt: asString(runner.startedAt),
310
+ heartbeatAt: asString(runner.heartbeatAt),
311
+ }
312
+ : null,
313
+ stats: {
314
+ tasks: asInteger(stats.tasks, 0, 0, Number.MAX_SAFE_INTEGER),
315
+ aiCalls: asInteger(stats.aiCalls, 0, 0, Number.MAX_SAFE_INTEGER),
316
+ inputTokens: asInteger(stats.inputTokens, 0, 0, Number.MAX_SAFE_INTEGER),
317
+ outputTokens: asInteger(stats.outputTokens, 0, 0, Number.MAX_SAFE_INTEGER),
318
+ cost: asNumber(stats.cost, 0, 0, Number.MAX_SAFE_INTEGER),
319
+ currency: asString(stats.currency) || undefined,
320
+ failures: asInteger(stats.failures, 0, 0, Number.MAX_SAFE_INTEGER),
321
+ },
322
+ message: asString(source.message) || null,
323
+ lastError: asString(lastError.message)
324
+ ? { message: asString(lastError.message), at: asString(lastError.at), task: (asString(lastError.task) || undefined) }
325
+ : null,
326
+ createdAt: asString(source.createdAt) || base.createdAt,
327
+ updatedAt: asString(source.updatedAt) || base.updatedAt,
328
+ version: asInteger(source.version, 0, 0, Number.MAX_SAFE_INTEGER),
329
+ };
330
+ }
331
+ export function parseAutopilotState(raw, now = new Date()) {
332
+ if (!raw?.trim())
333
+ return null;
334
+ try {
335
+ return normalizeAutopilotState(JSON.parse(raw), now);
336
+ }
337
+ catch {
338
+ return null;
339
+ }
340
+ }
341
+ export function serializeAutopilotState(state) {
342
+ return `${JSON.stringify(state, null, 2)}\n`;
343
+ }
344
+ export function parseActivityLog(raw) {
345
+ if (!raw?.trim())
346
+ return [];
347
+ try {
348
+ const parsed = JSON.parse(raw);
349
+ return asArray(parsed.activities)
350
+ .filter((entry) => Boolean(entry && typeof entry === "object" && typeof entry.id === "string"))
351
+ .slice(-MAX_ACTIVITIES);
352
+ }
353
+ catch {
354
+ return [];
355
+ }
356
+ }
357
+ export function serializeActivityLog(activities) {
358
+ return `${JSON.stringify({ schemaVersion: 1, activities: activities.slice(-MAX_ACTIVITIES) }, null, 2)}\n`;
359
+ }
360
+ /** A state saved as `running` by a runner that no longer exists is shown and resumed as paused. */
361
+ export function recoverInterruptedState(state, message) {
362
+ if (state.status !== "running")
363
+ return state;
364
+ return { ...state, status: "paused", runner: null, message };
365
+ }
366
+ export function autopilotProgress(state) {
367
+ const chapters = state?.plan?.chapters ?? [];
368
+ const scenes = chapters.flatMap((chapter) => chapter.scenes);
369
+ return {
370
+ chapters: chapters.length,
371
+ chaptersDone: chapters.filter((chapter) => chapter.status === "done").length,
372
+ scenes: scenes.length,
373
+ scenesWritten: scenes.filter((scene) => scene.status !== "planned").length,
374
+ words: scenes.reduce((total, scene) => total + (scene.words ?? 0), 0),
375
+ };
376
+ }
377
+ export function summarizeAutopilotState(state) {
378
+ return {
379
+ status: state.status,
380
+ phase: state.phase,
381
+ message: state.message,
382
+ progress: autopilotProgress(state),
383
+ question: state.question,
384
+ lastError: state.lastError,
385
+ runner: state.runner,
386
+ stats: state.stats,
387
+ pendingNotes: state.interventions.filter((entry) => entry.scope === "next_step" && entry.status === "pending").length,
388
+ constraints: state.constraints.length,
389
+ updatedAt: state.updatedAt,
390
+ };
391
+ }
392
+ export function pendingNotes(state) {
393
+ return state.interventions.filter((entry) => entry.scope === "next_step" && entry.status === "pending");
394
+ }
395
+ export function wordsOf(text) {
396
+ return countWords(text);
397
+ }
398
+ //# sourceMappingURL=state.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state.js","sourceRoot":"","sources":["../../src/autopilot/state.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AACrH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAqB7C,MAAM,CAAC,MAAM,cAAc,GAAG,GAAG,CAAC;AAClC,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,CAAC;AACrC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AACrC,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAC;AAClC,MAAM,CAAC,MAAM,kBAAkB,GAAG,EAAE,CAAC;AAErC,qFAAqF;AACrF,SAAS,UAAU,CAAC,KAAc,EAAE,GAAW;IAC7C,OAAO,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,gBAAgB,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC;AAClE,CAAC;AAED,mEAAmE;AACnE,MAAM,UAAU,cAAc,CAAC,WAAqB;IAClD,OAAO,UAAU,CAAC,WAAW,EAAE,eAAe,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,aAAa,GAAmB;IA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@
1
+ import type { BookStore } from "../book/store.js";
2
+ import type { PlannedChapter } from "./types.js";
3
+ /** Length the consolidation asks for, and the hard limit it enforces on the story so far. */
4
+ export declare const STORY_SO_FAR_TARGET_WORDS = 900;
5
+ export declare const STORY_SO_FAR_MAX_WORDS = 1200;
6
+ /** Chapters that keep the synopsis saved when they closed (the newest ones); older chapters fall back to their summaries. */
7
+ export declare const MAX_STORY_SNAPSHOTS = 4;
8
+ /** Keep `autopilot/state.json` small: only the newest closing synopses are kept. */
9
+ export declare function pruneStorySnapshots(chapters: PlannedChapter[], keep?: number): void;
10
+ export interface TotalResumeSection {
11
+ number: number;
12
+ heading: string;
13
+ text: string;
14
+ }
15
+ export interface TotalResume {
16
+ /** Free text before the first chapter section (an older single-block resume, or the scaffold hint). */
17
+ preamble: string;
18
+ chapters: TotalResumeSection[];
19
+ /** Top-level sections after the chapters, such as core's "# Story State Overview", kept as they are. */
20
+ trailing: string;
21
+ }
22
+ /** Split `resumes/total.md` into its per-chapter sections (`## Chapter 001 Title`, as Narrarium core writes them). */
23
+ export declare function parseTotalResume(body: string): TotalResume;
24
+ /**
25
+ * The total resume in core's per-chapter layout: closing a chapter replaces only its own section.
26
+ * The other chapters keep their section, or get their summary when they have none yet.
27
+ */
28
+ export declare function renderTotalResumeBody(existing: string, chapters: PlannedChapter[], closing: {
29
+ number: number;
30
+ title: string;
31
+ summary: string;
32
+ }): string;
33
+ /**
34
+ * The story before a chapter (the whole book without `chapterNumber`), built from per-chapter data:
35
+ * the synopsis saved when the latest earlier chapter closed, followed by the summaries of the
36
+ * chapters closed after it. Without saved synopses, the sections of `resumes/total.md` before the
37
+ * chapter are used; a single-block resume only when no chapter from this one on was ever closed.
38
+ */
39
+ export declare function storySoFarBefore(chapters: PlannedChapter[], chapterNumber: number | undefined, totalResume?: string): string;
40
+ /** Read the story so far for a prompt, keeping its most recent part when it is too long. */
41
+ export declare function readStorySoFar(store: BookStore, input: {
42
+ chapters?: PlannedChapter[];
43
+ beforeChapter?: number;
44
+ max: number;
45
+ }): Promise<string>;
46
+ /** `null` when the story so far fits the hard limit, else how many words it is over. */
47
+ export declare function storySoFarExcess(text: string, maxWords?: number): {
48
+ words: number;
49
+ over: number;
50
+ } | null;
51
+ //# sourceMappingURL=story-so-far.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story-so-far.d.ts","sourceRoot":"","sources":["../../src/autopilot/story-so-far.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAGlD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAEjD,6FAA6F;AAC7F,eAAO,MAAM,yBAAyB,MAAM,CAAC;AAC7C,eAAO,MAAM,sBAAsB,OAAO,CAAC;AAC3C,6HAA6H;AAC7H,eAAO,MAAM,mBAAmB,IAAI,CAAC;AAErC,oFAAoF;AACpF,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,cAAc,EAAE,EAAE,IAAI,SAAsB,GAAG,IAAI,CAQhG;AAED,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,WAAW;IAC1B,uGAAuG;IACvG,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,kBAAkB,EAAE,CAAC;IAC/B,wGAAwG;IACxG,QAAQ,EAAE,MAAM,CAAC;CAClB;AAID,sHAAsH;AACtH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,WAAW,CAgC1D;AAMD;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,EAAE,OAAO,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,MAAM,CAavJ;AAOD;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,cAAc,EAAE,EAAE,aAAa,EAAE,MAAM,GAAG,SAAS,EAAE,WAAW,SAAK,GAAG,MAAM,CA4BxH;AAED,4FAA4F;AAC5F,wBAAsB,cAAc,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE;IAAE,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAC;IAAC,GAAG,EAAE,MAAM,CAAA;CAAE,GAAG,OAAO,CAAC,MAAM,CAAC,CAOnJ;AAED,wFAAwF;AACxF,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,SAAyB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,IAAI,CAGxH"}
@@ -0,0 +1,137 @@
1
+ import { isThinDocument, readDocument } from "../book/context.js";
2
+ import { AUTOPILOT_STATE_FILE, TOTAL_RESUME_FILE, formatOrdinal } from "../book/paths.js";
3
+ import { countWords, tail } from "../util/text.js";
4
+ import { parseAutopilotState } from "./state.js";
5
+ /** Length the consolidation asks for, and the hard limit it enforces on the story so far. */
6
+ export const STORY_SO_FAR_TARGET_WORDS = 900;
7
+ export const STORY_SO_FAR_MAX_WORDS = 1200;
8
+ /** Chapters that keep the synopsis saved when they closed (the newest ones); older chapters fall back to their summaries. */
9
+ export const MAX_STORY_SNAPSHOTS = 4;
10
+ /** Keep `autopilot/state.json` small: only the newest closing synopses are kept. */
11
+ export function pruneStorySnapshots(chapters, keep = MAX_STORY_SNAPSHOTS) {
12
+ chapters
13
+ .filter((chapter) => chapter.storySoFarAtClose)
14
+ .sort((left, right) => right.number - left.number)
15
+ .slice(keep)
16
+ .forEach((chapter) => {
17
+ chapter.storySoFarAtClose = undefined;
18
+ });
19
+ }
20
+ const CHAPTER_HEADING = /^##\s+(?:Chapter|Capitolo)\s+0*(\d+)\b/i;
21
+ /** Split `resumes/total.md` into its per-chapter sections (`## Chapter 001 Title`, as Narrarium core writes them). */
22
+ export function parseTotalResume(body) {
23
+ const preamble = [];
24
+ const trailing = [];
25
+ const chapters = [];
26
+ let titleSeen = false;
27
+ let inTrailing = false;
28
+ for (const line of (body ?? "").split(/\r?\n/)) {
29
+ if (inTrailing) {
30
+ trailing.push(line);
31
+ continue;
32
+ }
33
+ if (/^#\s/.test(line)) {
34
+ if (chapters.length) {
35
+ inTrailing = true;
36
+ trailing.push(line);
37
+ continue;
38
+ }
39
+ if (!titleSeen && !preamble.some((entry) => entry.trim())) {
40
+ titleSeen = true;
41
+ continue;
42
+ }
43
+ }
44
+ const match = CHAPTER_HEADING.exec(line);
45
+ if (match)
46
+ chapters.push({ number: Number(match[1]), heading: line.trim(), lines: [] });
47
+ else if (chapters.length)
48
+ chapters[chapters.length - 1].lines.push(line);
49
+ else
50
+ preamble.push(line);
51
+ }
52
+ return {
53
+ preamble: preamble.join("\n").trim(),
54
+ chapters: chapters.map((section) => ({ number: section.number, heading: section.heading, text: section.lines.join("\n").trim() })),
55
+ trailing: trailing.join("\n").trim(),
56
+ };
57
+ }
58
+ function byNumber(left, right) {
59
+ return left.number - right.number;
60
+ }
61
+ /**
62
+ * The total resume in core's per-chapter layout: closing a chapter replaces only its own section.
63
+ * The other chapters keep their section, or get their summary when they have none yet.
64
+ */
65
+ export function renderTotalResumeBody(existing, chapters, closing) {
66
+ const parsed = parseTotalResume(existing);
67
+ const sections = new Map(parsed.chapters.map((section) => [section.number, section.text]));
68
+ const lines = ["# Book So Far", ""];
69
+ for (const chapter of [...chapters].sort(byNumber)) {
70
+ const text = chapter.number === closing.number
71
+ ? closing.summary
72
+ : sections.get(chapter.number) || (chapter.status === "done" ? chapter.summary : "");
73
+ if (!text)
74
+ continue;
75
+ lines.push(`## Chapter ${formatOrdinal(chapter.number)} ${chapter.number === closing.number ? closing.title : chapter.title}`, "", text, "");
76
+ }
77
+ if (parsed.trailing)
78
+ lines.push(parsed.trailing, "");
79
+ return lines.join("\n").trim();
80
+ }
81
+ /** Whether a chapter was ever closed: its text may already be part of an older single-block resume. */
82
+ function consolidated(chapter) {
83
+ return chapter.status === "done" || Boolean(chapter.storySoFarAtClose) || chapter.scenes.some((scene) => scene.status === "reviewed");
84
+ }
85
+ /**
86
+ * The story before a chapter (the whole book without `chapterNumber`), built from per-chapter data:
87
+ * the synopsis saved when the latest earlier chapter closed, followed by the summaries of the
88
+ * chapters closed after it. Without saved synopses, the sections of `resumes/total.md` before the
89
+ * chapter are used; a single-block resume only when no chapter from this one on was ever closed.
90
+ */
91
+ export function storySoFarBefore(chapters, chapterNumber, totalResume = "") {
92
+ const ordered = [...chapters].sort(byNumber);
93
+ const before = (number) => chapterNumber === undefined || number < chapterNumber;
94
+ const done = ordered.filter((chapter) => chapter.status === "done" && before(chapter.number));
95
+ let anchor = -1;
96
+ for (let index = done.length - 1; index >= 0; index -= 1) {
97
+ if (done[index].storySoFarAtClose) {
98
+ anchor = index;
99
+ break;
100
+ }
101
+ }
102
+ const summaries = (list) => list.filter((chapter) => chapter.summary).map((chapter) => `${chapter.number}. ${chapter.title}: ${chapter.summary}`);
103
+ if (anchor >= 0) {
104
+ const later = summaries(done.slice(anchor + 1));
105
+ return [done[anchor].storySoFarAtClose, later.length ? later.join("\n") : ""].filter(Boolean).join("\n\n");
106
+ }
107
+ const resume = parseTotalResume(totalResume);
108
+ if (resume.chapters.length) {
109
+ const titles = new Map(ordered.map((chapter) => [chapter.number, chapter.title]));
110
+ const sections = new Map(resume.chapters.filter((section) => before(section.number) && section.text).map((section) => [section.number, section.text]));
111
+ for (const chapter of done)
112
+ if (!sections.has(chapter.number) && chapter.summary)
113
+ sections.set(chapter.number, chapter.summary);
114
+ return [...sections.entries()].sort(([left], [right]) => left - right)
115
+ .map(([number, text]) => `${number}. ${titles.get(number) ?? `Chapter ${number}`}: ${text}`)
116
+ .join("\n\n");
117
+ }
118
+ const closedFromHere = chapterNumber !== undefined && ordered.some((chapter) => chapter.number >= chapterNumber && consolidated(chapter));
119
+ if (!closedFromHere && resume.preamble && !isThinDocument(resume.preamble))
120
+ return resume.preamble;
121
+ return summaries(done).join("\n");
122
+ }
123
+ /** Read the story so far for a prompt, keeping its most recent part when it is too long. */
124
+ export async function readStorySoFar(store, input) {
125
+ const [resume, chapters] = await Promise.all([
126
+ readDocument(store, TOTAL_RESUME_FILE).then((loaded) => loaded?.document.body ?? ""),
127
+ input.chapters ? Promise.resolve(input.chapters) : store.read(AUTOPILOT_STATE_FILE).then((file) => parseAutopilotState(file?.content)?.plan?.chapters ?? []),
128
+ ]);
129
+ const text = storySoFarBefore(chapters, input.beforeChapter, resume).trim();
130
+ return text ? tail(text, input.max) : "";
131
+ }
132
+ /** `null` when the story so far fits the hard limit, else how many words it is over. */
133
+ export function storySoFarExcess(text, maxWords = STORY_SO_FAR_MAX_WORDS) {
134
+ const words = countWords(text);
135
+ return words > maxWords ? { words, over: words - maxWords } : null;
136
+ }
137
+ //# sourceMappingURL=story-so-far.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"story-so-far.js","sourceRoot":"","sources":["../../src/autopilot/story-so-far.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAE1F,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AAGjD,6FAA6F;AAC7F,MAAM,CAAC,MAAM,yBAAyB,GAAG,GAAG,CAAC;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,IAAI,CAAC;AAC3C,6HAA6H;AAC7H,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAErC,oFAAoF;AACpF,MAAM,UAAU,mBAAmB,CAAC,QAA0B,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