@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/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,
@@ -120,10 +121,33 @@ function PersonaProvider({
120
121
  ok: res.ok
121
122
  });
122
123
  if (!res.ok) {
124
+ const parsedResult = { isJson: false };
125
+ try {
126
+ const body = await res.clone().json();
127
+ if (body && typeof body === "object") {
128
+ const message = body.error?.message ?? body.message ?? void 0;
129
+ if (body.error?.code ?? message) {
130
+ parsedResult.isJson = true;
131
+ parsedResult.info = {
132
+ status: res.status,
133
+ code: body.error?.code,
134
+ message
135
+ };
136
+ }
137
+ }
138
+ } catch {
139
+ }
123
140
  logger.warn("fetchWithAuth non-ok", {
124
141
  path: cleanPath,
125
- status: res.status
142
+ status: res.status,
143
+ ...parsedResult.info ?? {}
126
144
  });
145
+ if (parsedResult.info) {
146
+ try {
147
+ res.personaError = parsedResult.info;
148
+ } catch {
149
+ }
150
+ }
127
151
  } else {
128
152
  logger.info("fetchWithAuth succeeded", {
129
153
  path: cleanPath,
@@ -419,6 +443,14 @@ function normalizePendingInterrupt(pending) {
419
443
  }
420
444
 
421
445
  // src/hooks/useChat.ts
446
+ function httpFailure(res, what) {
447
+ const info = res.personaError;
448
+ if (!info || !info.code && !info.message) {
449
+ return new Error(`Failed to ${what}: ${res.statusText || res.status}`);
450
+ }
451
+ const parts = [info.status, info.code, info.message].filter(Boolean).join(", ");
452
+ return new Error(`Failed to ${what}: ${parts}`);
453
+ }
422
454
  function parseSandboxCommand(tc) {
423
455
  let command = tc.args ?? "";
424
456
  try {
@@ -551,8 +583,7 @@ function useChat(options = {}) {
551
583
  setError(null);
552
584
  try {
553
585
  const res = await fetchWithAuth(`/threads/${id}/messages`);
554
- if (!res.ok)
555
- throw new Error(`Failed to load thread history: ${res.statusText}`);
586
+ if (!res.ok) throw httpFailure(res, "load thread history");
556
587
  const body = await res.json();
557
588
  const data = body?.data ?? body;
558
589
  const raw = data?.messages ?? [];
@@ -812,7 +843,7 @@ function useChat(options = {}) {
812
843
  headers: { "Content-Type": "application/json" },
813
844
  body: JSON.stringify({ agentId: targetAgentId })
814
845
  });
815
- if (!createRes.ok) throw new Error(`Failed to create thread: ${createRes.statusText}`);
846
+ if (!createRes.ok) throw httpFailure(createRes, "create thread");
816
847
  const createBody = await createRes.json();
817
848
  const created = createBody?.data ?? createBody;
818
849
  resolvedThreadId = created._id ?? created.id;
@@ -2518,15 +2549,78 @@ function useVoice(options = {}) {
2518
2549
  };
2519
2550
  }
2520
2551
 
2521
- // src/hooks/useFiles.ts
2552
+ // src/hooks/useMessages.ts
2522
2553
  var import_react8 = require("react");
2554
+ async function readErrorMessage(res, fallback) {
2555
+ try {
2556
+ const body = await res.json();
2557
+ const message = body?.error?.message ?? body?.message;
2558
+ if (typeof message === "string" && message) return message;
2559
+ } catch {
2560
+ }
2561
+ return `${fallback}: ${res.statusText}`;
2562
+ }
2563
+ function useMessages() {
2564
+ const { fetchWithAuth, logger } = usePersonaContext();
2565
+ const messagesLogger = (0, import_react8.useMemo)(() => logger.child("messages"), [logger]);
2566
+ const [isSending, setIsSending] = (0, import_react8.useState)(false);
2567
+ const [error, setError] = (0, import_react8.useState)(null);
2568
+ const [lastDelivery, setLastDelivery] = (0, import_react8.useState)(null);
2569
+ const inFlightRef = (0, import_react8.useRef)(0);
2570
+ const post = (0, import_react8.useCallback)(
2571
+ async (path, input) => {
2572
+ inFlightRef.current += 1;
2573
+ setIsSending(true);
2574
+ setError(null);
2575
+ try {
2576
+ const res = await fetchWithAuth(path, {
2577
+ method: "POST",
2578
+ headers: { "Content-Type": "application/json" },
2579
+ body: JSON.stringify(input)
2580
+ });
2581
+ if (!res.ok) {
2582
+ throw new Error(await readErrorMessage(res, "Failed to send message"));
2583
+ }
2584
+ const payload = await res.json();
2585
+ const delivery = payload?.data ?? payload;
2586
+ setLastDelivery(delivery);
2587
+ messagesLogger.info("message sent", { path });
2588
+ return delivery;
2589
+ } catch (err) {
2590
+ const errorObj = err instanceof Error ? err : new Error(String(err));
2591
+ messagesLogger.warn("message send failed", {
2592
+ path,
2593
+ error: errorObj.message
2594
+ });
2595
+ setError(errorObj);
2596
+ throw errorObj;
2597
+ } finally {
2598
+ inFlightRef.current -= 1;
2599
+ if (inFlightRef.current === 0) setIsSending(false);
2600
+ }
2601
+ },
2602
+ [fetchWithAuth, messagesLogger]
2603
+ );
2604
+ const send = (0, import_react8.useCallback)(
2605
+ (input) => post("/messages", input),
2606
+ [post]
2607
+ );
2608
+ const sendFromAgent = (0, import_react8.useCallback)(
2609
+ (input) => post("/messages/agent", input),
2610
+ [post]
2611
+ );
2612
+ return { isSending, error, lastDelivery, send, sendFromAgent };
2613
+ }
2614
+
2615
+ // src/hooks/useFiles.ts
2616
+ var import_react9 = require("react");
2523
2617
  function useFiles(autoFetch = true) {
2524
2618
  const { fetchWithAuth } = usePersonaContext();
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 () => {
2619
+ const [files, setFiles] = (0, import_react9.useState)([]);
2620
+ const [isLoading, setIsLoading] = (0, import_react9.useState)(false);
2621
+ const [isUploading, setIsUploading] = (0, import_react9.useState)(false);
2622
+ const [error, setError] = (0, import_react9.useState)(null);
2623
+ const fetchFiles = (0, import_react9.useCallback)(async () => {
2530
2624
  setIsLoading(true);
2531
2625
  setError(null);
2532
2626
  try {
@@ -2544,7 +2638,7 @@ function useFiles(autoFetch = true) {
2544
2638
  setIsLoading(false);
2545
2639
  }
2546
2640
  }, [fetchWithAuth]);
2547
- const uploadFile = (0, import_react8.useCallback)(
2641
+ const uploadFile = (0, import_react9.useCallback)(
2548
2642
  async (fileOrFormData) => {
2549
2643
  setIsUploading(true);
2550
2644
  setError(null);
@@ -2577,7 +2671,7 @@ function useFiles(autoFetch = true) {
2577
2671
  },
2578
2672
  [fetchWithAuth, fetchFiles]
2579
2673
  );
2580
- const deleteFile = (0, import_react8.useCallback)(
2674
+ const deleteFile = (0, import_react9.useCallback)(
2581
2675
  async (fileId) => {
2582
2676
  const res = await fetchWithAuth(`/files/${fileId}`, { method: "DELETE" });
2583
2677
  if (!res.ok) throw new Error(`Failed to delete file: ${res.statusText}`);
@@ -2585,7 +2679,7 @@ function useFiles(autoFetch = true) {
2585
2679
  },
2586
2680
  [fetchWithAuth]
2587
2681
  );
2588
- const bulkDeleteFiles = (0, import_react8.useCallback)(
2682
+ const bulkDeleteFiles = (0, import_react9.useCallback)(
2589
2683
  async (fileIds) => {
2590
2684
  const res = await fetchWithAuth("/files/bulk-delete", {
2591
2685
  method: "POST",
@@ -2600,10 +2694,10 @@ function useFiles(autoFetch = true) {
2600
2694
  },
2601
2695
  [fetchWithAuth]
2602
2696
  );
2603
- const getDownloadUrl = (0, import_react8.useCallback)((fileId) => {
2697
+ const getDownloadUrl = (0, import_react9.useCallback)((fileId) => {
2604
2698
  return `/files/${fileId}`;
2605
2699
  }, []);
2606
- (0, import_react8.useEffect)(() => {
2700
+ (0, import_react9.useEffect)(() => {
2607
2701
  if (autoFetch) {
2608
2702
  void fetchFiles();
2609
2703
  }
@@ -2622,21 +2716,21 @@ function useFiles(autoFetch = true) {
2622
2716
  }
2623
2717
 
2624
2718
  // src/hooks/useAgents.ts
2625
- var import_react9 = require("react");
2719
+ var import_react10 = require("react");
2626
2720
  function useAgents(options = true) {
2627
2721
  const opts = typeof options === "boolean" ? { autoFetch: options } : options;
2628
2722
  const { autoFetch = true, page, limit, search, category, scope } = opts;
2629
2723
  const { fetchWithAuth } = usePersonaContext();
2630
- const [agents, setAgents] = (0, import_react9.useState)([]);
2631
- const [pagination, setPagination] = (0, import_react9.useState)({
2724
+ const [agents, setAgents] = (0, import_react10.useState)([]);
2725
+ const [pagination, setPagination] = (0, import_react10.useState)({
2632
2726
  total: 0,
2633
2727
  page: page ?? 1,
2634
2728
  limit: limit ?? 20,
2635
2729
  pages: 0
2636
2730
  });
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 () => {
2731
+ const [isLoading, setIsLoading] = (0, import_react10.useState)(false);
2732
+ const [error, setError] = (0, import_react10.useState)(null);
2733
+ const fetchAgents = (0, import_react10.useCallback)(async () => {
2640
2734
  setIsLoading(true);
2641
2735
  setError(null);
2642
2736
  try {
@@ -2664,7 +2758,7 @@ function useAgents(options = true) {
2664
2758
  setIsLoading(false);
2665
2759
  }
2666
2760
  }, [fetchWithAuth, page, limit, search, category, scope]);
2667
- const getAgent = (0, import_react9.useCallback)(
2761
+ const getAgent = (0, import_react10.useCallback)(
2668
2762
  async (agentId) => {
2669
2763
  const res = await fetchWithAuth(`/agents/${agentId}`);
2670
2764
  if (!res.ok) throw new Error(`Failed to fetch agent: ${res.statusText}`);
@@ -2672,7 +2766,7 @@ function useAgents(options = true) {
2672
2766
  },
2673
2767
  [fetchWithAuth]
2674
2768
  );
2675
- const createAgent = (0, import_react9.useCallback)(
2769
+ const createAgent = (0, import_react10.useCallback)(
2676
2770
  async (input) => {
2677
2771
  setError(null);
2678
2772
  try {
@@ -2696,7 +2790,7 @@ function useAgents(options = true) {
2696
2790
  },
2697
2791
  [fetchWithAuth]
2698
2792
  );
2699
- const updateAgent = (0, import_react9.useCallback)(
2793
+ const updateAgent = (0, import_react10.useCallback)(
2700
2794
  async (agentId, input) => {
2701
2795
  setError(null);
2702
2796
  try {
@@ -2720,7 +2814,7 @@ function useAgents(options = true) {
2720
2814
  },
2721
2815
  [fetchWithAuth]
2722
2816
  );
2723
- const deleteAgent = (0, import_react9.useCallback)(
2817
+ const deleteAgent = (0, import_react10.useCallback)(
2724
2818
  async (agentId) => {
2725
2819
  setError(null);
2726
2820
  try {
@@ -2738,7 +2832,7 @@ function useAgents(options = true) {
2738
2832
  },
2739
2833
  [fetchWithAuth]
2740
2834
  );
2741
- const bulkDeleteAgents = (0, import_react9.useCallback)(
2835
+ const bulkDeleteAgents = (0, import_react10.useCallback)(
2742
2836
  async (ids) => {
2743
2837
  setError(null);
2744
2838
  try {
@@ -2763,7 +2857,7 @@ function useAgents(options = true) {
2763
2857
  },
2764
2858
  [fetchWithAuth]
2765
2859
  );
2766
- (0, import_react9.useEffect)(() => {
2860
+ (0, import_react10.useEffect)(() => {
2767
2861
  if (autoFetch) void fetchAgents();
2768
2862
  }, [autoFetch, fetchAgents]);
2769
2863
  return {
@@ -2781,13 +2875,13 @@ function useAgents(options = true) {
2781
2875
  }
2782
2876
 
2783
2877
  // src/hooks/useConnection.ts
2784
- var import_react10 = require("react");
2878
+ var import_react11 = require("react");
2785
2879
  function useConnection(autoCheck = true) {
2786
2880
  const { fetchWithAuth } = usePersonaContext();
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 () => {
2881
+ const [health, setHealth] = (0, import_react11.useState)(null);
2882
+ const [isConnected, setIsConnected] = (0, import_react11.useState)(false);
2883
+ const [isLoading, setIsLoading] = (0, import_react11.useState)(false);
2884
+ const checkHealth = (0, import_react11.useCallback)(async () => {
2791
2885
  setIsLoading(true);
2792
2886
  try {
2793
2887
  const res = await fetchWithAuth("/health");
@@ -2806,7 +2900,7 @@ function useConnection(autoCheck = true) {
2806
2900
  setIsLoading(false);
2807
2901
  }
2808
2902
  }, [fetchWithAuth]);
2809
- (0, import_react10.useEffect)(() => {
2903
+ (0, import_react11.useEffect)(() => {
2810
2904
  if (autoCheck) {
2811
2905
  void checkHealth();
2812
2906
  }
@@ -2820,15 +2914,15 @@ function useConnection(autoCheck = true) {
2820
2914
  }
2821
2915
 
2822
2916
  // src/hooks/useMcpConnections.ts
2823
- var import_react11 = require("react");
2917
+ var import_react12 = require("react");
2824
2918
  function useMcpConnections(options = {}) {
2825
2919
  const { defaultAgentId, fetchWithAuth } = usePersonaContext();
2826
2920
  const agentId = options.agentId ?? defaultAgentId;
2827
2921
  const autoFetch = options.autoFetch ?? true;
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 () => {
2922
+ const [connections, setConnections] = (0, import_react12.useState)([]);
2923
+ const [isLoading, setIsLoading] = (0, import_react12.useState)(false);
2924
+ const [error, setError] = (0, import_react12.useState)(null);
2925
+ const fetchConnections = (0, import_react12.useCallback)(async () => {
2832
2926
  if (!agentId) return [];
2833
2927
  setIsLoading(true);
2834
2928
  setError(null);
@@ -2852,8 +2946,8 @@ function useMcpConnections(options = {}) {
2852
2946
  setIsLoading(false);
2853
2947
  }
2854
2948
  }, [agentId, fetchWithAuth, options.returnTo]);
2855
- const [isDisconnecting, setIsDisconnecting] = (0, import_react11.useState)(false);
2856
- const disconnect = (0, import_react11.useCallback)(
2949
+ const [isDisconnecting, setIsDisconnecting] = (0, import_react12.useState)(false);
2950
+ const disconnect = (0, import_react12.useCallback)(
2857
2951
  async (mcpId) => {
2858
2952
  setIsDisconnecting(true);
2859
2953
  setError(null);
@@ -2879,7 +2973,7 @@ function useMcpConnections(options = {}) {
2879
2973
  },
2880
2974
  [fetchWithAuth, fetchConnections]
2881
2975
  );
2882
- (0, import_react11.useEffect)(() => {
2976
+ (0, import_react12.useEffect)(() => {
2883
2977
  if (autoFetch) void fetchConnections();
2884
2978
  }, [autoFetch, fetchConnections]);
2885
2979
  return {
@@ -2895,11 +2989,11 @@ function useMcpConnections(options = {}) {
2895
2989
  }
2896
2990
 
2897
2991
  // src/hooks/useMcp.ts
2898
- var import_react12 = require("react");
2992
+ var import_react13 = require("react");
2899
2993
  function useMcp(options = {}) {
2900
2994
  const { fetchWithAuth } = usePersonaContext();
2901
2995
  const defaultMcpId = options.mcpId;
2902
- const readResource = (0, import_react12.useCallback)(
2996
+ const readResource = (0, import_react13.useCallback)(
2903
2997
  async (uri, mcpId) => {
2904
2998
  const id = mcpId ?? defaultMcpId;
2905
2999
  if (!id) throw new Error("MCP server ID is required to read resource");
@@ -2913,7 +3007,7 @@ function useMcp(options = {}) {
2913
3007
  },
2914
3008
  [fetchWithAuth, defaultMcpId]
2915
3009
  );
2916
- const callTool = (0, import_react12.useCallback)(
3010
+ const callTool = (0, import_react13.useCallback)(
2917
3011
  async (name, args, mcpId) => {
2918
3012
  const id = mcpId ?? defaultMcpId;
2919
3013
  if (!id) throw new Error("MCP server ID is required to call tool");
@@ -2936,20 +3030,20 @@ function useMcp(options = {}) {
2936
3030
  }
2937
3031
 
2938
3032
  // src/hooks/useSkills.ts
2939
- var import_react13 = require("react");
3033
+ var import_react14 = require("react");
2940
3034
  function useSkills(options = {}) {
2941
3035
  const { autoFetch = true, page, limit, search, scope } = options;
2942
3036
  const { fetchWithAuth } = usePersonaContext();
2943
- const [skills, setSkills] = (0, import_react13.useState)([]);
2944
- const [pagination, setPagination] = (0, import_react13.useState)({
3037
+ const [skills, setSkills] = (0, import_react14.useState)([]);
3038
+ const [pagination, setPagination] = (0, import_react14.useState)({
2945
3039
  total: 0,
2946
3040
  page: page ?? 1,
2947
3041
  limit: limit ?? 20,
2948
3042
  pages: 0
2949
3043
  });
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 () => {
3044
+ const [isLoading, setIsLoading] = (0, import_react14.useState)(false);
3045
+ const [error, setError] = (0, import_react14.useState)(null);
3046
+ const fetchSkills = (0, import_react14.useCallback)(async () => {
2953
3047
  setIsLoading(true);
2954
3048
  setError(null);
2955
3049
  try {
@@ -2976,7 +3070,7 @@ function useSkills(options = {}) {
2976
3070
  setIsLoading(false);
2977
3071
  }
2978
3072
  }, [fetchWithAuth, page, limit, search, scope]);
2979
- const getSkill = (0, import_react13.useCallback)(
3073
+ const getSkill = (0, import_react14.useCallback)(
2980
3074
  async (skillId) => {
2981
3075
  const res = await fetchWithAuth(`/skills/${skillId}`);
2982
3076
  if (!res.ok) throw new Error(`Failed to fetch skill: ${res.statusText}`);
@@ -2984,7 +3078,7 @@ function useSkills(options = {}) {
2984
3078
  },
2985
3079
  [fetchWithAuth]
2986
3080
  );
2987
- const createSkill = (0, import_react13.useCallback)(
3081
+ const createSkill = (0, import_react14.useCallback)(
2988
3082
  async (input) => {
2989
3083
  setError(null);
2990
3084
  try {
@@ -3008,7 +3102,7 @@ function useSkills(options = {}) {
3008
3102
  },
3009
3103
  [fetchWithAuth]
3010
3104
  );
3011
- const updateSkill = (0, import_react13.useCallback)(
3105
+ const updateSkill = (0, import_react14.useCallback)(
3012
3106
  async (skillId, input) => {
3013
3107
  setError(null);
3014
3108
  try {
@@ -3032,7 +3126,7 @@ function useSkills(options = {}) {
3032
3126
  },
3033
3127
  [fetchWithAuth]
3034
3128
  );
3035
- const deleteSkill = (0, import_react13.useCallback)(
3129
+ const deleteSkill = (0, import_react14.useCallback)(
3036
3130
  async (skillId) => {
3037
3131
  setError(null);
3038
3132
  try {
@@ -3050,7 +3144,7 @@ function useSkills(options = {}) {
3050
3144
  },
3051
3145
  [fetchWithAuth]
3052
3146
  );
3053
- const bulkDeleteSkills = (0, import_react13.useCallback)(
3147
+ const bulkDeleteSkills = (0, import_react14.useCallback)(
3054
3148
  async (ids) => {
3055
3149
  setError(null);
3056
3150
  try {
@@ -3075,7 +3169,7 @@ function useSkills(options = {}) {
3075
3169
  },
3076
3170
  [fetchWithAuth]
3077
3171
  );
3078
- const getSkillUsage = (0, import_react13.useCallback)(
3172
+ const getSkillUsage = (0, import_react14.useCallback)(
3079
3173
  async (skillId) => {
3080
3174
  const res = await fetchWithAuth(`/skills/${skillId}/usage`);
3081
3175
  if (!res.ok) throw new Error(`Failed to fetch skill usage: ${res.statusText}`);
@@ -3083,7 +3177,7 @@ function useSkills(options = {}) {
3083
3177
  },
3084
3178
  [fetchWithAuth]
3085
3179
  );
3086
- (0, import_react13.useEffect)(() => {
3180
+ (0, import_react14.useEffect)(() => {
3087
3181
  if (autoFetch) void fetchSkills();
3088
3182
  }, [autoFetch, fetchSkills]);
3089
3183
  return {
@@ -3102,20 +3196,20 @@ function useSkills(options = {}) {
3102
3196
  }
3103
3197
 
3104
3198
  // src/hooks/useRcpSources.ts
3105
- var import_react14 = require("react");
3199
+ var import_react15 = require("react");
3106
3200
  function useRcpSources(options = {}) {
3107
3201
  const { autoFetch = true, page, limit, search } = options;
3108
3202
  const { fetchWithAuth } = usePersonaContext();
3109
- const [rcpSources, setRcpSources] = (0, import_react14.useState)([]);
3110
- const [pagination, setPagination] = (0, import_react14.useState)({
3203
+ const [rcpSources, setRcpSources] = (0, import_react15.useState)([]);
3204
+ const [pagination, setPagination] = (0, import_react15.useState)({
3111
3205
  total: 0,
3112
3206
  page: page ?? 1,
3113
3207
  limit: limit ?? 20,
3114
3208
  pages: 0
3115
3209
  });
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 () => {
3210
+ const [isLoading, setIsLoading] = (0, import_react15.useState)(false);
3211
+ const [error, setError] = (0, import_react15.useState)(null);
3212
+ const fetchRcpSources = (0, import_react15.useCallback)(async () => {
3119
3213
  setIsLoading(true);
3120
3214
  setError(null);
3121
3215
  try {
@@ -3141,7 +3235,7 @@ function useRcpSources(options = {}) {
3141
3235
  setIsLoading(false);
3142
3236
  }
3143
3237
  }, [fetchWithAuth, page, limit, search]);
3144
- const getRcpSource = (0, import_react14.useCallback)(
3238
+ const getRcpSource = (0, import_react15.useCallback)(
3145
3239
  async (sourceId) => {
3146
3240
  const res = await fetchWithAuth(`/rcp-sources/${sourceId}`);
3147
3241
  if (!res.ok) throw new Error(`Failed to fetch RCP source: ${res.statusText}`);
@@ -3149,7 +3243,7 @@ function useRcpSources(options = {}) {
3149
3243
  },
3150
3244
  [fetchWithAuth]
3151
3245
  );
3152
- const createRcpSource = (0, import_react14.useCallback)(
3246
+ const createRcpSource = (0, import_react15.useCallback)(
3153
3247
  async (input) => {
3154
3248
  setError(null);
3155
3249
  try {
@@ -3173,7 +3267,7 @@ function useRcpSources(options = {}) {
3173
3267
  },
3174
3268
  [fetchWithAuth]
3175
3269
  );
3176
- const updateRcpSource = (0, import_react14.useCallback)(
3270
+ const updateRcpSource = (0, import_react15.useCallback)(
3177
3271
  async (sourceId, input) => {
3178
3272
  setError(null);
3179
3273
  try {
@@ -3197,7 +3291,7 @@ function useRcpSources(options = {}) {
3197
3291
  },
3198
3292
  [fetchWithAuth]
3199
3293
  );
3200
- const deleteRcpSource = (0, import_react14.useCallback)(
3294
+ const deleteRcpSource = (0, import_react15.useCallback)(
3201
3295
  async (sourceId) => {
3202
3296
  setError(null);
3203
3297
  try {
@@ -3215,7 +3309,7 @@ function useRcpSources(options = {}) {
3215
3309
  },
3216
3310
  [fetchWithAuth]
3217
3311
  );
3218
- const bulkDeleteRcpSources = (0, import_react14.useCallback)(
3312
+ const bulkDeleteRcpSources = (0, import_react15.useCallback)(
3219
3313
  async (ids) => {
3220
3314
  setError(null);
3221
3315
  try {
@@ -3240,7 +3334,7 @@ function useRcpSources(options = {}) {
3240
3334
  },
3241
3335
  [fetchWithAuth]
3242
3336
  );
3243
- const getRcpSourceUsage = (0, import_react14.useCallback)(
3337
+ const getRcpSourceUsage = (0, import_react15.useCallback)(
3244
3338
  async (sourceId) => {
3245
3339
  const res = await fetchWithAuth(`/rcp-sources/${sourceId}/usage`);
3246
3340
  if (!res.ok) throw new Error(`Failed to fetch RCP source usage: ${res.statusText}`);
@@ -3248,7 +3342,7 @@ function useRcpSources(options = {}) {
3248
3342
  },
3249
3343
  [fetchWithAuth]
3250
3344
  );
3251
- const testRcpSourceConnection = (0, import_react14.useCallback)(
3345
+ const testRcpSourceConnection = (0, import_react15.useCallback)(
3252
3346
  async (sourceId) => {
3253
3347
  setError(null);
3254
3348
  try {
@@ -3272,7 +3366,7 @@ function useRcpSources(options = {}) {
3272
3366
  },
3273
3367
  [fetchWithAuth]
3274
3368
  );
3275
- (0, import_react14.useEffect)(() => {
3369
+ (0, import_react15.useEffect)(() => {
3276
3370
  if (autoFetch) void fetchRcpSources();
3277
3371
  }, [autoFetch, fetchRcpSources]);
3278
3372
  return {
@@ -3292,21 +3386,21 @@ function useRcpSources(options = {}) {
3292
3386
  }
3293
3387
 
3294
3388
  // src/hooks/useKnowledgeBases.ts
3295
- var import_react15 = require("react");
3389
+ var import_react16 = require("react");
3296
3390
  function useKnowledgeBases(options = {}) {
3297
3391
  const { autoFetch = true, page, limit, search, scope } = options;
3298
3392
  const { fetchWithAuth } = usePersonaContext();
3299
- const [knowledgeBases, setKnowledgeBases] = (0, import_react15.useState)([]);
3300
- const [pagination, setPagination] = (0, import_react15.useState)({
3393
+ const [knowledgeBases, setKnowledgeBases] = (0, import_react16.useState)([]);
3394
+ const [pagination, setPagination] = (0, import_react16.useState)({
3301
3395
  total: 0,
3302
3396
  page: page ?? 1,
3303
3397
  limit: limit ?? 20,
3304
3398
  pages: 0
3305
3399
  });
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 () => {
3400
+ const [isLoading, setIsLoading] = (0, import_react16.useState)(false);
3401
+ const [isUploading, setIsUploading] = (0, import_react16.useState)(false);
3402
+ const [error, setError] = (0, import_react16.useState)(null);
3403
+ const fetchKnowledgeBases = (0, import_react16.useCallback)(async () => {
3310
3404
  setIsLoading(true);
3311
3405
  setError(null);
3312
3406
  try {
@@ -3333,7 +3427,7 @@ function useKnowledgeBases(options = {}) {
3333
3427
  setIsLoading(false);
3334
3428
  }
3335
3429
  }, [fetchWithAuth, page, limit, search, scope]);
3336
- const getKnowledgeBase = (0, import_react15.useCallback)(
3430
+ const getKnowledgeBase = (0, import_react16.useCallback)(
3337
3431
  async (kbId) => {
3338
3432
  const res = await fetchWithAuth(`/knowledge/${kbId}`);
3339
3433
  if (!res.ok) throw new Error(`Failed to fetch knowledge base: ${res.statusText}`);
@@ -3341,7 +3435,7 @@ function useKnowledgeBases(options = {}) {
3341
3435
  },
3342
3436
  [fetchWithAuth]
3343
3437
  );
3344
- const createKnowledgeBase = (0, import_react15.useCallback)(
3438
+ const createKnowledgeBase = (0, import_react16.useCallback)(
3345
3439
  async (input) => {
3346
3440
  setError(null);
3347
3441
  try {
@@ -3365,7 +3459,7 @@ function useKnowledgeBases(options = {}) {
3365
3459
  },
3366
3460
  [fetchWithAuth]
3367
3461
  );
3368
- const updateKnowledgeBase = (0, import_react15.useCallback)(
3462
+ const updateKnowledgeBase = (0, import_react16.useCallback)(
3369
3463
  async (kbId, input) => {
3370
3464
  setError(null);
3371
3465
  try {
@@ -3389,7 +3483,7 @@ function useKnowledgeBases(options = {}) {
3389
3483
  },
3390
3484
  [fetchWithAuth]
3391
3485
  );
3392
- const deleteKnowledgeBase = (0, import_react15.useCallback)(
3486
+ const deleteKnowledgeBase = (0, import_react16.useCallback)(
3393
3487
  async (kbId) => {
3394
3488
  setError(null);
3395
3489
  try {
@@ -3407,7 +3501,7 @@ function useKnowledgeBases(options = {}) {
3407
3501
  },
3408
3502
  [fetchWithAuth]
3409
3503
  );
3410
- const bulkDeleteKnowledgeBases = (0, import_react15.useCallback)(
3504
+ const bulkDeleteKnowledgeBases = (0, import_react16.useCallback)(
3411
3505
  async (ids) => {
3412
3506
  setError(null);
3413
3507
  try {
@@ -3432,7 +3526,7 @@ function useKnowledgeBases(options = {}) {
3432
3526
  },
3433
3527
  [fetchWithAuth]
3434
3528
  );
3435
- const getKnowledgeBaseUsage = (0, import_react15.useCallback)(
3529
+ const getKnowledgeBaseUsage = (0, import_react16.useCallback)(
3436
3530
  async (kbId) => {
3437
3531
  const res = await fetchWithAuth(`/knowledge/${kbId}/usage`);
3438
3532
  if (!res.ok) throw new Error(`Failed to fetch knowledge base usage: ${res.statusText}`);
@@ -3440,7 +3534,7 @@ function useKnowledgeBases(options = {}) {
3440
3534
  },
3441
3535
  [fetchWithAuth]
3442
3536
  );
3443
- const uploadDocuments = (0, import_react15.useCallback)(
3537
+ const uploadDocuments = (0, import_react16.useCallback)(
3444
3538
  async (kbId, files) => {
3445
3539
  setIsUploading(true);
3446
3540
  setError(null);
@@ -3482,7 +3576,7 @@ function useKnowledgeBases(options = {}) {
3482
3576
  },
3483
3577
  [fetchWithAuth]
3484
3578
  );
3485
- const listDocuments = (0, import_react15.useCallback)(
3579
+ const listDocuments = (0, import_react16.useCallback)(
3486
3580
  async (kbId) => {
3487
3581
  const res = await fetchWithAuth(`/knowledge/${kbId}/documents`);
3488
3582
  if (!res.ok) throw new Error(`Failed to list documents: ${res.statusText}`);
@@ -3490,7 +3584,7 @@ function useKnowledgeBases(options = {}) {
3490
3584
  },
3491
3585
  [fetchWithAuth]
3492
3586
  );
3493
- const deleteDocument = (0, import_react15.useCallback)(
3587
+ const deleteDocument = (0, import_react16.useCallback)(
3494
3588
  async (kbId, sourceName) => {
3495
3589
  setError(null);
3496
3590
  try {
@@ -3517,7 +3611,7 @@ function useKnowledgeBases(options = {}) {
3517
3611
  },
3518
3612
  [fetchWithAuth]
3519
3613
  );
3520
- const searchKnowledgeBase = (0, import_react15.useCallback)(
3614
+ const searchKnowledgeBase = (0, import_react16.useCallback)(
3521
3615
  async (kbId, query, opts) => {
3522
3616
  const res = await fetchWithAuth(`/knowledge/${kbId}/search`, {
3523
3617
  method: "POST",
@@ -3532,7 +3626,7 @@ function useKnowledgeBases(options = {}) {
3532
3626
  },
3533
3627
  [fetchWithAuth]
3534
3628
  );
3535
- (0, import_react15.useEffect)(() => {
3629
+ (0, import_react16.useEffect)(() => {
3536
3630
  if (autoFetch) void fetchKnowledgeBases();
3537
3631
  }, [autoFetch, fetchKnowledgeBases]);
3538
3632
  return {
@@ -3556,20 +3650,20 @@ function useKnowledgeBases(options = {}) {
3556
3650
  }
3557
3651
 
3558
3652
  // src/hooks/useMcpAdmin.ts
3559
- var import_react16 = require("react");
3653
+ var import_react17 = require("react");
3560
3654
  function useMcpAdmin(options = {}) {
3561
3655
  const { autoFetch = true, page, limit, search } = options;
3562
3656
  const { fetchWithAuth } = usePersonaContext();
3563
- const [mcps, setMcps] = (0, import_react16.useState)([]);
3564
- const [pagination, setPagination] = (0, import_react16.useState)({
3657
+ const [mcps, setMcps] = (0, import_react17.useState)([]);
3658
+ const [pagination, setPagination] = (0, import_react17.useState)({
3565
3659
  total: 0,
3566
3660
  page: page ?? 1,
3567
3661
  limit: limit ?? 20,
3568
3662
  pages: 0
3569
3663
  });
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 () => {
3664
+ const [isLoading, setIsLoading] = (0, import_react17.useState)(false);
3665
+ const [error, setError] = (0, import_react17.useState)(null);
3666
+ const fetchMcps = (0, import_react17.useCallback)(async () => {
3573
3667
  setIsLoading(true);
3574
3668
  setError(null);
3575
3669
  try {
@@ -3595,7 +3689,7 @@ function useMcpAdmin(options = {}) {
3595
3689
  setIsLoading(false);
3596
3690
  }
3597
3691
  }, [fetchWithAuth, page, limit, search]);
3598
- const getMcp = (0, import_react16.useCallback)(
3692
+ const getMcp = (0, import_react17.useCallback)(
3599
3693
  async (mcpId) => {
3600
3694
  const res = await fetchWithAuth(`/mcps/${mcpId}`);
3601
3695
  if (!res.ok) throw new Error(`Failed to fetch MCP: ${res.statusText}`);
@@ -3603,7 +3697,7 @@ function useMcpAdmin(options = {}) {
3603
3697
  },
3604
3698
  [fetchWithAuth]
3605
3699
  );
3606
- const createMcp = (0, import_react16.useCallback)(
3700
+ const createMcp = (0, import_react17.useCallback)(
3607
3701
  async (input) => {
3608
3702
  setError(null);
3609
3703
  try {
@@ -3627,7 +3721,7 @@ function useMcpAdmin(options = {}) {
3627
3721
  },
3628
3722
  [fetchWithAuth]
3629
3723
  );
3630
- const updateMcp = (0, import_react16.useCallback)(
3724
+ const updateMcp = (0, import_react17.useCallback)(
3631
3725
  async (mcpId, input) => {
3632
3726
  setError(null);
3633
3727
  try {
@@ -3651,7 +3745,7 @@ function useMcpAdmin(options = {}) {
3651
3745
  },
3652
3746
  [fetchWithAuth]
3653
3747
  );
3654
- const deleteMcp = (0, import_react16.useCallback)(
3748
+ const deleteMcp = (0, import_react17.useCallback)(
3655
3749
  async (mcpId) => {
3656
3750
  setError(null);
3657
3751
  try {
@@ -3669,7 +3763,7 @@ function useMcpAdmin(options = {}) {
3669
3763
  },
3670
3764
  [fetchWithAuth]
3671
3765
  );
3672
- const bulkDeleteMcps = (0, import_react16.useCallback)(
3766
+ const bulkDeleteMcps = (0, import_react17.useCallback)(
3673
3767
  async (ids) => {
3674
3768
  setError(null);
3675
3769
  try {
@@ -3694,7 +3788,7 @@ function useMcpAdmin(options = {}) {
3694
3788
  },
3695
3789
  [fetchWithAuth]
3696
3790
  );
3697
- const testConnection = (0, import_react16.useCallback)(
3791
+ const testConnection = (0, import_react17.useCallback)(
3698
3792
  async (mcpId) => {
3699
3793
  setError(null);
3700
3794
  try {
@@ -3718,7 +3812,7 @@ function useMcpAdmin(options = {}) {
3718
3812
  },
3719
3813
  [fetchWithAuth]
3720
3814
  );
3721
- (0, import_react16.useEffect)(() => {
3815
+ (0, import_react17.useEffect)(() => {
3722
3816
  if (autoFetch) void fetchMcps();
3723
3817
  }, [autoFetch, fetchMcps]);
3724
3818
  return {
@@ -3737,21 +3831,21 @@ function useMcpAdmin(options = {}) {
3737
3831
  }
3738
3832
 
3739
3833
  // src/hooks/useWorkflows.ts
3740
- var import_react17 = require("react");
3834
+ var import_react18 = require("react");
3741
3835
  function useWorkflows(options) {
3742
3836
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
3743
3837
  const { autoFetch = true, search, scope, visibility, isEnabled, page, limit } = opts;
3744
3838
  const { fetchWithAuth } = usePersonaContext();
3745
- const [workflows, setWorkflows] = (0, import_react17.useState)([]);
3746
- const [pagination, setPagination] = (0, import_react17.useState)({
3839
+ const [workflows, setWorkflows] = (0, import_react18.useState)([]);
3840
+ const [pagination, setPagination] = (0, import_react18.useState)({
3747
3841
  page: page ?? 1,
3748
3842
  limit: limit ?? 20,
3749
3843
  total: 0,
3750
3844
  totalPages: 0
3751
3845
  });
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 () => {
3846
+ const [isLoading, setIsLoading] = (0, import_react18.useState)(false);
3847
+ const [error, setError] = (0, import_react18.useState)(null);
3848
+ const fetchWorkflows = (0, import_react18.useCallback)(async () => {
3755
3849
  setIsLoading(true);
3756
3850
  setError(null);
3757
3851
  try {
@@ -3797,7 +3891,7 @@ function useWorkflows(options) {
3797
3891
  setIsLoading(false);
3798
3892
  }
3799
3893
  }, [fetchWithAuth, search, scope, visibility, isEnabled, page, limit]);
3800
- const createWorkflow = (0, import_react17.useCallback)(
3894
+ const createWorkflow = (0, import_react18.useCallback)(
3801
3895
  async (input) => {
3802
3896
  setError(null);
3803
3897
  try {
@@ -3821,7 +3915,7 @@ function useWorkflows(options) {
3821
3915
  },
3822
3916
  [fetchWithAuth]
3823
3917
  );
3824
- (0, import_react17.useEffect)(() => {
3918
+ (0, import_react18.useEffect)(() => {
3825
3919
  if (autoFetch) {
3826
3920
  void fetchWorkflows();
3827
3921
  }
@@ -3837,17 +3931,17 @@ function useWorkflows(options) {
3837
3931
  }
3838
3932
 
3839
3933
  // src/hooks/useWorkflow.ts
3840
- var import_react18 = require("react");
3934
+ var import_react19 = require("react");
3841
3935
  function useWorkflow(workflowId, options) {
3842
3936
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
3843
3937
  const { autoFetch = true } = opts;
3844
3938
  const { fetchWithAuth } = usePersonaContext();
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 () => {
3939
+ const [workflow, setWorkflow] = (0, import_react19.useState)(null);
3940
+ const [versions, setVersions] = (0, import_react19.useState)([]);
3941
+ const [mermaid, setMermaid] = (0, import_react19.useState)(null);
3942
+ const [isLoading, setIsLoading] = (0, import_react19.useState)(false);
3943
+ const [error, setError] = (0, import_react19.useState)(null);
3944
+ const fetchWorkflow = (0, import_react19.useCallback)(async () => {
3851
3945
  if (!workflowId) return null;
3852
3946
  setIsLoading(true);
3853
3947
  setError(null);
@@ -3867,7 +3961,7 @@ function useWorkflow(workflowId, options) {
3867
3961
  setIsLoading(false);
3868
3962
  }
3869
3963
  }, [fetchWithAuth, workflowId]);
3870
- const fetchVersions = (0, import_react18.useCallback)(async () => {
3964
+ const fetchVersions = (0, import_react19.useCallback)(async () => {
3871
3965
  if (!workflowId) return [];
3872
3966
  try {
3873
3967
  const res = await fetchWithAuth(`/workflows/${workflowId}/versions`);
@@ -3880,7 +3974,7 @@ function useWorkflow(workflowId, options) {
3880
3974
  return [];
3881
3975
  }
3882
3976
  }, [fetchWithAuth, workflowId]);
3883
- const getVersion = (0, import_react18.useCallback)(
3977
+ const getVersion = (0, import_react19.useCallback)(
3884
3978
  async (version) => {
3885
3979
  if (!workflowId) throw new Error("Workflow ID is required");
3886
3980
  const res = await fetchWithAuth(`/workflows/${workflowId}/versions/${version}`);
@@ -3891,7 +3985,7 @@ function useWorkflow(workflowId, options) {
3891
3985
  },
3892
3986
  [fetchWithAuth, workflowId]
3893
3987
  );
3894
- const fetchMermaid = (0, import_react18.useCallback)(async () => {
3988
+ const fetchMermaid = (0, import_react19.useCallback)(async () => {
3895
3989
  if (!workflowId) return "";
3896
3990
  try {
3897
3991
  const res = await fetchWithAuth(`/workflows/${workflowId}/mermaid`);
@@ -3904,7 +3998,7 @@ function useWorkflow(workflowId, options) {
3904
3998
  return "";
3905
3999
  }
3906
4000
  }, [fetchWithAuth, workflowId]);
3907
- const updateWorkflow = (0, import_react18.useCallback)(
4001
+ const updateWorkflow = (0, import_react19.useCallback)(
3908
4002
  async (input) => {
3909
4003
  if (!workflowId) throw new Error("Workflow ID is required");
3910
4004
  setError(null);
@@ -3923,7 +4017,7 @@ function useWorkflow(workflowId, options) {
3923
4017
  },
3924
4018
  [fetchWithAuth, workflowId]
3925
4019
  );
3926
- const saveDraft = (0, import_react18.useCallback)(
4020
+ const saveDraft = (0, import_react19.useCallback)(
3927
4021
  async (draft) => {
3928
4022
  if (!workflowId) throw new Error("Workflow ID is required");
3929
4023
  setError(null);
@@ -3942,7 +4036,7 @@ function useWorkflow(workflowId, options) {
3942
4036
  },
3943
4037
  [fetchWithAuth, workflowId]
3944
4038
  );
3945
- const publish = (0, import_react18.useCallback)(async () => {
4039
+ const publish = (0, import_react19.useCallback)(async () => {
3946
4040
  if (!workflowId) throw new Error("Workflow ID is required");
3947
4041
  setError(null);
3948
4042
  const res = await fetchWithAuth(`/workflows/${workflowId}/publish`, {
@@ -3957,7 +4051,7 @@ function useWorkflow(workflowId, options) {
3957
4051
  void fetchVersions();
3958
4052
  return versionResult;
3959
4053
  }, [fetchWithAuth, workflowId, fetchWorkflow, fetchVersions]);
3960
- const deleteWorkflow = (0, import_react18.useCallback)(async () => {
4054
+ const deleteWorkflow = (0, import_react19.useCallback)(async () => {
3961
4055
  if (!workflowId) throw new Error("Workflow ID is required");
3962
4056
  setError(null);
3963
4057
  const res = await fetchWithAuth(`/workflows/${workflowId}`, {
@@ -3968,7 +4062,7 @@ function useWorkflow(workflowId, options) {
3968
4062
  }
3969
4063
  setWorkflow(null);
3970
4064
  }, [fetchWithAuth, workflowId]);
3971
- (0, import_react18.useEffect)(() => {
4065
+ (0, import_react19.useEffect)(() => {
3972
4066
  if (autoFetch && workflowId) {
3973
4067
  void fetchWorkflow();
3974
4068
  }
@@ -3991,25 +4085,25 @@ function useWorkflow(workflowId, options) {
3991
4085
  }
3992
4086
 
3993
4087
  // src/hooks/useWorkflowStream.ts
3994
- var import_react19 = require("react");
4088
+ var import_react20 = require("react");
3995
4089
  function useWorkflowStream(workflowId, options) {
3996
4090
  const { baseUrl, getAuthToken, fetchWithAuth, logger } = usePersonaContext();
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)(
4091
+ const [status, setStatus] = (0, import_react20.useState)("idle");
4092
+ const [runId, setRunId] = (0, import_react20.useState)(null);
4093
+ const [activeNodeId, setActiveNodeId] = (0, import_react20.useState)(null);
4094
+ const [nodeRuns, setNodeRuns] = (0, import_react20.useState)(
4001
4095
  {}
4002
4096
  );
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);
4097
+ const [text, setText] = (0, import_react20.useState)("");
4098
+ const [output, setOutput] = (0, import_react20.useState)(null);
4099
+ const [error, setError] = (0, import_react20.useState)(null);
4100
+ const [events, setEvents] = (0, import_react20.useState)([]);
4101
+ const abortControllerRef = (0, import_react20.useRef)(null);
4102
+ const currentRunIdRef = (0, import_react20.useRef)(null);
4009
4103
  currentRunIdRef.current = runId;
4010
- const optionsRef = (0, import_react19.useRef)(options);
4104
+ const optionsRef = (0, import_react20.useRef)(options);
4011
4105
  optionsRef.current = options;
4012
- const cancel = (0, import_react19.useCallback)(async () => {
4106
+ const cancel = (0, import_react20.useCallback)(async () => {
4013
4107
  if (abortControllerRef.current) {
4014
4108
  abortControllerRef.current.abort();
4015
4109
  abortControllerRef.current = null;
@@ -4030,7 +4124,7 @@ function useWorkflowStream(workflowId, options) {
4030
4124
  setStatus("cancelled");
4031
4125
  setActiveNodeId(null);
4032
4126
  }, [fetchWithAuth, logger]);
4033
- const reset = (0, import_react19.useCallback)(() => {
4127
+ const reset = (0, import_react20.useCallback)(() => {
4034
4128
  if (abortControllerRef.current) {
4035
4129
  abortControllerRef.current.abort();
4036
4130
  abortControllerRef.current = null;
@@ -4044,7 +4138,7 @@ function useWorkflowStream(workflowId, options) {
4044
4138
  setError(null);
4045
4139
  setEvents([]);
4046
4140
  }, []);
4047
- const processStream = (0, import_react19.useCallback)(
4141
+ const processStream = (0, import_react20.useCallback)(
4048
4142
  async (url, method, body, targetRunId) => {
4049
4143
  if (abortControllerRef.current) {
4050
4144
  abortControllerRef.current.abort();
@@ -4209,7 +4303,7 @@ function useWorkflowStream(workflowId, options) {
4209
4303
  },
4210
4304
  [getAuthToken]
4211
4305
  );
4212
- const start = (0, import_react19.useCallback)(
4306
+ const start = (0, import_react20.useCallback)(
4213
4307
  async (input, opts) => {
4214
4308
  const targetWfId = opts?.workflowId || workflowId;
4215
4309
  if (!targetWfId) {
@@ -4230,7 +4324,7 @@ function useWorkflowStream(workflowId, options) {
4230
4324
  },
4231
4325
  [workflowId, baseUrl, processStream]
4232
4326
  );
4233
- const resume = (0, import_react19.useCallback)(
4327
+ const resume = (0, import_react20.useCallback)(
4234
4328
  async (targetRunId, sinceSeq) => {
4235
4329
  if (!targetRunId) {
4236
4330
  throw new Error("Run ID is required to resume stream");
@@ -4243,7 +4337,7 @@ function useWorkflowStream(workflowId, options) {
4243
4337
  },
4244
4338
  [baseUrl, processStream]
4245
4339
  );
4246
- (0, import_react19.useEffect)(() => {
4340
+ (0, import_react20.useEffect)(() => {
4247
4341
  return () => {
4248
4342
  if (abortControllerRef.current) {
4249
4343
  abortControllerRef.current.abort();
@@ -4268,21 +4362,21 @@ function useWorkflowStream(workflowId, options) {
4268
4362
  }
4269
4363
 
4270
4364
  // src/hooks/useWorkflowRuns.ts
4271
- var import_react20 = require("react");
4365
+ var import_react21 = require("react");
4272
4366
  function useWorkflowRuns(workflowId, options) {
4273
4367
  const opts = typeof options === "boolean" ? { autoFetch: options } : options ?? {};
4274
4368
  const { autoFetch = true, page = 1, limit = 20 } = opts;
4275
4369
  const { fetchWithAuth } = usePersonaContext();
4276
- const [runs, setRuns] = (0, import_react20.useState)([]);
4277
- const [pagination, setPagination] = (0, import_react20.useState)({
4370
+ const [runs, setRuns] = (0, import_react21.useState)([]);
4371
+ const [pagination, setPagination] = (0, import_react21.useState)({
4278
4372
  page,
4279
4373
  limit,
4280
4374
  total: 0,
4281
4375
  totalPages: 0
4282
4376
  });
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 () => {
4377
+ const [isLoading, setIsLoading] = (0, import_react21.useState)(false);
4378
+ const [error, setError] = (0, import_react21.useState)(null);
4379
+ const fetchRuns = (0, import_react21.useCallback)(async () => {
4286
4380
  if (!workflowId) return [];
4287
4381
  setIsLoading(true);
4288
4382
  setError(null);
@@ -4314,7 +4408,7 @@ function useWorkflowRuns(workflowId, options) {
4314
4408
  setIsLoading(false);
4315
4409
  }
4316
4410
  }, [fetchWithAuth, workflowId, page, limit]);
4317
- const getRun = (0, import_react20.useCallback)(
4411
+ const getRun = (0, import_react21.useCallback)(
4318
4412
  async (runId) => {
4319
4413
  if (!runId) throw new Error("Run ID is required");
4320
4414
  const res = await fetchWithAuth(`/workflows/runs/${runId}`);
@@ -4325,7 +4419,7 @@ function useWorkflowRuns(workflowId, options) {
4325
4419
  },
4326
4420
  [fetchWithAuth]
4327
4421
  );
4328
- const cancelRun = (0, import_react20.useCallback)(
4422
+ const cancelRun = (0, import_react21.useCallback)(
4329
4423
  async (runId) => {
4330
4424
  if (!runId) throw new Error("Run ID is required");
4331
4425
  const res = await fetchWithAuth(`/workflows/runs/${runId}/cancel`, {
@@ -4340,7 +4434,7 @@ function useWorkflowRuns(workflowId, options) {
4340
4434
  },
4341
4435
  [fetchWithAuth]
4342
4436
  );
4343
- (0, import_react20.useEffect)(() => {
4437
+ (0, import_react21.useEffect)(() => {
4344
4438
  if (autoFetch && workflowId) {
4345
4439
  void fetchRuns();
4346
4440
  }
@@ -4358,7 +4452,7 @@ function useWorkflowRuns(workflowId, options) {
4358
4452
 
4359
4453
  // src/index.ts
4360
4454
  var import_logger2 = require("@personaai/logger");
4361
- var VERSION = "0.17.0";
4455
+ var VERSION = "0.18.1";
4362
4456
  // Annotate the CommonJS export names for ESM import in node:
4363
4457
  0 && (module.exports = {
4364
4458
  ARCHITECT_AGENT_ID,
@@ -4381,6 +4475,7 @@ var VERSION = "0.17.0";
4381
4475
  useMcpAdmin,
4382
4476
  useMcpConnections,
4383
4477
  useMemory,
4478
+ useMessages,
4384
4479
  usePersonaContext,
4385
4480
  useRcpSources,
4386
4481
  useSkills,