@assistant-ui/react-mcp 0.1.16 → 0.1.18
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/dist/auth/createOAuthProvider.d.ts +13 -2
- package/dist/auth/createOAuthProvider.d.ts.map +1 -1
- package/dist/auth/createOAuthProvider.js +109 -31
- package/dist/auth/createOAuthProvider.js.map +1 -1
- package/dist/auth/types.d.ts +5 -1
- package/dist/auth/types.d.ts.map +1 -1
- package/dist/primitives/addForm/McpAddFormAuthFields.js +71 -28
- package/dist/primitives/addForm/McpAddFormAuthFields.js.map +1 -1
- package/dist/primitives/addForm/McpAddFormError.d.ts.map +1 -1
- package/dist/primitives/addForm/McpAddFormError.js +30 -10
- package/dist/primitives/addForm/McpAddFormError.js.map +1 -1
- package/dist/primitives/addForm/McpAddFormNameField.js +31 -18
- package/dist/primitives/addForm/McpAddFormNameField.js.map +1 -1
- package/dist/primitives/addForm/McpAddFormRoot.d.ts.map +1 -1
- package/dist/primitives/addForm/McpAddFormRoot.js +32 -11
- package/dist/primitives/addForm/McpAddFormRoot.js.map +1 -1
- package/dist/primitives/addForm/McpAddFormUrlField.js +31 -18
- package/dist/primitives/addForm/McpAddFormUrlField.js.map +1 -1
- package/dist/primitives/addForm/context.d.ts +9 -1
- package/dist/primitives/addForm/context.d.ts.map +1 -1
- package/dist/primitives/addForm/context.js.map +1 -1
- package/dist/resources/McpManagerResource.d.ts.map +1 -1
- package/dist/resources/McpManagerResource.js +330 -247
- package/dist/resources/McpManagerResource.js.map +1 -1
- package/dist/resources/McpServerRemovalFence.d.ts +7 -0
- package/dist/resources/McpServerRemovalFence.d.ts.map +1 -0
- package/dist/resources/McpServerRemovalFence.js +11 -0
- package/dist/resources/McpServerRemovalFence.js.map +1 -0
- package/dist/resources/McpServerResource.d.ts.map +1 -1
- package/dist/resources/McpServerResource.js +41 -16
- package/dist/resources/McpServerResource.js.map +1 -1
- package/dist/resources/storage/McpLocalStorage.d.ts.map +1 -1
- package/dist/resources/storage/McpLocalStorage.js +16 -1
- package/dist/resources/storage/McpLocalStorage.js.map +1 -1
- package/dist/resources/storage/types.d.ts +10 -8
- package/dist/resources/storage/types.d.ts.map +1 -1
- package/dist/utils/serverUrl.d.ts +8 -0
- package/dist/utils/serverUrl.d.ts.map +1 -0
- package/dist/utils/serverUrl.js +15 -0
- package/dist/utils/serverUrl.js.map +1 -0
- package/package.json +7 -7
- package/src/auth/createOAuthProvider.test.ts +544 -35
- package/src/auth/createOAuthProvider.ts +201 -46
- package/src/auth/types.ts +5 -1
- package/src/primitives/addForm/McpAddFormAccessibility.test.tsx +261 -0
- package/src/primitives/addForm/McpAddFormAuthFields.tsx +33 -15
- package/src/primitives/addForm/McpAddFormError.tsx +17 -3
- package/src/primitives/addForm/McpAddFormNameField.tsx +13 -1
- package/src/primitives/addForm/McpAddFormRoot.tsx +51 -8
- package/src/primitives/addForm/McpAddFormUrlField.tsx +12 -1
- package/src/primitives/addForm/context.tsx +10 -0
- package/src/resources/McpManagerResource.test.ts +712 -9
- package/src/resources/McpManagerResource.ts +208 -56
- package/src/resources/McpServerRemovalFence.ts +21 -0
- package/src/resources/McpServerResource.test.ts +252 -17
- package/src/resources/McpServerResource.ts +40 -15
- package/src/resources/storage/McpLocalStorage.test.ts +28 -0
- package/src/resources/storage/McpLocalStorage.ts +23 -1
- package/src/resources/storage/types.ts +10 -8
- package/src/utils/serverUrl.test.ts +66 -0
- package/src/utils/serverUrl.ts +23 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { assertUniqueServerIds } from "../utils/serverId.js";
|
|
2
2
|
import { createMcpId } from "../utils/createMcpId.js";
|
|
3
3
|
import { clearOAuthProviderAuthState } from "../auth/createOAuthProvider.js";
|
|
4
|
+
import { withMcpServerRemovalFence } from "./McpServerRemovalFence.js";
|
|
4
5
|
import { McpServerResource } from "./McpServerResource.js";
|
|
5
6
|
import { McpLocalStorage } from "./storage/McpLocalStorage.js";
|
|
6
7
|
import { attachTransformScopes, useAssistantClientRef, useClientLookup } from "@assistant-ui/store";
|
|
@@ -18,6 +19,9 @@ const NO_CONNECTORS = [];
|
|
|
18
19
|
const reportCustomStorageFailure = (operation, error) => {
|
|
19
20
|
console.error(`[assistant-ui/react-mcp] failed to ${operation} custom servers:`, error);
|
|
20
21
|
};
|
|
22
|
+
const reportBlockedCustomServerPersistence = () => {
|
|
23
|
+
console.error("[assistant-ui/react-mcp] custom server changes remain in memory because loading the persisted list failed; remount the manager to retry");
|
|
24
|
+
};
|
|
21
25
|
const persistCustomServers = async (storage, records) => {
|
|
22
26
|
try {
|
|
23
27
|
await storage.saveCustomServers(records);
|
|
@@ -25,126 +29,183 @@ const persistCustomServers = async (storage, records) => {
|
|
|
25
29
|
reportCustomStorageFailure("save", error);
|
|
26
30
|
}
|
|
27
31
|
};
|
|
28
|
-
const
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
|
|
32
|
+
const enqueueCustomServerTask = (persistenceQueues, scopeKey, task) => {
|
|
33
|
+
const next = (persistenceQueues.get(scopeKey) ?? Promise.resolve()).then(task);
|
|
34
|
+
persistenceQueues.set(scopeKey, next);
|
|
35
|
+
next.then(() => {
|
|
36
|
+
if (persistenceQueues.get(scopeKey) === next) persistenceQueues.delete(scopeKey);
|
|
37
|
+
});
|
|
38
|
+
};
|
|
39
|
+
const enqueueCustomServerPersistence = (persistenceQueues, scopeKey, storage, records) => enqueueCustomServerTask(persistenceQueues, scopeKey, () => persistCustomServers(storage, records));
|
|
40
|
+
const holdCustomServerPersistence = (persistenceQueues, scopeKey) => {
|
|
41
|
+
let release = () => {};
|
|
42
|
+
const gate = new Promise((resolve) => {
|
|
43
|
+
release = resolve;
|
|
44
|
+
});
|
|
45
|
+
enqueueCustomServerTask(persistenceQueues, scopeKey, () => gate);
|
|
46
|
+
return release;
|
|
47
|
+
};
|
|
48
|
+
const useMcpCustomServersResource = (t0) => {
|
|
49
|
+
const $ = c(17);
|
|
50
|
+
const { storage, scopeKey, persistenceQueues } = t0;
|
|
40
51
|
let t1;
|
|
41
|
-
if ($[
|
|
42
|
-
t1 =
|
|
43
|
-
$[
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
const
|
|
52
|
+
if ($[0] === Symbol.for("react.memo_cache_sentinel")) {
|
|
53
|
+
t1 = [];
|
|
54
|
+
$[0] = t1;
|
|
55
|
+
} else t1 = $[0];
|
|
56
|
+
const [customServers, setCustomServers] = useState(t1);
|
|
57
|
+
const [isHydrated, setIsHydrated] = useState(false);
|
|
47
58
|
let t2;
|
|
48
|
-
if ($[
|
|
59
|
+
if ($[1] === Symbol.for("react.memo_cache_sentinel")) {
|
|
49
60
|
t2 = [];
|
|
50
|
-
$[
|
|
51
|
-
} else t2 = $[
|
|
52
|
-
const
|
|
53
|
-
const
|
|
54
|
-
const
|
|
55
|
-
const
|
|
61
|
+
$[1] = t2;
|
|
62
|
+
} else t2 = $[1];
|
|
63
|
+
const customServersRef = useRef(t2);
|
|
64
|
+
const hydrationStateRef = useRef("pending");
|
|
65
|
+
const hasPendingMutationRef = useRef(false);
|
|
66
|
+
const reportedBlockedPersistenceRef = useRef(false);
|
|
56
67
|
let t3;
|
|
57
|
-
if ($[
|
|
58
|
-
t3 =
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
storageRef.current = storage;
|
|
67
|
-
};
|
|
68
|
-
t5 = [storage];
|
|
69
|
-
$[6] = storage;
|
|
70
|
-
$[7] = t4;
|
|
71
|
-
$[8] = t5;
|
|
72
|
-
} else {
|
|
73
|
-
t4 = $[7];
|
|
74
|
-
t5 = $[8];
|
|
75
|
-
}
|
|
76
|
-
useEffect(t4, t5);
|
|
77
|
-
let t6;
|
|
78
|
-
if ($[9] !== storage) {
|
|
79
|
-
t6 = async (signal) => {
|
|
80
|
-
const markHydrated = () => {
|
|
81
|
-
if (!signal.cancelled) {
|
|
82
|
-
hydratedRef.current = true;
|
|
83
|
-
setIsHydrated(true);
|
|
84
|
-
}
|
|
85
|
-
};
|
|
68
|
+
if ($[2] !== persistenceQueues || $[3] !== scopeKey || $[4] !== storage) {
|
|
69
|
+
t3 = async (signal) => {
|
|
70
|
+
while (true) {
|
|
71
|
+
const pendingPersistence = persistenceQueues.get(scopeKey);
|
|
72
|
+
if (!pendingPersistence) break;
|
|
73
|
+
await pendingPersistence;
|
|
74
|
+
if (signal.cancelled) return;
|
|
75
|
+
if (persistenceQueues.get(scopeKey) === pendingPersistence) break;
|
|
76
|
+
}
|
|
86
77
|
let records;
|
|
87
78
|
try {
|
|
88
79
|
records = await storage.loadCustomServers();
|
|
89
|
-
} catch (
|
|
90
|
-
const error =
|
|
91
|
-
if (!signal.cancelled)
|
|
92
|
-
|
|
80
|
+
} catch (t4) {
|
|
81
|
+
const error = t4;
|
|
82
|
+
if (!signal.cancelled) {
|
|
83
|
+
reportCustomStorageFailure("load", error);
|
|
84
|
+
hydrationStateRef.current = "failed";
|
|
85
|
+
if (hasPendingMutationRef.current) {
|
|
86
|
+
reportBlockedCustomServerPersistence();
|
|
87
|
+
reportedBlockedPersistenceRef.current = true;
|
|
88
|
+
}
|
|
89
|
+
setIsHydrated(true);
|
|
90
|
+
}
|
|
93
91
|
return;
|
|
94
92
|
}
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const hadPendingMutation = hasPendingMutationRef.current;
|
|
94
|
+
const mergedRecords = (() => {
|
|
95
|
+
const prev = customServersRef.current;
|
|
97
96
|
if (prev.length === 0) return records;
|
|
98
97
|
const persistedIds = new Set(records.map(_temp));
|
|
99
98
|
return [...records, ...prev.filter((r_0) => !persistedIds.has(r_0.id))];
|
|
100
|
-
});
|
|
101
|
-
|
|
99
|
+
})();
|
|
100
|
+
customServersRef.current = mergedRecords;
|
|
101
|
+
hydrationStateRef.current = "succeeded";
|
|
102
|
+
hasPendingMutationRef.current = false;
|
|
103
|
+
if (hadPendingMutation) enqueueCustomServerPersistence(persistenceQueues, scopeKey, storage, mergedRecords);
|
|
104
|
+
if (signal.cancelled) return;
|
|
105
|
+
setCustomServers(mergedRecords);
|
|
106
|
+
setIsHydrated(true);
|
|
102
107
|
};
|
|
103
|
-
$[
|
|
104
|
-
$[
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
$[2] = persistenceQueues;
|
|
109
|
+
$[3] = scopeKey;
|
|
110
|
+
$[4] = storage;
|
|
111
|
+
$[5] = t3;
|
|
112
|
+
} else t3 = $[5];
|
|
113
|
+
const hydrate = useEffectEvent(t3);
|
|
114
|
+
let t4;
|
|
115
|
+
if ($[6] !== hydrate) {
|
|
116
|
+
t4 = () => {
|
|
110
117
|
const signal_0 = { cancelled: false };
|
|
111
118
|
hydrate(signal_0);
|
|
112
119
|
return () => {
|
|
113
120
|
signal_0.cancelled = true;
|
|
114
121
|
};
|
|
115
122
|
};
|
|
116
|
-
$[
|
|
117
|
-
$[
|
|
118
|
-
} else
|
|
119
|
-
let
|
|
120
|
-
if ($[
|
|
121
|
-
|
|
122
|
-
$[
|
|
123
|
-
} else
|
|
124
|
-
useEffect(
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
123
|
+
$[6] = hydrate;
|
|
124
|
+
$[7] = t4;
|
|
125
|
+
} else t4 = $[7];
|
|
126
|
+
let t5;
|
|
127
|
+
if ($[8] === Symbol.for("react.memo_cache_sentinel")) {
|
|
128
|
+
t5 = [];
|
|
129
|
+
$[8] = t5;
|
|
130
|
+
} else t5 = $[8];
|
|
131
|
+
useEffect(t4, t5);
|
|
132
|
+
let t6;
|
|
133
|
+
if ($[9] !== persistenceQueues || $[10] !== scopeKey || $[11] !== storage) {
|
|
134
|
+
t6 = (updater) => {
|
|
135
|
+
const next = updater(customServersRef.current);
|
|
136
|
+
customServersRef.current = next;
|
|
137
|
+
setCustomServers(next);
|
|
138
|
+
if (hydrationStateRef.current === "succeeded") {
|
|
139
|
+
enqueueCustomServerPersistence(persistenceQueues, scopeKey, storage, next);
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
hasPendingMutationRef.current = true;
|
|
143
|
+
if (hydrationStateRef.current === "failed" && !reportedBlockedPersistenceRef.current) {
|
|
144
|
+
reportBlockedCustomServerPersistence();
|
|
145
|
+
reportedBlockedPersistenceRef.current = true;
|
|
146
|
+
}
|
|
132
147
|
};
|
|
133
|
-
|
|
134
|
-
$[
|
|
135
|
-
$[
|
|
136
|
-
$[
|
|
137
|
-
} else
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
+
$[9] = persistenceQueues;
|
|
149
|
+
$[10] = scopeKey;
|
|
150
|
+
$[11] = storage;
|
|
151
|
+
$[12] = t6;
|
|
152
|
+
} else t6 = $[12];
|
|
153
|
+
const updateCustomServers = t6;
|
|
154
|
+
let t7;
|
|
155
|
+
if ($[13] !== customServers || $[14] !== isHydrated || $[15] !== updateCustomServers) {
|
|
156
|
+
t7 = {
|
|
157
|
+
customServers,
|
|
158
|
+
isHydrated,
|
|
159
|
+
updateCustomServers
|
|
160
|
+
};
|
|
161
|
+
$[13] = customServers;
|
|
162
|
+
$[14] = isHydrated;
|
|
163
|
+
$[15] = updateCustomServers;
|
|
164
|
+
$[16] = t7;
|
|
165
|
+
} else t7 = $[16];
|
|
166
|
+
return t7;
|
|
167
|
+
};
|
|
168
|
+
const McpCustomServersResource = resource(useMcpCustomServersResource);
|
|
169
|
+
const useMcpManagerResource = (props) => {
|
|
170
|
+
const $ = c(75);
|
|
171
|
+
const connectors = props.connectors ?? NO_CONNECTORS;
|
|
172
|
+
const autoConnect = props.autoConnect ?? true;
|
|
173
|
+
let t0;
|
|
174
|
+
if ($[0] !== props.oauthRedirectUri) {
|
|
175
|
+
t0 = props.oauthRedirectUri ?? defaultRedirectUri();
|
|
176
|
+
$[0] = props.oauthRedirectUri;
|
|
177
|
+
$[1] = t0;
|
|
178
|
+
} else t0 = $[1];
|
|
179
|
+
const redirectUri = t0;
|
|
180
|
+
const connectionTimeout = props.connectionTimeout;
|
|
181
|
+
let t1;
|
|
182
|
+
if ($[2] !== props.storage) {
|
|
183
|
+
t1 = props.storage ?? McpLocalStorage();
|
|
184
|
+
$[2] = props.storage;
|
|
185
|
+
$[3] = t1;
|
|
186
|
+
} else t1 = $[3];
|
|
187
|
+
const storage = useResource(t1);
|
|
188
|
+
const [persistenceQueues] = useState(_temp2);
|
|
189
|
+
const storageScopeKey = storage.scopeId === void 0 ? "unscoped" : `scoped:${storage.scopeId}`;
|
|
190
|
+
let t2;
|
|
191
|
+
if ($[4] !== persistenceQueues || $[5] !== storage || $[6] !== storageScopeKey) {
|
|
192
|
+
t2 = withKey(storageScopeKey, McpCustomServersResource({
|
|
193
|
+
storage,
|
|
194
|
+
scopeKey: storageScopeKey,
|
|
195
|
+
persistenceQueues
|
|
196
|
+
}));
|
|
197
|
+
$[4] = persistenceQueues;
|
|
198
|
+
$[5] = storage;
|
|
199
|
+
$[6] = storageScopeKey;
|
|
200
|
+
$[7] = t2;
|
|
201
|
+
} else t2 = $[7];
|
|
202
|
+
const { customServers, isHydrated, updateCustomServers } = useResource(t2);
|
|
203
|
+
assertUniqueServerIds([...connectors.map(_temp3), ...customServers.map(_temp4)]);
|
|
204
|
+
let t3;
|
|
205
|
+
if ($[8] !== autoConnect || $[9] !== connectionTimeout || $[10] !== connectors || $[11] !== customServers || $[12] !== persistenceQueues || $[13] !== redirectUri || $[14] !== storage || $[15] !== storageScopeKey || $[16] !== updateCustomServers) {
|
|
206
|
+
let t4;
|
|
207
|
+
if ($[18] !== autoConnect || $[19] !== connectionTimeout || $[20] !== redirectUri || $[21] !== storage) {
|
|
208
|
+
t4 = (c_0) => withKey(c_0.id, McpServerResource({
|
|
148
209
|
id: c_0.id,
|
|
149
210
|
kind: "connector",
|
|
150
211
|
name: c_0.name,
|
|
@@ -157,18 +218,18 @@ const useMcpManagerResource = (props) => {
|
|
|
157
218
|
connectionTimeout: c_0.connectionTimeout ?? connectionTimeout,
|
|
158
219
|
...c_0.cache !== void 0 ? { cache: c_0.cache } : {},
|
|
159
220
|
...c_0.elicitation !== void 0 ? { elicitation: c_0.elicitation } : {},
|
|
160
|
-
onRemove:
|
|
221
|
+
onRemove: _temp5
|
|
161
222
|
}));
|
|
162
|
-
$[
|
|
163
|
-
$[
|
|
164
|
-
$[
|
|
165
|
-
$[
|
|
166
|
-
$[
|
|
167
|
-
} else
|
|
168
|
-
const connectorElements = connectors.map(
|
|
169
|
-
let
|
|
170
|
-
if ($[
|
|
171
|
-
|
|
223
|
+
$[18] = autoConnect;
|
|
224
|
+
$[19] = connectionTimeout;
|
|
225
|
+
$[20] = redirectUri;
|
|
226
|
+
$[21] = storage;
|
|
227
|
+
$[22] = t4;
|
|
228
|
+
} else t4 = $[22];
|
|
229
|
+
const connectorElements = connectors.map(t4);
|
|
230
|
+
let t5;
|
|
231
|
+
if ($[23] !== autoConnect || $[24] !== connectionTimeout || $[25] !== persistenceQueues || $[26] !== redirectUri || $[27] !== storage || $[28] !== storageScopeKey || $[29] !== updateCustomServers) {
|
|
232
|
+
t5 = (s_0) => withKey(s_0.id, McpServerResource(withMcpServerRemovalFence({
|
|
172
233
|
id: s_0.id,
|
|
173
234
|
kind: "custom",
|
|
174
235
|
name: s_0.name,
|
|
@@ -181,56 +242,62 @@ const useMcpManagerResource = (props) => {
|
|
|
181
242
|
...s_0.cache !== void 0 ? { cache: s_0.cache } : {},
|
|
182
243
|
...s_0.elicitation !== void 0 ? { elicitation: s_0.elicitation } : {},
|
|
183
244
|
onRemove: async () => {
|
|
184
|
-
|
|
245
|
+
updateCustomServers((prev) => prev.filter((record) => record.id !== s_0.id));
|
|
185
246
|
}
|
|
186
|
-
}));
|
|
187
|
-
$[
|
|
188
|
-
$[
|
|
189
|
-
$[
|
|
190
|
-
$[
|
|
191
|
-
$[
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
$[
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
$[
|
|
199
|
-
$[
|
|
200
|
-
$[
|
|
201
|
-
$[
|
|
202
|
-
|
|
203
|
-
|
|
247
|
+
}, () => holdCustomServerPersistence(persistenceQueues, storageScopeKey))));
|
|
248
|
+
$[23] = autoConnect;
|
|
249
|
+
$[24] = connectionTimeout;
|
|
250
|
+
$[25] = persistenceQueues;
|
|
251
|
+
$[26] = redirectUri;
|
|
252
|
+
$[27] = storage;
|
|
253
|
+
$[28] = storageScopeKey;
|
|
254
|
+
$[29] = updateCustomServers;
|
|
255
|
+
$[30] = t5;
|
|
256
|
+
} else t5 = $[30];
|
|
257
|
+
const customElements = customServers.map(t5);
|
|
258
|
+
t3 = [...connectorElements, ...customElements];
|
|
259
|
+
$[8] = autoConnect;
|
|
260
|
+
$[9] = connectionTimeout;
|
|
261
|
+
$[10] = connectors;
|
|
262
|
+
$[11] = customServers;
|
|
263
|
+
$[12] = persistenceQueues;
|
|
264
|
+
$[13] = redirectUri;
|
|
265
|
+
$[14] = storage;
|
|
266
|
+
$[15] = storageScopeKey;
|
|
267
|
+
$[16] = updateCustomServers;
|
|
268
|
+
$[17] = t3;
|
|
269
|
+
} else t3 = $[17];
|
|
270
|
+
const lookup = useClientLookup(t3);
|
|
204
271
|
const all = lookup.state;
|
|
205
|
-
let
|
|
206
|
-
if ($[
|
|
207
|
-
|
|
208
|
-
$[
|
|
209
|
-
$[
|
|
210
|
-
} else
|
|
211
|
-
let
|
|
212
|
-
if ($[
|
|
213
|
-
|
|
214
|
-
$[
|
|
215
|
-
$[
|
|
216
|
-
} else
|
|
217
|
-
let
|
|
218
|
-
if ($[
|
|
219
|
-
|
|
272
|
+
let t4;
|
|
273
|
+
if ($[31] !== all) {
|
|
274
|
+
t4 = all.filter(_temp6);
|
|
275
|
+
$[31] = all;
|
|
276
|
+
$[32] = t4;
|
|
277
|
+
} else t4 = $[32];
|
|
278
|
+
let t5;
|
|
279
|
+
if ($[33] !== all) {
|
|
280
|
+
t5 = all.filter(_temp7);
|
|
281
|
+
$[33] = all;
|
|
282
|
+
$[34] = t5;
|
|
283
|
+
} else t5 = $[34];
|
|
284
|
+
let t6;
|
|
285
|
+
if ($[35] !== all || $[36] !== isHydrated || $[37] !== t4 || $[38] !== t5) {
|
|
286
|
+
t6 = {
|
|
220
287
|
servers: all,
|
|
221
|
-
connectors:
|
|
222
|
-
customServers:
|
|
288
|
+
connectors: t4,
|
|
289
|
+
customServers: t5,
|
|
223
290
|
isHydrated
|
|
224
291
|
};
|
|
225
|
-
$[
|
|
226
|
-
$[
|
|
227
|
-
$[
|
|
228
|
-
$[
|
|
229
|
-
$[
|
|
230
|
-
} else
|
|
231
|
-
const state =
|
|
292
|
+
$[35] = all;
|
|
293
|
+
$[36] = isHydrated;
|
|
294
|
+
$[37] = t4;
|
|
295
|
+
$[38] = t5;
|
|
296
|
+
$[39] = t6;
|
|
297
|
+
} else t6 = $[39];
|
|
298
|
+
const state = t6;
|
|
232
299
|
let out;
|
|
233
|
-
if ($[
|
|
300
|
+
if ($[40] !== lookup || $[41] !== state.servers) {
|
|
234
301
|
out = {};
|
|
235
302
|
for (const server of state.servers) {
|
|
236
303
|
if (server.connectionState !== "connected") continue;
|
|
@@ -244,82 +311,82 @@ const useMcpManagerResource = (props) => {
|
|
|
244
311
|
};
|
|
245
312
|
}
|
|
246
313
|
}
|
|
247
|
-
$[
|
|
248
|
-
$[
|
|
249
|
-
$[
|
|
250
|
-
} else out = $[
|
|
314
|
+
$[40] = lookup;
|
|
315
|
+
$[41] = state.servers;
|
|
316
|
+
$[42] = out;
|
|
317
|
+
} else out = $[42];
|
|
251
318
|
const toolkit = out;
|
|
252
319
|
const clientRef = useAssistantClientRef();
|
|
253
|
-
let
|
|
254
|
-
if ($[
|
|
255
|
-
|
|
320
|
+
let t7;
|
|
321
|
+
if ($[43] !== clientRef || $[44] !== toolkit) {
|
|
322
|
+
t7 = () => {
|
|
256
323
|
const client = clientRef.current;
|
|
257
324
|
if (!client) return;
|
|
258
325
|
return client.modelContext.register({ getModelContext: () => ({ tools: toolkit }) });
|
|
259
326
|
};
|
|
260
|
-
$[
|
|
261
|
-
$[
|
|
262
|
-
$[
|
|
263
|
-
} else
|
|
264
|
-
let
|
|
265
|
-
if ($[
|
|
266
|
-
|
|
267
|
-
$[
|
|
268
|
-
$[
|
|
269
|
-
} else
|
|
270
|
-
useAssistantScopeEffect("modelContext",
|
|
271
|
-
let
|
|
272
|
-
if ($[
|
|
273
|
-
|
|
327
|
+
$[43] = clientRef;
|
|
328
|
+
$[44] = toolkit;
|
|
329
|
+
$[45] = t7;
|
|
330
|
+
} else t7 = $[45];
|
|
331
|
+
let t8;
|
|
332
|
+
if ($[46] !== toolkit) {
|
|
333
|
+
t8 = [toolkit];
|
|
334
|
+
$[46] = toolkit;
|
|
335
|
+
$[47] = t8;
|
|
336
|
+
} else t8 = $[47];
|
|
337
|
+
useAssistantScopeEffect("modelContext", t7, t8);
|
|
338
|
+
let t9;
|
|
339
|
+
if ($[48] !== lookup || $[49] !== state) {
|
|
340
|
+
t9 = (kind, index) => {
|
|
274
341
|
const list = kind === "connector" ? state.connectors : state.customServers;
|
|
275
342
|
const entry = list[index];
|
|
276
343
|
if (!entry) throw new Error(`McpManagerResource: no ${kind} at index ${index} (length ${list.length})`);
|
|
277
344
|
return lookup.get({ key: entry.id });
|
|
278
345
|
};
|
|
279
|
-
$[
|
|
280
|
-
$[
|
|
281
|
-
$[
|
|
282
|
-
} else
|
|
283
|
-
const serverByKind =
|
|
284
|
-
let
|
|
285
|
-
if ($[
|
|
286
|
-
|
|
287
|
-
$[
|
|
288
|
-
$[
|
|
289
|
-
} else
|
|
290
|
-
let
|
|
291
|
-
if ($[
|
|
292
|
-
|
|
346
|
+
$[48] = lookup;
|
|
347
|
+
$[49] = state;
|
|
348
|
+
$[50] = t9;
|
|
349
|
+
} else t9 = $[50];
|
|
350
|
+
const serverByKind = t9;
|
|
351
|
+
let t10;
|
|
352
|
+
if ($[51] !== state) {
|
|
353
|
+
t10 = () => state;
|
|
354
|
+
$[51] = state;
|
|
355
|
+
$[52] = t10;
|
|
356
|
+
} else t10 = $[52];
|
|
357
|
+
let t11;
|
|
358
|
+
if ($[53] !== lookup || $[54] !== serverByKind) {
|
|
359
|
+
t11 = (query) => {
|
|
293
360
|
if ("id" in query) return lookup.get({ key: query.id });
|
|
294
361
|
return serverByKind(query.kind, query.index);
|
|
295
362
|
};
|
|
296
|
-
$[
|
|
297
|
-
$[
|
|
298
|
-
$[
|
|
299
|
-
} else
|
|
300
|
-
let
|
|
301
|
-
let
|
|
302
|
-
if ($[
|
|
303
|
-
|
|
304
|
-
const { index: index_0 } =
|
|
363
|
+
$[53] = lookup;
|
|
364
|
+
$[54] = serverByKind;
|
|
365
|
+
$[55] = t11;
|
|
366
|
+
} else t11 = $[55];
|
|
367
|
+
let t12;
|
|
368
|
+
let t13;
|
|
369
|
+
if ($[56] !== serverByKind) {
|
|
370
|
+
t12 = (t14) => {
|
|
371
|
+
const { index: index_0 } = t14;
|
|
305
372
|
return serverByKind("connector", index_0);
|
|
306
373
|
};
|
|
307
|
-
|
|
308
|
-
const { index: index_1 } =
|
|
374
|
+
t13 = (t15) => {
|
|
375
|
+
const { index: index_1 } = t15;
|
|
309
376
|
return serverByKind("custom", index_1);
|
|
310
377
|
};
|
|
311
|
-
$[
|
|
312
|
-
$[
|
|
313
|
-
$[
|
|
378
|
+
$[56] = serverByKind;
|
|
379
|
+
$[57] = t12;
|
|
380
|
+
$[58] = t13;
|
|
314
381
|
} else {
|
|
315
|
-
|
|
316
|
-
|
|
382
|
+
t12 = $[57];
|
|
383
|
+
t13 = $[58];
|
|
317
384
|
}
|
|
318
|
-
let
|
|
319
|
-
if ($[
|
|
320
|
-
|
|
321
|
-
const { name, url, auth, connectionTimeout: connectionTimeout_0, cache, elicitation } =
|
|
322
|
-
const
|
|
385
|
+
let t14;
|
|
386
|
+
if ($[59] !== updateCustomServers) {
|
|
387
|
+
t14 = async (t15) => {
|
|
388
|
+
const { name, url, auth, connectionTimeout: connectionTimeout_0, cache, elicitation } = t15;
|
|
389
|
+
const record_0 = {
|
|
323
390
|
id: createMcpId(),
|
|
324
391
|
name,
|
|
325
392
|
url,
|
|
@@ -329,45 +396,58 @@ const useMcpManagerResource = (props) => {
|
|
|
329
396
|
...elicitation !== void 0 ? { elicitation } : {},
|
|
330
397
|
createdAt: Date.now()
|
|
331
398
|
};
|
|
332
|
-
|
|
333
|
-
return
|
|
399
|
+
updateCustomServers((prev_0) => [...prev_0, record_0]);
|
|
400
|
+
return record_0.id;
|
|
334
401
|
};
|
|
335
|
-
$[
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
402
|
+
$[59] = updateCustomServers;
|
|
403
|
+
$[60] = t14;
|
|
404
|
+
} else t14 = $[60];
|
|
405
|
+
let t15;
|
|
406
|
+
if ($[61] !== lookup || $[62] !== persistenceQueues || $[63] !== state || $[64] !== storage || $[65] !== storageScopeKey || $[66] !== updateCustomServers) {
|
|
407
|
+
t15 = async (id) => {
|
|
340
408
|
if (state.connectors.some((c_1) => c_1.id === id)) throw new Error(`Cannot remove connector "${id}" — connectors are app-defined and not removable. Use a custom server id instead.`);
|
|
341
409
|
try {
|
|
342
410
|
await lookup.get({ key: id }).remove();
|
|
343
411
|
} catch {
|
|
344
|
-
|
|
345
|
-
|
|
412
|
+
const releasePersistence = holdCustomServerPersistence(persistenceQueues, storageScopeKey);
|
|
413
|
+
try {
|
|
414
|
+
await clearOAuthProviderAuthState(storage, id);
|
|
415
|
+
updateCustomServers((prev_1) => prev_1.filter((record_1) => record_1.id !== id));
|
|
416
|
+
} catch (t16) {
|
|
417
|
+
const error = t16;
|
|
418
|
+
releasePersistence();
|
|
419
|
+
throw error;
|
|
420
|
+
}
|
|
421
|
+
releasePersistence();
|
|
346
422
|
}
|
|
347
423
|
};
|
|
348
|
-
$[
|
|
349
|
-
$[
|
|
350
|
-
$[
|
|
351
|
-
$[
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
424
|
+
$[61] = lookup;
|
|
425
|
+
$[62] = persistenceQueues;
|
|
426
|
+
$[63] = state;
|
|
427
|
+
$[64] = storage;
|
|
428
|
+
$[65] = storageScopeKey;
|
|
429
|
+
$[66] = updateCustomServers;
|
|
430
|
+
$[67] = t15;
|
|
431
|
+
} else t15 = $[67];
|
|
432
|
+
let t16;
|
|
433
|
+
if ($[68] !== t10 || $[69] !== t11 || $[70] !== t12 || $[71] !== t13 || $[72] !== t14 || $[73] !== t15) {
|
|
434
|
+
t16 = {
|
|
435
|
+
getState: t10,
|
|
436
|
+
server: t11,
|
|
437
|
+
connector: t12,
|
|
438
|
+
customServer: t13,
|
|
439
|
+
addCustomServer: t14,
|
|
440
|
+
removeServer: t15
|
|
362
441
|
};
|
|
363
|
-
$[
|
|
364
|
-
$[
|
|
365
|
-
$[
|
|
366
|
-
$[
|
|
367
|
-
$[
|
|
368
|
-
$[
|
|
369
|
-
|
|
370
|
-
|
|
442
|
+
$[68] = t10;
|
|
443
|
+
$[69] = t11;
|
|
444
|
+
$[70] = t12;
|
|
445
|
+
$[71] = t13;
|
|
446
|
+
$[72] = t14;
|
|
447
|
+
$[73] = t15;
|
|
448
|
+
$[74] = t16;
|
|
449
|
+
} else t16 = $[74];
|
|
450
|
+
return t16;
|
|
371
451
|
};
|
|
372
452
|
const McpManagerResource = resource(useMcpManagerResource);
|
|
373
453
|
attachTransformScopes(useMcpManagerResource, (scopes, parent) => {
|
|
@@ -376,17 +456,20 @@ attachTransformScopes(useMcpManagerResource, (scopes, parent) => {
|
|
|
376
456
|
function _temp(r) {
|
|
377
457
|
return r.id;
|
|
378
458
|
}
|
|
379
|
-
function _temp2(
|
|
459
|
+
function _temp2() {
|
|
460
|
+
return /* @__PURE__ */ new Map();
|
|
461
|
+
}
|
|
462
|
+
function _temp3(c) {
|
|
380
463
|
return c.id;
|
|
381
464
|
}
|
|
382
|
-
function
|
|
465
|
+
function _temp4(s) {
|
|
383
466
|
return s.id;
|
|
384
467
|
}
|
|
385
|
-
async function
|
|
386
|
-
function
|
|
468
|
+
async function _temp5() {}
|
|
469
|
+
function _temp6(s_1) {
|
|
387
470
|
return s_1.kind === "connector";
|
|
388
471
|
}
|
|
389
|
-
function
|
|
472
|
+
function _temp7(s_2) {
|
|
390
473
|
return s_2.kind === "custom";
|
|
391
474
|
}
|
|
392
475
|
//#endregion
|