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,438 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* State Manager - Manages orchestration state for Chrome-Sisyphus
|
|
4
|
+
* Provides file-based scratchpad management for workers
|
|
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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
40
|
+
exports.OrchestrationStateManager = void 0;
|
|
41
|
+
exports.getOrchestrationStateManager = getOrchestrationStateManager;
|
|
42
|
+
const fsp = __importStar(require("fs/promises"));
|
|
43
|
+
const path = __importStar(require("path"));
|
|
44
|
+
// Constants for safety limits
|
|
45
|
+
const MAX_PROGRESS_LOG_ENTRIES = 500;
|
|
46
|
+
const MAX_WORKER_NAME_LENGTH = 100;
|
|
47
|
+
// Pattern for valid worker names (alphanumeric, dashes, underscores, and common unicode)
|
|
48
|
+
// Note: This is a simplified pattern that allows common characters without ES6 unicode regex
|
|
49
|
+
const VALID_WORKER_NAME_PATTERN = /^[a-zA-Z0-9_\-\u3131-\uD79D\u4E00-\u9FFF\u0400-\u04FF\u0600-\u06FF]+$/;
|
|
50
|
+
/**
|
|
51
|
+
* Validate worker name for security and safety
|
|
52
|
+
* Prevents path traversal and other injection attacks
|
|
53
|
+
*/
|
|
54
|
+
function validateWorkerName(workerName) {
|
|
55
|
+
if (!workerName || typeof workerName !== 'string') {
|
|
56
|
+
return { valid: false, error: 'Worker name must be a non-empty string' };
|
|
57
|
+
}
|
|
58
|
+
if (workerName.length > MAX_WORKER_NAME_LENGTH) {
|
|
59
|
+
return { valid: false, error: `Worker name exceeds maximum length of ${MAX_WORKER_NAME_LENGTH}` };
|
|
60
|
+
}
|
|
61
|
+
// Check for path traversal patterns
|
|
62
|
+
if (workerName.includes('..') || workerName.includes('/') || workerName.includes('\\')) {
|
|
63
|
+
return { valid: false, error: 'Worker name contains invalid path characters' };
|
|
64
|
+
}
|
|
65
|
+
// Check for null bytes and control characters
|
|
66
|
+
if (/[\x00-\x1f]/.test(workerName)) {
|
|
67
|
+
return { valid: false, error: 'Worker name contains control characters' };
|
|
68
|
+
}
|
|
69
|
+
// Validate against allowed pattern
|
|
70
|
+
if (!VALID_WORKER_NAME_PATTERN.test(workerName)) {
|
|
71
|
+
return { valid: false, error: 'Worker name contains invalid characters' };
|
|
72
|
+
}
|
|
73
|
+
return { valid: true };
|
|
74
|
+
}
|
|
75
|
+
class OrchestrationStateManager {
|
|
76
|
+
baseDir;
|
|
77
|
+
constructor(baseDir = '.agent/chrome-sisyphus') {
|
|
78
|
+
this.baseDir = baseDir;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Ensure the orchestration directory exists
|
|
82
|
+
*/
|
|
83
|
+
async ensureDirectory() {
|
|
84
|
+
const fullPath = path.resolve(this.baseDir);
|
|
85
|
+
await fsp.mkdir(fullPath, { recursive: true });
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Initialize orchestration state
|
|
89
|
+
*/
|
|
90
|
+
async initOrchestration(orchestrationId, task, workers) {
|
|
91
|
+
await this.ensureDirectory();
|
|
92
|
+
const state = {
|
|
93
|
+
orchestrationId,
|
|
94
|
+
status: 'INIT',
|
|
95
|
+
createdAt: Date.now(),
|
|
96
|
+
updatedAt: Date.now(),
|
|
97
|
+
task,
|
|
98
|
+
workers: workers.map(w => ({
|
|
99
|
+
workerId: w.workerId,
|
|
100
|
+
workerName: w.workerName,
|
|
101
|
+
status: 'INIT',
|
|
102
|
+
})),
|
|
103
|
+
completedWorkers: 0,
|
|
104
|
+
failedWorkers: 0,
|
|
105
|
+
};
|
|
106
|
+
// Initialize worker scratchpads
|
|
107
|
+
for (const worker of workers) {
|
|
108
|
+
await this.initWorkerState(worker.workerId, worker.workerName, worker.tabId, worker.task);
|
|
109
|
+
}
|
|
110
|
+
// Write orchestration state
|
|
111
|
+
await this.writeOrchestrationState(state);
|
|
112
|
+
return state;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Initialize worker scratchpad
|
|
116
|
+
*/
|
|
117
|
+
async initWorkerState(workerId, workerName, tabId, task) {
|
|
118
|
+
// Validate worker name for security
|
|
119
|
+
const validation = validateWorkerName(workerName);
|
|
120
|
+
if (!validation.valid) {
|
|
121
|
+
console.error(`[StateManager] Invalid worker name "${workerName}": ${validation.error}`);
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
await this.ensureDirectory();
|
|
125
|
+
const state = {
|
|
126
|
+
workerId,
|
|
127
|
+
workerName,
|
|
128
|
+
tabId,
|
|
129
|
+
status: 'INIT',
|
|
130
|
+
iteration: 0,
|
|
131
|
+
maxIterations: 5,
|
|
132
|
+
startedAt: Date.now(),
|
|
133
|
+
lastUpdatedAt: Date.now(),
|
|
134
|
+
task,
|
|
135
|
+
progressLog: [],
|
|
136
|
+
extractedData: null,
|
|
137
|
+
errors: [],
|
|
138
|
+
};
|
|
139
|
+
await this.writeWorkerState(workerName, state);
|
|
140
|
+
return state;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Update worker state
|
|
144
|
+
*/
|
|
145
|
+
async updateWorkerState(workerName, update) {
|
|
146
|
+
// Validate worker name before updating
|
|
147
|
+
const validation = validateWorkerName(workerName);
|
|
148
|
+
if (!validation.valid) {
|
|
149
|
+
console.error(`[StateManager] Cannot update worker state: invalid name "${workerName}": ${validation.error}`);
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
const current = await this.readWorkerState(workerName);
|
|
153
|
+
if (!current) {
|
|
154
|
+
console.error(`[StateManager] Cannot update worker state: worker "${workerName}" not found`);
|
|
155
|
+
return null;
|
|
156
|
+
}
|
|
157
|
+
const updated = {
|
|
158
|
+
...current,
|
|
159
|
+
...update,
|
|
160
|
+
lastUpdatedAt: Date.now(),
|
|
161
|
+
};
|
|
162
|
+
await this.writeWorkerState(workerName, updated);
|
|
163
|
+
return updated;
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Add progress entry
|
|
167
|
+
* Note: Progress log is limited to MAX_PROGRESS_LOG_ENTRIES to prevent unbounded growth
|
|
168
|
+
*/
|
|
169
|
+
async addProgressEntry(workerName, action, result, error) {
|
|
170
|
+
const current = await this.readWorkerState(workerName);
|
|
171
|
+
if (!current) {
|
|
172
|
+
console.error(`[StateManager] Cannot add progress entry: worker "${workerName}" not found`);
|
|
173
|
+
return;
|
|
174
|
+
}
|
|
175
|
+
const entry = {
|
|
176
|
+
iteration: current.iteration,
|
|
177
|
+
timestamp: new Date().toISOString(),
|
|
178
|
+
action,
|
|
179
|
+
result,
|
|
180
|
+
error,
|
|
181
|
+
};
|
|
182
|
+
current.progressLog.push(entry);
|
|
183
|
+
// Limit progress log size to prevent unbounded growth
|
|
184
|
+
if (current.progressLog.length > MAX_PROGRESS_LOG_ENTRIES) {
|
|
185
|
+
// Keep the most recent entries, remove oldest
|
|
186
|
+
const removed = current.progressLog.length - MAX_PROGRESS_LOG_ENTRIES;
|
|
187
|
+
current.progressLog = current.progressLog.slice(removed);
|
|
188
|
+
console.error(`[StateManager] Progress log truncated for worker "${workerName}": removed ${removed} oldest entries`);
|
|
189
|
+
}
|
|
190
|
+
current.lastUpdatedAt = Date.now();
|
|
191
|
+
await this.writeWorkerState(workerName, current);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Read worker state from scratchpad
|
|
195
|
+
*/
|
|
196
|
+
async readWorkerState(workerName) {
|
|
197
|
+
// Validate worker name before reading
|
|
198
|
+
const validation = validateWorkerName(workerName);
|
|
199
|
+
if (!validation.valid) {
|
|
200
|
+
console.error(`[StateManager] Cannot read worker state: invalid name "${workerName}": ${validation.error}`);
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
const filePath = this.getWorkerPath(workerName);
|
|
204
|
+
try {
|
|
205
|
+
const content = await fsp.readFile(filePath, 'utf-8');
|
|
206
|
+
// Try to parse JSON from markdown code block
|
|
207
|
+
// Note: There may be multiple JSON blocks (extracted data + raw state)
|
|
208
|
+
// We need the last one which contains the full state object
|
|
209
|
+
const regex = /```json\n([\s\S]*?)\n```/g;
|
|
210
|
+
let lastMatch = null;
|
|
211
|
+
let match;
|
|
212
|
+
while ((match = regex.exec(content)) !== null) {
|
|
213
|
+
lastMatch = match;
|
|
214
|
+
}
|
|
215
|
+
if (lastMatch) {
|
|
216
|
+
// Get the last match (raw state)
|
|
217
|
+
return JSON.parse(lastMatch[1]);
|
|
218
|
+
}
|
|
219
|
+
// Fallback: try parsing entire file as JSON
|
|
220
|
+
return JSON.parse(content);
|
|
221
|
+
}
|
|
222
|
+
catch (error) {
|
|
223
|
+
console.error(`[StateManager] Failed to parse worker state for "${workerName}": ${error instanceof Error ? error.message : String(error)}`);
|
|
224
|
+
return null;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Write worker state to scratchpad (markdown format)
|
|
229
|
+
*/
|
|
230
|
+
async writeWorkerState(workerName, state) {
|
|
231
|
+
// Validate worker name before writing
|
|
232
|
+
const validation = validateWorkerName(workerName);
|
|
233
|
+
if (!validation.valid) {
|
|
234
|
+
console.error(`[StateManager] Cannot write worker state: invalid name "${workerName}": ${validation.error}`);
|
|
235
|
+
return;
|
|
236
|
+
}
|
|
237
|
+
const filePath = this.getWorkerPath(workerName);
|
|
238
|
+
try {
|
|
239
|
+
const markdown = this.formatWorkerMarkdown(state);
|
|
240
|
+
await fsp.writeFile(filePath, markdown, 'utf-8');
|
|
241
|
+
}
|
|
242
|
+
catch (error) {
|
|
243
|
+
console.error(`[StateManager] Failed to write worker state for "${workerName}": ${error instanceof Error ? error.message : String(error)}`);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
/**
|
|
247
|
+
* Format worker state as markdown
|
|
248
|
+
*/
|
|
249
|
+
formatWorkerMarkdown(state) {
|
|
250
|
+
const progressRows = state.progressLog.map(p => {
|
|
251
|
+
const time = p.timestamp.split('T')[1]?.split('.')[0] || p.timestamp;
|
|
252
|
+
const error = p.error || '-';
|
|
253
|
+
return `| ${p.iteration} | ${time} | ${p.action} | ${p.result} | ${error} |`;
|
|
254
|
+
});
|
|
255
|
+
const progressTable = progressRows.length > 0
|
|
256
|
+
? progressRows.join('\n')
|
|
257
|
+
: '| - | - | - | - | - |';
|
|
258
|
+
const errorList = state.errors.length > 0
|
|
259
|
+
? state.errors.map(e => `- ${e}`).join('\n')
|
|
260
|
+
: '(none)';
|
|
261
|
+
const lastUpdated = new Date(state.lastUpdatedAt).toISOString();
|
|
262
|
+
const extractedJson = JSON.stringify(state.extractedData, null, 2);
|
|
263
|
+
const stateJson = JSON.stringify(state, null, 2);
|
|
264
|
+
return `## Worker: ${state.workerName}
|
|
265
|
+
### Last Updated: ${lastUpdated}
|
|
266
|
+
|
|
267
|
+
### Meta
|
|
268
|
+
- Worker ID: ${state.workerId}
|
|
269
|
+
- Tab ID: ${state.tabId}
|
|
270
|
+
- Status: ${state.status}
|
|
271
|
+
- Iteration: ${state.iteration}/${state.maxIterations}
|
|
272
|
+
|
|
273
|
+
### Task
|
|
274
|
+
${state.task}
|
|
275
|
+
|
|
276
|
+
### Progress Log
|
|
277
|
+
| Iter | Time | Action | Result | Error |
|
|
278
|
+
|------|------|--------|--------|-------|
|
|
279
|
+
${progressTable}
|
|
280
|
+
|
|
281
|
+
### Extracted Data
|
|
282
|
+
\`\`\`json
|
|
283
|
+
${extractedJson}
|
|
284
|
+
\`\`\`
|
|
285
|
+
|
|
286
|
+
### Errors
|
|
287
|
+
${errorList}
|
|
288
|
+
|
|
289
|
+
---
|
|
290
|
+
<!-- Raw State (for parsing) -->
|
|
291
|
+
\`\`\`json
|
|
292
|
+
${stateJson}
|
|
293
|
+
\`\`\`
|
|
294
|
+
`;
|
|
295
|
+
}
|
|
296
|
+
/**
|
|
297
|
+
* Read orchestration state from file.
|
|
298
|
+
*
|
|
299
|
+
* NOTE: As of the race-condition fix, WorkflowEngine maintains in-memory state as the
|
|
300
|
+
* authoritative source of truth for completion counting. File reads/writes here are
|
|
301
|
+
* write-behind (persistence and debugging only) — they are NOT used for correctness by
|
|
302
|
+
* WorkflowEngine.completeWorker(). Use WorkflowEngine.getOrchestrationStatus() to get
|
|
303
|
+
* the most current state.
|
|
304
|
+
*/
|
|
305
|
+
async readOrchestrationState() {
|
|
306
|
+
const filePath = this.getOrchestrationPath();
|
|
307
|
+
try {
|
|
308
|
+
const content = await fsp.readFile(filePath, 'utf-8');
|
|
309
|
+
// Get the last JSON code block (the raw state)
|
|
310
|
+
const regex = /```json\n([\s\S]*?)\n```/g;
|
|
311
|
+
let lastMatch = null;
|
|
312
|
+
let match;
|
|
313
|
+
while ((match = regex.exec(content)) !== null) {
|
|
314
|
+
lastMatch = match;
|
|
315
|
+
}
|
|
316
|
+
if (lastMatch) {
|
|
317
|
+
return JSON.parse(lastMatch[1]);
|
|
318
|
+
}
|
|
319
|
+
return JSON.parse(content);
|
|
320
|
+
}
|
|
321
|
+
catch (error) {
|
|
322
|
+
console.error(`[StateManager] Failed to parse orchestration state: ${error instanceof Error ? error.message : String(error)}`);
|
|
323
|
+
return null;
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
/**
|
|
327
|
+
* Write orchestration state to file (write-behind).
|
|
328
|
+
*
|
|
329
|
+
* NOTE: This write is for persistence and debugging visibility only.
|
|
330
|
+
* WorkflowEngine holds the authoritative in-memory state — correctness does NOT
|
|
331
|
+
* depend on this file being up-to-date.
|
|
332
|
+
*/
|
|
333
|
+
async writeOrchestrationState(state) {
|
|
334
|
+
const filePath = this.getOrchestrationPath();
|
|
335
|
+
const markdown = this.formatOrchestrationMarkdown(state);
|
|
336
|
+
await fsp.writeFile(filePath, markdown, 'utf-8');
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Update orchestration state
|
|
340
|
+
*/
|
|
341
|
+
async updateOrchestrationState(update) {
|
|
342
|
+
const current = await this.readOrchestrationState();
|
|
343
|
+
if (!current)
|
|
344
|
+
return null;
|
|
345
|
+
const updated = {
|
|
346
|
+
...current,
|
|
347
|
+
...update,
|
|
348
|
+
updatedAt: Date.now(),
|
|
349
|
+
};
|
|
350
|
+
await this.writeOrchestrationState(updated);
|
|
351
|
+
return updated;
|
|
352
|
+
}
|
|
353
|
+
/**
|
|
354
|
+
* Format orchestration state as markdown
|
|
355
|
+
*/
|
|
356
|
+
formatOrchestrationMarkdown(state) {
|
|
357
|
+
const workerLines = state.workers.map(w => {
|
|
358
|
+
let icon = '⏳';
|
|
359
|
+
if (w.status === 'SUCCESS')
|
|
360
|
+
icon = '✅';
|
|
361
|
+
else if (w.status === 'FAIL')
|
|
362
|
+
icon = '❌';
|
|
363
|
+
const summary = w.resultSummary ? ` - ${w.resultSummary}` : '';
|
|
364
|
+
return `- ${icon} ${w.workerName}: ${w.status}${summary}`;
|
|
365
|
+
});
|
|
366
|
+
const workerList = workerLines.join('\n');
|
|
367
|
+
const lastUpdated = new Date(state.updatedAt).toISOString();
|
|
368
|
+
const stateJson = JSON.stringify(state, null, 2);
|
|
369
|
+
return `## Chrome-Sisyphus Orchestration
|
|
370
|
+
### Last Updated: ${lastUpdated}
|
|
371
|
+
|
|
372
|
+
### Status: ${state.status}
|
|
373
|
+
|
|
374
|
+
### Task
|
|
375
|
+
${state.task}
|
|
376
|
+
|
|
377
|
+
### Workers (${state.completedWorkers}/${state.workers.length} complete, ${state.failedWorkers} failed)
|
|
378
|
+
${workerList}
|
|
379
|
+
|
|
380
|
+
---
|
|
381
|
+
<!-- Raw State (for parsing) -->
|
|
382
|
+
\`\`\`json
|
|
383
|
+
${stateJson}
|
|
384
|
+
\`\`\`
|
|
385
|
+
`;
|
|
386
|
+
}
|
|
387
|
+
/**
|
|
388
|
+
* Get all worker states
|
|
389
|
+
*/
|
|
390
|
+
async getAllWorkerStates() {
|
|
391
|
+
const states = [];
|
|
392
|
+
const orch = await this.readOrchestrationState();
|
|
393
|
+
if (orch) {
|
|
394
|
+
for (const worker of orch.workers) {
|
|
395
|
+
const state = await this.readWorkerState(worker.workerName);
|
|
396
|
+
if (state) {
|
|
397
|
+
states.push(state);
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
return states;
|
|
402
|
+
}
|
|
403
|
+
/**
|
|
404
|
+
* Get worker scratchpad path
|
|
405
|
+
*/
|
|
406
|
+
getWorkerPath(workerName) {
|
|
407
|
+
return path.resolve(this.baseDir, `worker-${workerName}.md`);
|
|
408
|
+
}
|
|
409
|
+
/**
|
|
410
|
+
* Get orchestration state path
|
|
411
|
+
*/
|
|
412
|
+
getOrchestrationPath() {
|
|
413
|
+
return path.resolve(this.baseDir, 'orchestration.md');
|
|
414
|
+
}
|
|
415
|
+
/**
|
|
416
|
+
* Clean up orchestration files
|
|
417
|
+
*/
|
|
418
|
+
async cleanup() {
|
|
419
|
+
const fullPath = path.resolve(this.baseDir);
|
|
420
|
+
try {
|
|
421
|
+
const files = await fsp.readdir(fullPath);
|
|
422
|
+
await Promise.all(files.map(file => fsp.unlink(path.join(fullPath, file))));
|
|
423
|
+
}
|
|
424
|
+
catch {
|
|
425
|
+
// Directory may not exist
|
|
426
|
+
}
|
|
427
|
+
}
|
|
428
|
+
}
|
|
429
|
+
exports.OrchestrationStateManager = OrchestrationStateManager;
|
|
430
|
+
// Singleton instance
|
|
431
|
+
let stateManagerInstance = null;
|
|
432
|
+
function getOrchestrationStateManager(baseDir) {
|
|
433
|
+
if (!stateManagerInstance) {
|
|
434
|
+
stateManagerInstance = new OrchestrationStateManager(baseDir);
|
|
435
|
+
}
|
|
436
|
+
return stateManagerInstance;
|
|
437
|
+
}
|
|
438
|
+
//# sourceMappingURL=state-manager.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state-manager.js","sourceRoot":"","sources":["../../src/orchestration/state-manager.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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|
1
|
+
/**
|
|
2
|
+
* Workflow Engine - Executes parallel browser workflows
|
|
3
|
+
* Manages worker lifecycle and result aggregation
|
|
4
|
+
*/
|
|
5
|
+
import { OrchestrationState, WorkerState } from './state-manager';
|
|
6
|
+
import { ToolEntry } from '../types/tool-manifest';
|
|
7
|
+
export interface WorkflowStep {
|
|
8
|
+
workerId: string;
|
|
9
|
+
workerName: string;
|
|
10
|
+
url: string;
|
|
11
|
+
task: string;
|
|
12
|
+
successCriteria: string;
|
|
13
|
+
shareCookies?: boolean;
|
|
14
|
+
}
|
|
15
|
+
export interface WorkflowDefinition {
|
|
16
|
+
id: string;
|
|
17
|
+
name: string;
|
|
18
|
+
steps: WorkflowStep[];
|
|
19
|
+
parallel: boolean;
|
|
20
|
+
maxRetries: number;
|
|
21
|
+
timeout: number;
|
|
22
|
+
/** Maximum consecutive stale updates before circuit breaker triggers (default: 5) */
|
|
23
|
+
maxStaleIterations?: number;
|
|
24
|
+
/** Maximum total workflow execution time in ms (default: 300000) */
|
|
25
|
+
globalTimeoutMs?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface WorkerResult {
|
|
28
|
+
workerId: string;
|
|
29
|
+
workerName: string;
|
|
30
|
+
tabId: string;
|
|
31
|
+
status: 'SUCCESS' | 'PARTIAL' | 'FAIL';
|
|
32
|
+
resultSummary: string;
|
|
33
|
+
dataExtracted: unknown;
|
|
34
|
+
iterations: number;
|
|
35
|
+
errors: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface WorkflowResult {
|
|
38
|
+
orchestrationId: string;
|
|
39
|
+
status: 'COMPLETED' | 'PARTIAL' | 'FAILED';
|
|
40
|
+
workerResults: WorkerResult[];
|
|
41
|
+
completedCount: number;
|
|
42
|
+
failedCount: number;
|
|
43
|
+
duration: number;
|
|
44
|
+
}
|
|
45
|
+
export declare class WorkflowEngine {
|
|
46
|
+
private sessionManager;
|
|
47
|
+
private stateManager;
|
|
48
|
+
/**
|
|
49
|
+
* In-memory workflow state. Keyed by orchestrationId.
|
|
50
|
+
* This is the source of truth for completion tracking — avoids file-based race conditions.
|
|
51
|
+
*/
|
|
52
|
+
private workflowStates;
|
|
53
|
+
/**
|
|
54
|
+
* Per-worker runtime state for timeout and circuit breaker tracking.
|
|
55
|
+
* Keyed by workerName.
|
|
56
|
+
*/
|
|
57
|
+
private workerRuntimeStates;
|
|
58
|
+
/**
|
|
59
|
+
* Timeout handles for worker absolute timeouts. Keyed by workerName.
|
|
60
|
+
*/
|
|
61
|
+
private workerTimeoutHandles;
|
|
62
|
+
/**
|
|
63
|
+
* Global workflow timeout handle. Keyed by orchestrationId.
|
|
64
|
+
*/
|
|
65
|
+
private globalTimeoutHandles;
|
|
66
|
+
/**
|
|
67
|
+
* Promise-based mutex for serializing completeWorker operations.
|
|
68
|
+
* Prevents lost-update races when multiple workers complete simultaneously.
|
|
69
|
+
*/
|
|
70
|
+
private completionLock;
|
|
71
|
+
/**
|
|
72
|
+
* Acquire the completion lock. Returns a release function.
|
|
73
|
+
* All completeWorker calls are serialized through this lock.
|
|
74
|
+
*/
|
|
75
|
+
private acquireLock;
|
|
76
|
+
/**
|
|
77
|
+
* Initialize a new workflow
|
|
78
|
+
* Creates workers, tabs, and scratchpads
|
|
79
|
+
*/
|
|
80
|
+
initWorkflow(sessionId: string, workflow: WorkflowDefinition): Promise<{
|
|
81
|
+
orchestrationId: string;
|
|
82
|
+
workers: Array<{
|
|
83
|
+
workerId: string;
|
|
84
|
+
workerName: string;
|
|
85
|
+
tabId: string;
|
|
86
|
+
}>;
|
|
87
|
+
}>;
|
|
88
|
+
/**
|
|
89
|
+
* Update worker progress with circuit breaker check
|
|
90
|
+
*/
|
|
91
|
+
updateWorkerProgress(workerName: string, update: {
|
|
92
|
+
status?: WorkerState['status'];
|
|
93
|
+
iteration?: number;
|
|
94
|
+
action?: string;
|
|
95
|
+
result?: 'SUCCESS' | 'FAIL' | 'IN_PROGRESS';
|
|
96
|
+
extractedData?: unknown;
|
|
97
|
+
error?: string;
|
|
98
|
+
}): Promise<void>;
|
|
99
|
+
/**
|
|
100
|
+
* Hash extracted data for circuit breaker comparison
|
|
101
|
+
*/
|
|
102
|
+
private hashData;
|
|
103
|
+
/**
|
|
104
|
+
* Force-complete a single worker due to timeout or circuit breaker
|
|
105
|
+
*/
|
|
106
|
+
private forceCompleteWorker;
|
|
107
|
+
/**
|
|
108
|
+
* Force-complete all running workers in a workflow (global timeout)
|
|
109
|
+
*/
|
|
110
|
+
private forceCompleteAllRunningWorkers;
|
|
111
|
+
/**
|
|
112
|
+
* Mark worker as complete.
|
|
113
|
+
*
|
|
114
|
+
* Race-condition safe: all concurrent calls are serialized via a promise-based mutex.
|
|
115
|
+
* In-memory state is the source of truth for completion counting; file writes are
|
|
116
|
+
* write-behind (persistence/debugging only).
|
|
117
|
+
*/
|
|
118
|
+
completeWorker(workerName: string, status: 'SUCCESS' | 'PARTIAL' | 'FAIL', resultSummary: string, extractedData: unknown): Promise<void>;
|
|
119
|
+
/**
|
|
120
|
+
* Write orchestration state to file from in-memory state (write-behind).
|
|
121
|
+
* This is for persistence/debugging only — correctness is maintained in memory.
|
|
122
|
+
*/
|
|
123
|
+
private _writeOrchestrationStateBehind;
|
|
124
|
+
/**
|
|
125
|
+
* Fallback for completeWorker when no in-memory state exists (engine restart scenario).
|
|
126
|
+
* Uses the original file-based read-modify-write approach.
|
|
127
|
+
*/
|
|
128
|
+
private _completeWorkerFileFallback;
|
|
129
|
+
/**
|
|
130
|
+
* Get current orchestration status.
|
|
131
|
+
* Returns in-memory state when available (most current); falls back to file.
|
|
132
|
+
*/
|
|
133
|
+
getOrchestrationStatus(): Promise<OrchestrationState | null>;
|
|
134
|
+
/**
|
|
135
|
+
* Get all worker states
|
|
136
|
+
*/
|
|
137
|
+
getAllWorkerStates(): Promise<WorkerState[]>;
|
|
138
|
+
/**
|
|
139
|
+
* Get worker state by name
|
|
140
|
+
*/
|
|
141
|
+
getWorkerState(workerName: string): Promise<WorkerState | null>;
|
|
142
|
+
/**
|
|
143
|
+
* Collect final results from all workers.
|
|
144
|
+
* Uses in-memory orchestration status for correctness; reads per-worker detail from files.
|
|
145
|
+
*/
|
|
146
|
+
collectResults(): Promise<WorkflowResult | null>;
|
|
147
|
+
/**
|
|
148
|
+
* Cleanup workflow resources
|
|
149
|
+
*/
|
|
150
|
+
cleanupWorkflow(sessionId: string): Promise<void>;
|
|
151
|
+
/**
|
|
152
|
+
* Generate MCP tool documentation from a ToolEntry array.
|
|
153
|
+
* Groups tools by category and formats each tool with its parameters.
|
|
154
|
+
*/
|
|
155
|
+
private generateToolDocs;
|
|
156
|
+
/**
|
|
157
|
+
* Generate worker agent prompt for Background Task
|
|
158
|
+
*/
|
|
159
|
+
generateWorkerPrompt(workerId: string, workerName: string, tabId: string, task: string, successCriteria: string, manifestTools?: ToolEntry[], targetUrl?: string): string;
|
|
160
|
+
}
|
|
161
|
+
export declare function getWorkflowEngine(): WorkflowEngine;
|
|
162
|
+
//# sourceMappingURL=workflow-engine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"workflow-engine.d.ts","sourceRoot":"","sources":["../../src/orchestration/workflow-engine.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAgC,kBAAkB,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEhG,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAGnD,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB;AAED,MAAM,WAAW,kBAAkB;IACjC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,YAAY,EAAE,CAAC;IACtB,QAAQ,EAAE,OAAO,CAAC;IACl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