@oh-story/dsh 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (41) hide show
  1. package/README.md +10 -8
  2. package/lib/client.js +298 -87
  3. package/lib/client.js.map +4 -4
  4. package/lib/drama/manifest.json +34 -34
  5. package/lib/drama/skills/short-drama/SKILL.md +4 -1
  6. package/lib/drama/skills/short-drama/references/contract-and-ownership.md +2 -0
  7. package/lib/drama/skills/short-drama/references/creator-documents.md +30 -4
  8. package/lib/drama/skills/short-drama/references/creator-workflow.md +8 -2
  9. package/lib/drama/skills/short-drama/references/reference-roles.md +16 -2
  10. package/lib/drama/skills/short-drama/scripts/creator_markdown_check.py +328 -48
  11. package/lib/drama/skills/short-drama-produce/SKILL.md +4 -1
  12. package/lib/drama/skills/short-drama-produce/scripts/production_tool.py +34 -2
  13. package/lib/drama/skills/short-drama-storyboard/SKILL.md +27 -5
  14. package/lib/drama/skills/short-drama-storyboard/references/review-and-fixtures.md +2 -1
  15. package/lib/drama/skills/short-drama-storyboard/references/stage-contract.md +2 -2
  16. package/lib/drama/skills/short-drama-video-prompts/SKILL.md +11 -2
  17. package/lib/drama/skills/short-drama-video-prompts/assets/video-prompts.md +6 -1
  18. package/lib/drama/skills/short-drama-video-prompts/references/minimax-h3.md +19 -3
  19. package/lib/drama/skills/short-drama-video-prompts/references/stage-contract.md +8 -2
  20. package/lib/drama/skills/short-drama-video-prompts/references/target-model-profile.md +1 -0
  21. package/lib/index.js +194 -62
  22. package/lib/index.js.map +4 -4
  23. package/lib/types/client/drama-production-view.d.ts +1 -0
  24. package/lib/types/client/drama-production-view.d.ts.map +1 -1
  25. package/lib/types/client/drama-production.d.ts +3 -0
  26. package/lib/types/client/drama-production.d.ts.map +1 -1
  27. package/lib/types/client/index.d.ts.map +1 -1
  28. package/lib/types/client/video-studio.d.ts +2 -1
  29. package/lib/types/client/video-studio.d.ts.map +1 -1
  30. package/lib/types/client/workbench-presence.d.ts +29 -0
  31. package/lib/types/client/workbench-presence.d.ts.map +1 -0
  32. package/lib/types/drama-adapters.d.ts +65 -0
  33. package/lib/types/drama-adapters.d.ts.map +1 -0
  34. package/lib/types/host-python.d.ts +19 -0
  35. package/lib/types/host-python.d.ts.map +1 -0
  36. package/lib/types/index.d.ts +1 -0
  37. package/lib/types/index.d.ts.map +1 -1
  38. package/lib/types/skill-provider.d.ts +1 -1
  39. package/lib/types/skill-provider.d.ts.map +1 -1
  40. package/lib/types/workspace-route.d.ts.map +1 -1
  41. package/package.json +41 -41
package/lib/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": ["../src/index.ts", "../src/skill-provider.ts", "../src/native-hooks.ts", "../src/role-tool.ts", "../src/reference-tool.ts", "../src/role-provider.ts", "../src/production-tool.ts", "../src/production-intent.ts", "../src/workspace-route.ts", "../src/game-verification.ts", "../src/video-project.ts", "../src/workspace-request-trust.ts"],
4
- "sourcesContent": ["import type { Context } from \"@deepseek-ai/cordis\";\nimport type {} from \"@deepseek-ai/dsh-host-webserver\";\nimport type {} from \"@deepseek-ai/dsh-skill\";\nimport type {} from \"@deepseek-ai/dsh-subagent\";\nimport type {} from \"@deepseek-ai/dsh-tools\";\nimport z from \"@deepseek-ai/schemastery\";\nimport { createDramaSkillProvider, createNovelToGameSkillProvider, createOhStorySkillProvider, createVideoRecapSkillProvider } from \"./skill-provider.js\";\nimport { registerOhStoryHooks } from \"./native-hooks.js\";\nimport { registerOhStoryRoleTool } from \"./role-tool.js\";\nimport { registerOhStoryProductionTool } from \"./production-tool.js\";\nimport { registerWorkspaceRoute } from \"./workspace-route.js\";\nimport { assertTrustedWorkspaceAuthority } from \"./workspace-request-trust.js\";\n\nexport { createDramaSkillProvider, createNovelToGameSkillProvider, createOhStorySkillProvider, createVideoRecapSkillProvider, parseBundledSkill } from \"./skill-provider.js\";\nexport { OH_STORY_ROLE_NAMES, loadBundledRole } from \"./role-provider.js\";\nexport { createOhStoryRoleTool, OH_STORY_ROLE_TOOL_NAME, registerOhStoryRoleTool, roleToolFilter, type OhStoryRoleSubagents } from \"./role-tool.js\";\nexport { createOhStoryProductionTool, registerOhStoryProductionTool } from \"./production-tool.js\";\nexport { OH_STORY_PRODUCTION_TOOL_NAME, validateProductionIntent, type ProductionIntentArgs } from \"./production-intent.js\";\nexport { bundledReferenceGuard, createOhStoryReferenceTool, OH_STORY_REFERENCE_TOOL_NAME } from \"./reference-tool.js\";\nexport { registerWorkspaceRoute } from \"./workspace-route.js\";\nexport { registerOhStoryHooks } from \"./native-hooks.js\";\n\nexport const name = \"oh-story\";\nexport const inject = [\"skills\", \"subagents\", \"tools\", \"typert\", \"webServer\"];\n\n/** DSH owns models, providers, presets, permissions, roots, runs, and sessions. */\nexport interface Config {\n readonly editorMaxBytes?: number;\n readonly trustedHosts?: string[];\n}\n\nexport const Config = z.object({\n editorMaxBytes: z.natural().min(65_536).max(8_388_608).default(2_097_152),\n trustedHosts: z.array(String).default([])\n}) as z<Config>;\n\n/** Mount only domain contributions into the current DSH process. */\nexport async function apply(context: Context, config: Config = {}): Promise<void> {\n const trustedHosts = config.trustedHosts ?? [];\n for (const entry of trustedHosts) assertTrustedWorkspaceAuthority(entry);\n context.skills.registerProvider(() => createOhStorySkillProvider());\n context.skills.registerProvider(() => createDramaSkillProvider());\n context.skills.registerProvider(() => createNovelToGameSkillProvider());\n context.skills.registerProvider(() => createVideoRecapSkillProvider());\n registerOhStoryHooks(context);\n registerOhStoryProductionTool(context);\n await registerOhStoryRoleTool(context);\n registerWorkspaceRoute(context, { maxBytes: config.editorMaxBytes ?? 2_097_152, trustedHosts });\n}\n\nexport default { name, inject, Config, apply };\n", "import { readdir, readFile } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n BUNDLED_SKILL_RANK,\n type SkillCandidate,\n type SkillDefinition,\n type SkillProvider\n} from \"@deepseek-ai/dsh-skill\";\n\nconst STORY_PROVIDER_NAME = \"oh-story\";\nconst DRAMA_PROVIDER_NAME = \"short-drama\";\nconst GAME_PROVIDER_NAME = \"novel-to-game\";\nconst VIDEO_PROVIDER_NAME = \"video-recap\";\nconst DSH_SKILL_BRIDGE = [\n \"<oh-story-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, subagents, cancellation, resume, and Agent UI.\",\n \"Never start another Agent runtime, session transport, Dashboard, SSE stream, polling loop, or model configuration.\",\n \"All seven upstream Oh Story specialist Roles are bundled. Invoke one with oh_story_role and a self-contained prompt.\",\n \"Never inspect .claude/agents, .codex/agents, .opencode/agents, .agents/agents, .zcode, or .story-deployed to decide whether a Role is available, and never call invoke_subagent with a TypeName.\",\n \"Use only DSH-visible tools. DSH sandbox and permission policy remain authoritative.\",\n \"</oh-story-dsh-integration>\"\n].join(\"\\n\");\nconst DSH_SKILL_OVERRIDES: Readonly<Partial<Record<string, string>>> = {\n story: \"The \u5C0F\u8BF4 workspace is an official DSH conversation view. Never start or open a second web application.\",\n \"story-setup\": \"Initialize or validate novel project data only. DSH already supplies Skills, Roles, hooks, tools, permissions, sessions, and UI; never deploy Claude/OpenCode/Codex/Antigravity/ZCode/OpenClaw/Reasonix files or a .story-deployed marker.\",\n \"story-long-analyze\": \"Use oh_story_role for chapter extraction or specialist analysis. Never inspect platform agent directories or require a deployed external Agent definition.\",\n \"story-long-write\": \"All named Roles are provided through oh_story_role. Do not check platform agent files. Keep the upstream writing, Tracking, lint, outline, revision, and quality workflows.\",\n \"story-review\": \"All named reviewer Roles are provided through oh_story_role. Do not check platform agent files; full/lean review may use the bundled Roles directly.\",\n \"story-import\": \"All named Roles are provided through oh_story_role. Do not require story-setup to deploy them, and never inspect platform agent directories.\",\n \"story-deslop\": \"Use the bundled narrative-writer Role through oh_story_role when specialist review is useful. Never inspect platform agent directories.\",\n \"story-short-analyze\": \"Use oh_story_role for specialist analysis. Never inspect platform agent directories or require external Agent deployment.\",\n \"story-short-write\": \"All named Roles are provided through oh_story_role. Do not inspect platform agent files; preserve the upstream short-fiction workflow and quality gates.\",\n \"browser-cdp\": \"Use only browser or web capabilities visible in the current DSH preset. Do not start a parallel browser host; if no compatible capability is visible, explain the limitation.\",\n \"story-cover\": \"Use only image-generation or HTTP capabilities visible in the current DSH preset. Never assume a separate Codex or Claude runtime.\"\n};\nconst DSH_DRAMA_BRIDGE = [\n \"<short-drama-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, approvals, cancellation, resume, and Agent UI.\",\n \"The \u77ED\u5267 tab is the creator workspace. Never start dashboard_server.py, another web server, Dashboard, Agent runtime, session transport, or model configuration.\",\n \"Drama Skills v0.6 uses a creator-first contract: each episode keeps only the requested documents, up to five creator-facing sources at \u5267\u96C6/<EP>/\u5267\u672C.md, \u89C6\u89C9\u8BBE\u5B9A.md, \u5206\u955C.md, \u56FE\u7247\u63D0\u793A\u8BCD.md, and \u89C6\u9891\u63D0\u793A\u8BCD.md. Never precreate empty documents, backfill nominal stages, or start work the creator did not request. Persisted reviews use creator-readable Markdown under \u5BA1\u67E5/; an oral review writes nothing.\",\n \"For a v0.6 project, never create a parallel JSON/JSONL lifecycle truth, indexes, fingerprints, coverage tables, or QA records merely because legacy maintenance scripts and templates remain bundled.\",\n \"Never upgrade a v0.5 structured project in place or mix both contracts in one project root. Keep legacy production/audit artifacts read-only and pinned to v0.5; migrate only into a new creator-first root with manual per-episode creator confirmation.\",\n \"Use only tools visible in the current DSH preset and preserve the upstream project ownership, freshness, review, and explicit production-confirmation contracts.\",\n \"Use oh_story_production only for semantic production-view intents (open/focus, explicit shot order, or tracking a job that this Agent is actually executing). Cosmetic canvas layout remains creator-controlled. The tool changes only the Session projection: it does not edit creator documents, generate media, or authorize production.\",\n \"Production credentials remain outside project files. Never treat a prior acceptance, preview, continuation request, or budget discussion as confirmation for a paid production run.\",\n \"</short-drama-dsh-integration>\"\n].join(\"\\n\");\nconst DSH_DRAMA_OVERRIDES: Readonly<Partial<Record<string, string>>> = {\n \"short-drama\": \"A dashboard request means focus or use the native \u77ED\u5267 tab in this DSH Session. Do not run the bundled standalone Dashboard script. New projects follow only the v0.6 creator-first contract and create only documents required by the current request.\",\n \"short-drama-produce\": \"Use an upstream adapter only after the creator explicitly confirms the exact current job. Its source must be the current creator-first Markdown and its output belongs under \u5267\u96C6/<EP>/\u5236\u4F5C\u6210\u679C/. DSH permissions and approval UI remain authoritative. When oh_story_production is visible, register the previewed job with track_job after the confirmation is valid and before run \u2014 never at prepare time \u2014 passing the same job ID, target, modality and count the creator just approved.\",\n \"short-drama-assets\": \"Keep one stable `- ID\uFF1AVISUAL-*` line on every \u4EBA\u7269/\u9020\u578B/\u5730\u70B9/\u9053\u5177/\u72B6\u6001 entry in \u89C6\u89C9\u8BBE\u5B9A.md, and never change an existing ID when editing its heading or text. The \u751F\u4EA7 view identifies canvas nodes by that ID; entries without one still render, but the workbench reports their node identity as unstable.\"\n};\nconst DSH_GAME_BRIDGE = [\n \"<novel-to-game-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, approvals, cancellation, resume, Todo, and Chat UI.\",\n \"The \u6E38\u620F tab is the playable Game Studio. Never start a second Agent runtime, dashboard, session transport, or model configuration.\",\n \"Keep the complete upstream seven-Skill pipeline and write adaptation artifacts under game-adaptations/<project>/ exactly as the upstream contracts specify.\",\n \"For a web target, keep the authoritative playable entry at build/app/index.html so Game Studio can preview it. Do not silently replace a requested non-web runtime with a web build.\",\n \"Use only DSH-visible tools and approvals. qa/verification.json remains the sole machine QA truth and must cover launch, render, input, coreLoop, outcome, and restart with real execution evidence.\",\n \"The bundled Jin Ping Mei project is a read-only example, not a template to copy mechanically and not proof that another adaptation passed QA.\",\n \"</novel-to-game-dsh-integration>\"\n].join(\"\\n\");\nconst DSH_VIDEO_BRIDGE = [\n \"<video-recap-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, approvals, cancellation, resume, Todo, Chat, and the \u89C6\u9891 preview Studio.\",\n \"Never start a second Agent runtime, dashboard, session transport, web server, polling loop, or model configuration.\",\n \"Keep the complete upstream six-Skill pipeline. Put each project under video-recaps/<project>/, copy or import source media under sources/, and use work/ as the upstream work_dir so the Studio can discover authoritative manifests and outputs.\",\n \"The Video Studio is a preview and artifact surface, not a nonlinear editor. Do not invent a second project-state format, timeline truth, or render queue; recap_run_manifest.json, recap_phase.json, timeline.json, assembly_manifest.json, and the upstream artifacts remain authoritative.\",\n \"MIMO_API_KEY, FISH_API_KEY, and voice credentials stay in the host environment. Never write secrets into project files, tool arguments shown to the browser, or chat output.\",\n \"Use only DSH-visible tools and approvals. Run Python and ffmpeg through the current DSH execution world, preserve cancellation, and do not install or upgrade system dependencies without explicit user approval.\",\n \"When a new edited or final video is ready, tell the user that Video Studio can load it; never interrupt playback by replacing the currently loaded video silently.\",\n \"</video-recap-dsh-integration>\"\n].join(\"\\n\");\n\nconst DSH_NATIVE_SKILLS: Readonly<Partial<Record<string, string>>> = {\n story: `# story \u2014 DSH \u5C0F\u8BF4\u6D41\u7A0B\u5165\u53E3\n\n\u5728\u5F53\u524D DSH Session \u5185\u5224\u65AD\u7528\u6237\u610F\u56FE\uFF0C\u5E76\u52A0\u8F7D\u6700\u5339\u914D\u7684 Oh Story Skill\uFF1A\n\n- \u65B0\u5EFA\u6216\u4FEE\u590D\u5C0F\u8BF4\u5DE5\u7A0B\uFF1Astory-setup\n- \u957F\u7BC7\u9009\u9898/\u626B\u699C/\u62C6\u6587/\u65E5\u66F4\uFF1Astory-long-scan\u3001story-long-analyze\u3001story-long-write\n- \u77ED\u7BC7\u9009\u9898/\u62C6\u6587/\u5199\u4F5C\uFF1Astory-short-scan\u3001story-short-analyze\u3001story-short-write\n- \u5BFC\u5165\u5DF2\u6709\u4F5C\u54C1\uFF1Astory-import\n- \u5BA1\u7A3F\u4E0E\u53BB AI \u5473\uFF1Astory-review\u3001story-deslop\n- \u5C01\u9762\uFF1Astory-cover\n- \u7BA1\u7406\u4F5C\u8005\u4E60\u60EF\uFF08\u8BB0\u4F4F/\u67E5\u770B/\u786E\u8BA4/\u66FF\u6362/\u5FD8\u6389\u5199\u4F5C\u504F\u597D\uFF09\uFF1A\u52A0\u8F7D\u672C skill \u7684\n references/author-memory.md\uFF0C\u53EA\u7528\u672C skill \u7684 scripts/author_memory_commit.py \u7BA1\u7406\n \u5DE5\u4F5C\u533A\u7EA7 .story/\u4F5C\u8005\u8BB0\u5FC6/\uFF1B\u5DE5\u5177\u672A\u8FD4\u56DE Author Memory Receipt \u524D\u4E0D\u5F97\u58F0\u79F0\u5DF2\u8BB0\u4F4F\u3002\n\n\u610F\u56FE\u660E\u786E\u65F6\u76F4\u63A5\u8FDB\u5165\u5BF9\u5E94 Skill\uFF1B\u4E0D\u660E\u786E\u65F6\u53EA\u95EE\u4E00\u4E2A\u4F1A\u6539\u53D8\u6D41\u7A0B\u7684\u95EE\u9898\u3002\u9879\u76EE\u6587\u4EF6\u3001\nAgent\u3001\u6A21\u578B\u3001\u6743\u9650\u3001Session Log \u548C UI \u5747\u7531\u5F53\u524D DSH \u4F1A\u8BDD\u7BA1\u7406\u3002\u5C0F\u8BF4\u6587\u4EF6\u901A\u8FC7\u201C\u5C0F\u8BF4\u201D\n\u89C6\u56FE\u67E5\u770B\uFF0CAgent \u8FC7\u7A0B\u901A\u8FC7\u53F3\u4FA7\u52A8\u6001\u680F\u6216\u5B98\u65B9 Chat \u67E5\u770B\u3002\u7981\u6B62\u542F\u52A8\u72EC\u7ACB Dashboard\u3002`,\n \"story-setup\": `# story-setup \u2014 DSH \u539F\u751F\u5C0F\u8BF4\u5DE5\u7A0B\u521D\u59CB\u5316\n\n\u53EA\u521D\u59CB\u5316\u6216\u6821\u9A8C\u5F53\u524D DSH workspace \u4E2D\u7684\u5C0F\u8BF4\u6570\u636E\uFF0C\u4E0D\u90E8\u7F72\u4EFB\u4F55 Agent \u5E73\u53F0\u6587\u4EF6\u3002\n\n1. \u68C0\u67E5\u73B0\u6709\u6B63\u6587\u3001\u8BBE\u5B9A\u3001\u5927\u7EB2\u548C\u8FFD\u8E2A\u6587\u4EF6\uFF0C\u5DF2\u6709\u5185\u5BB9\u7EDD\u4E0D\u8986\u76D6\u3002\n2. \u6839\u636E\u7528\u6237\u58F0\u660E\u4E0E\u73B0\u6709\u7ED3\u6784\u5224\u65AD\u957F\u7BC7/\u77ED\u7BC7\uFF1B\u65E0\u6CD5\u53EF\u9760\u5224\u65AD\u65F6\u8BF7\u6C42\u786E\u8BA4\u3002\n3. \u957F\u7BC7\u6309\u9700\u5EFA\u7ACB \u6B63\u6587/\u3001\u8BBE\u5B9A/\u3001\u5927\u7EB2/\u3001\u8FFD\u8E2A/\uFF0C\u5E76\u51C6\u5907\u8FFD\u8E2A/_tracking-state.json\uFF1B\n \u7B2C\u4E00\u7AE0\u6B63\u6587\u843D\u76D8\u524D\u5FC5\u987B\u6709\u5BF9\u5E94\u7EC6\u7EB2\u3002\u77ED\u7BC7\u4FDD\u6301\u8F7B\u91CF\u7ED3\u6784\uFF0C\u4E0D\u5F3A\u52A0\u957F\u7BC7 Tracking\u3002\n4. \u9700\u8981\u67B6\u6784\u3001\u89D2\u8272\u6216\u7814\u7A76\u5DE5\u4F5C\u65F6\uFF0C\u901A\u8FC7 oh_story_role \u8C03\u7528\u5DF2\u6253\u5305 Role\uFF1B\u4E0D\u8981\u68C0\u67E5\u6216\n \u751F\u6210 .claude\u3001.codex\u3001.opencode\u3001.agents\u3001.zcode\u3001AGENTS.md \u6216 .story-deployed\u3002\n5. \u590D\u8FF0\u521B\u5EFA\u3001\u4FDD\u7559\u548C\u5F85\u7528\u6237\u786E\u8BA4\u7684\u6587\u4EF6\u3002\u4E0D\u8981\u914D\u7F6E\u6A21\u578B\u3001\u6743\u9650\u3001Hooks \u6216 Session\u3002\n\n\u9898\u6750\u3001\u89D2\u8272\u3001\u8282\u594F\u3001\u51B2\u7A81\u3001\u5F00\u7BC7\u548C\u5199\u4F5C\u65B9\u6CD5\u8D44\u6599\u4F4D\u4E8E references/agent-references/\uFF1B\n\u53EA\u52A0\u8F7D\u5F53\u524D\u4EFB\u52A1\u9700\u8981\u7684\u6587\u4EF6\u3002`,\n \"browser-cdp\": `# browser-cdp \u2014 DSH \u6D4F\u89C8\u5668\u80FD\u529B\u9002\u914D\n\n\u672C Skill \u4E0D\u542F\u52A8 Chrome\u3001CDP \u7AEF\u53E3\u3001\u72EC\u7ACB\u6D4F\u89C8\u5668 Host \u6216 setup-cdp-chrome.js\u3002\n\u4EC5\u4F7F\u7528\u5F53\u524D DSH Preset \u5DF2\u66B4\u9732\u7684 web_search\u3001web_fetch \u6216\u6D4F\u89C8\u5668\u5DE5\u5177\u5B8C\u6210\u7F51\u9875\u8BFB\u53D6\u3001\n\u699C\u5355\u91C7\u96C6\u548C\u8D44\u6599\u6838\u9A8C\u3002\u4FDD\u6301\u4EE5\u4E0B\u539F\u5219\uFF1A\n\n1. \u4F18\u5148\u4F7F\u7528\u7ED3\u6784\u5316\u641C\u7D22/\u6293\u53D6\u5DE5\u5177\uFF1B\u9700\u8981\u767B\u5F55\u6001\u6216\u4EA4\u4E92\u9875\u9762\u65F6\u624D\u4F7F\u7528\u53EF\u89C1\u6D4F\u89C8\u5668\u80FD\u529B\u3002\n2. \u5C0A\u91CD\u7AD9\u70B9\u6761\u6B3E\u3001\u8BBF\u95EE\u9891\u7387\u4E0E\u7528\u6237\u6388\u6743\uFF1B\u4E0D\u7ED5\u8FC7\u9A8C\u8BC1\u7801\u3001\u4ED8\u8D39\u5899\u6216\u8BBF\u95EE\u63A7\u5236\u3002\n3. \u8BB0\u5F55\u6765\u6E90 URL\u3001\u91C7\u96C6\u65F6\u95F4\u3001\u5931\u8D25\u9879\u548C\u6570\u636E\u8D28\u91CF\uFF0C\u4E0D\u628A\u63A8\u65AD\u5199\u6210\u9875\u9762\u4E8B\u5B9E\u3002\n4. \u5F53\u524D Preset \u6CA1\u6709\u517C\u5BB9\u80FD\u529B\u65F6\uFF0C\u8BF4\u660E\u7F3A\u5931\u80FD\u529B\u548C\u53EF\u884C\u7684\u624B\u5DE5\u6B65\u9AA4\uFF0C\u4E0D\u53E6\u8D77\u8FD0\u884C\u65F6\u3002`,\n \"story-long-scan\": `# story-long-scan \u2014 DSH \u539F\u751F\u957F\u7BC7\u626B\u699C\n\n\u57FA\u4E8E\u53EF\u6838\u9A8C\u6837\u672C\u8BC6\u522B\u957F\u7BC7\u7F51\u6587\u8D8B\u52BF\uFF0C\u4E0D\u8FD0\u884C\u6253\u5305\u811A\u672C\u3001\u4E0D\u63D0\u53D6\u767B\u5F55\u51ED\u636E\uFF0C\u4E5F\u4E0D\u7ED5\u8FC7\u9A8C\u8BC1\u7801\u3001\n\u8BBF\u95EE\u63A7\u5236\u6216\u7AD9\u70B9\u9650\u5236\u3002\n\n1. \u660E\u786E\u5E73\u53F0\u3001\u9891\u9053\u548C\u9898\u6750\u65B9\u5411\uFF1B\u53EA\u6709\u7B54\u6848\u4F1A\u6539\u53D8\u91C7\u6837\u8303\u56F4\u65F6\u624D\u95EE\u4E00\u4E2A\u95EE\u9898\u3002\n2. \u6570\u636E\u6765\u6E90\u4F9D\u6B21\u4E3A\uFF1A\u7528\u6237\u63D0\u4F9B\u7684\u6570\u636E\u6216\u94FE\u63A5\u3001\u5F53\u524D DSH Preset \u53EF\u89C1\u7684\u7F51\u9875\u5DE5\u5177\u3001\n references/genre-trends.md \u4E2D\u7684\u5386\u53F2\u8D8B\u52BF\u3002\u65E0\u6CD5\u83B7\u53D6\u5B9E\u65F6\u6570\u636E\u65F6\u5FC5\u987B\u660E\u786E\u6807\u4E3A\u5386\u53F2\u5047\u8BBE\u3002\n3. \u6BCF\u4E2A\u6837\u672C\u8BB0\u5F55\u6765\u6E90 URL\u3001\u91C7\u96C6\u65E5\u671F\u3001\u699C\u5355\u53E3\u5F84\u3001\u6709\u6548\u6761\u76EE\u6570\u3001\u7F3A\u5931\u5B57\u6BB5\u548C\u5F02\u5E38\u9879\uFF1B\n \u4E0D\u628A\u641C\u7D22\u6458\u8981\u3001\u63A8\u65AD\u6216\u8FC7\u671F\u7F13\u5B58\u5199\u6210\u9875\u9762\u4E8B\u5B9E\u3002\n4. \u6309\u9898\u6750\u5206\u5E03\u3001\u65B0\u9898\u6750\u4FE1\u53F7\u3001\u7ECF\u5178\u9898\u6750\u53D8\u5316\u3001\u7BC7\u5E45\u4E0E\u66F4\u65B0\u3001\u4E66\u540D\u6A21\u5F0F\u3001\u5F00\u5934\u5356\u70B9\u548C\n \u5DEE\u5F02\u5316\u5143\u7D20\u5206\u6790\u3002\u9700\u8981\u51B3\u7B56\u95E8\u7981\u65F6\u4F7F\u7528 references/topic-decision.md\u3002\n5. \u8F93\u51FA\u5E02\u573A\u6982\u51B5\u3001\u9898\u6750\u70ED\u5EA6\u3001\u8BC1\u636E\u4E0E\u53EF\u4FE1\u5EA6\u3001\u98CE\u9669\u3001\u4E09\u9879\u53EF\u6267\u884C\u65B9\u5411\u548C\u4E0B\u6B21\u590D\u626B\u65F6\u95F4\u3002\n\n\u5F53\u524D Preset \u6CA1\u6709\u7F51\u9875\u80FD\u529B\u4E14\u7528\u6237\u4E5F\u672A\u63D0\u4F9B\u6837\u672C\u65F6\uFF0C\u4F7F\u7528\u5185\u7F6E\u53C2\u8003\u5B8C\u6210\u65B9\u6CD5\u8BBA\u5206\u6790\uFF0C\n\u5E76\u5217\u51FA\u4ECD\u9700\u6838\u9A8C\u7684\u699C\u5355\uFF1B\u4E0D\u8981\u542F\u52A8 CDP\u3001\u72EC\u7ACB\u6D4F\u89C8\u5668\u6216\u5E76\u884C\u8FD0\u884C\u65F6\u3002`,\n \"story-short-scan\": `# story-short-scan \u2014 DSH \u539F\u751F\u77ED\u7BC7\u626B\u699C\n\n\u57FA\u4E8E\u53EF\u6838\u9A8C\u6837\u672C\u8BC6\u522B\u77ED\u7BC7\u5E02\u573A\u7684\u60C5\u7EEA\u3001\u9898\u6750\u4E0E\u4F20\u64AD\u4FE1\u53F7\uFF0C\u4E0D\u8FD0\u884C\u6253\u5305\u811A\u672C\u3001\u4E0D\u8BFB\u53D6 Cookie\n\u6216 token\uFF0C\u4E5F\u4E0D\u7ED5\u8FC7\u9A8C\u8BC1\u7801\u3001\u767B\u5F55\u6216\u8BBF\u95EE\u63A7\u5236\u3002\n\n1. \u660E\u786E\u5E73\u53F0\u4E0E\u65B9\u5411\uFF1B\u53EA\u6709\u7B54\u6848\u4F1A\u6539\u53D8\u91C7\u6837\u8303\u56F4\u65F6\u624D\u95EE\u4E00\u4E2A\u95EE\u9898\u3002\n2. \u6570\u636E\u6765\u6E90\u4F9D\u6B21\u4E3A\uFF1A\u7528\u6237\u63D0\u4F9B\u7684\u6570\u636E\u6216\u94FE\u63A5\u3001\u5F53\u524D DSH Preset \u53EF\u89C1\u7684\u7F51\u9875\u5DE5\u5177\u3001\n references/real-market-data.md \u4E2D\u7684\u5386\u53F2\u8D44\u6599\u3002\u65E0\u6CD5\u8054\u7F51\u65F6\u5FC5\u987B\u628A\u7ED3\u8BBA\u6807\u4E3A\u5019\u9009\u5047\u8BBE\u3002\n3. \u8BB0\u5F55\u6765\u6E90 URL\u3001\u91C7\u96C6\u65E5\u671F\u3001\u699C\u5355\u53E3\u5F84\u3001\u6709\u6548\u6837\u672C\u6570\u3001\u7F3A\u5931\u5B57\u6BB5\u548C\u5F02\u5E38\u9879\u3002\n4. \u5206\u6790\u60C5\u7EEA\u7C7B\u578B\u3001\u9898\u6750\u70ED\u70B9\u3001\u7BC7\u5E45\u3001\u5F00\u5934\u3001\u7ED3\u5C3E\u3001\u6807\u9898\u3001\u4EBA\u8BBE\u4E0E\u4F20\u64AD\u89E6\u53D1\u70B9\uFF1B\n \u7ED9\u6BCF\u4E2A\u8D8B\u52BF\u6807\u6CE8\u8BC1\u636E\u5F3A\u5EA6\u3001\u9971\u548C\u98CE\u9669\u548C\u6709\u6548\u671F\u3002\n5. \u8F93\u51FA\u5E02\u573A\u6982\u51B5\u3001\u60C5\u7EEA\u70ED\u5EA6\u3001\u9898\u6750\u70ED\u70B9\u3001\u5173\u952E\u6570\u636E\u3001\u98CE\u53E3\u9884\u8B66\u3001\u4E09\u9879\u53EF\u5199\u65B9\u5411\u548C\u590D\u626B\u65F6\u95F4\u3002\n\n\u5F53\u524D Preset \u6CA1\u6709\u7F51\u9875\u80FD\u529B\u4E14\u7528\u6237\u4E5F\u672A\u63D0\u4F9B\u6837\u672C\u65F6\uFF0C\u53EA\u505A\u5386\u53F2\u8D44\u6599\u5206\u6790\u5E76\u5217\u51FA\u9A8C\u8BC1\u52A8\u4F5C\uFF1B\n\u4E0D\u8981\u542F\u52A8 CDP\u3001\u72EC\u7ACB\u6D4F\u89C8\u5668\u6216\u5E76\u884C\u8FD0\u884C\u65F6\u3002`\n};\n\ninterface ParsedSkill {\n readonly name: string;\n readonly description: string;\n readonly content: string;\n readonly userInvocable: boolean;\n}\n\nfunction frontmatterValue(frontmatter: string, key: string): string | undefined {\n const lines = frontmatter.split(/\\r?\\n/u);\n const index = lines.findIndex((line) => new RegExp(`^${key}:\\\\s*`, \"u\").test(line));\n if (index < 0) return undefined;\n const raw = lines[index]?.replace(new RegExp(`^${key}:\\\\s*`, \"u\"), \"\").trim();\n if (raw === undefined) return undefined;\n if (raw === \">\" || raw === \"|\" || raw === \">-\" || raw === \"|-\") {\n const values: string[] = [];\n for (const line of lines.slice(index + 1)) {\n if (/^\\S/u.test(line)) break;\n values.push(line.trim());\n }\n return (raw.startsWith(\">\") ? values.join(\" \") : values.join(\"\\n\")).trim();\n }\n if (raw.startsWith(\"\\\"\") && raw.endsWith(\"\\\"\")) {\n try { return JSON.parse(raw) as string; }\n catch { return raw.slice(1, -1); }\n }\n return raw.replace(/^['\"]|['\"]$/gu, \"\");\n}\n\nexport function parseBundledSkill(source: string): ParsedSkill {\n const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?/u.exec(source);\n if (match?.[1] === undefined) throw new Error(\"Bundled skill is missing YAML frontmatter.\");\n const name = frontmatterValue(match[1], \"name\");\n const description = frontmatterValue(match[1], \"description\");\n if (!name || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(name)) throw new Error(\"Bundled skill has an invalid name.\");\n if (!description) throw new Error(`Bundled skill \"${name}\" has no description.`);\n return {\n name,\n description,\n content: source.slice(match[0].length),\n userInvocable: frontmatterValue(match[1], \"user-invocable\") !== \"false\"\n };\n}\n\nexport function dshSkillContent(name: string, content: string): string {\n const override = DSH_SKILL_OVERRIDES[name];\n const native = DSH_NATIVE_SKILLS[name];\n return `${DSH_SKILL_BRIDGE}${override === undefined ? \"\" : `\\n<skill-specific-dsh-override>${override}</skill-specific-dsh-override>`}\\n\\n${native ?? content}`;\n}\n\nexport function defaultBundledSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/oh-story/skills\")\n : resolve(current, \"oh-story/skills\");\n}\n\nexport function defaultDramaSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/drama/skills\")\n : resolve(current, \"drama/skills\");\n}\n\nexport function defaultNovelToGameSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/novel-to-game/skills\")\n : resolve(current, \"novel-to-game/skills\");\n}\n\nfunction createBundledSkillProvider(\n providerName: string,\n skillRoot: string,\n content: (name: string, source: string) => string\n): SkillProvider {\n const root = resolve(skillRoot);\n return {\n name: providerName,\n async list(): Promise<readonly SkillCandidate[]> {\n const directories = (await readdir(root, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n return Promise.all(directories.map(async (directory): Promise<SkillCandidate> => {\n const path = join(root, directory, \"SKILL.md\");\n const parsed = parseBundledSkill(await readFile(path, \"utf8\"));\n if (parsed.name !== directory) throw new Error(`Bundled skill directory \"${directory}\" does not match name \"${parsed.name}\".`);\n return {\n name: parsed.name,\n description: parsed.description,\n invocation: { modelInvocable: true, userInvocable: parsed.userInvocable },\n provider: providerName,\n source: \"bundled\",\n resourceBase: { kind: \"directory\", path: join(root, directory) },\n rank: BUNDLED_SKILL_RANK,\n locator: pathToFileURL(path),\n path\n };\n }));\n },\n async get(candidate): Promise<SkillDefinition | undefined> {\n if (candidate.provider !== providerName || typeof candidate.path !== \"string\") return undefined;\n const path = resolve(candidate.path);\n const relativePath = relative(root, path);\n if (relativePath === \"\" || relativePath.startsWith(\"..\") || isAbsolute(relativePath)) {\n throw new Error(\"Bundled skill locator escaped the packaged skill root.\");\n }\n const parsed = parseBundledSkill(await readFile(path, \"utf8\"));\n if (parsed.name !== candidate.name) return undefined;\n return {\n name: parsed.name,\n description: parsed.description,\n invocation: { modelInvocable: true, userInvocable: parsed.userInvocable },\n provider: providerName,\n source: \"bundled\",\n resourceBase: { kind: \"directory\", path: join(root, parsed.name) },\n path,\n content: content(parsed.name, parsed.content)\n };\n }\n };\n}\n\nexport function createOhStorySkillProvider(skillRoot = defaultBundledSkillRoot()): SkillProvider {\n return createBundledSkillProvider(STORY_PROVIDER_NAME, skillRoot, dshSkillContent);\n}\n\nexport function dshDramaSkillContent(name: string, content: string): string {\n const override = DSH_DRAMA_OVERRIDES[name];\n return `${DSH_DRAMA_BRIDGE}${override === undefined ? \"\" : `\\n<skill-specific-dsh-override>${override}</skill-specific-dsh-override>`}\\n\\n${content}`;\n}\n\nexport function createDramaSkillProvider(skillRoot = defaultDramaSkillRoot()): SkillProvider {\n return createBundledSkillProvider(DRAMA_PROVIDER_NAME, skillRoot, dshDramaSkillContent);\n}\n\nexport function dshNovelToGameSkillContent(_name: string, content: string): string {\n return `${DSH_GAME_BRIDGE}\\n\\n${content}`;\n}\n\nexport function createNovelToGameSkillProvider(skillRoot = defaultNovelToGameSkillRoot()): SkillProvider {\n return createBundledSkillProvider(GAME_PROVIDER_NAME, skillRoot, dshNovelToGameSkillContent);\n}\n\nexport function defaultVideoRecapSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/video-recap/skills\")\n : resolve(current, \"video-recap/skills\");\n}\n\nexport function dshVideoRecapSkillContent(_name: string, content: string): string {\n return `${DSH_VIDEO_BRIDGE}\\n\\n${content}`;\n}\n\nexport function createVideoRecapSkillProvider(skillRoot = defaultVideoRecapSkillRoot()): SkillProvider {\n return createBundledSkillProvider(VIDEO_PROVIDER_NAME, skillRoot, dshVideoRecapSkillContent);\n}\n", "import type { Context } from \"@deepseek-ai/cordis\";\nimport type { FileSystem, FsTarget } from \"@deepseek-ai/dsh-fs\";\nimport { createUserMessage } from \"@deepseek-ai/dsh-llm\";\nimport type { PostToolDecision, PreToolDecision, ToolExecution } from \"@deepseek-ai/dsh-tools\";\n\nconst MUTATION_TOOLS = new Set([\"write\", \"edit\", \"str_replace_editor\"]);\n\nexport interface StoryMutation {\n readonly root: string;\n readonly path: string;\n readonly chapter?: number;\n}\n\nfunction mutationPath(name: string, args: unknown): string | undefined {\n if (!MUTATION_TOOLS.has(name) || typeof args !== \"object\" || args === null || Array.isArray(args)) return undefined;\n const record = args as Record<string, unknown>;\n if (name === \"str_replace_editor\") {\n if (!new Set([\"create\", \"str_replace\", \"insert\"]).has(String(record.command))) return undefined;\n return typeof record.path === \"string\" && record.path.trim() !== \"\" ? record.path : undefined;\n }\n return typeof record.file_path === \"string\" && record.file_path.trim() !== \"\" ? record.file_path : undefined;\n}\n\nfunction normalizedRelativePath(path: string): string | undefined {\n const segments: string[] = [];\n for (const part of path.split(\"/\")) {\n if (part === \"\" || part === \".\") continue;\n if (part === \"..\") {\n if (segments.length === 0) return undefined;\n segments.pop();\n } else segments.push(part);\n }\n return segments.join(\"/\");\n}\n\nexport function detectStoryMutation(name: string, args: unknown, cwd: string | undefined): StoryMutation | undefined {\n const rawPath = mutationPath(name, args);\n if (cwd === undefined || rawPath === undefined) return undefined;\n const root = cwd.replaceAll(\"\\\\\", \"/\").replace(/\\/$/u, \"\");\n const candidate = rawPath.replaceAll(\"\\\\\", \"/\");\n const absolute = candidate.startsWith(\"/\") || /^[a-z]:\\//iu.test(candidate) || /^[a-z][a-z\\d+.-]*:\\/\\//iu.test(candidate);\n const insideRoot = /^[a-z]:\\//iu.test(root)\n ? candidate.toLowerCase().startsWith(`${root.toLowerCase()}/`)\n : candidate.startsWith(`${root}/`);\n if (absolute && !insideRoot) return undefined;\n const normalized = normalizedRelativePath(absolute ? candidate.slice(root.length + 1) : candidate);\n if (normalized === undefined) return undefined;\n if (!normalized.startsWith(\"\u6B63\u6587/\")) return undefined;\n const chapterText = /\u7B2C0*(\\d+)\u7AE0/u.exec(normalized)?.[1];\n return { root, path: normalized, ...(chapterText === undefined ? {} : { chapter: Number(chapterText) }) };\n}\n\ntype StoryFileSystem = Pick<FileSystem, \"resolve\" | \"contains\" | \"stat\" | \"listDir\">;\n\nasync function storyMutation(exec: ToolExecution, fs: StoryFileSystem): Promise<StoryMutation | undefined> {\n const cwd = exec.agent?.session.header.cwd;\n const path = mutationPath(exec.name, exec.arguments);\n if (cwd === undefined || path === undefined) return undefined;\n try {\n const [rootTarget, mutationTarget] = await Promise.all([\n fs.resolve(cwd, { signal: exec.signal }),\n fs.resolve(path, { cwd, signal: exec.signal })\n ]);\n if (!fs.contains(rootTarget, mutationTarget)) return undefined;\n } catch { return undefined; }\n return detectStoryMutation(exec.name, exec.arguments, cwd);\n}\n\nasync function target(fs: StoryFileSystem, root: string, path: string, signal?: AbortSignal): Promise<FsTarget> {\n return fs.resolve(path, { cwd: root, ...(signal === undefined ? {} : { signal }) });\n}\n\nasync function exists(fs: StoryFileSystem, root: string, path: string, signal?: AbortSignal): Promise<boolean> {\n return target(fs, root, path, signal)\n .then((value) => fs.stat(value, signal))\n .then((info) => info !== undefined, () => false);\n}\n\nasync function hasChapterOutline(fs: StoryFileSystem, root: string, chapter: number, signal?: AbortSignal): Promise<boolean> {\n const entries = await target(fs, root, \"\u5927\u7EB2\", signal)\n .then((directory) => fs.listDir(directory, signal))\n .catch(() => []);\n return entries.some((entry) => entry.type === \"file\"\n && Number(/^\u7EC6\u7EB2_\u7B2C0*(\\d+)\u7AE0.*\\.md$/u.exec(entry.name)?.[1]) === chapter);\n}\n\nexport async function validateStoryMutation(\n fs: StoryFileSystem,\n mutation: StoryMutation,\n signal?: AbortSignal\n): Promise<string | undefined> {\n const hasLongFormLayout = await exists(fs, mutation.root, \"\u5927\u7EB2\", signal)\n || await exists(fs, mutation.root, \"\u8FFD\u8E2A\", signal);\n if (!hasLongFormLayout) return undefined;\n if (!(await exists(fs, mutation.root, \"\u8FFD\u8E2A/_tracking-state.json\", signal))) {\n // Setup/import must be able to bootstrap an existing manuscript before the\n // canonical Tracking file exists. The Skill remains responsible for\n // creating it; hard guards begin once the project has committed Tracking.\n return undefined;\n }\n if (mutation.chapter !== undefined && !(await hasChapterOutline(fs, mutation.root, mutation.chapter, signal))) {\n return `Oh Story \u963B\u6B62\u5199\u5165\u7B2C ${String(mutation.chapter)} \u7AE0\uFF1A\u672A\u627E\u5230\u5BF9\u5E94\u7684 \u5927\u7EB2/\u7EC6\u7EB2_\u7B2CXXX\u7AE0*.md\u3002\u8BF7\u5148\u5B8C\u6210\u7EC6\u7EB2\u3002`;\n }\n return undefined;\n}\n\nexport async function decideStoryMutation(\n exec: ToolExecution,\n next: () => Promise<PreToolDecision>\n): Promise<PreToolDecision> {\n const fs = exec.agent?.ctx.get(\"fs\");\n if (fs === undefined) return next();\n const mutation = await storyMutation(exec, fs);\n if (mutation === undefined) return next();\n const reason = await validateStoryMutation(fs, mutation, exec.signal);\n if (reason !== undefined) return { kind: \"deny\", reason };\n return next();\n}\n\n/**\n * Native DSH equivalents of the upstream prose guards. They join DSH's typed\n * tool waterfall, so decisions remain visible in the official approval/tool UI.\n */\nexport function registerOhStoryHooks(context: Context): void {\n context.on(\"tools/pre-execute\", decideStoryMutation);\n\n context.on(\"tools/post-execute\", async (exec, result, next): Promise<PostToolDecision> => {\n const downstream = await next();\n if (result.isError || downstream.kind !== \"accept\") return downstream;\n const fs = exec.agent?.ctx.get(\"fs\");\n const mutation = fs === undefined ? undefined : await storyMutation(exec, fs);\n if (mutation === undefined) return downstream;\n const reminder = createUserMessage({\n source: { kind: \"plugin\", plugin: \"oh-story\" },\n content: [{\n type: \"text\",\n text: `<oh-story-post-write>\u6B63\u6587 ${mutation.path} \u5DF2\u53D8\u66F4\u3002\u7EE7\u7EED\u5F53\u524D\u6B65\u9AA4\u524D\u6838\u5BF9\u5E76\u66F4\u65B0 _tracking-state.json \u53CA\u5BF9\u5E94\u6D3E\u751F Tracking \u89C6\u56FE\uFF1B\u4E0D\u8981\u628A\u8FD9\u6761\u63D0\u9192\u5F53\u4F5C\u7528\u6237\u7684\u65B0\u5199\u4F5C\u8981\u6C42\u3002</oh-story-post-write>`\n }]\n });\n return {\n ...downstream,\n additionalContexts: [...downstream.additionalContexts ?? [], reminder]\n };\n });\n}\n", "import type { Context } from \"@deepseek-ai/cordis\";\nimport type { ContentBlock } from \"@deepseek-ai/dsh-llm\";\nimport type { SubagentRuntime } from \"@deepseek-ai/dsh-subagent\";\nimport type { JsonValue } from \"@deepseek-ai/dsh-util-values\";\nimport { defineTool, type ToolDefinition } from \"@deepseek-ai/dsh-tools\";\nimport {\n bundledReferenceGuard,\n createOhStoryReferenceTool,\n OH_STORY_REFERENCE_TOOL_NAME\n} from \"./reference-tool.js\";\nimport { OH_STORY_ROLE_NAMES, loadBundledRole, type OhStoryRoleName } from \"./role-provider.js\";\n\nexport const OH_STORY_ROLE_TOOL_NAME = \"oh_story_role\";\nexport type OhStoryRoleSubagents = Pick<SubagentRuntime, \"start\">;\n\nconst roleTools: Readonly<Record<OhStoryRoleName, readonly string[]>> = {\n \"chapter-extractor\": [\"read\", \"glob\", \"grep\"],\n \"character-designer\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\", \"write\", \"edit\"],\n \"consistency-checker\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\"],\n \"narrative-writer\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\", \"write\", \"edit\", \"bash\"],\n \"story-architect\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\", \"write\", \"edit\"],\n \"story-explorer\": [\"read\", \"glob\", \"grep\"],\n \"story-researcher\": [\"read\", \"glob\", \"grep\", \"bash\", \"write\", \"web_search\", \"web_fetch\"]\n};\n\nexport function roleToolFilter(role: OhStoryRoleName): { readonly allow: readonly string[] } {\n return { allow: roleTools[role] };\n}\n\nfunction resultText(output: readonly ContentBlock[]): string {\n return output.map((block) => block.type === \"text\" ? block.text : JSON.stringify(block)).join(\"\\n\");\n}\n\nexport async function createOhStoryRoleTool(subagents?: OhStoryRoleSubagents): Promise<ToolDefinition> {\n const personas = new Map<OhStoryRoleName, string>();\n await Promise.all(OH_STORY_ROLE_NAMES.map(async (role) => {\n personas.set(role, await loadBundledRole(role, undefined, \"native-tools\"));\n }));\n return defineTool({\n name: OH_STORY_ROLE_TOOL_NAME,\n description: \"Run one focused Oh Story specialist as a child of the current DSH Agent. The child inherits DSH model, workspace, permissions, lifecycle, and UI.\",\n parameters: {\n role: {\n type: \"string\",\n required: true,\n enum: OH_STORY_ROLE_NAMES,\n description: \"The exact Oh Story Role to run.\"\n },\n prompt: {\n type: \"string\",\n required: true,\n description: \"A self-contained task. The child inherits the current DSH workspace but not the current in-flight turn.\"\n }\n },\n output: {\n schema: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n role: { type: \"string\", required: true, enum: OH_STORY_ROLE_NAMES },\n runId: { type: \"string\", required: true },\n content: { type: \"array\", required: true, items: { type: \"json\" } }\n }\n },\n render: (_args, value) => [{ type: \"text\", text: resultText(value.content as unknown as ContentBlock[]) }]\n },\n isConcurrencySafe: () => true,\n async execute(args, exec) {\n if (exec.agent === undefined) throw new Error(\"oh_story_role requires a calling DSH Agent.\");\n const persona = personas.get(args.role);\n if (persona === undefined) throw new Error(`Oh Story Role ${args.role} is not bundled.`);\n const allowed = roleToolFilter(args.role).allow.filter((name) =>\n exec.agent?.ctx.tools.get(name, exec.agent) !== undefined);\n const runtime = subagents ?? exec.agent.ctx.get(\"subagents\");\n if (runtime === undefined) throw new Error(\"oh_story_role requires the DSH subagent runtime.\");\n const run = await runtime.start(\"spawn\", {\n label: `oh-story:${args.role}`,\n prompt: [{ type: \"text\", text: args.prompt }],\n parent: exec.agent,\n persona,\n toolFilter: { allow: allowed },\n maxDepth: 1,\n signal: exec.signal\n });\n try {\n const result = await run.result;\n if (result.stopReason !== \"completed\") {\n throw new Error(`Oh Story Role ${args.role} ended with ${result.stopReason}${result.diagnostic === undefined ? \"\" : `: ${result.diagnostic}`}`);\n }\n return {\n role: args.role,\n runId: run.id,\n content: result.output as unknown as JsonValue[]\n };\n } finally {\n await run.dispose();\n }\n }\n });\n}\n\nexport async function registerOhStoryRoleTool(context: Context): Promise<void> {\n const [definition, referenceDefinition] = await Promise.all([\n createOhStoryRoleTool(context.subagents),\n createOhStoryReferenceTool()\n ]);\n context.tools.register(referenceDefinition);\n context.tools.guard(bundledReferenceGuard(referenceDefinition, context.tools));\n let dispose: (() => void) | undefined;\n const mount = (): void => { dispose ??= context.tools.register(definition); };\n const unmount = (): void => { dispose?.(); dispose = undefined; };\n context.on(\"subagent/provider-added\", (provider) => { if (provider.name === \"spawn\") mount(); });\n context.on(\"subagent/provider-removed\", (name) => { if (name === \"spawn\") unmount(); });\n if (context.subagents.getProvider(\"spawn\") !== undefined) mount();\n}\n", "import { readdir, readFile, realpath } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve } from \"node:path\";\nimport { defineTool, type ToolDefinition, type ToolGuard, type ToolRuntime } from \"@deepseek-ai/dsh-tools\";\nimport { defaultBundledSkillRoot } from \"./skill-provider.js\";\n\nexport const OH_STORY_REFERENCE_TOOL_NAME = \"oh_story_bundled_reference\";\n\ninterface BundledReference {\n readonly canonicalPath: string;\n readonly name: string;\n}\n\nasync function collectMarkdown(root: string, directory = root): Promise<string[]> {\n const entries = await readdir(directory, { withFileTypes: true });\n const nested = await Promise.all(entries.map(async (entry): Promise<string[]> => {\n const path = join(directory, entry.name);\n if (entry.isDirectory()) return collectMarkdown(root, path);\n return entry.isFile() && entry.name.endsWith(\".md\") ? [path] : [];\n }));\n return nested.flat();\n}\n\nasync function bundledReferences(storySetupRoot: string): Promise<readonly BundledReference[]> {\n const root = await realpath(resolve(storySetupRoot));\n const referenceRoot = await realpath(join(root, \"references\", \"agent-references\"));\n const referenceDirectory = relative(root, referenceRoot);\n if (referenceDirectory === \"\" || referenceDirectory.startsWith(\"..\") || isAbsolute(referenceDirectory)) {\n throw new Error(\"Bundled Oh Story reference directory escaped its package root.\");\n }\n const values = await Promise.all((await collectMarkdown(referenceRoot)).map(async (path): Promise<BundledReference> => {\n const canonicalPath = await realpath(path);\n const inside = relative(referenceRoot, canonicalPath);\n if (inside === \"\" || inside.startsWith(\"..\") || isAbsolute(inside)) {\n throw new Error(`Bundled Oh Story reference escaped its package root: ${path}`);\n }\n return {\n canonicalPath,\n name: `story-setup/references/agent-references/${inside.replaceAll(\"\\\\\", \"/\")}`\n };\n }));\n return values.sort((left, right) => left.name.localeCompare(right.name));\n}\n\nexport async function createOhStoryReferenceTool(\n storySetupRoot = join(defaultBundledSkillRoot(), \"story-setup\")\n): Promise<ToolDefinition> {\n const references = await bundledReferences(storySetupRoot);\n if (references.length === 0) throw new Error(\"No bundled Oh Story references were found.\");\n const paths = references.map((reference) => reference.name);\n const byName = new Map(references.map((reference) => [reference.name, reference.canonicalPath]));\n return defineTool({\n name: OH_STORY_REFERENCE_TOOL_NAME,\n description: \"Read one exact, pinned Oh Story story-setup reference bundled with this plugin. This does not resolve project Skills or workspace files.\",\n parameters: {\n reference: {\n type: \"string\",\n required: true,\n enum: paths,\n description: \"The exact story-setup reference path named by the active bundled Role.\"\n }\n },\n output: {\n schema: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n reference: { type: \"string\", required: true },\n content: { type: \"string\", required: true }\n }\n },\n render: (_args, value) => [{\n type: \"text\",\n text: `Bundled Oh Story reference: ${value.reference}\\n\\n${value.content}`\n }]\n },\n isConcurrencySafe: () => true,\n async execute(args) {\n const path = byName.get(args.reference);\n if (path === undefined) throw new Error(`Oh Story reference is not bundled: ${args.reference}`);\n return { reference: args.reference, content: await readFile(path, \"utf8\") };\n }\n });\n}\n\n/** Deny a scoped same-name replacement instead of executing untrusted reference code. */\nexport function bundledReferenceGuard(\n definition: ToolDefinition,\n tools: Pick<ToolRuntime, \"get\">\n): ToolGuard {\n return (execution) => execution.name === OH_STORY_REFERENCE_TOOL_NAME\n && tools.get(OH_STORY_REFERENCE_TOOL_NAME, execution.agent) !== definition\n ? \"The pinned Oh Story reference tool was shadowed in this Agent scope.\"\n : undefined;\n}\n", "import { readFile } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport const OH_STORY_ROLE_NAMES = [\n \"chapter-extractor\",\n \"character-designer\",\n \"consistency-checker\",\n \"narrative-writer\",\n \"story-architect\",\n \"story-explorer\",\n \"story-researcher\"\n] as const;\n\nexport type OhStoryRoleName = typeof OH_STORY_ROLE_NAMES[number];\nexport type OhStoryRoleExecution = \"tool-free\" | \"native-tools\";\n\nfunction roleBody(source: string): string {\n const frontmatter = /^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/u.exec(source);\n return source.slice(frontmatter?.[0].length ?? 0).trim();\n}\n\nexport function defaultBundledRoleRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/oh-story/roles\")\n : resolve(current, \"oh-story/roles\");\n}\n\nexport async function loadBundledRole(\n name: OhStoryRoleName,\n roleRoot = defaultBundledRoleRoot(),\n execution: OhStoryRoleExecution = \"tool-free\"\n): Promise<string> {\n const body = roleBody(await readFile(join(resolve(roleRoot), `${name}.md`), \"utf8\"));\n if (body.length === 0) throw new Error(`Bundled role \"${name}\" is empty.`);\n const integration = execution === \"tool-free\"\n ? [\n \"You are running inside an Oh Story review-required DSH collaboration. The caller supplies every permitted input in the prompt.\",\n \"Do not read or write project files, do not call tools, and do not follow legacy .claude/.codex path or deployment instructions in the upstream role text.\",\n \"Return only the output contract requested by the caller; never claim to have changed the project.\"\n ]\n : [\n \"You are running as a native oh-story-dsh specialist. The current DSH workspace and visible tool set are your complete authority boundary.\",\n \"Never inspect or require legacy .claude/.opencode/.codex agent deployment files; this exact pinned Role is already active.\",\n \"Bundled story-setup references are pinned plugin resources, not project files or project Skills. When the upstream Role marks one mandatory, call oh_story_bundled_reference with the exact story-setup/references/agent-references path, then use only the returned content.\",\n \"If oh_story_bundled_reference or a required bundled reference is unavailable, report the missing reference to the caller. Never call the generic skill tool, fall back to a legacy platform path, or claim that an unread reference was used.\",\n \"Use only the tools actually visible to you. Mutate files only when the caller explicitly requests it and your visible DSH tools permit it; otherwise return findings to the caller.\"\n ];\n return [\n `OH_STORY_DSH_ROLE:${name}`,\n ...integration,\n \"\",\n body\n ].join(\"\\n\");\n}\n", "import type { Context } from \"@deepseek-ai/cordis\";\nimport { defineTool, type ToolDefinition } from \"@deepseek-ai/dsh-tools\";\nimport {\n OH_STORY_PRODUCTION_TOOL_NAME,\n PRODUCTION_INTENT_ACTIONS,\n PRODUCTION_INTENT_JOB_KINDS,\n PRODUCTION_INTENT_SECTIONS,\n validateProductionIntent,\n type ProductionIntentArgs\n} from \"./production-intent.js\";\n\nfunction intentMessage(intent: ProductionIntentArgs): string {\n if (intent.action === \"track_job\") return `\u5DF2\u628A ${intent.targetId ?? \"\u751F\u4EA7\u5BF9\u8C61\"} \u7684 ${intent.jobKind ?? \"\u5A92\u4F53\"} \u4EFB\u52A1\u6295\u5F71\u5230 ${intent.episode} \u7684\u4EFB\u52A1\u677F\u3002`;\n if (intent.action === \"set_sequence\") return `\u5DF2\u628A ${String(intent.shotIds?.length ?? 0)} \u4E2A\u955C\u5934\u7684\u987A\u5E8F\u53D1\u9001\u5230 ${intent.episode} \u6210\u7247\u89C6\u56FE\u3002`;\n if (intent.action === \"focus_target\") return `\u5DF2\u8BF7\u6C42 ${intent.episode} \u751F\u4EA7\u89C6\u56FE\u805A\u7126 ${intent.targetId ?? \"\u76EE\u6807\"}\u3002`;\n return `\u5DF2\u628A ${intent.action} \u754C\u9762\u610F\u56FE\u53D1\u9001\u5230 ${intent.episode} \u751F\u4EA7\u5DE5\u4F5C\u53F0\u3002`;\n}\n\nexport function createOhStoryProductionTool(): ToolDefinition {\n return defineTool({\n name: OH_STORY_PRODUCTION_TOOL_NAME,\n description: \"Operate the native oh-story short-drama production projection in the current DSH Session. It can open or focus semantic production targets, set an explicit shot order, or track a job the Agent is actually executing. It never controls cosmetic canvas layout, generates media, changes creator documents, or counts as creator confirmation for paid production.\",\n parameters: {\n action: { type: \"string\", required: true, enum: PRODUCTION_INTENT_ACTIONS, description: \"The exact production UI/task projection operation.\" },\n episode: { type: \"string\", required: true, description: \"Creator-first episode directory, for example \u5267\u96C6/EP001.\" },\n section: { type: \"string\", enum: PRODUCTION_INTENT_SECTIONS },\n targetId: { type: \"string\" },\n shotIds: { type: \"array\", items: { type: \"string\" } },\n jobId: { type: \"string\", description: \"Stable ID that must also appear in produced output filenames.\" },\n jobKind: { type: \"string\", enum: PRODUCTION_INTENT_JOB_KINDS },\n expectedOutputs: { type: \"integer\", description: \"Number of media files this job will produce. Repeat the count the creator approved when re-registering a batch; omit it to keep the count the workbench already recorded.\" },\n prompt: { type: \"string\", description: \"Exact prompt/specification for a tracked job; not a production authorization.\" }\n },\n output: {\n schema: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n action: { type: \"string\", required: true, enum: PRODUCTION_INTENT_ACTIONS },\n episode: { type: \"string\", required: true },\n message: { type: \"string\", required: true }\n }\n },\n render: (_args, value) => [{ type: \"text\", text: value.message }]\n },\n isConcurrencySafe: () => true,\n execute(args) {\n const intent = validateProductionIntent(args);\n return Promise.resolve({ action: intent.action, episode: intent.episode, message: intentMessage(intent) });\n }\n });\n}\n\nexport function registerOhStoryProductionTool(context: Context): void {\n context.tools.register(createOhStoryProductionTool());\n}\n", "export const OH_STORY_PRODUCTION_TOOL_NAME = \"oh_story_production\";\n\nexport const PRODUCTION_INTENT_ACTIONS = [\n \"open_section\",\n \"focus_target\",\n \"set_sequence\",\n \"track_job\"\n] as const;\n\nexport const PRODUCTION_INTENT_SECTIONS = [\"shots\", \"assets\", \"tasks\", \"sequence\", \"canvas\"] as const;\nexport const PRODUCTION_INTENT_JOB_KINDS = [\"image\", \"video\", \"composition\"] as const;\n\nexport type ProductionIntentAction = typeof PRODUCTION_INTENT_ACTIONS[number];\nexport type ProductionIntentSection = typeof PRODUCTION_INTENT_SECTIONS[number];\nexport type ProductionIntentJobKind = typeof PRODUCTION_INTENT_JOB_KINDS[number];\n\nexport interface ProductionIntentArgs {\n readonly action: ProductionIntentAction;\n readonly episode: string;\n readonly section?: ProductionIntentSection | undefined;\n readonly targetId?: string | undefined;\n readonly shotIds?: readonly string[] | undefined;\n readonly jobId?: string | undefined;\n readonly jobKind?: ProductionIntentJobKind | undefined;\n readonly expectedOutputs?: number | undefined;\n readonly prompt?: string | undefined;\n}\n\nfunction requiredText(value: string | undefined, field: string): string {\n const normalized = value?.trim();\n if (!normalized) throw new Error(`oh_story_production ${field} is required for this action.`);\n if (normalized.length > 512) throw new Error(`oh_story_production ${field} is too long.`);\n return normalized;\n}\n\n/** Validate the cross-runtime UI intent without reading or mutating workspace state. */\nexport function validateProductionIntent(args: ProductionIntentArgs): ProductionIntentArgs {\n const episode = args.episode.trim().replaceAll(\"\\\\\", \"/\").replace(/\\/$/u, \"\");\n if (!/^\u5267\u96C6\\/EP\\d{3,}$/u.test(episode)) {\n throw new Error(\"oh_story_production episode must use the creator path form \u5267\u96C6/EP001.\");\n }\n if (args.action === \"open_section\") {\n if (args.section === undefined) throw new Error(\"oh_story_production section is required for open_section.\");\n return { action: args.action, episode, section: args.section };\n }\n if (args.action === \"focus_target\") {\n return { action: args.action, episode, targetId: requiredText(args.targetId, \"targetId\"), section: args.section };\n }\n if (args.action === \"set_sequence\") {\n const shotIds = args.shotIds?.map((value) => value.trim()).filter((value) => value !== \"\") ?? [];\n if (shotIds.length === 0) throw new Error(\"oh_story_production shotIds must contain at least one shot for set_sequence.\");\n if (shotIds.length > 500 || new Set(shotIds).size !== shotIds.length || shotIds.some((value) => !/^SHOT-[A-Z0-9-]+$/u.test(value))) {\n throw new Error(\"oh_story_production shotIds must be unique canonical SHOT-* identifiers.\");\n }\n return { action: args.action, episode, shotIds };\n }\n // Leave expectedOutputs/prompt undefined when the caller omits them: track_job re-registers a job the\n // workbench already created, and defaulting here would silently reset a batch's count to 1.\n const expectedOutputs = args.expectedOutputs;\n if (expectedOutputs !== undefined && (!Number.isInteger(expectedOutputs) || expectedOutputs < 1 || expectedOutputs > 500)) {\n throw new Error(\"oh_story_production expectedOutputs must be an integer between 1 and 500.\");\n }\n if (args.jobKind === undefined) throw new Error(\"oh_story_production jobKind is required for track_job.\");\n const prompt = args.prompt?.trim();\n return {\n action: args.action,\n episode,\n jobId: requiredText(args.jobId, \"jobId\"),\n targetId: requiredText(args.targetId, \"targetId\"),\n jobKind: args.jobKind,\n expectedOutputs,\n prompt: prompt === \"\" ? undefined : prompt\n };\n}\n", "import { createHash } from \"node:crypto\";\nimport { createReadStream } from \"node:fs\";\nimport { readFile as readNodeFile, realpath as nodeRealpath, stat as nodeStat } from \"node:fs/promises\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport { extname, isAbsolute, relative, resolve } from \"node:path\";\nimport { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\nimport type { Context } from \"@deepseek-ai/cordis\";\nimport type { Agent } from \"@deepseek-ai/dsh-agent\";\nimport { FsError, type FileSystem, type FsInfo, type FsTarget, type FsVersion } from \"@deepseek-ai/dsh-fs\";\nimport type {} from \"@deepseek-ai/dsh-host-webserver\";\nimport type { SandboxPolicyService } from \"@deepseek-ai/dsh-sandbox-policy\";\nimport { SessionId } from \"@deepseek-ai/dsh-session\";\nimport type {} from \"@deepseek-ai/dsh-typert-registry\";\nimport { type GameVerificationBinding, WorkspaceVerificationTracker } from \"./game-verification.js\";\nimport { defaultNovelToGameSkillRoot } from \"./skill-provider.js\";\nimport { skipVideoDirectory, summarizeVideoProject, VIDEO_DIRECTORY, videoProjectRoot, visibleVideoPath, type VideoProjectSummary } from \"./video-project.js\";\nimport { isTrustedPreviewNavigation, isTrustedWorkspaceRequest } from \"./workspace-request-trust.js\";\n\nconst STORY_DIRECTORIES = [\"\u6B63\u6587\", \"\u5927\u7EB2\", \"\u8BBE\u5B9A\", \"\u8FFD\u8E2A\", \"\u5BF9\u6807\", \"\u53C2\u8003\u8D44\u6599\"] as const;\nconst DRAMA_DIRECTORIES = [\"\u8F93\u5165\", \"\u9879\u76EE\u5F00\u53D1\", \"\u8BBE\u5B9A\u96C6\", \"\u5267\u96C6\", \"\u4EA4\u4ED8\", \"\u521B\u4F5C\u8005\u51B3\u7B56\", \"\u5BA1\u67E5\"] as const;\nconst GAME_DIRECTORY = \"game-adaptations\";\n// Preview studios need only a small manifest-driven subset, so discover them before a very large\n// prose workspace can consume the shared listing budget.\nconst CREATIVE_DIRECTORIES = [VIDEO_DIRECTORY, GAME_DIRECTORY, ...STORY_DIRECTORIES, ...DRAMA_DIRECTORIES] as const;\nconst ROOT_FILES = new Set([\"short-drama.json\"]);\nconst EDITABLE_EXTENSIONS = new Set([\".md\", \".txt\", \".json\", \".jsonl\"]);\nconst GAME_EDITABLE_EXTENSIONS = new Set([...EDITABLE_EXTENSIONS, \".html\", \".css\", \".js\", \".mjs\", \".cjs\", \".ts\", \".tsx\", \".jsx\"]);\nconst VIDEO_EDITABLE_EXTENSIONS = new Set([...EDITABLE_EXTENSIONS, \".srt\", \".ass\"]);\nconst MEDIA_TYPES: ReadonlyMap<string, string> = new Map([\n [\".png\", \"image/png\"], [\".jpg\", \"image/jpeg\"], [\".jpeg\", \"image/jpeg\"], [\".webp\", \"image/webp\"], [\".gif\", \"image/gif\"],\n [\".mp4\", \"video/mp4\"], [\".webm\", \"video/webm\"], [\".mov\", \"video/quicktime\"], [\".mkv\", \"video/x-matroska\"],\n [\".mp3\", \"audio/mpeg\"], [\".wav\", \"audio/wav\"], [\".m4a\", \"audio/mp4\"]\n]);\nconst MEDIA_MAX_BYTES = 256 * 1_024 * 1_024;\nconst FILE_LIMIT = 1_000;\nconst PREVIEW_FILE_LIMIT = 32 * 1024 * 1024;\nconst BUNDLED_GAME_EXAMPLE = \"jin-ping-mei\";\nconst workspaceVerificationTracker = new WorkspaceVerificationTracker();\nconst execFileAsync = promisify(execFile);\nlet videoPreflightCache: { readonly expires: number; readonly value: VideoPreflightSummary } | undefined;\n\ninterface WorkspaceRouteOptions {\n readonly maxBytes: number;\n readonly trustedHosts?: readonly string[];\n}\n\n/** Host-process capability probe. The Agent's execution world may differ; `video-recap --doctor` is authoritative there. */\ninterface VideoPreflightSummary {\n readonly python: { readonly ok: boolean; readonly version?: string | undefined };\n readonly ffmpeg: { readonly ok: boolean; readonly subtitles: boolean };\n readonly ffprobe: { readonly ok: boolean };\n readonly credentials: { readonly mimo: boolean; readonly fish: boolean; readonly ttsProvider: string };\n}\n\ninterface WorkspaceFile {\n readonly path: string;\n readonly bytes: number;\n readonly version: string;\n readonly kind: \"text\" | \"media\";\n readonly mimeType?: string | undefined;\n}\n\ninterface GameVerificationSummary {\n readonly status: \"NOT_RUN\" | \"FAIL\" | \"PASS\";\n readonly checks: Readonly<Record<string, \"NOT_RUN\" | \"FAIL\" | \"PASS\">>;\n readonly runId?: string | undefined;\n readonly limitations: readonly { readonly scope: string; readonly reason: string }[];\n readonly binding: GameVerificationBinding;\n readonly verifiedPreviewVersion?: string | undefined;\n}\n\ninterface GameProjectSummary {\n readonly id: string;\n readonly root: string;\n readonly title: string;\n readonly source: \"workspace\" | \"example\";\n readonly previewReady: boolean;\n readonly previewUrl?: string | undefined;\n readonly previewVersion: string;\n readonly verification: GameVerificationSummary;\n}\n\ninterface WorkspaceRealm {\n readonly agent: Agent;\n readonly fs: FileSystem;\n readonly sandboxPolicy: SandboxPolicyService;\n readonly cwd: string;\n readonly root: FsTarget;\n}\n\ninterface ReadFileResult {\n readonly content: string;\n readonly bytes: number;\n readonly version: FsVersion;\n}\n\nclass WorkspaceHttpError extends Error {\n constructor(readonly status: number, message: string) { super(message); }\n}\n\nasync function commandOutput(command: string, args: readonly string[]): Promise<string | undefined> {\n try {\n const { stdout, stderr } = await execFileAsync(command, [...args], { encoding: \"utf8\", timeout: 5_000, maxBuffer: 4 * 1_024 * 1_024 });\n return `${stdout}${stderr}`.trim();\n } catch { return undefined; }\n}\n\nfunction pythonVersion(value: string | undefined): { readonly ok: boolean; readonly version?: string | undefined } {\n const match = /Python\\s+(\\d+)\\.(\\d+)(?:\\.(\\d+))?/u.exec(value ?? \"\");\n if (match === null) return { ok: false };\n const major = Number(match[1]);\n const minor = Number(match[2]);\n return { ok: major > 3 || (major === 3 && minor >= 10), version: match[0].replace(/^Python\\s+/u, \"\") };\n}\n\nfunction configured(...names: readonly string[]): boolean {\n return names.some((name) => (process.env[name] ?? \"\") !== \"\");\n}\n\nasync function videoPreflight(): Promise<VideoPreflightSummary> {\n if (videoPreflightCache !== undefined && videoPreflightCache.expires > Date.now()) return videoPreflightCache.value;\n let python: VideoPreflightSummary[\"python\"] = { ok: false };\n for (const command of [\"python3\", \"python\"]) {\n const parsed = pythonVersion(await commandOutput(command, [\"--version\"]));\n if (parsed.version !== undefined) { python = parsed; break; }\n }\n const [ffmpegOutput, ffmpegFilters, ffprobeOutput] = await Promise.all([\n commandOutput(\"ffmpeg\", [\"-version\"]),\n commandOutput(\"ffmpeg\", [\"-hide_banner\", \"-filters\"]),\n commandOutput(\"ffprobe\", [\"-version\"])\n ]);\n const value = {\n python,\n ffmpeg: { ok: ffmpegOutput !== undefined, subtitles: /\\bsubtitles\\b/u.test(ffmpegFilters ?? \"\") },\n ffprobe: { ok: ffprobeOutput !== undefined },\n credentials: {\n // Upstream falls back to the shared MIMO_API_KEY only when a per-service key is unset.\n mimo: configured(\"MIMO_API_KEY\", \"MIMO_VIDEO_API_KEY\", \"MIMO_TTS_API_KEY\", \"MIMO_ASR_API_KEY\"),\n fish: configured(\"FISH_API_KEY\"),\n ttsProvider: process.env.TTS_PROVIDER ?? \"mimo\"\n }\n };\n videoPreflightCache = { expires: Date.now() + 30_000, value };\n return value;\n}\n\nfunction send(response: ServerResponse, status: number, value: unknown): void {\n const body = `${JSON.stringify(value)}\\n`;\n response.writeHead(status, {\n \"content-type\": \"application/json; charset=utf-8\",\n \"content-length\": Buffer.byteLength(body),\n \"cache-control\": \"no-store\",\n \"x-content-type-options\": \"nosniff\"\n });\n response.end(body);\n}\n\nexport interface ByteRange { readonly start: number; readonly end: number }\n\n/**\n * RFC 9110 14.2: a Range this server cannot parse or does not support is ignored (`undefined`, full\n * 200 response); only a well-formed but unsatisfiable range earns a 416 (`null`).\n */\nexport function parseByteRange(value: string | undefined, size: number): ByteRange | undefined | null {\n const match = value === undefined ? null : /^bytes=(\\d*)-(\\d*)$/u.exec(value.trim());\n if (match === null) return undefined;\n const left = match[1] ?? \"\";\n const right = match[2] ?? \"\";\n if (left === \"\") {\n const suffix = Number(right);\n if (right === \"\" || !Number.isSafeInteger(suffix)) return undefined;\n return suffix === 0 || size <= 0 ? null : { start: Math.max(0, size - suffix), end: size - 1 };\n }\n const start = Number(left);\n const requestedEnd = right === \"\" ? Number.MAX_SAFE_INTEGER : Number(right);\n if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd) || requestedEnd < start) return undefined;\n return start >= size ? null : { start, end: Math.min(requestedEnd, size - 1) };\n}\n\nfunction mediaHeaders(mimeType: string, size: number, range: ByteRange | undefined): Record<string, string | number> {\n const start = range?.start ?? 0;\n const end = range?.end ?? size - 1;\n return {\n \"content-type\": mimeType,\n \"content-length\": Math.max(0, end - start + 1),\n \"cache-control\": \"private, max-age=60\",\n \"accept-ranges\": \"bytes\",\n ...(range === undefined ? {} : { \"content-range\": `bytes ${String(start)}-${String(end)}/${String(size)}` }),\n \"x-content-type-options\": \"nosniff\"\n };\n}\n\nfunction sendMediaBytes(request: IncomingMessage, response: ServerResponse, bytes: Uint8Array, mimeType: string): void {\n const range = parseByteRange(typeof request.headers.range === \"string\" ? request.headers.range : undefined, bytes.byteLength);\n if (range === null) {\n response.writeHead(416, { \"content-range\": `bytes */${String(bytes.byteLength)}`, \"cache-control\": \"no-store\" });\n response.end();\n return;\n }\n const start = range?.start ?? 0;\n const end = range?.end ?? bytes.byteLength - 1;\n const body = bytes.subarray(start, end + 1);\n response.writeHead(range === undefined ? 200 : 206, mediaHeaders(mimeType, bytes.byteLength, range));\n response.end(request.method === \"HEAD\" ? undefined : Buffer.from(body));\n}\n\n/**\n * Resolve the target to a path this web host may open directly, or `undefined` when it may not.\n * `processPath` is canonical in the backend's execution world, which is not necessarily this\n * process's, so containment is re-checked against the host-visible workspace root: a remote path\n * that happens to exist locally never becomes a stream.\n */\nasync function hostWorkspaceFile(realm: WorkspaceRealm, target: FsTarget, expectedSize: number): Promise<string | undefined> {\n const [root, path] = await Promise.all([\n nodeRealpath(realm.fs.processPath(realm.root)),\n nodeRealpath(realm.fs.processPath(target))\n ]);\n const inside = relative(root, path);\n if (inside === \"\" || inside.startsWith(\"..\") || isAbsolute(inside)) return undefined;\n const local = await nodeStat(path);\n return local.isFile() && local.size === expectedSize ? path : undefined;\n}\n\nasync function sendWorkspaceMedia(request: IncomingMessage, response: ServerResponse, realm: WorkspaceRealm, target: FsTarget, info: FsInfo, mimeType: string): Promise<void> {\n const expectedSize = info.size;\n if (expectedSize !== undefined) {\n // A remote filesystem may expose a process path this web host cannot read; fall back to its\n // bounded binary API for modest files.\n const processPath = await hostWorkspaceFile(realm, target, expectedSize).catch(() => undefined);\n if (processPath !== undefined) {\n const range = parseByteRange(typeof request.headers.range === \"string\" ? request.headers.range : undefined, expectedSize);\n if (range === null) {\n response.writeHead(416, { \"content-range\": `bytes */${String(expectedSize)}`, \"cache-control\": \"no-store\" });\n response.end();\n return;\n }\n response.writeHead(range === undefined ? 200 : 206, mediaHeaders(mimeType, expectedSize, range));\n if (request.method === \"HEAD\") { response.end(); return; }\n const stream = createReadStream(processPath, range === undefined ? undefined : { start: range.start, end: range.end });\n request.once(\"close\", () => { if (!response.writableEnded) stream.destroy(); });\n stream.on(\"error\", () => { if (!response.headersSent) response.destroy(); else response.end(); });\n stream.pipe(response);\n return;\n }\n if (expectedSize > MEDIA_MAX_BYTES) throw new WorkspaceHttpError(413, \"\u8FDC\u7A0B\u5A92\u4F53\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u56DE\u9000\u9884\u89C8\u5927\u5C0F\u9650\u5236\u3002\");\n }\n sendMediaBytes(request, response, await realm.fs.readBytes(target, undefined, MEDIA_MAX_BYTES), mimeType);\n}\n\nasync function jsonBody(request: IncomingMessage, maxBytes: number): Promise<Record<string, unknown>> {\n const chunks: Buffer[] = [];\n let size = 0;\n for await (const chunk of request as AsyncIterable<Uint8Array>) {\n const value = Buffer.from(chunk);\n size += value.byteLength;\n if (size > maxBytes) throw new WorkspaceHttpError(413, \"\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927\u3002\");\n chunks.push(value);\n }\n try {\n const value = JSON.parse(Buffer.concat(chunks).toString(\"utf8\")) as unknown;\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new Error();\n return value as Record<string, unknown>;\n } catch {\n throw new WorkspaceHttpError(400, \"\u8BF7\u6C42\u5FC5\u987B\u662F JSON \u5BF9\u8C61\u3002\");\n }\n}\n\nfunction safeRelativePath(path: string): boolean {\n return path !== \"\"\n && !path.startsWith(\"/\")\n && !path.includes(\"\\\\\")\n && !path.split(\"/\").some((segment) => segment === \"\" || segment === \".\" || segment === \"..\");\n}\n\nfunction editablePath(path: string): boolean {\n const extensions = path.startsWith(`${GAME_DIRECTORY}/`) ? GAME_EDITABLE_EXTENSIONS\n : path.startsWith(`${VIDEO_DIRECTORY}/`) ? VIDEO_EDITABLE_EXTENSIONS\n : EDITABLE_EXTENSIONS;\n return extensions.has(extname(path).toLocaleLowerCase());\n}\n\nexport function assertCreativePath(path: string, kind: \"text\" | \"media\"): void {\n if (kind === \"text\" ? !editablePath(path) : !MEDIA_TYPES.has(extname(path).toLocaleLowerCase())) {\n throw new WorkspaceHttpError(415, kind === \"text\" ? \"\u5DE5\u4F5C\u53F0\u4E0D\u652F\u6301\u7F16\u8F91\u8BE5\u6587\u4EF6\u7C7B\u578B\u3002\" : \"\u76EE\u6807\u4E0D\u662F\u53D7\u652F\u6301\u7684\u77ED\u5267\u5A92\u4F53\u6587\u4EF6\u3002\");\n }\n if (!safeRelativePath(path)) {\n throw new WorkspaceHttpError(403, \"\u6587\u4EF6\u8DEF\u5F84\u4E0D\u5728\u521B\u4F5C\u5DE5\u4F5C\u53F0\u4E2D\u3002\");\n }\n const root = path.split(\"/\", 1)[0];\n if (!CREATIVE_DIRECTORIES.some((directory) => directory === root) && !ROOT_FILES.has(path)) {\n throw new WorkspaceHttpError(403, \"\u6587\u4EF6\u8DEF\u5F84\u4E0D\u5728\u521B\u4F5C\u5DE5\u4F5C\u53F0\u4E2D\u3002\");\n }\n}\n\nexport function mediaMimeTypeForPath(path: string): string | undefined {\n return MEDIA_TYPES.get(extname(path).toLocaleLowerCase());\n}\n\nasync function workspaceRealmForSession(context: Context, rawId: string): Promise<WorkspaceRealm> {\n if (rawId === \"\") throw new WorkspaceHttpError(400, \"\u7F3A\u5C11 DSH sessionId\u3002\");\n const lookup = context.typert.lookups.get(\"agent\");\n if (lookup === undefined) throw new WorkspaceHttpError(503, \"DSH Agent lookup \u5F53\u524D\u4E0D\u53EF\u7528\u3002\");\n let agent: Agent | undefined;\n try {\n agent = await lookup.resolve(SessionId(rawId)) as Agent | undefined;\n } catch {\n throw new WorkspaceHttpError(404, \"DSH \u4F1A\u8BDD\u4E0D\u53EF\u7528\u3002\");\n }\n if (agent === undefined) throw new WorkspaceHttpError(404, \"DSH \u4F1A\u8BDD\u4E0D\u53EF\u7528\u3002\");\n if (agent.session.header.parentSession !== undefined || agent.session.header.origin === \"subagent\") {\n throw new WorkspaceHttpError(403, \"\u5B50 Agent \u4F1A\u8BDD\u4E0D\u5F00\u653E\u521B\u4F5C\u7F16\u8F91\u5668\u3002\");\n }\n const cwd = agent.session.header.cwd;\n if (cwd === undefined) throw new WorkspaceHttpError(409, \"\u5F53\u524D DSH \u4F1A\u8BDD\u6CA1\u6709\u5DE5\u4F5C\u76EE\u5F55\u3002\");\n const fs = agent.ctx.get(\"fs\");\n const sandboxPolicy = agent.ctx.get(\"sandboxPolicy\");\n if (fs === undefined || sandboxPolicy === undefined) throw new WorkspaceHttpError(503, \"DSH \u6587\u4EF6\u7CFB\u7EDF\u5F53\u524D\u4E0D\u53EF\u7528\u3002\");\n return { agent, fs, sandboxPolicy, cwd, root: await fs.resolve(cwd) };\n}\n\nasync function workspaceRealm(context: Context, url: URL): Promise<WorkspaceRealm> {\n const rawId = url.searchParams.get(\"sessionId\");\n if (rawId === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11 DSH sessionId\u3002\");\n return workspaceRealmForSession(context, rawId);\n}\n\nasync function creativeTarget(realm: WorkspaceRealm, path: string, kind: \"text\" | \"media\" = \"text\"): Promise<FsTarget> {\n assertCreativePath(path, kind);\n const target = await realm.fs.resolve(path, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, target)) throw new WorkspaceHttpError(403, \"\u6587\u4EF6\u8DEF\u5F84\u79BB\u5F00\u4E86 DSH \u5DE5\u4F5C\u76EE\u5F55\u3002\");\n return target;\n}\n\nfunction requireRegularFile(info: FsInfo | undefined): FsInfo {\n if (info === undefined) throw new WorkspaceHttpError(404, \"\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\");\n if (info.type !== \"file\") throw new WorkspaceHttpError(415, \"\u76EE\u6807\u4E0D\u662F\u53EF\u7F16\u8F91\u7684\u666E\u901A\u6587\u4EF6\u3002\");\n return info;\n}\n\n/** Read bytes and a matching opaque version, retrying if a writer wins the read window. */\nasync function readVersionedFile(fs: FileSystem, target: FsTarget, maxBytes: number): Promise<ReadFileResult> {\n for (let attempt = 0; attempt < 3; attempt += 1) {\n const before = requireRegularFile(await fs.stat(target));\n if (before.size !== undefined && before.size > maxBytes) throw new WorkspaceHttpError(413, \"\u6587\u4EF6\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u5927\u5C0F\u9650\u5236\u3002\");\n const bytes = await fs.readBytes(target, undefined, maxBytes);\n const after = requireRegularFile(await fs.stat(target));\n if (before.version !== after.version) continue;\n let content: string;\n try {\n content = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n } catch {\n throw new WorkspaceHttpError(415, \"\u6587\u4EF6\u4E0D\u662F\u6709\u6548\u7684 UTF-8 \u6587\u672C\u3002\");\n }\n return { content, bytes: bytes.byteLength, version: after.version };\n }\n throw new WorkspaceHttpError(409, \"\u6587\u4EF6\u6B63\u5728\u88AB\u4FEE\u6539\uFF0C\u8BF7\u91CD\u8BD5\u3002\");\n}\n\nasync function listFiles(realm: WorkspaceRealm): Promise<WorkspaceFile[]> {\n const files: WorkspaceFile[] = [];\n const walk = async (path: string, directory: FsTarget): Promise<void> => {\n for (const entry of await realm.fs.listDir(directory)) {\n if (entry.name.startsWith(\".\") || !realm.fs.contains(realm.root, entry.target)) continue;\n const childPath = `${path}/${entry.name}`;\n if (entry.type === \"directory\") {\n if (!skipVideoDirectory(childPath)) await walk(childPath, entry.target);\n }\n else if (entry.type === \"file\" && (editablePath(childPath) || MEDIA_TYPES.has(extname(entry.name).toLocaleLowerCase()))) {\n const info = entry.version === undefined || entry.size === undefined ? await realm.fs.stat(entry.target) : undefined;\n const version = entry.version ?? info?.version;\n const mimeType = MEDIA_TYPES.get(extname(entry.name).toLocaleLowerCase());\n if (version !== undefined && (!childPath.startsWith(`${VIDEO_DIRECTORY}/`) || visibleVideoPath(childPath))) {\n files.push({ path: childPath, bytes: entry.size ?? info?.size ?? 0, version, kind: mimeType === undefined ? \"text\" : \"media\", mimeType });\n }\n }\n if (files.length >= FILE_LIMIT) return;\n }\n };\n for (const directory of CREATIVE_DIRECTORIES) {\n const target = await realm.fs.resolve(directory, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, target)) continue;\n const info = await realm.fs.stat(target);\n if (info?.type === \"directory\") await walk(directory, target);\n if (files.length >= FILE_LIMIT) break;\n }\n for (const path of ROOT_FILES) {\n const target = await creativeTarget(realm, path);\n const info = await realm.fs.stat(target);\n if (info?.type === \"file\") files.push({ path, bytes: info.size ?? 0, version: info.version, kind: \"text\" });\n }\n return files.sort((left, right) => left.path.localeCompare(right.path, \"zh-Hans-CN\"));\n}\n\nasync function metadata(realm: WorkspaceRealm, files: readonly WorkspaceFile[], path: string, maxBytes: number): Promise<{ readonly value: unknown; readonly error?: string }> {\n if (!files.some((file) => file.path === path)) return { value: null };\n try {\n const target = await creativeTarget(realm, path);\n return { value: JSON.parse((await readVersionedFile(realm.fs, target, maxBytes)).content) as unknown };\n } catch (error) {\n return { value: null, error: error instanceof SyntaxError ? `${path} \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002` : `${path} \u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002` };\n }\n}\n\nfunction token(value: string): string {\n return Buffer.from(value, \"utf8\").toString(\"base64url\");\n}\n\nfunction untoken(value: string): string {\n try { return Buffer.from(value, \"base64url\").toString(\"utf8\"); }\n catch { throw new WorkspaceHttpError(400, \"\u6E38\u620F\u9884\u89C8\u6807\u8BC6\u65E0\u6548\u3002\"); }\n}\n\nexport function gameRoot(path: string): boolean {\n // Reject only what is actually unsafe; fs.resolve + fs.contains remain the real boundary.\n // A stricter slug allowlist silently hid legitimate project names (spaces, \u00B7, leading _, NFD).\n const parts = path.split(\"/\");\n const name = parts[1];\n return parts.length === 2 && parts[0] === GAME_DIRECTORY && name !== undefined\n && name !== \"\" && name !== \".\" && name !== \"..\" && name.length <= 128\n && !name.startsWith(\".\") && !name.includes(\"\\\\\");\n}\n\nfunction normalizedVerification(\n value: unknown,\n binding: GameVerificationBinding,\n verifiedPreviewVersion?: string\n): GameVerificationSummary {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return { status: \"NOT_RUN\", checks: {}, limitations: [], binding };\n }\n const record = value as Record<string, unknown>;\n const status = record.status === \"PASS\" || record.status === \"FAIL\" ? record.status : \"NOT_RUN\";\n const rawChecks = typeof record.checks === \"object\" && record.checks !== null && !Array.isArray(record.checks)\n ? record.checks as Record<string, unknown>\n : {};\n const checks: Record<string, \"NOT_RUN\" | \"FAIL\" | \"PASS\"> = {};\n for (const name of [\"launch\", \"render\", \"input\", \"coreLoop\", \"outcome\", \"restart\"]) {\n const check = rawChecks[name];\n checks[name] = check === \"PASS\" || check === \"FAIL\" ? check : \"NOT_RUN\";\n }\n const completeRun = typeof record.completeRun === \"object\" && record.completeRun !== null && !Array.isArray(record.completeRun)\n ? record.completeRun as Record<string, unknown>\n : {};\n const limitations = Array.isArray(record.limitations) ? record.limitations.flatMap((entry) => {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) return [];\n const item = entry as Record<string, unknown>;\n return typeof item.scope === \"string\" && typeof item.reason === \"string\"\n ? [{ scope: item.scope, reason: item.reason }]\n : [];\n }) : [];\n return {\n status,\n checks,\n runId: typeof completeRun.id === \"string\" ? completeRun.id : undefined,\n limitations,\n binding,\n verifiedPreviewVersion\n };\n}\n\nasync function workspaceText(realm: WorkspaceRealm, path: string, maxBytes: number): Promise<string | undefined> {\n const target = await realm.fs.resolve(path, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, target) || (await realm.fs.stat(target))?.type !== \"file\") return undefined;\n return (await readVersionedFile(realm.fs, target, maxBytes)).content;\n}\n\nasync function previewDigest(realm: WorkspaceRealm, projectRoot: string): Promise<{ readonly ready: boolean; readonly version: string }> {\n const appPath = `${projectRoot}/build/app`;\n const app = await realm.fs.resolve(appPath, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, app) || (await realm.fs.stat(app))?.type !== \"directory\") return { ready: false, version: \"missing\" };\n const entries: string[] = [];\n let ready = false;\n const visit = async (directory: FsTarget, path: string): Promise<void> => {\n for (const entry of await realm.fs.listDir(directory)) {\n if (entry.name.startsWith(\".\") || !realm.fs.contains(app, entry.target)) continue;\n const childPath = path === \"\" ? entry.name : `${path}/${entry.name}`;\n if (entry.type === \"directory\") await visit(entry.target, childPath);\n else if (entry.type === \"file\") {\n const info = entry.version === undefined ? await realm.fs.stat(entry.target) : undefined;\n const version = entry.version ?? info?.version;\n if (version !== undefined) entries.push(`${childPath}\\0${version}`);\n if (childPath === \"index.html\") ready = true;\n }\n if (entries.length >= 5_000) return;\n }\n };\n await visit(app, \"\");\n return { ready, version: createHash(\"sha256\").update(entries.sort().join(\"\\n\")).digest(\"hex\").slice(0, 16) };\n}\n\nfunction headingTitle(content: string | undefined, fallback: string): string {\n const heading = content?.split(/\\r?\\n/u).find((line) => /^#\\s+/u.test(line));\n return heading?.replace(/^#\\s+/u, \"\").replace(/^PRODUCT_BRIEF\\s*[\u00B7\u30FB:]?\\s*/iu, \"\").trim() || fallback;\n}\n\nasync function workspaceGameProjects(\n realm: WorkspaceRealm,\n files: readonly WorkspaceFile[],\n sessionId: string,\n maxBytes: number\n): Promise<GameProjectSummary[]> {\n const roots = [...new Set(files.flatMap((file) => {\n const parts = file.path.split(\"/\");\n return parts[0] === GAME_DIRECTORY && parts[1] !== undefined ? [`${GAME_DIRECTORY}/${parts[1]}`] : [];\n }))].filter(gameRoot).sort();\n return Promise.all(roots.map(async (root) => {\n const id = root.slice(`${GAME_DIRECTORY}/`.length);\n const qaPath = `${root}/qa/verification.json`;\n const qaFile = files.find((file) => file.path === qaPath);\n // Isolate per-project metadata failures: an unreadable brief, a non-UTF-8 or oversized\n // verification file, or a build/app subtree removed mid-rebuild must degrade this one card,\n // never abort the shared workspace listing (which also carries the story and drama trees).\n const [brief, qa, preview] = await Promise.all([\n workspaceText(realm, `${root}/PRODUCT_BRIEF.md`, maxBytes).catch(() => undefined),\n workspaceText(realm, qaPath, maxBytes).catch(() => undefined),\n previewDigest(realm, root).catch(() => ({ ready: false, version: \"unavailable\" }))\n ]);\n let verification: unknown;\n try { verification = qa === undefined ? undefined : JSON.parse(qa) as unknown; }\n catch { verification = undefined; }\n const freshness = workspaceVerificationTracker.observe(`${sessionId}\\0${root}`, qaFile?.version, preview.version);\n return {\n id: `workspace:${id}`,\n root,\n title: headingTitle(brief, id),\n source: \"workspace\" as const,\n previewReady: preview.ready,\n previewUrl: preview.ready\n ? `/oh-story/game-preview/workspace/${token(sessionId)}/${token(root)}/index.html`\n : undefined,\n previewVersion: preview.version,\n verification: normalizedVerification(verification, freshness.binding, freshness.verifiedPreviewVersion)\n };\n }));\n}\n\nasync function workspaceVideoProjects(realm: WorkspaceRealm, files: readonly WorkspaceFile[], maxBytes: number): Promise<VideoProjectSummary[]> {\n const roots = [...new Set(files.flatMap((file) => {\n const root = videoProjectRoot(file.path);\n return root === undefined ? [] : [root];\n }))].sort((left, right) => left.localeCompare(right, \"zh-Hans-CN\"));\n return Promise.all(roots.map(async (root) => {\n const findPath = (name: string): string | undefined => files.find((file) => file.path.startsWith(`${root}/`) && file.path.split(\"/\").at(-1) === name)?.path;\n const readJson = async (name: string): Promise<unknown> => {\n const path = findPath(name);\n if (path === undefined) return undefined;\n const content = await workspaceText(realm, path, maxBytes).catch(() => undefined);\n if (content === undefined) return undefined;\n try { return JSON.parse(content) as unknown; }\n catch { return undefined; }\n };\n const [project, runManifest, assembly] = await Promise.all([\n readJson(\"project.json\"),\n readJson(\"recap_run_manifest.json\"),\n readJson(\"assembly_manifest.json\")\n ]);\n return summarizeVideoProject(root, files, { project, runManifest, assembly });\n }));\n}\n\nfunction bundledExampleRoot(): string {\n return resolve(defaultNovelToGameSkillRoot(), `../examples/${BUNDLED_GAME_EXAMPLE}`);\n}\n\nasync function bundledGameExample(): Promise<GameProjectSummary> {\n const root = bundledExampleRoot();\n const [example, verification, manifest] = await Promise.all([\n readNodeFile(resolve(root, \"example.json\"), \"utf8\"),\n readNodeFile(resolve(root, \"qa/verification.json\"), \"utf8\"),\n readNodeFile(resolve(defaultNovelToGameSkillRoot(), \"../manifest.json\"), \"utf8\")\n ]);\n const exampleJson = JSON.parse(example) as { readonly title?: unknown };\n const manifestJson = JSON.parse(manifest) as { readonly upstream?: { readonly commit?: unknown } };\n const previewVersion = typeof manifestJson.upstream?.commit === \"string\" ? manifestJson.upstream.commit.slice(0, 16) : \"bundled\";\n return {\n id: `example:${BUNDLED_GAME_EXAMPLE}`,\n root: `examples/${BUNDLED_GAME_EXAMPLE}`,\n title: typeof exampleJson.title === \"string\" ? exampleJson.title : \"\u91D1\u74F6\u6885 \u00B7 \u98CE\u6708\u603B\u8D26\",\n source: \"example\",\n previewReady: true,\n previewUrl: `/oh-story/game-preview/example/${BUNDLED_GAME_EXAMPLE}/index.html`,\n previewVersion,\n verification: normalizedVerification(JSON.parse(verification) as unknown, \"PINNED\", previewVersion)\n };\n}\n\nfunction previewContentType(path: string): string {\n switch (extname(path).toLocaleLowerCase()) {\n case \".html\": return \"text/html; charset=utf-8\";\n case \".css\": return \"text/css; charset=utf-8\";\n case \".js\":\n case \".mjs\": return \"text/javascript; charset=utf-8\";\n case \".json\": return \"application/json; charset=utf-8\";\n case \".svg\": return \"image/svg+xml\";\n case \".png\": return \"image/png\";\n case \".jpg\":\n case \".jpeg\": return \"image/jpeg\";\n case \".webp\": return \"image/webp\";\n case \".gif\": return \"image/gif\";\n case \".woff\": return \"font/woff\";\n case \".woff2\": return \"font/woff2\";\n case \".wasm\": return \"application/wasm\";\n case \".mp3\": return \"audio/mpeg\";\n case \".ogg\": return \"audio/ogg\";\n default: return \"application/octet-stream\";\n }\n}\n\nfunction previewAssetSources(request: IncomingMessage): string {\n const authority = request.headers.host;\n if (authority === undefined) return \"'none'\";\n const prefix = `${authority}/oh-story/game-preview/`;\n return `http://${prefix} https://${prefix}`;\n}\n\n/**\n * Emitted for EVERY preview response, not just HTML. previewContentType serves .svg as\n * image/svg+xml \u2014 an active document type \u2014 so a game that self-navigates its frame to a scripted\n * SVG would otherwise land in a document with no policy at all, while the iframe sandbox flags\n * (which do persist across that navigation) still grant it script execution. The `sandbox`\n * directive makes each response self-confining regardless of the iframe attribute.\n */\nexport function previewContentSecurityPolicy(assets: string): string {\n return [\n \"sandbox allow-scripts allow-forms allow-modals allow-downloads allow-same-origin\",\n \"default-src 'none'\",\n `script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${assets}`,\n `style-src 'unsafe-inline' ${assets}`,\n `img-src data: blob: ${assets}`,\n `media-src data: blob: ${assets}`,\n `font-src data: ${assets}`,\n `connect-src ${assets}`,\n `worker-src blob: ${assets}`,\n `manifest-src ${assets}`,\n \"object-src 'none'\",\n \"base-uri 'none'\",\n \"form-action 'none'\",\n \"frame-ancestors 'self' http://127.0.0.1:* http://localhost:*\"\n ].join(\"; \");\n}\n\nfunction sendPreview(request: IncomingMessage, response: ServerResponse, path: string, bytes: Uint8Array): void {\n const assets = previewAssetSources(request);\n response.writeHead(200, {\n \"content-type\": previewContentType(path),\n \"content-length\": bytes.byteLength,\n \"cache-control\": \"no-store\",\n \"x-content-type-options\": \"nosniff\",\n \"cross-origin-resource-policy\": \"cross-origin\",\n \"access-control-allow-origin\": \"*\",\n \"content-security-policy\": previewContentSecurityPolicy(assets),\n });\n response.end(bytes);\n}\n\nasync function previewBytes(context: Context, pathname: string): Promise<{ readonly path: string; readonly bytes: Uint8Array }> {\n let segments: string[];\n try {\n segments = pathname.split(\"/\").slice(3).map((segment) => decodeURIComponent(segment));\n } catch {\n throw new WorkspaceHttpError(400, \"\u6E38\u620F\u9884\u89C8\u5730\u5740\u65E0\u6548\u3002\");\n }\n const kind = segments.shift();\n if (kind === \"example\") {\n const id = segments.shift();\n const path = segments.join(\"/\") || \"index.html\";\n if (id !== BUNDLED_GAME_EXAMPLE || !safeRelativePath(path)) throw new WorkspaceHttpError(404, \"\u6E38\u620F\u793A\u4F8B\u4E0D\u5B58\u5728\u3002\");\n const appRoot = resolve(bundledExampleRoot(), \"build/app\");\n const target = resolve(appRoot, path);\n const escaped = relative(appRoot, target);\n if (escaped.startsWith(\"..\") || isAbsolute(escaped)) throw new WorkspaceHttpError(403, \"\u9884\u89C8\u8D44\u6E90\u79BB\u5F00\u4E86\u6E38\u620F\u76EE\u5F55\u3002\");\n const info = await nodeStat(target).catch(() => undefined);\n if (!info?.isFile()) throw new WorkspaceHttpError(404, \"\u9884\u89C8\u8D44\u6E90\u4E0D\u5B58\u5728\u3002\");\n if (info.size > PREVIEW_FILE_LIMIT) throw new WorkspaceHttpError(413, \"\u9884\u89C8\u8D44\u6E90\u8FC7\u5927\u3002\");\n return { path, bytes: await readNodeFile(target) };\n }\n if (kind === \"workspace\") {\n const session = segments.shift();\n const project = segments.shift();\n const path = segments.join(\"/\") || \"index.html\";\n if (session === undefined || project === undefined || !safeRelativePath(path)) throw new WorkspaceHttpError(400, \"\u6E38\u620F\u9884\u89C8\u5730\u5740\u65E0\u6548\u3002\");\n const realm = await workspaceRealmForSession(context, untoken(session));\n const root = untoken(project);\n if (!gameRoot(root)) throw new WorkspaceHttpError(403, \"\u6E38\u620F\u9879\u76EE\u8DEF\u5F84\u65E0\u6548\u3002\");\n const appRoot = await realm.fs.resolve(`${root}/build/app`, { cwd: realm.cwd });\n const target = await realm.fs.resolve(`${root}/build/app/${path}`, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, appRoot) || !realm.fs.contains(appRoot, target)) {\n throw new WorkspaceHttpError(403, \"\u9884\u89C8\u8D44\u6E90\u79BB\u5F00\u4E86\u6E38\u620F\u76EE\u5F55\u3002\");\n }\n const info = requireRegularFile(await realm.fs.stat(target));\n if (info.size !== undefined && info.size > PREVIEW_FILE_LIMIT) throw new WorkspaceHttpError(413, \"\u9884\u89C8\u8D44\u6E90\u8FC7\u5927\u3002\");\n return { path, bytes: await realm.fs.readBytes(target, undefined, PREVIEW_FILE_LIMIT) };\n }\n throw new WorkspaceHttpError(404, \"\u6E38\u620F\u9884\u89C8\u4E0D\u5B58\u5728\u3002\");\n}\n\nfunction mapFsError(error: unknown): WorkspaceHttpError | undefined {\n if (!(error instanceof FsError)) return undefined;\n switch (error.code) {\n case \"FS_NOT_FOUND\": return new WorkspaceHttpError(404, \"\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\");\n case \"FS_TOO_LARGE\": return new WorkspaceHttpError(413, \"\u6587\u4EF6\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u5927\u5C0F\u9650\u5236\u3002\");\n case \"FS_NOT_TEXT\":\n case \"FS_NOT_REGULAR_FILE\": return new WorkspaceHttpError(415, \"\u76EE\u6807\u4E0D\u662F\u53EF\u7F16\u8F91\u7684\u6587\u672C\u6587\u4EF6\u3002\");\n case \"FS_PERMISSION_DENIED\":\n case \"FS_SANDBOX_DENIED\": return new WorkspaceHttpError(403, \"\u5F53\u524D DSH \u6743\u9650\u4E0D\u5141\u8BB8\u4FEE\u6539\u8BE5\u6587\u4EF6\u3002\");\n case \"FS_STALE_VERSION\":\n case \"FS_NOT_OBSERVED\": return new WorkspaceHttpError(412, \"\u6587\u4EF6\u5DF2\u5728\u78C1\u76D8\u4E0A\u66F4\u65B0\u3002\u8BF7\u5904\u7406\u51B2\u7A81\u540E\u518D\u4FDD\u5B58\u3002\");\n case \"FS_ABORTED\": return new WorkspaceHttpError(409, \"\u6587\u4EF6\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002\");\n default: return new WorkspaceHttpError(500, \"DSH \u6587\u4EF6\u7CFB\u7EDF\u64CD\u4F5C\u5931\u8D25\u3002\");\n }\n}\n\nasync function handle(context: Context, request: IncomingMessage, response: ServerResponse, options: WorkspaceRouteOptions): Promise<void> {\n try {\n const url = new URL(request.url ?? \"/\", \"http://127.0.0.1\");\n const gamePreview = url.pathname.startsWith(\"/oh-story/game-preview/\");\n const trusted = gamePreview\n ? isTrustedPreviewNavigation(request, options.trustedHosts ?? [])\n : isTrustedWorkspaceRequest(request, options.trustedHosts ?? []);\n if (!trusted) throw new WorkspaceHttpError(403, \"\u8BF7\u6C42\u6765\u6E90\u4E0D\u53D7\u4FE1\u4EFB\u3002\");\n if (gamePreview && request.method === \"GET\") {\n const preview = await previewBytes(context, url.pathname);\n sendPreview(request, response, preview.path, preview.bytes);\n return;\n }\n if (url.pathname === \"/oh-story/workspace\" && request.method === \"GET\") {\n const realm = await workspaceRealm(context, url);\n const files = await listFiles(realm);\n const tracking = await metadata(realm, files, \"\u8FFD\u8E2A/_tracking-state.json\", options.maxBytes);\n const shortDrama = await metadata(realm, files, \"short-drama.json\", options.maxBytes);\n const metadataErrors = [tracking.error, shortDrama.error].filter((value): value is string => value !== undefined);\n const sessionId = url.searchParams.get(\"sessionId\");\n if (sessionId === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11 DSH sessionId\u3002\");\n const games = [\n ...await workspaceGameProjects(realm, files, sessionId, options.maxBytes),\n await bundledGameExample()\n ];\n const videos = await workspaceVideoProjects(realm, files, options.maxBytes);\n send(response, 200, { cwd: realm.cwd, files, games, videos, tracking: tracking.value, shortDrama: shortDrama.value, metadataErrors, mode: \"dsh-session\" });\n return;\n }\n if (url.pathname === \"/oh-story/video-preflight\" && request.method === \"GET\") {\n send(response, 200, await videoPreflight());\n return;\n }\n if (url.pathname === \"/oh-story/file\" && request.method === \"GET\") {\n const realm = await workspaceRealm(context, url);\n const path = url.searchParams.get(\"path\");\n if (path === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11\u6587\u4EF6\u8DEF\u5F84\u3002\");\n const file = await readVersionedFile(realm.fs, await creativeTarget(realm, path), options.maxBytes);\n send(response, 200, { path, ...file });\n return;\n }\n if (url.pathname === \"/oh-story/media\" && (request.method === \"GET\" || request.method === \"HEAD\")) {\n const realm = await workspaceRealm(context, url);\n const path = url.searchParams.get(\"path\");\n if (path === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11\u5A92\u4F53\u6587\u4EF6\u8DEF\u5F84\u3002\");\n const mimeType = mediaMimeTypeForPath(path);\n if (mimeType === undefined) throw new WorkspaceHttpError(415, \"\u76EE\u6807\u4E0D\u662F\u53D7\u652F\u6301\u7684\u77ED\u5267\u5A92\u4F53\u6587\u4EF6\u3002\");\n const target = await creativeTarget(realm, path, \"media\");\n const info = requireRegularFile(await realm.fs.stat(target));\n await sendWorkspaceMedia(request, response, realm, target, info, mimeType);\n return;\n }\n if (url.pathname === \"/oh-story/file\" && request.method === \"PUT\") {\n const realm = await workspaceRealm(context, url);\n const path = url.searchParams.get(\"path\");\n if (path === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11\u6587\u4EF6\u8DEF\u5F84\u3002\");\n const input = await jsonBody(request, options.maxBytes * 6 + 1_024);\n if (typeof input.content !== \"string\") throw new WorkspaceHttpError(400, \"content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3002\");\n if (typeof input.baseVersion !== \"string\" || input.baseVersion === \"\") throw new WorkspaceHttpError(400, \"baseVersion \u5FC5\u987B\u662F\u6709\u6548\u7248\u672C\u3002\");\n if (Buffer.byteLength(input.content) > options.maxBytes) throw new WorkspaceHttpError(413, \"\u6587\u4EF6\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u5927\u5C0F\u9650\u5236\u3002\");\n const outcome = await realm.fs.writeText(\n await creativeTarget(realm, path),\n input.content,\n { kind: \"replaceIfVersion\", version: input.baseVersion as FsVersion },\n undefined,\n realm.sandboxPolicy.resolve({ session: realm.agent.session })\n );\n send(response, 200, { path, content: outcome.after, bytes: Buffer.byteLength(outcome.after), version: outcome.version });\n return;\n }\n send(response, 404, { error: \"Oh Story route not found.\" });\n } catch (error) {\n const mapped = error instanceof WorkspaceHttpError ? error : mapFsError(error);\n if (mapped === undefined) context.logger(\"oh-story\").error(\"workspace route failed\", error);\n send(response, mapped?.status ?? 500, { error: mapped?.message ?? \"Oh Story workspace operation failed.\" });\n }\n}\n\n/** Mount the narrow editor API on DSH's official web-server extension seam. */\nexport function registerWorkspaceRoute(context: Context, options: WorkspaceRouteOptions): void {\n context.effect(() => context.webServer.register({\n kind: \"prefix\",\n path: \"/oh-story\",\n handler: (request, response) => handle(context, request, response, options)\n }), \"oh-story: DSH-session workspace API\");\n}\n", "export type GameVerificationBinding = \"CURRENT\" | \"PINNED\" | \"STALE\" | \"UNBOUND\";\n\nexport interface GameVerificationFreshness {\n readonly binding: Exclude<GameVerificationBinding, \"PINNED\">;\n readonly verifiedPreviewVersion?: string | undefined;\n}\n\ninterface Observation {\n readonly verificationRevision: string | undefined;\n readonly previewVersion: string;\n readonly bound: boolean;\n}\n\n/**\n * The upstream QA schema intentionally contains no build digest. Track what\n * this DSH process actually observes instead of pretending an imported PASS\n * belongs to the current build. A QA rewrite binds that run to the preview\n * visible at the same observation; later preview changes make it stale.\n */\nexport class WorkspaceVerificationTracker {\n readonly #observations = new Map<string, Observation>();\n\n observe(key: string, verificationRevision: string | undefined, previewVersion: string): GameVerificationFreshness {\n const previous = this.#observations.get(key);\n if (previous === undefined) {\n this.#remember(key, { verificationRevision, previewVersion, bound: false });\n return { binding: \"UNBOUND\" };\n }\n if (verificationRevision !== previous.verificationRevision) {\n const bound = verificationRevision !== undefined;\n this.#remember(key, { verificationRevision, previewVersion, bound });\n return bound ? { binding: \"CURRENT\", verifiedPreviewVersion: previewVersion } : { binding: \"UNBOUND\" };\n }\n if (!previous.bound) return { binding: \"UNBOUND\" };\n return previewVersion === previous.previewVersion\n ? { binding: \"CURRENT\", verifiedPreviewVersion: previous.previewVersion }\n : { binding: \"STALE\", verifiedPreviewVersion: previous.previewVersion };\n }\n\n #remember(key: string, observation: Observation): void {\n this.#observations.set(key, observation);\n if (this.#observations.size <= 500) return;\n const oldest = this.#observations.keys().next();\n if (!oldest.done) this.#observations.delete(oldest.value);\n }\n}\n", "import { basename, extname } from \"node:path\";\n\nexport const VIDEO_DIRECTORY = \"video-recaps\";\n\nexport interface VideoWorkspaceFile {\n readonly path: string;\n readonly bytes: number;\n readonly version: string;\n readonly kind: \"text\" | \"media\";\n readonly mimeType?: string | undefined;\n}\n\nexport interface VideoPreviewAsset {\n readonly role: \"source\" | \"edited\" | \"final\";\n readonly label: string;\n readonly path: string;\n readonly bytes: number;\n readonly version: string;\n readonly mimeType: string;\n}\n\nexport interface VideoArtifactSummary {\n readonly label: string;\n readonly path: string;\n readonly version: string;\n readonly kind: \"plan\" | \"script\" | \"subtitle\" | \"quality\" | \"manifest\";\n}\n\nexport interface VideoProjectSummary {\n readonly id: string;\n readonly root: string;\n readonly title: string;\n readonly state: \"not-started\" | \"working\" | \"waiting\" | \"ready\";\n readonly stage: string;\n readonly stageLabel: string;\n readonly nextArtifact?: string | undefined;\n readonly previews: readonly VideoPreviewAsset[];\n readonly artifacts: readonly VideoArtifactSummary[];\n}\n\nconst VIDEO_EXTENSIONS = new Set([\".mp4\", \".mov\", \".mkv\", \".webm\"]);\nconst SKIPPED_DIRECTORIES = new Set([\"frames\", \"tts_segments\", \"asr_chunks\", \"chunks\", \"cache\", \"tmp\", \".subtitle_measure\"]);\nconst VISIBLE_TEXT_FILES = new Set([\n \"project.json\",\n \"recap_run_manifest.json\",\n \"recap_phase.json\",\n \"agent_narration_brief.md\",\n \"recap_story_plan.json\",\n \"visual_audio_board.json\",\n \"clip_plan.json\",\n \"clip_plan_validated.json\",\n \"narration.json\",\n \"narration_review.md\",\n \"tts_meta.json\",\n \"timeline.json\",\n \"assembly_manifest.json\",\n \"assembly_qc.json\",\n \"final_qc.json\",\n \"final_qc.md\",\n \"delivery_qc.json\",\n \"subtitles.srt\",\n \"subtitles.ass\"\n]);\n\nconst ARTIFACT_META: Readonly<Record<string, { readonly label: string; readonly kind: VideoArtifactSummary[\"kind\"] }>> = {\n \"recap_run_manifest.json\": { label: \"\u8FD0\u884C\u6E05\u5355\", kind: \"manifest\" },\n \"recap_phase.json\": { label: \"\u9636\u6BB5\u8D26\u672C\", kind: \"manifest\" },\n \"agent_narration_brief.md\": { label: \"\u89E3\u8BF4 Brief\", kind: \"plan\" },\n \"recap_story_plan.json\": { label: \"\u6545\u4E8B\u65B9\u6848\", kind: \"plan\" },\n \"visual_audio_board.json\": { label: \"\u97F3\u753B\u65B9\u6848\", kind: \"plan\" },\n \"clip_plan.json\": { label: \"\u526A\u8F91\u8BA1\u5212\", kind: \"plan\" },\n \"clip_plan_validated.json\": { label: \"\u5DF2\u6821\u9A8C\u526A\u8F91\u8BA1\u5212\", kind: \"plan\" },\n \"narration.json\": { label: \"\u89E3\u8BF4\u8BCD\", kind: \"script\" },\n \"narration_review.md\": { label: \"\u89E3\u8BF4\u590D\u6838\", kind: \"quality\" },\n \"timeline.json\": { label: \"\u6210\u7247\u65F6\u95F4\u7EBF\", kind: \"plan\" },\n \"assembly_manifest.json\": { label: \"\u5408\u6210\u6E05\u5355\", kind: \"manifest\" },\n \"assembly_qc.json\": { label: \"\u5408\u6210\u8D28\u68C0\", kind: \"quality\" },\n \"final_qc.json\": { label: \"\u6700\u7EC8\u8D28\u68C0\", kind: \"quality\" },\n \"final_qc.md\": { label: \"\u6700\u7EC8\u8D28\u68C0\u62A5\u544A\", kind: \"quality\" },\n \"delivery_qc.json\": { label: \"\u4EA4\u4ED8\u8D28\u68C0\", kind: \"quality\" },\n \"subtitles.srt\": { label: \"SRT \u5B57\u5E55\", kind: \"subtitle\" },\n \"subtitles.ass\": { label: \"ASS \u5B57\u5E55\", kind: \"subtitle\" }\n};\n\nexport function videoProjectRoot(path: string): string | undefined {\n const parts = path.split(\"/\");\n const name = parts[1];\n if (parts[0] !== VIDEO_DIRECTORY || name === undefined || name === \"\" || name === \".\" || name === \"..\" || name.startsWith(\".\") || name.includes(\"\\\\\") || name.length > 128) return undefined;\n return `${VIDEO_DIRECTORY}/${name}`;\n}\n\nexport function skipVideoDirectory(path: string): boolean {\n const parts = path.split(\"/\");\n return parts[0] === VIDEO_DIRECTORY && parts.length >= 3 && SKIPPED_DIRECTORIES.has(parts.at(-1) ?? \"\");\n}\n\nexport function visibleVideoPath(path: string): boolean {\n const root = videoProjectRoot(path);\n if (root === undefined || path === root) return false;\n const name = basename(path);\n const extension = extname(name).toLocaleLowerCase();\n if (VISIBLE_TEXT_FILES.has(name)) return true;\n if (!VIDEO_EXTENSIONS.has(extension)) return false;\n return path.startsWith(`${root}/sources/`)\n || path.startsWith(`${root}/outputs/`)\n || name === \"edited_source.mp4\"\n || /^recap_.+\\.(?:mp4|mov|webm)$/iu.test(name);\n}\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : undefined;\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() !== \"\" ? value.trim() : undefined;\n}\n\nfunction referencedMedia(files: readonly VideoWorkspaceFile[], value: unknown): VideoWorkspaceFile | undefined {\n const path = text(value)?.replaceAll(\"\\\\\", \"/\");\n if (path === undefined) return undefined;\n const direct = files.find((file) => file.path === path || path.endsWith(`/${file.path}`));\n if (direct !== undefined) return direct;\n const name = path.split(\"/\").at(-1);\n const matching = files.filter((file) => file.path.split(\"/\").at(-1) === name);\n return matching.length === 1 ? matching[0] : undefined;\n}\n\nfunction previewAsset(file: VideoWorkspaceFile, role: VideoPreviewAsset[\"role\"], label: string): VideoPreviewAsset | undefined {\n return file.kind === \"media\" && file.mimeType?.startsWith(\"video/\") === true\n ? { role, label, path: file.path, bytes: file.bytes, version: file.version, mimeType: file.mimeType }\n : undefined;\n}\n\nexport function summarizeVideoProject(\n root: string,\n files: readonly VideoWorkspaceFile[],\n metadata: {\n readonly project?: unknown;\n readonly runManifest?: unknown;\n readonly assembly?: unknown;\n } = {}\n): VideoProjectSummary {\n const id = root.slice(`${VIDEO_DIRECTORY}/`.length);\n const projectFiles = files.filter((file) => file.path.startsWith(`${root}/`));\n const project = record(metadata.project);\n const manifest = record(metadata.runManifest);\n const settings = record(manifest?.settings);\n const assembly = record(metadata.assembly);\n const source = referencedMedia(projectFiles, manifest?.source_video)\n ?? projectFiles.find((file) => file.kind === \"media\" && file.path.startsWith(`${root}/sources/`) && file.mimeType?.startsWith(\"video/\") === true);\n const edited = projectFiles.find((file) => file.path.split(\"/\").at(-1) === \"edited_source.mp4\");\n const final = referencedMedia(projectFiles, assembly?.final_output)\n ?? projectFiles.filter((file) => file.kind === \"media\" && (file.path.startsWith(`${root}/outputs/`) || /^recap_.+\\.(?:mp4|mov|webm)$/iu.test(file.path.split(\"/\").at(-1) ?? \"\"))).at(-1);\n const previews = [\n source === undefined ? undefined : previewAsset(source, \"source\", \"\u539F\u7247\"),\n edited === undefined ? undefined : previewAsset(edited, \"edited\", \"\u526A\u540E\u7247\"),\n final === undefined ? undefined : previewAsset(final, \"final\", \"\u6700\u7EC8\u6210\u7247\")\n ].filter((value): value is VideoPreviewAsset => value !== undefined);\n const names = new Set(projectFiles.map((file) => file.path.split(\"/\").at(-1)));\n const cutMode = settings?.edit_mode === \"cut\" || names.has(\"clip_plan.json\") || edited !== undefined;\n let state: VideoProjectSummary[\"state\"] = \"not-started\";\n let stage = \"source\";\n let stageLabel = source === undefined ? \"\u7B49\u5F85\u5BFC\u5165\u89C6\u9891\" : \"\u53EF\u4EE5\u5F00\u59CB\";\n let nextArtifact: string | undefined;\n if (final !== undefined) {\n state = \"ready\"; stage = \"complete\"; stageLabel = \"\u6210\u7247\u5DF2\u5C31\u7EEA\";\n } else if (names.has(\"tts_meta.json\")) {\n state = \"working\"; stage = \"assemble\"; stageLabel = \"\u6B63\u5728\u5408\u6210\";\n } else if (names.has(\"narration.json\")) {\n state = \"working\"; stage = \"voiceover\"; stageLabel = \"\u914D\u97F3\u4E0E\u5408\u6210\";\n } else if (cutMode && edited !== undefined) {\n state = \"waiting\"; stage = \"narration\"; stageLabel = \"\u7B49\u5F85\u89E3\u8BF4\u8BCD\"; nextArtifact = \"narration.json\";\n } else if (cutMode && names.has(\"clip_plan.json\")) {\n state = \"working\"; stage = \"cut\"; stageLabel = \"\u6B63\u5728\u526A\u8F91\";\n } else if (manifest !== undefined) {\n state = \"waiting\";\n stage = cutMode ? \"clip-plan\" : \"narration\";\n stageLabel = cutMode ? \"\u7B49\u5F85\u526A\u8F91\u8BA1\u5212\" : \"\u7B49\u5F85\u89E3\u8BF4\u8BCD\";\n nextArtifact = cutMode ? \"clip_plan.json\" : \"narration.json\";\n }\n const artifacts = projectFiles.flatMap((file): VideoArtifactSummary[] => {\n const name = file.path.split(\"/\").at(-1) ?? \"\";\n const meta = ARTIFACT_META[name];\n return meta === undefined ? [] : [{ ...meta, path: file.path, version: file.version }];\n }).sort((left, right) => left.path.localeCompare(right.path, \"zh-Hans-CN\"));\n return {\n id,\n root,\n title: text(project?.title) ?? id,\n state,\n stage,\n stageLabel,\n nextArtifact,\n previews,\n artifacts\n };\n}\n", "import type { IncomingHttpHeaders } from \"node:http\";\n\ninterface WorkspaceTrustRequest {\n readonly headers: IncomingHttpHeaders | Headers;\n}\n\nfunction header(headers: IncomingHttpHeaders | Headers, name: string): string | undefined {\n if (headers instanceof Headers) return headers.get(name) ?? undefined;\n const value = headers[name];\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction parseAuthority(authority: string): URL | undefined {\n try { return new URL(`http://${authority}`); }\n catch { return undefined; }\n}\n\nfunction canonicalAuthority(entry: string, url: URL): string {\n const port = url.port !== \"\" ? url.port : new URL(`https://${entry}`).port;\n return port === \"\" ? url.hostname : `${url.hostname}:${port}`;\n}\n\nfunction isLoopbackHostname(hostname: string): boolean {\n if (hostname === \"localhost\" || hostname === \"[::1]\") return true;\n const parts = hostname.split(\".\");\n return parts.length === 4\n && parts[0] === \"127\"\n && parts.every((part) => /^\\d{1,3}$/u.test(part) && Number(part) <= 255);\n}\n\nfunction isTrustedAuthority(host: URL, trustedHosts: readonly string[]): boolean {\n return trustedHosts.some((entry) => {\n const candidate = parseAuthority(entry);\n if (candidate === undefined) return false;\n return canonicalAuthority(entry, candidate) === candidate.hostname\n ? candidate.hostname === host.hostname\n : candidate.host === host.host;\n });\n}\n\n/** Reject malformed declarations at plugin load instead of silently widening access. */\nexport function assertTrustedWorkspaceAuthority(entry: string): void {\n const url = parseAuthority(entry);\n if (url !== undefined && canonicalAuthority(entry, url) === entry.toLocaleLowerCase()) return;\n throw new Error(`oh-story: trustedHosts entry ${JSON.stringify(entry)} is not a bare host[:port] authority`);\n}\n\n/**\n * Same browser trust boundary as DSH's native API: every request must address a\n * loopback or explicitly trusted Host, and browser markers must be same-origin.\n */\nexport function isTrustedWorkspaceRequest(\n request: WorkspaceTrustRequest,\n trustedHosts: readonly string[]\n): boolean {\n const authority = header(request.headers, \"host\");\n if (authority === undefined) return false;\n const host = parseAuthority(authority);\n if (host === undefined) return false;\n if (!isLoopbackHostname(host.hostname) && !isTrustedAuthority(host, trustedHosts)) return false;\n if (header(request.headers, \"sec-fetch-site\") === \"cross-site\") return false;\n const origin = header(request.headers, \"origin\");\n if (origin === undefined) return true;\n try { return new URL(origin).host === host.host; }\n catch { return false; }\n}\n\n/**\n * Permit a generated-game document to navigate from one loopback alias to\n * another (127.0.0.1 \u2194 localhost). Subresources then become same-origin with\n * the isolated preview document and use the stricter path above.\n */\nexport function isTrustedPreviewNavigation(\n request: WorkspaceTrustRequest,\n trustedHosts: readonly string[]\n): boolean {\n if (isTrustedWorkspaceRequest(request, trustedHosts)) return true;\n const authority = header(request.headers, \"host\");\n if (authority === undefined) return false;\n const host = parseAuthority(authority);\n if (host === undefined || (!isLoopbackHostname(host.hostname) && !isTrustedAuthority(host, trustedHosts))) return false;\n return header(request.headers, \"origin\") === undefined\n && header(request.headers, \"sec-fetch-site\") === \"cross-site\"\n && header(request.headers, \"sec-fetch-mode\") === \"navigate\"\n && [\"document\", \"iframe\"].includes(header(request.headers, \"sec-fetch-dest\") ??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AI,KAAM,EAAE,IAAI,OAAS,EAAE,QAAQ,OAAS;AAAA,EACxE,cAAc,EAAE,MAAM,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAGD,eAAsB,MAAM,SAAkB,SAAiB,CAAC,GAAkB;AAChF,QAAM,eAAe,OAAO,gBAAgB,CAAC;AAC7C,aAAW,SAAS,aAAc,iCAAgC,KAAK;AACvE,UAAQ,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAClE,UAAQ,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AAChE,UAAQ,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AACtE,UAAQ,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AACrE,uBAAqB,OAAO;AAC5B,gCAA8B,OAAO;AACrC,QAAM,wBAAwB,OAAO;AACrC,yBAAuB,SAAS,EAAE,UAAU,OAAO,kBAAkB,SAAW,aAAa,CAAC;AAChG;AAEA,IAAO,gBAAQ,EAAE,MAAM,QAAQ,QAAQ,MAAM;",
6
- "names": ["name", "name", "record", "defineTool", "readdir", "readFile", "isAbsolute", "join", "relative", "resolve", "readdir", "join", "resolve", "relative", "isAbsolute", "readFile", "readFile", "basename", "dirname", "join", "resolve", "fileURLToPath", "name", "defineTool", "name", "defineTool", "defineTool", "extname", "isAbsolute", "relative", "resolve", "basename", "name", "metadata", "name", "name", "target", "relative", "isAbsolute", "extname", "record", "resolve"]
3
+ "sources": ["../src/index.ts", "../src/skill-provider.ts", "../src/drama-adapters.ts", "../src/host-python.ts", "../src/native-hooks.ts", "../src/role-tool.ts", "../src/reference-tool.ts", "../src/role-provider.ts", "../src/production-tool.ts", "../src/production-intent.ts", "../src/workspace-route.ts", "../src/game-verification.ts", "../src/video-project.ts", "../src/workspace-request-trust.ts"],
4
+ "sourcesContent": ["import type { Context } from \"@deepseek-ai/cordis\";\nimport type {} from \"@deepseek-ai/dsh-host-webserver\";\nimport type {} from \"@deepseek-ai/dsh-skill\";\nimport type {} from \"@deepseek-ai/dsh-subagent\";\nimport type {} from \"@deepseek-ai/dsh-tools\";\nimport z from \"@deepseek-ai/schemastery\";\nimport { createDramaSkillProvider, createNovelToGameSkillProvider, createOhStorySkillProvider, createVideoRecapSkillProvider, defaultDramaSkillRoot } from \"./skill-provider.js\";\nimport { ensureDramaAdapterConfig } from \"./drama-adapters.js\";\nimport { hostPython } from \"./host-python.js\";\nimport { registerOhStoryHooks } from \"./native-hooks.js\";\nimport { registerOhStoryRoleTool } from \"./role-tool.js\";\nimport { registerOhStoryProductionTool } from \"./production-tool.js\";\nimport { registerWorkspaceRoute } from \"./workspace-route.js\";\nimport { assertTrustedWorkspaceAuthority } from \"./workspace-request-trust.js\";\n\nexport { createDramaSkillProvider, createNovelToGameSkillProvider, createOhStorySkillProvider, createVideoRecapSkillProvider, parseBundledSkill } from \"./skill-provider.js\";\nexport { OH_STORY_ROLE_NAMES, loadBundledRole } from \"./role-provider.js\";\nexport { createOhStoryRoleTool, OH_STORY_ROLE_TOOL_NAME, registerOhStoryRoleTool, roleToolFilter, type OhStoryRoleSubagents } from \"./role-tool.js\";\nexport { createOhStoryProductionTool, registerOhStoryProductionTool } from \"./production-tool.js\";\nexport { OH_STORY_PRODUCTION_TOOL_NAME, validateProductionIntent, type ProductionIntentArgs } from \"./production-intent.js\";\nexport { bundledReferenceGuard, createOhStoryReferenceTool, OH_STORY_REFERENCE_TOOL_NAME } from \"./reference-tool.js\";\nexport { registerWorkspaceRoute } from \"./workspace-route.js\";\nexport { registerOhStoryHooks } from \"./native-hooks.js\";\nexport { DRAMA_ADAPTER_CONFIG_ENV, DRAMA_ADAPTERS, dramaAdapterConfigPath, dramaAdapterStatuses, ensureDramaAdapterConfig } from \"./drama-adapters.js\";\n\nexport const name = \"oh-story\";\nexport const inject = [\"skills\", \"subagents\", \"tools\", \"typert\", \"webServer\"];\n\n/** DSH owns models, providers, presets, permissions, roots, runs, and sessions. */\nexport interface Config {\n readonly editorMaxBytes?: number;\n readonly trustedHosts?: string[];\n}\n\nexport const Config = z.object({\n editorMaxBytes: z.natural().min(65_536).max(8_388_608).default(2_097_152),\n trustedHosts: z.array(String).default([])\n}) as z<Config>;\n\n/** Mount only domain contributions into the current DSH process. */\nexport async function apply(context: Context, config: Config = {}): Promise<void> {\n const trustedHosts = config.trustedHosts ?? [];\n for (const entry of trustedHosts) assertTrustedWorkspaceAuthority(entry);\n context.skills.registerProvider(() => createOhStorySkillProvider());\n context.skills.registerProvider(() => createDramaSkillProvider());\n context.skills.registerProvider(() => createNovelToGameSkillProvider());\n context.skills.registerProvider(() => createVideoRecapSkillProvider());\n registerOhStoryHooks(context);\n registerOhStoryProductionTool(context);\n await registerOhStoryRoleTool(context);\n registerWorkspaceRoute(context, { maxBytes: config.editorMaxBytes ?? 2_097_152, trustedHosts });\n // Register the bundled media adapters for this host up front so the first\n // short-drama-produce run has a config to pass; the preflight route repeats\n // this and reports the outcome, so a failure here only delays the message.\n await ensureDramaAdapterConfig(defaultDramaSkillRoot(), { python: (await hostPython()).command });\n}\n\nexport default { name, inject, Config, apply };\n", "import { readdir, readFile } from \"node:fs/promises\";\nimport { basename, dirname, isAbsolute, join, relative, resolve } from \"node:path\";\nimport { dramaAdapterConfigPath, dramaAdapterSummary, DRAMA_ADAPTER_CONFIG_ENV } from \"./drama-adapters.js\";\nimport { fileURLToPath, pathToFileURL } from \"node:url\";\nimport {\n BUNDLED_SKILL_RANK,\n type SkillCandidate,\n type SkillDefinition,\n type SkillProvider\n} from \"@deepseek-ai/dsh-skill\";\n\nconst STORY_PROVIDER_NAME = \"oh-story\";\nconst DRAMA_PROVIDER_NAME = \"short-drama\";\nconst GAME_PROVIDER_NAME = \"novel-to-game\";\nconst VIDEO_PROVIDER_NAME = \"video-recap\";\nconst DSH_SKILL_BRIDGE = [\n \"<oh-story-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, subagents, cancellation, resume, and Agent UI.\",\n \"Never start another Agent runtime, session transport, Dashboard, SSE stream, polling loop, or model configuration.\",\n \"All seven upstream Oh Story specialist Roles are bundled. Invoke one with oh_story_role and a self-contained prompt.\",\n \"Never inspect .claude/agents, .codex/agents, .opencode/agents, .agents/agents, .zcode, or .story-deployed to decide whether a Role is available, and never call invoke_subagent with a TypeName.\",\n \"Use only DSH-visible tools. DSH sandbox and permission policy remain authoritative.\",\n \"</oh-story-dsh-integration>\"\n].join(\"\\n\");\nconst DSH_SKILL_OVERRIDES: Readonly<Partial<Record<string, string>>> = {\n story: \"The \u5C0F\u8BF4 workspace is an official DSH conversation view. Never start or open a second web application.\",\n \"story-setup\": \"Initialize or validate novel project data only. DSH already supplies Skills, Roles, hooks, tools, permissions, sessions, and UI; never deploy Claude/OpenCode/Codex/Antigravity/ZCode/OpenClaw/Reasonix files or a .story-deployed marker.\",\n \"story-long-analyze\": \"Use oh_story_role for chapter extraction or specialist analysis. Never inspect platform agent directories or require a deployed external Agent definition.\",\n \"story-long-write\": \"All named Roles are provided through oh_story_role. Do not check platform agent files. Keep the upstream writing, Tracking, lint, outline, revision, and quality workflows.\",\n \"story-review\": \"All named reviewer Roles are provided through oh_story_role. Do not check platform agent files; full/lean review may use the bundled Roles directly.\",\n \"story-import\": \"All named Roles are provided through oh_story_role. Do not require story-setup to deploy them, and never inspect platform agent directories.\",\n \"story-deslop\": \"Use the bundled narrative-writer Role through oh_story_role when specialist review is useful. Never inspect platform agent directories.\",\n \"story-short-analyze\": \"Use oh_story_role for specialist analysis. Never inspect platform agent directories or require external Agent deployment.\",\n \"story-short-write\": \"All named Roles are provided through oh_story_role. Do not inspect platform agent files; preserve the upstream short-fiction workflow and quality gates.\",\n \"browser-cdp\": \"Use only browser or web capabilities visible in the current DSH preset. Do not start a parallel browser host; if no compatible capability is visible, explain the limitation.\",\n \"story-cover\": \"Use only image-generation or HTTP capabilities visible in the current DSH preset. Never assume a separate Codex or Claude runtime.\"\n};\nconst DSH_DRAMA_BRIDGE = [\n \"<short-drama-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, approvals, cancellation, resume, and Agent UI.\",\n \"The \u77ED\u5267 tab is the creator workspace. Never start dashboard_server.py, another web server, Dashboard, Agent runtime, session transport, or model configuration.\",\n \"Drama Skills v0.6 uses a creator-first contract: each episode keeps only the requested documents, up to five creator-facing sources at \u5267\u96C6/<EP>/\u5267\u672C.md, \u89C6\u89C9\u8BBE\u5B9A.md, \u5206\u955C.md, \u56FE\u7247\u63D0\u793A\u8BCD.md, and \u89C6\u9891\u63D0\u793A\u8BCD.md. Never precreate empty documents, backfill nominal stages, or start work the creator did not request. Persisted reviews use creator-readable Markdown under \u5BA1\u67E5/; an oral review writes nothing.\",\n \"For a v0.6 project, never create a parallel JSON/JSONL lifecycle truth, indexes, fingerprints, coverage tables, or QA records merely because legacy maintenance scripts and templates remain bundled.\",\n \"Never upgrade a v0.5 structured project in place or mix both contracts in one project root. Keep legacy production/audit artifacts read-only and pinned to v0.5; migrate only into a new creator-first root with manual per-episode creator confirmation.\",\n \"Use only tools visible in the current DSH preset and preserve the upstream project ownership, freshness, review, and explicit production-confirmation contracts.\",\n \"Use oh_story_production only for semantic production-view intents (open/focus, explicit shot order, or tracking a job that this Agent is actually executing). Cosmetic canvas layout remains creator-controlled. The tool changes only the Session projection: it does not edit creator documents, generate media, or authorize production.\",\n \"Production credentials remain outside project files. Never treat a prior acceptance, preview, continuation request, or budget discussion as confirmation for a paid production run.\",\n \"</short-drama-dsh-integration>\"\n].join(\"\\n\");\nconst DSH_DRAMA_OVERRIDES: Readonly<Partial<Record<string, string | ((skillRoot: string) => string)>>> = {\n \"short-drama\": \"A dashboard request means focus or use the native \u77ED\u5267 tab in this DSH Session. Do not run the bundled standalone Dashboard script. New projects follow only the v0.6 creator-first contract and create only documents required by the current request.\",\n \"short-drama-produce\": (skillRoot) => `Use an upstream adapter only after the creator explicitly confirms the exact current job. Its source must be the current creator-first Markdown and its output belongs under \u5267\u96C6/<EP>/\u5236\u4F5C\u6210\u679C/. DSH permissions and approval UI remain authoritative. When oh_story_production is visible, register the previewed job with track_job after the confirmation is valid and before run \u2014 never at prepare time \u2014 passing the same job ID, target, modality and count the creator just approved. DeepSeek generates no media: every image, video, or music result comes from a provider adapter. The bundled adapters are ${dramaAdapterSummary()}; they are registered for this DSH host in ${dramaAdapterConfigPath(skillRoot).path} \u2014 pass that file as --adapter-config unless the creator names another config (${DRAMA_ADAPTER_CONFIG_ENV}). Credentials are read only from the DSH host process environment. Before preparing a paid job, name the adapter that will run it; if its variables are missing, tell the creator exactly which ones to export before starting DSH instead of failing inside run. Never read, print, or write credential values.`,\n \"short-drama-assets\": \"Keep one stable `- ID\uFF1AVISUAL-*` line on every \u4EBA\u7269/\u9020\u578B/\u5730\u70B9/\u9053\u5177/\u72B6\u6001 entry in \u89C6\u89C9\u8BBE\u5B9A.md, and never change an existing ID when editing its heading or text. The \u751F\u4EA7 view identifies canvas nodes by that ID; entries without one still render, but the workbench reports their node identity as unstable.\"\n};\nconst DSH_GAME_BRIDGE = [\n \"<novel-to-game-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, approvals, cancellation, resume, Todo, and Chat UI.\",\n \"The \u6E38\u620F tab is the playable Game Studio. Never start a second Agent runtime, dashboard, session transport, or model configuration.\",\n \"Keep the complete upstream seven-Skill pipeline and write adaptation artifacts under game-adaptations/<project>/ exactly as the upstream contracts specify.\",\n \"For a web target, keep the authoritative playable entry at build/app/index.html so Game Studio can preview it. Do not silently replace a requested non-web runtime with a web build.\",\n \"Use only DSH-visible tools and approvals. qa/verification.json remains the sole machine QA truth and must cover launch, render, input, coreLoop, outcome, and restart with real execution evidence.\",\n \"The bundled Jin Ping Mei project is a read-only example, not a template to copy mechanically and not proof that another adaptation passed QA.\",\n \"</novel-to-game-dsh-integration>\"\n].join(\"\\n\");\nconst DSH_VIDEO_BRIDGE = [\n \"<video-recap-dsh-integration>\",\n \"This Skill is a native contribution to the current DeepSeek Harness session.\",\n \"DSH owns the workspace, model, preset, permissions, Session Log, tools, approvals, cancellation, resume, Todo, Chat, and the \u89C6\u9891 preview Studio.\",\n \"Never start a second Agent runtime, dashboard, session transport, web server, polling loop, or model configuration.\",\n \"Keep the complete upstream six-Skill pipeline. Put each project under video-recaps/<project>/, copy or import source media under sources/, and use work/ as the upstream work_dir so the Studio can discover authoritative manifests and outputs.\",\n \"The Video Studio is a preview and artifact surface, not a nonlinear editor. Do not invent a second project-state format, timeline truth, or render queue; recap_run_manifest.json, recap_phase.json, timeline.json, assembly_manifest.json, and the upstream artifacts remain authoritative.\",\n \"MIMO_API_KEY, FISH_API_KEY, and voice credentials stay in the host environment. Never write secrets into project files, tool arguments shown to the browser, or chat output.\",\n \"Use only DSH-visible tools and approvals. Run Python and ffmpeg through the current DSH execution world, preserve cancellation, and do not install or upgrade system dependencies without explicit user approval.\",\n \"When a new edited or final video is ready, tell the user that Video Studio can load it; never interrupt playback by replacing the currently loaded video silently.\",\n \"</video-recap-dsh-integration>\"\n].join(\"\\n\");\n\nconst DSH_NATIVE_SKILLS: Readonly<Partial<Record<string, string>>> = {\n story: `# story \u2014 DSH \u5C0F\u8BF4\u6D41\u7A0B\u5165\u53E3\n\n\u5728\u5F53\u524D DSH Session \u5185\u5224\u65AD\u7528\u6237\u610F\u56FE\uFF0C\u5E76\u52A0\u8F7D\u6700\u5339\u914D\u7684 Oh Story Skill\uFF1A\n\n- \u65B0\u5EFA\u6216\u4FEE\u590D\u5C0F\u8BF4\u5DE5\u7A0B\uFF1Astory-setup\n- \u957F\u7BC7\u9009\u9898/\u626B\u699C/\u62C6\u6587/\u65E5\u66F4\uFF1Astory-long-scan\u3001story-long-analyze\u3001story-long-write\n- \u77ED\u7BC7\u9009\u9898/\u62C6\u6587/\u5199\u4F5C\uFF1Astory-short-scan\u3001story-short-analyze\u3001story-short-write\n- \u5BFC\u5165\u5DF2\u6709\u4F5C\u54C1\uFF1Astory-import\n- \u5BA1\u7A3F\u4E0E\u53BB AI \u5473\uFF1Astory-review\u3001story-deslop\n- \u5C01\u9762\uFF1Astory-cover\n- \u7BA1\u7406\u4F5C\u8005\u4E60\u60EF\uFF08\u8BB0\u4F4F/\u67E5\u770B/\u786E\u8BA4/\u66FF\u6362/\u5FD8\u6389\u5199\u4F5C\u504F\u597D\uFF09\uFF1A\u52A0\u8F7D\u672C skill \u7684\n references/author-memory.md\uFF0C\u53EA\u7528\u672C skill \u7684 scripts/author_memory_commit.py \u7BA1\u7406\n \u5DE5\u4F5C\u533A\u7EA7 .story/\u4F5C\u8005\u8BB0\u5FC6/\uFF1B\u5DE5\u5177\u672A\u8FD4\u56DE Author Memory Receipt \u524D\u4E0D\u5F97\u58F0\u79F0\u5DF2\u8BB0\u4F4F\u3002\n\n\u610F\u56FE\u660E\u786E\u65F6\u76F4\u63A5\u8FDB\u5165\u5BF9\u5E94 Skill\uFF1B\u4E0D\u660E\u786E\u65F6\u53EA\u95EE\u4E00\u4E2A\u4F1A\u6539\u53D8\u6D41\u7A0B\u7684\u95EE\u9898\u3002\u9879\u76EE\u6587\u4EF6\u3001\nAgent\u3001\u6A21\u578B\u3001\u6743\u9650\u3001Session Log \u548C UI \u5747\u7531\u5F53\u524D DSH \u4F1A\u8BDD\u7BA1\u7406\u3002\u5C0F\u8BF4\u6587\u4EF6\u901A\u8FC7\u201C\u5C0F\u8BF4\u201D\n\u89C6\u56FE\u67E5\u770B\uFF0CAgent \u8FC7\u7A0B\u901A\u8FC7\u53F3\u4FA7\u52A8\u6001\u680F\u6216\u5B98\u65B9 Chat \u67E5\u770B\u3002\u7981\u6B62\u542F\u52A8\u72EC\u7ACB Dashboard\u3002`,\n \"story-setup\": `# story-setup \u2014 DSH \u539F\u751F\u5C0F\u8BF4\u5DE5\u7A0B\u521D\u59CB\u5316\n\n\u53EA\u521D\u59CB\u5316\u6216\u6821\u9A8C\u5F53\u524D DSH workspace \u4E2D\u7684\u5C0F\u8BF4\u6570\u636E\uFF0C\u4E0D\u90E8\u7F72\u4EFB\u4F55 Agent \u5E73\u53F0\u6587\u4EF6\u3002\n\n1. \u68C0\u67E5\u73B0\u6709\u6B63\u6587\u3001\u8BBE\u5B9A\u3001\u5927\u7EB2\u548C\u8FFD\u8E2A\u6587\u4EF6\uFF0C\u5DF2\u6709\u5185\u5BB9\u7EDD\u4E0D\u8986\u76D6\u3002\n2. \u6839\u636E\u7528\u6237\u58F0\u660E\u4E0E\u73B0\u6709\u7ED3\u6784\u5224\u65AD\u957F\u7BC7/\u77ED\u7BC7\uFF1B\u65E0\u6CD5\u53EF\u9760\u5224\u65AD\u65F6\u8BF7\u6C42\u786E\u8BA4\u3002\n3. \u957F\u7BC7\u6309\u9700\u5EFA\u7ACB \u6B63\u6587/\u3001\u8BBE\u5B9A/\u3001\u5927\u7EB2/\u3001\u8FFD\u8E2A/\uFF0C\u5E76\u51C6\u5907\u8FFD\u8E2A/_tracking-state.json\uFF1B\n \u7B2C\u4E00\u7AE0\u6B63\u6587\u843D\u76D8\u524D\u5FC5\u987B\u6709\u5BF9\u5E94\u7EC6\u7EB2\u3002\u77ED\u7BC7\u4FDD\u6301\u8F7B\u91CF\u7ED3\u6784\uFF0C\u4E0D\u5F3A\u52A0\u957F\u7BC7 Tracking\u3002\n4. \u9700\u8981\u67B6\u6784\u3001\u89D2\u8272\u6216\u7814\u7A76\u5DE5\u4F5C\u65F6\uFF0C\u901A\u8FC7 oh_story_role \u8C03\u7528\u5DF2\u6253\u5305 Role\uFF1B\u4E0D\u8981\u68C0\u67E5\u6216\n \u751F\u6210 .claude\u3001.codex\u3001.opencode\u3001.agents\u3001.zcode\u3001AGENTS.md \u6216 .story-deployed\u3002\n5. \u590D\u8FF0\u521B\u5EFA\u3001\u4FDD\u7559\u548C\u5F85\u7528\u6237\u786E\u8BA4\u7684\u6587\u4EF6\u3002\u4E0D\u8981\u914D\u7F6E\u6A21\u578B\u3001\u6743\u9650\u3001Hooks \u6216 Session\u3002\n\n\u9898\u6750\u3001\u89D2\u8272\u3001\u8282\u594F\u3001\u51B2\u7A81\u3001\u5F00\u7BC7\u548C\u5199\u4F5C\u65B9\u6CD5\u8D44\u6599\u4F4D\u4E8E references/agent-references/\uFF1B\n\u53EA\u52A0\u8F7D\u5F53\u524D\u4EFB\u52A1\u9700\u8981\u7684\u6587\u4EF6\u3002`,\n \"browser-cdp\": `# browser-cdp \u2014 DSH \u6D4F\u89C8\u5668\u80FD\u529B\u9002\u914D\n\n\u672C Skill \u4E0D\u542F\u52A8 Chrome\u3001CDP \u7AEF\u53E3\u3001\u72EC\u7ACB\u6D4F\u89C8\u5668 Host \u6216 setup-cdp-chrome.js\u3002\n\u4EC5\u4F7F\u7528\u5F53\u524D DSH Preset \u5DF2\u66B4\u9732\u7684 web_search\u3001web_fetch \u6216\u6D4F\u89C8\u5668\u5DE5\u5177\u5B8C\u6210\u7F51\u9875\u8BFB\u53D6\u3001\n\u699C\u5355\u91C7\u96C6\u548C\u8D44\u6599\u6838\u9A8C\u3002\u4FDD\u6301\u4EE5\u4E0B\u539F\u5219\uFF1A\n\n1. \u4F18\u5148\u4F7F\u7528\u7ED3\u6784\u5316\u641C\u7D22/\u6293\u53D6\u5DE5\u5177\uFF1B\u9700\u8981\u767B\u5F55\u6001\u6216\u4EA4\u4E92\u9875\u9762\u65F6\u624D\u4F7F\u7528\u53EF\u89C1\u6D4F\u89C8\u5668\u80FD\u529B\u3002\n2. \u5C0A\u91CD\u7AD9\u70B9\u6761\u6B3E\u3001\u8BBF\u95EE\u9891\u7387\u4E0E\u7528\u6237\u6388\u6743\uFF1B\u4E0D\u7ED5\u8FC7\u9A8C\u8BC1\u7801\u3001\u4ED8\u8D39\u5899\u6216\u8BBF\u95EE\u63A7\u5236\u3002\n3. \u8BB0\u5F55\u6765\u6E90 URL\u3001\u91C7\u96C6\u65F6\u95F4\u3001\u5931\u8D25\u9879\u548C\u6570\u636E\u8D28\u91CF\uFF0C\u4E0D\u628A\u63A8\u65AD\u5199\u6210\u9875\u9762\u4E8B\u5B9E\u3002\n4. \u5F53\u524D Preset \u6CA1\u6709\u517C\u5BB9\u80FD\u529B\u65F6\uFF0C\u8BF4\u660E\u7F3A\u5931\u80FD\u529B\u548C\u53EF\u884C\u7684\u624B\u5DE5\u6B65\u9AA4\uFF0C\u4E0D\u53E6\u8D77\u8FD0\u884C\u65F6\u3002`,\n \"story-long-scan\": `# story-long-scan \u2014 DSH \u539F\u751F\u957F\u7BC7\u626B\u699C\n\n\u57FA\u4E8E\u53EF\u6838\u9A8C\u6837\u672C\u8BC6\u522B\u957F\u7BC7\u7F51\u6587\u8D8B\u52BF\uFF0C\u4E0D\u8FD0\u884C\u6253\u5305\u811A\u672C\u3001\u4E0D\u63D0\u53D6\u767B\u5F55\u51ED\u636E\uFF0C\u4E5F\u4E0D\u7ED5\u8FC7\u9A8C\u8BC1\u7801\u3001\n\u8BBF\u95EE\u63A7\u5236\u6216\u7AD9\u70B9\u9650\u5236\u3002\n\n1. \u660E\u786E\u5E73\u53F0\u3001\u9891\u9053\u548C\u9898\u6750\u65B9\u5411\uFF1B\u53EA\u6709\u7B54\u6848\u4F1A\u6539\u53D8\u91C7\u6837\u8303\u56F4\u65F6\u624D\u95EE\u4E00\u4E2A\u95EE\u9898\u3002\n2. \u6570\u636E\u6765\u6E90\u4F9D\u6B21\u4E3A\uFF1A\u7528\u6237\u63D0\u4F9B\u7684\u6570\u636E\u6216\u94FE\u63A5\u3001\u5F53\u524D DSH Preset \u53EF\u89C1\u7684\u7F51\u9875\u5DE5\u5177\u3001\n references/genre-trends.md \u4E2D\u7684\u5386\u53F2\u8D8B\u52BF\u3002\u65E0\u6CD5\u83B7\u53D6\u5B9E\u65F6\u6570\u636E\u65F6\u5FC5\u987B\u660E\u786E\u6807\u4E3A\u5386\u53F2\u5047\u8BBE\u3002\n3. \u6BCF\u4E2A\u6837\u672C\u8BB0\u5F55\u6765\u6E90 URL\u3001\u91C7\u96C6\u65E5\u671F\u3001\u699C\u5355\u53E3\u5F84\u3001\u6709\u6548\u6761\u76EE\u6570\u3001\u7F3A\u5931\u5B57\u6BB5\u548C\u5F02\u5E38\u9879\uFF1B\n \u4E0D\u628A\u641C\u7D22\u6458\u8981\u3001\u63A8\u65AD\u6216\u8FC7\u671F\u7F13\u5B58\u5199\u6210\u9875\u9762\u4E8B\u5B9E\u3002\n4. \u6309\u9898\u6750\u5206\u5E03\u3001\u65B0\u9898\u6750\u4FE1\u53F7\u3001\u7ECF\u5178\u9898\u6750\u53D8\u5316\u3001\u7BC7\u5E45\u4E0E\u66F4\u65B0\u3001\u4E66\u540D\u6A21\u5F0F\u3001\u5F00\u5934\u5356\u70B9\u548C\n \u5DEE\u5F02\u5316\u5143\u7D20\u5206\u6790\u3002\u9700\u8981\u51B3\u7B56\u95E8\u7981\u65F6\u4F7F\u7528 references/topic-decision.md\u3002\n5. \u8F93\u51FA\u5E02\u573A\u6982\u51B5\u3001\u9898\u6750\u70ED\u5EA6\u3001\u8BC1\u636E\u4E0E\u53EF\u4FE1\u5EA6\u3001\u98CE\u9669\u3001\u4E09\u9879\u53EF\u6267\u884C\u65B9\u5411\u548C\u4E0B\u6B21\u590D\u626B\u65F6\u95F4\u3002\n\n\u5F53\u524D Preset \u6CA1\u6709\u7F51\u9875\u80FD\u529B\u4E14\u7528\u6237\u4E5F\u672A\u63D0\u4F9B\u6837\u672C\u65F6\uFF0C\u4F7F\u7528\u5185\u7F6E\u53C2\u8003\u5B8C\u6210\u65B9\u6CD5\u8BBA\u5206\u6790\uFF0C\n\u5E76\u5217\u51FA\u4ECD\u9700\u6838\u9A8C\u7684\u699C\u5355\uFF1B\u4E0D\u8981\u542F\u52A8 CDP\u3001\u72EC\u7ACB\u6D4F\u89C8\u5668\u6216\u5E76\u884C\u8FD0\u884C\u65F6\u3002`,\n \"story-short-scan\": `# story-short-scan \u2014 DSH \u539F\u751F\u77ED\u7BC7\u626B\u699C\n\n\u57FA\u4E8E\u53EF\u6838\u9A8C\u6837\u672C\u8BC6\u522B\u77ED\u7BC7\u5E02\u573A\u7684\u60C5\u7EEA\u3001\u9898\u6750\u4E0E\u4F20\u64AD\u4FE1\u53F7\uFF0C\u4E0D\u8FD0\u884C\u6253\u5305\u811A\u672C\u3001\u4E0D\u8BFB\u53D6 Cookie\n\u6216 token\uFF0C\u4E5F\u4E0D\u7ED5\u8FC7\u9A8C\u8BC1\u7801\u3001\u767B\u5F55\u6216\u8BBF\u95EE\u63A7\u5236\u3002\n\n1. \u660E\u786E\u5E73\u53F0\u4E0E\u65B9\u5411\uFF1B\u53EA\u6709\u7B54\u6848\u4F1A\u6539\u53D8\u91C7\u6837\u8303\u56F4\u65F6\u624D\u95EE\u4E00\u4E2A\u95EE\u9898\u3002\n2. \u6570\u636E\u6765\u6E90\u4F9D\u6B21\u4E3A\uFF1A\u7528\u6237\u63D0\u4F9B\u7684\u6570\u636E\u6216\u94FE\u63A5\u3001\u5F53\u524D DSH Preset \u53EF\u89C1\u7684\u7F51\u9875\u5DE5\u5177\u3001\n references/real-market-data.md \u4E2D\u7684\u5386\u53F2\u8D44\u6599\u3002\u65E0\u6CD5\u8054\u7F51\u65F6\u5FC5\u987B\u628A\u7ED3\u8BBA\u6807\u4E3A\u5019\u9009\u5047\u8BBE\u3002\n3. \u8BB0\u5F55\u6765\u6E90 URL\u3001\u91C7\u96C6\u65E5\u671F\u3001\u699C\u5355\u53E3\u5F84\u3001\u6709\u6548\u6837\u672C\u6570\u3001\u7F3A\u5931\u5B57\u6BB5\u548C\u5F02\u5E38\u9879\u3002\n4. \u5206\u6790\u60C5\u7EEA\u7C7B\u578B\u3001\u9898\u6750\u70ED\u70B9\u3001\u7BC7\u5E45\u3001\u5F00\u5934\u3001\u7ED3\u5C3E\u3001\u6807\u9898\u3001\u4EBA\u8BBE\u4E0E\u4F20\u64AD\u89E6\u53D1\u70B9\uFF1B\n \u7ED9\u6BCF\u4E2A\u8D8B\u52BF\u6807\u6CE8\u8BC1\u636E\u5F3A\u5EA6\u3001\u9971\u548C\u98CE\u9669\u548C\u6709\u6548\u671F\u3002\n5. \u8F93\u51FA\u5E02\u573A\u6982\u51B5\u3001\u60C5\u7EEA\u70ED\u5EA6\u3001\u9898\u6750\u70ED\u70B9\u3001\u5173\u952E\u6570\u636E\u3001\u98CE\u53E3\u9884\u8B66\u3001\u4E09\u9879\u53EF\u5199\u65B9\u5411\u548C\u590D\u626B\u65F6\u95F4\u3002\n\n\u5F53\u524D Preset \u6CA1\u6709\u7F51\u9875\u80FD\u529B\u4E14\u7528\u6237\u4E5F\u672A\u63D0\u4F9B\u6837\u672C\u65F6\uFF0C\u53EA\u505A\u5386\u53F2\u8D44\u6599\u5206\u6790\u5E76\u5217\u51FA\u9A8C\u8BC1\u52A8\u4F5C\uFF1B\n\u4E0D\u8981\u542F\u52A8 CDP\u3001\u72EC\u7ACB\u6D4F\u89C8\u5668\u6216\u5E76\u884C\u8FD0\u884C\u65F6\u3002`\n};\n\ninterface ParsedSkill {\n readonly name: string;\n readonly description: string;\n readonly content: string;\n readonly userInvocable: boolean;\n}\n\nfunction frontmatterValue(frontmatter: string, key: string): string | undefined {\n const lines = frontmatter.split(/\\r?\\n/u);\n const index = lines.findIndex((line) => new RegExp(`^${key}:\\\\s*`, \"u\").test(line));\n if (index < 0) return undefined;\n const raw = lines[index]?.replace(new RegExp(`^${key}:\\\\s*`, \"u\"), \"\").trim();\n if (raw === undefined) return undefined;\n if (raw === \">\" || raw === \"|\" || raw === \">-\" || raw === \"|-\") {\n const values: string[] = [];\n for (const line of lines.slice(index + 1)) {\n if (/^\\S/u.test(line)) break;\n values.push(line.trim());\n }\n return (raw.startsWith(\">\") ? values.join(\" \") : values.join(\"\\n\")).trim();\n }\n if (raw.startsWith(\"\\\"\") && raw.endsWith(\"\\\"\")) {\n try { return JSON.parse(raw) as string; }\n catch { return raw.slice(1, -1); }\n }\n return raw.replace(/^['\"]|['\"]$/gu, \"\");\n}\n\nexport function parseBundledSkill(source: string): ParsedSkill {\n const match = /^---\\r?\\n([\\s\\S]*?)\\r?\\n---\\r?\\n?/u.exec(source);\n if (match?.[1] === undefined) throw new Error(\"Bundled skill is missing YAML frontmatter.\");\n const name = frontmatterValue(match[1], \"name\");\n const description = frontmatterValue(match[1], \"description\");\n if (!name || !/^[a-z0-9]+(?:-[a-z0-9]+)*$/u.test(name)) throw new Error(\"Bundled skill has an invalid name.\");\n if (!description) throw new Error(`Bundled skill \"${name}\" has no description.`);\n return {\n name,\n description,\n content: source.slice(match[0].length),\n userInvocable: frontmatterValue(match[1], \"user-invocable\") !== \"false\"\n };\n}\n\nexport function dshSkillContent(name: string, content: string): string {\n const override = DSH_SKILL_OVERRIDES[name];\n const native = DSH_NATIVE_SKILLS[name];\n return `${DSH_SKILL_BRIDGE}${override === undefined ? \"\" : `\\n<skill-specific-dsh-override>${override}</skill-specific-dsh-override>`}\\n\\n${native ?? content}`;\n}\n\nexport function defaultBundledSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/oh-story/skills\")\n : resolve(current, \"oh-story/skills\");\n}\n\nexport function defaultDramaSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/drama/skills\")\n : resolve(current, \"drama/skills\");\n}\n\nexport function defaultNovelToGameSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/novel-to-game/skills\")\n : resolve(current, \"novel-to-game/skills\");\n}\n\nfunction createBundledSkillProvider(\n providerName: string,\n skillRoot: string,\n content: (name: string, source: string) => string\n): SkillProvider {\n const root = resolve(skillRoot);\n return {\n name: providerName,\n async list(): Promise<readonly SkillCandidate[]> {\n const directories = (await readdir(root, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name)\n .sort();\n return Promise.all(directories.map(async (directory): Promise<SkillCandidate> => {\n const path = join(root, directory, \"SKILL.md\");\n const parsed = parseBundledSkill(await readFile(path, \"utf8\"));\n if (parsed.name !== directory) throw new Error(`Bundled skill directory \"${directory}\" does not match name \"${parsed.name}\".`);\n return {\n name: parsed.name,\n description: parsed.description,\n invocation: { modelInvocable: true, userInvocable: parsed.userInvocable },\n provider: providerName,\n source: \"bundled\",\n resourceBase: { kind: \"directory\", path: join(root, directory) },\n rank: BUNDLED_SKILL_RANK,\n locator: pathToFileURL(path),\n path\n };\n }));\n },\n async get(candidate): Promise<SkillDefinition | undefined> {\n if (candidate.provider !== providerName || typeof candidate.path !== \"string\") return undefined;\n const path = resolve(candidate.path);\n const relativePath = relative(root, path);\n if (relativePath === \"\" || relativePath.startsWith(\"..\") || isAbsolute(relativePath)) {\n throw new Error(\"Bundled skill locator escaped the packaged skill root.\");\n }\n const parsed = parseBundledSkill(await readFile(path, \"utf8\"));\n if (parsed.name !== candidate.name) return undefined;\n return {\n name: parsed.name,\n description: parsed.description,\n invocation: { modelInvocable: true, userInvocable: parsed.userInvocable },\n provider: providerName,\n source: \"bundled\",\n resourceBase: { kind: \"directory\", path: join(root, parsed.name) },\n path,\n content: content(parsed.name, parsed.content)\n };\n }\n };\n}\n\nexport function createOhStorySkillProvider(skillRoot = defaultBundledSkillRoot()): SkillProvider {\n return createBundledSkillProvider(STORY_PROVIDER_NAME, skillRoot, dshSkillContent);\n}\n\nexport function dshDramaSkillContent(name: string, content: string, skillRoot = defaultDramaSkillRoot()): string {\n const entry = DSH_DRAMA_OVERRIDES[name];\n // Resolved per read, not at import: the config path follows the environment\n // the host actually runs with, and matches what /oh-story/drama-preflight reports.\n const override = typeof entry === \"function\" ? entry(skillRoot) : entry;\n return `${DSH_DRAMA_BRIDGE}${override === undefined ? \"\" : `\\n<skill-specific-dsh-override>${override}</skill-specific-dsh-override>`}\\n\\n${content}`;\n}\n\nexport function createDramaSkillProvider(skillRoot = defaultDramaSkillRoot()): SkillProvider {\n return createBundledSkillProvider(DRAMA_PROVIDER_NAME, skillRoot, (name, content) => dshDramaSkillContent(name, content, skillRoot));\n}\n\nexport function dshNovelToGameSkillContent(_name: string, content: string): string {\n return `${DSH_GAME_BRIDGE}\\n\\n${content}`;\n}\n\nexport function createNovelToGameSkillProvider(skillRoot = defaultNovelToGameSkillRoot()): SkillProvider {\n return createBundledSkillProvider(GAME_PROVIDER_NAME, skillRoot, dshNovelToGameSkillContent);\n}\n\nexport function defaultVideoRecapSkillRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/video-recap/skills\")\n : resolve(current, \"video-recap/skills\");\n}\n\nexport function dshVideoRecapSkillContent(_name: string, content: string): string {\n return `${DSH_VIDEO_BRIDGE}\\n\\n${content}`;\n}\n\nexport function createVideoRecapSkillProvider(skillRoot = defaultVideoRecapSkillRoot()): SkillProvider {\n return createBundledSkillProvider(VIDEO_PROVIDER_NAME, skillRoot, dshVideoRecapSkillContent);\n}\n", "import { createHash } from \"node:crypto\";\nimport { access, lstat, mkdir, rename, writeFile } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { dirname, join, resolve } from \"node:path\";\n\n/**\n * Drama Skills generates no media by itself and neither does DeepSeek: every\n * image, video, or music result comes from a provider adapter that\n * `short-drama-produce` runs through `production_tool.py run --adapter-config`.\n * Upstream deliberately leaves that config file and its credentials outside\n * every project. This module names the bundled adapters, registers them for the\n * current DSH host so the Agent has a file to pass, and reports which host\n * environment variables are present \u2014 never their values.\n */\nexport type DramaAdapterModality = \"image\" | \"video\" | \"music\";\n\nexport interface DramaAdapterSpec {\n /** Adapter id used both in the config file and in a job's `adapter` field. */\n readonly name: string;\n readonly label: string;\n readonly modality: DramaAdapterModality;\n /** Host environment variables the bundled adapter refuses to run without. */\n readonly requiredEnv: readonly string[];\n readonly optionalEnv: readonly string[];\n readonly timeoutSeconds: number;\n /** Provider reference shipped with the Skill, relative to the drama skill root. */\n readonly reference: string;\n}\n\nexport interface DramaAdapterStatus {\n readonly name: string;\n readonly label: string;\n readonly modality: DramaAdapterModality;\n readonly configured: boolean;\n readonly missing: readonly string[];\n}\n\nexport interface DramaAdapterConfigLocation {\n readonly path: string;\n /** True when the plugin writes the file; false when the creator points at their own. */\n readonly generated: boolean;\n}\n\n/** Point at a creator-owned adapter config instead of the generated one. */\nexport const DRAMA_ADAPTER_CONFIG_ENV = \"OH_STORY_DRAMA_ADAPTER_CONFIG\";\n\nconst PROVIDER_SCRIPT = \"short-drama-produce/scripts/provider_adapters.py\";\n\nexport const DRAMA_ADAPTERS: readonly DramaAdapterSpec[] = [\n {\n name: \"gpt-image-2\",\n label: \"GPT Image 2\",\n modality: \"image\",\n requiredEnv: [\"OPENAI_API_KEY\"],\n optionalEnv: [\"OPENAI_BASE_URL\"],\n timeoutSeconds: 600,\n reference: \"short-drama-produce/references/providers/gpt-image-2.md\"\n },\n {\n name: \"seedance\",\n label: \"Seedance\",\n modality: \"video\",\n requiredEnv: [\"ARK_API_KEY\", \"SEEDANCE_MODEL\"],\n optionalEnv: [\"SEEDANCE_BASE_URL\", \"SEEDANCE_ALLOWED_RATIOS\", \"SEEDANCE_MIN_DURATION\", \"SEEDANCE_MAX_DURATION\"],\n timeoutSeconds: 3_600,\n reference: \"short-drama-produce/references/providers/seedance.md\"\n },\n {\n name: \"minimax-h3\",\n label: \"MiniMax H3\",\n modality: \"video\",\n requiredEnv: [\"MINIMAX_API_KEY\", \"MINIMAX_VIDEO_MODEL\", \"MINIMAX_VIDEO_RESOLUTIONS\"],\n optionalEnv: [\"MINIMAX_VIDEO_BASE_URL\", \"MINIMAX_VIDEO_RATIOS\", \"MINIMAX_VIDEO_MIN_DURATION\", \"MINIMAX_VIDEO_MAX_DURATION\"],\n timeoutSeconds: 3_600,\n reference: \"short-drama-produce/references/providers/minimax-h3-video.md\"\n },\n {\n name: \"minimax-music\",\n label: \"MiniMax Music\",\n modality: \"music\",\n requiredEnv: [\"MINIMAX_API_KEY\"],\n optionalEnv: [\"MINIMAX_BASE_URL\"],\n timeoutSeconds: 600,\n reference: \"short-drama-produce/references/providers/minimax-music.md\"\n }\n];\n\n/** Directory owned by this user: `/tmp` is world-writable on Linux, so the name carries the uid. */\nfunction generatedDirectory(temporaryRoot: string): string {\n const uid = process.getuid?.();\n return join(temporaryRoot, uid === undefined ? \"oh-story-dsh\" : `oh-story-dsh-${String(uid)}`);\n}\n\n/**\n * The generated file is keyed by the skill root so two DSH profiles running\n * different plugin installs never overwrite each other's registration.\n */\nexport function dramaAdapterConfigPath(skillRoot: string, env: NodeJS.ProcessEnv = process.env, temporaryRoot = tmpdir()): DramaAdapterConfigLocation {\n const custom = env[DRAMA_ADAPTER_CONFIG_ENV] ?? \"\";\n if (custom !== \"\") return { path: resolve(custom), generated: false };\n const key = createHash(\"sha256\").update(resolve(skillRoot)).digest(\"hex\").slice(0, 12);\n return { path: join(generatedDirectory(temporaryRoot), `drama-adapters-${key}.json`), generated: true };\n}\n\n/**\n * The file's content becomes an argv that `production_tool.py` executes, so it\n * is written only into a directory this process owns: a pre-existing directory\n * that belongs to someone else, or a symlink, is refused rather than reused.\n */\nasync function privateDirectory(path: string): Promise<boolean> {\n await mkdir(path, { recursive: true, mode: 0o700 });\n const info = await lstat(path);\n if (!info.isDirectory()) return false;\n const uid = process.getuid?.();\n return uid === undefined || info.uid === uid;\n}\n\n/** The upstream adapter-config document: argv commands and timeouts only, never credentials. */\nexport function dramaAdapterConfigDocument(skillRoot: string, python = \"python3\"): { readonly adapters: Record<string, { readonly command: readonly string[]; readonly timeout_seconds: number }> } {\n const script = resolve(skillRoot, PROVIDER_SCRIPT);\n const adapters: Record<string, { readonly command: readonly string[]; readonly timeout_seconds: number }> = {};\n for (const adapter of DRAMA_ADAPTERS) {\n adapters[adapter.name] = { command: [python, script, adapter.name], timeout_seconds: adapter.timeoutSeconds };\n }\n return { adapters };\n}\n\n/**\n * Register the bundled adapters for this host. A creator-owned config is left\n * untouched and only checked for existence.\n */\nexport async function ensureDramaAdapterConfig(\n skillRoot: string,\n options: { readonly python?: string; readonly env?: NodeJS.ProcessEnv; readonly temporaryRoot?: string } = {}\n): Promise<DramaAdapterConfigLocation & { readonly ok: boolean }> {\n const location = dramaAdapterConfigPath(skillRoot, options.env ?? process.env, options.temporaryRoot ?? tmpdir());\n if (!location.generated) {\n return { ...location, ok: await access(location.path).then(() => true, () => false) };\n }\n try {\n if (!(await privateDirectory(dirname(location.path)))) return { ...location, ok: false };\n const existing = await lstat(location.path).catch(() => undefined);\n if (existing !== undefined && !existing.isFile()) return { ...location, ok: false };\n // Temp file + rename: a reader never sees a truncated document.\n const staging = `${location.path}.${String(process.pid)}.tmp`;\n await writeFile(staging, `${JSON.stringify(dramaAdapterConfigDocument(skillRoot, options.python ?? \"python3\"), null, 2)}\\n`, { encoding: \"utf8\", mode: 0o600 });\n await rename(staging, location.path);\n return { ...location, ok: true };\n } catch {\n return { ...location, ok: false };\n }\n}\n\n/** Presence only: a variable counts as configured when it is set and non-empty. */\nexport function dramaAdapterStatuses(env: NodeJS.ProcessEnv = process.env): DramaAdapterStatus[] {\n return DRAMA_ADAPTERS.map((adapter) => {\n const missing = adapter.requiredEnv.filter((name) => (env[name] ?? \"\") === \"\");\n return { name: adapter.name, label: adapter.label, modality: adapter.modality, configured: missing.length === 0, missing };\n });\n}\n\n/** One line per adapter for Skill text: `gpt-image-2 (image: OPENAI_API_KEY)`. */\nexport function dramaAdapterSummary(): string {\n return DRAMA_ADAPTERS.map((adapter) => `${adapter.name} (${adapter.modality}: ${adapter.requiredEnv.join(\" + \")})`).join(\", \");\n}\n", "import { execFile } from \"node:child_process\";\nimport { promisify } from \"node:util\";\n\nconst execFileAsync = promisify(execFile);\n\nexport interface PythonProbe { readonly ok: boolean; readonly version?: string | undefined }\n\nexport async function commandOutput(command: string, args: readonly string[]): Promise<string | undefined> {\n try {\n const { stdout, stderr } = await execFileAsync(command, [...args], { encoding: \"utf8\", timeout: 5_000, maxBuffer: 4 * 1_024 * 1_024 });\n return `${stdout}${stderr}`.trim();\n } catch { return undefined; }\n}\n\n/** Upstream Skills require Python 3.10+. */\nexport function pythonVersion(value: string | undefined): PythonProbe {\n const match = /Python\\s+(\\d+)\\.(\\d+)(?:\\.(\\d+))?/u.exec(value ?? \"\");\n if (match === null) return { ok: false };\n const major = Number(match[1]);\n const minor = Number(match[2]);\n return { ok: major > 3 || (major === 3 && minor >= 10), version: match[0].replace(/^Python\\s+/u, \"\") };\n}\n\n/**\n * The interpreter the host will run upstream scripts with. The first command\n * that meets the version floor wins; an interpreter that answers but is too old\n * is reported only when nothing better exists, so `python3` at 3.9 does not hide\n * `python` at 3.12. The command is written into the adapter config's argv, so\n * this is the same choice everywhere the plugin starts Python.\n */\nexport async function hostPython(probe: (command: string, args: readonly string[]) => Promise<string | undefined> = commandOutput): Promise<{ readonly command: string; readonly probe: PythonProbe }> {\n let fallback: { readonly command: string; readonly probe: PythonProbe } | undefined;\n for (const command of [\"python3\", \"python\"]) {\n const parsed = pythonVersion(await probe(command, [\"--version\"]));\n if (parsed.ok) return { command, probe: parsed };\n if (parsed.version !== undefined) fallback ??= { command, probe: parsed };\n }\n return fallback ?? { command: \"python3\", probe: { ok: false } };\n}\n", "import type { Context } from \"@deepseek-ai/cordis\";\nimport type { FileSystem, FsTarget } from \"@deepseek-ai/dsh-fs\";\nimport { createUserMessage } from \"@deepseek-ai/dsh-llm\";\nimport type { PostToolDecision, PreToolDecision, ToolExecution } from \"@deepseek-ai/dsh-tools\";\n\nconst MUTATION_TOOLS = new Set([\"write\", \"edit\", \"str_replace_editor\"]);\n\nexport interface StoryMutation {\n readonly root: string;\n readonly path: string;\n readonly chapter?: number;\n}\n\nfunction mutationPath(name: string, args: unknown): string | undefined {\n if (!MUTATION_TOOLS.has(name) || typeof args !== \"object\" || args === null || Array.isArray(args)) return undefined;\n const record = args as Record<string, unknown>;\n if (name === \"str_replace_editor\") {\n if (!new Set([\"create\", \"str_replace\", \"insert\"]).has(String(record.command))) return undefined;\n return typeof record.path === \"string\" && record.path.trim() !== \"\" ? record.path : undefined;\n }\n return typeof record.file_path === \"string\" && record.file_path.trim() !== \"\" ? record.file_path : undefined;\n}\n\nfunction normalizedRelativePath(path: string): string | undefined {\n const segments: string[] = [];\n for (const part of path.split(\"/\")) {\n if (part === \"\" || part === \".\") continue;\n if (part === \"..\") {\n if (segments.length === 0) return undefined;\n segments.pop();\n } else segments.push(part);\n }\n return segments.join(\"/\");\n}\n\nexport function detectStoryMutation(name: string, args: unknown, cwd: string | undefined): StoryMutation | undefined {\n const rawPath = mutationPath(name, args);\n if (cwd === undefined || rawPath === undefined) return undefined;\n const root = cwd.replaceAll(\"\\\\\", \"/\").replace(/\\/$/u, \"\");\n const candidate = rawPath.replaceAll(\"\\\\\", \"/\");\n const absolute = candidate.startsWith(\"/\") || /^[a-z]:\\//iu.test(candidate) || /^[a-z][a-z\\d+.-]*:\\/\\//iu.test(candidate);\n const insideRoot = /^[a-z]:\\//iu.test(root)\n ? candidate.toLowerCase().startsWith(`${root.toLowerCase()}/`)\n : candidate.startsWith(`${root}/`);\n if (absolute && !insideRoot) return undefined;\n const normalized = normalizedRelativePath(absolute ? candidate.slice(root.length + 1) : candidate);\n if (normalized === undefined) return undefined;\n if (!normalized.startsWith(\"\u6B63\u6587/\")) return undefined;\n const chapterText = /\u7B2C0*(\\d+)\u7AE0/u.exec(normalized)?.[1];\n return { root, path: normalized, ...(chapterText === undefined ? {} : { chapter: Number(chapterText) }) };\n}\n\ntype StoryFileSystem = Pick<FileSystem, \"resolve\" | \"contains\" | \"stat\" | \"listDir\">;\n\nasync function storyMutation(exec: ToolExecution, fs: StoryFileSystem): Promise<StoryMutation | undefined> {\n const cwd = exec.agent?.session.header.cwd;\n const path = mutationPath(exec.name, exec.arguments);\n if (cwd === undefined || path === undefined) return undefined;\n try {\n const [rootTarget, mutationTarget] = await Promise.all([\n fs.resolve(cwd, { signal: exec.signal }),\n fs.resolve(path, { cwd, signal: exec.signal })\n ]);\n if (!fs.contains(rootTarget, mutationTarget)) return undefined;\n } catch { return undefined; }\n return detectStoryMutation(exec.name, exec.arguments, cwd);\n}\n\nasync function target(fs: StoryFileSystem, root: string, path: string, signal?: AbortSignal): Promise<FsTarget> {\n return fs.resolve(path, { cwd: root, ...(signal === undefined ? {} : { signal }) });\n}\n\nasync function exists(fs: StoryFileSystem, root: string, path: string, signal?: AbortSignal): Promise<boolean> {\n return target(fs, root, path, signal)\n .then((value) => fs.stat(value, signal))\n .then((info) => info !== undefined, () => false);\n}\n\nasync function hasChapterOutline(fs: StoryFileSystem, root: string, chapter: number, signal?: AbortSignal): Promise<boolean> {\n const entries = await target(fs, root, \"\u5927\u7EB2\", signal)\n .then((directory) => fs.listDir(directory, signal))\n .catch(() => []);\n return entries.some((entry) => entry.type === \"file\"\n && Number(/^\u7EC6\u7EB2_\u7B2C0*(\\d+)\u7AE0.*\\.md$/u.exec(entry.name)?.[1]) === chapter);\n}\n\nexport async function validateStoryMutation(\n fs: StoryFileSystem,\n mutation: StoryMutation,\n signal?: AbortSignal\n): Promise<string | undefined> {\n const hasLongFormLayout = await exists(fs, mutation.root, \"\u5927\u7EB2\", signal)\n || await exists(fs, mutation.root, \"\u8FFD\u8E2A\", signal);\n if (!hasLongFormLayout) return undefined;\n if (!(await exists(fs, mutation.root, \"\u8FFD\u8E2A/_tracking-state.json\", signal))) {\n // Setup/import must be able to bootstrap an existing manuscript before the\n // canonical Tracking file exists. The Skill remains responsible for\n // creating it; hard guards begin once the project has committed Tracking.\n return undefined;\n }\n if (mutation.chapter !== undefined && !(await hasChapterOutline(fs, mutation.root, mutation.chapter, signal))) {\n return `Oh Story \u963B\u6B62\u5199\u5165\u7B2C ${String(mutation.chapter)} \u7AE0\uFF1A\u672A\u627E\u5230\u5BF9\u5E94\u7684 \u5927\u7EB2/\u7EC6\u7EB2_\u7B2CXXX\u7AE0*.md\u3002\u8BF7\u5148\u5B8C\u6210\u7EC6\u7EB2\u3002`;\n }\n return undefined;\n}\n\nexport async function decideStoryMutation(\n exec: ToolExecution,\n next: () => Promise<PreToolDecision>\n): Promise<PreToolDecision> {\n const fs = exec.agent?.ctx.get(\"fs\");\n if (fs === undefined) return next();\n const mutation = await storyMutation(exec, fs);\n if (mutation === undefined) return next();\n const reason = await validateStoryMutation(fs, mutation, exec.signal);\n if (reason !== undefined) return { kind: \"deny\", reason };\n return next();\n}\n\n/**\n * Native DSH equivalents of the upstream prose guards. They join DSH's typed\n * tool waterfall, so decisions remain visible in the official approval/tool UI.\n */\nexport function registerOhStoryHooks(context: Context): void {\n context.on(\"tools/pre-execute\", decideStoryMutation);\n\n context.on(\"tools/post-execute\", async (exec, result, next): Promise<PostToolDecision> => {\n const downstream = await next();\n if (result.isError || downstream.kind !== \"accept\") return downstream;\n const fs = exec.agent?.ctx.get(\"fs\");\n const mutation = fs === undefined ? undefined : await storyMutation(exec, fs);\n if (mutation === undefined) return downstream;\n const reminder = createUserMessage({\n source: { kind: \"plugin\", plugin: \"oh-story\" },\n content: [{\n type: \"text\",\n text: `<oh-story-post-write>\u6B63\u6587 ${mutation.path} \u5DF2\u53D8\u66F4\u3002\u7EE7\u7EED\u5F53\u524D\u6B65\u9AA4\u524D\u6838\u5BF9\u5E76\u66F4\u65B0 _tracking-state.json \u53CA\u5BF9\u5E94\u6D3E\u751F Tracking \u89C6\u56FE\uFF1B\u4E0D\u8981\u628A\u8FD9\u6761\u63D0\u9192\u5F53\u4F5C\u7528\u6237\u7684\u65B0\u5199\u4F5C\u8981\u6C42\u3002</oh-story-post-write>`\n }]\n });\n return {\n ...downstream,\n additionalContexts: [...downstream.additionalContexts ?? [], reminder]\n };\n });\n}\n", "import type { Context } from \"@deepseek-ai/cordis\";\nimport type { ContentBlock } from \"@deepseek-ai/dsh-llm\";\nimport type { SubagentRuntime } from \"@deepseek-ai/dsh-subagent\";\nimport type { JsonValue } from \"@deepseek-ai/dsh-util-values\";\nimport { defineTool, type ToolDefinition } from \"@deepseek-ai/dsh-tools\";\nimport {\n bundledReferenceGuard,\n createOhStoryReferenceTool,\n OH_STORY_REFERENCE_TOOL_NAME\n} from \"./reference-tool.js\";\nimport { OH_STORY_ROLE_NAMES, loadBundledRole, type OhStoryRoleName } from \"./role-provider.js\";\n\nexport const OH_STORY_ROLE_TOOL_NAME = \"oh_story_role\";\nexport type OhStoryRoleSubagents = Pick<SubagentRuntime, \"start\">;\n\nconst roleTools: Readonly<Record<OhStoryRoleName, readonly string[]>> = {\n \"chapter-extractor\": [\"read\", \"glob\", \"grep\"],\n \"character-designer\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\", \"write\", \"edit\"],\n \"consistency-checker\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\"],\n \"narrative-writer\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\", \"write\", \"edit\", \"bash\"],\n \"story-architect\": [OH_STORY_REFERENCE_TOOL_NAME, \"read\", \"glob\", \"grep\", \"write\", \"edit\"],\n \"story-explorer\": [\"read\", \"glob\", \"grep\"],\n \"story-researcher\": [\"read\", \"glob\", \"grep\", \"bash\", \"write\", \"web_search\", \"web_fetch\"]\n};\n\nexport function roleToolFilter(role: OhStoryRoleName): { readonly allow: readonly string[] } {\n return { allow: roleTools[role] };\n}\n\nfunction resultText(output: readonly ContentBlock[]): string {\n return output.map((block) => block.type === \"text\" ? block.text : JSON.stringify(block)).join(\"\\n\");\n}\n\nexport async function createOhStoryRoleTool(subagents?: OhStoryRoleSubagents): Promise<ToolDefinition> {\n const personas = new Map<OhStoryRoleName, string>();\n await Promise.all(OH_STORY_ROLE_NAMES.map(async (role) => {\n personas.set(role, await loadBundledRole(role, undefined, \"native-tools\"));\n }));\n return defineTool({\n name: OH_STORY_ROLE_TOOL_NAME,\n description: \"Run one focused Oh Story specialist as a child of the current DSH Agent. The child inherits DSH model, workspace, permissions, lifecycle, and UI.\",\n parameters: {\n role: {\n type: \"string\",\n required: true,\n enum: OH_STORY_ROLE_NAMES,\n description: \"The exact Oh Story Role to run.\"\n },\n prompt: {\n type: \"string\",\n required: true,\n description: \"A self-contained task. The child inherits the current DSH workspace but not the current in-flight turn.\"\n }\n },\n output: {\n schema: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n role: { type: \"string\", required: true, enum: OH_STORY_ROLE_NAMES },\n runId: { type: \"string\", required: true },\n content: { type: \"array\", required: true, items: { type: \"json\" } }\n }\n },\n render: (_args, value) => [{ type: \"text\", text: resultText(value.content as unknown as ContentBlock[]) }]\n },\n isConcurrencySafe: () => true,\n async execute(args, exec) {\n if (exec.agent === undefined) throw new Error(\"oh_story_role requires a calling DSH Agent.\");\n const persona = personas.get(args.role);\n if (persona === undefined) throw new Error(`Oh Story Role ${args.role} is not bundled.`);\n const allowed = roleToolFilter(args.role).allow.filter((name) =>\n exec.agent?.ctx.tools.get(name, exec.agent) !== undefined);\n const runtime = subagents ?? exec.agent.ctx.get(\"subagents\");\n if (runtime === undefined) throw new Error(\"oh_story_role requires the DSH subagent runtime.\");\n const run = await runtime.start(\"spawn\", {\n label: `oh-story:${args.role}`,\n prompt: [{ type: \"text\", text: args.prompt }],\n parent: exec.agent,\n persona,\n toolFilter: { allow: allowed },\n maxDepth: 1,\n signal: exec.signal\n });\n try {\n const result = await run.result;\n if (result.stopReason !== \"completed\") {\n throw new Error(`Oh Story Role ${args.role} ended with ${result.stopReason}${result.diagnostic === undefined ? \"\" : `: ${result.diagnostic}`}`);\n }\n return {\n role: args.role,\n runId: run.id,\n content: result.output as unknown as JsonValue[]\n };\n } finally {\n await run.dispose();\n }\n }\n });\n}\n\nexport async function registerOhStoryRoleTool(context: Context): Promise<void> {\n const [definition, referenceDefinition] = await Promise.all([\n createOhStoryRoleTool(context.subagents),\n createOhStoryReferenceTool()\n ]);\n context.tools.register(referenceDefinition);\n context.tools.guard(bundledReferenceGuard(referenceDefinition, context.tools));\n let dispose: (() => void) | undefined;\n const mount = (): void => { dispose ??= context.tools.register(definition); };\n const unmount = (): void => { dispose?.(); dispose = undefined; };\n context.on(\"subagent/provider-added\", (provider) => { if (provider.name === \"spawn\") mount(); });\n context.on(\"subagent/provider-removed\", (name) => { if (name === \"spawn\") unmount(); });\n if (context.subagents.getProvider(\"spawn\") !== undefined) mount();\n}\n", "import { readdir, readFile, realpath } from \"node:fs/promises\";\nimport { isAbsolute, join, relative, resolve } from \"node:path\";\nimport { defineTool, type ToolDefinition, type ToolGuard, type ToolRuntime } from \"@deepseek-ai/dsh-tools\";\nimport { defaultBundledSkillRoot } from \"./skill-provider.js\";\n\nexport const OH_STORY_REFERENCE_TOOL_NAME = \"oh_story_bundled_reference\";\n\ninterface BundledReference {\n readonly canonicalPath: string;\n readonly name: string;\n}\n\nasync function collectMarkdown(root: string, directory = root): Promise<string[]> {\n const entries = await readdir(directory, { withFileTypes: true });\n const nested = await Promise.all(entries.map(async (entry): Promise<string[]> => {\n const path = join(directory, entry.name);\n if (entry.isDirectory()) return collectMarkdown(root, path);\n return entry.isFile() && entry.name.endsWith(\".md\") ? [path] : [];\n }));\n return nested.flat();\n}\n\nasync function bundledReferences(storySetupRoot: string): Promise<readonly BundledReference[]> {\n const root = await realpath(resolve(storySetupRoot));\n const referenceRoot = await realpath(join(root, \"references\", \"agent-references\"));\n const referenceDirectory = relative(root, referenceRoot);\n if (referenceDirectory === \"\" || referenceDirectory.startsWith(\"..\") || isAbsolute(referenceDirectory)) {\n throw new Error(\"Bundled Oh Story reference directory escaped its package root.\");\n }\n const values = await Promise.all((await collectMarkdown(referenceRoot)).map(async (path): Promise<BundledReference> => {\n const canonicalPath = await realpath(path);\n const inside = relative(referenceRoot, canonicalPath);\n if (inside === \"\" || inside.startsWith(\"..\") || isAbsolute(inside)) {\n throw new Error(`Bundled Oh Story reference escaped its package root: ${path}`);\n }\n return {\n canonicalPath,\n name: `story-setup/references/agent-references/${inside.replaceAll(\"\\\\\", \"/\")}`\n };\n }));\n return values.sort((left, right) => left.name.localeCompare(right.name));\n}\n\nexport async function createOhStoryReferenceTool(\n storySetupRoot = join(defaultBundledSkillRoot(), \"story-setup\")\n): Promise<ToolDefinition> {\n const references = await bundledReferences(storySetupRoot);\n if (references.length === 0) throw new Error(\"No bundled Oh Story references were found.\");\n const paths = references.map((reference) => reference.name);\n const byName = new Map(references.map((reference) => [reference.name, reference.canonicalPath]));\n return defineTool({\n name: OH_STORY_REFERENCE_TOOL_NAME,\n description: \"Read one exact, pinned Oh Story story-setup reference bundled with this plugin. This does not resolve project Skills or workspace files.\",\n parameters: {\n reference: {\n type: \"string\",\n required: true,\n enum: paths,\n description: \"The exact story-setup reference path named by the active bundled Role.\"\n }\n },\n output: {\n schema: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n reference: { type: \"string\", required: true },\n content: { type: \"string\", required: true }\n }\n },\n render: (_args, value) => [{\n type: \"text\",\n text: `Bundled Oh Story reference: ${value.reference}\\n\\n${value.content}`\n }]\n },\n isConcurrencySafe: () => true,\n async execute(args) {\n const path = byName.get(args.reference);\n if (path === undefined) throw new Error(`Oh Story reference is not bundled: ${args.reference}`);\n return { reference: args.reference, content: await readFile(path, \"utf8\") };\n }\n });\n}\n\n/** Deny a scoped same-name replacement instead of executing untrusted reference code. */\nexport function bundledReferenceGuard(\n definition: ToolDefinition,\n tools: Pick<ToolRuntime, \"get\">\n): ToolGuard {\n return (execution) => execution.name === OH_STORY_REFERENCE_TOOL_NAME\n && tools.get(OH_STORY_REFERENCE_TOOL_NAME, execution.agent) !== definition\n ? \"The pinned Oh Story reference tool was shadowed in this Agent scope.\"\n : undefined;\n}\n", "import { readFile } from \"node:fs/promises\";\nimport { basename, dirname, join, resolve } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\n\nexport const OH_STORY_ROLE_NAMES = [\n \"chapter-extractor\",\n \"character-designer\",\n \"consistency-checker\",\n \"narrative-writer\",\n \"story-architect\",\n \"story-explorer\",\n \"story-researcher\"\n] as const;\n\nexport type OhStoryRoleName = typeof OH_STORY_ROLE_NAMES[number];\nexport type OhStoryRoleExecution = \"tool-free\" | \"native-tools\";\n\nfunction roleBody(source: string): string {\n const frontmatter = /^---\\r?\\n[\\s\\S]*?\\r?\\n---\\r?\\n?/u.exec(source);\n return source.slice(frontmatter?.[0].length ?? 0).trim();\n}\n\nexport function defaultBundledRoleRoot(): string {\n const current = dirname(fileURLToPath(import.meta.url));\n return basename(current) === \"src\"\n ? resolve(current, \"../../knowledge/oh-story/roles\")\n : resolve(current, \"oh-story/roles\");\n}\n\nexport async function loadBundledRole(\n name: OhStoryRoleName,\n roleRoot = defaultBundledRoleRoot(),\n execution: OhStoryRoleExecution = \"tool-free\"\n): Promise<string> {\n const body = roleBody(await readFile(join(resolve(roleRoot), `${name}.md`), \"utf8\"));\n if (body.length === 0) throw new Error(`Bundled role \"${name}\" is empty.`);\n const integration = execution === \"tool-free\"\n ? [\n \"You are running inside an Oh Story review-required DSH collaboration. The caller supplies every permitted input in the prompt.\",\n \"Do not read or write project files, do not call tools, and do not follow legacy .claude/.codex path or deployment instructions in the upstream role text.\",\n \"Return only the output contract requested by the caller; never claim to have changed the project.\"\n ]\n : [\n \"You are running as a native oh-story-dsh specialist. The current DSH workspace and visible tool set are your complete authority boundary.\",\n \"Never inspect or require legacy .claude/.opencode/.codex agent deployment files; this exact pinned Role is already active.\",\n \"Bundled story-setup references are pinned plugin resources, not project files or project Skills. When the upstream Role marks one mandatory, call oh_story_bundled_reference with the exact story-setup/references/agent-references path, then use only the returned content.\",\n \"If oh_story_bundled_reference or a required bundled reference is unavailable, report the missing reference to the caller. Never call the generic skill tool, fall back to a legacy platform path, or claim that an unread reference was used.\",\n \"Use only the tools actually visible to you. Mutate files only when the caller explicitly requests it and your visible DSH tools permit it; otherwise return findings to the caller.\"\n ];\n return [\n `OH_STORY_DSH_ROLE:${name}`,\n ...integration,\n \"\",\n body\n ].join(\"\\n\");\n}\n", "import type { Context } from \"@deepseek-ai/cordis\";\nimport { defineTool, type ToolDefinition } from \"@deepseek-ai/dsh-tools\";\nimport {\n OH_STORY_PRODUCTION_TOOL_NAME,\n PRODUCTION_INTENT_ACTIONS,\n PRODUCTION_INTENT_JOB_KINDS,\n PRODUCTION_INTENT_SECTIONS,\n validateProductionIntent,\n type ProductionIntentArgs\n} from \"./production-intent.js\";\n\nfunction intentMessage(intent: ProductionIntentArgs): string {\n if (intent.action === \"track_job\") return `\u5DF2\u628A ${intent.targetId ?? \"\u751F\u4EA7\u5BF9\u8C61\"} \u7684 ${intent.jobKind ?? \"\u5A92\u4F53\"} \u4EFB\u52A1\u6295\u5F71\u5230 ${intent.episode} \u7684\u4EFB\u52A1\u677F\u3002`;\n if (intent.action === \"set_sequence\") return `\u5DF2\u628A ${String(intent.shotIds?.length ?? 0)} \u4E2A\u955C\u5934\u7684\u987A\u5E8F\u53D1\u9001\u5230 ${intent.episode} \u6210\u7247\u89C6\u56FE\u3002`;\n if (intent.action === \"focus_target\") return `\u5DF2\u8BF7\u6C42 ${intent.episode} \u751F\u4EA7\u89C6\u56FE\u805A\u7126 ${intent.targetId ?? \"\u76EE\u6807\"}\u3002`;\n return `\u5DF2\u628A ${intent.action} \u754C\u9762\u610F\u56FE\u53D1\u9001\u5230 ${intent.episode} \u751F\u4EA7\u5DE5\u4F5C\u53F0\u3002`;\n}\n\nexport function createOhStoryProductionTool(): ToolDefinition {\n return defineTool({\n name: OH_STORY_PRODUCTION_TOOL_NAME,\n description: \"Operate the native oh-story short-drama production projection in the current DSH Session. It can open or focus semantic production targets, set an explicit shot order, or track a job the Agent is actually executing. It never controls cosmetic canvas layout, generates media, changes creator documents, or counts as creator confirmation for paid production.\",\n parameters: {\n action: { type: \"string\", required: true, enum: PRODUCTION_INTENT_ACTIONS, description: \"The exact production UI/task projection operation.\" },\n episode: { type: \"string\", required: true, description: \"Creator-first episode directory, for example \u5267\u96C6/EP001.\" },\n section: { type: \"string\", enum: PRODUCTION_INTENT_SECTIONS },\n targetId: { type: \"string\" },\n shotIds: { type: \"array\", items: { type: \"string\" } },\n jobId: { type: \"string\", description: \"Stable ID that must also appear in produced output filenames.\" },\n jobKind: { type: \"string\", enum: PRODUCTION_INTENT_JOB_KINDS },\n expectedOutputs: { type: \"integer\", description: \"Number of media files this job will produce. Repeat the count the creator approved when re-registering a batch; omit it to keep the count the workbench already recorded.\" },\n prompt: { type: \"string\", description: \"Exact prompt/specification for a tracked job; not a production authorization.\" }\n },\n output: {\n schema: {\n type: \"object\",\n additionalProperties: false,\n properties: {\n action: { type: \"string\", required: true, enum: PRODUCTION_INTENT_ACTIONS },\n episode: { type: \"string\", required: true },\n message: { type: \"string\", required: true }\n }\n },\n render: (_args, value) => [{ type: \"text\", text: value.message }]\n },\n isConcurrencySafe: () => true,\n execute(args) {\n const intent = validateProductionIntent(args);\n return Promise.resolve({ action: intent.action, episode: intent.episode, message: intentMessage(intent) });\n }\n });\n}\n\nexport function registerOhStoryProductionTool(context: Context): void {\n context.tools.register(createOhStoryProductionTool());\n}\n", "export const OH_STORY_PRODUCTION_TOOL_NAME = \"oh_story_production\";\n\nexport const PRODUCTION_INTENT_ACTIONS = [\n \"open_section\",\n \"focus_target\",\n \"set_sequence\",\n \"track_job\"\n] as const;\n\nexport const PRODUCTION_INTENT_SECTIONS = [\"shots\", \"assets\", \"tasks\", \"sequence\", \"canvas\"] as const;\nexport const PRODUCTION_INTENT_JOB_KINDS = [\"image\", \"video\", \"composition\"] as const;\n\nexport type ProductionIntentAction = typeof PRODUCTION_INTENT_ACTIONS[number];\nexport type ProductionIntentSection = typeof PRODUCTION_INTENT_SECTIONS[number];\nexport type ProductionIntentJobKind = typeof PRODUCTION_INTENT_JOB_KINDS[number];\n\nexport interface ProductionIntentArgs {\n readonly action: ProductionIntentAction;\n readonly episode: string;\n readonly section?: ProductionIntentSection | undefined;\n readonly targetId?: string | undefined;\n readonly shotIds?: readonly string[] | undefined;\n readonly jobId?: string | undefined;\n readonly jobKind?: ProductionIntentJobKind | undefined;\n readonly expectedOutputs?: number | undefined;\n readonly prompt?: string | undefined;\n}\n\nfunction requiredText(value: string | undefined, field: string): string {\n const normalized = value?.trim();\n if (!normalized) throw new Error(`oh_story_production ${field} is required for this action.`);\n if (normalized.length > 512) throw new Error(`oh_story_production ${field} is too long.`);\n return normalized;\n}\n\n/** Validate the cross-runtime UI intent without reading or mutating workspace state. */\nexport function validateProductionIntent(args: ProductionIntentArgs): ProductionIntentArgs {\n const episode = args.episode.trim().replaceAll(\"\\\\\", \"/\").replace(/\\/$/u, \"\");\n if (!/^\u5267\u96C6\\/EP\\d{3,}$/u.test(episode)) {\n throw new Error(\"oh_story_production episode must use the creator path form \u5267\u96C6/EP001.\");\n }\n if (args.action === \"open_section\") {\n if (args.section === undefined) throw new Error(\"oh_story_production section is required for open_section.\");\n return { action: args.action, episode, section: args.section };\n }\n if (args.action === \"focus_target\") {\n return { action: args.action, episode, targetId: requiredText(args.targetId, \"targetId\"), section: args.section };\n }\n if (args.action === \"set_sequence\") {\n const shotIds = args.shotIds?.map((value) => value.trim()).filter((value) => value !== \"\") ?? [];\n if (shotIds.length === 0) throw new Error(\"oh_story_production shotIds must contain at least one shot for set_sequence.\");\n if (shotIds.length > 500 || new Set(shotIds).size !== shotIds.length || shotIds.some((value) => !/^SHOT-[A-Z0-9-]+$/u.test(value))) {\n throw new Error(\"oh_story_production shotIds must be unique canonical SHOT-* identifiers.\");\n }\n return { action: args.action, episode, shotIds };\n }\n // Leave expectedOutputs/prompt undefined when the caller omits them: track_job re-registers a job the\n // workbench already created, and defaulting here would silently reset a batch's count to 1.\n const expectedOutputs = args.expectedOutputs;\n if (expectedOutputs !== undefined && (!Number.isInteger(expectedOutputs) || expectedOutputs < 1 || expectedOutputs > 500)) {\n throw new Error(\"oh_story_production expectedOutputs must be an integer between 1 and 500.\");\n }\n if (args.jobKind === undefined) throw new Error(\"oh_story_production jobKind is required for track_job.\");\n const prompt = args.prompt?.trim();\n return {\n action: args.action,\n episode,\n jobId: requiredText(args.jobId, \"jobId\"),\n targetId: requiredText(args.targetId, \"targetId\"),\n jobKind: args.jobKind,\n expectedOutputs,\n prompt: prompt === \"\" ? undefined : prompt\n };\n}\n", "import { createHash } from \"node:crypto\";\nimport { createReadStream } from \"node:fs\";\nimport { readFile as readNodeFile, realpath as nodeRealpath, stat as nodeStat } from \"node:fs/promises\";\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport { extname, isAbsolute, relative, resolve } from \"node:path\";\nimport type { Context } from \"@deepseek-ai/cordis\";\nimport type { Agent } from \"@deepseek-ai/dsh-agent\";\nimport { FsError, type FileSystem, type FsInfo, type FsTarget, type FsVersion } from \"@deepseek-ai/dsh-fs\";\nimport type {} from \"@deepseek-ai/dsh-host-webserver\";\nimport type { SandboxPolicyService } from \"@deepseek-ai/dsh-sandbox-policy\";\nimport { SessionId } from \"@deepseek-ai/dsh-session\";\nimport type {} from \"@deepseek-ai/dsh-typert-registry\";\nimport { type GameVerificationBinding, WorkspaceVerificationTracker } from \"./game-verification.js\";\nimport { dramaAdapterStatuses, ensureDramaAdapterConfig, type DramaAdapterStatus } from \"./drama-adapters.js\";\nimport { commandOutput, hostPython } from \"./host-python.js\";\nimport { defaultDramaSkillRoot, defaultNovelToGameSkillRoot } from \"./skill-provider.js\";\nimport { skipVideoDirectory, summarizeVideoProject, VIDEO_DIRECTORY, videoProjectRoot, visibleVideoPath, type VideoProjectSummary } from \"./video-project.js\";\nimport { isTrustedPreviewNavigation, isTrustedWorkspaceRequest } from \"./workspace-request-trust.js\";\n\nconst STORY_DIRECTORIES = [\"\u6B63\u6587\", \"\u5927\u7EB2\", \"\u8BBE\u5B9A\", \"\u8FFD\u8E2A\", \"\u5BF9\u6807\", \"\u53C2\u8003\u8D44\u6599\"] as const;\nconst DRAMA_DIRECTORIES = [\"\u8F93\u5165\", \"\u9879\u76EE\u5F00\u53D1\", \"\u8BBE\u5B9A\u96C6\", \"\u5267\u96C6\", \"\u4EA4\u4ED8\", \"\u521B\u4F5C\u8005\u51B3\u7B56\", \"\u5BA1\u67E5\"] as const;\nconst GAME_DIRECTORY = \"game-adaptations\";\n// Preview studios need only a small manifest-driven subset, so discover them before a very large\n// prose workspace can consume the shared listing budget.\nconst CREATIVE_DIRECTORIES = [VIDEO_DIRECTORY, GAME_DIRECTORY, ...STORY_DIRECTORIES, ...DRAMA_DIRECTORIES] as const;\nconst ROOT_FILES = new Set([\"short-drama.json\"]);\nconst EDITABLE_EXTENSIONS = new Set([\".md\", \".txt\", \".json\", \".jsonl\"]);\nconst GAME_EDITABLE_EXTENSIONS = new Set([...EDITABLE_EXTENSIONS, \".html\", \".css\", \".js\", \".mjs\", \".cjs\", \".ts\", \".tsx\", \".jsx\"]);\nconst VIDEO_EDITABLE_EXTENSIONS = new Set([...EDITABLE_EXTENSIONS, \".srt\", \".ass\"]);\nconst MEDIA_TYPES: ReadonlyMap<string, string> = new Map([\n [\".png\", \"image/png\"], [\".jpg\", \"image/jpeg\"], [\".jpeg\", \"image/jpeg\"], [\".webp\", \"image/webp\"], [\".gif\", \"image/gif\"],\n [\".mp4\", \"video/mp4\"], [\".webm\", \"video/webm\"], [\".mov\", \"video/quicktime\"], [\".mkv\", \"video/x-matroska\"],\n [\".mp3\", \"audio/mpeg\"], [\".wav\", \"audio/wav\"], [\".m4a\", \"audio/mp4\"]\n]);\nconst MEDIA_MAX_BYTES = 256 * 1_024 * 1_024;\nconst FILE_LIMIT = 1_000;\nconst PREVIEW_FILE_LIMIT = 32 * 1024 * 1024;\nconst BUNDLED_GAME_EXAMPLE = \"jin-ping-mei\";\nconst workspaceVerificationTracker = new WorkspaceVerificationTracker();\nlet videoPreflightCache: { readonly expires: number; readonly value: VideoPreflightSummary } | undefined;\nlet dramaPreflightCache: { readonly expires: number; readonly value: DramaPreflightSummary } | undefined;\n\ninterface WorkspaceRouteOptions {\n readonly maxBytes: number;\n readonly trustedHosts?: readonly string[];\n}\n\n/** Host-process capability probe. The Agent's execution world may differ; `video-recap --doctor` is authoritative there. */\ninterface VideoPreflightSummary {\n readonly python: { readonly ok: boolean; readonly version?: string | undefined };\n readonly ffmpeg: { readonly ok: boolean; readonly subtitles: boolean };\n readonly ffprobe: { readonly ok: boolean };\n readonly credentials: { readonly mimo: boolean; readonly fish: boolean; readonly ttsProvider: string };\n}\n\ninterface WorkspaceFile {\n readonly path: string;\n readonly bytes: number;\n readonly version: string;\n readonly kind: \"text\" | \"media\";\n readonly mimeType?: string | undefined;\n}\n\ninterface GameVerificationSummary {\n readonly status: \"NOT_RUN\" | \"FAIL\" | \"PASS\";\n readonly checks: Readonly<Record<string, \"NOT_RUN\" | \"FAIL\" | \"PASS\">>;\n readonly runId?: string | undefined;\n readonly limitations: readonly { readonly scope: string; readonly reason: string }[];\n readonly binding: GameVerificationBinding;\n readonly verifiedPreviewVersion?: string | undefined;\n}\n\ninterface GameProjectSummary {\n readonly id: string;\n readonly root: string;\n readonly title: string;\n readonly source: \"workspace\" | \"example\";\n readonly previewReady: boolean;\n readonly previewUrl?: string | undefined;\n readonly previewVersion: string;\n readonly verification: GameVerificationSummary;\n}\n\ninterface WorkspaceRealm {\n readonly agent: Agent;\n readonly fs: FileSystem;\n readonly sandboxPolicy: SandboxPolicyService;\n readonly cwd: string;\n readonly root: FsTarget;\n}\n\ninterface ReadFileResult {\n readonly content: string;\n readonly bytes: number;\n readonly version: FsVersion;\n}\n\nclass WorkspaceHttpError extends Error {\n constructor(readonly status: number, message: string) { super(message); }\n}\n\nfunction configured(...names: readonly string[]): boolean {\n return names.some((name) => (process.env[name] ?? \"\") !== \"\");\n}\n\n/**\n * Host-process view of short-drama production: which bundled media adapters\n * have their environment set, and where the adapter config the Agent passes to\n * `production_tool.py run` lives. Values never leave the process.\n */\ninterface DramaPreflightSummary {\n readonly python: { readonly ok: boolean; readonly version?: string | undefined };\n readonly adapterConfig: { readonly path: string; readonly generated: boolean; readonly ok: boolean };\n readonly adapters: readonly DramaAdapterStatus[];\n}\n\nlet dramaPreflightInFlight: Promise<DramaPreflightSummary> | undefined;\n\nasync function dramaPreflight(): Promise<DramaPreflightSummary> {\n if (dramaPreflightCache !== undefined && dramaPreflightCache.expires > Date.now()) return dramaPreflightCache.value;\n // One probe per cache miss: concurrent requests share the write instead of\n // racing it, and the write itself is atomic (temp file + rename).\n dramaPreflightInFlight ??= (async () => {\n try {\n const python = await hostPython();\n const adapterConfig = await ensureDramaAdapterConfig(defaultDramaSkillRoot(), { python: python.command });\n const value = { python: python.probe, adapterConfig, adapters: dramaAdapterStatuses() };\n dramaPreflightCache = { expires: Date.now() + 30_000, value };\n return value;\n } finally { dramaPreflightInFlight = undefined; }\n })();\n return dramaPreflightInFlight;\n}\n\nasync function videoPreflight(): Promise<VideoPreflightSummary> {\n if (videoPreflightCache !== undefined && videoPreflightCache.expires > Date.now()) return videoPreflightCache.value;\n const python = (await hostPython()).probe;\n const [ffmpegOutput, ffmpegFilters, ffprobeOutput] = await Promise.all([\n commandOutput(\"ffmpeg\", [\"-version\"]),\n commandOutput(\"ffmpeg\", [\"-hide_banner\", \"-filters\"]),\n commandOutput(\"ffprobe\", [\"-version\"])\n ]);\n const value = {\n python,\n ffmpeg: { ok: ffmpegOutput !== undefined, subtitles: /\\bsubtitles\\b/u.test(ffmpegFilters ?? \"\") },\n ffprobe: { ok: ffprobeOutput !== undefined },\n credentials: {\n // Upstream falls back to the shared MIMO_API_KEY only when a per-service key is unset.\n mimo: configured(\"MIMO_API_KEY\", \"MIMO_VIDEO_API_KEY\", \"MIMO_TTS_API_KEY\", \"MIMO_ASR_API_KEY\"),\n fish: configured(\"FISH_API_KEY\"),\n ttsProvider: process.env.TTS_PROVIDER ?? \"mimo\"\n }\n };\n videoPreflightCache = { expires: Date.now() + 30_000, value };\n return value;\n}\n\nfunction send(response: ServerResponse, status: number, value: unknown): void {\n const body = `${JSON.stringify(value)}\\n`;\n response.writeHead(status, {\n \"content-type\": \"application/json; charset=utf-8\",\n \"content-length\": Buffer.byteLength(body),\n \"cache-control\": \"no-store\",\n \"x-content-type-options\": \"nosniff\"\n });\n response.end(body);\n}\n\nexport interface ByteRange { readonly start: number; readonly end: number }\n\n/**\n * RFC 9110 14.2: a Range this server cannot parse or does not support is ignored (`undefined`, full\n * 200 response); only a well-formed but unsatisfiable range earns a 416 (`null`).\n */\nexport function parseByteRange(value: string | undefined, size: number): ByteRange | undefined | null {\n const match = value === undefined ? null : /^bytes=(\\d*)-(\\d*)$/u.exec(value.trim());\n if (match === null) return undefined;\n const left = match[1] ?? \"\";\n const right = match[2] ?? \"\";\n if (left === \"\") {\n const suffix = Number(right);\n if (right === \"\" || !Number.isSafeInteger(suffix)) return undefined;\n return suffix === 0 || size <= 0 ? null : { start: Math.max(0, size - suffix), end: size - 1 };\n }\n const start = Number(left);\n const requestedEnd = right === \"\" ? Number.MAX_SAFE_INTEGER : Number(right);\n if (!Number.isSafeInteger(start) || !Number.isSafeInteger(requestedEnd) || requestedEnd < start) return undefined;\n return start >= size ? null : { start, end: Math.min(requestedEnd, size - 1) };\n}\n\nfunction mediaHeaders(mimeType: string, size: number, range: ByteRange | undefined): Record<string, string | number> {\n const start = range?.start ?? 0;\n const end = range?.end ?? size - 1;\n return {\n \"content-type\": mimeType,\n \"content-length\": Math.max(0, end - start + 1),\n \"cache-control\": \"private, max-age=60\",\n \"accept-ranges\": \"bytes\",\n ...(range === undefined ? {} : { \"content-range\": `bytes ${String(start)}-${String(end)}/${String(size)}` }),\n \"x-content-type-options\": \"nosniff\"\n };\n}\n\nfunction sendMediaBytes(request: IncomingMessage, response: ServerResponse, bytes: Uint8Array, mimeType: string): void {\n const range = parseByteRange(typeof request.headers.range === \"string\" ? request.headers.range : undefined, bytes.byteLength);\n if (range === null) {\n response.writeHead(416, { \"content-range\": `bytes */${String(bytes.byteLength)}`, \"cache-control\": \"no-store\" });\n response.end();\n return;\n }\n const start = range?.start ?? 0;\n const end = range?.end ?? bytes.byteLength - 1;\n const body = bytes.subarray(start, end + 1);\n response.writeHead(range === undefined ? 200 : 206, mediaHeaders(mimeType, bytes.byteLength, range));\n response.end(request.method === \"HEAD\" ? undefined : Buffer.from(body));\n}\n\n/**\n * Resolve the target to a path this web host may open directly, or `undefined` when it may not.\n * `processPath` is canonical in the backend's execution world, which is not necessarily this\n * process's, so containment is re-checked against the host-visible workspace root: a remote path\n * that happens to exist locally never becomes a stream.\n */\nasync function hostWorkspaceFile(realm: WorkspaceRealm, target: FsTarget, expectedSize: number): Promise<string | undefined> {\n const [root, path] = await Promise.all([\n nodeRealpath(realm.fs.processPath(realm.root)),\n nodeRealpath(realm.fs.processPath(target))\n ]);\n const inside = relative(root, path);\n if (inside === \"\" || inside.startsWith(\"..\") || isAbsolute(inside)) return undefined;\n const local = await nodeStat(path);\n return local.isFile() && local.size === expectedSize ? path : undefined;\n}\n\nasync function sendWorkspaceMedia(request: IncomingMessage, response: ServerResponse, realm: WorkspaceRealm, target: FsTarget, info: FsInfo, mimeType: string): Promise<void> {\n const expectedSize = info.size;\n if (expectedSize !== undefined) {\n // A remote filesystem may expose a process path this web host cannot read; fall back to its\n // bounded binary API for modest files.\n const processPath = await hostWorkspaceFile(realm, target, expectedSize).catch(() => undefined);\n if (processPath !== undefined) {\n const range = parseByteRange(typeof request.headers.range === \"string\" ? request.headers.range : undefined, expectedSize);\n if (range === null) {\n response.writeHead(416, { \"content-range\": `bytes */${String(expectedSize)}`, \"cache-control\": \"no-store\" });\n response.end();\n return;\n }\n response.writeHead(range === undefined ? 200 : 206, mediaHeaders(mimeType, expectedSize, range));\n if (request.method === \"HEAD\") { response.end(); return; }\n const stream = createReadStream(processPath, range === undefined ? undefined : { start: range.start, end: range.end });\n request.once(\"close\", () => { if (!response.writableEnded) stream.destroy(); });\n stream.on(\"error\", () => { if (!response.headersSent) response.destroy(); else response.end(); });\n stream.pipe(response);\n return;\n }\n if (expectedSize > MEDIA_MAX_BYTES) throw new WorkspaceHttpError(413, \"\u8FDC\u7A0B\u5A92\u4F53\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u56DE\u9000\u9884\u89C8\u5927\u5C0F\u9650\u5236\u3002\");\n }\n sendMediaBytes(request, response, await realm.fs.readBytes(target, undefined, MEDIA_MAX_BYTES), mimeType);\n}\n\nasync function jsonBody(request: IncomingMessage, maxBytes: number): Promise<Record<string, unknown>> {\n const chunks: Buffer[] = [];\n let size = 0;\n for await (const chunk of request as AsyncIterable<Uint8Array>) {\n const value = Buffer.from(chunk);\n size += value.byteLength;\n if (size > maxBytes) throw new WorkspaceHttpError(413, \"\u8BF7\u6C42\u5185\u5BB9\u8FC7\u5927\u3002\");\n chunks.push(value);\n }\n try {\n const value = JSON.parse(Buffer.concat(chunks).toString(\"utf8\")) as unknown;\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) throw new Error();\n return value as Record<string, unknown>;\n } catch {\n throw new WorkspaceHttpError(400, \"\u8BF7\u6C42\u5FC5\u987B\u662F JSON \u5BF9\u8C61\u3002\");\n }\n}\n\nfunction safeRelativePath(path: string): boolean {\n return path !== \"\"\n && !path.startsWith(\"/\")\n && !path.includes(\"\\\\\")\n && !path.split(\"/\").some((segment) => segment === \"\" || segment === \".\" || segment === \"..\");\n}\n\nfunction editablePath(path: string): boolean {\n const extensions = path.startsWith(`${GAME_DIRECTORY}/`) ? GAME_EDITABLE_EXTENSIONS\n : path.startsWith(`${VIDEO_DIRECTORY}/`) ? VIDEO_EDITABLE_EXTENSIONS\n : EDITABLE_EXTENSIONS;\n return extensions.has(extname(path).toLocaleLowerCase());\n}\n\nexport function assertCreativePath(path: string, kind: \"text\" | \"media\"): void {\n if (kind === \"text\" ? !editablePath(path) : !MEDIA_TYPES.has(extname(path).toLocaleLowerCase())) {\n throw new WorkspaceHttpError(415, kind === \"text\" ? \"\u5DE5\u4F5C\u53F0\u4E0D\u652F\u6301\u7F16\u8F91\u8BE5\u6587\u4EF6\u7C7B\u578B\u3002\" : \"\u76EE\u6807\u4E0D\u662F\u53D7\u652F\u6301\u7684\u77ED\u5267\u5A92\u4F53\u6587\u4EF6\u3002\");\n }\n if (!safeRelativePath(path)) {\n throw new WorkspaceHttpError(403, \"\u6587\u4EF6\u8DEF\u5F84\u4E0D\u5728\u521B\u4F5C\u5DE5\u4F5C\u53F0\u4E2D\u3002\");\n }\n const root = path.split(\"/\", 1)[0];\n if (!CREATIVE_DIRECTORIES.some((directory) => directory === root) && !ROOT_FILES.has(path)) {\n throw new WorkspaceHttpError(403, \"\u6587\u4EF6\u8DEF\u5F84\u4E0D\u5728\u521B\u4F5C\u5DE5\u4F5C\u53F0\u4E2D\u3002\");\n }\n}\n\nexport function mediaMimeTypeForPath(path: string): string | undefined {\n return MEDIA_TYPES.get(extname(path).toLocaleLowerCase());\n}\n\nasync function workspaceRealmForSession(context: Context, rawId: string): Promise<WorkspaceRealm> {\n if (rawId === \"\") throw new WorkspaceHttpError(400, \"\u7F3A\u5C11 DSH sessionId\u3002\");\n const lookup = context.typert.lookups.get(\"agent\");\n if (lookup === undefined) throw new WorkspaceHttpError(503, \"DSH Agent lookup \u5F53\u524D\u4E0D\u53EF\u7528\u3002\");\n let agent: Agent | undefined;\n try {\n agent = await lookup.resolve(SessionId(rawId)) as Agent | undefined;\n } catch {\n throw new WorkspaceHttpError(404, \"DSH \u4F1A\u8BDD\u4E0D\u53EF\u7528\u3002\");\n }\n if (agent === undefined) throw new WorkspaceHttpError(404, \"DSH \u4F1A\u8BDD\u4E0D\u53EF\u7528\u3002\");\n if (agent.session.header.parentSession !== undefined || agent.session.header.origin === \"subagent\") {\n throw new WorkspaceHttpError(403, \"\u5B50 Agent \u4F1A\u8BDD\u4E0D\u5F00\u653E\u521B\u4F5C\u7F16\u8F91\u5668\u3002\");\n }\n const cwd = agent.session.header.cwd;\n if (cwd === undefined) throw new WorkspaceHttpError(409, \"\u5F53\u524D DSH \u4F1A\u8BDD\u6CA1\u6709\u5DE5\u4F5C\u76EE\u5F55\u3002\");\n const fs = agent.ctx.get(\"fs\");\n const sandboxPolicy = agent.ctx.get(\"sandboxPolicy\");\n if (fs === undefined || sandboxPolicy === undefined) throw new WorkspaceHttpError(503, \"DSH \u6587\u4EF6\u7CFB\u7EDF\u5F53\u524D\u4E0D\u53EF\u7528\u3002\");\n return { agent, fs, sandboxPolicy, cwd, root: await fs.resolve(cwd) };\n}\n\nasync function workspaceRealm(context: Context, url: URL): Promise<WorkspaceRealm> {\n const rawId = url.searchParams.get(\"sessionId\");\n if (rawId === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11 DSH sessionId\u3002\");\n return workspaceRealmForSession(context, rawId);\n}\n\nasync function creativeTarget(realm: WorkspaceRealm, path: string, kind: \"text\" | \"media\" = \"text\"): Promise<FsTarget> {\n assertCreativePath(path, kind);\n const target = await realm.fs.resolve(path, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, target)) throw new WorkspaceHttpError(403, \"\u6587\u4EF6\u8DEF\u5F84\u79BB\u5F00\u4E86 DSH \u5DE5\u4F5C\u76EE\u5F55\u3002\");\n return target;\n}\n\nfunction requireRegularFile(info: FsInfo | undefined): FsInfo {\n if (info === undefined) throw new WorkspaceHttpError(404, \"\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\");\n if (info.type !== \"file\") throw new WorkspaceHttpError(415, \"\u76EE\u6807\u4E0D\u662F\u53EF\u7F16\u8F91\u7684\u666E\u901A\u6587\u4EF6\u3002\");\n return info;\n}\n\n/** Read bytes and a matching opaque version, retrying if a writer wins the read window. */\nasync function readVersionedFile(fs: FileSystem, target: FsTarget, maxBytes: number): Promise<ReadFileResult> {\n for (let attempt = 0; attempt < 3; attempt += 1) {\n const before = requireRegularFile(await fs.stat(target));\n if (before.size !== undefined && before.size > maxBytes) throw new WorkspaceHttpError(413, \"\u6587\u4EF6\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u5927\u5C0F\u9650\u5236\u3002\");\n const bytes = await fs.readBytes(target, undefined, maxBytes);\n const after = requireRegularFile(await fs.stat(target));\n if (before.version !== after.version) continue;\n let content: string;\n try {\n content = new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n } catch {\n throw new WorkspaceHttpError(415, \"\u6587\u4EF6\u4E0D\u662F\u6709\u6548\u7684 UTF-8 \u6587\u672C\u3002\");\n }\n return { content, bytes: bytes.byteLength, version: after.version };\n }\n throw new WorkspaceHttpError(409, \"\u6587\u4EF6\u6B63\u5728\u88AB\u4FEE\u6539\uFF0C\u8BF7\u91CD\u8BD5\u3002\");\n}\n\nasync function listFiles(realm: WorkspaceRealm): Promise<WorkspaceFile[]> {\n const files: WorkspaceFile[] = [];\n const walk = async (path: string, directory: FsTarget): Promise<void> => {\n for (const entry of await realm.fs.listDir(directory)) {\n if (entry.name.startsWith(\".\") || !realm.fs.contains(realm.root, entry.target)) continue;\n const childPath = `${path}/${entry.name}`;\n if (entry.type === \"directory\") {\n if (!skipVideoDirectory(childPath)) await walk(childPath, entry.target);\n }\n else if (entry.type === \"file\" && (editablePath(childPath) || MEDIA_TYPES.has(extname(entry.name).toLocaleLowerCase()))) {\n const info = entry.version === undefined || entry.size === undefined ? await realm.fs.stat(entry.target) : undefined;\n const version = entry.version ?? info?.version;\n const mimeType = MEDIA_TYPES.get(extname(entry.name).toLocaleLowerCase());\n if (version !== undefined && (!childPath.startsWith(`${VIDEO_DIRECTORY}/`) || visibleVideoPath(childPath))) {\n files.push({ path: childPath, bytes: entry.size ?? info?.size ?? 0, version, kind: mimeType === undefined ? \"text\" : \"media\", mimeType });\n }\n }\n if (files.length >= FILE_LIMIT) return;\n }\n };\n for (const directory of CREATIVE_DIRECTORIES) {\n const target = await realm.fs.resolve(directory, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, target)) continue;\n const info = await realm.fs.stat(target);\n if (info?.type === \"directory\") await walk(directory, target);\n if (files.length >= FILE_LIMIT) break;\n }\n for (const path of ROOT_FILES) {\n const target = await creativeTarget(realm, path);\n const info = await realm.fs.stat(target);\n if (info?.type === \"file\") files.push({ path, bytes: info.size ?? 0, version: info.version, kind: \"text\" });\n }\n return files.sort((left, right) => left.path.localeCompare(right.path, \"zh-Hans-CN\"));\n}\n\nasync function metadata(realm: WorkspaceRealm, files: readonly WorkspaceFile[], path: string, maxBytes: number): Promise<{ readonly value: unknown; readonly error?: string }> {\n if (!files.some((file) => file.path === path)) return { value: null };\n try {\n const target = await creativeTarget(realm, path);\n return { value: JSON.parse((await readVersionedFile(realm.fs, target, maxBytes)).content) as unknown };\n } catch (error) {\n return { value: null, error: error instanceof SyntaxError ? `${path} \u4E0D\u662F\u6709\u6548\u7684 JSON\u3002` : `${path} \u6682\u65F6\u65E0\u6CD5\u8BFB\u53D6\u3002` };\n }\n}\n\nfunction token(value: string): string {\n return Buffer.from(value, \"utf8\").toString(\"base64url\");\n}\n\nfunction untoken(value: string): string {\n try { return Buffer.from(value, \"base64url\").toString(\"utf8\"); }\n catch { throw new WorkspaceHttpError(400, \"\u6E38\u620F\u9884\u89C8\u6807\u8BC6\u65E0\u6548\u3002\"); }\n}\n\nexport function gameRoot(path: string): boolean {\n // Reject only what is actually unsafe; fs.resolve + fs.contains remain the real boundary.\n // A stricter slug allowlist silently hid legitimate project names (spaces, \u00B7, leading _, NFD).\n const parts = path.split(\"/\");\n const name = parts[1];\n return parts.length === 2 && parts[0] === GAME_DIRECTORY && name !== undefined\n && name !== \"\" && name !== \".\" && name !== \"..\" && name.length <= 128\n && !name.startsWith(\".\") && !name.includes(\"\\\\\");\n}\n\nfunction normalizedVerification(\n value: unknown,\n binding: GameVerificationBinding,\n verifiedPreviewVersion?: string\n): GameVerificationSummary {\n if (typeof value !== \"object\" || value === null || Array.isArray(value)) {\n return { status: \"NOT_RUN\", checks: {}, limitations: [], binding };\n }\n const record = value as Record<string, unknown>;\n const status = record.status === \"PASS\" || record.status === \"FAIL\" ? record.status : \"NOT_RUN\";\n const rawChecks = typeof record.checks === \"object\" && record.checks !== null && !Array.isArray(record.checks)\n ? record.checks as Record<string, unknown>\n : {};\n const checks: Record<string, \"NOT_RUN\" | \"FAIL\" | \"PASS\"> = {};\n for (const name of [\"launch\", \"render\", \"input\", \"coreLoop\", \"outcome\", \"restart\"]) {\n const check = rawChecks[name];\n checks[name] = check === \"PASS\" || check === \"FAIL\" ? check : \"NOT_RUN\";\n }\n const completeRun = typeof record.completeRun === \"object\" && record.completeRun !== null && !Array.isArray(record.completeRun)\n ? record.completeRun as Record<string, unknown>\n : {};\n const limitations = Array.isArray(record.limitations) ? record.limitations.flatMap((entry) => {\n if (typeof entry !== \"object\" || entry === null || Array.isArray(entry)) return [];\n const item = entry as Record<string, unknown>;\n return typeof item.scope === \"string\" && typeof item.reason === \"string\"\n ? [{ scope: item.scope, reason: item.reason }]\n : [];\n }) : [];\n return {\n status,\n checks,\n runId: typeof completeRun.id === \"string\" ? completeRun.id : undefined,\n limitations,\n binding,\n verifiedPreviewVersion\n };\n}\n\nasync function workspaceText(realm: WorkspaceRealm, path: string, maxBytes: number): Promise<string | undefined> {\n const target = await realm.fs.resolve(path, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, target) || (await realm.fs.stat(target))?.type !== \"file\") return undefined;\n return (await readVersionedFile(realm.fs, target, maxBytes)).content;\n}\n\nasync function previewDigest(realm: WorkspaceRealm, projectRoot: string): Promise<{ readonly ready: boolean; readonly version: string }> {\n const appPath = `${projectRoot}/build/app`;\n const app = await realm.fs.resolve(appPath, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, app) || (await realm.fs.stat(app))?.type !== \"directory\") return { ready: false, version: \"missing\" };\n const entries: string[] = [];\n let ready = false;\n const visit = async (directory: FsTarget, path: string): Promise<void> => {\n for (const entry of await realm.fs.listDir(directory)) {\n if (entry.name.startsWith(\".\") || !realm.fs.contains(app, entry.target)) continue;\n const childPath = path === \"\" ? entry.name : `${path}/${entry.name}`;\n if (entry.type === \"directory\") await visit(entry.target, childPath);\n else if (entry.type === \"file\") {\n const info = entry.version === undefined ? await realm.fs.stat(entry.target) : undefined;\n const version = entry.version ?? info?.version;\n if (version !== undefined) entries.push(`${childPath}\\0${version}`);\n if (childPath === \"index.html\") ready = true;\n }\n if (entries.length >= 5_000) return;\n }\n };\n await visit(app, \"\");\n return { ready, version: createHash(\"sha256\").update(entries.sort().join(\"\\n\")).digest(\"hex\").slice(0, 16) };\n}\n\nfunction headingTitle(content: string | undefined, fallback: string): string {\n const heading = content?.split(/\\r?\\n/u).find((line) => /^#\\s+/u.test(line));\n return heading?.replace(/^#\\s+/u, \"\").replace(/^PRODUCT_BRIEF\\s*[\u00B7\u30FB:]?\\s*/iu, \"\").trim() || fallback;\n}\n\nasync function workspaceGameProjects(\n realm: WorkspaceRealm,\n files: readonly WorkspaceFile[],\n sessionId: string,\n maxBytes: number\n): Promise<GameProjectSummary[]> {\n const roots = [...new Set(files.flatMap((file) => {\n const parts = file.path.split(\"/\");\n return parts[0] === GAME_DIRECTORY && parts[1] !== undefined ? [`${GAME_DIRECTORY}/${parts[1]}`] : [];\n }))].filter(gameRoot).sort();\n return Promise.all(roots.map(async (root) => {\n const id = root.slice(`${GAME_DIRECTORY}/`.length);\n const qaPath = `${root}/qa/verification.json`;\n const qaFile = files.find((file) => file.path === qaPath);\n // Isolate per-project metadata failures: an unreadable brief, a non-UTF-8 or oversized\n // verification file, or a build/app subtree removed mid-rebuild must degrade this one card,\n // never abort the shared workspace listing (which also carries the story and drama trees).\n const [brief, qa, preview] = await Promise.all([\n workspaceText(realm, `${root}/PRODUCT_BRIEF.md`, maxBytes).catch(() => undefined),\n workspaceText(realm, qaPath, maxBytes).catch(() => undefined),\n previewDigest(realm, root).catch(() => ({ ready: false, version: \"unavailable\" }))\n ]);\n let verification: unknown;\n try { verification = qa === undefined ? undefined : JSON.parse(qa) as unknown; }\n catch { verification = undefined; }\n const freshness = workspaceVerificationTracker.observe(`${sessionId}\\0${root}`, qaFile?.version, preview.version);\n return {\n id: `workspace:${id}`,\n root,\n title: headingTitle(brief, id),\n source: \"workspace\" as const,\n previewReady: preview.ready,\n previewUrl: preview.ready\n ? `/oh-story/game-preview/workspace/${token(sessionId)}/${token(root)}/index.html`\n : undefined,\n previewVersion: preview.version,\n verification: normalizedVerification(verification, freshness.binding, freshness.verifiedPreviewVersion)\n };\n }));\n}\n\nasync function workspaceVideoProjects(realm: WorkspaceRealm, files: readonly WorkspaceFile[], maxBytes: number): Promise<VideoProjectSummary[]> {\n const roots = [...new Set(files.flatMap((file) => {\n const root = videoProjectRoot(file.path);\n return root === undefined ? [] : [root];\n }))].sort((left, right) => left.localeCompare(right, \"zh-Hans-CN\"));\n return Promise.all(roots.map(async (root) => {\n const findPath = (name: string): string | undefined => files.find((file) => file.path.startsWith(`${root}/`) && file.path.split(\"/\").at(-1) === name)?.path;\n const readJson = async (name: string): Promise<unknown> => {\n const path = findPath(name);\n if (path === undefined) return undefined;\n const content = await workspaceText(realm, path, maxBytes).catch(() => undefined);\n if (content === undefined) return undefined;\n try { return JSON.parse(content) as unknown; }\n catch { return undefined; }\n };\n const [project, runManifest, assembly] = await Promise.all([\n readJson(\"project.json\"),\n readJson(\"recap_run_manifest.json\"),\n readJson(\"assembly_manifest.json\")\n ]);\n return summarizeVideoProject(root, files, { project, runManifest, assembly });\n }));\n}\n\nfunction bundledExampleRoot(): string {\n return resolve(defaultNovelToGameSkillRoot(), `../examples/${BUNDLED_GAME_EXAMPLE}`);\n}\n\nasync function bundledGameExample(): Promise<GameProjectSummary> {\n const root = bundledExampleRoot();\n const [example, verification, manifest] = await Promise.all([\n readNodeFile(resolve(root, \"example.json\"), \"utf8\"),\n readNodeFile(resolve(root, \"qa/verification.json\"), \"utf8\"),\n readNodeFile(resolve(defaultNovelToGameSkillRoot(), \"../manifest.json\"), \"utf8\")\n ]);\n const exampleJson = JSON.parse(example) as { readonly title?: unknown };\n const manifestJson = JSON.parse(manifest) as { readonly upstream?: { readonly commit?: unknown } };\n const previewVersion = typeof manifestJson.upstream?.commit === \"string\" ? manifestJson.upstream.commit.slice(0, 16) : \"bundled\";\n return {\n id: `example:${BUNDLED_GAME_EXAMPLE}`,\n root: `examples/${BUNDLED_GAME_EXAMPLE}`,\n title: typeof exampleJson.title === \"string\" ? exampleJson.title : \"\u91D1\u74F6\u6885 \u00B7 \u98CE\u6708\u603B\u8D26\",\n source: \"example\",\n previewReady: true,\n previewUrl: `/oh-story/game-preview/example/${BUNDLED_GAME_EXAMPLE}/index.html`,\n previewVersion,\n verification: normalizedVerification(JSON.parse(verification) as unknown, \"PINNED\", previewVersion)\n };\n}\n\nfunction previewContentType(path: string): string {\n switch (extname(path).toLocaleLowerCase()) {\n case \".html\": return \"text/html; charset=utf-8\";\n case \".css\": return \"text/css; charset=utf-8\";\n case \".js\":\n case \".mjs\": return \"text/javascript; charset=utf-8\";\n case \".json\": return \"application/json; charset=utf-8\";\n case \".svg\": return \"image/svg+xml\";\n case \".png\": return \"image/png\";\n case \".jpg\":\n case \".jpeg\": return \"image/jpeg\";\n case \".webp\": return \"image/webp\";\n case \".gif\": return \"image/gif\";\n case \".woff\": return \"font/woff\";\n case \".woff2\": return \"font/woff2\";\n case \".wasm\": return \"application/wasm\";\n case \".mp3\": return \"audio/mpeg\";\n case \".ogg\": return \"audio/ogg\";\n default: return \"application/octet-stream\";\n }\n}\n\nfunction previewAssetSources(request: IncomingMessage): string {\n const authority = request.headers.host;\n if (authority === undefined) return \"'none'\";\n const prefix = `${authority}/oh-story/game-preview/`;\n return `http://${prefix} https://${prefix}`;\n}\n\n/**\n * Emitted for EVERY preview response, not just HTML. previewContentType serves .svg as\n * image/svg+xml \u2014 an active document type \u2014 so a game that self-navigates its frame to a scripted\n * SVG would otherwise land in a document with no policy at all, while the iframe sandbox flags\n * (which do persist across that navigation) still grant it script execution. The `sandbox`\n * directive makes each response self-confining regardless of the iframe attribute.\n */\nexport function previewContentSecurityPolicy(assets: string): string {\n return [\n \"sandbox allow-scripts allow-forms allow-modals allow-downloads allow-same-origin\",\n \"default-src 'none'\",\n `script-src 'unsafe-inline' 'wasm-unsafe-eval' blob: ${assets}`,\n `style-src 'unsafe-inline' ${assets}`,\n `img-src data: blob: ${assets}`,\n `media-src data: blob: ${assets}`,\n `font-src data: ${assets}`,\n `connect-src ${assets}`,\n `worker-src blob: ${assets}`,\n `manifest-src ${assets}`,\n \"object-src 'none'\",\n \"base-uri 'none'\",\n \"form-action 'none'\",\n \"frame-ancestors 'self' http://127.0.0.1:* http://localhost:*\"\n ].join(\"; \");\n}\n\nfunction sendPreview(request: IncomingMessage, response: ServerResponse, path: string, bytes: Uint8Array): void {\n const assets = previewAssetSources(request);\n response.writeHead(200, {\n \"content-type\": previewContentType(path),\n \"content-length\": bytes.byteLength,\n \"cache-control\": \"no-store\",\n \"x-content-type-options\": \"nosniff\",\n \"cross-origin-resource-policy\": \"cross-origin\",\n \"access-control-allow-origin\": \"*\",\n \"content-security-policy\": previewContentSecurityPolicy(assets),\n });\n response.end(bytes);\n}\n\nasync function previewBytes(context: Context, pathname: string): Promise<{ readonly path: string; readonly bytes: Uint8Array }> {\n let segments: string[];\n try {\n segments = pathname.split(\"/\").slice(3).map((segment) => decodeURIComponent(segment));\n } catch {\n throw new WorkspaceHttpError(400, \"\u6E38\u620F\u9884\u89C8\u5730\u5740\u65E0\u6548\u3002\");\n }\n const kind = segments.shift();\n if (kind === \"example\") {\n const id = segments.shift();\n const path = segments.join(\"/\") || \"index.html\";\n if (id !== BUNDLED_GAME_EXAMPLE || !safeRelativePath(path)) throw new WorkspaceHttpError(404, \"\u6E38\u620F\u793A\u4F8B\u4E0D\u5B58\u5728\u3002\");\n const appRoot = resolve(bundledExampleRoot(), \"build/app\");\n const target = resolve(appRoot, path);\n const escaped = relative(appRoot, target);\n if (escaped.startsWith(\"..\") || isAbsolute(escaped)) throw new WorkspaceHttpError(403, \"\u9884\u89C8\u8D44\u6E90\u79BB\u5F00\u4E86\u6E38\u620F\u76EE\u5F55\u3002\");\n const info = await nodeStat(target).catch(() => undefined);\n if (!info?.isFile()) throw new WorkspaceHttpError(404, \"\u9884\u89C8\u8D44\u6E90\u4E0D\u5B58\u5728\u3002\");\n if (info.size > PREVIEW_FILE_LIMIT) throw new WorkspaceHttpError(413, \"\u9884\u89C8\u8D44\u6E90\u8FC7\u5927\u3002\");\n return { path, bytes: await readNodeFile(target) };\n }\n if (kind === \"workspace\") {\n const session = segments.shift();\n const project = segments.shift();\n const path = segments.join(\"/\") || \"index.html\";\n if (session === undefined || project === undefined || !safeRelativePath(path)) throw new WorkspaceHttpError(400, \"\u6E38\u620F\u9884\u89C8\u5730\u5740\u65E0\u6548\u3002\");\n const realm = await workspaceRealmForSession(context, untoken(session));\n const root = untoken(project);\n if (!gameRoot(root)) throw new WorkspaceHttpError(403, \"\u6E38\u620F\u9879\u76EE\u8DEF\u5F84\u65E0\u6548\u3002\");\n const appRoot = await realm.fs.resolve(`${root}/build/app`, { cwd: realm.cwd });\n const target = await realm.fs.resolve(`${root}/build/app/${path}`, { cwd: realm.cwd });\n if (!realm.fs.contains(realm.root, appRoot) || !realm.fs.contains(appRoot, target)) {\n throw new WorkspaceHttpError(403, \"\u9884\u89C8\u8D44\u6E90\u79BB\u5F00\u4E86\u6E38\u620F\u76EE\u5F55\u3002\");\n }\n const info = requireRegularFile(await realm.fs.stat(target));\n if (info.size !== undefined && info.size > PREVIEW_FILE_LIMIT) throw new WorkspaceHttpError(413, \"\u9884\u89C8\u8D44\u6E90\u8FC7\u5927\u3002\");\n return { path, bytes: await realm.fs.readBytes(target, undefined, PREVIEW_FILE_LIMIT) };\n }\n throw new WorkspaceHttpError(404, \"\u6E38\u620F\u9884\u89C8\u4E0D\u5B58\u5728\u3002\");\n}\n\nfunction mapFsError(error: unknown): WorkspaceHttpError | undefined {\n if (!(error instanceof FsError)) return undefined;\n switch (error.code) {\n case \"FS_NOT_FOUND\": return new WorkspaceHttpError(404, \"\u6587\u4EF6\u4E0D\u5B58\u5728\u3002\");\n case \"FS_TOO_LARGE\": return new WorkspaceHttpError(413, \"\u6587\u4EF6\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u5927\u5C0F\u9650\u5236\u3002\");\n case \"FS_NOT_TEXT\":\n case \"FS_NOT_REGULAR_FILE\": return new WorkspaceHttpError(415, \"\u76EE\u6807\u4E0D\u662F\u53EF\u7F16\u8F91\u7684\u6587\u672C\u6587\u4EF6\u3002\");\n case \"FS_PERMISSION_DENIED\":\n case \"FS_SANDBOX_DENIED\": return new WorkspaceHttpError(403, \"\u5F53\u524D DSH \u6743\u9650\u4E0D\u5141\u8BB8\u4FEE\u6539\u8BE5\u6587\u4EF6\u3002\");\n case \"FS_STALE_VERSION\":\n case \"FS_NOT_OBSERVED\": return new WorkspaceHttpError(412, \"\u6587\u4EF6\u5DF2\u5728\u78C1\u76D8\u4E0A\u66F4\u65B0\u3002\u8BF7\u5904\u7406\u51B2\u7A81\u540E\u518D\u4FDD\u5B58\u3002\");\n case \"FS_ABORTED\": return new WorkspaceHttpError(409, \"\u6587\u4EF6\u64CD\u4F5C\u5DF2\u53D6\u6D88\u3002\");\n default: return new WorkspaceHttpError(500, \"DSH \u6587\u4EF6\u7CFB\u7EDF\u64CD\u4F5C\u5931\u8D25\u3002\");\n }\n}\n\nasync function handle(context: Context, request: IncomingMessage, response: ServerResponse, options: WorkspaceRouteOptions): Promise<void> {\n try {\n const url = new URL(request.url ?? \"/\", \"http://127.0.0.1\");\n const gamePreview = url.pathname.startsWith(\"/oh-story/game-preview/\");\n const trusted = gamePreview\n ? isTrustedPreviewNavigation(request, options.trustedHosts ?? [])\n : isTrustedWorkspaceRequest(request, options.trustedHosts ?? []);\n if (!trusted) throw new WorkspaceHttpError(403, \"\u8BF7\u6C42\u6765\u6E90\u4E0D\u53D7\u4FE1\u4EFB\u3002\");\n if (gamePreview && request.method === \"GET\") {\n const preview = await previewBytes(context, url.pathname);\n sendPreview(request, response, preview.path, preview.bytes);\n return;\n }\n if (url.pathname === \"/oh-story/workspace\" && request.method === \"GET\") {\n const realm = await workspaceRealm(context, url);\n const files = await listFiles(realm);\n const tracking = await metadata(realm, files, \"\u8FFD\u8E2A/_tracking-state.json\", options.maxBytes);\n const shortDrama = await metadata(realm, files, \"short-drama.json\", options.maxBytes);\n const metadataErrors = [tracking.error, shortDrama.error].filter((value): value is string => value !== undefined);\n const sessionId = url.searchParams.get(\"sessionId\");\n if (sessionId === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11 DSH sessionId\u3002\");\n const games = [\n ...await workspaceGameProjects(realm, files, sessionId, options.maxBytes),\n await bundledGameExample()\n ];\n const videos = await workspaceVideoProjects(realm, files, options.maxBytes);\n send(response, 200, { cwd: realm.cwd, files, games, videos, tracking: tracking.value, shortDrama: shortDrama.value, metadataErrors, mode: \"dsh-session\" });\n return;\n }\n if (url.pathname === \"/oh-story/video-preflight\" && request.method === \"GET\") {\n send(response, 200, await videoPreflight());\n return;\n }\n if (url.pathname === \"/oh-story/drama-preflight\" && request.method === \"GET\") {\n send(response, 200, await dramaPreflight());\n return;\n }\n if (url.pathname === \"/oh-story/file\" && request.method === \"GET\") {\n const realm = await workspaceRealm(context, url);\n const path = url.searchParams.get(\"path\");\n if (path === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11\u6587\u4EF6\u8DEF\u5F84\u3002\");\n const file = await readVersionedFile(realm.fs, await creativeTarget(realm, path), options.maxBytes);\n send(response, 200, { path, ...file });\n return;\n }\n if (url.pathname === \"/oh-story/media\" && (request.method === \"GET\" || request.method === \"HEAD\")) {\n const realm = await workspaceRealm(context, url);\n const path = url.searchParams.get(\"path\");\n if (path === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11\u5A92\u4F53\u6587\u4EF6\u8DEF\u5F84\u3002\");\n const mimeType = mediaMimeTypeForPath(path);\n if (mimeType === undefined) throw new WorkspaceHttpError(415, \"\u76EE\u6807\u4E0D\u662F\u53D7\u652F\u6301\u7684\u77ED\u5267\u5A92\u4F53\u6587\u4EF6\u3002\");\n const target = await creativeTarget(realm, path, \"media\");\n const info = requireRegularFile(await realm.fs.stat(target));\n await sendWorkspaceMedia(request, response, realm, target, info, mimeType);\n return;\n }\n if (url.pathname === \"/oh-story/file\" && request.method === \"PUT\") {\n const realm = await workspaceRealm(context, url);\n const path = url.searchParams.get(\"path\");\n if (path === null) throw new WorkspaceHttpError(400, \"\u7F3A\u5C11\u6587\u4EF6\u8DEF\u5F84\u3002\");\n const input = await jsonBody(request, options.maxBytes * 6 + 1_024);\n if (typeof input.content !== \"string\") throw new WorkspaceHttpError(400, \"content \u5FC5\u987B\u662F\u5B57\u7B26\u4E32\u3002\");\n if (typeof input.baseVersion !== \"string\" || input.baseVersion === \"\") throw new WorkspaceHttpError(400, \"baseVersion \u5FC5\u987B\u662F\u6709\u6548\u7248\u672C\u3002\");\n if (Buffer.byteLength(input.content) > options.maxBytes) throw new WorkspaceHttpError(413, \"\u6587\u4EF6\u8D85\u8FC7\u5DE5\u4F5C\u53F0\u5927\u5C0F\u9650\u5236\u3002\");\n const outcome = await realm.fs.writeText(\n await creativeTarget(realm, path),\n input.content,\n { kind: \"replaceIfVersion\", version: input.baseVersion as FsVersion },\n undefined,\n realm.sandboxPolicy.resolve({ session: realm.agent.session })\n );\n send(response, 200, { path, content: outcome.after, bytes: Buffer.byteLength(outcome.after), version: outcome.version });\n return;\n }\n send(response, 404, { error: \"Oh Story route not found.\" });\n } catch (error) {\n const mapped = error instanceof WorkspaceHttpError ? error : mapFsError(error);\n if (mapped === undefined) context.logger(\"oh-story\").error(\"workspace route failed\", error);\n send(response, mapped?.status ?? 500, { error: mapped?.message ?? \"Oh Story workspace operation failed.\" });\n }\n}\n\n/** Mount the narrow editor API on DSH's official web-server extension seam. */\nexport function registerWorkspaceRoute(context: Context, options: WorkspaceRouteOptions): void {\n context.effect(() => context.webServer.register({\n kind: \"prefix\",\n path: \"/oh-story\",\n handler: (request, response) => handle(context, request, response, options)\n }), \"oh-story: DSH-session workspace API\");\n}\n", "export type GameVerificationBinding = \"CURRENT\" | \"PINNED\" | \"STALE\" | \"UNBOUND\";\n\nexport interface GameVerificationFreshness {\n readonly binding: Exclude<GameVerificationBinding, \"PINNED\">;\n readonly verifiedPreviewVersion?: string | undefined;\n}\n\ninterface Observation {\n readonly verificationRevision: string | undefined;\n readonly previewVersion: string;\n readonly bound: boolean;\n}\n\n/**\n * The upstream QA schema intentionally contains no build digest. Track what\n * this DSH process actually observes instead of pretending an imported PASS\n * belongs to the current build. A QA rewrite binds that run to the preview\n * visible at the same observation; later preview changes make it stale.\n */\nexport class WorkspaceVerificationTracker {\n readonly #observations = new Map<string, Observation>();\n\n observe(key: string, verificationRevision: string | undefined, previewVersion: string): GameVerificationFreshness {\n const previous = this.#observations.get(key);\n if (previous === undefined) {\n this.#remember(key, { verificationRevision, previewVersion, bound: false });\n return { binding: \"UNBOUND\" };\n }\n if (verificationRevision !== previous.verificationRevision) {\n const bound = verificationRevision !== undefined;\n this.#remember(key, { verificationRevision, previewVersion, bound });\n return bound ? { binding: \"CURRENT\", verifiedPreviewVersion: previewVersion } : { binding: \"UNBOUND\" };\n }\n if (!previous.bound) return { binding: \"UNBOUND\" };\n return previewVersion === previous.previewVersion\n ? { binding: \"CURRENT\", verifiedPreviewVersion: previous.previewVersion }\n : { binding: \"STALE\", verifiedPreviewVersion: previous.previewVersion };\n }\n\n #remember(key: string, observation: Observation): void {\n this.#observations.set(key, observation);\n if (this.#observations.size <= 500) return;\n const oldest = this.#observations.keys().next();\n if (!oldest.done) this.#observations.delete(oldest.value);\n }\n}\n", "import { basename, extname } from \"node:path\";\n\nexport const VIDEO_DIRECTORY = \"video-recaps\";\n\nexport interface VideoWorkspaceFile {\n readonly path: string;\n readonly bytes: number;\n readonly version: string;\n readonly kind: \"text\" | \"media\";\n readonly mimeType?: string | undefined;\n}\n\nexport interface VideoPreviewAsset {\n readonly role: \"source\" | \"edited\" | \"final\";\n readonly label: string;\n readonly path: string;\n readonly bytes: number;\n readonly version: string;\n readonly mimeType: string;\n}\n\nexport interface VideoArtifactSummary {\n readonly label: string;\n readonly path: string;\n readonly version: string;\n readonly kind: \"plan\" | \"script\" | \"subtitle\" | \"quality\" | \"manifest\";\n}\n\nexport interface VideoProjectSummary {\n readonly id: string;\n readonly root: string;\n readonly title: string;\n readonly state: \"not-started\" | \"working\" | \"waiting\" | \"ready\";\n readonly stage: string;\n readonly stageLabel: string;\n readonly nextArtifact?: string | undefined;\n readonly previews: readonly VideoPreviewAsset[];\n readonly artifacts: readonly VideoArtifactSummary[];\n}\n\nconst VIDEO_EXTENSIONS = new Set([\".mp4\", \".mov\", \".mkv\", \".webm\"]);\nconst SKIPPED_DIRECTORIES = new Set([\"frames\", \"tts_segments\", \"asr_chunks\", \"chunks\", \"cache\", \"tmp\", \".subtitle_measure\"]);\nconst VISIBLE_TEXT_FILES = new Set([\n \"project.json\",\n \"recap_run_manifest.json\",\n \"recap_phase.json\",\n \"agent_narration_brief.md\",\n \"recap_story_plan.json\",\n \"visual_audio_board.json\",\n \"clip_plan.json\",\n \"clip_plan_validated.json\",\n \"narration.json\",\n \"narration_review.md\",\n \"tts_meta.json\",\n \"timeline.json\",\n \"assembly_manifest.json\",\n \"assembly_qc.json\",\n \"final_qc.json\",\n \"final_qc.md\",\n \"delivery_qc.json\",\n \"subtitles.srt\",\n \"subtitles.ass\"\n]);\n\nconst ARTIFACT_META: Readonly<Record<string, { readonly label: string; readonly kind: VideoArtifactSummary[\"kind\"] }>> = {\n \"recap_run_manifest.json\": { label: \"\u8FD0\u884C\u6E05\u5355\", kind: \"manifest\" },\n \"recap_phase.json\": { label: \"\u9636\u6BB5\u8D26\u672C\", kind: \"manifest\" },\n \"agent_narration_brief.md\": { label: \"\u89E3\u8BF4 Brief\", kind: \"plan\" },\n \"recap_story_plan.json\": { label: \"\u6545\u4E8B\u65B9\u6848\", kind: \"plan\" },\n \"visual_audio_board.json\": { label: \"\u97F3\u753B\u65B9\u6848\", kind: \"plan\" },\n \"clip_plan.json\": { label: \"\u526A\u8F91\u8BA1\u5212\", kind: \"plan\" },\n \"clip_plan_validated.json\": { label: \"\u5DF2\u6821\u9A8C\u526A\u8F91\u8BA1\u5212\", kind: \"plan\" },\n \"narration.json\": { label: \"\u89E3\u8BF4\u8BCD\", kind: \"script\" },\n \"narration_review.md\": { label: \"\u89E3\u8BF4\u590D\u6838\", kind: \"quality\" },\n \"timeline.json\": { label: \"\u6210\u7247\u65F6\u95F4\u7EBF\", kind: \"plan\" },\n \"assembly_manifest.json\": { label: \"\u5408\u6210\u6E05\u5355\", kind: \"manifest\" },\n \"assembly_qc.json\": { label: \"\u5408\u6210\u8D28\u68C0\", kind: \"quality\" },\n \"final_qc.json\": { label: \"\u6700\u7EC8\u8D28\u68C0\", kind: \"quality\" },\n \"final_qc.md\": { label: \"\u6700\u7EC8\u8D28\u68C0\u62A5\u544A\", kind: \"quality\" },\n \"delivery_qc.json\": { label: \"\u4EA4\u4ED8\u8D28\u68C0\", kind: \"quality\" },\n \"subtitles.srt\": { label: \"SRT \u5B57\u5E55\", kind: \"subtitle\" },\n \"subtitles.ass\": { label: \"ASS \u5B57\u5E55\", kind: \"subtitle\" }\n};\n\nexport function videoProjectRoot(path: string): string | undefined {\n const parts = path.split(\"/\");\n const name = parts[1];\n if (parts[0] !== VIDEO_DIRECTORY || name === undefined || name === \"\" || name === \".\" || name === \"..\" || name.startsWith(\".\") || name.includes(\"\\\\\") || name.length > 128) return undefined;\n return `${VIDEO_DIRECTORY}/${name}`;\n}\n\nexport function skipVideoDirectory(path: string): boolean {\n const parts = path.split(\"/\");\n return parts[0] === VIDEO_DIRECTORY && parts.length >= 3 && SKIPPED_DIRECTORIES.has(parts.at(-1) ?? \"\");\n}\n\nexport function visibleVideoPath(path: string): boolean {\n const root = videoProjectRoot(path);\n if (root === undefined || path === root) return false;\n const name = basename(path);\n const extension = extname(name).toLocaleLowerCase();\n if (VISIBLE_TEXT_FILES.has(name)) return true;\n if (!VIDEO_EXTENSIONS.has(extension)) return false;\n return path.startsWith(`${root}/sources/`)\n || path.startsWith(`${root}/outputs/`)\n || name === \"edited_source.mp4\"\n || /^recap_.+\\.(?:mp4|mov|webm)$/iu.test(name);\n}\n\nfunction record(value: unknown): Record<string, unknown> | undefined {\n return typeof value === \"object\" && value !== null && !Array.isArray(value) ? value as Record<string, unknown> : undefined;\n}\n\nfunction text(value: unknown): string | undefined {\n return typeof value === \"string\" && value.trim() !== \"\" ? value.trim() : undefined;\n}\n\nfunction referencedMedia(files: readonly VideoWorkspaceFile[], value: unknown): VideoWorkspaceFile | undefined {\n const path = text(value)?.replaceAll(\"\\\\\", \"/\");\n if (path === undefined) return undefined;\n const direct = files.find((file) => file.path === path || path.endsWith(`/${file.path}`));\n if (direct !== undefined) return direct;\n const name = path.split(\"/\").at(-1);\n const matching = files.filter((file) => file.path.split(\"/\").at(-1) === name);\n return matching.length === 1 ? matching[0] : undefined;\n}\n\nfunction previewAsset(file: VideoWorkspaceFile, role: VideoPreviewAsset[\"role\"], label: string): VideoPreviewAsset | undefined {\n return file.kind === \"media\" && file.mimeType?.startsWith(\"video/\") === true\n ? { role, label, path: file.path, bytes: file.bytes, version: file.version, mimeType: file.mimeType }\n : undefined;\n}\n\nexport function summarizeVideoProject(\n root: string,\n files: readonly VideoWorkspaceFile[],\n metadata: {\n readonly project?: unknown;\n readonly runManifest?: unknown;\n readonly assembly?: unknown;\n } = {}\n): VideoProjectSummary {\n const id = root.slice(`${VIDEO_DIRECTORY}/`.length);\n const projectFiles = files.filter((file) => file.path.startsWith(`${root}/`));\n const project = record(metadata.project);\n const manifest = record(metadata.runManifest);\n const settings = record(manifest?.settings);\n const assembly = record(metadata.assembly);\n const source = referencedMedia(projectFiles, manifest?.source_video)\n ?? projectFiles.find((file) => file.kind === \"media\" && file.path.startsWith(`${root}/sources/`) && file.mimeType?.startsWith(\"video/\") === true);\n const edited = projectFiles.find((file) => file.path.split(\"/\").at(-1) === \"edited_source.mp4\");\n const final = referencedMedia(projectFiles, assembly?.final_output)\n ?? projectFiles.filter((file) => file.kind === \"media\" && (file.path.startsWith(`${root}/outputs/`) || /^recap_.+\\.(?:mp4|mov|webm)$/iu.test(file.path.split(\"/\").at(-1) ?? \"\"))).at(-1);\n const previews = [\n source === undefined ? undefined : previewAsset(source, \"source\", \"\u539F\u7247\"),\n edited === undefined ? undefined : previewAsset(edited, \"edited\", \"\u526A\u540E\u7247\"),\n final === undefined ? undefined : previewAsset(final, \"final\", \"\u6700\u7EC8\u6210\u7247\")\n ].filter((value): value is VideoPreviewAsset => value !== undefined);\n const names = new Set(projectFiles.map((file) => file.path.split(\"/\").at(-1)));\n const cutMode = settings?.edit_mode === \"cut\" || names.has(\"clip_plan.json\") || edited !== undefined;\n let state: VideoProjectSummary[\"state\"] = \"not-started\";\n let stage = \"source\";\n let stageLabel = source === undefined ? \"\u7B49\u5F85\u5BFC\u5165\u89C6\u9891\" : \"\u53EF\u4EE5\u5F00\u59CB\";\n let nextArtifact: string | undefined;\n if (final !== undefined) {\n state = \"ready\"; stage = \"complete\"; stageLabel = \"\u6210\u7247\u5DF2\u5C31\u7EEA\";\n } else if (names.has(\"tts_meta.json\")) {\n state = \"working\"; stage = \"assemble\"; stageLabel = \"\u6B63\u5728\u5408\u6210\";\n } else if (names.has(\"narration.json\")) {\n state = \"working\"; stage = \"voiceover\"; stageLabel = \"\u914D\u97F3\u4E0E\u5408\u6210\";\n } else if (cutMode && edited !== undefined) {\n state = \"waiting\"; stage = \"narration\"; stageLabel = \"\u7B49\u5F85\u89E3\u8BF4\u8BCD\"; nextArtifact = \"narration.json\";\n } else if (cutMode && names.has(\"clip_plan.json\")) {\n state = \"working\"; stage = \"cut\"; stageLabel = \"\u6B63\u5728\u526A\u8F91\";\n } else if (manifest !== undefined) {\n state = \"waiting\";\n stage = cutMode ? \"clip-plan\" : \"narration\";\n stageLabel = cutMode ? \"\u7B49\u5F85\u526A\u8F91\u8BA1\u5212\" : \"\u7B49\u5F85\u89E3\u8BF4\u8BCD\";\n nextArtifact = cutMode ? \"clip_plan.json\" : \"narration.json\";\n }\n const artifacts = projectFiles.flatMap((file): VideoArtifactSummary[] => {\n const name = file.path.split(\"/\").at(-1) ?? \"\";\n const meta = ARTIFACT_META[name];\n return meta === undefined ? [] : [{ ...meta, path: file.path, version: file.version }];\n }).sort((left, right) => left.path.localeCompare(right.path, \"zh-Hans-CN\"));\n return {\n id,\n root,\n title: text(project?.title) ?? id,\n state,\n stage,\n stageLabel,\n nextArtifact,\n previews,\n artifacts\n };\n}\n", "import type { IncomingHttpHeaders } from \"node:http\";\n\ninterface WorkspaceTrustRequest {\n readonly headers: IncomingHttpHeaders | Headers;\n}\n\nfunction header(headers: IncomingHttpHeaders | Headers, name: string): string | undefined {\n if (headers instanceof Headers) return headers.get(name) ?? undefined;\n const value = headers[name];\n return typeof value === \"string\" ? value : undefined;\n}\n\nfunction parseAuthority(authority: string): URL | undefined {\n try { return new URL(`http://${authority}`); }\n catch { return undefined; }\n}\n\nfunction canonicalAuthority(entry: string, url: URL): string {\n const port = url.port !== \"\" ? url.port : new URL(`https://${entry}`).port;\n return port === \"\" ? url.hostname : `${url.hostname}:${port}`;\n}\n\nfunction isLoopbackHostname(hostname: string): boolean {\n if (hostname === \"localhost\" || hostname === \"[::1]\") return true;\n const parts = hostname.split(\".\");\n return parts.length === 4\n && parts[0] === \"127\"\n && parts.every((part) => /^\\d{1,3}$/u.test(part) && Number(part) <= 255);\n}\n\nfunction isTrustedAuthority(host: URL, trustedHosts: readonly string[]): boolean {\n return trustedHosts.some((entry) => {\n const candidate = parseAuthority(entry);\n if (candidate === undefined) return false;\n return canonicalAuthority(entry, candidate) === candidate.hostname\n ? candidate.hostname === host.hostname\n : candidate.host === host.host;\n });\n}\n\n/** Reject malformed declarations at plugin load instead of silently widening access. */\nexport function assertTrustedWorkspaceAuthority(entry: string): void {\n const url = parseAuthority(entry);\n if (url !== undefined && canonicalAuthority(entry, url) === entry.toLocaleLowerCase()) return;\n throw new Error(`oh-story: trustedHosts entry ${JSON.stringify(entry)} is not a bare host[:port] authority`);\n}\n\n/**\n * Same browser trust boundary as DSH's native API: every request must address a\n * loopback or explicitly trusted Host, and browser markers must be same-origin.\n */\nexport function isTrustedWorkspaceRequest(\n request: WorkspaceTrustRequest,\n trustedHosts: readonly string[]\n): boolean {\n const authority = header(request.headers, \"host\");\n if (authority === undefined) return false;\n const host = parseAuthority(authority);\n if (host === undefined) return false;\n if (!isLoopbackHostname(host.hostname) && !isTrustedAuthority(host, trustedHosts)) return false;\n if (header(request.headers, \"sec-fetch-site\") === \"cross-site\") return false;\n const origin = header(request.headers, \"origin\");\n if (origin === undefined) return true;\n try { return new URL(origin).host === host.host; }\n catch { return false; }\n}\n\n/**\n * Permit a generated-game document to navigate from one loopback alias to\n * another (127.0.0.1 \u2194 localhost). Subresources then become same-origin with\n * the isolated preview document and use the stricter path above.\n */\nexport function isTrustedPreviewNavigation(\n request: WorkspaceTrustRequest,\n trustedHosts: readonly string[]\n): boolean {\n if (isTrustedWorkspaceRequest(request, trustedHosts)) return true;\n const authority = header(request.headers, \"host\");\n if (authority === undefined) return false;\n const host = parseAuthority(authority);\n if (host === undefined || (!isLoopbackHostname(host.hostname) && !isTrustedAuthority(host, trustedHosts))) return false;\n return header(request.headers, \"origin\") === undefined\n && header(request.headers, \"sec-fetch-site\") === \"cross-site\"\n && header(request.headers, \"sec-fetch-mode\") === \"navigate\"\n && [\"document\", \"iframe\"].includes(header(request.headers, \"sec-fetch-dest\") ?? \"\");\n}\n"],
5
+ "mappings": ";AAKA,OAAO,OAAO;;;ACLd,SAAS,SAAS,gBAAgB;AAClC,SAAS,UAAU,WAAAA,UAAS,YAAY,QAAAC,OAAM,UAAU,WAAAC,gBAAe;;;ACDvE,SAAS,kBAAkB;AAC3B,SAAS,QAAQ,OAAO,OAAO,QAAQ,iBAAiB;AACxD,SAAS,cAAc;AACvB,SAAS,SAAS,MAAM,eAAe;AAyChC,IAAM,2BAA2B;AAExC,IAAM,kBAAkB;AAEjB,IAAM,iBAA8C;AAAA,EACzD;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa,CAAC,gBAAgB;AAAA,IAC9B,aAAa,CAAC,iBAAiB;AAAA,IAC/B,gBAAgB;AAAA,IAChB,WAAW;AAAA,EACb;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,OAAO;AAAA,IACP,UAAU;AAAA,IACV,aAAa,CAAC,eAAe,gBAAgB;AAAA,IAC7C,aAAa,CAAC,qBAAqB,2BAA2B,yBAAyB,uBAAuB;AAA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M,SAAS,EAAE,OAAO;AAAA,EAC7B,gBAAgB,EAAE,QAAQ,EAAE,IAAI,KAAM,EAAE,IAAI,OAAS,EAAE,QAAQ,OAAS;AAAA,EACxE,cAAc,EAAE,MAAM,MAAM,EAAE,QAAQ,CAAC,CAAC;AAC1C,CAAC;AAGD,eAAsB,MAAM,SAAkB,SAAiB,CAAC,GAAkB;AAChF,QAAM,eAAe,OAAO,gBAAgB,CAAC;AAC7C,aAAW,SAAS,aAAc,iCAAgC,KAAK;AACvE,UAAQ,OAAO,iBAAiB,MAAM,2BAA2B,CAAC;AAClE,UAAQ,OAAO,iBAAiB,MAAM,yBAAyB,CAAC;AAChE,UAAQ,OAAO,iBAAiB,MAAM,+BAA+B,CAAC;AACtE,UAAQ,OAAO,iBAAiB,MAAM,8BAA8B,CAAC;AACrE,uBAAqB,OAAO;AAC5B,gCAA8B,OAAO;AACrC,QAAM,wBAAwB,OAAO;AACrC,yBAAuB,SAAS,EAAE,UAAU,OAAO,kBAAkB,SAAW,aAAa,CAAC;AAI9F,QAAM,yBAAyB,sBAAsB,GAAG,EAAE,SAAS,MAAM,WAAW,GAAG,QAAQ,CAAC;AAClG;AAEA,IAAO,gBAAQ,EAAE,MAAM,QAAQ,QAAQ,MAAM;",
6
+ "names": ["dirname", "join", "resolve", "name", "name", "dirname", "resolve", "join", "name", "record", "defineTool", "readdir", "readFile", "isAbsolute", "join", "relative", "resolve", "readdir", "join", "resolve", "relative", "isAbsolute", "readFile", "readFile", "basename", "dirname", "join", "resolve", "fileURLToPath", "name", "defineTool", "name", "defineTool", "defineTool", "createHash", "extname", "isAbsolute", "relative", "resolve", "basename", "name", "metadata", "name", "name", "target", "relative", "isAbsolute", "extname", "record", "createHash", "resolve"]
7
7
  }