@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.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.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
|
import { secondsToMilliseconds } from "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
|
agentEventPublisher;
|
121
|
+
/**
|
122
|
+
* The default timeout in seconds for API requests.
|
123
|
+
* @internal
|
124
|
+
*/
|
125
|
+
defaultTimeoutInSeconds;
|
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 = 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: secondsToMilliseconds(options.timeoutInSeconds ||
|
224
|
+
timeout: secondsToMilliseconds(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
|
import { Airtop as AirtopCore } from "@airtop/core";
|
221
|
-
import {
|
233
|
+
import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns/secondsToMilliseconds";
|
222
234
|
import { ConsoleTransport, LogLayer } from "loglayer";
|
223
235
|
import { serializeError } from "serialize-error";
|
224
236
|
|
@@ -269,26 +281,27 @@ var processLogMessage = (log, logLevel, ...args) => {
|
|
269
281
|
// src/session/AirtopSessionClient.ts
|
270
282
|
import { NotFoundError } from "@airtop/core";
|
271
283
|
|
284
|
+
// src/async-utils.ts
|
285
|
+
import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
|
286
|
+
|
272
287
|
// src/types.ts
|
273
288
|
var AirtopError = class extends Error {
|
274
289
|
issues;
|
275
|
-
|
290
|
+
metadata;
|
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
|
-
import { secondsToMilliseconds as secondsToMilliseconds3 } from "date-fns";
|
284
|
-
|
285
301
|
// src/async-utils.ts
|
286
|
-
import { secondsToMilliseconds as secondsToMilliseconds2 } from "date-fns";
|
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 = secondsToMilliseconds2(requestOptions?.timeoutInSeconds ||
|
304
|
+
const timeoutMs = secondsToMilliseconds2(requestOptions?.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 (thrownError.error?.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: secondsToMilliseconds3(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
|
-
|
664
|
-
|
665
|
-
|
666
|
-
},
|
667
|
-
{
|
668
|
-
timeout: secondsToMilliseconds3(600),
|
669
|
-
...this.resolveRequestOptions(requestOptions)
|
678
|
+
if (!config?.configuration?.interval?.timeoutSeconds) {
|
679
|
+
if (!config.configuration) {
|
680
|
+
config.configuration = {};
|
681
|
+
}
|
682
|
+
if (!config.configuration.interval) {
|
683
|
+
config.configuration.interval = {};
|
670
684
|
}
|
685
|
+
config.configuration.interval.timeoutSeconds = this.defaultTimeoutInSeconds;
|
686
|
+
}
|
687
|
+
if (!config?.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
|
/**
|
@@ -685,17 +717,19 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
685
717
|
if (config?.configuration.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
|
/**
|
@@ -713,17 +747,19 @@ var AirtopWindowClient = class extends AirtopBase {
|
|
713
747
|
if (config?.configuration.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: secondsToMilliseconds3(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: secondsToMilliseconds3(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: config?.outputSchema ? this.convertToJsonSchema(config.outputSchema) : void 0
|
863
908
|
},
|
864
909
|
{
|
865
|
-
timeout: secondsToMilliseconds3(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: secondsToMilliseconds3(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: secondsToMilliseconds3(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: secondsToMilliseconds3(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: config?.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: config?.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
|
@@ -1226,7 +1333,7 @@ var AirtopClient = class extends AirtopBase {
|
|
1226
1333
|
logLevel: config?.logLevel,
|
1227
1334
|
client: new AirtopCore({
|
1228
1335
|
maxRetries: 0,
|
1229
|
-
timeout:
|
1336
|
+
timeout: secondsToMilliseconds3(config.defaultTimeoutInSeconds ?? TIMEOUT_SECONDS_DEFAULT_VALUE),
|
1230
1337
|
apiKey: config.apiKey,
|
1231
1338
|
baseURL: config?.airtopUrl,
|
1232
1339
|
logLevel: config?.logLevel || "off",
|
@@ -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: config.defaultTimeoutInSeconds ?? TIMEOUT_SECONDS_DEFAULT_VALUE
|
1252
1360
|
});
|
1253
1361
|
this.log.withPrefix("[Airtop SDK]");
|
1254
1362
|
this.client.logLevel = config.logLevel;
|
@@ -1471,7 +1579,7 @@ function registerAirtopPlugin(plugin) {
|
|
1471
1579
|
// src/agent/AirtopAgentClient.ts
|
1472
1580
|
import { version as version2 } from "node:process";
|
1473
1581
|
import { Airtop as AirtopCore2 } from "@airtop/core";
|
1474
|
-
import { minutesToMilliseconds
|
1582
|
+
import { minutesToMilliseconds } from "date-fns";
|
1475
1583
|
import { ConsoleTransport as ConsoleTransport2 } from "loglayer";
|
1476
1584
|
import { LogLayer as LogLayer2 } from "loglayer";
|
1477
1585
|
import { serializeError as serializeError2 } from "serialize-error";
|
@@ -1485,7 +1593,7 @@ var AirtopAgentClient = class extends AirtopBase {
|
|
1485
1593
|
logLevel: config?.logLevel,
|
1486
1594
|
client: new AirtopCore2({
|
1487
1595
|
maxRetries: 0,
|
1488
|
-
timeout:
|
1596
|
+
timeout: minutesToMilliseconds(1),
|
1489
1597
|
apiKey: config.apiKey,
|
1490
1598
|
baseURL: config?.airtopUrl,
|
1491
1599
|
logLevel: config?.logLevel || "off",
|