@personaai/react 0.17.0 → 0.18.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/README.md +100 -4
- package/dist/index.cjs +214 -149
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +67 -2
- package/dist/index.d.ts +67 -2
- package/dist/index.js +201 -137
- package/dist/index.js.map +1 -1
- package/package.json +1 -6
- package/dist/docs/.nojekyll +0 -1
package/dist/index.cjs
CHANGED
|
@@ -40,6 +40,7 @@ __export(index_exports, {
|
|
|
40
40
|
useMcpAdmin: () => useMcpAdmin,
|
|
41
41
|
useMcpConnections: () => useMcpConnections,
|
|
42
42
|
useMemory: () => useMemory,
|
|
43
|
+
useMessages: () => useMessages,
|
|
43
44
|
usePersonaContext: () => usePersonaContext,
|
|
44
45
|
useRcpSources: () => useRcpSources,
|
|
45
46
|
useSkills: () => useSkills,
|
|
@@ -2518,15 +2519,78 @@ function useVoice(options = {}) {
|
|
|
2518
2519
|
};
|
|
2519
2520
|
}
|
|
2520
2521
|
|
|
2521
|
-
// src/hooks/
|
|
2522
|
+
// src/hooks/useMessages.ts
|
|
2522
2523
|
var import_react8 = require("react");
|
|
2524
|
+
async function readErrorMessage(res, fallback) {
|
|
2525
|
+
try {
|
|
2526
|
+
const body = await res.json();
|
|
2527
|
+
const message = body?.error?.message ?? body?.message;
|
|
2528
|
+
if (typeof message === "string" && message) return message;
|
|
2529
|
+
} catch {
|
|
2530
|
+
}
|
|
2531
|
+
return `${fallback}: ${res.statusText}`;
|
|
2532
|
+
}
|
|
2533
|
+
function useMessages() {
|
|
2534
|
+
const { fetchWithAuth, logger } = usePersonaContext();
|
|
2535
|
+
const messagesLogger = (0, import_react8.useMemo)(() => logger.child("messages"), [logger]);
|
|
2536
|
+
const [isSending, setIsSending] = (0, import_react8.useState)(false);
|
|
2537
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
2538
|
+
const [lastDelivery, setLastDelivery] = (0, import_react8.useState)(null);
|
|
2539
|
+
const inFlightRef = (0, import_react8.useRef)(0);
|
|
2540
|
+
const post = (0, import_react8.useCallback)(
|
|
2541
|
+
async (path, input) => {
|
|
2542
|
+
inFlightRef.current += 1;
|
|
2543
|
+
setIsSending(true);
|
|
2544
|
+
setError(null);
|
|
2545
|
+
try {
|
|
2546
|
+
const res = await fetchWithAuth(path, {
|
|
2547
|
+
method: "POST",
|
|
2548
|
+
headers: { "Content-Type": "application/json" },
|
|
2549
|
+
body: JSON.stringify(input)
|
|
2550
|
+
});
|
|
2551
|
+
if (!res.ok) {
|
|
2552
|
+
throw new Error(await readErrorMessage(res, "Failed to send message"));
|
|
2553
|
+
}
|
|
2554
|
+
const payload = await res.json();
|
|
2555
|
+
const delivery = payload?.data ?? payload;
|
|
2556
|
+
setLastDelivery(delivery);
|
|
2557
|
+
messagesLogger.info("message sent", { path });
|
|
2558
|
+
return delivery;
|
|
2559
|
+
} catch (err) {
|
|
2560
|
+
const errorObj = err instanceof Error ? err : new Error(String(err));
|
|
2561
|
+
messagesLogger.warn("message send failed", {
|
|
2562
|
+
path,
|
|
2563
|
+
error: errorObj.message
|
|
2564
|
+
});
|
|
2565
|
+
setError(errorObj);
|
|
2566
|
+
throw errorObj;
|
|
2567
|
+
} finally {
|
|
2568
|
+
inFlightRef.current -= 1;
|
|
2569
|
+
if (inFlightRef.current === 0) setIsSending(false);
|
|
2570
|
+
}
|
|
2571
|
+
},
|
|
2572
|
+
[fetchWithAuth, messagesLogger]
|
|
2573
|
+
);
|
|
2574
|
+
const send = (0, import_react8.useCallback)(
|
|
2575
|
+
(input) => post("/messages", input),
|
|
2576
|
+
[post]
|
|
2577
|
+
);
|
|
2578
|
+
const sendFromAgent = (0, import_react8.useCallback)(
|
|
2579
|
+
(input) => post("/messages/agent", input),
|
|
2580
|
+
[post]
|
|
2581
|
+
);
|
|
2582
|
+
return { isSending, error, lastDelivery, send, sendFromAgent };
|
|
2583
|
+
}
|
|
2584
|
+
|
|
2585
|
+
// src/hooks/useFiles.ts
|
|
2586
|
+
var import_react9 = require("react");
|
|
2523
2587
|
function useFiles(autoFetch = true) {
|
|
2524
2588
|
const { fetchWithAuth } = usePersonaContext();
|
|
2525
|
-
const [files, setFiles] = (0,
|
|
2526
|
-
const [isLoading, setIsLoading] = (0,
|
|
2527
|
-
const [isUploading, setIsUploading] = (0,
|
|
2528
|
-
const [error, setError] = (0,
|
|
2529
|
-
const fetchFiles = (0,
|
|
2589
|
+
const [files, setFiles] = (0, import_react9.useState)([]);
|
|
2590
|
+
const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
|
|
2591
|
+
const [isUploading, setIsUploading] = (0, import_react9.useState)(false);
|
|
2592
|
+
const [error, setError] = (0, import_react9.useState)(null);
|
|
2593
|
+
const fetchFiles = (0, import_react9.useCallback)(async () => {
|
|
2530
2594
|
setIsLoading(true);
|
|
2531
2595
|
setError(null);
|
|
2532
2596
|
try {
|
|
@@ -2544,7 +2608,7 @@ function useFiles(autoFetch = true) {
|
|
|
2544
2608
|
setIsLoading(false);
|
|
2545
2609
|
}
|
|
2546
2610
|
}, [fetchWithAuth]);
|
|
2547
|
-
const uploadFile = (0,
|
|
2611
|
+
const uploadFile = (0, import_react9.useCallback)(
|
|
2548
2612
|
async (fileOrFormData) => {
|
|
2549
2613
|
setIsUploading(true);
|
|
2550
2614
|
setError(null);
|
|
@@ -2577,7 +2641,7 @@ function useFiles(autoFetch = true) {
|
|
|
2577
2641
|
},
|
|
2578
2642
|
[fetchWithAuth, fetchFiles]
|
|
2579
2643
|
);
|
|
2580
|
-
const deleteFile = (0,
|
|
2644
|
+
const deleteFile = (0, import_react9.useCallback)(
|
|
2581
2645
|
async (fileId) => {
|
|
2582
2646
|
const res = await fetchWithAuth(`/files/${fileId}`, { method: "DELETE" });
|
|
2583
2647
|
if (!res.ok) throw new Error(`Failed to delete file: ${res.statusText}`);
|
|
@@ -2585,7 +2649,7 @@ function useFiles(autoFetch = true) {
|
|
|
2585
2649
|
},
|
|
2586
2650
|
[fetchWithAuth]
|
|
2587
2651
|
);
|
|
2588
|
-
const bulkDeleteFiles = (0,
|
|
2652
|
+
const bulkDeleteFiles = (0, import_react9.useCallback)(
|
|
2589
2653
|
async (fileIds) => {
|
|
2590
2654
|
const res = await fetchWithAuth("/files/bulk-delete", {
|
|
2591
2655
|
method: "POST",
|
|
@@ -2600,10 +2664,10 @@ function useFiles(autoFetch = true) {
|
|
|
2600
2664
|
},
|
|
2601
2665
|
[fetchWithAuth]
|
|
2602
2666
|
);
|
|
2603
|
-
const getDownloadUrl = (0,
|
|
2667
|
+
const getDownloadUrl = (0, import_react9.useCallback)((fileId) => {
|
|
2604
2668
|
return `/files/${fileId}`;
|
|
2605
2669
|
}, []);
|
|
2606
|
-
(0,
|
|
2670
|
+
(0, import_react9.useEffect)(() => {
|
|
2607
2671
|
if (autoFetch) {
|
|
2608
2672
|
void fetchFiles();
|
|
2609
2673
|
}
|
|
@@ -2622,21 +2686,21 @@ function useFiles(autoFetch = true) {
|
|
|
2622
2686
|
}
|
|
2623
2687
|
|
|
2624
2688
|
// src/hooks/useAgents.ts
|
|
2625
|
-
var
|
|
2689
|
+
var import_react10 = require("react");
|
|
2626
2690
|
function useAgents(options = true) {
|
|
2627
2691
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options;
|
|
2628
2692
|
const { autoFetch = true, page, limit, search, category, scope } = opts;
|
|
2629
2693
|
const { fetchWithAuth } = usePersonaContext();
|
|
2630
|
-
const [agents, setAgents] = (0,
|
|
2631
|
-
const [pagination, setPagination] = (0,
|
|
2694
|
+
const [agents, setAgents] = (0, import_react10.useState)([]);
|
|
2695
|
+
const [pagination, setPagination] = (0, import_react10.useState)({
|
|
2632
2696
|
total: 0,
|
|
2633
2697
|
page: page ?? 1,
|
|
2634
2698
|
limit: limit ?? 20,
|
|
2635
2699
|
pages: 0
|
|
2636
2700
|
});
|
|
2637
|
-
const [isLoading, setIsLoading] = (0,
|
|
2638
|
-
const [error, setError] = (0,
|
|
2639
|
-
const fetchAgents = (0,
|
|
2701
|
+
const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
|
|
2702
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
2703
|
+
const fetchAgents = (0, import_react10.useCallback)(async () => {
|
|
2640
2704
|
setIsLoading(true);
|
|
2641
2705
|
setError(null);
|
|
2642
2706
|
try {
|
|
@@ -2664,7 +2728,7 @@ function useAgents(options = true) {
|
|
|
2664
2728
|
setIsLoading(false);
|
|
2665
2729
|
}
|
|
2666
2730
|
}, [fetchWithAuth, page, limit, search, category, scope]);
|
|
2667
|
-
const getAgent = (0,
|
|
2731
|
+
const getAgent = (0, import_react10.useCallback)(
|
|
2668
2732
|
async (agentId) => {
|
|
2669
2733
|
const res = await fetchWithAuth(`/agents/${agentId}`);
|
|
2670
2734
|
if (!res.ok) throw new Error(`Failed to fetch agent: ${res.statusText}`);
|
|
@@ -2672,7 +2736,7 @@ function useAgents(options = true) {
|
|
|
2672
2736
|
},
|
|
2673
2737
|
[fetchWithAuth]
|
|
2674
2738
|
);
|
|
2675
|
-
const createAgent = (0,
|
|
2739
|
+
const createAgent = (0, import_react10.useCallback)(
|
|
2676
2740
|
async (input) => {
|
|
2677
2741
|
setError(null);
|
|
2678
2742
|
try {
|
|
@@ -2696,7 +2760,7 @@ function useAgents(options = true) {
|
|
|
2696
2760
|
},
|
|
2697
2761
|
[fetchWithAuth]
|
|
2698
2762
|
);
|
|
2699
|
-
const updateAgent = (0,
|
|
2763
|
+
const updateAgent = (0, import_react10.useCallback)(
|
|
2700
2764
|
async (agentId, input) => {
|
|
2701
2765
|
setError(null);
|
|
2702
2766
|
try {
|
|
@@ -2720,7 +2784,7 @@ function useAgents(options = true) {
|
|
|
2720
2784
|
},
|
|
2721
2785
|
[fetchWithAuth]
|
|
2722
2786
|
);
|
|
2723
|
-
const deleteAgent = (0,
|
|
2787
|
+
const deleteAgent = (0, import_react10.useCallback)(
|
|
2724
2788
|
async (agentId) => {
|
|
2725
2789
|
setError(null);
|
|
2726
2790
|
try {
|
|
@@ -2738,7 +2802,7 @@ function useAgents(options = true) {
|
|
|
2738
2802
|
},
|
|
2739
2803
|
[fetchWithAuth]
|
|
2740
2804
|
);
|
|
2741
|
-
const bulkDeleteAgents = (0,
|
|
2805
|
+
const bulkDeleteAgents = (0, import_react10.useCallback)(
|
|
2742
2806
|
async (ids) => {
|
|
2743
2807
|
setError(null);
|
|
2744
2808
|
try {
|
|
@@ -2763,7 +2827,7 @@ function useAgents(options = true) {
|
|
|
2763
2827
|
},
|
|
2764
2828
|
[fetchWithAuth]
|
|
2765
2829
|
);
|
|
2766
|
-
(0,
|
|
2830
|
+
(0, import_react10.useEffect)(() => {
|
|
2767
2831
|
if (autoFetch) void fetchAgents();
|
|
2768
2832
|
}, [autoFetch, fetchAgents]);
|
|
2769
2833
|
return {
|
|
@@ -2781,13 +2845,13 @@ function useAgents(options = true) {
|
|
|
2781
2845
|
}
|
|
2782
2846
|
|
|
2783
2847
|
// src/hooks/useConnection.ts
|
|
2784
|
-
var
|
|
2848
|
+
var import_react11 = require("react");
|
|
2785
2849
|
function useConnection(autoCheck = true) {
|
|
2786
2850
|
const { fetchWithAuth } = usePersonaContext();
|
|
2787
|
-
const [health, setHealth] = (0,
|
|
2788
|
-
const [isConnected, setIsConnected] = (0,
|
|
2789
|
-
const [isLoading, setIsLoading] = (0,
|
|
2790
|
-
const checkHealth = (0,
|
|
2851
|
+
const [health, setHealth] = (0, import_react11.useState)(null);
|
|
2852
|
+
const [isConnected, setIsConnected] = (0, import_react11.useState)(false);
|
|
2853
|
+
const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
|
|
2854
|
+
const checkHealth = (0, import_react11.useCallback)(async () => {
|
|
2791
2855
|
setIsLoading(true);
|
|
2792
2856
|
try {
|
|
2793
2857
|
const res = await fetchWithAuth("/health");
|
|
@@ -2806,7 +2870,7 @@ function useConnection(autoCheck = true) {
|
|
|
2806
2870
|
setIsLoading(false);
|
|
2807
2871
|
}
|
|
2808
2872
|
}, [fetchWithAuth]);
|
|
2809
|
-
(0,
|
|
2873
|
+
(0, import_react11.useEffect)(() => {
|
|
2810
2874
|
if (autoCheck) {
|
|
2811
2875
|
void checkHealth();
|
|
2812
2876
|
}
|
|
@@ -2820,15 +2884,15 @@ function useConnection(autoCheck = true) {
|
|
|
2820
2884
|
}
|
|
2821
2885
|
|
|
2822
2886
|
// src/hooks/useMcpConnections.ts
|
|
2823
|
-
var
|
|
2887
|
+
var import_react12 = require("react");
|
|
2824
2888
|
function useMcpConnections(options = {}) {
|
|
2825
2889
|
const { defaultAgentId, fetchWithAuth } = usePersonaContext();
|
|
2826
2890
|
const agentId = options.agentId ?? defaultAgentId;
|
|
2827
2891
|
const autoFetch = options.autoFetch ?? true;
|
|
2828
|
-
const [connections, setConnections] = (0,
|
|
2829
|
-
const [isLoading, setIsLoading] = (0,
|
|
2830
|
-
const [error, setError] = (0,
|
|
2831
|
-
const fetchConnections = (0,
|
|
2892
|
+
const [connections, setConnections] = (0, import_react12.useState)([]);
|
|
2893
|
+
const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
|
|
2894
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
2895
|
+
const fetchConnections = (0, import_react12.useCallback)(async () => {
|
|
2832
2896
|
if (!agentId) return [];
|
|
2833
2897
|
setIsLoading(true);
|
|
2834
2898
|
setError(null);
|
|
@@ -2852,8 +2916,8 @@ function useMcpConnections(options = {}) {
|
|
|
2852
2916
|
setIsLoading(false);
|
|
2853
2917
|
}
|
|
2854
2918
|
}, [agentId, fetchWithAuth, options.returnTo]);
|
|
2855
|
-
const [isDisconnecting, setIsDisconnecting] = (0,
|
|
2856
|
-
const disconnect = (0,
|
|
2919
|
+
const [isDisconnecting, setIsDisconnecting] = (0, import_react12.useState)(false);
|
|
2920
|
+
const disconnect = (0, import_react12.useCallback)(
|
|
2857
2921
|
async (mcpId) => {
|
|
2858
2922
|
setIsDisconnecting(true);
|
|
2859
2923
|
setError(null);
|
|
@@ -2879,7 +2943,7 @@ function useMcpConnections(options = {}) {
|
|
|
2879
2943
|
},
|
|
2880
2944
|
[fetchWithAuth, fetchConnections]
|
|
2881
2945
|
);
|
|
2882
|
-
(0,
|
|
2946
|
+
(0, import_react12.useEffect)(() => {
|
|
2883
2947
|
if (autoFetch) void fetchConnections();
|
|
2884
2948
|
}, [autoFetch, fetchConnections]);
|
|
2885
2949
|
return {
|
|
@@ -2895,11 +2959,11 @@ function useMcpConnections(options = {}) {
|
|
|
2895
2959
|
}
|
|
2896
2960
|
|
|
2897
2961
|
// src/hooks/useMcp.ts
|
|
2898
|
-
var
|
|
2962
|
+
var import_react13 = require("react");
|
|
2899
2963
|
function useMcp(options = {}) {
|
|
2900
2964
|
const { fetchWithAuth } = usePersonaContext();
|
|
2901
2965
|
const defaultMcpId = options.mcpId;
|
|
2902
|
-
const readResource = (0,
|
|
2966
|
+
const readResource = (0, import_react13.useCallback)(
|
|
2903
2967
|
async (uri, mcpId) => {
|
|
2904
2968
|
const id = mcpId ?? defaultMcpId;
|
|
2905
2969
|
if (!id) throw new Error("MCP server ID is required to read resource");
|
|
@@ -2913,7 +2977,7 @@ function useMcp(options = {}) {
|
|
|
2913
2977
|
},
|
|
2914
2978
|
[fetchWithAuth, defaultMcpId]
|
|
2915
2979
|
);
|
|
2916
|
-
const callTool = (0,
|
|
2980
|
+
const callTool = (0, import_react13.useCallback)(
|
|
2917
2981
|
async (name, args, mcpId) => {
|
|
2918
2982
|
const id = mcpId ?? defaultMcpId;
|
|
2919
2983
|
if (!id) throw new Error("MCP server ID is required to call tool");
|
|
@@ -2936,20 +3000,20 @@ function useMcp(options = {}) {
|
|
|
2936
3000
|
}
|
|
2937
3001
|
|
|
2938
3002
|
// src/hooks/useSkills.ts
|
|
2939
|
-
var
|
|
3003
|
+
var import_react14 = require("react");
|
|
2940
3004
|
function useSkills(options = {}) {
|
|
2941
3005
|
const { autoFetch = true, page, limit, search, scope } = options;
|
|
2942
3006
|
const { fetchWithAuth } = usePersonaContext();
|
|
2943
|
-
const [skills, setSkills] = (0,
|
|
2944
|
-
const [pagination, setPagination] = (0,
|
|
3007
|
+
const [skills, setSkills] = (0, import_react14.useState)([]);
|
|
3008
|
+
const [pagination, setPagination] = (0, import_react14.useState)({
|
|
2945
3009
|
total: 0,
|
|
2946
3010
|
page: page ?? 1,
|
|
2947
3011
|
limit: limit ?? 20,
|
|
2948
3012
|
pages: 0
|
|
2949
3013
|
});
|
|
2950
|
-
const [isLoading, setIsLoading] = (0,
|
|
2951
|
-
const [error, setError] = (0,
|
|
2952
|
-
const fetchSkills = (0,
|
|
3014
|
+
const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
|
|
3015
|
+
const [error, setError] = (0, import_react14.useState)(null);
|
|
3016
|
+
const fetchSkills = (0, import_react14.useCallback)(async () => {
|
|
2953
3017
|
setIsLoading(true);
|
|
2954
3018
|
setError(null);
|
|
2955
3019
|
try {
|
|
@@ -2976,7 +3040,7 @@ function useSkills(options = {}) {
|
|
|
2976
3040
|
setIsLoading(false);
|
|
2977
3041
|
}
|
|
2978
3042
|
}, [fetchWithAuth, page, limit, search, scope]);
|
|
2979
|
-
const getSkill = (0,
|
|
3043
|
+
const getSkill = (0, import_react14.useCallback)(
|
|
2980
3044
|
async (skillId) => {
|
|
2981
3045
|
const res = await fetchWithAuth(`/skills/${skillId}`);
|
|
2982
3046
|
if (!res.ok) throw new Error(`Failed to fetch skill: ${res.statusText}`);
|
|
@@ -2984,7 +3048,7 @@ function useSkills(options = {}) {
|
|
|
2984
3048
|
},
|
|
2985
3049
|
[fetchWithAuth]
|
|
2986
3050
|
);
|
|
2987
|
-
const createSkill = (0,
|
|
3051
|
+
const createSkill = (0, import_react14.useCallback)(
|
|
2988
3052
|
async (input) => {
|
|
2989
3053
|
setError(null);
|
|
2990
3054
|
try {
|
|
@@ -3008,7 +3072,7 @@ function useSkills(options = {}) {
|
|
|
3008
3072
|
},
|
|
3009
3073
|
[fetchWithAuth]
|
|
3010
3074
|
);
|
|
3011
|
-
const updateSkill = (0,
|
|
3075
|
+
const updateSkill = (0, import_react14.useCallback)(
|
|
3012
3076
|
async (skillId, input) => {
|
|
3013
3077
|
setError(null);
|
|
3014
3078
|
try {
|
|
@@ -3032,7 +3096,7 @@ function useSkills(options = {}) {
|
|
|
3032
3096
|
},
|
|
3033
3097
|
[fetchWithAuth]
|
|
3034
3098
|
);
|
|
3035
|
-
const deleteSkill = (0,
|
|
3099
|
+
const deleteSkill = (0, import_react14.useCallback)(
|
|
3036
3100
|
async (skillId) => {
|
|
3037
3101
|
setError(null);
|
|
3038
3102
|
try {
|
|
@@ -3050,7 +3114,7 @@ function useSkills(options = {}) {
|
|
|
3050
3114
|
},
|
|
3051
3115
|
[fetchWithAuth]
|
|
3052
3116
|
);
|
|
3053
|
-
const bulkDeleteSkills = (0,
|
|
3117
|
+
const bulkDeleteSkills = (0, import_react14.useCallback)(
|
|
3054
3118
|
async (ids) => {
|
|
3055
3119
|
setError(null);
|
|
3056
3120
|
try {
|
|
@@ -3075,7 +3139,7 @@ function useSkills(options = {}) {
|
|
|
3075
3139
|
},
|
|
3076
3140
|
[fetchWithAuth]
|
|
3077
3141
|
);
|
|
3078
|
-
const getSkillUsage = (0,
|
|
3142
|
+
const getSkillUsage = (0, import_react14.useCallback)(
|
|
3079
3143
|
async (skillId) => {
|
|
3080
3144
|
const res = await fetchWithAuth(`/skills/${skillId}/usage`);
|
|
3081
3145
|
if (!res.ok) throw new Error(`Failed to fetch skill usage: ${res.statusText}`);
|
|
@@ -3083,7 +3147,7 @@ function useSkills(options = {}) {
|
|
|
3083
3147
|
},
|
|
3084
3148
|
[fetchWithAuth]
|
|
3085
3149
|
);
|
|
3086
|
-
(0,
|
|
3150
|
+
(0, import_react14.useEffect)(() => {
|
|
3087
3151
|
if (autoFetch) void fetchSkills();
|
|
3088
3152
|
}, [autoFetch, fetchSkills]);
|
|
3089
3153
|
return {
|
|
@@ -3102,20 +3166,20 @@ function useSkills(options = {}) {
|
|
|
3102
3166
|
}
|
|
3103
3167
|
|
|
3104
3168
|
// src/hooks/useRcpSources.ts
|
|
3105
|
-
var
|
|
3169
|
+
var import_react15 = require("react");
|
|
3106
3170
|
function useRcpSources(options = {}) {
|
|
3107
3171
|
const { autoFetch = true, page, limit, search } = options;
|
|
3108
3172
|
const { fetchWithAuth } = usePersonaContext();
|
|
3109
|
-
const [rcpSources, setRcpSources] = (0,
|
|
3110
|
-
const [pagination, setPagination] = (0,
|
|
3173
|
+
const [rcpSources, setRcpSources] = (0, import_react15.useState)([]);
|
|
3174
|
+
const [pagination, setPagination] = (0, import_react15.useState)({
|
|
3111
3175
|
total: 0,
|
|
3112
3176
|
page: page ?? 1,
|
|
3113
3177
|
limit: limit ?? 20,
|
|
3114
3178
|
pages: 0
|
|
3115
3179
|
});
|
|
3116
|
-
const [isLoading, setIsLoading] = (0,
|
|
3117
|
-
const [error, setError] = (0,
|
|
3118
|
-
const fetchRcpSources = (0,
|
|
3180
|
+
const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
|
|
3181
|
+
const [error, setError] = (0, import_react15.useState)(null);
|
|
3182
|
+
const fetchRcpSources = (0, import_react15.useCallback)(async () => {
|
|
3119
3183
|
setIsLoading(true);
|
|
3120
3184
|
setError(null);
|
|
3121
3185
|
try {
|
|
@@ -3141,7 +3205,7 @@ function useRcpSources(options = {}) {
|
|
|
3141
3205
|
setIsLoading(false);
|
|
3142
3206
|
}
|
|
3143
3207
|
}, [fetchWithAuth, page, limit, search]);
|
|
3144
|
-
const getRcpSource = (0,
|
|
3208
|
+
const getRcpSource = (0, import_react15.useCallback)(
|
|
3145
3209
|
async (sourceId) => {
|
|
3146
3210
|
const res = await fetchWithAuth(`/rcp-sources/${sourceId}`);
|
|
3147
3211
|
if (!res.ok) throw new Error(`Failed to fetch RCP source: ${res.statusText}`);
|
|
@@ -3149,7 +3213,7 @@ function useRcpSources(options = {}) {
|
|
|
3149
3213
|
},
|
|
3150
3214
|
[fetchWithAuth]
|
|
3151
3215
|
);
|
|
3152
|
-
const createRcpSource = (0,
|
|
3216
|
+
const createRcpSource = (0, import_react15.useCallback)(
|
|
3153
3217
|
async (input) => {
|
|
3154
3218
|
setError(null);
|
|
3155
3219
|
try {
|
|
@@ -3173,7 +3237,7 @@ function useRcpSources(options = {}) {
|
|
|
3173
3237
|
},
|
|
3174
3238
|
[fetchWithAuth]
|
|
3175
3239
|
);
|
|
3176
|
-
const updateRcpSource = (0,
|
|
3240
|
+
const updateRcpSource = (0, import_react15.useCallback)(
|
|
3177
3241
|
async (sourceId, input) => {
|
|
3178
3242
|
setError(null);
|
|
3179
3243
|
try {
|
|
@@ -3197,7 +3261,7 @@ function useRcpSources(options = {}) {
|
|
|
3197
3261
|
},
|
|
3198
3262
|
[fetchWithAuth]
|
|
3199
3263
|
);
|
|
3200
|
-
const deleteRcpSource = (0,
|
|
3264
|
+
const deleteRcpSource = (0, import_react15.useCallback)(
|
|
3201
3265
|
async (sourceId) => {
|
|
3202
3266
|
setError(null);
|
|
3203
3267
|
try {
|
|
@@ -3215,7 +3279,7 @@ function useRcpSources(options = {}) {
|
|
|
3215
3279
|
},
|
|
3216
3280
|
[fetchWithAuth]
|
|
3217
3281
|
);
|
|
3218
|
-
const bulkDeleteRcpSources = (0,
|
|
3282
|
+
const bulkDeleteRcpSources = (0, import_react15.useCallback)(
|
|
3219
3283
|
async (ids) => {
|
|
3220
3284
|
setError(null);
|
|
3221
3285
|
try {
|
|
@@ -3240,7 +3304,7 @@ function useRcpSources(options = {}) {
|
|
|
3240
3304
|
},
|
|
3241
3305
|
[fetchWithAuth]
|
|
3242
3306
|
);
|
|
3243
|
-
const getRcpSourceUsage = (0,
|
|
3307
|
+
const getRcpSourceUsage = (0, import_react15.useCallback)(
|
|
3244
3308
|
async (sourceId) => {
|
|
3245
3309
|
const res = await fetchWithAuth(`/rcp-sources/${sourceId}/usage`);
|
|
3246
3310
|
if (!res.ok) throw new Error(`Failed to fetch RCP source usage: ${res.statusText}`);
|
|
@@ -3248,7 +3312,7 @@ function useRcpSources(options = {}) {
|
|
|
3248
3312
|
},
|
|
3249
3313
|
[fetchWithAuth]
|
|
3250
3314
|
);
|
|
3251
|
-
const testRcpSourceConnection = (0,
|
|
3315
|
+
const testRcpSourceConnection = (0, import_react15.useCallback)(
|
|
3252
3316
|
async (sourceId) => {
|
|
3253
3317
|
setError(null);
|
|
3254
3318
|
try {
|
|
@@ -3272,7 +3336,7 @@ function useRcpSources(options = {}) {
|
|
|
3272
3336
|
},
|
|
3273
3337
|
[fetchWithAuth]
|
|
3274
3338
|
);
|
|
3275
|
-
(0,
|
|
3339
|
+
(0, import_react15.useEffect)(() => {
|
|
3276
3340
|
if (autoFetch) void fetchRcpSources();
|
|
3277
3341
|
}, [autoFetch, fetchRcpSources]);
|
|
3278
3342
|
return {
|
|
@@ -3292,21 +3356,21 @@ function useRcpSources(options = {}) {
|
|
|
3292
3356
|
}
|
|
3293
3357
|
|
|
3294
3358
|
// src/hooks/useKnowledgeBases.ts
|
|
3295
|
-
var
|
|
3359
|
+
var import_react16 = require("react");
|
|
3296
3360
|
function useKnowledgeBases(options = {}) {
|
|
3297
3361
|
const { autoFetch = true, page, limit, search, scope } = options;
|
|
3298
3362
|
const { fetchWithAuth } = usePersonaContext();
|
|
3299
|
-
const [knowledgeBases, setKnowledgeBases] = (0,
|
|
3300
|
-
const [pagination, setPagination] = (0,
|
|
3363
|
+
const [knowledgeBases, setKnowledgeBases] = (0, import_react16.useState)([]);
|
|
3364
|
+
const [pagination, setPagination] = (0, import_react16.useState)({
|
|
3301
3365
|
total: 0,
|
|
3302
3366
|
page: page ?? 1,
|
|
3303
3367
|
limit: limit ?? 20,
|
|
3304
3368
|
pages: 0
|
|
3305
3369
|
});
|
|
3306
|
-
const [isLoading, setIsLoading] = (0,
|
|
3307
|
-
const [isUploading, setIsUploading] = (0,
|
|
3308
|
-
const [error, setError] = (0,
|
|
3309
|
-
const fetchKnowledgeBases = (0,
|
|
3370
|
+
const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
|
|
3371
|
+
const [isUploading, setIsUploading] = (0, import_react16.useState)(false);
|
|
3372
|
+
const [error, setError] = (0, import_react16.useState)(null);
|
|
3373
|
+
const fetchKnowledgeBases = (0, import_react16.useCallback)(async () => {
|
|
3310
3374
|
setIsLoading(true);
|
|
3311
3375
|
setError(null);
|
|
3312
3376
|
try {
|
|
@@ -3333,7 +3397,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3333
3397
|
setIsLoading(false);
|
|
3334
3398
|
}
|
|
3335
3399
|
}, [fetchWithAuth, page, limit, search, scope]);
|
|
3336
|
-
const getKnowledgeBase = (0,
|
|
3400
|
+
const getKnowledgeBase = (0, import_react16.useCallback)(
|
|
3337
3401
|
async (kbId) => {
|
|
3338
3402
|
const res = await fetchWithAuth(`/knowledge/${kbId}`);
|
|
3339
3403
|
if (!res.ok) throw new Error(`Failed to fetch knowledge base: ${res.statusText}`);
|
|
@@ -3341,7 +3405,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3341
3405
|
},
|
|
3342
3406
|
[fetchWithAuth]
|
|
3343
3407
|
);
|
|
3344
|
-
const createKnowledgeBase = (0,
|
|
3408
|
+
const createKnowledgeBase = (0, import_react16.useCallback)(
|
|
3345
3409
|
async (input) => {
|
|
3346
3410
|
setError(null);
|
|
3347
3411
|
try {
|
|
@@ -3365,7 +3429,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3365
3429
|
},
|
|
3366
3430
|
[fetchWithAuth]
|
|
3367
3431
|
);
|
|
3368
|
-
const updateKnowledgeBase = (0,
|
|
3432
|
+
const updateKnowledgeBase = (0, import_react16.useCallback)(
|
|
3369
3433
|
async (kbId, input) => {
|
|
3370
3434
|
setError(null);
|
|
3371
3435
|
try {
|
|
@@ -3389,7 +3453,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3389
3453
|
},
|
|
3390
3454
|
[fetchWithAuth]
|
|
3391
3455
|
);
|
|
3392
|
-
const deleteKnowledgeBase = (0,
|
|
3456
|
+
const deleteKnowledgeBase = (0, import_react16.useCallback)(
|
|
3393
3457
|
async (kbId) => {
|
|
3394
3458
|
setError(null);
|
|
3395
3459
|
try {
|
|
@@ -3407,7 +3471,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3407
3471
|
},
|
|
3408
3472
|
[fetchWithAuth]
|
|
3409
3473
|
);
|
|
3410
|
-
const bulkDeleteKnowledgeBases = (0,
|
|
3474
|
+
const bulkDeleteKnowledgeBases = (0, import_react16.useCallback)(
|
|
3411
3475
|
async (ids) => {
|
|
3412
3476
|
setError(null);
|
|
3413
3477
|
try {
|
|
@@ -3432,7 +3496,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3432
3496
|
},
|
|
3433
3497
|
[fetchWithAuth]
|
|
3434
3498
|
);
|
|
3435
|
-
const getKnowledgeBaseUsage = (0,
|
|
3499
|
+
const getKnowledgeBaseUsage = (0, import_react16.useCallback)(
|
|
3436
3500
|
async (kbId) => {
|
|
3437
3501
|
const res = await fetchWithAuth(`/knowledge/${kbId}/usage`);
|
|
3438
3502
|
if (!res.ok) throw new Error(`Failed to fetch knowledge base usage: ${res.statusText}`);
|
|
@@ -3440,7 +3504,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3440
3504
|
},
|
|
3441
3505
|
[fetchWithAuth]
|
|
3442
3506
|
);
|
|
3443
|
-
const uploadDocuments = (0,
|
|
3507
|
+
const uploadDocuments = (0, import_react16.useCallback)(
|
|
3444
3508
|
async (kbId, files) => {
|
|
3445
3509
|
setIsUploading(true);
|
|
3446
3510
|
setError(null);
|
|
@@ -3482,7 +3546,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3482
3546
|
},
|
|
3483
3547
|
[fetchWithAuth]
|
|
3484
3548
|
);
|
|
3485
|
-
const listDocuments = (0,
|
|
3549
|
+
const listDocuments = (0, import_react16.useCallback)(
|
|
3486
3550
|
async (kbId) => {
|
|
3487
3551
|
const res = await fetchWithAuth(`/knowledge/${kbId}/documents`);
|
|
3488
3552
|
if (!res.ok) throw new Error(`Failed to list documents: ${res.statusText}`);
|
|
@@ -3490,7 +3554,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3490
3554
|
},
|
|
3491
3555
|
[fetchWithAuth]
|
|
3492
3556
|
);
|
|
3493
|
-
const deleteDocument = (0,
|
|
3557
|
+
const deleteDocument = (0, import_react16.useCallback)(
|
|
3494
3558
|
async (kbId, sourceName) => {
|
|
3495
3559
|
setError(null);
|
|
3496
3560
|
try {
|
|
@@ -3517,7 +3581,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3517
3581
|
},
|
|
3518
3582
|
[fetchWithAuth]
|
|
3519
3583
|
);
|
|
3520
|
-
const searchKnowledgeBase = (0,
|
|
3584
|
+
const searchKnowledgeBase = (0, import_react16.useCallback)(
|
|
3521
3585
|
async (kbId, query, opts) => {
|
|
3522
3586
|
const res = await fetchWithAuth(`/knowledge/${kbId}/search`, {
|
|
3523
3587
|
method: "POST",
|
|
@@ -3532,7 +3596,7 @@ function useKnowledgeBases(options = {}) {
|
|
|
3532
3596
|
},
|
|
3533
3597
|
[fetchWithAuth]
|
|
3534
3598
|
);
|
|
3535
|
-
(0,
|
|
3599
|
+
(0, import_react16.useEffect)(() => {
|
|
3536
3600
|
if (autoFetch) void fetchKnowledgeBases();
|
|
3537
3601
|
}, [autoFetch, fetchKnowledgeBases]);
|
|
3538
3602
|
return {
|
|
@@ -3556,20 +3620,20 @@ function useKnowledgeBases(options = {}) {
|
|
|
3556
3620
|
}
|
|
3557
3621
|
|
|
3558
3622
|
// src/hooks/useMcpAdmin.ts
|
|
3559
|
-
var
|
|
3623
|
+
var import_react17 = require("react");
|
|
3560
3624
|
function useMcpAdmin(options = {}) {
|
|
3561
3625
|
const { autoFetch = true, page, limit, search } = options;
|
|
3562
3626
|
const { fetchWithAuth } = usePersonaContext();
|
|
3563
|
-
const [mcps, setMcps] = (0,
|
|
3564
|
-
const [pagination, setPagination] = (0,
|
|
3627
|
+
const [mcps, setMcps] = (0, import_react17.useState)([]);
|
|
3628
|
+
const [pagination, setPagination] = (0, import_react17.useState)({
|
|
3565
3629
|
total: 0,
|
|
3566
3630
|
page: page ?? 1,
|
|
3567
3631
|
limit: limit ?? 20,
|
|
3568
3632
|
pages: 0
|
|
3569
3633
|
});
|
|
3570
|
-
const [isLoading, setIsLoading] = (0,
|
|
3571
|
-
const [error, setError] = (0,
|
|
3572
|
-
const fetchMcps = (0,
|
|
3634
|
+
const [isLoading, setIsLoading] = (0, import_react17.useState)(false);
|
|
3635
|
+
const [error, setError] = (0, import_react17.useState)(null);
|
|
3636
|
+
const fetchMcps = (0, import_react17.useCallback)(async () => {
|
|
3573
3637
|
setIsLoading(true);
|
|
3574
3638
|
setError(null);
|
|
3575
3639
|
try {
|
|
@@ -3595,7 +3659,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3595
3659
|
setIsLoading(false);
|
|
3596
3660
|
}
|
|
3597
3661
|
}, [fetchWithAuth, page, limit, search]);
|
|
3598
|
-
const getMcp = (0,
|
|
3662
|
+
const getMcp = (0, import_react17.useCallback)(
|
|
3599
3663
|
async (mcpId) => {
|
|
3600
3664
|
const res = await fetchWithAuth(`/mcps/${mcpId}`);
|
|
3601
3665
|
if (!res.ok) throw new Error(`Failed to fetch MCP: ${res.statusText}`);
|
|
@@ -3603,7 +3667,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3603
3667
|
},
|
|
3604
3668
|
[fetchWithAuth]
|
|
3605
3669
|
);
|
|
3606
|
-
const createMcp = (0,
|
|
3670
|
+
const createMcp = (0, import_react17.useCallback)(
|
|
3607
3671
|
async (input) => {
|
|
3608
3672
|
setError(null);
|
|
3609
3673
|
try {
|
|
@@ -3627,7 +3691,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3627
3691
|
},
|
|
3628
3692
|
[fetchWithAuth]
|
|
3629
3693
|
);
|
|
3630
|
-
const updateMcp = (0,
|
|
3694
|
+
const updateMcp = (0, import_react17.useCallback)(
|
|
3631
3695
|
async (mcpId, input) => {
|
|
3632
3696
|
setError(null);
|
|
3633
3697
|
try {
|
|
@@ -3651,7 +3715,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3651
3715
|
},
|
|
3652
3716
|
[fetchWithAuth]
|
|
3653
3717
|
);
|
|
3654
|
-
const deleteMcp = (0,
|
|
3718
|
+
const deleteMcp = (0, import_react17.useCallback)(
|
|
3655
3719
|
async (mcpId) => {
|
|
3656
3720
|
setError(null);
|
|
3657
3721
|
try {
|
|
@@ -3669,7 +3733,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3669
3733
|
},
|
|
3670
3734
|
[fetchWithAuth]
|
|
3671
3735
|
);
|
|
3672
|
-
const bulkDeleteMcps = (0,
|
|
3736
|
+
const bulkDeleteMcps = (0, import_react17.useCallback)(
|
|
3673
3737
|
async (ids) => {
|
|
3674
3738
|
setError(null);
|
|
3675
3739
|
try {
|
|
@@ -3694,7 +3758,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3694
3758
|
},
|
|
3695
3759
|
[fetchWithAuth]
|
|
3696
3760
|
);
|
|
3697
|
-
const testConnection = (0,
|
|
3761
|
+
const testConnection = (0, import_react17.useCallback)(
|
|
3698
3762
|
async (mcpId) => {
|
|
3699
3763
|
setError(null);
|
|
3700
3764
|
try {
|
|
@@ -3718,7 +3782,7 @@ function useMcpAdmin(options = {}) {
|
|
|
3718
3782
|
},
|
|
3719
3783
|
[fetchWithAuth]
|
|
3720
3784
|
);
|
|
3721
|
-
(0,
|
|
3785
|
+
(0, import_react17.useEffect)(() => {
|
|
3722
3786
|
if (autoFetch) void fetchMcps();
|
|
3723
3787
|
}, [autoFetch, fetchMcps]);
|
|
3724
3788
|
return {
|
|
@@ -3737,21 +3801,21 @@ function useMcpAdmin(options = {}) {
|
|
|
3737
3801
|
}
|
|
3738
3802
|
|
|
3739
3803
|
// src/hooks/useWorkflows.ts
|
|
3740
|
-
var
|
|
3804
|
+
var import_react18 = require("react");
|
|
3741
3805
|
function useWorkflows(options) {
|
|
3742
3806
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
3743
3807
|
const { autoFetch = true, search, scope, visibility, isEnabled, page, limit } = opts;
|
|
3744
3808
|
const { fetchWithAuth } = usePersonaContext();
|
|
3745
|
-
const [workflows, setWorkflows] = (0,
|
|
3746
|
-
const [pagination, setPagination] = (0,
|
|
3809
|
+
const [workflows, setWorkflows] = (0, import_react18.useState)([]);
|
|
3810
|
+
const [pagination, setPagination] = (0, import_react18.useState)({
|
|
3747
3811
|
page: page ?? 1,
|
|
3748
3812
|
limit: limit ?? 20,
|
|
3749
3813
|
total: 0,
|
|
3750
3814
|
totalPages: 0
|
|
3751
3815
|
});
|
|
3752
|
-
const [isLoading, setIsLoading] = (0,
|
|
3753
|
-
const [error, setError] = (0,
|
|
3754
|
-
const fetchWorkflows = (0,
|
|
3816
|
+
const [isLoading, setIsLoading] = (0, import_react18.useState)(false);
|
|
3817
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
3818
|
+
const fetchWorkflows = (0, import_react18.useCallback)(async () => {
|
|
3755
3819
|
setIsLoading(true);
|
|
3756
3820
|
setError(null);
|
|
3757
3821
|
try {
|
|
@@ -3797,7 +3861,7 @@ function useWorkflows(options) {
|
|
|
3797
3861
|
setIsLoading(false);
|
|
3798
3862
|
}
|
|
3799
3863
|
}, [fetchWithAuth, search, scope, visibility, isEnabled, page, limit]);
|
|
3800
|
-
const createWorkflow = (0,
|
|
3864
|
+
const createWorkflow = (0, import_react18.useCallback)(
|
|
3801
3865
|
async (input) => {
|
|
3802
3866
|
setError(null);
|
|
3803
3867
|
try {
|
|
@@ -3821,7 +3885,7 @@ function useWorkflows(options) {
|
|
|
3821
3885
|
},
|
|
3822
3886
|
[fetchWithAuth]
|
|
3823
3887
|
);
|
|
3824
|
-
(0,
|
|
3888
|
+
(0, import_react18.useEffect)(() => {
|
|
3825
3889
|
if (autoFetch) {
|
|
3826
3890
|
void fetchWorkflows();
|
|
3827
3891
|
}
|
|
@@ -3837,17 +3901,17 @@ function useWorkflows(options) {
|
|
|
3837
3901
|
}
|
|
3838
3902
|
|
|
3839
3903
|
// src/hooks/useWorkflow.ts
|
|
3840
|
-
var
|
|
3904
|
+
var import_react19 = require("react");
|
|
3841
3905
|
function useWorkflow(workflowId, options) {
|
|
3842
3906
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
3843
3907
|
const { autoFetch = true } = opts;
|
|
3844
3908
|
const { fetchWithAuth } = usePersonaContext();
|
|
3845
|
-
const [workflow, setWorkflow] = (0,
|
|
3846
|
-
const [versions, setVersions] = (0,
|
|
3847
|
-
const [mermaid, setMermaid] = (0,
|
|
3848
|
-
const [isLoading, setIsLoading] = (0,
|
|
3849
|
-
const [error, setError] = (0,
|
|
3850
|
-
const fetchWorkflow = (0,
|
|
3909
|
+
const [workflow, setWorkflow] = (0, import_react19.useState)(null);
|
|
3910
|
+
const [versions, setVersions] = (0, import_react19.useState)([]);
|
|
3911
|
+
const [mermaid, setMermaid] = (0, import_react19.useState)(null);
|
|
3912
|
+
const [isLoading, setIsLoading] = (0, import_react19.useState)(false);
|
|
3913
|
+
const [error, setError] = (0, import_react19.useState)(null);
|
|
3914
|
+
const fetchWorkflow = (0, import_react19.useCallback)(async () => {
|
|
3851
3915
|
if (!workflowId) return null;
|
|
3852
3916
|
setIsLoading(true);
|
|
3853
3917
|
setError(null);
|
|
@@ -3867,7 +3931,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3867
3931
|
setIsLoading(false);
|
|
3868
3932
|
}
|
|
3869
3933
|
}, [fetchWithAuth, workflowId]);
|
|
3870
|
-
const fetchVersions = (0,
|
|
3934
|
+
const fetchVersions = (0, import_react19.useCallback)(async () => {
|
|
3871
3935
|
if (!workflowId) return [];
|
|
3872
3936
|
try {
|
|
3873
3937
|
const res = await fetchWithAuth(`/workflows/${workflowId}/versions`);
|
|
@@ -3880,7 +3944,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3880
3944
|
return [];
|
|
3881
3945
|
}
|
|
3882
3946
|
}, [fetchWithAuth, workflowId]);
|
|
3883
|
-
const getVersion = (0,
|
|
3947
|
+
const getVersion = (0, import_react19.useCallback)(
|
|
3884
3948
|
async (version) => {
|
|
3885
3949
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3886
3950
|
const res = await fetchWithAuth(`/workflows/${workflowId}/versions/${version}`);
|
|
@@ -3891,7 +3955,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3891
3955
|
},
|
|
3892
3956
|
[fetchWithAuth, workflowId]
|
|
3893
3957
|
);
|
|
3894
|
-
const fetchMermaid = (0,
|
|
3958
|
+
const fetchMermaid = (0, import_react19.useCallback)(async () => {
|
|
3895
3959
|
if (!workflowId) return "";
|
|
3896
3960
|
try {
|
|
3897
3961
|
const res = await fetchWithAuth(`/workflows/${workflowId}/mermaid`);
|
|
@@ -3904,7 +3968,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3904
3968
|
return "";
|
|
3905
3969
|
}
|
|
3906
3970
|
}, [fetchWithAuth, workflowId]);
|
|
3907
|
-
const updateWorkflow = (0,
|
|
3971
|
+
const updateWorkflow = (0, import_react19.useCallback)(
|
|
3908
3972
|
async (input) => {
|
|
3909
3973
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3910
3974
|
setError(null);
|
|
@@ -3923,7 +3987,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3923
3987
|
},
|
|
3924
3988
|
[fetchWithAuth, workflowId]
|
|
3925
3989
|
);
|
|
3926
|
-
const saveDraft = (0,
|
|
3990
|
+
const saveDraft = (0, import_react19.useCallback)(
|
|
3927
3991
|
async (draft) => {
|
|
3928
3992
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3929
3993
|
setError(null);
|
|
@@ -3942,7 +4006,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3942
4006
|
},
|
|
3943
4007
|
[fetchWithAuth, workflowId]
|
|
3944
4008
|
);
|
|
3945
|
-
const publish = (0,
|
|
4009
|
+
const publish = (0, import_react19.useCallback)(async () => {
|
|
3946
4010
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3947
4011
|
setError(null);
|
|
3948
4012
|
const res = await fetchWithAuth(`/workflows/${workflowId}/publish`, {
|
|
@@ -3957,7 +4021,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3957
4021
|
void fetchVersions();
|
|
3958
4022
|
return versionResult;
|
|
3959
4023
|
}, [fetchWithAuth, workflowId, fetchWorkflow, fetchVersions]);
|
|
3960
|
-
const deleteWorkflow = (0,
|
|
4024
|
+
const deleteWorkflow = (0, import_react19.useCallback)(async () => {
|
|
3961
4025
|
if (!workflowId) throw new Error("Workflow ID is required");
|
|
3962
4026
|
setError(null);
|
|
3963
4027
|
const res = await fetchWithAuth(`/workflows/${workflowId}`, {
|
|
@@ -3968,7 +4032,7 @@ function useWorkflow(workflowId, options) {
|
|
|
3968
4032
|
}
|
|
3969
4033
|
setWorkflow(null);
|
|
3970
4034
|
}, [fetchWithAuth, workflowId]);
|
|
3971
|
-
(0,
|
|
4035
|
+
(0, import_react19.useEffect)(() => {
|
|
3972
4036
|
if (autoFetch && workflowId) {
|
|
3973
4037
|
void fetchWorkflow();
|
|
3974
4038
|
}
|
|
@@ -3991,25 +4055,25 @@ function useWorkflow(workflowId, options) {
|
|
|
3991
4055
|
}
|
|
3992
4056
|
|
|
3993
4057
|
// src/hooks/useWorkflowStream.ts
|
|
3994
|
-
var
|
|
4058
|
+
var import_react20 = require("react");
|
|
3995
4059
|
function useWorkflowStream(workflowId, options) {
|
|
3996
4060
|
const { baseUrl, getAuthToken, fetchWithAuth, logger } = usePersonaContext();
|
|
3997
|
-
const [status, setStatus] = (0,
|
|
3998
|
-
const [runId, setRunId] = (0,
|
|
3999
|
-
const [activeNodeId, setActiveNodeId] = (0,
|
|
4000
|
-
const [nodeRuns, setNodeRuns] = (0,
|
|
4061
|
+
const [status, setStatus] = (0, import_react20.useState)("idle");
|
|
4062
|
+
const [runId, setRunId] = (0, import_react20.useState)(null);
|
|
4063
|
+
const [activeNodeId, setActiveNodeId] = (0, import_react20.useState)(null);
|
|
4064
|
+
const [nodeRuns, setNodeRuns] = (0, import_react20.useState)(
|
|
4001
4065
|
{}
|
|
4002
4066
|
);
|
|
4003
|
-
const [text, setText] = (0,
|
|
4004
|
-
const [output, setOutput] = (0,
|
|
4005
|
-
const [error, setError] = (0,
|
|
4006
|
-
const [events, setEvents] = (0,
|
|
4007
|
-
const abortControllerRef = (0,
|
|
4008
|
-
const currentRunIdRef = (0,
|
|
4067
|
+
const [text, setText] = (0, import_react20.useState)("");
|
|
4068
|
+
const [output, setOutput] = (0, import_react20.useState)(null);
|
|
4069
|
+
const [error, setError] = (0, import_react20.useState)(null);
|
|
4070
|
+
const [events, setEvents] = (0, import_react20.useState)([]);
|
|
4071
|
+
const abortControllerRef = (0, import_react20.useRef)(null);
|
|
4072
|
+
const currentRunIdRef = (0, import_react20.useRef)(null);
|
|
4009
4073
|
currentRunIdRef.current = runId;
|
|
4010
|
-
const optionsRef = (0,
|
|
4074
|
+
const optionsRef = (0, import_react20.useRef)(options);
|
|
4011
4075
|
optionsRef.current = options;
|
|
4012
|
-
const cancel = (0,
|
|
4076
|
+
const cancel = (0, import_react20.useCallback)(async () => {
|
|
4013
4077
|
if (abortControllerRef.current) {
|
|
4014
4078
|
abortControllerRef.current.abort();
|
|
4015
4079
|
abortControllerRef.current = null;
|
|
@@ -4030,7 +4094,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4030
4094
|
setStatus("cancelled");
|
|
4031
4095
|
setActiveNodeId(null);
|
|
4032
4096
|
}, [fetchWithAuth, logger]);
|
|
4033
|
-
const reset = (0,
|
|
4097
|
+
const reset = (0, import_react20.useCallback)(() => {
|
|
4034
4098
|
if (abortControllerRef.current) {
|
|
4035
4099
|
abortControllerRef.current.abort();
|
|
4036
4100
|
abortControllerRef.current = null;
|
|
@@ -4044,7 +4108,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4044
4108
|
setError(null);
|
|
4045
4109
|
setEvents([]);
|
|
4046
4110
|
}, []);
|
|
4047
|
-
const processStream = (0,
|
|
4111
|
+
const processStream = (0, import_react20.useCallback)(
|
|
4048
4112
|
async (url, method, body, targetRunId) => {
|
|
4049
4113
|
if (abortControllerRef.current) {
|
|
4050
4114
|
abortControllerRef.current.abort();
|
|
@@ -4209,7 +4273,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4209
4273
|
},
|
|
4210
4274
|
[getAuthToken]
|
|
4211
4275
|
);
|
|
4212
|
-
const start = (0,
|
|
4276
|
+
const start = (0, import_react20.useCallback)(
|
|
4213
4277
|
async (input, opts) => {
|
|
4214
4278
|
const targetWfId = opts?.workflowId || workflowId;
|
|
4215
4279
|
if (!targetWfId) {
|
|
@@ -4230,7 +4294,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4230
4294
|
},
|
|
4231
4295
|
[workflowId, baseUrl, processStream]
|
|
4232
4296
|
);
|
|
4233
|
-
const resume = (0,
|
|
4297
|
+
const resume = (0, import_react20.useCallback)(
|
|
4234
4298
|
async (targetRunId, sinceSeq) => {
|
|
4235
4299
|
if (!targetRunId) {
|
|
4236
4300
|
throw new Error("Run ID is required to resume stream");
|
|
@@ -4243,7 +4307,7 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4243
4307
|
},
|
|
4244
4308
|
[baseUrl, processStream]
|
|
4245
4309
|
);
|
|
4246
|
-
(0,
|
|
4310
|
+
(0, import_react20.useEffect)(() => {
|
|
4247
4311
|
return () => {
|
|
4248
4312
|
if (abortControllerRef.current) {
|
|
4249
4313
|
abortControllerRef.current.abort();
|
|
@@ -4268,21 +4332,21 @@ function useWorkflowStream(workflowId, options) {
|
|
|
4268
4332
|
}
|
|
4269
4333
|
|
|
4270
4334
|
// src/hooks/useWorkflowRuns.ts
|
|
4271
|
-
var
|
|
4335
|
+
var import_react21 = require("react");
|
|
4272
4336
|
function useWorkflowRuns(workflowId, options) {
|
|
4273
4337
|
const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
|
|
4274
4338
|
const { autoFetch = true, page = 1, limit = 20 } = opts;
|
|
4275
4339
|
const { fetchWithAuth } = usePersonaContext();
|
|
4276
|
-
const [runs, setRuns] = (0,
|
|
4277
|
-
const [pagination, setPagination] = (0,
|
|
4340
|
+
const [runs, setRuns] = (0, import_react21.useState)([]);
|
|
4341
|
+
const [pagination, setPagination] = (0, import_react21.useState)({
|
|
4278
4342
|
page,
|
|
4279
4343
|
limit,
|
|
4280
4344
|
total: 0,
|
|
4281
4345
|
totalPages: 0
|
|
4282
4346
|
});
|
|
4283
|
-
const [isLoading, setIsLoading] = (0,
|
|
4284
|
-
const [error, setError] = (0,
|
|
4285
|
-
const fetchRuns = (0,
|
|
4347
|
+
const [isLoading, setIsLoading] = (0, import_react21.useState)(false);
|
|
4348
|
+
const [error, setError] = (0, import_react21.useState)(null);
|
|
4349
|
+
const fetchRuns = (0, import_react21.useCallback)(async () => {
|
|
4286
4350
|
if (!workflowId) return [];
|
|
4287
4351
|
setIsLoading(true);
|
|
4288
4352
|
setError(null);
|
|
@@ -4314,7 +4378,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4314
4378
|
setIsLoading(false);
|
|
4315
4379
|
}
|
|
4316
4380
|
}, [fetchWithAuth, workflowId, page, limit]);
|
|
4317
|
-
const getRun = (0,
|
|
4381
|
+
const getRun = (0, import_react21.useCallback)(
|
|
4318
4382
|
async (runId) => {
|
|
4319
4383
|
if (!runId) throw new Error("Run ID is required");
|
|
4320
4384
|
const res = await fetchWithAuth(`/workflows/runs/${runId}`);
|
|
@@ -4325,7 +4389,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4325
4389
|
},
|
|
4326
4390
|
[fetchWithAuth]
|
|
4327
4391
|
);
|
|
4328
|
-
const cancelRun = (0,
|
|
4392
|
+
const cancelRun = (0, import_react21.useCallback)(
|
|
4329
4393
|
async (runId) => {
|
|
4330
4394
|
if (!runId) throw new Error("Run ID is required");
|
|
4331
4395
|
const res = await fetchWithAuth(`/workflows/runs/${runId}/cancel`, {
|
|
@@ -4340,7 +4404,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4340
4404
|
},
|
|
4341
4405
|
[fetchWithAuth]
|
|
4342
4406
|
);
|
|
4343
|
-
(0,
|
|
4407
|
+
(0, import_react21.useEffect)(() => {
|
|
4344
4408
|
if (autoFetch && workflowId) {
|
|
4345
4409
|
void fetchRuns();
|
|
4346
4410
|
}
|
|
@@ -4358,7 +4422,7 @@ function useWorkflowRuns(workflowId, options) {
|
|
|
4358
4422
|
|
|
4359
4423
|
// src/index.ts
|
|
4360
4424
|
var import_logger2 = require("@personaai/logger");
|
|
4361
|
-
var VERSION = "0.
|
|
4425
|
+
var VERSION = "0.18.0";
|
|
4362
4426
|
// Annotate the CommonJS export names for ESM import in node:
|
|
4363
4427
|
0 && (module.exports = {
|
|
4364
4428
|
ARCHITECT_AGENT_ID,
|
|
@@ -4381,6 +4445,7 @@ var VERSION = "0.10.0";
|
|
|
4381
4445
|
useMcpAdmin,
|
|
4382
4446
|
useMcpConnections,
|
|
4383
4447
|
useMemory,
|
|
4448
|
+
useMessages,
|
|
4384
4449
|
usePersonaContext,
|
|
4385
4450
|
useRcpSources,
|
|
4386
4451
|
useSkills,
|