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.
@@ -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 = 0;
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 webpageRawText = await page.locator('body').innerText({
111
- timeout: 5000,
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: ${await page.title()}
154
+ The current webpage title is: ${webpageTitle}
144
155
  The raw text of the current webpage is:
145
156
  \`\`\`
146
157
  ${webpageRawText}
@@ -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 `${error.constructor.name}: ${error.message}\n${error.stack || ''}`;
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
  }
@@ -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 = 0;
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 webpageRawText = await page.locator('body').innerText({
111
- timeout: 5000,
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: ${await page.title()}
154
+ The current webpage title is: ${webpageTitle}
144
155
  The raw text of the current webpage is:
145
156
  \`\`\`
146
157
  ${webpageRawText}
@@ -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 `${error.constructor.name}: ${error.message}\n${error.stack || ''}`;
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "donobu",
3
- "version": "5.21.0",
3
+ "version": "5.21.2",
4
4
  "description": "Create browser automations with an LLM agent and replay them as Playwright scripts.",
5
5
  "main": "dist/main.js",
6
6
  "module": "dist/esm/main.js",