@xoxoai/checkmate 0.4.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 +244 -0
- package/dist/ai/client.d.ts +49 -0
- package/dist/ai/client.d.ts.map +1 -0
- package/dist/ai/client.js +244 -0
- package/dist/ai/client.js.map +1 -0
- package/dist/ai/message-handler.d.ts +11 -0
- package/dist/ai/message-handler.d.ts.map +1 -0
- package/dist/ai/message-handler.js +33 -0
- package/dist/ai/message-handler.js.map +1 -0
- package/dist/ai/message-history.d.ts +19 -0
- package/dist/ai/message-history.d.ts.map +1 -0
- package/dist/ai/message-history.js +48 -0
- package/dist/ai/message-history.js.map +1 -0
- package/dist/ai/prompts.d.ts +4 -0
- package/dist/ai/prompts.d.ts.map +1 -0
- package/dist/ai/prompts.js +24 -0
- package/dist/ai/prompts.js.map +1 -0
- package/dist/ai/rate-limit-policy.d.ts +7 -0
- package/dist/ai/rate-limit-policy.d.ts.map +1 -0
- package/dist/ai/rate-limit-policy.js +17 -0
- package/dist/ai/rate-limit-policy.js.map +1 -0
- package/dist/ai/response-processor.d.ts +20 -0
- package/dist/ai/response-processor.d.ts.map +1 -0
- package/dist/ai/response-processor.js +62 -0
- package/dist/ai/response-processor.js.map +1 -0
- package/dist/ai/token-pricing.d.ts +13 -0
- package/dist/ai/token-pricing.d.ts.map +1 -0
- package/dist/ai/token-pricing.js +348 -0
- package/dist/ai/token-pricing.js.map +1 -0
- package/dist/ai/token-tracker.d.ts +33 -0
- package/dist/ai/token-tracker.d.ts.map +1 -0
- package/dist/ai/token-tracker.js +138 -0
- package/dist/ai/token-tracker.js.map +1 -0
- package/dist/ai/tool-response-handler.d.ts +21 -0
- package/dist/ai/tool-response-handler.d.ts.map +1 -0
- package/dist/ai/tool-response-handler.js +54 -0
- package/dist/ai/tool-response-handler.js.map +1 -0
- package/dist/config/runtime-config.d.ts +21 -0
- package/dist/config/runtime-config.d.ts.map +1 -0
- package/dist/config/runtime-config.js +98 -0
- package/dist/config/runtime-config.js.map +1 -0
- package/dist/core.d.ts +8 -0
- package/dist/core.d.ts.map +1 -0
- package/dist/core.js +4 -0
- package/dist/core.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/integrations/salesforce/authenticator.d.ts +27 -0
- package/dist/integrations/salesforce/authenticator.d.ts.map +1 -0
- package/dist/integrations/salesforce/authenticator.js +27 -0
- package/dist/integrations/salesforce/authenticator.js.map +1 -0
- package/dist/integrations/salesforce/cli-handler.d.ts +14 -0
- package/dist/integrations/salesforce/cli-handler.d.ts.map +1 -0
- package/dist/integrations/salesforce/cli-handler.js +50 -0
- package/dist/integrations/salesforce/cli-handler.js.map +1 -0
- package/dist/logging/index.d.ts +2 -0
- package/dist/logging/index.d.ts.map +1 -0
- package/dist/logging/index.js +4 -0
- package/dist/logging/index.js.map +1 -0
- package/dist/logging/logger.d.ts +5 -0
- package/dist/logging/logger.d.ts.map +1 -0
- package/dist/logging/logger.js +15 -0
- package/dist/logging/logger.js.map +1 -0
- package/dist/playwright.d.ts +102 -0
- package/dist/playwright.d.ts.map +1 -0
- package/dist/playwright.js +116 -0
- package/dist/playwright.js.map +1 -0
- package/dist/runtime/extension.d.ts +274 -0
- package/dist/runtime/extension.d.ts.map +1 -0
- package/dist/runtime/extension.js +171 -0
- package/dist/runtime/extension.js.map +1 -0
- package/dist/runtime/runner.d.ts +94 -0
- package/dist/runtime/runner.d.ts.map +1 -0
- package/dist/runtime/runner.js +86 -0
- package/dist/runtime/runner.js.map +1 -0
- package/dist/runtime/step-execution.d.ts +17 -0
- package/dist/runtime/step-execution.d.ts.map +1 -0
- package/dist/runtime/step-execution.js +49 -0
- package/dist/runtime/step-execution.js.map +1 -0
- package/dist/runtime/types.d.ts +79 -0
- package/dist/runtime/types.d.ts.map +1 -0
- package/dist/runtime/types.js +2 -0
- package/dist/runtime/types.js.map +1 -0
- package/dist/salesforce.d.ts +71 -0
- package/dist/salesforce.d.ts.map +1 -0
- package/dist/salesforce.js +73 -0
- package/dist/salesforce.js.map +1 -0
- package/dist/tools/browser/screenshot-service.d.ts +10 -0
- package/dist/tools/browser/screenshot-service.d.ts.map +1 -0
- package/dist/tools/browser/screenshot-service.js +23 -0
- package/dist/tools/browser/screenshot-service.js.map +1 -0
- package/dist/tools/browser/snapshot-filter/index.d.ts +4 -0
- package/dist/tools/browser/snapshot-filter/index.d.ts.map +1 -0
- package/dist/tools/browser/snapshot-filter/index.js +4 -0
- package/dist/tools/browser/snapshot-filter/index.js.map +1 -0
- package/dist/tools/browser/snapshot-filter/semantic-scorer.d.ts +15 -0
- package/dist/tools/browser/snapshot-filter/semantic-scorer.d.ts.map +1 -0
- package/dist/tools/browser/snapshot-filter/semantic-scorer.js +99 -0
- package/dist/tools/browser/snapshot-filter/semantic-scorer.js.map +1 -0
- package/dist/tools/browser/snapshot-filter/snapshot-filter.d.ts +4 -0
- package/dist/tools/browser/snapshot-filter/snapshot-filter.d.ts.map +1 -0
- package/dist/tools/browser/snapshot-filter/snapshot-filter.js +57 -0
- package/dist/tools/browser/snapshot-filter/snapshot-filter.js.map +1 -0
- package/dist/tools/browser/snapshot-filter/tree-reconstructor.d.ts +3 -0
- package/dist/tools/browser/snapshot-filter/tree-reconstructor.d.ts.map +1 -0
- package/dist/tools/browser/snapshot-filter/tree-reconstructor.js +85 -0
- package/dist/tools/browser/snapshot-filter/tree-reconstructor.js.map +1 -0
- package/dist/tools/browser/snapshot-service.d.ts +19 -0
- package/dist/tools/browser/snapshot-service.d.ts.map +1 -0
- package/dist/tools/browser/snapshot-service.js +67 -0
- package/dist/tools/browser/snapshot-service.js.map +1 -0
- package/dist/tools/browser/tool.d.ts +34 -0
- package/dist/tools/browser/tool.d.ts.map +1 -0
- package/dist/tools/browser/tool.js +226 -0
- package/dist/tools/browser/tool.js.map +1 -0
- package/dist/tools/browser/transient-state-tracker.d.ts +16 -0
- package/dist/tools/browser/transient-state-tracker.d.ts.map +1 -0
- package/dist/tools/browser/transient-state-tracker.js +266 -0
- package/dist/tools/browser/transient-state-tracker.js.map +1 -0
- package/dist/tools/define-agent-tool.d.ts +45 -0
- package/dist/tools/define-agent-tool.d.ts.map +1 -0
- package/dist/tools/define-agent-tool.js +55 -0
- package/dist/tools/define-agent-tool.js.map +1 -0
- package/dist/tools/dispatcher.d.ts +11 -0
- package/dist/tools/dispatcher.d.ts.map +1 -0
- package/dist/tools/dispatcher.js +49 -0
- package/dist/tools/dispatcher.js.map +1 -0
- package/dist/tools/loop-detector.d.ts +27 -0
- package/dist/tools/loop-detector.d.ts.map +1 -0
- package/dist/tools/loop-detector.js +76 -0
- package/dist/tools/loop-detector.js.map +1 -0
- package/dist/tools/registry.d.ts +21 -0
- package/dist/tools/registry.d.ts.map +1 -0
- package/dist/tools/registry.js +46 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/salesforce/login-tool.d.ts +7 -0
- package/dist/tools/salesforce/login-tool.d.ts.map +1 -0
- package/dist/tools/salesforce/login-tool.js +25 -0
- package/dist/tools/salesforce/login-tool.js.map +1 -0
- package/dist/tools/step/result-tool.d.ts +7 -0
- package/dist/tools/step/result-tool.d.ts.map +1 -0
- package/dist/tools/step/result-tool.js +32 -0
- package/dist/tools/step/result-tool.js.map +1 -0
- package/dist/tools/tool-contract.d.ts +3 -0
- package/dist/tools/tool-contract.d.ts.map +1 -0
- package/dist/tools/tool-contract.js +2 -0
- package/dist/tools/tool-contract.js.map +1 -0
- package/dist/tools/types.d.ts +139 -0
- package/dist/tools/types.d.ts.map +1 -0
- package/dist/tools/types.js +4 -0
- package/dist/tools/types.js.map +1 -0
- package/docs/EXTENSIONS.md +233 -0
- package/docs/GUIDE.md +467 -0
- package/docs/ROADMAP.md +47 -0
- package/package.json +106 -0
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { RuntimeConfig } from '../config/runtime-config';
|
|
2
|
+
import { Step } from './types';
|
|
3
|
+
import { CheckmateExtension } from './extension';
|
|
4
|
+
/**
|
|
5
|
+
* Options for creating a Checkmate runner.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* import { createRunner } from '@xoxoai/checkmate/core'
|
|
10
|
+
* import { web } from '@xoxoai/checkmate/playwright'
|
|
11
|
+
*
|
|
12
|
+
* const ai = createRunner({
|
|
13
|
+
* extensions: [web({ page })],
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export type CheckmateRunnerOptions = {
|
|
18
|
+
/**
|
|
19
|
+
* Extensions to compose into the runner.
|
|
20
|
+
*/
|
|
21
|
+
extensions?: CheckmateExtension[];
|
|
22
|
+
/**
|
|
23
|
+
* Advanced: provide a custom runtime config instance.
|
|
24
|
+
*/
|
|
25
|
+
runtimeConfig?: RuntimeConfig;
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Public runtime entry point for executing natural-language steps with Checkmate.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```ts
|
|
32
|
+
* const runner = new CheckmateRunner()
|
|
33
|
+
* await runner.run({
|
|
34
|
+
* action: 'Open the pricing page',
|
|
35
|
+
* expect: 'Pricing details are visible',
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare class CheckmateRunner {
|
|
40
|
+
private readonly aiClient;
|
|
41
|
+
private readonly extensionHost;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a new runner composed from extensions.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```ts
|
|
47
|
+
* const ai = new CheckmateRunner({
|
|
48
|
+
* extensions: [web({ page })],
|
|
49
|
+
* })
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
52
|
+
constructor(options?: CheckmateRunnerOptions);
|
|
53
|
+
/**
|
|
54
|
+
* Releases any runner-owned resources.
|
|
55
|
+
*
|
|
56
|
+
* @example
|
|
57
|
+
* ```ts
|
|
58
|
+
* await ai.teardown()
|
|
59
|
+
* ```
|
|
60
|
+
*/
|
|
61
|
+
teardown(): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* Executes one natural-language test step.
|
|
64
|
+
*
|
|
65
|
+
* @param step - The step definition to execute.
|
|
66
|
+
*
|
|
67
|
+
* @example
|
|
68
|
+
* ```ts
|
|
69
|
+
* await runner.run({
|
|
70
|
+
* action: 'Search for qwen3-vl',
|
|
71
|
+
* expect: 'The qwen3-vl model page is displayed',
|
|
72
|
+
* topPercent: 10,
|
|
73
|
+
* })
|
|
74
|
+
* ```
|
|
75
|
+
*/
|
|
76
|
+
run(step: Step): Promise<void>;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Creates a runner from the provided extensions.
|
|
80
|
+
*
|
|
81
|
+
* This is the main programmatic entry point from `@xoxoai/checkmate/core`.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* ```ts
|
|
85
|
+
* import { createRunner } from '@xoxoai/checkmate/core'
|
|
86
|
+
* import { web } from '@xoxoai/checkmate/playwright'
|
|
87
|
+
*
|
|
88
|
+
* const ai = createRunner({
|
|
89
|
+
* extensions: [web({ page })],
|
|
90
|
+
* })
|
|
91
|
+
* ```
|
|
92
|
+
*/
|
|
93
|
+
export declare function createRunner(options?: CheckmateRunnerOptions): CheckmateRunner;
|
|
94
|
+
//# sourceMappingURL=runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/runtime/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AACxD,OAAO,EAAE,IAAI,EAAE,MAAM,SAAS,CAAA;AAK9B,OAAO,EAAE,kBAAkB,EAAiB,MAAM,aAAa,CAAA;AAE/D;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,sBAAsB,GAAG;IACpC;;OAEG;IACH,UAAU,CAAC,EAAE,kBAAkB,EAAE,CAAA;IAEjC;;OAEG;IACH,aAAa,CAAC,EAAE,aAAa,CAAA;CAC7B,CAAA;AAED;;;;;;;;;;;GAWG;AACH,qBAAa,eAAe;IAC3B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAU;IACnC,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAe;IAE7C;;;;;;;;;OASG;gBACS,OAAO,GAAE,sBAA2B;IAQhD;;;;;;;OAOG;IACG,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;IAI/B;;;;;;;;;;;;;OAaG;IACG,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;CAGpC;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,YAAY,CAAC,OAAO,GAAE,sBAA2B,GAAG,eAAe,CAElF"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { RuntimeConfig } from '../config/runtime-config';
|
|
2
|
+
import { createStepResultTools } from '../tools/step/result-tool';
|
|
3
|
+
import { ToolRegistry } from '../tools/registry';
|
|
4
|
+
import { AiClient } from '../ai/client';
|
|
5
|
+
import { StepExecution } from './step-execution';
|
|
6
|
+
import { ExtensionHost } from './extension';
|
|
7
|
+
/**
|
|
8
|
+
* Public runtime entry point for executing natural-language steps with Checkmate.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* const runner = new CheckmateRunner()
|
|
13
|
+
* await runner.run({
|
|
14
|
+
* action: 'Open the pricing page',
|
|
15
|
+
* expect: 'Pricing details are visible',
|
|
16
|
+
* })
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class CheckmateRunner {
|
|
20
|
+
aiClient;
|
|
21
|
+
extensionHost;
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new runner composed from extensions.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* const ai = new CheckmateRunner({
|
|
28
|
+
* extensions: [web({ page })],
|
|
29
|
+
* })
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
32
|
+
constructor(options = {}) {
|
|
33
|
+
const runtimeConfig = options.runtimeConfig ?? new RuntimeConfig();
|
|
34
|
+
const toolRegistry = new ToolRegistry(runtimeConfig);
|
|
35
|
+
toolRegistry.register(createStepResultTools());
|
|
36
|
+
this.extensionHost = new ExtensionHost(runtimeConfig, toolRegistry, options.extensions ?? []);
|
|
37
|
+
this.aiClient = new AiClient({ runtimeConfig, toolRegistry, extensionHost: this.extensionHost });
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Releases any runner-owned resources.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```ts
|
|
44
|
+
* await ai.teardown()
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
async teardown() {
|
|
48
|
+
await this.extensionHost.teardown();
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Executes one natural-language test step.
|
|
52
|
+
*
|
|
53
|
+
* @param step - The step definition to execute.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* await runner.run({
|
|
58
|
+
* action: 'Search for qwen3-vl',
|
|
59
|
+
* expect: 'The qwen3-vl model page is displayed',
|
|
60
|
+
* topPercent: 10,
|
|
61
|
+
* })
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
64
|
+
async run(step) {
|
|
65
|
+
await new StepExecution(this.aiClient, this.extensionHost).run(step);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Creates a runner from the provided extensions.
|
|
70
|
+
*
|
|
71
|
+
* This is the main programmatic entry point from `@xoxoai/checkmate/core`.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* import { createRunner } from '@xoxoai/checkmate/core'
|
|
76
|
+
* import { web } from '@xoxoai/checkmate/playwright'
|
|
77
|
+
*
|
|
78
|
+
* const ai = createRunner({
|
|
79
|
+
* extensions: [web({ page })],
|
|
80
|
+
* })
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export function createRunner(options = {}) {
|
|
84
|
+
return new CheckmateRunner(options);
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/runtime/runner.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAA;AAExD,OAAO,EAAE,qBAAqB,EAAE,MAAM,2BAA2B,CAAA;AACjE,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAA;AAChD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAChD,OAAO,EAAsB,aAAa,EAAE,MAAM,aAAa,CAAA;AA2B/D;;;;;;;;;;;GAWG;AACH,MAAM,OAAO,eAAe;IACV,QAAQ,CAAU;IAClB,aAAa,CAAe;IAE7C;;;;;;;;;OASG;IACH,YAAY,UAAkC,EAAE;QAC/C,MAAM,aAAa,GAAG,OAAO,CAAC,aAAa,IAAI,IAAI,aAAa,EAAE,CAAA;QAClE,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,aAAa,CAAC,CAAA;QACpD,YAAY,CAAC,QAAQ,CAAC,qBAAqB,EAAE,CAAC,CAAA;QAC9C,IAAI,CAAC,aAAa,GAAG,IAAI,aAAa,CAAC,aAAa,EAAE,YAAY,EAAE,OAAO,CAAC,UAAU,IAAI,EAAE,CAAC,CAAA;QAC7F,IAAI,CAAC,QAAQ,GAAG,IAAI,QAAQ,CAAC,EAAE,aAAa,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,CAAC,aAAa,EAAE,CAAC,CAAA;IACjG,CAAC;IAED;;;;;;;OAOG;IACH,KAAK,CAAC,QAAQ;QACb,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAA;IACpC,CAAC;IAED;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,GAAG,CAAC,IAAU;QACnB,MAAM,IAAI,aAAa,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,aAAa,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;IACrE,CAAC;CACD;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,YAAY,CAAC,UAAkC,EAAE;IAChE,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAA;AACpC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { Step } from './types';
|
|
2
|
+
import { AiClient } from '../ai/client';
|
|
3
|
+
import { ExtensionHost } from './extension';
|
|
4
|
+
export declare class StepExecution {
|
|
5
|
+
private readonly aiClient;
|
|
6
|
+
private readonly extensionHost;
|
|
7
|
+
private stepResult;
|
|
8
|
+
private resolveStepResult;
|
|
9
|
+
private readonly stepResultPromise;
|
|
10
|
+
constructor(aiClient: AiClient, extensionHost: ExtensionHost);
|
|
11
|
+
run(step: Step): Promise<void>;
|
|
12
|
+
private logStepStart;
|
|
13
|
+
private logStepFinish;
|
|
14
|
+
private assertStepResult;
|
|
15
|
+
private assertionMessage;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=step-execution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-execution.d.ts","sourceRoot":"","sources":["../../src/runtime/step-execution.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,IAAI,EAAoD,MAAM,SAAS,CAAA;AAGhF,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAA;AACvC,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAA;AAE3C,qBAAa,aAAa;IAMxB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa;IAN/B,OAAO,CAAC,UAAU,CAA4C;IAC9D,OAAO,CAAC,iBAAiB,CAAoB;IAC7C,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAmB;gBAGnC,QAAQ,EAAE,QAAQ,EAClB,aAAa,EAAE,aAAa;IAOxC,GAAG,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC;IAoBpC,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,aAAa;IAIrB,OAAO,CAAC,gBAAgB;IAIxB,OAAO,CAAC,gBAAgB;CAGxB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { expect } from '@playwright/test';
|
|
2
|
+
import { logger } from '../logging';
|
|
3
|
+
import { STEP_START_USER_PROMPT, STEP_SYSTEM_PROMPT } from '../ai/prompts';
|
|
4
|
+
import { MessageHistory } from '../ai/message-history';
|
|
5
|
+
export class StepExecution {
|
|
6
|
+
aiClient;
|
|
7
|
+
extensionHost;
|
|
8
|
+
stepResult = { passed: false, actual: '' };
|
|
9
|
+
resolveStepResult;
|
|
10
|
+
stepResultPromise;
|
|
11
|
+
constructor(aiClient, extensionHost) {
|
|
12
|
+
this.aiClient = aiClient;
|
|
13
|
+
this.extensionHost = extensionHost;
|
|
14
|
+
this.stepResultPromise = new Promise((resolve) => {
|
|
15
|
+
this.resolveStepResult = resolve;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
async run(step) {
|
|
19
|
+
this.logStepStart(step);
|
|
20
|
+
try {
|
|
21
|
+
await this.aiClient.initialize(step, this.resolveStepResult);
|
|
22
|
+
const initialMessages = new MessageHistory().buildInitialMessages({
|
|
23
|
+
systemPrompt: STEP_SYSTEM_PROMPT(this.extensionHost.getInstructions()),
|
|
24
|
+
userPrompt: STEP_START_USER_PROMPT(step),
|
|
25
|
+
contextMessages: await this.extensionHost.buildInitialMessages(step),
|
|
26
|
+
});
|
|
27
|
+
await this.aiClient.sendMessage(initialMessages);
|
|
28
|
+
this.stepResult = await this.stepResultPromise;
|
|
29
|
+
this.assertStepResult(step);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
throw new Error(`\nFailed to execute action:\n${step.action}`, { cause: error });
|
|
33
|
+
}
|
|
34
|
+
this.logStepFinish();
|
|
35
|
+
}
|
|
36
|
+
logStepStart(step) {
|
|
37
|
+
logger.info(`step started:\n${JSON.stringify(step, null, 2).replaceAll(' ', '').trim()}`);
|
|
38
|
+
}
|
|
39
|
+
logStepFinish() {
|
|
40
|
+
logger.info('step finished');
|
|
41
|
+
}
|
|
42
|
+
assertStepResult(step) {
|
|
43
|
+
expect(this.stepResult.passed, this.assertionMessage(step)).toBeTruthy();
|
|
44
|
+
}
|
|
45
|
+
assertionMessage(step) {
|
|
46
|
+
return this.stepResult.passed ? step.expect : `\nExpected: ${step.expect}\nActual: ${this.stepResult.actual}`;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=step-execution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"step-execution.js","sourceRoot":"","sources":["../../src/runtime/step-execution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAEnC,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AAItD,MAAM,OAAO,aAAa;IAMP;IACA;IANV,UAAU,GAAe,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAA;IACtD,iBAAiB,CAAoB;IAC5B,iBAAiB,CAAmB;IAErD,YACkB,QAAkB,EAClB,aAA4B;QAD5B,aAAQ,GAAR,QAAQ,CAAU;QAClB,kBAAa,GAAb,aAAa,CAAe;QAE7C,IAAI,CAAC,iBAAiB,GAAG,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,EAAE;YAC5D,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAA;QACjC,CAAC,CAAC,CAAA;IACH,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,IAAU;QACnB,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAA;QAEvB,IAAI,CAAC;YACJ,MAAM,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,iBAAiB,CAAC,CAAA;YAC5D,MAAM,eAAe,GAAG,IAAI,cAAc,EAAE,CAAC,oBAAoB,CAAC;gBACjE,YAAY,EAAE,kBAAkB,CAAC,IAAI,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;gBACtE,UAAU,EAAE,sBAAsB,CAAC,IAAI,CAAC;gBACxC,eAAe,EAAE,MAAM,IAAI,CAAC,aAAa,CAAC,oBAAoB,CAAC,IAAI,CAAC;aACpE,CAAC,CAAA;YACF,MAAM,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,eAAe,CAAC,CAAA;YAChD,IAAI,CAAC,UAAU,GAAG,MAAM,IAAI,CAAC,iBAAiB,CAAA;YAC9C,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAA;QAC5B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,MAAM,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QACjF,CAAC;QAED,IAAI,CAAC,aAAa,EAAE,CAAA;IACrB,CAAC;IAEO,YAAY,CAAC,IAAU;QAC9B,MAAM,CAAC,IAAI,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IAC3F,CAAC;IAEO,aAAa;QACpB,MAAM,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;IAC7B,CAAC;IAEO,gBAAgB,CAAC,IAAU;QAClC,MAAM,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,UAAU,EAAE,CAAA;IACzE,CAAC;IAEO,gBAAgB,CAAC,IAAU;QAClC,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,eAAe,IAAI,CAAC,MAAM,aAAa,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,CAAA;IAC9G,CAAC;CACD"}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A single natural-language test step executed by Checkmate.
|
|
3
|
+
*
|
|
4
|
+
* `action` should describe what the agent needs to do.
|
|
5
|
+
* `expect` should describe the expected result after the action finishes.
|
|
6
|
+
* `search` can bias snapshot filtering toward specific keywords.
|
|
7
|
+
* `topPercent` controls how much of the scored page snapshot is kept.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```ts
|
|
11
|
+
* const step: Step = {
|
|
12
|
+
* action: "Open the pricing page and click the Pro plan",
|
|
13
|
+
* expect: "The checkout page for the Pro plan is displayed",
|
|
14
|
+
* topPercent: 15,
|
|
15
|
+
* }
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export interface Step {
|
|
19
|
+
/**
|
|
20
|
+
* What the agent should do in the browser.
|
|
21
|
+
*/
|
|
22
|
+
action: string;
|
|
23
|
+
/**
|
|
24
|
+
* What should be true after the action is complete.
|
|
25
|
+
*/
|
|
26
|
+
expect: string;
|
|
27
|
+
/**
|
|
28
|
+
* Optional keyword hints for snapshot filtering.
|
|
29
|
+
*
|
|
30
|
+
* When provided, these terms are prioritized over semantic `action + expect` matching.
|
|
31
|
+
*/
|
|
32
|
+
search?: string[];
|
|
33
|
+
/**
|
|
34
|
+
* Optional percentage of the highest-scoring snapshot elements to keep.
|
|
35
|
+
*
|
|
36
|
+
* This value is expressed as a real percent from `1` to `100`.
|
|
37
|
+
* For example, `10` keeps the top 10% of scored elements.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* ```ts
|
|
41
|
+
* topPercent: 20
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
topPercent?: number;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Final result returned by a step execution.
|
|
48
|
+
*
|
|
49
|
+
* @example
|
|
50
|
+
* ```ts
|
|
51
|
+
* const result: StepResult = {
|
|
52
|
+
* passed: true,
|
|
53
|
+
* actual: 'Checkout page is visible',
|
|
54
|
+
* }
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export interface StepResult {
|
|
58
|
+
/**
|
|
59
|
+
* Whether the step passed.
|
|
60
|
+
*/
|
|
61
|
+
passed: boolean;
|
|
62
|
+
/**
|
|
63
|
+
* The observed result collected during execution.
|
|
64
|
+
*/
|
|
65
|
+
actual: string;
|
|
66
|
+
}
|
|
67
|
+
export type StepResultPromise = Promise<StepResult>;
|
|
68
|
+
/**
|
|
69
|
+
* Callback used internally to resolve a running step result.
|
|
70
|
+
*
|
|
71
|
+
* @example
|
|
72
|
+
* ```ts
|
|
73
|
+
* const resolve: ResolveStepResult = (result) => {
|
|
74
|
+
* console.log(result.actual)
|
|
75
|
+
* }
|
|
76
|
+
* ```
|
|
77
|
+
*/
|
|
78
|
+
export type ResolveStepResult = (result: StepResult) => void;
|
|
79
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,WAAW,IAAI;IACpB;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;IAEd;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IAEjB;;;;;;;;;;OAUG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;;GAUG;AACH,MAAM,WAAW,UAAU;IAC1B;;OAEG;IACH,MAAM,EAAE,OAAO,CAAA;IAEf;;OAEG;IACH,MAAM,EAAE,MAAM,CAAA;CACd;AAED,MAAM,MAAM,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,CAAA;AAEnD;;;;;;;;;GASG;AACH,MAAM,MAAM,iBAAiB,GAAG,CAAC,MAAM,EAAE,UAAU,KAAK,IAAI,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { expect, Page } from '@playwright/test';
|
|
2
|
+
import { CheckmateRunner } from './runtime/runner';
|
|
3
|
+
import { CheckmateExtension } from './runtime/extension';
|
|
4
|
+
/**
|
|
5
|
+
* Fixture type exported by `@xoxoai/checkmate/salesforce`.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```ts
|
|
9
|
+
* test('salesforce flow', async ({ ai }) => {
|
|
10
|
+
* await ai.run({
|
|
11
|
+
* action: 'Login to Salesforce org',
|
|
12
|
+
* expect: 'The Salesforce home page is displayed',
|
|
13
|
+
* })
|
|
14
|
+
* })
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export type SalesforceFixtures = {
|
|
18
|
+
/**
|
|
19
|
+
* Runner composed with the built-in web and Salesforce extensions.
|
|
20
|
+
*/
|
|
21
|
+
ai: CheckmateRunner;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Creates the built-in Salesforce extension.
|
|
25
|
+
*
|
|
26
|
+
* This extension adds Salesforce-specific tools on top of the web extension.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* import { createRunner } from '@xoxoai/checkmate/core'
|
|
31
|
+
* import { web } from '@xoxoai/checkmate/playwright'
|
|
32
|
+
* import { salesforce } from '@xoxoai/checkmate/salesforce'
|
|
33
|
+
*
|
|
34
|
+
* const ai = createRunner({
|
|
35
|
+
* extensions: [web({ page }), salesforce()],
|
|
36
|
+
* })
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
export declare function salesforce(): CheckmateExtension;
|
|
40
|
+
/**
|
|
41
|
+
* Creates a runner composed with the built-in web and Salesforce extensions.
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* import { createSalesforceRunner } from '@xoxoai/checkmate/salesforce'
|
|
46
|
+
*
|
|
47
|
+
* const ai = createSalesforceRunner(page)
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare function createSalesforceRunner(page: Page): CheckmateRunner;
|
|
51
|
+
/**
|
|
52
|
+
* Playwright Test fixture with the `ai` runner.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```ts
|
|
56
|
+
* import { test } from '@xoxoai/checkmate/salesforce'
|
|
57
|
+
*
|
|
58
|
+
* test('salesforce account creation', async ({ ai }) => {
|
|
59
|
+
* await ai.run({
|
|
60
|
+
* action: 'Login to Salesforce org',
|
|
61
|
+
* expect: 'The Salesforce home page is displayed',
|
|
62
|
+
* })
|
|
63
|
+
* })
|
|
64
|
+
* ```
|
|
65
|
+
*/
|
|
66
|
+
export declare const test: import("playwright/test").TestType<import("playwright/test").PlaywrightTestArgs & import("playwright/test").PlaywrightTestOptions & SalesforceFixtures, import("playwright/test").PlaywrightWorkerArgs & import("playwright/test").PlaywrightWorkerOptions>;
|
|
67
|
+
/**
|
|
68
|
+
* Re-export of Playwright's `expect` for convenience.
|
|
69
|
+
*/
|
|
70
|
+
export { expect };
|
|
71
|
+
//# sourceMappingURL=salesforce.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"salesforce.d.ts","sourceRoot":"","sources":["../src/salesforce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,IAAI,EAAgB,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAgB,eAAe,EAAE,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAE,kBAAkB,EAAmB,MAAM,qBAAqB,CAAA;AAKzE;;;;;;;;;;;;GAYG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAChC;;OAEG;IACH,EAAE,EAAE,eAAe,CAAA;CACnB,CAAA;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,UAAU,IAAI,kBAAkB,CAW/C;AAED;;;;;;;;;GASG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,IAAI,GAAG,eAAe,CAElE;AAED;;;;;;;;;;;;;;GAcG;AACH,eAAO,MAAM,IAAI,6PAMf,CAAA;AAEF;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { expect, test as base } from '@playwright/test';
|
|
2
|
+
import { createRunner } from './runtime/runner';
|
|
3
|
+
import { defineExtension } from './runtime/extension';
|
|
4
|
+
import { PlaywrightCapability, web } from './playwright';
|
|
5
|
+
import { createSalesforceTools, SalesforceLoginTool } from './tools/salesforce/login-tool';
|
|
6
|
+
/**
|
|
7
|
+
* Creates the built-in Salesforce extension.
|
|
8
|
+
*
|
|
9
|
+
* This extension adds Salesforce-specific tools on top of the web extension.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```ts
|
|
13
|
+
* import { createRunner } from '@xoxoai/checkmate/core'
|
|
14
|
+
* import { web } from '@xoxoai/checkmate/playwright'
|
|
15
|
+
* import { salesforce } from '@xoxoai/checkmate/salesforce'
|
|
16
|
+
*
|
|
17
|
+
* const ai = createRunner({
|
|
18
|
+
* extensions: [web({ page }), salesforce()],
|
|
19
|
+
* })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export function salesforce() {
|
|
23
|
+
return defineExtension({
|
|
24
|
+
name: 'salesforce',
|
|
25
|
+
instructions: [
|
|
26
|
+
`Use '${SalesforceLoginTool.TOOL_LOGIN_TO_SALESFORCE_ORG}' when the step requires logging into a Salesforce org.`,
|
|
27
|
+
],
|
|
28
|
+
setup(api) {
|
|
29
|
+
const browserRuntime = api.getCapability(PlaywrightCapability.BROWSER_RUNTIME);
|
|
30
|
+
api.addTool(createSalesforceTools(browserRuntime));
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Creates a runner composed with the built-in web and Salesforce extensions.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```ts
|
|
39
|
+
* import { createSalesforceRunner } from '@xoxoai/checkmate/salesforce'
|
|
40
|
+
*
|
|
41
|
+
* const ai = createSalesforceRunner(page)
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
export function createSalesforceRunner(page) {
|
|
45
|
+
return createRunner({ extensions: [web({ page }), salesforce()] });
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Playwright Test fixture with the `ai` runner.
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* ```ts
|
|
52
|
+
* import { test } from '@xoxoai/checkmate/salesforce'
|
|
53
|
+
*
|
|
54
|
+
* test('salesforce account creation', async ({ ai }) => {
|
|
55
|
+
* await ai.run({
|
|
56
|
+
* action: 'Login to Salesforce org',
|
|
57
|
+
* expect: 'The Salesforce home page is displayed',
|
|
58
|
+
* })
|
|
59
|
+
* })
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
62
|
+
export const test = base.extend({
|
|
63
|
+
ai: async ({ page }, use) => {
|
|
64
|
+
const ai = createSalesforceRunner(page);
|
|
65
|
+
await use(ai);
|
|
66
|
+
await ai.teardown();
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
/**
|
|
70
|
+
* Re-export of Playwright's `expect` for convenience.
|
|
71
|
+
*/
|
|
72
|
+
export { expect };
|
|
73
|
+
//# sourceMappingURL=salesforce.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"salesforce.js","sourceRoot":"","sources":["../src/salesforce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAQ,IAAI,IAAI,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAC7D,OAAO,EAAE,YAAY,EAAmB,MAAM,kBAAkB,CAAA;AAChE,OAAO,EAAsB,eAAe,EAAE,MAAM,qBAAqB,CAAA;AACzE,OAAO,EAAE,oBAAoB,EAAE,GAAG,EAAE,MAAM,cAAc,CAAA;AAExD,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAA;AAsB1F;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,UAAU;IACzB,OAAO,eAAe,CAAC;QACtB,IAAI,EAAE,YAAY;QAClB,YAAY,EAAE;YACb,QAAQ,mBAAmB,CAAC,4BAA4B,yDAAyD;SACjH;QACD,KAAK,CAAC,GAAG;YACR,MAAM,cAAc,GAAG,GAAG,CAAC,aAAa,CAAqB,oBAAoB,CAAC,eAAe,CAAC,CAAA;YAClG,GAAG,CAAC,OAAO,CAAC,qBAAqB,CAAC,cAAc,CAAC,CAAC,CAAA;QACnD,CAAC;KACD,CAAC,CAAA;AACH,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,sBAAsB,CAAC,IAAU;IAChD,OAAO,YAAY,CAAC,EAAE,UAAU,EAAE,CAAC,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,CAAC,CAAA;AACnE,CAAC;AAED;;;;;;;;;;;;;;GAcG;AACH,MAAM,CAAC,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAqB;IACnD,EAAE,EAAE,KAAK,EAAE,EAAE,IAAI,EAAE,EAAE,GAAG,EAAE,EAAE;QAC3B,MAAM,EAAE,GAAG,sBAAsB,CAAC,IAAI,CAAC,CAAA;QACvC,MAAM,GAAG,CAAC,EAAE,CAAC,CAAA;QACb,MAAM,EAAE,CAAC,QAAQ,EAAE,CAAA;IACpB,CAAC;CACD,CAAC,CAAA;AAEF;;GAEG;AACH,OAAO,EAAE,MAAM,EAAE,CAAA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Page } from '@playwright/test';
|
|
2
|
+
export declare class BrowserScreenshotService {
|
|
3
|
+
private readonly page;
|
|
4
|
+
constructor(page: Page);
|
|
5
|
+
getCompressedScreenshot(): Promise<{
|
|
6
|
+
mimeType?: string;
|
|
7
|
+
data: string;
|
|
8
|
+
}>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=screenshot-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot-service.d.ts","sourceRoot":"","sources":["../../../src/tools/browser/screenshot-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAA;AAGvC,qBAAa,wBAAwB;IACxB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,IAAI;IAEjC,uBAAuB,IAAI,OAAO,CAAC;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;CAe7E"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import sharp from 'sharp';
|
|
2
|
+
export class BrowserScreenshotService {
|
|
3
|
+
page;
|
|
4
|
+
constructor(page) {
|
|
5
|
+
this.page = page;
|
|
6
|
+
}
|
|
7
|
+
async getCompressedScreenshot() {
|
|
8
|
+
try {
|
|
9
|
+
const screenshot = await this.page.screenshot();
|
|
10
|
+
const compressedBuffer = await sharp(screenshot)
|
|
11
|
+
.resize({ width: 768, height: 768, fit: 'inside' })
|
|
12
|
+
.toBuffer();
|
|
13
|
+
if (!compressedBuffer) {
|
|
14
|
+
throw new Error('Failed to compress screenshot');
|
|
15
|
+
}
|
|
16
|
+
return { mimeType: 'image/png', data: compressedBuffer.toString('base64') };
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
throw new Error(`Failed to get compressed screenshot:\n${error}`, { cause: error });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=screenshot-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"screenshot-service.js","sourceRoot":"","sources":["../../../src/tools/browser/screenshot-service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,MAAM,OAAO,wBAAwB;IACP;IAA7B,YAA6B,IAAU;QAAV,SAAI,GAAJ,IAAI,CAAM;IAAG,CAAC;IAE3C,KAAK,CAAC,uBAAuB;QAC5B,IAAI,CAAC;YACJ,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,IAAI,CAAC,UAAU,EAAE,CAAA;YAC/C,MAAM,gBAAgB,GAAG,MAAM,KAAK,CAAC,UAAU,CAAC;iBAC9C,MAAM,CAAC,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,QAAQ,EAAE,CAAC;iBAClD,QAAQ,EAAE,CAAA;YACZ,IAAI,CAAC,gBAAgB,EAAE,CAAC;gBACvB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;YACjD,CAAC;YAED,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,IAAI,EAAE,gBAAgB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAA;QAC5E,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YAChB,MAAM,IAAI,KAAK,CAAC,yCAAyC,KAAK,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC,CAAA;QACpF,CAAC;IACF,CAAC;CACD"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { filterSnapshot } from './snapshot-filter';
|
|
2
|
+
export { scoreSnapshotElements, filterByThreshold, filterTopPercent, type ScoredElement, type JsonValue, type JsonObject, type JsonArray, } from './semantic-scorer';
|
|
3
|
+
export { reconstructTree } from './tree-reconstructor';
|
|
4
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/tools/browser/snapshot-filter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,EAChB,KAAK,aAAa,EAClB,KAAK,SAAS,EACd,KAAK,UAAU,EACf,KAAK,SAAS,GACd,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/tools/browser/snapshot-filter/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAA;AAClD,OAAO,EACN,qBAAqB,EACrB,iBAAiB,EACjB,gBAAgB,GAKhB,MAAM,mBAAmB,CAAA;AAC1B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAA"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type JsonValue = string | number | boolean | null | JsonObject | JsonArray;
|
|
2
|
+
export type JsonObject = {
|
|
3
|
+
[key: string]: JsonValue;
|
|
4
|
+
};
|
|
5
|
+
export type JsonArray = JsonValue[];
|
|
6
|
+
export interface ScoredElement {
|
|
7
|
+
score: number;
|
|
8
|
+
path: (string | number)[];
|
|
9
|
+
element: JsonValue;
|
|
10
|
+
key: string;
|
|
11
|
+
}
|
|
12
|
+
export declare function scoreSnapshotElements(json: JsonValue, query: string): Promise<ScoredElement[]>;
|
|
13
|
+
export declare function filterByThreshold(scoredElements: ScoredElement[], threshold: number): ScoredElement[];
|
|
14
|
+
export declare function filterTopPercent(scoredElements: ScoredElement[], topPercent: number): ScoredElement[];
|
|
15
|
+
//# sourceMappingURL=semantic-scorer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"semantic-scorer.d.ts","sourceRoot":"","sources":["../../../../src/tools/browser/snapshot-filter/semantic-scorer.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,SAAS,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,UAAU,GAAG,SAAS,CAAA;AACjF,MAAM,MAAM,UAAU,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAA;AACrD,MAAM,MAAM,SAAS,GAAG,SAAS,EAAE,CAAA;AAEnC,MAAM,WAAW,aAAa;IAC7B,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAA;IACzB,OAAO,EAAE,SAAS,CAAA;IAClB,GAAG,EAAE,MAAM,CAAA;CACX;AAoBD,wBAAsB,qBAAqB,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAoCpG;AAgED,wBAAgB,iBAAiB,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE,SAAS,EAAE,MAAM,GAAG,aAAa,EAAE,CAErG;AAED,wBAAgB,gBAAgB,CAAC,cAAc,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,MAAM,GAAG,aAAa,EAAE,CAQrG"}
|