@arbidocs/sdk 0.4.147 → 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
@@ -5166,6 +5166,7 @@ async function updateConversationAssistantMode(arbi, conversationId, assistantMo
5166
5166
  // src/operations/assistant.ts
5167
5167
  var assistant_exports = {};
5168
5168
  __export(assistant_exports, {
5169
+ MAX_RETRIEVE_DOC_IDS: () => MAX_RETRIEVE_DOC_IDS,
5169
5170
  buildFactsContextTool: () => buildFactsContextTool,
5170
5171
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
5171
5172
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
@@ -5180,6 +5181,7 @@ __export(assistant_exports, {
5180
5181
  queryAssistant: () => queryAssistant,
5181
5182
  respondToAgent: () => respondToAgent,
5182
5183
  retrieve: () => retrieve,
5184
+ searchChunks: () => searchChunks,
5183
5185
  uploadSkill: () => uploadSkill
5184
5186
  });
5185
5187
  function buildRetrievalChunkTool(docIds, searchMode) {
@@ -5213,8 +5215,19 @@ function buildRetrievalTocTool(docIds) {
5213
5215
  tool_responses: {}
5214
5216
  };
5215
5217
  }
5218
+ var MAX_RETRIEVE_DOC_IDS = 5e3;
5216
5219
  async function retrieve(options) {
5217
- 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;
5218
5231
  const tools = {
5219
5232
  retrieval_chunk: buildRetrievalChunkTool(docIds, searchMode)
5220
5233
  };
@@ -5229,7 +5242,7 @@ async function retrieve(options) {
5229
5242
  workspace_ext_id: workspaceId,
5230
5243
  stream: false,
5231
5244
  background: false,
5232
- store: true,
5245
+ store,
5233
5246
  tools,
5234
5247
  ...model ? { model } : {}
5235
5248
  };
@@ -5249,6 +5262,34 @@ async function retrieve(options) {
5249
5262
  }
5250
5263
  return data;
5251
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
+ }
5252
5293
  async function queryAssistant(options) {
5253
5294
  const {
5254
5295
  workspaceId,
@@ -6919,6 +6960,11 @@ async function remove(arbi) {
6919
6960
  // src/operations/projects.ts
6920
6961
  var projects_exports = {};
6921
6962
  __export(projects_exports, {
6963
+ addAddonBlock: () => addAddonBlock,
6964
+ billingPortal: () => billingPortal,
6965
+ cancelSubscription: () => cancelSubscription,
6966
+ changePlan: () => changePlan,
6967
+ createCheckout: () => createCheckout,
6922
6968
  createProject: () => createProject,
6923
6969
  deleteProject: () => deleteProject,
6924
6970
  formatBudget: () => formatBudget,
@@ -6926,11 +6972,17 @@ __export(projects_exports, {
6926
6972
  getProjectInvoices: () => getProjectInvoices,
6927
6973
  getProjectUsage: () => getProjectUsage,
6928
6974
  getUserUsageToday: () => getUserUsageToday,
6975
+ listProducts: () => listProducts,
6929
6976
  listProjectEvents: () => listProjectEvents,
6930
6977
  listProjects: () => listProjects,
6931
6978
  parseBudget: () => parseBudget,
6979
+ previewPlanChange: () => previewPlanChange,
6980
+ quoteAddon: () => quoteAddon,
6981
+ quotePlan: () => quotePlan,
6932
6982
  refreshProject: () => refreshProject,
6933
6983
  renameProject: () => renameProject,
6984
+ setNextPeriodAddons: () => setNextPeriodAddons,
6985
+ updateAddonSettings: () => updateAddonSettings,
6934
6986
  updateProject: () => updateProject
6935
6987
  });
6936
6988
  async function listProjects(arbi, filters = {}) {
@@ -7053,6 +7105,95 @@ async function getProjectInvoices(arbi, projectExtId) {
7053
7105
  async function getUserUsageToday(arbi) {
7054
7106
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
7055
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
+ }
7056
7197
 
7057
7198
  // src/operations/work.ts
7058
7199
  var work_exports = {};
@@ -8144,10 +8285,8 @@ __export(calendar_exports, {
8144
8285
  cancelPublicBooking: () => cancelPublicBooking,
8145
8286
  connectCalDavAccount: () => connectCalDavAccount,
8146
8287
  connectOAuthAccount: () => connectOAuthAccount,
8147
- createAppPassword: () => createAppPassword,
8148
8288
  createCalendar: () => createCalendar,
8149
8289
  createEvent: () => createEvent,
8150
- createFeed: () => createFeed,
8151
8290
  createRoom: () => createRoom,
8152
8291
  decideCounter: () => decideCounter,
8153
8292
  deleteBookingPage: () => deleteBookingPage,
@@ -8164,7 +8303,6 @@ __export(calendar_exports, {
8164
8303
  getPublicBookingPage: () => getPublicBookingPage,
8165
8304
  importCalendarIcs: () => importCalendarIcs,
8166
8305
  listAccounts: () => listAccounts,
8167
- listAppPasswords: () => listAppPasswords,
8168
8306
  listBookingPages: () => listBookingPages,
8169
8307
  listCalDavProfiles: () => listCalDavProfiles,
8170
8308
  listCalendars: () => listCalendars,
@@ -8182,9 +8320,7 @@ __export(calendar_exports, {
8182
8320
  putCalendarSettings: () => putCalendarSettings,
8183
8321
  refreshCalendar: () => refreshCalendar,
8184
8322
  respondToEvent: () => respondToEvent,
8185
- revokeAppPassword: () => revokeAppPassword,
8186
8323
  shareCalendar: () => shareCalendar,
8187
- splitAppPasswords: () => splitAppPasswords,
8188
8324
  subscribeCalendar: () => subscribeCalendar,
8189
8325
  syncAccount: () => syncAccount,
8190
8326
  unlockCalendarKeys: () => unlockCalendarKeys,
@@ -8572,46 +8708,6 @@ async function publishCalendarToAccount(client, accId, calendarId) {
8572
8708
  "Publishing the calendar"
8573
8709
  );
8574
8710
  }
8575
- async function listAppPasswords(client) {
8576
- return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
8577
- }
8578
- async function createAppPassword(client, body) {
8579
- return take(
8580
- await client.fetch.POST("/v1/calendar/app-passwords", {
8581
- body: {
8582
- label: body.label.trim(),
8583
- calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
8584
- }
8585
- }),
8586
- "Creating the app password"
8587
- );
8588
- }
8589
- async function createFeed(client, body) {
8590
- return take(
8591
- await client.fetch.POST("/v1/calendar/feeds", {
8592
- body: {
8593
- calendar_id: body.calendar_id,
8594
- level: body.level,
8595
- label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
8596
- }
8597
- }),
8598
- "Creating the feed"
8599
- );
8600
- }
8601
- async function revokeAppPassword(client, apwId) {
8602
- take(
8603
- await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
8604
- params: { path: { apw_id: apwId } }
8605
- }),
8606
- "Revoking"
8607
- );
8608
- }
8609
- function splitAppPasswords(rows) {
8610
- return {
8611
- devices: rows.filter((r2) => r2.kind === "dav"),
8612
- feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
8613
- };
8614
- }
8615
8711
  async function listBookingPages(client) {
8616
8712
  return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8617
8713
  }
@@ -8980,7 +9076,23 @@ var Arbi = class {
8980
9076
  /** AI usage + spend breakdown for a project's billing period. */
8981
9077
  usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
8982
9078
  /** Stripe invoices for a project's subscription. */
8983
- 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)
8984
9096
  };
8985
9097
  // ── User (account-scoped usage) ───────────────────────────────────────
8986
9098
  user = {
@@ -9472,7 +9584,8 @@ var Arbi = class {
9472
9584
  /** The skills the caller can run (own + shared marketplace), metadata only. */
9473
9585
  listSkills: (options) => listSkills(this.requireClient(), options),
9474
9586
  /**
9475
- * 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.
9476
9589
  */
9477
9590
  retrieve: (query, docIds, options) => retrieve({
9478
9591
  arbi: this.requireClient(),
@@ -9602,10 +9715,6 @@ var Arbi = class {
9602
9715
  syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9603
9716
  disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9604
9717
  publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
9605
- listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
9606
- createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
9607
- createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
9608
- revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
9609
9718
  listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9610
9719
  putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9611
9720
  deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
@@ -9930,6 +10039,7 @@ exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
9930
10039
  exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
9931
10040
  exports.IMANAGE_VENDORS = IMANAGE_VENDORS;
9932
10041
  exports.MAILBOX_SYNC_VENDORS = MAILBOX_SYNC_VENDORS;
10042
+ exports.MAX_RETRIEVE_DOC_IDS = MAX_RETRIEVE_DOC_IDS;
9933
10043
  exports.MICROSOFT_VENDORS = MICROSOFT_VENDORS;
9934
10044
  exports.PlanStepsError = PlanStepsError;
9935
10045
  exports.PublicBookingError = PublicBookingError;
@@ -9995,11 +10105,11 @@ exports.resolveAuth = resolveAuth;
9995
10105
  exports.resolveCitations = resolveCitations;
9996
10106
  exports.resolveWorkspace = resolveWorkspace;
9997
10107
  exports.responses = responses_exports;
10108
+ exports.searchChunks = searchChunks;
9998
10109
  exports.selectWorkspace = selectWorkspace;
9999
10110
  exports.selectWorkspaceById = selectWorkspaceById;
10000
10111
  exports.sessions = sessions_exports;
10001
10112
  exports.settings = settings_exports;
10002
- exports.splitAppPasswords = splitAppPasswords;
10003
10113
  exports.streamSSE = streamSSE;
10004
10114
  exports.stripCitationMarkdown = stripCitationMarkdown;
10005
10115
  exports.summarizeCitations = summarizeCitations;