@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/index.cjs CHANGED
@@ -5741,6 +5741,7 @@ async function updateConversationAssistantMode(arbi, conversationId, assistantMo
5741
5741
  // src/operations/assistant.ts
5742
5742
  var assistant_exports = {};
5743
5743
  __export(assistant_exports, {
5744
+ MAX_RETRIEVE_DOC_IDS: () => MAX_RETRIEVE_DOC_IDS,
5744
5745
  buildFactsContextTool: () => buildFactsContextTool,
5745
5746
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
5746
5747
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
@@ -5755,6 +5756,7 @@ __export(assistant_exports, {
5755
5756
  queryAssistant: () => queryAssistant,
5756
5757
  respondToAgent: () => respondToAgent,
5757
5758
  retrieve: () => retrieve,
5759
+ searchChunks: () => searchChunks,
5758
5760
  uploadSkill: () => uploadSkill
5759
5761
  });
5760
5762
  function buildRetrievalChunkTool(docIds, searchMode) {
@@ -5788,8 +5790,19 @@ function buildRetrievalTocTool(docIds) {
5788
5790
  tool_responses: {}
5789
5791
  };
5790
5792
  }
5793
+ var MAX_RETRIEVE_DOC_IDS = 5e3;
5791
5794
  async function retrieve(options) {
5792
- 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;
5793
5806
  const tools = {
5794
5807
  retrieval_chunk: buildRetrievalChunkTool(docIds, searchMode)
5795
5808
  };
@@ -5804,7 +5817,7 @@ async function retrieve(options) {
5804
5817
  workspace_ext_id: workspaceId,
5805
5818
  stream: false,
5806
5819
  background: false,
5807
- store: true,
5820
+ store,
5808
5821
  tools,
5809
5822
  ...model ? { model } : {}
5810
5823
  };
@@ -5824,6 +5837,34 @@ async function retrieve(options) {
5824
5837
  }
5825
5838
  return data;
5826
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
+ }
5827
5868
  async function queryAssistant(options) {
5828
5869
  const {
5829
5870
  workspaceId,
@@ -7515,6 +7556,11 @@ async function remove(arbi) {
7515
7556
  // src/operations/projects.ts
7516
7557
  var projects_exports = {};
7517
7558
  __export(projects_exports, {
7559
+ addAddonBlock: () => addAddonBlock,
7560
+ billingPortal: () => billingPortal,
7561
+ cancelSubscription: () => cancelSubscription,
7562
+ changePlan: () => changePlan,
7563
+ createCheckout: () => createCheckout,
7518
7564
  createProject: () => createProject,
7519
7565
  deleteProject: () => deleteProject,
7520
7566
  formatBudget: () => formatBudget,
@@ -7522,11 +7568,17 @@ __export(projects_exports, {
7522
7568
  getProjectInvoices: () => getProjectInvoices,
7523
7569
  getProjectUsage: () => getProjectUsage,
7524
7570
  getUserUsageToday: () => getUserUsageToday,
7571
+ listProducts: () => listProducts,
7525
7572
  listProjectEvents: () => listProjectEvents,
7526
7573
  listProjects: () => listProjects,
7527
7574
  parseBudget: () => parseBudget,
7575
+ previewPlanChange: () => previewPlanChange,
7576
+ quoteAddon: () => quoteAddon,
7577
+ quotePlan: () => quotePlan,
7528
7578
  refreshProject: () => refreshProject,
7529
7579
  renameProject: () => renameProject,
7580
+ setNextPeriodAddons: () => setNextPeriodAddons,
7581
+ updateAddonSettings: () => updateAddonSettings,
7530
7582
  updateProject: () => updateProject
7531
7583
  });
7532
7584
  async function listProjects(arbi, filters = {}) {
@@ -7649,6 +7701,95 @@ async function getProjectInvoices(arbi, projectExtId) {
7649
7701
  async function getUserUsageToday(arbi) {
7650
7702
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
7651
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
+ }
7652
7793
 
7653
7794
  // src/operations/work.ts
7654
7795
  var work_exports = {};
@@ -8740,10 +8881,8 @@ __export(calendar_exports, {
8740
8881
  cancelPublicBooking: () => cancelPublicBooking,
8741
8882
  connectCalDavAccount: () => connectCalDavAccount,
8742
8883
  connectOAuthAccount: () => connectOAuthAccount,
8743
- createAppPassword: () => createAppPassword,
8744
8884
  createCalendar: () => createCalendar,
8745
8885
  createEvent: () => createEvent,
8746
- createFeed: () => createFeed,
8747
8886
  createRoom: () => createRoom,
8748
8887
  decideCounter: () => decideCounter,
8749
8888
  deleteBookingPage: () => deleteBookingPage,
@@ -8760,7 +8899,6 @@ __export(calendar_exports, {
8760
8899
  getPublicBookingPage: () => getPublicBookingPage,
8761
8900
  importCalendarIcs: () => importCalendarIcs,
8762
8901
  listAccounts: () => listAccounts,
8763
- listAppPasswords: () => listAppPasswords,
8764
8902
  listBookingPages: () => listBookingPages,
8765
8903
  listCalDavProfiles: () => listCalDavProfiles,
8766
8904
  listCalendars: () => listCalendars,
@@ -8778,9 +8916,7 @@ __export(calendar_exports, {
8778
8916
  putCalendarSettings: () => putCalendarSettings,
8779
8917
  refreshCalendar: () => refreshCalendar,
8780
8918
  respondToEvent: () => respondToEvent,
8781
- revokeAppPassword: () => revokeAppPassword,
8782
8919
  shareCalendar: () => shareCalendar,
8783
- splitAppPasswords: () => splitAppPasswords,
8784
8920
  subscribeCalendar: () => subscribeCalendar,
8785
8921
  syncAccount: () => syncAccount,
8786
8922
  unlockCalendarKeys: () => unlockCalendarKeys,
@@ -9168,46 +9304,6 @@ async function publishCalendarToAccount(client, accId, calendarId) {
9168
9304
  "Publishing the calendar"
9169
9305
  );
9170
9306
  }
9171
- async function listAppPasswords(client) {
9172
- return take(await client.fetch.GET("/v1/calendar/app-passwords"), "Loading app passwords");
9173
- }
9174
- async function createAppPassword(client, body) {
9175
- return take(
9176
- await client.fetch.POST("/v1/calendar/app-passwords", {
9177
- body: {
9178
- label: body.label.trim(),
9179
- calendar_ids: body.calendar_ids?.length ? body.calendar_ids : null
9180
- }
9181
- }),
9182
- "Creating the app password"
9183
- );
9184
- }
9185
- async function createFeed(client, body) {
9186
- return take(
9187
- await client.fetch.POST("/v1/calendar/feeds", {
9188
- body: {
9189
- calendar_id: body.calendar_id,
9190
- level: body.level,
9191
- label: body.label?.trim() || (body.level === "full" ? "Feed" : "Free/busy feed")
9192
- }
9193
- }),
9194
- "Creating the feed"
9195
- );
9196
- }
9197
- async function revokeAppPassword(client, apwId) {
9198
- take(
9199
- await client.fetch.DELETE("/v1/calendar/app-passwords/{apw_id}", {
9200
- params: { path: { apw_id: apwId } }
9201
- }),
9202
- "Revoking"
9203
- );
9204
- }
9205
- function splitAppPasswords(rows) {
9206
- return {
9207
- devices: rows.filter((r2) => r2.kind === "dav"),
9208
- feeds: rows.filter((r2) => r2.kind === "feed" || r2.kind === "freebusy")
9209
- };
9210
- }
9211
9307
  async function listBookingPages(client) {
9212
9308
  return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
9213
9309
  }
@@ -9576,7 +9672,23 @@ var Arbi = class {
9576
9672
  /** AI usage + spend breakdown for a project's billing period. */
9577
9673
  usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
9578
9674
  /** Stripe invoices for a project's subscription. */
9579
- 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)
9580
9692
  };
9581
9693
  // ── User (account-scoped usage) ───────────────────────────────────────
9582
9694
  user = {
@@ -10068,7 +10180,8 @@ var Arbi = class {
10068
10180
  /** The skills the caller can run (own + shared marketplace), metadata only. */
10069
10181
  listSkills: (options) => listSkills(this.requireClient(), options),
10070
10182
  /**
10071
- * 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.
10072
10185
  */
10073
10186
  retrieve: (query, docIds, options) => retrieve({
10074
10187
  arbi: this.requireClient(),
@@ -10198,10 +10311,6 @@ var Arbi = class {
10198
10311
  syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
10199
10312
  disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
10200
10313
  publishToAccount: (accId, calendarId) => this.withCalendarKeys((c2) => publishCalendarToAccount(c2, accId, calendarId)),
10201
- listAppPasswords: () => this.withCalendarKeys((c2) => listAppPasswords(c2)),
10202
- createAppPassword: (body) => this.withCalendarKeys((c2) => createAppPassword(c2, body)),
10203
- createFeed: (body) => this.withCalendarKeys((c2) => createFeed(c2, body)),
10204
- revokeAppPassword: (apwId) => this.withCalendarKeys((c2) => revokeAppPassword(c2, apwId)),
10205
10314
  listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
10206
10315
  putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
10207
10316
  deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
@@ -11603,6 +11712,7 @@ exports.FileConfigStore = FileConfigStore;
11603
11712
  exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
11604
11713
  exports.IMANAGE_VENDORS = IMANAGE_VENDORS;
11605
11714
  exports.MAILBOX_SYNC_VENDORS = MAILBOX_SYNC_VENDORS;
11715
+ exports.MAX_RETRIEVE_DOC_IDS = MAX_RETRIEVE_DOC_IDS;
11606
11716
  exports.MICROSOFT_VENDORS = MICROSOFT_VENDORS;
11607
11717
  exports.OpenClawOrchestrator = OpenClawOrchestrator;
11608
11718
  exports.PlanStepsError = PlanStepsError;
@@ -11686,12 +11796,12 @@ exports.resolveAuth = resolveAuth;
11686
11796
  exports.resolveCitations = resolveCitations;
11687
11797
  exports.resolveWorkspace = resolveWorkspace;
11688
11798
  exports.responses = responses_exports;
11799
+ exports.searchChunks = searchChunks;
11689
11800
  exports.selectWorkspace = selectWorkspace;
11690
11801
  exports.selectWorkspaceById = selectWorkspaceById;
11691
11802
  exports.sessions = sessions_exports;
11692
11803
  exports.settings = settings_exports;
11693
11804
  exports.signatureRequests = signature_requests_exports;
11694
- exports.splitAppPasswords = splitAppPasswords;
11695
11805
  exports.startDmListener = startDmListener;
11696
11806
  exports.streamSSE = streamSSE;
11697
11807
  exports.stripCitationMarkdown = stripCitationMarkdown;