@arbidocs/sdk 0.4.148 → 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(
@@ -9276,6 +9287,11 @@ var Arbi = class {
9276
9287
  void 0,
9277
9288
  options?.confirmInvite
9278
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),
9279
9295
  /**
9280
9296
  * Grant users a temporary key scoped to ONE session (identified by its public key), for
9281
9297
  * example an agent's run session minted by `agents.authorize()`. Nothing standing is created:
@@ -10029,22 +10045,135 @@ var Arbi = class {
10029
10045
  }
10030
10046
  };
10031
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
+
10032
10158
  exports.ACCOUNT_VENDOR = ACCOUNT_VENDOR;
10033
10159
  exports.Arbi = Arbi;
10034
10160
  exports.ArbiApiError = ArbiApiError;
10035
10161
  exports.ArbiError = ArbiError;
10036
10162
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
10037
10163
  exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;
10164
+ exports.ENTITY_KINDS = ENTITY_KINDS;
10038
10165
  exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
10039
10166
  exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
10040
10167
  exports.IMANAGE_VENDORS = IMANAGE_VENDORS;
10041
10168
  exports.MAILBOX_SYNC_VENDORS = MAILBOX_SYNC_VENDORS;
10042
10169
  exports.MAX_RETRIEVE_DOC_IDS = MAX_RETRIEVE_DOC_IDS;
10043
10170
  exports.MICROSOFT_VENDORS = MICROSOFT_VENDORS;
10171
+ exports.PRESENCE_KINDS = PRESENCE_KINDS;
10044
10172
  exports.PlanStepsError = PlanStepsError;
10045
10173
  exports.PublicBookingError = PublicBookingError;
10046
10174
  exports.SHAREPOINT_VENDORS = SHAREPOINT_VENDORS;
10047
10175
  exports.TAG_KINDS = TAG_KINDS;
10176
+ exports.TAG_NESTING_MAX_DEPTH = TAG_NESTING_MAX_DEPTH;
10048
10177
  exports.WebSocketAuthError = WebSocketAuthError;
10049
10178
  exports.account = account_exports;
10050
10179
  exports.agentconfig = agentconfig_exports;
@@ -10057,6 +10186,7 @@ exports.buildRetrievalChunkTool = buildRetrievalChunkTool;
10057
10186
  exports.buildRetrievalFullContextTool = buildRetrievalFullContextTool;
10058
10187
  exports.buildRetrievalTocTool = buildRetrievalTocTool;
10059
10188
  exports.calendar = calendar_exports;
10189
+ exports.canTagHaveParent = canTagHaveParent;
10060
10190
  exports.cancelPublicBooking = cancelPublicBooking;
10061
10191
  exports.chats = chats_exports;
10062
10192
  exports.connectErrorMessage = connectErrorMessage;
@@ -10068,11 +10198,14 @@ exports.contacts = contacts_exports;
10068
10198
  exports.conversations = conversations_exports;
10069
10199
  exports.countCitations = countCitations;
10070
10200
  exports.createAuthenticatedClient = createAuthenticatedClient;
10201
+ exports.defaultKindForFormat = defaultKindForFormat;
10071
10202
  exports.doctags = doctags_exports;
10072
10203
  exports.documents = documents_exports;
10073
10204
  exports.facts = facts_exports;
10074
10205
  exports.files = files_exports;
10206
+ exports.filterDocumentTags = filterDocumentTags;
10075
10207
  exports.filterSkills = filterSkills;
10208
+ exports.flattenTagTree = flattenTagTree;
10076
10209
  exports.formatAgentStepLabel = formatAgentStepLabel;
10077
10210
  exports.formatFileSize = formatFileSize;
10078
10211
  exports.formatGbp = formatGbp;
@@ -10080,16 +10213,24 @@ exports.formatGbpPerMillionTokens = formatGbpPerMillionTokens;
10080
10213
  exports.formatItemLabel = formatItemLabel;
10081
10214
  exports.formatUserName = formatUserName;
10082
10215
  exports.formatWorkspaceChoices = formatWorkspaceChoices;
10216
+ exports.getChildTags = getChildTags;
10217
+ exports.getEligibleParentTags = getEligibleParentTags;
10083
10218
  exports.getErrorMessage = getErrorMessage;
10084
10219
  exports.getPublicBookingPage = getPublicBookingPage;
10085
10220
  exports.getRawWorkspaceKey = getRawWorkspaceKey;
10221
+ exports.getTagDescendantIds = getTagDescendantIds;
10086
10222
  exports.health = health_exports;
10087
10223
  exports.houseTemplates = house_template_exports;
10088
10224
  exports.identityErrorCode = identityErrorCode;
10089
10225
  exports.identityVerification = identity_exports;
10226
+ exports.isAnnotationTag = isAnnotationTag;
10090
10227
  exports.isConnectorVendorVisible = isConnectorVendorVisible;
10091
10228
  exports.isDriveSyncVendor = isDriveSyncVendor;
10229
+ exports.isEntityTag = isEntityTag;
10230
+ exports.isFlatKind = isFlatKind;
10231
+ exports.isLabelTag = isLabelTag;
10092
10232
  exports.isMailboxSyncVendor = isMailboxSyncVendor;
10233
+ exports.isPresenceTag = isPresenceTag;
10093
10234
  exports.isSharePointVendor = isSharePointVendor;
10094
10235
  exports.mail = mail_exports;
10095
10236
  exports.notifications = notifications_exports;
@@ -10099,6 +10240,7 @@ exports.parseSlashTokenInProgress = parseSlashTokenInProgress;
10099
10240
  exports.performPasswordLogin = performPasswordLogin;
10100
10241
  exports.profile = profile_exports;
10101
10242
  exports.projects = projects_exports;
10243
+ exports.refusalReason = refusalReason;
10102
10244
  exports.requireData = requireData;
10103
10245
  exports.requireOk = requireOk;
10104
10246
  exports.resolveAuth = resolveAuth;
@@ -10113,11 +10255,15 @@ exports.settings = settings_exports;
10113
10255
  exports.streamSSE = streamSSE;
10114
10256
  exports.stripCitationMarkdown = stripCitationMarkdown;
10115
10257
  exports.summarizeCitations = summarizeCitations;
10258
+ exports.tagUseCount = tagUseCount;
10116
10259
  exports.tags = tags_exports;
10260
+ exports.tagsForScope = tagsForScope;
10261
+ exports.tagsOfGroup = tagsOfGroup;
10117
10262
  exports.usdToGbp = usdToGbp;
10118
10263
  exports.work = work_exports;
10119
10264
  exports.workflowSteps = workflow_steps_exports;
10120
10265
  exports.workflows = workflows_exports;
10121
10266
  exports.workspaces = workspaces_exports;
10267
+ exports.wouldCreateTagCycle = wouldCreateTagCycle;
10122
10268
  //# sourceMappingURL=browser.cjs.map
10123
10269
  //# sourceMappingURL=browser.cjs.map