@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/index.cjs CHANGED
@@ -3541,7 +3541,7 @@ function requireData(result, message) {
3541
3541
  }
3542
3542
  function requireOk(result, message) {
3543
3543
  if (result.error) {
3544
- throw new ArbiApiError(message, result.error);
3544
+ throw new ArbiApiError(message, result.error, result.response?.status);
3545
3545
  }
3546
3546
  }
3547
3547
  function getErrorMessage(err) {
@@ -5547,6 +5547,7 @@ __export(workspaces_exports, {
5547
5547
  grantTemporaryWorkspaceAccess: () => grantTemporaryWorkspaceAccess,
5548
5548
  listWorkspaceUsers: () => listWorkspaceUsers,
5549
5549
  listWorkspaces: () => listWorkspaces,
5550
+ primeWorkspaceKey: () => primeWorkspaceKey,
5550
5551
  removeWorkspaceUsers: () => removeWorkspaceUsers,
5551
5552
  setUserRole: () => setUserRole,
5552
5553
  updateWorkspace: () => updateWorkspace
@@ -5653,6 +5654,15 @@ async function getWorkspaceActivity(arbi, workspaceExtId, options = {}) {
5653
5654
  "Failed to fetch workspace activity"
5654
5655
  );
5655
5656
  }
5657
+ async function primeWorkspaceKey(arbi, workspaceExtId, sessionSealedKey) {
5658
+ requireOk(
5659
+ await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/prime-key", {
5660
+ params: { path: { workspace_ext_id: workspaceExtId } },
5661
+ body: { workspace_key: sessionSealedKey }
5662
+ }),
5663
+ "Failed to prime the workspace key"
5664
+ );
5665
+ }
5656
5666
 
5657
5667
  // src/operations/conversations.ts
5658
5668
  var conversations_exports = {};
@@ -5731,6 +5741,7 @@ async function updateConversationAssistantMode(arbi, conversationId, assistantMo
5731
5741
  // src/operations/assistant.ts
5732
5742
  var assistant_exports = {};
5733
5743
  __export(assistant_exports, {
5744
+ MAX_RETRIEVE_DOC_IDS: () => MAX_RETRIEVE_DOC_IDS,
5734
5745
  buildFactsContextTool: () => buildFactsContextTool,
5735
5746
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
5736
5747
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
@@ -5745,6 +5756,7 @@ __export(assistant_exports, {
5745
5756
  queryAssistant: () => queryAssistant,
5746
5757
  respondToAgent: () => respondToAgent,
5747
5758
  retrieve: () => retrieve,
5759
+ searchChunks: () => searchChunks,
5748
5760
  uploadSkill: () => uploadSkill
5749
5761
  });
5750
5762
  function buildRetrievalChunkTool(docIds, searchMode) {
@@ -5778,8 +5790,19 @@ function buildRetrievalTocTool(docIds) {
5778
5790
  tool_responses: {}
5779
5791
  };
5780
5792
  }
5793
+ var MAX_RETRIEVE_DOC_IDS = 5e3;
5781
5794
  async function retrieve(options) {
5782
- const { arbi, workspaceId, query, docIds, searchMode, fullContextDocIds, tocDocIds, model } = options;
5795
+ const {
5796
+ arbi,
5797
+ workspaceId,
5798
+ query,
5799
+ docIds,
5800
+ searchMode,
5801
+ fullContextDocIds,
5802
+ tocDocIds,
5803
+ model,
5804
+ store = true
5805
+ } = options;
5783
5806
  const tools = {
5784
5807
  retrieval_chunk: buildRetrievalChunkTool(docIds, searchMode)
5785
5808
  };
@@ -5794,7 +5817,7 @@ async function retrieve(options) {
5794
5817
  workspace_ext_id: workspaceId,
5795
5818
  stream: false,
5796
5819
  background: false,
5797
- store: true,
5820
+ store,
5798
5821
  tools,
5799
5822
  ...model ? { model } : {}
5800
5823
  };
@@ -5814,6 +5837,34 @@ async function retrieve(options) {
5814
5837
  }
5815
5838
  return data;
5816
5839
  }
5840
+ function isReadablePassage(content) {
5841
+ return content.length > 10 && content !== "-" && !/^[|\-\s]+$/.test(content);
5842
+ }
5843
+ function searchChunks(result) {
5844
+ const byId3 = /* @__PURE__ */ new Map();
5845
+ for (const [title, chunks] of Object.entries(result?.retrieval_chunk?.tool_responses ?? {})) {
5846
+ if (!Array.isArray(chunks)) continue;
5847
+ chunks.forEach((chunk2, index) => {
5848
+ if (!chunk2 || typeof chunk2 !== "object") return;
5849
+ const content = chunk2.content?.trim() ?? "";
5850
+ if (!isReadablePassage(content)) return;
5851
+ const meta = chunk2.metadata ?? {};
5852
+ const docId = meta.doc_ext_id || title;
5853
+ const rerank = meta.rerank_score;
5854
+ byId3.set(meta.chunk_ext_id || `${docId}_${index}`, {
5855
+ id: meta.chunk_ext_id || `${docId}_${index}`,
5856
+ ...meta.chunk_ext_id ? { chunkExtId: meta.chunk_ext_id } : {},
5857
+ docId,
5858
+ docTitle: meta.doc_title || title,
5859
+ ...meta.page_number != null ? { page: meta.page_number } : {},
5860
+ score: rerank && rerank > 0 ? rerank : meta.score ?? 0,
5861
+ index,
5862
+ content
5863
+ });
5864
+ });
5865
+ }
5866
+ return Array.from(byId3.values()).sort((a2, b2) => b2.score - a2.score);
5867
+ }
5817
5868
  async function queryAssistant(options) {
5818
5869
  const {
5819
5870
  workspaceId,
@@ -6952,6 +7003,271 @@ async function setWorkspaceNotificationLevel(arbi, workspaceId, level) {
6952
7003
  return patch;
6953
7004
  }
6954
7005
 
7006
+ // src/operations/connectors.ts
7007
+ var connectors_exports = {};
7008
+ __export(connectors_exports, {
7009
+ DRIVE_SYNC_VENDORS: () => DRIVE_SYNC_VENDORS,
7010
+ GOOGLE_VENDORS: () => GOOGLE_VENDORS,
7011
+ IMANAGE_VENDORS: () => IMANAGE_VENDORS,
7012
+ MAILBOX_SYNC_VENDORS: () => MAILBOX_SYNC_VENDORS,
7013
+ MICROSOFT_VENDORS: () => MICROSOFT_VENDORS,
7014
+ SHAREPOINT_VENDORS: () => SHAREPOINT_VENDORS,
7015
+ authorize: () => authorize,
7016
+ authorizeSlack: () => authorizeSlack,
7017
+ bridgeConnectorTokens: () => bridgeConnectorTokens,
7018
+ cancelDriveSync: () => cancelDriveSync,
7019
+ cancelMailboxSync: () => cancelMailboxSync,
7020
+ connectErrorMessage: () => connectErrorMessage,
7021
+ depositSessionTokens: () => depositSessionTokens,
7022
+ disconnect: () => disconnect,
7023
+ disconnectSlack: () => disconnectSlack,
7024
+ driveFolderDocCount: () => driveFolderDocCount,
7025
+ driveSyncEstimate: () => driveSyncEstimate,
7026
+ driveSyncProgress: () => driveSyncProgress,
7027
+ enableDriveSync: () => enableDriveSync,
7028
+ enableMailboxSync: () => enableMailboxSync,
7029
+ getSealedTokens: () => getSealedTokens,
7030
+ isConnectorVendorVisible: () => isConnectorVendorVisible,
7031
+ isDriveSyncVendor: () => isDriveSyncVendor,
7032
+ isMailboxSyncVendor: () => isMailboxSyncVendor,
7033
+ isSharePointVendor: () => isSharePointVendor,
7034
+ listCatalog: () => listCatalog,
7035
+ listDriveFolderChildren: () => listDriveFolderChildren,
7036
+ listDriveFolders: () => listDriveFolders,
7037
+ listMailboxFolders: () => listMailboxFolders,
7038
+ listMine: () => listMine,
7039
+ mailboxSyncProgress: () => mailboxSyncProgress,
7040
+ slackStatus: () => slackStatus,
7041
+ triggerDriveSync: () => triggerDriveSync,
7042
+ triggerMailboxSync: () => triggerMailboxSync
7043
+ });
7044
+ var vendorPath = (vendor) => ({ path: { vendor } });
7045
+ var vendorKeyPath = (vendor) => ({
7046
+ path: { vendor_key: vendor }
7047
+ });
7048
+ async function listCatalog(arbi) {
7049
+ return requireData(await arbi.fetch.GET("/v1/connectors"), "Failed to load connectors");
7050
+ }
7051
+ async function listMine(arbi) {
7052
+ return requireData(await arbi.fetch.GET("/v1/connectors/me"), "Failed to load your connections");
7053
+ }
7054
+ async function disconnect(arbi, vendor) {
7055
+ requireOk(
7056
+ await arbi.fetch.DELETE("/v1/connectors/{vendor_key}", { params: vendorKeyPath(vendor) }),
7057
+ "Failed to disconnect"
7058
+ );
7059
+ }
7060
+ async function authorize(arbi, vendor, returnTo) {
7061
+ const data = requireData(
7062
+ await arbi.fetch.GET("/v1/connectors/{vendor_key}/authorize", {
7063
+ params: { ...vendorKeyPath(vendor), query: returnTo ? { return_to: returnTo } : {} }
7064
+ }),
7065
+ "Could not start the connection"
7066
+ );
7067
+ return data.url;
7068
+ }
7069
+ async function getSealedTokens(arbi) {
7070
+ return requireData(
7071
+ await arbi.fetch.GET("/v1/connectors/sealed-tokens"),
7072
+ "Failed to load connector tokens"
7073
+ );
7074
+ }
7075
+ async function depositSessionTokens(arbi, body) {
7076
+ requireOk(
7077
+ await arbi.fetch.POST("/v1/connectors/session-tokens", { body }),
7078
+ "Failed to bridge connector tokens"
7079
+ );
7080
+ }
7081
+ async function listMailboxFolders(arbi, vendor) {
7082
+ return requireData(
7083
+ await arbi.fetch.GET("/v1/connectors/{vendor}/folders", { params: vendorPath(vendor) }),
7084
+ "Failed to load folders"
7085
+ );
7086
+ }
7087
+ async function enableMailboxSync(arbi, vendor, body) {
7088
+ return requireData(
7089
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-sync", {
7090
+ params: vendorPath(vendor),
7091
+ body
7092
+ }),
7093
+ "Failed to enable sync"
7094
+ );
7095
+ }
7096
+ async function triggerMailboxSync(arbi, vendor, workspaceExtId) {
7097
+ return requireData(
7098
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync", {
7099
+ params: {
7100
+ ...vendorPath(vendor),
7101
+ query: workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}
7102
+ }
7103
+ }),
7104
+ "Failed to start the sync"
7105
+ );
7106
+ }
7107
+ async function mailboxSyncProgress(arbi, vendor, workspaceExtId) {
7108
+ return requireData(
7109
+ await arbi.fetch.GET("/v1/connectors/{vendor}/sync-progress", {
7110
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
7111
+ }),
7112
+ "Failed to read the sync progress"
7113
+ );
7114
+ }
7115
+ async function cancelMailboxSync(arbi, vendor, workspaceExtId) {
7116
+ requireOk(
7117
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync/cancel", {
7118
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
7119
+ }),
7120
+ "Failed to cancel the sync"
7121
+ );
7122
+ }
7123
+ async function listDriveFolders(arbi, vendor) {
7124
+ return requireData(
7125
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folders", { params: vendorPath(vendor) }),
7126
+ "Failed to load folders"
7127
+ );
7128
+ }
7129
+ async function listDriveFolderChildren(arbi, vendor, itemId) {
7130
+ return requireData(
7131
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-children", {
7132
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
7133
+ }),
7134
+ "Failed to load folders"
7135
+ );
7136
+ }
7137
+ async function driveFolderDocCount(arbi, vendor, itemId) {
7138
+ const data = requireData(
7139
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-doc-count", {
7140
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
7141
+ }),
7142
+ "Failed to count documents"
7143
+ );
7144
+ return data.count;
7145
+ }
7146
+ async function enableDriveSync(arbi, vendor, body) {
7147
+ requireOk(
7148
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-drive-sync", {
7149
+ params: vendorPath(vendor),
7150
+ body
7151
+ }),
7152
+ "Failed to enable sync"
7153
+ );
7154
+ }
7155
+ async function triggerDriveSync(arbi, vendor) {
7156
+ return requireData(
7157
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync", { params: vendorPath(vendor) }),
7158
+ "Failed to start the sync"
7159
+ );
7160
+ }
7161
+ async function driveSyncEstimate(arbi, vendor) {
7162
+ return requireData(
7163
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-estimate", {
7164
+ params: vendorPath(vendor)
7165
+ }),
7166
+ "Failed to estimate the sync"
7167
+ );
7168
+ }
7169
+ async function driveSyncProgress(arbi, vendor) {
7170
+ return requireData(
7171
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-progress", {
7172
+ params: vendorPath(vendor)
7173
+ }),
7174
+ "Failed to read the sync progress"
7175
+ );
7176
+ }
7177
+ async function cancelDriveSync(arbi, vendor) {
7178
+ requireOk(
7179
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync/cancel", {
7180
+ params: vendorPath(vendor)
7181
+ }),
7182
+ "Failed to cancel the sync"
7183
+ );
7184
+ }
7185
+ async function slackStatus(arbi) {
7186
+ return requireData(
7187
+ await arbi.fetch.GET("/v1/slack/me"),
7188
+ "Failed to load the Slack connection"
7189
+ );
7190
+ }
7191
+ async function authorizeSlack(arbi, agentExtId) {
7192
+ const data = requireData(
7193
+ await arbi.fetch.GET("/v1/slack/authorize", {
7194
+ params: { query: { agent_ext_id: agentExtId } }
7195
+ }),
7196
+ "Could not start Slack authorization"
7197
+ );
7198
+ return data.url;
7199
+ }
7200
+ async function disconnectSlack(arbi) {
7201
+ requireOk(await arbi.fetch.DELETE("/v1/slack/me"), "Failed to disconnect Slack");
7202
+ }
7203
+ var MAILBOX_SYNC_VENDORS = ["microsoft", "gmail"];
7204
+ var DRIVE_SYNC_VENDORS = [
7205
+ "microsoft",
7206
+ "gmail",
7207
+ "microsoft_sharepoint",
7208
+ "clio",
7209
+ "box",
7210
+ "dropbox",
7211
+ "onenote"
7212
+ ];
7213
+ var MICROSOFT_VENDORS = ["microsoft", "ms365_mail"];
7214
+ var GOOGLE_VENDORS = ["gmail", "gdrive"];
7215
+ var IMANAGE_VENDORS = ["imanage"];
7216
+ var SHAREPOINT_VENDORS = ["microsoft_sharepoint"];
7217
+ var includes = (list, vendor) => list.includes(vendor);
7218
+ var isMailboxSyncVendor = (vendor) => includes(MAILBOX_SYNC_VENDORS, vendor);
7219
+ var isDriveSyncVendor = (vendor) => includes(DRIVE_SYNC_VENDORS, vendor);
7220
+ var isSharePointVendor = (vendor) => includes(SHAREPOINT_VENDORS, vendor);
7221
+ function isConnectorVendorVisible(settings, vendor) {
7222
+ if (includes(MICROSOFT_VENDORS, vendor)) return settings?.show_connector_microsoft ?? true;
7223
+ if (includes(GOOGLE_VENDORS, vendor)) return settings?.show_connector_google ?? true;
7224
+ if (includes(IMANAGE_VENDORS, vendor)) return settings?.show_connector_imanage ?? false;
7225
+ if (includes(SHAREPOINT_VENDORS, vendor)) return settings?.show_connector_sharepoint ?? false;
7226
+ return true;
7227
+ }
7228
+ var CONNECT_ERROR_PRODUCTS = {
7229
+ microsoft: "Microsoft",
7230
+ microsoft_sharepoint: "SharePoint",
7231
+ gmail: "Google",
7232
+ gdrive: "Google Drive",
7233
+ imanage: "iManage",
7234
+ slack: "Slack"
7235
+ };
7236
+ function connectErrorMessage(vendor) {
7237
+ const product = vendor && CONNECT_ERROR_PRODUCTS[vendor] || "the account";
7238
+ return `Couldn't connect ${product}. The connection was cancelled or not approved.`;
7239
+ }
7240
+ async function bridgeConnectorTokens(arbi, keys, { vendor, autoSyncWorkspaceExtId } = {}) {
7241
+ await client.initSodium();
7242
+ const keypair = client.encryptionKeypairFromSigningKey(keys.signingPrivateKey);
7243
+ try {
7244
+ let sealed = await getSealedTokens(arbi);
7245
+ if (vendor) sealed = sealed.filter((token) => token.vendor_key === vendor);
7246
+ for (const token of sealed) {
7247
+ try {
7248
+ const reseal = async (wrapped) => {
7249
+ const plain = client.sealedBoxDecrypt(wrapped, keypair.secretKey);
7250
+ try {
7251
+ return await client.sealKeyForSession(plain, keys.serverSessionKey);
7252
+ } finally {
7253
+ plain.fill(0);
7254
+ }
7255
+ };
7256
+ await depositSessionTokens(arbi, {
7257
+ vendor_key: token.vendor_key,
7258
+ access: await reseal(token.access_token),
7259
+ refresh: token.refresh_token ? await reseal(token.refresh_token) : null,
7260
+ ...autoSyncWorkspaceExtId ? { auto_sync_workspace_ext_id: autoSyncWorkspaceExtId } : {}
7261
+ });
7262
+ } catch (err) {
7263
+ console.error("[connectors] Could not bridge the token of", token.vendor_key, err);
7264
+ }
7265
+ }
7266
+ } finally {
7267
+ keypair.secretKey.fill(0);
7268
+ }
7269
+ }
7270
+
6955
7271
  // src/operations/agentconfig.ts
6956
7272
  var agentconfig_exports = {};
6957
7273
  __export(agentconfig_exports, {
@@ -7240,6 +7556,11 @@ async function remove(arbi) {
7240
7556
  // src/operations/projects.ts
7241
7557
  var projects_exports = {};
7242
7558
  __export(projects_exports, {
7559
+ addAddonBlock: () => addAddonBlock,
7560
+ billingPortal: () => billingPortal,
7561
+ cancelSubscription: () => cancelSubscription,
7562
+ changePlan: () => changePlan,
7563
+ createCheckout: () => createCheckout,
7243
7564
  createProject: () => createProject,
7244
7565
  deleteProject: () => deleteProject,
7245
7566
  formatBudget: () => formatBudget,
@@ -7247,11 +7568,17 @@ __export(projects_exports, {
7247
7568
  getProjectInvoices: () => getProjectInvoices,
7248
7569
  getProjectUsage: () => getProjectUsage,
7249
7570
  getUserUsageToday: () => getUserUsageToday,
7571
+ listProducts: () => listProducts,
7250
7572
  listProjectEvents: () => listProjectEvents,
7251
7573
  listProjects: () => listProjects,
7252
7574
  parseBudget: () => parseBudget,
7575
+ previewPlanChange: () => previewPlanChange,
7576
+ quoteAddon: () => quoteAddon,
7577
+ quotePlan: () => quotePlan,
7253
7578
  refreshProject: () => refreshProject,
7254
7579
  renameProject: () => renameProject,
7580
+ setNextPeriodAddons: () => setNextPeriodAddons,
7581
+ updateAddonSettings: () => updateAddonSettings,
7255
7582
  updateProject: () => updateProject
7256
7583
  });
7257
7584
  async function listProjects(arbi, filters = {}) {
@@ -7374,6 +7701,95 @@ async function getProjectInvoices(arbi, projectExtId) {
7374
7701
  async function getUserUsageToday(arbi) {
7375
7702
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
7376
7703
  }
7704
+ var projectPath = (projectExtId) => ({ path: { project_ext_id: projectExtId } });
7705
+ async function listProducts(arbi) {
7706
+ return requireData(await arbi.fetch.GET("/v1/user/products"), "Failed to load the plans");
7707
+ }
7708
+ async function quotePlan(arbi, projectExtId, body) {
7709
+ return requireData(
7710
+ projectExtId ? await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout/quote", {
7711
+ params: projectPath(projectExtId),
7712
+ body
7713
+ }) : await arbi.fetch.POST("/v1/user/projects/quote", { body }),
7714
+ "Failed to price the plan"
7715
+ );
7716
+ }
7717
+ async function createCheckout(arbi, projectExtId, body) {
7718
+ return requireData(
7719
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout", {
7720
+ params: projectPath(projectExtId),
7721
+ body
7722
+ }),
7723
+ "Failed to start the checkout"
7724
+ );
7725
+ }
7726
+ async function changePlan(arbi, projectExtId, body) {
7727
+ return requireData(
7728
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/change-plan", {
7729
+ params: projectPath(projectExtId),
7730
+ body
7731
+ }),
7732
+ "Failed to change the plan"
7733
+ );
7734
+ }
7735
+ async function previewPlanChange(arbi, projectExtId, body) {
7736
+ return requireData(
7737
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/plan/preview", {
7738
+ params: projectPath(projectExtId),
7739
+ body
7740
+ }),
7741
+ "Failed to price the plan change"
7742
+ );
7743
+ }
7744
+ async function quoteAddon(arbi, projectExtId, kind) {
7745
+ return requireData(
7746
+ await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/addons/quote", {
7747
+ params: { ...projectPath(projectExtId), query: { kind } }
7748
+ }),
7749
+ "Failed to price the add-on"
7750
+ );
7751
+ }
7752
+ async function billingPortal(arbi, projectExtId) {
7753
+ return requireData(
7754
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/billing-portal", {
7755
+ params: projectPath(projectExtId)
7756
+ }),
7757
+ "Failed to open the billing portal"
7758
+ );
7759
+ }
7760
+ async function addAddonBlock(arbi, projectExtId, kind) {
7761
+ const params = projectPath(projectExtId);
7762
+ return requireData(
7763
+ 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 }),
7764
+ "Failed to add the add-on"
7765
+ );
7766
+ }
7767
+ async function setNextPeriodAddons(arbi, projectExtId, body) {
7768
+ return requireData(
7769
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/next-period", {
7770
+ params: projectPath(projectExtId),
7771
+ body
7772
+ }),
7773
+ "Failed to change the add-ons"
7774
+ );
7775
+ }
7776
+ async function updateAddonSettings(arbi, projectExtId, body) {
7777
+ return requireData(
7778
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/settings", {
7779
+ params: projectPath(projectExtId),
7780
+ body
7781
+ }),
7782
+ "Failed to save the add-on settings"
7783
+ );
7784
+ }
7785
+ async function cancelSubscription(arbi, projectExtId) {
7786
+ return requireData(
7787
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/cancel", {
7788
+ params: projectPath(projectExtId)
7789
+ }),
7790
+ "Failed to cancel the subscription"
7791
+ );
7792
+ }
7377
7793
 
7378
7794
  // src/operations/work.ts
7379
7795
  var work_exports = {};
@@ -8465,10 +8881,8 @@ __export(calendar_exports, {
8465
8881
  cancelPublicBooking: () => cancelPublicBooking,
8466
8882
  connectCalDavAccount: () => connectCalDavAccount,
8467
8883
  connectOAuthAccount: () => connectOAuthAccount,
8468
- createAppPassword: () => createAppPassword,
8469
8884
  createCalendar: () => createCalendar,
8470
8885
  createEvent: () => createEvent,
8471
- createFeed: () => createFeed,
8472
8886
  createRoom: () => createRoom,
8473
8887
  decideCounter: () => decideCounter,
8474
8888
  deleteBookingPage: () => deleteBookingPage,
@@ -8485,7 +8899,6 @@ __export(calendar_exports, {
8485
8899
  getPublicBookingPage: () => getPublicBookingPage,
8486
8900
  importCalendarIcs: () => importCalendarIcs,
8487
8901
  listAccounts: () => listAccounts,
8488
- listAppPasswords: () => listAppPasswords,
8489
8902
  listBookingPages: () => listBookingPages,
8490
8903
  listCalDavProfiles: () => listCalDavProfiles,
8491
8904
  listCalendars: () => listCalendars,
@@ -8503,9 +8916,7 @@ __export(calendar_exports, {
8503
8916
  putCalendarSettings: () => putCalendarSettings,
8504
8917
  refreshCalendar: () => refreshCalendar,
8505
8918
  respondToEvent: () => respondToEvent,
8506
- revokeAppPassword: () => revokeAppPassword,
8507
8919
  shareCalendar: () => shareCalendar,
8508
- splitAppPasswords: () => splitAppPasswords,
8509
8920
  subscribeCalendar: () => subscribeCalendar,
8510
8921
  syncAccount: () => syncAccount,
8511
8922
  unlockCalendarKeys: () => unlockCalendarKeys,
@@ -8893,46 +9304,6 @@ async function publishCalendarToAccount(client, accId, calendarId) {
8893
9304
  "Publishing the calendar"
8894
9305
  );
8895
9306
  }
8896
- async function listAppPasswords(client) {
8897
- return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
8898
- }
8899
- async function createAppPassword(client, body) {
8900
- return take(
8901
- await client.fetch.POST("/v1/calendar/app-passwords", {
8902
- body: {
8903
- label: body.label.trim(),
8904
- calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
8905
- }
8906
- }),
8907
- "Creating the app password"
8908
- );
8909
- }
8910
- async function createFeed(client, body) {
8911
- return take(
8912
- await client.fetch.POST("/v1/calendar/feeds", {
8913
- body: {
8914
- calendar_id: body.calendar_id,
8915
- level: body.level,
8916
- label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
8917
- }
8918
- }),
8919
- "Creating the feed"
8920
- );
8921
- }
8922
- async function revokeAppPassword(client, apwId) {
8923
- take(
8924
- await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
8925
- params: { path: { apw_id: apwId } }
8926
- }),
8927
- "Revoking"
8928
- );
8929
- }
8930
- function splitAppPasswords(rows) {
8931
- return {
8932
- devices: rows.filter((r2) => r2.kind === "dav"),
8933
- feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
8934
- };
8935
- }
8936
9307
  async function listBookingPages(client) {
8937
9308
  return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8938
9309
  }
@@ -9301,7 +9672,23 @@ var Arbi = class {
9301
9672
  /** AI usage + spend breakdown for a project's billing period. */
9302
9673
  usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
9303
9674
  /** Stripe invoices for a project's subscription. */
9304
- invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId)
9675
+ invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId),
9676
+ /** Delete a project (only when empty: no workspaces, no subscription). */
9677
+ delete: (projectExtId) => deleteProject(this.requireClient(), projectExtId),
9678
+ /** The plans and add-ons on sale. */
9679
+ products: () => listProducts(this.requireClient()),
9680
+ /** The taxed total of a Pro purchase (a new project when `projectExtId` is null). */
9681
+ quotePlan: (projectExtId, body) => quotePlan(this.requireClient(), projectExtId, body),
9682
+ /** Start an embedded Stripe checkout; returns its `client_secret`. */
9683
+ checkout: (projectExtId, body) => createCheckout(this.requireClient(), projectExtId, body),
9684
+ changePlan: (projectExtId, body) => changePlan(this.requireClient(), projectExtId, body),
9685
+ previewPlanChange: (projectExtId, body) => previewPlanChange(this.requireClient(), projectExtId, body),
9686
+ quoteAddon: (projectExtId, kind) => quoteAddon(this.requireClient(), projectExtId, kind),
9687
+ billingPortal: (projectExtId) => billingPortal(this.requireClient(), projectExtId),
9688
+ addAddonBlock: (projectExtId, kind) => addAddonBlock(this.requireClient(), projectExtId, kind),
9689
+ setNextPeriodAddons: (projectExtId, body) => setNextPeriodAddons(this.requireClient(), projectExtId, body),
9690
+ updateAddonSettings: (projectExtId, body) => updateAddonSettings(this.requireClient(), projectExtId, body),
9691
+ cancelSubscription: (projectExtId) => cancelSubscription(this.requireClient(), projectExtId)
9305
9692
  };
9306
9693
  // ── User (account-scoped usage) ───────────────────────────────────────
9307
9694
  user = {
@@ -9447,6 +9834,8 @@ var Arbi = class {
9447
9834
  }
9448
9835
  // ── Workspaces ────────────────────────────────────────────────────────
9449
9836
  workspaces = {
9837
+ /** Hand this server session a workspace's key (sealed to the session) without opening it. */
9838
+ primeKey: (workspaceExtId, sessionSealedKey) => primeWorkspaceKey(this.requireClient(), workspaceExtId, sessionSealedKey),
9450
9839
  list: async () => this.rememberWorkspaces(await listWorkspaces(this.requireClient())),
9451
9840
  create: async (name, projectExtId, description, isPublic) => {
9452
9841
  const client = this.requireClient();
@@ -9791,7 +10180,8 @@ var Arbi = class {
9791
10180
  /** The skills the caller can run (own + shared marketplace), metadata only. */
9792
10181
  listSkills: (options) => listSkills(this.requireClient(), options),
9793
10182
  /**
9794
- * Search documents without LLM generation (retrieval only).
10183
+ * Search documents without LLM generation (retrieval only). No `docIds` searches the whole
10184
+ * workspace; `searchChunks(result)` ranks the passages found.
9795
10185
  */
9796
10186
  retrieve: (query, docIds, options) => retrieve({
9797
10187
  arbi: this.requireClient(),
@@ -9921,10 +10311,6 @@ var Arbi = class {
9921
10311
  syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9922
10312
  disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9923
10313
  publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
9924
- listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
9925
- createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
9926
- createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
9927
- revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
9928
10314
  listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9929
10315
  putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9930
10316
  deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
@@ -10037,6 +10423,49 @@ var Arbi = class {
10037
10423
  /** List the current user's durable activity feed. */
10038
10424
  listActivity: (options) => listActivity(this.requireClient(), options)
10039
10425
  };
10426
+ // ── Connectors ────────────────────────────────────────────────────────
10427
+ /**
10428
+ * Connectors: the catalog, the user's connections and their OAuth, mailbox and drive sync,
10429
+ * Slack. A vendor is its `vendor_key` (e.g. `microsoft`, `gmail`).
10430
+ */
10431
+ connectors = {
10432
+ catalog: () => listCatalog(this.requireClient()),
10433
+ mine: () => listMine(this.requireClient()),
10434
+ disconnect: (vendor) => disconnect(this.requireClient(), vendor),
10435
+ /** The provider consent URL; the OAuth comes back to `returnTo` (a path of this app). */
10436
+ authorize: (vendor, returnTo) => authorize(this.requireClient(), vendor, returnTo),
10437
+ /**
10438
+ * Let this server session use the user's connector grants (best effort: a failure is logged,
10439
+ * never thrown, so it cannot break a sign-in or a connect). Signed out: nothing to bridge.
10440
+ */
10441
+ bridgeTokens: async (options) => {
10442
+ const login = this.loginResult;
10443
+ if (!login) return;
10444
+ try {
10445
+ await bridgeConnectorTokens(this.requireClient(), login, options);
10446
+ } catch (err) {
10447
+ console.error("[connectors] Token bridge failed", err);
10448
+ }
10449
+ },
10450
+ mailboxFolders: (vendor) => listMailboxFolders(this.requireClient(), vendor),
10451
+ enableMailboxSync: (vendor, body) => enableMailboxSync(this.requireClient(), vendor, body),
10452
+ syncMailbox: (vendor, workspaceExtId) => triggerMailboxSync(this.requireClient(), vendor, workspaceExtId),
10453
+ mailboxSyncProgress: (vendor, workspaceExtId) => mailboxSyncProgress(this.requireClient(), vendor, workspaceExtId),
10454
+ cancelMailboxSync: (vendor, workspaceExtId) => cancelMailboxSync(this.requireClient(), vendor, workspaceExtId),
10455
+ driveFolders: (vendor) => listDriveFolders(this.requireClient(), vendor),
10456
+ driveFolderChildren: (vendor, itemId) => listDriveFolderChildren(this.requireClient(), vendor, itemId),
10457
+ driveFolderDocCount: (vendor, itemId) => driveFolderDocCount(this.requireClient(), vendor, itemId),
10458
+ enableDriveSync: (vendor, body) => enableDriveSync(this.requireClient(), vendor, body),
10459
+ syncDrive: (vendor) => triggerDriveSync(this.requireClient(), vendor),
10460
+ driveSyncEstimate: (vendor) => driveSyncEstimate(this.requireClient(), vendor),
10461
+ driveSyncProgress: (vendor) => driveSyncProgress(this.requireClient(), vendor),
10462
+ cancelDriveSync: (vendor) => cancelDriveSync(this.requireClient(), vendor),
10463
+ slack: {
10464
+ status: () => slackStatus(this.requireClient()),
10465
+ authorize: (agentExtId) => authorizeSlack(this.requireClient(), agentExtId),
10466
+ disconnect: () => disconnectSlack(this.requireClient())
10467
+ }
10468
+ };
10040
10469
  // ── Settings ──────────────────────────────────────────────────────────
10041
10470
  settings = {
10042
10471
  get: () => getSettings(this.requireClient()),
@@ -11277,11 +11706,18 @@ exports.ArbiSessionExpiredError = ArbiSessionExpiredError;
11277
11706
  exports.ClaudeOrchestrator = ClaudeOrchestrator;
11278
11707
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
11279
11708
  exports.DOC_TERMINAL_STATUSES = DOC_TERMINAL_STATUSES;
11709
+ exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;
11280
11710
  exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
11281
11711
  exports.FileConfigStore = FileConfigStore;
11712
+ exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
11713
+ exports.IMANAGE_VENDORS = IMANAGE_VENDORS;
11714
+ exports.MAILBOX_SYNC_VENDORS = MAILBOX_SYNC_VENDORS;
11715
+ exports.MAX_RETRIEVE_DOC_IDS = MAX_RETRIEVE_DOC_IDS;
11716
+ exports.MICROSOFT_VENDORS = MICROSOFT_VENDORS;
11282
11717
  exports.OpenClawOrchestrator = OpenClawOrchestrator;
11283
11718
  exports.PlanStepsError = PlanStepsError;
11284
11719
  exports.PublicBookingError = PublicBookingError;
11720
+ exports.SHAREPOINT_VENDORS = SHAREPOINT_VENDORS;
11285
11721
  exports.STEP_FIELD_OPTION_TONES = STEP_FIELD_OPTION_TONES;
11286
11722
  exports.TAG_KINDS = TAG_KINDS;
11287
11723
  exports.WebSocketAuthError = WebSocketAuthError;
@@ -11300,8 +11736,10 @@ exports.buildRetrievalTocTool = buildRetrievalTocTool;
11300
11736
  exports.calendar = calendar_exports;
11301
11737
  exports.cancelPublicBooking = cancelPublicBooking;
11302
11738
  exports.chats = chats_exports;
11739
+ exports.connectErrorMessage = connectErrorMessage;
11303
11740
  exports.connectWebSocket = connectWebSocket;
11304
11741
  exports.connectWithReconnect = connectWithReconnect;
11742
+ exports.connectors = connectors_exports;
11305
11743
  exports.consumeSSEStream = consumeSSEStream;
11306
11744
  exports.contacts = contacts_exports;
11307
11745
  exports.conversations = conversations_exports;
@@ -11335,6 +11773,10 @@ exports.health = health_exports;
11335
11773
  exports.houseTemplates = house_template_exports;
11336
11774
  exports.identityErrorCode = identityErrorCode;
11337
11775
  exports.identityVerification = identity_exports;
11776
+ exports.isConnectorVendorVisible = isConnectorVendorVisible;
11777
+ exports.isDriveSyncVendor = isDriveSyncVendor;
11778
+ exports.isMailboxSyncVendor = isMailboxSyncVendor;
11779
+ exports.isSharePointVendor = isSharePointVendor;
11338
11780
  exports.isSharedSkill = isSharedSkill;
11339
11781
  exports.listen = listen_exports;
11340
11782
  exports.mail = mail_exports;
@@ -11354,12 +11796,12 @@ exports.resolveAuth = resolveAuth;
11354
11796
  exports.resolveCitations = resolveCitations;
11355
11797
  exports.resolveWorkspace = resolveWorkspace;
11356
11798
  exports.responses = responses_exports;
11799
+ exports.searchChunks = searchChunks;
11357
11800
  exports.selectWorkspace = selectWorkspace;
11358
11801
  exports.selectWorkspaceById = selectWorkspaceById;
11359
11802
  exports.sessions = sessions_exports;
11360
11803
  exports.settings = settings_exports;
11361
11804
  exports.signatureRequests = signature_requests_exports;
11362
- exports.splitAppPasswords = splitAppPasswords;
11363
11805
  exports.startDmListener = startDmListener;
11364
11806
  exports.streamSSE = streamSSE;
11365
11807
  exports.stripCitationMarkdown = stripCitationMarkdown;