@kienmatu/inkos-core 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 (1104) hide show
  1. package/LICENSE +661 -0
  2. package/dist/agent/agent-session.d.ts +100 -0
  3. package/dist/agent/agent-session.d.ts.map +1 -0
  4. package/dist/agent/agent-session.js +1102 -0
  5. package/dist/agent/agent-session.js.map +1 -0
  6. package/dist/agent/agent-system-prompt.d.ts +12 -0
  7. package/dist/agent/agent-system-prompt.d.ts.map +1 -0
  8. package/dist/agent/agent-system-prompt.js +596 -0
  9. package/dist/agent/agent-system-prompt.js.map +1 -0
  10. package/dist/agent/agent-tools.d.ts +508 -0
  11. package/dist/agent/agent-tools.d.ts.map +1 -0
  12. package/dist/agent/agent-tools.js +3083 -0
  13. package/dist/agent/agent-tools.js.map +1 -0
  14. package/dist/agent/chapter-import-source.d.ts +16 -0
  15. package/dist/agent/chapter-import-source.d.ts.map +1 -0
  16. package/dist/agent/chapter-import-source.js +48 -0
  17. package/dist/agent/chapter-import-source.js.map +1 -0
  18. package/dist/agent/context-transform.d.ts +13 -0
  19. package/dist/agent/context-transform.d.ts.map +1 -0
  20. package/dist/agent/context-transform.js +183 -0
  21. package/dist/agent/context-transform.js.map +1 -0
  22. package/dist/agent/film-authoring-tools.d.ts +98 -0
  23. package/dist/agent/film-authoring-tools.d.ts.map +1 -0
  24. package/dist/agent/film-authoring-tools.js +405 -0
  25. package/dist/agent/film-authoring-tools.js.map +1 -0
  26. package/dist/agent/forecast-tools.d.ts +22 -0
  27. package/dist/agent/forecast-tools.d.ts.map +1 -0
  28. package/dist/agent/forecast-tools.js +153 -0
  29. package/dist/agent/forecast-tools.js.map +1 -0
  30. package/dist/agent/index.d.ts +8 -0
  31. package/dist/agent/index.d.ts.map +1 -0
  32. package/dist/agent/index.js +8 -0
  33. package/dist/agent/index.js.map +1 -0
  34. package/dist/agent/llm-stub.d.ts +19 -0
  35. package/dist/agent/llm-stub.d.ts.map +1 -0
  36. package/dist/agent/llm-stub.js +134 -0
  37. package/dist/agent/llm-stub.js.map +1 -0
  38. package/dist/agent/pi-stream.d.ts +8 -0
  39. package/dist/agent/pi-stream.d.ts.map +1 -0
  40. package/dist/agent/pi-stream.js +31 -0
  41. package/dist/agent/pi-stream.js.map +1 -0
  42. package/dist/agent/skill-tool.d.ts +42 -0
  43. package/dist/agent/skill-tool.d.ts.map +1 -0
  44. package/dist/agent/skill-tool.js +279 -0
  45. package/dist/agent/skill-tool.js.map +1 -0
  46. package/dist/agent/worker-agent.d.ts +24 -0
  47. package/dist/agent/worker-agent.d.ts.map +1 -0
  48. package/dist/agent/worker-agent.js +288 -0
  49. package/dist/agent/worker-agent.js.map +1 -0
  50. package/dist/agents/ai-tells.d.ts +26 -0
  51. package/dist/agents/ai-tells.d.ts.map +1 -0
  52. package/dist/agents/ai-tells.js +140 -0
  53. package/dist/agents/ai-tells.js.map +1 -0
  54. package/dist/agents/architect.d.ts +78 -0
  55. package/dist/agents/architect.d.ts.map +1 -0
  56. package/dist/agents/architect.js +1184 -0
  57. package/dist/agents/architect.js.map +1 -0
  58. package/dist/agents/base.d.ts +42 -0
  59. package/dist/agents/base.d.ts.map +1 -0
  60. package/dist/agents/base.js +123 -0
  61. package/dist/agents/base.js.map +1 -0
  62. package/dist/agents/chapter-analyzer.d.ts +30 -0
  63. package/dist/agents/chapter-analyzer.d.ts.map +1 -0
  64. package/dist/agents/chapter-analyzer.js +509 -0
  65. package/dist/agents/chapter-analyzer.js.map +1 -0
  66. package/dist/agents/composer.d.ts +67 -0
  67. package/dist/agents/composer.d.ts.map +1 -0
  68. package/dist/agents/composer.js +936 -0
  69. package/dist/agents/composer.js.map +1 -0
  70. package/dist/agents/consolidator.d.ts +39 -0
  71. package/dist/agents/consolidator.d.ts.map +1 -0
  72. package/dist/agents/consolidator.js +179 -0
  73. package/dist/agents/consolidator.js.map +1 -0
  74. package/dist/agents/continuity.d.ts +45 -0
  75. package/dist/agents/continuity.d.ts.map +1 -0
  76. package/dist/agents/continuity.js +722 -0
  77. package/dist/agents/continuity.js.map +1 -0
  78. package/dist/agents/detection-insights.d.ts +9 -0
  79. package/dist/agents/detection-insights.d.ts.map +1 -0
  80. package/dist/agents/detection-insights.js +54 -0
  81. package/dist/agents/detection-insights.js.map +1 -0
  82. package/dist/agents/detector.d.ts +17 -0
  83. package/dist/agents/detector.d.ts.map +1 -0
  84. package/dist/agents/detector.js +77 -0
  85. package/dist/agents/detector.js.map +1 -0
  86. package/dist/agents/en-prompt-sections.d.ts +4 -0
  87. package/dist/agents/en-prompt-sections.d.ts.map +1 -0
  88. package/dist/agents/en-prompt-sections.js +9 -0
  89. package/dist/agents/en-prompt-sections.js.map +1 -0
  90. package/dist/agents/fanfic-canon-importer.d.ts +16 -0
  91. package/dist/agents/fanfic-canon-importer.d.ts.map +1 -0
  92. package/dist/agents/fanfic-canon-importer.js +164 -0
  93. package/dist/agents/fanfic-canon-importer.js.map +1 -0
  94. package/dist/agents/fanfic-dimensions.d.ts +14 -0
  95. package/dist/agents/fanfic-dimensions.d.ts.map +1 -0
  96. package/dist/agents/fanfic-dimensions.js +63 -0
  97. package/dist/agents/fanfic-dimensions.js.map +1 -0
  98. package/dist/agents/fanfic-prompt-sections.d.ts +5 -0
  99. package/dist/agents/fanfic-prompt-sections.d.ts.map +1 -0
  100. package/dist/agents/fanfic-prompt-sections.js +85 -0
  101. package/dist/agents/fanfic-prompt-sections.js.map +1 -0
  102. package/dist/agents/foundation-reviewer.d.ts +34 -0
  103. package/dist/agents/foundation-reviewer.d.ts.map +1 -0
  104. package/dist/agents/foundation-reviewer.js +174 -0
  105. package/dist/agents/foundation-reviewer.js.map +1 -0
  106. package/dist/agents/observer-prompts.d.ts +10 -0
  107. package/dist/agents/observer-prompts.d.ts.map +1 -0
  108. package/dist/agents/observer-prompts.js +113 -0
  109. package/dist/agents/observer-prompts.js.map +1 -0
  110. package/dist/agents/planner-context.d.ts +53 -0
  111. package/dist/agents/planner-context.d.ts.map +1 -0
  112. package/dist/agents/planner-context.js +238 -0
  113. package/dist/agents/planner-context.js.map +1 -0
  114. package/dist/agents/planner-prompts.d.ts +45 -0
  115. package/dist/agents/planner-prompts.d.ts.map +1 -0
  116. package/dist/agents/planner-prompts.js +391 -0
  117. package/dist/agents/planner-prompts.js.map +1 -0
  118. package/dist/agents/planner.d.ts +90 -0
  119. package/dist/agents/planner.d.ts.map +1 -0
  120. package/dist/agents/planner.js +715 -0
  121. package/dist/agents/planner.js.map +1 -0
  122. package/dist/agents/polisher.d.ts +33 -0
  123. package/dist/agents/polisher.d.ts.map +1 -0
  124. package/dist/agents/polisher.js +122 -0
  125. package/dist/agents/polisher.js.map +1 -0
  126. package/dist/agents/post-write-validator.d.ts +35 -0
  127. package/dist/agents/post-write-validator.d.ts.map +1 -0
  128. package/dist/agents/post-write-validator.js +758 -0
  129. package/dist/agents/post-write-validator.js.map +1 -0
  130. package/dist/agents/radar-source.d.ts +38 -0
  131. package/dist/agents/radar-source.d.ts.map +1 -0
  132. package/dist/agents/radar-source.js +92 -0
  133. package/dist/agents/radar-source.js.map +1 -0
  134. package/dist/agents/radar.d.ts +24 -0
  135. package/dist/agents/radar.d.ts.map +1 -0
  136. package/dist/agents/radar.js +85 -0
  137. package/dist/agents/radar.js.map +1 -0
  138. package/dist/agents/researcher.d.ts +38 -0
  139. package/dist/agents/researcher.d.ts.map +1 -0
  140. package/dist/agents/researcher.js +164 -0
  141. package/dist/agents/researcher.js.map +1 -0
  142. package/dist/agents/reviser.d.ts +35 -0
  143. package/dist/agents/reviser.d.ts.map +1 -0
  144. package/dist/agents/reviser.js +496 -0
  145. package/dist/agents/reviser.js.map +1 -0
  146. package/dist/agents/rules-reader.d.ts +32 -0
  147. package/dist/agents/rules-reader.d.ts.map +1 -0
  148. package/dist/agents/rules-reader.js +129 -0
  149. package/dist/agents/rules-reader.js.map +1 -0
  150. package/dist/agents/script-storyboard.d.ts +66 -0
  151. package/dist/agents/script-storyboard.d.ts.map +1 -0
  152. package/dist/agents/script-storyboard.js +657 -0
  153. package/dist/agents/script-storyboard.js.map +1 -0
  154. package/dist/agents/sensitive-words.d.ts +24 -0
  155. package/dist/agents/sensitive-words.d.ts.map +1 -0
  156. package/dist/agents/sensitive-words.js +103 -0
  157. package/dist/agents/sensitive-words.js.map +1 -0
  158. package/dist/agents/settler-delta-parser.d.ts +7 -0
  159. package/dist/agents/settler-delta-parser.d.ts.map +1 -0
  160. package/dist/agents/settler-delta-parser.js +40 -0
  161. package/dist/agents/settler-delta-parser.js.map +1 -0
  162. package/dist/agents/settler-parser.d.ts +13 -0
  163. package/dist/agents/settler-parser.d.ts.map +1 -0
  164. package/dist/agents/settler-parser.js +20 -0
  165. package/dist/agents/settler-parser.js.map +1 -0
  166. package/dist/agents/settler-prompts.d.ts +22 -0
  167. package/dist/agents/settler-prompts.d.ts.map +1 -0
  168. package/dist/agents/settler-prompts.js +195 -0
  169. package/dist/agents/settler-prompts.js.map +1 -0
  170. package/dist/agents/short-fiction.d.ts +120 -0
  171. package/dist/agents/short-fiction.d.ts.map +1 -0
  172. package/dist/agents/short-fiction.js +353 -0
  173. package/dist/agents/short-fiction.js.map +1 -0
  174. package/dist/agents/state-validator.d.ts +33 -0
  175. package/dist/agents/state-validator.d.ts.map +1 -0
  176. package/dist/agents/state-validator.js +262 -0
  177. package/dist/agents/state-validator.js.map +1 -0
  178. package/dist/agents/style-analyzer.d.ts +11 -0
  179. package/dist/agents/style-analyzer.d.ts.map +1 -0
  180. package/dist/agents/style-analyzer.js +98 -0
  181. package/dist/agents/style-analyzer.js.map +1 -0
  182. package/dist/agents/writer-parser.d.ts +17 -0
  183. package/dist/agents/writer-parser.d.ts.map +1 -0
  184. package/dist/agents/writer-parser.js +131 -0
  185. package/dist/agents/writer-parser.js.map +1 -0
  186. package/dist/agents/writer-prompts.d.ts +12 -0
  187. package/dist/agents/writer-prompts.d.ts.map +1 -0
  188. package/dist/agents/writer-prompts.js +495 -0
  189. package/dist/agents/writer-prompts.js.map +1 -0
  190. package/dist/agents/writer.d.ts +102 -0
  191. package/dist/agents/writer.d.ts.map +1 -0
  192. package/dist/agents/writer.js +882 -0
  193. package/dist/agents/writer.js.map +1 -0
  194. package/dist/forecast/agent.d.ts +22 -0
  195. package/dist/forecast/agent.d.ts.map +1 -0
  196. package/dist/forecast/agent.js +48 -0
  197. package/dist/forecast/agent.js.map +1 -0
  198. package/dist/forecast/context-builder.d.ts +35 -0
  199. package/dist/forecast/context-builder.d.ts.map +1 -0
  200. package/dist/forecast/context-builder.js +214 -0
  201. package/dist/forecast/context-builder.js.map +1 -0
  202. package/dist/forecast/prompts.d.ts +12 -0
  203. package/dist/forecast/prompts.d.ts.map +1 -0
  204. package/dist/forecast/prompts.js +114 -0
  205. package/dist/forecast/prompts.js.map +1 -0
  206. package/dist/forecast/render.d.ts +9 -0
  207. package/dist/forecast/render.d.ts.map +1 -0
  208. package/dist/forecast/render.js +154 -0
  209. package/dist/forecast/render.js.map +1 -0
  210. package/dist/forecast/runner.d.ts +51 -0
  211. package/dist/forecast/runner.d.ts.map +1 -0
  212. package/dist/forecast/runner.js +115 -0
  213. package/dist/forecast/runner.js.map +1 -0
  214. package/dist/forecast/schema.d.ts +767 -0
  215. package/dist/forecast/schema.d.ts.map +1 -0
  216. package/dist/forecast/schema.js +115 -0
  217. package/dist/forecast/schema.js.map +1 -0
  218. package/dist/forecast/store.d.ts +32 -0
  219. package/dist/forecast/store.d.ts.map +1 -0
  220. package/dist/forecast/store.js +129 -0
  221. package/dist/forecast/store.js.map +1 -0
  222. package/dist/index.d.ts +160 -0
  223. package/dist/index.d.ts.map +1 -0
  224. package/dist/index.js +172 -0
  225. package/dist/index.js.map +1 -0
  226. package/dist/interaction/action-envelope.d.ts +1493 -0
  227. package/dist/interaction/action-envelope.d.ts.map +1 -0
  228. package/dist/interaction/action-envelope.js +257 -0
  229. package/dist/interaction/action-envelope.js.map +1 -0
  230. package/dist/interaction/book-session-store.d.ts +29 -0
  231. package/dist/interaction/book-session-store.d.ts.map +1 -0
  232. package/dist/interaction/book-session-store.js +185 -0
  233. package/dist/interaction/book-session-store.js.map +1 -0
  234. package/dist/interaction/draft-directive-parser.d.ts +38 -0
  235. package/dist/interaction/draft-directive-parser.d.ts.map +1 -0
  236. package/dist/interaction/draft-directive-parser.js +208 -0
  237. package/dist/interaction/draft-directive-parser.js.map +1 -0
  238. package/dist/interaction/edit-controller.d.ts +62 -0
  239. package/dist/interaction/edit-controller.d.ts.map +1 -0
  240. package/dist/interaction/edit-controller.js +381 -0
  241. package/dist/interaction/edit-controller.js.map +1 -0
  242. package/dist/interaction/events.d.ts +45 -0
  243. package/dist/interaction/events.d.ts.map +1 -0
  244. package/dist/interaction/events.js +32 -0
  245. package/dist/interaction/events.js.map +1 -0
  246. package/dist/interaction/export-artifact.d.ts +32 -0
  247. package/dist/interaction/export-artifact.d.ts.map +1 -0
  248. package/dist/interaction/export-artifact.js +103 -0
  249. package/dist/interaction/export-artifact.js.map +1 -0
  250. package/dist/interaction/intents.d.ts +99 -0
  251. package/dist/interaction/intents.d.ts.map +1 -0
  252. package/dist/interaction/intents.js +59 -0
  253. package/dist/interaction/intents.js.map +1 -0
  254. package/dist/interaction/modes.d.ts +5 -0
  255. package/dist/interaction/modes.d.ts.map +1 -0
  256. package/dist/interaction/modes.js +7 -0
  257. package/dist/interaction/modes.js.map +1 -0
  258. package/dist/interaction/project-control.d.ts +45 -0
  259. package/dist/interaction/project-control.d.ts.map +1 -0
  260. package/dist/interaction/project-control.js +71 -0
  261. package/dist/interaction/project-control.js.map +1 -0
  262. package/dist/interaction/project-session-store.d.ts +9 -0
  263. package/dist/interaction/project-session-store.d.ts.map +1 -0
  264. package/dist/interaction/project-session-store.js +64 -0
  265. package/dist/interaction/project-session-store.js.map +1 -0
  266. package/dist/interaction/project-tools.d.ts +23 -0
  267. package/dist/interaction/project-tools.d.ts.map +1 -0
  268. package/dist/interaction/project-tools.js +408 -0
  269. package/dist/interaction/project-tools.js.map +1 -0
  270. package/dist/interaction/request-router.d.ts +3 -0
  271. package/dist/interaction/request-router.d.ts.map +1 -0
  272. package/dist/interaction/request-router.js +5 -0
  273. package/dist/interaction/request-router.js.map +1 -0
  274. package/dist/interaction/runtime.d.ts +54 -0
  275. package/dist/interaction/runtime.d.ts.map +1 -0
  276. package/dist/interaction/runtime.js +919 -0
  277. package/dist/interaction/runtime.js.map +1 -0
  278. package/dist/interaction/session-transcript-legacy.d.ts +4 -0
  279. package/dist/interaction/session-transcript-legacy.d.ts.map +1 -0
  280. package/dist/interaction/session-transcript-legacy.js +102 -0
  281. package/dist/interaction/session-transcript-legacy.js.map +1 -0
  282. package/dist/interaction/session-transcript-restore.d.ts +18 -0
  283. package/dist/interaction/session-transcript-restore.d.ts.map +1 -0
  284. package/dist/interaction/session-transcript-restore.js +746 -0
  285. package/dist/interaction/session-transcript-restore.js.map +1 -0
  286. package/dist/interaction/session-transcript-schema.d.ts +435 -0
  287. package/dist/interaction/session-transcript-schema.d.ts.map +1 -0
  288. package/dist/interaction/session-transcript-schema.js +65 -0
  289. package/dist/interaction/session-transcript-schema.js.map +1 -0
  290. package/dist/interaction/session-transcript.d.ts +21 -0
  291. package/dist/interaction/session-transcript.d.ts.map +1 -0
  292. package/dist/interaction/session-transcript.js +164 -0
  293. package/dist/interaction/session-transcript.js.map +1 -0
  294. package/dist/interaction/session.d.ts +1194 -0
  295. package/dist/interaction/session.d.ts.map +1 -0
  296. package/dist/interaction/session.js +194 -0
  297. package/dist/interaction/session.js.map +1 -0
  298. package/dist/interaction/truth-authority.d.ts +4 -0
  299. package/dist/interaction/truth-authority.d.ts.map +1 -0
  300. package/dist/interaction/truth-authority.js +37 -0
  301. package/dist/interaction/truth-authority.js.map +1 -0
  302. package/dist/interactive-film/authoring-store.d.ts +35 -0
  303. package/dist/interactive-film/authoring-store.d.ts.map +1 -0
  304. package/dist/interactive-film/authoring-store.js +114 -0
  305. package/dist/interactive-film/authoring-store.js.map +1 -0
  306. package/dist/interactive-film/authoring-tools.d.ts +9 -0
  307. package/dist/interactive-film/authoring-tools.d.ts.map +1 -0
  308. package/dist/interactive-film/authoring-tools.js +19 -0
  309. package/dist/interactive-film/authoring-tools.js.map +1 -0
  310. package/dist/interactive-film/delta.d.ts +591 -0
  311. package/dist/interactive-film/delta.d.ts.map +1 -0
  312. package/dist/interactive-film/delta.js +54 -0
  313. package/dist/interactive-film/delta.js.map +1 -0
  314. package/dist/interactive-film/emotion.d.ts +20 -0
  315. package/dist/interactive-film/emotion.d.ts.map +1 -0
  316. package/dist/interactive-film/emotion.js +57 -0
  317. package/dist/interactive-film/emotion.js.map +1 -0
  318. package/dist/interactive-film/evaluator.d.ts +7 -0
  319. package/dist/interactive-film/evaluator.d.ts.map +1 -0
  320. package/dist/interactive-film/evaluator.js +40 -0
  321. package/dist/interactive-film/evaluator.js.map +1 -0
  322. package/dist/interactive-film/export-html.d.ts +6 -0
  323. package/dist/interactive-film/export-html.d.ts.map +1 -0
  324. package/dist/interactive-film/export-html.js +84 -0
  325. package/dist/interactive-film/export-html.js.map +1 -0
  326. package/dist/interactive-film/export-ink.d.ts +3 -0
  327. package/dist/interactive-film/export-ink.d.ts.map +1 -0
  328. package/dist/interactive-film/export-ink.js +51 -0
  329. package/dist/interactive-film/export-ink.js.map +1 -0
  330. package/dist/interactive-film/film-context.d.ts +4 -0
  331. package/dist/interactive-film/film-context.d.ts.map +1 -0
  332. package/dist/interactive-film/film-context.js +30 -0
  333. package/dist/interactive-film/film-context.js.map +1 -0
  334. package/dist/interactive-film/generate.d.ts +15 -0
  335. package/dist/interactive-film/generate.d.ts.map +1 -0
  336. package/dist/interactive-film/generate.js +51 -0
  337. package/dist/interactive-film/generate.js.map +1 -0
  338. package/dist/interactive-film/graph-schema.d.ts +819 -0
  339. package/dist/interactive-film/graph-schema.d.ts.map +1 -0
  340. package/dist/interactive-film/graph-schema.js +84 -0
  341. package/dist/interactive-film/graph-schema.js.map +1 -0
  342. package/dist/interactive-film/graph-store.d.ts +5 -0
  343. package/dist/interactive-film/graph-store.d.ts.map +1 -0
  344. package/dist/interactive-film/graph-store.js +24 -0
  345. package/dist/interactive-film/graph-store.js.map +1 -0
  346. package/dist/interactive-film/memory-link.d.ts +9 -0
  347. package/dist/interactive-film/memory-link.d.ts.map +1 -0
  348. package/dist/interactive-film/memory-link.js +15 -0
  349. package/dist/interactive-film/memory-link.js.map +1 -0
  350. package/dist/interactive-film/node-image.d.ts +29 -0
  351. package/dist/interactive-film/node-image.d.ts.map +1 -0
  352. package/dist/interactive-film/node-image.js +52 -0
  353. package/dist/interactive-film/node-image.js.map +1 -0
  354. package/dist/interactive-film/paths.d.ts +14 -0
  355. package/dist/interactive-film/paths.d.ts.map +1 -0
  356. package/dist/interactive-film/paths.js +60 -0
  357. package/dist/interactive-film/paths.js.map +1 -0
  358. package/dist/interactive-film/tool-schemas.d.ts +182 -0
  359. package/dist/interactive-film/tool-schemas.d.ts.map +1 -0
  360. package/dist/interactive-film/tool-schemas.js +125 -0
  361. package/dist/interactive-film/tool-schemas.js.map +1 -0
  362. package/dist/interactive-film/validation.d.ts +14 -0
  363. package/dist/interactive-film/validation.d.ts.map +1 -0
  364. package/dist/interactive-film/validation.js +292 -0
  365. package/dist/interactive-film/validation.js.map +1 -0
  366. package/dist/llm/agent-trajectory.d.ts +27 -0
  367. package/dist/llm/agent-trajectory.d.ts.map +1 -0
  368. package/dist/llm/agent-trajectory.js +74 -0
  369. package/dist/llm/agent-trajectory.js.map +1 -0
  370. package/dist/llm/config-migration.d.ts +5 -0
  371. package/dist/llm/config-migration.d.ts.map +1 -0
  372. package/dist/llm/config-migration.js +51 -0
  373. package/dist/llm/config-migration.js.map +1 -0
  374. package/dist/llm/cover-providers.d.ts +14 -0
  375. package/dist/llm/cover-providers.d.ts.map +1 -0
  376. package/dist/llm/cover-providers.js +51 -0
  377. package/dist/llm/cover-providers.js.map +1 -0
  378. package/dist/llm/long-form-completion.d.ts +16 -0
  379. package/dist/llm/long-form-completion.d.ts.map +1 -0
  380. package/dist/llm/long-form-completion.js +62 -0
  381. package/dist/llm/long-form-completion.js.map +1 -0
  382. package/dist/llm/provider.d.ts +110 -0
  383. package/dist/llm/provider.d.ts.map +1 -0
  384. package/dist/llm/provider.js +1405 -0
  385. package/dist/llm/provider.js.map +1 -0
  386. package/dist/llm/providers/endpoints/ai360.d.ts +10 -0
  387. package/dist/llm/providers/endpoints/ai360.d.ts.map +1 -0
  388. package/dist/llm/providers/endpoints/ai360.js +34 -0
  389. package/dist/llm/providers/endpoints/ai360.js.map +1 -0
  390. package/dist/llm/providers/endpoints/anthropic.d.ts +12 -0
  391. package/dist/llm/providers/endpoints/anthropic.d.ts.map +1 -0
  392. package/dist/llm/providers/endpoints/anthropic.js +72 -0
  393. package/dist/llm/providers/endpoints/anthropic.js.map +1 -0
  394. package/dist/llm/providers/endpoints/astronCodingPlan.d.ts +16 -0
  395. package/dist/llm/providers/endpoints/astronCodingPlan.d.ts.map +1 -0
  396. package/dist/llm/providers/endpoints/astronCodingPlan.js +16 -0
  397. package/dist/llm/providers/endpoints/astronCodingPlan.js.map +1 -0
  398. package/dist/llm/providers/endpoints/baichuan.d.ts +10 -0
  399. package/dist/llm/providers/endpoints/baichuan.d.ts.map +1 -0
  400. package/dist/llm/providers/endpoints/baichuan.js +20 -0
  401. package/dist/llm/providers/endpoints/baichuan.js.map +1 -0
  402. package/dist/llm/providers/endpoints/bailian.d.ts +25 -0
  403. package/dist/llm/providers/endpoints/bailian.d.ts.map +1 -0
  404. package/dist/llm/providers/endpoints/bailian.js +42 -0
  405. package/dist/llm/providers/endpoints/bailian.js.map +1 -0
  406. package/dist/llm/providers/endpoints/bailianCodingPlan.d.ts +10 -0
  407. package/dist/llm/providers/endpoints/bailianCodingPlan.d.ts.map +1 -0
  408. package/dist/llm/providers/endpoints/bailianCodingPlan.js +22 -0
  409. package/dist/llm/providers/endpoints/bailianCodingPlan.js.map +1 -0
  410. package/dist/llm/providers/endpoints/custom.d.ts +16 -0
  411. package/dist/llm/providers/endpoints/custom.d.ts.map +1 -0
  412. package/dist/llm/providers/endpoints/custom.js +15 -0
  413. package/dist/llm/providers/endpoints/custom.js.map +1 -0
  414. package/dist/llm/providers/endpoints/deepseek.d.ts +17 -0
  415. package/dist/llm/providers/endpoints/deepseek.d.ts.map +1 -0
  416. package/dist/llm/providers/endpoints/deepseek.js +20 -0
  417. package/dist/llm/providers/endpoints/deepseek.js.map +1 -0
  418. package/dist/llm/providers/endpoints/giteeai.d.ts +10 -0
  419. package/dist/llm/providers/endpoints/giteeai.d.ts.map +1 -0
  420. package/dist/llm/providers/endpoints/giteeai.js +33 -0
  421. package/dist/llm/providers/endpoints/giteeai.js.map +1 -0
  422. package/dist/llm/providers/endpoints/githubCopilot.d.ts +10 -0
  423. package/dist/llm/providers/endpoints/githubCopilot.d.ts.map +1 -0
  424. package/dist/llm/providers/endpoints/githubCopilot.js +35 -0
  425. package/dist/llm/providers/endpoints/githubCopilot.js.map +1 -0
  426. package/dist/llm/providers/endpoints/glmCodingPlan.d.ts +9 -0
  427. package/dist/llm/providers/endpoints/glmCodingPlan.d.ts.map +1 -0
  428. package/dist/llm/providers/endpoints/glmCodingPlan.js +21 -0
  429. package/dist/llm/providers/endpoints/glmCodingPlan.js.map +1 -0
  430. package/dist/llm/providers/endpoints/google.d.ts +12 -0
  431. package/dist/llm/providers/endpoints/google.d.ts.map +1 -0
  432. package/dist/llm/providers/endpoints/google.js +41 -0
  433. package/dist/llm/providers/endpoints/google.js.map +1 -0
  434. package/dist/llm/providers/endpoints/hunyuan.d.ts +10 -0
  435. package/dist/llm/providers/endpoints/hunyuan.d.ts.map +1 -0
  436. package/dist/llm/providers/endpoints/hunyuan.js +34 -0
  437. package/dist/llm/providers/endpoints/hunyuan.js.map +1 -0
  438. package/dist/llm/providers/endpoints/infiniai.d.ts +10 -0
  439. package/dist/llm/providers/endpoints/infiniai.d.ts.map +1 -0
  440. package/dist/llm/providers/endpoints/infiniai.js +64 -0
  441. package/dist/llm/providers/endpoints/infiniai.js.map +1 -0
  442. package/dist/llm/providers/endpoints/internlm.d.ts +10 -0
  443. package/dist/llm/providers/endpoints/internlm.d.ts.map +1 -0
  444. package/dist/llm/providers/endpoints/internlm.js +20 -0
  445. package/dist/llm/providers/endpoints/internlm.js.map +1 -0
  446. package/dist/llm/providers/endpoints/kimiCode.d.ts +9 -0
  447. package/dist/llm/providers/endpoints/kimiCode.d.ts.map +1 -0
  448. package/dist/llm/providers/endpoints/kimiCode.js +16 -0
  449. package/dist/llm/providers/endpoints/kimiCode.js.map +1 -0
  450. package/dist/llm/providers/endpoints/kimiCodingPlan.d.ts +9 -0
  451. package/dist/llm/providers/endpoints/kimiCodingPlan.d.ts.map +1 -0
  452. package/dist/llm/providers/endpoints/kimiCodingPlan.js +17 -0
  453. package/dist/llm/providers/endpoints/kimiCodingPlan.js.map +1 -0
  454. package/dist/llm/providers/endpoints/kkaiapi.d.ts +14 -0
  455. package/dist/llm/providers/endpoints/kkaiapi.d.ts.map +1 -0
  456. package/dist/llm/providers/endpoints/kkaiapi.js +44 -0
  457. package/dist/llm/providers/endpoints/kkaiapi.js.map +1 -0
  458. package/dist/llm/providers/endpoints/lmstudio.d.ts +10 -0
  459. package/dist/llm/providers/endpoints/lmstudio.d.ts.map +1 -0
  460. package/dist/llm/providers/endpoints/lmstudio.js +15 -0
  461. package/dist/llm/providers/endpoints/lmstudio.js.map +1 -0
  462. package/dist/llm/providers/endpoints/longcat.d.ts +9 -0
  463. package/dist/llm/providers/endpoints/longcat.d.ts.map +1 -0
  464. package/dist/llm/providers/endpoints/longcat.js +18 -0
  465. package/dist/llm/providers/endpoints/longcat.js.map +1 -0
  466. package/dist/llm/providers/endpoints/minimax.d.ts +15 -0
  467. package/dist/llm/providers/endpoints/minimax.d.ts.map +1 -0
  468. package/dist/llm/providers/endpoints/minimax.js +27 -0
  469. package/dist/llm/providers/endpoints/minimax.js.map +1 -0
  470. package/dist/llm/providers/endpoints/minimaxCodingPlan.d.ts +9 -0
  471. package/dist/llm/providers/endpoints/minimaxCodingPlan.d.ts.map +1 -0
  472. package/dist/llm/providers/endpoints/minimaxCodingPlan.js +21 -0
  473. package/dist/llm/providers/endpoints/minimaxCodingPlan.js.map +1 -0
  474. package/dist/llm/providers/endpoints/mistral.d.ts +11 -0
  475. package/dist/llm/providers/endpoints/mistral.d.ts.map +1 -0
  476. package/dist/llm/providers/endpoints/mistral.js +31 -0
  477. package/dist/llm/providers/endpoints/mistral.js.map +1 -0
  478. package/dist/llm/providers/endpoints/modelscope.d.ts +10 -0
  479. package/dist/llm/providers/endpoints/modelscope.d.ts.map +1 -0
  480. package/dist/llm/providers/endpoints/modelscope.js +22 -0
  481. package/dist/llm/providers/endpoints/modelscope.js.map +1 -0
  482. package/dist/llm/providers/endpoints/moonshot.d.ts +12 -0
  483. package/dist/llm/providers/endpoints/moonshot.d.ts.map +1 -0
  484. package/dist/llm/providers/endpoints/moonshot.js +29 -0
  485. package/dist/llm/providers/endpoints/moonshot.js.map +1 -0
  486. package/dist/llm/providers/endpoints/newapi.d.ts +14 -0
  487. package/dist/llm/providers/endpoints/newapi.d.ts.map +1 -0
  488. package/dist/llm/providers/endpoints/newapi.js +14 -0
  489. package/dist/llm/providers/endpoints/newapi.js.map +1 -0
  490. package/dist/llm/providers/endpoints/ollama.d.ts +12 -0
  491. package/dist/llm/providers/endpoints/ollama.d.ts.map +1 -0
  492. package/dist/llm/providers/endpoints/ollama.js +63 -0
  493. package/dist/llm/providers/endpoints/ollama.js.map +1 -0
  494. package/dist/llm/providers/endpoints/openai.d.ts +12 -0
  495. package/dist/llm/providers/endpoints/openai.d.ts.map +1 -0
  496. package/dist/llm/providers/endpoints/openai.js +67 -0
  497. package/dist/llm/providers/endpoints/openai.js.map +1 -0
  498. package/dist/llm/providers/endpoints/opencodeCodingPlan.d.ts +9 -0
  499. package/dist/llm/providers/endpoints/opencodeCodingPlan.d.ts.map +1 -0
  500. package/dist/llm/providers/endpoints/opencodeCodingPlan.js +23 -0
  501. package/dist/llm/providers/endpoints/opencodeCodingPlan.js.map +1 -0
  502. package/dist/llm/providers/endpoints/openrouter.d.ts +15 -0
  503. package/dist/llm/providers/endpoints/openrouter.d.ts.map +1 -0
  504. package/dist/llm/providers/endpoints/openrouter.js +75 -0
  505. package/dist/llm/providers/endpoints/openrouter.js.map +1 -0
  506. package/dist/llm/providers/endpoints/ppio.d.ts +15 -0
  507. package/dist/llm/providers/endpoints/ppio.d.ts.map +1 -0
  508. package/dist/llm/providers/endpoints/ppio.js +73 -0
  509. package/dist/llm/providers/endpoints/ppio.js.map +1 -0
  510. package/dist/llm/providers/endpoints/qiniu.d.ts +10 -0
  511. package/dist/llm/providers/endpoints/qiniu.d.ts.map +1 -0
  512. package/dist/llm/providers/endpoints/qiniu.js +24 -0
  513. package/dist/llm/providers/endpoints/qiniu.js.map +1 -0
  514. package/dist/llm/providers/endpoints/sensenova.d.ts +10 -0
  515. package/dist/llm/providers/endpoints/sensenova.d.ts.map +1 -0
  516. package/dist/llm/providers/endpoints/sensenova.js +37 -0
  517. package/dist/llm/providers/endpoints/sensenova.js.map +1 -0
  518. package/dist/llm/providers/endpoints/siliconcloud.d.ts +14 -0
  519. package/dist/llm/providers/endpoints/siliconcloud.d.ts.map +1 -0
  520. package/dist/llm/providers/endpoints/siliconcloud.js +114 -0
  521. package/dist/llm/providers/endpoints/siliconcloud.js.map +1 -0
  522. package/dist/llm/providers/endpoints/spark.d.ts +14 -0
  523. package/dist/llm/providers/endpoints/spark.d.ts.map +1 -0
  524. package/dist/llm/providers/endpoints/spark.js +21 -0
  525. package/dist/llm/providers/endpoints/spark.js.map +1 -0
  526. package/dist/llm/providers/endpoints/stepfun.d.ts +10 -0
  527. package/dist/llm/providers/endpoints/stepfun.d.ts.map +1 -0
  528. package/dist/llm/providers/endpoints/stepfun.js +27 -0
  529. package/dist/llm/providers/endpoints/stepfun.js.map +1 -0
  530. package/dist/llm/providers/endpoints/tencentcloud.d.ts +10 -0
  531. package/dist/llm/providers/endpoints/tencentcloud.d.ts.map +1 -0
  532. package/dist/llm/providers/endpoints/tencentcloud.js +17 -0
  533. package/dist/llm/providers/endpoints/tencentcloud.js.map +1 -0
  534. package/dist/llm/providers/endpoints/volcengine.d.ts +10 -0
  535. package/dist/llm/providers/endpoints/volcengine.d.ts.map +1 -0
  536. package/dist/llm/providers/endpoints/volcengine.js +44 -0
  537. package/dist/llm/providers/endpoints/volcengine.js.map +1 -0
  538. package/dist/llm/providers/endpoints/volcengineCodingPlan.d.ts +19 -0
  539. package/dist/llm/providers/endpoints/volcengineCodingPlan.d.ts.map +1 -0
  540. package/dist/llm/providers/endpoints/volcengineCodingPlan.js +25 -0
  541. package/dist/llm/providers/endpoints/volcengineCodingPlan.js.map +1 -0
  542. package/dist/llm/providers/endpoints/wenxin.d.ts +10 -0
  543. package/dist/llm/providers/endpoints/wenxin.d.ts.map +1 -0
  544. package/dist/llm/providers/endpoints/wenxin.js +98 -0
  545. package/dist/llm/providers/endpoints/wenxin.js.map +1 -0
  546. package/dist/llm/providers/endpoints/xai.d.ts +11 -0
  547. package/dist/llm/providers/endpoints/xai.d.ts.map +1 -0
  548. package/dist/llm/providers/endpoints/xai.js +25 -0
  549. package/dist/llm/providers/endpoints/xai.js.map +1 -0
  550. package/dist/llm/providers/endpoints/xiaomimimo.d.ts +12 -0
  551. package/dist/llm/providers/endpoints/xiaomimimo.d.ts.map +1 -0
  552. package/dist/llm/providers/endpoints/xiaomimimo.js +16 -0
  553. package/dist/llm/providers/endpoints/xiaomimimo.js.map +1 -0
  554. package/dist/llm/providers/endpoints/zeroone.d.ts +10 -0
  555. package/dist/llm/providers/endpoints/zeroone.d.ts.map +1 -0
  556. package/dist/llm/providers/endpoints/zeroone.js +26 -0
  557. package/dist/llm/providers/endpoints/zeroone.js.map +1 -0
  558. package/dist/llm/providers/endpoints/zhipu.d.ts +12 -0
  559. package/dist/llm/providers/endpoints/zhipu.d.ts.map +1 -0
  560. package/dist/llm/providers/endpoints/zhipu.js +51 -0
  561. package/dist/llm/providers/endpoints/zhipu.js.map +1 -0
  562. package/dist/llm/providers/index.d.ts +5 -0
  563. package/dist/llm/providers/index.d.ts.map +1 -0
  564. package/dist/llm/providers/index.js +64 -0
  565. package/dist/llm/providers/index.js.map +1 -0
  566. package/dist/llm/providers/lookup.d.ts +16 -0
  567. package/dist/llm/providers/lookup.d.ts.map +1 -0
  568. package/dist/llm/providers/lookup.js +68 -0
  569. package/dist/llm/providers/lookup.js.map +1 -0
  570. package/dist/llm/providers/probe.d.ts +11 -0
  571. package/dist/llm/providers/probe.d.ts.map +1 -0
  572. package/dist/llm/providers/probe.js +24 -0
  573. package/dist/llm/providers/probe.js.map +1 -0
  574. package/dist/llm/providers/types.d.ts +71 -0
  575. package/dist/llm/providers/types.d.ts.map +1 -0
  576. package/dist/llm/providers/types.js +9 -0
  577. package/dist/llm/providers/types.js.map +1 -0
  578. package/dist/llm/providers/verify.d.ts +27 -0
  579. package/dist/llm/providers/verify.d.ts.map +1 -0
  580. package/dist/llm/providers/verify.js +77 -0
  581. package/dist/llm/providers/verify.js.map +1 -0
  582. package/dist/llm/secrets.d.ts +9 -0
  583. package/dist/llm/secrets.d.ts.map +1 -0
  584. package/dist/llm/secrets.js +56 -0
  585. package/dist/llm/secrets.js.map +1 -0
  586. package/dist/llm/service-presets.d.ts +45 -0
  587. package/dist/llm/service-presets.d.ts.map +1 -0
  588. package/dist/llm/service-presets.js +180 -0
  589. package/dist/llm/service-presets.js.map +1 -0
  590. package/dist/llm/service-resolver.d.ts +10 -0
  591. package/dist/llm/service-resolver.d.ts.map +1 -0
  592. package/dist/llm/service-resolver.js +62 -0
  593. package/dist/llm/service-resolver.js.map +1 -0
  594. package/dist/llm/think-tag-stripper.d.ts +15 -0
  595. package/dist/llm/think-tag-stripper.d.ts.map +1 -0
  596. package/dist/llm/think-tag-stripper.js +60 -0
  597. package/dist/llm/think-tag-stripper.js.map +1 -0
  598. package/dist/materials/ingest.d.ts +31 -0
  599. package/dist/materials/ingest.d.ts.map +1 -0
  600. package/dist/materials/ingest.js +224 -0
  601. package/dist/materials/ingest.js.map +1 -0
  602. package/dist/materials/retrieve.d.ts +20 -0
  603. package/dist/materials/retrieve.d.ts.map +1 -0
  604. package/dist/materials/retrieve.js +109 -0
  605. package/dist/materials/retrieve.js.map +1 -0
  606. package/dist/models/book-rules.d.ts +142 -0
  607. package/dist/models/book-rules.d.ts.map +1 -0
  608. package/dist/models/book-rules.js +286 -0
  609. package/dist/models/book-rules.js.map +1 -0
  610. package/dist/models/book.d.ts +94 -0
  611. package/dist/models/book.d.ts.map +1 -0
  612. package/dist/models/book.js +79 -0
  613. package/dist/models/book.js.map +1 -0
  614. package/dist/models/chapter.d.ts +131 -0
  615. package/dist/models/chapter.d.ts.map +1 -0
  616. package/dist/models/chapter.js +38 -0
  617. package/dist/models/chapter.js.map +1 -0
  618. package/dist/models/context-compression.d.ts +13 -0
  619. package/dist/models/context-compression.d.ts.map +1 -0
  620. package/dist/models/context-compression.js +2 -0
  621. package/dist/models/context-compression.js.map +1 -0
  622. package/dist/models/detection.d.ts +25 -0
  623. package/dist/models/detection.d.ts.map +1 -0
  624. package/dist/models/detection.js +2 -0
  625. package/dist/models/detection.js.map +1 -0
  626. package/dist/models/genre-profile.d.ts +45 -0
  627. package/dist/models/genre-profile.d.ts.map +1 -0
  628. package/dist/models/genre-profile.js +26 -0
  629. package/dist/models/genre-profile.js.map +1 -0
  630. package/dist/models/input-governance.d.ts +437 -0
  631. package/dist/models/input-governance.d.ts.map +1 -0
  632. package/dist/models/input-governance.js +104 -0
  633. package/dist/models/input-governance.js.map +1 -0
  634. package/dist/models/length-governance.d.ts +85 -0
  635. package/dist/models/length-governance.d.ts.map +1 -0
  636. package/dist/models/length-governance.js +31 -0
  637. package/dist/models/length-governance.js.map +1 -0
  638. package/dist/models/play.d.ts +530 -0
  639. package/dist/models/play.d.ts.map +1 -0
  640. package/dist/models/play.js +318 -0
  641. package/dist/models/play.js.map +1 -0
  642. package/dist/models/project.d.ts +797 -0
  643. package/dist/models/project.d.ts.map +1 -0
  644. package/dist/models/project.js +152 -0
  645. package/dist/models/project.js.map +1 -0
  646. package/dist/models/runtime-state.d.ts +708 -0
  647. package/dist/models/runtime-state.d.ts.map +1 -0
  648. package/dist/models/runtime-state.js +105 -0
  649. package/dist/models/runtime-state.js.map +1 -0
  650. package/dist/models/state.d.ts +48 -0
  651. package/dist/models/state.d.ts.map +1 -0
  652. package/dist/models/state.js +6 -0
  653. package/dist/models/state.js.map +1 -0
  654. package/dist/models/style-profile.d.ts +16 -0
  655. package/dist/models/style-profile.d.ts.map +1 -0
  656. package/dist/models/style-profile.js +2 -0
  657. package/dist/models/style-profile.js.map +1 -0
  658. package/dist/notify/dispatcher.d.ts +10 -0
  659. package/dist/notify/dispatcher.d.ts.map +1 -0
  660. package/dist/notify/dispatcher.js +67 -0
  661. package/dist/notify/dispatcher.js.map +1 -0
  662. package/dist/notify/feishu.d.ts +6 -0
  663. package/dist/notify/feishu.d.ts.map +1 -0
  664. package/dist/notify/feishu.js +32 -0
  665. package/dist/notify/feishu.js.map +1 -0
  666. package/dist/notify/format.d.ts +12 -0
  667. package/dist/notify/format.d.ts.map +1 -0
  668. package/dist/notify/format.js +11 -0
  669. package/dist/notify/format.js.map +1 -0
  670. package/dist/notify/telegram.d.ts +7 -0
  671. package/dist/notify/telegram.d.ts.map +1 -0
  672. package/dist/notify/telegram.js +18 -0
  673. package/dist/notify/telegram.js.map +1 -0
  674. package/dist/notify/webhook.d.ts +15 -0
  675. package/dist/notify/webhook.d.ts.map +1 -0
  676. package/dist/notify/webhook.js +28 -0
  677. package/dist/notify/webhook.js.map +1 -0
  678. package/dist/notify/wechat-work.d.ts +6 -0
  679. package/dist/notify/wechat-work.d.ts.map +1 -0
  680. package/dist/notify/wechat-work.js +15 -0
  681. package/dist/notify/wechat-work.js.map +1 -0
  682. package/dist/pipeline/chapter-persistence.d.ts +33 -0
  683. package/dist/pipeline/chapter-persistence.d.ts.map +1 -0
  684. package/dist/pipeline/chapter-persistence.js +39 -0
  685. package/dist/pipeline/chapter-persistence.js.map +1 -0
  686. package/dist/pipeline/chapter-review-cycle.d.ts +81 -0
  687. package/dist/pipeline/chapter-review-cycle.d.ts.map +1 -0
  688. package/dist/pipeline/chapter-review-cycle.js +190 -0
  689. package/dist/pipeline/chapter-review-cycle.js.map +1 -0
  690. package/dist/pipeline/chapter-state-recovery.d.ts +61 -0
  691. package/dist/pipeline/chapter-state-recovery.d.ts.map +1 -0
  692. package/dist/pipeline/chapter-state-recovery.js +135 -0
  693. package/dist/pipeline/chapter-state-recovery.js.map +1 -0
  694. package/dist/pipeline/chapter-truth-validation.d.ts +42 -0
  695. package/dist/pipeline/chapter-truth-validation.d.ts.map +1 -0
  696. package/dist/pipeline/chapter-truth-validation.js +93 -0
  697. package/dist/pipeline/chapter-truth-validation.js.map +1 -0
  698. package/dist/pipeline/detection-runner.d.ts +31 -0
  699. package/dist/pipeline/detection-runner.d.ts.map +1 -0
  700. package/dist/pipeline/detection-runner.js +109 -0
  701. package/dist/pipeline/detection-runner.js.map +1 -0
  702. package/dist/pipeline/persisted-governed-plan.d.ts +5 -0
  703. package/dist/pipeline/persisted-governed-plan.d.ts.map +1 -0
  704. package/dist/pipeline/persisted-governed-plan.js +249 -0
  705. package/dist/pipeline/persisted-governed-plan.js.map +1 -0
  706. package/dist/pipeline/runner.d.ts +334 -0
  707. package/dist/pipeline/runner.d.ts.map +1 -0
  708. package/dist/pipeline/runner.js +2974 -0
  709. package/dist/pipeline/runner.js.map +1 -0
  710. package/dist/pipeline/scheduler.d.ts +58 -0
  711. package/dist/pipeline/scheduler.d.ts.map +1 -0
  712. package/dist/pipeline/scheduler.js +322 -0
  713. package/dist/pipeline/scheduler.js.map +1 -0
  714. package/dist/pipeline/script-storyboard-runner.d.ts +130 -0
  715. package/dist/pipeline/script-storyboard-runner.d.ts.map +1 -0
  716. package/dist/pipeline/script-storyboard-runner.js +532 -0
  717. package/dist/pipeline/script-storyboard-runner.js.map +1 -0
  718. package/dist/pipeline/short-fiction-runner.d.ts +110 -0
  719. package/dist/pipeline/short-fiction-runner.d.ts.map +1 -0
  720. package/dist/pipeline/short-fiction-runner.js +864 -0
  721. package/dist/pipeline/short-fiction-runner.js.map +1 -0
  722. package/dist/play/play-agents.d.ts +72 -0
  723. package/dist/play/play-agents.d.ts.map +1 -0
  724. package/dist/play/play-agents.js +580 -0
  725. package/dist/play/play-agents.js.map +1 -0
  726. package/dist/play/play-db-factory.d.ts +9 -0
  727. package/dist/play/play-db-factory.d.ts.map +1 -0
  728. package/dist/play/play-db-factory.js +18 -0
  729. package/dist/play/play-db-factory.js.map +1 -0
  730. package/dist/play/play-db.d.ts +22 -0
  731. package/dist/play/play-db.d.ts.map +1 -0
  732. package/dist/play/play-db.js +248 -0
  733. package/dist/play/play-db.js.map +1 -0
  734. package/dist/play/play-file-db.d.ts +32 -0
  735. package/dist/play/play-file-db.d.ts.map +1 -0
  736. package/dist/play/play-file-db.js +156 -0
  737. package/dist/play/play-file-db.js.map +1 -0
  738. package/dist/play/play-image.d.ts +58 -0
  739. package/dist/play/play-image.d.ts.map +1 -0
  740. package/dist/play/play-image.js +142 -0
  741. package/dist/play/play-image.js.map +1 -0
  742. package/dist/play/play-reducer.d.ts +31 -0
  743. package/dist/play/play-reducer.d.ts.map +1 -0
  744. package/dist/play/play-reducer.js +261 -0
  745. package/dist/play/play-reducer.js.map +1 -0
  746. package/dist/play/play-runner.d.ts +116 -0
  747. package/dist/play/play-runner.d.ts.map +1 -0
  748. package/dist/play/play-runner.js +582 -0
  749. package/dist/play/play-runner.js.map +1 -0
  750. package/dist/play/play-store.d.ts +113 -0
  751. package/dist/play/play-store.d.ts.map +1 -0
  752. package/dist/play/play-store.js +314 -0
  753. package/dist/play/play-store.js.map +1 -0
  754. package/dist/production/harness.d.ts +57 -0
  755. package/dist/production/harness.d.ts.map +1 -0
  756. package/dist/production/harness.js +51 -0
  757. package/dist/production/harness.js.map +1 -0
  758. package/dist/prompts/builtin-prompts.d.ts +10 -0
  759. package/dist/prompts/builtin-prompts.d.ts.map +1 -0
  760. package/dist/prompts/builtin-prompts.js +157 -0
  761. package/dist/prompts/builtin-prompts.js.map +1 -0
  762. package/dist/prompts/index.d.ts +5 -0
  763. package/dist/prompts/index.d.ts.map +1 -0
  764. package/dist/prompts/index.js +5 -0
  765. package/dist/prompts/index.js.map +1 -0
  766. package/dist/prompts/prompt-pack.d.ts +33 -0
  767. package/dist/prompts/prompt-pack.d.ts.map +1 -0
  768. package/dist/prompts/prompt-pack.js +82 -0
  769. package/dist/prompts/prompt-pack.js.map +1 -0
  770. package/dist/prompts/short-fiction.d.ts +58 -0
  771. package/dist/prompts/short-fiction.d.ts.map +1 -0
  772. package/dist/prompts/short-fiction.js +480 -0
  773. package/dist/prompts/short-fiction.js.map +1 -0
  774. package/dist/prompts/types.d.ts +22 -0
  775. package/dist/prompts/types.d.ts.map +1 -0
  776. package/dist/prompts/types.js +9 -0
  777. package/dist/prompts/types.js.map +1 -0
  778. package/dist/references/book-references.d.ts +40 -0
  779. package/dist/references/book-references.d.ts.map +1 -0
  780. package/dist/references/book-references.js +207 -0
  781. package/dist/references/book-references.js.map +1 -0
  782. package/dist/references/reference-context.d.ts +26 -0
  783. package/dist/references/reference-context.d.ts.map +1 -0
  784. package/dist/references/reference-context.js +120 -0
  785. package/dist/references/reference-context.js.map +1 -0
  786. package/dist/retrieval/local-search.d.ts +38 -0
  787. package/dist/retrieval/local-search.d.ts.map +1 -0
  788. package/dist/retrieval/local-search.js +232 -0
  789. package/dist/retrieval/local-search.js.map +1 -0
  790. package/dist/skills/builtin-loader.d.ts +9 -0
  791. package/dist/skills/builtin-loader.d.ts.map +1 -0
  792. package/dist/skills/builtin-loader.js +24 -0
  793. package/dist/skills/builtin-loader.js.map +1 -0
  794. package/dist/skills/external-loader.d.ts +26 -0
  795. package/dist/skills/external-loader.d.ts.map +1 -0
  796. package/dist/skills/external-loader.js +186 -0
  797. package/dist/skills/external-loader.js.map +1 -0
  798. package/dist/skills/index.d.ts +6 -0
  799. package/dist/skills/index.d.ts.map +1 -0
  800. package/dist/skills/index.js +6 -0
  801. package/dist/skills/index.js.map +1 -0
  802. package/dist/skills/production-bindings.d.ts +18 -0
  803. package/dist/skills/production-bindings.d.ts.map +1 -0
  804. package/dist/skills/production-bindings.js +37 -0
  805. package/dist/skills/production-bindings.js.map +1 -0
  806. package/dist/skills/registry.d.ts +6 -0
  807. package/dist/skills/registry.d.ts.map +1 -0
  808. package/dist/skills/registry.js +68 -0
  809. package/dist/skills/registry.js.map +1 -0
  810. package/dist/skills/types.d.ts +42 -0
  811. package/dist/skills/types.d.ts.map +1 -0
  812. package/dist/skills/types.js +10 -0
  813. package/dist/skills/types.js.map +1 -0
  814. package/dist/state/chapter-delete.d.ts +30 -0
  815. package/dist/state/chapter-delete.d.ts.map +1 -0
  816. package/dist/state/chapter-delete.js +78 -0
  817. package/dist/state/chapter-delete.js.map +1 -0
  818. package/dist/state/chapter-word-sync.d.ts +30 -0
  819. package/dist/state/chapter-word-sync.d.ts.map +1 -0
  820. package/dist/state/chapter-word-sync.js +62 -0
  821. package/dist/state/chapter-word-sync.js.map +1 -0
  822. package/dist/state/chapter-workspace.d.ts +15 -0
  823. package/dist/state/chapter-workspace.d.ts.map +1 -0
  824. package/dist/state/chapter-workspace.js +118 -0
  825. package/dist/state/chapter-workspace.js.map +1 -0
  826. package/dist/state/manager.d.ts +70 -0
  827. package/dist/state/manager.d.ts.map +1 -0
  828. package/dist/state/manager.js +727 -0
  829. package/dist/state/manager.js.map +1 -0
  830. package/dist/state/memory-db.d.ts +83 -0
  831. package/dist/state/memory-db.d.ts.map +1 -0
  832. package/dist/state/memory-db.js +249 -0
  833. package/dist/state/memory-db.js.map +1 -0
  834. package/dist/state/runtime-state-store.d.ts +38 -0
  835. package/dist/state/runtime-state-store.d.ts.map +1 -0
  836. package/dist/state/runtime-state-store.js +164 -0
  837. package/dist/state/runtime-state-store.js.map +1 -0
  838. package/dist/state/state-bootstrap.d.ts +21 -0
  839. package/dist/state/state-bootstrap.d.ts.map +1 -0
  840. package/dist/state/state-bootstrap.js +476 -0
  841. package/dist/state/state-bootstrap.js.map +1 -0
  842. package/dist/state/state-projections.d.ts +7 -0
  843. package/dist/state/state-projections.d.ts.map +1 -0
  844. package/dist/state/state-projections.js +209 -0
  845. package/dist/state/state-projections.js.map +1 -0
  846. package/dist/state/state-reducer.d.ts +13 -0
  847. package/dist/state/state-reducer.d.ts.map +1 -0
  848. package/dist/state/state-reducer.js +193 -0
  849. package/dist/state/state-reducer.js.map +1 -0
  850. package/dist/state/state-validator.d.ts +12 -0
  851. package/dist/state/state-validator.d.ts.map +1 -0
  852. package/dist/state/state-validator.js +67 -0
  853. package/dist/state/state-validator.js.map +1 -0
  854. package/dist/translation/epub.d.ts +10 -0
  855. package/dist/translation/epub.d.ts.map +1 -0
  856. package/dist/translation/epub.js +86 -0
  857. package/dist/translation/epub.js.map +1 -0
  858. package/dist/translation/export.d.ts +6 -0
  859. package/dist/translation/export.d.ts.map +1 -0
  860. package/dist/translation/export.js +68 -0
  861. package/dist/translation/export.js.map +1 -0
  862. package/dist/translation/index.d.ts +9 -0
  863. package/dist/translation/index.d.ts.map +1 -0
  864. package/dist/translation/index.js +9 -0
  865. package/dist/translation/index.js.map +1 -0
  866. package/dist/translation/llm-model.d.ts +11 -0
  867. package/dist/translation/llm-model.d.ts.map +1 -0
  868. package/dist/translation/llm-model.js +135 -0
  869. package/dist/translation/llm-model.js.map +1 -0
  870. package/dist/translation/project.d.ts +3 -0
  871. package/dist/translation/project.d.ts.map +1 -0
  872. package/dist/translation/project.js +76 -0
  873. package/dist/translation/project.js.map +1 -0
  874. package/dist/translation/run-store.d.ts +12 -0
  875. package/dist/translation/run-store.d.ts.map +1 -0
  876. package/dist/translation/run-store.js +69 -0
  877. package/dist/translation/run-store.js.map +1 -0
  878. package/dist/translation/runner.d.ts +6 -0
  879. package/dist/translation/runner.d.ts.map +1 -0
  880. package/dist/translation/runner.js +155 -0
  881. package/dist/translation/runner.js.map +1 -0
  882. package/dist/translation/source.d.ts +12 -0
  883. package/dist/translation/source.d.ts.map +1 -0
  884. package/dist/translation/source.js +66 -0
  885. package/dist/translation/source.js.map +1 -0
  886. package/dist/translation/text.d.ts +10 -0
  887. package/dist/translation/text.d.ts.map +1 -0
  888. package/dist/translation/text.js +110 -0
  889. package/dist/translation/text.js.map +1 -0
  890. package/dist/translation/types.d.ts +96 -0
  891. package/dist/translation/types.d.ts.map +1 -0
  892. package/dist/translation/types.js +2 -0
  893. package/dist/translation/types.js.map +1 -0
  894. package/dist/utils/analytics.d.ts +39 -0
  895. package/dist/utils/analytics.d.ts.map +1 -0
  896. package/dist/utils/analytics.js +50 -0
  897. package/dist/utils/analytics.js.map +1 -0
  898. package/dist/utils/atomic-file-set.d.ts +12 -0
  899. package/dist/utils/atomic-file-set.d.ts.map +1 -0
  900. package/dist/utils/atomic-file-set.js +93 -0
  901. package/dist/utils/atomic-file-set.js.map +1 -0
  902. package/dist/utils/book-eval.d.ts +35 -0
  903. package/dist/utils/book-eval.d.ts.map +1 -0
  904. package/dist/utils/book-eval.js +116 -0
  905. package/dist/utils/book-eval.js.map +1 -0
  906. package/dist/utils/book-id.d.ts +4 -0
  907. package/dist/utils/book-id.d.ts.map +1 -0
  908. package/dist/utils/book-id.js +27 -0
  909. package/dist/utils/book-id.js.map +1 -0
  910. package/dist/utils/cadence-policy.d.ts +36 -0
  911. package/dist/utils/cadence-policy.d.ts.map +1 -0
  912. package/dist/utils/cadence-policy.js +38 -0
  913. package/dist/utils/cadence-policy.js.map +1 -0
  914. package/dist/utils/chapter-cadence.d.ts +34 -0
  915. package/dist/utils/chapter-cadence.d.ts.map +1 -0
  916. package/dist/utils/chapter-cadence.js +143 -0
  917. package/dist/utils/chapter-cadence.js.map +1 -0
  918. package/dist/utils/chapter-memo-parser.d.ts +22 -0
  919. package/dist/utils/chapter-memo-parser.d.ts.map +1 -0
  920. package/dist/utils/chapter-memo-parser.js +158 -0
  921. package/dist/utils/chapter-memo-parser.js.map +1 -0
  922. package/dist/utils/chapter-splitter.d.ts +18 -0
  923. package/dist/utils/chapter-splitter.d.ts.map +1 -0
  924. package/dist/utils/chapter-splitter.js +60 -0
  925. package/dist/utils/chapter-splitter.js.map +1 -0
  926. package/dist/utils/config-loader.d.ts +11 -0
  927. package/dist/utils/config-loader.d.ts.map +1 -0
  928. package/dist/utils/config-loader.js +16 -0
  929. package/dist/utils/config-loader.js.map +1 -0
  930. package/dist/utils/context-assembly.d.ts +29 -0
  931. package/dist/utils/context-assembly.d.ts.map +1 -0
  932. package/dist/utils/context-assembly.js +117 -0
  933. package/dist/utils/context-assembly.js.map +1 -0
  934. package/dist/utils/context-filter.d.ts +31 -0
  935. package/dist/utils/context-filter.d.ts.map +1 -0
  936. package/dist/utils/context-filter.js +163 -0
  937. package/dist/utils/context-filter.js.map +1 -0
  938. package/dist/utils/effective-llm-config.d.ts +34 -0
  939. package/dist/utils/effective-llm-config.d.ts.map +1 -0
  940. package/dist/utils/effective-llm-config.js +463 -0
  941. package/dist/utils/effective-llm-config.js.map +1 -0
  942. package/dist/utils/governed-context.d.ts +11 -0
  943. package/dist/utils/governed-context.d.ts.map +1 -0
  944. package/dist/utils/governed-context.js +42 -0
  945. package/dist/utils/governed-context.js.map +1 -0
  946. package/dist/utils/governed-working-set.d.ts +18 -0
  947. package/dist/utils/governed-working-set.d.ts.map +1 -0
  948. package/dist/utils/governed-working-set.js +296 -0
  949. package/dist/utils/governed-working-set.js.map +1 -0
  950. package/dist/utils/hook-arbiter.d.ts +16 -0
  951. package/dist/utils/hook-arbiter.d.ts.map +1 -0
  952. package/dist/utils/hook-arbiter.js +161 -0
  953. package/dist/utils/hook-arbiter.js.map +1 -0
  954. package/dist/utils/hook-governance.d.ts +26 -0
  955. package/dist/utils/hook-governance.d.ts.map +1 -0
  956. package/dist/utils/hook-governance.js +65 -0
  957. package/dist/utils/hook-governance.js.map +1 -0
  958. package/dist/utils/hook-health.d.ts +15 -0
  959. package/dist/utils/hook-health.d.ts.map +1 -0
  960. package/dist/utils/hook-health.js +131 -0
  961. package/dist/utils/hook-health.js.map +1 -0
  962. package/dist/utils/hook-ledger-validator.d.ts +82 -0
  963. package/dist/utils/hook-ledger-validator.d.ts.map +1 -0
  964. package/dist/utils/hook-ledger-validator.js +225 -0
  965. package/dist/utils/hook-ledger-validator.js.map +1 -0
  966. package/dist/utils/hook-lifecycle.d.ts +41 -0
  967. package/dist/utils/hook-lifecycle.d.ts.map +1 -0
  968. package/dist/utils/hook-lifecycle.js +183 -0
  969. package/dist/utils/hook-lifecycle.js.map +1 -0
  970. package/dist/utils/hook-policy.d.ts +57 -0
  971. package/dist/utils/hook-policy.d.ts.map +1 -0
  972. package/dist/utils/hook-policy.js +96 -0
  973. package/dist/utils/hook-policy.js.map +1 -0
  974. package/dist/utils/hook-promotion.d.ts +83 -0
  975. package/dist/utils/hook-promotion.d.ts.map +1 -0
  976. package/dist/utils/hook-promotion.js +241 -0
  977. package/dist/utils/hook-promotion.js.map +1 -0
  978. package/dist/utils/hook-stale-detection.d.ts +51 -0
  979. package/dist/utils/hook-stale-detection.d.ts.map +1 -0
  980. package/dist/utils/hook-stale-detection.js +125 -0
  981. package/dist/utils/hook-stale-detection.js.map +1 -0
  982. package/dist/utils/language.d.ts +19 -0
  983. package/dist/utils/language.d.ts.map +1 -0
  984. package/dist/utils/language.js +29 -0
  985. package/dist/utils/language.js.map +1 -0
  986. package/dist/utils/length-metrics.d.ts +12 -0
  987. package/dist/utils/length-metrics.d.ts.map +1 -0
  988. package/dist/utils/length-metrics.js +85 -0
  989. package/dist/utils/length-metrics.js.map +1 -0
  990. package/dist/utils/llm-endpoint-auth.d.ts +5 -0
  991. package/dist/utils/llm-endpoint-auth.d.ts.map +1 -0
  992. package/dist/utils/llm-endpoint-auth.js +36 -0
  993. package/dist/utils/llm-endpoint-auth.js.map +1 -0
  994. package/dist/utils/llm-env.d.ts +14 -0
  995. package/dist/utils/llm-env.d.ts.map +1 -0
  996. package/dist/utils/llm-env.js +53 -0
  997. package/dist/utils/llm-env.js.map +1 -0
  998. package/dist/utils/logger.d.ts +31 -0
  999. package/dist/utils/logger.d.ts.map +1 -0
  1000. package/dist/utils/logger.js +79 -0
  1001. package/dist/utils/logger.js.map +1 -0
  1002. package/dist/utils/long-span-fatigue.d.ts +28 -0
  1003. package/dist/utils/long-span-fatigue.d.ts.map +1 -0
  1004. package/dist/utils/long-span-fatigue.js +406 -0
  1005. package/dist/utils/long-span-fatigue.js.map +1 -0
  1006. package/dist/utils/memory-retrieval.d.ts +71 -0
  1007. package/dist/utils/memory-retrieval.d.ts.map +1 -0
  1008. package/dist/utils/memory-retrieval.js +360 -0
  1009. package/dist/utils/memory-retrieval.js.map +1 -0
  1010. package/dist/utils/narrative-control.d.ts +16 -0
  1011. package/dist/utils/narrative-control.d.ts.map +1 -0
  1012. package/dist/utils/narrative-control.js +131 -0
  1013. package/dist/utils/narrative-control.js.map +1 -0
  1014. package/dist/utils/outline-paths.d.ts +63 -0
  1015. package/dist/utils/outline-paths.d.ts.map +1 -0
  1016. package/dist/utils/outline-paths.js +311 -0
  1017. package/dist/utils/outline-paths.js.map +1 -0
  1018. package/dist/utils/path-safety.d.ts +2 -0
  1019. package/dist/utils/path-safety.d.ts.map +1 -0
  1020. package/dist/utils/path-safety.js +11 -0
  1021. package/dist/utils/path-safety.js.map +1 -0
  1022. package/dist/utils/planning-materials.d.ts +35 -0
  1023. package/dist/utils/planning-materials.d.ts.map +1 -0
  1024. package/dist/utils/planning-materials.js +123 -0
  1025. package/dist/utils/planning-materials.js.map +1 -0
  1026. package/dist/utils/posix-path.d.ts +2 -0
  1027. package/dist/utils/posix-path.d.ts.map +1 -0
  1028. package/dist/utils/posix-path.js +7 -0
  1029. package/dist/utils/posix-path.js.map +1 -0
  1030. package/dist/utils/pov-filter.d.ts +30 -0
  1031. package/dist/utils/pov-filter.d.ts.map +1 -0
  1032. package/dist/utils/pov-filter.js +129 -0
  1033. package/dist/utils/pov-filter.js.map +1 -0
  1034. package/dist/utils/proxy-fetch.d.ts +9 -0
  1035. package/dist/utils/proxy-fetch.d.ts.map +1 -0
  1036. package/dist/utils/proxy-fetch.js +31 -0
  1037. package/dist/utils/proxy-fetch.js.map +1 -0
  1038. package/dist/utils/runtime-writer.d.ts +14 -0
  1039. package/dist/utils/runtime-writer.d.ts.map +1 -0
  1040. package/dist/utils/runtime-writer.js +21 -0
  1041. package/dist/utils/runtime-writer.js.map +1 -0
  1042. package/dist/utils/spot-fix-patches.d.ts +21 -0
  1043. package/dist/utils/spot-fix-patches.d.ts.map +1 -0
  1044. package/dist/utils/spot-fix-patches.js +148 -0
  1045. package/dist/utils/spot-fix-patches.js.map +1 -0
  1046. package/dist/utils/story-markdown.d.ts +13 -0
  1047. package/dist/utils/story-markdown.d.ts.map +1 -0
  1048. package/dist/utils/story-markdown.js +320 -0
  1049. package/dist/utils/story-markdown.js.map +1 -0
  1050. package/dist/utils/web-search.d.ts +28 -0
  1051. package/dist/utils/web-search.d.ts.map +1 -0
  1052. package/dist/utils/web-search.js +72 -0
  1053. package/dist/utils/web-search.js.map +1 -0
  1054. package/dist/utils/writing-methodology.d.ts +10 -0
  1055. package/dist/utils/writing-methodology.d.ts.map +1 -0
  1056. package/dist/utils/writing-methodology.js +163 -0
  1057. package/dist/utils/writing-methodology.js.map +1 -0
  1058. package/genres/cozy.md +43 -0
  1059. package/genres/cultivation.md +42 -0
  1060. package/genres/dungeon-core.md +40 -0
  1061. package/genres/horror.md +51 -0
  1062. package/genres/isekai.md +43 -0
  1063. package/genres/litrpg.md +43 -0
  1064. package/genres/other.md +24 -0
  1065. package/genres/progression.md +41 -0
  1066. package/genres/romantasy.md +45 -0
  1067. package/genres/sci-fi.md +42 -0
  1068. package/genres/system-apocalypse.md +40 -0
  1069. package/genres/tower-climber.md +41 -0
  1070. package/genres/urban.md +53 -0
  1071. package/genres/xianxia.md +46 -0
  1072. package/genres/xuanhuan.md +64 -0
  1073. package/package.json +76 -0
  1074. package/skills/inkos-interactive-film/SKILL.md +16 -0
  1075. package/skills/inkos-interactive-film/references/branch-state-craft.md +13 -0
  1076. package/skills/inkos-long-market-research/SKILL.md +16 -0
  1077. package/skills/inkos-long-market-research/references/research-rubric.md +19 -0
  1078. package/skills/inkos-long-story-analysis/SKILL.md +17 -0
  1079. package/skills/inkos-long-story-analysis/references/analysis-lens.md +16 -0
  1080. package/skills/inkos-long-writing/SKILL.md +17 -0
  1081. package/skills/inkos-long-writing/references/reader-contract-and-progression.md +13 -0
  1082. package/skills/inkos-long-writing/references/scene-dialogue-and-length-budget.md +13 -0
  1083. package/skills/inkos-play-world/SKILL.md +17 -0
  1084. package/skills/inkos-play-world/references/world-turn-continuity.md +13 -0
  1085. package/skills/inkos-script-writing/SKILL.md +15 -0
  1086. package/skills/inkos-script-writing/references/episode-scene-craft.md +13 -0
  1087. package/skills/inkos-short-market-research/SKILL.md +17 -0
  1088. package/skills/inkos-short-market-research/references/short-market-rubric.md +16 -0
  1089. package/skills/inkos-short-story-analysis/SKILL.md +16 -0
  1090. package/skills/inkos-short-story-analysis/references/deconstruction-template.md +14 -0
  1091. package/skills/inkos-short-writing/SKILL.md +18 -0
  1092. package/skills/inkos-short-writing/references/production-checklist.md +19 -0
  1093. package/skills/inkos-story-cover/SKILL.md +17 -0
  1094. package/skills/inkos-story-cover/references/cover-brief.md +16 -0
  1095. package/skills/inkos-story-deslop/SKILL.md +16 -0
  1096. package/skills/inkos-story-deslop/references/semantic-cleanup.md +13 -0
  1097. package/skills/inkos-story-import/SKILL.md +19 -0
  1098. package/skills/inkos-story-import/references/reconstruction-rubric.md +13 -0
  1099. package/skills/inkos-story-review/SKILL.md +16 -0
  1100. package/skills/inkos-story-review/references/review-matrix.md +21 -0
  1101. package/skills/inkos-storyboard/SKILL.md +15 -0
  1102. package/skills/inkos-storyboard/references/shot-continuity.md +13 -0
  1103. package/skills/inkos-translation/SKILL.md +14 -0
  1104. package/skills/inkos-translation/references/long-form-consistency.md +13 -0
@@ -0,0 +1,936 @@
1
+ import { readFile, readdir, mkdir } from "node:fs/promises";
2
+ import { dirname, join } from "node:path";
3
+ import { BaseAgent } from "./base.js";
4
+ import { ContextPackageSchema, } from "../models/input-governance.js";
5
+ import { parseChapterSummariesMarkdown, retrieveMemorySelection, } from "../utils/memory-retrieval.js";
6
+ import { buildGovernedRuleStack, buildGovernedTrace, isProtectedContextSource, } from "../utils/context-assembly.js";
7
+ import { writeGovernedRuntimeArtifacts } from "../utils/runtime-writer.js";
8
+ import { estimateTextTokens } from "../llm/provider.js";
9
+ export async function composeGovernedChapter(input) {
10
+ const storyDir = join(input.bookDir, "story");
11
+ const runtimeDir = join(storyDir, "runtime");
12
+ await mkdir(runtimeDir, { recursive: true });
13
+ const baseContext = await collectSelectedContext(storyDir, input.plan, input.book.language ?? "zh", input.outlineSectionSelector, input.memorySemanticSelector);
14
+ const referenceContext = await loadReferenceContext(input);
15
+ const selectedContext = [...baseContext.entries, ...referenceContext.entries];
16
+ const initialContextPackage = ContextPackageSchema.parse({
17
+ chapter: input.chapterNumber,
18
+ selectedContext,
19
+ });
20
+ const budgeted = await applyContextBudgetIfNeeded({
21
+ contextPackage: initialContextPackage,
22
+ chapterNumber: input.chapterNumber,
23
+ goal: input.plan.intent.goal,
24
+ language: input.book.language ?? "zh",
25
+ contextBudget: input.contextBudget,
26
+ compiler: input.compressibleContextCompiler,
27
+ onContextCompression: input.onContextCompression,
28
+ });
29
+ const contextPackage = budgeted.contextPackage;
30
+ const ruleStack = buildGovernedRuleStack(input.plan, input.chapterNumber);
31
+ const trace = buildGovernedTrace({
32
+ chapterNumber: input.chapterNumber,
33
+ plan: input.plan,
34
+ contextPackage,
35
+ composerInputs: [input.plan.runtimePath],
36
+ notes: [...referenceContext.notes, ...budgeted.notes],
37
+ compression: budgeted.compression,
38
+ retrieval: {
39
+ engine: baseContext.retrievalTrace.engine,
40
+ query: baseContext.retrievalTrace.query,
41
+ candidates: baseContext.retrievalTrace.candidates.map((candidate) => ({ ...candidate })),
42
+ ...(baseContext.retrievalTrace.semanticSelectedIds
43
+ ? { semanticSelectedIds: [...baseContext.retrievalTrace.semanticSelectedIds] }
44
+ : {}),
45
+ },
46
+ });
47
+ const { contextPath, ruleStackPath, tracePath, } = await writeGovernedRuntimeArtifacts({
48
+ runtimeDir,
49
+ chapterNumber: input.chapterNumber,
50
+ contextPackage,
51
+ ruleStack,
52
+ trace,
53
+ });
54
+ return {
55
+ contextPackage,
56
+ ruleStack,
57
+ trace,
58
+ contextPath,
59
+ ruleStackPath,
60
+ tracePath,
61
+ };
62
+ }
63
+ async function applyContextBudgetIfNeeded(params) {
64
+ const budget = params.contextBudget;
65
+ if (!budget || budget.contextWindowTokens <= 0) {
66
+ return { contextPackage: params.contextPackage, notes: [] };
67
+ }
68
+ const availableInputTokens = budget.contextWindowTokens - Math.max(0, budget.reservedOutputTokens);
69
+ const selectedContext = params.contextPackage.selectedContext;
70
+ const totalTokens = estimateSelectedContextTokens(selectedContext);
71
+ if (totalTokens <= availableInputTokens) {
72
+ return { contextPackage: params.contextPackage, notes: [] };
73
+ }
74
+ const protectedEntries = selectedContext.filter((entry) => isProtectedContextSource(entry.source));
75
+ const compressibleEntries = selectedContext.filter((entry) => !isProtectedContextSource(entry.source));
76
+ const protectedTokens = estimateSelectedContextTokens(protectedEntries);
77
+ if (protectedTokens > availableInputTokens) {
78
+ params.onContextCompression?.({
79
+ category: "story_context",
80
+ phase: "error",
81
+ message: "Protected context exceeds available input budget.",
82
+ protectedTokens,
83
+ compressibleTokens: totalTokens - protectedTokens,
84
+ budgetTokens: availableInputTokens,
85
+ sources: protectedEntries.map((entry) => entry.source),
86
+ });
87
+ throw new Error(`Protected context exceeds available input budget (${protectedTokens}/${availableInputTokens} tokens). ` +
88
+ "InkOS will not compress protected author intent, current focus, hard state, or active hook evidence.");
89
+ }
90
+ if (compressibleEntries.length === 0) {
91
+ return { contextPackage: params.contextPackage, notes: ["context-over-budget-no-compressible-entries"] };
92
+ }
93
+ if (!params.compiler) {
94
+ params.onContextCompression?.({
95
+ category: "story_context",
96
+ phase: "error",
97
+ message: "Context exceeds available input budget but no compiler was provided.",
98
+ protectedTokens,
99
+ compressibleTokens: estimateSelectedContextTokens(compressibleEntries),
100
+ budgetTokens: availableInputTokens,
101
+ sources: compressibleEntries.map((entry) => entry.source),
102
+ });
103
+ throw new Error(`Context exceeds available input budget (${totalTokens}/${availableInputTokens} tokens), ` +
104
+ "but no compressible context compiler was provided.");
105
+ }
106
+ const compileBudget = Math.max(1, availableInputTokens - protectedTokens);
107
+ const compressibleTokens = estimateSelectedContextTokens(compressibleEntries);
108
+ params.onContextCompression?.({
109
+ category: "story_context",
110
+ phase: "start",
111
+ protectedTokens,
112
+ compressibleTokens,
113
+ budgetTokens: compileBudget,
114
+ sources: compressibleEntries.map((entry) => entry.source),
115
+ });
116
+ let compiled;
117
+ try {
118
+ compiled = (await params.compiler({
119
+ chapterNumber: params.chapterNumber,
120
+ goal: params.goal,
121
+ language: params.language,
122
+ maxInputTokens: compileBudget,
123
+ protectedEntries,
124
+ compressibleEntries,
125
+ })).trim();
126
+ }
127
+ catch (error) {
128
+ params.onContextCompression?.({
129
+ category: "story_context",
130
+ phase: "error",
131
+ message: error instanceof Error ? error.message : String(error),
132
+ protectedTokens,
133
+ compressibleTokens,
134
+ budgetTokens: compileBudget,
135
+ sources: compressibleEntries.map((entry) => entry.source),
136
+ });
137
+ throw error;
138
+ }
139
+ if (!compiled) {
140
+ params.onContextCompression?.({
141
+ category: "story_context",
142
+ phase: "error",
143
+ message: "Compressible context compiler returned empty output.",
144
+ protectedTokens,
145
+ compressibleTokens,
146
+ budgetTokens: compileBudget,
147
+ sources: compressibleEntries.map((entry) => entry.source),
148
+ });
149
+ throw new Error("Compressible context compiler returned empty output.");
150
+ }
151
+ params.onContextCompression?.({
152
+ category: "story_context",
153
+ phase: "end",
154
+ protectedTokens,
155
+ compressibleTokens,
156
+ budgetTokens: compileBudget,
157
+ sources: compressibleEntries.map((entry) => entry.source),
158
+ });
159
+ return {
160
+ contextPackage: ContextPackageSchema.parse({
161
+ chapter: params.contextPackage.chapter,
162
+ selectedContext: [
163
+ ...protectedEntries,
164
+ {
165
+ source: "runtime/compiled-compressible-context",
166
+ reason: "Semantic compilation of lower-priority context after protected context exceeded the input budget.",
167
+ excerpt: compiled,
168
+ },
169
+ ],
170
+ }),
171
+ notes: ["compiled-compressible-context"],
172
+ compression: {
173
+ compiledSource: "runtime/compiled-compressible-context",
174
+ protectedSources: protectedEntries.map((entry) => entry.source),
175
+ compressedSources: compressibleEntries.map((entry) => entry.source),
176
+ protectedTokens,
177
+ compressibleTokens,
178
+ budgetTokens: compileBudget,
179
+ },
180
+ };
181
+ }
182
+ function estimateSelectedContextTokens(entries) {
183
+ return entries.reduce((total, entry) => (total + estimateTextTokens([entry.source, entry.reason, entry.excerpt].filter(Boolean).join("\n"))), 0);
184
+ }
185
+ function renderContextEntries(entries) {
186
+ return entries.map((entry) => [
187
+ `### ${entry.source}`,
188
+ `Reason: ${entry.reason}`,
189
+ entry.excerpt ? entry.excerpt : "(no excerpt)",
190
+ ].join("\n")).join("\n\n");
191
+ }
192
+ function parseSelectedSources(raw) {
193
+ const trimmed = raw.trim()
194
+ .replace(/^```(?:json)?\s*/i, "")
195
+ .replace(/```\s*$/i, "")
196
+ .trim();
197
+ const parse = (value) => JSON.parse(value);
198
+ let parsed;
199
+ try {
200
+ parsed = parse(trimmed);
201
+ }
202
+ catch {
203
+ const start = trimmed.indexOf("{");
204
+ const end = trimmed.lastIndexOf("}");
205
+ if (start < 0 || end <= start)
206
+ return [];
207
+ try {
208
+ parsed = parse(trimmed.slice(start, end + 1));
209
+ }
210
+ catch {
211
+ return [];
212
+ }
213
+ }
214
+ if (!parsed || typeof parsed !== "object")
215
+ return [];
216
+ const values = parsed.selectedSources;
217
+ if (!Array.isArray(values))
218
+ return [];
219
+ return values.filter((value) => typeof value === "string" && value.trim().length > 0);
220
+ }
221
+ export class ComposerAgent extends BaseAgent {
222
+ get name() {
223
+ return "composer";
224
+ }
225
+ async composeChapter(input) {
226
+ const contextBudget = input.contextBudget ?? contextBudgetFromClient(this.ctx.client);
227
+ return composeGovernedChapter({
228
+ ...input,
229
+ contextBudget,
230
+ compressibleContextCompiler: input.compressibleContextCompiler
231
+ ?? (contextBudget ? (request) => this.compileCompressibleContext(request) : undefined),
232
+ outlineSectionSelector: input.outlineSectionSelector ?? ((request) => this.selectOutlineSections(request)),
233
+ memorySemanticSelector: input.memorySemanticSelector ?? ((request) => this.selectMemoryCandidates(request)),
234
+ });
235
+ }
236
+ async selectMemoryCandidates(request) {
237
+ const candidates = request.candidates.map((candidate, index) => [
238
+ `#${index + 1} ${candidate.id}`,
239
+ `kind: ${candidate.kind}`,
240
+ `source: ${candidate.source}`,
241
+ `title: ${candidate.title}`,
242
+ candidate.excerpt,
243
+ ].join("\n")).join("\n\n");
244
+ const response = await this.chat([
245
+ {
246
+ role: "system",
247
+ content: [
248
+ "You are InkOS's semantic story-memory selector.",
249
+ "Select only candidate memories that materially help the current chapter task. Understand negation, corrections, causal relationships, aliases, and paraphrases; do not rank by keyword overlap.",
250
+ "Established current-state facts and active hook lifecycle are protected separately by the host, so do not invent ids or retain unrelated candidates just to be safe.",
251
+ "Return strict JSON only: {\"selectedSources\":[\"candidate-id\"]}.",
252
+ ].join("\n"),
253
+ },
254
+ {
255
+ role: "user",
256
+ content: [
257
+ `Chapter: ${request.chapterNumber}`,
258
+ "Current task:",
259
+ request.query,
260
+ "",
261
+ "BM25 candidates:",
262
+ candidates,
263
+ ].join("\n"),
264
+ },
265
+ ], {
266
+ temperature: 0.1,
267
+ maxTokens: 2048,
268
+ });
269
+ const allowed = new Set(request.candidates.map((candidate) => candidate.id));
270
+ return parseSelectedSources(response.content).filter((id) => allowed.has(id));
271
+ }
272
+ async selectOutlineSections(request) {
273
+ if (request.candidates.length <= 1) {
274
+ return request.candidates.map((candidate) => candidate.source);
275
+ }
276
+ const isEn = request.language === "en";
277
+ const candidates = request.candidates.map((candidate, index) => [
278
+ `#${index + 1} ${candidate.source}`,
279
+ `heading: ${candidate.heading}`,
280
+ candidate.excerpt,
281
+ ].join("\n")).join("\n\n");
282
+ const system = isEn
283
+ ? [
284
+ "You are InkOS's semantic outline-section selector.",
285
+ "Select only the outline sections needed for the current chapter. Prefer semantic relevance over keyword overlap.",
286
+ "Return strict JSON only: {\"selectedSources\":[\"...\"]}. Use exact source ids from the candidates. If uncertain, include the safest relevant anchors rather than inventing ids.",
287
+ ].join("\n")
288
+ : [
289
+ "你是 InkOS 的语义大纲选段器。",
290
+ "只选择当前章节真正需要的大纲段落。按语义相关性判断,不要按关键词重合机械选择。",
291
+ "只返回严格 JSON:{\"selectedSources\":[\"...\"]}。必须使用候选里的精确 source id;不确定时选最安全的相关锚点,不要编造 id。",
292
+ ].join("\n");
293
+ const user = isEn
294
+ ? [
295
+ `File: ${request.fileName}`,
296
+ `Chapter: ${request.chapterNumber}`,
297
+ `Goal: ${request.goal}`,
298
+ `Outline node: ${request.outlineNode}`,
299
+ "",
300
+ "Candidates:",
301
+ candidates,
302
+ ].join("\n")
303
+ : [
304
+ `文件:${request.fileName}`,
305
+ `章节:第${request.chapterNumber}章`,
306
+ `目标:${request.goal}`,
307
+ `大纲节点:${request.outlineNode}`,
308
+ "",
309
+ "候选段落:",
310
+ candidates,
311
+ ].join("\n");
312
+ const response = await this.chat([
313
+ { role: "system", content: system },
314
+ { role: "user", content: user },
315
+ ], {
316
+ temperature: 0.1,
317
+ maxTokens: 1024,
318
+ });
319
+ const allowed = new Set(request.candidates.map((candidate) => candidate.source));
320
+ return parseSelectedSources(response.content).filter((source) => allowed.has(source));
321
+ }
322
+ async selectReferenceSections(request) {
323
+ const isEn = request.language === "en";
324
+ const candidates = request.candidates.map((candidate, index) => [
325
+ `#${index + 1} ${candidate.source}`,
326
+ `title: ${candidate.title}`,
327
+ `heading: ${candidate.heading}`,
328
+ `user-defined uses: ${candidate.uses.join("; ")}`,
329
+ candidate.note ? `user note: ${candidate.note}` : undefined,
330
+ ].filter(Boolean).join("\n")).join("\n\n");
331
+ const system = isEn
332
+ ? [
333
+ "You are InkOS's semantic reference-section selector.",
334
+ "The user explicitly bound these reference assets to this book and described how each may be used.",
335
+ "Select only sections useful for the current chapter task. References are creative guidance, never canon and never stronger than author intent or established facts.",
336
+ "Return strict JSON only: {\"selectedSources\":[\"...\"]}. Use exact candidate source ids. An empty list is valid when no section is relevant.",
337
+ ].join("\n")
338
+ : [
339
+ "你是 InkOS 的参考资产语义选段器。",
340
+ "用户已把这些参考资产绑定到本书,并明确说明每份资料可以借鉴什么。",
341
+ "只选择当前章节任务真正需要的段落。参考资料只是创作借鉴,不能成为正典,也不能压过作者意图和既成事实。",
342
+ "只返回严格 JSON:{\"selectedSources\":[\"...\"]}。必须使用候选中的精确 source id;没有相关段落时可以返回空数组。",
343
+ ].join("\n");
344
+ const user = isEn
345
+ ? [
346
+ `Chapter: ${request.chapterNumber}`,
347
+ `Goal: ${request.goal}`,
348
+ `Outline node: ${request.outlineNode}`,
349
+ `Must keep: ${request.mustKeep.join("; ") || "(none)"}`,
350
+ "",
351
+ "Candidates (headings only; selected sections will be loaded verbatim by the host):",
352
+ candidates,
353
+ ].join("\n")
354
+ : [
355
+ `章节:第${request.chapterNumber}章`,
356
+ `目标:${request.goal}`,
357
+ `大纲节点:${request.outlineNode}`,
358
+ `必须保留:${request.mustKeep.join(";") || "(无)"}`,
359
+ "",
360
+ "候选段落(这里只给标题;宿主会把选中的段落原文完整载入):",
361
+ candidates,
362
+ ].join("\n");
363
+ const response = await this.chat([
364
+ { role: "system", content: system },
365
+ { role: "user", content: user },
366
+ ], {
367
+ temperature: 0.1,
368
+ maxTokens: 2048,
369
+ });
370
+ const allowed = new Set(request.candidates.map((candidate) => candidate.source));
371
+ return parseSelectedSources(response.content).filter((source) => allowed.has(source));
372
+ }
373
+ async compileCompressibleContext(request) {
374
+ const isEn = request.language === "en";
375
+ const protectedBlock = renderContextEntries(request.protectedEntries);
376
+ const compressibleBlock = renderContextEntries(request.compressibleEntries);
377
+ const system = isEn
378
+ ? [
379
+ "You are InkOS's semantic context compiler.",
380
+ "Only compile the COMPRESSIBLE CONTEXT. The PROTECTED CONTEXT is binding reference material and must not be rewritten, summarized as a substitute, or weakened.",
381
+ "Output concise Markdown with source pointers. Preserve names, unresolved promises, evidence, timing, and constraints that may affect the next chapter. Drop low-relevance noise.",
382
+ ].join("\n")
383
+ : [
384
+ "你是 InkOS 的语义上下文编译器。",
385
+ "只能编译【可压缩上下文】。【受保护上下文】是绑定参照,不得改写、不得替代总结、不得削弱。",
386
+ "输出简洁 Markdown,保留来源指针。保留会影响下一章的人名、未兑现承诺、证据、时间点和约束,丢弃低相关噪声。",
387
+ ].join("\n");
388
+ const user = isEn
389
+ ? [
390
+ `Chapter: ${request.chapterNumber}`,
391
+ `Goal: ${request.goal}`,
392
+ `Target budget for compiled context: <= ${request.maxInputTokens} estimated input tokens`,
393
+ "",
394
+ "## Protected Context (reference only, do not compile)",
395
+ protectedBlock || "(none)",
396
+ "",
397
+ "## Compressible Context (compile this)",
398
+ compressibleBlock || "(none)",
399
+ ].join("\n")
400
+ : [
401
+ `章节:第${request.chapterNumber}章`,
402
+ `目标:${request.goal}`,
403
+ `压缩后目标预算:不超过 ${request.maxInputTokens} 估算输入 tokens`,
404
+ "",
405
+ "## 受保护上下文(只作为参照,不要编译它)",
406
+ protectedBlock || "(无)",
407
+ "",
408
+ "## 可压缩上下文(只编译这一部分)",
409
+ compressibleBlock || "(无)",
410
+ ].join("\n");
411
+ const response = await this.chat([
412
+ { role: "system", content: system },
413
+ { role: "user", content: user },
414
+ ], {
415
+ temperature: 0.2,
416
+ maxTokens: Math.min(8192, Math.max(512, request.maxInputTokens)),
417
+ });
418
+ return response.content.trim();
419
+ }
420
+ }
421
+ async function loadReferenceContext(input) {
422
+ if (!input.referenceContextProvider)
423
+ return { entries: [], notes: [] };
424
+ try {
425
+ return await input.referenceContextProvider({
426
+ chapterNumber: input.chapterNumber,
427
+ goal: input.plan.intent.goal,
428
+ outlineNode: input.plan.intent.outlineNode ?? "",
429
+ mustKeep: input.plan.intent.mustKeep,
430
+ language: input.book.language ?? "zh",
431
+ });
432
+ }
433
+ catch {
434
+ return { entries: [], notes: ["book-reference-context-unavailable"] };
435
+ }
436
+ }
437
+ export function contextBudgetFromClient(client) {
438
+ const contextWindowTokens = client._piModel?.contextWindow;
439
+ if (!Number.isFinite(contextWindowTokens) || !contextWindowTokens || contextWindowTokens <= 0) {
440
+ return undefined;
441
+ }
442
+ return {
443
+ contextWindowTokens,
444
+ reservedOutputTokens: Math.max(0, client.defaults.maxTokens),
445
+ };
446
+ }
447
+ async function collectSelectedContext(storyDir, plan, language, outlineSectionSelector, memorySemanticSelector) {
448
+ const retrievalHints = deriveRetrievalHints(plan);
449
+ const memoBodyExcerpt = plan.memo.body.trim();
450
+ const chapterMemoEntry = memoBodyExcerpt.length > 0
451
+ ? [{
452
+ source: "runtime/chapter_memo",
453
+ reason: "Carry the planner's chapter memo into governed writing.",
454
+ excerpt: [
455
+ `goal=${plan.memo.goal}`,
456
+ plan.memo.isGoldenOpening ? "golden-opening=true" : undefined,
457
+ memoBodyExcerpt,
458
+ ].filter(Boolean).join(" | "),
459
+ }]
460
+ : [{
461
+ source: "runtime/chapter_memo",
462
+ reason: "Carry the planner's chapter memo into governed writing.",
463
+ excerpt: `goal=${plan.memo.goal}`,
464
+ }];
465
+ const entries = await Promise.all([
466
+ maybeContextSource(storyDir, "current_focus.md", "Current task focus for this chapter."),
467
+ maybeContextSource(storyDir, "author_intent.md", "User's long-term authorial intent and direction — binding, overrides model defaults."),
468
+ maybeContextSource(storyDir, "audit_drift.md", "Carry forward audit drift guidance from the previous chapter without polluting hard state facts."),
469
+ maybeContextSource(storyDir, "current_state.md", "Preserve hard state facts referenced by the active chapter brief or hard constraints."),
470
+ ]);
471
+ const outlineEntries = [
472
+ ...await maybeOutlineSectionSources(storyDir, "outline/story_frame.md", "Preserve canon constraints referenced by the active chapter brief or hard constraints.", plan, "story-frame", language, outlineSectionSelector),
473
+ ...await maybeOutlineSectionSources(storyDir, "outline/volume_map.md", "Anchor the default planning node for this chapter.", plan, "volume-map", language, outlineSectionSelector),
474
+ ];
475
+ const canonEntries = await Promise.all([
476
+ maybeContextSource(storyDir, "parent_canon.md", "Preserve parent canon constraints for governed continuation or fanfic writing."),
477
+ maybeContextSource(storyDir, "fanfic_canon.md", "Preserve extracted fanfic canon constraints for governed writing."),
478
+ ]);
479
+ const trailEntries = await buildRecentChapterTrailEntries(storyDir, plan.intent.chapter);
480
+ const memorySelection = await retrieveMemorySelection({
481
+ bookDir: dirname(storyDir),
482
+ chapterNumber: plan.intent.chapter,
483
+ goal: plan.intent.goal,
484
+ outlineNode: plan.intent.outlineNode,
485
+ mustKeep: retrievalHints,
486
+ semanticSelector: memorySemanticSelector,
487
+ });
488
+ const hookDebtEntries = await buildHookDebtEntries(storyDir, plan, memorySelection.activeHooks, language);
489
+ const summaryEntries = memorySelection.summaries.map((summary) => ({
490
+ source: `story/chapter_summaries.md#${summary.chapter}`,
491
+ reason: "Relevant episodic memory retrieved for the current chapter goal.",
492
+ excerpt: [summary.title, summary.events, summary.stateChanges, summary.hookActivity]
493
+ .filter(Boolean)
494
+ .join(" | "),
495
+ }));
496
+ const factEntries = memorySelection.facts.map((fact) => ({
497
+ source: `story/current_state.md#${toFactAnchor(fact.predicate)}`,
498
+ reason: "Relevant current-state fact retrieved for the current chapter goal.",
499
+ excerpt: `${fact.predicate} | ${fact.object}`,
500
+ }));
501
+ const hookEntries = memorySelection.hooks.map((hook) => ({
502
+ source: `story/pending_hooks.md#${hook.hookId}`,
503
+ reason: "Carry forward unresolved hooks that match the chapter focus.",
504
+ excerpt: [hook.type, hook.status, hook.expectedPayoff, hook.payoffTiming, hook.notes]
505
+ .filter(Boolean)
506
+ .join(" | "),
507
+ }));
508
+ const volumeSummaryEntries = memorySelection.volumeSummaries.map((summary) => ({
509
+ source: `story/volume_summaries.md#${summary.anchor}`,
510
+ reason: "Carry forward long-span arc memory compressed from earlier volumes.",
511
+ excerpt: `${summary.heading} | ${summary.content}`,
512
+ }));
513
+ return {
514
+ entries: [
515
+ ...chapterMemoEntry,
516
+ ...entries.filter((entry) => entry !== null),
517
+ ...outlineEntries,
518
+ ...canonEntries.filter((entry) => entry !== null),
519
+ ...trailEntries,
520
+ ...hookDebtEntries,
521
+ ...factEntries,
522
+ ...summaryEntries,
523
+ ...volumeSummaryEntries,
524
+ ...hookEntries,
525
+ ],
526
+ retrievalTrace: memorySelection.retrievalTrace,
527
+ };
528
+ }
529
+ function deriveRetrievalHints(plan) {
530
+ return [
531
+ plan.intent.goal,
532
+ plan.intent.outlineNode,
533
+ ...plan.memo.threadRefs,
534
+ ].filter((value) => Boolean(value));
535
+ }
536
+ async function buildRecentChapterTrailEntries(storyDir, chapterNumber) {
537
+ const content = await readFileOrDefault(join(storyDir, "chapter_summaries.md"));
538
+ if (!content || content === "(文件尚未创建)") {
539
+ return [];
540
+ }
541
+ const recentSummaries = parseChapterSummariesMarkdown(content)
542
+ .filter((summary) => summary.chapter < chapterNumber)
543
+ .sort((left, right) => right.chapter - left.chapter)
544
+ .slice(0, 5);
545
+ if (recentSummaries.length === 0) {
546
+ return [];
547
+ }
548
+ const entries = [];
549
+ const recentTitles = recentSummaries
550
+ .map((summary) => [summary.chapter, summary.title].filter(Boolean).join(": "))
551
+ .filter(Boolean)
552
+ .join(" | ");
553
+ if (recentTitles) {
554
+ entries.push({
555
+ source: "story/chapter_summaries.md#recent_titles",
556
+ reason: "Keep recent title history visible to avoid repetitive chapter naming.",
557
+ excerpt: recentTitles,
558
+ });
559
+ }
560
+ const moodTrail = recentSummaries
561
+ .filter((summary) => summary.mood || summary.chapterType)
562
+ .map((summary) => `${summary.chapter}: ${summary.mood || "(none)"} / ${summary.chapterType || "(none)"}`)
563
+ .join(" | ");
564
+ if (moodTrail) {
565
+ entries.push({
566
+ source: "story/chapter_summaries.md#recent_mood_type_trail",
567
+ reason: "Keep recent mood and chapter-type cadence visible before writing the next chapter.",
568
+ excerpt: moodTrail,
569
+ });
570
+ }
571
+ const endingTrail = await buildRecentEndingTrail(storyDir, chapterNumber);
572
+ if (endingTrail) {
573
+ entries.push({
574
+ source: "story/chapters#recent_endings",
575
+ reason: "Show how recent chapters ended so the writer avoids structural repetition (e.g. 3 consecutive collapse endings).",
576
+ excerpt: endingTrail,
577
+ });
578
+ }
579
+ return entries;
580
+ }
581
+ async function buildRecentEndingTrail(storyDir, chapterNumber) {
582
+ const chaptersDir = join(dirname(storyDir), "chapters");
583
+ try {
584
+ const files = await readdir(chaptersDir);
585
+ const chapterFiles = files
586
+ .filter((file) => file.endsWith(".md"))
587
+ .map((file) => ({ file, num: parseInt(file.slice(0, 4), 10) }))
588
+ .filter((entry) => Number.isFinite(entry.num) && entry.num < chapterNumber)
589
+ .sort((a, b) => b.num - a.num)
590
+ .slice(0, 3);
591
+ const endings = [];
592
+ for (const entry of chapterFiles.reverse()) {
593
+ const content = await readFile(join(chaptersDir, entry.file), "utf-8");
594
+ const lastLine = extractLastMeaningfulSentence(content);
595
+ if (lastLine) {
596
+ endings.push(`ch${entry.num}: ${lastLine}`);
597
+ }
598
+ }
599
+ return endings.length >= 2 ? endings.join(" | ") : undefined;
600
+ }
601
+ catch {
602
+ return undefined;
603
+ }
604
+ }
605
+ function extractLastMeaningfulSentence(content) {
606
+ const lines = content.split("\n").map((line) => line.trim()).filter((line) => line.length > 5 && !line.startsWith("#") && !line.startsWith("|") && !line.startsWith("==="));
607
+ const last = lines.at(-1);
608
+ if (!last)
609
+ return undefined;
610
+ return last.length > 60 ? last.slice(0, 57) + "..." : last;
611
+ }
612
+ async function buildHookDebtEntries(storyDir, plan, activeHooks, language) {
613
+ const targetHookIds = [...new Set(plan.memo.threadRefs)];
614
+ if (targetHookIds.length === 0) {
615
+ return [];
616
+ }
617
+ const summaries = parseChapterSummariesMarkdown(await readFileOrDefault(join(storyDir, "chapter_summaries.md")));
618
+ return targetHookIds.flatMap((hookId) => {
619
+ const hook = activeHooks.find((entry) => entry.hookId === hookId);
620
+ if (!hook) {
621
+ return [];
622
+ }
623
+ const seedSummary = findHookSummary(summaries, hook.hookId, hook.startChapter, "seed");
624
+ const latestSummary = findHookSummary(summaries, hook.hookId, hook.lastAdvancedChapter, "latest");
625
+ const role = language === "en" ? "memo-referenced debt" : "备忘引用旧债";
626
+ const promise = hook.expectedPayoff || (language === "en" ? "(unspecified)" : "(未写明)");
627
+ const seedBeat = seedSummary
628
+ ? renderHookDebtBeat(seedSummary)
629
+ : (hook.notes || promise);
630
+ const latestBeat = latestSummary && latestSummary !== seedSummary
631
+ ? renderHookDebtBeat(latestSummary)
632
+ : undefined;
633
+ const age = Math.max(0, plan.intent.chapter - Math.max(1, hook.startChapter));
634
+ return [{
635
+ source: `runtime/hook_debt#${hook.hookId}`,
636
+ reason: language === "en"
637
+ ? "Narrative debt brief with original seed text for this hook agenda target."
638
+ : "含原始种子文本的叙事债务简报。",
639
+ excerpt: language === "en"
640
+ ? [
641
+ `${hook.hookId} (${hook.type}, ${role}, open ${age} chapters)`,
642
+ `reader promise: ${promise}`,
643
+ `original seed (ch${hook.startChapter}): ${seedBeat}`,
644
+ latestBeat ? `latest turn (ch${hook.lastAdvancedChapter}): ${latestBeat}` : undefined,
645
+ ].filter(Boolean).join(" | ")
646
+ : [
647
+ `${hook.hookId}(${hook.type},${role},已开${age}章)`,
648
+ `读者承诺:${promise}`,
649
+ `种于第${hook.startChapter}章:${seedBeat}`,
650
+ latestBeat ? `推进于第${hook.lastAdvancedChapter}章:${latestBeat}` : undefined,
651
+ ].filter(Boolean).join(" | "),
652
+ }];
653
+ });
654
+ }
655
+ async function maybeContextSource(storyDir, fileName, reason) {
656
+ const path = join(storyDir, fileName);
657
+ let content = await readFileOrDefault(path);
658
+ let resolvedFileName = fileName;
659
+ if ((!content || content === "(文件尚未创建)")) {
660
+ // Phase 5 back-compat: the new outline/ files may be absent on legacy
661
+ // books. Fall back to the deprecated paths transparently.
662
+ const legacyFallback = outlineFallback(fileName);
663
+ if (legacyFallback) {
664
+ const legacyPath = join(storyDir, legacyFallback);
665
+ const legacyContent = await readFileOrDefault(legacyPath);
666
+ if (legacyContent && legacyContent !== "(文件尚未创建)") {
667
+ content = legacyContent;
668
+ resolvedFileName = legacyFallback;
669
+ }
670
+ }
671
+ }
672
+ if (!content || content === "(文件尚未创建)")
673
+ return null;
674
+ return {
675
+ source: `story/${resolvedFileName}`,
676
+ reason,
677
+ excerpt: content.trim(),
678
+ };
679
+ }
680
+ async function maybeOutlineSectionSources(storyDir, fileName, reason, plan, kind, language, outlineSectionSelector) {
681
+ const path = join(storyDir, fileName);
682
+ const content = await readFileOrDefault(path);
683
+ if (!content || content === "(文件尚未创建)") {
684
+ const legacyFallback = outlineFallback(fileName);
685
+ if (!legacyFallback)
686
+ return [];
687
+ const legacyContent = await readFileOrDefault(join(storyDir, legacyFallback));
688
+ if (!legacyContent || legacyContent === "(文件尚未创建)")
689
+ return [];
690
+ return await selectOutlineSectionEntries({
691
+ fileName: legacyFallback,
692
+ content: legacyContent,
693
+ reason,
694
+ plan,
695
+ kind,
696
+ language,
697
+ outlineSectionSelector,
698
+ });
699
+ }
700
+ return await selectOutlineSectionEntries({
701
+ fileName,
702
+ content,
703
+ reason,
704
+ plan,
705
+ kind,
706
+ language,
707
+ outlineSectionSelector,
708
+ });
709
+ }
710
+ async function selectOutlineSectionEntries(params) {
711
+ const sections = splitMarkdownSections(params.content);
712
+ if (sections.length === 0) {
713
+ return [{
714
+ source: `story/${params.fileName}#document`,
715
+ reason: params.reason,
716
+ excerpt: params.content.trim(),
717
+ }];
718
+ }
719
+ const hints = deriveOutlineSelectionHints(params.plan);
720
+ const selected = sections.filter((section) => params.kind === "story-frame"
721
+ ? isRelevantStoryFrameSection(section, hints)
722
+ : isRelevantVolumeMapSection(section, hints, params.plan.intent.chapter));
723
+ const finalSections = selected.length > 0 ? selected : fallbackOutlineSections(sections, params.kind, params.plan.intent.chapter);
724
+ const candidates = sections.map((section) => ({
725
+ source: `story/${params.fileName}#${slugifyAnchor(section.heading)}`,
726
+ heading: section.heading,
727
+ excerpt: section.raw.trim(),
728
+ }));
729
+ if (params.outlineSectionSelector) {
730
+ try {
731
+ const selectedSources = await params.outlineSectionSelector({
732
+ fileName: params.fileName,
733
+ kind: params.kind,
734
+ chapterNumber: params.plan.intent.chapter,
735
+ goal: params.plan.intent.goal,
736
+ outlineNode: params.plan.intent.outlineNode ?? "",
737
+ language: params.language,
738
+ candidates,
739
+ });
740
+ const selectedSourceSet = new Set(selectedSources);
741
+ const llmSections = sections.filter((section) => selectedSourceSet.has(`story/${params.fileName}#${slugifyAnchor(section.heading)}`));
742
+ if (llmSections.length > 0) {
743
+ return dedupeBySource(llmSections.map((section) => ({
744
+ source: `story/${params.fileName}#${slugifyAnchor(section.heading)}`,
745
+ reason: params.reason,
746
+ excerpt: section.raw.trim(),
747
+ })));
748
+ }
749
+ }
750
+ catch {
751
+ // Semantic section selection is quality guidance, not a hard dependency.
752
+ // If the provider flakes or returns malformed JSON, keep the deterministic
753
+ // fallback so chapter production does not stall.
754
+ }
755
+ }
756
+ return dedupeBySource(finalSections.map((section) => ({
757
+ source: `story/${params.fileName}#${slugifyAnchor(section.heading)}`,
758
+ reason: params.reason,
759
+ excerpt: section.raw.trim(),
760
+ })));
761
+ }
762
+ function splitMarkdownSections(content) {
763
+ const sections = [];
764
+ let current = null;
765
+ for (const line of content.split(/\r?\n/)) {
766
+ const headingMatch = /^(#{1,6})\s+(.+?)\s*$/.exec(line);
767
+ if (headingMatch) {
768
+ if (current && current.lines.some((entry) => entry.trim().length > 0)) {
769
+ sections.push(current);
770
+ }
771
+ current = {
772
+ heading: headingMatch[2].trim(),
773
+ lines: [line],
774
+ };
775
+ continue;
776
+ }
777
+ if (current) {
778
+ current.lines.push(line);
779
+ }
780
+ }
781
+ if (current && current.lines.some((entry) => entry.trim().length > 0)) {
782
+ sections.push(current);
783
+ }
784
+ return sections
785
+ .map((section) => ({
786
+ heading: section.heading,
787
+ raw: section.lines.join("\n").trim(),
788
+ }))
789
+ .filter((section) => section.raw.length > 0);
790
+ }
791
+ function deriveOutlineSelectionHints(plan) {
792
+ return [
793
+ plan.intent.goal,
794
+ plan.intent.outlineNode,
795
+ plan.intent.arcContext,
796
+ ...plan.intent.mustKeep,
797
+ ...plan.intent.mustAvoid,
798
+ ...plan.intent.styleEmphasis,
799
+ plan.memo.goal,
800
+ plan.memo.body,
801
+ ...plan.memo.threadRefs,
802
+ ].filter((value) => Boolean(value && value.trim()));
803
+ }
804
+ function isRelevantStoryFrameSection(section, hints) {
805
+ const heading = normalizeForMatch(section.heading);
806
+ const sectionText = normalizeForMatch(section.raw);
807
+ const hardHeadingSignals = [
808
+ "世界观",
809
+ "底色",
810
+ "铁律",
811
+ "规则",
812
+ "核心冲突",
813
+ "终局",
814
+ "world",
815
+ "tonal",
816
+ "rule",
817
+ "core conflict",
818
+ "endgame",
819
+ ];
820
+ if (hardHeadingSignals.some((signal) => heading.includes(normalizeForMatch(signal)))) {
821
+ return true;
822
+ }
823
+ return matchesOutlineHints(sectionText, hints);
824
+ }
825
+ function isRelevantVolumeMapSection(section, hints, chapterNumber) {
826
+ const heading = normalizeForMatch(section.heading);
827
+ if (headingMentionsChapter(heading, chapterNumber)) {
828
+ return true;
829
+ }
830
+ return matchesOutlineHints(normalizeForMatch(section.raw), hints);
831
+ }
832
+ function matchesOutlineHints(sectionText, hints) {
833
+ for (const hint of hints) {
834
+ const terms = extractMatchTerms(hint);
835
+ if (terms.length === 0)
836
+ continue;
837
+ const hits = terms.filter((term) => sectionText.includes(term));
838
+ if (hits.length >= Math.min(2, terms.length)) {
839
+ return true;
840
+ }
841
+ }
842
+ return false;
843
+ }
844
+ function fallbackOutlineSections(sections, kind, chapterNumber) {
845
+ if (kind === "volume-map") {
846
+ const chapterHit = sections.find((section) => headingMentionsChapter(normalizeForMatch(section.heading), chapterNumber));
847
+ if (chapterHit)
848
+ return [chapterHit];
849
+ }
850
+ return sections.slice(0, 1);
851
+ }
852
+ function extractMatchTerms(value) {
853
+ const normalized = normalizeForMatch(value);
854
+ const terms = new Set();
855
+ for (const term of normalized.match(/[a-z0-9]{3,}/g) ?? []) {
856
+ terms.add(term);
857
+ }
858
+ for (const term of normalized.match(/[\u4e00-\u9fff]{2,}/g) ?? []) {
859
+ terms.add(term);
860
+ }
861
+ return [...terms].filter((term) => term.length >= 2);
862
+ }
863
+ function normalizeForMatch(value) {
864
+ return value.toLowerCase().replace(/\s+/g, " ").trim();
865
+ }
866
+ function headingMentionsChapter(normalizedHeading, chapterNumber) {
867
+ return normalizedHeading.includes(`chapter ${chapterNumber}`)
868
+ || normalizedHeading.includes(`chapter${chapterNumber}`)
869
+ || normalizedHeading.includes(`ch.${chapterNumber}`)
870
+ || normalizedHeading.includes(`ch${chapterNumber}`)
871
+ || normalizedHeading.includes(`第${chapterNumber}章`);
872
+ }
873
+ function slugifyAnchor(value) {
874
+ return value
875
+ .trim()
876
+ .toLowerCase()
877
+ .replace(/[^a-z0-9\u4e00-\u9fff]+/g, "-")
878
+ .replace(/^-+|-+$/g, "")
879
+ || "section";
880
+ }
881
+ function dedupeBySource(entries) {
882
+ const seen = new Set();
883
+ return entries.filter((entry) => {
884
+ if (seen.has(entry.source))
885
+ return false;
886
+ seen.add(entry.source);
887
+ return true;
888
+ });
889
+ }
890
+ function outlineFallback(fileName) {
891
+ if (fileName === "outline/story_frame.md")
892
+ return "story_bible.md";
893
+ if (fileName === "outline/volume_map.md")
894
+ return "volume_outline.md";
895
+ return null;
896
+ }
897
+ function toFactAnchor(predicate) {
898
+ return predicate
899
+ .trim()
900
+ .toLowerCase()
901
+ .replace(/[^a-z0-9\u4e00-\u9fff]+/g, "-")
902
+ .replace(/^-+|-+$/g, "")
903
+ || "fact";
904
+ }
905
+ async function readFileOrDefault(path) {
906
+ try {
907
+ return await readFile(path, "utf-8");
908
+ }
909
+ catch {
910
+ return "(文件尚未创建)";
911
+ }
912
+ }
913
+ function findHookSummary(summaries, hookId, chapter, mode) {
914
+ const directChapterHit = summaries.find((summary) => summary.chapter === chapter);
915
+ const hookMentions = summaries.filter((summary) => summaryMentionsHook(summary, hookId));
916
+ if (mode === "seed") {
917
+ return hookMentions.find((summary) => summary.chapter === chapter)
918
+ ?? hookMentions.at(0)
919
+ ?? directChapterHit;
920
+ }
921
+ return [...hookMentions].reverse().find((summary) => summary.chapter === chapter)
922
+ ?? hookMentions.at(-1)
923
+ ?? directChapterHit;
924
+ }
925
+ function summaryMentionsHook(summary, hookId) {
926
+ return [
927
+ summary.title,
928
+ summary.events,
929
+ summary.stateChanges,
930
+ summary.hookActivity,
931
+ ].some((text) => text.includes(hookId));
932
+ }
933
+ function renderHookDebtBeat(summary) {
934
+ return `ch${summary.chapter} ${summary.title} - ${summary.events || summary.hookActivity || summary.stateChanges || "(none)"}`;
935
+ }
936
+ //# sourceMappingURL=composer.js.map