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,191 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* HintEngine — evaluates rules against tool results to produce proactive hints.
|
|
4
|
+
*
|
|
5
|
+
* Rules are sorted by priority (lower = higher priority) and evaluated first-match-wins.
|
|
6
|
+
* Uses ActivityTracker's recent calls for sequence/pattern detection.
|
|
7
|
+
* Integrates PatternLearner for adaptive error→recovery learning.
|
|
8
|
+
*/
|
|
9
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
12
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
13
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
14
|
+
}
|
|
15
|
+
Object.defineProperty(o, k2, desc);
|
|
16
|
+
}) : (function(o, m, k, k2) {
|
|
17
|
+
if (k2 === undefined) k2 = k;
|
|
18
|
+
o[k2] = m[k];
|
|
19
|
+
}));
|
|
20
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
21
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
22
|
+
}) : function(o, v) {
|
|
23
|
+
o["default"] = v;
|
|
24
|
+
});
|
|
25
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
26
|
+
var ownKeys = function(o) {
|
|
27
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
28
|
+
var ar = [];
|
|
29
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
30
|
+
return ar;
|
|
31
|
+
};
|
|
32
|
+
return ownKeys(o);
|
|
33
|
+
};
|
|
34
|
+
return function (mod) {
|
|
35
|
+
if (mod && mod.__esModule) return mod;
|
|
36
|
+
var result = {};
|
|
37
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
38
|
+
__setModuleDefault(result, mod);
|
|
39
|
+
return result;
|
|
40
|
+
};
|
|
41
|
+
})();
|
|
42
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
+
exports.HintEngine = void 0;
|
|
44
|
+
const fs = __importStar(require("fs"));
|
|
45
|
+
const path = __importStar(require("path"));
|
|
46
|
+
const pattern_learner_1 = require("./pattern-learner");
|
|
47
|
+
const error_recovery_1 = require("./rules/error-recovery");
|
|
48
|
+
const composite_suggestions_1 = require("./rules/composite-suggestions");
|
|
49
|
+
const sequence_detection_1 = require("./rules/sequence-detection");
|
|
50
|
+
const repetition_detection_1 = require("./rules/repetition-detection");
|
|
51
|
+
const learned_rules_1 = require("./rules/learned-rules");
|
|
52
|
+
const success_hints_1 = require("./rules/success-hints");
|
|
53
|
+
class HintEngine {
|
|
54
|
+
rules;
|
|
55
|
+
activityTracker;
|
|
56
|
+
learner;
|
|
57
|
+
logFilePath = null;
|
|
58
|
+
// Buffered async write stream
|
|
59
|
+
logStream = null;
|
|
60
|
+
logBuffer = [];
|
|
61
|
+
flushTimer = null;
|
|
62
|
+
static FLUSH_INTERVAL = 200; // ms
|
|
63
|
+
constructor(activityTracker) {
|
|
64
|
+
this.activityTracker = activityTracker;
|
|
65
|
+
this.learner = new pattern_learner_1.PatternLearner();
|
|
66
|
+
// Collect all rules and sort by priority (ascending = highest priority first)
|
|
67
|
+
// Learned rules (350) sit between repetition (250) and success hints (400)
|
|
68
|
+
this.rules = [
|
|
69
|
+
...error_recovery_1.errorRecoveryRules,
|
|
70
|
+
...composite_suggestions_1.compositeSuggestionRules,
|
|
71
|
+
...sequence_detection_1.sequenceDetectionRules,
|
|
72
|
+
...repetition_detection_1.repetitionDetectionRules,
|
|
73
|
+
...(0, learned_rules_1.createLearnedRules)(this.learner),
|
|
74
|
+
...success_hints_1.successHintRules,
|
|
75
|
+
].sort((a, b) => a.priority - b.priority);
|
|
76
|
+
// Flush remaining buffer on process exit
|
|
77
|
+
process.on('exit', () => {
|
|
78
|
+
this.flushBuffer();
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Enable hit/miss logging to a JSONL file for data collection.
|
|
83
|
+
*/
|
|
84
|
+
enableLogging(dirPath) {
|
|
85
|
+
try {
|
|
86
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
87
|
+
this.logFilePath = path.join(dirPath, `hints-${new Date().toISOString().slice(0, 10)}.jsonl`);
|
|
88
|
+
this.logStream = fs.createWriteStream(this.logFilePath, { flags: 'a' });
|
|
89
|
+
}
|
|
90
|
+
catch {
|
|
91
|
+
// Best-effort logging
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Enable adaptive learning — load existing patterns and persist new ones.
|
|
96
|
+
*/
|
|
97
|
+
enableLearning(dirPath) {
|
|
98
|
+
this.learner.enablePersistence(dirPath);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Evaluate rules and return the first matching hint, or null.
|
|
102
|
+
* Also feeds the learner for adaptive pattern detection.
|
|
103
|
+
*/
|
|
104
|
+
getHint(toolName, result, isError) {
|
|
105
|
+
const resultText = this.extractText(result);
|
|
106
|
+
const recentCalls = this.activityTracker.getRecentCalls(5);
|
|
107
|
+
const ctx = { toolName, resultText, isError, recentCalls };
|
|
108
|
+
let matchedRule = null;
|
|
109
|
+
let hint = null;
|
|
110
|
+
for (const rule of this.rules) {
|
|
111
|
+
const h = rule.match(ctx);
|
|
112
|
+
if (h) {
|
|
113
|
+
matchedRule = rule.name;
|
|
114
|
+
hint = h;
|
|
115
|
+
break;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
// Feed the learner: observe every completion for recovery detection
|
|
119
|
+
this.learner.onToolComplete(toolName, isError);
|
|
120
|
+
// If no rule matched an error, start learning observation
|
|
121
|
+
if (hint === null && isError) {
|
|
122
|
+
this.learner.onMiss(toolName, resultText);
|
|
123
|
+
}
|
|
124
|
+
this.log({ timestamp: Date.now(), toolName, isError, matchedRule, hint });
|
|
125
|
+
return hint;
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Extract text content from an MCPResult for pattern matching.
|
|
129
|
+
*/
|
|
130
|
+
extractText(result) {
|
|
131
|
+
const content = result.content;
|
|
132
|
+
if (!Array.isArray(content))
|
|
133
|
+
return JSON.stringify(result);
|
|
134
|
+
return content
|
|
135
|
+
.filter((c) => c.type === 'text')
|
|
136
|
+
.map((c) => c.text)
|
|
137
|
+
.join('\n');
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Write a log entry via buffered async stream (best-effort, non-blocking).
|
|
141
|
+
*/
|
|
142
|
+
log(entry) {
|
|
143
|
+
if (!this.logStream)
|
|
144
|
+
return;
|
|
145
|
+
this.logBuffer.push(JSON.stringify(entry) + '\n');
|
|
146
|
+
if (!this.flushTimer) {
|
|
147
|
+
this.flushTimer = setTimeout(() => {
|
|
148
|
+
this.flushBuffer();
|
|
149
|
+
}, HintEngine.FLUSH_INTERVAL);
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Flush buffered log entries to the write stream.
|
|
154
|
+
*/
|
|
155
|
+
flushBuffer() {
|
|
156
|
+
if (this.logBuffer.length > 0 && this.logStream) {
|
|
157
|
+
const data = this.logBuffer.join('');
|
|
158
|
+
this.logStream.write(data);
|
|
159
|
+
this.logBuffer = [];
|
|
160
|
+
}
|
|
161
|
+
this.flushTimer = null;
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Flush pending writes and close the log stream. Call on shutdown.
|
|
165
|
+
*/
|
|
166
|
+
destroy() {
|
|
167
|
+
this.flushBuffer();
|
|
168
|
+
if (this.logStream) {
|
|
169
|
+
this.logStream.end();
|
|
170
|
+
this.logStream = null;
|
|
171
|
+
}
|
|
172
|
+
if (this.flushTimer) {
|
|
173
|
+
clearTimeout(this.flushTimer);
|
|
174
|
+
this.flushTimer = null;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get all registered rules (for testing).
|
|
179
|
+
*/
|
|
180
|
+
getRules() {
|
|
181
|
+
return this.rules;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Get the pattern learner (for testing).
|
|
185
|
+
*/
|
|
186
|
+
getLearner() {
|
|
187
|
+
return this.learner;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
exports.HintEngine = HintEngine;
|
|
191
|
+
//# sourceMappingURL=hint-engine.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hint-engine.js","sourceRoot":"","sources":["../../src/hints/hint-engine.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAG7B,uDAAmD;AACnD,2DAA4D;AAC5D,yEAAyE;AACzE,mEAAoE;AACpE,uEAAwE;AACxE,yDAA2D;AAC3D,yDAAyD;AAuBzD,MAAa,UAAU;IACb,KAAK,CAAa;IAClB,eAAe,CAAkB;IACjC,OAAO,CAAiB;IACxB,WAAW,GAAkB,IAAI,CAAC;IAE1C,8BAA8B;IACtB,SAAS,GAA0B,IAAI,CAAC;IACxC,SAAS,GAAa,EAAE,CAAC;IACzB,UAAU,GAA0B,IAAI,CAAC;IACzC,MAAM,CAAU,cAAc,GAAG,GAAG,CAAC,CAAC,KAAK;IAEnD,YAAY,eAAgC;QA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,CAAC,UAAU,CAAC,CAAC;YAC9B,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC;QACzB,CAAC;IACH,CAAC;IAED;;OAEG;IACH,QAAQ;QACN,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;OAEG;IACH,UAAU;QACR,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;;AAzJH,gCA0JC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Hints module — Proactive hint system
|
|
3
|
+
*/
|
|
4
|
+
export { HintEngine } from './hint-engine';
|
|
5
|
+
export type { HintContext, HintRule, HintLogEntry } from './hint-engine';
|
|
6
|
+
export { PatternLearner } from './pattern-learner';
|
|
7
|
+
export type { LearnedPattern } from './pattern-learner';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/hints/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Hints module — Proactive hint system
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.PatternLearner = exports.HintEngine = void 0;
|
|
7
|
+
var hint_engine_1 = require("./hint-engine");
|
|
8
|
+
Object.defineProperty(exports, "HintEngine", { enumerable: true, get: function () { return hint_engine_1.HintEngine; } });
|
|
9
|
+
var pattern_learner_1 = require("./pattern-learner");
|
|
10
|
+
Object.defineProperty(exports, "PatternLearner", { enumerable: true, get: function () { return pattern_learner_1.PatternLearner; } });
|
|
11
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/hints/index.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,6CAA2C;AAAlC,yGAAA,UAAU,OAAA;AAEnB,qDAAmD;AAA1C,iHAAA,cAAc,OAAA"}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PatternLearner — Adaptive memory system that learns error→recovery patterns.
|
|
3
|
+
*
|
|
4
|
+
* Flow:
|
|
5
|
+
* 1. Hint miss on error → start observing next 3 tool calls
|
|
6
|
+
* 2. If a different tool succeeds → record as recovery pattern
|
|
7
|
+
* 3. Same error→recovery seen N times → promote to learned rule
|
|
8
|
+
* 4. Persisted to JSON, survives across sessions
|
|
9
|
+
*/
|
|
10
|
+
export interface LearnedPattern {
|
|
11
|
+
id: string;
|
|
12
|
+
errorFingerprint: string;
|
|
13
|
+
errorTools: string[];
|
|
14
|
+
recoveryTool: string;
|
|
15
|
+
occurrences: number;
|
|
16
|
+
confidence: number;
|
|
17
|
+
firstSeen: number;
|
|
18
|
+
lastSeen: number;
|
|
19
|
+
hint: string;
|
|
20
|
+
}
|
|
21
|
+
export declare class PatternLearner {
|
|
22
|
+
private pending;
|
|
23
|
+
private rawObservations;
|
|
24
|
+
private patterns;
|
|
25
|
+
private filePath;
|
|
26
|
+
private dirty;
|
|
27
|
+
static readonly WATCH_WINDOW = 3;
|
|
28
|
+
static readonly PROMOTE_THRESHOLD = 3;
|
|
29
|
+
static readonly CONFIDENCE_THRESHOLD = 0.6;
|
|
30
|
+
static readonly MAX_PENDING = 10;
|
|
31
|
+
/**
|
|
32
|
+
* Enable persistence — load existing patterns and save new ones.
|
|
33
|
+
*/
|
|
34
|
+
enablePersistence(dirPath: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Called when a hint miss occurs on an error (no static rule matched).
|
|
37
|
+
* Starts observing subsequent calls to detect recovery pattern.
|
|
38
|
+
*/
|
|
39
|
+
onMiss(toolName: string, errorText: string): void;
|
|
40
|
+
/**
|
|
41
|
+
* Called on every tool completion to observe potential recovery patterns.
|
|
42
|
+
*/
|
|
43
|
+
onToolComplete(toolName: string, isError: boolean): void;
|
|
44
|
+
/**
|
|
45
|
+
* Record an observed error→recovery correlation.
|
|
46
|
+
*/
|
|
47
|
+
private recordRecovery;
|
|
48
|
+
/**
|
|
49
|
+
* Check if a raw observation should be promoted to a learned pattern.
|
|
50
|
+
*/
|
|
51
|
+
private tryPromote;
|
|
52
|
+
/**
|
|
53
|
+
* Match an error against learned patterns.
|
|
54
|
+
*/
|
|
55
|
+
matchPattern(errorText: string, toolName: string): LearnedPattern | null;
|
|
56
|
+
/**
|
|
57
|
+
* Normalize error text for fingerprinting.
|
|
58
|
+
* Strips dynamic values (IDs, large numbers) to group similar errors.
|
|
59
|
+
*/
|
|
60
|
+
normalizeError(text: string): string;
|
|
61
|
+
/**
|
|
62
|
+
* Get all learned patterns (for testing/inspection).
|
|
63
|
+
*/
|
|
64
|
+
getPatterns(): LearnedPattern[];
|
|
65
|
+
/**
|
|
66
|
+
* Get pending observation count (for testing).
|
|
67
|
+
*/
|
|
68
|
+
getPendingCount(): number;
|
|
69
|
+
static generateHint(recoveryTool: string, occurrences: number): string;
|
|
70
|
+
private load;
|
|
71
|
+
/**
|
|
72
|
+
* Persist learned patterns to disk.
|
|
73
|
+
*/
|
|
74
|
+
save(): void;
|
|
75
|
+
}
|
|
76
|
+
//# sourceMappingURL=pattern-learner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-learner.d.ts","sourceRoot":"","sources":["../../src/hints/pattern-learner.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,gBAAgB,EAAE,MAAM,CAAC;I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OAAO,CAAC,IAAI;IAWZ;;OAEG;IACH,IAAI,IAAI,IAAI;CAgBb"}
|
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* PatternLearner — Adaptive memory system that learns error→recovery patterns.
|
|
4
|
+
*
|
|
5
|
+
* Flow:
|
|
6
|
+
* 1. Hint miss on error → start observing next 3 tool calls
|
|
7
|
+
* 2. If a different tool succeeds → record as recovery pattern
|
|
8
|
+
* 3. Same error→recovery seen N times → promote to learned rule
|
|
9
|
+
* 4. Persisted to JSON, survives across sessions
|
|
10
|
+
*/
|
|
11
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
12
|
+
if (k2 === undefined) k2 = k;
|
|
13
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
14
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
15
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
16
|
+
}
|
|
17
|
+
Object.defineProperty(o, k2, desc);
|
|
18
|
+
}) : (function(o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
}));
|
|
22
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
23
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
24
|
+
}) : function(o, v) {
|
|
25
|
+
o["default"] = v;
|
|
26
|
+
});
|
|
27
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
28
|
+
var ownKeys = function(o) {
|
|
29
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
30
|
+
var ar = [];
|
|
31
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
32
|
+
return ar;
|
|
33
|
+
};
|
|
34
|
+
return ownKeys(o);
|
|
35
|
+
};
|
|
36
|
+
return function (mod) {
|
|
37
|
+
if (mod && mod.__esModule) return mod;
|
|
38
|
+
var result = {};
|
|
39
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
40
|
+
__setModuleDefault(result, mod);
|
|
41
|
+
return result;
|
|
42
|
+
};
|
|
43
|
+
})();
|
|
44
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
45
|
+
exports.PatternLearner = void 0;
|
|
46
|
+
const fs = __importStar(require("fs"));
|
|
47
|
+
const path = __importStar(require("path"));
|
|
48
|
+
class PatternLearner {
|
|
49
|
+
pending = [];
|
|
50
|
+
rawObservations = new Map();
|
|
51
|
+
patterns = [];
|
|
52
|
+
filePath = null;
|
|
53
|
+
dirty = false;
|
|
54
|
+
static WATCH_WINDOW = 3;
|
|
55
|
+
static PROMOTE_THRESHOLD = 3;
|
|
56
|
+
static CONFIDENCE_THRESHOLD = 0.6;
|
|
57
|
+
static MAX_PENDING = 10;
|
|
58
|
+
/**
|
|
59
|
+
* Enable persistence — load existing patterns and save new ones.
|
|
60
|
+
*/
|
|
61
|
+
enablePersistence(dirPath) {
|
|
62
|
+
try {
|
|
63
|
+
fs.mkdirSync(dirPath, { recursive: true });
|
|
64
|
+
this.filePath = path.join(dirPath, 'learned-patterns.json');
|
|
65
|
+
this.load();
|
|
66
|
+
}
|
|
67
|
+
catch {
|
|
68
|
+
// Best-effort
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Called when a hint miss occurs on an error (no static rule matched).
|
|
73
|
+
* Starts observing subsequent calls to detect recovery pattern.
|
|
74
|
+
*/
|
|
75
|
+
onMiss(toolName, errorText) {
|
|
76
|
+
const fingerprint = this.normalizeError(errorText);
|
|
77
|
+
if (!fingerprint)
|
|
78
|
+
return;
|
|
79
|
+
// Limit pending observations to prevent memory buildup
|
|
80
|
+
if (this.pending.length >= PatternLearner.MAX_PENDING) {
|
|
81
|
+
this.pending.shift();
|
|
82
|
+
}
|
|
83
|
+
this.pending.push({
|
|
84
|
+
errorTool: toolName,
|
|
85
|
+
errorFingerprint: fingerprint,
|
|
86
|
+
timestamp: Date.now(),
|
|
87
|
+
remainingSlots: PatternLearner.WATCH_WINDOW,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Called on every tool completion to observe potential recovery patterns.
|
|
92
|
+
*/
|
|
93
|
+
onToolComplete(toolName, isError) {
|
|
94
|
+
const resolved = [];
|
|
95
|
+
for (let i = 0; i < this.pending.length; i++) {
|
|
96
|
+
const obs = this.pending[i];
|
|
97
|
+
if (!isError && toolName !== obs.errorTool) {
|
|
98
|
+
// Success with different tool = potential recovery
|
|
99
|
+
this.recordRecovery(obs.errorFingerprint, obs.errorTool, toolName);
|
|
100
|
+
resolved.push(i);
|
|
101
|
+
}
|
|
102
|
+
else if (!isError && toolName === obs.errorTool) {
|
|
103
|
+
// Same tool succeeded = self-resolved, discard
|
|
104
|
+
resolved.push(i);
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
// Another error, keep watching
|
|
108
|
+
obs.remainingSlots--;
|
|
109
|
+
if (obs.remainingSlots <= 0)
|
|
110
|
+
resolved.push(i);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
// Remove resolved observations (reverse order to preserve indices)
|
|
114
|
+
for (let i = resolved.length - 1; i >= 0; i--) {
|
|
115
|
+
this.pending.splice(resolved[i], 1);
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Record an observed error→recovery correlation.
|
|
120
|
+
*/
|
|
121
|
+
recordRecovery(errorFingerprint, errorTool, recoveryTool) {
|
|
122
|
+
let raw = this.rawObservations.get(errorFingerprint);
|
|
123
|
+
if (!raw) {
|
|
124
|
+
raw = {
|
|
125
|
+
errorFingerprint,
|
|
126
|
+
errorTools: new Set(),
|
|
127
|
+
recoveryTools: new Map(),
|
|
128
|
+
totalObservations: 0,
|
|
129
|
+
};
|
|
130
|
+
this.rawObservations.set(errorFingerprint, raw);
|
|
131
|
+
}
|
|
132
|
+
raw.errorTools.add(errorTool);
|
|
133
|
+
raw.recoveryTools.set(recoveryTool, (raw.recoveryTools.get(recoveryTool) || 0) + 1);
|
|
134
|
+
raw.totalObservations++;
|
|
135
|
+
this.tryPromote(raw);
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Check if a raw observation should be promoted to a learned pattern.
|
|
139
|
+
*/
|
|
140
|
+
tryPromote(raw) {
|
|
141
|
+
let bestTool = '';
|
|
142
|
+
let bestCount = 0;
|
|
143
|
+
for (const [tool, count] of raw.recoveryTools) {
|
|
144
|
+
if (count > bestCount) {
|
|
145
|
+
bestTool = tool;
|
|
146
|
+
bestCount = count;
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
const confidence = bestCount / raw.totalObservations;
|
|
150
|
+
if (bestCount < PatternLearner.PROMOTE_THRESHOLD || confidence < PatternLearner.CONFIDENCE_THRESHOLD) {
|
|
151
|
+
return;
|
|
152
|
+
}
|
|
153
|
+
const existing = this.patterns.find(p => p.errorFingerprint === raw.errorFingerprint);
|
|
154
|
+
if (existing) {
|
|
155
|
+
existing.occurrences = bestCount;
|
|
156
|
+
existing.confidence = confidence;
|
|
157
|
+
existing.recoveryTool = bestTool;
|
|
158
|
+
existing.lastSeen = Date.now();
|
|
159
|
+
existing.errorTools = Array.from(raw.errorTools);
|
|
160
|
+
existing.hint = PatternLearner.generateHint(bestTool, bestCount);
|
|
161
|
+
}
|
|
162
|
+
else {
|
|
163
|
+
this.patterns.push({
|
|
164
|
+
id: `learned-${Date.now()}-${Math.random().toString(36).slice(2, 6)}`,
|
|
165
|
+
errorFingerprint: raw.errorFingerprint,
|
|
166
|
+
errorTools: Array.from(raw.errorTools),
|
|
167
|
+
recoveryTool: bestTool,
|
|
168
|
+
occurrences: bestCount,
|
|
169
|
+
confidence,
|
|
170
|
+
firstSeen: Date.now(),
|
|
171
|
+
lastSeen: Date.now(),
|
|
172
|
+
hint: PatternLearner.generateHint(bestTool, bestCount),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
this.dirty = true;
|
|
176
|
+
this.save();
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Match an error against learned patterns.
|
|
180
|
+
*/
|
|
181
|
+
matchPattern(errorText, toolName) {
|
|
182
|
+
const fingerprint = this.normalizeError(errorText);
|
|
183
|
+
for (const pattern of this.patterns) {
|
|
184
|
+
if (pattern.errorTools.includes(toolName) &&
|
|
185
|
+
(fingerprint.includes(pattern.errorFingerprint) || pattern.errorFingerprint.includes(fingerprint))) {
|
|
186
|
+
return pattern;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Normalize error text for fingerprinting.
|
|
193
|
+
* Strips dynamic values (IDs, large numbers) to group similar errors.
|
|
194
|
+
*/
|
|
195
|
+
normalizeError(text) {
|
|
196
|
+
return text
|
|
197
|
+
.toLowerCase()
|
|
198
|
+
.replace(/\b[0-9a-f]{8,}\b/g, '{id}')
|
|
199
|
+
.replace(/\d{4,}/g, '{n}')
|
|
200
|
+
.replace(/\s+/g, ' ')
|
|
201
|
+
.trim()
|
|
202
|
+
.slice(0, 100);
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Get all learned patterns (for testing/inspection).
|
|
206
|
+
*/
|
|
207
|
+
getPatterns() {
|
|
208
|
+
return this.patterns;
|
|
209
|
+
}
|
|
210
|
+
/**
|
|
211
|
+
* Get pending observation count (for testing).
|
|
212
|
+
*/
|
|
213
|
+
getPendingCount() {
|
|
214
|
+
return this.pending.length;
|
|
215
|
+
}
|
|
216
|
+
static generateHint(recoveryTool, occurrences) {
|
|
217
|
+
return `Hint: Try ${recoveryTool} — learned from ${occurrences} previous recoveries.`;
|
|
218
|
+
}
|
|
219
|
+
load() {
|
|
220
|
+
if (!this.filePath)
|
|
221
|
+
return;
|
|
222
|
+
try {
|
|
223
|
+
const data = fs.readFileSync(this.filePath, 'utf-8');
|
|
224
|
+
const store = JSON.parse(data);
|
|
225
|
+
this.patterns = store.patterns || [];
|
|
226
|
+
}
|
|
227
|
+
catch {
|
|
228
|
+
this.patterns = [];
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
/**
|
|
232
|
+
* Persist learned patterns to disk.
|
|
233
|
+
*/
|
|
234
|
+
save() {
|
|
235
|
+
if (!this.filePath || !this.dirty)
|
|
236
|
+
return;
|
|
237
|
+
try {
|
|
238
|
+
const dir = path.dirname(this.filePath);
|
|
239
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
240
|
+
const store = {
|
|
241
|
+
version: 1,
|
|
242
|
+
patterns: this.patterns,
|
|
243
|
+
updatedAt: Date.now(),
|
|
244
|
+
};
|
|
245
|
+
fs.writeFileSync(this.filePath, JSON.stringify(store, null, 2));
|
|
246
|
+
this.dirty = false;
|
|
247
|
+
}
|
|
248
|
+
catch {
|
|
249
|
+
// Best-effort
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
exports.PatternLearner = PatternLearner;
|
|
254
|
+
//# sourceMappingURL=pattern-learner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pattern-learner.js","sourceRoot":"","sources":["../../src/hints/pattern-learner.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,uCAAyB;AACzB,2CAA6B;AAkC7B,MAAa,cAAc;IACjB,OAAO,GAAyB,EAAE,CAAC;IACnC,eAAe,GAAgC,IAAI,GAAG,EAAE,CAAC;IACzD,QAAQ,GAAqB,EAAE,CAAC;IAChC,QAAQ,GAAkB,IAAI,CAAC;IAC/B,KAAK,GAAG,KAAK,CAAC;IAEtB,MAAM,CAAU,YAAY,GAAG,CAAC,CAAC;IACjC,MAAM,CAAU,iBAAiB,GAAG,CAAC,CAAC;IACtC,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C,MAAM,KAAK,GAAiB;gBAC1B,OAAO,EAAE,CAAC;gBACV,QAAQ,EAAE,IAAI,CAAC,QAAQ;gBACvB,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;aACtB,CAAC;YACF,EAAE,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC;YAChE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;QAAC,MAAM,CAAC;YACP,cAAc;QAChB,CAAC;IACH,CAAC;;AA3NH,wCA4NC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-suggestions.d.ts","sourceRoot":"","sources":["../../../src/hints/rules/composite-suggestions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAe,MAAM,gBAAgB,CAAC;AAU5D,eAAO,MAAM,wBAAwB,EAAE,QAAQ,EA4C9C,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Composite Suggestions — suggests combining multi-step patterns into single calls.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.compositeSuggestionRules = void 0;
|
|
7
|
+
function lastToolWas(ctx, name) {
|
|
8
|
+
return ctx.recentCalls.length > 0 && ctx.recentCalls[0].toolName === name;
|
|
9
|
+
}
|
|
10
|
+
function recentToolCount(ctx, name) {
|
|
11
|
+
return ctx.recentCalls.filter(c => c.toolName === name).length;
|
|
12
|
+
}
|
|
13
|
+
exports.compositeSuggestionRules = [
|
|
14
|
+
{
|
|
15
|
+
name: 'find-then-click',
|
|
16
|
+
priority: 200,
|
|
17
|
+
match(ctx) {
|
|
18
|
+
if (ctx.toolName !== 'computer' && ctx.toolName !== 'click')
|
|
19
|
+
return null;
|
|
20
|
+
if (!lastToolWas(ctx, 'find'))
|
|
21
|
+
return null;
|
|
22
|
+
return 'Hint: Use click_element to find+click in one call.';
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
name: 'multiple-form-input',
|
|
27
|
+
priority: 201,
|
|
28
|
+
match(ctx) {
|
|
29
|
+
if (ctx.toolName !== 'form_input')
|
|
30
|
+
return null;
|
|
31
|
+
if (recentToolCount(ctx, 'form_input') >= 1) {
|
|
32
|
+
return 'Hint: Use fill_form({fields:{...}}) for multiple fields.';
|
|
33
|
+
}
|
|
34
|
+
return null;
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
name: 'navigate-then-click',
|
|
39
|
+
priority: 202,
|
|
40
|
+
match(ctx) {
|
|
41
|
+
if (ctx.toolName !== 'computer' && ctx.toolName !== 'click' && ctx.toolName !== 'click_element')
|
|
42
|
+
return null;
|
|
43
|
+
if (!lastToolWas(ctx, 'navigate'))
|
|
44
|
+
return null;
|
|
45
|
+
// Don't match screenshot operations — handled by sequence-detection
|
|
46
|
+
if (/screenshot/i.test(ctx.resultText))
|
|
47
|
+
return null;
|
|
48
|
+
return 'Hint: Use wait_and_click to handle loading delays.';
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: 'read-page-truncated',
|
|
53
|
+
priority: 203,
|
|
54
|
+
match(ctx) {
|
|
55
|
+
if (ctx.toolName !== 'read_page')
|
|
56
|
+
return null;
|
|
57
|
+
if (ctx.isError)
|
|
58
|
+
return null;
|
|
59
|
+
if (/truncat|too (long|large)|content cut|\.\.\.$/i.test(ctx.resultText)) {
|
|
60
|
+
return 'Hint: Use find(query) for targeted element search.';
|
|
61
|
+
}
|
|
62
|
+
return null;
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
];
|
|
66
|
+
//# sourceMappingURL=composite-suggestions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"composite-suggestions.js","sourceRo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