@ai-matrx/agents 0.9.1 → 0.9.2

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.
@@ -271,53 +271,27 @@ var import_react4 = require("react");
271
271
 
272
272
  // catalog/shared/useAgentConsumer.ts
273
273
  var import_react3 = require("react");
274
-
275
- // catalog/types.ts
276
- function isMandateAgentId(id) {
277
- return id.startsWith("mandate:");
278
- }
279
- var SORT_OPTIONS = [
280
- { value: "updated-desc", label: "Recent" },
281
- { value: "created-desc", label: "Created" },
282
- { value: "name-asc", label: "A \u2192 Z" },
283
- { value: "name-desc", label: "Z \u2192 A" },
284
- { value: "category-asc", label: "Category" }
285
- ];
286
- var AGENT_NONE_SENTINEL = "__none__";
287
- var DEFAULT_AGENT_CONSUMER_STATE = {
288
- tab: "mine",
289
- sortBy: "updated-desc",
290
- searchTerm: "",
291
- includedCats: [],
292
- includedTags: [],
293
- favFilter: "all",
294
- archFilter: "active",
295
- accessFilter: "any",
296
- favoritesFirst: true,
297
- listPage: 1,
298
- sharedPage: 1,
299
- serverMatchedIds: [],
300
- isServerSearching: false,
301
- deepSearch: false
302
- };
303
-
304
- // catalog/shared/useAgentConsumer.ts
305
274
  var DEBOUNCE_MS = 250;
306
275
  var MIN_QUERY_LENGTH = 2;
307
276
  function useAgentConsumer(consumerId, options) {
308
277
  const catalog = useAgentCatalog();
278
+ const defaults = catalog.consumerDefaults;
309
279
  const selectConsumer = (0, import_react3.useCallback)(
310
- (state) => state.consumers[consumerId] ?? DEFAULT_AGENT_CONSUMER_STATE,
311
- [consumerId]
280
+ (state) => state.consumers[consumerId] ?? defaults,
281
+ [consumerId, defaults]
312
282
  );
313
283
  const consumer = useAgentCatalogState(selectConsumer);
314
284
  const optionsRef = (0, import_react3.useRef)(options);
315
285
  optionsRef.current = options;
316
286
  (0, import_react3.useEffect)(() => {
317
287
  const opts = optionsRef.current;
288
+ const initial = {
289
+ ...opts?.initialTab ? { tab: opts.initialTab } : {},
290
+ ...opts?.initialArchFilter ? { archFilter: opts.initialArchFilter } : {}
291
+ };
318
292
  catalog.registerConsumer(
319
293
  consumerId,
320
- opts?.initialTab ? { tab: opts.initialTab } : void 0
294
+ Object.keys(initial).length > 0 ? initial : void 0
321
295
  );
322
296
  return () => {
323
297
  if (optionsRef.current?.unregisterOnUnmount) {
@@ -440,7 +414,10 @@ function useAgentConsumer(consumerId, options) {
440
414
  isSearching
441
415
  });
442
416
  }, [consumerId, catalog, matchedIds, isSearching]);
443
- const hasActiveFilters = consumer.searchTerm !== "" || consumer.includedCats.length > 0 || consumer.includedTags.length > 0 || consumer.favFilter !== "all" || consumer.archFilter !== "active" || consumer.accessFilter !== "any" || !consumer.favoritesFirst;
417
+ const hasActiveFilters = consumer.searchTerm !== "" || consumer.includedCats.length > 0 || consumer.includedTags.length > 0 || consumer.favFilter !== "all" || // The archive filter is compared to THIS CATALOG'S default, not to the
418
+ // hardcoded platform one: a host that legitimately defaults to "show all"
419
+ // must not have the reset control permanently lit.
420
+ consumer.archFilter !== defaults.archFilter || consumer.accessFilter !== "any" || !consumer.favoritesFirst;
444
421
  return {
445
422
  tab: consumer.tab,
446
423
  sortBy: consumer.sortBy,
@@ -449,6 +426,7 @@ function useAgentConsumer(consumerId, options) {
449
426
  includedTags: consumer.includedTags,
450
427
  favFilter: consumer.favFilter,
451
428
  archFilter: consumer.archFilter,
429
+ archFilterDefault: defaults.archFilter,
452
430
  accessFilter: consumer.accessFilter,
453
431
  favoritesFirst: consumer.favoritesFirst,
454
432
  listPage: consumer.listPage,
@@ -475,6 +453,34 @@ function useAgentConsumer(consumerId, options) {
475
453
  };
476
454
  }
477
455
 
456
+ // catalog/types.ts
457
+ function isMandateAgentId(id) {
458
+ return id.startsWith("mandate:");
459
+ }
460
+ var SORT_OPTIONS = [
461
+ { value: "updated-desc", label: "Recent" },
462
+ { value: "created-desc", label: "Created" },
463
+ { value: "name-asc", label: "A \u2192 Z" },
464
+ { value: "name-desc", label: "Z \u2192 A" },
465
+ { value: "category-asc", label: "Category" }
466
+ ];
467
+ var ARCHIVE_FILTER_ORDER = [
468
+ "active",
469
+ "both",
470
+ "archived"
471
+ ];
472
+ var ARCHIVE_FILTER_OPTIONS = [
473
+ { value: "active", label: "Hide archived", chip: "Archive" },
474
+ { value: "both", label: "Show all", chip: "All + archived" },
475
+ { value: "archived", label: "Archived only", chip: "Archived only" }
476
+ ];
477
+ function nextArchFilter(current) {
478
+ const index = ARCHIVE_FILTER_ORDER.indexOf(current);
479
+ if (index < 0) return ARCHIVE_FILTER_ORDER[0];
480
+ return ARCHIVE_FILTER_ORDER[(index + 1) % ARCHIVE_FILTER_ORDER.length];
481
+ }
482
+ var AGENT_NONE_SENTINEL = "__none__";
483
+
478
484
  // catalog/labels.ts
479
485
  function agentListEmptyLabel(tab, labels) {
480
486
  switch (tab) {
@@ -491,6 +497,26 @@ function shouldDefaultAgentListToPublicTab(args) {
491
497
  if (!args.agentsLoaded) return false;
492
498
  return args.ownedCount === 0;
493
499
  }
500
+ function agentArchiveFilterChipLabel(archFilter) {
501
+ return ARCHIVE_FILTER_OPTIONS.find((o) => o.value === archFilter)?.chip ?? "Archive";
502
+ }
503
+ function agentArchiveFilterStateLabel(archFilter) {
504
+ return ARCHIVE_FILTER_OPTIONS.find((o) => o.value === archFilter)?.label ?? "Hide archived";
505
+ }
506
+ function agentArchiveFilterControlLabel(archFilter) {
507
+ return `Archive filter: ${agentArchiveFilterStateLabel(
508
+ archFilter
509
+ ).toLowerCase()}. Click for ${agentArchiveFilterStateLabel(
510
+ nextArchFilter(archFilter)
511
+ ).toLowerCase()}`;
512
+ }
513
+ function agentListFooterLabel(args) {
514
+ const { count, archFilter, archivedHiddenCount } = args;
515
+ if (archFilter === "archived") return `${count} archived shown`;
516
+ const base = `${count} agent${count !== 1 ? "s" : ""}`;
517
+ if (archFilter === "both") return `${base} \xB7 archived shown`;
518
+ return archivedHiddenCount > 0 ? `${base} \xB7 ${archivedHiddenCount} archived hidden` : base;
519
+ }
494
520
 
495
521
  // catalog/score.ts
496
522
  function computeAgentSearchScore(agent, query) {
@@ -681,8 +707,7 @@ function filterUserTypeAgents(agents, consumer) {
681
707
  if (tab === "mine" && agent.isOwner !== true) return false;
682
708
  if (tab === "shared" && !(agent.isOwner === false && agent.accessLevel != null))
683
709
  return false;
684
- if (archFilter === "active" && agent.isArchived) return false;
685
- if (archFilter === "archived" && !agent.isArchived) return false;
710
+ if (!agentMatchesArchiveFilter(agent, archFilter)) return false;
686
711
  if (favFilter === "yes" && !agent.isFavorite) return false;
687
712
  if (favFilter === "no" && agent.isFavorite) return false;
688
713
  if (accessFilter === "owned" && agent.isOwner !== true) return false;
@@ -712,9 +737,10 @@ function filterUserTypeAgents(agents, consumer) {
712
737
  return sortFilteredAgents(filtered, consumer);
713
738
  }
714
739
  function filterBuiltinTypeAgents(agents, consumer) {
715
- const { searchTerm, favFilter, includedCats, includedTags } = consumer;
740
+ const { searchTerm, favFilter, archFilter, includedCats, includedTags } = consumer;
716
741
  const serverMatched = new Set(consumer.serverMatchedIds);
717
742
  const filtered = agents.filter((agent) => {
743
+ if (!agentMatchesArchiveFilter(agent, archFilter)) return false;
718
744
  if (favFilter === "yes" && !agent.isFavorite) return false;
719
745
  if (favFilter === "no" && agent.isFavorite) return false;
720
746
  if (includedCats.length > 0) {
@@ -760,6 +786,15 @@ function agentMatchesArchiveFilter(agent, archFilter) {
760
786
  if (archFilter === "archived") return Boolean(agent.isArchived);
761
787
  return true;
762
788
  }
789
+ function countBuiltinRows(agents, archFilter) {
790
+ let n = 0;
791
+ for (const a of agents) {
792
+ if (a.agentType !== "builtin") continue;
793
+ if (!agentMatchesArchiveFilter(a, archFilter)) continue;
794
+ n += 1;
795
+ }
796
+ return n;
797
+ }
763
798
  function countUserRows(agents, archFilter, predicate) {
764
799
  let n = 0;
765
800
  for (const a of agents) {
@@ -778,7 +813,7 @@ var selectAgentTabCounts = memoize2(
778
813
  mine: countUserRows(agents, archFilter, isOwned),
779
814
  shared: countUserRows(agents, archFilter, isShared),
780
815
  all: countUserRows(agents, archFilter, isAny),
781
- system: selectBuiltinTypeAgents(agents).length
816
+ system: countBuiltinRows(agents, archFilter)
782
817
  })
783
818
  );
784
819
  var selectTotalUserAgentsCount = memoize1(
@@ -791,7 +826,7 @@ var selectTotalSharedAgentsCount = memoize1(
791
826
  (agents) => countUserRows(agents, "active", isShared)
792
827
  );
793
828
  var selectTotalBuiltinAgentsCount = memoize1(
794
- (agents) => selectBuiltinTypeAgents(agents).length
829
+ (agents) => countBuiltinRows(agents, "active")
795
830
  );
796
831
  var selectTotalFavoriteAgentsCount = memoize1(
797
832
  (agents) => countUserRows(agents, "active", isFavorite)
@@ -813,6 +848,7 @@ function useAgentListCore({
813
848
  initialTab,
814
849
  includeSystemInAll = false,
815
850
  visibleTabs,
851
+ initialArchFilter,
816
852
  excludeAgentIds = EMPTY_EXCLUDES,
817
853
  defaultMandateKey
818
854
  }) {
@@ -822,7 +858,10 @@ function useAgentListCore({
822
858
  const [hoveredAgent, setHoveredAgent] = (0, import_react4.useState)(null);
823
859
  const hoverLeaveTimerRef = (0, import_react4.useRef)(null);
824
860
  const defaultTabAppliedRef = (0, import_react4.useRef)(false);
825
- const consumer = useAgentConsumer(consumerId, { unregisterOnUnmount: true });
861
+ const consumer = useAgentConsumer(consumerId, {
862
+ unregisterOnUnmount: true,
863
+ ...initialArchFilter ? { initialArchFilter } : {}
864
+ });
826
865
  const rows = useAgentCatalogRows();
827
866
  const userId = catalog.getUserIdOrNull();
828
867
  const tabCountsForFilter = selectAgentTabCounts(rows, consumer.state.archFilter);
@@ -836,7 +875,20 @@ function useAgentListCore({
836
875
  () => new Set(excludeAgentIds),
837
876
  [excludeAgentIds]
838
877
  );
839
- const agents = excludedAgentIds.size === 0 ? filteredAgents : filteredAgents.filter((agent) => !excludedAgentIds.has(agent.id));
878
+ const applyExcludes = (0, import_react4.useCallback)(
879
+ (list) => excludedAgentIds.size === 0 ? list : list.filter((agent) => !excludedAgentIds.has(agent.id)),
880
+ [excludedAgentIds]
881
+ );
882
+ const agents = applyExcludes(filteredAgents);
883
+ const selectArchivedProbe = (0, import_react4.useMemo)(
884
+ () => makeSelectFilteredAgents(includeSystemInAll),
885
+ [includeSystemInAll]
886
+ );
887
+ const archiveProbeState = (0, import_react4.useMemo)(
888
+ () => ({ ...consumer.state, archFilter: "archived" }),
889
+ [consumer.state]
890
+ );
891
+ const archivedHiddenCount = consumer.archFilter === "active" ? applyExcludes(selectArchivedProbe(rows, archiveProbeState)).length : 0;
840
892
  const status = useAgentCatalogState(selectStatus);
841
893
  const activeAgentId = activeAgentIdOverride ?? null;
842
894
  const pinnedAgent = activeAgentId ? catalog.getAgent(activeAgentId) : void 0;
@@ -923,7 +975,9 @@ function useAgentListCore({
923
975
  },
924
976
  [onSelect, navigateTo, navigate, catalog, consumerId]
925
977
  );
926
- const activeFilterCount = (consumer.sortBy !== "updated-desc" ? 1 : 0) + (consumer.includedCats.length > 0 ? 1 : 0) + (consumer.includedTags.length > 0 ? 1 : 0) + (consumer.favFilter !== "all" ? 1 : 0);
978
+ const activeFilterCount = (consumer.sortBy !== "updated-desc" ? 1 : 0) + (consumer.includedCats.length > 0 ? 1 : 0) + (consumer.includedTags.length > 0 ? 1 : 0) + (consumer.favFilter !== "all" ? 1 : 0) + // The archive filter counts like every other filter, so a list showing
979
+ // archived rows offers the reset control that puts them away again.
980
+ (consumer.archFilter !== consumer.archFilterDefault ? 1 : 0);
927
981
  const handleAgentHover = (0, import_react4.useCallback)(
928
982
  (agent, panelOpen) => {
929
983
  if (panelOpen) return;
@@ -964,8 +1018,15 @@ function useAgentListCore({
964
1018
  },
965
1019
  []
966
1020
  );
1021
+ const footerLabel = agentListFooterLabel({
1022
+ count: agents.length,
1023
+ archFilter: consumer.archFilter,
1024
+ archivedHiddenCount
1025
+ });
967
1026
  return {
968
1027
  agents,
1028
+ archivedHiddenCount,
1029
+ footerLabel,
969
1030
  isLoading,
970
1031
  activeAgentId,
971
1032
  pinnedAgent: pinnedAgent ?? null,
@@ -1108,6 +1169,18 @@ var SHAPES = {
1108
1169
  "M12 15v5s3.03-.55 4-2c1.08-1.62 0-5 0-5"
1109
1170
  ]
1110
1171
  },
1172
+ /**
1173
+ * THE ARCHIVE GLYPH (Lucide `archive`) — the ONE mark of the platform
1174
+ * archive filter, drawn identically in every Matrx client so the control a
1175
+ * person learns on one surface is recognisable on all of them.
1176
+ */
1177
+ archive: {
1178
+ paths: [
1179
+ "M3 3h18a1 1 0 0 1 1 1v3a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V4a1 1 0 0 1 1-1z",
1180
+ "M4 8v11a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8",
1181
+ "M10 12h4"
1182
+ ]
1183
+ },
1111
1184
  circleCheck: {
1112
1185
  paths: ["m9 12 2 2 4-4"],
1113
1186
  circles: [{ cx: 12, cy: 12, r: 10 }]
@@ -1177,6 +1250,7 @@ var TEXT_GLYPHS = {
1177
1250
  folder: "\u25A4",
1178
1251
  tag: "\u2317",
1179
1252
  rotateCcw: "\u21BA",
1253
+ archive: "\u25A3",
1180
1254
  loader: "\u25CC",
1181
1255
  alertTriangle: "\u26A0",
1182
1256
  music4: "\u266A",
@@ -1690,7 +1764,9 @@ function FilterChip({
1690
1764
  icon,
1691
1765
  label,
1692
1766
  active,
1693
- onPress
1767
+ onPress,
1768
+ accessibilityLabel,
1769
+ testID
1694
1770
  }) {
1695
1771
  const theme = useAgentCatalogNativeTheme();
1696
1772
  const { errorSink } = useAgentCatalog();
@@ -1701,7 +1777,8 @@ function FilterChip({
1701
1777
  onPress,
1702
1778
  accessibilityRole: "button",
1703
1779
  accessibilityState: { selected: active },
1704
- accessibilityLabel: label,
1780
+ accessibilityLabel: accessibilityLabel ?? label,
1781
+ ...testID ? { testID } : {},
1705
1782
  style: ({ pressed }) => [
1706
1783
  styles2.chip,
1707
1784
  {
@@ -1960,6 +2037,17 @@ function AgentFilterBar({
1960
2037
  }
1961
2038
  }
1962
2039
  ),
2040
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2041
+ FilterChip,
2042
+ {
2043
+ icon: "archive",
2044
+ label: agentArchiveFilterChipLabel(consumer.archFilter),
2045
+ active: consumer.archFilter !== consumer.archFilterDefault,
2046
+ accessibilityLabel: agentArchiveFilterControlLabel(consumer.archFilter),
2047
+ testID: "agent-archive-filter",
2048
+ onPress: () => consumer.setArchFilter(nextArchFilter(consumer.archFilter))
2049
+ }
2050
+ ),
1963
2051
  allCategories.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1964
2052
  FilterChip,
1965
2053
  {
@@ -2306,7 +2394,8 @@ function AgentListContent({
2306
2394
  systemTabLabel,
2307
2395
  pinnedAgent = null,
2308
2396
  defaultRow = null,
2309
- autoFocusSearch = false
2397
+ autoFocusSearch = false,
2398
+ archivedHiddenCount = 0
2310
2399
  }) {
2311
2400
  const catalog = useAgentCatalog();
2312
2401
  const theme = useAgentCatalogNativeTheme();
@@ -2534,19 +2623,20 @@ function AgentListContent({
2534
2623
  ),
2535
2624
  /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_react_native9.View, { style: hairline }),
2536
2625
  /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_react_native9.View, { style: [styles6.footer, { paddingHorizontal: theme.spacing.md }], children: [
2537
- /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
2626
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
2538
2627
  import_react_native9.Text,
2539
2628
  {
2629
+ testID: "agent-list-footer",
2540
2630
  style: {
2541
2631
  color: theme.colors.textMuted,
2542
2632
  fontSize: theme.fontSize.xs,
2543
2633
  fontVariant: ["tabular-nums"]
2544
2634
  },
2545
- children: [
2546
- agents.length,
2547
- " agent",
2548
- agents.length !== 1 ? "s" : ""
2549
- ]
2635
+ children: agentListFooterLabel({
2636
+ count: agents.length,
2637
+ archFilter: consumer.archFilter,
2638
+ archivedHiddenCount
2639
+ })
2550
2640
  }
2551
2641
  ),
2552
2642
  consumer.searchTerm.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
@@ -2713,6 +2803,7 @@ function AgentPickerBody({
2713
2803
  const [panelSearch, setPanelSearch] = (0, import_react6.useState)("");
2714
2804
  const {
2715
2805
  agents,
2806
+ archivedHiddenCount,
2716
2807
  isLoading,
2717
2808
  allCategories,
2718
2809
  allTags,
@@ -2784,6 +2875,7 @@ function AgentPickerBody({
2784
2875
  onReset: consumer.resetFilters,
2785
2876
  activeFilterCount,
2786
2877
  tabCounts,
2878
+ archivedHiddenCount,
2787
2879
  ...visibleTabs ? { visibleTabs } : {},
2788
2880
  ...systemTabLabel ?? (includeSystemInAll ? "System" : void 0) ? {
2789
2881
  systemTabLabel: systemTabLabel ?? (includeSystemInAll ? "System" : void 0)