@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.
- package/CHANGELOG.md +108 -0
- package/dist/catalog/index.cjs +51 -12
- package/dist/catalog/index.cjs.map +1 -1
- package/dist/catalog/index.d.cts +78 -4
- package/dist/catalog/index.d.ts +78 -4
- package/dist/catalog/index.js +51 -12
- package/dist/catalog/index.js.map +1 -1
- package/dist/catalog/native/index.cjs +51 -19
- package/dist/catalog/native/index.cjs.map +1 -1
- package/dist/catalog/native/index.d.cts +7 -2
- package/dist/catalog/native/index.d.ts +7 -2
- package/dist/catalog/native/index.js +51 -19
- package/dist/catalog/native/index.js.map +1 -1
- package/dist/catalog/react/index.cjs +55 -22
- package/dist/catalog/react/index.cjs.map +1 -1
- package/dist/catalog/react/index.d.cts +5 -0
- package/dist/catalog/react/index.d.ts +5 -0
- package/dist/catalog/react/index.js +55 -22
- package/dist/catalog/react/index.js.map +1 -1
- package/dist/{orchestra-BWJM2MWP.d.cts → orchestra-CID-rsu8.d.cts} +1 -1
- package/dist/{orchestra-BWJM2MWP.d.ts → orchestra-CID-rsu8.d.ts} +1 -1
- package/package.json +1 -1
|
@@ -567,7 +567,19 @@ function memoize2(fn) {
|
|
|
567
567
|
return last;
|
|
568
568
|
};
|
|
569
569
|
}
|
|
570
|
+
function compareAgentIds(a, b) {
|
|
571
|
+
const idA = a.id ?? "";
|
|
572
|
+
const idB = b.id ?? "";
|
|
573
|
+
if (idA < idB) return -1;
|
|
574
|
+
if (idA > idB) return 1;
|
|
575
|
+
return 0;
|
|
576
|
+
}
|
|
570
577
|
function applyAgentSortComparator(a, b, sortBy) {
|
|
578
|
+
const primary = compareAgentSortKey(a, b, sortBy);
|
|
579
|
+
if (!Number.isFinite(primary) || primary === 0) return compareAgentIds(a, b);
|
|
580
|
+
return primary;
|
|
581
|
+
}
|
|
582
|
+
function compareAgentSortKey(a, b, sortBy) {
|
|
571
583
|
switch (sortBy) {
|
|
572
584
|
case "name-asc":
|
|
573
585
|
return (a.name ?? "").localeCompare(b.name ?? "");
|
|
@@ -743,22 +755,46 @@ var makeSelectFilteredAgents = (includeSystemInAll = false) => memoize2(
|
|
|
743
755
|
return filterUserTypeAgents(userAgents, consumer);
|
|
744
756
|
}
|
|
745
757
|
);
|
|
758
|
+
function agentMatchesArchiveFilter(agent, archFilter) {
|
|
759
|
+
if (archFilter === "active") return !agent.isArchived;
|
|
760
|
+
if (archFilter === "archived") return Boolean(agent.isArchived);
|
|
761
|
+
return true;
|
|
762
|
+
}
|
|
763
|
+
function countUserRows(agents, archFilter, predicate) {
|
|
764
|
+
let n = 0;
|
|
765
|
+
for (const a of agents) {
|
|
766
|
+
if (a.agentType !== "user") continue;
|
|
767
|
+
if (!agentMatchesArchiveFilter(a, archFilter)) continue;
|
|
768
|
+
if (predicate(a)) n += 1;
|
|
769
|
+
}
|
|
770
|
+
return n;
|
|
771
|
+
}
|
|
772
|
+
var isOwned = (a) => a.isOwner === true;
|
|
773
|
+
var isShared = (a) => a.isOwner === false && a.accessLevel != null;
|
|
774
|
+
var isAny = () => true;
|
|
775
|
+
var isFavorite = (a) => Boolean(a.isFavorite);
|
|
776
|
+
var selectAgentTabCounts = memoize2(
|
|
777
|
+
(agents, archFilter) => ({
|
|
778
|
+
mine: countUserRows(agents, archFilter, isOwned),
|
|
779
|
+
shared: countUserRows(agents, archFilter, isShared),
|
|
780
|
+
all: countUserRows(agents, archFilter, isAny),
|
|
781
|
+
system: selectBuiltinTypeAgents(agents).length
|
|
782
|
+
})
|
|
783
|
+
);
|
|
746
784
|
var selectTotalUserAgentsCount = memoize1(
|
|
747
|
-
(agents) =>
|
|
785
|
+
(agents) => countUserRows(agents, "active", isAny)
|
|
748
786
|
);
|
|
749
787
|
var selectTotalOwnedAgentsCount = memoize1(
|
|
750
|
-
(agents) =>
|
|
788
|
+
(agents) => countUserRows(agents, "active", isOwned)
|
|
751
789
|
);
|
|
752
790
|
var selectTotalSharedAgentsCount = memoize1(
|
|
753
|
-
(agents) =>
|
|
754
|
-
(a) => a.isOwner === false && a.accessLevel != null
|
|
755
|
-
).length
|
|
791
|
+
(agents) => countUserRows(agents, "active", isShared)
|
|
756
792
|
);
|
|
757
793
|
var selectTotalBuiltinAgentsCount = memoize1(
|
|
758
794
|
(agents) => selectBuiltinTypeAgents(agents).length
|
|
759
795
|
);
|
|
760
796
|
var selectTotalFavoriteAgentsCount = memoize1(
|
|
761
|
-
(agents) =>
|
|
797
|
+
(agents) => countUserRows(agents, "active", isFavorite)
|
|
762
798
|
);
|
|
763
799
|
|
|
764
800
|
// catalog/shared/useAgentListCore.ts
|
|
@@ -789,7 +825,8 @@ function useAgentListCore({
|
|
|
789
825
|
const consumer = useAgentConsumer(consumerId, { unregisterOnUnmount: true });
|
|
790
826
|
const rows = useAgentCatalogRows();
|
|
791
827
|
const userId = catalog.getUserIdOrNull();
|
|
792
|
-
const
|
|
828
|
+
const tabCountsForFilter = selectAgentTabCounts(rows, consumer.state.archFilter);
|
|
829
|
+
const ownedCount = tabCountsForFilter.mine;
|
|
793
830
|
const selectFiltered = (0, import_react4.useMemo)(
|
|
794
831
|
() => makeSelectFilteredAgents(includeSystemInAll),
|
|
795
832
|
[includeSystemInAll]
|
|
@@ -806,12 +843,7 @@ function useAgentListCore({
|
|
|
806
843
|
const onSystemTab = consumer.tab === "system";
|
|
807
844
|
const allCategories = onSystemTab ? selectAllSystemAgentCategories(rows) : selectAllAgentCategories(rows);
|
|
808
845
|
const allTags = onSystemTab ? selectAllSystemAgentTags(rows) : selectAllAgentTags(rows);
|
|
809
|
-
const tabCounts =
|
|
810
|
-
mine: ownedCount,
|
|
811
|
-
shared: selectTotalSharedAgentsCount(rows),
|
|
812
|
-
all: selectTotalUserAgentsCount(rows),
|
|
813
|
-
system: selectTotalBuiltinAgentsCount(rows)
|
|
814
|
-
};
|
|
846
|
+
const tabCounts = tabCountsForFilter;
|
|
815
847
|
const isLoading = status === "loading";
|
|
816
848
|
const agentsLoaded = status === "succeeded" || status === "failed";
|
|
817
849
|
const ensureLoaded = (0, import_react4.useCallback)(() => {
|
|
@@ -1227,31 +1259,31 @@ function FavoriteAgentButton({
|
|
|
1227
1259
|
const theme = useAgentCatalogNativeTheme();
|
|
1228
1260
|
const select = (0, import_react5.useCallback)((state) => state.byId[id], [id]);
|
|
1229
1261
|
const record = useAgentCatalogState(select);
|
|
1230
|
-
const
|
|
1262
|
+
const isFavorite2 = record?.isFavorite ?? false;
|
|
1231
1263
|
const isOwner = record?.isOwner ?? true;
|
|
1232
1264
|
const inert = Boolean(disabled) || !isOwner;
|
|
1233
|
-
const title = isOwner ?
|
|
1265
|
+
const title = isOwner ? isFavorite2 ? "Remove from favorites" : "Add to favorites" : "Shared \u2014 cannot favorite";
|
|
1234
1266
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1235
1267
|
import_react_native3.Pressable,
|
|
1236
1268
|
{
|
|
1237
1269
|
onPress: () => {
|
|
1238
1270
|
if (inert) return;
|
|
1239
|
-
void catalog.setFavorite(id, !
|
|
1271
|
+
void catalog.setFavorite(id, !isFavorite2).catch(() => {
|
|
1240
1272
|
});
|
|
1241
1273
|
},
|
|
1242
1274
|
disabled: inert,
|
|
1243
1275
|
hitSlop: 8,
|
|
1244
1276
|
accessibilityRole: "button",
|
|
1245
1277
|
accessibilityLabel: title,
|
|
1246
|
-
accessibilityState: { disabled: inert, selected:
|
|
1278
|
+
accessibilityState: { disabled: inert, selected: isFavorite2 },
|
|
1247
1279
|
style: { opacity: inert ? 0.4 : 1 },
|
|
1248
1280
|
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1249
1281
|
AgentIcon,
|
|
1250
1282
|
{
|
|
1251
1283
|
name: "star",
|
|
1252
1284
|
size,
|
|
1253
|
-
filled:
|
|
1254
|
-
color:
|
|
1285
|
+
filled: isFavorite2,
|
|
1286
|
+
color: isFavorite2 ? theme.colors.favorite : theme.colors.textFaint,
|
|
1255
1287
|
report: catalog.errorSink
|
|
1256
1288
|
}
|
|
1257
1289
|
)
|