@zwbigi/ink-xy 0.1.2 → 0.1.4
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/.next/BUILD_ID +1 -1
- package/.next/app-path-routes-manifest.json +2 -2
- package/.next/build-manifest.json +2 -2
- package/.next/server/app/_global-error.html +1 -1
- package/.next/server/app/_global-error.rsc +1 -1
- package/.next/server/app/_global-error.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_global-error.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_global-error.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/_not-found.html +1 -1
- package/.next/server/app/_not-found.rsc +1 -1
- package/.next/server/app/_not-found.segments/_full.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_head.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_index.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_not-found.segment.rsc +1 -1
- package/.next/server/app/_not-found.segments/_tree.segment.rsc +1 -1
- package/.next/server/app/api/inkos/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/install/route.js.nft.json +1 -1
- package/.next/server/app/api/skills/search/route.js.nft.json +1 -1
- package/.next/server/app/index.html +1 -1
- package/.next/server/app/index.rsc +1 -1
- package/.next/server/app/index.segments/__PAGE__.segment.rsc +1 -1
- package/.next/server/app/index.segments/_full.segment.rsc +1 -1
- package/.next/server/app/index.segments/_head.segment.rsc +1 -1
- package/.next/server/app/index.segments/_index.segment.rsc +1 -1
- package/.next/server/app/index.segments/_tree.segment.rsc +1 -1
- package/.next/server/app-paths-manifest.json +2 -2
- package/.next/server/chunks/162.js +1 -1
- package/.next/server/middleware-build-manifest.js +1 -1
- package/.next/server/pages/404.html +1 -1
- package/.next/server/pages/500.html +1 -1
- package/.next/trace +4 -4
- package/.next/trace-build +1 -1
- package/bin/pi-web.js +4 -1
- package/inkos/.env.example +20 -0
- package/inkos/.node-version +1 -0
- package/inkos/.nvmrc +1 -0
- package/inkos/CHANGELOG.md +787 -0
- package/inkos/CONTRIBUTING.md +89 -0
- package/inkos/LICENSE +661 -0
- package/inkos/README.en.md +483 -0
- package/inkos/README.ja.md +461 -0
- package/inkos/README.md +272 -0
- package/inkos/assets/15qun.jpg +0 -0
- package/inkos/assets/41777702961_.pic.jpg +0 -0
- package/inkos/assets/inkos-short-demo-cover.png +0 -0
- package/inkos/assets/inkos-text.svg +40 -0
- package/inkos/assets/logo.svg +47 -0
- package/inkos/assets/screenshot-chapters.png +0 -0
- package/inkos/assets/screenshot-pipeline.png +0 -0
- package/inkos/assets/screenshot-state.png +0 -0
- package/inkos/assets/screenshot-terminal.png +0 -0
- package/inkos/assets/wechat-group-v8.jpg +0 -0
- package/inkos/package.json +42 -0
- package/inkos/packages/cli/package.json +74 -0
- package/inkos/packages/cli/src/__tests__/analytics.test.ts +154 -0
- package/inkos/packages/cli/src/__tests__/cli-integration.test.ts +1031 -0
- package/inkos/packages/cli/src/__tests__/daemon.test.ts +93 -0
- package/inkos/packages/cli/src/__tests__/doctor.test.ts +36 -0
- package/inkos/packages/cli/src/__tests__/interact-command.test.ts +142 -0
- package/inkos/packages/cli/src/__tests__/interaction-tools.test.ts +107 -0
- package/inkos/packages/cli/src/__tests__/llm-overrides.test.ts +25 -0
- package/inkos/packages/cli/src/__tests__/localization.test.ts +121 -0
- package/inkos/packages/cli/src/__tests__/progress-text.test.ts +92 -0
- package/inkos/packages/cli/src/__tests__/project-bootstrap.test.ts +71 -0
- package/inkos/packages/cli/src/__tests__/publish-package.test.ts +272 -0
- package/inkos/packages/cli/src/__tests__/revision-command.test.ts +82 -0
- package/inkos/packages/cli/src/__tests__/runtime-requirements.test.ts +89 -0
- package/inkos/packages/cli/src/__tests__/short-fiction-command.test.ts +48 -0
- package/inkos/packages/cli/src/__tests__/studio-runtime.test.ts +142 -0
- package/inkos/packages/cli/src/__tests__/studio.test.ts +87 -0
- package/inkos/packages/cli/src/__tests__/tui-activity-state.test.ts +20 -0
- package/inkos/packages/cli/src/__tests__/tui-agent-session.test.ts +213 -0
- package/inkos/packages/cli/src/__tests__/tui-chat-depth.test.ts +27 -0
- package/inkos/packages/cli/src/__tests__/tui-chat-draft.test.ts +44 -0
- package/inkos/packages/cli/src/__tests__/tui-command.test.ts +86 -0
- package/inkos/packages/cli/src/__tests__/tui-composer-caret.test.ts +46 -0
- package/inkos/packages/cli/src/__tests__/tui-composer-display.test.ts +40 -0
- package/inkos/packages/cli/src/__tests__/tui-dashboard.test.tsx +219 -0
- package/inkos/packages/cli/src/__tests__/tui-effects-i18n.test.ts +29 -0
- package/inkos/packages/cli/src/__tests__/tui-i18n.test.ts +22 -0
- package/inkos/packages/cli/src/__tests__/tui-input-chrome.test.ts +10 -0
- package/inkos/packages/cli/src/__tests__/tui-input-history.test.ts +40 -0
- package/inkos/packages/cli/src/__tests__/tui-layout.test.ts +55 -0
- package/inkos/packages/cli/src/__tests__/tui-local-commands.test.ts +47 -0
- package/inkos/packages/cli/src/__tests__/tui-session-store.test.ts +81 -0
- package/inkos/packages/cli/src/__tests__/tui-setup-i18n.test.ts +31 -0
- package/inkos/packages/cli/src/__tests__/tui-slash-autocomplete.test.ts +33 -0
- package/inkos/packages/cli/src/commands/agent.ts +65 -0
- package/inkos/packages/cli/src/commands/analytics.ts +77 -0
- package/inkos/packages/cli/src/commands/audit.ts +52 -0
- package/inkos/packages/cli/src/commands/book.ts +260 -0
- package/inkos/packages/cli/src/commands/compose.ts +50 -0
- package/inkos/packages/cli/src/commands/config.ts +328 -0
- package/inkos/packages/cli/src/commands/consolidate.ts +50 -0
- package/inkos/packages/cli/src/commands/daemon.ts +121 -0
- package/inkos/packages/cli/src/commands/detect.ts +125 -0
- package/inkos/packages/cli/src/commands/doctor.ts +391 -0
- package/inkos/packages/cli/src/commands/draft.ts +43 -0
- package/inkos/packages/cli/src/commands/eval.ts +217 -0
- package/inkos/packages/cli/src/commands/export.ts +45 -0
- package/inkos/packages/cli/src/commands/fanfic.ts +183 -0
- package/inkos/packages/cli/src/commands/genre.ts +160 -0
- package/inkos/packages/cli/src/commands/import.ts +158 -0
- package/inkos/packages/cli/src/commands/init.ts +47 -0
- package/inkos/packages/cli/src/commands/interact.ts +109 -0
- package/inkos/packages/cli/src/commands/plan.ts +54 -0
- package/inkos/packages/cli/src/commands/radar.ts +60 -0
- package/inkos/packages/cli/src/commands/review.ts +253 -0
- package/inkos/packages/cli/src/commands/revise.ts +58 -0
- package/inkos/packages/cli/src/commands/short-fiction.ts +294 -0
- package/inkos/packages/cli/src/commands/status.ts +138 -0
- package/inkos/packages/cli/src/commands/studio.ts +194 -0
- package/inkos/packages/cli/src/commands/style.ts +99 -0
- package/inkos/packages/cli/src/commands/tui.ts +18 -0
- package/inkos/packages/cli/src/commands/update.ts +45 -0
- package/inkos/packages/cli/src/commands/write.ts +324 -0
- package/inkos/packages/cli/src/index.ts +5 -0
- package/inkos/packages/cli/src/interaction/tools.ts +49 -0
- package/inkos/packages/cli/src/localization.ts +215 -0
- package/inkos/packages/cli/src/program.ts +106 -0
- package/inkos/packages/cli/src/progress-text.ts +85 -0
- package/inkos/packages/cli/src/project-bootstrap.ts +175 -0
- package/inkos/packages/cli/src/runtime-requirements.ts +135 -0
- package/inkos/packages/cli/src/tui/__tests__/markdown.test.ts +64 -0
- package/inkos/packages/cli/src/tui/activity-state.ts +41 -0
- package/inkos/packages/cli/src/tui/agent-input.ts +264 -0
- package/inkos/packages/cli/src/tui/ansi.ts +72 -0
- package/inkos/packages/cli/src/tui/app.ts +130 -0
- package/inkos/packages/cli/src/tui/chat-depth.ts +22 -0
- package/inkos/packages/cli/src/tui/chat-draft.ts +42 -0
- package/inkos/packages/cli/src/tui/composer-caret.ts +22 -0
- package/inkos/packages/cli/src/tui/composer-display.ts +26 -0
- package/inkos/packages/cli/src/tui/dashboard-model.ts +164 -0
- package/inkos/packages/cli/src/tui/dashboard.tsx +544 -0
- package/inkos/packages/cli/src/tui/effects.ts +542 -0
- package/inkos/packages/cli/src/tui/i18n.ts +278 -0
- package/inkos/packages/cli/src/tui/input-history.ts +69 -0
- package/inkos/packages/cli/src/tui/local-commands.ts +55 -0
- package/inkos/packages/cli/src/tui/markdown.ts +64 -0
- package/inkos/packages/cli/src/tui/session-store.ts +6 -0
- package/inkos/packages/cli/src/tui/setup.ts +397 -0
- package/inkos/packages/cli/src/tui/slash-autocomplete.ts +62 -0
- package/inkos/packages/cli/src/tui/theme.ts +17 -0
- package/inkos/packages/cli/src/utils.ts +222 -0
- package/inkos/packages/cli/tsconfig.json +9 -0
- package/inkos/packages/core/genres/cozy.md +43 -0
- package/inkos/packages/core/genres/cultivation.md +42 -0
- package/inkos/packages/core/genres/dungeon-core.md +40 -0
- package/inkos/packages/core/genres/horror.md +51 -0
- package/inkos/packages/core/genres/isekai.md +43 -0
- package/inkos/packages/core/genres/litrpg.md +43 -0
- package/inkos/packages/core/genres/other.md +24 -0
- package/inkos/packages/core/genres/progression.md +41 -0
- package/inkos/packages/core/genres/romantasy.md +45 -0
- package/inkos/packages/core/genres/sci-fi.md +42 -0
- package/inkos/packages/core/genres/system-apocalypse.md +40 -0
- package/inkos/packages/core/genres/tower-climber.md +41 -0
- package/inkos/packages/core/genres/urban.md +53 -0
- package/inkos/packages/core/genres/xianxia.md +46 -0
- package/inkos/packages/core/genres/xuanhuan.md +64 -0
- package/inkos/packages/core/package.json +61 -0
- package/inkos/packages/core/src/__tests__/agent-max-tokens-policy.test.ts +29 -0
- package/inkos/packages/core/src/__tests__/agent-session.test.ts +866 -0
- package/inkos/packages/core/src/__tests__/agent-system-prompt.test.ts +167 -0
- package/inkos/packages/core/src/__tests__/agent-tools-params.test.ts +197 -0
- package/inkos/packages/core/src/__tests__/agent-tools.test.ts +421 -0
- package/inkos/packages/core/src/__tests__/ai-tells.test.ts +90 -0
- package/inkos/packages/core/src/__tests__/architect-phase5-consolidated.test.ts +445 -0
- package/inkos/packages/core/src/__tests__/architect-phase5.test.ts +455 -0
- package/inkos/packages/core/src/__tests__/architect-phase7.test.ts +210 -0
- package/inkos/packages/core/src/__tests__/architect.test.ts +859 -0
- package/inkos/packages/core/src/__tests__/audit-parse.test.ts +78 -0
- package/inkos/packages/core/src/__tests__/book-id.test.ts +26 -0
- package/inkos/packages/core/src/__tests__/book-session-store.test.ts +447 -0
- package/inkos/packages/core/src/__tests__/book-session.test.ts +113 -0
- package/inkos/packages/core/src/__tests__/chapter-analyzer.test.ts +574 -0
- package/inkos/packages/core/src/__tests__/chapter-memo-parser.test.ts +247 -0
- package/inkos/packages/core/src/__tests__/chapter-persistence.test.ts +198 -0
- package/inkos/packages/core/src/__tests__/chapter-review-cycle.test.ts +294 -0
- package/inkos/packages/core/src/__tests__/chapter-splitter.test.ts +156 -0
- package/inkos/packages/core/src/__tests__/chapter-state-recovery.test.ts +235 -0
- package/inkos/packages/core/src/__tests__/chapter-truth-validation.test.ts +253 -0
- package/inkos/packages/core/src/__tests__/composer.test.ts +627 -0
- package/inkos/packages/core/src/__tests__/config-loader.test.ts +325 -0
- package/inkos/packages/core/src/__tests__/config-migration.test.ts +102 -0
- package/inkos/packages/core/src/__tests__/consolidator.test.ts +32 -0
- package/inkos/packages/core/src/__tests__/context-filter.test.ts +60 -0
- package/inkos/packages/core/src/__tests__/context-transform.test.ts +108 -0
- package/inkos/packages/core/src/__tests__/continuity.test.ts +391 -0
- package/inkos/packages/core/src/__tests__/detection-insights.test.ts +59 -0
- package/inkos/packages/core/src/__tests__/detector.test.ts +86 -0
- package/inkos/packages/core/src/__tests__/draft-directive-parser.test.ts +386 -0
- package/inkos/packages/core/src/__tests__/edit-controller.test.ts +190 -0
- package/inkos/packages/core/src/__tests__/effective-llm-config.test.ts +486 -0
- package/inkos/packages/core/src/__tests__/fanfic-dimensions.test.ts +58 -0
- package/inkos/packages/core/src/__tests__/fanfic-models.test.ts +69 -0
- package/inkos/packages/core/src/__tests__/governed-working-set.test.ts +155 -0
- package/inkos/packages/core/src/__tests__/hook-arbiter.test.ts +124 -0
- package/inkos/packages/core/src/__tests__/hook-governance.test.ts +228 -0
- package/inkos/packages/core/src/__tests__/hook-health.test.ts +166 -0
- package/inkos/packages/core/src/__tests__/hook-ledger-validator.test.ts +236 -0
- package/inkos/packages/core/src/__tests__/hook-promotion.test.ts +192 -0
- package/inkos/packages/core/src/__tests__/hook-stale-detection.test.ts +136 -0
- package/inkos/packages/core/src/__tests__/index-notify-lazy.test.ts +20 -0
- package/inkos/packages/core/src/__tests__/interaction-chat-tokens.test.ts +170 -0
- package/inkos/packages/core/src/__tests__/interaction-models.test.ts +155 -0
- package/inkos/packages/core/src/__tests__/interaction-nl-router.test.ts +223 -0
- package/inkos/packages/core/src/__tests__/interaction-runtime.test.ts +633 -0
- package/inkos/packages/core/src/__tests__/interaction-tools.test.ts +343 -0
- package/inkos/packages/core/src/__tests__/length-metrics.test.ts +82 -0
- package/inkos/packages/core/src/__tests__/length-normalizer.test.ts +331 -0
- package/inkos/packages/core/src/__tests__/list-models.test.ts +109 -0
- package/inkos/packages/core/src/__tests__/llm-env.test.ts +31 -0
- package/inkos/packages/core/src/__tests__/logger.test.ts +175 -0
- package/inkos/packages/core/src/__tests__/long-span-fatigue.test.ts +160 -0
- package/inkos/packages/core/src/__tests__/memory-retrieval.test.ts +1303 -0
- package/inkos/packages/core/src/__tests__/models.test.ts +918 -0
- package/inkos/packages/core/src/__tests__/outline-paths.test.ts +97 -0
- package/inkos/packages/core/src/__tests__/path-safety.test.ts +22 -0
- package/inkos/packages/core/src/__tests__/persisted-governed-plan.test.ts +134 -0
- package/inkos/packages/core/src/__tests__/phase5-cleanup.test.ts +393 -0
- package/inkos/packages/core/src/__tests__/phase5-hotfix.test.ts +288 -0
- package/inkos/packages/core/src/__tests__/phase7-hotfix.test.ts +614 -0
- package/inkos/packages/core/src/__tests__/pipeline-agent.test.ts +354 -0
- package/inkos/packages/core/src/__tests__/pipeline-runner-memory-sync.test.ts +317 -0
- package/inkos/packages/core/src/__tests__/pipeline-runner.test.ts +5200 -0
- package/inkos/packages/core/src/__tests__/planner-context.test.ts +137 -0
- package/inkos/packages/core/src/__tests__/planner-prompts-ratio.test.ts +11 -0
- package/inkos/packages/core/src/__tests__/planner-prompts.test.ts +171 -0
- package/inkos/packages/core/src/__tests__/planner.test.ts +362 -0
- package/inkos/packages/core/src/__tests__/planning-materials.test.ts +90 -0
- package/inkos/packages/core/src/__tests__/polisher.test.ts +189 -0
- package/inkos/packages/core/src/__tests__/post-write-validator.test.ts +291 -0
- package/inkos/packages/core/src/__tests__/probe.test.ts +77 -0
- package/inkos/packages/core/src/__tests__/project-interaction.test.ts +241 -0
- package/inkos/packages/core/src/__tests__/provider.test.ts +953 -0
- package/inkos/packages/core/src/__tests__/providers-group.test.ts +34 -0
- package/inkos/packages/core/src/__tests__/providers-lookup.test.ts +81 -0
- package/inkos/packages/core/src/__tests__/providers-schema.test.ts +158 -0
- package/inkos/packages/core/src/__tests__/proxy-fetch.test.ts +75 -0
- package/inkos/packages/core/src/__tests__/revise-foundation.test.ts +514 -0
- package/inkos/packages/core/src/__tests__/reviser.test.ts +859 -0
- package/inkos/packages/core/src/__tests__/runtime-state-store.test.ts +388 -0
- package/inkos/packages/core/src/__tests__/scheduler.test.ts +123 -0
- package/inkos/packages/core/src/__tests__/secrets-migration.test.ts +71 -0
- package/inkos/packages/core/src/__tests__/secrets.test.ts +95 -0
- package/inkos/packages/core/src/__tests__/sensitive-words.test.ts +88 -0
- package/inkos/packages/core/src/__tests__/service-presets-regression.test.ts +73 -0
- package/inkos/packages/core/src/__tests__/service-resolver-regression.test.ts +75 -0
- package/inkos/packages/core/src/__tests__/service-resolver.test.ts +228 -0
- package/inkos/packages/core/src/__tests__/session-transcript-restore.test.ts +1311 -0
- package/inkos/packages/core/src/__tests__/session-transcript.test.ts +195 -0
- package/inkos/packages/core/src/__tests__/settler-delta-parser.test.ts +133 -0
- package/inkos/packages/core/src/__tests__/short-fiction-public.test.ts +241 -0
- package/inkos/packages/core/src/__tests__/spot-fix-patches.test.ts +104 -0
- package/inkos/packages/core/src/__tests__/state-manager.test.ts +1298 -0
- package/inkos/packages/core/src/__tests__/state-projections.test.ts +130 -0
- package/inkos/packages/core/src/__tests__/state-reducer.test.ts +372 -0
- package/inkos/packages/core/src/__tests__/state-validator-agent.test.ts +165 -0
- package/inkos/packages/core/src/__tests__/state-validator.test.ts +122 -0
- package/inkos/packages/core/src/__tests__/style-analyzer.test.ts +61 -0
- package/inkos/packages/core/src/__tests__/temperature-constraints.test.ts +57 -0
- package/inkos/packages/core/src/__tests__/v13-hotfix-round4.test.ts +343 -0
- package/inkos/packages/core/src/__tests__/verify-service.test.ts +77 -0
- package/inkos/packages/core/src/__tests__/webhook.test.ts +91 -0
- package/inkos/packages/core/src/__tests__/writer-parser.test.ts +348 -0
- package/inkos/packages/core/src/__tests__/writer-prompts.test.ts +269 -0
- package/inkos/packages/core/src/__tests__/writer.test.ts +1360 -0
- package/inkos/packages/core/src/agent/agent-session.ts +737 -0
- package/inkos/packages/core/src/agent/agent-system-prompt.ts +199 -0
- package/inkos/packages/core/src/agent/agent-tools.ts +835 -0
- package/inkos/packages/core/src/agent/context-transform.ts +85 -0
- package/inkos/packages/core/src/agent/index.ts +14 -0
- package/inkos/packages/core/src/agents/ai-tells.ts +161 -0
- package/inkos/packages/core/src/agents/architect.ts +1291 -0
- package/inkos/packages/core/src/agents/base.ts +100 -0
- package/inkos/packages/core/src/agents/chapter-analyzer.ts +634 -0
- package/inkos/packages/core/src/agents/composer.ts +469 -0
- package/inkos/packages/core/src/agents/consolidator.ts +218 -0
- package/inkos/packages/core/src/agents/continuity.ts +824 -0
- package/inkos/packages/core/src/agents/detection-insights.ts +72 -0
- package/inkos/packages/core/src/agents/detector.ts +224 -0
- package/inkos/packages/core/src/agents/en-prompt-sections.ts +129 -0
- package/inkos/packages/core/src/agents/fanfic-canon-importer.ts +146 -0
- package/inkos/packages/core/src/agents/fanfic-dimensions.ts +87 -0
- package/inkos/packages/core/src/agents/fanfic-prompt-sections.ts +109 -0
- package/inkos/packages/core/src/agents/foundation-reviewer.ts +204 -0
- package/inkos/packages/core/src/agents/length-normalizer.ts +218 -0
- package/inkos/packages/core/src/agents/observer-prompts.ts +127 -0
- package/inkos/packages/core/src/agents/planner-context.ts +297 -0
- package/inkos/packages/core/src/agents/planner-prompts.ts +404 -0
- package/inkos/packages/core/src/agents/planner.ts +783 -0
- package/inkos/packages/core/src/agents/polisher.ts +153 -0
- package/inkos/packages/core/src/agents/post-write-validator.ts +873 -0
- package/inkos/packages/core/src/agents/radar-source.ts +123 -0
- package/inkos/packages/core/src/agents/radar.ts +120 -0
- package/inkos/packages/core/src/agents/reviser.ts +701 -0
- package/inkos/packages/core/src/agents/rules-reader.ts +155 -0
- package/inkos/packages/core/src/agents/sensitive-words.ts +142 -0
- package/inkos/packages/core/src/agents/settler-delta-parser.ts +53 -0
- package/inkos/packages/core/src/agents/settler-parser.ts +38 -0
- package/inkos/packages/core/src/agents/settler-prompts.ts +230 -0
- package/inkos/packages/core/src/agents/short-fiction.ts +429 -0
- package/inkos/packages/core/src/agents/state-validator.ts +322 -0
- package/inkos/packages/core/src/agents/style-analyzer.ts +93 -0
- package/inkos/packages/core/src/agents/writer-parser.ts +178 -0
- package/inkos/packages/core/src/agents/writer-prompts.ts +899 -0
- package/inkos/packages/core/src/agents/writer.ts +1450 -0
- package/inkos/packages/core/src/index.ts +392 -0
- package/inkos/packages/core/src/interaction/book-session-store.ts +226 -0
- package/inkos/packages/core/src/interaction/draft-directive-parser.ts +266 -0
- package/inkos/packages/core/src/interaction/edit-controller.ts +270 -0
- package/inkos/packages/core/src/interaction/events.ts +41 -0
- package/inkos/packages/core/src/interaction/export-artifact.ts +151 -0
- package/inkos/packages/core/src/interaction/intents.ts +63 -0
- package/inkos/packages/core/src/interaction/modes.ts +13 -0
- package/inkos/packages/core/src/interaction/nl-router.ts +258 -0
- package/inkos/packages/core/src/interaction/project-control.ts +150 -0
- package/inkos/packages/core/src/interaction/project-session-store.ts +81 -0
- package/inkos/packages/core/src/interaction/project-tools.ts +704 -0
- package/inkos/packages/core/src/interaction/request-router.ts +5 -0
- package/inkos/packages/core/src/interaction/runtime.ts +1167 -0
- package/inkos/packages/core/src/interaction/session-transcript-legacy.ts +113 -0
- package/inkos/packages/core/src/interaction/session-transcript-restore.ts +607 -0
- package/inkos/packages/core/src/interaction/session-transcript-schema.ts +76 -0
- package/inkos/packages/core/src/interaction/session-transcript.ts +189 -0
- package/inkos/packages/core/src/interaction/session.ts +226 -0
- package/inkos/packages/core/src/interaction/truth-authority.ts +45 -0
- package/inkos/packages/core/src/llm/config-migration.ts +58 -0
- package/inkos/packages/core/src/llm/cover-providers.ts +45 -0
- package/inkos/packages/core/src/llm/provider.ts +1331 -0
- package/inkos/packages/core/src/llm/providers/endpoints/ai360.ts +42 -0
- package/inkos/packages/core/src/llm/providers/endpoints/anthropic.ts +82 -0
- package/inkos/packages/core/src/llm/providers/endpoints/astronCodingPlan.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/baichuan.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/bailian.ts +65 -0
- package/inkos/packages/core/src/llm/providers/endpoints/bailianCodingPlan.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/custom.ts +22 -0
- package/inkos/packages/core/src/llm/providers/endpoints/deepseek.ts +35 -0
- package/inkos/packages/core/src/llm/providers/endpoints/giteeai.ts +41 -0
- package/inkos/packages/core/src/llm/providers/endpoints/githubCopilot.ts +43 -0
- package/inkos/packages/core/src/llm/providers/endpoints/glmCodingPlan.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/google.ts +51 -0
- package/inkos/packages/core/src/llm/providers/endpoints/hunyuan.ts +42 -0
- package/inkos/packages/core/src/llm/providers/endpoints/infiniai.ts +72 -0
- package/inkos/packages/core/src/llm/providers/endpoints/internlm.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/kimiCode.ts +23 -0
- package/inkos/packages/core/src/llm/providers/endpoints/kimiCodingPlan.ts +24 -0
- package/inkos/packages/core/src/llm/providers/endpoints/kkaiapi.ts +56 -0
- package/inkos/packages/core/src/llm/providers/endpoints/longcat.ts +25 -0
- package/inkos/packages/core/src/llm/providers/endpoints/minimax.ts +39 -0
- package/inkos/packages/core/src/llm/providers/endpoints/minimaxCodingPlan.ts +28 -0
- package/inkos/packages/core/src/llm/providers/endpoints/mistral.ts +40 -0
- package/inkos/packages/core/src/llm/providers/endpoints/modelscope.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/moonshot.ts +39 -0
- package/inkos/packages/core/src/llm/providers/endpoints/newapi.ts +21 -0
- package/inkos/packages/core/src/llm/providers/endpoints/ollama.ts +73 -0
- package/inkos/packages/core/src/llm/providers/endpoints/openai.ts +77 -0
- package/inkos/packages/core/src/llm/providers/endpoints/opencodeCodingPlan.ts +30 -0
- package/inkos/packages/core/src/llm/providers/endpoints/openrouter.ts +87 -0
- package/inkos/packages/core/src/llm/providers/endpoints/ppio.ts +86 -0
- package/inkos/packages/core/src/llm/providers/endpoints/qiniu.ts +32 -0
- package/inkos/packages/core/src/llm/providers/endpoints/sensenova.ts +45 -0
- package/inkos/packages/core/src/llm/providers/endpoints/siliconcloud.ts +126 -0
- package/inkos/packages/core/src/llm/providers/endpoints/spark.ts +33 -0
- package/inkos/packages/core/src/llm/providers/endpoints/stepfun.ts +35 -0
- package/inkos/packages/core/src/llm/providers/endpoints/tencentcloud.ts +25 -0
- package/inkos/packages/core/src/llm/providers/endpoints/volcengine.ts +52 -0
- package/inkos/packages/core/src/llm/providers/endpoints/volcengineCodingPlan.ts +42 -0
- package/inkos/packages/core/src/llm/providers/endpoints/wenxin.ts +106 -0
- package/inkos/packages/core/src/llm/providers/endpoints/xai.ts +34 -0
- package/inkos/packages/core/src/llm/providers/endpoints/xiaomimimo.ts +26 -0
- package/inkos/packages/core/src/llm/providers/endpoints/zeroone.ts +34 -0
- package/inkos/packages/core/src/llm/providers/endpoints/zhipu.ts +61 -0
- package/inkos/packages/core/src/llm/providers/index.ts +71 -0
- package/inkos/packages/core/src/llm/providers/lookup.ts +70 -0
- package/inkos/packages/core/src/llm/providers/probe.ts +35 -0
- package/inkos/packages/core/src/llm/providers/types.ts +89 -0
- package/inkos/packages/core/src/llm/providers/verify.ts +104 -0
- package/inkos/packages/core/src/llm/secrets.ts +77 -0
- package/inkos/packages/core/src/llm/service-presets.ts +215 -0
- package/inkos/packages/core/src/llm/service-resolver.ts +91 -0
- package/inkos/packages/core/src/models/book-rules.ts +126 -0
- package/inkos/packages/core/src/models/book.ts +70 -0
- package/inkos/packages/core/src/models/chapter.ts +42 -0
- package/inkos/packages/core/src/models/detection.ts +25 -0
- package/inkos/packages/core/src/models/genre-profile.ts +36 -0
- package/inkos/packages/core/src/models/input-governance.ts +99 -0
- package/inkos/packages/core/src/models/length-governance.ts +46 -0
- package/inkos/packages/core/src/models/project.ts +161 -0
- package/inkos/packages/core/src/models/runtime-state.ts +144 -0
- package/inkos/packages/core/src/models/state.ts +52 -0
- package/inkos/packages/core/src/models/style-profile.ts +15 -0
- package/inkos/packages/core/src/notify/dispatcher.ts +96 -0
- package/inkos/packages/core/src/notify/feishu.ts +34 -0
- package/inkos/packages/core/src/notify/telegram.ts +25 -0
- package/inkos/packages/core/src/notify/webhook.ts +58 -0
- package/inkos/packages/core/src/notify/wechat-work.ts +22 -0
- package/inkos/packages/core/src/pipeline/agent.ts +691 -0
- package/inkos/packages/core/src/pipeline/chapter-persistence.ts +79 -0
- package/inkos/packages/core/src/pipeline/chapter-review-cycle.ts +324 -0
- package/inkos/packages/core/src/pipeline/chapter-state-recovery.ts +236 -0
- package/inkos/packages/core/src/pipeline/chapter-truth-validation.ts +145 -0
- package/inkos/packages/core/src/pipeline/detection-runner.ts +164 -0
- package/inkos/packages/core/src/pipeline/persisted-governed-plan.ts +216 -0
- package/inkos/packages/core/src/pipeline/runner.ts +3438 -0
- package/inkos/packages/core/src/pipeline/scheduler.ts +411 -0
- package/inkos/packages/core/src/pipeline/short-fiction-runner.ts +801 -0
- package/inkos/packages/core/src/prompts/index.ts +1 -0
- package/inkos/packages/core/src/prompts/short-fiction.ts +273 -0
- package/inkos/packages/core/src/state/manager.ts +560 -0
- package/inkos/packages/core/src/state/memory-db.ts +359 -0
- package/inkos/packages/core/src/state/runtime-state-store.ts +164 -0
- package/inkos/packages/core/src/state/state-bootstrap.ts +657 -0
- package/inkos/packages/core/src/state/state-projections.ts +255 -0
- package/inkos/packages/core/src/state/state-reducer.ts +260 -0
- package/inkos/packages/core/src/state/state-validator.ts +117 -0
- package/inkos/packages/core/src/utils/analytics.ts +92 -0
- package/inkos/packages/core/src/utils/book-id.ts +31 -0
- package/inkos/packages/core/src/utils/cadence-policy.ts +46 -0
- package/inkos/packages/core/src/utils/chapter-cadence.ts +211 -0
- package/inkos/packages/core/src/utils/chapter-memo-parser.ts +157 -0
- package/inkos/packages/core/src/utils/chapter-splitter.ts +80 -0
- package/inkos/packages/core/src/utils/config-loader.ts +29 -0
- package/inkos/packages/core/src/utils/context-assembly.ts +98 -0
- package/inkos/packages/core/src/utils/context-filter.ts +190 -0
- package/inkos/packages/core/src/utils/effective-llm-config.ts +529 -0
- package/inkos/packages/core/src/utils/governed-context.ts +101 -0
- package/inkos/packages/core/src/utils/governed-working-set.ts +395 -0
- package/inkos/packages/core/src/utils/hook-arbiter.ts +332 -0
- package/inkos/packages/core/src/utils/hook-governance.ts +199 -0
- package/inkos/packages/core/src/utils/hook-health.ts +189 -0
- package/inkos/packages/core/src/utils/hook-ledger-validator.ts +277 -0
- package/inkos/packages/core/src/utils/hook-lifecycle.ts +224 -0
- package/inkos/packages/core/src/utils/hook-policy.ts +115 -0
- package/inkos/packages/core/src/utils/hook-promotion.ts +313 -0
- package/inkos/packages/core/src/utils/hook-stale-detection.ts +168 -0
- package/inkos/packages/core/src/utils/length-metrics.ts +123 -0
- package/inkos/packages/core/src/utils/llm-endpoint-auth.ts +40 -0
- package/inkos/packages/core/src/utils/llm-env.ts +74 -0
- package/inkos/packages/core/src/utils/logger.ts +123 -0
- package/inkos/packages/core/src/utils/long-span-fatigue.ts +545 -0
- package/inkos/packages/core/src/utils/memory-retrieval.ts +527 -0
- package/inkos/packages/core/src/utils/narrative-control.ts +177 -0
- package/inkos/packages/core/src/utils/outline-paths.ts +275 -0
- package/inkos/packages/core/src/utils/path-safety.ts +11 -0
- package/inkos/packages/core/src/utils/planning-materials.ts +185 -0
- package/inkos/packages/core/src/utils/pov-filter.ts +149 -0
- package/inkos/packages/core/src/utils/proxy-fetch.ts +44 -0
- package/inkos/packages/core/src/utils/runtime-writer.ts +41 -0
- package/inkos/packages/core/src/utils/spot-fix-patches.ts +189 -0
- package/inkos/packages/core/src/utils/story-markdown.ts +346 -0
- package/inkos/packages/core/src/utils/web-search.ts +82 -0
- package/inkos/packages/core/src/utils/writing-methodology.ts +164 -0
- package/inkos/packages/core/tsconfig.json +8 -0
- package/inkos/packages/core/vitest.config.ts +7 -0
- package/inkos/packages/studio/components.json +25 -0
- package/inkos/packages/studio/index.html +13 -0
- package/inkos/packages/studio/package.json +72 -0
- package/inkos/packages/studio/postcss.config.js +3 -0
- package/inkos/packages/studio/src/App.test.ts +25 -0
- package/inkos/packages/studio/src/App.tsx +280 -0
- package/inkos/packages/studio/src/api/__tests__/normalize-base-url.test.ts +40 -0
- package/inkos/packages/studio/src/api/book-create.test.ts +104 -0
- package/inkos/packages/studio/src/api/book-create.ts +94 -0
- package/inkos/packages/studio/src/api/errors.ts +17 -0
- package/inkos/packages/studio/src/api/index.ts +30 -0
- package/inkos/packages/studio/src/api/lib/run-store.ts +177 -0
- package/inkos/packages/studio/src/api/lib/sse.ts +50 -0
- package/inkos/packages/studio/src/api/phase5-hotfix.test.ts +335 -0
- package/inkos/packages/studio/src/api/safety.ts +6 -0
- package/inkos/packages/studio/src/api/server.test.ts +3162 -0
- package/inkos/packages/studio/src/api/server.ts +3666 -0
- package/inkos/packages/studio/src/api/v13-hotfix-round4.test.ts +226 -0
- package/inkos/packages/studio/src/app-state.test.ts +8 -0
- package/inkos/packages/studio/src/app-state.ts +1 -0
- package/inkos/packages/studio/src/components/ConfirmDialog.tsx +95 -0
- package/inkos/packages/studio/src/components/ServiceConfigSourceCard.tsx +139 -0
- package/inkos/packages/studio/src/components/ServiceQuickLinks.tsx +65 -0
- package/inkos/packages/studio/src/components/Sidebar.tsx +652 -0
- package/inkos/packages/studio/src/components/ai-elements/code-block.tsx +562 -0
- package/inkos/packages/studio/src/components/ai-elements/confirmation.tsx +174 -0
- package/inkos/packages/studio/src/components/ai-elements/message.tsx +360 -0
- package/inkos/packages/studio/src/components/ai-elements/prompt-input.tsx +1457 -0
- package/inkos/packages/studio/src/components/ai-elements/reasoning.tsx +226 -0
- package/inkos/packages/studio/src/components/ai-elements/shimmer.tsx +77 -0
- package/inkos/packages/studio/src/components/ai-elements/tool.tsx +173 -0
- package/inkos/packages/studio/src/components/chat/BookSidebar.tsx +291 -0
- package/inkos/packages/studio/src/components/chat/ChatMessage.tsx +39 -0
- package/inkos/packages/studio/src/components/chat/QuickActions.tsx +73 -0
- package/inkos/packages/studio/src/components/chat/ToolExecutionSteps.tsx +320 -0
- package/inkos/packages/studio/src/components/chat/__tests__/ToolExecutionSteps.test.ts +114 -0
- package/inkos/packages/studio/src/components/chat-utils.ts +56 -0
- package/inkos/packages/studio/src/components/chatbar-state.test.ts +69 -0
- package/inkos/packages/studio/src/components/sidebar/ChaptersSection.tsx +66 -0
- package/inkos/packages/studio/src/components/sidebar/CharacterSection.tsx +129 -0
- package/inkos/packages/studio/src/components/sidebar/FoundationSection.tsx +61 -0
- package/inkos/packages/studio/src/components/sidebar/ProgressSection.tsx +124 -0
- package/inkos/packages/studio/src/components/sidebar/SidebarCard.tsx +30 -0
- package/inkos/packages/studio/src/components/sidebar/SummarySection.tsx +89 -0
- package/inkos/packages/studio/src/components/ui/alert.tsx +76 -0
- package/inkos/packages/studio/src/components/ui/badge.tsx +52 -0
- package/inkos/packages/studio/src/components/ui/button-group.tsx +87 -0
- package/inkos/packages/studio/src/components/ui/button.tsx +58 -0
- package/inkos/packages/studio/src/components/ui/collapsible.tsx +19 -0
- package/inkos/packages/studio/src/components/ui/command.tsx +194 -0
- package/inkos/packages/studio/src/components/ui/dialog.tsx +158 -0
- package/inkos/packages/studio/src/components/ui/dropdown-menu.tsx +266 -0
- package/inkos/packages/studio/src/components/ui/hover-card.tsx +51 -0
- package/inkos/packages/studio/src/components/ui/input-group.tsx +158 -0
- package/inkos/packages/studio/src/components/ui/input.tsx +20 -0
- package/inkos/packages/studio/src/components/ui/select.tsx +199 -0
- package/inkos/packages/studio/src/components/ui/separator.tsx +23 -0
- package/inkos/packages/studio/src/components/ui/spinner.tsx +10 -0
- package/inkos/packages/studio/src/components/ui/textarea.tsx +18 -0
- package/inkos/packages/studio/src/components/ui/tooltip.tsx +66 -0
- package/inkos/packages/studio/src/constants/service-groups.ts +29 -0
- package/inkos/packages/studio/src/hooks/use-api.test.ts +93 -0
- package/inkos/packages/studio/src/hooks/use-api.ts +189 -0
- package/inkos/packages/studio/src/hooks/use-book-activity.test.ts +129 -0
- package/inkos/packages/studio/src/hooks/use-book-activity.ts +180 -0
- package/inkos/packages/studio/src/hooks/use-colors.ts +27 -0
- package/inkos/packages/studio/src/hooks/use-hash-route.test.ts +101 -0
- package/inkos/packages/studio/src/hooks/use-hash-route.ts +89 -0
- package/inkos/packages/studio/src/hooks/use-i18n.ts +289 -0
- package/inkos/packages/studio/src/hooks/use-session-events.ts +64 -0
- package/inkos/packages/studio/src/hooks/use-sse.test.ts +52 -0
- package/inkos/packages/studio/src/hooks/use-sse.ts +92 -0
- package/inkos/packages/studio/src/hooks/use-theme.test.ts +31 -0
- package/inkos/packages/studio/src/hooks/use-theme.ts +75 -0
- package/inkos/packages/studio/src/index.css +323 -0
- package/inkos/packages/studio/src/lib/error-copy.test.ts +34 -0
- package/inkos/packages/studio/src/lib/error-copy.ts +37 -0
- package/inkos/packages/studio/src/lib/utils.ts +6 -0
- package/inkos/packages/studio/src/main.tsx +10 -0
- package/inkos/packages/studio/src/pages/Analytics.tsx +80 -0
- package/inkos/packages/studio/src/pages/BookCreate.tsx +895 -0
- package/inkos/packages/studio/src/pages/BookDetail.tsx +652 -0
- package/inkos/packages/studio/src/pages/ChapterReader.tsx +266 -0
- package/inkos/packages/studio/src/pages/ChatPage.tsx +521 -0
- package/inkos/packages/studio/src/pages/DaemonControl.tsx +116 -0
- package/inkos/packages/studio/src/pages/Dashboard.tsx +379 -0
- package/inkos/packages/studio/src/pages/DoctorView.tsx +82 -0
- package/inkos/packages/studio/src/pages/GenreManager.tsx +464 -0
- package/inkos/packages/studio/src/pages/ImportManager.tsx +216 -0
- package/inkos/packages/studio/src/pages/LanguageSelector.tsx +74 -0
- package/inkos/packages/studio/src/pages/LogViewer.tsx +82 -0
- package/inkos/packages/studio/src/pages/RadarView.tsx +157 -0
- package/inkos/packages/studio/src/pages/ServiceDetailPage.tsx +393 -0
- package/inkos/packages/studio/src/pages/ServiceListPage.tsx +463 -0
- package/inkos/packages/studio/src/pages/StyleManager.tsx +225 -0
- package/inkos/packages/studio/src/pages/TruthFiles.tsx +194 -0
- package/inkos/packages/studio/src/pages/chat-page-state.test.ts +206 -0
- package/inkos/packages/studio/src/pages/chat-page-state.ts +112 -0
- package/inkos/packages/studio/src/pages/page-state.test.ts +258 -0
- package/inkos/packages/studio/src/pages/service-detail-state.test.ts +294 -0
- package/inkos/packages/studio/src/pages/service-detail-state.ts +234 -0
- package/inkos/packages/studio/src/pages/style-manager-state.test.ts +22 -0
- package/inkos/packages/studio/src/pages/truth-files-state.test.ts +61 -0
- package/inkos/packages/studio/src/shared/contracts.ts +143 -0
- package/inkos/packages/studio/src/store/chat/__tests__/message-parts.test.ts +172 -0
- package/inkos/packages/studio/src/store/chat/index.ts +3 -0
- package/inkos/packages/studio/src/store/chat/initialState.ts +8 -0
- package/inkos/packages/studio/src/store/chat/message-policy.test.ts +16 -0
- package/inkos/packages/studio/src/store/chat/message-policy.ts +5 -0
- package/inkos/packages/studio/src/store/chat/parts-builder.ts +187 -0
- package/inkos/packages/studio/src/store/chat/selectors.ts +13 -0
- package/inkos/packages/studio/src/store/chat/slices/create/action.ts +10 -0
- package/inkos/packages/studio/src/store/chat/slices/create/initialState.ts +9 -0
- package/inkos/packages/studio/src/store/chat/slices/message/action.ts +417 -0
- package/inkos/packages/studio/src/store/chat/slices/message/initialState.ts +10 -0
- package/inkos/packages/studio/src/store/chat/slices/message/runtime.test.ts +21 -0
- package/inkos/packages/studio/src/store/chat/slices/message/runtime.ts +233 -0
- package/inkos/packages/studio/src/store/chat/slices/message/stream-events.ts +272 -0
- package/inkos/packages/studio/src/store/chat/store.ts +11 -0
- package/inkos/packages/studio/src/store/chat/types.ts +169 -0
- package/inkos/packages/studio/src/store/service/index.ts +2 -0
- package/inkos/packages/studio/src/store/service/store.ts +123 -0
- package/inkos/packages/studio/src/store/service/types.ts +50 -0
- package/inkos/packages/studio/tsconfig.json +24 -0
- package/inkos/packages/studio/tsconfig.server.json +11 -0
- package/inkos/packages/studio/vite.config.ts +34 -0
- package/inkos/packages/studio/vitest.config.ts +14 -0
- package/inkos/pnpm-lock.yaml +9569 -0
- package/inkos/pnpm-workspace.yaml +2 -0
- package/inkos/scripts/prepare-package-for-publish.mjs +135 -0
- package/inkos/scripts/restore-package-json.mjs +31 -0
- package/inkos/scripts/set-package-versions.mjs +74 -0
- package/inkos/scripts/verify-no-workspace-protocol.mjs +140 -0
- package/inkos/skills/SKILL.md +654 -0
- package/inkos/tsconfig.json +19 -0
- package/package.json +4 -3
- /package/.next/static/{F2hMZMf1IyCVAWpkbtRz7 → -3vIrBZXdQ0rp7Wa3Kz40}/_buildManifest.js +0 -0
- /package/.next/static/{F2hMZMf1IyCVAWpkbtRz7 → -3vIrBZXdQ0rp7Wa3Kz40}/_ssgManifest.js +0 -0
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { appendFile, mkdir, readFile } from "node:fs/promises";
|
|
3
|
+
import { join } from "node:path";
|
|
4
|
+
import type { AgentMessage } from "@mariozechner/pi-agent-core";
|
|
5
|
+
import { TranscriptEventSchema, type TranscriptEvent } from "./session-transcript-schema.js";
|
|
6
|
+
import type { TranscriptRole } from "./session-transcript-schema.js";
|
|
7
|
+
|
|
8
|
+
const SESSIONS_DIR = ".inkos/sessions";
|
|
9
|
+
const appendQueues = new Map<string, Promise<void>>();
|
|
10
|
+
|
|
11
|
+
export function sessionsDir(projectRoot: string): string {
|
|
12
|
+
return join(projectRoot, SESSIONS_DIR);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export function transcriptPath(projectRoot: string, sessionId: string): string {
|
|
16
|
+
return join(sessionsDir(projectRoot), `${sessionId}.jsonl`);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export function legacyBookSessionPath(projectRoot: string, sessionId: string): string {
|
|
20
|
+
return join(sessionsDir(projectRoot), `${sessionId}.json`);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export async function readTranscriptEvents(
|
|
24
|
+
projectRoot: string,
|
|
25
|
+
sessionId: string,
|
|
26
|
+
): Promise<TranscriptEvent[]> {
|
|
27
|
+
let raw: string;
|
|
28
|
+
try {
|
|
29
|
+
raw = await readFile(transcriptPath(projectRoot, sessionId), "utf-8");
|
|
30
|
+
} catch {
|
|
31
|
+
return [];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const events: TranscriptEvent[] = [];
|
|
35
|
+
for (const line of raw.split(/\r?\n/)) {
|
|
36
|
+
if (!line.trim()) continue;
|
|
37
|
+
try {
|
|
38
|
+
const parsed = TranscriptEventSchema.safeParse(JSON.parse(line));
|
|
39
|
+
if (parsed.success) events.push(parsed.data);
|
|
40
|
+
} catch {
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return events.sort((a, b) => a.seq - b.seq);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export async function nextTranscriptSeq(projectRoot: string, sessionId: string): Promise<number> {
|
|
49
|
+
const events = await readTranscriptEvents(projectRoot, sessionId);
|
|
50
|
+
return events.reduce((max, event) => Math.max(max, event.seq), 0) + 1;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function appendTranscriptEvent(
|
|
54
|
+
projectRoot: string,
|
|
55
|
+
event: TranscriptEvent,
|
|
56
|
+
): Promise<void> {
|
|
57
|
+
await appendTranscriptEvents(projectRoot, event.sessionId, () => [event]);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export async function appendTranscriptEvents(
|
|
61
|
+
projectRoot: string,
|
|
62
|
+
sessionId: string,
|
|
63
|
+
buildEvents: (context: {
|
|
64
|
+
readonly events: ReadonlyArray<TranscriptEvent>;
|
|
65
|
+
readonly nextSeq: number;
|
|
66
|
+
}) => ReadonlyArray<TranscriptEvent> | Promise<ReadonlyArray<TranscriptEvent>>,
|
|
67
|
+
): Promise<TranscriptEvent[]> {
|
|
68
|
+
const key = `${projectRoot}:${sessionId}`;
|
|
69
|
+
const previous = appendQueues.get(key) ?? Promise.resolve();
|
|
70
|
+
let result: TranscriptEvent[] = [];
|
|
71
|
+
|
|
72
|
+
const next = previous.then(async () => {
|
|
73
|
+
const events = await readTranscriptEvents(projectRoot, sessionId);
|
|
74
|
+
const nextSeq = events.reduce((max, event) => Math.max(max, event.seq), 0) + 1;
|
|
75
|
+
const built = await buildEvents({ events, nextSeq });
|
|
76
|
+
result = built.map((event) => TranscriptEventSchema.parse(event));
|
|
77
|
+
if (result.length === 0) return;
|
|
78
|
+
|
|
79
|
+
await mkdir(sessionsDir(projectRoot), { recursive: true });
|
|
80
|
+
await appendFile(
|
|
81
|
+
transcriptPath(projectRoot, sessionId),
|
|
82
|
+
`${result.map((event) => JSON.stringify(event)).join("\n")}\n`,
|
|
83
|
+
"utf-8",
|
|
84
|
+
);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
appendQueues.set(key, next.catch(() => undefined));
|
|
88
|
+
await next;
|
|
89
|
+
return result;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
function transcriptRoleForMessage(message: AgentMessage): TranscriptRole | null {
|
|
93
|
+
if (!message || typeof message !== "object" || !("role" in message)) return null;
|
|
94
|
+
const role = (message as { role?: unknown }).role;
|
|
95
|
+
return role === "user" || role === "assistant" || role === "toolResult" || role === "system"
|
|
96
|
+
? role
|
|
97
|
+
: null;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function messageTimestamp(message: AgentMessage): number {
|
|
101
|
+
if (message && typeof message === "object") {
|
|
102
|
+
const timestamp = (message as { timestamp?: unknown }).timestamp;
|
|
103
|
+
if (typeof timestamp === "number" && Number.isFinite(timestamp) && timestamp >= 0) {
|
|
104
|
+
return Math.floor(timestamp);
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return Date.now();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function toolCallIdForMessage(message: AgentMessage): string | undefined {
|
|
111
|
+
if (!message || typeof message !== "object") return undefined;
|
|
112
|
+
if ((message as { role?: unknown }).role === "toolResult") {
|
|
113
|
+
const toolCallId = (message as { toolCallId?: unknown }).toolCallId;
|
|
114
|
+
return typeof toolCallId === "string" && toolCallId.length > 0 ? toolCallId : undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const content = (message as { content?: unknown }).content;
|
|
118
|
+
if (!Array.isArray(content)) return undefined;
|
|
119
|
+
const block = content.find(
|
|
120
|
+
(item): item is { type: "toolCall"; id: string } =>
|
|
121
|
+
!!item &&
|
|
122
|
+
typeof item === "object" &&
|
|
123
|
+
(item as { type?: unknown }).type === "toolCall" &&
|
|
124
|
+
typeof (item as { id?: unknown }).id === "string",
|
|
125
|
+
);
|
|
126
|
+
return block?.id;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export async function appendManualSessionMessages(
|
|
130
|
+
projectRoot: string,
|
|
131
|
+
sessionId: string,
|
|
132
|
+
messages: ReadonlyArray<AgentMessage>,
|
|
133
|
+
input = "",
|
|
134
|
+
): Promise<void> {
|
|
135
|
+
const persistedMessages = messages
|
|
136
|
+
.map((message) => ({ message, role: transcriptRoleForMessage(message) }))
|
|
137
|
+
.filter((entry): entry is { message: AgentMessage; role: TranscriptRole } => entry.role !== null);
|
|
138
|
+
if (persistedMessages.length === 0) return;
|
|
139
|
+
|
|
140
|
+
const requestId = randomUUID();
|
|
141
|
+
await appendTranscriptEvents(projectRoot, sessionId, ({ nextSeq }) => {
|
|
142
|
+
let seq = nextSeq;
|
|
143
|
+
const events: TranscriptEvent[] = [{
|
|
144
|
+
type: "request_started",
|
|
145
|
+
version: 1,
|
|
146
|
+
sessionId,
|
|
147
|
+
requestId,
|
|
148
|
+
seq: seq++,
|
|
149
|
+
timestamp: Date.now(),
|
|
150
|
+
input,
|
|
151
|
+
}];
|
|
152
|
+
|
|
153
|
+
let parentUuid: string | null = null;
|
|
154
|
+
let lastAssistantUuid: string | null = null;
|
|
155
|
+
for (const { message, role } of persistedMessages) {
|
|
156
|
+
const uuid = randomUUID();
|
|
157
|
+
const isToolResult = role === "toolResult";
|
|
158
|
+
const toolCallId = toolCallIdForMessage(message);
|
|
159
|
+
events.push({
|
|
160
|
+
type: "message",
|
|
161
|
+
version: 1,
|
|
162
|
+
sessionId,
|
|
163
|
+
requestId,
|
|
164
|
+
uuid,
|
|
165
|
+
parentUuid: isToolResult && lastAssistantUuid ? lastAssistantUuid : parentUuid,
|
|
166
|
+
seq: seq++,
|
|
167
|
+
role,
|
|
168
|
+
timestamp: messageTimestamp(message),
|
|
169
|
+
...(toolCallId ? { toolCallId } : {}),
|
|
170
|
+
...(isToolResult && lastAssistantUuid
|
|
171
|
+
? { sourceToolAssistantUuid: lastAssistantUuid }
|
|
172
|
+
: {}),
|
|
173
|
+
message,
|
|
174
|
+
});
|
|
175
|
+
if (role === "assistant") lastAssistantUuid = uuid;
|
|
176
|
+
parentUuid = uuid;
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
events.push({
|
|
180
|
+
type: "request_committed",
|
|
181
|
+
version: 1,
|
|
182
|
+
sessionId,
|
|
183
|
+
requestId,
|
|
184
|
+
seq,
|
|
185
|
+
timestamp: Date.now(),
|
|
186
|
+
});
|
|
187
|
+
return events;
|
|
188
|
+
});
|
|
189
|
+
}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
import { AutomationModeSchema, type AutomationMode } from "./modes.js";
|
|
3
|
+
import { ExecutionStateSchema, InteractionEventSchema, type InteractionEvent } from "./events.js";
|
|
4
|
+
import { assertSafeBookId, isSafeBookId } from "../utils/book-id.js";
|
|
5
|
+
|
|
6
|
+
export const PendingDecisionSchema = z.object({
|
|
7
|
+
kind: z.string().min(1),
|
|
8
|
+
bookId: z.string().min(1),
|
|
9
|
+
chapterNumber: z.number().int().min(1).optional(),
|
|
10
|
+
summary: z.string().min(1),
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
export type PendingDecision = z.infer<typeof PendingDecisionSchema>;
|
|
14
|
+
|
|
15
|
+
export const PipelineStageSchema = z.object({
|
|
16
|
+
label: z.string(),
|
|
17
|
+
status: z.enum(["pending", "active", "completed"]),
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
export type PipelineStage = z.infer<typeof PipelineStageSchema>;
|
|
21
|
+
|
|
22
|
+
export const ToolExecutionSchema = z.object({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
tool: z.string(),
|
|
25
|
+
agent: z.string().optional(),
|
|
26
|
+
label: z.string(),
|
|
27
|
+
status: z.enum(["running", "processing", "completed", "error"]),
|
|
28
|
+
args: z.record(z.unknown()).optional(),
|
|
29
|
+
result: z.string().optional(),
|
|
30
|
+
details: z.unknown().optional(),
|
|
31
|
+
error: z.string().optional(),
|
|
32
|
+
stages: z.array(PipelineStageSchema).optional(),
|
|
33
|
+
startedAt: z.number(),
|
|
34
|
+
completedAt: z.number().optional(),
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export type ToolExecution = z.infer<typeof ToolExecutionSchema>;
|
|
38
|
+
|
|
39
|
+
export const InteractionMessageSchema = z.object({
|
|
40
|
+
role: z.enum(["user", "assistant", "system"]),
|
|
41
|
+
content: z.string().min(1),
|
|
42
|
+
thinking: z.string().optional(),
|
|
43
|
+
toolExecutions: z.array(ToolExecutionSchema).optional(),
|
|
44
|
+
timestamp: z.number().int().nonnegative(),
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
export type InteractionMessage = z.infer<typeof InteractionMessageSchema>;
|
|
48
|
+
|
|
49
|
+
export const BookCreationDraftSchema = z.object({
|
|
50
|
+
concept: z.string().min(1),
|
|
51
|
+
title: z.string().min(1).optional(),
|
|
52
|
+
genre: z.string().min(1).optional(),
|
|
53
|
+
platform: z.string().min(1).optional(),
|
|
54
|
+
language: z.enum(["zh", "en"]).optional(),
|
|
55
|
+
targetChapters: z.number().int().min(1).optional(),
|
|
56
|
+
chapterWordCount: z.number().int().min(1).optional(),
|
|
57
|
+
blurb: z.string().min(1).optional(),
|
|
58
|
+
worldPremise: z.string().min(1).optional(),
|
|
59
|
+
settingNotes: z.string().min(1).optional(),
|
|
60
|
+
protagonist: z.string().min(1).optional(),
|
|
61
|
+
supportingCast: z.string().min(1).optional(),
|
|
62
|
+
conflictCore: z.string().min(1).optional(),
|
|
63
|
+
volumeOutline: z.string().min(1).optional(),
|
|
64
|
+
constraints: z.string().min(1).optional(),
|
|
65
|
+
authorIntent: z.string().min(1).optional(),
|
|
66
|
+
currentFocus: z.string().min(1).optional(),
|
|
67
|
+
nextQuestion: z.string().min(1).optional(),
|
|
68
|
+
missingFields: z.array(z.string().min(1)).default([]),
|
|
69
|
+
readyToCreate: z.boolean().default(false),
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
export type BookCreationDraft = z.infer<typeof BookCreationDraftSchema>;
|
|
73
|
+
|
|
74
|
+
export const DraftRoundSchema = z.object({
|
|
75
|
+
roundId: z.number().int().min(1),
|
|
76
|
+
userMessage: z.string(),
|
|
77
|
+
assistantRaw: z.string(),
|
|
78
|
+
fieldsUpdated: z.array(z.string()).default([]),
|
|
79
|
+
summary: z.string().default(""),
|
|
80
|
+
timestamp: z.number().int().nonnegative(),
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
export type DraftRound = z.infer<typeof DraftRoundSchema>;
|
|
84
|
+
|
|
85
|
+
export const InteractionSessionSchema = z.object({
|
|
86
|
+
sessionId: z.string().min(1),
|
|
87
|
+
projectRoot: z.string().min(1),
|
|
88
|
+
activeBookId: z.string().min(1).optional(),
|
|
89
|
+
activeChapterNumber: z.number().int().min(1).optional(),
|
|
90
|
+
creationDraft: BookCreationDraftSchema.optional(),
|
|
91
|
+
draftRounds: z.array(DraftRoundSchema).default([]),
|
|
92
|
+
automationMode: AutomationModeSchema.default("semi"),
|
|
93
|
+
messages: z.array(InteractionMessageSchema).default([]),
|
|
94
|
+
events: z.array(InteractionEventSchema).default([]),
|
|
95
|
+
pendingDecision: PendingDecisionSchema.optional(),
|
|
96
|
+
currentExecution: ExecutionStateSchema.optional(),
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
export type InteractionSession = z.infer<typeof InteractionSessionSchema>;
|
|
100
|
+
|
|
101
|
+
// -- Per-book session --
|
|
102
|
+
|
|
103
|
+
export const BookSessionSchema = z.object({
|
|
104
|
+
sessionId: z.string().min(1),
|
|
105
|
+
bookId: z.string().refine(isSafeBookId, "Invalid bookId").nullable(),
|
|
106
|
+
title: z.string().nullable().default(null),
|
|
107
|
+
messages: z.array(InteractionMessageSchema).default([]),
|
|
108
|
+
creationDraft: BookCreationDraftSchema.optional(),
|
|
109
|
+
draftRounds: z.array(DraftRoundSchema).default([]),
|
|
110
|
+
events: z.array(InteractionEventSchema).default([]),
|
|
111
|
+
currentExecution: ExecutionStateSchema.optional(),
|
|
112
|
+
createdAt: z.number().int().nonnegative(),
|
|
113
|
+
updatedAt: z.number().int().nonnegative(),
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
export type BookSession = z.infer<typeof BookSessionSchema>;
|
|
117
|
+
|
|
118
|
+
// -- Global session (simplified) --
|
|
119
|
+
|
|
120
|
+
export const GlobalSessionSchema = z.object({
|
|
121
|
+
activeBookId: z.string().refine(isSafeBookId, "Invalid activeBookId").optional(),
|
|
122
|
+
automationMode: AutomationModeSchema.default("semi"),
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
export type GlobalSession = z.infer<typeof GlobalSessionSchema>;
|
|
126
|
+
|
|
127
|
+
export function createBookSession(bookId: string | null, sessionId?: string): BookSession {
|
|
128
|
+
const now = Date.now();
|
|
129
|
+
const safeBookId = bookId === null ? null : assertSafeBookId(bookId);
|
|
130
|
+
return {
|
|
131
|
+
sessionId: sessionId ?? `${now}-${Math.random().toString(36).slice(2, 8)}`,
|
|
132
|
+
bookId: safeBookId,
|
|
133
|
+
title: null,
|
|
134
|
+
messages: [],
|
|
135
|
+
draftRounds: [],
|
|
136
|
+
events: [],
|
|
137
|
+
createdAt: now,
|
|
138
|
+
updatedAt: now,
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function appendBookSessionMessage(
|
|
143
|
+
session: BookSession,
|
|
144
|
+
message: InteractionMessage,
|
|
145
|
+
): BookSession {
|
|
146
|
+
return {
|
|
147
|
+
...session,
|
|
148
|
+
messages: [...session.messages, message].sort((a, b) => a.timestamp - b.timestamp),
|
|
149
|
+
updatedAt: Date.now(),
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
export function bindActiveBook(
|
|
154
|
+
session: InteractionSession,
|
|
155
|
+
bookId: string,
|
|
156
|
+
chapterNumber?: number,
|
|
157
|
+
): InteractionSession {
|
|
158
|
+
return {
|
|
159
|
+
...session,
|
|
160
|
+
activeBookId: bookId,
|
|
161
|
+
...(chapterNumber !== undefined ? { activeChapterNumber: chapterNumber } : {}),
|
|
162
|
+
};
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function clearPendingDecision(session: InteractionSession): InteractionSession {
|
|
166
|
+
if (!session.pendingDecision) {
|
|
167
|
+
return session;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
return {
|
|
171
|
+
...session,
|
|
172
|
+
pendingDecision: undefined,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export function updateCreationDraft(
|
|
177
|
+
session: InteractionSession,
|
|
178
|
+
draft: BookCreationDraft,
|
|
179
|
+
): InteractionSession {
|
|
180
|
+
return {
|
|
181
|
+
...session,
|
|
182
|
+
creationDraft: draft,
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export function clearCreationDraft(session: InteractionSession): InteractionSession {
|
|
187
|
+
if (!session.creationDraft) {
|
|
188
|
+
return session;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
...session,
|
|
193
|
+
creationDraft: undefined,
|
|
194
|
+
draftRounds: [],
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function updateAutomationMode(
|
|
199
|
+
session: InteractionSession,
|
|
200
|
+
automationMode: AutomationMode,
|
|
201
|
+
): InteractionSession {
|
|
202
|
+
return {
|
|
203
|
+
...session,
|
|
204
|
+
automationMode,
|
|
205
|
+
};
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export function appendInteractionMessage(
|
|
209
|
+
session: InteractionSession,
|
|
210
|
+
message: InteractionMessage,
|
|
211
|
+
): InteractionSession {
|
|
212
|
+
return {
|
|
213
|
+
...session,
|
|
214
|
+
messages: [...session.messages, message].sort((left, right) => left.timestamp - right.timestamp),
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function appendInteractionEvent(
|
|
219
|
+
session: InteractionSession,
|
|
220
|
+
event: InteractionEvent,
|
|
221
|
+
): InteractionSession {
|
|
222
|
+
return {
|
|
223
|
+
...session,
|
|
224
|
+
events: [...session.events, event],
|
|
225
|
+
};
|
|
226
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type TruthAuthority =
|
|
2
|
+
| "direction"
|
|
3
|
+
| "foundation"
|
|
4
|
+
| "rules"
|
|
5
|
+
| "runtime-truth"
|
|
6
|
+
| "memory";
|
|
7
|
+
|
|
8
|
+
const NORMALIZED_TRUTH_FILES = new Set([
|
|
9
|
+
"author_intent.md",
|
|
10
|
+
"current_focus.md",
|
|
11
|
+
"story_bible.md",
|
|
12
|
+
"volume_outline.md",
|
|
13
|
+
"book_rules.md",
|
|
14
|
+
"current_state.md",
|
|
15
|
+
"pending_hooks.md",
|
|
16
|
+
"chapter_summaries.md",
|
|
17
|
+
]);
|
|
18
|
+
|
|
19
|
+
export function normalizeTruthFileName(fileName: string): string {
|
|
20
|
+
const trimmed = fileName.trim().toLowerCase();
|
|
21
|
+
const normalized = trimmed.endsWith(".md") ? trimmed : `${trimmed}.md`;
|
|
22
|
+
if (!NORMALIZED_TRUTH_FILES.has(normalized)) {
|
|
23
|
+
return normalized;
|
|
24
|
+
}
|
|
25
|
+
return normalized;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function classifyTruthAuthority(fileName: string): TruthAuthority {
|
|
29
|
+
switch (normalizeTruthFileName(fileName)) {
|
|
30
|
+
case "author_intent.md":
|
|
31
|
+
case "current_focus.md":
|
|
32
|
+
return "direction";
|
|
33
|
+
case "story_bible.md":
|
|
34
|
+
case "volume_outline.md":
|
|
35
|
+
return "foundation";
|
|
36
|
+
case "book_rules.md":
|
|
37
|
+
return "rules";
|
|
38
|
+
case "current_state.md":
|
|
39
|
+
case "pending_hooks.md":
|
|
40
|
+
return "runtime-truth";
|
|
41
|
+
case "chapter_summaries.md":
|
|
42
|
+
default:
|
|
43
|
+
return "memory";
|
|
44
|
+
}
|
|
45
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { readFile, writeFile } from "node:fs/promises";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { saveSecrets, loadSecrets } from "./secrets.js";
|
|
4
|
+
import { guessServiceFromBaseUrl } from "./service-presets.js";
|
|
5
|
+
|
|
6
|
+
export interface MigrationResult {
|
|
7
|
+
migrated: boolean;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export async function migrateConfig(projectRoot: string): Promise<MigrationResult> {
|
|
11
|
+
const configPath = join(projectRoot, "inkos.json");
|
|
12
|
+
let raw: string;
|
|
13
|
+
try {
|
|
14
|
+
raw = await readFile(configPath, "utf-8");
|
|
15
|
+
} catch {
|
|
16
|
+
return { migrated: false };
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
const config = JSON.parse(raw);
|
|
20
|
+
const llm = config.llm;
|
|
21
|
+
if (!llm) return { migrated: false };
|
|
22
|
+
|
|
23
|
+
// Already new format
|
|
24
|
+
if (Array.isArray(llm.services)) return { migrated: false };
|
|
25
|
+
|
|
26
|
+
// Old format: llm.provider, llm.model, llm.baseUrl, llm.apiKey
|
|
27
|
+
const { provider, model, baseUrl, apiKey, ...restLlm } = llm;
|
|
28
|
+
if (!model && !provider) return { migrated: false };
|
|
29
|
+
|
|
30
|
+
// Determine service from baseUrl
|
|
31
|
+
const guessedService = baseUrl ? guessServiceFromBaseUrl(baseUrl) : null;
|
|
32
|
+
const service = guessedService ?? "custom";
|
|
33
|
+
|
|
34
|
+
// Build new service entry
|
|
35
|
+
const serviceEntry: Record<string, string> = { service };
|
|
36
|
+
if (service === "custom") {
|
|
37
|
+
serviceEntry.name = "Custom";
|
|
38
|
+
if (baseUrl) serviceEntry.baseUrl = baseUrl;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Write new config (no apiKey)
|
|
42
|
+
config.llm = {
|
|
43
|
+
...restLlm,
|
|
44
|
+
services: [serviceEntry],
|
|
45
|
+
defaultModel: model,
|
|
46
|
+
};
|
|
47
|
+
await writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
48
|
+
|
|
49
|
+
// Move apiKey to secrets
|
|
50
|
+
if (apiKey) {
|
|
51
|
+
const secrets = await loadSecrets(projectRoot);
|
|
52
|
+
const secretKey = service === "custom" ? `custom:${serviceEntry.name}` : service;
|
|
53
|
+
secrets.services[secretKey] = { apiKey };
|
|
54
|
+
await saveSecrets(projectRoot, secrets);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return { migrated: true };
|
|
58
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export type CoverProviderId = "kkaiapi" | "openai" | "google";
|
|
2
|
+
|
|
3
|
+
export interface CoverProviderPreset {
|
|
4
|
+
readonly service: CoverProviderId;
|
|
5
|
+
readonly label: string;
|
|
6
|
+
readonly baseUrl: string;
|
|
7
|
+
readonly api: "responses" | "images" | "gemini";
|
|
8
|
+
readonly defaultModel: string;
|
|
9
|
+
readonly models: readonly string[];
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const COVER_PROVIDER_PRESETS: readonly CoverProviderPreset[] = [
|
|
13
|
+
{
|
|
14
|
+
service: "kkaiapi",
|
|
15
|
+
label: "kkaiapi",
|
|
16
|
+
baseUrl: "https://api.kkaiapi.com/v1",
|
|
17
|
+
api: "images",
|
|
18
|
+
defaultModel: "gpt-image-2",
|
|
19
|
+
models: ["gpt-image-2"],
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
service: "openai",
|
|
23
|
+
label: "OpenAI Images",
|
|
24
|
+
baseUrl: "https://api.openai.com/v1",
|
|
25
|
+
api: "images",
|
|
26
|
+
defaultModel: "gpt-image-2",
|
|
27
|
+
models: ["gpt-image-2"],
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
service: "google",
|
|
31
|
+
label: "Google Gemini",
|
|
32
|
+
baseUrl: "https://generativelanguage.googleapis.com/v1beta",
|
|
33
|
+
api: "gemini",
|
|
34
|
+
defaultModel: "gemini-3.1-flash-image-preview",
|
|
35
|
+
models: ["gemini-3.1-flash-image-preview", "gemini-2.5-flash-image"],
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
|
|
39
|
+
export function resolveCoverProviderPreset(service: string | undefined): CoverProviderPreset | undefined {
|
|
40
|
+
return COVER_PROVIDER_PRESETS.find((provider) => provider.service === service);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export function coverSecretKey(service: string): string {
|
|
44
|
+
return `cover:${service}`;
|
|
45
|
+
}
|