@personaai/react 0.14.0 → 0.16.0
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/index.cjs +301 -184
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +46 -6
- package/dist/index.d.ts +46 -6
- package/dist/index.js +286 -170
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -48,7 +48,8 @@ __export(index_exports, {
|
|
|
48
48
|
useWorkflow: () => useWorkflow,
|
|
49
49
|
useWorkflowRuns: () => useWorkflowRuns,
|
|
50
50
|
useWorkflowStream: () => useWorkflowStream,
|
|
51
|
-
useWorkflows: () => useWorkflows
|
|
51
|
+
useWorkflows: () => useWorkflows,
|
|
52
|
+
useWorkspaceFiles: () => useWorkspaceFiles
|
|
52
53
|
});
|
|
53
54
|
module.exports = __toCommonJS(index_exports);
|
|
54
55
|
|
|
@@ -1720,7 +1721,8 @@ function useMemory(autoFetch = true) {
|
|
|
1720
1721
|
const { fetchWithAuth } = usePersonaContext();
|
|
1721
1722
|
const [memory, setMemory] = (0, import_react4.useState)({
|
|
1722
1723
|
userFiles: [],
|
|
1723
|
-
agentMemories: []
|
|
1724
|
+
agentMemories: [],
|
|
1725
|
+
agentWorkspaces: []
|
|
1724
1726
|
});
|
|
1725
1727
|
const [isLoading, setIsLoading] = (0, import_react4.useState)(false);
|
|
1726
1728
|
const [error, setError] = (0, import_react4.useState)(null);
|
|
@@ -1738,7 +1740,7 @@ function useMemory(autoFetch = true) {
|
|
|
1738
1740
|
} catch (err) {
|
|
1739
1741
|
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
1740
1742
|
setError(errorObj);
|
|
1741
|
-
return { userFiles: [], agentMemories: [] };
|
|
1743
|
+
return { userFiles: [], agentMemories: [], agentWorkspaces: [] };
|
|
1742
1744
|
} finally {
|
|
1743
1745
|
setIsLoading(false);
|
|
1744
1746
|
}
|
|
@@ -1943,8 +1945,122 @@ function useThreads(autoFetch = true) {
|
|
|
1943
1945
|
};
|
|
1944
1946
|
}
|
|
1945
1947
|
|
|
1946
|
-
// src/hooks/
|
|
1948
|
+
// src/hooks/useWorkspaceFiles.ts
|
|
1947
1949
|
var import_react6 = require("react");
|
|
1950
|
+
function toWorkspaceFile(file) {
|
|
1951
|
+
return {
|
|
1952
|
+
content: file.content,
|
|
1953
|
+
size: file.content.length,
|
|
1954
|
+
createdAt: file.createdAt ?? null,
|
|
1955
|
+
modifiedAt: file.updatedAt ?? null
|
|
1956
|
+
};
|
|
1957
|
+
}
|
|
1958
|
+
function useWorkspaceFiles(agentId, autoFetch = true) {
|
|
1959
|
+
const { fetchWithAuth } = usePersonaContext();
|
|
1960
|
+
const [files, setFiles] = (0, import_react6.useState)({});
|
|
1961
|
+
const [isLoading, setIsLoading] = (0, import_react6.useState)(false);
|
|
1962
|
+
const [isSaving, setIsSaving] = (0, import_react6.useState)(false);
|
|
1963
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
1964
|
+
const fetchFiles = (0, import_react6.useCallback)(async () => {
|
|
1965
|
+
if (!agentId) return {};
|
|
1966
|
+
setIsLoading(true);
|
|
1967
|
+
setError(null);
|
|
1968
|
+
try {
|
|
1969
|
+
const res = await fetchWithAuth("/memory");
|
|
1970
|
+
if (!res.ok) throw new Error(`Failed to list workspace files: ${res.statusText}`);
|
|
1971
|
+
const data = await res.json();
|
|
1972
|
+
const body = data?.data ?? data;
|
|
1973
|
+
const group = (body?.agentWorkspaces ?? []).find(
|
|
1974
|
+
(g) => g.agentId === agentId
|
|
1975
|
+
);
|
|
1976
|
+
const normalized = {};
|
|
1977
|
+
for (const file of group?.files ?? []) {
|
|
1978
|
+
normalized[file.path] = toWorkspaceFile(file);
|
|
1979
|
+
}
|
|
1980
|
+
setFiles(normalized);
|
|
1981
|
+
return normalized;
|
|
1982
|
+
} catch (err) {
|
|
1983
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
1984
|
+
setError(errorObj);
|
|
1985
|
+
return {};
|
|
1986
|
+
} finally {
|
|
1987
|
+
setIsLoading(false);
|
|
1988
|
+
}
|
|
1989
|
+
}, [fetchWithAuth, agentId]);
|
|
1990
|
+
const getFile = (0, import_react6.useCallback)(
|
|
1991
|
+
async (path) => {
|
|
1992
|
+
if (!agentId) throw new Error("useWorkspaceFiles: no agentId set");
|
|
1993
|
+
const query = new URLSearchParams({ path, scope: "workspace", agentId });
|
|
1994
|
+
const res = await fetchWithAuth(`/memory/file?${query.toString()}`);
|
|
1995
|
+
if (!res.ok) throw new Error(`Failed to read workspace file: ${res.statusText}`);
|
|
1996
|
+
const data = await res.json();
|
|
1997
|
+
const raw = data?.data ?? data;
|
|
1998
|
+
return toWorkspaceFile(raw);
|
|
1999
|
+
},
|
|
2000
|
+
[fetchWithAuth, agentId]
|
|
2001
|
+
);
|
|
2002
|
+
const writeFile = (0, import_react6.useCallback)(
|
|
2003
|
+
async (path, content) => {
|
|
2004
|
+
if (!agentId) throw new Error("useWorkspaceFiles: no agentId set");
|
|
2005
|
+
setIsSaving(true);
|
|
2006
|
+
setError(null);
|
|
2007
|
+
try {
|
|
2008
|
+
const res = await fetchWithAuth("/memory/file", {
|
|
2009
|
+
method: "PUT",
|
|
2010
|
+
headers: { "Content-Type": "application/json" },
|
|
2011
|
+
body: JSON.stringify({ path, content, scope: "workspace", agentId })
|
|
2012
|
+
});
|
|
2013
|
+
if (!res.ok) throw new Error(`Failed to write workspace file: ${res.statusText}`);
|
|
2014
|
+
const data = await res.json();
|
|
2015
|
+
const raw = data?.data ?? data;
|
|
2016
|
+
const file = toWorkspaceFile(raw);
|
|
2017
|
+
setFiles((prev) => ({ ...prev, [path]: file }));
|
|
2018
|
+
return file;
|
|
2019
|
+
} catch (err) {
|
|
2020
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
2021
|
+
setError(errorObj);
|
|
2022
|
+
throw errorObj;
|
|
2023
|
+
} finally {
|
|
2024
|
+
setIsSaving(false);
|
|
2025
|
+
}
|
|
2026
|
+
},
|
|
2027
|
+
[fetchWithAuth, agentId]
|
|
2028
|
+
);
|
|
2029
|
+
const deleteFile = (0, import_react6.useCallback)(
|
|
2030
|
+
async (path) => {
|
|
2031
|
+
if (!agentId) throw new Error("useWorkspaceFiles: no agentId set");
|
|
2032
|
+
const query = new URLSearchParams({ path, scope: "workspace", agentId });
|
|
2033
|
+
const res = await fetchWithAuth(`/memory/file?${query.toString()}`, { method: "DELETE" });
|
|
2034
|
+
if (!res.ok) throw new Error(`Failed to delete workspace file: ${res.statusText}`);
|
|
2035
|
+
setFiles((prev) => {
|
|
2036
|
+
const next = { ...prev };
|
|
2037
|
+
delete next[path];
|
|
2038
|
+
return next;
|
|
2039
|
+
});
|
|
2040
|
+
},
|
|
2041
|
+
[fetchWithAuth, agentId]
|
|
2042
|
+
);
|
|
2043
|
+
(0, import_react6.useEffect)(() => {
|
|
2044
|
+
if (autoFetch && agentId) {
|
|
2045
|
+
void fetchFiles();
|
|
2046
|
+
} else if (!agentId) {
|
|
2047
|
+
setFiles({});
|
|
2048
|
+
}
|
|
2049
|
+
}, [autoFetch, agentId, fetchFiles]);
|
|
2050
|
+
return {
|
|
2051
|
+
files,
|
|
2052
|
+
isLoading,
|
|
2053
|
+
isSaving,
|
|
2054
|
+
error,
|
|
2055
|
+
refetch: fetchFiles,
|
|
2056
|
+
getFile,
|
|
2057
|
+
writeFile,
|
|
2058
|
+
deleteFile
|
|
2059
|
+
};
|
|
2060
|
+
}
|
|
2061
|
+
|
|
2062
|
+
// src/hooks/useVoice.ts
|
|
2063
|
+
var import_react7 = require("react");
|
|
1948
2064
|
|
|
1949
2065
|
// src/hooks/voiceWorklets.ts
|
|
1950
2066
|
var RECORDER_WORKLET_SOURCE = `
|
|
@@ -2047,42 +2163,42 @@ function mergeTranscriptText(prev, next) {
|
|
|
2047
2163
|
}
|
|
2048
2164
|
function useVoice(options = {}) {
|
|
2049
2165
|
const { defaultAgentId, fetchWithAuth, logger } = usePersonaContext();
|
|
2050
|
-
const voiceLogger = (0,
|
|
2166
|
+
const voiceLogger = (0, import_react7.useMemo)(() => logger.child("voice"), [logger]);
|
|
2051
2167
|
const agentId = options.agentId || defaultAgentId;
|
|
2052
2168
|
const threadId = options.threadId;
|
|
2053
2169
|
const contextOverride = options.contextOverride;
|
|
2054
2170
|
const context = options.context;
|
|
2055
|
-
const [state, setState] = (0,
|
|
2056
|
-
const [isMuted, setIsMuted] = (0,
|
|
2057
|
-
const [transcript, setTranscript] = (0,
|
|
2171
|
+
const [state, setState] = (0, import_react7.useState)("idle");
|
|
2172
|
+
const [isMuted, setIsMuted] = (0, import_react7.useState)(false);
|
|
2173
|
+
const [transcript, setTranscript] = (0, import_react7.useState)(
|
|
2058
2174
|
[]
|
|
2059
2175
|
);
|
|
2060
|
-
const [partial, setPartial] = (0,
|
|
2176
|
+
const [partial, setPartial] = (0, import_react7.useState)(
|
|
2061
2177
|
null
|
|
2062
2178
|
);
|
|
2063
|
-
const [toolCalls, setToolCalls] = (0,
|
|
2064
|
-
const [error, setError] = (0,
|
|
2065
|
-
const [endReason, setEndReason] = (0,
|
|
2179
|
+
const [toolCalls, setToolCalls] = (0, import_react7.useState)([]);
|
|
2180
|
+
const [error, setError] = (0, import_react7.useState)(null);
|
|
2181
|
+
const [endReason, setEndReason] = (0, import_react7.useState)(
|
|
2066
2182
|
null
|
|
2067
2183
|
);
|
|
2068
|
-
const wsRef = (0,
|
|
2069
|
-
const streamRef = (0,
|
|
2070
|
-
const inputCtxRef = (0,
|
|
2071
|
-
const outputCtxRef = (0,
|
|
2072
|
-
const recorderNodeRef = (0,
|
|
2073
|
-
const playerNodeRef = (0,
|
|
2074
|
-
const acceptedTurnSeqRef = (0,
|
|
2075
|
-
const mountedRef = (0,
|
|
2076
|
-
const lastFinalTurnRef = (0,
|
|
2184
|
+
const wsRef = (0, import_react7.useRef)(null);
|
|
2185
|
+
const streamRef = (0, import_react7.useRef)(null);
|
|
2186
|
+
const inputCtxRef = (0, import_react7.useRef)(null);
|
|
2187
|
+
const outputCtxRef = (0, import_react7.useRef)(null);
|
|
2188
|
+
const recorderNodeRef = (0, import_react7.useRef)(null);
|
|
2189
|
+
const playerNodeRef = (0, import_react7.useRef)(null);
|
|
2190
|
+
const acceptedTurnSeqRef = (0, import_react7.useRef)(0);
|
|
2191
|
+
const mountedRef = (0, import_react7.useRef)(true);
|
|
2192
|
+
const lastFinalTurnRef = (0, import_react7.useRef)(
|
|
2077
2193
|
null
|
|
2078
2194
|
);
|
|
2079
|
-
(0,
|
|
2195
|
+
(0, import_react7.useEffect)(() => {
|
|
2080
2196
|
mountedRef.current = true;
|
|
2081
2197
|
return () => {
|
|
2082
2198
|
mountedRef.current = false;
|
|
2083
2199
|
};
|
|
2084
2200
|
}, []);
|
|
2085
|
-
const teardownAudio = (0,
|
|
2201
|
+
const teardownAudio = (0, import_react7.useCallback)(() => {
|
|
2086
2202
|
try {
|
|
2087
2203
|
streamRef.current?.getTracks().forEach((track) => track.stop());
|
|
2088
2204
|
} catch {
|
|
@@ -2109,7 +2225,7 @@ function useVoice(options = {}) {
|
|
|
2109
2225
|
}
|
|
2110
2226
|
outputCtxRef.current = null;
|
|
2111
2227
|
}, []);
|
|
2112
|
-
const stop = (0,
|
|
2228
|
+
const stop = (0, import_react7.useCallback)(() => {
|
|
2113
2229
|
voiceLogger.debug("stop() called");
|
|
2114
2230
|
try {
|
|
2115
2231
|
wsRef.current?.close(1e3, "client_stop");
|
|
@@ -2119,8 +2235,8 @@ function useVoice(options = {}) {
|
|
|
2119
2235
|
teardownAudio();
|
|
2120
2236
|
if (mountedRef.current) setState("idle");
|
|
2121
2237
|
}, [teardownAudio, voiceLogger]);
|
|
2122
|
-
(0,
|
|
2123
|
-
const startCapture = (0,
|
|
2238
|
+
(0, import_react7.useEffect)(() => stop, [stop]);
|
|
2239
|
+
const startCapture = (0, import_react7.useCallback)(async (inputSampleRate) => {
|
|
2124
2240
|
const stream = await navigator.mediaDevices.getUserMedia({
|
|
2125
2241
|
audio: {
|
|
2126
2242
|
echoCancellation: true,
|
|
@@ -2146,7 +2262,7 @@ function useVoice(options = {}) {
|
|
|
2146
2262
|
recorderNodeRef.current = recorderNode;
|
|
2147
2263
|
source.connect(recorderNode);
|
|
2148
2264
|
}, []);
|
|
2149
|
-
const setupPlayback = (0,
|
|
2265
|
+
const setupPlayback = (0, import_react7.useCallback)(async (outputSampleRate) => {
|
|
2150
2266
|
const outputCtx = new AudioContext({ sampleRate: outputSampleRate });
|
|
2151
2267
|
outputCtxRef.current = outputCtx;
|
|
2152
2268
|
await outputCtx.audioWorklet.addModule(playerWorkletUrl());
|
|
@@ -2154,7 +2270,7 @@ function useVoice(options = {}) {
|
|
|
2154
2270
|
playerNode.connect(outputCtx.destination);
|
|
2155
2271
|
playerNodeRef.current = playerNode;
|
|
2156
2272
|
}, []);
|
|
2157
|
-
const upsertToolCall = (0,
|
|
2273
|
+
const upsertToolCall = (0, import_react7.useCallback)(
|
|
2158
2274
|
(id, patch) => {
|
|
2159
2275
|
setToolCalls((prev) => {
|
|
2160
2276
|
const idx = prev.findIndex((t) => t.id === id);
|
|
@@ -2166,7 +2282,7 @@ function useVoice(options = {}) {
|
|
|
2166
2282
|
},
|
|
2167
2283
|
[]
|
|
2168
2284
|
);
|
|
2169
|
-
const handleTranscript = (0,
|
|
2285
|
+
const handleTranscript = (0, import_react7.useCallback)((value) => {
|
|
2170
2286
|
const { speaker, text, isFinal, turnSeq } = value;
|
|
2171
2287
|
if (!isFinal) {
|
|
2172
2288
|
setPartial({ id: "partial", speaker, text });
|
|
@@ -2189,7 +2305,7 @@ function useVoice(options = {}) {
|
|
|
2189
2305
|
});
|
|
2190
2306
|
lastFinalTurnRef.current = { speaker, turnSeq };
|
|
2191
2307
|
}, []);
|
|
2192
|
-
const handleCustomEvent = (0,
|
|
2308
|
+
const handleCustomEvent = (0, import_react7.useCallback)(
|
|
2193
2309
|
(name, value) => {
|
|
2194
2310
|
switch (name) {
|
|
2195
2311
|
case "voice_session_ready":
|
|
@@ -2247,7 +2363,7 @@ function useVoice(options = {}) {
|
|
|
2247
2363
|
},
|
|
2248
2364
|
[handleTranscript, setupPlayback, startCapture, teardownAudio, voiceLogger]
|
|
2249
2365
|
);
|
|
2250
|
-
const handleMessage = (0,
|
|
2366
|
+
const handleMessage = (0, import_react7.useCallback)(
|
|
2251
2367
|
(event) => {
|
|
2252
2368
|
if (typeof event.data !== "string") {
|
|
2253
2369
|
const buf = event.data;
|
|
@@ -2305,7 +2421,7 @@ function useVoice(options = {}) {
|
|
|
2305
2421
|
},
|
|
2306
2422
|
[handleCustomEvent, upsertToolCall, voiceLogger]
|
|
2307
2423
|
);
|
|
2308
|
-
const start = (0,
|
|
2424
|
+
const start = (0, import_react7.useCallback)(async () => {
|
|
2309
2425
|
if (!agentId) {
|
|
2310
2426
|
const err = new Error(
|
|
2311
2427
|
"useVoice: no agentId provided and no defaultAgentId set on PersonaProvider"
|
|
@@ -2372,17 +2488,17 @@ function useVoice(options = {}) {
|
|
|
2372
2488
|
teardownAudio();
|
|
2373
2489
|
}
|
|
2374
2490
|
}, [agentId, threadId, contextOverride, context, fetchWithAuth, handleMessage, teardownAudio, voiceLogger]);
|
|
2375
|
-
const mute = (0,
|
|
2491
|
+
const mute = (0, import_react7.useCallback)((muted) => {
|
|
2376
2492
|
setIsMuted(muted);
|
|
2377
2493
|
streamRef.current?.getAudioTracks().forEach((track) => {
|
|
2378
2494
|
track.enabled = !muted;
|
|
2379
2495
|
});
|
|
2380
2496
|
}, []);
|
|
2381
|
-
const sendText = (0,
|
|
2497
|
+
const sendText = (0, import_react7.useCallback)((text) => {
|
|
2382
2498
|
if (!text?.trim() || wsRef.current?.readyState !== WebSocket.OPEN) return;
|
|
2383
2499
|
wsRef.current.send(JSON.stringify({ type: "voice.text", text }));
|
|
2384
2500
|
}, []);
|
|
2385
|
-
const updateContext = (0,
|
|
2501
|
+
const updateContext = (0, import_react7.useCallback)((newContext) => {
|
|
2386
2502
|
if (wsRef.current?.readyState !== WebSocket.OPEN) return;
|
|
2387
2503
|
wsRef.current.send(JSON.stringify({ type: "voice.context", context: newContext }));
|
|
2388
2504
|
}, []);
|
|
@@ -2403,14 +2519,14 @@ function useVoice(options = {}) {
|
|
|
2403
2519
|
}
|
|
2404
2520
|
|
|
2405
2521
|
// src/hooks/useFiles.ts
|
|
2406
|
-
var
|
|
2522
|
+
var import_react8 = require("react");
|
|
2407
2523
|
function useFiles(autoFetch = true) {
|
|
2408
2524
|
const { fetchWithAuth } = usePersonaContext();
|
|
2409
|
-
const [files, setFiles] = (0,
|
|
2410
|
-
const [isLoading, setIsLoading] = (0,
|
|
2411
|
-
const [isUploading, setIsUploading] = (0,
|
|
2412
|
-
const [error, setError] = (0,
|
|
2413
|
-
const fetchFiles = (0,
|
|
2525
|
+
const [files, setFiles] = (0, import_react8.useState)([]);
|
|
2526
|
+
const [isLoading, setIsLoading] = (0, import_react8.useState)(false);
|
|
2527
|
+
const [isUploading, setIsUploading] = (0, import_react8.useState)(false);
|
|
2528
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
2529
|
+
const fetchFiles = (0, import_react8.useCallback)(async () => {
|
|
2414
2530
|
setIsLoading(true);
|
|
2415
2531
|
setError(null);
|
|
2416
2532
|
try {
|
|
@@ -2428,7 +2544,7 @@ function useFiles(autoFetch = true) {
|
|
|
2428
2544
|
setIsLoading(false);
|
|
2429
2545
|
}
|
|
2430
2546
|
}, [fetchWithAuth]);
|
|
2431
|
-
const uploadFile = (0,
|
|
2547
|
+
const uploadFile = (0, import_react8.useCallback)(
|
|
2432
2548
|
async (fileOrFormData) => {
|
|
2433
2549
|
setIsUploading(true);
|
|
2434
2550
|
setError(null);
|
|
@@ -2461,7 +2577,7 @@ function useFiles(autoFetch = true) {
|
|
|
2461
2577
|
},
|
|
2462
2578
|
[fetchWithAuth, fetchFiles]
|
|
2463
2579
|
);
|
|
2464
|
-
const deleteFile = (0,
|
|
2580
|
+
const deleteFile = (0, import_react8.useCallback)(
|
|
2465
2581
|
async (fileId) => {
|
|
2466
2582
|
const res = await fetchWithAuth(`/files/${fileId}`, { method: "DELETE" });
|
|
2467
2583
|
if (!res.ok) throw new Error(`Failed to delete file: ${res.statusText}`);
|
|
@@ -2469,7 +2585,7 @@ function useFiles(autoFetch = true) {
|
|
|
2469
2585
|
},
|
|
2470
2586
|
[fetchWithAuth]
|
|
2471
2587
|
);
|
|
2472
|
-
const bulkDeleteFiles = (0,
|
|
2588
|
+
const bulkDeleteFiles = (0, import_react8.useCallback)(
|
|
2473
2589
|
async (fileIds) => {
|
|
2474
2590
|
const res = await fetchWithAuth("/files/bulk-delete", {
|
|
2475
2591
|
method: "POST",
|
|
@@ -2484,10 +2600,10 @@ function useFiles(autoFetch = true) {
|
|
|
2484
2600
|
},
|
|
2485
2601
|
[fetchWithAuth]
|
|
2486
2602
|
);
|
|
2487
|
-
const getDownloadUrl = (0,
|
|
2603
|
+
const getDownloadUrl = (0, import_react8.useCallback)((fileId) => {
|
|
2488
2604
|
return `/files/${fileId}`;
|
|
2489
2605
|
}, []);
|
|
2490
|
-
(0,
|
|
2606
|
+
(0, import_react8.useEffect)(() => {
|
|
2491
2607
|
if (autoFetch) {
|
|
2492
2608
|
void fetchFiles();
|
|
2493
2609
|
}
|
|
@@ -2506,21 +2622,21 @@ function useFiles(autoFetch = true) {
|
|
|
2506
2622
|
}
|
|
2507
2623
|
|
|
2508
2624
|
// src/hooks/useAgents.ts
|
|
2509
|
-
var
|
|
2625
|
+
var import_react9 = require("react");
|
|
2510
2626
|
function useAgents(options = true) {
|
|
2511
2627
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options;
|
|
2512
2628
|
const { autoFetch = true, page, limit, search, category, scope } = opts;
|
|
2513
2629
|
const { fetchWithAuth } = usePersonaContext();
|
|
2514
|
-
const [agents, setAgents] = (0,
|
|
2515
|
-
const [pagination, setPagination] = (0,
|
|
2630
|
+
const [agents, setAgents] = (0, import_react9.useState)([]);
|
|
2631
|
+
const [pagination, setPagination] = (0, import_react9.useState)({
|
|
2516
2632
|
total: 0,
|
|
2517
2633
|
page: page ?? 1,
|
|
2518
2634
|
limit: limit ?? 20,
|
|
2519
2635
|
pages: 0
|
|
2520
2636
|
});
|
|
2521
|
-
const [isLoading, setIsLoading] = (0,
|
|
2522
|
-
const [error, setError] = (0,
|
|
2523
|
-
const fetchAgents = (0,
|
|
2637
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
2638
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
2639
|
+
const fetchAgents = (0, import_react9.useCallback)(async () => {
|
|
2524
2640
|
setIsLoading(true);
|
|
2525
2641
|
setError(null);
|
|
2526
2642
|
try {
|
|
@@ -2548,7 +2664,7 @@ function useAgents(options = true) {
|
|
|
2548
2664
|
setIsLoading(false);
|
|
2549
2665
|
}
|
|
2550
2666
|
}, [fetchWithAuth, page, limit, search, category, scope]);
|
|
2551
|
-
const getAgent = (0,
|
|
2667
|
+
const getAgent = (0, import_react9.useCallback)(
|
|
2552
2668
|
async (agentId) => {
|
|
2553
2669
|
const res = await fetchWithAuth(`/agents/${agentId}`);
|
|
2554
2670
|
if (!res.ok) throw new Error(`Failed to fetch agent: ${res.statusText}`);
|
|
@@ -2556,7 +2672,7 @@ function useAgents(options = true) {
|
|
|
2556
2672
|
},
|
|
2557
2673
|
[fetchWithAuth]
|
|
2558
2674
|
);
|
|
2559
|
-
const createAgent = (0,
|
|
2675
|
+
const createAgent = (0, import_react9.useCallback)(
|
|
2560
2676
|
async (input) => {
|
|
2561
2677
|
setError(null);
|
|
2562
2678
|
try {
|
|
@@ -2580,7 +2696,7 @@ function useAgents(options = true) {
|
|
|
2580
2696
|
},
|
|
2581
2697
|
[fetchWithAuth]
|
|
2582
2698
|
);
|
|
2583
|
-
const updateAgent = (0,
|
|
2699
|
+
const updateAgent = (0, import_react9.useCallback)(
|
|
2584
2700
|
async (agentId, input) => {
|
|
2585
2701
|
setError(null);
|
|
2586
2702
|
try {
|
|
@@ -2604,7 +2720,7 @@ function useAgents(options = true) {
|
|
|
2604
2720
|
},
|
|
2605
2721
|
[fetchWithAuth]
|
|
2606
2722
|
);
|
|
2607
|
-
const deleteAgent = (0,
|
|
2723
|
+
const deleteAgent = (0, import_react9.useCallback)(
|
|
2608
2724
|
async (agentId) => {
|
|
2609
2725
|
setError(null);
|
|
2610
2726
|
try {
|
|
@@ -2622,7 +2738,7 @@ function useAgents(options = true) {
|
|
|
2622
2738
|
},
|
|
2623
2739
|
[fetchWithAuth]
|
|
2624
2740
|
);
|
|
2625
|
-
const bulkDeleteAgents = (0,
|
|
2741
|
+
const bulkDeleteAgents = (0, import_react9.useCallback)(
|
|
2626
2742
|
async (ids) => {
|
|
2627
2743
|
setError(null);
|
|
2628
2744
|
try {
|
|
@@ -2647,7 +2763,7 @@ function useAgents(options = true) {
|
|
|
2647
2763
|
},
|
|
2648
2764
|
[fetchWithAuth]
|
|
2649
2765
|
);
|
|
2650
|
-
(0,
|
|
2766
|
+
(0, import_react9.useEffect)(() => {
|
|
2651
2767
|
if (autoFetch) void fetchAgents();
|
|
2652
2768
|
}, [autoFetch, fetchAgents]);
|
|
2653
2769
|
return {
|
|
@@ -2665,13 +2781,13 @@ function useAgents(options = true) {
|
|
|
2665
2781
|
}
|
|
2666
2782
|
|
|
2667
2783
|
// src/hooks/useConnection.ts
|
|
2668
|
-
var
|
|
2784
|
+
var import_react10 = require("react");
|
|
2669
2785
|
function useConnection(autoCheck = true) {
|
|
2670
2786
|
const { fetchWithAuth } = usePersonaContext();
|
|
2671
|
-
const [health, setHealth] = (0,
|
|
2672
|
-
const [isConnected, setIsConnected] = (0,
|
|
2673
|
-
const [isLoading, setIsLoading] = (0,
|
|
2674
|
-
const checkHealth = (0,
|
|
2787
|
+
const [health, setHealth] = (0, import_react10.useState)(null);
|
|
2788
|
+
const [isConnected, setIsConnected] = (0, import_react10.useState)(false);
|
|
2789
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
|
|
2790
|
+
const checkHealth = (0, import_react10.useCallback)(async () => {
|
|
2675
2791
|
setIsLoading(true);
|
|
2676
2792
|
try {
|
|
2677
2793
|
const res = await fetchWithAuth("/health");
|
|
@@ -2690,7 +2806,7 @@ function useConnection(autoCheck = true) {
|
|
|
2690
2806
|
setIsLoading(false);
|
|
2691
2807
|
}
|
|
2692
2808
|
}, [fetchWithAuth]);
|
|
2693
|
-
(0,
|
|
2809
|
+
(0, import_react10.useEffect)(() => {
|
|
2694
2810
|
if (autoCheck) {
|
|
2695
2811
|
void checkHealth();
|
|
2696
2812
|
}
|
|
@@ -2704,15 +2820,15 @@ function useConnection(autoCheck = true) {
|
|
|
2704
2820
|
}
|
|
2705
2821
|
|
|
2706
2822
|
// src/hooks/useMcpConnections.ts
|
|
2707
|
-
var
|
|
2823
|
+
var import_react11 = require("react");
|
|
2708
2824
|
function useMcpConnections(options = {}) {
|
|
2709
2825
|
const { defaultAgentId, fetchWithAuth } = usePersonaContext();
|
|
2710
2826
|
const agentId = options.agentId ?? defaultAgentId;
|
|
2711
2827
|
const autoFetch = options.autoFetch ?? true;
|
|
2712
|
-
const [connections, setConnections] = (0,
|
|
2713
|
-
const [isLoading, setIsLoading] = (0,
|
|
2714
|
-
const [error, setError] = (0,
|
|
2715
|
-
const fetchConnections = (0,
|
|
2828
|
+
const [connections, setConnections] = (0, import_react11.useState)([]);
|
|
2829
|
+
const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
|
|
2830
|
+
const [error, setError] = (0, import_react11.useState)(null);
|
|
2831
|
+
const fetchConnections = (0, import_react11.useCallback)(async () => {
|
|
2716
2832
|
if (!agentId) return [];
|
|
2717
2833
|
setIsLoading(true);
|
|
2718
2834
|
setError(null);
|
|
@@ -2736,8 +2852,8 @@ function useMcpConnections(options = {}) {
|
|
|
2736
2852
|
setIsLoading(false);
|
|
2737
2853
|
}
|
|
2738
2854
|
}, [agentId, fetchWithAuth, options.returnTo]);
|
|
2739
|
-
const [isDisconnecting, setIsDisconnecting] = (0,
|
|
2740
|
-
const disconnect = (0,
|
|
2855
|
+
const [isDisconnecting, setIsDisconnecting] = (0, import_react11.useState)(false);
|
|
2856
|
+
const disconnect = (0, import_react11.useCallback)(
|
|
2741
2857
|
async (mcpId) => {
|
|
2742
2858
|
setIsDisconnecting(true);
|
|
2743
2859
|
setError(null);
|
|
@@ -2763,7 +2879,7 @@ function useMcpConnections(options = {}) {
|
|
|
2763
2879
|
},
|
|
2764
2880
|
[fetchWithAuth, fetchConnections]
|
|
2765
2881
|
);
|
|
2766
|
-
(0,
|
|
2882
|
+
(0, import_react11.useEffect)(() => {
|
|
2767
2883
|
if (autoFetch) void fetchConnections();
|
|
2768
2884
|
}, [autoFetch, fetchConnections]);
|
|
2769
2885
|
return {
|
|
@@ -2779,11 +2895,11 @@ function useMcpConnections(options = {}) {
|
|
|
2779
2895
|
}
|
|
2780
2896
|
|
|
2781
2897
|
// src/hooks/useMcp.ts
|
|
2782
|
-
var
|
|
2898
|
+
var import_react12 = require("react");
|
|
2783
2899
|
function useMcp(options = {}) {
|
|
2784
2900
|
const { fetchWithAuth } = usePersonaContext();
|
|
2785
2901
|
const defaultMcpId = options.mcpId;
|
|
2786
|
-
const readResource = (0,
|
|
2902
|
+
const readResource = (0, import_react12.useCallback)(
|
|
2787
2903
|
async (uri, mcpId) => {
|
|
2788
2904
|
const id = mcpId ?? defaultMcpId;
|
|
2789
2905
|
if (!id) throw new Error("MCP server ID is required to read resource");
|
|
@@ -2797,7 +2913,7 @@ function useMcp(options = {}) {
|
|
|
2797
2913
|
},
|
|
2798
2914
|
[fetchWithAuth, defaultMcpId]
|
|
2799
2915
|
);
|
|
2800
|
-
const callTool = (0,
|
|
2916
|
+
const callTool = (0, import_react12.useCallback)(
|
|
2801
2917
|
async (name, args, mcpId) => {
|
|
2802
2918
|
const id = mcpId ?? defaultMcpId;
|
|
2803
2919
|
if (!id) throw new Error("MCP server ID is required to call tool");
|
|
@@ -2820,20 +2936,20 @@ function useMcp(options = {}) {
|
|
|
2820
2936
|
}
|
|
2821
2937
|
|
|
2822
2938
|
// src/hooks/useSkills.ts
|
|
2823
|
-
var
|
|
2939
|
+
var import_react13 = require("react");
|
|
2824
2940
|
function useSkills(options = {}) {
|
|
2825
2941
|
const { autoFetch = true, page, limit, search, scope } = options;
|
|
2826
2942
|
const { fetchWithAuth } = usePersonaContext();
|
|
2827
|
-
const [skills, setSkills] = (0,
|
|
2828
|
-
const [pagination, setPagination] = (0,
|
|
2943
|
+
const [skills, setSkills] = (0, import_react13.useState)([]);
|
|
2944
|
+
const [pagination, setPagination] = (0, import_react13.useState)({
|
|
2829
2945
|
total: 0,
|
|
2830
2946
|
page: page ?? 1,
|
|
2831
2947
|
limit: limit ?? 20,
|
|
2832
2948
|
pages: 0
|
|
2833
2949
|
});
|
|
2834
|
-
const [isLoading, setIsLoading] = (0,
|
|
2835
|
-
const [error, setError] = (0,
|
|
2836
|
-
const fetchSkills = (0,
|
|
2950
|
+
const [isLoading, setIsLoading] = (0, import_react13.useState)(false);
|
|
2951
|
+
const [error, setError] = (0, import_react13.useState)(null);
|
|
2952
|
+
const fetchSkills = (0, import_react13.useCallback)(async () => {
|
|
2837
2953
|
setIsLoading(true);
|
|
2838
2954
|
setError(null);
|
|
2839
2955
|
try {
|
|
@@ -2860,7 +2976,7 @@ function useSkills(options = {}) {
|
|
|
2860
2976
|
setIsLoading(false);
|
|
2861
2977
|
}
|
|
2862
2978
|
}, [fetchWithAuth, page, limit, search, scope]);
|
|
2863
|
-
const getSkill = (0,
|
|
2979
|
+
const getSkill = (0, import_react13.useCallback)(
|
|
2864
2980
|
async (skillId) => {
|
|
2865
2981
|
const res = await fetchWithAuth(`/skills/${skillId}`);
|
|
2866
2982
|
if (!res.ok) throw new Error(`Failed to fetch skill: ${res.statusText}`);
|
|
@@ -2868,7 +2984,7 @@ function useSkills(options = {}) {
|
|
|
2868
2984
|
},
|
|
2869
2985
|
[fetchWithAuth]
|
|
2870
2986
|
);
|
|
2871
|
-
const createSkill = (0,
|
|
2987
|
+
const createSkill = (0, import_react13.useCallback)(
|
|
2872
2988
|
async (input) => {
|
|
2873
2989
|
setError(null);
|
|
2874
2990
|
try {
|
|
@@ -2892,7 +3008,7 @@ function useSkills(options = {}) {
|
|
|
2892
3008
|
},
|
|
2893
3009
|
[fetchWithAuth]
|
|
2894
3010
|
);
|
|
2895
|
-
const updateSkill = (0,
|
|
3011
|
+
const updateSkill = (0, import_react13.useCallback)(
|
|
2896
3012
|
async (skillId, input) => {
|
|
2897
3013
|
setError(null);
|
|
2898
3014
|
try {
|
|
@@ -2916,7 +3032,7 @@ function useSkills(options = {}) {
|
|
|
2916
3032
|
},
|
|
2917
3033
|
[fetchWithAuth]
|
|
2918
3034
|
);
|
|
2919
|
-
const deleteSkill = (0,
|
|
3035
|
+
const deleteSkill = (0, import_react13.useCallback)(
|
|
2920
3036
|
async (skillId) => {
|
|
2921
3037
|
setError(null);
|
|
2922
3038
|
try {
|
|
@@ -2934,7 +3050,7 @@ function useSkills(options = {}) {
|
|
|
2934
3050
|
},
|
|
2935
3051
|
[fetchWithAuth]
|
|
2936
3052
|
);
|
|
2937
|
-
const bulkDeleteSkills = (0,
|
|
3053
|
+
const bulkDeleteSkills = (0, import_react13.useCallback)(
|
|
2938
3054
|
async (ids) => {
|
|
2939
3055
|
setError(null);
|
|
2940
3056
|
try {
|
|
@@ -2959,7 +3075,7 @@ function useSkills(options = {}) {
|
|
|
2959
3075
|
},
|
|
2960
3076
|
[fetchWithAuth]
|
|
2961
3077
|
);
|
|
2962
|
-
const getSkillUsage = (0,
|
|
3078
|
+
const getSkillUsage = (0, import_react13.useCallback)(
|
|
2963
3079
|
async (skillId) => {
|
|
2964
3080
|
const res = await fetchWithAuth(`/skills/${skillId}/usage`);
|
|
2965
3081
|
if (!res.ok) throw new Error(`Failed to fetch skill usage: ${res.statusText}`);
|
|
@@ -2967,7 +3083,7 @@ function useSkills(options = {}) {
|
|
|
2967
3083
|
},
|
|
2968
3084
|
[fetchWithAuth]
|
|
2969
3085
|
);
|
|
2970
|
-
(0,
|
|
3086
|
+
(0, import_react13.useEffect)(() => {
|
|
2971
3087
|
if (autoFetch) void fetchSkills();
|
|
2972
3088
|
}, [autoFetch, fetchSkills]);
|
|
2973
3089
|
return {
|
|
@@ -2986,20 +3102,20 @@ function useSkills(options = {}) {
|
|
|
2986
3102
|
}
|
|
2987
3103
|
|
|
2988
3104
|
// src/hooks/useRcpSources.ts
|
|
2989
|
-
var
|
|
3105
|
+
var import_react14 = require("react");
|
|
2990
3106
|
function useRcpSources(options = {}) {
|
|
2991
3107
|
const { autoFetch = true, page, limit, search } = options;
|
|
2992
3108
|
const { fetchWithAuth } = usePersonaContext();
|
|
2993
|
-
const [rcpSources, setRcpSources] = (0,
|
|
2994
|
-
const [pagination, setPagination] = (0,
|
|
3109
|
+
const [rcpSources, setRcpSources] = (0, import_react14.useState)([]);
|
|
3110
|
+
const [pagination, setPagination] = (0, import_react14.useState)({
|
|
2995
3111
|
total: 0,
|
|
2996
3112
|
page: page ?? 1,
|
|
2997
3113
|
limit: limit ?? 20,
|
|
2998
3114
|
pages: 0
|
|
2999
3115
|
});
|
|
3000
|
-
const [isLoading, setIsLoading] = (0,
|
|
3001
|
-
const [error, setError] = (0,
|
|
3002
|
-
const fetchRcpSources = (0,
|
|
3116
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
|
|
3117
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
3118
|
+
const fetchRcpSources = (0, import_react14.useCallback)(async () => {
|
|
3003
3119
|
setIsLoading(true);
|
|
3004
3120
|
setError(null);
|
|
3005
3121
|
try {
|
|
@@ -3025,7 +3141,7 @@ function useRcpSources(options = {}) {
|
|
|
3025
3141
|
setIsLoading(false);
|
|
3026
3142
|
}
|
|
3027
3143
|
}, [fetchWithAuth, page, limit, search]);
|
|
3028
|
-
const getRcpSource = (0,
|
|
3144
|
+
const getRcpSource = (0, import_react14.useCallback)(
|
|
3029
3145
|
async (sourceId) => {
|
|
3030
3146
|
const res = await fetchWithAuth(`/rcp-sources/${sourceId}`);
|
|
3031
3147
|
if (!res.ok) throw new Error(`Failed to fetch RCP source: ${res.statusText}`);
|
|
@@ -3033,7 +3149,7 @@ function useRcpSources(options = {}) {
|
|
|
3033
3149
|
},
|
|
3034
3150
|
[fetchWithAuth]
|
|
3035
3151
|
);
|
|
3036
|
-
const createRcpSource = (0,
|
|
3152
|
+
const createRcpSource = (0, import_react14.useCallback)(
|
|
3037
3153
|
async (input) => {
|
|
3038
3154
|
setError(null);
|
|
3039
3155
|
try {
|
|
@@ -3057,7 +3173,7 @@ function useRcpSources(options = {}) {
|
|
|
3057
3173
|
},
|
|
3058
3174
|
[fetchWithAuth]
|
|
3059
3175
|
);
|
|
3060
|
-
const updateRcpSource = (0,
|
|
3176
|
+
const updateRcpSource = (0, import_react14.useCallback)(
|
|
3061
3177
|
async (sourceId, input) => {
|
|
3062
3178
|
setError(null);
|
|
3063
3179
|
try {
|
|
@@ -3081,7 +3197,7 @@ function useRcpSources(options = {}) {
|
|
|
3081
3197
|
},
|
|
3082
3198
|
[fetchWithAuth]
|
|
3083
3199
|
);
|
|
3084
|
-
const deleteRcpSource = (0,
|
|
3200
|
+
const deleteRcpSource = (0, import_react14.useCallback)(
|
|
3085
3201
|
async (sourceId) => {
|
|
3086
3202
|
setError(null);
|
|
3087
3203
|
try {
|
|
@@ -3099,7 +3215,7 @@ function useRcpSources(options = {}) {
|
|
|
3099
3215
|
},
|
|
3100
3216
|
[fetchWithAuth]
|
|
3101
3217
|
);
|
|
3102
|
-
const bulkDeleteRcpSources = (0,
|
|
3218
|
+
const bulkDeleteRcpSources = (0, import_react14.useCallback)(
|
|
3103
3219
|
async (ids) => {
|
|
3104
3220
|
setError(null);
|
|
3105
3221
|
try {
|
|
@@ -3124,7 +3240,7 @@ function useRcpSources(options = {}) {
|
|
|
3124
3240
|
},
|
|
3125
3241
|
[fetchWithAuth]
|
|
3126
3242
|
);
|
|
3127
|
-
const getRcpSourceUsage = (0,
|
|
3243
|
+
const getRcpSourceUsage = (0, import_react14.useCallback)(
|
|
3128
3244
|
async (sourceId) => {
|
|
3129
3245
|
const res = await fetchWithAuth(`/rcp-sources/${sourceId}/usage`);
|
|
3130
3246
|
if (!res.ok) throw new Error(`Failed to fetch RCP source usage: ${res.statusText}`);
|
|
@@ -3132,7 +3248,7 @@ function useRcpSources(options = {}) {
|
|
|
3132
3248
|
},
|
|
3133
3249
|
[fetchWithAuth]
|
|
3134
3250
|
);
|
|
3135
|
-
const testRcpSourceConnection = (0,
|
|
3251
|
+
const testRcpSourceConnection = (0, import_react14.useCallback)(
|
|
3136
3252
|
async (sourceId) => {
|
|
3137
3253
|
setError(null);
|
|
3138
3254
|
try {
|
|
@@ -3156,7 +3272,7 @@ function useRcpSources(options = {}) {
|
|
|
3156
3272
|
},
|
|
3157
3273
|
[fetchWithAuth]
|
|
3158
3274
|
);
|
|
3159
|
-
(0,
|
|
3275
|
+
(0, import_react14.useEffect)(() => {
|
|
3160
3276
|
if (autoFetch) void fetchRcpSources();
|
|
3161
3277
|
}, [autoFetch, fetchRcpSources]);
|
|
3162
3278
|
return {
|
|
@@ -3176,21 +3292,21 @@ function useRcpSources(options = {}) {
|
|
|
3176
3292
|
}
|
|
3177
3293
|
|
|
3178
3294
|
// src/hooks/useKnowledgeBases.ts
|
|
3179
|
-
var
|
|
3295
|
+
var import_react15 = require("react");
|
|
3180
3296
|
function useKnowledgeBases(options = {}) {
|
|
3181
3297
|
const { autoFetch = true, page, limit, search, scope } = options;
|
|
3182
3298
|
const { fetchWithAuth } = usePersonaContext();
|
|
3183
|
-
const [knowledgeBases, setKnowledgeBases] = (0,
|
|
3184
|
-
const [pagination, setPagination] = (0,
|
|
3299
|
+
const [knowledgeBases, setKnowledgeBases] = (0, import_react15.useState)([]);
|
|
3300
|
+
const [pagination, setPagination] = (0, import_react15.useState)({
|
|
3185
3301
|
total: 0,
|
|
3186
3302
|
page: page ?? 1,
|
|
3187
3303
|
limit: limit ?? 20,
|
|
3188
3304
|
pages: 0
|
|
3189
3305
|
});
|
|
3190
|
-
const [isLoading, setIsLoading] = (0,
|
|
3191
|
-
const [isUploading, setIsUploading] = (0,
|
|
3192
|
-
const [error, setError] = (0,
|
|
3193
|
-
const fetchKnowledgeBases = (0,
|
|
3306
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
|
|
3307
|
+
const [isUploading, setIsUploading] = (0, import_react15.useState)(false);
|
|
3308
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
3309
|
+
const fetchKnowledgeBases = (0, import_react15.useCallback)(async () => {
|
|
3194
3310
|
setIsLoading(true);
|
|
3195
3311
|
setError(null);
|
|
3196
3312
|
try {
|
|
@@ -3217,7 +3333,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3217
3333
|
setIsLoading(false);
|
|
3218
3334
|
}
|
|
3219
3335
|
}, [fetchWithAuth, page, limit, search, scope]);
|
|
3220
|
-
const getKnowledgeBase = (0,
|
|
3336
|
+
const getKnowledgeBase = (0, import_react15.useCallback)(
|
|
3221
3337
|
async (kbId) => {
|
|
3222
3338
|
const res = await fetchWithAuth(`/knowledge/${kbId}`);
|
|
3223
3339
|
if (!res.ok) throw new Error(`Failed to fetch knowledge base: ${res.statusText}`);
|
|
@@ -3225,7 +3341,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3225
3341
|
},
|
|
3226
3342
|
[fetchWithAuth]
|
|
3227
3343
|
);
|
|
3228
|
-
const createKnowledgeBase = (0,
|
|
3344
|
+
const createKnowledgeBase = (0, import_react15.useCallback)(
|
|
3229
3345
|
async (input) => {
|
|
3230
3346
|
setError(null);
|
|
3231
3347
|
try {
|
|
@@ -3249,7 +3365,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3249
3365
|
},
|
|
3250
3366
|
[fetchWithAuth]
|
|
3251
3367
|
);
|
|
3252
|
-
const updateKnowledgeBase = (0,
|
|
3368
|
+
const updateKnowledgeBase = (0, import_react15.useCallback)(
|
|
3253
3369
|
async (kbId, input) => {
|
|
3254
3370
|
setError(null);
|
|
3255
3371
|
try {
|
|
@@ -3273,7 +3389,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3273
3389
|
},
|
|
3274
3390
|
[fetchWithAuth]
|
|
3275
3391
|
);
|
|
3276
|
-
const deleteKnowledgeBase = (0,
|
|
3392
|
+
const deleteKnowledgeBase = (0, import_react15.useCallback)(
|
|
3277
3393
|
async (kbId) => {
|
|
3278
3394
|
setError(null);
|
|
3279
3395
|
try {
|
|
@@ -3291,7 +3407,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3291
3407
|
},
|
|
3292
3408
|
[fetchWithAuth]
|
|
3293
3409
|
);
|
|
3294
|
-
const bulkDeleteKnowledgeBases = (0,
|
|
3410
|
+
const bulkDeleteKnowledgeBases = (0, import_react15.useCallback)(
|
|
3295
3411
|
async (ids) => {
|
|
3296
3412
|
setError(null);
|
|
3297
3413
|
try {
|
|
@@ -3316,7 +3432,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3316
3432
|
},
|
|
3317
3433
|
[fetchWithAuth]
|
|
3318
3434
|
);
|
|
3319
|
-
const getKnowledgeBaseUsage = (0,
|
|
3435
|
+
const getKnowledgeBaseUsage = (0, import_react15.useCallback)(
|
|
3320
3436
|
async (kbId) => {
|
|
3321
3437
|
const res = await fetchWithAuth(`/knowledge/${kbId}/usage`);
|
|
3322
3438
|
if (!res.ok) throw new Error(`Failed to fetch knowledge base usage: ${res.statusText}`);
|
|
@@ -3324,7 +3440,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3324
3440
|
},
|
|
3325
3441
|
[fetchWithAuth]
|
|
3326
3442
|
);
|
|
3327
|
-
const uploadDocuments = (0,
|
|
3443
|
+
const uploadDocuments = (0, import_react15.useCallback)(
|
|
3328
3444
|
async (kbId, files) => {
|
|
3329
3445
|
setIsUploading(true);
|
|
3330
3446
|
setError(null);
|
|
@@ -3366,7 +3482,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3366
3482
|
},
|
|
3367
3483
|
[fetchWithAuth]
|
|
3368
3484
|
);
|
|
3369
|
-
const listDocuments = (0,
|
|
3485
|
+
const listDocuments = (0, import_react15.useCallback)(
|
|
3370
3486
|
async (kbId) => {
|
|
3371
3487
|
const res = await fetchWithAuth(`/knowledge/${kbId}/documents`);
|
|
3372
3488
|
if (!res.ok) throw new Error(`Failed to list documents: ${res.statusText}`);
|
|
@@ -3374,7 +3490,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3374
3490
|
},
|
|
3375
3491
|
[fetchWithAuth]
|
|
3376
3492
|
);
|
|
3377
|
-
const deleteDocument = (0,
|
|
3493
|
+
const deleteDocument = (0, import_react15.useCallback)(
|
|
3378
3494
|
async (kbId, sourceName) => {
|
|
3379
3495
|
setError(null);
|
|
3380
3496
|
try {
|
|
@@ -3401,7 +3517,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3401
3517
|
},
|
|
3402
3518
|
[fetchWithAuth]
|
|
3403
3519
|
);
|
|
3404
|
-
const searchKnowledgeBase = (0,
|
|
3520
|
+
const searchKnowledgeBase = (0, import_react15.useCallback)(
|
|
3405
3521
|
async (kbId, query, opts) => {
|
|
3406
3522
|
const res = await fetchWithAuth(`/knowledge/${kbId}/search`, {
|
|
3407
3523
|
method: "POST",
|
|
@@ -3416,7 +3532,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3416
3532
|
},
|
|
3417
3533
|
[fetchWithAuth]
|
|
3418
3534
|
);
|
|
3419
|
-
(0,
|
|
3535
|
+
(0, import_react15.useEffect)(() => {
|
|
3420
3536
|
if (autoFetch) void fetchKnowledgeBases();
|
|
3421
3537
|
}, [autoFetch, fetchKnowledgeBases]);
|
|
3422
3538
|
return {
|
|
@@ -3440,20 +3556,20 @@ function useKnowledgeBases(options = {}) {
|
|
|
3440
3556
|
}
|
|
3441
3557
|
|
|
3442
3558
|
// src/hooks/useMcpAdmin.ts
|
|
3443
|
-
var
|
|
3559
|
+
var import_react16 = require("react");
|
|
3444
3560
|
function useMcpAdmin(options = {}) {
|
|
3445
3561
|
const { autoFetch = true, page, limit, search } = options;
|
|
3446
3562
|
const { fetchWithAuth } = usePersonaContext();
|
|
3447
|
-
const [mcps, setMcps] = (0,
|
|
3448
|
-
const [pagination, setPagination] = (0,
|
|
3563
|
+
const [mcps, setMcps] = (0, import_react16.useState)([]);
|
|
3564
|
+
const [pagination, setPagination] = (0, import_react16.useState)({
|
|
3449
3565
|
total: 0,
|
|
3450
3566
|
page: page ?? 1,
|
|
3451
3567
|
limit: limit ?? 20,
|
|
3452
3568
|
pages: 0
|
|
3453
3569
|
});
|
|
3454
|
-
const [isLoading, setIsLoading] = (0,
|
|
3455
|
-
const [error, setError] = (0,
|
|
3456
|
-
const fetchMcps = (0,
|
|
3570
|
+
const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
|
|
3571
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
3572
|
+
const fetchMcps = (0, import_react16.useCallback)(async () => {
|
|
3457
3573
|
setIsLoading(true);
|
|
3458
3574
|
setError(null);
|
|
3459
3575
|
try {
|
|
@@ -3479,7 +3595,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3479
3595
|
setIsLoading(false);
|
|
3480
3596
|
}
|
|
3481
3597
|
}, [fetchWithAuth, page, limit, search]);
|
|
3482
|
-
const getMcp = (0,
|
|
3598
|
+
const getMcp = (0, import_react16.useCallback)(
|
|
3483
3599
|
async (mcpId) => {
|
|
3484
3600
|
const res = await fetchWithAuth(`/mcps/${mcpId}`);
|
|
3485
3601
|
if (!res.ok) throw new Error(`Failed to fetch MCP: ${res.statusText}`);
|
|
@@ -3487,7 +3603,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3487
3603
|
},
|
|
3488
3604
|
[fetchWithAuth]
|
|
3489
3605
|
);
|
|
3490
|
-
const createMcp = (0,
|
|
3606
|
+
const createMcp = (0, import_react16.useCallback)(
|
|
3491
3607
|
async (input) => {
|
|
3492
3608
|
setError(null);
|
|
3493
3609
|
try {
|
|
@@ -3511,7 +3627,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3511
3627
|
},
|
|
3512
3628
|
[fetchWithAuth]
|
|
3513
3629
|
);
|
|
3514
|
-
const updateMcp = (0,
|
|
3630
|
+
const updateMcp = (0, import_react16.useCallback)(
|
|
3515
3631
|
async (mcpId, input) => {
|
|
3516
3632
|
setError(null);
|
|
3517
3633
|
try {
|
|
@@ -3535,7 +3651,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3535
3651
|
},
|
|
3536
3652
|
[fetchWithAuth]
|
|
3537
3653
|
);
|
|
3538
|
-
const deleteMcp = (0,
|
|
3654
|
+
const deleteMcp = (0, import_react16.useCallback)(
|
|
3539
3655
|
async (mcpId) => {
|
|
3540
3656
|
setError(null);
|
|
3541
3657
|
try {
|
|
@@ -3553,7 +3669,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3553
3669
|
},
|
|
3554
3670
|
[fetchWithAuth]
|
|
3555
3671
|
);
|
|
3556
|
-
const bulkDeleteMcps = (0,
|
|
3672
|
+
const bulkDeleteMcps = (0, import_react16.useCallback)(
|
|
3557
3673
|
async (ids) => {
|
|
3558
3674
|
setError(null);
|
|
3559
3675
|
try {
|
|
@@ -3578,7 +3694,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3578
3694
|
},
|
|
3579
3695
|
[fetchWithAuth]
|
|
3580
3696
|
);
|
|
3581
|
-
const testConnection = (0,
|
|
3697
|
+
const testConnection = (0, import_react16.useCallback)(
|
|
3582
3698
|
async (mcpId) => {
|
|
3583
3699
|
setError(null);
|
|
3584
3700
|
try {
|
|
@@ -3602,7 +3718,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3602
3718
|
},
|
|
3603
3719
|
[fetchWithAuth]
|
|
3604
3720
|
);
|
|
3605
|
-
(0,
|
|
3721
|
+
(0, import_react16.useEffect)(() => {
|
|
3606
3722
|
if (autoFetch) void fetchMcps();
|
|
3607
3723
|
}, [autoFetch, fetchMcps]);
|
|
3608
3724
|
return {
|
|
@@ -3621,21 +3737,21 @@ function useMcpAdmin(options = {}) {
|
|
|
3621
3737
|
}
|
|
3622
3738
|
|
|
3623
3739
|
// src/hooks/useWorkflows.ts
|
|
3624
|
-
var
|
|
3740
|
+
var import_react17 = require("react");
|
|
3625
3741
|
function useWorkflows(options) {
|
|
3626
3742
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
3627
3743
|
const { autoFetch = true, search, scope, visibility, isEnabled, page, limit } = opts;
|
|
3628
3744
|
const { fetchWithAuth } = usePersonaContext();
|
|
3629
|
-
const [workflows, setWorkflows] = (0,
|
|
3630
|
-
const [pagination, setPagination] = (0,
|
|
3745
|
+
const [workflows, setWorkflows] = (0, import_react17.useState)([]);
|
|
3746
|
+
const [pagination, setPagination] = (0, import_react17.useState)({
|
|
3631
3747
|
page: page ?? 1,
|
|
3632
3748
|
limit: limit ?? 20,
|
|
3633
3749
|
total: 0,
|
|
3634
3750
|
totalPages: 0
|
|
3635
3751
|
});
|
|
3636
|
-
const [isLoading, setIsLoading] = (0,
|
|
3637
|
-
const [error, setError] = (0,
|
|
3638
|
-
const fetchWorkflows = (0,
|
|
3752
|
+
const [isLoading, setIsLoading] = (0, import_react17.useState)(false);
|
|
3753
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
3754
|
+
const fetchWorkflows = (0, import_react17.useCallback)(async () => {
|
|
3639
3755
|
setIsLoading(true);
|
|
3640
3756
|
setError(null);
|
|
3641
3757
|
try {
|
|
@@ -3681,7 +3797,7 @@ function useWorkflows(options) {
|
|
|
3681
3797
|
setIsLoading(false);
|
|
3682
3798
|
}
|
|
3683
3799
|
}, [fetchWithAuth, search, scope, visibility, isEnabled, page, limit]);
|
|
3684
|
-
const createWorkflow = (0,
|
|
3800
|
+
const createWorkflow = (0, import_react17.useCallback)(
|
|
3685
3801
|
async (input) => {
|
|
3686
3802
|
setError(null);
|
|
3687
3803
|
try {
|
|
@@ -3705,7 +3821,7 @@ function useWorkflows(options) {
|
|
|
3705
3821
|
},
|
|
3706
3822
|
[fetchWithAuth]
|
|
3707
3823
|
);
|
|
3708
|
-
(0,
|
|
3824
|
+
(0, import_react17.useEffect)(() => {
|
|
3709
3825
|
if (autoFetch) {
|
|
3710
3826
|
void fetchWorkflows();
|
|
3711
3827
|
}
|
|
@@ -3721,17 +3837,17 @@ function useWorkflows(options) {
|
|
|
3721
3837
|
}
|
|
3722
3838
|
|
|
3723
3839
|
// src/hooks/useWorkflow.ts
|
|
3724
|
-
var
|
|
3840
|
+
var import_react18 = require("react");
|
|
3725
3841
|
function useWorkflow(workflowId, options) {
|
|
3726
3842
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
3727
3843
|
const { autoFetch = true } = opts;
|
|
3728
3844
|
const { fetchWithAuth } = usePersonaContext();
|
|
3729
|
-
const [workflow, setWorkflow] = (0,
|
|
3730
|
-
const [versions, setVersions] = (0,
|
|
3731
|
-
const [mermaid, setMermaid] = (0,
|
|
3732
|
-
const [isLoading, setIsLoading] = (0,
|
|
3733
|
-
const [error, setError] = (0,
|
|
3734
|
-
const fetchWorkflow = (0,
|
|
3845
|
+
const [workflow, setWorkflow] = (0, import_react18.useState)(null);
|
|
3846
|
+
const [versions, setVersions] = (0, import_react18.useState)([]);
|
|
3847
|
+
const [mermaid, setMermaid] = (0, import_react18.useState)(null);
|
|
3848
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(false);
|
|
3849
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
3850
|
+
const fetchWorkflow = (0, import_react18.useCallback)(async () => {
|
|
3735
3851
|
if (!workflowId) return null;
|
|
3736
3852
|
setIsLoading(true);
|
|
3737
3853
|
setError(null);
|
|
@@ -3751,7 +3867,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3751
3867
|
setIsLoading(false);
|
|
3752
3868
|
}
|
|
3753
3869
|
}, [fetchWithAuth, workflowId]);
|
|
3754
|
-
const fetchVersions = (0,
|
|
3870
|
+
const fetchVersions = (0, import_react18.useCallback)(async () => {
|
|
3755
3871
|
if (!workflowId) return [];
|
|
3756
3872
|
try {
|
|
3757
3873
|
const res = await fetchWithAuth(`/workflows/${workflowId}/versions`);
|
|
@@ -3764,7 +3880,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3764
3880
|
return [];
|
|
3765
3881
|
}
|
|
3766
3882
|
}, [fetchWithAuth, workflowId]);
|
|
3767
|
-
const getVersion = (0,
|
|
3883
|
+
const getVersion = (0, import_react18.useCallback)(
|
|
3768
3884
|
async (version) => {
|
|
3769
3885
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3770
3886
|
const res = await fetchWithAuth(`/workflows/${workflowId}/versions/${version}`);
|
|
@@ -3775,7 +3891,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3775
3891
|
},
|
|
3776
3892
|
[fetchWithAuth, workflowId]
|
|
3777
3893
|
);
|
|
3778
|
-
const fetchMermaid = (0,
|
|
3894
|
+
const fetchMermaid = (0, import_react18.useCallback)(async () => {
|
|
3779
3895
|
if (!workflowId) return "";
|
|
3780
3896
|
try {
|
|
3781
3897
|
const res = await fetchWithAuth(`/workflows/${workflowId}/mermaid`);
|
|
@@ -3788,7 +3904,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3788
3904
|
return "";
|
|
3789
3905
|
}
|
|
3790
3906
|
}, [fetchWithAuth, workflowId]);
|
|
3791
|
-
const updateWorkflow = (0,
|
|
3907
|
+
const updateWorkflow = (0, import_react18.useCallback)(
|
|
3792
3908
|
async (input) => {
|
|
3793
3909
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3794
3910
|
setError(null);
|
|
@@ -3807,7 +3923,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3807
3923
|
},
|
|
3808
3924
|
[fetchWithAuth, workflowId]
|
|
3809
3925
|
);
|
|
3810
|
-
const saveDraft = (0,
|
|
3926
|
+
const saveDraft = (0, import_react18.useCallback)(
|
|
3811
3927
|
async (draft) => {
|
|
3812
3928
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3813
3929
|
setError(null);
|
|
@@ -3826,7 +3942,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3826
3942
|
},
|
|
3827
3943
|
[fetchWithAuth, workflowId]
|
|
3828
3944
|
);
|
|
3829
|
-
const publish = (0,
|
|
3945
|
+
const publish = (0, import_react18.useCallback)(async () => {
|
|
3830
3946
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3831
3947
|
setError(null);
|
|
3832
3948
|
const res = await fetchWithAuth(`/workflows/${workflowId}/publish`, {
|
|
@@ -3841,7 +3957,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3841
3957
|
void fetchVersions();
|
|
3842
3958
|
return versionResult;
|
|
3843
3959
|
}, [fetchWithAuth, workflowId, fetchWorkflow, fetchVersions]);
|
|
3844
|
-
const deleteWorkflow = (0,
|
|
3960
|
+
const deleteWorkflow = (0, import_react18.useCallback)(async () => {
|
|
3845
3961
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3846
3962
|
setError(null);
|
|
3847
3963
|
const res = await fetchWithAuth(`/workflows/${workflowId}`, {
|
|
@@ -3852,7 +3968,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3852
3968
|
}
|
|
3853
3969
|
setWorkflow(null);
|
|
3854
3970
|
}, [fetchWithAuth, workflowId]);
|
|
3855
|
-
(0,
|
|
3971
|
+
(0, import_react18.useEffect)(() => {
|
|
3856
3972
|
if (autoFetch && workflowId) {
|
|
3857
3973
|
void fetchWorkflow();
|
|
3858
3974
|
}
|
|
@@ -3875,25 +3991,25 @@ function useWorkflow(workflowId, options) {
|
|
|
3875
3991
|
}
|
|
3876
3992
|
|
|
3877
3993
|
// src/hooks/useWorkflowStream.ts
|
|
3878
|
-
var
|
|
3994
|
+
var import_react19 = require("react");
|
|
3879
3995
|
function useWorkflowStream(workflowId, options) {
|
|
3880
3996
|
const { baseUrl, getAuthToken, fetchWithAuth, logger } = usePersonaContext();
|
|
3881
|
-
const [status, setStatus] = (0,
|
|
3882
|
-
const [runId, setRunId] = (0,
|
|
3883
|
-
const [activeNodeId, setActiveNodeId] = (0,
|
|
3884
|
-
const [nodeRuns, setNodeRuns] = (0,
|
|
3997
|
+
const [status, setStatus] = (0, import_react19.useState)("idle");
|
|
3998
|
+
const [runId, setRunId] = (0, import_react19.useState)(null);
|
|
3999
|
+
const [activeNodeId, setActiveNodeId] = (0, import_react19.useState)(null);
|
|
4000
|
+
const [nodeRuns, setNodeRuns] = (0, import_react19.useState)(
|
|
3885
4001
|
{}
|
|
3886
4002
|
);
|
|
3887
|
-
const [text, setText] = (0,
|
|
3888
|
-
const [output, setOutput] = (0,
|
|
3889
|
-
const [error, setError] = (0,
|
|
3890
|
-
const [events, setEvents] = (0,
|
|
3891
|
-
const abortControllerRef = (0,
|
|
3892
|
-
const currentRunIdRef = (0,
|
|
4003
|
+
const [text, setText] = (0, import_react19.useState)("");
|
|
4004
|
+
const [output, setOutput] = (0, import_react19.useState)(null);
|
|
4005
|
+
const [error, setError] = (0, import_react19.useState)(null);
|
|
4006
|
+
const [events, setEvents] = (0, import_react19.useState)([]);
|
|
4007
|
+
const abortControllerRef = (0, import_react19.useRef)(null);
|
|
4008
|
+
const currentRunIdRef = (0, import_react19.useRef)(null);
|
|
3893
4009
|
currentRunIdRef.current = runId;
|
|
3894
|
-
const optionsRef = (0,
|
|
4010
|
+
const optionsRef = (0, import_react19.useRef)(options);
|
|
3895
4011
|
optionsRef.current = options;
|
|
3896
|
-
const cancel = (0,
|
|
4012
|
+
const cancel = (0, import_react19.useCallback)(async () => {
|
|
3897
4013
|
if (abortControllerRef.current) {
|
|
3898
4014
|
abortControllerRef.current.abort();
|
|
3899
4015
|
abortControllerRef.current = null;
|
|
@@ -3914,7 +4030,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
3914
4030
|
setStatus("cancelled");
|
|
3915
4031
|
setActiveNodeId(null);
|
|
3916
4032
|
}, [fetchWithAuth, logger]);
|
|
3917
|
-
const reset = (0,
|
|
4033
|
+
const reset = (0, import_react19.useCallback)(() => {
|
|
3918
4034
|
if (abortControllerRef.current) {
|
|
3919
4035
|
abortControllerRef.current.abort();
|
|
3920
4036
|
abortControllerRef.current = null;
|
|
@@ -3928,7 +4044,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
3928
4044
|
setError(null);
|
|
3929
4045
|
setEvents([]);
|
|
3930
4046
|
}, []);
|
|
3931
|
-
const processStream = (0,
|
|
4047
|
+
const processStream = (0, import_react19.useCallback)(
|
|
3932
4048
|
async (url, method, body, targetRunId) => {
|
|
3933
4049
|
if (abortControllerRef.current) {
|
|
3934
4050
|
abortControllerRef.current.abort();
|
|
@@ -4093,7 +4209,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4093
4209
|
},
|
|
4094
4210
|
[getAuthToken]
|
|
4095
4211
|
);
|
|
4096
|
-
const start = (0,
|
|
4212
|
+
const start = (0, import_react19.useCallback)(
|
|
4097
4213
|
async (input, opts) => {
|
|
4098
4214
|
const targetWfId = opts?.workflowId || workflowId;
|
|
4099
4215
|
if (!targetWfId) {
|
|
@@ -4114,7 +4230,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4114
4230
|
},
|
|
4115
4231
|
[workflowId, baseUrl, processStream]
|
|
4116
4232
|
);
|
|
4117
|
-
const resume = (0,
|
|
4233
|
+
const resume = (0, import_react19.useCallback)(
|
|
4118
4234
|
async (targetRunId, sinceSeq) => {
|
|
4119
4235
|
if (!targetRunId) {
|
|
4120
4236
|
throw new Error("Run ID is required to resume stream");
|
|
@@ -4127,7 +4243,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4127
4243
|
},
|
|
4128
4244
|
[baseUrl, processStream]
|
|
4129
4245
|
);
|
|
4130
|
-
(0,
|
|
4246
|
+
(0, import_react19.useEffect)(() => {
|
|
4131
4247
|
return () => {
|
|
4132
4248
|
if (abortControllerRef.current) {
|
|
4133
4249
|
abortControllerRef.current.abort();
|
|
@@ -4152,21 +4268,21 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4152
4268
|
}
|
|
4153
4269
|
|
|
4154
4270
|
// src/hooks/useWorkflowRuns.ts
|
|
4155
|
-
var
|
|
4271
|
+
var import_react20 = require("react");
|
|
4156
4272
|
function useWorkflowRuns(workflowId, options) {
|
|
4157
4273
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
4158
4274
|
const { autoFetch = true, page = 1, limit = 20 } = opts;
|
|
4159
4275
|
const { fetchWithAuth } = usePersonaContext();
|
|
4160
|
-
const [runs, setRuns] = (0,
|
|
4161
|
-
const [pagination, setPagination] = (0,
|
|
4276
|
+
const [runs, setRuns] = (0, import_react20.useState)([]);
|
|
4277
|
+
const [pagination, setPagination] = (0, import_react20.useState)({
|
|
4162
4278
|
page,
|
|
4163
4279
|
limit,
|
|
4164
4280
|
total: 0,
|
|
4165
4281
|
totalPages: 0
|
|
4166
4282
|
});
|
|
4167
|
-
const [isLoading, setIsLoading] = (0,
|
|
4168
|
-
const [error, setError] = (0,
|
|
4169
|
-
const fetchRuns = (0,
|
|
4283
|
+
const [isLoading, setIsLoading] = (0, import_react20.useState)(false);
|
|
4284
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
4285
|
+
const fetchRuns = (0, import_react20.useCallback)(async () => {
|
|
4170
4286
|
if (!workflowId) return [];
|
|
4171
4287
|
setIsLoading(true);
|
|
4172
4288
|
setError(null);
|
|
@@ -4198,7 +4314,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4198
4314
|
setIsLoading(false);
|
|
4199
4315
|
}
|
|
4200
4316
|
}, [fetchWithAuth, workflowId, page, limit]);
|
|
4201
|
-
const getRun = (0,
|
|
4317
|
+
const getRun = (0, import_react20.useCallback)(
|
|
4202
4318
|
async (runId) => {
|
|
4203
4319
|
if (!runId) throw new Error("Run ID is required");
|
|
4204
4320
|
const res = await fetchWithAuth(`/workflows/runs/${runId}`);
|
|
@@ -4209,7 +4325,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4209
4325
|
},
|
|
4210
4326
|
[fetchWithAuth]
|
|
4211
4327
|
);
|
|
4212
|
-
const cancelRun = (0,
|
|
4328
|
+
const cancelRun = (0, import_react20.useCallback)(
|
|
4213
4329
|
async (runId) => {
|
|
4214
4330
|
if (!runId) throw new Error("Run ID is required");
|
|
4215
4331
|
const res = await fetchWithAuth(`/workflows/runs/${runId}/cancel`, {
|
|
@@ -4224,7 +4340,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4224
4340
|
},
|
|
4225
4341
|
[fetchWithAuth]
|
|
4226
4342
|
);
|
|
4227
|
-
(0,
|
|
4343
|
+
(0, import_react20.useEffect)(() => {
|
|
4228
4344
|
if (autoFetch && workflowId) {
|
|
4229
4345
|
void fetchRuns();
|
|
4230
4346
|
}
|
|
@@ -4273,6 +4389,7 @@ var VERSION = "0.10.0";
|
|
|
4273
4389
|
useWorkflow,
|
|
4274
4390
|
useWorkflowRuns,
|
|
4275
4391
|
useWorkflowStream,
|
|
4276
|
-
useWorkflows
|
|
4392
|
+
useWorkflows,
|
|
4393
|
+
useWorkspaceFiles
|
|
4277
4394
|
});
|
|
4278
4395
|
//# sourceMappingURL=index.cjs.map
|