@arbidocs/sdk 0.5.66 → 0.5.68
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/{browser-DHvxPDoF.d.cts → browser-BsuUurv5.d.cts} +98 -1
- package/dist/{browser-DpDuiKeo.d.ts → browser-D0iEy5W9.d.ts} +98 -1
- package/dist/browser.cjs +122 -0
- package/dist/browser.cjs.map +1 -1
- package/dist/browser.d.cts +1 -1
- package/dist/browser.d.ts +1 -1
- package/dist/browser.js +123 -2
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +122 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +123 -2
- package/dist/index.js.map +1 -1
- package/examples/react-chat/package.json +2 -2
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -6476,6 +6476,82 @@ async function listHouseTemplateCandidates(arbi) {
|
|
|
6476
6476
|
);
|
|
6477
6477
|
}
|
|
6478
6478
|
|
|
6479
|
+
// src/operations/model-connections.ts
|
|
6480
|
+
var model_connections_exports = {};
|
|
6481
|
+
__export(model_connections_exports, {
|
|
6482
|
+
directUsage: () => directUsage,
|
|
6483
|
+
listConnections: () => listConnections,
|
|
6484
|
+
removeConnection: () => removeConnection,
|
|
6485
|
+
savePersonalConnection: () => savePersonalConnection,
|
|
6486
|
+
sealPersonalApiKey: () => sealPersonalApiKey,
|
|
6487
|
+
unlockModelConnections: () => unlockModelConnections
|
|
6488
|
+
});
|
|
6489
|
+
var FAILED = "Could not update model connections";
|
|
6490
|
+
async function listConnections(arbi) {
|
|
6491
|
+
return requireData(await arbi.fetch.GET("/v1/model-connections"), FAILED);
|
|
6492
|
+
}
|
|
6493
|
+
async function directUsage(arbi) {
|
|
6494
|
+
return requireData(
|
|
6495
|
+
await arbi.fetch.GET("/v1/model-connections/usage"),
|
|
6496
|
+
FAILED
|
|
6497
|
+
);
|
|
6498
|
+
}
|
|
6499
|
+
async function savePersonalConnection(arbi, body, id) {
|
|
6500
|
+
const result = id ? await arbi.fetch.PUT("/v1/model-connections/personal/{connection_id}", {
|
|
6501
|
+
params: { path: { connection_id: id } },
|
|
6502
|
+
body
|
|
6503
|
+
}) : await arbi.fetch.POST("/v1/model-connections/personal", { body });
|
|
6504
|
+
return requireData(result, FAILED);
|
|
6505
|
+
}
|
|
6506
|
+
async function removeConnection(arbi, id) {
|
|
6507
|
+
requireOk(
|
|
6508
|
+
await arbi.fetch.DELETE("/v1/model-connections/{connection_id}", {
|
|
6509
|
+
params: { path: { connection_id: id } }
|
|
6510
|
+
}),
|
|
6511
|
+
FAILED
|
|
6512
|
+
);
|
|
6513
|
+
}
|
|
6514
|
+
async function sealPersonalApiKey(apiKey, signingPrivateKey) {
|
|
6515
|
+
await client.initSodium();
|
|
6516
|
+
const pair = client.encryptionKeypairFromSigningKey(signingPrivateKey);
|
|
6517
|
+
const bytes = new TextEncoder().encode(apiKey);
|
|
6518
|
+
try {
|
|
6519
|
+
return client.sealedBoxEncrypt(bytes, pair.publicKey);
|
|
6520
|
+
} finally {
|
|
6521
|
+
bytes.fill(0);
|
|
6522
|
+
pair.secretKey.fill(0);
|
|
6523
|
+
}
|
|
6524
|
+
}
|
|
6525
|
+
async function unlockModelConnections(arbi, keys, onlyId) {
|
|
6526
|
+
await client.initSodium();
|
|
6527
|
+
const pair = client.encryptionKeypairFromSigningKey(keys.signingPrivateKey);
|
|
6528
|
+
try {
|
|
6529
|
+
const rows = requireData(
|
|
6530
|
+
await arbi.fetch.GET("/v1/model-connections/sealed-keys"),
|
|
6531
|
+
FAILED
|
|
6532
|
+
);
|
|
6533
|
+
for (const row of rows) {
|
|
6534
|
+
if (onlyId && onlyId !== row.id || !row.sealed_api_key || !row.enabled) continue;
|
|
6535
|
+
const bytes = client.sealedBoxDecrypt(row.sealed_api_key, pair.secretKey);
|
|
6536
|
+
try {
|
|
6537
|
+
requireOk(
|
|
6538
|
+
await arbi.fetch.POST("/v1/model-connections/session-key", {
|
|
6539
|
+
body: {
|
|
6540
|
+
connection_id: row.id,
|
|
6541
|
+
sealed_api_key: client.sealedBoxEncrypt(bytes, keys.serverSessionKey)
|
|
6542
|
+
}
|
|
6543
|
+
}),
|
|
6544
|
+
FAILED
|
|
6545
|
+
);
|
|
6546
|
+
} finally {
|
|
6547
|
+
bytes.fill(0);
|
|
6548
|
+
}
|
|
6549
|
+
}
|
|
6550
|
+
} finally {
|
|
6551
|
+
pair.secretKey.fill(0);
|
|
6552
|
+
}
|
|
6553
|
+
}
|
|
6554
|
+
|
|
6479
6555
|
// src/operations/workspaces.ts
|
|
6480
6556
|
var workspaces_exports = {};
|
|
6481
6557
|
__export(workspaces_exports, {
|
|
@@ -13531,6 +13607,46 @@ var Arbi = class {
|
|
|
13531
13607
|
/** The documents the open workspace may use as its house template. */
|
|
13532
13608
|
candidates: () => listHouseTemplateCandidates(this.requireClient())
|
|
13533
13609
|
};
|
|
13610
|
+
// ── Model connections ───────────────────────────────────────────────
|
|
13611
|
+
/**
|
|
13612
|
+
* The main agent's OpenAI-compatible endpoints: the box's and the user's own. A personal key is
|
|
13613
|
+
* sealed to the user's identity and usable by a session only once unlocked on it.
|
|
13614
|
+
*/
|
|
13615
|
+
modelConnections = {
|
|
13616
|
+
list: () => listConnections(this.requireClient()),
|
|
13617
|
+
/** The user's direct model calls of the last 30 days. */
|
|
13618
|
+
usage: () => directUsage(this.requireClient()),
|
|
13619
|
+
/**
|
|
13620
|
+
* Add a personal connection (or replace `id`'s). An `apiKey` is sealed to the identity before
|
|
13621
|
+
* it is sent; an enabled connection with a key is unlocked on this session at once.
|
|
13622
|
+
*/
|
|
13623
|
+
save: async ({ id, apiKey, ...body }) => {
|
|
13624
|
+
const sealed = apiKey ? await sealPersonalApiKey(apiKey, this.identityKey()) : void 0;
|
|
13625
|
+
const row = await savePersonalConnection(
|
|
13626
|
+
this.requireClient(),
|
|
13627
|
+
{
|
|
13628
|
+
...body,
|
|
13629
|
+
protocol: "openai_chat_completions",
|
|
13630
|
+
allow_private_network: false,
|
|
13631
|
+
...sealed ? { sealed_api_key: sealed } : {}
|
|
13632
|
+
},
|
|
13633
|
+
id
|
|
13634
|
+
);
|
|
13635
|
+
if (row.has_api_key && row.enabled) await this.modelConnections.unlock(row.id);
|
|
13636
|
+
return row;
|
|
13637
|
+
},
|
|
13638
|
+
remove: (id) => removeConnection(this.requireClient(), id),
|
|
13639
|
+
/** Let this session use the user's enabled personal keys (only `onlyId`'s when given). */
|
|
13640
|
+
unlock: async (onlyId) => {
|
|
13641
|
+
const serverSessionKey = this.client?.session.getState().serverSessionKey ?? this.loginResult?.serverSessionKey;
|
|
13642
|
+
if (!serverSessionKey) throw new ArbiError("Sign in again to unlock model connections");
|
|
13643
|
+
await unlockModelConnections(
|
|
13644
|
+
this.requireClient(),
|
|
13645
|
+
{ signingPrivateKey: this.identityKey(), serverSessionKey },
|
|
13646
|
+
onlyId
|
|
13647
|
+
);
|
|
13648
|
+
}
|
|
13649
|
+
};
|
|
13534
13650
|
// ── Databases (user-defined tables of the open workspace) ──────────
|
|
13535
13651
|
databases = {
|
|
13536
13652
|
list: () => listDatabases(this.requireClient()),
|
|
@@ -13588,6 +13704,11 @@ var Arbi = class {
|
|
|
13588
13704
|
}
|
|
13589
13705
|
return this.loginResult;
|
|
13590
13706
|
}
|
|
13707
|
+
/** The signed-in user's identity (signing) key. */
|
|
13708
|
+
identityKey() {
|
|
13709
|
+
if (!this.loginResult) throw new ArbiError("Unlock your identity first");
|
|
13710
|
+
return this.loginResult.signingPrivateKey;
|
|
13711
|
+
}
|
|
13591
13712
|
requireWorkspace() {
|
|
13592
13713
|
if (!this.currentWorkspaceId) {
|
|
13593
13714
|
throw new ArbiError("No workspace selected. Call selectWorkspace() first.");
|
|
@@ -15539,6 +15660,7 @@ exports.mail = mail_exports;
|
|
|
15539
15660
|
exports.mailNode = mail_node_exports;
|
|
15540
15661
|
exports.mcpTools = mcpTools;
|
|
15541
15662
|
exports.mergeAgentSteps = mergeAgentSteps;
|
|
15663
|
+
exports.modelConnections = model_connections_exports;
|
|
15542
15664
|
exports.notifications = notifications_exports;
|
|
15543
15665
|
exports.parseSSEEvents = parseSSEEvents;
|
|
15544
15666
|
exports.parseSlashCommand = parseSlashCommand;
|