donobu 2.10.1 → 2.11.1
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/README.md +3 -1
- package/dist/assets/generated/version +1 -1
- package/dist/esm/assets/generated/version +1 -1
- package/dist/esm/tools/AssertTool.d.ts.map +1 -1
- package/dist/esm/tools/AssertTool.js +33 -12
- package/dist/esm/tools/AssertTool.js.map +1 -1
- package/dist/tools/AssertTool.d.ts.map +1 -1
- package/dist/tools/AssertTool.js +33 -12
- package/dist/tools/AssertTool.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -115,5 +115,7 @@ and have an LLM API key set up (of which can also be done via an environment var
|
|
|
115
115
|
Here is an example terminal command:
|
|
116
116
|
|
|
117
117
|
```
|
|
118
|
-
SELF_HEAL_TESTS_ENABLED=true
|
|
118
|
+
SELF_HEAL_TESTS_ENABLED=true \
|
|
119
|
+
ANTHROPIC_API_KEY=your-api-key \
|
|
120
|
+
npx playwright test your-test.ts
|
|
119
121
|
```
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1050
|
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
1050
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssertTool.d.ts","sourceRoot":"","sources":["../../../src/tools/AssertTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,UAAU,uBACR,SAAQ,qBAAqB,EAC3B,wBAAwB;CAAG;AAE/B,qBAAa,UAAW,SAAQ,IAAI,CAClC,wBAAwB,EACxB,uBAAuB,CACxB;IACC,gBAAuB,IAAI,YAAY;IAEvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAgB9C;;
|
|
1
|
+
{"version":3,"file":"AssertTool.d.ts","sourceRoot":"","sources":["../../../src/tools/AssertTool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAK1D,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AAExE,MAAM,WAAW,wBAAwB;IACvC;;;;;;OAMG;IACH,kBAAkB,EAAE,MAAM,CAAC;CAC5B;AAED,UAAU,uBACR,SAAQ,qBAAqB,EAC3B,wBAAwB;CAAG;AAE/B,qBAAa,UAAW,SAAQ,IAAI,CAClC,wBAAwB,EACxB,uBAAuB,CACxB;IACC,gBAAuB,IAAI,YAAY;IAEvC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,wBAAwB,CAgB9C;;IAaoB,IAAI,CACxB,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,wBAAwB,GACnC,OAAO,CAAC,cAAc,CAAC;IAkDJ,WAAW,CAC/B,OAAO,EAAE,eAAe,EACxB,UAAU,EAAE,uBAAuB,GAClC,OAAO,CAAC,cAAc,CAAC;CAG3B"}
|
|
@@ -6,21 +6,42 @@ const PlaywrightUtils_1 = require("../utils/PlaywrightUtils");
|
|
|
6
6
|
const MiscUtils_1 = require("../utils/MiscUtils");
|
|
7
7
|
class AssertTool extends Tool_1.Tool {
|
|
8
8
|
constructor() {
|
|
9
|
-
super(AssertTool.NAME,
|
|
9
|
+
super(AssertTool.NAME, `This method will test that a given condition (i.e. the 'assertionToTestFor' field) holds true.
|
|
10
|
+
It will use a screenshot of the current webpage, its raw page text, page URL, and page title, to evaluate a given assertion.`, 'AssertToolCoreParameters', 'AssertToolGptParameters', true);
|
|
10
11
|
}
|
|
11
12
|
async call(context, parameters) {
|
|
12
13
|
const screenshot = await PlaywrightUtils_1.PlaywrightUtils.takePngScreenshot(context.page);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const webpageRawText = await context.page.evaluate(() => document.body.innerText);
|
|
15
|
+
const promptMessages = [
|
|
16
|
+
{
|
|
17
|
+
type: 'system',
|
|
18
|
+
text: `You are a tool that will evaluate whether a given assertion holds true or not about a given webpage.
|
|
19
|
+
You will have access to a screenshot of the webpage, its raw text, URL, title, etc.
|
|
20
|
+
You should only use the given information to make your assertion.
|
|
21
|
+
Do not use any other information or context.`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'user',
|
|
25
|
+
items: [
|
|
26
|
+
{ type: 'png', bytes: screenshot },
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: `Make the following assertion about the current webpage: ${parameters.assertionToTestFor}
|
|
30
|
+
|
|
31
|
+
The current webpage URL is: ${context.page.url()}
|
|
32
|
+
The current webpage title is: ${await context.page.title()}
|
|
33
|
+
The raw text of the current webpage is:
|
|
34
|
+
\`\`\`
|
|
35
|
+
${webpageRawText}
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
Note that since this is the raw textual content, the text may be a bit jumbled, have its styling lost,
|
|
39
|
+
careful positioning lost, etc.`,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
const assertionOutcome = await context.gptClient.getStructuredOutput(promptMessages, AssertTool.ASSERTION_OUTCOME_SCHEMA);
|
|
24
45
|
MiscUtils_1.MiscUtils.updateTokenCounts(assertionOutcome, context.metadata);
|
|
25
46
|
const assertPassed = assertionOutcome.output.assertionPassed ? true : false;
|
|
26
47
|
const report = assertPassed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssertTool.js","sourceRoot":"","sources":["../../../src/tools/AssertTool.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAI9B,8DAA2D;AAC3D,kDAA+C;AAmB/C,MAAa,UAAW,SAAQ,WAG/B;IAqBC;QACE,KAAK,CACH,UAAU,CAAC,IAAI,EACf,
|
|
1
|
+
{"version":3,"file":"AssertTool.js","sourceRoot":"","sources":["../../../src/tools/AssertTool.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAI9B,8DAA2D;AAC3D,kDAA+C;AAmB/C,MAAa,UAAW,SAAQ,WAG/B;IAqBC;QACE,KAAK,CACH,UAAU,CAAC,IAAI,EACf;6HACuH,EACvH,0BAA0B,EAC1B,yBAAyB,EACzB,IAAI,CACL,CAAC;IACJ,CAAC;IAEe,KAAK,CAAC,IAAI,CACxB,OAAwB,EACxB,UAAoC;QAEpC,MAAM,UAAU,GAAG,MAAM,iCAAe,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzE,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAChD,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,CAC9B,CAAC;QACF,MAAM,cAAc,GAAG;YACrB;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE;;;6CAG+B;aACd;YACzB;gBACE,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE;oBACL,EAAE,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE,UAAU,EAAE;oBAClC;wBACE,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,2DAA2D,UAAU,CAAC,kBAAkB;;8BAE5E,OAAO,CAAC,IAAI,CAAC,GAAG,EAAE;gCAChB,MAAM,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE;;;EAGxD,cAAc;;;;+BAIe;qBACpB;iBACF;a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O,EAAE,eAAe,EACxB,UAAU,EAAE,uBAAuB,GAClC,OAAO,CAAC,cAAc,CAAC;CAG3B"}
|
package/dist/tools/AssertTool.js
CHANGED
|
@@ -6,21 +6,42 @@ const PlaywrightUtils_1 = require("../utils/PlaywrightUtils");
|
|
|
6
6
|
const MiscUtils_1 = require("../utils/MiscUtils");
|
|
7
7
|
class AssertTool extends Tool_1.Tool {
|
|
8
8
|
constructor() {
|
|
9
|
-
super(AssertTool.NAME,
|
|
9
|
+
super(AssertTool.NAME, `This method will test that a given condition (i.e. the 'assertionToTestFor' field) holds true.
|
|
10
|
+
It will use a screenshot of the current webpage, its raw page text, page URL, and page title, to evaluate a given assertion.`, 'AssertToolCoreParameters', 'AssertToolGptParameters', true);
|
|
10
11
|
}
|
|
11
12
|
async call(context, parameters) {
|
|
12
13
|
const screenshot = await PlaywrightUtils_1.PlaywrightUtils.takePngScreenshot(context.page);
|
|
13
|
-
const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
14
|
+
const webpageRawText = await context.page.evaluate(() => document.body.innerText);
|
|
15
|
+
const promptMessages = [
|
|
16
|
+
{
|
|
17
|
+
type: 'system',
|
|
18
|
+
text: `You are a tool that will evaluate whether a given assertion holds true or not about a given webpage.
|
|
19
|
+
You will have access to a screenshot of the webpage, its raw text, URL, title, etc.
|
|
20
|
+
You should only use the given information to make your assertion.
|
|
21
|
+
Do not use any other information or context.`,
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'user',
|
|
25
|
+
items: [
|
|
26
|
+
{ type: 'png', bytes: screenshot },
|
|
27
|
+
{
|
|
28
|
+
type: 'text',
|
|
29
|
+
text: `Make the following assertion about the current webpage: ${parameters.assertionToTestFor}
|
|
30
|
+
|
|
31
|
+
The current webpage URL is: ${context.page.url()}
|
|
32
|
+
The current webpage title is: ${await context.page.title()}
|
|
33
|
+
The raw text of the current webpage is:
|
|
34
|
+
\`\`\`
|
|
35
|
+
${webpageRawText}
|
|
36
|
+
\`\`\`
|
|
37
|
+
|
|
38
|
+
Note that since this is the raw textual content, the text may be a bit jumbled, have its styling lost,
|
|
39
|
+
careful positioning lost, etc.`,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
const assertionOutcome = await context.gptClient.getStructuredOutput(promptMessages, AssertTool.ASSERTION_OUTCOME_SCHEMA);
|
|
24
45
|
MiscUtils_1.MiscUtils.updateTokenCounts(assertionOutcome, context.metadata);
|
|
25
46
|
const assertPassed = assertionOutcome.output.assertionPassed ? true : false;
|
|
26
47
|
const report = assertPassed
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AssertTool.js","sourceRoot":"","sources":["../../src/tools/AssertTool.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAI9B,8DAA2D;AAC3D,kDAA+C;AAmB/C,MAAa,UAAW,SAAQ,WAG/B;IAqBC;QACE,KAAK,CACH,UAAU,CAAC,IAAI,EACf,
|
|
1
|
+
{"version":3,"file":"AssertTool.js","sourceRoot":"","sources":["../../src/tools/AssertTool.ts"],"names":[],"mappings":";;;AAAA,iCAA8B;AAI9B,8DAA2D;AAC3D,kDAA+C;AAmB/C,MAAa,UAAW,SAAQ,WAG/B;IAqBC;QACE,KAAK,CACH,UAAU,CAAC,IAAI,EACf;6HACuH,EACvH,0BAA0B,EAC1B,yBAAyB,EACzB,IAAI,CACL,CAAC;IACJ,CAAC;IAEe,KAAK,CAAC,IAAI,CACxB,OAAwB,EACxB,UAAoC;QAEpC,MAAM,UAAU,GAAG,MAAM,iCAAe,CAAC,iBAAiB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACzE,MAAM,cAAc,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,QAAQ,CAChD,GAAG,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,SAAS,C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