@arbidocs/sdk 0.4.148 → 0.4.151

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
@@ -3533,6 +3533,10 @@ var ArbiApiError = class extends ArbiError {
3533
3533
  this.detail = apiErrorDetail(apiError);
3534
3534
  }
3535
3535
  };
3536
+ function refusalReason(err, fallback) {
3537
+ if (err instanceof ArbiApiError) return err.detail || fallback;
3538
+ return apiErrorDetail(err) || fallback;
3539
+ }
3536
3540
  function requireData(result, message) {
3537
3541
  if (result.error || !result.data) {
3538
3542
  throw new ArbiApiError(message, result.error, result.response?.status);
@@ -5539,6 +5543,7 @@ async function listHouseTemplateCandidates(arbi) {
5539
5543
  // src/operations/workspaces.ts
5540
5544
  var workspaces_exports = {};
5541
5545
  __export(workspaces_exports, {
5546
+ addWorkspaceMembers: () => addWorkspaceMembers,
5542
5547
  addWorkspaceUsers: () => addWorkspaceUsers,
5543
5548
  copyDocuments: () => copyDocuments,
5544
5549
  createWorkspace: () => createWorkspace,
@@ -5586,6 +5591,12 @@ async function updateWorkspace(arbi, body) {
5586
5591
  async function listWorkspaceUsers(arbi) {
5587
5592
  return requireData(await arbi.fetch.GET("/v1/workspace/users"), "Failed to fetch workspace users");
5588
5593
  }
5594
+ async function addWorkspaceMembers(arbi, request) {
5595
+ return requireData(
5596
+ await arbi.fetch.POST("/v1/workspace/users", { body: request }),
5597
+ "Failed to add users"
5598
+ );
5599
+ }
5589
5600
  async function addWorkspaceUsers(arbi, emails, role = "collaborator", target, confirmInvite = false) {
5590
5601
  const invite = confirmInvite ? { confirm_invite: true } : {};
5591
5602
  return requireData(
@@ -9872,6 +9883,11 @@ var Arbi = class {
9872
9883
  void 0,
9873
9884
  options?.confirmInvite
9874
9885
  ),
9886
+ /**
9887
+ * `POST /v1/workspace/users` with the whole request (another workspace with its sealed key, a
9888
+ * session-scoped grant, an invitation, a resource share): see `addWorkspaceMembers`.
9889
+ */
9890
+ addMembers: (request) => addWorkspaceMembers(this.requireClient(), request),
9875
9891
  /**
9876
9892
  * Grant users a temporary key scoped to ONE session (identified by its public key), for
9877
9893
  * example an agent's run session minted by `agents.authorize()`. Nothing standing is created:
@@ -11385,6 +11401,116 @@ function attachmentFromFile(filePath) {
11385
11401
  );
11386
11402
  }
11387
11403
 
11404
+ // src/tag-helpers.ts
11405
+ var ENTITY_KINDS = ["person", "organisation"];
11406
+ var PRESENCE_KINDS = ["label", "issue", "person", "organisation"];
11407
+ function defaultKindForFormat(format) {
11408
+ if (format === "checkbox") return "label";
11409
+ if (format === "search") return "search";
11410
+ return "annotation";
11411
+ }
11412
+ function tagUseCount(tag) {
11413
+ return (tag.doctag_count ?? 0) + (tag.facttag_count ?? 0) + (tag.convotag_count ?? 0);
11414
+ }
11415
+ function filterDocumentTags(tags) {
11416
+ return tags.filter((tag) => tag.kind !== "search");
11417
+ }
11418
+ function isPresenceTag(tag) {
11419
+ return PRESENCE_KINDS.includes(tag.kind);
11420
+ }
11421
+ function isLabelTag(tag) {
11422
+ return tag.kind === "label";
11423
+ }
11424
+ function isAnnotationTag(tag) {
11425
+ return tag.kind === "annotation";
11426
+ }
11427
+ function isEntityTag(tag) {
11428
+ return ENTITY_KINDS.includes(tag.kind);
11429
+ }
11430
+ function tagsOfGroup(tags, group) {
11431
+ return tags.filter(group === "label" ? isLabelTag : isAnnotationTag);
11432
+ }
11433
+ function tagsForScope(tags, scope) {
11434
+ return tags.filter((tag) => {
11435
+ const onDocs = (tag.doctag_count ?? 0) > 0;
11436
+ const onFacts = (tag.facttag_count ?? 0) > 0;
11437
+ if (!onDocs && !onFacts) return true;
11438
+ return scope === "document" ? onDocs : onFacts;
11439
+ });
11440
+ }
11441
+ var TAG_NESTING_MAX_DEPTH = 2;
11442
+ function indexByExternalId(tags) {
11443
+ return new Map(tags.map((tag) => [tag.external_id, tag]));
11444
+ }
11445
+ function resolveParentId(tag, byId3) {
11446
+ const parentId = tag.parent_ext_id;
11447
+ if (!parentId || parentId === tag.external_id) return null;
11448
+ return byId3.has(parentId) ? parentId : null;
11449
+ }
11450
+ function buildChildIndex(tags) {
11451
+ const byId3 = indexByExternalId(tags);
11452
+ const childrenOf = /* @__PURE__ */ new Map();
11453
+ for (const tag of tags) {
11454
+ const parentId = resolveParentId(tag, byId3);
11455
+ if (!parentId) continue;
11456
+ const siblings = childrenOf.get(parentId);
11457
+ if (siblings) siblings.push(tag);
11458
+ else childrenOf.set(parentId, [tag]);
11459
+ }
11460
+ return childrenOf;
11461
+ }
11462
+ function getChildTags(tags, tagId) {
11463
+ return buildChildIndex(tags).get(tagId) ?? [];
11464
+ }
11465
+ function getTagDescendantIds(tags, tagId) {
11466
+ const childrenOf = buildChildIndex(tags);
11467
+ const found = /* @__PURE__ */ new Set();
11468
+ const queue = [...childrenOf.get(tagId) ?? []];
11469
+ while (queue.length > 0) {
11470
+ const tag = queue.shift();
11471
+ if (tag.external_id === tagId || found.has(tag.external_id)) continue;
11472
+ found.add(tag.external_id);
11473
+ queue.push(...childrenOf.get(tag.external_id) ?? []);
11474
+ }
11475
+ return found;
11476
+ }
11477
+ function flattenTagTree(tags) {
11478
+ const byId3 = indexByExternalId(tags);
11479
+ const childrenOf = buildChildIndex(tags);
11480
+ const rows = [];
11481
+ const emitted = /* @__PURE__ */ new Set();
11482
+ const visit = (tag, depth) => {
11483
+ if (emitted.has(tag.external_id)) return;
11484
+ emitted.add(tag.external_id);
11485
+ const children = childrenOf.get(tag.external_id) ?? [];
11486
+ rows.push({ tag, depth, childCount: children.length });
11487
+ for (const child of children) visit(child, depth + 1);
11488
+ };
11489
+ for (const tag of tags) {
11490
+ if (resolveParentId(tag, byId3) === null) visit(tag, 0);
11491
+ }
11492
+ for (const tag of tags) visit(tag, 0);
11493
+ return rows;
11494
+ }
11495
+ var isFlatKind = (kind) => FLAT_TAG_KINDS.includes(kind);
11496
+ function getEligibleParentTags(tags, tagId) {
11497
+ const byId3 = indexByExternalId(tags);
11498
+ const blocked = tagId ? getTagDescendantIds(tags, tagId) : /* @__PURE__ */ new Set();
11499
+ if (tagId) blocked.add(tagId);
11500
+ return tags.filter(
11501
+ (tag) => !blocked.has(tag.external_id) && resolveParentId(tag, byId3) === null && // Issues, people and organisations are flat: never a parent (the API refuses it).
11502
+ !isFlatKind(tag.kind)
11503
+ );
11504
+ }
11505
+ function wouldCreateTagCycle(tags, tagId, parentId) {
11506
+ if (!parentId) return false;
11507
+ if (parentId === tagId) return true;
11508
+ return getTagDescendantIds(tags, tagId).has(parentId);
11509
+ }
11510
+ function canTagHaveParent(tags, tagId) {
11511
+ return getChildTags(tags, tagId).length === 0;
11512
+ }
11513
+
11388
11514
  // src/listen/index.ts
11389
11515
  var listen_exports = {};
11390
11516
  __export(listen_exports, {
@@ -11707,6 +11833,7 @@ exports.ClaudeOrchestrator = ClaudeOrchestrator;
11707
11833
  exports.DEFAULT_AI_USD_PER_GBP = DEFAULT_AI_USD_PER_GBP;
11708
11834
  exports.DOC_TERMINAL_STATUSES = DOC_TERMINAL_STATUSES;
11709
11835
  exports.DRIVE_SYNC_VENDORS = DRIVE_SYNC_VENDORS;
11836
+ exports.ENTITY_KINDS = ENTITY_KINDS;
11710
11837
  exports.FLAT_TAG_KINDS = FLAT_TAG_KINDS;
11711
11838
  exports.FileConfigStore = FileConfigStore;
11712
11839
  exports.GOOGLE_VENDORS = GOOGLE_VENDORS;
@@ -11715,11 +11842,13 @@ exports.MAILBOX_SYNC_VENDORS = MAILBOX_SYNC_VENDORS;
11715
11842
  exports.MAX_RETRIEVE_DOC_IDS = MAX_RETRIEVE_DOC_IDS;
11716
11843
  exports.MICROSOFT_VENDORS = MICROSOFT_VENDORS;
11717
11844
  exports.OpenClawOrchestrator = OpenClawOrchestrator;
11845
+ exports.PRESENCE_KINDS = PRESENCE_KINDS;
11718
11846
  exports.PlanStepsError = PlanStepsError;
11719
11847
  exports.PublicBookingError = PublicBookingError;
11720
11848
  exports.SHAREPOINT_VENDORS = SHAREPOINT_VENDORS;
11721
11849
  exports.STEP_FIELD_OPTION_TONES = STEP_FIELD_OPTION_TONES;
11722
11850
  exports.TAG_KINDS = TAG_KINDS;
11851
+ exports.TAG_NESTING_MAX_DEPTH = TAG_NESTING_MAX_DEPTH;
11723
11852
  exports.WebSocketAuthError = WebSocketAuthError;
11724
11853
  exports.account = account_exports;
11725
11854
  exports.agentconfig = agentconfig_exports;
@@ -11734,6 +11863,7 @@ exports.buildRetrievalChunkTool = buildRetrievalChunkTool;
11734
11863
  exports.buildRetrievalFullContextTool = buildRetrievalFullContextTool;
11735
11864
  exports.buildRetrievalTocTool = buildRetrievalTocTool;
11736
11865
  exports.calendar = calendar_exports;
11866
+ exports.canTagHaveParent = canTagHaveParent;
11737
11867
  exports.cancelPublicBooking = cancelPublicBooking;
11738
11868
  exports.chats = chats_exports;
11739
11869
  exports.connectErrorMessage = connectErrorMessage;
@@ -11746,14 +11876,17 @@ exports.conversations = conversations_exports;
11746
11876
  exports.countCitations = countCitations;
11747
11877
  exports.createAuthenticatedClient = createAuthenticatedClient;
11748
11878
  exports.createDocumentWaiter = createDocumentWaiter;
11879
+ exports.defaultKindForFormat = defaultKindForFormat;
11749
11880
  exports.deviceFlow = device_flow_exports;
11750
11881
  exports.doctags = doctags_exports;
11751
11882
  exports.documents = documents_exports;
11752
11883
  exports.documentsNode = documents_node_exports;
11753
11884
  exports.facts = facts_exports;
11754
11885
  exports.files = files_exports;
11886
+ exports.filterDocumentTags = filterDocumentTags;
11755
11887
  exports.filterSkills = filterSkills;
11756
11888
  exports.firm = firm_exports;
11889
+ exports.flattenTagTree = flattenTagTree;
11757
11890
  exports.formatAgentStepLabel = formatAgentStepLabel;
11758
11891
  exports.formatFileSize = formatFileSize;
11759
11892
  exports.formatGbp = formatGbp;
@@ -11765,17 +11898,25 @@ exports.formatWorkspaceChoices = formatWorkspaceChoices;
11765
11898
  exports.formatWsMessage = formatWsMessage;
11766
11899
  exports.generateEncryptedWorkspaceKey = generateEncryptedWorkspaceKey;
11767
11900
  exports.generateNewWorkspaceKey = generateNewWorkspaceKey;
11901
+ exports.getChildTags = getChildTags;
11902
+ exports.getEligibleParentTags = getEligibleParentTags;
11768
11903
  exports.getErrorCode = getErrorCode;
11769
11904
  exports.getErrorMessage = getErrorMessage;
11770
11905
  exports.getPublicBookingPage = getPublicBookingPage;
11771
11906
  exports.getRawWorkspaceKey = getRawWorkspaceKey;
11907
+ exports.getTagDescendantIds = getTagDescendantIds;
11772
11908
  exports.health = health_exports;
11773
11909
  exports.houseTemplates = house_template_exports;
11774
11910
  exports.identityErrorCode = identityErrorCode;
11775
11911
  exports.identityVerification = identity_exports;
11912
+ exports.isAnnotationTag = isAnnotationTag;
11776
11913
  exports.isConnectorVendorVisible = isConnectorVendorVisible;
11777
11914
  exports.isDriveSyncVendor = isDriveSyncVendor;
11915
+ exports.isEntityTag = isEntityTag;
11916
+ exports.isFlatKind = isFlatKind;
11917
+ exports.isLabelTag = isLabelTag;
11778
11918
  exports.isMailboxSyncVendor = isMailboxSyncVendor;
11919
+ exports.isPresenceTag = isPresenceTag;
11779
11920
  exports.isSharePointVendor = isSharePointVendor;
11780
11921
  exports.isSharedSkill = isSharedSkill;
11781
11922
  exports.listen = listen_exports;
@@ -11790,6 +11931,7 @@ exports.performSigningKeyLogin = performSigningKeyLogin;
11790
11931
  exports.performSsoDeviceFlowLogin = performSsoDeviceFlowLogin;
11791
11932
  exports.profile = profile_exports;
11792
11933
  exports.projects = projects_exports;
11934
+ exports.refusalReason = refusalReason;
11793
11935
  exports.requireData = requireData;
11794
11936
  exports.requireOk = requireOk;
11795
11937
  exports.resolveAuth = resolveAuth;
@@ -11806,12 +11948,16 @@ exports.startDmListener = startDmListener;
11806
11948
  exports.streamSSE = streamSSE;
11807
11949
  exports.stripCitationMarkdown = stripCitationMarkdown;
11808
11950
  exports.summarizeCitations = summarizeCitations;
11951
+ exports.tagUseCount = tagUseCount;
11809
11952
  exports.tags = tags_exports;
11953
+ exports.tagsForScope = tagsForScope;
11954
+ exports.tagsOfGroup = tagsOfGroup;
11810
11955
  exports.uploadSkill = uploadSkill;
11811
11956
  exports.usdToGbp = usdToGbp;
11812
11957
  exports.work = work_exports;
11813
11958
  exports.workflowSteps = workflow_steps_exports;
11814
11959
  exports.workflows = workflows_exports;
11815
11960
  exports.workspaces = workspaces_exports;
11961
+ exports.wouldCreateTagCycle = wouldCreateTagCycle;
11816
11962
  //# sourceMappingURL=index.cjs.map
11817
11963
  //# sourceMappingURL=index.cjs.map