@airtop/sdk 0.0.11 → 0.0.13

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.
Files changed (84) hide show
  1. package/api/resources/profiles/client/Client.js +4 -4
  2. package/api/resources/profiles/client/requests/ProfilesDeleteRequest.d.ts +1 -1
  3. package/api/resources/profiles/client/requests/ProfilesGetRequest.d.ts +1 -1
  4. package/api/resources/sessions/client/Client.d.ts +1 -1
  5. package/api/resources/sessions/client/Client.js +11 -11
  6. package/api/resources/sessions/client/requests/SessionsListRequest.d.ts +4 -4
  7. package/api/resources/sessions/types/SessionsListRequestStatus.d.ts +3 -3
  8. package/api/resources/sessions/types/SessionsListRequestStatus.js +1 -1
  9. package/api/resources/windows/client/Client.d.ts +9 -9
  10. package/api/resources/windows/client/Client.js +18 -18
  11. package/api/resources/windows/client/requests/GetWindowInfoRequest.d.ts +4 -4
  12. package/api/resources/windows/client/requests/PromptContentRequest.d.ts +8 -2
  13. package/api/resources/windows/client/requests/ScrapeContentRequest.d.ts +6 -0
  14. package/api/resources/windows/client/requests/SummarizeContentRequest.d.ts +7 -1
  15. package/api/types/AiResponseEnvelope.d.ts +0 -3
  16. package/api/types/ExternalProfileV1.d.ts +2 -2
  17. package/api/types/ExternalSessionAiResponseMetadata.d.ts +1 -0
  18. package/api/types/ExternalSessionAiResponseMetadataStatus.d.ts +3 -0
  19. package/api/types/ExternalSessionConfig.d.ts +3 -3
  20. package/api/types/ExternalSessionWithConnectionInfo.d.ts +11 -9
  21. package/api/types/Issue.d.ts +3 -3
  22. package/api/types/ScrapeResponseContent.d.ts +2 -2
  23. package/api/types/ScrapeResponseEnvelope.d.ts +1 -2
  24. package/api/types/ScrapeResponseOutput.d.ts +3 -3
  25. package/api/types/SessionConfigV1.d.ts +4 -4
  26. package/api/types/SessionsWithPagination.d.ts +2 -2
  27. package/api/types/Window.d.ts +2 -2
  28. package/dist/api/resources/profiles/client/Client.js +4 -4
  29. package/dist/api/resources/profiles/client/requests/ProfilesDeleteRequest.d.ts +1 -1
  30. package/dist/api/resources/profiles/client/requests/ProfilesGetRequest.d.ts +1 -1
  31. package/dist/api/resources/sessions/client/Client.d.ts +1 -1
  32. package/dist/api/resources/sessions/client/Client.js +11 -11
  33. package/dist/api/resources/sessions/client/requests/SessionsListRequest.d.ts +4 -4
  34. package/dist/api/resources/sessions/types/SessionsListRequestStatus.d.ts +3 -3
  35. package/dist/api/resources/sessions/types/SessionsListRequestStatus.js +1 -1
  36. package/dist/api/resources/windows/client/Client.d.ts +9 -9
  37. package/dist/api/resources/windows/client/Client.js +18 -18
  38. package/dist/api/resources/windows/client/requests/GetWindowInfoRequest.d.ts +4 -4
  39. package/dist/api/resources/windows/client/requests/PromptContentRequest.d.ts +8 -2
  40. package/dist/api/resources/windows/client/requests/ScrapeContentRequest.d.ts +6 -0
  41. package/dist/api/resources/windows/client/requests/SummarizeContentRequest.d.ts +7 -1
  42. package/dist/api/types/AiResponseEnvelope.d.ts +0 -3
  43. package/dist/api/types/ExternalProfileV1.d.ts +2 -2
  44. package/dist/api/types/ExternalSessionAiResponseMetadata.d.ts +1 -0
  45. package/dist/api/types/ExternalSessionAiResponseMetadataStatus.d.ts +3 -0
  46. package/dist/api/types/ExternalSessionConfig.d.ts +3 -3
  47. package/dist/api/types/ExternalSessionWithConnectionInfo.d.ts +11 -9
  48. package/dist/api/types/Issue.d.ts +3 -3
  49. package/dist/api/types/ScrapeResponseContent.d.ts +2 -2
  50. package/dist/api/types/ScrapeResponseEnvelope.d.ts +1 -2
  51. package/dist/api/types/ScrapeResponseOutput.d.ts +3 -3
  52. package/dist/api/types/SessionConfigV1.d.ts +4 -4
  53. package/dist/api/types/SessionsWithPagination.d.ts +2 -2
  54. package/dist/api/types/Window.d.ts +2 -2
  55. package/dist/serialization/resources/sessions/types/SessionsListRequestStatus.d.ts +1 -1
  56. package/dist/serialization/resources/sessions/types/SessionsListRequestStatus.js +1 -1
  57. package/dist/serialization/types/AiResponseEnvelope.d.ts +0 -3
  58. package/dist/serialization/types/AiResponseEnvelope.js +0 -3
  59. package/dist/serialization/types/ExternalSessionWithConnectionInfo.d.ts +1 -0
  60. package/dist/serialization/types/ExternalSessionWithConnectionInfo.js +1 -0
  61. package/dist/serialization/types/ScrapeResponseEnvelope.d.ts +0 -3
  62. package/dist/serialization/types/ScrapeResponseEnvelope.js +0 -3
  63. package/dist/serialization/types/SessionConfigV1.d.ts +1 -1
  64. package/dist/serialization/types/SessionConfigV1.js +1 -1
  65. package/dist/wrapper/AirtopClient.js +1 -1
  66. package/dist/wrapper/AirtopSessions.js +3 -1
  67. package/dist/wrapper/AirtopWindows.d.ts +24 -7
  68. package/dist/wrapper/AirtopWindows.js +62 -11
  69. package/package.json +8 -6
  70. package/reference.md +10 -10
  71. package/serialization/resources/sessions/types/SessionsListRequestStatus.d.ts +1 -1
  72. package/serialization/resources/sessions/types/SessionsListRequestStatus.js +1 -1
  73. package/serialization/types/AiResponseEnvelope.d.ts +0 -3
  74. package/serialization/types/AiResponseEnvelope.js +0 -3
  75. package/serialization/types/ExternalSessionWithConnectionInfo.d.ts +1 -0
  76. package/serialization/types/ExternalSessionWithConnectionInfo.js +1 -0
  77. package/serialization/types/ScrapeResponseEnvelope.d.ts +0 -3
  78. package/serialization/types/ScrapeResponseEnvelope.js +0 -3
  79. package/serialization/types/SessionConfigV1.d.ts +1 -1
  80. package/serialization/types/SessionConfigV1.js +1 -1
  81. package/wrapper/AirtopClient.js +1 -1
  82. package/wrapper/AirtopSessions.js +3 -1
  83. package/wrapper/AirtopWindows.d.ts +24 -7
  84. package/wrapper/AirtopWindows.js +62 -11
@@ -4,13 +4,10 @@
4
4
  import * as serializers from "../index";
5
5
  import * as Airtop from "../../api/index";
6
6
  import * as core from "../../core";
7
- import { Issue } from "./Issue";
8
7
  import { ScrapeResponseOutput } from "./ScrapeResponseOutput";
9
8
  export declare const ScrapeResponseEnvelope: core.serialization.ObjectSchema<serializers.ScrapeResponseEnvelope.Raw, Airtop.ScrapeResponseEnvelope>;
10
9
  export declare namespace ScrapeResponseEnvelope {
11
10
  interface Raw {
12
- errors?: Issue.Raw[] | null;
13
11
  modelResponse: ScrapeResponseOutput.Raw;
14
- warnings?: Issue.Raw[] | null;
15
12
  }
16
13
  }
@@ -28,10 +28,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.ScrapeResponseEnvelope = void 0;
30
30
  const core = __importStar(require("../../core"));
31
- const Issue_1 = require("./Issue");
32
31
  const ScrapeResponseOutput_1 = require("./ScrapeResponseOutput");
33
32
  exports.ScrapeResponseEnvelope = core.serialization.object({
34
- errors: core.serialization.list(Issue_1.Issue).optional(),
35
33
  modelResponse: ScrapeResponseOutput_1.ScrapeResponseOutput,
36
- warnings: core.serialization.list(Issue_1.Issue).optional(),
37
34
  });
@@ -7,8 +7,8 @@ import * as core from "../../core";
7
7
  export declare const SessionConfigV1: core.serialization.ObjectSchema<serializers.SessionConfigV1.Raw, Airtop.SessionConfigV1>;
8
8
  export declare namespace SessionConfigV1 {
9
9
  interface Raw {
10
+ baseProfileId?: string | null;
10
11
  persistProfile?: boolean | null;
11
- profileId?: string | null;
12
12
  timeoutMinutes?: number | null;
13
13
  }
14
14
  }
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.SessionConfigV1 = void 0;
30
30
  const core = __importStar(require("../../core"));
31
31
  exports.SessionConfigV1 = core.serialization.object({
32
+ baseProfileId: core.serialization.string().optional(),
32
33
  persistProfile: core.serialization.boolean().optional(),
33
- profileId: core.serialization.string().optional(),
34
34
  timeoutMinutes: core.serialization.number().optional(),
35
35
  });
@@ -8,7 +8,7 @@ class AirtopClient {
8
8
  constructor(options) {
9
9
  this._client = new Client_1.AirtopClient(options);
10
10
  this.debug = (options === null || options === void 0 ? void 0 : options.debug) || false;
11
- this._windowsWrapper = new AirtopWindows_1.AirtopWindows(this._client);
11
+ this._windowsWrapper = new AirtopWindows_1.AirtopWindows(this._client, options === null || options === void 0 ? void 0 : options.apiKey);
12
12
  this._sessionsWrapper = new AirtopSessions_1.AirtopSessions(this._client, options === null || options === void 0 ? void 0 : options.debug);
13
13
  }
14
14
  get windows() {
@@ -48,7 +48,9 @@ class AirtopSessions {
48
48
  this.log('No browser created, timed out?');
49
49
  throw new Error(`Waiting for session ready timed out`);
50
50
  }
51
- return this.getInfo(createSessionResponse.data.id, requestOptions);
51
+ const getInfoResponse = yield this.getInfo(createSessionResponse.data.id, requestOptions);
52
+ // Merge the createSessionResponse with any new data from getInfoResponse
53
+ return Object.assign(Object.assign({}, createSessionResponse), { data: Object.assign(Object.assign({}, createSessionResponse.data), getInfoResponse.data) });
52
54
  }
53
55
  catch (e) {
54
56
  this.log(e);
@@ -1,18 +1,35 @@
1
- import { Page as PuppeteerPage } from 'puppeteer';
2
- import { Page as PlaywrightPage } from 'playwright';
3
- import { WebDriver } from 'selenium-webdriver';
1
+ declare namespace puppeteer {
2
+ interface Page {
3
+ mainFrame(): any;
4
+ }
5
+ }
6
+ declare namespace playwright {
7
+ interface Page {
8
+ context(): any;
9
+ }
10
+ }
11
+ declare namespace seleniumWebdriver {
12
+ interface WebDriver {
13
+ getSession(): Promise<any>;
14
+ createCDPConnection(domain: string): Promise<any>;
15
+ }
16
+ }
4
17
  import { AirtopClient as FernClient } from '../Client';
5
18
  import * as Airtop from '../api';
6
19
  import { Windows as WindowsNamespace } from '../api/resources/windows/client/Client';
20
+ import * as core from '../core';
7
21
  export declare class AirtopWindows {
8
22
  private airtopClient;
23
+ private apiKeySupplier;
9
24
  private _windows;
10
- constructor(airtopClient: FernClient);
25
+ constructor(airtopClient: FernClient, apiKeySupplier: core.Supplier<core.BearerToken | undefined>);
11
26
  getWindowInfo(sessionId: string, windowId: string, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
12
27
  promptContent(sessionId: string, windowId: string, request: Airtop.PromptContentRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
13
28
  scrapeContent(sessionId: string, windowId: string, requestOptions?: Airtop.ScrapeContentRequest): Promise<Airtop.ScrapeResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
14
29
  summarizeContent(sessionId: string, windowId: string, request?: Airtop.SummarizeContentRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
15
- getWindowInfoForPuppeteerPage(sessionId: string, page: PuppeteerPage, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
16
- getWindowInfoForPlaywrightPage(sessionId: string, page: PlaywrightPage, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
17
- getWindowInfoForSeleniumDriver(sessionId: string, driver: WebDriver, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
30
+ getWindowInfoForPuppeteerPage(session: Airtop.ExternalSessionWithConnectionInfo, page: puppeteer.Page, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
31
+ getWindowInfoForPlaywrightPage(session: Airtop.ExternalSessionWithConnectionInfo, page: playwright.Page, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
32
+ private executeSeleniumCDPCommand;
33
+ getWindowInfoForSeleniumDriver(session: Airtop.ExternalSessionWithConnectionInfo, driver: seleniumWebdriver.WebDriver, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
18
34
  }
35
+ export {};
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,11 +31,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
32
  });
10
33
  };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
11
37
  Object.defineProperty(exports, "__esModule", { value: true });
12
38
  exports.AirtopWindows = void 0;
39
+ const node_fetch_1 = __importDefault(require("node-fetch"));
40
+ const core = __importStar(require("../core"));
13
41
  class AirtopWindows {
14
- constructor(airtopClient) {
42
+ constructor(airtopClient, apiKeySupplier) {
15
43
  this.airtopClient = airtopClient;
44
+ this.apiKeySupplier = apiKeySupplier;
16
45
  this._windows = airtopClient.windows;
17
46
  }
18
47
  getWindowInfo(sessionId, windowId, request, requestOptions) {
@@ -31,13 +60,13 @@ class AirtopWindows {
31
60
  summarizeContent(sessionId, windowId, request, requestOptions) {
32
61
  return this._windows.summarizeContent(sessionId, windowId, request, requestOptions);
33
62
  }
34
- getWindowInfoForPuppeteerPage(sessionId, page, request, requestOptions) {
63
+ getWindowInfoForPuppeteerPage(session, page, request, requestOptions) {
35
64
  return __awaiter(this, void 0, void 0, function* () {
36
65
  const targetId = yield page.mainFrame()._id;
37
- return yield this.getWindowInfo(sessionId, targetId, request, requestOptions);
66
+ return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
38
67
  });
39
68
  }
40
- getWindowInfoForPlaywrightPage(sessionId, page, request, requestOptions) {
69
+ getWindowInfoForPlaywrightPage(session, page, request, requestOptions) {
41
70
  return __awaiter(this, void 0, void 0, function* () {
42
71
  // Retrieve target information
43
72
  const cdpSession = yield page.context().newCDPSession(page);
@@ -46,19 +75,41 @@ class AirtopWindows {
46
75
  if (!targetId) {
47
76
  throw new Error('TargetId not found');
48
77
  }
49
- return yield this.getWindowInfo(sessionId, targetId, request, requestOptions);
78
+ return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
50
79
  });
51
80
  }
52
- getWindowInfoForSeleniumDriver(sessionId, driver, request, requestOptions) {
81
+ executeSeleniumCDPCommand(driver, session, apiKey) {
53
82
  return __awaiter(this, void 0, void 0, function* () {
54
- const cdpSession = yield driver.createCDPConnection('page');
55
- // Fetch the available targets using the Target domain
56
- const { targetInfo } = yield cdpSession.send('Target.getTargetInfo');
57
- const targetId = targetInfo.targetId;
83
+ // Get the current WebDriver session ID
84
+ const webDriverSessionId = (yield driver.getSession()).getId();
85
+ if (!webDriverSessionId) {
86
+ throw new Error('No WebDriver session available');
87
+ }
88
+ const chromedriverSessionUrl = `${session.chromedriverUrl}/session/${webDriverSessionId}/chromium/send_command_and_get_result`;
89
+ const response = yield (0, node_fetch_1.default)(chromedriverSessionUrl, {
90
+ method: 'POST',
91
+ headers: {
92
+ 'Content-Type': 'application/json',
93
+ Authorization: `Bearer ${apiKey}`,
94
+ },
95
+ body: JSON.stringify({
96
+ cmd: 'Target.getTargetInfo',
97
+ params: {},
98
+ }),
99
+ });
100
+ return response.json();
101
+ });
102
+ }
103
+ getWindowInfoForSeleniumDriver(session, driver, request, requestOptions) {
104
+ var _a, _b;
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const apiKey = yield core.Supplier.get(this.apiKeySupplier);
107
+ const result = yield this.executeSeleniumCDPCommand(driver, session, apiKey || '');
108
+ const targetId = (_b = (_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.targetInfo) === null || _b === void 0 ? void 0 : _b.targetId;
58
109
  if (!targetId) {
59
110
  throw new Error('TargetId not found');
60
111
  }
61
- return yield this.getWindowInfo(sessionId, targetId, request, requestOptions);
112
+ return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
62
113
  });
63
114
  }
64
115
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airtop/sdk",
3
- "version": "0.0.11",
3
+ "version": "0.0.13",
4
4
  "private": false,
5
5
  "repository": "https://github.com/airtop-ai/airtop-node-sdk",
6
6
  "main": "./index.js",
@@ -17,10 +17,7 @@
17
17
  "formdata-node": "^6.0.3",
18
18
  "node-fetch": "2.7.0",
19
19
  "qs": "6.11.2",
20
- "js-base64": "3.7.2",
21
- "playwright": "1.47.2",
22
- "puppeteer": "22.14.0",
23
- "selenium-webdriver": "4.25.0"
20
+ "js-base64": "3.7.2"
24
21
  },
25
22
  "devDependencies": {
26
23
  "@types/url-join": "4.0.1",
@@ -56,5 +53,10 @@
56
53
  "node",
57
54
  "typescript"
58
55
  ],
59
- "license": "MIT"
56
+ "license": "MIT",
57
+ "peerDependencies": {
58
+ "playwright": "1.47.2",
59
+ "puppeteer": "22.14.0",
60
+ "selenium-webdriver": "4.25.0"
61
+ }
60
62
  }
package/reference.md CHANGED
@@ -351,7 +351,7 @@ await client.sessions.terminate("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b");
351
351
  <dl>
352
352
  <dd>
353
353
 
354
- **id:** `string` — ID of the session to delete
354
+ **id:** `string` — ID of the session to delete.
355
355
 
356
356
  </dd>
357
357
  </dl>
@@ -449,7 +449,7 @@ await client.sessions.events("string");
449
449
 
450
450
  ```typescript
451
451
  await client.windows.getWindowInfo("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "7334da2a-91b0-42c5-6156-76a5eba87430", {
452
- screenResolution: "1920x1080",
452
+ screenResolution: "1280x720",
453
453
  });
454
454
  ```
455
455
 
@@ -466,7 +466,7 @@ await client.windows.getWindowInfo("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "7334
466
466
  <dl>
467
467
  <dd>
468
468
 
469
- **sessionId:** `string` — ID of the session that owns the window
469
+ **sessionId:** `string` — ID of the session that owns the window.
470
470
 
471
471
  </dd>
472
472
  </dl>
@@ -474,7 +474,7 @@ await client.windows.getWindowInfo("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "7334
474
474
  <dl>
475
475
  <dd>
476
476
 
477
- **windowId:** `string` — id of the browser window, either the windowId (uuid) or targetId (simple string)
477
+ **windowId:** `string` — ID of the browser window, which can either be a normal AirTop windowId or a [CDP TargetId](https://chromedevtools.github.io/devtools-protocol/tot/Target/#type-TargetID) from a browser automation library like Puppeteer (typically associated with the page or main frame). Our SDKs will handle retrieving a TargetId for you from various popular browser automation libraries, but we also have details in our guides on how to do it manually.
478
478
 
479
479
  </dd>
480
480
  </dl>
@@ -532,7 +532,7 @@ await client.windows.promptContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
532
532
  <dl>
533
533
  <dd>
534
534
 
535
- **sessionId:** `string` — The session id to submit a prompt about
535
+ **sessionId:** `string` — The session id for the window.
536
536
 
537
537
  </dd>
538
538
  </dl>
@@ -540,7 +540,7 @@ await client.windows.promptContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
540
540
  <dl>
541
541
  <dd>
542
542
 
543
- **windowId:** `string` — The window id to submit a prompt about
543
+ **windowId:** `string` — The Airtop window id of the browser window to target with an Airtop AI prompt.
544
544
 
545
545
  </dd>
546
546
  </dl>
@@ -596,7 +596,7 @@ await client.windows.scrapeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
596
596
  <dl>
597
597
  <dd>
598
598
 
599
- **sessionId:** `string` — The session id to scrape
599
+ **sessionId:** `string` — The session id for the window.
600
600
 
601
601
  </dd>
602
602
  </dl>
@@ -604,7 +604,7 @@ await client.windows.scrapeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0334
604
604
  <dl>
605
605
  <dd>
606
606
 
607
- **windowId:** `string` — The window id to scrape
607
+ **windowId:** `string` — The Airtop window id of the browser window to scrape.
608
608
 
609
609
  </dd>
610
610
  </dl>
@@ -660,7 +660,7 @@ await client.windows.summarizeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0
660
660
  <dl>
661
661
  <dd>
662
662
 
663
- **sessionId:** `string` — The session id to summarize
663
+ **sessionId:** `string` — The session id for the window.
664
664
 
665
665
  </dd>
666
666
  </dl>
@@ -668,7 +668,7 @@ await client.windows.summarizeContent("6aac6f73-bd89-4a76-ab32-5a6c422e8b0b", "0
668
668
  <dl>
669
669
  <dd>
670
670
 
671
- **windowId:** `string` — The window id to summarize
671
+ **windowId:** `string` — The Airtop window id of the browser window to summarize.
672
672
 
673
673
  </dd>
674
674
  </dl>
@@ -6,5 +6,5 @@ import * as Airtop from "../../../../api/index";
6
6
  import * as core from "../../../../core";
7
7
  export declare const SessionsListRequestStatus: core.serialization.Schema<serializers.SessionsListRequestStatus.Raw, Airtop.SessionsListRequestStatus>;
8
8
  export declare namespace SessionsListRequestStatus {
9
- type Raw = "awaiting_capacity" | "initializing" | "running" | "ended";
9
+ type Raw = "awaitingCapacity" | "initializing" | "running" | "ended";
10
10
  }
@@ -28,4 +28,4 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.SessionsListRequestStatus = void 0;
30
30
  const core = __importStar(require("../../../../core"));
31
- exports.SessionsListRequestStatus = core.serialization.enum_(["awaiting_capacity", "initializing", "running", "ended"]);
31
+ exports.SessionsListRequestStatus = core.serialization.enum_(["awaitingCapacity", "initializing", "running", "ended"]);
@@ -4,12 +4,9 @@
4
4
  import * as serializers from "../index";
5
5
  import * as Airtop from "../../api/index";
6
6
  import * as core from "../../core";
7
- import { Issue } from "./Issue";
8
7
  export declare const AiResponseEnvelope: core.serialization.ObjectSchema<serializers.AiResponseEnvelope.Raw, Airtop.AiResponseEnvelope>;
9
8
  export declare namespace AiResponseEnvelope {
10
9
  interface Raw {
11
- errors?: Issue.Raw[] | null;
12
10
  modelResponse: string;
13
- warnings?: Issue.Raw[] | null;
14
11
  }
15
12
  }
@@ -28,9 +28,6 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.AiResponseEnvelope = void 0;
30
30
  const core = __importStar(require("../../core"));
31
- const Issue_1 = require("./Issue");
32
31
  exports.AiResponseEnvelope = core.serialization.object({
33
- errors: core.serialization.list(Issue_1.Issue).optional(),
34
32
  modelResponse: core.serialization.string(),
35
- warnings: core.serialization.list(Issue_1.Issue).optional(),
36
33
  });
@@ -16,6 +16,7 @@ export declare namespace ExternalSessionWithConnectionInfo {
16
16
  dateCreated?: string | null;
17
17
  id: string;
18
18
  lastActivity?: string | null;
19
+ profileId?: string | null;
19
20
  status: string;
20
21
  }
21
22
  }
@@ -38,5 +38,6 @@ exports.ExternalSessionWithConnectionInfo = core.serialization.object({
38
38
  dateCreated: core.serialization.date().optional(),
39
39
  id: core.serialization.string(),
40
40
  lastActivity: core.serialization.date().optional(),
41
+ profileId: core.serialization.string().optional(),
41
42
  status: core.serialization.string(),
42
43
  });
@@ -4,13 +4,10 @@
4
4
  import * as serializers from "../index";
5
5
  import * as Airtop from "../../api/index";
6
6
  import * as core from "../../core";
7
- import { Issue } from "./Issue";
8
7
  import { ScrapeResponseOutput } from "./ScrapeResponseOutput";
9
8
  export declare const ScrapeResponseEnvelope: core.serialization.ObjectSchema<serializers.ScrapeResponseEnvelope.Raw, Airtop.ScrapeResponseEnvelope>;
10
9
  export declare namespace ScrapeResponseEnvelope {
11
10
  interface Raw {
12
- errors?: Issue.Raw[] | null;
13
11
  modelResponse: ScrapeResponseOutput.Raw;
14
- warnings?: Issue.Raw[] | null;
15
12
  }
16
13
  }
@@ -28,10 +28,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
28
28
  Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.ScrapeResponseEnvelope = void 0;
30
30
  const core = __importStar(require("../../core"));
31
- const Issue_1 = require("./Issue");
32
31
  const ScrapeResponseOutput_1 = require("./ScrapeResponseOutput");
33
32
  exports.ScrapeResponseEnvelope = core.serialization.object({
34
- errors: core.serialization.list(Issue_1.Issue).optional(),
35
33
  modelResponse: ScrapeResponseOutput_1.ScrapeResponseOutput,
36
- warnings: core.serialization.list(Issue_1.Issue).optional(),
37
34
  });
@@ -7,8 +7,8 @@ import * as core from "../../core";
7
7
  export declare const SessionConfigV1: core.serialization.ObjectSchema<serializers.SessionConfigV1.Raw, Airtop.SessionConfigV1>;
8
8
  export declare namespace SessionConfigV1 {
9
9
  interface Raw {
10
+ baseProfileId?: string | null;
10
11
  persistProfile?: boolean | null;
11
- profileId?: string | null;
12
12
  timeoutMinutes?: number | null;
13
13
  }
14
14
  }
@@ -29,7 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
29
29
  exports.SessionConfigV1 = void 0;
30
30
  const core = __importStar(require("../../core"));
31
31
  exports.SessionConfigV1 = core.serialization.object({
32
+ baseProfileId: core.serialization.string().optional(),
32
33
  persistProfile: core.serialization.boolean().optional(),
33
- profileId: core.serialization.string().optional(),
34
34
  timeoutMinutes: core.serialization.number().optional(),
35
35
  });
@@ -8,7 +8,7 @@ class AirtopClient {
8
8
  constructor(options) {
9
9
  this._client = new Client_1.AirtopClient(options);
10
10
  this.debug = (options === null || options === void 0 ? void 0 : options.debug) || false;
11
- this._windowsWrapper = new AirtopWindows_1.AirtopWindows(this._client);
11
+ this._windowsWrapper = new AirtopWindows_1.AirtopWindows(this._client, options === null || options === void 0 ? void 0 : options.apiKey);
12
12
  this._sessionsWrapper = new AirtopSessions_1.AirtopSessions(this._client, options === null || options === void 0 ? void 0 : options.debug);
13
13
  }
14
14
  get windows() {
@@ -48,7 +48,9 @@ class AirtopSessions {
48
48
  this.log('No browser created, timed out?');
49
49
  throw new Error(`Waiting for session ready timed out`);
50
50
  }
51
- return this.getInfo(createSessionResponse.data.id, requestOptions);
51
+ const getInfoResponse = yield this.getInfo(createSessionResponse.data.id, requestOptions);
52
+ // Merge the createSessionResponse with any new data from getInfoResponse
53
+ return Object.assign(Object.assign({}, createSessionResponse), { data: Object.assign(Object.assign({}, createSessionResponse.data), getInfoResponse.data) });
52
54
  }
53
55
  catch (e) {
54
56
  this.log(e);
@@ -1,18 +1,35 @@
1
- import { Page as PuppeteerPage } from 'puppeteer';
2
- import { Page as PlaywrightPage } from 'playwright';
3
- import { WebDriver } from 'selenium-webdriver';
1
+ declare namespace puppeteer {
2
+ interface Page {
3
+ mainFrame(): any;
4
+ }
5
+ }
6
+ declare namespace playwright {
7
+ interface Page {
8
+ context(): any;
9
+ }
10
+ }
11
+ declare namespace seleniumWebdriver {
12
+ interface WebDriver {
13
+ getSession(): Promise<any>;
14
+ createCDPConnection(domain: string): Promise<any>;
15
+ }
16
+ }
4
17
  import { AirtopClient as FernClient } from '../Client';
5
18
  import * as Airtop from '../api';
6
19
  import { Windows as WindowsNamespace } from '../api/resources/windows/client/Client';
20
+ import * as core from '../core';
7
21
  export declare class AirtopWindows {
8
22
  private airtopClient;
23
+ private apiKeySupplier;
9
24
  private _windows;
10
- constructor(airtopClient: FernClient);
25
+ constructor(airtopClient: FernClient, apiKeySupplier: core.Supplier<core.BearerToken | undefined>);
11
26
  getWindowInfo(sessionId: string, windowId: string, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
12
27
  promptContent(sessionId: string, windowId: string, request: Airtop.PromptContentRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
13
28
  scrapeContent(sessionId: string, windowId: string, requestOptions?: Airtop.ScrapeContentRequest): Promise<Airtop.ScrapeResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
14
29
  summarizeContent(sessionId: string, windowId: string, request?: Airtop.SummarizeContentRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.AiResponseEnvelopeExternalSessionAiResponseMetadataWrapper>;
15
- getWindowInfoForPuppeteerPage(sessionId: string, page: PuppeteerPage, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
16
- getWindowInfoForPlaywrightPage(sessionId: string, page: PlaywrightPage, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
17
- getWindowInfoForSeleniumDriver(sessionId: string, driver: WebDriver, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
30
+ getWindowInfoForPuppeteerPage(session: Airtop.ExternalSessionWithConnectionInfo, page: puppeteer.Page, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
31
+ getWindowInfoForPlaywrightPage(session: Airtop.ExternalSessionWithConnectionInfo, page: playwright.Page, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
32
+ private executeSeleniumCDPCommand;
33
+ getWindowInfoForSeleniumDriver(session: Airtop.ExternalSessionWithConnectionInfo, driver: seleniumWebdriver.WebDriver, request?: Airtop.GetWindowInfoRequest, requestOptions?: WindowsNamespace.RequestOptions): Promise<Airtop.WindowEnvelopeDefaultMetaWrapper>;
18
34
  }
35
+ export {};
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,11 +31,17 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
32
  });
10
33
  };
34
+ var __importDefault = (this && this.__importDefault) || function (mod) {
35
+ return (mod && mod.__esModule) ? mod : { "default": mod };
36
+ };
11
37
  Object.defineProperty(exports, "__esModule", { value: true });
12
38
  exports.AirtopWindows = void 0;
39
+ const node_fetch_1 = __importDefault(require("node-fetch"));
40
+ const core = __importStar(require("../core"));
13
41
  class AirtopWindows {
14
- constructor(airtopClient) {
42
+ constructor(airtopClient, apiKeySupplier) {
15
43
  this.airtopClient = airtopClient;
44
+ this.apiKeySupplier = apiKeySupplier;
16
45
  this._windows = airtopClient.windows;
17
46
  }
18
47
  getWindowInfo(sessionId, windowId, request, requestOptions) {
@@ -31,13 +60,13 @@ class AirtopWindows {
31
60
  summarizeContent(sessionId, windowId, request, requestOptions) {
32
61
  return this._windows.summarizeContent(sessionId, windowId, request, requestOptions);
33
62
  }
34
- getWindowInfoForPuppeteerPage(sessionId, page, request, requestOptions) {
63
+ getWindowInfoForPuppeteerPage(session, page, request, requestOptions) {
35
64
  return __awaiter(this, void 0, void 0, function* () {
36
65
  const targetId = yield page.mainFrame()._id;
37
- return yield this.getWindowInfo(sessionId, targetId, request, requestOptions);
66
+ return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
38
67
  });
39
68
  }
40
- getWindowInfoForPlaywrightPage(sessionId, page, request, requestOptions) {
69
+ getWindowInfoForPlaywrightPage(session, page, request, requestOptions) {
41
70
  return __awaiter(this, void 0, void 0, function* () {
42
71
  // Retrieve target information
43
72
  const cdpSession = yield page.context().newCDPSession(page);
@@ -46,19 +75,41 @@ class AirtopWindows {
46
75
  if (!targetId) {
47
76
  throw new Error('TargetId not found');
48
77
  }
49
- return yield this.getWindowInfo(sessionId, targetId, request, requestOptions);
78
+ return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
50
79
  });
51
80
  }
52
- getWindowInfoForSeleniumDriver(sessionId, driver, request, requestOptions) {
81
+ executeSeleniumCDPCommand(driver, session, apiKey) {
53
82
  return __awaiter(this, void 0, void 0, function* () {
54
- const cdpSession = yield driver.createCDPConnection('page');
55
- // Fetch the available targets using the Target domain
56
- const { targetInfo } = yield cdpSession.send('Target.getTargetInfo');
57
- const targetId = targetInfo.targetId;
83
+ // Get the current WebDriver session ID
84
+ const webDriverSessionId = (yield driver.getSession()).getId();
85
+ if (!webDriverSessionId) {
86
+ throw new Error('No WebDriver session available');
87
+ }
88
+ const chromedriverSessionUrl = `${session.chromedriverUrl}/session/${webDriverSessionId}/chromium/send_command_and_get_result`;
89
+ const response = yield (0, node_fetch_1.default)(chromedriverSessionUrl, {
90
+ method: 'POST',
91
+ headers: {
92
+ 'Content-Type': 'application/json',
93
+ Authorization: `Bearer ${apiKey}`,
94
+ },
95
+ body: JSON.stringify({
96
+ cmd: 'Target.getTargetInfo',
97
+ params: {},
98
+ }),
99
+ });
100
+ return response.json();
101
+ });
102
+ }
103
+ getWindowInfoForSeleniumDriver(session, driver, request, requestOptions) {
104
+ var _a, _b;
105
+ return __awaiter(this, void 0, void 0, function* () {
106
+ const apiKey = yield core.Supplier.get(this.apiKeySupplier);
107
+ const result = yield this.executeSeleniumCDPCommand(driver, session, apiKey || '');
108
+ const targetId = (_b = (_a = result === null || result === void 0 ? void 0 : result.value) === null || _a === void 0 ? void 0 : _a.targetInfo) === null || _b === void 0 ? void 0 : _b.targetId;
58
109
  if (!targetId) {
59
110
  throw new Error('TargetId not found');
60
111
  }
61
- return yield this.getWindowInfo(sessionId, targetId, request, requestOptions);
112
+ return yield this.getWindowInfo(session.id, targetId, request, requestOptions);
62
113
  });
63
114
  }
64
115
  }