@arbidocs/sdk 0.3.115 → 0.3.117
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-B5b3SDW6.d.cts → browser-CxTSIAhf.d.cts} +1029 -714
- package/dist/{browser-B5b3SDW6.d.ts → browser-CxTSIAhf.d.ts} +1029 -714
- package/dist/browser.cjs +225 -37
- 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 +225 -38
- package/dist/browser.js.map +1 -1
- package/dist/index.cjs +226 -45
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -108
- package/dist/index.d.ts +3 -108
- package/dist/index.js +226 -45
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5187,6 +5187,7 @@ __export(workspaces_exports, {
|
|
|
5187
5187
|
copyDocuments: () => copyDocuments,
|
|
5188
5188
|
createWorkspace: () => createWorkspace,
|
|
5189
5189
|
deleteWorkspaces: () => deleteWorkspaces,
|
|
5190
|
+
getWorkspaceChronology: () => getWorkspaceChronology,
|
|
5190
5191
|
listWorkspaceUsers: () => listWorkspaceUsers,
|
|
5191
5192
|
listWorkspaces: () => listWorkspaces,
|
|
5192
5193
|
removeWorkspaceUsers: () => removeWorkspaceUsers,
|
|
@@ -5251,6 +5252,14 @@ async function setUserRole(arbi, userIds, role) {
|
|
|
5251
5252
|
"Failed to update roles"
|
|
5252
5253
|
);
|
|
5253
5254
|
}
|
|
5255
|
+
async function getWorkspaceChronology(arbi, workspaceId) {
|
|
5256
|
+
return requireData(
|
|
5257
|
+
await arbi.fetch.GET("/v1/workspace/{workspace_ext_id}/chronology", {
|
|
5258
|
+
params: { path: { workspace_ext_id: workspaceId } }
|
|
5259
|
+
}),
|
|
5260
|
+
"Failed to fetch workspace chronology"
|
|
5261
|
+
);
|
|
5262
|
+
}
|
|
5254
5263
|
async function copyDocuments(arbi, targetWorkspaceId, docIds, targetWorkspaceKey) {
|
|
5255
5264
|
return requireData(
|
|
5256
5265
|
await arbi.fetch.POST("/v1/workspace/copy", {
|
|
@@ -5615,13 +5624,58 @@ __export(dm_exports, {
|
|
|
5615
5624
|
decryptDmContent: () => decryptDmContent,
|
|
5616
5625
|
deleteDMs: () => deleteDMs,
|
|
5617
5626
|
encryptDmContent: () => encryptDmContent,
|
|
5627
|
+
listActivity: () => listActivity,
|
|
5618
5628
|
listDMs: () => listDMs,
|
|
5619
5629
|
listDecryptedDMs: () => listDecryptedDMs,
|
|
5620
5630
|
markRead: () => markRead,
|
|
5621
5631
|
requestWorkspaceAccess: () => requestWorkspaceAccess,
|
|
5632
|
+
resolveRecipient: () => resolveRecipient,
|
|
5622
5633
|
sendDM: () => sendDM,
|
|
5623
5634
|
sendEncryptedDM: () => sendEncryptedDM
|
|
5624
5635
|
});
|
|
5636
|
+
|
|
5637
|
+
// src/operations/agents.ts
|
|
5638
|
+
var agents_exports = {};
|
|
5639
|
+
__export(agents_exports, {
|
|
5640
|
+
createAgent: () => createAgent,
|
|
5641
|
+
deleteAgents: () => deleteAgents,
|
|
5642
|
+
getAgentConfig: () => getAgentConfig,
|
|
5643
|
+
listAgentWorkspaces: () => listAgentWorkspaces,
|
|
5644
|
+
listAgents: () => listAgents
|
|
5645
|
+
});
|
|
5646
|
+
async function listAgents(arbi) {
|
|
5647
|
+
return requireData(await arbi.fetch.GET("/v1/agents"), "Failed to fetch agents");
|
|
5648
|
+
}
|
|
5649
|
+
async function createAgent(arbi, name) {
|
|
5650
|
+
const body = { name };
|
|
5651
|
+
return requireData(await arbi.fetch.POST("/v1/agents", { body }), "Failed to create agent");
|
|
5652
|
+
}
|
|
5653
|
+
async function getAgentConfig(arbi, agentExtId) {
|
|
5654
|
+
return requireData(
|
|
5655
|
+
await arbi.fetch.GET("/v1/agents/{agent_ext_id}/config", {
|
|
5656
|
+
params: { path: { agent_ext_id: agentExtId } }
|
|
5657
|
+
}),
|
|
5658
|
+
"Failed to fetch agent config"
|
|
5659
|
+
);
|
|
5660
|
+
}
|
|
5661
|
+
async function listAgentWorkspaces(arbi, agentExtId) {
|
|
5662
|
+
return requireData(
|
|
5663
|
+
await arbi.fetch.GET("/v1/agents/{agent_ext_id}/workspaces", {
|
|
5664
|
+
params: { path: { agent_ext_id: agentExtId } }
|
|
5665
|
+
}),
|
|
5666
|
+
"Failed to fetch agent workspaces"
|
|
5667
|
+
);
|
|
5668
|
+
}
|
|
5669
|
+
async function deleteAgents(arbi, agentExtIds) {
|
|
5670
|
+
return requireData(
|
|
5671
|
+
await arbi.fetch.DELETE("/v1/agents", {
|
|
5672
|
+
body: { agent_ext_ids: agentExtIds }
|
|
5673
|
+
}),
|
|
5674
|
+
"Failed to delete agents"
|
|
5675
|
+
);
|
|
5676
|
+
}
|
|
5677
|
+
|
|
5678
|
+
// src/operations/dm.ts
|
|
5625
5679
|
function createDmCryptoContext(arbi, signingPrivateKeyBytes, userExtId) {
|
|
5626
5680
|
const ed25519PublicKey = signingPrivateKeyBytes.slice(32, 64);
|
|
5627
5681
|
const encryptionKeypair = arbi.crypto.deriveEncryptionKeypairFromSigning({
|
|
@@ -5670,6 +5724,51 @@ async function listDecryptedDMs(arbi, crypto) {
|
|
|
5670
5724
|
const raw = await listDMs(arbi);
|
|
5671
5725
|
return decryptDmBatch(arbi, raw, crypto);
|
|
5672
5726
|
}
|
|
5727
|
+
async function listActivity(arbi, options) {
|
|
5728
|
+
return requireData(
|
|
5729
|
+
await arbi.fetch.GET("/v1/notifications/", {
|
|
5730
|
+
params: {
|
|
5731
|
+
query: {
|
|
5732
|
+
type: "activity",
|
|
5733
|
+
...options?.limit != null ? { limit: options.limit } : {},
|
|
5734
|
+
...options?.offset != null ? { offset: options.offset } : {}
|
|
5735
|
+
}
|
|
5736
|
+
}
|
|
5737
|
+
}),
|
|
5738
|
+
"Failed to fetch activity"
|
|
5739
|
+
);
|
|
5740
|
+
}
|
|
5741
|
+
async function resolveRecipient(arbi, ref) {
|
|
5742
|
+
const isEmail = ref.includes("@");
|
|
5743
|
+
const matchKey = isEmail ? "email" : "external_id";
|
|
5744
|
+
const contacts = await listContacts(arbi);
|
|
5745
|
+
const contactMatch = contacts.find(
|
|
5746
|
+
(c2) => isEmail ? c2.email === ref : c2.user?.external_id === ref || c2.external_id === ref
|
|
5747
|
+
);
|
|
5748
|
+
if (contactMatch?.user?.encryption_public_key) {
|
|
5749
|
+
return {
|
|
5750
|
+
extId: contactMatch.user.external_id,
|
|
5751
|
+
pubKey: contactMatch.user.encryption_public_key
|
|
5752
|
+
};
|
|
5753
|
+
}
|
|
5754
|
+
try {
|
|
5755
|
+
const agents = await listAgents(arbi);
|
|
5756
|
+
const agentMatch = agents.find((a2) => a2[matchKey] === ref);
|
|
5757
|
+
if (agentMatch?.encryption_public_key) {
|
|
5758
|
+
return { extId: agentMatch.external_id, pubKey: agentMatch.encryption_public_key };
|
|
5759
|
+
}
|
|
5760
|
+
} catch {
|
|
5761
|
+
}
|
|
5762
|
+
try {
|
|
5763
|
+
const wsUsers = await listWorkspaceUsers(arbi);
|
|
5764
|
+
const wsMatch = wsUsers.find((wu) => wu.user[matchKey] === ref);
|
|
5765
|
+
if (wsMatch?.user.encryption_public_key) {
|
|
5766
|
+
return { extId: wsMatch.user.external_id, pubKey: wsMatch.user.encryption_public_key };
|
|
5767
|
+
}
|
|
5768
|
+
} catch {
|
|
5769
|
+
}
|
|
5770
|
+
return null;
|
|
5771
|
+
}
|
|
5673
5772
|
async function sendEncryptedDM(arbi, messages, crypto) {
|
|
5674
5773
|
const encrypted = await Promise.all(
|
|
5675
5774
|
messages.map(async (msg) => ({
|
|
@@ -5866,47 +5965,6 @@ async function getFileContent(auth, fileId) {
|
|
|
5866
5965
|
});
|
|
5867
5966
|
}
|
|
5868
5967
|
|
|
5869
|
-
// src/operations/agents.ts
|
|
5870
|
-
var agents_exports = {};
|
|
5871
|
-
__export(agents_exports, {
|
|
5872
|
-
createAgent: () => createAgent,
|
|
5873
|
-
deleteAgents: () => deleteAgents,
|
|
5874
|
-
getAgentConfig: () => getAgentConfig,
|
|
5875
|
-
listAgentWorkspaces: () => listAgentWorkspaces,
|
|
5876
|
-
listAgents: () => listAgents
|
|
5877
|
-
});
|
|
5878
|
-
async function listAgents(arbi) {
|
|
5879
|
-
return requireData(await arbi.fetch.GET("/v1/agents"), "Failed to fetch agents");
|
|
5880
|
-
}
|
|
5881
|
-
async function createAgent(arbi, name) {
|
|
5882
|
-
const body = { name };
|
|
5883
|
-
return requireData(await arbi.fetch.POST("/v1/agents", { body }), "Failed to create agent");
|
|
5884
|
-
}
|
|
5885
|
-
async function getAgentConfig(arbi, agentExtId) {
|
|
5886
|
-
return requireData(
|
|
5887
|
-
await arbi.fetch.GET("/v1/agents/{agent_ext_id}/config", {
|
|
5888
|
-
params: { path: { agent_ext_id: agentExtId } }
|
|
5889
|
-
}),
|
|
5890
|
-
"Failed to fetch agent config"
|
|
5891
|
-
);
|
|
5892
|
-
}
|
|
5893
|
-
async function listAgentWorkspaces(arbi, agentExtId) {
|
|
5894
|
-
return requireData(
|
|
5895
|
-
await arbi.fetch.GET("/v1/agents/{agent_ext_id}/workspaces", {
|
|
5896
|
-
params: { path: { agent_ext_id: agentExtId } }
|
|
5897
|
-
}),
|
|
5898
|
-
"Failed to fetch agent workspaces"
|
|
5899
|
-
);
|
|
5900
|
-
}
|
|
5901
|
-
async function deleteAgents(arbi, agentExtIds) {
|
|
5902
|
-
return requireData(
|
|
5903
|
-
await arbi.fetch.DELETE("/v1/agents", {
|
|
5904
|
-
body: { agent_ext_ids: agentExtIds }
|
|
5905
|
-
}),
|
|
5906
|
-
"Failed to delete agents"
|
|
5907
|
-
);
|
|
5908
|
-
}
|
|
5909
|
-
|
|
5910
5968
|
// src/operations/sessions.ts
|
|
5911
5969
|
var sessions_exports = {};
|
|
5912
5970
|
__export(sessions_exports, {
|
|
@@ -5920,6 +5978,9 @@ async function listSessions(arbi) {
|
|
|
5920
5978
|
var projects_exports = {};
|
|
5921
5979
|
__export(projects_exports, {
|
|
5922
5980
|
createProject: () => createProject,
|
|
5981
|
+
getProjectInvoices: () => getProjectInvoices,
|
|
5982
|
+
getProjectUsage: () => getProjectUsage,
|
|
5983
|
+
getUserUsageToday: () => getUserUsageToday,
|
|
5923
5984
|
listProjects: () => listProjects,
|
|
5924
5985
|
refreshProject: () => refreshProject
|
|
5925
5986
|
});
|
|
@@ -5942,6 +6003,28 @@ async function refreshProject(arbi, projectExtId) {
|
|
|
5942
6003
|
"Failed to refresh project"
|
|
5943
6004
|
);
|
|
5944
6005
|
}
|
|
6006
|
+
async function getProjectUsage(arbi, projectExtId, monthsBack) {
|
|
6007
|
+
return requireData(
|
|
6008
|
+
await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/usage", {
|
|
6009
|
+
params: {
|
|
6010
|
+
path: { project_ext_id: projectExtId },
|
|
6011
|
+
query: monthsBack === void 0 ? void 0 : { months_back: monthsBack }
|
|
6012
|
+
}
|
|
6013
|
+
}),
|
|
6014
|
+
"Failed to fetch project usage"
|
|
6015
|
+
);
|
|
6016
|
+
}
|
|
6017
|
+
async function getProjectInvoices(arbi, projectExtId) {
|
|
6018
|
+
return requireData(
|
|
6019
|
+
await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/invoices", {
|
|
6020
|
+
params: { path: { project_ext_id: projectExtId } }
|
|
6021
|
+
}),
|
|
6022
|
+
"Failed to fetch project invoices"
|
|
6023
|
+
);
|
|
6024
|
+
}
|
|
6025
|
+
async function getUserUsageToday(arbi) {
|
|
6026
|
+
return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
|
|
6027
|
+
}
|
|
5945
6028
|
|
|
5946
6029
|
// src/operations/tasks.ts
|
|
5947
6030
|
async function listTasks(arbi) {
|
|
@@ -6017,6 +6100,7 @@ var Arbi = class {
|
|
|
6017
6100
|
client = null;
|
|
6018
6101
|
loginResult = null;
|
|
6019
6102
|
currentWorkspaceId = null;
|
|
6103
|
+
dmCryptoContext = null;
|
|
6020
6104
|
options;
|
|
6021
6105
|
constructor(options) {
|
|
6022
6106
|
this.options = options;
|
|
@@ -6103,6 +6187,7 @@ var Arbi = class {
|
|
|
6103
6187
|
}
|
|
6104
6188
|
this.loginResult = null;
|
|
6105
6189
|
this.currentWorkspaceId = null;
|
|
6190
|
+
this.dmCryptoContext = null;
|
|
6106
6191
|
}
|
|
6107
6192
|
// ── Accessors ─────────────────────────────────────────────────────────
|
|
6108
6193
|
/** Get the underlying ArbiClient (throws if not initialized). */
|
|
@@ -6150,7 +6235,26 @@ var Arbi = class {
|
|
|
6150
6235
|
projects = {
|
|
6151
6236
|
list: () => listProjects(this.requireClient()),
|
|
6152
6237
|
create: (name) => createProject(this.requireClient(), name),
|
|
6153
|
-
refresh: (projectExtId) => refreshProject(this.requireClient(), projectExtId)
|
|
6238
|
+
refresh: (projectExtId) => refreshProject(this.requireClient(), projectExtId),
|
|
6239
|
+
/** AI usage + spend breakdown for a project's billing period. */
|
|
6240
|
+
usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
|
|
6241
|
+
/** Stripe invoices for a project's subscription. */
|
|
6242
|
+
invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId)
|
|
6243
|
+
};
|
|
6244
|
+
// ── User (account-scoped usage) ───────────────────────────────────────
|
|
6245
|
+
user = {
|
|
6246
|
+
/**
|
|
6247
|
+
* The authenticated user's identity from the current session
|
|
6248
|
+
* (`external_id` + `email`), established at login. Returns `null` when not
|
|
6249
|
+
* logged in. This is the canonical "who am I" accessor — DM direction and
|
|
6250
|
+
* ownership checks read it instead of re-deriving identity per call.
|
|
6251
|
+
*/
|
|
6252
|
+
identity: () => {
|
|
6253
|
+
const state = this.requireClient().session.getState();
|
|
6254
|
+
return state.userExtId && state.userEmail ? { externalId: state.userExtId, email: state.userEmail } : null;
|
|
6255
|
+
},
|
|
6256
|
+
/** Today's deployment-wide credit spend for the current user. */
|
|
6257
|
+
usageToday: () => getUserUsageToday(this.requireClient())
|
|
6154
6258
|
};
|
|
6155
6259
|
// ── Workspaces ────────────────────────────────────────────────────────
|
|
6156
6260
|
workspaces = {
|
|
@@ -6198,6 +6302,14 @@ var Arbi = class {
|
|
|
6198
6302
|
targetWorkspaceId,
|
|
6199
6303
|
docIds,
|
|
6200
6304
|
targetWorkspaceKey
|
|
6305
|
+
),
|
|
6306
|
+
/**
|
|
6307
|
+
* The last-generated document-derived chronology (key case events / dates).
|
|
6308
|
+
* Defaults to the currently open workspace when no id is passed.
|
|
6309
|
+
*/
|
|
6310
|
+
chronology: (workspaceId) => getWorkspaceChronology(
|
|
6311
|
+
this.requireClient(),
|
|
6312
|
+
workspaceId ?? this.requireWorkspace()
|
|
6201
6313
|
)
|
|
6202
6314
|
};
|
|
6203
6315
|
// ── Documents ─────────────────────────────────────────────────────────
|
|
@@ -6324,11 +6436,80 @@ var Arbi = class {
|
|
|
6324
6436
|
groupByStatus: groupContactsByStatus
|
|
6325
6437
|
};
|
|
6326
6438
|
// ── Direct Messages ───────────────────────────────────────────────────
|
|
6439
|
+
/**
|
|
6440
|
+
* Build (and cache) the DM crypto context for the current session.
|
|
6441
|
+
*
|
|
6442
|
+
* Derives the user's curve25519 keypair from the stored signing key and pairs
|
|
6443
|
+
* it with their external_id — everything `list()`/`send()` need to encrypt and
|
|
6444
|
+
* decrypt. Cached for the session and cleared on logout. Consumers never touch
|
|
6445
|
+
* this: it's an internal of the `dm` surface.
|
|
6446
|
+
*/
|
|
6447
|
+
async requireDmCrypto() {
|
|
6448
|
+
if (this.dmCryptoContext) return this.dmCryptoContext;
|
|
6449
|
+
const client = this.requireClient();
|
|
6450
|
+
const session = await client.storage.getSession();
|
|
6451
|
+
if (!session) {
|
|
6452
|
+
throw new ArbiError("Not authenticated \u2014 no session available for DM encryption");
|
|
6453
|
+
}
|
|
6454
|
+
const userExtId = client.session.getState().userExtId;
|
|
6455
|
+
if (!userExtId) {
|
|
6456
|
+
throw new ArbiError("No user identity in session \u2014 cannot set up DM encryption");
|
|
6457
|
+
}
|
|
6458
|
+
this.dmCryptoContext = createDmCryptoContext(client, session.signingPrivateKey, userExtId);
|
|
6459
|
+
return this.dmCryptoContext;
|
|
6460
|
+
}
|
|
6327
6461
|
dm = {
|
|
6328
|
-
|
|
6329
|
-
|
|
6462
|
+
/**
|
|
6463
|
+
* List direct messages, newest first, with content already **decrypted**.
|
|
6464
|
+
* (A message that can't be decrypted comes back as `[Decryption failed]`.)
|
|
6465
|
+
*/
|
|
6466
|
+
list: async () => listDecryptedDMs(this.requireClient(), await this.requireDmCrypto()),
|
|
6467
|
+
/**
|
|
6468
|
+
* Send an E2E-encrypted DM to a recipient (email or `usr-`/`agt-` id).
|
|
6469
|
+
* Resolves the recipient's public key and encrypts internally — the caller
|
|
6470
|
+
* passes plaintext and never handles keys or ciphertext.
|
|
6471
|
+
*/
|
|
6472
|
+
send: async (recipient, text) => {
|
|
6473
|
+
const client = this.requireClient();
|
|
6474
|
+
const resolved = await resolveRecipient(client, recipient);
|
|
6475
|
+
if (!resolved) {
|
|
6476
|
+
throw new ArbiError(
|
|
6477
|
+
`Could not resolve DM recipient "${recipient}" (not a known contact, agent, or workspace member)`
|
|
6478
|
+
);
|
|
6479
|
+
}
|
|
6480
|
+
return sendEncryptedDM(
|
|
6481
|
+
client,
|
|
6482
|
+
[
|
|
6483
|
+
{
|
|
6484
|
+
recipient_ext_id: resolved.extId,
|
|
6485
|
+
content: text,
|
|
6486
|
+
recipient_encryption_public_key: resolved.pubKey
|
|
6487
|
+
}
|
|
6488
|
+
],
|
|
6489
|
+
await this.requireDmCrypto()
|
|
6490
|
+
);
|
|
6491
|
+
},
|
|
6492
|
+
/**
|
|
6493
|
+
* Send to a recipient whose external_id + public key are already known
|
|
6494
|
+
* (e.g. from a message's `sender`), skipping directory resolution.
|
|
6495
|
+
*/
|
|
6496
|
+
sendTo: async (recipientExtId, recipientPublicKey, text) => sendEncryptedDM(
|
|
6497
|
+
this.requireClient(),
|
|
6498
|
+
[
|
|
6499
|
+
{
|
|
6500
|
+
recipient_ext_id: recipientExtId,
|
|
6501
|
+
content: text,
|
|
6502
|
+
recipient_encryption_public_key: recipientPublicKey
|
|
6503
|
+
}
|
|
6504
|
+
],
|
|
6505
|
+
await this.requireDmCrypto()
|
|
6506
|
+
),
|
|
6507
|
+
/** Resolve a recipient reference to `{ extId, pubKey }` (contacts → agents → workspace). */
|
|
6508
|
+
resolveRecipient: (recipient) => resolveRecipient(this.requireClient(), recipient),
|
|
6330
6509
|
markRead: (messageIds) => markRead(this.requireClient(), messageIds),
|
|
6331
|
-
delete: (messageIds) => deleteDMs(this.requireClient(), messageIds)
|
|
6510
|
+
delete: (messageIds) => deleteDMs(this.requireClient(), messageIds),
|
|
6511
|
+
/** List the current user's durable activity feed (never unread; excluded from DMs). */
|
|
6512
|
+
listActivity: (options) => listActivity(this.requireClient(), options)
|
|
6332
6513
|
};
|
|
6333
6514
|
// ── Settings ──────────────────────────────────────────────────────────
|
|
6334
6515
|
settings = {
|