@ai-matrx/chat 0.3.24 → 0.3.26
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 +14 -0
- package/dist/agents/identity/agent-identity.d.ts +19 -1
- package/dist/agents/identity/agent-identity.js +22 -5
- package/dist/agents/redux/agent-definition/converters.js +1 -1
- package/dist/agents/redux/agent-definition/selectors.d.ts +604 -4573
- package/dist/agents/redux/agent-definition/selectors.js +6 -129
- package/dist/agents/redux/agent-definition/thunks.d.ts +0 -1
- package/dist/agents/redux/agent-definition/thunks.js +0 -16
- package/dist/agents/redux/agent-filter/selectors.d.ts +1 -402
- package/dist/agents/redux/agent-filter/selectors.js +1 -25
- package/dist/agents/types/agent-definition.types.d.ts +0 -8
- package/dist/conversation/hooks/useDomCapturePrint.js +2 -2
- package/dist/host/db-types.d.ts +36 -0
- package/package.json +7 -6
- package/dist/agents/redux/agent-definition/list-mirror.d.ts +0 -139
- package/dist/agents/redux/agent-definition/list-mirror.js +0 -157
- package/dist/agents/route/AgentListHydrator.d.ts +0 -4
- package/dist/agents/route/AgentListHydrator.js +0 -49
|
@@ -1,139 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* DEPRECATED — the agent-list MIRROR (agent core B2). Removed in the next chat
|
|
3
|
-
* release: readers move to `agents/identity/agent-identity.ts` and
|
|
4
|
-
* `agents/identity/agent-catalog-lists.ts`, which read the ONE catalog store.
|
|
5
|
-
* Kept one release so hosts can repoint before the exports disappear.
|
|
6
|
-
*/
|
|
7
|
-
import type { ChatDispatch, ChatRootState } from "../../../store/root-state.js";
|
|
8
|
-
/** Thunk form of `overlayAgentFavorites`, for surfaces that seed rows themselves. */
|
|
9
|
-
export declare const overlayAgentFavoritesThunk: import("@reduxjs/toolkit").AsyncThunk<void, readonly string[], {
|
|
10
|
-
extra?: unknown;
|
|
11
|
-
rejectValue?: unknown;
|
|
12
|
-
serializedErrorType?: unknown;
|
|
13
|
-
pendingMeta?: unknown;
|
|
14
|
-
fulfilledMeta?: unknown;
|
|
15
|
-
rejectedMeta?: unknown;
|
|
16
|
-
dispatch: ChatDispatch;
|
|
17
|
-
state: ChatRootState;
|
|
18
|
-
}>;
|
|
19
|
-
/**
|
|
20
|
-
* Hydrates this registry from the ONE agent catalog. The gallery, the agent
|
|
21
|
-
* pages, and every name-resolving surface read `agentDefinition`; the catalog
|
|
22
|
-
* reads the database. This is the seam between them.
|
|
23
|
-
*
|
|
24
|
-
* The catalog's own freshness window and in-flight dedupe make this safe to
|
|
25
|
-
* dispatch on every mount — no thunk-level TTL guard is needed or wanted.
|
|
26
|
-
*/
|
|
27
|
-
export declare const fetchAgentsList: import("@reduxjs/toolkit").AsyncThunk<void, void, {
|
|
28
|
-
extra?: unknown;
|
|
29
|
-
rejectValue?: unknown;
|
|
30
|
-
serializedErrorType?: unknown;
|
|
31
|
-
pendingMeta?: unknown;
|
|
32
|
-
fulfilledMeta?: unknown;
|
|
33
|
-
rejectedMeta?: unknown;
|
|
34
|
-
dispatch: ChatDispatch;
|
|
35
|
-
state: ChatRootState;
|
|
36
|
-
}>;
|
|
37
|
-
/**
|
|
38
|
-
* Server-side agent search — the canonical path for finding an agent.
|
|
39
|
-
*
|
|
40
|
-
* WHY THIS EXISTS: the list is paginated. Filtering only what the client has
|
|
41
|
-
* already loaded silently reports "no results" for agents that were simply
|
|
42
|
-
* never fetched. Any paginated collection therefore needs a server search.
|
|
43
|
-
*
|
|
44
|
-
* ADDITIVE BY CONTRACT: results go through `mergeAgentListRows`, the same
|
|
45
|
-
* merge the list fetch uses. Rows are ADDED to the store and existing records
|
|
46
|
-
* are enriched, never replaced or evicted. Local matches keep rendering
|
|
47
|
-
* instantly while this resolves, then server-only matches fold in beneath
|
|
48
|
-
* them — nothing the user is already looking at disappears.
|
|
49
|
-
*
|
|
50
|
-
* Two tiers:
|
|
51
|
-
* deep = false (default) — name, description, category, tags, model, id
|
|
52
|
-
* deep = true — the above PLUS the agent's own prompt content
|
|
53
|
-
*
|
|
54
|
-
* Tier 2 is a strict superset and prompt hits always score below every tier-1
|
|
55
|
-
* field, so enabling it can only append below the obvious matches.
|
|
56
|
-
*
|
|
57
|
-
* Returns the matched ids in server rank order so a caller can preserve
|
|
58
|
-
* server relevance ordering if it wants to.
|
|
59
|
-
*/
|
|
60
|
-
export declare const searchAgentsServer: import("@reduxjs/toolkit").AsyncThunk<{
|
|
61
|
-
ids: string[];
|
|
62
|
-
deep: boolean;
|
|
63
|
-
query: string;
|
|
64
|
-
}, {
|
|
65
|
-
query: string;
|
|
66
|
-
deep?: boolean;
|
|
67
|
-
limit?: number;
|
|
68
|
-
}, {
|
|
69
|
-
extra?: unknown;
|
|
70
|
-
rejectValue?: unknown;
|
|
71
|
-
serializedErrorType?: unknown;
|
|
72
|
-
pendingMeta?: unknown;
|
|
73
|
-
fulfilledMeta?: unknown;
|
|
74
|
-
rejectedMeta?: unknown;
|
|
75
|
-
dispatch: ChatDispatch;
|
|
76
|
-
state: ChatRootState;
|
|
77
|
-
}>;
|
|
78
|
-
/**
|
|
79
|
-
* The picker-era name for the same hydration. Kept because ~20 surfaces
|
|
80
|
-
* dispatch it by name; it is `fetchAgentsList` with no status writes, because
|
|
81
|
-
* a picker's own loading state comes from the package now.
|
|
82
|
-
*/
|
|
83
|
-
export declare const fetchAgentsListFull: import("@reduxjs/toolkit").AsyncThunk<void, void, {
|
|
84
|
-
extra?: unknown;
|
|
85
|
-
rejectValue?: unknown;
|
|
86
|
-
serializedErrorType?: unknown;
|
|
87
|
-
pendingMeta?: unknown;
|
|
88
|
-
fulfilledMeta?: unknown;
|
|
89
|
-
rejectedMeta?: unknown;
|
|
90
|
-
dispatch: ChatDispatch;
|
|
91
|
-
state: ChatRootState;
|
|
92
|
-
}>;
|
|
93
|
-
/**
|
|
94
|
-
* Makes sure ONE agent's identity (name, description, …) is in this registry.
|
|
95
|
-
*
|
|
96
|
-
* Neither execution fetch (`agx_get_execution_minimal` / `_full`) carries the
|
|
97
|
-
* name, so an agent that no list fetch had loaded launched with a nameless
|
|
98
|
-
* record: every window titled it "Agent" and the empty hero lost its name.
|
|
99
|
-
* The name comes from the same place every name comes from — the ONE catalog —
|
|
100
|
-
* projected through `mergeAgentSummaries`. No-op when the name is present.
|
|
101
|
-
*/
|
|
102
|
-
export declare const ensureAgentIdentity: import("@reduxjs/toolkit").AsyncThunk<void, string, {
|
|
103
|
-
extra?: unknown;
|
|
104
|
-
rejectValue?: unknown;
|
|
105
|
-
serializedErrorType?: unknown;
|
|
106
|
-
pendingMeta?: unknown;
|
|
107
|
-
fulfilledMeta?: unknown;
|
|
108
|
-
rejectedMeta?: unknown;
|
|
109
|
-
dispatch: ChatDispatch;
|
|
110
|
-
state: ChatRootState;
|
|
111
|
-
}>;
|
|
112
|
-
/**
|
|
113
|
-
* THE FRESHNESS IS THE PACKAGE'S. `isChatListFresh` and its module-level
|
|
114
|
-
* timestamp are gone: the catalog owns the 15-minute TTL and the 4-hour
|
|
115
|
-
* tab-restore threshold, so there is exactly one answer to "is the list
|
|
116
|
-
* stale" on this platform.
|
|
117
|
-
*/
|
|
118
|
-
export declare function isChatListStale(): boolean;
|
|
119
|
-
/**
|
|
120
|
-
* Initializes the agent catalogue for the chat sidebar and hydrates this
|
|
121
|
-
* registry from it. Safe to call on every mount — the catalog's own TTL and
|
|
122
|
-
* shared in-flight promise collapse concurrent mounts to one read.
|
|
123
|
-
*
|
|
124
|
-
* Usage:
|
|
125
|
-
* dispatch(initializeChatAgents()) // skip if fresh
|
|
126
|
-
* dispatch(initializeChatAgents({ force: true })) // always re-read
|
|
127
|
-
*/
|
|
128
|
-
export declare const initializeChatAgents: import("@reduxjs/toolkit").AsyncThunk<void, void | {
|
|
129
|
-
force?: boolean;
|
|
130
|
-
}, {
|
|
131
|
-
extra?: unknown;
|
|
132
|
-
rejectValue?: unknown;
|
|
133
|
-
serializedErrorType?: unknown;
|
|
134
|
-
pendingMeta?: unknown;
|
|
135
|
-
fulfilledMeta?: unknown;
|
|
136
|
-
rejectedMeta?: unknown;
|
|
137
|
-
dispatch: ChatDispatch;
|
|
138
|
-
state: ChatRootState;
|
|
139
|
-
}>;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { createAsyncThunk } from "@reduxjs/toolkit";
|
|
2
|
-
import { getAgentCatalog } from "../../../host/ui-slots.js";
|
|
3
|
-
import { readFavoriteIds } from "../../../context/sources/scopes.js";
|
|
4
|
-
import {
|
|
5
|
-
mergePartialAgent,
|
|
6
|
-
setAgentFetchStatus,
|
|
7
|
-
setAgentsStatus,
|
|
8
|
-
setAgentsError
|
|
9
|
-
} from "./slice.js";
|
|
10
|
-
const REGISTRY_ACCESS_LEVELS = [
|
|
11
|
-
"owner",
|
|
12
|
-
"admin",
|
|
13
|
-
"editor",
|
|
14
|
-
"viewer",
|
|
15
|
-
"system"
|
|
16
|
-
];
|
|
17
|
-
function toRegistryAccessLevel(value) {
|
|
18
|
-
return REGISTRY_ACCESS_LEVELS.find(
|
|
19
|
-
(level) => level === value
|
|
20
|
-
) ?? null;
|
|
21
|
-
}
|
|
22
|
-
function mergeAgentSummaries(dispatch, rows) {
|
|
23
|
-
for (const row of rows) {
|
|
24
|
-
dispatch(
|
|
25
|
-
mergePartialAgent({
|
|
26
|
-
id: row.id,
|
|
27
|
-
name: row.name ?? void 0,
|
|
28
|
-
description: row.description,
|
|
29
|
-
category: row.category,
|
|
30
|
-
tags: row.tags,
|
|
31
|
-
agentType: row.agentType,
|
|
32
|
-
modelId: row.modelId,
|
|
33
|
-
isActive: row.isActive,
|
|
34
|
-
isArchived: row.isArchived,
|
|
35
|
-
// No `isFavorite`: the catalog row's column is retired — stars are
|
|
36
|
-
// overlaid from platform.user_entity_state by `overlayAgentFavorites`.
|
|
37
|
-
// The registry spells "absent" as `undefined` where the DB row spells
|
|
38
|
-
// it `null`. Five fields differ; this is the vocabulary translation
|
|
39
|
-
// at the seam, not a value change.
|
|
40
|
-
createdBy: row.createdBy ?? void 0,
|
|
41
|
-
organizationId: row.organizationId ?? void 0,
|
|
42
|
-
taskId: row.taskId,
|
|
43
|
-
sourceAgentId: row.sourceAgentId,
|
|
44
|
-
createdAt: row.createdAt ?? void 0,
|
|
45
|
-
updatedAt: row.updatedAt ?? void 0,
|
|
46
|
-
isVersion: false,
|
|
47
|
-
isOwner: row.isOwner,
|
|
48
|
-
// `access_level` is a DB-owned vocabulary the package deliberately
|
|
49
|
-
// leaves open (an unknown level renders as itself). This registry's
|
|
50
|
-
// field is a closed union, so an unrecognised level is stored as
|
|
51
|
-
// `null` — absent, never silently coerced into a wrong level.
|
|
52
|
-
accessLevel: toRegistryAccessLevel(row.accessLevel),
|
|
53
|
-
sharedByEmail: row.sharedByEmail ?? void 0,
|
|
54
|
-
// The class pin; a catalog read that lacks the column leaves it absent.
|
|
55
|
-
...row.offeringId === void 0 ? {} : { listOfferingPin: row.offeringId }
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
dispatch(setAgentFetchStatus({ id: row.id, status: "list" }));
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
async function overlayAgentFavorites(dispatch, ids) {
|
|
62
|
-
if (ids.length === 0) return;
|
|
63
|
-
const favorites = await readFavoriteIds("agent", ids);
|
|
64
|
-
if (!favorites) return;
|
|
65
|
-
for (const id of ids) {
|
|
66
|
-
dispatch(mergePartialAgent({ id, isFavorite: favorites.has(id) }));
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
const overlayAgentFavoritesThunk = createAsyncThunk("agentDefinition/overlayFavorites", async (ids, { dispatch }) => {
|
|
70
|
-
await overlayAgentFavorites(dispatch, ids);
|
|
71
|
-
});
|
|
72
|
-
const fetchAgentsList = createAsyncThunk(
|
|
73
|
-
"agentDefinition/fetchList",
|
|
74
|
-
async (_, { dispatch }) => {
|
|
75
|
-
dispatch(setAgentsStatus("loading"));
|
|
76
|
-
dispatch(setAgentsError(null));
|
|
77
|
-
const catalog = getAgentCatalog();
|
|
78
|
-
try {
|
|
79
|
-
await catalog.ensureLoaded();
|
|
80
|
-
} catch (e) {
|
|
81
|
-
dispatch(setAgentsError(e instanceof Error ? e.message : String(e)));
|
|
82
|
-
dispatch(setAgentsStatus("failed"));
|
|
83
|
-
throw e;
|
|
84
|
-
}
|
|
85
|
-
const rows = catalog.getState().rows;
|
|
86
|
-
mergeAgentSummaries(dispatch, rows);
|
|
87
|
-
await overlayAgentFavorites(
|
|
88
|
-
dispatch,
|
|
89
|
-
rows.map((r) => r.id)
|
|
90
|
-
);
|
|
91
|
-
dispatch(setAgentsStatus("succeeded"));
|
|
92
|
-
}
|
|
93
|
-
);
|
|
94
|
-
const searchAgentsServer = createAsyncThunk(
|
|
95
|
-
"agentDefinition/searchServer",
|
|
96
|
-
async ({ query, deep = false }, { dispatch }) => {
|
|
97
|
-
const q = query.trim();
|
|
98
|
-
if (!q) return { ids: [], deep, query: q };
|
|
99
|
-
const catalog = getAgentCatalog();
|
|
100
|
-
const ids = await catalog.searchServer(q, deep);
|
|
101
|
-
const state = catalog.getState();
|
|
102
|
-
const hits = ids.map((id) => state.byId[id]).filter((r) => !!r);
|
|
103
|
-
mergeAgentSummaries(dispatch, hits);
|
|
104
|
-
await overlayAgentFavorites(
|
|
105
|
-
dispatch,
|
|
106
|
-
hits.map((r) => r.id)
|
|
107
|
-
);
|
|
108
|
-
return { ids, deep, query: q };
|
|
109
|
-
}
|
|
110
|
-
);
|
|
111
|
-
const fetchAgentsListFull = createAsyncThunk(
|
|
112
|
-
"agentDefinition/fetchListFull",
|
|
113
|
-
async (_, { dispatch }) => {
|
|
114
|
-
const catalog = getAgentCatalog();
|
|
115
|
-
await catalog.ensureLoaded();
|
|
116
|
-
const rows = catalog.getState().rows;
|
|
117
|
-
mergeAgentSummaries(dispatch, rows);
|
|
118
|
-
await overlayAgentFavorites(
|
|
119
|
-
dispatch,
|
|
120
|
-
rows.map((r) => r.id)
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
);
|
|
124
|
-
const ensureAgentIdentity = createAsyncThunk(
|
|
125
|
-
"agentDefinition/ensureIdentity",
|
|
126
|
-
async (agentId, { dispatch, getState }) => {
|
|
127
|
-
if (getState().agentDefinition.agents?.[agentId]?.name) return;
|
|
128
|
-
const catalog = getAgentCatalog();
|
|
129
|
-
let row = catalog.getState().byId[agentId];
|
|
130
|
-
if (!row) {
|
|
131
|
-
await catalog.ensureLoaded();
|
|
132
|
-
row = catalog.getState().byId[agentId];
|
|
133
|
-
}
|
|
134
|
-
if (row) {
|
|
135
|
-
mergeAgentSummaries(dispatch, [row]);
|
|
136
|
-
await overlayAgentFavorites(dispatch, [row.id]);
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
);
|
|
140
|
-
function isChatListStale() {
|
|
141
|
-
return getAgentCatalog().isStale();
|
|
142
|
-
}
|
|
143
|
-
const initializeChatAgents = createAsyncThunk("agentDefinition/initializeChatAgents", async (arg, { dispatch }) => {
|
|
144
|
-
const force = arg?.force ?? false;
|
|
145
|
-
const catalog = getAgentCatalog();
|
|
146
|
-
await catalog.ensureLoaded(force ? { force: true } : void 0);
|
|
147
|
-
mergeAgentSummaries(dispatch, catalog.getState().rows);
|
|
148
|
-
});
|
|
149
|
-
export {
|
|
150
|
-
ensureAgentIdentity,
|
|
151
|
-
fetchAgentsList,
|
|
152
|
-
fetchAgentsListFull,
|
|
153
|
-
initializeChatAgents,
|
|
154
|
-
isChatListStale,
|
|
155
|
-
overlayAgentFavoritesThunk,
|
|
156
|
-
searchAgentsServer
|
|
157
|
-
};
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
import { useEffect } from "react";
|
|
3
|
-
import { useAppDispatch } from "../../store/hooks.js";
|
|
4
|
-
import {
|
|
5
|
-
mergePartialAgent,
|
|
6
|
-
setAgentFetchStatus,
|
|
7
|
-
setAgentsStatus
|
|
8
|
-
} from "../redux/agent-definition/slice.js";
|
|
9
|
-
import { overlayAgentFavoritesThunk } from "../redux/agent-definition/thunks.js";
|
|
10
|
-
function AgentListHydrator({ seeds }) {
|
|
11
|
-
const dispatch = useAppDispatch();
|
|
12
|
-
useEffect(() => {
|
|
13
|
-
for (const row of seeds) {
|
|
14
|
-
dispatch(
|
|
15
|
-
mergePartialAgent({
|
|
16
|
-
id: row.id,
|
|
17
|
-
name: row.name,
|
|
18
|
-
description: row.description,
|
|
19
|
-
category: row.category,
|
|
20
|
-
tags: row.tags ?? [],
|
|
21
|
-
agentType: row.agent_type,
|
|
22
|
-
modelId: row.model_id,
|
|
23
|
-
isActive: row.is_active,
|
|
24
|
-
isArchived: row.is_archived,
|
|
25
|
-
// No `isFavorite` from the seed: the retired column. Stars are
|
|
26
|
-
// overlaid from platform.user_entity_state just below.
|
|
27
|
-
createdBy: row.created_by,
|
|
28
|
-
organizationId: row.organization_id,
|
|
29
|
-
taskId: row.task_id ?? null,
|
|
30
|
-
sourceAgentId: row.source_agent_id,
|
|
31
|
-
createdAt: row.created_at,
|
|
32
|
-
updatedAt: row.updated_at,
|
|
33
|
-
isVersion: false,
|
|
34
|
-
isOwner: row.is_owner,
|
|
35
|
-
accessLevel: row.access_level,
|
|
36
|
-
sharedByEmail: row.shared_by_email,
|
|
37
|
-
listOfferingPin: row.offering_id
|
|
38
|
-
})
|
|
39
|
-
);
|
|
40
|
-
dispatch(setAgentFetchStatus({ id: row.id, status: "list" }));
|
|
41
|
-
}
|
|
42
|
-
dispatch(setAgentsStatus("succeeded"));
|
|
43
|
-
void dispatch(overlayAgentFavoritesThunk(seeds.map((row) => row.id)));
|
|
44
|
-
}, []);
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
export {
|
|
48
|
-
AgentListHydrator
|
|
49
|
-
};
|