@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.cjs CHANGED
@@ -3529,7 +3529,7 @@ function requireData(result, message) {
3529
3529
  }
3530
3530
  function requireOk(result, message) {
3531
3531
  if (result.error) {
3532
- throw new ArbiApiError(message, result.error);
3532
+ throw new ArbiApiError(message, result.error, result.response?.status);
3533
3533
  }
3534
3534
  }
3535
3535
  function getErrorMessage(err) {
@@ -4972,6 +4972,7 @@ __export(workspaces_exports, {
4972
4972
  grantTemporaryWorkspaceAccess: () => grantTemporaryWorkspaceAccess,
4973
4973
  listWorkspaceUsers: () => listWorkspaceUsers,
4974
4974
  listWorkspaces: () => listWorkspaces,
4975
+ primeWorkspaceKey: () => primeWorkspaceKey,
4975
4976
  removeWorkspaceUsers: () => removeWorkspaceUsers,
4976
4977
  setUserRole: () => setUserRole,
4977
4978
  updateWorkspace: () => updateWorkspace
@@ -5078,6 +5079,15 @@ async function getWorkspaceActivity(arbi, workspaceExtId, options = {}) {
5078
5079
  "Failed to fetch workspace activity"
5079
5080
  );
5080
5081
  }
5082
+ async function primeWorkspaceKey(arbi, workspaceExtId, sessionSealedKey) {
5083
+ requireOk(
5084
+ await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/prime-key", {
5085
+ params: { path: { workspace_ext_id: workspaceExtId } },
5086
+ body: { workspace_key: sessionSealedKey }
5087
+ }),
5088
+ "Failed to prime the workspace key"
5089
+ );
5090
+ }
5081
5091
 
5082
5092
  // src/operations/conversations.ts
5083
5093
  var conversations_exports = {};
@@ -5156,6 +5166,7 @@ async function updateConversationAssistantMode(arbi, conversationId, assistantMo
5156
5166
  // src/operations/assistant.ts
5157
5167
  var assistant_exports = {};
5158
5168
  __export(assistant_exports, {
5169
+ MAX_RETRIEVE_DOC_IDS: () => MAX_RETRIEVE_DOC_IDS,
5159
5170
  buildFactsContextTool: () => buildFactsContextTool,
5160
5171
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
5161
5172
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
@@ -5170,6 +5181,7 @@ __export(assistant_exports, {
5170
5181
  queryAssistant: () => queryAssistant,
5171
5182
  respondToAgent: () => respondToAgent,
5172
5183
  retrieve: () => retrieve,
5184
+ searchChunks: () => searchChunks,
5173
5185
  uploadSkill: () => uploadSkill
5174
5186
  });
5175
5187
  function buildRetrievalChunkTool(docIds, searchMode) {
@@ -5203,8 +5215,19 @@ function buildRetrievalTocTool(docIds) {
5203
5215
  tool_responses: {}
5204
5216
  };
5205
5217
  }
5218
+ var MAX_RETRIEVE_DOC_IDS = 5e3;
5206
5219
  async function retrieve(options) {
5207
- const { arbi, workspaceId, query, docIds, searchMode, fullContextDocIds, tocDocIds, model } = options;
5220
+ const {
5221
+ arbi,
5222
+ workspaceId,
5223
+ query,
5224
+ docIds,
5225
+ searchMode,
5226
+ fullContextDocIds,
5227
+ tocDocIds,
5228
+ model,
5229
+ store = true
5230
+ } = options;
5208
5231
  const tools = {
5209
5232
  retrieval_chunk: buildRetrievalChunkTool(docIds, searchMode)
5210
5233
  };
@@ -5219,7 +5242,7 @@ async function retrieve(options) {
5219
5242
  workspace_ext_id: workspaceId,
5220
5243
  stream: false,
5221
5244
  background: false,
5222
- store: true,
5245
+ store,
5223
5246
  tools,
5224
5247
  ...model ? { model } : {}
5225
5248
  };
@@ -5239,6 +5262,34 @@ async function retrieve(options) {
5239
5262
  }
5240
5263
  return data;
5241
5264
  }
5265
+ function isReadablePassage(content) {
5266
+ return content.length > 10 && content !== "-" && !/^[|\-\s]+$/.test(content);
5267
+ }
5268
+ function searchChunks(result) {
5269
+ const byId3 = /* @__PURE__ */ new Map();
5270
+ for (const [title, chunks] of Object.entries(result?.retrieval_chunk?.tool_responses ?? {})) {
5271
+ if (!Array.isArray(chunks)) continue;
5272
+ chunks.forEach((chunk, index) => {
5273
+ if (!chunk || typeof chunk !== "object") return;
5274
+ const content = chunk.content?.trim() ?? "";
5275
+ if (!isReadablePassage(content)) return;
5276
+ const meta = chunk.metadata ?? {};
5277
+ const docId = meta.doc_ext_id || title;
5278
+ const rerank = meta.rerank_score;
5279
+ byId3.set(meta.chunk_ext_id || `${docId}_${index}`, {
5280
+ id: meta.chunk_ext_id || `${docId}_${index}`,
5281
+ ...meta.chunk_ext_id ? { chunkExtId: meta.chunk_ext_id } : {},
5282
+ docId,
5283
+ docTitle: meta.doc_title || title,
5284
+ ...meta.page_number != null ? { page: meta.page_number } : {},
5285
+ score: rerank && rerank > 0 ? rerank : meta.score ?? 0,
5286
+ index,
5287
+ content
5288
+ });
5289
+ });
5290
+ }
5291
+ return Array.from(byId3.values()).sort((a2, b2) => b2.score - a2.score);
5292
+ }
5242
5293
  async function queryAssistant(options) {
5243
5294
  const {
5244
5295
  workspaceId,
@@ -6361,6 +6412,271 @@ async function setWorkspaceNotificationLevel(arbi, workspaceId, level) {
6361
6412
  return patch;
6362
6413
  }
6363
6414
 
6415
+ // src/operations/connectors.ts
6416
+ var connectors_exports = {};
6417
+ __export(connectors_exports, {
6418
+ DRIVE_SYNC_VENDORS: () => DRIVE_SYNC_VENDORS,
6419
+ GOOGLE_VENDORS: () => GOOGLE_VENDORS,
6420
+ IMANAGE_VENDORS: () => IMANAGE_VENDORS,
6421
+ MAILBOX_SYNC_VENDORS: () => MAILBOX_SYNC_VENDORS,
6422
+ MICROSOFT_VENDORS: () => MICROSOFT_VENDORS,
6423
+ SHAREPOINT_VENDORS: () => SHAREPOINT_VENDORS,
6424
+ authorize: () => authorize,
6425
+ authorizeSlack: () => authorizeSlack,
6426
+ bridgeConnectorTokens: () => bridgeConnectorTokens,
6427
+ cancelDriveSync: () => cancelDriveSync,
6428
+ cancelMailboxSync: () => cancelMailboxSync,
6429
+ connectErrorMessage: () => connectErrorMessage,
6430
+ depositSessionTokens: () => depositSessionTokens,
6431
+ disconnect: () => disconnect,
6432
+ disconnectSlack: () => disconnectSlack,
6433
+ driveFolderDocCount: () => driveFolderDocCount,
6434
+ driveSyncEstimate: () => driveSyncEstimate,
6435
+ driveSyncProgress: () => driveSyncProgress,
6436
+ enableDriveSync: () => enableDriveSync,
6437
+ enableMailboxSync: () => enableMailboxSync,
6438
+ getSealedTokens: () => getSealedTokens,
6439
+ isConnectorVendorVisible: () => isConnectorVendorVisible,
6440
+ isDriveSyncVendor: () => isDriveSyncVendor,
6441
+ isMailboxSyncVendor: () => isMailboxSyncVendor,
6442
+ isSharePointVendor: () => isSharePointVendor,
6443
+ listCatalog: () => listCatalog,
6444
+ listDriveFolderChildren: () => listDriveFolderChildren,
6445
+ listDriveFolders: () => listDriveFolders,
6446
+ listMailboxFolders: () => listMailboxFolders,
6447
+ listMine: () => listMine,
6448
+ mailboxSyncProgress: () => mailboxSyncProgress,
6449
+ slackStatus: () => slackStatus,
6450
+ triggerDriveSync: () => triggerDriveSync,
6451
+ triggerMailboxSync: () => triggerMailboxSync
6452
+ });
6453
+ var vendorPath = (vendor) => ({ path: { vendor } });
6454
+ var vendorKeyPath = (vendor) => ({
6455
+ path: { vendor_key: vendor }
6456
+ });
6457
+ async function listCatalog(arbi) {
6458
+ return requireData(await arbi.fetch.GET("/v1/connectors"), "Failed to load connectors");
6459
+ }
6460
+ async function listMine(arbi) {
6461
+ return requireData(await arbi.fetch.GET("/v1/connectors/me"), "Failed to load your connections");
6462
+ }
6463
+ async function disconnect(arbi, vendor) {
6464
+ requireOk(
6465
+ await arbi.fetch.DELETE("/v1/connectors/{vendor_key}", { params: vendorKeyPath(vendor) }),
6466
+ "Failed to disconnect"
6467
+ );
6468
+ }
6469
+ async function authorize(arbi, vendor, returnTo) {
6470
+ const data = requireData(
6471
+ await arbi.fetch.GET("/v1/connectors/{vendor_key}/authorize", {
6472
+ params: { ...vendorKeyPath(vendor), query: returnTo ? { return_to: returnTo } : {} }
6473
+ }),
6474
+ "Could not start the connection"
6475
+ );
6476
+ return data.url;
6477
+ }
6478
+ async function getSealedTokens(arbi) {
6479
+ return requireData(
6480
+ await arbi.fetch.GET("/v1/connectors/sealed-tokens"),
6481
+ "Failed to load connector tokens"
6482
+ );
6483
+ }
6484
+ async function depositSessionTokens(arbi, body) {
6485
+ requireOk(
6486
+ await arbi.fetch.POST("/v1/connectors/session-tokens", { body }),
6487
+ "Failed to bridge connector tokens"
6488
+ );
6489
+ }
6490
+ async function listMailboxFolders(arbi, vendor) {
6491
+ return requireData(
6492
+ await arbi.fetch.GET("/v1/connectors/{vendor}/folders", { params: vendorPath(vendor) }),
6493
+ "Failed to load folders"
6494
+ );
6495
+ }
6496
+ async function enableMailboxSync(arbi, vendor, body) {
6497
+ return requireData(
6498
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-sync", {
6499
+ params: vendorPath(vendor),
6500
+ body
6501
+ }),
6502
+ "Failed to enable sync"
6503
+ );
6504
+ }
6505
+ async function triggerMailboxSync(arbi, vendor, workspaceExtId) {
6506
+ return requireData(
6507
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync", {
6508
+ params: {
6509
+ ...vendorPath(vendor),
6510
+ query: workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}
6511
+ }
6512
+ }),
6513
+ "Failed to start the sync"
6514
+ );
6515
+ }
6516
+ async function mailboxSyncProgress(arbi, vendor, workspaceExtId) {
6517
+ return requireData(
6518
+ await arbi.fetch.GET("/v1/connectors/{vendor}/sync-progress", {
6519
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
6520
+ }),
6521
+ "Failed to read the sync progress"
6522
+ );
6523
+ }
6524
+ async function cancelMailboxSync(arbi, vendor, workspaceExtId) {
6525
+ requireOk(
6526
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync/cancel", {
6527
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
6528
+ }),
6529
+ "Failed to cancel the sync"
6530
+ );
6531
+ }
6532
+ async function listDriveFolders(arbi, vendor) {
6533
+ return requireData(
6534
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folders", { params: vendorPath(vendor) }),
6535
+ "Failed to load folders"
6536
+ );
6537
+ }
6538
+ async function listDriveFolderChildren(arbi, vendor, itemId) {
6539
+ return requireData(
6540
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-children", {
6541
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
6542
+ }),
6543
+ "Failed to load folders"
6544
+ );
6545
+ }
6546
+ async function driveFolderDocCount(arbi, vendor, itemId) {
6547
+ const data = requireData(
6548
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-doc-count", {
6549
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
6550
+ }),
6551
+ "Failed to count documents"
6552
+ );
6553
+ return data.count;
6554
+ }
6555
+ async function enableDriveSync(arbi, vendor, body) {
6556
+ requireOk(
6557
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-drive-sync", {
6558
+ params: vendorPath(vendor),
6559
+ body
6560
+ }),
6561
+ "Failed to enable sync"
6562
+ );
6563
+ }
6564
+ async function triggerDriveSync(arbi, vendor) {
6565
+ return requireData(
6566
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync", { params: vendorPath(vendor) }),
6567
+ "Failed to start the sync"
6568
+ );
6569
+ }
6570
+ async function driveSyncEstimate(arbi, vendor) {
6571
+ return requireData(
6572
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-estimate", {
6573
+ params: vendorPath(vendor)
6574
+ }),
6575
+ "Failed to estimate the sync"
6576
+ );
6577
+ }
6578
+ async function driveSyncProgress(arbi, vendor) {
6579
+ return requireData(
6580
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-progress", {
6581
+ params: vendorPath(vendor)
6582
+ }),
6583
+ "Failed to read the sync progress"
6584
+ );
6585
+ }
6586
+ async function cancelDriveSync(arbi, vendor) {
6587
+ requireOk(
6588
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync/cancel", {
6589
+ params: vendorPath(vendor)
6590
+ }),
6591
+ "Failed to cancel the sync"
6592
+ );
6593
+ }
6594
+ async function slackStatus(arbi) {
6595
+ return requireData(
6596
+ await arbi.fetch.GET("/v1/slack/me"),
6597
+ "Failed to load the Slack connection"
6598
+ );
6599
+ }
6600
+ async function authorizeSlack(arbi, agentExtId) {
6601
+ const data = requireData(
6602
+ await arbi.fetch.GET("/v1/slack/authorize", {
6603
+ params: { query: { agent_ext_id: agentExtId } }
6604
+ }),
6605
+ "Could not start Slack authorization"
6606
+ );
6607
+ return data.url;
6608
+ }
6609
+ async function disconnectSlack(arbi) {
6610
+ requireOk(await arbi.fetch.DELETE("/v1/slack/me"), "Failed to disconnect Slack");
6611
+ }
6612
+ var MAILBOX_SYNC_VENDORS = ["microsoft", "gmail"];
6613
+ var DRIVE_SYNC_VENDORS = [
6614
+ "microsoft",
6615
+ "gmail",
6616
+ "microsoft_sharepoint",
6617
+ "clio",
6618
+ "box",
6619
+ "dropbox",
6620
+ "onenote"
6621
+ ];
6622
+ var MICROSOFT_VENDORS = ["microsoft", "ms365_mail"];
6623
+ var GOOGLE_VENDORS = ["gmail", "gdrive"];
6624
+ var IMANAGE_VENDORS = ["imanage"];
6625
+ var SHAREPOINT_VENDORS = ["microsoft_sharepoint"];
6626
+ var includes = (list, vendor) => list.includes(vendor);
6627
+ var isMailboxSyncVendor = (vendor) => includes(MAILBOX_SYNC_VENDORS, vendor);
6628
+ var isDriveSyncVendor = (vendor) => includes(DRIVE_SYNC_VENDORS, vendor);
6629
+ var isSharePointVendor = (vendor) => includes(SHAREPOINT_VENDORS, vendor);
6630
+ function isConnectorVendorVisible(settings, vendor) {
6631
+ if (includes(MICROSOFT_VENDORS, vendor)) return settings?.show_connector_microsoft ?? true;
6632
+ if (includes(GOOGLE_VENDORS, vendor)) return settings?.show_connector_google ?? true;
6633
+ if (includes(IMANAGE_VENDORS, vendor)) return settings?.show_connector_imanage ?? false;
6634
+ if (includes(SHAREPOINT_VENDORS, vendor)) return settings?.show_connector_sharepoint ?? false;
6635
+ return true;
6636
+ }
6637
+ var CONNECT_ERROR_PRODUCTS = {
6638
+ microsoft: "Microsoft",
6639
+ microsoft_sharepoint: "SharePoint",
6640
+ gmail: "Google",
6641
+ gdrive: "Google Drive",
6642
+ imanage: "iManage",
6643
+ slack: "Slack"
6644
+ };
6645
+ function connectErrorMessage(vendor) {
6646
+ const product = vendor && CONNECT_ERROR_PRODUCTS[vendor] || "the account";
6647
+ return `Couldn't connect ${product}. The connection was cancelled or not approved.`;
6648
+ }
6649
+ async function bridgeConnectorTokens(arbi, keys, { vendor, autoSyncWorkspaceExtId } = {}) {
6650
+ await client.initSodium();
6651
+ const keypair = client.encryptionKeypairFromSigningKey(keys.signingPrivateKey);
6652
+ try {
6653
+ let sealed = await getSealedTokens(arbi);
6654
+ if (vendor) sealed = sealed.filter((token) => token.vendor_key === vendor);
6655
+ for (const token of sealed) {
6656
+ try {
6657
+ const reseal = async (wrapped) => {
6658
+ const plain = client.sealedBoxDecrypt(wrapped, keypair.secretKey);
6659
+ try {
6660
+ return await client.sealKeyForSession(plain, keys.serverSessionKey);
6661
+ } finally {
6662
+ plain.fill(0);
6663
+ }
6664
+ };
6665
+ await depositSessionTokens(arbi, {
6666
+ vendor_key: token.vendor_key,
6667
+ access: await reseal(token.access_token),
6668
+ refresh: token.refresh_token ? await reseal(token.refresh_token) : null,
6669
+ ...autoSyncWorkspaceExtId ? { auto_sync_workspace_ext_id: autoSyncWorkspaceExtId } : {}
6670
+ });
6671
+ } catch (err) {
6672
+ console.error("[connectors] Could not bridge the token of", token.vendor_key, err);
6673
+ }
6674
+ }
6675
+ } finally {
6676
+ keypair.secretKey.fill(0);
6677
+ }
6678
+ }
6679
+
6364
6680
  // src/operations/agentconfig.ts
6365
6681
  var agentconfig_exports = {};
6366
6682
  __export(agentconfig_exports, {
@@ -6644,6 +6960,11 @@ async function remove(arbi) {
6644
6960
  // src/operations/projects.ts
6645
6961
  var projects_exports = {};
6646
6962
  __export(projects_exports, {
6963
+ addAddonBlock: () => addAddonBlock,
6964
+ billingPortal: () => billingPortal,
6965
+ cancelSubscription: () => cancelSubscription,
6966
+ changePlan: () => changePlan,
6967
+ createCheckout: () => createCheckout,
6647
6968
  createProject: () => createProject,
6648
6969
  deleteProject: () => deleteProject,
6649
6970
  formatBudget: () => formatBudget,
@@ -6651,11 +6972,17 @@ __export(projects_exports, {
6651
6972
  getProjectInvoices: () => getProjectInvoices,
6652
6973
  getProjectUsage: () => getProjectUsage,
6653
6974
  getUserUsageToday: () => getUserUsageToday,
6975
+ listProducts: () => listProducts,
6654
6976
  listProjectEvents: () => listProjectEvents,
6655
6977
  listProjects: () => listProjects,
6656
6978
  parseBudget: () => parseBudget,
6979
+ previewPlanChange: () => previewPlanChange,
6980
+ quoteAddon: () => quoteAddon,
6981
+ quotePlan: () => quotePlan,
6657
6982
  refreshProject: () => refreshProject,
6658
6983
  renameProject: () => renameProject,
6984
+ setNextPeriodAddons: () => setNextPeriodAddons,
6985
+ updateAddonSettings: () => updateAddonSettings,
6659
6986
  updateProject: () => updateProject
6660
6987
  });
6661
6988
  async function listProjects(arbi, filters = {}) {
@@ -6778,6 +7105,95 @@ async function getProjectInvoices(arbi, projectExtId) {
6778
7105
  async function getUserUsageToday(arbi) {
6779
7106
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
6780
7107
  }
7108
+ var projectPath = (projectExtId) => ({ path: { project_ext_id: projectExtId } });
7109
+ async function listProducts(arbi) {
7110
+ return requireData(await arbi.fetch.GET("/v1/user/products"), "Failed to load the plans");
7111
+ }
7112
+ async function quotePlan(arbi, projectExtId, body) {
7113
+ return requireData(
7114
+ projectExtId ? await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout/quote", {
7115
+ params: projectPath(projectExtId),
7116
+ body
7117
+ }) : await arbi.fetch.POST("/v1/user/projects/quote", { body }),
7118
+ "Failed to price the plan"
7119
+ );
7120
+ }
7121
+ async function createCheckout(arbi, projectExtId, body) {
7122
+ return requireData(
7123
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout", {
7124
+ params: projectPath(projectExtId),
7125
+ body
7126
+ }),
7127
+ "Failed to start the checkout"
7128
+ );
7129
+ }
7130
+ async function changePlan(arbi, projectExtId, body) {
7131
+ return requireData(
7132
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/change-plan", {
7133
+ params: projectPath(projectExtId),
7134
+ body
7135
+ }),
7136
+ "Failed to change the plan"
7137
+ );
7138
+ }
7139
+ async function previewPlanChange(arbi, projectExtId, body) {
7140
+ return requireData(
7141
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/plan/preview", {
7142
+ params: projectPath(projectExtId),
7143
+ body
7144
+ }),
7145
+ "Failed to price the plan change"
7146
+ );
7147
+ }
7148
+ async function quoteAddon(arbi, projectExtId, kind) {
7149
+ return requireData(
7150
+ await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/addons/quote", {
7151
+ params: { ...projectPath(projectExtId), query: { kind } }
7152
+ }),
7153
+ "Failed to price the add-on"
7154
+ );
7155
+ }
7156
+ async function billingPortal(arbi, projectExtId) {
7157
+ return requireData(
7158
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/billing-portal", {
7159
+ params: projectPath(projectExtId)
7160
+ }),
7161
+ "Failed to open the billing portal"
7162
+ );
7163
+ }
7164
+ async function addAddonBlock(arbi, projectExtId, kind) {
7165
+ const params = projectPath(projectExtId);
7166
+ return requireData(
7167
+ 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 }),
7168
+ "Failed to add the add-on"
7169
+ );
7170
+ }
7171
+ async function setNextPeriodAddons(arbi, projectExtId, body) {
7172
+ return requireData(
7173
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/next-period", {
7174
+ params: projectPath(projectExtId),
7175
+ body
7176
+ }),
7177
+ "Failed to change the add-ons"
7178
+ );
7179
+ }
7180
+ async function updateAddonSettings(arbi, projectExtId, body) {
7181
+ return requireData(
7182
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/settings", {
7183
+ params: projectPath(projectExtId),
7184
+ body
7185
+ }),
7186
+ "Failed to save the add-on settings"
7187
+ );
7188
+ }
7189
+ async function cancelSubscription(arbi, projectExtId) {
7190
+ return requireData(
7191
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/cancel", {
7192
+ params: projectPath(projectExtId)
7193
+ }),
7194
+ "Failed to cancel the subscription"
7195
+ );
7196
+ }
6781
7197
 
6782
7198
  // src/operations/work.ts
6783
7199
  var work_exports = {};
@@ -7869,10 +8285,8 @@ __export(calendar_exports, {
7869
8285
  cancelPublicBooking: () => cancelPublicBooking,
7870
8286
  connectCalDavAccount: () => connectCalDavAccount,
7871
8287
  connectOAuthAccount: () => connectOAuthAccount,
7872
- createAppPassword: () => createAppPassword,
7873
8288
  createCalendar: () => createCalendar,
7874
8289
  createEvent: () => createEvent,
7875
- createFeed: () => createFeed,
7876
8290
  createRoom: () => createRoom,
7877
8291
  decideCounter: () => decideCounter,
7878
8292
  deleteBookingPage: () => deleteBookingPage,
@@ -7889,7 +8303,6 @@ __export(calendar_exports, {
7889
8303
  getPublicBookingPage: () => getPublicBookingPage,
7890
8304
  importCalendarIcs: () => importCalendarIcs,
7891
8305
  listAccounts: () => listAccounts,
7892
- listAppPasswords: () => listAppPasswords,
7893
8306
  listBookingPages: () => listBookingPages,
7894
8307
  listCalDavProfiles: () => listCalDavProfiles,
7895
8308
  listCalendars: () => listCalendars,
@@ -7907,9 +8320,7 @@ __export(calendar_exports, {
7907
8320
  putCalendarSettings: () => putCalendarSettings,
7908
8321
  refreshCalendar: () => refreshCalendar,
7909
8322
  respondToEvent: () => respondToEvent,
7910
- revokeAppPassword: () => revokeAppPassword,
7911
8323
  shareCalendar: () => shareCalendar,
7912
- splitAppPasswords: () => splitAppPasswords,
7913
8324
  subscribeCalendar: () => subscribeCalendar,
7914
8325
  syncAccount: () => syncAccount,
7915
8326
  unlockCalendarKeys: () => unlockCalendarKeys,
@@ -8297,46 +8708,6 @@ async function publishCalendarToAccount(client, accId, calendarId) {
8297
8708
  "Publishing the calendar"
8298
8709
  );
8299
8710
  }
8300
- async function listAppPasswords(client) {
8301
- return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
8302
- }
8303
- async function createAppPassword(client, body) {
8304
- return take(
8305
- await client.fetch.POST("/v1/calendar/app-passwords", {
8306
- body: {
8307
- label: body.label.trim(),
8308
- calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
8309
- }
8310
- }),
8311
- "Creating the app password"
8312
- );
8313
- }
8314
- async function createFeed(client, body) {
8315
- return take(
8316
- await client.fetch.POST("/v1/calendar/feeds", {
8317
- body: {
8318
- calendar_id: body.calendar_id,
8319
- level: body.level,
8320
- label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
8321
- }
8322
- }),
8323
- "Creating the feed"
8324
- );
8325
- }
8326
- async function revokeAppPassword(client, apwId) {
8327
- take(
8328
- await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
8329
- params: { path: { apw_id: apwId } }
8330
- }),
8331
- "Revoking"
8332
- );
8333
- }
8334
- function splitAppPasswords(rows) {
8335
- return {
8336
- devices: rows.filter((r2) => r2.kind === "dav"),
8337
- feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
8338
- };
8339
- }
8340
8711
  async function listBookingPages(client) {
8341
8712
  return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8342
8713
  }
@@ -8705,7 +9076,23 @@ var Arbi = class {
8705
9076
  /** AI usage + spend breakdown for a project's billing period. */
8706
9077
  usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
8707
9078
  /** Stripe invoices for a project's subscription. */
8708
- invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId)
9079
+ invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId),
9080
+ /** Delete a project (only when empty: no workspaces, no subscription). */
9081
+ delete: (projectExtId) => deleteProject(this.requireClient(), projectExtId),
9082
+ /** The plans and add-ons on sale. */
9083
+ products: () => listProducts(this.requireClient()),
9084
+ /** The taxed total of a Pro purchase (a new project when `projectExtId` is null). */
9085
+ quotePlan: (projectExtId, body) => quotePlan(this.requireClient(), projectExtId, body),
9086
+ /** Start an embedded Stripe checkout; returns its `client_secret`. */
9087
+ checkout: (projectExtId, body) => createCheckout(this.requireClient(), projectExtId, body),
9088
+ changePlan: (projectExtId, body) => changePlan(this.requireClient(), projectExtId, body),
9089
+ previewPlanChange: (projectExtId, body) => previewPlanChange(this.requireClient(), projectExtId, body),
9090
+ quoteAddon: (projectExtId, kind) => quoteAddon(this.requireClient(), projectExtId, kind),
9091
+ billingPortal: (projectExtId) => billingPortal(this.requireClient(), projectExtId),
9092
+ addAddonBlock: (projectExtId, kind) => addAddonBlock(this.requireClient(), projectExtId, kind),
9093
+ setNextPeriodAddons: (projectExtId, body) => setNextPeriodAddons(this.requireClient(), projectExtId, body),
9094
+ updateAddonSettings: (projectExtId, body) => updateAddonSettings(this.requireClient(), projectExtId, body),
9095
+ cancelSubscription: (projectExtId) => cancelSubscription(this.requireClient(), projectExtId)
8709
9096
  };
8710
9097
  // ── User (account-scoped usage) ───────────────────────────────────────
8711
9098
  user = {
@@ -8851,6 +9238,8 @@ var Arbi = class {
8851
9238
  }
8852
9239
  // ── Workspaces ────────────────────────────────────────────────────────
8853
9240
  workspaces = {
9241
+ /** Hand this server session a workspace's key (sealed to the session) without opening it. */
9242
+ primeKey: (workspaceExtId, sessionSealedKey) => primeWorkspaceKey(this.requireClient(), workspaceExtId, sessionSealedKey),
8854
9243
  list: async () => this.rememberWorkspaces(await listWorkspaces(this.requireClient())),
8855
9244
  create: async (name, projectExtId, description, isPublic) => {
8856
9245
  const client = this.requireClient();
@@ -9195,7 +9584,8 @@ var Arbi = class {
9195
9584
  /** The skills the caller can run (own + shared marketplace), metadata only. */
9196
9585
  listSkills: (options) => listSkills(this.requireClient(), options),
9197
9586
  /**
9198
- * Search documents without LLM generation (retrieval only).
9587
+ * Search documents without LLM generation (retrieval only). No `docIds` searches the whole
9588
+ * workspace; `searchChunks(result)` ranks the passages found.
9199
9589
  */
9200
9590
  retrieve: (query, docIds, options) => retrieve({
9201
9591
  arbi: this.requireClient(),
@@ -9325,10 +9715,6 @@ var Arbi = class {
9325
9715
  syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9326
9716
  disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9327
9717
  publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
9328
- listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
9329
- createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
9330
- createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
9331
- revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
9332
9718
  listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9333
9719
  putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9334
9720
  deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
@@ -9441,6 +9827,49 @@ var Arbi = class {
9441
9827
  /** List the current user's durable activity feed. */
9442
9828
  listActivity: (options) => listActivity(this.requireClient(), options)
9443
9829
  };
9830
+ // ── Connectors ────────────────────────────────────────────────────────
9831
+ /**
9832
+ * Connectors: the catalog, the user's connections and their OAuth, mailbox and drive sync,
9833
+ * Slack. A vendor is its `vendor_key` (e.g. `microsoft`, `gmail`).
9834
+ */
9835
+ connectors = {
9836
+ catalog: () => listCatalog(this.requireClient()),
9837
+ mine: () => listMine(this.requireClient()),
9838
+ disconnect: (vendor) => disconnect(this.requireClient(), vendor),
9839
+ /** The provider consent URL; the OAuth comes back to `returnTo` (a path of this app). */
9840
+ authorize: (vendor, returnTo) => authorize(this.requireClient(), vendor, returnTo),
9841
+ /**
9842
+ * Let this server session use the user's connector grants (best effort: a failure is logged,
9843
+ * never thrown, so it cannot break a sign-in or a connect). Signed out: nothing to bridge.
9844
+ */
9845
+ bridgeTokens: async (options) => {
9846
+ const login = this.loginResult;
9847
+ if (!login) return;
9848
+ try {
9849
+ await bridgeConnectorTokens(this.requireClient(), login, options);
9850
+ } catch (err) {
9851
+ console.error("[connectors] Token bridge failed", err);
9852
+ }
9853
+ },
9854
+ mailboxFolders: (vendor) => listMailboxFolders(this.requireClient(), vendor),
9855
+ enableMailboxSync: (vendor, body) => enableMailboxSync(this.requireClient(), vendor, body),
9856
+ syncMailbox: (vendor, workspaceExtId) => triggerMailboxSync(this.requireClient(), vendor, workspaceExtId),
9857
+ mailboxSyncProgress: (vendor, workspaceExtId) => mailboxSyncProgress(this.requireClient(), vendor, workspaceExtId),
9858
+ cancelMailboxSync: (vendor, workspaceExtId) => cancelMailboxSync(this.requireClient(), vendor, workspaceExtId),
9859
+ driveFolders: (vendor) => listDriveFolders(this.requireClient(), vendor),
9860
+ driveFolderChildren: (vendor, itemId) => listDriveFolderChildren(this.requireClient(), vendor, itemId),
9861
+ driveFolderDocCount: (vendor, itemId) => driveFolderDocCount(this.requireClient(), vendor, itemId),
9862
+ enableDriveSync: (vendor, body) => enableDriveSync(this.requireClient(), vendor, body),
9863
+ syncDrive: (vendor) => triggerDriveSync(this.requireClient(), vendor),
9864
+ driveSyncEstimate: (vendor) => driveSyncEstimate(this.requireClient(), vendor),
9865
+ driveSyncProgress: (vendor) => driveSyncProgress(this.requireClient(), vendor),
9866
+ cancelDriveSync: (vendor) => cancelDriveSync(this.requireClient(), vendor),
9867
+ slack: {
9868
+ status: () => slackStatus(this.requireClient()),
9869
+ authorize: (agentExtId) => authorizeSlack(this.requireClient(), agentExtId),
9870
+ disconnect: () => disconnectSlack(this.requireClient())
9871
+ }
9872
+ };
9444
9873
  // ── Settings ──────────────────────────────────────────────────────────
9445
9874
  settings = {
9446
9875
  get: () => getSettings(this.requireClient()),
@@ -9605,9 +10034,16 @@ exports.Arbi = Arbi;
9605
10034
  exports.ArbiApiError = ArbiApiError;
9606
10035
  exports.ArbiError = ArbiError;
9607
10036
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
10037
+ exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;
9608
10038
  exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
10039
+ exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
10040
+ exports.IMANAGE_VENDORS = IMANAGE_VENDORS;
10041
+ exports.MAILBOX_SYNC_VENDORS = MAILBOX_SYNC_VENDORS;
10042
+ exports.MAX_RETRIEVE_DOC_IDS = MAX_RETRIEVE_DOC_IDS;
10043
+ exports.MICROSOFT_VENDORS = MICROSOFT_VENDORS;
9609
10044
  exports.PlanStepsError = PlanStepsError;
9610
10045
  exports.PublicBookingError = PublicBookingError;
10046
+ exports.SHAREPOINT_VENDORS = SHAREPOINT_VENDORS;
9611
10047
  exports.TAG_KINDS = TAG_KINDS;
9612
10048
  exports.WebSocketAuthError = WebSocketAuthError;
9613
10049
  exports.account = account_exports;
@@ -9623,8 +10059,10 @@ exports.buildRetrievalTocTool = buildRetrievalTocTool;
9623
10059
  exports.calendar = calendar_exports;
9624
10060
  exports.cancelPublicBooking = cancelPublicBooking;
9625
10061
  exports.chats = chats_exports;
10062
+ exports.connectErrorMessage = connectErrorMessage;
9626
10063
  exports.connectWebSocket = connectWebSocket;
9627
10064
  exports.connectWithReconnect = connectWithReconnect;
10065
+ exports.connectors = connectors_exports;
9628
10066
  exports.consumeSSEStream = consumeSSEStream;
9629
10067
  exports.contacts = contacts_exports;
9630
10068
  exports.conversations = conversations_exports;
@@ -9649,6 +10087,10 @@ exports.health = health_exports;
9649
10087
  exports.houseTemplates = house_template_exports;
9650
10088
  exports.identityErrorCode = identityErrorCode;
9651
10089
  exports.identityVerification = identity_exports;
10090
+ exports.isConnectorVendorVisible = isConnectorVendorVisible;
10091
+ exports.isDriveSyncVendor = isDriveSyncVendor;
10092
+ exports.isMailboxSyncVendor = isMailboxSyncVendor;
10093
+ exports.isSharePointVendor = isSharePointVendor;
9652
10094
  exports.mail = mail_exports;
9653
10095
  exports.notifications = notifications_exports;
9654
10096
  exports.parseSSEEvents = parseSSEEvents;
@@ -9663,11 +10105,11 @@ exports.resolveAuth = resolveAuth;
9663
10105
  exports.resolveCitations = resolveCitations;
9664
10106
  exports.resolveWorkspace = resolveWorkspace;
9665
10107
  exports.responses = responses_exports;
10108
+ exports.searchChunks = searchChunks;
9666
10109
  exports.selectWorkspace = selectWorkspace;
9667
10110
  exports.selectWorkspaceById = selectWorkspaceById;
9668
10111
  exports.sessions = sessions_exports;
9669
10112
  exports.settings = settings_exports;
9670
- exports.splitAppPasswords = splitAppPasswords;
9671
10113
  exports.streamSSE = streamSSE;
9672
10114
  exports.stripCitationMarkdown = stripCitationMarkdown;
9673
10115
  exports.summarizeCitations = summarizeCitations;