@arbidocs/sdk 0.4.31 → 0.4.33

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.
@@ -1,2 +1,2 @@
1
- export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, K as FactResponse, L as FactSearchRequest, M as FactSearchResponse, P as ListFactsOptions, S as MessageMetadataPayload, T as MessageQueuedEvent, U as OutputTokensDetails, V as ParsedSlashCommand, W as PendingAuthResponse, X as PlanWorkRequest, Y as ProbeAnswerEvent, Z as ProjectInvoicesResponse, _ as ProjectUsageResponse, $ as QueryOptions, a0 as ReconnectOptions, a1 as ReconnectableWsConnection, a2 as RequestApprovalRequest, a3 as ResolvedCitation, a5 as ResponseCompletedEvent, a6 as ResponseContentPartAddedEvent, a7 as ResponseCreatedEvent, a8 as ResponseFailedEvent, a9 as ResponseOutputItemAddedEvent, aa as ResponseOutputItemDoneEvent, ab as ResponseOutputTextDeltaEvent, ac as ResponseOutputTextDoneEvent, ad as ResponseUsage, ae as ReviewWorkRequest, af as SSEEvent, ag as SSEStreamCallbacks, ah as SSEStreamResult, ai as SSEStreamStartData, ak as SkillSummary, am as SubmitBackgroundQueryOptions, an as TaskPlan, ao as TokenBudgetContext, ap as UpdateConversationRequest, aq as UpdateFactRequest, ar as UpdateWorkflowRequest, ax as UserDailyUsageResponse, ay as UserInfo, az as UserInputRequestEvent, aA as UserMessageEvent, aB as WebSocketAuthError, aC as WorkStatus, aD as WorkflowAuthMode, aE as WorkflowResponse, aF as WorkflowRunResponse, aG as WorkspaceContext, aH as WsConnection, aI as account, aJ as agentconfig, aL as assistant, aM as authenticatedFetch, aO as buildRetrievalChunkTool, aP as buildRetrievalFullContextTool, aQ as buildRetrievalTocTool, aR as connectWebSocket, aS as connectWithReconnect, aT as consumeSSEStream, aU as contacts, aV as conversations, aW as countCitations, aX as createAuthenticatedClient, aZ as dm, a_ as doctags, a$ as documents, b0 as facts, b1 as files, b2 as filterSkills, b3 as formatAgentStepLabel, b4 as formatFileSize, b5 as formatItemLabel, b7 as formatUserName, b8 as formatWorkspaceChoices, bd as getErrorMessage, be as getRawWorkspaceKey, bf as health, bg as parseSSEEvents, bh as parseSlashCommand, bi as parseSlashTokenInProgress, bj as performPasswordLogin, bm as profile, bn as projects, bo as requireData, bp as requireOk, bq as resolveAuth, br as resolveCitations, bs as resolveWorkspace, bt as responses, bu as selectWorkspace, bv as selectWorkspaceById, bw as sessions, bx as settings, by as streamSSE, bz as stripCitationMarkdown, bA as summarizeCitations, bB as tags, bC as work, bD as workflows, bE as workspaces } from './browser-CsCYLnPh.cjs';
1
+ export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, G as DocumentAutomationAction, J as DocumentSelector, M as FactResponse, N as FactSearchRequest, O as FactSearchResponse, R as ListFactsOptions, V as MessageMetadataPayload, W as MessageQueuedEvent, X as OutputTokensDetails, Y as ParsedSlashCommand, Z as PendingAuthResponse, _ as PlanWorkRequest, $ as ProbeAnswerEvent, a0 as ProjectInvoicesResponse, a1 as ProjectUsageResponse, a2 as QueryOptions, a3 as ReconnectOptions, a4 as ReconnectableWsConnection, a5 as RequestApprovalRequest, a6 as ResolvedCitation, a8 as ResponseCompletedEvent, a9 as ResponseContentPartAddedEvent, aa as ResponseCreatedEvent, ab as ResponseFailedEvent, ac as ResponseOutputItemAddedEvent, ad as ResponseOutputItemDoneEvent, ae as ResponseOutputTextDeltaEvent, af as ResponseOutputTextDoneEvent, ag as ResponseUsage, ah as ReviewWorkRequest, ai as SSEEvent, aj as SSEStreamCallbacks, ak as SSEStreamResult, al as SSEStreamStartData, an as SkillSummary, ap as SubmitBackgroundQueryOptions, aq as TaskPlan, ar as TokenBudgetContext, as as UpdateConversationRequest, at as UpdateFactRequest, au as UpdateWorkflowRequest, aA as UserDailyUsageResponse, aB as UserInfo, aC as UserInputRequestEvent, aD as UserMessageEvent, aE as WebSocketAuthError, aF as WorkStatus, aG as WorkflowAuthMode, aH as WorkflowResponse, aI as WorkflowRunHistoryResponse, aJ as WorkflowRunResponse, aK as WorkspaceContext, aL as WsConnection, aM as account, aN as agentconfig, aP as assistant, aQ as authenticatedFetch, aS as buildRetrievalChunkTool, aT as buildRetrievalFullContextTool, aU as buildRetrievalTocTool, aV as connectWebSocket, aW as connectWithReconnect, aX as consumeSSEStream, aY as contacts, aZ as conversations, a_ as countCitations, a$ as createAuthenticatedClient, b1 as dm, b2 as doctags, b3 as documents, b4 as facts, b5 as files, b6 as filterSkills, b7 as formatAgentStepLabel, b8 as formatFileSize, b9 as formatItemLabel, bb as formatUserName, bc as formatWorkspaceChoices, bh as getErrorMessage, bi as getRawWorkspaceKey, bj as health, bk as mail, bl as parseSSEEvents, bm as parseSlashCommand, bn as parseSlashTokenInProgress, bo as performPasswordLogin, br as profile, bs as projects, bt as requireData, bu as requireOk, bv as resolveAuth, bw as resolveCitations, bx as resolveWorkspace, by as responses, bz as selectWorkspace, bA as selectWorkspaceById, bB as sessions, bC as settings, bD as streamSSE, bE as stripCitationMarkdown, bF as summarizeCitations, bG as tags, bH as work, bI as workflows, bJ as workspaces } from './browser-CQ3lohen.cjs';
2
2
  export { LoginProfile } from '@arbidocs/client';
package/dist/browser.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, K as FactResponse, L as FactSearchRequest, M as FactSearchResponse, P as ListFactsOptions, S as MessageMetadataPayload, T as MessageQueuedEvent, U as OutputTokensDetails, V as ParsedSlashCommand, W as PendingAuthResponse, X as PlanWorkRequest, Y as ProbeAnswerEvent, Z as ProjectInvoicesResponse, _ as ProjectUsageResponse, $ as QueryOptions, a0 as ReconnectOptions, a1 as ReconnectableWsConnection, a2 as RequestApprovalRequest, a3 as ResolvedCitation, a5 as ResponseCompletedEvent, a6 as ResponseContentPartAddedEvent, a7 as ResponseCreatedEvent, a8 as ResponseFailedEvent, a9 as ResponseOutputItemAddedEvent, aa as ResponseOutputItemDoneEvent, ab as ResponseOutputTextDeltaEvent, ac as ResponseOutputTextDoneEvent, ad as ResponseUsage, ae as ReviewWorkRequest, af as SSEEvent, ag as SSEStreamCallbacks, ah as SSEStreamResult, ai as SSEStreamStartData, ak as SkillSummary, am as SubmitBackgroundQueryOptions, an as TaskPlan, ao as TokenBudgetContext, ap as UpdateConversationRequest, aq as UpdateFactRequest, ar as UpdateWorkflowRequest, ax as UserDailyUsageResponse, ay as UserInfo, az as UserInputRequestEvent, aA as UserMessageEvent, aB as WebSocketAuthError, aC as WorkStatus, aD as WorkflowAuthMode, aE as WorkflowResponse, aF as WorkflowRunResponse, aG as WorkspaceContext, aH as WsConnection, aI as account, aJ as agentconfig, aL as assistant, aM as authenticatedFetch, aO as buildRetrievalChunkTool, aP as buildRetrievalFullContextTool, aQ as buildRetrievalTocTool, aR as connectWebSocket, aS as connectWithReconnect, aT as consumeSSEStream, aU as contacts, aV as conversations, aW as countCitations, aX as createAuthenticatedClient, aZ as dm, a_ as doctags, a$ as documents, b0 as facts, b1 as files, b2 as filterSkills, b3 as formatAgentStepLabel, b4 as formatFileSize, b5 as formatItemLabel, b7 as formatUserName, b8 as formatWorkspaceChoices, bd as getErrorMessage, be as getRawWorkspaceKey, bf as health, bg as parseSSEEvents, bh as parseSlashCommand, bi as parseSlashTokenInProgress, bj as performPasswordLogin, bm as profile, bn as projects, bo as requireData, bp as requireOk, bq as resolveAuth, br as resolveCitations, bs as resolveWorkspace, bt as responses, bu as selectWorkspace, bv as selectWorkspaceById, bw as sessions, bx as settings, by as streamSSE, bz as stripCitationMarkdown, bA as summarizeCitations, bB as tags, bC as work, bD as workflows, bE as workspaces } from './browser-CsCYLnPh.js';
1
+ export { A as ActivityKind, a as ActivityResponse, b as AgentControlStateEvent, c as AgentStepDeltaEvent, d as AgentStepEvent, e as Arbi, f as ArbiApiError, g as ArbiError, h as ArbiErrorEvent, i as ArbiOptions, k as ArtifactEvent, l as AuthContext, m as AuthHeaders, n as AuthMode, o as AuthenticatedClient, C as ChatSession, p as CitationSummary, q as CliConfig, r as CliCredentials, s as CommandDescriptor, t as ConfigStore, u as ConnectOptions, v as ConversationResponse, w as CreateFactRequest, x as CreateFactsRequest, y as CreateWorkRequest, z as CreateWorkflowRequest, B as DeferredInterjectionEvent, G as DocumentAutomationAction, J as DocumentSelector, M as FactResponse, N as FactSearchRequest, O as FactSearchResponse, R as ListFactsOptions, V as MessageMetadataPayload, W as MessageQueuedEvent, X as OutputTokensDetails, Y as ParsedSlashCommand, Z as PendingAuthResponse, _ as PlanWorkRequest, $ as ProbeAnswerEvent, a0 as ProjectInvoicesResponse, a1 as ProjectUsageResponse, a2 as QueryOptions, a3 as ReconnectOptions, a4 as ReconnectableWsConnection, a5 as RequestApprovalRequest, a6 as ResolvedCitation, a8 as ResponseCompletedEvent, a9 as ResponseContentPartAddedEvent, aa as ResponseCreatedEvent, ab as ResponseFailedEvent, ac as ResponseOutputItemAddedEvent, ad as ResponseOutputItemDoneEvent, ae as ResponseOutputTextDeltaEvent, af as ResponseOutputTextDoneEvent, ag as ResponseUsage, ah as ReviewWorkRequest, ai as SSEEvent, aj as SSEStreamCallbacks, ak as SSEStreamResult, al as SSEStreamStartData, an as SkillSummary, ap as SubmitBackgroundQueryOptions, aq as TaskPlan, ar as TokenBudgetContext, as as UpdateConversationRequest, at as UpdateFactRequest, au as UpdateWorkflowRequest, aA as UserDailyUsageResponse, aB as UserInfo, aC as UserInputRequestEvent, aD as UserMessageEvent, aE as WebSocketAuthError, aF as WorkStatus, aG as WorkflowAuthMode, aH as WorkflowResponse, aI as WorkflowRunHistoryResponse, aJ as WorkflowRunResponse, aK as WorkspaceContext, aL as WsConnection, aM as account, aN as agentconfig, aP as assistant, aQ as authenticatedFetch, aS as buildRetrievalChunkTool, aT as buildRetrievalFullContextTool, aU as buildRetrievalTocTool, aV as connectWebSocket, aW as connectWithReconnect, aX as consumeSSEStream, aY as contacts, aZ as conversations, a_ as countCitations, a$ as createAuthenticatedClient, b1 as dm, b2 as doctags, b3 as documents, b4 as facts, b5 as files, b6 as filterSkills, b7 as formatAgentStepLabel, b8 as formatFileSize, b9 as formatItemLabel, bb as formatUserName, bc as formatWorkspaceChoices, bh as getErrorMessage, bi as getRawWorkspaceKey, bj as health, bk as mail, bl as parseSSEEvents, bm as parseSlashCommand, bn as parseSlashTokenInProgress, bo as performPasswordLogin, br as profile, bs as projects, bt as requireData, bu as requireOk, bv as resolveAuth, bw as resolveCitations, bx as resolveWorkspace, by as responses, bz as selectWorkspace, bA as selectWorkspaceById, bB as sessions, bC as settings, bD as streamSSE, bE as stripCitationMarkdown, bF as summarizeCitations, bG as tags, bH as work, bI as workflows, bJ as workspaces } from './browser-CQ3lohen.js';
2
2
  export { LoginProfile } from '@arbidocs/client';
package/dist/browser.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createArbiClient, base64ToBytes, deriveEncryptionKeypairFromSigning, sealedBoxDecrypt, sealKeyForSession, buildWebSocketUrl, createAuthMessage, parseServerMessage, isMessageType, createContentHash, encryptFile, changePasswordWithRekey } from '@arbidocs/client';
1
+ import { createArbiClient, base64ToBytes, deriveEncryptionKeypairFromSigning, sealedBoxDecrypt, sealKeyForSession, buildWebSocketUrl, createAuthMessage, parseServerMessage, isMessageType, createContentHash, encryptFile, changePasswordWithRekey, initSodium } from '@arbidocs/client';
2
2
 
3
3
  var __defProp = Object.defineProperty;
4
4
  var __getOwnPropNames = Object.getOwnPropertyNames;
@@ -3556,8 +3556,8 @@ async function extractErrorMessage(res) {
3556
3556
  const text = await res.text();
3557
3557
  if (text) {
3558
3558
  try {
3559
- const json = JSON.parse(text);
3560
- bodyDetail = detailText(json.detail) || json.message || json.error || void 0;
3559
+ const json2 = JSON.parse(text);
3560
+ bodyDetail = detailText(json2.detail) || json2.message || json2.error || void 0;
3561
3561
  } catch {
3562
3562
  if (text.length < 200) bodyDetail = text;
3563
3563
  }
@@ -4486,8 +4486,8 @@ async function getThumbnails(auth, docIds) {
4486
4486
  headers: { "Content-Type": "application/json" },
4487
4487
  body: JSON.stringify({ document_ext_ids: docIds })
4488
4488
  });
4489
- const json = await res.json();
4490
- return json.thumbnails ?? {};
4489
+ const json2 = await res.json();
4490
+ return json2.thumbnails ?? {};
4491
4491
  }
4492
4492
  async function uploadFile(auth, fileData, fileName, options) {
4493
4493
  const formData = new FormData();
@@ -5364,17 +5364,17 @@ async function encryptDmContent(arbi, plaintext, recipientEncryptionPubKeyBase64
5364
5364
  senderEncryptionSecretKey
5365
5365
  );
5366
5366
  }
5367
- async function decryptDmContent(arbi, notification, crypto) {
5367
+ async function decryptDmContent(arbi, notification, crypto2) {
5368
5368
  if (!notification.content) return null;
5369
- const isSent = notification.sender.external_id === crypto.userExtId;
5369
+ const isSent = notification.sender.external_id === crypto2.userExtId;
5370
5370
  const otherParty = isSent ? notification.recipient : notification.sender;
5371
5371
  return arbi.crypto.decryptMessage(
5372
5372
  notification.content,
5373
5373
  otherParty.encryption_public_key,
5374
- crypto.encryptionKeypair.secretKey
5374
+ crypto2.encryptionKeypair.secretKey
5375
5375
  );
5376
5376
  }
5377
- async function decryptDmBatch(arbi, notifications, crypto) {
5377
+ async function decryptDmBatch(arbi, notifications, crypto2) {
5378
5378
  const results = [];
5379
5379
  for (const n2 of notifications) {
5380
5380
  if (n2.type !== "user_message" || !n2.content) {
@@ -5382,7 +5382,7 @@ async function decryptDmBatch(arbi, notifications, crypto) {
5382
5382
  continue;
5383
5383
  }
5384
5384
  try {
5385
- const plaintext = await decryptDmContent(arbi, n2, crypto);
5385
+ const plaintext = await decryptDmContent(arbi, n2, crypto2);
5386
5386
  results.push({ ...n2, content: plaintext });
5387
5387
  } catch {
5388
5388
  results.push({ ...n2, content: "[Decryption failed]" });
@@ -5393,9 +5393,9 @@ async function decryptDmBatch(arbi, notifications, crypto) {
5393
5393
  async function listDMs(arbi) {
5394
5394
  return requireData(await arbi.fetch.GET("/v1/notifications/"), "Failed to fetch messages");
5395
5395
  }
5396
- async function listDecryptedDMs(arbi, crypto) {
5396
+ async function listDecryptedDMs(arbi, crypto2) {
5397
5397
  const raw = await listDMs(arbi);
5398
- return decryptDmBatch(arbi, raw, crypto);
5398
+ return decryptDmBatch(arbi, raw, crypto2);
5399
5399
  }
5400
5400
  async function listActivity(arbi, options) {
5401
5401
  return requireData(
@@ -5442,7 +5442,7 @@ async function resolveRecipient(arbi, ref) {
5442
5442
  }
5443
5443
  return null;
5444
5444
  }
5445
- async function sendEncryptedDM(arbi, messages, crypto) {
5445
+ async function sendEncryptedDM(arbi, messages, crypto2) {
5446
5446
  const plaintextFor = new Map(messages.map((m2) => [m2.recipient_ext_id, m2.content]));
5447
5447
  const encrypted = await Promise.all(
5448
5448
  messages.map(async (msg) => ({
@@ -5451,7 +5451,7 @@ async function sendEncryptedDM(arbi, messages, crypto) {
5451
5451
  arbi,
5452
5452
  msg.content,
5453
5453
  msg.recipient_encryption_public_key,
5454
- crypto.encryptionKeypair.secretKey
5454
+ crypto2.encryptionKeypair.secretKey
5455
5455
  )
5456
5456
  }))
5457
5457
  );
@@ -5466,7 +5466,7 @@ async function sendEncryptedDM(arbi, messages, crypto) {
5466
5466
  content: plaintextFor.get(n2.recipient.external_id) ?? n2.content
5467
5467
  }));
5468
5468
  }
5469
- async function requestWorkspaceAccess(arbi, params, crypto) {
5469
+ async function requestWorkspaceAccess(arbi, params, crypto2) {
5470
5470
  const payload = JSON.stringify({
5471
5471
  session_pubkey_b64: params.sessionPubkeyB64,
5472
5472
  note: params.note?.trim() || void 0
@@ -5475,7 +5475,7 @@ async function requestWorkspaceAccess(arbi, params, crypto) {
5475
5475
  arbi,
5476
5476
  payload,
5477
5477
  params.recipientEncryptionPublicKey,
5478
- crypto.encryptionKeypair.secretKey
5478
+ crypto2.encryptionKeypair.secretKey
5479
5479
  );
5480
5480
  return requireData(
5481
5481
  await arbi.fetch.POST("/v1/notifications/access-request", {
@@ -5876,6 +5876,7 @@ __export(workflows_exports, {
5876
5876
  createWorkflow: () => createWorkflow,
5877
5877
  deleteWorkflow: () => deleteWorkflow,
5878
5878
  getWorkflow: () => getWorkflow,
5879
+ listWorkflowRuns: () => listWorkflowRuns,
5879
5880
  listWorkflows: () => listWorkflows,
5880
5881
  runWorkflow: () => runWorkflow,
5881
5882
  updateWorkflow: () => updateWorkflow
@@ -5911,6 +5912,12 @@ async function runWorkflow(arbi, workflowId) {
5911
5912
  "Failed to run workflow"
5912
5913
  );
5913
5914
  }
5915
+ async function listWorkflowRuns(arbi, workflowId) {
5916
+ return requireData(
5917
+ await arbi.fetch.GET("/v1/workflow/{workflow_id}/runs", byId2(workflowId)),
5918
+ "Failed to list automation executions"
5919
+ );
5920
+ }
5914
5921
 
5915
5922
  // src/operations/facts.ts
5916
5923
  var facts_exports = {};
@@ -5984,8 +5991,8 @@ function tokenExpiresWithin(token, seconds) {
5984
5991
  const payload = token?.split(".")[1];
5985
5992
  if (!payload) return false;
5986
5993
  try {
5987
- const json = atob(payload.replace(/-/g, "+").replace(/_/g, "/"));
5988
- const { exp } = JSON.parse(json);
5994
+ const json2 = atob(payload.replace(/-/g, "+").replace(/_/g, "/"));
5995
+ const { exp } = JSON.parse(json2);
5989
5996
  return typeof exp === "number" && exp * 1e3 - Date.now() < seconds * 1e3;
5990
5997
  } catch {
5991
5998
  return false;
@@ -6376,9 +6383,9 @@ var Arbi = class {
6376
6383
  const lr2 = this.requireLogin();
6377
6384
  const userExtId = lr2.userExtId ?? client.session.getState().userExtId;
6378
6385
  if (!userExtId) throw new ArbiError("No user id in session \u2014 cannot request access");
6379
- const crypto = createDmCryptoContext(client, lr2.signingPrivateKey, userExtId);
6386
+ const crypto2 = createDmCryptoContext(client, lr2.signingPrivateKey, userExtId);
6380
6387
  const sessionPubkeyB64 = client.crypto.bytesToBase64(lr2.serverSessionKey);
6381
- return requestWorkspaceAccess(client, { ...params, sessionPubkeyB64 }, crypto);
6388
+ return requestWorkspaceAccess(client, { ...params, sessionPubkeyB64 }, crypto2);
6382
6389
  },
6383
6390
  copyDocuments: (targetWorkspaceId, docIds, targetWorkspaceKey) => copyDocuments(
6384
6391
  this.requireClient(),
@@ -6815,6 +6822,137 @@ var Arbi = class {
6815
6822
  }
6816
6823
  };
6817
6824
 
6818
- export { Arbi, ArbiApiError, ArbiError, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getRawWorkspaceKey, health_exports as health, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, work_exports as work, workflows_exports as workflows, workspaces_exports as workspaces };
6825
+ // src/operations/mail.ts
6826
+ var mail_exports = {};
6827
+ __export(mail_exports, {
6828
+ NATIVE_ACCOUNT: () => NATIVE_ACCOUNT,
6829
+ attachmentFromBytes: () => attachmentFromBytes,
6830
+ claimNativeAlias: () => claimNativeAlias,
6831
+ createMailFetch: () => createMailFetch,
6832
+ downloadAttachment: () => downloadAttachment,
6833
+ getMailPolicy: () => getMailPolicy,
6834
+ getMessage: () => getMessage2,
6835
+ listFolders: () => listFolders,
6836
+ listMailAccounts: () => listMailAccounts,
6837
+ listMessages: () => listMessages,
6838
+ saveDraft: () => saveDraft,
6839
+ sendMessage: () => sendMessage,
6840
+ unlockNativeMail: () => unlockNativeMail,
6841
+ updateMessage: () => updateMessage
6842
+ });
6843
+ var NATIVE_ACCOUNT = "native";
6844
+ function createMailFetch(auth) {
6845
+ return (path, init = {}) => authenticatedFetch({
6846
+ ...auth,
6847
+ path: `/v1/mail${path}`,
6848
+ method: init.method,
6849
+ body: init.body,
6850
+ headers: {
6851
+ ...init.body ? { "Content-Type": "application/json" } : {},
6852
+ ...init.headers
6853
+ }
6854
+ });
6855
+ }
6856
+ async function json(response) {
6857
+ return (await response).json();
6858
+ }
6859
+ var accountPath = (accountId) => `/accounts/${encodeURIComponent(accountId)}`;
6860
+ function getMailPolicy(mail) {
6861
+ return json(mail("/policy"));
6862
+ }
6863
+ function listMailAccounts(mail) {
6864
+ return json(mail("/accounts"));
6865
+ }
6866
+ async function claimNativeAlias(mail, alias) {
6867
+ const { email } = await json(
6868
+ mail("/native/alias", { method: "POST", body: JSON.stringify({ alias }) })
6869
+ );
6870
+ return email;
6871
+ }
6872
+ function listFolders(mail, accountId = NATIVE_ACCOUNT) {
6873
+ return json(mail(`${accountPath(accountId)}/folders`));
6874
+ }
6875
+ function listMessages(mail, options) {
6876
+ const params = new URLSearchParams({ folder_id: options.folderId });
6877
+ if (options.query) params.set("q", options.query);
6878
+ if (options.cursor) params.set("cursor", options.cursor);
6879
+ if (options.limit) params.set("limit", String(options.limit));
6880
+ return json(mail(`${accountPath(options.accountId ?? NATIVE_ACCOUNT)}/messages?${params}`));
6881
+ }
6882
+ function getMessage2(mail, messageId, accountId = NATIVE_ACCOUNT) {
6883
+ return json(mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}`));
6884
+ }
6885
+ async function downloadAttachment(mail, messageId, attachmentId, accountId = NATIVE_ACCOUNT) {
6886
+ const path = `${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}/attachments/${encodeURIComponent(attachmentId)}`;
6887
+ return new Uint8Array(await (await mail(path)).arrayBuffer());
6888
+ }
6889
+ async function updateMessage(mail, messageId, update, accountId = NATIVE_ACCOUNT) {
6890
+ await mail(`${accountPath(accountId)}/messages/${encodeURIComponent(messageId)}`, {
6891
+ method: "PATCH",
6892
+ body: JSON.stringify(update)
6893
+ });
6894
+ }
6895
+ function saveDraft(mail, compose, accountId = NATIVE_ACCOUNT) {
6896
+ return json(
6897
+ mail(`${accountPath(accountId)}/drafts`, { method: "POST", body: JSON.stringify(compose) })
6898
+ );
6899
+ }
6900
+ function sendMessage(mail, message, accountId = NATIVE_ACCOUNT) {
6901
+ const body = { ...message, request_id: message.request_id ?? crypto.randomUUID() };
6902
+ return json(
6903
+ mail(`${accountPath(accountId)}/send`, { method: "POST", body: JSON.stringify(body) })
6904
+ );
6905
+ }
6906
+ async function unlockNativeMail(mail, keys) {
6907
+ await initSodium();
6908
+ const secretKey = deriveEncryptionKeypairFromSigning({
6909
+ publicKey: keys.signingPrivateKey.slice(32, 64),
6910
+ secretKey: keys.signingPrivateKey
6911
+ }).secretKey;
6912
+ try {
6913
+ let cursor = 0;
6914
+ while (cursor !== null) {
6915
+ const page = await json(
6916
+ mail(`/native/keys?cursor=${cursor}`)
6917
+ );
6918
+ const sealed = {};
6919
+ for (const [id, wrapped] of Object.entries(page.keys)) {
6920
+ const key = sealedBoxDecrypt(wrapped, secretKey);
6921
+ try {
6922
+ sealed[id] = await sealKeyForSession(key, keys.serverSessionKey);
6923
+ } finally {
6924
+ key.fill(0);
6925
+ }
6926
+ }
6927
+ if (Object.keys(sealed).length) {
6928
+ await mail("/native/session-keys", {
6929
+ method: "POST",
6930
+ body: JSON.stringify({ keys: sealed })
6931
+ });
6932
+ }
6933
+ cursor = page.next_cursor;
6934
+ }
6935
+ } finally {
6936
+ secretKey.fill(0);
6937
+ }
6938
+ }
6939
+ function attachmentFromBytes(name, contentType, bytes) {
6940
+ return {
6941
+ id: "",
6942
+ name,
6943
+ content_type: contentType,
6944
+ size: bytes.length,
6945
+ content_base64: bytesToBase64(bytes)
6946
+ };
6947
+ }
6948
+ function bytesToBase64(bytes) {
6949
+ let binary = "";
6950
+ for (let i2 = 0; i2 < bytes.length; i2 += 32768) {
6951
+ binary += String.fromCharCode(...bytes.subarray(i2, i2 + 32768));
6952
+ }
6953
+ return btoa(binary);
6954
+ }
6955
+
6956
+ export { Arbi, ArbiApiError, ArbiError, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, dm_exports as dm, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getRawWorkspaceKey, health_exports as health, mail_exports as mail, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, work_exports as work, workflows_exports as workflows, workspaces_exports as workspaces };
6819
6957
  //# sourceMappingURL=browser.js.map
6820
6958
  //# sourceMappingURL=browser.js.map