@airtop/sdk 1.0.0-alpha2.4 → 1.0.0-alpha2.40
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/index.cjs +1092 -189
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +810 -65
- package/dist/index.d.ts +810 -65
- package/dist/index.js +1084 -181
- package/dist/index.js.map +1 -1
- package/package.json +17 -15
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; } function _optionalChainDelete(ops) { const result = _optionalChain(ops); return result == null ? true : result; }var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
2
|
var __commonJS = (cb, mod) => function __require() {
|
|
3
3
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
4
|
};
|
|
@@ -9,7 +9,7 @@ var require_package = __commonJS({
|
|
|
9
9
|
module.exports = {
|
|
10
10
|
name: "@airtop/sdk",
|
|
11
11
|
description: "Airtop SDK for TypeScript",
|
|
12
|
-
version: "1.0.0-alpha2.
|
|
12
|
+
version: "1.0.0-alpha2.40",
|
|
13
13
|
type: "module",
|
|
14
14
|
main: "./dist/index.cjs",
|
|
15
15
|
module: "./dist/index.js",
|
|
@@ -38,34 +38,36 @@ var require_package = __commonJS({
|
|
|
38
38
|
"agentic"
|
|
39
39
|
],
|
|
40
40
|
scripts: {
|
|
41
|
-
"
|
|
42
|
-
"test:e2e": "vitest --run",
|
|
41
|
+
"test:e2e": "vitest --run --max-concurrency=1 --no-file-parallelism",
|
|
42
|
+
"test:e2e:parallel": "vitest --run",
|
|
43
43
|
"build:dev": "node_modules/.bin/hash-runner",
|
|
44
|
+
build: "tsup src/index.ts",
|
|
44
45
|
clean: "rm -rf .turbo node_modules dist",
|
|
45
|
-
lint: "biome check --write --unsafe src
|
|
46
|
-
"
|
|
46
|
+
lint: "biome check --no-errors-on-unmatched --write --unsafe src",
|
|
47
|
+
"lint:staged": "biome check --no-errors-on-unmatched --write --unsafe --staged src",
|
|
48
|
+
"verify-types": "tsc --noEmit && tsc --noEmit --project tsconfig.e2e.json"
|
|
47
49
|
},
|
|
48
50
|
dependencies: {
|
|
51
|
+
"@airtop/core": "0.1.0-alpha.49",
|
|
49
52
|
"@airtop/json-schema-adapter": "workspace:*",
|
|
50
|
-
"@airtop/core": "0.1.0-alpha.22",
|
|
51
53
|
"date-fns": "4.1.0",
|
|
52
|
-
loglayer: "
|
|
54
|
+
loglayer: "8.1.0",
|
|
53
55
|
"serialize-error": "12.0.0",
|
|
54
56
|
uuid: "11.1.0"
|
|
55
57
|
},
|
|
56
58
|
devDependencies: {
|
|
57
|
-
"@biomejs/biome": "
|
|
58
|
-
"@dotenvx/dotenvx": "1.
|
|
59
|
+
"@biomejs/biome": "2.2.4",
|
|
60
|
+
"@dotenvx/dotenvx": "1.49.1",
|
|
59
61
|
"@internal/tsconfig": "workspace:*",
|
|
60
62
|
"deep-utility-types": "1.3.1",
|
|
61
63
|
"env-var": "7.5.0",
|
|
62
|
-
"hash-runner": "
|
|
64
|
+
"hash-runner": "4.0.0",
|
|
63
65
|
nanoid: "5.1.5",
|
|
64
|
-
tsup: "8.
|
|
65
|
-
typescript: "5.
|
|
66
|
+
tsup: "8.5.0",
|
|
67
|
+
typescript: "5.9.2",
|
|
66
68
|
"utility-types": "3.11.0",
|
|
67
69
|
uuid: "11.1.0",
|
|
68
|
-
vitest: "3.
|
|
70
|
+
vitest: "3.2.4",
|
|
69
71
|
zod: "*"
|
|
70
72
|
},
|
|
71
73
|
bugs: "https://github.com/airtop-ai/airtop-sdk/issues",
|
|
@@ -79,13 +81,24 @@ var require_package = __commonJS({
|
|
|
79
81
|
optionalDependencies: {
|
|
80
82
|
"@airtop/json-schema-adapter-zod": "workspace:*"
|
|
81
83
|
},
|
|
82
|
-
packageManager: "pnpm@10.
|
|
84
|
+
packageManager: "pnpm@10.17.0"
|
|
83
85
|
};
|
|
84
86
|
}
|
|
85
87
|
});
|
|
86
88
|
|
|
89
|
+
// src/index.ts
|
|
90
|
+
var _indexjs = require('@airtop/core/resources/index.js'); var AirtopCore4 = _interopRequireWildcard(_indexjs);
|
|
91
|
+
var _sharedmjs = require('@airtop/core/resources/shared.mjs'); var AirtopCoreShared = _interopRequireWildcard(_sharedmjs);
|
|
92
|
+
var _windowsjs = require('@airtop/core/resources/windows.js'); var AirtopCoreWindows = _interopRequireWildcard(_windowsjs);
|
|
93
|
+
|
|
87
94
|
// src/AirtopBase.ts
|
|
88
95
|
var _datefns = require('date-fns');
|
|
96
|
+
|
|
97
|
+
// src/constants.ts
|
|
98
|
+
var TIMEOUT_SECONDS_DEFAULT_VALUE = 300;
|
|
99
|
+
var DEFAULT_POLLING_INTERVAL_MS = 500;
|
|
100
|
+
|
|
101
|
+
// src/AirtopBase.ts
|
|
89
102
|
var AirtopBase = class {
|
|
90
103
|
/**
|
|
91
104
|
* Logger instance for the SDK
|
|
@@ -102,6 +115,21 @@ var AirtopBase = class {
|
|
|
102
115
|
* @internal
|
|
103
116
|
**/
|
|
104
117
|
|
|
118
|
+
/**
|
|
119
|
+
* The job id for the ongoing automation
|
|
120
|
+
* @internal
|
|
121
|
+
*/
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Instance for sending agent events
|
|
125
|
+
* @internal
|
|
126
|
+
*/
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The default timeout in seconds for API requests.
|
|
130
|
+
* @internal
|
|
131
|
+
*/
|
|
132
|
+
|
|
105
133
|
/**
|
|
106
134
|
* Creates a new instance of AirtopBase
|
|
107
135
|
* @param config - Configuration options for the SDK
|
|
@@ -110,6 +138,29 @@ var AirtopBase = class {
|
|
|
110
138
|
this.log = config.log.withPrefix("[Airtop]");
|
|
111
139
|
this.client = config.client;
|
|
112
140
|
this.outputJsonAdapter = config.outputSchemaAdapter;
|
|
141
|
+
this.jobId = config.jobId;
|
|
142
|
+
this.defaultTimeoutInSeconds = _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE));
|
|
143
|
+
if (config.agentEventPublisher) {
|
|
144
|
+
this.agentEventPublisher = config.agentEventPublisher;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Sets the publisher for sending agent events. Internal use only.
|
|
149
|
+
* @internal
|
|
150
|
+
*/
|
|
151
|
+
_setAgentEventPublisher(logger) {
|
|
152
|
+
this.agentEventPublisher = logger;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Sends a payload to the agent with the specified event name.
|
|
156
|
+
* @param eventName The name of the event
|
|
157
|
+
* @param payload The payload to send to the agent
|
|
158
|
+
* @internal
|
|
159
|
+
*/
|
|
160
|
+
_sendAgentPayload(eventName, payload) {
|
|
161
|
+
if (this.agentEventPublisher) {
|
|
162
|
+
this.agentEventPublisher.withMetadata(payload).info(eventName);
|
|
163
|
+
}
|
|
113
164
|
}
|
|
114
165
|
/**
|
|
115
166
|
* Returns the API key used by the SDK
|
|
@@ -163,7 +214,10 @@ var AirtopBase = class {
|
|
|
163
214
|
getCommonConfig() {
|
|
164
215
|
return {
|
|
165
216
|
client: this.client,
|
|
166
|
-
log: this.log
|
|
217
|
+
log: this.log,
|
|
218
|
+
jobId: this.jobId,
|
|
219
|
+
outputSchemaAdapter: this.outputJsonAdapter,
|
|
220
|
+
agentEventPublisher: this.agentEventPublisher
|
|
167
221
|
};
|
|
168
222
|
}
|
|
169
223
|
/**
|
|
@@ -174,7 +228,7 @@ var AirtopBase = class {
|
|
|
174
228
|
*/
|
|
175
229
|
resolveRequestOptions(options = {}) {
|
|
176
230
|
return {
|
|
177
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, options.timeoutInSeconds ||
|
|
231
|
+
timeout: _datefns.secondsToMilliseconds.call(void 0, options.timeoutInSeconds || this.defaultTimeoutInSeconds),
|
|
178
232
|
maxRetries: options.maxRetries || 0,
|
|
179
233
|
signal: options.abortSignal
|
|
180
234
|
};
|
|
@@ -183,10 +237,94 @@ var AirtopBase = class {
|
|
|
183
237
|
|
|
184
238
|
// src/AirtopClient.ts
|
|
185
239
|
var _core = require('@airtop/core');
|
|
186
|
-
var
|
|
240
|
+
var _secondsToMilliseconds = require('date-fns/secondsToMilliseconds');
|
|
187
241
|
var _loglayer = require('loglayer');
|
|
188
242
|
var _serializeerror = require('serialize-error');
|
|
189
243
|
|
|
244
|
+
// src/file/AirtopFileClient.ts
|
|
245
|
+
var AirtopFileClient = class extends AirtopBase {
|
|
246
|
+
/**
|
|
247
|
+
* The file id
|
|
248
|
+
* @internal
|
|
249
|
+
*/
|
|
250
|
+
|
|
251
|
+
/**
|
|
252
|
+
* Creates a new AirtopFileClient instance.
|
|
253
|
+
* @param config - Common configuration options
|
|
254
|
+
* @param fileId - File id
|
|
255
|
+
*/
|
|
256
|
+
constructor(config, fileId) {
|
|
257
|
+
super(config);
|
|
258
|
+
this.log = this.log.child().withContext({
|
|
259
|
+
fileId
|
|
260
|
+
});
|
|
261
|
+
this.fileId = fileId;
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Gets a file by ID.
|
|
265
|
+
* @param requestOptions
|
|
266
|
+
* @returns AirtopFile instance
|
|
267
|
+
*/
|
|
268
|
+
async getFile(requestOptions = {}) {
|
|
269
|
+
const results = await this.client.files.get(this.fileId, this.resolveRequestOptions(requestOptions));
|
|
270
|
+
return new AirtopFile(this.getCommonConfig(), results);
|
|
271
|
+
}
|
|
272
|
+
/**
|
|
273
|
+
* Removes a file by ID.
|
|
274
|
+
* @param requestOptions - Request options
|
|
275
|
+
*/
|
|
276
|
+
async removeFile(requestOptions = {}) {
|
|
277
|
+
return this.client.files.delete(this.fileId, this.resolveRequestOptions(requestOptions));
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
|
|
281
|
+
// src/file/AirtopFile.ts
|
|
282
|
+
var AirtopFile = class extends AirtopFileClient {
|
|
283
|
+
/**
|
|
284
|
+
* The file data containing details such as the id, file name, type, and download URL.
|
|
285
|
+
* Includes all information about the file that was processed or retrieved.
|
|
286
|
+
*/
|
|
287
|
+
|
|
288
|
+
/**
|
|
289
|
+
* The metadata associated with the file operation.
|
|
290
|
+
* Contains information about the request that processed the file.
|
|
291
|
+
*/
|
|
292
|
+
|
|
293
|
+
/**
|
|
294
|
+
* Warnings that occurred during file processing or operation.
|
|
295
|
+
* These are non-fatal issues that didn't prevent file processing.
|
|
296
|
+
*/
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Errors that occurred during file processing or operation.
|
|
300
|
+
* These are fatal issues that prevented file processing.
|
|
301
|
+
*/
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* Creates a new AirtopFile instance.
|
|
305
|
+
* @param config - Common configuration options for the file
|
|
306
|
+
* @param fileData - File data
|
|
307
|
+
*/
|
|
308
|
+
constructor(config, fileData) {
|
|
309
|
+
super(config, fileData.data.id);
|
|
310
|
+
this.meta = fileData.meta;
|
|
311
|
+
this.data = fileData.data;
|
|
312
|
+
this.warnings = fileData.warnings;
|
|
313
|
+
this.errors = fileData.errors;
|
|
314
|
+
}
|
|
315
|
+
/**
|
|
316
|
+
* Returns response data as a JSON object.
|
|
317
|
+
*/
|
|
318
|
+
toJSON() {
|
|
319
|
+
return {
|
|
320
|
+
data: this.data,
|
|
321
|
+
meta: this.meta,
|
|
322
|
+
warnings: this.warnings,
|
|
323
|
+
errors: this.errors
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
};
|
|
327
|
+
|
|
190
328
|
// src/logger-utils.ts
|
|
191
329
|
var processLogMessage = (log, logLevel, ...args) => {
|
|
192
330
|
if (logLevel === "off") {
|
|
@@ -234,8 +372,165 @@ var processLogMessage = (log, logLevel, ...args) => {
|
|
|
234
372
|
// src/session/AirtopSessionClient.ts
|
|
235
373
|
|
|
236
374
|
|
|
237
|
-
// src/
|
|
375
|
+
// src/async-utils.ts
|
|
376
|
+
|
|
377
|
+
|
|
378
|
+
// src/types.ts
|
|
379
|
+
var AirtopError = class extends Error {
|
|
380
|
+
|
|
381
|
+
|
|
382
|
+
constructor(issues, metadata) {
|
|
383
|
+
const errorMessage = issues.map((issue) => issue.message).join("\n");
|
|
384
|
+
const errorMessageWithMetadata = metadata ? `${errorMessage}
|
|
385
|
+
${JSON.stringify(metadata)}` : errorMessage;
|
|
386
|
+
super(errorMessageWithMetadata);
|
|
387
|
+
this.issues = issues;
|
|
388
|
+
this.metadata = metadata;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
238
391
|
|
|
392
|
+
// src/async-utils.ts
|
|
393
|
+
async function waitForRequestCompletion(client, requestId, requestOptions) {
|
|
394
|
+
const startTime = Date.now();
|
|
395
|
+
const timeoutMs = _datefns.secondsToMilliseconds.call(void 0, _optionalChain([requestOptions, 'optionalAccess', _5 => _5.timeoutInSeconds]) || TIMEOUT_SECONDS_DEFAULT_VALUE);
|
|
396
|
+
while (Date.now() - startTime < timeoutMs) {
|
|
397
|
+
const apiResponse = await client.requests.getRequestStatusV2(requestId, requestOptions);
|
|
398
|
+
if (apiResponse.status === "completed") {
|
|
399
|
+
return apiResponse.response;
|
|
400
|
+
}
|
|
401
|
+
if (apiResponse.status === "error") {
|
|
402
|
+
throw new Error(apiResponse.error);
|
|
403
|
+
}
|
|
404
|
+
await new Promise((resolve) => setTimeout(resolve, DEFAULT_POLLING_INTERVAL_MS));
|
|
405
|
+
}
|
|
406
|
+
throw new Error("Waiting for request timed out");
|
|
407
|
+
}
|
|
408
|
+
async function withRequestCompletionPolling(client, fn, requestOptions) {
|
|
409
|
+
try {
|
|
410
|
+
const response = await fn();
|
|
411
|
+
return waitForRequestCompletion(client, response.requestId, requestOptions);
|
|
412
|
+
} catch (thrownError) {
|
|
413
|
+
if (_optionalChain([thrownError, 'access', _6 => _6.error, 'optionalAccess', _7 => _7.errors])) {
|
|
414
|
+
throw new AirtopError(thrownError.error.errors, {
|
|
415
|
+
requestId: thrownError.error.requestId
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
throw thrownError;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
// src/window/AirtopNode.ts
|
|
423
|
+
var AirtopNode = class {
|
|
424
|
+
/**
|
|
425
|
+
* The window client
|
|
426
|
+
*/
|
|
427
|
+
|
|
428
|
+
/**
|
|
429
|
+
* The node handle id to use for all requests
|
|
430
|
+
*/
|
|
431
|
+
|
|
432
|
+
/**
|
|
433
|
+
* The xpath selector of the node
|
|
434
|
+
*/
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* Constructor
|
|
438
|
+
* @param client - The window client
|
|
439
|
+
* @param nodeData - The node data to use for all requests
|
|
440
|
+
*/
|
|
441
|
+
constructor(client, nodeData) {
|
|
442
|
+
this.windowClient = client;
|
|
443
|
+
this.nodeHandleId = nodeData.id;
|
|
444
|
+
this.selector = nodeData.xpath;
|
|
445
|
+
}
|
|
446
|
+
/**
|
|
447
|
+
* Extract content from the node
|
|
448
|
+
* @param prompt - The prompt to use for the extraction
|
|
449
|
+
* @param config - The configuration to use for the extraction
|
|
450
|
+
* @param requestOptions - The request options to use for the extraction
|
|
451
|
+
*/
|
|
452
|
+
async extract(prompt, config, requestOptions = {}) {
|
|
453
|
+
const augmentedConfig = {
|
|
454
|
+
...config,
|
|
455
|
+
nodeHandleId: this.nodeHandleId
|
|
456
|
+
};
|
|
457
|
+
return this.windowClient.extract(prompt, augmentedConfig, requestOptions);
|
|
458
|
+
}
|
|
459
|
+
/**
|
|
460
|
+
* Act on the node
|
|
461
|
+
* @param prompt - The prompt to use for the action
|
|
462
|
+
* @param config - The configuration to use for the action
|
|
463
|
+
* @param requestOptions - The request options to use for the action
|
|
464
|
+
*/
|
|
465
|
+
async act(prompt, config, requestOptions = {}) {
|
|
466
|
+
const augmentedConfig = {
|
|
467
|
+
...config,
|
|
468
|
+
nodeHandleId: this.nodeHandleId
|
|
469
|
+
};
|
|
470
|
+
return this.windowClient.act(prompt, augmentedConfig, requestOptions);
|
|
471
|
+
}
|
|
472
|
+
/**
|
|
473
|
+
* Execute an LLM call on the node
|
|
474
|
+
* @param prompt - The prompt to use for the LLM call
|
|
475
|
+
* @param config - The configuration to use for the LLM call
|
|
476
|
+
* @param requestOptions - The request options to use for the LLM call
|
|
477
|
+
*/
|
|
478
|
+
async llm(prompt, config, requestOptions = {}) {
|
|
479
|
+
return this.windowClient.llm(prompt, { ...config, nodeHandleId: this.nodeHandleId }, requestOptions);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Find one element in the node
|
|
483
|
+
* @param prompt - The prompt to use for the find one
|
|
484
|
+
* @param config - The configuration to use for the find one
|
|
485
|
+
* @param requestOptions - The request options to use for the find one
|
|
486
|
+
*/
|
|
487
|
+
async findOne(prompt, config, requestOptions = {}) {
|
|
488
|
+
const augmentedConfig = {
|
|
489
|
+
...config,
|
|
490
|
+
nodeHandleId: this.nodeHandleId
|
|
491
|
+
};
|
|
492
|
+
return this.windowClient.findOne(prompt, augmentedConfig, requestOptions);
|
|
493
|
+
}
|
|
494
|
+
/**
|
|
495
|
+
* Find one element in the node
|
|
496
|
+
* @param prompt - The prompt to use for the find one
|
|
497
|
+
* @param config - The configuration to use for the find one
|
|
498
|
+
* @param requestOptions - The request options to use for the find one
|
|
499
|
+
*/
|
|
500
|
+
async findOneOptional(prompt, config, requestOptions = {}) {
|
|
501
|
+
const augmentedConfig = {
|
|
502
|
+
...config,
|
|
503
|
+
nodeHandleId: this.nodeHandleId
|
|
504
|
+
};
|
|
505
|
+
return this.windowClient.findOneOptional(prompt, augmentedConfig, requestOptions);
|
|
506
|
+
}
|
|
507
|
+
/**
|
|
508
|
+
* Find many elements in the node
|
|
509
|
+
* @param prompt - The prompt to use for the find many
|
|
510
|
+
* @param config - The configuration to use for the find many
|
|
511
|
+
* @param requestOptions - The request options to use for the find many
|
|
512
|
+
*/
|
|
513
|
+
async findMany(prompt, config, requestOptions = {}) {
|
|
514
|
+
const augmentedConfig = {
|
|
515
|
+
...config,
|
|
516
|
+
nodeHandleId: this.nodeHandleId
|
|
517
|
+
};
|
|
518
|
+
return this.windowClient.findMany(prompt, augmentedConfig, requestOptions);
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Find many elements in the node
|
|
522
|
+
* @param prompt - The prompt to use for the find many
|
|
523
|
+
* @param config - The configuration to use for the find many
|
|
524
|
+
* @param requestOptions - The request options to use for the find many
|
|
525
|
+
*/
|
|
526
|
+
async findManyOptional(prompt, config, requestOptions = {}) {
|
|
527
|
+
const augmentedConfig = {
|
|
528
|
+
...config,
|
|
529
|
+
nodeHandleId: this.nodeHandleId
|
|
530
|
+
};
|
|
531
|
+
return this.windowClient.findManyOptional(prompt, augmentedConfig, requestOptions);
|
|
532
|
+
}
|
|
533
|
+
};
|
|
239
534
|
|
|
240
535
|
// src/window/AirtopWindowScreenshot.ts
|
|
241
536
|
function extractMimeAndBase64(dataUrl) {
|
|
@@ -336,6 +631,19 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
336
631
|
});
|
|
337
632
|
this.windowId = windowId;
|
|
338
633
|
this.sessionId = sessionId;
|
|
634
|
+
this.client.windows.get(
|
|
635
|
+
this.windowId,
|
|
636
|
+
{
|
|
637
|
+
sessionId: this.sessionId
|
|
638
|
+
},
|
|
639
|
+
this.resolveRequestOptions()
|
|
640
|
+
).then((results) => {
|
|
641
|
+
this._sendAgentPayload("LiveViewUrl", {
|
|
642
|
+
liveViewUrl: results.data.liveViewUrl,
|
|
643
|
+
windowId: this.windowId,
|
|
644
|
+
sessionId: this.sessionId
|
|
645
|
+
});
|
|
646
|
+
});
|
|
339
647
|
}
|
|
340
648
|
/**
|
|
341
649
|
* Gets the window ID.
|
|
@@ -377,17 +685,21 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
377
685
|
this.log.withMetadata({
|
|
378
686
|
elementDescription
|
|
379
687
|
}).info("Clicking on element");
|
|
380
|
-
return
|
|
381
|
-
this.
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
688
|
+
return withRequestCompletionPolling(
|
|
689
|
+
this.client,
|
|
690
|
+
() => this.client.windows.clickAsync(
|
|
691
|
+
this.getWindowId(),
|
|
692
|
+
{
|
|
693
|
+
...config,
|
|
694
|
+
createDraftTestCase: true,
|
|
695
|
+
// Always create a draft test case from Stainless SDK
|
|
696
|
+
elementDescription,
|
|
697
|
+
sessionId: this.sessionId
|
|
698
|
+
},
|
|
699
|
+
{
|
|
700
|
+
...this.resolveRequestOptions(requestOptions)
|
|
701
|
+
}
|
|
702
|
+
)
|
|
391
703
|
);
|
|
392
704
|
}
|
|
393
705
|
/**
|
|
@@ -409,17 +721,21 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
409
721
|
*/
|
|
410
722
|
async hover(elementDescription, config, requestOptions = {}) {
|
|
411
723
|
this.log.withMetadata(config).info("Hovering over window");
|
|
412
|
-
return
|
|
413
|
-
this.
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
724
|
+
return withRequestCompletionPolling(
|
|
725
|
+
this.client,
|
|
726
|
+
() => this.client.windows.hoverAsync(
|
|
727
|
+
this.getWindowId(),
|
|
728
|
+
{
|
|
729
|
+
elementDescription,
|
|
730
|
+
sessionId: this.sessionId,
|
|
731
|
+
createDraftTestCase: true,
|
|
732
|
+
// Always create a draft test case from Stainless SDK
|
|
733
|
+
...config || {}
|
|
734
|
+
},
|
|
735
|
+
{
|
|
736
|
+
...this.resolveRequestOptions(requestOptions)
|
|
737
|
+
}
|
|
738
|
+
)
|
|
423
739
|
);
|
|
424
740
|
}
|
|
425
741
|
/**
|
|
@@ -441,7 +757,6 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
441
757
|
...config
|
|
442
758
|
},
|
|
443
759
|
{
|
|
444
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
|
445
760
|
...this.resolveRequestOptions(requestOptions)
|
|
446
761
|
}
|
|
447
762
|
);
|
|
@@ -453,19 +768,33 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
453
768
|
* @param requestOptions - Request options
|
|
454
769
|
* @returns Promise resolving to the monitoring operation result
|
|
455
770
|
*/
|
|
456
|
-
async monitor(condition, config, requestOptions = {}) {
|
|
771
|
+
async monitor(condition, config = {}, requestOptions = {}) {
|
|
457
772
|
this.log.withMetadata().info("Monitoring window");
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
},
|
|
465
|
-
{
|
|
466
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
|
467
|
-
...this.resolveRequestOptions(requestOptions)
|
|
773
|
+
if (!_optionalChain([config, 'optionalAccess', _8 => _8.configuration, 'optionalAccess', _9 => _9.interval, 'optionalAccess', _10 => _10.timeoutSeconds])) {
|
|
774
|
+
if (!config.configuration) {
|
|
775
|
+
config.configuration = {};
|
|
776
|
+
}
|
|
777
|
+
if (!config.configuration.interval) {
|
|
778
|
+
config.configuration.interval = {};
|
|
468
779
|
}
|
|
780
|
+
config.configuration.interval.timeoutSeconds = this.defaultTimeoutInSeconds;
|
|
781
|
+
}
|
|
782
|
+
if (!_optionalChain([config, 'optionalAccess', _11 => _11.timeThresholdSeconds])) {
|
|
783
|
+
config.timeThresholdSeconds = this.defaultTimeoutInSeconds;
|
|
784
|
+
}
|
|
785
|
+
return withRequestCompletionPolling(
|
|
786
|
+
this.client,
|
|
787
|
+
() => this.client.windows.monitorAsync(
|
|
788
|
+
this.getWindowId(),
|
|
789
|
+
{
|
|
790
|
+
condition,
|
|
791
|
+
sessionId: this.sessionId,
|
|
792
|
+
...config || {}
|
|
793
|
+
},
|
|
794
|
+
{
|
|
795
|
+
...this.resolveRequestOptions(requestOptions)
|
|
796
|
+
}
|
|
797
|
+
)
|
|
469
798
|
);
|
|
470
799
|
}
|
|
471
800
|
/**
|
|
@@ -480,20 +809,24 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
480
809
|
prompt
|
|
481
810
|
}).info("Performing a page query");
|
|
482
811
|
const newConfig = config;
|
|
483
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
812
|
+
if (_optionalChain([config, 'optionalAccess', _12 => _12.configuration, 'access', _13 => _13.outputSchema])) {
|
|
484
813
|
newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
|
|
485
814
|
}
|
|
486
|
-
return
|
|
487
|
-
this.
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
815
|
+
return withRequestCompletionPolling(
|
|
816
|
+
this.client,
|
|
817
|
+
() => this.client.windows.pageQueryAsync(
|
|
818
|
+
this.getWindowId(),
|
|
819
|
+
{
|
|
820
|
+
sessionId: this.sessionId,
|
|
821
|
+
prompt,
|
|
822
|
+
createDraftTestCase: true,
|
|
823
|
+
// Always create a draft test case from Stainless SDK
|
|
824
|
+
...newConfig || {}
|
|
825
|
+
},
|
|
826
|
+
{
|
|
827
|
+
...this.resolveRequestOptions(requestOptions)
|
|
828
|
+
}
|
|
829
|
+
)
|
|
497
830
|
);
|
|
498
831
|
}
|
|
499
832
|
/**
|
|
@@ -508,20 +841,22 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
508
841
|
prompt
|
|
509
842
|
}).info("Performing a paginated extraction");
|
|
510
843
|
const newConfig = config;
|
|
511
|
-
if (_optionalChain([config, 'optionalAccess',
|
|
844
|
+
if (_optionalChain([config, 'optionalAccess', _14 => _14.configuration, 'access', _15 => _15.outputSchema])) {
|
|
512
845
|
newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
|
|
513
846
|
}
|
|
514
|
-
return
|
|
515
|
-
this.
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
847
|
+
return withRequestCompletionPolling(
|
|
848
|
+
this.client,
|
|
849
|
+
() => this.client.windows.paginatedExtractionAsync(
|
|
850
|
+
this.getWindowId(),
|
|
851
|
+
{
|
|
852
|
+
prompt,
|
|
853
|
+
sessionId: this.sessionId,
|
|
854
|
+
...newConfig || {}
|
|
855
|
+
},
|
|
856
|
+
{
|
|
857
|
+
...this.resolveRequestOptions(requestOptions)
|
|
858
|
+
}
|
|
859
|
+
)
|
|
525
860
|
);
|
|
526
861
|
}
|
|
527
862
|
/**
|
|
@@ -532,16 +867,18 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
532
867
|
*/
|
|
533
868
|
async scrape(config, requestOptions = {}) {
|
|
534
869
|
this.log.info("Scraping window");
|
|
535
|
-
return
|
|
536
|
-
this.
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
870
|
+
return withRequestCompletionPolling(
|
|
871
|
+
this.client,
|
|
872
|
+
() => this.client.windows.scrapeAsync(
|
|
873
|
+
this.getWindowId(),
|
|
874
|
+
{
|
|
875
|
+
sessionId: this.sessionId,
|
|
876
|
+
...config || {}
|
|
877
|
+
},
|
|
878
|
+
{
|
|
879
|
+
...this.resolveRequestOptions(requestOptions)
|
|
880
|
+
}
|
|
881
|
+
)
|
|
545
882
|
);
|
|
546
883
|
}
|
|
547
884
|
/**
|
|
@@ -552,16 +889,18 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
552
889
|
*/
|
|
553
890
|
async screenshot(config, requestOptions = {}) {
|
|
554
891
|
this.log.info("Screenshotting window");
|
|
555
|
-
const resp = await
|
|
556
|
-
this.
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
892
|
+
const resp = await withRequestCompletionPolling(
|
|
893
|
+
this.client,
|
|
894
|
+
() => this.client.windows.screenshotAsync(
|
|
895
|
+
this.getWindowId(),
|
|
896
|
+
{
|
|
897
|
+
sessionId: this.sessionId,
|
|
898
|
+
...config || {}
|
|
899
|
+
},
|
|
900
|
+
{
|
|
901
|
+
...this.resolveRequestOptions(requestOptions)
|
|
902
|
+
}
|
|
903
|
+
)
|
|
565
904
|
);
|
|
566
905
|
return new AirtopWindowScreenshot(resp);
|
|
567
906
|
}
|
|
@@ -573,16 +912,18 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
573
912
|
*/
|
|
574
913
|
async scroll(config, requestOptions = {}) {
|
|
575
914
|
this.log.info("Scrolling window");
|
|
576
|
-
return
|
|
577
|
-
this.
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
915
|
+
return withRequestCompletionPolling(
|
|
916
|
+
this.client,
|
|
917
|
+
() => this.client.windows.scrollAsync(
|
|
918
|
+
this.getWindowId(),
|
|
919
|
+
{
|
|
920
|
+
sessionId: this.sessionId,
|
|
921
|
+
...config || {}
|
|
922
|
+
},
|
|
923
|
+
{
|
|
924
|
+
...this.resolveRequestOptions(requestOptions)
|
|
925
|
+
}
|
|
926
|
+
)
|
|
586
927
|
);
|
|
587
928
|
}
|
|
588
929
|
/**
|
|
@@ -596,17 +937,200 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
|
596
937
|
this.log.withMetadata({
|
|
597
938
|
text
|
|
598
939
|
}).info("Typing text");
|
|
599
|
-
return
|
|
600
|
-
this.
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
940
|
+
return withRequestCompletionPolling(
|
|
941
|
+
this.client,
|
|
942
|
+
() => this.client.windows.typeAsync(
|
|
943
|
+
this.getWindowId(),
|
|
944
|
+
{
|
|
945
|
+
sessionId: this.sessionId,
|
|
946
|
+
text,
|
|
947
|
+
createDraftTestCase: true,
|
|
948
|
+
// Always create a draft test case from Stainless SDK
|
|
949
|
+
...config || {}
|
|
950
|
+
},
|
|
951
|
+
{
|
|
952
|
+
...this.resolveRequestOptions(requestOptions)
|
|
953
|
+
}
|
|
954
|
+
)
|
|
955
|
+
);
|
|
956
|
+
}
|
|
957
|
+
async extract(prompt, config, requestOptions = {}) {
|
|
958
|
+
this.log.withMetadata({ prompt }).info("Extracting content");
|
|
959
|
+
return withRequestCompletionPolling(
|
|
960
|
+
this.client,
|
|
961
|
+
() => this.client.windows.extract(
|
|
962
|
+
this.getWindowId(),
|
|
963
|
+
{
|
|
964
|
+
prompt,
|
|
965
|
+
sessionId: this.sessionId,
|
|
966
|
+
jobId: this.jobId,
|
|
967
|
+
...config || {}
|
|
968
|
+
},
|
|
969
|
+
{
|
|
970
|
+
...this.resolveRequestOptions(requestOptions)
|
|
971
|
+
}
|
|
972
|
+
)
|
|
973
|
+
);
|
|
974
|
+
}
|
|
975
|
+
async act(prompt, config, requestOptions = {}) {
|
|
976
|
+
this.log.withMetadata({ prompt }).info("Acting on content");
|
|
977
|
+
return withRequestCompletionPolling(
|
|
978
|
+
this.client,
|
|
979
|
+
() => this.client.windows.act(
|
|
980
|
+
this.getWindowId(),
|
|
981
|
+
{
|
|
982
|
+
prompt,
|
|
983
|
+
sessionId: this.sessionId,
|
|
984
|
+
jobId: this.jobId,
|
|
985
|
+
...config || {}
|
|
986
|
+
},
|
|
987
|
+
{
|
|
988
|
+
...this.resolveRequestOptions(requestOptions)
|
|
989
|
+
}
|
|
990
|
+
)
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
async llm(prompt, config, requestOptions = {}) {
|
|
994
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
|
995
|
+
return withRequestCompletionPolling(
|
|
996
|
+
this.client,
|
|
997
|
+
() => this.client.windows.llm(
|
|
998
|
+
this.getWindowId(),
|
|
999
|
+
{
|
|
1000
|
+
prompt,
|
|
1001
|
+
sessionId: this.sessionId,
|
|
1002
|
+
jobId: this.jobId,
|
|
1003
|
+
...config || {},
|
|
1004
|
+
includeWebContext: true,
|
|
1005
|
+
// Always include web context for window.llm() calls
|
|
1006
|
+
outputSchema: _optionalChain([config, 'optionalAccess', _16 => _16.outputSchema]) ? this.convertToJsonSchema(config.outputSchema) : void 0
|
|
1007
|
+
},
|
|
1008
|
+
{
|
|
1009
|
+
...this.resolveRequestOptions(requestOptions)
|
|
1010
|
+
}
|
|
1011
|
+
)
|
|
1012
|
+
);
|
|
1013
|
+
}
|
|
1014
|
+
async findOnePrivate(prompt, config, requestOptions = {}) {
|
|
1015
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
|
1016
|
+
const apiResponse = await withRequestCompletionPolling(
|
|
1017
|
+
this.client,
|
|
1018
|
+
() => this.client.windows.findOne(
|
|
1019
|
+
this.getWindowId(),
|
|
1020
|
+
{
|
|
1021
|
+
prompt,
|
|
1022
|
+
sessionId: this.sessionId,
|
|
1023
|
+
jobId: this.jobId,
|
|
1024
|
+
...config || {}
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
...this.resolveRequestOptions(requestOptions)
|
|
1028
|
+
}
|
|
1029
|
+
)
|
|
1030
|
+
);
|
|
1031
|
+
if (apiResponse.errors.length > 0) {
|
|
1032
|
+
throw new AirtopError(apiResponse.errors);
|
|
1033
|
+
}
|
|
1034
|
+
try {
|
|
1035
|
+
if (!apiResponse.data.nodeHandle) {
|
|
1036
|
+
return null;
|
|
609
1037
|
}
|
|
1038
|
+
return new AirtopNode(this, apiResponse.data.nodeHandle);
|
|
1039
|
+
} catch (error) {
|
|
1040
|
+
this.log.withMetadata({ nodeDataStr: apiResponse.data.nodeHandle }).withError(error).error("Error parsing node data");
|
|
1041
|
+
throw error;
|
|
1042
|
+
}
|
|
1043
|
+
}
|
|
1044
|
+
async findOne(prompt, config, requestOptions = {}) {
|
|
1045
|
+
const configOverride = { ...config, optional: false };
|
|
1046
|
+
return await this.findOnePrivate(prompt, configOverride, requestOptions);
|
|
1047
|
+
}
|
|
1048
|
+
async findOneOptional(prompt, config, requestOptions = {}) {
|
|
1049
|
+
const configOverride = { ...config, optional: true };
|
|
1050
|
+
return await this.findOnePrivate(prompt, configOverride, requestOptions);
|
|
1051
|
+
}
|
|
1052
|
+
async findManyPrivate(prompt, config, requestOptions = {}) {
|
|
1053
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
|
1054
|
+
const apiResponse = await withRequestCompletionPolling(
|
|
1055
|
+
this.client,
|
|
1056
|
+
() => this.client.windows.findMany(
|
|
1057
|
+
this.getWindowId(),
|
|
1058
|
+
{
|
|
1059
|
+
prompt,
|
|
1060
|
+
sessionId: this.sessionId,
|
|
1061
|
+
jobId: this.jobId,
|
|
1062
|
+
...config || {}
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
...this.resolveRequestOptions(requestOptions)
|
|
1066
|
+
}
|
|
1067
|
+
)
|
|
1068
|
+
);
|
|
1069
|
+
if (apiResponse.errors.length > 0) {
|
|
1070
|
+
throw new AirtopError(apiResponse.errors);
|
|
1071
|
+
}
|
|
1072
|
+
const nodeHandleData = apiResponse.data.nodeHandles;
|
|
1073
|
+
return nodeHandleData.map((nodeHandle) => new AirtopNode(this, nodeHandle));
|
|
1074
|
+
}
|
|
1075
|
+
async findMany(prompt, config, requestOptions = {}) {
|
|
1076
|
+
const configOverride = { ...config, optional: false };
|
|
1077
|
+
return await this.findManyPrivate(prompt, configOverride, requestOptions);
|
|
1078
|
+
}
|
|
1079
|
+
async findManyOptional(prompt, config, requestOptions = {}) {
|
|
1080
|
+
const configOverride = { ...config, optional: true };
|
|
1081
|
+
return await this.findManyPrivate(prompt, configOverride, requestOptions);
|
|
1082
|
+
}
|
|
1083
|
+
async waitForPage(config, requestOptions = {}) {
|
|
1084
|
+
return await withRequestCompletionPolling(
|
|
1085
|
+
this.client,
|
|
1086
|
+
() => this.client.windows.waitForPage(
|
|
1087
|
+
this.getWindowId(),
|
|
1088
|
+
{
|
|
1089
|
+
sessionId: this.sessionId,
|
|
1090
|
+
jobId: this.jobId,
|
|
1091
|
+
...config || {}
|
|
1092
|
+
},
|
|
1093
|
+
{
|
|
1094
|
+
...this.resolveRequestOptions(requestOptions)
|
|
1095
|
+
}
|
|
1096
|
+
)
|
|
1097
|
+
);
|
|
1098
|
+
}
|
|
1099
|
+
async navigate(direction, config, requestOptions = {}) {
|
|
1100
|
+
return await withRequestCompletionPolling(
|
|
1101
|
+
this.client,
|
|
1102
|
+
() => this.client.windows.navigate(
|
|
1103
|
+
this.getWindowId(),
|
|
1104
|
+
{
|
|
1105
|
+
direction,
|
|
1106
|
+
sessionId: this.sessionId,
|
|
1107
|
+
jobId: this.jobId,
|
|
1108
|
+
...config || {}
|
|
1109
|
+
},
|
|
1110
|
+
{
|
|
1111
|
+
...this.resolveRequestOptions(requestOptions)
|
|
1112
|
+
}
|
|
1113
|
+
)
|
|
1114
|
+
);
|
|
1115
|
+
}
|
|
1116
|
+
async fillForm(formData, config, requestOptions = {}) {
|
|
1117
|
+
return await withRequestCompletionPolling(
|
|
1118
|
+
this.client,
|
|
1119
|
+
() => this.client.windows.executeAutomation(
|
|
1120
|
+
this.getWindowId(),
|
|
1121
|
+
{
|
|
1122
|
+
sessionId: this.sessionId,
|
|
1123
|
+
...config || {},
|
|
1124
|
+
automationId: _optionalChain([config, 'optionalAccess', _17 => _17.automationId]) || "auto",
|
|
1125
|
+
parameters: {
|
|
1126
|
+
customData: typeof formData === "string" ? formData : JSON.stringify(formData)
|
|
1127
|
+
// Will be interpreted by the LLM
|
|
1128
|
+
}
|
|
1129
|
+
},
|
|
1130
|
+
{
|
|
1131
|
+
...this.resolveRequestOptions(requestOptions)
|
|
1132
|
+
}
|
|
1133
|
+
)
|
|
610
1134
|
);
|
|
611
1135
|
}
|
|
612
1136
|
};
|
|
@@ -665,7 +1189,7 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
|
665
1189
|
*/
|
|
666
1190
|
|
|
667
1191
|
/**
|
|
668
|
-
* Creates a new
|
|
1192
|
+
* Creates a new AirtopSessionClient instance.
|
|
669
1193
|
* @param config - Common configuration options for the session
|
|
670
1194
|
* @param sessionId - Browser session id
|
|
671
1195
|
*/
|
|
@@ -682,6 +1206,9 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
|
682
1206
|
getSessionId() {
|
|
683
1207
|
return this.sessionId;
|
|
684
1208
|
}
|
|
1209
|
+
async listWindows(requestOptions = {}) {
|
|
1210
|
+
return this.client.sessions.listWindows(this.sessionId, this.resolveRequestOptions(requestOptions));
|
|
1211
|
+
}
|
|
685
1212
|
/**
|
|
686
1213
|
* Gets the state of the session using the attached session id.
|
|
687
1214
|
* @param requestOptions - Request options
|
|
@@ -751,15 +1278,29 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
|
751
1278
|
* @param requestOptions - Request options
|
|
752
1279
|
* @returns A new AirtopWindow<AirtopWindowCreateResponse> instance
|
|
753
1280
|
*/
|
|
754
|
-
async createWindow(url, requestOptions = {}) {
|
|
1281
|
+
async createWindow(url, createOptions = {}, requestOptions = {}) {
|
|
755
1282
|
this.log.info("Creating window");
|
|
756
1283
|
const results = await this.client.windows.create(
|
|
757
1284
|
this.sessionId,
|
|
758
1285
|
{
|
|
759
|
-
url
|
|
1286
|
+
url,
|
|
1287
|
+
...createOptions
|
|
760
1288
|
},
|
|
761
1289
|
this.resolveRequestOptions(requestOptions)
|
|
762
1290
|
);
|
|
1291
|
+
this.client.windows.get(
|
|
1292
|
+
results.data.windowId,
|
|
1293
|
+
{
|
|
1294
|
+
sessionId: this.sessionId
|
|
1295
|
+
},
|
|
1296
|
+
this.resolveRequestOptions()
|
|
1297
|
+
).then((windowResults) => {
|
|
1298
|
+
this._sendAgentPayload("LiveViewUrl", {
|
|
1299
|
+
liveViewUrl: windowResults.data.liveViewUrl,
|
|
1300
|
+
windowId: results.data.windowId,
|
|
1301
|
+
sessionId: this.sessionId
|
|
1302
|
+
});
|
|
1303
|
+
});
|
|
763
1304
|
return new AirtopWindow(this.getCommonConfig(), this.sessionId, results);
|
|
764
1305
|
}
|
|
765
1306
|
/**
|
|
@@ -775,10 +1316,11 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
|
775
1316
|
* @param fileName - The name of the file to create
|
|
776
1317
|
* @param config - Additional configuration options for creating the file
|
|
777
1318
|
* @param requestOptions - Request options
|
|
1319
|
+
* @returns AirtopFile instance
|
|
778
1320
|
*/
|
|
779
|
-
createFile(fileName, config = {}, requestOptions = {}) {
|
|
1321
|
+
async createFile(fileName, config = {}, requestOptions = {}) {
|
|
780
1322
|
this.log.info("Creating file");
|
|
781
|
-
|
|
1323
|
+
const results = await this.client.files.createFile(
|
|
782
1324
|
{
|
|
783
1325
|
...config,
|
|
784
1326
|
fileName,
|
|
@@ -786,6 +1328,137 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
|
786
1328
|
},
|
|
787
1329
|
this.resolveRequestOptions(requestOptions)
|
|
788
1330
|
);
|
|
1331
|
+
return new AirtopFile(this.getCommonConfig(), results);
|
|
1332
|
+
}
|
|
1333
|
+
async llm(prompt, config, requestOptions = {}) {
|
|
1334
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
|
1335
|
+
const currentWindows = await this.listWindows();
|
|
1336
|
+
if (currentWindows.data.windows.length === 0) {
|
|
1337
|
+
throw new AirtopError([
|
|
1338
|
+
{
|
|
1339
|
+
message: "No windows found in the session. Please create a window before calling the llm() method."
|
|
1340
|
+
}
|
|
1341
|
+
]);
|
|
1342
|
+
}
|
|
1343
|
+
const firstWindow = currentWindows.data.windows[0];
|
|
1344
|
+
return withRequestCompletionPolling(
|
|
1345
|
+
this.client,
|
|
1346
|
+
() => this.client.windows.llm(
|
|
1347
|
+
firstWindow.windowId,
|
|
1348
|
+
{
|
|
1349
|
+
prompt,
|
|
1350
|
+
sessionId: this.sessionId,
|
|
1351
|
+
jobId: this.jobId,
|
|
1352
|
+
...config || {},
|
|
1353
|
+
includeWebContext: false,
|
|
1354
|
+
// Do not include web context for session.llm() calls
|
|
1355
|
+
outputSchema: _optionalChain([config, 'optionalAccess', _18 => _18.outputSchema]) ? this.convertToJsonSchema(config.outputSchema) : void 0
|
|
1356
|
+
},
|
|
1357
|
+
{
|
|
1358
|
+
...this.resolveRequestOptions(requestOptions)
|
|
1359
|
+
}
|
|
1360
|
+
)
|
|
1361
|
+
);
|
|
1362
|
+
}
|
|
1363
|
+
/**
|
|
1364
|
+
* Implementation for the overloaded service method.
|
|
1365
|
+
*/
|
|
1366
|
+
async service(promptOrArgs, serviceOrRequestOptions, requestOptions = {}) {
|
|
1367
|
+
if (typeof promptOrArgs === "string") {
|
|
1368
|
+
const prompt = promptOrArgs;
|
|
1369
|
+
const service = typeof serviceOrRequestOptions === "string" ? serviceOrRequestOptions : void 0;
|
|
1370
|
+
const options2 = typeof serviceOrRequestOptions === "object" ? serviceOrRequestOptions : requestOptions;
|
|
1371
|
+
this.log.withMetadata({ prompt }).info("Service");
|
|
1372
|
+
const parameters2 = { prompt, services: service };
|
|
1373
|
+
const body2 = { parameters: parameters2 };
|
|
1374
|
+
return withRequestCompletionPolling(
|
|
1375
|
+
this.client,
|
|
1376
|
+
() => this.client.sessions.service(this.sessionId, body2),
|
|
1377
|
+
options2
|
|
1378
|
+
);
|
|
1379
|
+
}
|
|
1380
|
+
const parameters = promptOrArgs;
|
|
1381
|
+
const options = serviceOrRequestOptions || {};
|
|
1382
|
+
this.log.withMetadata({ parameters }).info("Service");
|
|
1383
|
+
const body = {
|
|
1384
|
+
parameters: {
|
|
1385
|
+
prompt: parameters.prompt,
|
|
1386
|
+
services: parameters.services,
|
|
1387
|
+
outputSchema: parameters.outputSchema ? this.convertToJsonSchema(parameters.outputSchema) : void 0
|
|
1388
|
+
}
|
|
1389
|
+
};
|
|
1390
|
+
return withRequestCompletionPolling(
|
|
1391
|
+
this.client,
|
|
1392
|
+
() => this.client.sessions.service(this.sessionId, body),
|
|
1393
|
+
options
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
async getConnectedServices(configOrRequestOptions) {
|
|
1397
|
+
const isConfigFormat = configOrRequestOptions && ("options" in configOrRequestOptions || "requestOptions" in configOrRequestOptions);
|
|
1398
|
+
const options = isConfigFormat ? configOrRequestOptions.options : void 0;
|
|
1399
|
+
const requestOptions = isConfigFormat ? configOrRequestOptions.requestOptions || {} : configOrRequestOptions || {};
|
|
1400
|
+
return withRequestCompletionPolling(
|
|
1401
|
+
this.client,
|
|
1402
|
+
() => this.client.sessions.getConnectedServices(this.sessionId, options),
|
|
1403
|
+
requestOptions
|
|
1404
|
+
);
|
|
1405
|
+
}
|
|
1406
|
+
/**
|
|
1407
|
+
* Waits for a file to be downloaded in a session and reach 'available' status.
|
|
1408
|
+
* Defaults to looking back 5 seconds in the event stream for the file to be available.
|
|
1409
|
+
* Use `lookbackSeconds` to control this behavior.
|
|
1410
|
+
*
|
|
1411
|
+
* @param configuration - The optional configuration parameters for the function
|
|
1412
|
+
* @param configuration.lookbackSeconds - The number of seconds to look back for prior events. Default `5`. 0 means no lookback.
|
|
1413
|
+
* @param configuration.fileType - The file type to wait for, such as "browser_download". If provided, only files of this type will be considered.
|
|
1414
|
+
* @param requestOptions - Optional request configuration including timeout
|
|
1415
|
+
* @returns Object containing file's id and downloadUrl, or null if timed out
|
|
1416
|
+
*/
|
|
1417
|
+
async waitForDownload(configuration, requestOptions = {}) {
|
|
1418
|
+
const { lookbackSeconds = 5, fileType } = configuration || {};
|
|
1419
|
+
this.log.info(`waiting for file to be available on session: ${this.sessionId}`);
|
|
1420
|
+
const startTime = /* @__PURE__ */ new Date();
|
|
1421
|
+
const timeoutSeconds = _optionalChain([requestOptions, 'optionalAccess', _19 => _19.timeoutInSeconds]) || 120;
|
|
1422
|
+
const timeoutPromise = new Promise((resolve) => {
|
|
1423
|
+
setTimeout(() => {
|
|
1424
|
+
this.log.info(`waiting for file timed out after ${timeoutSeconds} seconds`);
|
|
1425
|
+
resolve(null);
|
|
1426
|
+
}, timeoutSeconds * 1e3);
|
|
1427
|
+
});
|
|
1428
|
+
const processEventsPromise = (async () => {
|
|
1429
|
+
const sessionEvents = await this.client.sessions.getEvents(
|
|
1430
|
+
this.sessionId,
|
|
1431
|
+
{ all: lookbackSeconds >= 0, reverse: true },
|
|
1432
|
+
{ timeoutInSeconds: timeoutSeconds, ...requestOptions || {} }
|
|
1433
|
+
);
|
|
1434
|
+
for await (const event of sessionEvents) {
|
|
1435
|
+
const e = event;
|
|
1436
|
+
if (e.event === "file_status") {
|
|
1437
|
+
if (e.status === "available") {
|
|
1438
|
+
const eventTime = Date.parse(e.eventTime);
|
|
1439
|
+
this.log.info(`file_status message received:
|
|
1440
|
+
${JSON.stringify(event, null, 2)}`);
|
|
1441
|
+
if (fileType && e.type !== fileType) {
|
|
1442
|
+
this.log.info(`skipping file of type ${e.type} (looking for ${fileType})`);
|
|
1443
|
+
continue;
|
|
1444
|
+
}
|
|
1445
|
+
const thresholdTime = startTime.getTime() - lookbackSeconds * 1e3;
|
|
1446
|
+
if (eventTime < thresholdTime) {
|
|
1447
|
+
this.log.info(`stopping event processing - encountered event older than lookbackSeconds threshold`);
|
|
1448
|
+
break;
|
|
1449
|
+
}
|
|
1450
|
+
return {
|
|
1451
|
+
id: e.fileId,
|
|
1452
|
+
downloadUrl: e.downloadUrl,
|
|
1453
|
+
fileName: e.name,
|
|
1454
|
+
fileType: e.type
|
|
1455
|
+
};
|
|
1456
|
+
}
|
|
1457
|
+
}
|
|
1458
|
+
}
|
|
1459
|
+
return null;
|
|
1460
|
+
})();
|
|
1461
|
+
return Promise.race([timeoutPromise, processEventsPromise]);
|
|
789
1462
|
}
|
|
790
1463
|
};
|
|
791
1464
|
|
|
@@ -845,19 +1518,20 @@ var AirtopClient = class extends AirtopBase {
|
|
|
845
1518
|
*/
|
|
846
1519
|
constructor(config) {
|
|
847
1520
|
super({
|
|
848
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
|
1521
|
+
logLevel: _optionalChain([config, 'optionalAccess', _20 => _20.logLevel]),
|
|
849
1522
|
client: new (0, _core.Airtop)({
|
|
850
1523
|
maxRetries: 0,
|
|
851
|
-
timeout:
|
|
1524
|
+
timeout: _secondsToMilliseconds.secondsToMilliseconds.call(void 0, _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE))),
|
|
852
1525
|
apiKey: config.apiKey,
|
|
853
|
-
baseURL: _optionalChain([config, 'optionalAccess',
|
|
854
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
|
1526
|
+
baseURL: _optionalChain([config, 'optionalAccess', _21 => _21.airtopUrl]),
|
|
1527
|
+
logLevel: _optionalChain([config, 'optionalAccess', _22 => _22.logLevel]) || "off",
|
|
855
1528
|
defaultHeaders: {
|
|
856
1529
|
"x-airtop-sdk-source": "typescript",
|
|
857
|
-
"x-airtop-sdk-version": version
|
|
1530
|
+
"x-airtop-sdk-version": version,
|
|
1531
|
+
"x-airtop-sdk-environment": _nullishCoalesce(_optionalChain([config, 'optionalAccess', _23 => _23.environment]), () => ( "default"))
|
|
858
1532
|
}
|
|
859
1533
|
}),
|
|
860
|
-
log: _optionalChain([config, 'optionalAccess',
|
|
1534
|
+
log: _optionalChain([config, 'optionalAccess', _24 => _24.logger]) || new (0, _loglayer.LogLayer)({
|
|
861
1535
|
errorSerializer: _serializeerror.serializeError,
|
|
862
1536
|
transport: new (0, _loglayer.ConsoleTransport)({
|
|
863
1537
|
logger: console,
|
|
@@ -868,7 +1542,10 @@ var AirtopClient = class extends AirtopBase {
|
|
|
868
1542
|
contextFieldName: "context",
|
|
869
1543
|
metadataFieldName: "metadata"
|
|
870
1544
|
}),
|
|
871
|
-
outputSchemaAdapter: config.outputSchemaAdapter
|
|
1545
|
+
outputSchemaAdapter: config.outputSchemaAdapter,
|
|
1546
|
+
jobId: config.jobId,
|
|
1547
|
+
agentEventPublisher: config.agentEventPublisher,
|
|
1548
|
+
defaultTimeoutInSeconds: _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE))
|
|
872
1549
|
});
|
|
873
1550
|
this.log.withPrefix("[Airtop SDK]");
|
|
874
1551
|
this.client.logLevel = config.logLevel;
|
|
@@ -894,8 +1571,8 @@ var AirtopClient = class extends AirtopBase {
|
|
|
894
1571
|
* @returns A new AirtopSession instance
|
|
895
1572
|
*/
|
|
896
1573
|
async createSession(config, options = {}) {
|
|
897
|
-
const skipWaitSessionReady = _nullishCoalesce(config.skipWaitSessionReady, () => ( false));
|
|
898
|
-
|
|
1574
|
+
const skipWaitSessionReady = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _25 => _25.skipWaitSessionReady]), () => ( false));
|
|
1575
|
+
_optionalChainDelete([config, 'optionalAccess', _26 => delete _26.skipWaitSessionReady]);
|
|
899
1576
|
const sessionResponse = await this.client.sessions.create(
|
|
900
1577
|
{
|
|
901
1578
|
configuration: config
|
|
@@ -983,6 +1660,13 @@ var AirtopClient = class extends AirtopBase {
|
|
|
983
1660
|
withSessionId(sessionId) {
|
|
984
1661
|
return new AirtopSessionClient(this.getCommonConfig(), sessionId);
|
|
985
1662
|
}
|
|
1663
|
+
/**
|
|
1664
|
+
* Returns a file client instance for making file-based requests for a given file id.
|
|
1665
|
+
* @param fileId - The file ID to attach to the AirtopFileClient instance
|
|
1666
|
+
*/
|
|
1667
|
+
withFileId(fileId) {
|
|
1668
|
+
return new AirtopFileClient(this.getCommonConfig(), fileId);
|
|
1669
|
+
}
|
|
986
1670
|
/**
|
|
987
1671
|
* Retrieves the status of a request.
|
|
988
1672
|
* @param requestId - ID of the request to check
|
|
@@ -996,28 +1680,24 @@ var AirtopClient = class extends AirtopBase {
|
|
|
996
1680
|
return this.client.requests.getRequestStatus(requestId, this.resolveRequestOptions(requestOptions));
|
|
997
1681
|
}
|
|
998
1682
|
/**
|
|
999
|
-
*
|
|
1000
|
-
* @param
|
|
1001
|
-
* @param requestOptions
|
|
1002
|
-
*/
|
|
1003
|
-
async getFile(fileId, requestOptions = {}) {
|
|
1004
|
-
return this.client.files.get(fileId, this.resolveRequestOptions(requestOptions));
|
|
1005
|
-
}
|
|
1006
|
-
/**
|
|
1007
|
-
* Removes a file by ID.
|
|
1008
|
-
* @param fileId - ID of the file to remove
|
|
1683
|
+
* List files
|
|
1684
|
+
* @param query - File list parameters
|
|
1009
1685
|
* @param requestOptions - Request options
|
|
1686
|
+
* @returns Object containing pagination info and array of AirtopFile instances
|
|
1010
1687
|
*/
|
|
1011
|
-
async
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1688
|
+
async listFiles(query, requestOptions = {}) {
|
|
1689
|
+
const files = await this.client.files.list(query, this.resolveRequestOptions(requestOptions));
|
|
1690
|
+
return {
|
|
1691
|
+
pagination: files.data.pagination,
|
|
1692
|
+
files: files.data.files.map(
|
|
1693
|
+
(file) => new AirtopFile(this.getCommonConfig(), {
|
|
1694
|
+
data: file
|
|
1695
|
+
})
|
|
1696
|
+
),
|
|
1697
|
+
errors: files.errors,
|
|
1698
|
+
meta: files.meta,
|
|
1699
|
+
warnings: files.warnings
|
|
1700
|
+
};
|
|
1021
1701
|
}
|
|
1022
1702
|
/**
|
|
1023
1703
|
* List all automations
|
|
@@ -1044,43 +1724,6 @@ var AirtopClient = class extends AirtopBase {
|
|
|
1044
1724
|
}
|
|
1045
1725
|
};
|
|
1046
1726
|
|
|
1047
|
-
// src/plugin/AirtopPlugin.types.ts
|
|
1048
|
-
var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
|
|
1049
|
-
AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
|
|
1050
|
-
AirtopPluginAugmentationType2["AirtopWindowClient"] = "AirtopWindowClient";
|
|
1051
|
-
AirtopPluginAugmentationType2["AirtopWindow"] = "AirtopWindow";
|
|
1052
|
-
AirtopPluginAugmentationType2["AirtopSessionClient"] = "AirtopSessionClient";
|
|
1053
|
-
AirtopPluginAugmentationType2["AirtopSession"] = "AirtopSession";
|
|
1054
|
-
AirtopPluginAugmentationType2["AirtopWindowScreenshot"] = "AirtopWindowScreenshot";
|
|
1055
|
-
return AirtopPluginAugmentationType2;
|
|
1056
|
-
})(AirtopPluginAugmentationType || {});
|
|
1057
|
-
|
|
1058
|
-
// src/plugin/AirtopPlugin.ts
|
|
1059
|
-
function registerAirtopPlugin(plugin) {
|
|
1060
|
-
for (const pluginToAdd of plugin.pluginsToAdd) {
|
|
1061
|
-
switch (pluginToAdd.augmentationType) {
|
|
1062
|
-
case "AirtopClient" /* AirtopClient */:
|
|
1063
|
-
pluginToAdd.augment(AirtopClient.prototype);
|
|
1064
|
-
break;
|
|
1065
|
-
case "AirtopSessionClient" /* AirtopSessionClient */:
|
|
1066
|
-
pluginToAdd.augment(AirtopSessionClient.prototype);
|
|
1067
|
-
break;
|
|
1068
|
-
case "AirtopSession" /* AirtopSession */:
|
|
1069
|
-
pluginToAdd.augment(AirtopSession.prototype);
|
|
1070
|
-
break;
|
|
1071
|
-
case "AirtopWindowClient" /* AirtopWindowClient */:
|
|
1072
|
-
pluginToAdd.augment(AirtopWindowClient.prototype);
|
|
1073
|
-
break;
|
|
1074
|
-
case "AirtopWindow" /* AirtopWindow */:
|
|
1075
|
-
pluginToAdd.augment(AirtopWindow.prototype);
|
|
1076
|
-
break;
|
|
1077
|
-
case "AirtopWindowScreenshot" /* AirtopWindowScreenshot */:
|
|
1078
|
-
pluginToAdd.augment(AirtopWindowScreenshot.prototype);
|
|
1079
|
-
break;
|
|
1080
|
-
}
|
|
1081
|
-
}
|
|
1082
|
-
}
|
|
1083
|
-
|
|
1084
1727
|
// src/AirtopMocks.ts
|
|
1085
1728
|
|
|
1086
1729
|
|
|
@@ -1172,6 +1815,266 @@ var AirtopMocks = class {
|
|
|
1172
1815
|
}
|
|
1173
1816
|
};
|
|
1174
1817
|
|
|
1818
|
+
// src/agent/AirtopAgentClient.ts
|
|
1819
|
+
var _process = require('process');
|
|
1820
|
+
|
|
1821
|
+
|
|
1822
|
+
|
|
1823
|
+
|
|
1824
|
+
var AirtopAgentClient = class extends AirtopBase {
|
|
1825
|
+
/**
|
|
1826
|
+
* Creates a new instance of the Airtop SDK.
|
|
1827
|
+
* @param config - Configuration options for the Airtop SDK
|
|
1828
|
+
*/
|
|
1829
|
+
constructor(config) {
|
|
1830
|
+
super({
|
|
1831
|
+
logLevel: _optionalChain([config, 'optionalAccess', _27 => _27.logLevel]),
|
|
1832
|
+
client: new (0, _core.Airtop)({
|
|
1833
|
+
maxRetries: 0,
|
|
1834
|
+
timeout: _datefns.minutesToMilliseconds.call(void 0, 1),
|
|
1835
|
+
apiKey: config.apiKey,
|
|
1836
|
+
baseURL: _optionalChain([config, 'optionalAccess', _28 => _28.airtopUrl]),
|
|
1837
|
+
logLevel: _optionalChain([config, 'optionalAccess', _29 => _29.logLevel]) || "off",
|
|
1838
|
+
defaultHeaders: {
|
|
1839
|
+
"x-airtop-sdk-source": "typescript",
|
|
1840
|
+
"x-airtop-sdk-version": _process.version
|
|
1841
|
+
}
|
|
1842
|
+
}),
|
|
1843
|
+
log: _optionalChain([config, 'optionalAccess', _30 => _30.logger]) || new (0, _loglayer.LogLayer)({
|
|
1844
|
+
errorSerializer: _serializeerror.serializeError,
|
|
1845
|
+
transport: new (0, _loglayer.ConsoleTransport)({
|
|
1846
|
+
logger: console,
|
|
1847
|
+
messageField: "message",
|
|
1848
|
+
enabled: config.logLevel !== "off",
|
|
1849
|
+
level: config.logLevel === "off" ? "error" : config.logLevel || "error"
|
|
1850
|
+
}),
|
|
1851
|
+
contextFieldName: "context",
|
|
1852
|
+
metadataFieldName: "metadata"
|
|
1853
|
+
}),
|
|
1854
|
+
outputSchemaAdapter: config.outputSchemaAdapter,
|
|
1855
|
+
jobId: config.jobId
|
|
1856
|
+
});
|
|
1857
|
+
this.log.withPrefix("[Airtop SDK]");
|
|
1858
|
+
this.client.logLevel = config.logLevel;
|
|
1859
|
+
this.client.logger = {
|
|
1860
|
+
debug: (message, ...rest) => {
|
|
1861
|
+
processLogMessage(this.log, "debug", message, rest);
|
|
1862
|
+
},
|
|
1863
|
+
error: (message, ...rest) => {
|
|
1864
|
+
processLogMessage(this.log, "error", message, rest);
|
|
1865
|
+
},
|
|
1866
|
+
info: (message, ...rest) => {
|
|
1867
|
+
processLogMessage(this.log, "info", message, rest);
|
|
1868
|
+
},
|
|
1869
|
+
warn: (message, ...rest) => {
|
|
1870
|
+
processLogMessage(this.log, "warn", message, rest);
|
|
1871
|
+
}
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
/**
|
|
1875
|
+
* Creates a new agent. A new draft version is created by default.
|
|
1876
|
+
* @param params - Parameters for creating the agent.
|
|
1877
|
+
* @param requestOptions - Request options.
|
|
1878
|
+
* @returns The created agent data.
|
|
1879
|
+
*/
|
|
1880
|
+
async createAgent(params, requestOptions = {}) {
|
|
1881
|
+
this.log.info("Creating agent");
|
|
1882
|
+
return this.client.agents.createAgent(params, this.resolveRequestOptions(requestOptions));
|
|
1883
|
+
}
|
|
1884
|
+
/**
|
|
1885
|
+
* Retrieves a specific agent by its ID.
|
|
1886
|
+
* @param agentId - The ID of the agent to retrieve.
|
|
1887
|
+
* @param requestOptions - Request options.
|
|
1888
|
+
* @returns The agent data.
|
|
1889
|
+
*/
|
|
1890
|
+
async getAgent(agentId, params = {}, requestOptions = {}) {
|
|
1891
|
+
this.log.withMetadata({ agentId }).info("Retrieving agent");
|
|
1892
|
+
return this.client.agents.getAgent(agentId, params, this.resolveRequestOptions(requestOptions));
|
|
1893
|
+
}
|
|
1894
|
+
/**
|
|
1895
|
+
* Lists agents.
|
|
1896
|
+
* @param params - Optional parameters for listing agents (e.g., pagination).
|
|
1897
|
+
* @param requestOptions - Request options.
|
|
1898
|
+
* @returns A list of agents.
|
|
1899
|
+
*/
|
|
1900
|
+
async listAgents(params, requestOptions = {}) {
|
|
1901
|
+
this.log.info("Listing agents");
|
|
1902
|
+
return this.client.agents.getAgents(params, this.resolveRequestOptions(requestOptions));
|
|
1903
|
+
}
|
|
1904
|
+
/**
|
|
1905
|
+
* Creates a new draft version of an agent. If one already exists, does nothing.
|
|
1906
|
+
* @param agentId - The ID of the agent for which to create a new draft version.
|
|
1907
|
+
* @param requestOptions - Request options.
|
|
1908
|
+
* @returns The draft version data.
|
|
1909
|
+
*/
|
|
1910
|
+
async createNewAgentDraftVersion(agentId, requestOptions = {}) {
|
|
1911
|
+
this.log.withMetadata({ agentId }).info("Creating new draft version of agent");
|
|
1912
|
+
return this.client.agents.createAgentDraft(agentId, {}, this.resolveRequestOptions(requestOptions));
|
|
1913
|
+
}
|
|
1914
|
+
/**
|
|
1915
|
+
* Publishes a new version of an agent from the current draft.
|
|
1916
|
+
* @param agentId - The ID of the agent to publish.
|
|
1917
|
+
* @returns The published version data
|
|
1918
|
+
*/
|
|
1919
|
+
async publishNewAgentVersion(agentId, params = {}, requestOptions = {}) {
|
|
1920
|
+
this.log.withMetadata({ agentId }).info("Publishing new version of agent");
|
|
1921
|
+
return this.client.agents.publishAgent(agentId, params, this.resolveRequestOptions(requestOptions));
|
|
1922
|
+
}
|
|
1923
|
+
/**
|
|
1924
|
+
* Retrieves the data for a specific version of an agent.
|
|
1925
|
+
* @param agentId - The ID of the agent.
|
|
1926
|
+
* @param version - The version number of the agent to retrieve.
|
|
1927
|
+
* @param requestOptions - Request options.
|
|
1928
|
+
* @returns The agent version data.
|
|
1929
|
+
*/
|
|
1930
|
+
async getAgentVersionData(agentId, version3, requestOptions = {}) {
|
|
1931
|
+
this.log.withMetadata({ agentId }).info("Retrieving agent version data");
|
|
1932
|
+
return this.client.agents.getAgentVersion(
|
|
1933
|
+
version3,
|
|
1934
|
+
{
|
|
1935
|
+
id: agentId
|
|
1936
|
+
},
|
|
1937
|
+
this.resolveRequestOptions(requestOptions)
|
|
1938
|
+
);
|
|
1939
|
+
}
|
|
1940
|
+
async updateAgentVersionData(agentId, version3, params, requestOptions = {}) {
|
|
1941
|
+
this.log.withMetadata({ agentId }).info("Updating agent");
|
|
1942
|
+
return this.client.agents.updateAgentVersionData(
|
|
1943
|
+
version3,
|
|
1944
|
+
{
|
|
1945
|
+
id: agentId,
|
|
1946
|
+
...params
|
|
1947
|
+
},
|
|
1948
|
+
this.resolveRequestOptions(requestOptions)
|
|
1949
|
+
);
|
|
1950
|
+
}
|
|
1951
|
+
/**
|
|
1952
|
+
* Retrieves the current version data of an agent. This is the version that is currently active or in draft state.
|
|
1953
|
+
* @param agentId - The ID of the agent.
|
|
1954
|
+
* @param params - Optional parameters for retrieving the version data.
|
|
1955
|
+
* @param requestOptions - Request options.
|
|
1956
|
+
* @returns The current agent version data
|
|
1957
|
+
*/
|
|
1958
|
+
async getCurrentAgentVersionData(agentId, params, requestOptions = {}) {
|
|
1959
|
+
this.log.withMetadata({ agentId }).info("Retrieving current agent version data");
|
|
1960
|
+
return this.client.agents.getCurrentAgentVersion(agentId, params, this.resolveRequestOptions(requestOptions));
|
|
1961
|
+
}
|
|
1962
|
+
/**
|
|
1963
|
+
* Updates an existing agent.
|
|
1964
|
+
* @param agentId - The ID of the agent to update.
|
|
1965
|
+
* @param params - The new data for the agent.
|
|
1966
|
+
* @param requestOptions - Request options.
|
|
1967
|
+
* @returns The updated agent data.
|
|
1968
|
+
*/
|
|
1969
|
+
async updateAgent(agentId, params, requestOptions = {}) {
|
|
1970
|
+
this.log.withMetadata({ agentId }).info("Updating agent");
|
|
1971
|
+
return this.client.agents.updateAgent(agentId, params, this.resolveRequestOptions(requestOptions));
|
|
1972
|
+
}
|
|
1973
|
+
/**
|
|
1974
|
+
* Deletes one or more agents.
|
|
1975
|
+
* @param params - Parameters for deleting agents.
|
|
1976
|
+
* @param requestOptions - Request options.
|
|
1977
|
+
* @returns A response confirming the deletion.
|
|
1978
|
+
*/
|
|
1979
|
+
async deleteAgents(params, requestOptions = {}) {
|
|
1980
|
+
this.log.info("Deleting agent(s)");
|
|
1981
|
+
return this.client.agents.deleteAgents(params, this.resolveRequestOptions(requestOptions));
|
|
1982
|
+
}
|
|
1983
|
+
/**
|
|
1984
|
+
* Creates an invocation for an agent.
|
|
1985
|
+
* @param agentId - The ID of the agent for which to create an invocation.
|
|
1986
|
+
* @param params - Parameters for creating the agent invocation.
|
|
1987
|
+
* @param requestOptions - Request options.
|
|
1988
|
+
* @returns The created agent invocation data.
|
|
1989
|
+
*/
|
|
1990
|
+
async createAgentInvocation(agentId, params, requestOptions = {}) {
|
|
1991
|
+
this.log.withMetadata({ agentId }).info("Creating agent invocation");
|
|
1992
|
+
return this.client.agents.createInvocation(agentId, params, this.resolveRequestOptions(requestOptions));
|
|
1993
|
+
}
|
|
1994
|
+
/**
|
|
1995
|
+
* Lists invocations of an agent.
|
|
1996
|
+
* @param agentIds - The ID of the agent whose invocations to list.
|
|
1997
|
+
* @param params - Optional parameters for listing agent invocations.
|
|
1998
|
+
* @param requestOptions - Request options.
|
|
1999
|
+
* @returns A list of agent invocations.
|
|
2000
|
+
*/
|
|
2001
|
+
async listAgentInvocations(agentIds, params, requestOptions = {}) {
|
|
2002
|
+
this.log.withMetadata({ agentIds }).info("Listing agent invocations");
|
|
2003
|
+
return this.client.agents.getInvocations(agentIds, params, this.resolveRequestOptions(requestOptions));
|
|
2004
|
+
}
|
|
2005
|
+
/**
|
|
2006
|
+
* Cancels a specific invocation of an agent.
|
|
2007
|
+
* @param agentId - The ID of the agent.
|
|
2008
|
+
* @param invocationId - The ID of the invocation to cancel.
|
|
2009
|
+
* @param paramsBody - Optional body parameters for cancelling the invocation.
|
|
2010
|
+
* @param requestOptions - Request options.
|
|
2011
|
+
* @returns A promise that resolves when the operation is complete.
|
|
2012
|
+
*/
|
|
2013
|
+
async cancelAgentInvocation(agentId, invocationId, paramsBody, requestOptions = {}) {
|
|
2014
|
+
this.log.withMetadata({ agentId, invocationId }).info("Cancelling agent invocation");
|
|
2015
|
+
const resolvedOptions = this.resolveRequestOptions(requestOptions);
|
|
2016
|
+
const finalOptions = { ...resolvedOptions };
|
|
2017
|
+
const params = { id: agentId, ...paramsBody };
|
|
2018
|
+
if (paramsBody) {
|
|
2019
|
+
finalOptions.body = paramsBody;
|
|
2020
|
+
}
|
|
2021
|
+
await this.client.agents.cancelInvocation(invocationId, params, finalOptions);
|
|
2022
|
+
}
|
|
2023
|
+
};
|
|
2024
|
+
|
|
2025
|
+
// src/window/AirtopWindowClient.types.ts
|
|
2026
|
+
var WindowNavigateDirection = /* @__PURE__ */ ((WindowNavigateDirection2) => {
|
|
2027
|
+
WindowNavigateDirection2["BACK"] = "backward";
|
|
2028
|
+
WindowNavigateDirection2["FORWARD"] = "forward";
|
|
2029
|
+
return WindowNavigateDirection2;
|
|
2030
|
+
})(WindowNavigateDirection || {});
|
|
2031
|
+
|
|
2032
|
+
// src/plugin/AirtopPlugin.types.ts
|
|
2033
|
+
var AirtopPluginAugmentationType = /* @__PURE__ */ ((AirtopPluginAugmentationType2) => {
|
|
2034
|
+
AirtopPluginAugmentationType2["AirtopClient"] = "AirtopClient";
|
|
2035
|
+
AirtopPluginAugmentationType2["AirtopWindowClient"] = "AirtopWindowClient";
|
|
2036
|
+
AirtopPluginAugmentationType2["AirtopWindow"] = "AirtopWindow";
|
|
2037
|
+
AirtopPluginAugmentationType2["AirtopSessionClient"] = "AirtopSessionClient";
|
|
2038
|
+
AirtopPluginAugmentationType2["AirtopSession"] = "AirtopSession";
|
|
2039
|
+
AirtopPluginAugmentationType2["AirtopWindowScreenshot"] = "AirtopWindowScreenshot";
|
|
2040
|
+
return AirtopPluginAugmentationType2;
|
|
2041
|
+
})(AirtopPluginAugmentationType || {});
|
|
2042
|
+
|
|
2043
|
+
// src/plugin/AirtopPlugin.ts
|
|
2044
|
+
function registerAirtopPlugin(plugin) {
|
|
2045
|
+
for (const pluginToAdd of plugin.pluginsToAdd) {
|
|
2046
|
+
switch (pluginToAdd.augmentationType) {
|
|
2047
|
+
case "AirtopClient" /* AirtopClient */:
|
|
2048
|
+
pluginToAdd.augment(AirtopClient.prototype);
|
|
2049
|
+
break;
|
|
2050
|
+
case "AirtopSessionClient" /* AirtopSessionClient */:
|
|
2051
|
+
pluginToAdd.augment(AirtopSessionClient.prototype);
|
|
2052
|
+
break;
|
|
2053
|
+
case "AirtopSession" /* AirtopSession */:
|
|
2054
|
+
pluginToAdd.augment(AirtopSession.prototype);
|
|
2055
|
+
break;
|
|
2056
|
+
case "AirtopWindowClient" /* AirtopWindowClient */:
|
|
2057
|
+
pluginToAdd.augment(AirtopWindowClient.prototype);
|
|
2058
|
+
break;
|
|
2059
|
+
case "AirtopWindow" /* AirtopWindow */:
|
|
2060
|
+
pluginToAdd.augment(AirtopWindow.prototype);
|
|
2061
|
+
break;
|
|
2062
|
+
case "AirtopWindowScreenshot" /* AirtopWindowScreenshot */:
|
|
2063
|
+
pluginToAdd.augment(AirtopWindowScreenshot.prototype);
|
|
2064
|
+
break;
|
|
2065
|
+
}
|
|
2066
|
+
}
|
|
2067
|
+
}
|
|
2068
|
+
|
|
2069
|
+
|
|
2070
|
+
|
|
2071
|
+
|
|
2072
|
+
|
|
2073
|
+
|
|
2074
|
+
|
|
2075
|
+
|
|
2076
|
+
|
|
2077
|
+
|
|
1175
2078
|
|
|
1176
2079
|
|
|
1177
2080
|
|
|
@@ -1182,5 +2085,5 @@ var AirtopMocks = class {
|
|
|
1182
2085
|
|
|
1183
2086
|
|
|
1184
2087
|
|
|
1185
|
-
exports.AirtopBase = AirtopBase; exports.AirtopClient = AirtopClient; exports.AirtopMocks = AirtopMocks; exports.AirtopPluginAugmentationType = AirtopPluginAugmentationType; exports.AirtopSession = AirtopSession; exports.AirtopSessionClient = AirtopSessionClient; exports.AirtopWindow = AirtopWindow; exports.AirtopWindowClient = AirtopWindowClient; exports.AirtopWindowScreenshot = AirtopWindowScreenshot; exports.registerAirtopPlugin = registerAirtopPlugin;
|
|
2088
|
+
exports.AirtopAgentClient = AirtopAgentClient; exports.AirtopBase = AirtopBase; exports.AirtopClient = AirtopClient; exports.AirtopCore = AirtopCore4; exports.AirtopCoreShared = AirtopCoreShared; exports.AirtopCoreWindows = AirtopCoreWindows; exports.AirtopError = AirtopError; exports.AirtopFile = AirtopFile; exports.AirtopFileClient = AirtopFileClient; exports.AirtopMocks = AirtopMocks; exports.AirtopNode = AirtopNode; exports.AirtopPluginAugmentationType = AirtopPluginAugmentationType; exports.AirtopSession = AirtopSession; exports.AirtopSessionClient = AirtopSessionClient; exports.AirtopWindow = AirtopWindow; exports.AirtopWindowClient = AirtopWindowClient; exports.AirtopWindowScreenshot = AirtopWindowScreenshot; exports.WindowNavigateDirection = WindowNavigateDirection; exports.registerAirtopPlugin = registerAirtopPlugin;
|
|
1186
2089
|
//# sourceMappingURL=index.cjs.map
|