@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.js CHANGED
@@ -3532,7 +3532,7 @@ function requireData(result, message) {
3532
3532
  }
3533
3533
  function requireOk(result, message) {
3534
3534
  if (result.error) {
3535
- throw new ArbiApiError(message, result.error);
3535
+ throw new ArbiApiError(message, result.error, result.response?.status);
3536
3536
  }
3537
3537
  }
3538
3538
  function getErrorMessage(err) {
@@ -5538,6 +5538,7 @@ __export(workspaces_exports, {
5538
5538
  grantTemporaryWorkspaceAccess: () => grantTemporaryWorkspaceAccess,
5539
5539
  listWorkspaceUsers: () => listWorkspaceUsers,
5540
5540
  listWorkspaces: () => listWorkspaces,
5541
+ primeWorkspaceKey: () => primeWorkspaceKey,
5541
5542
  removeWorkspaceUsers: () => removeWorkspaceUsers,
5542
5543
  setUserRole: () => setUserRole,
5543
5544
  updateWorkspace: () => updateWorkspace
@@ -5644,6 +5645,15 @@ async function getWorkspaceActivity(arbi, workspaceExtId, options = {}) {
5644
5645
  "Failed to fetch workspace activity"
5645
5646
  );
5646
5647
  }
5648
+ async function primeWorkspaceKey(arbi, workspaceExtId, sessionSealedKey) {
5649
+ requireOk(
5650
+ await arbi.fetch.POST("/v1/workspace/{workspace_ext_id}/prime-key", {
5651
+ params: { path: { workspace_ext_id: workspaceExtId } },
5652
+ body: { workspace_key: sessionSealedKey }
5653
+ }),
5654
+ "Failed to prime the workspace key"
5655
+ );
5656
+ }
5647
5657
 
5648
5658
  // src/operations/conversations.ts
5649
5659
  var conversations_exports = {};
@@ -5722,6 +5732,7 @@ async function updateConversationAssistantMode(arbi, conversationId, assistantMo
5722
5732
  // src/operations/assistant.ts
5723
5733
  var assistant_exports = {};
5724
5734
  __export(assistant_exports, {
5735
+ MAX_RETRIEVE_DOC_IDS: () => MAX_RETRIEVE_DOC_IDS,
5725
5736
  buildFactsContextTool: () => buildFactsContextTool,
5726
5737
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
5727
5738
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
@@ -5736,6 +5747,7 @@ __export(assistant_exports, {
5736
5747
  queryAssistant: () => queryAssistant,
5737
5748
  respondToAgent: () => respondToAgent,
5738
5749
  retrieve: () => retrieve,
5750
+ searchChunks: () => searchChunks,
5739
5751
  uploadSkill: () => uploadSkill
5740
5752
  });
5741
5753
  function buildRetrievalChunkTool(docIds, searchMode) {
@@ -5769,8 +5781,19 @@ function buildRetrievalTocTool(docIds) {
5769
5781
  tool_responses: {}
5770
5782
  };
5771
5783
  }
5784
+ var MAX_RETRIEVE_DOC_IDS = 5e3;
5772
5785
  async function retrieve(options) {
5773
- const { arbi, workspaceId, query, docIds, searchMode, fullContextDocIds, tocDocIds, model } = options;
5786
+ const {
5787
+ arbi,
5788
+ workspaceId,
5789
+ query,
5790
+ docIds,
5791
+ searchMode,
5792
+ fullContextDocIds,
5793
+ tocDocIds,
5794
+ model,
5795
+ store = true
5796
+ } = options;
5774
5797
  const tools = {
5775
5798
  retrieval_chunk: buildRetrievalChunkTool(docIds, searchMode)
5776
5799
  };
@@ -5785,7 +5808,7 @@ async function retrieve(options) {
5785
5808
  workspace_ext_id: workspaceId,
5786
5809
  stream: false,
5787
5810
  background: false,
5788
- store: true,
5811
+ store,
5789
5812
  tools,
5790
5813
  ...model ? { model } : {}
5791
5814
  };
@@ -5805,6 +5828,34 @@ async function retrieve(options) {
5805
5828
  }
5806
5829
  return data;
5807
5830
  }
5831
+ function isReadablePassage(content) {
5832
+ return content.length > 10 && content !== "-" && !/^[|\-\s]+$/.test(content);
5833
+ }
5834
+ function searchChunks(result) {
5835
+ const byId3 = /* @__PURE__ */ new Map();
5836
+ for (const [title, chunks] of Object.entries(result?.retrieval_chunk?.tool_responses ?? {})) {
5837
+ if (!Array.isArray(chunks)) continue;
5838
+ chunks.forEach((chunk2, index) => {
5839
+ if (!chunk2 || typeof chunk2 !== "object") return;
5840
+ const content = chunk2.content?.trim() ?? "";
5841
+ if (!isReadablePassage(content)) return;
5842
+ const meta = chunk2.metadata ?? {};
5843
+ const docId = meta.doc_ext_id || title;
5844
+ const rerank = meta.rerank_score;
5845
+ byId3.set(meta.chunk_ext_id || `${docId}_${index}`, {
5846
+ id: meta.chunk_ext_id || `${docId}_${index}`,
5847
+ ...meta.chunk_ext_id ? { chunkExtId: meta.chunk_ext_id } : {},
5848
+ docId,
5849
+ docTitle: meta.doc_title || title,
5850
+ ...meta.page_number != null ? { page: meta.page_number } : {},
5851
+ score: rerank && rerank > 0 ? rerank : meta.score ?? 0,
5852
+ index,
5853
+ content
5854
+ });
5855
+ });
5856
+ }
5857
+ return Array.from(byId3.values()).sort((a2, b2) => b2.score - a2.score);
5858
+ }
5808
5859
  async function queryAssistant(options) {
5809
5860
  const {
5810
5861
  workspaceId,
@@ -6943,6 +6994,271 @@ async function setWorkspaceNotificationLevel(arbi, workspaceId, level) {
6943
6994
  return patch;
6944
6995
  }
6945
6996
 
6997
+ // src/operations/connectors.ts
6998
+ var connectors_exports = {};
6999
+ __export(connectors_exports, {
7000
+ DRIVE_SYNC_VENDORS: () => DRIVE_SYNC_VENDORS,
7001
+ GOOGLE_VENDORS: () => GOOGLE_VENDORS,
7002
+ IMANAGE_VENDORS: () => IMANAGE_VENDORS,
7003
+ MAILBOX_SYNC_VENDORS: () => MAILBOX_SYNC_VENDORS,
7004
+ MICROSOFT_VENDORS: () => MICROSOFT_VENDORS,
7005
+ SHAREPOINT_VENDORS: () => SHAREPOINT_VENDORS,
7006
+ authorize: () => authorize,
7007
+ authorizeSlack: () => authorizeSlack,
7008
+ bridgeConnectorTokens: () => bridgeConnectorTokens,
7009
+ cancelDriveSync: () => cancelDriveSync,
7010
+ cancelMailboxSync: () => cancelMailboxSync,
7011
+ connectErrorMessage: () => connectErrorMessage,
7012
+ depositSessionTokens: () => depositSessionTokens,
7013
+ disconnect: () => disconnect,
7014
+ disconnectSlack: () => disconnectSlack,
7015
+ driveFolderDocCount: () => driveFolderDocCount,
7016
+ driveSyncEstimate: () => driveSyncEstimate,
7017
+ driveSyncProgress: () => driveSyncProgress,
7018
+ enableDriveSync: () => enableDriveSync,
7019
+ enableMailboxSync: () => enableMailboxSync,
7020
+ getSealedTokens: () => getSealedTokens,
7021
+ isConnectorVendorVisible: () => isConnectorVendorVisible,
7022
+ isDriveSyncVendor: () => isDriveSyncVendor,
7023
+ isMailboxSyncVendor: () => isMailboxSyncVendor,
7024
+ isSharePointVendor: () => isSharePointVendor,
7025
+ listCatalog: () => listCatalog,
7026
+ listDriveFolderChildren: () => listDriveFolderChildren,
7027
+ listDriveFolders: () => listDriveFolders,
7028
+ listMailboxFolders: () => listMailboxFolders,
7029
+ listMine: () => listMine,
7030
+ mailboxSyncProgress: () => mailboxSyncProgress,
7031
+ slackStatus: () => slackStatus,
7032
+ triggerDriveSync: () => triggerDriveSync,
7033
+ triggerMailboxSync: () => triggerMailboxSync
7034
+ });
7035
+ var vendorPath = (vendor) => ({ path: { vendor } });
7036
+ var vendorKeyPath = (vendor) => ({
7037
+ path: { vendor_key: vendor }
7038
+ });
7039
+ async function listCatalog(arbi) {
7040
+ return requireData(await arbi.fetch.GET("/v1/connectors"), "Failed to load connectors");
7041
+ }
7042
+ async function listMine(arbi) {
7043
+ return requireData(await arbi.fetch.GET("/v1/connectors/me"), "Failed to load your connections");
7044
+ }
7045
+ async function disconnect(arbi, vendor) {
7046
+ requireOk(
7047
+ await arbi.fetch.DELETE("/v1/connectors/{vendor_key}", { params: vendorKeyPath(vendor) }),
7048
+ "Failed to disconnect"
7049
+ );
7050
+ }
7051
+ async function authorize(arbi, vendor, returnTo) {
7052
+ const data = requireData(
7053
+ await arbi.fetch.GET("/v1/connectors/{vendor_key}/authorize", {
7054
+ params: { ...vendorKeyPath(vendor), query: returnTo ? { return_to: returnTo } : {} }
7055
+ }),
7056
+ "Could not start the connection"
7057
+ );
7058
+ return data.url;
7059
+ }
7060
+ async function getSealedTokens(arbi) {
7061
+ return requireData(
7062
+ await arbi.fetch.GET("/v1/connectors/sealed-tokens"),
7063
+ "Failed to load connector tokens"
7064
+ );
7065
+ }
7066
+ async function depositSessionTokens(arbi, body) {
7067
+ requireOk(
7068
+ await arbi.fetch.POST("/v1/connectors/session-tokens", { body }),
7069
+ "Failed to bridge connector tokens"
7070
+ );
7071
+ }
7072
+ async function listMailboxFolders(arbi, vendor) {
7073
+ return requireData(
7074
+ await arbi.fetch.GET("/v1/connectors/{vendor}/folders", { params: vendorPath(vendor) }),
7075
+ "Failed to load folders"
7076
+ );
7077
+ }
7078
+ async function enableMailboxSync(arbi, vendor, body) {
7079
+ return requireData(
7080
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-sync", {
7081
+ params: vendorPath(vendor),
7082
+ body
7083
+ }),
7084
+ "Failed to enable sync"
7085
+ );
7086
+ }
7087
+ async function triggerMailboxSync(arbi, vendor, workspaceExtId) {
7088
+ return requireData(
7089
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync", {
7090
+ params: {
7091
+ ...vendorPath(vendor),
7092
+ query: workspaceExtId ? { workspace_ext_id: workspaceExtId } : {}
7093
+ }
7094
+ }),
7095
+ "Failed to start the sync"
7096
+ );
7097
+ }
7098
+ async function mailboxSyncProgress(arbi, vendor, workspaceExtId) {
7099
+ return requireData(
7100
+ await arbi.fetch.GET("/v1/connectors/{vendor}/sync-progress", {
7101
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
7102
+ }),
7103
+ "Failed to read the sync progress"
7104
+ );
7105
+ }
7106
+ async function cancelMailboxSync(arbi, vendor, workspaceExtId) {
7107
+ requireOk(
7108
+ await arbi.fetch.POST("/v1/connectors/{vendor}/sync/cancel", {
7109
+ params: { ...vendorPath(vendor), query: { workspace_ext_id: workspaceExtId } }
7110
+ }),
7111
+ "Failed to cancel the sync"
7112
+ );
7113
+ }
7114
+ async function listDriveFolders(arbi, vendor) {
7115
+ return requireData(
7116
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folders", { params: vendorPath(vendor) }),
7117
+ "Failed to load folders"
7118
+ );
7119
+ }
7120
+ async function listDriveFolderChildren(arbi, vendor, itemId) {
7121
+ return requireData(
7122
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-children", {
7123
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
7124
+ }),
7125
+ "Failed to load folders"
7126
+ );
7127
+ }
7128
+ async function driveFolderDocCount(arbi, vendor, itemId) {
7129
+ const data = requireData(
7130
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-folder-doc-count", {
7131
+ params: { ...vendorPath(vendor), query: { item_id: itemId } }
7132
+ }),
7133
+ "Failed to count documents"
7134
+ );
7135
+ return data.count;
7136
+ }
7137
+ async function enableDriveSync(arbi, vendor, body) {
7138
+ requireOk(
7139
+ await arbi.fetch.POST("/v1/connectors/{vendor}/enable-drive-sync", {
7140
+ params: vendorPath(vendor),
7141
+ body
7142
+ }),
7143
+ "Failed to enable sync"
7144
+ );
7145
+ }
7146
+ async function triggerDriveSync(arbi, vendor) {
7147
+ return requireData(
7148
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync", { params: vendorPath(vendor) }),
7149
+ "Failed to start the sync"
7150
+ );
7151
+ }
7152
+ async function driveSyncEstimate(arbi, vendor) {
7153
+ return requireData(
7154
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-estimate", {
7155
+ params: vendorPath(vendor)
7156
+ }),
7157
+ "Failed to estimate the sync"
7158
+ );
7159
+ }
7160
+ async function driveSyncProgress(arbi, vendor) {
7161
+ return requireData(
7162
+ await arbi.fetch.GET("/v1/connectors/{vendor}/drive-sync-progress", {
7163
+ params: vendorPath(vendor)
7164
+ }),
7165
+ "Failed to read the sync progress"
7166
+ );
7167
+ }
7168
+ async function cancelDriveSync(arbi, vendor) {
7169
+ requireOk(
7170
+ await arbi.fetch.POST("/v1/connectors/{vendor}/drive-sync/cancel", {
7171
+ params: vendorPath(vendor)
7172
+ }),
7173
+ "Failed to cancel the sync"
7174
+ );
7175
+ }
7176
+ async function slackStatus(arbi) {
7177
+ return requireData(
7178
+ await arbi.fetch.GET("/v1/slack/me"),
7179
+ "Failed to load the Slack connection"
7180
+ );
7181
+ }
7182
+ async function authorizeSlack(arbi, agentExtId) {
7183
+ const data = requireData(
7184
+ await arbi.fetch.GET("/v1/slack/authorize", {
7185
+ params: { query: { agent_ext_id: agentExtId } }
7186
+ }),
7187
+ "Could not start Slack authorization"
7188
+ );
7189
+ return data.url;
7190
+ }
7191
+ async function disconnectSlack(arbi) {
7192
+ requireOk(await arbi.fetch.DELETE("/v1/slack/me"), "Failed to disconnect Slack");
7193
+ }
7194
+ var MAILBOX_SYNC_VENDORS = ["microsoft", "gmail"];
7195
+ var DRIVE_SYNC_VENDORS = [
7196
+ "microsoft",
7197
+ "gmail",
7198
+ "microsoft_sharepoint",
7199
+ "clio",
7200
+ "box",
7201
+ "dropbox",
7202
+ "onenote"
7203
+ ];
7204
+ var MICROSOFT_VENDORS = ["microsoft", "ms365_mail"];
7205
+ var GOOGLE_VENDORS = ["gmail", "gdrive"];
7206
+ var IMANAGE_VENDORS = ["imanage"];
7207
+ var SHAREPOINT_VENDORS = ["microsoft_sharepoint"];
7208
+ var includes = (list, vendor) => list.includes(vendor);
7209
+ var isMailboxSyncVendor = (vendor) => includes(MAILBOX_SYNC_VENDORS, vendor);
7210
+ var isDriveSyncVendor = (vendor) => includes(DRIVE_SYNC_VENDORS, vendor);
7211
+ var isSharePointVendor = (vendor) => includes(SHAREPOINT_VENDORS, vendor);
7212
+ function isConnectorVendorVisible(settings, vendor) {
7213
+ if (includes(MICROSOFT_VENDORS, vendor)) return settings?.show_connector_microsoft ?? true;
7214
+ if (includes(GOOGLE_VENDORS, vendor)) return settings?.show_connector_google ?? true;
7215
+ if (includes(IMANAGE_VENDORS, vendor)) return settings?.show_connector_imanage ?? false;
7216
+ if (includes(SHAREPOINT_VENDORS, vendor)) return settings?.show_connector_sharepoint ?? false;
7217
+ return true;
7218
+ }
7219
+ var CONNECT_ERROR_PRODUCTS = {
7220
+ microsoft: "Microsoft",
7221
+ microsoft_sharepoint: "SharePoint",
7222
+ gmail: "Google",
7223
+ gdrive: "Google Drive",
7224
+ imanage: "iManage",
7225
+ slack: "Slack"
7226
+ };
7227
+ function connectErrorMessage(vendor) {
7228
+ const product = vendor && CONNECT_ERROR_PRODUCTS[vendor] || "the account";
7229
+ return `Couldn't connect ${product}. The connection was cancelled or not approved.`;
7230
+ }
7231
+ async function bridgeConnectorTokens(arbi, keys, { vendor, autoSyncWorkspaceExtId } = {}) {
7232
+ await initSodium();
7233
+ const keypair = encryptionKeypairFromSigningKey(keys.signingPrivateKey);
7234
+ try {
7235
+ let sealed = await getSealedTokens(arbi);
7236
+ if (vendor) sealed = sealed.filter((token) => token.vendor_key === vendor);
7237
+ for (const token of sealed) {
7238
+ try {
7239
+ const reseal = async (wrapped) => {
7240
+ const plain = sealedBoxDecrypt(wrapped, keypair.secretKey);
7241
+ try {
7242
+ return await sealKeyForSession(plain, keys.serverSessionKey);
7243
+ } finally {
7244
+ plain.fill(0);
7245
+ }
7246
+ };
7247
+ await depositSessionTokens(arbi, {
7248
+ vendor_key: token.vendor_key,
7249
+ access: await reseal(token.access_token),
7250
+ refresh: token.refresh_token ? await reseal(token.refresh_token) : null,
7251
+ ...autoSyncWorkspaceExtId ? { auto_sync_workspace_ext_id: autoSyncWorkspaceExtId } : {}
7252
+ });
7253
+ } catch (err) {
7254
+ console.error("[connectors] Could not bridge the token of", token.vendor_key, err);
7255
+ }
7256
+ }
7257
+ } finally {
7258
+ keypair.secretKey.fill(0);
7259
+ }
7260
+ }
7261
+
6946
7262
  // src/operations/agentconfig.ts
6947
7263
  var agentconfig_exports = {};
6948
7264
  __export(agentconfig_exports, {
@@ -7231,6 +7547,11 @@ async function remove(arbi) {
7231
7547
  // src/operations/projects.ts
7232
7548
  var projects_exports = {};
7233
7549
  __export(projects_exports, {
7550
+ addAddonBlock: () => addAddonBlock,
7551
+ billingPortal: () => billingPortal,
7552
+ cancelSubscription: () => cancelSubscription,
7553
+ changePlan: () => changePlan,
7554
+ createCheckout: () => createCheckout,
7234
7555
  createProject: () => createProject,
7235
7556
  deleteProject: () => deleteProject,
7236
7557
  formatBudget: () => formatBudget,
@@ -7238,11 +7559,17 @@ __export(projects_exports, {
7238
7559
  getProjectInvoices: () => getProjectInvoices,
7239
7560
  getProjectUsage: () => getProjectUsage,
7240
7561
  getUserUsageToday: () => getUserUsageToday,
7562
+ listProducts: () => listProducts,
7241
7563
  listProjectEvents: () => listProjectEvents,
7242
7564
  listProjects: () => listProjects,
7243
7565
  parseBudget: () => parseBudget,
7566
+ previewPlanChange: () => previewPlanChange,
7567
+ quoteAddon: () => quoteAddon,
7568
+ quotePlan: () => quotePlan,
7244
7569
  refreshProject: () => refreshProject,
7245
7570
  renameProject: () => renameProject,
7571
+ setNextPeriodAddons: () => setNextPeriodAddons,
7572
+ updateAddonSettings: () => updateAddonSettings,
7246
7573
  updateProject: () => updateProject
7247
7574
  });
7248
7575
  async function listProjects(arbi, filters = {}) {
@@ -7365,6 +7692,95 @@ async function getProjectInvoices(arbi, projectExtId) {
7365
7692
  async function getUserUsageToday(arbi) {
7366
7693
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
7367
7694
  }
7695
+ var projectPath = (projectExtId) => ({ path: { project_ext_id: projectExtId } });
7696
+ async function listProducts(arbi) {
7697
+ return requireData(await arbi.fetch.GET("/v1/user/products"), "Failed to load the plans");
7698
+ }
7699
+ async function quotePlan(arbi, projectExtId, body) {
7700
+ return requireData(
7701
+ projectExtId ? await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout/quote", {
7702
+ params: projectPath(projectExtId),
7703
+ body
7704
+ }) : await arbi.fetch.POST("/v1/user/projects/quote", { body }),
7705
+ "Failed to price the plan"
7706
+ );
7707
+ }
7708
+ async function createCheckout(arbi, projectExtId, body) {
7709
+ return requireData(
7710
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout", {
7711
+ params: projectPath(projectExtId),
7712
+ body
7713
+ }),
7714
+ "Failed to start the checkout"
7715
+ );
7716
+ }
7717
+ async function changePlan(arbi, projectExtId, body) {
7718
+ return requireData(
7719
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/change-plan", {
7720
+ params: projectPath(projectExtId),
7721
+ body
7722
+ }),
7723
+ "Failed to change the plan"
7724
+ );
7725
+ }
7726
+ async function previewPlanChange(arbi, projectExtId, body) {
7727
+ return requireData(
7728
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/plan/preview", {
7729
+ params: projectPath(projectExtId),
7730
+ body
7731
+ }),
7732
+ "Failed to price the plan change"
7733
+ );
7734
+ }
7735
+ async function quoteAddon(arbi, projectExtId, kind) {
7736
+ return requireData(
7737
+ await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/addons/quote", {
7738
+ params: { ...projectPath(projectExtId), query: { kind } }
7739
+ }),
7740
+ "Failed to price the add-on"
7741
+ );
7742
+ }
7743
+ async function billingPortal(arbi, projectExtId) {
7744
+ return requireData(
7745
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/billing-portal", {
7746
+ params: projectPath(projectExtId)
7747
+ }),
7748
+ "Failed to open the billing portal"
7749
+ );
7750
+ }
7751
+ async function addAddonBlock(arbi, projectExtId, kind) {
7752
+ const params = projectPath(projectExtId);
7753
+ return requireData(
7754
+ 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 }),
7755
+ "Failed to add the add-on"
7756
+ );
7757
+ }
7758
+ async function setNextPeriodAddons(arbi, projectExtId, body) {
7759
+ return requireData(
7760
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/next-period", {
7761
+ params: projectPath(projectExtId),
7762
+ body
7763
+ }),
7764
+ "Failed to change the add-ons"
7765
+ );
7766
+ }
7767
+ async function updateAddonSettings(arbi, projectExtId, body) {
7768
+ return requireData(
7769
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/settings", {
7770
+ params: projectPath(projectExtId),
7771
+ body
7772
+ }),
7773
+ "Failed to save the add-on settings"
7774
+ );
7775
+ }
7776
+ async function cancelSubscription(arbi, projectExtId) {
7777
+ return requireData(
7778
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/cancel", {
7779
+ params: projectPath(projectExtId)
7780
+ }),
7781
+ "Failed to cancel the subscription"
7782
+ );
7783
+ }
7368
7784
 
7369
7785
  // src/operations/work.ts
7370
7786
  var work_exports = {};
@@ -8456,10 +8872,8 @@ __export(calendar_exports, {
8456
8872
  cancelPublicBooking: () => cancelPublicBooking,
8457
8873
  connectCalDavAccount: () => connectCalDavAccount,
8458
8874
  connectOAuthAccount: () => connectOAuthAccount,
8459
- createAppPassword: () => createAppPassword,
8460
8875
  createCalendar: () => createCalendar,
8461
8876
  createEvent: () => createEvent,
8462
- createFeed: () => createFeed,
8463
8877
  createRoom: () => createRoom,
8464
8878
  decideCounter: () => decideCounter,
8465
8879
  deleteBookingPage: () => deleteBookingPage,
@@ -8476,7 +8890,6 @@ __export(calendar_exports, {
8476
8890
  getPublicBookingPage: () => getPublicBookingPage,
8477
8891
  importCalendarIcs: () => importCalendarIcs,
8478
8892
  listAccounts: () => listAccounts,
8479
- listAppPasswords: () => listAppPasswords,
8480
8893
  listBookingPages: () => listBookingPages,
8481
8894
  listCalDavProfiles: () => listCalDavProfiles,
8482
8895
  listCalendars: () => listCalendars,
@@ -8494,9 +8907,7 @@ __export(calendar_exports, {
8494
8907
  putCalendarSettings: () => putCalendarSettings,
8495
8908
  refreshCalendar: () => refreshCalendar,
8496
8909
  respondToEvent: () => respondToEvent,
8497
- revokeAppPassword: () => revokeAppPassword,
8498
8910
  shareCalendar: () => shareCalendar,
8499
- splitAppPasswords: () => splitAppPasswords,
8500
8911
  subscribeCalendar: () => subscribeCalendar,
8501
8912
  syncAccount: () => syncAccount,
8502
8913
  unlockCalendarKeys: () => unlockCalendarKeys,
@@ -8884,46 +9295,6 @@ async function publishCalendarToAccount(client, accId, calendarId) {
8884
9295
  "Publishing the calendar"
8885
9296
  );
8886
9297
  }
8887
- async function listAppPasswords(client) {
8888
- return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
8889
- }
8890
- async function createAppPassword(client, body) {
8891
- return take(
8892
- await client.fetch.POST("/v1/calendar/app-passwords", {
8893
- body: {
8894
- label: body.label.trim(),
8895
- calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
8896
- }
8897
- }),
8898
- "Creating the app password"
8899
- );
8900
- }
8901
- async function createFeed(client, body) {
8902
- return take(
8903
- await client.fetch.POST("/v1/calendar/feeds", {
8904
- body: {
8905
- calendar_id: body.calendar_id,
8906
- level: body.level,
8907
- label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
8908
- }
8909
- }),
8910
- "Creating the feed"
8911
- );
8912
- }
8913
- async function revokeAppPassword(client, apwId) {
8914
- take(
8915
- await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
8916
- params: { path: { apw_id: apwId } }
8917
- }),
8918
- "Revoking"
8919
- );
8920
- }
8921
- function splitAppPasswords(rows) {
8922
- return {
8923
- devices: rows.filter((r2) => r2.kind === "dav"),
8924
- feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
8925
- };
8926
- }
8927
9298
  async function listBookingPages(client) {
8928
9299
  return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8929
9300
  }
@@ -9292,7 +9663,23 @@ var Arbi = class {
9292
9663
  /** AI usage + spend breakdown for a project's billing period. */
9293
9664
  usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
9294
9665
  /** Stripe invoices for a project's subscription. */
9295
- invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId)
9666
+ invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId),
9667
+ /** Delete a project (only when empty: no workspaces, no subscription). */
9668
+ delete: (projectExtId) => deleteProject(this.requireClient(), projectExtId),
9669
+ /** The plans and add-ons on sale. */
9670
+ products: () => listProducts(this.requireClient()),
9671
+ /** The taxed total of a Pro purchase (a new project when `projectExtId` is null). */
9672
+ quotePlan: (projectExtId, body) => quotePlan(this.requireClient(), projectExtId, body),
9673
+ /** Start an embedded Stripe checkout; returns its `client_secret`. */
9674
+ checkout: (projectExtId, body) => createCheckout(this.requireClient(), projectExtId, body),
9675
+ changePlan: (projectExtId, body) => changePlan(this.requireClient(), projectExtId, body),
9676
+ previewPlanChange: (projectExtId, body) => previewPlanChange(this.requireClient(), projectExtId, body),
9677
+ quoteAddon: (projectExtId, kind) => quoteAddon(this.requireClient(), projectExtId, kind),
9678
+ billingPortal: (projectExtId) => billingPortal(this.requireClient(), projectExtId),
9679
+ addAddonBlock: (projectExtId, kind) => addAddonBlock(this.requireClient(), projectExtId, kind),
9680
+ setNextPeriodAddons: (projectExtId, body) => setNextPeriodAddons(this.requireClient(), projectExtId, body),
9681
+ updateAddonSettings: (projectExtId, body) => updateAddonSettings(this.requireClient(), projectExtId, body),
9682
+ cancelSubscription: (projectExtId) => cancelSubscription(this.requireClient(), projectExtId)
9296
9683
  };
9297
9684
  // ── User (account-scoped usage) ───────────────────────────────────────
9298
9685
  user = {
@@ -9438,6 +9825,8 @@ var Arbi = class {
9438
9825
  }
9439
9826
  // ── Workspaces ────────────────────────────────────────────────────────
9440
9827
  workspaces = {
9828
+ /** Hand this server session a workspace's key (sealed to the session) without opening it. */
9829
+ primeKey: (workspaceExtId, sessionSealedKey) => primeWorkspaceKey(this.requireClient(), workspaceExtId, sessionSealedKey),
9441
9830
  list: async () => this.rememberWorkspaces(await listWorkspaces(this.requireClient())),
9442
9831
  create: async (name, projectExtId, description, isPublic) => {
9443
9832
  const client = this.requireClient();
@@ -9782,7 +10171,8 @@ var Arbi = class {
9782
10171
  /** The skills the caller can run (own + shared marketplace), metadata only. */
9783
10172
  listSkills: (options) => listSkills(this.requireClient(), options),
9784
10173
  /**
9785
- * Search documents without LLM generation (retrieval only).
10174
+ * Search documents without LLM generation (retrieval only). No `docIds` searches the whole
10175
+ * workspace; `searchChunks(result)` ranks the passages found.
9786
10176
  */
9787
10177
  retrieve: (query, docIds, options) => retrieve({
9788
10178
  arbi: this.requireClient(),
@@ -9912,10 +10302,6 @@ var Arbi = class {
9912
10302
  syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9913
10303
  disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9914
10304
  publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
9915
- listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
9916
- createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
9917
- createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
9918
- revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
9919
10305
  listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9920
10306
  putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9921
10307
  deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
@@ -10028,6 +10414,49 @@ var Arbi = class {
10028
10414
  /** List the current user's durable activity feed. */
10029
10415
  listActivity: (options) => listActivity(this.requireClient(), options)
10030
10416
  };
10417
+ // ── Connectors ────────────────────────────────────────────────────────
10418
+ /**
10419
+ * Connectors: the catalog, the user's connections and their OAuth, mailbox and drive sync,
10420
+ * Slack. A vendor is its `vendor_key` (e.g. `microsoft`, `gmail`).
10421
+ */
10422
+ connectors = {
10423
+ catalog: () => listCatalog(this.requireClient()),
10424
+ mine: () => listMine(this.requireClient()),
10425
+ disconnect: (vendor) => disconnect(this.requireClient(), vendor),
10426
+ /** The provider consent URL; the OAuth comes back to `returnTo` (a path of this app). */
10427
+ authorize: (vendor, returnTo) => authorize(this.requireClient(), vendor, returnTo),
10428
+ /**
10429
+ * Let this server session use the user's connector grants (best effort: a failure is logged,
10430
+ * never thrown, so it cannot break a sign-in or a connect). Signed out: nothing to bridge.
10431
+ */
10432
+ bridgeTokens: async (options) => {
10433
+ const login = this.loginResult;
10434
+ if (!login) return;
10435
+ try {
10436
+ await bridgeConnectorTokens(this.requireClient(), login, options);
10437
+ } catch (err) {
10438
+ console.error("[connectors] Token bridge failed", err);
10439
+ }
10440
+ },
10441
+ mailboxFolders: (vendor) => listMailboxFolders(this.requireClient(), vendor),
10442
+ enableMailboxSync: (vendor, body) => enableMailboxSync(this.requireClient(), vendor, body),
10443
+ syncMailbox: (vendor, workspaceExtId) => triggerMailboxSync(this.requireClient(), vendor, workspaceExtId),
10444
+ mailboxSyncProgress: (vendor, workspaceExtId) => mailboxSyncProgress(this.requireClient(), vendor, workspaceExtId),
10445
+ cancelMailboxSync: (vendor, workspaceExtId) => cancelMailboxSync(this.requireClient(), vendor, workspaceExtId),
10446
+ driveFolders: (vendor) => listDriveFolders(this.requireClient(), vendor),
10447
+ driveFolderChildren: (vendor, itemId) => listDriveFolderChildren(this.requireClient(), vendor, itemId),
10448
+ driveFolderDocCount: (vendor, itemId) => driveFolderDocCount(this.requireClient(), vendor, itemId),
10449
+ enableDriveSync: (vendor, body) => enableDriveSync(this.requireClient(), vendor, body),
10450
+ syncDrive: (vendor) => triggerDriveSync(this.requireClient(), vendor),
10451
+ driveSyncEstimate: (vendor) => driveSyncEstimate(this.requireClient(), vendor),
10452
+ driveSyncProgress: (vendor) => driveSyncProgress(this.requireClient(), vendor),
10453
+ cancelDriveSync: (vendor) => cancelDriveSync(this.requireClient(), vendor),
10454
+ slack: {
10455
+ status: () => slackStatus(this.requireClient()),
10456
+ authorize: (agentExtId) => authorizeSlack(this.requireClient(), agentExtId),
10457
+ disconnect: () => disconnectSlack(this.requireClient())
10458
+ }
10459
+ };
10031
10460
  // ── Settings ──────────────────────────────────────────────────────────
10032
10461
  settings = {
10033
10462
  get: () => getSettings(this.requireClient()),
@@ -11260,6 +11689,6 @@ async function startDmListener(options) {
11260
11689
  };
11261
11690
  }
11262
11691
 
11263
- export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ClaudeOrchestrator, DEFAULT_AI_USD_PER_GBP, DOC_TERMINAL_STATUSES, FLAT_TAG_KINDS, FileConfigStore, OpenClawOrchestrator, PlanStepsError, PublicBookingError, STEP_FIELD_OPTION_TONES, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, buildDocNameMap, 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, createDocumentWaiter, device_flow_exports as deviceFlow, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, facts_exports as facts, files_exports as files, filterSkills, firm_exports as firm, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getErrorCode, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, health_exports as health, house_template_exports as houseTemplates, identityErrorCode, identity_exports as identityVerification, isSharedSkill, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, 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, signature_requests_exports as signatureRequests, splitAppPasswords, startDmListener, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, uploadSkill, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
11692
+ export { ACCOUNT_VENDOR, Arbi, ArbiApiError, ArbiError, ArbiSessionExpiredError, ClaudeOrchestrator, DEFAULT_AI_USD_PER_GBP, DOC_TERMINAL_STATUSES, DRIVE_SYNC_VENDORS, FLAT_TAG_KINDS, FileConfigStore, GOOGLE_VENDORS, IMANAGE_VENDORS, MAILBOX_SYNC_VENDORS, MAX_RETRIEVE_DOC_IDS, MICROSOFT_VENDORS, OpenClawOrchestrator, PlanStepsError, PublicBookingError, SHAREPOINT_VENDORS, STEP_FIELD_OPTION_TONES, TAG_KINDS, WebSocketAuthError, account_exports as account, agentconfig_exports as agentconfig, agents_exports as agents, assistant_exports as assistant, authenticatedFetch, bookPublicSlot, buildCitationChunkData, buildDocNameMap, 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, createDocumentWaiter, device_flow_exports as deviceFlow, doctags_exports as doctags, documents_exports as documents, documents_node_exports as documentsNode, facts_exports as facts, files_exports as files, filterSkills, firm_exports as firm, formatAgentStepLabel, formatFileSize, formatGbp, formatGbpPerMillionTokens, formatItemLabel, formatStreamSummary, formatUserName, formatWorkspaceChoices, formatWsMessage, generateEncryptedWorkspaceKey, generateNewWorkspaceKey, getErrorCode, getErrorMessage, getPublicBookingPage, getRawWorkspaceKey, health_exports as health, house_template_exports as houseTemplates, identityErrorCode, identity_exports as identityVerification, isConnectorVendorVisible, isDriveSyncVendor, isMailboxSyncVendor, isSharePointVendor, isSharedSkill, listen_exports as listen, mail_exports as mail, mail_node_exports as mailNode, notifications_exports as notifications, parseSSEEvents, parseSlashCommand, parseSlashTokenInProgress, performPasswordLogin, performSigningKeyLogin, performSsoDeviceFlowLogin, 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, signature_requests_exports as signatureRequests, startDmListener, streamSSE, stripCitationMarkdown, summarizeCitations, tags_exports as tags, uploadSkill, usdToGbp, work_exports as work, workflow_steps_exports as workflowSteps, workflows_exports as workflows, workspaces_exports as workspaces };
11264
11693
  //# sourceMappingURL=index.js.map
11265
11694
  //# sourceMappingURL=index.js.map