@oya-ai/cli 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.js +72 -27
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1547,10 +1547,10 @@ function formatEnvValue(value) {
|
|
|
1547
1547
|
const escaped = value.replace(/\\/g, "\\\\").replace(/"/g, '\\"').replace(/\n/g, "\\n").replace(/\r/g, "\\r");
|
|
1548
1548
|
return `"${escaped}"`;
|
|
1549
1549
|
}
|
|
1550
|
-
function readEnv(
|
|
1551
|
-
if (!existsSync3(
|
|
1550
|
+
function readEnv(path2) {
|
|
1551
|
+
if (!existsSync3(path2)) return {};
|
|
1552
1552
|
const out2 = {};
|
|
1553
|
-
for (const line of readFileSync3(
|
|
1553
|
+
for (const line of readFileSync3(path2, "utf8").split("\n")) {
|
|
1554
1554
|
const m = /^(?:export\s+)?([A-Z0-9_]+)=(.*)$/.exec(line.trim());
|
|
1555
1555
|
if (m) out2[m[1]] = parseEnvValue(m[2]);
|
|
1556
1556
|
}
|
|
@@ -1577,8 +1577,8 @@ function renderEnv(values, extra) {
|
|
|
1577
1577
|
if (extra.length) lines.push(...extra, "");
|
|
1578
1578
|
return lines.join("\n");
|
|
1579
1579
|
}
|
|
1580
|
-
function writeEnv(
|
|
1581
|
-
writePrivateFile(
|
|
1580
|
+
function writeEnv(path2, body) {
|
|
1581
|
+
writePrivateFile(path2, body, ENV_FILE_MODE);
|
|
1582
1582
|
}
|
|
1583
1583
|
|
|
1584
1584
|
// src/install/build-env.ts
|
|
@@ -2968,11 +2968,11 @@ function replayDeployment(flags, saved) {
|
|
|
2968
2968
|
return plan2;
|
|
2969
2969
|
}
|
|
2970
2970
|
function saveDeploymentPlan(root, p) {
|
|
2971
|
-
const
|
|
2971
|
+
const path2 = join7(root, PLAN_FILE), temporary = `${path2}.${process.pid}.tmp`;
|
|
2972
2972
|
writeFileSync3(temporary, `${JSON.stringify(p, null, JSON_INDENT)}
|
|
2973
2973
|
`, { mode: ENV_FILE_MODE, flag: "wx" });
|
|
2974
|
-
renameSync2(temporary,
|
|
2975
|
-
note(`Saved ${
|
|
2974
|
+
renameSync2(temporary, path2);
|
|
2975
|
+
note(`Saved ${path2}; credentials stay in the target's secret store.`);
|
|
2976
2976
|
}
|
|
2977
2977
|
async function executeDeployment(root, p, databaseUrl2) {
|
|
2978
2978
|
try {
|
|
@@ -3279,9 +3279,9 @@ var Http = class _Http {
|
|
|
3279
3279
|
return new _Http(this.baseUrl, this.apiKey, this.timeoutMs, this.fetchImpl, this.origin, merged);
|
|
3280
3280
|
}
|
|
3281
3281
|
/** Sends one request and returns the parsed answer, or throws an OyaError when it failed. */
|
|
3282
|
-
async request(method,
|
|
3283
|
-
const res = await this.send(`${this.baseUrl}${
|
|
3284
|
-
return readAnswer2(res, `${method} ${
|
|
3282
|
+
async request(method, path2, body, timeoutMs = this.timeoutMs, headers = {}) {
|
|
3283
|
+
const res = await this.send(`${this.baseUrl}${path2}`, this.init(method, body, timeoutMs, headers), timeoutMs);
|
|
3284
|
+
return readAnswer2(res, `${method} ${path2}`, this);
|
|
3285
3285
|
}
|
|
3286
3286
|
/** The fetch options for one call, with this client's key on them. */
|
|
3287
3287
|
init(method, body, timeoutMs, headers) {
|
|
@@ -3549,8 +3549,8 @@ var Browser = class {
|
|
|
3549
3549
|
http;
|
|
3550
3550
|
/** Runs one browser command; a command that ran and failed throws. */
|
|
3551
3551
|
async command(action, params = {}, timeoutMs) {
|
|
3552
|
-
const
|
|
3553
|
-
const result = await this.http.request("POST",
|
|
3552
|
+
const path2 = `/api/browsers/${segment(this.id)}/command`;
|
|
3553
|
+
const result = await this.http.request("POST", path2, { action, params }, timeoutMs);
|
|
3554
3554
|
if (result.ok === false) throw new OyaError(result.error || `${action} failed`, Status3.UNPROCESSABLE, result);
|
|
3555
3555
|
return result.data;
|
|
3556
3556
|
}
|
|
@@ -3662,8 +3662,8 @@ var Browser = class {
|
|
|
3662
3662
|
*/
|
|
3663
3663
|
async ask(prompt, { data, secrets } = {}) {
|
|
3664
3664
|
const body = { messages: [{ role: "user", content: prompt }], data, secrets };
|
|
3665
|
-
const
|
|
3666
|
-
return agentAnswer(await this.http.request("POST",
|
|
3665
|
+
const path2 = `/api/browsers/${segment(this.id)}/chat`;
|
|
3666
|
+
return agentAnswer(await this.http.request("POST", path2, body, AGENT_TIMEOUT_MS)).text;
|
|
3667
3667
|
}
|
|
3668
3668
|
/**
|
|
3669
3669
|
* `ask()` for data: the agent does the task and answers in the shape of `schema`
|
|
@@ -3671,8 +3671,8 @@ var Browser = class {
|
|
|
3671
3671
|
*/
|
|
3672
3672
|
async extract(prompt, schema, values = {}) {
|
|
3673
3673
|
const body = { messages: [{ role: "user", content: prompt }], ...values, schema };
|
|
3674
|
-
const
|
|
3675
|
-
const res = agentAnswer(await this.http.request("POST",
|
|
3674
|
+
const path2 = `/api/browsers/${segment(this.id)}/chat`;
|
|
3675
|
+
const res = agentAnswer(await this.http.request("POST", path2, body, AGENT_TIMEOUT_MS));
|
|
3676
3676
|
if (res.failed || res.data === void 0) throw new OyaError(res.text, Status3.UNPROCESSABLE, res);
|
|
3677
3677
|
return res.data;
|
|
3678
3678
|
}
|
|
@@ -3697,9 +3697,9 @@ var Browser = class {
|
|
|
3697
3697
|
* replaces the broken steps in the playbook (`healed`); off, the step's error is thrown.
|
|
3698
3698
|
*/
|
|
3699
3699
|
async play(name, data = {}, { autoHeal = true } = {}) {
|
|
3700
|
-
const
|
|
3700
|
+
const path2 = `/api/browsers/${segment(this.id)}/playbooks/${segment(name, "name")}/play`;
|
|
3701
3701
|
return agentAnswer(
|
|
3702
|
-
await this.http.request("POST",
|
|
3702
|
+
await this.http.request("POST", path2, { variables: data, autoHeal }, AGENT_TIMEOUT_MS)
|
|
3703
3703
|
);
|
|
3704
3704
|
}
|
|
3705
3705
|
/**
|
|
@@ -3729,8 +3729,8 @@ var Browser = class {
|
|
|
3729
3729
|
* 60 seconds. Mint one per viewer, the first connection spends it.
|
|
3730
3730
|
*/
|
|
3731
3731
|
async liveStreamUrl() {
|
|
3732
|
-
const
|
|
3733
|
-
const { ticket } = await this.http.request("POST",
|
|
3732
|
+
const path2 = `/api/control/sessions/${segment(this.id)}/ticket`;
|
|
3733
|
+
const { ticket } = await this.http.request("POST", path2, {});
|
|
3734
3734
|
return `${this.http.baseUrl}/api/live/${segment(this.id)}?ticket=${encodeURIComponent(ticket)}`;
|
|
3735
3735
|
}
|
|
3736
3736
|
/**
|
|
@@ -3745,8 +3745,8 @@ var Browser = class {
|
|
|
3745
3745
|
* expires or you revoke it, so treat it like a password.
|
|
3746
3746
|
*/
|
|
3747
3747
|
async shareUrl({ control = false, expiresInSeconds = 3600 } = {}) {
|
|
3748
|
-
const
|
|
3749
|
-
const c = await this.http.request("POST",
|
|
3748
|
+
const path2 = `/api/control/sessions/${segment(this.id)}/share`;
|
|
3749
|
+
const c = await this.http.request("POST", path2, { control, expiresIn: expiresInSeconds });
|
|
3750
3750
|
return { url: shareLink(this.http.baseUrl, this.id, c.token), id: c.id, expiresAt: c.expiresAt };
|
|
3751
3751
|
}
|
|
3752
3752
|
/** Revoke a link from `shareUrl()` before it expires, by the id it returned. */
|
|
@@ -3818,8 +3818,8 @@ function startBody(options) {
|
|
|
3818
3818
|
var idempotencyKeyOf = ({ idempotencyKey }) => idempotencyKey ? headerSafe(idempotencyKey, "idempotencyKey", 'Use letters, digits, "-" and "_".') : globalThis.crypto.randomUUID();
|
|
3819
3819
|
async function start(http, wait, options) {
|
|
3820
3820
|
const headers = { "Idempotency-Key": idempotencyKeyOf(options) };
|
|
3821
|
-
const
|
|
3822
|
-
const started = await http().request("POST",
|
|
3821
|
+
const path2 = "/api/browsers/start";
|
|
3822
|
+
const started = await http().request("POST", path2, startBody(options), START_TIMEOUT_MS, headers);
|
|
3823
3823
|
if (started.status === "starting") {
|
|
3824
3824
|
await wait(started.id, options.readyTimeoutMs ?? READY_TIMEOUT_MS2 + (options.queueMs || 0));
|
|
3825
3825
|
started.cdpUrl = (await fetchBrowser(http, started.id)).cdpUrl;
|
|
@@ -4050,6 +4050,49 @@ var personaGroupApi = (http) => ({
|
|
|
4050
4050
|
await http().request("DELETE", `/api/persona-groups/${segment(name, "name")}`);
|
|
4051
4051
|
}
|
|
4052
4052
|
});
|
|
4053
|
+
var path = (id) => "/api/assistants/" + segment(id, "assistant ID");
|
|
4054
|
+
var gateways = (http) => ({
|
|
4055
|
+
/** Request device pairing. */
|
|
4056
|
+
connectWhatsApp: (id) => http().request("POST", path(id) + "/whatsapp"),
|
|
4057
|
+
/** Read the currently active pairing code or connection status. */
|
|
4058
|
+
whatsAppStatus: (id) => http().request("GET", path(id) + "/whatsapp"),
|
|
4059
|
+
/** Stop handling incoming messages and erase local WhatsApp credentials. */
|
|
4060
|
+
disconnectWhatsApp: (id) => http().request("DELETE", path(id) + "/whatsapp"),
|
|
4061
|
+
/** Rotate the key accepted by the assistant webhook. */
|
|
4062
|
+
rotateInboundKey: (id) => http().request("POST", path(id) + "/inbound-key")
|
|
4063
|
+
});
|
|
4064
|
+
var skills = (http) => ({
|
|
4065
|
+
/** List available reusable instructions. */
|
|
4066
|
+
listSkills: async () => (await http().request("GET", "/api/assistants")).skills,
|
|
4067
|
+
/** Save instructions once for several assistants. */
|
|
4068
|
+
createSkill: (body) => http().request("POST", "/api/assistants/skills", body)
|
|
4069
|
+
});
|
|
4070
|
+
var definitions = (http) => ({
|
|
4071
|
+
/** Discover definitions in this project. */
|
|
4072
|
+
list: async () => (await http().request("GET", "/api/assistants")).assistants,
|
|
4073
|
+
/** Save a new assistant. */
|
|
4074
|
+
create: (body) => http().request("POST", "/api/assistants", body),
|
|
4075
|
+
/** Change the instructions for future turns. */
|
|
4076
|
+
update: (id, body) => http().request("PUT", path(id), body),
|
|
4077
|
+
/** Change one assistant's model without interrupting its device or contact memory. */
|
|
4078
|
+
setModel: (id, model) => http().request("PATCH", path(id) + "/model", { model }),
|
|
4079
|
+
/** Remove this assistant and its messages. */
|
|
4080
|
+
remove: (id) => http().request("DELETE", path(id))
|
|
4081
|
+
});
|
|
4082
|
+
var conversations = (http) => ({
|
|
4083
|
+
/** Submit a contact message for asynchronous processing. */
|
|
4084
|
+
send: (id, body) => http().request("POST", path(id) + "/messages", body),
|
|
4085
|
+
/** Read the original receipt and latest response. */
|
|
4086
|
+
message: (id, messageId) => http().request("GET", path(id) + "/messages/" + segment(messageId, "message ID")),
|
|
4087
|
+
/** Erase a contact's conversation. */
|
|
4088
|
+
forget: (id, contact) => http().request("DELETE", path(id) + "/contacts/" + segment(contact, "contact"))
|
|
4089
|
+
});
|
|
4090
|
+
var assistantApi = (http) => ({
|
|
4091
|
+
...definitions(http),
|
|
4092
|
+
...skills(http),
|
|
4093
|
+
...conversations(http),
|
|
4094
|
+
...gateways(http)
|
|
4095
|
+
});
|
|
4053
4096
|
var configApi = (http) => ({
|
|
4054
4097
|
/** This key's settings. Secrets read back masked. */
|
|
4055
4098
|
get: () => http().request("GET", "/api/config"),
|
|
@@ -4227,6 +4270,8 @@ var Oya = class {
|
|
|
4227
4270
|
personaGroups = personaGroupApi(() => this.http);
|
|
4228
4271
|
/** The same as `personaGroups`, matching the `profiles` alias. */
|
|
4229
4272
|
profileGroups = this.personaGroups;
|
|
4273
|
+
/** Build and message project-owned hosted assistants. */
|
|
4274
|
+
assistants = assistantApi(() => this.http);
|
|
4230
4275
|
/** What this key has spent. */
|
|
4231
4276
|
usage() {
|
|
4232
4277
|
return this.http.request("GET", "/api/usage");
|
|
@@ -4999,9 +5044,9 @@ import { createRequire } from "module";
|
|
|
4999
5044
|
var help = async () => console.log(HELP2);
|
|
5000
5045
|
function packageVersion() {
|
|
5001
5046
|
const require2 = createRequire(import.meta.url);
|
|
5002
|
-
for (const
|
|
5047
|
+
for (const path2 of ["../package.json", "../../package.json"]) {
|
|
5003
5048
|
try {
|
|
5004
|
-
return require2(
|
|
5049
|
+
return require2(path2).version;
|
|
5005
5050
|
} catch {
|
|
5006
5051
|
}
|
|
5007
5052
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oya-ai/cli",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.297",
|
|
4
4
|
"description": "Command line for Oya, the HIPAA-compliant agentic browser: start browsers and run playbooks from your terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://oyabrowser.com",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"access": "public"
|
|
51
51
|
},
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@oya-ai/browser": "1.0.
|
|
53
|
+
"@oya-ai/browser": "1.0.297",
|
|
54
54
|
"@types/node": "^20.19.43",
|
|
55
55
|
"tsup": "^9.0.0",
|
|
56
56
|
"typescript": "^6.0.3"
|