@arbidocs/sdk 0.4.127 → 0.4.129

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"]) {
@@ -5225,7 +5229,11 @@ async function presignedPut(url, body, onProgress, headers) {
5225
5229
  });
5226
5230
  return;
5227
5231
  }
5228
- const putRes = await fetch(url, { method: "PUT", body, ...headers ? { headers } : {} });
5232
+ const putRes = await fetch(url, {
5233
+ method: "PUT",
5234
+ body,
5235
+ ...headers ? { headers } : {}
5236
+ });
5229
5237
  if (!putRes.ok) {
5230
5238
  const snippet = await putRes.text().catch(() => "");
5231
5239
  throw new Error(`Presigned PUT failed: ${putRes.status} ${snippet.slice(0, 200)}`);
@@ -6361,10 +6369,7 @@ async function downloadChatAttachment(arbi, file) {
6361
6369
 
6362
6370
  // src/operations/chats.ts
6363
6371
  function createChatCryptoContext(signingPrivateKeyBytes, userExtId) {
6364
- const encryptionKeypair = client.deriveEncryptionKeypairFromSigning({
6365
- publicKey: signingPrivateKeyBytes.slice(32, 64),
6366
- secretKey: signingPrivateKeyBytes
6367
- });
6372
+ const encryptionKeypair = client.encryptionKeypairFromSigningKey(signingPrivateKeyBytes);
6368
6373
  return { encryptionKeypair, userExtId };
6369
6374
  }
6370
6375
  function isAgentExtId(extId) {
@@ -8162,6 +8167,7 @@ __export(mail_exports, {
8162
8167
  NATIVE_ACCOUNT: () => NATIVE_ACCOUNT,
8163
8168
  attachmentFromBytes: () => attachmentFromBytes,
8164
8169
  claimNativeAlias: () => claimNativeAlias,
8170
+ claimSecureMail: () => claimSecureMail,
8165
8171
  createMailFetch: () => createMailFetch,
8166
8172
  downloadAttachment: () => downloadAttachment,
8167
8173
  getMailPolicy: () => getMailPolicy,
@@ -8239,10 +8245,7 @@ function sendMessage(mail, message, accountId = NATIVE_ACCOUNT) {
8239
8245
  }
8240
8246
  async function unlockNativeMail(mail, keys) {
8241
8247
  await client.initSodium();
8242
- const secretKey = client.deriveEncryptionKeypairFromSigning({
8243
- publicKey: keys.signingPrivateKey.slice(32, 64),
8244
- secretKey: keys.signingPrivateKey
8245
- }).secretKey;
8248
+ const secretKey = client.encryptionKeypairFromSigningKey(keys.signingPrivateKey).secretKey;
8246
8249
  try {
8247
8250
  let cursor = 0;
8248
8251
  while (cursor !== null) {
@@ -8270,6 +8273,18 @@ async function unlockNativeMail(mail, keys) {
8270
8273
  secretKey.fill(0);
8271
8274
  }
8272
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
+ }
8273
8288
  function attachmentFromBytes(name, contentType, bytes) {
8274
8289
  return {
8275
8290
  id: "",
@@ -10427,16 +10442,19 @@ exports.ArbiSessionExpiredError = ArbiSessionExpiredError;
10427
10442
  exports.ClaudeOrchestrator = ClaudeOrchestrator;
10428
10443
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
10429
10444
  exports.DOC_TERMINAL_STATUSES = DOC_TERMINAL_STATUSES;
10445
+ exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
10430
10446
  exports.FileConfigStore = FileConfigStore;
10431
10447
  exports.OpenClawOrchestrator = OpenClawOrchestrator;
10432
10448
  exports.PlanStepsError = PlanStepsError;
10433
10449
  exports.STEP_FIELD_OPTION_TONES = STEP_FIELD_OPTION_TONES;
10450
+ exports.TAG_KINDS = TAG_KINDS;
10434
10451
  exports.WebSocketAuthError = WebSocketAuthError;
10435
10452
  exports.account = account_exports;
10436
10453
  exports.agentconfig = agentconfig_exports;
10437
10454
  exports.agents = agents_exports;
10438
10455
  exports.assistant = assistant_exports;
10439
10456
  exports.authenticatedFetch = authenticatedFetch;
10457
+ exports.buildCitationChunkData = buildCitationChunkData;
10440
10458
  exports.buildDocNameMap = buildDocNameMap;
10441
10459
  exports.buildFactsContextTool = buildFactsContextTool;
10442
10460
  exports.buildRetrievalChunkTool = buildRetrievalChunkTool;