donobu 5.18.0 → 5.18.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.
@@ -31,6 +31,24 @@ const donobuTestStack_1 = require("../test/utils/donobuTestStack");
31
31
  const originalGotoRegistry_1 = require("./originalGotoRegistry");
32
32
  const SmartSelector_1 = require("./SmartSelector");
33
33
  const tbd_1 = require("./tbd");
34
+ /**
35
+ * Resolve a URL against the browser context's baseURL (if set), mirroring
36
+ * what Playwright does internally before issuing the navigation request.
37
+ * This gives us the *intended* URL (before any server-side redirects).
38
+ */
39
+ function resolveBaseUrl(page, url) {
40
+ const baseURL = page.context()._options?.baseURL;
41
+ // Only resolve against baseURL if the URL is relative (no scheme like https:).
42
+ if (baseURL && !/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url)) {
43
+ try {
44
+ return new URL(url, baseURL).href;
45
+ }
46
+ catch {
47
+ return url;
48
+ }
49
+ }
50
+ return url;
51
+ }
34
52
  // Donobu page extension helpers: decorate Playwright pages with Donobu behaviors and keep one
35
53
  // coherent flow (and persistence record) per browser context so new tabs share state safely.
36
54
  const PLACEHOLDER_FLOW_URL = 'https://example.com';
@@ -340,13 +358,14 @@ Use this information to return an appropriate JSON object.`,
340
358
  page.goto = async (url, options) => {
341
359
  const startedAt = new Date().getTime();
342
360
  const flowId = sharedState.donobuFlowMetadata.id;
361
+ const effectiveUrl = resolveBaseUrl(page, url);
343
362
  // First navigation sets the target website and records the tool call with screenshots.
344
363
  if (sharedState.donobuFlowMetadata.web?.targetWebsite === PLACEHOLDER_FLOW_URL) {
345
364
  sharedState.donobuFlowMetadata = {
346
365
  ...sharedState.donobuFlowMetadata,
347
366
  web: {
348
367
  ...sharedState.donobuFlowMetadata.web,
349
- targetWebsite: url,
368
+ targetWebsite: effectiveUrl,
350
369
  },
351
370
  };
352
371
  await sharedState.persistence.setFlowMetadata(sharedState.donobuFlowMetadata);
@@ -362,18 +381,18 @@ Use this information to return an appropriate JSON object.`,
362
381
  id: MiscUtils_1.MiscUtils.createAdHocToolCallId(),
363
382
  toolName: GoToWebpageTool_1.GoToWebpageTool.NAME,
364
383
  parameters: {
365
- url: url,
384
+ url: effectiveUrl,
366
385
  },
367
386
  outcome: {
368
387
  isSuccessful: true,
369
- forLlm: `Successfully navigated to ${url}`,
388
+ forLlm: `Successfully navigated to ${effectiveUrl}`,
370
389
  metadata: {
371
390
  pageTitle: pageTitle,
372
391
  resolvedUrl: page.url(),
373
392
  },
374
393
  },
375
394
  postCallImageId: postCallImageId,
376
- page: url,
395
+ page: effectiveUrl,
377
396
  startedAt: startedAt,
378
397
  completedAt: completedAt,
379
398
  });
@@ -390,7 +409,7 @@ Use this information to return an appropriate JSON object.`,
390
409
  id: MiscUtils_1.MiscUtils.createAdHocToolCallId(),
391
410
  toolName: GoToWebpageTool_1.GoToWebpageTool.NAME,
392
411
  parameters: {
393
- url: url,
412
+ url: effectiveUrl,
394
413
  },
395
414
  outcome: {
396
415
  isSuccessful: false,
@@ -398,7 +417,7 @@ Use this information to return an appropriate JSON object.`,
398
417
  metadata: null,
399
418
  },
400
419
  postCallImageId: postCallImageId,
401
- page: url,
420
+ page: effectiveUrl,
402
421
  startedAt: startedAt,
403
422
  completedAt: completedAt,
404
423
  });
@@ -31,6 +31,24 @@ const donobuTestStack_1 = require("../test/utils/donobuTestStack");
31
31
  const originalGotoRegistry_1 = require("./originalGotoRegistry");
32
32
  const SmartSelector_1 = require("./SmartSelector");
33
33
  const tbd_1 = require("./tbd");
34
+ /**
35
+ * Resolve a URL against the browser context's baseURL (if set), mirroring
36
+ * what Playwright does internally before issuing the navigation request.
37
+ * This gives us the *intended* URL (before any server-side redirects).
38
+ */
39
+ function resolveBaseUrl(page, url) {
40
+ const baseURL = page.context()._options?.baseURL;
41
+ // Only resolve against baseURL if the URL is relative (no scheme like https:).
42
+ if (baseURL && !/^[a-zA-Z][a-zA-Z\d+\-.]*:/.test(url)) {
43
+ try {
44
+ return new URL(url, baseURL).href;
45
+ }
46
+ catch {
47
+ return url;
48
+ }
49
+ }
50
+ return url;
51
+ }
34
52
  // Donobu page extension helpers: decorate Playwright pages with Donobu behaviors and keep one
35
53
  // coherent flow (and persistence record) per browser context so new tabs share state safely.
36
54
  const PLACEHOLDER_FLOW_URL = 'https://example.com';
@@ -340,13 +358,14 @@ Use this information to return an appropriate JSON object.`,
340
358
  page.goto = async (url, options) => {
341
359
  const startedAt = new Date().getTime();
342
360
  const flowId = sharedState.donobuFlowMetadata.id;
361
+ const effectiveUrl = resolveBaseUrl(page, url);
343
362
  // First navigation sets the target website and records the tool call with screenshots.
344
363
  if (sharedState.donobuFlowMetadata.web?.targetWebsite === PLACEHOLDER_FLOW_URL) {
345
364
  sharedState.donobuFlowMetadata = {
346
365
  ...sharedState.donobuFlowMetadata,
347
366
  web: {
348
367
  ...sharedState.donobuFlowMetadata.web,
349
- targetWebsite: url,
368
+ targetWebsite: effectiveUrl,
350
369
  },
351
370
  };
352
371
  await sharedState.persistence.setFlowMetadata(sharedState.donobuFlowMetadata);
@@ -362,18 +381,18 @@ Use this information to return an appropriate JSON object.`,
362
381
  id: MiscUtils_1.MiscUtils.createAdHocToolCallId(),
363
382
  toolName: GoToWebpageTool_1.GoToWebpageTool.NAME,
364
383
  parameters: {
365
- url: url,
384
+ url: effectiveUrl,
366
385
  },
367
386
  outcome: {
368
387
  isSuccessful: true,
369
- forLlm: `Successfully navigated to ${url}`,
388
+ forLlm: `Successfully navigated to ${effectiveUrl}`,
370
389
  metadata: {
371
390
  pageTitle: pageTitle,
372
391
  resolvedUrl: page.url(),
373
392
  },
374
393
  },
375
394
  postCallImageId: postCallImageId,
376
- page: url,
395
+ page: effectiveUrl,
377
396
  startedAt: startedAt,
378
397
  completedAt: completedAt,
379
398
  });
@@ -390,7 +409,7 @@ Use this information to return an appropriate JSON object.`,
390
409
  id: MiscUtils_1.MiscUtils.createAdHocToolCallId(),
391
410
  toolName: GoToWebpageTool_1.GoToWebpageTool.NAME,
392
411
  parameters: {
393
- url: url,
412
+ url: effectiveUrl,
394
413
  },
395
414
  outcome: {
396
415
  isSuccessful: false,
@@ -398,7 +417,7 @@ Use this information to return an appropriate JSON object.`,
398
417
  metadata: null,
399
418
  },
400
419
  postCallImageId: postCallImageId,
401
- page: url,
420
+ page: effectiveUrl,
402
421
  startedAt: startedAt,
403
422
  completedAt: completedAt,
404
423
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "donobu",
3
- "version": "5.18.0",
3
+ "version": "5.18.1",
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",