@personaai/react 0.17.1 → 0.18.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -0
- package/dist/index.cjs +248 -153
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +77 -2
- package/dist/index.d.ts +77 -2
- package/dist/index.js +235 -141
- package/dist/index.js.map +1 -1
- package/package.json +1 -6
package/dist/index.js
CHANGED
|
@@ -65,10 +65,33 @@ function PersonaProvider({
|
|
|
65
65
|
ok: res.ok
|
|
66
66
|
});
|
|
67
67
|
if (!res.ok) {
|
|
68
|
+
const parsedResult = { isJson: false };
|
|
69
|
+
try {
|
|
70
|
+
const body = await res.clone().json();
|
|
71
|
+
if (body && typeof body === "object") {
|
|
72
|
+
const message = body.error?.message ?? body.message ?? void 0;
|
|
73
|
+
if (body.error?.code ?? message) {
|
|
74
|
+
parsedResult.isJson = true;
|
|
75
|
+
parsedResult.info = {
|
|
76
|
+
status: res.status,
|
|
77
|
+
code: body.error?.code,
|
|
78
|
+
message
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
} catch {
|
|
83
|
+
}
|
|
68
84
|
logger.warn("fetchWithAuth non-ok", {
|
|
69
85
|
path: cleanPath,
|
|
70
|
-
status: res.status
|
|
86
|
+
status: res.status,
|
|
87
|
+
...parsedResult.info ?? {}
|
|
71
88
|
});
|
|
89
|
+
if (parsedResult.info) {
|
|
90
|
+
try {
|
|
91
|
+
res.personaError = parsedResult.info;
|
|
92
|
+
} catch {
|
|
93
|
+
}
|
|
94
|
+
}
|
|
72
95
|
} else {
|
|
73
96
|
logger.info("fetchWithAuth succeeded", {
|
|
74
97
|
path: cleanPath,
|
|
@@ -364,6 +387,14 @@ function normalizePendingInterrupt(pending) {
|
|
|
364
387
|
}
|
|
365
388
|
|
|
366
389
|
// src/hooks/useChat.ts
|
|
390
|
+
function httpFailure(res, what) {
|
|
391
|
+
const info = res.personaError;
|
|
392
|
+
if (!info || !info.code && !info.message) {
|
|
393
|
+
return new Error(`Failed to ${what}: ${res.statusText || res.status}`);
|
|
394
|
+
}
|
|
395
|
+
const parts = [info.status, info.code, info.message].filter(Boolean).join(", ");
|
|
396
|
+
return new Error(`Failed to ${what}: ${parts}`);
|
|
397
|
+
}
|
|
367
398
|
function parseSandboxCommand(tc) {
|
|
368
399
|
let command = tc.args ?? "";
|
|
369
400
|
try {
|
|
@@ -496,8 +527,7 @@ function useChat(options = {}) {
|
|
|
496
527
|
setError(null);
|
|
497
528
|
try {
|
|
498
529
|
const res = await fetchWithAuth(`/threads/${id}/messages`);
|
|
499
|
-
if (!res.ok)
|
|
500
|
-
throw new Error(`Failed to load thread history: ${res.statusText}`);
|
|
530
|
+
if (!res.ok) throw httpFailure(res, "load thread history");
|
|
501
531
|
const body = await res.json();
|
|
502
532
|
const data = body?.data ?? body;
|
|
503
533
|
const raw = data?.messages ?? [];
|
|
@@ -757,7 +787,7 @@ function useChat(options = {}) {
|
|
|
757
787
|
headers: { "Content-Type": "application/json" },
|
|
758
788
|
body: JSON.stringify({ agentId: targetAgentId })
|
|
759
789
|
});
|
|
760
|
-
if (!createRes.ok) throw
|
|
790
|
+
if (!createRes.ok) throw httpFailure(createRes, "create thread");
|
|
761
791
|
const createBody = await createRes.json();
|
|
762
792
|
const created = createBody?.data ?? createBody;
|
|
763
793
|
resolvedThreadId = created._id ?? created.id;
|
|
@@ -2463,15 +2493,78 @@ function useVoice(options = {}) {
|
|
|
2463
2493
|
};
|
|
2464
2494
|
}
|
|
2465
2495
|
|
|
2496
|
+
// src/hooks/useMessages.ts
|
|
2497
|
+
import { useCallback as useCallback7, useMemo as useMemo5, useRef as useRef4, useState as useState7 } from "react";
|
|
2498
|
+
async function readErrorMessage(res, fallback) {
|
|
2499
|
+
try {
|
|
2500
|
+
const body = await res.json();
|
|
2501
|
+
const message = body?.error?.message ?? body?.message;
|
|
2502
|
+
if (typeof message === "string" && message) return message;
|
|
2503
|
+
} catch {
|
|
2504
|
+
}
|
|
2505
|
+
return `${fallback}: ${res.statusText}`;
|
|
2506
|
+
}
|
|
2507
|
+
function useMessages() {
|
|
2508
|
+
const { fetchWithAuth, logger } = usePersonaContext();
|
|
2509
|
+
const messagesLogger = useMemo5(() => logger.child("messages"), [logger]);
|
|
2510
|
+
const [isSending, setIsSending] = useState7(false);
|
|
2511
|
+
const [error, setError] = useState7(null);
|
|
2512
|
+
const [lastDelivery, setLastDelivery] = useState7(null);
|
|
2513
|
+
const inFlightRef = useRef4(0);
|
|
2514
|
+
const post = useCallback7(
|
|
2515
|
+
async (path, input) => {
|
|
2516
|
+
inFlightRef.current += 1;
|
|
2517
|
+
setIsSending(true);
|
|
2518
|
+
setError(null);
|
|
2519
|
+
try {
|
|
2520
|
+
const res = await fetchWithAuth(path, {
|
|
2521
|
+
method: "POST",
|
|
2522
|
+
headers: { "Content-Type": "application/json" },
|
|
2523
|
+
body: JSON.stringify(input)
|
|
2524
|
+
});
|
|
2525
|
+
if (!res.ok) {
|
|
2526
|
+
throw new Error(await readErrorMessage(res, "Failed to send message"));
|
|
2527
|
+
}
|
|
2528
|
+
const payload = await res.json();
|
|
2529
|
+
const delivery = payload?.data ?? payload;
|
|
2530
|
+
setLastDelivery(delivery);
|
|
2531
|
+
messagesLogger.info("message sent", { path });
|
|
2532
|
+
return delivery;
|
|
2533
|
+
} catch (err) {
|
|
2534
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
2535
|
+
messagesLogger.warn("message send failed", {
|
|
2536
|
+
path,
|
|
2537
|
+
error: errorObj.message
|
|
2538
|
+
});
|
|
2539
|
+
setError(errorObj);
|
|
2540
|
+
throw errorObj;
|
|
2541
|
+
} finally {
|
|
2542
|
+
inFlightRef.current -= 1;
|
|
2543
|
+
if (inFlightRef.current === 0) setIsSending(false);
|
|
2544
|
+
}
|
|
2545
|
+
},
|
|
2546
|
+
[fetchWithAuth, messagesLogger]
|
|
2547
|
+
);
|
|
2548
|
+
const send = useCallback7(
|
|
2549
|
+
(input) => post("/messages", input),
|
|
2550
|
+
[post]
|
|
2551
|
+
);
|
|
2552
|
+
const sendFromAgent = useCallback7(
|
|
2553
|
+
(input) => post("/messages/agent", input),
|
|
2554
|
+
[post]
|
|
2555
|
+
);
|
|
2556
|
+
return { isSending, error, lastDelivery, send, sendFromAgent };
|
|
2557
|
+
}
|
|
2558
|
+
|
|
2466
2559
|
// src/hooks/useFiles.ts
|
|
2467
|
-
import { useCallback as
|
|
2560
|
+
import { useCallback as useCallback8, useEffect as useEffect7, useState as useState8 } from "react";
|
|
2468
2561
|
function useFiles(autoFetch = true) {
|
|
2469
2562
|
const { fetchWithAuth } = usePersonaContext();
|
|
2470
|
-
const [files, setFiles] =
|
|
2471
|
-
const [isLoading, setIsLoading] =
|
|
2472
|
-
const [isUploading, setIsUploading] =
|
|
2473
|
-
const [error, setError] =
|
|
2474
|
-
const fetchFiles =
|
|
2563
|
+
const [files, setFiles] = useState8([]);
|
|
2564
|
+
const [isLoading, setIsLoading] = useState8(false);
|
|
2565
|
+
const [isUploading, setIsUploading] = useState8(false);
|
|
2566
|
+
const [error, setError] = useState8(null);
|
|
2567
|
+
const fetchFiles = useCallback8(async () => {
|
|
2475
2568
|
setIsLoading(true);
|
|
2476
2569
|
setError(null);
|
|
2477
2570
|
try {
|
|
@@ -2489,7 +2582,7 @@ function useFiles(autoFetch = true) {
|
|
|
2489
2582
|
setIsLoading(false);
|
|
2490
2583
|
}
|
|
2491
2584
|
}, [fetchWithAuth]);
|
|
2492
|
-
const uploadFile =
|
|
2585
|
+
const uploadFile = useCallback8(
|
|
2493
2586
|
async (fileOrFormData) => {
|
|
2494
2587
|
setIsUploading(true);
|
|
2495
2588
|
setError(null);
|
|
@@ -2522,7 +2615,7 @@ function useFiles(autoFetch = true) {
|
|
|
2522
2615
|
},
|
|
2523
2616
|
[fetchWithAuth, fetchFiles]
|
|
2524
2617
|
);
|
|
2525
|
-
const deleteFile =
|
|
2618
|
+
const deleteFile = useCallback8(
|
|
2526
2619
|
async (fileId) => {
|
|
2527
2620
|
const res = await fetchWithAuth(`/files/${fileId}`, { method: "DELETE" });
|
|
2528
2621
|
if (!res.ok) throw new Error(`Failed to delete file: ${res.statusText}`);
|
|
@@ -2530,7 +2623,7 @@ function useFiles(autoFetch = true) {
|
|
|
2530
2623
|
},
|
|
2531
2624
|
[fetchWithAuth]
|
|
2532
2625
|
);
|
|
2533
|
-
const bulkDeleteFiles =
|
|
2626
|
+
const bulkDeleteFiles = useCallback8(
|
|
2534
2627
|
async (fileIds) => {
|
|
2535
2628
|
const res = await fetchWithAuth("/files/bulk-delete", {
|
|
2536
2629
|
method: "POST",
|
|
@@ -2545,7 +2638,7 @@ function useFiles(autoFetch = true) {
|
|
|
2545
2638
|
},
|
|
2546
2639
|
[fetchWithAuth]
|
|
2547
2640
|
);
|
|
2548
|
-
const getDownloadUrl =
|
|
2641
|
+
const getDownloadUrl = useCallback8((fileId) => {
|
|
2549
2642
|
return `/files/${fileId}`;
|
|
2550
2643
|
}, []);
|
|
2551
2644
|
useEffect7(() => {
|
|
@@ -2567,21 +2660,21 @@ function useFiles(autoFetch = true) {
|
|
|
2567
2660
|
}
|
|
2568
2661
|
|
|
2569
2662
|
// src/hooks/useAgents.ts
|
|
2570
|
-
import { useCallback as
|
|
2663
|
+
import { useCallback as useCallback9, useEffect as useEffect8, useState as useState9 } from "react";
|
|
2571
2664
|
function useAgents(options = true) {
|
|
2572
2665
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options;
|
|
2573
2666
|
const { autoFetch = true, page, limit, search, category, scope } = opts;
|
|
2574
2667
|
const { fetchWithAuth } = usePersonaContext();
|
|
2575
|
-
const [agents, setAgents] =
|
|
2576
|
-
const [pagination, setPagination] =
|
|
2668
|
+
const [agents, setAgents] = useState9([]);
|
|
2669
|
+
const [pagination, setPagination] = useState9({
|
|
2577
2670
|
total: 0,
|
|
2578
2671
|
page: page ?? 1,
|
|
2579
2672
|
limit: limit ?? 20,
|
|
2580
2673
|
pages: 0
|
|
2581
2674
|
});
|
|
2582
|
-
const [isLoading, setIsLoading] =
|
|
2583
|
-
const [error, setError] =
|
|
2584
|
-
const fetchAgents =
|
|
2675
|
+
const [isLoading, setIsLoading] = useState9(false);
|
|
2676
|
+
const [error, setError] = useState9(null);
|
|
2677
|
+
const fetchAgents = useCallback9(async () => {
|
|
2585
2678
|
setIsLoading(true);
|
|
2586
2679
|
setError(null);
|
|
2587
2680
|
try {
|
|
@@ -2609,7 +2702,7 @@ function useAgents(options = true) {
|
|
|
2609
2702
|
setIsLoading(false);
|
|
2610
2703
|
}
|
|
2611
2704
|
}, [fetchWithAuth, page, limit, search, category, scope]);
|
|
2612
|
-
const getAgent =
|
|
2705
|
+
const getAgent = useCallback9(
|
|
2613
2706
|
async (agentId) => {
|
|
2614
2707
|
const res = await fetchWithAuth(`/agents/${agentId}`);
|
|
2615
2708
|
if (!res.ok) throw new Error(`Failed to fetch agent: ${res.statusText}`);
|
|
@@ -2617,7 +2710,7 @@ function useAgents(options = true) {
|
|
|
2617
2710
|
},
|
|
2618
2711
|
[fetchWithAuth]
|
|
2619
2712
|
);
|
|
2620
|
-
const createAgent =
|
|
2713
|
+
const createAgent = useCallback9(
|
|
2621
2714
|
async (input) => {
|
|
2622
2715
|
setError(null);
|
|
2623
2716
|
try {
|
|
@@ -2641,7 +2734,7 @@ function useAgents(options = true) {
|
|
|
2641
2734
|
},
|
|
2642
2735
|
[fetchWithAuth]
|
|
2643
2736
|
);
|
|
2644
|
-
const updateAgent =
|
|
2737
|
+
const updateAgent = useCallback9(
|
|
2645
2738
|
async (agentId, input) => {
|
|
2646
2739
|
setError(null);
|
|
2647
2740
|
try {
|
|
@@ -2665,7 +2758,7 @@ function useAgents(options = true) {
|
|
|
2665
2758
|
},
|
|
2666
2759
|
[fetchWithAuth]
|
|
2667
2760
|
);
|
|
2668
|
-
const deleteAgent =
|
|
2761
|
+
const deleteAgent = useCallback9(
|
|
2669
2762
|
async (agentId) => {
|
|
2670
2763
|
setError(null);
|
|
2671
2764
|
try {
|
|
@@ -2683,7 +2776,7 @@ function useAgents(options = true) {
|
|
|
2683
2776
|
},
|
|
2684
2777
|
[fetchWithAuth]
|
|
2685
2778
|
);
|
|
2686
|
-
const bulkDeleteAgents =
|
|
2779
|
+
const bulkDeleteAgents = useCallback9(
|
|
2687
2780
|
async (ids) => {
|
|
2688
2781
|
setError(null);
|
|
2689
2782
|
try {
|
|
@@ -2726,13 +2819,13 @@ function useAgents(options = true) {
|
|
|
2726
2819
|
}
|
|
2727
2820
|
|
|
2728
2821
|
// src/hooks/useConnection.ts
|
|
2729
|
-
import { useCallback as
|
|
2822
|
+
import { useCallback as useCallback10, useEffect as useEffect9, useState as useState10 } from "react";
|
|
2730
2823
|
function useConnection(autoCheck = true) {
|
|
2731
2824
|
const { fetchWithAuth } = usePersonaContext();
|
|
2732
|
-
const [health, setHealth] =
|
|
2733
|
-
const [isConnected, setIsConnected] =
|
|
2734
|
-
const [isLoading, setIsLoading] =
|
|
2735
|
-
const checkHealth =
|
|
2825
|
+
const [health, setHealth] = useState10(null);
|
|
2826
|
+
const [isConnected, setIsConnected] = useState10(false);
|
|
2827
|
+
const [isLoading, setIsLoading] = useState10(false);
|
|
2828
|
+
const checkHealth = useCallback10(async () => {
|
|
2736
2829
|
setIsLoading(true);
|
|
2737
2830
|
try {
|
|
2738
2831
|
const res = await fetchWithAuth("/health");
|
|
@@ -2765,15 +2858,15 @@ function useConnection(autoCheck = true) {
|
|
|
2765
2858
|
}
|
|
2766
2859
|
|
|
2767
2860
|
// src/hooks/useMcpConnections.ts
|
|
2768
|
-
import { useCallback as
|
|
2861
|
+
import { useCallback as useCallback11, useEffect as useEffect10, useState as useState11 } from "react";
|
|
2769
2862
|
function useMcpConnections(options = {}) {
|
|
2770
2863
|
const { defaultAgentId, fetchWithAuth } = usePersonaContext();
|
|
2771
2864
|
const agentId = options.agentId ?? defaultAgentId;
|
|
2772
2865
|
const autoFetch = options.autoFetch ?? true;
|
|
2773
|
-
const [connections, setConnections] =
|
|
2774
|
-
const [isLoading, setIsLoading] =
|
|
2775
|
-
const [error, setError] =
|
|
2776
|
-
const fetchConnections =
|
|
2866
|
+
const [connections, setConnections] = useState11([]);
|
|
2867
|
+
const [isLoading, setIsLoading] = useState11(false);
|
|
2868
|
+
const [error, setError] = useState11(null);
|
|
2869
|
+
const fetchConnections = useCallback11(async () => {
|
|
2777
2870
|
if (!agentId) return [];
|
|
2778
2871
|
setIsLoading(true);
|
|
2779
2872
|
setError(null);
|
|
@@ -2797,8 +2890,8 @@ function useMcpConnections(options = {}) {
|
|
|
2797
2890
|
setIsLoading(false);
|
|
2798
2891
|
}
|
|
2799
2892
|
}, [agentId, fetchWithAuth, options.returnTo]);
|
|
2800
|
-
const [isDisconnecting, setIsDisconnecting] =
|
|
2801
|
-
const disconnect =
|
|
2893
|
+
const [isDisconnecting, setIsDisconnecting] = useState11(false);
|
|
2894
|
+
const disconnect = useCallback11(
|
|
2802
2895
|
async (mcpId) => {
|
|
2803
2896
|
setIsDisconnecting(true);
|
|
2804
2897
|
setError(null);
|
|
@@ -2840,11 +2933,11 @@ function useMcpConnections(options = {}) {
|
|
|
2840
2933
|
}
|
|
2841
2934
|
|
|
2842
2935
|
// src/hooks/useMcp.ts
|
|
2843
|
-
import { useCallback as
|
|
2936
|
+
import { useCallback as useCallback12 } from "react";
|
|
2844
2937
|
function useMcp(options = {}) {
|
|
2845
2938
|
const { fetchWithAuth } = usePersonaContext();
|
|
2846
2939
|
const defaultMcpId = options.mcpId;
|
|
2847
|
-
const readResource =
|
|
2940
|
+
const readResource = useCallback12(
|
|
2848
2941
|
async (uri, mcpId) => {
|
|
2849
2942
|
const id = mcpId ?? defaultMcpId;
|
|
2850
2943
|
if (!id) throw new Error("MCP server ID is required to read resource");
|
|
@@ -2858,7 +2951,7 @@ function useMcp(options = {}) {
|
|
|
2858
2951
|
},
|
|
2859
2952
|
[fetchWithAuth, defaultMcpId]
|
|
2860
2953
|
);
|
|
2861
|
-
const callTool =
|
|
2954
|
+
const callTool = useCallback12(
|
|
2862
2955
|
async (name, args, mcpId) => {
|
|
2863
2956
|
const id = mcpId ?? defaultMcpId;
|
|
2864
2957
|
if (!id) throw new Error("MCP server ID is required to call tool");
|
|
@@ -2881,20 +2974,20 @@ function useMcp(options = {}) {
|
|
|
2881
2974
|
}
|
|
2882
2975
|
|
|
2883
2976
|
// src/hooks/useSkills.ts
|
|
2884
|
-
import { useCallback as
|
|
2977
|
+
import { useCallback as useCallback13, useEffect as useEffect11, useState as useState12 } from "react";
|
|
2885
2978
|
function useSkills(options = {}) {
|
|
2886
2979
|
const { autoFetch = true, page, limit, search, scope } = options;
|
|
2887
2980
|
const { fetchWithAuth } = usePersonaContext();
|
|
2888
|
-
const [skills, setSkills] =
|
|
2889
|
-
const [pagination, setPagination] =
|
|
2981
|
+
const [skills, setSkills] = useState12([]);
|
|
2982
|
+
const [pagination, setPagination] = useState12({
|
|
2890
2983
|
total: 0,
|
|
2891
2984
|
page: page ?? 1,
|
|
2892
2985
|
limit: limit ?? 20,
|
|
2893
2986
|
pages: 0
|
|
2894
2987
|
});
|
|
2895
|
-
const [isLoading, setIsLoading] =
|
|
2896
|
-
const [error, setError] =
|
|
2897
|
-
const fetchSkills =
|
|
2988
|
+
const [isLoading, setIsLoading] = useState12(false);
|
|
2989
|
+
const [error, setError] = useState12(null);
|
|
2990
|
+
const fetchSkills = useCallback13(async () => {
|
|
2898
2991
|
setIsLoading(true);
|
|
2899
2992
|
setError(null);
|
|
2900
2993
|
try {
|
|
@@ -2921,7 +3014,7 @@ function useSkills(options = {}) {
|
|
|
2921
3014
|
setIsLoading(false);
|
|
2922
3015
|
}
|
|
2923
3016
|
}, [fetchWithAuth, page, limit, search, scope]);
|
|
2924
|
-
const getSkill =
|
|
3017
|
+
const getSkill = useCallback13(
|
|
2925
3018
|
async (skillId) => {
|
|
2926
3019
|
const res = await fetchWithAuth(`/skills/${skillId}`);
|
|
2927
3020
|
if (!res.ok) throw new Error(`Failed to fetch skill: ${res.statusText}`);
|
|
@@ -2929,7 +3022,7 @@ function useSkills(options = {}) {
|
|
|
2929
3022
|
},
|
|
2930
3023
|
[fetchWithAuth]
|
|
2931
3024
|
);
|
|
2932
|
-
const createSkill =
|
|
3025
|
+
const createSkill = useCallback13(
|
|
2933
3026
|
async (input) => {
|
|
2934
3027
|
setError(null);
|
|
2935
3028
|
try {
|
|
@@ -2953,7 +3046,7 @@ function useSkills(options = {}) {
|
|
|
2953
3046
|
},
|
|
2954
3047
|
[fetchWithAuth]
|
|
2955
3048
|
);
|
|
2956
|
-
const updateSkill =
|
|
3049
|
+
const updateSkill = useCallback13(
|
|
2957
3050
|
async (skillId, input) => {
|
|
2958
3051
|
setError(null);
|
|
2959
3052
|
try {
|
|
@@ -2977,7 +3070,7 @@ function useSkills(options = {}) {
|
|
|
2977
3070
|
},
|
|
2978
3071
|
[fetchWithAuth]
|
|
2979
3072
|
);
|
|
2980
|
-
const deleteSkill =
|
|
3073
|
+
const deleteSkill = useCallback13(
|
|
2981
3074
|
async (skillId) => {
|
|
2982
3075
|
setError(null);
|
|
2983
3076
|
try {
|
|
@@ -2995,7 +3088,7 @@ function useSkills(options = {}) {
|
|
|
2995
3088
|
},
|
|
2996
3089
|
[fetchWithAuth]
|
|
2997
3090
|
);
|
|
2998
|
-
const bulkDeleteSkills =
|
|
3091
|
+
const bulkDeleteSkills = useCallback13(
|
|
2999
3092
|
async (ids) => {
|
|
3000
3093
|
setError(null);
|
|
3001
3094
|
try {
|
|
@@ -3020,7 +3113,7 @@ function useSkills(options = {}) {
|
|
|
3020
3113
|
},
|
|
3021
3114
|
[fetchWithAuth]
|
|
3022
3115
|
);
|
|
3023
|
-
const getSkillUsage =
|
|
3116
|
+
const getSkillUsage = useCallback13(
|
|
3024
3117
|
async (skillId) => {
|
|
3025
3118
|
const res = await fetchWithAuth(`/skills/${skillId}/usage`);
|
|
3026
3119
|
if (!res.ok) throw new Error(`Failed to fetch skill usage: ${res.statusText}`);
|
|
@@ -3047,20 +3140,20 @@ function useSkills(options = {}) {
|
|
|
3047
3140
|
}
|
|
3048
3141
|
|
|
3049
3142
|
// src/hooks/useRcpSources.ts
|
|
3050
|
-
import { useCallback as
|
|
3143
|
+
import { useCallback as useCallback14, useEffect as useEffect12, useState as useState13 } from "react";
|
|
3051
3144
|
function useRcpSources(options = {}) {
|
|
3052
3145
|
const { autoFetch = true, page, limit, search } = options;
|
|
3053
3146
|
const { fetchWithAuth } = usePersonaContext();
|
|
3054
|
-
const [rcpSources, setRcpSources] =
|
|
3055
|
-
const [pagination, setPagination] =
|
|
3147
|
+
const [rcpSources, setRcpSources] = useState13([]);
|
|
3148
|
+
const [pagination, setPagination] = useState13({
|
|
3056
3149
|
total: 0,
|
|
3057
3150
|
page: page ?? 1,
|
|
3058
3151
|
limit: limit ?? 20,
|
|
3059
3152
|
pages: 0
|
|
3060
3153
|
});
|
|
3061
|
-
const [isLoading, setIsLoading] =
|
|
3062
|
-
const [error, setError] =
|
|
3063
|
-
const fetchRcpSources =
|
|
3154
|
+
const [isLoading, setIsLoading] = useState13(false);
|
|
3155
|
+
const [error, setError] = useState13(null);
|
|
3156
|
+
const fetchRcpSources = useCallback14(async () => {
|
|
3064
3157
|
setIsLoading(true);
|
|
3065
3158
|
setError(null);
|
|
3066
3159
|
try {
|
|
@@ -3086,7 +3179,7 @@ function useRcpSources(options = {}) {
|
|
|
3086
3179
|
setIsLoading(false);
|
|
3087
3180
|
}
|
|
3088
3181
|
}, [fetchWithAuth, page, limit, search]);
|
|
3089
|
-
const getRcpSource =
|
|
3182
|
+
const getRcpSource = useCallback14(
|
|
3090
3183
|
async (sourceId) => {
|
|
3091
3184
|
const res = await fetchWithAuth(`/rcp-sources/${sourceId}`);
|
|
3092
3185
|
if (!res.ok) throw new Error(`Failed to fetch RCP source: ${res.statusText}`);
|
|
@@ -3094,7 +3187,7 @@ function useRcpSources(options = {}) {
|
|
|
3094
3187
|
},
|
|
3095
3188
|
[fetchWithAuth]
|
|
3096
3189
|
);
|
|
3097
|
-
const createRcpSource =
|
|
3190
|
+
const createRcpSource = useCallback14(
|
|
3098
3191
|
async (input) => {
|
|
3099
3192
|
setError(null);
|
|
3100
3193
|
try {
|
|
@@ -3118,7 +3211,7 @@ function useRcpSources(options = {}) {
|
|
|
3118
3211
|
},
|
|
3119
3212
|
[fetchWithAuth]
|
|
3120
3213
|
);
|
|
3121
|
-
const updateRcpSource =
|
|
3214
|
+
const updateRcpSource = useCallback14(
|
|
3122
3215
|
async (sourceId, input) => {
|
|
3123
3216
|
setError(null);
|
|
3124
3217
|
try {
|
|
@@ -3142,7 +3235,7 @@ function useRcpSources(options = {}) {
|
|
|
3142
3235
|
},
|
|
3143
3236
|
[fetchWithAuth]
|
|
3144
3237
|
);
|
|
3145
|
-
const deleteRcpSource =
|
|
3238
|
+
const deleteRcpSource = useCallback14(
|
|
3146
3239
|
async (sourceId) => {
|
|
3147
3240
|
setError(null);
|
|
3148
3241
|
try {
|
|
@@ -3160,7 +3253,7 @@ function useRcpSources(options = {}) {
|
|
|
3160
3253
|
},
|
|
3161
3254
|
[fetchWithAuth]
|
|
3162
3255
|
);
|
|
3163
|
-
const bulkDeleteRcpSources =
|
|
3256
|
+
const bulkDeleteRcpSources = useCallback14(
|
|
3164
3257
|
async (ids) => {
|
|
3165
3258
|
setError(null);
|
|
3166
3259
|
try {
|
|
@@ -3185,7 +3278,7 @@ function useRcpSources(options = {}) {
|
|
|
3185
3278
|
},
|
|
3186
3279
|
[fetchWithAuth]
|
|
3187
3280
|
);
|
|
3188
|
-
const getRcpSourceUsage =
|
|
3281
|
+
const getRcpSourceUsage = useCallback14(
|
|
3189
3282
|
async (sourceId) => {
|
|
3190
3283
|
const res = await fetchWithAuth(`/rcp-sources/${sourceId}/usage`);
|
|
3191
3284
|
if (!res.ok) throw new Error(`Failed to fetch RCP source usage: ${res.statusText}`);
|
|
@@ -3193,7 +3286,7 @@ function useRcpSources(options = {}) {
|
|
|
3193
3286
|
},
|
|
3194
3287
|
[fetchWithAuth]
|
|
3195
3288
|
);
|
|
3196
|
-
const testRcpSourceConnection =
|
|
3289
|
+
const testRcpSourceConnection = useCallback14(
|
|
3197
3290
|
async (sourceId) => {
|
|
3198
3291
|
setError(null);
|
|
3199
3292
|
try {
|
|
@@ -3237,21 +3330,21 @@ function useRcpSources(options = {}) {
|
|
|
3237
3330
|
}
|
|
3238
3331
|
|
|
3239
3332
|
// src/hooks/useKnowledgeBases.ts
|
|
3240
|
-
import { useCallback as
|
|
3333
|
+
import { useCallback as useCallback15, useEffect as useEffect13, useState as useState14 } from "react";
|
|
3241
3334
|
function useKnowledgeBases(options = {}) {
|
|
3242
3335
|
const { autoFetch = true, page, limit, search, scope } = options;
|
|
3243
3336
|
const { fetchWithAuth } = usePersonaContext();
|
|
3244
|
-
const [knowledgeBases, setKnowledgeBases] =
|
|
3245
|
-
const [pagination, setPagination] =
|
|
3337
|
+
const [knowledgeBases, setKnowledgeBases] = useState14([]);
|
|
3338
|
+
const [pagination, setPagination] = useState14({
|
|
3246
3339
|
total: 0,
|
|
3247
3340
|
page: page ?? 1,
|
|
3248
3341
|
limit: limit ?? 20,
|
|
3249
3342
|
pages: 0
|
|
3250
3343
|
});
|
|
3251
|
-
const [isLoading, setIsLoading] =
|
|
3252
|
-
const [isUploading, setIsUploading] =
|
|
3253
|
-
const [error, setError] =
|
|
3254
|
-
const fetchKnowledgeBases =
|
|
3344
|
+
const [isLoading, setIsLoading] = useState14(false);
|
|
3345
|
+
const [isUploading, setIsUploading] = useState14(false);
|
|
3346
|
+
const [error, setError] = useState14(null);
|
|
3347
|
+
const fetchKnowledgeBases = useCallback15(async () => {
|
|
3255
3348
|
setIsLoading(true);
|
|
3256
3349
|
setError(null);
|
|
3257
3350
|
try {
|
|
@@ -3278,7 +3371,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3278
3371
|
setIsLoading(false);
|
|
3279
3372
|
}
|
|
3280
3373
|
}, [fetchWithAuth, page, limit, search, scope]);
|
|
3281
|
-
const getKnowledgeBase =
|
|
3374
|
+
const getKnowledgeBase = useCallback15(
|
|
3282
3375
|
async (kbId) => {
|
|
3283
3376
|
const res = await fetchWithAuth(`/knowledge/${kbId}`);
|
|
3284
3377
|
if (!res.ok) throw new Error(`Failed to fetch knowledge base: ${res.statusText}`);
|
|
@@ -3286,7 +3379,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3286
3379
|
},
|
|
3287
3380
|
[fetchWithAuth]
|
|
3288
3381
|
);
|
|
3289
|
-
const createKnowledgeBase =
|
|
3382
|
+
const createKnowledgeBase = useCallback15(
|
|
3290
3383
|
async (input) => {
|
|
3291
3384
|
setError(null);
|
|
3292
3385
|
try {
|
|
@@ -3310,7 +3403,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3310
3403
|
},
|
|
3311
3404
|
[fetchWithAuth]
|
|
3312
3405
|
);
|
|
3313
|
-
const updateKnowledgeBase =
|
|
3406
|
+
const updateKnowledgeBase = useCallback15(
|
|
3314
3407
|
async (kbId, input) => {
|
|
3315
3408
|
setError(null);
|
|
3316
3409
|
try {
|
|
@@ -3334,7 +3427,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3334
3427
|
},
|
|
3335
3428
|
[fetchWithAuth]
|
|
3336
3429
|
);
|
|
3337
|
-
const deleteKnowledgeBase =
|
|
3430
|
+
const deleteKnowledgeBase = useCallback15(
|
|
3338
3431
|
async (kbId) => {
|
|
3339
3432
|
setError(null);
|
|
3340
3433
|
try {
|
|
@@ -3352,7 +3445,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3352
3445
|
},
|
|
3353
3446
|
[fetchWithAuth]
|
|
3354
3447
|
);
|
|
3355
|
-
const bulkDeleteKnowledgeBases =
|
|
3448
|
+
const bulkDeleteKnowledgeBases = useCallback15(
|
|
3356
3449
|
async (ids) => {
|
|
3357
3450
|
setError(null);
|
|
3358
3451
|
try {
|
|
@@ -3377,7 +3470,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3377
3470
|
},
|
|
3378
3471
|
[fetchWithAuth]
|
|
3379
3472
|
);
|
|
3380
|
-
const getKnowledgeBaseUsage =
|
|
3473
|
+
const getKnowledgeBaseUsage = useCallback15(
|
|
3381
3474
|
async (kbId) => {
|
|
3382
3475
|
const res = await fetchWithAuth(`/knowledge/${kbId}/usage`);
|
|
3383
3476
|
if (!res.ok) throw new Error(`Failed to fetch knowledge base usage: ${res.statusText}`);
|
|
@@ -3385,7 +3478,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3385
3478
|
},
|
|
3386
3479
|
[fetchWithAuth]
|
|
3387
3480
|
);
|
|
3388
|
-
const uploadDocuments =
|
|
3481
|
+
const uploadDocuments = useCallback15(
|
|
3389
3482
|
async (kbId, files) => {
|
|
3390
3483
|
setIsUploading(true);
|
|
3391
3484
|
setError(null);
|
|
@@ -3427,7 +3520,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3427
3520
|
},
|
|
3428
3521
|
[fetchWithAuth]
|
|
3429
3522
|
);
|
|
3430
|
-
const listDocuments =
|
|
3523
|
+
const listDocuments = useCallback15(
|
|
3431
3524
|
async (kbId) => {
|
|
3432
3525
|
const res = await fetchWithAuth(`/knowledge/${kbId}/documents`);
|
|
3433
3526
|
if (!res.ok) throw new Error(`Failed to list documents: ${res.statusText}`);
|
|
@@ -3435,7 +3528,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3435
3528
|
},
|
|
3436
3529
|
[fetchWithAuth]
|
|
3437
3530
|
);
|
|
3438
|
-
const deleteDocument =
|
|
3531
|
+
const deleteDocument = useCallback15(
|
|
3439
3532
|
async (kbId, sourceName) => {
|
|
3440
3533
|
setError(null);
|
|
3441
3534
|
try {
|
|
@@ -3462,7 +3555,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3462
3555
|
},
|
|
3463
3556
|
[fetchWithAuth]
|
|
3464
3557
|
);
|
|
3465
|
-
const searchKnowledgeBase =
|
|
3558
|
+
const searchKnowledgeBase = useCallback15(
|
|
3466
3559
|
async (kbId, query, opts) => {
|
|
3467
3560
|
const res = await fetchWithAuth(`/knowledge/${kbId}/search`, {
|
|
3468
3561
|
method: "POST",
|
|
@@ -3501,20 +3594,20 @@ function useKnowledgeBases(options = {}) {
|
|
|
3501
3594
|
}
|
|
3502
3595
|
|
|
3503
3596
|
// src/hooks/useMcpAdmin.ts
|
|
3504
|
-
import { useCallback as
|
|
3597
|
+
import { useCallback as useCallback16, useEffect as useEffect14, useState as useState15 } from "react";
|
|
3505
3598
|
function useMcpAdmin(options = {}) {
|
|
3506
3599
|
const { autoFetch = true, page, limit, search } = options;
|
|
3507
3600
|
const { fetchWithAuth } = usePersonaContext();
|
|
3508
|
-
const [mcps, setMcps] =
|
|
3509
|
-
const [pagination, setPagination] =
|
|
3601
|
+
const [mcps, setMcps] = useState15([]);
|
|
3602
|
+
const [pagination, setPagination] = useState15({
|
|
3510
3603
|
total: 0,
|
|
3511
3604
|
page: page ?? 1,
|
|
3512
3605
|
limit: limit ?? 20,
|
|
3513
3606
|
pages: 0
|
|
3514
3607
|
});
|
|
3515
|
-
const [isLoading, setIsLoading] =
|
|
3516
|
-
const [error, setError] =
|
|
3517
|
-
const fetchMcps =
|
|
3608
|
+
const [isLoading, setIsLoading] = useState15(false);
|
|
3609
|
+
const [error, setError] = useState15(null);
|
|
3610
|
+
const fetchMcps = useCallback16(async () => {
|
|
3518
3611
|
setIsLoading(true);
|
|
3519
3612
|
setError(null);
|
|
3520
3613
|
try {
|
|
@@ -3540,7 +3633,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3540
3633
|
setIsLoading(false);
|
|
3541
3634
|
}
|
|
3542
3635
|
}, [fetchWithAuth, page, limit, search]);
|
|
3543
|
-
const getMcp =
|
|
3636
|
+
const getMcp = useCallback16(
|
|
3544
3637
|
async (mcpId) => {
|
|
3545
3638
|
const res = await fetchWithAuth(`/mcps/${mcpId}`);
|
|
3546
3639
|
if (!res.ok) throw new Error(`Failed to fetch MCP: ${res.statusText}`);
|
|
@@ -3548,7 +3641,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3548
3641
|
},
|
|
3549
3642
|
[fetchWithAuth]
|
|
3550
3643
|
);
|
|
3551
|
-
const createMcp =
|
|
3644
|
+
const createMcp = useCallback16(
|
|
3552
3645
|
async (input) => {
|
|
3553
3646
|
setError(null);
|
|
3554
3647
|
try {
|
|
@@ -3572,7 +3665,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3572
3665
|
},
|
|
3573
3666
|
[fetchWithAuth]
|
|
3574
3667
|
);
|
|
3575
|
-
const updateMcp =
|
|
3668
|
+
const updateMcp = useCallback16(
|
|
3576
3669
|
async (mcpId, input) => {
|
|
3577
3670
|
setError(null);
|
|
3578
3671
|
try {
|
|
@@ -3596,7 +3689,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3596
3689
|
},
|
|
3597
3690
|
[fetchWithAuth]
|
|
3598
3691
|
);
|
|
3599
|
-
const deleteMcp =
|
|
3692
|
+
const deleteMcp = useCallback16(
|
|
3600
3693
|
async (mcpId) => {
|
|
3601
3694
|
setError(null);
|
|
3602
3695
|
try {
|
|
@@ -3614,7 +3707,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3614
3707
|
},
|
|
3615
3708
|
[fetchWithAuth]
|
|
3616
3709
|
);
|
|
3617
|
-
const bulkDeleteMcps =
|
|
3710
|
+
const bulkDeleteMcps = useCallback16(
|
|
3618
3711
|
async (ids) => {
|
|
3619
3712
|
setError(null);
|
|
3620
3713
|
try {
|
|
@@ -3639,7 +3732,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3639
3732
|
},
|
|
3640
3733
|
[fetchWithAuth]
|
|
3641
3734
|
);
|
|
3642
|
-
const testConnection =
|
|
3735
|
+
const testConnection = useCallback16(
|
|
3643
3736
|
async (mcpId) => {
|
|
3644
3737
|
setError(null);
|
|
3645
3738
|
try {
|
|
@@ -3682,21 +3775,21 @@ function useMcpAdmin(options = {}) {
|
|
|
3682
3775
|
}
|
|
3683
3776
|
|
|
3684
3777
|
// src/hooks/useWorkflows.ts
|
|
3685
|
-
import { useCallback as
|
|
3778
|
+
import { useCallback as useCallback17, useEffect as useEffect15, useState as useState16 } from "react";
|
|
3686
3779
|
function useWorkflows(options) {
|
|
3687
3780
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
3688
3781
|
const { autoFetch = true, search, scope, visibility, isEnabled, page, limit } = opts;
|
|
3689
3782
|
const { fetchWithAuth } = usePersonaContext();
|
|
3690
|
-
const [workflows, setWorkflows] =
|
|
3691
|
-
const [pagination, setPagination] =
|
|
3783
|
+
const [workflows, setWorkflows] = useState16([]);
|
|
3784
|
+
const [pagination, setPagination] = useState16({
|
|
3692
3785
|
page: page ?? 1,
|
|
3693
3786
|
limit: limit ?? 20,
|
|
3694
3787
|
total: 0,
|
|
3695
3788
|
totalPages: 0
|
|
3696
3789
|
});
|
|
3697
|
-
const [isLoading, setIsLoading] =
|
|
3698
|
-
const [error, setError] =
|
|
3699
|
-
const fetchWorkflows =
|
|
3790
|
+
const [isLoading, setIsLoading] = useState16(false);
|
|
3791
|
+
const [error, setError] = useState16(null);
|
|
3792
|
+
const fetchWorkflows = useCallback17(async () => {
|
|
3700
3793
|
setIsLoading(true);
|
|
3701
3794
|
setError(null);
|
|
3702
3795
|
try {
|
|
@@ -3742,7 +3835,7 @@ function useWorkflows(options) {
|
|
|
3742
3835
|
setIsLoading(false);
|
|
3743
3836
|
}
|
|
3744
3837
|
}, [fetchWithAuth, search, scope, visibility, isEnabled, page, limit]);
|
|
3745
|
-
const createWorkflow =
|
|
3838
|
+
const createWorkflow = useCallback17(
|
|
3746
3839
|
async (input) => {
|
|
3747
3840
|
setError(null);
|
|
3748
3841
|
try {
|
|
@@ -3782,17 +3875,17 @@ function useWorkflows(options) {
|
|
|
3782
3875
|
}
|
|
3783
3876
|
|
|
3784
3877
|
// src/hooks/useWorkflow.ts
|
|
3785
|
-
import { useCallback as
|
|
3878
|
+
import { useCallback as useCallback18, useEffect as useEffect16, useState as useState17 } from "react";
|
|
3786
3879
|
function useWorkflow(workflowId, options) {
|
|
3787
3880
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
3788
3881
|
const { autoFetch = true } = opts;
|
|
3789
3882
|
const { fetchWithAuth } = usePersonaContext();
|
|
3790
|
-
const [workflow, setWorkflow] =
|
|
3791
|
-
const [versions, setVersions] =
|
|
3792
|
-
const [mermaid, setMermaid] =
|
|
3793
|
-
const [isLoading, setIsLoading] =
|
|
3794
|
-
const [error, setError] =
|
|
3795
|
-
const fetchWorkflow =
|
|
3883
|
+
const [workflow, setWorkflow] = useState17(null);
|
|
3884
|
+
const [versions, setVersions] = useState17([]);
|
|
3885
|
+
const [mermaid, setMermaid] = useState17(null);
|
|
3886
|
+
const [isLoading, setIsLoading] = useState17(false);
|
|
3887
|
+
const [error, setError] = useState17(null);
|
|
3888
|
+
const fetchWorkflow = useCallback18(async () => {
|
|
3796
3889
|
if (!workflowId) return null;
|
|
3797
3890
|
setIsLoading(true);
|
|
3798
3891
|
setError(null);
|
|
@@ -3812,7 +3905,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3812
3905
|
setIsLoading(false);
|
|
3813
3906
|
}
|
|
3814
3907
|
}, [fetchWithAuth, workflowId]);
|
|
3815
|
-
const fetchVersions =
|
|
3908
|
+
const fetchVersions = useCallback18(async () => {
|
|
3816
3909
|
if (!workflowId) return [];
|
|
3817
3910
|
try {
|
|
3818
3911
|
const res = await fetchWithAuth(`/workflows/${workflowId}/versions`);
|
|
@@ -3825,7 +3918,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3825
3918
|
return [];
|
|
3826
3919
|
}
|
|
3827
3920
|
}, [fetchWithAuth, workflowId]);
|
|
3828
|
-
const getVersion =
|
|
3921
|
+
const getVersion = useCallback18(
|
|
3829
3922
|
async (version) => {
|
|
3830
3923
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3831
3924
|
const res = await fetchWithAuth(`/workflows/${workflowId}/versions/${version}`);
|
|
@@ -3836,7 +3929,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3836
3929
|
},
|
|
3837
3930
|
[fetchWithAuth, workflowId]
|
|
3838
3931
|
);
|
|
3839
|
-
const fetchMermaid =
|
|
3932
|
+
const fetchMermaid = useCallback18(async () => {
|
|
3840
3933
|
if (!workflowId) return "";
|
|
3841
3934
|
try {
|
|
3842
3935
|
const res = await fetchWithAuth(`/workflows/${workflowId}/mermaid`);
|
|
@@ -3849,7 +3942,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3849
3942
|
return "";
|
|
3850
3943
|
}
|
|
3851
3944
|
}, [fetchWithAuth, workflowId]);
|
|
3852
|
-
const updateWorkflow =
|
|
3945
|
+
const updateWorkflow = useCallback18(
|
|
3853
3946
|
async (input) => {
|
|
3854
3947
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3855
3948
|
setError(null);
|
|
@@ -3868,7 +3961,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3868
3961
|
},
|
|
3869
3962
|
[fetchWithAuth, workflowId]
|
|
3870
3963
|
);
|
|
3871
|
-
const saveDraft =
|
|
3964
|
+
const saveDraft = useCallback18(
|
|
3872
3965
|
async (draft) => {
|
|
3873
3966
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3874
3967
|
setError(null);
|
|
@@ -3887,7 +3980,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3887
3980
|
},
|
|
3888
3981
|
[fetchWithAuth, workflowId]
|
|
3889
3982
|
);
|
|
3890
|
-
const publish =
|
|
3983
|
+
const publish = useCallback18(async () => {
|
|
3891
3984
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3892
3985
|
setError(null);
|
|
3893
3986
|
const res = await fetchWithAuth(`/workflows/${workflowId}/publish`, {
|
|
@@ -3902,7 +3995,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3902
3995
|
void fetchVersions();
|
|
3903
3996
|
return versionResult;
|
|
3904
3997
|
}, [fetchWithAuth, workflowId, fetchWorkflow, fetchVersions]);
|
|
3905
|
-
const deleteWorkflow =
|
|
3998
|
+
const deleteWorkflow = useCallback18(async () => {
|
|
3906
3999
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3907
4000
|
setError(null);
|
|
3908
4001
|
const res = await fetchWithAuth(`/workflows/${workflowId}`, {
|
|
@@ -3936,25 +4029,25 @@ function useWorkflow(workflowId, options) {
|
|
|
3936
4029
|
}
|
|
3937
4030
|
|
|
3938
4031
|
// src/hooks/useWorkflowStream.ts
|
|
3939
|
-
import { useCallback as
|
|
4032
|
+
import { useCallback as useCallback19, useEffect as useEffect17, useRef as useRef5, useState as useState18 } from "react";
|
|
3940
4033
|
function useWorkflowStream(workflowId, options) {
|
|
3941
4034
|
const { baseUrl, getAuthToken, fetchWithAuth, logger } = usePersonaContext();
|
|
3942
|
-
const [status, setStatus] =
|
|
3943
|
-
const [runId, setRunId] =
|
|
3944
|
-
const [activeNodeId, setActiveNodeId] =
|
|
3945
|
-
const [nodeRuns, setNodeRuns] =
|
|
4035
|
+
const [status, setStatus] = useState18("idle");
|
|
4036
|
+
const [runId, setRunId] = useState18(null);
|
|
4037
|
+
const [activeNodeId, setActiveNodeId] = useState18(null);
|
|
4038
|
+
const [nodeRuns, setNodeRuns] = useState18(
|
|
3946
4039
|
{}
|
|
3947
4040
|
);
|
|
3948
|
-
const [text, setText] =
|
|
3949
|
-
const [output, setOutput] =
|
|
3950
|
-
const [error, setError] =
|
|
3951
|
-
const [events, setEvents] =
|
|
3952
|
-
const abortControllerRef =
|
|
3953
|
-
const currentRunIdRef =
|
|
4041
|
+
const [text, setText] = useState18("");
|
|
4042
|
+
const [output, setOutput] = useState18(null);
|
|
4043
|
+
const [error, setError] = useState18(null);
|
|
4044
|
+
const [events, setEvents] = useState18([]);
|
|
4045
|
+
const abortControllerRef = useRef5(null);
|
|
4046
|
+
const currentRunIdRef = useRef5(null);
|
|
3954
4047
|
currentRunIdRef.current = runId;
|
|
3955
|
-
const optionsRef =
|
|
4048
|
+
const optionsRef = useRef5(options);
|
|
3956
4049
|
optionsRef.current = options;
|
|
3957
|
-
const cancel =
|
|
4050
|
+
const cancel = useCallback19(async () => {
|
|
3958
4051
|
if (abortControllerRef.current) {
|
|
3959
4052
|
abortControllerRef.current.abort();
|
|
3960
4053
|
abortControllerRef.current = null;
|
|
@@ -3975,7 +4068,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
3975
4068
|
setStatus("cancelled");
|
|
3976
4069
|
setActiveNodeId(null);
|
|
3977
4070
|
}, [fetchWithAuth, logger]);
|
|
3978
|
-
const reset =
|
|
4071
|
+
const reset = useCallback19(() => {
|
|
3979
4072
|
if (abortControllerRef.current) {
|
|
3980
4073
|
abortControllerRef.current.abort();
|
|
3981
4074
|
abortControllerRef.current = null;
|
|
@@ -3989,7 +4082,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
3989
4082
|
setError(null);
|
|
3990
4083
|
setEvents([]);
|
|
3991
4084
|
}, []);
|
|
3992
|
-
const processStream =
|
|
4085
|
+
const processStream = useCallback19(
|
|
3993
4086
|
async (url, method, body, targetRunId) => {
|
|
3994
4087
|
if (abortControllerRef.current) {
|
|
3995
4088
|
abortControllerRef.current.abort();
|
|
@@ -4154,7 +4247,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4154
4247
|
},
|
|
4155
4248
|
[getAuthToken]
|
|
4156
4249
|
);
|
|
4157
|
-
const start =
|
|
4250
|
+
const start = useCallback19(
|
|
4158
4251
|
async (input, opts) => {
|
|
4159
4252
|
const targetWfId = opts?.workflowId || workflowId;
|
|
4160
4253
|
if (!targetWfId) {
|
|
@@ -4175,7 +4268,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4175
4268
|
},
|
|
4176
4269
|
[workflowId, baseUrl, processStream]
|
|
4177
4270
|
);
|
|
4178
|
-
const resume =
|
|
4271
|
+
const resume = useCallback19(
|
|
4179
4272
|
async (targetRunId, sinceSeq) => {
|
|
4180
4273
|
if (!targetRunId) {
|
|
4181
4274
|
throw new Error("Run ID is required to resume stream");
|
|
@@ -4213,21 +4306,21 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4213
4306
|
}
|
|
4214
4307
|
|
|
4215
4308
|
// src/hooks/useWorkflowRuns.ts
|
|
4216
|
-
import { useCallback as
|
|
4309
|
+
import { useCallback as useCallback20, useEffect as useEffect18, useState as useState19 } from "react";
|
|
4217
4310
|
function useWorkflowRuns(workflowId, options) {
|
|
4218
4311
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
4219
4312
|
const { autoFetch = true, page = 1, limit = 20 } = opts;
|
|
4220
4313
|
const { fetchWithAuth } = usePersonaContext();
|
|
4221
|
-
const [runs, setRuns] =
|
|
4222
|
-
const [pagination, setPagination] =
|
|
4314
|
+
const [runs, setRuns] = useState19([]);
|
|
4315
|
+
const [pagination, setPagination] = useState19({
|
|
4223
4316
|
page,
|
|
4224
4317
|
limit,
|
|
4225
4318
|
total: 0,
|
|
4226
4319
|
totalPages: 0
|
|
4227
4320
|
});
|
|
4228
|
-
const [isLoading, setIsLoading] =
|
|
4229
|
-
const [error, setError] =
|
|
4230
|
-
const fetchRuns =
|
|
4321
|
+
const [isLoading, setIsLoading] = useState19(false);
|
|
4322
|
+
const [error, setError] = useState19(null);
|
|
4323
|
+
const fetchRuns = useCallback20(async () => {
|
|
4231
4324
|
if (!workflowId) return [];
|
|
4232
4325
|
setIsLoading(true);
|
|
4233
4326
|
setError(null);
|
|
@@ -4259,7 +4352,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4259
4352
|
setIsLoading(false);
|
|
4260
4353
|
}
|
|
4261
4354
|
}, [fetchWithAuth, workflowId, page, limit]);
|
|
4262
|
-
const getRun =
|
|
4355
|
+
const getRun = useCallback20(
|
|
4263
4356
|
async (runId) => {
|
|
4264
4357
|
if (!runId) throw new Error("Run ID is required");
|
|
4265
4358
|
const res = await fetchWithAuth(`/workflows/runs/${runId}`);
|
|
@@ -4270,7 +4363,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4270
4363
|
},
|
|
4271
4364
|
[fetchWithAuth]
|
|
4272
4365
|
);
|
|
4273
|
-
const cancelRun =
|
|
4366
|
+
const cancelRun = useCallback20(
|
|
4274
4367
|
async (runId) => {
|
|
4275
4368
|
if (!runId) throw new Error("Run ID is required");
|
|
4276
4369
|
const res = await fetchWithAuth(`/workflows/runs/${runId}/cancel`, {
|
|
@@ -4309,7 +4402,7 @@ import {
|
|
|
4309
4402
|
getLogLevel,
|
|
4310
4403
|
isLevelEnabled
|
|
4311
4404
|
} from "@personaai/logger";
|
|
4312
|
-
var VERSION = "0.
|
|
4405
|
+
var VERSION = "0.18.1";
|
|
4313
4406
|
export {
|
|
4314
4407
|
ARCHITECT_AGENT_ID,
|
|
4315
4408
|
PersonaProvider,
|
|
@@ -4331,6 +4424,7 @@ export {
|
|
|
4331
4424
|
useMcpAdmin,
|
|
4332
4425
|
useMcpConnections,
|
|
4333
4426
|
useMemory,
|
|
4427
|
+
useMessages,
|
|
4334
4428
|
usePersonaContext,
|
|
4335
4429
|
useRcpSources,
|
|
4336
4430
|
useSkills,
|