@arbidocs/sdk 0.4.146 → 0.4.148

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.js CHANGED
@@ -3526,7 +3526,7 @@ function requireData(result, message) {
3526
3526
  }
3527
3527
  function requireOk(result, message) {
3528
3528
  if (result.error) {
3529
- throw new ArbiApiError(message, result.error);
3529
+ throw new ArbiApiError(message, result.error, result.response?.status);
3530
3530
  }
3531
3531
  }
3532
3532
  function getErrorMessage(err) {
@@ -4969,6 +4969,7 @@ __export(workspaces_exports, {
4969
4969
  grantTemporaryWorkspaceAccess: () => grantTemporaryWorkspaceAccess,
4970
4970
  listWorkspaceUsers: () => listWorkspaceUsers,
4971
4971
  listWorkspaces: () => listWorkspaces,
4972
+ primeWorkspaceKey: () => primeWorkspaceKey,
4972
4973
  removeWorkspaceUsers: () => removeWorkspaceUsers,
4973
4974
  setUserRole: () => setUserRole,
4974
4975
  updateWorkspace: () => updateWorkspace
@@ -5075,6 +5076,15 @@ async function getWorkspaceActivity(arbi, workspaceExtId, options = {}) {
5075
5076
  "Failed to fetch workspace activity"
5076
5077
  );
5077
5078
  }
5079
+ async function primeWorkspaceKey(arbi, workspaceExtId, sessionSealedKey) {
5080
+ requireOk(
5081
+ await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/prime-key", {
5082
+ params: { path: { workspace_ext_id: workspaceExtId } },
5083
+ body: { workspace_key: sessionSealedKey }
5084
+ }),
5085
+ "Failed to prime the workspace key"
5086
+ );
5087
+ }
5078
5088
 
5079
5089
  // src/operations/conversations.ts
5080
5090
  var conversations_exports = {};
@@ -5153,6 +5163,7 @@ async function updateConversationAssistantMode(arbi, conversationId, assistantMo
5153
5163
  // src/operations/assistant.ts
5154
5164
  var assistant_exports = {};
5155
5165
  __export(assistant_exports, {
5166
+ MAX_RETRIEVE_DOC_IDS: () => MAX_RETRIEVE_DOC_IDS,
5156
5167
  buildFactsContextTool: () => buildFactsContextTool,
5157
5168
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
5158
5169
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
@@ -5167,6 +5178,7 @@ __export(assistant_exports, {
5167
5178
  queryAssistant: () => queryAssistant,
5168
5179
  respondToAgent: () => respondToAgent,
5169
5180
  retrieve: () => retrieve,
5181
+ searchChunks: () => searchChunks,
5170
5182
  uploadSkill: () => uploadSkill
5171
5183
  });
5172
5184
  function buildRetrievalChunkTool(docIds, searchMode) {
@@ -5200,8 +5212,19 @@ function buildRetrievalTocTool(docIds) {
5200
5212
  tool_responses: {}
5201
5213
  };
5202
5214
  }
5215
+ var MAX_RETRIEVE_DOC_IDS = 5e3;
5203
5216
  async function retrieve(options) {
5204
- const { arbi, workspaceId, query, docIds, searchMode, fullContextDocIds, tocDocIds, model } = options;
5217
+ const {
5218
+ arbi,
5219
+ workspaceId,
5220
+ query,
5221
+ docIds,
5222
+ searchMode,
5223
+ fullContextDocIds,
5224
+ tocDocIds,
5225
+ model,
5226
+ store = true
5227
+ } = options;
5205
5228
  const tools = {
5206
5229
  retrieval_chunk: buildRetrievalChunkTool(docIds, searchMode)
5207
5230
  };
@@ -5216,7 +5239,7 @@ async function retrieve(options) {
5216
5239
  workspace_ext_id: workspaceId,
5217
5240
  stream: false,
5218
5241
  background: false,
5219
- store: true,
5242
+ store,
5220
5243
  tools,
5221
5244
  ...model ? { model } : {}
5222
5245
  };
@@ -5236,6 +5259,34 @@ async function retrieve(options) {
5236
5259
  }
5237
5260
  return data;
5238
5261
  }
5262
+ function isReadablePassage(content) {
5263
+ return content.length > 10 && content !== "-" && !/^[|\-\s]+$/.test(content);
5264
+ }
5265
+ function searchChunks(result) {
5266
+ const byId3 = /* @__PURE__ */ new Map();
5267
+ for (const [title, chunks] of Object.entries(result?.retrieval_chunk?.tool_responses ?? {})) {
5268
+ if (!Array.isArray(chunks)) continue;
5269
+ chunks.forEach((chunk, index) => {
5270
+ if (!chunk || typeof chunk !== "object") return;
5271
+ const content = chunk.content?.trim() ?? "";
5272
+ if (!isReadablePassage(content)) return;
5273
+ const meta = chunk.metadata ?? {};
5274
+ const docId = meta.doc_ext_id || title;
5275
+ const rerank = meta.rerank_score;
5276
+ byId3.set(meta.chunk_ext_id || `${docId}_${index}`, {
5277
+ id: meta.chunk_ext_id || `${docId}_${index}`,
5278
+ ...meta.chunk_ext_id ? { chunkExtId: meta.chunk_ext_id } : {},
5279
+ docId,
5280
+ docTitle: meta.doc_title || title,
5281
+ ...meta.page_number != null ? { page: meta.page_number } : {},
5282
+ score: rerank && rerank > 0 ? rerank : meta.score ?? 0,
5283
+ index,
5284
+ content
5285
+ });
5286
+ });
5287
+ }
5288
+ return Array.from(byId3.values()).sort((a2, b2) => b2.score - a2.score);
5289
+ }
5239
5290
  async function queryAssistant(options) {
5240
5291
  const {
5241
5292
  workspaceId,
@@ -6358,6 +6409,271 @@ async function setWorkspaceNotificationLevel(arbi, workspaceId, level) {
6358
6409
  return patch;
6359
6410
  }
6360
6411
 
6412
+ // src/operations/connectors.ts
6413
+ var connectors_exports = {};
6414
+ __export(connectors_exports, {
6415
+ DRIVE_SYNC_VENDORS: () => DRIVE_SYNC_VENDORS,
6416
+ GOOGLE_VENDORS: () => GOOGLE_VENDORS,
6417
+ IMANAGE_VENDORS: () => IMANAGE_VENDORS,
6418
+ MAILBOX_SYNC_VENDORS: () => MAILBOX_SYNC_VENDORS,
6419
+ MICROSOFT_VENDORS: () => MICROSOFT_VENDORS,
6420
+ SHAREPOINT_VENDORS: () => SHAREPOINT_VENDORS,
6421
+ authorize: () => authorize,
6422
+ authorizeSlack: () => authorizeSlack,
6423
+ bridgeConnectorTokens: () => bridgeConnectorTokens,
6424
+ cancelDriveSync: () => cancelDriveSync,
6425
+ cancelMailboxSync: () => cancelMailboxSync,
6426
+ connectErrorMessage: () => connectErrorMessage,
6427
+ depositSessionTokens: () => depositSessionTokens,
6428
+ disconnect: () => disconnect,
6429
+ disconnectSlack: () => disconnectSlack,
6430
+ driveFolderDocCount: () => driveFolderDocCount,
6431
+ driveSyncEstimate: () => driveSyncEstimate,
6432
+ driveSyncProgress: () => driveSyncProgress,
6433
+ enableDriveSync: () => enableDriveSync,
6434
+ enableMailboxSync: () => enableMailboxSync,
6435
+ getSealedTokens: () => getSealedTokens,
6436
+ isConnectorVendorVisible: () => isConnectorVendorVisible,
6437
+ isDriveSyncVendor: () => isDriveSyncVendor,
6438
+ isMailboxSyncVendor: () => isMailboxSyncVendor,
6439
+ isSharePointVendor: () => isSharePointVendor,
6440
+ listCatalog: () => listCatalog,
6441
+ listDriveFolderChildren: () => listDriveFolderChildren,
6442
+ listDriveFolders: () => listDriveFolders,
6443
+ listMailboxFolders: () => listMailboxFolders,
6444
+ listMine: () => listMine,
6445
+ mailboxSyncProgress: () => mailboxSyncProgress,
6446
+ slackStatus: () => slackStatus,
6447
+ triggerDriveSync: () => triggerDriveSync,
6448
+ triggerMailboxSync: () => triggerMailboxSync
6449
+ });
6450
+ var vendorPath = (vendor) => ({ path: { vendor } });
6451
+ var vendorKeyPath = (vendor) => ({
6452
+ path: { vendor_key: vendor }
6453
+ });
6454
+ async function listCatalog(arbi) {
6455
+ return requireData(await arbi.fetch.GET("/v1/connectors"), "Failed to load connectors");
6456
+ }
6457
+ async function listMine(arbi) {
6458
+ return requireData(await arbi.fetch.GET("/v1/connectors/me"), "Failed to load your connections");
6459
+ }
6460
+ async function disconnect(arbi, vendor) {
6461
+ requireOk(
6462
+ await arbi.fetch.DELETE("/v1/connectors/{vendor_key}", { params: vendorKeyPath(vendor) }),
6463
+ "Failed to disconnect"
6464
+ );
6465
+ }
6466
+ async function authorize(arbi, vendor, returnTo) {
6467
+ const data = requireData(
6468
+ await arbi.fetch.GET("/v1/connectors/{vendor_key}/authorize", {
6469
+ params: { ...vendorKeyPath(vendor), query: returnTo ? { return_to: returnTo } : {} }
6470
+ }),
6471
+ "Could not start the connection"
6472
+ );
6473
+ return data.url;
6474
+ }
6475
+ async function getSealedTokens(arbi) {
6476
+ return requireData(
6477
+ await arbi.fetch.GET("/v1/connectors/sealed-tokens"),
6478
+ "Failed to load connector tokens"
6479
+ );
6480
+ }
6481
+ async function depositSessionTokens(arbi, body) {
6482
+ requireOk(
6483
+ await arbi.fetch.POST("/v1/connectors/session-tokens", { body }),
6484
+ "Failed to bridge connector tokens"
6485
+ );
6486
+ }
6487
+ async function listMailboxFolders(arbi, vendor) {
6488
+ return requireData(
6489
+ await arbi.fetch.GET("/v1/connectors/{vendor}/folders", { params: vendorPath(vendor) }),
6490
+ "Failed to load folders"
6491
+ );
6492
+ }
6493
+ async function enableMailboxSync(arbi, vendor, body) {
6494
+ return requireData(
6495
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-sync", {
6496
+ params: vendorPath(vendor),
6497
+ body
6498
+ }),
6499
+ "Failed to enable sync"
6500
+ );
6501
+ }
6502
+ async function triggerMailboxSync(arbi, vendor, workspaceExtId) {
6503
+ return requireData(
6504
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync", {
6505
+ params: {
6506
+ ...vendorPath(vendor),
6507
+ query: workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}
6508
+ }
6509
+ }),
6510
+ "Failed to start the sync"
6511
+ );
6512
+ }
6513
+ async function mailboxSyncProgress(arbi, vendor, workspaceExtId) {
6514
+ return requireData(
6515
+ await arbi.fetch.GET("/v1/connectors/{vendor}/sync-progress", {
6516
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
6517
+ }),
6518
+ "Failed to read the sync progress"
6519
+ );
6520
+ }
6521
+ async function cancelMailboxSync(arbi, vendor, workspaceExtId) {
6522
+ requireOk(
6523
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync/cancel", {
6524
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
6525
+ }),
6526
+ "Failed to cancel the sync"
6527
+ );
6528
+ }
6529
+ async function listDriveFolders(arbi, vendor) {
6530
+ return requireData(
6531
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folders", { params: vendorPath(vendor) }),
6532
+ "Failed to load folders"
6533
+ );
6534
+ }
6535
+ async function listDriveFolderChildren(arbi, vendor, itemId) {
6536
+ return requireData(
6537
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-children", {
6538
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
6539
+ }),
6540
+ "Failed to load folders"
6541
+ );
6542
+ }
6543
+ async function driveFolderDocCount(arbi, vendor, itemId) {
6544
+ const data = requireData(
6545
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-doc-count", {
6546
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
6547
+ }),
6548
+ "Failed to count documents"
6549
+ );
6550
+ return data.count;
6551
+ }
6552
+ async function enableDriveSync(arbi, vendor, body) {
6553
+ requireOk(
6554
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-drive-sync", {
6555
+ params: vendorPath(vendor),
6556
+ body
6557
+ }),
6558
+ "Failed to enable sync"
6559
+ );
6560
+ }
6561
+ async function triggerDriveSync(arbi, vendor) {
6562
+ return requireData(
6563
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync", { params: vendorPath(vendor) }),
6564
+ "Failed to start the sync"
6565
+ );
6566
+ }
6567
+ async function driveSyncEstimate(arbi, vendor) {
6568
+ return requireData(
6569
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-estimate", {
6570
+ params: vendorPath(vendor)
6571
+ }),
6572
+ "Failed to estimate the sync"
6573
+ );
6574
+ }
6575
+ async function driveSyncProgress(arbi, vendor) {
6576
+ return requireData(
6577
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-progress", {
6578
+ params: vendorPath(vendor)
6579
+ }),
6580
+ "Failed to read the sync progress"
6581
+ );
6582
+ }
6583
+ async function cancelDriveSync(arbi, vendor) {
6584
+ requireOk(
6585
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync/cancel", {
6586
+ params: vendorPath(vendor)
6587
+ }),
6588
+ "Failed to cancel the sync"
6589
+ );
6590
+ }
6591
+ async function slackStatus(arbi) {
6592
+ return requireData(
6593
+ await arbi.fetch.GET("/v1/slack/me"),
6594
+ "Failed to load the Slack connection"
6595
+ );
6596
+ }
6597
+ async function authorizeSlack(arbi, agentExtId) {
6598
+ const data = requireData(
6599
+ await arbi.fetch.GET("/v1/slack/authorize", {
6600
+ params: { query: { agent_ext_id: agentExtId } }
6601
+ }),
6602
+ "Could not start Slack authorization"
6603
+ );
6604
+ return data.url;
6605
+ }
6606
+ async function disconnectSlack(arbi) {
6607
+ requireOk(await arbi.fetch.DELETE("/v1/slack/me"), "Failed to disconnect Slack");
6608
+ }
6609
+ var MAILBOX_SYNC_VENDORS = ["microsoft", "gmail"];
6610
+ var DRIVE_SYNC_VENDORS = [
6611
+ "microsoft",
6612
+ "gmail",
6613
+ "microsoft_sharepoint",
6614
+ "clio",
6615
+ "box",
6616
+ "dropbox",
6617
+ "onenote"
6618
+ ];
6619
+ var MICROSOFT_VENDORS = ["microsoft", "ms365_mail"];
6620
+ var GOOGLE_VENDORS = ["gmail", "gdrive"];
6621
+ var IMANAGE_VENDORS = ["imanage"];
6622
+ var SHAREPOINT_VENDORS = ["microsoft_sharepoint"];
6623
+ var includes = (list, vendor) => list.includes(vendor);
6624
+ var isMailboxSyncVendor = (vendor) => includes(MAILBOX_SYNC_VENDORS, vendor);
6625
+ var isDriveSyncVendor = (vendor) => includes(DRIVE_SYNC_VENDORS, vendor);
6626
+ var isSharePointVendor = (vendor) => includes(SHAREPOINT_VENDORS, vendor);
6627
+ function isConnectorVendorVisible(settings, vendor) {
6628
+ if (includes(MICROSOFT_VENDORS, vendor)) return settings?.show_connector_microsoft ?? true;
6629
+ if (includes(GOOGLE_VENDORS, vendor)) return settings?.show_connector_google ?? true;
6630
+ if (includes(IMANAGE_VENDORS, vendor)) return settings?.show_connector_imanage ?? false;
6631
+ if (includes(SHAREPOINT_VENDORS, vendor)) return settings?.show_connector_sharepoint ?? false;
6632
+ return true;
6633
+ }
6634
+ var CONNECT_ERROR_PRODUCTS = {
6635
+ microsoft: "Microsoft",
6636
+ microsoft_sharepoint: "SharePoint",
6637
+ gmail: "Google",
6638
+ gdrive: "Google Drive",
6639
+ imanage: "iManage",
6640
+ slack: "Slack"
6641
+ };
6642
+ function connectErrorMessage(vendor) {
6643
+ const product = vendor && CONNECT_ERROR_PRODUCTS[vendor] || "the account";
6644
+ return `Couldn't connect ${product}. The connection was cancelled or not approved.`;
6645
+ }
6646
+ async function bridgeConnectorTokens(arbi, keys, { vendor, autoSyncWorkspaceExtId } = {}) {
6647
+ await initSodium();
6648
+ const keypair = encryptionKeypairFromSigningKey(keys.signingPrivateKey);
6649
+ try {
6650
+ let sealed = await getSealedTokens(arbi);
6651
+ if (vendor) sealed = sealed.filter((token) => token.vendor_key === vendor);
6652
+ for (const token of sealed) {
6653
+ try {
6654
+ const reseal = async (wrapped) => {
6655
+ const plain = sealedBoxDecrypt(wrapped, keypair.secretKey);
6656
+ try {
6657
+ return await sealKeyForSession(plain, keys.serverSessionKey);
6658
+ } finally {
6659
+ plain.fill(0);
6660
+ }
6661
+ };
6662
+ await depositSessionTokens(arbi, {
6663
+ vendor_key: token.vendor_key,
6664
+ access: await reseal(token.access_token),
6665
+ refresh: token.refresh_token ? await reseal(token.refresh_token) : null,
6666
+ ...autoSyncWorkspaceExtId ? { auto_sync_workspace_ext_id: autoSyncWorkspaceExtId } : {}
6667
+ });
6668
+ } catch (err) {
6669
+ console.error("[connectors] Could not bridge the token of", token.vendor_key, err);
6670
+ }
6671
+ }
6672
+ } finally {
6673
+ keypair.secretKey.fill(0);
6674
+ }
6675
+ }
6676
+
6361
6677
  // src/operations/agentconfig.ts
6362
6678
  var agentconfig_exports = {};
6363
6679
  __export(agentconfig_exports, {
@@ -6641,6 +6957,11 @@ async function remove(arbi) {
6641
6957
  // src/operations/projects.ts
6642
6958
  var projects_exports = {};
6643
6959
  __export(projects_exports, {
6960
+ addAddonBlock: () => addAddonBlock,
6961
+ billingPortal: () => billingPortal,
6962
+ cancelSubscription: () => cancelSubscription,
6963
+ changePlan: () => changePlan,
6964
+ createCheckout: () => createCheckout,
6644
6965
  createProject: () => createProject,
6645
6966
  deleteProject: () => deleteProject,
6646
6967
  formatBudget: () => formatBudget,
@@ -6648,11 +6969,17 @@ __export(projects_exports, {
6648
6969
  getProjectInvoices: () => getProjectInvoices,
6649
6970
  getProjectUsage: () => getProjectUsage,
6650
6971
  getUserUsageToday: () => getUserUsageToday,
6972
+ listProducts: () => listProducts,
6651
6973
  listProjectEvents: () => listProjectEvents,
6652
6974
  listProjects: () => listProjects,
6653
6975
  parseBudget: () => parseBudget,
6976
+ previewPlanChange: () => previewPlanChange,
6977
+ quoteAddon: () => quoteAddon,
6978
+ quotePlan: () => quotePlan,
6654
6979
  refreshProject: () => refreshProject,
6655
6980
  renameProject: () => renameProject,
6981
+ setNextPeriodAddons: () => setNextPeriodAddons,
6982
+ updateAddonSettings: () => updateAddonSettings,
6656
6983
  updateProject: () => updateProject
6657
6984
  });
6658
6985
  async function listProjects(arbi, filters = {}) {
@@ -6775,6 +7102,95 @@ async function getProjectInvoices(arbi, projectExtId) {
6775
7102
  async function getUserUsageToday(arbi) {
6776
7103
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
6777
7104
  }
7105
+ var projectPath = (projectExtId) => ({ path: { project_ext_id: projectExtId } });
7106
+ async function listProducts(arbi) {
7107
+ return requireData(await arbi.fetch.GET("/v1/user/products"), "Failed to load the plans");
7108
+ }
7109
+ async function quotePlan(arbi, projectExtId, body) {
7110
+ return requireData(
7111
+ projectExtId ? await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout/quote", {
7112
+ params: projectPath(projectExtId),
7113
+ body
7114
+ }) : await arbi.fetch.POST("/v1/user/projects/quote", { body }),
7115
+ "Failed to price the plan"
7116
+ );
7117
+ }
7118
+ async function createCheckout(arbi, projectExtId, body) {
7119
+ return requireData(
7120
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout", {
7121
+ params: projectPath(projectExtId),
7122
+ body
7123
+ }),
7124
+ "Failed to start the checkout"
7125
+ );
7126
+ }
7127
+ async function changePlan(arbi, projectExtId, body) {
7128
+ return requireData(
7129
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/change-plan", {
7130
+ params: projectPath(projectExtId),
7131
+ body
7132
+ }),
7133
+ "Failed to change the plan"
7134
+ );
7135
+ }
7136
+ async function previewPlanChange(arbi, projectExtId, body) {
7137
+ return requireData(
7138
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/plan/preview", {
7139
+ params: projectPath(projectExtId),
7140
+ body
7141
+ }),
7142
+ "Failed to price the plan change"
7143
+ );
7144
+ }
7145
+ async function quoteAddon(arbi, projectExtId, kind) {
7146
+ return requireData(
7147
+ await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/addons/quote", {
7148
+ params: { ...projectPath(projectExtId), query: { kind } }
7149
+ }),
7150
+ "Failed to price the add-on"
7151
+ );
7152
+ }
7153
+ async function billingPortal(arbi, projectExtId) {
7154
+ return requireData(
7155
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/billing-portal", {
7156
+ params: projectPath(projectExtId)
7157
+ }),
7158
+ "Failed to open the billing portal"
7159
+ );
7160
+ }
7161
+ async function addAddonBlock(arbi, projectExtId, kind) {
7162
+ const params = projectPath(projectExtId);
7163
+ return requireData(
7164
+ kind === "ai_usage" ? await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/addons/ai-usage", { params }) : await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/addons/storage", { params }),
7165
+ "Failed to add the add-on"
7166
+ );
7167
+ }
7168
+ async function setNextPeriodAddons(arbi, projectExtId, body) {
7169
+ return requireData(
7170
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/next-period", {
7171
+ params: projectPath(projectExtId),
7172
+ body
7173
+ }),
7174
+ "Failed to change the add-ons"
7175
+ );
7176
+ }
7177
+ async function updateAddonSettings(arbi, projectExtId, body) {
7178
+ return requireData(
7179
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/settings", {
7180
+ params: projectPath(projectExtId),
7181
+ body
7182
+ }),
7183
+ "Failed to save the add-on settings"
7184
+ );
7185
+ }
7186
+ async function cancelSubscription(arbi, projectExtId) {
7187
+ return requireData(
7188
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/cancel", {
7189
+ params: projectPath(projectExtId)
7190
+ }),
7191
+ "Failed to cancel the subscription"
7192
+ );
7193
+ }
6778
7194
 
6779
7195
  // src/operations/work.ts
6780
7196
  var work_exports = {};
@@ -7866,10 +8282,8 @@ __export(calendar_exports, {
7866
8282
  cancelPublicBooking: () => cancelPublicBooking,
7867
8283
  connectCalDavAccount: () => connectCalDavAccount,
7868
8284
  connectOAuthAccount: () => connectOAuthAccount,
7869
- createAppPassword: () => createAppPassword,
7870
8285
  createCalendar: () => createCalendar,
7871
8286
  createEvent: () => createEvent,
7872
- createFeed: () => createFeed,
7873
8287
  createRoom: () => createRoom,
7874
8288
  decideCounter: () => decideCounter,
7875
8289
  deleteBookingPage: () => deleteBookingPage,
@@ -7886,7 +8300,6 @@ __export(calendar_exports, {
7886
8300
  getPublicBookingPage: () => getPublicBookingPage,
7887
8301
  importCalendarIcs: () => importCalendarIcs,
7888
8302
  listAccounts: () => listAccounts,
7889
- listAppPasswords: () => listAppPasswords,
7890
8303
  listBookingPages: () => listBookingPages,
7891
8304
  listCalDavProfiles: () => listCalDavProfiles,
7892
8305
  listCalendars: () => listCalendars,
@@ -7904,9 +8317,7 @@ __export(calendar_exports, {
7904
8317
  putCalendarSettings: () => putCalendarSettings,
7905
8318
  refreshCalendar: () => refreshCalendar,
7906
8319
  respondToEvent: () => respondToEvent,
7907
- revokeAppPassword: () => revokeAppPassword,
7908
8320
  shareCalendar: () => shareCalendar,
7909
- splitAppPasswords: () => splitAppPasswords,
7910
8321
  subscribeCalendar: () => subscribeCalendar,
7911
8322
  syncAccount: () => syncAccount,
7912
8323
  unlockCalendarKeys: () => unlockCalendarKeys,
@@ -8294,46 +8705,6 @@ async function publishCalendarToAccount(client, accId, calendarId) {
8294
8705
  "Publishing the calendar"
8295
8706
  );
8296
8707
  }
8297
- async function listAppPasswords(client) {
8298
- return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
8299
- }
8300
- async function createAppPassword(client, body) {
8301
- return take(
8302
- await client.fetch.POST("/v1/calendar/app-passwords", {
8303
- body: {
8304
- label: body.label.trim(),
8305
- calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
8306
- }
8307
- }),
8308
- "Creating the app password"
8309
- );
8310
- }
8311
- async function createFeed(client, body) {
8312
- return take(
8313
- await client.fetch.POST("/v1/calendar/feeds", {
8314
- body: {
8315
- calendar_id: body.calendar_id,
8316
- level: body.level,
8317
- label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
8318
- }
8319
- }),
8320
- "Creating the feed"
8321
- );
8322
- }
8323
- async function revokeAppPassword(client, apwId) {
8324
- take(
8325
- await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
8326
- params: { path: { apw_id: apwId } }
8327
- }),
8328
- "Revoking"
8329
- );
8330
- }
8331
- function splitAppPasswords(rows) {
8332
- return {
8333
- devices: rows.filter((r2) => r2.kind === "dav"),
8334
- feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
8335
- };
8336
- }
8337
8708
  async function listBookingPages(client) {
8338
8709
  return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8339
8710
  }
@@ -8702,7 +9073,23 @@ var Arbi = class {
8702
9073
  /** AI usage + spend breakdown for a project's billing period. */
8703
9074
  usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
8704
9075
  /** Stripe invoices for a project's subscription. */
8705
- invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId)
9076
+ invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId),
9077
+ /** Delete a project (only when empty: no workspaces, no subscription). */
9078
+ delete: (projectExtId) => deleteProject(this.requireClient(), projectExtId),
9079
+ /** The plans and add-ons on sale. */
9080
+ products: () => listProducts(this.requireClient()),
9081
+ /** The taxed total of a Pro purchase (a new project when `projectExtId` is null). */
9082
+ quotePlan: (projectExtId, body) => quotePlan(this.requireClient(), projectExtId, body),
9083
+ /** Start an embedded Stripe checkout; returns its `client_secret`. */
9084
+ checkout: (projectExtId, body) => createCheckout(this.requireClient(), projectExtId, body),
9085
+ changePlan: (projectExtId, body) => changePlan(this.requireClient(), projectExtId, body),
9086
+ previewPlanChange: (projectExtId, body) => previewPlanChange(this.requireClient(), projectExtId, body),
9087
+ quoteAddon: (projectExtId, kind) => quoteAddon(this.requireClient(), projectExtId, kind),
9088
+ billingPortal: (projectExtId) => billingPortal(this.requireClient(), projectExtId),
9089
+ addAddonBlock: (projectExtId, kind) => addAddonBlock(this.requireClient(), projectExtId, kind),
9090
+ setNextPeriodAddons: (projectExtId, body) => setNextPeriodAddons(this.requireClient(), projectExtId, body),
9091
+ updateAddonSettings: (projectExtId, body) => updateAddonSettings(this.requireClient(), projectExtId, body),
9092
+ cancelSubscription: (projectExtId) => cancelSubscription(this.requireClient(), projectExtId)
8706
9093
  };
8707
9094
  // ── User (account-scoped usage) ───────────────────────────────────────
8708
9095
  user = {
@@ -8848,6 +9235,8 @@ var Arbi = class {
8848
9235
  }
8849
9236
  // ── Workspaces ────────────────────────────────────────────────────────
8850
9237
  workspaces = {
9238
+ /** Hand this server session a workspace's key (sealed to the session) without opening it. */
9239
+ primeKey: (workspaceExtId, sessionSealedKey) => primeWorkspaceKey(this.requireClient(), workspaceExtId, sessionSealedKey),
8851
9240
  list: async () => this.rememberWorkspaces(await listWorkspaces(this.requireClient())),
8852
9241
  create: async (name, projectExtId, description, isPublic) => {
8853
9242
  const client = this.requireClient();
@@ -9192,7 +9581,8 @@ var Arbi = class {
9192
9581
  /** The skills the caller can run (own + shared marketplace), metadata only. */
9193
9582
  listSkills: (options) => listSkills(this.requireClient(), options),
9194
9583
  /**
9195
- * Search documents without LLM generation (retrieval only).
9584
+ * Search documents without LLM generation (retrieval only). No `docIds` searches the whole
9585
+ * workspace; `searchChunks(result)` ranks the passages found.
9196
9586
  */
9197
9587
  retrieve: (query, docIds, options) => retrieve({
9198
9588
  arbi: this.requireClient(),
@@ -9322,10 +9712,6 @@ var Arbi = class {
9322
9712
  syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9323
9713
  disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9324
9714
  publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
9325
- listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
9326
- createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
9327
- createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
9328
- revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
9329
9715
  listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9330
9716
  putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9331
9717
  deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
@@ -9438,6 +9824,49 @@ var Arbi = class {
9438
9824
  /** List the current user's durable activity feed. */
9439
9825
  listActivity: (options) => listActivity(this.requireClient(), options)
9440
9826
  };
9827
+ // ── Connectors ────────────────────────────────────────────────────────
9828
+ /**
9829
+ * Connectors: the catalog, the user's connections and their OAuth, mailbox and drive sync,
9830
+ * Slack. A vendor is its `vendor_key` (e.g. `microsoft`, `gmail`).
9831
+ */
9832
+ connectors = {
9833
+ catalog: () => listCatalog(this.requireClient()),
9834
+ mine: () => listMine(this.requireClient()),
9835
+ disconnect: (vendor) => disconnect(this.requireClient(), vendor),
9836
+ /** The provider consent URL; the OAuth comes back to `returnTo` (a path of this app). */
9837
+ authorize: (vendor, returnTo) => authorize(this.requireClient(), vendor, returnTo),
9838
+ /**
9839
+ * Let this server session use the user's connector grants (best effort: a failure is logged,
9840
+ * never thrown, so it cannot break a sign-in or a connect). Signed out: nothing to bridge.
9841
+ */
9842
+ bridgeTokens: async (options) => {
9843
+ const login = this.loginResult;
9844
+ if (!login) return;
9845
+ try {
9846
+ await bridgeConnectorTokens(this.requireClient(), login, options);
9847
+ } catch (err) {
9848
+ console.error("[connectors] Token bridge failed", err);
9849
+ }
9850
+ },
9851
+ mailboxFolders: (vendor) => listMailboxFolders(this.requireClient(), vendor),
9852
+ enableMailboxSync: (vendor, body) => enableMailboxSync(this.requireClient(), vendor, body),
9853
+ syncMailbox: (vendor, workspaceExtId) => triggerMailboxSync(this.requireClient(), vendor, workspaceExtId),
9854
+ mailboxSyncProgress: (vendor, workspaceExtId) => mailboxSyncProgress(this.requireClient(), vendor, workspaceExtId),
9855
+ cancelMailboxSync: (vendor, workspaceExtId) => cancelMailboxSync(this.requireClient(), vendor, workspaceExtId),
9856
+ driveFolders: (vendor) => listDriveFolders(this.requireClient(), vendor),
9857
+ driveFolderChildren: (vendor, itemId) => listDriveFolderChildren(this.requireClient(), vendor, itemId),
9858
+ driveFolderDocCount: (vendor, itemId) => driveFolderDocCount(this.requireClient(), vendor, itemId),
9859
+ enableDriveSync: (vendor, body) => enableDriveSync(this.requireClient(), vendor, body),
9860
+ syncDrive: (vendor) => triggerDriveSync(this.requireClient(), vendor),
9861
+ driveSyncEstimate: (vendor) => driveSyncEstimate(this.requireClient(), vendor),
9862
+ driveSyncProgress: (vendor) => driveSyncProgress(this.requireClient(), vendor),
9863
+ cancelDriveSync: (vendor) => cancelDriveSync(this.requireClient(), vendor),
9864
+ slack: {
9865
+ status: () => slackStatus(this.requireClient()),
9866
+ authorize: (agentExtId) => authorizeSlack(this.requireClient(), agentExtId),
9867
+ disconnect: () => disconnectSlack(this.requireClient())
9868
+ }
9869
+ };
9441
9870
  // ── Settings ──────────────────────────────────────────────────────────
9442
9871
  settings = {
9443
9872
  get: () => getSettings(this.requireClient()),
@@ -9597,6 +10026,6 @@ var Arbi = class {
9597
10026
  }
9598
10027
  };
9599
10028
 
9600
- export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, DEFAULT_AI_USD_PER_GBP, FLAT_TAG_KINDS, PlanStepsError, PublicBookingError, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, calendar_exports as calendar, cancelPublicBooking, chats_exports as chats, connectWebSocket, connectWithReconnect, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, health_exports as health, house_template_exports as houseTemplates, identityErrorCode, identity_exports as identityVerification, mail_exports as mail, notifications_exports as notifications, 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, splitAppPasswords, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
10029
+ export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, DEFAULT_AI_USD_PER_GBP, DRIVE_SYNC_VENDORS, FLAT_TAG_KINDS, GOOGLE_VENDORS, IMANAGE_VENDORS, MAILBOX_SYNC_VENDORS, MAX_RETRIEVE_DOC_IDS, MICROSOFT_VENDORS, PlanStepsError, PublicBookingError, SHAREPOINT_VENDORS, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, buildFactsContextTool, buildRetrievalChunkTool, buildRetrievalFullContextTool, buildRetrievalTocTool, calendar_exports as calendar, cancelPublicBooking, chats_exports as chats, connectErrorMessage, connectWebSocket, connectWithReconnect, connectors_exports as connectors, consumeSSEStream, contacts_exports as contacts, conversations_exports as conversations, countCitations, createAuthenticatedClient, doctags_exports as doctags, documents_exports as documents, facts_exports as facts, files_exports as files, filterSkills, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatUserName, formatWorkspaceChoices, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, health_exports as health, house_template_exports as houseTemplates, identityErrorCode, identity_exports as identityVerification, isConnectorVendorVisible, isDriveSyncVendor, isMailboxSyncVendor, isSharePointVendor, mail_exports as mail, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, profile_exports as profile, projects_exports as projects, requireData, requireOk, resolveAuth, resolveCitations, resolveWorkspace, responses_exports as responses, searchChunks, selectWorkspace, selectWorkspaceById, sessions_exports as sessions, settings_exports as settings, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
9601
10030
  //# sourceMappingURL=browser.js.map
9602
10031
  //# sourceMappingURL=browser.js.map