@airtop/sdk 1.0.0-alpha2.6 → 1.0.0-alpha2.7
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 +191 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +85 -3
- package/dist/index.d.ts +85 -3
- package/dist/index.js +194 -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 } 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.
|
@@ -422,6 +435,71 @@ interface WindowPromptResponse extends AIPromptResponse {
|
|
422
435
|
*/
|
423
436
|
interface WindowScrapeResponse extends ScrapeResponse {
|
424
437
|
}
|
438
|
+
/**
|
439
|
+
* Configuration parameters for extracting content from a window.
|
440
|
+
*/
|
441
|
+
interface WindowExtractConfig extends Omit<WindowExtractParams, "sessionId" | "prompt" | "jobId"> {
|
442
|
+
}
|
443
|
+
/**
|
444
|
+
* Configuration parameters for acting on content in a window.
|
445
|
+
*/
|
446
|
+
interface WindowActConfig extends Omit<WindowActParams, "sessionId" | "prompt" | "jobId"> {
|
447
|
+
}
|
448
|
+
/**
|
449
|
+
* Configuration parameters for executing an LLM call in a window.
|
450
|
+
*/
|
451
|
+
interface WindowLlmConfig extends Omit<WindowLlmParams, "sessionId" | "prompt"> {
|
452
|
+
}
|
453
|
+
/**
|
454
|
+
* Configuration parameters for finding one element in a window.
|
455
|
+
*/
|
456
|
+
interface WindowFindOneConfig extends Omit<WindowFindOneParams, "sessionId" | "prompt" | "jobId"> {
|
457
|
+
}
|
458
|
+
|
459
|
+
declare class AirtopNode {
|
460
|
+
/**
|
461
|
+
* The window client
|
462
|
+
*/
|
463
|
+
protected windowClient: AirtopWindowClient;
|
464
|
+
/**
|
465
|
+
* The node handle id to use for all requests
|
466
|
+
*/
|
467
|
+
protected nodeHandleId: string;
|
468
|
+
/**
|
469
|
+
* Constructor
|
470
|
+
* @param client - The window client
|
471
|
+
* @param nodeHandleId - The node handle id to use for all requests
|
472
|
+
*/
|
473
|
+
constructor(client: AirtopWindowClient, nodeHandleId: string);
|
474
|
+
/**
|
475
|
+
* Extract content from the node
|
476
|
+
* @param prompt - The prompt to use for the extraction
|
477
|
+
* @param config - The configuration to use for the extraction
|
478
|
+
* @param requestOptions - The request options to use for the extraction
|
479
|
+
*/
|
480
|
+
extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
481
|
+
/**
|
482
|
+
* Act on the node
|
483
|
+
* @param prompt - The prompt to use for the action
|
484
|
+
* @param config - The configuration to use for the action
|
485
|
+
* @param requestOptions - The request options to use for the action
|
486
|
+
*/
|
487
|
+
act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
488
|
+
/**
|
489
|
+
* Execute an LLM call on the node
|
490
|
+
* @param prompt - The prompt to use for the LLM call
|
491
|
+
* @param config - The configuration to use for the LLM call
|
492
|
+
* @param requestOptions - The request options to use for the LLM call
|
493
|
+
*/
|
494
|
+
llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
495
|
+
/**
|
496
|
+
* Find one element in the node
|
497
|
+
* @param prompt - The prompt to use for the find one
|
498
|
+
* @param config - The configuration to use for the find one
|
499
|
+
* @param requestOptions - The request options to use for the find one
|
500
|
+
*/
|
501
|
+
findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
|
502
|
+
}
|
425
503
|
|
426
504
|
/**
|
427
505
|
* Response object for a screenshot operation.
|
@@ -467,7 +545,7 @@ declare class AirtopWindowScreenshot {
|
|
467
545
|
};
|
468
546
|
}
|
469
547
|
|
470
|
-
|
548
|
+
/**, waitForRequestCompletion
|
471
549
|
* Client for making window-specific requests to the Airtop API.
|
472
550
|
*/
|
473
551
|
declare class AirtopWindowClient extends AirtopBase {
|
@@ -585,6 +663,10 @@ declare class AirtopWindowClient extends AirtopBase {
|
|
585
663
|
* @returns Promise resolving when the text has been typed
|
586
664
|
*/
|
587
665
|
type(text: string, config?: WindowTypeConfig, requestOptions?: AirtopRequestOptions): Promise<_airtop_core_resources_shared_mjs.AIPromptResponse>;
|
666
|
+
extract(prompt: string, config?: WindowExtractConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
667
|
+
act(prompt: string, config?: WindowActConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
668
|
+
llm(prompt: string, config?: WindowLlmConfig, requestOptions?: AirtopRequestOptions): Promise<WindowPromptResponse>;
|
669
|
+
findOne(prompt: string, config?: WindowFindOneConfig, requestOptions?: AirtopRequestOptions): Promise<AirtopNode>;
|
588
670
|
}
|
589
671
|
|
590
672
|
/**
|
@@ -1025,4 +1107,4 @@ declare class AirtopMocks {
|
|
1025
1107
|
}): AirtopWindow<AirtopWindowGetInfoResponse>;
|
1026
1108
|
}
|
1027
1109
|
|
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 };
|
1110
|
+
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 WindowActConfig, type WindowClickConfig, type WindowCreateData, type WindowError, type WindowExtractConfig, 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.7",
|
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.25",
|
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 AirtopNode = 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,88 @@ 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 AirtopNode(this, nodeHandleId);
|
788
|
+
}
|
612
789
|
};
|
613
790
|
|
614
791
|
// src/window/AirtopWindow.ts
|
@@ -868,7 +1045,8 @@ var AirtopClient = class extends AirtopBase {
|
|
868
1045
|
contextFieldName: "context",
|
869
1046
|
metadataFieldName: "metadata"
|
870
1047
|
}),
|
871
|
-
outputSchemaAdapter: config.outputSchemaAdapter
|
1048
|
+
outputSchemaAdapter: config.outputSchemaAdapter,
|
1049
|
+
jobId: config.jobId
|
872
1050
|
});
|
873
1051
|
this.log.withPrefix("[Airtop SDK]");
|
874
1052
|
this.client.logLevel = config.logLevel;
|
@@ -894,8 +1072,8 @@ var AirtopClient = class extends AirtopBase {
|
|
894
1072
|
* @returns A new AirtopSession instance
|
895
1073
|
*/
|
896
1074
|
async createSession(config, options = {}) {
|
897
|
-
const skipWaitSessionReady = config
|
898
|
-
delete config
|
1075
|
+
const skipWaitSessionReady = config?.skipWaitSessionReady ?? false;
|
1076
|
+
delete config?.skipWaitSessionReady;
|
899
1077
|
const sessionResponse = await this.client.sessions.create(
|
900
1078
|
{
|
901
1079
|
configuration: config
|