lantern-harness 0.1.14 → 0.1.16

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 (128) hide show
  1. package/CHANGELOG.md +41 -0
  2. package/README.md +1 -1
  3. package/builtin/session/lh-nav-groups.mjs +3 -0
  4. package/cli/ai-testbench.mjs +0 -0
  5. package/cli/server.mjs +3 -0
  6. package/config/app.defaults.json +2 -0
  7. package/dist/500.html +4 -4
  8. package/dist/_astro/Base.VCz1UVxQ.css +1 -0
  9. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.DMNdQAFX.js +1 -0
  10. package/dist/_astro/CaseExecBoard.cBdsZU9e.js +1 -0
  11. package/dist/_astro/CaseGenerateApp.D2ftaUXT.js +9 -0
  12. package/dist/_astro/CasesLibrary.DWXEje9u.js +19 -0
  13. package/dist/_astro/ChatApp.DeOJ7uAF.js +226 -0
  14. package/dist/_astro/ColumnResize.BgYkV9Iy.js +1 -0
  15. package/dist/_astro/{DashboardBoard.BKtXwr_n.js → DashboardBoard.BNuKH_zX.js} +1 -1
  16. package/dist/_astro/DocsFileBrowser.-dkkxR4X.js +1 -0
  17. package/dist/_astro/{DocsPager.C6R2nQ60.js → DocsPager.v4kQH163.js} +1 -1
  18. package/dist/_astro/{DrawerField.BXWvezBs.js → DrawerField.C0ehOlDt.js} +1 -1
  19. package/dist/_astro/ExcelFieldTags.ytbpKt-Z.js +5 -0
  20. package/dist/_astro/{KnowledgeLibrary.fYr4VQkZ.js → KnowledgeLibrary.Dw-IX3Zt.js} +1 -1
  21. package/dist/_astro/{NavLibraries.CpnreEwA.js → NavLibraries.D1J9BwYo.js} +1 -1
  22. package/dist/_astro/OverflowHint.pvo2Xc8R.js +1 -0
  23. package/dist/_astro/PluginsPage.BxscT2eI.js +7 -0
  24. package/dist/_astro/PluginsPage.uNmdj9oC.js +1 -0
  25. package/dist/_astro/{PmBugsBoard.ifLSqDOs.js → PmBugsBoard.BTtm1lki.js} +1 -1
  26. package/dist/_astro/{PmIterationsBoard.CVjphcgB.js → PmIterationsBoard.Dm67iXe_.js} +1 -1
  27. package/dist/_astro/{PmProjectDetail.Dudm02Xv.js → PmProjectDetail.B7oWL7y-.js} +1 -1
  28. package/dist/_astro/{PmProjectsBoard.CKWUrQHF.js → PmProjectsBoard.8QI44RlE.js} +1 -1
  29. package/dist/_astro/PmRequirementsBoard.DMJVLCqz.js +1 -0
  30. package/dist/_astro/PmRequirementsBoard.X98441HZ.js +1 -0
  31. package/dist/_astro/{PmShared.BwVlCk92.js → PmShared.DbDseTcc.js} +1 -1
  32. package/dist/_astro/PromptMountDialog.YH2odDZx.js +58 -0
  33. package/dist/_astro/PromptsLibrary.BGLzT5qB.js +1 -0
  34. package/dist/_astro/{ReportsPage.BKcIJsLn.js → ReportsPage.BjcajHR6.js} +1 -1
  35. package/dist/_astro/ReqAnalysisBoard.wlVfu2Hi.js +28 -0
  36. package/dist/_astro/RequirementsLibrary.CgzwlAXi.js +1 -0
  37. package/dist/_astro/SearchableSelect.mvcBwegf.js +1 -0
  38. package/dist/_astro/{SelectDropdown.DqKxIust.js → SelectDropdown.Cb-QtC-D.js} +1 -1
  39. package/dist/_astro/{SettingsDialog.a99Y08tE.js → SettingsDialog.C2qXt7Cw.js} +1 -1
  40. package/dist/_astro/{SpaceSwitcher.DDGfnQBp.js → SpaceSwitcher.DMoqOVpS.js} +1 -1
  41. package/dist/_astro/TasksBoard.Bz_JL_uQ.js +1 -0
  42. package/dist/_astro/{TemplatesLibrary.C3mqFIB0.js → TemplatesLibrary.B5KmjjFw.js} +1 -1
  43. package/dist/_astro/TestStatsBoard.EIDxmU_8.js +1 -0
  44. package/dist/_astro/TodosBoard.DV1VzVDe.js +1 -0
  45. package/dist/_astro/UiAutoBoard.DJljpjXT.js +9 -0
  46. package/dist/_astro/{app-config.Bm4oN4YP.js → app-config.CF1xVPmo.js} +1 -1
  47. package/dist/_astro/app-version.v6jLgARE.js +1 -0
  48. package/dist/_astro/case-review.DYyZat83.js +3 -0
  49. package/dist/_astro/case-types.DS1EQ5yP.js +1 -0
  50. package/dist/_astro/composer-task.DJmluzPT.js +5 -0
  51. package/dist/_astro/export.joBT53eb.js +148 -0
  52. package/dist/_astro/{hydrate-cache.BJ2nzhRq.js → hydrate-cache.CmC22o_H.js} +1 -1
  53. package/dist/_astro/{i18n.m5rqL3-h.js → i18n.B3BVhlok.js} +1 -1
  54. package/dist/_astro/index.astro_astro_type_script_index_0_lang.CM78W1qz.js +1 -0
  55. package/dist/_astro/{open-docs-in-session.DPCjFUcv.js → open-docs-in-session.B6uyOxPn.js} +1 -1
  56. package/dist/_astro/{plugins.CCqu2gnf.js → plugins.DYyAjBXb.js} +1 -1
  57. package/dist/_astro/prompts-meta.C_MeYq8G.js +2 -0
  58. package/dist/_astro/req-analysis.CkLx8c9E.js +6 -0
  59. package/dist/_astro/{settings.DNkAyQxA.js → settings.BvxRxdqa.js} +2 -2
  60. package/dist/_astro/{spaces-client.D4EmN6SH.js → spaces-client.Dy3tSPta.js} +1 -1
  61. package/dist/_astro/story-review.Ct1XRMjk.js +10 -0
  62. package/dist/_astro/{tasks.otRBFydq.js → tasks.BNBkrFC3.js} +1 -1
  63. package/dist/_astro/{view-prefs.Do8yjl1I.js → view-prefs.D1snIG5o.js} +1 -1
  64. package/dist/case-exec/index.html +5 -5
  65. package/dist/cases/generate/index.html +5 -5
  66. package/dist/cases/library/index.html +5 -5
  67. package/dist/dashboard/index.html +5 -5
  68. package/dist/docs/changelog/index.html +42 -5
  69. package/dist/docs/install/index.html +4 -4
  70. package/dist/docs/manual/index.html +92 -52
  71. package/dist/index.html +1 -1
  72. package/dist/knowledge/index.html +5 -5
  73. package/dist/knowledge//345/212/237/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/347/274/226/345/206/231/350/247/204/350/214/203/index.html +4 -4
  74. package/dist/plugins/index.html +5 -5
  75. package/dist/pm/bugs/index.html +5 -5
  76. package/dist/pm/iterations/index.html +5 -5
  77. package/dist/pm/projects/detail/index.html +5 -5
  78. package/dist/pm/projects/index.html +5 -5
  79. package/dist/pm/requirements/index.html +5 -5
  80. package/dist/prompts/index.html +5 -5
  81. package/dist/reports/index.html +5 -5
  82. package/dist/requirement-analysis/index.html +5 -5
  83. package/dist/requirements/index.html +5 -5
  84. package/dist/tasks/index.html +5 -5
  85. package/dist/templates/index.html +5 -5
  86. package/dist/templates//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//345/212/237/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +4 -4
  87. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212//346/200/247/350/203/275/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +4 -4
  88. package/dist/templates//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213//346/200/247/350/203/275/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +4 -4
  89. package/dist/templates//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212//346/216/245/345/217/243/346/265/213/350/257/225/346/212/245/345/221/212/346/250/241/346/235/277/index.html +4 -4
  90. package/dist/templates//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213//350/207/252/345/212/250/345/214/226/346/265/213/350/257/225/347/224/250/344/276/213/346/250/241/346/235/277/index.html +4 -4
  91. package/dist/test-automation/index.html +5 -5
  92. package/dist/test-stats/index.html +5 -5
  93. package/dist/todos/index.html +5 -5
  94. package/dist/workbench/index.html +5 -5
  95. package/docs//346/223/215/344/275/234/346/211/213/345/206/214.md +59 -39
  96. package/lh-plugins/case-review-prompt.mjs +181 -0
  97. package/lh-plugins/lh-case-review.mjs +627 -0
  98. package/lh-plugins/lh-project-docs.mjs +4 -1
  99. package/lh-plugins/lh-req-analysis.mjs +1 -1
  100. package/lh-plugins/plugin-prompts.mjs +4 -0
  101. package/package.json +16 -18
  102. package/dist/_astro/Base.XN4RkAyb.css +0 -1
  103. package/dist/_astro/Base.astro_astro_type_script_index_0_lang.BS3Daz5F.js +0 -1
  104. package/dist/_astro/CaseExecBoard.6RFYgAq5.js +0 -1
  105. package/dist/_astro/CaseGenerateApp.BwvNF4eM.js +0 -9
  106. package/dist/_astro/CasesLibrary.LnLh6m6G.js +0 -1
  107. package/dist/_astro/ChatApp.bMYcVMLe.js +0 -226
  108. package/dist/_astro/ColumnResize.BEkEW7qw.js +0 -1
  109. package/dist/_astro/DocsFileBrowser.nSAGUo3l.js +0 -1
  110. package/dist/_astro/ExcelFieldTags.CaD64a2w.js +0 -152
  111. package/dist/_astro/OverflowHint.DI-tZ2fv.js +0 -1
  112. package/dist/_astro/PluginsPage.B56V66Kk.js +0 -7
  113. package/dist/_astro/PluginsPage.DaLeNTSR.js +0 -1
  114. package/dist/_astro/PmRequirementsBoard.CB33kbaD.js +0 -1
  115. package/dist/_astro/PmRequirementsBoard.CJFck3LB.js +0 -1
  116. package/dist/_astro/PromptMountDialog.D_94WQc3.js +0 -58
  117. package/dist/_astro/PromptsLibrary.Bn5Y9KTB.js +0 -1
  118. package/dist/_astro/ReqAnalysisBoard.D1UGCxJd.js +0 -28
  119. package/dist/_astro/RequirementsLibrary.D5iItFfK.js +0 -1
  120. package/dist/_astro/SearchableSelect.BzNQ6oXG.js +0 -1
  121. package/dist/_astro/TasksBoard.BniGtf89.js +0 -1
  122. package/dist/_astro/TestStatsBoard.CyWsC1tC.js +0 -1
  123. package/dist/_astro/TodosBoard.Z4Ev2O0M.js +0 -1
  124. package/dist/_astro/UiAutoBoard.DOYiz3km.js +0 -9
  125. package/dist/_astro/app-version.6yGkRTiD.js +0 -1
  126. package/dist/_astro/index.astro_astro_type_script_index_0_lang.CPKr56B1.js +0 -1
  127. package/dist/_astro/prompts-meta.BiymOMAE.js +0 -2
  128. package/dist/_astro/story-review.a7qZTroW.js +0 -15
@@ -0,0 +1,28 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{s as r}from"./plugins.DYyAjBXb.js";import{a as i,i as a,n as o,o as s,r as c,t as l}from"./view-prefs.D1snIG5o.js";import{t as u}from"./jsx-runtime.DUg_B_vD.js";import{t as d}from"./ConfirmDialog.CsMwWevK.js";import{t as f}from"./OverflowHint.pvo2Xc8R.js";import{t as ee}from"./SelectDropdown.Cb-QtC-D.js";import{showToast as p}from"./Toast.BO2NFckG.js";import{s as te}from"./llm.BZEzE0x2.js";import{f as ne,l as re,p as ie}from"./settings.BvxRxdqa.js";import{E as m,S as ae,T as oe,_ as se,a as ce,b as le,c as ue,d as de,f as fe,g as pe,h as me,i as he,l as ge,m as h,n as g,o as _,p as _e,r as ve,s as ye,t as v,u as be,v as xe,w as Se,x as Ce,y as we}from"./req-analysis.CkLx8c9E.js";import{_ as Te,a as Ee,c as De,d as Oe,f as ke,g as Ae,h as je,i as Me,l as y,m as Ne,n as Pe,o as Fe,p as Ie,r as Le,s as Re,u as b}from"./story-review.Ct1XRMjk.js";import{t as ze}from"./hydrate-cache.CmC22o_H.js";import{O as Be,S as x,_ as Ve,g as He,m as S,u as Ue}from"./PmShared.DbDseTcc.js";var C=e(t(),1),We=`可用工具(只调用这些,不要自己编工具名):
2
+ - req_set_outline:提交本批「需求条目」,返回每个条目的 id。
3
+ - req_set_stories:提交「用户故事」;补写时提交合并后的完整故事集(带原 id 原地更新)。
4
+ - req_save_check:提交体检结果(缺口清单 + 结论)。
5
+ - req_save_test_points:提交测试点(功能 / 边界值 / 异常 / 业务规则 / 非功能五维,P0–P3)。
6
+
7
+ 提交后不要重复提交同样的内容;工具返回 ok 之后再写最终回答。`,Ge=[`missing-scenario`,`missing-dimension`,`untestable-acceptance`,`conflict`,`over-split`,`other`];function Ke(e){try{let t=JSON.parse(e||`{}`);return t&&typeof t==`object`?t:{}}catch{return{}}}function w(e,t=500){return typeof e==`string`?e.trim().slice(0,t):``}function T(e){return String(e??``).toLowerCase().replace(/[\s\p{P}\p{S}]+/gu,``)}function qe(e){let t=w(e,10);return t===`high`||t===`medium`||t===`low`?t:`medium`}function E(e){let t=w(e,40);return Ge.includes(t)?t:`other`}var D=[`functional`,`boundary`,`exception`,`business`,`nonfunctional`];function O(e){let t=w(e,40);if(D.includes(t))return t;let n=w(e,20);return D.find(e=>Re[e]===n)??`functional`}function k(e){let t=w(e,4).toUpperCase();return b.includes(t)?t:`P1`}function A(e,t){if(!e||typeof e!=`object`)return null;let n=e,r=w(n.title,200);if(!r)return null;let i=w(n.storyId,20);return{id:``,storyId:t.has(i)?i:``,dimension:O(n.dimension),priority:k(n.priority),title:r,precondition:w(n.precondition,1e3),steps:Array.isArray(n.steps)?n.steps.map(e=>w(e,500)).filter(Boolean).slice(0,20):[],expected:w(n.expected,1e3)}}var Je=[{type:`function`,function:{name:`req_set_outline`,description:`提交本批从原始需求里抽出的需求条目(一条 = 一个可独立验收的能力点)。返回每个条目的 id,供 sourceRefs 引用。`,parameters:{type:`object`,properties:{items:{type:`array`,items:{type:`object`,properties:{title:{type:`string`,description:`一句话概括`},quote:{type:`string`,description:`原文关键句,不超过 80 字`}},required:[`title`]}}},required:[`items`]}}},{type:`function`,function:{name:`req_set_stories`,description:`提交用户故事。拆解时只提交这一批新故事;补写时提交合并后的完整故事集(带原 id 的原地更新,新故事不带 id)。`,parameters:{type:`object`,properties:{stories:{type:`array`,items:{type:`object`,properties:{id:{type:`string`,description:`已有故事才带(US-001 这种)`},title:{type:`string`,description:`一句话说明这条故事做什么`},role:{type:`string`,description:`角色(来自原文;推断的要在 value 里注明)`},goal:{type:`string`,description:`用户想达成的目标`},value:{type:`string`,description:`业务价值 / 补充说明(角色为推断时写在这里)`},sourceRefs:{type:`array`,items:{type:`string`},description:`对应的需求条目 id(req_set_outline 返回的真实 id)`},priority:{type:`string`,enum:[`P0`,`P1`,`P2`]},preconditions:{type:`array`,items:{type:`string`}},mainFlow:{type:`array`,items:{type:`object`,properties:{actor:{type:`string`},action:{type:`string`,description:`动词开头的一步`},result:{type:`string`,description:`用户能看到的变化`}},required:[`action`]}},altFlows:{type:`array`,items:{type:`object`,properties:{name:{type:`string`},trigger:{type:`string`,description:`什么情况下走这条替代路径`},steps:{type:`array`,items:{type:`string`}}},required:[`name`,`trigger`]}},exceptions:{type:`array`,items:{type:`object`,properties:{scenario:{type:`string`,description:`异常场景`},expected:{type:`string`,description:`系统应有的表现`}},required:[`scenario`,`expected`]}},postconditions:{type:`array`,items:{type:`string`}},acceptance:{type:`array`,items:{type:`object`,properties:{given:{type:`string`},when:{type:`string`},then:{type:`string`,description:`必须可判定`}},required:[`given`,`when`,`then`]}},dimensions:{type:`array`,items:{type:`string`},description:`权限 / 边界值 / 并发与幂等 / 空数据 / 超时与失败 / 国际化与时区`}},required:[`title`,`role`,`mainFlow`,`acceptance`]}}},required:[`stories`]}}},{type:`function`,function:{name:`req_save_check`,description:`提交需求体检结果:语义类缺口清单 + 两三句话结论。只出问题,不改写故事。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论,两三句话`},gaps:{type:`array`,items:{type:`object`,properties:{storyTitle:{type:`string`,description:`相关故事标题;全局问题填空串`},type:{type:`string`,enum:Ge},severity:{type:`string`,enum:[`high`,`medium`,`low`]},title:{type:`string`},detail:{type:`string`,description:`位置 + 原因`},suggestion:{type:`string`,description:`建议补写什么`}},required:[`title`,`detail`]}}},required:[`gaps`]}}},{type:`function`,function:{name:`req_save_test_points`,description:`提交基于用户故事拆出的测试点:功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度全覆盖,每条标 P0–P3。一次提交全部,不要分多次。`,parameters:{type:`object`,properties:{summary:{type:`string`,description:`整体结论:几条、五维覆盖情况、最该先测什么`},points:{type:`array`,items:{type:`object`,properties:{storyId:{type:`string`,description:`对应故事 id(US-001 这种);全局测试点填空串`},dimension:{type:`string`,enum:D,description:`functional 功能 / boundary 边界值 / exception 异常 / business 业务规则 / nonfunctional 非功能`},priority:{type:`string`,enum:b},title:{type:`string`,description:`一句话说清测什么(动词开头,带条件)`},precondition:{type:`string`,description:`执行前需要的数据 / 角色 / 状态`},steps:{type:`array`,items:{type:`string`},description:`可执行步骤,一步一个动作`},expected:{type:`string`,description:`可判定的预期结果,有阈值写具体数值`}},required:[`dimension`,`priority`,`title`]}}},required:[`points`]}}}];async function Ye(e,t,n){let r=Ke(t),i=n.getDoc();if(!i)return JSON.stringify({ok:!1,error:`当前还没有打开分析文档`});if(e===`req_set_outline`){let e=Array.isArray(r.items)?r.items:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.outline.length,items:i.outline.map(({id:e,title:t})=>({id:e,title:t})),note:`没有提交新条目,需求条目保持不变。`});let t=i.outline,a=new Set(t.map(e=>T(e.title))),o=new Set(t.map(e=>e.id)),s=[];for(let t of e){let e=t&&typeof t==`object`?t:{},r=w(e.title,200)||w(e.quote,200);if(!r||a.has(T(r)))continue;a.add(T(r));let i=`RO-${n.batch+1}-${s.length+1}`,c=i,l=1;for(;o.has(c);)c=`${i}-${l++}`;o.add(c),s.push({id:c,title:r,quote:w(e.quote,500)})}let c=[...t,...s],l=await n.saveOutline(c);return JSON.stringify({ok:!0,added:s.length,total:l.length,items:l.map(({id:e,title:t})=>({id:e,title:t})),note:s.length>0?`条目已保存。接下来用 req_set_stories 提交故事,sourceRefs 只能引用上面返回的 id。`:`这些条目已经存在,没有重复写入;继续提交故事即可。`})}if(e===`req_set_stories`){let e=Array.isArray(r.stories)?r.stories:[];if(!e.length)return JSON.stringify({ok:!0,added:0,total:i.stories.length,note:`没有提交故事,故事集保持不变。`});let t=i.stories.length,a=xe(i.stories,e),o=await n.saveStories(a),s=new Set(i.outline.map(e=>e.id)),c=o.stories.flatMap(e=>e.sourceRefs).filter(e=>!s.has(e));return JSON.stringify({ok:!0,added:Math.max(0,o.stories.length-t),total:o.stories.length,stories:o.stories.map(({id:e,title:t,priority:n})=>({id:e,title:t,priority:n})),danglingSourceRefs:Array.from(new Set(c)).slice(0,10),note:c.length>0?`有些 sourceRefs 不在需求条目里,覆盖率会算不到;需要的话用真实条目 id 修正。`:`故事已保存。`})}if(e===`req_save_check`){let e=ue(i),t=new Map(i.stories.filter(e=>e.title).map(e=>[T(e.title),e.id])),a=new Set(i.stories.map(e=>e.id)),o=Array.isArray(r.gaps)?r.gaps:[],s=[];for(let e of o){let n=e&&typeof e==`object`?e:{},r=w(n.title,200);if(!r)continue;let i=w(n.storyId,20),o=a.has(i)&&i||t.get(T(w(n.storyTitle,200)))||``,c=E(n.type);s.push({id:h(c,o,r),storyId:o,type:c,severity:qe(n.severity),title:r,detail:w(n.detail,1e3),suggestion:w(n.suggestion,1e3),origin:`model`,selected:!1})}let c=se(e.gaps,s),l=w(r.summary,1500)||e.summary;return await n.saveCheck({...e,summary:l,gaps:c}),JSON.stringify({ok:!0,gaps:c.length,high:c.filter(e=>e.severity===`high`).length,coverage:e.coverage,dimensions:e.dimensions.map(e=>({label:e.label,covered:e.covered})),note:`体检报告已保存:整体 ${c.length} 个缺口(高 ${c.filter(e=>e.severity===`high`).length} 个),覆盖率 ${Math.round(e.coverage.rate*100)}%。用户可以在页面上勾选缺口补写。`})}if(e===`req_save_test_points`){let e=Array.isArray(r.points)?r.points:[];if(!e.length)return JSON.stringify({ok:!0,total:i.testPoints?.points.length??0,note:`没有提交测试点,原结果保持不变。`});if(typeof n.saveTestPoints!=`function`)return JSON.stringify({ok:!1,error:`当前上下文不支持保存测试点`});let t=new Set(i.stories.map(e=>e.id)),a=e.slice(0,500).map(e=>A(e,t)).filter(e=>e!==null);if(!a.length)return JSON.stringify({ok:!1,error:`测试点都缺少标题,没有保存`});let o=(await n.saveTestPoints({at:new Date().toISOString(),summary:w(r.summary,2e3),points:a})).testPoints?.points??a,s=D.map(e=>({dimension:Re[e],count:o.filter(t=>t.dimension===e).length})),c=b.map(e=>({priority:e,count:o.filter(t=>t.priority===e).length})),l=s.filter(e=>e.count===0).map(e=>e.dimension);return JSON.stringify({ok:!0,total:o.length,byDimension:s,byPriority:c,uncoveredDimensions:l,note:l.length>0?`测试点已保存:整体 ${o.length} 条。${l.join(`、`)}还没有测试点,如确实不适用请在回答里说明。`:`测试点已保存:整体 ${o.length} 条,五个维度都有覆盖。`})}return JSON.stringify({ok:!1,error:`未知工具:${e}`})}function j(e){let t=[],n=/```json\s*([\s\S]*?)```/gi,r;for(;(r=n.exec(e))!==null;)r[1]?.trim()&&t.push(r[1].trim());return t}function Xe(e){let t=j(String(e??``));for(let e of t)try{let t=JSON.parse(e),n=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.stories)?t.stories:null;if(!n?.length)continue;let r=n.filter(e=>!!(e&&typeof e==`object`&&typeof e.title==`string`));if(r.length)return r}catch{}return[]}function Ze(e,t=[]){let n=new Set(t),r=j(String(e??``));for(let e of r)try{let t=JSON.parse(e),r=Array.isArray(t)?t:t&&typeof t==`object`&&Array.isArray(t.points)?t.points:null;if(!r?.length)continue;let i=r.map(e=>A(e,n)).filter(e=>e!==null);if(!i.length)continue;let a=t&&typeof t==`object`&&!Array.isArray(t)?w(t.summary,2e3):``;return{at:new Date().toISOString(),summary:a,points:i}}catch{}return null}var M=u(),N=`text-xs font-semibold tracking-wide text-stone-500`,P=`inline-flex h-7 items-center justify-center rounded-md bg-[#3370ff] px-2.5 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Qe=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`;function $e({check:e,stories:t,busy:n,onToggleGap:r,onToggleAll:i,onFix:a,onReview:o,onExport:s}){if(!e)return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有审查结果`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`审查会先用固定规则核对覆盖率与字段完整性,再让模型专查场景遗漏与维度缺失(替代流程不成立、验收不可测也会一并报)。`}),(0,M.jsx)(`button`,{type:`button`,className:`mt-4 h-9 rounded-md bg-[#3370ff] px-4 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:n||!t.length,onClick:o,children:`开始审查`})]});let c=Ee(e.gaps),l=e.gaps.filter(e=>e.selected).length,u=e.coverage.total?Math.round(e.coverage.rate*100):0,d=Pe(e.gaps),ee=new Map(t.map(e=>[e.id,e.title]));return(0,M.jsxs)(`div`,{className:`space-y-4`,children:[(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-6 gap-y-2`,children:[(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:N,children:`需求条目覆盖率`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.coverage.covered,(0,M.jsxs)(`span`,{className:`text-sm font-normal text-stone-400`,children:[` / `,e.coverage.total]}),(0,M.jsxs)(`span`,{className:`ml-2 text-sm font-normal text-stone-500`,children:[u,`%`]})]})]}),(0,M.jsxs)(`div`,{className:`min-w-[160px] flex-1`,children:[(0,M.jsx)(`div`,{className:`h-2 overflow-hidden rounded-full bg-stone-100`,children:(0,M.jsx)(`div`,{className:`h-full rounded-full transition-all ${u>=90?`bg-emerald-500`:u>=60?`bg-amber-500`:`bg-red-500`}`,style:{width:`${Math.max(u,e.coverage.total?2:0)}%`}})}),(0,M.jsx)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:e.coverage.total?`有故事引用的条目算覆盖;sourceRefs 为空的故事不会计入`:`还没有需求条目,先回「需求分析」做一次拆解`})]}),(0,M.jsxs)(`div`,{className:`text-right`,children:[(0,M.jsx)(`p`,{className:N,children:`缺口`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-lg font-semibold text-stone-800`,children:[e.gaps.length,(0,M.jsxs)(`span`,{className:`ml-1.5 text-xs font-normal text-stone-400`,children:[`高 `,d.high,` · 中 `,d.medium,` · 低 `,d.low]})]})]})]}),e.summary?(0,M.jsx)(`p`,{className:`mt-3 border-t border-stone-100 pt-2 text-xs leading-relaxed text-stone-500`,children:e.summary}):null]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsx)(`p`,{className:N,children:`维度覆盖`}),(0,M.jsx)(`div`,{className:`mt-2 grid gap-1.5 sm:grid-cols-2 lg:grid-cols-3`,children:e.dimensions.map(e=>{let t=e.stories.join(`, `);return(0,M.jsxs)(`div`,{"data-hint-width":!0,className:`min-w-0 rounded-lg border px-2.5 py-1.5 text-xs ${e.covered?`border-emerald-200 bg-emerald-50/60`:`border-stone-200 bg-stone-50`}`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{"aria-hidden":`true`,className:`shrink-0 ${e.covered?`text-emerald-600`:`text-stone-400`}`,children:e.covered?`✓`:`—`}),(0,M.jsx)(`span`,{className:`shrink-0 whitespace-nowrap font-medium ${e.covered?`text-emerald-800`:`text-stone-500`}`,children:e.label}),(0,M.jsx)(`span`,{className:`ml-auto shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.stories.length?`${e.stories.length} 条`:`未覆盖`})]}),(0,M.jsx)(`div`,{className:`mt-0.5 min-w-0 pl-[18px]`,children:t?(0,M.jsx)(f,{text:t,matchAnchorWidth:!0,className:`block truncate text-[11px] text-stone-400`}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:`没有故事覆盖`})})]},e.key)})})]}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center justify-between gap-2 border-b border-stone-100 px-4 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-700`,children:`缺口清单`}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`已选 `,l,` 条`]})]}),(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:Qe,onClick:s,children:`导出 Markdown`}),(0,M.jsx)(`button`,{type:`button`,className:Qe,onClick:()=>i(l!==e.gaps.length),children:l===e.gaps.length&&e.gaps.length?`清空选择`:`全选`}),(0,M.jsx)(`button`,{type:`button`,className:P,disabled:n||!l,onClick:a,children:`补写选中缺口`})]})]}),c.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:c.map(e=>(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/60 px-4 py-1.5`,children:[(0,M.jsx)(`p`,{className:`text-xs font-semibold text-stone-600`,children:e.label}),(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500`,children:e.gaps.length}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.gaps.map(e=>(0,M.jsx)(F,{gap:e,storyTitle:ee.get(e.storyId)??``,onToggle:r},e.id))})]},e.key))}):(0,M.jsx)(`p`,{className:`px-4 py-10 text-center text-sm text-stone-400`,children:`没有发现缺口。覆盖率与维度都过了,可以再人工过一遍验收标准。`})]})]})}function F({gap:e,storyTitle:t,onToggle:n}){return(0,M.jsxs)(`li`,{className:`flex items-start gap-2.5 px-4 py-2.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1 h-3.5 w-3.5 shrink-0 accent-[#3370ff]`,checked:e.selected,onChange:t=>n(e.id,t.target.checked)}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-1.5`,children:[(0,M.jsx)(x,{tone:g[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 text-[11px] text-stone-500`,children:ve[e.type]}),e.storyId?(0,M.jsxs)(`span`,{className:`font-mono text-[11px] text-stone-400`,children:[e.storyId,t?` · ${t}`:``]}):(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`全局`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-300`,children:e.origin===`model`?`模型`:`规则`})]}),(0,M.jsx)(`p`,{className:`mt-0.5 text-sm text-stone-800`,children:e.title}),e.detail?(0,M.jsx)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-stone-500`,children:e.detail}):null,e.suggestion?(0,M.jsxs)(`p`,{className:`mt-0.5 text-xs leading-relaxed text-amber-700`,children:[`建议:`,e.suggestion]}):null]})]})}var I=`inline-flex h-7 items-center justify-center rounded-md border border-stone-200 bg-white px-2 text-xs text-stone-600 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,L=`text-xs font-semibold tracking-wide text-stone-500`;function R({point:e}){return(0,M.jsxs)(`div`,{className:`space-y-1 text-[11px] leading-relaxed text-stone-500`,children:[e.precondition?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`前置:`}),e.precondition]}):null,e.steps.length?(0,M.jsxs)(`div`,{children:[(0,M.jsx)(`p`,{className:`text-stone-400`,children:`步骤:`}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]}):null,e.expected?(0,M.jsxs)(`p`,{children:[(0,M.jsx)(`span`,{className:`text-stone-400`,children:`预期:`}),e.expected]}):null]})}function z({doc:e}){let t=Ae(e.testPoints);return(0,M.jsx)(`div`,{className:`overflow-x-auto pb-1`,children:(0,M.jsxs)(`div`,{className:`min-w-[860px]`,children:[(0,M.jsx)(`div`,{className:`flex justify-center`,children:(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5 text-center shadow-sm`,children:[(0,M.jsx)(`p`,{className:`text-sm font-semibold text-stone-800`,children:e.title||`未命名分析`}),(0,M.jsxs)(`p`,{className:`mt-0.5 text-[11px] text-stone-400`,children:[`测试点 `,e.testPoints?.points.length??0,` 条 · 五维覆盖`]})]})}),(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`relative`,children:[(0,M.jsx)(`div`,{className:`absolute top-0 right-[10%] left-[10%] h-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsx)(`div`,{className:`grid grid-cols-5 gap-3`,children:t.map(e=>{let t=De[e.key];return(0,M.jsxs)(`div`,{className:`flex flex-col`,children:[(0,M.jsx)(`div`,{className:`mx-auto h-4 w-px bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-1 border-b border-stone-100 px-2.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${t.accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:t.label})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[10px] tabular-nums text-stone-400`,children:e.points.length})]}),(0,M.jsx)(`div`,{className:`space-y-1.5 px-2 py-2`,children:e.points.length?e.points.map(e=>(0,M.jsxs)(`div`,{className:`rounded-lg border border-stone-100 bg-stone-50/60 px-2 py-1.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-start gap-1.5`,children:[(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority}),(0,M.jsx)(`p`,{className:`min-w-0 flex-1 text-[11px] leading-snug text-stone-700`,children:e.title})]}),(0,M.jsx)(f,{text:`${e.storyId||`全局`}${e.expected?` · ${e.expected}`:``}`,className:`mt-1 block truncate text-[10px] text-stone-400`})]},e.id)):(0,M.jsx)(`p`,{className:`py-2 text-center text-[11px] text-stone-300`,children:`无`})})]})]},e.key)})})]}),(0,M.jsx)(`p`,{className:`mt-3 text-center text-[11px] text-stone-400`,children:`分支 = 五个维度,叶子 = 测试点;左侧标签为优先级。需要完整结构可导出 XMind。`})]})})}function et({doc:e}){let t=Ae(e.testPoints);return(0,M.jsx)(`div`,{className:`space-y-3`,children:t.map(e=>(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2 border-b border-stone-100 px-3.5 py-2`,children:[(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`h-2 w-2 shrink-0 rounded-full ${De[e.key].accent}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:`text-sm font-medium text-stone-700`,children:e.label}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-[11px] text-stone-400`,children:e.hint})]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] tabular-nums text-stone-400`,children:e.points.length})]}),e.points.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:e.points.map(e=>(0,M.jsx)(`li`,{children:(0,M.jsxs)(`details`,{className:`group px-3.5 py-2`,children:[(0,M.jsxs)(`summary`,{className:`flex cursor-pointer list-none items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0`,children:(0,M.jsx)(x,{tone:y[e.priority].tone,children:e.priority})}),(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(`span`,{className:`block text-sm text-stone-800`,children:e.title}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`font-mono`,children:e.storyId||`全局`}),(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsxs)(`span`,{children:[e.steps.length,` 步`]}),e.expected?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`text-stone-300`,children:`·`}),(0,M.jsx)(f,{text:e.expected,className:`min-w-0 flex-1 truncate`})]}):null]})]}),(0,M.jsx)(`span`,{className:`mt-0.5 shrink-0 text-[11px] text-stone-300 group-open:hidden`,children:`展开`}),(0,M.jsx)(`span`,{className:`mt-0.5 hidden shrink-0 text-[11px] text-stone-300 group-open:inline`,children:`收起`})]}),(0,M.jsx)(`div`,{className:`mt-1.5 border-l-2 border-stone-100 pl-2.5`,children:(0,M.jsx)(R,{point:e})})]})},e.id))}):(0,M.jsx)(`p`,{className:`px-3.5 py-3 text-xs text-stone-400`,children:`本维度没有测试点。`})]},e.key))})}function tt({doc:e,generating:t,busy:n,promptReady:r,onGenerate:i,onExportXmind:a,onExportMarkdown:o}){let[s,c]=(0,C.useState)(`map`),l=e.testPoints,u=ke(l);if(!l){let n=e.stories.length?r?``:`「测试点生成提示词.md」还没就绪,重新打开插件会自动补齐`:`还没有用户故事,先做一次拆解`;return(0,M.jsxs)(`div`,{className:`flex flex-col items-center justify-center rounded-xl border border-dashed border-stone-200 px-4 py-16 text-center`,children:[(0,M.jsx)(`p`,{className:`text-sm font-medium text-stone-600`,children:`还没有测试点`}),(0,M.jsx)(`p`,{className:`mt-1 max-w-md text-xs leading-relaxed text-stone-400`,children:`基于拆好的用户故事,按功能 / 边界值 / 异常 / 业务规则 / 非功能五个维度拆测试点,每条标 P0–P3;结果可看导图、可下载 XMind。`}),n?(0,M.jsx)(`p`,{className:`mt-2 text-xs text-amber-700`,children:n}):null,(0,M.jsx)(`p`,{className:`mt-3 text-xs text-stone-400`,children:t?`正在生成测试点,完成后会自动出现在这里。`:`用左栏的「生成测试点」开始拆。`})]})}return(0,M.jsxs)(`div`,{className:`space-y-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-2 rounded-xl border border-stone-200 bg-white px-3.5 py-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-500`,children:[`共 `,(0,M.jsx)(`span`,{className:`font-medium text-stone-700`,children:u.total}),` 条`]}),(0,M.jsx)(`span`,{className:`flex items-center gap-1`,children:b.map(e=>(0,M.jsxs)(x,{tone:y[e].tone,children:[e,` `,u.byPriority[e]]},e))}),(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`维度覆盖 `,u.coveredDimensions,`/5`]}),(0,M.jsxs)(`span`,{className:`ml-auto flex items-center gap-1.5`,children:[(0,M.jsx)(`span`,{className:`flex overflow-hidden rounded-md border border-stone-200`,children:[{id:`map`,label:`导图`},{id:`list`,label:`列表`}].map(e=>(0,M.jsx)(`button`,{type:`button`,className:`h-7 px-2.5 text-xs transition-colors ${s===e.id?`bg-[#eef3ff] font-medium text-[#1f4fd8]`:`bg-white text-stone-500 hover:bg-stone-50`}`,onClick:()=>c(e.id),children:e.label},e.id))}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:i,children:t?`生成中…`:`重新生成`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:a,children:`导出 XMind`}),(0,M.jsx)(`button`,{type:`button`,className:I,disabled:n,onClick:o,children:`导出 Markdown`})]})]}),s===`map`?(0,M.jsx)(z,{doc:e}):(0,M.jsx)(et,{doc:e}),(0,M.jsxs)(`div`,{className:`rounded-xl border border-stone-200 bg-white px-3.5 py-2.5`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsx)(`p`,{className:L,children:`生成说明`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:l.at})]}),(0,M.jsx)(`p`,{className:`mt-1 whitespace-pre-wrap text-xs leading-relaxed text-stone-600`,children:l.summary||`(模型没有给整体结论)`})]})]})}var nt=[{value:`P0`,label:`P0 · 必须做`},{value:`P1`,label:`P1 · 应该做`},{value:`P2`,label:`P2 · 可以做`}],B=`h-9 w-full rounded-md border border-stone-200 bg-white px-2 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,V=`w-full resize-y rounded-md border border-stone-200 bg-white px-2 py-1.5 text-sm text-stone-800 outline-none transition-colors focus:border-[#3370ff] placeholder:text-stone-400`,H=`text-xs font-semibold tracking-wide text-stone-500`,rt=`text-[11px] font-medium tracking-wide text-stone-400`,it={P0:`bg-red-400`,P1:`bg-amber-400`,P2:`bg-stone-300`};function U({label:e,children:t}){return(0,M.jsxs)(`div`,{className:`grid gap-1 sm:grid-cols-[88px_minmax(0,1fr)] sm:gap-3`,children:[(0,M.jsx)(`p`,{className:`${rt} pt-0.5`,children:e}),(0,M.jsx)(`div`,{className:`min-w-0 text-[13px] leading-relaxed text-stone-700`,children:t})]})}function at(e){return e.split(`
8
+ `).map(e=>e.trim()).filter(Boolean)}function W({label:e,value:t,placeholder:n,onChange:r}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsxs)(`span`,{className:H,children:[e,`(一行一条)`]}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[64px]`,value:t.join(`
9
+ `),placeholder:n,onChange:e=>r(at(e.target.value))})]})}function ot({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`主流程(一行一步:动作 -> 结果)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>e.result?`${e.action} -> ${e.result}`:e.action).join(`
10
+ `),placeholder:`填写申请单 -> 进入待审批`,onChange:e=>t(at(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{action:e}:{action:e.slice(0,t).trim(),result:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function st({value:e,onChange:t}){let n=e.map(e=>[`${e.name} | ${e.trigger}`,...e.steps.map((e,t)=>`${t+1}. ${e}`)].join(`
11
+ `)).join(`
12
+
13
+ `);return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`替代流程(空行分段:名称 | 触发条件,下面写步骤)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:n,placeholder:`转人工审批 | 金额超过 5 万
14
+ 1. 提交后进入人工队列
15
+ 2. 审批通过再继续`,onChange:e=>t(e.target.value.split(/\n{2,}/).map(e=>{let t=e.split(`
16
+ `).map(e=>e.trim()).filter(Boolean),[n,r]=(t.shift()??``).split(`|`);return{name:(n??``).trim()||`替代流程`,trigger:(r??``).trim(),steps:t.map(e=>e.replace(/^\d+[.、)]\s*/,``))}}).filter(e=>e.name!==`替代流程`||e.steps.length||e.trigger))})]})}function ct({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`异常场景(一行一条:场景 -> 预期)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>e.expected?`${e.scenario} -> ${e.expected}`:e.scenario).join(`
17
+ `),placeholder:`提交时网络中断 -> 提示重试并保留草稿`,onChange:e=>t(at(e.target.value).map(e=>{let t=e.indexOf(`->`)>=0?e.indexOf(`->`):e.indexOf(`→`);return t<0?{scenario:e,expected:``}:{scenario:e.slice(0,t).trim(),expected:e.slice(t+(e.startsWith(`->`,t)?2:1)).trim()}}))})]})}function lt({value:e,onChange:t}){return(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`验收标准(一行一条:Given | When | Then)`}),(0,M.jsx)(`textarea`,{className:`${V} mt-1 min-h-[80px]`,value:e.map(e=>`${e.given} | ${e.when} | ${e.then}`).join(`
18
+ `),placeholder:`已登录且有权限 | 提交申请单 | 列表里出现一条待审批记录`,onChange:e=>t(at(e.target.value).map(e=>{let[t=``,n=``,r=``]=e.split(`|`).map(e=>e.trim());return{given:t,when:n,then:r}}))})]})}function ut({story:e,index:t,total:n,gaps:r,busy:i,onSave:a,onDelete:o,onMove:s,domId:c}){let[l,u]=(0,C.useState)(!1),[d,f]=(0,C.useState)(!1),[p,te]=(0,C.useState)(e),[ne,re]=(0,C.useState)(!1);(0,C.useEffect)(()=>{if(l||d){re(!0);return}let e=window.setTimeout(()=>re(!1),200);return()=>window.clearTimeout(e)},[l,d]);let ie=()=>{te({...e}),f(!0),u(!0)},m=e=>te(t=>({...t,...e})),ae=r.filter(e=>e.severity===`high`).length;return(0,M.jsxs)(`li`,{id:c,className:`overflow-hidden rounded-xl border bg-white transition-colors ${l||d?`border-stone-200 shadow-sm`:`border-stone-200 hover:border-stone-300`}`,children:[(0,M.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":l,"aria-label":l?`收起 ${e.id}`:`展开 ${e.id}`,className:`flex cursor-pointer items-start gap-3 px-3.5 py-3 outline-none transition-colors hover:bg-stone-50/70 focus-visible:bg-stone-50/70`,onClick:()=>u(e=>!e),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),u(e=>!e))},children:[(0,M.jsx)(`span`,{className:`mt-1 h-9 w-[3px] shrink-0 rounded-full ${it[e.priority]}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id||`待编号`}),(0,M.jsx)(x,{tone:_[e.priority],children:e.priority}),(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),r.length>0?(0,M.jsxs)(x,{tone:ae?`red`:`amber`,children:[r.length,` 个缺口`,ae?` · 高 ${ae}`:``]}):null]}),(0,M.jsx)(`p`,{className:`mt-1 line-clamp-2 text-xs text-stone-500`,children:[e.role&&`角色:${e.role}`,e.goal&&`目标:${e.goal}`].filter(Boolean).join(` · `)||`还没有写角色与目标`}),l?null:(0,M.jsxs)(`p`,{className:`mt-1 text-[11px] text-stone-400`,children:[`验收 `,e.acceptance.length,` · 异常 `,e.exceptions.length,` · 维度`,` `,e.dimensions.length]})]}),(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center gap-0.5`,onClick:e=>e.stopPropagation(),onKeyDown:e=>e.stopPropagation(),children:[(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`上移`,disabled:i||t===0,onClick:()=>s(-1),children:(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`-rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600 disabled:opacity-30`,"aria-label":`下移`,disabled:i||t>=n-1,onClick:()=>s(1),children:(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`rotate-90`})}),(0,M.jsx)(`button`,{type:`button`,className:`rounded p-1 text-stone-400 transition-colors hover:bg-stone-100 hover:text-stone-600`,"aria-label":d?`取消编辑`:`编辑`,onClick:()=>d?f(!1):ie(),children:(0,M.jsx)(S,{name:`pencil`,size:14})}),(0,M.jsx)(`button`,{type:`button`,className:`tw-icon-danger rounded p-1`,"aria-label":`删除`,disabled:i,onClick:o,children:(0,M.jsx)(S,{name:`trash`,size:14})}),(0,M.jsx)(S,{name:`chevronRight`,size:14,className:`ml-1 text-stone-300 transition-transform duration-150 ${l||d?`rotate-90`:``}`})]})]}),(0,M.jsx)(`div`,{className:`grid transition-[grid-template-rows] duration-200 ease-out motion-reduce:transition-none ${l||d?`grid-rows-[1fr]`:`grid-rows-[0fr]`}`,children:(0,M.jsxs)(`div`,{className:`min-h-0 overflow-hidden`,children:[ne&&d?(0,M.jsxs)(`div`,{className:`space-y-3 border-t border-stone-100 px-4 py-3`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`标题`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.title,onChange:e=>m({title:e.target.value})})]}),(0,M.jsxs)(`div`,{className:`grid gap-3 sm:grid-cols-2`,children:[(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`角色`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.role,onChange:e=>m({role:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`优先级`}),(0,M.jsx)(`div`,{className:`mt-1`,children:(0,M.jsx)(ee,{options:nt,value:p.priority,onChange:e=>m({priority:e}),ariaLabel:`优先级`,flat:!0})})]})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`目标`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.goal,onChange:e=>m({goal:e.target.value})})]}),(0,M.jsxs)(`label`,{className:`block`,children:[(0,M.jsx)(`span`,{className:H,children:`价值 / 备注`}),(0,M.jsx)(`input`,{className:`${B} mt-1`,value:p.value,onChange:e=>m({value:e.target.value})})]}),(0,M.jsx)(W,{label:`前置条件`,value:p.preconditions,placeholder:`已登录且拥有申请权限`,onChange:e=>m({preconditions:e})}),(0,M.jsx)(ot,{value:p.mainFlow,onChange:e=>m({mainFlow:e})}),(0,M.jsx)(st,{value:p.altFlows,onChange:e=>m({altFlows:e})}),(0,M.jsx)(ct,{value:p.exceptions,onChange:e=>m({exceptions:e})}),(0,M.jsx)(W,{label:`后置条件`,value:p.postconditions,placeholder:`申请单状态变为待审批`,onChange:e=>m({postconditions:e})}),(0,M.jsx)(lt,{value:p.acceptance,onChange:e=>m({acceptance:e})}),(0,M.jsx)(W,{label:`覆盖维度`,value:p.dimensions,placeholder:`权限、边界值、超时与失败`,onChange:e=>m({dimensions:e})}),(0,M.jsxs)(`div`,{className:`flex items-center justify-between gap-2`,children:[(0,M.jsxs)(`span`,{className:`text-xs text-stone-400`,children:[`来源条目:`,e.sourceRefs.join(`、`)||`(未关联)`]}),(0,M.jsxs)(`div`,{className:`flex gap-2`,children:[(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md border border-stone-200 px-3 text-xs text-stone-600 transition-colors hover:bg-stone-50`,onClick:()=>f(!1),children:`取消`}),(0,M.jsx)(`button`,{type:`button`,className:`h-8 rounded-md bg-[#3370ff] px-3 text-xs font-medium text-white transition-opacity hover:opacity-90 disabled:opacity-50`,disabled:i||!p.title.trim(),onClick:()=>{a(p),f(!1)},children:`保存`})]})]})]}):null,ne&&!d?(0,M.jsxs)(`div`,{className:`border-t border-stone-100 bg-stone-50/50 px-3.5 py-3.5`,children:[(0,M.jsxs)(`div`,{className:`space-y-3.5`,children:[e.value?(0,M.jsx)(U,{label:`价值`,children:e.value}):null,e.preconditions.length?(0,M.jsx)(U,{label:`前置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.preconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.mainFlow.length?(0,M.jsx)(U,{label:`主流程`,children:(0,M.jsx)(`ol`,{className:`list-decimal space-y-0.5 pl-4`,children:e.mainFlow.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.actor?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[e.actor,`:`]}):null,e.action,e.result?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.result]}):null]},t))})}):null,e.altFlows.length?(0,M.jsx)(U,{label:`替代流程`,children:(0,M.jsx)(`ul`,{className:`space-y-1.5`,children:e.altFlows.map((e,t)=>(0,M.jsxs)(`li`,{children:[(0,M.jsxs)(`p`,{className:`font-medium text-stone-700`,children:[e.name,e.trigger?(0,M.jsxs)(`span`,{className:`font-normal text-stone-500`,children:[`(触发:`,e.trigger,`)`]}):null]}),(0,M.jsx)(`ol`,{className:`mt-0.5 list-decimal space-y-0.5 pl-4 text-stone-600`,children:e.steps.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})]},t))})}):null,e.exceptions.length?(0,M.jsx)(U,{label:`异常场景`,children:(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:e.exceptions.map((e,t)=>(0,M.jsxs)(`li`,{children:[e.scenario,e.expected?(0,M.jsxs)(`span`,{className:`text-stone-500`,children:[` → `,e.expected]}):null]},t))})}):null,e.postconditions.length?(0,M.jsx)(U,{label:`后置条件`,children:(0,M.jsx)(`ul`,{className:`list-disc space-y-0.5 pl-4`,children:e.postconditions.map((e,t)=>(0,M.jsx)(`li`,{children:e},t))})}):null,e.acceptance.length?(0,M.jsx)(U,{label:`验收标准`,children:(0,M.jsx)(`ul`,{className:`space-y-1`,children:e.acceptance.map((e,t)=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-baseline gap-x-2 gap-y-0.5 rounded-md bg-white px-2 py-1 ring-1 ring-stone-100`,children:[(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Given`}),(0,M.jsx)(`span`,{children:e.given||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`When`}),(0,M.jsx)(`span`,{children:e.when||`—`}),(0,M.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:`Then`}),(0,M.jsx)(`span`,{className:e.then?`text-stone-800`:`text-red-500`,children:e.then||`(未写)`})]},t))})}):null,e.dimensions.length?(0,M.jsx)(U,{label:`覆盖维度`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.dimensions.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e))})}):null,(0,M.jsx)(U,{label:`来源条目`,children:(0,M.jsx)(`div`,{className:`flex flex-wrap gap-1`,children:e.sourceRefs.length?e.sourceRefs.map(e=>(0,M.jsx)(`span`,{className:`rounded bg-white px-1.5 py-0.5 font-mono text-[11px] text-stone-500 ring-1 ring-stone-100`,children:e},e)):(0,M.jsx)(`span`,{className:`text-amber-600`,children:`未关联(覆盖率会算不到)`})})})]}),r.length?(0,M.jsxs)(`div`,{className:`mt-3 rounded-lg border border-amber-200 bg-amber-50/70 px-3 py-2`,children:[(0,M.jsx)(`p`,{className:`text-xs font-medium text-amber-900`,children:`审查发现的问题`}),(0,M.jsx)(`ul`,{className:`mt-1 space-y-1`,children:r.map(e=>(0,M.jsxs)(`li`,{className:`flex flex-wrap items-center gap-1.5 text-xs`,children:[(0,M.jsx)(x,{tone:g[e.severity],children:v[e.severity]}),(0,M.jsx)(`span`,{className:`text-stone-500`,children:ve[e.type]}),(0,M.jsx)(`span`,{className:`text-stone-700`,children:e.title})]},e.id))})]}):null]}):null]})})]})}var dt=`reqanalysis.doc`,ft=`reqanalysis.listmode`,pt=`reqanalysis.view`,mt=`reqanalysis.tab`,ht=`reqanalysis.storykeyword`,gt=[`list`,`work`],_t=[`stories`,`check`,`outline`,`points`],vt=`reqanalysis.activity`,yt=[`info`,`tool`,`done`,`error`];function bt(e){return`${vt}.${e}`}function xt(e){if(!e)return[];let t=l(bt(e),[]);return Array.isArray(t)?t.filter(e=>{if(!e||typeof e!=`object`)return!1;let t=e;return typeof t.id==`number`&&typeof t.text==`string`&&typeof t.at==`string`&&yt.includes(t.kind)}).slice(-200):[]}var St=/\.[a-z0-9]+$/i,Ct={md:`Markdown`,markdown:`Markdown`,txt:`文本`,csv:`CSV`,docx:`Word`,xlsx:`Excel`,xls:`Excel`,doc:`Word(旧版)`,pdf:`PDF`,ppt:`PPT`,pptx:`PPT`},wt=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md bg-[#3370ff] px-3.5 text-sm font-medium text-white transition-opacity hover:opacity-90 disabled:cursor-not-allowed disabled:opacity-50`,Tt=`inline-flex h-9 items-center justify-center gap-1.5 rounded-md border border-stone-200 bg-white px-3 text-sm text-stone-700 transition-colors hover:bg-stone-50 disabled:cursor-not-allowed disabled:opacity-50`,Et=`text-xs font-semibold tracking-wide text-stone-500`;function Dt(e){return e.split(`/`).pop()||e}function Ot(e){return e.replace(St,``)}function kt(e){return(e.format||Dt(e.path).split(`.`).pop()||``).toLowerCase()}function At(e){let t=new Date(e);if(Number.isNaN(t.getTime()))return`—`;let n=e=>String(e).padStart(2,`0`),r=`${n(t.getMonth()+1)}/${n(t.getDate())} ${n(t.getHours())}:${n(t.getMinutes())}`;return t.getFullYear()===new Date().getFullYear()?r:`${t.getFullYear()}/${r}`}function jt(e){return[...e].sort((e,t)=>t.updatedAt.localeCompare(e.updatedAt))}function Mt({name:e,ready:t}){return(0,M.jsxs)(`div`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(f,{text:e,className:`min-w-0 flex-1 truncate text-xs text-stone-500`}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-stone-400`}`,children:t?`已就绪`:`未就绪`})]})}function Nt(){let e=Be(`reqAnalysis`),t=Be(`storyReview`),l=Be(`testPoints`),[u,se]=(0,C.useState)(null),[h,g]=(0,C.useState)([]),[_,ve]=(0,C.useState)(``),[v,Ee]=(0,C.useState)(null),[De,ke]=(0,C.useState)([]),[Ae,y]=(0,C.useState)(``),[Pe,Re]=(0,C.useState)(``),[b,Ge]=(0,C.useState)(null),[Ke,w]=(0,C.useState)(null),[T,qe]=(0,C.useState)(null),[E,D]=(0,C.useState)(null),[O,k]=(0,C.useState)(null),[A,j]=(0,C.useState)(null),[N,P]=(0,C.useState)([]),[Qe,F]=(0,C.useState)(``),[I,L]=(0,C.useState)(``),[R,z]=(0,C.useState)(()=>o(mt,_t,`stories`));(0,C.useEffect)(()=>{i(mt,R)},[R]);let[et,nt]=(0,C.useState)(`list`),B=(0,C.useRef)(o(pt,gt,`list`)),[V,H]=(0,C.useState)(()=>B.current===`work`),[rt,it]=(0,C.useState)(()=>o(ft,[`doc`,`story`],`doc`)),[U,at]=(0,C.useState)(()=>c(ht,``));(0,C.useEffect)(()=>{s(ht,U)},[U]);let[W,ot]=(0,C.useState)(null),[st,ct]=(0,C.useState)([]),lt=(0,C.useRef)(``),[vt,yt]=(0,C.useState)(``),[St,Nt]=(0,C.useState)(!1),[Pt,Ft]=(0,C.useState)(!1),G=(0,C.useRef)(null),K=(0,C.useRef)(null),It=(0,C.useRef)(0),Lt=(0,C.useRef)(null),Rt=(0,C.useRef)(null),zt=(0,C.useCallback)(e=>t.on||e!==`checked`&&e!==`accepted`?ye[e]:ye.decomposed,[t.on]),Bt=(0,C.useMemo)(()=>{let e=e=>+!e.supported;return[...De].sort((t,n)=>e(t)-e(n)||t.path.localeCompare(n.path,`zh`)).map(e=>{let t=kt(e),n=Ct[t]??t.toUpperCase();return{value:e.path,label:e.path,secondary:e.supported?t:`${n} · 暂不支持,请另存为 .docx / .xlsx / .md`,disabled:!e.supported}})},[De]),q=(0,C.useCallback)(e=>{G.current=e,Ee(e),g(t=>jt(t.map(t=>t.id===e.id?e:t)))},[]),J=(0,C.useCallback)((e,t=`info`)=>{It.current+=1,P(n=>[...n,{id:It.current,kind:t,text:e,at:new Date().toISOString()}])},[]),Vt=(0,C.useRef)(!1);(0,C.useEffect)(()=>{if(!_){Vt.current=!0,P([]);return}let e=xt(_);It.current=e.reduce((e,t)=>Math.max(e,t.id),0),Vt.current=!0,P(e)},[_]),(0,C.useEffect)(()=>{Vt.current?Vt.current=!1:_&&a(bt(_),N.slice(-200))},[N,_]);let Y=(0,C.useCallback)(e=>{G.current=e,Ee(e),ve(e?.id??``),s(dt,e?.id??``),e?.sourcePath&&y(e.sourcePath)},[]),X=(0,C.useCallback)(e=>{nt(e),i(pt,e)},[]),Z=(0,C.useCallback)((e,t=`stories`)=>{Y(e),z(t),X(`work`),ze(`req-analysis`)},[X,Y]),Ht=(0,C.useCallback)((e,t)=>{lt.current=t,Z(e,`stories`)},[Z]);(0,C.useEffect)(()=>{if(et!==`work`||!lt.current)return;let e=lt.current;lt.current=``;let t=0,n=requestAnimationFrame(()=>{let n=document.getElementById(`req-story-${e}`);n&&(n.scrollIntoView({block:`center`,behavior:`smooth`}),n.classList.add(`tw-req-story-focus`),t=window.setTimeout(()=>n.classList.remove(`tw-req-story-focus`),1600))});return()=>{cancelAnimationFrame(n),t&&window.clearTimeout(t)}},[et,v?.id]);let Ut=(0,C.useMemo)(()=>h.flatMap(e=>e.stories.map(t=>({doc:e,story:t}))),[h]),Wt=Ut.length,Gt=(0,C.useMemo)(()=>{let e=U.trim().toLowerCase(),t=t=>String(t??``).toLowerCase().includes(e),n=e?Ut.filter(({doc:e,story:n})=>t(n.id)||t(n.title)||t(n.role)||t(n.goal)||t(e.title)):Ut,r=[],i=new Map;for(let e of n){let t=i.get(e.doc.id);t===void 0?(i.set(e.doc.id,r.length),r.push({doc:e.doc,rows:[e]})):r[t].rows.push(e)}return r.sort((e,t)=>t.doc.updatedAt.localeCompare(e.doc.updatedAt))},[Ut,U]),Kt=(0,C.useMemo)(()=>new Set(W?.ids??[]),[W]),qt=(0,C.useCallback)((e,t)=>{ot(n=>{if(!n||n.docId!==e)return{docId:e,ids:[t]};let r=n.ids.includes(t)?n.ids.filter(e=>e!==t):[...n.ids,t];return r.length?{docId:e,ids:r}:null})},[]),Jt=(0,C.useCallback)((e,t)=>{ot(n=>n?.docId===e&&t.every(e=>n.ids.includes(e))?null:t.length?{docId:e,ids:t}:null)},[]),Yt=(0,C.useCallback)(e=>{it(e),i(ft,e)},[]);(0,C.useEffect)(()=>{let e=!0;(async()=>{if(await n(),!e)return;Ge(re());let t=await fe();if(e&&(se(t),t))try{let[t,n,r,i]=await Promise.all([me(),_e(),Me(),je()]);if(!e)return;let a=n;if((!n.exists||!n.decompose.trim())&&(await Se(!0).catch(()=>void 0),a=await _e()),!e)return;w(a);let o=r;if((!r.exists||!r.review.trim())&&(await Fe(!0).catch(()=>void 0),o=await Me()),!e)return;o.exists&&qe(o),i.exists&&D(i);let s=jt(t);g(s);let l=c(dt,``),u=s.find(e=>e.id===l)??s[0]??null;Y(u);let d=B.current;B.current=`list`,d===`work`&&u&&l&&u.id===l&&(X(`work`),ze(`req-analysis`)),H(!1)}catch(t){e&&(H(!1),L(t instanceof Error?t.message:String(t)))}})();let t=ne(()=>Ge(re()));return()=>{e=!1,t()}},[X,Y]),(0,C.useEffect)(()=>{if(!t.ready)return;if(!t.on){qe(null),z(e=>e===`check`?`stories`:e);return}if(!u||T!==null)return;let e=!0;return(async()=>{let t=await Me();(!t.exists||!t.review.trim())&&(await Fe(!0).catch(()=>void 0),t=await Me()),e&&qe(t)})(),()=>{e=!1}},[t.ready,t.on,u,T]),(0,C.useEffect)(()=>{if(!l.ready)return;if(!l.on){D(null),z(e=>e===`points`?`stories`:e);return}if(!u||E!==null)return;let e=!0;return(async()=>{let t=await je();(!t.exists||!t.generate.trim())&&(await Te(!0).catch(()=>void 0),t=await je()),e&&D(t)})(),()=>{e=!1}},[l.ready,l.on,u,E]),(0,C.useEffect)(()=>{if(!u)return;let e=!0;return pe().then(t=>{e&&ke(t)}).catch(t=>{e&&Re(t instanceof Error?t.message:String(t))}),()=>{e=!1}},[u]),(0,C.useEffect)(()=>{let e=v?.sourcePath;if(!e){yt(``);return}let t=!0;return le(e).then(e=>{t&&yt(Ce(e))}).catch(()=>{t&&yt(``)}),()=>{t=!1}},[v?.sourcePath,v?.sourceHash]),(0,C.useEffect)(()=>{let e=Lt.current;e&&(e.scrollTop=e.scrollHeight)},[N]);let Xt=!!(v?.sourceHash&&vt&&v.sourceHash!==vt),Zt=(0,C.useMemo)(()=>new Set((v?.stories??[]).flatMap(e=>e.sourceRefs)),[v?.stories]),Qt=Ke??null,$t=!!Qt?.decompose.trim(),en=(0,C.useMemo)(()=>(v?.check?.gaps??[]).filter(e=>e.selected).length,[v?.check]),Q=(0,C.useCallback)(async(e,t)=>{let n=t??G.current;if(!n)throw Error(`还没有分析文档`);let r=await m(n.id,e);return q(r),r},[q]),tn=(0,C.useCallback)(()=>{Rt.current&&window.clearTimeout(Rt.current),Rt.current=window.setTimeout(()=>{let e=G.current;e?.check&&m(e.id,{check:e.check}).catch(()=>void 0)},600)},[]),nn=(0,C.useCallback)(async e=>{if(!e)return null;let t=h.find(t=>t.sourcePath===e);if(t)return Z(t,`stories`),t;try{let t=await le(e),n=Dt(e),r=await ge({sourcePath:e,sourceTitle:n,sourceHash:Ce(t),title:Ot(n)});return g(e=>jt([r,...e])),Z(r,`stories`),J(`新建分析:${r.title}`),r}catch(e){let t=e instanceof Error?e.message:String(e);return L(t),p(t,`error`),y(G.current?.sourcePath??``),null}},[h,Z,J]),rn=!!(b?.baseURL&&b.apiKey&&b.model),an=(0,C.useCallback)(()=>!rn||!b?(p(`请先在设置里配置模型`,`error`),ie(`model`),null):b,[rn,b]),$=(0,C.useCallback)((e,t)=>({getDoc:()=>G.current,batch:t,saveOutline:async t=>{let n=await m(e.id,{outline:t});return q(n),n.outline},saveStories:async t=>{let n=await m(e.id,{stories:t});return q(n),J(`已写入 ${n.stories.length} 个用户故事`),n},saveCheck:async t=>{let n=G.current?.check,r={...t,gaps:we(n?.gaps??[],t.gaps)},i=await m(e.id,{check:r,status:`checked`});return q(i),i},saveTestPoints:async t=>{let n=await m(e.id,{testPoints:t});return q(n),n}}),[q,J]),on=(0,C.useCallback)(async()=>{let e=G.current,n=an();if(!e||!n)return;let r=Qt?.decompose.trim()??``;if(!r){p(`没有读到「${ce}」的「## 拆解」段落`,`error`);return}L(``),F(``),P([]),k(`decompose`),j({label:`拆解`,done:0,total:0,message:`正在读取来源文档`});let i=new AbortController;K.current=i;try{let a=await m(e.id,{status:`draft`,progress:{stage:`stories`,done:0,total:0,message:`正在读取来源文档`,at:new Date().toISOString()}});q(a);let o=await le(e.sourcePath);if(!o.trim())throw Error(`来源文档是空的`);let s=ae(o);if(!s.length)throw Error(`来源文档没有可拆解的内容`);j({label:`拆解`,done:0,total:s.length,message:`共 ${s.length} 批,准备拆第 1 批`}),J(s.length>1?`来源 ${o.length} 字,已分 ${s.length} 批拆解`:`来源 ${o.length} 字,单批拆解`);let c=await m(e.id,{replaceStories:!0,stories:[],outline:[],check:null,status:`draft`,sourceHash:Ce(o)});q(c);for(let t of s){if(i.signal.aborted)break;let a=G.current?.stories.length??0,o=[r,``,We,``,`## 已抽取的需求条目(sourceRefs 只能引用这些 id)`,(G.current?.outline??[]).map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
19
+ `)||`(本批还没有条目,先调用 req_set_outline)`].join(`
20
+ `),c=[`这一批是原始需求的第 ${t.index+1}/${s.length} 段${t.title?`(章节:${t.title})`:``}。只处理这一段的条目与故事,已完成的部分不要重写。`,``,`## 原始需求`,``,t.text].join(`
21
+ `);await Q({progress:{stage:`stories`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`,at:new Date().toISOString()}},G.current).catch(()=>void 0),j({label:`拆解`,done:t.index,total:s.length,message:`正在拆第 ${t.index+1}/${s.length} 批`});let l=``;for await(let r of te(n,[{role:`system`,content:o},{role:`user`,content:c}],i.signal,{tools:Je,maxToolRounds:20,runTool:(n,r)=>Ye(n,r,$(e,t.index))}))r.type===`content`?(l+=r.delta,F(e=>e+r.delta)):r.type===`tool`&&r.status===`running`&&J(`调用 ${r.name}`,`tool`);if((G.current?.stories.length??0)===a){let n=Xe(l);if(n.length){let t=xe(G.current?.stories??[],n),r=await m(e.id,{stories:t});q(r),J(`模型没调工具,已从回答里兜底解析 ${n.length} 个故事`,`info`)}else J(`第 ${t.index+1} 批没有拿到结构化故事`,`error`)}j({label:`拆解`,done:t.index+1,total:s.length,message:`第 ${t.index+1}/${s.length} 批已写入`})}if(i.signal.aborted){J(`已中断:已经写入的故事保留`,`info`);return}let l=await m(e.id,{status:`decomposed`,progress:{stage:`done`,done:s.length,total:s.length,message:`拆解完成`,at:new Date().toISOString()}});q(l),J(`拆解完成:${l.outline.length} 条需求条目、${l.stories.length} 个用户故事`,`done`),z(`stories`),t.on&&!i.signal.aborted?(p(`拆解完成,接着做用户故事审查`,`success`),await cn.current?.(!0)):p(`拆解完成`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?J(`已中断:已经写入的故事保留`,`info`):(L(t),J(`拆解失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,q,J,Qt,an,t.on,Q]),sn=(0,C.useCallback)(async(e=!1)=>{let t=G.current;if(!t)return;if(!t.stories.length){e||p(`还没有用户故事,先做一次拆解`,`info`);return}L(``),e||(F(``),P([])),k(`audit`),j({label:`审查用户故事`,done:0,total:2,message:`正在跑规则体检`});let n=new AbortController;K.current=n;try{let e=ue(t),r=await m(t.id,{check:{...e,gaps:we(t.check?.gaps??[],e.gaps)},status:`checked`,progress:{stage:`audit`,done:0,total:1,message:`规则体检完成,等待模型评审`,at:new Date().toISOString()}});q(r),J(`规则体检:覆盖率 ${Math.round(e.coverage.rate*100)}%,${e.gaps.length} 个缺口`),j({label:`审查用户故事`,done:1,total:2,message:`规则体检完成,等待模型评审`});let i=T?.review.trim()??``,a=rn?b:null;if(!a||!i){J(a?`「用户故事审查提示词.md」缺少「## 审查」段落,只保留规则结果`:`没有配置模型,只保留规则结果`,`info`),z(`check`);return}let o=!1,s=$(t,90),c=s.saveCheck;s.saveCheck=async e=>{o=!0;let t=await c(e);return J(`模型体检:整体 ${t.check?.gaps.length??0} 个缺口`,`done`),t};let l=G.current??r,u=[`## 需求条目`,l.outline.length?l.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
22
+ `):`(无)`,``,`## 用户故事(${l.stories.length} 条)`,"```json",JSON.stringify(l.stories,null,2),"```"].join(`
23
+ `);for await(let e of te(a,[{role:`system`,content:`${i}\n\n${We}`},{role:`user`,content:u}],n.signal,{tools:Je.filter(e=>e.function.name===`req_save_check`),maxToolRounds:8,runTool:(e,t)=>Ye(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);o||(J(`模型没有提交体检结果,当前只保留规则结果`,`error`),p(`模型没有提交体检结果,只保留了规则检查`,`error`)),j({label:`审查用户故事`,done:2,total:2,message:o?`模型评审完成`:`已保留规则结果`}),z(`check`)}catch(e){let t=e instanceof Error?e.message:String(e);n.signal.aborted?J(`已中断:规则体检结果已保留`,`info`):(L(t),J(`体检失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,rn,q,J,T,b]),cn=(0,C.useRef)(null);cn.current=sn;let ln=(0,C.useCallback)(async()=>{let e=G.current,t=an();if(!e||!t)return;let n=(e.check?.gaps??[]).filter(e=>e.selected);if(!n.length){p(`先在缺口清单里勾选要补写的条目`,`info`);return}let r=T?.fix.trim()??``;if(!r){p(`「用户故事审查提示词.md」缺少「## 补写」段落`,`error`);return}L(``),F(``),P([]),k(`fix`);let i=new AbortController;K.current=i;try{J(`按 ${n.length} 个勾选缺口补写`,`info`);let a=new Map(e.stories.map(e=>[e.id,e.title])),o=[`## 当前故事集(${e.stories.length} 条,没被点名的必须原样保留)`,"```json",JSON.stringify(e.stories,null,2),"```",``,`## 勾选待补写的缺口`,n.map(e=>{let t=e.storyId?`${e.storyId} ${a.get(e.storyId)??``}`:`全局问题`;return[`- [${e.severity}] ${t}|${e.title}`,e.detail?` 原因:${e.detail}`:``,e.suggestion?` 建议:${e.suggestion}`:``].filter(Boolean).join(`
24
+ `)}).join(`
25
+ `)].join(`
26
+ `),s=$(e,90),c=!1,l=s.saveStories;s.saveStories=async e=>(c=!0,l(e));for await(let e of te(t,[{role:`system`,content:`${r}\n\n${We}`},{role:`user`,content:o}],i.signal,{tools:Je.filter(e=>e.function.name===`req_set_stories`),maxToolRounds:10,runTool:(e,t)=>Ye(e,t,s)}))e.type===`content`?F(t=>t+e.delta):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);if(!c){J(`模型没有提交补写结果,故事集保持不变`,`error`),p(`模型没有提交补写结果`,`error`);return}let u=G.current;if(u){let e=ue(u),t=await m(u.id,{check:e,status:`decomposed`});q(t)}J(`补写完成,已按规则重算覆盖率;建议再跑一次体检`,`done`),z(`check`),p(`补写完成,建议再跑一次体检`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);i.signal.aborted?J(`已中断:已经写入的改动保留`,`info`):(L(t),J(`补写失败:${t}`,`error`))}finally{k(null),K.current=null}},[$,q,J,an,T]),un=(0,C.useCallback)(async()=>{let e=G.current,t=an();if(!e||!t)return;if(!e.stories.length){p(`还没有用户故事,先做一次拆解`,`info`);return}let n=E?.generate.trim()??``;if(!n){p(`没有读到「${Oe}」的「## 生成」段落`,`error`);return}L(``),F(``),P([]),k(`testpoints`),z(`points`),j({label:`生成测试点`,done:0,total:2,message:`正在整理用户故事,等待模型生成`}),await Q({progress:{stage:`points`,done:0,total:2,message:`正在生成测试点`,at:new Date().toISOString()}},e).catch(()=>void 0),J(`开始生成测试点(五维覆盖,P0–P3)`,`info`);let r=new AbortController;K.current=r;try{let i=$(e,90),a=!1,o=i.saveTestPoints;i.saveTestPoints=async e=>{a=!0,j({label:`生成测试点`,done:1,total:2,message:`正在写入测试点`});let t=await o(e);return J(`测试点已写入:${t.testPoints?.points.length??0} 条`,`done`),t};let s=[`## 分析标题\n${e.title||`未命名分析`}`,``,`## 需求条目`,e.outline.length?e.outline.map(e=>`- ${e.id} ${e.title}${e.quote?`(原文:${e.quote})`:``}`).join(`
27
+ `):`(无)`,``,`## 用户故事(${e.stories.length} 条)`,"```json",JSON.stringify(e.stories,null,2),"```"].join(`
28
+ `),c=``;for await(let e of te(t,[{role:`system`,content:`${n}\n\n${We}`},{role:`user`,content:s}],r.signal,{tools:Je.filter(e=>e.function.name===`req_save_test_points`),maxToolRounds:8,runTool:(e,t)=>Ye(e,t,i)}))e.type===`content`?(c+=e.delta,F(t=>t+e.delta)):e.type===`tool`&&e.status===`running`&&J(`调用 ${e.name}`,`tool`);if(!a){let t=Ze(c,e.stories.map(e=>e.id));t&&(await i.saveTestPoints(t),a=!0,J(`模型没调工具,已从回答里兜底解析 ${t.points.length} 条`,`info`))}if(!a)J(`模型没有提交测试点,原结果保持不变`,`error`),p(`模型没有提交测试点,原结果保持不变`,`error`);else{let e=G.current?.testPoints?.points??[],t=t=>e.filter(e=>e.priority===t).length;J(`测试点完成:${e.length} 条(P0 ${t(`P0`)} / P1 ${t(`P1`)} / P2 ${t(`P2`)} / P3 ${t(`P3`)})`,`done`),j({label:`生成测试点`,done:2,total:2,message:`已生成 ${e.length} 条`}),await Q({progress:{stage:`done`,done:2,total:2,message:`测试点已生成 ${e.length} 条`,at:new Date().toISOString()}},G.current).catch(()=>void 0),p(`测试点已生成`,`success`)}}catch(e){let t=e instanceof Error?e.message:String(e);r.signal.aborted?J(`已中断:已经生成的测试点保留`,`info`):(L(t),J(`生成测试点失败:${t}`,`error`))}finally{k(null),j(null),K.current=null}},[$,J,an,Q,E]),dn=(0,C.useCallback)(async()=>{let e=G.current;if(!e?.testPoints)p(`还没有测试点可导出`,`info`);else try{let t=await Ne(e);J(`已导出 ${t}`,`done`)}catch(e){p(`导出失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[J]),fn=(0,C.useCallback)(()=>{let e=G.current;if(!e?.testPoints){p(`还没有测试点可导出`,`info`);return}let t=Ie(e);J(`已导出 ${t}`,`done`)},[J]),pn=(0,C.useCallback)(async e=>{let t=G.current;if(t)try{await Q({stories:e},t)}catch(e){p(`保存失败:${e instanceof Error?e.message:String(e)}`,`error`)}},[Q]),mn=(0,C.useCallback)((e,t)=>{let n=G.current;if(!n)return;let r=n.stories.map((n,r)=>r===e?{...t,id:n.id}:n);pn(r)},[pn]),hn=(0,C.useCallback)(e=>{let t=G.current;t&&pn(t.stories.filter((t,n)=>n!==e))},[pn]),gn=(0,C.useCallback)((e,t)=>{let n=G.current;if(!n)return;let r=e+t;if(r<0||r>=n.stories.length)return;let i=[...n.stories],a=i[e],o=i[r];a&&o&&(i[e]=o,i[r]=a,pn(i))},[pn]),_n=(0,C.useCallback)((e,t)=>{let n=G.current;if(!n?.check)return;let r={...n,check:{...n.check,gaps:n.check.gaps.map(n=>n.id===e?{...n,selected:t}:n)}};q(r),tn()},[q,tn]),vn=(0,C.useCallback)(e=>{let t=G.current;if(!t?.check)return;let n={...t,check:{...t.check,gaps:t.check.gaps.map(t=>({...t,selected:e}))}};q(n),tn()},[q,tn]),yn=(0,C.useCallback)(e=>{let t=G.current,n=e.trim();t&&n&&n!==t.title&&Q({title:n},t).catch(()=>void 0)},[Q]),bn=(0,C.useCallback)(async()=>{let e=G.current;if(e)try{await be(e.id);let t=h.filter(t=>t.id!==e.id);g(t),Y(t[0]??null),X(`list`),p(`已删除分析记录`,`success`)}catch(e){p(`删除失败:${e instanceof Error?e.message:String(e)}`,`error`)}finally{Nt(!1)}},[X,h,Y]),xn=(0,C.useCallback)(()=>{let e=G.current;if(!e)return;let t=new Blob([oe(e)],{type:`text/markdown;charset=utf-8`}),n=URL.createObjectURL(t),r=document.createElement(`a`);r.href=n,r.download=de(e),document.body.appendChild(r),r.click(),r.remove(),window.setTimeout(()=>URL.revokeObjectURL(n),1e3),p(`已导出 Markdown`,`success`)},[]),Sn=(0,C.useCallback)(()=>{let e=G.current;if(!e?.check)return;let t=Le(e,e.check);p(`已导出 ${t}`,`success`)},[]),Cn=(0,C.useCallback)(()=>{K.current?.abort()},[]);if(!e.ready)return(0,M.jsx)(He,{label:`正在读取插件开关`});if(!e.on)return(0,M.jsx)(Ve,{children:r(`reqAnalysis`)});if(u===null)return(0,M.jsx)(He,{label:`正在连接需求分析服务`});if(!u)return(0,M.jsx)(Ve,{children:"需求分析需要本地服务,当前未就绪:确认服务已升级到最新版本并重启(`lantern` 一体服务或 `npm run dev`),静态部署的页面用不了。"});if(V)return(0,M.jsx)(He,{label:`正在回到上次的分析`});let wn=v?.outline.filter(e=>Zt.has(e.id)).length??0,Tn=v?.check?.gaps??[],En=(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 flex-col gap-3`,children:[(0,M.jsxs)(`section`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white px-4 py-3`,children:[(0,M.jsxs)(`div`,{className:`flex flex-wrap items-end gap-3`,children:[(0,M.jsxs)(`div`,{className:`min-w-[240px] flex-1`,children:[(0,M.jsx)(`p`,{className:Et,children:`新建分析`}),(0,M.jsx)(`div`,{className:`mt-1.5 max-w-[440px]`,children:(0,M.jsx)(ee,{options:Bt,value:Ae,onChange:e=>{y(e),e&&nn(e)},triggerTitle:Ae||`选择来源需求文档…`,ariaLabel:`选择来源需求文档`,searchable:!0,searchPlaceholder:`搜索文件名或路径…`,flat:!0})})]}),(0,M.jsxs)(`span`,{className:`pb-1 text-[11px] text-stone-400`,children:[`共 `,h.length,` 份分析`]})]}),Pe?(0,M.jsxs)(`p`,{className:`mt-2 text-xs leading-relaxed text-amber-700`,children:[`读不到需求文档库:`,Pe,(0,M.jsx)(`br`,{}),`请先启用「需求文档库」插件,或确认 `,he,` 之外的内容目录没有被移动。`]}):null]}),I?(0,M.jsxs)(`div`,{className:`flex shrink-0 items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,(0,M.jsxs)(`section`,{className:`flex min-h-0 flex-1 flex-col overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 flex-wrap items-center gap-2 border-b border-stone-100 px-3 py-2`,children:[(0,M.jsxs)(`div`,{className:`inline-flex rounded-lg border border-stone-200 bg-stone-50 p-0.5`,children:[(0,M.jsx)(`button`,{type:`button`,onClick:()=>Yt(`doc`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${rt===`doc`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按需求说明书`}),(0,M.jsx)(`button`,{type:`button`,onClick:()=>Yt(`story`),className:`h-7 rounded-md px-2.5 text-xs transition-colors ${rt===`story`?`bg-white text-stone-900 shadow-sm`:`text-stone-500 hover:text-stone-700`}`,children:`按用户故事`})]}),rt===`story`?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`label`,{className:`relative block`,children:[(0,M.jsx)(S,{name:`search`,size:14,className:`pointer-events-none absolute left-2.5 top-1/2 -translate-y-1/2 text-stone-400`}),(0,M.jsx)(`input`,{value:U,onChange:e=>at(e.target.value),placeholder:`搜索编号 / 标题 / 角色…`,className:`h-8 w-52 rounded-lg border border-stone-200 bg-white pl-8 pr-3 text-xs text-stone-800 outline-none transition-colors focus:border-[#3370ff]`})]}),(0,M.jsxs)(`span`,{className:`text-[11px] text-stone-400`,children:[Wt,` 个故事`,W?` · 已选 ${W.ids.length}`:``]}),(0,M.jsx)(`button`,{type:`button`,disabled:!W,onClick:()=>{if(!W)return;let e=new URLSearchParams({plugin:`caseGen`,reqDoc:W.docId,stories:W.ids.join(`,`)});window.location.href=`/workbench/?${e.toString()}`},className:`${wt} ml-auto h-8 text-xs`,children:`用选中故事生成用例`})]}):(0,M.jsxs)(`span`,{className:`ml-auto text-[11px] text-stone-400`,children:[h.length,` 份分析 · `,Wt,` 个故事`]})]}),(0,M.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto`,children:rt===`doc`?h.length?(0,M.jsx)(`ul`,{className:`divide-y divide-stone-100`,children:h.map(e=>{let t=zt(e.status);return(0,M.jsxs)(`li`,{className:`flex items-center gap-3 px-4 py-3 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center text-left`,onClick:()=>Z(e,`stories`),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`truncate text-sm font-medium text-stone-800`,children:e.title}),(0,M.jsx)(x,{tone:t.tone,children:t.label})]}),(0,M.jsxs)(`span`,{className:`mt-1 flex flex-wrap items-center gap-x-3 gap-y-0.5 text-[11px] text-stone-400`,children:[(0,M.jsx)(`span`,{className:`truncate`,children:e.sourcePath||`(未指定来源)`}),(0,M.jsxs)(`span`,{children:[`用户故事 `,e.stories.length]}),(0,M.jsxs)(`span`,{children:[`需求条目 `,e.outline.length]}),(0,M.jsx)(`span`,{children:At(e.updatedAt)})]})]})}),(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 shrink-0 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-700 transition-colors hover:border-[#3370ff] hover:text-[#3370ff]`,onClick:()=>Z(e,`stories`),children:[`用户故事`,(0,M.jsx)(S,{name:`chevronRight`,size:13})]}),(0,M.jsx)(`button`,{type:`button`,"aria-label":`删除 ${e.title}`,className:`tw-icon-danger flex h-8 w-8 shrink-0 items-center justify-center rounded-md`,onClick:()=>{Y(e),Nt(!0)},children:(0,M.jsx)(S,{name:`trash`,size:14})})]},e.id)})}):(0,M.jsx)(Ue,{icon:`file`,title:`还没有分析记录`,hint:`上面选一份需求文档,系统会新建一份分析并进入用户故事拆解。`}):Gt.length?(0,M.jsx)(`div`,{className:`divide-y divide-stone-100`,children:Gt.map(({doc:e,rows:t})=>{let n=st.includes(e.id),r=t.map(e=>e.story.id),i=W?.docId===e.id&&r.length>0&&r.every(e=>Kt.has(e));return(0,M.jsxs)(`section`,{children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2 bg-stone-50/70 px-3 py-1.5`,children:[(0,M.jsx)(`input`,{type:`checkbox`,"aria-label":`选中 ${e.title} 的全部故事`,checked:i,onChange:()=>Jt(e.id,r)}),(0,M.jsxs)(`button`,{type:`button`,className:`flex min-w-0 flex-1 items-center gap-1.5 text-left`,onClick:()=>ct(t=>t.includes(e.id)?t.filter(t=>t!==e.id):[...t,e.id]),children:[(0,M.jsx)(S,{name:n?`chevronRight`:`chevronDown`,size:13,className:`shrink-0 text-stone-400`}),(0,M.jsx)(`span`,{className:`truncate text-xs font-medium text-stone-700`,children:e.title}),(0,M.jsxs)(`span`,{className:`shrink-0 text-[11px] text-stone-400`,children:[t.length,` 个故事 · `,At(e.updatedAt)]})]}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-[11px] text-[#3370ff] hover:underline`,onClick:()=>Z(e,`stories`),children:`打开拆解`})]}),n?null:(0,M.jsx)(`ul`,{className:`divide-y divide-stone-50`,children:t.map(({story:t})=>(0,M.jsxs)(`li`,{className:`flex items-start gap-2 px-4 py-2 transition-colors hover:bg-stone-50`,children:[(0,M.jsx)(`input`,{type:`checkbox`,className:`mt-1`,"aria-label":`选中 ${t.id}`,checked:Kt.has(t.id)&&W?.docId===e.id,onChange:()=>qt(e.id,t.id)}),(0,M.jsxs)(`button`,{type:`button`,className:`min-w-0 flex-1 text-left`,onClick:()=>Ht(e,t.id),children:[(0,M.jsxs)(`span`,{className:`flex min-w-0 items-center gap-2`,children:[(0,M.jsx)(`span`,{className:`shrink-0 font-mono text-[11px] text-stone-400`,children:t.id}),(0,M.jsx)(`span`,{className:`truncate text-sm text-stone-800`,children:t.title})]}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex flex-wrap items-center gap-x-2.5 gap-y-0.5 text-[11px] text-stone-400`,children:[t.role?(0,M.jsxs)(`span`,{children:[`角色:`,t.role]}):null,(0,M.jsxs)(`span`,{children:[`优先级 `,t.priority]}),(0,M.jsxs)(`span`,{children:[`验收 `,t.acceptance.length]}),(0,M.jsxs)(`span`,{children:[`异常 `,t.exceptions.length]}),(0,M.jsxs)(`span`,{children:[`维度 `,t.dimensions.length]})]})]})]},`${e.id}-${t.id}`))})]},e.id)})}):(0,M.jsx)(Ue,{icon:`file`,title:U?`没有匹配的用户故事`:`还没有用户故事`,hint:U?`换个编号、标题或角色再试。`:`先按「需求说明书」选中一份文档拆解,故事会自动出现在这里。`})})]})]});return(0,M.jsxs)(`div`,{className:`flex h-full min-h-0 flex-1 flex-col p-3`,children:[et===`list`?En:(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`div`,{className:`mb-2 flex shrink-0 items-center gap-2`,children:[(0,M.jsxs)(`button`,{type:`button`,className:`inline-flex h-8 items-center gap-1 rounded-md border border-stone-200 bg-white px-2.5 text-xs text-stone-600 transition-colors hover:border-stone-300 hover:text-stone-800`,onClick:()=>{y(``),L(``),X(`list`)},children:[(0,M.jsx)(S,{name:`arrowLeft`,size:14}),`返回列表`]}),(0,M.jsx)(`span`,{className:`min-w-0 truncate text-xs text-stone-400`,children:v?.title?`用户故事 · ${v.title}`:`用户故事`})]}),(0,M.jsxs)(`div`,{className:`flex min-h-0 flex-1 gap-4`,children:[(0,M.jsxs)(`aside`,{className:`flex w-[280px] shrink-0 flex-col gap-3 overflow-y-auto pb-1`,children:[(0,M.jsxs)(`section`,{"data-hint-width":!0,className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Et,children:`分析记录`}),(0,M.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:h.length})]}),(0,M.jsx)(`div`,{className:`px-2 py-2`,children:h.length?(0,M.jsx)(`ul`,{className:`space-y-0.5`,children:h.map(e=>{let t=e.id===_,n=zt(e.status);return(0,M.jsx)(`li`,{children:(0,M.jsx)(`button`,{type:`button`,className:`flex w-full items-start gap-2 rounded-lg px-2 py-1.5 text-left transition-colors ${t?`bg-[#eef3ff]`:`hover:bg-stone-50`}`,onClick:()=>Y(e),children:(0,M.jsxs)(`span`,{className:`min-w-0 flex-1`,children:[(0,M.jsx)(f,{text:e.title,matchAnchorWidth:!0,className:`block truncate text-xs ${t?`font-medium text-[#1f4fd8]`:`text-stone-700`}`}),(0,M.jsxs)(`span`,{className:`mt-0.5 flex items-center gap-1 text-[11px] text-stone-400`,children:[(0,M.jsx)(x,{tone:n.tone,children:n.label}),(0,M.jsxs)(`span`,{children:[e.stories.length,` 个故事`]})]})]})})},e.id)})}):(0,M.jsx)(`p`,{className:`px-1.5 py-1 text-xs text-stone-400`,children:`还没有分析记录,选一份来源文档开始。`})})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Et,children:`提示词`})}),(0,M.jsxs)(`div`,{className:`px-3.5 py-3`,children:[(0,M.jsxs)(`div`,{className:`space-y-1.5`,children:[(0,M.jsx)(Mt,{name:ce,ready:$t}),(0,M.jsx)(Mt,{name:T?.file??`用户故事审查提示词.md`,ready:t.on&&!!T?.review.trim()&&!!T?.fix.trim()}),(0,M.jsx)(Mt,{name:Oe,ready:l.on&&!!E?.generate.trim()})]}),(0,M.jsx)(`p`,{className:`mt-2 text-[11px] ${rn?`text-stone-400`:`text-amber-700`}`,children:rn?`模型:${b?.model}`:`还没配置模型`})]})]}),(0,M.jsxs)(`section`,{className:`rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsx)(`div`,{className:`border-b border-stone-100 px-3.5 py-2.5`,children:(0,M.jsx)(`p`,{className:Et,children:`动作`})}),(0,M.jsxs)(`div`,{className:`space-y-2 px-3.5 py-3`,children:[(0,M.jsx)(`button`,{type:`button`,className:`${wt} w-full`,disabled:!v||!!O||!v.sourcePath,onClick:()=>{v?.stories.length?Ft(!0):on()},children:O===`decompose`?`拆解中…`:v?.stories.length?`重新拆解`:`开始拆解`}),t.on?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void sn(),children:O===`audit`?`审查中…`:v?.check?`重新审查用户故事`:`用户故事审查`}):null,l.on?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v||!!O||!v.stories.length,onClick:()=>void un(),children:O===`testpoints`?`生成中…`:v?.testPoints?`重新生成测试点`:`生成测试点`}):null,O?(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,onClick:Cn,children:`中断`}):(0,M.jsx)(`button`,{type:`button`,className:`${Tt} w-full`,disabled:!v,onClick:xn,children:`导出 Markdown`}),v&&!O?(0,M.jsx)(`button`,{type:`button`,className:`h-8 w-full rounded-md text-xs text-stone-400 transition-colors hover:bg-red-50 hover:text-red-500`,onClick:()=>Nt(!0),children:`删除这份分析`}):null]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-[140px] flex-1 flex-col rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`flex shrink-0 items-center justify-between border-b border-stone-100 px-3.5 py-2.5`,children:[(0,M.jsx)(`p`,{className:Et,children:`活动日志`}),N.length?(0,M.jsx)(`button`,{type:`button`,className:`text-[11px] text-stone-400 transition-colors hover:text-stone-600`,onClick:()=>P([]),children:`清空`}):null]}),(0,M.jsx)(`div`,{ref:Lt,className:`min-h-0 flex-1 space-y-1 overflow-y-auto px-3.5 py-2.5`,children:N.length?N.map(e=>(0,M.jsxs)(`p`,{className:`flex gap-1.5 text-[11px] leading-relaxed`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${e.kind===`error`?`bg-red-500`:e.kind===`done`?`bg-emerald-500`:e.kind===`tool`?`bg-[#3370ff]`:`bg-stone-300`}`,"aria-hidden":`true`}),(0,M.jsx)(`span`,{className:e.kind===`error`?`text-red-600`:`text-stone-500`,children:e.text})]},e.id)):(0,M.jsx)(`p`,{className:`text-[11px] leading-relaxed text-stone-400`,children:`拆解 / 审查的过程会记在这里:抽取需求条目、写故事、跑审查与补写。`})})]})]}),(0,M.jsxs)(`section`,{className:`flex min-h-0 min-w-0 flex-1 flex-col`,children:[I?(0,M.jsxs)(`div`,{className:`mb-2 flex items-start justify-between gap-2 rounded-lg border border-red-200 bg-red-50 px-3 py-2 text-xs text-red-700`,children:[(0,M.jsx)(`span`,{className:`break-all`,children:I}),(0,M.jsx)(`button`,{type:`button`,className:`shrink-0 text-red-400`,onClick:()=>L(``),children:`✕`})]}):null,v?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsxs)(`header`,{className:`shrink-0 rounded-xl border border-stone-200 bg-white`,children:[(0,M.jsxs)(`div`,{className:`px-4 pt-3`,children:[(0,M.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,M.jsx)(`input`,{className:`min-w-0 flex-1 rounded-md border border-transparent bg-transparent px-1 py-0.5 text-[15px] font-semibold text-stone-800 outline-none transition-colors hover:border-stone-200 focus:border-[#3370ff] focus:bg-white`,defaultValue:v.title,"aria-label":`分析标题`,onBlur:e=>yn(e.target.value)},v.id),O?(0,M.jsxs)(`span`,{className:`inline-flex shrink-0 items-center gap-1.5 text-xs text-stone-500`,children:[(0,M.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`}),A?A.message:O===`decompose`?`拆解中`:O===`audit`?`审查中`:O===`testpoints`?`生成测试点中`:O===`fix`?`补写中`:`处理中`,A&&A.total>0?(0,M.jsxs)(`span`,{className:`tabular-nums text-stone-400`,children:[Math.round(Math.min(A.done,A.total)/A.total*100),`%`]}):null]}):null,(0,M.jsx)(x,{tone:zt(v.status).tone,children:zt(v.status).label})]}),O?(0,M.jsx)(`div`,{className:`mt-2`,children:(0,M.jsx)(`div`,{className:`tw-run-track`,role:`progressbar`,"aria-label":`${A?.label??`任务`}进度`,"aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":A&&A.total>0?Math.round(Math.min(A.done,A.total)/A.total*100):void 0,children:(0,M.jsx)(`div`,{className:A&&A.total>0?`tw-run-fill`:`tw-run-fill tw-run-fill--indeterminate`,style:A&&A.total>0?{width:`${Math.round(Math.min(A.done,A.total)/A.total*100)}%`}:void 0})})}):null,(0,M.jsxs)(`div`,{className:`mt-2 flex min-w-0 items-center gap-2.5 text-[11px] text-stone-400`,children:[(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`故事`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.stories.length})]}),(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`条目`,` `,(0,M.jsxs)(`span`,{className:`font-medium text-stone-600`,children:[wn,`/`,v.outline.length]}),` `,`覆盖`]}),t.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`缺口`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:Tn.length}),en?` · 已选 ${en}`:``]}),v.check?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`覆盖率`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.check.coverage.total?`${Math.round(v.check.coverage.rate*100)}%`:`—`})]})]}):null]}):null,l.on?(0,M.jsxs)(M.Fragment,{children:[(0,M.jsx)(`span`,{className:`h-3 w-px shrink-0 bg-stone-200`,"aria-hidden":`true`}),(0,M.jsxs)(`span`,{className:`shrink-0`,children:[`测试点`,` `,(0,M.jsx)(`span`,{className:`font-medium text-stone-600`,children:v.testPoints?.points.length??0})]})]}):null,(0,M.jsxs)(`span`,{className:`ml-auto min-w-0 truncate pl-2`,children:[`来源:`,v.sourcePath]}),Xt?(0,M.jsx)(`span`,{className:`shrink-0 rounded bg-amber-50 px-1.5 py-0.5 text-[10px] text-amber-700`,children:`源文档已更新`}):null]})]}),(0,M.jsx)(`div`,{role:`tablist`,"aria-label":`需求分析视图`,className:`mt-2.5 flex items-center gap-1 border-b border-stone-100 px-2`,children:[{id:`stories`,label:`用户故事`,count:v.stories.length},{id:`check`,label:`审查结果`,count:Tn.length},{id:`outline`,label:`需求条目`,count:v.outline.length},{id:`points`,label:`测试点`,count:v.testPoints?.points.length??0}].filter(e=>(e.id!==`check`||t.on)&&(e.id!==`points`||l.on)).map(e=>{let t=R===e.id;return(0,M.jsxs)(`button`,{type:`button`,role:`tab`,"aria-selected":t,className:`-mb-px flex items-center gap-1.5 border-b-2 px-3 py-2 text-xs transition-colors ${t?`border-[#3370ff] font-medium text-[#3370ff]`:`border-transparent text-stone-500 hover:text-stone-800`}`,onClick:()=>z(e.id),children:[e.label,(0,M.jsx)(`span`,{className:`rounded-full px-1.5 text-[10px] leading-4 tabular-nums ${t?`bg-[#eaf1ff] text-[#3370ff]`:`bg-stone-100 text-stone-400`}`,children:e.count})]},e.id)})})]}),(0,M.jsxs)(`div`,{className:`mt-3 min-h-0 flex-1 overflow-y-auto pr-1`,children:[R===`stories`?v.stories.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.stories.map((e,t)=>(0,M.jsx)(ut,{story:e,index:t,total:v.stories.length,gaps:Tn.filter(t=>t.storyId===e.id),busy:!!O,onSave:e=>mn(t,e),onDelete:()=>hn(t),onMove:e=>gn(t,e),domId:e.id?`req-story-${e.id}`:void 0},`${e.id}-${t}`))}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有用户故事`,hint:`点左侧「开始拆解」,会先抽需求条目再拆故事。`})}):null,R===`check`&&t.on?(0,M.jsx)($e,{check:v.check,stories:v.stories,busy:!!O,onToggleGap:_n,onToggleAll:vn,onFix:()=>void ln(),onReview:()=>void sn(),onExport:Sn}):null,R===`points`&&l.on?(0,M.jsx)(tt,{doc:v,generating:O===`testpoints`,busy:!!O,promptReady:!!E?.generate.trim(),onGenerate:()=>void un(),onExportXmind:()=>void dn(),onExportMarkdown:fn}):null,R===`outline`?v.outline.length?(0,M.jsx)(`ul`,{className:`space-y-2`,children:v.outline.map(e=>{let t=Zt.has(e.id);return(0,M.jsx)(`li`,{className:`rounded-xl border border-stone-200 bg-white px-4 py-2.5`,children:(0,M.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,M.jsx)(`span`,{className:`mt-1.5 h-1.5 w-1.5 shrink-0 rounded-full ${t?`bg-emerald-500`:`bg-amber-400`}`,"aria-hidden":`true`}),(0,M.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,M.jsxs)(`p`,{className:`text-sm text-stone-800`,children:[(0,M.jsx)(`span`,{className:`mr-1.5 rounded bg-stone-100 px-1.5 py-0.5 font-mono text-[11px] text-stone-500`,children:e.id}),e.title]}),e.quote?(0,M.jsx)(`p`,{className:`mt-1 border-l-2 border-stone-200 pl-2 text-xs leading-relaxed text-stone-400`,children:e.quote}):null]}),(0,M.jsx)(`span`,{className:`shrink-0 text-[11px] ${t?`text-emerald-600`:`text-amber-600`}`,children:t?`已覆盖`:`未覆盖`})]})},e.id)})}):(0,M.jsx)(`div`,{className:`flex items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有需求条目`,hint:`拆解时模型会先抽条目,覆盖率按条目统计。`})}):null]}),Qe?(0,M.jsxs)(`details`,{className:`mt-2 shrink-0 rounded-xl border border-stone-200 bg-white px-3 py-2`,children:[(0,M.jsx)(`summary`,{className:`cursor-pointer text-xs text-stone-500`,children:`模型说明(本轮)`}),(0,M.jsx)(`pre`,{className:`mt-1 max-h-[180px] overflow-y-auto whitespace-pre-wrap break-words text-[11px] leading-relaxed text-stone-600`,children:Qe})]}):null]}):(0,M.jsx)(`div`,{className:`flex min-h-0 flex-1 items-center justify-center rounded-xl border border-stone-200 bg-white`,children:(0,M.jsx)(Ue,{icon:`file`,title:`还没有选来源`,hint:`左侧选一份「需求文档库」里的 Word / Excel / Markdown / txt,系统会新建一份分析。`})})]})]})]}),(0,M.jsx)(d,{open:St,title:`删除分析记录`,message:`确认删除「${v?.title??``}」?故事、需求条目、体检报告与测试点都会一起删掉,来源需求文档不受影响。`,confirmLabel:`删除`,danger:`solid`,onClose:()=>Nt(!1),onConfirm:()=>void bn()}),(0,M.jsx)(d,{open:Pt,title:`重新拆解`,message:`重新拆解会用模型结果替换当前 ${v?.stories.length??0} 个用户故事,旧体检报告、测试点与需求条目也会一起清掉,编号从 US-001 重新开始。`,confirmLabel:`重新拆解`,onClose:()=>Ft(!1),onConfirm:()=>{Ft(!1),on()}})]})}export{Nt as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n}from"./app-config.CF1xVPmo.js";import{i as r,o as i,s as a}from"./plugins.DYyAjBXb.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./ConfirmDialog.CsMwWevK.js";import{n as c,t as ee}from"./DocsPager.v4kQH163.js";import{showToast as l}from"./Toast.BO2NFckG.js";import{a as u,c as te,f as ne,h as re,i as ie,l as ae,m as oe,n as se,o as d,p as ce,r as f,s as p,t as le,u as ue}from"./project-docs.Cd2gKPKh.js";import{n as de}from"./doc-roots.DAJP9Svr.js";import{t as fe}from"./useListAnim.BoerpmsB.js";import{t as m}from"./NamePromptDialog.CS1pTTVl.js";var h=e(t(),1),g=o(),pe=5;function _({className:e=`w-4 h-4`,open:t=!1}){return(0,g.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:t?(0,g.jsx)(`path`,{d:`M6 14l1.45-2.9A2 2 0 0 1 9.24 10H20a2 2 0 0 1 1.94 2.5l-1.55 6a2 2 0 0 1-1.94 1.5H4a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h3.9a2 2 0 0 1 1.69.9l.81 1.2a2 2 0 0 0 1.67.9H18a2 2 0 0 1 2 2v2`}):(0,g.jsx)(`path`,{d:`M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V7z`})})}function v({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M21.17 6.81a1 1 0 0 0-3.99-3.99L3.84 16.17a2 2 0 0 0-.5.83l-1.32 4.35a.5.5 0 0 0 .62.62l4.35-1.32a2 2 0 0 0 .83-.5z`}),(0,g.jsx)(`path`,{d:`m15 5 4 4`})]})}function y({className:e=`w-3 h-3`}){return(0,g.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,strokeLinecap:`round`,strokeLinejoin:`round`,"aria-hidden":`true`,children:[(0,g.jsx)(`path`,{d:`M3 6h18`}),(0,g.jsx)(`path`,{d:`M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6`}),(0,g.jsx)(`path`,{d:`M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2`}),(0,g.jsx)(`path`,{d:`M10 11v6`}),(0,g.jsx)(`path`,{d:`M14 11v6`})]})}function b({node:e,depth:t,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o}){let s=r[e.path]??i,c=n===e.path;return(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${c?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8+t*12},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{o(e.path),e.children.length&&a(e.path)},"aria-expanded":e.children.length?s:void 0,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${c?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,g.jsx)(`span`,{className:`w-3.5 shrink-0`,"aria-hidden":`true`}),(0,g.jsx)(_,{open:!!(e.children.length&&s),className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,e.fileCount??0,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${s?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:e.children.map(e=>(0,g.jsx)(b,{node:e,depth:t+1,activePath:n,expanded:r,globalOpen:i,onToggle:a,onSelect:o},e.path))})})]})}function me(e){return e==null?`—`:e<1024?`${e} B`:e<1048576?`${(e/1024).toFixed(1)} KB`:`${(e/1048576).toFixed(1)} MB`}function x(){let[e,t]=(0,h.useState)(()=>r(`requirements`)),[o,x]=(0,h.useState)(!1),[S,he]=(0,h.useState)(null),[C,ge]=(0,h.useState)([]),[_e,ve]=(0,h.useState)(0),[w,T]=(0,h.useState)(`.`),[E,D]=(0,h.useState)([]),[ye,O]=(0,h.useState)({}),[k,be]=(0,h.useState)(!0),[A,j]=(0,h.useState)(null),[M,N]=(0,h.useState)(!1),[P,F]=(0,h.useState)(null),[xe,I]=(0,h.useState)(!1),[L,R]=(0,h.useState)(null),[z,B]=(0,h.useState)(null),[Se,V]=(0,h.useState)(1),[H,Ce]=c(pe),[we,U]=(0,h.useState)(null),W=(0,h.useRef)(null),{cls:Te,play:G}=fe(),K=(0,h.useCallback)(async()=>{let e=await ie(`requirements`);ge(e.tree),ve(e.totalFiles)},[]),q=(0,h.useCallback)(async(e=w)=>{j(null);try{let[t]=await Promise.all([p(`requirements`,e),K()]);D(t.entries),T(t.path)}catch(e){j(e instanceof Error?e.message:String(e))}},[w,K]);(0,h.useEffect)(()=>{let e=i(e=>t(!!e.requirements));return n().then(()=>{t(r(`requirements`)),x(!0)}),e},[]),(0,h.useEffect)(()=>{o&&e&&(async()=>{let e=await f(`requirements`);if(he(e),e)try{let[e]=await Promise.all([p(`requirements`,`.`),K()]);D(e.entries),T(e.path)}catch(e){j(e instanceof Error?e.message:String(e))}})()},[o,e,K]);function Ee(){be(e=>!e),O({})}async function J(e){G(),T(e),V(1),F(null),U(null),j(null);try{let t=await p(`requirements`,e);D(t.entries)}catch(e){j(e instanceof Error?e.message:String(e))}}async function De(e){I(!1),N(!0),j(null);try{await te(`requirements`,w,e),await q(w),l(`已新建文件夹「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`新建文件夹失败:${t}`,`error`)}finally{N(!1)}}async function Oe(e){if(e.type===`file`){N(!0),j(null);try{await ae(`requirements`,e.path)}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}async function ke(e){if(e?.length){N(!0),j(null);try{for(let t of Array.from(e))await re(`requirements`,w,t);await q(w),l(`已上传 ${e.length} 个文件`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`上传失败:${t}`,`error`)}finally{N(!1),W.current&&(W.current.value=``)}}}function Ae(e){let t=u(C,e.path),n=t?.fileCount??0,r=t?le(t):0;R({...e,isDir:!0,blocked:n>0||r>0,files:n,dirs:r})}function je(e){R({name:e.name,path:e.path,isDir:!1})}function Y(e,t){B({...e,isDir:t})}async function Me(){let e=L;if(e&&(R(null),!e.blocked)){N(!0),j(null);try{await se(`requirements`,e.path),P&&d(P.path,e.path)&&F(null);let t=d(w,e.path)?ue(e.path):w;await q(t),l(`已删除「${e.name}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`删除失败:${t}`,`error`)}finally{N(!1)}}}async function Ne(e){let t=z;if(t&&(B(null),e!==t.name)){N(!0),j(null);try{let n=await oe(`requirements`,t.path,e);await q(ce(w,t.path,n)),l(`已重命名为「${e}」`,`success`)}catch(e){let t=e instanceof Error?e.message:String(e);j(t),l(`重命名失败:${t}`,`error`)}finally{N(!1)}}}let Pe=(()=>{if(!L)return``;if(!L.isDir)return`删除文件「${L.name}」?将移入系统废纸篓,可随时找回。`;if(L.blocked){let e=[];return L.files&&e.push(`${L.files} 个文件`),L.dirs&&e.push(`${L.dirs} 个子文件夹`),`文件夹「${L.name}」中还有 ${e.join(`、`)},请先清空内部内容后再删除。`}return`删除文件夹「${L.name}」?将移入系统废纸篓。`})();async function Fe(e){if(e.type!==`file`)return;let t=e.name.toLowerCase();if(t.endsWith(`.md`)||t.endsWith(`.txt`)){N(!0),j(null);try{let t=await ne(`requirements`,e.path);F({path:t.path,content:t.content})}catch(e){j(e instanceof Error?e.message:String(e))}finally{N(!1)}}}if(!o)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在读取插件开关`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!e)return(0,g.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:a(`requirements`)});if(S===null)return(0,g.jsx)(`div`,{className:`tw-lib-probing`,"aria-busy":`true`,"aria-label":`正在连接本地文档服务`,children:(0,g.jsx)(`span`,{className:`tw-lib-spin`,"aria-hidden":`true`})});if(!S)return(0,g.jsx)(`div`,{className:`tw-lib-notice rounded-xl border border-amber-200 bg-amber-50 px-5 py-8 text-sm text-amber-900`,children:`需求文档库需要本地文档服务,当前未就绪。`});let X=E.filter(e=>e.type===`file`),Z=E.filter(e=>e.type===`dir`),Q=Math.max(1,Math.ceil(X.length/H)),$=Math.min(Se,Q),Ie=X.slice(($-1)*H,$*H);function Le(e){G(),Ce(e),V(1)}return(0,g.jsxs)(`div`,{className:`flex gap-4 min-h-0`,children:[(0,g.jsxs)(`aside`,{className:`w-56 shrink-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2.5 border-b border-stone-100 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs font-semibold text-stone-500`,children:`文件夹`}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>I(!0),className:`tw-mkdir-btn disabled:opacity-40`,children:`+ 新建`})]}),(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto py-2 px-1 space-y-1`,children:[(0,g.jsx)(`div`,{className:`group flex items-center rounded-md ${w===`.`?`bg-[#e8f0fe]`:`hover:bg-stone-100`}`,style:{paddingLeft:8},children:(0,g.jsxs)(`button`,{type:`button`,onClick:()=>{J(`.`),Ee()},"aria-expanded":k,className:`flex-1 min-w-0 flex items-center gap-1.5 py-1.5 pr-1 text-sm text-left ${w===`.`?`text-[#4176e6]`:`text-stone-600`}`,children:[(0,g.jsx)(_,{open:k,className:`w-3.5 h-3.5 shrink-0 text-[#4176e6]`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:`全部需求`}),(0,g.jsxs)(`span`,{className:`shrink-0 tabular-nums text-[11px] text-stone-400`,children:[`(`,_e,`)`]})]})}),(0,g.jsx)(`div`,{className:`tw-collapse ${k?`is-open`:``}`,children:(0,g.jsx)(`div`,{className:`tw-collapse-inner space-y-1`,children:C.map(e=>(0,g.jsx)(b,{node:e,depth:0,activePath:w,expanded:ye,globalOpen:k,onToggle:e=>O(t=>({...t,[e]:!(t[e]??k)})),onSelect:e=>void J(e)},e.path))})})]})]}),(0,g.jsxs)(`section`,{className:`flex-1 min-w-0 rounded-xl border border-stone-200 bg-white flex flex-col overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-4 py-3 border-b border-stone-100 flex items-center gap-2 flex-wrap`,children:[(0,g.jsxs)(`div`,{className:`text-sm text-stone-600 flex-1 min-w-0 truncate`,children:[(0,g.jsx)(`span`,{className:`text-stone-400`,children:de(`requirements`)}),w===`.`?``:w]}),(0,g.jsx)(`input`,{ref:W,type:`file`,multiple:!0,accept:`.md,.txt,.docx,.xlsx,.xls,.csv,text/plain,text/markdown,text/csv,application/vnd.openxmlformats-officedocument.wordprocessingml.document,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel`,className:`hidden`,onChange:e=>void ke(e.target.files)}),(0,g.jsx)(`button`,{type:`button`,disabled:M,onClick:()=>W.current?.click(),className:`h-8 px-3 shrink-0 whitespace-nowrap text-sm font-medium text-white bg-[#4176e6] rounded-lg hover:bg-[#3565c7] disabled:opacity-40`,children:`上传文件`})]}),A?(0,g.jsx)(`div`,{className:`mx-4 mt-3 px-3 py-2 text-sm text-red-700 bg-red-50 border border-red-200 rounded-lg`,children:A}):null,(0,g.jsxs)(`div`,{className:`flex-1 overflow-y-auto p-4 space-y-4`,children:[Z.length>0&&(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`子文件夹`}),(0,g.jsx)(`ul`,{className:`space-y-1`,children:Z.map(e=>(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border border-stone-100 hover:bg-stone-50`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 flex items-center gap-2 text-left text-sm text-stone-700`,onClick:()=>void J(e.path),children:[(0,g.jsx)(_,{className:`w-4 h-4 text-[#4176e6] shrink-0`}),(0,g.jsx)(`span`,{className:`flex-1 min-w-0 truncate`,children:e.name})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!0),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>Ae({name:e.name,path:e.path}),className:`tw-icon-danger p-1.5 rounded`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path))})]}),(0,g.jsxs)(`div`,{children:[(0,g.jsx)(`div`,{className:`text-xs font-medium text-stone-400 mb-2`,children:`文件`}),X.length===0?(0,g.jsx)(`p`,{className:`text-sm text-stone-400 py-6 text-center border border-dashed border-stone-200 rounded-lg`,children:`当前文件夹为空,点击「上传文件」添加需求文档(.md / .txt / .docx / .xlsx / .csv)`}):(0,g.jsx)(`ul`,{className:`${Te}space-y-1`,children:Ie.map(e=>{let t=we===e.path;return(0,g.jsxs)(`li`,{className:`flex items-center gap-2 px-3 py-2 rounded-lg border transition-colors ${t?`border-[#c7dcff] bg-[#e8f0fe]`:`border-stone-100 hover:bg-stone-50`}`,children:[(0,g.jsxs)(`button`,{type:`button`,className:`flex-1 min-w-0 text-left`,onClick:()=>{U(e.path),Fe(e)},onDoubleClick:t=>{t.preventDefault(),Oe(e)},children:[(0,g.jsx)(`div`,{className:`text-sm text-stone-800 truncate`,"data-hint":e.name,children:e.name}),(0,g.jsx)(`div`,{className:`text-[11px] text-stone-400`,children:me(e.size)})]}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`重命名 ${e.name}`,onClick:()=>Y({name:e.name,path:e.path},!1),className:`p-1.5 rounded text-stone-400 hover:text-[#4176e6] hover:bg-[#e8f0fe] disabled:opacity-40`,children:(0,g.jsx)(v,{className:`w-3.5 h-3.5`})}),(0,g.jsx)(`button`,{type:`button`,disabled:M,"aria-label":`删除 ${e.name}`,onClick:()=>je(e),className:`tw-icon-danger p-1.5 rounded`,children:(0,g.jsx)(y,{className:`w-3.5 h-3.5`})})]},e.path)})})]}),P?(0,g.jsxs)(`div`,{className:`rounded-lg border border-stone-200 overflow-hidden`,children:[(0,g.jsxs)(`div`,{className:`px-3 py-2 bg-stone-50 border-b border-stone-200 flex items-center justify-between`,children:[(0,g.jsx)(`span`,{className:`text-xs text-stone-500 truncate`,children:P.path}),(0,g.jsx)(`button`,{type:`button`,className:`text-xs text-stone-500 hover:text-stone-800`,onClick:()=>F(null),children:`关闭预览`})]}),(0,g.jsx)(`pre`,{className:`max-h-80 overflow-auto p-4 text-xs leading-5 text-stone-700 whitespace-pre-wrap bg-white`,children:P.content})]}):null]}),X.length>0?(0,g.jsx)(ee,{page:$,totalPages:Q,pageSize:H,busy:M,onPage:e=>{G(),V(e)},onPageSize:Le}):null]}),(0,g.jsx)(m,{open:xe,title:`新建文件夹`,onClose:()=>I(!1),onConfirm:e=>void De(e)}),(0,g.jsx)(m,{open:z!=null,title:z?.isDir?`重命名文件夹`:`重命名文件`,label:z?.isDir?`文件夹名称`:`文件名称`,initialValue:z?.name??``,lockExtension:z!=null&&!z.isDir,confirmLabel:`保存`,onClose:()=>B(null),onConfirm:e=>void Ne(e)}),(0,g.jsx)(s,{open:L!=null,title:L?.blocked?`无法删除文件夹`:L?.isDir?`删除文件夹`:`删除需求文件`,message:Pe,confirmLabel:L?.blocked?`知道了`:`删除`,cancelLabel:`取消`,danger:!L?.blocked,hideCancel:!!L?.blocked,onClose:()=>R(null),onConfirm:()=>void Me()})]})}export{x as default};
@@ -0,0 +1 @@
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{p as n}from"./app-config.CF1xVPmo.js";import{t as r}from"./jsx-runtime.DUg_B_vD.js";import{t as i}from"./OverflowHint.pvo2Xc8R.js";import{t as a}from"./SelectDropdown.Cb-QtC-D.js";import{i as o}from"./case-types.DS1EQ5yP.js";var s=`/__tb_case_sessions`,c=`tw.case.sessions.v1`,l=!1;function u(){return`csess_${Date.now().toString(36)}_${Math.random().toString(36).slice(2,7)}`}function d(e){if(typeof e==`string`&&e.trim()){let t=e.trim();return o().some(e=>e.id===t),t}return o()[0]?.id??`functional`}function f(e){if(!e||!Array.isArray(e.sessions))return{sessions:[],activeId:``};let t=e.sessions.filter(e=>e&&typeof e==`object`&&e.id).map(e=>({...e,caseType:d(e.caseType)})),n=typeof e.activeId==`string`?e.activeId:``;return t.length&&!t.some(e=>e.id===n)&&(n=t[0].id),t.length||(n=``),{sessions:t,activeId:n}}function p(){try{let e=localStorage.getItem(n(c));return e?f(JSON.parse(e)):{sessions:[],activeId:``}}catch{return{sessions:[],activeId:``}}}function m(e){try{localStorage.setItem(n(c),JSON.stringify(e))}catch{}}async function h(){try{let e=await fetch(s,{signal:AbortSignal.timeout(2e3)});if(e.ok){let t=await e.json();l=!0;let n=f(t.store);return m(n),n}}catch{}return l=!1,p()}function g(){return p()}async function _(e){if(m(e),l)try{await fetch(s,{method:`PUT`,headers:{"Content-Type":`application/json`},body:JSON.stringify({store:e})})}catch{}}function v(e){m(e),_(e)}function y(e){let t=Date.now(),n={id:u(),title:e.title?.trim()||`用例生成`,createdAt:t,updatedAt:t,caseType:e.caseType,outputFormat:e.outputFormat,reqPaths:e.reqPaths,templateId:e.templateId,templateTitle:e.templateTitle,promptPath:e.promptPath,knowledgePaths:e.knowledgePaths?.length?[...e.knowledgePaths]:void 0,messages:[]};return v({sessions:[n,...p().sessions],activeId:n.id}),n}function b(e,t){let n=p(),r=n.sessions.map(n=>n.id===e?{...n,...t,updatedAt:Date.now()}:n),i={...n,sessions:r};return v(i),i}var x=e(t(),1),S=r();function C({options:e,values:t,onChange:n,placeholder:r=`选择…`,disabled:a=!1}){let[o,s]=(0,x.useState)(!1),c=(0,x.useRef)(null);(0,x.useEffect)(()=>{if(!o)return;function e(e){c.current?.contains(e.target)||s(!1)}return document.addEventListener(`mousedown`,e),()=>document.removeEventListener(`mousedown`,e)},[o]);let l=e.filter(e=>t.includes(e.value)).map(e=>e.label),u=a||l.length===0?r:l.length<=2?l.join(`、`):`已选 ${l.length} 项`;function d(e){t.includes(e)?n(t.filter(t=>t!==e)):n([...t,e])}return(0,S.jsxs)(`div`,{className:`relative mt-1`,ref:c,children:[(0,S.jsxs)(`button`,{type:`button`,disabled:a,onClick:()=>s(e=>!e),className:a?`w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-stone-50 px-3 text-sm text-left text-stone-400 cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center justify-between gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30`,children:[(0,S.jsx)(i,{text:u,className:`min-w-0 flex-1 truncate ${a||l.length?``:`text-stone-400`}`}),(0,S.jsx)(`svg`,{className:`w-4 h-4 text-stone-400 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,S.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})]}),o?(0,S.jsx)(`div`,{className:`tw-select-menu tw-dsh-scroll tw-popover-anim absolute z-80 mt-1 max-h-72 w-full overflow-auto rounded-lg p-1 shadow-lg ring-1 ring-stone-200`,children:e.length===0?(0,S.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`暂无可选项`}):e.map(e=>{let n=t.includes(e.value);return(0,S.jsxs)(`label`,{className:`flex items-center gap-2 rounded-md px-3 py-2 text-sm text-stone-700 cursor-pointer hover:bg-stone-50`,children:[(0,S.jsx)(`input`,{type:`checkbox`,checked:n,onChange:()=>d(e.value),className:`rounded border-stone-300 text-[#4176e6] focus:ring-[#4176e6]/40`}),(0,S.jsx)(i,{text:e.label,className:`min-w-0 flex-1 truncate`})]},e.value)})}):null]})}function w({options:e,value:t,onChange:n,placeholder:r=`搜索并选择…`,disabled:o=!1,allowEmpty:s=!0,emptyLabel:c=`不选择`}){let l=(0,x.useMemo)(()=>{let t=e.map(e=>({value:e.value,label:e.label}));return s?[{value:``,label:c,muted:!0},...t]:t},[e,s,c]),u=t?l.find(e=>e.value===t):void 0;return(0,S.jsx)(a,{options:l,value:t,onChange:n,disabled:o,searchable:!0,searchPlaceholder:r,dimWhenOpen:!0,renderTrigger:(e,{open:t})=>u?(0,S.jsx)(`span`,{className:`min-w-0 flex-1 ${t?`text-stone-400`:``}`,children:(0,S.jsx)(i,{text:u.label,className:`block truncate`})}):(0,S.jsx)(`span`,{className:`min-w-0 flex-1 truncate text-stone-400`,children:r})})}export{g as a,h as i,C as n,v as o,y as r,b as s,w as t};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./listbox.DNxAJmEo.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.DI-tZ2fv.js";var c=e(t(),1),l=o();function u({className:e=`w-4 h-4 text-stone-400 shrink-0`}){return(0,l.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}function d({value:e,onChange:t,placeholder:n,ariaLabel:r}){let i=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=i.current;if(!e)return;e.focus();let t=requestAnimationFrame(()=>e.focus());return()=>cancelAnimationFrame(t)},[]),(0,l.jsx)(`div`,{className:`shrink-0 border-b border-stone-100 bg-white px-1.5 py-1.5`,children:(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`svg`,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,l.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,l.jsx)(`path`,{d:`m16.5 16.5 4 4`})]}),(0,l.jsx)(`input`,{ref:i,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{[`Escape`,`Enter`,`ArrowDown`,`ArrowUp`].includes(e.key)||e.stopPropagation()},placeholder:n,"aria-label":r,spellCheck:!1,className:`h-8 w-full rounded-md border border-stone-200 bg-stone-50 pl-7 pr-2 text-sm text-stone-700 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})})}function f(){return(0,l.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function p({options:e,value:t,onChange:o,disabled:p=!1,className:m=``,compact:h=!1,ariaLabel:g,showCheck:_=!1,centerContent:v=!1,unstyled:y=!1,triggerClassName:b=``,hideChevron:x=!1,flat:S=!1,menuMinWidth:C,menuMatchTrigger:w=!0,renderTrigger:T,renderOptionPrefix:E,renderOptionAction:D,searchable:O=!1,searchPlaceholder:k=`搜索…`,triggerTitle:A,hideTriggerHint:j=!1,dimWhenOpen:M=!1}){let N=e.find(e=>e.value===t),[P,F]=(0,c.useState)(``),I=(0,c.useMemo)(()=>{let t=P.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,P]),L=v?`relative justify-center`:`justify-between`,R=v?`w-4 h-4 text-stone-400 shrink-0 absolute right-2.5`:void 0,z=y?`w-full flex items-center cursor-pointer outline-none disabled:cursor-not-allowed`:h?`tw-field-trigger w-full h-8 flex items-center gap-1.5 rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:S?`tw-field-trigger w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`;return(0,l.jsx)(i,{value:t,onChange:e=>{F(``),o(e)},disabled:p,children:({open:e})=>(0,l.jsxs)(`div`,{className:`relative ${y?``:h?`inline-block`:S?``:`mt-1`} ${m}`,children:[(0,l.jsxs)(n,{"aria-label":g,onClick:()=>{O&&F(``)},className:`${z} ${L} ${b} ${M&&e?`text-stone-400`:``}`,children:[T?T(N,{open:e}):(0,l.jsx)(s,{text:A??N?.label??t,className:`min-w-0 flex-1 truncate`,disabled:j}),x?null:(0,l.jsx)(u,{className:R})]}),(0,l.jsxs)(a,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:!w&&C?{minWidth:C}:void 0,className:`tw-select-menu tw-menu-anim z-80 flex max-h-64 flex-col overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${w?`w-max min-w-(--button-width) max-w-[360px]`:`w-max min-w-[150px] max-w-[360px]`}`,children:[O?(0,l.jsx)(d,{value:P,onChange:F,placeholder:k,ariaLabel:g?`${g}搜索`:`搜索选项`}):null,(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-auto p-1 pb-2`,children:[O&&I.length===0?(0,l.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):null,I.map(e=>(0,l.jsxs)(r,{value:e.value,disabled:e.disabled,className:`group flex select-none items-center gap-2 rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${e.disabled?`cursor-not-allowed text-stone-300 data-[focus]:bg-transparent data-[selected]:bg-transparent data-[selected]:font-normal`:`cursor-pointer`} ${_?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${e.muted?`text-stone-400 data-[selected]:text-stone-500`:``} ${v&&!_&&!E?`justify-center px-2`:``}`,children:[_?(0,l.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,l.jsx)(f,{})}):E?(0,l.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:E(e)}):null,(0,l.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,l.jsx)(s,{text:e.label,className:`min-w-0 w-full truncate`}),e.secondary?(0,l.jsx)(s,{text:e.secondary,className:`min-w-0 w-full truncate font-mono text-[10px] font-normal leading-4 text-stone-400`}):null]}),D?(0,l.jsx)(`span`,{className:`ml-0.5 flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),e.preventDefault()},children:D(e)}):null]},e.value))]})]})]})})}export{p as t};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{i as n,n as r,r as i,t as a}from"./listbox.DNxAJmEo.js";import{t as o}from"./jsx-runtime.DUg_B_vD.js";import{t as s}from"./OverflowHint.pvo2Xc8R.js";var c=e(t(),1),l=o();function u({className:e=`w-4 h-4 text-stone-400 shrink-0`}){return(0,l.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M5.23 7.21a.75.75 0 011.06.02L10 11.17l3.71-3.94a.75.75 0 111.08 1.04l-4.25 4.5a.75.75 0 01-1.08 0l-4.25-4.5a.75.75 0 01.02-1.06z`,clipRule:`evenodd`})})}function d({value:e,onChange:t,placeholder:n,ariaLabel:r}){let i=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=i.current;if(!e)return;e.focus();let t=requestAnimationFrame(()=>e.focus());return()=>cancelAnimationFrame(t)},[]),(0,l.jsx)(`div`,{className:`shrink-0 border-b border-stone-100 bg-white px-1.5 py-1.5`,children:(0,l.jsxs)(`div`,{className:`relative`,children:[(0,l.jsxs)(`svg`,{className:`pointer-events-none absolute left-2 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,strokeLinecap:`round`,"aria-hidden":`true`,children:[(0,l.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,l.jsx)(`path`,{d:`m16.5 16.5 4 4`})]}),(0,l.jsx)(`input`,{ref:i,value:e,onChange:e=>t(e.target.value),onKeyDown:e=>{[`Escape`,`Enter`,`ArrowDown`,`ArrowUp`].includes(e.key)||e.stopPropagation()},placeholder:n,"aria-label":r,spellCheck:!1,className:`h-8 w-full rounded-md border border-stone-200 bg-stone-50 pl-7 pr-2 text-sm text-stone-700 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})})}function f(){return(0,l.jsx)(`svg`,{className:`w-4 h-4 shrink-0`,viewBox:`0 0 20 20`,fill:`currentColor`,"aria-hidden":!0,children:(0,l.jsx)(`path`,{fillRule:`evenodd`,d:`M16.704 4.153a.75.75 0 01.143 1.052l-8 10.5a.75.75 0 01-1.127.075l-4.5-4.5a.75.75 0 011.06-1.06l3.894 3.893 7.48-9.817a.75.75 0 011.05-.143z`,clipRule:`evenodd`})})}function p({options:e,value:t,onChange:o,disabled:p=!1,className:m=``,compact:h=!1,ariaLabel:g,showCheck:_=!1,centerContent:v=!1,unstyled:y=!1,triggerClassName:b=``,hideChevron:x=!1,flat:S=!1,menuMinWidth:C,menuMatchTrigger:w=!0,renderTrigger:T,renderOptionPrefix:E,renderOptionAction:D,searchable:O=!1,searchPlaceholder:k=`搜索…`,triggerTitle:A,hideTriggerHint:j=!1,dimWhenOpen:M=!1}){let N=e.find(e=>e.value===t),[P,F]=(0,c.useState)(``),I=(0,c.useMemo)(()=>{let t=P.trim().toLowerCase();return t?e.filter(e=>e.label.toLowerCase().includes(t)||e.value.toLowerCase().includes(t)):e},[e,P]),L=v?`relative justify-center`:`justify-between`,R=v?`w-4 h-4 text-stone-400 shrink-0 absolute right-2.5`:void 0,z=y?`w-full flex items-center cursor-pointer outline-none disabled:cursor-not-allowed`:h?`tw-field-trigger w-full h-8 flex items-center gap-1.5 rounded-lg border border-stone-300 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-400 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:S?`tw-field-trigger w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-2.5 text-sm text-left text-stone-700 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`:`tw-field-trigger w-full h-9 flex items-center gap-2 rounded-lg border border-stone-200 bg-white px-3 text-sm text-left text-stone-800 outline-none cursor-pointer hover:border-stone-300 focus:ring-2 focus:ring-[#4176e6]/30 focus:border-[#4176e6] disabled:bg-stone-50 disabled:text-stone-400 disabled:cursor-not-allowed`;return(0,l.jsx)(i,{value:t,onChange:e=>{F(``),o(e)},disabled:p,children:({open:e})=>(0,l.jsxs)(`div`,{className:`relative ${y?``:h?`inline-block`:S?``:`mt-1`} ${m}`,children:[(0,l.jsxs)(n,{"aria-label":g,onClick:()=>{O&&F(``)},className:`${z} ${L} ${b} ${M&&e?`text-stone-400`:``}`,children:[T?T(N,{open:e}):(0,l.jsx)(s,{text:A??N?.label??t,className:`min-w-0 flex-1 truncate`,disabled:j}),x?null:(0,l.jsx)(u,{className:R})]}),(0,l.jsxs)(a,{transition:!0,anchor:{to:`bottom start`,gap:4,padding:12},style:!w&&C?{minWidth:C}:void 0,className:`tw-select-menu tw-menu-anim z-80 flex max-h-64 flex-col overflow-hidden rounded-lg shadow-lg ring-1 ring-stone-200 [--anchor-max-height:16rem] focus:outline-none ${w?`w-max min-w-(--button-width) max-w-[360px]`:`w-max min-w-[150px] max-w-[360px]`}`,children:[O?(0,l.jsx)(d,{value:P,onChange:F,placeholder:k,ariaLabel:g?`${g}搜索`:`搜索选项`}):null,(0,l.jsxs)(`div`,{className:`min-h-0 flex-1 space-y-1 overflow-auto p-1 pb-2`,children:[O&&I.length===0?(0,l.jsx)(`div`,{className:`px-3 py-2 text-sm text-stone-400`,children:`无匹配项`}):null,I.map(e=>(0,l.jsxs)(r,{value:e.value,disabled:e.disabled,className:`group flex select-none items-center gap-2 rounded-md px-3 py-2 text-sm leading-5 data-[focus]:bg-stone-50 data-[selected]:bg-(--tw-accent-soft) ${e.disabled?`cursor-not-allowed text-stone-300 data-[focus]:bg-transparent data-[selected]:bg-transparent data-[selected]:font-normal`:`cursor-pointer`} ${_?`text-stone-700 data-[selected]:text-stone-900`:`data-[selected]:text-(--tw-accent) data-[selected]:font-medium`} ${e.muted?`text-stone-400 data-[selected]:text-stone-500`:``} ${v&&!_&&!E?`justify-center px-2`:``}`,children:[_?(0,l.jsx)(`span`,{className:`w-4 shrink-0 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100`,children:(0,l.jsx)(f,{})}):E?(0,l.jsx)(`span`,{className:`flex w-3.5 shrink-0 items-center justify-center`,children:E(e)}):null,(0,l.jsxs)(`span`,{className:`flex min-w-0 flex-1 flex-col gap-0.5`,children:[(0,l.jsx)(s,{text:e.label,className:`min-w-0 w-full truncate`}),e.secondary?(0,l.jsx)(s,{text:e.secondary,className:`min-w-0 w-full truncate font-mono text-[10px] font-normal leading-4 text-stone-400`}):null]}),D?(0,l.jsx)(`span`,{className:`ml-0.5 flex shrink-0 items-center`,onPointerDown:e=>e.stopPropagation(),onClick:e=>{e.stopPropagation(),e.preventDefault()},children:D(e)}):null]},e.value))]})]})]})})}export{p as t};
@@ -1 +1 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as ee,s as a}from"./app-config.Bm4oN4YP.js";import{i as te,n as o,r as ne,t as s}from"./listbox.DNxAJmEo.js";import{a as re,o as ie}from"./dialog.DZHZCe_T.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as ae}from"./ConfirmDialog.CsMwWevK.js";import{showToast as oe}from"./Toast.BO2NFckG.js";import{i as se}from"./llm.BZEzE0x2.js";import{_ as ce,a as l,c as u,d as le,g as ue,h as de,i as fe,l as d,n as f,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.DNkAyQxA.js";import{n as p}from"./i18n.m5rqL3-h.js";import{s as m}from"./fs-tools.3F9MFrLf.js";import{_ as h,c as g,l as ye}from"./bash-tools.CPS0ZiKi.js";import{t as be}from"./app-version.6yGkRTiD.js";import{n as xe,t as Se}from"./update.DXCPfU4a.js";var _=e(t(),1);function v(e){return e===`time-context`||e===`tool-todo`||e===`tool-ask-user`||e===`user-questions`||e===`plan-mode`||e===`tool-result-pruner`||e===`compaction-basic`||e===`command-compact`||e===`tool-goal`||e===`command-goal`||e===`goal`||e===`tool-schedule`||e===`schedule`||e===`goal-round-driver`||e===`session-log-download`||e===`llm-retry`||e===`session-title-llm`||e===`session-stats`||e===`locale`||e===`config-editor`||e===`subagent`||e===`subagent-fork-in-process`||e===`spill-local`||e===`spill-policy`||e===`session-turn-outline`||e===`image-offload`||e===`session-persistence-jsonl`||e===`session-checkpoint-policy`||e===`session-query-sqlite`||e===`session-projection-cache`||e===`storage-domain`||e===`workspace-changes`||e===`workspace-dependencies`||e===`skill-office`||e===`fs-observation-policy`||e===`deepseek-llm-api-extensions`||e===`session-log-deepseek`||e===`subagent-model-selection-settings`||e===`authorization`||e===`modules`||e===`resources`||e===`mcp-resources`||e===`ptc-runtime`||e===`headless-runner`||e===`headless-startup`||e===`sdk-jsonrpc-server`||e===`sdk-app-startup`||e===`acp`||e===`acp-app-startup`||e===`subagent-spawn-in-process`||e===`llm-pi-ai`||e===`session-reference`||e===`tool-subagent`||e===`tool-subagent-control`||e===`tool-subagent-list-agents`||e===`tool-subagent-fork`||e===`tool-workflow`||e===`workflow-ptc`||e===`session-title`||e===`attachment-local`||e===`file-upload`||e===`file-reference-local`||e===`credentials`||e===`connection`||e===`token-meter`||e===`llm`||e===`llm-deepseek`||e===`agent-default-model`||e===`session`||e===`sessions`||e===`session-projection`||e===`storage`||e===`storage-json`||e===`settings`||e===`commands`||e===`shortcuts`||e===`timeout-policy`||e===`shell-env`||e===`approval`||e===`agent`||e===`system-prompt`||e===`tools`||e===`repeat-tool-reminder`?`ready`:e===`tool-web`||e===`web`||e===`web-fetch-http`||e===`web-search-deepseek`?`web`:e===`tool-bash`||e===`tool-jobs`||e===`jobs`||e===`sandbox-policy`||e===`bash-sandbox`||e===`sandbox`||e===`pty`||e===`terminal-bash`||e===`persistent-bash`||e===`subprocess`?`bash`:e===`tool-pwsh`||e===`persistent-pwsh`||e===`terminal-pwsh`||e===`pwsh-sandbox`?`pwsh`:e===`tool-fs`||e===`tool-fs-search`||e===`tool-skill`||e===`skill`||e===`agent-instructions`||e===`present`||e===`office-to-pdf`||e===`filesystem`||e===`fs-sandbox`||e===`permission`||e===`working-directory`||e===`tool-working-directory`||e===`workspace`?`fs`:`none`}var y=[{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`会话能力`},{id:`time-context`,packageName:`@deepseek-ai/dsh-time-context`,roleZh:`注入当前时间与耗时。`,category:`会话能力`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`会话能力`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`会话能力`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`会话能力`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`会话能力`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`会话能力`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载工作区 SKILL.md。`,category:`会话能力`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`会话能力`},{id:`tool-schedule`,packageName:`@deepseek-ai/dsh-tool-schedule`,roleZh:`模型可创建/查询/更新/删除定时提醒,到点投递回原会话。`,category:`会话能力`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`会话能力`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`会话能力`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`planning`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`compaction`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`compaction`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`compaction`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`delegation`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`delegation`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`delegation`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`delegation`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`delegation`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`delegation`},{id:`tool-ask-user`,packageName:`@deepseek-ai/dsh-tool-ask-user`,roleZh:`模型可向用户提出结构化问题并等待回答。`,category:`会话能力`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`会话能力`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`会话能力`},{id:`present`,packageName:`@deepseek-ai/dsh-tool-present`,roleZh:`模型可声明「交付了哪些工作区文件」,便于 UI 展示/打开。`,category:`会话能力`}],b=[{id:`attachment-local`,packageName:`@deepseek-ai/dsh-attachment-local`,roleZh:`本机附件存储与读取。`,category:`会话 / 存储`},{id:`session`,packageName:`@deepseek-ai/dsh-session`,roleZh:`事件溯源的会话存储(会话真相源)。`,category:`会话 / 存储`},{id:`session-checkpoint-policy`,packageName:`@deepseek-ai/dsh-session-checkpoint-policy`,roleZh:`会话检查点策略。`,category:`会话 / 存储`},{id:`session-log-deepseek`,packageName:`@deepseek-ai/dsh-session-log-deepseek`,roleZh:`DeepSeek 侧增量无损会话日志请求扩展。`,category:`会话 / 存储`},{id:`session-log-download`,packageName:`@deepseek-ai/dsh-session-log-export`,roleZh:`导出会话日志。`,category:`会话 / 存储`},{id:`session-persistence-jsonl`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话以 JSONL 持久化。`,category:`会话 / 存储`},{id:`session-projection`,packageName:`@deepseek-ai/dsh-session-projection`,roleZh:`会话投影视图(给 UI/查询用)。`,category:`会话 / 存储`},{id:`session-projection-cache`,packageName:`@deepseek-ai/dsh-session-projection-cache`,roleZh:`会话投影缓存。`,category:`会话 / 存储`},{id:`session-query-sqlite`,packageName:`@deepseek-ai/dsh-session-query-sqlite`,roleZh:`会话全文/结构化查询(sqlite)。`,category:`会话 / 存储`},{id:`session-reference`,packageName:`@deepseek-ai/dsh-session-reference`,roleZh:`会话内引用(消息/文件等)。`,category:`会话 / 存储`},{id:`session-stats`,packageName:`@deepseek-ai/dsh-session-stats`,roleZh:`会话统计信息。`,category:`会话 / 存储`},{id:`session-title`,packageName:`@deepseek-ai/dsh-session-title`,roleZh:`会话标题能力。`,category:`会话 / 存储`},{id:`session-turn-outline`,packageName:`@deepseek-ai/dsh-session-turn-outline`,roleZh:`对话回合摘要。`,category:`会话 / 存储`},{id:`sessions`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话 JSONL 持久化后端(与 session-persistence 同类)。`,category:`会话 / 存储`},{id:`storage`,packageName:`@deepseek-ai/dsh-storage`,roleZh:`通用存储服务。`,category:`会话 / 存储`},{id:`storage-domain`,packageName:`@deepseek-ai/dsh-storage-domain`,roleZh:`按域划分的存储。`,category:`会话 / 存储`},{id:`storage-json`,packageName:`@deepseek-ai/dsh-storage-json`,roleZh:`JSON 文件存储后端。`,category:`会话 / 存储`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`模型面工具/命令`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`模型面工具/命令`},{id:`skill-office`,packageName:`@deepseek-ai/dsh-skill-office`,roleZh:`Office(Word/PPT/Excel)相关工作流 Skill。`,category:`模型面工具/命令`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`模型面工具/命令`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`模型面工具/命令`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`模型面工具/命令`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`模型面工具/命令`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`模型面工具/命令`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`模型面工具/命令`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`模型面工具/命令`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载某个 Skill,把技能说明拉进上下文。`,category:`模型面工具/命令`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`模型面工具/命令`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`模型面工具/命令`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`模型面工具/命令`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`模型面工具/命令`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`模型面工具/命令`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`模型面工具/命令`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`模型面工具/命令`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`模型面工具/命令`},{id:`acp`,packageName:`@deepseek-ai/dsh-acp`,roleZh:`通过 JSON-RPC stdio 驱动 Harness Agent 的自动化协议服务(给外部编排用)。`,category:`其它`},{id:`acp-app-startup`,packageName:`@deepseek-ai/dsh-acp-app`,roleZh:`ACP 配置包启动:在 base 之上挂 JSON-RPC stdio 与进程生命周期。`,category:`其它`},{id:`authorization`,packageName:`@deepseek-ai/dsh-authorization`,roleZh:`授权/鉴权服务。`,category:`其它`},{id:`commands`,packageName:`@deepseek-ai/dsh-commands`,roleZh:`人类 slash 命令注册底座。`,category:`其它`},{id:`config-editor`,packageName:`@deepseek-ai/dsh-config-editor`,roleZh:`配置编辑能力。`,category:`其它`},{id:`connection`,packageName:`@deepseek-ai/dsh-client-connection`,roleZh:`客户端与 Host 连接。`,category:`其它`},{id:`credentials`,packageName:`@deepseek-ai/dsh-credentials-local`,roleZh:`本机凭证存储。`,category:`其它`},{id:`file-reference-local`,packageName:`@deepseek-ai/dsh-file-reference-local`,roleZh:`本机文件引用解析。`,category:`其它`},{id:`file-upload`,packageName:`@deepseek-ai/dsh-client-file-upload`,roleZh:`客户端上传文件。`,category:`其它`},{id:`filesystem`,packageName:`@deepseek-ai/dsh-fs-local`,roleZh:`本机文件系统实现(ctx.fs),供 tool-fs 等读写。`,category:`其它`},{id:`fs-observation-policy`,packageName:`@deepseek-ai/dsh-fs-observation-policy`,roleZh:`文件系统观察/上报策略。`,category:`其它`},{id:`headless-runner`,packageName:`@deepseek-ai/dsh-headless`,roleZh:`无 Host/HTTP/浏览器的一键 Agent/Session 运行器(纯 headless)。`,category:`其它`},{id:`headless-startup`,packageName:`@deepseek-ai/dsh-headless/startup`,roleZh:`Headless 配置包的启动插件。`,category:`其它`},{id:`image-offload`,packageName:`@deepseek-ai/dsh-compaction-image-offload`,roleZh:`超预算图片卸载为占位符并重试。`,category:`其它`},{id:`locale`,packageName:`@deepseek-ai/dsh-client-locale`,roleZh:`界面语言。`,category:`其它`},{id:`mcp-resources`,packageName:`@deepseek-ai/dsh-mcp-resources`,roleZh:`MCP 资源对接。`,category:`其它`},{id:`modules`,packageName:`@deepseek-ai/dsh-client-modules`,roleZh:`客户端模块加载。`,category:`其它`},{id:`office-to-pdf`,packageName:`@deepseek-ai/dsh-office-to-pdf`,roleZh:`Office 转 PDF。`,category:`其它`},{id:`pty`,packageName:`@deepseek-ai/dsh-terminal`,roleZh:`持久 PTY 会话能力缝:会话 id、后端注册、交互读写与信号。`,category:`其它`},{id:`repeat-tool-reminder`,packageName:`@deepseek-ai/dsh-repeat-tool-reminder`,roleZh:`重复工具调用时提醒模型。`,category:`其它`},{id:`resources`,packageName:`@deepseek-ai/dsh-client-resources`,roleZh:`客户端资源。`,category:`其它`},{id:`sdk-app-startup`,packageName:`@deepseek-ai/dsh-sdk-app`,roleZh:`SDK 配置包启动:stdio JSON-RPC 服务与进程生命周期。`,category:`其它`},{id:`sdk-jsonrpc-server`,packageName:`@deepseek-ai/dsh-sdk-jsonrpc-server`,roleZh:`给进程外 SDK 客户端用的 stdio JSON-RPC 服务端。`,category:`其它`},{id:`settings`,packageName:`@deepseek-ai/dsh-settings`,roleZh:`设置读写与校验。`,category:`其它`},{id:`shell-env`,packageName:`@deepseek-ai/dsh-shell-env`,roleZh:`注入/管理 shell 环境变量。`,category:`其它`},{id:`shortcuts`,packageName:`@deepseek-ai/dsh-client-shortcuts`,roleZh:`快捷键注册。`,category:`其它`},{id:`timeout-policy`,packageName:`@deepseek-ai/dsh-tool-call-timeout-policy`,roleZh:`单次工具调用超时策略。`,category:`其它`},{id:`user-questions`,packageName:`@deepseek-ai/dsh-user-questions`,roleZh:`用户提问通道(供 ask_user 等使用)。`,category:`其它`},{id:`working-directory`,packageName:`@deepseek-ai/dsh-working-directory`,roleZh:`会话工作目录状态。`,category:`其它`},{id:`workspace`,packageName:`@deepseek-ai/dsh-workspace`,roleZh:`工作区抽象(根目录、切换等)。`,category:`其它`},{id:`workspace-changes`,packageName:`@deepseek-ai/dsh-workspace-changes`,roleZh:`工作区变更追踪。`,category:`其它`},{id:`workspace-dependencies`,packageName:`@deepseek-ai/dsh-tool-workspace-dependencies`,roleZh:`向模型提供捆绑的 Python/Node/pnpm 依赖绝对路径(load_workspace_dependencies)。`,category:`其它`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`上下文压缩`},{id:`spill-local`,packageName:`@deepseek-ai/dsh-spill-local`,roleZh:`过大内容溢出到本机文件。`,category:`上下文压缩`},{id:`spill-policy`,packageName:`@deepseek-ai/dsh-spill-policy`,roleZh:`何时溢出、溢出策略。`,category:`上下文压缩`},{id:`token-meter`,packageName:`@deepseek-ai/dsh-token-meter`,roleZh:`统计上下文 token 用量。`,category:`上下文压缩`},{id:`web`,packageName:`@deepseek-ai/dsh-web`,roleZh:`网页能力缝(ctx.web):注册 search/fetch provider。`,category:`网页能力`},{id:`web-fetch-http`,packageName:`@deepseek-ai/dsh-web-fetch-http`,roleZh:`通用 HTTP 抓取网页正文 provider。`,category:`网页能力`},{id:`goal`,packageName:`@deepseek-ai/dsh-goal`,roleZh:`本会话目标状态机服务。`,category:`预设 / 能力服务`},{id:`goal-round-driver`,packageName:`@deepseek-ai/dsh-goal-round-driver`,roleZh:`按目标驱动多轮执行。`,category:`预设 / 能力服务`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`预设 / 能力服务`},{id:`schedule`,packageName:`@deepseek-ai/dsh-schedule`,roleZh:`主机级持久提醒,到点投递原会话。`,category:`预设 / 能力服务`},{id:`skill`,packageName:`@deepseek-ai/dsh-skill`,roleZh:`Skill 能力注册底座。`,category:`预设 / 能力服务`},{id:`approval`,packageName:`@deepseek-ai/dsh-user-approval`,roleZh:`敏感操作需用户批准。`,category:`执行 / 权限`},{id:`bash-sandbox`,packageName:`@deepseek-ai/dsh-bash-sandbox`,roleZh:`bash 专用沙箱绑定。`,category:`执行 / 权限`},{id:`fs-sandbox`,packageName:`@deepseek-ai/dsh-fs-sandbox`,roleZh:`文件系统沙箱。`,category:`执行 / 权限`},{id:`jobs`,packageName:`@deepseek-ai/dsh-jobs-local`,roleZh:`后台任务注册表(id、归属、轮询、取消)。`,category:`执行 / 权限`},{id:`permission`,packageName:`@deepseek-ai/dsh-permission-presets`,roleZh:`权限预设(只读/读写等档位)。`,category:`执行 / 权限`},{id:`persistent-bash`,packageName:`@deepseek-ai/dsh-tool-bash-persistent`,roleZh:`带 PTY 的持久 Bash 工具(跨调用保持 shell 状态)。`,category:`执行 / 权限`},{id:`persistent-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh-persistent`,roleZh:`带 PTY 的持久 PowerShell 工具。`,category:`执行 / 权限`},{id:`pwsh-sandbox`,packageName:`@deepseek-ai/dsh-pwsh-sandbox`,roleZh:`pwsh 专用沙箱绑定。`,category:`执行 / 权限`},{id:`sandbox`,packageName:`@deepseek-ai/dsh-sandbox-local`,roleZh:`本机沙箱执行环境。`,category:`执行 / 权限`},{id:`sandbox-policy`,packageName:`@deepseek-ai/dsh-sandbox-policy`,roleZh:`沙箱策略(能跑什么、不能跑什么)。`,category:`执行 / 权限`},{id:`subprocess`,packageName:`@deepseek-ai/dsh-subprocess-local`,roleZh:`本机子进程执行器。`,category:`执行 / 权限`},{id:`terminal-bash`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 bash PTY 后端。`,category:`执行 / 权限`},{id:`terminal-pwsh`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 pwsh PTY 后端。`,category:`执行 / 权限`},{id:`ptc-runtime`,packageName:`@deepseek-ai/dsh-ptc-runtime-node`,roleZh:`PTC(工具调用呈现)Node 运行时。`,category:`子代理 / 工作流`},{id:`subagent`,packageName:`@deepseek-ai/dsh-subagent`,roleZh:`子代理能力底座。`,category:`子代理 / 工作流`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`子代理 / 工作流`},{id:`agent`,packageName:`@deepseek-ai/dsh-agent`,roleZh:`Agent 主体:把会话、工具、模型串起来。`,category:`LLM / Agent 核心`},{id:`agent-default-model`,packageName:`@deepseek-ai/dsh-agent-default-model`,roleZh:`解析/提供默认模型配置。`,category:`LLM / Agent 核心`},{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`LLM / Agent 核心`},{id:`deepseek-llm-api-extensions`,packageName:`@deepseek-ai/dsh-deepseek-llm-api-extensions`,roleZh:`给官方 DeepSeek API 适配器登记额外请求字段。`,category:`LLM / Agent 核心`},{id:`llm`,packageName:`@deepseek-ai/dsh-llm`,roleZh:`厂商无关的 LLM 服务接口(发请求、流式、工具调用等)。`,category:`LLM / Agent 核心`},{id:`llm-deepseek`,packageName:`@deepseek-ai/dsh-llm-deepseek-api-key`,roleZh:`DeepSeek API Key 模型适配。`,category:`LLM / Agent 核心`},{id:`llm-pi-ai`,packageName:`@deepseek-ai/dsh-llm-pi-ai`,roleZh:`Pi AI 等 LLM 适配。`,category:`LLM / Agent 核心`},{id:`llm-retry`,packageName:`@deepseek-ai/dsh-llm-retry`,roleZh:`LLM 调用失败重试策略。`,category:`LLM / Agent 核心`},{id:`session-title-llm`,packageName:`@deepseek-ai/dsh-session-title-first-prompt-llm`,roleZh:`用首条用户消息经 LLM 自动起会话标题。`,category:`LLM / Agent 核心`},{id:`subagent-fork-in-process`,packageName:`@deepseek-ai/dsh-subagent-fork-in-process`,roleZh:`进程内 fork 子代理实现。`,category:`LLM / Agent 核心`},{id:`subagent-model-selection-settings`,packageName:`@deepseek-ai/dsh-tool-subagent/model-selection-settings`,roleZh:`子代理可选模型的设置项。`,category:`LLM / Agent 核心`},{id:`subagent-spawn-in-process`,packageName:`@deepseek-ai/dsh-subagent-spawn-in-process`,roleZh:`进程内 spawn 子代理实现。`,category:`LLM / Agent 核心`},{id:`system-prompt`,packageName:`@deepseek-ai/dsh-system-prompt`,roleZh:`系统提示词拼装服务。`,category:`LLM / Agent 核心`},{id:`tools`,packageName:`@deepseek-ai/dsh-tools`,roleZh:`工具注册与执行总闸。`,category:`LLM / Agent 核心`}],x=c();function S(e){return String(e??``).replace(/(\s*dsh[^)]*)/gi,``).replace(/\(\s*dsh[^)]*\)/gi,``).replace(/\bdsh\b/gi,``).replace(/\s{2,}/g,` `).replace(/(\s*)/g,``).trim()}function C({status:e}){let t=e.tone===`ready`?`bg-emerald-50 text-emerald-700 border-emerald-100`:e.tone===`warn`?`bg-amber-50 text-amber-800 border-amber-100`:`bg-stone-100 text-stone-500 border-stone-200`;return(0,x.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 py-0.5 text-[11px] ${t}`,children:e.label})}function Ce({tone:e}){return(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 shrink-0 rounded-full ${e===`ready`?`bg-emerald-500`:e===`warn`?`bg-amber-500`:`bg-stone-300`}`})}function w({open:e}){return(0,x.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-150 ${e?`rotate-90`:``}`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,x.jsx)(`path`,{fillRule:`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.17 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,clipRule:`evenodd`})})}function we(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,ee]=(0,_.useState)(null),[a,te]=(0,_.useState)(null),[o,ne]=(0,_.useState)(!0),[s,re]=(0,_.useState)(``),[ie,c]=(0,_.useState)({}),[ae,oe]=(0,_.useState)({});function se(e){c(t=>({...t,[e]:!t[e]}))}function ce(e){oe(t=>({...t,[e]:!t[e]}))}(0,_.useEffect)(()=>{let e=!0;return(async()=>{try{let[n,i,a,o]=await Promise.all([h(),m(),g(),ye()]);if(!e)return;t(n),r(i),ee(a),te(o)}finally{e&&ne(!1)}})(),()=>{e=!1}},[]);function l(t){let r=v(t.id);return r===`none`?{label:`规划中`,tone:`plan`}:r===`ready`?{label:`已就绪`,tone:`ready`}:o?{label:`探测中…`,tone:`plan`}:r===`web`?e?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`fs`?n?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`bash`?i?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`pwsh`?a?.ok&&a.available?{label:`已就绪`,tone:`ready`}:a?.ok?{label:`未装 PowerShell`,tone:`warn`}:{label:`需本地服务`,tone:`warn`}:{label:`规划中`,tone:`plan`}}let u=s.trim().toLowerCase(),le=e=>!u||e.id.toLowerCase().includes(u)||S(e.roleZh).toLowerCase().includes(u),ue=y.filter(le),de=b.filter(le),fe=[{id:`session`,title:`会话插件`,hint:`每个会话各自加载,随会话结束释放`,items:ue,total:y.length},{id:`global`,title:`全局插件`,hint:`由系统与所有会话共享,常驻运行`,items:de,total:b.length}];return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsx)(`div`,{className:`shrink-0 px-6 pt-5 pb-3`,children:(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`h3`,{className:`text-[15px] font-semibold text-stone-900`,children:`内置插件`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-stone-500`,children:`由平台按会话或全局提供,默认常开,不需要开关;状态取决于本机服务是否就绪。`})]}),(0,x.jsxs)(`label`,{className:`relative block w-44 shrink-0`,children:[(0,x.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,x.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,x.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,x.jsx)(`input`,{value:s,onChange:e=>re(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-8 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-2.5 text-xs text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})]})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:(0,x.jsx)(`div`,{className:`space-y-3`,children:fe.map(e=>{let t=!ie[e.id];return(0,x.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-expanded":t,className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors hover:bg-stone-50/70`,children:[(0,x.jsx)(w,{open:t}),(0,x.jsx)(`h4`,{className:`text-[13px] font-medium text-stone-700`,children:e.title}),(0,x.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:u?`${e.items.length}/${e.total}`:e.total}),(0,x.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-stone-400`,children:e.hint})]}),t?e.items.length?(0,x.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-2 border-t border-stone-100 p-2.5`,children:e.items.map(t=>{let n=l(t),r=`${e.id}:${t.id}`,i=!!ae[r];return(0,x.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":i,onClick:()=>ce(r),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce(r))},className:`flex cursor-pointer flex-col rounded-lg border p-2.5 text-left transition-colors ${i?`border-[#4176e6]/40 bg-[#f6f9ff]`:`border-stone-200 bg-white hover:border-stone-300 hover:bg-stone-50/60`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(`span`,{className:`mt-1.5`,children:(0,x.jsx)(Ce,{tone:n.tone})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`p`,{className:`truncate font-mono text-[12.5px] text-stone-800`,children:t.id}),(0,x.jsx)(`p`,{className:`mt-0.5 text-[11.5px] leading-5 text-stone-500 ${i?``:`line-clamp-2`}`,children:S(t.roleZh)})]}),(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,x.jsx)(C,{status:n}),(0,x.jsx)(w,{open:i})]})]}),i?(0,x.jsxs)(`dl`,{className:`mt-2 grid w-full grid-cols-[auto_1fr] gap-x-2 gap-y-1 border-t border-stone-200/70 pt-2 text-[11px]`,children:[(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`分类`}),(0,x.jsx)(`dd`,{className:`truncate text-stone-600`,children:t.category}),(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`npm 包`}),(0,x.jsx)(`dd`,{className:`truncate font-mono text-stone-600`,children:t.packageName||`—`})]}):null]},r)})}):(0,x.jsx)(`p`,{className:`border-t border-stone-100 px-3.5 py-4 text-center text-xs text-stone-400`,children:`没有匹配的内置插件`}):null]},e.id)})})})]})}function Te(e){try{return new URL(e).host}catch{return``}}var Ee=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],T=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,E=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function De({className:e=`w-3.5 h-3.5`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,x.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ke({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function Ae({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,x.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,x.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function je({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M10 4a2 2 0 0 1 4 0v1h3a1 1 0 0 1 1 1v3h1a2 2 0 0 1 0 4h-1v3a1 1 0 0 1-1 1h-3v1a2 2 0 0 1-4 0v-1H7a1 1 0 0 1-1-1v-3H5a2 2 0 0 1 0-4h1V6a1 1 0 0 1 1-1h3V4z`})})}function Me({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,x.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,x.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,x.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function D({title:e,description:t,control:n}){return(0,x.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,x.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,x.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,x.jsx)(`div`,{className:`shrink-0`,children:n})]})}function O({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,x.jsxs)(ne,{value:e,onChange:n,children:[(0,x.jsxs)(te,{className:E,children:[(0,x.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,x.jsx)(De,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,x.jsxs)(o,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,x.jsx)(`span`,{children:e.label}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function k(){let[e,t]=(0,_.useState)(!1),[c,m]=(0,_.useState)(`general`),[h,g]=(0,_.useState)(()=>ee().model.providers),[ye,v]=(0,_.useState)(()=>ee().model.activeId),[y,b]=(0,_.useState)(null),[S,C]=(0,_.useState)(``),[Ce,w]=(0,_.useState)(`DeepSeek`),[E,k]=(0,_.useState)(``),[A,Ne]=(0,_.useState)(``),[j,M]=(0,_.useState)(``),[N,Pe]=(0,_.useState)([]),[P,F]=(0,_.useState)(`idle`),[Fe,Ie]=(0,_.useState)(!1),[Le,Re]=(0,_.useState)(`readonly`),[ze,Be]=(0,_.useState)(!1),[Ve,I]=(0,_.useState)(!1),[He,Ue]=(0,_.useState)(null),[L,R]=(0,_.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[We,z]=(0,_.useState)(`14`),Ge=(0,_.useRef)(0),[B,Ke]=(0,_.useState)(null),[qe,Je]=(0,_.useState)(!1),[Ye,Xe]=(0,_.useState)(!1),[Ze,V]=(0,_.useState)(!1),[Qe,H]=(0,_.useState)(``),U=(0,_.useRef)(null),$e=(0,_.useRef)(!1),W=y!==null,G=L.language,K=h.find(e=>e.id===ye),q=(K?.name||``).trim(),J=B?.status??null,et=J?.phase===`done`&&!!J.to&&J.to===B?.current&&be!==B?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,tt=J?.phase===`failed`?J.error:``,Y=Ze||J?.phase===`installing`||J?.phase===`restarting`,nt=(J?.to||B?.latest||``).replace(/^v/,``),X=tt||Qe,rt=B?.checkedAt&&!Y?new Date(B.checkedAt).toLocaleTimeString():``,it=qe?``:Y?J?.phase===`restarting`?p(`settings.updateRestarting`,void 0,G):p(`settings.updateInstalling`,{v:nt},G):X?`${p(`settings.updateFailed`,void 0,G)}:${X}`:et?p(`settings.updateDone`,{v:J?.to||``},G):B?.mode===`dev`&&B?.hasUpdate?p(`settings.updateDevMode`,void 0,G):B?.error?`${p(`settings.updateUnavailable`,void 0,G)}:${B.error}`:B?.hasUpdate?B.mode===`npx`?p(`settings.updateNpxHint`,void 0,G):``:B?`${p(`settings.updateLatest`,void 0,G)}${rt?` · ${p(`settings.updateCheckedAt`,{time:rt},G)}`:``}`:Ye?p(`settings.updateUnavailable`,void 0,G):``,at=q||(G===`en`?`No model`:`未配置`),ot=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function st(e=`general`){m(e),r().then(()=>{ct(),t(!0)})}function ct(){Be(n()),g(u()),v(l()),I(!!d()),R(he()),me(he()),Re(pe()),b(null)}function Z(){U.current!==null&&(window.clearInterval(U.current),U.current=null)}async function lt(e=!0){Je(!0);try{let t=await Se(e);t&&(Ke(t),H(``))}finally{Je(!1),Xe(!0)}}function ut(e){Z();let t=Date.now()+18e4;U.current=window.setInterval(async()=>{if(!$e.current){$e.current=!0;try{let n=await Se(!0);if(n){Ke(n);let t=n.status;if(t?.phase===`failed`){Z(),V(!1),H(t.error||p(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),V(!1);return}}Date.now()>t&&(Z(),V(!1),H(p(`settings.updateTimeout`,void 0,G)))}finally{$e.current=!1}}},1500)}async function dt(){let e=B?.latest||``;H(``),V(!0);let t=B?.current||be,n=await xe(e||void 0);n.ok?ut(t):(V(!1),H(n.error||p(`settings.updateFailed`,void 0,G)))}function ft(e){if(!e){let e=a();b(e),C(`DeepSeek`),w(`DeepSeek`),k(`https://api.deepseek.com/v1`),Ne(``),M(``),Pe([]),F(`idle`),Ie(!1);return}b(e.id),C(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===l()?i().trim():``)||``;Ne(t),M(e.model),Pe(e.availableModels??[]),F(e.availableModels?.length?`ok`:`idle`),w(f.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),Ie(!1)}(0,_.useEffect)(()=>{r().then(()=>ct());let e=e=>{let n=e.detail;m(n?.tab===`model`?`model`:n?.tab===`builtin`?`builtin`:`general`),r().then(()=>{ct(),t(!0)})};window.addEventListener(ge,e);let n=le(e=>R(e)),i=_e(e=>Re(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,_.useEffect)(()=>{if(e)return(async()=>{let e=await Se(!1);if(Xe(!0),!e)return;Ke(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(V(!0),ut(t.from||e.current))})(),Z},[e]),(0,_.useEffect)(()=>{if(!e||c!==`model`||!W)return;let t=E.trim(),n=A.trim();if(!t||!n){F(e=>e===`ok`?`ok`:`idle`);return}F(`loading`);let r=++Ge.current,i=setTimeout(()=>{se(t,n).then(e=>{r===Ge.current&&(Pe(e),F(`ok`))}).catch(()=>{r===Ge.current&&F(`fail`)})},800);return()=>clearTimeout(i)},[e,c,W,E,A]);function pt(e){w(e);let t=f.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!S.trim()||f.some(e=>e.label===S))&&C(t.label)),M(``)}function Q(e){R(ue(e))}(0,_.useEffect)(()=>{z(String(L.sessionFontSize))},[L.sessionFontSize]);function mt(){let e=Number(We);if(!We.trim()||!Number.isFinite(e)){z(String(L.sessionFontSize));return}let t=ue({sessionFontSize:Math.round(e)});R(t),z(String(t.sessionFontSize))}let ht=!!(S.trim()&&E.trim()&&A.trim()&&j.trim()),$=N.length>0;function gt(){if(!ht||!y)return;let e=!h.some(e=>e.id===y),t=ve({id:y,name:S.trim(),baseURL:E.trim(),apiKey:A.trim(),model:j.trim(),availableModels:$?N:void 0},{activate:!0});g(t),v(y),b(null),I(!!d()),oe(e?`已新增模型服务`:`已保存模型服务`,`success`)}function _t(e){Ue(e)}function vt(){let e=He;if(!e)return;let t=h.find(t=>t.id===e)?.name??`该服务`;Ue(null);let n=fe(e);g(n),v(l()),y===e&&b(null),I(!!d()),oe(`已删除模型服务「${t}」`,`success`)}function yt(e){ce(e),v(e),I(!!d())}let bt=[{value:`readonly`,label:p(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:p(`settings.access.readwrite`,void 0,G)},{value:`full`,label:p(`settings.access.full`,void 0,G)}],xt=[{value:`concise`,label:p(`settings.step.concise`,void 0,G)},{value:`standard`,label:p(`settings.step.standard`,void 0,G)},{value:`detailed`,label:p(`settings.step.detailed`,void 0,G)},{value:`full`,label:p(`settings.step.full`,void 0,G)}],St=[{value:`queue`,label:p(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:p(`settings.busySend.interrupt`,void 0,G)}],Ct=[{value:`light`,label:p(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:p(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:p(`settings.appear.system`,void 0,G),icon:`monitor`}],wt=[{id:`general`,label:p(`settings.general`,void 0,G),icon:(0,x.jsx)(ke,{})},{id:`model`,label:p(`settings.model`,void 0,G),icon:(0,x.jsx)(Ae,{})},{id:`builtin`,label:p(`settings.builtin`,void 0,G),icon:(0,x.jsx)(je,{})}],Tt=c===`general`||c===`builtin`?p(c===`general`?`settings.general`:`settings.builtin`,void 0,G):W?h.some(e=>e.id===y)?p(`settings.editProvider`,void 0,G):p(`settings.addProviderTitle`,void 0,G):p(`settings.model`,void 0,G);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>st(`general`),className:`tw-nav-settings-btn`,"data-hint":Ve?`设置(已配置模型)`:`设置`,children:[(0,x.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,x.jsx)(`span`,{"data-i18n":`nav.settings`,children:p(`nav.settings`,void 0,G)})]}),(0,x.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":ot,onClick:()=>st(`model`),children:[(0,x.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:`tw-nav-provider-name`,children:at})]})]}),(0,x.jsx)(re,{show:e,children:(0,x.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,x.jsx)(ie,{children:(0,x.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,x.jsx)(ie,{children:(0,x.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Tt}),(0,x.jsx)(`button`,{type:`button`,"aria-label":p(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,x.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,x.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:wt.map(e=>{let t=c===e.id;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.id),e.id===`model`&&b(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,x.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,x.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:c===`general`?(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,x.jsx)(D,{title:p(`settings.access`,void 0,G),description:p(`settings.accessDesc`,void 0,G),control:(0,x.jsx)(O,{value:Le,options:bt,onChange:e=>{Re(e),de(e)}})}),(0,x.jsx)(D,{title:p(`settings.language`,void 0,G),control:(0,x.jsx)(O,{value:L.language,options:Ee,onChange:e=>Q({language:e})})}),(0,x.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:p(`settings.appearance`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:Ct.map(e=>{let t=L.appearance===e.value;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(Me,{kind:e.icon}),(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,x.jsx)(D,{title:p(`settings.fontSize`,void 0,G),description:p(`settings.fontSizeDesc`,void 0,G),control:(0,x.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,x.jsx)(`input`,{type:`number`,min:12,max:22,value:We,onChange:e=>z(e.target.value),onBlur:mt,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,x.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,x.jsx)(D,{title:p(`settings.toolSteps`,void 0,G),description:p(`settings.toolStepsDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.toolStepDetail,options:xt,onChange:e=>Q({toolStepDetail:e})})}),(0,x.jsx)(D,{title:p(`settings.busySend`,void 0,G),description:p(`settings.busySendDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.busySendBehavior,options:St,onChange:e=>Q({busySendBehavior:e})})}),(0,x.jsx)(D,{title:p(`settings.subagentModel`,void 0,G),description:p(`settings.subagentModelDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.subagentModel?.trim()?L.subagentModel:`inherit`,options:[{value:`inherit`,label:p(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:p(`settings.platformVersion`,void 0,G)}),(0,x.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,be]}),B?.hasUpdate&&!Y&&!et?(0,x.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${p(`settings.updateAvailable`,void 0,G)} v${(B.latest||``).replace(/^v/,``)}`}):null]}),(0,x.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,x.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),p(`settings.updateWorking`,void 0,G)]}):et?(0,x.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:p(`settings.updateReload`,void 0,G)}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:qe,onClick:()=>void lt(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:qe?(0,x.jsxs)(x.Fragment,{children:[p(`settings.updateChecking`,void 0,G),(0,x.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{})]})]}):p(`settings.updateCheck`,void 0,G)}),B?.hasUpdate?(0,x.jsx)(`button`,{type:`button`,disabled:B.mode===`dev`,onClick:()=>void dt(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:p(`settings.updateNow`,void 0,G)}):null]})})]}),it?(0,x.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:it}):null,X&&B?.logPath?(0,x.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:p(`settings.updateLog`,{path:B.logPath},G)}):null]})]}):W?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:p(`settings.back`,void 0,G)})}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.displayName`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`DeepSeek`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.preset`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:f.map(e=>{let t=Ce===e.label;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>pt(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,x.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?Te(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.baseUrl`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:E,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.apiKey`,void 0,G)}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(`input`,{type:Fe?`text`:`password`,value:A,onChange:e=>Ne(e.target.value),placeholder:`sk-...`,className:`${T} pr-14`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>Ie(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Fe?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),ze?(0,x.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:p(`settings.keyHint`,void 0,G)}):null]}),(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,x.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:p(`settings.modelField`,void 0,G)}),P===`loading`&&(0,x.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:p(`settings.recognizing`,void 0,G)}),$&&P===`ok`&&(0,x.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:p(`settings.recognized`,{n:N.length},G)}),P===`fail`&&!$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeFail`,void 0,G)}),P===`fail`&&$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeKeep`,void 0,G)})]}),$?(0,x.jsxs)(ne,{value:j,onChange:M,children:[(0,x.jsxs)(te,{className:`${T} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,x.jsx)(`span`,{className:`truncate text-stone-800`,children:j||(G===`en`?`Select a model`:`请选择模型`)}),(0,x.jsx)(De,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:N.map(e=>(0,x.jsxs)(o,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,x.jsx)(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:p(`settings.modelPlaceholder`,void 0,G),className:T})]})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:p(`settings.cancel`,void 0,G)}),(0,x.jsx)(`button`,{type:`button`,onClick:gt,disabled:!ht,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:p(`settings.save`,void 0,G)})]})]}):c===`builtin`?(0,x.jsx)(we,{}):(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,x.jsx)(`p`,{className:`text-sm text-stone-500`,children:p(`settings.modelIntro`,void 0,G)}),(0,x.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[h.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===ye;return(0,x.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,x.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>yt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,x.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:p(`settings.edit`,void 0,G)}),h.length>1?(0,x.jsx)(`button`,{type:`button`,onClick:()=>_t(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:p(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:p(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,x.jsx)(ae,{open:He!=null,title:p(`settings.delete`,void 0,G),message:p(`settings.deleteConfirm`,void 0,G),confirmLabel:p(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>Ue(null),onConfirm:vt})]})}export{k as default};
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{a as n,i as r,n as i,r as ee,s as a}from"./app-config.CF1xVPmo.js";import{i as te,n as o,r as ne,t as s}from"./listbox.DNxAJmEo.js";import{a as re,o as ie}from"./dialog.DZHZCe_T.js";import{t as c}from"./jsx-runtime.DUg_B_vD.js";import{t as ae}from"./ConfirmDialog.CsMwWevK.js";import{showToast as oe}from"./Toast.BO2NFckG.js";import{i as se}from"./llm.BZEzE0x2.js";import{_ as ce,a as l,c as u,d as le,g as ue,h as de,i as fe,l as d,n as f,o as pe,r as me,s as he,t as ge,u as _e,v as ve}from"./settings.BvxRxdqa.js";import{n as p}from"./i18n.B3BVhlok.js";import{s as m}from"./fs-tools.3F9MFrLf.js";import{_ as h,c as g,l as ye}from"./bash-tools.CPS0ZiKi.js";import{t as be}from"./app-version.v6jLgARE.js";import{n as xe,t as Se}from"./update.DXCPfU4a.js";var _=e(t(),1);function v(e){return e===`time-context`||e===`tool-todo`||e===`tool-ask-user`||e===`user-questions`||e===`plan-mode`||e===`tool-result-pruner`||e===`compaction-basic`||e===`command-compact`||e===`tool-goal`||e===`command-goal`||e===`goal`||e===`tool-schedule`||e===`schedule`||e===`goal-round-driver`||e===`session-log-download`||e===`llm-retry`||e===`session-title-llm`||e===`session-stats`||e===`locale`||e===`config-editor`||e===`subagent`||e===`subagent-fork-in-process`||e===`spill-local`||e===`spill-policy`||e===`session-turn-outline`||e===`image-offload`||e===`session-persistence-jsonl`||e===`session-checkpoint-policy`||e===`session-query-sqlite`||e===`session-projection-cache`||e===`storage-domain`||e===`workspace-changes`||e===`workspace-dependencies`||e===`skill-office`||e===`fs-observation-policy`||e===`deepseek-llm-api-extensions`||e===`session-log-deepseek`||e===`subagent-model-selection-settings`||e===`authorization`||e===`modules`||e===`resources`||e===`mcp-resources`||e===`ptc-runtime`||e===`headless-runner`||e===`headless-startup`||e===`sdk-jsonrpc-server`||e===`sdk-app-startup`||e===`acp`||e===`acp-app-startup`||e===`subagent-spawn-in-process`||e===`llm-pi-ai`||e===`session-reference`||e===`tool-subagent`||e===`tool-subagent-control`||e===`tool-subagent-list-agents`||e===`tool-subagent-fork`||e===`tool-workflow`||e===`workflow-ptc`||e===`session-title`||e===`attachment-local`||e===`file-upload`||e===`file-reference-local`||e===`credentials`||e===`connection`||e===`token-meter`||e===`llm`||e===`llm-deepseek`||e===`agent-default-model`||e===`session`||e===`sessions`||e===`session-projection`||e===`storage`||e===`storage-json`||e===`settings`||e===`commands`||e===`shortcuts`||e===`timeout-policy`||e===`shell-env`||e===`approval`||e===`agent`||e===`system-prompt`||e===`tools`||e===`repeat-tool-reminder`?`ready`:e===`tool-web`||e===`web`||e===`web-fetch-http`||e===`web-search-deepseek`?`web`:e===`tool-bash`||e===`tool-jobs`||e===`jobs`||e===`sandbox-policy`||e===`bash-sandbox`||e===`sandbox`||e===`pty`||e===`terminal-bash`||e===`persistent-bash`||e===`subprocess`?`bash`:e===`tool-pwsh`||e===`persistent-pwsh`||e===`terminal-pwsh`||e===`pwsh-sandbox`?`pwsh`:e===`tool-fs`||e===`tool-fs-search`||e===`tool-skill`||e===`skill`||e===`agent-instructions`||e===`present`||e===`office-to-pdf`||e===`filesystem`||e===`fs-sandbox`||e===`permission`||e===`working-directory`||e===`tool-working-directory`||e===`workspace`?`fs`:`none`}var y=[{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`会话能力`},{id:`time-context`,packageName:`@deepseek-ai/dsh-time-context`,roleZh:`注入当前时间与耗时。`,category:`会话能力`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`会话能力`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`会话能力`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`会话能力`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`会话能力`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`会话能力`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载工作区 SKILL.md。`,category:`会话能力`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`会话能力`},{id:`tool-schedule`,packageName:`@deepseek-ai/dsh-tool-schedule`,roleZh:`模型可创建/查询/更新/删除定时提醒,到点投递回原会话。`,category:`会话能力`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`会话能力`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`会话能力`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`planning`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`compaction`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`compaction`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`compaction`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`delegation`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`delegation`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`delegation`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`delegation`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`delegation`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`delegation`},{id:`tool-ask-user`,packageName:`@deepseek-ai/dsh-tool-ask-user`,roleZh:`模型可向用户提出结构化问题并等待回答。`,category:`会话能力`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`会话能力`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`会话能力`},{id:`present`,packageName:`@deepseek-ai/dsh-tool-present`,roleZh:`模型可声明「交付了哪些工作区文件」,便于 UI 展示/打开。`,category:`会话能力`}],b=[{id:`attachment-local`,packageName:`@deepseek-ai/dsh-attachment-local`,roleZh:`本机附件存储与读取。`,category:`会话 / 存储`},{id:`session`,packageName:`@deepseek-ai/dsh-session`,roleZh:`事件溯源的会话存储(会话真相源)。`,category:`会话 / 存储`},{id:`session-checkpoint-policy`,packageName:`@deepseek-ai/dsh-session-checkpoint-policy`,roleZh:`会话检查点策略。`,category:`会话 / 存储`},{id:`session-log-deepseek`,packageName:`@deepseek-ai/dsh-session-log-deepseek`,roleZh:`DeepSeek 侧增量无损会话日志请求扩展。`,category:`会话 / 存储`},{id:`session-log-download`,packageName:`@deepseek-ai/dsh-session-log-export`,roleZh:`导出会话日志。`,category:`会话 / 存储`},{id:`session-persistence-jsonl`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话以 JSONL 持久化。`,category:`会话 / 存储`},{id:`session-projection`,packageName:`@deepseek-ai/dsh-session-projection`,roleZh:`会话投影视图(给 UI/查询用)。`,category:`会话 / 存储`},{id:`session-projection-cache`,packageName:`@deepseek-ai/dsh-session-projection-cache`,roleZh:`会话投影缓存。`,category:`会话 / 存储`},{id:`session-query-sqlite`,packageName:`@deepseek-ai/dsh-session-query-sqlite`,roleZh:`会话全文/结构化查询(sqlite)。`,category:`会话 / 存储`},{id:`session-reference`,packageName:`@deepseek-ai/dsh-session-reference`,roleZh:`会话内引用(消息/文件等)。`,category:`会话 / 存储`},{id:`session-stats`,packageName:`@deepseek-ai/dsh-session-stats`,roleZh:`会话统计信息。`,category:`会话 / 存储`},{id:`session-title`,packageName:`@deepseek-ai/dsh-session-title`,roleZh:`会话标题能力。`,category:`会话 / 存储`},{id:`session-turn-outline`,packageName:`@deepseek-ai/dsh-session-turn-outline`,roleZh:`对话回合摘要。`,category:`会话 / 存储`},{id:`sessions`,packageName:`@deepseek-ai/dsh-session-persistence-jsonl`,roleZh:`会话 JSONL 持久化后端(与 session-persistence 同类)。`,category:`会话 / 存储`},{id:`storage`,packageName:`@deepseek-ai/dsh-storage`,roleZh:`通用存储服务。`,category:`会话 / 存储`},{id:`storage-domain`,packageName:`@deepseek-ai/dsh-storage-domain`,roleZh:`按域划分的存储。`,category:`会话 / 存储`},{id:`storage-json`,packageName:`@deepseek-ai/dsh-storage-json`,roleZh:`JSON 文件存储后端。`,category:`会话 / 存储`},{id:`command-compact`,packageName:`@deepseek-ai/dsh-command-compact`,roleZh:`人类手动压缩会话的 slash 命令。`,category:`模型面工具/命令`},{id:`command-goal`,packageName:`@deepseek-ai/dsh-command-goal`,roleZh:`人类管理会话目标的 slash 命令。`,category:`模型面工具/命令`},{id:`skill-office`,packageName:`@deepseek-ai/dsh-skill-office`,roleZh:`Office(Word/PPT/Excel)相关工作流 Skill。`,category:`模型面工具/命令`},{id:`tool-bash`,packageName:`@deepseek-ai/dsh-tool-bash`,roleZh:`模型可调用 bash 在本机执行命令(可后台、可沙箱升级)。`,category:`模型面工具/命令`},{id:`tool-fs`,packageName:`@deepseek-ai/dsh-tool-fs`,roleZh:`模型可读/写/编辑工作区文件。`,category:`模型面工具/命令`},{id:`tool-fs-search`,packageName:`@deepseek-ai/dsh-tool-fs-search`,roleZh:`模型可用 glob / grep 搜索工作区文件(内置 ripgrep)。`,category:`模型面工具/命令`},{id:`tool-goal`,packageName:`@deepseek-ai/dsh-tool-goal`,roleZh:`模型可读写本会话目标,并在执行时做权限校验。`,category:`模型面工具/命令`},{id:`tool-jobs`,packageName:`@deepseek-ai/dsh-tool-jobs`,roleZh:`模型可查看/读取输出/终止后台任务(job_list/output/kill)。`,category:`模型面工具/命令`},{id:`tool-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh`,roleZh:`模型可调用 PowerShell(主要面向 Windows)。`,category:`模型面工具/命令`},{id:`tool-result-pruner`,packageName:`@deepseek-ai/dsh-compaction-tool-result-pruner`,roleZh:`裁剪过长的工具返回(头/中/尾保留),省 token。`,category:`模型面工具/命令`},{id:`tool-skill`,packageName:`@deepseek-ai/dsh-tool-skill`,roleZh:`模型可按需加载某个 Skill,把技能说明拉进上下文。`,category:`模型面工具/命令`},{id:`tool-subagent`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可派生子代理去执行子任务(spawn)。`,category:`模型面工具/命令`},{id:`tool-subagent-control`,packageName:`@deepseek-ai/dsh-tool-subagent-control`,roleZh:`模型可给子代理发消息、中断、列出正在跑的子代理。`,category:`模型面工具/命令`},{id:`tool-subagent-fork`,packageName:`@deepseek-ai/dsh-tool-subagent`,roleZh:`模型可 fork 当前上下文开子代理并行干活。`,category:`模型面工具/命令`},{id:`tool-subagent-list-agents`,packageName:`@deepseek-ai/dsh-tool-subagent-control/list-agents`,roleZh:`单独暴露 list_agents,列出可用/运行中的子代理。`,category:`模型面工具/命令`},{id:`tool-todo`,packageName:`@deepseek-ai/dsh-tool-todo`,roleZh:`模型可维护本会话待办清单(todo_write)。`,category:`模型面工具/命令`},{id:`tool-web`,packageName:`@deepseek-ai/dsh-tool-web`,roleZh:`模型可网页搜索(web_search)与抓取页面(web_fetch)。`,category:`模型面工具/命令`},{id:`tool-workflow`,packageName:`@deepseek-ai/dsh-tool-workflow`,roleZh:`模型可调用 workflow:跑一段编排脚本来协调多步。`,category:`模型面工具/命令`},{id:`tool-working-directory`,packageName:`@deepseek-ai/dsh-tool-working-directory`,roleZh:`模型可查看/切换会话工作目录。`,category:`模型面工具/命令`},{id:`acp`,packageName:`@deepseek-ai/dsh-acp`,roleZh:`通过 JSON-RPC stdio 驱动 Harness Agent 的自动化协议服务(给外部编排用)。`,category:`其它`},{id:`acp-app-startup`,packageName:`@deepseek-ai/dsh-acp-app`,roleZh:`ACP 配置包启动:在 base 之上挂 JSON-RPC stdio 与进程生命周期。`,category:`其它`},{id:`authorization`,packageName:`@deepseek-ai/dsh-authorization`,roleZh:`授权/鉴权服务。`,category:`其它`},{id:`commands`,packageName:`@deepseek-ai/dsh-commands`,roleZh:`人类 slash 命令注册底座。`,category:`其它`},{id:`config-editor`,packageName:`@deepseek-ai/dsh-config-editor`,roleZh:`配置编辑能力。`,category:`其它`},{id:`connection`,packageName:`@deepseek-ai/dsh-client-connection`,roleZh:`客户端与 Host 连接。`,category:`其它`},{id:`credentials`,packageName:`@deepseek-ai/dsh-credentials-local`,roleZh:`本机凭证存储。`,category:`其它`},{id:`file-reference-local`,packageName:`@deepseek-ai/dsh-file-reference-local`,roleZh:`本机文件引用解析。`,category:`其它`},{id:`file-upload`,packageName:`@deepseek-ai/dsh-client-file-upload`,roleZh:`客户端上传文件。`,category:`其它`},{id:`filesystem`,packageName:`@deepseek-ai/dsh-fs-local`,roleZh:`本机文件系统实现(ctx.fs),供 tool-fs 等读写。`,category:`其它`},{id:`fs-observation-policy`,packageName:`@deepseek-ai/dsh-fs-observation-policy`,roleZh:`文件系统观察/上报策略。`,category:`其它`},{id:`headless-runner`,packageName:`@deepseek-ai/dsh-headless`,roleZh:`无 Host/HTTP/浏览器的一键 Agent/Session 运行器(纯 headless)。`,category:`其它`},{id:`headless-startup`,packageName:`@deepseek-ai/dsh-headless/startup`,roleZh:`Headless 配置包的启动插件。`,category:`其它`},{id:`image-offload`,packageName:`@deepseek-ai/dsh-compaction-image-offload`,roleZh:`超预算图片卸载为占位符并重试。`,category:`其它`},{id:`locale`,packageName:`@deepseek-ai/dsh-client-locale`,roleZh:`界面语言。`,category:`其它`},{id:`mcp-resources`,packageName:`@deepseek-ai/dsh-mcp-resources`,roleZh:`MCP 资源对接。`,category:`其它`},{id:`modules`,packageName:`@deepseek-ai/dsh-client-modules`,roleZh:`客户端模块加载。`,category:`其它`},{id:`office-to-pdf`,packageName:`@deepseek-ai/dsh-office-to-pdf`,roleZh:`Office 转 PDF。`,category:`其它`},{id:`pty`,packageName:`@deepseek-ai/dsh-terminal`,roleZh:`持久 PTY 会话能力缝:会话 id、后端注册、交互读写与信号。`,category:`其它`},{id:`repeat-tool-reminder`,packageName:`@deepseek-ai/dsh-repeat-tool-reminder`,roleZh:`重复工具调用时提醒模型。`,category:`其它`},{id:`resources`,packageName:`@deepseek-ai/dsh-client-resources`,roleZh:`客户端资源。`,category:`其它`},{id:`sdk-app-startup`,packageName:`@deepseek-ai/dsh-sdk-app`,roleZh:`SDK 配置包启动:stdio JSON-RPC 服务与进程生命周期。`,category:`其它`},{id:`sdk-jsonrpc-server`,packageName:`@deepseek-ai/dsh-sdk-jsonrpc-server`,roleZh:`给进程外 SDK 客户端用的 stdio JSON-RPC 服务端。`,category:`其它`},{id:`settings`,packageName:`@deepseek-ai/dsh-settings`,roleZh:`设置读写与校验。`,category:`其它`},{id:`shell-env`,packageName:`@deepseek-ai/dsh-shell-env`,roleZh:`注入/管理 shell 环境变量。`,category:`其它`},{id:`shortcuts`,packageName:`@deepseek-ai/dsh-client-shortcuts`,roleZh:`快捷键注册。`,category:`其它`},{id:`timeout-policy`,packageName:`@deepseek-ai/dsh-tool-call-timeout-policy`,roleZh:`单次工具调用超时策略。`,category:`其它`},{id:`user-questions`,packageName:`@deepseek-ai/dsh-user-questions`,roleZh:`用户提问通道(供 ask_user 等使用)。`,category:`其它`},{id:`working-directory`,packageName:`@deepseek-ai/dsh-working-directory`,roleZh:`会话工作目录状态。`,category:`其它`},{id:`workspace`,packageName:`@deepseek-ai/dsh-workspace`,roleZh:`工作区抽象(根目录、切换等)。`,category:`其它`},{id:`workspace-changes`,packageName:`@deepseek-ai/dsh-workspace-changes`,roleZh:`工作区变更追踪。`,category:`其它`},{id:`workspace-dependencies`,packageName:`@deepseek-ai/dsh-tool-workspace-dependencies`,roleZh:`向模型提供捆绑的 Python/Node/pnpm 依赖绝对路径(load_workspace_dependencies)。`,category:`其它`},{id:`compaction-basic`,packageName:`@deepseek-ai/dsh-compaction-basic`,roleZh:`上下文 token 过高时自动摘要压缩,腾出窗口。`,category:`上下文压缩`},{id:`spill-local`,packageName:`@deepseek-ai/dsh-spill-local`,roleZh:`过大内容溢出到本机文件。`,category:`上下文压缩`},{id:`spill-policy`,packageName:`@deepseek-ai/dsh-spill-policy`,roleZh:`何时溢出、溢出策略。`,category:`上下文压缩`},{id:`token-meter`,packageName:`@deepseek-ai/dsh-token-meter`,roleZh:`统计上下文 token 用量。`,category:`上下文压缩`},{id:`web`,packageName:`@deepseek-ai/dsh-web`,roleZh:`网页能力缝(ctx.web):注册 search/fetch provider。`,category:`网页能力`},{id:`web-fetch-http`,packageName:`@deepseek-ai/dsh-web-fetch-http`,roleZh:`通用 HTTP 抓取网页正文 provider。`,category:`网页能力`},{id:`goal`,packageName:`@deepseek-ai/dsh-goal`,roleZh:`本会话目标状态机服务。`,category:`预设 / 能力服务`},{id:`goal-round-driver`,packageName:`@deepseek-ai/dsh-goal-round-driver`,roleZh:`按目标驱动多轮执行。`,category:`预设 / 能力服务`},{id:`plan-mode`,packageName:`@deepseek-ai/dsh-plan-mode`,roleZh:`计划模式(探查→方案→批准→实施)。`,category:`预设 / 能力服务`},{id:`schedule`,packageName:`@deepseek-ai/dsh-schedule`,roleZh:`主机级持久提醒,到点投递原会话。`,category:`预设 / 能力服务`},{id:`skill`,packageName:`@deepseek-ai/dsh-skill`,roleZh:`Skill 能力注册底座。`,category:`预设 / 能力服务`},{id:`approval`,packageName:`@deepseek-ai/dsh-user-approval`,roleZh:`敏感操作需用户批准。`,category:`执行 / 权限`},{id:`bash-sandbox`,packageName:`@deepseek-ai/dsh-bash-sandbox`,roleZh:`bash 专用沙箱绑定。`,category:`执行 / 权限`},{id:`fs-sandbox`,packageName:`@deepseek-ai/dsh-fs-sandbox`,roleZh:`文件系统沙箱。`,category:`执行 / 权限`},{id:`jobs`,packageName:`@deepseek-ai/dsh-jobs-local`,roleZh:`后台任务注册表(id、归属、轮询、取消)。`,category:`执行 / 权限`},{id:`permission`,packageName:`@deepseek-ai/dsh-permission-presets`,roleZh:`权限预设(只读/读写等档位)。`,category:`执行 / 权限`},{id:`persistent-bash`,packageName:`@deepseek-ai/dsh-tool-bash-persistent`,roleZh:`带 PTY 的持久 Bash 工具(跨调用保持 shell 状态)。`,category:`执行 / 权限`},{id:`persistent-pwsh`,packageName:`@deepseek-ai/dsh-tool-pwsh-persistent`,roleZh:`带 PTY 的持久 PowerShell 工具。`,category:`执行 / 权限`},{id:`pwsh-sandbox`,packageName:`@deepseek-ai/dsh-pwsh-sandbox`,roleZh:`pwsh 专用沙箱绑定。`,category:`执行 / 权限`},{id:`sandbox`,packageName:`@deepseek-ai/dsh-sandbox-local`,roleZh:`本机沙箱执行环境。`,category:`执行 / 权限`},{id:`sandbox-policy`,packageName:`@deepseek-ai/dsh-sandbox-policy`,roleZh:`沙箱策略(能跑什么、不能跑什么)。`,category:`执行 / 权限`},{id:`subprocess`,packageName:`@deepseek-ai/dsh-subprocess-local`,roleZh:`本机子进程执行器。`,category:`执行 / 权限`},{id:`terminal-bash`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 bash PTY 后端。`,category:`执行 / 权限`},{id:`terminal-pwsh`,packageName:`@deepseek-ai/dsh-terminal-bash`,roleZh:`基于子进程终端原语的持久 pwsh PTY 后端。`,category:`执行 / 权限`},{id:`ptc-runtime`,packageName:`@deepseek-ai/dsh-ptc-runtime-node`,roleZh:`PTC(工具调用呈现)Node 运行时。`,category:`子代理 / 工作流`},{id:`subagent`,packageName:`@deepseek-ai/dsh-subagent`,roleZh:`子代理能力底座。`,category:`子代理 / 工作流`},{id:`workflow-ptc`,packageName:`@deepseek-ai/dsh-workflow-ptc`,roleZh:`在沙箱 Node 运行时里跑工作流编排脚本。`,category:`子代理 / 工作流`},{id:`agent`,packageName:`@deepseek-ai/dsh-agent`,roleZh:`Agent 主体:把会话、工具、模型串起来。`,category:`LLM / Agent 核心`},{id:`agent-default-model`,packageName:`@deepseek-ai/dsh-agent-default-model`,roleZh:`解析/提供默认模型配置。`,category:`LLM / Agent 核心`},{id:`agent-instructions`,packageName:`@deepseek-ai/dsh-agent-instructions`,roleZh:`加载 AGENTS.md/CLAUDE.md。`,category:`LLM / Agent 核心`},{id:`deepseek-llm-api-extensions`,packageName:`@deepseek-ai/dsh-deepseek-llm-api-extensions`,roleZh:`给官方 DeepSeek API 适配器登记额外请求字段。`,category:`LLM / Agent 核心`},{id:`llm`,packageName:`@deepseek-ai/dsh-llm`,roleZh:`厂商无关的 LLM 服务接口(发请求、流式、工具调用等)。`,category:`LLM / Agent 核心`},{id:`llm-deepseek`,packageName:`@deepseek-ai/dsh-llm-deepseek-api-key`,roleZh:`DeepSeek API Key 模型适配。`,category:`LLM / Agent 核心`},{id:`llm-pi-ai`,packageName:`@deepseek-ai/dsh-llm-pi-ai`,roleZh:`Pi AI 等 LLM 适配。`,category:`LLM / Agent 核心`},{id:`llm-retry`,packageName:`@deepseek-ai/dsh-llm-retry`,roleZh:`LLM 调用失败重试策略。`,category:`LLM / Agent 核心`},{id:`session-title-llm`,packageName:`@deepseek-ai/dsh-session-title-first-prompt-llm`,roleZh:`用首条用户消息经 LLM 自动起会话标题。`,category:`LLM / Agent 核心`},{id:`subagent-fork-in-process`,packageName:`@deepseek-ai/dsh-subagent-fork-in-process`,roleZh:`进程内 fork 子代理实现。`,category:`LLM / Agent 核心`},{id:`subagent-model-selection-settings`,packageName:`@deepseek-ai/dsh-tool-subagent/model-selection-settings`,roleZh:`子代理可选模型的设置项。`,category:`LLM / Agent 核心`},{id:`subagent-spawn-in-process`,packageName:`@deepseek-ai/dsh-subagent-spawn-in-process`,roleZh:`进程内 spawn 子代理实现。`,category:`LLM / Agent 核心`},{id:`system-prompt`,packageName:`@deepseek-ai/dsh-system-prompt`,roleZh:`系统提示词拼装服务。`,category:`LLM / Agent 核心`},{id:`tools`,packageName:`@deepseek-ai/dsh-tools`,roleZh:`工具注册与执行总闸。`,category:`LLM / Agent 核心`}],x=c();function S(e){return String(e??``).replace(/(\s*dsh[^)]*)/gi,``).replace(/\(\s*dsh[^)]*\)/gi,``).replace(/\bdsh\b/gi,``).replace(/\s{2,}/g,` `).replace(/(\s*)/g,``).trim()}function C({status:e}){let t=e.tone===`ready`?`bg-emerald-50 text-emerald-700 border-emerald-100`:e.tone===`warn`?`bg-amber-50 text-amber-800 border-amber-100`:`bg-stone-100 text-stone-500 border-stone-200`;return(0,x.jsx)(`span`,{className:`shrink-0 rounded border px-1.5 py-0.5 text-[11px] ${t}`,children:e.label})}function Ce({tone:e}){return(0,x.jsx)(`span`,{"aria-hidden":`true`,className:`h-1.5 w-1.5 shrink-0 rounded-full ${e===`ready`?`bg-emerald-500`:e===`warn`?`bg-amber-500`:`bg-stone-300`}`})}function w({open:e}){return(0,x.jsx)(`svg`,{"aria-hidden":`true`,className:`h-3.5 w-3.5 shrink-0 text-stone-400 transition-transform duration-150 ${e?`rotate-90`:``}`,viewBox:`0 0 20 20`,fill:`currentColor`,children:(0,x.jsx)(`path`,{fillRule:`evenodd`,d:`M7.21 14.77a.75.75 0 01.02-1.06L11.17 10 7.23 6.29a.75.75 0 111.04-1.08l4.5 4.25a.75.75 0 010 1.08l-4.5 4.25a.75.75 0 01-1.06-.02z`,clipRule:`evenodd`})})}function we(){let[e,t]=(0,_.useState)(null),[n,r]=(0,_.useState)(null),[i,ee]=(0,_.useState)(null),[a,te]=(0,_.useState)(null),[o,ne]=(0,_.useState)(!0),[s,re]=(0,_.useState)(``),[ie,c]=(0,_.useState)({}),[ae,oe]=(0,_.useState)({});function se(e){c(t=>({...t,[e]:!t[e]}))}function ce(e){oe(t=>({...t,[e]:!t[e]}))}(0,_.useEffect)(()=>{let e=!0;return(async()=>{try{let[n,i,a,o]=await Promise.all([h(),m(),g(),ye()]);if(!e)return;t(n),r(i),ee(a),te(o)}finally{e&&ne(!1)}})(),()=>{e=!1}},[]);function l(t){let r=v(t.id);return r===`none`?{label:`规划中`,tone:`plan`}:r===`ready`?{label:`已就绪`,tone:`ready`}:o?{label:`探测中…`,tone:`plan`}:r===`web`?e?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`fs`?n?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`bash`?i?.ok?{label:`已就绪`,tone:`ready`}:{label:`需本地服务`,tone:`warn`}:r===`pwsh`?a?.ok&&a.available?{label:`已就绪`,tone:`ready`}:a?.ok?{label:`未装 PowerShell`,tone:`warn`}:{label:`需本地服务`,tone:`warn`}:{label:`规划中`,tone:`plan`}}let u=s.trim().toLowerCase(),le=e=>!u||e.id.toLowerCase().includes(u)||S(e.roleZh).toLowerCase().includes(u),ue=y.filter(le),de=b.filter(le),fe=[{id:`session`,title:`会话插件`,hint:`每个会话各自加载,随会话结束释放`,items:ue,total:y.length},{id:`global`,title:`全局插件`,hint:`由系统与所有会话共享,常驻运行`,items:de,total:b.length}];return(0,x.jsxs)(`div`,{className:`flex h-full min-h-0 flex-col`,children:[(0,x.jsx)(`div`,{className:`shrink-0 px-6 pt-5 pb-3`,children:(0,x.jsxs)(`div`,{className:`flex items-start gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`h3`,{className:`text-[15px] font-semibold text-stone-900`,children:`内置插件`}),(0,x.jsx)(`p`,{className:`mt-1 text-xs leading-5 text-stone-500`,children:`由平台按会话或全局提供,默认常开,不需要开关;状态取决于本机服务是否就绪。`})]}),(0,x.jsxs)(`label`,{className:`relative block w-44 shrink-0`,children:[(0,x.jsxs)(`svg`,{"aria-hidden":`true`,className:`pointer-events-none absolute left-2.5 top-1/2 h-3.5 w-3.5 -translate-y-1/2 text-stone-400`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.8`,children:[(0,x.jsx)(`circle`,{cx:`11`,cy:`11`,r:`7`}),(0,x.jsx)(`path`,{d:`m20 20-3.5-3.5`})]}),(0,x.jsx)(`input`,{value:s,onChange:e=>re(e.target.value),placeholder:`搜索插件名 / 作用`,className:`h-8 w-full rounded-lg border border-stone-200 bg-white pl-8 pr-2.5 text-xs text-stone-800 outline-none transition-colors placeholder:text-stone-400 focus:border-[#4176e6]`})]})]})}),(0,x.jsx)(`div`,{className:`min-h-0 flex-1 overflow-y-auto px-6 pb-6`,children:(0,x.jsx)(`div`,{className:`space-y-3`,children:fe.map(e=>{let t=!ie[e.id];return(0,x.jsxs)(`section`,{className:`overflow-hidden rounded-xl border border-stone-200 bg-white`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>se(e.id),"aria-expanded":t,className:`flex w-full items-center gap-2 px-3.5 py-2.5 text-left transition-colors hover:bg-stone-50/70`,children:[(0,x.jsx)(w,{open:t}),(0,x.jsx)(`h4`,{className:`text-[13px] font-medium text-stone-700`,children:e.title}),(0,x.jsx)(`span`,{className:`text-[11px] tabular-nums text-stone-400`,children:u?`${e.items.length}/${e.total}`:e.total}),(0,x.jsx)(`span`,{className:`ml-auto truncate text-[11px] text-stone-400`,children:e.hint})]}),t?e.items.length?(0,x.jsx)(`div`,{className:`grid grid-cols-2 items-start gap-2 border-t border-stone-100 p-2.5`,children:e.items.map(t=>{let n=l(t),r=`${e.id}:${t.id}`,i=!!ae[r];return(0,x.jsxs)(`div`,{role:`button`,tabIndex:0,"aria-expanded":i,onClick:()=>ce(r),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&(e.preventDefault(),ce(r))},className:`flex cursor-pointer flex-col rounded-lg border p-2.5 text-left transition-colors ${i?`border-[#4176e6]/40 bg-[#f6f9ff]`:`border-stone-200 bg-white hover:border-stone-300 hover:bg-stone-50/60`}`,children:[(0,x.jsxs)(`div`,{className:`flex items-start gap-2`,children:[(0,x.jsx)(`span`,{className:`mt-1.5`,children:(0,x.jsx)(Ce,{tone:n.tone})}),(0,x.jsxs)(`div`,{className:`min-w-0 flex-1`,children:[(0,x.jsx)(`p`,{className:`truncate font-mono text-[12.5px] text-stone-800`,children:t.id}),(0,x.jsx)(`p`,{className:`mt-0.5 text-[11.5px] leading-5 text-stone-500 ${i?``:`line-clamp-2`}`,children:S(t.roleZh)})]}),(0,x.jsxs)(`div`,{className:`flex shrink-0 flex-col items-end gap-1.5`,children:[(0,x.jsx)(C,{status:n}),(0,x.jsx)(w,{open:i})]})]}),i?(0,x.jsxs)(`dl`,{className:`mt-2 grid w-full grid-cols-[auto_1fr] gap-x-2 gap-y-1 border-t border-stone-200/70 pt-2 text-[11px]`,children:[(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`分类`}),(0,x.jsx)(`dd`,{className:`truncate text-stone-600`,children:t.category}),(0,x.jsx)(`dt`,{className:`shrink-0 text-stone-400`,children:`npm 包`}),(0,x.jsx)(`dd`,{className:`truncate font-mono text-stone-600`,children:t.packageName||`—`})]}):null]},r)})}):(0,x.jsx)(`p`,{className:`border-t border-stone-100 px-3.5 py-4 text-center text-xs text-stone-400`,children:`没有匹配的内置插件`}):null]},e.id)})})})]})}function Te(e){try{return new URL(e).host}catch{return``}}var Ee=[{value:`zh-CN`,label:`中文`},{value:`en`,label:`English`}],T=`w-full px-3 py-2 text-sm border border-stone-300 rounded-lg bg-white focus:outline-none focus:ring-2 focus:ring-[#4176e6]/35 focus:border-[#4176e6] transition-colors`,E=`inline-flex items-center gap-1.5 h-9 min-w-30 px-3 rounded-lg bg-stone-100 text-sm text-stone-700 hover:bg-stone-200/80 transition-colors outline-none focus:outline-none`;function De({className:e=`w-3.5 h-3.5`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.5`,children:(0,x.jsx)(`path`,{d:`M6 8l4 4 4-4`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function Oe({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`2`,children:(0,x.jsx)(`path`,{d:`M5 10.5l3.5 3.5L15 6.5`,strokeLinecap:`round`,strokeLinejoin:`round`})})}function ke({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M12 1v2M12 21v2M4.2 4.2l1.4 1.4M18.4 18.4l1.4 1.4M1 12h2M21 12h2M4.2 19.8l1.4-1.4M18.4 5.6l1.4-1.4`})]})}function Ae({className:e=`w-4 h-4`}){return(0,x.jsxs)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`ellipse`,{cx:`12`,cy:`5`,rx:`8`,ry:`3`}),(0,x.jsx)(`path`,{d:`M4 5v6c0 1.7 3.6 3 8 3s8-1.3 8-3V5`}),(0,x.jsx)(`path`,{d:`M4 11v6c0 1.7 3.6 3 8 3s8-1.3 8-3v-6`})]})}function je({className:e=`w-4 h-4`}){return(0,x.jsx)(`svg`,{className:e,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M10 4a2 2 0 0 1 4 0v1h3a1 1 0 0 1 1 1v3h1a2 2 0 0 1 0 4h-1v3a1 1 0 0 1-1 1h-3v1a2 2 0 0 1-4 0v-1H7a1 1 0 0 1-1-1v-3H5a2 2 0 0 1 0-4h1V6a1 1 0 0 1 1-1h3V4z`})})}function Me({kind:e}){let t=`w-5 h-5`;return e===`sun`?(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`4`}),(0,x.jsx)(`path`,{d:`M12 2v2M12 20v2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M2 12h2M20 12h2M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4`})]}):e===`moon`?(0,x.jsx)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M21 14.5A8.5 8.5 0 1 1 9.5 3a7 7 0 0 0 11.5 11.5z`})}):(0,x.jsxs)(`svg`,{className:t,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:[(0,x.jsx)(`rect`,{x:`3`,y:`4`,width:`18`,height:`12`,rx:`2`}),(0,x.jsx)(`path`,{d:`M8 20h8M12 16v4`})]})}function D({title:e,description:t,control:n}){return(0,x.jsxs)(`div`,{className:`flex items-center gap-4 py-4 border-b border-stone-100 last:border-b-0`,children:[(0,x.jsxs)(`div`,{className:`flex-1 min-w-0`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800`,children:e}),t?(0,x.jsx)(`div`,{className:`mt-0.5 text-xs text-stone-400 leading-5`,children:t}):null]}),(0,x.jsx)(`div`,{className:`shrink-0`,children:n})]})}function O({value:e,options:t,onChange:n}){let r=t.find(t=>t.value===e)?.label??e;return(0,x.jsxs)(ne,{value:e,onChange:n,children:[(0,x.jsxs)(te,{className:E,children:[(0,x.jsx)(`span`,{className:`flex-1 text-left truncate`,children:r}),(0,x.jsx)(De,{className:`w-3.5 h-3.5 text-stone-400 shrink-0`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom end`,gap:6},className:`tw-select-menu tw-menu-anim z-60 min-w-40 rounded-xl py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:t.map(e=>(0,x.jsxs)(o,{value:e.value,className:`group cursor-pointer select-none flex items-center justify-between gap-3 px-3 py-2 text-sm text-stone-700 data-[focus]:bg-stone-50 data-[selected]:text-stone-900`,children:[(0,x.jsx)(`span`,{children:e.label}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0`})]},e.value))})]})}function k(){let[e,t]=(0,_.useState)(!1),[c,m]=(0,_.useState)(`general`),[h,g]=(0,_.useState)(()=>ee().model.providers),[ye,v]=(0,_.useState)(()=>ee().model.activeId),[y,b]=(0,_.useState)(null),[S,C]=(0,_.useState)(``),[Ce,w]=(0,_.useState)(`DeepSeek`),[E,k]=(0,_.useState)(``),[A,Ne]=(0,_.useState)(``),[j,M]=(0,_.useState)(``),[N,Pe]=(0,_.useState)([]),[P,F]=(0,_.useState)(`idle`),[Fe,Ie]=(0,_.useState)(!1),[Le,Re]=(0,_.useState)(`readonly`),[ze,Be]=(0,_.useState)(!1),[Ve,I]=(0,_.useState)(!1),[He,Ue]=(0,_.useState)(null),[L,R]=(0,_.useState)({language:`zh-CN`,appearance:`system`,sessionFontSize:14,toolStepDetail:`standard`,busySendBehavior:`queue`,subagentModel:``}),[We,z]=(0,_.useState)(`14`),Ge=(0,_.useRef)(0),[B,Ke]=(0,_.useState)(null),[qe,Je]=(0,_.useState)(!1),[Ye,Xe]=(0,_.useState)(!1),[Ze,V]=(0,_.useState)(!1),[Qe,H]=(0,_.useState)(``),U=(0,_.useRef)(null),$e=(0,_.useRef)(!1),W=y!==null,G=L.language,K=h.find(e=>e.id===ye),q=(K?.name||``).trim(),J=B?.status??null,et=J?.phase===`done`&&!!J.to&&J.to===B?.current&&be!==B?.current&&Date.now()-Date.parse(J.finishedAt||``)<864e5,tt=J?.phase===`failed`?J.error:``,Y=Ze||J?.phase===`installing`||J?.phase===`restarting`,nt=(J?.to||B?.latest||``).replace(/^v/,``),X=tt||Qe,rt=B?.checkedAt&&!Y?new Date(B.checkedAt).toLocaleTimeString():``,it=qe?``:Y?J?.phase===`restarting`?p(`settings.updateRestarting`,void 0,G):p(`settings.updateInstalling`,{v:nt},G):X?`${p(`settings.updateFailed`,void 0,G)}:${X}`:et?p(`settings.updateDone`,{v:J?.to||``},G):B?.mode===`dev`&&B?.hasUpdate?p(`settings.updateDevMode`,void 0,G):B?.error?`${p(`settings.updateUnavailable`,void 0,G)}:${B.error}`:B?.hasUpdate?B.mode===`npx`?p(`settings.updateNpxHint`,void 0,G):``:B?`${p(`settings.updateLatest`,void 0,G)}${rt?` · ${p(`settings.updateCheckedAt`,{time:rt},G)}`:``}`:Ye?p(`settings.updateUnavailable`,void 0,G):``,at=q||(G===`en`?`No model`:`未配置`),ot=q?K?.model?.trim()?`${q} · ${K.model.trim()}`:q:G===`en`?`No model configured`:`未配置模型`;function st(e=`general`){m(e),r().then(()=>{ct(),t(!0)})}function ct(){Be(n()),g(u()),v(l()),I(!!d()),R(he()),me(he()),Re(pe()),b(null)}function Z(){U.current!==null&&(window.clearInterval(U.current),U.current=null)}async function lt(e=!0){Je(!0);try{let t=await Se(e);t&&(Ke(t),H(``))}finally{Je(!1),Xe(!0)}}function ut(e){Z();let t=Date.now()+18e4;U.current=window.setInterval(async()=>{if(!$e.current){$e.current=!0;try{let n=await Se(!0);if(n){Ke(n);let t=n.status;if(t?.phase===`failed`){Z(),V(!1),H(t.error||p(`settings.updateFailed`,void 0,G));return}if(t?.phase===`done`||e&&n.current!==e){Z(),V(!1);return}}Date.now()>t&&(Z(),V(!1),H(p(`settings.updateTimeout`,void 0,G)))}finally{$e.current=!1}}},1500)}async function dt(){let e=B?.latest||``;H(``),V(!0);let t=B?.current||be,n=await xe(e||void 0);n.ok?ut(t):(V(!1),H(n.error||p(`settings.updateFailed`,void 0,G)))}function ft(e){if(!e){let e=a();b(e),C(`DeepSeek`),w(`DeepSeek`),k(`https://api.deepseek.com/v1`),Ne(``),M(``),Pe([]),F(`idle`),Ie(!1);return}b(e.id),C(e.name),k(e.baseURL);let t=e.apiKey?.trim()||(e.id===l()?i().trim():``)||``;Ne(t),M(e.model),Pe(e.availableModels??[]),F(e.availableModels?.length?`ok`:`idle`),w(f.find(t=>t.baseURL===e.baseURL)?.label??`自定义`),Ie(!1)}(0,_.useEffect)(()=>{r().then(()=>ct());let e=e=>{let n=e.detail;m(n?.tab===`model`?`model`:n?.tab===`builtin`?`builtin`:`general`),r().then(()=>{ct(),t(!0)})};window.addEventListener(ge,e);let n=le(e=>R(e)),i=_e(e=>Re(e));return()=>{window.removeEventListener(ge,e),n(),i()}},[]),(0,_.useEffect)(()=>{if(e)return(async()=>{let e=await Se(!1);if(Xe(!0),!e)return;Ke(e);let t=e.status;(t?.phase===`installing`||t?.phase===`restarting`)&&(V(!0),ut(t.from||e.current))})(),Z},[e]),(0,_.useEffect)(()=>{if(!e||c!==`model`||!W)return;let t=E.trim(),n=A.trim();if(!t||!n){F(e=>e===`ok`?`ok`:`idle`);return}F(`loading`);let r=++Ge.current,i=setTimeout(()=>{se(t,n).then(e=>{r===Ge.current&&(Pe(e),F(`ok`))}).catch(()=>{r===Ge.current&&F(`fail`)})},800);return()=>clearTimeout(i)},[e,c,W,E,A]);function pt(e){w(e);let t=f.find(t=>t.label===e);t&&(t.baseURL&&k(t.baseURL),(!S.trim()||f.some(e=>e.label===S))&&C(t.label)),M(``)}function Q(e){R(ue(e))}(0,_.useEffect)(()=>{z(String(L.sessionFontSize))},[L.sessionFontSize]);function mt(){let e=Number(We);if(!We.trim()||!Number.isFinite(e)){z(String(L.sessionFontSize));return}let t=ue({sessionFontSize:Math.round(e)});R(t),z(String(t.sessionFontSize))}let ht=!!(S.trim()&&E.trim()&&A.trim()&&j.trim()),$=N.length>0;function gt(){if(!ht||!y)return;let e=!h.some(e=>e.id===y),t=ve({id:y,name:S.trim(),baseURL:E.trim(),apiKey:A.trim(),model:j.trim(),availableModels:$?N:void 0},{activate:!0});g(t),v(y),b(null),I(!!d()),oe(e?`已新增模型服务`:`已保存模型服务`,`success`)}function _t(e){Ue(e)}function vt(){let e=He;if(!e)return;let t=h.find(t=>t.id===e)?.name??`该服务`;Ue(null);let n=fe(e);g(n),v(l()),y===e&&b(null),I(!!d()),oe(`已删除模型服务「${t}」`,`success`)}function yt(e){ce(e),v(e),I(!!d())}let bt=[{value:`readonly`,label:p(`settings.access.readonly`,void 0,G)},{value:`readwrite`,label:p(`settings.access.readwrite`,void 0,G)},{value:`full`,label:p(`settings.access.full`,void 0,G)}],xt=[{value:`concise`,label:p(`settings.step.concise`,void 0,G)},{value:`standard`,label:p(`settings.step.standard`,void 0,G)},{value:`detailed`,label:p(`settings.step.detailed`,void 0,G)},{value:`full`,label:p(`settings.step.full`,void 0,G)}],St=[{value:`queue`,label:p(`settings.busySend.queue`,void 0,G)},{value:`interrupt`,label:p(`settings.busySend.interrupt`,void 0,G)}],Ct=[{value:`light`,label:p(`settings.appear.light`,void 0,G),icon:`sun`},{value:`dark`,label:p(`settings.appear.dark`,void 0,G),icon:`moon`},{value:`system`,label:p(`settings.appear.system`,void 0,G),icon:`monitor`}],wt=[{id:`general`,label:p(`settings.general`,void 0,G),icon:(0,x.jsx)(ke,{})},{id:`model`,label:p(`settings.model`,void 0,G),icon:(0,x.jsx)(Ae,{})},{id:`builtin`,label:p(`settings.builtin`,void 0,G),icon:(0,x.jsx)(je,{})}],Tt=c===`general`||c===`builtin`?p(c===`general`?`settings.general`:`settings.builtin`,void 0,G):W?h.some(e=>e.id===y)?p(`settings.editProvider`,void 0,G):p(`settings.addProviderTitle`,void 0,G):p(`settings.model`,void 0,G);return(0,x.jsxs)(x.Fragment,{children:[(0,x.jsxs)(`div`,{className:`tw-nav-foot-row`,children:[(0,x.jsxs)(`button`,{type:`button`,onClick:()=>st(`general`),className:`tw-nav-settings-btn`,"data-hint":Ve?`设置(已配置模型)`:`设置`,children:[(0,x.jsxs)(`svg`,{className:`tw-nav-ico w-4.5 h-4.5 shrink-0`,viewBox:`0 0 24 24`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,"aria-hidden":`true`,children:[(0,x.jsx)(`circle`,{cx:`12`,cy:`12`,r:`3`}),(0,x.jsx)(`path`,{d:`M19.4 15a1.7 1.7 0 0 0 .3 1.8l.1.1a2 2 0 1 1-2.8 2.8l-.1-.1a1.7 1.7 0 0 0-1.8-.3 1.7 1.7 0 0 0-1 1.5V21a2 2 0 1 1-4 0v-.1a1.7 1.7 0 0 0-1-1.5 1.7 1.7 0 0 0-1.8.3l-.1.1a2 2 0 1 1-2.8-2.8l.1-.1a1.7 1.7 0 0 0 .3-1.8 1.7 1.7 0 0 0-1.5-1H3a2 2 0 1 1 0-4h.1a1.7 1.7 0 0 0 1.5-1 1.7 1.7 0 0 0-.3-1.8l-.1-.1a2 2 0 1 1 2.8-2.8l.1.1a1.7 1.7 0 0 0 1.8.3H9a1.7 1.7 0 0 0 1-1.5V3a2 2 0 1 1 4 0v.1a1.7 1.7 0 0 0 1 1.5 1.7 1.7 0 0 0 1.8-.3l.1-.1a2 2 0 1 1 2.8 2.8l-.1.1a1.7 1.7 0 0 0-.3 1.8V9c.2.6.7 1 1.5 1H21a2 2 0 1 1 0 4h-.1a1.7 1.7 0 0 0-1.5 1z`})]}),(0,x.jsx)(`span`,{"data-i18n":`nav.settings`,children:p(`nav.settings`,void 0,G)})]}),(0,x.jsxs)(`button`,{type:`button`,className:`tw-nav-provider-chip${q?``:` is-empty`}`,"data-hint":ot,onClick:()=>st(`model`),children:[(0,x.jsx)(`span`,{className:`tw-nav-provider-dot`,"aria-hidden":`true`}),(0,x.jsx)(`span`,{className:`tw-nav-provider-name`,children:at})]})]}),(0,x.jsx)(re,{show:e,children:(0,x.jsxs)(`div`,{className:`fixed inset-0 z-110 flex items-center justify-center p-4`,children:[(0,x.jsx)(ie,{children:(0,x.jsx)(`div`,{className:`tw-dialog-backdrop-anim absolute inset-0 bg-stone-950/45`,onClick:()=>t(!1),"aria-hidden":`true`})}),(0,x.jsx)(ie,{children:(0,x.jsxs)(`div`,{className:`tw-settings-dialog tw-dialog-panel-anim relative bg-white rounded-2xl shadow-2xl w-full max-w-3xl h-[min(92vh,720px)] overflow-hidden flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`shrink-0 h-12 px-4 flex items-center justify-between border-b border-stone-100 bg-white`,children:[(0,x.jsx)(`h2`,{className:`text-sm font-semibold text-stone-800 truncate pr-3`,children:Tt}),(0,x.jsx)(`button`,{type:`button`,"aria-label":p(`settings.close`,void 0,G),onClick:()=>t(!1),className:`w-8 h-8 inline-flex items-center justify-center rounded-lg text-stone-400 hover:text-stone-700 hover:bg-stone-100 transition-colors`,children:(0,x.jsx)(`svg`,{className:`w-4 h-4`,viewBox:`0 0 20 20`,fill:`none`,stroke:`currentColor`,strokeWidth:`1.75`,children:(0,x.jsx)(`path`,{d:`M5 5l10 10M15 5L5 15`,strokeLinecap:`round`})})})]}),(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex`,children:[(0,x.jsx)(`aside`,{className:`w-38 shrink-0 border-r border-stone-100 bg-[#f4f5f7] py-3 px-2 space-y-0.5`,children:wt.map(e=>{let t=c===e.id;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>{m(e.id),e.id===`model`&&b(null)},className:`w-full flex items-center gap-2 px-3 py-2.5 rounded-lg text-sm transition-colors ${t?`bg-[#e8f0fe] text-[#4176e6] font-medium`:`text-stone-600 hover:bg-white/70 hover:text-stone-800`}`,children:[(0,x.jsx)(`span`,{className:t?`text-[#4176e6]`:`text-stone-400`,children:e.icon}),e.label]},e.id)})}),(0,x.jsx)(`div`,{className:`flex-1 min-w-0 flex flex-col min-h-0 bg-white`,children:c===`general`?(0,x.jsxs)(`div`,{className:`flex-1 min-h-0 flex flex-col`,children:[(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-1`,children:[(0,x.jsx)(D,{title:p(`settings.access`,void 0,G),description:p(`settings.accessDesc`,void 0,G),control:(0,x.jsx)(O,{value:Le,options:bt,onChange:e=>{Re(e),de(e)}})}),(0,x.jsx)(D,{title:p(`settings.language`,void 0,G),control:(0,x.jsx)(O,{value:L.language,options:Ee,onChange:e=>Q({language:e})})}),(0,x.jsxs)(`div`,{className:`py-4 border-b border-stone-100`,children:[(0,x.jsx)(`div`,{className:`text-sm font-medium text-stone-800 mb-3`,children:p(`settings.appearance`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-3 gap-2.5`,children:Ct.map(e=>{let t=L.appearance===e.value;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>Q({appearance:e.value}),className:`flex flex-col items-center justify-center gap-2 h-19 rounded-xl border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] text-[#4176e6] ring-1 ring-[#4176e6]/30`:`border-stone-200 text-stone-500 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(Me,{kind:e.icon}),(0,x.jsx)(`span`,{className:`text-xs font-medium`,children:e.label})]},e.value)})})]}),(0,x.jsx)(D,{title:p(`settings.fontSize`,void 0,G),description:p(`settings.fontSizeDesc`,void 0,G),control:(0,x.jsxs)(`div`,{className:`inline-flex items-center gap-1.5`,children:[(0,x.jsx)(`input`,{type:`number`,min:12,max:22,value:We,onChange:e=>z(e.target.value),onBlur:mt,onKeyDown:e=>{e.key===`Enter`&&e.currentTarget.blur()},className:`w-14 h-9 px-2 text-sm text-center rounded-lg bg-stone-100 border-0 outline-none focus:ring-2 focus:ring-[#4176e6]/30`}),(0,x.jsx)(`span`,{className:`text-sm text-stone-400`,children:`px`})]})}),(0,x.jsx)(D,{title:p(`settings.toolSteps`,void 0,G),description:p(`settings.toolStepsDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.toolStepDetail,options:xt,onChange:e=>Q({toolStepDetail:e})})}),(0,x.jsx)(D,{title:p(`settings.busySend`,void 0,G),description:p(`settings.busySendDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.busySendBehavior,options:St,onChange:e=>Q({busySendBehavior:e})})}),(0,x.jsx)(D,{title:p(`settings.subagentModel`,void 0,G),description:p(`settings.subagentModelDesc`,void 0,G),control:(0,x.jsx)(O,{value:L.subagentModel?.trim()?L.subagentModel:`inherit`,options:[{value:`inherit`,label:p(`settings.subagentModel.inherit`,void 0,G)},...Array.from(new Set([...K?.availableModels??[],...K?.model?[K.model]:[]])).filter(Boolean).map(e=>({value:e,label:e}))],onChange:e=>Q({subagentModel:e===`inherit`?``:e})})})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-6 py-3 border-t border-stone-100`,children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between gap-3`,children:[(0,x.jsxs)(`div`,{className:`min-w-0 flex items-center gap-2`,children:[(0,x.jsx)(`span`,{className:`text-sm text-stone-700 whitespace-nowrap`,children:p(`settings.platformVersion`,void 0,G)}),(0,x.jsxs)(`span`,{className:`text-sm tabular-nums text-stone-500`,children:[`v`,be]}),B?.hasUpdate&&!Y&&!et?(0,x.jsx)(`span`,{className:`inline-flex items-center h-[18px] px-1.5 rounded-full bg-[#edf3fe] text-[11px] font-medium text-[#4176e6] tabular-nums whitespace-nowrap`,children:`${p(`settings.updateAvailable`,void 0,G)} v${(B.latest||``).replace(/^v/,``)}`}):null]}),(0,x.jsx)(`div`,{className:`shrink-0 flex items-center gap-2`,children:Y?(0,x.jsxs)(`span`,{className:`inline-flex items-center gap-1.5 h-8 px-3 rounded-lg text-xs text-stone-500 bg-stone-100 whitespace-nowrap`,children:[(0,x.jsx)(`span`,{className:`w-3 h-3 rounded-full border-2 border-stone-300 border-t-[#4176e6] animate-spin`}),p(`settings.updateWorking`,void 0,G)]}):et?(0,x.jsx)(`button`,{type:`button`,onClick:()=>window.location.reload(),className:`h-8 px-3 rounded-lg text-xs font-medium text-[#4176e6] bg-[#edf3fe] hover:bg-[#e2ecfd] whitespace-nowrap`,children:p(`settings.updateReload`,void 0,G)}):(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`button`,{type:`button`,disabled:qe,onClick:()=>void lt(!0),className:`inline-flex items-center justify-center min-w-[76px] h-8 px-3 rounded-lg text-xs font-medium text-stone-600 bg-stone-100 hover:bg-stone-200 disabled:opacity-70 disabled:cursor-default whitespace-nowrap`,children:qe?(0,x.jsxs)(x.Fragment,{children:[p(`settings.updateChecking`,void 0,G),(0,x.jsxs)(`span`,{className:`tw-dots`,"aria-hidden":`true`,children:[(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{}),(0,x.jsx)(`i`,{})]})]}):p(`settings.updateCheck`,void 0,G)}),B?.hasUpdate?(0,x.jsx)(`button`,{type:`button`,disabled:B.mode===`dev`,onClick:()=>void dt(),className:`h-8 px-3 rounded-lg text-xs font-semibold text-white bg-[#4176e6] hover:bg-[#3566d6] disabled:opacity-50 disabled:cursor-not-allowed whitespace-nowrap`,children:p(`settings.updateNow`,void 0,G)}):null]})})]}),it?(0,x.jsx)(`div`,{className:`mt-1 text-[11px] leading-relaxed ${X?`text-red-500`:`text-stone-400`}`,children:it}):null,X&&B?.logPath?(0,x.jsx)(`div`,{className:`mt-0.5 text-[11px] leading-relaxed text-stone-400 break-all`,children:p(`settings.updateLog`,{path:B.logPath},G)}):null]})]}):W?(0,x.jsxs)(x.Fragment,{children:[(0,x.jsx)(`div`,{className:`shrink-0 px-5 pt-3 pb-2 flex items-center gap-2 border-b border-stone-100`,children:(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`text-sm text-stone-500 hover:text-stone-800`,children:p(`settings.back`,void 0,G)})}),(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-5 py-4 space-y-4`,children:[(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.displayName`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:S,onChange:e=>C(e.target.value),placeholder:`DeepSeek`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.preset`,void 0,G)}),(0,x.jsx)(`div`,{className:`grid grid-cols-2 gap-2`,children:f.map(e=>{let t=Ce===e.label;return(0,x.jsxs)(`button`,{type:`button`,onClick:()=>pt(e.label),className:`text-left px-3 py-2 rounded-lg border transition-colors ${t?`border-[#4176e6] bg-[#edf3fe] ring-1 ring-[#4176e6]/30`:`border-stone-200 hover:border-stone-300 hover:bg-stone-50`}`,children:[(0,x.jsx)(`div`,{className:`text-sm ${t?`text-[#3565c7] font-medium`:`text-stone-700`}`,children:e.label}),(0,x.jsx)(`div`,{className:`text-[11px] text-stone-400 truncate`,children:e.baseURL?Te(e.baseURL):`OpenAI compatible`})]},e.label)})})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.baseUrl`,void 0,G)}),(0,x.jsx)(`input`,{type:`text`,value:E,onChange:e=>k(e.target.value),placeholder:`https://api.deepseek.com/v1`,className:T})]}),(0,x.jsxs)(`div`,{children:[(0,x.jsx)(`label`,{className:`block text-xs font-medium text-stone-500 mb-1.5`,children:p(`settings.apiKey`,void 0,G)}),(0,x.jsxs)(`div`,{className:`relative`,children:[(0,x.jsx)(`input`,{type:Fe?`text`:`password`,value:A,onChange:e=>Ne(e.target.value),placeholder:`sk-...`,className:`${T} pr-14`}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>Ie(e=>!e),className:`absolute right-2 top-1/2 -translate-y-1/2 text-[11px] text-stone-400 hover:text-stone-600 px-1.5 py-1`,children:Fe?G===`en`?`Hide`:`隐藏`:G===`en`?`Show`:`显示`})]}),ze?(0,x.jsx)(`p`,{className:`mt-1.5 text-[11px] text-stone-400 leading-5`,children:p(`settings.keyHint`,void 0,G)}):null]}),(0,x.jsxs)(`div`,{children:[(0,x.jsxs)(`div`,{className:`flex items-center justify-between mb-1.5`,children:[(0,x.jsx)(`label`,{className:`text-xs font-medium text-stone-500`,children:p(`settings.modelField`,void 0,G)}),P===`loading`&&(0,x.jsx)(`span`,{className:`text-[11px] text-stone-400`,children:p(`settings.recognizing`,void 0,G)}),$&&P===`ok`&&(0,x.jsx)(`span`,{className:`text-[11px] text-emerald-600`,children:p(`settings.recognized`,{n:N.length},G)}),P===`fail`&&!$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeFail`,void 0,G)}),P===`fail`&&$&&(0,x.jsx)(`span`,{className:`text-[11px] text-amber-600`,children:p(`settings.recognizeKeep`,void 0,G)})]}),$?(0,x.jsxs)(ne,{value:j,onChange:M,children:[(0,x.jsxs)(te,{className:`${T} flex items-center justify-between text-left hover:border-stone-400 cursor-pointer`,children:[(0,x.jsx)(`span`,{className:`truncate text-stone-800`,children:j||(G===`en`?`Select a model`:`请选择模型`)}),(0,x.jsx)(De,{className:`w-4 h-4 shrink-0 ml-2 text-stone-400`})]}),(0,x.jsx)(s,{transition:!0,anchor:{to:`bottom start`,gap:6},className:`tw-select-menu tw-menu-anim z-60 w-(--button-width) max-h-60 overflow-auto rounded-lg py-1 shadow-lg ring-1 ring-stone-200 focus:outline-none`,children:N.map(e=>(0,x.jsxs)(o,{value:e,className:`group cursor-pointer select-none flex items-center justify-between px-3 py-2 text-sm text-stone-700 data-[focus]:bg-[#edf3fe] data-[selected]:text-[#3565c7] data-[selected]:font-medium`,children:[(0,x.jsx)(`span`,{className:`truncate`,children:e}),(0,x.jsx)(Oe,{className:`w-4 h-4 text-[#4176e6] opacity-0 group-data-[selected]:opacity-100 shrink-0 ml-2`})]},e))})]}):(0,x.jsx)(`input`,{type:`text`,value:j,onChange:e=>M(e.target.value),placeholder:p(`settings.modelPlaceholder`,void 0,G),className:T})]})]}),(0,x.jsxs)(`div`,{className:`shrink-0 px-5 py-3.5 bg-stone-50 border-t border-stone-100 flex justify-end gap-2`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>b(null),className:`px-3.5 py-1.5 text-sm text-stone-600 hover:bg-stone-200/60 rounded-lg`,children:p(`settings.cancel`,void 0,G)}),(0,x.jsx)(`button`,{type:`button`,onClick:gt,disabled:!ht,className:`px-3.5 py-1.5 text-sm font-medium text-white bg-[#4176e6] hover:bg-[#3565c7] rounded-lg disabled:opacity-40 disabled:cursor-not-allowed`,children:p(`settings.save`,void 0,G)})]})]}):c===`builtin`?(0,x.jsx)(we,{}):(0,x.jsxs)(`div`,{className:`flex-1 overflow-y-auto px-6 py-5 bg-[#f4f5f7]`,children:[(0,x.jsx)(`p`,{className:`text-sm text-stone-500`,children:p(`settings.modelIntro`,void 0,G)}),(0,x.jsxs)(`div`,{className:`mt-5 space-y-2.5`,children:[h.map(e=>{let t=!!(e.apiKey?.trim()&&e.baseURL.trim()&&e.model.trim()),n=e.id===ye;return(0,x.jsxs)(`div`,{className:`flex items-center gap-3 rounded-xl border border-stone-200/90 bg-white px-4 py-3.5 shadow-[0_1px_0_rgba(15,23,42,0.02)]`,children:[(0,x.jsxs)(`button`,{type:`button`,"data-hint":n?G===`en`?`Active`:`当前使用`:G===`en`?`Set active`:`设为当前`,onClick:()=>yt(e.id),className:`flex-1 min-w-0 flex items-center gap-2 text-left`,children:[(0,x.jsx)(`span`,{className:`text-sm font-medium text-stone-800 truncate`,children:e.name}),t?(0,x.jsx)(`span`,{className:`w-1.5 h-1.5 rounded-full shrink-0 bg-emerald-500`}):null]}),(0,x.jsxs)(`div`,{className:`flex items-center gap-1.5 shrink-0`,children:[(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(e),className:`h-8 px-3 text-sm text-stone-700 rounded-lg border border-stone-200 bg-white hover:bg-stone-50`,children:p(`settings.edit`,void 0,G)}),h.length>1?(0,x.jsx)(`button`,{type:`button`,onClick:()=>_t(e.id),className:`h-8 px-3 text-sm text-red-600 rounded-lg hover:bg-red-50`,children:p(`settings.delete`,void 0,G)}):null]})]},e.id)}),(0,x.jsx)(`button`,{type:`button`,onClick:()=>ft(null),className:`w-full h-12 rounded-xl border border-dashed border-stone-300 bg-white/60 text-sm text-stone-600 hover:border-[#4176e6] hover:text-[#4176e6] hover:bg-[#edf3fe]/50 transition-colors`,children:p(`settings.addProvider`,void 0,G)})]})]})})]})]})})]})}),(0,x.jsx)(ae,{open:He!=null,title:p(`settings.delete`,void 0,G),message:p(`settings.deleteConfirm`,void 0,G),confirmLabel:p(`settings.delete`,void 0,G),cancelLabel:G===`en`?`Cancel`:`取消`,danger:!0,onClose:()=>Ue(null),onConfirm:vt})]})}export{k as default};
@@ -1,4 +1,4 @@
1
- import{s as e,t}from"./react.Blvh0GOs.js";import{E as n,f as r,i}from"./app-config.Bm4oN4YP.js";import{c as a}from"./plugins.CCqu2gnf.js";import{i as o,n as s,r as c,t as l}from"./dialog.DZHZCe_T.js";import{i as ee,n as u,r as d,t as f}from"./menu.Dnrpz489.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.CsMwWevK.js";import{showToast as h}from"./Toast.BO2NFckG.js";import{n as te}from"./llm.BZEzE0x2.js";import{f as g}from"./project-docs.Cd2gKPKh.js";import{t as _}from"./prompts-meta.BiymOMAE.js";import{l as ne}from"./settings.DNkAyQxA.js";import{n as v}from"./i18n.m5rqL3-h.js";import{a as y,c as re,d as ie,f as b,i as ae,l as oe,m as se,n as ce,o as x,p as le,r as ue,s as de,t as fe,u as pe}from"./spaces-client.D4EmN6SH.js";var S=e(t(),1),me=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
1
+ import{s as e,t}from"./react.Blvh0GOs.js";import{E as n,f as r,i}from"./app-config.CF1xVPmo.js";import{c as a}from"./plugins.DYyAjBXb.js";import{i as o,n as s,r as c,t as l}from"./dialog.DZHZCe_T.js";import{i as ee,n as u,r as d,t as f}from"./menu.Dnrpz489.js";import{t as p}from"./jsx-runtime.DUg_B_vD.js";import{t as m}from"./ConfirmDialog.CsMwWevK.js";import{showToast as h}from"./Toast.BO2NFckG.js";import{n as te}from"./llm.BZEzE0x2.js";import{f as g}from"./project-docs.Cd2gKPKh.js";import{t as _}from"./prompts-meta.C_MeYq8G.js";import{l as ne}from"./settings.BvxRxdqa.js";import{n as v}from"./i18n.B3BVhlok.js";import{a as y,c as re,d as ie,f as b,i as ae,l as oe,m as se,n as ce,o as x,p as le,r as ue,s as de,t as fe,u as pe}from"./spaces-client.Dy3tSPta.js";var S=e(t(),1),me=`你是提示词作者。根据用户对这个数据空间的要求,写一份「默认提示词」正文(Markdown 纯文本,不要用代码围栏)。
2
2
  这份提示词将作为 Lantern Harness 该空间里 AI 助手的默认人设与回答原则。
3
3
  要求:
4
4
  - 用「你是…」起头设定角色;