@dudko.dev/agent-web-react 0.0.17 → 0.0.19
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/README.md +33 -4
- package/dist/index.cjs +84 -767
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -264
- package/dist/index.d.ts +3 -264
- package/dist/index.js +72 -738
- package/dist/index.js.map +1 -1
- package/dist/mcp.cjs +711 -0
- package/dist/mcp.cjs.map +1 -0
- package/dist/mcp.d.cts +265 -0
- package/dist/mcp.d.ts +265 -0
- package/dist/mcp.js +668 -0
- package/dist/mcp.js.map +1 -0
- package/package.json +13 -3
package/dist/index.cjs
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
2
|
var __defProp = Object.defineProperty;
|
|
4
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
6
|
var __export = (target, all) => {
|
|
9
7
|
for (var name in all)
|
|
@@ -17,14 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
15
|
}
|
|
18
16
|
return to;
|
|
19
17
|
};
|
|
20
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
21
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
22
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
23
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
24
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
25
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
26
|
-
mod
|
|
27
|
-
));
|
|
28
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
19
|
|
|
30
20
|
// src/index.ts
|
|
@@ -61,7 +51,6 @@ __export(src_exports, {
|
|
|
61
51
|
attachmentKindOf: () => attachmentKindOf,
|
|
62
52
|
attachmentRefusal: () => attachmentRefusal,
|
|
63
53
|
chatTitle: () => chatTitle,
|
|
64
|
-
claimOAuthCallback: () => claimOAuthCallback,
|
|
65
54
|
createAgent: () => import_agent_web4.createAgent,
|
|
66
55
|
createFileTools: () => import_agent_web4.createFileTools,
|
|
67
56
|
createInitialAgentState: () => createInitialAgentState,
|
|
@@ -71,11 +60,9 @@ __export(src_exports, {
|
|
|
71
60
|
defaultLabels: () => defaultLabels,
|
|
72
61
|
defineSkill: () => import_agent_web4.defineSkill,
|
|
73
62
|
defineTool: () => import_agent_web4.defineTool,
|
|
74
|
-
describeMcpResult: () => describeMcpResult,
|
|
75
63
|
downscaleImage: () => downscaleImage,
|
|
76
64
|
filterCommands: () => filterCommands,
|
|
77
65
|
formatElapsed: () => formatElapsed,
|
|
78
|
-
isUnauthorizedError: () => isUnauthorizedError,
|
|
79
66
|
isWebGPUAvailable: () => import_agent_web4.isWebGPUAvailable,
|
|
80
67
|
loadSkillFromUrl: () => import_agent_web4.loadSkillFromUrl,
|
|
81
68
|
markReadOnly: () => import_agent_web4.markReadOnly,
|
|
@@ -85,9 +72,7 @@ __export(src_exports, {
|
|
|
85
72
|
parseSkillMarkdown: () => import_agent_web4.parseSkillMarkdown,
|
|
86
73
|
parseSlash: () => parseSlash,
|
|
87
74
|
preloadWebLLMModel: () => import_agent_web4.preloadWebLLMModel,
|
|
88
|
-
readCallbackParams: () => readCallbackParams,
|
|
89
75
|
serveSubagentWorker: () => import_agent_web4.serveSubagentWorker,
|
|
90
|
-
stripOAuthParams: () => stripOAuthParams,
|
|
91
76
|
supportsImages: () => import_agent_web4.supportsImages,
|
|
92
77
|
supportsPdf: () => import_agent_web4.supportsPdf,
|
|
93
78
|
unloadWebLLMModel: () => import_agent_web4.unloadWebLLMModel,
|
|
@@ -98,8 +83,6 @@ __export(src_exports, {
|
|
|
98
83
|
useCredentials: () => useCredentials,
|
|
99
84
|
useLabels: () => useLabels,
|
|
100
85
|
useLocalModel: () => useLocalModel,
|
|
101
|
-
useMcp: () => useMcp,
|
|
102
|
-
useMcpServers: () => useMcpServers,
|
|
103
86
|
useOptionalAgentContext: () => useOptionalAgentContext,
|
|
104
87
|
useSpeechToText: () => useSpeechToText,
|
|
105
88
|
useVirtualFiles: () => useVirtualFiles,
|
|
@@ -176,24 +159,24 @@ var patchStep = (steps, id, fn) => steps.map((s) => s.id === id ? fn(s) : s);
|
|
|
176
159
|
var patchApproval = (approvals, id, fn) => approvals.map((a) => a.id === id ? fn(a) : a);
|
|
177
160
|
var patchSubagent = (subagents, id, fn) => subagents.map((s) => s.id === id ? fn(s) : s);
|
|
178
161
|
var runningStepId = (steps) => [...steps].reverse().find((s) => s.status === "running")?.id;
|
|
179
|
-
var applySubagentEvent = (
|
|
162
|
+
var applySubagentEvent = (view, event) => {
|
|
180
163
|
switch (event.type) {
|
|
181
164
|
case "step.start":
|
|
182
165
|
return {
|
|
183
|
-
...
|
|
184
|
-
steps:
|
|
166
|
+
...view,
|
|
167
|
+
steps: view.steps + 1,
|
|
185
168
|
activity: `step ${event.index}/${event.total}: ${event.step.description}`
|
|
186
169
|
};
|
|
187
170
|
case "step.tool-call":
|
|
188
|
-
return { ...
|
|
171
|
+
return { ...view, toolCalls: view.toolCalls + 1, activity: `\u2192 ${event.name}` };
|
|
189
172
|
case "final.text-delta":
|
|
190
|
-
return { ...
|
|
173
|
+
return { ...view, text: view.text + event.delta, activity: "writing the answer" };
|
|
191
174
|
case "final":
|
|
192
|
-
return { ...
|
|
175
|
+
return { ...view, text: event.text };
|
|
193
176
|
case "usage":
|
|
194
|
-
return { ...
|
|
177
|
+
return { ...view, usage: addUsage(view.usage, event.usage) };
|
|
195
178
|
default:
|
|
196
|
-
return
|
|
179
|
+
return view;
|
|
197
180
|
}
|
|
198
181
|
};
|
|
199
182
|
var finalizeAssistant = (messages, content, extra = {}) => {
|
|
@@ -259,7 +242,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
259
242
|
case "plan.step-added":
|
|
260
243
|
return state;
|
|
261
244
|
case "step.start": {
|
|
262
|
-
const
|
|
245
|
+
const view = {
|
|
263
246
|
id: event.step.id,
|
|
264
247
|
index: event.index,
|
|
265
248
|
total: event.total,
|
|
@@ -270,7 +253,7 @@ var applyEvent = (state, event, ctx) => {
|
|
|
270
253
|
status: "running",
|
|
271
254
|
blocked: false
|
|
272
255
|
};
|
|
273
|
-
return { ...state, steps: [...state.steps,
|
|
256
|
+
return { ...state, steps: [...state.steps, view] };
|
|
274
257
|
}
|
|
275
258
|
case "step.reasoning-delta":
|
|
276
259
|
return {
|
|
@@ -1060,684 +1043,25 @@ var useCredentials = (store) => {
|
|
|
1060
1043
|
return { store: resolved, setKey, removeKey, hasKey, version };
|
|
1061
1044
|
};
|
|
1062
1045
|
|
|
1063
|
-
// src/hooks/use-mcp.ts
|
|
1064
|
-
var import_react6 = require("react");
|
|
1065
|
-
var OAUTH_UNSUPPORTED = "The installed @dudko.dev/agent-web has no MCP OAuth support. Upgrade the core to a version exporting BrowserOAuthProvider, or use a static Authorization header.";
|
|
1066
|
-
var PENDING_KEY = "agent-web-react:mcp:pending";
|
|
1067
|
-
var OAUTH_KEY = "agent-web-react:mcp:oauth";
|
|
1068
|
-
var PENDING_TTL_MS = 10 * 60 * 1e3;
|
|
1069
|
-
var modulePromise;
|
|
1070
|
-
var loadMcp = () => {
|
|
1071
|
-
modulePromise ??= import("@dudko.dev/agent-web/mcp").then((m) => m).catch((err) => {
|
|
1072
|
-
modulePromise = void 0;
|
|
1073
|
-
throw err;
|
|
1074
|
-
});
|
|
1075
|
-
return modulePromise;
|
|
1076
|
-
};
|
|
1077
|
-
var describeMcpResult = (result) => {
|
|
1078
|
-
if (!result) return { status: "error", error: "The connector returned no result for the server" };
|
|
1079
|
-
if (result.connected) return { status: "connected" };
|
|
1080
|
-
if (result.needsAuthorization) return { status: "needs-authorization" };
|
|
1081
|
-
return { status: "error", error: result.error ?? "Could not connect to the MCP server" };
|
|
1082
|
-
};
|
|
1083
|
-
var OAUTH_PARAMS = ["code", "state", "error", "error_description", "iss"];
|
|
1084
|
-
var readCallbackParams = (href) => {
|
|
1085
|
-
const target = href ?? (typeof globalThis.location !== "undefined" ? globalThis.location.href : void 0);
|
|
1086
|
-
if (!target) return void 0;
|
|
1087
|
-
let url;
|
|
1088
|
-
try {
|
|
1089
|
-
url = new URL(target);
|
|
1090
|
-
} catch {
|
|
1091
|
-
return void 0;
|
|
1092
|
-
}
|
|
1093
|
-
const params = new URLSearchParams(url.search);
|
|
1094
|
-
const hash = url.hash.startsWith("#") ? url.hash.slice(1) : url.hash;
|
|
1095
|
-
const q = hash.indexOf("?");
|
|
1096
|
-
if (q >= 0) {
|
|
1097
|
-
for (const [k, v] of new URLSearchParams(hash.slice(q + 1))) {
|
|
1098
|
-
if (!params.has(k)) params.set(k, v);
|
|
1099
|
-
}
|
|
1100
|
-
}
|
|
1101
|
-
const code = params.get("code") ?? void 0;
|
|
1102
|
-
const error = params.get("error") ?? void 0;
|
|
1103
|
-
if (!code && !error) return void 0;
|
|
1104
|
-
return {
|
|
1105
|
-
code,
|
|
1106
|
-
state: params.get("state") ?? void 0,
|
|
1107
|
-
error,
|
|
1108
|
-
errorDescription: params.get("error_description") ?? void 0
|
|
1109
|
-
};
|
|
1110
|
-
};
|
|
1111
|
-
var stripOAuthParams = (href) => {
|
|
1112
|
-
const url = new URL(href);
|
|
1113
|
-
for (const key of OAUTH_PARAMS) url.searchParams.delete(key);
|
|
1114
|
-
const hash = url.hash.startsWith("#") ? url.hash.slice(1) : url.hash;
|
|
1115
|
-
const q = hash.indexOf("?");
|
|
1116
|
-
if (q >= 0) {
|
|
1117
|
-
const params = new URLSearchParams(hash.slice(q + 1));
|
|
1118
|
-
for (const key of OAUTH_PARAMS) params.delete(key);
|
|
1119
|
-
const rest = params.toString();
|
|
1120
|
-
url.hash = rest ? `${hash.slice(0, q)}?${rest}` : hash.slice(0, q);
|
|
1121
|
-
}
|
|
1122
|
-
return url.toString();
|
|
1123
|
-
};
|
|
1124
|
-
var claimedCallbacks = /* @__PURE__ */ new Set();
|
|
1125
|
-
var claimOAuthCallback = (callback) => {
|
|
1126
|
-
const key = `${callback.code ?? ""}|${callback.state ?? ""}|${callback.error ?? ""}`;
|
|
1127
|
-
if (claimedCallbacks.has(key)) return false;
|
|
1128
|
-
claimedCallbacks.add(key);
|
|
1129
|
-
return true;
|
|
1130
|
-
};
|
|
1131
|
-
var readRecord = (key) => {
|
|
1132
|
-
try {
|
|
1133
|
-
const raw = globalThis.localStorage?.getItem(key);
|
|
1134
|
-
return raw ? JSON.parse(raw) : void 0;
|
|
1135
|
-
} catch {
|
|
1136
|
-
return void 0;
|
|
1137
|
-
}
|
|
1138
|
-
};
|
|
1139
|
-
var writeRecord = (key, value) => {
|
|
1140
|
-
try {
|
|
1141
|
-
if (value) globalThis.localStorage?.setItem(key, JSON.stringify(value));
|
|
1142
|
-
else globalThis.localStorage?.removeItem(key);
|
|
1143
|
-
} catch {
|
|
1144
|
-
}
|
|
1145
|
-
};
|
|
1146
|
-
var defaultRedirectUrl = () => typeof globalThis.location === "undefined" ? "" : `${globalThis.location.origin}${globalThis.location.pathname}`;
|
|
1147
|
-
var isUnauthorizedError = (err, mod) => {
|
|
1148
|
-
if (!(err instanceof Error)) return false;
|
|
1149
|
-
if (mod?.UnauthorizedError && err instanceof mod.UnauthorizedError) return true;
|
|
1150
|
-
return err.constructor?.name === "UnauthorizedError";
|
|
1151
|
-
};
|
|
1152
|
-
var watchAuthorization = (tools, mod, onUnauthorized) => {
|
|
1153
|
-
const entries = Object.entries(tools).map(([name, value]) => {
|
|
1154
|
-
const tool = value;
|
|
1155
|
-
if (typeof tool.execute !== "function") return [name, value];
|
|
1156
|
-
const execute = tool.execute.bind(tool);
|
|
1157
|
-
const watched = (args, options) => {
|
|
1158
|
-
try {
|
|
1159
|
-
const out = execute(args, options);
|
|
1160
|
-
if (out && typeof out.then === "function") {
|
|
1161
|
-
return out.then(void 0, (err) => {
|
|
1162
|
-
if (isUnauthorizedError(err, mod)) onUnauthorized();
|
|
1163
|
-
throw err;
|
|
1164
|
-
});
|
|
1165
|
-
}
|
|
1166
|
-
return out;
|
|
1167
|
-
} catch (err) {
|
|
1168
|
-
if (isUnauthorizedError(err, mod)) onUnauthorized();
|
|
1169
|
-
throw err;
|
|
1170
|
-
}
|
|
1171
|
-
};
|
|
1172
|
-
return [name, { ...value, execute: watched }];
|
|
1173
|
-
});
|
|
1174
|
-
return Object.fromEntries(entries);
|
|
1175
|
-
};
|
|
1176
|
-
var useMcp = (options = {}) => {
|
|
1177
|
-
const [status, setStatus] = (0, import_react6.useState)("idle");
|
|
1178
|
-
const [tools, setTools] = (0, import_react6.useState)(void 0);
|
|
1179
|
-
const [catalog, setCatalog] = (0, import_react6.useState)([]);
|
|
1180
|
-
const [error, setError] = (0, import_react6.useState)(void 0);
|
|
1181
|
-
const [authorizationUrl, setAuthorizationUrl] = (0, import_react6.useState)(void 0);
|
|
1182
|
-
const [oauthSupported, setOauthSupported] = (0, import_react6.useState)(void 0);
|
|
1183
|
-
const [completingAuthorization, setCompletingAuthorization] = (0, import_react6.useState)(
|
|
1184
|
-
() => readCallbackParams() !== void 0
|
|
1185
|
-
);
|
|
1186
|
-
const connectionRef = (0, import_react6.useRef)(void 0);
|
|
1187
|
-
const providerRef = (0, import_react6.useRef)(void 0);
|
|
1188
|
-
const epochRef = (0, import_react6.useRef)(0);
|
|
1189
|
-
const optionsRef = (0, import_react6.useRef)(options);
|
|
1190
|
-
optionsRef.current = options;
|
|
1191
|
-
const closeConnection = (0, import_react6.useCallback)(async () => {
|
|
1192
|
-
const open = connectionRef.current;
|
|
1193
|
-
connectionRef.current = void 0;
|
|
1194
|
-
if (open) await open.close().catch(() => {
|
|
1195
|
-
});
|
|
1196
|
-
}, []);
|
|
1197
|
-
const checkOAuthSupport = (0, import_react6.useCallback)(async () => {
|
|
1198
|
-
try {
|
|
1199
|
-
const mod = await loadMcp();
|
|
1200
|
-
const supported = typeof mod.BrowserOAuthProvider === "function";
|
|
1201
|
-
setOauthSupported(supported);
|
|
1202
|
-
return supported;
|
|
1203
|
-
} catch {
|
|
1204
|
-
setOauthSupported(false);
|
|
1205
|
-
return false;
|
|
1206
|
-
}
|
|
1207
|
-
}, []);
|
|
1208
|
-
const connect = (0, import_react6.useCallback)(
|
|
1209
|
-
async (opts) => {
|
|
1210
|
-
const epoch = ++epochRef.current;
|
|
1211
|
-
const current = () => epochRef.current === epoch;
|
|
1212
|
-
await closeConnection();
|
|
1213
|
-
if (!current()) return;
|
|
1214
|
-
setStatus("connecting");
|
|
1215
|
-
setError(void 0);
|
|
1216
|
-
setAuthorizationUrl(void 0);
|
|
1217
|
-
setTools(void 0);
|
|
1218
|
-
setCatalog([]);
|
|
1219
|
-
try {
|
|
1220
|
-
const mod = await loadMcp();
|
|
1221
|
-
setOauthSupported(typeof mod.BrowserOAuthProvider === "function");
|
|
1222
|
-
const name = opts.name ?? "mcp";
|
|
1223
|
-
let authProvider;
|
|
1224
|
-
if (opts.oauth) {
|
|
1225
|
-
if (!mod.BrowserOAuthProvider) throw new Error(OAUTH_UNSUPPORTED);
|
|
1226
|
-
const oauth = typeof opts.oauth === "object" ? opts.oauth : {};
|
|
1227
|
-
const record = {
|
|
1228
|
-
url: opts.url,
|
|
1229
|
-
name,
|
|
1230
|
-
redirectUrl: oauth.redirectUrl ?? defaultRedirectUrl(),
|
|
1231
|
-
scope: oauth.scope,
|
|
1232
|
-
clientName: oauth.clientName ?? optionsRef.current.clientName,
|
|
1233
|
-
startedAt: Date.now()
|
|
1234
|
-
};
|
|
1235
|
-
authProvider = new mod.BrowserOAuthProvider({
|
|
1236
|
-
serverUrl: record.url,
|
|
1237
|
-
redirectUrl: record.redirectUrl,
|
|
1238
|
-
clientName: record.clientName,
|
|
1239
|
-
scope: record.scope
|
|
1240
|
-
});
|
|
1241
|
-
providerRef.current = authProvider;
|
|
1242
|
-
writeRecord(PENDING_KEY, record);
|
|
1243
|
-
writeRecord(OAUTH_KEY, record);
|
|
1244
|
-
} else {
|
|
1245
|
-
providerRef.current = void 0;
|
|
1246
|
-
}
|
|
1247
|
-
const connection = await mod.connectMcpHttp(
|
|
1248
|
-
{
|
|
1249
|
-
[name]: {
|
|
1250
|
-
url: opts.url,
|
|
1251
|
-
headers: opts.oauth ? void 0 : opts.headers,
|
|
1252
|
-
authProvider
|
|
1253
|
-
}
|
|
1254
|
-
},
|
|
1255
|
-
{ clientName: optionsRef.current.clientName, onLog: optionsRef.current.onLog }
|
|
1256
|
-
);
|
|
1257
|
-
if (!current()) {
|
|
1258
|
-
await connection.close().catch(() => {
|
|
1259
|
-
});
|
|
1260
|
-
return;
|
|
1261
|
-
}
|
|
1262
|
-
const outcome = describeMcpResult(connection.results[0]);
|
|
1263
|
-
if (outcome.status !== "connected") {
|
|
1264
|
-
await connection.close().catch(() => {
|
|
1265
|
-
});
|
|
1266
|
-
if (outcome.status === "needs-authorization") {
|
|
1267
|
-
const url = authProvider?.authorizationUrl;
|
|
1268
|
-
setAuthorizationUrl(url ? String(url) : void 0);
|
|
1269
|
-
setStatus("needs-authorization");
|
|
1270
|
-
return;
|
|
1271
|
-
}
|
|
1272
|
-
throw new Error(outcome.error);
|
|
1273
|
-
}
|
|
1274
|
-
connectionRef.current = connection;
|
|
1275
|
-
writeRecord(PENDING_KEY, void 0);
|
|
1276
|
-
setTools(
|
|
1277
|
-
watchAuthorization(connection.tools, mod, () => {
|
|
1278
|
-
if (!current()) return;
|
|
1279
|
-
const url = providerRef.current?.authorizationUrl;
|
|
1280
|
-
if (url) setAuthorizationUrl(String(url));
|
|
1281
|
-
setStatus("needs-authorization");
|
|
1282
|
-
})
|
|
1283
|
-
);
|
|
1284
|
-
setCatalog(connection.catalog);
|
|
1285
|
-
setStatus("connected");
|
|
1286
|
-
} catch (err) {
|
|
1287
|
-
if (!current()) return;
|
|
1288
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1289
|
-
setStatus("error");
|
|
1290
|
-
}
|
|
1291
|
-
},
|
|
1292
|
-
[closeConnection]
|
|
1293
|
-
);
|
|
1294
|
-
const disconnect = (0, import_react6.useCallback)(async () => {
|
|
1295
|
-
epochRef.current++;
|
|
1296
|
-
await closeConnection();
|
|
1297
|
-
setTools(void 0);
|
|
1298
|
-
setCatalog([]);
|
|
1299
|
-
setAuthorizationUrl(void 0);
|
|
1300
|
-
setError(void 0);
|
|
1301
|
-
setStatus("idle");
|
|
1302
|
-
}, [closeConnection]);
|
|
1303
|
-
const authorize = (0, import_react6.useCallback)(() => {
|
|
1304
|
-
if (authorizationUrl && typeof globalThis.location !== "undefined") {
|
|
1305
|
-
globalThis.location.href = authorizationUrl;
|
|
1306
|
-
}
|
|
1307
|
-
}, [authorizationUrl]);
|
|
1308
|
-
const forgetAuthorization = (0, import_react6.useCallback)(async () => {
|
|
1309
|
-
const record = readRecord(OAUTH_KEY);
|
|
1310
|
-
writeRecord(PENDING_KEY, void 0);
|
|
1311
|
-
writeRecord(OAUTH_KEY, void 0);
|
|
1312
|
-
let provider = providerRef.current;
|
|
1313
|
-
if (!provider && record) {
|
|
1314
|
-
const mod = await loadMcp().catch(() => void 0);
|
|
1315
|
-
if (mod?.BrowserOAuthProvider) {
|
|
1316
|
-
provider = new mod.BrowserOAuthProvider({
|
|
1317
|
-
serverUrl: record.url,
|
|
1318
|
-
redirectUrl: record.redirectUrl,
|
|
1319
|
-
clientName: record.clientName,
|
|
1320
|
-
scope: record.scope
|
|
1321
|
-
});
|
|
1322
|
-
}
|
|
1323
|
-
}
|
|
1324
|
-
await provider?.reset().catch(() => {
|
|
1325
|
-
});
|
|
1326
|
-
providerRef.current = void 0;
|
|
1327
|
-
await disconnect();
|
|
1328
|
-
}, [disconnect]);
|
|
1329
|
-
(0, import_react6.useEffect)(() => {
|
|
1330
|
-
const callback = readCallbackParams();
|
|
1331
|
-
if (!callback) {
|
|
1332
|
-
setCompletingAuthorization(false);
|
|
1333
|
-
return;
|
|
1334
|
-
}
|
|
1335
|
-
const pending = readRecord(PENDING_KEY);
|
|
1336
|
-
const fresh = pending !== void 0 && (pending.startedAt === void 0 || Date.now() - pending.startedAt < PENDING_TTL_MS);
|
|
1337
|
-
if (!pending || !fresh) {
|
|
1338
|
-
if (pending) writeRecord(PENDING_KEY, void 0);
|
|
1339
|
-
setCompletingAuthorization(false);
|
|
1340
|
-
return;
|
|
1341
|
-
}
|
|
1342
|
-
if (!claimOAuthCallback(callback)) {
|
|
1343
|
-
setCompletingAuthorization(false);
|
|
1344
|
-
return;
|
|
1345
|
-
}
|
|
1346
|
-
if (typeof globalThis.history !== "undefined") {
|
|
1347
|
-
globalThis.history.replaceState(null, "", stripOAuthParams(globalThis.location.href));
|
|
1348
|
-
}
|
|
1349
|
-
void (async () => {
|
|
1350
|
-
try {
|
|
1351
|
-
const mod = await loadMcp();
|
|
1352
|
-
setOauthSupported(typeof mod.BrowserOAuthProvider === "function");
|
|
1353
|
-
if (!mod.BrowserOAuthProvider || !mod.finishMcpOAuth) throw new Error(OAUTH_UNSUPPORTED);
|
|
1354
|
-
const provider = new mod.BrowserOAuthProvider({
|
|
1355
|
-
serverUrl: pending.url,
|
|
1356
|
-
redirectUrl: pending.redirectUrl ?? defaultRedirectUrl(),
|
|
1357
|
-
clientName: pending.clientName,
|
|
1358
|
-
scope: pending.scope
|
|
1359
|
-
});
|
|
1360
|
-
providerRef.current = provider;
|
|
1361
|
-
await mod.finishMcpOAuth(provider, callback);
|
|
1362
|
-
writeRecord(PENDING_KEY, void 0);
|
|
1363
|
-
setCompletingAuthorization(false);
|
|
1364
|
-
await connect({ url: pending.url, name: pending.name, oauth: true });
|
|
1365
|
-
} catch (err) {
|
|
1366
|
-
writeRecord(PENDING_KEY, void 0);
|
|
1367
|
-
setError(err instanceof Error ? err.message : String(err));
|
|
1368
|
-
setStatus("error");
|
|
1369
|
-
} finally {
|
|
1370
|
-
setCompletingAuthorization(false);
|
|
1371
|
-
}
|
|
1372
|
-
})();
|
|
1373
|
-
}, [connect]);
|
|
1374
|
-
(0, import_react6.useEffect)(
|
|
1375
|
-
() => () => {
|
|
1376
|
-
epochRef.current++;
|
|
1377
|
-
void closeConnection();
|
|
1378
|
-
},
|
|
1379
|
-
[closeConnection]
|
|
1380
|
-
);
|
|
1381
|
-
return {
|
|
1382
|
-
status,
|
|
1383
|
-
tools,
|
|
1384
|
-
catalog,
|
|
1385
|
-
error,
|
|
1386
|
-
authorizationUrl,
|
|
1387
|
-
oauthSupported,
|
|
1388
|
-
completingAuthorization,
|
|
1389
|
-
connect,
|
|
1390
|
-
disconnect,
|
|
1391
|
-
authorize,
|
|
1392
|
-
forgetAuthorization,
|
|
1393
|
-
checkOAuthSupport
|
|
1394
|
-
};
|
|
1395
|
-
};
|
|
1396
|
-
|
|
1397
|
-
// src/hooks/use-mcp-servers.ts
|
|
1398
|
-
var import_react7 = require("react");
|
|
1399
|
-
var DEFAULT_KEY = "agent-web-react:mcp-servers";
|
|
1400
|
-
var sanitize = (s) => s.replace(/[^a-zA-Z0-9_-]/g, "_").slice(0, 32) || "mcp";
|
|
1401
|
-
var view = (s, patch = {}) => ({
|
|
1402
|
-
name: s.name,
|
|
1403
|
-
url: s.url,
|
|
1404
|
-
auth: s.auth,
|
|
1405
|
-
status: "idle",
|
|
1406
|
-
catalog: [],
|
|
1407
|
-
...patch
|
|
1408
|
-
});
|
|
1409
|
-
var useMcpServers = (options = {}) => {
|
|
1410
|
-
const storageKey = options.storageKey ?? DEFAULT_KEY;
|
|
1411
|
-
const pendingKey = `${storageKey}:pending`;
|
|
1412
|
-
const persist = options.persist !== false;
|
|
1413
|
-
const [servers, setServers] = (0, import_react7.useState)(
|
|
1414
|
-
() => persist ? (readRecord(storageKey) ?? []).map((s) => view(s)) : []
|
|
1415
|
-
);
|
|
1416
|
-
const [oauthSupported, setOauthSupported] = (0, import_react7.useState)(void 0);
|
|
1417
|
-
const [completingAuthorization, setCompleting] = (0, import_react7.useState)(
|
|
1418
|
-
() => readCallbackParams() !== void 0 && readRecord(pendingKey) !== void 0
|
|
1419
|
-
);
|
|
1420
|
-
const [toolsVersion, setToolsVersion] = (0, import_react7.useState)(0);
|
|
1421
|
-
const liveRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
1422
|
-
const specsRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
1423
|
-
if (specsRef.current.size === 0 && servers.length > 0) {
|
|
1424
|
-
for (const s of servers)
|
|
1425
|
-
specsRef.current.set(s.name, { name: s.name, url: s.url, auth: s.auth });
|
|
1426
|
-
}
|
|
1427
|
-
const optionsRef = (0, import_react7.useRef)(options);
|
|
1428
|
-
optionsRef.current = options;
|
|
1429
|
-
const unmountedRef = (0, import_react7.useRef)(false);
|
|
1430
|
-
const saveList = (0, import_react7.useCallback)(() => {
|
|
1431
|
-
if (!persist) return;
|
|
1432
|
-
writeRecord(storageKey, [...specsRef.current.values()]);
|
|
1433
|
-
}, [persist, storageKey]);
|
|
1434
|
-
const patch = (0, import_react7.useCallback)((name, p) => {
|
|
1435
|
-
if (unmountedRef.current) return;
|
|
1436
|
-
setServers((list) => list.map((s) => s.name === name ? { ...s, ...p } : s));
|
|
1437
|
-
}, []);
|
|
1438
|
-
const live = (name) => {
|
|
1439
|
-
let l = liveRef.current.get(name);
|
|
1440
|
-
if (!l) {
|
|
1441
|
-
l = { epoch: 0 };
|
|
1442
|
-
liveRef.current.set(name, l);
|
|
1443
|
-
}
|
|
1444
|
-
return l;
|
|
1445
|
-
};
|
|
1446
|
-
const closeServer = (0, import_react7.useCallback)(async (name) => {
|
|
1447
|
-
const l = liveRef.current.get(name);
|
|
1448
|
-
if (!l) return;
|
|
1449
|
-
l.epoch += 1;
|
|
1450
|
-
const open = l.connection;
|
|
1451
|
-
l.connection = void 0;
|
|
1452
|
-
if (l.tools) {
|
|
1453
|
-
l.tools = void 0;
|
|
1454
|
-
setToolsVersion((v) => v + 1);
|
|
1455
|
-
}
|
|
1456
|
-
if (open) await open.close().catch(() => {
|
|
1457
|
-
});
|
|
1458
|
-
}, []);
|
|
1459
|
-
const providerFor = (mod, spec) => {
|
|
1460
|
-
if (!mod.BrowserOAuthProvider) throw new Error(OAUTH_UNSUPPORTED);
|
|
1461
|
-
return new mod.BrowserOAuthProvider({
|
|
1462
|
-
serverUrl: spec.url,
|
|
1463
|
-
redirectUrl: spec.oauth?.redirectUrl ?? defaultRedirectUrl(),
|
|
1464
|
-
clientName: spec.oauth?.clientName ?? optionsRef.current.clientName,
|
|
1465
|
-
scope: spec.oauth?.scope
|
|
1466
|
-
});
|
|
1467
|
-
};
|
|
1468
|
-
const connectServer = (0, import_react7.useCallback)(
|
|
1469
|
-
async (name) => {
|
|
1470
|
-
const spec = specsRef.current.get(name);
|
|
1471
|
-
if (!spec) return;
|
|
1472
|
-
await closeServer(name);
|
|
1473
|
-
const l = live(name);
|
|
1474
|
-
const epoch = ++l.epoch;
|
|
1475
|
-
const current = () => !unmountedRef.current && l.epoch === epoch;
|
|
1476
|
-
if (spec.auth === "bearer" && !l.token) {
|
|
1477
|
-
patch(name, { status: "idle", error: "Enter the bearer token to connect." });
|
|
1478
|
-
return;
|
|
1479
|
-
}
|
|
1480
|
-
patch(name, {
|
|
1481
|
-
status: "connecting",
|
|
1482
|
-
error: void 0,
|
|
1483
|
-
authorizationUrl: void 0,
|
|
1484
|
-
catalog: []
|
|
1485
|
-
});
|
|
1486
|
-
try {
|
|
1487
|
-
const mod = await loadMcp();
|
|
1488
|
-
setOauthSupported(typeof mod.BrowserOAuthProvider === "function");
|
|
1489
|
-
let provider;
|
|
1490
|
-
if (spec.auth === "oauth") {
|
|
1491
|
-
provider = providerFor(mod, spec);
|
|
1492
|
-
l.provider = provider;
|
|
1493
|
-
}
|
|
1494
|
-
const connection = await mod.connectMcpHttp(
|
|
1495
|
-
{
|
|
1496
|
-
[name]: {
|
|
1497
|
-
url: spec.url,
|
|
1498
|
-
headers: spec.auth === "bearer" && l.token ? { Authorization: `Bearer ${l.token}` } : void 0,
|
|
1499
|
-
authProvider: provider,
|
|
1500
|
-
connectTimeoutMs: optionsRef.current.connectTimeoutMs
|
|
1501
|
-
}
|
|
1502
|
-
},
|
|
1503
|
-
{
|
|
1504
|
-
clientName: optionsRef.current.clientName,
|
|
1505
|
-
onLog: optionsRef.current.onLog,
|
|
1506
|
-
connectTimeoutMs: optionsRef.current.connectTimeoutMs
|
|
1507
|
-
}
|
|
1508
|
-
);
|
|
1509
|
-
if (!current()) {
|
|
1510
|
-
await connection.close().catch(() => {
|
|
1511
|
-
});
|
|
1512
|
-
return;
|
|
1513
|
-
}
|
|
1514
|
-
const outcome = describeMcpResult(connection.results[0]);
|
|
1515
|
-
if (outcome.status !== "connected") {
|
|
1516
|
-
await connection.close().catch(() => {
|
|
1517
|
-
});
|
|
1518
|
-
if (outcome.status === "needs-authorization") {
|
|
1519
|
-
const url = provider?.authorizationUrl;
|
|
1520
|
-
patch(name, {
|
|
1521
|
-
status: "needs-authorization",
|
|
1522
|
-
authorizationUrl: url ? String(url) : void 0
|
|
1523
|
-
});
|
|
1524
|
-
return;
|
|
1525
|
-
}
|
|
1526
|
-
throw new Error(outcome.error);
|
|
1527
|
-
}
|
|
1528
|
-
l.connection = connection;
|
|
1529
|
-
l.tools = watchAuthorization(connection.tools, mod, () => {
|
|
1530
|
-
if (!current()) return;
|
|
1531
|
-
const url = l.provider?.authorizationUrl;
|
|
1532
|
-
patch(name, {
|
|
1533
|
-
status: "needs-authorization",
|
|
1534
|
-
authorizationUrl: url ? String(url) : void 0
|
|
1535
|
-
});
|
|
1536
|
-
});
|
|
1537
|
-
setToolsVersion((v) => v + 1);
|
|
1538
|
-
patch(name, { status: "connected", catalog: connection.catalog });
|
|
1539
|
-
} catch (err) {
|
|
1540
|
-
if (!current()) return;
|
|
1541
|
-
patch(name, { status: "error", error: err instanceof Error ? err.message : String(err) });
|
|
1542
|
-
}
|
|
1543
|
-
},
|
|
1544
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1545
|
-
[closeServer, patch, pendingKey]
|
|
1546
|
-
);
|
|
1547
|
-
const add = (0, import_react7.useCallback)(
|
|
1548
|
-
async (input) => {
|
|
1549
|
-
let name = sanitize(input.name);
|
|
1550
|
-
const taken = specsRef.current.get(name);
|
|
1551
|
-
if (taken && taken.url !== input.url) {
|
|
1552
|
-
let n = 2;
|
|
1553
|
-
while (specsRef.current.has(`${name}_${n}`)) n += 1;
|
|
1554
|
-
name = `${name}_${n}`;
|
|
1555
|
-
}
|
|
1556
|
-
const spec = {
|
|
1557
|
-
name,
|
|
1558
|
-
url: input.url,
|
|
1559
|
-
auth: input.auth ?? "none",
|
|
1560
|
-
...input.oauth ? { oauth: input.oauth } : {}
|
|
1561
|
-
};
|
|
1562
|
-
specsRef.current.set(name, spec);
|
|
1563
|
-
live(name).token = input.auth === "bearer" ? input.token : void 0;
|
|
1564
|
-
setServers(
|
|
1565
|
-
(list) => list.some((s) => s.name === name) ? list.map((s) => s.name === name ? view(spec) : s) : [...list, view(spec)]
|
|
1566
|
-
);
|
|
1567
|
-
saveList();
|
|
1568
|
-
await connectServer(name);
|
|
1569
|
-
return name;
|
|
1570
|
-
},
|
|
1571
|
-
[connectServer, saveList]
|
|
1572
|
-
);
|
|
1573
|
-
const remove = (0, import_react7.useCallback)(
|
|
1574
|
-
async (name) => {
|
|
1575
|
-
await closeServer(name);
|
|
1576
|
-
liveRef.current.delete(name);
|
|
1577
|
-
specsRef.current.delete(name);
|
|
1578
|
-
saveList();
|
|
1579
|
-
setServers((list) => list.filter((s) => s.name !== name));
|
|
1580
|
-
},
|
|
1581
|
-
[closeServer, saveList]
|
|
1582
|
-
);
|
|
1583
|
-
const reconnect = (0, import_react7.useCallback)(
|
|
1584
|
-
async (name, token) => {
|
|
1585
|
-
if (token !== void 0) live(name).token = token;
|
|
1586
|
-
await connectServer(name);
|
|
1587
|
-
},
|
|
1588
|
-
[connectServer]
|
|
1589
|
-
);
|
|
1590
|
-
const authorize = (0, import_react7.useCallback)(
|
|
1591
|
-
(name) => {
|
|
1592
|
-
const url = servers.find((s) => s.name === name)?.authorizationUrl;
|
|
1593
|
-
const spec = specsRef.current.get(name);
|
|
1594
|
-
if (!url || !spec || typeof globalThis.location === "undefined") return;
|
|
1595
|
-
const pending = {
|
|
1596
|
-
name,
|
|
1597
|
-
url: spec.url,
|
|
1598
|
-
redirectUrl: spec.oauth?.redirectUrl ?? defaultRedirectUrl(),
|
|
1599
|
-
scope: spec.oauth?.scope,
|
|
1600
|
-
clientName: spec.oauth?.clientName ?? optionsRef.current.clientName,
|
|
1601
|
-
startedAt: Date.now()
|
|
1602
|
-
};
|
|
1603
|
-
writeRecord(pendingKey, pending);
|
|
1604
|
-
globalThis.location.href = url;
|
|
1605
|
-
},
|
|
1606
|
-
[servers, pendingKey]
|
|
1607
|
-
);
|
|
1608
|
-
const forgetAuthorization = (0, import_react7.useCallback)(
|
|
1609
|
-
async (name) => {
|
|
1610
|
-
const spec = specsRef.current.get(name);
|
|
1611
|
-
const l = liveRef.current.get(name);
|
|
1612
|
-
let provider = l?.provider;
|
|
1613
|
-
if (!provider && spec?.auth === "oauth") {
|
|
1614
|
-
const mod = await loadMcp().catch(() => void 0);
|
|
1615
|
-
if (mod?.BrowserOAuthProvider) provider = providerFor(mod, spec);
|
|
1616
|
-
}
|
|
1617
|
-
await provider?.reset().catch(() => {
|
|
1618
|
-
});
|
|
1619
|
-
if (l) l.provider = void 0;
|
|
1620
|
-
const pending = readRecord(pendingKey);
|
|
1621
|
-
if (pending?.name === name) writeRecord(pendingKey, void 0);
|
|
1622
|
-
await closeServer(name);
|
|
1623
|
-
patch(name, { status: "idle", authorizationUrl: void 0, catalog: [], error: void 0 });
|
|
1624
|
-
},
|
|
1625
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1626
|
-
[closeServer, patch, pendingKey]
|
|
1627
|
-
);
|
|
1628
|
-
const checkOAuthSupport = (0, import_react7.useCallback)(async () => {
|
|
1629
|
-
try {
|
|
1630
|
-
const mod = await loadMcp();
|
|
1631
|
-
const supported = typeof mod.BrowserOAuthProvider === "function";
|
|
1632
|
-
setOauthSupported(supported);
|
|
1633
|
-
return supported;
|
|
1634
|
-
} catch {
|
|
1635
|
-
setOauthSupported(false);
|
|
1636
|
-
return false;
|
|
1637
|
-
}
|
|
1638
|
-
}, []);
|
|
1639
|
-
(0, import_react7.useEffect)(() => {
|
|
1640
|
-
unmountedRef.current = false;
|
|
1641
|
-
const callback = readCallbackParams();
|
|
1642
|
-
const pending = readRecord(pendingKey);
|
|
1643
|
-
const fresh = pending !== void 0 && Date.now() - pending.startedAt < PENDING_TTL_MS;
|
|
1644
|
-
const ours = Boolean(callback && pending && fresh && claimOAuthCallback(callback));
|
|
1645
|
-
if (callback && pending && !fresh) writeRecord(pendingKey, void 0);
|
|
1646
|
-
if (ours && typeof globalThis.history !== "undefined") {
|
|
1647
|
-
globalThis.history.replaceState(null, "", stripOAuthParams(globalThis.location.href));
|
|
1648
|
-
}
|
|
1649
|
-
const autoConnect = optionsRef.current.autoConnect !== false;
|
|
1650
|
-
void (async () => {
|
|
1651
|
-
if (ours && pending && callback) {
|
|
1652
|
-
try {
|
|
1653
|
-
const mod = await loadMcp();
|
|
1654
|
-
setOauthSupported(typeof mod.BrowserOAuthProvider === "function");
|
|
1655
|
-
if (!mod.finishMcpOAuth) throw new Error(OAUTH_UNSUPPORTED);
|
|
1656
|
-
const spec = specsRef.current.get(pending.name) ?? {
|
|
1657
|
-
name: pending.name,
|
|
1658
|
-
url: pending.url,
|
|
1659
|
-
auth: "oauth"
|
|
1660
|
-
};
|
|
1661
|
-
if (!specsRef.current.has(spec.name)) {
|
|
1662
|
-
specsRef.current.set(spec.name, spec);
|
|
1663
|
-
setServers((list) => [...list, view(spec)]);
|
|
1664
|
-
saveList();
|
|
1665
|
-
}
|
|
1666
|
-
const provider = providerFor(mod, {
|
|
1667
|
-
...spec,
|
|
1668
|
-
oauth: {
|
|
1669
|
-
redirectUrl: pending.redirectUrl,
|
|
1670
|
-
scope: pending.scope,
|
|
1671
|
-
clientName: pending.clientName
|
|
1672
|
-
}
|
|
1673
|
-
});
|
|
1674
|
-
live(spec.name).provider = provider;
|
|
1675
|
-
await mod.finishMcpOAuth(provider, callback);
|
|
1676
|
-
writeRecord(pendingKey, void 0);
|
|
1677
|
-
} catch (err) {
|
|
1678
|
-
writeRecord(pendingKey, void 0);
|
|
1679
|
-
patch(pending.name, {
|
|
1680
|
-
status: "error",
|
|
1681
|
-
error: err instanceof Error ? err.message : String(err)
|
|
1682
|
-
});
|
|
1683
|
-
}
|
|
1684
|
-
}
|
|
1685
|
-
setCompleting(false);
|
|
1686
|
-
if (autoConnect || ours) {
|
|
1687
|
-
await Promise.all(
|
|
1688
|
-
[...specsRef.current.keys()].filter((name) => autoConnect || name === pending?.name).map((name) => connectServer(name))
|
|
1689
|
-
);
|
|
1690
|
-
}
|
|
1691
|
-
})();
|
|
1692
|
-
return () => {
|
|
1693
|
-
unmountedRef.current = true;
|
|
1694
|
-
for (const name of liveRef.current.keys()) void closeServer(name);
|
|
1695
|
-
};
|
|
1696
|
-
}, []);
|
|
1697
|
-
const tools = (0, import_react7.useMemo)(() => {
|
|
1698
|
-
const merged = {};
|
|
1699
|
-
for (const l of liveRef.current.values()) if (l.tools) Object.assign(merged, l.tools);
|
|
1700
|
-
return merged;
|
|
1701
|
-
}, [toolsVersion]);
|
|
1702
|
-
const catalog = (0, import_react7.useMemo)(
|
|
1703
|
-
() => servers.filter((s) => s.status === "connected").flatMap((s) => s.catalog),
|
|
1704
|
-
[servers]
|
|
1705
|
-
);
|
|
1706
|
-
return {
|
|
1707
|
-
servers,
|
|
1708
|
-
tools,
|
|
1709
|
-
catalog,
|
|
1710
|
-
connectedCount: servers.filter((s) => s.status === "connected").length,
|
|
1711
|
-
completingAuthorization,
|
|
1712
|
-
oauthSupported,
|
|
1713
|
-
checkOAuthSupport,
|
|
1714
|
-
add,
|
|
1715
|
-
remove,
|
|
1716
|
-
reconnect,
|
|
1717
|
-
authorize,
|
|
1718
|
-
forgetAuthorization
|
|
1719
|
-
};
|
|
1720
|
-
};
|
|
1721
|
-
|
|
1722
1046
|
// src/hooks/use-webllm-model.ts
|
|
1723
1047
|
var import_agent_web3 = require("@dudko.dev/agent-web");
|
|
1724
1048
|
|
|
1725
1049
|
// src/hooks/use-local-model.ts
|
|
1726
|
-
var
|
|
1050
|
+
var import_react6 = require("react");
|
|
1727
1051
|
var keyOf = (id, tokens) => tokens ? `${id}@${tokens}` : id;
|
|
1728
1052
|
var useLocalModel = (modelId, engine, options) => {
|
|
1729
|
-
const [loaded, setLoaded] = (0,
|
|
1730
|
-
const [pending, setPending] = (0,
|
|
1731
|
-
const [failure, setFailure] = (0,
|
|
1732
|
-
const engineRef = (0,
|
|
1053
|
+
const [loaded, setLoaded] = (0, import_react6.useState)(void 0);
|
|
1054
|
+
const [pending, setPending] = (0, import_react6.useState)();
|
|
1055
|
+
const [failure, setFailure] = (0, import_react6.useState)();
|
|
1056
|
+
const engineRef = (0, import_react6.useRef)(engine);
|
|
1733
1057
|
engineRef.current = engine;
|
|
1734
|
-
const loadedRef = (0,
|
|
1735
|
-
const inflightRef = (0,
|
|
1058
|
+
const loadedRef = (0, import_react6.useRef)(void 0);
|
|
1059
|
+
const inflightRef = (0, import_react6.useRef)(
|
|
1736
1060
|
void 0
|
|
1737
1061
|
);
|
|
1738
1062
|
const windowTokens = options?.contextWindowTokens;
|
|
1739
1063
|
const key = keyOf(modelId, windowTokens);
|
|
1740
|
-
const seqRef = (0,
|
|
1064
|
+
const seqRef = (0, import_react6.useRef)(0);
|
|
1741
1065
|
const setHeld = (next) => {
|
|
1742
1066
|
loadedRef.current = next;
|
|
1743
1067
|
setLoaded(next);
|
|
@@ -1748,7 +1072,7 @@ var useLocalModel = (modelId, engine, options) => {
|
|
|
1748
1072
|
} catch {
|
|
1749
1073
|
}
|
|
1750
1074
|
};
|
|
1751
|
-
const load = (0,
|
|
1075
|
+
const load = (0, import_react6.useCallback)(() => {
|
|
1752
1076
|
const id = modelId;
|
|
1753
1077
|
if (loadedRef.current?.key === key) return Promise.resolve(loadedRef.current.model);
|
|
1754
1078
|
if (inflightRef.current?.key === key) return inflightRef.current.promise;
|
|
@@ -1800,7 +1124,7 @@ var useLocalModel = (modelId, engine, options) => {
|
|
|
1800
1124
|
inflightRef.current = { key, promise };
|
|
1801
1125
|
return promise;
|
|
1802
1126
|
}, [modelId, key]);
|
|
1803
|
-
const unload = (0,
|
|
1127
|
+
const unload = (0, import_react6.useCallback)(async () => {
|
|
1804
1128
|
seqRef.current++;
|
|
1805
1129
|
inflightRef.current = void 0;
|
|
1806
1130
|
setPending(void 0);
|
|
@@ -1862,7 +1186,7 @@ var createWebLLMEngine = (options) => {
|
|
|
1862
1186
|
};
|
|
1863
1187
|
|
|
1864
1188
|
// src/labels.tsx
|
|
1865
|
-
var
|
|
1189
|
+
var import_react7 = require("react");
|
|
1866
1190
|
|
|
1867
1191
|
// src/composer.ts
|
|
1868
1192
|
var parseSlash = (text) => {
|
|
@@ -2084,15 +1408,15 @@ var mergeLabels = (base2, over) => {
|
|
|
2084
1408
|
}
|
|
2085
1409
|
return out;
|
|
2086
1410
|
};
|
|
2087
|
-
var LabelsContext = (0,
|
|
1411
|
+
var LabelsContext = (0, import_react7.createContext)(defaultLabels);
|
|
2088
1412
|
var AgentLabelsProvider = ({ labels, children }) => {
|
|
2089
|
-
const parent = (0,
|
|
2090
|
-
const value = (0,
|
|
1413
|
+
const parent = (0, import_react7.useContext)(LabelsContext);
|
|
1414
|
+
const value = (0, import_react7.useMemo)(() => mergeLabels(parent, labels), [parent, labels]);
|
|
2091
1415
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(LabelsContext.Provider, { value, children });
|
|
2092
1416
|
};
|
|
2093
1417
|
var useLabels = (over) => {
|
|
2094
|
-
const ctx = (0,
|
|
2095
|
-
return (0,
|
|
1418
|
+
const ctx = (0, import_react7.useContext)(LabelsContext);
|
|
1419
|
+
return (0, import_react7.useMemo)(() => mergeLabels(ctx, over), [ctx, over]);
|
|
2096
1420
|
};
|
|
2097
1421
|
|
|
2098
1422
|
// src/image-resize.ts
|
|
@@ -2145,25 +1469,25 @@ var downscaleImage = async (file, opts = {}) => {
|
|
|
2145
1469
|
};
|
|
2146
1470
|
|
|
2147
1471
|
// src/context.tsx
|
|
2148
|
-
var
|
|
1472
|
+
var import_react8 = require("react");
|
|
2149
1473
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
2150
|
-
var AgentContext = (0,
|
|
1474
|
+
var AgentContext = (0, import_react8.createContext)(null);
|
|
2151
1475
|
var AgentProvider = ({ config, children, ...options }) => {
|
|
2152
1476
|
const agent = useAgent(config, options);
|
|
2153
1477
|
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AgentContext.Provider, { value: agent, children });
|
|
2154
1478
|
};
|
|
2155
1479
|
var useAgentContext = () => {
|
|
2156
|
-
const ctx = (0,
|
|
1480
|
+
const ctx = (0, import_react8.useContext)(AgentContext);
|
|
2157
1481
|
if (!ctx) throw new Error("useAgentContext must be used within an <AgentProvider>");
|
|
2158
1482
|
return ctx;
|
|
2159
1483
|
};
|
|
2160
|
-
var useOptionalAgentContext = () => (0,
|
|
1484
|
+
var useOptionalAgentContext = () => (0, import_react8.useContext)(AgentContext);
|
|
2161
1485
|
|
|
2162
1486
|
// src/components/AgentChat.tsx
|
|
2163
|
-
var
|
|
1487
|
+
var import_react13 = require("react");
|
|
2164
1488
|
|
|
2165
1489
|
// src/components/AgentComposer.tsx
|
|
2166
|
-
var
|
|
1490
|
+
var import_react9 = require("react");
|
|
2167
1491
|
|
|
2168
1492
|
// src/components/icons.tsx
|
|
2169
1493
|
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
@@ -2242,9 +1566,9 @@ var thinkingDefaults = (l) => [
|
|
|
2242
1566
|
var MODES = ["autopilot", "ask-writes", "ask-all", "read-only"];
|
|
2243
1567
|
var ModeIcon = ({ mode }) => mode === "autopilot" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(BoltIcon, { size: 14 }) : mode === "read-only" ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(EyeIcon, { size: 14 }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ShieldIcon, { size: 14 });
|
|
2244
1568
|
var attachSeq = 0;
|
|
2245
|
-
var useIsoLayoutEffect = typeof window === "undefined" ?
|
|
1569
|
+
var useIsoLayoutEffect = typeof window === "undefined" ? import_react9.useEffect : import_react9.useLayoutEffect;
|
|
2246
1570
|
var useMenuPlacement = (open, anchor, align) => {
|
|
2247
|
-
const [style, setStyle] = (0,
|
|
1571
|
+
const [style, setStyle] = (0, import_react9.useState)();
|
|
2248
1572
|
useIsoLayoutEffect(() => {
|
|
2249
1573
|
if (!open) return;
|
|
2250
1574
|
const place = () => {
|
|
@@ -2319,19 +1643,19 @@ var AgentComposer = ({
|
|
|
2319
1643
|
const L = useLabels(labelsOverride);
|
|
2320
1644
|
const MODE_CHIP = L.modes;
|
|
2321
1645
|
const DEFAULT_THINKING = thinkingDefaults(L);
|
|
2322
|
-
const [text, setText] = (0,
|
|
2323
|
-
const [pending, setPending] = (0,
|
|
2324
|
-
const [menu, setMenu] = (0,
|
|
2325
|
-
const [active, setActive] = (0,
|
|
2326
|
-
const [dismissed, setDismissed] = (0,
|
|
2327
|
-
const [attachError, setAttachError] = (0,
|
|
2328
|
-
const [dragging, setDragging] = (0,
|
|
2329
|
-
const rootRef = (0,
|
|
2330
|
-
const modelRef = (0,
|
|
2331
|
-
const modeRef = (0,
|
|
2332
|
-
const [dropRect, setDropRect] = (0,
|
|
2333
|
-
const [compactBar, setCompactBar] = (0,
|
|
2334
|
-
(0,
|
|
1646
|
+
const [text, setText] = (0, import_react9.useState)("");
|
|
1647
|
+
const [pending, setPending] = (0, import_react9.useState)([]);
|
|
1648
|
+
const [menu, setMenu] = (0, import_react9.useState)(void 0);
|
|
1649
|
+
const [active, setActive] = (0, import_react9.useState)(0);
|
|
1650
|
+
const [dismissed, setDismissed] = (0, import_react9.useState)(() => /* @__PURE__ */ new Set());
|
|
1651
|
+
const [attachError, setAttachError] = (0, import_react9.useState)();
|
|
1652
|
+
const [dragging, setDragging] = (0, import_react9.useState)(false);
|
|
1653
|
+
const rootRef = (0, import_react9.useRef)(null);
|
|
1654
|
+
const modelRef = (0, import_react9.useRef)(null);
|
|
1655
|
+
const modeRef = (0, import_react9.useRef)(null);
|
|
1656
|
+
const [dropRect, setDropRect] = (0, import_react9.useState)();
|
|
1657
|
+
const [compactBar, setCompactBar] = (0, import_react9.useState)(false);
|
|
1658
|
+
(0, import_react9.useEffect)(() => {
|
|
2335
1659
|
const el = rootRef.current;
|
|
2336
1660
|
if (!el || typeof ResizeObserver === "undefined") return;
|
|
2337
1661
|
const ro = new ResizeObserver(
|
|
@@ -2340,8 +1664,8 @@ var AgentComposer = ({
|
|
|
2340
1664
|
ro.observe(el);
|
|
2341
1665
|
return () => ro.disconnect();
|
|
2342
1666
|
}, [compactWidth]);
|
|
2343
|
-
const fileRef = (0,
|
|
2344
|
-
const inputRef = (0,
|
|
1667
|
+
const fileRef = (0, import_react9.useRef)(null);
|
|
1668
|
+
const inputRef = (0, import_react9.useRef)(null);
|
|
2345
1669
|
const busy = agent.isRunning;
|
|
2346
1670
|
const ready = agent.isReady && !disabled;
|
|
2347
1671
|
const caps = agent.agent?.capabilities;
|
|
@@ -2350,10 +1674,10 @@ var AgentComposer = ({
|
|
|
2350
1674
|
onFinal: (heard) => setText((t) => t.trim() ? `${t.trimEnd()} ${heard}` : heard)
|
|
2351
1675
|
});
|
|
2352
1676
|
const showMic = speech !== false && stt.supported;
|
|
2353
|
-
const [startedAt, setStartedAt] = (0,
|
|
2354
|
-
const [now, setNow] = (0,
|
|
2355
|
-
const [lastElapsed, setLastElapsed] = (0,
|
|
2356
|
-
(0,
|
|
1677
|
+
const [startedAt, setStartedAt] = (0, import_react9.useState)();
|
|
1678
|
+
const [now, setNow] = (0, import_react9.useState)(() => Date.now());
|
|
1679
|
+
const [lastElapsed, setLastElapsed] = (0, import_react9.useState)();
|
|
1680
|
+
(0, import_react9.useEffect)(() => {
|
|
2357
1681
|
if (!busy) {
|
|
2358
1682
|
if (startedAt !== void 0) setLastElapsed(Date.now() - startedAt);
|
|
2359
1683
|
setStartedAt(void 0);
|
|
@@ -2366,7 +1690,7 @@ var AgentComposer = ({
|
|
|
2366
1690
|
return () => clearInterval(id);
|
|
2367
1691
|
}, [busy]);
|
|
2368
1692
|
const elapsed = startedAt !== void 0 ? now - startedAt : lastElapsed;
|
|
2369
|
-
const allCommands = (0,
|
|
1693
|
+
const allCommands = (0, import_react9.useMemo)(() => {
|
|
2370
1694
|
const out = [];
|
|
2371
1695
|
if (builtinCommands) {
|
|
2372
1696
|
out.push(
|
|
@@ -2446,8 +1770,8 @@ var AgentComposer = ({
|
|
|
2446
1770
|
const commandsStyle = useMenuPlacement(paletteOpen, rootRef, "stretch");
|
|
2447
1771
|
const modelStyle = useMenuPlacement(menu === "model", modelRef, "left");
|
|
2448
1772
|
const modeStyle = useMenuPlacement(menu === "mode", modeRef, "right");
|
|
2449
|
-
(0,
|
|
2450
|
-
(0,
|
|
1773
|
+
(0, import_react9.useEffect)(() => setActive(0), [text, menu]);
|
|
1774
|
+
(0, import_react9.useEffect)(() => {
|
|
2451
1775
|
if (!menu) return;
|
|
2452
1776
|
const onDown = (e) => {
|
|
2453
1777
|
if (!rootRef.current?.contains(e.target)) setMenu(void 0);
|
|
@@ -2540,9 +1864,9 @@ var AgentComposer = ({
|
|
|
2540
1864
|
e.preventDefault();
|
|
2541
1865
|
void addFiles(pasted);
|
|
2542
1866
|
};
|
|
2543
|
-
const addFilesRef = (0,
|
|
1867
|
+
const addFilesRef = (0, import_react9.useRef)(addFiles);
|
|
2544
1868
|
addFilesRef.current = addFiles;
|
|
2545
|
-
(0,
|
|
1869
|
+
(0, import_react9.useEffect)(() => {
|
|
2546
1870
|
if (attachments === false) return;
|
|
2547
1871
|
const target = dropZone === "window" ? globalThis.window : dropZone === "self" ? rootRef.current : dropZone.current;
|
|
2548
1872
|
if (!target) return;
|
|
@@ -2972,7 +2296,7 @@ var AgentComposer = ({
|
|
|
2972
2296
|
};
|
|
2973
2297
|
|
|
2974
2298
|
// src/components/ChatHistoryList.tsx
|
|
2975
|
-
var
|
|
2299
|
+
var import_react10 = require("react");
|
|
2976
2300
|
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
2977
2301
|
var defaultTime = (ms) => {
|
|
2978
2302
|
const d = new Date(ms);
|
|
@@ -3042,7 +2366,7 @@ var ChatHistoryList = ({
|
|
|
3042
2366
|
}
|
|
3043
2367
|
)
|
|
3044
2368
|
] }, c.id);
|
|
3045
|
-
return renderChat ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2369
|
+
return renderChat ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react10.Fragment, { children: renderChat(c, active, row) }, c.id) : row;
|
|
3046
2370
|
}) })
|
|
3047
2371
|
] });
|
|
3048
2372
|
};
|
|
@@ -3166,7 +2490,7 @@ var ContextMeter = ({
|
|
|
3166
2490
|
};
|
|
3167
2491
|
|
|
3168
2492
|
// src/components/FilesPanel.tsx
|
|
3169
|
-
var
|
|
2493
|
+
var import_react11 = require("react");
|
|
3170
2494
|
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
3171
2495
|
var PREVIEW_CHARS = 2e4;
|
|
3172
2496
|
var FilesPanel = ({
|
|
@@ -3183,9 +2507,9 @@ var FilesPanel = ({
|
|
|
3183
2507
|
}) => {
|
|
3184
2508
|
const L = useLabels(labels);
|
|
3185
2509
|
const fs = useVirtualFiles(vfs, prefix);
|
|
3186
|
-
const [preview, setPreview] = (0,
|
|
3187
|
-
const inputRef = (0,
|
|
3188
|
-
(0,
|
|
2510
|
+
const [preview, setPreview] = (0, import_react11.useState)();
|
|
2511
|
+
const inputRef = (0, import_react11.useRef)(null);
|
|
2512
|
+
(0, import_react11.useEffect)(() => {
|
|
3189
2513
|
if (preview && !fs.files.some((f) => f.path === preview.path)) setPreview(void 0);
|
|
3190
2514
|
}, [fs.files, preview]);
|
|
3191
2515
|
const open = async (f) => {
|
|
@@ -3286,7 +2610,7 @@ var FilesPanel = ({
|
|
|
3286
2610
|
},
|
|
3287
2611
|
f.path
|
|
3288
2612
|
);
|
|
3289
|
-
return renderFile ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2613
|
+
return renderFile ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_react11.Fragment, { children: renderFile(f, row) }, f.path) : row;
|
|
3290
2614
|
}) }),
|
|
3291
2615
|
preview && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { className: "awr-filepreview", children: preview.kind === "image" ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("img", { src: preview.src, alt: preview.path }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("pre", { children: preview.text.length > PREVIEW_CHARS ? `${preview.text.slice(0, PREVIEW_CHARS)}
|
|
3292
2616
|
\u2026` : preview.text }) })
|
|
@@ -3294,7 +2618,7 @@ var FilesPanel = ({
|
|
|
3294
2618
|
};
|
|
3295
2619
|
|
|
3296
2620
|
// src/components/StepList.tsx
|
|
3297
|
-
var
|
|
2621
|
+
var import_react12 = require("react");
|
|
3298
2622
|
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
3299
2623
|
var ToolCallRow = ({ call, showUsage = true, labels }) => {
|
|
3300
2624
|
const L = useLabels(labels);
|
|
@@ -3363,7 +2687,7 @@ var StepItem = ({
|
|
|
3363
2687
|
step.text.trim() && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("p", { className: "awr-step__text", children: step.text.trim() }),
|
|
3364
2688
|
showToolCalls && step.toolCalls.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "awr-step__tools", children: step.toolCalls.map((call, i) => {
|
|
3365
2689
|
const row = /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ToolCallRow, { call, showUsage }, i);
|
|
3366
|
-
return renderToolCall ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2690
|
+
return renderToolCall ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react12.Fragment, { children: renderToolCall(call, row) }, i) : row;
|
|
3367
2691
|
}) }),
|
|
3368
2692
|
approvals.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("ul", { className: "awr-step__tools", children: approvals.map((a) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("li", { className: `awr-tool awr-tool__row awr-tool--approval-${a.status}`, children: [
|
|
3369
2693
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ShieldIcon, { size: 13, className: "awr-tool__icon" }),
|
|
@@ -3639,7 +2963,7 @@ var AgentChatInner = ({
|
|
|
3639
2963
|
}
|
|
3640
2964
|
const L = useLabels();
|
|
3641
2965
|
const external = isHistoryHook(history) ? history : void 0;
|
|
3642
|
-
const [ownStore] = (0,
|
|
2966
|
+
const [ownStore] = (0, import_react13.useState)(
|
|
3643
2967
|
() => history instanceof ChatHistoryStore ? history : new ChatHistoryStore()
|
|
3644
2968
|
);
|
|
3645
2969
|
const own = useChatHistory(agent, {
|
|
@@ -3647,9 +2971,9 @@ var AgentChatInner = ({
|
|
|
3647
2971
|
enabled: Boolean(history) && !external
|
|
3648
2972
|
});
|
|
3649
2973
|
const chats = history ? external ?? own : void 0;
|
|
3650
|
-
const rootRef = (0,
|
|
3651
|
-
const [narrow, setNarrow] = (0,
|
|
3652
|
-
(0,
|
|
2974
|
+
const rootRef = (0, import_react13.useRef)(null);
|
|
2975
|
+
const [narrow, setNarrow] = (0, import_react13.useState)(void 0);
|
|
2976
|
+
(0, import_react13.useEffect)(() => {
|
|
3653
2977
|
const el = rootRef.current;
|
|
3654
2978
|
if (!el || typeof ResizeObserver === "undefined") return setNarrow(false);
|
|
3655
2979
|
const measure = () => setNarrow(el.getBoundingClientRect().width < narrowWidth);
|
|
@@ -3658,9 +2982,9 @@ var AgentChatInner = ({
|
|
|
3658
2982
|
ro.observe(el);
|
|
3659
2983
|
return () => ro.disconnect();
|
|
3660
2984
|
}, [narrowWidth]);
|
|
3661
|
-
const [historyChoice, setHistoryOpen] = (0,
|
|
2985
|
+
const [historyChoice, setHistoryOpen] = (0, import_react13.useState)(defaultHistoryOpen);
|
|
3662
2986
|
const historyOpen = historyChoice ?? narrow === false;
|
|
3663
|
-
const [filesOpen, setFilesOpen] = (0,
|
|
2987
|
+
const [filesOpen, setFilesOpen] = (0, import_react13.useState)(defaultFilesOpen);
|
|
3664
2988
|
const toggleHistory = () => {
|
|
3665
2989
|
setHistoryOpen(!historyOpen);
|
|
3666
2990
|
if (narrow && !historyOpen) setFilesOpen(false);
|
|
@@ -3669,13 +2993,13 @@ var AgentChatInner = ({
|
|
|
3669
2993
|
setFilesOpen((o) => !o);
|
|
3670
2994
|
if (narrow && !filesOpen) setHistoryOpen(false);
|
|
3671
2995
|
};
|
|
3672
|
-
const bodyRef = (0,
|
|
3673
|
-
const stickRef = (0,
|
|
3674
|
-
(0,
|
|
2996
|
+
const bodyRef = (0, import_react13.useRef)(null);
|
|
2997
|
+
const stickRef = (0, import_react13.useRef)(true);
|
|
2998
|
+
(0, import_react13.useEffect)(() => {
|
|
3675
2999
|
const el = bodyRef.current;
|
|
3676
3000
|
if (el && stickRef.current) el.scrollTop = el.scrollHeight;
|
|
3677
3001
|
}, [agent.messages, agent.steps, agent.finalText, agent.modelLoad, agent.pendingApprovals]);
|
|
3678
|
-
const [compacting, setCompacting] = (0,
|
|
3002
|
+
const [compacting, setCompacting] = (0, import_react13.useState)(false);
|
|
3679
3003
|
const compact = () => {
|
|
3680
3004
|
setCompacting(true);
|
|
3681
3005
|
void agent.compact().finally(() => setCompacting(false));
|
|
@@ -3860,7 +3184,7 @@ var AgentChatInner = ({
|
|
|
3860
3184
|
};
|
|
3861
3185
|
|
|
3862
3186
|
// src/components/Composer.tsx
|
|
3863
|
-
var
|
|
3187
|
+
var import_react14 = require("react");
|
|
3864
3188
|
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3865
3189
|
var Composer = ({
|
|
3866
3190
|
onSubmit,
|
|
@@ -3870,7 +3194,7 @@ var Composer = ({
|
|
|
3870
3194
|
placeholder = "Ask the agent to do something\u2026",
|
|
3871
3195
|
className
|
|
3872
3196
|
}) => {
|
|
3873
|
-
const [text, setText] = (0,
|
|
3197
|
+
const [text, setText] = (0, import_react14.useState)("");
|
|
3874
3198
|
const submit = () => {
|
|
3875
3199
|
const value = text.trim();
|
|
3876
3200
|
if (!value || busy || disabled) return;
|
|
@@ -3983,7 +3307,7 @@ var ApprovalModeSwitch = ({
|
|
|
3983
3307
|
);
|
|
3984
3308
|
|
|
3985
3309
|
// src/components/ApiKeyForm.tsx
|
|
3986
|
-
var
|
|
3310
|
+
var import_react15 = require("react");
|
|
3987
3311
|
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3988
3312
|
var ApiKeyForm = ({
|
|
3989
3313
|
credentials,
|
|
@@ -3993,10 +3317,10 @@ var ApiKeyForm = ({
|
|
|
3993
3317
|
onChange,
|
|
3994
3318
|
className
|
|
3995
3319
|
}) => {
|
|
3996
|
-
const [value, setValue] = (0,
|
|
3997
|
-
const [present, setPresent] = (0,
|
|
3998
|
-
const [busy, setBusy] = (0,
|
|
3999
|
-
(0,
|
|
3320
|
+
const [value, setValue] = (0, import_react15.useState)("");
|
|
3321
|
+
const [present, setPresent] = (0, import_react15.useState)(false);
|
|
3322
|
+
const [busy, setBusy] = (0, import_react15.useState)(false);
|
|
3323
|
+
(0, import_react15.useEffect)(() => {
|
|
4000
3324
|
let active = true;
|
|
4001
3325
|
credentials.hasKey(credentialRef).then((has) => {
|
|
4002
3326
|
if (active) setPresent(has);
|
|
@@ -4114,7 +3438,6 @@ var import_agent_web4 = require("@dudko.dev/agent-web");
|
|
|
4114
3438
|
attachmentKindOf,
|
|
4115
3439
|
attachmentRefusal,
|
|
4116
3440
|
chatTitle,
|
|
4117
|
-
claimOAuthCallback,
|
|
4118
3441
|
createAgent,
|
|
4119
3442
|
createFileTools,
|
|
4120
3443
|
createInitialAgentState,
|
|
@@ -4124,11 +3447,9 @@ var import_agent_web4 = require("@dudko.dev/agent-web");
|
|
|
4124
3447
|
defaultLabels,
|
|
4125
3448
|
defineSkill,
|
|
4126
3449
|
defineTool,
|
|
4127
|
-
describeMcpResult,
|
|
4128
3450
|
downscaleImage,
|
|
4129
3451
|
filterCommands,
|
|
4130
3452
|
formatElapsed,
|
|
4131
|
-
isUnauthorizedError,
|
|
4132
3453
|
isWebGPUAvailable,
|
|
4133
3454
|
loadSkillFromUrl,
|
|
4134
3455
|
markReadOnly,
|
|
@@ -4138,9 +3459,7 @@ var import_agent_web4 = require("@dudko.dev/agent-web");
|
|
|
4138
3459
|
parseSkillMarkdown,
|
|
4139
3460
|
parseSlash,
|
|
4140
3461
|
preloadWebLLMModel,
|
|
4141
|
-
readCallbackParams,
|
|
4142
3462
|
serveSubagentWorker,
|
|
4143
|
-
stripOAuthParams,
|
|
4144
3463
|
supportsImages,
|
|
4145
3464
|
supportsPdf,
|
|
4146
3465
|
unloadWebLLMModel,
|
|
@@ -4151,8 +3470,6 @@ var import_agent_web4 = require("@dudko.dev/agent-web");
|
|
|
4151
3470
|
useCredentials,
|
|
4152
3471
|
useLabels,
|
|
4153
3472
|
useLocalModel,
|
|
4154
|
-
useMcp,
|
|
4155
|
-
useMcpServers,
|
|
4156
3473
|
useOptionalAgentContext,
|
|
4157
3474
|
useSpeechToText,
|
|
4158
3475
|
useVirtualFiles,
|