wuying-agentbay-sdk 0.5.1 → 0.7.0
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/README.md +84 -153
- package/dist/index.cjs +1766 -245
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.mts +821 -50
- package/dist/index.d.ts +821 -50
- package/dist/index.mjs +1743 -222
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -305,6 +305,7 @@ declare class CreateMcpSessionRequest extends $dara.Model {
|
|
|
305
305
|
externalUserId?: string;
|
|
306
306
|
imageId?: string;
|
|
307
307
|
labels?: string;
|
|
308
|
+
mcpPolicyId?: string;
|
|
308
309
|
persistenceDataList?: CreateMcpSessionRequestPersistenceDataList[];
|
|
309
310
|
sessionId?: string;
|
|
310
311
|
vpcResource?: boolean;
|
|
@@ -326,6 +327,7 @@ declare class CreateMcpSessionShrinkRequest extends $dara.Model {
|
|
|
326
327
|
externalUserId?: string;
|
|
327
328
|
imageId?: string;
|
|
328
329
|
labels?: string;
|
|
330
|
+
mcpPolicyId?: string;
|
|
329
331
|
persistenceDataListShrink?: string;
|
|
330
332
|
sessionId?: string;
|
|
331
333
|
vpcResource?: boolean;
|
|
@@ -704,6 +706,9 @@ declare class InitBrowserRequest extends $dara.Model {
|
|
|
704
706
|
authorization?: string;
|
|
705
707
|
persistentPath?: string;
|
|
706
708
|
sessionId?: string;
|
|
709
|
+
browserOption?: {
|
|
710
|
+
[key: string]: any;
|
|
711
|
+
};
|
|
707
712
|
static names(): {
|
|
708
713
|
[key: string]: string;
|
|
709
714
|
};
|
|
@@ -1153,6 +1158,268 @@ declare class SyncContextResponse extends $dara.Model {
|
|
|
1153
1158
|
});
|
|
1154
1159
|
}
|
|
1155
1160
|
|
|
1161
|
+
declare class DeleteContextFileRequest extends $dara.Model {
|
|
1162
|
+
authorization?: string;
|
|
1163
|
+
contextId?: string;
|
|
1164
|
+
filePath?: string;
|
|
1165
|
+
static names(): {
|
|
1166
|
+
[key: string]: string;
|
|
1167
|
+
};
|
|
1168
|
+
static types(): {
|
|
1169
|
+
[key: string]: any;
|
|
1170
|
+
};
|
|
1171
|
+
validate(): void;
|
|
1172
|
+
constructor(map?: {
|
|
1173
|
+
[key: string]: any;
|
|
1174
|
+
});
|
|
1175
|
+
}
|
|
1176
|
+
|
|
1177
|
+
declare class DeleteContextFileResponseBody extends $dara.Model {
|
|
1178
|
+
code?: string;
|
|
1179
|
+
httpStatusCode?: number;
|
|
1180
|
+
message?: string;
|
|
1181
|
+
requestId?: string;
|
|
1182
|
+
success?: boolean;
|
|
1183
|
+
static names(): {
|
|
1184
|
+
[key: string]: string;
|
|
1185
|
+
};
|
|
1186
|
+
static types(): {
|
|
1187
|
+
[key: string]: any;
|
|
1188
|
+
};
|
|
1189
|
+
validate(): void;
|
|
1190
|
+
constructor(map?: {
|
|
1191
|
+
[key: string]: any;
|
|
1192
|
+
});
|
|
1193
|
+
}
|
|
1194
|
+
|
|
1195
|
+
declare class DeleteContextFileResponse extends $dara.Model {
|
|
1196
|
+
headers?: {
|
|
1197
|
+
[key: string]: string;
|
|
1198
|
+
};
|
|
1199
|
+
statusCode?: number;
|
|
1200
|
+
body?: DeleteContextFileResponseBody;
|
|
1201
|
+
static names(): {
|
|
1202
|
+
[key: string]: string;
|
|
1203
|
+
};
|
|
1204
|
+
static types(): {
|
|
1205
|
+
[key: string]: any;
|
|
1206
|
+
};
|
|
1207
|
+
validate(): void;
|
|
1208
|
+
constructor(map?: {
|
|
1209
|
+
[key: string]: any;
|
|
1210
|
+
});
|
|
1211
|
+
}
|
|
1212
|
+
|
|
1213
|
+
declare class DescribeContextFilesRequest extends $dara.Model {
|
|
1214
|
+
authorization?: string;
|
|
1215
|
+
pageNumber?: number;
|
|
1216
|
+
pageSize?: number;
|
|
1217
|
+
parentFolderPath?: string;
|
|
1218
|
+
contextId?: string;
|
|
1219
|
+
static names(): {
|
|
1220
|
+
[key: string]: string;
|
|
1221
|
+
};
|
|
1222
|
+
static types(): {
|
|
1223
|
+
[key: string]: any;
|
|
1224
|
+
};
|
|
1225
|
+
validate(): void;
|
|
1226
|
+
constructor(map?: {
|
|
1227
|
+
[key: string]: any;
|
|
1228
|
+
});
|
|
1229
|
+
}
|
|
1230
|
+
|
|
1231
|
+
declare class DescribeContextFilesResponseBodyData extends $dara.Model {
|
|
1232
|
+
fileId?: string;
|
|
1233
|
+
fileName?: string;
|
|
1234
|
+
filePath?: string;
|
|
1235
|
+
fileType?: string;
|
|
1236
|
+
gmtCreate?: string;
|
|
1237
|
+
gmtModified?: string;
|
|
1238
|
+
size?: number;
|
|
1239
|
+
status?: string;
|
|
1240
|
+
static names(): {
|
|
1241
|
+
[key: string]: string;
|
|
1242
|
+
};
|
|
1243
|
+
static types(): {
|
|
1244
|
+
[key: string]: any;
|
|
1245
|
+
};
|
|
1246
|
+
validate(): void;
|
|
1247
|
+
constructor(map?: {
|
|
1248
|
+
[key: string]: any;
|
|
1249
|
+
});
|
|
1250
|
+
}
|
|
1251
|
+
declare class DescribeContextFilesResponseBody extends $dara.Model {
|
|
1252
|
+
code?: string;
|
|
1253
|
+
count?: number;
|
|
1254
|
+
data?: DescribeContextFilesResponseBodyData[];
|
|
1255
|
+
httpStatusCode?: number;
|
|
1256
|
+
message?: string;
|
|
1257
|
+
requestId?: string;
|
|
1258
|
+
success?: boolean;
|
|
1259
|
+
static names(): {
|
|
1260
|
+
[key: string]: string;
|
|
1261
|
+
};
|
|
1262
|
+
static types(): {
|
|
1263
|
+
[key: string]: any;
|
|
1264
|
+
};
|
|
1265
|
+
validate(): void;
|
|
1266
|
+
constructor(map?: {
|
|
1267
|
+
[key: string]: any;
|
|
1268
|
+
});
|
|
1269
|
+
}
|
|
1270
|
+
|
|
1271
|
+
declare class DescribeContextFilesResponse extends $dara.Model {
|
|
1272
|
+
headers?: {
|
|
1273
|
+
[key: string]: string;
|
|
1274
|
+
};
|
|
1275
|
+
statusCode?: number;
|
|
1276
|
+
body?: DescribeContextFilesResponseBody;
|
|
1277
|
+
static names(): {
|
|
1278
|
+
[key: string]: string;
|
|
1279
|
+
};
|
|
1280
|
+
static types(): {
|
|
1281
|
+
[key: string]: any;
|
|
1282
|
+
};
|
|
1283
|
+
validate(): void;
|
|
1284
|
+
constructor(map?: {
|
|
1285
|
+
[key: string]: any;
|
|
1286
|
+
});
|
|
1287
|
+
}
|
|
1288
|
+
|
|
1289
|
+
declare class GetContextFileDownloadUrlRequest extends $dara.Model {
|
|
1290
|
+
authorization?: string;
|
|
1291
|
+
contextId?: string;
|
|
1292
|
+
filePath?: string;
|
|
1293
|
+
static names(): {
|
|
1294
|
+
[key: string]: string;
|
|
1295
|
+
};
|
|
1296
|
+
static types(): {
|
|
1297
|
+
[key: string]: any;
|
|
1298
|
+
};
|
|
1299
|
+
validate(): void;
|
|
1300
|
+
constructor(map?: {
|
|
1301
|
+
[key: string]: any;
|
|
1302
|
+
});
|
|
1303
|
+
}
|
|
1304
|
+
|
|
1305
|
+
declare class GetContextFileDownloadUrlResponseBodyData extends $dara.Model {
|
|
1306
|
+
expireTime?: number;
|
|
1307
|
+
url?: string;
|
|
1308
|
+
static names(): {
|
|
1309
|
+
[key: string]: string;
|
|
1310
|
+
};
|
|
1311
|
+
static types(): {
|
|
1312
|
+
[key: string]: any;
|
|
1313
|
+
};
|
|
1314
|
+
validate(): void;
|
|
1315
|
+
constructor(map?: {
|
|
1316
|
+
[key: string]: any;
|
|
1317
|
+
});
|
|
1318
|
+
}
|
|
1319
|
+
declare class GetContextFileDownloadUrlResponseBody extends $dara.Model {
|
|
1320
|
+
code?: string;
|
|
1321
|
+
data?: GetContextFileDownloadUrlResponseBodyData;
|
|
1322
|
+
httpStatusCode?: number;
|
|
1323
|
+
message?: string;
|
|
1324
|
+
requestId?: string;
|
|
1325
|
+
success?: boolean;
|
|
1326
|
+
static names(): {
|
|
1327
|
+
[key: string]: string;
|
|
1328
|
+
};
|
|
1329
|
+
static types(): {
|
|
1330
|
+
[key: string]: any;
|
|
1331
|
+
};
|
|
1332
|
+
validate(): void;
|
|
1333
|
+
constructor(map?: {
|
|
1334
|
+
[key: string]: any;
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1338
|
+
declare class GetContextFileDownloadUrlResponse extends $dara.Model {
|
|
1339
|
+
headers?: {
|
|
1340
|
+
[key: string]: string;
|
|
1341
|
+
};
|
|
1342
|
+
statusCode?: number;
|
|
1343
|
+
body?: GetContextFileDownloadUrlResponseBody;
|
|
1344
|
+
static names(): {
|
|
1345
|
+
[key: string]: string;
|
|
1346
|
+
};
|
|
1347
|
+
static types(): {
|
|
1348
|
+
[key: string]: any;
|
|
1349
|
+
};
|
|
1350
|
+
validate(): void;
|
|
1351
|
+
constructor(map?: {
|
|
1352
|
+
[key: string]: any;
|
|
1353
|
+
});
|
|
1354
|
+
}
|
|
1355
|
+
|
|
1356
|
+
declare class GetContextFileUploadUrlRequest extends $dara.Model {
|
|
1357
|
+
authorization?: string;
|
|
1358
|
+
contextId?: string;
|
|
1359
|
+
filePath?: string;
|
|
1360
|
+
static names(): {
|
|
1361
|
+
[key: string]: string;
|
|
1362
|
+
};
|
|
1363
|
+
static types(): {
|
|
1364
|
+
[key: string]: any;
|
|
1365
|
+
};
|
|
1366
|
+
validate(): void;
|
|
1367
|
+
constructor(map?: {
|
|
1368
|
+
[key: string]: any;
|
|
1369
|
+
});
|
|
1370
|
+
}
|
|
1371
|
+
|
|
1372
|
+
declare class GetContextFileUploadUrlResponseBodyData extends $dara.Model {
|
|
1373
|
+
expireTime?: number;
|
|
1374
|
+
url?: string;
|
|
1375
|
+
static names(): {
|
|
1376
|
+
[key: string]: string;
|
|
1377
|
+
};
|
|
1378
|
+
static types(): {
|
|
1379
|
+
[key: string]: any;
|
|
1380
|
+
};
|
|
1381
|
+
validate(): void;
|
|
1382
|
+
constructor(map?: {
|
|
1383
|
+
[key: string]: any;
|
|
1384
|
+
});
|
|
1385
|
+
}
|
|
1386
|
+
declare class GetContextFileUploadUrlResponseBody extends $dara.Model {
|
|
1387
|
+
code?: string;
|
|
1388
|
+
data?: GetContextFileUploadUrlResponseBodyData;
|
|
1389
|
+
httpStatusCode?: number;
|
|
1390
|
+
message?: string;
|
|
1391
|
+
requestId?: string;
|
|
1392
|
+
success?: boolean;
|
|
1393
|
+
static names(): {
|
|
1394
|
+
[key: string]: string;
|
|
1395
|
+
};
|
|
1396
|
+
static types(): {
|
|
1397
|
+
[key: string]: any;
|
|
1398
|
+
};
|
|
1399
|
+
validate(): void;
|
|
1400
|
+
constructor(map?: {
|
|
1401
|
+
[key: string]: any;
|
|
1402
|
+
});
|
|
1403
|
+
}
|
|
1404
|
+
|
|
1405
|
+
declare class GetContextFileUploadUrlResponse extends $dara.Model {
|
|
1406
|
+
headers?: {
|
|
1407
|
+
[key: string]: string;
|
|
1408
|
+
};
|
|
1409
|
+
statusCode?: number;
|
|
1410
|
+
body?: GetContextFileUploadUrlResponseBody;
|
|
1411
|
+
static names(): {
|
|
1412
|
+
[key: string]: string;
|
|
1413
|
+
};
|
|
1414
|
+
static types(): {
|
|
1415
|
+
[key: string]: any;
|
|
1416
|
+
};
|
|
1417
|
+
validate(): void;
|
|
1418
|
+
constructor(map?: {
|
|
1419
|
+
[key: string]: any;
|
|
1420
|
+
});
|
|
1421
|
+
}
|
|
1422
|
+
|
|
1156
1423
|
declare class Client extends OpenApi {
|
|
1157
1424
|
constructor(config: $OpenApiUtil.Config);
|
|
1158
1425
|
getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: {
|
|
@@ -1405,6 +1672,66 @@ declare class Client extends OpenApi {
|
|
|
1405
1672
|
* @returns InitBrowserResponse
|
|
1406
1673
|
*/
|
|
1407
1674
|
initBrowserSync(request: InitBrowserRequest): InitBrowserResponse;
|
|
1675
|
+
/**
|
|
1676
|
+
* 获取上传context文件url
|
|
1677
|
+
*
|
|
1678
|
+
* @param request - DeleteContextFileRequest
|
|
1679
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
1680
|
+
* @returns DeleteContextFileResponse
|
|
1681
|
+
*/
|
|
1682
|
+
deleteContextFileWithOptions(request: DeleteContextFileRequest, runtime: $dara.RuntimeOptions): Promise<DeleteContextFileResponse>;
|
|
1683
|
+
/**
|
|
1684
|
+
* 获取上传context文件url
|
|
1685
|
+
*
|
|
1686
|
+
* @param request - DeleteContextFileRequest
|
|
1687
|
+
* @returns DeleteContextFileResponse
|
|
1688
|
+
*/
|
|
1689
|
+
deleteContextFile(request: DeleteContextFileRequest): Promise<DeleteContextFileResponse>;
|
|
1690
|
+
/**
|
|
1691
|
+
* 查询context特定目录文件
|
|
1692
|
+
*
|
|
1693
|
+
* @param request - DescribeContextFilesRequest
|
|
1694
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
1695
|
+
* @returns DescribeContextFilesResponse
|
|
1696
|
+
*/
|
|
1697
|
+
describeContextFilesWithOptions(request: DescribeContextFilesRequest, runtime: $dara.RuntimeOptions): Promise<DescribeContextFilesResponse>;
|
|
1698
|
+
/**
|
|
1699
|
+
* 查询context特定目录文件
|
|
1700
|
+
*
|
|
1701
|
+
* @param request - DescribeContextFilesRequest
|
|
1702
|
+
* @returns DescribeContextFilesResponse
|
|
1703
|
+
*/
|
|
1704
|
+
describeContextFiles(request: DescribeContextFilesRequest): Promise<DescribeContextFilesResponse>;
|
|
1705
|
+
/**
|
|
1706
|
+
* 获取上传context文件url
|
|
1707
|
+
*
|
|
1708
|
+
* @param request - GetContextFileDownloadUrlRequest
|
|
1709
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
1710
|
+
* @returns GetContextFileDownloadUrlResponse
|
|
1711
|
+
*/
|
|
1712
|
+
getContextFileDownloadUrlWithOptions(request: GetContextFileDownloadUrlRequest, runtime: $dara.RuntimeOptions): Promise<GetContextFileDownloadUrlResponse>;
|
|
1713
|
+
/**
|
|
1714
|
+
* 获取上传context文件url
|
|
1715
|
+
*
|
|
1716
|
+
* @param request - GetContextFileDownloadUrlRequest
|
|
1717
|
+
* @returns GetContextFileDownloadUrlResponse
|
|
1718
|
+
*/
|
|
1719
|
+
getContextFileDownloadUrl(request: GetContextFileDownloadUrlRequest): Promise<GetContextFileDownloadUrlResponse>;
|
|
1720
|
+
/**
|
|
1721
|
+
* 获取上传context文件url
|
|
1722
|
+
*
|
|
1723
|
+
* @param request - GetContextFileUploadUrlRequest
|
|
1724
|
+
* @param runtime - runtime options for this request RuntimeOptions
|
|
1725
|
+
* @returns GetContextFileUploadUrlResponse
|
|
1726
|
+
*/
|
|
1727
|
+
getContextFileUploadUrlWithOptions(request: GetContextFileUploadUrlRequest, runtime: $dara.RuntimeOptions): Promise<GetContextFileUploadUrlResponse>;
|
|
1728
|
+
/**
|
|
1729
|
+
* 获取上传context文件url
|
|
1730
|
+
*
|
|
1731
|
+
* @param request - GetContextFileUploadUrlRequest
|
|
1732
|
+
* @returns GetContextFileUploadUrlResponse
|
|
1733
|
+
*/
|
|
1734
|
+
getContextFileUploadUrl(request: GetContextFileUploadUrlRequest): Promise<GetContextFileUploadUrlResponse>;
|
|
1408
1735
|
}
|
|
1409
1736
|
|
|
1410
1737
|
interface Config {
|
|
@@ -1412,6 +1739,19 @@ interface Config {
|
|
|
1412
1739
|
endpoint: string;
|
|
1413
1740
|
timeout_ms: number;
|
|
1414
1741
|
}
|
|
1742
|
+
/**
|
|
1743
|
+
* Load .env file into process.env if it exists
|
|
1744
|
+
* This function should be called early to ensure .env variables are available
|
|
1745
|
+
*/
|
|
1746
|
+
declare function loadDotEnv(): void;
|
|
1747
|
+
/**
|
|
1748
|
+
* The SDK uses the following precedence order for configuration (highest to lowest):
|
|
1749
|
+
* 1. Explicitly passed configuration in code.
|
|
1750
|
+
* 2. Environment variables.
|
|
1751
|
+
* 3. .env file.
|
|
1752
|
+
* 4. Default configuration.
|
|
1753
|
+
*/
|
|
1754
|
+
declare function loadConfig(customConfig?: Config): Config;
|
|
1415
1755
|
|
|
1416
1756
|
/**
|
|
1417
1757
|
* Base interface for API responses
|
|
@@ -1733,6 +2073,49 @@ interface ContextListResult extends ApiResponse {
|
|
|
1733
2073
|
/** Optional error message if the operation failed */
|
|
1734
2074
|
errorMessage?: string;
|
|
1735
2075
|
}
|
|
2076
|
+
/**
|
|
2077
|
+
* Result of a presigned URL request
|
|
2078
|
+
*/
|
|
2079
|
+
interface FileUrlResult extends ApiResponse {
|
|
2080
|
+
/** Request identifier for tracking API calls */
|
|
2081
|
+
requestId: string;
|
|
2082
|
+
/** Whether the operation was successful */
|
|
2083
|
+
success: boolean;
|
|
2084
|
+
/** The presigned URL */
|
|
2085
|
+
url: string;
|
|
2086
|
+
/** Optional expire time (epoch seconds) */
|
|
2087
|
+
expireTime?: number;
|
|
2088
|
+
/** Optional error message if the operation failed */
|
|
2089
|
+
errorMessage?: string;
|
|
2090
|
+
}
|
|
2091
|
+
/**
|
|
2092
|
+
* Represents a file item in a context
|
|
2093
|
+
*/
|
|
2094
|
+
interface ContextFileEntry {
|
|
2095
|
+
fileId?: string;
|
|
2096
|
+
fileName?: string;
|
|
2097
|
+
filePath: string;
|
|
2098
|
+
fileType?: string;
|
|
2099
|
+
gmtCreate?: string;
|
|
2100
|
+
gmtModified?: string;
|
|
2101
|
+
size?: number;
|
|
2102
|
+
status?: string;
|
|
2103
|
+
}
|
|
2104
|
+
/**
|
|
2105
|
+
* Result of context file listing
|
|
2106
|
+
*/
|
|
2107
|
+
interface ContextFileListResult extends ApiResponse {
|
|
2108
|
+
/** Request identifier for tracking API calls */
|
|
2109
|
+
requestId: string;
|
|
2110
|
+
/** Whether the operation was successful */
|
|
2111
|
+
success: boolean;
|
|
2112
|
+
/** File entries under a folder */
|
|
2113
|
+
entries: ContextFileEntry[];
|
|
2114
|
+
/** Optional total count returned by backend */
|
|
2115
|
+
count?: number;
|
|
2116
|
+
/** Optional error message if the operation failed */
|
|
2117
|
+
errorMessage?: string;
|
|
2118
|
+
}
|
|
1736
2119
|
|
|
1737
2120
|
/**
|
|
1738
2121
|
* Represents a persistent storage context in the AgentBay cloud environment.
|
|
@@ -1840,6 +2223,22 @@ declare class ContextService {
|
|
|
1840
2223
|
* @returns OperationResult with requestId
|
|
1841
2224
|
*/
|
|
1842
2225
|
delete(context: Context): Promise<OperationResult>;
|
|
2226
|
+
/**
|
|
2227
|
+
* Get a presigned upload URL for a file in a context.
|
|
2228
|
+
*/
|
|
2229
|
+
getFileUploadUrl(contextId: string, filePath: string): Promise<FileUrlResult>;
|
|
2230
|
+
/**
|
|
2231
|
+
* Get a presigned download URL for a file in a context.
|
|
2232
|
+
*/
|
|
2233
|
+
getFileDownloadUrl(contextId: string, filePath: string): Promise<FileUrlResult>;
|
|
2234
|
+
/**
|
|
2235
|
+
* Delete a file in a context.
|
|
2236
|
+
*/
|
|
2237
|
+
deleteFile(contextId: string, filePath: string): Promise<OperationResult>;
|
|
2238
|
+
/**
|
|
2239
|
+
* List files under a specific folder path in a context.
|
|
2240
|
+
*/
|
|
2241
|
+
listFiles(contextId: string, parentFolderPath: string, pageNumber?: number, pageSize?: number): Promise<ContextFileListResult>;
|
|
1843
2242
|
}
|
|
1844
2243
|
|
|
1845
2244
|
declare enum UploadStrategy {
|
|
@@ -1860,6 +2259,25 @@ interface DownloadPolicy {
|
|
|
1860
2259
|
interface DeletePolicy {
|
|
1861
2260
|
syncLocalFile: boolean;
|
|
1862
2261
|
}
|
|
2262
|
+
interface ExtractPolicy {
|
|
2263
|
+
extract: boolean;
|
|
2264
|
+
deleteSrcFile: boolean;
|
|
2265
|
+
extractToCurrentFolder: boolean;
|
|
2266
|
+
}
|
|
2267
|
+
declare class ExtractPolicyClass implements ExtractPolicy {
|
|
2268
|
+
extract: boolean;
|
|
2269
|
+
deleteSrcFile: boolean;
|
|
2270
|
+
extractToCurrentFolder: boolean;
|
|
2271
|
+
constructor(extract?: boolean, deleteSrcFile?: boolean, extractToCurrentFolder?: boolean);
|
|
2272
|
+
/**
|
|
2273
|
+
* Creates a new extract policy with default values
|
|
2274
|
+
*/
|
|
2275
|
+
static default(): ExtractPolicyClass;
|
|
2276
|
+
/**
|
|
2277
|
+
* Converts to plain object for JSON serialization
|
|
2278
|
+
*/
|
|
2279
|
+
toDict(): Record<string, any>;
|
|
2280
|
+
}
|
|
1863
2281
|
interface WhiteList {
|
|
1864
2282
|
path: string;
|
|
1865
2283
|
excludePaths?: string[];
|
|
@@ -1871,12 +2289,14 @@ interface SyncPolicy {
|
|
|
1871
2289
|
uploadPolicy?: UploadPolicy;
|
|
1872
2290
|
downloadPolicy?: DownloadPolicy;
|
|
1873
2291
|
deletePolicy?: DeletePolicy;
|
|
2292
|
+
extractPolicy?: ExtractPolicy;
|
|
1874
2293
|
bwList?: BWList;
|
|
1875
2294
|
}
|
|
1876
2295
|
declare class SyncPolicyImpl implements SyncPolicy {
|
|
1877
2296
|
uploadPolicy?: UploadPolicy;
|
|
1878
2297
|
downloadPolicy?: DownloadPolicy;
|
|
1879
2298
|
deletePolicy?: DeletePolicy;
|
|
2299
|
+
extractPolicy?: ExtractPolicy;
|
|
1880
2300
|
bwList?: BWList;
|
|
1881
2301
|
constructor(policy?: Partial<SyncPolicy>);
|
|
1882
2302
|
private ensureDefaults;
|
|
@@ -1892,6 +2312,7 @@ declare class ContextSync {
|
|
|
1892
2312
|
declare function newUploadPolicy(): UploadPolicy;
|
|
1893
2313
|
declare function newDownloadPolicy(): DownloadPolicy;
|
|
1894
2314
|
declare function newDeletePolicy(): DeletePolicy;
|
|
2315
|
+
declare function newExtractPolicy(): ExtractPolicy;
|
|
1895
2316
|
declare function newSyncPolicy(): SyncPolicy;
|
|
1896
2317
|
declare function newSyncPolicyWithDefaults(policy?: Partial<SyncPolicy>): SyncPolicy;
|
|
1897
2318
|
declare function newContextSync(contextId: string, path: string, policy?: SyncPolicy): ContextSync;
|
|
@@ -2258,15 +2679,14 @@ declare class FileSystem {
|
|
|
2258
2679
|
*/
|
|
2259
2680
|
moveFile(source: string, destination: string): Promise<BoolResult>;
|
|
2260
2681
|
/**
|
|
2261
|
-
*
|
|
2262
|
-
* Corresponds to Python's read_file() method
|
|
2682
|
+
* Internal method to read a file chunk. Used for chunked file operations.
|
|
2263
2683
|
*
|
|
2264
2684
|
* @param path - Path to the file to read.
|
|
2265
2685
|
* @param offset - Optional: Byte offset to start reading from (0-based).
|
|
2266
2686
|
* @param length - Optional: Number of bytes to read. If 0, reads the entire file from offset.
|
|
2267
2687
|
* @returns FileContentResult with file content and requestId
|
|
2268
2688
|
*/
|
|
2269
|
-
|
|
2689
|
+
private readFileChunk;
|
|
2270
2690
|
/**
|
|
2271
2691
|
* Reads the content of multiple files.
|
|
2272
2692
|
* Corresponds to Python's read_multiple_files() method
|
|
@@ -2286,34 +2706,30 @@ declare class FileSystem {
|
|
|
2286
2706
|
*/
|
|
2287
2707
|
searchFiles(path: string, pattern: string, excludePatterns?: string[]): Promise<FileSearchResult>;
|
|
2288
2708
|
/**
|
|
2289
|
-
*
|
|
2290
|
-
* Corresponds to Python's write_file() method
|
|
2709
|
+
* Internal method to write a file chunk. Used for chunked file operations.
|
|
2291
2710
|
*
|
|
2292
2711
|
* @param path - Path to the file to write.
|
|
2293
2712
|
* @param content - Content to write to the file.
|
|
2294
2713
|
* @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
|
|
2295
2714
|
* @returns BoolResult with write result and requestId
|
|
2296
2715
|
*/
|
|
2297
|
-
|
|
2716
|
+
private writeFileChunk;
|
|
2298
2717
|
/**
|
|
2299
|
-
* Reads
|
|
2300
|
-
* Corresponds to Python's read_large_file() method
|
|
2718
|
+
* Reads the contents of a file. Automatically handles large files by chunking.
|
|
2301
2719
|
*
|
|
2302
2720
|
* @param path - Path to the file to read.
|
|
2303
|
-
* @param chunkSize - Optional: Size of each chunk in bytes. Default is 60KB.
|
|
2304
2721
|
* @returns FileContentResult with complete file content and requestId
|
|
2305
2722
|
*/
|
|
2306
|
-
|
|
2723
|
+
readFile(path: string): Promise<FileContentResult>;
|
|
2307
2724
|
/**
|
|
2308
|
-
* Writes a
|
|
2309
|
-
* Corresponds to Python's write_large_file() method
|
|
2725
|
+
* Writes content to a file. Automatically handles large files by chunking.
|
|
2310
2726
|
*
|
|
2311
2727
|
* @param path - Path to the file to write.
|
|
2312
2728
|
* @param content - Content to write to the file.
|
|
2313
|
-
* @param
|
|
2729
|
+
* @param mode - Optional: Write mode. One of "overwrite", "append", or "create_new". Default is "overwrite".
|
|
2314
2730
|
* @returns BoolResult indicating success or failure with requestId
|
|
2315
2731
|
*/
|
|
2316
|
-
|
|
2732
|
+
writeFile(path: string, content: string, mode?: string): Promise<BoolResult>;
|
|
2317
2733
|
}
|
|
2318
2734
|
|
|
2319
2735
|
/**
|
|
@@ -2643,6 +3059,7 @@ interface ObserveOptions {
|
|
|
2643
3059
|
interface ExtractOptions<T = any> {
|
|
2644
3060
|
instruction: string;
|
|
2645
3061
|
schema: new (...args: any[]) => T;
|
|
3062
|
+
use_text_extract: boolean;
|
|
2646
3063
|
selector?: string;
|
|
2647
3064
|
iframe?: boolean;
|
|
2648
3065
|
domSettleTimeoutsMS?: number;
|
|
@@ -2695,8 +3112,62 @@ declare class BrowserAgent {
|
|
|
2695
3112
|
private _callMcpTool;
|
|
2696
3113
|
}
|
|
2697
3114
|
|
|
3115
|
+
interface BrowserViewport {
|
|
3116
|
+
width: number;
|
|
3117
|
+
height: number;
|
|
3118
|
+
}
|
|
3119
|
+
interface BrowserScreen {
|
|
3120
|
+
width: number;
|
|
3121
|
+
height: number;
|
|
3122
|
+
}
|
|
3123
|
+
interface BrowserFingerprint {
|
|
3124
|
+
devices?: Array<'desktop' | 'mobile'>;
|
|
3125
|
+
operatingSystems?: Array<'windows' | 'macos' | 'linux' | 'android' | 'ios'>;
|
|
3126
|
+
locales?: string[];
|
|
3127
|
+
}
|
|
3128
|
+
interface BrowserProxy {
|
|
3129
|
+
type: 'custom' | 'wuying';
|
|
3130
|
+
server?: string;
|
|
3131
|
+
username?: string;
|
|
3132
|
+
password?: string;
|
|
3133
|
+
strategy?: 'restricted' | 'polling';
|
|
3134
|
+
pollsize?: number;
|
|
3135
|
+
toMap(): Record<string, any>;
|
|
3136
|
+
}
|
|
3137
|
+
declare class BrowserProxyClass implements BrowserProxy {
|
|
3138
|
+
type: 'custom' | 'wuying';
|
|
3139
|
+
server?: string;
|
|
3140
|
+
username?: string;
|
|
3141
|
+
password?: string;
|
|
3142
|
+
strategy?: 'restricted' | 'polling';
|
|
3143
|
+
pollsize?: number;
|
|
3144
|
+
constructor(proxyType: 'custom' | 'wuying', server?: string, username?: string, password?: string, strategy?: 'restricted' | 'polling', pollsize?: number);
|
|
3145
|
+
toMap(): Record<string, any>;
|
|
3146
|
+
static fromMap(m: Record<string, any> | null | undefined): BrowserProxyClass | null;
|
|
3147
|
+
}
|
|
2698
3148
|
interface BrowserOption {
|
|
2699
3149
|
persistentPath?: string;
|
|
3150
|
+
useStealth?: boolean;
|
|
3151
|
+
userAgent?: string;
|
|
3152
|
+
viewport?: BrowserViewport;
|
|
3153
|
+
screen?: BrowserScreen;
|
|
3154
|
+
fingerprint?: BrowserFingerprint;
|
|
3155
|
+
proxies?: BrowserProxy[];
|
|
3156
|
+
/** Path to the extensions directory. Defaults to "/tmp/extensions/" */
|
|
3157
|
+
extensionPath?: string;
|
|
3158
|
+
}
|
|
3159
|
+
declare class BrowserOptionClass implements BrowserOption {
|
|
3160
|
+
persistentPath?: string;
|
|
3161
|
+
useStealth?: boolean;
|
|
3162
|
+
userAgent?: string;
|
|
3163
|
+
viewport?: BrowserViewport;
|
|
3164
|
+
screen?: BrowserScreen;
|
|
3165
|
+
fingerprint?: BrowserFingerprint;
|
|
3166
|
+
proxies?: BrowserProxy[];
|
|
3167
|
+
extensionPath?: string;
|
|
3168
|
+
constructor(useStealth?: boolean, userAgent?: string, viewport?: BrowserViewport, screen?: BrowserScreen, fingerprint?: BrowserFingerprint, proxies?: BrowserProxy[]);
|
|
3169
|
+
toMap(): Record<string, any>;
|
|
3170
|
+
fromMap(m: Record<string, any> | null | undefined): BrowserOptionClass;
|
|
2700
3171
|
}
|
|
2701
3172
|
declare class Browser {
|
|
2702
3173
|
private session;
|
|
@@ -2709,12 +3180,12 @@ declare class Browser {
|
|
|
2709
3180
|
* Initialize the browser instance with the given options.
|
|
2710
3181
|
* Returns true if successful, false otherwise.
|
|
2711
3182
|
*/
|
|
2712
|
-
initialize(option: BrowserOption): boolean;
|
|
3183
|
+
initialize(option: BrowserOptionClass | BrowserOption): boolean;
|
|
2713
3184
|
/**
|
|
2714
3185
|
* Initialize the browser instance with the given options asynchronously.
|
|
2715
3186
|
* Returns true if successful, false otherwise.
|
|
2716
3187
|
*/
|
|
2717
|
-
initializeAsync(option: BrowserOption): Promise<boolean>;
|
|
3188
|
+
initializeAsync(option: BrowserOptionClass | BrowserOption): Promise<boolean>;
|
|
2718
3189
|
/**
|
|
2719
3190
|
* Returns the endpoint URL if the browser is initialized, otherwise throws an exception.
|
|
2720
3191
|
* When initialized, always fetches the latest CDP url from session.getLink().
|
|
@@ -2723,11 +3194,15 @@ declare class Browser {
|
|
|
2723
3194
|
/**
|
|
2724
3195
|
* Returns the current BrowserOption used to initialize the browser, or null if not set.
|
|
2725
3196
|
*/
|
|
2726
|
-
getOption():
|
|
3197
|
+
getOption(): BrowserOptionClass | null;
|
|
2727
3198
|
/**
|
|
2728
3199
|
* Returns true if the browser was initialized, false otherwise.
|
|
2729
3200
|
*/
|
|
2730
3201
|
isInitialized(): boolean;
|
|
3202
|
+
/**
|
|
3203
|
+
* Stop the browser instance, internal use only.
|
|
3204
|
+
*/
|
|
3205
|
+
private _stopBrowser;
|
|
2731
3206
|
}
|
|
2732
3207
|
|
|
2733
3208
|
/**
|
|
@@ -2752,7 +3227,6 @@ interface McpToolsResult extends OperationResult {
|
|
|
2752
3227
|
declare class Session {
|
|
2753
3228
|
private agentBay;
|
|
2754
3229
|
sessionId: string;
|
|
2755
|
-
resourceUrl: string;
|
|
2756
3230
|
isVpc: boolean;
|
|
2757
3231
|
networkInterfaceIp: string;
|
|
2758
3232
|
httpPort: string;
|
|
@@ -2874,30 +3348,344 @@ declare class Session {
|
|
|
2874
3348
|
}
|
|
2875
3349
|
|
|
2876
3350
|
/**
|
|
2877
|
-
*
|
|
3351
|
+
* Represents a browser extension as a cloud resource.
|
|
3352
|
+
*/
|
|
3353
|
+
declare class Extension {
|
|
3354
|
+
/**
|
|
3355
|
+
* The unique identifier of the extension.
|
|
3356
|
+
*/
|
|
3357
|
+
id: string;
|
|
3358
|
+
/**
|
|
3359
|
+
* The name of the extension.
|
|
3360
|
+
*/
|
|
3361
|
+
name: string;
|
|
3362
|
+
/**
|
|
3363
|
+
* Date and time when the extension was created.
|
|
3364
|
+
*/
|
|
3365
|
+
createdAt?: string;
|
|
3366
|
+
/**
|
|
3367
|
+
* Initialize an Extension object.
|
|
3368
|
+
*
|
|
3369
|
+
* @param id - The unique identifier of the extension.
|
|
3370
|
+
* @param name - The name of the extension.
|
|
3371
|
+
* @param createdAt - Date and time when the extension was created.
|
|
3372
|
+
*/
|
|
3373
|
+
constructor(id: string, name: string, createdAt?: string);
|
|
3374
|
+
}
|
|
3375
|
+
/**
|
|
3376
|
+
* Configuration options for browser extension integration.
|
|
3377
|
+
*
|
|
3378
|
+
* This class encapsulates the necessary parameters for setting up
|
|
3379
|
+
* browser extension synchronization and context management.
|
|
2878
3380
|
*/
|
|
2879
|
-
|
|
3381
|
+
declare class ExtensionOption {
|
|
3382
|
+
/**
|
|
3383
|
+
* ID of the extension context for browser extensions.
|
|
3384
|
+
*/
|
|
3385
|
+
contextId: string;
|
|
3386
|
+
/**
|
|
3387
|
+
* List of extension IDs to be loaded/synchronized.
|
|
3388
|
+
*/
|
|
3389
|
+
extensionIds: string[];
|
|
3390
|
+
/**
|
|
3391
|
+
* Initialize ExtensionOption with context and extension configuration.
|
|
3392
|
+
*
|
|
3393
|
+
* @param contextId - ID of the extension context for browser extensions.
|
|
3394
|
+
* This should match the context where extensions are stored.
|
|
3395
|
+
* @param extensionIds - List of extension IDs to be loaded in the browser session.
|
|
3396
|
+
* Each ID should correspond to a valid extension in the context.
|
|
3397
|
+
*
|
|
3398
|
+
* @throws {Error} If contextId is empty or extensionIds is empty.
|
|
3399
|
+
*/
|
|
3400
|
+
constructor(contextId: string, extensionIds: string[]);
|
|
3401
|
+
/**
|
|
3402
|
+
* String representation of ExtensionOption.
|
|
3403
|
+
*/
|
|
3404
|
+
toString(): string;
|
|
3405
|
+
/**
|
|
3406
|
+
* Human-readable string representation.
|
|
3407
|
+
*/
|
|
3408
|
+
toDisplayString(): string;
|
|
3409
|
+
/**
|
|
3410
|
+
* Validate the extension option configuration.
|
|
3411
|
+
*
|
|
3412
|
+
* @returns True if configuration is valid, false otherwise.
|
|
3413
|
+
*/
|
|
3414
|
+
validate(): boolean;
|
|
3415
|
+
}
|
|
3416
|
+
/**
|
|
3417
|
+
* Provides methods to manage user browser extensions.
|
|
3418
|
+
* This service integrates with the existing context functionality for file operations.
|
|
3419
|
+
*
|
|
3420
|
+
* **Usage** (Simplified - Auto-detection):
|
|
3421
|
+
* ```typescript
|
|
3422
|
+
* // Service automatically detects if context exists and creates if needed
|
|
3423
|
+
* const extensionsService = new ExtensionsService(agentBay, "browser_extensions");
|
|
3424
|
+
*
|
|
3425
|
+
* // Or use with empty contextId to auto-generate context name
|
|
3426
|
+
* const extensionsService = new ExtensionsService(agentBay); // Uses default generated name
|
|
3427
|
+
*
|
|
3428
|
+
* // Use the service immediately - initialization happens automatically
|
|
3429
|
+
* const extension = await extensionsService.create("/path/to/plugin.zip");
|
|
3430
|
+
* ```
|
|
3431
|
+
*
|
|
3432
|
+
* **Integration with ExtensionOption (Simplified)**:
|
|
3433
|
+
* ```typescript
|
|
3434
|
+
* // Create extensions and configure for browser sessions
|
|
3435
|
+
* const extensionsService = new ExtensionsService(agentBay, "my_extensions");
|
|
3436
|
+
* const ext1 = await extensionsService.create("/path/to/ext1.zip");
|
|
3437
|
+
* const ext2 = await extensionsService.create("/path/to/ext2.zip");
|
|
3438
|
+
*
|
|
3439
|
+
* // Create extension option for browser integration (no contextId needed!)
|
|
3440
|
+
* const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
|
|
3441
|
+
*
|
|
3442
|
+
* // Use with BrowserContext for session creation
|
|
3443
|
+
* const browserContext = new BrowserContext({
|
|
3444
|
+
* contextId: "browser_session",
|
|
3445
|
+
* autoUpload: true,
|
|
3446
|
+
* extensionOption: extOption // All extension config encapsulated
|
|
3447
|
+
* });
|
|
3448
|
+
* ```
|
|
3449
|
+
*
|
|
3450
|
+
* **Context Management**:
|
|
3451
|
+
* - If contextId provided and exists: Uses the existing context
|
|
3452
|
+
* - If contextId provided but doesn't exist: Creates context with provided name
|
|
3453
|
+
* - If contextId empty or not provided: Generates default name and creates context
|
|
3454
|
+
* - No need to manually manage context creation or call initialize()
|
|
3455
|
+
* - Context initialization happens automatically on first method call
|
|
3456
|
+
*/
|
|
3457
|
+
declare class ExtensionsService {
|
|
3458
|
+
private agentBay;
|
|
3459
|
+
private contextService;
|
|
3460
|
+
private extensionContext;
|
|
3461
|
+
private contextId;
|
|
3462
|
+
private contextName;
|
|
3463
|
+
private autoCreated;
|
|
3464
|
+
private _initializationPromise;
|
|
3465
|
+
/**
|
|
3466
|
+
* Initializes the ExtensionsService with a context.
|
|
3467
|
+
*
|
|
3468
|
+
* @param agentBay - The AgentBay client instance.
|
|
3469
|
+
* @param contextId - The context ID or name. If empty or not provided,
|
|
3470
|
+
* a default context name will be generated automatically.
|
|
3471
|
+
* If the context doesn't exist, it will be automatically created.
|
|
3472
|
+
*
|
|
3473
|
+
* Note:
|
|
3474
|
+
* The service automatically detects if the context exists. If not,
|
|
3475
|
+
* it creates a new context with the provided name or a generated default name.
|
|
3476
|
+
* Context initialization is handled lazily on first use.
|
|
3477
|
+
*/
|
|
3478
|
+
constructor(agentBay: AgentBay, contextId?: string);
|
|
3479
|
+
/**
|
|
3480
|
+
* Internal method to initialize the context.
|
|
3481
|
+
* This ensures the context is ready before any operations.
|
|
3482
|
+
*/
|
|
3483
|
+
private _initializeContext;
|
|
3484
|
+
/**
|
|
3485
|
+
* Ensures the service is initialized before performing operations.
|
|
3486
|
+
*/
|
|
3487
|
+
private _ensureInitialized;
|
|
3488
|
+
/**
|
|
3489
|
+
* An internal helper method that encapsulates the flow of "get upload URL for a specific path and upload".
|
|
3490
|
+
* Uses the existing context service for file operations.
|
|
3491
|
+
*
|
|
3492
|
+
* @param localPath - The path to the local file.
|
|
3493
|
+
* @param remotePath - The path of the file in context storage.
|
|
3494
|
+
*
|
|
3495
|
+
* @throws {AgentBayError} If getting the credential or uploading fails.
|
|
3496
|
+
*/
|
|
3497
|
+
private _uploadToCloud;
|
|
3498
|
+
/**
|
|
3499
|
+
* Lists all available browser extensions within this context from the cloud.
|
|
3500
|
+
* Uses the context service to list files under the extensions directory.
|
|
3501
|
+
*
|
|
3502
|
+
* @returns Promise that resolves to an array of Extension objects.
|
|
3503
|
+
* @throws {AgentBayError} If listing extensions fails.
|
|
3504
|
+
*/
|
|
3505
|
+
list(): Promise<Extension[]>;
|
|
3506
|
+
/**
|
|
3507
|
+
* Uploads a new browser extension from a local path into the current context.
|
|
3508
|
+
*
|
|
3509
|
+
* @param localPath - Path to the local extension file (must be a .zip file).
|
|
3510
|
+
* @returns Promise that resolves to an Extension object.
|
|
3511
|
+
* @throws {Error} If the local file doesn't exist.
|
|
3512
|
+
* @throws {Error} If the file format is not supported (only .zip is supported).
|
|
3513
|
+
* @throws {AgentBayError} If upload fails.
|
|
3514
|
+
*/
|
|
3515
|
+
create(localPath: string): Promise<Extension>;
|
|
3516
|
+
/**
|
|
3517
|
+
* Updates an existing browser extension in the current context with a new file.
|
|
3518
|
+
*
|
|
3519
|
+
* @param extensionId - ID of the extension to update.
|
|
3520
|
+
* @param newLocalPath - Path to the new local extension file.
|
|
3521
|
+
* @returns Promise that resolves to an Extension object.
|
|
3522
|
+
* @throws {Error} If the new local file doesn't exist.
|
|
3523
|
+
* @throws {Error} If the extension doesn't exist in the context.
|
|
3524
|
+
* @throws {AgentBayError} If update fails.
|
|
3525
|
+
*/
|
|
3526
|
+
update(extensionId: string, newLocalPath: string): Promise<Extension>;
|
|
3527
|
+
/**
|
|
3528
|
+
* Gets detailed information about a specific browser extension.
|
|
3529
|
+
*
|
|
3530
|
+
* @param extensionId - The ID of the extension to get info for.
|
|
3531
|
+
* @returns Promise that resolves to an Extension object if found, undefined otherwise.
|
|
3532
|
+
*/
|
|
3533
|
+
private _getExtensionInfo;
|
|
3534
|
+
/**
|
|
3535
|
+
* Cleans up the auto-created context if it was created by this service.
|
|
3536
|
+
*
|
|
3537
|
+
* @returns Promise that resolves to true if cleanup was successful or not needed, false if cleanup failed.
|
|
3538
|
+
*
|
|
3539
|
+
* Note:
|
|
3540
|
+
* This method only works if the context was auto-created by this service.
|
|
3541
|
+
* For existing contexts, no cleanup is performed.
|
|
3542
|
+
*/
|
|
3543
|
+
cleanup(): Promise<boolean>;
|
|
3544
|
+
/**
|
|
3545
|
+
* Deletes a browser extension from the current context.
|
|
3546
|
+
*
|
|
3547
|
+
* @param extensionId - ID of the extension to delete.
|
|
3548
|
+
* @returns Promise that resolves to true if deletion was successful, false otherwise.
|
|
3549
|
+
*/
|
|
3550
|
+
delete(extensionId: string): Promise<boolean>;
|
|
3551
|
+
/**
|
|
3552
|
+
* Create an ExtensionOption for the current context with specified extension IDs.
|
|
3553
|
+
*
|
|
3554
|
+
* This is a convenience method that creates an ExtensionOption using the current
|
|
3555
|
+
* service's contextId and the provided extension IDs. This option can then be
|
|
3556
|
+
* used with BrowserContext for browser session creation.
|
|
3557
|
+
*
|
|
3558
|
+
* @param extensionIds - List of extension IDs to include in the option.
|
|
3559
|
+
* These should be extensions that exist in the current context.
|
|
3560
|
+
* @returns ExtensionOption configuration object for browser extension integration.
|
|
3561
|
+
* @throws {Error} If extensionIds is empty or invalid.
|
|
3562
|
+
*
|
|
3563
|
+
* @example
|
|
3564
|
+
* ```typescript
|
|
3565
|
+
* // Create extensions
|
|
3566
|
+
* const ext1 = await extensionsService.create("/path/to/ext1.zip");
|
|
3567
|
+
* const ext2 = await extensionsService.create("/path/to/ext2.zip");
|
|
3568
|
+
*
|
|
3569
|
+
* // Create extension option for browser integration
|
|
3570
|
+
* const extOption = extensionsService.createExtensionOption([ext1.id, ext2.id]);
|
|
3571
|
+
*
|
|
3572
|
+
* // Use with BrowserContext
|
|
3573
|
+
* const browserContext = new BrowserContext({
|
|
3574
|
+
* contextId: "browser_session",
|
|
3575
|
+
* autoUpload: true,
|
|
3576
|
+
* extensionContextId: extOption.contextId,
|
|
3577
|
+
* extensionIds: extOption.extensionIds
|
|
3578
|
+
* });
|
|
3579
|
+
* ```
|
|
3580
|
+
*/
|
|
3581
|
+
createExtensionOption(extensionIds: string[]): ExtensionOption;
|
|
3582
|
+
}
|
|
3583
|
+
|
|
3584
|
+
/**
|
|
3585
|
+
* Browser context configuration for session with optional extension support.
|
|
3586
|
+
*
|
|
3587
|
+
* This class provides browser context configuration for cloud sessions and supports
|
|
3588
|
+
* automatic extension synchronization when ExtensionOption is provided.
|
|
3589
|
+
*
|
|
3590
|
+
* Key Features:
|
|
3591
|
+
* - Browser context binding for sessions
|
|
3592
|
+
* - Automatic browser data upload on session end
|
|
3593
|
+
* - Optional extension integration with automatic context sync generation
|
|
3594
|
+
* - Clean API with ExtensionOption encapsulation
|
|
3595
|
+
*
|
|
3596
|
+
* Extension Configuration:
|
|
3597
|
+
* - **ExtensionOption**: Pass an ExtensionOption object with contextId and extensionIds
|
|
3598
|
+
* - **No Extensions**: Don't provide extensionOption parameter (extensionContextSyncs will be undefined)
|
|
3599
|
+
*
|
|
3600
|
+
* Usage Examples:
|
|
3601
|
+
* ```typescript
|
|
3602
|
+
* // With extensions using ExtensionOption
|
|
3603
|
+
* import { ExtensionOption } from "./extension";
|
|
3604
|
+
*
|
|
3605
|
+
* const extOption = new ExtensionOption(
|
|
3606
|
+
* "my_extensions",
|
|
3607
|
+
* ["ext1", "ext2"]
|
|
3608
|
+
* );
|
|
3609
|
+
*
|
|
3610
|
+
* const browserContext = new BrowserContext(
|
|
3611
|
+
* "browser_session",
|
|
3612
|
+
* true,
|
|
3613
|
+
* extOption
|
|
3614
|
+
* );
|
|
3615
|
+
*
|
|
3616
|
+
* // Without extensions (minimal configuration)
|
|
3617
|
+
* const browserContext = new BrowserContext(
|
|
3618
|
+
* "browser_session",
|
|
3619
|
+
* true
|
|
3620
|
+
* );
|
|
3621
|
+
* // extensionContextSyncs will be undefined
|
|
3622
|
+
* ```
|
|
3623
|
+
*/
|
|
3624
|
+
declare class BrowserContext {
|
|
2880
3625
|
/** ID of the browser context to bind to the session */
|
|
2881
3626
|
contextId: string;
|
|
2882
3627
|
/** Whether to automatically upload browser data when the session ends */
|
|
2883
3628
|
autoUpload: boolean;
|
|
3629
|
+
/** Optional extension configuration object containing context_id and extension_ids */
|
|
3630
|
+
extensionOption?: ExtensionOption;
|
|
3631
|
+
/** ID of the extension context for browser extensions. Set automatically from extension_option. */
|
|
3632
|
+
extensionContextId?: string;
|
|
3633
|
+
/** List of extension IDs to synchronize. Set automatically from extension_option. */
|
|
3634
|
+
extensionIds?: string[];
|
|
3635
|
+
/** Auto-generated context syncs for extensions. None if no extension configuration provided. */
|
|
3636
|
+
extensionContextSyncs?: ContextSync[];
|
|
3637
|
+
/**
|
|
3638
|
+
* Initialize BrowserContextImpl with optional extension support.
|
|
3639
|
+
*
|
|
3640
|
+
* @param contextId - ID of the browser context to bind to the session.
|
|
3641
|
+
* This identifies the browser instance for the session.
|
|
3642
|
+
* @param autoUpload - Whether to automatically upload browser data
|
|
3643
|
+
* when the session ends. Defaults to true.
|
|
3644
|
+
* @param extensionOption - Extension configuration object containing
|
|
3645
|
+
* contextId and extensionIds. This encapsulates
|
|
3646
|
+
* all extension-related configuration.
|
|
3647
|
+
* Defaults to undefined.
|
|
3648
|
+
*
|
|
3649
|
+
* Extension Configuration:
|
|
3650
|
+
* - **ExtensionOption**: Use extensionOption parameter with an ExtensionOption object
|
|
3651
|
+
* - **No Extensions**: Don't provide extensionOption parameter
|
|
3652
|
+
*
|
|
3653
|
+
* Auto-generation:
|
|
3654
|
+
* - extensionContextSyncs is automatically generated when extensionOption is provided
|
|
3655
|
+
* - extensionContextSyncs will be undefined if no extensionOption is provided
|
|
3656
|
+
* - extensionContextSyncs will be a ContextSync[] if extensionOption is valid
|
|
3657
|
+
*/
|
|
3658
|
+
constructor(contextId: string, autoUpload?: boolean, extensionOption?: ExtensionOption);
|
|
3659
|
+
/**
|
|
3660
|
+
* Create ContextSync configurations for browser extensions.
|
|
3661
|
+
*
|
|
3662
|
+
* This method is called only when extensionOption is provided and contains
|
|
3663
|
+
* valid extension configuration (contextId and extensionIds).
|
|
3664
|
+
*
|
|
3665
|
+
* @returns ContextSync[] - List of context sync configurations for extensions.
|
|
3666
|
+
* Returns empty list if extension configuration is invalid.
|
|
3667
|
+
*/
|
|
3668
|
+
private _createExtensionContextSyncs;
|
|
3669
|
+
/**
|
|
3670
|
+
* Get all context syncs including extension syncs.
|
|
3671
|
+
*
|
|
3672
|
+
* @returns ContextSync[] - All context sync configurations. Returns empty list if no extensions configured.
|
|
3673
|
+
*/
|
|
3674
|
+
getAllContextSyncs(): ContextSync[];
|
|
2884
3675
|
}
|
|
2885
3676
|
/**
|
|
2886
3677
|
* Configuration interface for CreateSessionParams
|
|
2887
3678
|
*/
|
|
2888
3679
|
interface CreateSessionParamsConfig {
|
|
2889
3680
|
labels: Record<string, string>;
|
|
2890
|
-
/**
|
|
2891
|
-
* @deprecated This field is deprecated and will be removed in a future version.
|
|
2892
|
-
* Please use contextSync instead for more flexible and powerful data persistence.
|
|
2893
|
-
*/
|
|
2894
|
-
contextId?: string;
|
|
2895
3681
|
imageId?: string;
|
|
2896
3682
|
contextSync: ContextSync[];
|
|
2897
3683
|
/** Optional configuration for browser data synchronization */
|
|
2898
3684
|
browserContext?: BrowserContext;
|
|
2899
3685
|
/** Whether to create a VPC-based session. Defaults to false. */
|
|
2900
3686
|
isVpc?: boolean;
|
|
3687
|
+
/** MCP policy id to apply when creating the session. */
|
|
3688
|
+
mcpPolicyId?: string;
|
|
2901
3689
|
}
|
|
2902
3690
|
/**
|
|
2903
3691
|
* CreateSessionParams provides a way to configure the parameters for creating a new session
|
|
@@ -2906,25 +3694,6 @@ interface CreateSessionParamsConfig {
|
|
|
2906
3694
|
declare class CreateSessionParams$1 implements CreateSessionParamsConfig {
|
|
2907
3695
|
/** Custom labels for the Session. These can be used for organizing and filtering sessions. */
|
|
2908
3696
|
labels: Record<string, string>;
|
|
2909
|
-
/**
|
|
2910
|
-
* ID of the context to bind to the session.
|
|
2911
|
-
* The context can include various types of persistence like file system (volume) and cookies.
|
|
2912
|
-
*
|
|
2913
|
-
* @deprecated This field is deprecated and will be removed in a future version.
|
|
2914
|
-
* Please use contextSync instead for more flexible and powerful data persistence.
|
|
2915
|
-
*
|
|
2916
|
-
* Important Limitations:
|
|
2917
|
-
* 1. One session at a time: A context can only be used by one session at a time.
|
|
2918
|
-
* If you try to create a session with a context ID that is already in use by another active session,
|
|
2919
|
-
* the session creation will fail.
|
|
2920
|
-
*
|
|
2921
|
-
* 2. OS binding: A context is bound to the operating system of the first session that uses it.
|
|
2922
|
-
* When a context is first used with a session, it becomes bound to that session's OS.
|
|
2923
|
-
* Any attempt to use the context with a session running on a different OS will fail.
|
|
2924
|
-
* For example, if a context is first used with a Linux session, it cannot later be used
|
|
2925
|
-
* with a Windows or Android session.
|
|
2926
|
-
*/
|
|
2927
|
-
contextId?: string;
|
|
2928
3697
|
/** Image ID to use for the session. */
|
|
2929
3698
|
imageId?: string;
|
|
2930
3699
|
/**
|
|
@@ -2936,15 +3705,13 @@ declare class CreateSessionParams$1 implements CreateSessionParamsConfig {
|
|
|
2936
3705
|
browserContext?: BrowserContext;
|
|
2937
3706
|
/** Whether to create a VPC-based session. Defaults to false. */
|
|
2938
3707
|
isVpc: boolean;
|
|
3708
|
+
/** MCP policy id to apply when creating the session. */
|
|
3709
|
+
mcpPolicyId?: string;
|
|
2939
3710
|
constructor();
|
|
2940
3711
|
/**
|
|
2941
3712
|
* WithLabels sets the labels for the session parameters and returns the updated parameters.
|
|
2942
3713
|
*/
|
|
2943
3714
|
withLabels(labels: Record<string, string>): CreateSessionParams$1;
|
|
2944
|
-
/**
|
|
2945
|
-
* WithContextID sets the context ID for the session parameters and returns the updated parameters.
|
|
2946
|
-
*/
|
|
2947
|
-
withContextID(contextId: string): CreateSessionParams$1;
|
|
2948
3715
|
/**
|
|
2949
3716
|
* WithImageId sets the image ID for the session parameters and returns the updated parameters.
|
|
2950
3717
|
*/
|
|
@@ -2957,6 +3724,10 @@ declare class CreateSessionParams$1 implements CreateSessionParamsConfig {
|
|
|
2957
3724
|
* WithIsVpc sets the VPC flag for the session parameters and returns the updated parameters.
|
|
2958
3725
|
*/
|
|
2959
3726
|
withIsVpc(isVpc: boolean): CreateSessionParams$1;
|
|
3727
|
+
/**
|
|
3728
|
+
* WithMcpPolicyId sets the MCP policy id for the session parameters and returns the updated parameters.
|
|
3729
|
+
*/
|
|
3730
|
+
withMcpPolicyId(mcpPolicyId: string): CreateSessionParams$1;
|
|
2960
3731
|
/**
|
|
2961
3732
|
* GetLabelsJSON returns the labels as a JSON string.
|
|
2962
3733
|
* Returns an object with success status and result/error message to match Go version behavior.
|
|
@@ -3021,12 +3792,12 @@ interface SessionListResult extends ApiResponse {
|
|
|
3021
3792
|
* Parameters for creating a session.
|
|
3022
3793
|
*/
|
|
3023
3794
|
interface CreateSessionParams {
|
|
3024
|
-
contextId?: string;
|
|
3025
3795
|
labels?: Record<string, string>;
|
|
3026
3796
|
imageId?: string;
|
|
3027
3797
|
contextSync?: ContextSync[];
|
|
3028
3798
|
browserContext?: BrowserContext;
|
|
3029
3799
|
isVpc?: boolean;
|
|
3800
|
+
mcpPolicyId?: string;
|
|
3030
3801
|
}
|
|
3031
3802
|
/**
|
|
3032
3803
|
* Main class for interacting with the AgentBay cloud runtime environment.
|
|
@@ -3171,4 +3942,4 @@ declare function log(message: string, ...args: any[]): void;
|
|
|
3171
3942
|
*/
|
|
3172
3943
|
declare function logError(message: string, error?: any): void;
|
|
3173
3944
|
|
|
3174
|
-
export { APIError, type ActOptions, ActResult, Agent, AgentBay, AgentBayError, Application, ApplicationError, ApplyMqttTokenRequest, ApplyMqttTokenResponse, ApplyMqttTokenResponseBody, ApplyMqttTokenResponseBodyData, AuthenticationError, type BWList, Browser, BrowserAgent,
|
|
3945
|
+
export { APIError, type ActOptions, ActResult, Agent, AgentBay, AgentBayError, Application, ApplicationError, ApplyMqttTokenRequest, ApplyMqttTokenResponse, ApplyMqttTokenResponseBody, ApplyMqttTokenResponseBodyData, AuthenticationError, type BWList, Browser, BrowserAgent, BrowserContext, BrowserError, type BrowserFingerprint, type BrowserOption, BrowserOptionClass, type BrowserProxy, BrowserProxyClass, type BrowserScreen, type BrowserViewport, CallMcpToolRequest, CallMcpToolResponse, CallMcpToolResponseBody, Client, Command, CommandError, type Config, Context, type ContextInfoResult, ContextManager, ContextService, type ContextStatusData, type ContextStatusItem, ContextSync, type ContextSyncResult, CreateMcpSessionRequest, CreateMcpSessionRequestPersistenceDataList, CreateMcpSessionResponse, CreateMcpSessionResponseBody, CreateMcpSessionResponseBodyData, CreateMcpSessionShrinkRequest, type CreateSessionParams, type CreateSessionParamsConfig, DeleteContextFileRequest, DeleteContextFileResponse, DeleteContextFileResponseBody, DeleteContextRequest, DeleteContextResponse, DeleteContextResponseBody, type DeletePolicy, DescribeContextFilesRequest, DescribeContextFilesResponse, DescribeContextFilesResponseBody, type DirectoryEntry, type DownloadPolicy, DownloadStrategy, type ExecutionResult, Extension, ExtensionOption, ExtensionsService, type ExtractOptions, type ExtractPolicy, ExtractPolicyClass, FileError, type FileInfo, FileSystem, GetContextFileDownloadUrlRequest, GetContextFileDownloadUrlResponse, GetContextFileDownloadUrlResponseBody, GetContextFileUploadUrlRequest, GetContextFileUploadUrlResponse, GetContextFileUploadUrlResponseBody, GetContextInfoRequest, GetContextInfoResponse, GetContextInfoResponseBody, GetContextInfoResponseBodyData, GetContextRequest, GetContextResponse, GetContextResponseBody, GetContextResponseBodyData, GetLabelRequest, GetLabelResponse, GetLabelResponseBody, GetLabelResponseBodyData, GetLinkRequest, GetLinkResponse, GetLinkResponseBody, GetLinkResponseBodyData, GetMcpResourceRequest, GetMcpResourceResponse, GetMcpResourceResponseBody, GetMcpResourceResponseBodyData, GetMcpResourceResponseBodyDataDesktopInfo, InitBrowserRequest, InitBrowserResponse, InitBrowserResponseBody, InitBrowserResponseBodyData, type InstalledApp, KeyCode, ListContextsRequest, ListContextsResponse, ListContextsResponseBody, ListContextsResponseBodyData, ListMcpToolsRequest, ListMcpToolsResponse, ListMcpToolsResponseBody, type ListSessionParams, ListSessionRequest, ListSessionResponse, ListSessionResponseBody, ListSessionResponseBodyData, type McpSession, type McpToolResult, ModifyContextRequest, ModifyContextResponse, ModifyContextResponseBody, type ObserveOptions, ObserveResult, Oss, OssError, type Process, type QueryResult, ReleaseMcpSessionRequest, ReleaseMcpSessionResponse, ReleaseMcpSessionResponseBody, Session, SessionError, type SessionInterface, SetLabelRequest, SetLabelResponse, SetLabelResponseBody, SyncContextRequest, SyncContextResponse, SyncContextResponseBody, type SyncPolicy, SyncPolicyImpl, UI, type UIElement, UIError, type UploadPolicy, UploadStrategy, type WhiteList, loadConfig, loadDotEnv, log, logError, newContextManager, newContextSync, newCreateSessionParams, newDeletePolicy, newDownloadPolicy, newExtractPolicy, newSyncPolicy, newSyncPolicyWithDefaults, newUploadPolicy };
|