valyu-js 2.7.11 → 2.7.12
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.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +29 -21
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +29 -21
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { createHmac, timingSafeEqual } from "crypto";
|
|
3
|
+
import http from "http";
|
|
4
|
+
import https from "https";
|
|
3
5
|
import axios from "axios";
|
|
4
|
-
var SDK_VERSION = "2.7.
|
|
6
|
+
var SDK_VERSION = "2.7.12";
|
|
5
7
|
function normalizeContentsJobResponse(api) {
|
|
6
8
|
return {
|
|
7
9
|
success: api.success ?? true,
|
|
@@ -56,6 +58,12 @@ var Valyu = class {
|
|
|
56
58
|
"X-Valyu-SDK": "valyu-js",
|
|
57
59
|
"X-Valyu-SDK-Version": SDK_VERSION
|
|
58
60
|
};
|
|
61
|
+
this.client = axios.create({
|
|
62
|
+
baseURL: this.baseUrl,
|
|
63
|
+
headers: this.headers,
|
|
64
|
+
httpAgent: new http.Agent({ keepAlive: true }),
|
|
65
|
+
httpsAgent: new https.Agent({ keepAlive: true })
|
|
66
|
+
});
|
|
59
67
|
this.deepresearch = {
|
|
60
68
|
create: this._deepresearchCreate.bind(this),
|
|
61
69
|
status: this._deepresearchStatus.bind(this),
|
|
@@ -340,7 +348,7 @@ var Valyu = class {
|
|
|
340
348
|
if (options.instructions !== void 0) {
|
|
341
349
|
payload.instructions = options.instructions;
|
|
342
350
|
}
|
|
343
|
-
const response = await
|
|
351
|
+
const response = await this.client.post(`${this.baseUrl}/search`, payload, {
|
|
344
352
|
headers: this.headers
|
|
345
353
|
});
|
|
346
354
|
if (!response.status || response.status < 200 || response.status >= 300) {
|
|
@@ -496,7 +504,7 @@ var Valyu = class {
|
|
|
496
504
|
if (options.webhookUrl !== void 0) {
|
|
497
505
|
payload.webhook_url = options.webhookUrl;
|
|
498
506
|
}
|
|
499
|
-
const response = await
|
|
507
|
+
const response = await this.client.post(`${this.baseUrl}/contents`, payload, {
|
|
500
508
|
headers: this.headers
|
|
501
509
|
});
|
|
502
510
|
if (!response.status || response.status < 200 || response.status >= 300) {
|
|
@@ -535,7 +543,7 @@ var Valyu = class {
|
|
|
535
543
|
*/
|
|
536
544
|
async getContentsJob(jobId) {
|
|
537
545
|
try {
|
|
538
|
-
const response = await
|
|
546
|
+
const response = await this.client.get(
|
|
539
547
|
`${this.baseUrl}/contents/jobs/${jobId}`,
|
|
540
548
|
{ headers: this.headers }
|
|
541
549
|
);
|
|
@@ -700,7 +708,7 @@ var Valyu = class {
|
|
|
700
708
|
if (options.hitl.outlineReview !== void 0)
|
|
701
709
|
payload.hitl.outline_review = options.hitl.outlineReview;
|
|
702
710
|
}
|
|
703
|
-
const response = await
|
|
711
|
+
const response = await this.client.post(
|
|
704
712
|
`${this.baseUrl}/deepresearch/tasks`,
|
|
705
713
|
payload,
|
|
706
714
|
{ headers: this.headers }
|
|
@@ -718,7 +726,7 @@ var Valyu = class {
|
|
|
718
726
|
*/
|
|
719
727
|
async _deepresearchStatus(taskId) {
|
|
720
728
|
try {
|
|
721
|
-
const response = await
|
|
729
|
+
const response = await this.client.get(
|
|
722
730
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/status`,
|
|
723
731
|
{ headers: this.headers }
|
|
724
732
|
);
|
|
@@ -823,7 +831,7 @@ var Valyu = class {
|
|
|
823
831
|
async _deepresearchList(options) {
|
|
824
832
|
try {
|
|
825
833
|
const limit = options?.limit || 10;
|
|
826
|
-
const response = await
|
|
834
|
+
const response = await this.client.get(
|
|
827
835
|
`${this.baseUrl}/deepresearch/list?limit=${limit}`,
|
|
828
836
|
{ headers: this.headers }
|
|
829
837
|
);
|
|
@@ -846,7 +854,7 @@ var Valyu = class {
|
|
|
846
854
|
error: "instruction is required and cannot be empty"
|
|
847
855
|
};
|
|
848
856
|
}
|
|
849
|
-
const response = await
|
|
857
|
+
const response = await this.client.post(
|
|
850
858
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/update`,
|
|
851
859
|
{ instruction },
|
|
852
860
|
{ headers: this.headers }
|
|
@@ -867,7 +875,7 @@ var Valyu = class {
|
|
|
867
875
|
*/
|
|
868
876
|
async _deepresearchRespond(taskId, interactionId, response) {
|
|
869
877
|
try {
|
|
870
|
-
const resp = await
|
|
878
|
+
const resp = await this.client.post(
|
|
871
879
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/respond`,
|
|
872
880
|
{
|
|
873
881
|
interaction_id: interactionId,
|
|
@@ -927,7 +935,7 @@ var Valyu = class {
|
|
|
927
935
|
*/
|
|
928
936
|
async _deepresearchCancel(taskId) {
|
|
929
937
|
try {
|
|
930
|
-
const response = await
|
|
938
|
+
const response = await this.client.post(
|
|
931
939
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/cancel`,
|
|
932
940
|
{},
|
|
933
941
|
{ headers: this.headers }
|
|
@@ -945,7 +953,7 @@ var Valyu = class {
|
|
|
945
953
|
*/
|
|
946
954
|
async _deepresearchDelete(taskId) {
|
|
947
955
|
try {
|
|
948
|
-
const response = await
|
|
956
|
+
const response = await this.client.delete(
|
|
949
957
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/delete`,
|
|
950
958
|
{ headers: this.headers }
|
|
951
959
|
);
|
|
@@ -962,7 +970,7 @@ var Valyu = class {
|
|
|
962
970
|
*/
|
|
963
971
|
async _deepresearchTogglePublic(taskId, isPublic) {
|
|
964
972
|
try {
|
|
965
|
-
const response = await
|
|
973
|
+
const response = await this.client.post(
|
|
966
974
|
`${this.baseUrl}/deepresearch/tasks/${taskId}/public`,
|
|
967
975
|
{ public: isPublic },
|
|
968
976
|
{ headers: this.headers }
|
|
@@ -993,7 +1001,7 @@ var Valyu = class {
|
|
|
993
1001
|
headers["x-api-key"] = this.headers["x-api-key"];
|
|
994
1002
|
}
|
|
995
1003
|
const url = `${this.baseUrl}/deepresearch/tasks/${taskId}/assets/${assetId}${params.toString() ? `?${params.toString()}` : ""}`;
|
|
996
|
-
const response = await
|
|
1004
|
+
const response = await this.client.get(url, {
|
|
997
1005
|
headers,
|
|
998
1006
|
responseType: "arraybuffer"
|
|
999
1007
|
// For binary data
|
|
@@ -1060,7 +1068,7 @@ var Valyu = class {
|
|
|
1060
1068
|
}
|
|
1061
1069
|
if (options.webhookUrl) payload.webhook_url = options.webhookUrl;
|
|
1062
1070
|
if (options.metadata) payload.metadata = options.metadata;
|
|
1063
|
-
const response = await
|
|
1071
|
+
const response = await this.client.post(
|
|
1064
1072
|
`${this.baseUrl}/deepresearch/batches`,
|
|
1065
1073
|
payload,
|
|
1066
1074
|
{ headers: this.headers }
|
|
@@ -1080,7 +1088,7 @@ var Valyu = class {
|
|
|
1080
1088
|
*/
|
|
1081
1089
|
async _batchStatus(batchId) {
|
|
1082
1090
|
try {
|
|
1083
|
-
const response = await
|
|
1091
|
+
const response = await this.client.get(
|
|
1084
1092
|
`${this.baseUrl}/deepresearch/batches/${batchId}`,
|
|
1085
1093
|
{ headers: this.headers }
|
|
1086
1094
|
);
|
|
@@ -1143,7 +1151,7 @@ var Valyu = class {
|
|
|
1143
1151
|
if (task.metadata) taskPayload.metadata = task.metadata;
|
|
1144
1152
|
return taskPayload;
|
|
1145
1153
|
});
|
|
1146
|
-
const response = await
|
|
1154
|
+
const response = await this.client.post(
|
|
1147
1155
|
`${this.baseUrl}/deepresearch/batches/${batchId}/tasks`,
|
|
1148
1156
|
{ tasks: tasksPayload },
|
|
1149
1157
|
{ headers: this.headers }
|
|
@@ -1181,7 +1189,7 @@ var Valyu = class {
|
|
|
1181
1189
|
params.append("include_output", options.includeOutput.toString());
|
|
1182
1190
|
}
|
|
1183
1191
|
const url = `${this.baseUrl}/deepresearch/batches/${batchId}/tasks${params.toString() ? `?${params.toString()}` : ""}`;
|
|
1184
|
-
const response = await
|
|
1192
|
+
const response = await this.client.get(url, { headers: this.headers });
|
|
1185
1193
|
return { success: true, ...response.data };
|
|
1186
1194
|
} catch (e) {
|
|
1187
1195
|
return {
|
|
@@ -1197,7 +1205,7 @@ var Valyu = class {
|
|
|
1197
1205
|
*/
|
|
1198
1206
|
async _batchCancel(batchId) {
|
|
1199
1207
|
try {
|
|
1200
|
-
const response = await
|
|
1208
|
+
const response = await this.client.post(
|
|
1201
1209
|
`${this.baseUrl}/deepresearch/batches/${batchId}/cancel`,
|
|
1202
1210
|
{},
|
|
1203
1211
|
{ headers: this.headers }
|
|
@@ -1223,7 +1231,7 @@ var Valyu = class {
|
|
|
1223
1231
|
params.append("limit", options.limit.toString());
|
|
1224
1232
|
}
|
|
1225
1233
|
const url = `${this.baseUrl}/deepresearch/batches${params.toString() ? `?${params.toString()}` : ""}`;
|
|
1226
|
-
const response = await
|
|
1234
|
+
const response = await this.client.get(url, {
|
|
1227
1235
|
headers: this.headers
|
|
1228
1236
|
});
|
|
1229
1237
|
return { success: true, batches: response.data };
|
|
@@ -1581,7 +1589,7 @@ var Valyu = class {
|
|
|
1581
1589
|
params.append("category", options.category);
|
|
1582
1590
|
}
|
|
1583
1591
|
const url = `${this.baseUrl}/datasources${params.toString() ? `?${params.toString()}` : ""}`;
|
|
1584
|
-
const response = await
|
|
1592
|
+
const response = await this.client.get(url, { headers: this.headers });
|
|
1585
1593
|
return { success: true, datasources: response.data.datasources };
|
|
1586
1594
|
} catch (e) {
|
|
1587
1595
|
return {
|
|
@@ -1596,7 +1604,7 @@ var Valyu = class {
|
|
|
1596
1604
|
*/
|
|
1597
1605
|
async _datasourcesCategories() {
|
|
1598
1606
|
try {
|
|
1599
|
-
const response = await
|
|
1607
|
+
const response = await this.client.get(`${this.baseUrl}/datasources/categories`, {
|
|
1600
1608
|
headers: this.headers
|
|
1601
1609
|
});
|
|
1602
1610
|
return { success: true, categories: response.data.categories };
|