@airtop/sdk 1.0.0-alpha2.17 → 1.0.0-alpha2.19
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 +242 -134
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +47 -8
- package/dist/index.d.ts +47 -8
- package/dist/index.js +232 -124
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
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.19",
|
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.34",
|
51
51
|
"date-fns": "4.1.0",
|
52
52
|
loglayer: "6.3.3",
|
53
53
|
"serialize-error": "12.0.0",
|
@@ -86,6 +86,12 @@ var require_package = __commonJS({
|
|
86
86
|
|
87
87
|
// src/AirtopBase.ts
|
88
88
|
var _datefns = require('date-fns');
|
89
|
+
|
90
|
+
// src/constants.ts
|
91
|
+
var TIMEOUT_SECONDS_DEFAULT_VALUE = 300;
|
92
|
+
var DEFAULT_POLLING_INTERVAL_MS = 500;
|
93
|
+
|
94
|
+
// src/AirtopBase.ts
|
89
95
|
var AirtopBase = class {
|
90
96
|
/**
|
91
97
|
* Logger instance for the SDK
|
@@ -112,6 +118,11 @@ var AirtopBase = class {
|
|
112
118
|
* @internal
|
113
119
|
*/
|
114
120
|
|
121
|
+
/**
|
122
|
+
* The default timeout in seconds for API requests.
|
123
|
+
* @internal
|
124
|
+
*/
|
125
|
+
|
115
126
|
/**
|
116
127
|
* Creates a new instance of AirtopBase
|
117
128
|
* @param config - Configuration options for the SDK
|
@@ -121,6 +132,7 @@ var AirtopBase = class {
|
|
121
132
|
this.client = config.client;
|
122
133
|
this.outputJsonAdapter = config.outputSchemaAdapter;
|
123
134
|
this.jobId = config.jobId;
|
135
|
+
this.defaultTimeoutInSeconds = _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE));
|
124
136
|
if (config.agentEventPublisher) {
|
125
137
|
this.agentEventPublisher = config.agentEventPublisher;
|
126
138
|
}
|
@@ -209,7 +221,7 @@ var AirtopBase = class {
|
|
209
221
|
*/
|
210
222
|
resolveRequestOptions(options = {}) {
|
211
223
|
return {
|
212
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, options.timeoutInSeconds ||
|
224
|
+
timeout: _datefns.secondsToMilliseconds.call(void 0, options.timeoutInSeconds || this.defaultTimeoutInSeconds),
|
213
225
|
maxRetries: options.maxRetries || 0,
|
214
226
|
signal: options.abortSignal
|
215
227
|
};
|
@@ -218,7 +230,7 @@ var AirtopBase = class {
|
|
218
230
|
|
219
231
|
// src/AirtopClient.ts
|
220
232
|
var _core = require('@airtop/core');
|
221
|
-
var
|
233
|
+
var _secondsToMilliseconds = require('date-fns/secondsToMilliseconds');
|
222
234
|
var _loglayer = require('loglayer');
|
223
235
|
var _serializeerror = require('serialize-error');
|
224
236
|
|
@@ -269,26 +281,27 @@ var processLogMessage = (log, logLevel, ...args) => {
|
|
269
281
|
// src/session/AirtopSessionClient.ts
|
270
282
|
|
271
283
|
|
284
|
+
// src/async-utils.ts
|
285
|
+
|
286
|
+
|
272
287
|
// src/types.ts
|
273
288
|
var AirtopError = class extends Error {
|
274
289
|
|
275
|
-
|
290
|
+
|
291
|
+
constructor(issues, metadata) {
|
276
292
|
const errorMessage = issues.map((issue) => issue.message).join("\n");
|
277
|
-
|
293
|
+
const errorMessageWithMetadata = metadata ? `${errorMessage}
|
294
|
+
${JSON.stringify(metadata)}` : errorMessage;
|
295
|
+
super(errorMessageWithMetadata);
|
278
296
|
this.issues = issues;
|
297
|
+
this.metadata = metadata;
|
279
298
|
}
|
280
299
|
};
|
281
300
|
|
282
|
-
// src/window/AirtopWindowClient.ts
|
283
|
-
|
284
|
-
|
285
301
|
// src/async-utils.ts
|
286
|
-
|
287
|
-
var DEFAULT_TIMEOUT_SECONDS = 300;
|
288
|
-
var DEFAULT_POLLING_INTERVAL_MS = 500;
|
289
302
|
async function waitForRequestCompletion(client, requestId, requestOptions) {
|
290
303
|
const startTime = Date.now();
|
291
|
-
const timeoutMs = _datefns.secondsToMilliseconds.call(void 0, _optionalChain([requestOptions, 'optionalAccess', _5 => _5.timeoutInSeconds]) ||
|
304
|
+
const timeoutMs = _datefns.secondsToMilliseconds.call(void 0, _optionalChain([requestOptions, 'optionalAccess', _5 => _5.timeoutInSeconds]) || TIMEOUT_SECONDS_DEFAULT_VALUE);
|
292
305
|
while (Date.now() - startTime < timeoutMs) {
|
293
306
|
const apiResponse = await client.requests.getRequestStatusV2(requestId, requestOptions);
|
294
307
|
if (apiResponse.status === "completed") {
|
@@ -307,7 +320,9 @@ async function withRequestCompletionPolling(client, fn, requestOptions) {
|
|
307
320
|
return waitForRequestCompletion(client, response.requestId, requestOptions);
|
308
321
|
} catch (thrownError) {
|
309
322
|
if (_optionalChain([thrownError, 'access', _6 => _6.error, 'optionalAccess', _7 => _7.errors])) {
|
310
|
-
throw new AirtopError(thrownError.error.errors
|
323
|
+
throw new AirtopError(thrownError.error.errors, {
|
324
|
+
requestId: thrownError.error.requestId
|
325
|
+
});
|
311
326
|
}
|
312
327
|
throw thrownError;
|
313
328
|
}
|
@@ -370,7 +385,7 @@ var AirtopNode = class {
|
|
370
385
|
* @param requestOptions - The request options to use for the LLM call
|
371
386
|
*/
|
372
387
|
async llm(prompt, config, requestOptions = {}) {
|
373
|
-
return this.windowClient.llm(prompt, config, requestOptions);
|
388
|
+
return this.windowClient.llm(prompt, { ...config, nodeHandleId: this.nodeHandleId }, requestOptions);
|
374
389
|
}
|
375
390
|
/**
|
376
391
|
* Find one element in the node
|
@@ -579,17 +594,19 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
579
594
|
this.log.withMetadata({
|
580
595
|
elementDescription
|
581
596
|
}).info("Clicking on element");
|
582
|
-
return
|
583
|
-
this.
|
584
|
-
|
585
|
-
|
586
|
-
|
587
|
-
|
588
|
-
|
589
|
-
|
590
|
-
|
591
|
-
|
592
|
-
|
597
|
+
return withRequestCompletionPolling(
|
598
|
+
this.client,
|
599
|
+
() => this.client.windows.clickAsync(
|
600
|
+
this.getWindowId(),
|
601
|
+
{
|
602
|
+
...config,
|
603
|
+
elementDescription,
|
604
|
+
sessionId: this.sessionId
|
605
|
+
},
|
606
|
+
{
|
607
|
+
...this.resolveRequestOptions(requestOptions)
|
608
|
+
}
|
609
|
+
)
|
593
610
|
);
|
594
611
|
}
|
595
612
|
/**
|
@@ -611,17 +628,19 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
611
628
|
*/
|
612
629
|
async hover(elementDescription, config, requestOptions = {}) {
|
613
630
|
this.log.withMetadata(config).info("Hovering over window");
|
614
|
-
return
|
615
|
-
this.
|
616
|
-
|
617
|
-
|
618
|
-
|
619
|
-
|
620
|
-
|
621
|
-
|
622
|
-
|
623
|
-
|
624
|
-
|
631
|
+
return withRequestCompletionPolling(
|
632
|
+
this.client,
|
633
|
+
() => this.client.windows.hoverAsync(
|
634
|
+
this.getWindowId(),
|
635
|
+
{
|
636
|
+
elementDescription,
|
637
|
+
sessionId: this.sessionId,
|
638
|
+
...config || {}
|
639
|
+
},
|
640
|
+
{
|
641
|
+
...this.resolveRequestOptions(requestOptions)
|
642
|
+
}
|
643
|
+
)
|
625
644
|
);
|
626
645
|
}
|
627
646
|
/**
|
@@ -643,7 +662,6 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
643
662
|
...config
|
644
663
|
},
|
645
664
|
{
|
646
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
647
665
|
...this.resolveRequestOptions(requestOptions)
|
648
666
|
}
|
649
667
|
);
|
@@ -655,19 +673,33 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
655
673
|
* @param requestOptions - Request options
|
656
674
|
* @returns Promise resolving to the monitoring operation result
|
657
675
|
*/
|
658
|
-
async monitor(condition, config, requestOptions = {}) {
|
676
|
+
async monitor(condition, config = {}, requestOptions = {}) {
|
659
677
|
this.log.withMetadata().info("Monitoring window");
|
660
|
-
|
661
|
-
|
662
|
-
|
663
|
-
condition,
|
664
|
-
sessionId: this.sessionId,
|
665
|
-
...config || {}
|
666
|
-
},
|
667
|
-
{
|
668
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
669
|
-
...this.resolveRequestOptions(requestOptions)
|
678
|
+
if (!_optionalChain([config, 'optionalAccess', _8 => _8.configuration, 'optionalAccess', _9 => _9.interval, 'optionalAccess', _10 => _10.timeoutSeconds])) {
|
679
|
+
if (!config.configuration) {
|
680
|
+
config.configuration = {};
|
670
681
|
}
|
682
|
+
if (!config.configuration.interval) {
|
683
|
+
config.configuration.interval = {};
|
684
|
+
}
|
685
|
+
config.configuration.interval.timeoutSeconds = this.defaultTimeoutInSeconds;
|
686
|
+
}
|
687
|
+
if (!_optionalChain([config, 'optionalAccess', _11 => _11.timeThresholdSeconds])) {
|
688
|
+
config.timeThresholdSeconds = this.defaultTimeoutInSeconds;
|
689
|
+
}
|
690
|
+
return withRequestCompletionPolling(
|
691
|
+
this.client,
|
692
|
+
() => this.client.windows.monitorAsync(
|
693
|
+
this.getWindowId(),
|
694
|
+
{
|
695
|
+
condition,
|
696
|
+
sessionId: this.sessionId,
|
697
|
+
...config || {}
|
698
|
+
},
|
699
|
+
{
|
700
|
+
...this.resolveRequestOptions(requestOptions)
|
701
|
+
}
|
702
|
+
)
|
671
703
|
);
|
672
704
|
}
|
673
705
|
/**
|
@@ -682,20 +714,22 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
682
714
|
prompt
|
683
715
|
}).info("Performing a page query");
|
684
716
|
const newConfig = config;
|
685
|
-
if (_optionalChain([config, 'optionalAccess',
|
717
|
+
if (_optionalChain([config, 'optionalAccess', _12 => _12.configuration, 'access', _13 => _13.outputSchema])) {
|
686
718
|
newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
|
687
719
|
}
|
688
|
-
return
|
689
|
-
this.
|
690
|
-
|
691
|
-
|
692
|
-
|
693
|
-
|
694
|
-
|
695
|
-
|
696
|
-
|
697
|
-
|
698
|
-
|
720
|
+
return withRequestCompletionPolling(
|
721
|
+
this.client,
|
722
|
+
() => this.client.windows.pageQueryAsync(
|
723
|
+
this.getWindowId(),
|
724
|
+
{
|
725
|
+
sessionId: this.sessionId,
|
726
|
+
prompt,
|
727
|
+
...newConfig || {}
|
728
|
+
},
|
729
|
+
{
|
730
|
+
...this.resolveRequestOptions(requestOptions)
|
731
|
+
}
|
732
|
+
)
|
699
733
|
);
|
700
734
|
}
|
701
735
|
/**
|
@@ -710,20 +744,22 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
710
744
|
prompt
|
711
745
|
}).info("Performing a paginated extraction");
|
712
746
|
const newConfig = config;
|
713
|
-
if (_optionalChain([config, 'optionalAccess',
|
747
|
+
if (_optionalChain([config, 'optionalAccess', _14 => _14.configuration, 'access', _15 => _15.outputSchema])) {
|
714
748
|
newConfig.configuration.outputSchema = this.convertToJsonSchema(config.configuration.outputSchema);
|
715
749
|
}
|
716
|
-
return
|
717
|
-
this.
|
718
|
-
|
719
|
-
|
720
|
-
|
721
|
-
|
722
|
-
|
723
|
-
|
724
|
-
|
725
|
-
|
726
|
-
|
750
|
+
return withRequestCompletionPolling(
|
751
|
+
this.client,
|
752
|
+
() => this.client.windows.paginatedExtractionAsync(
|
753
|
+
this.getWindowId(),
|
754
|
+
{
|
755
|
+
prompt,
|
756
|
+
sessionId: this.sessionId,
|
757
|
+
...newConfig || {}
|
758
|
+
},
|
759
|
+
{
|
760
|
+
...this.resolveRequestOptions(requestOptions)
|
761
|
+
}
|
762
|
+
)
|
727
763
|
);
|
728
764
|
}
|
729
765
|
/**
|
@@ -734,16 +770,18 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
734
770
|
*/
|
735
771
|
async scrape(config, requestOptions = {}) {
|
736
772
|
this.log.info("Scraping window");
|
737
|
-
return
|
738
|
-
this.
|
739
|
-
|
740
|
-
|
741
|
-
|
742
|
-
|
743
|
-
|
744
|
-
|
745
|
-
|
746
|
-
|
773
|
+
return withRequestCompletionPolling(
|
774
|
+
this.client,
|
775
|
+
() => this.client.windows.scrapeAsync(
|
776
|
+
this.getWindowId(),
|
777
|
+
{
|
778
|
+
sessionId: this.sessionId,
|
779
|
+
...config || {}
|
780
|
+
},
|
781
|
+
{
|
782
|
+
...this.resolveRequestOptions(requestOptions)
|
783
|
+
}
|
784
|
+
)
|
747
785
|
);
|
748
786
|
}
|
749
787
|
/**
|
@@ -754,16 +792,18 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
754
792
|
*/
|
755
793
|
async screenshot(config, requestOptions = {}) {
|
756
794
|
this.log.info("Screenshotting window");
|
757
|
-
const resp = await
|
758
|
-
this.
|
759
|
-
|
760
|
-
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
795
|
+
const resp = await withRequestCompletionPolling(
|
796
|
+
this.client,
|
797
|
+
() => this.client.windows.screenshotAsync(
|
798
|
+
this.getWindowId(),
|
799
|
+
{
|
800
|
+
sessionId: this.sessionId,
|
801
|
+
...config || {}
|
802
|
+
},
|
803
|
+
{
|
804
|
+
...this.resolveRequestOptions(requestOptions)
|
805
|
+
}
|
806
|
+
)
|
767
807
|
);
|
768
808
|
return new AirtopWindowScreenshot(resp);
|
769
809
|
}
|
@@ -775,16 +815,18 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
775
815
|
*/
|
776
816
|
async scroll(config, requestOptions = {}) {
|
777
817
|
this.log.info("Scrolling window");
|
778
|
-
return
|
779
|
-
this.
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
818
|
+
return withRequestCompletionPolling(
|
819
|
+
this.client,
|
820
|
+
() => this.client.windows.scrollAsync(
|
821
|
+
this.getWindowId(),
|
822
|
+
{
|
823
|
+
sessionId: this.sessionId,
|
824
|
+
...config || {}
|
825
|
+
},
|
826
|
+
{
|
827
|
+
...this.resolveRequestOptions(requestOptions)
|
828
|
+
}
|
829
|
+
)
|
788
830
|
);
|
789
831
|
}
|
790
832
|
/**
|
@@ -798,17 +840,19 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
798
840
|
this.log.withMetadata({
|
799
841
|
text
|
800
842
|
}).info("Typing text");
|
801
|
-
return
|
802
|
-
this.
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
807
|
-
|
808
|
-
|
809
|
-
|
810
|
-
|
811
|
-
|
843
|
+
return withRequestCompletionPolling(
|
844
|
+
this.client,
|
845
|
+
() => this.client.windows.typeAsync(
|
846
|
+
this.getWindowId(),
|
847
|
+
{
|
848
|
+
sessionId: this.sessionId,
|
849
|
+
text,
|
850
|
+
...config || {}
|
851
|
+
},
|
852
|
+
{
|
853
|
+
...this.resolveRequestOptions(requestOptions)
|
854
|
+
}
|
855
|
+
)
|
812
856
|
);
|
813
857
|
}
|
814
858
|
async extract(prompt, config, requestOptions = {}) {
|
@@ -824,7 +868,6 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
824
868
|
...config || {}
|
825
869
|
},
|
826
870
|
{
|
827
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
828
871
|
...this.resolveRequestOptions(requestOptions)
|
829
872
|
}
|
830
873
|
)
|
@@ -843,7 +886,6 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
843
886
|
...config || {}
|
844
887
|
},
|
845
888
|
{
|
846
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
847
889
|
...this.resolveRequestOptions(requestOptions)
|
848
890
|
}
|
849
891
|
)
|
@@ -859,10 +901,12 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
859
901
|
prompt,
|
860
902
|
sessionId: this.sessionId,
|
861
903
|
jobId: this.jobId,
|
862
|
-
...config || {}
|
904
|
+
...config || {},
|
905
|
+
includeWebContext: true,
|
906
|
+
// Always include web context for window.llm() calls
|
907
|
+
outputSchema: _optionalChain([config, 'optionalAccess', _16 => _16.outputSchema]) ? this.convertToJsonSchema(config.outputSchema) : void 0
|
863
908
|
},
|
864
909
|
{
|
865
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
866
910
|
...this.resolveRequestOptions(requestOptions)
|
867
911
|
}
|
868
912
|
)
|
@@ -881,7 +925,6 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
881
925
|
...config || {}
|
882
926
|
},
|
883
927
|
{
|
884
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
885
928
|
...this.resolveRequestOptions(requestOptions)
|
886
929
|
}
|
887
930
|
)
|
@@ -920,7 +963,6 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
920
963
|
...config || {}
|
921
964
|
},
|
922
965
|
{
|
923
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
924
966
|
...this.resolveRequestOptions(requestOptions)
|
925
967
|
}
|
926
968
|
)
|
@@ -950,7 +992,6 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
950
992
|
...config || {}
|
951
993
|
},
|
952
994
|
{
|
953
|
-
timeout: _datefns.secondsToMilliseconds.call(void 0, 600),
|
954
995
|
...this.resolveRequestOptions(requestOptions)
|
955
996
|
}
|
956
997
|
)
|
@@ -968,7 +1009,26 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
968
1009
|
...config || {}
|
969
1010
|
},
|
970
1011
|
{
|
971
|
-
|
1012
|
+
...this.resolveRequestOptions(requestOptions)
|
1013
|
+
}
|
1014
|
+
)
|
1015
|
+
);
|
1016
|
+
}
|
1017
|
+
async fillForm(formData, config, requestOptions = {}) {
|
1018
|
+
return await withRequestCompletionPolling(
|
1019
|
+
this.client,
|
1020
|
+
() => this.client.windows.executeAutomation(
|
1021
|
+
this.getWindowId(),
|
1022
|
+
{
|
1023
|
+
sessionId: this.sessionId,
|
1024
|
+
...config || {},
|
1025
|
+
automationId: _optionalChain([config, 'optionalAccess', _17 => _17.automationId]) || "auto",
|
1026
|
+
parameters: {
|
1027
|
+
customData: typeof formData === "string" ? formData : JSON.stringify(formData)
|
1028
|
+
// Will be interpreted by the LLM
|
1029
|
+
}
|
1030
|
+
},
|
1031
|
+
{
|
972
1032
|
...this.resolveRequestOptions(requestOptions)
|
973
1033
|
}
|
974
1034
|
)
|
@@ -1047,6 +1107,9 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
1047
1107
|
getSessionId() {
|
1048
1108
|
return this.sessionId;
|
1049
1109
|
}
|
1110
|
+
async listWindows(requestOptions = {}) {
|
1111
|
+
return this.client.sessions.listWindows(this.sessionId, this.resolveRequestOptions(requestOptions));
|
1112
|
+
}
|
1050
1113
|
/**
|
1051
1114
|
* Gets the state of the session using the attached session id.
|
1052
1115
|
* @param requestOptions - Request options
|
@@ -1165,6 +1228,50 @@ var AirtopSessionClient = class extends AirtopBase {
|
|
1165
1228
|
this.resolveRequestOptions(requestOptions)
|
1166
1229
|
);
|
1167
1230
|
}
|
1231
|
+
async llm(prompt, config, requestOptions = {}) {
|
1232
|
+
this.log.withMetadata({ prompt }).info("Executing LLM call");
|
1233
|
+
const currentWindows = await this.listWindows();
|
1234
|
+
if (currentWindows.data.windows.length === 0) {
|
1235
|
+
throw new AirtopError([
|
1236
|
+
{
|
1237
|
+
message: "No windows found in the session. Please create a window before calling the llm() method."
|
1238
|
+
}
|
1239
|
+
]);
|
1240
|
+
}
|
1241
|
+
const firstWindow = currentWindows.data.windows[0];
|
1242
|
+
return withRequestCompletionPolling(
|
1243
|
+
this.client,
|
1244
|
+
() => this.client.windows.llm(
|
1245
|
+
firstWindow.windowId,
|
1246
|
+
{
|
1247
|
+
prompt,
|
1248
|
+
sessionId: this.sessionId,
|
1249
|
+
jobId: this.jobId,
|
1250
|
+
...config || {},
|
1251
|
+
includeWebContext: false,
|
1252
|
+
// Do not include web context for session.llm() calls
|
1253
|
+
outputSchema: _optionalChain([config, 'optionalAccess', _18 => _18.outputSchema]) ? this.convertToJsonSchema(config.outputSchema) : void 0
|
1254
|
+
},
|
1255
|
+
{
|
1256
|
+
...this.resolveRequestOptions(requestOptions)
|
1257
|
+
}
|
1258
|
+
)
|
1259
|
+
);
|
1260
|
+
}
|
1261
|
+
/**
|
1262
|
+
* Calls the service endpoint.
|
1263
|
+
* @param prompt - The prompt to send to the service, describing the actions to take
|
1264
|
+
* @param service - The service to call, if not provided, the service will be inferred from the prompt
|
1265
|
+
* @param requestOptions - Request options
|
1266
|
+
*/
|
1267
|
+
async service(prompt, service, requestOptions = {}) {
|
1268
|
+
this.log.withMetadata({ prompt }).info("Service");
|
1269
|
+
return withRequestCompletionPolling(
|
1270
|
+
this.client,
|
1271
|
+
() => this.client.sessions.service(this.sessionId, { prompt, service }),
|
1272
|
+
requestOptions
|
1273
|
+
);
|
1274
|
+
}
|
1168
1275
|
};
|
1169
1276
|
|
1170
1277
|
// src/session/AirtopSession.ts
|
@@ -1223,19 +1330,19 @@ var AirtopClient = class extends AirtopBase {
|
|
1223
1330
|
*/
|
1224
1331
|
constructor(config) {
|
1225
1332
|
super({
|
1226
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1333
|
+
logLevel: _optionalChain([config, 'optionalAccess', _19 => _19.logLevel]),
|
1227
1334
|
client: new (0, _core.Airtop)({
|
1228
1335
|
maxRetries: 0,
|
1229
|
-
timeout:
|
1336
|
+
timeout: _secondsToMilliseconds.secondsToMilliseconds.call(void 0, _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE))),
|
1230
1337
|
apiKey: config.apiKey,
|
1231
|
-
baseURL: _optionalChain([config, 'optionalAccess',
|
1232
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1338
|
+
baseURL: _optionalChain([config, 'optionalAccess', _20 => _20.airtopUrl]),
|
1339
|
+
logLevel: _optionalChain([config, 'optionalAccess', _21 => _21.logLevel]) || "off",
|
1233
1340
|
defaultHeaders: {
|
1234
1341
|
"x-airtop-sdk-source": "typescript",
|
1235
1342
|
"x-airtop-sdk-version": version
|
1236
1343
|
}
|
1237
1344
|
}),
|
1238
|
-
log: _optionalChain([config, 'optionalAccess',
|
1345
|
+
log: _optionalChain([config, 'optionalAccess', _22 => _22.logger]) || new (0, _loglayer.LogLayer)({
|
1239
1346
|
errorSerializer: _serializeerror.serializeError,
|
1240
1347
|
transport: new (0, _loglayer.ConsoleTransport)({
|
1241
1348
|
logger: console,
|
@@ -1248,7 +1355,8 @@ var AirtopClient = class extends AirtopBase {
|
|
1248
1355
|
}),
|
1249
1356
|
outputSchemaAdapter: config.outputSchemaAdapter,
|
1250
1357
|
jobId: config.jobId,
|
1251
|
-
agentEventPublisher: config.agentEventPublisher
|
1358
|
+
agentEventPublisher: config.agentEventPublisher,
|
1359
|
+
defaultTimeoutInSeconds: _nullishCoalesce(config.defaultTimeoutInSeconds, () => ( TIMEOUT_SECONDS_DEFAULT_VALUE))
|
1252
1360
|
});
|
1253
1361
|
this.log.withPrefix("[Airtop SDK]");
|
1254
1362
|
this.client.logLevel = config.logLevel;
|
@@ -1274,8 +1382,8 @@ var AirtopClient = class extends AirtopBase {
|
|
1274
1382
|
* @returns A new AirtopSession instance
|
1275
1383
|
*/
|
1276
1384
|
async createSession(config, options = {}) {
|
1277
|
-
const skipWaitSessionReady = _nullishCoalesce(_optionalChain([config, 'optionalAccess',
|
1278
|
-
_optionalChainDelete([config, 'optionalAccess',
|
1385
|
+
const skipWaitSessionReady = _nullishCoalesce(_optionalChain([config, 'optionalAccess', _23 => _23.skipWaitSessionReady]), () => ( false));
|
1386
|
+
_optionalChainDelete([config, 'optionalAccess', _24 => delete _24.skipWaitSessionReady]);
|
1279
1387
|
const sessionResponse = await this.client.sessions.create(
|
1280
1388
|
{
|
1281
1389
|
configuration: config
|
@@ -1482,19 +1590,19 @@ var AirtopAgentClient = class extends AirtopBase {
|
|
1482
1590
|
*/
|
1483
1591
|
constructor(config) {
|
1484
1592
|
super({
|
1485
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1593
|
+
logLevel: _optionalChain([config, 'optionalAccess', _25 => _25.logLevel]),
|
1486
1594
|
client: new (0, _core.Airtop)({
|
1487
1595
|
maxRetries: 0,
|
1488
1596
|
timeout: _datefns.minutesToMilliseconds.call(void 0, 1),
|
1489
1597
|
apiKey: config.apiKey,
|
1490
|
-
baseURL: _optionalChain([config, 'optionalAccess',
|
1491
|
-
logLevel: _optionalChain([config, 'optionalAccess',
|
1598
|
+
baseURL: _optionalChain([config, 'optionalAccess', _26 => _26.airtopUrl]),
|
1599
|
+
logLevel: _optionalChain([config, 'optionalAccess', _27 => _27.logLevel]) || "off",
|
1492
1600
|
defaultHeaders: {
|
1493
1601
|
"x-airtop-sdk-source": "typescript",
|
1494
1602
|
"x-airtop-sdk-version": _process.version
|
1495
1603
|
}
|
1496
1604
|
}),
|
1497
|
-
log: _optionalChain([config, 'optionalAccess',
|
1605
|
+
log: _optionalChain([config, 'optionalAccess', _28 => _28.logger]) || new (0, _loglayer.LogLayer)({
|
1498
1606
|
errorSerializer: _serializeerror.serializeError,
|
1499
1607
|
transport: new (0, _loglayer.ConsoleTransport)({
|
1500
1608
|
logger: console,
|