@oya-ai/browser 1.0.107 → 1.0.111

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -255,6 +255,8 @@ interface BrowserInfo {
255
255
  }
256
256
  /** A browser plus what it has been doing, from `browser.status()`. */
257
257
  interface BrowserDetail extends BrowserInfo {
258
+ /** The actions it does, sorted, one spelling each: an action not listed answers action_unsupported or action_unknown. */
259
+ actions: string[];
258
260
  /** Its most recent commands, newest first. */
259
261
  activity: Activity[];
260
262
  }
@@ -342,10 +344,6 @@ interface Config extends Omit<ConfigUpdate, 'llm_provider' | 'browser_provider'
342
344
  }>;
343
345
  }
344
346
 
345
- /**
346
- * OyaError: the one error type the SDK throws for a failed call, carrying the
347
- * HTTP status and the server's answer so a caller can branch on either.
348
- */
349
347
  /** A failed API call or browser command. */
350
348
  declare class OyaError extends Error {
351
349
  /** The HTTP status, or the SDK's own status for errors it raises itself. */
@@ -689,6 +687,31 @@ interface SiteCredentials {
689
687
  /** The password; stored sealed and never returned. */
690
688
  password: string;
691
689
  }
690
+ /** A cookie in a persona's jar. */
691
+ interface Cookie {
692
+ /** The cookie's name. */
693
+ name: string;
694
+ /** Its value: a session, so treat it as a secret. */
695
+ value: string;
696
+ /** The domain it is sent to; a leading dot includes subdomains. */
697
+ domain: string;
698
+ /** The path it is sent to. `/` when omitted. */
699
+ path?: string;
700
+ /** Sent over HTTPS only. */
701
+ secure?: boolean;
702
+ /** Hidden from page scripts. */
703
+ httpOnly?: boolean;
704
+ /** `Strict`, `Lax` or `None` (Playwright), or `strict`, `lax`, `no_restriction` (Chrome extensions). */
705
+ sameSite?: string;
706
+ /** When it expires, in seconds since the epoch. A session cookie has none. */
707
+ expirationDate?: number;
708
+ /** The same, as Playwright and Puppeteer spell it; `-1` for a session cookie. */
709
+ expires?: number;
710
+ /** Whether it is sent to this exact host only. */
711
+ hostOnly?: boolean;
712
+ }
713
+ /** The formats a jar is exported in: as stored, or ready for Playwright's `context.addCookies()`. */
714
+ type CookieFormat = 'json' | 'playwright';
692
715
 
693
716
  /**
694
717
  * Types for the durable control plane: sessions and their lifecycle, human
@@ -696,6 +719,13 @@ interface SiteCredentials {
696
719
  */
697
720
  /** What a member or credential may do: read, operate browsers, or also administer the project. */
698
721
  type ControlRole = 'viewer' | 'operator' | 'administrator';
722
+ /** How to recover a session: in place (the default), or replaced by a fresh one. */
723
+ interface RecoverOptions {
724
+ /** Start a fresh session in its place. */
725
+ replace?: boolean;
726
+ /** cdp only: the Chrome the replacement runs on. */
727
+ wsUrl?: string;
728
+ }
699
729
  /** What a human holding the control lease may send. Mirrors the server's allowlist. */
700
730
  type HumanInputAction = 'click' | 'type' | 'press_key' | 'scroll' | 'click_coordinates' | 'double_click' | 'drag' | 'mouse_move' | 'scroll_at' | 'type_text' | 'keyboard_type' | 'navigate' | 'back' | 'forward' | 'reload' | 'screenshot' | 'analyze' | 'read_page';
701
731
  /** A browser session as the control plane records it, including ones no longer connected. */
@@ -809,14 +839,24 @@ interface OyaOptions {
809
839
  fetch?: typeof globalThis.fetch;
810
840
  }
811
841
 
842
+ /** Where the key and the address came from, so a message names the one to fix. */
843
+ interface Origin {
844
+ /** The key's source, as a message names it: "the apiKey option", "OYA_API_KEY" or "~/.oya/config.json". */
845
+ apiKeyFrom: string;
846
+ /** The address's source, named the same way, or "default" for the hosted one. */
847
+ baseUrlFrom: string;
848
+ /** Whether a key is also saved by `oya login`, which an environment key overrides. */
849
+ savedKey: boolean;
850
+ }
812
851
  /** The one HTTP path. Everything else in this package is a wrapper over it. */
813
852
  declare class Http {
814
853
  readonly baseUrl: string;
815
854
  readonly apiKey: string;
816
855
  private readonly timeoutMs;
817
856
  private readonly fetchImpl;
818
- /** Stores where to call, with which key, how long to wait and which fetch to use. */
819
- constructor(baseUrl: string, apiKey: string, timeoutMs: number, fetchImpl: typeof globalThis.fetch);
857
+ readonly origin: Origin;
858
+ /** Stores where to call, with which key, how long to wait, which fetch to use, and where the key and address came from. */
859
+ constructor(baseUrl: string, apiKey: string, timeoutMs: number, fetchImpl: typeof globalThis.fetch, origin?: Origin);
820
860
  /** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
821
861
  request<T>(method: string, path: string, body?: unknown, timeoutMs?: number, headers?: Record<string, string>): Promise<T>;
822
862
  /** The fetch options for one call, with this client's key on them. */
@@ -991,6 +1031,17 @@ interface SiteLogins {
991
1031
  /** Usernames only. */
992
1032
  credentials: SiteLogin[];
993
1033
  }
1034
+ /** `PUT /api/pool/cookies`: what an import did. */
1035
+ interface CookiesImported {
1036
+ /** The persona the cookies went to. */
1037
+ persona: string;
1038
+ /** Cookies merged into the jar. */
1039
+ imported: number;
1040
+ /** Cookies left out: no name, value or domain, or already expired. */
1041
+ skipped: number;
1042
+ /** Cookies in the jar afterwards. */
1043
+ total: number;
1044
+ }
994
1045
 
995
1046
  /**
996
1047
  * The shapes Browser's methods take and return that are not part of the
@@ -1286,7 +1337,7 @@ declare class Oya {
1286
1337
  removeMember: (userId: string) => Promise<Ack>;
1287
1338
  createCredential: (options: CredentialRequest) => Promise<NewCredential>;
1288
1339
  revokeCredential: (id: string) => Promise<Ack>;
1289
- recover: (id: string, replace?: boolean) => Promise<unknown>;
1340
+ recover: (id: string, options?: boolean | RecoverOptions) => Promise<unknown>;
1290
1341
  ticket: (id: string) => Promise<Ticket>;
1291
1342
  events: (after?: number) => Promise<EventPage>;
1292
1343
  cancel: (id: string) => Promise<ControlSession>;
@@ -1316,6 +1367,10 @@ declare class Oya {
1316
1367
  };
1317
1368
  /** Identities: fingerprint, cookie jar and proxy bound together, plus their stored factors and logins. */
1318
1369
  readonly personas: {
1370
+ copyCookies: (from: string, to: string) => Promise<CookiesImported>;
1371
+ clearCookies: (id: string) => Promise<void>;
1372
+ cookies: (id: string, format?: CookieFormat) => Promise<Cookie[]>;
1373
+ importCookies: (id: string, list: Cookie[]) => Promise<CookiesImported>;
1319
1374
  setCredentials: (id: string, config: SiteCredentials) => Promise<CredentialsSaved>;
1320
1375
  credentials: (id: string) => Promise<SiteLogins>;
1321
1376
  clearCredentials: (id: string, domain: string) => Promise<void>;
@@ -1348,6 +1403,10 @@ declare class Oya {
1348
1403
  };
1349
1404
  /** Saved profiles. `personas` is retained as an alias for existing clients. */
1350
1405
  readonly profiles: {
1406
+ copyCookies: (from: string, to: string) => Promise<CookiesImported>;
1407
+ clearCookies: (id: string) => Promise<void>;
1408
+ cookies: (id: string, format?: CookieFormat) => Promise<Cookie[]>;
1409
+ importCookies: (id: string, list: Cookie[]) => Promise<CookiesImported>;
1351
1410
  setCredentials: (id: string, config: SiteCredentials) => Promise<CredentialsSaved>;
1352
1411
  credentials: (id: string) => Promise<SiteLogins>;
1353
1412
  clearCredentials: (id: string, domain: string) => Promise<void>;
@@ -1369,4 +1428,4 @@ declare class Oya {
1369
1428
  private waitUntilConnected;
1370
1429
  }
1371
1430
 
1372
- export { type Activity, type Analysis, type AnalyzeOptions, type AttentionRequest, type Block, Browser, type BrowserDetail, type BrowserInfo, type CaptchaResult, type CaptchaSolver, type Config, type ConfigUpdate, type ControlCredential, type ControlEvent, type ControlOverview, type ControlRole, type ControlSession, type Element, type FileValue, type Fingerprint, type Health, type HumanInputAction, type LlmProvider, MAX_FILE_BYTES, type MfaConfig, type MfaResult, Oya, OyaError, type OyaOptions, type PageFormat, type PersonaInfo, type PersonaPrefs, type PlayResult, type Playbook, type PlaybookSummary, type ProjectSettings, type Provider, type ProxyCreate, type ProxyInfo, Run, type RunData, type RunInfo, type RunResult, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };
1431
+ export { type Activity, type Analysis, type AnalyzeOptions, type AttentionRequest, type Block, Browser, type BrowserDetail, type BrowserInfo, type CaptchaResult, type CaptchaSolver, type Config, type ConfigUpdate, type ControlCredential, type ControlEvent, type ControlOverview, type ControlRole, type ControlSession, type Cookie, type CookieFormat, type Element, type FileValue, type Fingerprint, type Health, type HumanInputAction, type LlmProvider, MAX_FILE_BYTES, type MfaConfig, type MfaResult, Oya, OyaError, type OyaOptions, type PageFormat, type PersonaInfo, type PersonaPrefs, type PlayResult, type Playbook, type PlaybookSummary, type ProjectSettings, type Provider, type ProxyCreate, type ProxyInfo, type RecoverOptions, Run, type RunData, type RunInfo, type RunResult, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };
package/dist/index.d.ts CHANGED
@@ -255,6 +255,8 @@ interface BrowserInfo {
255
255
  }
256
256
  /** A browser plus what it has been doing, from `browser.status()`. */
257
257
  interface BrowserDetail extends BrowserInfo {
258
+ /** The actions it does, sorted, one spelling each: an action not listed answers action_unsupported or action_unknown. */
259
+ actions: string[];
258
260
  /** Its most recent commands, newest first. */
259
261
  activity: Activity[];
260
262
  }
@@ -342,10 +344,6 @@ interface Config extends Omit<ConfigUpdate, 'llm_provider' | 'browser_provider'
342
344
  }>;
343
345
  }
344
346
 
345
- /**
346
- * OyaError: the one error type the SDK throws for a failed call, carrying the
347
- * HTTP status and the server's answer so a caller can branch on either.
348
- */
349
347
  /** A failed API call or browser command. */
350
348
  declare class OyaError extends Error {
351
349
  /** The HTTP status, or the SDK's own status for errors it raises itself. */
@@ -689,6 +687,31 @@ interface SiteCredentials {
689
687
  /** The password; stored sealed and never returned. */
690
688
  password: string;
691
689
  }
690
+ /** A cookie in a persona's jar. */
691
+ interface Cookie {
692
+ /** The cookie's name. */
693
+ name: string;
694
+ /** Its value: a session, so treat it as a secret. */
695
+ value: string;
696
+ /** The domain it is sent to; a leading dot includes subdomains. */
697
+ domain: string;
698
+ /** The path it is sent to. `/` when omitted. */
699
+ path?: string;
700
+ /** Sent over HTTPS only. */
701
+ secure?: boolean;
702
+ /** Hidden from page scripts. */
703
+ httpOnly?: boolean;
704
+ /** `Strict`, `Lax` or `None` (Playwright), or `strict`, `lax`, `no_restriction` (Chrome extensions). */
705
+ sameSite?: string;
706
+ /** When it expires, in seconds since the epoch. A session cookie has none. */
707
+ expirationDate?: number;
708
+ /** The same, as Playwright and Puppeteer spell it; `-1` for a session cookie. */
709
+ expires?: number;
710
+ /** Whether it is sent to this exact host only. */
711
+ hostOnly?: boolean;
712
+ }
713
+ /** The formats a jar is exported in: as stored, or ready for Playwright's `context.addCookies()`. */
714
+ type CookieFormat = 'json' | 'playwright';
692
715
 
693
716
  /**
694
717
  * Types for the durable control plane: sessions and their lifecycle, human
@@ -696,6 +719,13 @@ interface SiteCredentials {
696
719
  */
697
720
  /** What a member or credential may do: read, operate browsers, or also administer the project. */
698
721
  type ControlRole = 'viewer' | 'operator' | 'administrator';
722
+ /** How to recover a session: in place (the default), or replaced by a fresh one. */
723
+ interface RecoverOptions {
724
+ /** Start a fresh session in its place. */
725
+ replace?: boolean;
726
+ /** cdp only: the Chrome the replacement runs on. */
727
+ wsUrl?: string;
728
+ }
699
729
  /** What a human holding the control lease may send. Mirrors the server's allowlist. */
700
730
  type HumanInputAction = 'click' | 'type' | 'press_key' | 'scroll' | 'click_coordinates' | 'double_click' | 'drag' | 'mouse_move' | 'scroll_at' | 'type_text' | 'keyboard_type' | 'navigate' | 'back' | 'forward' | 'reload' | 'screenshot' | 'analyze' | 'read_page';
701
731
  /** A browser session as the control plane records it, including ones no longer connected. */
@@ -809,14 +839,24 @@ interface OyaOptions {
809
839
  fetch?: typeof globalThis.fetch;
810
840
  }
811
841
 
842
+ /** Where the key and the address came from, so a message names the one to fix. */
843
+ interface Origin {
844
+ /** The key's source, as a message names it: "the apiKey option", "OYA_API_KEY" or "~/.oya/config.json". */
845
+ apiKeyFrom: string;
846
+ /** The address's source, named the same way, or "default" for the hosted one. */
847
+ baseUrlFrom: string;
848
+ /** Whether a key is also saved by `oya login`, which an environment key overrides. */
849
+ savedKey: boolean;
850
+ }
812
851
  /** The one HTTP path. Everything else in this package is a wrapper over it. */
813
852
  declare class Http {
814
853
  readonly baseUrl: string;
815
854
  readonly apiKey: string;
816
855
  private readonly timeoutMs;
817
856
  private readonly fetchImpl;
818
- /** Stores where to call, with which key, how long to wait and which fetch to use. */
819
- constructor(baseUrl: string, apiKey: string, timeoutMs: number, fetchImpl: typeof globalThis.fetch);
857
+ readonly origin: Origin;
858
+ /** Stores where to call, with which key, how long to wait, which fetch to use, and where the key and address came from. */
859
+ constructor(baseUrl: string, apiKey: string, timeoutMs: number, fetchImpl: typeof globalThis.fetch, origin?: Origin);
820
860
  /** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
821
861
  request<T>(method: string, path: string, body?: unknown, timeoutMs?: number, headers?: Record<string, string>): Promise<T>;
822
862
  /** The fetch options for one call, with this client's key on them. */
@@ -991,6 +1031,17 @@ interface SiteLogins {
991
1031
  /** Usernames only. */
992
1032
  credentials: SiteLogin[];
993
1033
  }
1034
+ /** `PUT /api/pool/cookies`: what an import did. */
1035
+ interface CookiesImported {
1036
+ /** The persona the cookies went to. */
1037
+ persona: string;
1038
+ /** Cookies merged into the jar. */
1039
+ imported: number;
1040
+ /** Cookies left out: no name, value or domain, or already expired. */
1041
+ skipped: number;
1042
+ /** Cookies in the jar afterwards. */
1043
+ total: number;
1044
+ }
994
1045
 
995
1046
  /**
996
1047
  * The shapes Browser's methods take and return that are not part of the
@@ -1286,7 +1337,7 @@ declare class Oya {
1286
1337
  removeMember: (userId: string) => Promise<Ack>;
1287
1338
  createCredential: (options: CredentialRequest) => Promise<NewCredential>;
1288
1339
  revokeCredential: (id: string) => Promise<Ack>;
1289
- recover: (id: string, replace?: boolean) => Promise<unknown>;
1340
+ recover: (id: string, options?: boolean | RecoverOptions) => Promise<unknown>;
1290
1341
  ticket: (id: string) => Promise<Ticket>;
1291
1342
  events: (after?: number) => Promise<EventPage>;
1292
1343
  cancel: (id: string) => Promise<ControlSession>;
@@ -1316,6 +1367,10 @@ declare class Oya {
1316
1367
  };
1317
1368
  /** Identities: fingerprint, cookie jar and proxy bound together, plus their stored factors and logins. */
1318
1369
  readonly personas: {
1370
+ copyCookies: (from: string, to: string) => Promise<CookiesImported>;
1371
+ clearCookies: (id: string) => Promise<void>;
1372
+ cookies: (id: string, format?: CookieFormat) => Promise<Cookie[]>;
1373
+ importCookies: (id: string, list: Cookie[]) => Promise<CookiesImported>;
1319
1374
  setCredentials: (id: string, config: SiteCredentials) => Promise<CredentialsSaved>;
1320
1375
  credentials: (id: string) => Promise<SiteLogins>;
1321
1376
  clearCredentials: (id: string, domain: string) => Promise<void>;
@@ -1348,6 +1403,10 @@ declare class Oya {
1348
1403
  };
1349
1404
  /** Saved profiles. `personas` is retained as an alias for existing clients. */
1350
1405
  readonly profiles: {
1406
+ copyCookies: (from: string, to: string) => Promise<CookiesImported>;
1407
+ clearCookies: (id: string) => Promise<void>;
1408
+ cookies: (id: string, format?: CookieFormat) => Promise<Cookie[]>;
1409
+ importCookies: (id: string, list: Cookie[]) => Promise<CookiesImported>;
1351
1410
  setCredentials: (id: string, config: SiteCredentials) => Promise<CredentialsSaved>;
1352
1411
  credentials: (id: string) => Promise<SiteLogins>;
1353
1412
  clearCredentials: (id: string, domain: string) => Promise<void>;
@@ -1369,4 +1428,4 @@ declare class Oya {
1369
1428
  private waitUntilConnected;
1370
1429
  }
1371
1430
 
1372
- export { type Activity, type Analysis, type AnalyzeOptions, type AttentionRequest, type Block, Browser, type BrowserDetail, type BrowserInfo, type CaptchaResult, type CaptchaSolver, type Config, type ConfigUpdate, type ControlCredential, type ControlEvent, type ControlOverview, type ControlRole, type ControlSession, type Element, type FileValue, type Fingerprint, type Health, type HumanInputAction, type LlmProvider, MAX_FILE_BYTES, type MfaConfig, type MfaResult, Oya, OyaError, type OyaOptions, type PageFormat, type PersonaInfo, type PersonaPrefs, type PlayResult, type Playbook, type PlaybookSummary, type ProjectSettings, type Provider, type ProxyCreate, type ProxyInfo, Run, type RunData, type RunInfo, type RunResult, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };
1431
+ export { type Activity, type Analysis, type AnalyzeOptions, type AttentionRequest, type Block, Browser, type BrowserDetail, type BrowserInfo, type CaptchaResult, type CaptchaSolver, type Config, type ConfigUpdate, type ControlCredential, type ControlEvent, type ControlOverview, type ControlRole, type ControlSession, type Cookie, type CookieFormat, type Element, type FileValue, type Fingerprint, type Health, type HumanInputAction, type LlmProvider, MAX_FILE_BYTES, type MfaConfig, type MfaResult, Oya, OyaError, type OyaOptions, type PageFormat, type PersonaInfo, type PersonaPrefs, type PlayResult, type Playbook, type PlaybookSummary, type ProjectSettings, type Provider, type ProxyCreate, type ProxyInfo, type RecoverOptions, Run, type RunData, type RunInfo, type RunResult, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };