@ai-matrx/agents 0.9.0 → 0.9.1

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.
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode } from 'react';
3
- import { t as AgentCatalogNavigate, v as AgentCatalogOpenPeek, n as AgentCatalog, A as AgentSummary, z as AgentCatalogState, f as AgentTab, i as AgentSortOption, E as AgentFavFilter, m as AgentArchFilter, k as AgentAccessFilter, h as AgentConsumerState, J as DefaultRowState } from '../../orchestra-BWJM2MWP.cjs';
4
- export { O as OrchestraBadge, W as orchestraDelegatesLine, X as orchestraDepthLine, Y as orchestraLabel, Z as orchestraModeLabel } from '../../orchestra-BWJM2MWP.cjs';
3
+ import { t as AgentCatalogNavigate, v as AgentCatalogOpenPeek, n as AgentCatalog, A as AgentSummary, z as AgentCatalogState, f as AgentTab, j as AgentSortOption, E as AgentFavFilter, i as AgentArchFilter, l as AgentAccessFilter, h as AgentConsumerState, J as DefaultRowState } from '../../orchestra-CID-rsu8.cjs';
4
+ export { O as OrchestraBadge, W as orchestraDelegatesLine, X as orchestraDepthLine, Y as orchestraLabel, Z as orchestraModeLabel } from '../../orchestra-CID-rsu8.cjs';
5
5
 
6
6
  /**
7
7
  * The anchor a row renders for cmd/ctrl-click. DEFAULT (web): a plain `<a>` —
@@ -301,6 +301,11 @@ declare function useAgentConsumer(consumerId: string, options?: {
301
301
  * The four ownership counts a tab strip prints. Declared HERE, beside the code
302
302
  * that computes them, so both the web tab strip and the native one name the
303
303
  * same shape (0.9.0 — it used to live in the web-only `AgentListTabs`).
304
+ *
305
+ * 🚨 These are the numbers on the BADGES, and since 0.9.1 they count exactly
306
+ * the rows the tab renders under the consumer's own archive filter. A badge
307
+ * that counted rows the list hid was the screen telling the user something
308
+ * untrue about her own agents.
304
309
  */
305
310
  interface AgentListTabCounts {
306
311
  mine: number;
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ComponentType, ReactNode } from 'react';
3
- import { t as AgentCatalogNavigate, v as AgentCatalogOpenPeek, n as AgentCatalog, A as AgentSummary, z as AgentCatalogState, f as AgentTab, i as AgentSortOption, E as AgentFavFilter, m as AgentArchFilter, k as AgentAccessFilter, h as AgentConsumerState, J as DefaultRowState } from '../../orchestra-BWJM2MWP.js';
4
- export { O as OrchestraBadge, W as orchestraDelegatesLine, X as orchestraDepthLine, Y as orchestraLabel, Z as orchestraModeLabel } from '../../orchestra-BWJM2MWP.js';
3
+ import { t as AgentCatalogNavigate, v as AgentCatalogOpenPeek, n as AgentCatalog, A as AgentSummary, z as AgentCatalogState, f as AgentTab, j as AgentSortOption, E as AgentFavFilter, i as AgentArchFilter, l as AgentAccessFilter, h as AgentConsumerState, J as DefaultRowState } from '../../orchestra-CID-rsu8.js';
4
+ export { O as OrchestraBadge, W as orchestraDelegatesLine, X as orchestraDepthLine, Y as orchestraLabel, Z as orchestraModeLabel } from '../../orchestra-CID-rsu8.js';
5
5
 
6
6
  /**
7
7
  * The anchor a row renders for cmd/ctrl-click. DEFAULT (web): a plain `<a>` —
@@ -301,6 +301,11 @@ declare function useAgentConsumer(consumerId: string, options?: {
301
301
  * The four ownership counts a tab strip prints. Declared HERE, beside the code
302
302
  * that computes them, so both the web tab strip and the native one name the
303
303
  * same shape (0.9.0 — it used to live in the web-only `AgentListTabs`).
304
+ *
305
+ * 🚨 These are the numbers on the BADGES, and since 0.9.1 they count exactly
306
+ * the rows the tab renders under the consumer's own archive filter. A badge
307
+ * that counted rows the list hid was the screen telling the user something
308
+ * untrue about her own agents.
304
309
  */
305
310
  interface AgentListTabCounts {
306
311
  mine: number;
@@ -525,7 +525,19 @@ function memoize2(fn) {
525
525
  return last;
526
526
  };
527
527
  }
528
+ function compareAgentIds(a, b) {
529
+ const idA = a.id ?? "";
530
+ const idB = b.id ?? "";
531
+ if (idA < idB) return -1;
532
+ if (idA > idB) return 1;
533
+ return 0;
534
+ }
528
535
  function applyAgentSortComparator(a, b, sortBy) {
536
+ const primary = compareAgentSortKey(a, b, sortBy);
537
+ if (!Number.isFinite(primary) || primary === 0) return compareAgentIds(a, b);
538
+ return primary;
539
+ }
540
+ function compareAgentSortKey(a, b, sortBy) {
529
541
  switch (sortBy) {
530
542
  case "name-asc":
531
543
  return (a.name ?? "").localeCompare(b.name ?? "");
@@ -701,22 +713,46 @@ var makeSelectFilteredAgents = (includeSystemInAll = false) => memoize2(
701
713
  return filterUserTypeAgents(userAgents, consumer);
702
714
  }
703
715
  );
716
+ function agentMatchesArchiveFilter(agent, archFilter) {
717
+ if (archFilter === "active") return !agent.isArchived;
718
+ if (archFilter === "archived") return Boolean(agent.isArchived);
719
+ return true;
720
+ }
721
+ function countUserRows(agents, archFilter, predicate) {
722
+ let n = 0;
723
+ for (const a of agents) {
724
+ if (a.agentType !== "user") continue;
725
+ if (!agentMatchesArchiveFilter(a, archFilter)) continue;
726
+ if (predicate(a)) n += 1;
727
+ }
728
+ return n;
729
+ }
730
+ var isOwned = (a) => a.isOwner === true;
731
+ var isShared = (a) => a.isOwner === false && a.accessLevel != null;
732
+ var isAny = () => true;
733
+ var isFavorite = (a) => Boolean(a.isFavorite);
734
+ var selectAgentTabCounts = memoize2(
735
+ (agents, archFilter) => ({
736
+ mine: countUserRows(agents, archFilter, isOwned),
737
+ shared: countUserRows(agents, archFilter, isShared),
738
+ all: countUserRows(agents, archFilter, isAny),
739
+ system: selectBuiltinTypeAgents(agents).length
740
+ })
741
+ );
704
742
  var selectTotalUserAgentsCount = memoize1(
705
- (agents) => selectUserTypeAgents(agents).length
743
+ (agents) => countUserRows(agents, "active", isAny)
706
744
  );
707
745
  var selectTotalOwnedAgentsCount = memoize1(
708
- (agents) => selectUserTypeAgents(agents).filter((a) => a.isOwner === true).length
746
+ (agents) => countUserRows(agents, "active", isOwned)
709
747
  );
710
748
  var selectTotalSharedAgentsCount = memoize1(
711
- (agents) => selectUserTypeAgents(agents).filter(
712
- (a) => a.isOwner === false && a.accessLevel != null
713
- ).length
749
+ (agents) => countUserRows(agents, "active", isShared)
714
750
  );
715
751
  var selectTotalBuiltinAgentsCount = memoize1(
716
752
  (agents) => selectBuiltinTypeAgents(agents).length
717
753
  );
718
754
  var selectTotalFavoriteAgentsCount = memoize1(
719
- (agents) => selectUserTypeAgents(agents).filter((a) => a.isFavorite).length
755
+ (agents) => countUserRows(agents, "active", isFavorite)
720
756
  );
721
757
 
722
758
  // catalog/shared/useAgentListCore.ts
@@ -747,7 +783,8 @@ function useAgentListCore({
747
783
  const consumer = useAgentConsumer(consumerId, { unregisterOnUnmount: true });
748
784
  const rows = useAgentCatalogRows();
749
785
  const userId = catalog.getUserIdOrNull();
750
- const ownedCount = selectTotalOwnedAgentsCount(rows);
786
+ const tabCountsForFilter = selectAgentTabCounts(rows, consumer.state.archFilter);
787
+ const ownedCount = tabCountsForFilter.mine;
751
788
  const selectFiltered = useMemo3(
752
789
  () => makeSelectFilteredAgents(includeSystemInAll),
753
790
  [includeSystemInAll]
@@ -764,12 +801,7 @@ function useAgentListCore({
764
801
  const onSystemTab = consumer.tab === "system";
765
802
  const allCategories = onSystemTab ? selectAllSystemAgentCategories(rows) : selectAllAgentCategories(rows);
766
803
  const allTags = onSystemTab ? selectAllSystemAgentTags(rows) : selectAllAgentTags(rows);
767
- const tabCounts = {
768
- mine: ownedCount,
769
- shared: selectTotalSharedAgentsCount(rows),
770
- all: selectTotalUserAgentsCount(rows),
771
- system: selectTotalBuiltinAgentsCount(rows)
772
- };
804
+ const tabCounts = tabCountsForFilter;
773
805
  const isLoading = status === "loading";
774
806
  const agentsLoaded = status === "succeeded" || status === "failed";
775
807
  const ensureLoaded = useCallback3(() => {
@@ -1185,31 +1217,31 @@ function FavoriteAgentButton({
1185
1217
  const theme = useAgentCatalogNativeTheme();
1186
1218
  const select = useCallback4((state) => state.byId[id], [id]);
1187
1219
  const record = useAgentCatalogState(select);
1188
- const isFavorite = record?.isFavorite ?? false;
1220
+ const isFavorite2 = record?.isFavorite ?? false;
1189
1221
  const isOwner = record?.isOwner ?? true;
1190
1222
  const inert = Boolean(disabled) || !isOwner;
1191
- const title = isOwner ? isFavorite ? "Remove from favorites" : "Add to favorites" : "Shared \u2014 cannot favorite";
1223
+ const title = isOwner ? isFavorite2 ? "Remove from favorites" : "Add to favorites" : "Shared \u2014 cannot favorite";
1192
1224
  return /* @__PURE__ */ jsx4(
1193
1225
  Pressable2,
1194
1226
  {
1195
1227
  onPress: () => {
1196
1228
  if (inert) return;
1197
- void catalog.setFavorite(id, !isFavorite).catch(() => {
1229
+ void catalog.setFavorite(id, !isFavorite2).catch(() => {
1198
1230
  });
1199
1231
  },
1200
1232
  disabled: inert,
1201
1233
  hitSlop: 8,
1202
1234
  accessibilityRole: "button",
1203
1235
  accessibilityLabel: title,
1204
- accessibilityState: { disabled: inert, selected: isFavorite },
1236
+ accessibilityState: { disabled: inert, selected: isFavorite2 },
1205
1237
  style: { opacity: inert ? 0.4 : 1 },
1206
1238
  children: /* @__PURE__ */ jsx4(
1207
1239
  AgentIcon,
1208
1240
  {
1209
1241
  name: "star",
1210
1242
  size,
1211
- filled: isFavorite,
1212
- color: isFavorite ? theme.colors.favorite : theme.colors.textFaint,
1243
+ filled: isFavorite2,
1244
+ color: isFavorite2 ? theme.colors.favorite : theme.colors.textFaint,
1213
1245
  report: catalog.errorSink
1214
1246
  }
1215
1247
  )