notte-sdk 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs ADDED
@@ -0,0 +1,2761 @@
1
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
2
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
3
+ }) : x)(function(x) {
4
+ if (typeof require !== "undefined") return require.apply(this, arguments);
5
+ throw Error('Dynamic require of "' + x + '" is not supported');
6
+ });
7
+
8
+ // src/lib/client/core/bodySerializer.gen.ts
9
+ var serializeFormDataPair = (data, key, value) => {
10
+ if (typeof value === "string" || value instanceof Blob) {
11
+ data.append(key, value);
12
+ } else if (value instanceof Date) {
13
+ data.append(key, value.toISOString());
14
+ } else {
15
+ data.append(key, JSON.stringify(value));
16
+ }
17
+ };
18
+ var formDataBodySerializer = {
19
+ bodySerializer: (body) => {
20
+ const data = new FormData();
21
+ Object.entries(body).forEach(([key, value]) => {
22
+ if (value === void 0 || value === null) {
23
+ return;
24
+ }
25
+ if (Array.isArray(value)) {
26
+ value.forEach((v) => serializeFormDataPair(data, key, v));
27
+ } else {
28
+ serializeFormDataPair(data, key, value);
29
+ }
30
+ });
31
+ return data;
32
+ }
33
+ };
34
+ var jsonBodySerializer = {
35
+ bodySerializer: (body) => JSON.stringify(body, (_key, value) => typeof value === "bigint" ? value.toString() : value)
36
+ };
37
+
38
+ // src/lib/client/core/params.gen.ts
39
+ var extraPrefixesMap = {
40
+ $body_: "body",
41
+ $headers_: "headers",
42
+ $path_: "path",
43
+ $query_: "query"
44
+ };
45
+ var extraPrefixes = Object.entries(extraPrefixesMap);
46
+
47
+ // src/lib/client/core/serverSentEvents.gen.ts
48
+ var createSseClient = ({
49
+ onRequest,
50
+ onSseError,
51
+ onSseEvent,
52
+ responseTransformer,
53
+ responseValidator,
54
+ sseDefaultRetryDelay,
55
+ sseMaxRetryAttempts,
56
+ sseMaxRetryDelay,
57
+ sseSleepFn,
58
+ url,
59
+ ...options
60
+ }) => {
61
+ let lastEventId;
62
+ const sleep = sseSleepFn ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
63
+ const createStream = async function* () {
64
+ let retryDelay = sseDefaultRetryDelay ?? 3e3;
65
+ let attempt = 0;
66
+ const signal = options.signal ?? new AbortController().signal;
67
+ while (true) {
68
+ if (signal.aborted) break;
69
+ attempt++;
70
+ const headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers);
71
+ if (lastEventId !== void 0) {
72
+ headers.set("Last-Event-ID", lastEventId);
73
+ }
74
+ try {
75
+ const requestInit = {
76
+ redirect: "follow",
77
+ ...options,
78
+ body: options.serializedBody,
79
+ headers,
80
+ signal
81
+ };
82
+ let request = new Request(url, requestInit);
83
+ if (onRequest) {
84
+ request = await onRequest(url, requestInit);
85
+ }
86
+ const _fetch = options.fetch ?? globalThis.fetch;
87
+ const response = await _fetch(request);
88
+ if (!response.ok) throw new Error(`SSE failed: ${response.status} ${response.statusText}`);
89
+ if (!response.body) throw new Error("No body in SSE response");
90
+ const reader = response.body.pipeThrough(new TextDecoderStream()).getReader();
91
+ let buffer = "";
92
+ const abortHandler = () => {
93
+ try {
94
+ reader.cancel();
95
+ } catch {
96
+ }
97
+ };
98
+ signal.addEventListener("abort", abortHandler);
99
+ try {
100
+ while (true) {
101
+ const { done, value } = await reader.read();
102
+ if (done) break;
103
+ buffer += value;
104
+ buffer = buffer.replace(/\r\n/g, "\n").replace(/\r/g, "\n");
105
+ const chunks = buffer.split("\n\n");
106
+ buffer = chunks.pop() ?? "";
107
+ for (const chunk of chunks) {
108
+ const lines = chunk.split("\n");
109
+ const dataLines = [];
110
+ let eventName;
111
+ for (const line of lines) {
112
+ if (line.startsWith("data:")) {
113
+ dataLines.push(line.replace(/^data:\s*/, ""));
114
+ } else if (line.startsWith("event:")) {
115
+ eventName = line.replace(/^event:\s*/, "");
116
+ } else if (line.startsWith("id:")) {
117
+ lastEventId = line.replace(/^id:\s*/, "");
118
+ } else if (line.startsWith("retry:")) {
119
+ const parsed = Number.parseInt(line.replace(/^retry:\s*/, ""), 10);
120
+ if (!Number.isNaN(parsed)) {
121
+ retryDelay = parsed;
122
+ }
123
+ }
124
+ }
125
+ let data;
126
+ let parsedJson = false;
127
+ if (dataLines.length) {
128
+ const rawData = dataLines.join("\n");
129
+ try {
130
+ data = JSON.parse(rawData);
131
+ parsedJson = true;
132
+ } catch {
133
+ data = rawData;
134
+ }
135
+ }
136
+ if (parsedJson) {
137
+ if (responseValidator) {
138
+ await responseValidator(data);
139
+ }
140
+ if (responseTransformer) {
141
+ data = await responseTransformer(data);
142
+ }
143
+ }
144
+ onSseEvent?.({
145
+ data,
146
+ event: eventName,
147
+ id: lastEventId,
148
+ retry: retryDelay
149
+ });
150
+ if (dataLines.length) {
151
+ yield data;
152
+ }
153
+ }
154
+ }
155
+ } finally {
156
+ signal.removeEventListener("abort", abortHandler);
157
+ reader.releaseLock();
158
+ }
159
+ break;
160
+ } catch (error) {
161
+ onSseError?.(error);
162
+ if (sseMaxRetryAttempts !== void 0 && attempt >= sseMaxRetryAttempts) {
163
+ break;
164
+ }
165
+ const backoff = Math.min(retryDelay * 2 ** (attempt - 1), sseMaxRetryDelay ?? 3e4);
166
+ await sleep(backoff);
167
+ }
168
+ }
169
+ };
170
+ const stream = createStream();
171
+ return { stream };
172
+ };
173
+
174
+ // src/lib/client/core/pathSerializer.gen.ts
175
+ var separatorArrayExplode = (style) => {
176
+ switch (style) {
177
+ case "label":
178
+ return ".";
179
+ case "matrix":
180
+ return ";";
181
+ case "simple":
182
+ return ",";
183
+ default:
184
+ return "&";
185
+ }
186
+ };
187
+ var separatorArrayNoExplode = (style) => {
188
+ switch (style) {
189
+ case "form":
190
+ return ",";
191
+ case "pipeDelimited":
192
+ return "|";
193
+ case "spaceDelimited":
194
+ return "%20";
195
+ default:
196
+ return ",";
197
+ }
198
+ };
199
+ var separatorObjectExplode = (style) => {
200
+ switch (style) {
201
+ case "label":
202
+ return ".";
203
+ case "matrix":
204
+ return ";";
205
+ case "simple":
206
+ return ",";
207
+ default:
208
+ return "&";
209
+ }
210
+ };
211
+ var serializeArrayParam = ({
212
+ allowReserved,
213
+ explode,
214
+ name,
215
+ style,
216
+ value
217
+ }) => {
218
+ if (!explode) {
219
+ const joinedValues2 = (allowReserved ? value : value.map((v) => encodeURIComponent(v))).join(separatorArrayNoExplode(style));
220
+ switch (style) {
221
+ case "label":
222
+ return `.${joinedValues2}`;
223
+ case "matrix":
224
+ return `;${name}=${joinedValues2}`;
225
+ case "simple":
226
+ return joinedValues2;
227
+ default:
228
+ return `${name}=${joinedValues2}`;
229
+ }
230
+ }
231
+ const separator = separatorArrayExplode(style);
232
+ const joinedValues = value.map((v) => {
233
+ if (style === "label" || style === "simple") {
234
+ return allowReserved ? v : encodeURIComponent(v);
235
+ }
236
+ return serializePrimitiveParam({
237
+ allowReserved,
238
+ name,
239
+ value: v
240
+ });
241
+ }).join(separator);
242
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
243
+ };
244
+ var serializePrimitiveParam = ({
245
+ allowReserved,
246
+ name,
247
+ value
248
+ }) => {
249
+ if (value === void 0 || value === null) {
250
+ return "";
251
+ }
252
+ if (typeof value === "object") {
253
+ throw new Error(
254
+ "Deeply-nested arrays/objects aren\u2019t supported. Provide your own `querySerializer()` to handle these."
255
+ );
256
+ }
257
+ return `${name}=${allowReserved ? value : encodeURIComponent(value)}`;
258
+ };
259
+ var serializeObjectParam = ({
260
+ allowReserved,
261
+ explode,
262
+ name,
263
+ style,
264
+ value,
265
+ valueOnly
266
+ }) => {
267
+ if (value instanceof Date) {
268
+ return valueOnly ? value.toISOString() : `${name}=${value.toISOString()}`;
269
+ }
270
+ if (style !== "deepObject" && !explode) {
271
+ let values = [];
272
+ Object.entries(value).forEach(([key, v]) => {
273
+ values = [...values, key, allowReserved ? v : encodeURIComponent(v)];
274
+ });
275
+ const joinedValues2 = values.join(",");
276
+ switch (style) {
277
+ case "form":
278
+ return `${name}=${joinedValues2}`;
279
+ case "label":
280
+ return `.${joinedValues2}`;
281
+ case "matrix":
282
+ return `;${name}=${joinedValues2}`;
283
+ default:
284
+ return joinedValues2;
285
+ }
286
+ }
287
+ const separator = separatorObjectExplode(style);
288
+ const joinedValues = Object.entries(value).map(
289
+ ([key, v]) => serializePrimitiveParam({
290
+ allowReserved,
291
+ name: style === "deepObject" ? `${name}[${key}]` : key,
292
+ value: v
293
+ })
294
+ ).join(separator);
295
+ return style === "label" || style === "matrix" ? separator + joinedValues : joinedValues;
296
+ };
297
+
298
+ // src/lib/client/core/utils.gen.ts
299
+ var PATH_PARAM_RE = /\{[^{}]+\}/g;
300
+ var defaultPathSerializer = ({ path, url: _url }) => {
301
+ let url = _url;
302
+ const matches = _url.match(PATH_PARAM_RE);
303
+ if (matches) {
304
+ for (const match of matches) {
305
+ let explode = false;
306
+ let name = match.substring(1, match.length - 1);
307
+ let style = "simple";
308
+ if (name.endsWith("*")) {
309
+ explode = true;
310
+ name = name.substring(0, name.length - 1);
311
+ }
312
+ if (name.startsWith(".")) {
313
+ name = name.substring(1);
314
+ style = "label";
315
+ } else if (name.startsWith(";")) {
316
+ name = name.substring(1);
317
+ style = "matrix";
318
+ }
319
+ const value = path[name];
320
+ if (value === void 0 || value === null) {
321
+ continue;
322
+ }
323
+ if (Array.isArray(value)) {
324
+ url = url.replace(match, serializeArrayParam({ explode, name, style, value }));
325
+ continue;
326
+ }
327
+ if (typeof value === "object") {
328
+ url = url.replace(
329
+ match,
330
+ serializeObjectParam({
331
+ explode,
332
+ name,
333
+ style,
334
+ value,
335
+ valueOnly: true
336
+ })
337
+ );
338
+ continue;
339
+ }
340
+ if (style === "matrix") {
341
+ url = url.replace(
342
+ match,
343
+ `;${serializePrimitiveParam({
344
+ name,
345
+ value
346
+ })}`
347
+ );
348
+ continue;
349
+ }
350
+ const replaceValue = encodeURIComponent(
351
+ style === "label" ? `.${value}` : value
352
+ );
353
+ url = url.replace(match, replaceValue);
354
+ }
355
+ }
356
+ return url;
357
+ };
358
+ var getUrl = ({
359
+ baseUrl,
360
+ path,
361
+ query,
362
+ querySerializer,
363
+ url: _url
364
+ }) => {
365
+ const pathUrl = _url.startsWith("/") ? _url : `/${_url}`;
366
+ let url = (baseUrl ?? "") + pathUrl;
367
+ if (path) {
368
+ url = defaultPathSerializer({ path, url });
369
+ }
370
+ let search = query ? querySerializer(query) : "";
371
+ if (search.startsWith("?")) {
372
+ search = search.substring(1);
373
+ }
374
+ if (search) {
375
+ url += `?${search}`;
376
+ }
377
+ return url;
378
+ };
379
+ function getValidRequestBody(options) {
380
+ const hasBody = options.body !== void 0;
381
+ const isSerializedBody = hasBody && options.bodySerializer;
382
+ if (isSerializedBody) {
383
+ if ("serializedBody" in options) {
384
+ const hasSerializedBody = options.serializedBody !== void 0 && options.serializedBody !== "";
385
+ return hasSerializedBody ? options.serializedBody : null;
386
+ }
387
+ return options.body !== "" ? options.body : null;
388
+ }
389
+ if (hasBody) {
390
+ return options.body;
391
+ }
392
+ return void 0;
393
+ }
394
+
395
+ // src/lib/client/core/auth.gen.ts
396
+ var getAuthToken = async (auth, callback) => {
397
+ const token = typeof callback === "function" ? await callback(auth) : callback;
398
+ if (!token) {
399
+ return;
400
+ }
401
+ if (auth.scheme === "bearer") {
402
+ return `Bearer ${token}`;
403
+ }
404
+ if (auth.scheme === "basic") {
405
+ return `Basic ${btoa(token)}`;
406
+ }
407
+ return token;
408
+ };
409
+
410
+ // src/lib/client/client/utils.gen.ts
411
+ var createQuerySerializer = ({
412
+ parameters = {},
413
+ ...args
414
+ } = {}) => {
415
+ const querySerializer = (queryParams) => {
416
+ const search = [];
417
+ if (queryParams && typeof queryParams === "object") {
418
+ for (const name in queryParams) {
419
+ const value = queryParams[name];
420
+ if (value === void 0 || value === null) {
421
+ continue;
422
+ }
423
+ const options = parameters[name] || args;
424
+ if (Array.isArray(value)) {
425
+ const serializedArray = serializeArrayParam({
426
+ allowReserved: options.allowReserved,
427
+ explode: true,
428
+ name,
429
+ style: "form",
430
+ value,
431
+ ...options.array
432
+ });
433
+ if (serializedArray) search.push(serializedArray);
434
+ } else if (typeof value === "object") {
435
+ const serializedObject = serializeObjectParam({
436
+ allowReserved: options.allowReserved,
437
+ explode: true,
438
+ name,
439
+ style: "deepObject",
440
+ value,
441
+ ...options.object
442
+ });
443
+ if (serializedObject) search.push(serializedObject);
444
+ } else {
445
+ const serializedPrimitive = serializePrimitiveParam({
446
+ allowReserved: options.allowReserved,
447
+ name,
448
+ value
449
+ });
450
+ if (serializedPrimitive) search.push(serializedPrimitive);
451
+ }
452
+ }
453
+ }
454
+ return search.join("&");
455
+ };
456
+ return querySerializer;
457
+ };
458
+ var getParseAs = (contentType) => {
459
+ if (!contentType) {
460
+ return "stream";
461
+ }
462
+ const cleanContent = contentType.split(";")[0]?.trim();
463
+ if (!cleanContent) {
464
+ return;
465
+ }
466
+ if (cleanContent.startsWith("application/json") || cleanContent.endsWith("+json")) {
467
+ return "json";
468
+ }
469
+ if (cleanContent === "multipart/form-data") {
470
+ return "formData";
471
+ }
472
+ if (["application/", "audio/", "image/", "video/"].some((type) => cleanContent.startsWith(type))) {
473
+ return "blob";
474
+ }
475
+ if (cleanContent.startsWith("text/")) {
476
+ return "text";
477
+ }
478
+ return;
479
+ };
480
+ var checkForExistence = (options, name) => {
481
+ if (!name) {
482
+ return false;
483
+ }
484
+ if (options.headers.has(name) || options.query?.[name] || options.headers.get("Cookie")?.includes(`${name}=`)) {
485
+ return true;
486
+ }
487
+ return false;
488
+ };
489
+ var setAuthParams = async ({
490
+ security,
491
+ ...options
492
+ }) => {
493
+ for (const auth of security) {
494
+ if (checkForExistence(options, auth.name)) {
495
+ continue;
496
+ }
497
+ const token = await getAuthToken(auth, options.auth);
498
+ if (!token) {
499
+ continue;
500
+ }
501
+ const name = auth.name ?? "Authorization";
502
+ switch (auth.in) {
503
+ case "query":
504
+ if (!options.query) {
505
+ options.query = {};
506
+ }
507
+ options.query[name] = token;
508
+ break;
509
+ case "cookie":
510
+ options.headers.append("Cookie", `${name}=${token}`);
511
+ break;
512
+ case "header":
513
+ default:
514
+ options.headers.set(name, token);
515
+ break;
516
+ }
517
+ }
518
+ };
519
+ var buildUrl = (options) => getUrl({
520
+ baseUrl: options.baseUrl,
521
+ path: options.path,
522
+ query: options.query,
523
+ querySerializer: typeof options.querySerializer === "function" ? options.querySerializer : createQuerySerializer(options.querySerializer),
524
+ url: options.url
525
+ });
526
+ var mergeConfigs = (a, b) => {
527
+ const config = { ...a, ...b };
528
+ if (config.baseUrl?.endsWith("/")) {
529
+ config.baseUrl = config.baseUrl.substring(0, config.baseUrl.length - 1);
530
+ }
531
+ config.headers = mergeHeaders(a.headers, b.headers);
532
+ return config;
533
+ };
534
+ var headersEntries = (headers) => {
535
+ const entries = [];
536
+ headers.forEach((value, key) => {
537
+ entries.push([key, value]);
538
+ });
539
+ return entries;
540
+ };
541
+ var mergeHeaders = (...headers) => {
542
+ const mergedHeaders = new Headers();
543
+ for (const header of headers) {
544
+ if (!header) {
545
+ continue;
546
+ }
547
+ const iterator = header instanceof Headers ? headersEntries(header) : Object.entries(header);
548
+ for (const [key, value] of iterator) {
549
+ if (value === null) {
550
+ mergedHeaders.delete(key);
551
+ } else if (Array.isArray(value)) {
552
+ for (const v of value) {
553
+ mergedHeaders.append(key, v);
554
+ }
555
+ } else if (value !== void 0) {
556
+ mergedHeaders.set(
557
+ key,
558
+ typeof value === "object" ? JSON.stringify(value) : value
559
+ );
560
+ }
561
+ }
562
+ }
563
+ return mergedHeaders;
564
+ };
565
+ var Interceptors = class {
566
+ constructor() {
567
+ this.fns = [];
568
+ }
569
+ clear() {
570
+ this.fns = [];
571
+ }
572
+ eject(id) {
573
+ const index = this.getInterceptorIndex(id);
574
+ if (this.fns[index]) {
575
+ this.fns[index] = null;
576
+ }
577
+ }
578
+ exists(id) {
579
+ const index = this.getInterceptorIndex(id);
580
+ return Boolean(this.fns[index]);
581
+ }
582
+ getInterceptorIndex(id) {
583
+ if (typeof id === "number") {
584
+ return this.fns[id] ? id : -1;
585
+ }
586
+ return this.fns.indexOf(id);
587
+ }
588
+ update(id, fn) {
589
+ const index = this.getInterceptorIndex(id);
590
+ if (this.fns[index]) {
591
+ this.fns[index] = fn;
592
+ return id;
593
+ }
594
+ return false;
595
+ }
596
+ use(fn) {
597
+ this.fns.push(fn);
598
+ return this.fns.length - 1;
599
+ }
600
+ };
601
+ var createInterceptors = () => ({
602
+ error: new Interceptors(),
603
+ request: new Interceptors(),
604
+ response: new Interceptors()
605
+ });
606
+ var defaultQuerySerializer = createQuerySerializer({
607
+ allowReserved: false,
608
+ array: {
609
+ explode: true,
610
+ style: "form"
611
+ },
612
+ object: {
613
+ explode: true,
614
+ style: "deepObject"
615
+ }
616
+ });
617
+ var defaultHeaders = {
618
+ "Content-Type": "application/json"
619
+ };
620
+ var createConfig = (override = {}) => ({
621
+ ...jsonBodySerializer,
622
+ headers: defaultHeaders,
623
+ parseAs: "auto",
624
+ querySerializer: defaultQuerySerializer,
625
+ ...override
626
+ });
627
+
628
+ // src/lib/client/client/client.gen.ts
629
+ var createClient = (config = {}) => {
630
+ let _config = mergeConfigs(createConfig(), config);
631
+ const getConfig = () => ({ ..._config });
632
+ const setConfig = (config2) => {
633
+ _config = mergeConfigs(_config, config2);
634
+ return getConfig();
635
+ };
636
+ const interceptors = createInterceptors();
637
+ const beforeRequest = async (options) => {
638
+ const opts = {
639
+ ..._config,
640
+ ...options,
641
+ fetch: options.fetch ?? _config.fetch ?? globalThis.fetch,
642
+ headers: mergeHeaders(_config.headers, options.headers),
643
+ serializedBody: void 0
644
+ };
645
+ if (opts.security) {
646
+ await setAuthParams({
647
+ ...opts,
648
+ security: opts.security
649
+ });
650
+ }
651
+ if (opts.requestValidator) {
652
+ await opts.requestValidator(opts);
653
+ }
654
+ if (opts.body !== void 0 && opts.bodySerializer) {
655
+ opts.serializedBody = opts.bodySerializer(opts.body);
656
+ }
657
+ if (opts.body === void 0 || opts.serializedBody === "") {
658
+ opts.headers.delete("Content-Type");
659
+ }
660
+ const resolvedOpts = opts;
661
+ const url = buildUrl(resolvedOpts);
662
+ return { opts: resolvedOpts, url };
663
+ };
664
+ const request = async (options) => {
665
+ const { opts, url } = await beforeRequest(options);
666
+ const requestInit = {
667
+ redirect: "follow",
668
+ ...opts,
669
+ body: getValidRequestBody(opts)
670
+ };
671
+ let request2 = new Request(url, requestInit);
672
+ for (const fn of interceptors.request.fns) {
673
+ if (fn) {
674
+ request2 = await fn(request2, opts);
675
+ }
676
+ }
677
+ const _fetch = opts.fetch;
678
+ let response;
679
+ try {
680
+ response = await _fetch(request2);
681
+ } catch (error2) {
682
+ let finalError2 = error2;
683
+ for (const fn of interceptors.error.fns) {
684
+ if (fn) {
685
+ finalError2 = await fn(error2, void 0, request2, opts);
686
+ }
687
+ }
688
+ finalError2 = finalError2 || {};
689
+ if (opts.throwOnError) {
690
+ throw finalError2;
691
+ }
692
+ return opts.responseStyle === "data" ? void 0 : {
693
+ error: finalError2,
694
+ request: request2,
695
+ response: void 0
696
+ };
697
+ }
698
+ for (const fn of interceptors.response.fns) {
699
+ if (fn) {
700
+ response = await fn(response, request2, opts);
701
+ }
702
+ }
703
+ const result = {
704
+ request: request2,
705
+ response
706
+ };
707
+ if (response.ok) {
708
+ const parseAs = (opts.parseAs === "auto" ? getParseAs(response.headers.get("Content-Type")) : opts.parseAs) ?? "json";
709
+ if (response.status === 204 || response.headers.get("Content-Length") === "0") {
710
+ let emptyData;
711
+ switch (parseAs) {
712
+ case "arrayBuffer":
713
+ case "blob":
714
+ case "text":
715
+ emptyData = await response[parseAs]();
716
+ break;
717
+ case "formData":
718
+ emptyData = new FormData();
719
+ break;
720
+ case "stream":
721
+ emptyData = response.body;
722
+ break;
723
+ case "json":
724
+ default:
725
+ emptyData = {};
726
+ break;
727
+ }
728
+ return opts.responseStyle === "data" ? emptyData : {
729
+ data: emptyData,
730
+ ...result
731
+ };
732
+ }
733
+ let data;
734
+ switch (parseAs) {
735
+ case "arrayBuffer":
736
+ case "blob":
737
+ case "formData":
738
+ case "text":
739
+ data = await response[parseAs]();
740
+ break;
741
+ case "json": {
742
+ const text = await response.text();
743
+ data = text ? JSON.parse(text) : {};
744
+ break;
745
+ }
746
+ case "stream":
747
+ return opts.responseStyle === "data" ? response.body : {
748
+ data: response.body,
749
+ ...result
750
+ };
751
+ }
752
+ if (parseAs === "json") {
753
+ if (opts.responseValidator) {
754
+ await opts.responseValidator(data);
755
+ }
756
+ if (opts.responseTransformer) {
757
+ data = await opts.responseTransformer(data);
758
+ }
759
+ }
760
+ return opts.responseStyle === "data" ? data : {
761
+ data,
762
+ ...result
763
+ };
764
+ }
765
+ const textError = await response.text();
766
+ let jsonError;
767
+ try {
768
+ jsonError = JSON.parse(textError);
769
+ } catch {
770
+ }
771
+ const error = jsonError ?? textError;
772
+ let finalError = error;
773
+ for (const fn of interceptors.error.fns) {
774
+ if (fn) {
775
+ finalError = await fn(error, response, request2, opts);
776
+ }
777
+ }
778
+ finalError = finalError || {};
779
+ if (opts.throwOnError) {
780
+ throw finalError;
781
+ }
782
+ return opts.responseStyle === "data" ? void 0 : {
783
+ error: finalError,
784
+ ...result
785
+ };
786
+ };
787
+ const makeMethodFn = (method) => (options) => request({ ...options, method });
788
+ const makeSseFn = (method) => async (options) => {
789
+ const { opts, url } = await beforeRequest(options);
790
+ return createSseClient({
791
+ ...opts,
792
+ body: opts.body,
793
+ headers: opts.headers,
794
+ method,
795
+ onRequest: async (url2, init) => {
796
+ let request2 = new Request(url2, init);
797
+ for (const fn of interceptors.request.fns) {
798
+ if (fn) {
799
+ request2 = await fn(request2, opts);
800
+ }
801
+ }
802
+ return request2;
803
+ },
804
+ serializedBody: getValidRequestBody(opts),
805
+ url
806
+ });
807
+ };
808
+ const _buildUrl = (options) => buildUrl({ ..._config, ...options });
809
+ return {
810
+ buildUrl: _buildUrl,
811
+ connect: makeMethodFn("CONNECT"),
812
+ delete: makeMethodFn("DELETE"),
813
+ get: makeMethodFn("GET"),
814
+ getConfig,
815
+ head: makeMethodFn("HEAD"),
816
+ interceptors,
817
+ options: makeMethodFn("OPTIONS"),
818
+ patch: makeMethodFn("PATCH"),
819
+ post: makeMethodFn("POST"),
820
+ put: makeMethodFn("PUT"),
821
+ request,
822
+ setConfig,
823
+ sse: {
824
+ connect: makeSseFn("CONNECT"),
825
+ delete: makeSseFn("DELETE"),
826
+ get: makeSseFn("GET"),
827
+ head: makeSseFn("HEAD"),
828
+ options: makeSseFn("OPTIONS"),
829
+ patch: makeSseFn("PATCH"),
830
+ post: makeSseFn("POST"),
831
+ put: makeSseFn("PUT"),
832
+ trace: makeSseFn("TRACE")
833
+ },
834
+ trace: makeMethodFn("TRACE")
835
+ };
836
+ };
837
+
838
+ // src/lib/client/client.gen.ts
839
+ var client = createClient(createConfig({ baseUrl: "https://us-staging.notte.cc" }));
840
+
841
+ // src/lib/client/sdk.gen.ts
842
+ var listSessions = (options) => (options?.client ?? client).get({
843
+ security: [{ scheme: "bearer", type: "http" }],
844
+ url: "/sessions",
845
+ ...options
846
+ });
847
+ var sessionStart = (options) => (options.client ?? client).post({
848
+ security: [{ scheme: "bearer", type: "http" }],
849
+ url: "/sessions/start",
850
+ ...options,
851
+ headers: {
852
+ "Content-Type": "application/json",
853
+ ...options.headers
854
+ }
855
+ });
856
+ var sessionStatus = (options) => (options.client ?? client).get({
857
+ security: [{ scheme: "bearer", type: "http" }],
858
+ url: "/sessions/{session_id}",
859
+ ...options
860
+ });
861
+ var getSessionScript = (options) => (options.client ?? client).get({
862
+ security: [{ scheme: "bearer", type: "http" }],
863
+ url: "/sessions/{session_id}/workflow/code",
864
+ ...options
865
+ });
866
+ var sessionStop = (options) => (options.client ?? client).delete({
867
+ security: [{ scheme: "bearer", type: "http" }],
868
+ url: "/sessions/{session_id}/stop",
869
+ ...options
870
+ });
871
+ var sessionCookiesGet = (options) => (options.client ?? client).get({
872
+ security: [{ scheme: "bearer", type: "http" }],
873
+ url: "/sessions/{session_id}/cookies",
874
+ ...options
875
+ });
876
+ var sessionCookiesSet = (options) => (options.client ?? client).post({
877
+ security: [{ scheme: "bearer", type: "http" }],
878
+ url: "/sessions/{session_id}/cookies",
879
+ ...options,
880
+ headers: {
881
+ "Content-Type": "application/json",
882
+ ...options.headers
883
+ }
884
+ });
885
+ var sessionDebugInfo = (options) => (options.client ?? client).get({
886
+ security: [{ scheme: "bearer", type: "http" }],
887
+ url: "/sessions/{session_id}/debug",
888
+ ...options
889
+ });
890
+ var sessionOffset = (options) => (options.client ?? client).get({
891
+ security: [{ scheme: "bearer", type: "http" }],
892
+ url: "/sessions/{session_id}/offset",
893
+ ...options
894
+ });
895
+ var pageObserve = (options) => (options.client ?? client).post({
896
+ security: [{ scheme: "bearer", type: "http" }],
897
+ url: "/sessions/{session_id}/page/observe",
898
+ ...options,
899
+ headers: {
900
+ "Content-Type": "application/json",
901
+ ...options.headers
902
+ }
903
+ });
904
+ var pageScreenshot = (options) => (options.client ?? client).post({
905
+ security: [{ scheme: "bearer", type: "http" }],
906
+ url: "/sessions/{session_id}/page/screenshot",
907
+ ...options
908
+ });
909
+ var pageExecute = (options) => (options.client ?? client).post({
910
+ security: [{ scheme: "bearer", type: "http" }],
911
+ url: "/sessions/{session_id}/page/execute",
912
+ ...options,
913
+ headers: {
914
+ "Content-Type": "application/json",
915
+ ...options.headers
916
+ }
917
+ });
918
+ var pageScrape = (options) => (options.client ?? client).post({
919
+ security: [{ scheme: "bearer", type: "http" }],
920
+ url: "/sessions/{session_id}/page/scrape",
921
+ ...options,
922
+ headers: {
923
+ "Content-Type": "application/json",
924
+ ...options.headers
925
+ }
926
+ });
927
+ var sessionNetworkLogs = (options) => (options.client ?? client).get({
928
+ security: [{ scheme: "bearer", type: "http" }],
929
+ url: "/sessions/{session_id}/network/logs",
930
+ ...options
931
+ });
932
+ var sessionReplay = (options) => (options.client ?? client).get({
933
+ security: [{ scheme: "bearer", type: "http" }],
934
+ url: "/sessions/{session_id}/replay",
935
+ ...options
936
+ });
937
+ var agentStart = (options) => (options.client ?? client).post({
938
+ security: [{ scheme: "bearer", type: "http" }],
939
+ url: "/agents/start",
940
+ ...options,
941
+ headers: {
942
+ "Content-Type": "application/json",
943
+ ...options.headers
944
+ }
945
+ });
946
+ var agentStatus = (options) => (options.client ?? client).get({
947
+ security: [{ scheme: "bearer", type: "http" }],
948
+ url: "/agents/{agent_id}",
949
+ ...options
950
+ });
951
+ var getScript = (options) => (options.client ?? client).get({
952
+ security: [{ scheme: "bearer", type: "http" }],
953
+ url: "/agents/{agent_id}/workflow/code",
954
+ ...options
955
+ });
956
+ var agentStop = (options) => (options.client ?? client).delete({
957
+ security: [{ scheme: "bearer", type: "http" }],
958
+ url: "/agents/{agent_id}/stop",
959
+ ...options
960
+ });
961
+ var listAgents = (options) => (options?.client ?? client).get({
962
+ security: [{ scheme: "bearer", type: "http" }],
963
+ url: "/agents",
964
+ ...options
965
+ });
966
+ var listFunctions = (options) => (options?.client ?? client).get({
967
+ security: [{ scheme: "bearer", type: "http" }],
968
+ url: "/functions",
969
+ ...options
970
+ });
971
+ var functionCreate = (options) => (options.client ?? client).post({
972
+ ...formDataBodySerializer,
973
+ security: [{ scheme: "bearer", type: "http" }],
974
+ url: "/functions",
975
+ ...options,
976
+ headers: {
977
+ "Content-Type": null,
978
+ ...options.headers
979
+ }
980
+ });
981
+ var functionDelete = (options) => (options.client ?? client).delete({
982
+ security: [{ scheme: "bearer", type: "http" }],
983
+ url: "/functions/{function_id}",
984
+ ...options
985
+ });
986
+ var functionDownloadUrl = (options) => (options.client ?? client).get({
987
+ security: [{ scheme: "bearer", type: "http" }],
988
+ url: "/functions/{function_id}",
989
+ ...options
990
+ });
991
+ var functionUpdate = (options) => (options.client ?? client).post({
992
+ ...formDataBodySerializer,
993
+ security: [{ scheme: "bearer", type: "http" }],
994
+ url: "/functions/{function_id}",
995
+ ...options,
996
+ headers: {
997
+ "Content-Type": null,
998
+ ...options.headers
999
+ }
1000
+ });
1001
+ var functionFork = (options) => (options.client ?? client).post({
1002
+ security: [{ scheme: "bearer", type: "http" }],
1003
+ url: "/functions/{function_id}/fork",
1004
+ ...options
1005
+ });
1006
+ var functionScheduleDelete = (options) => (options.client ?? client).delete({
1007
+ security: [{ scheme: "bearer", type: "http" }],
1008
+ url: "/functions/{function_id}/schedule",
1009
+ ...options
1010
+ });
1011
+ var functionScheduleSet = (options) => (options.client ?? client).post({
1012
+ security: [{ scheme: "bearer", type: "http" }],
1013
+ url: "/functions/{function_id}/schedule",
1014
+ ...options,
1015
+ headers: {
1016
+ "Content-Type": "application/json",
1017
+ ...options.headers
1018
+ }
1019
+ });
1020
+ var functionRunStart = (options) => (options.client ?? client).post({
1021
+ security: [{ scheme: "bearer", type: "http" }],
1022
+ url: "/functions/{function_id}/runs/start",
1023
+ ...options,
1024
+ headers: {
1025
+ "Content-Type": "application/json",
1026
+ ...options.headers
1027
+ }
1028
+ });
1029
+ var functionRunStop = (options) => (options.client ?? client).delete({
1030
+ security: [{ scheme: "bearer", type: "http" }],
1031
+ url: "/functions/{function_id}/runs/{run_id}",
1032
+ ...options
1033
+ });
1034
+ var functionRunGetMetadata = (options) => (options.client ?? client).get({
1035
+ security: [{ scheme: "bearer", type: "http" }],
1036
+ url: "/functions/{function_id}/runs/{run_id}",
1037
+ ...options
1038
+ });
1039
+ var functionRunUpdateMetadata = (options) => (options.client ?? client).patch({
1040
+ security: [{ scheme: "bearer", type: "http" }],
1041
+ url: "/functions/{function_id}/runs/{run_id}",
1042
+ ...options,
1043
+ headers: {
1044
+ "Content-Type": "application/json",
1045
+ ...options.headers
1046
+ }
1047
+ });
1048
+ var listFunctionRunsByFunctionId = (options) => (options.client ?? client).get({
1049
+ security: [{ scheme: "bearer", type: "http" }],
1050
+ url: "/functions/{function_id}/runs",
1051
+ ...options
1052
+ });
1053
+ var vaultCreate = (options) => (options.client ?? client).post({
1054
+ security: [{ scheme: "bearer", type: "http" }],
1055
+ url: "/vaults/create",
1056
+ ...options,
1057
+ headers: {
1058
+ "Content-Type": "application/json",
1059
+ ...options.headers
1060
+ }
1061
+ });
1062
+ var vaultCredentialsDelete = (options) => (options.client ?? client).delete({
1063
+ security: [{ scheme: "bearer", type: "http" }],
1064
+ url: "/vaults/{vault_id}/credentials",
1065
+ ...options
1066
+ });
1067
+ var vaultCredentialsGet = (options) => (options.client ?? client).get({
1068
+ security: [{ scheme: "bearer", type: "http" }],
1069
+ url: "/vaults/{vault_id}/credentials",
1070
+ ...options
1071
+ });
1072
+ var vaultCredentialsAdd = (options) => (options.client ?? client).post({
1073
+ security: [{ scheme: "bearer", type: "http" }],
1074
+ url: "/vaults/{vault_id}/credentials",
1075
+ ...options,
1076
+ headers: {
1077
+ "Content-Type": "application/json",
1078
+ ...options.headers
1079
+ }
1080
+ });
1081
+ var vaultDelete = (options) => (options.client ?? client).delete({
1082
+ security: [{ scheme: "bearer", type: "http" }],
1083
+ url: "/vaults/{vault_id}",
1084
+ ...options
1085
+ });
1086
+ var vaultCredentialsList = (options) => (options.client ?? client).get({
1087
+ security: [{ scheme: "bearer", type: "http" }],
1088
+ url: "/vaults/{vault_id}",
1089
+ ...options
1090
+ });
1091
+ var vaultUpdate = (options) => (options.client ?? client).patch({
1092
+ security: [{ scheme: "bearer", type: "http" }],
1093
+ url: "/vaults/{vault_id}",
1094
+ ...options,
1095
+ headers: {
1096
+ "Content-Type": "application/json",
1097
+ ...options.headers
1098
+ }
1099
+ });
1100
+ var vaultCreditCardDelete = (options) => (options.client ?? client).delete({
1101
+ security: [{ scheme: "bearer", type: "http" }],
1102
+ url: "/vaults/{vault_id}/card",
1103
+ ...options
1104
+ });
1105
+ var vaultCreditCardGet = (options) => (options.client ?? client).get({
1106
+ security: [{ scheme: "bearer", type: "http" }],
1107
+ url: "/vaults/{vault_id}/card",
1108
+ ...options
1109
+ });
1110
+ var vaultCreditCardSet = (options) => (options.client ?? client).post({
1111
+ security: [{ scheme: "bearer", type: "http" }],
1112
+ url: "/vaults/{vault_id}/card",
1113
+ ...options,
1114
+ headers: {
1115
+ "Content-Type": "application/json",
1116
+ ...options.headers
1117
+ }
1118
+ });
1119
+ var listVaults = (options) => (options?.client ?? client).get({
1120
+ security: [{ scheme: "bearer", type: "http" }],
1121
+ url: "/vaults",
1122
+ ...options
1123
+ });
1124
+ var profileCreate = (options) => (options.client ?? client).post({
1125
+ security: [{ scheme: "bearer", type: "http" }],
1126
+ url: "/profiles/create",
1127
+ ...options,
1128
+ headers: {
1129
+ "Content-Type": "application/json",
1130
+ ...options.headers
1131
+ }
1132
+ });
1133
+ var profileDelete = (options) => (options.client ?? client).delete({
1134
+ security: [{ scheme: "bearer", type: "http" }],
1135
+ url: "/profiles/{profile_id}",
1136
+ ...options
1137
+ });
1138
+ var profileGet = (options) => (options.client ?? client).get({
1139
+ security: [{ scheme: "bearer", type: "http" }],
1140
+ url: "/profiles/{profile_id}",
1141
+ ...options
1142
+ });
1143
+ var profileList = (options) => (options?.client ?? client).get({
1144
+ security: [{ scheme: "bearer", type: "http" }],
1145
+ url: "/profiles",
1146
+ ...options
1147
+ });
1148
+ var personaCreate = (options) => (options.client ?? client).post({
1149
+ security: [{ scheme: "bearer", type: "http" }],
1150
+ url: "/personas/create",
1151
+ ...options,
1152
+ headers: {
1153
+ "Content-Type": "application/json",
1154
+ ...options.headers
1155
+ }
1156
+ });
1157
+ var personaDelete = (options) => (options.client ?? client).delete({
1158
+ security: [{ scheme: "bearer", type: "http" }],
1159
+ url: "/personas/{persona_id}",
1160
+ ...options
1161
+ });
1162
+ var personaGet = (options) => (options.client ?? client).get({
1163
+ security: [{ scheme: "bearer", type: "http" }],
1164
+ url: "/personas/{persona_id}",
1165
+ ...options
1166
+ });
1167
+ var personaEmailsList = (options) => (options.client ?? client).get({
1168
+ security: [{ scheme: "bearer", type: "http" }],
1169
+ url: "/personas/{persona_id}/emails",
1170
+ ...options
1171
+ });
1172
+ var listPersonas = (options) => (options?.client ?? client).get({
1173
+ security: [{ scheme: "bearer", type: "http" }],
1174
+ url: "/personas",
1175
+ ...options
1176
+ });
1177
+ var personaSmsList = (options) => (options.client ?? client).get({
1178
+ security: [{ scheme: "bearer", type: "http" }],
1179
+ url: "/personas/{persona_id}/sms",
1180
+ ...options
1181
+ });
1182
+ var improvePrompt = (options) => (options.client ?? client).post({
1183
+ url: "/prompts/improve",
1184
+ ...options,
1185
+ headers: {
1186
+ "Content-Type": "application/json",
1187
+ ...options.headers
1188
+ }
1189
+ });
1190
+ var nudgePrompt = (options) => (options.client ?? client).post({
1191
+ url: "/prompts/nudge",
1192
+ ...options,
1193
+ headers: {
1194
+ "Content-Type": "application/json",
1195
+ ...options.headers
1196
+ }
1197
+ });
1198
+ var getUsage = (options) => (options?.client ?? client).get({
1199
+ security: [{ scheme: "bearer", type: "http" }],
1200
+ url: "/usage",
1201
+ ...options
1202
+ });
1203
+ var getUsageLogs = (options) => (options?.client ?? client).get({
1204
+ security: [{ scheme: "bearer", type: "http" }],
1205
+ url: "/usage/logs",
1206
+ ...options
1207
+ });
1208
+ var fileDownload = (options) => (options.client ?? client).get({
1209
+ security: [{ scheme: "bearer", type: "http" }],
1210
+ url: "/storage/{session_id}/downloads/{filename}",
1211
+ ...options
1212
+ });
1213
+ var fileUploadDownloadedFile = (options) => (options.client ?? client).post({
1214
+ ...formDataBodySerializer,
1215
+ security: [{ scheme: "bearer", type: "http" }],
1216
+ url: "/storage/{session_id}/downloads/{filename}",
1217
+ ...options,
1218
+ headers: {
1219
+ "Content-Type": null,
1220
+ ...options.headers
1221
+ }
1222
+ });
1223
+ var fileListDownloads = (options) => (options.client ?? client).get({
1224
+ security: [{ scheme: "bearer", type: "http" }],
1225
+ url: "/storage/{session_id}/downloads",
1226
+ ...options
1227
+ });
1228
+ var fileUpload = (options) => (options.client ?? client).post({
1229
+ ...formDataBodySerializer,
1230
+ security: [{ scheme: "bearer", type: "http" }],
1231
+ url: "/storage/uploads/{filename}",
1232
+ ...options,
1233
+ headers: {
1234
+ "Content-Type": null,
1235
+ ...options.headers
1236
+ }
1237
+ });
1238
+ var fileListUploads = (options) => (options?.client ?? client).get({
1239
+ security: [{ scheme: "bearer", type: "http" }],
1240
+ url: "/storage/uploads",
1241
+ ...options
1242
+ });
1243
+ var anythingStart = (options) => (options.client ?? client).post({
1244
+ security: [{ scheme: "bearer", type: "http" }],
1245
+ url: "/anything/start",
1246
+ ...options,
1247
+ headers: {
1248
+ "Content-Type": "application/json",
1249
+ ...options.headers
1250
+ }
1251
+ });
1252
+ var healthCheck = (options) => (options?.client ?? client).get({ url: "/health", ...options });
1253
+ var scrapeWebpage = (options) => (options.client ?? client).post({
1254
+ security: [{ scheme: "bearer", type: "http" }],
1255
+ url: "/scrape",
1256
+ ...options,
1257
+ headers: {
1258
+ "Content-Type": "application/json",
1259
+ ...options.headers
1260
+ }
1261
+ });
1262
+ var scrapeFromHtml = (options) => (options.client ?? client).post({
1263
+ security: [{ scheme: "bearer", type: "http" }],
1264
+ url: "/scrape_from_html",
1265
+ ...options,
1266
+ headers: {
1267
+ "Content-Type": "application/json",
1268
+ ...options.headers
1269
+ }
1270
+ });
1271
+
1272
+ // src/utils.ts
1273
+ function formatError(error) {
1274
+ if (typeof error === "object" && error !== null) {
1275
+ if ("message" in error && typeof error.message === "string") {
1276
+ return error.message;
1277
+ }
1278
+ try {
1279
+ return JSON.stringify(error, null, 2);
1280
+ } catch {
1281
+ return String(error);
1282
+ }
1283
+ }
1284
+ if (error instanceof Error) {
1285
+ return error.message;
1286
+ }
1287
+ return String(error);
1288
+ }
1289
+
1290
+ // src/session.ts
1291
+ import { z } from "zod";
1292
+ function processScrapeResponse(scrapeResponse, options) {
1293
+ if (options.only_images && scrapeResponse.images) {
1294
+ return scrapeResponse.images;
1295
+ }
1296
+ if (requiresSchema(options)) {
1297
+ const structured = scrapeResponse.structured;
1298
+ if (!structured) {
1299
+ throw new Error("Failed to scrape structured data. This should not happen. Please report this issue.");
1300
+ }
1301
+ if (options.response_format && typeof options.response_format.parse === "function") {
1302
+ if (structured.data) {
1303
+ try {
1304
+ const validatedData = options.response_format.parse(structured.data);
1305
+ return validatedData;
1306
+ } catch (error) {
1307
+ throw new Error(`Schema validation failed: ${error instanceof Error ? error.message : String(error)}`);
1308
+ }
1309
+ }
1310
+ return structured;
1311
+ }
1312
+ return structured;
1313
+ }
1314
+ if (options.response_format && typeof options.response_format.parse === "function") {
1315
+ try {
1316
+ const validatedData = options.response_format.parse(scrapeResponse);
1317
+ return validatedData;
1318
+ } catch (error) {
1319
+ throw new Error(`Schema validation failed: ${error instanceof Error ? error.message : String(error)}`);
1320
+ }
1321
+ }
1322
+ return scrapeResponse.markdown;
1323
+ }
1324
+ function requiresSchema(options) {
1325
+ return !!(options.response_format || options.instructions);
1326
+ }
1327
+ var Session = class {
1328
+ constructor(client2, options = {}) {
1329
+ this.sessionId = null;
1330
+ this.isActive = false;
1331
+ this.response = null;
1332
+ this.client = client2;
1333
+ this.options = options;
1334
+ }
1335
+ /**
1336
+ * Start the session - creates a new session on the server
1337
+ */
1338
+ async start() {
1339
+ if (this.isActive) {
1340
+ throw new Error("Session is already active");
1341
+ }
1342
+ try {
1343
+ const response = await sessionStart({
1344
+ client: this.client.getClient(),
1345
+ body: this.options
1346
+ });
1347
+ if (response?.error) {
1348
+ throw new Error(`Failed to create session: ${formatError(response.error)}`);
1349
+ }
1350
+ const sessionData = response.data;
1351
+ this.sessionId = sessionData.session_id;
1352
+ this.isActive = true;
1353
+ this.response = sessionData;
1354
+ } catch (error) {
1355
+ throw new Error(`Failed to start session: ${error instanceof Error ? error.message : String(error)}`);
1356
+ }
1357
+ }
1358
+ /**
1359
+ * Stop the session - terminates the session on the server
1360
+ */
1361
+ async stop() {
1362
+ if (!this.isActive || !this.sessionId) {
1363
+ return;
1364
+ }
1365
+ const response = await sessionStop({
1366
+ client: this.client.getClient(),
1367
+ path: {
1368
+ session_id: this.sessionId
1369
+ }
1370
+ });
1371
+ if (response?.error) {
1372
+ throw new Error(`Failed to stop session: ${formatError(response.error)}`);
1373
+ }
1374
+ this.response = response.data;
1375
+ this.isActive = false;
1376
+ this.sessionId = null;
1377
+ }
1378
+ /**
1379
+ * Get session status
1380
+ */
1381
+ async status() {
1382
+ if (!this.sessionId) {
1383
+ throw new Error("Session not started");
1384
+ }
1385
+ const response = await sessionStatus({
1386
+ client: this.client.getClient(),
1387
+ path: {
1388
+ session_id: this.sessionId
1389
+ }
1390
+ });
1391
+ if (response?.error) {
1392
+ throw new Error(`Failed to get session status: ${formatError(response.error)}`);
1393
+ }
1394
+ return response.data;
1395
+ }
1396
+ /**
1397
+ * Get session ID
1398
+ */
1399
+ getId() {
1400
+ return this.sessionId;
1401
+ }
1402
+ /**
1403
+ * Check if session is active
1404
+ */
1405
+ isSessionActive() {
1406
+ return this.isActive;
1407
+ }
1408
+ /**
1409
+ * Get the last response from session operations
1410
+ */
1411
+ getResponse() {
1412
+ return this.response;
1413
+ }
1414
+ /**
1415
+ * Set cookies for the session
1416
+ */
1417
+ async setCookies(cookies) {
1418
+ if (!this.sessionId) {
1419
+ throw new Error("Session not started");
1420
+ }
1421
+ const response = await sessionCookiesSet({
1422
+ client: this.client.getClient(),
1423
+ path: {
1424
+ session_id: this.sessionId
1425
+ },
1426
+ body: {
1427
+ cookies
1428
+ }
1429
+ });
1430
+ if (response?.error) {
1431
+ throw new Error(`Failed to set cookies: ${formatError(response.error)}`);
1432
+ }
1433
+ return response.data;
1434
+ }
1435
+ /**
1436
+ * Set cookies from a file
1437
+ */
1438
+ async setCookiesFromFile(cookieFile) {
1439
+ const fs = await import("fs/promises");
1440
+ const cookieData = await fs.readFile(cookieFile, "utf-8");
1441
+ const cookies = JSON.parse(cookieData);
1442
+ return this.setCookies(cookies);
1443
+ }
1444
+ /**
1445
+ * Get cookies from the session
1446
+ */
1447
+ async getCookies() {
1448
+ if (!this.sessionId) {
1449
+ throw new Error("Session not started");
1450
+ }
1451
+ const response = await sessionCookiesGet({
1452
+ client: this.client.getClient(),
1453
+ path: {
1454
+ session_id: this.sessionId
1455
+ }
1456
+ });
1457
+ if (response?.error) {
1458
+ throw new Error(`Failed to get cookies: ${formatError(response.error)}`);
1459
+ }
1460
+ return response.data.cookies;
1461
+ }
1462
+ /**
1463
+ * Execute an action on the page
1464
+ */
1465
+ async execute(action, raiseOnFailure = true) {
1466
+ if (!this.sessionId) {
1467
+ throw new Error("Session not started");
1468
+ }
1469
+ const response = await pageExecute({
1470
+ client: this.client.getClient(),
1471
+ path: {
1472
+ session_id: this.sessionId
1473
+ },
1474
+ body: action
1475
+ });
1476
+ if (response?.error) {
1477
+ throw new Error(`Failed to execute action: ${formatError(response.error)}`);
1478
+ }
1479
+ const result = response.data;
1480
+ if (raiseOnFailure && !result.success) {
1481
+ throw new Error(`Action execution failed: ${result.message}`);
1482
+ }
1483
+ return result;
1484
+ }
1485
+ /**
1486
+ * Observe the current page state
1487
+ */
1488
+ async observe(perceptionType = "fast") {
1489
+ if (!this.sessionId) {
1490
+ throw new Error("Session not started");
1491
+ }
1492
+ const response = await pageObserve({
1493
+ client: this.client.getClient(),
1494
+ path: {
1495
+ session_id: this.sessionId
1496
+ },
1497
+ body: {
1498
+ perception_type: perceptionType
1499
+ }
1500
+ });
1501
+ if (response?.error) {
1502
+ throw new Error(`Failed to observe page: ${formatError(response.error)}`);
1503
+ }
1504
+ return response.data;
1505
+ }
1506
+ /**
1507
+ * Get session replay data
1508
+ */
1509
+ async replay() {
1510
+ if (!this.sessionId) {
1511
+ throw new Error("Session not started");
1512
+ }
1513
+ const response = await sessionReplay({
1514
+ client: this.client.getClient(),
1515
+ path: {
1516
+ session_id: this.sessionId
1517
+ }
1518
+ });
1519
+ if (response?.error) {
1520
+ throw new Error(`Failed to get session replay: ${formatError(response.error)}`);
1521
+ }
1522
+ return response.data;
1523
+ }
1524
+ async scrape(options = {}) {
1525
+ if (!this.sessionId) {
1526
+ throw new Error("Session not started");
1527
+ }
1528
+ const apiOptions = { ...options };
1529
+ if (options.response_format && typeof options.response_format.parse === "function") {
1530
+ if (options.json_schema) {
1531
+ apiOptions.response_format = options.json_schema;
1532
+ } else {
1533
+ apiOptions.response_format = z.toJSONSchema(options.response_format);
1534
+ }
1535
+ if (!apiOptions.instructions) {
1536
+ const schemaStr = JSON.stringify(apiOptions.response_format);
1537
+ if (schemaStr.includes("plans") || schemaStr.includes("plan")) {
1538
+ apiOptions.instructions = "Extract pricing plans from the page";
1539
+ } else if (schemaStr.includes("products") || schemaStr.includes("product")) {
1540
+ apiOptions.instructions = "Extract product information from the page";
1541
+ } else if (schemaStr.includes("articles") || schemaStr.includes("article")) {
1542
+ apiOptions.instructions = "Extract article information from the page";
1543
+ } else {
1544
+ apiOptions.instructions = "Extract structured data from the page based on the provided schema";
1545
+ }
1546
+ }
1547
+ }
1548
+ const response = await pageScrape({
1549
+ client: this.client.getClient(),
1550
+ path: {
1551
+ session_id: this.sessionId
1552
+ },
1553
+ body: apiOptions
1554
+ });
1555
+ if (response?.error) {
1556
+ throw new Error(`Failed to scrape page: ${JSON.stringify(response.error)}`);
1557
+ }
1558
+ return processScrapeResponse(response.data, options);
1559
+ }
1560
+ /**
1561
+ * Context manager pattern - automatically start and stop session
1562
+ * Usage: await session.use(async (session) => { ... })
1563
+ */
1564
+ async use(callback) {
1565
+ await this.start();
1566
+ try {
1567
+ return await callback(this);
1568
+ } finally {
1569
+ await this.stop();
1570
+ }
1571
+ }
1572
+ /**
1573
+ * Async iterator pattern for session lifecycle management
1574
+ * Usage: for await (const session of sessionInstance) { ... }
1575
+ */
1576
+ async *[Symbol.asyncIterator]() {
1577
+ await this.start();
1578
+ try {
1579
+ yield this;
1580
+ } finally {
1581
+ await this.stop();
1582
+ }
1583
+ }
1584
+ };
1585
+
1586
+ // src/agent.ts
1587
+ import WebSocket from "ws";
1588
+ function validatePersonaOption(persona, persona_id) {
1589
+ if (persona) {
1590
+ try {
1591
+ const personaId = persona.personaId;
1592
+ if (!personaId || personaId.length === 0) {
1593
+ throw new Error("Persona ID cannot be empty");
1594
+ }
1595
+ return personaId;
1596
+ } catch (error) {
1597
+ throw new Error(`Invalid persona object: ${error instanceof Error ? error.message : String(error)}`);
1598
+ }
1599
+ } else if (persona_id) {
1600
+ if (persona_id.length === 0) {
1601
+ throw new Error("Persona ID cannot be empty");
1602
+ }
1603
+ return persona_id;
1604
+ }
1605
+ return void 0;
1606
+ }
1607
+ function validateVaultOption(vault, vault_id) {
1608
+ if (vault) {
1609
+ try {
1610
+ const vaultId = vault.vaultId;
1611
+ if (!vaultId || vaultId.length === 0) {
1612
+ throw new Error("Vault ID cannot be empty");
1613
+ }
1614
+ return vaultId;
1615
+ } catch (error) {
1616
+ throw new Error(`Invalid vault object: ${error instanceof Error ? error.message : String(error)}`);
1617
+ }
1618
+ } else if (vault_id) {
1619
+ if (vault_id.length === 0) {
1620
+ throw new Error("Vault ID cannot be empty");
1621
+ }
1622
+ return vault_id;
1623
+ }
1624
+ return void 0;
1625
+ }
1626
+ function validateSessionOption(session) {
1627
+ const sessionId = session.getId();
1628
+ if (!sessionId || sessionId.length === 0) {
1629
+ throw new Error("Session ID cannot be empty");
1630
+ }
1631
+ return sessionId;
1632
+ }
1633
+ function validateAgentIdOption(agent_id) {
1634
+ if (agent_id.length === 0) {
1635
+ throw new Error("Agent ID cannot be empty");
1636
+ }
1637
+ }
1638
+ var defaultStepLogger = (stepData, stepCounter, agentId) => {
1639
+ console.log(`\u2728 Step ${stepCounter} (agent: ${agentId})`);
1640
+ if (stepData && typeof stepData === "object") {
1641
+ if (stepData.state) {
1642
+ const state = stepData.state;
1643
+ if (state.page_summary) {
1644
+ console.log(`\u{1F4DD} Current page: ${state.page_summary}`);
1645
+ }
1646
+ if (state.previous_goal_eval) {
1647
+ const statusEmoji = state.previous_goal_status === "success" ? "\u2705" : state.previous_goal_status === "failure" ? "\u274C" : "\u2753";
1648
+ console.log(`\u{1F52C} Previous goal: ${statusEmoji} ${state.previous_goal_eval}`);
1649
+ }
1650
+ if (state.memory) {
1651
+ console.log(`\u{1F9E0} Memory: ${state.memory}`);
1652
+ }
1653
+ if (state.next_goal) {
1654
+ console.log(`\u{1F3AF} Next goal: ${state.next_goal}`);
1655
+ }
1656
+ if (state.relevant_interactions && state.relevant_interactions.length > 0) {
1657
+ console.log(`\u{1F194} Relevant ids:`);
1658
+ state.relevant_interactions.forEach((interaction) => {
1659
+ console.log(` \u25B6 ${interaction.id}: ${interaction.reason}`);
1660
+ });
1661
+ }
1662
+ }
1663
+ if (stepData.action) {
1664
+ const action = stepData.action;
1665
+ let actionStr = `\u26A1 Taking action:
1666
+ \u25B6 ${action.name || action.type || "Unknown action"}`;
1667
+ if (action.id) {
1668
+ actionStr += ` with id ${action.id}`;
1669
+ } else if (action.param && action.param.name && action[action.param.name]) {
1670
+ actionStr += ` with ${action.param.name}=${action[action.param.name]}`;
1671
+ }
1672
+ console.log(actionStr);
1673
+ }
1674
+ } else {
1675
+ console.log(stepData);
1676
+ }
1677
+ console.log("");
1678
+ };
1679
+ var Agent = class {
1680
+ constructor(client2, options) {
1681
+ this.response = null;
1682
+ this.websocket = null;
1683
+ this.client = client2;
1684
+ if ("agent_id" in options && options.agent_id) {
1685
+ if (options.session) {
1686
+ throw new Error("Either session (for running a new agent) or agent_id (for accessing an existing agent) have to be provided, not both");
1687
+ }
1688
+ validateAgentIdOption(options.agent_id);
1689
+ this.existingAgent = true;
1690
+ this.response = { agent_id: options.agent_id };
1691
+ } else if ("session" in options && options.session) {
1692
+ if (options.agent_id) {
1693
+ throw new Error("Either session (for running a new agent) or agent_id (for accessing an existing agent) have to be provided, not both");
1694
+ }
1695
+ this.existingAgent = false;
1696
+ const { session, vault, persona, ...requestData } = options;
1697
+ const sessionId = validateSessionOption(session);
1698
+ const vaultId = validateVaultOption(vault, options.vault_id);
1699
+ const personaId = validatePersonaOption(persona, options.persona_id);
1700
+ this.request = {
1701
+ session_id: sessionId,
1702
+ vault_id: vaultId,
1703
+ persona_id: personaId,
1704
+ ...requestData
1705
+ };
1706
+ } else {
1707
+ throw new Error("Either session (for running a new agent) or agent_id (for accessing an existing agent) have to be provided");
1708
+ }
1709
+ }
1710
+ /**
1711
+ * Start an agent task (non-blocking) - mirrors Python start method
1712
+ */
1713
+ async start(data) {
1714
+ if (this.existingAgent) {
1715
+ throw new Error("You cannot call start() on an agent instantiated from agent id");
1716
+ }
1717
+ if (!this.request) {
1718
+ throw new Error("Agent not properly initialized with session");
1719
+ }
1720
+ try {
1721
+ const requestBody = {
1722
+ ...this.request,
1723
+ ...data
1724
+ };
1725
+ const response = await agentStart({
1726
+ client: this.client.getClient(),
1727
+ body: requestBody
1728
+ });
1729
+ if (response?.error) {
1730
+ throw new Error(`Failed to start agent: ${formatError(response.error)}`);
1731
+ }
1732
+ this.response = response.data;
1733
+ return this.response;
1734
+ } catch (error) {
1735
+ throw new Error(`Failed to start agent: ${error instanceof Error ? error.message : String(error)}`);
1736
+ }
1737
+ }
1738
+ /**
1739
+ * Run agent task (blocking) - mirrors Python run method behavior
1740
+ * This is the main method that mirrors the Python SDK's run method
1741
+ */
1742
+ async run(data) {
1743
+ if (this.existingAgent) {
1744
+ throw new Error("You cannot call run() on an agent instantiated from agent id");
1745
+ }
1746
+ this.response = await this.start(data);
1747
+ console.log(`[Agent] ${this.agentId} started`);
1748
+ return await this.watchLogsAndWait(true, data.updateHandler || null);
1749
+ }
1750
+ /**
1751
+ * Watch logs and wait for completion - mirrors Python watch_logs_and_wait
1752
+ */
1753
+ async watchLogsAndWait(log = true, updateHandler = null) {
1754
+ if (this.existingAgent) {
1755
+ throw new Error("You cannot call watchLogsAndWait() on an agent instantiated from agent id");
1756
+ }
1757
+ if (!this.response) {
1758
+ throw new Error("Agent not started");
1759
+ }
1760
+ try {
1761
+ const result = await this.watchLogs(log, updateHandler);
1762
+ if (result) {
1763
+ return result;
1764
+ }
1765
+ await new Promise((resolve) => setTimeout(resolve, 3e3));
1766
+ return await this.status();
1767
+ } catch (error) {
1768
+ console.error(`[Agent] ${this.agentId} failed to complete in time. Try running agent.status() after a few seconds.`);
1769
+ return await this.status();
1770
+ }
1771
+ }
1772
+ /**
1773
+ * Watch logs via WebSocket - mirrors Python watch_logs method
1774
+ */
1775
+ async watchLogs(log = true, updateHandler = null) {
1776
+ if (this.existingAgent) {
1777
+ throw new Error("You cannot call watchLogs() on an agent instantiated from agent id");
1778
+ }
1779
+ if (!this.response) {
1780
+ throw new Error("Agent not started");
1781
+ }
1782
+ const config = this.client.getConfig();
1783
+ const token = config.apiKey;
1784
+ const agentId = this.response.agent_id;
1785
+ const sessionId = this.response.session_id;
1786
+ const wsUrl = config.baseUrl?.replace("https://", "wss://").replace("http://", "ws://") + `/agents/${agentId}/debug/logs?token=${token}&session_id=${sessionId}`;
1787
+ return new Promise((resolve, reject) => {
1788
+ this.websocket = new WebSocket(wsUrl);
1789
+ let counter = 0;
1790
+ this.websocket.on("open", () => {
1791
+ });
1792
+ this.websocket.on("error", (error) => {
1793
+ console.error(`Connection error: ${agentId} ${error.message}`);
1794
+ resolve(null);
1795
+ });
1796
+ this.websocket.on("message", (data) => {
1797
+ try {
1798
+ const message = data.toString();
1799
+ let parsed;
1800
+ try {
1801
+ parsed = JSON.parse(message);
1802
+ } catch {
1803
+ return;
1804
+ }
1805
+ if (parsed.agent_id === agentId && parsed.task !== void 0 && parsed.status !== void 0) {
1806
+ const response = parsed;
1807
+ if (updateHandler) {
1808
+ updateHandler({
1809
+ type: "completion",
1810
+ data: response,
1811
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1812
+ });
1813
+ } else if (!response.success) {
1814
+ console.error(response.answer);
1815
+ }
1816
+ this.disconnectWebSocket();
1817
+ resolve(response);
1818
+ return;
1819
+ }
1820
+ if (log) {
1821
+ counter++;
1822
+ if (updateHandler) {
1823
+ updateHandler({
1824
+ type: "step",
1825
+ data: parsed,
1826
+ timestamp: (/* @__PURE__ */ new Date()).toISOString()
1827
+ });
1828
+ } else {
1829
+ defaultStepLogger(parsed, counter, agentId);
1830
+ }
1831
+ }
1832
+ } catch (error) {
1833
+ console.error(`Error processing WebSocket message: ${error}`);
1834
+ }
1835
+ });
1836
+ this.websocket.on("close", () => {
1837
+ this.websocket = null;
1838
+ resolve(null);
1839
+ });
1840
+ setTimeout(() => {
1841
+ if (this.websocket && this.websocket.readyState === WebSocket.OPEN) {
1842
+ this.disconnectWebSocket();
1843
+ resolve(null);
1844
+ }
1845
+ }, 3e5);
1846
+ });
1847
+ }
1848
+ /**
1849
+ * Get agent status - mirrors Python status method
1850
+ */
1851
+ async status() {
1852
+ if (!this.response) {
1853
+ throw new Error("Agent not started or not accessible");
1854
+ }
1855
+ const response = await agentStatus({
1856
+ client: this.client.getClient(),
1857
+ path: {
1858
+ agent_id: this.response.agent_id
1859
+ }
1860
+ });
1861
+ if (response?.error) {
1862
+ throw new Error(`Failed to get agent status: ${formatError(response.error)}`);
1863
+ }
1864
+ return response.data;
1865
+ }
1866
+ /**
1867
+ * Stop the agent - mirrors Python stop method
1868
+ */
1869
+ async stop() {
1870
+ if (this.existingAgent) {
1871
+ throw new Error("You cannot call stop() on an agent instantiated from agent id");
1872
+ }
1873
+ if (!this.response) {
1874
+ throw new Error("Agent not started");
1875
+ }
1876
+ try {
1877
+ console.log(`[Agent] ${this.response.agent_id} is stopping`);
1878
+ const response = await agentStop({
1879
+ client: this.client.getClient(),
1880
+ path: {
1881
+ agent_id: this.response.agent_id
1882
+ },
1883
+ query: { session_id: this.response.session_id }
1884
+ });
1885
+ if (response?.error) {
1886
+ throw new Error(`Failed to stop agent: ${formatError(response.error)}`);
1887
+ }
1888
+ console.log(`[Agent] ${this.response.agent_id} stopped`);
1889
+ return response.data;
1890
+ } catch (error) {
1891
+ console.warn(`Failed to stop agent: ${error instanceof Error ? error.message : String(error)}`);
1892
+ throw error;
1893
+ } finally {
1894
+ this.disconnectWebSocket();
1895
+ }
1896
+ }
1897
+ /**
1898
+ * Disconnect WebSocket
1899
+ */
1900
+ disconnectWebSocket() {
1901
+ if (this.websocket) {
1902
+ this.websocket.close();
1903
+ this.websocket = null;
1904
+ }
1905
+ }
1906
+ /**
1907
+ * Get agent ID - mirrors Python agent_id property
1908
+ */
1909
+ get agentId() {
1910
+ if (!this.response) {
1911
+ throw new Error("You need to run the agent first to get the agent id");
1912
+ }
1913
+ return this.response.agent_id;
1914
+ }
1915
+ /**
1916
+ * Get session ID - mirrors Python session_id property
1917
+ */
1918
+ get sessionId() {
1919
+ if (!this.response) {
1920
+ throw new Error("You need to run the agent first to get the session id");
1921
+ }
1922
+ return this.response.session_id;
1923
+ }
1924
+ /**
1925
+ * Check if agent is running - convenience method
1926
+ */
1927
+ isRunning() {
1928
+ return this.response !== null;
1929
+ }
1930
+ };
1931
+
1932
+ // src/vaults.ts
1933
+ var NotteVault = class {
1934
+ constructor(client2, options = {}) {
1935
+ this._vaultId = null;
1936
+ this.initPromise = null;
1937
+ this.client = client2;
1938
+ if (options && "vault_id" in options && options.vault_id) {
1939
+ this.initPromise = this.initExistingVault(options.vault_id);
1940
+ } else {
1941
+ this.initPromise = this.initNewVault(options || {});
1942
+ }
1943
+ }
1944
+ async initExistingVault(vaultId) {
1945
+ await this.verifyVaultExists(vaultId);
1946
+ this._vaultId = vaultId;
1947
+ return this._vaultId;
1948
+ }
1949
+ async initNewVault(createData) {
1950
+ const response = await vaultCreate({
1951
+ client: this.client.getClient(),
1952
+ body: createData
1953
+ });
1954
+ if (response?.error) {
1955
+ throw new Error(`Failed to create vault: ${formatError(response.error)}`);
1956
+ }
1957
+ const vault = response.data;
1958
+ console.warn(`[Vault] ${vault.vault_id} created since no vault id was provided. Please store this to retrieve it later.`);
1959
+ this._vaultId = vault.vault_id;
1960
+ return this._vaultId;
1961
+ }
1962
+ async verifyVaultExists(vaultId) {
1963
+ if (vaultId.length === 0) {
1964
+ throw new Error("Vault ID cannot be empty");
1965
+ }
1966
+ const response = await vaultCredentialsList({
1967
+ client: this.client.getClient(),
1968
+ path: {
1969
+ vault_id: vaultId
1970
+ }
1971
+ });
1972
+ if (response?.error) {
1973
+ throw new Error(`Failed to verify vault exists: ${formatError(response.error)}`);
1974
+ }
1975
+ }
1976
+ async ensureInitialized() {
1977
+ if (this._vaultId) {
1978
+ return this._vaultId;
1979
+ }
1980
+ if (this.initPromise) {
1981
+ return await this.initPromise;
1982
+ }
1983
+ throw new Error("Vault not initialized");
1984
+ }
1985
+ get vaultId() {
1986
+ if (!this._vaultId) {
1987
+ throw new Error("Vault not initialized. Use await on vault operations first.");
1988
+ }
1989
+ return this._vaultId;
1990
+ }
1991
+ /**
1992
+ * Start the vault - no-op for compatibility with Python interface
1993
+ */
1994
+ start() {
1995
+ }
1996
+ /**
1997
+ * Stop the vault - deletes it and all credentials
1998
+ */
1999
+ async stop() {
2000
+ const vaultId = await this.ensureInitialized();
2001
+ console.log(`[Vault] ${vaultId} deleted. All credentials have been deleted.`);
2002
+ await this.delete();
2003
+ }
2004
+ /**
2005
+ * Add or update credentials for a URL
2006
+ */
2007
+ async addCredentials(url, credentials) {
2008
+ if (credentials.mfa_secret) {
2009
+ this.validateMfaSecret(credentials.mfa_secret);
2010
+ }
2011
+ const vaultId = await this.ensureInitialized();
2012
+ const response = await vaultCredentialsAdd({
2013
+ client: this.client.getClient(),
2014
+ path: {
2015
+ vault_id: vaultId
2016
+ },
2017
+ body: { url, credentials }
2018
+ });
2019
+ if (response?.error) {
2020
+ throw new Error(`Failed to add credentials: ${formatError(response.error)}`);
2021
+ }
2022
+ }
2023
+ /**
2024
+ * Get credentials for a URL
2025
+ */
2026
+ async getCredentials(url) {
2027
+ try {
2028
+ const vaultId = await this.ensureInitialized();
2029
+ const response = await vaultCredentialsGet({
2030
+ client: this.client.getClient(),
2031
+ path: {
2032
+ vault_id: vaultId
2033
+ },
2034
+ query: { url }
2035
+ });
2036
+ if (response?.error) {
2037
+ return null;
2038
+ }
2039
+ const credentialsResponse = response.data;
2040
+ return credentialsResponse.credentials;
2041
+ } catch (error) {
2042
+ return null;
2043
+ }
2044
+ }
2045
+ /**
2046
+ * Delete credentials for a URL
2047
+ */
2048
+ async deleteCredentials(url) {
2049
+ const vaultId = await this.ensureInitialized();
2050
+ const response = await vaultCredentialsDelete({
2051
+ client: this.client.getClient(),
2052
+ path: {
2053
+ vault_id: vaultId
2054
+ },
2055
+ query: { url }
2056
+ });
2057
+ if (response?.error) {
2058
+ throw new Error(`Failed to delete credentials: ${formatError(response.error)}`);
2059
+ }
2060
+ }
2061
+ /**
2062
+ * Set credit card information
2063
+ */
2064
+ async setCreditCard(creditCard) {
2065
+ const vaultId = await this.ensureInitialized();
2066
+ const response = await vaultCreditCardSet({
2067
+ client: this.client.getClient(),
2068
+ path: {
2069
+ vault_id: vaultId
2070
+ },
2071
+ body: { credit_card: creditCard }
2072
+ });
2073
+ if (response?.error) {
2074
+ throw new Error(`Failed to set credit card: ${formatError(response.error)}`);
2075
+ }
2076
+ }
2077
+ /**
2078
+ * Get credit card information
2079
+ */
2080
+ async getCreditCard() {
2081
+ const vaultId = await this.ensureInitialized();
2082
+ const response = await vaultCreditCardGet({
2083
+ client: this.client.getClient(),
2084
+ path: {
2085
+ vault_id: vaultId
2086
+ }
2087
+ });
2088
+ if (response?.error) {
2089
+ throw new Error(`Failed to get credit card: ${formatError(response.error)}`);
2090
+ }
2091
+ const creditCardResponse = response.data;
2092
+ return creditCardResponse.credit_card;
2093
+ }
2094
+ /**
2095
+ * List all credentials in the vault
2096
+ */
2097
+ async listCredentials() {
2098
+ const vaultId = await this.ensureInitialized();
2099
+ const response = await vaultCredentialsList({
2100
+ client: this.client.getClient(),
2101
+ path: {
2102
+ vault_id: vaultId
2103
+ }
2104
+ });
2105
+ if (response?.error) {
2106
+ throw new Error(`Failed to list credentials: ${formatError(response.error)}`);
2107
+ }
2108
+ const credentialsResponse = response.data;
2109
+ return credentialsResponse.credentials;
2110
+ }
2111
+ /**
2112
+ * Delete credit card information
2113
+ */
2114
+ async deleteCreditCard() {
2115
+ const vaultId = await this.ensureInitialized();
2116
+ const response = await vaultCreditCardDelete({
2117
+ client: this.client.getClient(),
2118
+ path: {
2119
+ vault_id: vaultId
2120
+ }
2121
+ });
2122
+ if (response?.error) {
2123
+ throw new Error(`Failed to delete credit card: ${formatError(response.error)}`);
2124
+ }
2125
+ }
2126
+ /**
2127
+ * Delete the entire vault
2128
+ */
2129
+ async delete() {
2130
+ const vaultId = await this.ensureInitialized();
2131
+ const response = await vaultDelete({
2132
+ client: this.client.getClient(),
2133
+ path: {
2134
+ vault_id: vaultId
2135
+ }
2136
+ });
2137
+ if (response?.error) {
2138
+ throw new Error(`Failed to delete vault: ${formatError(response.error)}`);
2139
+ }
2140
+ }
2141
+ /**
2142
+ * Add credentials from environment variables
2143
+ * Mirrors Python's add_credentials_from_env method
2144
+ */
2145
+ async addCredentialsFromEnv(url) {
2146
+ const domain = this.extractDomainFromUrl(url);
2147
+ const envPrefix = domain.replace(/[^a-zA-Z0-9]/g, "_").toUpperCase();
2148
+ const email = process.env[`${envPrefix}_EMAIL`] || process.env[`${envPrefix}_USERNAME`];
2149
+ const password = process.env[`${envPrefix}_PASSWORD`];
2150
+ if (!email || !password) {
2151
+ throw new Error(`Environment variables ${envPrefix}_EMAIL/USERNAME and ${envPrefix}_PASSWORD are required`);
2152
+ }
2153
+ const credentials = { email, password };
2154
+ const mfaSecret = process.env[`${envPrefix}_MFA_SECRET`];
2155
+ if (mfaSecret) {
2156
+ this.validateMfaSecret(mfaSecret);
2157
+ credentials.mfa_secret = mfaSecret;
2158
+ }
2159
+ await this.addCredentials(url, credentials);
2160
+ }
2161
+ /**
2162
+ * Extract domain from URL for environment variable naming
2163
+ */
2164
+ extractDomainFromUrl(url) {
2165
+ try {
2166
+ const urlObj = new URL(url);
2167
+ return urlObj.hostname.replace(/^www\./, "");
2168
+ } catch {
2169
+ const match = url.match(/(?:https?:\/\/)?(?:www\.)?([^\/]+)/);
2170
+ return match ? match[1] : url;
2171
+ }
2172
+ }
2173
+ /**
2174
+ * Validate MFA secret format
2175
+ * Mirrors Python's MFA secret validation
2176
+ */
2177
+ validateMfaSecret(mfaSecret) {
2178
+ if (/^\d+$/.test(mfaSecret)) {
2179
+ throw new Error("MFA secret cannot be all numbers. Please provide a valid base32 secret.");
2180
+ }
2181
+ if (mfaSecret.length < 16) {
2182
+ throw new Error("MFA secret must be at least 16 characters long");
2183
+ }
2184
+ }
2185
+ /**
2186
+ * Generate a secure random password
2187
+ * Mirrors Python's generate_password method
2188
+ */
2189
+ generatePassword(length = 20, includeSpecialChars = true) {
2190
+ const minRequiredLength = includeSpecialChars ? 4 : 3;
2191
+ if (length < minRequiredLength) {
2192
+ throw new Error(`Password length must be at least ${minRequiredLength} characters`);
2193
+ }
2194
+ const lowercase = "abcdefghijklmnopqrstuvwxyz";
2195
+ const uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
2196
+ const digits = "0123456789";
2197
+ const specialChars = "!@#$%^&*()_+-=[]|;:,.<>?";
2198
+ const crypto = globalThis.crypto || __require("crypto");
2199
+ const array = new Uint8Array(length);
2200
+ crypto.getRandomValues(array);
2201
+ const allowedChars = includeSpecialChars ? "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_" : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2202
+ let password = Array.from(array, (byte) => allowedChars[byte % allowedChars.length]).join("").slice(0, length);
2203
+ const passwordArray = password.split("");
2204
+ if (!includeSpecialChars) {
2205
+ for (let i = 0; i < passwordArray.length; i++) {
2206
+ if (specialChars.includes(passwordArray[i])) {
2207
+ const alphanumeric = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
2208
+ passwordArray[i] = alphanumeric[Math.floor(Math.random() * alphanumeric.length)];
2209
+ }
2210
+ }
2211
+ }
2212
+ let maxIterations = 10;
2213
+ while (maxIterations-- > 0) {
2214
+ let allRequirementsMet = true;
2215
+ if (!passwordArray.some((c) => lowercase.includes(c))) {
2216
+ const index = Math.floor(Math.random() * passwordArray.length);
2217
+ passwordArray[index] = lowercase[Math.floor(Math.random() * lowercase.length)];
2218
+ allRequirementsMet = false;
2219
+ }
2220
+ if (!passwordArray.some((c) => uppercase.includes(c))) {
2221
+ const index = Math.floor(Math.random() * passwordArray.length);
2222
+ passwordArray[index] = uppercase[Math.floor(Math.random() * uppercase.length)];
2223
+ allRequirementsMet = false;
2224
+ }
2225
+ if (!passwordArray.some((c) => digits.includes(c))) {
2226
+ const index = Math.floor(Math.random() * passwordArray.length);
2227
+ passwordArray[index] = digits[Math.floor(Math.random() * digits.length)];
2228
+ allRequirementsMet = false;
2229
+ }
2230
+ if (includeSpecialChars && !passwordArray.some((c) => specialChars.includes(c))) {
2231
+ const index = Math.floor(Math.random() * passwordArray.length);
2232
+ passwordArray[index] = specialChars[Math.floor(Math.random() * specialChars.length)];
2233
+ allRequirementsMet = false;
2234
+ }
2235
+ if (allRequirementsMet) {
2236
+ break;
2237
+ }
2238
+ }
2239
+ return passwordArray.join("");
2240
+ }
2241
+ };
2242
+
2243
+ // src/personas.ts
2244
+ var NottePersona = class {
2245
+ constructor(client2, options = {}) {
2246
+ this.response = null;
2247
+ this.initPromise = null;
2248
+ this.client = client2;
2249
+ if (options && "persona_id" in options && options.persona_id) {
2250
+ this.initPromise = this.initExistingPersona(options.persona_id);
2251
+ this._initRequest = {};
2252
+ } else {
2253
+ const createData = options || {};
2254
+ this._initRequest = createData;
2255
+ this.initPromise = this.initNewPersona(createData);
2256
+ }
2257
+ }
2258
+ /**
2259
+ * Get persona info
2260
+ */
2261
+ get info() {
2262
+ if (this.response === null) {
2263
+ throw new Error("Persona not initialized");
2264
+ }
2265
+ return this.response;
2266
+ }
2267
+ /**
2268
+ * Get vault (cached property equivalent)
2269
+ */
2270
+ get vault() {
2271
+ if (this._vault === void 0) {
2272
+ const vault = this._getVault();
2273
+ if (vault === null) {
2274
+ throw new Error(
2275
+ "Persona has no vault. Please create a new persona using `create_vault=true` to use this feature."
2276
+ );
2277
+ }
2278
+ this._vault = vault;
2279
+ }
2280
+ return this._vault;
2281
+ }
2282
+ /**
2283
+ * Check if persona has a vault
2284
+ */
2285
+ get hasVault() {
2286
+ return this.info.vault_id !== null;
2287
+ }
2288
+ async initExistingPersona(personaId) {
2289
+ const response = await personaGet({
2290
+ client: this.client.getClient(),
2291
+ path: {
2292
+ persona_id: personaId
2293
+ }
2294
+ });
2295
+ if (response?.error) {
2296
+ throw new Error(`Failed to get persona: ${formatError(response.error)}`);
2297
+ }
2298
+ this.response = response.data;
2299
+ return this.response;
2300
+ }
2301
+ async initNewPersona(createData) {
2302
+ const response = await personaCreate({
2303
+ client: this.client.getClient(),
2304
+ body: createData
2305
+ });
2306
+ if (response?.error) {
2307
+ throw new Error(`Failed to create persona: ${formatError(response.error)}`);
2308
+ }
2309
+ this.response = response.data;
2310
+ console.warn(
2311
+ `[Persona] ${this.response.persona_id} created since no persona id was provided. Please store this to retrieve it later.`
2312
+ );
2313
+ return this.response;
2314
+ }
2315
+ async ensureInitialized() {
2316
+ if (this.response) {
2317
+ return this.response;
2318
+ }
2319
+ if (this.initPromise) {
2320
+ return await this.initPromise;
2321
+ }
2322
+ throw new Error("Persona not initialized");
2323
+ }
2324
+ /**
2325
+ * Get persona ID
2326
+ */
2327
+ get personaId() {
2328
+ if (!this.response) {
2329
+ throw new Error("Persona not initialized. Use await on persona operations first.");
2330
+ }
2331
+ return this.response.persona_id;
2332
+ }
2333
+ /**
2334
+ * Start the persona - ensures initialization
2335
+ */
2336
+ async start() {
2337
+ if (this.response === null) {
2338
+ await this.create();
2339
+ }
2340
+ }
2341
+ /**
2342
+ * Stop the persona - deletes it
2343
+ */
2344
+ async stop() {
2345
+ await this.ensureInitialized();
2346
+ console.log(`[Persona] ${this.personaId} deleted.`);
2347
+ await this.delete();
2348
+ }
2349
+ /**
2350
+ * Get vault - private helper method
2351
+ */
2352
+ _getVault() {
2353
+ if (this.info.vault_id === null) {
2354
+ return null;
2355
+ }
2356
+ return new NotteVault(this.client, { vault_id: this.info.vault_id });
2357
+ }
2358
+ /**
2359
+ * Create the persona
2360
+ */
2361
+ async create() {
2362
+ if (this.response !== null) {
2363
+ throw new Error(`Persona ${this.personaId} already initialized`);
2364
+ }
2365
+ const response = await personaCreate({
2366
+ client: this.client.getClient(),
2367
+ body: this._initRequest
2368
+ });
2369
+ if (response?.error) {
2370
+ throw new Error(`Failed to create persona: ${formatError(response.error)}`);
2371
+ }
2372
+ this.response = response.data;
2373
+ }
2374
+ /**
2375
+ * Delete the persona from the notte console
2376
+ */
2377
+ async delete() {
2378
+ await this.ensureInitialized();
2379
+ const response = await personaDelete({
2380
+ client: this.client.getClient(),
2381
+ path: {
2382
+ persona_id: this.personaId
2383
+ }
2384
+ });
2385
+ if (response?.error) {
2386
+ throw new Error(`Failed to delete persona: ${formatError(response.error)}`);
2387
+ }
2388
+ return response.data;
2389
+ }
2390
+ /**
2391
+ * Add credentials to the persona (generates a password and stores it in the vault)
2392
+ */
2393
+ async addCredentials(url) {
2394
+ const vault = this._getVault();
2395
+ if (vault === null) {
2396
+ throw new Error(
2397
+ "Cannot add credentials to a persona without a vault. Please create a new persona using `create_vault=true` to use this feature."
2398
+ );
2399
+ }
2400
+ const password = vault.generatePassword();
2401
+ await vault.addCredentials(url, {
2402
+ email: this.info.email,
2403
+ password
2404
+ });
2405
+ }
2406
+ /**
2407
+ * Read recent emails sent to the persona
2408
+ */
2409
+ async emails(options) {
2410
+ await this.ensureInitialized();
2411
+ const response = await personaEmailsList({
2412
+ client: this.client.getClient(),
2413
+ path: {
2414
+ persona_id: this.personaId
2415
+ },
2416
+ query: options || {}
2417
+ });
2418
+ if (response?.error) {
2419
+ throw new Error(`Failed to list emails: ${formatError(response.error)}`);
2420
+ }
2421
+ return response.data;
2422
+ }
2423
+ /**
2424
+ * Read recent SMS messages sent to the persona
2425
+ */
2426
+ async sms(options) {
2427
+ await this.ensureInitialized();
2428
+ const response = await personaSmsList({
2429
+ client: this.client.getClient(),
2430
+ path: {
2431
+ persona_id: this.personaId
2432
+ },
2433
+ query: options || {}
2434
+ });
2435
+ if (response?.error) {
2436
+ throw new Error(`Failed to list SMS messages: ${formatError(response.error)}`);
2437
+ }
2438
+ return response.data;
2439
+ }
2440
+ /**
2441
+ * Get persona information (alias for ensureInitialized)
2442
+ */
2443
+ async get() {
2444
+ await this.ensureInitialized();
2445
+ return this.response;
2446
+ }
2447
+ /**
2448
+ * Context manager for automatic cleanup
2449
+ */
2450
+ async use(callback) {
2451
+ try {
2452
+ return await callback(this);
2453
+ } finally {
2454
+ if (this._initRequest && !("persona_id" in this._initRequest)) {
2455
+ try {
2456
+ await this.delete();
2457
+ } catch (error) {
2458
+ console.warn(`Failed to delete persona during cleanup: ${error}`);
2459
+ }
2460
+ }
2461
+ }
2462
+ }
2463
+ };
2464
+
2465
+ // src/version.ts
2466
+ var SDK_VERSION = true ? "0.0.1" : "dev";
2467
+
2468
+ // src/functions.ts
2469
+ var NotteFunction = class {
2470
+ constructor(client2, options) {
2471
+ this.client = client2;
2472
+ this.functionId = options.function_id;
2473
+ this.decryptionKey = options.decryption_key;
2474
+ }
2475
+ /**
2476
+ * Get metadata for a specific function run
2477
+ */
2478
+ async retrieve(functionRunId) {
2479
+ try {
2480
+ const response = await functionRunGetMetadata({
2481
+ client: this.client.getClient(),
2482
+ path: {
2483
+ function_id: this.functionId,
2484
+ run_id: functionRunId
2485
+ }
2486
+ });
2487
+ if (response?.error) {
2488
+ throw new Error(`Failed to get function run metadata: ${formatError(response.error)}`);
2489
+ }
2490
+ return response.data;
2491
+ } catch (error) {
2492
+ if (error instanceof Error && error.message.startsWith("Failed to get function run metadata:")) {
2493
+ throw error;
2494
+ }
2495
+ throw new Error(`Failed to get function run metadata: ${error instanceof Error ? error.message : String(error)}`);
2496
+ }
2497
+ }
2498
+ /**
2499
+ * Start a function run
2500
+ */
2501
+ async run(variables = {}) {
2502
+ const apiKey = this.client.getConfig().apiKey || "";
2503
+ if (!apiKey) {
2504
+ throw new Error("API key is required. Provide it via config.apiKey or set the NOTTE_API_KEY environment variable.");
2505
+ }
2506
+ try {
2507
+ const response = await functionRunStart({
2508
+ client: this.client.getClient(),
2509
+ path: {
2510
+ function_id: this.functionId
2511
+ },
2512
+ headers: {
2513
+ "x-notte-api-key": apiKey,
2514
+ "x-notte-request-origin": "sdk-node",
2515
+ "x-notte-sdk-version": SDK_VERSION
2516
+ },
2517
+ body: {
2518
+ workflow_id: this.functionId,
2519
+ variables,
2520
+ stream: false
2521
+ }
2522
+ });
2523
+ if (response?.error) {
2524
+ throw new Error(`Failed to start function run: ${formatError(response.error)}`);
2525
+ }
2526
+ return response.data;
2527
+ } catch (error) {
2528
+ if (error instanceof Error && error.message.startsWith("Failed to start function run:")) {
2529
+ throw error;
2530
+ }
2531
+ throw new Error(`Failed to run function: ${error instanceof Error ? error.message : String(error)}`);
2532
+ }
2533
+ }
2534
+ /**
2535
+ * Get the function ID
2536
+ */
2537
+ getFunctionId() {
2538
+ return this.functionId;
2539
+ }
2540
+ };
2541
+
2542
+ // src/client.ts
2543
+ import { z as z2 } from "zod";
2544
+ var NotteClient = class {
2545
+ constructor(config = {}) {
2546
+ const apiKey = config.apiKey || process.env.NOTTE_API_KEY;
2547
+ const isProxyMode = config.baseUrl && !config.baseUrl.startsWith("https://");
2548
+ if (!apiKey && !isProxyMode) {
2549
+ throw new Error("API key is required. Provide it via config.apiKey or set the NOTTE_API_KEY environment variable.");
2550
+ }
2551
+ this.config = {
2552
+ baseUrl: config.baseUrl || "https://api.notte.cc",
2553
+ apiKey,
2554
+ ...config
2555
+ };
2556
+ client.setConfig({
2557
+ baseUrl: this.config.baseUrl
2558
+ });
2559
+ client.interceptors.request.use((request) => {
2560
+ request.headers.set("Authorization", `Bearer ${this.config.apiKey}`);
2561
+ request.headers.set("x-notte-request-origin", "sdk-node");
2562
+ request.headers.set("x-notte-sdk-version", SDK_VERSION);
2563
+ return request;
2564
+ });
2565
+ }
2566
+ /**
2567
+ * Create a new session
2568
+ */
2569
+ Session(options = {}) {
2570
+ return new Session(this, options);
2571
+ }
2572
+ /**
2573
+ * Create a new agent
2574
+ */
2575
+ Agent(options) {
2576
+ return new Agent(this, options);
2577
+ }
2578
+ /**
2579
+ * Create or access a vault
2580
+ */
2581
+ Vault(options) {
2582
+ return new NotteVault(this, options);
2583
+ }
2584
+ /**
2585
+ * Create or access a persona
2586
+ */
2587
+ Persona(options) {
2588
+ return new NottePersona(this, options);
2589
+ }
2590
+ /**
2591
+ * Create or access a function
2592
+ */
2593
+ NotteFunction(options) {
2594
+ return new NotteFunction(this, options);
2595
+ }
2596
+ /**
2597
+ * Personas client for listing and managing personas
2598
+ */
2599
+ get personas() {
2600
+ return {
2601
+ list: async (options) => {
2602
+ const response = await listPersonas({
2603
+ client: this.getClient(),
2604
+ query: options || {}
2605
+ });
2606
+ if (response?.error) {
2607
+ throw new Error(`Failed to list personas: ${JSON.stringify(response.error)}`);
2608
+ }
2609
+ return response.data?.items || [];
2610
+ }
2611
+ };
2612
+ }
2613
+ /**
2614
+ * Get the configured client instance
2615
+ */
2616
+ getClient() {
2617
+ return client;
2618
+ }
2619
+ async scrape(url, options = {}) {
2620
+ const apiOptions = { ...options };
2621
+ if (options.response_format && typeof options.response_format.parse === "function") {
2622
+ if (options.json_schema) {
2623
+ apiOptions.response_format = options.json_schema;
2624
+ } else {
2625
+ apiOptions.response_format = z2.toJSONSchema(options.response_format);
2626
+ }
2627
+ if (!apiOptions.instructions) {
2628
+ const schemaStr = JSON.stringify(apiOptions.response_format);
2629
+ if (schemaStr.includes("plans") || schemaStr.includes("plan")) {
2630
+ apiOptions.instructions = "Extract pricing plans from the page";
2631
+ } else if (schemaStr.includes("products") || schemaStr.includes("product")) {
2632
+ apiOptions.instructions = "Extract product information from the page";
2633
+ } else if (schemaStr.includes("articles") || schemaStr.includes("article")) {
2634
+ apiOptions.instructions = "Extract article information from the page";
2635
+ } else {
2636
+ apiOptions.instructions = "Extract structured data from the page based on the provided schema";
2637
+ }
2638
+ }
2639
+ }
2640
+ const response = await scrapeWebpage({
2641
+ client: this.getClient(),
2642
+ body: {
2643
+ url,
2644
+ ...apiOptions
2645
+ }
2646
+ });
2647
+ if (response?.error) {
2648
+ throw new Error(`Failed to scrape webpage: ${JSON.stringify(response.error)}`);
2649
+ }
2650
+ const scrapeResponse = response.data;
2651
+ return processScrapeResponse(scrapeResponse, options);
2652
+ }
2653
+ /**
2654
+ * Get the client configuration
2655
+ */
2656
+ getConfig() {
2657
+ return this.config;
2658
+ }
2659
+ };
2660
+
2661
+ // src/proxy/types.ts
2662
+ var NotteProxyAuthError = class extends Error {
2663
+ constructor(message = "Unauthorized") {
2664
+ super(message);
2665
+ this.name = "NotteProxyAuthError";
2666
+ }
2667
+ };
2668
+
2669
+ // src/index.ts
2670
+ var createClient2 = (config) => {
2671
+ if (config?.baseUrl) {
2672
+ client.setConfig({ baseUrl: config.baseUrl });
2673
+ }
2674
+ if (config?.token) {
2675
+ client.interceptors.request.use((request) => {
2676
+ request.headers.set("Authorization", `Bearer ${config.token}`);
2677
+ return request;
2678
+ });
2679
+ }
2680
+ return client;
2681
+ };
2682
+ export {
2683
+ Agent,
2684
+ NotteClient,
2685
+ NotteFunction,
2686
+ NottePersona,
2687
+ NotteProxyAuthError,
2688
+ NotteVault,
2689
+ Session,
2690
+ agentStart,
2691
+ agentStatus,
2692
+ agentStop,
2693
+ anythingStart,
2694
+ client,
2695
+ createClient2 as createClient,
2696
+ NotteClient as default,
2697
+ fileDownload,
2698
+ fileListDownloads,
2699
+ fileListUploads,
2700
+ fileUpload,
2701
+ fileUploadDownloadedFile,
2702
+ functionCreate,
2703
+ functionDelete,
2704
+ functionDownloadUrl,
2705
+ functionFork,
2706
+ functionRunGetMetadata,
2707
+ functionRunStart,
2708
+ functionRunStop,
2709
+ functionRunUpdateMetadata,
2710
+ functionScheduleDelete,
2711
+ functionScheduleSet,
2712
+ functionUpdate,
2713
+ getScript,
2714
+ getSessionScript,
2715
+ getUsage,
2716
+ getUsageLogs,
2717
+ healthCheck,
2718
+ improvePrompt,
2719
+ listAgents,
2720
+ listFunctionRunsByFunctionId,
2721
+ listFunctions,
2722
+ listPersonas,
2723
+ listSessions,
2724
+ listVaults,
2725
+ nudgePrompt,
2726
+ pageExecute,
2727
+ pageObserve,
2728
+ pageScrape,
2729
+ pageScreenshot,
2730
+ personaCreate,
2731
+ personaDelete,
2732
+ personaEmailsList,
2733
+ personaGet,
2734
+ personaSmsList,
2735
+ profileCreate,
2736
+ profileDelete,
2737
+ profileGet,
2738
+ profileList,
2739
+ scrapeFromHtml,
2740
+ scrapeWebpage,
2741
+ sessionCookiesGet,
2742
+ sessionCookiesSet,
2743
+ sessionDebugInfo,
2744
+ sessionNetworkLogs,
2745
+ sessionOffset,
2746
+ sessionReplay,
2747
+ sessionStart,
2748
+ sessionStatus,
2749
+ sessionStop,
2750
+ vaultCreate,
2751
+ vaultCredentialsAdd,
2752
+ vaultCredentialsDelete,
2753
+ vaultCredentialsGet,
2754
+ vaultCredentialsList,
2755
+ vaultCreditCardDelete,
2756
+ vaultCreditCardGet,
2757
+ vaultCreditCardSet,
2758
+ vaultDelete,
2759
+ vaultUpdate
2760
+ };
2761
+ //# sourceMappingURL=index.mjs.map