donobu 5.21.0 → 5.21.2
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/esm/tools/AssertTool.js +15 -4
- package/dist/esm/utils/Logger.js +1 -1
- package/dist/esm/utils/MiscUtils.d.ts +1 -0
- package/dist/esm/utils/MiscUtils.js +10 -0
- package/dist/tools/AssertTool.js +15 -4
- package/dist/utils/Logger.js +1 -1
- package/dist/utils/MiscUtils.d.ts +1 -0
- package/dist/utils/MiscUtils.js +10 -0
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ const MiscUtils_1 = require("../utils/MiscUtils");
|
|
|
10
10
|
const PlaywrightUtils_1 = require("../utils/PlaywrightUtils");
|
|
11
11
|
const TargetUtils_1 = require("../utils/TargetUtils");
|
|
12
12
|
const Tool_1 = require("./Tool");
|
|
13
|
-
const DEFAULT_RETRIES =
|
|
13
|
+
const DEFAULT_RETRIES = 1;
|
|
14
14
|
const DEFAULT_RETRY_WAIT_SECONDS = 3;
|
|
15
15
|
exports.AssertCoreSchema = v4_1.z.object({
|
|
16
16
|
assertionToTestFor: v4_1.z.string()
|
|
@@ -107,8 +107,19 @@ It will use a screenshot of the current viewport of the webpage, the webpage's t
|
|
|
107
107
|
await page.waitForTimeout(retryWaitSeconds * 1000);
|
|
108
108
|
}
|
|
109
109
|
const screenshot = await PlaywrightUtils_1.PlaywrightUtils.takeViewportScreenshot(page);
|
|
110
|
-
const
|
|
111
|
-
|
|
110
|
+
const webpageTextTimeoutMs = 5000;
|
|
111
|
+
const webpageRawText = await page
|
|
112
|
+
.locator('body')
|
|
113
|
+
.innerText({ timeout: webpageTextTimeoutMs })
|
|
114
|
+
.catch((error) => {
|
|
115
|
+
const msg = `[${MiscUtils_1.MiscUtils.errName(error)}: Failed to extract page text within ${webpageTextTimeoutMs}ms. The page may still be loading or the main thread may be blocked.]`;
|
|
116
|
+
Logger_1.appLogger.warn(msg);
|
|
117
|
+
return msg;
|
|
118
|
+
});
|
|
119
|
+
const webpageTitle = await page.title().catch((error) => {
|
|
120
|
+
const msg = `[${MiscUtils_1.MiscUtils.errName(error)}: Failed to retrieve page title]`;
|
|
121
|
+
Logger_1.appLogger.warn(msg);
|
|
122
|
+
return msg;
|
|
112
123
|
});
|
|
113
124
|
const promptMessages = [
|
|
114
125
|
{
|
|
@@ -140,7 +151,7 @@ CRITICAL RULES for generating structured steps — follow these precisely:
|
|
|
140
151
|
|
|
141
152
|
The current date and time in ISO 8601 format is ${new Date().toISOString()}.
|
|
142
153
|
The current webpage URL is: ${page.url()}
|
|
143
|
-
The current webpage title is: ${
|
|
154
|
+
The current webpage title is: ${webpageTitle}
|
|
144
155
|
The raw text of the current webpage is:
|
|
145
156
|
\`\`\`
|
|
146
157
|
${webpageRawText}
|
package/dist/esm/utils/Logger.js
CHANGED
|
@@ -21,7 +21,7 @@ const MAX_FILES = 2;
|
|
|
21
21
|
* Formats an error object into a detailed string representation
|
|
22
22
|
*/
|
|
23
23
|
function formatError(error) {
|
|
24
|
-
return `${
|
|
24
|
+
return `${MiscUtils_1.MiscUtils.errName(error)}: ${error.message}\n${error.stack || ''}`;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Winston stores extra positional args (e.g., logger.error('msg', err, meta))
|
|
@@ -3,6 +3,7 @@ import type { GptMessage } from '../models/GptMessage';
|
|
|
3
3
|
export declare class MiscUtils {
|
|
4
4
|
private constructor();
|
|
5
5
|
static readonly DONOBU_VERSION: string;
|
|
6
|
+
static errName(error: unknown): string;
|
|
6
7
|
static capitalize(s: string): string;
|
|
7
8
|
/**
|
|
8
9
|
* Force a true/false/undefined value for a given value. This is a stripped down
|
|
@@ -12,6 +12,16 @@ const v4_1 = __importDefault(require("zod/v4"));
|
|
|
12
12
|
const envVars_1 = require("../envVars");
|
|
13
13
|
class MiscUtils {
|
|
14
14
|
constructor() { }
|
|
15
|
+
static errName(error) {
|
|
16
|
+
if (error instanceof Error) {
|
|
17
|
+
return error.constructor.name !== 'Error'
|
|
18
|
+
? error.constructor.name
|
|
19
|
+
: error.name;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return typeof error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
15
25
|
static capitalize(s) {
|
|
16
26
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
17
27
|
}
|
package/dist/tools/AssertTool.js
CHANGED
|
@@ -10,7 +10,7 @@ const MiscUtils_1 = require("../utils/MiscUtils");
|
|
|
10
10
|
const PlaywrightUtils_1 = require("../utils/PlaywrightUtils");
|
|
11
11
|
const TargetUtils_1 = require("../utils/TargetUtils");
|
|
12
12
|
const Tool_1 = require("./Tool");
|
|
13
|
-
const DEFAULT_RETRIES =
|
|
13
|
+
const DEFAULT_RETRIES = 1;
|
|
14
14
|
const DEFAULT_RETRY_WAIT_SECONDS = 3;
|
|
15
15
|
exports.AssertCoreSchema = v4_1.z.object({
|
|
16
16
|
assertionToTestFor: v4_1.z.string()
|
|
@@ -107,8 +107,19 @@ It will use a screenshot of the current viewport of the webpage, the webpage's t
|
|
|
107
107
|
await page.waitForTimeout(retryWaitSeconds * 1000);
|
|
108
108
|
}
|
|
109
109
|
const screenshot = await PlaywrightUtils_1.PlaywrightUtils.takeViewportScreenshot(page);
|
|
110
|
-
const
|
|
111
|
-
|
|
110
|
+
const webpageTextTimeoutMs = 5000;
|
|
111
|
+
const webpageRawText = await page
|
|
112
|
+
.locator('body')
|
|
113
|
+
.innerText({ timeout: webpageTextTimeoutMs })
|
|
114
|
+
.catch((error) => {
|
|
115
|
+
const msg = `[${MiscUtils_1.MiscUtils.errName(error)}: Failed to extract page text within ${webpageTextTimeoutMs}ms. The page may still be loading or the main thread may be blocked.]`;
|
|
116
|
+
Logger_1.appLogger.warn(msg);
|
|
117
|
+
return msg;
|
|
118
|
+
});
|
|
119
|
+
const webpageTitle = await page.title().catch((error) => {
|
|
120
|
+
const msg = `[${MiscUtils_1.MiscUtils.errName(error)}: Failed to retrieve page title]`;
|
|
121
|
+
Logger_1.appLogger.warn(msg);
|
|
122
|
+
return msg;
|
|
112
123
|
});
|
|
113
124
|
const promptMessages = [
|
|
114
125
|
{
|
|
@@ -140,7 +151,7 @@ CRITICAL RULES for generating structured steps — follow these precisely:
|
|
|
140
151
|
|
|
141
152
|
The current date and time in ISO 8601 format is ${new Date().toISOString()}.
|
|
142
153
|
The current webpage URL is: ${page.url()}
|
|
143
|
-
The current webpage title is: ${
|
|
154
|
+
The current webpage title is: ${webpageTitle}
|
|
144
155
|
The raw text of the current webpage is:
|
|
145
156
|
\`\`\`
|
|
146
157
|
${webpageRawText}
|
package/dist/utils/Logger.js
CHANGED
|
@@ -21,7 +21,7 @@ const MAX_FILES = 2;
|
|
|
21
21
|
* Formats an error object into a detailed string representation
|
|
22
22
|
*/
|
|
23
23
|
function formatError(error) {
|
|
24
|
-
return `${
|
|
24
|
+
return `${MiscUtils_1.MiscUtils.errName(error)}: ${error.message}\n${error.stack || ''}`;
|
|
25
25
|
}
|
|
26
26
|
/**
|
|
27
27
|
* Winston stores extra positional args (e.g., logger.error('msg', err, meta))
|
|
@@ -3,6 +3,7 @@ import type { GptMessage } from '../models/GptMessage';
|
|
|
3
3
|
export declare class MiscUtils {
|
|
4
4
|
private constructor();
|
|
5
5
|
static readonly DONOBU_VERSION: string;
|
|
6
|
+
static errName(error: unknown): string;
|
|
6
7
|
static capitalize(s: string): string;
|
|
7
8
|
/**
|
|
8
9
|
* Force a true/false/undefined value for a given value. This is a stripped down
|
package/dist/utils/MiscUtils.js
CHANGED
|
@@ -12,6 +12,16 @@ const v4_1 = __importDefault(require("zod/v4"));
|
|
|
12
12
|
const envVars_1 = require("../envVars");
|
|
13
13
|
class MiscUtils {
|
|
14
14
|
constructor() { }
|
|
15
|
+
static errName(error) {
|
|
16
|
+
if (error instanceof Error) {
|
|
17
|
+
return error.constructor.name !== 'Error'
|
|
18
|
+
? error.constructor.name
|
|
19
|
+
: error.name;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return typeof error;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
15
25
|
static capitalize(s) {
|
|
16
26
|
return s.charAt(0).toUpperCase() + s.slice(1);
|
|
17
27
|
}
|