@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.
- package/LICENSE +661 -0
- package/dist/agent/agent-session.d.ts +100 -0
- package/dist/agent/agent-session.d.ts.map +1 -0
- package/dist/agent/agent-session.js +1102 -0
- package/dist/agent/agent-session.js.map +1 -0
- package/dist/agent/agent-system-prompt.d.ts +12 -0
- package/dist/agent/agent-system-prompt.d.ts.map +1 -0
- package/dist/agent/agent-system-prompt.js +596 -0
- package/dist/agent/agent-system-prompt.js.map +1 -0
- package/dist/agent/agent-tools.d.ts +508 -0
- package/dist/agent/agent-tools.d.ts.map +1 -0
- package/dist/agent/agent-tools.js +3083 -0
- package/dist/agent/agent-tools.js.map +1 -0
- package/dist/agent/chapter-import-source.d.ts +16 -0
- package/dist/agent/chapter-import-source.d.ts.map +1 -0
- package/dist/agent/chapter-import-source.js +48 -0
- package/dist/agent/chapter-import-source.js.map +1 -0
- package/dist/agent/context-transform.d.ts +13 -0
- package/dist/agent/context-transform.d.ts.map +1 -0
- package/dist/agent/context-transform.js +183 -0
- package/dist/agent/context-transform.js.map +1 -0
- package/dist/agent/film-authoring-tools.d.ts +98 -0
- package/dist/agent/film-authoring-tools.d.ts.map +1 -0
- package/dist/agent/film-authoring-tools.js +405 -0
- package/dist/agent/film-authoring-tools.js.map +1 -0
- package/dist/agent/forecast-tools.d.ts +22 -0
- package/dist/agent/forecast-tools.d.ts.map +1 -0
- package/dist/agent/forecast-tools.js +153 -0
- package/dist/agent/forecast-tools.js.map +1 -0
- package/dist/agent/index.d.ts +8 -0
- package/dist/agent/index.d.ts.map +1 -0
- package/dist/agent/index.js +8 -0
- package/dist/agent/index.js.map +1 -0
- package/dist/agent/llm-stub.d.ts +19 -0
- package/dist/agent/llm-stub.d.ts.map +1 -0
- package/dist/agent/llm-stub.js +134 -0
- package/dist/agent/llm-stub.js.map +1 -0
- package/dist/agent/pi-stream.d.ts +8 -0
- package/dist/agent/pi-stream.d.ts.map +1 -0
- package/dist/agent/pi-stream.js +31 -0
- package/dist/agent/pi-stream.js.map +1 -0
- package/dist/agent/skill-tool.d.ts +42 -0
- package/dist/agent/skill-tool.d.ts.map +1 -0
- package/dist/agent/skill-tool.js +279 -0
- package/dist/agent/skill-tool.js.map +1 -0
- package/dist/agent/worker-agent.d.ts +24 -0
- package/dist/agent/worker-agent.d.ts.map +1 -0
- package/dist/agent/worker-agent.js +288 -0
- package/dist/agent/worker-agent.js.map +1 -0
- package/dist/agents/ai-tells.d.ts +26 -0
- package/dist/agents/ai-tells.d.ts.map +1 -0
- package/dist/agents/ai-tells.js +140 -0
- package/dist/agents/ai-tells.js.map +1 -0
- package/dist/agents/architect.d.ts +78 -0
- package/dist/agents/architect.d.ts.map +1 -0
- package/dist/agents/architect.js +1184 -0
- package/dist/agents/architect.js.map +1 -0
- package/dist/agents/base.d.ts +42 -0
- package/dist/agents/base.d.ts.map +1 -0
- package/dist/agents/base.js +123 -0
- package/dist/agents/base.js.map +1 -0
- package/dist/agents/chapter-analyzer.d.ts +30 -0
- package/dist/agents/chapter-analyzer.d.ts.map +1 -0
- package/dist/agents/chapter-analyzer.js +509 -0
- package/dist/agents/chapter-analyzer.js.map +1 -0
- package/dist/agents/composer.d.ts +67 -0
- package/dist/agents/composer.d.ts.map +1 -0
- package/dist/agents/composer.js +936 -0
- package/dist/agents/composer.js.map +1 -0
- package/dist/agents/consolidator.d.ts +39 -0
- package/dist/agents/consolidator.d.ts.map +1 -0
- package/dist/agents/consolidator.js +179 -0
- package/dist/agents/consolidator.js.map +1 -0
- package/dist/agents/continuity.d.ts +45 -0
- package/dist/agents/continuity.d.ts.map +1 -0
- package/dist/agents/continuity.js +722 -0
- package/dist/agents/continuity.js.map +1 -0
- package/dist/agents/detection-insights.d.ts +9 -0
- package/dist/agents/detection-insights.d.ts.map +1 -0
- package/dist/agents/detection-insights.js +54 -0
- package/dist/agents/detection-insights.js.map +1 -0
- package/dist/agents/detector.d.ts +17 -0
- package/dist/agents/detector.d.ts.map +1 -0
- package/dist/agents/detector.js +77 -0
- package/dist/agents/detector.js.map +1 -0
- package/dist/agents/en-prompt-sections.d.ts +4 -0
- package/dist/agents/en-prompt-sections.d.ts.map +1 -0
- package/dist/agents/en-prompt-sections.js +9 -0
- package/dist/agents/en-prompt-sections.js.map +1 -0
- package/dist/agents/fanfic-canon-importer.d.ts +16 -0
- package/dist/agents/fanfic-canon-importer.d.ts.map +1 -0
- package/dist/agents/fanfic-canon-importer.js +164 -0
- package/dist/agents/fanfic-canon-importer.js.map +1 -0
- package/dist/agents/fanfic-dimensions.d.ts +14 -0
- package/dist/agents/fanfic-dimensions.d.ts.map +1 -0
- package/dist/agents/fanfic-dimensions.js +63 -0
- package/dist/agents/fanfic-dimensions.js.map +1 -0
- package/dist/agents/fanfic-prompt-sections.d.ts +5 -0
- package/dist/agents/fanfic-prompt-sections.d.ts.map +1 -0
- package/dist/agents/fanfic-prompt-sections.js +85 -0
- package/dist/agents/fanfic-prompt-sections.js.map +1 -0
- package/dist/agents/foundation-reviewer.d.ts +34 -0
- package/dist/agents/foundation-reviewer.d.ts.map +1 -0
- package/dist/agents/foundation-reviewer.js +174 -0
- package/dist/agents/foundation-reviewer.js.map +1 -0
- package/dist/agents/observer-prompts.d.ts +10 -0
- package/dist/agents/observer-prompts.d.ts.map +1 -0
- package/dist/agents/observer-prompts.js +113 -0
- package/dist/agents/observer-prompts.js.map +1 -0
- package/dist/agents/planner-context.d.ts +53 -0
- package/dist/agents/planner-context.d.ts.map +1 -0
- package/dist/agents/planner-context.js +238 -0
- package/dist/agents/planner-context.js.map +1 -0
- package/dist/agents/planner-prompts.d.ts +45 -0
- package/dist/agents/planner-prompts.d.ts.map +1 -0
- package/dist/agents/planner-prompts.js +391 -0
- package/dist/agents/planner-prompts.js.map +1 -0
- package/dist/agents/planner.d.ts +90 -0
- package/dist/agents/planner.d.ts.map +1 -0
- package/dist/agents/planner.js +715 -0
- package/dist/agents/planner.js.map +1 -0
- package/dist/agents/polisher.d.ts +33 -0
- package/dist/agents/polisher.d.ts.map +1 -0
- package/dist/agents/polisher.js +122 -0
- package/dist/agents/polisher.js.map +1 -0
- package/dist/agents/post-write-validator.d.ts +35 -0
- package/dist/agents/post-write-validator.d.ts.map +1 -0
- package/dist/agents/post-write-validator.js +758 -0
- package/dist/agents/post-write-validator.js.map +1 -0
- package/dist/agents/radar-source.d.ts +38 -0
- package/dist/agents/radar-source.d.ts.map +1 -0
- package/dist/agents/radar-source.js +92 -0
- package/dist/agents/radar-source.js.map +1 -0
- package/dist/agents/radar.d.ts +24 -0
- package/dist/agents/radar.d.ts.map +1 -0
- package/dist/agents/radar.js +85 -0
- package/dist/agents/radar.js.map +1 -0
- package/dist/agents/researcher.d.ts +38 -0
- package/dist/agents/researcher.d.ts.map +1 -0
- package/dist/agents/researcher.js +164 -0
- package/dist/agents/researcher.js.map +1 -0
- package/dist/agents/reviser.d.ts +35 -0
- package/dist/agents/reviser.d.ts.map +1 -0
- package/dist/agents/reviser.js +496 -0
- package/dist/agents/reviser.js.map +1 -0
- package/dist/agents/rules-reader.d.ts +32 -0
- package/dist/agents/rules-reader.d.ts.map +1 -0
- package/dist/agents/rules-reader.js +129 -0
- package/dist/agents/rules-reader.js.map +1 -0
- package/dist/agents/script-storyboard.d.ts +66 -0
- package/dist/agents/script-storyboard.d.ts.map +1 -0
- package/dist/agents/script-storyboard.js +657 -0
- package/dist/agents/script-storyboard.js.map +1 -0
- package/dist/agents/sensitive-words.d.ts +24 -0
- package/dist/agents/sensitive-words.d.ts.map +1 -0
- package/dist/agents/sensitive-words.js +103 -0
- package/dist/agents/sensitive-words.js.map +1 -0
- package/dist/agents/settler-delta-parser.d.ts +7 -0
- package/dist/agents/settler-delta-parser.d.ts.map +1 -0
- package/dist/agents/settler-delta-parser.js +40 -0
- package/dist/agents/settler-delta-parser.js.map +1 -0
- package/dist/agents/settler-parser.d.ts +13 -0
- package/dist/agents/settler-parser.d.ts.map +1 -0
- package/dist/agents/settler-parser.js +20 -0
- package/dist/agents/settler-parser.js.map +1 -0
- package/dist/agents/settler-prompts.d.ts +22 -0
- package/dist/agents/settler-prompts.d.ts.map +1 -0
- package/dist/agents/settler-prompts.js +195 -0
- package/dist/agents/settler-prompts.js.map +1 -0
- package/dist/agents/short-fiction.d.ts +120 -0
- package/dist/agents/short-fiction.d.ts.map +1 -0
- package/dist/agents/short-fiction.js +353 -0
- package/dist/agents/short-fiction.js.map +1 -0
- package/dist/agents/state-validator.d.ts +33 -0
- package/dist/agents/state-validator.d.ts.map +1 -0
- package/dist/agents/state-validator.js +262 -0
- package/dist/agents/state-validator.js.map +1 -0
- package/dist/agents/style-analyzer.d.ts +11 -0
- package/dist/agents/style-analyzer.d.ts.map +1 -0
- package/dist/agents/style-analyzer.js +98 -0
- package/dist/agents/style-analyzer.js.map +1 -0
- package/dist/agents/writer-parser.d.ts +17 -0
- package/dist/agents/writer-parser.d.ts.map +1 -0
- package/dist/agents/writer-parser.js +131 -0
- package/dist/agents/writer-parser.js.map +1 -0
- package/dist/agents/writer-prompts.d.ts +12 -0
- package/dist/agents/writer-prompts.d.ts.map +1 -0
- package/dist/agents/writer-prompts.js +495 -0
- package/dist/agents/writer-prompts.js.map +1 -0
- package/dist/agents/writer.d.ts +102 -0
- package/dist/agents/writer.d.ts.map +1 -0
- package/dist/agents/writer.js +882 -0
- package/dist/agents/writer.js.map +1 -0
- package/dist/forecast/agent.d.ts +22 -0
- package/dist/forecast/agent.d.ts.map +1 -0
- package/dist/forecast/agent.js +48 -0
- package/dist/forecast/agent.js.map +1 -0
- package/dist/forecast/context-builder.d.ts +35 -0
- package/dist/forecast/context-builder.d.ts.map +1 -0
- package/dist/forecast/context-builder.js +214 -0
- package/dist/forecast/context-builder.js.map +1 -0
- package/dist/forecast/prompts.d.ts +12 -0
- package/dist/forecast/prompts.d.ts.map +1 -0
- package/dist/forecast/prompts.js +114 -0
- package/dist/forecast/prompts.js.map +1 -0
- package/dist/forecast/render.d.ts +9 -0
- package/dist/forecast/render.d.ts.map +1 -0
- package/dist/forecast/render.js +154 -0
- package/dist/forecast/render.js.map +1 -0
- package/dist/forecast/runner.d.ts +51 -0
- package/dist/forecast/runner.d.ts.map +1 -0
- package/dist/forecast/runner.js +115 -0
- package/dist/forecast/runner.js.map +1 -0
- package/dist/forecast/schema.d.ts +767 -0
- package/dist/forecast/schema.d.ts.map +1 -0
- package/dist/forecast/schema.js +115 -0
- package/dist/forecast/schema.js.map +1 -0
- package/dist/forecast/store.d.ts +32 -0
- package/dist/forecast/store.d.ts.map +1 -0
- package/dist/forecast/store.js +129 -0
- package/dist/forecast/store.js.map +1 -0
- package/dist/index.d.ts +160 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +172 -0
- package/dist/index.js.map +1 -0
- package/dist/interaction/action-envelope.d.ts +1493 -0
- package/dist/interaction/action-envelope.d.ts.map +1 -0
- package/dist/interaction/action-envelope.js +257 -0
- package/dist/interaction/action-envelope.js.map +1 -0
- package/dist/interaction/book-session-store.d.ts +29 -0
- package/dist/interaction/book-session-store.d.ts.map +1 -0
- package/dist/interaction/book-session-store.js +185 -0
- package/dist/interaction/book-session-store.js.map +1 -0
- package/dist/interaction/draft-directive-parser.d.ts +38 -0
- package/dist/interaction/draft-directive-parser.d.ts.map +1 -0
- package/dist/interaction/draft-directive-parser.js +208 -0
- package/dist/interaction/draft-directive-parser.js.map +1 -0
- package/dist/interaction/edit-controller.d.ts +62 -0
- package/dist/interaction/edit-controller.d.ts.map +1 -0
- package/dist/interaction/edit-controller.js +381 -0
- package/dist/interaction/edit-controller.js.map +1 -0
- package/dist/interaction/events.d.ts +45 -0
- package/dist/interaction/events.d.ts.map +1 -0
- package/dist/interaction/events.js +32 -0
- package/dist/interaction/events.js.map +1 -0
- package/dist/interaction/export-artifact.d.ts +32 -0
- package/dist/interaction/export-artifact.d.ts.map +1 -0
- package/dist/interaction/export-artifact.js +103 -0
- package/dist/interaction/export-artifact.js.map +1 -0
- package/dist/interaction/intents.d.ts +99 -0
- package/dist/interaction/intents.d.ts.map +1 -0
- package/dist/interaction/intents.js +59 -0
- package/dist/interaction/intents.js.map +1 -0
- package/dist/interaction/modes.d.ts +5 -0
- package/dist/interaction/modes.d.ts.map +1 -0
- package/dist/interaction/modes.js +7 -0
- package/dist/interaction/modes.js.map +1 -0
- package/dist/interaction/project-control.d.ts +45 -0
- package/dist/interaction/project-control.d.ts.map +1 -0
- package/dist/interaction/project-control.js +71 -0
- package/dist/interaction/project-control.js.map +1 -0
- package/dist/interaction/project-session-store.d.ts +9 -0
- package/dist/interaction/project-session-store.d.ts.map +1 -0
- package/dist/interaction/project-session-store.js +64 -0
- package/dist/interaction/project-session-store.js.map +1 -0
- package/dist/interaction/project-tools.d.ts +23 -0
- package/dist/interaction/project-tools.d.ts.map +1 -0
- package/dist/interaction/project-tools.js +408 -0
- package/dist/interaction/project-tools.js.map +1 -0
- package/dist/interaction/request-router.d.ts +3 -0
- package/dist/interaction/request-router.d.ts.map +1 -0
- package/dist/interaction/request-router.js +5 -0
- package/dist/interaction/request-router.js.map +1 -0
- package/dist/interaction/runtime.d.ts +54 -0
- package/dist/interaction/runtime.d.ts.map +1 -0
- package/dist/interaction/runtime.js +919 -0
- package/dist/interaction/runtime.js.map +1 -0
- package/dist/interaction/session-transcript-legacy.d.ts +4 -0
- package/dist/interaction/session-transcript-legacy.d.ts.map +1 -0
- package/dist/interaction/session-transcript-legacy.js +102 -0
- package/dist/interaction/session-transcript-legacy.js.map +1 -0
- package/dist/interaction/session-transcript-restore.d.ts +18 -0
- package/dist/interaction/session-transcript-restore.d.ts.map +1 -0
- package/dist/interaction/session-transcript-restore.js +746 -0
- package/dist/interaction/session-transcript-restore.js.map +1 -0
- package/dist/interaction/session-transcript-schema.d.ts +435 -0
- package/dist/interaction/session-transcript-schema.d.ts.map +1 -0
- package/dist/interaction/session-transcript-schema.js +65 -0
- package/dist/interaction/session-transcript-schema.js.map +1 -0
- package/dist/interaction/session-transcript.d.ts +21 -0
- package/dist/interaction/session-transcript.d.ts.map +1 -0
- package/dist/interaction/session-transcript.js +164 -0
- package/dist/interaction/session-transcript.js.map +1 -0
- package/dist/interaction/session.d.ts +1194 -0
- package/dist/interaction/session.d.ts.map +1 -0
- package/dist/interaction/session.js +194 -0
- package/dist/interaction/session.js.map +1 -0
- package/dist/interaction/truth-authority.d.ts +4 -0
- package/dist/interaction/truth-authority.d.ts.map +1 -0
- package/dist/interaction/truth-authority.js +37 -0
- package/dist/interaction/truth-authority.js.map +1 -0
- package/dist/interactive-film/authoring-store.d.ts +35 -0
- package/dist/interactive-film/authoring-store.d.ts.map +1 -0
- package/dist/interactive-film/authoring-store.js +114 -0
- package/dist/interactive-film/authoring-store.js.map +1 -0
- package/dist/interactive-film/authoring-tools.d.ts +9 -0
- package/dist/interactive-film/authoring-tools.d.ts.map +1 -0
- package/dist/interactive-film/authoring-tools.js +19 -0
- package/dist/interactive-film/authoring-tools.js.map +1 -0
- package/dist/interactive-film/delta.d.ts +591 -0
- package/dist/interactive-film/delta.d.ts.map +1 -0
- package/dist/interactive-film/delta.js +54 -0
- package/dist/interactive-film/delta.js.map +1 -0
- package/dist/interactive-film/emotion.d.ts +20 -0
- package/dist/interactive-film/emotion.d.ts.map +1 -0
- package/dist/interactive-film/emotion.js +57 -0
- package/dist/interactive-film/emotion.js.map +1 -0
- package/dist/interactive-film/evaluator.d.ts +7 -0
- package/dist/interactive-film/evaluator.d.ts.map +1 -0
- package/dist/interactive-film/evaluator.js +40 -0
- package/dist/interactive-film/evaluator.js.map +1 -0
- package/dist/interactive-film/export-html.d.ts +6 -0
- package/dist/interactive-film/export-html.d.ts.map +1 -0
- package/dist/interactive-film/export-html.js +84 -0
- package/dist/interactive-film/export-html.js.map +1 -0
- package/dist/interactive-film/export-ink.d.ts +3 -0
- package/dist/interactive-film/export-ink.d.ts.map +1 -0
- package/dist/interactive-film/export-ink.js +51 -0
- package/dist/interactive-film/export-ink.js.map +1 -0
- package/dist/interactive-film/film-context.d.ts +4 -0
- package/dist/interactive-film/film-context.d.ts.map +1 -0
- package/dist/interactive-film/film-context.js +30 -0
- package/dist/interactive-film/film-context.js.map +1 -0
- package/dist/interactive-film/generate.d.ts +15 -0
- package/dist/interactive-film/generate.d.ts.map +1 -0
- package/dist/interactive-film/generate.js +51 -0
- package/dist/interactive-film/generate.js.map +1 -0
- package/dist/interactive-film/graph-schema.d.ts +819 -0
- package/dist/interactive-film/graph-schema.d.ts.map +1 -0
- package/dist/interactive-film/graph-schema.js +84 -0
- package/dist/interactive-film/graph-schema.js.map +1 -0
- package/dist/interactive-film/graph-store.d.ts +5 -0
- package/dist/interactive-film/graph-store.d.ts.map +1 -0
- package/dist/interactive-film/graph-store.js +24 -0
- package/dist/interactive-film/graph-store.js.map +1 -0
- package/dist/interactive-film/memory-link.d.ts +9 -0
- package/dist/interactive-film/memory-link.d.ts.map +1 -0
- package/dist/interactive-film/memory-link.js +15 -0
- package/dist/interactive-film/memory-link.js.map +1 -0
- package/dist/interactive-film/node-image.d.ts +29 -0
- package/dist/interactive-film/node-image.d.ts.map +1 -0
- package/dist/interactive-film/node-image.js +52 -0
- package/dist/interactive-film/node-image.js.map +1 -0
- package/dist/interactive-film/paths.d.ts +14 -0
- package/dist/interactive-film/paths.d.ts.map +1 -0
- package/dist/interactive-film/paths.js +60 -0
- package/dist/interactive-film/paths.js.map +1 -0
- package/dist/interactive-film/tool-schemas.d.ts +182 -0
- package/dist/interactive-film/tool-schemas.d.ts.map +1 -0
- package/dist/interactive-film/tool-schemas.js +125 -0
- package/dist/interactive-film/tool-schemas.js.map +1 -0
- package/dist/interactive-film/validation.d.ts +14 -0
- package/dist/interactive-film/validation.d.ts.map +1 -0
- package/dist/interactive-film/validation.js +292 -0
- package/dist/interactive-film/validation.js.map +1 -0
- package/dist/llm/agent-trajectory.d.ts +27 -0
- package/dist/llm/agent-trajectory.d.ts.map +1 -0
- package/dist/llm/agent-trajectory.js +74 -0
- package/dist/llm/agent-trajectory.js.map +1 -0
- package/dist/llm/config-migration.d.ts +5 -0
- package/dist/llm/config-migration.d.ts.map +1 -0
- package/dist/llm/config-migration.js +51 -0
- package/dist/llm/config-migration.js.map +1 -0
- package/dist/llm/cover-providers.d.ts +14 -0
- package/dist/llm/cover-providers.d.ts.map +1 -0
- package/dist/llm/cover-providers.js +51 -0
- package/dist/llm/cover-providers.js.map +1 -0
- package/dist/llm/long-form-completion.d.ts +16 -0
- package/dist/llm/long-form-completion.d.ts.map +1 -0
- package/dist/llm/long-form-completion.js +62 -0
- package/dist/llm/long-form-completion.js.map +1 -0
- package/dist/llm/provider.d.ts +110 -0
- package/dist/llm/provider.d.ts.map +1 -0
- package/dist/llm/provider.js +1405 -0
- package/dist/llm/provider.js.map +1 -0
- package/dist/llm/providers/endpoints/ai360.d.ts +10 -0
- package/dist/llm/providers/endpoints/ai360.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/ai360.js +34 -0
- package/dist/llm/providers/endpoints/ai360.js.map +1 -0
- package/dist/llm/providers/endpoints/anthropic.d.ts +12 -0
- package/dist/llm/providers/endpoints/anthropic.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/anthropic.js +72 -0
- package/dist/llm/providers/endpoints/anthropic.js.map +1 -0
- package/dist/llm/providers/endpoints/astronCodingPlan.d.ts +16 -0
- package/dist/llm/providers/endpoints/astronCodingPlan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/astronCodingPlan.js +16 -0
- package/dist/llm/providers/endpoints/astronCodingPlan.js.map +1 -0
- package/dist/llm/providers/endpoints/baichuan.d.ts +10 -0
- package/dist/llm/providers/endpoints/baichuan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/baichuan.js +20 -0
- package/dist/llm/providers/endpoints/baichuan.js.map +1 -0
- package/dist/llm/providers/endpoints/bailian.d.ts +25 -0
- package/dist/llm/providers/endpoints/bailian.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/bailian.js +42 -0
- package/dist/llm/providers/endpoints/bailian.js.map +1 -0
- package/dist/llm/providers/endpoints/bailianCodingPlan.d.ts +10 -0
- package/dist/llm/providers/endpoints/bailianCodingPlan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/bailianCodingPlan.js +22 -0
- package/dist/llm/providers/endpoints/bailianCodingPlan.js.map +1 -0
- package/dist/llm/providers/endpoints/custom.d.ts +16 -0
- package/dist/llm/providers/endpoints/custom.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/custom.js +15 -0
- package/dist/llm/providers/endpoints/custom.js.map +1 -0
- package/dist/llm/providers/endpoints/deepseek.d.ts +17 -0
- package/dist/llm/providers/endpoints/deepseek.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/deepseek.js +20 -0
- package/dist/llm/providers/endpoints/deepseek.js.map +1 -0
- package/dist/llm/providers/endpoints/giteeai.d.ts +10 -0
- package/dist/llm/providers/endpoints/giteeai.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/giteeai.js +33 -0
- package/dist/llm/providers/endpoints/giteeai.js.map +1 -0
- package/dist/llm/providers/endpoints/githubCopilot.d.ts +10 -0
- package/dist/llm/providers/endpoints/githubCopilot.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/githubCopilot.js +35 -0
- package/dist/llm/providers/endpoints/githubCopilot.js.map +1 -0
- package/dist/llm/providers/endpoints/glmCodingPlan.d.ts +9 -0
- package/dist/llm/providers/endpoints/glmCodingPlan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/glmCodingPlan.js +21 -0
- package/dist/llm/providers/endpoints/glmCodingPlan.js.map +1 -0
- package/dist/llm/providers/endpoints/google.d.ts +12 -0
- package/dist/llm/providers/endpoints/google.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/google.js +41 -0
- package/dist/llm/providers/endpoints/google.js.map +1 -0
- package/dist/llm/providers/endpoints/hunyuan.d.ts +10 -0
- package/dist/llm/providers/endpoints/hunyuan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/hunyuan.js +34 -0
- package/dist/llm/providers/endpoints/hunyuan.js.map +1 -0
- package/dist/llm/providers/endpoints/infiniai.d.ts +10 -0
- package/dist/llm/providers/endpoints/infiniai.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/infiniai.js +64 -0
- package/dist/llm/providers/endpoints/infiniai.js.map +1 -0
- package/dist/llm/providers/endpoints/internlm.d.ts +10 -0
- package/dist/llm/providers/endpoints/internlm.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/internlm.js +20 -0
- package/dist/llm/providers/endpoints/internlm.js.map +1 -0
- package/dist/llm/providers/endpoints/kimiCode.d.ts +9 -0
- package/dist/llm/providers/endpoints/kimiCode.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/kimiCode.js +16 -0
- package/dist/llm/providers/endpoints/kimiCode.js.map +1 -0
- package/dist/llm/providers/endpoints/kimiCodingPlan.d.ts +9 -0
- package/dist/llm/providers/endpoints/kimiCodingPlan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/kimiCodingPlan.js +17 -0
- package/dist/llm/providers/endpoints/kimiCodingPlan.js.map +1 -0
- package/dist/llm/providers/endpoints/kkaiapi.d.ts +14 -0
- package/dist/llm/providers/endpoints/kkaiapi.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/kkaiapi.js +44 -0
- package/dist/llm/providers/endpoints/kkaiapi.js.map +1 -0
- package/dist/llm/providers/endpoints/lmstudio.d.ts +10 -0
- package/dist/llm/providers/endpoints/lmstudio.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/lmstudio.js +15 -0
- package/dist/llm/providers/endpoints/lmstudio.js.map +1 -0
- package/dist/llm/providers/endpoints/longcat.d.ts +9 -0
- package/dist/llm/providers/endpoints/longcat.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/longcat.js +18 -0
- package/dist/llm/providers/endpoints/longcat.js.map +1 -0
- package/dist/llm/providers/endpoints/minimax.d.ts +15 -0
- package/dist/llm/providers/endpoints/minimax.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/minimax.js +27 -0
- package/dist/llm/providers/endpoints/minimax.js.map +1 -0
- package/dist/llm/providers/endpoints/minimaxCodingPlan.d.ts +9 -0
- package/dist/llm/providers/endpoints/minimaxCodingPlan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/minimaxCodingPlan.js +21 -0
- package/dist/llm/providers/endpoints/minimaxCodingPlan.js.map +1 -0
- package/dist/llm/providers/endpoints/mistral.d.ts +11 -0
- package/dist/llm/providers/endpoints/mistral.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/mistral.js +31 -0
- package/dist/llm/providers/endpoints/mistral.js.map +1 -0
- package/dist/llm/providers/endpoints/modelscope.d.ts +10 -0
- package/dist/llm/providers/endpoints/modelscope.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/modelscope.js +22 -0
- package/dist/llm/providers/endpoints/modelscope.js.map +1 -0
- package/dist/llm/providers/endpoints/moonshot.d.ts +12 -0
- package/dist/llm/providers/endpoints/moonshot.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/moonshot.js +29 -0
- package/dist/llm/providers/endpoints/moonshot.js.map +1 -0
- package/dist/llm/providers/endpoints/newapi.d.ts +14 -0
- package/dist/llm/providers/endpoints/newapi.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/newapi.js +14 -0
- package/dist/llm/providers/endpoints/newapi.js.map +1 -0
- package/dist/llm/providers/endpoints/ollama.d.ts +12 -0
- package/dist/llm/providers/endpoints/ollama.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/ollama.js +63 -0
- package/dist/llm/providers/endpoints/ollama.js.map +1 -0
- package/dist/llm/providers/endpoints/openai.d.ts +12 -0
- package/dist/llm/providers/endpoints/openai.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/openai.js +67 -0
- package/dist/llm/providers/endpoints/openai.js.map +1 -0
- package/dist/llm/providers/endpoints/opencodeCodingPlan.d.ts +9 -0
- package/dist/llm/providers/endpoints/opencodeCodingPlan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/opencodeCodingPlan.js +23 -0
- package/dist/llm/providers/endpoints/opencodeCodingPlan.js.map +1 -0
- package/dist/llm/providers/endpoints/openrouter.d.ts +15 -0
- package/dist/llm/providers/endpoints/openrouter.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/openrouter.js +75 -0
- package/dist/llm/providers/endpoints/openrouter.js.map +1 -0
- package/dist/llm/providers/endpoints/ppio.d.ts +15 -0
- package/dist/llm/providers/endpoints/ppio.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/ppio.js +73 -0
- package/dist/llm/providers/endpoints/ppio.js.map +1 -0
- package/dist/llm/providers/endpoints/qiniu.d.ts +10 -0
- package/dist/llm/providers/endpoints/qiniu.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/qiniu.js +24 -0
- package/dist/llm/providers/endpoints/qiniu.js.map +1 -0
- package/dist/llm/providers/endpoints/sensenova.d.ts +10 -0
- package/dist/llm/providers/endpoints/sensenova.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/sensenova.js +37 -0
- package/dist/llm/providers/endpoints/sensenova.js.map +1 -0
- package/dist/llm/providers/endpoints/siliconcloud.d.ts +14 -0
- package/dist/llm/providers/endpoints/siliconcloud.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/siliconcloud.js +114 -0
- package/dist/llm/providers/endpoints/siliconcloud.js.map +1 -0
- package/dist/llm/providers/endpoints/spark.d.ts +14 -0
- package/dist/llm/providers/endpoints/spark.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/spark.js +21 -0
- package/dist/llm/providers/endpoints/spark.js.map +1 -0
- package/dist/llm/providers/endpoints/stepfun.d.ts +10 -0
- package/dist/llm/providers/endpoints/stepfun.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/stepfun.js +27 -0
- package/dist/llm/providers/endpoints/stepfun.js.map +1 -0
- package/dist/llm/providers/endpoints/tencentcloud.d.ts +10 -0
- package/dist/llm/providers/endpoints/tencentcloud.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/tencentcloud.js +17 -0
- package/dist/llm/providers/endpoints/tencentcloud.js.map +1 -0
- package/dist/llm/providers/endpoints/volcengine.d.ts +10 -0
- package/dist/llm/providers/endpoints/volcengine.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/volcengine.js +44 -0
- package/dist/llm/providers/endpoints/volcengine.js.map +1 -0
- package/dist/llm/providers/endpoints/volcengineCodingPlan.d.ts +19 -0
- package/dist/llm/providers/endpoints/volcengineCodingPlan.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/volcengineCodingPlan.js +25 -0
- package/dist/llm/providers/endpoints/volcengineCodingPlan.js.map +1 -0
- package/dist/llm/providers/endpoints/wenxin.d.ts +10 -0
- package/dist/llm/providers/endpoints/wenxin.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/wenxin.js +98 -0
- package/dist/llm/providers/endpoints/wenxin.js.map +1 -0
- package/dist/llm/providers/endpoints/xai.d.ts +11 -0
- package/dist/llm/providers/endpoints/xai.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/xai.js +25 -0
- package/dist/llm/providers/endpoints/xai.js.map +1 -0
- package/dist/llm/providers/endpoints/xiaomimimo.d.ts +12 -0
- package/dist/llm/providers/endpoints/xiaomimimo.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/xiaomimimo.js +16 -0
- package/dist/llm/providers/endpoints/xiaomimimo.js.map +1 -0
- package/dist/llm/providers/endpoints/zeroone.d.ts +10 -0
- package/dist/llm/providers/endpoints/zeroone.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/zeroone.js +26 -0
- package/dist/llm/providers/endpoints/zeroone.js.map +1 -0
- package/dist/llm/providers/endpoints/zhipu.d.ts +12 -0
- package/dist/llm/providers/endpoints/zhipu.d.ts.map +1 -0
- package/dist/llm/providers/endpoints/zhipu.js +51 -0
- package/dist/llm/providers/endpoints/zhipu.js.map +1 -0
- package/dist/llm/providers/index.d.ts +5 -0
- package/dist/llm/providers/index.d.ts.map +1 -0
- package/dist/llm/providers/index.js +64 -0
- package/dist/llm/providers/index.js.map +1 -0
- package/dist/llm/providers/lookup.d.ts +16 -0
- package/dist/llm/providers/lookup.d.ts.map +1 -0
- package/dist/llm/providers/lookup.js +68 -0
- package/dist/llm/providers/lookup.js.map +1 -0
- package/dist/llm/providers/probe.d.ts +11 -0
- package/dist/llm/providers/probe.d.ts.map +1 -0
- package/dist/llm/providers/probe.js +24 -0
- package/dist/llm/providers/probe.js.map +1 -0
- package/dist/llm/providers/types.d.ts +71 -0
- package/dist/llm/providers/types.d.ts.map +1 -0
- package/dist/llm/providers/types.js +9 -0
- package/dist/llm/providers/types.js.map +1 -0
- package/dist/llm/providers/verify.d.ts +27 -0
- package/dist/llm/providers/verify.d.ts.map +1 -0
- package/dist/llm/providers/verify.js +77 -0
- package/dist/llm/providers/verify.js.map +1 -0
- package/dist/llm/secrets.d.ts +9 -0
- package/dist/llm/secrets.d.ts.map +1 -0
- package/dist/llm/secrets.js +56 -0
- package/dist/llm/secrets.js.map +1 -0
- package/dist/llm/service-presets.d.ts +45 -0
- package/dist/llm/service-presets.d.ts.map +1 -0
- package/dist/llm/service-presets.js +180 -0
- package/dist/llm/service-presets.js.map +1 -0
- package/dist/llm/service-resolver.d.ts +10 -0
- package/dist/llm/service-resolver.d.ts.map +1 -0
- package/dist/llm/service-resolver.js +62 -0
- package/dist/llm/service-resolver.js.map +1 -0
- package/dist/llm/think-tag-stripper.d.ts +15 -0
- package/dist/llm/think-tag-stripper.d.ts.map +1 -0
- package/dist/llm/think-tag-stripper.js +60 -0
- package/dist/llm/think-tag-stripper.js.map +1 -0
- package/dist/materials/ingest.d.ts +31 -0
- package/dist/materials/ingest.d.ts.map +1 -0
- package/dist/materials/ingest.js +224 -0
- package/dist/materials/ingest.js.map +1 -0
- package/dist/materials/retrieve.d.ts +20 -0
- package/dist/materials/retrieve.d.ts.map +1 -0
- package/dist/materials/retrieve.js +109 -0
- package/dist/materials/retrieve.js.map +1 -0
- package/dist/models/book-rules.d.ts +142 -0
- package/dist/models/book-rules.d.ts.map +1 -0
- package/dist/models/book-rules.js +286 -0
- package/dist/models/book-rules.js.map +1 -0
- package/dist/models/book.d.ts +94 -0
- package/dist/models/book.d.ts.map +1 -0
- package/dist/models/book.js +79 -0
- package/dist/models/book.js.map +1 -0
- package/dist/models/chapter.d.ts +131 -0
- package/dist/models/chapter.d.ts.map +1 -0
- package/dist/models/chapter.js +38 -0
- package/dist/models/chapter.js.map +1 -0
- package/dist/models/context-compression.d.ts +13 -0
- package/dist/models/context-compression.d.ts.map +1 -0
- package/dist/models/context-compression.js +2 -0
- package/dist/models/context-compression.js.map +1 -0
- package/dist/models/detection.d.ts +25 -0
- package/dist/models/detection.d.ts.map +1 -0
- package/dist/models/detection.js +2 -0
- package/dist/models/detection.js.map +1 -0
- package/dist/models/genre-profile.d.ts +45 -0
- package/dist/models/genre-profile.d.ts.map +1 -0
- package/dist/models/genre-profile.js +26 -0
- package/dist/models/genre-profile.js.map +1 -0
- package/dist/models/input-governance.d.ts +437 -0
- package/dist/models/input-governance.d.ts.map +1 -0
- package/dist/models/input-governance.js +104 -0
- package/dist/models/input-governance.js.map +1 -0
- package/dist/models/length-governance.d.ts +85 -0
- package/dist/models/length-governance.d.ts.map +1 -0
- package/dist/models/length-governance.js +31 -0
- package/dist/models/length-governance.js.map +1 -0
- package/dist/models/play.d.ts +530 -0
- package/dist/models/play.d.ts.map +1 -0
- package/dist/models/play.js +318 -0
- package/dist/models/play.js.map +1 -0
- package/dist/models/project.d.ts +797 -0
- package/dist/models/project.d.ts.map +1 -0
- package/dist/models/project.js +152 -0
- package/dist/models/project.js.map +1 -0
- package/dist/models/runtime-state.d.ts +708 -0
- package/dist/models/runtime-state.d.ts.map +1 -0
- package/dist/models/runtime-state.js +105 -0
- package/dist/models/runtime-state.js.map +1 -0
- package/dist/models/state.d.ts +48 -0
- package/dist/models/state.d.ts.map +1 -0
- package/dist/models/state.js +6 -0
- package/dist/models/state.js.map +1 -0
- package/dist/models/style-profile.d.ts +16 -0
- package/dist/models/style-profile.d.ts.map +1 -0
- package/dist/models/style-profile.js +2 -0
- package/dist/models/style-profile.js.map +1 -0
- package/dist/notify/dispatcher.d.ts +10 -0
- package/dist/notify/dispatcher.d.ts.map +1 -0
- package/dist/notify/dispatcher.js +67 -0
- package/dist/notify/dispatcher.js.map +1 -0
- package/dist/notify/feishu.d.ts +6 -0
- package/dist/notify/feishu.d.ts.map +1 -0
- package/dist/notify/feishu.js +32 -0
- package/dist/notify/feishu.js.map +1 -0
- package/dist/notify/format.d.ts +12 -0
- package/dist/notify/format.d.ts.map +1 -0
- package/dist/notify/format.js +11 -0
- package/dist/notify/format.js.map +1 -0
- package/dist/notify/telegram.d.ts +7 -0
- package/dist/notify/telegram.d.ts.map +1 -0
- package/dist/notify/telegram.js +18 -0
- package/dist/notify/telegram.js.map +1 -0
- package/dist/notify/webhook.d.ts +15 -0
- package/dist/notify/webhook.d.ts.map +1 -0
- package/dist/notify/webhook.js +28 -0
- package/dist/notify/webhook.js.map +1 -0
- package/dist/notify/wechat-work.d.ts +6 -0
- package/dist/notify/wechat-work.d.ts.map +1 -0
- package/dist/notify/wechat-work.js +15 -0
- package/dist/notify/wechat-work.js.map +1 -0
- package/dist/pipeline/chapter-persistence.d.ts +33 -0
- package/dist/pipeline/chapter-persistence.d.ts.map +1 -0
- package/dist/pipeline/chapter-persistence.js +39 -0
- package/dist/pipeline/chapter-persistence.js.map +1 -0
- package/dist/pipeline/chapter-review-cycle.d.ts +81 -0
- package/dist/pipeline/chapter-review-cycle.d.ts.map +1 -0
- package/dist/pipeline/chapter-review-cycle.js +190 -0
- package/dist/pipeline/chapter-review-cycle.js.map +1 -0
- package/dist/pipeline/chapter-state-recovery.d.ts +61 -0
- package/dist/pipeline/chapter-state-recovery.d.ts.map +1 -0
- package/dist/pipeline/chapter-state-recovery.js +135 -0
- package/dist/pipeline/chapter-state-recovery.js.map +1 -0
- package/dist/pipeline/chapter-truth-validation.d.ts +42 -0
- package/dist/pipeline/chapter-truth-validation.d.ts.map +1 -0
- package/dist/pipeline/chapter-truth-validation.js +93 -0
- package/dist/pipeline/chapter-truth-validation.js.map +1 -0
- package/dist/pipeline/detection-runner.d.ts +31 -0
- package/dist/pipeline/detection-runner.d.ts.map +1 -0
- package/dist/pipeline/detection-runner.js +109 -0
- package/dist/pipeline/detection-runner.js.map +1 -0
- package/dist/pipeline/persisted-governed-plan.d.ts +5 -0
- package/dist/pipeline/persisted-governed-plan.d.ts.map +1 -0
- package/dist/pipeline/persisted-governed-plan.js +249 -0
- package/dist/pipeline/persisted-governed-plan.js.map +1 -0
- package/dist/pipeline/runner.d.ts +334 -0
- package/dist/pipeline/runner.d.ts.map +1 -0
- package/dist/pipeline/runner.js +2974 -0
- package/dist/pipeline/runner.js.map +1 -0
- package/dist/pipeline/scheduler.d.ts +58 -0
- package/dist/pipeline/scheduler.d.ts.map +1 -0
- package/dist/pipeline/scheduler.js +322 -0
- package/dist/pipeline/scheduler.js.map +1 -0
- package/dist/pipeline/script-storyboard-runner.d.ts +130 -0
- package/dist/pipeline/script-storyboard-runner.d.ts.map +1 -0
- package/dist/pipeline/script-storyboard-runner.js +532 -0
- package/dist/pipeline/script-storyboard-runner.js.map +1 -0
- package/dist/pipeline/short-fiction-runner.d.ts +110 -0
- package/dist/pipeline/short-fiction-runner.d.ts.map +1 -0
- package/dist/pipeline/short-fiction-runner.js +864 -0
- package/dist/pipeline/short-fiction-runner.js.map +1 -0
- package/dist/play/play-agents.d.ts +72 -0
- package/dist/play/play-agents.d.ts.map +1 -0
- package/dist/play/play-agents.js +580 -0
- package/dist/play/play-agents.js.map +1 -0
- package/dist/play/play-db-factory.d.ts +9 -0
- package/dist/play/play-db-factory.d.ts.map +1 -0
- package/dist/play/play-db-factory.js +18 -0
- package/dist/play/play-db-factory.js.map +1 -0
- package/dist/play/play-db.d.ts +22 -0
- package/dist/play/play-db.d.ts.map +1 -0
- package/dist/play/play-db.js +248 -0
- package/dist/play/play-db.js.map +1 -0
- package/dist/play/play-file-db.d.ts +32 -0
- package/dist/play/play-file-db.d.ts.map +1 -0
- package/dist/play/play-file-db.js +156 -0
- package/dist/play/play-file-db.js.map +1 -0
- package/dist/play/play-image.d.ts +58 -0
- package/dist/play/play-image.d.ts.map +1 -0
- package/dist/play/play-image.js +142 -0
- package/dist/play/play-image.js.map +1 -0
- package/dist/play/play-reducer.d.ts +31 -0
- package/dist/play/play-reducer.d.ts.map +1 -0
- package/dist/play/play-reducer.js +261 -0
- package/dist/play/play-reducer.js.map +1 -0
- package/dist/play/play-runner.d.ts +116 -0
- package/dist/play/play-runner.d.ts.map +1 -0
- package/dist/play/play-runner.js +582 -0
- package/dist/play/play-runner.js.map +1 -0
- package/dist/play/play-store.d.ts +113 -0
- package/dist/play/play-store.d.ts.map +1 -0
- package/dist/play/play-store.js +314 -0
- package/dist/play/play-store.js.map +1 -0
- package/dist/production/harness.d.ts +57 -0
- package/dist/production/harness.d.ts.map +1 -0
- package/dist/production/harness.js +51 -0
- package/dist/production/harness.js.map +1 -0
- package/dist/prompts/builtin-prompts.d.ts +10 -0
- package/dist/prompts/builtin-prompts.d.ts.map +1 -0
- package/dist/prompts/builtin-prompts.js +157 -0
- package/dist/prompts/builtin-prompts.js.map +1 -0
- package/dist/prompts/index.d.ts +5 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +5 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/prompt-pack.d.ts +33 -0
- package/dist/prompts/prompt-pack.d.ts.map +1 -0
- package/dist/prompts/prompt-pack.js +82 -0
- package/dist/prompts/prompt-pack.js.map +1 -0
- package/dist/prompts/short-fiction.d.ts +58 -0
- package/dist/prompts/short-fiction.d.ts.map +1 -0
- package/dist/prompts/short-fiction.js +480 -0
- package/dist/prompts/short-fiction.js.map +1 -0
- package/dist/prompts/types.d.ts +22 -0
- package/dist/prompts/types.d.ts.map +1 -0
- package/dist/prompts/types.js +9 -0
- package/dist/prompts/types.js.map +1 -0
- package/dist/references/book-references.d.ts +40 -0
- package/dist/references/book-references.d.ts.map +1 -0
- package/dist/references/book-references.js +207 -0
- package/dist/references/book-references.js.map +1 -0
- package/dist/references/reference-context.d.ts +26 -0
- package/dist/references/reference-context.d.ts.map +1 -0
- package/dist/references/reference-context.js +120 -0
- package/dist/references/reference-context.js.map +1 -0
- package/dist/retrieval/local-search.d.ts +38 -0
- package/dist/retrieval/local-search.d.ts.map +1 -0
- package/dist/retrieval/local-search.js +232 -0
- package/dist/retrieval/local-search.js.map +1 -0
- package/dist/skills/builtin-loader.d.ts +9 -0
- package/dist/skills/builtin-loader.d.ts.map +1 -0
- package/dist/skills/builtin-loader.js +24 -0
- package/dist/skills/builtin-loader.js.map +1 -0
- package/dist/skills/external-loader.d.ts +26 -0
- package/dist/skills/external-loader.d.ts.map +1 -0
- package/dist/skills/external-loader.js +186 -0
- package/dist/skills/external-loader.js.map +1 -0
- package/dist/skills/index.d.ts +6 -0
- package/dist/skills/index.d.ts.map +1 -0
- package/dist/skills/index.js +6 -0
- package/dist/skills/index.js.map +1 -0
- package/dist/skills/production-bindings.d.ts +18 -0
- package/dist/skills/production-bindings.d.ts.map +1 -0
- package/dist/skills/production-bindings.js +37 -0
- package/dist/skills/production-bindings.js.map +1 -0
- package/dist/skills/registry.d.ts +6 -0
- package/dist/skills/registry.d.ts.map +1 -0
- package/dist/skills/registry.js +68 -0
- package/dist/skills/registry.js.map +1 -0
- package/dist/skills/types.d.ts +42 -0
- package/dist/skills/types.d.ts.map +1 -0
- package/dist/skills/types.js +10 -0
- package/dist/skills/types.js.map +1 -0
- package/dist/state/chapter-delete.d.ts +30 -0
- package/dist/state/chapter-delete.d.ts.map +1 -0
- package/dist/state/chapter-delete.js +78 -0
- package/dist/state/chapter-delete.js.map +1 -0
- package/dist/state/chapter-word-sync.d.ts +30 -0
- package/dist/state/chapter-word-sync.d.ts.map +1 -0
- package/dist/state/chapter-word-sync.js +62 -0
- package/dist/state/chapter-word-sync.js.map +1 -0
- package/dist/state/chapter-workspace.d.ts +15 -0
- package/dist/state/chapter-workspace.d.ts.map +1 -0
- package/dist/state/chapter-workspace.js +118 -0
- package/dist/state/chapter-workspace.js.map +1 -0
- package/dist/state/manager.d.ts +70 -0
- package/dist/state/manager.d.ts.map +1 -0
- package/dist/state/manager.js +727 -0
- package/dist/state/manager.js.map +1 -0
- package/dist/state/memory-db.d.ts +83 -0
- package/dist/state/memory-db.d.ts.map +1 -0
- package/dist/state/memory-db.js +249 -0
- package/dist/state/memory-db.js.map +1 -0
- package/dist/state/runtime-state-store.d.ts +38 -0
- package/dist/state/runtime-state-store.d.ts.map +1 -0
- package/dist/state/runtime-state-store.js +164 -0
- package/dist/state/runtime-state-store.js.map +1 -0
- package/dist/state/state-bootstrap.d.ts +21 -0
- package/dist/state/state-bootstrap.d.ts.map +1 -0
- package/dist/state/state-bootstrap.js +476 -0
- package/dist/state/state-bootstrap.js.map +1 -0
- package/dist/state/state-projections.d.ts +7 -0
- package/dist/state/state-projections.d.ts.map +1 -0
- package/dist/state/state-projections.js +209 -0
- package/dist/state/state-projections.js.map +1 -0
- package/dist/state/state-reducer.d.ts +13 -0
- package/dist/state/state-reducer.d.ts.map +1 -0
- package/dist/state/state-reducer.js +193 -0
- package/dist/state/state-reducer.js.map +1 -0
- package/dist/state/state-validator.d.ts +12 -0
- package/dist/state/state-validator.d.ts.map +1 -0
- package/dist/state/state-validator.js +67 -0
- package/dist/state/state-validator.js.map +1 -0
- package/dist/translation/epub.d.ts +10 -0
- package/dist/translation/epub.d.ts.map +1 -0
- package/dist/translation/epub.js +86 -0
- package/dist/translation/epub.js.map +1 -0
- package/dist/translation/export.d.ts +6 -0
- package/dist/translation/export.d.ts.map +1 -0
- package/dist/translation/export.js +68 -0
- package/dist/translation/export.js.map +1 -0
- package/dist/translation/index.d.ts +9 -0
- package/dist/translation/index.d.ts.map +1 -0
- package/dist/translation/index.js +9 -0
- package/dist/translation/index.js.map +1 -0
- package/dist/translation/llm-model.d.ts +11 -0
- package/dist/translation/llm-model.d.ts.map +1 -0
- package/dist/translation/llm-model.js +135 -0
- package/dist/translation/llm-model.js.map +1 -0
- package/dist/translation/project.d.ts +3 -0
- package/dist/translation/project.d.ts.map +1 -0
- package/dist/translation/project.js +76 -0
- package/dist/translation/project.js.map +1 -0
- package/dist/translation/run-store.d.ts +12 -0
- package/dist/translation/run-store.d.ts.map +1 -0
- package/dist/translation/run-store.js +69 -0
- package/dist/translation/run-store.js.map +1 -0
- package/dist/translation/runner.d.ts +6 -0
- package/dist/translation/runner.d.ts.map +1 -0
- package/dist/translation/runner.js +155 -0
- package/dist/translation/runner.js.map +1 -0
- package/dist/translation/source.d.ts +12 -0
- package/dist/translation/source.d.ts.map +1 -0
- package/dist/translation/source.js +66 -0
- package/dist/translation/source.js.map +1 -0
- package/dist/translation/text.d.ts +10 -0
- package/dist/translation/text.d.ts.map +1 -0
- package/dist/translation/text.js +110 -0
- package/dist/translation/text.js.map +1 -0
- package/dist/translation/types.d.ts +96 -0
- package/dist/translation/types.d.ts.map +1 -0
- package/dist/translation/types.js +2 -0
- package/dist/translation/types.js.map +1 -0
- package/dist/utils/analytics.d.ts +39 -0
- package/dist/utils/analytics.d.ts.map +1 -0
- package/dist/utils/analytics.js +50 -0
- package/dist/utils/analytics.js.map +1 -0
- package/dist/utils/atomic-file-set.d.ts +12 -0
- package/dist/utils/atomic-file-set.d.ts.map +1 -0
- package/dist/utils/atomic-file-set.js +93 -0
- package/dist/utils/atomic-file-set.js.map +1 -0
- package/dist/utils/book-eval.d.ts +35 -0
- package/dist/utils/book-eval.d.ts.map +1 -0
- package/dist/utils/book-eval.js +116 -0
- package/dist/utils/book-eval.js.map +1 -0
- package/dist/utils/book-id.d.ts +4 -0
- package/dist/utils/book-id.d.ts.map +1 -0
- package/dist/utils/book-id.js +27 -0
- package/dist/utils/book-id.js.map +1 -0
- package/dist/utils/cadence-policy.d.ts +36 -0
- package/dist/utils/cadence-policy.d.ts.map +1 -0
- package/dist/utils/cadence-policy.js +38 -0
- package/dist/utils/cadence-policy.js.map +1 -0
- package/dist/utils/chapter-cadence.d.ts +34 -0
- package/dist/utils/chapter-cadence.d.ts.map +1 -0
- package/dist/utils/chapter-cadence.js +143 -0
- package/dist/utils/chapter-cadence.js.map +1 -0
- package/dist/utils/chapter-memo-parser.d.ts +22 -0
- package/dist/utils/chapter-memo-parser.d.ts.map +1 -0
- package/dist/utils/chapter-memo-parser.js +158 -0
- package/dist/utils/chapter-memo-parser.js.map +1 -0
- package/dist/utils/chapter-splitter.d.ts +18 -0
- package/dist/utils/chapter-splitter.d.ts.map +1 -0
- package/dist/utils/chapter-splitter.js +60 -0
- package/dist/utils/chapter-splitter.js.map +1 -0
- package/dist/utils/config-loader.d.ts +11 -0
- package/dist/utils/config-loader.d.ts.map +1 -0
- package/dist/utils/config-loader.js +16 -0
- package/dist/utils/config-loader.js.map +1 -0
- package/dist/utils/context-assembly.d.ts +29 -0
- package/dist/utils/context-assembly.d.ts.map +1 -0
- package/dist/utils/context-assembly.js +117 -0
- package/dist/utils/context-assembly.js.map +1 -0
- package/dist/utils/context-filter.d.ts +31 -0
- package/dist/utils/context-filter.d.ts.map +1 -0
- package/dist/utils/context-filter.js +163 -0
- package/dist/utils/context-filter.js.map +1 -0
- package/dist/utils/effective-llm-config.d.ts +34 -0
- package/dist/utils/effective-llm-config.d.ts.map +1 -0
- package/dist/utils/effective-llm-config.js +463 -0
- package/dist/utils/effective-llm-config.js.map +1 -0
- package/dist/utils/governed-context.d.ts +11 -0
- package/dist/utils/governed-context.d.ts.map +1 -0
- package/dist/utils/governed-context.js +42 -0
- package/dist/utils/governed-context.js.map +1 -0
- package/dist/utils/governed-working-set.d.ts +18 -0
- package/dist/utils/governed-working-set.d.ts.map +1 -0
- package/dist/utils/governed-working-set.js +296 -0
- package/dist/utils/governed-working-set.js.map +1 -0
- package/dist/utils/hook-arbiter.d.ts +16 -0
- package/dist/utils/hook-arbiter.d.ts.map +1 -0
- package/dist/utils/hook-arbiter.js +161 -0
- package/dist/utils/hook-arbiter.js.map +1 -0
- package/dist/utils/hook-governance.d.ts +26 -0
- package/dist/utils/hook-governance.d.ts.map +1 -0
- package/dist/utils/hook-governance.js +65 -0
- package/dist/utils/hook-governance.js.map +1 -0
- package/dist/utils/hook-health.d.ts +15 -0
- package/dist/utils/hook-health.d.ts.map +1 -0
- package/dist/utils/hook-health.js +131 -0
- package/dist/utils/hook-health.js.map +1 -0
- package/dist/utils/hook-ledger-validator.d.ts +82 -0
- package/dist/utils/hook-ledger-validator.d.ts.map +1 -0
- package/dist/utils/hook-ledger-validator.js +225 -0
- package/dist/utils/hook-ledger-validator.js.map +1 -0
- package/dist/utils/hook-lifecycle.d.ts +41 -0
- package/dist/utils/hook-lifecycle.d.ts.map +1 -0
- package/dist/utils/hook-lifecycle.js +183 -0
- package/dist/utils/hook-lifecycle.js.map +1 -0
- package/dist/utils/hook-policy.d.ts +57 -0
- package/dist/utils/hook-policy.d.ts.map +1 -0
- package/dist/utils/hook-policy.js +96 -0
- package/dist/utils/hook-policy.js.map +1 -0
- package/dist/utils/hook-promotion.d.ts +83 -0
- package/dist/utils/hook-promotion.d.ts.map +1 -0
- package/dist/utils/hook-promotion.js +241 -0
- package/dist/utils/hook-promotion.js.map +1 -0
- package/dist/utils/hook-stale-detection.d.ts +51 -0
- package/dist/utils/hook-stale-detection.d.ts.map +1 -0
- package/dist/utils/hook-stale-detection.js +125 -0
- package/dist/utils/hook-stale-detection.js.map +1 -0
- package/dist/utils/language.d.ts +19 -0
- package/dist/utils/language.d.ts.map +1 -0
- package/dist/utils/language.js +29 -0
- package/dist/utils/language.js.map +1 -0
- package/dist/utils/length-metrics.d.ts +12 -0
- package/dist/utils/length-metrics.d.ts.map +1 -0
- package/dist/utils/length-metrics.js +85 -0
- package/dist/utils/length-metrics.js.map +1 -0
- package/dist/utils/llm-endpoint-auth.d.ts +5 -0
- package/dist/utils/llm-endpoint-auth.d.ts.map +1 -0
- package/dist/utils/llm-endpoint-auth.js +36 -0
- package/dist/utils/llm-endpoint-auth.js.map +1 -0
- package/dist/utils/llm-env.d.ts +14 -0
- package/dist/utils/llm-env.d.ts.map +1 -0
- package/dist/utils/llm-env.js +53 -0
- package/dist/utils/llm-env.js.map +1 -0
- package/dist/utils/logger.d.ts +31 -0
- package/dist/utils/logger.d.ts.map +1 -0
- package/dist/utils/logger.js +79 -0
- package/dist/utils/logger.js.map +1 -0
- package/dist/utils/long-span-fatigue.d.ts +28 -0
- package/dist/utils/long-span-fatigue.d.ts.map +1 -0
- package/dist/utils/long-span-fatigue.js +406 -0
- package/dist/utils/long-span-fatigue.js.map +1 -0
- package/dist/utils/memory-retrieval.d.ts +71 -0
- package/dist/utils/memory-retrieval.d.ts.map +1 -0
- package/dist/utils/memory-retrieval.js +360 -0
- package/dist/utils/memory-retrieval.js.map +1 -0
- package/dist/utils/narrative-control.d.ts +16 -0
- package/dist/utils/narrative-control.d.ts.map +1 -0
- package/dist/utils/narrative-control.js +131 -0
- package/dist/utils/narrative-control.js.map +1 -0
- package/dist/utils/outline-paths.d.ts +63 -0
- package/dist/utils/outline-paths.d.ts.map +1 -0
- package/dist/utils/outline-paths.js +311 -0
- package/dist/utils/outline-paths.js.map +1 -0
- package/dist/utils/path-safety.d.ts +2 -0
- package/dist/utils/path-safety.d.ts.map +1 -0
- package/dist/utils/path-safety.js +11 -0
- package/dist/utils/path-safety.js.map +1 -0
- package/dist/utils/planning-materials.d.ts +35 -0
- package/dist/utils/planning-materials.d.ts.map +1 -0
- package/dist/utils/planning-materials.js +123 -0
- package/dist/utils/planning-materials.js.map +1 -0
- package/dist/utils/posix-path.d.ts +2 -0
- package/dist/utils/posix-path.d.ts.map +1 -0
- package/dist/utils/posix-path.js +7 -0
- package/dist/utils/posix-path.js.map +1 -0
- package/dist/utils/pov-filter.d.ts +30 -0
- package/dist/utils/pov-filter.d.ts.map +1 -0
- package/dist/utils/pov-filter.js +129 -0
- package/dist/utils/pov-filter.js.map +1 -0
- package/dist/utils/proxy-fetch.d.ts +9 -0
- package/dist/utils/proxy-fetch.d.ts.map +1 -0
- package/dist/utils/proxy-fetch.js +31 -0
- package/dist/utils/proxy-fetch.js.map +1 -0
- package/dist/utils/runtime-writer.d.ts +14 -0
- package/dist/utils/runtime-writer.d.ts.map +1 -0
- package/dist/utils/runtime-writer.js +21 -0
- package/dist/utils/runtime-writer.js.map +1 -0
- package/dist/utils/spot-fix-patches.d.ts +21 -0
- package/dist/utils/spot-fix-patches.d.ts.map +1 -0
- package/dist/utils/spot-fix-patches.js +148 -0
- package/dist/utils/spot-fix-patches.js.map +1 -0
- package/dist/utils/story-markdown.d.ts +13 -0
- package/dist/utils/story-markdown.d.ts.map +1 -0
- package/dist/utils/story-markdown.js +320 -0
- package/dist/utils/story-markdown.js.map +1 -0
- package/dist/utils/web-search.d.ts +28 -0
- package/dist/utils/web-search.d.ts.map +1 -0
- package/dist/utils/web-search.js +72 -0
- package/dist/utils/web-search.js.map +1 -0
- package/dist/utils/writing-methodology.d.ts +10 -0
- package/dist/utils/writing-methodology.d.ts.map +1 -0
- package/dist/utils/writing-methodology.js +163 -0
- package/dist/utils/writing-methodology.js.map +1 -0
- package/genres/cozy.md +43 -0
- package/genres/cultivation.md +42 -0
- package/genres/dungeon-core.md +40 -0
- package/genres/horror.md +51 -0
- package/genres/isekai.md +43 -0
- package/genres/litrpg.md +43 -0
- package/genres/other.md +24 -0
- package/genres/progression.md +41 -0
- package/genres/romantasy.md +45 -0
- package/genres/sci-fi.md +42 -0
- package/genres/system-apocalypse.md +40 -0
- package/genres/tower-climber.md +41 -0
- package/genres/urban.md +53 -0
- package/genres/xianxia.md +46 -0
- package/genres/xuanhuan.md +64 -0
- package/package.json +76 -0
- package/skills/inkos-interactive-film/SKILL.md +16 -0
- package/skills/inkos-interactive-film/references/branch-state-craft.md +13 -0
- package/skills/inkos-long-market-research/SKILL.md +16 -0
- package/skills/inkos-long-market-research/references/research-rubric.md +19 -0
- package/skills/inkos-long-story-analysis/SKILL.md +17 -0
- package/skills/inkos-long-story-analysis/references/analysis-lens.md +16 -0
- package/skills/inkos-long-writing/SKILL.md +17 -0
- package/skills/inkos-long-writing/references/reader-contract-and-progression.md +13 -0
- package/skills/inkos-long-writing/references/scene-dialogue-and-length-budget.md +13 -0
- package/skills/inkos-play-world/SKILL.md +17 -0
- package/skills/inkos-play-world/references/world-turn-continuity.md +13 -0
- package/skills/inkos-script-writing/SKILL.md +15 -0
- package/skills/inkos-script-writing/references/episode-scene-craft.md +13 -0
- package/skills/inkos-short-market-research/SKILL.md +17 -0
- package/skills/inkos-short-market-research/references/short-market-rubric.md +16 -0
- package/skills/inkos-short-story-analysis/SKILL.md +16 -0
- package/skills/inkos-short-story-analysis/references/deconstruction-template.md +14 -0
- package/skills/inkos-short-writing/SKILL.md +18 -0
- package/skills/inkos-short-writing/references/production-checklist.md +19 -0
- package/skills/inkos-story-cover/SKILL.md +17 -0
- package/skills/inkos-story-cover/references/cover-brief.md +16 -0
- package/skills/inkos-story-deslop/SKILL.md +16 -0
- package/skills/inkos-story-deslop/references/semantic-cleanup.md +13 -0
- package/skills/inkos-story-import/SKILL.md +19 -0
- package/skills/inkos-story-import/references/reconstruction-rubric.md +13 -0
- package/skills/inkos-story-review/SKILL.md +16 -0
- package/skills/inkos-story-review/references/review-matrix.md +21 -0
- package/skills/inkos-storyboard/SKILL.md +15 -0
- package/skills/inkos-storyboard/references/shot-continuity.md +13 -0
- package/skills/inkos-translation/SKILL.md +14 -0
- package/skills/inkos-translation/references/long-form-consistency.md +13 -0
|
@@ -0,0 +1,727 @@
|
|
|
1
|
+
import { readFile, writeFile, mkdir, readdir, rm, stat, unlink, open } from "node:fs/promises";
|
|
2
|
+
import { randomUUID } from "node:crypto";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
import { bootstrapStructuredStateFromMarkdown, resolveDurableStoryProgress } from "./state-bootstrap.js";
|
|
5
|
+
const BOOK_LOCK_HEARTBEAT_MS = 30_000;
|
|
6
|
+
const BOOK_LOCK_LEASE_MS = 3 * 60_000;
|
|
7
|
+
const BOOK_LOCK_RELEASE_RETRIES = 4;
|
|
8
|
+
// Studio creates a PipelineRunner per request. Lock ownership therefore has to
|
|
9
|
+
// be shared by every StateManager in this process, not stored on one instance.
|
|
10
|
+
const processBookLocks = new Map();
|
|
11
|
+
export class BookWriteLockError extends Error {
|
|
12
|
+
bookId;
|
|
13
|
+
lockPath;
|
|
14
|
+
code = "BOOK_BUSY";
|
|
15
|
+
constructor(bookId, lockPath, lockData) {
|
|
16
|
+
super(`Book "${bookId}" is locked by an active InkOS write${lockData ? ` (${lockData})` : ""}. ` +
|
|
17
|
+
"Wait for it to finish or stop the running task, then retry. Stale locks are recovered automatically.");
|
|
18
|
+
this.bookId = bookId;
|
|
19
|
+
this.lockPath = lockPath;
|
|
20
|
+
this.name = "BookWriteLockError";
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export class StateManager {
|
|
24
|
+
projectRoot;
|
|
25
|
+
constructor(projectRoot) {
|
|
26
|
+
this.projectRoot = projectRoot;
|
|
27
|
+
}
|
|
28
|
+
static defaultAuthorIntent(language) {
|
|
29
|
+
return language === "zh"
|
|
30
|
+
? "# 作者意图\n\n(在这里描述这本书的长期创作方向。)\n"
|
|
31
|
+
: "# Author Intent\n\n(Describe the long-horizon vision for this book here.)\n";
|
|
32
|
+
}
|
|
33
|
+
static defaultCurrentFocus(language) {
|
|
34
|
+
return language === "zh"
|
|
35
|
+
? "# 当前聚焦\n\n## 当前重点\n\n(描述接下来 1-3 章最需要优先推进的内容。)\n"
|
|
36
|
+
: "# Current Focus\n\n## Active Focus\n\n(Describe what the next 1-3 chapters should prioritize.)\n";
|
|
37
|
+
}
|
|
38
|
+
async ensureControlDocuments(bookId, authorIntent) {
|
|
39
|
+
const language = await this.resolveControlDocumentLanguage(bookId);
|
|
40
|
+
await this.ensureControlDocumentsAt(this.bookDir(bookId), language, authorIntent);
|
|
41
|
+
}
|
|
42
|
+
async ensureControlDocumentsAt(bookDir, language, authorIntent) {
|
|
43
|
+
const storyDir = join(bookDir, "story");
|
|
44
|
+
const runtimeDir = join(storyDir, "runtime");
|
|
45
|
+
const outlineDir = join(storyDir, "outline");
|
|
46
|
+
const rolesMajorDir = join(storyDir, "roles", "主要角色");
|
|
47
|
+
const rolesMinorDir = join(storyDir, "roles", "次要角色");
|
|
48
|
+
await mkdir(storyDir, { recursive: true });
|
|
49
|
+
await mkdir(runtimeDir, { recursive: true });
|
|
50
|
+
await mkdir(outlineDir, { recursive: true });
|
|
51
|
+
await mkdir(rolesMajorDir, { recursive: true });
|
|
52
|
+
await mkdir(rolesMinorDir, { recursive: true });
|
|
53
|
+
await this.writeIfMissing(join(storyDir, "author_intent.md"), authorIntent?.trim()
|
|
54
|
+
? authorIntent.trimEnd() + "\n"
|
|
55
|
+
: StateManager.defaultAuthorIntent(language));
|
|
56
|
+
await this.writeIfMissing(join(storyDir, "current_focus.md"), StateManager.defaultCurrentFocus(language));
|
|
57
|
+
// Ensure style_guide includes writing methodology even without reference text
|
|
58
|
+
const styleGuidePath = join(storyDir, "style_guide.md");
|
|
59
|
+
try {
|
|
60
|
+
const existing = await readFile(styleGuidePath, "utf-8");
|
|
61
|
+
if (!existing.includes("写作方法论") && !existing.includes("Writing Methodology")) {
|
|
62
|
+
const { buildWritingMethodologySection } = await import("../utils/writing-methodology.js");
|
|
63
|
+
await writeFile(styleGuidePath, `${existing}\n\n${buildWritingMethodologySection(language)}`, "utf-8");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
const { buildWritingMethodologySection } = await import("../utils/writing-methodology.js");
|
|
68
|
+
await writeFile(styleGuidePath, buildWritingMethodologySection(language), "utf-8");
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
async loadControlDocuments(bookId) {
|
|
72
|
+
await this.ensureControlDocuments(bookId);
|
|
73
|
+
const storyDir = join(this.bookDir(bookId), "story");
|
|
74
|
+
const runtimeDir = join(storyDir, "runtime");
|
|
75
|
+
const [authorIntent, currentFocus] = await Promise.all([
|
|
76
|
+
readFile(join(storyDir, "author_intent.md"), "utf-8"),
|
|
77
|
+
readFile(join(storyDir, "current_focus.md"), "utf-8"),
|
|
78
|
+
]);
|
|
79
|
+
return { authorIntent, currentFocus, runtimeDir };
|
|
80
|
+
}
|
|
81
|
+
async resolveControlDocumentLanguage(bookId) {
|
|
82
|
+
try {
|
|
83
|
+
const raw = await readFile(join(this.bookDir(bookId), "book.json"), "utf-8");
|
|
84
|
+
const parsed = JSON.parse(raw);
|
|
85
|
+
return parsed.language === "zh" ? "zh" : "en";
|
|
86
|
+
}
|
|
87
|
+
catch {
|
|
88
|
+
return "en";
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async acquireBookLock(bookId) {
|
|
92
|
+
await mkdir(this.bookDir(bookId), { recursive: true });
|
|
93
|
+
const lockPath = join(this.bookDir(bookId), ".write.lock");
|
|
94
|
+
const lockKey = this.normalizeLockKey(lockPath);
|
|
95
|
+
const existingOwner = processBookLocks.get(lockKey);
|
|
96
|
+
if (existingOwner) {
|
|
97
|
+
throw new BookWriteLockError(bookId, lockPath, this.describeLock(existingOwner.metadata));
|
|
98
|
+
}
|
|
99
|
+
const now = Date.now();
|
|
100
|
+
const owner = {
|
|
101
|
+
metadata: {
|
|
102
|
+
version: 1,
|
|
103
|
+
pid: process.pid,
|
|
104
|
+
token: randomUUID(),
|
|
105
|
+
startedAt: now,
|
|
106
|
+
heartbeatAt: now,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
// Reserve synchronously before the first filesystem await so two
|
|
110
|
+
// StateManager instances in this process cannot race through EEXIST and
|
|
111
|
+
// mistake the other one's live file for a stale same-process lock.
|
|
112
|
+
processBookLocks.set(lockKey, owner);
|
|
113
|
+
try {
|
|
114
|
+
let acquired = false;
|
|
115
|
+
for (let attempt = 0; attempt < 4 && !acquired; attempt++) {
|
|
116
|
+
try {
|
|
117
|
+
await this.createLockFile(lockPath, owner.metadata);
|
|
118
|
+
acquired = true;
|
|
119
|
+
}
|
|
120
|
+
catch (error) {
|
|
121
|
+
if (error?.code !== "EEXIST") {
|
|
122
|
+
throw error;
|
|
123
|
+
}
|
|
124
|
+
let snapshot;
|
|
125
|
+
try {
|
|
126
|
+
snapshot = await this.readLockSnapshot(lockPath);
|
|
127
|
+
}
|
|
128
|
+
catch (snapshotError) {
|
|
129
|
+
if (snapshotError?.code === "ENOENT") {
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
throw snapshotError;
|
|
133
|
+
}
|
|
134
|
+
if (!this.isStaleLock(snapshot.metadata, snapshot.mtimeMs)) {
|
|
135
|
+
throw new BookWriteLockError(bookId, lockPath, snapshot.raw);
|
|
136
|
+
}
|
|
137
|
+
await this.removeStaleLock(lockPath, snapshot.raw);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
if (!acquired) {
|
|
141
|
+
throw new BookWriteLockError(bookId, lockPath);
|
|
142
|
+
}
|
|
143
|
+
this.startLockHeartbeat(lockPath, lockKey, owner);
|
|
144
|
+
let released = false;
|
|
145
|
+
return async () => {
|
|
146
|
+
if (released)
|
|
147
|
+
return;
|
|
148
|
+
released = true;
|
|
149
|
+
if (owner.heartbeatTimer)
|
|
150
|
+
clearInterval(owner.heartbeatTimer);
|
|
151
|
+
await owner.heartbeatTask;
|
|
152
|
+
if (processBookLocks.get(lockKey)?.metadata.token === owner.metadata.token) {
|
|
153
|
+
processBookLocks.delete(lockKey);
|
|
154
|
+
}
|
|
155
|
+
try {
|
|
156
|
+
const snapshot = await this.readLockSnapshot(lockPath);
|
|
157
|
+
if (snapshot.metadata?.token !== owner.metadata.token) {
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
await this.unlinkWithRetry(lockPath);
|
|
161
|
+
}
|
|
162
|
+
catch (error) {
|
|
163
|
+
if (error?.code !== "ENOENT") {
|
|
164
|
+
console.warn(`[inkos] Failed to release book lock ${lockPath}: ${String(error)}`);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
catch (error) {
|
|
170
|
+
if (processBookLocks.get(lockKey)?.metadata.token === owner.metadata.token) {
|
|
171
|
+
processBookLocks.delete(lockKey);
|
|
172
|
+
}
|
|
173
|
+
throw error;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
normalizeLockKey(lockPath) {
|
|
177
|
+
const absolute = resolve(lockPath);
|
|
178
|
+
return process.platform === "win32" ? absolute.toLowerCase() : absolute;
|
|
179
|
+
}
|
|
180
|
+
serializeLock(metadata) {
|
|
181
|
+
return JSON.stringify(metadata);
|
|
182
|
+
}
|
|
183
|
+
describeLock(metadata) {
|
|
184
|
+
return `pid:${metadata.pid} started:${new Date(metadata.startedAt).toISOString()}`;
|
|
185
|
+
}
|
|
186
|
+
async createLockFile(lockPath, metadata) {
|
|
187
|
+
const handle = await open(lockPath, "wx");
|
|
188
|
+
try {
|
|
189
|
+
await handle.writeFile(this.serializeLock(metadata), "utf-8");
|
|
190
|
+
}
|
|
191
|
+
catch (error) {
|
|
192
|
+
await handle.close().catch(() => undefined);
|
|
193
|
+
await this.unlinkWithRetry(lockPath).catch(() => undefined);
|
|
194
|
+
throw error;
|
|
195
|
+
}
|
|
196
|
+
await handle.close();
|
|
197
|
+
}
|
|
198
|
+
parseLockMetadata(lockData) {
|
|
199
|
+
try {
|
|
200
|
+
const parsed = JSON.parse(lockData);
|
|
201
|
+
const pid = typeof parsed.pid === "number" ? parsed.pid : undefined;
|
|
202
|
+
const startedAt = typeof parsed.startedAt === "number" ? parsed.startedAt : undefined;
|
|
203
|
+
const heartbeatAt = typeof parsed.heartbeatAt === "number" ? parsed.heartbeatAt : startedAt;
|
|
204
|
+
return {
|
|
205
|
+
...(parsed.version === 1 ? { version: 1 } : {}),
|
|
206
|
+
...(pid !== undefined ? { pid } : {}),
|
|
207
|
+
...(typeof parsed.token === "string" ? { token: parsed.token } : {}),
|
|
208
|
+
...(startedAt !== undefined ? { startedAt } : {}),
|
|
209
|
+
...(heartbeatAt !== undefined ? { heartbeatAt } : {}),
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
catch {
|
|
213
|
+
const pid = this.extractLockPid(lockData);
|
|
214
|
+
const timestampMatch = lockData.match(/ts:(\d+)/);
|
|
215
|
+
const startedAt = timestampMatch ? Number.parseInt(timestampMatch[1] ?? "", 10) : undefined;
|
|
216
|
+
if (pid === undefined && startedAt === undefined)
|
|
217
|
+
return undefined;
|
|
218
|
+
return {
|
|
219
|
+
...(pid !== undefined ? { pid } : {}),
|
|
220
|
+
...(Number.isFinite(startedAt) ? { startedAt, heartbeatAt: startedAt } : {}),
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async readLockSnapshot(lockPath) {
|
|
225
|
+
const [raw, lockStat] = await Promise.all([
|
|
226
|
+
readFile(lockPath, "utf-8"),
|
|
227
|
+
stat(lockPath),
|
|
228
|
+
]);
|
|
229
|
+
return { raw, metadata: this.parseLockMetadata(raw), mtimeMs: lockStat.mtimeMs };
|
|
230
|
+
}
|
|
231
|
+
isStaleLock(metadata, mtimeMs) {
|
|
232
|
+
if (metadata?.pid === process.pid) {
|
|
233
|
+
// No processBookLocks owner existed before this acquisition reserved its
|
|
234
|
+
// slot, so a same-pid file here can only be orphaned from an older task.
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
if (metadata?.pid !== undefined && !this.isProcessAlive(metadata.pid)) {
|
|
238
|
+
return true;
|
|
239
|
+
}
|
|
240
|
+
const heartbeatAt = metadata?.heartbeatAt ?? mtimeMs;
|
|
241
|
+
const hasLeaseMetadata = metadata?.version === 1 && typeof metadata.token === "string";
|
|
242
|
+
return hasLeaseMetadata && Date.now() - heartbeatAt > BOOK_LOCK_LEASE_MS;
|
|
243
|
+
}
|
|
244
|
+
async removeStaleLock(lockPath, expectedRaw) {
|
|
245
|
+
const currentRaw = await readFile(lockPath, "utf-8").catch(() => undefined);
|
|
246
|
+
if (currentRaw === undefined)
|
|
247
|
+
return;
|
|
248
|
+
if (currentRaw !== expectedRaw) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
await this.unlinkWithRetry(lockPath);
|
|
252
|
+
}
|
|
253
|
+
startLockHeartbeat(lockPath, lockKey, owner) {
|
|
254
|
+
const refresh = async () => {
|
|
255
|
+
if (processBookLocks.get(lockKey)?.metadata.token !== owner.metadata.token)
|
|
256
|
+
return;
|
|
257
|
+
const handle = await open(lockPath, "r+");
|
|
258
|
+
try {
|
|
259
|
+
const currentRaw = await handle.readFile("utf-8");
|
|
260
|
+
if (this.parseLockMetadata(currentRaw)?.token !== owner.metadata.token)
|
|
261
|
+
return;
|
|
262
|
+
owner.metadata.heartbeatAt = Date.now();
|
|
263
|
+
const serialized = Buffer.from(this.serializeLock(owner.metadata), "utf-8");
|
|
264
|
+
await handle.write(serialized, 0, serialized.length, 0);
|
|
265
|
+
await handle.truncate(serialized.length);
|
|
266
|
+
}
|
|
267
|
+
finally {
|
|
268
|
+
await handle.close();
|
|
269
|
+
}
|
|
270
|
+
};
|
|
271
|
+
owner.heartbeatTimer = setInterval(() => {
|
|
272
|
+
if (owner.heartbeatTask)
|
|
273
|
+
return;
|
|
274
|
+
const task = refresh()
|
|
275
|
+
.catch((error) => {
|
|
276
|
+
console.warn(`[inkos] Failed to refresh book lock ${lockPath}: ${String(error)}`);
|
|
277
|
+
})
|
|
278
|
+
.finally(() => {
|
|
279
|
+
if (owner.heartbeatTask === task)
|
|
280
|
+
owner.heartbeatTask = undefined;
|
|
281
|
+
});
|
|
282
|
+
owner.heartbeatTask = task;
|
|
283
|
+
}, BOOK_LOCK_HEARTBEAT_MS);
|
|
284
|
+
owner.heartbeatTimer.unref?.();
|
|
285
|
+
}
|
|
286
|
+
async unlinkWithRetry(lockPath) {
|
|
287
|
+
for (let attempt = 0; attempt < BOOK_LOCK_RELEASE_RETRIES; attempt++) {
|
|
288
|
+
try {
|
|
289
|
+
await unlink(lockPath);
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
catch (error) {
|
|
293
|
+
const code = error?.code;
|
|
294
|
+
if (code === "ENOENT")
|
|
295
|
+
return;
|
|
296
|
+
const retryable = code === "EPERM" || code === "EACCES" || code === "EBUSY";
|
|
297
|
+
if (!retryable || attempt === BOOK_LOCK_RELEASE_RETRIES - 1)
|
|
298
|
+
throw error;
|
|
299
|
+
await new Promise((resolveDelay) => setTimeout(resolveDelay, 25 * (attempt + 1)));
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
extractLockPid(lockData) {
|
|
304
|
+
const match = lockData.match(/pid:(\d+)/);
|
|
305
|
+
if (!match)
|
|
306
|
+
return undefined;
|
|
307
|
+
const pid = Number.parseInt(match[1] ?? "", 10);
|
|
308
|
+
return Number.isInteger(pid) && pid > 0 ? pid : undefined;
|
|
309
|
+
}
|
|
310
|
+
isProcessAlive(pid) {
|
|
311
|
+
try {
|
|
312
|
+
process.kill(pid, 0);
|
|
313
|
+
return true;
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
const code = error?.code;
|
|
317
|
+
if (code === "ESRCH") {
|
|
318
|
+
return false;
|
|
319
|
+
}
|
|
320
|
+
return true;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
get booksDir() {
|
|
324
|
+
return join(this.projectRoot, "books");
|
|
325
|
+
}
|
|
326
|
+
bookDir(bookId) {
|
|
327
|
+
return join(this.booksDir, bookId);
|
|
328
|
+
}
|
|
329
|
+
stateDir(bookId) {
|
|
330
|
+
return join(this.bookDir(bookId), "story", "state");
|
|
331
|
+
}
|
|
332
|
+
async loadProjectConfig() {
|
|
333
|
+
const configPath = join(this.projectRoot, "inkos.json");
|
|
334
|
+
const raw = await readFile(configPath, "utf-8");
|
|
335
|
+
return JSON.parse(raw);
|
|
336
|
+
}
|
|
337
|
+
async saveProjectConfig(config) {
|
|
338
|
+
const configPath = join(this.projectRoot, "inkos.json");
|
|
339
|
+
await writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
340
|
+
}
|
|
341
|
+
async loadBookConfig(bookId) {
|
|
342
|
+
const configPath = join(this.bookDir(bookId), "book.json");
|
|
343
|
+
const raw = await readFile(configPath, "utf-8");
|
|
344
|
+
if (!raw.trim()) {
|
|
345
|
+
throw new Error(`book.json is empty for book "${bookId}"`);
|
|
346
|
+
}
|
|
347
|
+
return JSON.parse(raw);
|
|
348
|
+
}
|
|
349
|
+
async saveBookConfig(bookId, config) {
|
|
350
|
+
await this.saveBookConfigAt(this.bookDir(bookId), config);
|
|
351
|
+
}
|
|
352
|
+
async saveBookConfigAt(bookDir, config) {
|
|
353
|
+
await mkdir(bookDir, { recursive: true });
|
|
354
|
+
await writeFile(join(bookDir, "book.json"), JSON.stringify(config, null, 2), "utf-8");
|
|
355
|
+
}
|
|
356
|
+
async ensureRuntimeState(bookId, fallbackChapter = 0) {
|
|
357
|
+
await bootstrapStructuredStateFromMarkdown({
|
|
358
|
+
bookDir: this.bookDir(bookId),
|
|
359
|
+
fallbackChapter,
|
|
360
|
+
});
|
|
361
|
+
}
|
|
362
|
+
async listBooks() {
|
|
363
|
+
try {
|
|
364
|
+
const entries = await readdir(this.booksDir);
|
|
365
|
+
const bookIds = [];
|
|
366
|
+
for (const entry of entries) {
|
|
367
|
+
const bookJsonPath = join(this.booksDir, entry, "book.json");
|
|
368
|
+
try {
|
|
369
|
+
await stat(bookJsonPath);
|
|
370
|
+
bookIds.push(entry);
|
|
371
|
+
}
|
|
372
|
+
catch {
|
|
373
|
+
// not a book directory
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
return bookIds;
|
|
377
|
+
}
|
|
378
|
+
catch {
|
|
379
|
+
return [];
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
async getNextChapterNumber(bookId) {
|
|
383
|
+
const durableChapter = await resolveDurableStoryProgress({
|
|
384
|
+
bookDir: this.bookDir(bookId),
|
|
385
|
+
});
|
|
386
|
+
// Ensure structured state is bootstrapped (side-effect: creates missing
|
|
387
|
+
// JSON files), but do NOT trust its chapter number for progress — only
|
|
388
|
+
// the contiguous durable artifact chain is authoritative.
|
|
389
|
+
await bootstrapStructuredStateFromMarkdown({
|
|
390
|
+
bookDir: this.bookDir(bookId),
|
|
391
|
+
fallbackChapter: durableChapter,
|
|
392
|
+
});
|
|
393
|
+
return durableChapter + 1;
|
|
394
|
+
}
|
|
395
|
+
async getPersistedChapterCount(bookId) {
|
|
396
|
+
const chaptersDir = join(this.bookDir(bookId), "chapters");
|
|
397
|
+
const chapterNumbers = new Set();
|
|
398
|
+
try {
|
|
399
|
+
const files = await readdir(chaptersDir);
|
|
400
|
+
for (const file of files) {
|
|
401
|
+
const match = file.match(/^(\d+)_.*\.md$/);
|
|
402
|
+
if (!match)
|
|
403
|
+
continue;
|
|
404
|
+
chapterNumbers.add(parseInt(match[1], 10));
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
catch {
|
|
408
|
+
return 0;
|
|
409
|
+
}
|
|
410
|
+
return chapterNumbers.size;
|
|
411
|
+
}
|
|
412
|
+
async loadChapterIndex(bookId) {
|
|
413
|
+
const indexPath = join(this.bookDir(bookId), "chapters", "index.json");
|
|
414
|
+
try {
|
|
415
|
+
const raw = await readFile(indexPath, "utf-8");
|
|
416
|
+
const parsed = JSON.parse(raw);
|
|
417
|
+
if (Array.isArray(parsed) && parsed.length > 0)
|
|
418
|
+
return parsed;
|
|
419
|
+
if (Array.isArray(parsed)) {
|
|
420
|
+
const rebuilt = await this.rebuildChapterIndexFromFiles(bookId);
|
|
421
|
+
return rebuilt.length > 0 ? rebuilt : parsed;
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
const rebuilt = await this.rebuildChapterIndexFromFiles(bookId);
|
|
426
|
+
if (rebuilt.length > 0)
|
|
427
|
+
return rebuilt;
|
|
428
|
+
}
|
|
429
|
+
return [];
|
|
430
|
+
}
|
|
431
|
+
async rebuildChapterIndexFromFiles(bookId) {
|
|
432
|
+
return this.rebuildChapterIndexFromFilesAt(this.bookDir(bookId));
|
|
433
|
+
}
|
|
434
|
+
async rebuildChapterIndexFromFilesAt(bookDir) {
|
|
435
|
+
const chaptersDir = join(bookDir, "chapters");
|
|
436
|
+
let files;
|
|
437
|
+
try {
|
|
438
|
+
files = await readdir(chaptersDir);
|
|
439
|
+
}
|
|
440
|
+
catch {
|
|
441
|
+
return [];
|
|
442
|
+
}
|
|
443
|
+
const rows = await Promise.all(files.flatMap(async (file) => {
|
|
444
|
+
const match = file.match(/^(\d+)[_-]?(.*?)\.md$/);
|
|
445
|
+
if (!match)
|
|
446
|
+
return [];
|
|
447
|
+
const number = parseInt(match[1], 10);
|
|
448
|
+
if (!Number.isFinite(number) || number <= 0)
|
|
449
|
+
return [];
|
|
450
|
+
const filePath = join(chaptersDir, file);
|
|
451
|
+
const [metadata, content] = await Promise.all([
|
|
452
|
+
stat(filePath).catch(() => null),
|
|
453
|
+
readFile(filePath, "utf-8").catch(() => ""),
|
|
454
|
+
]);
|
|
455
|
+
const timestamp = (metadata?.mtime ?? new Date()).toISOString();
|
|
456
|
+
const rawTitle = match[2]?.replace(/^_+/, "").replace(/_/g, " ").trim();
|
|
457
|
+
return [{
|
|
458
|
+
number,
|
|
459
|
+
title: rawTitle || `第${number}章`,
|
|
460
|
+
status: "ready-for-review",
|
|
461
|
+
wordCount: content.replace(/\s+/g, "").length,
|
|
462
|
+
createdAt: timestamp,
|
|
463
|
+
updatedAt: timestamp,
|
|
464
|
+
auditIssues: [],
|
|
465
|
+
lengthWarnings: [],
|
|
466
|
+
}];
|
|
467
|
+
}));
|
|
468
|
+
return rows
|
|
469
|
+
.flat()
|
|
470
|
+
.sort((a, b) => a.number - b.number);
|
|
471
|
+
}
|
|
472
|
+
async saveChapterIndex(bookId, index, options = {}) {
|
|
473
|
+
await this.saveChapterIndexAt(this.bookDir(bookId), index, options);
|
|
474
|
+
}
|
|
475
|
+
async saveChapterIndexAt(bookDir, index, options = {}) {
|
|
476
|
+
const chaptersDir = join(bookDir, "chapters");
|
|
477
|
+
await mkdir(chaptersDir, { recursive: true });
|
|
478
|
+
const safeIndex = index.length === 0 && !options.allowEmptyWithChapterFiles
|
|
479
|
+
? await this.rebuildChapterIndexFromFilesAt(bookDir).then((rebuilt) => rebuilt.length > 0 ? rebuilt : index)
|
|
480
|
+
: index;
|
|
481
|
+
await writeFile(join(chaptersDir, "index.json"), JSON.stringify(safeIndex, null, 2), "utf-8");
|
|
482
|
+
}
|
|
483
|
+
async snapshotState(bookId, chapterNumber) {
|
|
484
|
+
await this.snapshotStateAt(this.bookDir(bookId), chapterNumber);
|
|
485
|
+
}
|
|
486
|
+
async snapshotStateAt(bookDir, chapterNumber) {
|
|
487
|
+
const storyDir = join(bookDir, "story");
|
|
488
|
+
const snapshotDir = join(storyDir, "snapshots", String(chapterNumber));
|
|
489
|
+
await mkdir(snapshotDir, { recursive: true });
|
|
490
|
+
const files = [
|
|
491
|
+
"current_state.md", "particle_ledger.md", "pending_hooks.md",
|
|
492
|
+
"chapter_summaries.md", "subplot_board.md", "emotional_arcs.md", "character_matrix.md",
|
|
493
|
+
];
|
|
494
|
+
await Promise.all(files.map(async (f) => {
|
|
495
|
+
try {
|
|
496
|
+
const content = await readFile(join(storyDir, f), "utf-8");
|
|
497
|
+
await writeFile(join(snapshotDir, f), content, "utf-8");
|
|
498
|
+
}
|
|
499
|
+
catch {
|
|
500
|
+
// file doesn't exist yet
|
|
501
|
+
}
|
|
502
|
+
}));
|
|
503
|
+
const stateDir = join(bookDir, "story", "state");
|
|
504
|
+
const snapshotStateDir = join(snapshotDir, "state");
|
|
505
|
+
try {
|
|
506
|
+
const stateFiles = await readdir(stateDir);
|
|
507
|
+
if (stateFiles.length > 0) {
|
|
508
|
+
await mkdir(snapshotStateDir, { recursive: true });
|
|
509
|
+
await Promise.all(stateFiles.map(async (fileName) => {
|
|
510
|
+
const content = await readFile(join(stateDir, fileName), "utf-8");
|
|
511
|
+
await writeFile(join(snapshotStateDir, fileName), content, "utf-8");
|
|
512
|
+
}));
|
|
513
|
+
}
|
|
514
|
+
}
|
|
515
|
+
catch {
|
|
516
|
+
// state directory missing — skip
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
async isCompleteBookDirectory(bookDir) {
|
|
520
|
+
// Phase 5 cleanup: prefer outline/* paths, fall back to legacy flat files
|
|
521
|
+
// so older books on disk still resolve as complete.
|
|
522
|
+
const requiredSingle = [
|
|
523
|
+
join(bookDir, "book.json"),
|
|
524
|
+
join(bookDir, "story", "book_rules.md"),
|
|
525
|
+
join(bookDir, "story", "current_state.md"),
|
|
526
|
+
join(bookDir, "story", "pending_hooks.md"),
|
|
527
|
+
join(bookDir, "chapters", "index.json"),
|
|
528
|
+
];
|
|
529
|
+
const eitherOr = [
|
|
530
|
+
// story_frame (new) OR story_bible (legacy)
|
|
531
|
+
[
|
|
532
|
+
join(bookDir, "story", "outline", "story_frame.md"),
|
|
533
|
+
join(bookDir, "story", "story_bible.md"),
|
|
534
|
+
],
|
|
535
|
+
// volume_map (new) OR volume_outline (legacy)
|
|
536
|
+
[
|
|
537
|
+
join(bookDir, "story", "outline", "volume_map.md"),
|
|
538
|
+
join(bookDir, "story", "volume_outline.md"),
|
|
539
|
+
],
|
|
540
|
+
];
|
|
541
|
+
for (const requiredPath of requiredSingle) {
|
|
542
|
+
try {
|
|
543
|
+
await stat(requiredPath);
|
|
544
|
+
}
|
|
545
|
+
catch {
|
|
546
|
+
return false;
|
|
547
|
+
}
|
|
548
|
+
}
|
|
549
|
+
for (const alternatives of eitherOr) {
|
|
550
|
+
let found = false;
|
|
551
|
+
for (const candidate of alternatives) {
|
|
552
|
+
try {
|
|
553
|
+
await stat(candidate);
|
|
554
|
+
found = true;
|
|
555
|
+
break;
|
|
556
|
+
}
|
|
557
|
+
catch {
|
|
558
|
+
// try next alternative
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
if (!found)
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
return true;
|
|
565
|
+
}
|
|
566
|
+
async restoreState(bookId, chapterNumber) {
|
|
567
|
+
const storyDir = join(this.bookDir(bookId), "story");
|
|
568
|
+
const snapshotDir = join(storyDir, "snapshots", String(chapterNumber));
|
|
569
|
+
const files = [
|
|
570
|
+
"current_state.md", "particle_ledger.md", "pending_hooks.md",
|
|
571
|
+
"chapter_summaries.md", "subplot_board.md", "emotional_arcs.md", "character_matrix.md",
|
|
572
|
+
];
|
|
573
|
+
try {
|
|
574
|
+
// current_state.md and pending_hooks.md are required;
|
|
575
|
+
// particle_ledger.md is optional (numericalSystem=false genres don't have it)
|
|
576
|
+
// the rest are optional (may not exist in older snapshots)
|
|
577
|
+
const requiredFiles = ["current_state.md", "pending_hooks.md"];
|
|
578
|
+
const optionalFiles = files.filter((f) => !requiredFiles.includes(f));
|
|
579
|
+
await Promise.all(requiredFiles.map(async (f) => {
|
|
580
|
+
const content = await readFile(join(snapshotDir, f), "utf-8");
|
|
581
|
+
await writeFile(join(storyDir, f), content, "utf-8");
|
|
582
|
+
}));
|
|
583
|
+
await Promise.all(optionalFiles.map(async (f) => {
|
|
584
|
+
const targetPath = join(storyDir, f);
|
|
585
|
+
try {
|
|
586
|
+
const content = await readFile(join(snapshotDir, f), "utf-8");
|
|
587
|
+
await writeFile(targetPath, content, "utf-8");
|
|
588
|
+
}
|
|
589
|
+
catch {
|
|
590
|
+
await rm(targetPath, { force: true });
|
|
591
|
+
}
|
|
592
|
+
}));
|
|
593
|
+
const stateDir = this.stateDir(bookId);
|
|
594
|
+
let restoredStructuredState = false;
|
|
595
|
+
try {
|
|
596
|
+
const snapshotStateDir = join(snapshotDir, "state");
|
|
597
|
+
const stateFiles = await readdir(snapshotStateDir);
|
|
598
|
+
if (stateFiles.length > 0) {
|
|
599
|
+
restoredStructuredState = true;
|
|
600
|
+
await mkdir(stateDir, { recursive: true });
|
|
601
|
+
await Promise.all(stateFiles.map(async (fileName) => {
|
|
602
|
+
const content = await readFile(join(snapshotStateDir, fileName), "utf-8");
|
|
603
|
+
await writeFile(join(stateDir, fileName), content, "utf-8");
|
|
604
|
+
}));
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
catch {
|
|
608
|
+
// snapshot structured state missing — skip
|
|
609
|
+
}
|
|
610
|
+
if (!restoredStructuredState) {
|
|
611
|
+
await rm(stateDir, { recursive: true, force: true });
|
|
612
|
+
}
|
|
613
|
+
return true;
|
|
614
|
+
}
|
|
615
|
+
catch {
|
|
616
|
+
return false;
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* Roll back state to the snapshot at `targetChapter`, removing all chapters
|
|
621
|
+
* after it and their associated files (chapter markdown, snapshots, runtime).
|
|
622
|
+
* Used by review reject to undo a bad chapter and everything that followed.
|
|
623
|
+
*
|
|
624
|
+
* Returns the list of chapter numbers that were discarded.
|
|
625
|
+
*/
|
|
626
|
+
async rollbackToChapter(bookId, targetChapter) {
|
|
627
|
+
const restored = await this.restoreState(bookId, targetChapter);
|
|
628
|
+
if (!restored) {
|
|
629
|
+
throw new Error(`Cannot restore snapshot for chapter ${targetChapter} in "${bookId}"`);
|
|
630
|
+
}
|
|
631
|
+
const bookDir = this.bookDir(bookId);
|
|
632
|
+
const chaptersDir = join(bookDir, "chapters");
|
|
633
|
+
const index = await this.loadChapterIndex(bookId);
|
|
634
|
+
const kept = [];
|
|
635
|
+
const discarded = [];
|
|
636
|
+
for (const entry of index) {
|
|
637
|
+
if (entry.number <= targetChapter) {
|
|
638
|
+
kept.push(entry);
|
|
639
|
+
}
|
|
640
|
+
else {
|
|
641
|
+
discarded.push(entry.number);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
// Delete chapter markdown files for discarded chapters
|
|
645
|
+
try {
|
|
646
|
+
const files = await readdir(chaptersDir);
|
|
647
|
+
for (const file of files) {
|
|
648
|
+
const match = file.match(/^(\d+)_.*\.md$/);
|
|
649
|
+
if (!match)
|
|
650
|
+
continue;
|
|
651
|
+
const num = parseInt(match[1], 10);
|
|
652
|
+
if (num > targetChapter) {
|
|
653
|
+
await unlink(join(chaptersDir, file)).catch(() => { });
|
|
654
|
+
}
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
catch {
|
|
658
|
+
// chapters directory missing
|
|
659
|
+
}
|
|
660
|
+
// Delete snapshots for discarded chapters
|
|
661
|
+
const snapshotsDir = join(bookDir, "story", "snapshots");
|
|
662
|
+
try {
|
|
663
|
+
const snapshots = await readdir(snapshotsDir);
|
|
664
|
+
for (const snap of snapshots) {
|
|
665
|
+
const num = parseInt(snap, 10);
|
|
666
|
+
if (Number.isFinite(num) && num > targetChapter) {
|
|
667
|
+
await rm(join(snapshotsDir, snap), { recursive: true, force: true });
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
}
|
|
671
|
+
catch {
|
|
672
|
+
// snapshots directory missing
|
|
673
|
+
}
|
|
674
|
+
// Delete runtime artifacts for discarded chapters
|
|
675
|
+
const runtimeDir = join(bookDir, "story", "runtime");
|
|
676
|
+
try {
|
|
677
|
+
const runtimeFiles = await readdir(runtimeDir);
|
|
678
|
+
for (const file of runtimeFiles) {
|
|
679
|
+
const match = file.match(/^chapter-(\d+)\./);
|
|
680
|
+
if (!match)
|
|
681
|
+
continue;
|
|
682
|
+
const num = parseInt(match[1], 10);
|
|
683
|
+
if (num > targetChapter) {
|
|
684
|
+
await unlink(join(runtimeDir, file)).catch(() => { });
|
|
685
|
+
}
|
|
686
|
+
}
|
|
687
|
+
}
|
|
688
|
+
catch {
|
|
689
|
+
// runtime directory missing
|
|
690
|
+
}
|
|
691
|
+
// Also check story/drafts/ for discarded chapter files
|
|
692
|
+
const draftsDir = join(bookDir, "story", "drafts");
|
|
693
|
+
try {
|
|
694
|
+
const draftFiles = await readdir(draftsDir);
|
|
695
|
+
for (const file of draftFiles) {
|
|
696
|
+
const match = file.match(/^(\d+)_.*\.md$/);
|
|
697
|
+
if (!match)
|
|
698
|
+
continue;
|
|
699
|
+
const num = parseInt(match[1], 10);
|
|
700
|
+
if (num > targetChapter) {
|
|
701
|
+
await unlink(join(draftsDir, file)).catch(() => { });
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
}
|
|
705
|
+
catch {
|
|
706
|
+
// drafts directory missing
|
|
707
|
+
}
|
|
708
|
+
// Drop any persisted sqlite acceleration index so discarded chapters
|
|
709
|
+
// cannot leak back into retrieval after the markdown/state rollback.
|
|
710
|
+
await Promise.all([
|
|
711
|
+
rm(join(bookDir, "story", "memory.db"), { force: true }),
|
|
712
|
+
rm(join(bookDir, "story", "memory.db-shm"), { force: true }),
|
|
713
|
+
rm(join(bookDir, "story", "memory.db-wal"), { force: true }),
|
|
714
|
+
]);
|
|
715
|
+
await this.saveChapterIndex(bookId, kept);
|
|
716
|
+
return discarded;
|
|
717
|
+
}
|
|
718
|
+
async writeIfMissing(path, content) {
|
|
719
|
+
try {
|
|
720
|
+
await stat(path);
|
|
721
|
+
}
|
|
722
|
+
catch {
|
|
723
|
+
await writeFile(path, content, "utf-8");
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
//# sourceMappingURL=manager.js.map
|