@oya-ai/browser 1.0.295 → 1.0.297
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.cjs +66 -19
- package/dist/index.d.cts +76 -1
- package/dist/index.d.ts +76 -1
- package/dist/index.js +66 -19
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -188,9 +188,9 @@ var Http = class _Http {
|
|
|
188
188
|
return new _Http(this.baseUrl, this.apiKey, this.timeoutMs, this.fetchImpl, this.origin, merged);
|
|
189
189
|
}
|
|
190
190
|
/** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
|
|
191
|
-
async request(method,
|
|
192
|
-
const res = await this.send(`${this.baseUrl}${
|
|
193
|
-
return readAnswer(res, `${method} ${
|
|
191
|
+
async request(method, path2, body, timeoutMs = this.timeoutMs, headers = {}) {
|
|
192
|
+
const res = await this.send(`${this.baseUrl}${path2}`, this.init(method, body, timeoutMs, headers), timeoutMs);
|
|
193
|
+
return readAnswer(res, `${method} ${path2}`, this);
|
|
194
194
|
}
|
|
195
195
|
/** The fetch options for one call, with this client's key on them. */
|
|
196
196
|
init(method, body, timeoutMs, headers) {
|
|
@@ -464,8 +464,8 @@ var Browser = class {
|
|
|
464
464
|
http;
|
|
465
465
|
/** Runs one browser command; a command that ran and failed throws. */
|
|
466
466
|
async command(action, params = {}, timeoutMs) {
|
|
467
|
-
const
|
|
468
|
-
const result = await this.http.request("POST",
|
|
467
|
+
const path2 = `/api/browsers/${segment(this.id)}/command`;
|
|
468
|
+
const result = await this.http.request("POST", path2, { action, params }, timeoutMs);
|
|
469
469
|
if (result.ok === false) throw new OyaError(result.error || `${action} failed`, Status.UNPROCESSABLE, result);
|
|
470
470
|
return result.data;
|
|
471
471
|
}
|
|
@@ -577,8 +577,8 @@ var Browser = class {
|
|
|
577
577
|
*/
|
|
578
578
|
async ask(prompt, { data, secrets } = {}) {
|
|
579
579
|
const body = { messages: [{ role: "user", content: prompt }], data, secrets };
|
|
580
|
-
const
|
|
581
|
-
return agentAnswer(await this.http.request("POST",
|
|
580
|
+
const path2 = `/api/browsers/${segment(this.id)}/chat`;
|
|
581
|
+
return agentAnswer(await this.http.request("POST", path2, body, AGENT_TIMEOUT_MS)).text;
|
|
582
582
|
}
|
|
583
583
|
/**
|
|
584
584
|
* `ask()` for data: the agent does the task and answers in the shape of `schema`
|
|
@@ -586,8 +586,8 @@ var Browser = class {
|
|
|
586
586
|
*/
|
|
587
587
|
async extract(prompt, schema, values = {}) {
|
|
588
588
|
const body = { messages: [{ role: "user", content: prompt }], ...values, schema };
|
|
589
|
-
const
|
|
590
|
-
const res = agentAnswer(await this.http.request("POST",
|
|
589
|
+
const path2 = `/api/browsers/${segment(this.id)}/chat`;
|
|
590
|
+
const res = agentAnswer(await this.http.request("POST", path2, body, AGENT_TIMEOUT_MS));
|
|
591
591
|
if (res.failed || res.data === void 0) throw new OyaError(res.text, Status.UNPROCESSABLE, res);
|
|
592
592
|
return res.data;
|
|
593
593
|
}
|
|
@@ -612,9 +612,9 @@ var Browser = class {
|
|
|
612
612
|
* replaces the broken steps in the playbook (`healed`); off, the step's error is thrown.
|
|
613
613
|
*/
|
|
614
614
|
async play(name, data = {}, { autoHeal = true } = {}) {
|
|
615
|
-
const
|
|
615
|
+
const path2 = `/api/browsers/${segment(this.id)}/playbooks/${segment(name, "name")}/play`;
|
|
616
616
|
return agentAnswer(
|
|
617
|
-
await this.http.request("POST",
|
|
617
|
+
await this.http.request("POST", path2, { variables: data, autoHeal }, AGENT_TIMEOUT_MS)
|
|
618
618
|
);
|
|
619
619
|
}
|
|
620
620
|
/**
|
|
@@ -644,8 +644,8 @@ var Browser = class {
|
|
|
644
644
|
* 60 seconds. Mint one per viewer, the first connection spends it.
|
|
645
645
|
*/
|
|
646
646
|
async liveStreamUrl() {
|
|
647
|
-
const
|
|
648
|
-
const { ticket } = await this.http.request("POST",
|
|
647
|
+
const path2 = `/api/control/sessions/${segment(this.id)}/ticket`;
|
|
648
|
+
const { ticket } = await this.http.request("POST", path2, {});
|
|
649
649
|
return `${this.http.baseUrl}/api/live/${segment(this.id)}?ticket=${encodeURIComponent(ticket)}`;
|
|
650
650
|
}
|
|
651
651
|
/**
|
|
@@ -660,8 +660,8 @@ var Browser = class {
|
|
|
660
660
|
* expires or you revoke it, so treat it like a password.
|
|
661
661
|
*/
|
|
662
662
|
async shareUrl({ control = false, expiresInSeconds = 3600 } = {}) {
|
|
663
|
-
const
|
|
664
|
-
const c = await this.http.request("POST",
|
|
663
|
+
const path2 = `/api/control/sessions/${segment(this.id)}/share`;
|
|
664
|
+
const c = await this.http.request("POST", path2, { control, expiresIn: expiresInSeconds });
|
|
665
665
|
return { url: shareLink(this.http.baseUrl, this.id, c.token), id: c.id, expiresAt: c.expiresAt };
|
|
666
666
|
}
|
|
667
667
|
/** Revoke a link from `shareUrl()` before it expires, by the id it returned. */
|
|
@@ -735,8 +735,8 @@ function startBody(options) {
|
|
|
735
735
|
var idempotencyKeyOf = ({ idempotencyKey }) => idempotencyKey ? headerSafe(idempotencyKey, "idempotencyKey", 'Use letters, digits, "-" and "_".') : globalThis.crypto.randomUUID();
|
|
736
736
|
async function start(http, wait, options) {
|
|
737
737
|
const headers = { "Idempotency-Key": idempotencyKeyOf(options) };
|
|
738
|
-
const
|
|
739
|
-
const started = await http().request("POST",
|
|
738
|
+
const path2 = "/api/browsers/start";
|
|
739
|
+
const started = await http().request("POST", path2, startBody(options), START_TIMEOUT_MS, headers);
|
|
740
740
|
if (started.status === "starting") {
|
|
741
741
|
await wait(started.id, options.readyTimeoutMs ?? READY_TIMEOUT_MS + (options.queueMs || 0));
|
|
742
742
|
started.cdpUrl = (await fetchBrowser(http, started.id)).cdpUrl;
|
|
@@ -978,6 +978,51 @@ var personaGroupApi = (http) => ({
|
|
|
978
978
|
}
|
|
979
979
|
});
|
|
980
980
|
|
|
981
|
+
// src/api/assistants.ts
|
|
982
|
+
var path = (id) => "/api/assistants/" + segment(id, "assistant ID");
|
|
983
|
+
var gateways = (http) => ({
|
|
984
|
+
/** Request device pairing. */
|
|
985
|
+
connectWhatsApp: (id) => http().request("POST", path(id) + "/whatsapp"),
|
|
986
|
+
/** Read the currently active pairing code or connection status. */
|
|
987
|
+
whatsAppStatus: (id) => http().request("GET", path(id) + "/whatsapp"),
|
|
988
|
+
/** Stop handling incoming messages and erase local WhatsApp credentials. */
|
|
989
|
+
disconnectWhatsApp: (id) => http().request("DELETE", path(id) + "/whatsapp"),
|
|
990
|
+
/** Rotate the key accepted by the assistant webhook. */
|
|
991
|
+
rotateInboundKey: (id) => http().request("POST", path(id) + "/inbound-key")
|
|
992
|
+
});
|
|
993
|
+
var skills = (http) => ({
|
|
994
|
+
/** List available reusable instructions. */
|
|
995
|
+
listSkills: async () => (await http().request("GET", "/api/assistants")).skills,
|
|
996
|
+
/** Save instructions once for several assistants. */
|
|
997
|
+
createSkill: (body) => http().request("POST", "/api/assistants/skills", body)
|
|
998
|
+
});
|
|
999
|
+
var definitions = (http) => ({
|
|
1000
|
+
/** Discover definitions in this project. */
|
|
1001
|
+
list: async () => (await http().request("GET", "/api/assistants")).assistants,
|
|
1002
|
+
/** Save a new assistant. */
|
|
1003
|
+
create: (body) => http().request("POST", "/api/assistants", body),
|
|
1004
|
+
/** Change the instructions for future turns. */
|
|
1005
|
+
update: (id, body) => http().request("PUT", path(id), body),
|
|
1006
|
+
/** Change one assistant's model without interrupting its device or contact memory. */
|
|
1007
|
+
setModel: (id, model) => http().request("PATCH", path(id) + "/model", { model }),
|
|
1008
|
+
/** Remove this assistant and its messages. */
|
|
1009
|
+
remove: (id) => http().request("DELETE", path(id))
|
|
1010
|
+
});
|
|
1011
|
+
var conversations = (http) => ({
|
|
1012
|
+
/** Submit a contact message for asynchronous processing. */
|
|
1013
|
+
send: (id, body) => http().request("POST", path(id) + "/messages", body),
|
|
1014
|
+
/** Read the original receipt and latest response. */
|
|
1015
|
+
message: (id, messageId) => http().request("GET", path(id) + "/messages/" + segment(messageId, "message ID")),
|
|
1016
|
+
/** Erase a contact's conversation. */
|
|
1017
|
+
forget: (id, contact) => http().request("DELETE", path(id) + "/contacts/" + segment(contact, "contact"))
|
|
1018
|
+
});
|
|
1019
|
+
var assistantApi = (http) => ({
|
|
1020
|
+
...definitions(http),
|
|
1021
|
+
...skills(http),
|
|
1022
|
+
...conversations(http),
|
|
1023
|
+
...gateways(http)
|
|
1024
|
+
});
|
|
1025
|
+
|
|
981
1026
|
// src/api/config.ts
|
|
982
1027
|
var configApi = (http) => ({
|
|
983
1028
|
/** This key's settings. Secrets read back masked. */
|
|
@@ -1136,13 +1181,13 @@ var base64 = (bytes) => {
|
|
|
1136
1181
|
}
|
|
1137
1182
|
return btoa(binary);
|
|
1138
1183
|
};
|
|
1139
|
-
async function readPath(
|
|
1184
|
+
async function readPath(path2) {
|
|
1140
1185
|
const fs = await import(
|
|
1141
1186
|
/* webpackIgnore: true */
|
|
1142
1187
|
/* @vite-ignore */
|
|
1143
1188
|
NODE_FS
|
|
1144
1189
|
);
|
|
1145
|
-
return { bytes: new Uint8Array(await fs.readFile(
|
|
1190
|
+
return { bytes: new Uint8Array(await fs.readFile(path2)), name: path2.split(/[\\/]/).pop() || "file" };
|
|
1146
1191
|
}
|
|
1147
1192
|
async function readSource(source) {
|
|
1148
1193
|
if (typeof source === "string") return readPath(source);
|
|
@@ -1227,6 +1272,8 @@ var Oya = class {
|
|
|
1227
1272
|
personaGroups = personaGroupApi(() => this.http);
|
|
1228
1273
|
/** The same as `personaGroups`, matching the `profiles` alias. */
|
|
1229
1274
|
profileGroups = this.personaGroups;
|
|
1275
|
+
/** Build and message project-owned hosted assistants. */
|
|
1276
|
+
assistants = assistantApi(() => this.http);
|
|
1230
1277
|
/** What this key has spent. */
|
|
1231
1278
|
usage() {
|
|
1232
1279
|
return this.http.request("GET", "/api/usage");
|
package/dist/index.d.cts
CHANGED
|
@@ -1264,6 +1264,62 @@ interface CookiesImported {
|
|
|
1264
1264
|
total: number;
|
|
1265
1265
|
}
|
|
1266
1266
|
|
|
1267
|
+
/** Instructions and display name chosen by the builder. */
|
|
1268
|
+
interface AssistantDefinition {
|
|
1269
|
+
/** Project-owned skills to apply when replying. */ skillIds?: string[];
|
|
1270
|
+
/** Enabled first-party plugins. */ plugins?: 'public-web'[];
|
|
1271
|
+
/** Apps contacts may connect to their own account. */ connections?: 'googlecalendar'[];
|
|
1272
|
+
/** Pin a supported project model or inherit the default. */
|
|
1273
|
+
model?: {
|
|
1274
|
+
provider: string; /** Model identifier. */
|
|
1275
|
+
model: string;
|
|
1276
|
+
} | null;
|
|
1277
|
+
/** Public name for this assistant. */
|
|
1278
|
+
name: string;
|
|
1279
|
+
/** Builder's behavior and tone instructions. */
|
|
1280
|
+
instructions: string;
|
|
1281
|
+
}
|
|
1282
|
+
/** Saved project-scoped assistant. */
|
|
1283
|
+
interface Assistant extends AssistantDefinition {
|
|
1284
|
+
/** Stable assistant identifier. */
|
|
1285
|
+
id: string;
|
|
1286
|
+
}
|
|
1287
|
+
/** A durable receipt, including the saved reply after completion. */
|
|
1288
|
+
interface AssistantMessage {
|
|
1289
|
+
/** Server-generated ID for polling. */
|
|
1290
|
+
id: string;
|
|
1291
|
+
/** Current status of the turn. */
|
|
1292
|
+
state: 'queued' | 'running' | 'completed' | 'failed';
|
|
1293
|
+
/** Original message. */
|
|
1294
|
+
text: string;
|
|
1295
|
+
/** Saved response after completion. */
|
|
1296
|
+
reply?: string | null;
|
|
1297
|
+
/** WhatsApp transport status after a reply is saved. */
|
|
1298
|
+
delivery?: 'queued' | 'unknown' | 'submitted';
|
|
1299
|
+
}
|
|
1300
|
+
/** Stable retry key and contact identity are supplied by the builder's backend. */
|
|
1301
|
+
interface AssistantInput {
|
|
1302
|
+
/** Unique per contact, reused on transport retry. */
|
|
1303
|
+
messageId: string;
|
|
1304
|
+
/** Contact identifier local to this assistant. */
|
|
1305
|
+
contact: string;
|
|
1306
|
+
/** Incoming text. */
|
|
1307
|
+
text: string;
|
|
1308
|
+
}
|
|
1309
|
+
/** A linked-device enrollment, including the current QR material when requested by an administrator. */
|
|
1310
|
+
interface WhatsAppDevice {
|
|
1311
|
+
/** Pairing or connection status. */
|
|
1312
|
+
state: string;
|
|
1313
|
+
/** Short-lived pairing material. */
|
|
1314
|
+
qr: string | null;
|
|
1315
|
+
}
|
|
1316
|
+
/** Reusable instructions owned by a project. */
|
|
1317
|
+
interface AssistantSkill {
|
|
1318
|
+
/** Assignment identity. */ id: string;
|
|
1319
|
+
/** Builder-selected name. */ name: string;
|
|
1320
|
+
/** Private instructions. */ instructions: string;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1267
1323
|
/**
|
|
1268
1324
|
* The shapes Browser's methods take and return that are not part of the
|
|
1269
1325
|
* exported types: tab listings, dialog answers, share links and the like.
|
|
@@ -1689,6 +1745,25 @@ declare class Oya {
|
|
|
1689
1745
|
update: (name: string, personaIds: string[]) => Promise<PersonaGroup>;
|
|
1690
1746
|
remove: (name: string) => Promise<void>;
|
|
1691
1747
|
};
|
|
1748
|
+
/** Build and message project-owned hosted assistants. */
|
|
1749
|
+
readonly assistants: {
|
|
1750
|
+
connectWhatsApp: (id: string) => Promise<WhatsAppDevice>;
|
|
1751
|
+
whatsAppStatus: (id: string) => Promise<WhatsAppDevice>;
|
|
1752
|
+
disconnectWhatsApp: (id: string) => Promise<void>;
|
|
1753
|
+
rotateInboundKey: (id: string) => Promise<{
|
|
1754
|
+
secret: string;
|
|
1755
|
+
}>;
|
|
1756
|
+
send: (id: string, body: AssistantInput) => Promise<AssistantMessage>;
|
|
1757
|
+
message: (id: string, messageId: string) => Promise<AssistantMessage>;
|
|
1758
|
+
forget: (id: string, contact: string) => Promise<void>;
|
|
1759
|
+
listSkills: () => Promise<AssistantSkill[]>;
|
|
1760
|
+
createSkill: (body: Omit<AssistantSkill, "id">) => Promise<AssistantSkill>;
|
|
1761
|
+
list: () => Promise<Assistant[]>;
|
|
1762
|
+
create: (body: AssistantDefinition) => Promise<Assistant>;
|
|
1763
|
+
update: (id: string, body: AssistantDefinition) => Promise<Assistant>;
|
|
1764
|
+
setModel: (id: string, model: NonNullable<AssistantDefinition["model"]> | null) => Promise<Assistant>;
|
|
1765
|
+
remove: (id: string) => Promise<void>;
|
|
1766
|
+
};
|
|
1692
1767
|
/** What this key has spent. */
|
|
1693
1768
|
usage(): Promise<unknown>;
|
|
1694
1769
|
/** Waits for a starting browser to dial in, through this client's own list and session calls. */
|
|
@@ -1696,4 +1771,4 @@ declare class Oya {
|
|
|
1696
1771
|
}
|
|
1697
1772
|
|
|
1698
1773
|
export { Browser, MAX_FILE_BYTES, Oya, OyaError, Run, Oya as default, file };
|
|
1699
|
-
export type { Activity, Analysis, AnalyzeOptions, AttentionRequest, Block, BrowserDetail, BrowserInfo, CaptchaResult, CaptchaSolver, Config, ConfigUpdate, ControlCredential, ControlEvent, ControlOverview, ControlRole, ControlSession, Cookie, CookieFormat, DesktopOptions, EcsAuth, EcsConfig, Element, FileValue, Fingerprint, Health, HumanInputAction, ImportOptions, LlmCatalogEntry, LlmProvider, MfaConfig, MfaResult, ModelOptions, OyaOptions, PageFormat, PersonaGroup, PersonaInfo, PersonaPrefs, PlayResult, Playbook, PlaybookAnswer, PlaybookExport, PlaybookSummary, ProjectSettings, Provider, ProxyCreate, ProxyInfo, RecoverOptions, RunData, RunInfo, RunResult, SandboxRuntime, Signup, SignupOptions, SiteCredentials, StartOptions, StartResult, StopResult, SubmitOptions };
|
|
1774
|
+
export type { Activity, Analysis, AnalyzeOptions, Assistant, AssistantDefinition, AssistantInput, AssistantMessage, AssistantSkill, AttentionRequest, Block, BrowserDetail, BrowserInfo, CaptchaResult, CaptchaSolver, Config, ConfigUpdate, ControlCredential, ControlEvent, ControlOverview, ControlRole, ControlSession, Cookie, CookieFormat, DesktopOptions, EcsAuth, EcsConfig, Element, FileValue, Fingerprint, Health, HumanInputAction, ImportOptions, LlmCatalogEntry, LlmProvider, MfaConfig, MfaResult, ModelOptions, OyaOptions, PageFormat, PersonaGroup, PersonaInfo, PersonaPrefs, PlayResult, Playbook, PlaybookAnswer, PlaybookExport, PlaybookSummary, ProjectSettings, Provider, ProxyCreate, ProxyInfo, RecoverOptions, RunData, RunInfo, RunResult, SandboxRuntime, Signup, SignupOptions, SiteCredentials, StartOptions, StartResult, StopResult, SubmitOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1264,6 +1264,62 @@ interface CookiesImported {
|
|
|
1264
1264
|
total: number;
|
|
1265
1265
|
}
|
|
1266
1266
|
|
|
1267
|
+
/** Instructions and display name chosen by the builder. */
|
|
1268
|
+
interface AssistantDefinition {
|
|
1269
|
+
/** Project-owned skills to apply when replying. */ skillIds?: string[];
|
|
1270
|
+
/** Enabled first-party plugins. */ plugins?: 'public-web'[];
|
|
1271
|
+
/** Apps contacts may connect to their own account. */ connections?: 'googlecalendar'[];
|
|
1272
|
+
/** Pin a supported project model or inherit the default. */
|
|
1273
|
+
model?: {
|
|
1274
|
+
provider: string; /** Model identifier. */
|
|
1275
|
+
model: string;
|
|
1276
|
+
} | null;
|
|
1277
|
+
/** Public name for this assistant. */
|
|
1278
|
+
name: string;
|
|
1279
|
+
/** Builder's behavior and tone instructions. */
|
|
1280
|
+
instructions: string;
|
|
1281
|
+
}
|
|
1282
|
+
/** Saved project-scoped assistant. */
|
|
1283
|
+
interface Assistant extends AssistantDefinition {
|
|
1284
|
+
/** Stable assistant identifier. */
|
|
1285
|
+
id: string;
|
|
1286
|
+
}
|
|
1287
|
+
/** A durable receipt, including the saved reply after completion. */
|
|
1288
|
+
interface AssistantMessage {
|
|
1289
|
+
/** Server-generated ID for polling. */
|
|
1290
|
+
id: string;
|
|
1291
|
+
/** Current status of the turn. */
|
|
1292
|
+
state: 'queued' | 'running' | 'completed' | 'failed';
|
|
1293
|
+
/** Original message. */
|
|
1294
|
+
text: string;
|
|
1295
|
+
/** Saved response after completion. */
|
|
1296
|
+
reply?: string | null;
|
|
1297
|
+
/** WhatsApp transport status after a reply is saved. */
|
|
1298
|
+
delivery?: 'queued' | 'unknown' | 'submitted';
|
|
1299
|
+
}
|
|
1300
|
+
/** Stable retry key and contact identity are supplied by the builder's backend. */
|
|
1301
|
+
interface AssistantInput {
|
|
1302
|
+
/** Unique per contact, reused on transport retry. */
|
|
1303
|
+
messageId: string;
|
|
1304
|
+
/** Contact identifier local to this assistant. */
|
|
1305
|
+
contact: string;
|
|
1306
|
+
/** Incoming text. */
|
|
1307
|
+
text: string;
|
|
1308
|
+
}
|
|
1309
|
+
/** A linked-device enrollment, including the current QR material when requested by an administrator. */
|
|
1310
|
+
interface WhatsAppDevice {
|
|
1311
|
+
/** Pairing or connection status. */
|
|
1312
|
+
state: string;
|
|
1313
|
+
/** Short-lived pairing material. */
|
|
1314
|
+
qr: string | null;
|
|
1315
|
+
}
|
|
1316
|
+
/** Reusable instructions owned by a project. */
|
|
1317
|
+
interface AssistantSkill {
|
|
1318
|
+
/** Assignment identity. */ id: string;
|
|
1319
|
+
/** Builder-selected name. */ name: string;
|
|
1320
|
+
/** Private instructions. */ instructions: string;
|
|
1321
|
+
}
|
|
1322
|
+
|
|
1267
1323
|
/**
|
|
1268
1324
|
* The shapes Browser's methods take and return that are not part of the
|
|
1269
1325
|
* exported types: tab listings, dialog answers, share links and the like.
|
|
@@ -1689,6 +1745,25 @@ declare class Oya {
|
|
|
1689
1745
|
update: (name: string, personaIds: string[]) => Promise<PersonaGroup>;
|
|
1690
1746
|
remove: (name: string) => Promise<void>;
|
|
1691
1747
|
};
|
|
1748
|
+
/** Build and message project-owned hosted assistants. */
|
|
1749
|
+
readonly assistants: {
|
|
1750
|
+
connectWhatsApp: (id: string) => Promise<WhatsAppDevice>;
|
|
1751
|
+
whatsAppStatus: (id: string) => Promise<WhatsAppDevice>;
|
|
1752
|
+
disconnectWhatsApp: (id: string) => Promise<void>;
|
|
1753
|
+
rotateInboundKey: (id: string) => Promise<{
|
|
1754
|
+
secret: string;
|
|
1755
|
+
}>;
|
|
1756
|
+
send: (id: string, body: AssistantInput) => Promise<AssistantMessage>;
|
|
1757
|
+
message: (id: string, messageId: string) => Promise<AssistantMessage>;
|
|
1758
|
+
forget: (id: string, contact: string) => Promise<void>;
|
|
1759
|
+
listSkills: () => Promise<AssistantSkill[]>;
|
|
1760
|
+
createSkill: (body: Omit<AssistantSkill, "id">) => Promise<AssistantSkill>;
|
|
1761
|
+
list: () => Promise<Assistant[]>;
|
|
1762
|
+
create: (body: AssistantDefinition) => Promise<Assistant>;
|
|
1763
|
+
update: (id: string, body: AssistantDefinition) => Promise<Assistant>;
|
|
1764
|
+
setModel: (id: string, model: NonNullable<AssistantDefinition["model"]> | null) => Promise<Assistant>;
|
|
1765
|
+
remove: (id: string) => Promise<void>;
|
|
1766
|
+
};
|
|
1692
1767
|
/** What this key has spent. */
|
|
1693
1768
|
usage(): Promise<unknown>;
|
|
1694
1769
|
/** Waits for a starting browser to dial in, through this client's own list and session calls. */
|
|
@@ -1696,4 +1771,4 @@ declare class Oya {
|
|
|
1696
1771
|
}
|
|
1697
1772
|
|
|
1698
1773
|
export { Browser, MAX_FILE_BYTES, Oya, OyaError, Run, Oya as default, file };
|
|
1699
|
-
export type { Activity, Analysis, AnalyzeOptions, AttentionRequest, Block, BrowserDetail, BrowserInfo, CaptchaResult, CaptchaSolver, Config, ConfigUpdate, ControlCredential, ControlEvent, ControlOverview, ControlRole, ControlSession, Cookie, CookieFormat, DesktopOptions, EcsAuth, EcsConfig, Element, FileValue, Fingerprint, Health, HumanInputAction, ImportOptions, LlmCatalogEntry, LlmProvider, MfaConfig, MfaResult, ModelOptions, OyaOptions, PageFormat, PersonaGroup, PersonaInfo, PersonaPrefs, PlayResult, Playbook, PlaybookAnswer, PlaybookExport, PlaybookSummary, ProjectSettings, Provider, ProxyCreate, ProxyInfo, RecoverOptions, RunData, RunInfo, RunResult, SandboxRuntime, Signup, SignupOptions, SiteCredentials, StartOptions, StartResult, StopResult, SubmitOptions };
|
|
1774
|
+
export type { Activity, Analysis, AnalyzeOptions, Assistant, AssistantDefinition, AssistantInput, AssistantMessage, AssistantSkill, AttentionRequest, Block, BrowserDetail, BrowserInfo, CaptchaResult, CaptchaSolver, Config, ConfigUpdate, ControlCredential, ControlEvent, ControlOverview, ControlRole, ControlSession, Cookie, CookieFormat, DesktopOptions, EcsAuth, EcsConfig, Element, FileValue, Fingerprint, Health, HumanInputAction, ImportOptions, LlmCatalogEntry, LlmProvider, MfaConfig, MfaResult, ModelOptions, OyaOptions, PageFormat, PersonaGroup, PersonaInfo, PersonaPrefs, PlayResult, Playbook, PlaybookAnswer, PlaybookExport, PlaybookSummary, ProjectSettings, Provider, ProxyCreate, ProxyInfo, RecoverOptions, RunData, RunInfo, RunResult, SandboxRuntime, Signup, SignupOptions, SiteCredentials, StartOptions, StartResult, StopResult, SubmitOptions };
|
package/dist/index.js
CHANGED
|
@@ -156,9 +156,9 @@ var Http = class _Http {
|
|
|
156
156
|
return new _Http(this.baseUrl, this.apiKey, this.timeoutMs, this.fetchImpl, this.origin, merged);
|
|
157
157
|
}
|
|
158
158
|
/** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
|
|
159
|
-
async request(method,
|
|
160
|
-
const res = await this.send(`${this.baseUrl}${
|
|
161
|
-
return readAnswer(res, `${method} ${
|
|
159
|
+
async request(method, path2, body, timeoutMs = this.timeoutMs, headers = {}) {
|
|
160
|
+
const res = await this.send(`${this.baseUrl}${path2}`, this.init(method, body, timeoutMs, headers), timeoutMs);
|
|
161
|
+
return readAnswer(res, `${method} ${path2}`, this);
|
|
162
162
|
}
|
|
163
163
|
/** The fetch options for one call, with this client's key on them. */
|
|
164
164
|
init(method, body, timeoutMs, headers) {
|
|
@@ -432,8 +432,8 @@ var Browser = class {
|
|
|
432
432
|
http;
|
|
433
433
|
/** Runs one browser command; a command that ran and failed throws. */
|
|
434
434
|
async command(action, params = {}, timeoutMs) {
|
|
435
|
-
const
|
|
436
|
-
const result = await this.http.request("POST",
|
|
435
|
+
const path2 = `/api/browsers/${segment(this.id)}/command`;
|
|
436
|
+
const result = await this.http.request("POST", path2, { action, params }, timeoutMs);
|
|
437
437
|
if (result.ok === false) throw new OyaError(result.error || `${action} failed`, Status.UNPROCESSABLE, result);
|
|
438
438
|
return result.data;
|
|
439
439
|
}
|
|
@@ -545,8 +545,8 @@ var Browser = class {
|
|
|
545
545
|
*/
|
|
546
546
|
async ask(prompt, { data, secrets } = {}) {
|
|
547
547
|
const body = { messages: [{ role: "user", content: prompt }], data, secrets };
|
|
548
|
-
const
|
|
549
|
-
return agentAnswer(await this.http.request("POST",
|
|
548
|
+
const path2 = `/api/browsers/${segment(this.id)}/chat`;
|
|
549
|
+
return agentAnswer(await this.http.request("POST", path2, body, AGENT_TIMEOUT_MS)).text;
|
|
550
550
|
}
|
|
551
551
|
/**
|
|
552
552
|
* `ask()` for data: the agent does the task and answers in the shape of `schema`
|
|
@@ -554,8 +554,8 @@ var Browser = class {
|
|
|
554
554
|
*/
|
|
555
555
|
async extract(prompt, schema, values = {}) {
|
|
556
556
|
const body = { messages: [{ role: "user", content: prompt }], ...values, schema };
|
|
557
|
-
const
|
|
558
|
-
const res = agentAnswer(await this.http.request("POST",
|
|
557
|
+
const path2 = `/api/browsers/${segment(this.id)}/chat`;
|
|
558
|
+
const res = agentAnswer(await this.http.request("POST", path2, body, AGENT_TIMEOUT_MS));
|
|
559
559
|
if (res.failed || res.data === void 0) throw new OyaError(res.text, Status.UNPROCESSABLE, res);
|
|
560
560
|
return res.data;
|
|
561
561
|
}
|
|
@@ -580,9 +580,9 @@ var Browser = class {
|
|
|
580
580
|
* replaces the broken steps in the playbook (`healed`); off, the step's error is thrown.
|
|
581
581
|
*/
|
|
582
582
|
async play(name, data = {}, { autoHeal = true } = {}) {
|
|
583
|
-
const
|
|
583
|
+
const path2 = `/api/browsers/${segment(this.id)}/playbooks/${segment(name, "name")}/play`;
|
|
584
584
|
return agentAnswer(
|
|
585
|
-
await this.http.request("POST",
|
|
585
|
+
await this.http.request("POST", path2, { variables: data, autoHeal }, AGENT_TIMEOUT_MS)
|
|
586
586
|
);
|
|
587
587
|
}
|
|
588
588
|
/**
|
|
@@ -612,8 +612,8 @@ var Browser = class {
|
|
|
612
612
|
* 60 seconds. Mint one per viewer, the first connection spends it.
|
|
613
613
|
*/
|
|
614
614
|
async liveStreamUrl() {
|
|
615
|
-
const
|
|
616
|
-
const { ticket } = await this.http.request("POST",
|
|
615
|
+
const path2 = `/api/control/sessions/${segment(this.id)}/ticket`;
|
|
616
|
+
const { ticket } = await this.http.request("POST", path2, {});
|
|
617
617
|
return `${this.http.baseUrl}/api/live/${segment(this.id)}?ticket=${encodeURIComponent(ticket)}`;
|
|
618
618
|
}
|
|
619
619
|
/**
|
|
@@ -628,8 +628,8 @@ var Browser = class {
|
|
|
628
628
|
* expires or you revoke it, so treat it like a password.
|
|
629
629
|
*/
|
|
630
630
|
async shareUrl({ control = false, expiresInSeconds = 3600 } = {}) {
|
|
631
|
-
const
|
|
632
|
-
const c = await this.http.request("POST",
|
|
631
|
+
const path2 = `/api/control/sessions/${segment(this.id)}/share`;
|
|
632
|
+
const c = await this.http.request("POST", path2, { control, expiresIn: expiresInSeconds });
|
|
633
633
|
return { url: shareLink(this.http.baseUrl, this.id, c.token), id: c.id, expiresAt: c.expiresAt };
|
|
634
634
|
}
|
|
635
635
|
/** Revoke a link from `shareUrl()` before it expires, by the id it returned. */
|
|
@@ -703,8 +703,8 @@ function startBody(options) {
|
|
|
703
703
|
var idempotencyKeyOf = ({ idempotencyKey }) => idempotencyKey ? headerSafe(idempotencyKey, "idempotencyKey", 'Use letters, digits, "-" and "_".') : globalThis.crypto.randomUUID();
|
|
704
704
|
async function start(http, wait, options) {
|
|
705
705
|
const headers = { "Idempotency-Key": idempotencyKeyOf(options) };
|
|
706
|
-
const
|
|
707
|
-
const started = await http().request("POST",
|
|
706
|
+
const path2 = "/api/browsers/start";
|
|
707
|
+
const started = await http().request("POST", path2, startBody(options), START_TIMEOUT_MS, headers);
|
|
708
708
|
if (started.status === "starting") {
|
|
709
709
|
await wait(started.id, options.readyTimeoutMs ?? READY_TIMEOUT_MS + (options.queueMs || 0));
|
|
710
710
|
started.cdpUrl = (await fetchBrowser(http, started.id)).cdpUrl;
|
|
@@ -946,6 +946,51 @@ var personaGroupApi = (http) => ({
|
|
|
946
946
|
}
|
|
947
947
|
});
|
|
948
948
|
|
|
949
|
+
// src/api/assistants.ts
|
|
950
|
+
var path = (id) => "/api/assistants/" + segment(id, "assistant ID");
|
|
951
|
+
var gateways = (http) => ({
|
|
952
|
+
/** Request device pairing. */
|
|
953
|
+
connectWhatsApp: (id) => http().request("POST", path(id) + "/whatsapp"),
|
|
954
|
+
/** Read the currently active pairing code or connection status. */
|
|
955
|
+
whatsAppStatus: (id) => http().request("GET", path(id) + "/whatsapp"),
|
|
956
|
+
/** Stop handling incoming messages and erase local WhatsApp credentials. */
|
|
957
|
+
disconnectWhatsApp: (id) => http().request("DELETE", path(id) + "/whatsapp"),
|
|
958
|
+
/** Rotate the key accepted by the assistant webhook. */
|
|
959
|
+
rotateInboundKey: (id) => http().request("POST", path(id) + "/inbound-key")
|
|
960
|
+
});
|
|
961
|
+
var skills = (http) => ({
|
|
962
|
+
/** List available reusable instructions. */
|
|
963
|
+
listSkills: async () => (await http().request("GET", "/api/assistants")).skills,
|
|
964
|
+
/** Save instructions once for several assistants. */
|
|
965
|
+
createSkill: (body) => http().request("POST", "/api/assistants/skills", body)
|
|
966
|
+
});
|
|
967
|
+
var definitions = (http) => ({
|
|
968
|
+
/** Discover definitions in this project. */
|
|
969
|
+
list: async () => (await http().request("GET", "/api/assistants")).assistants,
|
|
970
|
+
/** Save a new assistant. */
|
|
971
|
+
create: (body) => http().request("POST", "/api/assistants", body),
|
|
972
|
+
/** Change the instructions for future turns. */
|
|
973
|
+
update: (id, body) => http().request("PUT", path(id), body),
|
|
974
|
+
/** Change one assistant's model without interrupting its device or contact memory. */
|
|
975
|
+
setModel: (id, model) => http().request("PATCH", path(id) + "/model", { model }),
|
|
976
|
+
/** Remove this assistant and its messages. */
|
|
977
|
+
remove: (id) => http().request("DELETE", path(id))
|
|
978
|
+
});
|
|
979
|
+
var conversations = (http) => ({
|
|
980
|
+
/** Submit a contact message for asynchronous processing. */
|
|
981
|
+
send: (id, body) => http().request("POST", path(id) + "/messages", body),
|
|
982
|
+
/** Read the original receipt and latest response. */
|
|
983
|
+
message: (id, messageId) => http().request("GET", path(id) + "/messages/" + segment(messageId, "message ID")),
|
|
984
|
+
/** Erase a contact's conversation. */
|
|
985
|
+
forget: (id, contact) => http().request("DELETE", path(id) + "/contacts/" + segment(contact, "contact"))
|
|
986
|
+
});
|
|
987
|
+
var assistantApi = (http) => ({
|
|
988
|
+
...definitions(http),
|
|
989
|
+
...skills(http),
|
|
990
|
+
...conversations(http),
|
|
991
|
+
...gateways(http)
|
|
992
|
+
});
|
|
993
|
+
|
|
949
994
|
// src/api/config.ts
|
|
950
995
|
var configApi = (http) => ({
|
|
951
996
|
/** This key's settings. Secrets read back masked. */
|
|
@@ -1104,13 +1149,13 @@ var base64 = (bytes) => {
|
|
|
1104
1149
|
}
|
|
1105
1150
|
return btoa(binary);
|
|
1106
1151
|
};
|
|
1107
|
-
async function readPath(
|
|
1152
|
+
async function readPath(path2) {
|
|
1108
1153
|
const fs = await import(
|
|
1109
1154
|
/* webpackIgnore: true */
|
|
1110
1155
|
/* @vite-ignore */
|
|
1111
1156
|
NODE_FS
|
|
1112
1157
|
);
|
|
1113
|
-
return { bytes: new Uint8Array(await fs.readFile(
|
|
1158
|
+
return { bytes: new Uint8Array(await fs.readFile(path2)), name: path2.split(/[\\/]/).pop() || "file" };
|
|
1114
1159
|
}
|
|
1115
1160
|
async function readSource(source) {
|
|
1116
1161
|
if (typeof source === "string") return readPath(source);
|
|
@@ -1195,6 +1240,8 @@ var Oya = class {
|
|
|
1195
1240
|
personaGroups = personaGroupApi(() => this.http);
|
|
1196
1241
|
/** The same as `personaGroups`, matching the `profiles` alias. */
|
|
1197
1242
|
profileGroups = this.personaGroups;
|
|
1243
|
+
/** Build and message project-owned hosted assistants. */
|
|
1244
|
+
assistants = assistantApi(() => this.http);
|
|
1198
1245
|
/** What this key has spent. */
|
|
1199
1246
|
usage() {
|
|
1200
1247
|
return this.http.request("GET", "/api/usage");
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oya-ai/browser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.297",
|
|
4
4
|
"description": "TypeScript SDK for Oya, the HIPAA-compliant agentic browser: start cloud browsers, run playbooks, attach Playwright.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://oyabrowser.com",
|