@oya-ai/browser 1.0.110 → 1.0.113

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. */
@@ -721,6 +719,13 @@ type CookieFormat = 'json' | 'playwright';
721
719
  */
722
720
  /** What a member or credential may do: read, operate browsers, or also administer the project. */
723
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
+ }
724
729
  /** What a human holding the control lease may send. Mirrors the server's allowlist. */
725
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';
726
731
  /** A browser session as the control plane records it, including ones no longer connected. */
@@ -834,14 +839,24 @@ interface OyaOptions {
834
839
  fetch?: typeof globalThis.fetch;
835
840
  }
836
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
+ }
837
851
  /** The one HTTP path. Everything else in this package is a wrapper over it. */
838
852
  declare class Http {
839
853
  readonly baseUrl: string;
840
854
  readonly apiKey: string;
841
855
  private readonly timeoutMs;
842
856
  private readonly fetchImpl;
843
- /** Stores where to call, with which key, how long to wait and which fetch to use. */
844
- 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);
845
860
  /** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
846
861
  request<T>(method: string, path: string, body?: unknown, timeoutMs?: number, headers?: Record<string, string>): Promise<T>;
847
862
  /** The fetch options for one call, with this client's key on them. */
@@ -1214,6 +1229,11 @@ declare class Browser {
1214
1229
  * with filters like `{{name|first}}`, so a playbook saved from the run stores no values.
1215
1230
  */
1216
1231
  ask(prompt: string, { data, secrets }?: AskValues): Promise<string>;
1232
+ /**
1233
+ * `ask()` for data: the agent does the task and answers in the shape of `schema`
1234
+ * (a JSON schema), instead of in words. Throws when the agent reports it could not.
1235
+ */
1236
+ extract<T = unknown>(prompt: string, schema: Record<string, unknown>, values?: AskValues): Promise<T>;
1217
1237
  /**
1218
1238
  * Save the last `ask()` on this browser as a named playbook. Every value that was
1219
1239
  * typed, picked or clicked becomes a variable, with what the run used kept in
@@ -1322,7 +1342,7 @@ declare class Oya {
1322
1342
  removeMember: (userId: string) => Promise<Ack>;
1323
1343
  createCredential: (options: CredentialRequest) => Promise<NewCredential>;
1324
1344
  revokeCredential: (id: string) => Promise<Ack>;
1325
- recover: (id: string, replace?: boolean) => Promise<unknown>;
1345
+ recover: (id: string, options?: boolean | RecoverOptions) => Promise<unknown>;
1326
1346
  ticket: (id: string) => Promise<Ticket>;
1327
1347
  events: (after?: number) => Promise<EventPage>;
1328
1348
  cancel: (id: string) => Promise<ControlSession>;
@@ -1413,4 +1433,4 @@ declare class Oya {
1413
1433
  private waitUntilConnected;
1414
1434
  }
1415
1435
 
1416
- 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, Run, type RunData, type RunInfo, type RunResult, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };
1436
+ 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. */
@@ -721,6 +719,13 @@ type CookieFormat = 'json' | 'playwright';
721
719
  */
722
720
  /** What a member or credential may do: read, operate browsers, or also administer the project. */
723
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
+ }
724
729
  /** What a human holding the control lease may send. Mirrors the server's allowlist. */
725
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';
726
731
  /** A browser session as the control plane records it, including ones no longer connected. */
@@ -834,14 +839,24 @@ interface OyaOptions {
834
839
  fetch?: typeof globalThis.fetch;
835
840
  }
836
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
+ }
837
851
  /** The one HTTP path. Everything else in this package is a wrapper over it. */
838
852
  declare class Http {
839
853
  readonly baseUrl: string;
840
854
  readonly apiKey: string;
841
855
  private readonly timeoutMs;
842
856
  private readonly fetchImpl;
843
- /** Stores where to call, with which key, how long to wait and which fetch to use. */
844
- 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);
845
860
  /** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
846
861
  request<T>(method: string, path: string, body?: unknown, timeoutMs?: number, headers?: Record<string, string>): Promise<T>;
847
862
  /** The fetch options for one call, with this client's key on them. */
@@ -1214,6 +1229,11 @@ declare class Browser {
1214
1229
  * with filters like `{{name|first}}`, so a playbook saved from the run stores no values.
1215
1230
  */
1216
1231
  ask(prompt: string, { data, secrets }?: AskValues): Promise<string>;
1232
+ /**
1233
+ * `ask()` for data: the agent does the task and answers in the shape of `schema`
1234
+ * (a JSON schema), instead of in words. Throws when the agent reports it could not.
1235
+ */
1236
+ extract<T = unknown>(prompt: string, schema: Record<string, unknown>, values?: AskValues): Promise<T>;
1217
1237
  /**
1218
1238
  * Save the last `ask()` on this browser as a named playbook. Every value that was
1219
1239
  * typed, picked or clicked becomes a variable, with what the run used kept in
@@ -1322,7 +1342,7 @@ declare class Oya {
1322
1342
  removeMember: (userId: string) => Promise<Ack>;
1323
1343
  createCredential: (options: CredentialRequest) => Promise<NewCredential>;
1324
1344
  revokeCredential: (id: string) => Promise<Ack>;
1325
- recover: (id: string, replace?: boolean) => Promise<unknown>;
1345
+ recover: (id: string, options?: boolean | RecoverOptions) => Promise<unknown>;
1326
1346
  ticket: (id: string) => Promise<Ticket>;
1327
1347
  events: (after?: number) => Promise<EventPage>;
1328
1348
  cancel: (id: string) => Promise<ControlSession>;
@@ -1413,4 +1433,4 @@ declare class Oya {
1413
1433
  private waitUntilConnected;
1414
1434
  }
1415
1435
 
1416
- 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, Run, type RunData, type RunInfo, type RunResult, type SiteCredentials, type StartOptions, type StartResult, type StopResult, type SubmitOptions, Oya as default, file };
1436
+ 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 };