claude-chrome-parallel 1.0.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.
- package/LICENSE +21 -0
- package/README.md +501 -0
- package/assets/demo.svg +278 -0
- package/dist/cdp/client.d.ts +218 -0
- package/dist/cdp/client.d.ts.map +1 -0
- package/dist/cdp/client.js +797 -0
- package/dist/cdp/client.js.map +1 -0
- package/dist/cdp/connection-pool.d.ts +125 -0
- package/dist/cdp/connection-pool.d.ts.map +1 -0
- package/dist/cdp/connection-pool.js +443 -0
- package/dist/cdp/connection-pool.js.map +1 -0
- package/dist/cdp/screenshot-scheduler.d.ts +54 -0
- package/dist/cdp/screenshot-scheduler.d.ts.map +1 -0
- package/dist/cdp/screenshot-scheduler.js +87 -0
- package/dist/cdp/screenshot-scheduler.js.map +1 -0
- package/dist/chrome/launcher.d.ts +55 -0
- package/dist/chrome/launcher.d.ts.map +1 -0
- package/dist/chrome/launcher.js +383 -0
- package/dist/chrome/launcher.js.map +1 -0
- package/dist/chrome/pool.d.ts +54 -0
- package/dist/chrome/pool.d.ts.map +1 -0
- package/dist/chrome/pool.js +301 -0
- package/dist/chrome/pool.js.map +1 -0
- package/dist/chrome/profile-detector.d.ts +52 -0
- package/dist/chrome/profile-detector.d.ts.map +1 -0
- package/dist/chrome/profile-detector.js +246 -0
- package/dist/chrome/profile-detector.js.map +1 -0
- package/dist/cli/claude-session.d.ts +11 -0
- package/dist/cli/claude-session.js +349 -0
- package/dist/cli/claude-session.js.map +1 -0
- package/dist/cli/index.d.ts +14 -0
- package/dist/cli/index.js +858 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/cli/install.d.ts +16 -0
- package/dist/cli/install.js +185 -0
- package/dist/cli/install.js.map +1 -0
- package/dist/cli/uninstall.d.ts +7 -0
- package/dist/cli/uninstall.js +126 -0
- package/dist/cli/uninstall.js.map +1 -0
- package/dist/cli/update-check.d.ts +9 -0
- package/dist/cli/update-check.js +141 -0
- package/dist/cli/update-check.js.map +1 -0
- package/dist/config/config-recovery.d.ts +69 -0
- package/dist/config/config-recovery.d.ts.map +1 -0
- package/dist/config/config-recovery.js +302 -0
- package/dist/config/config-recovery.js.map +1 -0
- package/dist/config/global.d.ts +49 -0
- package/dist/config/global.d.ts.map +1 -0
- package/dist/config/global.js +24 -0
- package/dist/config/global.js.map +1 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/index.d.ts.map +1 -0
- package/dist/config/index.js +23 -0
- package/dist/config/index.js.map +1 -0
- package/dist/config/session-isolator.d.ts +76 -0
- package/dist/config/session-isolator.d.ts.map +1 -0
- package/dist/config/session-isolator.js +268 -0
- package/dist/config/session-isolator.js.map +1 -0
- package/dist/dashboard/activity-tracker.d.ts +76 -0
- package/dist/dashboard/activity-tracker.d.ts.map +1 -0
- package/dist/dashboard/activity-tracker.js +219 -0
- package/dist/dashboard/activity-tracker.js.map +1 -0
- package/dist/dashboard/ansi.d.ts +117 -0
- package/dist/dashboard/ansi.d.ts.map +1 -0
- package/dist/dashboard/ansi.js +199 -0
- package/dist/dashboard/ansi.js.map +1 -0
- package/dist/dashboard/index.d.ts +110 -0
- package/dist/dashboard/index.d.ts.map +1 -0
- package/dist/dashboard/index.js +412 -0
- package/dist/dashboard/index.js.map +1 -0
- package/dist/dashboard/keyboard-handler.d.ts +43 -0
- package/dist/dashboard/keyboard-handler.d.ts.map +1 -0
- package/dist/dashboard/keyboard-handler.js +215 -0
- package/dist/dashboard/keyboard-handler.js.map +1 -0
- package/dist/dashboard/operation-controller.d.ts +76 -0
- package/dist/dashboard/operation-controller.d.ts.map +1 -0
- package/dist/dashboard/operation-controller.js +167 -0
- package/dist/dashboard/operation-controller.js.map +1 -0
- package/dist/dashboard/renderer.d.ts +76 -0
- package/dist/dashboard/renderer.d.ts.map +1 -0
- package/dist/dashboard/renderer.js +193 -0
- package/dist/dashboard/renderer.js.map +1 -0
- package/dist/dashboard/types.d.ts +56 -0
- package/dist/dashboard/types.d.ts.map +1 -0
- package/dist/dashboard/types.js +12 -0
- package/dist/dashboard/types.js.map +1 -0
- package/dist/dashboard/views/main-view.d.ts +23 -0
- package/dist/dashboard/views/main-view.d.ts.map +1 -0
- package/dist/dashboard/views/main-view.js +143 -0
- package/dist/dashboard/views/main-view.js.map +1 -0
- package/dist/dashboard/views/sessions-view.d.ts +22 -0
- package/dist/dashboard/views/sessions-view.d.ts.map +1 -0
- package/dist/dashboard/views/sessions-view.js +104 -0
- package/dist/dashboard/views/sessions-view.js.map +1 -0
- package/dist/dashboard/views/tabs-view.d.ts +21 -0
- package/dist/dashboard/views/tabs-view.d.ts.map +1 -0
- package/dist/dashboard/views/tabs-view.js +92 -0
- package/dist/dashboard/views/tabs-view.js.map +1 -0
- package/dist/hints/hint-engine.d.ts +77 -0
- package/dist/hints/hint-engine.d.ts.map +1 -0
- package/dist/hints/hint-engine.js +191 -0
- package/dist/hints/hint-engine.js.map +1 -0
- package/dist/hints/index.d.ts +8 -0
- package/dist/hints/index.d.ts.map +1 -0
- package/dist/hints/index.js +11 -0
- package/dist/hints/index.js.map +1 -0
- package/dist/hints/pattern-learner.d.ts +76 -0
- package/dist/hints/pattern-learner.d.ts.map +1 -0
- package/dist/hints/pattern-learner.js +254 -0
- package/dist/hints/pattern-learner.js.map +1 -0
- package/dist/hints/rules/composite-suggestions.d.ts +6 -0
- package/dist/hints/rules/composite-suggestions.d.ts.map +1 -0
- package/dist/hints/rules/composite-suggestions.js +66 -0
- package/dist/hints/rules/composite-suggestions.js.map +1 -0
- package/dist/hints/rules/error-recovery.d.ts +7 -0
- package/dist/hints/rules/error-recovery.d.ts.map +1 -0
- package/dist/hints/rules/error-recovery.js +55 -0
- package/dist/hints/rules/error-recovery.js.map +1 -0
- package/dist/hints/rules/learned-rules.d.ts +13 -0
- package/dist/hints/rules/learned-rules.d.ts.map +1 -0
- package/dist/hints/rules/learned-rules.js +27 -0
- package/dist/hints/rules/learned-rules.js.map +1 -0
- package/dist/hints/rules/repetition-detection.d.ts +7 -0
- package/dist/hints/rules/repetition-detection.d.ts.map +1 -0
- package/dist/hints/rules/repetition-detection.js +82 -0
- package/dist/hints/rules/repetition-detection.js.map +1 -0
- package/dist/hints/rules/sequence-detection.d.ts +6 -0
- package/dist/hints/rules/sequence-detection.d.ts.map +1 -0
- package/dist/hints/rules/sequence-detection.js +89 -0
- package/dist/hints/rules/sequence-detection.js.map +1 -0
- package/dist/hints/rules/success-hints.d.ts +6 -0
- package/dist/hints/rules/success-hints.d.ts.map +1 -0
- package/dist/hints/rules/success-hints.js +62 -0
- package/dist/hints/rules/success-hints.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +272 -0
- package/dist/index.js.map +1 -0
- package/dist/lightpanda/launcher.d.ts +58 -0
- package/dist/lightpanda/launcher.d.ts.map +1 -0
- package/dist/lightpanda/launcher.js +199 -0
- package/dist/lightpanda/launcher.js.map +1 -0
- package/dist/mcp-server.d.ts +129 -0
- package/dist/mcp-server.d.ts.map +1 -0
- package/dist/mcp-server.js +641 -0
- package/dist/mcp-server.js.map +1 -0
- package/dist/memory/domain-memory.d.ts +68 -0
- package/dist/memory/domain-memory.d.ts.map +1 -0
- package/dist/memory/domain-memory.js +227 -0
- package/dist/memory/domain-memory.js.map +1 -0
- package/dist/orchestration/plan-executor.d.ts +19 -0
- package/dist/orchestration/plan-executor.d.ts.map +1 -0
- package/dist/orchestration/plan-executor.js +284 -0
- package/dist/orchestration/plan-executor.js.map +1 -0
- package/dist/orchestration/plan-registry.d.ts +55 -0
- package/dist/orchestration/plan-registry.d.ts.map +1 -0
- package/dist/orchestration/plan-registry.js +255 -0
- package/dist/orchestration/plan-registry.js.map +1 -0
- package/dist/orchestration/state-manager.d.ts +127 -0
- package/dist/orchestration/state-manager.d.ts.map +1 -0
- package/dist/orchestration/state-manager.js +438 -0
- package/dist/orchestration/state-manager.js.map +1 -0
- package/dist/orchestration/workflow-engine.d.ts +162 -0
- package/dist/orchestration/workflow-engine.d.ts.map +1 -0
- package/dist/orchestration/workflow-engine.js +731 -0
- package/dist/orchestration/workflow-engine.js.map +1 -0
- package/dist/resources/usage-guide.d.ts +13 -0
- package/dist/resources/usage-guide.d.ts.map +1 -0
- package/dist/resources/usage-guide.js +101 -0
- package/dist/resources/usage-guide.js.map +1 -0
- package/dist/router/browser-router.d.ts +51 -0
- package/dist/router/browser-router.d.ts.map +1 -0
- package/dist/router/browser-router.js +178 -0
- package/dist/router/browser-router.js.map +1 -0
- package/dist/router/cookie-sync.d.ts +48 -0
- package/dist/router/cookie-sync.d.ts.map +1 -0
- package/dist/router/cookie-sync.js +106 -0
- package/dist/router/cookie-sync.js.map +1 -0
- package/dist/router/index.d.ts +5 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +10 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/tool-routing-registry.d.ts +21 -0
- package/dist/router/tool-routing-registry.d.ts.map +1 -0
- package/dist/router/tool-routing-registry.js +90 -0
- package/dist/router/tool-routing-registry.js.map +1 -0
- package/dist/session-manager.d.ts +251 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +912 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/tools/batch-execute.d.ts +11 -0
- package/dist/tools/batch-execute.d.ts.map +1 -0
- package/dist/tools/batch-execute.js +226 -0
- package/dist/tools/batch-execute.js.map +1 -0
- package/dist/tools/click-element.d.ts +8 -0
- package/dist/tools/click-element.d.ts.map +1 -0
- package/dist/tools/click-element.js +455 -0
- package/dist/tools/click-element.js.map +1 -0
- package/dist/tools/computer.d.ts +6 -0
- package/dist/tools/computer.d.ts.map +1 -0
- package/dist/tools/computer.js +638 -0
- package/dist/tools/computer.js.map +1 -0
- package/dist/tools/console-capture.d.ts +6 -0
- package/dist/tools/console-capture.d.ts.map +1 -0
- package/dist/tools/console-capture.js +320 -0
- package/dist/tools/console-capture.js.map +1 -0
- package/dist/tools/cookies.d.ts +6 -0
- package/dist/tools/cookies.d.ts.map +1 -0
- package/dist/tools/cookies.js +263 -0
- package/dist/tools/cookies.js.map +1 -0
- package/dist/tools/drag-drop.d.ts +6 -0
- package/dist/tools/drag-drop.d.ts.map +1 -0
- package/dist/tools/drag-drop.js +252 -0
- package/dist/tools/drag-drop.js.map +1 -0
- package/dist/tools/emulate-device.d.ts +6 -0
- package/dist/tools/emulate-device.d.ts.map +1 -0
- package/dist/tools/emulate-device.js +221 -0
- package/dist/tools/emulate-device.js.map +1 -0
- package/dist/tools/file-upload.d.ts +6 -0
- package/dist/tools/file-upload.d.ts.map +1 -0
- package/dist/tools/file-upload.js +208 -0
- package/dist/tools/file-upload.js.map +1 -0
- package/dist/tools/fill-form.d.ts +8 -0
- package/dist/tools/fill-form.d.ts.map +1 -0
- package/dist/tools/fill-form.js +342 -0
- package/dist/tools/fill-form.js.map +1 -0
- package/dist/tools/find.d.ts +6 -0
- package/dist/tools/find.d.ts.map +1 -0
- package/dist/tools/find.js +330 -0
- package/dist/tools/find.js.map +1 -0
- package/dist/tools/form-input.d.ts +6 -0
- package/dist/tools/form-input.d.ts.map +1 -0
- package/dist/tools/form-input.js +181 -0
- package/dist/tools/form-input.js.map +1 -0
- package/dist/tools/geolocation.d.ts +6 -0
- package/dist/tools/geolocation.d.ts.map +1 -0
- package/dist/tools/geolocation.js +172 -0
- package/dist/tools/geolocation.js.map +1 -0
- package/dist/tools/http-auth.d.ts +6 -0
- package/dist/tools/http-auth.d.ts.map +1 -0
- package/dist/tools/http-auth.js +136 -0
- package/dist/tools/http-auth.js.map +1 -0
- package/dist/tools/index.d.ts +6 -0
- package/dist/tools/index.d.ts.map +1 -0
- package/dist/tools/index.js +104 -0
- package/dist/tools/index.js.map +1 -0
- package/dist/tools/javascript.d.ts +6 -0
- package/dist/tools/javascript.d.ts.map +1 -0
- package/dist/tools/javascript.js +138 -0
- package/dist/tools/javascript.js.map +1 -0
- package/dist/tools/lightweight-scroll.d.ts +11 -0
- package/dist/tools/lightweight-scroll.d.ts.map +1 -0
- package/dist/tools/lightweight-scroll.js +266 -0
- package/dist/tools/lightweight-scroll.js.map +1 -0
- package/dist/tools/memory.d.ts +10 -0
- package/dist/tools/memory.d.ts.map +1 -0
- package/dist/tools/memory.js +141 -0
- package/dist/tools/memory.js.map +1 -0
- package/dist/tools/navigate.d.ts +6 -0
- package/dist/tools/navigate.d.ts.map +1 -0
- package/dist/tools/navigate.js +241 -0
- package/dist/tools/navigate.js.map +1 -0
- package/dist/tools/network.d.ts +6 -0
- package/dist/tools/network.d.ts.map +1 -0
- package/dist/tools/network.js +215 -0
- package/dist/tools/network.js.map +1 -0
- package/dist/tools/orchestration.d.ts +6 -0
- package/dist/tools/orchestration.d.ts.map +1 -0
- package/dist/tools/orchestration.js +746 -0
- package/dist/tools/orchestration.js.map +1 -0
- package/dist/tools/page-content.d.ts +6 -0
- package/dist/tools/page-content.d.ts.map +1 -0
- package/dist/tools/page-content.js +120 -0
- package/dist/tools/page-content.js.map +1 -0
- package/dist/tools/page-pdf.d.ts +6 -0
- package/dist/tools/page-pdf.d.ts.map +1 -0
- package/dist/tools/page-pdf.js +245 -0
- package/dist/tools/page-pdf.js.map +1 -0
- package/dist/tools/page-reload.d.ts +6 -0
- package/dist/tools/page-reload.d.ts.map +1 -0
- package/dist/tools/page-reload.js +89 -0
- package/dist/tools/page-reload.js.map +1 -0
- package/dist/tools/performance-metrics.d.ts +6 -0
- package/dist/tools/performance-metrics.d.ts.map +1 -0
- package/dist/tools/performance-metrics.js +158 -0
- package/dist/tools/performance-metrics.js.map +1 -0
- package/dist/tools/read-page.d.ts +6 -0
- package/dist/tools/read-page.d.ts.map +1 -0
- package/dist/tools/read-page.js +287 -0
- package/dist/tools/read-page.js.map +1 -0
- package/dist/tools/request-intercept.d.ts +6 -0
- package/dist/tools/request-intercept.d.ts.map +1 -0
- package/dist/tools/request-intercept.js +439 -0
- package/dist/tools/request-intercept.js.map +1 -0
- package/dist/tools/selector-query.d.ts +6 -0
- package/dist/tools/selector-query.d.ts.map +1 -0
- package/dist/tools/selector-query.js +206 -0
- package/dist/tools/selector-query.js.map +1 -0
- package/dist/tools/shutdown.d.ts +12 -0
- package/dist/tools/shutdown.d.ts.map +1 -0
- package/dist/tools/shutdown.js +120 -0
- package/dist/tools/shutdown.js.map +1 -0
- package/dist/tools/storage.d.ts +6 -0
- package/dist/tools/storage.d.ts.map +1 -0
- package/dist/tools/storage.js +264 -0
- package/dist/tools/storage.js.map +1 -0
- package/dist/tools/tabs-close.d.ts +6 -0
- package/dist/tools/tabs-close.d.ts.map +1 -0
- package/dist/tools/tabs-close.js +124 -0
- package/dist/tools/tabs-close.js.map +1 -0
- package/dist/tools/tabs-context.d.ts +6 -0
- package/dist/tools/tabs-context.d.ts.map +1 -0
- package/dist/tools/tabs-context.js +92 -0
- package/dist/tools/tabs-context.js.map +1 -0
- package/dist/tools/tabs-create.d.ts +6 -0
- package/dist/tools/tabs-create.d.ts.map +1 -0
- package/dist/tools/tabs-create.js +73 -0
- package/dist/tools/tabs-create.js.map +1 -0
- package/dist/tools/user-agent.d.ts +6 -0
- package/dist/tools/user-agent.d.ts.map +1 -0
- package/dist/tools/user-agent.js +128 -0
- package/dist/tools/user-agent.js.map +1 -0
- package/dist/tools/wait-and-click.d.ts +8 -0
- package/dist/tools/wait-and-click.d.ts.map +1 -0
- package/dist/tools/wait-and-click.js +290 -0
- package/dist/tools/wait-and-click.js.map +1 -0
- package/dist/tools/wait-for.d.ts +6 -0
- package/dist/tools/wait-for.d.ts.map +1 -0
- package/dist/tools/wait-for.js +248 -0
- package/dist/tools/wait-for.js.map +1 -0
- package/dist/tools/worker-create.d.ts +7 -0
- package/dist/tools/worker-create.d.ts.map +1 -0
- package/dist/tools/worker-create.js +62 -0
- package/dist/tools/worker-create.js.map +1 -0
- package/dist/tools/worker-delete.d.ts +6 -0
- package/dist/tools/worker-delete.d.ts.map +1 -0
- package/dist/tools/worker-delete.js +80 -0
- package/dist/tools/worker-delete.js.map +1 -0
- package/dist/tools/worker-list.d.ts +6 -0
- package/dist/tools/worker-list.d.ts.map +1 -0
- package/dist/tools/worker-list.js +67 -0
- package/dist/tools/worker-list.js.map +1 -0
- package/dist/tools/xpath-query.d.ts +6 -0
- package/dist/tools/xpath-query.d.ts.map +1 -0
- package/dist/tools/xpath-query.js +230 -0
- package/dist/tools/xpath-query.js.map +1 -0
- package/dist/types/browser-backend.d.ts +30 -0
- package/dist/types/browser-backend.d.ts.map +1 -0
- package/dist/types/browser-backend.js +9 -0
- package/dist/types/browser-backend.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +19 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/mcp.d.ts +54 -0
- package/dist/types/mcp.d.ts.map +1 -0
- package/dist/types/mcp.js +14 -0
- package/dist/types/mcp.js.map +1 -0
- package/dist/types/plan-cache.d.ts +121 -0
- package/dist/types/plan-cache.d.ts.map +1 -0
- package/dist/types/plan-cache.js +9 -0
- package/dist/types/plan-cache.js.map +1 -0
- package/dist/types/profile.d.ts +76 -0
- package/dist/types/profile.d.ts.map +1 -0
- package/dist/types/profile.js +35 -0
- package/dist/types/profile.js.map +1 -0
- package/dist/types/session.d.ts +65 -0
- package/dist/types/session.d.ts.map +1 -0
- package/dist/types/session.js +6 -0
- package/dist/types/session.js.map +1 -0
- package/dist/types/tool-manifest.d.ts +52 -0
- package/dist/types/tool-manifest.d.ts.map +1 -0
- package/dist/types/tool-manifest.js +37 -0
- package/dist/types/tool-manifest.js.map +1 -0
- package/dist/utils/atomic-file.d.ts +50 -0
- package/dist/utils/atomic-file.d.ts.map +1 -0
- package/dist/utils/atomic-file.js +217 -0
- package/dist/utils/atomic-file.js.map +1 -0
- package/dist/utils/index.d.ts +6 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +22 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/json-validator.d.ts +40 -0
- package/dist/utils/json-validator.d.ts.map +1 -0
- package/dist/utils/json-validator.js +295 -0
- package/dist/utils/json-validator.js.map +1 -0
- package/dist/utils/ref-id-manager.d.ts +26 -0
- package/dist/utils/ref-id-manager.d.ts.map +1 -0
- package/dist/utils/ref-id-manager.js +81 -0
- package/dist/utils/ref-id-manager.js.map +1 -0
- package/dist/utils/request-queue.d.ts +37 -0
- package/dist/utils/request-queue.d.ts.map +1 -0
- package/dist/utils/request-queue.js +110 -0
- package/dist/utils/request-queue.js.map +1 -0
- package/package.json +78 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"profile.js","sourceRoot":"","sources":["../../src/types/profile.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AA+DH;;GAEG;AACH,MAAa,iBAAkB,SAAQ,KAAK;IAExB;IACA;IAFlB,YACkB,SAAiB,EACjB,WAAmB;QAEnC,KAAK,CAAC,YAAY,SAAS,sEAAsE,CAAC,CAAC;QAHnF,cAAS,GAAT,SAAS,CAAQ;QACjB,gBAAW,GAAX,WAAW,CAAQ;QAGnC,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC;IAClC,CAAC;CACF;AARD,8CAQC;AAED;;GAEG;AACH,MAAa,oBAAqB,SAAQ,KAAK;IAE3B;IACA;IAFlB,YACkB,SAAiB,EACjB,iBAA2B;QAE3C,KAAK,CACH,YAAY,SAAS,oCAAoC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,MAAM,EAAE,CAClG,CAAC;QALc,cAAS,GAAT,SAAS,CAAQ;QACjB,sBAAiB,GAAjB,iBAAiB,CAAU;QAK3C,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AAVD,oDAUC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Session Types
|
|
3
|
+
*/
|
|
4
|
+
import { BrowserContext } from 'puppeteer-core';
|
|
5
|
+
/**
|
|
6
|
+
* Worker - An isolated browser context within a session
|
|
7
|
+
* Each worker has its own cookies, localStorage, sessionStorage
|
|
8
|
+
* Enables parallel browser operations from a single Claude Code session
|
|
9
|
+
*/
|
|
10
|
+
export interface Worker {
|
|
11
|
+
id: string;
|
|
12
|
+
name: string;
|
|
13
|
+
targets: Set<string>;
|
|
14
|
+
context: BrowserContext | null;
|
|
15
|
+
createdAt: number;
|
|
16
|
+
lastActivityAt: number;
|
|
17
|
+
port?: number;
|
|
18
|
+
poolOrigin?: string;
|
|
19
|
+
}
|
|
20
|
+
export interface WorkerInfo {
|
|
21
|
+
id: string;
|
|
22
|
+
name: string;
|
|
23
|
+
targetCount: number;
|
|
24
|
+
createdAt: number;
|
|
25
|
+
lastActivityAt: number;
|
|
26
|
+
}
|
|
27
|
+
export interface WorkerCreateOptions {
|
|
28
|
+
id?: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
shareCookies?: boolean;
|
|
31
|
+
targetUrl?: string;
|
|
32
|
+
}
|
|
33
|
+
export interface Session {
|
|
34
|
+
id: string;
|
|
35
|
+
/** Workers within this session (each with isolated browser context) */
|
|
36
|
+
workers: Map<string, Worker>;
|
|
37
|
+
/** Default worker for backwards compatibility */
|
|
38
|
+
defaultWorkerId: string;
|
|
39
|
+
createdAt: number;
|
|
40
|
+
lastActivityAt: number;
|
|
41
|
+
name: string;
|
|
42
|
+
targets: Set<string>;
|
|
43
|
+
context?: BrowserContext | null;
|
|
44
|
+
}
|
|
45
|
+
export interface SessionInfo {
|
|
46
|
+
id: string;
|
|
47
|
+
targetCount: number;
|
|
48
|
+
workerCount: number;
|
|
49
|
+
workers: WorkerInfo[];
|
|
50
|
+
createdAt: number;
|
|
51
|
+
lastActivityAt: number;
|
|
52
|
+
name: string;
|
|
53
|
+
}
|
|
54
|
+
export interface SessionCreateOptions {
|
|
55
|
+
id?: string;
|
|
56
|
+
name?: string;
|
|
57
|
+
}
|
|
58
|
+
export interface SessionEvent {
|
|
59
|
+
type: 'session:created' | 'session:deleted' | 'session:target-added' | 'session:target-removed' | 'session:target-closed' | 'worker:created' | 'worker:deleted';
|
|
60
|
+
sessionId: string;
|
|
61
|
+
targetId?: string;
|
|
62
|
+
workerId?: string;
|
|
63
|
+
timestamp: number;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=session.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAEhD;;;;GAIG;AACH,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,UAAU;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,mBAAmB;IAClC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,uEAAuE;IACvE,OAAO,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,iDAAiD;IACjD,eAAe,EAAE,MAAM,CAAC;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;IAEb,OAAO,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACrB,OAAO,CAAC,EAAE,cAAc,GAAG,IAAI,CAAC;CACjC;AAED,MAAM,WAAW,WAAW;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,iBAAiB,GAAG,iBAAiB,GAAG,sBAAsB,GAAG,wBAAwB,GAAG,uBAAuB,GAAG,gBAAgB,GAAG,gBAAgB,CAAC;IAChK,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/types/session.ts"],"names":[],"mappings":";AAAA;;GAEG"}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tool Manifest Types - Shared Tool Registry for worker agents
|
|
3
|
+
*
|
|
4
|
+
* Enables workflow_init to export registered tool schemas so that
|
|
5
|
+
* worker agents can skip ToolSearch and call tools immediately.
|
|
6
|
+
*/
|
|
7
|
+
/** A single tool entry in the manifest */
|
|
8
|
+
export interface ToolEntry {
|
|
9
|
+
/** Full MCP tool name (e.g. "navigate", "javascript_tool") */
|
|
10
|
+
name: string;
|
|
11
|
+
/** Human-readable description */
|
|
12
|
+
description: string;
|
|
13
|
+
/** JSON Schema for tool parameters */
|
|
14
|
+
inputSchema: {
|
|
15
|
+
type: 'object';
|
|
16
|
+
properties: Record<string, unknown>;
|
|
17
|
+
required?: string[];
|
|
18
|
+
};
|
|
19
|
+
/** Tool category for filtering */
|
|
20
|
+
category: ToolCategory;
|
|
21
|
+
}
|
|
22
|
+
/** Tool categories for WorkerToolConfig filtering */
|
|
23
|
+
export type ToolCategory = 'navigation' | 'interaction' | 'content' | 'javascript' | 'network' | 'tabs' | 'media' | 'emulation' | 'orchestration' | 'worker' | 'composite' | 'performance' | 'lifecycle';
|
|
24
|
+
/** The complete tool manifest exported by the MCP server */
|
|
25
|
+
export interface ToolManifest {
|
|
26
|
+
/** Manifest version for cache invalidation */
|
|
27
|
+
version: string;
|
|
28
|
+
/** Generation timestamp */
|
|
29
|
+
generatedAt: number;
|
|
30
|
+
/** All registered tools */
|
|
31
|
+
tools: ToolEntry[];
|
|
32
|
+
/** Total tool count */
|
|
33
|
+
toolCount: number;
|
|
34
|
+
}
|
|
35
|
+
/** Per-worker tool access configuration */
|
|
36
|
+
export interface WorkerToolConfig {
|
|
37
|
+
/** Worker type determines default tool set */
|
|
38
|
+
workerType: 'extraction' | 'interaction' | 'full';
|
|
39
|
+
/** Allowed tool categories (whitelist) */
|
|
40
|
+
allowedCategories?: ToolCategory[];
|
|
41
|
+
/** Specific tools to include regardless of category */
|
|
42
|
+
additionalTools?: string[];
|
|
43
|
+
/** Specific tools to exclude regardless of category */
|
|
44
|
+
excludedTools?: string[];
|
|
45
|
+
}
|
|
46
|
+
/** Default tool sets per worker type */
|
|
47
|
+
export declare const DEFAULT_WORKER_TOOLS: Record<WorkerToolConfig['workerType'], ToolCategory[]>;
|
|
48
|
+
/**
|
|
49
|
+
* Filter manifest tools based on WorkerToolConfig
|
|
50
|
+
*/
|
|
51
|
+
export declare function filterToolsForWorker(manifest: ToolManifest, config: WorkerToolConfig): ToolEntry[];
|
|
52
|
+
//# sourceMappingURL=tool-manifest.d.ts.map
|
|
@@ -0,0 +1 @@
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,CAAC,gBAAgB,CAAC,YAAY,CAAC,EAAE,YAAY,EAAE,CAOvF,CAAC;AAEF;;GAEG;AACH,wBAAgB,oBAAoB,CAClC,QAAQ,EAAE,YAAY,EACtB,MAAM,EAAE,gBAAgB,GACvB,SAAS,EAAE,CAmBb"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Tool Manifest Types - Shared Tool Registry for worker agents
|
|
4
|
+
*
|
|
5
|
+
* Enables workflow_init to export registered tool schemas so that
|
|
6
|
+
* worker agents can skip ToolSearch and call tools immediately.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.DEFAULT_WORKER_TOOLS = void 0;
|
|
10
|
+
exports.filterToolsForWorker = filterToolsForWorker;
|
|
11
|
+
/** Default tool sets per worker type */
|
|
12
|
+
exports.DEFAULT_WORKER_TOOLS = {
|
|
13
|
+
extraction: ['javascript', 'content', 'composite'],
|
|
14
|
+
interaction: ['navigation', 'interaction', 'content', 'javascript', 'composite'],
|
|
15
|
+
full: [
|
|
16
|
+
'navigation', 'interaction', 'content', 'javascript',
|
|
17
|
+
'network', 'tabs', 'media', 'emulation', 'composite', 'performance',
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Filter manifest tools based on WorkerToolConfig
|
|
22
|
+
*/
|
|
23
|
+
function filterToolsForWorker(manifest, config) {
|
|
24
|
+
const allowedCategories = config.allowedCategories || exports.DEFAULT_WORKER_TOOLS[config.workerType];
|
|
25
|
+
let tools = manifest.tools.filter(t => allowedCategories.includes(t.category));
|
|
26
|
+
// Add specific additional tools
|
|
27
|
+
if (config.additionalTools?.length) {
|
|
28
|
+
const additional = manifest.tools.filter(t => config.additionalTools.includes(t.name) && !tools.some(existing => existing.name === t.name));
|
|
29
|
+
tools = [...tools, ...additional];
|
|
30
|
+
}
|
|
31
|
+
// Remove excluded tools
|
|
32
|
+
if (config.excludedTools?.length) {
|
|
33
|
+
tools = tools.filter(t => !config.excludedTools.includes(t.name));
|
|
34
|
+
}
|
|
35
|
+
return tools;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=tool-manifest.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tool-manifest.js","sourceRoot":"","sources":["../../src/types/tool-manifest.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAuEH,oDAsBC;AAnCD,wCAAwC;AAC3B,QAAA,oBAAoB,GAA2D;IAC1F,UAAU,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,WAAW,CAAC;IAClD,WAAW,EAAE,CAAC,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY,EAAE,WAAW,CAAC;IAChF,IAAI,EAAE;QACJ,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,YAAY;QACpD,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa;KACpE;CACF,CAAC;AAEF;;GAEG;AACH,SAAgB,oBAAoB,CAClC,QAAsB,EACtB,MAAwB;IAExB,MAAM,iBAAiB,GAAG,MAAM,CAAC,iBAAiB,IAAI,4BAAoB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE9F,IAAI,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,iBAAiB,CAAC,QAAQ,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE/E,gCAAgC;IAChC,IAAI,MAAM,CAAC,eAAe,EAAE,MAAM,EAAE,CAAC;QACnC,MAAM,UAAU,GAAG,QAAQ,CAAC,KAAK,CAAC,MAAM,CACtC,CAAC,CAAC,EAAE,CAAC,MAAM,CAAC,eAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC,CACnG,CAAC;QACF,KAAK,GAAG,CAAC,GAAG,KAAK,EAAE,GAAG,UAAU,CAAC,CAAC;IACpC,CAAC;IAED,wBAAwB;IACxB,IAAI,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,CAAC;QACjC,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,aAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;IACrE,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Atomic file operations for safe concurrent access
|
|
3
|
+
* Prevents race conditions when multiple processes access the same file
|
|
4
|
+
*/
|
|
5
|
+
export interface WriteOptions {
|
|
6
|
+
/** Create backup before writing */
|
|
7
|
+
backup?: boolean;
|
|
8
|
+
/** Timeout for acquiring lock (ms) */
|
|
9
|
+
lockTimeout?: number;
|
|
10
|
+
}
|
|
11
|
+
export interface ReadResult<T> {
|
|
12
|
+
success: boolean;
|
|
13
|
+
data?: T;
|
|
14
|
+
error?: string;
|
|
15
|
+
corrupted?: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Write file atomically using temp file + rename pattern
|
|
19
|
+
* This ensures the file is never in a partial/corrupt state
|
|
20
|
+
*/
|
|
21
|
+
export declare function writeFileAtomicSafe(filePath: string, data: string | object, options?: WriteOptions): Promise<void>;
|
|
22
|
+
/**
|
|
23
|
+
* Read file safely with JSON validation
|
|
24
|
+
*/
|
|
25
|
+
export declare function readFileSafe<T = unknown>(filePath: string): Promise<ReadResult<T>>;
|
|
26
|
+
/**
|
|
27
|
+
* Create a backup of a file
|
|
28
|
+
*/
|
|
29
|
+
export declare function backupFile(filePath: string, backupDir?: string): Promise<string>;
|
|
30
|
+
/**
|
|
31
|
+
* Restore a file from backup
|
|
32
|
+
*/
|
|
33
|
+
export declare function restoreFromBackup(backupPath: string, targetPath: string): Promise<void>;
|
|
34
|
+
/**
|
|
35
|
+
* Get list of available backups for a file
|
|
36
|
+
*/
|
|
37
|
+
export declare function listBackups(originalFilename: string, backupDir?: string): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Clean up old backups, keeping only the specified number
|
|
40
|
+
*/
|
|
41
|
+
export declare function cleanupBackups(originalFilename: string, keepCount?: number, backupDir?: string): number;
|
|
42
|
+
/**
|
|
43
|
+
* Acquire a file lock with timeout
|
|
44
|
+
*/
|
|
45
|
+
export declare function acquireLock(filePath: string, timeout?: number): Promise<() => Promise<void>>;
|
|
46
|
+
/**
|
|
47
|
+
* Check if a file is currently locked
|
|
48
|
+
*/
|
|
49
|
+
export declare function isLocked(filePath: string): Promise<boolean>;
|
|
50
|
+
//# sourceMappingURL=atomic-file.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-file.d.ts","sourceRoot":"","sources":["../../src/utils/atomic-file.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAQH,MAAM,WAAW,YAAY;IAC3B,mCAAmC;IACnC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,sCAAsC;IACtC,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU,CAAC,CAAC;IAC3B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,CAAC,CAAC;IACT,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED;;;GAGG;AACH,wBAAsB,mBAAmB,CACvC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,OAAO,GAAE,YAAiB,GACzB,OAAO,CAAC,IAAI,CAAC,CAiBf;AAED;;GAEG;AACH,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAgCxB;AAED;;GAEG;AACH,wBAAsB,UAAU,CAC9B,QAAQ,EAAE,MAAM,EAChB,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,MAAM,CAAC,CA4BjB;AAED;;GAEG;AACH,wBAAsB,iBAAiB,CACrC,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,IAAI,CAAC,CAcf;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,gBAAgB,EAAE,MAAM,EACxB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,EAAE,CAoBV;AAED;;GAEG;AACH,wBAAgB,cAAc,CAC5B,gBAAgB,EAAE,MAAM,EACxB,SAAS,GAAE,MAAU,EACrB,SAAS,CAAC,EAAE,MAAM,GACjB,MAAM,CAqBR;AAED;;GAEG;AACH,wBAAsB,WAAW,CAC/B,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,MAAc,GACtB,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,CAoB9B;AAED;;GAEG;AACH,wBAAsB,QAAQ,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAKjE"}
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Atomic file operations for safe concurrent access
|
|
4
|
+
* Prevents race conditions when multiple processes access the same file
|
|
5
|
+
*/
|
|
6
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
7
|
+
if (k2 === undefined) k2 = k;
|
|
8
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
9
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
10
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(o, k2, desc);
|
|
13
|
+
}) : (function(o, m, k, k2) {
|
|
14
|
+
if (k2 === undefined) k2 = k;
|
|
15
|
+
o[k2] = m[k];
|
|
16
|
+
}));
|
|
17
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
18
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
19
|
+
}) : function(o, v) {
|
|
20
|
+
o["default"] = v;
|
|
21
|
+
});
|
|
22
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
23
|
+
var ownKeys = function(o) {
|
|
24
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
25
|
+
var ar = [];
|
|
26
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
27
|
+
return ar;
|
|
28
|
+
};
|
|
29
|
+
return ownKeys(o);
|
|
30
|
+
};
|
|
31
|
+
return function (mod) {
|
|
32
|
+
if (mod && mod.__esModule) return mod;
|
|
33
|
+
var result = {};
|
|
34
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
35
|
+
__setModuleDefault(result, mod);
|
|
36
|
+
return result;
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
40
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
41
|
+
};
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.writeFileAtomicSafe = writeFileAtomicSafe;
|
|
44
|
+
exports.readFileSafe = readFileSafe;
|
|
45
|
+
exports.backupFile = backupFile;
|
|
46
|
+
exports.restoreFromBackup = restoreFromBackup;
|
|
47
|
+
exports.listBackups = listBackups;
|
|
48
|
+
exports.cleanupBackups = cleanupBackups;
|
|
49
|
+
exports.acquireLock = acquireLock;
|
|
50
|
+
exports.isLocked = isLocked;
|
|
51
|
+
const fs = __importStar(require("fs"));
|
|
52
|
+
const path = __importStar(require("path"));
|
|
53
|
+
const os = __importStar(require("os"));
|
|
54
|
+
const write_file_atomic_1 = __importDefault(require("write-file-atomic"));
|
|
55
|
+
const lockfile = __importStar(require("proper-lockfile"));
|
|
56
|
+
/**
|
|
57
|
+
* Write file atomically using temp file + rename pattern
|
|
58
|
+
* This ensures the file is never in a partial/corrupt state
|
|
59
|
+
*/
|
|
60
|
+
async function writeFileAtomicSafe(filePath, data, options = {}) {
|
|
61
|
+
const { backup = false, lockTimeout = 10000 } = options;
|
|
62
|
+
const content = typeof data === 'string' ? data : JSON.stringify(data, null, 2);
|
|
63
|
+
// Ensure directory exists
|
|
64
|
+
const dir = path.dirname(filePath);
|
|
65
|
+
if (!fs.existsSync(dir)) {
|
|
66
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
67
|
+
}
|
|
68
|
+
// Create backup if requested and file exists
|
|
69
|
+
if (backup && fs.existsSync(filePath)) {
|
|
70
|
+
await backupFile(filePath);
|
|
71
|
+
}
|
|
72
|
+
// Use write-file-atomic for safe writing
|
|
73
|
+
await (0, write_file_atomic_1.default)(filePath, content, { encoding: 'utf8' });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Read file safely with JSON validation
|
|
77
|
+
*/
|
|
78
|
+
async function readFileSafe(filePath) {
|
|
79
|
+
try {
|
|
80
|
+
if (!fs.existsSync(filePath)) {
|
|
81
|
+
return { success: false, error: 'File does not exist' };
|
|
82
|
+
}
|
|
83
|
+
const content = fs.readFileSync(filePath, 'utf8');
|
|
84
|
+
// Try to parse as JSON
|
|
85
|
+
try {
|
|
86
|
+
const data = JSON.parse(content);
|
|
87
|
+
return { success: true, data };
|
|
88
|
+
}
|
|
89
|
+
catch (parseError) {
|
|
90
|
+
// Check if it's a corruption pattern (two JSON objects concatenated)
|
|
91
|
+
if (content.includes('}{')) {
|
|
92
|
+
return {
|
|
93
|
+
success: false,
|
|
94
|
+
error: 'JSON parse error - corruption detected',
|
|
95
|
+
corrupted: true,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
return {
|
|
99
|
+
success: false,
|
|
100
|
+
error: `JSON parse error: ${parseError.message}`,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
return {
|
|
106
|
+
success: false,
|
|
107
|
+
error: `Read error: ${error.message}`,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Create a backup of a file
|
|
113
|
+
*/
|
|
114
|
+
async function backupFile(filePath, backupDir) {
|
|
115
|
+
if (!fs.existsSync(filePath)) {
|
|
116
|
+
throw new Error(`File does not exist: ${filePath}`);
|
|
117
|
+
}
|
|
118
|
+
// Default backup directory
|
|
119
|
+
const defaultBackupDir = path.join(os.homedir(), '.claude-chrome-parallel', 'backups');
|
|
120
|
+
const targetDir = backupDir || defaultBackupDir;
|
|
121
|
+
// Ensure backup directory exists
|
|
122
|
+
if (!fs.existsSync(targetDir)) {
|
|
123
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
124
|
+
}
|
|
125
|
+
// Generate backup filename with timestamp
|
|
126
|
+
const basename = path.basename(filePath);
|
|
127
|
+
const timestamp = new Date().toISOString().replace(/[:.]/g, '-');
|
|
128
|
+
const backupName = `${basename}.${timestamp}.bak`;
|
|
129
|
+
const backupPath = path.join(targetDir, backupName);
|
|
130
|
+
// Copy file to backup location
|
|
131
|
+
fs.copyFileSync(filePath, backupPath);
|
|
132
|
+
return backupPath;
|
|
133
|
+
}
|
|
134
|
+
/**
|
|
135
|
+
* Restore a file from backup
|
|
136
|
+
*/
|
|
137
|
+
async function restoreFromBackup(backupPath, targetPath) {
|
|
138
|
+
if (!fs.existsSync(backupPath)) {
|
|
139
|
+
throw new Error(`Backup file does not exist: ${backupPath}`);
|
|
140
|
+
}
|
|
141
|
+
// Ensure target directory exists
|
|
142
|
+
const targetDir = path.dirname(targetPath);
|
|
143
|
+
if (!fs.existsSync(targetDir)) {
|
|
144
|
+
fs.mkdirSync(targetDir, { recursive: true });
|
|
145
|
+
}
|
|
146
|
+
// Use atomic write to restore
|
|
147
|
+
const content = fs.readFileSync(backupPath, 'utf8');
|
|
148
|
+
await writeFileAtomicSafe(targetPath, content);
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get list of available backups for a file
|
|
152
|
+
*/
|
|
153
|
+
function listBackups(originalFilename, backupDir) {
|
|
154
|
+
const defaultBackupDir = path.join(os.homedir(), '.claude-chrome-parallel', 'backups');
|
|
155
|
+
const targetDir = backupDir || defaultBackupDir;
|
|
156
|
+
if (!fs.existsSync(targetDir)) {
|
|
157
|
+
return [];
|
|
158
|
+
}
|
|
159
|
+
const basename = path.basename(originalFilename);
|
|
160
|
+
const pattern = new RegExp(`^${basename.replace('.', '\\.')}\\..*\\.bak$`);
|
|
161
|
+
return fs
|
|
162
|
+
.readdirSync(targetDir)
|
|
163
|
+
.filter((file) => pattern.test(file))
|
|
164
|
+
.sort()
|
|
165
|
+
.reverse(); // Most recent first
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Clean up old backups, keeping only the specified number
|
|
169
|
+
*/
|
|
170
|
+
function cleanupBackups(originalFilename, keepCount = 5, backupDir) {
|
|
171
|
+
const backups = listBackups(originalFilename, backupDir);
|
|
172
|
+
const toDelete = backups.slice(keepCount);
|
|
173
|
+
const defaultBackupDir = path.join(os.homedir(), '.claude-chrome-parallel', 'backups');
|
|
174
|
+
const targetDir = backupDir || defaultBackupDir;
|
|
175
|
+
for (const backup of toDelete) {
|
|
176
|
+
const backupPath = path.join(targetDir, backup);
|
|
177
|
+
try {
|
|
178
|
+
fs.unlinkSync(backupPath);
|
|
179
|
+
}
|
|
180
|
+
catch {
|
|
181
|
+
// Ignore deletion errors
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
return toDelete.length;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Acquire a file lock with timeout
|
|
188
|
+
*/
|
|
189
|
+
async function acquireLock(filePath, timeout = 10000) {
|
|
190
|
+
// Ensure file exists for locking
|
|
191
|
+
const dir = path.dirname(filePath);
|
|
192
|
+
if (!fs.existsSync(dir)) {
|
|
193
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
194
|
+
}
|
|
195
|
+
if (!fs.existsSync(filePath)) {
|
|
196
|
+
fs.writeFileSync(filePath, '{}');
|
|
197
|
+
}
|
|
198
|
+
const release = await lockfile.lock(filePath, {
|
|
199
|
+
retries: {
|
|
200
|
+
retries: Math.ceil(timeout / 100),
|
|
201
|
+
factor: 1,
|
|
202
|
+
minTimeout: 100,
|
|
203
|
+
maxTimeout: 100,
|
|
204
|
+
},
|
|
205
|
+
});
|
|
206
|
+
return release;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Check if a file is currently locked
|
|
210
|
+
*/
|
|
211
|
+
async function isLocked(filePath) {
|
|
212
|
+
if (!fs.existsSync(filePath)) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
return lockfile.check(filePath);
|
|
216
|
+
}
|
|
217
|
+
//# sourceMappingURL=atomic-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"atomic-file.js","sourceRoot":"","sources":["../../src/utils/atomic-file.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BH,kDAqBC;AAKD,oCAkCC;AAKD,gCA+BC;AAKD,8CAiBC;AAKD,kCAuBC;AAKD,wCAyBC;AAKD,kCAuBC;AAKD,4BAKC;AA9OD,uCAAyB;AACzB,2CAA6B;AAC7B,uCAAyB;AACzB,0EAAgD;AAChD,0DAA4C;AAgB5C;;;GAGG;AACI,KAAK,UAAU,mBAAmB,CACvC,QAAgB,EAChB,IAAqB,EACrB,UAAwB,EAAE;IAE1B,MAAM,EAAE,MAAM,GAAG,KAAK,EAAE,WAAW,GAAG,KAAK,EAAE,GAAG,OAAO,CAAC;IACxD,MA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AAE,IAAI,EAAE,CAAC,CAAC;IACzC,CAAC;IACD,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,EAAE,CAAC,aAAa,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;IACnC,CAAC;IAED,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE;QAC5C,OAAO,EAAE;YACP,OAAO,EAAE,IAAI,CAAC,IAAI,CAAC,OAAO,GAAG,GAAG,CAAC;YACjC,MAAM,EAAE,CAAC;YACT,UAAU,EAAE,GAAG;YACf,UAAU,EAAE,GAAG;SAChB;KACF,CAAC,CAAC;IAEH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED;;GAEG;AACI,KAAK,UAAU,QAAQ,CAAC,QAAgB;IAC7C,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC7B,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Utility exports
|
|
4
|
+
*/
|
|
5
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
10
|
+
}
|
|
11
|
+
Object.defineProperty(o, k2, desc);
|
|
12
|
+
}) : (function(o, m, k, k2) {
|
|
13
|
+
if (k2 === undefined) k2 = k;
|
|
14
|
+
o[k2] = m[k];
|
|
15
|
+
}));
|
|
16
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
17
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
18
|
+
};
|
|
19
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
+
__exportStar(require("./atomic-file"), exports);
|
|
21
|
+
__exportStar(require("./json-validator"), exports);
|
|
22
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;AAEH,gDAA8B;AAC9B,mDAAiC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* JSON validation and corruption detection utilities
|
|
3
|
+
* Detects and attempts to recover from common JSON corruption patterns
|
|
4
|
+
*/
|
|
5
|
+
export interface ValidationResult {
|
|
6
|
+
valid: boolean;
|
|
7
|
+
error?: string;
|
|
8
|
+
corrupted?: boolean;
|
|
9
|
+
corruptionType?: 'concatenated' | 'truncated' | 'invalid' | 'empty';
|
|
10
|
+
}
|
|
11
|
+
export interface RecoveryResult {
|
|
12
|
+
success: boolean;
|
|
13
|
+
data?: unknown;
|
|
14
|
+
method?: string;
|
|
15
|
+
error?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Check if a string is valid JSON
|
|
19
|
+
*/
|
|
20
|
+
export declare function isValidJson(content: string): boolean;
|
|
21
|
+
/**
|
|
22
|
+
* Detect corruption in JSON content
|
|
23
|
+
* Identifies common corruption patterns from race conditions
|
|
24
|
+
*/
|
|
25
|
+
export declare function detectCorruption(content: string): ValidationResult;
|
|
26
|
+
/**
|
|
27
|
+
* Extract valid JSON from corrupted content
|
|
28
|
+
* Attempts various recovery strategies
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractValidJson(content: string): RecoveryResult;
|
|
31
|
+
/**
|
|
32
|
+
* Merge two JSON objects, preferring values from the second
|
|
33
|
+
* Useful for recovering from partial writes
|
|
34
|
+
*/
|
|
35
|
+
export declare function mergeJsonObjects(obj1: Record<string, unknown>, obj2: Record<string, unknown>): Record<string, unknown>;
|
|
36
|
+
/**
|
|
37
|
+
* Validate .claude.json specific structure
|
|
38
|
+
*/
|
|
39
|
+
export declare function validateClaudeConfig(content: unknown): ValidationResult;
|
|
40
|
+
//# sourceMappingURL=json-validator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"json-validator.d.ts","sourceRoot":"","sources":["../../src/utils/json-validator.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,EAAE,OAAO,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,cAAc,CAAC,EAAE,cAAc,GAAG,WAAW,GAAG,SAAS,GAAG,OAAO,CAAC;CACrE;AAED,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,OAAO,CAAC;IACjB,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAOpD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CA0DlE;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,MAAM,GAAG,cAAc,CA4DhE;AA8HD;;;GAGG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAC7B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAuBzB;AAED;;GAEG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,gBAAgB,CA2BvE"}
|