@weavecode/weave 0.1.6 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (340) hide show
  1. package/node_modules/@weavecode/cli/dist/cli.js +3 -3
  2. package/node_modules/@weavecode/cli/dist/commands/chpass.js +1 -1
  3. package/node_modules/@weavecode/cli/dist/commands/daemon-auth.js +1 -1
  4. package/node_modules/@weavecode/cli/dist/commands/daemon.js +2 -2
  5. package/node_modules/@weavecode/cli/dist/commands/dashboard.js +2 -2
  6. package/node_modules/@weavecode/cli/dist/commands/doctor.js +1 -1
  7. package/node_modules/@weavecode/cli/dist/commands/init.js +1 -1
  8. package/node_modules/@weavecode/cli/dist/commands/msg.js +2 -2
  9. package/node_modules/@weavecode/cli/dist/commands/scan.js +1 -1
  10. package/node_modules/@weavecode/cli/dist/commands/status.js +2 -2
  11. package/node_modules/@weavecode/cli/dist/commands/uninstall.js +1 -1
  12. package/node_modules/@weavecode/cli/dist/i18n/dict/en.js +1 -1
  13. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.d.ts +1 -0
  14. package/node_modules/@weavecode/cli/dist/i18n/dict/zh.js +2 -2
  15. package/node_modules/@weavecode/cli/dist/i18n/index.js +1 -1
  16. package/node_modules/@weavecode/cli/dist/i18n/t.js +1 -1
  17. package/node_modules/@weavecode/cli/dist/init/claudemd-gen.js +3 -3
  18. package/node_modules/@weavecode/cli/dist/init/executor.js +3 -3
  19. package/node_modules/@weavecode/cli/dist/init/git-commit.js +2 -2
  20. package/node_modules/@weavecode/cli/dist/init/harnesses/claude.js +7 -7
  21. package/node_modules/@weavecode/cli/dist/init/harnesses/codex.js +1 -1
  22. package/node_modules/@weavecode/cli/dist/init/instruction-link.js +1 -1
  23. package/node_modules/@weavecode/cli/dist/init/plugin-templates.js +1 -1
  24. package/node_modules/@weavecode/cli/dist/init/prompt.js +4 -4
  25. package/node_modules/@weavecode/cli/dist/init/provision.js +1 -1
  26. package/node_modules/@weavecode/cli/dist/init/uninstall.js +6 -6
  27. package/node_modules/@weavecode/cli/dist/init/wiring.js +1 -1
  28. package/node_modules/@weavecode/cli/dist/parser.js +1 -1
  29. package/node_modules/@weavecode/cli/dist/statusline/ansi.js +1 -1
  30. package/node_modules/@weavecode/cli/dist/statusline/mock-input.js +1 -1
  31. package/node_modules/@weavecode/cli/dist/statusline/preview.js +2 -2
  32. package/node_modules/@weavecode/cli/package.json +5 -5
  33. package/node_modules/@weavecode/core/dist/harness-checks.js +1 -1
  34. package/node_modules/@weavecode/core/dist/harness.d.ts +11 -0
  35. package/node_modules/@weavecode/core/dist/harness.js +1 -1
  36. package/node_modules/@weavecode/core/dist/platform.js +1 -1
  37. package/node_modules/@weavecode/core/dist/types.js +1 -1
  38. package/node_modules/@weavecode/core/dist/utils/fs.js +1 -1
  39. package/node_modules/@weavecode/core/dist/utils/logger.js +1 -1
  40. package/node_modules/@weavecode/core/package.json +1 -1
  41. package/node_modules/@weavecode/harness/dist/claude/assets.js +4 -4
  42. package/node_modules/@weavecode/harness/dist/claude/capture.js +9 -9
  43. package/node_modules/@weavecode/harness/dist/claude/commands.js +2 -2
  44. package/node_modules/@weavecode/harness/dist/claude/config.js +2 -2
  45. package/node_modules/@weavecode/harness/dist/claude/detect.js +1 -1
  46. package/node_modules/@weavecode/harness/dist/claude/edits.js +1 -1
  47. package/node_modules/@weavecode/harness/dist/claude/event-source.js +1 -1
  48. package/node_modules/@weavecode/harness/dist/claude/images.js +2 -2
  49. package/node_modules/@weavecode/harness/dist/claude/index.js +1 -1
  50. package/node_modules/@weavecode/harness/dist/claude/liveness.js +1 -1
  51. package/node_modules/@weavecode/harness/dist/claude/mcp-gen.js +1 -1
  52. package/node_modules/@weavecode/harness/dist/claude/messaging.js +2 -2
  53. package/node_modules/@weavecode/harness/dist/claude/model-aliases.js +1 -1
  54. package/node_modules/@weavecode/harness/dist/claude/narration.js +1 -1
  55. package/node_modules/@weavecode/harness/dist/claude/peers.js +1 -1
  56. package/node_modules/@weavecode/harness/dist/claude/plan.js +1 -1
  57. package/node_modules/@weavecode/harness/dist/claude/plugins.js +4 -4
  58. package/node_modules/@weavecode/harness/dist/claude/prompt-inbox.js +1 -1
  59. package/node_modules/@weavecode/harness/dist/claude/prompt.js +3 -3
  60. package/node_modules/@weavecode/harness/dist/claude/questions.js +2 -2
  61. package/node_modules/@weavecode/harness/dist/claude/resume.js +1 -1
  62. package/node_modules/@weavecode/harness/dist/claude/rewind.js +1 -1
  63. package/node_modules/@weavecode/harness/dist/claude/settings-gen.js +1 -1
  64. package/node_modules/@weavecode/harness/dist/claude/side-question.js +2 -2
  65. package/node_modules/@weavecode/harness/dist/claude/statusline/generator.js +14 -14
  66. package/node_modules/@weavecode/harness/dist/claude/statusline/git-cache.js +1 -1
  67. package/node_modules/@weavecode/harness/dist/claude/statusline/surface.js +2 -2
  68. package/node_modules/@weavecode/harness/dist/claude/transcript-cursor.js +2 -2
  69. package/node_modules/@weavecode/harness/dist/claude/transcript.js +7 -7
  70. package/node_modules/@weavecode/harness/dist/codex/assets.js +1 -1
  71. package/node_modules/@weavecode/harness/dist/codex/capture.js +2 -2
  72. package/node_modules/@weavecode/harness/dist/codex/commands.js +4 -4
  73. package/node_modules/@weavecode/harness/dist/codex/config.js +2 -2
  74. package/node_modules/@weavecode/harness/dist/codex/detect.js +1 -1
  75. package/node_modules/@weavecode/harness/dist/codex/event-source.js +2 -2
  76. package/node_modules/@weavecode/harness/dist/codex/images.js +1 -1
  77. package/node_modules/@weavecode/harness/dist/codex/index.js +1 -1
  78. package/node_modules/@weavecode/harness/dist/codex/liveness.js +1 -1
  79. package/node_modules/@weavecode/harness/dist/codex/mcp.js +1 -1
  80. package/node_modules/@weavecode/harness/dist/codex/messaging.js +2 -2
  81. package/node_modules/@weavecode/harness/dist/codex/narration.js +1 -1
  82. package/node_modules/@weavecode/harness/dist/codex/plugin-state.js +1 -1
  83. package/node_modules/@weavecode/harness/dist/codex/plugins.js +3 -3
  84. package/node_modules/@weavecode/harness/dist/codex/provision.js +1 -1
  85. package/node_modules/@weavecode/harness/dist/codex/questions.js +2 -2
  86. package/node_modules/@weavecode/harness/dist/codex/rollout.js +5 -5
  87. package/node_modules/@weavecode/harness/dist/codex/side-question.js +4 -4
  88. package/node_modules/@weavecode/harness/dist/codex/titles.js +4 -4
  89. package/node_modules/@weavecode/harness/dist/codex/toml.js +13 -13
  90. package/node_modules/@weavecode/harness/dist/codex/transcript.js +2 -2
  91. package/node_modules/@weavecode/harness/dist/driver.d.ts +7 -0
  92. package/node_modules/@weavecode/harness/dist/driver.js +1 -1
  93. package/node_modules/@weavecode/harness/dist/init/generated.js +2 -2
  94. package/node_modules/@weavecode/harness/dist/init/pipeline.js +1 -1
  95. package/node_modules/@weavecode/harness/dist/registry-wiring.js +1 -1
  96. package/node_modules/@weavecode/harness/dist/shared/install-link.js +1 -1
  97. package/node_modules/@weavecode/harness/dist/shared/json-cap.js +1 -1
  98. package/node_modules/@weavecode/harness/dist/zcode/assets.js +1 -1
  99. package/node_modules/@weavecode/harness/dist/zcode/capture.js +3 -3
  100. package/node_modules/@weavecode/harness/dist/zcode/mcp.js +2 -2
  101. package/node_modules/@weavecode/harness/package.json +2 -2
  102. package/node_modules/@weavecode/server/dist/config/dotted.js +1 -1
  103. package/node_modules/@weavecode/server/dist/config/profiles.js +2 -2
  104. package/node_modules/@weavecode/server/dist/daemon/ai-config.js +2 -2
  105. package/node_modules/@weavecode/server/dist/daemon/ai-context.js +6 -6
  106. package/node_modules/@weavecode/server/dist/daemon/ai-routes.js +4 -4
  107. package/node_modules/@weavecode/server/dist/daemon/api-log.js +3 -3
  108. package/node_modules/@weavecode/server/dist/daemon/auth-routes.js +1 -1
  109. package/node_modules/@weavecode/server/dist/daemon/auto-start.js +6 -6
  110. package/node_modules/@weavecode/server/dist/daemon/capture-routes.js +1 -1
  111. package/node_modules/@weavecode/server/dist/daemon/config-routes.js +1 -1
  112. package/node_modules/@weavecode/server/dist/daemon/cron.js +1 -1
  113. package/node_modules/@weavecode/server/dist/daemon/dashboard-auth.js +2 -2
  114. package/node_modules/@weavecode/server/dist/daemon/dashboard-pusher.js +1 -1
  115. package/node_modules/@weavecode/server/dist/daemon/data-bus.js +1 -1
  116. package/node_modules/@weavecode/server/dist/daemon/decision-config.js +2 -2
  117. package/node_modules/@weavecode/server/dist/daemon/dev-entry.js +1 -1
  118. package/node_modules/@weavecode/server/dist/daemon/entry.js +2 -2
  119. package/node_modules/@weavecode/server/dist/daemon/fs-browser.js +1 -1
  120. package/node_modules/@weavecode/server/dist/daemon/hook-pipeline.js +1 -1
  121. package/node_modules/@weavecode/server/dist/daemon/hooks-routes.js +1 -1
  122. package/node_modules/@weavecode/server/dist/daemon/http.js +1 -1
  123. package/node_modules/@weavecode/server/dist/daemon/liveness.js +1 -1
  124. package/node_modules/@weavecode/server/dist/daemon/mcp-orchestration.js +1 -1
  125. package/node_modules/@weavecode/server/dist/daemon/narration-watcher.js +2 -2
  126. package/node_modules/@weavecode/server/dist/daemon/opener/backend-ghostty.js +1 -1
  127. package/node_modules/@weavecode/server/dist/daemon/opener/backend-iterm.js +1 -1
  128. package/node_modules/@weavecode/server/dist/daemon/opener/backend-konsole.js +2 -2
  129. package/node_modules/@weavecode/server/dist/daemon/opener/backend-terminal-app.js +1 -1
  130. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wezterm.js +1 -1
  131. package/node_modules/@weavecode/server/dist/daemon/opener/backend-wt.js +1 -1
  132. package/node_modules/@weavecode/server/dist/daemon/opener/backend.js +1 -1
  133. package/node_modules/@weavecode/server/dist/daemon/opener/launch.js +1 -1
  134. package/node_modules/@weavecode/server/dist/daemon/opener/pty-terminals.js +4 -4
  135. package/node_modules/@weavecode/server/dist/daemon/opener/shared.js +1 -1
  136. package/node_modules/@weavecode/server/dist/daemon/opener/wezterm-mux.js +1 -1
  137. package/node_modules/@weavecode/server/dist/daemon/opener/wt.js +3 -3
  138. package/node_modules/@weavecode/server/dist/daemon/opener.js +1 -1
  139. package/node_modules/@weavecode/server/dist/daemon/port.js +1 -1
  140. package/node_modules/@weavecode/server/dist/daemon/project-files.js +2 -2
  141. package/node_modules/@weavecode/server/dist/daemon/project-harnesses.js +2 -2
  142. package/node_modules/@weavecode/server/dist/daemon/project-updates-refresher.js +1 -1
  143. package/node_modules/@weavecode/server/dist/daemon/prompt-images.js +1 -1
  144. package/node_modules/@weavecode/server/dist/daemon/routes/hooks-admin.js +1 -1
  145. package/node_modules/@weavecode/server/dist/daemon/routes/market.js +1 -1
  146. package/node_modules/@weavecode/server/dist/daemon/routes/orchestration.js +1 -1
  147. package/node_modules/@weavecode/server/dist/daemon/routes/path-refs.js +1 -1
  148. package/node_modules/@weavecode/server/dist/daemon/routes/project-files.js +1 -1
  149. package/node_modules/@weavecode/server/dist/daemon/routes/projects.js +1 -1
  150. package/node_modules/@weavecode/server/dist/daemon/routes/search.js +1 -1
  151. package/node_modules/@weavecode/server/dist/daemon/routes/session-control.js +1 -1
  152. package/node_modules/@weavecode/server/dist/daemon/routes/session-insights.js +1 -1
  153. package/node_modules/@weavecode/server/dist/daemon/routes/settings-statusline.js +1 -1
  154. package/node_modules/@weavecode/server/dist/daemon/routes/uploads.js +1 -1
  155. package/node_modules/@weavecode/server/dist/daemon/routes/visualizations.js +1 -1
  156. package/node_modules/@weavecode/server/dist/daemon/routes/watches.js +1 -1
  157. package/node_modules/@weavecode/server/dist/daemon/server.js +8 -8
  158. package/node_modules/@weavecode/server/dist/daemon/session-open.d.ts +17 -0
  159. package/node_modules/@weavecode/server/dist/daemon/session-open.js +1 -1
  160. package/node_modules/@weavecode/server/dist/daemon/session-probe.js +1 -1
  161. package/node_modules/@weavecode/server/dist/daemon/settings.js +2 -2
  162. package/node_modules/@weavecode/server/dist/daemon/snapshot-refresher.js +1 -1
  163. package/node_modules/@weavecode/server/dist/daemon/sse-hub.js +1 -1
  164. package/node_modules/@weavecode/server/dist/daemon/start.js +1 -1
  165. package/node_modules/@weavecode/server/dist/daemon/state.js +2 -2
  166. package/node_modules/@weavecode/server/dist/daemon/static.js +1 -1
  167. package/node_modules/@weavecode/server/dist/daemon/terminal-topology-refresher.js +1 -1
  168. package/node_modules/@weavecode/server/dist/daemon/tls.js +1 -1
  169. package/node_modules/@weavecode/server/dist/daemon/toolkit-routes.js +1 -1
  170. package/node_modules/@weavecode/server/dist/daemon/upload-sessions.js +1 -1
  171. package/node_modules/@weavecode/server/dist/db/db.js +2 -2
  172. package/node_modules/@weavecode/server/dist/db/layout.js +1 -1
  173. package/node_modules/@weavecode/server/dist/hooks/answer-keys.js +1 -1
  174. package/node_modules/@weavecode/server/dist/hooks/bus.js +1 -1
  175. package/node_modules/@weavecode/server/dist/hooks/dashboard-rate.js +1 -1
  176. package/node_modules/@weavecode/server/dist/hooks/decision-judge.js +1 -1
  177. package/node_modules/@weavecode/server/dist/hooks/delivery/ack-gate.js +1 -1
  178. package/node_modules/@weavecode/server/dist/hooks/delivery/channels.js +1 -1
  179. package/node_modules/@weavecode/server/dist/hooks/delivery/keys.js +1 -1
  180. package/node_modules/@weavecode/server/dist/hooks/delivery/queue.js +1 -1
  181. package/node_modules/@weavecode/server/dist/hooks/delivery/relay.js +1 -1
  182. package/node_modules/@weavecode/server/dist/hooks/delivery/send.js +2 -2
  183. package/node_modules/@weavecode/server/dist/hooks/delivery/views.d.ts +3 -1
  184. package/node_modules/@weavecode/server/dist/hooks/delivery/views.js +1 -1
  185. package/node_modules/@weavecode/server/dist/hooks/dispatcher.js +6 -6
  186. package/node_modules/@weavecode/server/dist/hooks/edge-extract.js +1 -1
  187. package/node_modules/@weavecode/server/dist/hooks/handlers/webhook.js +1 -1
  188. package/node_modules/@weavecode/server/dist/hooks/headless-runner.js +2 -2
  189. package/node_modules/@weavecode/server/dist/hooks/inbox-socket.js +2 -2
  190. package/node_modules/@weavecode/server/dist/hooks/inbox-worker.js +3 -3
  191. package/node_modules/@weavecode/server/dist/hooks/match.js +1 -1
  192. package/node_modules/@weavecode/server/dist/hooks/message-deliverer.js +5 -5
  193. package/node_modules/@weavecode/server/dist/hooks/mirror.js +4 -4
  194. package/node_modules/@weavecode/server/dist/hooks/orchestration-engine.js +7 -7
  195. package/node_modules/@weavecode/server/dist/hooks/orchestration-graph.js +1 -1
  196. package/node_modules/@weavecode/server/dist/hooks/plugin-installer.js +3 -3
  197. package/node_modules/@weavecode/server/dist/hooks/plugin-loader.js +1 -1
  198. package/node_modules/@weavecode/server/dist/hooks/plugin-project-state.js +1 -1
  199. package/node_modules/@weavecode/server/dist/hooks/prompt-flusher.js +1 -1
  200. package/node_modules/@weavecode/server/dist/hooks/promptbox.js +8 -8
  201. package/node_modules/@weavecode/server/dist/hooks/push-notify.js +2 -2
  202. package/node_modules/@weavecode/server/dist/hooks/question-tracker.js +1 -1
  203. package/node_modules/@weavecode/server/dist/hooks/registry.js +1 -1
  204. package/node_modules/@weavecode/server/dist/hooks/resume-runner.js +1 -1
  205. package/node_modules/@weavecode/server/dist/hooks/session-purge.js +1 -1
  206. package/node_modules/@weavecode/server/dist/hooks/side-questions.js +1 -1
  207. package/node_modules/@weavecode/server/dist/hooks/synthetic-sessions.js +1 -1
  208. package/node_modules/@weavecode/server/dist/hooks/toolkit-scan.js +1 -1
  209. package/node_modules/@weavecode/server/dist/hooks/toolkit.js +5 -5
  210. package/node_modules/@weavecode/server/dist/hooks/watch-engine.js +1 -1
  211. package/node_modules/@weavecode/server/dist/install/apply-update.js +1 -1
  212. package/node_modules/@weavecode/server/dist/install/capabilities.js +1 -1
  213. package/node_modules/@weavecode/server/dist/install/codex-toml.js +1 -1
  214. package/node_modules/@weavecode/server/dist/install/file-assets.js +1 -1
  215. package/node_modules/@weavecode/server/dist/install/fingerprint.js +1 -1
  216. package/node_modules/@weavecode/server/dist/install/global-config.js +1 -1
  217. package/node_modules/@weavecode/server/dist/install/global-file-assets.js +1 -1
  218. package/node_modules/@weavecode/server/dist/install/init-files.js +2 -2
  219. package/node_modules/@weavecode/server/dist/install/install-ledger.js +1 -1
  220. package/node_modules/@weavecode/server/dist/install/installer.js +1 -1
  221. package/node_modules/@weavecode/server/dist/install/library-index.js +1 -1
  222. package/node_modules/@weavecode/server/dist/install/mcp-rows.js +1 -1
  223. package/node_modules/@weavecode/server/dist/install/plugin-install.js +1 -1
  224. package/node_modules/@weavecode/server/dist/install/plugin-rows.js +1 -1
  225. package/node_modules/@weavecode/server/dist/install/plugin-templates.js +1 -1
  226. package/node_modules/@weavecode/server/dist/install/project-config.js +1 -1
  227. package/node_modules/@weavecode/server/dist/install/reader.js +1 -1
  228. package/node_modules/@weavecode/server/dist/install/scan-cache.js +1 -1
  229. package/node_modules/@weavecode/server/dist/install/scanner.js +1 -1
  230. package/node_modules/@weavecode/server/dist/install/settings-mcp.js +2 -2
  231. package/node_modules/@weavecode/server/dist/install/updates.js +1 -1
  232. package/node_modules/@weavecode/server/dist/market/builtin.js +1 -1
  233. package/node_modules/@weavecode/server/dist/market/identity.js +1 -1
  234. package/node_modules/@weavecode/server/dist/market/import.js +2 -2
  235. package/node_modules/@weavecode/server/dist/market/refresh.js +1 -1
  236. package/node_modules/@weavecode/server/dist/market/resolve.js +1 -1
  237. package/node_modules/@weavecode/server/dist/market/updates.js +1 -1
  238. package/node_modules/@weavecode/server/dist/registry.js +2 -2
  239. package/node_modules/@weavecode/server/dist/repositories/hook-dispatches.js +5 -5
  240. package/node_modules/@weavecode/server/dist/repositories/hook-events.js +4 -4
  241. package/node_modules/@weavecode/server/dist/repositories/hook-rules.js +4 -4
  242. package/node_modules/@weavecode/server/dist/repositories/libraries.js +1 -1
  243. package/node_modules/@weavecode/server/dist/repositories/orchestrations.js +7 -7
  244. package/node_modules/@weavecode/server/dist/repositories/plugin-states.js +1 -1
  245. package/node_modules/@weavecode/server/dist/repositories/projects.js +2 -2
  246. package/node_modules/@weavecode/server/dist/repositories/push-subscriptions.js +2 -2
  247. package/node_modules/@weavecode/server/dist/repositories/session-watches.js +4 -4
  248. package/node_modules/@weavecode/server/dist/repositories/sessions.js +2 -2
  249. package/node_modules/@weavecode/server/dist/repositories/uploads.js +11 -11
  250. package/node_modules/@weavecode/server/dist/statusline/cache-sweeper.js +1 -1
  251. package/node_modules/@weavecode/server/dist/statusline/generator.js +1 -1
  252. package/node_modules/@weavecode/server/dist/statusline/manager.js +3 -3
  253. package/node_modules/@weavecode/server/dist/surfaces.js +1 -1
  254. package/node_modules/@weavecode/server/dist/watch/cache.js +1 -1
  255. package/node_modules/@weavecode/server/dist/watch/classifier.js +1 -1
  256. package/node_modules/@weavecode/server/dist/watch/plugin-mods.js +1 -1
  257. package/node_modules/@weavecode/server/dist/watch/sync-scheduler.js +1 -1
  258. package/node_modules/@weavecode/server/dist/watch/watch-service.js +1 -1
  259. package/node_modules/@weavecode/server/package.json +4 -4
  260. package/node_modules/@weavecode/server/web/dist/assets/{abnfDiagram-WEYOIA3C-CbIFQh0R.js → abnfDiagram-WEYOIA3C-DDeQkTf5.js} +1 -1
  261. package/node_modules/@weavecode/server/web/dist/assets/{arc-DH8-rYAa.js → arc-CRZTRyjb.js} +1 -1
  262. package/node_modules/@weavecode/server/web/dist/assets/{architectureDiagram-ZHVYKT53-qnv6S0sc.js → architectureDiagram-ZHVYKT53-Dj54DE3O.js} +1 -1
  263. package/node_modules/@weavecode/server/web/dist/assets/{blockDiagram-RJAE7QA3-pT5eO-cB.js → blockDiagram-RJAE7QA3-BIH8mSIZ.js} +1 -1
  264. package/node_modules/@weavecode/server/web/dist/assets/{c4Diagram-XDPPPE54-DHDBDMb1.js → c4Diagram-XDPPPE54-5YoKWFOD.js} +1 -1
  265. package/node_modules/@weavecode/server/web/dist/assets/channel-5VM93AJ8.js +1 -0
  266. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2E7WHVMD-CT951PH5.js → chunk-2E7WHVMD-B653kMXt.js} +1 -1
  267. package/node_modules/@weavecode/server/web/dist/assets/{chunk-2Q5K7J3B-E5AD7_ZY.js → chunk-2Q5K7J3B-f_A4_eDz.js} +1 -1
  268. package/node_modules/@weavecode/server/web/dist/assets/{chunk-4EMNKR2T-DWz9qkcy.js → chunk-4EMNKR2T-v5j5qNGj.js} +1 -1
  269. package/node_modules/@weavecode/server/web/dist/assets/{chunk-55XCU76K-D-SgWD8w.js → chunk-55XCU76K-CgEqeP7j.js} +1 -1
  270. package/node_modules/@weavecode/server/web/dist/assets/{chunk-5VM5RSS4-ci6YzbO5.js → chunk-5VM5RSS4-BeROhLXN.js} +1 -1
  271. package/node_modules/@weavecode/server/web/dist/assets/{chunk-JWPE2WC7-CY4mr2f4.js → chunk-JWPE2WC7-D6dXb_jr.js} +1 -1
  272. package/node_modules/@weavecode/server/web/dist/assets/{chunk-VQ5W62QI-CON8zyg8.js → chunk-VQ5W62QI-CnHdSEMi.js} +1 -1
  273. package/node_modules/@weavecode/server/web/dist/assets/{chunk-XXDRQBXY-DXXXZ4pW.js → chunk-XXDRQBXY-BkG_e6PE.js} +1 -1
  274. package/node_modules/@weavecode/server/web/dist/assets/{chunk-ZCHMQSOR-CukvPvkM.js → chunk-ZCHMQSOR-DxR-fxzs.js} +2 -2
  275. package/node_modules/@weavecode/server/web/dist/assets/{classDiagram-v2-4MYWR3UA-GiWZ9xtF.js → classDiagram-v2-4MYWR3UA-DQe1b_k8.js} +1 -1
  276. package/node_modules/@weavecode/server/web/dist/assets/{cose-bilkent-JH36ORCC-D7aJ-akq.js → cose-bilkent-JH36ORCC-DThrA8S5.js} +1 -1
  277. package/node_modules/@weavecode/server/web/dist/assets/{cynefin-EF2NZ3EQ-9B__MaRM.js → cynefin-EF2NZ3EQ-OZotFKUu.js} +1 -1
  278. package/node_modules/@weavecode/server/web/dist/assets/{cynefinDiagram-WF24UDRP-B2ujZh2k.js → cynefinDiagram-WF24UDRP-DJjq2hfT.js} +1 -1
  279. package/node_modules/@weavecode/server/web/dist/assets/{dagre-NK4GIZVX-nHaB6IWf.js → dagre-NK4GIZVX-C2vH93HT.js} +1 -1
  280. package/node_modules/@weavecode/server/web/dist/assets/{diagram-CBK3MWTC-xKfjDvgr.js → diagram-CBK3MWTC-DrF_ScM-.js} +1 -1
  281. package/node_modules/@weavecode/server/web/dist/assets/{diagram-I5XIIV2D-BHT2-5mY.js → diagram-I5XIIV2D-D1qoUJ4t.js} +1 -1
  282. package/node_modules/@weavecode/server/web/dist/assets/{diagram-ODIL2UCW-CckywF4W.js → diagram-ODIL2UCW-D9A6W8oB.js} +1 -1
  283. package/node_modules/@weavecode/server/web/dist/assets/{diagram-PFBEJUXE-Dpjlc7Wh.js → diagram-PFBEJUXE-PeI-eyu2.js} +1 -1
  284. package/node_modules/@weavecode/server/web/dist/assets/{diagram-RJA3I4VV-M6WznOaW.js → diagram-RJA3I4VV-DITY0Rd8.js} +1 -1
  285. package/node_modules/@weavecode/server/web/dist/assets/{diagram-TYUNFSNR-DgRJ3zL1.js → diagram-TYUNFSNR-D5KieEw5.js} +1 -1
  286. package/node_modules/@weavecode/server/web/dist/assets/{ebnfDiagram-V4P3TTPT-BzzVN__a.js → ebnfDiagram-V4P3TTPT-DDylK-gz.js} +1 -1
  287. package/node_modules/@weavecode/server/web/dist/assets/{elk-QONTBCTQ-Ch6Gs9G9.js → elk-QONTBCTQ-D3xrVg0U.js} +1 -1
  288. package/node_modules/@weavecode/server/web/dist/assets/{erDiagram-KYQIGQAA-COxT-Pxb.js → erDiagram-KYQIGQAA-y_V1cor7.js} +1 -1
  289. package/node_modules/@weavecode/server/web/dist/assets/{flowDiagram-IUGLLWBU-CJVWnTBa.js → flowDiagram-IUGLLWBU-BJ8Z0MkF.js} +1 -1
  290. package/node_modules/@weavecode/server/web/dist/assets/{ganttDiagram-R7GPNTJY-BkRpWPUl.js → ganttDiagram-R7GPNTJY-C0q-CS1T.js} +1 -1
  291. package/node_modules/@weavecode/server/web/dist/assets/{gitGraphDiagram-PDYL7XHY-Ba8BJcvZ.js → gitGraphDiagram-PDYL7XHY-BYTComiB.js} +1 -1
  292. package/node_modules/@weavecode/server/web/dist/assets/index-BKxAxaVG.js +1091 -0
  293. package/node_modules/@weavecode/server/web/dist/assets/index-C0Sd4MH7.css +11 -0
  294. package/node_modules/@weavecode/server/web/dist/assets/{infoDiagram-MVDRKAX5-HTQ5FUNK.js → infoDiagram-MVDRKAX5-DtixgjLP.js} +1 -1
  295. package/node_modules/@weavecode/server/web/dist/assets/{ishikawaDiagram-HPEHV2GE-BNjEDIZy.js → ishikawaDiagram-HPEHV2GE-ChEnND76.js} +1 -1
  296. package/node_modules/@weavecode/server/web/dist/assets/{journeyDiagram-BOSHW7O7-Cao6h91a.js → journeyDiagram-BOSHW7O7-DHcNtpYF.js} +1 -1
  297. package/node_modules/@weavecode/server/web/dist/assets/{kanban-definition-FNSA4HC5-CXIx2CHQ.js → kanban-definition-FNSA4HC5-Dft7qpW5.js} +1 -1
  298. package/node_modules/@weavecode/server/web/dist/assets/{linear-65WmlvQb.js → linear-DEo11t-X.js} +1 -1
  299. package/node_modules/@weavecode/server/web/dist/assets/{mermaid.core-D39fi_iR.js → mermaid.core-D_Dp_Kl2.js} +4 -4
  300. package/node_modules/@weavecode/server/web/dist/assets/{mindmap-definition-6OY57UG3-DHqpz_AK.js → mindmap-definition-6OY57UG3-CM6OAd_-.js} +1 -1
  301. package/node_modules/@weavecode/server/web/dist/assets/{pegDiagram-ECIUJNBX-Cpy1nsER.js → pegDiagram-ECIUJNBX-_QkY0h8Q.js} +1 -1
  302. package/node_modules/@weavecode/server/web/dist/assets/{pieDiagram-GNMPY74T-B1IyNqzr.js → pieDiagram-GNMPY74T-ZGr5vtDj.js} +1 -1
  303. package/node_modules/@weavecode/server/web/dist/assets/{quadrantDiagram-D57K4MC3-zSM6o7mB.js → quadrantDiagram-D57K4MC3-D8pQ_PU2.js} +1 -1
  304. package/node_modules/@weavecode/server/web/dist/assets/{railroadDiagram-Y72NRBL7-oM4XJIwA.js → railroadDiagram-Y72NRBL7-DUIo-WmA.js} +1 -1
  305. package/node_modules/@weavecode/server/web/dist/assets/{requirementDiagram-EQYSW5RA-CbCLBjHf.js → requirementDiagram-EQYSW5RA-C90DU5Ny.js} +1 -1
  306. package/node_modules/@weavecode/server/web/dist/assets/{sankeyDiagram-SY24JHO5-BucVk6EP.js → sankeyDiagram-SY24JHO5-B_poYGgJ.js} +1 -1
  307. package/node_modules/@weavecode/server/web/dist/assets/{sequenceDiagram-BLEHNHQU-Dg8CYEnT.js → sequenceDiagram-BLEHNHQU-DDW7b2Dn.js} +1 -1
  308. package/node_modules/@weavecode/server/web/dist/assets/{sizeCapture-INFHLROL-C51zb7Oc.js → sizeCapture-INFHLROL-CmKoqX6K.js} +1 -1
  309. package/node_modules/@weavecode/server/web/dist/assets/{stateDiagram-v2-A6IESKWZ-BvK2l3is.js → stateDiagram-v2-A6IESKWZ-CkVMAyxG.js} +1 -1
  310. package/node_modules/@weavecode/server/web/dist/assets/{swimlanes-B3ENRKFQ-Ds7QOfXW.js → swimlanes-B3ENRKFQ-Dm_Omzky.js} +1 -1
  311. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-Bjj8ZA4d.js +8 -0
  312. package/node_modules/@weavecode/server/web/dist/assets/{timeline-definition-JXYKGLGB-CadU4Qq4.js → timeline-definition-JXYKGLGB-DnhkRGLb.js} +1 -1
  313. package/node_modules/@weavecode/server/web/dist/assets/{usecaseDiagram-WPOLBNNX-BYuZwTDZ.js → usecaseDiagram-WPOLBNNX-_TdIjC6Z.js} +1 -1
  314. package/node_modules/@weavecode/server/web/dist/assets/{vennDiagram-Q3Y3IDCW-C7zgxe07.js → vennDiagram-Q3Y3IDCW-FzgsymXB.js} +1 -1
  315. package/node_modules/@weavecode/server/web/dist/assets/{wardleyDiagram-IVAIDKWA-DA4Otf4s.js → wardleyDiagram-IVAIDKWA-BwqimStC.js} +1 -1
  316. package/node_modules/@weavecode/server/web/dist/assets/{xychartDiagram-4URNHDU4-Bs5YGwMU.js → xychartDiagram-4URNHDU4-CFjjVPIV.js} +1 -1
  317. package/node_modules/@weavecode/server/web/dist/icons/apple-touch-icon.png +0 -0
  318. package/node_modules/@weavecode/server/web/dist/icons/icon-192.png +0 -0
  319. package/node_modules/@weavecode/server/web/dist/icons/icon-512.png +0 -0
  320. package/node_modules/@weavecode/server/web/dist/icons/icon-maskable-512.png +0 -0
  321. package/node_modules/@weavecode/server/web/dist/index.html +11 -2
  322. package/node_modules/@weavecode/server/web/dist/manifest.webmanifest +16 -0
  323. package/node_modules/@weavecode/templates/package.json +2 -2
  324. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/README.md +3 -8
  325. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/package.json +1 -1
  326. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.d.ts +4 -2
  327. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.es6.js +10 -1
  328. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.es6.mjs +10 -1
  329. package/node_modules/selfsigned/node_modules/@peculiar/x509/node_modules/tslib/tslib.js +10 -1
  330. package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/README.md +3 -8
  331. package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/package.json +1 -1
  332. package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.d.ts +4 -2
  333. package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.es6.js +10 -1
  334. package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.es6.mjs +10 -1
  335. package/node_modules/selfsigned/node_modules/pkijs/node_modules/tslib/tslib.js +10 -1
  336. package/package.json +6 -6
  337. package/node_modules/@weavecode/server/web/dist/assets/channel-BHPeeuzN.js +0 -1
  338. package/node_modules/@weavecode/server/web/dist/assets/index-CtifxEiF.css +0 -11
  339. package/node_modules/@weavecode/server/web/dist/assets/index-FwH9INgS.js +0 -1090
  340. package/node_modules/@weavecode/server/web/dist/assets/swimlanesDiagram-AYQRV4AK-ByBF02UJ.js +0 -8
@@ -1,8 +1,8 @@
1
- import{randomUUID as s}from"node:crypto";import{HookRuleSchema as d}from"@weavecode/core";export class HookRuleRepository{db;constructor(r){this.db=r}create(r){const e=new Date().toISOString(),o=d.parse({id:s(),name:r.name,enabled:r.enabled??!0,priority:r.priority??0,projectId:r.projectId,source:r.source,filter:r.filter??{},handler:r.handler,timeoutMs:r.timeoutMs??1e4,record:r.record??r.handler.type!=="log",origin:r.origin??"user",pluginId:r.pluginId??null});return this.insertRow(o,e,e),o}upsertPluginRule(r){const e=new Date().toISOString(),o=this.getById(r.id);if(!o)return this.insertRow(r,e,e),r;const t=d.parse({...r,enabled:o.enabled});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
1
+ import{randomUUID as s}from"node:crypto";import{HookRuleSchema as o}from"@weavecode/core";export class HookRuleRepository{db;constructor(e){this.db=e}create(e){const t=new Date().toISOString(),i=o.parse({id:s(),name:e.name,enabled:e.enabled??!0,priority:e.priority??0,projectId:e.projectId,source:e.source,filter:e.filter??{},handler:e.handler,timeoutMs:e.timeoutMs??1e4,record:e.record??e.handler.type!=="log",origin:e.origin??"user",pluginId:e.pluginId??null});return this.insertRow(i,t,t),i}upsertPluginRule(e){const t=new Date().toISOString(),i=this.getById(e.id);if(!i)return this.insertRow(e,t,t),e;const r=o.parse({...e,enabled:i.enabled});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
2
2
  source = ?, filter = ?, handler = ?, timeout_ms = ?, record = ?,
3
3
  origin = ?, plugin_id = ?, updated_at = ?
4
- WHERE id = ?`).run(t.name,t.enabled?1:0,t.priority,t.projectId,JSON.stringify(t.source),JSON.stringify(t.filter),JSON.stringify(t.handler),t.timeoutMs,t.record?1:0,t.origin,t.pluginId,e,t.id),t}removeByPlugin(r){const e=this.db.prepare("DELETE FROM hook_rules WHERE plugin_id = ?").run(r);return Number(e.changes)}listByPlugin(r){return this.db.prepare("SELECT * FROM hook_rules WHERE plugin_id = ? ORDER BY created_at ASC").all(r).map(n).filter(e=>e!==void 0)}getById(r){const e=this.db.prepare("SELECT * FROM hook_rules WHERE id = ?").get(r);return e?n(e):void 0}list(r){return(r===void 0?this.db.prepare("SELECT * FROM hook_rules ORDER BY priority DESC, created_at ASC").all():this.db.prepare("SELECT * FROM hook_rules WHERE project_id IS NULL OR project_id = ? ORDER BY priority DESC, created_at ASC").all(r)).map(n).filter(e=>e!==void 0)}update(r,e){const o=this.getById(r);if(!o)return;const t=d.parse({...o,...e,id:r,projectId:"projectId"in e?e.projectId:o.projectId});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
4
+ WHERE id = ?`).run(r.name,r.enabled?1:0,r.priority,r.projectId,JSON.stringify(r.source),JSON.stringify(r.filter),JSON.stringify(r.handler),r.timeoutMs,r.record?1:0,r.origin,r.pluginId,t,r.id),r}removeByPlugin(e){const t=this.db.prepare("DELETE FROM hook_rules WHERE plugin_id = ?").run(e);return Number(t.changes)}listByPlugin(e){return this.db.prepare("SELECT * FROM hook_rules WHERE plugin_id = ? ORDER BY created_at ASC").all(e).map(d).filter(i=>i!==void 0)}getById(e){const t=this.db.prepare("SELECT * FROM hook_rules WHERE id = ?").get(e);return t?d(t):void 0}list(e){return(e===void 0?this.db.prepare("SELECT * FROM hook_rules ORDER BY priority DESC, created_at ASC").all():this.db.prepare("SELECT * FROM hook_rules WHERE project_id IS NULL OR project_id = ? ORDER BY priority DESC, created_at ASC").all(e)).map(d).filter(i=>i!==void 0)}update(e,t){const i=this.getById(e);if(!i)return;const r=o.parse({...i,...t,id:e,projectId:"projectId"in t?t.projectId:i.projectId});return this.db.prepare(`UPDATE hook_rules SET name = ?, enabled = ?, priority = ?, project_id = ?,
5
5
  source = ?, filter = ?, handler = ?, timeout_ms = ?, record = ?, updated_at = ?
6
- WHERE id = ?`).run(t.name,t.enabled?1:0,t.priority,t.projectId,JSON.stringify(t.source),JSON.stringify(t.filter),JSON.stringify(t.handler),t.timeoutMs,t.record?1:0,new Date().toISOString(),r),t}setEnabled(r,e){const o=this.db.prepare("UPDATE hook_rules SET enabled = ?, updated_at = ? WHERE id = ?").run(e?1:0,new Date().toISOString(),r);if(Number(o.changes)!==0)return this.getById(r)}remove(r){const e=this.db.prepare("DELETE FROM hook_rules WHERE id = ?").run(r);return Number(e.changes)>0}insertRow(r,e,o){this.db.prepare(`INSERT INTO hook_rules (id, name, enabled, priority, project_id, source, filter, handler,
6
+ WHERE id = ?`).run(r.name,r.enabled?1:0,r.priority,r.projectId,JSON.stringify(r.source),JSON.stringify(r.filter),JSON.stringify(r.handler),r.timeoutMs,r.record?1:0,new Date().toISOString(),e),r}setEnabled(e,t){const i=this.db.prepare("UPDATE hook_rules SET enabled = ?, updated_at = ? WHERE id = ?").run(t?1:0,new Date().toISOString(),e);if(Number(i.changes)!==0)return this.getById(e)}remove(e){const t=this.db.prepare("DELETE FROM hook_rules WHERE id = ?").run(e);return Number(t.changes)>0}insertRow(e,t,i){this.db.prepare(`INSERT INTO hook_rules (id, name, enabled, priority, project_id, source, filter, handler,
7
7
  timeout_ms, record, origin, plugin_id, created_at, updated_at)
8
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(r.id,r.name,r.enabled?1:0,r.priority,r.projectId,JSON.stringify(r.source),JSON.stringify(r.filter),JSON.stringify(r.handler),r.timeoutMs,r.record?1:0,r.origin,r.pluginId,e,o)}}function n(i){try{return d.parse({id:String(i.id),name:String(i.name),enabled:Number(i.enabled)===1,priority:Number(i.priority),projectId:i.project_id==null?null:Number(i.project_id),source:JSON.parse(String(i.source)),filter:JSON.parse(String(i.filter??"{}")),handler:JSON.parse(String(i.handler)),timeoutMs:Number(i.timeout_ms),record:Number(i.record)===1,origin:i.origin??"user",pluginId:i.plugin_id==null?null:String(i.plugin_id)})}catch{return}}
8
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(e.id,e.name,e.enabled?1:0,e.priority,e.projectId,JSON.stringify(e.source),JSON.stringify(e.filter),JSON.stringify(e.handler),e.timeoutMs,e.record?1:0,e.origin,e.pluginId,t,i)}}function d(n){try{return o.parse({id:String(n.id),name:String(n.name),enabled:Number(n.enabled)===1,priority:Number(n.priority),projectId:n.project_id==null?null:Number(n.project_id),source:JSON.parse(String(n.source)),filter:JSON.parse(String(n.filter??"{}")),handler:JSON.parse(String(n.handler)),timeoutMs:Number(n.timeout_ms),record:Number(n.record)===1,origin:n.origin??"user",pluginId:n.plugin_id==null?null:String(n.plugin_id)})}catch{return}}
@@ -1 +1 @@
1
- import a from"node:path";import{getDataRoot as h}from"../db/paths.js";import{isInsideDir as o,resolveLibraryPath as p,toRelPosix as d}from"../market/resolve.js";export class LibraryRepository{db;dataRoot;constructor(t,r=h()){this.db=t,this.dataRoot=r}add(t){return this.getByPath(t.path)||(this.db.prepare("INSERT OR IGNORE INTO libraries (path, kind, added_at) VALUES (?, ?, ?)").run(this.writeForm(t.path),t.kind,new Date().toISOString()),this.getByPath(t.path))}getByPath(t){for(const r of new Set([t,this.writeForm(t)])){const s=this.db.prepare("SELECT * FROM libraries WHERE path = ?").get(r);if(s)return this.resolveRow(e(s))}}getById(t){const r=this.db.prepare("SELECT * FROM libraries WHERE id = ?").get(t);return r?this.resolveRow(e(r)):void 0}list(){return this.db.prepare("SELECT * FROM libraries ORDER BY added_at DESC").all().map(t=>this.resolveRow(e(t)))}setPath(t,r){this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(this.writeForm(r),t)}remove(t){this.db.prepare("DELETE FROM libraries WHERE id = ?").run(t)}writeForm(t){return a.isAbsolute(t)&&o(t,this.dataRoot)?d(t,this.dataRoot):t}resolveRow(t){if(!a.isAbsolute(t.path))return{...t,path:p(t,this.dataRoot)};const r=a.resolve(t.path);return o(r,this.dataRoot)?(this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(d(r,this.dataRoot),t.id),{...t,path:r}):t}}function e(i){return{id:Number(i.id),path:String(i.path),kind:i.kind,addedAt:String(i.added_at)}}
1
+ import i from"node:path";import{getDataRoot as h}from"../db/paths.js";import{isInsideDir as o,resolveLibraryPath as n,toRelPosix as d}from"../market/resolve.js";export class LibraryRepository{db;dataRoot;constructor(t,r=h()){this.db=t,this.dataRoot=r}add(t){const r=this.getByPath(t.path);return r||(this.db.prepare("INSERT OR IGNORE INTO libraries (path, kind, added_at) VALUES (?, ?, ?)").run(this.writeForm(t.path),t.kind,new Date().toISOString()),this.getByPath(t.path))}getByPath(t){for(const r of new Set([t,this.writeForm(t)])){const s=this.db.prepare("SELECT * FROM libraries WHERE path = ?").get(r);if(s)return this.resolveRow(a(s))}}getById(t){const r=this.db.prepare("SELECT * FROM libraries WHERE id = ?").get(t);return r?this.resolveRow(a(r)):void 0}list(){return this.db.prepare("SELECT * FROM libraries ORDER BY added_at DESC").all().map(t=>this.resolveRow(a(t)))}setPath(t,r){this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(this.writeForm(r),t)}remove(t){this.db.prepare("DELETE FROM libraries WHERE id = ?").run(t)}writeForm(t){return i.isAbsolute(t)&&o(t,this.dataRoot)?d(t,this.dataRoot):t}resolveRow(t){if(!i.isAbsolute(t.path))return{...t,path:n(t,this.dataRoot)};const r=i.resolve(t.path);return o(r,this.dataRoot)?(this.db.prepare("UPDATE libraries SET path = ? WHERE id = ?").run(d(r,this.dataRoot),t.id),{...t,path:r}):t}}function a(e){return{id:Number(e.id),path:String(e.path),kind:e.kind,addedAt:String(e.added_at)}}
@@ -1,16 +1,16 @@
1
- import{randomBytes as E}from"node:crypto";export const ORCH_RUN_RETENTION_DAYS=7,ORCH_RUN_KEEP_PER_ORCH=100;function h(o){let t;try{t=JSON.parse(String(o))}catch{return[]}if(!Array.isArray(t))return[];const e=[];for(const r of t){if(typeof r!="object"||r===null)continue;const n=r;if(typeof n.id!="string"||!n.id)continue;const i={id:n.id,kind:n.kind==="webhook"?"webhook":n.kind==="trigger"?"trigger":"session"};typeof n.webhookToken=="string"&&n.webhookToken&&(i.webhookToken=n.webhookToken),typeof n.url=="string"&&n.url&&(i.url=n.url),typeof n.secret=="string"&&n.secret&&(i.secret=n.secret),n.autoFire===!0&&(i.autoFire=!0),e.push(i)}return e}export function graphDirections(o,t){const e=new Set(t.map(n=>n.to)),r=new Set(t.map(n=>n.from));return{entries:o.filter(n=>!e.has(n.id)),exits:o.filter(n=>!r.has(n.id))}}export function pendingCountsOf(o){const t={};for(const[e,r]of Object.entries(o.pending))r.length>0&&(t[e]=r.length);return t}export function toRunSummary(o){const{state:t,...e}=o;return{...e,pendingCounts:pendingCountsOf(t)}}function d(){return E(18).toString("base64url")}function p(){return{pending:{},events:[]}}export class OrchestrationRepository{db;constructor(t){this.db=t}insert(t){const e=new Date().toISOString(),r=l(this.db,t.nodes,t.edges),n=this.db.prepare(`INSERT INTO orchestrations
1
+ import{randomBytes as f}from"node:crypto";export const ORCH_RUN_RETENTION_DAYS=7,ORCH_RUN_KEEP_PER_ORCH=100;function l(s){let e;try{e=JSON.parse(String(s))}catch{return[]}if(!Array.isArray(e))return[];const t=[];for(const n of e){if(typeof n!="object"||n===null)continue;const r=n;if(typeof r.id!="string"||!r.id)continue;const o={id:r.id,kind:r.kind==="webhook"?"webhook":r.kind==="trigger"?"trigger":"session"};typeof r.webhookToken=="string"&&r.webhookToken&&(o.webhookToken=r.webhookToken),typeof r.url=="string"&&r.url&&(o.url=r.url),typeof r.secret=="string"&&r.secret&&(o.secret=r.secret),r.autoFire===!0&&(o.autoFire=!0),t.push(o)}return t}export function graphDirections(s,e){const t=new Set(e.map(r=>r.to)),n=new Set(e.map(r=>r.from));return{entries:s.filter(r=>!t.has(r.id)),exits:s.filter(r=>!n.has(r.id))}}export function pendingCountsOf(s){const e={};for(const[t,n]of Object.entries(s.pending))n.length>0&&(e[t]=n.length);return e}export function toRunSummary(s){const{state:e,...t}=s;return{...t,pendingCounts:pendingCountsOf(e)}}function u(){return f(18).toString("base64url")}function g(){return{pending:{},events:[]}}export class OrchestrationRepository{db;constructor(e){this.db=e}insert(e){const t=new Date().toISOString(),n=p(this.db,e.nodes,e.edges),r=this.db.prepare(`INSERT INTO orchestrations
2
2
  (name, project_id, start_text, nodes, edges, enabled, cron, created_at, updated_at)
3
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(t.name,t.projectId,t.startText,JSON.stringify(r),JSON.stringify(t.edges),t.enabled===!1?0:1,t.cron??null,e,e);return this.getById(Number(n.lastInsertRowid))}getById(t){const e=this.db.prepare("SELECT * FROM orchestrations WHERE id = ?").get(t);return e?u(e):void 0}getByNodeToken(t){for(const e of this.list()){const r=e.nodes.find(n=>n.kind==="webhook"&&n.webhookToken===t);if(r)return{row:e,nodeId:r.id}}}list(){return this.db.prepare("SELECT * FROM orchestrations ORDER BY id").all().map(u)}listByProject(t){return this.db.prepare("SELECT * FROM orchestrations WHERE project_id = ? ORDER BY id").all(t).map(u)}update(t,e){const r=this.getById(t);if(!r)return;const n=l(this.db,e.nodes??r.nodes,e.edges??r.edges);return this.db.prepare(`UPDATE orchestrations
3
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`).run(e.name,e.projectId,e.startText,JSON.stringify(n),JSON.stringify(e.edges),e.enabled===!1?0:1,e.cron??null,t,t);return this.getById(Number(r.lastInsertRowid))}getById(e){const t=this.db.prepare("SELECT * FROM orchestrations WHERE id = ?").get(e);return t?c(t):void 0}getByNodeToken(e){for(const t of this.list()){const n=t.nodes.find(r=>r.kind==="webhook"&&r.webhookToken===e);if(n)return{row:t,nodeId:n.id}}}list(){return this.db.prepare("SELECT * FROM orchestrations ORDER BY id").all().map(c)}listByProject(e){return this.db.prepare("SELECT * FROM orchestrations WHERE project_id = ? ORDER BY id").all(e).map(c)}update(e,t){const n=this.getById(e);if(!n)return;const r=p(this.db,t.nodes??n.nodes,t.edges??n.edges);return this.db.prepare(`UPDATE orchestrations
4
4
  SET name = ?, project_id = ?, start_text = ?, nodes = ?, edges = ?, enabled = ?, cron = ?, updated_at = ?
5
- WHERE id = ?`).run(e.name??r.name,e.projectId??r.projectId,e.startText??r.startText,JSON.stringify(n),JSON.stringify(e.edges??r.edges),e.enabled??r.enabled?1:0,e.cron===void 0?r.cron:e.cron,new Date().toISOString(),t),this.getById(t)}setCronFired(t,e){this.db.prepare("UPDATE orchestrations SET last_cron_at = ? WHERE id = ?").run(e,t)}rotateNodeToken(t,e){const r=this.getById(t);if(!r||!r.nodes.find(a=>a.id===e&&a.kind==="webhook"))return null;const n=this.allTokens();let i=d();for(;n.has(i);)i=d();const s=r.nodes.map(a=>a.id===e?{...a,webhookToken:i}:a);return this.db.prepare("UPDATE orchestrations SET nodes = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(s),new Date().toISOString(),t),i}allTokens(){const t=new Set;for(const e of this.list())for(const r of e.nodes)r.webhookToken&&t.add(r.webhookToken);return t}deleteById(t){return Number(this.db.prepare("DELETE FROM orchestrations WHERE id = ?").run(t).changes)===1}deleteMentioningSession(t){const e=this.list().filter(r=>r.nodes.some(n=>n.kind==="session"&&n.id===t));return this.deleteAll(e)}deleteByProject(t){return this.deleteAll(this.listByProject(t))}deleteAll(t){const e=this.db.prepare("DELETE FROM orchestrations WHERE id = ?");return t.reduce((r,n)=>r+Number(e.run(n.id).changes),0)}}function l(o,t,e){const r=new Set(e.map(i=>i.to)),n=new Set;try{for(const i of o.prepare("SELECT nodes FROM orchestrations").all())for(const s of h(i.nodes))s.webhookToken&&n.add(s.webhookToken)}catch{}return t.map(i=>{if(i.kind!=="webhook"||i.webhookToken||r.has(i.id))return i;let s=d();for(;n.has(s);)s=d();return n.add(s),{...i,webhookToken:s}})}export class OrchestrationRunRepository{db;constructor(t){this.db=t}insert(t){const e=new Date().toISOString(),r=this.db.prepare(`INSERT INTO orchestration_runs
5
+ WHERE id = ?`).run(t.name??n.name,t.projectId??n.projectId,t.startText??n.startText,JSON.stringify(r),JSON.stringify(t.edges??n.edges),t.enabled??n.enabled?1:0,t.cron===void 0?n.cron:t.cron,new Date().toISOString(),e),this.getById(e)}setCronFired(e,t){this.db.prepare("UPDATE orchestrations SET last_cron_at = ? WHERE id = ?").run(t,e)}rotateNodeToken(e,t){const n=this.getById(e);if(!n||!n.nodes.find(a=>a.id===t&&a.kind==="webhook"))return null;const o=this.allTokens();let i=u();for(;o.has(i);)i=u();const d=n.nodes.map(a=>a.id===t?{...a,webhookToken:i}:a);return this.db.prepare("UPDATE orchestrations SET nodes = ?, updated_at = ? WHERE id = ?").run(JSON.stringify(d),new Date().toISOString(),e),i}allTokens(){const e=new Set;for(const t of this.list())for(const n of t.nodes)n.webhookToken&&e.add(n.webhookToken);return e}deleteById(e){return Number(this.db.prepare("DELETE FROM orchestrations WHERE id = ?").run(e).changes)===1}deleteMentioningSession(e){const t=this.list().filter(n=>n.nodes.some(r=>r.kind==="session"&&r.id===e));return this.deleteAll(t)}deleteByProject(e){return this.deleteAll(this.listByProject(e))}deleteAll(e){const t=this.db.prepare("DELETE FROM orchestrations WHERE id = ?");return e.reduce((n,r)=>n+Number(t.run(r.id).changes),0)}}function p(s,e,t){const n=new Set(t.map(o=>o.to)),r=new Set;try{for(const o of s.prepare("SELECT nodes FROM orchestrations").all())for(const i of l(o.nodes))i.webhookToken&&r.add(i.webhookToken)}catch{}return e.map(o=>{if(o.kind!=="webhook"||o.webhookToken||n.has(o.id))return o;let i=u();for(;r.has(i);)i=u();return r.add(i),{...o,webhookToken:i}})}export class OrchestrationRunRepository{db;constructor(e){this.db=e}insert(e){const t=new Date().toISOString(),n=this.db.prepare(`INSERT INTO orchestration_runs
6
6
  (orchestration_id, orchestration_name, project_id, trigger, status, deliveries, state, created_at, updated_at)
7
- VALUES (?, ?, ?, ?, 'running', 0, ?, ?, ?)`).run(t.orchestrationId,t.orchestrationName,t.projectId,t.trigger,JSON.stringify(p()),e,e);return this.getById(Number(r.lastInsertRowid))}getById(t){const e=this.db.prepare("SELECT * FROM orchestration_runs WHERE id = ?").get(t);return e?c(e):void 0}listRunning(){return this.db.prepare("SELECT * FROM orchestration_runs WHERE status = 'running' ORDER BY id").all().map(c)}query(t){const e=Math.min(Math.max(t.limit??30,1),200),r=[],n=[];t.orchestrationId!=null&&(r.push("orchestration_id = ?"),n.push(t.orchestrationId)),t.projectId!=null&&(r.push("project_id = ?"),n.push(t.projectId)),t.status&&(r.push("status = ?"),n.push(t.status)),t.text&&(r.push("orchestration_name LIKE ?"),n.push(`%${t.text}%`)),t.before!=null&&(r.push("id < ?"),n.push(t.before));const i=r.length>0?`WHERE ${r.join(" AND ")}`:"",s=this.db.prepare(`SELECT * FROM orchestration_runs ${i} ORDER BY id DESC LIMIT ?`).all(...n,e+1).map(c),a=s.slice(0,e);return{runs:a,nextBefore:s.length>e?a[a.length-1].id:null}}updateState(t,e,r){return Number(this.db.prepare(`UPDATE orchestration_runs SET state = ?, deliveries = ?, updated_at = ?
8
- WHERE id = ? AND status = 'running'`).run(JSON.stringify(e),r,new Date().toISOString(),t).changes)===1}finish(t,e,r=null,n){const i=new Date().toISOString();return Number(this.db.prepare(`UPDATE orchestration_runs
7
+ VALUES (?, ?, ?, ?, 'running', 0, ?, ?, ?)`).run(e.orchestrationId,e.orchestrationName,e.projectId,e.trigger,JSON.stringify(g()),t,t);return this.getById(Number(n.lastInsertRowid))}getById(e){const t=this.db.prepare("SELECT * FROM orchestration_runs WHERE id = ?").get(e);return t?h(t):void 0}listRunning(){return this.db.prepare("SELECT * FROM orchestration_runs WHERE status = 'running' ORDER BY id").all().map(h)}query(e){const t=Math.min(Math.max(e.limit??30,1),200),n=[],r=[];e.orchestrationId!=null&&(n.push("orchestration_id = ?"),r.push(e.orchestrationId)),e.projectId!=null&&(n.push("project_id = ?"),r.push(e.projectId)),e.status&&(n.push("status = ?"),r.push(e.status)),e.text&&(n.push("orchestration_name LIKE ?"),r.push(`%${e.text}%`)),e.before!=null&&(n.push("id < ?"),r.push(e.before));const o=n.length>0?`WHERE ${n.join(" AND ")}`:"",i=this.db.prepare(`SELECT * FROM orchestration_runs ${o} ORDER BY id DESC LIMIT ?`).all(...r,t+1).map(h),d=i.slice(0,t);return{runs:d,nextBefore:i.length>t?d[d.length-1].id:null}}updateState(e,t,n){return Number(this.db.prepare(`UPDATE orchestration_runs SET state = ?, deliveries = ?, updated_at = ?
8
+ WHERE id = ? AND status = 'running'`).run(JSON.stringify(t),n,new Date().toISOString(),e).changes)===1}finish(e,t,n=null,r){const o=new Date().toISOString();return Number(this.db.prepare(`UPDATE orchestration_runs
9
9
  SET status = ?, error = ?, state = COALESCE(?, state), finished_at = ?, updated_at = ?
10
- WHERE id = ? AND status = 'running'`).run(e,r,n?JSON.stringify(n):null,i,i,t).changes)===1}prune(t=new Date){const e=new Date(t.getTime()-ORCH_RUN_RETENTION_DAYS*864e5).toISOString(),r=Number(this.db.prepare("DELETE FROM orchestration_runs WHERE status <> 'running' AND created_at < ?").run(e).changes),n=Number(this.db.prepare(`DELETE FROM orchestration_runs
10
+ WHERE id = ? AND status = 'running'`).run(t,n,r?JSON.stringify(r):null,o,o,e).changes)===1}prune(e=new Date){const t=new Date(e.getTime()-ORCH_RUN_RETENTION_DAYS*864e5).toISOString(),n=Number(this.db.prepare("DELETE FROM orchestration_runs WHERE status <> 'running' AND created_at < ?").run(t).changes),r=Number(this.db.prepare(`DELETE FROM orchestration_runs
11
11
  WHERE status <> 'running' AND id IN (
12
12
  SELECT id FROM (
13
13
  SELECT id, ROW_NUMBER() OVER (PARTITION BY orchestration_id ORDER BY id DESC) AS rn
14
14
  FROM orchestration_runs
15
15
  ) WHERE rn > ?
16
- )`).run(ORCH_RUN_KEEP_PER_ORCH).changes);return r+n}clear(t,e){const r=[],n=[];t==="finished"&&r.push("status <> 'running'"),e!=null&&(r.push("project_id = ?"),n.push(e));const i=r.length>0?`WHERE ${r.join(" AND ")}`:"";return Number(this.db.prepare(`DELETE FROM orchestration_runs ${i}`).run(...n).changes)}}function u(o){return{id:Number(o.id),name:String(o.name),projectId:Number(o.project_id),startText:String(o.start_text??""),nodes:h(o.nodes),edges:g(o.edges,[]),enabled:Number(o.enabled??1)!==0,cron:o.cron==null?null:String(o.cron),lastCronAt:o.last_cron_at==null?null:String(o.last_cron_at),createdAt:String(o.created_at),updatedAt:String(o.updated_at)}}function c(o){const t=g(o.state,p());return{id:Number(o.id),orchestrationId:Number(o.orchestration_id),orchestrationName:String(o.orchestration_name),projectId:Number(o.project_id),trigger:String(o.trigger),status:String(o.status),deliveries:Number(o.deliveries),state:{pending:t.pending??{},events:t.events??[]},error:o.error==null?null:String(o.error),createdAt:String(o.created_at),finishedAt:o.finished_at==null?null:String(o.finished_at),updatedAt:String(o.updated_at)}}function g(o,t){try{return JSON.parse(String(o))}catch{return t}}
16
+ )`).run(ORCH_RUN_KEEP_PER_ORCH).changes);return n+r}clear(e,t){const n=[],r=[];e==="finished"&&n.push("status <> 'running'"),t!=null&&(n.push("project_id = ?"),r.push(t));const o=n.length>0?`WHERE ${n.join(" AND ")}`:"";return Number(this.db.prepare(`DELETE FROM orchestration_runs ${o}`).run(...r).changes)}}function c(s){return{id:Number(s.id),name:String(s.name),projectId:Number(s.project_id),startText:String(s.start_text??""),nodes:l(s.nodes),edges:E(s.edges,[]),enabled:Number(s.enabled??1)!==0,cron:s.cron==null?null:String(s.cron),lastCronAt:s.last_cron_at==null?null:String(s.last_cron_at),createdAt:String(s.created_at),updatedAt:String(s.updated_at)}}function h(s){const e=E(s.state,g());return{id:Number(s.id),orchestrationId:Number(s.orchestration_id),orchestrationName:String(s.orchestration_name),projectId:Number(s.project_id),trigger:String(s.trigger),status:String(s.status),deliveries:Number(s.deliveries),state:{pending:e.pending??{},events:e.events??[]},error:s.error==null?null:String(s.error),createdAt:String(s.created_at),finishedAt:s.finished_at==null?null:String(s.finished_at),updatedAt:String(s.updated_at)}}function E(s,e){try{return JSON.parse(String(s))}catch{return e}}
@@ -1 +1 @@
1
- export class PluginStateRepository{db;constructor(t){this.db=t}get(t){const e=this.db.prepare("SELECT * FROM plugin_states WHERE id = ?").get(t);if(e)return{id:String(e.id),enabled:Number(e.enabled)===1,config:JSON.parse(String(e.config??"{}")),updatedAt:String(e.updated_at)}}list(){return this.db.prepare("SELECT * FROM plugin_states ORDER BY id ASC").all().map(t=>({id:String(t.id),enabled:Number(t.enabled)===1,config:JSON.parse(String(t.config??"{}")),updatedAt:String(t.updated_at)}))}setEnabled(t,e){this.upsert(t,{enabled:e})}setConfig(t,e){this.upsert(t,{config:e})}remove(t){this.db.prepare("DELETE FROM plugin_states WHERE id = ?").run(t)}upsert(t,e){const i=this.get(t),n=new Date().toISOString(),r=e.enabled??i?.enabled??!0,d=e.config??i?.config??{};i?this.db.prepare("UPDATE plugin_states SET enabled = ?, config = ?, updated_at = ? WHERE id = ?").run(r?1:0,JSON.stringify(d),n,t):this.db.prepare("INSERT INTO plugin_states (id, enabled, config, updated_at) VALUES (?, ?, ?, ?)").run(t,r?1:0,JSON.stringify(d),n)}}
1
+ export class PluginStateRepository{db;constructor(t){this.db=t}get(t){const e=this.db.prepare("SELECT * FROM plugin_states WHERE id = ?").get(t);if(e)return{id:String(e.id),enabled:Number(e.enabled)===1,config:JSON.parse(String(e.config??"{}")),updatedAt:String(e.updated_at)}}list(){return this.db.prepare("SELECT * FROM plugin_states ORDER BY id ASC").all().map(e=>({id:String(e.id),enabled:Number(e.enabled)===1,config:JSON.parse(String(e.config??"{}")),updatedAt:String(e.updated_at)}))}setEnabled(t,e){this.upsert(t,{enabled:e})}setConfig(t,e){this.upsert(t,{config:e})}remove(t){this.db.prepare("DELETE FROM plugin_states WHERE id = ?").run(t)}upsert(t,e){const n=this.get(t),i=new Date().toISOString(),s=e.enabled??n?.enabled??!0,r=e.config??n?.config??{};n?this.db.prepare("UPDATE plugin_states SET enabled = ?, config = ?, updated_at = ? WHERE id = ?").run(s?1:0,JSON.stringify(r),i,t):this.db.prepare("INSERT INTO plugin_states (id, enabled, config, updated_at) VALUES (?, ?, ?, ?)").run(t,s?1:0,JSON.stringify(r),i)}}
@@ -1,3 +1,3 @@
1
- import{resolve as o}from"node:path";export function projectKey(r){return o(r)}export class ProjectRepository{db;constructor(t){this.db=t}register(t){const e=new Date().toISOString(),s=projectKey(t.path);return this.db.prepare(`INSERT INTO projects (path, name, token, source, registered_at, last_seen_at)
1
+ import{resolve as o}from"node:path";export function projectKey(r){return o(r)}export class ProjectRepository{db;constructor(e){this.db=e}register(e){const t=new Date().toISOString(),s=projectKey(e.path);return this.db.prepare(`INSERT INTO projects (path, name, token, source, registered_at, last_seen_at)
2
2
  VALUES (?, ?, ?, ?, ?, ?)
3
- ON CONFLICT(path) DO UPDATE SET last_seen_at = excluded.last_seen_at`).run(s,t.name,t.token,t.source,e,e),this.getByPath(s)}getByPath(t){const e=this.db.prepare("SELECT * FROM projects WHERE path = ?").get(projectKey(t));return e?a(e):void 0}getByToken(t){const e=this.db.prepare("SELECT * FROM projects WHERE token = ?").get(t);return e?a(e):void 0}getById(t){const e=this.db.prepare("SELECT * FROM projects WHERE id = ?").get(t);return e?a(e):void 0}list(){return this.db.prepare("SELECT * FROM projects WHERE archived_at IS NULL ORDER BY sort_order IS NULL, sort_order ASC, registered_at DESC").all().map(t=>a(t))}listArchived(){return this.db.prepare("SELECT * FROM projects WHERE archived_at IS NOT NULL ORDER BY archived_at DESC").all().map(t=>a(t))}setOrder(t){this.db.exec("BEGIN");try{this.db.exec("UPDATE projects SET sort_order = NULL");const e=this.db.prepare("UPDATE projects SET sort_order = ? WHERE id = ?");t.forEach((s,n)=>{e.run(n,s)}),this.db.exec("COMMIT")}catch(e){throw this.db.exec("ROLLBACK"),e}}touch(t){this.db.prepare("UPDATE projects SET last_seen_at = ? WHERE id = ?").run(new Date().toISOString(),t)}remove(t){this.db.prepare("DELETE FROM projects WHERE id = ?").run(t)}setArchived(t,e){return(e?this.db.prepare("UPDATE projects SET archived_at = ?, sort_order = NULL WHERE id = ?").run(new Date().toISOString(),t):this.db.prepare("UPDATE projects SET archived_at = NULL WHERE id = ?").run(t)).changes>0}getMeta(t){const e=this.db.prepare("SELECT meta FROM projects WHERE id = ?").get(t);if(!e||e.meta==null)return null;try{const s=JSON.parse(String(e.meta));return s&&typeof s=="object"&&!Array.isArray(s)?s:null}catch{return null}}setMeta(t,e){const s={...this.getMeta(t)??{},...e};this.db.prepare("UPDATE projects SET meta = ? WHERE id = ?").run(JSON.stringify(s),t)}}function a(r){return{id:Number(r.id),path:String(r.path),name:String(r.name),token:String(r.token),source:r.source,registeredAt:String(r.registered_at),lastSeenAt:r.last_seen_at==null?null:String(r.last_seen_at),meta:r.meta==null?null:String(r.meta),sortOrder:r.sort_order==null?null:Number(r.sort_order),archivedAt:r.archived_at==null?null:String(r.archived_at)}}
3
+ ON CONFLICT(path) DO UPDATE SET last_seen_at = excluded.last_seen_at`).run(s,e.name,e.token,e.source,t,t),this.getByPath(s)}getByPath(e){const t=this.db.prepare("SELECT * FROM projects WHERE path = ?").get(projectKey(e));return t?n(t):void 0}getByToken(e){const t=this.db.prepare("SELECT * FROM projects WHERE token = ?").get(e);return t?n(t):void 0}getById(e){const t=this.db.prepare("SELECT * FROM projects WHERE id = ?").get(e);return t?n(t):void 0}list(){return this.db.prepare("SELECT * FROM projects WHERE archived_at IS NULL ORDER BY sort_order IS NULL, sort_order ASC, registered_at DESC").all().map(e=>n(e))}listArchived(){return this.db.prepare("SELECT * FROM projects WHERE archived_at IS NOT NULL ORDER BY archived_at DESC").all().map(e=>n(e))}setOrder(e){this.db.exec("BEGIN");try{this.db.exec("UPDATE projects SET sort_order = NULL");const t=this.db.prepare("UPDATE projects SET sort_order = ? WHERE id = ?");e.forEach((s,a)=>{t.run(a,s)}),this.db.exec("COMMIT")}catch(t){throw this.db.exec("ROLLBACK"),t}}touch(e){this.db.prepare("UPDATE projects SET last_seen_at = ? WHERE id = ?").run(new Date().toISOString(),e)}remove(e){this.db.prepare("DELETE FROM projects WHERE id = ?").run(e)}setArchived(e,t){return(t?this.db.prepare("UPDATE projects SET archived_at = ?, sort_order = NULL WHERE id = ?").run(new Date().toISOString(),e):this.db.prepare("UPDATE projects SET archived_at = NULL WHERE id = ?").run(e)).changes>0}getMeta(e){const t=this.db.prepare("SELECT meta FROM projects WHERE id = ?").get(e);if(!t||t.meta==null)return null;try{const s=JSON.parse(String(t.meta));return s&&typeof s=="object"&&!Array.isArray(s)?s:null}catch{return null}}setMeta(e,t){const s={...this.getMeta(e)??{},...t};this.db.prepare("UPDATE projects SET meta = ? WHERE id = ?").run(JSON.stringify(s),e)}}function n(r){return{id:Number(r.id),path:String(r.path),name:String(r.name),token:String(r.token),source:r.source,registeredAt:String(r.registered_at),lastSeenAt:r.last_seen_at==null?null:String(r.last_seen_at),meta:r.meta==null?null:String(r.meta),sortOrder:r.sort_order==null?null:Number(r.sort_order),archivedAt:r.archived_at==null?null:String(r.archived_at)}}
@@ -1,4 +1,4 @@
1
- export class PushSubscriptionRepository{db;constructor(t){this.db=t}upsert(t){return this.db.prepare(`INSERT INTO push_subscriptions (endpoint, p256dh, auth, user_agent, created_at)
1
+ export class PushSubscriptionRepository{db;constructor(e){this.db=e}upsert(e){return this.db.prepare(`INSERT INTO push_subscriptions (endpoint, p256dh, auth, user_agent, created_at)
2
2
  VALUES (?, ?, ?, ?, ?)
3
3
  ON CONFLICT(endpoint) DO UPDATE SET p256dh = excluded.p256dh, auth = excluded.auth,
4
- user_agent = excluded.user_agent`).run(t.endpoint,t.p256dh,t.auth,t.userAgent??null,new Date().toISOString()),this.getById(t.endpoint)}getById(t){const n=this.db.prepare("SELECT * FROM push_subscriptions WHERE endpoint = ?").get(t);return n?r(n):void 0}list(){return this.db.prepare("SELECT * FROM push_subscriptions ORDER BY created_at, endpoint").all().map(r)}deleteByEndpoint(t){return Number(this.db.prepare("DELETE FROM push_subscriptions WHERE endpoint = ?").run(t).changes)===1}}function r(e){return{endpoint:String(e.endpoint),p256dh:String(e.p256dh),auth:String(e.auth),userAgent:e.user_agent==null?null:String(e.user_agent),createdAt:String(e.created_at)}}
4
+ user_agent = excluded.user_agent`).run(e.endpoint,e.p256dh,e.auth,e.userAgent??null,new Date().toISOString()),this.getById(e.endpoint)}getById(e){const n=this.db.prepare("SELECT * FROM push_subscriptions WHERE endpoint = ?").get(e);return n?r(n):void 0}list(){return this.db.prepare("SELECT * FROM push_subscriptions ORDER BY created_at, endpoint").all().map(r)}deleteByEndpoint(e){return Number(this.db.prepare("DELETE FROM push_subscriptions WHERE endpoint = ?").run(e).changes)===1}}function r(t){return{endpoint:String(t.endpoint),p256dh:String(t.p256dh),auth:String(t.auth),userAgent:t.user_agent==null?null:String(t.user_agent),createdAt:String(t.created_at)}}
@@ -1,5 +1,5 @@
1
- export const WATCH_ON_VALUES=["idle","turnEnd","messageFailed"],DEFAULT_WATCH_ON=["idle"];export class SessionWatchRepository{db;constructor(e){this.db=e}insert(e){const t=this.db.prepare(`INSERT INTO session_watches (watcher_session_id, target_session_id, notify, on_events, remaining, created_at)
2
- VALUES (?, ?, ?, ?, ?, ?)`).run(e.watcherSessionId,e.targetSessionId,e.notify,JSON.stringify(e.onEvents?.length?e.onEvents:DEFAULT_WATCH_ON),e.times===void 0?1:e.times,new Date().toISOString());return this.getById(Number(t.lastInsertRowid))}getById(e){const t=this.db.prepare("SELECT * FROM session_watches WHERE id = ?").get(e);return t?n(t):void 0}listPendingByTarget(e){return this.db.prepare("SELECT * FROM session_watches WHERE target_session_id = ? AND fired_at IS NULL").all(e).map(n)}listPending(){return this.db.prepare("SELECT * FROM session_watches WHERE fired_at IS NULL ORDER BY id").all().map(n)}consumeHit(e){if(Number(this.db.prepare(`UPDATE session_watches SET remaining = remaining - 1
3
- WHERE id = ? AND fired_at IS NULL AND remaining > 0`).run(e).changes)===1)return this.db.prepare("UPDATE session_watches SET fired_at = ? WHERE id = ? AND remaining = 0 AND fired_at IS NULL").run(new Date().toISOString(),e),this.getById(e)??null;const t=this.getById(e);return t&&t.remaining===null&&t.firedAt===null?t:null}updateById(e,t){const i=this.getById(e);if(!(!i||i.firedAt!==null))return this.db.prepare("UPDATE session_watches SET on_events = ?, remaining = ? WHERE id = ? AND fired_at IS NULL").run(JSON.stringify(t.onEvents??i.onEvents),t.remaining,e),this.getById(e)}deleteById(e){return Number(this.db.prepare("DELETE FROM session_watches WHERE id = ?").run(e).changes)===1}deleteBySession(e){return Number(this.db.prepare("DELETE FROM session_watches WHERE target_session_id = ? OR watcher_session_id = ?").run(e,e).changes)}deleteByProject(e){return Number(this.db.prepare(`DELETE FROM session_watches
1
+ export const WATCH_ON_VALUES=["idle","turnEnd","messageFailed"],DEFAULT_WATCH_ON=["idle"];export class SessionWatchRepository{db;constructor(e){this.db=e}insert(e){const s=this.db.prepare(`INSERT INTO session_watches (watcher_session_id, target_session_id, notify, on_events, remaining, created_at)
2
+ VALUES (?, ?, ?, ?, ?, ?)`).run(e.watcherSessionId,e.targetSessionId,e.notify,JSON.stringify(e.onEvents?.length?e.onEvents:DEFAULT_WATCH_ON),e.times===void 0?1:e.times,new Date().toISOString());return this.getById(Number(s.lastInsertRowid))}getById(e){const s=this.db.prepare("SELECT * FROM session_watches WHERE id = ?").get(e);return s?i(s):void 0}listPendingByTarget(e){return this.db.prepare("SELECT * FROM session_watches WHERE target_session_id = ? AND fired_at IS NULL").all(e).map(i)}listPending(){return this.db.prepare("SELECT * FROM session_watches WHERE fired_at IS NULL ORDER BY id").all().map(i)}consumeHit(e){if(Number(this.db.prepare(`UPDATE session_watches SET remaining = remaining - 1
3
+ WHERE id = ? AND fired_at IS NULL AND remaining > 0`).run(e).changes)===1)return this.db.prepare("UPDATE session_watches SET fired_at = ? WHERE id = ? AND remaining = 0 AND fired_at IS NULL").run(new Date().toISOString(),e),this.getById(e)??null;const t=this.getById(e);return t&&t.remaining===null&&t.firedAt===null?t:null}updateById(e,s){const t=this.getById(e);if(!(!t||t.firedAt!==null))return this.db.prepare("UPDATE session_watches SET on_events = ?, remaining = ? WHERE id = ? AND fired_at IS NULL").run(JSON.stringify(s.onEvents??t.onEvents),s.remaining,e),this.getById(e)}deleteById(e){return Number(this.db.prepare("DELETE FROM session_watches WHERE id = ?").run(e).changes)===1}deleteBySession(e){return Number(this.db.prepare("DELETE FROM session_watches WHERE target_session_id = ? OR watcher_session_id = ?").run(e,e).changes)}deleteByProject(e){return Number(this.db.prepare(`DELETE FROM session_watches
4
4
  WHERE target_session_id IN (SELECT session_id FROM sessions WHERE project_id = ?)
5
- OR watcher_session_id IN (SELECT session_id FROM sessions WHERE project_id = ?)`).run(e,e).changes)}}function n(s){return{id:Number(s.id),watcherSessionId:s.watcher_session_id==null?null:String(s.watcher_session_id),targetSessionId:String(s.target_session_id),onEvents:parseOn(s.on_events),remaining:s.remaining==null?null:Number(s.remaining),notify:s.notify==null?null:String(s.notify),firedAt:s.fired_at==null?null:String(s.fired_at),createdAt:String(s.created_at)}}export function parseOn(s){if(typeof s!="string"||!s)return[...DEFAULT_WATCH_ON];try{const e=JSON.parse(s);if(!Array.isArray(e))return[...DEFAULT_WATCH_ON];const t=e.filter(i=>WATCH_ON_VALUES.includes(i));return t.length?t:[...DEFAULT_WATCH_ON]}catch{return[...DEFAULT_WATCH_ON]}}
5
+ OR watcher_session_id IN (SELECT session_id FROM sessions WHERE project_id = ?)`).run(e,e).changes)}}function i(n){return{id:Number(n.id),watcherSessionId:n.watcher_session_id==null?null:String(n.watcher_session_id),targetSessionId:String(n.target_session_id),onEvents:parseOn(n.on_events),remaining:n.remaining==null?null:Number(n.remaining),notify:n.notify==null?null:String(n.notify),firedAt:n.fired_at==null?null:String(n.fired_at),createdAt:String(n.created_at)}}export function parseOn(n){if(typeof n!="string"||!n)return[...DEFAULT_WATCH_ON];try{const e=JSON.parse(n);if(!Array.isArray(e))return[...DEFAULT_WATCH_ON];const s=e.filter(t=>WATCH_ON_VALUES.includes(t));return s.length?s:[...DEFAULT_WATCH_ON]}catch{return[...DEFAULT_WATCH_ON]}}
@@ -1,7 +1,7 @@
1
- import{HARNESS_COMPACTION as O,HARNESS_LIFECYCLE as u,HARNESS_TOOL_EVENTS as h,isHarness as p}from"@weavecode/core";import{readDaemonSettingsSync as A,DEFAULT_SESSION_IDLE_DAYS as L}from"../daemon/settings.js";export const PROMPTLESS_GRACE_MS=60*6e4;function N(){return(A().sessions?.idleDays??L)*864e5}function S(i){const e=new Set;for(const n of Object.values(u)){for(const o of n.close)e.add(o);for(const o of n.sessionMarkers)e.add(o);n.sessionExit&&e.add(n.sessionExit)}const s=[...e].map(n=>`'${n}'`).join(","),t=Object.values(O).filter(n=>n.end&&n.endSource).map(n=>`(${i}.event_type = '${n.end}' AND COALESCE(json_extract(${i}.payload, '$.raw.source'), '') = '${n.endSource}')`).join(" OR ");return`${i}.event_type IN (${s})${t?` AND NOT (${t})`:""}`}function R(i){const e=new Set;for(const t of Object.values(h))for(const n of t)e.add(n);const s=[...e].map(t=>`'${t}'`).join(",");return`${i}.event_type IN (${s})`}export class SessionRepository{db;constructor(e){this.db=e}touch(e,s,t){const n=t??new Date().toISOString();return this.db.prepare(`INSERT INTO sessions (session_id, project_id, last_seen_at, created_at)
1
+ import{HARNESS_COMPACTION as h,HARNESS_LIFECYCLE as d,HARNESS_TOOL_EVENTS as O,isHarness as p}from"@weavecode/core";import{readDaemonSettingsSync as A,DEFAULT_SESSION_IDLE_DAYS as L}from"../daemon/settings.js";export const PROMPTLESS_GRACE_MS=60*6e4;function N(){return(A().sessions?.idleDays??L)*864e5}function S(i){const e=new Set;for(const n of Object.values(d)){for(const o of n.close)e.add(o);for(const o of n.sessionMarkers)e.add(o);n.sessionExit&&e.add(n.sessionExit)}const s=[...e].map(n=>`'${n}'`).join(","),t=Object.values(h).filter(n=>n.end&&n.endSource).map(n=>`(${i}.event_type = '${n.end}' AND COALESCE(json_extract(${i}.payload, '$.raw.source'), '') = '${n.endSource}')`).join(" OR ");return`${i}.event_type IN (${s})${t?` AND NOT (${t})`:""}`}function c(i){const e=new Set;for(const t of Object.values(O))for(const n of t)e.add(n);const s=[...e].map(t=>`'${t}'`).join(",");return`${i}.event_type IN (${s})`}export class SessionRepository{db;constructor(e){this.db=e}touch(e,s,t){const n=t??new Date().toISOString();return this.db.prepare(`INSERT INTO sessions (session_id, project_id, last_seen_at, created_at)
2
2
  VALUES (?, ?, ?, ?)
3
3
  ON CONFLICT(session_id) DO UPDATE SET
4
4
  last_seen_at = MAX(sessions.last_seen_at, excluded.last_seen_at),
5
- project_id = COALESCE(sessions.project_id, excluded.project_id)`).run(e,s??null,n,n),this.getBySessionId(e)}getBySessionId(e){const s=this.db.prepare("SELECT * FROM sessions WHERE session_id = ?").get(e);return s?_(s):void 0}countAll(){return Number(this.db.prepare("SELECT COUNT(*) AS n FROM sessions").get().n)}list(e){return(e===void 0?this.db.prepare("SELECT * FROM sessions ORDER BY created_at DESC LIMIT 200").all():this.db.prepare("SELECT * FROM sessions WHERE project_id = ? ORDER BY created_at DESC LIMIT 200").all(e)).map(_)}searchByTitle(e,s){const t=`%${e.replace(/[\\%_]/g,n=>`\\${n}`)}%`;return this.db.prepare("SELECT * FROM sessions WHERE title LIKE ? ESCAPE '\\' ORDER BY last_seen_at DESC LIMIT ?").all(t,s).map(_)}listWithCounts(e,s){const t=`SELECT s.*, (SELECT COUNT(*) FROM hook_events e WHERE e.session_id = s.session_id) AS event_count, (SELECT e2.source FROM hook_events e2 WHERE e2.session_id = s.session_id ORDER BY e2.id DESC LIMIT 1) AS harness, (SELECT e5.event_type FROM hook_events e5 WHERE e5.session_id = s.session_id ORDER BY e5.id DESC LIMIT 1) AS last_event_type, (SELECT MAX(e3.id) FROM hook_events e3 WHERE e3.session_id = s.session_id AND e3.event_type = 'UserPromptSubmit') AS last_ups, (SELECT MAX(e6.id) FROM hook_events e6 WHERE e6.session_id = s.session_id AND ${S("e6")}) AS last_close, (SELECT MAX(e7.id) FROM hook_events e7 WHERE e7.session_id = s.session_id AND ${R("e7")}) AS last_tool, (SELECT MAX(e4.id) FROM hook_events e4 WHERE e4.session_id = s.session_id AND e4.event_type IN ('Stop', 'StopFailure', 'SessionEnd')) AS last_stop FROM sessions s`,n=[],o=[];return e!==void 0&&(n.push("s.project_id = ?"),o.push(e)),s&&s.length>0&&(n.push(`s.session_id IN (${s.map(()=>"?").join(",")})`),o.push(...s)),this.db.prepare(`${t}${n.length>0?` WHERE ${n.join(" AND ")}`:""} ORDER BY s.created_at DESC LIMIT 200`).all(...o).map(r=>{const d=r.harness,l=r.last_ups,E=r.last_close,a=r.last_tool,c=r.last_stop,T=r.last_event_type;return{..._(r),eventCount:Number(r.event_count??0),harness:p(d)?d:null,turnOpen:l!=null&&(E==null||Number(l)>Number(E))||a!=null&&(E==null||Number(a)>Number(E)),lastEventType:T??null,hasRun:l!=null||c!=null,autoDeleteAt:new Date(Date.parse(String(r.last_seen_at))+(l==null?PROMPTLESS_GRACE_MS:N())).toISOString(),promptless:l==null}})}turnOpenOf(e){const s=this.db.prepare(`SELECT (SELECT MAX(e3.id) FROM hook_events e3 WHERE e3.session_id = ? AND e3.event_type = 'UserPromptSubmit') AS last_ups, (SELECT MAX(e6.id) FROM hook_events e6 WHERE e6.session_id = ? AND ${S("e6")}) AS last_close, (SELECT MAX(e7.id) FROM hook_events e7 WHERE e7.session_id = ? AND ${R("e7")}) AS last_tool`).get(e,e,e);if(!this.getBySessionId(e))return null;const t=s?.last_ups??null,n=s?.last_close??null,o=s?.last_tool??null;return t!=null&&(n==null||Number(t)>Number(n))||o!=null&&(n==null||Number(o)>Number(n))}hasRunOf(e){const s=this.db.prepare("SELECT EXISTS(SELECT 1 FROM hook_events e WHERE e.session_id = ? AND e.event_type IN ('UserPromptSubmit','Stop','StopFailure','SessionEnd')) AS hit").get(e);return Number(s?.hit??0)>0}lastMainEventAtOf(e){const s=[...new Set(Object.values(u).map(n=>n.subagentStop))].map(n=>`'${n}'`).join(","),t=this.db.prepare(`SELECT created_at FROM hook_events
5
+ project_id = COALESCE(sessions.project_id, excluded.project_id)`).run(e,s??null,n,n),this.getBySessionId(e)}getBySessionId(e){const s=this.db.prepare("SELECT * FROM sessions WHERE session_id = ?").get(e);return s?_(s):void 0}countAll(){return Number(this.db.prepare("SELECT COUNT(*) AS n FROM sessions").get().n)}list(e){return(e===void 0?this.db.prepare("SELECT * FROM sessions ORDER BY created_at DESC LIMIT 200").all():this.db.prepare("SELECT * FROM sessions WHERE project_id = ? ORDER BY created_at DESC LIMIT 200").all(e)).map(_)}searchByTitle(e,s){const t=`%${e.replace(/[\\%_]/g,o=>`\\${o}`)}%`;return this.db.prepare("SELECT * FROM sessions WHERE title LIKE ? ESCAPE '\\' ORDER BY last_seen_at DESC LIMIT ?").all(t,s).map(_)}listWithCounts(e,s){const t=`SELECT s.*, (SELECT COUNT(*) FROM hook_events e WHERE e.session_id = s.session_id) AS event_count, (SELECT e2.source FROM hook_events e2 WHERE e2.session_id = s.session_id ORDER BY e2.id DESC LIMIT 1) AS harness, (SELECT e5.event_type FROM hook_events e5 WHERE e5.session_id = s.session_id ORDER BY e5.id DESC LIMIT 1) AS last_event_type, (SELECT MAX(e3.id) FROM hook_events e3 WHERE e3.session_id = s.session_id AND e3.event_type = 'UserPromptSubmit') AS last_ups, (SELECT MAX(e6.id) FROM hook_events e6 WHERE e6.session_id = s.session_id AND ${S("e6")}) AS last_close, (SELECT MAX(e7.id) FROM hook_events e7 WHERE e7.session_id = s.session_id AND ${c("e7")}) AS last_tool, (SELECT MAX(e4.id) FROM hook_events e4 WHERE e4.session_id = s.session_id AND e4.event_type IN ('Stop', 'StopFailure', 'SessionEnd')) AS last_stop FROM sessions s`,n=[],o=[];return e!==void 0&&(n.push("s.project_id = ?"),o.push(e)),s&&s.length>0&&(n.push(`s.session_id IN (${s.map(()=>"?").join(",")})`),o.push(...s)),this.db.prepare(`${t}${n.length>0?` WHERE ${n.join(" AND ")}`:""} ORDER BY s.created_at DESC LIMIT 200`).all(...o).map(r=>{const a=r.harness,l=r.last_ups,E=r.last_close,u=r.last_tool,R=r.last_stop,T=r.last_event_type;return{..._(r),eventCount:Number(r.event_count??0),harness:p(a)?a:null,turnOpen:l!=null&&(E==null||Number(l)>Number(E))||u!=null&&(E==null||Number(u)>Number(E)),lastEventType:T??null,hasRun:l!=null||R!=null,autoDeleteAt:new Date(Date.parse(String(r.last_seen_at))+(l==null?PROMPTLESS_GRACE_MS:N())).toISOString(),promptless:l==null}})}turnOpenOf(e){const s=this.db.prepare(`SELECT (SELECT MAX(e3.id) FROM hook_events e3 WHERE e3.session_id = ? AND e3.event_type = 'UserPromptSubmit') AS last_ups, (SELECT MAX(e6.id) FROM hook_events e6 WHERE e6.session_id = ? AND ${S("e6")}) AS last_close, (SELECT MAX(e7.id) FROM hook_events e7 WHERE e7.session_id = ? AND ${c("e7")}) AS last_tool`).get(e,e,e);if(!this.getBySessionId(e))return null;const t=s?.last_ups??null,n=s?.last_close??null,o=s?.last_tool??null;return t!=null&&(n==null||Number(t)>Number(n))||o!=null&&(n==null||Number(o)>Number(n))}hasRunOf(e){const s=this.db.prepare("SELECT EXISTS(SELECT 1 FROM hook_events e WHERE e.session_id = ? AND e.event_type IN ('UserPromptSubmit','Stop','StopFailure','SessionEnd')) AS hit").get(e);return Number(s?.hit??0)>0}lastMainEventAtOf(e){const s=[...new Set(Object.values(d).map(n=>n.subagentStop))].map(n=>`'${n}'`).join(","),t=this.db.prepare(`SELECT created_at FROM hook_events
6
6
  WHERE session_id = ? AND event_type NOT IN (${s})
7
7
  ORDER BY id DESC LIMIT 1`).get(e);return t?String(t.created_at):null}livenessRowOf(e){const s=this.db.prepare("SELECT s.session_id, s.last_seen_at, COUNT(e.id) AS event_count, (SELECT e2.source FROM hook_events e2 WHERE e2.session_id = s.session_id ORDER BY e2.id DESC LIMIT 1) AS harness, (SELECT e5.event_type FROM hook_events e5 WHERE e5.session_id = s.session_id ORDER BY e5.id DESC LIMIT 1) AS last_event_type FROM sessions s LEFT JOIN hook_events e ON e.session_id = s.session_id WHERE s.session_id = ? GROUP BY s.session_id").get(e);if(!s)return null;const t=s.harness;return{sessionId:String(s.session_id),harness:p(t)?t:null,lastSeenAt:String(s.last_seen_at),lastEventType:s.last_event_type==null?null:String(s.last_event_type),eventCount:Number(s.event_count??0)}}setPendingTitle(e,s){const t=this.getBySessionId(e);if(t)return t.pendingTitle===s?t:t.title===s?(t.pendingTitle!=null&&this.db.prepare("UPDATE sessions SET pending_title = NULL WHERE session_id = ?").run(e),this.getBySessionId(e)):(this.db.prepare("UPDATE sessions SET title = ?, pending_title = ? WHERE session_id = ?").run(s,s,e),this.getBySessionId(e))}applyReportedTitle(e,s){const t=this.getBySessionId(e);return t?t.pendingTitle!=null?s===t.pendingTitle?(this.db.prepare("UPDATE sessions SET title = ?, pending_title = NULL WHERE session_id = ?").run(s,e),t.title!==s):!1:s!=null&&s!==t.title?(this.db.prepare("UPDATE sessions SET title = ? WHERE session_id = ?").run(s,e),!0):!1:!1}confirmPendingTitle(e,s){return this.db.prepare("UPDATE sessions SET title = ?, pending_title = NULL WHERE session_id = ? AND pending_title = ?").run(s,e,s).changes>0}setTitle(e,s){return this.db.prepare("UPDATE sessions SET title = ?, pending_title = NULL WHERE session_id = ?").run(s,e),this.getBySessionId(e)}remove(e){this.db.prepare("DELETE FROM sessions WHERE session_id = ?").run(e)}removeByProject(e){return Number(this.db.prepare("DELETE FROM sessions WHERE project_id = ?").run(e).changes)}}function _(i){return{sessionId:String(i.session_id),projectId:i.project_id==null?null:Number(i.project_id),title:i.title==null?null:String(i.title),pendingTitle:i.pending_title==null?null:String(i.pending_title),lastSeenAt:String(i.last_seen_at),createdAt:String(i.created_at)}}
@@ -1,31 +1,31 @@
1
- import{createHash as m}from"node:crypto";import{createReadStream as y,mkdirSync as p,readFileSync as _,writeFileSync as S,existsSync as o,renameSync as N,rmSync as u,statSync as O}from"node:fs";import l from"node:path";import{getUploadsDir as b}from"../db/paths.js";export const UPLOAD_IMAGE_TYPES=["image/png","image/jpeg","image/gif","image/webp"],UPLOAD_MEDIA_TYPES=UPLOAD_IMAGE_TYPES;export function isImageMediaType(a){return UPLOAD_IMAGE_TYPES.includes(a)}export const UPLOAD_MAX_BYTES=10*1024*1024,UPLOAD_FILE_MAX_BYTES=512*1024*1024;export function maxUploadBytes(a){return isImageMediaType(a)?UPLOAD_MAX_BYTES:UPLOAD_FILE_MAX_BYTES}export const UPLOAD_CLEANUP_GRACE_MS=5*6e4,UPLOAD_ORPHAN_GRACE_MS=60*6e4;const T={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp"},I=48,C=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;function A(a){const e=(a.split(/[\\/]/).pop()??"").replace(/\.[A-Za-z0-9]{1,10}$/,"").replace(/[\u0000-\u001f<>:"|?*]/g,"-").replace(/\s+/g,"-").replace(/^[.-]+/,"").replace(/[.-]+$/,"").slice(0,I);return e?C.test(e)?`_${e}`:e:""}function f(a,e){if(isImageMediaType(a))return T[a];const i=/\.([A-Za-z0-9]{1,10})$/.exec(e);return i?`.${i[1].toLowerCase()}`:".bin"}export class UploadRepository{db;dir;constructor(e,i=b()){this.db=e,this.dir=i}get defaultDir(){return this.dir}save(e){const i=m("sha256").update(e.bytes).digest("hex"),t=this.getById(i);if(t){const n=this.pathOf(t);return o(n)||(p(this.dirOf(t),{recursive:!0}),S(this.filePath(t.id,t.mediaType,t.name,this.dirOf(t)),e.bytes)),t}const s=e.dir??this.dir;p(s,{recursive:!0});const r=this.filePath(i,e.mediaType,e.name,s);return o(r)||S(r,e.bytes),this.db.prepare(`INSERT INTO uploads (id, media_type, name, size, created_at, dir) VALUES (?, ?, ?, ?, ?, ?)
2
- ON CONFLICT(id) DO NOTHING`).run(i,e.mediaType,e.name,e.bytes.length,new Date().toISOString(),e.dir??null),this.getById(i)}async adoptFromFile(e){const i=m("sha256");await new Promise((E,h)=>{y(e.file).on("data",g=>i.update(g)).on("end",()=>E()).on("error",h)});const t=i.digest("hex"),s=O(e.file).size,r=this.getById(t);if(r){const E=this.pathOf(r);return o(E)?u(e.file,{force:!0}):(p(this.dirOf(r),{recursive:!0}),N(e.file,this.filePath(r.id,r.mediaType,r.name,this.dirOf(r)))),r}const n=e.dir??this.dir;p(n,{recursive:!0});const d=this.filePath(t,e.mediaType,e.name,n);return o(d)?u(e.file,{force:!0}):N(e.file,d),this.db.prepare(`INSERT INTO uploads (id, media_type, name, size, created_at, dir) VALUES (?, ?, ?, ?, ?, ?)
3
- ON CONFLICT(id) DO NOTHING`).run(t,e.mediaType,e.name,s,new Date().toISOString(),e.dir??null),this.getById(t)}getById(e){const i=this.db.prepare("SELECT * FROM uploads WHERE id = ?").get(e);return i?c(i):void 0}filePath(e,i,t,s=this.dir){const r=A(t),n=e.slice(0,16);return l.join(s,`${r?`${r}-${n}`:n}${f(i,t)}`)}pathOf(e){const i=this.filePath(e.id,e.mediaType,e.name,this.dirOf(e));if(o(i))return i;const t=l.join(this.dirOf(e),`${e.id}${f(e.mediaType,e.name)}`);return o(t)?t:i}dirOf(e){return e.dir??this.dir}refsOf(e){const i=[];for(const t of e){const s=this.getById(t);if(!s)return null;i.push({id:s.id,name:s.name,mediaType:s.mediaType,path:this.pathOf(s)})}return i}fileStatOf(e){const i=this.getById(e);if(!i)return;const t=this.pathOf(i);if(o(t))return{row:i,file:t,size:O(t).size}}fileOf(e){const i=this.getById(e);if(!i)return;const t=this.pathOf(i);if(o(t))return{row:i,bytes:_(t)}}linkToEvent(e,i){const t=this.db.prepare("INSERT INTO event_images (event_id, upload_id) VALUES (?, ?) ON CONFLICT DO NOTHING");for(const s of i)t.run(e,s)}pruneUnreferenced(e=UPLOAD_ORPHAN_GRACE_MS,i=Date.now()){const t=this.db.prepare(`SELECT id, media_type, name, dir FROM uploads
4
- WHERE created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images)`).all(new Date(i-e).toISOString()),s=this.db.prepare("DELETE FROM uploads WHERE id = ?");for(const r of t)u(this.pathOf({id:r.id,mediaType:r.media_type,name:r.name,dir:r.dir}),{force:!0}),s.run(r.id);return t.length}imagesBySession(e){const i=this.db.prepare(`SELECT e.event_id AS eventId, u.* FROM event_images e
1
+ import{createHash as m}from"node:crypto";import{createReadStream as y,mkdirSync as c,readFileSync as _,writeFileSync as f,existsSync as o,renameSync as S,rmSync as u,statSync as l}from"node:fs";import O from"node:path";import{getUploadsDir as b}from"../db/paths.js";export const UPLOAD_IMAGE_TYPES=["image/png","image/jpeg","image/gif","image/webp"],UPLOAD_MEDIA_TYPES=UPLOAD_IMAGE_TYPES;export function isImageMediaType(d){return UPLOAD_IMAGE_TYPES.includes(d)}export const UPLOAD_MAX_BYTES=10*1024*1024,UPLOAD_FILE_MAX_BYTES=512*1024*1024;export function maxUploadBytes(d){return isImageMediaType(d)?UPLOAD_MAX_BYTES:UPLOAD_FILE_MAX_BYTES}export const UPLOAD_CLEANUP_GRACE_MS=5*6e4,UPLOAD_ORPHAN_GRACE_MS=60*6e4;const T={"image/png":".png","image/jpeg":".jpg","image/gif":".gif","image/webp":".webp"},I=48,A=/^(con|prn|aux|nul|com[1-9]|lpt[1-9])$/i;function C(d){const t=(d.split(/[\\/]/).pop()??"").replace(/\.[A-Za-z0-9]{1,10}$/,"").replace(/[\u0000-\u001f<>:"|?*]/g,"-").replace(/\s+/g,"-").replace(/^[.-]+/,"").replace(/[.-]+$/,"").slice(0,I);return t?A.test(t)?`_${t}`:t:""}function N(d,e){if(isImageMediaType(d))return T[d];const t=/\.([A-Za-z0-9]{1,10})$/.exec(e);return t?`.${t[1].toLowerCase()}`:".bin"}export class UploadRepository{db;dir;constructor(e,t=b()){this.db=e,this.dir=t}get defaultDir(){return this.dir}save(e){const t=m("sha256").update(e.bytes).digest("hex"),i=this.getById(t);if(i){const n=this.pathOf(i);return o(n)||(c(this.dirOf(i),{recursive:!0}),f(this.filePath(i.id,i.mediaType,i.name,this.dirOf(i)),e.bytes)),i}const r=e.dir??this.dir;c(r,{recursive:!0});const s=this.filePath(t,e.mediaType,e.name,r);return o(s)||f(s,e.bytes),this.db.prepare(`INSERT INTO uploads (id, media_type, name, size, created_at, dir) VALUES (?, ?, ?, ?, ?, ?)
2
+ ON CONFLICT(id) DO NOTHING`).run(t,e.mediaType,e.name,e.bytes.length,new Date().toISOString(),e.dir??null),this.getById(t)}async adoptFromFile(e){const t=m("sha256");await new Promise((E,h)=>{y(e.file).on("data",g=>t.update(g)).on("end",()=>E()).on("error",h)});const i=t.digest("hex"),r=l(e.file).size,s=this.getById(i);if(s){const E=this.pathOf(s);return o(E)?u(e.file,{force:!0}):(c(this.dirOf(s),{recursive:!0}),S(e.file,this.filePath(s.id,s.mediaType,s.name,this.dirOf(s)))),s}const n=e.dir??this.dir;c(n,{recursive:!0});const a=this.filePath(i,e.mediaType,e.name,n);return o(a)?u(e.file,{force:!0}):S(e.file,a),this.db.prepare(`INSERT INTO uploads (id, media_type, name, size, created_at, dir) VALUES (?, ?, ?, ?, ?, ?)
3
+ ON CONFLICT(id) DO NOTHING`).run(i,e.mediaType,e.name,r,new Date().toISOString(),e.dir??null),this.getById(i)}getById(e){const t=this.db.prepare("SELECT * FROM uploads WHERE id = ?").get(e);return t?p(t):void 0}filePath(e,t,i,r=this.dir){const s=C(i),n=e.slice(0,16);return O.join(r,`${s?`${s}-${n}`:n}${N(t,i)}`)}pathOf(e){const t=this.filePath(e.id,e.mediaType,e.name,this.dirOf(e));if(o(t))return t;const i=O.join(this.dirOf(e),`${e.id}${N(e.mediaType,e.name)}`);return o(i)?i:t}dirOf(e){return e.dir??this.dir}refsOf(e){const t=[];for(const i of e){const r=this.getById(i);if(!r)return null;t.push({id:r.id,name:r.name,mediaType:r.mediaType,path:this.pathOf(r)})}return t}fileStatOf(e){const t=this.getById(e);if(!t)return;const i=this.pathOf(t);if(o(i))return{row:t,file:i,size:l(i).size}}fileOf(e){const t=this.getById(e);if(!t)return;const i=this.pathOf(t);if(o(i))return{row:t,bytes:_(i)}}linkToEvent(e,t){const i=this.db.prepare("INSERT INTO event_images (event_id, upload_id) VALUES (?, ?) ON CONFLICT DO NOTHING");for(const r of t)i.run(e,r)}pruneUnreferenced(e=UPLOAD_ORPHAN_GRACE_MS,t=Date.now()){const i=this.db.prepare(`SELECT id, media_type, name, dir FROM uploads
4
+ WHERE created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images)`).all(new Date(t-e).toISOString()),r=this.db.prepare("DELETE FROM uploads WHERE id = ?");for(const s of i)u(this.pathOf({id:s.id,mediaType:s.media_type,name:s.name,dir:s.dir}),{force:!0}),r.run(s.id);return i.length}imagesBySession(e){const t=this.db.prepare(`SELECT e.event_id AS eventId, u.* FROM event_images e
5
5
  JOIN uploads u ON u.id = e.upload_id
6
6
  JOIN hook_events h ON h.id = e.event_id
7
7
  WHERE h.session_id = ?
8
- ORDER BY e.event_id, u.created_at`).all(e),t=new Map;for(const s of i){const r=Number(s.eventId),n=t.get(r)??[];n.push(c(s)),t.set(r,n)}return t}uploadsBySession(e){const i=this.db.prepare(`SELECT DISTINCT u.* FROM event_images e
8
+ ORDER BY e.event_id, u.created_at`).all(e),i=new Map;for(const r of t){const s=Number(r.eventId),n=i.get(s)??[];n.push(p(r)),i.set(s,n)}return i}uploadsBySession(e){const t=this.db.prepare(`SELECT DISTINCT u.* FROM event_images e
9
9
  JOIN uploads u ON u.id = e.upload_id
10
10
  JOIN hook_events h ON h.id = e.event_id
11
11
  WHERE h.session_id = ?
12
- ORDER BY u.created_at`).all(e);return i.length===0?null:i.map(c)}sessionBreakdown(e){const i=this.db.prepare(`SELECT u.media_type AS mediaType, COUNT(DISTINCT u.id) AS n, SUM(u.size) AS bytes
12
+ ORDER BY u.created_at`).all(e);return t.length===0?null:t.map(p)}sessionBreakdown(e){const t=this.db.prepare(`SELECT u.media_type AS mediaType, COUNT(DISTINCT u.id) AS n, SUM(u.size) AS bytes
13
13
  FROM event_images e
14
14
  JOIN uploads u ON u.id = e.upload_id
15
15
  JOIN hook_events h ON h.id = e.event_id
16
16
  WHERE h.session_id = ?
17
- GROUP BY u.media_type`).all(e);if(i.length===0)return null;let t={count:0,bytes:0};for(const r of i)isImageMediaType(String(r.mediaType))&&(t={count:t.count+Number(r.n),bytes:t.bytes+Number(r.bytes)});const s={count:i.reduce((r,n)=>r+Number(n.n),0),bytes:i.reduce((r,n)=>r+Number(n.bytes),0)};return{images:t,files:{count:s.count-t.count,bytes:s.bytes-t.bytes}}}usageBySession(){return this.db.prepare(`SELECT h.session_id AS sessionId, COUNT(DISTINCT u.id) AS count, COALESCE(SUM(u.size), 0) AS bytes
17
+ GROUP BY u.media_type`).all(e);if(t.length===0)return null;let i={count:0,bytes:0};for(const s of t)isImageMediaType(String(s.mediaType))&&(i={count:i.count+Number(s.n),bytes:i.bytes+Number(s.bytes)});const r={count:t.reduce((s,n)=>s+Number(n.n),0),bytes:t.reduce((s,n)=>s+Number(n.bytes),0)};return{images:i,files:{count:r.count-i.count,bytes:r.bytes-i.bytes}}}usageBySession(){return this.db.prepare(`SELECT h.session_id AS sessionId, COUNT(DISTINCT u.id) AS count, COALESCE(SUM(u.size), 0) AS bytes
18
18
  FROM event_images e
19
19
  JOIN uploads u ON u.id = e.upload_id
20
20
  JOIN hook_events h ON h.id = e.event_id
21
21
  GROUP BY h.session_id
22
- ORDER BY bytes DESC`).all().map(e=>({sessionId:String(e.sessionId),count:Number(e.count),bytes:Number(e.bytes)}))}removeMany(e){const i=this.db.prepare("DELETE FROM uploads WHERE id = ?");let t=0;for(const s of e){const r=this.getById(s);r&&(u(this.pathOf(r),{force:!0}),t+=Number(i.run(s).changes))}return t}unreferencedStats(e=UPLOAD_CLEANUP_GRACE_MS,i=Date.now()){const t=this.db.prepare(`SELECT COUNT(*) AS n, COALESCE(SUM(size), 0) AS bytes FROM uploads
23
- WHERE created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images)`).get(new Date(i-e).toISOString());return{count:Number(t.n),bytes:Number(t.bytes)}}overview(e=UPLOAD_CLEANUP_GRACE_MS,i=Date.now()){const t=new Date(i-e).toISOString(),s=this.db.prepare(`SELECT COUNT(*) AS n, COALESCE(SUM(size), 0) AS bytes,
22
+ ORDER BY bytes DESC`).all().map(t=>({sessionId:String(t.sessionId),count:Number(t.count),bytes:Number(t.bytes)}))}removeMany(e){const t=this.db.prepare("DELETE FROM uploads WHERE id = ?");let i=0;for(const r of e){const s=this.getById(r);s&&(u(this.pathOf(s),{force:!0}),i+=Number(t.run(r).changes))}return i}unreferencedStats(e=UPLOAD_CLEANUP_GRACE_MS,t=Date.now()){const i=this.db.prepare(`SELECT COUNT(*) AS n, COALESCE(SUM(size), 0) AS bytes FROM uploads
23
+ WHERE created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images)`).get(new Date(t-e).toISOString());return{count:Number(i.n),bytes:Number(i.bytes)}}overview(e=UPLOAD_CLEANUP_GRACE_MS,t=Date.now()){const i=new Date(t-e).toISOString(),r=this.db.prepare(`SELECT COUNT(*) AS n, COALESCE(SUM(size), 0) AS bytes,
24
24
  COALESCE(SUM(CASE WHEN media_type IN ('image/png','image/jpeg','image/gif','image/webp') THEN size ELSE 0 END), 0) AS imgBytes,
25
25
  COALESCE(SUM(CASE WHEN media_type IN ('image/png','image/jpeg','image/gif','image/webp') THEN 1 ELSE 0 END), 0) AS imgN,
26
26
  COALESCE(SUM(CASE WHEN id IN (SELECT upload_id FROM event_images) THEN size ELSE 0 END), 0) AS refBytes,
27
27
  COALESCE(SUM(CASE WHEN id IN (SELECT upload_id FROM event_images) THEN 1 ELSE 0 END), 0) AS refN,
28
28
  COALESCE(SUM(CASE WHEN created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images) THEN size ELSE 0 END), 0) AS unrefBytes,
29
29
  COALESCE(SUM(CASE WHEN created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images) THEN 1 ELSE 0 END), 0) AS unrefN
30
- FROM uploads`).get(t,t),r={count:Number(s.n),bytes:Number(s.bytes)},n={count:Number(s.imgN),bytes:Number(s.imgBytes)};return{total:r,images:n,files:{count:r.count-n.count,bytes:r.bytes-n.bytes},referenced:{count:Number(s.refN),bytes:Number(s.refBytes)},unreferenced:{count:Number(s.unrefN),bytes:Number(s.unrefBytes)}}}cleanupUnreferenced(e,i=UPLOAD_CLEANUP_GRACE_MS,t=Date.now()){const s=this.db.prepare(`SELECT id, media_type, name, dir FROM uploads
31
- WHERE created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images)`).all(new Date(t-i).toISOString()),r=this.db.prepare("DELETE FROM uploads WHERE id = ?");let n=0;for(const d of s)u(this.pathOf({id:d.id,mediaType:d.media_type,name:d.name,dir:d.dir}),{force:!0}),n+=Number(r.run(d.id).changes),e(n,s.length);return n}}function c(a){return{id:String(a.id),mediaType:String(a.media_type),name:String(a.name),size:Number(a.size),createdAt:String(a.created_at),dir:a.dir==null?null:String(a.dir)}}
30
+ FROM uploads`).get(i,i),s={count:Number(r.n),bytes:Number(r.bytes)},n={count:Number(r.imgN),bytes:Number(r.imgBytes)};return{total:s,images:n,files:{count:s.count-n.count,bytes:s.bytes-n.bytes},referenced:{count:Number(r.refN),bytes:Number(r.refBytes)},unreferenced:{count:Number(r.unrefN),bytes:Number(r.unrefBytes)}}}cleanupUnreferenced(e,t=UPLOAD_CLEANUP_GRACE_MS,i=Date.now()){const r=this.db.prepare(`SELECT id, media_type, name, dir FROM uploads
31
+ WHERE created_at <= ? AND id NOT IN (SELECT upload_id FROM event_images)`).all(new Date(i-t).toISOString()),s=this.db.prepare("DELETE FROM uploads WHERE id = ?");let n=0;for(const a of r)u(this.pathOf({id:a.id,mediaType:a.media_type,name:a.name,dir:a.dir}),{force:!0}),n+=Number(s.run(a.id).changes),e(n,r.length);return n}}function p(d){return{id:String(d.id),mediaType:String(d.media_type),name:String(d.name),size:Number(d.size),createdAt:String(d.created_at),dir:d.dir==null?null:String(d.dir)}}
@@ -1 +1 @@
1
- import{existsSync as l,readdirSync as w,readFileSync as d,renameSync as L,statSync as m,unlinkSync as j,writeFileSync as D}from"node:fs";import E from"node:os";import S from"node:path";import{statuslineCacheDir as _}from"./generator.js";export const SWEEP_INTERVAL_MS=10*6e4,FILE_STALE_MS=1440*6e4,TMP_STALE_MS=60*6e4;const x=["weave-sl-","weave-slc-"];export const LEGACY_STALE_MS=60*6e4;export class StatuslineCacheSweeper{dir;tmpDir;now;constructor(t=_(),e=E.tmpdir(),n=Date.now){this.dir=t,this.tmpDir=e,this.now=n}sweep(){return this.sweepCacheDir()+this.sweepLegacyTmp()}sweepCacheDir(){if(!l(this.dir))return 0;const t=this.now();let e=0;for(const n of y(this.dir)){const r=S.join(this.dir,n);if(n.endsWith(".tmp")){f(r,t,TMP_STALE_MS)&&(o(r),e++);continue}if(!n.endsWith(".json"))continue;if(f(r,t,FILE_STALE_MS)){o(r),e++;continue}let c;try{c=JSON.parse(d(r,"utf8"))}catch{o(r),e++;continue}const a=c.git??{},p=c.tokens??{};let h=!1;for(const[s,u]of Object.entries(a))(!u||typeof u.expires!="number"||u.expires<t)&&(delete a[s],h=!0);for(const s of Object.keys(p))this.transcriptLive(s,t)||(delete p[s],h=!0);if(Object.keys(a).length===0&&Object.keys(p).length===0){o(r),e++;continue}if(h){const s=`${r}.${process.pid}.tmp`;try{D(s,JSON.stringify({...c,git:a,tokens:p})),L(s,r)}catch{}}}return e}transcriptLive(t,e){try{return e-m(t).mtimeMs<=FILE_STALE_MS}catch{return!1}}sweepLegacyTmp(){const t=this.now();let e=0;for(const n of y(this.tmpDir)){if(!n.endsWith(".json")||!x.some(c=>n.startsWith(c)))continue;const r=S.join(this.tmpDir,n);f(r,t,LEGACY_STALE_MS)&&(o(r),e++)}return e}start(){this.sweep();const t=setInterval(()=>this.sweep(),SWEEP_INTERVAL_MS);return t.unref(),t}}export function startStatuslineCacheSweeper(){return new StatuslineCacheSweeper().start()}function y(i){try{return w(i)}catch{return[]}}function f(i,t,e){try{return t-m(i).mtimeMs>e}catch{return!1}}function o(i){try{j(i)}catch{}}
1
+ import{existsSync as y,readdirSync as d,readFileSync as w,renameSync as _,statSync as m,unlinkSync as E,writeFileSync as L}from"node:fs";import x from"node:os";import l from"node:path";import{statuslineCacheDir as j}from"./generator.js";export const SWEEP_INTERVAL_MS=10*6e4,FILE_STALE_MS=1440*6e4,TMP_STALE_MS=60*6e4;const D=["weave-sl-","weave-slc-"];export const LEGACY_STALE_MS=60*6e4;export class StatuslineCacheSweeper{dir;tmpDir;now;constructor(t=j(),e=x.tmpdir(),n=Date.now){this.dir=t,this.tmpDir=e,this.now=n}sweep(){return this.sweepCacheDir()+this.sweepLegacyTmp()}sweepCacheDir(){if(!y(this.dir))return 0;const t=this.now();let e=0;for(const n of S(this.dir)){const r=l.join(this.dir,n);if(n.endsWith(".tmp")){u(r,t,TMP_STALE_MS)&&(c(r),e++);continue}if(!n.endsWith(".json"))continue;if(u(r,t,FILE_STALE_MS)){c(r),e++;continue}let o;try{o=JSON.parse(w(r,"utf8"))}catch{c(r),e++;continue}const a=o.git??{},p=o.tokens??{};let f=!1;for(const[i,h]of Object.entries(a))(!h||typeof h.expires!="number"||h.expires<t)&&(delete a[i],f=!0);for(const i of Object.keys(p))this.transcriptLive(i,t)||(delete p[i],f=!0);if(Object.keys(a).length===0&&Object.keys(p).length===0){c(r),e++;continue}if(f){const i=`${r}.${process.pid}.tmp`;try{L(i,JSON.stringify({...o,git:a,tokens:p})),_(i,r)}catch{}}}return e}transcriptLive(t,e){try{return e-m(t).mtimeMs<=FILE_STALE_MS}catch{return!1}}sweepLegacyTmp(){const t=this.now();let e=0;for(const n of S(this.tmpDir)){if(!n.endsWith(".json")||!D.some(o=>n.startsWith(o)))continue;const r=l.join(this.tmpDir,n);u(r,t,LEGACY_STALE_MS)&&(c(r),e++)}return e}start(){this.sweep();const t=setInterval(()=>this.sweep(),SWEEP_INTERVAL_MS);return t.unref(),t}}export function startStatuslineCacheSweeper(){return new StatuslineCacheSweeper().start()}function S(s){try{return d(s)}catch{return[]}}function u(s,t,e){try{return t-m(s).mtimeMs>e}catch{return!1}}function c(s){try{E(s)}catch{}}
@@ -1 +1 @@
1
- import{generateStatuslineScript as e}from"@weavecode/harness";import{getStatuslineDir as i}from"../db/paths.js";import{WEAVE_VERSION as n}from"../version.js";export function statuslineCacheDir(){return i()}export function generateStatuslineScript(r,t={}){return e(r,{cacheDir:t.cacheDir??statuslineCacheDir(),version:n})}
1
+ import{generateStatuslineScript as r}from"@weavecode/harness";import{getStatuslineDir as i}from"../db/paths.js";import{WEAVE_VERSION as n}from"../version.js";export function statuslineCacheDir(){return i()}export function generateStatuslineScript(t,e={}){return r(t,{cacheDir:e.cacheDir??statuslineCacheDir(),version:n})}
@@ -1,3 +1,3 @@
1
- import{readFile as f,writeFile as p,mkdir as d}from"node:fs/promises";import{homedir as h}from"node:os";import s from"node:path";import{DEFAULT_STATUSLINE_CONFIG as a,LEGACY_IDENTITY_LINE as C,LEGACY_METRICS_LINE as x,NAMED_COLORS as v,SEGMENT_ORDER as b}from"./config.js";import{generateStatuslineScript as j,statuslineCacheDir as N}from"./generator.js";import{statuslineSurfaceFor as E}from"../surfaces.js";const w=".weave",y="statusline.json",S="statusline.json",l=E("claude");export function statuslineScriptRelPath(){return l.scriptRelPath}let u=s.join(h(),".weave");export function setGlobalStatuslineDir(e){u=e}export async function readGlobalStatuslineConfig(){try{const e=await f(s.join(u,S),"utf-8");return{...c(JSON.parse(e)),source:"global"}}catch{return a}}export async function writeGlobalStatuslineConfig(e){await d(u,{recursive:!0});const t={...c(e),source:"global"};await p(s.join(u,S),`${JSON.stringify(t,null,2)}
2
- `,"utf-8")}export async function readStatuslineConfig(e){const t=await readGlobalStatuslineConfig();try{const r=await f(s.join(e,w,y),"utf-8"),n=JSON.parse(r);return n.source==="custom"?c(n):t}catch{return t}}export async function writeStatuslineConfig(e,t){const r=s.join(e,w);await d(r,{recursive:!0});const n=(t.source??"global")==="global"?{source:"global"}:c(t);await p(s.join(r,y),`${JSON.stringify(n,null,2)}
3
- `,"utf-8")}export async function writeStatuslineScript(e,t){const r=s.join(e,l.scriptRelPath);return await d(s.dirname(r),{recursive:!0}),await p(r,t,"utf-8"),r}export async function readStatuslineScript(e){try{return await f(s.join(e,l.scriptRelPath),"utf-8")}catch{return""}}export function readStatuslineFacts(e){return l.facts?.(N(),e)??null}export async function ensureSettingsStatusLine(e,t=30){await l.wire(e,{scriptPath:s.join(e,l.scriptRelPath),refreshInterval:t})}export async function applyStatuslineConfig(e,t){await writeStatuslineConfig(e,t);const r=(t.source??"global")==="global"?await readGlobalStatuslineConfig():c(t),n=j(r);await writeStatuslineScript(e,n),await ensureSettingsStatusLine(e,r.refreshInterval)}function I(e){let t,r=!1;if(e.lines?.length)t=e.lines.map(o=>[...o]);else if(e.order?.length){r=!0;const o=e.order;e.layout==="multi"?t=[C.filter(i=>o.includes(i)),x.filter(i=>o.includes(i))].filter(i=>i.length>0):t=[o]}else r=!0,t=a.lines.map(o=>[...o]);const n=new Set;if(t=t.map(o=>o.filter(i=>!b.includes(i)||n.has(i)?!1:(n.add(i),!0))),t.length===0&&(t=[[]]),r){const o=b.filter(i=>{if(n.has(i))return!1;const m=e.segments?.[i];return typeof m?.enabled=="boolean"?m.enabled:a.segments[i].enabled});o.length&&(t[0]=[...t[0],...o])}return t}const $=/^#[0-9a-fA-F]{6}$/,L=/^#([0-9a-fA-F]{3})$/,_=/^ansi256:(\d{1,3})$/;function g(e,t){if(typeof e!="string")return t;if(v.includes(e))return e;const r=_.exec(e);if(r){const o=Number(r[1]);return o>=0&&o<=255?`ansi256:${o}`:t}if($.test(e))return e.toLowerCase();const n=L.exec(e);if(n){const[,o]=n;return`#${o[0]}${o[0]}${o[1]}${o[1]}${o[2]}${o[2]}`.toLowerCase()}return t}function F(e,t){if(!e||typeof e!="object")return{...t};const r=e,n={...t,...r,color:g(r.color,t.color),backgroundColor:r.backgroundColor==null?null:g(r.backgroundColor,t.backgroundColor??"gray")};return(typeof r.label!="string"||r.label==="")&&delete n.label,(typeof r.format!="string"||r.format==="")&&delete n.format,r.metric!=="session"&&r.metric!=="context"&&delete n.metric,r.window!=="five_hour"&&r.window!=="seven_day"&&r.window!=="spend"&&delete n.window,n}function T(e){const t=a.bar;if(!e||typeof e!="object")return{...t};const r=e,n=Math.round(Number(r.cells));return{cells:Number.isFinite(n)?Math.max(1,Math.min(40,n)):t.cells,fill:typeof r.fill=="string"&&r.fill!==""?r.fill:t.fill,empty:typeof r.empty=="string"&&r.empty!==""?r.empty:t.empty}}function c(e){const t={...a.segments};for(const n of Object.keys(t))t[n]=F(e.segments?.[n],t[n]);const r=e.refreshInterval;return{separator:e.separator??a.separator,align:e.align??a.align,logoText:a.logoText,logoColor:g(e.logoColor,a.logoColor),powerline:{...e.powerline,enabled:e.powerline?.enabled??a.powerline.enabled},lines:I(e),refreshInterval:r!=null&&r>=1?r:a.refreshInterval,source:e.source??a.source,bar:T(e.bar),divider:typeof e.divider=="string"?e.divider:a.divider,labelSeparator:typeof e.labelSeparator=="string"?e.labelSeparator:a.labelSeparator,segments:t}}
1
+ import{readFile as f,writeFile as g,mkdir as m}from"node:fs/promises";import{homedir as h}from"node:os";import s from"node:path";import{DEFAULT_STATUSLINE_CONFIG as i,LEGACY_IDENTITY_LINE as C,LEGACY_METRICS_LINE as E,NAMED_COLORS as L,SEGMENT_ORDER as d}from"./config.js";import{generateStatuslineScript as x,statuslineCacheDir as I}from"./generator.js";import{statuslineSurfaceFor as N}from"../surfaces.js";const b=".weave",w="statusline.json",y="statusline.json",a=N("claude");export function statuslineScriptRelPath(){return a.scriptRelPath}let u=s.join(h(),".weave");export function setGlobalStatuslineDir(t){u=t}export async function readGlobalStatuslineConfig(){try{const t=await f(s.join(u,y),"utf-8");return{...c(JSON.parse(t)),source:"global"}}catch{return i}}export async function writeGlobalStatuslineConfig(t){await m(u,{recursive:!0});const e={...c(t),source:"global"};await g(s.join(u,y),`${JSON.stringify(e,null,2)}
2
+ `,"utf-8")}export async function readStatuslineConfig(t){const e=await readGlobalStatuslineConfig();try{const n=await f(s.join(t,b,w),"utf-8"),r=JSON.parse(n);return r.source==="custom"?c(r):e}catch{return e}}export async function writeStatuslineConfig(t,e){const n=s.join(t,b);await m(n,{recursive:!0});const o=(e.source??"global")==="global"?{source:"global"}:c(e);await g(s.join(n,w),`${JSON.stringify(o,null,2)}
3
+ `,"utf-8")}export async function writeStatuslineScript(t,e){const n=s.join(t,a.scriptRelPath);return await m(s.dirname(n),{recursive:!0}),await g(n,e,"utf-8"),n}export async function readStatuslineScript(t){try{return await f(s.join(t,a.scriptRelPath),"utf-8")}catch{return""}}export function readStatuslineFacts(t){return a.facts?.(I(),t)??null}export async function ensureSettingsStatusLine(t,e=30){await a.wire(t,{scriptPath:s.join(t,a.scriptRelPath),refreshInterval:e})}export async function applyStatuslineConfig(t,e){await writeStatuslineConfig(t,e);const n=(e.source??"global")==="global"?await readGlobalStatuslineConfig():c(e),r=x(n);await writeStatuslineScript(t,r),await ensureSettingsStatusLine(t,n.refreshInterval)}function T(t){let e,n=!1;if(t.lines?.length)e=t.lines.map(o=>[...o]);else if(t.order?.length){n=!0;const o=t.order;t.layout==="multi"?e=[C.filter(l=>o.includes(l)),E.filter(l=>o.includes(l))].filter(l=>l.length>0):e=[o]}else n=!0,e=i.lines.map(o=>[...o]);const r=new Set;if(e=e.map(o=>o.filter(l=>!d.includes(l)||r.has(l)?!1:(r.add(l),!0))),e.length===0&&(e=[[]]),n){const o=d.filter(l=>{if(r.has(l))return!1;const S=t.segments?.[l];return typeof S?.enabled=="boolean"?S.enabled:i.segments[l].enabled});o.length&&(e[0]=[...e[0],...o])}return e}const _=/^#[0-9a-fA-F]{6}$/,A=/^#([0-9a-fA-F]{3})$/,F=/^ansi256:(\d{1,3})$/;function p(t,e){if(typeof t!="string")return e;if(L.includes(t))return t;const n=F.exec(t);if(n){const o=Number(n[1]);return o>=0&&o<=255?`ansi256:${o}`:e}if(_.test(t))return t.toLowerCase();const r=A.exec(t);if(r){const[,o]=r;return`#${o[0]}${o[0]}${o[1]}${o[1]}${o[2]}${o[2]}`.toLowerCase()}return e}function $(t,e){if(!t||typeof t!="object")return{...e};const n=t,r={...e,...n,color:p(n.color,e.color),backgroundColor:n.backgroundColor==null?null:p(n.backgroundColor,e.backgroundColor??"gray")};return(typeof n.label!="string"||n.label==="")&&delete r.label,(typeof n.format!="string"||n.format==="")&&delete r.format,n.metric!=="session"&&n.metric!=="context"&&delete r.metric,n.window!=="five_hour"&&n.window!=="seven_day"&&n.window!=="spend"&&delete r.window,r}function j(t){const e=i.bar;if(!t||typeof t!="object")return{...e};const n=t,r=Math.round(Number(n.cells));return{cells:Number.isFinite(r)?Math.max(1,Math.min(40,r)):e.cells,fill:typeof n.fill=="string"&&n.fill!==""?n.fill:e.fill,empty:typeof n.empty=="string"&&n.empty!==""?n.empty:e.empty}}function c(t){const e={...i.segments};for(const r of Object.keys(e))e[r]=$(t.segments?.[r],e[r]);const n=t.refreshInterval;return{separator:t.separator??i.separator,align:t.align??i.align,logoText:i.logoText,logoColor:p(t.logoColor,i.logoColor),powerline:{...t.powerline,enabled:t.powerline?.enabled??i.powerline.enabled},lines:T(t),refreshInterval:n!=null&&n>=1?n:i.refreshInterval,source:t.source??i.source,bar:j(t.bar),divider:typeof t.divider=="string"?t.divider:i.divider,labelSeparator:typeof t.labelSeparator=="string"?t.labelSeparator:i.labelSeparator,segments:e}}
@@ -1 +1 @@
1
- import{createRuntimeRegistry as n}from"@weavecode/harness";const e=n();export function assetSurfaceFor(r){const t=e.get(r)?.assets;if(!t)throw new Error(`no asset surface registered for harness: ${r}`);return t}export function assetSurfaces(){return e.all().map(r=>r.assets).filter(r=>r!==void 0)}export function pluginSurfaceFor(r){const t=e.get(r)?.plugins;if(!t)throw new Error(`no plugin surface registered for harness: ${r}`);return t}export function pluginSurfaces(){return e.all().filter(r=>r.plugins!==void 0).map(r=>({harness:r.id,surface:r.plugins}))}export function pluginStateFor(r){const t=e.get(r)?.pluginState;if(!t)throw new Error(`no plugin state surface registered for harness: ${r}`);return t}export function pluginStateSurfaces(){return e.all().filter(r=>r.pluginState!==void 0).map(r=>({harness:r.id,state:r.pluginState}))}export function messagingSurfaceFor(r){const t=e.get(r)?.messaging;if(!t)throw new Error(`no messaging surface registered for harness: ${r}`);return t}export function messagingSurfaces(){return e.all().filter(r=>r.messaging!==void 0).map(r=>({harness:r.id,surface:r.messaging}))}export function captureSurfaces(){return e.all().filter(r=>r.capture!==void 0).map(r=>({harness:r.id,surface:r.capture}))}export function blockingPromptFor(r){return e.get(r)?.questions??null}export function statuslineSurfaceFor(r){return e.get(r)?.statusline??null}export function statuslineSurfaces(){return e.all().filter(r=>r.statusline!==void 0).map(r=>({harness:r.id,surface:r.statusline}))}export function configSurfaceFor(r){return e.get(r)?.config??null}export function editSurfaceFor(r){return e.get(r)?.edits??null}export function imagesSurfaceFor(r){return e.get(r)?.images??null}export function narrationSurfaceFor(r){return e.get(r)?.narration??null}export function rewindSurfaceFor(r){return e.get(r)?.rewind??null}export function commandsSurfaceFor(r){return e.get(r)?.commands??null}export function configSurfaces(){return e.all().filter(r=>r.config!==void 0).map(r=>({harness:r.id,surface:r.config}))}export function sessionTitleSurfaceFor(r){return e.get(r)?.titles??null}
1
+ import{createRuntimeRegistry as t}from"@weavecode/harness";const r=t();export function assetSurfaceFor(e){const n=r.get(e)?.assets;if(!n)throw new Error(`no asset surface registered for harness: ${e}`);return n}export function assetSurfaces(){return r.all().map(e=>e.assets).filter(e=>e!==void 0)}export function pluginSurfaceFor(e){const n=r.get(e)?.plugins;if(!n)throw new Error(`no plugin surface registered for harness: ${e}`);return n}export function pluginSurfaces(){return r.all().filter(e=>e.plugins!==void 0).map(e=>({harness:e.id,surface:e.plugins}))}export function pluginStateFor(e){const n=r.get(e)?.pluginState;if(!n)throw new Error(`no plugin state surface registered for harness: ${e}`);return n}export function pluginStateSurfaces(){return r.all().filter(e=>e.pluginState!==void 0).map(e=>({harness:e.id,state:e.pluginState}))}export function messagingSurfaceFor(e){const n=r.get(e)?.messaging;if(!n)throw new Error(`no messaging surface registered for harness: ${e}`);return n}export function messagingSurfaces(){return r.all().filter(e=>e.messaging!==void 0).map(e=>({harness:e.id,surface:e.messaging}))}export function captureSurfaces(){return r.all().filter(e=>e.capture!==void 0).map(e=>({harness:e.id,surface:e.capture}))}export function blockingPromptFor(e){return r.get(e)?.questions??null}export function statuslineSurfaceFor(e){return r.get(e)?.statusline??null}export function statuslineSurfaces(){return r.all().filter(e=>e.statusline!==void 0).map(e=>({harness:e.id,surface:e.statusline}))}export function configSurfaceFor(e){return r.get(e)?.config??null}export function editSurfaceFor(e){return r.get(e)?.edits??null}export function imagesSurfaceFor(e){return r.get(e)?.images??null}export function narrationSurfaceFor(e){return r.get(e)?.narration??null}export function rewindSurfaceFor(e){return r.get(e)?.rewind??null}export function commandsSurfaceFor(e){return r.get(e)?.commands??null}export function configSurfaces(){return r.all().filter(e=>e.config!==void 0).map(e=>({harness:e.id,surface:e.config}))}export function sessionTitleSurfaceFor(e){return r.get(e)?.titles??null}
@@ -1 +1 @@
1
- export class WatchCache{byProject=new Map;upsert(e,t){let r=this.byProject.get(e);r||(r=new Map,this.byProject.set(e,r)),r.set(t.relPath,t)}remove(e,t){this.byProject.get(e)?.delete(t)}list(e){const t=this.byProject.get(e);return t?[...t.values()].sort((r,l)=>r.relPath.localeCompare(l.relPath)):[]}clear(e){this.byProject.delete(e)}clearAll(){this.byProject.clear()}}
1
+ export class WatchCache{byProject=new Map;upsert(e,t){let r=this.byProject.get(e);r||(r=new Map,this.byProject.set(e,r)),r.set(t.relPath,t)}remove(e,t){this.byProject.get(e)?.delete(t)}list(e){const t=this.byProject.get(e);return t?[...t.values()].sort((r,c)=>r.relPath.localeCompare(c.relPath)):[]}clear(e){this.byProject.delete(e)}clearAll(){this.byProject.clear()}}
@@ -1 +1 @@
1
- import{assetSurfaces as r}from"../surfaces.js";export function classifyAsset(s){const t=normalizeRelPath(s);if(t===".mcp.json")return"mcp";if(t.startsWith(".claude/skills/")||t.startsWith(".codex/skills/")||t.startsWith(".agents/skills/"))return"skill";if(t===".claude/settings.json"||t===".claude/settings.local.json"||t===".codex/config.toml")return"settings";if(t.startsWith(".claude/commands/")||t.startsWith(".codex/prompts/"))return"command";if(t.startsWith(".claude/agents/"))return"agent";if(t.startsWith(".claude/helpers/"))return"helper";if(t.startsWith(".claude/workflows/"))return"workflow";if(t.startsWith(".claude/rules/"))return"rule";if(t.startsWith(".claude/output-styles/"))return"output-style";if(t.startsWith(".claude/plugins/")||t.startsWith(".weave/plugins/"))return"plugin";const e=t.slice(t.lastIndexOf("/")+1);return e==="CLAUDE.md"||e==="AGENTS.md"?"instructions":"other"}export function classifyAgent(s){const t=normalizeRelPath(s);return r().find(e=>e.classify(t))?.harness??"claude"}export function normalizeRelPath(s){let t=s.replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);for(;t.startsWith("/");)t=t.slice(1);return t}
1
+ import{assetSurfaces as i}from"../surfaces.js";export function classifyAsset(s){const t=normalizeRelPath(s);if(t===".mcp.json")return"mcp";if(t.startsWith(".claude/skills/")||t.startsWith(".codex/skills/")||t.startsWith(".agents/skills/"))return"skill";if(t===".claude/settings.json"||t===".claude/settings.local.json"||t===".codex/config.toml")return"settings";if(t.startsWith(".claude/commands/")||t.startsWith(".codex/prompts/"))return"command";if(t.startsWith(".claude/agents/"))return"agent";if(t.startsWith(".claude/helpers/"))return"helper";if(t.startsWith(".claude/workflows/"))return"workflow";if(t.startsWith(".claude/rules/"))return"rule";if(t.startsWith(".claude/output-styles/"))return"output-style";if(t.startsWith(".claude/plugins/")||t.startsWith(".weave/plugins/"))return"plugin";const e=t.slice(t.lastIndexOf("/")+1);return e==="CLAUDE.md"||e==="AGENTS.md"?"instructions":"other"}export function classifyAgent(s){const t=normalizeRelPath(s);return i().find(r=>r.classify(t))?.harness??"claude"}export function normalizeRelPath(s){let t=s.replace(/\\/g,"/");for(;t.startsWith("./");)t=t.slice(2);for(;t.startsWith("/");)t=t.slice(1);return t}
@@ -1 +1 @@
1
- import{readFileSync as c,statSync as u,existsSync as a}from"node:fs";import n from"node:path";const h=8;export class PluginModsSniffer{cache=new Map;verdicts=new Map;revalidate;constructor(t={}){this.revalidate=t.revalidate??!0}refine(t,e,s){return t!=="plugin"?t:this.sniff(n.dirname(s))?"mods":"plugin"}sniff(t){if(!this.revalidate){const s=this.verdicts.get(t);if(s!==void 0)return s}const e=this.walkUp(t);return this.revalidate||this.verdicts.set(t,e),e}walkUp(t){let e=t;for(let s=0;s<h;s++){if(f(e))return!1;if(this.hooksMods(e))return!0;if(a(n.join(e,".claude-plugin","plugin.json")))return!1;const i=n.dirname(e);if(i===e)return!1;e=i}return!1}hooksMods(t){const e=n.join(t,"hooks","hooks.json"),s=this.cache.get(t);let i=-1;if(a(e))try{i=u(e).mtimeMs}catch{}if(i===-1)return s?.hooksMtimeMs!==-1&&this.cache.set(t,{mods:!1,hooksMtimeMs:-1}),!1;if(s&&s.hooksMtimeMs===i)return s.mods;const o=d(e);return this.cache.set(t,{mods:o,hooksMtimeMs:i}),o}}function f(r){if(n.basename(r)!=="plugins")return!1;const t=n.basename(n.dirname(r));return t===".claude"||t===".weave"}export function hasNonEmptyModules(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const t=r.modules;return Array.isArray(t)&&t.length>0}function d(r){try{return hasNonEmptyModules(JSON.parse(c(r,"utf8")))}catch{return!1}}
1
+ import{readFileSync as f,statSync as u,existsSync as o}from"node:fs";import n from"node:path";const l=8;export class PluginModsSniffer{cache=new Map;verdicts=new Map;revalidate;constructor(e={}){this.revalidate=e.revalidate??!0}refine(e,t,s){return e!=="plugin"?e:this.sniff(n.dirname(s))?"mods":"plugin"}sniff(e){if(!this.revalidate){const s=this.verdicts.get(e);if(s!==void 0)return s}const t=this.walkUp(e);return this.revalidate||this.verdicts.set(e,t),t}walkUp(e){let t=e;for(let s=0;s<l;s++){if(c(t))return!1;if(this.hooksMods(t))return!0;if(o(n.join(t,".claude-plugin","plugin.json")))return!1;const i=n.dirname(t);if(i===t)return!1;t=i}return!1}hooksMods(e){const t=n.join(e,"hooks","hooks.json"),s=this.cache.get(e);let i=-1;if(o(t))try{i=u(t).mtimeMs}catch{}if(i===-1)return s?.hooksMtimeMs!==-1&&this.cache.set(e,{mods:!1,hooksMtimeMs:-1}),!1;if(s&&s.hooksMtimeMs===i)return s.mods;const a=h(t);return this.cache.set(e,{mods:a,hooksMtimeMs:i}),a}}function c(r){if(n.basename(r)!=="plugins")return!1;const e=n.basename(n.dirname(r));return e===".claude"||e===".weave"}export function hasNonEmptyModules(r){if(!r||typeof r!="object"||Array.isArray(r))return!1;const e=r.modules;return Array.isArray(e)&&e.length>0}function h(r){try{return hasNonEmptyModules(JSON.parse(f(r,"utf8")))}catch{return!1}}
@@ -1 +1 @@
1
- import{FingerprintCache as a}from"../install/fingerprint.js";import{buildLibraryIndex as e}from"../install/library-index.js";import{detectUpdates as n}from"../install/updates.js";import{syncAll as c}from"../install/apply-update.js";import{markSynced as h}from"../install/project-config.js";import{syncPlugins as o}from"../hooks/plugin-project-state.js";export class SyncScheduler{projects;libraries;timer;intervalMs;cache;plugins;onSynced;running=!1;constructor(s,r,i={}){this.projects=s,this.libraries=r,this.intervalMs=i.intervalMs??6e4,this.cache=i.cache??new a,this.plugins=i.plugins,this.onSynced=i.onSynced}start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs))}stop(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}async tick(){if(!this.running&&this.libraries){this.running=!0;try{const s=this.libraries.list(),r=await e(s),i=this.plugins?.list().map(t=>t.id);for(const t of this.projects.list()){if(i)try{o(t,i,{projects:this.projects})}catch{}(await n(t.path,s,this.cache,r)).available!==0&&(await c(t.path,s,this.cache,r),await h(t.path,new Date().toISOString()),this.onSynced?.())}}finally{this.running=!1}}}}
1
+ import{FingerprintCache as e}from"../install/fingerprint.js";import{buildLibraryIndex as n}from"../install/library-index.js";import{detectUpdates as a}from"../install/updates.js";import{syncAll as c}from"../install/apply-update.js";import{markSynced as h}from"../install/project-config.js";import{syncPlugins as o}from"../hooks/plugin-project-state.js";export class SyncScheduler{projects;libraries;timer;intervalMs;cache;plugins;onSynced;running=!1;constructor(r,s,t={}){this.projects=r,this.libraries=s,this.intervalMs=t.intervalMs??6e4,this.cache=t.cache??new e,this.plugins=t.plugins,this.onSynced=t.onSynced}start(){this.timer||(this.timer=setInterval(()=>{this.tick()},this.intervalMs))}stop(){this.timer&&(clearInterval(this.timer),this.timer=void 0)}async tick(){if(!this.running&&this.libraries){this.running=!0;try{const r=this.libraries.list(),s=await n(r),t=this.plugins?.list().map(i=>i.id);for(const i of this.projects.list()){if(t)try{o(i,t,{projects:this.projects})}catch{}(await a(i.path,r,this.cache,s)).available!==0&&(await c(i.path,r,this.cache,s),await h(i.path,new Date().toISOString()),this.onSynced?.())}}finally{this.running=!1}}}}
@@ -1 +1 @@
1
- import{EventEmitter as p}from"node:events";import{existsSync as b,lstatSync as w,readdirSync as y,realpathSync as P,statSync as f,watch as d}from"node:fs";import h from"node:path";import{watch as j}from"chokidar";import{WatchCache as v}from"./cache.js";import{classifyAgent as R,classifyAsset as S,normalizeRelPath as g}from"./classifier.js";import{PluginModsSniffer as T}from"./plugin-mods.js";import{globalPersonalSkillRootsOwned as M}from"../install/global-config.js";import{assetSurfaces as G}from"../surfaces.js";const k="<global>",I=new T;export function shouldIgnore(l){return l===""||l==="."||l===".weave"||l.startsWith(".weave/")?!1:G().every(t=>t.ignore(l))}export class WatchService{projects;emitter=new p;watchers=new Map;cache=new v;debounceMs;reconcileMs;isIgnored;globalRootSource;timers=new Map;pending=new Map;reconcileTimer;globalRoots=new Map;globalPending=new Map;globalTimer;constructor(t,e={}){this.projects=t,this.debounceMs=e.debounceMs??300,this.reconcileMs=e.reconcileMs??5e3,this.isIgnored=e.isIgnored??shouldIgnore,this.globalRootSource=e.globalRootSource??M}start(){this.reconcile(),this.reconcileTimer=setInterval(()=>this.reconcile(),this.reconcileMs)}stop(){for(const t of this.watchers.values())t.close();this.watchers.clear();for(const t of[...this.globalRoots.keys()])this.unwatchGlobalRoot(t);for(const t of this.timers.values())clearTimeout(t);this.timers.clear(),this.pending.clear(),this.globalPending.clear(),this.globalTimer&&(clearTimeout(this.globalTimer),this.globalTimer=void 0),this.cache.clearAll(),this.reconcileTimer&&(clearInterval(this.reconcileTimer),this.reconcileTimer=void 0)}reconcile(){const t=new Set(this.projects.list().map(e=>e.path));for(const e of t)this.watchers.has(e)||(this.watchProject(e),this.watchers.has(e)&&this.emitter.emit("project",{action:"added",projectPath:e}));for(const e of[...this.watchers.keys()])t.has(e)||(this.unwatchProject(e),this.emitter.emit("project",{action:"removed",projectPath:e}));this.reconcileGlobalRoots()}reconcileGlobalRoots(){const t=this.globalRootSource(),e=new Set(t.map(s=>s.root));for(const{harness:s,root:o}of t){if(this.globalRoots.has(o)){this.syncGlobalEntries(o);continue}b(o)&&this.watchGlobalRoot(o,s)}for(const s of[...this.globalRoots.keys()])(!e.has(s)||!b(s))&&this.unwatchGlobalRoot(s)}getAssets(t){return this.cache.list(t)}subscribe(t){return this.emitter.on("change",t),()=>this.emitter.off("change",t)}subscribeProjects(t){return this.emitter.on("project",t),()=>this.emitter.off("project",t)}watchProject(t){if(!b(t))return;const e=this.projects.getByPath(t)?.name??h.basename(t),s=j(".",{cwd:t,ignored:o=>this.isIgnored(g(h.relative(t,o))),ignoreInitial:!1,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});this.watchers.set(t,s),s.on("add",o=>this.onFile(t,e,o,"add")),s.on("change",o=>this.onFile(t,e,o,"change")),s.on("unlink",o=>this.onFile(t,e,o,"unlink")),s.on("error",o=>this.emitter.emit("watch-error",o))}unwatchProject(t){const e=this.watchers.get(t);e&&(e.close(),this.watchers.delete(t));const s=this.timers.get(t);s&&(clearTimeout(s),this.timers.delete(t)),this.pending.delete(t),this.cache.clear(t)}watchGlobalRoot(t,e){const s=d(t,(o,i)=>{this.syncGlobalEntries(t),i&&this.emitGlobalPath(t,g(String(i)))});s.on("error",o=>this.emitter.emit("watch-error",o)),this.globalRoots.set(t,{harness:e,root:s,entries:new Map}),this.syncGlobalEntries(t)}syncGlobalEntries(t){const e=this.globalRoots.get(t);if(!e)return;let s;try{s=y(t)}catch{return}const o=new Set;for(const i of s){if(i.startsWith("."))continue;const r=h.join(t,i);let a;try{if(!f(r).isDirectory())continue;a=P(r)}catch{continue}o.add(i);const c=e.entries.get(i);if(c?.real===a)continue;c&&(c.watcher.close(),e.entries.delete(i));const n=d(a,{recursive:!0},(u,m)=>{m&&this.emitGlobalPath(t,g(h.join(i,String(m))))});n.on("error",()=>{n.close(),e.entries.delete(i)}),e.entries.set(i,{real:a,watcher:n})}for(const[i,r]of e.entries)o.has(i)||(r.watcher.close(),e.entries.delete(i))}unwatchGlobalRoot(t){const e=this.globalRoots.get(t);if(e){e.root.close();for(const s of e.entries.values())s.watcher.close();this.globalRoots.delete(t)}}emitGlobalPath(t,e){if(!e||e.split("/").some(i=>i.startsWith(".")))return;const s=h.join(t,e);let o="unlink";try{if(!f(s).isFile())return;o="change"}catch{}this.enqueueGlobal({projectPath:k,projectName:"global",category:"skill",agent:this.globalRoots.get(t)?.harness??"claude",relPath:e,absPath:s,kind:o})}enqueueGlobal(t){this.globalPending.set(t.absPath,t),this.globalTimer&&clearTimeout(this.globalTimer),this.globalTimer=setTimeout(()=>this.flushGlobal(),this.debounceMs)}flushGlobal(){this.globalTimer=void 0;for(const t of this.globalPending.values())this.emitter.emit("change",t);this.globalPending.clear()}onFile(t,e,s,o){const i=g(s),r=h.join(t,i);let a=S(i);o!=="unlink"&&a==="plugin"&&(a=I.refine(a,i,r));const c=R(i);let n;if(o==="unlink")this.cache.remove(t,i);else try{const u=w(r);n=u.isSymbolicLink()||void 0;const m=n?f(r).mtimeMs:u.mtimeMs;this.cache.upsert(t,{absPath:r,relPath:i,category:a,agent:c,mtimeMs:m,...n?{isSymlink:!0}:{}})}catch{this.cache.remove(t,i)}this.enqueue(t,{projectPath:t,projectName:e,category:a,agent:c,relPath:i,absPath:r,kind:o,...n?{isSymlink:!0}:{}})}enqueue(t,e){let s=this.pending.get(t);s||(s=new Map,this.pending.set(t,s)),s.set(e.relPath,e);const o=this.timers.get(t);o&&clearTimeout(o),this.timers.set(t,setTimeout(()=>this.flush(t),this.debounceMs))}flush(t){this.timers.delete(t);const e=this.pending.get(t);if(this.pending.delete(t),!!e)for(const s of e.values())this.emitter.emit("change",s)}}
1
+ import{EventEmitter as w}from"node:events";import{existsSync as g,lstatSync as y,readdirSync as p,realpathSync as S,statSync as b,watch as d}from"node:fs";import h from"node:path";import{watch as v}from"chokidar";import{WatchCache as R}from"./cache.js";import{classifyAgent as T,classifyAsset as M,normalizeRelPath as f}from"./classifier.js";import{PluginModsSniffer as G}from"./plugin-mods.js";import{globalPersonalSkillRootsOwned as k}from"../install/global-config.js";import{assetSurfaces as I}from"../surfaces.js";const E="<global>",W=new G;export function shouldIgnore(c){return c===""||c==="."||c===".weave"||c.startsWith(".weave/")?!1:I().every(e=>e.ignore(c))}export class WatchService{projects;emitter=new w;watchers=new Map;cache=new R;debounceMs;reconcileMs;isIgnored;globalRootSource;timers=new Map;pending=new Map;reconcileTimer;globalRoots=new Map;globalPending=new Map;globalTimer;constructor(e,t={}){this.projects=e,this.debounceMs=t.debounceMs??300,this.reconcileMs=t.reconcileMs??5e3,this.isIgnored=t.isIgnored??shouldIgnore,this.globalRootSource=t.globalRootSource??k}start(){this.reconcile(),this.reconcileTimer=setInterval(()=>this.reconcile(),this.reconcileMs)}stop(){for(const e of this.watchers.values())e.close();this.watchers.clear();for(const e of[...this.globalRoots.keys()])this.unwatchGlobalRoot(e);for(const e of this.timers.values())clearTimeout(e);this.timers.clear(),this.pending.clear(),this.globalPending.clear(),this.globalTimer&&(clearTimeout(this.globalTimer),this.globalTimer=void 0),this.cache.clearAll(),this.reconcileTimer&&(clearInterval(this.reconcileTimer),this.reconcileTimer=void 0)}reconcile(){const e=new Set(this.projects.list().map(t=>t.path));for(const t of e)this.watchers.has(t)||(this.watchProject(t),this.watchers.has(t)&&this.emitter.emit("project",{action:"added",projectPath:t}));for(const t of[...this.watchers.keys()])e.has(t)||(this.unwatchProject(t),this.emitter.emit("project",{action:"removed",projectPath:t}));this.reconcileGlobalRoots()}reconcileGlobalRoots(){const e=this.globalRootSource(),t=new Set(e.map(s=>s.root));for(const{harness:s,root:o}of e){if(this.globalRoots.has(o)){this.syncGlobalEntries(o);continue}g(o)&&this.watchGlobalRoot(o,s)}for(const s of[...this.globalRoots.keys()])(!t.has(s)||!g(s))&&this.unwatchGlobalRoot(s)}getAssets(e){return this.cache.list(e)}subscribe(e){return this.emitter.on("change",e),()=>this.emitter.off("change",e)}subscribeProjects(e){return this.emitter.on("project",e),()=>this.emitter.off("project",e)}watchProject(e){if(!g(e))return;const s=this.projects.getByPath(e)?.name??h.basename(e),o=v(".",{cwd:e,ignored:i=>this.isIgnored(f(h.relative(e,i))),ignoreInitial:!1,awaitWriteFinish:{stabilityThreshold:200,pollInterval:50}});this.watchers.set(e,o),o.on("add",i=>this.onFile(e,s,i,"add")),o.on("change",i=>this.onFile(e,s,i,"change")),o.on("unlink",i=>this.onFile(e,s,i,"unlink")),o.on("error",i=>this.emitter.emit("watch-error",i))}unwatchProject(e){const t=this.watchers.get(e);t&&(t.close(),this.watchers.delete(e));const s=this.timers.get(e);s&&(clearTimeout(s),this.timers.delete(e)),this.pending.delete(e),this.cache.clear(e)}watchGlobalRoot(e,t){const s=d(e,(o,i)=>{this.syncGlobalEntries(e),i&&this.emitGlobalPath(e,f(String(i)))});s.on("error",o=>this.emitter.emit("watch-error",o)),this.globalRoots.set(e,{harness:t,root:s,entries:new Map}),this.syncGlobalEntries(e)}syncGlobalEntries(e){const t=this.globalRoots.get(e);if(!t)return;let s;try{s=p(e)}catch{return}const o=new Set;for(const i of s){if(i.startsWith("."))continue;const n=h.join(e,i);let r;try{if(!b(n).isDirectory())continue;r=S(n)}catch{continue}o.add(i);const a=t.entries.get(i);if(a?.real===r)continue;a&&(a.watcher.close(),t.entries.delete(i));const l=d(r,{recursive:!0},(u,m)=>{m&&this.emitGlobalPath(e,f(h.join(i,String(m))))});l.on("error",()=>{l.close(),t.entries.delete(i)}),t.entries.set(i,{real:r,watcher:l})}for(const[i,n]of t.entries)o.has(i)||(n.watcher.close(),t.entries.delete(i))}unwatchGlobalRoot(e){const t=this.globalRoots.get(e);if(t){t.root.close();for(const s of t.entries.values())s.watcher.close();this.globalRoots.delete(e)}}emitGlobalPath(e,t){if(!t||t.split("/").some(i=>i.startsWith(".")))return;const s=h.join(e,t);let o="unlink";try{if(!b(s).isFile())return;o="change"}catch{}this.enqueueGlobal({projectPath:E,projectName:"global",category:"skill",agent:this.globalRoots.get(e)?.harness??"claude",relPath:t,absPath:s,kind:o})}enqueueGlobal(e){this.globalPending.set(e.absPath,e),this.globalTimer&&clearTimeout(this.globalTimer),this.globalTimer=setTimeout(()=>this.flushGlobal(),this.debounceMs)}flushGlobal(){this.globalTimer=void 0;for(const e of this.globalPending.values())this.emitter.emit("change",e);this.globalPending.clear()}onFile(e,t,s,o){const i=f(s),n=h.join(e,i);let r=M(i);o!=="unlink"&&r==="plugin"&&(r=W.refine(r,i,n));const a=T(i);let l;if(o==="unlink")this.cache.remove(e,i);else try{const u=y(n);l=u.isSymbolicLink()||void 0;const m=l?b(n).mtimeMs:u.mtimeMs;this.cache.upsert(e,{absPath:n,relPath:i,category:r,agent:a,mtimeMs:m,...l?{isSymlink:!0}:{}})}catch{this.cache.remove(e,i)}this.enqueue(e,{projectPath:e,projectName:t,category:r,agent:a,relPath:i,absPath:n,kind:o,...l?{isSymlink:!0}:{}})}enqueue(e,t){let s=this.pending.get(e);s||(s=new Map,this.pending.set(e,s)),s.set(t.relPath,t);const o=this.timers.get(e);o&&clearTimeout(o),this.timers.set(e,setTimeout(()=>this.flush(e),this.debounceMs))}flush(e){this.timers.delete(e);const t=this.pending.get(e);if(this.pending.delete(e),!!t)for(const s of t.values())this.emitter.emit("change",s)}}
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@weavecode/server",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "Weave daemon — HTTP server, SQLite data layer, and hook ingestion",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -21,9 +21,9 @@
21
21
  },
22
22
  "dependencies": {
23
23
  "@modelcontextprotocol/sdk": "1.32.1",
24
- "@weavecode/core": "^0.1.6",
25
- "@weavecode/harness": "^0.1.6",
26
- "@weavecode/templates": "^0.1.6",
24
+ "@weavecode/core": "^0.1.7",
25
+ "@weavecode/harness": "^0.1.7",
26
+ "@weavecode/templates": "^0.1.7",
27
27
  "chokidar": "^4.0.0",
28
28
  "selfsigned": "^5.5.0",
29
29
  "smol-toml": "^1.3.0",
@@ -1 +1 @@
1
- import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-CT951PH5.js";import{p as f}from"./chunk-JWPE2WC7-CY4mr2f4.js";import{_ as n,l as o}from"./mermaid.core-D39fi_iR.js";import"./index-FwH9INgS.js";import{M as c,b as d}from"./cynefin-EF2NZ3EQ-9B__MaRM.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
1
+ import{g as p,r as u,d as a}from"./chunk-2E7WHVMD-B653kMXt.js";import{p as f}from"./chunk-JWPE2WC7-D6dXb_jr.js";import{_ as n,l as o}from"./mermaid.core-D_Dp_Kl2.js";import"./index-BKxAxaVG.js";import{M as c,b as d}from"./cynefin-EF2NZ3EQ-OZotFKUu.js";var v=d().RailroadAbnf.parser.LangiumParser,i=n(e=>{const r=e.alternatives.map(g);return r.length===1?r[0]:{type:"choice",alternatives:r}},"transformAlternation"),g=n(e=>{const r=e.elements.map(y);return r.length===1?r[0]:{type:"sequence",elements:r}},"transformConcatenation"),b=n(e=>{if(e.includes("*")){const[t,s]=e.split("*"),l=t?parseInt(t,10):0,m=s?parseInt(s,10):1/0;return{min:l,max:m}}const r=parseInt(e,10);return{min:r,max:r}},"parseRepeat"),y=n(e=>{const r=A(e.primary);if(!e.repeat)return r;const{min:t,max:s}=b(e.repeat);return t===0&&s===1?{type:"optional",element:r}:{type:"repetition",element:r,min:t,max:s}},"transformElement"),A=n(e=>{switch(e.$type){case"AbnfStringLiteral":return{type:"terminal",value:e.value};case"AbnfNumVal":return{type:"terminal",value:e.value};case"AbnfRuleName":return{type:"nonterminal",name:e.name};case"AbnfGroup":return i(e.element);case"AbnfOptionalGroup":return{type:"optional",element:i(e.element)};default:throw new Error(`Unsupported ABNF primary node: ${e.$type}`)}},"transformPrimary"),P=n(e=>({name:e.name,definition:i(e.definition)}),"transformRule"),h=n(e=>{f(e,a),e.title&&a.setTitle(e.title),e.rules.map(r=>a.addRule(P(r)))},"populateDb"),R={parse:n(e=>{a.clear(),o.debug("[ABNF Parser] Starting Langium parse");const r=v.parse(e);if(r.lexerErrors.length>0||r.parserErrors.length>0)throw new c(r);const t=r.value;o.debug("[ABNF Parser] Parsed rules:",t.rules.length),h(t),o.debug("[ABNF Parser] Parse complete")},"parse"),parser:{yy:a}},B={parser:R,db:a,renderer:u,styles:p};export{B as diagram};
@@ -1 +1 @@
1
- import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-D39fi_iR.js";function cn(l){return l.innerRadius}function gn(l){return l.outerRadius}function yn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,A,C,a){var I=E-l,i=q-h,n=C-v,d=a-A,u=d*I-n*i;if(!(u*u<g))return u=(n*(h-A)-d*(l-v))/u,[l+u*I,h+u*i]}function W(l,h,E,q,v,A,C){var a=l-E,I=h-q,i=(C?A:-A)/L(a*a+I*I),n=i*I,d=-i*a,u=l+n,s=h+d,f=E+n,c=q+d,F=(u+f)/2,t=(s+c)/2,m=f-u,y=c-s,R=m*m+y*y,T=v-A,P=u*c-f*s,O=(y<0?-1:1)*L(on(0,T*T*R-P*P)),S=(P*y-m*O)/R,z=(-P*m-y*O)/R,w=(P*y+m*O)/R,p=(-P*m+y*O)/R,x=S-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(S=w,z=p),{cx:S,cy:z,x01:-n,y01:-d,x11:S*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=gn,E=B(0),q=null,v=yn,A=dn,C=mn,a=null,I=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=I()),s<u&&(d=s,s=u,u=d),!(s>g))a.moveTo(0,0);else if(F>tn-g)a.moveTo(s*H(f),s*j(f)),a.arc(0,0,s,f,c,!t),u>g&&(a.moveTo(u*H(c),u*j(c)),a.arc(0,0,u,c,f,t));else{var m=f,y=c,R=f,T=c,P=F,O=F,S=C.apply(this,arguments)/2,z=S>g&&(q?+q.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(z>g){var G=sn(z/u*j(S)),M=sn(z/s*j(S));(P-=G*2)>g?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(O-=M*2)>g?(M*=t?1:-1,m+=M,y-=M):(O=0,m=y=(f+c)/2)}var J=s*H(m),K=s*j(m),N=u*H(T),Q=u*j(T);if(w>g){var U=s*H(y),V=s*j(y),X=u*H(R),Y=u*j(R),D;if(F<an)if(D=pn(J,K,X,Y,U,V,N,Q)){var Z=J-D[0],$=K-D[1],b=U-D[0],k=V-D[1],nn=1/j(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(D[0]*D[0]+D[1]*D[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}O>g?x>g?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,y,!t)):a.moveTo(J,K),!(u>g)||!(P>g)?a.lineTo(N,Q):p>g?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,j(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:B(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:B(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};
1
+ import{a5 as ln,a6 as an,a7 as H,a8 as j,a9 as B,aa as un,ab as g,ac as tn,ad as L,ae as _,af as rn,ag as o,ah as on,ai as sn,aj as fn}from"./mermaid.core-D_Dp_Kl2.js";function cn(l){return l.innerRadius}function gn(l){return l.outerRadius}function yn(l){return l.startAngle}function dn(l){return l.endAngle}function mn(l){return l&&l.padAngle}function pn(l,h,E,q,v,A,C,a){var I=E-l,i=q-h,n=C-v,d=a-A,u=d*I-n*i;if(!(u*u<g))return u=(n*(h-A)-d*(l-v))/u,[l+u*I,h+u*i]}function W(l,h,E,q,v,A,C){var a=l-E,I=h-q,i=(C?A:-A)/L(a*a+I*I),n=i*I,d=-i*a,u=l+n,s=h+d,f=E+n,c=q+d,F=(u+f)/2,t=(s+c)/2,m=f-u,y=c-s,R=m*m+y*y,T=v-A,P=u*c-f*s,O=(y<0?-1:1)*L(on(0,T*T*R-P*P)),S=(P*y-m*O)/R,z=(-P*m-y*O)/R,w=(P*y+m*O)/R,p=(-P*m+y*O)/R,x=S-F,e=z-t,r=w-F,G=p-t;return x*x+e*e>r*r+G*G&&(S=w,z=p),{cx:S,cy:z,x01:-n,y01:-d,x11:S*(v/T-1),y11:z*(v/T-1)}}function hn(){var l=cn,h=gn,E=B(0),q=null,v=yn,A=dn,C=mn,a=null,I=ln(i);function i(){var n,d,u=+l.apply(this,arguments),s=+h.apply(this,arguments),f=v.apply(this,arguments)-un,c=A.apply(this,arguments)-un,F=rn(c-f),t=c>f;if(a||(a=n=I()),s<u&&(d=s,s=u,u=d),!(s>g))a.moveTo(0,0);else if(F>tn-g)a.moveTo(s*H(f),s*j(f)),a.arc(0,0,s,f,c,!t),u>g&&(a.moveTo(u*H(c),u*j(c)),a.arc(0,0,u,c,f,t));else{var m=f,y=c,R=f,T=c,P=F,O=F,S=C.apply(this,arguments)/2,z=S>g&&(q?+q.apply(this,arguments):L(u*u+s*s)),w=_(rn(s-u)/2,+E.apply(this,arguments)),p=w,x=w,e,r;if(z>g){var G=sn(z/u*j(S)),M=sn(z/s*j(S));(P-=G*2)>g?(G*=t?1:-1,R+=G,T-=G):(P=0,R=T=(f+c)/2),(O-=M*2)>g?(M*=t?1:-1,m+=M,y-=M):(O=0,m=y=(f+c)/2)}var J=s*H(m),K=s*j(m),N=u*H(T),Q=u*j(T);if(w>g){var U=s*H(y),V=s*j(y),X=u*H(R),Y=u*j(R),D;if(F<an)if(D=pn(J,K,X,Y,U,V,N,Q)){var Z=J-D[0],$=K-D[1],b=U-D[0],k=V-D[1],nn=1/j(fn((Z*b+$*k)/(L(Z*Z+$*$)*L(b*b+k*k)))/2),en=L(D[0]*D[0]+D[1]*D[1]);p=_(w,(u-en)/(nn-1)),x=_(w,(s-en)/(nn+1))}else p=x=0}O>g?x>g?(e=W(X,Y,J,K,s,x,t),r=W(U,V,N,Q,s,x,t),a.moveTo(e.cx+e.x01,e.cy+e.y01),x<w?a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,x,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,s,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),!t),a.arc(r.cx,r.cy,x,o(r.y11,r.x11),o(r.y01,r.x01),!t))):(a.moveTo(J,K),a.arc(0,0,s,m,y,!t)):a.moveTo(J,K),!(u>g)||!(P>g)?a.lineTo(N,Q):p>g?(e=W(N,Q,U,V,u,-p,t),r=W(J,K,X,Y,u,-p,t),a.lineTo(e.cx+e.x01,e.cy+e.y01),p<w?a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(r.y01,r.x01),!t):(a.arc(e.cx,e.cy,p,o(e.y01,e.x01),o(e.y11,e.x11),!t),a.arc(0,0,u,o(e.cy+e.y11,e.cx+e.x11),o(r.cy+r.y11,r.cx+r.x11),t),a.arc(r.cx,r.cy,p,o(r.y11,r.x11),o(r.y01,r.x01),!t))):a.arc(0,0,u,T,R,t)}if(a.closePath(),n)return a=null,n+""||null}return i.centroid=function(){var n=(+l.apply(this,arguments)+ +h.apply(this,arguments))/2,d=(+v.apply(this,arguments)+ +A.apply(this,arguments))/2-an/2;return[H(d)*n,j(d)*n]},i.innerRadius=function(n){return arguments.length?(l=typeof n=="function"?n:B(+n),i):l},i.outerRadius=function(n){return arguments.length?(h=typeof n=="function"?n:B(+n),i):h},i.cornerRadius=function(n){return arguments.length?(E=typeof n=="function"?n:B(+n),i):E},i.padRadius=function(n){return arguments.length?(q=n==null?null:typeof n=="function"?n:B(+n),i):q},i.startAngle=function(n){return arguments.length?(v=typeof n=="function"?n:B(+n),i):v},i.endAngle=function(n){return arguments.length?(A=typeof n=="function"?n:B(+n),i):A},i.padAngle=function(n){return arguments.length?(C=typeof n=="function"?n:B(+n),i):C},i.context=function(n){return arguments.length?(a=n??null,i):a},i}export{hn as d};