@arbidocs/sdk 0.4.147 → 0.4.150

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
@@ -3521,6 +3521,10 @@ var ArbiApiError = class extends ArbiError {
3521
3521
  this.detail = apiErrorDetail(apiError);
3522
3522
  }
3523
3523
  };
3524
+ function refusalReason(err, fallback) {
3525
+ if (err instanceof ArbiApiError) return err.detail || fallback;
3526
+ return apiErrorDetail(err) || fallback;
3527
+ }
3524
3528
  function requireData(result, message) {
3525
3529
  if (result.error || !result.data) {
3526
3530
  throw new ArbiApiError(message, result.error, result.response?.status);
@@ -4964,6 +4968,7 @@ async function listHouseTemplateCandidates(arbi) {
4964
4968
  // src/operations/workspaces.ts
4965
4969
  var workspaces_exports = {};
4966
4970
  __export(workspaces_exports, {
4971
+ addWorkspaceMembers: () => addWorkspaceMembers,
4967
4972
  addWorkspaceUsers: () => addWorkspaceUsers,
4968
4973
  copyDocuments: () => copyDocuments,
4969
4974
  createWorkspace: () => createWorkspace,
@@ -5011,6 +5016,12 @@ async function updateWorkspace(arbi, body) {
5011
5016
  async function listWorkspaceUsers(arbi) {
5012
5017
  return requireData(await arbi.fetch.GET("/v1/workspace/users"), "Failed to fetch workspace users");
5013
5018
  }
5019
+ async function addWorkspaceMembers(arbi, request) {
5020
+ return requireData(
5021
+ await arbi.fetch.POST("/v1/workspace/users", { body: request }),
5022
+ "Failed to add users"
5023
+ );
5024
+ }
5014
5025
  async function addWorkspaceUsers(arbi, emails, role = "collaborator", target, confirmInvite = false) {
5015
5026
  const invite = confirmInvite ? { confirm_invite: true } : {};
5016
5027
  return requireData(
@@ -5166,6 +5177,7 @@ async function updateConversationAssistantMode(arbi, conversationId, assistantMo
5166
5177
  // src/operations/assistant.ts
5167
5178
  var assistant_exports = {};
5168
5179
  __export(assistant_exports, {
5180
+ MAX_RETRIEVE_DOC_IDS: () => MAX_RETRIEVE_DOC_IDS,
5169
5181
  buildFactsContextTool: () => buildFactsContextTool,
5170
5182
  buildRetrievalChunkTool: () => buildRetrievalChunkTool,
5171
5183
  buildRetrievalFullContextTool: () => buildRetrievalFullContextTool,
@@ -5180,6 +5192,7 @@ __export(assistant_exports, {
5180
5192
  queryAssistant: () => queryAssistant,
5181
5193
  respondToAgent: () => respondToAgent,
5182
5194
  retrieve: () => retrieve,
5195
+ searchChunks: () => searchChunks,
5183
5196
  uploadSkill: () => uploadSkill
5184
5197
  });
5185
5198
  function buildRetrievalChunkTool(docIds, searchMode) {
@@ -5213,8 +5226,19 @@ function buildRetrievalTocTool(docIds) {
5213
5226
  tool_responses: {}
5214
5227
  };
5215
5228
  }
5229
+ var MAX_RETRIEVE_DOC_IDS = 5e3;
5216
5230
  async function retrieve(options) {
5217
- const { arbi, workspaceId, query, docIds, searchMode, fullContextDocIds, tocDocIds, model } = options;
5231
+ const {
5232
+ arbi,
5233
+ workspaceId,
5234
+ query,
5235
+ docIds,
5236
+ searchMode,
5237
+ fullContextDocIds,
5238
+ tocDocIds,
5239
+ model,
5240
+ store = true
5241
+ } = options;
5218
5242
  const tools = {
5219
5243
  retrieval_chunk: buildRetrievalChunkTool(docIds, searchMode)
5220
5244
  };
@@ -5229,7 +5253,7 @@ async function retrieve(options) {
5229
5253
  workspace_ext_id: workspaceId,
5230
5254
  stream: false,
5231
5255
  background: false,
5232
- store: true,
5256
+ store,
5233
5257
  tools,
5234
5258
  ...model ? { model } : {}
5235
5259
  };
@@ -5249,6 +5273,34 @@ async function retrieve(options) {
5249
5273
  }
5250
5274
  return data;
5251
5275
  }
5276
+ function isReadablePassage(content) {
5277
+ return content.length > 10 && content !== "-" && !/^[|\-\s]+$/.test(content);
5278
+ }
5279
+ function searchChunks(result) {
5280
+ const byId3 = /* @__PURE__ */ new Map();
5281
+ for (const [title, chunks] of Object.entries(result?.retrieval_chunk?.tool_responses ?? {})) {
5282
+ if (!Array.isArray(chunks)) continue;
5283
+ chunks.forEach((chunk, index) => {
5284
+ if (!chunk || typeof chunk !== "object") return;
5285
+ const content = chunk.content?.trim() ?? "";
5286
+ if (!isReadablePassage(content)) return;
5287
+ const meta = chunk.metadata ?? {};
5288
+ const docId = meta.doc_ext_id || title;
5289
+ const rerank = meta.rerank_score;
5290
+ byId3.set(meta.chunk_ext_id || `${docId}_${index}`, {
5291
+ id: meta.chunk_ext_id || `${docId}_${index}`,
5292
+ ...meta.chunk_ext_id ? { chunkExtId: meta.chunk_ext_id } : {},
5293
+ docId,
5294
+ docTitle: meta.doc_title || title,
5295
+ ...meta.page_number != null ? { page: meta.page_number } : {},
5296
+ score: rerank && rerank > 0 ? rerank : meta.score ?? 0,
5297
+ index,
5298
+ content
5299
+ });
5300
+ });
5301
+ }
5302
+ return Array.from(byId3.values()).sort((a2, b2) => b2.score - a2.score);
5303
+ }
5252
5304
  async function queryAssistant(options) {
5253
5305
  const {
5254
5306
  workspaceId,
@@ -6919,6 +6971,11 @@ async function remove(arbi) {
6919
6971
  // src/operations/projects.ts
6920
6972
  var projects_exports = {};
6921
6973
  __export(projects_exports, {
6974
+ addAddonBlock: () => addAddonBlock,
6975
+ billingPortal: () => billingPortal,
6976
+ cancelSubscription: () => cancelSubscription,
6977
+ changePlan: () => changePlan,
6978
+ createCheckout: () => createCheckout,
6922
6979
  createProject: () => createProject,
6923
6980
  deleteProject: () => deleteProject,
6924
6981
  formatBudget: () => formatBudget,
@@ -6926,11 +6983,17 @@ __export(projects_exports, {
6926
6983
  getProjectInvoices: () => getProjectInvoices,
6927
6984
  getProjectUsage: () => getProjectUsage,
6928
6985
  getUserUsageToday: () => getUserUsageToday,
6986
+ listProducts: () => listProducts,
6929
6987
  listProjectEvents: () => listProjectEvents,
6930
6988
  listProjects: () => listProjects,
6931
6989
  parseBudget: () => parseBudget,
6990
+ previewPlanChange: () => previewPlanChange,
6991
+ quoteAddon: () => quoteAddon,
6992
+ quotePlan: () => quotePlan,
6932
6993
  refreshProject: () => refreshProject,
6933
6994
  renameProject: () => renameProject,
6995
+ setNextPeriodAddons: () => setNextPeriodAddons,
6996
+ updateAddonSettings: () => updateAddonSettings,
6934
6997
  updateProject: () => updateProject
6935
6998
  });
6936
6999
  async function listProjects(arbi, filters = {}) {
@@ -7053,6 +7116,95 @@ async function getProjectInvoices(arbi, projectExtId) {
7053
7116
  async function getUserUsageToday(arbi) {
7054
7117
  return requireData(await arbi.fetch.GET("/v1/user/me/usage/today"), "Failed to fetch today usage");
7055
7118
  }
7119
+ var projectPath = (projectExtId) => ({ path: { project_ext_id: projectExtId } });
7120
+ async function listProducts(arbi) {
7121
+ return requireData(await arbi.fetch.GET("/v1/user/products"), "Failed to load the plans");
7122
+ }
7123
+ async function quotePlan(arbi, projectExtId, body) {
7124
+ return requireData(
7125
+ projectExtId ? await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout/quote", {
7126
+ params: projectPath(projectExtId),
7127
+ body
7128
+ }) : await arbi.fetch.POST("/v1/user/projects/quote", { body }),
7129
+ "Failed to price the plan"
7130
+ );
7131
+ }
7132
+ async function createCheckout(arbi, projectExtId, body) {
7133
+ return requireData(
7134
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/checkout", {
7135
+ params: projectPath(projectExtId),
7136
+ body
7137
+ }),
7138
+ "Failed to start the checkout"
7139
+ );
7140
+ }
7141
+ async function changePlan(arbi, projectExtId, body) {
7142
+ return requireData(
7143
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/change-plan", {
7144
+ params: projectPath(projectExtId),
7145
+ body
7146
+ }),
7147
+ "Failed to change the plan"
7148
+ );
7149
+ }
7150
+ async function previewPlanChange(arbi, projectExtId, body) {
7151
+ return requireData(
7152
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/plan/preview", {
7153
+ params: projectPath(projectExtId),
7154
+ body
7155
+ }),
7156
+ "Failed to price the plan change"
7157
+ );
7158
+ }
7159
+ async function quoteAddon(arbi, projectExtId, kind) {
7160
+ return requireData(
7161
+ await arbi.fetch.GET("/v1/user/projects/{project_ext_id}/addons/quote", {
7162
+ params: { ...projectPath(projectExtId), query: { kind } }
7163
+ }),
7164
+ "Failed to price the add-on"
7165
+ );
7166
+ }
7167
+ async function billingPortal(arbi, projectExtId) {
7168
+ return requireData(
7169
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/billing-portal", {
7170
+ params: projectPath(projectExtId)
7171
+ }),
7172
+ "Failed to open the billing portal"
7173
+ );
7174
+ }
7175
+ async function addAddonBlock(arbi, projectExtId, kind) {
7176
+ const params = projectPath(projectExtId);
7177
+ return requireData(
7178
+ 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 }),
7179
+ "Failed to add the add-on"
7180
+ );
7181
+ }
7182
+ async function setNextPeriodAddons(arbi, projectExtId, body) {
7183
+ return requireData(
7184
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/next-period", {
7185
+ params: projectPath(projectExtId),
7186
+ body
7187
+ }),
7188
+ "Failed to change the add-ons"
7189
+ );
7190
+ }
7191
+ async function updateAddonSettings(arbi, projectExtId, body) {
7192
+ return requireData(
7193
+ await arbi.fetch.PUT("/v1/user/projects/{project_ext_id}/addons/settings", {
7194
+ params: projectPath(projectExtId),
7195
+ body
7196
+ }),
7197
+ "Failed to save the add-on settings"
7198
+ );
7199
+ }
7200
+ async function cancelSubscription(arbi, projectExtId) {
7201
+ return requireData(
7202
+ await arbi.fetch.POST("/v1/user/projects/{project_ext_id}/cancel", {
7203
+ params: projectPath(projectExtId)
7204
+ }),
7205
+ "Failed to cancel the subscription"
7206
+ );
7207
+ }
7056
7208
 
7057
7209
  // src/operations/work.ts
7058
7210
  var work_exports = {};
@@ -8144,10 +8296,8 @@ __export(calendar_exports, {
8144
8296
  cancelPublicBooking: () => cancelPublicBooking,
8145
8297
  connectCalDavAccount: () => connectCalDavAccount,
8146
8298
  connectOAuthAccount: () => connectOAuthAccount,
8147
- createAppPassword: () => createAppPassword,
8148
8299
  createCalendar: () => createCalendar,
8149
8300
  createEvent: () => createEvent,
8150
- createFeed: () => createFeed,
8151
8301
  createRoom: () => createRoom,
8152
8302
  decideCounter: () => decideCounter,
8153
8303
  deleteBookingPage: () => deleteBookingPage,
@@ -8164,7 +8314,6 @@ __export(calendar_exports, {
8164
8314
  getPublicBookingPage: () => getPublicBookingPage,
8165
8315
  importCalendarIcs: () => importCalendarIcs,
8166
8316
  listAccounts: () => listAccounts,
8167
- listAppPasswords: () => listAppPasswords,
8168
8317
  listBookingPages: () => listBookingPages,
8169
8318
  listCalDavProfiles: () => listCalDavProfiles,
8170
8319
  listCalendars: () => listCalendars,
@@ -8182,9 +8331,7 @@ __export(calendar_exports, {
8182
8331
  putCalendarSettings: () => putCalendarSettings,
8183
8332
  refreshCalendar: () => refreshCalendar,
8184
8333
  respondToEvent: () => respondToEvent,
8185
- revokeAppPassword: () => revokeAppPassword,
8186
8334
  shareCalendar: () => shareCalendar,
8187
- splitAppPasswords: () => splitAppPasswords,
8188
8335
  subscribeCalendar: () => subscribeCalendar,
8189
8336
  syncAccount: () => syncAccount,
8190
8337
  unlockCalendarKeys: () => unlockCalendarKeys,
@@ -8572,46 +8719,6 @@ async function publishCalendarToAccount(client, accId, calendarId) {
8572
8719
  "Publishing the calendar"
8573
8720
  );
8574
8721
  }
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
8722
  async function listBookingPages(client) {
8616
8723
  return take(await client.fetch.GET("/v1/calendar/booking-pages"), "Loading booking pages");
8617
8724
  }
@@ -8980,7 +9087,23 @@ var Arbi = class {
8980
9087
  /** AI usage + spend breakdown for a project's billing period. */
8981
9088
  usage: (projectExtId, monthsBack) => getProjectUsage(this.requireClient(), projectExtId, monthsBack),
8982
9089
  /** Stripe invoices for a project's subscription. */
8983
- invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId)
9090
+ invoices: (projectExtId) => getProjectInvoices(this.requireClient(), projectExtId),
9091
+ /** Delete a project (only when empty: no workspaces, no subscription). */
9092
+ delete: (projectExtId) => deleteProject(this.requireClient(), projectExtId),
9093
+ /** The plans and add-ons on sale. */
9094
+ products: () => listProducts(this.requireClient()),
9095
+ /** The taxed total of a Pro purchase (a new project when `projectExtId` is null). */
9096
+ quotePlan: (projectExtId, body) => quotePlan(this.requireClient(), projectExtId, body),
9097
+ /** Start an embedded Stripe checkout; returns its `client_secret`. */
9098
+ checkout: (projectExtId, body) => createCheckout(this.requireClient(), projectExtId, body),
9099
+ changePlan: (projectExtId, body) => changePlan(this.requireClient(), projectExtId, body),
9100
+ previewPlanChange: (projectExtId, body) => previewPlanChange(this.requireClient(), projectExtId, body),
9101
+ quoteAddon: (projectExtId, kind) => quoteAddon(this.requireClient(), projectExtId, kind),
9102
+ billingPortal: (projectExtId) => billingPortal(this.requireClient(), projectExtId),
9103
+ addAddonBlock: (projectExtId, kind) => addAddonBlock(this.requireClient(), projectExtId, kind),
9104
+ setNextPeriodAddons: (projectExtId, body) => setNextPeriodAddons(this.requireClient(), projectExtId, body),
9105
+ updateAddonSettings: (projectExtId, body) => updateAddonSettings(this.requireClient(), projectExtId, body),
9106
+ cancelSubscription: (projectExtId) => cancelSubscription(this.requireClient(), projectExtId)
8984
9107
  };
8985
9108
  // ── User (account-scoped usage) ───────────────────────────────────────
8986
9109
  user = {
@@ -9164,6 +9287,11 @@ var Arbi = class {
9164
9287
  void 0,
9165
9288
  options?.confirmInvite
9166
9289
  ),
9290
+ /**
9291
+ * `POST /v1/workspace/users` with the whole request (another workspace with its sealed key, a
9292
+ * session-scoped grant, an invitation, a resource share): see `addWorkspaceMembers`.
9293
+ */
9294
+ addMembers: (request) => addWorkspaceMembers(this.requireClient(), request),
9167
9295
  /**
9168
9296
  * Grant users a temporary key scoped to ONE session (identified by its public key), for
9169
9297
  * example an agent's run session minted by `agents.authorize()`. Nothing standing is created:
@@ -9472,7 +9600,8 @@ var Arbi = class {
9472
9600
  /** The skills the caller can run (own + shared marketplace), metadata only. */
9473
9601
  listSkills: (options) => listSkills(this.requireClient(), options),
9474
9602
  /**
9475
- * Search documents without LLM generation (retrieval only).
9603
+ * Search documents without LLM generation (retrieval only). No `docIds` searches the whole
9604
+ * workspace; `searchChunks(result)` ranks the passages found.
9476
9605
  */
9477
9606
  retrieve: (query, docIds, options) => retrieve({
9478
9607
  arbi: this.requireClient(),
@@ -9602,10 +9731,6 @@ var Arbi = class {
9602
9731
  syncAccount: (accId) => this.withCalendarKeys((c2) => syncAccount(c2, accId)),
9603
9732
  disconnectAccount: (accId) => this.withCalendarKeys((c2) => disconnectAccount(c2, accId)),
9604
9733
  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
9734
  listBookingPages: () => this.withCalendarKeys((c2) => listBookingPages(c2)),
9610
9735
  putBookingPage: (body) => this.withCalendarKeys((c2) => putBookingPage(c2, body)),
9611
9736
  deleteBookingPage: (slug) => this.withCalendarKeys((c2) => deleteBookingPage(c2, slug))
@@ -9920,21 +10045,135 @@ var Arbi = class {
9920
10045
  }
9921
10046
  };
9922
10047
 
10048
+ // src/tag-helpers.ts
10049
+ var ENTITY_KINDS = ["person", "organisation"];
10050
+ var PRESENCE_KINDS = ["label", "issue", "person", "organisation"];
10051
+ function defaultKindForFormat(format) {
10052
+ if (format === "checkbox") return "label";
10053
+ if (format === "search") return "search";
10054
+ return "annotation";
10055
+ }
10056
+ function tagUseCount(tag) {
10057
+ return (tag.doctag_count ?? 0) + (tag.facttag_count ?? 0) + (tag.convotag_count ?? 0);
10058
+ }
10059
+ function filterDocumentTags(tags) {
10060
+ return tags.filter((tag) => tag.kind !== "search");
10061
+ }
10062
+ function isPresenceTag(tag) {
10063
+ return PRESENCE_KINDS.includes(tag.kind);
10064
+ }
10065
+ function isLabelTag(tag) {
10066
+ return tag.kind === "label";
10067
+ }
10068
+ function isAnnotationTag(tag) {
10069
+ return tag.kind === "annotation";
10070
+ }
10071
+ function isEntityTag(tag) {
10072
+ return ENTITY_KINDS.includes(tag.kind);
10073
+ }
10074
+ function tagsOfGroup(tags, group) {
10075
+ return tags.filter(group === "label" ? isLabelTag : isAnnotationTag);
10076
+ }
10077
+ function tagsForScope(tags, scope) {
10078
+ return tags.filter((tag) => {
10079
+ const onDocs = (tag.doctag_count ?? 0) > 0;
10080
+ const onFacts = (tag.facttag_count ?? 0) > 0;
10081
+ if (!onDocs && !onFacts) return true;
10082
+ return scope === "document" ? onDocs : onFacts;
10083
+ });
10084
+ }
10085
+ var TAG_NESTING_MAX_DEPTH = 2;
10086
+ function indexByExternalId(tags) {
10087
+ return new Map(tags.map((tag) => [tag.external_id, tag]));
10088
+ }
10089
+ function resolveParentId(tag, byId3) {
10090
+ const parentId = tag.parent_ext_id;
10091
+ if (!parentId || parentId === tag.external_id) return null;
10092
+ return byId3.has(parentId) ? parentId : null;
10093
+ }
10094
+ function buildChildIndex(tags) {
10095
+ const byId3 = indexByExternalId(tags);
10096
+ const childrenOf = /* @__PURE__ */ new Map();
10097
+ for (const tag of tags) {
10098
+ const parentId = resolveParentId(tag, byId3);
10099
+ if (!parentId) continue;
10100
+ const siblings = childrenOf.get(parentId);
10101
+ if (siblings) siblings.push(tag);
10102
+ else childrenOf.set(parentId, [tag]);
10103
+ }
10104
+ return childrenOf;
10105
+ }
10106
+ function getChildTags(tags, tagId) {
10107
+ return buildChildIndex(tags).get(tagId) ?? [];
10108
+ }
10109
+ function getTagDescendantIds(tags, tagId) {
10110
+ const childrenOf = buildChildIndex(tags);
10111
+ const found = /* @__PURE__ */ new Set();
10112
+ const queue = [...childrenOf.get(tagId) ?? []];
10113
+ while (queue.length > 0) {
10114
+ const tag = queue.shift();
10115
+ if (tag.external_id === tagId || found.has(tag.external_id)) continue;
10116
+ found.add(tag.external_id);
10117
+ queue.push(...childrenOf.get(tag.external_id) ?? []);
10118
+ }
10119
+ return found;
10120
+ }
10121
+ function flattenTagTree(tags) {
10122
+ const byId3 = indexByExternalId(tags);
10123
+ const childrenOf = buildChildIndex(tags);
10124
+ const rows = [];
10125
+ const emitted = /* @__PURE__ */ new Set();
10126
+ const visit = (tag, depth) => {
10127
+ if (emitted.has(tag.external_id)) return;
10128
+ emitted.add(tag.external_id);
10129
+ const children = childrenOf.get(tag.external_id) ?? [];
10130
+ rows.push({ tag, depth, childCount: children.length });
10131
+ for (const child of children) visit(child, depth + 1);
10132
+ };
10133
+ for (const tag of tags) {
10134
+ if (resolveParentId(tag, byId3) === null) visit(tag, 0);
10135
+ }
10136
+ for (const tag of tags) visit(tag, 0);
10137
+ return rows;
10138
+ }
10139
+ var isFlatKind = (kind) => FLAT_TAG_KINDS.includes(kind);
10140
+ function getEligibleParentTags(tags, tagId) {
10141
+ const byId3 = indexByExternalId(tags);
10142
+ const blocked = tagId ? getTagDescendantIds(tags, tagId) : /* @__PURE__ */ new Set();
10143
+ if (tagId) blocked.add(tagId);
10144
+ return tags.filter(
10145
+ (tag) => !blocked.has(tag.external_id) && resolveParentId(tag, byId3) === null && // Issues, people and organisations are flat: never a parent (the API refuses it).
10146
+ !isFlatKind(tag.kind)
10147
+ );
10148
+ }
10149
+ function wouldCreateTagCycle(tags, tagId, parentId) {
10150
+ if (!parentId) return false;
10151
+ if (parentId === tagId) return true;
10152
+ return getTagDescendantIds(tags, tagId).has(parentId);
10153
+ }
10154
+ function canTagHaveParent(tags, tagId) {
10155
+ return getChildTags(tags, tagId).length === 0;
10156
+ }
10157
+
9923
10158
  exports.ACCOUNT_VENDOR = ACCOUNT_VENDOR;
9924
10159
  exports.Arbi = Arbi;
9925
10160
  exports.ArbiApiError = ArbiApiError;
9926
10161
  exports.ArbiError = ArbiError;
9927
10162
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
9928
10163
  exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;
10164
+ exports.ENTITY_KINDS = ENTITY_KINDS;
9929
10165
  exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
9930
10166
  exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
9931
10167
  exports.IMANAGE_VENDORS = IMANAGE_VENDORS;
9932
10168
  exports.MAILBOX_SYNC_VENDORS = MAILBOX_SYNC_VENDORS;
10169
+ exports.MAX_RETRIEVE_DOC_IDS = MAX_RETRIEVE_DOC_IDS;
9933
10170
  exports.MICROSOFT_VENDORS = MICROSOFT_VENDORS;
10171
+ exports.PRESENCE_KINDS = PRESENCE_KINDS;
9934
10172
  exports.PlanStepsError = PlanStepsError;
9935
10173
  exports.PublicBookingError = PublicBookingError;
9936
10174
  exports.SHAREPOINT_VENDORS = SHAREPOINT_VENDORS;
9937
10175
  exports.TAG_KINDS = TAG_KINDS;
10176
+ exports.TAG_NESTING_MAX_DEPTH = TAG_NESTING_MAX_DEPTH;
9938
10177
  exports.WebSocketAuthError = WebSocketAuthError;
9939
10178
  exports.account = account_exports;
9940
10179
  exports.agentconfig = agentconfig_exports;
@@ -9947,6 +10186,7 @@ exports.buildRetrievalChunkTool = buildRetrievalChunkTool;
9947
10186
  exports.buildRetrievalFullContextTool = buildRetrievalFullContextTool;
9948
10187
  exports.buildRetrievalTocTool = buildRetrievalTocTool;
9949
10188
  exports.calendar = calendar_exports;
10189
+ exports.canTagHaveParent = canTagHaveParent;
9950
10190
  exports.cancelPublicBooking = cancelPublicBooking;
9951
10191
  exports.chats = chats_exports;
9952
10192
  exports.connectErrorMessage = connectErrorMessage;
@@ -9958,11 +10198,14 @@ exports.contacts = contacts_exports;
9958
10198
  exports.conversations = conversations_exports;
9959
10199
  exports.countCitations = countCitations;
9960
10200
  exports.createAuthenticatedClient = createAuthenticatedClient;
10201
+ exports.defaultKindForFormat = defaultKindForFormat;
9961
10202
  exports.doctags = doctags_exports;
9962
10203
  exports.documents = documents_exports;
9963
10204
  exports.facts = facts_exports;
9964
10205
  exports.files = files_exports;
10206
+ exports.filterDocumentTags = filterDocumentTags;
9965
10207
  exports.filterSkills = filterSkills;
10208
+ exports.flattenTagTree = flattenTagTree;
9966
10209
  exports.formatAgentStepLabel = formatAgentStepLabel;
9967
10210
  exports.formatFileSize = formatFileSize;
9968
10211
  exports.formatGbp = formatGbp;
@@ -9970,16 +10213,24 @@ exports.formatGbpPerMillionTokens = formatGbpPerMillionTokens;
9970
10213
  exports.formatItemLabel = formatItemLabel;
9971
10214
  exports.formatUserName = formatUserName;
9972
10215
  exports.formatWorkspaceChoices = formatWorkspaceChoices;
10216
+ exports.getChildTags = getChildTags;
10217
+ exports.getEligibleParentTags = getEligibleParentTags;
9973
10218
  exports.getErrorMessage = getErrorMessage;
9974
10219
  exports.getPublicBookingPage = getPublicBookingPage;
9975
10220
  exports.getRawWorkspaceKey = getRawWorkspaceKey;
10221
+ exports.getTagDescendantIds = getTagDescendantIds;
9976
10222
  exports.health = health_exports;
9977
10223
  exports.houseTemplates = house_template_exports;
9978
10224
  exports.identityErrorCode = identityErrorCode;
9979
10225
  exports.identityVerification = identity_exports;
10226
+ exports.isAnnotationTag = isAnnotationTag;
9980
10227
  exports.isConnectorVendorVisible = isConnectorVendorVisible;
9981
10228
  exports.isDriveSyncVendor = isDriveSyncVendor;
10229
+ exports.isEntityTag = isEntityTag;
10230
+ exports.isFlatKind = isFlatKind;
10231
+ exports.isLabelTag = isLabelTag;
9982
10232
  exports.isMailboxSyncVendor = isMailboxSyncVendor;
10233
+ exports.isPresenceTag = isPresenceTag;
9983
10234
  exports.isSharePointVendor = isSharePointVendor;
9984
10235
  exports.mail = mail_exports;
9985
10236
  exports.notifications = notifications_exports;
@@ -9989,25 +10240,30 @@ exports.parseSlashTokenInProgress = parseSlashTokenInProgress;
9989
10240
  exports.performPasswordLogin = performPasswordLogin;
9990
10241
  exports.profile = profile_exports;
9991
10242
  exports.projects = projects_exports;
10243
+ exports.refusalReason = refusalReason;
9992
10244
  exports.requireData = requireData;
9993
10245
  exports.requireOk = requireOk;
9994
10246
  exports.resolveAuth = resolveAuth;
9995
10247
  exports.resolveCitations = resolveCitations;
9996
10248
  exports.resolveWorkspace = resolveWorkspace;
9997
10249
  exports.responses = responses_exports;
10250
+ exports.searchChunks = searchChunks;
9998
10251
  exports.selectWorkspace = selectWorkspace;
9999
10252
  exports.selectWorkspaceById = selectWorkspaceById;
10000
10253
  exports.sessions = sessions_exports;
10001
10254
  exports.settings = settings_exports;
10002
- exports.splitAppPasswords = splitAppPasswords;
10003
10255
  exports.streamSSE = streamSSE;
10004
10256
  exports.stripCitationMarkdown = stripCitationMarkdown;
10005
10257
  exports.summarizeCitations = summarizeCitations;
10258
+ exports.tagUseCount = tagUseCount;
10006
10259
  exports.tags = tags_exports;
10260
+ exports.tagsForScope = tagsForScope;
10261
+ exports.tagsOfGroup = tagsOfGroup;
10007
10262
  exports.usdToGbp = usdToGbp;
10008
10263
  exports.work = work_exports;
10009
10264
  exports.workflowSteps = workflow_steps_exports;
10010
10265
  exports.workflows = workflows_exports;
10011
10266
  exports.workspaces = workspaces_exports;
10267
+ exports.wouldCreateTagCycle = wouldCreateTagCycle;
10012
10268
  //# sourceMappingURL=browser.cjs.map
10013
10269
  //# sourceMappingURL=browser.cjs.map