@arbidocs/sdk 0.4.159 → 0.4.161
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/browser.cjs
CHANGED
|
@@ -3521,6 +3521,14 @@ var ArbiApiError = class extends ArbiError {
|
|
|
3521
3521
|
this.detail = apiErrorDetail(apiError);
|
|
3522
3522
|
}
|
|
3523
3523
|
};
|
|
3524
|
+
var DuplicateContactError = class extends ArbiApiError {
|
|
3525
|
+
contactId;
|
|
3526
|
+
constructor(message, contactId, apiError) {
|
|
3527
|
+
super(message, apiError ?? { detail: message }, 409);
|
|
3528
|
+
this.name = "DuplicateContactError";
|
|
3529
|
+
this.contactId = contactId;
|
|
3530
|
+
}
|
|
3531
|
+
};
|
|
3524
3532
|
function refusalReason(err, fallback) {
|
|
3525
3533
|
if (err instanceof ArbiApiError) return err.detail || fallback;
|
|
3526
3534
|
return apiErrorDetail(err) || fallback;
|
|
@@ -4473,8 +4481,20 @@ var SUPPORTED_EXTENSIONS = /* @__PURE__ */ new Set([
|
|
|
4473
4481
|
function sanitizeFolderPath(folderPath) {
|
|
4474
4482
|
return folderPath.replace(/[\x00-\x1f\x7f]/g, "").replace(/\\/g, "/").replace(/\/{2,}/g, "/").replace(/^\/|\/$/g, "").trim();
|
|
4475
4483
|
}
|
|
4476
|
-
async function listDocuments(arbi) {
|
|
4477
|
-
|
|
4484
|
+
async function listDocuments(arbi, workspaceExtId) {
|
|
4485
|
+
if (!workspaceExtId) {
|
|
4486
|
+
return requireData(await arbi.fetch.GET("/v1/document/list"), "Failed to fetch documents");
|
|
4487
|
+
}
|
|
4488
|
+
const docs = requireData(
|
|
4489
|
+
await arbi.fetch.GET("/v1/document/list", {
|
|
4490
|
+
params: { query: { workspace_ext_id: workspaceExtId } }
|
|
4491
|
+
}),
|
|
4492
|
+
"Failed to fetch documents"
|
|
4493
|
+
);
|
|
4494
|
+
if (docs.some((doc) => doc.workspace_ext_id !== workspaceExtId)) {
|
|
4495
|
+
throw new ArbiError(`This server cannot list workspace ${workspaceExtId} without opening it`);
|
|
4496
|
+
}
|
|
4497
|
+
return docs;
|
|
4478
4498
|
}
|
|
4479
4499
|
async function* listPaginated(arbi, options = {}) {
|
|
4480
4500
|
const {
|
|
@@ -5098,10 +5118,13 @@ async function grantTemporaryWorkspaceAccess(arbi, params) {
|
|
|
5098
5118
|
"Failed to grant temporary access"
|
|
5099
5119
|
);
|
|
5100
5120
|
}
|
|
5101
|
-
async function removeWorkspaceUsers(arbi, userIds) {
|
|
5121
|
+
async function removeWorkspaceUsers(arbi, userIds, workspaceExtId) {
|
|
5102
5122
|
requireOk(
|
|
5103
5123
|
await arbi.fetch.DELETE("/v1/workspace/users", {
|
|
5104
|
-
body: {
|
|
5124
|
+
body: {
|
|
5125
|
+
users: userIds.map((id) => ({ user_ext_id: id })),
|
|
5126
|
+
...workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}
|
|
5127
|
+
}
|
|
5105
5128
|
}),
|
|
5106
5129
|
"Failed to remove users"
|
|
5107
5130
|
);
|
|
@@ -5408,7 +5431,7 @@ async function listSkills(arbi, options) {
|
|
|
5408
5431
|
return result.skills;
|
|
5409
5432
|
}
|
|
5410
5433
|
function isSharedSkill(skill) {
|
|
5411
|
-
return skill.is_owner
|
|
5434
|
+
return (skill.is_owner ?? true) && skill.visibility === "global";
|
|
5412
5435
|
}
|
|
5413
5436
|
function uploadSkill(auth, slug, markdown, options) {
|
|
5414
5437
|
return uploadFile(auth, new Blob([markdown], { type: "text/markdown" }), "SKILL.md", {
|
|
@@ -5680,11 +5703,23 @@ __export(contacts_exports, {
|
|
|
5680
5703
|
createContact: () => createContact,
|
|
5681
5704
|
deleteContact: () => deleteContact,
|
|
5682
5705
|
groupContactsByStatus: () => groupContactsByStatus,
|
|
5706
|
+
importContacts: () => importContacts,
|
|
5683
5707
|
inviteContacts: () => inviteContacts,
|
|
5708
|
+
linkContact: () => linkContact,
|
|
5684
5709
|
listContacts: () => listContacts,
|
|
5685
5710
|
searchContacts: () => searchContacts,
|
|
5686
5711
|
updateContact: () => updateContact
|
|
5687
5712
|
});
|
|
5713
|
+
function requireContact(result, message) {
|
|
5714
|
+
const error = result.error;
|
|
5715
|
+
if (result.response?.status === 409 && error && typeof error === "object" && "contact_id" in error)
|
|
5716
|
+
throw new DuplicateContactError(
|
|
5717
|
+
apiErrorDetail(error) ?? "This person is already in your contacts",
|
|
5718
|
+
error.contact_id || null,
|
|
5719
|
+
error
|
|
5720
|
+
);
|
|
5721
|
+
return requireData(result, message);
|
|
5722
|
+
}
|
|
5688
5723
|
async function listContacts(arbi) {
|
|
5689
5724
|
return requireData(await arbi.fetch.GET("/v1/contacts/"), "Failed to fetch contacts");
|
|
5690
5725
|
}
|
|
@@ -5695,10 +5730,13 @@ async function inviteContacts(arbi, emails) {
|
|
|
5695
5730
|
);
|
|
5696
5731
|
}
|
|
5697
5732
|
async function createContact(arbi, body) {
|
|
5698
|
-
return
|
|
5733
|
+
return requireContact(
|
|
5734
|
+
await arbi.fetch.POST("/v1/contacts/", { body }),
|
|
5735
|
+
"Failed to create contact"
|
|
5736
|
+
);
|
|
5699
5737
|
}
|
|
5700
5738
|
async function updateContact(arbi, contactId, card) {
|
|
5701
|
-
return
|
|
5739
|
+
return requireContact(
|
|
5702
5740
|
await arbi.fetch.PATCH("/v1/contacts/{cnt_id}", {
|
|
5703
5741
|
params: { path: { cnt_id: contactId } },
|
|
5704
5742
|
body: { card, invite: false }
|
|
@@ -5706,12 +5744,32 @@ async function updateContact(arbi, contactId, card) {
|
|
|
5706
5744
|
"Failed to update contact"
|
|
5707
5745
|
);
|
|
5708
5746
|
}
|
|
5747
|
+
async function linkContact(arbi, contactId, email, card) {
|
|
5748
|
+
return requireContact(
|
|
5749
|
+
await arbi.fetch.PATCH("/v1/contacts/{cnt_id}", {
|
|
5750
|
+
params: { path: { cnt_id: contactId } },
|
|
5751
|
+
body: { card, email, invite: true }
|
|
5752
|
+
}),
|
|
5753
|
+
"Failed to link contact"
|
|
5754
|
+
);
|
|
5755
|
+
}
|
|
5709
5756
|
async function deleteContact(arbi, contactId) {
|
|
5710
5757
|
requireOk(
|
|
5711
5758
|
await arbi.fetch.DELETE("/v1/contacts/{cnt_id}", { params: { path: { cnt_id: contactId } } }),
|
|
5712
5759
|
"Failed to delete contact"
|
|
5713
5760
|
);
|
|
5714
5761
|
}
|
|
5762
|
+
async function importContacts(arbi, file) {
|
|
5763
|
+
const form = new FormData();
|
|
5764
|
+
form.append("file", file);
|
|
5765
|
+
return requireData(
|
|
5766
|
+
await arbi.fetch.POST("/v1/contacts/import", {
|
|
5767
|
+
body: { file: "" },
|
|
5768
|
+
bodySerializer: () => form
|
|
5769
|
+
}),
|
|
5770
|
+
"Failed to import contacts"
|
|
5771
|
+
);
|
|
5772
|
+
}
|
|
5715
5773
|
async function searchContacts(arbi, q2) {
|
|
5716
5774
|
return requireData(
|
|
5717
5775
|
await arbi.fetch.GET("/v1/contacts/search", { params: { query: { q: q2 } } }),
|
|
@@ -5783,8 +5841,11 @@ var chats_exports = {};
|
|
|
5783
5841
|
__export(chats_exports, {
|
|
5784
5842
|
CHAT_ATTACHMENT_MAX_BYTES: () => CHAT_ATTACHMENT_MAX_BYTES,
|
|
5785
5843
|
CHAT_ATTACHMENT_MAX_FILES: () => CHAT_ATTACHMENT_MAX_FILES,
|
|
5844
|
+
CHAT_PAGE_SIZE: () => CHAT_PAGE_SIZE,
|
|
5786
5845
|
DECRYPTION_FAILED: () => DECRYPTION_FAILED,
|
|
5846
|
+
ENCRYPTED_PREVIEW: () => ENCRYPTED_PREVIEW,
|
|
5787
5847
|
addChatMembers: () => addChatMembers,
|
|
5848
|
+
chatMessagePreview: () => chatMessagePreview,
|
|
5788
5849
|
chatMessageTombstone: () => chatMessageTombstone,
|
|
5789
5850
|
checkChatAttachmentLimits: () => checkChatAttachmentLimits,
|
|
5790
5851
|
createChatCryptoContext: () => createChatCryptoContext,
|
|
@@ -5801,6 +5862,7 @@ __export(chats_exports, {
|
|
|
5801
5862
|
getChat: () => getChat,
|
|
5802
5863
|
hasRead: () => hasRead,
|
|
5803
5864
|
isAgentExtId: () => isAgentExtId,
|
|
5865
|
+
isTranscriptMessage: () => isTranscriptMessage,
|
|
5804
5866
|
listChatMessages: () => listChatMessages,
|
|
5805
5867
|
listChats: () => listChats,
|
|
5806
5868
|
loadDecryptedChat: () => loadDecryptedChat,
|
|
@@ -5808,6 +5870,8 @@ __export(chats_exports, {
|
|
|
5808
5870
|
openChatKeyRing: () => openChatKeyRing,
|
|
5809
5871
|
openDirectChat: () => openDirectChat,
|
|
5810
5872
|
parseChatAttachmentManifest: () => parseChatAttachmentManifest,
|
|
5873
|
+
parseTranscriptContent: () => parseTranscriptContent,
|
|
5874
|
+
readByOthers: () => readByOthers,
|
|
5811
5875
|
removeChatMember: () => removeChatMember,
|
|
5812
5876
|
renameChat: () => renameChat,
|
|
5813
5877
|
resolveRecipient: () => resolveRecipient,
|
|
@@ -6088,6 +6152,39 @@ function chatMessageTombstone(message) {
|
|
|
6088
6152
|
delete row.attachmentsError;
|
|
6089
6153
|
return row;
|
|
6090
6154
|
}
|
|
6155
|
+
function isTranscriptMessage(message) {
|
|
6156
|
+
return message.kind === "transcript";
|
|
6157
|
+
}
|
|
6158
|
+
function parseTranscriptContent(content) {
|
|
6159
|
+
if (!content) return null;
|
|
6160
|
+
try {
|
|
6161
|
+
const parsed = JSON.parse(content);
|
|
6162
|
+
if (!parsed || typeof parsed !== "object") return null;
|
|
6163
|
+
const p2 = parsed;
|
|
6164
|
+
if (typeof p2.text !== "string") return null;
|
|
6165
|
+
return {
|
|
6166
|
+
text: p2.text,
|
|
6167
|
+
speaker_identity: typeof p2.speaker_identity === "string" ? p2.speaker_identity : "",
|
|
6168
|
+
speaker_name: typeof p2.speaker_name === "string" ? p2.speaker_name : "",
|
|
6169
|
+
started_at: typeof p2.started_at === "string" ? p2.started_at : null
|
|
6170
|
+
};
|
|
6171
|
+
} catch {
|
|
6172
|
+
return null;
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
var ENCRYPTED_PREVIEW = "[Encrypted]";
|
|
6176
|
+
function chatMessagePreview(message) {
|
|
6177
|
+
if (message.deleted) return null;
|
|
6178
|
+
if (message.kind === "call") return "Call";
|
|
6179
|
+
if (message.kind === "recording") return "Recording";
|
|
6180
|
+
if (message.decryptFailed) return ENCRYPTED_PREVIEW;
|
|
6181
|
+
const transcript = isTranscriptMessage(message) ? parseTranscriptContent(message.content) : null;
|
|
6182
|
+
if (transcript) {
|
|
6183
|
+
return `Transcript \xB7 ${transcript.speaker_name ? `${transcript.speaker_name}: ` : ""}${transcript.text}`;
|
|
6184
|
+
}
|
|
6185
|
+
if (message.content) return message.content;
|
|
6186
|
+
return message.attachmentFiles?.length ? `\u{1F4CE} ${message.attachmentFiles.map((f2) => f2.name).join(", ")}` : null;
|
|
6187
|
+
}
|
|
6091
6188
|
async function decryptChatMessage(ring, message) {
|
|
6092
6189
|
if (message.deleted) return chatMessageTombstone(message);
|
|
6093
6190
|
const key = ring.keys.get(message.key_version);
|
|
@@ -6188,12 +6285,18 @@ async function renameChat(arbi, ring, title) {
|
|
|
6188
6285
|
"Failed to rename chat"
|
|
6189
6286
|
);
|
|
6190
6287
|
}
|
|
6191
|
-
async function addChatMembers(arbi, ring, members) {
|
|
6288
|
+
async function addChatMembers(arbi, ring, members, options = {}) {
|
|
6192
6289
|
if (ring.kind === "direct") {
|
|
6193
6290
|
throw new Error("A direct chat cannot gain members: create a group instead");
|
|
6194
6291
|
}
|
|
6195
6292
|
if (members.some((m2) => isAgentExtId(m2.external_id))) {
|
|
6196
|
-
throw new Error(
|
|
6293
|
+
throw new Error(
|
|
6294
|
+
ring.kind === "meeting" ? "Personal agents cannot join a meeting chat" : "Personal agents cannot join a group chat"
|
|
6295
|
+
);
|
|
6296
|
+
}
|
|
6297
|
+
const callKey = options.callKey ?? null;
|
|
6298
|
+
if (ring.kind === "meeting" && !callKey) {
|
|
6299
|
+
throw new Error("You do not hold this meeting\u2019s call key");
|
|
6197
6300
|
}
|
|
6198
6301
|
const key = keyFor(ring, ring.currentVersion);
|
|
6199
6302
|
return requireData(
|
|
@@ -6203,7 +6306,8 @@ async function addChatMembers(arbi, ring, members) {
|
|
|
6203
6306
|
members: await Promise.all(
|
|
6204
6307
|
members.map(async (m2) => ({
|
|
6205
6308
|
user_ext_id: m2.external_id,
|
|
6206
|
-
sealed_key: await client.sealChatKey(key, m2.encryption_public_key)
|
|
6309
|
+
sealed_key: await client.sealChatKey(key, m2.encryption_public_key),
|
|
6310
|
+
...callKey ? { call_sealed_key: await client.sealCallKey(callKey, m2.encryption_public_key) } : {}
|
|
6207
6311
|
}))
|
|
6208
6312
|
)
|
|
6209
6313
|
}
|
|
@@ -6256,6 +6360,7 @@ async function ensureChatKeyCurrent(arbi, chat, crypto2) {
|
|
|
6256
6360
|
throw err;
|
|
6257
6361
|
}
|
|
6258
6362
|
}
|
|
6363
|
+
var CHAT_PAGE_SIZE = 50;
|
|
6259
6364
|
async function listChatMessages(arbi, chatExtId, options) {
|
|
6260
6365
|
return requireData(
|
|
6261
6366
|
await arbi.fetch.GET("/v1/chats/{chat_ext_id}/messages", {
|
|
@@ -6318,6 +6423,10 @@ function hasRead(member, message) {
|
|
|
6318
6423
|
if (!member?.last_read_at) return false;
|
|
6319
6424
|
return Date.parse(member.last_read_at) >= Date.parse(message.created_at);
|
|
6320
6425
|
}
|
|
6426
|
+
function readByOthers(chat, myExtId, message) {
|
|
6427
|
+
const others = chat.members.filter((m2) => m2.user.external_id !== myExtId);
|
|
6428
|
+
return others.every((m2) => hasRead(m2, message));
|
|
6429
|
+
}
|
|
6321
6430
|
async function resolveRecipient(arbi, ref) {
|
|
6322
6431
|
const isEmail = ref.includes("@");
|
|
6323
6432
|
const matchKey = isEmail ? "email" : "external_id";
|
|
@@ -6859,7 +6968,6 @@ async function getFileContent(auth, fileId) {
|
|
|
6859
6968
|
// src/operations/sessions.ts
|
|
6860
6969
|
var sessions_exports = {};
|
|
6861
6970
|
__export(sessions_exports, {
|
|
6862
|
-
currentSessionId: () => currentSessionId,
|
|
6863
6971
|
listSessions: () => listSessions,
|
|
6864
6972
|
logoutAllSessions: () => logoutAllSessions,
|
|
6865
6973
|
terminateSession: () => terminateSession
|
|
@@ -6882,16 +6990,6 @@ async function logoutAllSessions(arbi) {
|
|
|
6882
6990
|
"Failed to sign out of all sessions"
|
|
6883
6991
|
);
|
|
6884
6992
|
}
|
|
6885
|
-
function currentSessionId(accessToken) {
|
|
6886
|
-
const payload = accessToken?.split(".")[1];
|
|
6887
|
-
if (!payload) return null;
|
|
6888
|
-
try {
|
|
6889
|
-
const claims = JSON.parse(atob(payload.replace(/-/g, "+").replace(/_/g, "/")));
|
|
6890
|
-
return typeof claims.sk === "string" ? claims.sk.slice(0, 12) : null;
|
|
6891
|
-
} catch {
|
|
6892
|
-
return null;
|
|
6893
|
-
}
|
|
6894
|
-
}
|
|
6895
6993
|
|
|
6896
6994
|
// src/operations/profile.ts
|
|
6897
6995
|
var profile_exports = {};
|
|
@@ -6924,9 +7022,13 @@ async function topUpFirmPool(arbi, aiAddons) {
|
|
|
6924
7022
|
var account_exports = {};
|
|
6925
7023
|
__export(account_exports, {
|
|
6926
7024
|
confirmEmailChange: () => confirmEmailChange,
|
|
7025
|
+
getEntitlements: () => getEntitlements,
|
|
6927
7026
|
requestDeletion: () => requestDeletion,
|
|
6928
7027
|
requestEmailChange: () => requestEmailChange
|
|
6929
7028
|
});
|
|
7029
|
+
async function getEntitlements(arbi) {
|
|
7030
|
+
return requireData(await arbi.fetch.GET("/v1/user/entitlements"), "Failed to load entitlements");
|
|
7031
|
+
}
|
|
6930
7032
|
async function requestEmailChange(arbi, newEmail) {
|
|
6931
7033
|
requireOk(
|
|
6932
7034
|
await arbi.fetch.POST("/v1/user/request-email-change", { body: { new_email: newEmail } }),
|
|
@@ -8833,15 +8935,8 @@ async function cancelPublicBooking(baseUrl, slug, token) {
|
|
|
8833
8935
|
|
|
8834
8936
|
// src/arbi.ts
|
|
8835
8937
|
function tokenExpiresWithin(token, seconds) {
|
|
8836
|
-
const
|
|
8837
|
-
|
|
8838
|
-
try {
|
|
8839
|
-
const json2 = atob(payload.replace(/-/g, "+").replace(/_/g, "/"));
|
|
8840
|
-
const { exp } = JSON.parse(json2);
|
|
8841
|
-
return typeof exp === "number" && exp * 1e3 - Date.now() < seconds * 1e3;
|
|
8842
|
-
} catch {
|
|
8843
|
-
return false;
|
|
8844
|
-
}
|
|
8938
|
+
const expiresAt = client.readSessionClaims(token)?.expiresAt;
|
|
8939
|
+
return expiresAt != null && expiresAt - Date.now() < seconds * 1e3;
|
|
8845
8940
|
}
|
|
8846
8941
|
var Arbi = class {
|
|
8847
8942
|
client = null;
|
|
@@ -8851,7 +8946,12 @@ var Arbi = class {
|
|
|
8851
8946
|
currentWorkspaceId = null;
|
|
8852
8947
|
/** Wrapped workspace keys seen in the last list/create, so selecting needs no re-fetch. */
|
|
8853
8948
|
wrappedKeys = /* @__PURE__ */ new Map();
|
|
8949
|
+
/** Workspaces whose key this server session holds (`workspaces.open`), keyed per session key. */
|
|
8950
|
+
openedWorkspaces = /* @__PURE__ */ new Map();
|
|
8951
|
+
openedForSessionKey = null;
|
|
8854
8952
|
chatCryptoContext = null;
|
|
8953
|
+
/** The chat keys I hold, opened once per set of epochs (`chatRingSignature`). */
|
|
8954
|
+
chatRings = /* @__PURE__ */ new Map();
|
|
8855
8955
|
sessionExpiredListeners = /* @__PURE__ */ new Set();
|
|
8856
8956
|
options;
|
|
8857
8957
|
constructor(options) {
|
|
@@ -8987,9 +9087,41 @@ var Arbi = class {
|
|
|
8987
9087
|
);
|
|
8988
9088
|
}
|
|
8989
9089
|
/**
|
|
8990
|
-
*
|
|
8991
|
-
*
|
|
8992
|
-
*
|
|
9090
|
+
* Make a workspace usable for requests that name it, WITHOUT changing the current workspace (on
|
|
9091
|
+
* the server or here): its key, sealed to this server session, is deposited with `/prime-key`.
|
|
9092
|
+
* Idempotent: cached per server session (a re-login rotates it), concurrent calls share one
|
|
9093
|
+
* request, and the current workspace is already open.
|
|
9094
|
+
*/
|
|
9095
|
+
openWorkspace(workspaceId) {
|
|
9096
|
+
if (workspaceId === this.currentWorkspaceId) return Promise.resolve();
|
|
9097
|
+
const lr2 = this.requireLogin();
|
|
9098
|
+
if (this.openedForSessionKey !== lr2.serverSessionKey) {
|
|
9099
|
+
this.openedWorkspaces.clear();
|
|
9100
|
+
this.openedForSessionKey = lr2.serverSessionKey;
|
|
9101
|
+
}
|
|
9102
|
+
const cached = this.openedWorkspaces.get(workspaceId);
|
|
9103
|
+
if (cached) return cached;
|
|
9104
|
+
const opening = this.sealWorkspaceKey(workspaceId).then(
|
|
9105
|
+
(sealedKey) => primeWorkspaceKey(this.requireClient(), workspaceId, sealedKey)
|
|
9106
|
+
);
|
|
9107
|
+
this.openedWorkspaces.set(workspaceId, opening);
|
|
9108
|
+
opening.catch(() => {
|
|
9109
|
+
if (this.openedWorkspaces.get(workspaceId) === opening)
|
|
9110
|
+
this.openedWorkspaces.delete(workspaceId);
|
|
9111
|
+
});
|
|
9112
|
+
return opening;
|
|
9113
|
+
}
|
|
9114
|
+
/** The workspace a call names, opened for this session; `undefined` for the current one. */
|
|
9115
|
+
async targetWorkspace(workspaceId) {
|
|
9116
|
+
if (!workspaceId || workspaceId === this.currentWorkspaceId) return void 0;
|
|
9117
|
+
await this.openWorkspace(workspaceId);
|
|
9118
|
+
return workspaceId;
|
|
9119
|
+
}
|
|
9120
|
+
/**
|
|
9121
|
+
* Make a workspace the CURRENT one: decrypt its key, open it on the server (which makes it the
|
|
9122
|
+
* session's active workspace) and record it in the session. This is navigation: only the host's
|
|
9123
|
+
* workspace switch calls it. Package code that needs another workspace calls
|
|
9124
|
+
* `workspaces.open(id)` and passes the workspace to the request instead.
|
|
8993
9125
|
*/
|
|
8994
9126
|
async selectWorkspace(workspaceId) {
|
|
8995
9127
|
const client = this.requireClient();
|
|
@@ -9030,6 +9162,7 @@ var Arbi = class {
|
|
|
9030
9162
|
this.currentWorkspaceId = null;
|
|
9031
9163
|
this.wrappedKeys.clear();
|
|
9032
9164
|
this.chatCryptoContext = null;
|
|
9165
|
+
this.chatRings.clear();
|
|
9033
9166
|
this.client?.session.clear();
|
|
9034
9167
|
for (const listener of [...this.sessionExpiredListeners]) listener();
|
|
9035
9168
|
}
|
|
@@ -9076,6 +9209,7 @@ var Arbi = class {
|
|
|
9076
9209
|
this.currentWorkspaceId = null;
|
|
9077
9210
|
this.wrappedKeys.clear();
|
|
9078
9211
|
this.chatCryptoContext = null;
|
|
9212
|
+
this.chatRings.clear();
|
|
9079
9213
|
}
|
|
9080
9214
|
// ── Accessors ─────────────────────────────────────────────────────────
|
|
9081
9215
|
/** Get the underlying ArbiClient (throws if not initialized). */
|
|
@@ -9216,6 +9350,8 @@ var Arbi = class {
|
|
|
9216
9350
|
};
|
|
9217
9351
|
// ── Account ───────────────────────────────────────────────────────────
|
|
9218
9352
|
account = {
|
|
9353
|
+
/** Which paid features (native mail, the calendar, hosting calls) this person may use, and why not. */
|
|
9354
|
+
entitlements: () => getEntitlements(this.requireClient()),
|
|
9219
9355
|
/** Send a verification code to the new address (not for SSO accounts). */
|
|
9220
9356
|
requestEmailChange: (newEmail) => requestEmailChange(this.requireClient(), newEmail),
|
|
9221
9357
|
/** Confirm the email change with the emailed code; the session and profile follow. */
|
|
@@ -9296,6 +9432,13 @@ var Arbi = class {
|
|
|
9296
9432
|
}
|
|
9297
9433
|
// ── Workspaces ────────────────────────────────────────────────────────
|
|
9298
9434
|
workspaces = {
|
|
9435
|
+
/**
|
|
9436
|
+
* Make a workspace usable for requests that name it, WITHOUT changing the current workspace
|
|
9437
|
+
* (on the server or in the host). `removeUsers` and `documents.list` open the workspace they
|
|
9438
|
+
* are given themselves; `documents.upload` with `workspaceExtId` needs it opened first.
|
|
9439
|
+
* Idempotent and cached per server session. Navigation uses `selectWorkspace`.
|
|
9440
|
+
*/
|
|
9441
|
+
open: (workspaceId) => this.openWorkspace(workspaceId),
|
|
9299
9442
|
/** Hand this server session a workspace's key (sealed to the session) without opening it. */
|
|
9300
9443
|
primeKey: (workspaceExtId, sessionSealedKey) => primeWorkspaceKey(this.requireClient(), workspaceExtId, sessionSealedKey),
|
|
9301
9444
|
list: async () => this.rememberWorkspaces(await listWorkspaces(this.requireClient())),
|
|
@@ -9363,7 +9506,12 @@ var Arbi = class {
|
|
|
9363
9506
|
workspaceExtId: params.workspaceId,
|
|
9364
9507
|
workspaceKey: await this.sealWorkspaceKey(params.workspaceId)
|
|
9365
9508
|
}),
|
|
9366
|
-
|
|
9509
|
+
/** Remove users (or agents) from the current workspace, or from `options.workspaceId`. */
|
|
9510
|
+
removeUsers: async (userIds, options) => removeWorkspaceUsers(
|
|
9511
|
+
this.requireClient(),
|
|
9512
|
+
userIds,
|
|
9513
|
+
await this.targetWorkspace(options?.workspaceId)
|
|
9514
|
+
),
|
|
9367
9515
|
setUserRole: (userIds, role) => setUserRole(this.requireClient(), userIds, role),
|
|
9368
9516
|
/**
|
|
9369
9517
|
* Ask another user to grant you workspace access. Builds the E2E-encrypted
|
|
@@ -9393,7 +9541,11 @@ var Arbi = class {
|
|
|
9393
9541
|
};
|
|
9394
9542
|
// ── Documents ─────────────────────────────────────────────────────────
|
|
9395
9543
|
documents = {
|
|
9396
|
-
|
|
9544
|
+
/** The current workspace's documents, or `options.workspaceId`'s (opened, not switched to). */
|
|
9545
|
+
list: async (options) => listDocuments(
|
|
9546
|
+
this.requireClient(),
|
|
9547
|
+
await this.targetWorkspace(options?.workspaceId)
|
|
9548
|
+
),
|
|
9397
9549
|
/**
|
|
9398
9550
|
* Async iterator that yields pages of documents sequentially.
|
|
9399
9551
|
* Use this for large workspaces to stream output as pages arrive.
|
|
@@ -9646,6 +9798,16 @@ var Arbi = class {
|
|
|
9646
9798
|
respond: (assistantMessageExtId, answer) => respondToAgent(this.requireClient(), assistantMessageExtId, answer),
|
|
9647
9799
|
/** The skills the caller can run (own + shared marketplace), metadata only. */
|
|
9648
9800
|
listSkills: (options) => listSkills(this.requireClient(), options),
|
|
9801
|
+
/**
|
|
9802
|
+
* Save a SKILL.md as the caller's skill ``slug``: private unless ``shared`` (pass
|
|
9803
|
+
* ``shared: isSharedSkill(skill)`` when changing an existing skill, so a shared one stays shared).
|
|
9804
|
+
*/
|
|
9805
|
+
uploadSkill: (slug, markdown, options) => {
|
|
9806
|
+
this.requireWorkspace();
|
|
9807
|
+
return this.recovering(
|
|
9808
|
+
() => uploadSkill(this.getAuthHeaders(), slug, markdown, options)
|
|
9809
|
+
);
|
|
9810
|
+
},
|
|
9649
9811
|
/**
|
|
9650
9812
|
* Search documents without LLM generation (retrieval only). No `docIds` searches the whole
|
|
9651
9813
|
* workspace; `searchChunks(result)` ranks the passages found.
|
|
@@ -9703,7 +9865,11 @@ var Arbi = class {
|
|
|
9703
9865
|
invite: (emails) => inviteContacts(this.requireClient(), emails),
|
|
9704
9866
|
create: (body) => this.withCalendarKeys((c2) => createContact(c2, body)),
|
|
9705
9867
|
update: (contactId, card) => this.withCalendarKeys((c2) => updateContact(c2, contactId, card)),
|
|
9868
|
+
/** Link a card-only contact to `email` (invites it, or links the account at once). */
|
|
9869
|
+
link: (contactId, email, card) => this.withCalendarKeys((c2) => linkContact(c2, contactId, email, card)),
|
|
9706
9870
|
delete: (contactId) => this.withCalendarKeys((c2) => deleteContact(c2, contactId)),
|
|
9871
|
+
/** Import one .vcf file (Pro). */
|
|
9872
|
+
import: (file) => this.withCalendarKeys((c2) => importContacts(c2, file)),
|
|
9707
9873
|
search: (q2) => this.withCalendarKeys((c2) => searchContacts(c2, q2)),
|
|
9708
9874
|
groupByStatus: groupContactsByStatus
|
|
9709
9875
|
};
|
|
@@ -9806,14 +9972,36 @@ var Arbi = class {
|
|
|
9806
9972
|
return this.chatCryptoContext;
|
|
9807
9973
|
}
|
|
9808
9974
|
/** Fetch a chat, sealing a new epoch first when it is `rotation_required`. */
|
|
9809
|
-
async readyChat(
|
|
9975
|
+
async readyChat(chat) {
|
|
9810
9976
|
const client = this.requireClient();
|
|
9811
9977
|
return ensureChatKeyCurrent(
|
|
9812
9978
|
client,
|
|
9813
|
-
await getChat(client,
|
|
9979
|
+
typeof chat === "string" ? await getChat(client, chat) : chat,
|
|
9814
9980
|
await this.requireChatCrypto()
|
|
9815
9981
|
);
|
|
9816
9982
|
}
|
|
9983
|
+
/**
|
|
9984
|
+
* The keys of `chat` I hold, opened once per set of epochs: a direct chat's pair key depends on
|
|
9985
|
+
* the members' public keys, a group's on the epochs sealed to me.
|
|
9986
|
+
*/
|
|
9987
|
+
chatRing(chat) {
|
|
9988
|
+
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(",")}`;
|
|
9989
|
+
const cached = this.chatRings.get(chat.external_id);
|
|
9990
|
+
if (cached && cached.sig === sig) return cached.ring;
|
|
9991
|
+
const ring = this.requireChatCrypto().then((crypto2) => openChatKeyRing(chat, crypto2));
|
|
9992
|
+
ring.catch(() => {
|
|
9993
|
+
if (this.chatRings.get(chat.external_id)?.ring === ring)
|
|
9994
|
+
this.chatRings.delete(chat.external_id);
|
|
9995
|
+
});
|
|
9996
|
+
this.chatRings.set(chat.external_id, { sig, ring });
|
|
9997
|
+
return ring;
|
|
9998
|
+
}
|
|
9999
|
+
/**
|
|
10000
|
+
* Chats: direct (a person, myself, or my own agent), group and meeting. Every message, title and
|
|
10001
|
+
* attachment is end-to-end encrypted under the chat key in this process; a caller passes and
|
|
10002
|
+
* gets plaintext and never handles keys. Operations on an open chat take the `ChatResponse`
|
|
10003
|
+
* (no refetch); the by-id forms fetch it first.
|
|
10004
|
+
*/
|
|
9817
10005
|
chats = {
|
|
9818
10006
|
/** My chats, most recently active first (raw: titles/last messages are ciphertext). */
|
|
9819
10007
|
list: (kind) => listChats(this.requireClient(), kind),
|
|
@@ -9822,6 +10010,33 @@ var Arbi = class {
|
|
|
9822
10010
|
openDirect: (peerExtId) => openDirectChat(this.requireClient(), peerExtId),
|
|
9823
10011
|
/** Create a group (epoch 1 sealed to every member). Agents are refused. */
|
|
9824
10012
|
createGroup: async (params) => createGroupChat(this.requireClient(), await this.requireChatCrypto(), params),
|
|
10013
|
+
/** Who I am in chats: my external id and the X25519 public key chat keys are sealed to. */
|
|
10014
|
+
identity: async () => {
|
|
10015
|
+
const crypto2 = await this.requireChatCrypto();
|
|
10016
|
+
return {
|
|
10017
|
+
externalId: crypto2.userExtId,
|
|
10018
|
+
publicKey: client.bytesToBase64(crypto2.encryptionKeypair.publicKey)
|
|
10019
|
+
};
|
|
10020
|
+
},
|
|
10021
|
+
/** The keys of a chat I hold (cached per set of epochs). */
|
|
10022
|
+
ring: (chat) => this.chatRing(chat),
|
|
10023
|
+
/** Make a chat postable: seal the next epoch when it is `rotation_required`. */
|
|
10024
|
+
ready: (chat) => this.readyChat(chat),
|
|
10025
|
+
/** One page of messages decrypted, oldest first; page back with `before` (the oldest id). */
|
|
10026
|
+
page: async (chat, options = {}) => {
|
|
10027
|
+
const limit = options.limit ?? CHAT_PAGE_SIZE;
|
|
10028
|
+
const raw = await listChatMessages(this.requireClient(), chat.external_id, {
|
|
10029
|
+
before: options.before,
|
|
10030
|
+
limit
|
|
10031
|
+
});
|
|
10032
|
+
const ring = await this.chatRing(chat);
|
|
10033
|
+
const messages = (await decryptChatMessages(ring, raw)).reverse();
|
|
10034
|
+
return { messages, hasMore: raw.length === limit };
|
|
10035
|
+
},
|
|
10036
|
+
/** Decrypt one message of `chat` (never throws: a failure is marked on the row). */
|
|
10037
|
+
decrypt: async (chat, message) => decryptChatMessage(await this.chatRing(chat), message),
|
|
10038
|
+
/** A group's title in plaintext; null when it has none or it does not open. */
|
|
10039
|
+
title: async (chat) => chat.title ? decryptChatTitle(await this.chatRing(chat), chat) : null,
|
|
9825
10040
|
/** A chat with its keys opened, title and newest messages decrypted (oldest first). */
|
|
9826
10041
|
load: async (chatExtId, options) => {
|
|
9827
10042
|
const chat = await this.readyChat(chatExtId);
|
|
@@ -9832,30 +10047,50 @@ var Arbi = class {
|
|
|
9832
10047
|
options
|
|
9833
10048
|
);
|
|
9834
10049
|
},
|
|
9835
|
-
/** Post plaintext to a chat (encrypted under its current epoch). */
|
|
9836
|
-
send: async (
|
|
9837
|
-
const
|
|
9838
|
-
|
|
9839
|
-
|
|
10050
|
+
/** Post plaintext to a chat (encrypted under its current epoch). Returns it decrypted. */
|
|
10051
|
+
send: async (chat, text, options) => {
|
|
10052
|
+
const ready = await this.readyChat(chat);
|
|
10053
|
+
return sendChatMessage(
|
|
10054
|
+
this.requireClient(),
|
|
10055
|
+
await this.chatRing(ready),
|
|
10056
|
+
text,
|
|
10057
|
+
options
|
|
10058
|
+
);
|
|
9840
10059
|
},
|
|
9841
|
-
rename: async (
|
|
9842
|
-
const
|
|
9843
|
-
|
|
9844
|
-
return renameChat(this.requireClient(), ring, title);
|
|
10060
|
+
rename: async (chat, title) => {
|
|
10061
|
+
const ready = await this.readyChat(chat);
|
|
10062
|
+
return renameChat(this.requireClient(), await this.chatRing(ready), title);
|
|
9845
10063
|
},
|
|
9846
|
-
|
|
9847
|
-
|
|
9848
|
-
const
|
|
9849
|
-
return addChatMembers(
|
|
10064
|
+
/** Add people; a meeting chat also needs its call key, sealed to each (`callKey`). */
|
|
10065
|
+
addMembers: async (chat, members, options) => {
|
|
10066
|
+
const ready = await this.readyChat(chat);
|
|
10067
|
+
return addChatMembers(
|
|
10068
|
+
this.requireClient(),
|
|
10069
|
+
await this.chatRing(ready),
|
|
10070
|
+
members,
|
|
10071
|
+
options
|
|
10072
|
+
);
|
|
9850
10073
|
},
|
|
9851
|
-
/**
|
|
9852
|
-
|
|
10074
|
+
/**
|
|
10075
|
+
* Remove a member (owner) or leave (own id). Removing someone seals the next epoch to the rest
|
|
10076
|
+
* straight away; when that fails, the next member to open the chat does it.
|
|
10077
|
+
*/
|
|
10078
|
+
removeMember: async (chat, userExtId) => {
|
|
10079
|
+
const chatExtId = typeof chat === "string" ? chat : chat.external_id;
|
|
9853
10080
|
await removeChatMember(this.requireClient(), chatExtId, userExtId);
|
|
9854
10081
|
const crypto2 = await this.requireChatCrypto();
|
|
9855
|
-
if (userExtId
|
|
10082
|
+
if (userExtId === crypto2.userExtId) return;
|
|
10083
|
+
try {
|
|
10084
|
+
await this.readyChat(chatExtId);
|
|
10085
|
+
} catch {
|
|
10086
|
+
}
|
|
9856
10087
|
},
|
|
9857
10088
|
markRead: (chatExtId, messageExtId) => markChatRead(this.requireClient(), chatExtId, messageExtId),
|
|
9858
|
-
deleteMessage: (chatExtId, messageExtId) => deleteChatMessage(this.requireClient(), chatExtId, messageExtId)
|
|
10089
|
+
deleteMessage: (chatExtId, messageExtId) => deleteChatMessage(this.requireClient(), chatExtId, messageExtId),
|
|
10090
|
+
/** Encrypt each file with its own key and upload the ciphertext (limits checked first). */
|
|
10091
|
+
uploadAttachments: (files) => uploadChatAttachments(this.requireClient(), files),
|
|
10092
|
+
/** Fetch, decrypt and size-check one attachment. */
|
|
10093
|
+
downloadAttachment: (file) => downloadChatAttachment(this.requireClient(), file)
|
|
9859
10094
|
};
|
|
9860
10095
|
/** Direct-chat conveniences addressed by peer (email or `usr-`/`agt-` id). */
|
|
9861
10096
|
dm = {
|
|
@@ -10062,7 +10297,7 @@ var Arbi = class {
|
|
|
10062
10297
|
sessions = {
|
|
10063
10298
|
list: () => listSessions(this.requireClient()),
|
|
10064
10299
|
/** The id this device's session is listed under in `list()`; `null` when unknown. */
|
|
10065
|
-
currentId: () =>
|
|
10300
|
+
currentId: () => client.readSessionClaims(this.client?.session.getState().accessToken)?.sessionId ?? null,
|
|
10066
10301
|
/** End one of your own sessions now (not the one this device is on: that is `logout`). */
|
|
10067
10302
|
terminate: (sessionId) => terminateSession(this.requireClient(), sessionId),
|
|
10068
10303
|
/** Sign out of every device on the server, then clear this instance. */
|
|
@@ -10208,6 +10443,7 @@ exports.ArbiApiError = ArbiApiError;
|
|
|
10208
10443
|
exports.ArbiError = ArbiError;
|
|
10209
10444
|
exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
|
|
10210
10445
|
exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;
|
|
10446
|
+
exports.DuplicateContactError = DuplicateContactError;
|
|
10211
10447
|
exports.ENTITY_KINDS = ENTITY_KINDS;
|
|
10212
10448
|
exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
|
|
10213
10449
|
exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
|
|
@@ -10279,6 +10515,7 @@ exports.isLabelTag = isLabelTag;
|
|
|
10279
10515
|
exports.isMailboxSyncVendor = isMailboxSyncVendor;
|
|
10280
10516
|
exports.isPresenceTag = isPresenceTag;
|
|
10281
10517
|
exports.isSharePointVendor = isSharePointVendor;
|
|
10518
|
+
exports.isSharedSkill = isSharedSkill;
|
|
10282
10519
|
exports.mail = mail_exports;
|
|
10283
10520
|
exports.notifications = notifications_exports;
|
|
10284
10521
|
exports.parseSSEEvents = parseSSEEvents;
|