@runweave/server-linux-x64 0.1.7 → 0.1.9

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 (352) hide show
  1. package/manifest.json +1487 -156
  2. package/native.tar.gz +0 -0
  3. package/package.json +1 -1
  4. package/payload/.agents/plugins/marketplace.json +20 -0
  5. package/payload/app-server/build-info.json +3 -3
  6. package/payload/app-server/index.cjs +1 -1
  7. package/payload/backend/build-info.json +4 -4
  8. package/payload/backend/index.cjs +2416 -1684
  9. package/payload/backend/ios-simulators/pool.py +3 -3
  10. package/payload/backend/scheduled-tasks-sqlite-worker.cjs +224 -171
  11. package/payload/frontend/dist/assets/{_baseUniq-i1Ki3twP.js → _baseUniq-qHFga5V8.js} +1 -1
  12. package/payload/frontend/dist/assets/{access-DK9V0f3W.js → access-DgHvmn15.js} +1 -1
  13. package/payload/frontend/dist/assets/{advanced-B13lWv1d.js → advanced-C1Fh14vw.js} +1 -1
  14. package/payload/frontend/dist/assets/{appearance-DumRYmkD.js → appearance-Bs7cSXqO.js} +1 -1
  15. package/payload/frontend/dist/assets/{arc-HKn3_xyV.js → arc-E3iYHQG_.js} +1 -1
  16. package/payload/frontend/dist/assets/{architectureDiagram-Q4EWVU46-C09x7b94.js → architectureDiagram-Q4EWVU46-DgpYpTb9.js} +1 -1
  17. package/payload/frontend/dist/assets/{blockDiagram-DXYQGD6D-CFLFTR6d.js → blockDiagram-DXYQGD6D-CfFOEKZ7.js} +1 -1
  18. package/payload/frontend/dist/assets/{c4Diagram-AHTNJAMY-8P8Q-xqC.js → c4Diagram-AHTNJAMY-BxlHBUj3.js} +1 -1
  19. package/payload/frontend/dist/assets/channel-amxyNKnk.js +1 -0
  20. package/payload/frontend/dist/assets/{chunk-4BX2VUAB-B1KEkTal.js → chunk-4BX2VUAB-xWocgDo8.js} +1 -1
  21. package/payload/frontend/dist/assets/{chunk-4TB4RGXK-Bu_Z47kJ.js → chunk-4TB4RGXK-Bl1cNICf.js} +1 -1
  22. package/payload/frontend/dist/assets/{chunk-55IACEB6-xzHVCHyi.js → chunk-55IACEB6-DVtE836u.js} +1 -1
  23. package/payload/frontend/dist/assets/{chunk-EDXVE4YY-h3HAW06h.js → chunk-EDXVE4YY-Dbd3tDCr.js} +1 -1
  24. package/payload/frontend/dist/assets/{chunk-FMBD7UC4-CQ4faPSh.js → chunk-FMBD7UC4-MPJaTsyN.js} +1 -1
  25. package/payload/frontend/dist/assets/{chunk-OYMX7WX6-CubmLoGT.js → chunk-OYMX7WX6-D3LuudlW.js} +1 -1
  26. package/payload/frontend/dist/assets/{chunk-QZHKN3VN-xk0zKNja.js → chunk-QZHKN3VN-Dn1aF6iQ.js} +1 -1
  27. package/payload/frontend/dist/assets/{chunk-YZCP3GAM-CHpTv8sd.js → chunk-YZCP3GAM-jZYbHnCw.js} +1 -1
  28. package/payload/frontend/dist/assets/classDiagram-6PBFFD2Q-B8cTijjT.js +1 -0
  29. package/payload/frontend/dist/assets/classDiagram-v2-HSJHXN6E-B8cTijjT.js +1 -0
  30. package/payload/frontend/dist/assets/clone-xzI2eGRI.js +1 -0
  31. package/payload/frontend/dist/assets/connection-V2iI-6rM.js +12 -0
  32. package/payload/frontend/dist/assets/{connections-A7InZw2T.js → connections-G_Q7342g.js} +1 -1
  33. package/payload/frontend/dist/assets/{cose-bilkent-S5V4N54A-CQn27vi_.js → cose-bilkent-S5V4N54A-75FLD3RS.js} +1 -1
  34. package/payload/frontend/dist/assets/{dagre-KV5264BT-CClOwB9v.js → dagre-KV5264BT-DEm-DpJL.js} +1 -1
  35. package/payload/frontend/dist/assets/{desktop-BgryfXXM.js → desktop-g5JC-CQd.js} +1 -1
  36. package/payload/frontend/dist/assets/{diagram-5BDNPKRD-DcUJOAmV.js → diagram-5BDNPKRD-BV6P2UTy.js} +1 -1
  37. package/payload/frontend/dist/assets/{diagram-G4DWMVQ6-DdabmTwk.js → diagram-G4DWMVQ6-DuCK-MM2.js} +1 -1
  38. package/payload/frontend/dist/assets/{diagram-MMDJMWI5-DmcxjBIk.js → diagram-MMDJMWI5-D5_GlPgO.js} +1 -1
  39. package/payload/frontend/dist/assets/{diagram-TYMM5635-BUSpXaiN.js → diagram-TYMM5635-QRbOYR1P.js} +1 -1
  40. package/payload/frontend/dist/assets/{erDiagram-SMLLAGMA-vkAXcv5_.js → erDiagram-SMLLAGMA-DefCheAw.js} +1 -1
  41. package/payload/frontend/dist/assets/{flowDiagram-DWJPFMVM-BHDU7BUJ.js → flowDiagram-DWJPFMVM-DVzyWIso.js} +1 -1
  42. package/payload/frontend/dist/assets/{ganttDiagram-T4ZO3ILL-C3lAG7_6.js → ganttDiagram-T4ZO3ILL-BJaClUEF.js} +1 -1
  43. package/payload/frontend/dist/assets/{gitGraphDiagram-UUTBAWPF-DHLyYJf7.js → gitGraphDiagram-UUTBAWPF-BLfbApNz.js} +1 -1
  44. package/payload/frontend/dist/assets/{graph-Bp5bIzXM.js → graph-C-YqFh68.js} +1 -1
  45. package/payload/frontend/dist/assets/{image-DkcKNLTV.js → image-CZo_2Awc.js} +1 -1
  46. package/payload/frontend/dist/assets/{index-BUS7FSlk.js → index-6q2aeqkt.js} +95 -105
  47. package/payload/frontend/dist/assets/{infoDiagram-42DDH7IO-CVp9zvmA.js → infoDiagram-42DDH7IO-BakVOutT.js} +1 -1
  48. package/payload/frontend/dist/assets/{ishikawaDiagram-UXIWVN3A-D07QPX3O.js → ishikawaDiagram-UXIWVN3A-D_1Oa5Dc.js} +1 -1
  49. package/payload/frontend/dist/assets/{journeyDiagram-VCZTEJTY-D-iZPDHM.js → journeyDiagram-VCZTEJTY-Y8TVFv6B.js} +1 -1
  50. package/payload/frontend/dist/assets/{kanban-definition-6JOO6SKY-BR4eWb08.js → kanban-definition-6JOO6SKY-DxeNhTIB.js} +1 -1
  51. package/payload/frontend/dist/assets/{layout-Cyv0DyJm.js → layout-5cMeOTAp.js} +1 -1
  52. package/payload/frontend/dist/assets/{linear-D5M7Pvj1.js → linear-Bnc3ev5g.js} +1 -1
  53. package/payload/frontend/dist/assets/main-3TPtEl66.js +706 -0
  54. package/payload/frontend/dist/assets/main-D4_uoZQa.css +33 -0
  55. package/payload/frontend/dist/assets/{min-BFlloFGg.js → min-BRXKkrS8.js} +1 -1
  56. package/payload/frontend/dist/assets/{mindmap-definition-QFDTVHPH-AKUF178o.js → mindmap-definition-QFDTVHPH-RYZO_BEr.js} +1 -1
  57. package/payload/frontend/dist/assets/{monitoring-B2okceCB.js → monitoring-Fv7kZ4s6.js} +1 -1
  58. package/payload/frontend/dist/assets/{notifications-0lql4_qJ.js → notifications-BzrYqyMH.js} +1 -1
  59. package/payload/frontend/dist/assets/{pieDiagram-DEJITSTG-CRiHmwn7.js → pieDiagram-DEJITSTG-Bzw0dhjz.js} +1 -1
  60. package/payload/frontend/dist/assets/{quadrantDiagram-34T5L4WZ-CzXrq7IJ.js → quadrantDiagram-34T5L4WZ-CQJY_msa.js} +1 -1
  61. package/payload/frontend/dist/assets/{record-content-DTCQKbEj.js → record-content-B7-6olQt.js} +1 -1
  62. package/payload/frontend/dist/assets/{requirementDiagram-MS252O5E-Bbn5ulLV.js → requirementDiagram-MS252O5E-DuP8hAV8.js} +1 -1
  63. package/payload/frontend/dist/assets/{sankeyDiagram-XADWPNL6-D9ZZ46pQ.js → sankeyDiagram-XADWPNL6-D-fQnCZZ.js} +1 -1
  64. package/payload/frontend/dist/assets/{sequenceDiagram-FGHM5R23-DxOP2gDa.js → sequenceDiagram-FGHM5R23-DaZNEccV.js} +1 -1
  65. package/payload/frontend/dist/assets/{stateDiagram-FHFEXIEX-NF_Qq5Cq.js → stateDiagram-FHFEXIEX-CkOLt5R1.js} +1 -1
  66. package/payload/frontend/dist/assets/stateDiagram-v2-QKLJ7IA2-atg1K4nB.js +1 -0
  67. package/payload/frontend/dist/assets/{status-2U71YpVe.js → status-CIIPajZp.js} +1 -1
  68. package/payload/frontend/dist/assets/suiji-C453W-Sg.js +1 -0
  69. package/payload/frontend/dist/assets/{svg-DpI3GSCw.js → svg-BUqAWGtg.js} +1 -1
  70. package/payload/frontend/dist/assets/{tabs-CYKuiiHg.js → tabs-Cwlp1Meu.js} +1 -1
  71. package/payload/frontend/dist/assets/{timeline-definition-GMOUNBTQ-ChEZSNF_.js → timeline-definition-GMOUNBTQ-BOKDMwHS.js} +1 -1
  72. package/payload/frontend/dist/assets/{vennDiagram-DHZGUBPP-Ch26SNbB.js → vennDiagram-DHZGUBPP-fSZjDS41.js} +1 -1
  73. package/payload/frontend/dist/assets/{wardley-RL74JXVD-D0ap5vv0.js → wardley-RL74JXVD-D1KIsvoD.js} +1 -1
  74. package/payload/frontend/dist/assets/{wardleyDiagram-NUSXRM2D-btdjsmHO.js → wardleyDiagram-NUSXRM2D-FMe67dwE.js} +1 -1
  75. package/payload/frontend/dist/assets/{xychartDiagram-5P7HB3ND-CklPtFGT.js → xychartDiagram-5P7HB3ND-B9AM9_9w.js} +1 -1
  76. package/payload/frontend/dist/build-info.json +4 -4
  77. package/payload/frontend/dist/companion.html +1 -1
  78. package/payload/frontend/dist/index.html +3 -3
  79. package/payload/packages/agent-bridge/src/install-pi.mjs +81 -0
  80. package/payload/plugins/pi/dist/SKILL.md +22 -0
  81. package/payload/plugins/pi/dist/bridge/app-server-client.cjs +82 -0
  82. package/payload/plugins/pi/dist/bridge/feishu_stop_notify.sh +169 -0
  83. package/payload/plugins/pi/dist/bridge/runweave-hook-bridge.cjs +583 -0
  84. package/payload/plugins/pi/dist/bridge/runweave-hook-completion.cjs +42 -0
  85. package/payload/plugins/pi/dist/bridge/runweave-hook-payload.cjs +578 -0
  86. package/payload/plugins/pi/dist/bridge/runweave-task-supervision.cjs +167 -0
  87. package/payload/plugins/pi/dist/runweave.js +316 -0
  88. package/payload/plugins/toolkit/.codex-plugin/plugin.json +31 -0
  89. package/payload/plugins/toolkit/README.md +185 -0
  90. package/payload/plugins/toolkit/hooks/AGENTS.md +6 -0
  91. package/payload/plugins/toolkit/hooks/app-server-client.cjs +82 -0
  92. package/payload/plugins/toolkit/hooks/feishu_stop_notify.sh +169 -0
  93. package/payload/plugins/toolkit/hooks/runweave-hook-bridge.cjs +583 -0
  94. package/payload/plugins/toolkit/hooks/runweave-hook-completion.cjs +42 -0
  95. package/payload/plugins/toolkit/hooks/runweave-hook-dispatch.cjs +123 -0
  96. package/payload/plugins/toolkit/hooks/runweave-hook-payload.cjs +578 -0
  97. package/payload/plugins/toolkit/hooks/runweave-task-supervision.cjs +167 -0
  98. package/payload/plugins/toolkit/hooks.json +108 -0
  99. package/payload/plugins/toolkit/skills/acceptance/SKILL.md +70 -0
  100. package/payload/plugins/toolkit/skills/acceptance/agents/openai.yaml +4 -0
  101. package/payload/plugins/toolkit/skills/acceptance/references/capture.md +38 -0
  102. package/payload/plugins/toolkit/skills/acceptance/references/delivery.md +54 -0
  103. package/payload/plugins/toolkit/skills/acceptance/references/gallery-contract.md +84 -0
  104. package/payload/plugins/toolkit/skills/acceptance/references/gallery-copy.md +34 -0
  105. package/payload/plugins/toolkit/skills/acceptance/references/video.md +52 -0
  106. package/payload/plugins/toolkit/skills/acceptance/scripts/capture.py +137 -0
  107. package/payload/plugins/toolkit/skills/acceptance/scripts/common.py +63 -0
  108. package/payload/plugins/toolkit/skills/acceptance/scripts/gallery.py +353 -0
  109. package/payload/plugins/toolkit/skills/acceptance/scripts/preview.py +109 -0
  110. package/payload/plugins/toolkit/skills/acceptance/scripts/video.py +283 -0
  111. package/payload/plugins/toolkit/skills/acceptance/templates/reader.css +576 -0
  112. package/payload/plugins/toolkit/skills/acceptance/templates/reader.html +63 -0
  113. package/payload/plugins/toolkit/skills/acceptance/templates/reader.js +326 -0
  114. package/payload/plugins/toolkit/skills/acceptance/templates/viewer.css +55 -0
  115. package/payload/plugins/toolkit/skills/acceptance-gallery/SKILL.md +8 -0
  116. package/payload/plugins/toolkit/skills/acceptance-gallery/agents/openai.yaml +6 -0
  117. package/payload/plugins/toolkit/skills/acceptance-gallery/references/capture-and-copy.md +3 -0
  118. package/payload/plugins/toolkit/skills/acceptance-gallery/references/content-contract.md +3 -0
  119. package/payload/plugins/toolkit/skills/acceptance-gallery/scripts/gallery.py +9 -0
  120. package/payload/plugins/toolkit/skills/acceptance-video/SKILL.md +8 -0
  121. package/payload/plugins/toolkit/skills/acceptance-video/agents/openai.yaml +6 -0
  122. package/payload/plugins/toolkit/skills/acceptance-video/references/input-and-capture.md +3 -0
  123. package/payload/plugins/toolkit/skills/acceptance-video/references/mobile-review.md +3 -0
  124. package/payload/plugins/toolkit/skills/acceptance-video/scripts/capture.py +9 -0
  125. package/payload/plugins/toolkit/skills/acceptance-video/scripts/video.py +9 -0
  126. package/payload/plugins/toolkit/skills/agent-device/SKILL.md +86 -0
  127. package/payload/plugins/toolkit/skills/agent-device/agents/openai.yaml +4 -0
  128. package/payload/plugins/toolkit/skills/agent-device/references/ios-setup.md +36 -0
  129. package/payload/plugins/toolkit/skills/agent-device/scripts/device.py +398 -0
  130. package/payload/plugins/toolkit/skills/agent-device/scripts/resources.py +248 -0
  131. package/payload/plugins/toolkit/skills/architecture-flow-prototyping/SKILL.md +128 -0
  132. package/payload/plugins/toolkit/skills/architecture-flow-prototyping/agents/openai.yaml +4 -0
  133. package/payload/plugins/toolkit/skills/architecture-flow-prototyping/references/architecture-flow-checklist.md +59 -0
  134. package/payload/plugins/toolkit/skills/architecture-flow-prototyping/references/architecture-flow-guide.md +135 -0
  135. package/payload/plugins/toolkit/skills/architecture-flow-prototyping/references/architecture-flow-handoff-template.md +57 -0
  136. package/payload/plugins/toolkit/skills/ask-first/SKILL.md +81 -0
  137. package/payload/plugins/toolkit/skills/brainstorming/SKILL.md +41 -0
  138. package/payload/plugins/toolkit/skills/browse-record/SKILL.md +35 -0
  139. package/payload/plugins/toolkit/skills/browse-record/references/app-usage.md +19 -0
  140. package/payload/plugins/toolkit/skills/browse-record/references/daily-reporting.md +115 -0
  141. package/payload/plugins/toolkit/skills/browse-record/references/zhihu.md +33 -0
  142. package/payload/plugins/toolkit/skills/browse-record/scripts/app_usage.py +110 -0
  143. package/payload/plugins/toolkit/skills/browse-record/scripts/browse_job.py +385 -0
  144. package/payload/plugins/toolkit/skills/browse-record/scripts/zhihu-read.js +126 -0
  145. package/payload/plugins/toolkit/skills/browse-record/scripts/zhihu_http.py +273 -0
  146. package/payload/plugins/toolkit/skills/clear-technical-explanations/LICENSE +21 -0
  147. package/payload/plugins/toolkit/skills/clear-technical-explanations/SKILL.md +103 -0
  148. package/payload/plugins/toolkit/skills/code-grounded-requirements/SKILL.md +54 -0
  149. package/payload/plugins/toolkit/skills/daily-doc-maintenance/SKILL.md +151 -0
  150. package/payload/plugins/toolkit/skills/daily-record/SKILL.md +63 -0
  151. package/payload/plugins/toolkit/skills/daily-record/agents/openai.yaml +4 -0
  152. package/payload/plugins/toolkit/skills/daily-record/references/browser-history.md +6 -0
  153. package/payload/plugins/toolkit/skills/daily-record/references/feishu.md +90 -0
  154. package/payload/plugins/toolkit/skills/daily-record/references/scheduled-reporting.md +144 -0
  155. package/payload/plugins/toolkit/skills/daily-record/references/scheduled-task.template.json +15 -0
  156. package/payload/plugins/toolkit/skills/daily-record/references/suiji-work-records.md +57 -0
  157. package/payload/plugins/toolkit/skills/daily-record/scripts/feishu.py +280 -0
  158. package/payload/plugins/toolkit/skills/daily-record/scripts/job.py +416 -0
  159. package/payload/plugins/toolkit/skills/daily-record/scripts/job_browser.py +77 -0
  160. package/payload/plugins/toolkit/skills/daily-record/scripts/job_facts.py +132 -0
  161. package/payload/plugins/toolkit/skills/daily-record/scripts/job_isolation.py +69 -0
  162. package/payload/plugins/toolkit/skills/daily-record/scripts/job_materials.py +154 -0
  163. package/payload/plugins/toolkit/skills/daily-record/scripts/job_screen.py +77 -0
  164. package/payload/plugins/toolkit/skills/daily-record/scripts/job_state.py +309 -0
  165. package/payload/plugins/toolkit/skills/daily-refactor/SKILL.md +101 -0
  166. package/payload/plugins/toolkit/skills/daily-refactor/scripts/compare-architecture-reports.mjs +168 -0
  167. package/payload/plugins/toolkit/skills/debugging-strategies/SKILL.md +38 -0
  168. package/payload/plugins/toolkit/skills/debugging-strategies/resources/implementation-playbook.md +520 -0
  169. package/payload/plugins/toolkit/skills/diagnostic-log-debugging/SKILL.md +79 -0
  170. package/payload/plugins/toolkit/skills/doc-coauthoring/SKILL.md +64 -0
  171. package/payload/plugins/toolkit/skills/eli5/LICENSE +21 -0
  172. package/payload/plugins/toolkit/skills/eli5/SKILL.md +18 -0
  173. package/payload/plugins/toolkit/skills/experience/SKILL.md +71 -0
  174. package/payload/plugins/toolkit/skills/experience/package.json +13 -0
  175. package/payload/plugins/toolkit/skills/git-advanced-workflows/SKILL.md +457 -0
  176. package/payload/plugins/toolkit/skills/github-pr/SKILL.md +109 -0
  177. package/payload/plugins/toolkit/skills/github-pr/scripts/github-access.mjs +292 -0
  178. package/payload/plugins/toolkit/skills/github-pr/scripts/preflight.mjs +191 -0
  179. package/payload/plugins/toolkit/skills/github-pr/scripts/source-worktree.mjs +354 -0
  180. package/payload/plugins/toolkit/skills/grill-with-docs/SKILL.md +66 -0
  181. package/payload/plugins/toolkit/skills/grill-with-docs/agents/openai.yaml +6 -0
  182. package/payload/plugins/toolkit/skills/grilling/SKILL.md +14 -0
  183. package/payload/plugins/toolkit/skills/handoff/SKILL.md +98 -0
  184. package/payload/plugins/toolkit/skills/karpathy-guidelines/SKILL.md +73 -0
  185. package/payload/plugins/toolkit/skills/playwright-cli/SKILL.md +562 -0
  186. package/payload/plugins/toolkit/skills/playwright-cli/references/element-attributes.md +23 -0
  187. package/payload/plugins/toolkit/skills/playwright-cli/references/playwright-tests.md +39 -0
  188. package/payload/plugins/toolkit/skills/playwright-cli/references/request-mocking.md +87 -0
  189. package/payload/plugins/toolkit/skills/playwright-cli/references/running-code.md +240 -0
  190. package/payload/plugins/toolkit/skills/playwright-cli/references/session-management.md +226 -0
  191. package/payload/plugins/toolkit/skills/playwright-cli/references/spec-driven-testing.md +312 -0
  192. package/payload/plugins/toolkit/skills/playwright-cli/references/storage-state.md +275 -0
  193. package/payload/plugins/toolkit/skills/playwright-cli/references/test-generation.md +138 -0
  194. package/payload/plugins/toolkit/skills/playwright-cli/references/tracing.md +142 -0
  195. package/payload/plugins/toolkit/skills/playwright-cli/references/video-recording.md +157 -0
  196. package/payload/plugins/toolkit/skills/playwright-cli/templates/standalone.config.json +7 -0
  197. package/payload/plugins/toolkit/skills/product-exploration/SKILL.md +64 -0
  198. package/payload/plugins/toolkit/skills/product-exploration/agents/openai.yaml +5 -0
  199. package/payload/plugins/toolkit/skills/prototype-first-development/SKILL.md +134 -0
  200. package/payload/plugins/toolkit/skills/prototype-first-development/references/html-prototype-template/README.md +88 -0
  201. package/payload/plugins/toolkit/skills/prototype-first-development/references/html-prototype-template/app.js +145 -0
  202. package/payload/plugins/toolkit/skills/prototype-first-development/references/html-prototype-template/index.html +229 -0
  203. package/payload/plugins/toolkit/skills/prototype-first-development/references/html-prototype-template/mock-state.json +60 -0
  204. package/payload/plugins/toolkit/skills/prototype-first-development/references/implementation-plan-handoff-template.md +61 -0
  205. package/payload/plugins/toolkit/skills/prototype-first-development/references/prototype-workflow-checklist.md +64 -0
  206. package/payload/plugins/toolkit/skills/publish-runweave-server/SKILL.md +64 -0
  207. package/payload/plugins/toolkit/skills/publish-runweave-server/agents/openai.yaml +4 -0
  208. package/payload/plugins/toolkit/skills/react-best-practices/AGENTS.md +3227 -0
  209. package/payload/plugins/toolkit/skills/react-best-practices/README.md +127 -0
  210. package/payload/plugins/toolkit/skills/react-best-practices/SKILL.md +143 -0
  211. package/payload/plugins/toolkit/skills/react-best-practices/metadata.json +15 -0
  212. package/payload/plugins/toolkit/skills/react-best-practices/rules/advanced/event-handler-refs.md +55 -0
  213. package/payload/plugins/toolkit/skills/react-best-practices/rules/advanced/init-once.md +42 -0
  214. package/payload/plugins/toolkit/skills/react-best-practices/rules/advanced/use-latest.md +39 -0
  215. package/payload/plugins/toolkit/skills/react-best-practices/rules/async/api-routes.md +38 -0
  216. package/payload/plugins/toolkit/skills/react-best-practices/rules/async/defer-await.md +80 -0
  217. package/payload/plugins/toolkit/skills/react-best-practices/rules/async/dependencies.md +52 -0
  218. package/payload/plugins/toolkit/skills/react-best-practices/rules/async/parallel.md +28 -0
  219. package/payload/plugins/toolkit/skills/react-best-practices/rules/async/suspense-boundaries.md +99 -0
  220. package/payload/plugins/toolkit/skills/react-best-practices/rules/bundle/barrel-imports.md +59 -0
  221. package/payload/plugins/toolkit/skills/react-best-practices/rules/bundle/conditional.md +37 -0
  222. package/payload/plugins/toolkit/skills/react-best-practices/rules/bundle/defer-third-party.md +49 -0
  223. package/payload/plugins/toolkit/skills/react-best-practices/rules/bundle/dynamic-imports.md +35 -0
  224. package/payload/plugins/toolkit/skills/react-best-practices/rules/bundle/preload.md +46 -0
  225. package/payload/plugins/toolkit/skills/react-best-practices/rules/client/event-listeners.md +78 -0
  226. package/payload/plugins/toolkit/skills/react-best-practices/rules/client/localstorage-schema.md +77 -0
  227. package/payload/plugins/toolkit/skills/react-best-practices/rules/client/passive-event-listeners.md +48 -0
  228. package/payload/plugins/toolkit/skills/react-best-practices/rules/client/swr-dedup.md +56 -0
  229. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/batch-dom-css.md +110 -0
  230. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/cache-function-results.md +80 -0
  231. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/cache-property-access.md +28 -0
  232. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/cache-storage.md +70 -0
  233. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/combine-iterations.md +32 -0
  234. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/early-exit.md +50 -0
  235. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/flatmap-filter.md +55 -0
  236. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/hoist-regexp.md +45 -0
  237. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/index-maps.md +37 -0
  238. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/length-check-first.md +50 -0
  239. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/min-max-loop.md +82 -0
  240. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/set-map-lookups.md +24 -0
  241. package/payload/plugins/toolkit/skills/react-best-practices/rules/js/tosorted-immutable.md +57 -0
  242. package/payload/plugins/toolkit/skills/react-best-practices/rules/meta/sections.md +46 -0
  243. package/payload/plugins/toolkit/skills/react-best-practices/rules/meta/template.md +28 -0
  244. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/activity.md +26 -0
  245. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/animate-svg-wrapper.md +38 -0
  246. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/conditional-render.md +32 -0
  247. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/content-visibility.md +38 -0
  248. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/hoist-jsx.md +36 -0
  249. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/hydration-no-flicker.md +72 -0
  250. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/hydration-suppress-warning.md +26 -0
  251. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/resource-hints.md +89 -0
  252. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/script-defer-async.md +71 -0
  253. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/svg-precision.md +28 -0
  254. package/payload/plugins/toolkit/skills/react-best-practices/rules/rendering/usetransition-loading.md +75 -0
  255. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/defer-reads.md +39 -0
  256. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/dependencies.md +45 -0
  257. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/derived-state-no-effect.md +40 -0
  258. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/derived-state.md +29 -0
  259. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/functional-setstate.md +77 -0
  260. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/lazy-state-init.md +58 -0
  261. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/memo-with-default-value.md +36 -0
  262. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/memo.md +44 -0
  263. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/move-effect-to-event.md +45 -0
  264. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/no-inline-components.md +83 -0
  265. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/simple-expression-in-memo.md +35 -0
  266. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/transitions.md +40 -0
  267. package/payload/plugins/toolkit/skills/react-best-practices/rules/rerender/use-ref-transient-values.md +73 -0
  268. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/after-nonblocking.md +74 -0
  269. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/auth-actions.md +96 -0
  270. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/cache-lru.md +41 -0
  271. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/cache-react.md +76 -0
  272. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/dedup-props.md +65 -0
  273. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/hoist-static-io.md +139 -0
  274. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/parallel-fetching.md +83 -0
  275. package/payload/plugins/toolkit/skills/react-best-practices/rules/server/serialization.md +38 -0
  276. package/payload/plugins/toolkit/skills/recorded-browser-mcp-verification/SKILL.md +8 -0
  277. package/payload/plugins/toolkit/skills/recorded-browser-mcp-verification/agents/openai.yaml +6 -0
  278. package/payload/plugins/toolkit/skills/reproduce-before-fix/SKILL.md +93 -0
  279. package/payload/plugins/toolkit/skills/reproduce-before-fix/agents/openai.yaml +7 -0
  280. package/payload/plugins/toolkit/skills/review-only/SKILL.md +72 -0
  281. package/payload/plugins/toolkit/skills/review-with-runtime-evidence/SKILL.md +134 -0
  282. package/payload/plugins/toolkit/skills/review-with-runtime-evidence/agents/openai.yaml +7 -0
  283. package/payload/plugins/toolkit/skills/review-with-runtime-evidence/references/contracts.md +114 -0
  284. package/payload/plugins/toolkit/skills/review-with-runtime-evidence/scripts/classify-runtime-verdict.mjs +140 -0
  285. package/payload/plugins/toolkit/skills/review-with-runtime-evidence/scripts/run-static-review.mjs +389 -0
  286. package/payload/plugins/toolkit/skills/review-with-runtime-evidence/scripts/static-review-contract.mjs +243 -0
  287. package/payload/plugins/toolkit/skills/run-test-cases/SKILL.md +63 -0
  288. package/payload/plugins/toolkit/skills/runweave-change-validation/SKILL.md +196 -0
  289. package/payload/plugins/toolkit/skills/runweave-change-validation/agents/openai.yaml +7 -0
  290. package/payload/plugins/toolkit/skills/runweave-change-validation/scripts/assert-dev-session-status.mjs +181 -0
  291. package/payload/plugins/toolkit/skills/runweave-dev-session/SKILL.md +126 -0
  292. package/payload/plugins/toolkit/skills/runweave-dev-session/agents/openai.yaml +7 -0
  293. package/payload/plugins/toolkit/skills/runweave-management/SKILL.md +47 -0
  294. package/payload/plugins/toolkit/skills/scheduled-task/SKILL.md +35 -0
  295. package/payload/plugins/toolkit/skills/shadcn/SKILL.md +245 -0
  296. package/payload/plugins/toolkit/skills/shadcn/agents/openai.yml +5 -0
  297. package/payload/plugins/toolkit/skills/shadcn/assets/shadcn-small.png +0 -0
  298. package/payload/plugins/toolkit/skills/shadcn/assets/shadcn.png +0 -0
  299. package/payload/plugins/toolkit/skills/shadcn/cli.md +276 -0
  300. package/payload/plugins/toolkit/skills/shadcn/customization.md +209 -0
  301. package/payload/plugins/toolkit/skills/shadcn/evals/evals.json +47 -0
  302. package/payload/plugins/toolkit/skills/shadcn/mcp.md +94 -0
  303. package/payload/plugins/toolkit/skills/shadcn/rules/base-vs-radix.md +310 -0
  304. package/payload/plugins/toolkit/skills/shadcn/rules/composition.md +197 -0
  305. package/payload/plugins/toolkit/skills/shadcn/rules/forms.md +198 -0
  306. package/payload/plugins/toolkit/skills/shadcn/rules/icons.md +101 -0
  307. package/payload/plugins/toolkit/skills/shadcn/rules/styling.md +163 -0
  308. package/payload/plugins/toolkit/skills/suiji/SKILL.md +54 -0
  309. package/payload/plugins/toolkit/skills/suiji/references/api.md +72 -0
  310. package/payload/plugins/toolkit/skills/suiji/references/source-adapter.md +40 -0
  311. package/payload/plugins/toolkit/skills/suiji/references/work-records.md +36 -0
  312. package/payload/plugins/toolkit/skills/suiji/scripts/source_adapter.py +46 -0
  313. package/payload/plugins/toolkit/skills/suiji/scripts/suiji.py +358 -0
  314. package/payload/plugins/toolkit/skills/suiji/scripts/work_records.py +328 -0
  315. package/payload/plugins/toolkit/skills/suiji/scripts/work_reports.py +75 -0
  316. package/payload/plugins/toolkit/skills/sync-branch-hard-reset/SKILL.md +59 -0
  317. package/payload/plugins/toolkit/skills/update-runweave-backend/SKILL.md +90 -0
  318. package/payload/plugins/toolkit/skills/update-runweave-backend/agents/openai.yaml +4 -0
  319. package/payload/plugins/toolkit/skills/update-runweave-backend/references/npm-update.md +68 -0
  320. package/payload/plugins/toolkit/skills/update-runweave-backend/references/systemd.md +34 -0
  321. package/payload/plugins/toolkit/skills/update-runweave-desktop/SKILL.md +102 -0
  322. package/payload/plugins/toolkit/skills/update-runweave-ios/SKILL.md +16 -0
  323. package/payload/plugins/toolkit/skills/update-runweave-ios/references/ios-wireless-recovery.md +54 -0
  324. package/payload/plugins/toolkit/skills/using-rw/SKILL.md +265 -0
  325. package/payload/plugins/toolkit/skills/write-plan/SKILL.md +72 -0
  326. package/payload/plugins/toolkit/skills/write-test-cases/SKILL.md +100 -0
  327. package/payload/plugins/toolkit/skills/write-test-cases/assets/test-plan-template.yaml +15 -0
  328. package/payload/plugins/toolkit/skills/write-test-cases/references/coverage-checklist.md +75 -0
  329. package/payload/plugins/toolkit/skills/write-test-cases/references/design-techniques.md +91 -0
  330. package/payload/plugins/toolkit/skills/youtube-reading/SKILL.md +35 -0
  331. package/payload/plugins/toolkit/skills/youtube-reading/agents/openai.yaml +4 -0
  332. package/payload/plugins/toolkit/skills/youtube-reading/assets/runtime-lock.json +92 -0
  333. package/payload/plugins/toolkit/skills/youtube-reading/references/content-contract.md +52 -0
  334. package/payload/plugins/toolkit/skills/youtube-reading/references/setup.md +70 -0
  335. package/payload/plugins/toolkit/skills/youtube-reading/requirements.lock +9 -0
  336. package/payload/plugins/toolkit/skills/youtube-reading/scripts/artifacts.py +206 -0
  337. package/payload/plugins/toolkit/skills/youtube-reading/scripts/runtime.py +424 -0
  338. package/payload/plugins/toolkit/skills/youtube-reading/scripts/youtube_reading.py +314 -0
  339. package/payload/plugins/toolkit-release.json +1 -0
  340. package/payload/scripts/toolkit/codex-state.mjs +75 -0
  341. package/payload/scripts/toolkit/release.mjs +210 -0
  342. package/payload/scripts/toolkit/sync-runtime.mjs +108 -0
  343. package/payload/scripts/toolkit/sync.mjs +585 -0
  344. package/payload/frontend/dist/assets/channel-CuSisha8.js +0 -1
  345. package/payload/frontend/dist/assets/classDiagram-6PBFFD2Q-ClJkT7PY.js +0 -1
  346. package/payload/frontend/dist/assets/classDiagram-v2-HSJHXN6E-ClJkT7PY.js +0 -1
  347. package/payload/frontend/dist/assets/clone-CPcyXi9g.js +0 -1
  348. package/payload/frontend/dist/assets/connection-BhcgnOMb.js +0 -12
  349. package/payload/frontend/dist/assets/main-BDBhLSX2.js +0 -696
  350. package/payload/frontend/dist/assets/main-Cg6Oo1xK.css +0 -33
  351. package/payload/frontend/dist/assets/stateDiagram-v2-QKLJ7IA2-DhdOfEAv.js +0 -1
  352. package/payload/frontend/dist/assets/suiji-DXtfgwxj.js +0 -1
@@ -0,0 +1,12 @@
1
+ var Je=Object.defineProperty;var Ge=(i,t,s)=>t in i?Je(i,t,{enumerable:!0,configurable:!0,writable:!0,value:s}):i[t]=s;var A=(i,t,s)=>Ge(i,typeof t!="symbol"?t+"":t,s);import{r as m,j as e,u as B}from"./index-D9-cSGu-.js";import{s as Be,B as h,I as K,t as G,v as Qe,w as Ze,x as Xe,y as Ye,E as et,G as tt,P as st,N as it,J as at,K as rt,O as nt,h as ot,r as lt,Q as ct,X as dt,U as ke}from"./main-3TPtEl66.js";import{S as Fe,r as pe,R as Ce,a as Me}from"./record-content-B7-6olQt.js";/**
2
+ * @license lucide-react v0.484.0 - ISC
3
+ *
4
+ * This source code is licensed under the ISC license.
5
+ * See the LICENSE file in the root directory of this source tree.
6
+ */const ut=[["path",{d:"M12 12h.01",key:"1mp3jc"}],["path",{d:"M16 6V4a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v2",key:"1ksdt3"}],["path",{d:"M22 13a18.15 18.15 0 0 1-20 0",key:"12hx5q"}],["rect",{width:"20",height:"14",x:"2",y:"6",rx:"2",key:"i6l2r4"}]],ht=Be("briefcase-business",ut);/**
7
+ * @license lucide-react v0.484.0 - ISC
8
+ *
9
+ * This source code is licensed under the ISC license.
10
+ * See the LICENSE file in the root directory of this source tree.
11
+ */const pt=[["path",{d:"m3 17 2 2 4-4",key:"1jhpwq"}],["path",{d:"m3 7 2 2 4-4",key:"1obspn"}],["path",{d:"M13 6h8",key:"15sg57"}],["path",{d:"M13 12h8",key:"h98zly"}],["path",{d:"M13 18h8",key:"oe0vm4"}]],ft=Be("list-checks",pt);function xt({report:i,onOpen:t}){const s=i.days.filter(a=>a.coverage!=="complete");return e.jsxs("button",{type:"button",onClick:t,className:"rounded-2xl border border-emerald-600/40 bg-emerald-50/40 p-4 text-left dark:bg-emerald-950/20",children:[e.jsxs("p",{className:"mb-2 text-xs font-medium text-emerald-700 dark:text-emerald-400",children:["周报 · ",i.from," — ",i.to]}),e.jsx("h3",{className:"mb-2 font-semibold",children:i.title}),e.jsx("p",{className:"line-clamp-2 whitespace-pre-wrap text-sm leading-7",children:i.body.replace(/[#*]/g,"")}),e.jsxs("p",{className:"mt-3 text-xs text-muted-foreground",children:[s.length?`${s.length} 天来源尚未齐全 · `:"","查看完整周报 →"]})]})}function mt({original:i,model:t,writable:s,onClose:a,onLogs:r}){const[l,n]=m.useState(i),[d,c]=m.useState(),[u,p]=m.useState(!1),[v,o]=m.useState(!1),[g,k]=m.useState(""),E="work:report:"+i.id;m.useEffect(()=>{let j=!0;return Promise.all([t.client.request("/api/suiji/v1/work-reports/"+i.id),t.store.get(E)]).then(([w,C])=>{j&&t.client.active&&(n(w.report),c(C))},w=>{j&&k(String(w))}),()=>{j=!1}},[i.id,t,E]);const x=async j=>{t.client.active&&c(j),await t.persistReportDraft(E,j)},b=async()=>{try{d||await x({title:l.title,body:l.body,version:l.version}),p(!0)}catch(j){k(String(j))}},S=async()=>{if(!d||v||!s)return;o(!0),k("");let j=d;try{if(!j.pending){if(!j.title.trim()||[...j.title.trim()].length>80||!j.body.trim()||[...j.body].length>2e4)throw new Error("标题1–80字,正文1–20000字");j={...j,pending:{path:"/api/suiji/v1/work-reports/"+l.id,method:"PATCH",key:crypto.randomUUID(),data:{title:j.title.trim(),body:j.body,expectedVersion:j.version}}},await x(j)}const w=j.pending,C=await t.client.request(w.path,w.method,w.data,w.key),R=w.data;if(C.report.id!==l.id||C.report.body!==R.body||C.report.title!==R.title||C.report.version!==R.expectedVersion+1)throw new Error("保存回执不匹配,请手动确认原请求");await t.clearReportDraft(E),t.client.active&&(n(C.report),c(void 0),p(!1),await t.load())}catch(w){w instanceof G&&!w.uncertain&&await x({...j,pending:void 0}),t.client.active&&k(String(w))}finally{t.client.active&&o(!1)}};return e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","aria-label":"周报详情",children:[e.jsxs("header",{className:"flex items-center justify-between border-b p-4",children:[e.jsx(h,{variant:"ghost",disabled:v,onClick:a,children:"返回工作"}),e.jsx("span",{children:"周报"}),e.jsx(h,{variant:"ghost",disabled:v||!s,onClick:()=>void(u?S():b()),children:u?d!=null&&d.pending?"手动确认原请求":"保存":"编辑周报"})]}),e.jsxs("div",{className:"flex-1 space-y-4 overflow-y-auto p-5",children:[g&&e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:g}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[l.from," — ",l.to," · 七个自然日"]}),l.needsReview?e.jsx("p",{className:"text-sm text-amber-600",children:"来源含历史浏览内容,此周报待人工复核。"}):null,e.jsxs("p",{className:"text-xs text-muted-foreground",children:["根据 ",l.sourceFacts.length," 条工作事实整理",l.manuallyEdited?" · 已人工编辑":""]}),l.days.some(j=>j.coverage!=="complete")&&e.jsxs("p",{className:"rounded-xl bg-amber-50 p-3 text-sm text-amber-900",children:["来源未齐:",l.days.filter(j=>j.coverage!=="complete").map(j=>j.date).join("、"),"。未上报不代表没有工作。"]}),u&&d?e.jsxs(e.Fragment,{children:[e.jsxs("label",{className:"block text-sm",children:["周报标题",e.jsx(K,{"aria-label":"周报标题",value:d.title,disabled:v||!!d.pending,onChange:j=>void x({...d,title:j.target.value}).catch(w=>k(String(w)))})]}),e.jsxs("label",{className:"block text-sm",children:["周报正文",e.jsx("textarea",{"aria-label":"周报正文",className:"min-h-80 w-full rounded-xl border bg-background p-3",value:d.body,disabled:v||!!d.pending,onChange:j=>void x({...d,body:j.target.value}).catch(w=>k(String(w)))})]}),d.pending?e.jsx("p",{children:"保存结果待确认,返回或重启不会自动发送。"}):e.jsx(h,{variant:"outline",onClick:()=>{t.client.request("/api/suiji/v1/work-reports/"+l.id).then(async j=>{n(j.report),await x({...d,version:j.report.version}),k("已更新版本,保留草稿,请核对后保存。")},j=>k(String(j)))},children:"读取最新版本并保留草稿"})]}):e.jsxs(e.Fragment,{children:[e.jsx("h2",{className:"text-xl font-semibold",children:l.title}),e.jsx("div",{className:"whitespace-pre-wrap break-words leading-8",children:l.body})]})]}),e.jsx("footer",{className:"border-t p-4",children:e.jsx(h,{variant:"outline",disabled:v,onClick:r,children:"查看原始日志"})})]})}const Ne={progress:"有进展",discussed:"讨论",documented:"已记录",attempted:"尝试","agent-reported":"Agent 反馈",verified:"已验证"},Ue=()=>new Intl.DateTimeFormat("en-CA",{timeZone:"Asia/Shanghai",year:"numeric",month:"2-digit",day:"2-digit"}).format(new Date),ne="/api/suiji/v1/work-facts",H=i=>i instanceof Error?i.message:"操作失败";class gt{constructor(t,s,a=!1){A(this,"state",{items:[],reports:[],view:"all",days:[],cursor:null,from:"",to:"",loading:!1,busy:!1,error:""});A(this,"listeners",new Set);A(this,"generation",0);A(this,"alive",!0);A(this,"writable",!1);A(this,"read");A(this,"writes",Promise.resolve());A(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));A(this,"snapshot",()=>this.state);this.client=t,this.store=s,this.reportsSupported=a}set(t){this.alive&&this.client.active&&(this.state={...this.state,...t},this.listeners.forEach(s=>s()))}persist(t,s){const a=structuredClone(s),r=this.writes.catch(()=>{}).then(()=>this.store.set(t,a));return this.writes=r,r}dispose(){var t;this.alive=!1,++this.generation,(t=this.read)==null||t.abort()}async settled(){await this.writes.catch(()=>{})}async initialize(){this.alive=!0;try{const[t,s,a]=await Promise.all([this.store.get("work:dates"),this.store.get("work:reclassify:active"),this.store.get("work:reclassify:undo")]),r=s?await this.store.get("work:reclassify:"+s):void 0;this.set({...t??{},batch:r,undo:a}),await this.load()}catch(t){this.set({error:H(t)})}}async load(t=!1,s=!0){var u;if(t&&(!this.state.cursor||this.state.loading))return;(u=this.read)==null||u.abort(),this.read=new AbortController;const a=++this.generation,{from:r,to:l,cursor:n,view:d}=this.state;this.set({loading:!0,error:"",...t?{}:{items:[],reports:[],days:[],cursor:null}});const c=new URLSearchParams({...this.reportsSupported?{view:d}:{},...r?{from:r}:{},...l?{to:l}:{},...t&&n?{cursor:n}:{}});try{const p=await this.client.request(ne+"?"+c,"GET",void 0,void 0,this.read.signal);if(!this.alive||a!==this.generation)return;const v=t?Object.values(Object.fromEntries([...this.state.days,...p.days].map(o=>[o.date,o]))):p.days;this.set({items:t?[...this.state.items,...p.items]:p.items,reports:t?[...this.state.reports,...p.reports??[]]:p.reports??[],days:v,cursor:p.nextCursor})}catch(p){if(!this.alive||a!==this.generation)return;if(p instanceof G&&p.detail.error.code==="WORK_FEED_CHANGED"&&s){await this.load(!1,!1);return}this.set({error:H(p)})}finally{a===this.generation&&this.set({loading:!1})}}persistReportDraft(t,s){return this.persist(t,s)}async clearReportDraft(t){await this.writes,await this.store.remove(t)}async show(t,s=this.state.from,a=this.state.to){this.set({view:t}),await this.dates(s,a)}async dates(t,s){if(t&&s&&t>s){this.set({error:"开始日期不能晚于结束日期"});return}await this.persist("work:dates",{from:t,to:s}),this.set({from:t,to:s}),await this.load()}async detail(t){try{const s=await this.client.request(ne+"/"+t);this.set({detail:s.fact})}catch(s){this.set({error:H(s)})}}closeDetail(){this.set({detail:void 0})}async edit(t){try{await this.writes;const s=(t==null?void 0:t.id)??"new",a=s==="new"?"work:new":"work:edit:"+s,r=await this.store.get(a)??{id:s,fields:t?{workDate:t.workDate,title:t.title,statement:t.statement,status:t.status,project:t.project}:{workDate:Ue(),title:"",statement:"",status:"progress",project:null},...t?{base:t}:{}};await this.persist(a,r),this.set({draft:r,error:""})}catch(s){this.set({error:H(s)})}}update(t){const s=this.state.draft;if(!this.writable||!s||s.pending||this.state.busy)return;const a={...s,fields:{...s.fields,...t}};this.set({draft:a}),this.persist(a.id==="new"?"work:new":"work:edit:"+a.id,a).catch(r=>this.set({error:H(r)}))}closeEditor(){this.state.busy||this.set({draft:void 0})}async discardEditor(){const t=this.state.draft;if(!(!t||t.pending||this.state.busy))try{await this.writes,await this.store.remove(t.id==="new"?"work:new":"work:edit:"+t.id),this.set({draft:void 0})}catch(s){this.set({error:H(s)})}}async refreshVersion(){const t=this.state.draft;if(!(!(t!=null&&t.base)||t.pending||this.state.busy))try{const{fact:s}=await this.client.request(ne+"/"+t.id),a={...t,base:s};await this.persist("work:edit:"+t.id,a),this.set({draft:a,detail:s,error:"已读取当前版本,下方保留你的草稿;请核对最新事实后再保存。"})}catch(s){this.set({error:H(s)})}}async save(){var a,r;let t=this.state.draft;if(!this.writable||!t||this.state.busy)return;this.set({busy:!0,error:""});const s=t.id==="new"?"work:new":"work:edit:"+t.id;try{if(await this.writes,!t.pending){const d=t.fields;if(!d.title.trim()||!d.statement.trim()||[...d.title.trim()].length>80||[...d.statement].length>4e3||[...((a=d.project)==null?void 0:a.trim())??""].length>80||!/^\d{4}-\d\d-\d\d$/.test(d.workDate))throw new Error("请填写有效工作日期、1–80字标题及1–4000字正文;项目最多80字");const c={...d,title:d.title.trim(),project:((r=d.project)==null?void 0:r.trim())||null},u=t.base?{expectedVersion:t.base.version,...Object.fromEntries(Object.entries(c).filter(([p,v])=>v!==t.base[p]))}:c;if(t.base&&Object.keys(u).length===1){this.set({draft:void 0});return}t={...t,pending:{key:crypto.randomUUID(),method:t.base?"PATCH":"POST",path:ne+(t.base?"/"+t.id:""),data:u}},await this.persist(s,t),this.set({draft:t})}const l=t.pending,{fact:n}=await this.client.request(l.path,l.method,l.data,l.key);if(!(n!=null&&n.id)||t.base&&n.id!==t.id||Object.entries(l.data).some(([d,c])=>d!=="expectedVersion"&&n[d]!==c))throw new Error("保存回执不匹配,请手动确认原请求");await this.store.remove(s),this.set({draft:void 0,detail:n}),await this.dates(n.workDate,n.workDate)}catch(l){l instanceof G&&!l.uncertain&&t.pending&&(t={...t,pending:void 0},await this.persist(s,t),this.set({draft:t})),this.set({error:H(l)})}finally{this.set({busy:!1})}}async beginBatch(t,s=!1){if(!(this.state.batch||this.state.busy))try{const a={id:crypto.randomUUID(),rows:t,project:"",...s?{undo:s}:{}};await this.persist("work:reclassify:"+a.id,a),await this.persist("work:reclassify:active",a.id),this.set({batch:a,error:""})}catch(a){this.set({error:H(a)})}}updateBatch(t,s){const a=this.state.batch;if(!a||a.pending||this.state.busy)return;const r={...a,rows:t,project:s};this.set({batch:r}),this.persist("work:reclassify:"+a.id,r).catch(l=>this.set({error:H(l)}))}async refreshBatch(){const t=this.state.batch;if(!(!this.writable||!t||t.undo||t.pending||this.state.busy))try{const s=await Promise.all(t.rows.map(async r=>(await this.client.request(ne+"/"+r.id)).fact)),a={...t,rows:s};await this.persist("work:reclassify:"+t.id,a),this.set({batch:a,error:"已读取所选事实的最新版本,请核对后再确认归类。"})}catch(s){this.set({error:H(s)})}}async cancelBatch(){const t=this.state.batch;if(!(!t||t.pending||this.state.busy))try{await this.writes,await this.store.remove("work:reclassify:"+t.id),await this.store.remove("work:reclassify:active"),this.set({batch:void 0})}catch(s){this.set({error:H(s)})}}async undo(){this.state.undo&&!this.state.batch&&await this.beginBatch([],!0)}async commitBatch(){let t=this.state.batch;if(!this.writable||!t||this.state.busy)return;this.set({busy:!0,error:""});const s="work:reclassify:"+t.id;try{if(await this.writes,!t.pending){if(!t.undo&&(t.rows.length<1||t.rows.length>100))throw new Error("请选择1–100条已加载记录");const c=t.undo?this.state.undo:{items:t.rows.map(u=>({id:u.id,expectedVersion:u.version})),project:t.project.trim()||null};if(!c)throw new Error("没有可撤销的项目调整");t={...t,pending:{path:ne+(t.undo?"/reclassify/undo":"/reclassify"),method:"POST",data:c,key:crypto.randomUUID()}},await this.persist(s,t),this.set({batch:t})}const a=t.pending,{facts:r}=await this.client.request(a.path,a.method,a.data,a.key),l=a.data;if(!Array.isArray(r)||r.length!==l.items.length||l.items.some(c=>!r.some(u=>u.id===c.id&&u.version===c.expectedVersion+1&&u.project===("project"in c?c.project:l.project))))throw new Error("归类回执不匹配,请手动确认原请求");const n=t.undo?void 0:{items:r.map(c=>({id:c.id,expectedVersion:c.version,project:t.rows.find(u=>u.id===c.id).project}))};n?await this.persist("work:reclassify:undo",n):await this.store.remove("work:reclassify:undo"),await this.store.remove(s),await this.store.remove("work:reclassify:active");const d=r.find(c=>{var u;return c.id===((u=this.state.detail)==null?void 0:u.id)})??this.state.detail;this.set({batch:void 0,undo:n,detail:d}),await this.load()}catch(a){a instanceof G&&!a.uncertain&&t.pending&&(t={...t,pending:void 0},await this.persist(s,t),this.set({batch:t})),this.set({error:H(a)})}finally{this.set({busy:!1})}}}function vt({model:i,writable:t}){const{draft:s,busy:a,error:r,detail:l}=i.state;if(!s)return null;const n=!t||a||!!s.pending,d=(c,u)=>i.update({[c]:u});return e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","aria-label":"工作事实编辑",children:[e.jsxs("header",{className:"flex items-center justify-between border-b p-4",children:[e.jsx(h,{variant:"ghost",disabled:a,onClick:()=>i.closeEditor(),children:"返回"}),e.jsx("h2",{children:s.base?"编辑事实":"补记事实"}),e.jsx(h,{disabled:a||!t,onClick:()=>void i.save(),children:a?"保存中…":s.pending?"手动确认原请求":"保存"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-5 overflow-y-auto p-5",children:[r?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:r}):null,s.pending?e.jsx("p",{role:"status",className:"text-sm",children:"保存结果待确认。原请求已保存在本机,返回或重启不会自动发送。"}):null,e.jsxs("label",{className:"space-y-2 text-sm",children:["工作日期",e.jsx(K,{type:"date","aria-label":"工作日期",disabled:n,value:s.fields.workDate,onChange:c=>d("workDate",c.target.value)})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["标题",e.jsx(K,{"aria-label":"事实标题",disabled:n,value:s.fields.title,onChange:c=>d("title",c.target.value)})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["事实正文",e.jsx("textarea",{"aria-label":"事实正文",disabled:n,className:"min-h-48 w-full rounded-xl border bg-background p-3",value:s.fields.statement,onChange:c=>d("statement",c.target.value)})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["实际状态",e.jsx("select",{"aria-label":"事实状态",disabled:n,className:"w-full rounded-xl border bg-background p-3",value:s.fields.status,onChange:c=>i.update({status:c.target.value}),children:Object.entries(Ne).map(([c,u])=>e.jsx("option",{value:c,children:u},c))})]}),e.jsxs("label",{className:"space-y-2 text-sm",children:["项目(可选)",e.jsx(K,{"aria-label":"事实项目",placeholder:"未归类",disabled:n,value:s.fields.project??"",onChange:c=>i.update({project:c.target.value||null})})]}),s.base&&!s.pending?e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"outline",disabled:a,onClick:()=>void i.refreshVersion(),children:"读取最新版本并保留草稿"}),(l==null?void 0:l.id)===s.id?e.jsxs("div",{className:"whitespace-pre-wrap rounded-xl bg-secondary p-3 text-sm",children:[e.jsxs("p",{children:["服务当前 v",l.version," · ",l.workDate," ·"," ",l.project??"未归类"]}),e.jsx("strong",{children:l.title}),e.jsx("p",{children:l.statement})]}):null]}):null,e.jsx(h,{variant:"ghost",disabled:n,onClick:()=>void i.discardEditor(),children:"丢弃未保存草稿"})]})]})}function bt({model:i,writable:t}){const{batch:s,items:a,busy:r,error:l,undo:n}=i.state;if(!s)return null;const d=!t||r||!!s.pending,c=new Set(s.rows.map(p=>p.id)),u=[...s.rows,...a.filter(p=>!c.has(p.id))];return e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","aria-label":"重新归类",children:[e.jsxs("header",{className:"flex items-center justify-between border-b p-4",children:[e.jsx("h2",{children:s.undo?"撤销本次归类":"重新归类"}),e.jsx(h,{variant:"ghost",disabled:d,onClick:()=>void i.cancelBatch(),children:"取消"})]}),e.jsxs("div",{className:"flex flex-1 flex-col gap-4 overflow-y-auto p-5",children:[l?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:l}):null,s.pending?e.jsx("p",{children:"操作结果待确认,原请求已保存在本机;不会自动重发。"}):null,s.undo?e.jsxs("p",{children:["按原成功回执的版本还原 ",(n==null?void 0:n.items.length)??0," ","条记录的项目;任何一条版本变化将整批停止。"]}):e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",disabled:d,onClick:()=>void i.refreshBatch(),children:"读取所选事实最新版本"}),e.jsxs("p",{className:"text-sm",children:["已选 ",s.rows.length," 条。仅修改项目,正文、日期和状态保持。"]}),e.jsx(h,{variant:"outline",disabled:d||a.length>100,onClick:()=>i.updateBatch([...new Map([...s.rows,...a].map(p=>[p.id,p])).values()],s.project),children:"全选已加载记录"}),i.state.cursor?e.jsx("p",{className:"text-sm text-muted-foreground",children:"还有未加载记录;返回列表加载后再选择。"}):null,e.jsxs("label",{className:"text-sm",children:["目标项目(留空为未归类)",e.jsx(K,{"aria-label":"目标项目",list:"work-projects",disabled:d,value:s.project,onChange:p=>i.updateBatch(s.rows,p.target.value)})]}),e.jsx("datalist",{id:"work-projects",children:[...new Set(a.map(p=>p.project).filter(p=>!!p))].map(p=>e.jsx("option",{value:p},p))}),e.jsx("div",{className:"flex flex-col gap-3",children:u.map(p=>e.jsxs("label",{className:"flex items-start gap-3 rounded-xl border p-3 text-sm",children:[e.jsx("input",{type:"checkbox","aria-label":`选择 ${p.title}`,disabled:d||!c.has(p.id)&&s.rows.length>=100,checked:c.has(p.id),onChange:v=>i.updateBatch(v.target.checked?[...s.rows,p]:s.rows.filter(o=>o.id!==p.id),s.project)}),e.jsxs("span",{children:[e.jsx("strong",{children:p.title}),e.jsx("br",{}),p.workDate," · ",p.project??"未归类",e.jsx("br",{}),e.jsx("small",{children:p.id})]})]},p.id))})]})]}),e.jsx("div",{className:"shrink-0 border-t bg-background p-4",children:e.jsx(h,{className:"h-auto min-h-10 w-full whitespace-normal break-words",disabled:!t||r||!s.undo&&!s.rows.length,onClick:()=>void i.commitBatch(),children:r?"保存中…":s.pending?"手动确认原请求":s.undo?"确认撤销项目调整":`确认 ${s.rows.length} 条 → ${s.project.trim()||"未归类"}`})})]})}function jt({model:i,active:t,writable:s,onReview:a}){const r=m.useSyncExternalStore(i.subscribe,i.snapshot),[l,n]=m.useState(!1),[d,c]=m.useState(""),[u,p]=m.useState(""),[v,o]=m.useState(!1);m.useEffect(()=>{i.writable=s},[i,s]),m.useEffect(()=>{t&&i.load()},[t,i]);const{detail:g,draft:k,batch:E}=r,[x,b]=m.useState();if(x)return e.jsx(mt,{original:x,model:i,writable:s,onClose:()=>b(void 0),onLogs:()=>{b(void 0),i.show("logs",x.from,x.to)}});const S=w=>{const C=Math.round((Date.parse(Ue()+"T00:00:00Z")-Date.parse(w+"T00:00:00Z"))/864e5);return`${C===0?"今天 · ":C===1?"昨天 · ":C===2?"前天 · ":""}${w}`},j=()=>{if(r.view==="reports")return"这个日期范围尚无周报";const w=r.from&&r.to?Math.floor((Date.parse(r.to)-Date.parse(r.from))/864e5)+1:0;return w>0&&r.days.length===w&&r.days.every(C=>C.coverage==="complete"&&C.count===0)?"已导入范围内没有记录":r.days.some(C=>C.coverage==="partial")?"记录尚未完整导入":"这个日期范围尚未导入工作记录"};return e.jsxs("div",{className:"relative flex min-h-0 flex-1 flex-col",children:[e.jsxs("div",{className:k||E||g?"hidden":"flex min-h-0 flex-1 flex-col",children:[e.jsxs("header",{className:"flex shrink-0 items-center justify-between px-5 py-3",children:[e.jsx("h1",{className:"text-lg font-semibold",children:"工作"}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>{c(r.from),p(r.to),n(w=>!w)},children:"日期"}),e.jsx(h,{variant:"ghost",size:"sm","aria-label":"工作更多",onClick:()=>o(w=>!w),children:"更多"})]})]}),i.reportsSupported&&e.jsx("div",{className:"flex gap-2 px-5 pb-3","aria-label":"工作类型",children:[["all","全部"],["logs","日志"],["reports","总结"]].map(([w,C])=>e.jsx(h,{size:"sm",variant:r.view===w?"secondary":"ghost",onClick:()=>void i.show(w),children:C},w))}),v?e.jsxs("div",{className:"flex flex-wrap gap-2 border-y px-5 py-2",children:[e.jsx(h,{variant:"ghost",size:"sm",disabled:r.loading,onClick:()=>{o(!1),i.load()},children:"刷新工作"}),e.jsx(h,{variant:"ghost",size:"sm",onClick:()=>{o(!1),a()},children:"AI 回顾"}),e.jsx(h,{variant:"ghost",size:"sm",disabled:!s,onClick:()=>{o(!1),i.beginBatch([])},children:"重新归类"}),r.undo?e.jsx(h,{variant:"ghost",size:"sm",disabled:!s,onClick:()=>{o(!1),i.undo()},children:"撤销上次归类"}):null]}):null,l?e.jsxs("form",{className:"flex flex-col gap-3 border-y p-5",onSubmit:w=>{w.preventDefault(),(!d||!u||d<=u)&&(n(!1),i.dates(d,u))},children:[e.jsxs("label",{className:"text-sm",children:["开始日期",e.jsx(K,{type:"date","aria-label":"开始日期",value:d,onChange:w=>c(w.target.value)})]}),e.jsxs("label",{className:"text-sm",children:["结束日期",e.jsx(K,{type:"date","aria-label":"结束日期",value:u,onChange:w=>p(w.target.value)})]}),d&&u&&d>u?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:"开始日期不能晚于结束日期"}):null,e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"submit",disabled:!!(d&&u&&d>u),children:"应用日期"}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>{n(!1),i.dates("","")},children:"清空日期"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>n(!1),children:"取消"})]})]}):null,r.from||r.to?e.jsxs("p",{className:"px-5 pb-2 text-sm text-muted-foreground",children:[r.from||"最早"," 至 ",r.to||"最近"]}):null,e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto px-5 pb-24","aria-label":"工作事实列表",children:[r.error?e.jsx("p",{role:"alert",className:"py-3 text-sm text-destructive",children:r.error}):null,[...new Set([...r.items.map(w=>w.workDate),...r.reports.map(w=>w.to)])].sort().reverse().map(w=>{var C;return e.jsxs("section",{className:"pb-5",children:[e.jsxs("h2",{className:"mb-3 text-sm font-medium text-muted-foreground",children:[S(w)," ",e.jsxs("span",{children:["· ",((C=r.days.find(R=>R.date===w))==null?void 0:C.count)??"…"," 条"]})]}),e.jsxs("div",{className:"flex flex-col gap-3",children:[r.reports.filter(R=>R.to===w).map(R=>e.jsx(xt,{report:R,onOpen:()=>b(R)},R.id)),r.items.filter(R=>R.workDate===w).map(R=>e.jsxs("button",{type:"button",onClick:()=>void i.detail(R.id),className:"rounded-2xl border bg-card p-4 text-left",children:[e.jsxs("p",{className:"mb-2 text-xs text-muted-foreground",children:[R.project??"未归类"," · ",Ne[R.status]]}),e.jsx("h3",{className:"mb-2 font-semibold",children:R.title}),e.jsx("p",{className:"whitespace-pre-wrap break-words text-sm leading-7",children:R.statement})]},R.id))]})]},w)}),!r.loading&&!r.items.length&&!r.reports.length?e.jsx("p",{className:"py-16 text-center text-muted-foreground",children:j()}):null,r.loading?e.jsx("p",{role:"status",className:"py-8 text-center",children:"正在读取工作事实…"}):null,r.cursor?e.jsx(h,{variant:"outline",className:"w-full",disabled:r.loading,onClick:()=>void i.load(!0),children:"加载更多工作记录"}):null]}),e.jsx(h,{"aria-label":"补记工作事实",className:"absolute bottom-5 right-5 size-12 rounded-full text-2xl shadow-lg",disabled:!s,onClick:()=>void i.edit(),children:"+"})]}),g&&!k&&!E?e.jsxs("section",{className:"flex min-h-0 flex-1 flex-col","aria-label":"工作事实详情",children:[e.jsxs("header",{className:"flex items-center justify-between border-b p-4",children:[e.jsx(h,{variant:"ghost",onClick:()=>i.closeDetail(),children:"返回工作"}),e.jsx(h,{variant:"ghost",disabled:!s,onClick:()=>void i.edit(g),children:"编辑事实"})]}),e.jsxs("div",{className:"flex-1 overflow-y-auto p-5",children:[e.jsxs("p",{className:"mb-3 text-sm text-muted-foreground",children:[g.workDate," · ",g.project??"未归类"," ·"," ",Ne[g.status]]}),e.jsx("h2",{className:"mb-4 text-xl font-semibold",children:g.title}),e.jsx("p",{className:"mb-6 whitespace-pre-wrap break-words leading-8",children:g.statement}),e.jsx(h,{variant:"outline",disabled:!s,onClick:()=>void i.beginBatch([g]),children:"重新归类这条"})]})]}):null,k?e.jsx(vt,{model:i,writable:s}):E?e.jsx(bt,{model:i,writable:s}):null]})}const ue={bodyScalars:2e4,attachmentBytes:5*1024*1024,imagesPerRecord:1,markdownPerRecord:1,defaultPageSize:20,maxPageSize:100,tagsPerRecord:2,tagScalars:20};function Le(i){if(i.length>ue.tagsPerRecord)throw new Error("最多 2 个标签");const t=i.map(s=>s.trim());if(t.some(s=>!s||[...s].length>ue.tagScalars||/[\u0000-\u001f\u007f\uD800-\uDFFF]/u.test(s)))throw new Error("标签须为 1–20 个字符,不能包含控制字符或无效 Unicode");if(new Set(t).size!==t.length)throw new Error("标签不能重复");return t}function wt(i,t){var s,a;return(((s=i==null?void 0:i.latest)==null?void 0:s.sequence)??0)>(((a=t==null?void 0:t.latest)==null?void 0:a.sequence)??0)?i:t??i}function yt(i){return`使用随记 Skill 处理这条记录。先读取最新原文、全部跟进和相关附件,按我本次要求执行。完整结果、图片和文档在当前终端交付;随记只追加简短最终摘要,默认不上传图片、文档或附件,不记录过程或失败。后续问答、补图不自动回写。未经我确认,不标记完成。
12
+ `+JSON.stringify({format:"suiji-handoff-v1",...i},null,2)}class $e{constructor(t,s,a,r,l=!1){A(this,"listeners",new Set);A(this,"queue",Promise.resolve());A(this,"writes",0);A(this,"active",!0);A(this,"state");A(this,"correctionAbort");A(this,"correctionKey");A(this,"subscribe",t=>(this.listeners.add(t),()=>{this.listeners.delete(t)}));A(this,"snapshot",()=>this.state);A(this,"lastSaveDiagnostics");this.client=s,this.store=a,this.followupRecordId=r,this.historySupported=l,this.state={draft:t,busy:!1,localSaving:!1,message:t.frozen?"保存结果待确认,请手动重试;输入暂时锁定":"",localError:!1,conflict:!1}}get storeKey(){return this.followupRecordId?"followup:"+this.followupRecordId:"draft:"+this.state.draft.id}dispose(){var t;this.active=!1,(t=this.correctionAbort)==null||t.abort(),this.listeners.clear()}settled(){return this.queue}initialize(){return this.loadFeedbackState(),this.persist()}async discard(){if(!(this.state.busy||this.state.draft.frozen)){this.patch({busy:!0});try{await this.queue,this.check(),await this.store.remove(this.storeKey),this.patch({discarded:!0})}catch(t){this.patch({message:t instanceof Error?t.message:"放弃草稿失败"})}finally{this.patch({busy:!1})}}}check(){if(!this.active||!this.client.active)throw new DOMException("编辑会话已结束","AbortError")}patch(t){this.state={...this.state,...t},this.listeners.forEach(s=>s())}persist(t=this.state.draft){const s=structuredClone(t);++this.writes,this.patch({localSaving:!0});const a=this.queue.then(()=>this.store.set(this.storeKey,s));return this.queue=a.catch(()=>{}),a.then(()=>this.patch({localError:!1})).catch(r=>{throw this.patch({message:r instanceof Error?r.message:"本机草稿未保存",localError:!0}),r}).finally(()=>{--this.writes,this.patch({localSaving:this.writes>0})})}edit(t){if(this.state.busy||this.state.draft.frozen)return;const s={...this.state.draft,...t};this.patch({draft:s,...t.body!==void 0&&t.body!==this.state.draft.body?{correction:void 0,correctionSource:void 0}:{}}),this.persist(s).catch(()=>{})}async loadLexicon(){try{const t=await this.store.get("lexicon-intent");this.check(),this.patch({lexiconPending:!!t});const s=await this.client.request("/api/suiji/v1/correction-lexicon");this.check(),this.patch({lexicon:s})}catch(t){this.active&&this.patch({correctionMessage:t instanceof Error?t.message:"词库读取失败"})}}async correct(){const t=this.state.draft.body;if(this.state.busy||this.state.draft.frozen||!t.trim()||this.state.correctionBusy)return;if(this.correctionKey&&this.state.correctionSource!==t){this.patch({correctionMessage:"原请求结果待确认;请先取消,再对新正文发起纠错"});return}const s=new AbortController;this.correctionAbort=s;const a=this.correctionKey??crypto.randomUUID();this.correctionKey=a,this.patch({correctionBusy:!0,correction:void 0,correctionSource:t,correctionMessage:"正在纠正文字…"});try{let r=await this.client.request("/api/suiji/v1/corrections","POST",{text:t,...this.historySupported&&!this.followupRecordId?{feedbackCapable:!0,...this.state.draft.id!=="new"?{recordId:this.state.draft.id}:{}}:{}},a,s.signal);for(this.check(),this.patch({correction:r});r.status==="running"&&!s.signal.aborted;)await new Promise(l=>setTimeout(l,1e3)),this.check(),r=await this.client.request("/api/suiji/v1/corrections/"+r.id,"GET",void 0,void 0,s.signal),this.patch({correction:r});if(this.check(),s.signal.aborted)return;this.correctionKey=void 0,this.patch({correction:r,correctionMessage:r.status==="completed"?"":r.error??"纠错未完成"})}catch(r){this.active&&!s.signal.aborted&&this.patch({correctionMessage:"纠错结果待确认;再次点击会沿用同一请求。"+(r instanceof Error?r.message:"")})}finally{this.correctionAbort===s&&(this.correctionAbort=void 0,this.patch({correctionBusy:!1}))}}async cancelCorrection(){var s,a;const t=(s=this.state.correction)==null?void 0:s.id;(a=this.correctionAbort)==null||a.abort(),t&&await this.client.request("/api/suiji/v1/corrections/"+t,"DELETE").catch(()=>{}),this.correctionKey=void 0,this.patch({correction:void 0,correctionSource:void 0,correctionBusy:!1,correctionMessage:""})}applyCorrection(){const{correction:t,correctionSource:s,draft:a}=this.state;if(!t||t.status!=="completed"||!t.correctedText||s!==a.body||a.frozen||this.state.busy||!this.active||!this.client.active){this.patch({correctionMessage:"正文或编辑会话已变化,请重新纠错"});return}const r={...a,body:t.correctedText,correctionTrace:t.historyId&&this.state.correctionSource?{correctionId:t.id,inputText:this.state.correctionSource,correctedText:t.correctedText,applied:!0}:void 0};this.patch({draft:r,correction:void 0,correctionSource:void 0}),this.persist(r).catch(()=>{}),this.patch({correctionMessage:"已应用到本机草稿;点击保存才会更新记录"})}async putLexicon(t){this.check();const s=this.state.lexicon;if(!s)throw new Error("请先读取词库");const r=await this.store.get("lexicon-intent")??{key:crypto.randomUUID(),data:{expectedVersion:s.version,entries:t}};await this.store.set("lexicon-intent",r),this.patch({lexiconPending:!0});try{const l=await this.client.request("/api/suiji/v1/correction-lexicon","PUT",r.data,r.key);this.check(),await this.store.remove("lexicon-intent"),this.patch({lexicon:l,lexiconPending:!1,correctionMessage:"已记住;可在词库中撤销"})}catch(l){throw l instanceof G&&!l.uncertain&&(await this.store.remove("lexicon-intent"),this.patch({lexiconPending:!1})),this.patch({correctionMessage:l instanceof Error?l.message:"词库结果待确认,请手动重试"}),l}}async addFile(t){try{if(this.check(),t.size>ue.attachmentBytes)throw new Error("每个附件最多 5 MiB");const s=["image/jpeg","image/png"].includes(t.type);if(!s&&!/\.md$/i.test(t.name))throw new Error("仅支持 JPEG、PNG 和 Markdown");s||new TextDecoder("utf-8",{fatal:!0}).decode(await t.arrayBuffer()),this.check();const a=this.state.draft,r=s?"image":"markdown";if(a.existing.some(l=>l.kind===r)||a.files.some(l=>(l.file.type.startsWith("image/")?"image":"markdown")===r))throw new Error("每条最多一张图片和一个 Markdown,请先移除原附件");s||(t=new File([t],t.name,{type:"text/markdown",lastModified:t.lastModified})),this.edit({files:[...a.files,{id:crypto.randomUUID(),file:t,key:crypto.randomUUID()}]})}catch(s){this.patch({message:s instanceof Error?s.message:"附件读取失败"})}}async save(){var r,l;const t=Qe("suiji_save");this.lastSaveDiagnostics=t;let s=!1,a=!1;if(this.state.busy||this.state.saved||this.state.savedFollowup){t.stage("rejected");return}this.patch({busy:!0,message:""});try{this.check();let n=this.state.draft;if(!this.followupRecordId&&!n.pending&&n.tags!==void 0&&(n={...n,tags:Le(n.tags)},this.patch({draft:n})),[...n.body].length>ue.bodyScalars)throw new Error("正文最多 20,000 个字符");if(!n.body.trim()&&!n.existing.length&&!n.files.length)throw new Error("请输入正文或添加附件");if(await this.persist(n),this.check(),!n.pending){n={...n,frozen:!0},this.patch({draft:n}),await this.persist(n);for(const[u,p]of n.files.entries()){if(p.uploaded)continue;this.check();const v=new FormData;v.append("file",p.file,p.file.name);const o=await this.client.request("/api/suiji/v1/uploads","POST",v,p.key);this.check(),n={...n,files:n.files.map((g,k)=>k===u?{...g,uploaded:o.attachment}:g)},this.patch({draft:n}),await this.persist(n)}n={...n,pending:{path:this.followupRecordId?`/api/suiji/v1/records/${this.followupRecordId}/followups`:"/api/suiji/v1/records"+(n.id==="new"?"":"/"+n.id),method:this.followupRecordId||n.id==="new"?"POST":"PATCH",key:crypto.randomUUID(),data:{...this.followupRecordId?{}:{kind:n.kind,...n.id==="new"?{}:{expectedVersion:n.version}},body:n.body,...this.followupRecordId||n.tags===void 0?{}:{tags:n.tags},attachmentIds:[...n.existing.map(u=>u.id),...n.files.map(u=>u.uploaded.id)]}}},this.patch({draft:n}),await this.persist(n)}this.check();const d=n.pending;s=!0,t.stage("request_started",void 0,d.key);const c=await this.client.request(d.path,d.method,d.data,d.key);if(t.stage("response_received"),this.check(),this.followupRecordId&&(!("followup"in c)||c.followup.recordId!==this.followupRecordId||c.followup.body!==n.body||JSON.stringify(c.followup.attachments.map(u=>u.id))!==JSON.stringify(n.files.map(u=>u.uploaded.id))||((r=c.followupSummary.latest)==null?void 0:r.sequence)!==c.followup.sequence))throw new Error("跟进响应与保存内容不一致,请手动重试确认");if("record"in c&&(c.record.body!==n.body||n.id!=="new"&&c.record.id!==n.id))throw new Error("记录响应与保存正文不一致,请手动重试确认");a=!0,t.stage("confirmed"),"record"in c&&((l=n.correctionTrace)!=null&&l.applied)&&(n.version===void 0||c.record.version>n.version)&&await this.enqueueFeedback({correctionId:n.correctionTrace.correctionId,key:crypto.randomUUID(),recordId:c.record.id,recordVersion:c.record.version,saveKey:d.key}).catch(()=>{}),await this.store.remove(this.storeKey),"record"in c&&this.retryFeedback(),"followup"in c?this.patch({savedFollowup:c}):this.patch({saved:c.record}),t.stage("state_updated")}catch(n){if(t.stage(s&&!a&&!(n instanceof G&&!n.uncertain)?"unknown":"failed",n),!this.active)return;if(n instanceof G&&!n.uncertain){const d=n.detail.error.code==="VERSION_CONFLICT",c={...this.state.draft,frozen:!1,pending:void 0};this.patch({draft:c,conflict:d,message:n.message}),await this.persist(c).catch(()=>{})}else this.patch({message:(this.state.draft.frozen?"保存结果待确认,手动重试会沿用同一次请求。":"")+(n instanceof Error?n.message:"保存失败")})}finally{this.patch({busy:!1})}}async loadPreferences(){if(this.historySupported)try{const t=await this.client.request("/api/suiji/v1/correction-preferences");this.check(),this.patch({preferences:t})}catch(t){this.patch({correctionMessage:t instanceof Error?t.message:"读取历史设置失败"})}}async setHistoryEnabled(t){const s=this.state.preferences;if(s)try{const a=await this.client.request("/api/suiji/v1/correction-preferences","PUT",{expectedVersion:s.version,historyEnabled:t},crypto.randomUUID());this.check(),this.patch({preferences:a})}catch(a){this.patch({correctionMessage:a instanceof Error?a.message:"设置失败"})}}async loadHistory(t){if(this.historySupported)try{const s=await this.client.request("/api/suiji/v1/correction-history"+(t?"?cursor="+encodeURIComponent(t):""));this.check(),this.patch({history:t&&this.state.history?{items:[...this.state.history.items,...s.items],nextCursor:s.nextCursor}:s})}catch(s){this.patch({correctionMessage:s instanceof Error?s.message:"历史读取失败"})}}async deleteHistory(t){try{await this.client.request("/api/suiji/v1/correction-history"+(t?"/"+t:""),"DELETE",void 0,crypto.randomUUID()),this.check(),await this.loadHistory(),await this.loadPreferences()}catch(s){this.patch({correctionMessage:s instanceof Error?s.message:"删除失败"})}}async loadFeedbackState(){const t=await this.store.get("feedback-intents").catch(()=>{});this.active&&this.patch({feedbackPending:!!(t!=null&&t.length)})}async enqueueFeedback(t){const s=await this.store.get("feedback-intents")??[];await this.store.set("feedback-intents",[...s,t]),this.patch({feedbackPending:!0})}async retryFeedback(){const t=await this.store.get("feedback-intents").catch(()=>{});if(!(t!=null&&t.length))return;const s=[];for(const a of t)try{await this.client.request("/api/suiji/v1/corrections/"+a.correctionId+"/feedback","POST",{recordId:a.recordId,recordVersion:a.recordVersion,saveKey:a.saveKey},a.key)}catch(r){(!(r instanceof G)||r.uncertain)&&s.push(a)}s.length?await this.store.set("feedback-intents",s):await this.store.remove("feedback-intents"),this.patch({feedbackPending:!!s.length})}async loadLatest(){if(!(this.state.busy||this.state.draft.id==="new"))try{const{record:t}=await this.client.request("/api/suiji/v1/records/"+this.state.draft.id);this.check(),this.patch({latest:t})}catch(t){this.patch({message:t instanceof Error?t.message:"读取最新版本失败"})}}acceptLatestVersion(){const t=this.state.latest;if(!t||this.state.busy||this.state.draft.frozen)return;const s={...this.state.draft,version:t.version,existing:t.attachments,files:[]};if(this.state.draft.files.length){this.patch({message:"本机还有新增附件,请先保存其文件并移除,再采用最新附件版本"});return}this.patch({draft:s,latest:void 0,conflict:!1,message:"已采用最新版本号与附件,本机正文、类型和标签选择保留;请比较后手动保存"}),this.persist(s).catch(()=>{})}}function kt({client:i,store:t,writable:s,alive:a,models:r,setEditor:l,setItems:n,setDetail:d,setMessage:c}){const u=B(v=>{if(!a.current||!i.active)return;const o=g=>({...g.version>v.version?g:v,followupSummary:wt(g.followupSummary,v.followupSummary)});n(g=>g.map(k=>k.id===v.id?o(k):k)),d(g=>(g==null?void 0:g.record.id)===v.id?{...g,record:o(g.record)}:g)}),p=B(async v=>{if(!(!s||v.deletedAt))try{const o="followup:"+v.id;let g=r.current.get(o);if(!g){const k=await t.get(o)??{id:v.id,kind:"note",body:"",existing:[],files:[]};if(!a.current)return;g=new $e(k,i,t,v.id),r.current.set(o,g),await g.initialize()}a.current&&l(g)}catch(o){a.current&&c(o instanceof Error?o.message:"跟进草稿读取失败")}});return{acceptRecord:u,editFollowup:p}}function Nt({client:i,store:t,writable:s,statusBusy:a,alive:r,setStatusBusy:l,setMessage:n,setPending:d,acceptRecord:c,setDetail:u,load:p}){return B(async(v,o)=>{var g;if(!(!s||a)){l(!0),n("");try{const k=await t.get("status:"+v.id);if(!k&&((g=await t.get("draft:"+v.id))!=null&&g.frozen))throw new Error("正文保存结果待确认,请先在编辑器确认");const E=k??{path:`/api/suiji/v1/records/${v.id}${"tags"in o?"":"trashed"in o?"/trash":"/task-status"}`,method:"tags"in o?"PATCH":"POST",key:crypto.randomUUID(),data:{expectedVersion:v.version,...o}};if(await t.set("status:"+v.id,E),!r.current)return;d(b=>new Set([...b,v.id]));const x=await i.request(E.path,E.method,E.data,E.key);if(!r.current)return;await t.remove("status:"+v.id),d(b=>{const S=new Set(b);return S.delete(v.id),S}),c(x.record),u(b=>(b==null?void 0:b.record.id)!==v.id?b:E.path.endsWith("/trash")||E.path.endsWith("/task-status")&&x.record.taskStatus==="done"?void 0:b),await p()}catch(k){if(!r.current)return;if(k instanceof G&&!k.uncertain)try{await t.remove("status:"+v.id),d(E=>{const x=new Set(E);return x.delete(v.id),x})}catch{n("本机状态确认写入失败,请手动重试");return}if(k instanceof G&&k.detail.error.code==="VERSION_CONFLICT"){try{const E=await i.request(`/api/suiji/v1/records/${v.id}`);c(E.record),n("记录已在其他地方更新,已显示最新内容,请重新选择标签或操作")}catch{n("记录已有新版本,读取失败,请返回列表重新打开后再操作")}return}n(k instanceof Error?k.message:"操作结果待确认")}finally{r.current&&l(!1)}}})}const Ae=["bg-emerald-100 text-emerald-900 dark:bg-emerald-950 dark:text-emerald-200","bg-blue-100 text-blue-900 dark:bg-blue-950 dark:text-blue-200","bg-purple-100 text-purple-900 dark:bg-purple-950 dark:text-purple-200","bg-pink-100 text-pink-900 dark:bg-pink-950 dark:text-pink-200","bg-orange-100 text-orange-900 dark:bg-orange-950 dark:text-orange-200","bg-teal-100 text-teal-900 dark:bg-teal-950 dark:text-teal-200"];function Se(i){let t=0;for(const s of i)t=(t*31+s.codePointAt(0))%Ae.length;return Ae[t]}function he({tags:i=[],onSelect:t}){return i.length?e.jsx("div",{className:"relative flex flex-wrap gap-2",children:i.map(s=>t?e.jsx("button",{type:"button",className:`rounded-full px-2.5 py-1 text-xs break-all ${Se(s)}`,"aria-label":`筛选标签:${s}`,onClick:()=>t(s),children:s},s):e.jsx("span",{className:`rounded-full px-2.5 py-1 text-xs break-all ${Se(s)}`,children:s},s))}):null}function Ve({selected:i=[],available:t,onChange:s}){const[a,r]=m.useState(!1),[l,n]=m.useState(""),[d,c]=m.useState(""),u=t.slice(0,6),p=o=>{try{s(Le([...i,o])),n(""),c(""),r(!1)}catch(g){c(g.message)}},v=o=>{s(i.filter(g=>g!==o)),c("")};return e.jsxs("div",{className:"flex flex-col gap-2",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[i.filter(o=>!u.includes(o)).map(o=>e.jsxs("button",{type:"button","aria-label":`移除标签:${o}`,className:`rounded-full px-2.5 py-1 text-sm break-all ${Se(o)}`,onClick:()=>v(o),children:[o," ×"]},o)),e.jsx(h,{type:"button",variant:"ghost",size:"sm",disabled:i.length>=2,"aria-expanded":a,onClick:()=>r(!a),children:"+标签"}),i.length>=2?e.jsx("span",{className:"text-xs text-muted-foreground",children:"最多 2 个标签"}):null]}),u.length?e.jsxs("div",{role:"group","aria-label":"最近使用的标签",className:"flex flex-wrap items-center gap-2",children:[e.jsx("span",{className:"text-xs text-muted-foreground",children:"最近使用"}),u.map(o=>{const g=i.includes(o);return e.jsxs(h,{type:"button",variant:g?"default":"outline",size:"sm","aria-pressed":g,disabled:!g&&i.length>=2,onClick:()=>g?v(o):p(o),children:[o,g?" ✓":""]},o)})]}):null,a&&i.length<2?e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border p-3",children:[e.jsx(K,{"aria-label":"标签名称",placeholder:"搜索或创建标签",value:l,onChange:o=>n(o.target.value),onKeyDown:o=>{o.key==="Enter"&&!o.nativeEvent.isComposing&&(o.preventDefault(),p(l))}}),e.jsx("div",{className:"flex max-h-40 flex-wrap gap-2 overflow-y-auto",children:t.filter(o=>!i.includes(o)&&o.includes(l.trim())).map(o=>e.jsx(h,{type:"button",variant:"outline",size:"sm",onClick:()=>p(o),children:o},o))}),l.trim()&&!t.includes(l.trim())?e.jsxs(h,{type:"button",variant:"outline",size:"sm",onClick:()=>p(l),children:["创建「",l.trim(),"」"]}):null]}):null,d?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:d}):null]})}function St({available:i,selected:t,onSelect:s}){const[a,r]=m.useState(!1),[l,n]=m.useState(""),d=i.slice(0,5);if(t&&!d.includes(t)&&d.push(t),!d.length)return null;const c=u=>{s(u===t?"":u),r(!1),n("")};return e.jsxs("div",{className:"mb-4 flex flex-col gap-2","aria-label":"标签筛选",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[d.map(u=>e.jsxs(h,{type:"button",size:"sm",variant:t===u?"default":"outline","aria-pressed":t===u,onClick:()=>c(u),children:[u,t===u?" ×":""]},u)),e.jsx(h,{type:"button",variant:"ghost",size:"sm","aria-expanded":a,onClick:()=>r(!a),children:"更多标签"})]}),a?e.jsxs("div",{className:"flex flex-col gap-2 rounded-xl border p-3",children:[e.jsx(K,{"aria-label":"搜索标签",placeholder:"搜索已有标签",value:l,onChange:u=>n(u.target.value)}),e.jsx("div",{className:"flex max-h-48 flex-wrap gap-2 overflow-y-auto",children:i.filter(u=>u.includes(l.trim())).map(u=>e.jsx(h,{type:"button",size:"sm",variant:t===u?"default":"outline",onClick:()=>c(u),children:u},u))})]}):null]})}function Ct(i,t){const s=[...new Set(t.map(r=>r.canonical))].filter(Boolean).sort((r,l)=>l.length-r.length),a=[];for(let r=0;r<i.length;){const l=s.find(n=>i.startsWith(n,r));if(l)a.push({text:l,term:t.find(n=>n.canonical===l)}),r+=l.length;else{const n=a.at(-1);n&&!n.term?n.text+=i.charAt(r):a.push({text:i.charAt(r)}),r++}}return a}function Et({model:i,selectedText:t,available:s}){var C,R,L,F,_,N;const a=m.useSyncExternalStore(i.subscribe,i.snapshot),[r,l]=m.useState(!1),[n,d]=m.useState(!1),[c,u]=m.useState(!1),[p,v]=m.useState(),[o,g]=m.useState(),[k,E]=m.useState("");m.useEffect(()=>{i.loadLexicon(),i.loadPreferences()},[i]);const x=((C=a.lexicon)==null?void 0:C.entries)??[],b=async()=>{if(!p||!a.lexicon)return;const y=p.canonical.trim(),T=p.variant.trim();if(!y)return;const M=structuredClone(x),U=structuredClone(x),$=U.find(I=>I.canonical===y);if($?T&&!$.variants.includes(T)&&$.variants.push(T):U.push({canonical:y,variants:T?[T]:[]}),JSON.stringify(U)===JSON.stringify(x)){E("这个写法已在词库中"),v(void 0);return}try{await i.putLexicon(U),g(M),v(void 0)}catch{}},S=async y=>{try{await i.putLexicon(x.filter(T=>T.canonical!==y))}catch{}},j=a.correction,w=(j==null?void 0:j.status)==="completed"&&j.correctedText;return e.jsxs("section",{className:"space-y-3 rounded-xl border p-4 text-sm","aria-label":"文字纠错",children:[e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{type:"button",variant:"outline",disabled:!s||!a.draft.body.trim()||a.correctionBusy||a.draft.frozen,onClick:()=>void i.correct(),children:a.correctionBusy?"正在纠正…":"纠正文字"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>d(!n),children:"纠错词库"}),i.historySupported?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>{u(!c),c||i.loadHistory()},children:"历史辅助"}):null,t?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>v({canonical:t,variant:""}),children:"记住选词"}):null]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"点击后,本次文字和专有词库会经 Codex CLI 发送给模型提供方。"}),s?null:e.jsx("p",{className:"text-xs text-muted-foreground",children:"此服务尚未启用文字纠错;词库仍可管理。"}),a.correctionMessage||k?e.jsx("p",{role:"status",children:k||a.correctionMessage}):null,a.feedbackPending?e.jsx(h,{type:"button",variant:"outline",onClick:()=>void i.retryFeedback(),children:"手动重试历史反馈"}):null,c&&i.historySupported?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsx("strong",{children:"历史辅助"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"开启后,随记服务端会保存纠错前文本、候选和应用后实际保存的正文; 下次纠错会将少量相关修改示例连同本次文字发送给模型提供方。不会自动修改正式词库。"}),e.jsxs("label",{className:"flex items-center gap-2",children:[e.jsx("input",{type:"checkbox",checked:((R=a.preferences)==null?void 0:R.historyEnabled)??!1,disabled:!a.preferences,onChange:y=>void i.setHistoryEnabled(y.target.checked)}),"启用历史辅助"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"关闭后不再新增或使用历史。清空只删除纠错派生记录,不删除随记正文或词库。"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>void i.loadHistory(),children:"刷新历史"}),e.jsx(h,{type:"button",variant:"outline",disabled:!((L=a.history)!=null&&L.items.length),onClick:()=>void i.deleteHistory(),children:"清空纠错历史"})]}),(F=a.history)==null?void 0:F.items.map(y=>e.jsxs("div",{className:"space-y-1 rounded border p-2",children:[e.jsxs("p",{className:"whitespace-pre-wrap break-words",children:["候选:",y.correctedText]}),e.jsxs("p",{className:"whitespace-pre-wrap break-words",children:["保存:",y.finalText]}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>void i.deleteHistory(y.id),children:"删除"})]},y.id)),(_=a.history)!=null&&_.nextCursor?e.jsx(h,{type:"button",variant:"outline",onClick:()=>{var y;return void i.loadHistory((y=a.history)==null?void 0:y.nextCursor)},children:"加载更多"}):null]}):null,a.lexiconPending?e.jsx(h,{type:"button",variant:"outline",onClick:()=>void i.putLexicon(x).then(()=>{g(x),v(void 0),E("")}).catch(()=>{}),children:"手动重试确认词库写入"}):null,w?e.jsxs("div",{className:"space-y-3 rounded-lg border p-3",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("strong",{children:"纠错预览"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>l(!r),children:r?"收起原文":"查看原文"})]}),r?e.jsx("p",{className:"whitespace-pre-wrap break-words",children:a.correctionSource}):null,e.jsx("p",{className:"whitespace-pre-wrap break-words",children:Ct(j.correctedText,j.suggestedTerms??[]).map((y,T)=>y.term?e.jsx("button",{type:"button",className:"decoration-dotted underline underline-offset-4",onClick:()=>v(y.term),children:y.text},T):e.jsx("span",{children:y.text},T))}),(N=j.uncertainTerms)!=null&&N.length?e.jsxs("p",{children:["仍不确定:",j.uncertainTerms.join("、"),"。请核对原文。"]}):null,e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"button",onClick:()=>i.applyCorrection(),disabled:a.draft.body!==a.correctionSource||a.draft.frozen,children:"应用到草稿"}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>void i.cancelCorrection(),children:"取消"})]})]}):null,p?e.jsxs("div",{className:"space-y-2 rounded-lg border p-3",children:[e.jsx("strong",{children:"记住这个写法"}),e.jsxs("label",{className:"block",children:["正确写法",e.jsx("input",{className:"w-full rounded border bg-background p-2",value:p.canonical,onChange:y=>v({...p,canonical:y.target.value})})]}),e.jsxs("label",{className:"block",children:["误识别写法(可留空)",e.jsx("input",{className:"w-full rounded border bg-background p-2",value:p.variant,onChange:y=>v({...p,variant:y.target.value})})]}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(h,{type:"button",disabled:a.lexiconPending||!a.lexicon,onClick:()=>void b(),children:"加入词库"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>v(void 0),children:"取消"})]})]}):null,o?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>{i.putLexicon(o).then(()=>g(void 0)).catch(()=>{})},children:"撤销本次添加"}):null,n?e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex justify-between",children:[e.jsx("strong",{children:"纠错词库"}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>void i.loadLexicon(),children:"刷新"})]}),x.map(y=>e.jsxs("div",{className:"flex items-center justify-between gap-2 rounded border p-2",children:[e.jsxs("span",{children:[y.canonical,y.variants.length?` ← ${y.variants.join("、")}`:""]}),e.jsx(h,{type:"button",variant:"ghost",onClick:()=>void S(y.canonical),children:"移除"})]},y.canonical)),e.jsx(h,{type:"button",variant:"outline",onClick:()=>v({canonical:"",variant:""}),children:"新增词条"})]}):null]})}function Rt({model:i,onClose:t,onSaved:s,onFollowupSaved:a,onDiscard:r,availableTags:l,correctionAvailable:n}){const d=m.useSyncExternalStore(i.subscribe,i.snapshot),{draft:c,busy:u}=d,p=B(s),[v,o]=m.useState(""),g=B(x=>{const b=Array.from(x.clipboardData.files).find(S=>S.type.startsWith("image/"));b&&(x.preventDefault(),x.stopPropagation(),!u&&!c.frozen&&i.addFile(b))}),k=B(x=>a==null?void 0:a(x));m.useEffect(()=>{var x;d.savedFollowup&&((x=i.lastSaveDiagnostics)==null||x.stage("ui_updated"),k(d.savedFollowup))},[d.savedFollowup,k,i]);const E=B(r);return m.useEffect(()=>{var x;d.saved&&((x=i.lastSaveDiagnostics)==null||x.stage("ui_updated"),p(d.saved))},[d.saved,p,i]),m.useEffect(()=>{d.discarded&&E()},[d.discarded,E]),e.jsxs(Fe,{title:i.followupRecordId?"追加跟进":c.id==="new"?"记下一点什么":"编辑记录",onBack:t,busy:u,onPaste:g,description:c.frozen?"保存结果待确认,请手动重试":"草稿自动保留,点保存后上传。",children:[e.jsxs("fieldset",{disabled:u||c.frozen,className:"flex flex-col gap-4",children:[i.followupRecordId?null:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("span",{children:"类型"}),e.jsx("div",{role:"group","aria-label":"记录类型",className:"inline-flex gap-1 rounded-xl bg-secondary p-1",children:[["note","想法"],["task","待办"]].map(([x,b])=>e.jsx(h,{type:"button",size:"sm",variant:c.kind===x?"default":"ghost","aria-pressed":c.kind===x,disabled:!!c.material&&x==="task",onClick:()=>i.edit({kind:x}),children:b},x))})]}),!i.followupRecordId&&c.id!=="new"?e.jsx("p",{className:"text-sm text-muted-foreground",children:c.material?`旧素材归属日期:${c.material.materialDate}。服务切换后保存到浏览;原冻结请求保持不变,请在新版随记中查看。`:"切换为待办时设为未完成;切换为想法时清除待办状态。"}):null,e.jsxs("label",{className:"flex flex-col gap-2",children:[i.followupRecordId?"跟进内容":"原文",e.jsx("textarea",{"aria-label":i.followupRecordId?"跟进内容":"原文",value:c.body,onChange:x=>i.edit({body:x.target.value}),onSelect:x=>{const b=x.currentTarget;o(b.value.slice(b.selectionStart,b.selectionEnd).trim().slice(0,80))},placeholder:"此刻的想法、一个链接,或者以后想做的事……",className:"min-h-56 resize-y rounded-xl border bg-background p-4 leading-relaxed outline-none focus:ring-2 focus:ring-ring"})]}),n!==void 0?e.jsx(Et,{model:i,selectedText:v,available:n}):null,i.followupRecordId?null:e.jsx(Ve,{selected:c.tags,available:l,onChange:x=>i.edit({tags:x})}),e.jsxs("span",{className:"text-right text-xs text-muted-foreground",children:[[...c.body].length.toLocaleString()," / 20,000"]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["添加图片或 Markdown",e.jsx("span",{className:"text-xs text-muted-foreground",children:"可在编辑区按 ⌘V / Ctrl+V 粘贴图片。"}),e.jsx("input",{"aria-label":"添加附件",type:"file",accept:"image/jpeg,image/png,.md",onChange:x=>{var S;const b=(S=x.target.files)==null?void 0:S[0];x.target.value="",b&&i.addFile(b)}})]}),[...c.existing.map(x=>({id:x.id,name:x.fileName,existing:!0})),...c.files.map(x=>({id:x.id,name:x.file.name,existing:!1}))].map(x=>e.jsxs("div",{className:"flex items-center justify-between gap-3 rounded-lg border p-3",children:[e.jsx("span",{className:"truncate",children:x.name}),e.jsx(h,{type:"button",size:"sm",variant:"ghost",onClick:()=>i.edit(x.existing?{existing:c.existing.filter(b=>b.id!==x.id)}:{files:c.files.filter(b=>b.id!==x.id)}),children:"移除"})]},x.id))]}),d.message?e.jsx("p",{role:"alert",className:"whitespace-pre-wrap text-sm text-destructive",children:d.message}):null,d.conflict?e.jsx(h,{variant:"outline",onClick:()=>void i.loadLatest(),children:"查看最新原文"}):null,d.latest?e.jsxs("section",{className:"flex flex-col gap-3 rounded-xl border p-4",children:[e.jsx("p",{children:"云端标签"}),e.jsx(he,{tags:d.latest.tags}),e.jsxs("p",{children:["本机标签",c.tags===void 0?":未修改,保存时保留云端标签":""]}),e.jsx(he,{tags:c.tags}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["服务端版本 ",d.latest.version,",类型:",d.latest.kind==="note"?"想法":"待办","。请与上方本机草稿比较"]}),e.jsx("p",{className:"whitespace-pre-wrap break-words",children:d.latest.body}),e.jsx(h,{variant:"outline",onClick:()=>i.acceptLatestVersion(),children:"保留本机正文、类型和标签选择,采用最新版本继续编辑"})]}):null,e.jsxs("div",{className:"flex items-center justify-between gap-3",children:[e.jsx("span",{role:"status",className:"text-xs text-muted-foreground",children:d.localError?"本机草稿未保存":d.localSaving?"正在保存本机草稿…":"本机草稿已保存"}),e.jsx(h,{disabled:u,onClick:()=>void i.save(),children:u?"正在保存…":c.frozen?"手动重试确认":"保存"})]}),e.jsx(h,{variant:"ghost",disabled:u||c.frozen,onClick:()=>{window.confirm("放弃这份本机草稿?已保存的记录不会改变。")&&i.discard()},children:"放弃本机草稿"})]})}function It({record:i,client:t,writable:s,onAdd:a,onRecord:r,onOpenLink:l}){var x;const[n,d]=m.useState([]),[c,u]=m.useState(null),[p,v]=m.useState(!1),[o,g]=m.useState(""),k=m.useRef(0),E=B(async(b=!1)=>{const S=++k.current;v(!0),g("");try{const j=`/api/suiji/v1/records/${i.id}`,[w,C]=await Promise.all([t.request(j+"/followups"+(b&&c?"?cursor="+encodeURIComponent(c):"")),b?void 0:t.request(j)]);if(!t.active||S!==k.current)return;d(R=>b?[...R,...w.items.filter(L=>!R.some(F=>F.id===L.id))]:w.items),u(w.nextCursor),C&&r(C.record)}catch(j){S===k.current&&g(j instanceof Error?j.message:"跟进读取失败")}finally{S===k.current&&v(!1)}});return m.useEffect(()=>{const b=k;return E(),()=>{++b.current}},[E,i.id,t]),e.jsxs("section",{className:"flex flex-col gap-4 border-t pt-4","aria-label":"跟进",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("h3",{children:["跟进 ",((x=i.followupSummary)==null?void 0:x.count)??n.length," 条"]}),e.jsx(h,{variant:"ghost",disabled:p,onClick:()=>void E(),children:"刷新跟进"}),i.deletedAt?null:e.jsx(h,{disabled:!s,onClick:a,children:"追加跟进"})]}),o?e.jsx("p",{role:"alert",className:"text-destructive",children:o}):null,n.map(b=>e.jsxs("article",{className:"flex flex-col gap-2 rounded-xl border p-4",children:[e.jsxs("p",{className:"text-xs text-muted-foreground",children:[b.source.actor==="app"?"你":`Agent${b.source.agentName?" · "+b.source.agentName:""}`," ","· ",pe(b.createdAt)]}),b.source.sessionId?e.jsxs("p",{className:"break-all text-xs text-muted-foreground",children:["会话:",b.source.sessionId]}):null,e.jsx(Ce,{body:b.body,onOpenLink:l}),b.attachments.map(S=>e.jsx(Me,{attachment:S,client:t},S.id))]},b.id)),p?e.jsx("p",{role:"status",children:"正在读取跟进…"}):null,c?e.jsx(h,{variant:"outline",disabled:p,onClick:()=>void E(!0),children:"加载更早跟进"}):null]})}const Ee=i=>i.kind==="note"?"想法":{open:"未完成",done:"已完成",archived:"不再做"}[i.taskStatus??"open"];function qt({record:i,onOpenLink:t,client:s,onTag:a,availableTags:r,onTagsChange:l,message:n,onClose:d,onEdit:c,onStatus:u,onTrash:p,onReview:v,onRecreate:o,info:g,onFollowup:k,onRecord:E,writable:x,pending:b,busy:S,citedVersion:j}){var M,U;const[w,C]=m.useState(!1),[R,L]=m.useState(!1),[F,_]=m.useState(!1),[N,y]=m.useState("");m.useEffect(()=>{y("")},[i.id,i.body]),m.useEffect(()=>{if(!N)return;const $=window.setTimeout(()=>y(""),2500);return()=>window.clearTimeout($)},[N]);const T=B(async()=>{_(!0),y("");try{await navigator.clipboard.writeText(i.body),y(i.attachments.length?"正文已复制,附件未包含":"正文已复制")}catch{y("复制失败,请重试或选择正文手动复制")}finally{_(!1)}});return e.jsxs(Fe,{title:Ee(i),description:pe(i.createdAt),onBack:d,actions:e.jsxs(e.Fragment,{children:[e.jsx(h,{variant:"ghost",size:"icon","aria-label":"复制",title:i.body?"复制":"暂无正文可复制",disabled:!i.body||F,onClick:()=>void T(),children:e.jsx(Ze,{className:"size-4"})}),e.jsx(h,{variant:"ghost",disabled:!x||b||S||!!i.deletedAt,onClick:c,children:"编辑"})]}),feedback:N?e.jsx("div",{className:"pointer-events-none absolute inset-x-4 bottom-5 z-10 flex justify-center",children:e.jsx("p",{role:"status",className:"rounded-full border bg-popover px-4 py-2.5 text-center text-sm text-popover-foreground shadow-lg",children:N})}):null,children:[j!==void 0&&j!==i.version?e.jsxs("p",{role:"status",className:"text-sm text-muted-foreground",children:["此记录已更新;回答引用的是版本 ",j,",下方是当前原文。"]}):null,e.jsx(Ce,{body:i.body,onOpenLink:t}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsx(he,{tags:i.tags,onSelect:a}),i.deletedAt?null:e.jsx(h,{variant:"ghost",size:"sm",disabled:!x||b||S,"aria-expanded":R,onClick:()=>L(!R),children:R?"收起标签":(((M=i.tags)==null?void 0:M.length)??0)>=2?"管理标签":"添加标签"})]}),R&&!i.deletedAt?e.jsxs("fieldset",{disabled:!x||b||S,"aria-label":"快速编辑标签",className:"min-w-0 space-y-2 rounded-xl border p-3 disabled:opacity-60",children:[e.jsx(Ve,{selected:i.tags,available:r,onChange:l}),e.jsx("p",{role:"status",className:"text-xs text-muted-foreground",children:S?"正在保存标签…":b?"保存结果待确认,请手动确认":"选择或移除后自动保存,最多 2 个标签"})]}):null,n?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:n}):null,e.jsx("div",{className:"flex flex-wrap gap-2",children:i.attachments.map($=>e.jsx(Me,{attachment:$,client:s},$.id))}),(U=g.features)!=null&&U.followups?e.jsxs(e.Fragment,{children:[i.deletedAt?null:e.jsx(h,{variant:"outline",onClick:()=>{navigator.clipboard.writeText(yt({endpoint:s.endpoint,serverId:g.serverId,ownerId:g.ownerId,recordId:i.id})).then(()=>y("交接指令已复制"),()=>y("复制失败,请重试"))},children:"交给 Agent"}),e.jsx(It,{record:i,client:s,writable:x,onAdd:k,onRecord:E,onOpenLink:t})]}):null,i.deletedAt?e.jsx("p",{role:"status",children:"已在回收站,恢复后可继续编辑。"}):null,b?e.jsx(h,{disabled:!x||S,onClick:()=>u("done"),children:"操作结果待确认 · 手动确认"}):null,e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",disabled:!!i.deletedAt,onClick:v,children:"聊聊这条"}),!i.deletedAt&&i.kind==="task"&&(i.taskStatus==="open"||b)?e.jsxs(e.Fragment,{children:[e.jsx(h,{disabled:!x||S,onClick:()=>u("done"),children:b?"手动确认操作":"标记完成"}),b?null:e.jsx(h,{variant:"outline",disabled:!x||S,onClick:()=>u("archived"),children:"不再做"})]}):!i.deletedAt&&i.taskStatus==="done"?e.jsx(h,{disabled:!x||S||b,onClick:()=>u("open"),children:"撤销完成"}):!i.deletedAt&&i.kind==="task"?e.jsx(h,{disabled:!x,onClick:o,children:"再次想做"}):null,i.deletedAt?e.jsx(h,{disabled:!x||b||S,onClick:()=>p(!1),children:"恢复记录"}):w?e.jsxs("div",{className:"flex flex-wrap items-center gap-2",role:"alert",children:[e.jsx("span",{children:"移入回收站后可恢复,正文和附件会保留。"}),e.jsx(h,{variant:"destructive",disabled:!x||b||S,onClick:()=>{C(!1),p(!0)},children:"确认移入回收站"}),e.jsx(h,{variant:"ghost",onClick:()=>C(!1),children:"取消"})]}):e.jsx(h,{variant:"destructive",disabled:!x||b||S,onClick:()=>C(!0),children:"移入回收站"})]})]})}function Tt({record:i,pending:t,onOpen:s,onOpenLink:a,onTag:r}){var l;return e.jsxs("article",{className:"relative flex flex-col gap-3 rounded-2xl border bg-card p-4 text-left shadow-sm transition-colors hover:bg-accent",children:[e.jsx("button",{type:"button","aria-label":`查看记录:${i.body||"附件记录"}`,onClick:s,className:"absolute inset-0 rounded-2xl focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"}),e.jsxs("span",{className:"pointer-events-none relative flex items-center justify-between gap-3 text-xs text-muted-foreground",children:[e.jsxs("span",{children:[Ee(i),t?" · 状态待确认":""]}),e.jsx("time",{children:pe(i.createdAt)})]}),e.jsx(Ce,{onOpenLink:a,body:i.body||"附件记录",className:"pointer-events-none relative line-clamp-5"}),i.attachments.length?e.jsx("span",{className:"pointer-events-none relative text-xs text-muted-foreground",children:i.attachments.map(n=>n.fileName).join(" · ")}):null,(l=i.followupSummary)!=null&&l.latest?e.jsxs("p",{className:"pointer-events-none relative truncate text-sm text-muted-foreground",children:["跟进 ",i.followupSummary.count," 条 · ",i.followupSummary.latest.excerpt]}):null,e.jsx(he,{tags:i.tags,onSelect:r})]})}function Dt({client:i,info:t,scope:s,onScope:a,onOpen:r,onSave:l,writable:n,onLockedChange:d}){var _;const[c,u]=m.useState(""),[p,v]=m.useState([]),[o,g]=m.useState(),[k,E]=m.useState(!1),[x,b]=m.useState(""),S=m.useRef(void 0),j=m.useRef(!0);m.useEffect(()=>{d==null||d(!!(S.current||k||(o==null?void 0:o.status)==="running"))},[k,o,x,d]),m.useEffect(()=>(j.current=!0,()=>{j.current=!1}),[]);const w=B(async()=>{if(!(k||(o==null?void 0:o.status)==="running")){E(!0),b(""),S.current??(S.current={key:crypto.randomUUID(),input:{question:c,scope:s,history:p.flatMap(N=>{var y;return[{role:"user",text:N.question},{role:"assistant",text:((y=N.job.answer)==null?void 0:y.text)??""}]}).slice(-6)}});try{const N=await i.request("/api/suiji/v1/reviews","POST",S.current.input,S.current.key);j.current&&g(N)}catch(N){j.current&&b((N instanceof Error?N.message:"回顾请求失败")+"。问题保留,点击手动确认可重查同一次请求。")}finally{j.current&&E(!1)}}}),C=B(N=>{g(N),N.status!=="running"&&(N.status==="completed"?(v(y=>{var T;return[...y,{question:((T=S.current)==null?void 0:T.input.question)??c,job:N}]}),u(""),b("")):b(N.error??(N.status==="cancelled"?"已取消,原问题保留":"回顾未完成")),S.current=void 0)});m.useEffect(()=>{if(!o)return;if(o.status!=="running"){S.current&&C(o);return}let N=!0,y;const T=async()=>{try{const M=await i.request("/api/suiji/v1/reviews/"+o.id);if(!N)return;M.status!=="running"?C(M):y=setTimeout(()=>void T(),1500)}catch(M){N&&b((M instanceof Error?M.message:"无法读取进度")+"。可手动查询此回顾的进度。")}};return y=setTimeout(()=>void T(),800),()=>{N=!1,clearTimeout(y)}},[i,o,C]);const R=B(async()=>{if(o)try{C(await i.request("/api/suiji/v1/reviews/"+o.id)),b("")}catch(N){b(N instanceof Error?N.message:"查询失败")}}),L=B(async()=>{if(o)try{C(await i.request("/api/suiji/v1/reviews/"+o.id,"DELETE"))}catch(N){b(N instanceof Error?N.message:"取消失败,请手动重试")}}),F=k||(o==null?void 0:o.status)==="running";return(_=t.ai)!=null&&_.enabled?e.jsxs("section",{className:"flex flex-col gap-7",children:[e.jsxs("header",{className:"flex flex-col gap-2",children:[e.jsx("h2",{className:"text-xl font-semibold",children:"从记录里,接着想"}),e.jsx("p",{className:"text-sm leading-6 text-muted-foreground",children:"主动发问后才检索。回答引用实际原文,保存结论由你决定。"})]}),p.map(N=>e.jsxs("article",{className:"flex flex-col gap-4",children:[e.jsx("p",{className:"ml-8 rounded-2xl bg-secondary p-4 whitespace-pre-wrap",children:N.question}),e.jsxs("div",{className:"flex flex-col gap-4 rounded-2xl border bg-card p-5",children:[e.jsx("p",{className:"whitespace-pre-wrap break-words leading-7",children:N.job.answer.text}),N.job.answer.citations.map((y,T)=>e.jsxs("button",{className:"flex flex-col gap-1 rounded-xl border p-3 text-left hover:bg-accent",onClick:()=>r(y.recordId,y.version),children:[e.jsxs("span",{className:"text-xs text-muted-foreground",children:["[",T+1,"] ",pe(y.createdAt)," ·"," ",Ee(y)," · 版本 ",y.version,y.attachment?` · ${y.attachment.fileName}`:""]}),e.jsx("span",{className:"whitespace-pre-wrap break-words text-sm",children:y.quote||"已读取图片附件"})]},T)),e.jsxs("p",{className:"text-xs leading-5 text-muted-foreground",children:["本次查看 ",N.job.answer.coverage.listedRecords," 条摘要、",N.job.answer.coverage.readRecords," 条原文、",N.job.answer.coverage.attachmentReads," ","段附件。关键词检索,未启用向量索引,未读取外链。"]}),e.jsxs("div",{className:"flex flex-wrap gap-2",children:[e.jsx(h,{variant:"outline",size:"sm",disabled:!n,onClick:()=>l(N.job.answer.text,"note"),children:"另存笔记"}),e.jsx(h,{variant:"outline",size:"sm",disabled:!n,onClick:()=>l(N.job.answer.text,"task"),children:"新建待办"})]})]})]},N.job.id)),e.jsxs("form",{className:"flex flex-col gap-3 rounded-2xl border bg-card p-5",onSubmit:N=>{N.preventDefault(),w()},children:[e.jsxs("label",{className:"flex items-center gap-3 text-sm",children:["回顾范围",e.jsxs("select",{"aria-label":"回顾范围",disabled:F||!!S.current,value:s.kind,onChange:N=>a({kind:N.target.value}),className:"rounded-lg border bg-background p-2",children:[e.jsx("option",{value:"all",children:"全部历史"}),e.jsx("option",{value:"open",children:"当前待办"}),s.kind==="record"?e.jsx("option",{value:"record",children:"这条记录"}):null]})]}),e.jsx("label",{className:"sr-only",htmlFor:"suiji-question",children:"向随记提问"}),e.jsx("textarea",{id:"suiji-question",value:c,disabled:F||!!S.current,onChange:N=>u(N.target.value),maxLength:4e3,placeholder:"以前有哪些想做、后来放下的事?",className:"min-h-28 resize-y rounded-xl border bg-background p-3 leading-6"}),F?e.jsx("p",{role:"status",className:"text-sm text-muted-foreground",children:"正在检索与回顾,可以继续浏览记录…"}):null,x?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:x}):null,e.jsxs("div",{className:"flex flex-wrap justify-end gap-2",children:[x&&!k?e.jsx(h,{type:"button",variant:"ghost",onClick:()=>{S.current=void 0,g(void 0),b("")},children:"结束此次等待,重新提问"}):null,(o==null?void 0:o.status)==="running"?e.jsxs(e.Fragment,{children:[e.jsx(h,{type:"button",variant:"outline",onClick:()=>void R(),children:"查询进度"}),e.jsx(h,{type:"button",variant:"outline",onClick:()=>void L(),children:"取消回顾"})]}):e.jsx(h,{type:"submit",disabled:k||!c.trim(),children:S.current?"手动确认请求":"发送"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"对话仅保留在当前页面会话,刷新后不会自动重新执行。服务上的回顾结果保留 30 分钟。"})]}):e.jsxs("section",{className:"flex flex-col gap-3 py-16 text-center",children:[e.jsx("h2",{className:"text-xl",children:"AI 回顾尚未启用"}),e.jsx("p",{className:"text-muted-foreground",children:"当前服务没有可用的回顾模型。记录和待办仍可正常使用。"})]})}function zt({active:i,disabled:t,loading:s,cursor:a,load:r}){const l=m.useRef(null),n=m.useRef(null),d=m.useRef(null),[c,u]=m.useState(!1);return m.useEffect(()=>{const p=l.current,v=n.current;if(!i||t||s||!a||c||!p||!v)return;const o=new IntersectionObserver(([g])=>{g!=null&&g.isIntersecting&&(o.disconnect(),r(!0))},{root:p,rootMargin:"0px 0px 200px 0px"});return o.observe(v),()=>o.disconnect()},[i,t,s,a,c,l,n,r]),{failed:c,scrollContainer:l,trigger:n,begin:(p,v,o)=>p&&(!v||o||d.current===v)?!1:(d.current=p?v:null,u(!1),!0),fail:p=>{p&&(d.current=null,u(!0))}}}function Pt({cursor:i,failed:t,loading:s,trigger:a,onRetry:r}){return e.jsx("div",{ref:a,className:"flex min-h-px justify-center gap-3",children:i&&t?e.jsx(h,{variant:"outline",disabled:s,onClick:r,children:"重试加载"}):null})}function At({connection:i,active:t=!0,headerActions:s,onOpenLink:a}){var De,ze,Pe;const{client:r,info:l,store:n}=i,[d]=m.useState(()=>{var f;return new gt(r,n,((f=l.features)==null?void 0:f.workReports)===!0)}),[c,u]=m.useState(!1),[p,v]=m.useState(),[o,g]=m.useState("records"),[k,E]=m.useState(""),[x,b]=m.useState("open"),[S,j]=m.useState(""),[w,C]=m.useState(""),[R,L]=m.useState([]),[F,_]=m.useState(!1),N=Xe(S,{wait:250}),y=m.useRef(0),[T,M]=m.useState([]),[U,$]=m.useState(null),[I,oe]=m.useState(!1),[fe,Q]=m.useState(""),[P,Z]=m.useState(),[V,re]=m.useState(),[Oe,Re]=m.useState({kind:"all"}),[xe,me]=m.useState(new Set),[Ie,He]=m.useState(!1),[te,Ke]=m.useState(!1),O=m.useRef(!0),X=m.useRef(0),ge=m.useRef(!1),ce=m.useRef(void 0),ie=m.useRef(new Map),ve=B(async()=>{if(!(ge.current||!navigator.locks)){ge.current=!0;try{await navigator.locks.request("suiji-editor:"+n.scope,{ifAvailable:!0},async f=>{!f||!O.current||(Ke(!0),await new Promise(q=>{ce.current=q}))})}finally{ge.current=!1}}});m.useEffect(()=>{var q;O.current=!0,ve(),(q=l.features)!=null&&q.workRecords&&d.initialize();const f=ie.current;return()=>{O.current=!1,f.forEach(D=>D.dispose()),d.dispose(),Promise.all([...f.values()].map(D=>D.settled()).concat(d.settled())).finally(()=>{var D;(D=ce.current)==null||D.call(ce),n.close()})}},[ve,n,d,l]);const Y=B(async(f=!1)=>{var ae;if(o==="ai"||o==="work"||!le.begin(f,U,I))return;const q=++X.current;oe(!0),Q(""),f||(M([]),$(null));const D=new URLSearchParams;o==="tasks"?(D.set("kind","task"),D.set("taskStatus",x)):k&&D.set("kind",k),o==="trash"&&D.set("trash","true"),N&&D.set("q",N),w&&D.set("tag",w),f&&U&&D.set("cursor",U);try{const[z,J]=await Promise.all([r.request("/api/suiji/v1/records?"+D),f?void 0:r.request("/api/suiji/v1/tags")]);if(!O.current||q!==X.current)return;J&&L(J.items);const se=await Promise.all(z.items.map(async ee=>await n.get("status:"+ee.id)?ee.id:void 0));if(!O.current||q!==X.current)return;const W=(ae=l.features)!=null&&ae.browse?z.items.filter(ee=>!ee.material):z.items;M(ee=>f?[...ee,...W.filter(ye=>!ee.some(We=>We.id===ye.id))]:W),$(z.nextCursor),me(ee=>new Set([...f?ee:[],...se.filter(ye=>!!ye)]))}catch(z){O.current&&q===X.current&&(le.fail(f),Q(z instanceof Error?z.message:"读取失败"))}finally{O.current&&q===X.current&&oe(!1)}});m.useEffect(()=>{t&&Y()},[Y,o,k,x,N,w,t]);const le=zt({active:t,disabled:o==="ai"||o==="work"||!!(P||V),loading:I,cursor:U,load:Y}),be=B(f=>{++X.current,++y.current,M([]),$(null),Z(void 0),o==="ai"&&g("records"),f===w?Y():C(f)}),qe=B(async(f,q)=>{const D=X.current,ae=++y.current;try{const{record:z}=await r.request("/api/suiji/v1/records/"+f),J=await n.get("status:"+f);if(!O.current||D!==X.current||ae!==y.current)return;me(se=>{const W=new Set(se);return J?W.add(f):W.delete(f),W}),M(se=>se.map(W=>W.id===z.id&&W.version<=z.version?z:W)),Z({record:z,citedVersion:q})}catch(z){O.current&&Q(z instanceof Error?z.message:"读取失败")}}),de=B(async(f,q="task",D="")=>{var ae;if(!(!te||f!=null&&f.deletedAt))try{if(f&&await n.get("status:"+f.id))throw new Error("记录操作待确认,请先手动确认");const z=(f==null?void 0:f.id)??"new";let J=ie.current.get(z);if(J&&D&&Q("已恢复原有草稿;新结论未覆盖它。请先处理当前草稿,再另存结论。"),!J){const se=await n.get("draft:"+z);if(!O.current)return;const W=se??{id:z,kind:(f==null?void 0:f.kind)??q,material:f==null?void 0:f.material,body:(f==null?void 0:f.body)??D,tags:(f==null?void 0:f.tags)??[],version:f==null?void 0:f.version,existing:(f==null?void 0:f.attachments)??[],files:[]};J=new $e(W,r,n,void 0,((ae=l.features)==null?void 0:ae.correctionHistory)===!0),ie.current.set(z,J),se&&D&&Q("已恢复原有草稿;新结论未覆盖它。请先处理当前草稿,再另存结论。"),await J.initialize()}O.current&&re(J)}catch(z){O.current&&Q(z instanceof Error?z.message:"草稿读取失败")}}),{acceptRecord:je,editFollowup:_e}=kt({client:r,store:n,writable:te,alive:O,models:ie,setEditor:re,setItems:M,setDetail:Z,setMessage:Q}),we=Nt({client:r,store:n,writable:te,statusBusy:Ie,alive:O,setStatusBusy:He,setMessage:Q,setPending:me,acceptRecord:je,setDetail:Z,load:Y}),Te=T.filter(f=>!!f.deletedAt==(o==="trash")&&(!w||(f.tags??[]).includes(w))&&(o==="tasks"?f.kind==="task"&&f.taskStatus===x:!k||f.kind===k)&&(o!=="records"||f.taskStatus!=="done"&&f.taskStatus!=="archived"||xe.has(f.id)));return e.jsxs("main",{className:"relative flex h-full min-h-0 flex-col bg-background text-foreground",children:[s&&o!=="ai"&&o!=="work"&&!P&&!V?Ye.createPortal(e.jsx(h,{variant:"ghost",size:"icon","aria-label":I?"刷新中":"刷新",title:"刷新",disabled:I,onClick:()=>void Y(),children:e.jsx(et,{className:`size-4 ${I?"animate-spin":""}`})}),s):null,e.jsxs("div",{className:P||V?"hidden":"flex min-h-0 flex-1 flex-col",children:[(De=l.features)!=null&&De.workRecords?e.jsx("div",{className:o==="work"?"flex min-h-0 flex-1 flex-col":"hidden",children:e.jsx(jt,{model:d,active:o==="work",writable:te,onReview:()=>{v({tab:"work"}),g("ai")}})}):null,e.jsxs("div",{ref:le.scrollContainer,className:o==="work"?"hidden":"min-h-0 flex-1 overflow-y-auto px-5 pt-4",children:[te?null:e.jsxs("div",{className:"flex items-center justify-between gap-4 rounded-xl border p-4 text-sm",children:[e.jsx("p",{children:"另一随记页面正在编辑,当前可浏览。关闭那一页后可接管编辑。"}),e.jsx(h,{variant:"outline",size:"sm",onClick:()=>void ve(),children:"接管编辑"})]}),fe?e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:fe}):null,e.jsxs("div",{hidden:o!=="ai",className:"pb-6",children:[p?e.jsxs(h,{variant:"ghost",onClick:()=>{g(p.tab),Z(p.detail),v(void 0)},children:["返回",p.detail?"原记录":"工作"]}):null,e.jsx(Dt,{client:r,info:l,scope:Oe,onScope:Re,onOpen:(f,q)=>void qe(f,q),onSave:(f,q)=>void de(void 0,q,f),writable:te,onLockedChange:u})]}),o!=="ai"&&o!=="work"?e.jsxs(e.Fragment,{children:[e.jsxs("section",{className:"mb-4 flex flex-wrap items-center justify-between gap-3",children:[o==="tasks"?e.jsxs("label",{className:"flex items-center gap-3 text-sm",children:["状态",e.jsxs("select",{"aria-label":"待办状态",value:x,onChange:f=>b(f.target.value),className:"rounded-xl border bg-card p-2",children:[e.jsx("option",{value:"open",children:"未完成"}),e.jsx("option",{value:"done",children:"已完成"}),e.jsx("option",{value:"archived",children:"不再做"})]})]}):e.jsx("div",{className:"flex items-center gap-3 text-sm",children:e.jsx("div",{role:"group","aria-label":"类型筛选",className:"inline-flex gap-1 rounded-xl bg-secondary p-1",children:[["","全部"],["note","想法"],["task","待办"]].map(([f,q])=>e.jsx(h,{type:"button",size:"sm",variant:k===f?"default":"ghost","aria-pressed":k===f,onClick:()=>E(f),children:q},f))})}),e.jsx(h,{variant:"ghost",size:"icon","aria-label":"搜索记录","aria-pressed":F,onClick:()=>{F&&j(""),_(f=>!f)},children:e.jsx(tt,{className:"size-4"})}),F?e.jsx(K,{autoFocus:!0,"aria-label":"搜索原文",placeholder:"搜索正文关键词",value:S,onChange:f=>j(f.target.value),className:"w-full"}):null]}),e.jsx(St,{available:R,selected:w,onSelect:be}),e.jsxs("section",{className:"flex flex-col gap-4 pb-20",children:[Te.map(f=>e.jsx(Tt,{record:f,pending:xe.has(f.id),onOpen:()=>void qe(f.id),onOpenLink:a,onTag:be},f.id)),I?e.jsx("p",{role:"status",className:"py-8 text-center text-muted-foreground",children:"正在读取记录…"}):Te.length===0?e.jsxs("div",{className:"flex flex-col gap-3 py-16 text-center",children:[e.jsx("h2",{className:"text-xl",children:S||w?"没有找到匹配的原文":o==="trash"?"回收站为空":"留一点想法在这里"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:S||w?"试试其他标签或更短的关键词。":o==="trash"?"删除的记录会保留在这里,可随时恢复。":"点右下角加号,记下一句想到的事。"})]}):null,e.jsx(Pt,{cursor:U,failed:le.failed,loading:I,trigger:le.trigger,onRetry:()=>void Y(!0)})]})]}):null]}),o!=="trash"&&o!=="ai"&&o!=="work"?e.jsx(h,{"aria-label":"新增记录",className:"absolute bottom-20 right-5 size-12 rounded-full shadow-lg",disabled:!te,onClick:()=>void de(),children:e.jsx(st,{})}):null,e.jsx("nav",{"aria-label":"随记导航",className:"grid shrink-0 grid-cols-4 border-t bg-background px-2 py-2",children:[["records","记录",it],["tasks","待办",ft],["trash","回收站",at],(ze=l.features)!=null&&ze.workRecords?["work","工作",ht]:["ai","AI",rt]].map(([f,q,D])=>e.jsxs("button",{type:"button","aria-current":o===f?"page":void 0,className:`flex flex-col items-center gap-1 rounded-lg py-2 text-xs ${o===f?"bg-secondary text-primary":"text-muted-foreground hover:bg-accent"}`,onClick:()=>{++X.current,g(f)},children:[e.jsx(D,{className:"size-5"}),q]},f))})]}),P&&!V?e.jsx(qt,{onOpenLink:a,...P,client:r,info:l,onFollowup:()=>void _e(P.record),onRecord:je,onTag:be,availableTags:R,onTagsChange:f=>void we(P.record,{tags:f}),message:fe,onClose:()=>Z(void 0),onEdit:()=>void de(P.record),onStatus:f=>void we(P.record,{targetStatus:f}),onTrash:f=>void we(P.record,{trashed:f}),onReview:()=>{v({tab:o,detail:P}),c||Re({kind:"record",recordId:P.record.id}),Z(void 0),g("ai")},onRecreate:()=>void de(void 0,"task",P.record.body),writable:te,pending:xe.has(P.record.id),busy:Ie},P.record.id):null,V?e.jsx(Rt,{model:V,correctionAvailable:(Pe=l.features)==null?void 0:Pe.correction,availableTags:R,onClose:()=>{V.cancelCorrection(),re(void 0)},onDiscard:()=>{ie.current.delete(V.followupRecordId?"followup:"+V.followupRecordId:V.state.draft.id),V.dispose(),re(void 0)},onFollowupSaved:f=>{const q=f.followup.recordId;ie.current.delete("followup:"+q),V.dispose(),re(void 0),(P==null?void 0:P.record.id)===q&&je({...P.record,followupSummary:f.followupSummary}),Y()},onSaved:f=>{var q;(q=l.features)!=null&&q.browse&&f.material?(Z(void 0),Q("此素材已保存到浏览,请在新版随记 App 中查看。")):P&&Z({record:f}),ie.current.delete(V.followupRecordId?"followup:"+V.followupRecordId:V.state.draft.id),V.dispose(),re(void 0),Y()}}):null]})}function Lt({active:i=!0,accountOnly:t=!1,onClose:s,onOpenLink:a}){const{accounts:r,endpoint:l,setEndpoint:n,username:d,setUsername:c,password:u,setPassword:p,busy:v,message:o,connection:g,needsLogin:k,setNeedsLogin:E,ensure:x,initialize:b,connect:S,switchEnvironment:j,logout:w,editAccount:C,isCurrent:R}=nt(),[L,F]=m.useState(t),[_,N]=m.useState(null),y=m.useRef(!0);m.useEffect(()=>(y.current=!0,x(),()=>{y.current=!1}),[x]),m.useEffect(()=>{g&&F(t)},[g,t]);const T=B(I=>{const oe=g==null?void 0:g.client;a==null||a(I,()=>y.current&&!!oe&&R(oe))}),M=B(async I=>{$&&!window.confirm("放弃当前环境未保存的账户修改?")||await j(I)}),U=r==null?void 0:r.profiles[r.active],$=t&&!!U&&!g&&(l!==U.endpoint||d!==U.username||u!==(U.password??""));return ot($,t&&v&&$),e.jsxs("section",{className:"suiji-theme flex h-full min-h-0 flex-col bg-background text-foreground","aria-label":"随记内容",children:[e.jsxs("header",{className:"flex h-14 shrink-0 items-center gap-2 border-b px-4",children:[L&&g&&!t?e.jsx(h,{variant:"ghost",size:"icon","aria-label":"返回随记",onClick:()=>F(!1),children:e.jsx(lt,{className:"size-4"})}):null,e.jsx("h1",{className:"font-semibold",children:L?"账户设置":"随记"}),(r==null?void 0:r.active)==="development"?e.jsx("span",{className:"rounded bg-secondary px-2 py-0.5 text-xs",children:"开发"}):null,e.jsxs("div",{className:"ml-auto flex items-center gap-1",children:[L?null:e.jsx("div",{ref:N,className:"flex"}),g&&!L?e.jsx(h,{variant:"ghost",size:"icon","aria-label":"随记设置",onClick:()=>F(!0),children:e.jsx(ct,{className:"size-4"})}):null,s?e.jsx(h,{variant:"ghost",size:"icon","aria-label":"关闭随记",onClick:s,children:e.jsx(dt,{className:"size-4"})}):null]})]}),g&&!t?e.jsx("div",{hidden:L,className:"min-h-0 flex-1",children:e.jsx(At,{connection:g,active:i,headerActions:_,onOpenLink:a?T:void 0},g.store.scope)}):null,t||L||!g?e.jsxs("div",{className:"min-h-0 flex-1 overflow-y-auto p-5",children:[r?e.jsxs(e.Fragment,{children:[e.jsx("fieldset",{disabled:v,className:"mb-6 flex gap-2","aria-label":"账户环境",children:["production","development"].map(I=>e.jsx(h,{className:"flex-1",variant:r.active===I?"default":"outline","aria-pressed":r.active===I,onClick:()=>void M(I),children:ke(I)},I))}),e.jsx("p",{className:"mb-5 text-sm text-muted-foreground",children:g?"切换环境会保留各自的账户和草稿。":"首次登录后,下次打开会自动连接。"}),g?e.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[e.jsxs("p",{children:["已登录",ke(r.active),"环境 · ",d]}),e.jsx("p",{className:"break-all text-muted-foreground",children:l}),e.jsx(h,{variant:"outline",disabled:v,onClick:C,children:"修改账户配置"}),e.jsxs(h,{variant:"destructive",disabled:v,onClick:()=>void w(),children:["退出",ke(r.active),"账户"]})]}):k?e.jsxs("form",{className:"flex flex-col gap-5",onSubmit:I=>{I.preventDefault(),S(r,!0)},children:[e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["服务地址",e.jsx(K,{"aria-label":"随记服务地址",type:"url",value:l,required:!0,disabled:v,onChange:I=>n(I.target.value),placeholder:"https://你的随记服务"})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["账号",e.jsx(K,{"aria-label":"随记账号",autoComplete:"username",value:d,required:!0,disabled:v,onChange:I=>c(I.target.value)})]}),e.jsxs("label",{className:"flex flex-col gap-2 text-sm",children:["密码",e.jsx(K,{"aria-label":"随记密码",type:"password",autoComplete:"current-password",value:u,required:!0,disabled:v,onChange:I=>p(I.target.value)})]}),e.jsx(h,{type:"submit",disabled:v,children:v?"正在连接…":"登录随记"})]}):e.jsxs("div",{className:"flex flex-col gap-4 text-sm",children:[e.jsx("p",{children:v?"正在恢复已保存的账户…":"暂时无法连接,账户和草稿已保留。"}),e.jsx(h,{variant:"outline",disabled:v,onClick:()=>E(!0),children:"修改账户配置"})]})]}):null,v?e.jsx("p",{role:"status",className:"mt-4 text-sm",children:"正在连接…"}):null,o?e.jsxs("div",{className:"mt-4 flex flex-col gap-3",children:[e.jsx("p",{role:"alert",className:"text-sm text-destructive",children:o}),e.jsx(h,{variant:"outline",disabled:v,onClick:()=>void b(),children:"重试连接"})]}):null]}):null]})}export{Lt as default};
@@ -1 +1 @@
1
- import{j as n}from"./index-D9-cSGu-.js";import{e as m,o as u,T as h,p as l}from"./main-BDBhLSX2.js";import{S as x}from"./tabs-CYKuiiHg.js";function R(t){var i,r;const e=m(),s=u(),o=new URLSearchParams(e.search),c=o.get("section")??"saved";return(i=window.electronAPI)!=null&&i.isElectron?n.jsxs(n.Fragment,{children:[n.jsx(x,{items:[["saved","连接"],["hosts","SSH 主机与通道"]],active:c}),c==="hosts"?n.jsx(h,{embedded:!0}):n.jsx(l,{embedded:!0,onManageTunnels:()=>{const a=new URLSearchParams(e.search);a.set("section","hosts"),s(`${e.pathname}?${a}`,{state:e.state})},connections:t.connections,activeId:o.get("target")??((r=t.activeConnection)==null?void 0:r.id)??null,onAdd:t.onAdd,onRemove:t.onRemove,onEdit:t.onEdit,onReconnect:t.onReconnect,onSelect:a=>{const d=new URLSearchParams(e.search);d.set("target",a),s(`${e.pathname}?${d}`,{state:e.state})}})]}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"连接与 SSH 通道由桌面应用管理。"})}export{R as default};
1
+ import{j as n}from"./index-D9-cSGu-.js";import{e as m,o as u,T as h,p as l}from"./main-3TPtEl66.js";import{S as x}from"./tabs-Cwlp1Meu.js";function R(t){var i,r;const e=m(),s=u(),o=new URLSearchParams(e.search),c=o.get("section")??"saved";return(i=window.electronAPI)!=null&&i.isElectron?n.jsxs(n.Fragment,{children:[n.jsx(x,{items:[["saved","连接"],["hosts","SSH 主机与通道"]],active:c}),c==="hosts"?n.jsx(h,{embedded:!0}):n.jsx(l,{embedded:!0,onManageTunnels:()=>{const a=new URLSearchParams(e.search);a.set("section","hosts"),s(`${e.pathname}?${a}`,{state:e.state})},connections:t.connections,activeId:o.get("target")??((r=t.activeConnection)==null?void 0:r.id)??null,onAdd:t.onAdd,onRemove:t.onRemove,onEdit:t.onEdit,onReconnect:t.onReconnect,onSelect:a=>{const d=new URLSearchParams(e.search);d.set("target",a),s(`${e.pathname}?${d}`,{state:e.state})}})]}):n.jsx("p",{className:"text-sm text-muted-foreground",children:"连接与 SSH 通道由桌面应用管理。"})}export{R as default};