@jitsusama/agentic-harness.core 0.1.0

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 (974) hide show
  1. package/README.md +52 -0
  2. package/dist/advisor/charter.d.ts +14 -0
  3. package/dist/advisor/charter.js +48 -0
  4. package/dist/advisor/findings.d.ts +43 -0
  5. package/dist/advisor/findings.js +82 -0
  6. package/dist/advisor/index.d.ts +24 -0
  7. package/dist/advisor/index.js +23 -0
  8. package/dist/advisor/settings.d.ts +16 -0
  9. package/dist/advisor/settings.js +30 -0
  10. package/dist/advisor/substantive.d.ts +14 -0
  11. package/dist/advisor/substantive.js +33 -0
  12. package/dist/advisor/tools.d.ts +38 -0
  13. package/dist/advisor/tools.js +202 -0
  14. package/dist/attribution/commit-hook.d.ts +53 -0
  15. package/dist/attribution/commit-hook.js +133 -0
  16. package/dist/attribution/gh-footer.d.ts +27 -0
  17. package/dist/attribution/gh-footer.js +80 -0
  18. package/dist/attribution/index.d.ts +11 -0
  19. package/dist/attribution/index.js +11 -0
  20. package/dist/attribution/model-name.d.ts +11 -0
  21. package/dist/attribution/model-name.js +26 -0
  22. package/dist/bin/attribution.d.ts +36 -0
  23. package/dist/bin/attribution.js +82 -0
  24. package/dist/bin/cli.d.ts +14 -0
  25. package/dist/bin/cli.js +236 -0
  26. package/dist/bin/gate-deps.d.ts +23 -0
  27. package/dist/bin/gate-deps.js +61 -0
  28. package/dist/bin/guardians.d.ts +51 -0
  29. package/dist/bin/guardians.js +174 -0
  30. package/dist/bin/memory.d.ts +16 -0
  31. package/dist/bin/memory.js +81 -0
  32. package/dist/bin/notes.d.ts +30 -0
  33. package/dist/bin/notes.js +67 -0
  34. package/dist/bin/process-exec.d.ts +14 -0
  35. package/dist/bin/process-exec.js +31 -0
  36. package/dist/bin/quest.d.ts +38 -0
  37. package/dist/bin/quest.js +187 -0
  38. package/dist/bin/slack-auth.d.ts +49 -0
  39. package/dist/bin/slack-auth.js +107 -0
  40. package/dist/clock/index.d.ts +46 -0
  41. package/dist/clock/index.js +72 -0
  42. package/dist/command/cwd.d.ts +21 -0
  43. package/dist/command/cwd.js +60 -0
  44. package/dist/command/edit.d.ts +14 -0
  45. package/dist/command/edit.js +22 -0
  46. package/dist/command/flags.d.ts +29 -0
  47. package/dist/command/flags.js +111 -0
  48. package/dist/command/index.d.ts +16 -0
  49. package/dist/command/index.js +12 -0
  50. package/dist/command/tokenize.d.ts +7 -0
  51. package/dist/command/tokenize.js +315 -0
  52. package/dist/command/types.d.ts +66 -0
  53. package/dist/command/types.js +9 -0
  54. package/dist/completion/index.d.ts +17 -0
  55. package/dist/completion/index.js +16 -0
  56. package/dist/completion/investigate.d.ts +63 -0
  57. package/dist/completion/investigate.js +198 -0
  58. package/dist/completion/resolve.d.ts +29 -0
  59. package/dist/completion/resolve.js +42 -0
  60. package/dist/completion/side.d.ts +51 -0
  61. package/dist/completion/side.js +93 -0
  62. package/dist/completion/types.d.ts +84 -0
  63. package/dist/completion/types.js +14 -0
  64. package/dist/exec/exec.d.ts +38 -0
  65. package/dist/exec/exec.js +51 -0
  66. package/dist/exec/index.d.ts +8 -0
  67. package/dist/exec/index.js +8 -0
  68. package/dist/gate/decision.d.ts +52 -0
  69. package/dist/gate/decision.js +68 -0
  70. package/dist/gate/deps.d.ts +14 -0
  71. package/dist/gate/deps.js +1 -0
  72. package/dist/gate/index.d.ts +2 -0
  73. package/dist/gate/index.js +1 -0
  74. package/dist/git-cli/index.d.ts +47 -0
  75. package/dist/git-cli/index.js +127 -0
  76. package/dist/github-cli/command-spec.d.ts +14 -0
  77. package/dist/github-cli/command-spec.js +18 -0
  78. package/dist/github-cli/index.d.ts +71 -0
  79. package/dist/github-cli/index.js +188 -0
  80. package/dist/google/apis/calendar.d.ts +64 -0
  81. package/dist/google/apis/calendar.js +297 -0
  82. package/dist/google/apis/docs.d.ts +29 -0
  83. package/dist/google/apis/docs.js +154 -0
  84. package/dist/google/apis/drive.d.ts +46 -0
  85. package/dist/google/apis/drive.js +189 -0
  86. package/dist/google/apis/gmail.d.ts +67 -0
  87. package/dist/google/apis/gmail.js +374 -0
  88. package/dist/google/apis/index.d.ts +10 -0
  89. package/dist/google/apis/index.js +10 -0
  90. package/dist/google/apis/sheets.d.ts +16 -0
  91. package/dist/google/apis/sheets.js +54 -0
  92. package/dist/google/apis/slides.d.ts +16 -0
  93. package/dist/google/apis/slides.js +40 -0
  94. package/dist/google/auth/browser.d.ts +5 -0
  95. package/dist/google/auth/browser.js +27 -0
  96. package/dist/google/auth/credentials.d.ts +26 -0
  97. package/dist/google/auth/credentials.js +69 -0
  98. package/dist/google/auth/errors.d.ts +15 -0
  99. package/dist/google/auth/errors.js +26 -0
  100. package/dist/google/auth/index.d.ts +12 -0
  101. package/dist/google/auth/index.js +12 -0
  102. package/dist/google/auth/oauth-app.d.ts +15 -0
  103. package/dist/google/auth/oauth-app.js +20 -0
  104. package/dist/google/auth/oauth.d.ts +46 -0
  105. package/dist/google/auth/oauth.js +146 -0
  106. package/dist/google/auth/server.d.ts +13 -0
  107. package/dist/google/auth/server.js +70 -0
  108. package/dist/google/auth/setup-instructions.d.ts +16 -0
  109. package/dist/google/auth/setup-instructions.js +24 -0
  110. package/dist/google/auth/store.d.ts +19 -0
  111. package/dist/google/auth/store.js +27 -0
  112. package/dist/google/index.d.ts +13 -0
  113. package/dist/google/index.js +12 -0
  114. package/dist/google/paths.d.ts +17 -0
  115. package/dist/google/paths.js +28 -0
  116. package/dist/google/renderers/calendar.d.ts +23 -0
  117. package/dist/google/renderers/calendar.js +312 -0
  118. package/dist/google/renderers/drive.d.ts +31 -0
  119. package/dist/google/renderers/drive.js +214 -0
  120. package/dist/google/renderers/email.d.ts +16 -0
  121. package/dist/google/renderers/email.js +130 -0
  122. package/dist/google/renderers/index.d.ts +8 -0
  123. package/dist/google/renderers/index.js +8 -0
  124. package/dist/google/types.d.ts +143 -0
  125. package/dist/google/types.js +27 -0
  126. package/dist/governance/distill.d.ts +31 -0
  127. package/dist/governance/distill.js +78 -0
  128. package/dist/governance/index.d.ts +11 -0
  129. package/dist/governance/index.js +10 -0
  130. package/dist/governance/render.d.ts +13 -0
  131. package/dist/governance/render.js +23 -0
  132. package/dist/governance/store.d.ts +32 -0
  133. package/dist/governance/store.js +102 -0
  134. package/dist/governance/types.d.ts +19 -0
  135. package/dist/governance/types.js +9 -0
  136. package/dist/guardian/index.d.ts +7 -0
  137. package/dist/guardian/index.js +7 -0
  138. package/dist/guardian/types.d.ts +37 -0
  139. package/dist/guardian/types.js +12 -0
  140. package/dist/internal/github/cli.d.ts +40 -0
  141. package/dist/internal/github/cli.js +102 -0
  142. package/dist/internal/guardian/commit-file.d.ts +7 -0
  143. package/dist/internal/guardian/commit-file.js +36 -0
  144. package/dist/internal/guardian/commit-format.d.ts +35 -0
  145. package/dist/internal/guardian/commit-format.js +63 -0
  146. package/dist/internal/guardian/commit-shell.d.ts +38 -0
  147. package/dist/internal/guardian/commit-shell.js +134 -0
  148. package/dist/internal/guardian/history-gate.d.ts +41 -0
  149. package/dist/internal/guardian/history-gate.js +76 -0
  150. package/dist/internal/guardian/prose-gate.d.ts +31 -0
  151. package/dist/internal/guardian/prose-gate.js +50 -0
  152. package/dist/internal/guardian/redirect-gate.d.ts +41 -0
  153. package/dist/internal/guardian/redirect-gate.js +114 -0
  154. package/dist/internal/guardian/section-gate.d.ts +20 -0
  155. package/dist/internal/guardian/section-gate.js +36 -0
  156. package/dist/internal/guardian/title-gate.d.ts +20 -0
  157. package/dist/internal/guardian/title-gate.js +36 -0
  158. package/dist/internal/json-array.d.ts +11 -0
  159. package/dist/internal/json-array.js +40 -0
  160. package/dist/internal/lsp/registry.d.ts +12 -0
  161. package/dist/internal/lsp/registry.js +16 -0
  162. package/dist/internal/notes/discovery.d.ts +59 -0
  163. package/dist/internal/notes/discovery.js +91 -0
  164. package/dist/internal/notes/frontmatter.d.ts +52 -0
  165. package/dist/internal/notes/frontmatter.js +163 -0
  166. package/dist/internal/notes/id.d.ts +42 -0
  167. package/dist/internal/notes/id.js +80 -0
  168. package/dist/internal/notes/io.d.ts +25 -0
  169. package/dist/internal/notes/io.js +51 -0
  170. package/dist/internal/notes/sanitize.d.ts +19 -0
  171. package/dist/internal/notes/sanitize.js +35 -0
  172. package/dist/internal/process-global.d.ts +20 -0
  173. package/dist/internal/process-global.js +28 -0
  174. package/dist/internal/quest/alias-index.d.ts +61 -0
  175. package/dist/internal/quest/alias-index.js +69 -0
  176. package/dist/internal/quest/append-journey.d.ts +22 -0
  177. package/dist/internal/quest/append-journey.js +63 -0
  178. package/dist/internal/quest/bash-write.d.ts +49 -0
  179. package/dist/internal/quest/bash-write.js +208 -0
  180. package/dist/internal/quest/dates.d.ts +14 -0
  181. package/dist/internal/quest/dates.js +20 -0
  182. package/dist/internal/quest/discovery.d.ts +96 -0
  183. package/dist/internal/quest/discovery.js +354 -0
  184. package/dist/internal/quest/fields.d.ts +37 -0
  185. package/dist/internal/quest/fields.js +94 -0
  186. package/dist/internal/quest/frontmatter.d.ts +88 -0
  187. package/dist/internal/quest/frontmatter.js +630 -0
  188. package/dist/internal/quest/git-signals.d.ts +53 -0
  189. package/dist/internal/quest/git-signals.js +192 -0
  190. package/dist/internal/quest/id.d.ts +50 -0
  191. package/dist/internal/quest/id.js +116 -0
  192. package/dist/internal/quest/io.d.ts +54 -0
  193. package/dist/internal/quest/io.js +233 -0
  194. package/dist/internal/quest/mentions.d.ts +45 -0
  195. package/dist/internal/quest/mentions.js +70 -0
  196. package/dist/internal/quest/mutate.d.ts +38 -0
  197. package/dist/internal/quest/mutate.js +83 -0
  198. package/dist/internal/quest/process-liveness.d.ts +98 -0
  199. package/dist/internal/quest/process-liveness.js +216 -0
  200. package/dist/internal/quest/quest-doc.d.ts +116 -0
  201. package/dist/internal/quest/quest-doc.js +239 -0
  202. package/dist/internal/quest/ranking.d.ts +48 -0
  203. package/dist/internal/quest/ranking.js +114 -0
  204. package/dist/internal/quest/reopen.d.ts +65 -0
  205. package/dist/internal/quest/reopen.js +113 -0
  206. package/dist/internal/quest/resolve-cwd.d.ts +32 -0
  207. package/dist/internal/quest/resolve-cwd.js +89 -0
  208. package/dist/internal/quest/sanitize.d.ts +42 -0
  209. package/dist/internal/quest/sanitize.js +69 -0
  210. package/dist/internal/quest/scaffold.d.ts +59 -0
  211. package/dist/internal/quest/scaffold.js +169 -0
  212. package/dist/internal/quest/scratch.d.ts +27 -0
  213. package/dist/internal/quest/scratch.js +106 -0
  214. package/dist/internal/quest/session-liveness.d.ts +125 -0
  215. package/dist/internal/quest/session-liveness.js +386 -0
  216. package/dist/internal/quest/session-ownership.d.ts +22 -0
  217. package/dist/internal/quest/session-ownership.js +100 -0
  218. package/dist/internal/quest/session-registry.d.ts +221 -0
  219. package/dist/internal/quest/session-registry.js +266 -0
  220. package/dist/internal/quest/status.d.ts +10 -0
  221. package/dist/internal/quest/status.js +15 -0
  222. package/dist/internal/quest/structural-journal.d.ts +41 -0
  223. package/dist/internal/quest/structural-journal.js +67 -0
  224. package/dist/internal/quest/structural.d.ts +43 -0
  225. package/dist/internal/quest/structural.js +77 -0
  226. package/dist/internal/quest/toc.d.ts +28 -0
  227. package/dist/internal/quest/toc.js +90 -0
  228. package/dist/internal/quest/trees.d.ts +53 -0
  229. package/dist/internal/quest/trees.js +145 -0
  230. package/dist/internal/quest/url-fetchers.d.ts +50 -0
  231. package/dist/internal/quest/url-fetchers.js +97 -0
  232. package/dist/internal/quest/write-classifier.d.ts +46 -0
  233. package/dist/internal/quest/write-classifier.js +59 -0
  234. package/dist/internal/refs/builtins.d.ts +32 -0
  235. package/dist/internal/refs/builtins.js +179 -0
  236. package/dist/internal/refs/registry.d.ts +25 -0
  237. package/dist/internal/refs/registry.js +42 -0
  238. package/dist/internal/registry/global-symbol-registry.d.ts +37 -0
  239. package/dist/internal/registry/global-symbol-registry.js +55 -0
  240. package/dist/internal/review/registry.d.ts +12 -0
  241. package/dist/internal/review/registry.js +16 -0
  242. package/dist/internal/sqlite/db.d.ts +16 -0
  243. package/dist/internal/sqlite/db.js +26 -0
  244. package/dist/internal/terminal/builtins.d.ts +8 -0
  245. package/dist/internal/terminal/builtins.js +14 -0
  246. package/dist/internal/terminal/drivers/fallback.d.ts +8 -0
  247. package/dist/internal/terminal/drivers/fallback.js +31 -0
  248. package/dist/internal/terminal/drivers/shared.d.ts +39 -0
  249. package/dist/internal/terminal/drivers/shared.js +51 -0
  250. package/dist/internal/terminal/drivers/tmux.d.ts +14 -0
  251. package/dist/internal/terminal/drivers/tmux.js +88 -0
  252. package/dist/internal/terminal/drivers/wezterm.d.ts +35 -0
  253. package/dist/internal/terminal/drivers/wezterm.js +175 -0
  254. package/dist/internal/terminal/registry.d.ts +12 -0
  255. package/dist/internal/terminal/registry.js +16 -0
  256. package/dist/internal/tree/builtins.d.ts +8 -0
  257. package/dist/internal/tree/builtins.js +10 -0
  258. package/dist/internal/tree/providers/git-worktree.d.ts +20 -0
  259. package/dist/internal/tree/providers/git-worktree.js +279 -0
  260. package/dist/internal/tree/registry.d.ts +12 -0
  261. package/dist/internal/tree/registry.js +16 -0
  262. package/dist/lsp/config.d.ts +77 -0
  263. package/dist/lsp/config.js +154 -0
  264. package/dist/lsp/external.d.ts +13 -0
  265. package/dist/lsp/external.js +52 -0
  266. package/dist/lsp/format.d.ts +11 -0
  267. package/dist/lsp/format.js +54 -0
  268. package/dist/lsp/index.d.ts +17 -0
  269. package/dist/lsp/index.js +16 -0
  270. package/dist/lsp/offsets.d.ts +22 -0
  271. package/dist/lsp/offsets.js +51 -0
  272. package/dist/lsp/registry.d.ts +28 -0
  273. package/dist/lsp/registry.js +45 -0
  274. package/dist/lsp/standalone/backend.d.ts +42 -0
  275. package/dist/lsp/standalone/backend.js +150 -0
  276. package/dist/lsp/standalone/document.d.ts +45 -0
  277. package/dist/lsp/standalone/document.js +81 -0
  278. package/dist/lsp/standalone/server.d.ts +84 -0
  279. package/dist/lsp/standalone/server.js +521 -0
  280. package/dist/lsp/types.d.ts +119 -0
  281. package/dist/lsp/types.js +13 -0
  282. package/dist/memory/db.d.ts +15 -0
  283. package/dist/memory/db.js +25 -0
  284. package/dist/memory/index.d.ts +12 -0
  285. package/dist/memory/index.js +11 -0
  286. package/dist/memory/paths.d.ts +19 -0
  287. package/dist/memory/paths.js +33 -0
  288. package/dist/memory/scope.d.ts +14 -0
  289. package/dist/memory/scope.js +22 -0
  290. package/dist/memory/store.d.ts +12 -0
  291. package/dist/memory/store.js +146 -0
  292. package/dist/memory/types.d.ts +80 -0
  293. package/dist/memory/types.js +6 -0
  294. package/dist/notes/types.d.ts +50 -0
  295. package/dist/notes/types.js +23 -0
  296. package/dist/notes/verbs/create.d.ts +5 -0
  297. package/dist/notes/verbs/create.js +55 -0
  298. package/dist/notes/verbs/mutate.d.ts +8 -0
  299. package/dist/notes/verbs/mutate.js +152 -0
  300. package/dist/notes/verbs/queries.d.ts +15 -0
  301. package/dist/notes/verbs/queries.js +116 -0
  302. package/dist/notes/verbs/reindex.d.ts +12 -0
  303. package/dist/notes/verbs/reindex.js +35 -0
  304. package/dist/notes/verbs/shared.d.ts +37 -0
  305. package/dist/notes/verbs/shared.js +29 -0
  306. package/dist/observability/index.d.ts +13 -0
  307. package/dist/observability/index.js +12 -0
  308. package/dist/observability/recorder.d.ts +50 -0
  309. package/dist/observability/recorder.js +77 -0
  310. package/dist/observability/store.d.ts +22 -0
  311. package/dist/observability/store.js +213 -0
  312. package/dist/observability/types.d.ts +82 -0
  313. package/dist/observability/types.js +1 -0
  314. package/dist/process/index.d.ts +9 -0
  315. package/dist/process/index.js +9 -0
  316. package/dist/process/process.d.ts +95 -0
  317. package/dist/process/process.js +153 -0
  318. package/dist/prose/block.d.ts +9 -0
  319. package/dist/prose/block.js +43 -0
  320. package/dist/prose/detect.d.ts +50 -0
  321. package/dist/prose/detect.js +217 -0
  322. package/dist/prose/gate.d.ts +14 -0
  323. package/dist/prose/gate.js +21 -0
  324. package/dist/prose/index.d.ts +4 -0
  325. package/dist/prose/index.js +4 -0
  326. package/dist/prose/wrap.d.ts +9 -0
  327. package/dist/prose/wrap.js +47 -0
  328. package/dist/quest/actions.d.ts +20 -0
  329. package/dist/quest/actions.js +107 -0
  330. package/dist/quest/config.d.ts +79 -0
  331. package/dist/quest/config.js +83 -0
  332. package/dist/quest/index.d.ts +29 -0
  333. package/dist/quest/index.js +28 -0
  334. package/dist/quest/lifecycle.d.ts +365 -0
  335. package/dist/quest/lifecycle.js +900 -0
  336. package/dist/quest/lookup.d.ts +243 -0
  337. package/dist/quest/lookup.js +496 -0
  338. package/dist/quest/machine.d.ts +48 -0
  339. package/dist/quest/machine.js +96 -0
  340. package/dist/quest/render-rows.d.ts +166 -0
  341. package/dist/quest/render-rows.js +214 -0
  342. package/dist/quest/state.d.ts +111 -0
  343. package/dist/quest/state.js +46 -0
  344. package/dist/quest/types.d.ts +224 -0
  345. package/dist/quest/types.js +10 -0
  346. package/dist/quest/verbs/alias.d.ts +9 -0
  347. package/dist/quest/verbs/alias.js +129 -0
  348. package/dist/quest/verbs/lifecycle.d.ts +36 -0
  349. package/dist/quest/verbs/lifecycle.js +407 -0
  350. package/dist/quest/verbs/queries.d.ts +24 -0
  351. package/dist/quest/verbs/queries.js +241 -0
  352. package/dist/quest/verbs/reorder.d.ts +15 -0
  353. package/dist/quest/verbs/reorder.js +85 -0
  354. package/dist/quest/verbs/shared.d.ts +63 -0
  355. package/dist/quest/verbs/shared.js +35 -0
  356. package/dist/quest/verbs/stage.d.ts +39 -0
  357. package/dist/quest/verbs/stage.js +506 -0
  358. package/dist/quest/verbs/structural.d.ts +23 -0
  359. package/dist/quest/verbs/structural.js +310 -0
  360. package/dist/quest/verbs/tree-ops.d.ts +20 -0
  361. package/dist/quest/verbs/tree-ops.js +289 -0
  362. package/dist/refs/index.d.ts +13 -0
  363. package/dist/refs/index.js +12 -0
  364. package/dist/refs/lookup.d.ts +53 -0
  365. package/dist/refs/lookup.js +102 -0
  366. package/dist/refs/register.d.ts +34 -0
  367. package/dist/refs/register.js +44 -0
  368. package/dist/refs/types.d.ts +81 -0
  369. package/dist/refs/types.js +17 -0
  370. package/dist/remote/index.d.ts +9 -0
  371. package/dist/remote/index.js +9 -0
  372. package/dist/remote/name.d.ts +22 -0
  373. package/dist/remote/name.js +30 -0
  374. package/dist/result/cite.d.ts +84 -0
  375. package/dist/result/cite.js +127 -0
  376. package/dist/result/counts.d.ts +15 -0
  377. package/dist/result/counts.js +17 -0
  378. package/dist/result/details.d.ts +61 -0
  379. package/dist/result/details.js +121 -0
  380. package/dist/result/digest.d.ts +37 -0
  381. package/dist/result/digest.js +227 -0
  382. package/dist/result/follow.d.ts +29 -0
  383. package/dist/result/follow.js +37 -0
  384. package/dist/result/index.d.ts +26 -0
  385. package/dist/result/index.js +26 -0
  386. package/dist/result/listing.d.ts +62 -0
  387. package/dist/result/listing.js +72 -0
  388. package/dist/result/location.d.ts +67 -0
  389. package/dist/result/location.js +125 -0
  390. package/dist/result/query.d.ts +67 -0
  391. package/dist/result/query.js +144 -0
  392. package/dist/result/spill.d.ts +41 -0
  393. package/dist/result/spill.js +121 -0
  394. package/dist/result/store.d.ts +83 -0
  395. package/dist/result/store.js +214 -0
  396. package/dist/result/view.d.ts +31 -0
  397. package/dist/result/view.js +38 -0
  398. package/dist/review/anchor.d.ts +84 -0
  399. package/dist/review/anchor.js +89 -0
  400. package/dist/review/ask/agents.d.ts +80 -0
  401. package/dist/review/ask/agents.js +296 -0
  402. package/dist/review/ask/anchorable.d.ts +35 -0
  403. package/dist/review/ask/anchorable.js +76 -0
  404. package/dist/review/ask/answer.d.ts +54 -0
  405. package/dist/review/ask/answer.js +209 -0
  406. package/dist/review/ask/audit.d.ts +71 -0
  407. package/dist/review/ask/audit.js +158 -0
  408. package/dist/review/ask/collect.d.ts +41 -0
  409. package/dist/review/ask/collect.js +82 -0
  410. package/dist/review/ask/council.d.ts +290 -0
  411. package/dist/review/ask/council.js +386 -0
  412. package/dist/review/ask/critique.d.ts +69 -0
  413. package/dist/review/ask/critique.js +157 -0
  414. package/dist/review/ask/harvest.d.ts +119 -0
  415. package/dist/review/ask/harvest.js +409 -0
  416. package/dist/review/ask/identity.d.ts +93 -0
  417. package/dist/review/ask/identity.js +134 -0
  418. package/dist/review/ask/judge.d.ts +37 -0
  419. package/dist/review/ask/judge.js +140 -0
  420. package/dist/review/ask/persona.d.ts +84 -0
  421. package/dist/review/ask/persona.js +127 -0
  422. package/dist/review/ask/progress.d.ts +117 -0
  423. package/dist/review/ask/progress.js +137 -0
  424. package/dist/review/ask/prompt.d.ts +131 -0
  425. package/dist/review/ask/prompt.js +242 -0
  426. package/dist/review/ask/roster.d.ts +94 -0
  427. package/dist/review/ask/roster.js +338 -0
  428. package/dist/review/ask/run.d.ts +435 -0
  429. package/dist/review/ask/run.js +340 -0
  430. package/dist/review/ask/span.d.ts +70 -0
  431. package/dist/review/ask/span.js +166 -0
  432. package/dist/review/ask/stack-round.d.ts +66 -0
  433. package/dist/review/ask/stack-round.js +125 -0
  434. package/dist/review/ask/start.d.ts +48 -0
  435. package/dist/review/ask/start.js +118 -0
  436. package/dist/review/ask/store.d.ts +83 -0
  437. package/dist/review/ask/store.js +226 -0
  438. package/dist/review/ask/wire.d.ts +89 -0
  439. package/dist/review/ask/wire.js +204 -0
  440. package/dist/review/attach.d.ts +161 -0
  441. package/dist/review/attach.js +357 -0
  442. package/dist/review/authoring.d.ts +84 -0
  443. package/dist/review/authoring.js +203 -0
  444. package/dist/review/backed.d.ts +90 -0
  445. package/dist/review/backed.js +168 -0
  446. package/dist/review/bind.d.ts +75 -0
  447. package/dist/review/bind.js +223 -0
  448. package/dist/review/budget.d.ts +133 -0
  449. package/dist/review/budget.js +278 -0
  450. package/dist/review/capabilities.d.ts +217 -0
  451. package/dist/review/capabilities.js +46 -0
  452. package/dist/review/change.d.ts +155 -0
  453. package/dist/review/change.js +15 -0
  454. package/dist/review/checks.d.ts +56 -0
  455. package/dist/review/checks.js +11 -0
  456. package/dist/review/config.d.ts +71 -0
  457. package/dist/review/config.js +125 -0
  458. package/dist/review/conventions.d.ts +35 -0
  459. package/dist/review/conventions.js +58 -0
  460. package/dist/review/conversation.d.ts +98 -0
  461. package/dist/review/conversation.js +16 -0
  462. package/dist/review/decided.d.ts +58 -0
  463. package/dist/review/decided.js +67 -0
  464. package/dist/review/diff.d.ts +116 -0
  465. package/dist/review/diff.js +237 -0
  466. package/dist/review/draft/continuation.d.ts +23 -0
  467. package/dist/review/draft/continuation.js +32 -0
  468. package/dist/review/draft/fanout.d.ts +57 -0
  469. package/dist/review/draft/fanout.js +46 -0
  470. package/dist/review/draft/handle.d.ts +55 -0
  471. package/dist/review/draft/handle.js +110 -0
  472. package/dist/review/draft/plan.d.ts +112 -0
  473. package/dist/review/draft/plan.js +343 -0
  474. package/dist/review/draft/publish.d.ts +38 -0
  475. package/dist/review/draft/publish.js +118 -0
  476. package/dist/review/draft/render.d.ts +32 -0
  477. package/dist/review/draft/render.js +100 -0
  478. package/dist/review/draft/state.d.ts +98 -0
  479. package/dist/review/draft/state.js +83 -0
  480. package/dist/review/draft/store.d.ts +33 -0
  481. package/dist/review/draft/store.js +100 -0
  482. package/dist/review/elsewhere.d.ts +27 -0
  483. package/dist/review/elsewhere.js +39 -0
  484. package/dist/review/engine.d.ts +106 -0
  485. package/dist/review/engine.js +243 -0
  486. package/dist/review/events.d.ts +59 -0
  487. package/dist/review/events.js +35 -0
  488. package/dist/review/failed.d.ts +46 -0
  489. package/dist/review/failed.js +56 -0
  490. package/dist/review/finding.d.ts +81 -0
  491. package/dist/review/finding.js +85 -0
  492. package/dist/review/fix.d.ts +147 -0
  493. package/dist/review/fix.js +175 -0
  494. package/dist/review/followup.d.ts +84 -0
  495. package/dist/review/followup.js +123 -0
  496. package/dist/review/index.d.ts +134 -0
  497. package/dist/review/index.js +80 -0
  498. package/dist/review/keys.d.ts +23 -0
  499. package/dist/review/keys.js +40 -0
  500. package/dist/review/landing.d.ts +37 -0
  501. package/dist/review/landing.js +68 -0
  502. package/dist/review/lenses.d.ts +132 -0
  503. package/dist/review/lenses.js +430 -0
  504. package/dist/review/propose-from.d.ts +76 -0
  505. package/dist/review/propose-from.js +86 -0
  506. package/dist/review/provider.d.ts +306 -0
  507. package/dist/review/provider.js +16 -0
  508. package/dist/review/providers/git/index.d.ts +23 -0
  509. package/dist/review/providers/git/index.js +214 -0
  510. package/dist/review/providers/github/authoring.d.ts +22 -0
  511. package/dist/review/providers/github/authoring.js +350 -0
  512. package/dist/review/providers/github/claims.d.ts +49 -0
  513. package/dist/review/providers/github/claims.js +136 -0
  514. package/dist/review/providers/github/conversation.d.ts +18 -0
  515. package/dist/review/providers/github/conversation.js +455 -0
  516. package/dist/review/providers/github/fields.d.ts +30 -0
  517. package/dist/review/providers/github/fields.js +47 -0
  518. package/dist/review/providers/github/index.d.ts +15 -0
  519. package/dist/review/providers/github/index.js +110 -0
  520. package/dist/review/providers/github/proposals.d.ts +14 -0
  521. package/dist/review/providers/github/proposals.js +298 -0
  522. package/dist/review/providers/github/queue.d.ts +46 -0
  523. package/dist/review/providers/github/queue.js +122 -0
  524. package/dist/review/providers/github/stacking.d.ts +20 -0
  525. package/dist/review/providers/github/stacking.js +107 -0
  526. package/dist/review/queue.d.ts +43 -0
  527. package/dist/review/queue.js +56 -0
  528. package/dist/review/reactable.d.ts +93 -0
  529. package/dist/review/reactable.js +140 -0
  530. package/dist/review/register.d.ts +52 -0
  531. package/dist/review/register.js +53 -0
  532. package/dist/review/resolve.d.ts +58 -0
  533. package/dist/review/resolve.js +150 -0
  534. package/dist/review/retarget.d.ts +73 -0
  535. package/dist/review/retarget.js +82 -0
  536. package/dist/review/revisited.d.ts +77 -0
  537. package/dist/review/revisited.js +121 -0
  538. package/dist/review/stack.d.ts +110 -0
  539. package/dist/review/stack.js +52 -0
  540. package/dist/sections/block.d.ts +9 -0
  541. package/dist/sections/block.js +42 -0
  542. package/dist/sections/detect.d.ts +31 -0
  543. package/dist/sections/detect.js +67 -0
  544. package/dist/sections/gate.d.ts +21 -0
  545. package/dist/sections/gate.js +22 -0
  546. package/dist/sections/index.d.ts +5 -0
  547. package/dist/sections/index.js +5 -0
  548. package/dist/sections/sanctioned.d.ts +13 -0
  549. package/dist/sections/sanctioned.js +21 -0
  550. package/dist/shell/index.d.ts +8 -0
  551. package/dist/shell/index.js +8 -0
  552. package/dist/shell/parse.d.ts +125 -0
  553. package/dist/shell/parse.js +298 -0
  554. package/dist/slack/api/channels.d.ts +12 -0
  555. package/dist/slack/api/channels.js +28 -0
  556. package/dist/slack/api/client.d.ts +94 -0
  557. package/dist/slack/api/client.js +272 -0
  558. package/dist/slack/api/files.d.ts +95 -0
  559. package/dist/slack/api/files.js +223 -0
  560. package/dist/slack/api/index.d.ts +11 -0
  561. package/dist/slack/api/index.js +11 -0
  562. package/dist/slack/api/messages.d.ts +98 -0
  563. package/dist/slack/api/messages.js +292 -0
  564. package/dist/slack/api/reactions.d.ts +47 -0
  565. package/dist/slack/api/reactions.js +50 -0
  566. package/dist/slack/api/resolve-conversations.d.ts +43 -0
  567. package/dist/slack/api/resolve-conversations.js +130 -0
  568. package/dist/slack/api/resolve-messages.d.ts +29 -0
  569. package/dist/slack/api/resolve-messages.js +93 -0
  570. package/dist/slack/api/resolve-users.d.ts +27 -0
  571. package/dist/slack/api/resolve-users.js +73 -0
  572. package/dist/slack/api/search.d.ts +86 -0
  573. package/dist/slack/api/search.js +186 -0
  574. package/dist/slack/api/users.d.ts +12 -0
  575. package/dist/slack/api/users.js +33 -0
  576. package/dist/slack/auth/browser-extract.d.ts +33 -0
  577. package/dist/slack/auth/browser-extract.js +201 -0
  578. package/dist/slack/auth/browser.d.ts +5 -0
  579. package/dist/slack/auth/browser.js +25 -0
  580. package/dist/slack/auth/credentials.d.ts +14 -0
  581. package/dist/slack/auth/credentials.js +24 -0
  582. package/dist/slack/auth/errors.d.ts +9 -0
  583. package/dist/slack/auth/errors.js +19 -0
  584. package/dist/slack/auth/extract.d.ts +23 -0
  585. package/dist/slack/auth/extract.js +44 -0
  586. package/dist/slack/auth/index.d.ts +12 -0
  587. package/dist/slack/auth/index.js +11 -0
  588. package/dist/slack/auth/oauth-app.d.ts +11 -0
  589. package/dist/slack/auth/oauth-app.js +20 -0
  590. package/dist/slack/auth/oauth.d.ts +31 -0
  591. package/dist/slack/auth/oauth.js +82 -0
  592. package/dist/slack/auth/server.d.ts +14 -0
  593. package/dist/slack/auth/server.js +75 -0
  594. package/dist/slack/auth/store.d.ts +17 -0
  595. package/dist/slack/auth/store.js +27 -0
  596. package/dist/slack/block-message.d.ts +9 -0
  597. package/dist/slack/block-message.js +30 -0
  598. package/dist/slack/blocks.d.ts +94 -0
  599. package/dist/slack/blocks.js +765 -0
  600. package/dist/slack/content-gate.d.ts +12 -0
  601. package/dist/slack/content-gate.js +22 -0
  602. package/dist/slack/detect.d.ts +31 -0
  603. package/dist/slack/detect.js +125 -0
  604. package/dist/slack/index.d.ts +18 -0
  605. package/dist/slack/index.js +17 -0
  606. package/dist/slack/paths.d.ts +28 -0
  607. package/dist/slack/paths.js +46 -0
  608. package/dist/slack/renderers/channel.d.ts +6 -0
  609. package/dist/slack/renderers/channel.js +27 -0
  610. package/dist/slack/renderers/index.d.ts +9 -0
  611. package/dist/slack/renderers/index.js +9 -0
  612. package/dist/slack/renderers/message.d.ts +21 -0
  613. package/dist/slack/renderers/message.js +214 -0
  614. package/dist/slack/renderers/reactions.d.ts +8 -0
  615. package/dist/slack/renderers/reactions.js +43 -0
  616. package/dist/slack/renderers/search.d.ts +6 -0
  617. package/dist/slack/renderers/search.js +39 -0
  618. package/dist/slack/renderers/user.d.ts +6 -0
  619. package/dist/slack/renderers/user.js +32 -0
  620. package/dist/slack/resolvers/cache.d.ts +29 -0
  621. package/dist/slack/resolvers/cache.js +70 -0
  622. package/dist/slack/resolvers/conversation-cache.d.ts +42 -0
  623. package/dist/slack/resolvers/conversation-cache.js +128 -0
  624. package/dist/slack/resolvers/conversation.d.ts +44 -0
  625. package/dist/slack/resolvers/conversation.js +229 -0
  626. package/dist/slack/resolvers/index.d.ts +8 -0
  627. package/dist/slack/resolvers/index.js +8 -0
  628. package/dist/slack/resolvers/target.d.ts +19 -0
  629. package/dist/slack/resolvers/target.js +45 -0
  630. package/dist/slack/resolvers/url.d.ts +20 -0
  631. package/dist/slack/resolvers/url.js +22 -0
  632. package/dist/slack/resolvers/user.d.ts +54 -0
  633. package/dist/slack/resolvers/user.js +134 -0
  634. package/dist/slack/types.d.ts +180 -0
  635. package/dist/slack/types.js +13 -0
  636. package/dist/tdd/attest.d.ts +21 -0
  637. package/dist/tdd/attest.js +21 -0
  638. package/dist/tdd/discipline.d.ts +11 -0
  639. package/dist/tdd/discipline.js +28 -0
  640. package/dist/tdd/index.d.ts +14 -0
  641. package/dist/tdd/index.js +13 -0
  642. package/dist/tdd/machine.d.ts +48 -0
  643. package/dist/tdd/machine.js +139 -0
  644. package/dist/tdd/presentation.d.ts +34 -0
  645. package/dist/tdd/presentation.js +38 -0
  646. package/dist/tdd/queries.d.ts +10 -0
  647. package/dist/tdd/queries.js +22 -0
  648. package/dist/terminal/index.d.ts +12 -0
  649. package/dist/terminal/index.js +11 -0
  650. package/dist/terminal/register.d.ts +21 -0
  651. package/dist/terminal/register.js +31 -0
  652. package/dist/terminal/resolve.d.ts +63 -0
  653. package/dist/terminal/resolve.js +117 -0
  654. package/dist/terminal/types.d.ts +134 -0
  655. package/dist/terminal/types.js +19 -0
  656. package/dist/thinking/index.d.ts +20 -0
  657. package/dist/thinking/index.js +27 -0
  658. package/dist/title/block.d.ts +9 -0
  659. package/dist/title/block.js +32 -0
  660. package/dist/title/detect.d.ts +25 -0
  661. package/dist/title/detect.js +154 -0
  662. package/dist/title/gate.d.ts +19 -0
  663. package/dist/title/gate.js +21 -0
  664. package/dist/title/index.d.ts +3 -0
  665. package/dist/title/index.js +3 -0
  666. package/dist/tree/index.d.ts +18 -0
  667. package/dist/tree/index.js +17 -0
  668. package/dist/tree/register.d.ts +21 -0
  669. package/dist/tree/register.js +31 -0
  670. package/dist/tree/resolve.d.ts +20 -0
  671. package/dist/tree/resolve.js +31 -0
  672. package/dist/tree/types.d.ts +83 -0
  673. package/dist/tree/types.js +12 -0
  674. package/dist/ui/count.d.ts +29 -0
  675. package/dist/ui/count.js +35 -0
  676. package/dist/ui/path.d.ts +25 -0
  677. package/dist/ui/path.js +40 -0
  678. package/dist/verify/index.d.ts +17 -0
  679. package/dist/verify/index.js +14 -0
  680. package/dist/verify/project.d.ts +21 -0
  681. package/dist/verify/project.js +49 -0
  682. package/dist/verify/resolve.d.ts +26 -0
  683. package/dist/verify/resolve.js +27 -0
  684. package/dist/verify/run.d.ts +31 -0
  685. package/dist/verify/run.js +145 -0
  686. package/dist/web/a11y/announcements.d.ts +67 -0
  687. package/dist/web/a11y/announcements.js +116 -0
  688. package/dist/web/a11y/budget.d.ts +75 -0
  689. package/dist/web/a11y/budget.js +97 -0
  690. package/dist/web/a11y/focus.d.ts +37 -0
  691. package/dist/web/a11y/focus.js +106 -0
  692. package/dist/web/a11y/index.d.ts +19 -0
  693. package/dist/web/a11y/index.js +25 -0
  694. package/dist/web/a11y/naming.d.ts +23 -0
  695. package/dist/web/a11y/naming.js +55 -0
  696. package/dist/web/a11y/outline.d.ts +23 -0
  697. package/dist/web/a11y/outline.js +42 -0
  698. package/dist/web/a11y/reading.d.ts +12 -0
  699. package/dist/web/a11y/reading.js +101 -0
  700. package/dist/web/a11y/scope.d.ts +23 -0
  701. package/dist/web/a11y/scope.js +99 -0
  702. package/dist/web/a11y/states.d.ts +22 -0
  703. package/dist/web/a11y/states.js +53 -0
  704. package/dist/web/a11y/tree.d.ts +124 -0
  705. package/dist/web/a11y/tree.js +269 -0
  706. package/dist/web/a11y/walk.d.ts +225 -0
  707. package/dist/web/a11y/walk.js +568 -0
  708. package/dist/web/a11y/walkprobe.d.ts +44 -0
  709. package/dist/web/a11y/walkprobe.js +365 -0
  710. package/dist/web/audit/axe.d.ts +219 -0
  711. package/dist/web/audit/axe.js +322 -0
  712. package/dist/web/audit/behind.d.ts +63 -0
  713. package/dist/web/audit/behind.js +142 -0
  714. package/dist/web/audit/capture.d.ts +43 -0
  715. package/dist/web/audit/capture.js +185 -0
  716. package/dist/web/audit/colour.d.ts +85 -0
  717. package/dist/web/audit/colour.js +189 -0
  718. package/dist/web/audit/contrast.d.ts +74 -0
  719. package/dist/web/audit/contrast.js +104 -0
  720. package/dist/web/audit/health.d.ts +27 -0
  721. package/dist/web/audit/health.js +57 -0
  722. package/dist/web/audit/index.d.ts +22 -0
  723. package/dist/web/audit/index.js +22 -0
  724. package/dist/web/audit/pair.d.ts +55 -0
  725. package/dist/web/audit/pair.js +157 -0
  726. package/dist/web/audit/probe.d.ts +31 -0
  727. package/dist/web/audit/probe.js +189 -0
  728. package/dist/web/audit/report.d.ts +22 -0
  729. package/dist/web/audit/report.js +250 -0
  730. package/dist/web/audit/structure.d.ts +126 -0
  731. package/dist/web/audit/structure.js +595 -0
  732. package/dist/web/audit/sweep.d.ts +66 -0
  733. package/dist/web/audit/sweep.js +117 -0
  734. package/dist/web/audit/target.d.ts +89 -0
  735. package/dist/web/audit/target.js +168 -0
  736. package/dist/web/audit/verdict.d.ts +48 -0
  737. package/dist/web/audit/verdict.js +52 -0
  738. package/dist/web/audit/visual.d.ts +161 -0
  739. package/dist/web/audit/visual.js +297 -0
  740. package/dist/web/browser.d.ts +213 -0
  741. package/dist/web/browser.js +927 -0
  742. package/dist/web/compare/images.d.ts +45 -0
  743. package/dist/web/compare/images.js +101 -0
  744. package/dist/web/compare/index.d.ts +15 -0
  745. package/dist/web/compare/index.js +15 -0
  746. package/dist/web/compare/provenance.d.ts +48 -0
  747. package/dist/web/compare/provenance.js +86 -0
  748. package/dist/web/compare/regions.d.ts +78 -0
  749. package/dist/web/compare/regions.js +211 -0
  750. package/dist/web/cookies/extract.d.ts +26 -0
  751. package/dist/web/cookies/extract.js +167 -0
  752. package/dist/web/cookies/index.d.ts +8 -0
  753. package/dist/web/cookies/index.js +7 -0
  754. package/dist/web/cookies/inject.d.ts +13 -0
  755. package/dist/web/cookies/inject.js +27 -0
  756. package/dist/web/cookies/setup.d.ts +31 -0
  757. package/dist/web/cookies/setup.js +94 -0
  758. package/dist/web/design/index.d.ts +9 -0
  759. package/dist/web/design/index.js +9 -0
  760. package/dist/web/design/inventory.d.ts +126 -0
  761. package/dist/web/design/inventory.js +324 -0
  762. package/dist/web/design/probe.d.ts +24 -0
  763. package/dist/web/design/probe.js +88 -0
  764. package/dist/web/element/actionable.d.ts +34 -0
  765. package/dist/web/element/actionable.js +48 -0
  766. package/dist/web/element/animations.d.ts +48 -0
  767. package/dist/web/element/animations.js +74 -0
  768. package/dist/web/element/box.d.ts +53 -0
  769. package/dist/web/element/box.js +58 -0
  770. package/dist/web/element/hover.d.ts +75 -0
  771. package/dist/web/element/hover.js +172 -0
  772. package/dist/web/element/index.d.ts +17 -0
  773. package/dist/web/element/index.js +17 -0
  774. package/dist/web/element/listeners.d.ts +72 -0
  775. package/dist/web/element/listeners.js +98 -0
  776. package/dist/web/element/measure.d.ts +40 -0
  777. package/dist/web/element/measure.js +118 -0
  778. package/dist/web/element/probes.d.ts +108 -0
  779. package/dist/web/element/probes.js +195 -0
  780. package/dist/web/element/pseudo.d.ts +51 -0
  781. package/dist/web/element/pseudo.js +96 -0
  782. package/dist/web/element/view.d.ts +30 -0
  783. package/dist/web/element/view.js +117 -0
  784. package/dist/web/element/visibility.d.ts +42 -0
  785. package/dist/web/element/visibility.js +67 -0
  786. package/dist/web/envelope/artifacts.d.ts +23 -0
  787. package/dist/web/envelope/artifacts.js +45 -0
  788. package/dist/web/envelope/index.d.ts +9 -0
  789. package/dist/web/envelope/index.js +9 -0
  790. package/dist/web/envelope/naming.d.ts +23 -0
  791. package/dist/web/envelope/naming.js +43 -0
  792. package/dist/web/envelope/paged.d.ts +42 -0
  793. package/dist/web/envelope/paged.js +99 -0
  794. package/dist/web/envelope/sink.d.ts +43 -0
  795. package/dist/web/envelope/sink.js +67 -0
  796. package/dist/web/environment/devices.d.ts +65 -0
  797. package/dist/web/environment/devices.js +82 -0
  798. package/dist/web/environment/emulation.d.ts +124 -0
  799. package/dist/web/environment/emulation.js +258 -0
  800. package/dist/web/environment/index.d.ts +15 -0
  801. package/dist/web/environment/index.js +15 -0
  802. package/dist/web/environment/probes.d.ts +18 -0
  803. package/dist/web/environment/probes.js +40 -0
  804. package/dist/web/environment/shaping.d.ts +90 -0
  805. package/dist/web/environment/shaping.js +141 -0
  806. package/dist/web/environment/status.d.ts +51 -0
  807. package/dist/web/environment/status.js +109 -0
  808. package/dist/web/environment/storage.d.ts +55 -0
  809. package/dist/web/environment/storage.js +142 -0
  810. package/dist/web/environment/tabs.d.ts +32 -0
  811. package/dist/web/environment/tabs.js +47 -0
  812. package/dist/web/environment/view.d.ts +10 -0
  813. package/dist/web/environment/view.js +42 -0
  814. package/dist/web/evaluate/index.d.ts +6 -0
  815. package/dist/web/evaluate/index.js +6 -0
  816. package/dist/web/evaluate/outcome.d.ts +74 -0
  817. package/dist/web/evaluate/outcome.js +91 -0
  818. package/dist/web/evaluate/probe.d.ts +31 -0
  819. package/dist/web/evaluate/probe.js +303 -0
  820. package/dist/web/index.d.ts +47 -0
  821. package/dist/web/index.js +47 -0
  822. package/dist/web/input/index.d.ts +11 -0
  823. package/dist/web/input/index.js +11 -0
  824. package/dist/web/input/keys.d.ts +48 -0
  825. package/dist/web/input/keys.js +189 -0
  826. package/dist/web/input/pointer.d.ts +56 -0
  827. package/dist/web/input/pointer.js +77 -0
  828. package/dist/web/input/touch.d.ts +61 -0
  829. package/dist/web/input/touch.js +83 -0
  830. package/dist/web/mermaid.d.ts +69 -0
  831. package/dist/web/mermaid.js +223 -0
  832. package/dist/web/paths.d.ts +16 -0
  833. package/dist/web/paths.js +27 -0
  834. package/dist/web/perf/heap.d.ts +42 -0
  835. package/dist/web/perf/heap.js +73 -0
  836. package/dist/web/perf/index.d.ts +14 -0
  837. package/dist/web/perf/index.js +14 -0
  838. package/dist/web/perf/layers.d.ts +98 -0
  839. package/dist/web/perf/layers.js +165 -0
  840. package/dist/web/perf/probe.d.ts +26 -0
  841. package/dist/web/perf/probe.js +123 -0
  842. package/dist/web/perf/profile.d.ts +53 -0
  843. package/dist/web/perf/profile.js +97 -0
  844. package/dist/web/perf/trace.d.ts +152 -0
  845. package/dist/web/perf/trace.js +429 -0
  846. package/dist/web/perf/view.d.ts +6 -0
  847. package/dist/web/perf/view.js +86 -0
  848. package/dist/web/perf/vitals.d.ts +141 -0
  849. package/dist/web/perf/vitals.js +175 -0
  850. package/dist/web/reader.d.ts +131 -0
  851. package/dist/web/reader.js +340 -0
  852. package/dist/web/screenshot.d.ts +50 -0
  853. package/dist/web/screenshot.js +108 -0
  854. package/dist/web/search.d.ts +49 -0
  855. package/dist/web/search.js +137 -0
  856. package/dist/web/session/artifacts.d.ts +32 -0
  857. package/dist/web/session/artifacts.js +47 -0
  858. package/dist/web/session/emulation.d.ts +118 -0
  859. package/dist/web/session/emulation.js +307 -0
  860. package/dist/web/session/recording.d.ts +51 -0
  861. package/dist/web/session/recording.js +64 -0
  862. package/dist/web/session/settling.d.ts +42 -0
  863. package/dist/web/session/settling.js +104 -0
  864. package/dist/web/session/shaping.d.ts +48 -0
  865. package/dist/web/session/shaping.js +113 -0
  866. package/dist/web/session/sourcemaps.d.ts +64 -0
  867. package/dist/web/session/sourcemaps.js +135 -0
  868. package/dist/web/session/telemetry.d.ts +219 -0
  869. package/dist/web/session/telemetry.js +486 -0
  870. package/dist/web/session/wires.d.ts +22 -0
  871. package/dist/web/session/wires.js +11 -0
  872. package/dist/web/session.d.ts +1153 -0
  873. package/dist/web/session.js +3400 -0
  874. package/dist/web/snapshot/deep.d.ts +36 -0
  875. package/dist/web/snapshot/deep.js +91 -0
  876. package/dist/web/snapshot/flatten.d.ts +101 -0
  877. package/dist/web/snapshot/flatten.js +131 -0
  878. package/dist/web/snapshot/index.d.ts +8 -0
  879. package/dist/web/snapshot/index.js +10 -0
  880. package/dist/web/snapshot/presented.d.ts +32 -0
  881. package/dist/web/snapshot/presented.js +74 -0
  882. package/dist/web/snapshot/query.d.ts +67 -0
  883. package/dist/web/snapshot/query.js +136 -0
  884. package/dist/web/sourcemap/index.d.ts +9 -0
  885. package/dist/web/sourcemap/index.js +9 -0
  886. package/dist/web/sourcemap/mappings.d.ts +111 -0
  887. package/dist/web/sourcemap/mappings.js +218 -0
  888. package/dist/web/styles/capture.d.ts +49 -0
  889. package/dist/web/styles/capture.js +85 -0
  890. package/dist/web/styles/cascade.d.ts +107 -0
  891. package/dist/web/styles/cascade.js +275 -0
  892. package/dist/web/styles/curation.d.ts +45 -0
  893. package/dist/web/styles/curation.js +282 -0
  894. package/dist/web/styles/index.d.ts +10 -0
  895. package/dist/web/styles/index.js +10 -0
  896. package/dist/web/target/index.d.ts +7 -0
  897. package/dist/web/target/index.js +7 -0
  898. package/dist/web/target/refusals.d.ts +59 -0
  899. package/dist/web/target/refusals.js +305 -0
  900. package/dist/web/target/target.d.ts +59 -0
  901. package/dist/web/target/target.js +94 -0
  902. package/dist/web/telemetry/buffer.d.ts +35 -0
  903. package/dist/web/telemetry/buffer.js +72 -0
  904. package/dist/web/telemetry/console.d.ts +127 -0
  905. package/dist/web/telemetry/console.js +217 -0
  906. package/dist/web/telemetry/dialogs.d.ts +41 -0
  907. package/dist/web/telemetry/dialogs.js +38 -0
  908. package/dist/web/telemetry/downloads.d.ts +42 -0
  909. package/dist/web/telemetry/downloads.js +65 -0
  910. package/dist/web/telemetry/failure.d.ts +31 -0
  911. package/dist/web/telemetry/failure.js +72 -0
  912. package/dist/web/telemetry/har.d.ts +97 -0
  913. package/dist/web/telemetry/har.js +227 -0
  914. package/dist/web/telemetry/index.d.ts +18 -0
  915. package/dist/web/telemetry/index.js +18 -0
  916. package/dist/web/telemetry/lifecycle.d.ts +69 -0
  917. package/dist/web/telemetry/lifecycle.js +120 -0
  918. package/dist/web/telemetry/network.d.ts +152 -0
  919. package/dist/web/telemetry/network.js +130 -0
  920. package/dist/web/telemetry/requests.d.ts +31 -0
  921. package/dist/web/telemetry/requests.js +119 -0
  922. package/dist/web/telemetry/sockets.d.ts +56 -0
  923. package/dist/web/telemetry/sockets.js +101 -0
  924. package/dist/web/telemetry/view.d.ts +16 -0
  925. package/dist/web/telemetry/view.js +125 -0
  926. package/dist/web/wait/conditions.d.ts +87 -0
  927. package/dist/web/wait/conditions.js +100 -0
  928. package/dist/web/wait/index.d.ts +6 -0
  929. package/dist/web/wait/index.js +6 -0
  930. package/dist/web/wait/settle.d.ts +54 -0
  931. package/dist/web/wait/settle.js +84 -0
  932. package/dist/work/ask.d.ts +45 -0
  933. package/dist/work/ask.js +85 -0
  934. package/dist/work/author.d.ts +61 -0
  935. package/dist/work/author.js +144 -0
  936. package/dist/work/broker.d.ts +151 -0
  937. package/dist/work/broker.js +165 -0
  938. package/dist/work/events.d.ts +98 -0
  939. package/dist/work/events.js +57 -0
  940. package/dist/work/history.d.ts +69 -0
  941. package/dist/work/history.js +174 -0
  942. package/dist/work/index.d.ts +49 -0
  943. package/dist/work/index.js +33 -0
  944. package/dist/work/inplay.d.ts +43 -0
  945. package/dist/work/inplay.js +42 -0
  946. package/dist/work/memory.d.ts +84 -0
  947. package/dist/work/memory.js +203 -0
  948. package/dist/work/objection.d.ts +92 -0
  949. package/dist/work/objection.js +72 -0
  950. package/dist/work/provider.d.ts +79 -0
  951. package/dist/work/provider.js +45 -0
  952. package/dist/work/providers/git.d.ts +29 -0
  953. package/dist/work/providers/git.js +87 -0
  954. package/dist/work/publish.d.ts +53 -0
  955. package/dist/work/publish.js +139 -0
  956. package/dist/work/rebase.d.ts +78 -0
  957. package/dist/work/rebase.js +261 -0
  958. package/dist/work/reclaim.d.ts +56 -0
  959. package/dist/work/reclaim.js +52 -0
  960. package/dist/work/register.d.ts +29 -0
  961. package/dist/work/register.js +41 -0
  962. package/dist/work/stack.d.ts +126 -0
  963. package/dist/work/stack.js +243 -0
  964. package/dist/work/stacks.d.ts +156 -0
  965. package/dist/work/stacks.js +524 -0
  966. package/dist/work/survey.d.ts +52 -0
  967. package/dist/work/survey.js +58 -0
  968. package/dist/work/tidy.d.ts +147 -0
  969. package/dist/work/tidy.js +136 -0
  970. package/dist/work/tree.d.ts +120 -0
  971. package/dist/work/tree.js +69 -0
  972. package/dist/work/unattended.d.ts +40 -0
  973. package/dist/work/unattended.js +57 -0
  974. package/package.json +145 -0
@@ -0,0 +1,927 @@
1
+ /**
2
+ * Browser lifecycle: launch Chrome once, reuse across tool calls.
3
+ * Pure Chrome management: no cookie knowledge.
4
+ *
5
+ * The singleton lives on globalThis rather than in a module
6
+ * variable. Pi loads each extension as its own module instance,
7
+ * so a module-level singleton would give web search, mermaid and
8
+ * the browser tool a browser each, all racing to launch Chrome
9
+ * against the same per-pid profile; the first wins the profile
10
+ * lock and the rest fail to launch. A process-global instance,
11
+ * plus a shared in-flight launch promise, means one browser and
12
+ * one profile no matter how many extensions reach for it.
13
+ */
14
+ import { execFileSync } from "node:child_process";
15
+ import * as crypto from "node:crypto";
16
+ import * as fs from "node:fs";
17
+ import * as os from "node:os";
18
+ import * as path from "node:path";
19
+ import { clearTimeout, setTimeout } from "node:timers";
20
+ import puppeteer from "puppeteer-core";
21
+ import { processGlobal } from "../internal/process-global.js";
22
+ /** How many times to try launching Chrome before giving up. */
23
+ const LAUNCH_ATTEMPTS = 3;
24
+ /** Backoff before each retry, in milliseconds. The array length is
25
+ * LAUNCH_ATTEMPTS - 1; a Chrome self-update window clears in seconds. */
26
+ const LAUNCH_BACKOFF_MS = [500, 1500];
27
+ /** Close the shared browser after this long with no new page opened. */
28
+ const IDLE_TIMEOUT_MS = 5 * 60_000;
29
+ /** Parse a Puppeteer launch error into an exit code and Chrome's stderr. */
30
+ export function classifyLaunchError(err) {
31
+ const message = err instanceof Error ? err.message : String(err);
32
+ const info = {};
33
+ const code = message.match(/Code:\s*(\d+)/);
34
+ if (code)
35
+ info.exitCode = Number(code[1]);
36
+ // Puppeteer frames Chrome's own output between a `stderr:` header
37
+ // and its troubleshooting footer; lift whatever sits in between.
38
+ const stderr = message.match(/stderr:\s*\n([\s\S]*?)\n\s*TROUBLESHOOTING/);
39
+ const captured = stderr?.[1]?.trim();
40
+ if (captured)
41
+ info.chromeStderr = captured;
42
+ return info;
43
+ }
44
+ /** Build a human-readable message for a launch that never came up. */
45
+ export function formatLaunchFailure(info, attempts, fallback) {
46
+ const code = info.exitCode === undefined ? "" : ` (exit code ${info.exitCode})`;
47
+ const lines = [
48
+ `Chrome could not be launched after ${attempts} attempts${code}.`,
49
+ "This is often transient on macOS when Chrome is auto-updating in " +
50
+ "the background, and retrying in a minute usually clears it. If it " +
51
+ "keeps failing, check that Google Chrome opens normally, or set " +
52
+ "CHROME_PATH to a working binary.",
53
+ ];
54
+ if (info.chromeStderr)
55
+ lines.push("", "Chrome said:", info.chromeStderr);
56
+ // When the failure is not a parseable Chrome exit (an EACCES or
57
+ // ENOSPC from the profile, say), keep the raw reason rather than
58
+ // discarding it behind the generic hint.
59
+ else if (fallback)
60
+ lines.push("", fallback);
61
+ return lines.join("\n");
62
+ }
63
+ /** Thrown when Chrome could not be launched after the retry budget. */
64
+ export class BrowserLaunchFailed extends Error {
65
+ exitCode;
66
+ chromeStderr;
67
+ constructor(cause, attempts) {
68
+ const info = classifyLaunchError(cause);
69
+ const fallback = cause instanceof Error ? cause.message : String(cause);
70
+ super(formatLaunchFailure(info, attempts, fallback));
71
+ this.name = "BrowserLaunchFailed";
72
+ this.exitCode = info.exitCode;
73
+ this.chromeStderr = info.chromeStderr;
74
+ this.cause = cause;
75
+ }
76
+ }
77
+ const defaultGroupKill = (pid, signal) => {
78
+ process.kill(pid, signal);
79
+ };
80
+ /**
81
+ * Kill a detached Chrome's whole process group, falling back to the
82
+ * bare pid. Chrome is spawned detached, so its pgid equals its pid;
83
+ * the negative pid reaps every helper (GPU, network, renderers) that
84
+ * a lone pid kill would leave to reparent to launchd.
85
+ */
86
+ export function killPidGroup(pid, groupKill = defaultGroupKill) {
87
+ try {
88
+ groupKill(-pid, "SIGKILL");
89
+ }
90
+ catch {
91
+ // The group is gone or unkillable; try the leader on its own.
92
+ try {
93
+ groupKill(pid, "SIGKILL");
94
+ }
95
+ catch {
96
+ // Nothing left to kill; the process already exited.
97
+ }
98
+ }
99
+ }
100
+ /** Kill a live browser process tree: group first, then proc.kill fallback. */
101
+ export function killTree(proc, groupKill = defaultGroupKill) {
102
+ const pid = proc?.pid;
103
+ if (!proc || !pid)
104
+ return;
105
+ try {
106
+ groupKill(-pid, "SIGKILL");
107
+ }
108
+ catch {
109
+ // Group kill failed; fall back to Puppeteer's own process handle.
110
+ try {
111
+ proc.kill("SIGKILL");
112
+ }
113
+ catch {
114
+ // Already dead.
115
+ }
116
+ }
117
+ }
118
+ /**
119
+ * True when a profile's owning process is still running. Liveness is keyed
120
+ * on the pid alone: a generation-unique profile directory means a
121
+ * reused pid can never collide with a live owner's directory, so a
122
+ * pid that is alive is treated as the owner and kept. This fails
123
+ * closed, a reused pid only ever leaks a stale directory rather than
124
+ * killing a live browser.
125
+ */
126
+ function ownerAlive(opts, entry, owner) {
127
+ const pid = owner ? owner.ownerPid : Number.parseInt(entry, 10);
128
+ return Number.isFinite(pid) && opts.isPidAlive(pid);
129
+ }
130
+ /** True when a probe reports the pid still names this exact profile. */
131
+ function stillOurs(opts, pid, dir) {
132
+ try {
133
+ return opts.verifyBrowser(pid, dir);
134
+ }
135
+ catch {
136
+ // Cannot confirm, so treat it as still present and fail safe.
137
+ return true;
138
+ }
139
+ }
140
+ /**
141
+ * Reap Chrome trees and profile dirs a prior run left behind. Each
142
+ * dir is reaped only when its owning process is dead. The candidate kill
143
+ * set is the exact-profile matches unioned with a recorded pid; each
144
+ * candidate is re-verified immediately before it is signalled, so a
145
+ * pid that exited and was reused is never group-killed. The dir is
146
+ * removed only once discovery has run and a fresh check confirms no
147
+ * candidate still names it, so a failed probe or a surviving process
148
+ * keeps the dir for a later sweep. Every step is best-effort: one bad
149
+ * entry can never abort the sweep or block a launch.
150
+ */
151
+ export function reapOrphans(opts) {
152
+ for (const entry of opts.listEntries()) {
153
+ try {
154
+ const dir = path.join(opts.root, entry);
155
+ let owner;
156
+ try {
157
+ owner = opts.readOwner(dir);
158
+ }
159
+ catch {
160
+ // Unreadable record; treat as no record.
161
+ }
162
+ if (ownerAlive(opts, entry, owner))
163
+ continue;
164
+ const discovered = opts.findProcsByProfile(dir);
165
+ const candidates = new Set(discovered ?? []);
166
+ if (owner?.browserPid)
167
+ candidates.add(owner.browserPid);
168
+ for (const pid of candidates) {
169
+ // Re-verify at signalling time: a stale discovery entry or a
170
+ // pid that has since been reused must not be group-killed.
171
+ if (!stillOurs(opts, pid, dir))
172
+ continue;
173
+ try {
174
+ opts.killPid(pid);
175
+ }
176
+ catch {
177
+ // Lost a race with the process exiting; a later sweep
178
+ // reclaims the dir.
179
+ }
180
+ }
181
+ // Remove the dir only when discovery ran and nothing we targeted
182
+ // still names the profile. A failed probe or a survivor keeps it.
183
+ if (discovered === undefined)
184
+ continue;
185
+ const cleared = [...candidates].every((pid) => !stillOurs(opts, pid, dir));
186
+ if (!cleared)
187
+ continue;
188
+ try {
189
+ opts.removeDir(dir);
190
+ }
191
+ catch {
192
+ // A busy or unreadable dir must not block launches; the next
193
+ // startup sweeps whatever this one could not.
194
+ }
195
+ }
196
+ catch {
197
+ // Defensive: never let one entry abort the whole sweep.
198
+ }
199
+ }
200
+ }
201
+ /**
202
+ * Puppeteer opens one blank page on launch, so a browser with no
203
+ * consumer page open sits at this count. A higher count means work
204
+ * is in flight.
205
+ */
206
+ const INITIAL_PAGE_COUNT = 1;
207
+ /** Decide whether an idle browser is truly unused and safe to close. */
208
+ export function shouldCloseWhenIdle(openPageCount) {
209
+ return openPageCount <= INITIAL_PAGE_COUNT;
210
+ }
211
+ /**
212
+ * Decide whether teardown should force-kill the browser process group.
213
+ * Never after a clean graceful close, since the pid is already gone and
214
+ * could be reused; only when the close did not happen and the process
215
+ * still verifies as our Chrome.
216
+ */
217
+ export function shouldForceKill(closedGracefully, stillVerifies) {
218
+ return !closedGracefully && stillVerifies;
219
+ }
220
+ /** Build an idle-close countdown that rearms on touch and stops on cancel. */
221
+ export function createIdleCloser(opts) {
222
+ const setTimer = opts.setTimer ?? setTimeout;
223
+ const clearTimer = opts.clearTimer ?? clearTimeout;
224
+ let timer;
225
+ const cancel = () => {
226
+ if (timer !== undefined) {
227
+ clearTimer(timer);
228
+ timer = undefined;
229
+ }
230
+ };
231
+ return {
232
+ touch() {
233
+ cancel();
234
+ timer = setTimer(() => {
235
+ timer = undefined;
236
+ opts.close();
237
+ }, opts.idleMs);
238
+ // A pending idle close must not, by itself, hold the event loop
239
+ // open and delay process exit.
240
+ timer.unref?.();
241
+ },
242
+ cancel,
243
+ };
244
+ }
245
+ function sharedState() {
246
+ return processGlobal("pi:web-shared-browser", () => ({}));
247
+ }
248
+ /**
249
+ * Parent dir for per-launch Chrome profiles. Each launch gets
250
+ * its own subdir; a startup sweep removes the ones left behind
251
+ * by a prior run that a SIGKILL or crash could not clean, which
252
+ * is the orphan the clean-exit teardown never reclaims.
253
+ */
254
+ const PROFILE_ROOT = path.join(os.tmpdir(), "pi-web-chrome");
255
+ /**
256
+ * This process's own profile directory, resolved once and shared
257
+ * across extension module instances. The name carries a random
258
+ * generation nonce alongside the pid, so a reused pid can never
259
+ * collide with a previous run's directory and the reaper can treat
260
+ * a live pid as its owner without a fragile start-time probe.
261
+ */
262
+ function ownProfileDir() {
263
+ return processGlobal("pi:web-chrome-profile", () => path.join(PROFILE_ROOT, `${process.pid}-${crypto.randomBytes(6).toString("hex")}`));
264
+ }
265
+ /** The ownership record path inside a profile dir. */
266
+ function ownerFile(profileDir) {
267
+ return path.join(profileDir, "owner.json");
268
+ }
269
+ /** Read a profile's ownership record, or undefined if absent or unreadable. */
270
+ function readOwnerRecord(profileDir) {
271
+ try {
272
+ const raw = fs.readFileSync(ownerFile(profileDir), "utf8");
273
+ const rec = JSON.parse(raw);
274
+ if (typeof rec?.ownerPid === "number")
275
+ return rec;
276
+ }
277
+ catch {
278
+ // No record, or malformed; the caller treats this as no record.
279
+ }
280
+ return undefined;
281
+ }
282
+ /** True when a pid names a live process (EPERM still means it exists). */
283
+ export function isPidAlive(pid) {
284
+ try {
285
+ process.kill(pid, 0);
286
+ return true;
287
+ }
288
+ catch (err) {
289
+ return err.code === "EPERM";
290
+ }
291
+ }
292
+ /**
293
+ * Confirm a single pid is still the Chrome we launched for `profileDir`,
294
+ * by matching its --user-data-dir argument exactly. This guards the
295
+ * kill against a reused pid now owned by an unrelated process.
296
+ */
297
+ function verifyBrowser(pid, profileDir) {
298
+ try {
299
+ const cmd = execFileSync("ps", ["-p", String(pid), "-o", "command="], {
300
+ encoding: "utf8",
301
+ });
302
+ return namesProfile(cmd, profileDir);
303
+ }
304
+ catch {
305
+ return false;
306
+ }
307
+ }
308
+ function escapeRegExp(value) {
309
+ return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
310
+ }
311
+ /**
312
+ * True when `command` carries this exact profile as its
313
+ * --user-data-dir. Both sides of the value are anchored, so neither a
314
+ * longer sibling path nor a differently-prefixed flag can collide.
315
+ */
316
+ export function namesProfile(command, profileDir) {
317
+ return new RegExp(`(?:^|\\s)--user-data-dir=${escapeRegExp(profileDir)}(?:\\s|$)`).test(command);
318
+ }
319
+ /**
320
+ * Pids that still name `profileDir` as their --user-data-dir, matched
321
+ * as an exact argument so a longer sibling path never collides. Used
322
+ * only to rediscover an orphan whose owner is already proven dead.
323
+ */
324
+ function findProcsByProfile(profileDir) {
325
+ try {
326
+ const out = execFileSync("ps", ["-eo", "pid=,command="], {
327
+ encoding: "utf8",
328
+ maxBuffer: 8 * 1024 * 1024,
329
+ });
330
+ const pids = [];
331
+ for (const line of out.split("\n")) {
332
+ if (!namesProfile(line, profileDir))
333
+ continue;
334
+ const pid = Number.parseInt(line.trim(), 10);
335
+ if (Number.isFinite(pid) && pid !== process.pid)
336
+ pids.push(pid);
337
+ }
338
+ return pids;
339
+ }
340
+ catch {
341
+ // The probe itself failed: signal "unknown", not "none", so a
342
+ // still-running orphan is not mistaken for an empty result.
343
+ return undefined;
344
+ }
345
+ }
346
+ /** Record who owns this profile, which Chrome pid it launched, and how a
347
+ * separate process can reach that same browser. */
348
+ function writeOwnerRecord(profileDir, browserPid, browserWSEndpoint) {
349
+ const record = {
350
+ ownerPid: process.pid,
351
+ browserPid,
352
+ browserWSEndpoint,
353
+ };
354
+ try {
355
+ fs.writeFileSync(ownerFile(profileDir), JSON.stringify(record));
356
+ }
357
+ catch {
358
+ // A missing record only downgrades a future reap to bare-pid
359
+ // liveness, so a write failure is not worth failing the launch.
360
+ }
361
+ }
362
+ /**
363
+ * Reap Chrome trees and profile dirs left behind by a prior run.
364
+ * A dir is reaped only when its owning process is provably dead, so a
365
+ * live sibling process keeps its browser; the recorded Chrome pid is
366
+ * killed only after an exact re-verify.
367
+ */
368
+ function reapOrphanProfiles() {
369
+ reapOrphans({
370
+ root: PROFILE_ROOT,
371
+ listEntries: () => {
372
+ try {
373
+ return fs.readdirSync(PROFILE_ROOT);
374
+ }
375
+ catch {
376
+ // No profile root yet; nothing to reap.
377
+ return [];
378
+ }
379
+ },
380
+ readOwner: readOwnerRecord,
381
+ isPidAlive,
382
+ verifyBrowser,
383
+ findProcsByProfile,
384
+ killPid: (pid) => killPidGroup(pid),
385
+ removeDir: (dir) => fs.rmSync(dir, { recursive: true, force: true }),
386
+ });
387
+ }
388
+ /**
389
+ * Kill Chrome and exit on the signals that would otherwise
390
+ * orphan it (SIGINT, SIGTERM, SIGHUP), and on clean exit. A
391
+ * hard-killed subagent gets SIGTERM, so this is what keeps the
392
+ * RELY01 orphan from accumulating.
393
+ */
394
+ function installLifecycleHandlers() {
395
+ const state = sharedState();
396
+ if (state.lifecycleInstalled)
397
+ return;
398
+ state.lifecycleInstalled = true;
399
+ process.once("exit", killBrowserSync);
400
+ for (const signal of ["SIGINT", "SIGTERM", "SIGHUP"]) {
401
+ process.once(signal, () => {
402
+ killBrowserSync();
403
+ process.exit(0);
404
+ });
405
+ }
406
+ }
407
+ const CHROME_PATHS = [
408
+ "/Applications/Google Chrome.app/Contents/MacOS/Google Chrome",
409
+ "/Applications/Chromium.app/Contents/MacOS/Chromium",
410
+ "/usr/bin/google-chrome",
411
+ "/usr/bin/google-chrome-stable",
412
+ "/usr/bin/chromium",
413
+ "/usr/bin/chromium-browser",
414
+ // Ubuntu ships Chromium as a snap, which lands here and on no
415
+ // other path in this list.
416
+ "/snap/bin/chromium",
417
+ ];
418
+ /** Whether a path is there, treating an unreadable path as absent. */
419
+ function present(p) {
420
+ try {
421
+ return fs.existsSync(p);
422
+ }
423
+ catch {
424
+ // An unreadable path is no use to us either way, so it counts
425
+ // as absent and the caller moves on.
426
+ return false;
427
+ }
428
+ }
429
+ function findChrome() {
430
+ for (const p of CHROME_PATHS) {
431
+ if (present(p))
432
+ return p;
433
+ }
434
+ throw new Error("Chrome not found. Install Google Chrome or set CHROME_PATH.");
435
+ }
436
+ /**
437
+ * Settle on the binary to launch, refusing a configured path that is
438
+ * not there.
439
+ *
440
+ * CHROME_PATH used to be taken on trust, so a stale or mistyped
441
+ * value fell through to the launch loop: three attempts, two
442
+ * backoffs, and then a message whose first line blamed a Chrome
443
+ * auto-update. None of that is true of a path that does not exist,
444
+ * and no amount of retrying fixes it. A missing Chrome was already
445
+ * treated as the settled misconfig it is; this is the same fault
446
+ * arriving by a different door.
447
+ */
448
+ export function resolveChromePath(configured, exists = present) {
449
+ if (!configured)
450
+ return findChrome();
451
+ if (!exists(configured))
452
+ throw new Error(`CHROME_PATH is set to ${configured}, which does not exist. ` +
453
+ "Point it at a Chrome or Chromium binary, or unset it to use " +
454
+ "the installed browser.");
455
+ return configured;
456
+ }
457
+ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
458
+ /** How long to wait for Chrome to publish the port it bound for
459
+ * --remote-debugging-port=0, polling since the write lands on a
460
+ * different schedule than the DevTools pipe launch() already waited on. */
461
+ const DEVTOOLS_PORT_TIMEOUT_MS = 2000;
462
+ const DEVTOOLS_PORT_POLL_MS = 50;
463
+ /** Path Chrome writes its bound remote-debugging port to. */
464
+ function devToolsActivePortFile(profileDir) {
465
+ return path.join(profileDir, "DevToolsActivePort");
466
+ }
467
+ /** Read the port Chrome bound for --remote-debugging-port=0, polling
468
+ * briefly since the file is not necessarily there the instant launch()
469
+ * resolves. Undefined when it never appears within the budget. */
470
+ async function readDevToolsPort(profileDir) {
471
+ const deadline = Date.now() + DEVTOOLS_PORT_TIMEOUT_MS;
472
+ for (;;) {
473
+ try {
474
+ const raw = fs.readFileSync(devToolsActivePortFile(profileDir), "utf8");
475
+ const port = Number.parseInt(raw.split("\n")[0] ?? "", 10);
476
+ if (Number.isFinite(port) && port > 0)
477
+ return port;
478
+ }
479
+ catch {
480
+ // Not written yet, or unreadable; keep polling until the deadline.
481
+ }
482
+ if (Date.now() >= deadline)
483
+ return undefined;
484
+ await sleep(DEVTOOLS_PORT_POLL_MS);
485
+ }
486
+ }
487
+ /** Ask Chrome's DevTools HTTP endpoint for the browser-wide WebSocket URL
488
+ * a separate process can connect() to. Best-effort: a failure here only
489
+ * means cross-process reconnection is unavailable, never that the launch
490
+ * itself failed. */
491
+ async function readBrowserWSEndpoint(port) {
492
+ try {
493
+ const res = await fetch(`http://127.0.0.1:${port}/json/version`);
494
+ const body = await res.json();
495
+ const url = body
496
+ .webSocketDebuggerUrl;
497
+ return typeof url === "string" ? url : undefined;
498
+ }
499
+ catch {
500
+ return undefined;
501
+ }
502
+ }
503
+ /** Launch headless Chrome once, against a freshly reset profile. */
504
+ async function launchOnce(executablePath) {
505
+ const profileDir = ownProfileDir();
506
+ // Reset the profile so a half-dead Chrome's SingletonLock from a
507
+ // prior attempt cannot poison this one.
508
+ fs.rmSync(profileDir, { recursive: true, force: true });
509
+ fs.mkdirSync(profileDir, { recursive: true });
510
+ const browser = await puppeteer.launch({
511
+ executablePath,
512
+ headless: true,
513
+ userDataDir: profileDir,
514
+ args: [
515
+ "--no-sandbox",
516
+ "--disable-setuid-sandbox",
517
+ "--disable-gpu",
518
+ "--disable-dev-shm-usage",
519
+ // Route Chrome's own errors to stderr (at v=0, errors only) so
520
+ // a failed launch carries a real reason. dumpio stays false, so
521
+ // none of this reaches the user's terminal on success.
522
+ "--enable-logging=stderr",
523
+ "--v=0",
524
+ // Two independent DevTools transports, both requested explicitly
525
+ // (puppeteer only adds one itself, and only when args carries
526
+ // neither): the pipe is what this process's own puppeteer.launch
527
+ // connects over, unaffected by anything below. The port, bound to
528
+ // loopback on a free port Chrome picks, exists purely so a later,
529
+ // separate process can attach to this same browser instead of
530
+ // launching its own; nothing here reads or writes it before then.
531
+ "--remote-debugging-pipe",
532
+ "--remote-debugging-port=0",
533
+ ],
534
+ dumpio: false,
535
+ // Talk to Chrome over stdio rather than a DevTools websocket for
536
+ // *this* process's own connection. A websocket is a TCP handle
537
+ // that holds the event loop and cannot be unref'd through
538
+ // puppeteer's public surface, which is what kept a finished
539
+ // script running until the idle close fired. Pipes can be. The
540
+ // --remote-debugging-port above still gives a second, later
541
+ // process a socket-based endpoint to reconnect over; that
542
+ // process pays this same cost, but only while it is actually
543
+ // using the browser, not this one, which never opens the port
544
+ // itself.
545
+ pipe: true,
546
+ });
547
+ const browserPid = browser.process()?.pid;
548
+ // Discover and publish the reconnect endpoint. Best-effort and never
549
+ // awaited-into-failure: any problem here leaves browserWSEndpoint
550
+ // unset, which only means a later process falls back to launching
551
+ // its own Chrome rather than reusing this one.
552
+ let wsEndpoint;
553
+ try {
554
+ const port = await readDevToolsPort(profileDir);
555
+ if (port !== undefined)
556
+ wsEndpoint = await readBrowserWSEndpoint(port);
557
+ }
558
+ catch {
559
+ // Same as above: reconnection is an optional extra.
560
+ }
561
+ // Record ownership so a later run can tell our live Chrome from an
562
+ // orphan and know exactly which pid to reap.
563
+ writeOwnerRecord(profileDir, browserPid, wsEndpoint);
564
+ releaseEventLoop(browser.process());
565
+ return browser;
566
+ }
567
+ /**
568
+ * Attach to a browser a different, still-live process already launched,
569
+ * instead of spawning one of our own. For a stateless-per-invocation
570
+ * caller (a CLI, not a long-lived extension host that keeps its own
571
+ * processGlobal state) that wants to reuse whatever browser is already
572
+ * warm rather than paying a fresh launch every call.
573
+ *
574
+ * Scans every profile under PROFILE_ROOT for a live owner that published
575
+ * a reconnectable endpoint, and attaches to the first one that answers.
576
+ * Returns undefined when none is found or reachable, so the caller can
577
+ * fall back to getBrowser().
578
+ *
579
+ * The caller does not own what this returns: closing it must be
580
+ * `browser.disconnect()`, never `browser.close()`, which would tear down
581
+ * the browser out from under the process that actually launched it.
582
+ */
583
+ export async function connectShared() {
584
+ let entries;
585
+ try {
586
+ entries = fs.readdirSync(PROFILE_ROOT);
587
+ }
588
+ catch {
589
+ return undefined;
590
+ }
591
+ for (const entry of entries) {
592
+ const dir = path.join(PROFILE_ROOT, entry);
593
+ const owner = readOwnerRecord(dir);
594
+ if (!owner?.browserWSEndpoint || !isPidAlive(owner.ownerPid))
595
+ continue;
596
+ try {
597
+ return await puppeteer.connect({
598
+ browserWSEndpoint: owner.browserWSEndpoint,
599
+ });
600
+ }
601
+ catch {
602
+ // Stale endpoint (closed since the record was written) or an
603
+ // unreachable one; try the next candidate rather than failing.
604
+ }
605
+ }
606
+ return undefined;
607
+ }
608
+ /**
609
+ * Stop the warm browser from being the only reason this process
610
+ * stays alive.
611
+ *
612
+ * The browser is kept between sessions so the next call does not
613
+ * pay a second and a half to launch Chrome again. But its child
614
+ * process, its stdio pipes and its DevTools socket all hold the
615
+ * event loop, so a script that opened a session, did its work
616
+ * and closed it sat there until the five-minute idle close fired
617
+ * and only then exited. Measured: two and a half seconds of
618
+ * work, three hundred and one seconds of wall clock, three and a
619
+ * half seconds of CPU. Anything wiring this into CI would have
620
+ * read that as a hang.
621
+ *
622
+ * unref does not close anything. The browser stays usable and
623
+ * the idle close still runs; it just stops counting as a reason
624
+ * to keep running. A session has its own handles and is
625
+ * unaffected, and a script exits when its own work is done.
626
+ */
627
+ export function releaseEventLoop(child) {
628
+ if (!child)
629
+ return;
630
+ child.unref();
631
+ for (const pipe of child.stdio)
632
+ nudge(pipe, "unref");
633
+ }
634
+ /** Ask a stdio entry to ref or unref itself, if it can. */
635
+ function nudge(pipe, how) {
636
+ if (typeof pipe !== "object" || pipe === null)
637
+ return;
638
+ const method = pipe[how];
639
+ if (typeof method === "function")
640
+ method.call(pipe);
641
+ }
642
+ /**
643
+ * Keep the process alive for as long as a teardown needs.
644
+ *
645
+ * The inverse of releaseEventLoop. Closing a browser is several
646
+ * round trips, and once nothing is ref'd Node is free to exit
647
+ * in the middle of them, which leaves the caller's promise
648
+ * hanging and Chrome to be reaped as an orphan next run.
649
+ */
650
+ export function holdEventLoop(child) {
651
+ if (!child)
652
+ return;
653
+ child.ref();
654
+ for (const pipe of child.stdio)
655
+ nudge(pipe, "ref");
656
+ }
657
+ /**
658
+ * Launch Chrome with a bounded retry. A Chrome self-update on macOS
659
+ * makes the first spawn exit before its DevTools endpoint appears;
660
+ * the window is brief, so a short backoff usually rides it out. A
661
+ * failed puppeteer.launch group-kills its own child, and each
662
+ * attempt resets the profile, so retries never stack orphans.
663
+ */
664
+ async function launchBrowser() {
665
+ installLifecycleHandlers();
666
+ reapOrphanProfiles();
667
+ // Resolve the binary once, before the loop. A missing Chrome is a
668
+ // settled misconfig, not a transient, so it throws its own clear
669
+ // error immediately instead of being retried or sniffed for by
670
+ // message text.
671
+ const executablePath = resolveChromePath(process.env.CHROME_PATH);
672
+ let lastError;
673
+ for (let attempt = 1; attempt <= LAUNCH_ATTEMPTS; attempt++) {
674
+ try {
675
+ return await launchOnce(executablePath);
676
+ }
677
+ catch (err) {
678
+ lastError = err;
679
+ const backoff = LAUNCH_BACKOFF_MS[attempt - 1];
680
+ if (backoff !== undefined)
681
+ await sleep(backoff);
682
+ }
683
+ }
684
+ throw new BrowserLaunchFailed(lastError, LAUNCH_ATTEMPTS);
685
+ }
686
+ /**
687
+ * Get the shared headless Chrome instance, launching it if
688
+ * needed. Concurrent callers share one in-flight launch, so two
689
+ * extensions reaching for the browser in the same tick do not
690
+ * race two Chrome processes onto the same profile.
691
+ */
692
+ export async function getBrowser() {
693
+ const state = sharedState();
694
+ // Wait out an in-flight teardown so we never hand back a browser that
695
+ // is closing, nor race a relaunch against its profile removal.
696
+ if (state.closing)
697
+ await state.closing;
698
+ if (state.browser?.connected)
699
+ return state.browser;
700
+ // A browser that exists but has disconnected is stale: retire it (and
701
+ // its still-running process) before launching a replacement.
702
+ if (state.browser)
703
+ await closeBrowser();
704
+ if (state.launching)
705
+ return state.launching;
706
+ state.launching = launchBrowser();
707
+ try {
708
+ state.browser = await state.launching;
709
+ idleCloser().touch();
710
+ return state.browser;
711
+ }
712
+ finally {
713
+ state.launching = undefined;
714
+ }
715
+ }
716
+ /**
717
+ * The idle-close countdown, created once per process. When it
718
+ * fires it shuts the shared browser down; a later getBrowser
719
+ * relaunches, which also picks up a Chrome that updated in the
720
+ * meantime rather than reusing a version pinned hours ago.
721
+ */
722
+ function idleCloser() {
723
+ const state = sharedState();
724
+ if (!state.idle) {
725
+ state.idle = createIdleCloser({
726
+ idleMs: IDLE_TIMEOUT_MS,
727
+ close: () => {
728
+ void closeIfUnused();
729
+ },
730
+ });
731
+ }
732
+ return state.idle;
733
+ }
734
+ /**
735
+ * The idle timer fired. Close only if no consumer page is open;
736
+ * otherwise a session or in-flight read is still using the browser,
737
+ * so rearm the countdown instead of closing under it.
738
+ */
739
+ async function closeIfUnused() {
740
+ const state = sharedState();
741
+ const b = state.browser;
742
+ if (b?.connected) {
743
+ try {
744
+ const pages = await b.pages();
745
+ if (!shouldCloseWhenIdle(pages.length)) {
746
+ idleCloser().touch();
747
+ return;
748
+ }
749
+ }
750
+ catch {
751
+ // Could not read pages; fall through to the pending check.
752
+ }
753
+ }
754
+ // A page acquisition may have started during the async pages read.
755
+ // This check and closeBrowser's synchronous prologue (which sets
756
+ // state.closing) run with no await between them, so a newPage that
757
+ // reserved a lease either is seen here or waits on state.closing.
758
+ if ((state.pending ?? 0) > 0) {
759
+ idleCloser().touch();
760
+ return;
761
+ }
762
+ await closeBrowser();
763
+ }
764
+ /** The user agent every tab we open presents. */
765
+ const USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) " +
766
+ "AppleWebKit/537.36 (KHTML, like Gecko) " +
767
+ "Chrome/131.0.0.0 Safari/537.36";
768
+ /** Open a new browser tab with a standard user agent string. */
769
+ export async function newPage() {
770
+ return withLease(async (b) => {
771
+ const page = await b.newPage();
772
+ return dressPage(page);
773
+ });
774
+ }
775
+ /**
776
+ * Open a tab in a browser context of its own: separate
777
+ * cookies, storage and cache from every other context in the
778
+ * shared Chrome. Two sessions opened this way are two
779
+ * genuinely independent users. Closing the context closes the
780
+ * tabs inside it and leaves its siblings alone.
781
+ */
782
+ export async function newContextPage() {
783
+ return withLease(async (b) => {
784
+ const context = await b.createBrowserContext();
785
+ try {
786
+ const page = await dressPage(await context.newPage());
787
+ return { page, context };
788
+ }
789
+ catch (err) {
790
+ // Do not leave an empty context behind on a failed open.
791
+ await context.close().catch(() => { });
792
+ throw err;
793
+ }
794
+ });
795
+ }
796
+ /** Give a fresh tab the user agent we present everywhere. */
797
+ async function dressPage(page) {
798
+ try {
799
+ await page.setUserAgent(USER_AGENT);
800
+ }
801
+ catch (err) {
802
+ await page.close();
803
+ throw err;
804
+ }
805
+ return page;
806
+ }
807
+ /**
808
+ * Run an acquisition against the shared browser while holding
809
+ * a lease, so an idle close firing concurrently sees the
810
+ * in-flight work and defers instead of pulling Chrome out from
811
+ * under it.
812
+ */
813
+ async function withLease(acquire) {
814
+ const state = sharedState();
815
+ // Reserve the lease synchronously, before any await.
816
+ state.pending = (state.pending ?? 0) + 1;
817
+ try {
818
+ const b = await getBrowser();
819
+ idleCloser().touch();
820
+ return await acquire(b);
821
+ }
822
+ finally {
823
+ state.pending = (state.pending ?? 1) - 1;
824
+ }
825
+ }
826
+ /** Shut down the shared Chrome instance if it's running. */
827
+ export async function closeBrowser() {
828
+ const state = sharedState();
829
+ // One teardown at a time: a second caller (say the idle timer and an
830
+ // explicit close) awaits the same operation rather than racing it.
831
+ if (state.closing)
832
+ return state.closing;
833
+ state.closing = runClose(state);
834
+ try {
835
+ await state.closing;
836
+ }
837
+ finally {
838
+ state.closing = undefined;
839
+ }
840
+ }
841
+ async function runClose(state) {
842
+ // Wait out an in-flight launch so a browser that resolves after
843
+ // close is not orphaned past the intended shutdown.
844
+ if (state.launching) {
845
+ try {
846
+ await state.launching;
847
+ }
848
+ catch {
849
+ // A failed launch leaves nothing to close.
850
+ }
851
+ }
852
+ const b = state.browser;
853
+ if (!b)
854
+ return;
855
+ state.idle?.cancel();
856
+ const proc = b.process();
857
+ // Take the handles back before tearing down. They are unref'd
858
+ // while the browser sits warm, so that a finished script is not
859
+ // held open by a browser nobody is using; but a close in
860
+ // progress is work worth staying alive for, and without this
861
+ // Node exited mid-teardown and the caller's await never
862
+ // settled. Symmetry with releaseEventLoop at launch.
863
+ holdEventLoop(proc);
864
+ const pid = proc?.pid;
865
+ const dir = ownProfileDir();
866
+ let closedGracefully = false;
867
+ try {
868
+ if (b.connected) {
869
+ await b.close();
870
+ closedGracefully = true;
871
+ }
872
+ }
873
+ catch {
874
+ // Graceful close failed; the force-kill below handles it.
875
+ }
876
+ finally {
877
+ // Force-kill only when we did not cleanly close (a disconnected or
878
+ // close-failed browser), and only while the pid still verifies as
879
+ // our Chrome. After a clean close the pid is gone and could be
880
+ // reused, so signalling its group would be unsafe.
881
+ if (shouldForceKill(closedGracefully, pid ? verifyBrowser(pid, dir) : false)) {
882
+ killTree(proc);
883
+ }
884
+ state.browser = undefined;
885
+ // Reclaim the profile only once the process is gone: a clean close,
886
+ // or a post-teardown check that no longer finds it. Otherwise keep
887
+ // the dir so the next run's reaper still has a handle to a survivor.
888
+ const gone = closedGracefully || !pid || !verifyBrowser(pid, dir);
889
+ if (gone) {
890
+ try {
891
+ fs.rmSync(dir, { recursive: true, force: true });
892
+ }
893
+ catch {
894
+ // Best-effort cleanup; the next launch sweeps leftovers.
895
+ }
896
+ }
897
+ }
898
+ }
899
+ /**
900
+ * Force-kill the Chrome process synchronously. Called from
901
+ * `process.on('exit')` where async work isn't possible.
902
+ */
903
+ export function killBrowserSync() {
904
+ const state = sharedState();
905
+ state.idle?.cancel();
906
+ const b = state.browser;
907
+ if (!b)
908
+ return;
909
+ // Group-kill so the helper tree dies with the leader instead of
910
+ // reparenting to launchd, but only for a process we can still confirm
911
+ // is ours by its exact profile, so neither a stale CDP connection nor
912
+ // a crashed-and-reused pid is ever signalled. Reclaim the dir only
913
+ // when it was ours to kill; otherwise leave it for the next reaper.
914
+ const proc = b.process();
915
+ const pid = proc?.pid;
916
+ const dir = ownProfileDir();
917
+ if (pid && verifyBrowser(pid, dir)) {
918
+ killTree(proc);
919
+ try {
920
+ fs.rmSync(dir, { recursive: true, force: true });
921
+ }
922
+ catch {
923
+ // Best-effort; a later run's reaper removes whatever remains.
924
+ }
925
+ }
926
+ state.browser = undefined;
927
+ }