@arbidocs/sdk 0.4.128 → 0.4.130

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -4044,24 +4044,14 @@ async function performSsoDeviceFlowLogin(config, email, password, store, callbac
4044
4044
  }
4045
4045
  async function selectWorkspace(arbi, workspaceId, wrappedKey, serverSessionKey, signingPrivateKeyBase64) {
4046
4046
  const signingPrivateKey = client.base64ToBytes(signingPrivateKeyBase64);
4047
- const ed25519PublicKey = signingPrivateKey.slice(32, 64);
4048
- const encryptionKeyPair = client.deriveEncryptionKeypairFromSigning({
4049
- publicKey: ed25519PublicKey,
4050
- secretKey: signingPrivateKey
4051
- });
4052
- const workspaceKey = client.sealedBoxDecrypt(wrappedKey, encryptionKeyPair.secretKey);
4047
+ const workspaceKey = client.unwrapWorkspaceKey(wrappedKey, signingPrivateKey);
4053
4048
  const header = await client.sealKeyForSession(workspaceKey, serverSessionKey);
4054
4049
  arbi.session.setSelectedWorkspace(workspaceId);
4055
4050
  return header;
4056
4051
  }
4057
4052
  async function generateEncryptedWorkspaceKey(arbi, wrappedKey, serverSessionKey, signingPrivateKeyBase64) {
4058
4053
  const signingPrivateKey = client.base64ToBytes(signingPrivateKeyBase64);
4059
- const ed25519PublicKey = signingPrivateKey.slice(32, 64);
4060
- const encryptionKeyPair = client.deriveEncryptionKeypairFromSigning({
4061
- publicKey: ed25519PublicKey,
4062
- secretKey: signingPrivateKey
4063
- });
4064
- const workspaceKey = client.sealedBoxDecrypt(wrappedKey, encryptionKeyPair.secretKey);
4054
+ const workspaceKey = client.unwrapWorkspaceKey(wrappedKey, signingPrivateKey);
4065
4055
  return client.sealKeyForSession(workspaceKey, serverSessionKey);
4066
4056
  }
4067
4057
  async function generateNewWorkspaceKey(arbi, serverSessionKey) {
@@ -4081,12 +4071,7 @@ async function getRawWorkspaceKey(arbi, workspaceId, signingPrivateKeyBase64) {
4081
4071
  throw new ArbiError(`Workspace ${workspaceId} not found or has no encryption key`);
4082
4072
  }
4083
4073
  const signingPrivateKey = client.base64ToBytes(signingPrivateKeyBase64);
4084
- const ed25519PublicKey = signingPrivateKey.slice(32, 64);
4085
- const encryptionKeyPair = client.deriveEncryptionKeypairFromSigning({
4086
- publicKey: ed25519PublicKey,
4087
- secretKey: signingPrivateKey
4088
- });
4089
- return client.sealedBoxDecrypt(ws.wrapped_key, encryptionKeyPair.secretKey);
4074
+ return client.unwrapWorkspaceKey(ws.wrapped_key, signingPrivateKey);
4090
4075
  }
4091
4076
  var StaleSessionError = class extends ArbiError {
4092
4077
  constructor(message) {
@@ -4882,6 +4867,25 @@ function countCitations(metadata) {
4882
4867
  function stripCitationMarkdown(text) {
4883
4868
  return text.replace(/\[([^\]]+)\]\(#cite-(\d+)\)/g, "$1[$2]");
4884
4869
  }
4870
+ function buildCitationChunkData(message) {
4871
+ const merged = {};
4872
+ const sources = [message.tools, message.meta?.tools];
4873
+ for (const toolName of ["retrieval_full_context", "retrieval_chunk"]) {
4874
+ for (const tools of sources) {
4875
+ const tool = tools?.[toolName];
4876
+ if (!tool?.tool_responses) continue;
4877
+ for (const [key, chunks] of Object.entries(tool.tool_responses)) {
4878
+ if (!Array.isArray(chunks)) continue;
4879
+ const seen = new Set((merged[key] ?? []).map((c2) => c2.metadata?.chunk_ext_id));
4880
+ const fresh = chunks.filter(
4881
+ (c2) => !c2.metadata?.chunk_ext_id || !seen.has(c2.metadata.chunk_ext_id)
4882
+ );
4883
+ merged[key] = [...merged[key] ?? [], ...fresh];
4884
+ }
4885
+ }
4886
+ }
4887
+ return merged;
4888
+ }
4885
4889
  function buildChunkLookup(tools) {
4886
4890
  const lookup = /* @__PURE__ */ new Map();
4887
4891
  for (const toolName of ["retrieval_chunk", "retrieval_full_context"]) {
@@ -6365,10 +6369,7 @@ async function downloadChatAttachment(arbi, file) {
6365
6369
 
6366
6370
  // src/operations/chats.ts
6367
6371
  function createChatCryptoContext(signingPrivateKeyBytes, userExtId) {
6368
- const encryptionKeypair = client.deriveEncryptionKeypairFromSigning({
6369
- publicKey: signingPrivateKeyBytes.slice(32, 64),
6370
- secretKey: signingPrivateKeyBytes
6371
- });
6372
+ const encryptionKeypair = client.encryptionKeypairFromSigningKey(signingPrivateKeyBytes);
6372
6373
  return { encryptionKeypair, userExtId };
6373
6374
  }
6374
6375
  function isAgentExtId(extId) {
@@ -8166,6 +8167,7 @@ __export(mail_exports, {
8166
8167
  NATIVE_ACCOUNT: () => NATIVE_ACCOUNT,
8167
8168
  attachmentFromBytes: () => attachmentFromBytes,
8168
8169
  claimNativeAlias: () => claimNativeAlias,
8170
+ claimSecureMail: () => claimSecureMail,
8169
8171
  createMailFetch: () => createMailFetch,
8170
8172
  downloadAttachment: () => downloadAttachment,
8171
8173
  getMailPolicy: () => getMailPolicy,
@@ -8243,10 +8245,7 @@ function sendMessage(mail, message, accountId = NATIVE_ACCOUNT) {
8243
8245
  }
8244
8246
  async function unlockNativeMail(mail, keys) {
8245
8247
  await client.initSodium();
8246
- const secretKey = client.deriveEncryptionKeypairFromSigning({
8247
- publicKey: keys.signingPrivateKey.slice(32, 64),
8248
- secretKey: keys.signingPrivateKey
8249
- }).secretKey;
8248
+ const secretKey = client.encryptionKeypairFromSigningKey(keys.signingPrivateKey).secretKey;
8250
8249
  try {
8251
8250
  let cursor = 0;
8252
8251
  while (cursor !== null) {
@@ -8274,6 +8273,18 @@ async function unlockNativeMail(mail, keys) {
8274
8273
  secretKey.fill(0);
8275
8274
  }
8276
8275
  }
8276
+ async function claimSecureMail(mail, id, fragmentKey, recipientPublicKey) {
8277
+ const key = client.decodeSecureMailKey(fragmentKey);
8278
+ try {
8279
+ const path4 = `/secure/${encodeURIComponent(id)}`;
8280
+ const { raw } = await client.openSecureMail(await json(mail(path4)), key);
8281
+ raw.fill(0);
8282
+ const claim = await client.secureMailClaim(key, recipientPublicKey);
8283
+ return await json(mail(`${path4}/claim`, { method: "POST", body: JSON.stringify(claim) }));
8284
+ } finally {
8285
+ key.fill(0);
8286
+ }
8287
+ }
8277
8288
  function attachmentFromBytes(name, contentType, bytes) {
8278
8289
  return {
8279
8290
  id: "",
@@ -10431,16 +10442,19 @@ exports.ArbiSessionExpiredError = ArbiSessionExpiredError;
10431
10442
  exports.ClaudeOrchestrator = ClaudeOrchestrator;
10432
10443
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
10433
10444
  exports.DOC_TERMINAL_STATUSES = DOC_TERMINAL_STATUSES;
10445
+ exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
10434
10446
  exports.FileConfigStore = FileConfigStore;
10435
10447
  exports.OpenClawOrchestrator = OpenClawOrchestrator;
10436
10448
  exports.PlanStepsError = PlanStepsError;
10437
10449
  exports.STEP_FIELD_OPTION_TONES = STEP_FIELD_OPTION_TONES;
10450
+ exports.TAG_KINDS = TAG_KINDS;
10438
10451
  exports.WebSocketAuthError = WebSocketAuthError;
10439
10452
  exports.account = account_exports;
10440
10453
  exports.agentconfig = agentconfig_exports;
10441
10454
  exports.agents = agents_exports;
10442
10455
  exports.assistant = assistant_exports;
10443
10456
  exports.authenticatedFetch = authenticatedFetch;
10457
+ exports.buildCitationChunkData = buildCitationChunkData;
10444
10458
  exports.buildDocNameMap = buildDocNameMap;
10445
10459
  exports.buildFactsContextTool = buildFactsContextTool;
10446
10460
  exports.buildRetrievalChunkTool = buildRetrievalChunkTool;