simplex-ts 1.0.5 → 1.0.7

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 CHANGED
@@ -1,11 +1,32 @@
1
- # Simplex TypeScript
1
+ # Simplex TypeScript Package Template
2
2
 
3
- A TypeScript package for interacting with the Simplex API, providing a clean and type-safe interface for browser automation and web interaction.
3
+ A TypeScript package for browser automation and web interaction using Simplex API.
4
4
 
5
- ## Installation
5
+ ## Features
6
+
7
+ - Browser automation with high-level commands
8
+ - Session-based interaction
9
+ - Element interaction (click, type, scroll)
10
+ - Content extraction (text, images, bounding boxes)
11
+ - File upload and download capabilities
12
+ - TypeScript support with type definitions
13
+ - Built with modern tooling (ESM + CommonJS output)
14
+
15
+ ## Getting Started
16
+
17
+ 1. Install dependencies:
18
+ ```bash
19
+ npm install
20
+ ```
21
+
22
+ 2. Build the package:
23
+ ```bash
24
+ npm run build
25
+ ```
6
26
 
27
+ 3. Run tests:
7
28
  ```bash
8
- npm install simplex-ts
29
+ npm test
9
30
  ```
10
31
 
11
32
  ## Usage
@@ -13,86 +34,46 @@ npm install simplex-ts
13
34
  ```typescript
14
35
  import { Simplex } from 'simplex-ts';
15
36
 
16
- // Initialize with your API key
37
+ // Initialize Simplex with your API key
17
38
  const simplex = new Simplex('your-api-key');
18
39
 
19
- // Create a session
40
+ // Create a new session
20
41
  const [sessionId, livestreamUrl] = await simplex.createSession();
21
42
 
22
- // Navigate to a URL
23
- await simplex.goto('https://example.com');
43
+ // Navigate to a website
44
+ await simplex.goto('example.com');
24
45
 
25
- // Click elements
26
- await simplex.click('button with text "Submit"');
46
+ // Interact with elements
47
+ await simplex.click('Login button');
48
+ await simplex.type('user@example.com');
49
+ await simplex.pressEnter();
27
50
 
28
- // Type text
29
- await simplex.type('Hello, World!');
30
-
31
- // Extract text
32
- const text = await simplex.extractText('element with text');
51
+ // Extract content
52
+ const text = await simplex.extractText('Welcome message');
53
+ console.log(text);
33
54
 
34
55
  // Close the session when done
35
56
  await simplex.closeSession();
36
57
  ```
37
58
 
38
- ## Features
39
-
40
- - Type-safe API interactions
41
- - Browser automation capabilities
42
- - Element interaction (click, type, scroll)
43
- - Text and image extraction
44
- - File upload/download support
45
- - Session management
46
- - Live streaming support
47
-
48
- ## API Reference
49
-
50
- ### Constructor
51
- ```typescript
52
- constructor(apiKey: string)
53
- ```
54
-
55
- ### Methods
56
-
57
- #### createSession
58
- ```typescript
59
- createSession(
60
- showInConsole?: boolean,
61
- proxies?: boolean,
62
- workflowName?: string,
63
- sessionData?: SessionData | string
64
- ): Promise<[string, string]>
65
- ```
66
-
67
- #### goto
68
- ```typescript
69
- goto(url: string, cdpUrl?: string): Promise<void>
70
- ```
71
-
72
- #### click
73
- ```typescript
74
- click(elementDescription: string, cdpUrl?: string): Promise<string>
75
- ```
76
-
77
- #### type
78
- ```typescript
79
- type(text: string, cdpUrl?: string): Promise<void>
80
- ```
81
-
82
- #### extractText
83
- ```typescript
84
- extractText(elementDescription: string, cdpUrl?: string): Promise<string>
85
- ```
86
-
87
- #### extractImage
88
- ```typescript
89
- extractImage(elementDescription: string, cdpUrl?: string): Promise<string>
90
- ```
91
-
92
- #### closeSession
93
- ```typescript
94
- closeSession(): Promise<void>
95
- ```
59
+ ### Available Methods
60
+
61
+ - `createSession()` - Start a new browser session
62
+ - `goto(url)` - Navigate to a URL
63
+ - `click(elementDescription)` - Click an element
64
+ - `type(text)` - Type text
65
+ - `pressEnter()` - Press Enter key
66
+ - `pressTab()` - Press Tab key
67
+ - `deleteText()` - Delete text
68
+ - `extractBbox(elementDescription)` - Get element bounding box
69
+ - `extractText(elementDescription)` - Extract text from element
70
+ - `extractImage(elementDescription)` - Extract image from element
71
+ - `scroll(pixels)` - Scroll page
72
+ - `wait(milliseconds)` - Wait for specified duration
73
+ - `clickAndUpload(elementDescription, file)` - Click and upload file
74
+ - `clickAndDownload(elementDescription)` - Click and download file
75
+ - `exists(elementDescription)` - Check if element exists
76
+ - `closeSession()` - Close the browser session
96
77
 
97
78
  ## License
98
79
 
package/dist/index.d.mts CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Example function to demonstrate package usage
3
+ * @param name - The name to greet
4
+ * @returns A greeting message
5
+ */
6
+ declare function greet(name: string): string;
1
7
  interface SessionData {
2
8
  [key: string]: any;
3
9
  }
@@ -10,6 +16,8 @@ declare class Simplex {
10
16
  createSession(showInConsole?: boolean, proxies?: boolean, workflowName?: string, sessionData?: SessionData | string): Promise<[string, string]>;
11
17
  goto(url: string, cdpUrl?: string): Promise<void>;
12
18
  click(elementDescription: string, cdpUrl?: string): Promise<string>;
19
+ scrollToElement(elementDescription: string, cdpUrl?: string): Promise<string>;
20
+ hover(elementDescription: string, cdpUrl?: string): Promise<string>;
13
21
  type(text: string, cdpUrl?: string): Promise<void>;
14
22
  pressEnter(cdpUrl?: string): Promise<void>;
15
23
  pressTab(cdpUrl?: string): Promise<void>;
@@ -22,7 +30,8 @@ declare class Simplex {
22
30
  clickAndUpload(elementDescription: string, filePathOrCallable: string | (() => Blob)): Promise<void>;
23
31
  clickAndDownload(elementDescription: string): Promise<[string, string]>;
24
32
  exists(elementDescription: string, cdpUrl?: string): Promise<[boolean, string]>;
33
+ getNetworkResponse(url: string, cdpUrl?: string): Promise<string>;
25
34
  closeSession(): Promise<void>;
26
35
  }
27
36
 
28
- export { Simplex };
37
+ export { Simplex, greet };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,9 @@
1
+ /**
2
+ * Example function to demonstrate package usage
3
+ * @param name - The name to greet
4
+ * @returns A greeting message
5
+ */
6
+ declare function greet(name: string): string;
1
7
  interface SessionData {
2
8
  [key: string]: any;
3
9
  }
@@ -10,6 +16,8 @@ declare class Simplex {
10
16
  createSession(showInConsole?: boolean, proxies?: boolean, workflowName?: string, sessionData?: SessionData | string): Promise<[string, string]>;
11
17
  goto(url: string, cdpUrl?: string): Promise<void>;
12
18
  click(elementDescription: string, cdpUrl?: string): Promise<string>;
19
+ scrollToElement(elementDescription: string, cdpUrl?: string): Promise<string>;
20
+ hover(elementDescription: string, cdpUrl?: string): Promise<string>;
13
21
  type(text: string, cdpUrl?: string): Promise<void>;
14
22
  pressEnter(cdpUrl?: string): Promise<void>;
15
23
  pressTab(cdpUrl?: string): Promise<void>;
@@ -22,7 +30,8 @@ declare class Simplex {
22
30
  clickAndUpload(elementDescription: string, filePathOrCallable: string | (() => Blob)): Promise<void>;
23
31
  clickAndDownload(elementDescription: string): Promise<[string, string]>;
24
32
  exists(elementDescription: string, cdpUrl?: string): Promise<[boolean, string]>;
33
+ getNetworkResponse(url: string, cdpUrl?: string): Promise<string>;
25
34
  closeSession(): Promise<void>;
26
35
  }
27
36
 
28
- export { Simplex };
37
+ export { Simplex, greet };
package/dist/index.js CHANGED
@@ -1,3 +1,346 @@
1
- 'use strict';var l=require('axios');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var l__default=/*#__PURE__*/_interopDefault(l);var p="https://api.simplex.sh",d=class{constructor(s){this.sessionId=null;this.connectUrl=null;this.apiKey=s;}async makeRequest(s,e,t,i){try{console.log(`Making ${s.toUpperCase()} request to ${e}`);let n=new FormData;t&&Object.entries(t).forEach(([a,c])=>{c!=null&&n.append(a,c.toString());}),console.log("Request data:",t);let o=await l__default.default({method:s,url:`${p}${e}`,data:s==="post"?n:void 0,params:s==="get"?i:void 0,headers:{"x-api-key":this.apiKey,...s==="post"?{"Content-Type":"multipart/form-data"}:{}}});console.log("Response status:",o.status),console.log("Response data:",JSON.stringify(o.data,null,2));let r=o.data;if(!r.succeeded&&!(e==="/create_session"&&r.session_id)){let a=r.error||"Request failed";throw console.error("API request failed:",a),new Error(a)}return r}catch(n){if(l__default.default.isAxiosError(n)){let o=n.response?.data?.error||n.message;throw console.error("Axios error:",{status:n.response?.status,statusText:n.response?.statusText,data:n.response?.data,message:o}),new Error(`Request failed: ${o}`)}throw console.error("Unexpected error:",n),n}}async createSession(s=true,e=true,t,i){let n={proxies:e,workflow_name:t};if(this.sessionId)throw new Error("A session is already active. Please close the current session before creating a new one.");if(i)if(typeof i=="string")try{n.session_data=JSON.stringify(JSON.parse(i));}catch{throw new Error("File system operations are not supported in this environment")}else n.session_data=JSON.stringify(i);let o=await this.makeRequest("post","/create_session",n);if(!o.session_id)throw new Error("Session creation failed: No session ID returned");return this.sessionId=o.session_id,this.connectUrl=o.connect_url||null,s&&o.livestream_url&&console.log(`Livestream URL: ${o.livestream_url}`),[o.session_id,o.livestream_url||""]}async goto(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling goto with url='${s}'`);!s.startsWith("http://")&&!s.startsWith("https://")&&(s="https://"+s);let t={url:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/goto",t);}async click(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling click with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("post","/click",t)).element_clicked||""}async type(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling type with text='${s}'`);let t={text:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/type",t);}async pressEnter(s){if(!s&&!this.sessionId)throw new Error("Must call createSession before calling pressEnter");let e=s?{cdp_url:s}:{session_id:this.sessionId};await this.makeRequest("post","/press_enter",e);}async pressTab(s){if(!s&&!this.sessionId)throw new Error("Must call createSession before calling pressTab");let e=s?{cdp_url:s}:{session_id:this.sessionId};await this.makeRequest("post","/press_tab",e);}async deleteText(s){if(!s&&!this.sessionId)throw new Error("Must call createSession before calling deleteText");let e=s?{cdp_url:s}:{session_id:this.sessionId};await this.makeRequest("post","/delete_text",e);}async extractBbox(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling extractBbox with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("get","/extract-bbox",void 0,t)).bbox}async extractText(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling extractText with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("post","/extract-text",t)).text||""}async extractImage(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling extractImage with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("get","/extract-image",void 0,t)).image||""}async scroll(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling scroll with pixels=${s}`);let t={pixels:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/scroll",t);}async wait(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling wait with milliseconds=${s}`);let t={milliseconds:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/wait",t);}async clickAndUpload(s,e){if(!this.sessionId)throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${s}'`);if(typeof e!="string"&&typeof e!="function")throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof e}`);let t=new FormData;if(t.append("element_description",s),t.append("session_id",this.sessionId),typeof e=="string")throw new Error("File system operations are not supported in this environment");{let i=e();t.append("file",i,"file");}await this.makeRequest("post","/click_and_upload",t,void 0);}async clickAndDownload(s){if(!this.sessionId)throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${s}'`);let e={element_description:s,session_id:this.sessionId},t=await this.makeRequest("post","/click_and_download",e);return [t.b64||"",t.filename||""]}async exists(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling exists with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}},i=await this.makeRequest("post","/exists",t);return [i.exists||false,i.reasoning||""]}async closeSession(){this.sessionId&&(await this.makeRequest("post","/close_session",{session_id:this.sessionId}),this.sessionId=null,this.connectUrl=null);}};
2
- exports.Simplex=d;//# sourceMappingURL=index.js.map
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/index.ts
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
+ Simplex: () => Simplex,
34
+ greet: () => greet
35
+ });
36
+ module.exports = __toCommonJS(index_exports);
37
+ var import_axios = __toESM(require("axios"));
38
+ function greet(name) {
39
+ return `Hello, ${name}!`;
40
+ }
41
+ var BASE_URL = "https://simplex-dev-shreya--api-server-fastapi-app.modal.run";
42
+ var Simplex = class {
43
+ constructor(apiKey) {
44
+ this.sessionId = null;
45
+ this.connectUrl = null;
46
+ this.apiKey = apiKey;
47
+ }
48
+ async makeRequest(method, endpoint, data, params) {
49
+ try {
50
+ console.log(`Making ${method.toUpperCase()} request to ${endpoint}`);
51
+ const formData = new FormData();
52
+ if (data) {
53
+ Object.entries(data).forEach(([key, value]) => {
54
+ if (value !== void 0 && value !== null) {
55
+ formData.append(key, value.toString());
56
+ }
57
+ });
58
+ }
59
+ const response = await (0, import_axios.default)({
60
+ method,
61
+ url: `${BASE_URL}${endpoint}`,
62
+ data: method === "post" ? formData : void 0,
63
+ params: method === "get" ? params : void 0,
64
+ headers: {
65
+ "x-api-key": this.apiKey,
66
+ ...method === "post" ? { "Content-Type": "multipart/form-data" } : {}
67
+ }
68
+ });
69
+ const responseData = response.data;
70
+ if (endpoint == "/hover" || endpoint == "/scroll_to_element") {
71
+ if (!("succeeded" in responseData)) {
72
+ console.error("Response data missing 'succeeded' property:", responseData);
73
+ throw new Error("Invalid API response: missing 'succeeded' property");
74
+ } else {
75
+ if (responseData.succeeded) {
76
+ return responseData;
77
+ } else {
78
+ throw new Error(responseData.error || "Request failed");
79
+ }
80
+ }
81
+ }
82
+ if (endpoint == "/goto") {
83
+ if (!("succeeded" in responseData)) {
84
+ console.error('Response data missing "succeeded" property:', responseData);
85
+ throw new Error('Invalid API response: missing "succeeded" property');
86
+ } else {
87
+ return responseData;
88
+ }
89
+ }
90
+ if (endpoint == "/get_network_response") {
91
+ if (!("status" in responseData)) {
92
+ console.error('Response data missing "status" property:', responseData);
93
+ throw new Error('Invalid API response: missing "status" property');
94
+ } else if (responseData.status == "success") {
95
+ return responseData;
96
+ } else {
97
+ throw new Error("Failed to get network response");
98
+ }
99
+ }
100
+ if (!responseData.succeeded && !(endpoint === "/create_session" && responseData.session_id)) {
101
+ const errorMessage = responseData.error || "Request failed";
102
+ console.error("API request failed:", errorMessage);
103
+ throw new Error(errorMessage);
104
+ }
105
+ return responseData;
106
+ } catch (error) {
107
+ if (import_axios.default.isAxiosError(error)) {
108
+ const errorMessage = error.response?.data?.error || error.message;
109
+ console.error("Axios error:", {
110
+ status: error.response?.status,
111
+ statusText: error.response?.statusText,
112
+ data: error.response?.data,
113
+ message: errorMessage
114
+ });
115
+ throw new Error(`Request failed: ${errorMessage}`);
116
+ }
117
+ console.error("Unexpected error:", error);
118
+ throw error;
119
+ }
120
+ }
121
+ async createSession(showInConsole = true, proxies = true, workflowName, sessionData) {
122
+ const data = {
123
+ proxies,
124
+ workflow_name: workflowName
125
+ };
126
+ if (this.sessionId) {
127
+ throw new Error("A session is already active. Please close the current session before creating a new one.");
128
+ }
129
+ if (sessionData) {
130
+ if (typeof sessionData === "string") {
131
+ try {
132
+ data.session_data = JSON.stringify(JSON.parse(sessionData));
133
+ } catch {
134
+ throw new Error("File system operations are not supported in this environment");
135
+ }
136
+ } else {
137
+ data.session_data = JSON.stringify(sessionData);
138
+ }
139
+ }
140
+ const response = await this.makeRequest("post", "/create_session", data);
141
+ if (!response.session_id) {
142
+ throw new Error("Session creation failed: No session ID returned");
143
+ }
144
+ this.sessionId = response.session_id;
145
+ this.connectUrl = response.connect_url || null;
146
+ if (showInConsole && response.livestream_url) {
147
+ console.log(`Livestream URL: ${response.livestream_url}`);
148
+ }
149
+ return [response.session_id, response.livestream_url || ""];
150
+ }
151
+ async goto(url, cdpUrl) {
152
+ if (!cdpUrl && !this.sessionId) {
153
+ throw new Error(`Must call createSession before calling goto with url='${url}'`);
154
+ }
155
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
156
+ url = "https://" + url;
157
+ }
158
+ const data = {
159
+ url,
160
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
161
+ };
162
+ await this.makeRequest("post", "/goto", data);
163
+ }
164
+ async click(elementDescription, cdpUrl) {
165
+ if (!cdpUrl && !this.sessionId) {
166
+ throw new Error(`Must call createSession before calling click with elementDescription='${elementDescription}'`);
167
+ }
168
+ const data = {
169
+ element_description: elementDescription,
170
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
171
+ };
172
+ const response = await this.makeRequest("post", "/click", data);
173
+ return response.element_clicked || "";
174
+ }
175
+ async scrollToElement(elementDescription, cdpUrl) {
176
+ if (!cdpUrl && !this.sessionId) {
177
+ throw new Error(`Must call createSession before calling scrollToElement with elementDescription='${elementDescription}'`);
178
+ }
179
+ const data = {
180
+ element_description: elementDescription,
181
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
182
+ };
183
+ const response = await this.makeRequest("post", "/scroll_to_element", data);
184
+ return response.element_info || "";
185
+ }
186
+ async hover(elementDescription, cdpUrl) {
187
+ if (!cdpUrl && !this.sessionId) {
188
+ throw new Error(`Must call createSession before calling hover with elementDescription='${elementDescription}'`);
189
+ }
190
+ const data = {
191
+ element_description: elementDescription,
192
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
193
+ };
194
+ const response = await this.makeRequest("post", "/hover", data);
195
+ return response.element_info || "";
196
+ }
197
+ async type(text, cdpUrl) {
198
+ if (!cdpUrl && !this.sessionId) {
199
+ throw new Error(`Must call createSession before calling type with text='${text}'`);
200
+ }
201
+ const data = {
202
+ text,
203
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
204
+ };
205
+ await this.makeRequest("post", "/type", data);
206
+ }
207
+ async pressEnter(cdpUrl) {
208
+ if (!cdpUrl && !this.sessionId) {
209
+ throw new Error("Must call createSession before calling pressEnter");
210
+ }
211
+ const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };
212
+ await this.makeRequest("post", "/press_enter", data);
213
+ }
214
+ async pressTab(cdpUrl) {
215
+ if (!cdpUrl && !this.sessionId) {
216
+ throw new Error("Must call createSession before calling pressTab");
217
+ }
218
+ const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };
219
+ await this.makeRequest("post", "/press_tab", data);
220
+ }
221
+ async deleteText(cdpUrl) {
222
+ if (!cdpUrl && !this.sessionId) {
223
+ throw new Error("Must call createSession before calling deleteText");
224
+ }
225
+ const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };
226
+ await this.makeRequest("post", "/delete_text", data);
227
+ }
228
+ async extractBbox(elementDescription, cdpUrl) {
229
+ if (!cdpUrl && !this.sessionId) {
230
+ throw new Error(`Must call createSession before calling extractBbox with elementDescription='${elementDescription}'`);
231
+ }
232
+ const params = {
233
+ element_description: elementDescription,
234
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
235
+ };
236
+ const response = await this.makeRequest("get", "/extract-bbox", void 0, params);
237
+ return response.bbox;
238
+ }
239
+ async extractText(elementDescription, cdpUrl) {
240
+ if (!cdpUrl && !this.sessionId) {
241
+ throw new Error(`Must call createSession before calling extractText with elementDescription='${elementDescription}'`);
242
+ }
243
+ const data = {
244
+ element_description: elementDescription,
245
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
246
+ };
247
+ const response = await this.makeRequest("post", "/extract-text", data);
248
+ return response.text || "";
249
+ }
250
+ async extractImage(elementDescription, cdpUrl) {
251
+ if (!cdpUrl && !this.sessionId) {
252
+ throw new Error(`Must call createSession before calling extractImage with elementDescription='${elementDescription}'`);
253
+ }
254
+ const params = {
255
+ element_description: elementDescription,
256
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
257
+ };
258
+ const response = await this.makeRequest("get", "/extract-image", void 0, params);
259
+ return response.image || "";
260
+ }
261
+ async scroll(pixels, cdpUrl) {
262
+ if (!cdpUrl && !this.sessionId) {
263
+ throw new Error(`Must call createSession before calling scroll with pixels=${pixels}`);
264
+ }
265
+ const data = {
266
+ pixels,
267
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
268
+ };
269
+ await this.makeRequest("post", "/scroll", data);
270
+ }
271
+ async wait(milliseconds, cdpUrl) {
272
+ if (!cdpUrl && !this.sessionId) {
273
+ throw new Error(`Must call createSession before calling wait with milliseconds=${milliseconds}`);
274
+ }
275
+ const data = {
276
+ milliseconds,
277
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
278
+ };
279
+ await this.makeRequest("post", "/wait", data);
280
+ }
281
+ async clickAndUpload(elementDescription, filePathOrCallable) {
282
+ if (!this.sessionId) {
283
+ throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${elementDescription}'`);
284
+ }
285
+ if (typeof filePathOrCallable !== "string" && typeof filePathOrCallable !== "function") {
286
+ throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof filePathOrCallable}`);
287
+ }
288
+ const formData = new FormData();
289
+ formData.append("element_description", elementDescription);
290
+ formData.append("session_id", this.sessionId);
291
+ if (typeof filePathOrCallable === "string") {
292
+ throw new Error("File system operations are not supported in this environment");
293
+ } else {
294
+ const blob = filePathOrCallable();
295
+ formData.append("file", blob, "file");
296
+ }
297
+ await this.makeRequest("post", "/click_and_upload", formData, void 0);
298
+ }
299
+ async clickAndDownload(elementDescription) {
300
+ if (!this.sessionId) {
301
+ throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${elementDescription}'`);
302
+ }
303
+ const data = {
304
+ element_description: elementDescription,
305
+ session_id: this.sessionId
306
+ };
307
+ const response = await this.makeRequest("post", "/click_and_download", data);
308
+ return [response.b64 || "", response.filename || ""];
309
+ }
310
+ async exists(elementDescription, cdpUrl) {
311
+ if (!cdpUrl && !this.sessionId) {
312
+ throw new Error(`Must call createSession before calling exists with elementDescription='${elementDescription}'`);
313
+ }
314
+ const data = {
315
+ element_description: elementDescription,
316
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
317
+ };
318
+ const response = await this.makeRequest("post", "/exists", data);
319
+ return [response.exists || false, response.reasoning || ""];
320
+ }
321
+ async getNetworkResponse(url, cdpUrl) {
322
+ if (!cdpUrl && !this.sessionId) {
323
+ throw new Error(`Must call createSession before calling getNetworkResponse with url='${url}'`);
324
+ }
325
+ const data = {
326
+ url,
327
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
328
+ };
329
+ const response = await this.makeRequest("post", "/get_network_response", data);
330
+ return response.response || "";
331
+ }
332
+ async closeSession() {
333
+ if (!this.sessionId) {
334
+ return;
335
+ }
336
+ await this.makeRequest("post", "/close_session", { session_id: this.sessionId });
337
+ this.sessionId = null;
338
+ this.connectUrl = null;
339
+ }
340
+ };
341
+ // Annotate the CommonJS export names for ESM import in node:
342
+ 0 && (module.exports = {
343
+ Simplex,
344
+ greet
345
+ });
3
346
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["BASE_URL","Simplex","apiKey","method","endpoint","data","params","formData","key","value","response","axios","responseData","errorMessage","error","showInConsole","proxies","workflowName","sessionData","url","cdpUrl","elementDescription","text","pixels","milliseconds","filePathOrCallable","blob"],"mappings":"oJAIA,IAAMA,CAAW,CAAA,wBAAA,CA+BJC,CAAN,CAAA,KAAc,CAKnB,WAAA,CAAYC,CAAgB,CAAA,CAH5B,IAAQ,CAAA,SAAA,CAA2B,KACnC,IAAQ,CAAA,UAAA,CAA4B,IAGlC,CAAA,IAAA,CAAK,MAASA,CAAAA,EAChB,CAEA,MAAc,WACZC,CAAAA,CAAAA,CACAC,CACAC,CAAAA,CAAAA,CACAC,CACY,CAAA,CACZ,GAAI,CACF,OAAA,CAAQ,GAAI,CAAA,CAAA,OAAA,EAAUH,CAAO,CAAA,WAAA,EAAa,CAAA,YAAA,EAAeC,CAAQ,CAAA,CAAE,CAGnE,CAAA,IAAMG,CAAW,CAAA,IAAI,QACjBF,CAAAA,CAAAA,EACF,MAAO,CAAA,OAAA,CAAQA,CAAI,CAAA,CAAE,OAAQ,CAAA,CAAC,CAACG,CAAAA,CAAKC,CAAK,CAAA,GAAM,CAClBA,CAAAA,EAAU,IACnCF,EAAAA,CAAAA,CAAS,OAAOC,CAAKC,CAAAA,CAAAA,CAAM,QAAS,EAAC,EAEzC,CAAC,CAGH,CAAA,OAAA,CAAQ,GAAI,CAAA,eAAA,CAAiBJ,CAAI,CAAA,CAEjC,IAAMK,CAAAA,CAAW,MAAMC,kBAAAA,CAAM,CAC3B,MAAA,CAAAR,CACA,CAAA,GAAA,CAAK,CAAGH,EAAAA,CAAQ,CA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AAA,CAAqBgB,CACrB,CAAA,GAAID,CAAS,CAAA,CAAE,OAASA,CAAAA,CAAO,CAAI,CAAA,CAAE,UAAY,CAAA,IAAA,CAAK,SAAU,CAClE,CAEMV,CAAAA,CAAAA,CAAW,MAAM,IAAA,CAAK,WAA6B,CAAA,MAAA,CAAQ,SAAWL,CAAAA,CAAI,CAChF,CAAA,OAAO,CAACK,CAAAA,CAAS,QAAU,KAAOA,CAAAA,CAAAA,CAAS,SAAa,EAAA,EAAE,CAC5D,CAEA,MAAM,YAAA,EAA8B,CAC7B,IAAA,CAAK,SAIV,GAAA,MAAM,IAAK,CAAA,WAAA,CAAY,MAAQ,CAAA,gBAAA,CAAkB,CAAE,UAAA,CAAY,IAAK,CAAA,SAAU,CAAC,CAAA,CAC/E,IAAK,CAAA,SAAA,CAAY,IACjB,CAAA,IAAA,CAAK,UAAa,CAAA,IAAA,EACpB,CACF","file":"index.js","sourcesContent":["// Export other functions and types here \n\nimport axios from 'axios';\n\nconst BASE_URL = \"https://api.simplex.sh\";\n\ninterface SessionData {\n [key: string]: any;\n}\n\ninterface PlaywrightClickOptions {\n locator: string;\n locatorType: string;\n exact?: boolean;\n elementIndex?: 'first' | 'last' | 'nth';\n nthIndex?: number;\n locatorOptions?: Record<string, any>;\n}\n\ninterface SimplexResponse {\n succeeded: boolean;\n error?: string;\n session_id?: string;\n livestream_url?: string;\n connect_url?: string;\n element_clicked?: string;\n text?: string;\n image?: string;\n bbox?: any;\n b64?: string;\n filename?: string;\n exists?: boolean;\n reasoning?: string;\n}\n\nexport class Simplex {\n private apiKey: string;\n private sessionId: string | null = null;\n private connectUrl: string | null = null;\n\n constructor(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n private async makeRequest<T>(\n method: 'get' | 'post',\n endpoint: string,\n data?: any,\n params?: any\n ): Promise<T> {\n try {\n console.log(`Making ${method.toUpperCase()} request to ${endpoint}`);\n \n // Convert data to FormData\n const formData = new FormData();\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n formData.append(key, value.toString());\n }\n });\n }\n\n console.log('Request data:', data);\n \n const response = await axios({\n method,\n url: `${BASE_URL}${endpoint}`,\n data: method === 'post' ? formData : undefined,\n params: method === 'get' ? params : undefined,\n headers: {\n 'x-api-key': this.apiKey,\n ...(method === 'post' ? { 'Content-Type': 'multipart/form-data' } : {})\n }\n });\n\n console.log('Response status:', response.status);\n console.log('Response data:', JSON.stringify(response.data, null, 2));\n\n const responseData = response.data as SimplexResponse;\n \n // Consider response successful if:\n // 1. It has succeeded: true, or\n // 2. It's a create_session response with a session_id\n if (!responseData.succeeded && !(endpoint === '/create_session' && responseData.session_id)) {\n const errorMessage = responseData.error || 'Request failed';\n console.error('API request failed:', errorMessage);\n throw new Error(errorMessage);\n }\n return responseData as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const errorMessage = error.response?.data?.error || error.message;\n console.error('Axios error:', {\n status: error.response?.status,\n statusText: error.response?.statusText,\n data: error.response?.data,\n message: errorMessage\n });\n throw new Error(`Request failed: ${errorMessage}`);\n }\n console.error('Unexpected error:', error);\n throw error;\n }\n }\n\n async createSession(\n showInConsole: boolean = true,\n proxies: boolean = true,\n workflowName?: string,\n sessionData?: SessionData | string\n ): Promise<[string, string]> {\n const data: any = {\n proxies,\n workflow_name: workflowName\n };\n\n if (this.sessionId) {\n throw new Error(\"A session is already active. Please close the current session before creating a new one.\");\n }\n if (sessionData) {\n if (typeof sessionData === 'string') {\n try {\n data.session_data = JSON.stringify(JSON.parse(sessionData));\n } catch {\n // If parsing fails, treat as file path\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n }\n } else {\n data.session_data = JSON.stringify(sessionData);\n }\n }\n\n const response = await this.makeRequest<SimplexResponse>('post', '/create_session', data);\n \n if (!response.session_id) {\n throw new Error('Session creation failed: No session ID returned');\n }\n\n this.sessionId = response.session_id;\n this.connectUrl = response.connect_url || null;\n\n if (showInConsole && response.livestream_url) {\n console.log(`Livestream URL: ${response.livestream_url}`);\n }\n\n return [response.session_id, response.livestream_url || ''];\n }\n\n async goto(url: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling goto with url='${url}'`);\n }\n\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\n url = 'https://' + url;\n }\n\n const data = {\n url,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/goto', data);\n }\n\n async click(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling click with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click', data);\n return response.element_clicked || '';\n }\n\n async type(text: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling type with text='${text}'`);\n }\n\n const data = {\n text,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/type', data);\n }\n\n async pressEnter(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressEnter');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_enter', data);\n }\n\n async pressTab(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressTab');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_tab', data);\n }\n\n async deleteText(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling deleteText');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/delete_text', data);\n }\n\n async extractBbox(elementDescription: string, cdpUrl?: string): Promise<any> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractBbox with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-bbox', undefined, params);\n return response.bbox;\n }\n\n async extractText(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractText with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/extract-text', data);\n return response.text || '';\n }\n\n async extractImage(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractImage with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-image', undefined, params);\n return response.image || '';\n }\n\n async scroll(pixels: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling scroll with pixels=${pixels}`);\n }\n\n const data = {\n pixels,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/scroll', data);\n }\n\n async wait(milliseconds: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling wait with milliseconds=${milliseconds}`);\n }\n\n const data = {\n milliseconds,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/wait', data);\n }\n\n async clickAndUpload(\n elementDescription: string,\n filePathOrCallable: string | (() => Blob)\n ): Promise<void> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${elementDescription}'`);\n }\n\n if (typeof filePathOrCallable !== 'string' && typeof filePathOrCallable !== 'function') {\n throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof filePathOrCallable}`);\n }\n\n const formData = new FormData();\n formData.append('element_description', elementDescription);\n formData.append('session_id', this.sessionId);\n\n if (typeof filePathOrCallable === 'string') {\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n } else {\n const blob = filePathOrCallable();\n formData.append('file', blob, 'file'); // Add filename for the blob\n }\n\n await this.makeRequest('post', '/click_and_upload', formData, undefined);\n }\n\n async clickAndDownload(elementDescription: string): Promise<[string, string]> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n session_id: this.sessionId\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click_and_download', data);\n return [response.b64 || '', response.filename || ''];\n }\n\n async exists(elementDescription: string, cdpUrl?: string): Promise<[boolean, string]> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling exists with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/exists', data);\n return [response.exists || false, response.reasoning || ''];\n }\n\n async closeSession(): Promise<void> {\n if (!this.sessionId) {\n return;\n }\n\n await this.makeRequest('post', '/close_session', { session_id: this.sessionId });\n this.sessionId = null;\n this.connectUrl = null;\n }\n} "]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Example function to demonstrate package usage\n * @param name - The name to greet\n * @returns A greeting message\n */\nexport function greet(name: string): string {\n return `Hello, ${name}!`;\n}\n\n// Export other functions and types here \nimport axios from 'axios';\n\n// const BASE_URL = \"https://api.simplex.sh\"\nconst BASE_URL = \"https://simplex-dev-shreya--api-server-fastapi-app.modal.run\"\n\ninterface SessionData {\n [key: string]: any;\n}\n\ninterface PlaywrightClickOptions {\n locator: string;\n locatorType: string;\n exact?: boolean;\n elementIndex?: 'first' | 'last' | 'nth';\n nthIndex?: number;\n locatorOptions?: Record<string, any>;\n}\n\ninterface SimplexResponse {\n succeeded: boolean;\n error?: string;\n session_id?: string;\n livestream_url?: string;\n connect_url?: string;\n element_clicked?: string;\n element_info?: string;\n text?: string;\n image?: string;\n bbox?: any;\n b64?: string;\n filename?: string;\n exists?: boolean;\n reasoning?: string;\n response?: string;\n}\n\nexport class Simplex {\n private apiKey: string;\n private sessionId: string | null = null;\n private connectUrl: string | null = null;\n\n constructor(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n private async makeRequest<T>(\n method: 'get' | 'post',\n endpoint: string,\n data?: any,\n params?: any\n ): Promise<T> {\n try {\n console.log(`Making ${method.toUpperCase()} request to ${endpoint}`);\n \n // Convert data to FormData\n const formData = new FormData();\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n formData.append(key, value.toString());\n }\n });\n }\n\n // console.log('Request data:', Object.fromEntries(formData.entries()));\n \n const response = await axios({\n method,\n url: `${BASE_URL}${endpoint}`,\n data: method === 'post' ? formData : undefined,\n params: method === 'get' ? params : undefined,\n headers: {\n 'x-api-key': this.apiKey,\n ...(method === 'post' ? { 'Content-Type': 'multipart/form-data' } : {})\n }\n });\n\n // console.log('Response status:', response.status);\n // console.log('Response data:', JSON.stringify(response.data, null, 2));\n\n const responseData = response.data as SimplexResponse;\n \n // Consider response successful if:\n // 1. It has succeeded: true, or\n // 2. It's a create_session response with a session_id\n // Check if 'succeeded' property exists in responseData\n // console.log('Response data:', responseData);\n\n if (endpoint == \"/hover\" || endpoint == \"/scroll_to_element\") {\n if (!('succeeded' in responseData)) {\n console.error(\"Response data missing 'succeeded' property:\", responseData);\n throw new Error(\"Invalid API response: missing 'succeeded' property\");\n } else {\n if (responseData.succeeded) {\n return responseData as T;\n } else {\n throw new Error(responseData.error || 'Request failed');\n }\n }\n }\n\n if (endpoint == \"/goto\") {\n if (!('succeeded' in responseData)) {\n console.error('Response data missing \"succeeded\" property:', responseData);\n throw new Error('Invalid API response: missing \"succeeded\" property');\n } else {\n return responseData as T;\n }\n }\n\n if (endpoint == \"/get_network_response\") {\n if (!('status' in responseData)) {\n console.error('Response data missing \"status\" property:', responseData);\n throw new Error('Invalid API response: missing \"status\" property');\n } else if (responseData.status == \"success\") {\n return responseData as T;\n } else {\n throw new Error('Failed to get network response');\n }\n }\n\n if (!responseData.succeeded && !(endpoint === '/create_session' && responseData.session_id)) {\n const errorMessage = responseData.error || 'Request failed';\n console.error('API request failed:', errorMessage);\n throw new Error(errorMessage);\n }\n return responseData as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const errorMessage = error.response?.data?.error || error.message;\n console.error('Axios error:', {\n status: error.response?.status,\n statusText: error.response?.statusText,\n data: error.response?.data,\n message: errorMessage\n });\n throw new Error(`Request failed: ${errorMessage}`);\n }\n console.error('Unexpected error:', error);\n throw error;\n }\n }\n\n async createSession(\n showInConsole: boolean = true,\n proxies: boolean = true,\n workflowName?: string,\n sessionData?: SessionData | string\n ): Promise<[string, string]> {\n const data: any = {\n proxies,\n workflow_name: workflowName\n };\n\n if (this.sessionId) {\n throw new Error(\"A session is already active. Please close the current session before creating a new one.\");\n }\n if (sessionData) {\n if (typeof sessionData === 'string') {\n try {\n data.session_data = JSON.stringify(JSON.parse(sessionData));\n } catch {\n // If parsing fails, treat as file path\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n }\n } else {\n data.session_data = JSON.stringify(sessionData);\n }\n }\n\n const response = await this.makeRequest<SimplexResponse>('post', '/create_session', data);\n \n if (!response.session_id) {\n throw new Error('Session creation failed: No session ID returned');\n }\n\n this.sessionId = response.session_id;\n this.connectUrl = response.connect_url || null;\n\n if (showInConsole && response.livestream_url) {\n console.log(`Livestream URL: ${response.livestream_url}`);\n }\n\n return [response.session_id, response.livestream_url || ''];\n }\n\n async goto(url: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling goto with url='${url}'`);\n }\n\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\n url = 'https://' + url;\n }\n\n const data = {\n url,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/goto', data);\n }\n\n async click(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling click with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click', data);\n return response.element_clicked || '';\n }\n\n async scrollToElement(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling scrollToElement with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/scroll_to_element', data);\n return response.element_info || '';\n }\n\n async hover(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling hover with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/hover', data);\n return response.element_info || '';\n }\n\n async type(text: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling type with text='${text}'`);\n }\n\n const data = {\n text,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/type', data);\n }\n\n async pressEnter(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressEnter');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_enter', data);\n }\n\n async pressTab(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressTab');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_tab', data);\n }\n\n async deleteText(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling deleteText');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/delete_text', data);\n }\n\n async extractBbox(elementDescription: string, cdpUrl?: string): Promise<any> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractBbox with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-bbox', undefined, params);\n return response.bbox;\n }\n\n async extractText(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractText with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/extract-text', data);\n return response.text || '';\n }\n\n async extractImage(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractImage with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-image', undefined, params);\n return response.image || '';\n }\n\n async scroll(pixels: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling scroll with pixels=${pixels}`);\n }\n\n const data = {\n pixels,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/scroll', data);\n }\n\n async wait(milliseconds: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling wait with milliseconds=${milliseconds}`);\n }\n\n const data = {\n milliseconds,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/wait', data);\n }\n\n async clickAndUpload(\n elementDescription: string,\n filePathOrCallable: string | (() => Blob)\n ): Promise<void> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${elementDescription}'`);\n }\n\n if (typeof filePathOrCallable !== 'string' && typeof filePathOrCallable !== 'function') {\n throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof filePathOrCallable}`);\n }\n\n const formData = new FormData();\n formData.append('element_description', elementDescription);\n formData.append('session_id', this.sessionId);\n\n if (typeof filePathOrCallable === 'string') {\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n } else {\n const blob = filePathOrCallable();\n formData.append('file', blob, 'file'); // Add filename for the blob\n }\n\n await this.makeRequest('post', '/click_and_upload', formData, undefined);\n }\n\n async clickAndDownload(elementDescription: string): Promise<[string, string]> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n session_id: this.sessionId\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click_and_download', data);\n return [response.b64 || '', response.filename || ''];\n }\n\n async exists(elementDescription: string, cdpUrl?: string): Promise<[boolean, string]> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling exists with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/exists', data);\n return [response.exists || false, response.reasoning || ''];\n }\n\n async getNetworkResponse(url: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling getNetworkResponse with url='${url}'`);\n }\n\n const data = {\n url,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/get_network_response', data);\n return response.response || '';\n }\n\n async closeSession(): Promise<void> {\n if (!this.sessionId) {\n return;\n }\n\n await this.makeRequest('post', '/close_session', { session_id: this.sessionId });\n this.sessionId = null;\n this.connectUrl = null;\n }\n} "],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,mBAAkB;AALX,SAAS,MAAM,MAAsB;AAC1C,SAAO,UAAU,IAAI;AACvB;AAMA,IAAM,WAAW;AAiCV,IAAM,UAAN,MAAc;AAAA,EAKnB,YAAY,QAAgB;AAH5B,SAAQ,YAA2B;AACnC,SAAQ,aAA4B;AAGlC,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAc,YACZ,QACA,UACA,MACA,QACY;AACZ,QAAI;AACF,cAAQ,IAAI,UAAU,OAAO,YAAY,CAAC,eAAe,QAAQ,EAAE;AAGnE,YAAM,WAAW,IAAI,SAAS;AAC9B,UAAI,MAAM;AACR,eAAO,QAAQ,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC7C,cAAI,UAAU,UAAa,UAAU,MAAM;AACzC,qBAAS,OAAO,KAAK,MAAM,SAAS,CAAC;AAAA,UACvC;AAAA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AAM,OAAO;AAAA,MACX,qBAAqB;AAAA,MACrB,YAAY,KAAK;AAAA,IACnB;AAEA,UAAM,WAAW,MAAM,KAAK,YAA6B,QAAQ,uBAAuB,IAAI;AAC5F,WAAO,CAAC,SAAS,OAAO,IAAI,SAAS,YAAY,EAAE;AAAA,EACrD;AAAA,EAEA,MAAM,OAAO,oBAA4B,QAA6C;AACpF,QAAI,CAAC,UAAU,CAAC,KAAK,WAAW;AAC9B,YAAM,IAAI,MAAM,0EAA0E,kBAAkB,GAAG;AAAA,IACjH;AAEA,UAAM,OAAO;AAAA,MACX,qBAAqB;AAAA,MACrB,GAAI,SAAS,EAAE,SAAS,OAAO,IAAI,EAAE,YAAY,KAAK,UAAU;AAAA,IAClE;AAEA,UAAM,WAAW,MAAM,KAAK,YAA6B,QAAQ,WAAW,IAAI;AAChF,WAAO,CAAC,SAAS,UAAU,OAAO,SAAS,aAAa,EAAE;AAAA,EAC5D;AAAA,EAEA,MAAM,mBAAmB,KAAa,QAAkC;AACtE,QAAI,CAAC,UAAU,CAAC,KAAK,WAAW;AAC9B,YAAM,IAAI,MAAM,uEAAuE,GAAG,GAAG;AAAA,IAC/F;AAEA,UAAM,OAAO;AAAA,MACX;AAAA,MACA,GAAI,SAAS,EAAE,SAAS,OAAO,IAAI,EAAE,YAAY,KAAK,UAAU;AAAA,IAClE;AAEA,UAAM,WAAW,MAAM,KAAK,YAA6B,QAAQ,yBAAyB,IAAI;AAC9F,WAAO,SAAS,YAAY;AAAA,EAC9B;AAAA,EAEA,MAAM,eAA8B;AAClC,QAAI,CAAC,KAAK,WAAW;AACnB;AAAA,IACF;AAEA,UAAM,KAAK,YAAY,QAAQ,kBAAkB,EAAE,YAAY,KAAK,UAAU,CAAC;AAC/E,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AACF;","names":["axios"]}
package/dist/index.mjs CHANGED
@@ -1,3 +1,310 @@
1
- import l from'axios';var p="https://api.simplex.sh",d=class{constructor(s){this.sessionId=null;this.connectUrl=null;this.apiKey=s;}async makeRequest(s,e,t,i){try{console.log(`Making ${s.toUpperCase()} request to ${e}`);let n=new FormData;t&&Object.entries(t).forEach(([a,c])=>{c!=null&&n.append(a,c.toString());}),console.log("Request data:",t);let o=await l({method:s,url:`${p}${e}`,data:s==="post"?n:void 0,params:s==="get"?i:void 0,headers:{"x-api-key":this.apiKey,...s==="post"?{"Content-Type":"multipart/form-data"}:{}}});console.log("Response status:",o.status),console.log("Response data:",JSON.stringify(o.data,null,2));let r=o.data;if(!r.succeeded&&!(e==="/create_session"&&r.session_id)){let a=r.error||"Request failed";throw console.error("API request failed:",a),new Error(a)}return r}catch(n){if(l.isAxiosError(n)){let o=n.response?.data?.error||n.message;throw console.error("Axios error:",{status:n.response?.status,statusText:n.response?.statusText,data:n.response?.data,message:o}),new Error(`Request failed: ${o}`)}throw console.error("Unexpected error:",n),n}}async createSession(s=true,e=true,t,i){let n={proxies:e,workflow_name:t};if(this.sessionId)throw new Error("A session is already active. Please close the current session before creating a new one.");if(i)if(typeof i=="string")try{n.session_data=JSON.stringify(JSON.parse(i));}catch{throw new Error("File system operations are not supported in this environment")}else n.session_data=JSON.stringify(i);let o=await this.makeRequest("post","/create_session",n);if(!o.session_id)throw new Error("Session creation failed: No session ID returned");return this.sessionId=o.session_id,this.connectUrl=o.connect_url||null,s&&o.livestream_url&&console.log(`Livestream URL: ${o.livestream_url}`),[o.session_id,o.livestream_url||""]}async goto(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling goto with url='${s}'`);!s.startsWith("http://")&&!s.startsWith("https://")&&(s="https://"+s);let t={url:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/goto",t);}async click(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling click with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("post","/click",t)).element_clicked||""}async type(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling type with text='${s}'`);let t={text:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/type",t);}async pressEnter(s){if(!s&&!this.sessionId)throw new Error("Must call createSession before calling pressEnter");let e=s?{cdp_url:s}:{session_id:this.sessionId};await this.makeRequest("post","/press_enter",e);}async pressTab(s){if(!s&&!this.sessionId)throw new Error("Must call createSession before calling pressTab");let e=s?{cdp_url:s}:{session_id:this.sessionId};await this.makeRequest("post","/press_tab",e);}async deleteText(s){if(!s&&!this.sessionId)throw new Error("Must call createSession before calling deleteText");let e=s?{cdp_url:s}:{session_id:this.sessionId};await this.makeRequest("post","/delete_text",e);}async extractBbox(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling extractBbox with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("get","/extract-bbox",void 0,t)).bbox}async extractText(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling extractText with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("post","/extract-text",t)).text||""}async extractImage(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling extractImage with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}};return (await this.makeRequest("get","/extract-image",void 0,t)).image||""}async scroll(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling scroll with pixels=${s}`);let t={pixels:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/scroll",t);}async wait(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling wait with milliseconds=${s}`);let t={milliseconds:s,...e?{cdp_url:e}:{session_id:this.sessionId}};await this.makeRequest("post","/wait",t);}async clickAndUpload(s,e){if(!this.sessionId)throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${s}'`);if(typeof e!="string"&&typeof e!="function")throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof e}`);let t=new FormData;if(t.append("element_description",s),t.append("session_id",this.sessionId),typeof e=="string")throw new Error("File system operations are not supported in this environment");{let i=e();t.append("file",i,"file");}await this.makeRequest("post","/click_and_upload",t,void 0);}async clickAndDownload(s){if(!this.sessionId)throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${s}'`);let e={element_description:s,session_id:this.sessionId},t=await this.makeRequest("post","/click_and_download",e);return [t.b64||"",t.filename||""]}async exists(s,e){if(!e&&!this.sessionId)throw new Error(`Must call createSession before calling exists with elementDescription='${s}'`);let t={element_description:s,...e?{cdp_url:e}:{session_id:this.sessionId}},i=await this.makeRequest("post","/exists",t);return [i.exists||false,i.reasoning||""]}async closeSession(){this.sessionId&&(await this.makeRequest("post","/close_session",{session_id:this.sessionId}),this.sessionId=null,this.connectUrl=null);}};
2
- export{d as Simplex};//# sourceMappingURL=index.mjs.map
1
+ // src/index.ts
2
+ import axios from "axios";
3
+ function greet(name) {
4
+ return `Hello, ${name}!`;
5
+ }
6
+ var BASE_URL = "https://simplex-dev-shreya--api-server-fastapi-app.modal.run";
7
+ var Simplex = class {
8
+ constructor(apiKey) {
9
+ this.sessionId = null;
10
+ this.connectUrl = null;
11
+ this.apiKey = apiKey;
12
+ }
13
+ async makeRequest(method, endpoint, data, params) {
14
+ try {
15
+ console.log(`Making ${method.toUpperCase()} request to ${endpoint}`);
16
+ const formData = new FormData();
17
+ if (data) {
18
+ Object.entries(data).forEach(([key, value]) => {
19
+ if (value !== void 0 && value !== null) {
20
+ formData.append(key, value.toString());
21
+ }
22
+ });
23
+ }
24
+ const response = await axios({
25
+ method,
26
+ url: `${BASE_URL}${endpoint}`,
27
+ data: method === "post" ? formData : void 0,
28
+ params: method === "get" ? params : void 0,
29
+ headers: {
30
+ "x-api-key": this.apiKey,
31
+ ...method === "post" ? { "Content-Type": "multipart/form-data" } : {}
32
+ }
33
+ });
34
+ const responseData = response.data;
35
+ if (endpoint == "/hover" || endpoint == "/scroll_to_element") {
36
+ if (!("succeeded" in responseData)) {
37
+ console.error("Response data missing 'succeeded' property:", responseData);
38
+ throw new Error("Invalid API response: missing 'succeeded' property");
39
+ } else {
40
+ if (responseData.succeeded) {
41
+ return responseData;
42
+ } else {
43
+ throw new Error(responseData.error || "Request failed");
44
+ }
45
+ }
46
+ }
47
+ if (endpoint == "/goto") {
48
+ if (!("succeeded" in responseData)) {
49
+ console.error('Response data missing "succeeded" property:', responseData);
50
+ throw new Error('Invalid API response: missing "succeeded" property');
51
+ } else {
52
+ return responseData;
53
+ }
54
+ }
55
+ if (endpoint == "/get_network_response") {
56
+ if (!("status" in responseData)) {
57
+ console.error('Response data missing "status" property:', responseData);
58
+ throw new Error('Invalid API response: missing "status" property');
59
+ } else if (responseData.status == "success") {
60
+ return responseData;
61
+ } else {
62
+ throw new Error("Failed to get network response");
63
+ }
64
+ }
65
+ if (!responseData.succeeded && !(endpoint === "/create_session" && responseData.session_id)) {
66
+ const errorMessage = responseData.error || "Request failed";
67
+ console.error("API request failed:", errorMessage);
68
+ throw new Error(errorMessage);
69
+ }
70
+ return responseData;
71
+ } catch (error) {
72
+ if (axios.isAxiosError(error)) {
73
+ const errorMessage = error.response?.data?.error || error.message;
74
+ console.error("Axios error:", {
75
+ status: error.response?.status,
76
+ statusText: error.response?.statusText,
77
+ data: error.response?.data,
78
+ message: errorMessage
79
+ });
80
+ throw new Error(`Request failed: ${errorMessage}`);
81
+ }
82
+ console.error("Unexpected error:", error);
83
+ throw error;
84
+ }
85
+ }
86
+ async createSession(showInConsole = true, proxies = true, workflowName, sessionData) {
87
+ const data = {
88
+ proxies,
89
+ workflow_name: workflowName
90
+ };
91
+ if (this.sessionId) {
92
+ throw new Error("A session is already active. Please close the current session before creating a new one.");
93
+ }
94
+ if (sessionData) {
95
+ if (typeof sessionData === "string") {
96
+ try {
97
+ data.session_data = JSON.stringify(JSON.parse(sessionData));
98
+ } catch {
99
+ throw new Error("File system operations are not supported in this environment");
100
+ }
101
+ } else {
102
+ data.session_data = JSON.stringify(sessionData);
103
+ }
104
+ }
105
+ const response = await this.makeRequest("post", "/create_session", data);
106
+ if (!response.session_id) {
107
+ throw new Error("Session creation failed: No session ID returned");
108
+ }
109
+ this.sessionId = response.session_id;
110
+ this.connectUrl = response.connect_url || null;
111
+ if (showInConsole && response.livestream_url) {
112
+ console.log(`Livestream URL: ${response.livestream_url}`);
113
+ }
114
+ return [response.session_id, response.livestream_url || ""];
115
+ }
116
+ async goto(url, cdpUrl) {
117
+ if (!cdpUrl && !this.sessionId) {
118
+ throw new Error(`Must call createSession before calling goto with url='${url}'`);
119
+ }
120
+ if (!url.startsWith("http://") && !url.startsWith("https://")) {
121
+ url = "https://" + url;
122
+ }
123
+ const data = {
124
+ url,
125
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
126
+ };
127
+ await this.makeRequest("post", "/goto", data);
128
+ }
129
+ async click(elementDescription, cdpUrl) {
130
+ if (!cdpUrl && !this.sessionId) {
131
+ throw new Error(`Must call createSession before calling click with elementDescription='${elementDescription}'`);
132
+ }
133
+ const data = {
134
+ element_description: elementDescription,
135
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
136
+ };
137
+ const response = await this.makeRequest("post", "/click", data);
138
+ return response.element_clicked || "";
139
+ }
140
+ async scrollToElement(elementDescription, cdpUrl) {
141
+ if (!cdpUrl && !this.sessionId) {
142
+ throw new Error(`Must call createSession before calling scrollToElement with elementDescription='${elementDescription}'`);
143
+ }
144
+ const data = {
145
+ element_description: elementDescription,
146
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
147
+ };
148
+ const response = await this.makeRequest("post", "/scroll_to_element", data);
149
+ return response.element_info || "";
150
+ }
151
+ async hover(elementDescription, cdpUrl) {
152
+ if (!cdpUrl && !this.sessionId) {
153
+ throw new Error(`Must call createSession before calling hover with elementDescription='${elementDescription}'`);
154
+ }
155
+ const data = {
156
+ element_description: elementDescription,
157
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
158
+ };
159
+ const response = await this.makeRequest("post", "/hover", data);
160
+ return response.element_info || "";
161
+ }
162
+ async type(text, cdpUrl) {
163
+ if (!cdpUrl && !this.sessionId) {
164
+ throw new Error(`Must call createSession before calling type with text='${text}'`);
165
+ }
166
+ const data = {
167
+ text,
168
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
169
+ };
170
+ await this.makeRequest("post", "/type", data);
171
+ }
172
+ async pressEnter(cdpUrl) {
173
+ if (!cdpUrl && !this.sessionId) {
174
+ throw new Error("Must call createSession before calling pressEnter");
175
+ }
176
+ const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };
177
+ await this.makeRequest("post", "/press_enter", data);
178
+ }
179
+ async pressTab(cdpUrl) {
180
+ if (!cdpUrl && !this.sessionId) {
181
+ throw new Error("Must call createSession before calling pressTab");
182
+ }
183
+ const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };
184
+ await this.makeRequest("post", "/press_tab", data);
185
+ }
186
+ async deleteText(cdpUrl) {
187
+ if (!cdpUrl && !this.sessionId) {
188
+ throw new Error("Must call createSession before calling deleteText");
189
+ }
190
+ const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };
191
+ await this.makeRequest("post", "/delete_text", data);
192
+ }
193
+ async extractBbox(elementDescription, cdpUrl) {
194
+ if (!cdpUrl && !this.sessionId) {
195
+ throw new Error(`Must call createSession before calling extractBbox with elementDescription='${elementDescription}'`);
196
+ }
197
+ const params = {
198
+ element_description: elementDescription,
199
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
200
+ };
201
+ const response = await this.makeRequest("get", "/extract-bbox", void 0, params);
202
+ return response.bbox;
203
+ }
204
+ async extractText(elementDescription, cdpUrl) {
205
+ if (!cdpUrl && !this.sessionId) {
206
+ throw new Error(`Must call createSession before calling extractText with elementDescription='${elementDescription}'`);
207
+ }
208
+ const data = {
209
+ element_description: elementDescription,
210
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
211
+ };
212
+ const response = await this.makeRequest("post", "/extract-text", data);
213
+ return response.text || "";
214
+ }
215
+ async extractImage(elementDescription, cdpUrl) {
216
+ if (!cdpUrl && !this.sessionId) {
217
+ throw new Error(`Must call createSession before calling extractImage with elementDescription='${elementDescription}'`);
218
+ }
219
+ const params = {
220
+ element_description: elementDescription,
221
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
222
+ };
223
+ const response = await this.makeRequest("get", "/extract-image", void 0, params);
224
+ return response.image || "";
225
+ }
226
+ async scroll(pixels, cdpUrl) {
227
+ if (!cdpUrl && !this.sessionId) {
228
+ throw new Error(`Must call createSession before calling scroll with pixels=${pixels}`);
229
+ }
230
+ const data = {
231
+ pixels,
232
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
233
+ };
234
+ await this.makeRequest("post", "/scroll", data);
235
+ }
236
+ async wait(milliseconds, cdpUrl) {
237
+ if (!cdpUrl && !this.sessionId) {
238
+ throw new Error(`Must call createSession before calling wait with milliseconds=${milliseconds}`);
239
+ }
240
+ const data = {
241
+ milliseconds,
242
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
243
+ };
244
+ await this.makeRequest("post", "/wait", data);
245
+ }
246
+ async clickAndUpload(elementDescription, filePathOrCallable) {
247
+ if (!this.sessionId) {
248
+ throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${elementDescription}'`);
249
+ }
250
+ if (typeof filePathOrCallable !== "string" && typeof filePathOrCallable !== "function") {
251
+ throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof filePathOrCallable}`);
252
+ }
253
+ const formData = new FormData();
254
+ formData.append("element_description", elementDescription);
255
+ formData.append("session_id", this.sessionId);
256
+ if (typeof filePathOrCallable === "string") {
257
+ throw new Error("File system operations are not supported in this environment");
258
+ } else {
259
+ const blob = filePathOrCallable();
260
+ formData.append("file", blob, "file");
261
+ }
262
+ await this.makeRequest("post", "/click_and_upload", formData, void 0);
263
+ }
264
+ async clickAndDownload(elementDescription) {
265
+ if (!this.sessionId) {
266
+ throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${elementDescription}'`);
267
+ }
268
+ const data = {
269
+ element_description: elementDescription,
270
+ session_id: this.sessionId
271
+ };
272
+ const response = await this.makeRequest("post", "/click_and_download", data);
273
+ return [response.b64 || "", response.filename || ""];
274
+ }
275
+ async exists(elementDescription, cdpUrl) {
276
+ if (!cdpUrl && !this.sessionId) {
277
+ throw new Error(`Must call createSession before calling exists with elementDescription='${elementDescription}'`);
278
+ }
279
+ const data = {
280
+ element_description: elementDescription,
281
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
282
+ };
283
+ const response = await this.makeRequest("post", "/exists", data);
284
+ return [response.exists || false, response.reasoning || ""];
285
+ }
286
+ async getNetworkResponse(url, cdpUrl) {
287
+ if (!cdpUrl && !this.sessionId) {
288
+ throw new Error(`Must call createSession before calling getNetworkResponse with url='${url}'`);
289
+ }
290
+ const data = {
291
+ url,
292
+ ...cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId }
293
+ };
294
+ const response = await this.makeRequest("post", "/get_network_response", data);
295
+ return response.response || "";
296
+ }
297
+ async closeSession() {
298
+ if (!this.sessionId) {
299
+ return;
300
+ }
301
+ await this.makeRequest("post", "/close_session", { session_id: this.sessionId });
302
+ this.sessionId = null;
303
+ this.connectUrl = null;
304
+ }
305
+ };
306
+ export {
307
+ Simplex,
308
+ greet
309
+ };
3
310
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts"],"names":["BASE_URL","Simplex","apiKey","method","endpoint","data","params","formData","key","value","response","axios","responseData","errorMessage","error","showInConsole","proxies","workflowName","sessionData","url","cdpUrl","elementDescription","text","pixels","milliseconds","filePathOrCallable","blob"],"mappings":"qBAIA,IAAMA,CAAW,CAAA,wBAAA,CA+BJC,CAAN,CAAA,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AAE,UAAA,CAAY,IAAK,CAAA,SAAU,CAAC,CAAA,CAC/E,IAAK,CAAA,SAAA,CAAY,IACjB,CAAA,IAAA,CAAK,UAAa,CAAA,IAAA,EACpB,CACF","file":"index.mjs","sourcesContent":["// Export other functions and types here \n\nimport axios from 'axios';\n\nconst BASE_URL = \"https://api.simplex.sh\";\n\ninterface SessionData {\n [key: string]: any;\n}\n\ninterface PlaywrightClickOptions {\n locator: string;\n locatorType: string;\n exact?: boolean;\n elementIndex?: 'first' | 'last' | 'nth';\n nthIndex?: number;\n locatorOptions?: Record<string, any>;\n}\n\ninterface SimplexResponse {\n succeeded: boolean;\n error?: string;\n session_id?: string;\n livestream_url?: string;\n connect_url?: string;\n element_clicked?: string;\n text?: string;\n image?: string;\n bbox?: any;\n b64?: string;\n filename?: string;\n exists?: boolean;\n reasoning?: string;\n}\n\nexport class Simplex {\n private apiKey: string;\n private sessionId: string | null = null;\n private connectUrl: string | null = null;\n\n constructor(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n private async makeRequest<T>(\n method: 'get' | 'post',\n endpoint: string,\n data?: any,\n params?: any\n ): Promise<T> {\n try {\n console.log(`Making ${method.toUpperCase()} request to ${endpoint}`);\n \n // Convert data to FormData\n const formData = new FormData();\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n formData.append(key, value.toString());\n }\n });\n }\n\n console.log('Request data:', data);\n \n const response = await axios({\n method,\n url: `${BASE_URL}${endpoint}`,\n data: method === 'post' ? formData : undefined,\n params: method === 'get' ? params : undefined,\n headers: {\n 'x-api-key': this.apiKey,\n ...(method === 'post' ? { 'Content-Type': 'multipart/form-data' } : {})\n }\n });\n\n console.log('Response status:', response.status);\n console.log('Response data:', JSON.stringify(response.data, null, 2));\n\n const responseData = response.data as SimplexResponse;\n \n // Consider response successful if:\n // 1. It has succeeded: true, or\n // 2. It's a create_session response with a session_id\n if (!responseData.succeeded && !(endpoint === '/create_session' && responseData.session_id)) {\n const errorMessage = responseData.error || 'Request failed';\n console.error('API request failed:', errorMessage);\n throw new Error(errorMessage);\n }\n return responseData as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const errorMessage = error.response?.data?.error || error.message;\n console.error('Axios error:', {\n status: error.response?.status,\n statusText: error.response?.statusText,\n data: error.response?.data,\n message: errorMessage\n });\n throw new Error(`Request failed: ${errorMessage}`);\n }\n console.error('Unexpected error:', error);\n throw error;\n }\n }\n\n async createSession(\n showInConsole: boolean = true,\n proxies: boolean = true,\n workflowName?: string,\n sessionData?: SessionData | string\n ): Promise<[string, string]> {\n const data: any = {\n proxies,\n workflow_name: workflowName\n };\n\n if (this.sessionId) {\n throw new Error(\"A session is already active. Please close the current session before creating a new one.\");\n }\n if (sessionData) {\n if (typeof sessionData === 'string') {\n try {\n data.session_data = JSON.stringify(JSON.parse(sessionData));\n } catch {\n // If parsing fails, treat as file path\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n }\n } else {\n data.session_data = JSON.stringify(sessionData);\n }\n }\n\n const response = await this.makeRequest<SimplexResponse>('post', '/create_session', data);\n \n if (!response.session_id) {\n throw new Error('Session creation failed: No session ID returned');\n }\n\n this.sessionId = response.session_id;\n this.connectUrl = response.connect_url || null;\n\n if (showInConsole && response.livestream_url) {\n console.log(`Livestream URL: ${response.livestream_url}`);\n }\n\n return [response.session_id, response.livestream_url || ''];\n }\n\n async goto(url: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling goto with url='${url}'`);\n }\n\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\n url = 'https://' + url;\n }\n\n const data = {\n url,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/goto', data);\n }\n\n async click(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling click with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click', data);\n return response.element_clicked || '';\n }\n\n async type(text: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling type with text='${text}'`);\n }\n\n const data = {\n text,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/type', data);\n }\n\n async pressEnter(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressEnter');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_enter', data);\n }\n\n async pressTab(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressTab');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_tab', data);\n }\n\n async deleteText(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling deleteText');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/delete_text', data);\n }\n\n async extractBbox(elementDescription: string, cdpUrl?: string): Promise<any> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractBbox with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-bbox', undefined, params);\n return response.bbox;\n }\n\n async extractText(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractText with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/extract-text', data);\n return response.text || '';\n }\n\n async extractImage(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractImage with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-image', undefined, params);\n return response.image || '';\n }\n\n async scroll(pixels: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling scroll with pixels=${pixels}`);\n }\n\n const data = {\n pixels,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/scroll', data);\n }\n\n async wait(milliseconds: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling wait with milliseconds=${milliseconds}`);\n }\n\n const data = {\n milliseconds,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/wait', data);\n }\n\n async clickAndUpload(\n elementDescription: string,\n filePathOrCallable: string | (() => Blob)\n ): Promise<void> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${elementDescription}'`);\n }\n\n if (typeof filePathOrCallable !== 'string' && typeof filePathOrCallable !== 'function') {\n throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof filePathOrCallable}`);\n }\n\n const formData = new FormData();\n formData.append('element_description', elementDescription);\n formData.append('session_id', this.sessionId);\n\n if (typeof filePathOrCallable === 'string') {\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n } else {\n const blob = filePathOrCallable();\n formData.append('file', blob, 'file'); // Add filename for the blob\n }\n\n await this.makeRequest('post', '/click_and_upload', formData, undefined);\n }\n\n async clickAndDownload(elementDescription: string): Promise<[string, string]> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n session_id: this.sessionId\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click_and_download', data);\n return [response.b64 || '', response.filename || ''];\n }\n\n async exists(elementDescription: string, cdpUrl?: string): Promise<[boolean, string]> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling exists with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/exists', data);\n return [response.exists || false, response.reasoning || ''];\n }\n\n async closeSession(): Promise<void> {\n if (!this.sessionId) {\n return;\n }\n\n await this.makeRequest('post', '/close_session', { session_id: this.sessionId });\n this.sessionId = null;\n this.connectUrl = null;\n }\n} "]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["/**\n * Example function to demonstrate package usage\n * @param name - The name to greet\n * @returns A greeting message\n */\nexport function greet(name: string): string {\n return `Hello, ${name}!`;\n}\n\n// Export other functions and types here \nimport axios from 'axios';\n\n// const BASE_URL = \"https://api.simplex.sh\"\nconst BASE_URL = \"https://simplex-dev-shreya--api-server-fastapi-app.modal.run\"\n\ninterface SessionData {\n [key: string]: any;\n}\n\ninterface PlaywrightClickOptions {\n locator: string;\n locatorType: string;\n exact?: boolean;\n elementIndex?: 'first' | 'last' | 'nth';\n nthIndex?: number;\n locatorOptions?: Record<string, any>;\n}\n\ninterface SimplexResponse {\n succeeded: boolean;\n error?: string;\n session_id?: string;\n livestream_url?: string;\n connect_url?: string;\n element_clicked?: string;\n element_info?: string;\n text?: string;\n image?: string;\n bbox?: any;\n b64?: string;\n filename?: string;\n exists?: boolean;\n reasoning?: string;\n response?: string;\n}\n\nexport class Simplex {\n private apiKey: string;\n private sessionId: string | null = null;\n private connectUrl: string | null = null;\n\n constructor(apiKey: string) {\n this.apiKey = apiKey;\n }\n\n private async makeRequest<T>(\n method: 'get' | 'post',\n endpoint: string,\n data?: any,\n params?: any\n ): Promise<T> {\n try {\n console.log(`Making ${method.toUpperCase()} request to ${endpoint}`);\n \n // Convert data to FormData\n const formData = new FormData();\n if (data) {\n Object.entries(data).forEach(([key, value]) => {\n if (value !== undefined && value !== null) {\n formData.append(key, value.toString());\n }\n });\n }\n\n // console.log('Request data:', Object.fromEntries(formData.entries()));\n \n const response = await axios({\n method,\n url: `${BASE_URL}${endpoint}`,\n data: method === 'post' ? formData : undefined,\n params: method === 'get' ? params : undefined,\n headers: {\n 'x-api-key': this.apiKey,\n ...(method === 'post' ? { 'Content-Type': 'multipart/form-data' } : {})\n }\n });\n\n // console.log('Response status:', response.status);\n // console.log('Response data:', JSON.stringify(response.data, null, 2));\n\n const responseData = response.data as SimplexResponse;\n \n // Consider response successful if:\n // 1. It has succeeded: true, or\n // 2. It's a create_session response with a session_id\n // Check if 'succeeded' property exists in responseData\n // console.log('Response data:', responseData);\n\n if (endpoint == \"/hover\" || endpoint == \"/scroll_to_element\") {\n if (!('succeeded' in responseData)) {\n console.error(\"Response data missing 'succeeded' property:\", responseData);\n throw new Error(\"Invalid API response: missing 'succeeded' property\");\n } else {\n if (responseData.succeeded) {\n return responseData as T;\n } else {\n throw new Error(responseData.error || 'Request failed');\n }\n }\n }\n\n if (endpoint == \"/goto\") {\n if (!('succeeded' in responseData)) {\n console.error('Response data missing \"succeeded\" property:', responseData);\n throw new Error('Invalid API response: missing \"succeeded\" property');\n } else {\n return responseData as T;\n }\n }\n\n if (endpoint == \"/get_network_response\") {\n if (!('status' in responseData)) {\n console.error('Response data missing \"status\" property:', responseData);\n throw new Error('Invalid API response: missing \"status\" property');\n } else if (responseData.status == \"success\") {\n return responseData as T;\n } else {\n throw new Error('Failed to get network response');\n }\n }\n\n if (!responseData.succeeded && !(endpoint === '/create_session' && responseData.session_id)) {\n const errorMessage = responseData.error || 'Request failed';\n console.error('API request failed:', errorMessage);\n throw new Error(errorMessage);\n }\n return responseData as T;\n } catch (error) {\n if (axios.isAxiosError(error)) {\n const errorMessage = error.response?.data?.error || error.message;\n console.error('Axios error:', {\n status: error.response?.status,\n statusText: error.response?.statusText,\n data: error.response?.data,\n message: errorMessage\n });\n throw new Error(`Request failed: ${errorMessage}`);\n }\n console.error('Unexpected error:', error);\n throw error;\n }\n }\n\n async createSession(\n showInConsole: boolean = true,\n proxies: boolean = true,\n workflowName?: string,\n sessionData?: SessionData | string\n ): Promise<[string, string]> {\n const data: any = {\n proxies,\n workflow_name: workflowName\n };\n\n if (this.sessionId) {\n throw new Error(\"A session is already active. Please close the current session before creating a new one.\");\n }\n if (sessionData) {\n if (typeof sessionData === 'string') {\n try {\n data.session_data = JSON.stringify(JSON.parse(sessionData));\n } catch {\n // If parsing fails, treat as file path\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n }\n } else {\n data.session_data = JSON.stringify(sessionData);\n }\n }\n\n const response = await this.makeRequest<SimplexResponse>('post', '/create_session', data);\n \n if (!response.session_id) {\n throw new Error('Session creation failed: No session ID returned');\n }\n\n this.sessionId = response.session_id;\n this.connectUrl = response.connect_url || null;\n\n if (showInConsole && response.livestream_url) {\n console.log(`Livestream URL: ${response.livestream_url}`);\n }\n\n return [response.session_id, response.livestream_url || ''];\n }\n\n async goto(url: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling goto with url='${url}'`);\n }\n\n if (!url.startsWith('http://') && !url.startsWith('https://')) {\n url = 'https://' + url;\n }\n\n const data = {\n url,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/goto', data);\n }\n\n async click(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling click with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click', data);\n return response.element_clicked || '';\n }\n\n async scrollToElement(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling scrollToElement with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/scroll_to_element', data);\n return response.element_info || '';\n }\n\n async hover(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling hover with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/hover', data);\n return response.element_info || '';\n }\n\n async type(text: string, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling type with text='${text}'`);\n }\n\n const data = {\n text,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/type', data);\n }\n\n async pressEnter(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressEnter');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_enter', data);\n }\n\n async pressTab(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling pressTab');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/press_tab', data);\n }\n\n async deleteText(cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error('Must call createSession before calling deleteText');\n }\n\n const data = cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId };\n await this.makeRequest('post', '/delete_text', data);\n }\n\n async extractBbox(elementDescription: string, cdpUrl?: string): Promise<any> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractBbox with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-bbox', undefined, params);\n return response.bbox;\n }\n\n async extractText(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractText with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/extract-text', data);\n return response.text || '';\n }\n\n async extractImage(elementDescription: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling extractImage with elementDescription='${elementDescription}'`);\n }\n\n const params = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('get', '/extract-image', undefined, params);\n return response.image || '';\n }\n\n async scroll(pixels: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling scroll with pixels=${pixels}`);\n }\n\n const data = {\n pixels,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/scroll', data);\n }\n\n async wait(milliseconds: number, cdpUrl?: string): Promise<void> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling wait with milliseconds=${milliseconds}`);\n }\n\n const data = {\n milliseconds,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n await this.makeRequest('post', '/wait', data);\n }\n\n async clickAndUpload(\n elementDescription: string,\n filePathOrCallable: string | (() => Blob)\n ): Promise<void> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndUpload with elementDescription='${elementDescription}'`);\n }\n\n if (typeof filePathOrCallable !== 'string' && typeof filePathOrCallable !== 'function') {\n throw new TypeError(`filePathOrCallable must be either a string or a callable, not a ${typeof filePathOrCallable}`);\n }\n\n const formData = new FormData();\n formData.append('element_description', elementDescription);\n formData.append('session_id', this.sessionId);\n\n if (typeof filePathOrCallable === 'string') {\n // Note: File system operations are not available in browser environment\n throw new Error('File system operations are not supported in this environment');\n } else {\n const blob = filePathOrCallable();\n formData.append('file', blob, 'file'); // Add filename for the blob\n }\n\n await this.makeRequest('post', '/click_and_upload', formData, undefined);\n }\n\n async clickAndDownload(elementDescription: string): Promise<[string, string]> {\n if (!this.sessionId) {\n throw new Error(`Must call createSession before calling clickAndDownload with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n session_id: this.sessionId\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/click_and_download', data);\n return [response.b64 || '', response.filename || ''];\n }\n\n async exists(elementDescription: string, cdpUrl?: string): Promise<[boolean, string]> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling exists with elementDescription='${elementDescription}'`);\n }\n\n const data = {\n element_description: elementDescription,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/exists', data);\n return [response.exists || false, response.reasoning || ''];\n }\n\n async getNetworkResponse(url: string, cdpUrl?: string): Promise<string> {\n if (!cdpUrl && !this.sessionId) {\n throw new Error(`Must call createSession before calling getNetworkResponse with url='${url}'`);\n }\n\n const data = {\n url,\n ...(cdpUrl ? { cdp_url: cdpUrl } : { session_id: this.sessionId })\n };\n\n const response = await this.makeRequest<SimplexResponse>('post', '/get_network_response', data);\n return response.response || '';\n }\n\n async closeSession(): Promise<void> {\n if (!this.sessionId) {\n return;\n }\n\n await this.makeRequest('post', '/close_session', { session_id: this.sessionId });\n this.sessionId = null;\n this.connectUrl = null;\n }\n} "],"mappings":";AAUA,OAAO,WAAW;AALX,SAAS,MAAM,MAAsB;AAC1C,SAAO,UAAU,IAAI;AACvB;AAMA,IAAM,WAAW;AAiCV,IAAM,UAAN,MAAc;AAAA,EAKnB,YAAY,QAAgB;AAH5B,SAAQ,YAA2B;AACnC,SAAQ,aAA4B;AAGlC,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAc,YACZ,QACA,UACA,MACA,QACY;AACZ,QAAI;AACF,cAAQ,IAAI,UAAU,OAAO,YAAY,CAAC,eAAe,QAAQ,EAAE;AAGnE,YAAM,WAAW,IAAI,SAAS;AAC9B,UAAI,MAAM;AACR,eAAO,QAAQ,IAAI,EAAE,QAAQ,CAAC,CAAC,KAAK,KAAK,MAAM;AAC7C,cAAI,UAAU,UAAa,UAAU,MAAM;AACzC,qBAAS,OAAO,KAAK,MAAM,SAAS,CAAC;AAAA,UACvC;AAAA,QACF,CAAC;AAAA,MACH;AAIA,YAAM,WAAW,MAAM,MAAM;AAAA,QAC3B;AAAA,QACA,KAAK,GAAG,QAAQ,GAAG,QAAQ;AAAA,QAC3B,MAAM,WAAW,SAAS,WAAW;AAAA,QACrC,QAAQ,WAAW,QAAQ,SAAS;AAAA,QACpC,SAAS;AAAA,UACP,aAAa,KAAK;AAAA,UAClB,GAAI,WAAW,SAAS,EAAE,gBAAgB,sBAAsB,IAAI,CAAC;AAAA,QACvE;AAAA,MACF,CAAC;AAKD,YAAM,eAAe,SAAS;AAQ9B,UAAI,YAAY,YAAY,YAAY,sBAAsB;AAC5D,YAAI,EAAE,eAAe,eAAe;AAClC,kBAAQ,MAAM,+CAA+C,YAAY;AACzE,gBAAM,IAAI,MAAM,oDAAoD;AAAA,QAC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AAI;AAChF,WAAO,CAAC,SAAS,UAAU,OAAO,SAAS,aAAa,EAAE;AAAA,EAC5D;AAAA,EAEA,MAAM,mBAAmB,KAAa,QAAkC;AACtE,QAAI,CAAC,UAAU,CAAC,KAAK,WAAW;AAC9B,YAAM,IAAI,MAAM,uEAAuE,GAAG,GAAG;AAAA,IAC/F;AAEA,UAAM,OAAO;AAAA,MACX;AAAA,MACA,GAAI,SAAS,EAAE,SAAS,OAAO,IAAI,EAAE,YAAY,KAAK,UAAU;AAAA,IAClE;AAEA,UAAM,WAAW,MAAM,KAAK,YAA6B,QAAQ,yBAAyB,IAAI;AAC9F,WAAO,SAAS,YAAY;AAAA,EAC9B;AAAA,EAEA,MAAM,eAA8B;AAClC,QAAI,CAAC,KAAK,WAAW;AACnB;AAAA,IACF;AAEA,UAAM,KAAK,YAAY,QAAQ,kBAAkB,EAAE,YAAY,KAAK,UAAU,CAAC;AAC/E,SAAK,YAAY;AACjB,SAAK,aAAa;AAAA,EACpB;AACF;","names":[]}
package/package.json CHANGED
@@ -1,17 +1,10 @@
1
1
  {
2
2
  "name": "simplex-ts",
3
- "version": "1.0.5",
4
- "description": "A TypeScript package for the Simplex API",
3
+ "version": "1.0.7",
4
+ "description": "A TypeScript package template",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/index.d.ts",
11
- "import": "./dist/index.mjs",
12
- "require": "./dist/index.js"
13
- }
14
- },
15
8
  "files": [
16
9
  "dist"
17
10
  ],
@@ -29,17 +22,16 @@
29
22
  "license": "MIT",
30
23
  "devDependencies": {
31
24
  "@types/jest": "^29.5.12",
32
- "@types/node": "^20.17.30",
33
- "glob": "^10.3.10",
25
+ "@types/node": "^20.11.19",
34
26
  "jest": "^29.7.0",
35
27
  "rimraf": "^5.0.5",
36
28
  "ts-jest": "^29.1.2",
37
- "ts-node": "^10.9.2",
38
29
  "tsup": "^8.0.2",
39
- "typescript": "^5.8.2"
30
+ "typescript": "^5.3.3",
31
+ "glob": "^10.3.10"
40
32
  },
41
33
  "dependencies": {
42
34
  "axios": "^1.6.7",
43
- "dotenv": "^16.4.7"
35
+ "dotenv": "^16.4.5"
44
36
  }
45
- }
37
+ }