@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,1102 @@
1
+ import { createHash, randomUUID } from "node:crypto";
2
+ import { Agent } from "@mariozechner/pi-agent-core";
3
+ import { getModel, getEnvApiKey, createAssistantMessageEventStream } from "@mariozechner/pi-ai";
4
+ import { buildAgentSystemPrompt } from "./agent-system-prompt.js";
5
+ import { createPatchChapterTextTool, createReplaceChapterTextTool, createResyncChapterStateTool, createDeleteLatestChapterTool, createRenameEntityTool, createSubAgentTool, createReadTool, createGrepTool, createLsTool, createWriteTruthFileTool, createShortFictionRunTool, createGenerateCoverTool, createPlayEditTool, createPlayReviseTool, createPlayStartTool, createPlayStepTool, createProposeActionTool, createScriptCreationTool, createStoryboardCreationTool, createInteractiveFilmCreationTool, createTranslationCreateTool, createFanficBookTool, createContinuationImportTool, createSpinoffBookTool, createImitationBookTool, createResearchWebTool, createIngestMaterialTool, createRetrieveMaterialTool, createManageBookReferenceTool, createImportChaptersTool, } from "./agent-tools.js";
6
+ import { createFilmAuthoringTools, filmLLMDepsFromClient } from "./film-authoring-tools.js";
7
+ import { createNarrativeForecastCreateTool, createNarrativeForecastGetTool, createNarrativeForecastSelectTool, } from "./forecast-tools.js";
8
+ import { createBookContextTransform, createInteractiveFilmContextTransform } from "./context-transform.js";
9
+ import { appendTranscriptEvents, readTranscriptEvents, } from "../interaction/session-transcript.js";
10
+ import { TOOL_RESULT_BRIDGE_TEXT, adaptRestoredAgentMessagesForModel, appendRestoredHistoryBoundary, restoreAgentMessagesFromTranscript, } from "../interaction/session-transcript-restore.js";
11
+ import { createSkillRegistry, loadAvailableAgentSkills, mergeActivatedSkillGuidance, resolveProductionSkillActivations, } from "../skills/index.js";
12
+ import { assertSafeBookId } from "../utils/book-id.js";
13
+ import { PlayStore } from "../play/play-store.js";
14
+ import { isLlmStubEnabled, stubAgentStream } from "./llm-stub.js";
15
+ import { assistantInvokesSkill, createUseSkillTool, sanitizeSkillTurnMessage, } from "./skill-tool.js";
16
+ import { opaqueConversationId, runWithAgentTrajectory } from "../llm/agent-trajectory.js";
17
+ import { guardedPiStream } from "./pi-stream.js";
18
+ const agentCache = new Map();
19
+ const agentSessionQueues = new Map();
20
+ /** TTL for cached agents: 5 minutes. */
21
+ const CACHE_TTL_MS = 5 * 60 * 1000;
22
+ const EMPTY_USAGE = {
23
+ input: 0,
24
+ output: 0,
25
+ cacheRead: 0,
26
+ cacheWrite: 0,
27
+ totalTokens: 0,
28
+ cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 },
29
+ };
30
+ /** Cleanup interval handle (lazy-started). */
31
+ let cleanupTimer = null;
32
+ function ensureCleanupTimer() {
33
+ if (cleanupTimer)
34
+ return;
35
+ cleanupTimer = setInterval(() => {
36
+ const now = Date.now();
37
+ for (const [id, entry] of agentCache) {
38
+ if (now - entry.lastActive > CACHE_TTL_MS) {
39
+ agentCache.delete(id);
40
+ }
41
+ }
42
+ // Stop the timer when nothing left to watch.
43
+ if (agentCache.size === 0 && cleanupTimer) {
44
+ clearInterval(cleanupTimer);
45
+ cleanupTimer = null;
46
+ }
47
+ }, 60_000); // run every 60 s
48
+ // Allow the process to exit even if this timer is alive.
49
+ if (cleanupTimer && typeof cleanupTimer === "object" && "unref" in cleanupTimer) {
50
+ cleanupTimer.unref();
51
+ }
52
+ }
53
+ // ---------------------------------------------------------------------------
54
+ // Helpers
55
+ // ---------------------------------------------------------------------------
56
+ function resolveModel(spec) {
57
+ if (!spec) {
58
+ throw new Error("Model is required but was undefined. Check LLM configuration.");
59
+ }
60
+ if (typeof spec === "object" && "id" in spec && "api" in spec) {
61
+ // Already a Model object.
62
+ return spec;
63
+ }
64
+ const { provider, modelId } = spec;
65
+ if (!provider || !modelId) {
66
+ throw new Error(`Invalid model spec: provider=${provider}, modelId=${modelId}`);
67
+ }
68
+ return getModel(provider, modelId);
69
+ }
70
+ function envFlagEnabled(value, defaultValue) {
71
+ if (value === undefined)
72
+ return defaultValue;
73
+ if (value === "1" || value.toLowerCase() === "true")
74
+ return true;
75
+ if (value === "0" || value.toLowerCase() === "false")
76
+ return false;
77
+ return defaultValue;
78
+ }
79
+ function agentModelIdentity(model) {
80
+ return [
81
+ model.api,
82
+ model.provider,
83
+ model.baseUrl ?? "",
84
+ model.id,
85
+ ].join("::");
86
+ }
87
+ function actionPayloadCacheKey(payload) {
88
+ return payload ? JSON.stringify(payload) : "";
89
+ }
90
+ function skillResolutionCacheKey(value) {
91
+ return createHash("sha256").update(JSON.stringify({
92
+ used: value.usedSkills.map((skill) => ({
93
+ id: skill.id,
94
+ source: skill.source,
95
+ body: skill.body ?? "",
96
+ })),
97
+ forced: value.forcedSkillIds,
98
+ missing: value.missingSkillIds,
99
+ disabled: value.disabledSkillIds,
100
+ available: value.availableSkills.map((skill) => ({
101
+ id: skill.id,
102
+ name: skill.name,
103
+ description: skill.description,
104
+ body: skill.body ?? "",
105
+ baseDir: skill.baseDir ?? "",
106
+ })),
107
+ })).digest("hex");
108
+ }
109
+ function sessionQueueKey(projectRoot, sessionId) {
110
+ return `${projectRoot}\0${sessionId}`;
111
+ }
112
+ function agentCacheKey(projectRoot, sessionId) {
113
+ return sessionQueueKey(projectRoot, sessionId);
114
+ }
115
+ function buildAttachmentUserBlock(attachments, language) {
116
+ if (!attachments?.length)
117
+ return "";
118
+ const isEn = language === "en";
119
+ const lines = [
120
+ isEn
121
+ ? "\n\n## Uploaded Files (host-provided, user-authorized)"
122
+ : "\n\n## 用户上传文件(宿主已接收,用户授权本轮使用)",
123
+ ];
124
+ for (const attachment of attachments) {
125
+ lines.push(`\n### ${attachment.filename}`);
126
+ lines.push(`- id: ${attachment.id}`);
127
+ lines.push(`- mime: ${attachment.mimeType || "application/octet-stream"}`);
128
+ lines.push(`- size: ${attachment.size}`);
129
+ if (attachment.storedPath)
130
+ lines.push(`- stored_path: ${attachment.storedPath}`);
131
+ if (attachment.text) {
132
+ lines.push(isEn ? "\nContent:" : "\n内容:");
133
+ lines.push("```");
134
+ lines.push(attachment.text);
135
+ lines.push("```");
136
+ }
137
+ else if (attachment.image) {
138
+ lines.push(isEn ? "- image: attached as multimodal input" : "- 图片:已作为多模态输入附加");
139
+ }
140
+ else {
141
+ lines.push(isEn
142
+ ? "- content: stored only; no extractor is available for this MIME type yet"
143
+ : "- 内容:已保存;当前 MIME 类型暂未配置文本抽取器");
144
+ }
145
+ }
146
+ return lines.join("\n");
147
+ }
148
+ function attachmentImages(attachments) {
149
+ return (attachments ?? [])
150
+ .filter((attachment) => attachment.image)
151
+ .map((attachment) => ({
152
+ type: "image",
153
+ data: attachment.image.data,
154
+ mimeType: attachment.image.mimeType,
155
+ }));
156
+ }
157
+ function localAssistantStopStream(model) {
158
+ const stream = createAssistantMessageEventStream();
159
+ const message = {
160
+ role: "assistant",
161
+ content: [],
162
+ api: model.api,
163
+ provider: model.provider,
164
+ model: model.id,
165
+ usage: EMPTY_USAGE,
166
+ stopReason: "stop",
167
+ timestamp: Date.now(),
168
+ };
169
+ queueMicrotask(() => {
170
+ stream.push({ type: "done", reason: "stop", message });
171
+ stream.end(message);
172
+ });
173
+ return stream;
174
+ }
175
+ export function isTerminalProductionToolName(toolName) {
176
+ return toolName === "propose_action"
177
+ || toolName === "sub_agent"
178
+ || toolName === "resync_chapter_state"
179
+ || toolName === "short_fiction_run"
180
+ || toolName === "script_create"
181
+ || toolName === "storyboard_create"
182
+ || toolName === "interactive_film_create"
183
+ || toolName === "translation_create"
184
+ || toolName === "fanfic_create"
185
+ || toolName === "continuation_import"
186
+ || toolName === "spinoff_create"
187
+ || toolName === "imitation_create"
188
+ || toolName === "generate_cover"
189
+ || toolName === "play_start"
190
+ || toolName === "play_edit"
191
+ || toolName === "play_revise"
192
+ || toolName === "play_step"
193
+ || toolName === "create_narrative_forecast"
194
+ || toolName === "get_narrative_forecast"
195
+ || toolName === "select_narrative_branch";
196
+ }
197
+ function hasUnansweredTerminalToolResult(messages) {
198
+ let assistantTextAfterTool = false;
199
+ for (let index = messages.length - 1; index >= 0; index -= 1) {
200
+ const message = messages[index];
201
+ if (!message || typeof message !== "object" || !("role" in message))
202
+ continue;
203
+ const role = message.role;
204
+ if (role === "user")
205
+ return false;
206
+ if (role === "assistant") {
207
+ const text = extractTextFromAssistant(message).trim();
208
+ if (text)
209
+ assistantTextAfterTool = true;
210
+ continue;
211
+ }
212
+ if (role !== "toolResult")
213
+ continue;
214
+ const toolName = message.toolName;
215
+ if (isTerminalProductionToolName(toolName)) {
216
+ return !assistantTextAfterTool;
217
+ }
218
+ }
219
+ return false;
220
+ }
221
+ async function runInAgentSessionQueue(projectRoot, sessionId, task) {
222
+ const key = sessionQueueKey(projectRoot, sessionId);
223
+ const previous = agentSessionQueues.get(key) ?? Promise.resolve();
224
+ let release;
225
+ const gate = new Promise((resolve) => {
226
+ release = resolve;
227
+ });
228
+ const queued = previous.catch(() => undefined).then(() => gate);
229
+ agentSessionQueues.set(key, queued);
230
+ await previous.catch(() => undefined);
231
+ try {
232
+ return await task();
233
+ }
234
+ finally {
235
+ release();
236
+ if (agentSessionQueues.get(key) === queued) {
237
+ agentSessionQueues.delete(key);
238
+ }
239
+ }
240
+ }
241
+ async function latestCommittedSeq(projectRoot, sessionId) {
242
+ const events = await readTranscriptEvents(projectRoot, sessionId);
243
+ return events
244
+ .filter((event) => event.type === "request_committed")
245
+ .reduce((max, event) => Math.max(max, event.seq), 0);
246
+ }
247
+ function transcriptRoleForMessage(message) {
248
+ if (!message || typeof message !== "object" || !("role" in message))
249
+ return null;
250
+ const role = message.role;
251
+ return role === "user" || role === "assistant" || role === "toolResult" || role === "system"
252
+ ? role
253
+ : null;
254
+ }
255
+ function firstToolCallId(message) {
256
+ if (!message || typeof message !== "object" || !("content" in message))
257
+ return undefined;
258
+ const content = message.content;
259
+ if (!Array.isArray(content))
260
+ return undefined;
261
+ const block = content.find((item) => !!item &&
262
+ typeof item === "object" &&
263
+ item.type === "toolCall" &&
264
+ typeof item.id === "string");
265
+ return block?.id;
266
+ }
267
+ function toolCallIdForMessage(message) {
268
+ if (!message || typeof message !== "object")
269
+ return undefined;
270
+ if (message.role === "toolResult") {
271
+ const toolCallId = message.toolCallId;
272
+ return typeof toolCallId === "string" && toolCallId.length > 0 ? toolCallId : undefined;
273
+ }
274
+ return firstToolCallId(message);
275
+ }
276
+ function messageTimestamp(message) {
277
+ if (message && typeof message === "object") {
278
+ const timestamp = message.timestamp;
279
+ if (typeof timestamp === "number" && Number.isFinite(timestamp) && timestamp >= 0) {
280
+ return Math.floor(timestamp);
281
+ }
282
+ }
283
+ return Date.now();
284
+ }
285
+ async function ensureSessionCreatedEvent(projectRoot, sessionId, bookId, sessionKind) {
286
+ await appendTranscriptEvents(projectRoot, sessionId, ({ events, nextSeq }) => {
287
+ if (events.some((event) => event.type === "session_created"))
288
+ return [];
289
+ const now = Date.now();
290
+ return [{
291
+ type: "session_created",
292
+ version: 1,
293
+ sessionId,
294
+ seq: nextSeq,
295
+ timestamp: now,
296
+ bookId,
297
+ ...(sessionKind ? { sessionKind } : {}),
298
+ title: null,
299
+ createdAt: now,
300
+ updatedAt: now,
301
+ }];
302
+ });
303
+ }
304
+ async function appendAgentTranscriptEvent(projectRoot, sessionId, buildEvent) {
305
+ const events = await appendTranscriptEvents(projectRoot, sessionId, ({ nextSeq }) => [
306
+ buildEvent(nextSeq),
307
+ ]);
308
+ const event = events[0];
309
+ if (!event)
310
+ throw new Error(`Failed to append transcript event for session "${sessionId}"`);
311
+ return event;
312
+ }
313
+ /**
314
+ * Extract readable text from an AssistantMessage's content array.
315
+ * Filters out tool-call blocks; concatenates text blocks.
316
+ */
317
+ function extractTextFromAssistant(msg) {
318
+ return msg.content
319
+ .filter((c) => c.type === "text")
320
+ .map((c) => c.text)
321
+ .join("");
322
+ }
323
+ function lastAssistantMessage(messages) {
324
+ for (let i = messages.length - 1; i >= 0; i--) {
325
+ const msg = messages[i];
326
+ if (msg && typeof msg === "object" && "role" in msg && msg.role === "assistant") {
327
+ return msg;
328
+ }
329
+ }
330
+ return undefined;
331
+ }
332
+ function assistantErrorMessage(message) {
333
+ return message &&
334
+ (message.stopReason === "error" || message.stopReason === "aborted") &&
335
+ message.errorMessage
336
+ ? message.errorMessage
337
+ : undefined;
338
+ }
339
+ function convertAgentMessagesForModel(messages, model) {
340
+ const llmMessages = messages.flatMap((message) => {
341
+ if (!message || typeof message !== "object" || !("role" in message))
342
+ return [];
343
+ const raw = message;
344
+ if (raw.role === "user" || raw.role === "assistant" || raw.role === "toolResult") {
345
+ return [message];
346
+ }
347
+ if (raw.role === "system" && typeof raw.content === "string") {
348
+ return [{
349
+ role: "user",
350
+ content: raw.content,
351
+ timestamp: messageTimestamp(message),
352
+ }];
353
+ }
354
+ return [];
355
+ });
356
+ const candidate = model;
357
+ // InkOS's internal `toolResult` role is not part of the OpenAI Chat Completions spec.
358
+ // Many openai-completions upstreams (Google, and kkaiapi/DeepSeek-Pro-style gateways) reject
359
+ // it outright — which surfaces as an opaque "503 provider temporarily unavailable" — so fold
360
+ // tool results into a plain user message for EVERY openai-completions endpoint, not just Google.
361
+ // Anthropic-format endpoints (MiniMax / 百炼) handle tool results natively and are left untouched.
362
+ const isOpenAICompletionsCompatible = candidate.api === "openai-completions";
363
+ if (!isOpenAICompletionsCompatible)
364
+ return llmMessages;
365
+ const converted = [];
366
+ const pushToolResultsAsUser = (toolResults) => {
367
+ const lines = toolResults.flatMap((result) => {
368
+ const content = result.content
369
+ .map((block) => block.type === "text" ? block.text : "[image]")
370
+ .filter(Boolean)
371
+ .join("\n")
372
+ .trim() || "(empty tool result)";
373
+ return [`- ${result.toolName} (${result.toolCallId}):`, content];
374
+ });
375
+ converted.push({
376
+ role: "user",
377
+ content: [
378
+ "[Tool results]",
379
+ ...lines,
380
+ "Use these tool results to answer the active user request. If a tool failed, explain the failure and choose the next useful action.",
381
+ ].join("\n"),
382
+ timestamp: toolResults.reduce((max, result) => Math.max(max, messageTimestamp(result)), 0) || Date.now(),
383
+ });
384
+ };
385
+ for (let i = 0; i < llmMessages.length; i++) {
386
+ const message = llmMessages[i];
387
+ if (message.role === "assistant") {
388
+ const textContent = message.content.filter((block) => block.type === "text" && typeof block.text === "string" && block.text.trim().length > 0);
389
+ if (textContent.length === 1 &&
390
+ message.content.length === 1 &&
391
+ textContent[0].text.trim() === TOOL_RESULT_BRIDGE_TEXT) {
392
+ continue;
393
+ }
394
+ const toolCallIds = new Set();
395
+ for (const block of message.content) {
396
+ if (block.type === "toolCall" && typeof block.id === "string" && block.id.length > 0) {
397
+ toolCallIds.add(block.id);
398
+ }
399
+ }
400
+ if (toolCallIds.size === 0) {
401
+ converted.push(message);
402
+ continue;
403
+ }
404
+ if (textContent.length > 0) {
405
+ converted.push({ ...message, content: textContent });
406
+ }
407
+ const toolResults = [];
408
+ let nextIndex = i + 1;
409
+ while (nextIndex < llmMessages.length) {
410
+ const next = llmMessages[nextIndex];
411
+ if (next.role !== "toolResult" || !toolCallIds.has(next.toolCallId))
412
+ break;
413
+ toolResults.push(next);
414
+ nextIndex += 1;
415
+ }
416
+ if (toolResults.length > 0) {
417
+ pushToolResultsAsUser(toolResults);
418
+ i = nextIndex - 1;
419
+ }
420
+ continue;
421
+ }
422
+ if (message.role === "toolResult") {
423
+ pushToolResultsAsUser([message]);
424
+ continue;
425
+ }
426
+ converted.push(message);
427
+ }
428
+ return converted;
429
+ }
430
+ /**
431
+ * Extract thinking/reasoning text from an AssistantMessage's content array.
432
+ */
433
+ function extractThinkingFromAssistant(msg) {
434
+ return msg.content
435
+ .filter((c) => c.type === "thinking")
436
+ .map((c) => c.thinking ?? "")
437
+ .join("");
438
+ }
439
+ /**
440
+ * Convert plain `{ role, content }` messages (from BookSession disk storage)
441
+ * back into pi-agent AgentMessage format so they can be loaded into an Agent.
442
+ */
443
+ function plainToAgentMessages(plain) {
444
+ return plain.map((m) => {
445
+ const ts = Date.now();
446
+ if (m.role === "user") {
447
+ return { role: "user", content: m.content, timestamp: ts };
448
+ }
449
+ // For stored assistant messages we only have the text.
450
+ // Re-wrap as a minimal AssistantMessage with a single TextContent.
451
+ return {
452
+ role: "assistant",
453
+ content: [{ type: "text", text: m.content }],
454
+ api: "anthropic-messages",
455
+ provider: "anthropic",
456
+ model: "unknown",
457
+ usage: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, totalTokens: 0, cost: { input: 0, output: 0, cacheRead: 0, cacheWrite: 0, total: 0 } },
458
+ stopReason: "stop",
459
+ timestamp: ts,
460
+ };
461
+ });
462
+ }
463
+ /**
464
+ * Flatten the Agent's in-memory messages to plain `{ role, content }` pairs
465
+ * suitable for BookSession persistence.
466
+ */
467
+ function agentMessagesToPlain(messages) {
468
+ const out = [];
469
+ for (const msg of messages) {
470
+ if (!msg || typeof msg !== "object" || !("role" in msg))
471
+ continue;
472
+ const m = msg;
473
+ if (m.role === "user") {
474
+ const content = typeof m.content === "string"
475
+ ? m.content
476
+ : Array.isArray(m.content)
477
+ ? m.content
478
+ .filter((c) => c.type === "text")
479
+ .map((c) => c.text)
480
+ .join("")
481
+ : "";
482
+ if (content)
483
+ out.push({ role: "user", content });
484
+ }
485
+ else if (m.role === "assistant") {
486
+ const text = extractTextFromAssistant(m);
487
+ const thinking = extractThinkingFromAssistant(m);
488
+ if (text || thinking) {
489
+ const entry = { role: "assistant", content: text };
490
+ if (thinking)
491
+ entry.thinking = thinking;
492
+ out.push(entry);
493
+ }
494
+ }
495
+ // ToolResult messages are internal; skip them for persistence.
496
+ }
497
+ return out;
498
+ }
499
+ // ---------------------------------------------------------------------------
500
+ // Main entry point
501
+ // ---------------------------------------------------------------------------
502
+ /**
503
+ * 会创建/修改书籍与产物的生产工具。suppressProductionTools 为 true(同会话
504
+ * 有后台生产任务在运行)时从工具表剔除;read/grep/ls、research/material 与
505
+ * propose_action 保留——propose_action 引发的确认任务在 host 侧另有单任务闸门。
506
+ */
507
+ const PRODUCTION_MUTATION_TOOL_NAMES = new Set([
508
+ "sub_agent",
509
+ "generate_cover",
510
+ "write_truth_file",
511
+ "rename_entity",
512
+ "patch_chapter_text",
513
+ "replace_chapter_text",
514
+ "resync_chapter_state",
515
+ "delete_latest_chapter",
516
+ "import_chapters",
517
+ "fanfic_create",
518
+ "continuation_import",
519
+ "spinoff_create",
520
+ "imitation_create",
521
+ ]);
522
+ function createAgentToolsForMode(params) {
523
+ const tools = createModeTools(params);
524
+ return params.intentSkillTool ? [...tools, params.intentSkillTool] : tools;
525
+ }
526
+ function createModeTools(params) {
527
+ const lang = params.language === "en" ? "en" : "zh";
528
+ const subAgentTool = createSubAgentTool(params.pipeline, params.bookId, params.projectRoot, {
529
+ actionPayload: params.actionPayload,
530
+ language: lang,
531
+ activeSkills: params.activeSkills,
532
+ workerSkills: params.workerSkills,
533
+ });
534
+ const proposalTool = createProposeActionTool(lang, {
535
+ sameSession: params.sessionKind !== "chat",
536
+ requestedSkillIds: params.requestedSkillIds,
537
+ attachmentPaths: params.attachmentPaths,
538
+ });
539
+ const researchTool = createResearchWebTool(params.projectRoot);
540
+ const materialTool = createIngestMaterialTool(params.projectRoot);
541
+ const materialRetrievalTool = createRetrieveMaterialTool(params.projectRoot);
542
+ const projectReadTool = createReadTool(params.projectRoot, { scope: "project" });
543
+ const importChaptersTool = createImportChaptersTool(params.pipeline, params.bookId, params.projectRoot);
544
+ const isConfirmed = (intent) => {
545
+ return (params.actionSource === "button" || params.actionSource === "slash")
546
+ && params.requestedIntent === intent;
547
+ };
548
+ if (params.sessionKind === "chat") {
549
+ if (isConfirmed("translation_create")) {
550
+ return [createTranslationCreateTool(params.projectRoot, { actionPayload: params.actionPayload })];
551
+ }
552
+ if (isConfirmed("fanfic_init")) {
553
+ return [createFanficBookTool(params.pipeline, params.projectRoot, {
554
+ defaultSkills: params.productionSkills?.("longWriting"),
555
+ activeSkills: params.activeSkills,
556
+ })];
557
+ }
558
+ if (isConfirmed("continuation_import")) {
559
+ return [createContinuationImportTool(params.pipeline, params.bookId, params.projectRoot, {
560
+ defaultSkills: params.productionSkills?.("longWriting"),
561
+ activeSkills: params.activeSkills,
562
+ })];
563
+ }
564
+ if (isConfirmed("spinoff_create")) {
565
+ return [createSpinoffBookTool(params.pipeline, params.projectRoot, {
566
+ defaultSkills: params.productionSkills?.("longWriting"),
567
+ activeSkills: params.activeSkills,
568
+ })];
569
+ }
570
+ if (isConfirmed("style_imitation")) {
571
+ return [createImitationBookTool(params.pipeline, params.projectRoot, {
572
+ defaultSkills: params.productionSkills?.("longWriting"),
573
+ activeSkills: params.activeSkills,
574
+ })];
575
+ }
576
+ return [proposalTool, researchTool, materialTool, materialRetrievalTool, importChaptersTool];
577
+ }
578
+ if (params.sessionKind === "short") {
579
+ if (isConfirmed("short_run")) {
580
+ return [createShortFictionRunTool(params.pipeline, params.projectRoot, {
581
+ actionPayload: params.actionPayload,
582
+ language: lang,
583
+ defaultSkills: params.productionSkills?.("shortWriting"),
584
+ activeSkills: params.activeSkills,
585
+ })];
586
+ }
587
+ if (isConfirmed("generate_cover")) {
588
+ return [createGenerateCoverTool(params.projectRoot, { actionPayload: params.actionPayload })];
589
+ }
590
+ return [proposalTool, materialTool, materialRetrievalTool];
591
+ }
592
+ if (params.sessionKind === "script") {
593
+ if (isConfirmed("script_create")) {
594
+ return [createScriptCreationTool(params.pipeline, params.projectRoot, {
595
+ actionPayload: params.actionPayload,
596
+ language: lang,
597
+ defaultSkills: params.productionSkills?.("script"),
598
+ activeSkills: params.activeSkills,
599
+ })];
600
+ }
601
+ return [proposalTool, projectReadTool, materialTool, materialRetrievalTool];
602
+ }
603
+ if (params.sessionKind === "storyboard") {
604
+ if (isConfirmed("storyboard_create")) {
605
+ return [createStoryboardCreationTool(params.pipeline, params.projectRoot, {
606
+ actionPayload: params.actionPayload,
607
+ language: lang,
608
+ defaultSkills: params.productionSkills?.("storyboard"),
609
+ activeSkills: params.activeSkills,
610
+ })];
611
+ }
612
+ return [proposalTool, projectReadTool, materialTool, materialRetrievalTool];
613
+ }
614
+ if (params.sessionKind === "interactive-film") {
615
+ if (isConfirmed("interactive_film_create")) {
616
+ return [createInteractiveFilmCreationTool(params.pipeline, params.projectRoot, {
617
+ actionPayload: params.actionPayload,
618
+ language: lang,
619
+ defaultSkills: params.productionSkills?.("interactiveFilm"),
620
+ activeSkills: params.activeSkills,
621
+ })];
622
+ }
623
+ return [proposalTool, projectReadTool, materialTool, materialRetrievalTool];
624
+ }
625
+ if (params.sessionKind === "interactive-film-authoring") {
626
+ const projectId = params.bookId;
627
+ if (!projectId) {
628
+ throw new Error("interactive-film-authoring session requires a non-null bookId");
629
+ }
630
+ const agentCtx = params.pipeline.createAgentContext("film-authoring", projectId);
631
+ const llm = filmLLMDepsFromClient(agentCtx.client, agentCtx.model, {
632
+ activatedSkills: () => mergeActivatedSkillGuidance(params.productionSkills?.("interactiveFilm") ?? [], params.activeSkills?.() ?? []),
633
+ });
634
+ return createFilmAuthoringTools({
635
+ projectRoot: params.projectRoot,
636
+ projectId,
637
+ llm,
638
+ proposeActionTool: proposalTool,
639
+ confirmedIntent: params.requestedIntent,
640
+ language: lang,
641
+ });
642
+ }
643
+ if (params.sessionKind === "play") {
644
+ if (isConfirmed("play_start")) {
645
+ return [createPlayStartTool(params.pipeline, params.projectRoot, params.sessionId, params.playMode, {
646
+ actionPayload: params.actionPayload,
647
+ defaultSkills: params.productionSkills?.("play"),
648
+ activeSkills: params.activeSkills,
649
+ })];
650
+ }
651
+ if (params.playWorldExists) {
652
+ return [
653
+ createPlayEditTool(params.projectRoot, params.sessionId, lang),
654
+ createPlayReviseTool(params.pipeline, params.projectRoot, params.sessionId, {
655
+ language: lang,
656
+ defaultSkills: params.productionSkills?.("play"),
657
+ activeSkills: params.activeSkills,
658
+ }),
659
+ createPlayStepTool(params.pipeline, params.projectRoot, params.sessionId, {
660
+ language: lang,
661
+ defaultSkills: params.productionSkills?.("play"),
662
+ activeSkills: params.activeSkills,
663
+ }),
664
+ materialTool,
665
+ materialRetrievalTool,
666
+ ];
667
+ }
668
+ return [proposalTool, materialTool, materialRetrievalTool];
669
+ }
670
+ if (params.sessionKind === "book-create" && !params.bookId) {
671
+ if (isConfirmed("create_book")) {
672
+ return [createSubAgentTool(params.pipeline, params.bookId, params.projectRoot, {
673
+ actionPayload: params.actionPayload,
674
+ architectCreateOnly: true,
675
+ language: lang,
676
+ activeSkills: params.activeSkills,
677
+ workerSkills: params.workerSkills,
678
+ })];
679
+ }
680
+ return [proposalTool, researchTool, materialTool, materialRetrievalTool];
681
+ }
682
+ if (!params.bookId) {
683
+ return [];
684
+ }
685
+ const bookTools = [
686
+ subAgentTool,
687
+ createGenerateCoverTool(params.projectRoot, { actionPayload: params.actionPayload }),
688
+ createReadTool(params.projectRoot, { allowSystemPaths: params.allowSystemFileRead }),
689
+ createWriteTruthFileTool(params.pipeline, params.projectRoot, params.bookId),
690
+ createRenameEntityTool(params.pipeline, params.projectRoot, params.bookId),
691
+ createPatchChapterTextTool(params.pipeline, params.projectRoot, params.bookId),
692
+ createReplaceChapterTextTool(params.pipeline, params.projectRoot, params.bookId),
693
+ createResyncChapterStateTool(params.pipeline, params.bookId, {
694
+ language: lang,
695
+ defaultSkills: params.productionSkills?.("longWriting"),
696
+ activeSkills: params.activeSkills,
697
+ }),
698
+ createDeleteLatestChapterTool(params.projectRoot, params.bookId),
699
+ researchTool,
700
+ materialTool,
701
+ materialRetrievalTool,
702
+ createManageBookReferenceTool(params.projectRoot, params.bookId),
703
+ importChaptersTool,
704
+ createNarrativeForecastCreateTool(params.pipeline, params.bookId, params.projectRoot),
705
+ createNarrativeForecastGetTool(params.bookId, params.projectRoot),
706
+ createNarrativeForecastSelectTool(params.bookId, params.projectRoot),
707
+ createGrepTool(params.projectRoot),
708
+ createLsTool(params.projectRoot),
709
+ ];
710
+ if (params.sessionKind === "edit") {
711
+ // Edit mode stays deterministic: forecast create runs an LLM projection,
712
+ // and get/select belong to the planning workflow, not text editing.
713
+ return bookTools.filter((tool) => ![
714
+ "sub_agent",
715
+ "generate_cover",
716
+ "research_web",
717
+ "import_chapters",
718
+ "create_narrative_forecast",
719
+ "get_narrative_forecast",
720
+ "select_narrative_branch",
721
+ ].includes(tool.name));
722
+ }
723
+ return bookTools;
724
+ }
725
+ /**
726
+ * Run a single conversation turn within a cached Agent session.
727
+ *
728
+ * If the session already exists in the cache, reuses the Agent (with its full
729
+ * in-memory message history including tool calls). Otherwise creates a new
730
+ * Agent, optionally restoring messages from `initialMessages`.
731
+ */
732
+ export async function runAgentSession(config, userMessage, initialMessages) {
733
+ return runInAgentSessionQueue(config.projectRoot, config.sessionId, () => runAgentSessionUnlocked(config, userMessage, initialMessages));
734
+ }
735
+ async function runAgentSessionUnlocked(config, userMessage, initialMessages) {
736
+ const { sessionId, language, pipeline, projectRoot, onEvent, onContextCompression } = config;
737
+ // Normalize at the entry point so downstream comparisons, closures, and
738
+ // fs paths never see `undefined`. The type is already `string | null`, but
739
+ // some callers may bypass the type system (e.g. `activeBookId ?? null` gets
740
+ // skipped) and we don't want that to (a) throw in path.join or (b) trigger
741
+ // a spurious cache eviction because `null !== undefined`.
742
+ const bookId = config.bookId ? assertSafeBookId(config.bookId) : null;
743
+ const sessionKind = config.sessionKind ?? (bookId ? "book" : "chat");
744
+ const playMode = config.playMode;
745
+ const actionSource = config.actionSource ?? "free-text";
746
+ const requestedIntent = config.requestedIntent;
747
+ const actionPayload = config.actionPayload;
748
+ const actionPayloadKey = actionPayloadCacheKey(actionPayload);
749
+ const configuredSkills = await loadAvailableAgentSkills({ projectRoot });
750
+ const skillRegistry = createSkillRegistry({ skills: configuredSkills.skills });
751
+ const skillResolution = skillRegistry.resolveSkills({
752
+ requestedSkills: config.requestedSkills,
753
+ disabledSkills: config.disabledSkills,
754
+ });
755
+ const skillResolutionKey = skillResolutionCacheKey(skillResolution);
756
+ const model = resolveModel(config.model);
757
+ const requestedModelIdentity = agentModelIdentity(model);
758
+ const allowSystemFileRead = config.allowSystemFileRead ?? envFlagEnabled(process.env.INKOS_AGENT_ALLOW_SYSTEM_READ, false);
759
+ const suppressProductionTools = config.suppressProductionTools ?? false;
760
+ const playWorldExists = sessionKind === "play"
761
+ ? Boolean(await new PlayStore(projectRoot).loadWorld(sessionId))
762
+ : false;
763
+ const cacheKey = agentCacheKey(projectRoot, sessionId);
764
+ // ----- Resolve or create Agent -----
765
+ let cached = agentCache.get(cacheKey);
766
+ let currentCommittedSeq;
767
+ if (cached) {
768
+ currentCommittedSeq = await latestCommittedSeq(projectRoot, sessionId);
769
+ // Evict and rebuild if model protocol identity OR bookId changed. Both are
770
+ // captured into the Agent at construction time (model via initialState,
771
+ // bookId via closures in systemPrompt / tools / transformContext), so a
772
+ // mismatch means the cached Agent would keep using stale context.
773
+ const modelChanged = cached.modelIdentity !== requestedModelIdentity;
774
+ const projectRootChanged = cached.projectRoot !== projectRoot;
775
+ const bookChanged = cached.bookId !== bookId;
776
+ const sessionKindChanged = cached.sessionKind !== sessionKind;
777
+ const actionSourceChanged = cached.actionSource !== actionSource;
778
+ const requestedIntentChanged = cached.requestedIntent !== requestedIntent;
779
+ const actionPayloadChanged = cached.actionPayloadKey !== actionPayloadKey;
780
+ const skillResolutionChanged = cached.skillResolutionKey !== skillResolutionKey;
781
+ const languageChanged = cached.language !== language;
782
+ const apiKeyChanged = cached.apiKey !== config.apiKey;
783
+ const readPermissionChanged = cached.allowSystemFileRead !== allowSystemFileRead;
784
+ const playWorldChanged = cached.playWorldExists !== playWorldExists;
785
+ const backgroundTaskContextChanged = cached.backgroundTaskContext !== config.backgroundTaskContext;
786
+ const suppressProductionToolsChanged = cached.suppressProductionTools !== suppressProductionTools;
787
+ const transcriptChanged = cached.lastCommittedSeq !== currentCommittedSeq;
788
+ if (modelChanged ||
789
+ projectRootChanged ||
790
+ bookChanged ||
791
+ sessionKindChanged ||
792
+ actionSourceChanged ||
793
+ requestedIntentChanged ||
794
+ actionPayloadChanged ||
795
+ skillResolutionChanged ||
796
+ languageChanged ||
797
+ apiKeyChanged ||
798
+ readPermissionChanged ||
799
+ playWorldChanged ||
800
+ backgroundTaskContextChanged ||
801
+ suppressProductionToolsChanged ||
802
+ transcriptChanged) {
803
+ agentCache.delete(cacheKey);
804
+ cached = undefined;
805
+ }
806
+ }
807
+ if (!cached) {
808
+ const restoredHistory = await restoreAgentMessagesFromTranscript(projectRoot, sessionId, sessionKind);
809
+ if (restoredHistory.length > 0) {
810
+ onContextCompression?.({
811
+ category: "session_context",
812
+ phase: "start",
813
+ sources: ["session transcript"],
814
+ });
815
+ onContextCompression?.({
816
+ category: "session_context",
817
+ phase: "end",
818
+ sources: ["session transcript"],
819
+ });
820
+ }
821
+ const restoredMessages = appendRestoredHistoryBoundary(adaptRestoredAgentMessagesForModel(restoredHistory, model), language);
822
+ const initialAgentMessages = restoredMessages.length > 0
823
+ ? restoredMessages
824
+ : initialMessages && initialMessages.length > 0
825
+ ? plainToAgentMessages(initialMessages)
826
+ : [];
827
+ let terminalToolResultTail = false;
828
+ const turnSkills = new Map(skillResolution.usedSkills.map((skill) => [skill.id, { skill, resources: [] }]));
829
+ const productionSkills = (capability) => (resolveProductionSkillActivations(skillResolution.availableSkills, capability));
830
+ const allowIntentSkillSelection = actionSource === "free-text"
831
+ && skillResolution.forcedSkillIds.length === 0;
832
+ const baseSystemPrompt = buildAgentSystemPrompt(bookId, language, sessionKind, {
833
+ actionSource,
834
+ requestedIntent,
835
+ playWorldExists,
836
+ skills: skillResolution,
837
+ allowIntentSkillSelection,
838
+ });
839
+ const intentSkillTool = allowIntentSkillSelection
840
+ ? createUseSkillTool({
841
+ registry: skillRegistry,
842
+ disabledSkillIds: skillResolution.disabledSkillIds,
843
+ onActivate: (activation) => turnSkills.set(activation.skill.id, activation),
844
+ })
845
+ : undefined;
846
+ const agentTools = createAgentToolsForMode({
847
+ pipeline,
848
+ bookId,
849
+ sessionId,
850
+ sessionKind,
851
+ actionSource,
852
+ requestedIntent,
853
+ actionPayload,
854
+ projectRoot,
855
+ allowSystemFileRead,
856
+ language,
857
+ playMode,
858
+ playWorldExists,
859
+ intentSkillTool,
860
+ requestedSkillIds: () => [...turnSkills.keys()],
861
+ attachmentPaths: () => cached?.currentAttachmentPaths ?? [],
862
+ activeSkills: () => [...turnSkills.values()],
863
+ workerSkills: (agent) => {
864
+ if (agent === "architect" || agent === "writer")
865
+ return productionSkills("longWriting");
866
+ if (agent === "auditor" || agent === "reviser")
867
+ return productionSkills("longReview");
868
+ return [];
869
+ },
870
+ productionSkills,
871
+ });
872
+ const agent = new Agent({
873
+ initialState: {
874
+ model,
875
+ systemPrompt: config.backgroundTaskContext
876
+ ? `${baseSystemPrompt}\n\n${config.backgroundTaskContext}`
877
+ : baseSystemPrompt,
878
+ tools: suppressProductionTools
879
+ ? agentTools.filter((tool) => !PRODUCTION_MUTATION_TOOL_NAMES.has(tool.name))
880
+ : agentTools,
881
+ messages: initialAgentMessages,
882
+ },
883
+ transformContext: sessionKind === "interactive-film-authoring" && bookId
884
+ ? createInteractiveFilmContextTransform(bookId, projectRoot)
885
+ : createBookContextTransform(bookId, projectRoot, { onContextCompression }),
886
+ convertToLlm: (messages) => {
887
+ terminalToolResultTail = hasUnansweredTerminalToolResult(messages);
888
+ return convertAgentMessagesForModel(messages, model);
889
+ },
890
+ streamFn: (streamModel, context, options) => {
891
+ if (terminalToolResultTail) {
892
+ terminalToolResultTail = false;
893
+ return localAssistantStopStream(streamModel);
894
+ }
895
+ if (isLlmStubEnabled())
896
+ return stubAgentStream(streamModel, context);
897
+ return guardedPiStream(streamModel, context, options);
898
+ },
899
+ getApiKey: (provider) => {
900
+ if (config.apiKey)
901
+ return config.apiKey;
902
+ return getEnvApiKey(provider);
903
+ },
904
+ });
905
+ cached = {
906
+ agent,
907
+ sessionId,
908
+ projectRoot,
909
+ bookId,
910
+ sessionKind,
911
+ actionSource,
912
+ requestedIntent,
913
+ actionPayloadKey,
914
+ skillResolutionKey,
915
+ turnSkills,
916
+ playWorldExists,
917
+ language,
918
+ modelIdentity: requestedModelIdentity,
919
+ apiKey: config.apiKey,
920
+ allowSystemFileRead,
921
+ backgroundTaskContext: config.backgroundTaskContext,
922
+ suppressProductionTools,
923
+ currentAttachmentPaths: (config.attachments ?? [])
924
+ .map((attachment) => attachment.storedPath?.trim())
925
+ .filter((path) => Boolean(path)),
926
+ lastCommittedSeq: currentCommittedSeq ?? await latestCommittedSeq(projectRoot, sessionId),
927
+ lastActive: Date.now(),
928
+ };
929
+ agentCache.set(cacheKey, cached);
930
+ ensureCleanupTimer();
931
+ }
932
+ cached.lastActive = Date.now();
933
+ cached.currentAttachmentPaths = (config.attachments ?? [])
934
+ .map((attachment) => attachment.storedPath?.trim())
935
+ .filter((path) => Boolean(path));
936
+ cached.turnSkills.clear();
937
+ for (const skill of skillResolution.usedSkills) {
938
+ cached.turnSkills.set(skill.id, { skill, resources: [] });
939
+ }
940
+ const { agent } = cached;
941
+ const attachmentBlock = buildAttachmentUserBlock(config.attachments, language);
942
+ const promptMessage = attachmentBlock ? `${userMessage}${attachmentBlock}` : userMessage;
943
+ const promptImages = attachmentImages(config.attachments);
944
+ // ----- Prepare transcript persistence -----
945
+ const requestId = randomUUID();
946
+ await ensureSessionCreatedEvent(projectRoot, sessionId, bookId, sessionKind);
947
+ await appendAgentTranscriptEvent(projectRoot, sessionId, (seq) => ({
948
+ type: "request_started",
949
+ version: 1,
950
+ sessionId,
951
+ requestId,
952
+ seq,
953
+ timestamp: Date.now(),
954
+ sessionKind,
955
+ input: promptMessage,
956
+ }));
957
+ let parentUuid = null;
958
+ let piTurnIndex = 0;
959
+ let lastAssistantUuid = null;
960
+ let skillTurnActive = cached.turnSkills.size > 0;
961
+ const persistAgentEvent = async (event) => {
962
+ if (event.type === "turn_start") {
963
+ piTurnIndex += 1;
964
+ return;
965
+ }
966
+ if (event.type !== "message_end")
967
+ return;
968
+ const role = transcriptRoleForMessage(event.message);
969
+ if (!role)
970
+ return;
971
+ if (assistantInvokesSkill(event.message))
972
+ skillTurnActive = true;
973
+ const persistedMessage = sanitizeSkillTurnMessage(event.message, skillTurnActive);
974
+ const uuid = randomUUID();
975
+ const isToolResult = role === "toolResult";
976
+ const toolCallId = toolCallIdForMessage(event.message);
977
+ await appendAgentTranscriptEvent(projectRoot, sessionId, (seq) => ({
978
+ type: "message",
979
+ version: 1,
980
+ sessionId,
981
+ requestId,
982
+ uuid,
983
+ parentUuid: isToolResult && lastAssistantUuid ? lastAssistantUuid : parentUuid,
984
+ seq,
985
+ role,
986
+ timestamp: messageTimestamp(event.message),
987
+ piTurnIndex,
988
+ ...(toolCallId ? { toolCallId } : {}),
989
+ ...(isToolResult && lastAssistantUuid
990
+ ? { sourceToolAssistantUuid: lastAssistantUuid }
991
+ : {}),
992
+ message: persistedMessage,
993
+ }));
994
+ if (role === "assistant")
995
+ lastAssistantUuid = uuid;
996
+ parentUuid = uuid;
997
+ };
998
+ // ----- Subscribe to events (transcript persistence + SSE forwarding) -----
999
+ const unsubscribe = agent.subscribe(async (event) => {
1000
+ await persistAgentEvent(event);
1001
+ onEvent?.(event);
1002
+ });
1003
+ // ----- Execute the turn -----
1004
+ let finalAssistant;
1005
+ let errorMessage;
1006
+ const turnMessageStartIndex = agent.state.messages.length;
1007
+ try {
1008
+ await runWithAgentTrajectory({
1009
+ conversationId: opaqueConversationId(sessionId),
1010
+ runId: requestId,
1011
+ agentRole: "main",
1012
+ }, async () => {
1013
+ if (promptImages.length > 0) {
1014
+ await agent.prompt(promptMessage, promptImages);
1015
+ }
1016
+ else {
1017
+ await agent.prompt(promptMessage);
1018
+ }
1019
+ });
1020
+ finalAssistant = lastAssistantMessage(agent.state.messages);
1021
+ agent.state.messages = agent.state.messages.map((message, index) => (sanitizeSkillTurnMessage(message, skillTurnActive && index >= turnMessageStartIndex)));
1022
+ errorMessage = assistantErrorMessage(finalAssistant);
1023
+ if (errorMessage) {
1024
+ const failedError = errorMessage;
1025
+ await appendAgentTranscriptEvent(projectRoot, sessionId, (seq) => ({
1026
+ type: "request_failed",
1027
+ version: 1,
1028
+ sessionId,
1029
+ requestId,
1030
+ seq,
1031
+ timestamp: Date.now(),
1032
+ error: failedError,
1033
+ }));
1034
+ agentCache.delete(cacheKey);
1035
+ }
1036
+ else {
1037
+ const committed = await appendAgentTranscriptEvent(projectRoot, sessionId, (seq) => ({
1038
+ type: "request_committed",
1039
+ version: 1,
1040
+ sessionId,
1041
+ requestId,
1042
+ seq,
1043
+ timestamp: Date.now(),
1044
+ }));
1045
+ cached.lastCommittedSeq = committed.seq;
1046
+ }
1047
+ }
1048
+ catch (error) {
1049
+ await appendAgentTranscriptEvent(projectRoot, sessionId, (seq) => ({
1050
+ type: "request_failed",
1051
+ version: 1,
1052
+ sessionId,
1053
+ requestId,
1054
+ seq,
1055
+ timestamp: Date.now(),
1056
+ error: error instanceof Error ? error.message : String(error),
1057
+ }));
1058
+ agentCache.delete(cacheKey);
1059
+ throw error;
1060
+ }
1061
+ finally {
1062
+ unsubscribe();
1063
+ }
1064
+ // ----- Extract result -----
1065
+ const allMessages = agent.state.messages;
1066
+ finalAssistant ??= lastAssistantMessage(allMessages);
1067
+ const responseText = finalAssistant ? extractTextFromAssistant(finalAssistant) : "";
1068
+ errorMessage ??= assistantErrorMessage(finalAssistant);
1069
+ return {
1070
+ responseText,
1071
+ messages: allMessages.slice(),
1072
+ ...(errorMessage ? { errorMessage } : {}),
1073
+ };
1074
+ }
1075
+ // ---------------------------------------------------------------------------
1076
+ // Cache management
1077
+ // ---------------------------------------------------------------------------
1078
+ /** Manually evict a cached Agent session. */
1079
+ export function evictAgentCache(sessionId) {
1080
+ let deleted = agentCache.delete(sessionId);
1081
+ for (const [key, entry] of agentCache) {
1082
+ if (entry.sessionId !== sessionId)
1083
+ continue;
1084
+ agentCache.delete(key);
1085
+ deleted = true;
1086
+ }
1087
+ return deleted;
1088
+ }
1089
+ /** Abort an active cached pi-agent session and evict it from cache. */
1090
+ export function abortAgentSession(projectRoot, sessionId) {
1091
+ let aborted = false;
1092
+ for (const [key, entry] of agentCache) {
1093
+ if (entry.projectRoot !== projectRoot || entry.sessionId !== sessionId)
1094
+ continue;
1095
+ entry.agent.abort();
1096
+ entry.agent.clearAllQueues?.();
1097
+ agentCache.delete(key);
1098
+ aborted = true;
1099
+ }
1100
+ return aborted;
1101
+ }
1102
+ //# sourceMappingURL=agent-session.js.map