mewkit 1.15.0 → 1.16.1

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 (494) hide show
  1. package/NOTICE +24 -0
  2. package/README.md +29 -70
  3. package/dist/commands/visual-plan.d.ts +23 -0
  4. package/dist/commands/visual-plan.d.ts.map +1 -0
  5. package/dist/commands/visual-plan.js +26 -0
  6. package/dist/commands/visual-plan.js.map +1 -0
  7. package/dist/core/capability.d.ts +81 -81
  8. package/dist/core/consolidation-ledger.d.ts.map +1 -1
  9. package/dist/core/consolidation-ledger.js +13 -11
  10. package/dist/core/consolidation-ledger.js.map +1 -1
  11. package/dist/core/install-metadata.d.ts +27 -27
  12. package/dist/core/plugin-manifest.d.ts +16 -16
  13. package/dist/core/release-metadata.d.ts +2 -2
  14. package/dist/core/task-record.d.ts +8 -8
  15. package/dist/index.js +33 -21
  16. package/dist/index.js.map +1 -1
  17. package/dist/local-web/atomic-write.d.ts +15 -0
  18. package/dist/local-web/atomic-write.d.ts.map +1 -0
  19. package/dist/local-web/atomic-write.js +69 -0
  20. package/dist/local-web/atomic-write.js.map +1 -0
  21. package/dist/local-web/constants.d.ts +13 -0
  22. package/dist/local-web/constants.d.ts.map +1 -0
  23. package/dist/local-web/constants.js +13 -0
  24. package/dist/local-web/constants.js.map +1 -0
  25. package/dist/local-web/etag.d.ts +19 -0
  26. package/dist/local-web/etag.d.ts.map +1 -0
  27. package/dist/local-web/etag.js +32 -0
  28. package/dist/local-web/etag.js.map +1 -0
  29. package/dist/local-web/host-guard.d.ts +12 -0
  30. package/dist/local-web/host-guard.d.ts.map +1 -0
  31. package/dist/local-web/host-guard.js +18 -0
  32. package/dist/local-web/host-guard.js.map +1 -0
  33. package/dist/local-web/index.d.ts +23 -0
  34. package/dist/local-web/index.d.ts.map +1 -0
  35. package/dist/local-web/index.js +23 -0
  36. package/dist/local-web/index.js.map +1 -0
  37. package/dist/local-web/local-server.d.ts +37 -0
  38. package/dist/local-web/local-server.d.ts.map +1 -0
  39. package/dist/local-web/local-server.js +85 -0
  40. package/dist/local-web/local-server.js.map +1 -0
  41. package/dist/local-web/open-browser.d.ts +12 -0
  42. package/dist/local-web/open-browser.d.ts.map +1 -0
  43. package/dist/{orchviz/open-url.js → local-web/open-browser.js} +9 -8
  44. package/dist/local-web/open-browser.js.map +1 -0
  45. package/dist/local-web/origin-guard.d.ts +11 -0
  46. package/dist/local-web/origin-guard.d.ts.map +1 -0
  47. package/dist/local-web/origin-guard.js +15 -0
  48. package/dist/local-web/origin-guard.js.map +1 -0
  49. package/dist/local-web/path-boundary.d.ts +20 -0
  50. package/dist/local-web/path-boundary.d.ts.map +1 -0
  51. package/dist/local-web/path-boundary.js +39 -0
  52. package/dist/local-web/path-boundary.js.map +1 -0
  53. package/dist/local-web/request-body.d.ts +24 -0
  54. package/dist/local-web/request-body.d.ts.map +1 -0
  55. package/dist/local-web/request-body.js +68 -0
  56. package/dist/local-web/request-body.js.map +1 -0
  57. package/dist/local-web/static-handler.d.ts +14 -0
  58. package/dist/local-web/static-handler.d.ts.map +1 -0
  59. package/dist/{orchviz/server → local-web}/static-handler.js +11 -6
  60. package/dist/local-web/static-handler.js.map +1 -0
  61. package/dist/migrate/reconcile/portable-manifest.d.ts +12 -12
  62. package/dist/migrate/reconcile/portable-registry.d.ts +24 -24
  63. package/dist/migrate/types.d.ts +10 -10
  64. package/dist/{orchviz/token-estimator.d.ts → token-estimator/index.d.ts} +6 -1
  65. package/dist/token-estimator/index.d.ts.map +1 -0
  66. package/dist/{orchviz/token-estimator.js → token-estimator/index.js} +11 -2
  67. package/dist/token-estimator/index.js.map +1 -0
  68. package/dist/visual-plan/__fixtures__/valid-plan.d.ts +15 -0
  69. package/dist/visual-plan/__fixtures__/valid-plan.d.ts.map +1 -0
  70. package/dist/visual-plan/__fixtures__/valid-plan.js +79 -0
  71. package/dist/visual-plan/__fixtures__/valid-plan.js.map +1 -0
  72. package/dist/visual-plan/application/apply-feedback.d.ts +31 -0
  73. package/dist/visual-plan/application/apply-feedback.d.ts.map +1 -0
  74. package/dist/visual-plan/application/apply-feedback.js +85 -0
  75. package/dist/visual-plan/application/apply-feedback.js.map +1 -0
  76. package/dist/visual-plan/application/apply-patch-op.d.ts +13 -0
  77. package/dist/visual-plan/application/apply-patch-op.d.ts.map +1 -0
  78. package/dist/visual-plan/application/apply-patch-op.js +72 -0
  79. package/dist/visual-plan/application/apply-patch-op.js.map +1 -0
  80. package/dist/visual-plan/application/approve.d.ts +24 -0
  81. package/dist/visual-plan/application/approve.d.ts.map +1 -0
  82. package/dist/visual-plan/application/approve.js +53 -0
  83. package/dist/visual-plan/application/approve.js.map +1 -0
  84. package/dist/visual-plan/application/clock.d.ts +8 -0
  85. package/dist/visual-plan/application/clock.d.ts.map +1 -0
  86. package/dist/visual-plan/application/clock.js +10 -0
  87. package/dist/visual-plan/application/clock.js.map +1 -0
  88. package/dist/visual-plan/application/export-plan.d.ts +19 -0
  89. package/dist/visual-plan/application/export-plan.d.ts.map +1 -0
  90. package/dist/visual-plan/application/export-plan.js +74 -0
  91. package/dist/visual-plan/application/export-plan.js.map +1 -0
  92. package/dist/visual-plan/application/patch-plan.d.ts +26 -0
  93. package/dist/visual-plan/application/patch-plan.d.ts.map +1 -0
  94. package/dist/visual-plan/application/patch-plan.js +48 -0
  95. package/dist/visual-plan/application/patch-plan.js.map +1 -0
  96. package/dist/visual-plan/application/prepare-feedback.d.ts +24 -0
  97. package/dist/visual-plan/application/prepare-feedback.d.ts.map +1 -0
  98. package/dist/visual-plan/application/prepare-feedback.js +70 -0
  99. package/dist/visual-plan/application/prepare-feedback.js.map +1 -0
  100. package/dist/visual-plan/application/rehash.d.ts +19 -0
  101. package/dist/visual-plan/application/rehash.d.ts.map +1 -0
  102. package/dist/visual-plan/application/rehash.js +43 -0
  103. package/dist/visual-plan/application/rehash.js.map +1 -0
  104. package/dist/visual-plan/application/status.d.ts +20 -0
  105. package/dist/visual-plan/application/status.d.ts.map +1 -0
  106. package/dist/visual-plan/application/status.js +27 -0
  107. package/dist/visual-plan/application/status.js.map +1 -0
  108. package/dist/visual-plan/application/validate-plan.d.ts +30 -0
  109. package/dist/visual-plan/application/validate-plan.d.ts.map +1 -0
  110. package/dist/visual-plan/application/validate-plan.js +59 -0
  111. package/dist/visual-plan/application/validate-plan.js.map +1 -0
  112. package/dist/visual-plan/domain/coverage.d.ts +35 -0
  113. package/dist/visual-plan/domain/coverage.d.ts.map +1 -0
  114. package/dist/visual-plan/domain/coverage.js +99 -0
  115. package/dist/visual-plan/domain/coverage.js.map +1 -0
  116. package/dist/visual-plan/domain/cross-refs.d.ts +20 -0
  117. package/dist/visual-plan/domain/cross-refs.d.ts.map +1 -0
  118. package/dist/visual-plan/domain/cross-refs.js +92 -0
  119. package/dist/visual-plan/domain/cross-refs.js.map +1 -0
  120. package/dist/visual-plan/domain/errors.d.ts +43 -0
  121. package/dist/visual-plan/domain/errors.d.ts.map +1 -0
  122. package/dist/visual-plan/domain/errors.js +33 -0
  123. package/dist/visual-plan/domain/errors.js.map +1 -0
  124. package/dist/visual-plan/domain/feedback-schemas.d.ts +160 -0
  125. package/dist/visual-plan/domain/feedback-schemas.d.ts.map +1 -0
  126. package/dist/visual-plan/domain/feedback-schemas.js +71 -0
  127. package/dist/visual-plan/domain/feedback-schemas.js.map +1 -0
  128. package/dist/visual-plan/domain/ids.d.ts +21 -0
  129. package/dist/visual-plan/domain/ids.d.ts.map +1 -0
  130. package/dist/visual-plan/domain/ids.js +25 -0
  131. package/dist/visual-plan/domain/ids.js.map +1 -0
  132. package/dist/visual-plan/domain/patches.d.ts +176 -0
  133. package/dist/visual-plan/domain/patches.d.ts.map +1 -0
  134. package/dist/visual-plan/domain/patches.js +41 -0
  135. package/dist/visual-plan/domain/patches.js.map +1 -0
  136. package/dist/visual-plan/domain/sanitizer-config.d.ts +61 -0
  137. package/dist/visual-plan/domain/sanitizer-config.d.ts.map +1 -0
  138. package/dist/visual-plan/domain/sanitizer-config.js +70 -0
  139. package/dist/visual-plan/domain/sanitizer-config.js.map +1 -0
  140. package/dist/visual-plan/domain/schemas.d.ts +1492 -0
  141. package/dist/visual-plan/domain/schemas.d.ts.map +1 -0
  142. package/dist/visual-plan/domain/schemas.js +166 -0
  143. package/dist/visual-plan/domain/schemas.js.map +1 -0
  144. package/dist/visual-plan/domain/wireframe-theme.d.ts +24 -0
  145. package/dist/visual-plan/domain/wireframe-theme.d.ts.map +1 -0
  146. package/dist/visual-plan/domain/wireframe-theme.js +169 -0
  147. package/dist/visual-plan/domain/wireframe-theme.js.map +1 -0
  148. package/dist/visual-plan/infrastructure/atomic-write.d.ts +11 -0
  149. package/dist/visual-plan/infrastructure/atomic-write.d.ts.map +1 -0
  150. package/dist/visual-plan/infrastructure/atomic-write.js +44 -0
  151. package/dist/visual-plan/infrastructure/atomic-write.js.map +1 -0
  152. package/dist/visual-plan/infrastructure/feedback-repository.d.ts +18 -0
  153. package/dist/visual-plan/infrastructure/feedback-repository.d.ts.map +1 -0
  154. package/dist/visual-plan/infrastructure/feedback-repository.js +59 -0
  155. package/dist/visual-plan/infrastructure/feedback-repository.js.map +1 -0
  156. package/dist/visual-plan/infrastructure/hashing.d.ts +37 -0
  157. package/dist/visual-plan/infrastructure/hashing.d.ts.map +1 -0
  158. package/dist/visual-plan/infrastructure/hashing.js +81 -0
  159. package/dist/visual-plan/infrastructure/hashing.js.map +1 -0
  160. package/dist/visual-plan/infrastructure/plan-state.d.ts +32 -0
  161. package/dist/visual-plan/infrastructure/plan-state.d.ts.map +1 -0
  162. package/dist/visual-plan/infrastructure/plan-state.js +58 -0
  163. package/dist/visual-plan/infrastructure/plan-state.js.map +1 -0
  164. package/dist/visual-plan/infrastructure/receipt-repository.d.ts +17 -0
  165. package/dist/visual-plan/infrastructure/receipt-repository.d.ts.map +1 -0
  166. package/dist/visual-plan/infrastructure/receipt-repository.js +59 -0
  167. package/dist/visual-plan/infrastructure/receipt-repository.js.map +1 -0
  168. package/dist/visual-plan/infrastructure/visual-plan-repository.d.ts +38 -0
  169. package/dist/visual-plan/infrastructure/visual-plan-repository.d.ts.map +1 -0
  170. package/dist/visual-plan/infrastructure/visual-plan-repository.js +97 -0
  171. package/dist/visual-plan/infrastructure/visual-plan-repository.js.map +1 -0
  172. package/dist/visual-plan/infrastructure/wireframe-sanitizer.d.ts +41 -0
  173. package/dist/visual-plan/infrastructure/wireframe-sanitizer.d.ts.map +1 -0
  174. package/dist/visual-plan/infrastructure/wireframe-sanitizer.js +72 -0
  175. package/dist/visual-plan/infrastructure/wireframe-sanitizer.js.map +1 -0
  176. package/dist/visual-plan/interface/cli.d.ts +29 -0
  177. package/dist/visual-plan/interface/cli.d.ts.map +1 -0
  178. package/dist/visual-plan/interface/cli.js +280 -0
  179. package/dist/visual-plan/interface/cli.js.map +1 -0
  180. package/dist/visual-plan/interface/studio.d.ts +20 -0
  181. package/dist/visual-plan/interface/studio.d.ts.map +1 -0
  182. package/dist/visual-plan/interface/studio.js +74 -0
  183. package/dist/visual-plan/interface/studio.js.map +1 -0
  184. package/dist/visual-plan/server/csp.d.ts +13 -0
  185. package/dist/visual-plan/server/csp.d.ts.map +1 -0
  186. package/dist/visual-plan/server/csp.js +17 -0
  187. package/dist/visual-plan/server/csp.js.map +1 -0
  188. package/dist/visual-plan/server/edit-lock.d.ts +28 -0
  189. package/dist/visual-plan/server/edit-lock.d.ts.map +1 -0
  190. package/dist/visual-plan/server/edit-lock.js +71 -0
  191. package/dist/visual-plan/server/edit-lock.js.map +1 -0
  192. package/dist/visual-plan/server/routes/feedback.d.ts +12 -0
  193. package/dist/visual-plan/server/routes/feedback.d.ts.map +1 -0
  194. package/dist/visual-plan/server/routes/feedback.js +63 -0
  195. package/dist/visual-plan/server/routes/feedback.js.map +1 -0
  196. package/dist/visual-plan/server/routes/get-plan.d.ts +14 -0
  197. package/dist/visual-plan/server/routes/get-plan.d.ts.map +1 -0
  198. package/dist/visual-plan/server/routes/get-plan.js +38 -0
  199. package/dist/visual-plan/server/routes/get-plan.js.map +1 -0
  200. package/dist/visual-plan/server/routes/patch.d.ts +10 -0
  201. package/dist/visual-plan/server/routes/patch.d.ts.map +1 -0
  202. package/dist/visual-plan/server/routes/patch.js +66 -0
  203. package/dist/visual-plan/server/routes/patch.js.map +1 -0
  204. package/dist/visual-plan/server/visual-plan-server.d.ts +30 -0
  205. package/dist/visual-plan/server/visual-plan-server.d.ts.map +1 -0
  206. package/dist/visual-plan/server/visual-plan-server.js +79 -0
  207. package/dist/visual-plan/server/visual-plan-server.js.map +1 -0
  208. package/dist/visual-plan-web/architects-daughter-latin-400-normal.woff +0 -0
  209. package/dist/visual-plan-web/architects-daughter-latin-400-normal.woff2 +0 -0
  210. package/dist/visual-plan-web/architects-daughter-latin-ext-400-normal.woff +0 -0
  211. package/dist/visual-plan-web/architects-daughter-latin-ext-400-normal.woff2 +0 -0
  212. package/dist/visual-plan-web/index.css +1 -0
  213. package/dist/visual-plan-web/index.html +17 -0
  214. package/dist/visual-plan-web/index.js +187 -0
  215. package/package.json +15 -18
  216. package/dist/commands/orchviz.d.ts +0 -12
  217. package/dist/commands/orchviz.d.ts.map +0 -1
  218. package/dist/commands/orchviz.js +0 -157
  219. package/dist/commands/orchviz.js.map +0 -1
  220. package/dist/migrate/converters/md-to-codex-rules.d.ts +0 -10
  221. package/dist/migrate/converters/md-to-codex-rules.d.ts.map +0 -1
  222. package/dist/migrate/converters/md-to-codex-rules.js +0 -133
  223. package/dist/migrate/converters/md-to-codex-rules.js.map +0 -1
  224. package/dist/orchviz/constants.d.ts +0 -72
  225. package/dist/orchviz/constants.d.ts.map +0 -1
  226. package/dist/orchviz/constants.js +0 -105
  227. package/dist/orchviz/constants.js.map +0 -1
  228. package/dist/orchviz/fs-utils.d.ts +0 -24
  229. package/dist/orchviz/fs-utils.d.ts.map +0 -1
  230. package/dist/orchviz/fs-utils.js +0 -49
  231. package/dist/orchviz/fs-utils.js.map +0 -1
  232. package/dist/orchviz/index.d.ts +0 -29
  233. package/dist/orchviz/index.d.ts.map +0 -1
  234. package/dist/orchviz/index.js +0 -28
  235. package/dist/orchviz/index.js.map +0 -1
  236. package/dist/orchviz/log-persister.d.ts +0 -22
  237. package/dist/orchviz/log-persister.d.ts.map +0 -1
  238. package/dist/orchviz/log-persister.js +0 -96
  239. package/dist/orchviz/log-persister.js.map +0 -1
  240. package/dist/orchviz/logger.d.ts +0 -13
  241. package/dist/orchviz/logger.d.ts.map +0 -1
  242. package/dist/orchviz/logger.js +0 -47
  243. package/dist/orchviz/logger.js.map +0 -1
  244. package/dist/orchviz/open-url.d.ts +0 -11
  245. package/dist/orchviz/open-url.d.ts.map +0 -1
  246. package/dist/orchviz/open-url.js.map +0 -1
  247. package/dist/orchviz/overlay/collector.d.ts +0 -29
  248. package/dist/orchviz/overlay/collector.d.ts.map +0 -1
  249. package/dist/orchviz/overlay/collector.js +0 -38
  250. package/dist/orchviz/overlay/collector.js.map +0 -1
  251. package/dist/orchviz/overlay/gate-readers.d.ts +0 -18
  252. package/dist/orchviz/overlay/gate-readers.d.ts.map +0 -1
  253. package/dist/orchviz/overlay/gate-readers.js +0 -111
  254. package/dist/orchviz/overlay/gate-readers.js.map +0 -1
  255. package/dist/orchviz/overlay/session-state-readers.d.ts +0 -18
  256. package/dist/orchviz/overlay/session-state-readers.d.ts.map +0 -1
  257. package/dist/orchviz/overlay/session-state-readers.js +0 -78
  258. package/dist/orchviz/overlay/session-state-readers.js.map +0 -1
  259. package/dist/orchviz/parser/handle-progress.d.ts +0 -9
  260. package/dist/orchviz/parser/handle-progress.d.ts.map +0 -1
  261. package/dist/orchviz/parser/handle-progress.js +0 -38
  262. package/dist/orchviz/parser/handle-progress.js.map +0 -1
  263. package/dist/orchviz/parser/handle-system.d.ts +0 -22
  264. package/dist/orchviz/parser/handle-system.d.ts.map +0 -1
  265. package/dist/orchviz/parser/handle-system.js +0 -99
  266. package/dist/orchviz/parser/handle-system.js.map +0 -1
  267. package/dist/orchviz/parser/handle-text.d.ts +0 -10
  268. package/dist/orchviz/parser/handle-text.d.ts.map +0 -1
  269. package/dist/orchviz/parser/handle-text.js +0 -83
  270. package/dist/orchviz/parser/handle-text.js.map +0 -1
  271. package/dist/orchviz/parser/handle-thinking.d.ts +0 -10
  272. package/dist/orchviz/parser/handle-thinking.d.ts.map +0 -1
  273. package/dist/orchviz/parser/handle-thinking.js +0 -35
  274. package/dist/orchviz/parser/handle-thinking.js.map +0 -1
  275. package/dist/orchviz/parser/handle-tool-result.d.ts +0 -10
  276. package/dist/orchviz/parser/handle-tool-result.d.ts.map +0 -1
  277. package/dist/orchviz/parser/handle-tool-result.js +0 -130
  278. package/dist/orchviz/parser/handle-tool-result.js.map +0 -1
  279. package/dist/orchviz/parser/handle-tool-use.d.ts +0 -11
  280. package/dist/orchviz/parser/handle-tool-use.d.ts.map +0 -1
  281. package/dist/orchviz/parser/handle-tool-use.js +0 -120
  282. package/dist/orchviz/parser/handle-tool-use.js.map +0 -1
  283. package/dist/orchviz/parser/index.d.ts +0 -38
  284. package/dist/orchviz/parser/index.d.ts.map +0 -1
  285. package/dist/orchviz/parser/index.js +0 -144
  286. package/dist/orchviz/parser/index.js.map +0 -1
  287. package/dist/orchviz/parser/label-helpers.d.ts +0 -9
  288. package/dist/orchviz/parser/label-helpers.d.ts.map +0 -1
  289. package/dist/orchviz/parser/label-helpers.js +0 -44
  290. package/dist/orchviz/parser/label-helpers.js.map +0 -1
  291. package/dist/orchviz/parser/strip-ansi.d.ts +0 -6
  292. package/dist/orchviz/parser/strip-ansi.d.ts.map +0 -1
  293. package/dist/orchviz/parser/strip-ansi.js +0 -14
  294. package/dist/orchviz/parser/strip-ansi.js.map +0 -1
  295. package/dist/orchviz/parser/utils.d.ts +0 -20
  296. package/dist/orchviz/parser/utils.d.ts.map +0 -1
  297. package/dist/orchviz/parser/utils.js +0 -54
  298. package/dist/orchviz/parser/utils.js.map +0 -1
  299. package/dist/orchviz/permission-detection.d.ts +0 -32
  300. package/dist/orchviz/permission-detection.d.ts.map +0 -1
  301. package/dist/orchviz/permission-detection.js +0 -104
  302. package/dist/orchviz/permission-detection.js.map +0 -1
  303. package/dist/orchviz/plan/apply-todo-toggle.d.ts +0 -29
  304. package/dist/orchviz/plan/apply-todo-toggle.d.ts.map +0 -1
  305. package/dist/orchviz/plan/apply-todo-toggle.js +0 -129
  306. package/dist/orchviz/plan/apply-todo-toggle.js.map +0 -1
  307. package/dist/orchviz/plan/atomic-write.d.ts +0 -25
  308. package/dist/orchviz/plan/atomic-write.d.ts.map +0 -1
  309. package/dist/orchviz/plan/atomic-write.js +0 -85
  310. package/dist/orchviz/plan/atomic-write.js.map +0 -1
  311. package/dist/orchviz/plan/collector.d.ts +0 -49
  312. package/dist/orchviz/plan/collector.d.ts.map +0 -1
  313. package/dist/orchviz/plan/collector.js +0 -169
  314. package/dist/orchviz/plan/collector.js.map +0 -1
  315. package/dist/orchviz/plan/etag.d.ts +0 -24
  316. package/dist/orchviz/plan/etag.d.ts.map +0 -1
  317. package/dist/orchviz/plan/etag.js +0 -58
  318. package/dist/orchviz/plan/etag.js.map +0 -1
  319. package/dist/orchviz/plan/find-active-plan.d.ts +0 -9
  320. package/dist/orchviz/plan/find-active-plan.d.ts.map +0 -1
  321. package/dist/orchviz/plan/find-active-plan.js +0 -90
  322. package/dist/orchviz/plan/find-active-plan.js.map +0 -1
  323. package/dist/orchviz/plan/index.d.ts +0 -23
  324. package/dist/orchviz/plan/index.d.ts.map +0 -1
  325. package/dist/orchviz/plan/index.js +0 -91
  326. package/dist/orchviz/plan/index.js.map +0 -1
  327. package/dist/orchviz/plan/list-plans.d.ts +0 -19
  328. package/dist/orchviz/plan/list-plans.d.ts.map +0 -1
  329. package/dist/orchviz/plan/list-plans.js +0 -143
  330. package/dist/orchviz/plan/list-plans.js.map +0 -1
  331. package/dist/orchviz/plan/parse-phase-file.d.ts +0 -13
  332. package/dist/orchviz/plan/parse-phase-file.d.ts.map +0 -1
  333. package/dist/orchviz/plan/parse-phase-file.js +0 -134
  334. package/dist/orchviz/plan/parse-phase-file.js.map +0 -1
  335. package/dist/orchviz/plan/parse-plan-file.d.ts +0 -19
  336. package/dist/orchviz/plan/parse-plan-file.d.ts.map +0 -1
  337. package/dist/orchviz/plan/parse-plan-file.js +0 -62
  338. package/dist/orchviz/plan/parse-plan-file.js.map +0 -1
  339. package/dist/orchviz/plan/plan-constants.d.ts +0 -17
  340. package/dist/orchviz/plan/plan-constants.d.ts.map +0 -1
  341. package/dist/orchviz/plan/plan-constants.js +0 -19
  342. package/dist/orchviz/plan/plan-constants.js.map +0 -1
  343. package/dist/orchviz/plan/plan-lifecycle.d.ts +0 -17
  344. package/dist/orchviz/plan/plan-lifecycle.d.ts.map +0 -1
  345. package/dist/orchviz/plan/plan-lifecycle.js +0 -97
  346. package/dist/orchviz/plan/plan-lifecycle.js.map +0 -1
  347. package/dist/orchviz/plan/types.d.ts +0 -46
  348. package/dist/orchviz/plan/types.d.ts.map +0 -1
  349. package/dist/orchviz/plan/types.js +0 -6
  350. package/dist/orchviz/plan/types.js.map +0 -1
  351. package/dist/orchviz/protocol.d.ts +0 -171
  352. package/dist/orchviz/protocol.d.ts.map +0 -1
  353. package/dist/orchviz/protocol.js +0 -23
  354. package/dist/orchviz/protocol.js.map +0 -1
  355. package/dist/orchviz/redact.d.ts +0 -10
  356. package/dist/orchviz/redact.d.ts.map +0 -1
  357. package/dist/orchviz/redact.js +0 -38
  358. package/dist/orchviz/redact.js.map +0 -1
  359. package/dist/orchviz/sanitize.d.ts +0 -11
  360. package/dist/orchviz/sanitize.d.ts.map +0 -1
  361. package/dist/orchviz/sanitize.js +0 -38
  362. package/dist/orchviz/sanitize.js.map +0 -1
  363. package/dist/orchviz/server/api-handlers.d.ts +0 -55
  364. package/dist/orchviz/server/api-handlers.d.ts.map +0 -1
  365. package/dist/orchviz/server/api-handlers.js +0 -112
  366. package/dist/orchviz/server/api-handlers.js.map +0 -1
  367. package/dist/orchviz/server/index.d.ts +0 -36
  368. package/dist/orchviz/server/index.d.ts.map +0 -1
  369. package/dist/orchviz/server/index.js +0 -144
  370. package/dist/orchviz/server/index.js.map +0 -1
  371. package/dist/orchviz/server/sse-handler.d.ts +0 -28
  372. package/dist/orchviz/server/sse-handler.d.ts.map +0 -1
  373. package/dist/orchviz/server/sse-handler.js +0 -217
  374. package/dist/orchviz/server/sse-handler.js.map +0 -1
  375. package/dist/orchviz/server/static-handler.d.ts +0 -9
  376. package/dist/orchviz/server/static-handler.d.ts.map +0 -1
  377. package/dist/orchviz/server/static-handler.js.map +0 -1
  378. package/dist/orchviz/server/write-handlers.d.ts +0 -20
  379. package/dist/orchviz/server/write-handlers.d.ts.map +0 -1
  380. package/dist/orchviz/server/write-handlers.js +0 -184
  381. package/dist/orchviz/server/write-handlers.js.map +0 -1
  382. package/dist/orchviz/server/write-utils.d.ts +0 -59
  383. package/dist/orchviz/server/write-utils.d.ts.map +0 -1
  384. package/dist/orchviz/server/write-utils.js +0 -161
  385. package/dist/orchviz/server/write-utils.js.map +0 -1
  386. package/dist/orchviz/session-discovery.d.ts +0 -19
  387. package/dist/orchviz/session-discovery.d.ts.map +0 -1
  388. package/dist/orchviz/session-discovery.js +0 -104
  389. package/dist/orchviz/session-discovery.js.map +0 -1
  390. package/dist/orchviz/session-manager.d.ts +0 -17
  391. package/dist/orchviz/session-manager.d.ts.map +0 -1
  392. package/dist/orchviz/session-manager.js +0 -63
  393. package/dist/orchviz/session-manager.js.map +0 -1
  394. package/dist/orchviz/session-runtime.d.ts +0 -21
  395. package/dist/orchviz/session-runtime.d.ts.map +0 -1
  396. package/dist/orchviz/session-runtime.js +0 -135
  397. package/dist/orchviz/session-runtime.js.map +0 -1
  398. package/dist/orchviz/session-watcher.d.ts +0 -33
  399. package/dist/orchviz/session-watcher.d.ts.map +0 -1
  400. package/dist/orchviz/session-watcher.js +0 -135
  401. package/dist/orchviz/session-watcher.js.map +0 -1
  402. package/dist/orchviz/subagent-meta.d.ts +0 -12
  403. package/dist/orchviz/subagent-meta.d.ts.map +0 -1
  404. package/dist/orchviz/subagent-meta.js +0 -34
  405. package/dist/orchviz/subagent-meta.js.map +0 -1
  406. package/dist/orchviz/subagent-scanner.d.ts +0 -15
  407. package/dist/orchviz/subagent-scanner.d.ts.map +0 -1
  408. package/dist/orchviz/subagent-scanner.js +0 -27
  409. package/dist/orchviz/subagent-scanner.js.map +0 -1
  410. package/dist/orchviz/subagent-watcher.d.ts +0 -20
  411. package/dist/orchviz/subagent-watcher.d.ts.map +0 -1
  412. package/dist/orchviz/subagent-watcher.js +0 -160
  413. package/dist/orchviz/subagent-watcher.js.map +0 -1
  414. package/dist/orchviz/token-estimator.d.ts.map +0 -1
  415. package/dist/orchviz/token-estimator.js.map +0 -1
  416. package/dist/orchviz/tool-input-data.d.ts +0 -11
  417. package/dist/orchviz/tool-input-data.d.ts.map +0 -1
  418. package/dist/orchviz/tool-input-data.js +0 -74
  419. package/dist/orchviz/tool-input-data.js.map +0 -1
  420. package/dist/orchviz/tool-summarizer.d.ts +0 -16
  421. package/dist/orchviz/tool-summarizer.d.ts.map +0 -1
  422. package/dist/orchviz/tool-summarizer.js +0 -129
  423. package/dist/orchviz/tool-summarizer.js.map +0 -1
  424. package/dist/orchviz-web/fira-code-cyrillic-400-normal.woff +0 -0
  425. package/dist/orchviz-web/fira-code-cyrillic-400-normal.woff2 +0 -0
  426. package/dist/orchviz-web/fira-code-cyrillic-500-normal.woff +0 -0
  427. package/dist/orchviz-web/fira-code-cyrillic-500-normal.woff2 +0 -0
  428. package/dist/orchviz-web/fira-code-cyrillic-ext-400-normal.woff +0 -0
  429. package/dist/orchviz-web/fira-code-cyrillic-ext-400-normal.woff2 +0 -0
  430. package/dist/orchviz-web/fira-code-cyrillic-ext-500-normal.woff +0 -0
  431. package/dist/orchviz-web/fira-code-cyrillic-ext-500-normal.woff2 +0 -0
  432. package/dist/orchviz-web/fira-code-greek-400-normal.woff +0 -0
  433. package/dist/orchviz-web/fira-code-greek-400-normal.woff2 +0 -0
  434. package/dist/orchviz-web/fira-code-greek-500-normal.woff +0 -0
  435. package/dist/orchviz-web/fira-code-greek-500-normal.woff2 +0 -0
  436. package/dist/orchviz-web/fira-code-greek-ext-400-normal.woff +0 -0
  437. package/dist/orchviz-web/fira-code-greek-ext-400-normal.woff2 +0 -0
  438. package/dist/orchviz-web/fira-code-greek-ext-500-normal.woff +0 -0
  439. package/dist/orchviz-web/fira-code-greek-ext-500-normal.woff2 +0 -0
  440. package/dist/orchviz-web/fira-code-latin-400-normal.woff +0 -0
  441. package/dist/orchviz-web/fira-code-latin-400-normal.woff2 +0 -0
  442. package/dist/orchviz-web/fira-code-latin-500-normal.woff +0 -0
  443. package/dist/orchviz-web/fira-code-latin-500-normal.woff2 +0 -0
  444. package/dist/orchviz-web/fira-code-latin-ext-400-normal.woff +0 -0
  445. package/dist/orchviz-web/fira-code-latin-ext-400-normal.woff2 +0 -0
  446. package/dist/orchviz-web/fira-code-latin-ext-500-normal.woff +0 -0
  447. package/dist/orchviz-web/fira-code-latin-ext-500-normal.woff2 +0 -0
  448. package/dist/orchviz-web/fira-code-symbols2-400-normal.woff +0 -0
  449. package/dist/orchviz-web/fira-code-symbols2-500-normal.woff +0 -0
  450. package/dist/orchviz-web/index.css +0 -1
  451. package/dist/orchviz-web/index.html +0 -18
  452. package/dist/orchviz-web/index.js +0 -53
  453. package/dist/orchviz-web/inter-cyrillic-400-normal.woff +0 -0
  454. package/dist/orchviz-web/inter-cyrillic-400-normal.woff2 +0 -0
  455. package/dist/orchviz-web/inter-cyrillic-500-normal.woff +0 -0
  456. package/dist/orchviz-web/inter-cyrillic-500-normal.woff2 +0 -0
  457. package/dist/orchviz-web/inter-cyrillic-600-normal.woff +0 -0
  458. package/dist/orchviz-web/inter-cyrillic-600-normal.woff2 +0 -0
  459. package/dist/orchviz-web/inter-cyrillic-ext-400-normal.woff +0 -0
  460. package/dist/orchviz-web/inter-cyrillic-ext-400-normal.woff2 +0 -0
  461. package/dist/orchviz-web/inter-cyrillic-ext-500-normal.woff +0 -0
  462. package/dist/orchviz-web/inter-cyrillic-ext-500-normal.woff2 +0 -0
  463. package/dist/orchviz-web/inter-cyrillic-ext-600-normal.woff +0 -0
  464. package/dist/orchviz-web/inter-cyrillic-ext-600-normal.woff2 +0 -0
  465. package/dist/orchviz-web/inter-greek-400-normal.woff +0 -0
  466. package/dist/orchviz-web/inter-greek-400-normal.woff2 +0 -0
  467. package/dist/orchviz-web/inter-greek-500-normal.woff +0 -0
  468. package/dist/orchviz-web/inter-greek-500-normal.woff2 +0 -0
  469. package/dist/orchviz-web/inter-greek-600-normal.woff +0 -0
  470. package/dist/orchviz-web/inter-greek-600-normal.woff2 +0 -0
  471. package/dist/orchviz-web/inter-greek-ext-400-normal.woff +0 -0
  472. package/dist/orchviz-web/inter-greek-ext-400-normal.woff2 +0 -0
  473. package/dist/orchviz-web/inter-greek-ext-500-normal.woff +0 -0
  474. package/dist/orchviz-web/inter-greek-ext-500-normal.woff2 +0 -0
  475. package/dist/orchviz-web/inter-greek-ext-600-normal.woff +0 -0
  476. package/dist/orchviz-web/inter-greek-ext-600-normal.woff2 +0 -0
  477. package/dist/orchviz-web/inter-latin-400-normal.woff +0 -0
  478. package/dist/orchviz-web/inter-latin-400-normal.woff2 +0 -0
  479. package/dist/orchviz-web/inter-latin-500-normal.woff +0 -0
  480. package/dist/orchviz-web/inter-latin-500-normal.woff2 +0 -0
  481. package/dist/orchviz-web/inter-latin-600-normal.woff +0 -0
  482. package/dist/orchviz-web/inter-latin-600-normal.woff2 +0 -0
  483. package/dist/orchviz-web/inter-latin-ext-400-normal.woff +0 -0
  484. package/dist/orchviz-web/inter-latin-ext-400-normal.woff2 +0 -0
  485. package/dist/orchviz-web/inter-latin-ext-500-normal.woff +0 -0
  486. package/dist/orchviz-web/inter-latin-ext-500-normal.woff2 +0 -0
  487. package/dist/orchviz-web/inter-latin-ext-600-normal.woff +0 -0
  488. package/dist/orchviz-web/inter-latin-ext-600-normal.woff2 +0 -0
  489. package/dist/orchviz-web/inter-vietnamese-400-normal.woff +0 -0
  490. package/dist/orchviz-web/inter-vietnamese-400-normal.woff2 +0 -0
  491. package/dist/orchviz-web/inter-vietnamese-500-normal.woff +0 -0
  492. package/dist/orchviz-web/inter-vietnamese-500-normal.woff2 +0 -0
  493. package/dist/orchviz-web/inter-vietnamese-600-normal.woff +0 -0
  494. package/dist/orchviz-web/inter-vietnamese-600-normal.woff2 +0 -0
@@ -1,38 +0,0 @@
1
- /**
2
- * Combined sanitization for events leaving the server (SSE / API).
3
- * - stripAnsi → defense vs ANSI-injection (red-team Critical #1)
4
- * - scrubSecrets → defense vs key/PEM leak (red-team Medium #13 / Q3)
5
- * - newline scrubbing → defense vs SSE frame injection (red-team RT2 #2)
6
- *
7
- * Recursive: walks every string in nested objects/arrays.
8
- */
9
- import { stripAnsi } from "./parser/strip-ansi.js";
10
- import { scrubSecrets } from "./redact.js";
11
- function sanitizeString(s) {
12
- // Strip ANSI, scrub secrets, then collapse \r\n / \n that would break SSE frames.
13
- const cleaned = scrubSecrets(stripAnsi(s));
14
- return cleaned.replace(/\r\n|\r|\n/g, " ");
15
- }
16
- function sanitizeValue(v) {
17
- if (typeof v === "string")
18
- return sanitizeString(v);
19
- if (Array.isArray(v))
20
- return v.map(sanitizeValue);
21
- if (v && typeof v === "object") {
22
- const out = {};
23
- for (const [k, val] of Object.entries(v)) {
24
- out[k] = sanitizeValue(val);
25
- }
26
- return out;
27
- }
28
- return v;
29
- }
30
- export function sanitizeEvent(event) {
31
- return {
32
- time: event.time,
33
- type: event.type,
34
- payload: sanitizeValue(event.payload),
35
- ...(event.sessionId ? { sessionId: event.sessionId } : {}),
36
- };
37
- }
38
- //# sourceMappingURL=sanitize.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sanitize.js","sourceRoot":"","sources":["../../src/orchviz/sanitize.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,SAAS,cAAc,CAAC,CAAS;IAChC,kFAAkF;IAClF,MAAM,OAAO,GAAG,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3C,OAAO,OAAO,CAAC,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC,CAAC;AAC5C,CAAC;AAED,SAAS,aAAa,CAAC,CAAU;IAChC,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,cAAc,CAAC,CAAC,CAAC,CAAC;IACpD,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAAE,OAAO,CAAC,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IAClD,IAAI,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAChC,MAAM,GAAG,GAA4B,EAAE,CAAC;QACxC,KAAK,MAAM,CAAC,CAAC,EAAE,GAAG,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAA4B,CAAC,EAAE,CAAC;YACrE,GAAG,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,GAAG,CAAC,CAAC;QAC7B,CAAC;QACD,OAAO,GAAG,CAAC;IACZ,CAAC;IACD,OAAO,CAAC,CAAC;AACV,CAAC;AAED,MAAM,UAAU,aAAa,CAAC,KAAiB;IAC9C,OAAO;QACN,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,OAAO,EAAE,aAAa,CAAC,KAAK,CAAC,OAAO,CAA4B;QAChE,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KAC1D,CAAC;AACH,CAAC"}
@@ -1,55 +0,0 @@
1
- /**
2
- * /api/overlays + /api/plan + /api/plans — JSON endpoints backed by collectors.
3
- */
4
- import type { ServerResponse } from "node:http";
5
- import { PlanCollector, type PlanSnapshot } from "../plan/collector.js";
6
- export interface OverlayState {
7
- gate1?: {
8
- name: string;
9
- approved: boolean;
10
- } | null;
11
- gate2?: {
12
- name: string;
13
- verdict: string;
14
- } | null;
15
- model?: string | null;
16
- cost?: {
17
- tokens: number;
18
- usd: number;
19
- } | null;
20
- phase?: string | null;
21
- }
22
- export type OverlayProvider = () => OverlayState;
23
- export declare function writeJson(res: ServerResponse, status: number, body: unknown): void;
24
- export declare function handleOverlays(res: ServerResponse, provider: OverlayProvider): void;
25
- export declare const PLACEHOLDER_OVERLAYS: OverlayProvider;
26
- export declare function makeOverlayProvider(projectRoot: string): OverlayProvider;
27
- /**
28
- * PlanProvider now accepts an optional slug string.
29
- * PlanCollector.snapshot(slug?) maps to this signature.
30
- */
31
- export type PlanProvider = (slug?: string) => PlanSnapshot;
32
- /**
33
- * Handle GET /api/plan — optionally targeted by ?slug=<slug> query param.
34
- *
35
- * Error mapping (R2-8):
36
- * snapshot.error === "invalid-slug" → 400
37
- * snapshot.error === "forbidden-path" → 403
38
- * snapshot.error === "not-found" → 404
39
- * no error → 200
40
- */
41
- export declare function handlePlan(res: ServerResponse, provider: PlanProvider, query: URLSearchParams): void;
42
- export declare const PLACEHOLDER_PLAN: PlanProvider;
43
- export declare function makePlanProvider(projectRoot: string): PlanProvider;
44
- /**
45
- * Create a standalone PlanCollector instance for injection into the write handler.
46
- * The write handler calls collector.invalidate() after every successful write,
47
- * invalidating the cache so the next GET returns fresh data (R2-4).
48
- */
49
- export declare function makePlanCollector(projectRoot: string): PlanCollector;
50
- /**
51
- * Handle GET /api/plans — returns all non-archived plan summaries sorted mtime desc.
52
- * HTML-tag scrub applied to all string fields (red-team H2).
53
- */
54
- export declare function handlePlans(res: ServerResponse, projectRoot: string): void;
55
- //# sourceMappingURL=api-handlers.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-handlers.d.ts","sourceRoot":"","sources":["../../../src/orchviz/server/api-handlers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,cAA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,YAAY,CAGlE;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,aAAa,CAEpE;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,GAAG,IAAI,CAQ1E"}
@@ -1,112 +0,0 @@
1
- /**
2
- * /api/overlays + /api/plan + /api/plans — JSON endpoints backed by collectors.
3
- */
4
- import { OverlayCollector } from "../overlay/collector.js";
5
- import { PlanCollector } from "../plan/collector.js";
6
- import { listPlans } from "../plan/list-plans.js";
7
- const PLAN_ERROR_HTTP = {
8
- "invalid-slug": 400,
9
- "forbidden-path": 403,
10
- "not-found": 404,
11
- };
12
- const HTML_TAG_RE = /<[^>]*>/g;
13
- /** Recursively strip HTML tags from string fields. Defense-in-depth (red-team H2). */
14
- function stripHtmlDeep(value) {
15
- if (typeof value === "string")
16
- return value.replace(HTML_TAG_RE, "");
17
- if (Array.isArray(value))
18
- return value.map(stripHtmlDeep);
19
- if (value && typeof value === "object") {
20
- const out = {};
21
- for (const [k, v] of Object.entries(value)) {
22
- out[k] = stripHtmlDeep(v);
23
- }
24
- return out;
25
- }
26
- return value;
27
- }
28
- export function writeJson(res, status, body) {
29
- const payload = JSON.stringify(body);
30
- res.writeHead(status, {
31
- "Content-Type": "application/json; charset=utf-8",
32
- "Content-Length": String(Buffer.byteLength(payload)),
33
- "Cache-Control": "no-cache",
34
- });
35
- res.end(payload);
36
- }
37
- export function handleOverlays(res, provider) {
38
- try {
39
- writeJson(res, 200, provider());
40
- }
41
- catch {
42
- writeJson(res, 500, { error: "overlay-read-failed" });
43
- }
44
- }
45
- export const PLACEHOLDER_OVERLAYS = () => ({
46
- gate1: null,
47
- gate2: null,
48
- model: null,
49
- cost: null,
50
- phase: null,
51
- });
52
- export function makeOverlayProvider(projectRoot) {
53
- const collector = new OverlayCollector(projectRoot);
54
- return () => collector.snapshot();
55
- }
56
- /**
57
- * Handle GET /api/plan — optionally targeted by ?slug=<slug> query param.
58
- *
59
- * Error mapping (R2-8):
60
- * snapshot.error === "invalid-slug" → 400
61
- * snapshot.error === "forbidden-path" → 403
62
- * snapshot.error === "not-found" → 404
63
- * no error → 200
64
- */
65
- export function handlePlan(res, provider, query) {
66
- try {
67
- const slug = query.get("slug") ?? undefined;
68
- const snapshot = provider(slug);
69
- if (snapshot.error) {
70
- writeJson(res, PLAN_ERROR_HTTP[snapshot.error], { error: snapshot.error });
71
- return;
72
- }
73
- const safe = stripHtmlDeep(snapshot);
74
- writeJson(res, 200, safe);
75
- }
76
- catch {
77
- writeJson(res, 500, { error: "plan-read-failed" });
78
- }
79
- }
80
- export const PLACEHOLDER_PLAN = () => ({
81
- plan: null,
82
- phaseEtags: null,
83
- readonly: false,
84
- generatedAt: new Date().toISOString(),
85
- });
86
- export function makePlanProvider(projectRoot) {
87
- const collector = new PlanCollector(projectRoot);
88
- return (slug) => collector.snapshot(slug);
89
- }
90
- /**
91
- * Create a standalone PlanCollector instance for injection into the write handler.
92
- * The write handler calls collector.invalidate() after every successful write,
93
- * invalidating the cache so the next GET returns fresh data (R2-4).
94
- */
95
- export function makePlanCollector(projectRoot) {
96
- return new PlanCollector(projectRoot);
97
- }
98
- /**
99
- * Handle GET /api/plans — returns all non-archived plan summaries sorted mtime desc.
100
- * HTML-tag scrub applied to all string fields (red-team H2).
101
- */
102
- export function handlePlans(res, projectRoot) {
103
- try {
104
- const plans = listPlans(projectRoot);
105
- const safe = stripHtmlDeep(plans);
106
- writeJson(res, 200, { plans: safe, generatedAt: new Date().toISOString() });
107
- }
108
- catch {
109
- writeJson(res, 500, { error: "plans-read-failed" });
110
- }
111
- }
112
- //# sourceMappingURL=api-handlers.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"api-handlers.js","sourceRoot":"","sources":["../../../src/orchviz/server/api-handlers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D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S,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAC;IACpD,CAAC;AACF,CAAC;AAED,MAAM,CAAC,MAAM,gBAAgB,GAAiB,GAAG,EAAE,CAAC,CAAC;IACpD,IAAI,EAAE,IAAI;IACV,UAAU,EAAE,IAAI;IAChB,QAAQ,EAAE,KAAK;IACf,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE;CACrC,CAAC,CAAC;AAEH,MAAM,UAAU,gBAAgB,CAAC,WAAmB;IACnD,MAAM,SAAS,GAAG,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;IACjD,OAAO,CAAC,IAAa,EAAE,EAAE,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACpD,OAAO,IAAI,aAAa,CAAC,WAAW,CAAC,CAAC;AACvC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,WAAW,CAAC,GAAmB,EAAE,WAAmB;IACnE,IAAI,CAAC;QACJ,MAAM,KAAK,GAAG,SAAS,CAAC,WAAW,CAAC,CAAC;QACrC,MAAM,IAAI,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;QAClC,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;IAC7E,CAAC;IAAC,MAAM,CAAC;QACR,SAAS,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,mBAAmB,EAAE,CAAC,CAAC;IACrD,CAAC;AACF,CAAC"}
@@ -1,36 +0,0 @@
1
- /**
2
- * OrchvizServer — node:http server bound 127.0.0.1 with SSE relay + static UI.
3
- *
4
- * Architecture ported from patoles/agent-flow @ 59ccf4e (app/src/server.ts +
5
- * scripts/relay.ts SSE block). License Apache-2.0 (see ../../NOTICE).
6
- */
7
- import { EventEmitter } from "node:events";
8
- import { type OverlayProvider, type PlanProvider } from "./api-handlers.js";
9
- import type { PlanCollector } from "../plan/collector.js";
10
- export interface OrchvizServerOptions {
11
- port?: number;
12
- staticDir: string;
13
- eventSource: EventEmitter;
14
- overlayProvider?: OverlayProvider;
15
- planProvider?: PlanProvider;
16
- /** Required for /api/plans endpoint. Falls back to no-op if absent. */
17
- projectRoot?: string;
18
- /** Required for POST /api/plan/todo cache invalidation (red-team M4 / R2-4). */
19
- planCollector?: PlanCollector;
20
- verbose?: boolean;
21
- }
22
- export declare class OrchvizServer {
23
- private server;
24
- private readonly relay;
25
- private actualPort;
26
- private readonly opts;
27
- private readonly forwardEvent;
28
- constructor(opts: OrchvizServerOptions);
29
- get port(): number;
30
- get url(): string;
31
- start(onListening?: (url: string) => void): Promise<string>;
32
- stop(): Promise<void>;
33
- private routeRequest;
34
- private isHostAllowed;
35
- }
36
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/orchviz/server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAM3C,OAAO,EAON,KAAK,eAAe,EACpB,KAAK,YAAY,EACjB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,WAAW,oBAAoB;IACpC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,YAAY,CAAC;IAC1B,eAAe,CAAC,EAAE,eAAe,CAAC;IAClC,YAAY,CAAC,EAAE,YAAY,CAAC;IAC5B,uEAAuE;IACvE,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gFAAgF;IAChF,aAAa,CAAC,EAAE,aAAa,CAAC;IAC9B,OAAO,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,qBAAa,aAAa;IACzB,OAAO,CAAC,MAAM,CAA4B;IAC1C,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAkB;IACxC,OAAO,CAAC,UAAU,CAAK;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAuB;IAC5C,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0B;gBAE3C,IAAI,EAAE,oBAAoB;IAOtC,IAAI,IAAI,IAAI,MAAM,CAEjB;IAED,IAAI,GAAG,IAAI,MAAM,CAEhB;IAEK,KAAK,CAAC,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC;IAoC3D,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,OAAO,CAAC,YAAY;IAqDpB,OAAO,CAAC,aAAa;CAOrB"}
@@ -1,144 +0,0 @@
1
- /**
2
- * OrchvizServer — node:http server bound 127.0.0.1 with SSE relay + static UI.
3
- *
4
- * Architecture ported from patoles/agent-flow @ 59ccf4e (app/src/server.ts +
5
- * scripts/relay.ts SSE block). License Apache-2.0 (see ../../NOTICE).
6
- */
7
- import * as http from "node:http";
8
- import { BIND_HOST, SSE_DRAIN_GRACE_MS } from "../constants.js";
9
- import { sanitizeEvent } from "../sanitize.js";
10
- import { SseRelay } from "./sse-handler.js";
11
- import { serveStatic } from "./static-handler.js";
12
- import { handleOverlays, handlePlan, handlePlans, writeJson, PLACEHOLDER_OVERLAYS, PLACEHOLDER_PLAN, } from "./api-handlers.js";
13
- import { handleTodoWrite, handleTodoPreflight } from "./write-handlers.js";
14
- export class OrchvizServer {
15
- server = null;
16
- relay = new SseRelay();
17
- actualPort = 0;
18
- opts;
19
- forwardEvent;
20
- constructor(opts) {
21
- this.opts = opts;
22
- this.forwardEvent = (e) => {
23
- this.relay.publish(sanitizeEvent(e));
24
- };
25
- }
26
- get port() {
27
- return this.actualPort;
28
- }
29
- get url() {
30
- return `http://${BIND_HOST}:${this.actualPort}`;
31
- }
32
- async start(onListening) {
33
- this.relay.start();
34
- this.opts.eventSource.on("event", this.forwardEvent);
35
- const desiredPort = this.opts.port ?? 0;
36
- const tryListen = (port) => new Promise((resolve, reject) => {
37
- const server = http.createServer((req, res) => this.routeRequest(req, res));
38
- // All errors reject — caller distinguishes EADDRINUSE / EACCES for fallback.
39
- server.on("error", reject);
40
- server.listen(port, BIND_HOST, () => {
41
- this.server = server;
42
- const addr = server.address();
43
- this.actualPort = typeof addr === "object" && addr ? addr.port : port;
44
- resolve();
45
- });
46
- });
47
- try {
48
- await tryListen(desiredPort);
49
- }
50
- catch (err) {
51
- const e = err;
52
- if (desiredPort !== 0 && (e.code === "EADDRINUSE" || e.code === "EACCES")) {
53
- if (this.opts.verbose) {
54
- process.stderr.write(`[orchviz] port ${desiredPort} unavailable (${e.code}); falling back to random\n`);
55
- }
56
- await tryListen(0);
57
- }
58
- else {
59
- throw err;
60
- }
61
- }
62
- const url = this.url;
63
- if (onListening)
64
- onListening(url);
65
- return url;
66
- }
67
- async stop() {
68
- this.opts.eventSource.off("event", this.forwardEvent);
69
- this.relay.stop();
70
- if (!this.server)
71
- return;
72
- const srv = this.server;
73
- this.server = null;
74
- await new Promise((resolve) => {
75
- const timer = setTimeout(() => resolve(), SSE_DRAIN_GRACE_MS);
76
- if (typeof timer.unref === "function")
77
- timer.unref();
78
- srv.close(() => {
79
- clearTimeout(timer);
80
- resolve();
81
- });
82
- });
83
- }
84
- routeRequest(req, res) {
85
- // Host header guard — defense vs DNS rebinding (red-team RT2 #1).
86
- if (!this.isHostAllowed(req)) {
87
- res.writeHead(403, { "Content-Type": "text/plain" });
88
- res.end("Forbidden");
89
- return;
90
- }
91
- const url = new URL(req.url ?? "/", `http://${BIND_HOST}:${this.actualPort}`);
92
- const pathname = url.pathname;
93
- // Route /api/plan/todo BEFORE the GET/HEAD method gate (spec step 14).
94
- if (pathname === "/api/plan/todo") {
95
- const writeCtx = {
96
- projectRoot: this.opts.projectRoot ?? "",
97
- port: this.actualPort,
98
- planCollector: this.opts.planCollector,
99
- };
100
- if (req.method === "OPTIONS") {
101
- handleTodoPreflight(req, res, this.actualPort);
102
- return;
103
- }
104
- void handleTodoWrite(req, res, writeCtx);
105
- return;
106
- }
107
- if (req.method !== "GET" && req.method !== "HEAD") {
108
- res.writeHead(405, { Allow: "GET, HEAD", "Content-Type": "text/plain" });
109
- res.end("Method Not Allowed");
110
- return;
111
- }
112
- if (pathname === "/events") {
113
- this.relay.handle(req, res);
114
- return;
115
- }
116
- if (pathname === "/api/overlays") {
117
- handleOverlays(res, this.opts.overlayProvider ?? PLACEHOLDER_OVERLAYS);
118
- return;
119
- }
120
- if (pathname === "/api/plans") {
121
- if (this.opts.projectRoot) {
122
- handlePlans(res, this.opts.projectRoot);
123
- }
124
- else {
125
- writeJson(res, 200, { plans: [], generatedAt: new Date().toISOString() });
126
- }
127
- return;
128
- }
129
- if (pathname === "/api/plan") {
130
- handlePlan(res, this.opts.planProvider ?? PLACEHOLDER_PLAN, url.searchParams);
131
- return;
132
- }
133
- serveStatic(req, res, this.opts.staticDir);
134
- }
135
- isHostAllowed(req) {
136
- const host = req.headers.host;
137
- if (!host)
138
- return false;
139
- const expected = new Set([`${BIND_HOST}:${this.actualPort}`, `localhost:${this.actualPort}`]);
140
- // Allow stable port match too in case actualPort still 0 during fallback.
141
- return expected.has(host) || host === BIND_HOST || host === "localhost";
142
- }
143
- }
144
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/orchviz/server/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAGlC,OAAO,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAChE,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,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W,EAAE,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC;YAC3E,CAAC;YACD,OAAO;QACR,CAAC;QACD,IAAI,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC9B,UAAU,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,gBAAgB,EAAE,GAAG,CAAC,YAAY,CAAC,CAAC;YAC9E,OAAO;QACR,CAAC;QACD,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAEO,aAAa,CAAC,GAAyB;QAC9C,MAAM,IAAI,GAAG,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC;QAC9B,IAAI,CAAC,IAAI;YAAE,OAAO,KAAK,CAAC;QACxB,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,SAAS,IAAI,IAAI,CAAC,UAAU,EAAE,EAAE,aAAa,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC;QAC9F,0EAA0E;QAC1E,OAAO,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,IAAI,KAAK,SAAS,IAAI,IAAI,KAAK,WAAW,CAAC;IACzE,CAAC;CACD"}
@@ -1,28 +0,0 @@
1
- /**
2
- * SSE handler — replay buffer, heartbeat, Last-Event-ID, client cap.
3
- */
4
- import type { IncomingMessage, ServerResponse } from "node:http";
5
- import type { AgentEvent } from "../protocol.js";
6
- export interface BufferedEvent {
7
- id: number;
8
- event: AgentEvent;
9
- }
10
- export declare class SseRelay {
11
- private readonly clients;
12
- private readonly buffer;
13
- private readonly agentRegistry;
14
- private readonly pauseRegistry;
15
- private readonly pauseDebounce;
16
- private nextId;
17
- private heartbeat;
18
- start(): void;
19
- stop(): void;
20
- clientCount(): number;
21
- publish(event: AgentEvent): void;
22
- private publishImmediately;
23
- handle(req: IncomingMessage, res: ServerResponse): void;
24
- private broadcast;
25
- private writeOne;
26
- private sendHeartbeat;
27
- }
28
- //# sourceMappingURL=sse-handler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"sse-handler.d.ts","sourceRoot":"","sources":["../../../src/orchviz/server/sse-handler.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAA4D,MAAM,gBAAgB,CAAC;AAO3G,MAAM,WAAW,aAAa;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,UAAU,CAAC;CAClB;AAeD,qBAAa,QAAQ;IACpB,OAAO,CAAC,QAAQ,CAAC,OAAO,CAA6B;IACrD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAuB;IAK9C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoC;IAIlE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAoC;IAIlE,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyC;IACvE,OAAO,CAAC,MAAM,CAAK;IACnB,OAAO,CAAC,SAAS,CAA+B;IAEhD,KAAK,IAAI,IAAI;IAMb,IAAI,IAAI,IAAI;IAeZ,WAAW,IAAI,MAAM;IAIrB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI;IAyChC,OAAO,CAAC,kBAAkB;IA+B1B,MAAM,CAAC,GAAG,EAAE,eAAe,EAAE,GAAG,EAAE,cAAc,GAAG,IAAI;IA4CvD,OAAO,CAAC,SAAS;IAmBjB,OAAO,CAAC,QAAQ;IAIhB,OAAO,CAAC,aAAa;CAcrB"}
@@ -1,217 +0,0 @@
1
- /**
2
- * SSE handler — replay buffer, heartbeat, Last-Event-ID, client cap.
3
- */
4
- import { MAX_SSE_BUFFER, MAX_SSE_CLIENTS, SSE_HEARTBEAT_MS, PAUSE_MIN_DURATION_MS } from "../constants.js";
5
- const SPAWN_TYPE = "agent_spawn";
6
- const PAUSE_STARTED = "pause_started";
7
- const PAUSE_CLEARED = "pause_cleared";
8
- function pauseKey(event) {
9
- const payload = event.payload;
10
- const session = event.sessionId ?? "_";
11
- const agent = payload?.agent ?? "_";
12
- const tid = payload?.toolUseId ?? "*";
13
- return `${session}:${agent}:${tid}`;
14
- }
15
- export class SseRelay {
16
- clients = new Set();
17
- buffer = [];
18
- // Persistent registry of agent_spawn events keyed by `${sessionId}:${name}`.
19
- // The ring buffer evicts old events, but a browser that reconnects mid-session
20
- // still needs to know which agents exist — otherwise tool_call_* events drop
21
- // silently because their target agent was never spawned in the client view.
22
- agentRegistry = new Map();
23
- // [red-team #6] Parallel registry for pause_started so reconnecting clients
24
- // see active pauses even after the ring buffer has evicted the originating
25
- // event. Cleared on pause_cleared.
26
- pauseRegistry = new Map();
27
- // [red-team #8] Pause debouncer with explicit cancellation handle.
28
- // Buffers `pause_started` for PAUSE_MIN_DURATION_MS so a `pause_cleared`
29
- // arriving inside the window cancels both events (no UI flicker).
30
- pauseDebounce = new Map();
31
- nextId = 1;
32
- heartbeat = null;
33
- start() {
34
- if (this.heartbeat)
35
- return;
36
- this.heartbeat = setInterval(() => this.sendHeartbeat(), SSE_HEARTBEAT_MS);
37
- if (typeof this.heartbeat.unref === "function")
38
- this.heartbeat.unref();
39
- }
40
- stop() {
41
- if (this.heartbeat)
42
- clearInterval(this.heartbeat);
43
- this.heartbeat = null;
44
- for (const entry of this.pauseDebounce.values())
45
- clearTimeout(entry.timer);
46
- this.pauseDebounce.clear();
47
- for (const c of this.clients) {
48
- try {
49
- c.end();
50
- }
51
- catch {
52
- // ignore
53
- }
54
- }
55
- this.clients.clear();
56
- }
57
- clientCount() {
58
- return this.clients.size;
59
- }
60
- publish(event) {
61
- // Pause debouncer: buffer pause_started for PAUSE_MIN_DURATION_MS.
62
- // If pause_cleared arrives in the window, drop both. Otherwise emit on timer fire.
63
- if (event.type === PAUSE_STARTED) {
64
- const key = pauseKey(event);
65
- // Cancel a prior buffered pause_started for the same key — a duplicate
66
- // shouldn't double-emit; latest wins.
67
- const prior = this.pauseDebounce.get(key);
68
- if (prior)
69
- clearTimeout(prior.timer);
70
- const timer = setTimeout(() => {
71
- this.pauseDebounce.delete(key);
72
- this.publishImmediately(event);
73
- }, PAUSE_MIN_DURATION_MS);
74
- if (typeof timer.unref === "function")
75
- timer.unref();
76
- this.pauseDebounce.set(key, { timer, bufferedEvent: event });
77
- return;
78
- }
79
- if (event.type === PAUSE_CLEARED) {
80
- const key = pauseKey(event);
81
- const pending = this.pauseDebounce.get(key);
82
- if (pending) {
83
- clearTimeout(pending.timer);
84
- this.pauseDebounce.delete(key);
85
- return; // sub-window pause cancelled — drop both events
86
- }
87
- // No exact-key match — fallback search by `${session}:${agent}:*` so a
88
- // pause_cleared for permission_request (no toolUseId) still cancels
89
- // any pending heuristic pause for the same agent.
90
- const sessionAgentPrefix = key.replace(/:[^:]*$/, ":");
91
- for (const [k, entry] of this.pauseDebounce) {
92
- if (k.startsWith(sessionAgentPrefix)) {
93
- clearTimeout(entry.timer);
94
- this.pauseDebounce.delete(k);
95
- return;
96
- }
97
- }
98
- // Otherwise fall through and publish pause_cleared normally.
99
- }
100
- this.publishImmediately(event);
101
- }
102
- publishImmediately(event) {
103
- const id = this.nextId++;
104
- const buffered = { id, event };
105
- this.buffer.push(buffered);
106
- if (this.buffer.length > MAX_SSE_BUFFER)
107
- this.buffer.shift();
108
- if (event.type === SPAWN_TYPE) {
109
- const name = event.payload?.name ?? "unknown";
110
- this.agentRegistry.set(`${event.sessionId ?? "_"}:${name}`, buffered);
111
- }
112
- if (event.type === PAUSE_STARTED || event.type === PAUSE_CLEARED) {
113
- // [code-review fix] Align pauseRegistry key to pauseKey() so multiple
114
- // pauses on the same (session, agent) but different toolUseIds don't
115
- // collide. Two-part key would silently overwrite the older entry on
116
- // a second concurrent pause, dropping it from reconnect replay.
117
- const key = pauseKey(event);
118
- if (event.type === PAUSE_STARTED) {
119
- this.pauseRegistry.set(key, buffered);
120
- }
121
- else {
122
- this.pauseRegistry.delete(key);
123
- // Also clear any wildcard-toolUseId variant so a heuristic
124
- // permission_request clear that omits toolUseId removes the entry
125
- // previously written by the same heuristic pause_started.
126
- const prefix = key.replace(/:[^:]*$/, ":");
127
- for (const k of this.pauseRegistry.keys()) {
128
- if (k.startsWith(prefix))
129
- this.pauseRegistry.delete(k);
130
- }
131
- }
132
- }
133
- this.broadcast(id, event);
134
- }
135
- handle(req, res) {
136
- if (this.clients.size >= MAX_SSE_CLIENTS) {
137
- res.writeHead(503, { "Content-Type": "text/plain" });
138
- res.end("Too many SSE clients");
139
- return;
140
- }
141
- res.writeHead(200, {
142
- "Content-Type": "text/event-stream",
143
- "Cache-Control": "no-cache, no-transform",
144
- Connection: "keep-alive",
145
- "X-Accel-Buffering": "no",
146
- });
147
- res.write(": connected\n\n");
148
- const lastIdHeader = req.headers["last-event-id"];
149
- const lastId = typeof lastIdHeader === "string" ? parseInt(lastIdHeader, 10) || 0 : 0;
150
- // Replay agent_spawn registry first so the client knows which agents exist
151
- // before any tool_call_* / message events arrive that reference them. Skip
152
- // any agent_spawn already inside the ring buffer (avoid duplicate).
153
- const bufferedIds = new Set(this.buffer.map((b) => b.id));
154
- for (const buffered of this.agentRegistry.values()) {
155
- if (buffered.id > lastId && !bufferedIds.has(buffered.id)) {
156
- this.writeOne(res, buffered.id, buffered.event);
157
- }
158
- }
159
- // [red-team #6] Replay pause_started events whose pauses are still active.
160
- for (const buffered of this.pauseRegistry.values()) {
161
- if (buffered.id > lastId && !bufferedIds.has(buffered.id)) {
162
- this.writeOne(res, buffered.id, buffered.event);
163
- }
164
- }
165
- for (const buffered of this.buffer) {
166
- if (buffered.id > lastId)
167
- this.writeOne(res, buffered.id, buffered.event);
168
- }
169
- this.clients.add(res);
170
- const cleanup = () => {
171
- this.clients.delete(res);
172
- };
173
- req.on("close", cleanup);
174
- req.on("error", cleanup);
175
- res.on("error", cleanup);
176
- }
177
- broadcast(id, event) {
178
- for (const res of this.clients) {
179
- try {
180
- const ok = this.writeOne(res, id, event);
181
- if (!ok) {
182
- // Slow client; backpressure → drop further events for it but keep alive.
183
- continue;
184
- }
185
- }
186
- catch {
187
- this.clients.delete(res);
188
- try {
189
- res.end();
190
- }
191
- catch {
192
- // ignore
193
- }
194
- }
195
- }
196
- }
197
- writeOne(res, id, event) {
198
- return res.write(`id: ${id}\ndata: ${JSON.stringify(event)}\n\n`);
199
- }
200
- sendHeartbeat() {
201
- for (const res of this.clients) {
202
- try {
203
- res.write(": ping\n\n");
204
- }
205
- catch {
206
- this.clients.delete(res);
207
- try {
208
- res.end();
209
- }
210
- catch {
211
- // ignore
212
- }
213
- }
214
- }
215
- }
216
- }
217
- //# sourceMappingURL=sse-handler.js.map