@tutti-os/agent-gui 0.0.108 → 0.0.109

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.
@@ -5,7 +5,7 @@ import {
5
5
  agentMentionFilterLabel,
6
6
  agentMentionGroupLabel,
7
7
  mentionGroupExpandCount
8
- } from "./chunk-UFD2QKGC.js";
8
+ } from "./chunk-K7WFXVSD.js";
9
9
  import {
10
10
  resolveAgentMentionFileThumbnailUrl,
11
11
  resolveAgentMentionFileVisualKind
@@ -505,4 +505,4 @@ export {
505
505
  AgentFileMentionPalette,
506
506
  AgentContextMentionPalette
507
507
  };
508
- //# sourceMappingURL=chunk-QTW5CH62.js.map
508
+ //# sourceMappingURL=chunk-A5UXTAYJ.js.map
@@ -646,7 +646,7 @@ function buildAgentMentionGroups(input) {
646
646
  expandStatus: group.loadMoreStatus
647
647
  }));
648
648
  }
649
- const provenanceGroups = buildSessionProvenanceGroups(input);
649
+ const provenanceGroups = buildAgentProvenanceGroups(input);
650
650
  if (provenanceGroups) {
651
651
  return provenanceGroups;
652
652
  }
@@ -711,41 +711,38 @@ function issueTopicPaginationChanges(groupsAtStart, currentGroups) {
711
711
  return [{ ...group, items: appendedItems }];
712
712
  });
713
713
  }
714
- function buildSessionProvenanceGroups(input) {
715
- if (input.currentFilter !== "session" || !input.provenanceCatalog?.enabledDimensions.includes("agent")) {
714
+ function buildAgentProvenanceGroups(input) {
715
+ if (input.currentFilter !== "session" && input.currentFilter !== "agent" || !input.provenanceCatalog?.enabledDimensions.includes("agent")) {
716
716
  return null;
717
717
  }
718
718
  const selectedAgentTargetIds = input.provenanceFilter?.agentTargetIds ?? null;
719
719
  const selectedAgentTargetIdSet = selectedAgentTargetIds === null ? null : new Set(selectedAgentTargetIds);
720
- const sessionItems = input.rawGroups.sessions.filter(
721
- (item) => item.kind === "session" && (selectedAgentTargetIdSet === null || (item.agentTargetId ? selectedAgentTargetIdSet.has(item.agentTargetId) : false))
722
- );
720
+ const sourceItems = agentProvenanceItemsForFilter(input).filter((item) => {
721
+ if (selectedAgentTargetIdSet === null) {
722
+ return true;
723
+ }
724
+ const agentTargetId = agentTargetIdForMentionItem(item);
725
+ return agentTargetId !== null && selectedAgentTargetIdSet.has(agentTargetId);
726
+ });
723
727
  const catalogAgentTargetIds = new Set(
724
728
  input.provenanceCatalog.agentOptions.map((option) => option.id)
725
729
  );
726
730
  const catalogGroups = input.provenanceCatalog.agentOptions.flatMap(
727
731
  (option) => {
728
- const items = sessionItems.filter(
729
- (item) => item.kind === "session" && item.agentTargetId === option.id
732
+ const items = sourceItems.filter(
733
+ (item) => agentTargetIdForMentionItem(item) === option.id
730
734
  );
731
735
  if (items.length === 0) {
732
736
  return [];
733
737
  }
734
- const groupId = agentProvenanceMentionGroupId(option.id);
735
- const pageSize = mentionGroupPageSize(input.currentFilter, groupId);
736
- const visibleCount = Math.min(
737
- items.length,
738
- input.expandedCounts[groupId] ?? pageSize
739
- );
740
738
  return [
741
- {
742
- id: groupId,
739
+ buildAgentProvenanceGroup({
740
+ currentFilter: input.currentFilter,
741
+ expandedCounts: input.expandedCounts,
742
+ id: agentProvenanceMentionGroupId(option.id),
743
743
  label: option.label,
744
- items: items.slice(0, visibleCount),
745
- totalCount: items.length,
746
- visibleCount,
747
- hasMore: items.length > visibleCount
748
- }
744
+ items
745
+ })
749
746
  ];
750
747
  }
751
748
  );
@@ -753,11 +750,12 @@ function buildSessionProvenanceGroups(input) {
753
750
  return catalogGroups;
754
751
  }
755
752
  const unmatchedGroups = /* @__PURE__ */ new Map();
756
- for (const item of sessionItems) {
757
- if (item.kind !== "session" || item.agentTargetId && catalogAgentTargetIds.has(item.agentTargetId)) {
753
+ for (const item of sourceItems) {
754
+ const agentTargetId = agentTargetIdForMentionItem(item);
755
+ if (agentTargetId && catalogAgentTargetIds.has(agentTargetId)) {
758
756
  continue;
759
757
  }
760
- const identity = item.agentTargetId?.trim() || item.agentName.trim() || item.initiatorName.trim() || item.targetId;
758
+ const identity = unmatchedAgentProvenanceIdentity(item);
761
759
  const key = `uncatalogued:${identity}`;
762
760
  const existing = unmatchedGroups.get(key);
763
761
  if (existing) {
@@ -766,28 +764,63 @@ function buildSessionProvenanceGroups(input) {
766
764
  }
767
765
  unmatchedGroups.set(key, {
768
766
  id: agentProvenanceMentionGroupId(key),
769
- label: item.agentName.trim() || item.initiatorName.trim() || item.agentTargetId?.trim() || item.title,
767
+ label: unmatchedAgentProvenanceLabel(item),
770
768
  items: [item]
771
769
  });
772
770
  }
773
771
  return [
774
772
  ...catalogGroups,
775
- ...[...unmatchedGroups.values()].map((group) => {
776
- const pageSize = mentionGroupPageSize(input.currentFilter, group.id);
777
- const visibleCount = Math.min(
778
- group.items.length,
779
- input.expandedCounts[group.id] ?? pageSize
780
- );
781
- return {
782
- ...group,
783
- items: group.items.slice(0, visibleCount),
784
- totalCount: group.items.length,
785
- visibleCount,
786
- hasMore: group.items.length > visibleCount
787
- };
788
- })
773
+ ...[...unmatchedGroups.values()].map(
774
+ (group) => buildAgentProvenanceGroup({
775
+ currentFilter: input.currentFilter,
776
+ expandedCounts: input.expandedCounts,
777
+ ...group
778
+ })
779
+ )
789
780
  ];
790
781
  }
782
+ function agentProvenanceItemsForFilter(input) {
783
+ if (input.currentFilter === "session") {
784
+ return input.rawGroups.sessions.filter((item) => item.kind === "session");
785
+ }
786
+ return input.rawGroups.agents.filter((item) => item.kind === "agent-target");
787
+ }
788
+ function agentTargetIdForMentionItem(item) {
789
+ if (item.kind === "session") {
790
+ return item.agentTargetId?.trim() || null;
791
+ }
792
+ if (item.kind === "agent-target") {
793
+ return item.targetId.trim() || null;
794
+ }
795
+ return null;
796
+ }
797
+ function unmatchedAgentProvenanceIdentity(item) {
798
+ if (item.kind === "session") {
799
+ return item.agentTargetId?.trim() || item.agentName.trim() || item.initiatorName.trim() || item.targetId;
800
+ }
801
+ return item.targetId;
802
+ }
803
+ function unmatchedAgentProvenanceLabel(item) {
804
+ if (item.kind === "session") {
805
+ return item.agentName.trim() || item.initiatorName.trim() || item.agentTargetId?.trim() || item.title;
806
+ }
807
+ return item.name;
808
+ }
809
+ function buildAgentProvenanceGroup(input) {
810
+ const pageSize = mentionGroupPageSize(input.currentFilter, input.id);
811
+ const visibleCount = Math.min(
812
+ input.items.length,
813
+ input.expandedCounts[input.id] ?? pageSize
814
+ );
815
+ return {
816
+ id: input.id,
817
+ label: input.label,
818
+ items: input.items.slice(0, visibleCount),
819
+ totalCount: input.items.length,
820
+ visibleCount,
821
+ hasMore: input.items.length > visibleCount
822
+ };
823
+ }
791
824
  function agentProvenanceMentionGroupId(agentTargetId) {
792
825
  return `agent:${encodeURIComponent(agentTargetId)}`;
793
826
  }
@@ -2809,4 +2842,4 @@ export {
2809
2842
  AgentMentionSearchController,
2810
2843
  preloadAgentMentionBrowse
2811
2844
  };
2812
- //# sourceMappingURL=chunk-UFD2QKGC.js.map
2845
+ //# sourceMappingURL=chunk-K7WFXVSD.js.map