@skyvern/client 1.0.3 → 1.0.10
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 +45 -0
- package/dist/cjs/Client.d.ts +17 -1
- package/dist/cjs/Client.js +80 -6
- package/dist/cjs/api/client/requests/BodyUploadFileV1UploadFilePost.d.ts +10 -0
- package/dist/cjs/api/client/requests/BodyUploadFileV1UploadFilePost.js +3 -0
- package/dist/cjs/api/client/requests/GetWorkflowsRequest.d.ts +2 -0
- package/dist/cjs/api/client/requests/index.d.ts +1 -0
- package/dist/cjs/api/types/Action.d.ts +1 -0
- package/dist/cjs/api/types/Artifact.d.ts +1 -0
- package/dist/cjs/api/types/PromptAction.d.ts +1 -1
- package/dist/cjs/api/types/RetryRunWebhookRequest.d.ts +4 -0
- package/dist/cjs/api/types/RetryRunWebhookRequest.js +3 -0
- package/dist/cjs/api/types/UploadFileResponse.d.ts +6 -0
- package/dist/cjs/api/types/UploadFileResponse.js +3 -0
- package/dist/cjs/api/types/Workflow.d.ts +1 -0
- package/dist/cjs/api/types/index.d.ts +2 -0
- package/dist/cjs/api/types/index.js +2 -0
- package/dist/cjs/core/exports.d.ts +1 -0
- package/dist/cjs/core/exports.js +17 -0
- package/dist/cjs/core/file/exports.d.ts +1 -0
- package/dist/cjs/core/file/exports.js +2 -0
- package/dist/cjs/core/file/file.d.ts +10 -0
- package/dist/cjs/core/file/file.js +221 -0
- package/dist/cjs/core/file/index.d.ts +2 -0
- package/dist/cjs/core/file/index.js +18 -0
- package/dist/cjs/core/file/types.d.ts +66 -0
- package/dist/cjs/core/file/types.js +2 -0
- package/dist/cjs/core/form-data-utils/FormDataWrapper.d.ts +15 -0
- package/dist/cjs/core/form-data-utils/FormDataWrapper.js +185 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.d.ts +1 -0
- package/dist/cjs/core/form-data-utils/encodeAsFormParameter.js +12 -0
- package/dist/cjs/core/form-data-utils/index.d.ts +2 -0
- package/dist/cjs/core/form-data-utils/index.js +20 -0
- package/dist/cjs/core/index.d.ts +2 -0
- package/dist/cjs/core/index.js +3 -1
- package/dist/cjs/exports.d.ts +1 -0
- package/dist/cjs/exports.js +17 -0
- package/dist/cjs/index.d.ts +1 -0
- package/dist/cjs/index.js +4 -0
- package/dist/cjs/library/Skyvern.js +26 -7
- package/dist/cjs/library/SkyvernBrowserPage.d.ts +85 -2
- package/dist/cjs/library/SkyvernBrowserPage.js +131 -18
- package/dist/cjs/library/SkyvernBrowserPageAgent.d.ts +68 -20
- package/dist/cjs/library/SkyvernBrowserPageAgent.js +20 -33
- package/dist/cjs/version.d.ts +1 -1
- package/dist/cjs/version.js +1 -1
- package/dist/esm/Client.d.mts +17 -1
- package/dist/esm/Client.mjs +80 -6
- package/dist/esm/api/client/requests/BodyUploadFileV1UploadFilePost.d.mts +10 -0
- package/dist/esm/api/client/requests/BodyUploadFileV1UploadFilePost.mjs +2 -0
- package/dist/esm/api/client/requests/GetWorkflowsRequest.d.mts +2 -0
- package/dist/esm/api/client/requests/index.d.mts +1 -0
- package/dist/esm/api/types/Action.d.mts +1 -0
- package/dist/esm/api/types/Artifact.d.mts +1 -0
- package/dist/esm/api/types/PromptAction.d.mts +1 -1
- package/dist/esm/api/types/RetryRunWebhookRequest.d.mts +4 -0
- package/dist/esm/api/types/RetryRunWebhookRequest.mjs +2 -0
- package/dist/esm/api/types/UploadFileResponse.d.mts +6 -0
- package/dist/esm/api/types/UploadFileResponse.mjs +2 -0
- package/dist/esm/api/types/Workflow.d.mts +1 -0
- package/dist/esm/api/types/index.d.mts +2 -0
- package/dist/esm/api/types/index.mjs +2 -0
- package/dist/esm/core/exports.d.mts +1 -0
- package/dist/esm/core/exports.mjs +1 -0
- package/dist/esm/core/file/exports.d.mts +1 -0
- package/dist/esm/core/file/exports.mjs +1 -0
- package/dist/esm/core/file/file.d.mts +10 -0
- package/dist/esm/core/file/file.mjs +184 -0
- package/dist/esm/core/file/index.d.mts +2 -0
- package/dist/esm/core/file/index.mjs +2 -0
- package/dist/esm/core/file/types.d.mts +66 -0
- package/dist/esm/core/file/types.mjs +1 -0
- package/dist/esm/core/form-data-utils/FormDataWrapper.d.mts +15 -0
- package/dist/esm/core/form-data-utils/FormDataWrapper.mjs +147 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.d.mts +1 -0
- package/dist/esm/core/form-data-utils/encodeAsFormParameter.mjs +9 -0
- package/dist/esm/core/form-data-utils/index.d.mts +2 -0
- package/dist/esm/core/form-data-utils/index.mjs +2 -0
- package/dist/esm/core/index.d.mts +2 -0
- package/dist/esm/core/index.mjs +2 -0
- package/dist/esm/exports.d.mts +1 -0
- package/dist/esm/exports.mjs +1 -0
- package/dist/esm/index.d.mts +1 -0
- package/dist/esm/index.mjs +1 -0
- package/dist/esm/library/Skyvern.mjs +26 -7
- package/dist/esm/library/SkyvernBrowserPage.d.mts +85 -2
- package/dist/esm/library/SkyvernBrowserPage.mjs +131 -18
- package/dist/esm/library/SkyvernBrowserPageAgent.d.mts +68 -20
- package/dist/esm/library/SkyvernBrowserPageAgent.mjs +20 -33
- package/dist/esm/version.d.mts +1 -1
- package/dist/esm/version.mjs +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./file.js"), exports);
|
|
18
|
+
__exportStar(require("./types.js"), exports);
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A file that can be uploaded. Can be a file-like object (stream, buffer, blob, etc.),
|
|
3
|
+
* a path to a file, or an object with a file-like object and metadata.
|
|
4
|
+
*/
|
|
5
|
+
export type Uploadable = Uploadable.FileLike | Uploadable.FromPath | Uploadable.WithMetadata;
|
|
6
|
+
export declare namespace Uploadable {
|
|
7
|
+
/**
|
|
8
|
+
* Various file-like objects that can be used to upload a file.
|
|
9
|
+
*/
|
|
10
|
+
type FileLike = ArrayBuffer | ArrayBufferLike | ArrayBufferView | Uint8Array | import("buffer").Buffer | import("buffer").Blob | import("buffer").File | import("stream").Readable | import("stream/web").ReadableStream | globalThis.Blob | globalThis.File | ReadableStream;
|
|
11
|
+
/**
|
|
12
|
+
* A file path with optional metadata, used for uploading a file from the file system.
|
|
13
|
+
*/
|
|
14
|
+
type FromPath = {
|
|
15
|
+
/** The path to the file to upload */
|
|
16
|
+
path: string;
|
|
17
|
+
/**
|
|
18
|
+
* Optional override for the file name (defaults to basename of path).
|
|
19
|
+
* This is used to set the `Content-Disposition` header in upload requests.
|
|
20
|
+
*/
|
|
21
|
+
filename?: string;
|
|
22
|
+
/**
|
|
23
|
+
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
24
|
+
* This is used to set the `Content-Type` header in upload requests.
|
|
25
|
+
*/
|
|
26
|
+
contentType?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Optional file size in bytes.
|
|
29
|
+
* If not provided, the file size will be determined from the file system.
|
|
30
|
+
* The content length is used to set the `Content-Length` header in upload requests.
|
|
31
|
+
*/
|
|
32
|
+
contentLength?: number;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* A file-like object with metadata, used for uploading files.
|
|
36
|
+
*/
|
|
37
|
+
type WithMetadata = {
|
|
38
|
+
/** The file data */
|
|
39
|
+
data: FileLike;
|
|
40
|
+
/**
|
|
41
|
+
* Optional override for the file name (defaults to basename of path).
|
|
42
|
+
* This is used to set the `Content-Disposition` header in upload requests.
|
|
43
|
+
*/
|
|
44
|
+
filename?: string;
|
|
45
|
+
/**
|
|
46
|
+
* Optional MIME type of the file (e.g., 'image/jpeg', 'text/plain').
|
|
47
|
+
* This is used to set the `Content-Type` header in upload requests.
|
|
48
|
+
*
|
|
49
|
+
* If not provided, the content type may be determined from the data itself.
|
|
50
|
+
* * If the data is a `File`, `Blob`, or similar, the content type will be determined from the file itself, if the type is set.
|
|
51
|
+
* * Any other data type will not have a content type set, and the upload request will use `Content-Type: application/octet-stream` instead.
|
|
52
|
+
*/
|
|
53
|
+
contentType?: string;
|
|
54
|
+
/**
|
|
55
|
+
* Optional file size in bytes.
|
|
56
|
+
* The content length is used to set the `Content-Length` header in upload requests.
|
|
57
|
+
* If the content length is not provided and cannot be determined, the upload request will not include the `Content-Length` header, but will use `Transfer-Encoding: chunked` instead.
|
|
58
|
+
*
|
|
59
|
+
* If not provided, the file size will be determined depending on the data type.
|
|
60
|
+
* * If the data is of type `fs.ReadStream` (`createReadStream`), the size will be determined from the file system.
|
|
61
|
+
* * If the data is a `Buffer`, `ArrayBuffer`, `Uint8Array`, `Blob`, `File`, or similar, the size will be determined from the data itself.
|
|
62
|
+
* * If the data is a `Readable` or `ReadableStream`, the size will not be determined.
|
|
63
|
+
*/
|
|
64
|
+
contentLength?: number;
|
|
65
|
+
};
|
|
66
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { type Uploadable } from "../../core/file/index.js";
|
|
2
|
+
interface FormDataRequest<Body> {
|
|
3
|
+
body: Body;
|
|
4
|
+
headers: Record<string, string>;
|
|
5
|
+
duplex?: "half";
|
|
6
|
+
}
|
|
7
|
+
export declare function newFormData(): Promise<FormDataWrapper>;
|
|
8
|
+
export declare class FormDataWrapper {
|
|
9
|
+
private fd;
|
|
10
|
+
setup(): Promise<void>;
|
|
11
|
+
append(key: string, value: unknown): void;
|
|
12
|
+
appendFile(key: string, value: Uploadable): Promise<void>;
|
|
13
|
+
getRequest(): FormDataRequest<FormData>;
|
|
14
|
+
}
|
|
15
|
+
export {};
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
36
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
37
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
38
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
39
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
40
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
41
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
var __asyncValues = (this && this.__asyncValues) || function (o) {
|
|
45
|
+
if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
|
|
46
|
+
var m = o[Symbol.asyncIterator], i;
|
|
47
|
+
return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
|
|
48
|
+
function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
|
|
49
|
+
function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
|
|
50
|
+
};
|
|
51
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
52
|
+
exports.FormDataWrapper = void 0;
|
|
53
|
+
exports.newFormData = newFormData;
|
|
54
|
+
const index_js_1 = require("../../core/file/index.js");
|
|
55
|
+
const json_js_1 = require("../../core/json.js");
|
|
56
|
+
const index_js_2 = require("../runtime/index.js");
|
|
57
|
+
function newFormData() {
|
|
58
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
59
|
+
return new FormDataWrapper();
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
class FormDataWrapper {
|
|
63
|
+
constructor() {
|
|
64
|
+
this.fd = new FormData();
|
|
65
|
+
}
|
|
66
|
+
setup() {
|
|
67
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
68
|
+
// noop
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
append(key, value) {
|
|
72
|
+
this.fd.append(key, String(value));
|
|
73
|
+
}
|
|
74
|
+
appendFile(key, value) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
76
|
+
const { data, filename, contentType } = yield (0, index_js_1.toMultipartDataPart)(value);
|
|
77
|
+
const blob = yield convertToBlob(data, contentType);
|
|
78
|
+
if (filename) {
|
|
79
|
+
this.fd.append(key, blob, filename);
|
|
80
|
+
}
|
|
81
|
+
else {
|
|
82
|
+
this.fd.append(key, blob);
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
getRequest() {
|
|
87
|
+
return {
|
|
88
|
+
body: this.fd,
|
|
89
|
+
headers: {},
|
|
90
|
+
duplex: "half",
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
exports.FormDataWrapper = FormDataWrapper;
|
|
95
|
+
function isStreamLike(value) {
|
|
96
|
+
return typeof value === "object" && value != null && ("read" in value || "pipe" in value);
|
|
97
|
+
}
|
|
98
|
+
function isReadableStream(value) {
|
|
99
|
+
return typeof value === "object" && value != null && "getReader" in value;
|
|
100
|
+
}
|
|
101
|
+
function isBuffer(value) {
|
|
102
|
+
return typeof Buffer !== "undefined" && Buffer.isBuffer && Buffer.isBuffer(value);
|
|
103
|
+
}
|
|
104
|
+
function isArrayBufferView(value) {
|
|
105
|
+
return ArrayBuffer.isView(value);
|
|
106
|
+
}
|
|
107
|
+
function streamToBuffer(stream) {
|
|
108
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
109
|
+
var _a, stream_1, stream_1_1;
|
|
110
|
+
var _b, e_1, _c, _d;
|
|
111
|
+
if (index_js_2.RUNTIME.type === "node") {
|
|
112
|
+
const { Readable } = yield Promise.resolve().then(() => __importStar(require("stream")));
|
|
113
|
+
if (stream instanceof Readable) {
|
|
114
|
+
const chunks = [];
|
|
115
|
+
try {
|
|
116
|
+
for (_a = true, stream_1 = __asyncValues(stream); stream_1_1 = yield stream_1.next(), _b = stream_1_1.done, !_b; _a = true) {
|
|
117
|
+
_d = stream_1_1.value;
|
|
118
|
+
_a = false;
|
|
119
|
+
const chunk = _d;
|
|
120
|
+
chunks.push(Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
124
|
+
finally {
|
|
125
|
+
try {
|
|
126
|
+
if (!_a && !_b && (_c = stream_1.return)) yield _c.call(stream_1);
|
|
127
|
+
}
|
|
128
|
+
finally { if (e_1) throw e_1.error; }
|
|
129
|
+
}
|
|
130
|
+
return Buffer.concat(chunks);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
if (isReadableStream(stream)) {
|
|
134
|
+
const reader = stream.getReader();
|
|
135
|
+
const chunks = [];
|
|
136
|
+
try {
|
|
137
|
+
while (true) {
|
|
138
|
+
const { done, value } = yield reader.read();
|
|
139
|
+
if (done)
|
|
140
|
+
break;
|
|
141
|
+
chunks.push(value);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
finally {
|
|
145
|
+
reader.releaseLock();
|
|
146
|
+
}
|
|
147
|
+
const totalLength = chunks.reduce((sum, chunk) => sum + chunk.length, 0);
|
|
148
|
+
const result = new Uint8Array(totalLength);
|
|
149
|
+
let offset = 0;
|
|
150
|
+
for (const chunk of chunks) {
|
|
151
|
+
result.set(chunk, offset);
|
|
152
|
+
offset += chunk.length;
|
|
153
|
+
}
|
|
154
|
+
return Buffer.from(result);
|
|
155
|
+
}
|
|
156
|
+
throw new Error(`Unsupported stream type: ${typeof stream}. Expected Node.js Readable stream or Web ReadableStream.`);
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
function convertToBlob(value, contentType) {
|
|
160
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
161
|
+
if (isStreamLike(value) || isReadableStream(value)) {
|
|
162
|
+
const buffer = yield streamToBuffer(value);
|
|
163
|
+
return new Blob([buffer], { type: contentType });
|
|
164
|
+
}
|
|
165
|
+
if (value instanceof Blob) {
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
if (isBuffer(value)) {
|
|
169
|
+
return new Blob([value], { type: contentType });
|
|
170
|
+
}
|
|
171
|
+
if (value instanceof ArrayBuffer) {
|
|
172
|
+
return new Blob([value], { type: contentType });
|
|
173
|
+
}
|
|
174
|
+
if (isArrayBufferView(value)) {
|
|
175
|
+
return new Blob([value], { type: contentType });
|
|
176
|
+
}
|
|
177
|
+
if (typeof value === "string") {
|
|
178
|
+
return new Blob([value], { type: contentType });
|
|
179
|
+
}
|
|
180
|
+
if (typeof value === "object" && value !== null) {
|
|
181
|
+
return new Blob([(0, json_js_1.toJson)(value)], { type: contentType !== null && contentType !== void 0 ? contentType : "application/json" });
|
|
182
|
+
}
|
|
183
|
+
return new Blob([String(value)], { type: contentType });
|
|
184
|
+
});
|
|
185
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function encodeAsFormParameter(value: unknown): Record<string, string>;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.encodeAsFormParameter = encodeAsFormParameter;
|
|
4
|
+
const qs_js_1 = require("../url/qs.js");
|
|
5
|
+
function encodeAsFormParameter(value) {
|
|
6
|
+
const stringified = (0, qs_js_1.toQueryString)(value, { encode: false });
|
|
7
|
+
const keyValuePairs = stringified.split("&").map((pair) => {
|
|
8
|
+
const [key, value] = pair.split("=");
|
|
9
|
+
return [key, value];
|
|
10
|
+
});
|
|
11
|
+
return Object.fromEntries(keyValuePairs);
|
|
12
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.encodeAsFormParameter = void 0;
|
|
18
|
+
var encodeAsFormParameter_js_1 = require("./encodeAsFormParameter.js");
|
|
19
|
+
Object.defineProperty(exports, "encodeAsFormParameter", { enumerable: true, get: function () { return encodeAsFormParameter_js_1.encodeAsFormParameter; } });
|
|
20
|
+
__exportStar(require("./FormDataWrapper.js"), exports);
|
package/dist/cjs/core/index.d.ts
CHANGED
package/dist/cjs/core/index.js
CHANGED
|
@@ -36,7 +36,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
36
36
|
};
|
|
37
37
|
})();
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.url = void 0;
|
|
39
|
+
exports.url = exports.file = void 0;
|
|
40
40
|
__exportStar(require("./fetcher/index.js"), exports);
|
|
41
|
+
exports.file = __importStar(require("./file/index.js"));
|
|
42
|
+
__exportStar(require("./form-data-utils/index.js"), exports);
|
|
41
43
|
__exportStar(require("./runtime/index.js"), exports);
|
|
42
44
|
exports.url = __importStar(require("./url/index.js"));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./core/exports.js";
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./core/exports.js"), exports);
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -3,5 +3,6 @@ export type { BaseClientOptions, BaseRequestOptions } from "./BaseClient.js";
|
|
|
3
3
|
export { SkyvernClient } from "./Client.js";
|
|
4
4
|
export { SkyvernEnvironment } from "./environments.js";
|
|
5
5
|
export { SkyvernError, SkyvernTimeoutError } from "./errors/index.js";
|
|
6
|
+
export * from "./exports.js";
|
|
6
7
|
export { Skyvern, SkyvernBrowser, SkyvernBrowserPageAgent, SkyvernBrowserPageAi } from "./library/index.js";
|
|
7
8
|
export type { SkyvernOptions, SkyvernBrowserPage } from "./library/index.js";
|
package/dist/cjs/index.js
CHANGED
|
@@ -32,6 +32,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
32
32
|
return result;
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
36
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
37
|
+
};
|
|
35
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
39
|
exports.SkyvernBrowserPageAi = exports.SkyvernBrowserPageAgent = exports.SkyvernBrowser = exports.Skyvern = exports.SkyvernTimeoutError = exports.SkyvernError = exports.SkyvernEnvironment = exports.SkyvernClient = exports.SkyvernApi = void 0;
|
|
37
40
|
exports.SkyvernApi = __importStar(require("./api/index.js"));
|
|
@@ -42,6 +45,7 @@ Object.defineProperty(exports, "SkyvernEnvironment", { enumerable: true, get: fu
|
|
|
42
45
|
var index_js_1 = require("./errors/index.js");
|
|
43
46
|
Object.defineProperty(exports, "SkyvernError", { enumerable: true, get: function () { return index_js_1.SkyvernError; } });
|
|
44
47
|
Object.defineProperty(exports, "SkyvernTimeoutError", { enumerable: true, get: function () { return index_js_1.SkyvernTimeoutError; } });
|
|
48
|
+
__exportStar(require("./exports.js"), exports);
|
|
45
49
|
var index_js_2 = require("./library/index.js");
|
|
46
50
|
Object.defineProperty(exports, "Skyvern", { enumerable: true, get: function () { return index_js_2.Skyvern; } });
|
|
47
51
|
Object.defineProperty(exports, "SkyvernBrowser", { enumerable: true, get: function () { return index_js_2.SkyvernBrowser; } });
|
|
@@ -60,6 +60,9 @@ const environments_js_1 = require("../environments.js");
|
|
|
60
60
|
const SkyvernBrowser_js_1 = require("./SkyvernBrowser.js");
|
|
61
61
|
const logger_js_1 = require("./logger.js");
|
|
62
62
|
const core = __importStar(require("../core/index.js"));
|
|
63
|
+
function _getBrowserSessionUrl(browserSessionId) {
|
|
64
|
+
return `https://app.skyvern.com/browser-session/${browserSessionId}`;
|
|
65
|
+
}
|
|
63
66
|
/**
|
|
64
67
|
* Main entry point for the Skyvern SDK.
|
|
65
68
|
*
|
|
@@ -179,7 +182,12 @@ class Skyvern extends Client_js_1.SkyvernClient {
|
|
|
179
182
|
timeout: options === null || options === void 0 ? void 0 : options.timeout,
|
|
180
183
|
proxy_location: options === null || options === void 0 ? void 0 : options.proxyLocation,
|
|
181
184
|
});
|
|
182
|
-
|
|
185
|
+
if (this._environment === environments_js_1.SkyvernEnvironment.Cloud) {
|
|
186
|
+
logger_js_1.LOG.info("Launched new cloud browser session", { url: _getBrowserSessionUrl(browserSession.browser_session_id) });
|
|
187
|
+
}
|
|
188
|
+
else {
|
|
189
|
+
logger_js_1.LOG.info("Launched new cloud browser session", { browser_session_id: browserSession.browser_session_id });
|
|
190
|
+
}
|
|
183
191
|
return this._connectToCloudBrowserSession(browserSession);
|
|
184
192
|
});
|
|
185
193
|
}
|
|
@@ -194,7 +202,12 @@ class Skyvern extends Client_js_1.SkyvernClient {
|
|
|
194
202
|
return __awaiter(this, void 0, void 0, function* () {
|
|
195
203
|
this._ensureCloudEnvironment();
|
|
196
204
|
const browserSession = yield this.getBrowserSession(browserSessionId);
|
|
197
|
-
|
|
205
|
+
if (this._environment === environments_js_1.SkyvernEnvironment.Cloud) {
|
|
206
|
+
logger_js_1.LOG.info("Connecting to existing cloud browser session", { url: _getBrowserSessionUrl(browserSession.browser_session_id) });
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
logger_js_1.LOG.info("Connecting to existing cloud browser session", { browser_session_id: browserSession.browser_session_id });
|
|
210
|
+
}
|
|
198
211
|
return this._connectToCloudBrowserSession(browserSession);
|
|
199
212
|
});
|
|
200
213
|
}
|
|
@@ -218,17 +231,23 @@ class Skyvern extends Client_js_1.SkyvernClient {
|
|
|
218
231
|
this._ensureCloudEnvironment();
|
|
219
232
|
const browserSessions = yield this.getBrowserSessions();
|
|
220
233
|
const browserSession = browserSessions
|
|
221
|
-
.filter((s) => s.runnable_id == null)
|
|
234
|
+
.filter((s) => s.runnable_id == null && s.started_at != null && s.browser_address != null)
|
|
222
235
|
.sort((a, b) => {
|
|
223
|
-
const aTime =
|
|
224
|
-
const bTime =
|
|
236
|
+
const aTime = new Date(a.started_at).getTime();
|
|
237
|
+
const bTime = new Date(b.started_at).getTime();
|
|
225
238
|
return bTime - aTime;
|
|
226
|
-
})
|
|
239
|
+
})
|
|
240
|
+
.at(0);
|
|
227
241
|
if (!browserSession) {
|
|
228
242
|
logger_js_1.LOG.info("No existing cloud browser session found, launching a new session");
|
|
229
243
|
return this.launchCloudBrowser(options);
|
|
230
244
|
}
|
|
231
|
-
|
|
245
|
+
if (this._environment === environments_js_1.SkyvernEnvironment.Cloud) {
|
|
246
|
+
logger_js_1.LOG.info("Reusing existing cloud browser session", { url: _getBrowserSessionUrl(browserSession.browser_session_id) });
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
logger_js_1.LOG.info("Reusing existing cloud browser session", { browser_session_id: browserSession.browser_session_id });
|
|
250
|
+
}
|
|
232
251
|
return this._connectToCloudBrowserSession(browserSession);
|
|
233
252
|
});
|
|
234
253
|
}
|
|
@@ -30,20 +30,103 @@ export declare class SkyvernBrowserPageCore {
|
|
|
30
30
|
static create(browser: SkyvernBrowser, page: Page): SkyvernBrowserPage;
|
|
31
31
|
get page(): Page;
|
|
32
32
|
get browser(): SkyvernBrowser;
|
|
33
|
+
/**
|
|
34
|
+
* Click an element using a CSS selector, AI-powered prompt matching, or both.
|
|
35
|
+
*
|
|
36
|
+
* This method supports three modes:
|
|
37
|
+
* - **Selector-based**: Click the element matching the CSS selector
|
|
38
|
+
* - **AI-powered**: Use natural language to describe which element to click
|
|
39
|
+
* - **Fallback mode**: Try the selector first, fall back to AI if it fails
|
|
40
|
+
*
|
|
41
|
+
* @param selector - CSS selector for the target element.
|
|
42
|
+
* @param options - Click options including prompt.
|
|
43
|
+
* @param options.prompt - Natural language description of which element to click.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```typescript
|
|
47
|
+
* // Click using a CSS selector
|
|
48
|
+
* await page.click("#open-invoice-button");
|
|
49
|
+
*
|
|
50
|
+
* // Click using AI with natural language
|
|
51
|
+
* await page.click({ prompt: "Click on the 'Open Invoice' button" });
|
|
52
|
+
*
|
|
53
|
+
* // Try selector first, fall back to AI if selector fails
|
|
54
|
+
* await page.click("#open-invoice-button", { prompt: "Click on the 'Open Invoice' button" });
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
33
57
|
click(selector: string, options?: Parameters<Page["click"]>[1]): Promise<void>;
|
|
34
58
|
click(options: {
|
|
35
59
|
prompt: string;
|
|
36
60
|
} & Partial<Parameters<Page["click"]>[1]>): Promise<void>;
|
|
61
|
+
click(selector: string, options: {
|
|
62
|
+
prompt: string;
|
|
63
|
+
} & Partial<Parameters<Page["click"]>[1]>): Promise<void>;
|
|
64
|
+
/**
|
|
65
|
+
* Fill an input field using a CSS selector, AI-powered prompt matching, or both.
|
|
66
|
+
*
|
|
67
|
+
* This method supports three modes:
|
|
68
|
+
* - **Selector-based**: Fill the input field with a value using CSS selector
|
|
69
|
+
* - **AI-powered**: Use natural language prompt (AI extracts value from prompt or uses provided value)
|
|
70
|
+
* - **Fallback mode**: Try the selector first, fall back to AI if it fails
|
|
71
|
+
*
|
|
72
|
+
* @param selector - CSS selector for the target input element.
|
|
73
|
+
* @param value - The text value to input into the field.
|
|
74
|
+
* @param options - Fill options including prompt.
|
|
75
|
+
* @param options.prompt - Natural language description of which field to fill and what value.
|
|
76
|
+
*
|
|
77
|
+
* @example
|
|
78
|
+
* ```typescript
|
|
79
|
+
* // Fill using selector and value
|
|
80
|
+
* await page.fill("#email-input", "user@example.com");
|
|
81
|
+
*
|
|
82
|
+
* // Fill using AI with natural language
|
|
83
|
+
* await page.fill({ prompt: "Fill 'user@example.com' in the email address field" });
|
|
84
|
+
*
|
|
85
|
+
* // Try selector first, fall back to AI if selector fails
|
|
86
|
+
* await page.fill("#email-input", "user@example.com", { prompt: "Fill the email address" });
|
|
87
|
+
* ```
|
|
88
|
+
*/
|
|
37
89
|
fill(selector: string, value: string, options?: Parameters<Page["fill"]>[2]): Promise<void>;
|
|
38
90
|
fill(options: {
|
|
39
91
|
prompt: string;
|
|
40
92
|
value?: string;
|
|
41
93
|
} & Partial<Parameters<Page["fill"]>[2]>): Promise<void>;
|
|
42
|
-
|
|
94
|
+
fill(selector: string, value: string, options: {
|
|
95
|
+
prompt: string;
|
|
96
|
+
} & Partial<Parameters<Page["fill"]>[2]>): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Select an option from a dropdown using a CSS selector, AI-powered prompt matching, or both.
|
|
99
|
+
*
|
|
100
|
+
* This method supports three modes:
|
|
101
|
+
* - **Selector-based**: Select the option with a value using CSS selector
|
|
102
|
+
* - **AI-powered**: Use natural language prompt (AI extracts value from prompt or uses provided value)
|
|
103
|
+
* - **Fallback mode**: Try the selector first, fall back to AI if it fails
|
|
104
|
+
*
|
|
105
|
+
* @param selector - CSS selector for the target select/dropdown element.
|
|
106
|
+
* @param value - The option value to select.
|
|
107
|
+
* @param options - Select options including prompt.
|
|
108
|
+
* @param options.prompt - Natural language description of which option to select.
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* ```typescript
|
|
112
|
+
* // Select using selector and value
|
|
113
|
+
* await page.selectOption("#country", "us");
|
|
114
|
+
*
|
|
115
|
+
* // Select using AI with natural language
|
|
116
|
+
* await page.selectOption({ prompt: "Select 'United States' from the country dropdown" });
|
|
117
|
+
*
|
|
118
|
+
* // Try selector first, fall back to AI if selector fails
|
|
119
|
+
* await page.selectOption("#country", "us", { prompt: "Select United States from country" });
|
|
120
|
+
* ```
|
|
121
|
+
*/
|
|
122
|
+
selectOption(selector: string, values: string | string[], options?: Parameters<Page["selectOption"]>[2]): Promise<void>;
|
|
43
123
|
selectOption(options: {
|
|
44
124
|
prompt: string;
|
|
45
125
|
value?: string;
|
|
46
|
-
} & Partial<Parameters<Page["selectOption"]>[2]>): Promise<
|
|
126
|
+
} & Partial<Parameters<Page["selectOption"]>[2]>): Promise<void>;
|
|
127
|
+
selectOption(selector: string, values: string | string[], options: {
|
|
128
|
+
prompt: string;
|
|
129
|
+
} & Partial<Parameters<Page["selectOption"]>[2]>): Promise<void>;
|
|
47
130
|
/**
|
|
48
131
|
* Perform an action on the page using AI based on a natural language prompt.
|
|
49
132
|
*
|