agent-web-interface 4.4.0 → 4.5.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/dist/src/browser/browser-session-config.d.ts +33 -0
- package/dist/src/browser/browser-session-config.d.ts.map +1 -0
- package/dist/src/browser/browser-session-config.js +24 -0
- package/dist/src/browser/browser-session-config.js.map +1 -0
- package/dist/src/browser/ensure-browser.d.ts +12 -27
- package/dist/src/browser/ensure-browser.d.ts.map +1 -1
- package/dist/src/browser/ensure-browser.js +104 -37
- package/dist/src/browser/ensure-browser.js.map +1 -1
- package/dist/src/browser/index.d.ts +2 -1
- package/dist/src/browser/index.d.ts.map +1 -1
- package/dist/src/browser/index.js +1 -0
- package/dist/src/browser/index.js.map +1 -1
- package/dist/src/browser/session-manager.d.ts +20 -0
- package/dist/src/browser/session-manager.d.ts.map +1 -1
- package/dist/src/browser/session-manager.js +122 -17
- package/dist/src/browser/session-manager.js.map +1 -1
- package/dist/src/browser/session-manager.types.d.ts +14 -2
- package/dist/src/browser/session-manager.types.d.ts.map +1 -1
- package/dist/src/browser/session-manager.types.js +5 -1
- package/dist/src/browser/session-manager.types.js.map +1 -1
- package/dist/src/cli/args.d.ts +12 -18
- package/dist/src/cli/args.d.ts.map +1 -1
- package/dist/src/cli/args.js +35 -40
- package/dist/src/cli/args.js.map +1 -1
- package/dist/src/form/constraint-extraction.d.ts +5 -0
- package/dist/src/form/constraint-extraction.d.ts.map +1 -1
- package/dist/src/form/constraint-extraction.js +13 -6
- package/dist/src/form/constraint-extraction.js.map +1 -1
- package/dist/src/form/field-extractor.d.ts.map +1 -1
- package/dist/src/form/field-extractor.js +14 -7
- package/dist/src/form/field-extractor.js.map +1 -1
- package/dist/src/form/form-state.d.ts.map +1 -1
- package/dist/src/form/form-state.js +16 -4
- package/dist/src/form/form-state.js.map +1 -1
- package/dist/src/gateway/http-gateway.d.ts +56 -0
- package/dist/src/gateway/http-gateway.d.ts.map +1 -0
- package/dist/src/gateway/http-gateway.js +229 -0
- package/dist/src/gateway/http-gateway.js.map +1 -0
- package/dist/src/gateway/json-rpc-errors.d.ts +6 -0
- package/dist/src/gateway/json-rpc-errors.d.ts.map +1 -0
- package/dist/src/gateway/json-rpc-errors.js +11 -0
- package/dist/src/gateway/json-rpc-errors.js.map +1 -0
- package/dist/src/gateway/session-router.d.ts +80 -0
- package/dist/src/gateway/session-router.d.ts.map +1 -0
- package/dist/src/gateway/session-router.js +177 -0
- package/dist/src/gateway/session-router.js.map +1 -0
- package/dist/src/http-entry.d.ts +20 -0
- package/dist/src/http-entry.d.ts.map +1 -0
- package/dist/src/http-entry.js +112 -0
- package/dist/src/http-entry.js.map +1 -0
- package/dist/src/index.d.ts +1 -10
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +25 -232
- package/dist/src/index.js.map +1 -1
- package/dist/src/lib/text-utils.d.ts +0 -24
- package/dist/src/lib/text-utils.d.ts.map +1 -1
- package/dist/src/lib/text-utils.js +2 -38
- package/dist/src/lib/text-utils.js.map +1 -1
- package/dist/src/observation/eid-linker.d.ts.map +1 -1
- package/dist/src/observation/eid-linker.js +1 -21
- package/dist/src/observation/eid-linker.js.map +1 -1
- package/dist/src/server/index.d.ts +0 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +0 -1
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/server/mcp-server.d.ts +6 -2
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/dist/src/server/mcp-server.js +3 -91
- package/dist/src/server/mcp-server.js.map +1 -1
- package/dist/src/server/server-config.d.ts +4 -20
- package/dist/src/server/server-config.d.ts.map +1 -1
- package/dist/src/server/server-config.js +6 -50
- package/dist/src/server/server-config.js.map +1 -1
- package/dist/src/server/tool-registrar.types.d.ts +25 -0
- package/dist/src/server/tool-registrar.types.d.ts.map +1 -0
- package/dist/src/server/tool-registrar.types.js +10 -0
- package/dist/src/server/tool-registrar.types.js.map +1 -0
- package/dist/src/server/tool-result-handler.d.ts +61 -0
- package/dist/src/server/tool-result-handler.d.ts.map +1 -0
- package/dist/src/server/tool-result-handler.js +137 -0
- package/dist/src/server/tool-result-handler.js.map +1 -0
- package/dist/src/session/session-controller.d.ts +123 -0
- package/dist/src/session/session-controller.d.ts.map +1 -0
- package/dist/src/session/session-controller.js +273 -0
- package/dist/src/session/session-controller.js.map +1 -0
- package/dist/src/shared/services/index.d.ts +0 -2
- package/dist/src/shared/services/index.d.ts.map +1 -1
- package/dist/src/shared/services/index.js +0 -2
- package/dist/src/shared/services/index.js.map +1 -1
- package/dist/src/shared/version.d.ts +10 -0
- package/dist/src/shared/version.d.ts.map +1 -0
- package/dist/src/shared/version.js +32 -0
- package/dist/src/shared/version.js.map +1 -0
- package/dist/src/snapshot/element-resolver.d.ts +3 -2
- package/dist/src/snapshot/element-resolver.d.ts.map +1 -1
- package/dist/src/snapshot/element-resolver.js +83 -8
- package/dist/src/snapshot/element-resolver.js.map +1 -1
- package/dist/src/snapshot/extractors/attribute-extractor.d.ts.map +1 -1
- package/dist/src/snapshot/extractors/attribute-extractor.js +4 -0
- package/dist/src/snapshot/extractors/attribute-extractor.js.map +1 -1
- package/dist/src/snapshot/extractors/layout-extractor.d.ts +9 -7
- package/dist/src/snapshot/extractors/layout-extractor.d.ts.map +1 -1
- package/dist/src/snapshot/extractors/layout-extractor.js +34 -19
- package/dist/src/snapshot/extractors/layout-extractor.js.map +1 -1
- package/dist/src/snapshot/extractors/state-extractor.d.ts +2 -2
- package/dist/src/snapshot/extractors/state-extractor.d.ts.map +1 -1
- package/dist/src/snapshot/extractors/state-extractor.js +22 -2
- package/dist/src/snapshot/extractors/state-extractor.js.map +1 -1
- package/dist/src/snapshot/extractors/types.d.ts +6 -0
- package/dist/src/snapshot/extractors/types.d.ts.map +1 -1
- package/dist/src/snapshot/extractors/types.js.map +1 -1
- package/dist/src/snapshot/snapshot-compiler.d.ts.map +1 -1
- package/dist/src/snapshot/snapshot-compiler.js +15 -2
- package/dist/src/snapshot/snapshot-compiler.js.map +1 -1
- package/dist/src/snapshot/snapshot.types.d.ts +10 -1
- package/dist/src/snapshot/snapshot.types.d.ts.map +1 -1
- package/dist/src/snapshot/snapshot.types.js.map +1 -1
- package/dist/src/state/actionables-filter.d.ts.map +1 -1
- package/dist/src/state/actionables-filter.js +7 -3
- package/dist/src/state/actionables-filter.js.map +1 -1
- package/dist/src/state/atoms-extractor.d.ts.map +1 -1
- package/dist/src/state/atoms-extractor.js +3 -23
- package/dist/src/state/atoms-extractor.js.map +1 -1
- package/dist/src/state/diff-engine.d.ts.map +1 -1
- package/dist/src/state/diff-engine.js +6 -33
- package/dist/src/state/diff-engine.js.map +1 -1
- package/dist/src/state/element-identity.d.ts +3 -6
- package/dist/src/state/element-identity.d.ts.map +1 -1
- package/dist/src/state/element-identity.js +10 -7
- package/dist/src/state/element-identity.js.map +1 -1
- package/dist/src/state/element-ref.types.d.ts +5 -27
- package/dist/src/state/element-ref.types.d.ts.map +1 -1
- package/dist/src/state/state-manager.d.ts.map +1 -1
- package/dist/src/state/state-manager.js +3 -1
- package/dist/src/state/state-manager.js.map +1 -1
- package/dist/src/state/state-renderer.d.ts.map +1 -1
- package/dist/src/state/state-renderer.js +3 -1
- package/dist/src/state/state-renderer.js.map +1 -1
- package/dist/src/state/types.d.ts +2 -1
- package/dist/src/state/types.d.ts.map +1 -1
- package/dist/src/state/url-sanitization.d.ts +1 -1
- package/dist/src/state/url-sanitization.d.ts.map +1 -1
- package/dist/src/state/url-sanitization.js +29 -13
- package/dist/src/state/url-sanitization.js.map +1 -1
- package/dist/src/tools/action-context.d.ts +6 -11
- package/dist/src/tools/action-context.d.ts.map +1 -1
- package/dist/src/tools/action-context.js +10 -19
- package/dist/src/tools/action-context.js.map +1 -1
- package/dist/src/tools/action-stabilization.d.ts.map +1 -1
- package/dist/src/tools/action-stabilization.js +6 -0
- package/dist/src/tools/action-stabilization.js.map +1 -1
- package/dist/src/tools/browser-tools.d.ts +3 -2
- package/dist/src/tools/browser-tools.d.ts.map +1 -1
- package/dist/src/tools/browser-tools.js +5 -3
- package/dist/src/tools/browser-tools.js.map +1 -1
- package/dist/src/tools/canvas-tools.d.ts +2 -1
- package/dist/src/tools/canvas-tools.d.ts.map +1 -1
- package/dist/src/tools/canvas-tools.js +5 -7
- package/dist/src/tools/canvas-tools.js.map +1 -1
- package/dist/src/tools/errors.d.ts +2 -34
- package/dist/src/tools/errors.d.ts.map +1 -1
- package/dist/src/tools/errors.js +1 -44
- package/dist/src/tools/errors.js.map +1 -1
- package/dist/src/tools/execute-action.d.ts +4 -3
- package/dist/src/tools/execute-action.d.ts.map +1 -1
- package/dist/src/tools/execute-action.js +32 -23
- package/dist/src/tools/execute-action.js.map +1 -1
- package/dist/src/tools/form-tools.d.ts +3 -8
- package/dist/src/tools/form-tools.d.ts.map +1 -1
- package/dist/src/tools/form-tools.js +38 -18
- package/dist/src/tools/form-tools.js.map +1 -1
- package/dist/src/tools/index.d.ts +6 -6
- package/dist/src/tools/index.d.ts.map +1 -1
- package/dist/src/tools/index.js +7 -10
- package/dist/src/tools/index.js.map +1 -1
- package/dist/src/tools/interaction-tools.d.ts +6 -5
- package/dist/src/tools/interaction-tools.d.ts.map +1 -1
- package/dist/src/tools/interaction-tools.js +29 -32
- package/dist/src/tools/interaction-tools.js.map +1 -1
- package/dist/src/tools/navigation-tools.d.ts +7 -13
- package/dist/src/tools/navigation-tools.d.ts.map +1 -1
- package/dist/src/tools/navigation-tools.js +52 -59
- package/dist/src/tools/navigation-tools.js.map +1 -1
- package/dist/src/tools/observation-tools.d.ts +6 -5
- package/dist/src/tools/observation-tools.d.ts.map +1 -1
- package/dist/src/tools/observation-tools.js +30 -34
- package/dist/src/tools/observation-tools.js.map +1 -1
- package/dist/src/tools/readability-tools.d.ts +16 -0
- package/dist/src/tools/readability-tools.d.ts.map +1 -0
- package/dist/src/tools/readability-tools.js +45 -0
- package/dist/src/tools/readability-tools.js.map +1 -0
- package/dist/src/tools/response-builder.d.ts +20 -32
- package/dist/src/tools/response-builder.d.ts.map +1 -1
- package/dist/src/tools/response-builder.js +31 -47
- package/dist/src/tools/response-builder.js.map +1 -1
- package/dist/src/tools/stale-element-retry.d.ts.map +1 -1
- package/dist/src/tools/stale-element-retry.js +37 -2
- package/dist/src/tools/stale-element-retry.js.map +1 -1
- package/dist/src/tools/tool-context.d.ts +4 -36
- package/dist/src/tools/tool-context.d.ts.map +1 -1
- package/dist/src/tools/tool-context.js +6 -75
- package/dist/src/tools/tool-context.js.map +1 -1
- package/dist/src/tools/tool-context.types.d.ts +141 -0
- package/dist/src/tools/tool-context.types.d.ts.map +1 -0
- package/dist/src/tools/tool-context.types.js +11 -0
- package/dist/src/tools/tool-context.types.js.map +1 -0
- package/dist/src/tools/tool-registration.d.ts +25 -0
- package/dist/src/tools/tool-registration.d.ts.map +1 -0
- package/dist/src/tools/tool-registration.js +180 -0
- package/dist/src/tools/tool-registration.js.map +1 -0
- package/dist/src/tools/tool-schemas.d.ts +88 -1947
- package/dist/src/tools/tool-schemas.d.ts.map +1 -1
- package/dist/src/tools/tool-schemas.js +21 -302
- package/dist/src/tools/tool-schemas.js.map +1 -1
- package/dist/src/tools/viewport-tools.d.ts +4 -3
- package/dist/src/tools/viewport-tools.d.ts.map +1 -1
- package/dist/src/tools/viewport-tools.js +17 -21
- package/dist/src/tools/viewport-tools.js.map +1 -1
- package/dist/src/worker/chrome-worker-process.d.ts +4 -0
- package/dist/src/worker/chrome-worker-process.d.ts.map +1 -1
- package/dist/src/worker/chrome-worker-process.js +1 -1
- package/dist/src/worker/chrome-worker-process.js.map +1 -1
- package/package.json +7 -3
- package/dist/src/factpack/action-selector.d.ts +0 -36
- package/dist/src/factpack/action-selector.d.ts.map +0 -1
- package/dist/src/factpack/action-selector.js +0 -367
- package/dist/src/factpack/action-selector.js.map +0 -1
- package/dist/src/factpack/dialog-detector.d.ts +0 -19
- package/dist/src/factpack/dialog-detector.d.ts.map +0 -1
- package/dist/src/factpack/dialog-detector.js +0 -354
- package/dist/src/factpack/dialog-detector.js.map +0 -1
- package/dist/src/factpack/form-detector.d.ts +0 -28
- package/dist/src/factpack/form-detector.d.ts.map +0 -1
- package/dist/src/factpack/form-detector.js +0 -555
- package/dist/src/factpack/form-detector.js.map +0 -1
- package/dist/src/factpack/index.d.ts +0 -32
- package/dist/src/factpack/index.d.ts.map +0 -1
- package/dist/src/factpack/index.js +0 -73
- package/dist/src/factpack/index.js.map +0 -1
- package/dist/src/factpack/page-classifier.d.ts +0 -22
- package/dist/src/factpack/page-classifier.d.ts.map +0 -1
- package/dist/src/factpack/page-classifier.js +0 -526
- package/dist/src/factpack/page-classifier.js.map +0 -1
- package/dist/src/factpack/types.d.ts +0 -307
- package/dist/src/factpack/types.d.ts.map +0 -1
- package/dist/src/factpack/types.js +0 -12
- package/dist/src/factpack/types.js.map +0 -1
- package/dist/src/lib/constants.d.ts +0 -27
- package/dist/src/lib/constants.d.ts.map +0 -1
- package/dist/src/lib/constants.js +0 -63
- package/dist/src/lib/constants.js.map +0 -1
- package/dist/src/lib/index.d.ts +0 -12
- package/dist/src/lib/index.d.ts.map +0 -1
- package/dist/src/lib/index.js +0 -17
- package/dist/src/lib/index.js.map +0 -1
- package/dist/src/lib/regions.d.ts +0 -29
- package/dist/src/lib/regions.d.ts.map +0 -1
- package/dist/src/lib/regions.js +0 -93
- package/dist/src/lib/regions.js.map +0 -1
- package/dist/src/lib/scoring.d.ts +0 -47
- package/dist/src/lib/scoring.d.ts.map +0 -1
- package/dist/src/lib/scoring.js +0 -79
- package/dist/src/lib/scoring.js.map +0 -1
- package/dist/src/lib/selectors.d.ts +0 -42
- package/dist/src/lib/selectors.d.ts.map +0 -1
- package/dist/src/lib/selectors.js +0 -138
- package/dist/src/lib/selectors.js.map +0 -1
- package/dist/src/renderer/budget-manager.d.ts +0 -46
- package/dist/src/renderer/budget-manager.d.ts.map +0 -1
- package/dist/src/renderer/budget-manager.js +0 -133
- package/dist/src/renderer/budget-manager.js.map +0 -1
- package/dist/src/renderer/constants.d.ts +0 -38
- package/dist/src/renderer/constants.d.ts.map +0 -1
- package/dist/src/renderer/constants.js +0 -29
- package/dist/src/renderer/constants.js.map +0 -1
- package/dist/src/renderer/index.d.ts +0 -12
- package/dist/src/renderer/index.d.ts.map +0 -1
- package/dist/src/renderer/index.js +0 -16
- package/dist/src/renderer/index.js.map +0 -1
- package/dist/src/renderer/section-renderers.d.ts +0 -42
- package/dist/src/renderer/section-renderers.d.ts.map +0 -1
- package/dist/src/renderer/section-renderers.js +0 -252
- package/dist/src/renderer/section-renderers.js.map +0 -1
- package/dist/src/renderer/token-counter.d.ts +0 -45
- package/dist/src/renderer/token-counter.d.ts.map +0 -1
- package/dist/src/renderer/token-counter.js +0 -65
- package/dist/src/renderer/token-counter.js.map +0 -1
- package/dist/src/renderer/types.d.ts +0 -71
- package/dist/src/renderer/types.d.ts.map +0 -1
- package/dist/src/renderer/types.js +0 -7
- package/dist/src/renderer/types.js.map +0 -1
- package/dist/src/renderer/xml-renderer.d.ts +0 -42
- package/dist/src/renderer/xml-renderer.d.ts.map +0 -1
- package/dist/src/renderer/xml-renderer.js +0 -103
- package/dist/src/renderer/xml-renderer.js.map +0 -1
- package/dist/src/server/session-store.d.ts +0 -163
- package/dist/src/server/session-store.d.ts.map +0 -1
- package/dist/src/server/session-store.js +0 -248
- package/dist/src/server/session-store.js.map +0 -1
- package/dist/src/session/session-worker-binding.d.ts +0 -57
- package/dist/src/session/session-worker-binding.d.ts.map +0 -1
- package/dist/src/session/session-worker-binding.js +0 -109
- package/dist/src/session/session-worker-binding.js.map +0 -1
- package/dist/src/shared/services/dom-transformer.service.d.ts +0 -71
- package/dist/src/shared/services/dom-transformer.service.d.ts.map +0 -1
- package/dist/src/shared/services/dom-transformer.service.js +0 -190
- package/dist/src/shared/services/dom-transformer.service.js.map +0 -1
- package/dist/src/shared/services/selector-builder.service.d.ts +0 -53
- package/dist/src/shared/services/selector-builder.service.d.ts.map +0 -1
- package/dist/src/shared/services/selector-builder.service.js +0 -240
- package/dist/src/shared/services/selector-builder.service.js.map +0 -1
- package/dist/src/state/constants.d.ts +0 -125
- package/dist/src/state/constants.d.ts.map +0 -1
- package/dist/src/state/constants.js +0 -131
- package/dist/src/state/constants.js.map +0 -1
- package/dist/src/tools/state-manager-registry.d.ts +0 -26
- package/dist/src/tools/state-manager-registry.d.ts.map +0 -1
- package/dist/src/tools/state-manager-registry.js +0 -39
- package/dist/src/tools/state-manager-registry.js.map +0 -1
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* queries their scene graphs for object metadata, and returns annotated screenshots.
|
|
7
7
|
*/
|
|
8
8
|
import type { CompositeResult } from './tool-result.types.js';
|
|
9
|
+
import type { ToolContext } from './tool-context.types.js';
|
|
9
10
|
/** A single detected object on the canvas. */
|
|
10
11
|
export interface CanvasObject {
|
|
11
12
|
type: string;
|
|
@@ -28,5 +29,5 @@ export interface CanvasMetadata {
|
|
|
28
29
|
* Inspect a canvas element: detect library, query scene graph, and return
|
|
29
30
|
* an annotated screenshot with coordinate grid + object bounding boxes.
|
|
30
31
|
*/
|
|
31
|
-
export declare function inspectCanvas(rawInput: unknown): Promise<CompositeResult>;
|
|
32
|
+
export declare function inspectCanvas(rawInput: unknown, ctx: ToolContext): Promise<CompositeResult>;
|
|
32
33
|
//# sourceMappingURL=canvas-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/canvas-tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/canvas-tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,KAAK,EAAE,eAAe,EAA2B,MAAM,wBAAwB,CAAC;AACvF,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAM3D,8CAA8C;AAC9C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,sDAAsD;AACtD,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,YAAY,EAAE,CAAC;IACxB,WAAW,EAAE;QAAE,CAAC,EAAE,MAAM,CAAC;QAAC,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CACvC;AA4TD;;;GAGG;AACH,wBAAsB,aAAa,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,eAAe,CAAC,CA6DjG"}
|
|
@@ -7,7 +7,6 @@
|
|
|
7
7
|
*/
|
|
8
8
|
import { InspectCanvasInputSchema } from './tool-schemas.js';
|
|
9
9
|
import { captureScreenshot, getElementBoundingBox } from '../screenshot/index.js';
|
|
10
|
-
import { getSessionManager, resolveExistingPage, ensureCdpSession, requireSnapshot, resolveElementByEid, } from './tool-context.js';
|
|
11
10
|
// ---------------------------------------------------------------------------
|
|
12
11
|
// Canvas detection script (executed in page context via Runtime.callFunctionOn)
|
|
13
12
|
// ---------------------------------------------------------------------------
|
|
@@ -314,15 +313,14 @@ async function cleanupInspection(cdp, objectId) {
|
|
|
314
313
|
* Inspect a canvas element: detect library, query scene graph, and return
|
|
315
314
|
* an annotated screenshot with coordinate grid + object bounding boxes.
|
|
316
315
|
*/
|
|
317
|
-
export async function inspectCanvas(rawInput) {
|
|
316
|
+
export async function inspectCanvas(rawInput, ctx) {
|
|
318
317
|
const input = InspectCanvasInputSchema.parse(rawInput);
|
|
319
|
-
|
|
320
|
-
let handle = resolveExistingPage(session, input.page_id);
|
|
318
|
+
let handle = ctx.resolveExistingPage(input.page_id);
|
|
321
319
|
const pageId = handle.page_id;
|
|
322
|
-
const ensureResult = await ensureCdpSession(
|
|
320
|
+
const ensureResult = await ctx.ensureCdpSession(handle);
|
|
323
321
|
handle = ensureResult.handle;
|
|
324
|
-
const snapshot = requireSnapshot(pageId);
|
|
325
|
-
const node = resolveElementByEid(pageId, input.eid, snapshot);
|
|
322
|
+
const snapshot = ctx.requireSnapshot(pageId);
|
|
323
|
+
const node = ctx.resolveElementByEid(pageId, input.eid, snapshot);
|
|
326
324
|
// Scroll canvas into view before computing bounding box and overlay
|
|
327
325
|
await handle.cdp.send('DOM.scrollIntoViewIfNeeded', {
|
|
328
326
|
backendNodeId: node.backend_node_id,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"canvas-tools.js","sourceRoot":"","sources":["../../../src/tools/canvas-tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;
|
|
1
|
+
{"version":3,"file":"canvas-tools.js","sourceRoot":"","sources":["../../../src/tools/canvas-tools.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,wBAAwB,EAAE,MAAM,mBAAmB,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,wBAAwB,CAAC;AAyBlF,8EAA8E;AAC9E,gFAAgF;AAChF,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,oBAAoB,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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W,EAAE,EAAE,EAAE,KAAK,EAAE,QAAQ,CAAC,OAAkB,EAAE,CAAC;QAC3E,aAAa,EAAE,IAAI;QACnB,YAAY,EAAE,KAAK;KACpB,CAAC,CAAC;IAEH,8EAA8E;IAC9E,IAAI,gBAA0C,CAAC;IAC/C,IAAI,CAAC;QACH,gBAAgB,GAAG,MAAM,iBAAiB,CAAC,MAAM,CAAC,GAAG,EAAE;YACrD,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,KAAK;YAC7B,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,IAAI;SACL,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,MAAM,iBAAiB,CAAC,MAAM,CAAC,GAAG,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,KAAK,EAAE,gBAAgB,EAAE,CAAC;AACxF,CAAC"}
|
|
@@ -4,32 +4,11 @@
|
|
|
4
4
|
* Standardized errors for browser tools with consistent formatting.
|
|
5
5
|
* All errors follow the pattern: `${context}: ${identifier}` or `${message}. ${instruction}`
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
* Base error class for all tool errors.
|
|
9
|
-
*/
|
|
10
|
-
export declare class ToolError extends Error {
|
|
7
|
+
declare class ToolError extends Error {
|
|
11
8
|
readonly code: string;
|
|
12
9
|
readonly details?: Record<string, unknown> | undefined;
|
|
13
10
|
constructor(message: string, code: string, details?: Record<string, unknown> | undefined);
|
|
14
11
|
}
|
|
15
|
-
/**
|
|
16
|
-
* Thrown when tools are used before initialization.
|
|
17
|
-
*/
|
|
18
|
-
export declare class ToolsNotInitializedError extends ToolError {
|
|
19
|
-
constructor();
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Thrown when a page is not found by ID.
|
|
23
|
-
*/
|
|
24
|
-
export declare class PageNotFoundError extends ToolError {
|
|
25
|
-
constructor(pageId: string);
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Thrown when no page is available for operations.
|
|
29
|
-
*/
|
|
30
|
-
export declare class NoPageAvailableError extends ToolError {
|
|
31
|
-
constructor();
|
|
32
|
-
}
|
|
33
12
|
/**
|
|
34
13
|
* Thrown when a snapshot is required but not available.
|
|
35
14
|
*/
|
|
@@ -48,16 +27,5 @@ export declare class ElementNotFoundError extends ToolError {
|
|
|
48
27
|
export declare class StaleElementError extends ToolError {
|
|
49
28
|
constructor(eid: string);
|
|
50
29
|
}
|
|
51
|
-
|
|
52
|
-
* Thrown when a node is not found in snapshot.
|
|
53
|
-
*/
|
|
54
|
-
export declare class NodeNotFoundError extends ToolError {
|
|
55
|
-
constructor(nodeId: string);
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* Thrown when eid is required but not provided.
|
|
59
|
-
*/
|
|
60
|
-
export declare class EidRequiredError extends ToolError {
|
|
61
|
-
constructor();
|
|
62
|
-
}
|
|
30
|
+
export {};
|
|
63
31
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/tools/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/tools/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,cAAM,SAAU,SAAQ,KAAK;aAGT,IAAI,EAAE,MAAM;aACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;gBAFjD,OAAO,EAAE,MAAM,EACC,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,YAAA;CAKpD;AAED;;GAEG;AACH,qBAAa,qBAAsB,SAAQ,SAAS;gBACtC,MAAM,EAAE,MAAM;CAK3B;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,SAAS;gBACrC,GAAG,EAAE,MAAM;CAGxB;AAED;;GAEG;AACH,qBAAa,iBAAkB,SAAQ,SAAS;gBAClC,GAAG,EAAE,MAAM;CAGxB"}
|
package/dist/src/tools/errors.js
CHANGED
|
@@ -4,10 +4,7 @@
|
|
|
4
4
|
* Standardized errors for browser tools with consistent formatting.
|
|
5
5
|
* All errors follow the pattern: `${context}: ${identifier}` or `${message}. ${instruction}`
|
|
6
6
|
*/
|
|
7
|
-
|
|
8
|
-
* Base error class for all tool errors.
|
|
9
|
-
*/
|
|
10
|
-
export class ToolError extends Error {
|
|
7
|
+
class ToolError extends Error {
|
|
11
8
|
code;
|
|
12
9
|
details;
|
|
13
10
|
constructor(message, code, details) {
|
|
@@ -17,30 +14,6 @@ export class ToolError extends Error {
|
|
|
17
14
|
this.name = 'ToolError';
|
|
18
15
|
}
|
|
19
16
|
}
|
|
20
|
-
/**
|
|
21
|
-
* Thrown when tools are used before initialization.
|
|
22
|
-
*/
|
|
23
|
-
export class ToolsNotInitializedError extends ToolError {
|
|
24
|
-
constructor() {
|
|
25
|
-
super('Tools not initialized. Call initializeTools() first.', 'TOOLS_NOT_INITIALIZED');
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* Thrown when a page is not found by ID.
|
|
30
|
-
*/
|
|
31
|
-
export class PageNotFoundError extends ToolError {
|
|
32
|
-
constructor(pageId) {
|
|
33
|
-
super(`Page not found: ${pageId}`, 'PAGE_NOT_FOUND', { pageId });
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Thrown when no page is available for operations.
|
|
38
|
-
*/
|
|
39
|
-
export class NoPageAvailableError extends ToolError {
|
|
40
|
-
constructor() {
|
|
41
|
-
super('No page available. Use launch_browser first.', 'NO_PAGE_AVAILABLE');
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
17
|
/**
|
|
45
18
|
* Thrown when a snapshot is required but not available.
|
|
46
19
|
*/
|
|
@@ -67,20 +40,4 @@ export class StaleElementError extends ToolError {
|
|
|
67
40
|
super(`Element has stale reference: ${eid}`, 'STALE_ELEMENT', { eid });
|
|
68
41
|
}
|
|
69
42
|
}
|
|
70
|
-
/**
|
|
71
|
-
* Thrown when a node is not found in snapshot.
|
|
72
|
-
*/
|
|
73
|
-
export class NodeNotFoundError extends ToolError {
|
|
74
|
-
constructor(nodeId) {
|
|
75
|
-
super(`Node not found in snapshot: ${nodeId}`, 'NODE_NOT_FOUND', { nodeId });
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Thrown when eid is required but not provided.
|
|
80
|
-
*/
|
|
81
|
-
export class EidRequiredError extends ToolError {
|
|
82
|
-
constructor() {
|
|
83
|
-
super('Element ID (eid) is required.', 'EID_REQUIRED');
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
43
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/tools/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/tools/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,MAAM,SAAU,SAAQ,KAAK;IAGT;IACA;IAHlB,YACE,OAAe,EACC,IAAY,EACZ,OAAiC;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QAHC,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAA0B;QAGjD,IAAI,CAAC,IAAI,GAAG,WAAW,CAAC;IAC1B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,qBAAsB,SAAQ,SAAS;IAClD,YAAY,MAAc;QACxB,KAAK,CAAC,wBAAwB,MAAM,6BAA6B,EAAE,mBAAmB,EAAE;YACtF,MAAM;SACP,CAAC,CAAC;IACL,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,oBAAqB,SAAQ,SAAS;IACjD,YAAY,GAAW;QACrB,KAAK,CAAC,sBAAsB,GAAG,EAAE,EAAE,mBAAmB,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACnE,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,iBAAkB,SAAQ,SAAS;IAC9C,YAAY,GAAW;QACrB,KAAK,CAAC,gCAAgC,GAAG,EAAE,EAAE,eAAe,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IACzE,CAAC;CACF"}
|
|
@@ -12,6 +12,7 @@ import type { PageHandle } from '../browser/page-registry.js';
|
|
|
12
12
|
import type { StateResponse } from '../state/types.js';
|
|
13
13
|
import type { ClickOutcome } from '../state/element-ref.types.js';
|
|
14
14
|
import type { RuntimeHealth } from '../state/health.types.js';
|
|
15
|
+
import type { ToolContext } from './tool-context.types.js';
|
|
15
16
|
/**
|
|
16
17
|
* Result of executing an action.
|
|
17
18
|
*/
|
|
@@ -64,7 +65,7 @@ export type CaptureSnapshotFn = () => Promise<{
|
|
|
64
65
|
* @param action - The action to execute
|
|
65
66
|
* @returns Action result with page brief and metadata
|
|
66
67
|
*/
|
|
67
|
-
export declare function executeAction(handle: PageHandle, action: () => Promise<void>, captureSnapshot?: CaptureSnapshotFn): Promise<ActionResult>;
|
|
68
|
+
export declare function executeAction(handle: PageHandle, action: () => Promise<void>, ctx: ToolContext, captureSnapshot?: CaptureSnapshotFn): Promise<ActionResult>;
|
|
68
69
|
/**
|
|
69
70
|
* Execute an element-based action with automatic retry on stale element errors.
|
|
70
71
|
*
|
|
@@ -81,7 +82,7 @@ export declare function executeAction(handle: PageHandle, action: () => Promise<
|
|
|
81
82
|
* @param snapshotStore - Snapshot store to update with fresh snapshot
|
|
82
83
|
* @returns Action result with page brief and metadata
|
|
83
84
|
*/
|
|
84
|
-
export declare function executeActionWithRetry(handle: PageHandle, node: ReadableNode, action: (backendNodeId: number) => Promise<void>, snapshotStore?: {
|
|
85
|
+
export declare function executeActionWithRetry(handle: PageHandle, node: ReadableNode, action: (backendNodeId: number) => Promise<void>, ctx: ToolContext, snapshotStore?: {
|
|
85
86
|
store: (pageId: string, snapshot: BaseSnapshot) => void;
|
|
86
87
|
}, captureSnapshot?: CaptureSnapshotFn): Promise<ActionResult>;
|
|
87
88
|
/**
|
|
@@ -99,7 +100,7 @@ export declare function executeActionWithRetry(handle: PageHandle, node: Readabl
|
|
|
99
100
|
* @param snapshotStore - Snapshot store to update with fresh snapshot
|
|
100
101
|
* @returns ActionResultWithOutcome including ClickOutcome
|
|
101
102
|
*/
|
|
102
|
-
export declare function executeActionWithOutcome(handle: PageHandle, node: ReadableNode, action: (backendNodeId: number) => Promise<void>, snapshotStore?: {
|
|
103
|
+
export declare function executeActionWithOutcome(handle: PageHandle, node: ReadableNode, action: (backendNodeId: number) => Promise<void>, ctx: ToolContext, snapshotStore?: {
|
|
103
104
|
store: (pageId: string, snapshot: BaseSnapshot) => void;
|
|
104
105
|
}, captureSnapshot?: CaptureSnapshotFn): Promise<ActionResultWithOutcome>;
|
|
105
106
|
//# sourceMappingURL=execute-action.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-action.d.ts","sourceRoot":"","sources":["../../../src/tools/execute-action.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"execute-action.d.ts","sourceRoot":"","sources":["../../../src/tools/execute-action.ts"],"names":[],"mappings":"AAAA;;;;;;;;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,CAAC,CA0DvB;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,sBAAsB,CAC1C,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAChD,GAAG,EAAE,WAAW,EAChB,aAAa,CAAC,EAAE;IAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAA;CAAE,EAC3E,eAAe,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,YAAY,CAAC,CA4GvB;AAMD;;;;;;;;;;;;;;GAcG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE,UAAU,EAClB,IAAI,EAAE,YAAY,EAClB,MAAM,EAAE,CAAC,aAAa,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,EAChD,GAAG,EAAE,WAAW,EAChB,aAAa,CAAC,EAAE;IAAE,KAAK,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,KAAK,IAAI,CAAA;CAAE,EAC3E,eAAe,CAAC,EAAE,iBAAiB,GAClC,OAAO,CAAC,uBAAuB,CAAC,CA2IlC"}
|
|
@@ -7,10 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* Navigation-aware click outcome model for better error classification.
|
|
9
9
|
*/
|
|
10
|
-
import { observationAccumulator } from '../observation/index.js';
|
|
11
10
|
import { ATTACHMENT_SIGNIFICANCE_THRESHOLD } from '../observation/observation.types.js';
|
|
12
|
-
import { getDependencyTracker } from '../form/index.js';
|
|
13
|
-
import { getStateManager } from './state-manager-registry.js';
|
|
14
11
|
import { computeObservedEffect } from './effect-tracker.js';
|
|
15
12
|
import { stabilizeAfterAction, captureSnapshotFallback } from './action-stabilization.js';
|
|
16
13
|
import { isStaleElementError, handleStaleElementRetry } from './stale-element-retry.js';
|
|
@@ -34,13 +31,13 @@ import { captureNavigationState, checkNavigationOccurred } from './navigation-de
|
|
|
34
31
|
* @param action - The action to execute
|
|
35
32
|
* @returns Action result with page brief and metadata
|
|
36
33
|
*/
|
|
37
|
-
export async function executeAction(handle, action, captureSnapshot) {
|
|
34
|
+
export async function executeAction(handle, action, ctx, captureSnapshot) {
|
|
38
35
|
let success = true;
|
|
39
36
|
let error;
|
|
40
37
|
// Record pre-action timestamp for observation capture
|
|
41
38
|
const actionStartTime = Date.now();
|
|
42
39
|
// Ensure observation accumulator is injected
|
|
43
|
-
await
|
|
40
|
+
await ctx.getObservationAccumulator().ensureInjected(handle.page);
|
|
44
41
|
// Execute action - if this throws, we catch and return error
|
|
45
42
|
try {
|
|
46
43
|
await action();
|
|
@@ -52,20 +49,24 @@ export async function executeAction(handle, action, captureSnapshot) {
|
|
|
52
49
|
// Stabilize page after action (handles both SPA updates and full navigations)
|
|
53
50
|
await stabilizeAfterAction(handle.page);
|
|
54
51
|
// Capture observations from the action window
|
|
55
|
-
const observations = await
|
|
52
|
+
const observations = await ctx
|
|
53
|
+
.getObservationAccumulator()
|
|
54
|
+
.getObservations(handle.page, actionStartTime);
|
|
56
55
|
// Capture snapshot
|
|
57
56
|
const capture = captureSnapshot ?? (() => captureSnapshotFallback(handle));
|
|
58
57
|
const captureResult = await capture();
|
|
59
58
|
const snapshot = captureResult.snapshot;
|
|
60
59
|
// Filter observations to reduce noise (threshold 5 requires semantic signals)
|
|
61
|
-
const filteredObservations =
|
|
60
|
+
const filteredObservations = ctx
|
|
61
|
+
.getObservationAccumulator()
|
|
62
|
+
.filterBySignificance(observations, ATTACHMENT_SIGNIFICANCE_THRESHOLD);
|
|
62
63
|
// Attach observations to snapshot if any were captured
|
|
63
64
|
if (filteredObservations.duringAction.length > 0 ||
|
|
64
65
|
filteredObservations.sincePrevious.length > 0) {
|
|
65
66
|
snapshot.observations = filteredObservations;
|
|
66
67
|
}
|
|
67
68
|
// Generate state response using StateManager
|
|
68
|
-
const stateManager = getStateManager(handle.page_id);
|
|
69
|
+
const stateManager = ctx.getStateManager(handle.page_id);
|
|
69
70
|
const state_response = stateManager.generateResponse(snapshot);
|
|
70
71
|
return {
|
|
71
72
|
success,
|
|
@@ -94,14 +95,14 @@ export async function executeAction(handle, action, captureSnapshot) {
|
|
|
94
95
|
* @param snapshotStore - Snapshot store to update with fresh snapshot
|
|
95
96
|
* @returns Action result with page brief and metadata
|
|
96
97
|
*/
|
|
97
|
-
export async function executeActionWithRetry(handle, node, action, snapshotStore, captureSnapshot) {
|
|
98
|
+
export async function executeActionWithRetry(handle, node, action, ctx, snapshotStore, captureSnapshot) {
|
|
98
99
|
let success = true;
|
|
99
100
|
let error;
|
|
100
101
|
let retried = false;
|
|
101
102
|
// Record pre-action timestamp for observation capture
|
|
102
103
|
const actionStartTime = Date.now();
|
|
103
104
|
// Ensure observation accumulator is injected
|
|
104
|
-
await
|
|
105
|
+
await ctx.getObservationAccumulator().ensureInjected(handle.page);
|
|
105
106
|
const capture = captureSnapshot ?? (() => captureSnapshotFallback(handle));
|
|
106
107
|
// Try the action
|
|
107
108
|
try {
|
|
@@ -143,19 +144,23 @@ export async function executeActionWithRetry(handle, node, action, snapshotStore
|
|
|
143
144
|
// Stabilize page after action (handles both SPA updates and full navigations)
|
|
144
145
|
await stabilizeAfterAction(handle.page);
|
|
145
146
|
// Capture observations from the action window
|
|
146
|
-
const observations = await
|
|
147
|
+
const observations = await ctx
|
|
148
|
+
.getObservationAccumulator()
|
|
149
|
+
.getObservations(handle.page, actionStartTime);
|
|
147
150
|
// Capture final snapshot
|
|
148
151
|
const captureResult = await capture();
|
|
149
152
|
const snapshot = captureResult.snapshot;
|
|
150
153
|
// Filter observations to reduce noise (threshold 5 requires semantic signals)
|
|
151
|
-
const filteredObservations =
|
|
154
|
+
const filteredObservations = ctx
|
|
155
|
+
.getObservationAccumulator()
|
|
156
|
+
.filterBySignificance(observations, ATTACHMENT_SIGNIFICANCE_THRESHOLD);
|
|
152
157
|
// Attach observations to snapshot if any were captured
|
|
153
158
|
if (filteredObservations.duringAction.length > 0 ||
|
|
154
159
|
filteredObservations.sincePrevious.length > 0) {
|
|
155
160
|
snapshot.observations = filteredObservations;
|
|
156
161
|
}
|
|
157
162
|
// Generate state response using StateManager
|
|
158
|
-
const stateManager = getStateManager(handle.page_id);
|
|
163
|
+
const stateManager = ctx.getStateManager(handle.page_id);
|
|
159
164
|
// Get previous snapshot BEFORE generateResponse shifts it
|
|
160
165
|
const prevSnapshot = stateManager.getPreviousSnapshot();
|
|
161
166
|
const state_response = stateManager.generateResponse(snapshot);
|
|
@@ -163,7 +168,7 @@ export async function executeActionWithRetry(handle, node, action, snapshotStore
|
|
|
163
168
|
if (success) {
|
|
164
169
|
const effect = computeObservedEffect(node.node_id, 'type', prevSnapshot, snapshot);
|
|
165
170
|
if (effect) {
|
|
166
|
-
getDependencyTracker().recordEffect(handle.page_id, effect);
|
|
171
|
+
ctx.getDependencyTracker().recordEffect(handle.page_id, effect);
|
|
167
172
|
}
|
|
168
173
|
}
|
|
169
174
|
// Add note about retry if it happened
|
|
@@ -199,7 +204,7 @@ export async function executeActionWithRetry(handle, node, action, snapshotStore
|
|
|
199
204
|
* @param snapshotStore - Snapshot store to update with fresh snapshot
|
|
200
205
|
* @returns ActionResultWithOutcome including ClickOutcome
|
|
201
206
|
*/
|
|
202
|
-
export async function executeActionWithOutcome(handle, node, action, snapshotStore, captureSnapshot) {
|
|
207
|
+
export async function executeActionWithOutcome(handle, node, action, ctx, snapshotStore, captureSnapshot) {
|
|
203
208
|
let success = true;
|
|
204
209
|
let error;
|
|
205
210
|
let retried = false;
|
|
@@ -207,7 +212,7 @@ export async function executeActionWithOutcome(handle, node, action, snapshotSto
|
|
|
207
212
|
// Record pre-action timestamp for observation capture
|
|
208
213
|
const actionStartTime = Date.now();
|
|
209
214
|
// Ensure observation accumulator is injected
|
|
210
|
-
await
|
|
215
|
+
await ctx.getObservationAccumulator().ensureInjected(handle.page);
|
|
211
216
|
const capture = captureSnapshot ?? (() => captureSnapshotFallback(handle));
|
|
212
217
|
// Capture pre-click navigation state
|
|
213
218
|
const preClickState = await captureNavigationState(handle);
|
|
@@ -219,7 +224,7 @@ export async function executeActionWithOutcome(handle, node, action, snapshotSto
|
|
|
219
224
|
const navigated = checkNavigationOccurred(preClickState, postClickState);
|
|
220
225
|
// Clear dependency tracker on navigation (old dependencies no longer valid)
|
|
221
226
|
if (navigated) {
|
|
222
|
-
getDependencyTracker().clearPage(handle.page_id);
|
|
227
|
+
ctx.getDependencyTracker().clearPage(handle.page_id);
|
|
223
228
|
}
|
|
224
229
|
outcome = { status: 'success', navigated };
|
|
225
230
|
}
|
|
@@ -232,7 +237,7 @@ export async function executeActionWithOutcome(handle, node, action, snapshotSto
|
|
|
232
237
|
if (isNavigation) {
|
|
233
238
|
// Element gone due to navigation - this is often success!
|
|
234
239
|
// Clear dependency tracker on navigation (old dependencies no longer valid)
|
|
235
|
-
getDependencyTracker().clearPage(handle.page_id);
|
|
240
|
+
ctx.getDependencyTracker().clearPage(handle.page_id);
|
|
236
241
|
outcome = { status: 'success', navigated: true };
|
|
237
242
|
// Don't retry - navigation happened
|
|
238
243
|
}
|
|
@@ -255,12 +260,16 @@ export async function executeActionWithOutcome(handle, node, action, snapshotSto
|
|
|
255
260
|
// Stabilize page after action (handles both SPA updates and full navigations)
|
|
256
261
|
await stabilizeAfterAction(handle.page);
|
|
257
262
|
// Capture observations from the action window
|
|
258
|
-
const observations = await
|
|
263
|
+
const observations = await ctx
|
|
264
|
+
.getObservationAccumulator()
|
|
265
|
+
.getObservations(handle.page, actionStartTime);
|
|
259
266
|
// Capture final snapshot
|
|
260
267
|
const captureResult = await capture();
|
|
261
268
|
const snapshot = captureResult.snapshot;
|
|
262
269
|
// Filter observations to reduce noise (threshold 5 requires semantic signals)
|
|
263
|
-
const filteredObservations =
|
|
270
|
+
const filteredObservations = ctx
|
|
271
|
+
.getObservationAccumulator()
|
|
272
|
+
.filterBySignificance(observations, ATTACHMENT_SIGNIFICANCE_THRESHOLD);
|
|
264
273
|
// Attach observations to snapshot if any were captured
|
|
265
274
|
if (filteredObservations.duringAction.length > 0 ||
|
|
266
275
|
filteredObservations.sincePrevious.length > 0) {
|
|
@@ -273,14 +282,14 @@ export async function executeActionWithOutcome(handle, node, action, snapshotSto
|
|
|
273
282
|
const postStabilizeUrl = handle.page.url();
|
|
274
283
|
if (postStabilizeUrl !== preClickState.url) {
|
|
275
284
|
outcome = { status: 'success', navigated: true };
|
|
276
|
-
getDependencyTracker().clearPage(handle.page_id);
|
|
285
|
+
ctx.getDependencyTracker().clearPage(handle.page_id);
|
|
277
286
|
}
|
|
278
287
|
}
|
|
279
288
|
// Determine if click caused a navigation (used for trimming and dependency tracking)
|
|
280
289
|
const didNavigate = outcome.status === 'success' && outcome.navigated;
|
|
281
290
|
// Generate state response using StateManager
|
|
282
291
|
// Trim regions when navigation occurred (same rationale as navigate() tool)
|
|
283
|
-
const stateManager = getStateManager(handle.page_id);
|
|
292
|
+
const stateManager = ctx.getStateManager(handle.page_id);
|
|
284
293
|
// Get previous snapshot BEFORE generateResponse shifts it
|
|
285
294
|
const prevSnapshot = stateManager.getPreviousSnapshot();
|
|
286
295
|
const state_response = stateManager.generateResponse(snapshot, didNavigate ? { trimRegions: true } : undefined);
|
|
@@ -288,7 +297,7 @@ export async function executeActionWithOutcome(handle, node, action, snapshotSto
|
|
|
288
297
|
if (success && !didNavigate) {
|
|
289
298
|
const effect = computeObservedEffect(node.node_id, 'click', prevSnapshot, snapshot);
|
|
290
299
|
if (effect) {
|
|
291
|
-
getDependencyTracker().recordEffect(handle.page_id, effect);
|
|
300
|
+
ctx.getDependencyTracker().recordEffect(handle.page_id, effect);
|
|
292
301
|
}
|
|
293
302
|
}
|
|
294
303
|
// Add note about retry if it happened and we recovered
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"execute-action.js","sourceRoot":"","sources":["../../../src/tools/execute-action.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAOH,OAAO,EA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AI,CAAC,UAAU;QACpC,iBAAiB,EAAE,QAAQ,CAAC,IAAI,CAAC,iBAAiB;QAClD,cAAc;QACd,KAAK;QACL,QAAQ;QACR,cAAc,EAAE,aAAa,CAAC,cAAc;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -5,13 +5,8 @@
|
|
|
5
5
|
* Provides semantic understanding of form-like interactions.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
+
import type { ToolContext } from './tool-context.types.js';
|
|
8
9
|
import { type FormRegion, type FormField, type FormAction, type FieldDependency } from '../form/index.js';
|
|
9
|
-
import type { SessionManager } from '../browser/session-manager.js';
|
|
10
|
-
/**
|
|
11
|
-
* Initialize form tools with a session manager instance.
|
|
12
|
-
* @deprecated Use initializeToolContext() instead. Kept for backward compatibility.
|
|
13
|
-
*/
|
|
14
|
-
export declare function initializeFormTools(_manager: SessionManager): void;
|
|
15
10
|
/**
|
|
16
11
|
* get_form input schema
|
|
17
12
|
*/
|
|
@@ -95,13 +90,13 @@ export declare const _testExports: {
|
|
|
95
90
|
* dependencies, and state. Reads actual runtime values via CDP
|
|
96
91
|
* to provide accurate filled/has_value status.
|
|
97
92
|
*/
|
|
98
|
-
export declare function getFormUnderstanding(rawInput: unknown): Promise<string>;
|
|
93
|
+
export declare function getFormUnderstanding(rawInput: unknown, ctx: ToolContext): Promise<string>;
|
|
99
94
|
/**
|
|
100
95
|
* Get context for a specific field.
|
|
101
96
|
*
|
|
102
97
|
* Returns detailed information about a field including purpose inference,
|
|
103
98
|
* constraints, dependencies, and suggested next action.
|
|
104
99
|
*/
|
|
105
|
-
export declare function getFieldContext(rawInput: unknown): string;
|
|
100
|
+
export declare function getFieldContext(rawInput: unknown, ctx: ToolContext): string;
|
|
106
101
|
export {};
|
|
107
102
|
//# sourceMappingURL=form-tools.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"form-tools.d.ts","sourceRoot":"","sources":["../../../src/tools/form-tools.ts"],"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MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG,SAAS,CAsC5D;AAED;;;;;GAKG;AACH,iBAAS,oBAAoB,CAC3B,KAAK,EAAE,SAAS,EAChB,IAAI,EAAE,UAAU,EAChB,YAAY,EAAE,eAAe,EAAE,GAC9B,MAAM,CAgGR;AAMD,0CAA0C;AAC1C,eAAO,MAAM,YAAY;;;;;;CAMxB,CAAC;AAMF;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CA4F/F;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,WAAW,GAAG,MAAM,CAwC3E"}
|
|
@@ -5,15 +5,35 @@
|
|
|
5
5
|
* Provides semantic understanding of form-like interactions.
|
|
6
6
|
*/
|
|
7
7
|
import { z } from 'zod';
|
|
8
|
-
import {
|
|
9
|
-
import { detectForms, getDependencyTracker, computeFormState, readRuntimeValues, } from '../form/index.js';
|
|
8
|
+
import { detectForms, computeFormState, readRuntimeValues, } from '../form/index.js';
|
|
10
9
|
import { escapeXml } from '../lib/text-utils.js';
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
*
|
|
11
|
+
* Resolve internal node_ids to stable semantic eids on all form fields and actions.
|
|
12
|
+
* Option eids (radio buttons) require a node_id→backend_node_id map from the snapshot.
|
|
14
13
|
*/
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
function resolveFormEids(forms, registry, nodes) {
|
|
15
|
+
const resolve = (backendNodeId) => registry.getEidByBackendNodeId(backendNodeId);
|
|
16
|
+
const nodeIdToBackendId = nodes
|
|
17
|
+
? new Map(nodes.map((n) => [n.node_id, n.backend_node_id]))
|
|
18
|
+
: undefined;
|
|
19
|
+
for (const form of forms) {
|
|
20
|
+
for (const field of form.fields) {
|
|
21
|
+
field.eid = resolve(field.backend_node_id) ?? field.eid;
|
|
22
|
+
if (nodeIdToBackendId && field.constraints.options) {
|
|
23
|
+
for (const opt of field.constraints.options) {
|
|
24
|
+
if (opt.eid) {
|
|
25
|
+
const backendId = nodeIdToBackendId.get(opt.eid);
|
|
26
|
+
if (backendId !== undefined) {
|
|
27
|
+
opt.eid = resolve(backendId) ?? opt.eid;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
for (const action of form.actions) {
|
|
34
|
+
action.eid = resolve(action.backend_node_id) ?? action.eid;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
17
37
|
}
|
|
18
38
|
// ============================================================================
|
|
19
39
|
// Input/Output Schemas
|
|
@@ -282,20 +302,19 @@ export const _testExports = {
|
|
|
282
302
|
* dependencies, and state. Reads actual runtime values via CDP
|
|
283
303
|
* to provide accurate filled/has_value status.
|
|
284
304
|
*/
|
|
285
|
-
export async function getFormUnderstanding(rawInput) {
|
|
305
|
+
export async function getFormUnderstanding(rawInput, ctx) {
|
|
286
306
|
const input = GetFormUnderstandingInputSchema.parse(rawInput);
|
|
287
|
-
const
|
|
288
|
-
const snapshotStore = getSnapshotStore();
|
|
307
|
+
const snapshotStore = ctx.getSnapshotStore();
|
|
289
308
|
// Resolve page with CDP client for runtime value reading
|
|
290
|
-
const handle = resolveExistingPage(
|
|
309
|
+
const handle = ctx.resolveExistingPage(input.page_id);
|
|
291
310
|
const pageId = handle.page_id;
|
|
292
311
|
// Get snapshot for the page
|
|
293
312
|
const snapshot = snapshotStore.getByPageId(pageId);
|
|
294
313
|
if (!snapshot) {
|
|
295
314
|
return '<error>No snapshot available. Use snapshot first.</error>';
|
|
296
315
|
}
|
|
297
|
-
// Detect forms
|
|
298
316
|
const allForms = detectForms(snapshot);
|
|
317
|
+
resolveFormEids(allForms, ctx.getStateManager(pageId).getElementRegistry(), snapshot.nodes);
|
|
299
318
|
// Filter by form_id if specified
|
|
300
319
|
const forms = input.form_id ? allForms.filter((f) => f.form_id === input.form_id) : allForms;
|
|
301
320
|
if (forms.length === 0 && input.form_id) {
|
|
@@ -310,7 +329,8 @@ export async function getFormUnderstanding(rawInput) {
|
|
|
310
329
|
backend_node_id: f.backend_node_id,
|
|
311
330
|
frame_id: f.frame_id,
|
|
312
331
|
semantic_type: f.purpose.semantic_type,
|
|
313
|
-
input_type: snapshot.nodes.find((n) => n.
|
|
332
|
+
input_type: snapshot.nodes.find((n) => n.backend_node_id === f.backend_node_id)?.attributes
|
|
333
|
+
?.input_type,
|
|
314
334
|
label: f.label,
|
|
315
335
|
}));
|
|
316
336
|
const runtimeResult = await readRuntimeValues(handle.cdp, fieldRequests, {
|
|
@@ -346,7 +366,7 @@ export async function getFormUnderstanding(rawInput) {
|
|
|
346
366
|
}
|
|
347
367
|
}
|
|
348
368
|
// Enrich fields with observed dependencies
|
|
349
|
-
const tracker = getDependencyTracker();
|
|
369
|
+
const tracker = ctx.getDependencyTracker();
|
|
350
370
|
for (const form of forms) {
|
|
351
371
|
for (const field of form.fields) {
|
|
352
372
|
const deps = tracker.getDependenciesFor(pageId, field.eid);
|
|
@@ -367,12 +387,11 @@ export async function getFormUnderstanding(rawInput) {
|
|
|
367
387
|
* Returns detailed information about a field including purpose inference,
|
|
368
388
|
* constraints, dependencies, and suggested next action.
|
|
369
389
|
*/
|
|
370
|
-
export function getFieldContext(rawInput) {
|
|
390
|
+
export function getFieldContext(rawInput, ctx) {
|
|
371
391
|
const input = GetFieldContextInputSchema.parse(rawInput);
|
|
372
|
-
const
|
|
373
|
-
const snapshotStore = getSnapshotStore();
|
|
392
|
+
const snapshotStore = ctx.getSnapshotStore();
|
|
374
393
|
// Resolve page
|
|
375
|
-
const handle = resolveExistingPage(
|
|
394
|
+
const handle = ctx.resolveExistingPage(input.page_id);
|
|
376
395
|
const pageId = handle.page_id;
|
|
377
396
|
// Get snapshot for the page
|
|
378
397
|
const snapshot = snapshotStore.getByPageId(pageId);
|
|
@@ -381,6 +400,7 @@ export function getFieldContext(rawInput) {
|
|
|
381
400
|
}
|
|
382
401
|
// Find the field's form
|
|
383
402
|
const allForms = detectForms(snapshot);
|
|
403
|
+
resolveFormEids(allForms, ctx.getStateManager(pageId).getElementRegistry());
|
|
384
404
|
let targetField;
|
|
385
405
|
let targetForm;
|
|
386
406
|
for (const form of allForms) {
|
|
@@ -395,7 +415,7 @@ export function getFieldContext(rawInput) {
|
|
|
395
415
|
return `<error>Field not found in any form: ${escapeXml(input.eid)}</error>`;
|
|
396
416
|
}
|
|
397
417
|
// Get dependencies
|
|
398
|
-
const tracker = getDependencyTracker();
|
|
418
|
+
const tracker = ctx.getDependencyTracker();
|
|
399
419
|
const dependencies = tracker.getDependenciesFor(pageId, input.eid);
|
|
400
420
|
return buildFieldContextXml(targetField, targetForm, dependencies);
|
|
401
421
|
}
|