@doxbrix/doxloop 0.1.4 → 0.2.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 (357) hide show
  1. package/CHANGELOG.md +1153 -0
  2. package/README.md +422 -226
  3. package/assets/doxbrix-preview.css +77 -15
  4. package/contracts/agent-events-v1.schema.json +1 -0
  5. package/contracts/coverage-v1.schema.json +59 -0
  6. package/contracts/drift-v1.schema.json +1 -0
  7. package/contracts/evaluation-v1.schema.json +62 -0
  8. package/contracts/quality-codes-v1.json +1 -0
  9. package/contracts/quality-report-v1.schema.json +1 -0
  10. package/contracts/validation-v1.schema.json +1 -0
  11. package/dist/agent-failure.d.ts +36 -0
  12. package/dist/agent-failure.js +98 -0
  13. package/dist/agent-isolation.d.ts +17 -0
  14. package/dist/agent-isolation.js +94 -0
  15. package/dist/agent-log.d.ts +197 -0
  16. package/dist/agent-log.js +1094 -0
  17. package/dist/agent-process.d.ts +63 -0
  18. package/dist/agent-process.js +128 -0
  19. package/dist/agent-reply.d.ts +47 -0
  20. package/dist/agent-reply.js +315 -0
  21. package/dist/agents.d.ts +40 -4
  22. package/dist/agents.js +115 -11
  23. package/dist/api-coverage.d.ts +11 -0
  24. package/dist/api-coverage.js +72 -0
  25. package/dist/application-probe.d.ts +28 -0
  26. package/dist/application-probe.js +93 -0
  27. package/dist/application-url.d.ts +14 -0
  28. package/dist/application-url.js +26 -0
  29. package/dist/args.js +15 -0
  30. package/dist/artifact-deploy.d.ts +9 -0
  31. package/dist/artifact-deploy.js +28 -8
  32. package/dist/assets.d.ts +72 -0
  33. package/dist/assets.js +382 -0
  34. package/dist/auth.d.ts +10 -0
  35. package/dist/auth.js +38 -9
  36. package/dist/author.d.ts +206 -4
  37. package/dist/author.js +1650 -52
  38. package/dist/authoring-batches.d.ts +190 -0
  39. package/dist/authoring-batches.js +489 -0
  40. package/dist/authoring-postpass.d.ts +79 -0
  41. package/dist/authoring-postpass.js +1289 -0
  42. package/dist/authoring-progress.d.ts +95 -0
  43. package/dist/authoring-progress.js +269 -0
  44. package/dist/autosync.d.ts +56 -0
  45. package/dist/autosync.js +442 -0
  46. package/dist/batch-artifacts.d.ts +81 -0
  47. package/dist/batch-artifacts.js +412 -0
  48. package/dist/batch-limits.d.ts +37 -0
  49. package/dist/batch-limits.js +80 -0
  50. package/dist/branding.d.ts +41 -0
  51. package/dist/branding.js +229 -0
  52. package/dist/bundle-upload.d.ts +26 -0
  53. package/dist/bundle-upload.js +99 -0
  54. package/dist/capture-auth.d.ts +95 -0
  55. package/dist/capture-auth.js +204 -0
  56. package/dist/capture.d.ts +48 -0
  57. package/dist/capture.js +20 -1
  58. package/dist/cli.js +839 -32
  59. package/dist/content-links.d.ts +10 -0
  60. package/dist/content-links.js +49 -0
  61. package/dist/contract-validation.d.ts +4 -0
  62. package/dist/contract-validation.js +25 -0
  63. package/dist/coverage-actions.d.ts +8 -0
  64. package/dist/coverage-actions.js +71 -0
  65. package/dist/coverage-resolutions.d.ts +16 -0
  66. package/dist/coverage-resolutions.js +58 -0
  67. package/dist/db.d.ts +37 -0
  68. package/dist/db.js +288 -0
  69. package/dist/demo.d.ts +12 -0
  70. package/dist/demo.js +122 -0
  71. package/dist/deploy-credentials.d.ts +7 -0
  72. package/dist/deploy-credentials.js +76 -0
  73. package/dist/deploy-targets/github-pages.d.ts +3 -0
  74. package/dist/deploy-targets/github-pages.js +100 -0
  75. package/dist/deploy-targets/index.d.ts +8 -0
  76. package/dist/deploy-targets/index.js +78 -0
  77. package/dist/deploy-targets/netlify.d.ts +3 -0
  78. package/dist/deploy-targets/netlify.js +49 -0
  79. package/dist/deploy-targets/types.d.ts +32 -0
  80. package/dist/deploy-targets/types.js +2 -0
  81. package/dist/deploy-targets/vercel.d.ts +3 -0
  82. package/dist/deploy-targets/vercel.js +95 -0
  83. package/dist/deploy.d.ts +9 -0
  84. package/dist/deploy.js +87 -13
  85. package/dist/deterministic-capture.d.ts +90 -0
  86. package/dist/deterministic-capture.js +435 -0
  87. package/dist/direct-edit.d.ts +40 -0
  88. package/dist/direct-edit.js +159 -0
  89. package/dist/docs-crawl.d.ts +86 -0
  90. package/dist/docs-crawl.js +536 -0
  91. package/dist/docs-site.d.ts +49 -0
  92. package/dist/docs-site.js +233 -0
  93. package/dist/doctor.js +8 -0
  94. package/dist/documentation-collections.d.ts +23 -0
  95. package/dist/documentation-collections.js +191 -0
  96. package/dist/documentation-plan.d.ts +253 -0
  97. package/dist/documentation-plan.js +2563 -0
  98. package/dist/doxbrix-build.d.ts +19 -0
  99. package/dist/doxbrix-build.js +167 -0
  100. package/dist/doxbrix-markdown.d.ts +9 -0
  101. package/dist/doxbrix-markdown.js +115 -14
  102. package/dist/drift.d.ts +10 -0
  103. package/dist/drift.js +164 -0
  104. package/dist/evaluation.d.ts +46 -0
  105. package/dist/evaluation.js +113 -0
  106. package/dist/evidence-pack.d.ts +47 -0
  107. package/dist/evidence-pack.js +358 -0
  108. package/dist/evidence.d.ts +25 -0
  109. package/dist/evidence.js +175 -0
  110. package/dist/fs.d.ts +8 -2
  111. package/dist/fs.js +41 -11
  112. package/dist/generator-api.d.ts +89 -0
  113. package/dist/generator-preflight.d.ts +27 -0
  114. package/dist/generator-preflight.js +105 -0
  115. package/dist/generator-runtime.d.ts +7 -0
  116. package/dist/generator-runtime.js +17 -1
  117. package/dist/generators.d.ts +24 -2
  118. package/dist/generators.js +54 -1
  119. package/dist/git-delivery.d.ts +17 -0
  120. package/dist/git-delivery.js +123 -0
  121. package/dist/globs.d.ts +16 -0
  122. package/dist/globs.js +65 -0
  123. package/dist/glossary.d.ts +26 -0
  124. package/dist/glossary.js +179 -0
  125. package/dist/history.d.ts +106 -0
  126. package/dist/history.js +600 -0
  127. package/dist/html-markdown.d.ts +46 -0
  128. package/dist/html-markdown.js +423 -0
  129. package/dist/interactive.js +16 -15
  130. package/dist/job-events.d.ts +74 -0
  131. package/dist/job-events.js +377 -0
  132. package/dist/keep-awake.d.ts +50 -0
  133. package/dist/keep-awake.js +123 -0
  134. package/dist/local-source-snapshot.d.ts +20 -0
  135. package/dist/local-source-snapshot.js +61 -0
  136. package/dist/mintlify-detect.d.ts +3 -0
  137. package/dist/mintlify-detect.js +18 -0
  138. package/dist/mintlify-import.d.ts +75 -0
  139. package/dist/mintlify-import.js +190 -0
  140. package/dist/navigation.d.ts +98 -0
  141. package/dist/navigation.js +310 -0
  142. package/dist/openapi.d.ts +60 -0
  143. package/dist/openapi.js +439 -0
  144. package/dist/page-editor-bridge.d.ts +3 -0
  145. package/dist/page-editor-bridge.js +109 -0
  146. package/dist/page-editor-preview.d.ts +10 -0
  147. package/dist/page-editor-preview.js +55 -0
  148. package/dist/page-extension.d.ts +9 -0
  149. package/dist/page-extension.js +15 -0
  150. package/dist/page-metadata.d.ts +28 -0
  151. package/dist/page-metadata.js +166 -0
  152. package/dist/page-operations.d.ts +34 -0
  153. package/dist/page-operations.js +215 -0
  154. package/dist/page-routes.d.ts +4 -0
  155. package/dist/page-routes.js +61 -0
  156. package/dist/pages.d.ts +20 -0
  157. package/dist/pages.js +184 -0
  158. package/dist/plan-generator.d.ts +3 -0
  159. package/dist/plan-generator.js +21 -0
  160. package/dist/plan-navigation.d.ts +11 -0
  161. package/dist/plan-navigation.js +30 -0
  162. package/dist/planning-captures.d.ts +20 -0
  163. package/dist/planning-captures.js +143 -0
  164. package/dist/planning-research.d.ts +135 -0
  165. package/dist/planning-research.js +472 -0
  166. package/dist/planning-triage.d.ts +23 -0
  167. package/dist/planning-triage.js +131 -0
  168. package/dist/preview.d.ts +24 -0
  169. package/dist/preview.js +280 -29
  170. package/dist/project-detect.d.ts +36 -0
  171. package/dist/project-detect.js +251 -0
  172. package/dist/project-import.d.ts +54 -0
  173. package/dist/project-import.js +157 -0
  174. package/dist/project-lock.d.ts +6 -0
  175. package/dist/project-lock.js +96 -0
  176. package/dist/project-registry.d.ts +25 -0
  177. package/dist/project-registry.js +79 -0
  178. package/dist/project.d.ts +35 -3
  179. package/dist/project.js +388 -38
  180. package/dist/prompts.d.ts +9 -0
  181. package/dist/prompts.js +33 -4
  182. package/dist/proposal-replay.d.ts +32 -0
  183. package/dist/proposal-replay.js +99 -0
  184. package/dist/quality-claims.d.ts +8 -0
  185. package/dist/quality-claims.js +168 -0
  186. package/dist/quality-config.d.ts +5 -0
  187. package/dist/quality-config.js +84 -0
  188. package/dist/quality-contract.d.ts +37 -0
  189. package/dist/quality-contract.js +46 -0
  190. package/dist/quality-examples.d.ts +4 -0
  191. package/dist/quality-examples.js +233 -0
  192. package/dist/quality-gates.d.ts +16 -0
  193. package/dist/quality-gates.js +192 -0
  194. package/dist/quality-links.d.ts +7 -0
  195. package/dist/quality-links.js +149 -0
  196. package/dist/quality-lint.d.ts +6 -0
  197. package/dist/quality-lint.js +124 -0
  198. package/dist/quality-rendered.d.ts +11 -0
  199. package/dist/quality-rendered.js +222 -0
  200. package/dist/quality-schema.d.ts +3 -0
  201. package/dist/quality-schema.js +71 -0
  202. package/dist/release-notes.d.ts +44 -0
  203. package/dist/release-notes.js +183 -0
  204. package/dist/remote-monitor.d.ts +16 -0
  205. package/dist/remote-monitor.js +74 -0
  206. package/dist/remote-source.d.ts +34 -0
  207. package/dist/remote-source.js +426 -0
  208. package/dist/review-diff.d.ts +82 -0
  209. package/dist/review-diff.js +400 -0
  210. package/dist/review-learning.d.ts +11 -0
  211. package/dist/review-learning.js +60 -0
  212. package/dist/review-render.d.ts +38 -0
  213. package/dist/review-render.js +224 -0
  214. package/dist/review-report.d.ts +9 -0
  215. package/dist/review-report.js +89 -0
  216. package/dist/review-ui.d.ts +14 -0
  217. package/dist/review-ui.js +1248 -0
  218. package/dist/schedule.d.ts +78 -0
  219. package/dist/schedule.js +480 -0
  220. package/dist/screen-capture-provider.d.ts +52 -0
  221. package/dist/screen-capture-provider.js +218 -0
  222. package/dist/screenshot-workflow.d.ts +167 -0
  223. package/dist/screenshot-workflow.js +1237 -0
  224. package/dist/settings.d.ts +1 -1
  225. package/dist/settings.js +95 -7
  226. package/dist/site-export.d.ts +18 -0
  227. package/dist/site-export.js +87 -0
  228. package/dist/source-connectors.d.ts +33 -0
  229. package/dist/source-connectors.js +268 -0
  230. package/dist/source-discovery.d.ts +132 -0
  231. package/dist/source-discovery.js +823 -0
  232. package/dist/source-intelligence.d.ts +9 -0
  233. package/dist/source-intelligence.js +306 -0
  234. package/dist/sync-review.d.ts +28 -0
  235. package/dist/sync-review.js +264 -0
  236. package/dist/sync-runs.d.ts +192 -0
  237. package/dist/sync-runs.js +2244 -0
  238. package/dist/sync.d.ts +35 -0
  239. package/dist/sync.js +298 -32
  240. package/dist/text-diff.d.ts +9 -0
  241. package/dist/text-diff.js +59 -0
  242. package/dist/types.d.ts +946 -1
  243. package/dist/ui/assets/doxloop-logo-light-De7Nx7j7.png +0 -0
  244. package/dist/ui/assets/index-BHBYU2aG.css +1 -0
  245. package/dist/ui/assets/index-Cq3RPQiC.js +33 -0
  246. package/dist/ui/index.html +18 -0
  247. package/dist/ui-server.d.ts +83 -0
  248. package/dist/ui-server.js +3532 -0
  249. package/dist/usage-budget.d.ts +28 -0
  250. package/dist/usage-budget.js +90 -0
  251. package/dist/validation.d.ts +25 -1
  252. package/dist/validation.js +312 -26
  253. package/dist/workspace-tools.d.ts +54 -0
  254. package/dist/workspace-tools.js +123 -0
  255. package/docs/agent-compatibility.md +50 -28
  256. package/docs/ci-and-automation.md +105 -66
  257. package/docs/doxbrix-http-api.md +8 -1
  258. package/docs/existing-documentation.md +80 -0
  259. package/docs/generation-performance.md +108 -0
  260. package/docs/generator-authoring.md +68 -5
  261. package/docs/generator-selection.md +50 -13
  262. package/docs/mintlify-import.md +71 -0
  263. package/docs/openapi-security.md +25 -0
  264. package/docs/project-format.md +331 -36
  265. package/docs/release-quality.md +158 -0
  266. package/docs/releasing.md +72 -0
  267. package/docs/review-workflows.md +51 -0
  268. package/docs/security-model.md +102 -39
  269. package/docs/troubleshooting.md +226 -93
  270. package/package.json +46 -15
  271. package/scripts/test-auto-screenshot.mjs +172 -0
  272. package/skills/doxloop-authoring/SKILL.md +242 -361
  273. package/skills/doxloop-authoring/references/existing-documentation.md +94 -0
  274. package/skills/doxloop-authoring/references/navigation-architecture.md +18 -7
  275. package/skills/doxloop-authoring/references/page-depth.md +169 -0
  276. package/skills/doxloop-authoring/references/project-format.md +106 -7
  277. package/skills/doxloop-authoring/references/quality.md +10 -0
  278. package/skills/doxloop-authoring/references/screenshot-manifest.md +113 -0
  279. package/skills/doxloop-authoring/references/screenshots.md +149 -235
  280. package/skills/doxloop-authoring/references/workflows.md +76 -0
  281. package/skills/doxloop-doxbrix/SKILL.md +38 -22
  282. package/skills/doxloop-doxbrix/references/api-endpoints.md +15 -14
  283. package/skills/doxloop-doxbrix/references/components.md +30 -3
  284. package/skills/doxloop-doxbrix/references/manifest.md +3 -2
  285. package/vendor/doxbrix-import/LICENSE +202 -0
  286. package/vendor/doxbrix-import/README.md +17 -0
  287. package/vendor/doxbrix-import/UPSTREAM.json +47 -0
  288. package/vendor/doxbrix-import/dist/docs/frontmatter.d.ts +13 -0
  289. package/vendor/doxbrix-import/dist/docs/frontmatter.js +83 -0
  290. package/vendor/doxbrix-import/dist/docs/import.d.ts +21 -0
  291. package/vendor/doxbrix-import/dist/docs/import.js +147 -0
  292. package/vendor/doxbrix-import/dist/docs/manifest.d.ts +163 -0
  293. package/vendor/doxbrix-import/dist/docs/manifest.js +64 -0
  294. package/vendor/doxbrix-import/dist/docs/project.d.ts +25 -0
  295. package/vendor/doxbrix-import/dist/docs/project.js +77 -0
  296. package/vendor/doxbrix-import/dist/docs/starter.d.ts +4 -0
  297. package/vendor/doxbrix-import/dist/docs/starter.js +11 -0
  298. package/vendor/doxbrix-import/dist/importer.d.ts +227 -0
  299. package/vendor/doxbrix-import/dist/importer.js +1567 -0
  300. package/vendor/doxbrix-import/dist/mintlify-openapi.d.ts +37 -0
  301. package/vendor/doxbrix-import/dist/mintlify-openapi.js +305 -0
  302. package/vendor/doxbrix-import/dist/safe-path.d.ts +9 -0
  303. package/vendor/doxbrix-import/dist/safe-path.js +47 -0
  304. package/dist/agents.d.ts.map +0 -1
  305. package/dist/agents.js.map +0 -1
  306. package/dist/args.d.ts.map +0 -1
  307. package/dist/args.js.map +0 -1
  308. package/dist/artifact-deploy.d.ts.map +0 -1
  309. package/dist/artifact-deploy.js.map +0 -1
  310. package/dist/auth.d.ts.map +0 -1
  311. package/dist/auth.js.map +0 -1
  312. package/dist/author.d.ts.map +0 -1
  313. package/dist/author.js.map +0 -1
  314. package/dist/capture.d.ts.map +0 -1
  315. package/dist/capture.js.map +0 -1
  316. package/dist/cli.d.ts.map +0 -1
  317. package/dist/cli.js.map +0 -1
  318. package/dist/deploy.d.ts.map +0 -1
  319. package/dist/deploy.js.map +0 -1
  320. package/dist/deployment-visibility.d.ts.map +0 -1
  321. package/dist/deployment-visibility.js.map +0 -1
  322. package/dist/doctor.d.ts.map +0 -1
  323. package/dist/doctor.js.map +0 -1
  324. package/dist/doxbrix-markdown.d.ts.map +0 -1
  325. package/dist/doxbrix-markdown.js.map +0 -1
  326. package/dist/errors.d.ts.map +0 -1
  327. package/dist/errors.js.map +0 -1
  328. package/dist/fs.d.ts.map +0 -1
  329. package/dist/fs.js.map +0 -1
  330. package/dist/generator-api.d.ts.map +0 -1
  331. package/dist/generator-api.js.map +0 -1
  332. package/dist/generator-manager.d.ts.map +0 -1
  333. package/dist/generator-manager.js.map +0 -1
  334. package/dist/generator-runtime.d.ts.map +0 -1
  335. package/dist/generator-runtime.js.map +0 -1
  336. package/dist/generators.d.ts.map +0 -1
  337. package/dist/generators.js.map +0 -1
  338. package/dist/interactive.d.ts.map +0 -1
  339. package/dist/interactive.js.map +0 -1
  340. package/dist/preview.d.ts.map +0 -1
  341. package/dist/preview.js.map +0 -1
  342. package/dist/progress.d.ts.map +0 -1
  343. package/dist/progress.js.map +0 -1
  344. package/dist/project.d.ts.map +0 -1
  345. package/dist/project.js.map +0 -1
  346. package/dist/prompts.d.ts.map +0 -1
  347. package/dist/prompts.js.map +0 -1
  348. package/dist/settings.d.ts.map +0 -1
  349. package/dist/settings.js.map +0 -1
  350. package/dist/sync.d.ts.map +0 -1
  351. package/dist/sync.js.map +0 -1
  352. package/dist/types.d.ts.map +0 -1
  353. package/dist/types.js.map +0 -1
  354. package/dist/validation.d.ts.map +0 -1
  355. package/dist/validation.js.map +0 -1
  356. package/dist/version.d.ts.map +0 -1
  357. package/dist/version.js.map +0 -1
@@ -0,0 +1,218 @@
1
+ import { mkdir, readFile, writeFile } from 'node:fs/promises';
2
+ import { createRequire } from 'node:module';
3
+ import { dirname, join, resolve } from 'node:path';
4
+ import { pathToFileURL } from 'node:url';
5
+ import { applicationUrl } from './application-url.js';
6
+ import { DoxloopError } from './errors.js';
7
+ export const SCREEN_CAPTURE_SERVER = 'doxloop_capture';
8
+ /** Launch the same Chrome channel used by the MCP server, then close it. */
9
+ export async function checkScreenCaptureBrowser() {
10
+ try {
11
+ const chromium = await loadChromium();
12
+ const browser = await chromium.launch({ channel: 'chrome', headless: true, timeout: 15_000 });
13
+ await browser.close();
14
+ return { available: true, message: 'The Doxloop capture browser started successfully.' };
15
+ }
16
+ catch (cause) {
17
+ return {
18
+ available: false,
19
+ message: `The Doxloop capture browser could not start. Install Google Chrome and retry. ${cause instanceof Error ? cause.message.split('\n')[0] : String(cause)}`,
20
+ };
21
+ }
22
+ }
23
+ /** The Playwright bundled with the MCP server, so the sign-in window matches the capture browser. */
24
+ async function loadChromium() {
25
+ const require = createRequire(import.meta.url);
26
+ const packageJson = require.resolve('@playwright/mcp/package.json');
27
+ const playwrightPath = createRequire(packageJson).resolve('playwright');
28
+ const imported = await import(pathToFileURL(playwrightPath).href);
29
+ const chromium = imported.chromium ?? imported.default?.chromium;
30
+ if (!chromium)
31
+ throw new Error('Playwright did not expose Chromium.');
32
+ return chromium;
33
+ }
34
+ /**
35
+ * Open a visible Chrome window on the application's sign-in page so the user
36
+ * can authenticate by hand, including MFA, SSO, and passkeys. The session is
37
+ * snapshotted every couple of seconds while the window is open, so closing
38
+ * the window early still leaves the last signed-in state to save.
39
+ */
40
+ export async function startCaptureSignIn(application) {
41
+ const viewport = application.screenshots?.viewport ?? { width: 1440, height: 900 };
42
+ const path = application.authentication?.loginPath ?? application.screenshots?.startPath ?? application.readyPath ?? '/';
43
+ const url = applicationUrl(application.baseUrl, path).toString();
44
+ let chromium;
45
+ try {
46
+ chromium = await loadChromium();
47
+ }
48
+ catch (cause) {
49
+ throw new DoxloopError(`The sign-in browser could not load: ${cause instanceof Error ? cause.message.split('\n')[0] : String(cause)}`);
50
+ }
51
+ let browser;
52
+ try {
53
+ browser = await chromium.launch({ channel: 'chrome', headless: false, timeout: 20_000 });
54
+ }
55
+ catch (cause) {
56
+ throw new DoxloopError(`The sign-in browser could not start. Install Google Chrome and retry. ${cause instanceof Error ? cause.message.split('\n')[0] : String(cause)}`);
57
+ }
58
+ const context = await browser.newContext({ viewport });
59
+ const page = await context.newPage();
60
+ let latest;
61
+ let lastUrl = url;
62
+ let connected = true;
63
+ const snapshot = async () => {
64
+ if (!connected)
65
+ return latest;
66
+ try {
67
+ const pages = context.pages();
68
+ const active = pages[pages.length - 1];
69
+ if (active)
70
+ lastUrl = active.url();
71
+ latest = await context.storageState();
72
+ }
73
+ catch {
74
+ // The window is closing; keep the previous snapshot.
75
+ }
76
+ return latest;
77
+ };
78
+ const timer = setInterval(() => { void snapshot(); }, 2_000);
79
+ timer.unref?.();
80
+ browser.on('disconnected', () => {
81
+ connected = false;
82
+ clearInterval(timer);
83
+ });
84
+ const close = async () => {
85
+ clearInterval(timer);
86
+ if (!connected)
87
+ return;
88
+ connected = false;
89
+ try {
90
+ await browser.close();
91
+ }
92
+ catch { /* Already gone. */ }
93
+ };
94
+ try {
95
+ await page.goto(url, { waitUntil: 'commit', timeout: 30_000 });
96
+ }
97
+ catch (cause) {
98
+ await close();
99
+ throw new DoxloopError(`The sign-in page could not be opened: ${cause instanceof Error ? cause.message.split('\n')[0] : String(cause)}`);
100
+ }
101
+ return {
102
+ url,
103
+ currentUrl: () => lastUrl,
104
+ open: () => connected && browser.isConnected(),
105
+ state: snapshot,
106
+ finish: async () => {
107
+ const state = await snapshot();
108
+ await close();
109
+ if (!state)
110
+ throw new DoxloopError('The sign-in window closed before a session could be read. Start the sign-in again.');
111
+ return state;
112
+ },
113
+ cancel: close,
114
+ };
115
+ }
116
+ /**
117
+ * Build a private Playwright MCP server for one authoring run. The server is
118
+ * passed directly to the selected agent, so users do not have to install or
119
+ * configure a browser plugin in Codex or Claude Code themselves.
120
+ */
121
+ export function screenCaptureProvider(workspace, application, auth, outputDirectory) {
122
+ const require = createRequire(import.meta.url);
123
+ const packageJson = require.resolve('@playwright/mcp/package.json');
124
+ const viewport = application.screenshots?.viewport ?? { width: 1440, height: 900 };
125
+ return {
126
+ name: SCREEN_CAPTURE_SERVER,
127
+ command: process.execPath,
128
+ args: [
129
+ join(dirname(packageJson), 'cli.js'),
130
+ '--headless',
131
+ '--browser',
132
+ 'chrome',
133
+ '--isolated',
134
+ '--output-dir',
135
+ outputDirectory ?? join(resolve(workspace), '.doxloop', 'capture-output'),
136
+ '--viewport-size',
137
+ `${viewport.width}x${viewport.height}`,
138
+ '--timeout-action',
139
+ '10000',
140
+ '--timeout-navigation',
141
+ '60000',
142
+ // A recorded sign-in session seeds the isolated profile, so the agent
143
+ // lands on the signed-in application instead of its login page.
144
+ ...(auth?.storageStatePath ? ['--storage-state', auth.storageStatePath] : []),
145
+ // Saved credentials are typed by name: the agent passes the secret's
146
+ // name to the type or fill tool and the server substitutes the value,
147
+ // then redacts it from every tool response.
148
+ ...(auth?.secretsPath ? ['--secrets', auth.secretsPath] : []),
149
+ ],
150
+ };
151
+ }
152
+ export function codexCaptureArguments(provider, required) {
153
+ const prefix = `mcp_servers.${provider.name}`;
154
+ return [
155
+ '-c',
156
+ `${prefix}.command=${JSON.stringify(provider.command)}`,
157
+ '-c',
158
+ `${prefix}.args=${JSON.stringify(provider.args)}`,
159
+ '-c',
160
+ `${prefix}.startup_timeout_sec=20`,
161
+ '-c',
162
+ `${prefix}.required=${required}`,
163
+ '-c',
164
+ `${prefix}.default_tools_approval_mode="approve"`,
165
+ ];
166
+ }
167
+ export function claudeCaptureArguments(provider) {
168
+ return [
169
+ '--mcp-config',
170
+ JSON.stringify({
171
+ mcpServers: {
172
+ [provider.name]: {
173
+ type: 'stdio',
174
+ command: provider.command,
175
+ args: provider.args,
176
+ },
177
+ },
178
+ }),
179
+ ];
180
+ }
181
+ /**
182
+ * Gemini CLI has no flag for a one-off MCP server: it reads `mcpServers` from
183
+ * the project's `.gemini/settings.json`. Merge the run's capture server into
184
+ * that file, keeping every other setting the user has there. `trust` lets the
185
+ * capture tools run without a confirmation Gemini cannot get unattended.
186
+ */
187
+ export async function writeGeminiCaptureSettings(root, provider) {
188
+ const directory = join(root, '.gemini');
189
+ const path = join(directory, 'settings.json');
190
+ await mkdir(directory, { recursive: true });
191
+ let settings = {};
192
+ try {
193
+ const parsed = JSON.parse(await readFile(path, 'utf8'));
194
+ if (parsed && typeof parsed === 'object' && !Array.isArray(parsed))
195
+ settings = parsed;
196
+ }
197
+ catch {
198
+ // A missing or unreadable file starts from an empty object.
199
+ }
200
+ const existing = settings.mcpServers;
201
+ const servers = existing && typeof existing === 'object' && !Array.isArray(existing) ? { ...existing } : {};
202
+ if (provider)
203
+ servers[provider.name] = geminiCaptureServer(provider);
204
+ else
205
+ delete servers[SCREEN_CAPTURE_SERVER];
206
+ settings.mcpServers = servers;
207
+ await writeFile(path, `${JSON.stringify(settings, null, 2)}\n`, 'utf8');
208
+ return path;
209
+ }
210
+ export function geminiCaptureServer(provider) {
211
+ return {
212
+ command: provider.command,
213
+ args: provider.args,
214
+ timeout: 20_000,
215
+ trust: true,
216
+ };
217
+ }
218
+ //# sourceMappingURL=screen-capture-provider.js.map
@@ -0,0 +1,167 @@
1
+ import { PNG } from 'pngjs';
2
+ import { type SignInProbe } from './application-probe.js';
3
+ import { type CaptureAuthContext } from './capture-auth.js';
4
+ import type { ApplicationConfig, DocumentationPlan, ScreenshotIntent, ScreenshotRunSummary } from './types.js';
5
+ export declare const SCREENSHOT_MANIFEST_FILE: string;
6
+ export interface ApplicationReadiness {
7
+ configured: boolean;
8
+ reachable: boolean;
9
+ status: 'not-configured' | 'ready' | 'authentication-required' | 'unreachable';
10
+ url?: string;
11
+ message: string;
12
+ /**
13
+ * How sign-in will be handled during capture: the recorded browser session,
14
+ * saved credentials the agent types, an expired session with nothing to
15
+ * fall back on, or no sign-in material at all.
16
+ */
17
+ authentication?: 'none' | 'session' | 'credentials' | 'expired';
18
+ /**
19
+ * The sign-in route a browser visit ended on, when the page is a sign-in
20
+ * wall that only shows once client-side routing runs (a single-page app
21
+ * that answers 200 and then redirects to `/auth`).
22
+ */
23
+ signInPath?: string;
24
+ }
25
+ export interface ApplicationReadinessOptions {
26
+ /**
27
+ * Load the page in the headless browser when the HTTP check says it is
28
+ * ready and no sign-in material exists, to catch client-side sign-in walls.
29
+ * `true` uses the managed browser; a function replaces it (tests).
30
+ */
31
+ browserProbe?: boolean | SignInProbe;
32
+ /** Where the message is shown: the setup wizard or a project's settings. */
33
+ context?: 'setup' | 'project';
34
+ }
35
+ /** The message for a sign-in wall the browser probe found. */
36
+ export declare function signInWallMessage(signInPath: string, context?: 'setup' | 'project'): string;
37
+ interface ScreenshotManifest {
38
+ schemaVersion: 1;
39
+ guides: ScreenshotManifestGuide[];
40
+ }
41
+ interface ScreenshotManifestGuide {
42
+ page: string;
43
+ steps: ScreenshotManifestStep[];
44
+ }
45
+ interface ScreenshotManifestStep {
46
+ id: string;
47
+ action: string;
48
+ expectedState: string;
49
+ purpose: string;
50
+ /** One-based item in the approved page visuals.captureSequence. */
51
+ sequenceItem?: number;
52
+ capture: boolean | 'required' | 'recommended';
53
+ target?: string;
54
+ file?: string;
55
+ alt?: string;
56
+ /** `planned` is the staged, not-yet-attempted state Doxloop writes up front. */
57
+ status: 'planned' | 'verified' | 'text-only' | 'failed';
58
+ textOnlyReason?: string;
59
+ checks?: {
60
+ expectedStateConfirmed?: boolean;
61
+ privacyReviewed?: boolean;
62
+ legibilityReviewed?: boolean;
63
+ meaningful?: boolean;
64
+ };
65
+ }
66
+ /** Generator-native committed asset root for guide screenshots. */
67
+ export declare const GUIDE_ASSET_ROOTS: Record<string, string>;
68
+ /**
69
+ * Create the guide asset directories before the agent opens a browser.
70
+ *
71
+ * The capture tool resolves its filename against the project root and does not
72
+ * create missing parents: a nested filename whose directory does not exist
73
+ * fails with ENOENT, and the run then reports screenshots it never took. The
74
+ * agent is told to create each directory, but a forgotten `mkdir` silently
75
+ * costs an entire guide, so Doxloop creates the predictable ones itself.
76
+ */
77
+ export declare function prepareGuideAssetDirectories(workspace: string, generator: string, plan: Pick<DocumentationPlan, 'pages'> | undefined, contentDir?: string): Promise<string[]>;
78
+ /**
79
+ * Write the approved guides into the manifest before the agent runs.
80
+ *
81
+ * Left to build the manifest itself, an agent builds it at the end out of what
82
+ * it happened to capture: guides it decided to skip — often without ever
83
+ * opening their startPath — simply do not appear, and the run reports success
84
+ * while quietly dropping half the approved work. Staging every approved guide
85
+ * up front turns capture into filling in a form, and a guide the agent never
86
+ * touched stays visible as an unfinished row instead of vanishing.
87
+ *
88
+ * Existing manifests are never overwritten, so a resumed or recovered run keeps
89
+ * the work it already recorded.
90
+ */
91
+ export declare function writeScreenshotManifestSkeleton(workspace: string, plan: Pick<DocumentationPlan, 'pages'> | undefined): Promise<number>;
92
+ /**
93
+ * Claim images the agent captured but never recorded as captures.
94
+ *
95
+ * An agent cannot see a PNG file, so any manifest row it fills in is bookkeeping
96
+ * rather than observation. A cautious agent that is asked to inspect the saved
97
+ * image concludes it cannot, and honestly records every step as text-only —
98
+ * discarding a directory of perfectly good screenshots and failing a run that
99
+ * actually worked. The state was already confirmed in the browser before the
100
+ * shutter, and Doxloop checks the file itself during validation, so adopt an
101
+ * unclaimed image into the step its filename names and let that validation
102
+ * judge it. The images are surfaced for human review either way.
103
+ */
104
+ export declare function adoptCapturedImages(workspace: string, generator: string, plan: DocumentationPlan | undefined): Promise<string[]>;
105
+ export declare function collapseDuplicateCaptures(workspace: string, plan: DocumentationPlan | undefined): Promise<string[]>;
106
+ /** Drop an image reference, and the frame wrapper it leaves behind. */
107
+ export declare function removeImageReference(content: string, file: string): string;
108
+ /**
109
+ * Place verified captures the agent left orphaned.
110
+ *
111
+ * Agents routinely capture every planned state and then embed only the first,
112
+ * because a step component holds the procedure and there is no obvious place to
113
+ * put the rest. The images are real and reviewed, so dropping the run over
114
+ * placement wastes correct work: insert each unused capture into the step it
115
+ * belongs to, matching capture order to step order, and fall back to the end of
116
+ * the page when the guide has no step markup.
117
+ */
118
+ export declare function embedMissingCaptures(workspace: string, plan: DocumentationPlan | undefined): Promise<string[]>;
119
+ export declare function normalizeScreenshotIntent(value: unknown): ScreenshotIntent;
120
+ export declare function assertScreenshotPlanningReadiness(application: ApplicationConfig | undefined, rawIntent: unknown, auth?: CaptureAuthContext): Promise<void>;
121
+ export declare function screenshotPlanSummary(plan: Pick<DocumentationPlan, 'pages'>): {
122
+ guides: number;
123
+ captures: number;
124
+ };
125
+ export declare function checkApplicationReadiness(application?: ApplicationConfig, auth?: CaptureAuthContext, options?: ApplicationReadinessOptions): Promise<ApplicationReadiness>;
126
+ export interface ScreenshotValidationOptions {
127
+ /**
128
+ * Accept the run despite screenshot problems. Every defect becomes a text-only
129
+ * step with the problem recorded as its reason, images that cannot be shown
130
+ * are removed from their guide, and the summary reports how many problems
131
+ * remain for review. Nothing is thrown for a capture shortfall.
132
+ */
133
+ tolerateDefects?: boolean;
134
+ /**
135
+ * Collect every defect without changing the manifest, the pages, or the
136
+ * images, so a targeted retake can be attempted before anything is
137
+ * downgraded. Implies `tolerateDefects` for collection purposes.
138
+ */
139
+ dryRun?: boolean;
140
+ }
141
+ export declare function validateScreenshotManifest(workspace: string, plan: DocumentationPlan | undefined, rawIntent: unknown, options?: ScreenshotValidationOptions): Promise<{
142
+ summary: ScreenshotRunSummary;
143
+ manifest?: ScreenshotManifest;
144
+ defects: string[];
145
+ }>;
146
+ /**
147
+ * Summarize how far capture got, guide by guide, for an agent that continues an
148
+ * interrupted run. Verified rows are named so the agent keeps them; unfinished
149
+ * rows are named with their start path so it knows exactly what is left.
150
+ */
151
+ export declare function describeScreenshotManifestProgress(workspace: string, plan: DocumentationPlan | undefined): Promise<{
152
+ lines: string[];
153
+ verified: number;
154
+ unfinished: number;
155
+ }>;
156
+ /** Share of sampled pixels holding the single most common color. */
157
+ export declare function dominantColorShare(image: PNG): number;
158
+ /** Where a run's discarded images go; never part of a proposal, always recoverable. */
159
+ export declare const QUARANTINE_DIRECTORY = ".doxloop/quarantine";
160
+ /**
161
+ * Set an image aside instead of deleting it. A downgrade that turns out to be
162
+ * wrong (a validator disagreeing with bookkeeping, a duplicate that was not
163
+ * one) then costs a note on the run, not the picture.
164
+ */
165
+ export declare function quarantineImage(workspace: string, file: string): Promise<string | undefined>;
166
+ export {};
167
+ //# sourceMappingURL=screenshot-workflow.d.ts.map