@airtop/sdk 1.0.0-alpha2.6 → 1.0.0-alpha2.8
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 +212 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +96 -3
- package/dist/index.d.ts +96 -3
- package/dist/index.js +215 -16
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
@@ -11,7 +11,7 @@ import * as _airtop_core_resources_shared_js from '@airtop/core/resources/shared
|
|
11
11
|
import { SessionConfigV1, GetFileResponse, FilesResponse, ListAutomationsOutput, AutomationData, ExternalSessionWithConnectionInfo, EnvelopeDefaultMeta, Issue, AIPromptResponse as AIPromptResponse$1, WindowIDDataResponse, OperationOutcomeResponse } from '@airtop/core/resources/shared.js';
|
12
12
|
export { AIResponseEnvelope, AirtopPagination, ExternalSessionAIResponseMetadata, ExternalSessionWithConnectionInfo, Issue, OperationOutcomeResponse, WindowIDDataResponse } from '@airtop/core/resources/shared.js';
|
13
13
|
import * as _airtop_core_resources_sessions_mjs from '@airtop/core/resources/sessions.mjs';
|
14
|
-
import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams } from '@airtop/core/resources/windows.js';
|
14
|
+
import { WindowClickParams, WindowHoverParams, WindowLoadURLParams, WindowMonitorParams, WindowScrapeParams, WindowScreenshotParams, WindowScrollParams, WindowTypeParams, WindowExtractParams, WindowActParams, WindowLlmParams, WindowFindOneParams, WindowFindManyParams } from '@airtop/core/resources/windows.js';
|
15
15
|
|
16
16
|
/**
|
17
17
|
* Shared configuration between Airtop classes.
|
@@ -36,6 +36,10 @@ interface CommonAirtopConfig {
|
|
36
36
|
* Used for customizing output schema handling.
|
37
37
|
*/
|
38
38
|
outputSchemaAdapter?: AirtopJsonSchemaAdapter;
|
39
|
+
/**
|
40
|
+
* The automation job ID to use for the request.
|
41
|
+
*/
|
42
|
+
jobId?: string;
|
39
43
|
}
|
40
44
|
/**
|
41
45
|
* Configuration for defining the JSON schema output.
|
@@ -97,6 +101,11 @@ declare class AirtopBase {
|
|
97
101
|
* @internal
|
98
102
|
**/
|
99
103
|
protected outputJsonAdapter: AirtopJsonSchemaAdapter;
|
104
|
+
/**
|
105
|
+
* The job id for the ongoing automation
|
106
|
+
* @internal
|
107
|
+
*/
|
108
|
+
protected jobId?: string;
|
100
109
|
/**
|
101
110
|
* Creates a new instance of AirtopBase
|
102
111
|
* @param config - Configuration options for the SDK
|
@@ -180,6 +189,10 @@ interface AirtopConstructorConfig {
|
|
180
189
|
* Used to customize how response data is structured.
|
181
190
|
*/
|
182
191
|
outputSchemaAdapter?: AirtopJsonSchemaAdapter;
|
192
|
+
/**
|
193
|
+
* The job ID to use for the ongoing automation.
|
194
|
+
*/
|
195
|
+
jobId?: string;
|
183
196
|
}
|
184
197
|
/**
|
185
198
|
* Configuration options for creating a new session.
|
@@ -348,6 +361,51 @@ interface AirtopWindowGetInfoResponse extends AirtopWindowCreateResponse {
|
|
348
361
|
data: WindowInfoData;
|
349
362
|
}
|
350
363
|
|
364
|
+
declare class AirtopNodeImpl {
|
365
|
+
/**
|
366
|
+
* The window client
|
367
|
+
*/
|
368
|
+
protected windowClient: AirtopWindowClient;
|
369
|
+
/**
|
370
|
+
* The node handle id to use for all requests
|
371
|
+
*/
|
372
|
+
protected nodeHandleId: string;
|
373
|
+
/**
|
374
|
+
* Constructor
|
375
|
+
* @param client - The window client
|
376
|
+
* @param nodeHandleId - The node handle id to use for all requests
|
377
|
+
*/
|
378
|
+
constructor(client: AirtopWindowClient, nodeHandleId: string);
|
379
|
+
/**
|
380
|
+
* Extract content from the node
|
381
|
+
* @param prompt - The prompt to use for the extraction
|
382
|
+
* @param config - The configuration to use for the extraction
|
383
|
+
* @param requestOptions - The request options to use for the extraction
|
384
|
+
*/
|
385
|
+
extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
386
|
+
/**
|
387
|
+
* Act on the node
|
388
|
+
* @param prompt - The prompt to use for the action
|
389
|
+
* @param config - The configuration to use for the action
|
390
|
+
* @param requestOptions - The request options to use for the action
|
391
|
+
*/
|
392
|
+
act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
393
|
+
/**
|
394
|
+
* Execute an LLM call on the node
|
395
|
+
* @param prompt - The prompt to use for the LLM call
|
396
|
+
* @param config - The configuration to use for the LLM call
|
397
|
+
* @param requestOptions - The request options to use for the LLM call
|
398
|
+
*/
|
399
|
+
llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
400
|
+
/**
|
401
|
+
* Find one element in the node
|
402
|
+
* @param prompt - The prompt to use for the find one
|
403
|
+
* @param config - The configuration to use for the find one
|
404
|
+
* @param requestOptions - The request options to use for the find one
|
405
|
+
*/
|
406
|
+
findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
|
407
|
+
}
|
408
|
+
|
351
409
|
/**
|
352
410
|
* Configuration parameters for typing text in a window.
|
353
411
|
* Excludes session ID and text content which are provided separately.
|
@@ -422,6 +480,36 @@ interface WindowPromptResponse extends AIPromptResponse {
|
|
422
480
|
*/
|
423
481
|
interface WindowScrapeResponse extends ScrapeResponse {
|
424
482
|
}
|
483
|
+
/**
|
484
|
+
* Configuration parameters for extracting content from a window.
|
485
|
+
*/
|
486
|
+
interface WindowExtractConfig extends Omit<WindowExtractParams, "sessionId" | "prompt" | "jobId"> {
|
487
|
+
}
|
488
|
+
/**
|
489
|
+
* Configuration parameters for acting on content in a window.
|
490
|
+
*/
|
491
|
+
interface WindowActConfig extends Omit<WindowActParams, "sessionId" | "prompt" | "jobId"> {
|
492
|
+
}
|
493
|
+
/**
|
494
|
+
* Configuration parameters for executing an LLM call in a window.
|
495
|
+
*/
|
496
|
+
interface WindowLlmConfig extends Omit<WindowLlmParams, "sessionId" | "prompt"> {
|
497
|
+
}
|
498
|
+
/**
|
499
|
+
* Configuration parameters for finding one element in a window.
|
500
|
+
*/
|
501
|
+
interface WindowFindOneConfig extends Omit<WindowFindOneParams, "sessionId" | "prompt" | "jobId"> {
|
502
|
+
}
|
503
|
+
/**
|
504
|
+
* Configuration parameters for finding multiple elements in a window.
|
505
|
+
*/
|
506
|
+
interface WindowFindManyConfig extends Omit<WindowFindManyParams, "sessionId" | "prompt" | "jobId"> {
|
507
|
+
}
|
508
|
+
/**
|
509
|
+
* Response for finding one element in a window.
|
510
|
+
*/
|
511
|
+
interface AirtopNode extends AirtopNodeImpl {
|
512
|
+
}
|
425
513
|
|
426
514
|
/**
|
427
515
|
* Response object for a screenshot operation.
|
@@ -467,7 +555,7 @@ declare class AirtopWindowScreenshot {
|
|
467
555
|
};
|
468
556
|
}
|
469
557
|
|
470
|
-
|
558
|
+
/**, waitForRequestCompletion
|
471
559
|
* Client for making window-specific requests to the Airtop API.
|
472
560
|
*/
|
473
561
|
declare class AirtopWindowClient extends AirtopBase {
|
@@ -585,6 +673,11 @@ declare class AirtopWindowClient extends AirtopBase {
|
|
585
673
|
* @returns Promise resolving when the text has been typed
|
586
674
|
*/
|
587
675
|
type(text: string, config?: WindowTypeConfig, requestOptions?: AirtopRequestOptions): Promise<_airtop_core_resources_shared_mjs.AIPromptResponse>;
|
676
|
+
extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
677
|
+
act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
678
|
+
llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
679
|
+
findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
|
680
|
+
findMany(prompt: string, config?: WindowFindManyConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode[]>;
|
588
681
|
}
|
589
682
|
|
590
683
|
/**
|
@@ -1025,4 +1118,4 @@ declare class AirtopMocks {
|
|
1025
1118
|
}): AirtopWindow<AirtopWindowGetInfoResponse>;
|
1026
1119
|
}
|
1027
1120
|
|
1028
|
-
export { type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, AirtopMocks, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionWarning, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWarning, registerAirtopPlugin };
|
1121
|
+
export { type AirtopAutomationData, type AirtopAutomationListResponse, type AirtopAutomationUpdateDescriptionConfig, AirtopBase, AirtopClient, type AirtopClientPlugin, type AirtopConstructorConfig, type AirtopFileListParams, type AirtopFileResponse, type AirtopFilesResponse, AirtopMocks, type AirtopNode, AirtopPluginAugmentationType, type AirtopPluginRegistration, type AirtopPluginType, type AirtopProfile, type AirtopRequestOptions, AirtopSession, AirtopSessionClient, type AirtopSessionClientPlugin, type AirtopSessionPlugin, type AirtopSessionResponse, AirtopWindow, AirtopWindowClient, type AirtopWindowClientPlugin, type AirtopWindowCreateResponse, type AirtopWindowGetInfoResponse, type AirtopWindowPlugin, AirtopWindowScreenshot, type AirtopWindowScreenshotPlugin, type AirtopWindowScreenshotResponse, type CommonAirtopConfig, type CommonResponse, type CommonWindowResponse, type CreateFileConfig, type CreateSessionConfig, type GetFilesConfig, type GetSessionsConfig, type OutputJsonSchemaConfig, type ScreenshotData, type SessionData, type SessionError, type SessionMetadata, type SessionWarning, type WindowActConfig, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, type WindowFindManyConfig, type WindowFindOneConfig, type WindowGetConfig, type WindowHoverConfig, type WindowInfoData, type WindowLlmConfig, type WindowLoadUrlConfig, type WindowMetadata, type WindowMonitorConfig, type WindowPageQueryConfig, type WindowPaginatedExtractionConfig, type WindowPromptResponse, type WindowScrapeConfig, type WindowScrapeResponse, type WindowScreenshotConfig, type WindowScrollConfig, type WindowTypeConfig, type WindowWarning, registerAirtopPlugin };
|
package/dist/index.js
CHANGED
@@ -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.8",
|
13
13
|
type: "module",
|
14
14
|
main: "./dist/index.cjs",
|
15
15
|
module: "./dist/index.js",
|
@@ -47,7 +47,7 @@ var require_package = __commonJS({
|
|
47
47
|
},
|
48
48
|
dependencies: {
|
49
49
|
"@airtop/json-schema-adapter": "workspace:*",
|
50
|
-
"@airtop/core": "0.1.0-alpha.
|
50
|
+
"@airtop/core": "0.1.0-alpha.26",
|
51
51
|
"date-fns": "4.1.0",
|
52
52
|
loglayer: "6.3.3",
|
53
53
|
"serialize-error": "12.0.0",
|
@@ -102,6 +102,11 @@ var AirtopBase = class {
|
|
102
102
|
* @internal
|
103
103
|
**/
|
104
104
|
outputJsonAdapter;
|
105
|
+
/**
|
106
|
+
* The job id for the ongoing automation
|
107
|
+
* @internal
|
108
|
+
*/
|
109
|
+
jobId;
|
105
110
|
/**
|
106
111
|
* Creates a new instance of AirtopBase
|
107
112
|
* @param config - Configuration options for the SDK
|
@@ -110,6 +115,7 @@ var AirtopBase = class {
|
|
110
115
|
this.log = config.log.withPrefix("[Airtop]");
|
111
116
|
this.client = config.client;
|
112
117
|
this.outputJsonAdapter = config.outputSchemaAdapter;
|
118
|
+
this.jobId = config.jobId;
|
113
119
|
}
|
114
120
|
/**
|
115
121
|
* Returns the API key used by the SDK
|
@@ -163,7 +169,8 @@ var AirtopBase = class {
|
|
163
169
|
getCommonConfig() {
|
164
170
|
return {
|
165
171
|
client: this.client,
|
166
|
-
log: this.log
|
172
|
+
log: this.log,
|
173
|
+
jobId: this.jobId
|
167
174
|
};
|
168
175
|
}
|
169
176
|
/**
|
@@ -235,7 +242,100 @@ var processLogMessage = (log, logLevel, ...args) => {
|
|
235
242
|
import { NotFoundError } from "@airtop/core";
|
236
243
|
|
237
244
|
// src/window/AirtopWindowClient.ts
|
245
|
+
import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns";
|
246
|
+
|
247
|
+
// src/async-utils.ts
|
238
248
|
import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
|
249
|
+
var DEFAULT_TIMEOUT_SECONDS = 300;
|
250
|
+
var DEFAULT_POLLING_INTERVAL_SECONDS = 2;
|
251
|
+
async function waitForRequestCompletion(client, requestId, requestOptions) {
|
252
|
+
const startTime = Date.now();
|
253
|
+
const timeoutMs = secondsToMilliseconds2(requestOptions?.timeoutInSeconds || DEFAULT_TIMEOUT_SECONDS);
|
254
|
+
while (Date.now() - startTime < timeoutMs) {
|
255
|
+
const apiResponse = await client.requests.getRequestStatus(requestId, requestOptions);
|
256
|
+
if (apiResponse.status === "completed") {
|
257
|
+
return apiResponse.response;
|
258
|
+
}
|
259
|
+
if (apiResponse.status === "error") {
|
260
|
+
throw new Error(apiResponse.error);
|
261
|
+
}
|
262
|
+
await new Promise((resolve) => setTimeout(resolve, secondsToMilliseconds2(DEFAULT_POLLING_INTERVAL_SECONDS)));
|
263
|
+
}
|
264
|
+
throw new Error("Waiting for request timed out");
|
265
|
+
}
|
266
|
+
async function withRequestCompletionPolling(client, fn, requestOptions) {
|
267
|
+
const response = await fn();
|
268
|
+
return waitForRequestCompletion(client, response.requestId, requestOptions);
|
269
|
+
}
|
270
|
+
|
271
|
+
// src/window/AirtopNode.ts
|
272
|
+
var AirtopNodeImpl = class {
|
273
|
+
/**
|
274
|
+
* The window client
|
275
|
+
*/
|
276
|
+
windowClient;
|
277
|
+
/**
|
278
|
+
* The node handle id to use for all requests
|
279
|
+
*/
|
280
|
+
nodeHandleId;
|
281
|
+
/**
|
282
|
+
* Constructor
|
283
|
+
* @param client - The window client
|
284
|
+
* @param nodeHandleId - The node handle id to use for all requests
|
285
|
+
*/
|
286
|
+
constructor(client, nodeHandleId) {
|
287
|
+
this.windowClient = client;
|
288
|
+
this.nodeHandleId = nodeHandleId;
|
289
|
+
}
|
290
|
+
/**
|
291
|
+
* Extract content from the node
|
292
|
+
* @param prompt - The prompt to use for the extraction
|
293
|
+
* @param config - The configuration to use for the extraction
|
294
|
+
* @param requestOptions - The request options to use for the extraction
|
295
|
+
*/
|
296
|
+
async extract(prompt, config, requestOptions = {}) {
|
297
|
+
const augmentedConfig = {
|
298
|
+
...config,
|
299
|
+
nodeHandleId: this.nodeHandleId
|
300
|
+
};
|
301
|
+
return this.windowClient.extract(prompt, augmentedConfig, requestOptions);
|
302
|
+
}
|
303
|
+
/**
|
304
|
+
* Act on the node
|
305
|
+
* @param prompt - The prompt to use for the action
|
306
|
+
* @param config - The configuration to use for the action
|
307
|
+
* @param requestOptions - The request options to use for the action
|
308
|
+
*/
|
309
|
+
async act(prompt, config, requestOptions = {}) {
|
310
|
+
const augmentedConfig = {
|
311
|
+
...config,
|
312
|
+
nodeHandleId: this.nodeHandleId
|
313
|
+
};
|
314
|
+
return this.windowClient.act(prompt, augmentedConfig, requestOptions);
|
315
|
+
}
|
316
|
+
/**
|
317
|
+
* Execute an LLM call on the node
|
318
|
+
* @param prompt - The prompt to use for the LLM call
|
319
|
+
* @param config - The configuration to use for the LLM call
|
320
|
+
* @param requestOptions - The request options to use for the LLM call
|
321
|
+
*/
|
322
|
+
async llm(prompt, config, requestOptions = {}) {
|
323
|
+
return this.windowClient.llm(prompt, config, requestOptions);
|
324
|
+
}
|
325
|
+
/**
|
326
|
+
* Find one element in the node
|
327
|
+
* @param prompt - The prompt to use for the find one
|
328
|
+
* @param config - The configuration to use for the find one
|
329
|
+
* @param requestOptions - The request options to use for the find one
|
330
|
+
*/
|
331
|
+
async findOne(prompt, config, requestOptions = {}) {
|
332
|
+
const augmentedConfig = {
|
333
|
+
...config,
|
334
|
+
nodeHandleId: this.nodeHandleId
|
335
|
+
};
|
336
|
+
return this.windowClient.findOne(prompt, augmentedConfig, requestOptions);
|
337
|
+
}
|
338
|
+
};
|
239
339
|
|
240
340
|
// src/window/AirtopWindowScreenshot.ts
|
241
341
|
function extractMimeAndBase64(dataUrl) {
|
@@ -385,7 +485,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
385
485
|
sessionId: this.sessionId
|
386
486
|
},
|
387
487
|
{
|
388
|
-
timeout:
|
488
|
+
timeout: secondsToMilliseconds3(600),
|
389
489
|
...this.resolveRequestOptions(requestOptions)
|
390
490
|
}
|
391
491
|
);
|
@@ -417,7 +517,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
417
517
|
...config || {}
|
418
518
|
},
|
419
519
|
{
|
420
|
-
timeout:
|
520
|
+
timeout: secondsToMilliseconds3(600),
|
421
521
|
...this.resolveRequestOptions(requestOptions)
|
422
522
|
}
|
423
523
|
);
|
@@ -441,7 +541,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
441
541
|
...config
|
442
542
|
},
|
443
543
|
{
|
444
|
-
timeout:
|
544
|
+
timeout: secondsToMilliseconds3(600),
|
445
545
|
...this.resolveRequestOptions(requestOptions)
|
446
546
|
}
|
447
547
|
);
|
@@ -463,7 +563,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
463
563
|
...config || {}
|
464
564
|
},
|
465
565
|
{
|
466
|
-
timeout:
|
566
|
+
timeout: secondsToMilliseconds3(600),
|
467
567
|
...this.resolveRequestOptions(requestOptions)
|
468
568
|
}
|
469
569
|
);
|
@@ -491,7 +591,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
491
591
|
...newConfig || {}
|
492
592
|
},
|
493
593
|
{
|
494
|
-
timeout:
|
594
|
+
timeout: secondsToMilliseconds3(600),
|
495
595
|
...this.resolveRequestOptions(requestOptions)
|
496
596
|
}
|
497
597
|
);
|
@@ -519,7 +619,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
519
619
|
...newConfig || {}
|
520
620
|
},
|
521
621
|
{
|
522
|
-
timeout:
|
622
|
+
timeout: secondsToMilliseconds3(600),
|
523
623
|
...this.resolveRequestOptions(requestOptions)
|
524
624
|
}
|
525
625
|
);
|
@@ -539,7 +639,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
539
639
|
...config || {}
|
540
640
|
},
|
541
641
|
{
|
542
|
-
timeout:
|
642
|
+
timeout: secondsToMilliseconds3(600),
|
543
643
|
...this.resolveRequestOptions(requestOptions)
|
544
644
|
}
|
545
645
|
);
|
@@ -559,7 +659,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
559
659
|
...config || {}
|
560
660
|
},
|
561
661
|
{
|
562
|
-
timeout:
|
662
|
+
timeout: secondsToMilliseconds3(600),
|
563
663
|
...this.resolveRequestOptions(requestOptions)
|
564
664
|
}
|
565
665
|
);
|
@@ -580,7 +680,7 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
580
680
|
...config || {}
|
581
681
|
},
|
582
682
|
{
|
583
|
-
timeout:
|
683
|
+
timeout: secondsToMilliseconds3(600),
|
584
684
|
...this.resolveRequestOptions(requestOptions)
|
585
685
|
}
|
586
686
|
);
|
@@ -604,11 +704,109 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
604
704
|
...config || {}
|
605
705
|
},
|
606
706
|
{
|
607
|
-
timeout:
|
707
|
+
timeout: secondsToMilliseconds3(600),
|
608
708
|
...this.resolveRequestOptions(requestOptions)
|
609
709
|
}
|
610
710
|
);
|
611
711
|
}
|
712
|
+
async extract(prompt, config, requestOptions = {}) {
|
713
|
+
this.log.withMetadata({ prompt }).info("Extracting content");
|
714
|
+
return withRequestCompletionPolling(
|
715
|
+
this.client,
|
716
|
+
() => this.client.windows.extract(
|
717
|
+
this.getWindowId(),
|
718
|
+
{
|
719
|
+
prompt,
|
720
|
+
sessionId: this.sessionId,
|
721
|
+
jobId: this.jobId,
|
722
|
+
...config || {}
|
723
|
+
},
|
724
|
+
{
|
725
|
+
timeout: secondsToMilliseconds3(600),
|
726
|
+
...this.resolveRequestOptions(requestOptions)
|
727
|
+
}
|
728
|
+
)
|
729
|
+
);
|
730
|
+
}
|
731
|
+
async act(prompt, config, requestOptions = {}) {
|
732
|
+
this.log.withMetadata({ prompt }).info("Acting on content");
|
733
|
+
return withRequestCompletionPolling(
|
734
|
+
this.client,
|
735
|
+
() => this.client.windows.act(
|
736
|
+
this.getWindowId(),
|
737
|
+
{
|
738
|
+
prompt,
|
739
|
+
sessionId: this.sessionId,
|
740
|
+
jobId: this.jobId,
|
741
|
+
...config || {}
|
742
|
+
},
|
743
|
+
{
|
744
|
+
timeout: secondsToMilliseconds3(600),
|
745
|
+
...this.resolveRequestOptions(requestOptions)
|
746
|
+
}
|
747
|
+
)
|
748
|
+
);
|
749
|
+
}
|
750
|
+
async llm(prompt, config, requestOptions = {}) {
|
751
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
752
|
+
return withRequestCompletionPolling(
|
753
|
+
this.client,
|
754
|
+
() => this.client.windows.llm(
|
755
|
+
this.getWindowId(),
|
756
|
+
{
|
757
|
+
prompt,
|
758
|
+
sessionId: this.sessionId,
|
759
|
+
...config || {}
|
760
|
+
},
|
761
|
+
{
|
762
|
+
timeout: secondsToMilliseconds3(600),
|
763
|
+
...this.resolveRequestOptions(requestOptions)
|
764
|
+
}
|
765
|
+
)
|
766
|
+
);
|
767
|
+
}
|
768
|
+
async findOne(prompt, config, requestOptions = {}) {
|
769
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
770
|
+
const apiResponse = await withRequestCompletionPolling(
|
771
|
+
this.client,
|
772
|
+
() => this.client.windows.findOne(
|
773
|
+
this.getWindowId(),
|
774
|
+
{
|
775
|
+
prompt,
|
776
|
+
sessionId: this.sessionId,
|
777
|
+
jobId: this.jobId,
|
778
|
+
...config || {}
|
779
|
+
},
|
780
|
+
{
|
781
|
+
timeout: secondsToMilliseconds3(600),
|
782
|
+
...this.resolveRequestOptions(requestOptions)
|
783
|
+
}
|
784
|
+
)
|
785
|
+
);
|
786
|
+
const nodeHandleId = apiResponse.data.modelResponse;
|
787
|
+
return new AirtopNodeImpl(this, nodeHandleId);
|
788
|
+
}
|
789
|
+
async findMany(prompt, config, requestOptions = {}) {
|
790
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
791
|
+
const apiResponse = await withRequestCompletionPolling(
|
792
|
+
this.client,
|
793
|
+
() => this.client.windows.findMany(
|
794
|
+
this.getWindowId(),
|
795
|
+
{
|
796
|
+
prompt,
|
797
|
+
sessionId: this.sessionId,
|
798
|
+
jobId: this.jobId,
|
799
|
+
...config || {}
|
800
|
+
},
|
801
|
+
{
|
802
|
+
timeout: secondsToMilliseconds3(600),
|
803
|
+
...this.resolveRequestOptions(requestOptions)
|
804
|
+
}
|
805
|
+
)
|
806
|
+
);
|
807
|
+
const nodeHandleIds = apiResponse.data.modelResponse.split(",");
|
808
|
+
return nodeHandleIds.map((nodeHandleId) => new AirtopNodeImpl(this, nodeHandleId));
|
809
|
+
}
|
612
810
|
};
|
613
811
|
|
614
812
|
// src/window/AirtopWindow.ts
|
@@ -868,7 +1066,8 @@ var AirtopClient = class extends AirtopBase {
|
|
868
1066
|
contextFieldName: "context",
|
869
1067
|
metadataFieldName: "metadata"
|
870
1068
|
}),
|
871
|
-
outputSchemaAdapter: config.outputSchemaAdapter
|
1069
|
+
outputSchemaAdapter: config.outputSchemaAdapter,
|
1070
|
+
jobId: config.jobId
|
872
1071
|
});
|
873
1072
|
this.log.withPrefix("[Airtop SDK]");
|
874
1073
|
this.client.logLevel = config.logLevel;
|
@@ -894,8 +1093,8 @@ var AirtopClient = class extends AirtopBase {
|
|
894
1093
|
* @returns A new AirtopSession instance
|
895
1094
|
*/
|
896
1095
|
async createSession(config, options = {}) {
|
897
|
-
const skipWaitSessionReady = config
|
898
|
-
delete config
|
1096
|
+
const skipWaitSessionReady = config?.skipWaitSessionReady ?? false;
|
1097
|
+
delete config?.skipWaitSessionReady;
|
899
1098
|
const sessionResponse = await this.client.sessions.create(
|
900
1099
|
{
|
901
1100
|
configuration: config
|