@arbidocs/sdk 0.4.159 → 0.4.160
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-5rJLwOd9.d.cts → browser-coa0VhYO.d.cts} +232 -33
- package/dist/{browser-5rJLwOd9.d.ts → browser-coa0VhYO.d.ts} +232 -33
- package/dist/browser.cjs +292 -55
- 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 +292 -57
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +291 -55
- 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 +292 -57
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -3533,6 +3533,14 @@ var ArbiApiError = class extends ArbiError {
|
|
|
3533
3533
|
this.detail = apiErrorDetail(apiError);
|
|
3534
3534
|
}
|
|
3535
3535
|
};
|
|
3536
|
+
var DuplicateContactError = class extends ArbiApiError {
|
|
3537
|
+
contactId;
|
|
3538
|
+
constructor(message, contactId, apiError) {
|
|
3539
|
+
super(message, apiError ?? { detail: message }, 409);
|
|
3540
|
+
this.name = "DuplicateContactError";
|
|
3541
|
+
this.contactId = contactId;
|
|
3542
|
+
}
|
|
3543
|
+
};
|
|
3536
3544
|
function refusalReason(err, fallback) {
|
|
3537
3545
|
if (err instanceof ArbiApiError) return err.detail || fallback;
|
|
3538
3546
|
return apiErrorDetail(err) || fallback;
|
|
@@ -5027,8 +5035,20 @@ var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
5027
5035
|
function sanitizeFolderPath(folderPath) {
|
|
5028
5036
|
return folderPath.replace(/[\x00-\x1f\x7f]/g, "").replace(/\\/g, "/").replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "").trim();
|
|
5029
5037
|
}
|
|
5030
|
-
async function listDocuments(arbi) {
|
|
5031
|
-
|
|
5038
|
+
async function listDocuments(arbi, workspaceExtId) {
|
|
5039
|
+
if (!workspaceExtId) {
|
|
5040
|
+
return requireData(await arbi.fetch.GET("/v1/document/list"), "Failed to fetch documents");
|
|
5041
|
+
}
|
|
5042
|
+
const docs = requireData(
|
|
5043
|
+
await arbi.fetch.GET("/v1/document/list", {
|
|
5044
|
+
params: { query: { workspace_ext_id: workspaceExtId } }
|
|
5045
|
+
}),
|
|
5046
|
+
"Failed to fetch documents"
|
|
5047
|
+
);
|
|
5048
|
+
if (docs.some((doc) => doc.workspace_ext_id !== workspaceExtId)) {
|
|
5049
|
+
throw new ArbiError(`This server cannot list workspace ${workspaceExtId} without opening it`);
|
|
5050
|
+
}
|
|
5051
|
+
return docs;
|
|
5032
5052
|
}
|
|
5033
5053
|
async function* listPaginated(arbi, options = {}) {
|
|
5034
5054
|
const {
|
|
@@ -5675,10 +5695,13 @@ async function grantTemporaryWorkspaceAccess(arbi, params) {
|
|
|
5675
5695
|
"Failed to grant temporary access"
|
|
5676
5696
|
);
|
|
5677
5697
|
}
|
|
5678
|
-
async function removeWorkspaceUsers(arbi, userIds) {
|
|
5698
|
+
async function removeWorkspaceUsers(arbi, userIds, workspaceExtId) {
|
|
5679
5699
|
requireOk(
|
|
5680
5700
|
await arbi.fetch.DELETE("/v1/workspace/users", {
|
|
5681
|
-
body: {
|
|
5701
|
+
body: {
|
|
5702
|
+
users: userIds.map((id) => ({ user_ext_id: id })),
|
|
5703
|
+
...workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}
|
|
5704
|
+
}
|
|
5682
5705
|
}),
|
|
5683
5706
|
"Failed to remove users"
|
|
5684
5707
|
);
|
|
@@ -5985,7 +6008,7 @@ async function listSkills(arbi, options) {
|
|
|
5985
6008
|
return result.skills;
|
|
5986
6009
|
}
|
|
5987
6010
|
function isSharedSkill(skill) {
|
|
5988
|
-
return skill.is_owner
|
|
6011
|
+
return (skill.is_owner ?? true) && skill.visibility === "global";
|
|
5989
6012
|
}
|
|
5990
6013
|
function uploadSkill(auth, slug, markdown, options) {
|
|
5991
6014
|
return uploadFile(auth, new Blob([markdown], { type: "text/markdown" }), "SKILL.md", {
|
|
@@ -6257,11 +6280,23 @@ __export(contacts_exports, {
|
|
|
6257
6280
|
createContact: () => createContact,
|
|
6258
6281
|
deleteContact: () => deleteContact,
|
|
6259
6282
|
groupContactsByStatus: () => groupContactsByStatus,
|
|
6283
|
+
importContacts: () => importContacts,
|
|
6260
6284
|
inviteContacts: () => inviteContacts,
|
|
6285
|
+
linkContact: () => linkContact,
|
|
6261
6286
|
listContacts: () => listContacts,
|
|
6262
6287
|
searchContacts: () => searchContacts,
|
|
6263
6288
|
updateContact: () => updateContact
|
|
6264
6289
|
});
|
|
6290
|
+
function requireContact(result, message) {
|
|
6291
|
+
const error = result.error;
|
|
6292
|
+
if (result.response?.status === 409 && error && typeof error === "object" && "contact_id" in error)
|
|
6293
|
+
throw new DuplicateContactError(
|
|
6294
|
+
apiErrorDetail(error) ?? "This person is already in your contacts",
|
|
6295
|
+
error.contact_id || null,
|
|
6296
|
+
error
|
|
6297
|
+
);
|
|
6298
|
+
return requireData(result, message);
|
|
6299
|
+
}
|
|
6265
6300
|
async function listContacts(arbi) {
|
|
6266
6301
|
return requireData(await arbi.fetch.GET("/v1/contacts/"), "Failed to fetch contacts");
|
|
6267
6302
|
}
|
|
@@ -6272,10 +6307,13 @@ async function inviteContacts(arbi, emails) {
|
|
|
6272
6307
|
);
|
|
6273
6308
|
}
|
|
6274
6309
|
async function createContact(arbi, body) {
|
|
6275
|
-
return
|
|
6310
|
+
return requireContact(
|
|
6311
|
+
await arbi.fetch.POST("/v1/contacts/", { body }),
|
|
6312
|
+
"Failed to create contact"
|
|
6313
|
+
);
|
|
6276
6314
|
}
|
|
6277
6315
|
async function updateContact(arbi, contactId, card) {
|
|
6278
|
-
return
|
|
6316
|
+
return requireContact(
|
|
6279
6317
|
await arbi.fetch.PATCH("/v1/contacts/{cnt_id}", {
|
|
6280
6318
|
params: { path: { cnt_id: contactId } },
|
|
6281
6319
|
body: { card, invite: false }
|
|
@@ -6283,12 +6321,32 @@ async function updateContact(arbi, contactId, card) {
|
|
|
6283
6321
|
"Failed to update contact"
|
|
6284
6322
|
);
|
|
6285
6323
|
}
|
|
6324
|
+
async function linkContact(arbi, contactId, email, card) {
|
|
6325
|
+
return requireContact(
|
|
6326
|
+
await arbi.fetch.PATCH("/v1/contacts/{cnt_id}", {
|
|
6327
|
+
params: { path: { cnt_id: contactId } },
|
|
6328
|
+
body: { card, email, invite: true }
|
|
6329
|
+
}),
|
|
6330
|
+
"Failed to link contact"
|
|
6331
|
+
);
|
|
6332
|
+
}
|
|
6286
6333
|
async function deleteContact(arbi, contactId) {
|
|
6287
6334
|
requireOk(
|
|
6288
6335
|
await arbi.fetch.DELETE("/v1/contacts/{cnt_id}", { params: { path: { cnt_id: contactId } } }),
|
|
6289
6336
|
"Failed to delete contact"
|
|
6290
6337
|
);
|
|
6291
6338
|
}
|
|
6339
|
+
async function importContacts(arbi, file) {
|
|
6340
|
+
const form = new FormData();
|
|
6341
|
+
form.append("file", file);
|
|
6342
|
+
return requireData(
|
|
6343
|
+
await arbi.fetch.POST("/v1/contacts/import", {
|
|
6344
|
+
body: { file: "" },
|
|
6345
|
+
bodySerializer: () => form
|
|
6346
|
+
}),
|
|
6347
|
+
"Failed to import contacts"
|
|
6348
|
+
);
|
|
6349
|
+
}
|
|
6292
6350
|
async function searchContacts(arbi, q2) {
|
|
6293
6351
|
return requireData(
|
|
6294
6352
|
await arbi.fetch.GET("/v1/contacts/search", { params: { query: { q: q2 } } }),
|
|
@@ -6360,8 +6418,11 @@ var chats_exports = {};
|
|
|
6360
6418
|
__export(chats_exports, {
|
|
6361
6419
|
CHAT_ATTACHMENT_MAX_BYTES: () => CHAT_ATTACHMENT_MAX_BYTES,
|
|
6362
6420
|
CHAT_ATTACHMENT_MAX_FILES: () => CHAT_ATTACHMENT_MAX_FILES,
|
|
6421
|
+
CHAT_PAGE_SIZE: () => CHAT_PAGE_SIZE,
|
|
6363
6422
|
DECRYPTION_FAILED: () => DECRYPTION_FAILED,
|
|
6423
|
+
ENCRYPTED_PREVIEW: () => ENCRYPTED_PREVIEW,
|
|
6364
6424
|
addChatMembers: () => addChatMembers,
|
|
6425
|
+
chatMessagePreview: () => chatMessagePreview,
|
|
6365
6426
|
chatMessageTombstone: () => chatMessageTombstone,
|
|
6366
6427
|
checkChatAttachmentLimits: () => checkChatAttachmentLimits,
|
|
6367
6428
|
createChatCryptoContext: () => createChatCryptoContext,
|
|
@@ -6378,6 +6439,7 @@ __export(chats_exports, {
|
|
|
6378
6439
|
getChat: () => getChat,
|
|
6379
6440
|
hasRead: () => hasRead,
|
|
6380
6441
|
isAgentExtId: () => isAgentExtId,
|
|
6442
|
+
isTranscriptMessage: () => isTranscriptMessage,
|
|
6381
6443
|
listChatMessages: () => listChatMessages,
|
|
6382
6444
|
listChats: () => listChats,
|
|
6383
6445
|
loadDecryptedChat: () => loadDecryptedChat,
|
|
@@ -6385,6 +6447,8 @@ __export(chats_exports, {
|
|
|
6385
6447
|
openChatKeyRing: () => openChatKeyRing,
|
|
6386
6448
|
openDirectChat: () => openDirectChat,
|
|
6387
6449
|
parseChatAttachmentManifest: () => parseChatAttachmentManifest,
|
|
6450
|
+
parseTranscriptContent: () => parseTranscriptContent,
|
|
6451
|
+
readByOthers: () => readByOthers,
|
|
6388
6452
|
removeChatMember: () => removeChatMember,
|
|
6389
6453
|
renameChat: () => renameChat,
|
|
6390
6454
|
resolveRecipient: () => resolveRecipient,
|
|
@@ -6681,6 +6745,39 @@ function chatMessageTombstone(message) {
|
|
|
6681
6745
|
delete row.attachmentsError;
|
|
6682
6746
|
return row;
|
|
6683
6747
|
}
|
|
6748
|
+
function isTranscriptMessage(message) {
|
|
6749
|
+
return message.kind === "transcript";
|
|
6750
|
+
}
|
|
6751
|
+
function parseTranscriptContent(content) {
|
|
6752
|
+
if (!content) return null;
|
|
6753
|
+
try {
|
|
6754
|
+
const parsed = JSON.parse(content);
|
|
6755
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
6756
|
+
const p2 = parsed;
|
|
6757
|
+
if (typeof p2.text !== "string") return null;
|
|
6758
|
+
return {
|
|
6759
|
+
text: p2.text,
|
|
6760
|
+
speaker_identity: typeof p2.speaker_identity === "string" ? p2.speaker_identity : "",
|
|
6761
|
+
speaker_name: typeof p2.speaker_name === "string" ? p2.speaker_name : "",
|
|
6762
|
+
started_at: typeof p2.started_at === "string" ? p2.started_at : null
|
|
6763
|
+
};
|
|
6764
|
+
} catch {
|
|
6765
|
+
return null;
|
|
6766
|
+
}
|
|
6767
|
+
}
|
|
6768
|
+
var ENCRYPTED_PREVIEW = "[Encrypted]";
|
|
6769
|
+
function chatMessagePreview(message) {
|
|
6770
|
+
if (message.deleted) return null;
|
|
6771
|
+
if (message.kind === "call") return "Call";
|
|
6772
|
+
if (message.kind === "recording") return "Recording";
|
|
6773
|
+
if (message.decryptFailed) return ENCRYPTED_PREVIEW;
|
|
6774
|
+
const transcript = isTranscriptMessage(message) ? parseTranscriptContent(message.content) : null;
|
|
6775
|
+
if (transcript) {
|
|
6776
|
+
return `Transcript \xB7 ${transcript.speaker_name ? `${transcript.speaker_name}: ` : ""}${transcript.text}`;
|
|
6777
|
+
}
|
|
6778
|
+
if (message.content) return message.content;
|
|
6779
|
+
return message.attachmentFiles?.length ? `\u{1F4CE} ${message.attachmentFiles.map((f2) => f2.name).join(", ")}` : null;
|
|
6780
|
+
}
|
|
6684
6781
|
async function decryptChatMessage(ring, message) {
|
|
6685
6782
|
if (message.deleted) return chatMessageTombstone(message);
|
|
6686
6783
|
const key = ring.keys.get(message.key_version);
|
|
@@ -6781,12 +6878,18 @@ async function renameChat(arbi, ring, title) {
|
|
|
6781
6878
|
"Failed to rename chat"
|
|
6782
6879
|
);
|
|
6783
6880
|
}
|
|
6784
|
-
async function addChatMembers(arbi, ring, members) {
|
|
6881
|
+
async function addChatMembers(arbi, ring, members, options = {}) {
|
|
6785
6882
|
if (ring.kind === "direct") {
|
|
6786
6883
|
throw new Error("A direct chat cannot gain members: create a group instead");
|
|
6787
6884
|
}
|
|
6788
6885
|
if (members.some((m2) => isAgentExtId(m2.external_id))) {
|
|
6789
|
-
throw new Error(
|
|
6886
|
+
throw new Error(
|
|
6887
|
+
ring.kind === "meeting" ? "Personal agents cannot join a meeting chat" : "Personal agents cannot join a group chat"
|
|
6888
|
+
);
|
|
6889
|
+
}
|
|
6890
|
+
const callKey = options.callKey ?? null;
|
|
6891
|
+
if (ring.kind === "meeting" && !callKey) {
|
|
6892
|
+
throw new Error("You do not hold this meeting\u2019s call key");
|
|
6790
6893
|
}
|
|
6791
6894
|
const key = keyFor(ring, ring.currentVersion);
|
|
6792
6895
|
return requireData(
|
|
@@ -6796,7 +6899,8 @@ async function addChatMembers(arbi, ring, members) {
|
|
|
6796
6899
|
members: await Promise.all(
|
|
6797
6900
|
members.map(async (m2) => ({
|
|
6798
6901
|
user_ext_id: m2.external_id,
|
|
6799
|
-
sealed_key: await client.sealChatKey(key, m2.encryption_public_key)
|
|
6902
|
+
sealed_key: await client.sealChatKey(key, m2.encryption_public_key),
|
|
6903
|
+
...callKey ? { call_sealed_key: await client.sealCallKey(callKey, m2.encryption_public_key) } : {}
|
|
6800
6904
|
}))
|
|
6801
6905
|
)
|
|
6802
6906
|
}
|
|
@@ -6849,6 +6953,7 @@ async function ensureChatKeyCurrent(arbi, chat, crypto2) {
|
|
|
6849
6953
|
throw err;
|
|
6850
6954
|
}
|
|
6851
6955
|
}
|
|
6956
|
+
var CHAT_PAGE_SIZE = 50;
|
|
6852
6957
|
async function listChatMessages(arbi, chatExtId, options) {
|
|
6853
6958
|
return requireData(
|
|
6854
6959
|
await arbi.fetch.GET("/v1/chats/{chat_ext_id}/messages", {
|
|
@@ -6911,6 +7016,10 @@ function hasRead(member, message) {
|
|
|
6911
7016
|
if (!member?.last_read_at) return false;
|
|
6912
7017
|
return Date.parse(member.last_read_at) >= Date.parse(message.created_at);
|
|
6913
7018
|
}
|
|
7019
|
+
function readByOthers(chat, myExtId, message) {
|
|
7020
|
+
const others = chat.members.filter((m2) => m2.user.external_id !== myExtId);
|
|
7021
|
+
return others.every((m2) => hasRead(m2, message));
|
|
7022
|
+
}
|
|
6914
7023
|
async function resolveRecipient(arbi, ref) {
|
|
6915
7024
|
const isEmail = ref.includes("@");
|
|
6916
7025
|
const matchKey = isEmail ? "email" : "external_id";
|
|
@@ -7452,7 +7561,6 @@ async function getFileContent(auth, fileId) {
|
|
|
7452
7561
|
// src/operations/sessions.ts
|
|
7453
7562
|
var sessions_exports = {};
|
|
7454
7563
|
__export(sessions_exports, {
|
|
7455
|
-
currentSessionId: () => currentSessionId,
|
|
7456
7564
|
listSessions: () => listSessions,
|
|
7457
7565
|
logoutAllSessions: () => logoutAllSessions,
|
|
7458
7566
|
terminateSession: () => terminateSession
|
|
@@ -7475,16 +7583,6 @@ async function logoutAllSessions(arbi) {
|
|
|
7475
7583
|
"Failed to sign out of all sessions"
|
|
7476
7584
|
);
|
|
7477
7585
|
}
|
|
7478
|
-
function currentSessionId(accessToken) {
|
|
7479
|
-
const payload = accessToken?.split(".")[1];
|
|
7480
|
-
if (!payload) return null;
|
|
7481
|
-
try {
|
|
7482
|
-
const claims = JSON.parse(atob(payload.replace(/-/g, "+").replace(/_/g, "/")));
|
|
7483
|
-
return typeof claims.sk === "string" ? claims.sk.slice(0, 12) : null;
|
|
7484
|
-
} catch {
|
|
7485
|
-
return null;
|
|
7486
|
-
}
|
|
7487
|
-
}
|
|
7488
7586
|
|
|
7489
7587
|
// src/operations/profile.ts
|
|
7490
7588
|
var profile_exports = {};
|
|
@@ -7522,9 +7620,13 @@ async function topUpFirmPool(arbi, aiAddons) {
|
|
|
7522
7620
|
var account_exports = {};
|
|
7523
7621
|
__export(account_exports, {
|
|
7524
7622
|
confirmEmailChange: () => confirmEmailChange,
|
|
7623
|
+
getEntitlements: () => getEntitlements,
|
|
7525
7624
|
requestDeletion: () => requestDeletion,
|
|
7526
7625
|
requestEmailChange: () => requestEmailChange
|
|
7527
7626
|
});
|
|
7627
|
+
async function getEntitlements(arbi) {
|
|
7628
|
+
return requireData(await arbi.fetch.GET("/v1/user/entitlements"), "Failed to load entitlements");
|
|
7629
|
+
}
|
|
7528
7630
|
async function requestEmailChange(arbi, newEmail) {
|
|
7529
7631
|
requireOk(
|
|
7530
7632
|
await arbi.fetch.POST("/v1/user/request-email-change", { body: { new_email: newEmail } }),
|
|
@@ -9431,15 +9533,8 @@ async function cancelPublicBooking(baseUrl, slug, token) {
|
|
|
9431
9533
|
|
|
9432
9534
|
// src/arbi.ts
|
|
9433
9535
|
function tokenExpiresWithin(token, seconds) {
|
|
9434
|
-
const
|
|
9435
|
-
|
|
9436
|
-
try {
|
|
9437
|
-
const json2 = atob(payload.replace(/-/g, "+").replace(/_/g, "/"));
|
|
9438
|
-
const { exp } = JSON.parse(json2);
|
|
9439
|
-
return typeof exp === "number" && exp * 1e3 - Date.now() < seconds * 1e3;
|
|
9440
|
-
} catch {
|
|
9441
|
-
return false;
|
|
9442
|
-
}
|
|
9536
|
+
const expiresAt = client.readSessionClaims(token)?.expiresAt;
|
|
9537
|
+
return expiresAt != null && expiresAt - Date.now() < seconds * 1e3;
|
|
9443
9538
|
}
|
|
9444
9539
|
var Arbi = class {
|
|
9445
9540
|
client = null;
|
|
@@ -9449,7 +9544,12 @@ var Arbi = class {
|
|
|
9449
9544
|
currentWorkspaceId = null;
|
|
9450
9545
|
/** Wrapped workspace keys seen in the last list/create, so selecting needs no re-fetch. */
|
|
9451
9546
|
wrappedKeys = /* @__PURE__ */ new Map();
|
|
9547
|
+
/** Workspaces whose key this server session holds (`workspaces.open`), keyed per session key. */
|
|
9548
|
+
openedWorkspaces = /* @__PURE__ */ new Map();
|
|
9549
|
+
openedForSessionKey = null;
|
|
9452
9550
|
chatCryptoContext = null;
|
|
9551
|
+
/** The chat keys I hold, opened once per set of epochs (`chatRingSignature`). */
|
|
9552
|
+
chatRings = /* @__PURE__ */ new Map();
|
|
9453
9553
|
sessionExpiredListeners = /* @__PURE__ */ new Set();
|
|
9454
9554
|
options;
|
|
9455
9555
|
constructor(options) {
|
|
@@ -9585,9 +9685,41 @@ var Arbi = class {
|
|
|
9585
9685
|
);
|
|
9586
9686
|
}
|
|
9587
9687
|
/**
|
|
9588
|
-
*
|
|
9589
|
-
*
|
|
9590
|
-
*
|
|
9688
|
+
* Make a workspace usable for requests that name it, WITHOUT changing the current workspace (on
|
|
9689
|
+
* the server or here): its key, sealed to this server session, is deposited with `/prime-key`.
|
|
9690
|
+
* Idempotent: cached per server session (a re-login rotates it), concurrent calls share one
|
|
9691
|
+
* request, and the current workspace is already open.
|
|
9692
|
+
*/
|
|
9693
|
+
openWorkspace(workspaceId) {
|
|
9694
|
+
if (workspaceId === this.currentWorkspaceId) return Promise.resolve();
|
|
9695
|
+
const lr2 = this.requireLogin();
|
|
9696
|
+
if (this.openedForSessionKey !== lr2.serverSessionKey) {
|
|
9697
|
+
this.openedWorkspaces.clear();
|
|
9698
|
+
this.openedForSessionKey = lr2.serverSessionKey;
|
|
9699
|
+
}
|
|
9700
|
+
const cached = this.openedWorkspaces.get(workspaceId);
|
|
9701
|
+
if (cached) return cached;
|
|
9702
|
+
const opening = this.sealWorkspaceKey(workspaceId).then(
|
|
9703
|
+
(sealedKey) => primeWorkspaceKey(this.requireClient(), workspaceId, sealedKey)
|
|
9704
|
+
);
|
|
9705
|
+
this.openedWorkspaces.set(workspaceId, opening);
|
|
9706
|
+
opening.catch(() => {
|
|
9707
|
+
if (this.openedWorkspaces.get(workspaceId) === opening)
|
|
9708
|
+
this.openedWorkspaces.delete(workspaceId);
|
|
9709
|
+
});
|
|
9710
|
+
return opening;
|
|
9711
|
+
}
|
|
9712
|
+
/** The workspace a call names, opened for this session; `undefined` for the current one. */
|
|
9713
|
+
async targetWorkspace(workspaceId) {
|
|
9714
|
+
if (!workspaceId || workspaceId === this.currentWorkspaceId) return void 0;
|
|
9715
|
+
await this.openWorkspace(workspaceId);
|
|
9716
|
+
return workspaceId;
|
|
9717
|
+
}
|
|
9718
|
+
/**
|
|
9719
|
+
* Make a workspace the CURRENT one: decrypt its key, open it on the server (which makes it the
|
|
9720
|
+
* session's active workspace) and record it in the session. This is navigation: only the host's
|
|
9721
|
+
* workspace switch calls it. Package code that needs another workspace calls
|
|
9722
|
+
* `workspaces.open(id)` and passes the workspace to the request instead.
|
|
9591
9723
|
*/
|
|
9592
9724
|
async selectWorkspace(workspaceId) {
|
|
9593
9725
|
const client = this.requireClient();
|
|
@@ -9628,6 +9760,7 @@ var Arbi = class {
|
|
|
9628
9760
|
this.currentWorkspaceId = null;
|
|
9629
9761
|
this.wrappedKeys.clear();
|
|
9630
9762
|
this.chatCryptoContext = null;
|
|
9763
|
+
this.chatRings.clear();
|
|
9631
9764
|
this.client?.session.clear();
|
|
9632
9765
|
for (const listener of [...this.sessionExpiredListeners]) listener();
|
|
9633
9766
|
}
|
|
@@ -9674,6 +9807,7 @@ var Arbi = class {
|
|
|
9674
9807
|
this.currentWorkspaceId = null;
|
|
9675
9808
|
this.wrappedKeys.clear();
|
|
9676
9809
|
this.chatCryptoContext = null;
|
|
9810
|
+
this.chatRings.clear();
|
|
9677
9811
|
}
|
|
9678
9812
|
// ── Accessors ─────────────────────────────────────────────────────────
|
|
9679
9813
|
/** Get the underlying ArbiClient (throws if not initialized). */
|
|
@@ -9814,6 +9948,8 @@ var Arbi = class {
|
|
|
9814
9948
|
};
|
|
9815
9949
|
// ── Account ───────────────────────────────────────────────────────────
|
|
9816
9950
|
account = {
|
|
9951
|
+
/** Which paid features (native mail, the calendar, hosting calls) this person may use, and why not. */
|
|
9952
|
+
entitlements: () => getEntitlements(this.requireClient()),
|
|
9817
9953
|
/** Send a verification code to the new address (not for SSO accounts). */
|
|
9818
9954
|
requestEmailChange: (newEmail) => requestEmailChange(this.requireClient(), newEmail),
|
|
9819
9955
|
/** Confirm the email change with the emailed code; the session and profile follow. */
|
|
@@ -9894,6 +10030,13 @@ var Arbi = class {
|
|
|
9894
10030
|
}
|
|
9895
10031
|
// ── Workspaces ────────────────────────────────────────────────────────
|
|
9896
10032
|
workspaces = {
|
|
10033
|
+
/**
|
|
10034
|
+
* Make a workspace usable for requests that name it, WITHOUT changing the current workspace
|
|
10035
|
+
* (on the server or in the host). `removeUsers` and `documents.list` open the workspace they
|
|
10036
|
+
* are given themselves; `documents.upload` with `workspaceExtId` needs it opened first.
|
|
10037
|
+
* Idempotent and cached per server session. Navigation uses `selectWorkspace`.
|
|
10038
|
+
*/
|
|
10039
|
+
open: (workspaceId) => this.openWorkspace(workspaceId),
|
|
9897
10040
|
/** Hand this server session a workspace's key (sealed to the session) without opening it. */
|
|
9898
10041
|
primeKey: (workspaceExtId, sessionSealedKey) => primeWorkspaceKey(this.requireClient(), workspaceExtId, sessionSealedKey),
|
|
9899
10042
|
list: async () => this.rememberWorkspaces(await listWorkspaces(this.requireClient())),
|
|
@@ -9961,7 +10104,12 @@ var Arbi = class {
|
|
|
9961
10104
|
workspaceExtId: params.workspaceId,
|
|
9962
10105
|
workspaceKey: await this.sealWorkspaceKey(params.workspaceId)
|
|
9963
10106
|
}),
|
|
9964
|
-
|
|
10107
|
+
/** Remove users (or agents) from the current workspace, or from `options.workspaceId`. */
|
|
10108
|
+
removeUsers: async (userIds, options) => removeWorkspaceUsers(
|
|
10109
|
+
this.requireClient(),
|
|
10110
|
+
userIds,
|
|
10111
|
+
await this.targetWorkspace(options?.workspaceId)
|
|
10112
|
+
),
|
|
9965
10113
|
setUserRole: (userIds, role) => setUserRole(this.requireClient(), userIds, role),
|
|
9966
10114
|
/**
|
|
9967
10115
|
* Ask another user to grant you workspace access. Builds the E2E-encrypted
|
|
@@ -9991,7 +10139,11 @@ var Arbi = class {
|
|
|
9991
10139
|
};
|
|
9992
10140
|
// ── Documents ─────────────────────────────────────────────────────────
|
|
9993
10141
|
documents = {
|
|
9994
|
-
|
|
10142
|
+
/** The current workspace's documents, or `options.workspaceId`'s (opened, not switched to). */
|
|
10143
|
+
list: async (options) => listDocuments(
|
|
10144
|
+
this.requireClient(),
|
|
10145
|
+
await this.targetWorkspace(options?.workspaceId)
|
|
10146
|
+
),
|
|
9995
10147
|
/**
|
|
9996
10148
|
* Async iterator that yields pages of documents sequentially.
|
|
9997
10149
|
* Use this for large workspaces to stream output as pages arrive.
|
|
@@ -10244,6 +10396,16 @@ var Arbi = class {
|
|
|
10244
10396
|
respond: (assistantMessageExtId, answer) => respondToAgent(this.requireClient(), assistantMessageExtId, answer),
|
|
10245
10397
|
/** The skills the caller can run (own + shared marketplace), metadata only. */
|
|
10246
10398
|
listSkills: (options) => listSkills(this.requireClient(), options),
|
|
10399
|
+
/**
|
|
10400
|
+
* Save a SKILL.md as the caller's skill ``slug``: private unless ``shared`` (pass
|
|
10401
|
+
* ``shared: isSharedSkill(skill)`` when changing an existing skill, so a shared one stays shared).
|
|
10402
|
+
*/
|
|
10403
|
+
uploadSkill: (slug, markdown, options) => {
|
|
10404
|
+
this.requireWorkspace();
|
|
10405
|
+
return this.recovering(
|
|
10406
|
+
() => uploadSkill(this.getAuthHeaders(), slug, markdown, options)
|
|
10407
|
+
);
|
|
10408
|
+
},
|
|
10247
10409
|
/**
|
|
10248
10410
|
* Search documents without LLM generation (retrieval only). No `docIds` searches the whole
|
|
10249
10411
|
* workspace; `searchChunks(result)` ranks the passages found.
|
|
@@ -10301,7 +10463,11 @@ var Arbi = class {
|
|
|
10301
10463
|
invite: (emails) => inviteContacts(this.requireClient(), emails),
|
|
10302
10464
|
create: (body) => this.withCalendarKeys((c2) => createContact(c2, body)),
|
|
10303
10465
|
update: (contactId, card) => this.withCalendarKeys((c2) => updateContact(c2, contactId, card)),
|
|
10466
|
+
/** Link a card-only contact to `email` (invites it, or links the account at once). */
|
|
10467
|
+
link: (contactId, email, card) => this.withCalendarKeys((c2) => linkContact(c2, contactId, email, card)),
|
|
10304
10468
|
delete: (contactId) => this.withCalendarKeys((c2) => deleteContact(c2, contactId)),
|
|
10469
|
+
/** Import one .vcf file (Pro). */
|
|
10470
|
+
import: (file) => this.withCalendarKeys((c2) => importContacts(c2, file)),
|
|
10305
10471
|
search: (q2) => this.withCalendarKeys((c2) => searchContacts(c2, q2)),
|
|
10306
10472
|
groupByStatus: groupContactsByStatus
|
|
10307
10473
|
};
|
|
@@ -10404,14 +10570,36 @@ var Arbi = class {
|
|
|
10404
10570
|
return this.chatCryptoContext;
|
|
10405
10571
|
}
|
|
10406
10572
|
/** Fetch a chat, sealing a new epoch first when it is `rotation_required`. */
|
|
10407
|
-
async readyChat(
|
|
10573
|
+
async readyChat(chat) {
|
|
10408
10574
|
const client = this.requireClient();
|
|
10409
10575
|
return ensureChatKeyCurrent(
|
|
10410
10576
|
client,
|
|
10411
|
-
await getChat(client,
|
|
10577
|
+
typeof chat === "string" ? await getChat(client, chat) : chat,
|
|
10412
10578
|
await this.requireChatCrypto()
|
|
10413
10579
|
);
|
|
10414
10580
|
}
|
|
10581
|
+
/**
|
|
10582
|
+
* The keys of `chat` I hold, opened once per set of epochs: a direct chat's pair key depends on
|
|
10583
|
+
* the members' public keys, a group's on the epochs sealed to me.
|
|
10584
|
+
*/
|
|
10585
|
+
chatRing(chat) {
|
|
10586
|
+
const sig = chat.kind === "direct" ? `d:${chat.members.map((m2) => `${m2.user.external_id}=${m2.user.encryption_public_key}`).join(",")}` : `g:${chat.key_version}:${(chat.my_keys ?? []).map((k2) => `${k2.version}=${k2.sealed_key}`).join(",")}`;
|
|
10587
|
+
const cached = this.chatRings.get(chat.external_id);
|
|
10588
|
+
if (cached && cached.sig === sig) return cached.ring;
|
|
10589
|
+
const ring = this.requireChatCrypto().then((crypto2) => openChatKeyRing(chat, crypto2));
|
|
10590
|
+
ring.catch(() => {
|
|
10591
|
+
if (this.chatRings.get(chat.external_id)?.ring === ring)
|
|
10592
|
+
this.chatRings.delete(chat.external_id);
|
|
10593
|
+
});
|
|
10594
|
+
this.chatRings.set(chat.external_id, { sig, ring });
|
|
10595
|
+
return ring;
|
|
10596
|
+
}
|
|
10597
|
+
/**
|
|
10598
|
+
* Chats: direct (a person, myself, or my own agent), group and meeting. Every message, title and
|
|
10599
|
+
* attachment is end-to-end encrypted under the chat key in this process; a caller passes and
|
|
10600
|
+
* gets plaintext and never handles keys. Operations on an open chat take the `ChatResponse`
|
|
10601
|
+
* (no refetch); the by-id forms fetch it first.
|
|
10602
|
+
*/
|
|
10415
10603
|
chats = {
|
|
10416
10604
|
/** My chats, most recently active first (raw: titles/last messages are ciphertext). */
|
|
10417
10605
|
list: (kind) => listChats(this.requireClient(), kind),
|
|
@@ -10420,6 +10608,33 @@ var Arbi = class {
|
|
|
10420
10608
|
openDirect: (peerExtId) => openDirectChat(this.requireClient(), peerExtId),
|
|
10421
10609
|
/** Create a group (epoch 1 sealed to every member). Agents are refused. */
|
|
10422
10610
|
createGroup: async (params) => createGroupChat(this.requireClient(), await this.requireChatCrypto(), params),
|
|
10611
|
+
/** Who I am in chats: my external id and the X25519 public key chat keys are sealed to. */
|
|
10612
|
+
identity: async () => {
|
|
10613
|
+
const crypto2 = await this.requireChatCrypto();
|
|
10614
|
+
return {
|
|
10615
|
+
externalId: crypto2.userExtId,
|
|
10616
|
+
publicKey: client.bytesToBase64(crypto2.encryptionKeypair.publicKey)
|
|
10617
|
+
};
|
|
10618
|
+
},
|
|
10619
|
+
/** The keys of a chat I hold (cached per set of epochs). */
|
|
10620
|
+
ring: (chat) => this.chatRing(chat),
|
|
10621
|
+
/** Make a chat postable: seal the next epoch when it is `rotation_required`. */
|
|
10622
|
+
ready: (chat) => this.readyChat(chat),
|
|
10623
|
+
/** One page of messages decrypted, oldest first; page back with `before` (the oldest id). */
|
|
10624
|
+
page: async (chat, options = {}) => {
|
|
10625
|
+
const limit = options.limit ?? CHAT_PAGE_SIZE;
|
|
10626
|
+
const raw = await listChatMessages(this.requireClient(), chat.external_id, {
|
|
10627
|
+
before: options.before,
|
|
10628
|
+
limit
|
|
10629
|
+
});
|
|
10630
|
+
const ring = await this.chatRing(chat);
|
|
10631
|
+
const messages = (await decryptChatMessages(ring, raw)).reverse();
|
|
10632
|
+
return { messages, hasMore: raw.length === limit };
|
|
10633
|
+
},
|
|
10634
|
+
/** Decrypt one message of `chat` (never throws: a failure is marked on the row). */
|
|
10635
|
+
decrypt: async (chat, message) => decryptChatMessage(await this.chatRing(chat), message),
|
|
10636
|
+
/** A group's title in plaintext; null when it has none or it does not open. */
|
|
10637
|
+
title: async (chat) => chat.title ? decryptChatTitle(await this.chatRing(chat), chat) : null,
|
|
10423
10638
|
/** A chat with its keys opened, title and newest messages decrypted (oldest first). */
|
|
10424
10639
|
load: async (chatExtId, options) => {
|
|
10425
10640
|
const chat = await this.readyChat(chatExtId);
|
|
@@ -10430,30 +10645,50 @@ var Arbi = class {
|
|
|
10430
10645
|
options
|
|
10431
10646
|
);
|
|
10432
10647
|
},
|
|
10433
|
-
/** Post plaintext to a chat (encrypted under its current epoch). */
|
|
10434
|
-
send: async (
|
|
10435
|
-
const
|
|
10436
|
-
|
|
10437
|
-
|
|
10648
|
+
/** Post plaintext to a chat (encrypted under its current epoch). Returns it decrypted. */
|
|
10649
|
+
send: async (chat, text, options) => {
|
|
10650
|
+
const ready = await this.readyChat(chat);
|
|
10651
|
+
return sendChatMessage(
|
|
10652
|
+
this.requireClient(),
|
|
10653
|
+
await this.chatRing(ready),
|
|
10654
|
+
text,
|
|
10655
|
+
options
|
|
10656
|
+
);
|
|
10438
10657
|
},
|
|
10439
|
-
rename: async (
|
|
10440
|
-
const
|
|
10441
|
-
|
|
10442
|
-
return renameChat(this.requireClient(), ring, title);
|
|
10658
|
+
rename: async (chat, title) => {
|
|
10659
|
+
const ready = await this.readyChat(chat);
|
|
10660
|
+
return renameChat(this.requireClient(), await this.chatRing(ready), title);
|
|
10443
10661
|
},
|
|
10444
|
-
|
|
10445
|
-
|
|
10446
|
-
const
|
|
10447
|
-
return addChatMembers(
|
|
10662
|
+
/** Add people; a meeting chat also needs its call key, sealed to each (`callKey`). */
|
|
10663
|
+
addMembers: async (chat, members, options) => {
|
|
10664
|
+
const ready = await this.readyChat(chat);
|
|
10665
|
+
return addChatMembers(
|
|
10666
|
+
this.requireClient(),
|
|
10667
|
+
await this.chatRing(ready),
|
|
10668
|
+
members,
|
|
10669
|
+
options
|
|
10670
|
+
);
|
|
10448
10671
|
},
|
|
10449
|
-
/**
|
|
10450
|
-
|
|
10672
|
+
/**
|
|
10673
|
+
* Remove a member (owner) or leave (own id). Removing someone seals the next epoch to the rest
|
|
10674
|
+
* straight away; when that fails, the next member to open the chat does it.
|
|
10675
|
+
*/
|
|
10676
|
+
removeMember: async (chat, userExtId) => {
|
|
10677
|
+
const chatExtId = typeof chat === "string" ? chat : chat.external_id;
|
|
10451
10678
|
await removeChatMember(this.requireClient(), chatExtId, userExtId);
|
|
10452
10679
|
const crypto2 = await this.requireChatCrypto();
|
|
10453
|
-
if (userExtId
|
|
10680
|
+
if (userExtId === crypto2.userExtId) return;
|
|
10681
|
+
try {
|
|
10682
|
+
await this.readyChat(chatExtId);
|
|
10683
|
+
} catch {
|
|
10684
|
+
}
|
|
10454
10685
|
},
|
|
10455
10686
|
markRead: (chatExtId, messageExtId) => markChatRead(this.requireClient(), chatExtId, messageExtId),
|
|
10456
|
-
deleteMessage: (chatExtId, messageExtId) => deleteChatMessage(this.requireClient(), chatExtId, messageExtId)
|
|
10687
|
+
deleteMessage: (chatExtId, messageExtId) => deleteChatMessage(this.requireClient(), chatExtId, messageExtId),
|
|
10688
|
+
/** Encrypt each file with its own key and upload the ciphertext (limits checked first). */
|
|
10689
|
+
uploadAttachments: (files) => uploadChatAttachments(this.requireClient(), files),
|
|
10690
|
+
/** Fetch, decrypt and size-check one attachment. */
|
|
10691
|
+
downloadAttachment: (file) => downloadChatAttachment(this.requireClient(), file)
|
|
10457
10692
|
};
|
|
10458
10693
|
/** Direct-chat conveniences addressed by peer (email or `usr-`/`agt-` id). */
|
|
10459
10694
|
dm = {
|
|
@@ -10660,7 +10895,7 @@ var Arbi = class {
|
|
|
10660
10895
|
sessions = {
|
|
10661
10896
|
list: () => listSessions(this.requireClient()),
|
|
10662
10897
|
/** The id this device's session is listed under in `list()`; `null` when unknown. */
|
|
10663
|
-
currentId: () =>
|
|
10898
|
+
currentId: () => client.readSessionClaims(this.client?.session.getState().accessToken)?.sessionId ?? null,
|
|
10664
10899
|
/** End one of your own sessions now (not the one this device is on: that is `logout`). */
|
|
10665
10900
|
terminate: (sessionId) => terminateSession(this.requireClient(), sessionId),
|
|
10666
10901
|
/** Sign out of every device on the server, then clear this instance. */
|
|
@@ -11882,6 +12117,7 @@ exports.ClaudeOrchestrator = ClaudeOrchestrator;
|
|
|
11882
12117
|
exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
|
|
11883
12118
|
exports.DOC_TERMINAL_STATUSES = DOC_TERMINAL_STATUSES;
|
|
11884
12119
|
exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;
|
|
12120
|
+
exports.DuplicateContactError = DuplicateContactError;
|
|
11885
12121
|
exports.ENTITY_KINDS = ENTITY_KINDS;
|
|
11886
12122
|
exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
|
|
11887
12123
|
exports.FileConfigStore = FileConfigStore;
|